@yan_coquoz/react_input

0.1.57 • Public • Published

React Component

  • Author
  • GitHub P14_HRnet_React size GitHub top language GitHub language count

Minimalist input-like components for React.

french translation

Prerequisites

Summary

React Components

  • InputText
  • InputNumber
  • SelectField
  • Button
  • Modale
  • DatePicker
  • ScrollBar

Properties

All properties with a * are required :

InputText

  • idName *: {String} Corresponds to the htmlFor and className.properties of the label, as well as the id and the name of the input.
  • labelName : {String} label value and placeholder content.
  • isRequired : {Boolean} Whether the value is required or not.
  • myClass : {String} component class name.
  • toUpperCase : {Boolean} if you need to upper case label.
  • onChange : {Function} To have a controlled component, allows to retrieve the values of the input: name and value, for each action on the keyboard.
  • value: {String} the value found in the field.
  • placeholder: {String} the placeholder.

to summary


InputNumber

  • idName *: {String} Corresponds to the htmlFor and className properties of the label, as well as the id and the name of the input.
  • labelName : {String} label and placeholder content
  • isRequired : {Boolean} Whether the value is required or not
  • myClass *: {String} component class name
  • mini : {Number} minimum value
  • maxi : {Number} maximum value
  • toUpperCase : {Boolean} if you need to upper case label.
  • onChange : {Function} To have a controlled component, allows to retrieve the values of the input: name and value, for each action on the keyboard.
  • value: {String} the value found in the field.
  • placeholder: {String} the placeholder.

to summary


SelectField

  • options *: {Array of Object || Array} for the option tag, if it 's an Array of Object, it must contain a property name who will be display
  • labelName : {String} instead of label
  • isRequired : {Boolean} Whether the value is required or not.
  • idName *: {String} Corresponds to the htmlFor and className properties of the label, as well as the id and the name of the input.
  • onChange : {Function} to get the event.
  • toUpperCase : {Boolean} if you need to upper case label
  • optValue : {Boolean} Render 'Options' for first value in select area. If true, the first value will be options, but if isRequired is true, the value will be empty.
  • group : {Boolean} false by default. If true, tabs must look like this : [{car:[...arrayOfCars],bike:[...arrayOfBikes]}], then optgroup label will be car and bike.
  • onClick : {Function} Capture the click of the field.
  • onBlur : {Function} Capture the change of the field.
  • value : {String} the value found in the field.

to summary


Button

  • type *: {String} The type of button : button, submit, reset...
  • children *: {String} The content, like : 'validate', 'save' ...
  • myClass : {String} A class to give some style
  • idName : {String} Id of the button
  • onClick : {Function} If you need a function.. (onClick)

to summary


Modale

  • message *: {String} The message you need to display
  • open *: {Boolean} the order to open the modal
  • sendStyle : {String} Send color to the border of close button and text.
  • onClose *: {Function} the order to close the modal

to summary


DatePicker

  • idName *: {String} Corresponds to the htmlFor and className properties of the label, as well as the id of the input.
  • labelName : {String} label value.
  • myClass : {String} input className
  • isRequired : {Boolean} Whether the value is required or not.
  • toUpperCase : {Boolean} if you need to upper case label
  • lang : {String} to format date. by default "en" : yyyy-MM-dd. Can be french with "fr" : dd-MM-yyyy
  • placeholder : {String} What is expected in the field.

to summary


ScrollBar

  • barColor : {Number} Height of the progress bar, in pixels.
  • barHeight : {String} Progress bar color. 5px by default.
  • barOpacity : {Boolean} Gives a gradual opacity effect along the bar. False by default.

to summary


Example

import React, {useState} from "react"
import { InputText, Button, Modale, DatePicker } from "@yan_coquoz/react_input"

const MyForm = () => {
  const [isOpen, setIsOpen] = useState(false);

  const tab1 = ["red", "blue", "green"];
  const tab2 = ["short", "coat", "socket"];
  const tab3 = ["moto", "car", "boat"];

  const arrays = [
    { colors: [...tab1] },
    { clothes: [...tab2] },
    { vehicle: [...tab3] },
  ];

  const selectTabs = {
    options: arrays,
    idName: "arrays",
    labelName: "all tables",
    optValue: true,
    toUpperCase: true,
    isRequired: true,
    group: true,
  };

const barOptions = {
    barColor: "rgba(3, 83, 255, 0.8)",
    barHeight: 5,
    barOpacity: true,
}

    function handleOpenModal() {
        setIsOpen(true);
  }

  function handleInputText(name, value){
    console.log(name, value)
    // do what you want
 }
    return(
        <div>
            <ScrollBar {...barOptions}/>
            <form>
                <InputText 
                    idName={firstname} 
                    labelName={first name} 
                    isRequired={true} 
                    sendValue={handleInputText} 
                    myClass={"input_firstname"} 
                    toUpperCase={true}
                />

                <DatePicker
                    idName={"dateOfBirth"}
                    isRequired={false}
                    labelName={"date of birth"}
                    toUpperCase={true}
                    lang={"en"}
                />
                
                <SelectField {...selectTabs}>

                <Button type="submit">Save</Button>
            </form>
            <div>
                <Button type="button" onClick={handleOpenModal}>
                    Open Modale
                </Button>
                <Modale message="Hello World !!!" open={isOpen} sendStyle={"#F0F"} onClose={()=> setIsOpen(!isOpen)} />
            </div>
        </div>
    )
}

to summary


Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.570latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.570
0.1.560
0.1.550
0.1.540
0.1.530
0.1.520
0.1.510
0.1.500
0.1.490
0.1.480
0.1.470
0.1.460
0.1.450
0.1.440
0.1.430
0.1.420
0.1.410
0.1.400
0.1.390
0.1.380
0.1.370
0.1.360
0.1.350
0.1.340
0.1.330
0.1.321
0.1.310
0.1.300
0.1.290
0.1.280
0.1.270
0.1.260
0.1.250
0.1.240
0.1.231
0.1.220
0.1.210
0.1.200
0.1.190
0.1.180
0.1.170
0.1.10
0.1.160
0.1.150
0.1.140
0.1.130
0.1.120
0.1.110
0.1.101
0.1.90
0.1.70
0.1.60
0.1.50
0.1.40
0.1.00

Package Sidebar

Install

npm i @yan_coquoz/react_input

Weekly Downloads

3

Version

0.1.57

License

none

Unpacked Size

53.5 kB

Total Files

27

Last publish

Collaborators

  • yan_coquoz