14.3.5 • Published 4 months ago

aio-input v14.3.5

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

aio-input

generate all inputs in react.

Note: Composite Component for Versatility and Consistency

The decision to composite all 24 input types into one component, AIOInput, was made to enhance versatility, maintainability, and consistency across various input scenarios in web development.

Versatility:

By encapsulating all input types within a single component, developers have access to a wide range of input functionalities without the need to import and manage multiple components. This approach simplifies the component structure and streamlines development workflows, especially in projects requiring diverse input requirements.

Maintainability:

Using a composite component allows for centralized management of common functionalities such as popover handling, option configuration, rendering layout, and event handling (e.g., onChange events). Any updates or enhancements to these shared functionalities can be implemented once within the composite component, ensuring consistent behavior across all input types.

Consistency:

All input types share a common configuration syntax and utilize the same underlying methods for rendering and event handling. This promotes consistency in the development process, making it easier for developers to learn, use, and maintain the component. Additionally, consistent configuration options enhance code readability and reduce the likelihood of errors.

In summary, the AIOInput component offers a unified solution for handling diverse input requirements in web applications, providing developers with a versatile, maintainable, and consistent toolset for building interactive user interfaces.

avilable types

Typehas multiple typehas popover prophas options prophas option prop
textNoyes (if set options prop)Yes (if set options prop)Yes
numberNoyes (if set options prop)Yes (if set options prop)Yes
textareaNoyes (if set options prop)Yes (if set options prop)Yes
passwordNoNoNoNo
colorNoNoYes (if set options prop)No
selectYes (multiselect)YesYesYes
tabsNoNoYesYes
buttonsYes (multiselect)NoYesYes
radioYes (checklist)NoYesYes
checkboxNoNoNoNo
spinnerYes (range spinner)NoNoNo
sliderYes (range slider)NoNoNo
dateYes (multi date)YesNoYes
timeNoYesNoNo
listNoNoYesYes
imageNoYesNoNo
fileYes (multiple files)NoNoYes
treeNoNoNoYes
acardionYes (multiple acardion)NoYesYes
tableNoNoNoNo
formNoNoNoNo
buttonNoYes (if set popover prop)NoNo

collection types are form , table and tree types that can take all input types to modify set of data:

  • in input type form you can use all this types as elements of form. form get an object as value and inputs object by definition fields and will pass changed value automatically by onChange prop
  • in input type table you can use all this types as table cell content. table get an array of objects as table rows by value prop and input object in columns prop will be props of each cell input. by change each input , table onChange will pass changed rows automatically.
  • in input type tree you can use all this types as text of tree node. tree get an object contain text function. you can customize tree node text as other inputs or any jsx content.

public props

proptypedefaultdescription
placeholderstringundefinedguiding users on the expected format or content or show instead empty contents.
disabledbooleanfalsemake input disabled.
loadingbooleanfalsemake input disabled and show loader after.
beforejsxundefineduse input before content.
afterjsxundefineduse input after content.
justifybooleanfalsemake content justify.
attrsattributes object{}custom input container standard html attributes.
stylestyle object{}custom input container style object.
classNamestringundefinedcustom input container className.
subtextstringundefinedinput subtext. show under input.
optionsarray of anyrequired in some input typesinput selective options.use in selective input types.
optionobject contain functions or stringundefinedconfigure each option.use in selective types.
caretfalse or jsxdefault caretcaret icon of dropdown inputs. set false to hide and set jsx to cutomize. use in dropdown types.
popoverobjectundefinedcustomize input popover. use in dropdown types like.
checkIconarray of 2 jsxarray of default checkboxescustomize check icon in toggle types like checkbox , radio , multiselect and tree.
justNumberboolean or array of charactersfalseWhen justNumber is set to true, the input field will only accept numerical values.When justNumber is an array of strings, the input field will accept numerical values along with the specified characters in the array. use in text , textarea and password input types.
filterarray of characters[]When filter is set to an array of strings, the input field will disallow the specified characters from being entered by the user. use in text , textarea and password types.
maxLengthnumberInfinityWhen maxLength is set to a number, the input field will limit the number of characters the user can input to the specified maximum length. use in text , textarea , password input types.
inputAttrsattributes object{}set starndard input attributes like set accept attribute in type file. use in text , number , textarea , color , file and password types.
multipleboolean or numberfalseEnables multiple selection mode. If true, allows selecting multiple options. If a number, limits the maximum number of selections.

options and option props

options

  • type : Array
  • use in this types: select radio tabs buttons tree text number textarea color
  • define selective options.An array containing options for the selectable component.

option

  • type : Object contain Functions
  • use in this types : text number textarea select tabs buttons radio date list file tree acardion.
  • configure each option of options prop , tags or rows of input.
  • Each function called for each options or rows or tags and takes the original option and details as parameters and returns value configurations.

Option Configuration Properties(functions)

PropertyTypeDescription
textstringText presentation of the option.
valuestringUnique value of the option.
beforeHTMLElementHTML element to be used before the option element.
afterHTMLElementHTML element to be used after the option element.
subtextstringSubtext to be rendered at the bottom of the option.
checkedbooleanIf false, renders an unchecked checkbox before the option; if true, renders a checked checkbox before the option.
checkIconstringCustomizes the checkbox of the option if checked is a boolean.
attrsobjectStandard attributes of the option element container.
classNamestringSets a custom className to the option element container.
styleobjectSets a custom style object to the option element container.
onClickfunctionSets a custom onClick event to the option element container; setting this will prevent default actions.
closebooleanIf content is in a popover and set to true, clicking will close the popover.
justifybooleanIf set to true, the container will be justified.
disabledbooleanIf set to true, the option will be disabled.
tagAttrsobjectCustom attributes of the option tags.
tagBeforeHTMLElementCustom element to be used before the tag.
tagAfterHTMLElementCustom element to be used after the tag.
<AIOInput
  type='select'
  options={[
    {name:'john',id:'1',gender:'male',color:'#ff0000'},
    {name:'stephan',id:'2',gender:'male',color:'#ffa500'},
    {name:'edvard',id:'3',gender:'male',color:'#ffff00'},
    {name:'luis',id:'4',gender:'male',color:'#9acd32'},
    {name:'carlos',id:'5',gender:'male',color:'#90ee90'}
  ]}
  option={{
    text:(option)=>option.name,
    value:(option)=>option.id,
    before:(option)=><Icon path={option.gender === 'male'?mdiHumanMale:mdiHumanFemale} size={0.8}/>,
    after:(option)=><div style={{color:'#fff',background:option.gender === 'male'?'blue':'pink'}}>{option.gender}</div>,
    subtext:(option)=>option.id,
    checked:(option)=>option.id === selectedUserId,
    checkIcon:()=>[
        <Icon path={mdiCheckboxBlankOutline} size={0.7} color='#ddd'/>,
        <Icon path={mdiCheckboxMarked} size={0.7} color='#5400ff'/>
    ],
    attrs:(option)=>{
      return {
        title:option.name
      }
    },
    className:(option)=>`my-option my-option-${option.gender}`,
    style:(option)=>{
      return {borderBottom:`1px solid ${option.gender === 'male'?'blue':'pink'`}
    },
    disabled:(option)=>option.gender === 'male'
  }}
/>

alt text

popover props

  • use in this types:
    • select date time
    • text textarea number if set options prop
    • button if you want to set custom popover about button
  • An object to configure input popover contain : Property | Type | Default | Description -------- | ---- | ------- | ----------- position | 'fullscreen' or 'center' or 'popover' or 'left' or 'right' or 'top' or 'bottom' | 'popover' | Set popover position setAttrs | function that returns attributes object | undefined | set custom attributes of any parts of popover .it get key is parameter and suitable for each key, returns custom attributes object.avilable values of key is backdrop modal header body footer fitHorizontal | boolean | false | set true to fit width of popover to input width. body | function | undefined | set custom popover for button type. limitTo | string | undefined | set limitTo to open popover in limit of element selected by limitTo selector. fitTo | string | undefined | set fitTo to open popover by exact size of element selected by fitTo selector. header | object contain {attrs:Object,title:string,close:boolean} | undefined | if set title or close, a header content will render in top of popover. title is header title and if close set true , close button will be rendered. for customize header you can set attrs property. all this properties are optional
<AIOInput
   type='button'
   text='My Button'
   popover={{
      position:'center',
      body:({close})=>{
         return <Details/>
      },
      header:{
         title:'My Title',
         subtitle:'My Subtitle',
         onClose:true,
         before:'...any content',
         after:'...any content',
      },
      setAttrs:(key)=>{// key 'backdrop' | 'modal' | 'header' | 'body' | 'footer'
         if(key === 'backdrop'){
            return {
               style:{background:'rgba(0,0,0,0.3)'}
            }
         }
         if(key === 'modal'){
            return {
               //... any attributes
            }
         }
         if(key === 'header'){
            return {
               //... any attributes
            }
         }
         if(key === 'body'){
            return {
               //... any attributes
            }
         }
         if(key === 'footer'){
            return {
               //... any attributes
            }
         }
      },
      fitTo:'...string element selector',
      limitTo:'...string element selector',
      fitHorizontal:true
   }}
/>

multiple props

  • use in this types:
    • select radio buttons file slider spinner
  • boolean or number :
    • Enables multiple selection mode. If true, allows selecting multiple options. If a number, limits the maximum number of selections.
  • enable multiple in select type will generate multiselect input by showing selected tags
  • enable multiple in radio type will generate checklist input.
  • enable multiple in slider type will generate range slider input by more than one point to select a range of values.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState();
  return (
      <AIOInput
          type='text'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="text"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstring---input placeholder
justNumberBoolean or ArrayfalseWhen justNumber is set to true, the input field will only accept numerical values.When justNumber is an array of strings, the input field will accept numerical values along with the specified characters in the array.
maxLengthnumberundefinedWhen maxLength is set to a number, the input field will limit the number of characters the user can input to the specified maximum length.
filterarray of stringsundefinedWhen filter is set to an array of strings, the input field will disallow the specified characters from being entered by the user.
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
inputAttrsobjectundefinedUse the inputAttrs prop to set any additional attributes for the element.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayundefinedUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
caretboolean or jsx/htmltrueSet caret to false to hide the default caret when options are provided. Set caret to a ReactNode to render a custom caret element instead of the default caret when options are provided.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState(0);
  return (
      <AIOInput
          type='number'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="number"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstring---input placeholder
maxLengthnumberInfinityWhen maxLength is set to a number, the input field will limit the number of characters the user can input to the specified maximum length.
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
inputAttrsobjectundefinedUse the inputAttrs prop to set any additional attributes for the element.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayundefinedUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
maxnumberundefinedUse the min prop to set the minimum value allowed for the input.
minnumberundefinedUse the min prop to set the maximum value allowed for the input.
swipnumber0Use the swipe prop to enable swiping functionality on a number input.The value of swipe determines the speed of value change when swiping the mouse up or down.A non-zero value will enable swiping, where the absolute value indicates the speed of change.
spinbooleantrueSet spin to false to hide the spin buttons of the input.
caretboolean or jsx/htmltrueSet caret to false to hide the default caret when options are provided. Set caret to a ReactNode to render a custom caret element instead of the default caret when options are provided.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState();
  return (
      <AIOInput
          type='password'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="password"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstring---input placeholder
justNumberBoolean or ArrayfalseWhen justNumber is set to true, the input field will only accept numerical values.When justNumber is an array of strings, the input field will accept numerical values along with the specified characters in the array.
maxLengthnumberundefinedWhen maxLength is set to a number, the input field will limit the number of characters the user can input to the specified maximum length.
filterarray of stringsundefinedWhen filter is set to an array of strings, the input field will disallow the specified characters from being entered by the user.
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
inputAttrsobjectundefinedUse the inputAttrs prop to set any additional attributes for the element.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState();
  return (
      <AIOInput
          type='textarea'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="textarea"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstring---input placeholder
justNumberBoolean or ArrayfalseWhen justNumber is set to true, the input field will only accept numerical values.When justNumber is an array of strings, the input field will accept numerical values along with the specified characters in the array.
maxLengthnumberundefinedWhen maxLength is set to a number, the input field will limit the number of characters the user can input to the specified maximum length.
filterarray of stringsundefinedWhen filter is set to an array of strings, the input field will disallow the specified characters from being entered by the user.
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
inputAttrsobjectundefinedUse the inputAttrs prop to set any additional attributes for the element.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayundefinedUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
caretboolean or jsx/htmltrueSet caret to false to hide the default caret when options are provided. Set caret to a ReactNode to render a custom caret element instead of the default caret when options are provided.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState(false);
  return (
      <AIOInput
          type='checkbox'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="checkbox"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
textstringundefinedUse the text prop to specify the text to be displayed as the text of checkbox input.
checkIconobject or arrayundefinedUse the checkIcon prop to apply custom styles to the checkbox icon in the multiselect options.also can be an array with two members: the first member represents the unchecked custom checkbox, and the second member represents the checked custom checkbox.

alt text

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState();
  return (
      <AIOInput
          type='select'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="select"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstringundefinedinput placeholder
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayRequiredUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
caretboolean or jsx/htmltrueSet caret to false to hide the default caret when options are provided. Set caret to a ReactNode to render a custom caret element instead of the default caret when options are provided.
deSelectboolean or functionfalseSet deSelect to true to make the value of the component undefined when the user clicks on a selected option again. Set deSelect to a function to call the provided function when the user clicks on a selected option again.
textstringundefinedUse the text prop to specify the text to be displayed as the selected option in the select input. When text is set, the provided text will be displayed instead of the text of the selected option.
hideTagsbooleanfalseSet hideTags to true to hide the selected options as tags under the multiselect input.
checkIconobject or arrayundefinedUse the checkIcon prop to apply custom styles to the checkbox icon in the multiselect options.also can be an array with two members: the first member represents the unchecked custom checkbox, and the second member represents the checked custom checkbox.

alt text

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState([]);
  return (
      <AIOInput
          type='tabs'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="tabs"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayRequiredUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
deSelectboolean or functionfalseSet deSelect to true to make the value of the component undefined when the user clicks on a selected option again. Set deSelect to a function to call the provided function when the user clicks on a selected option again.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState('3');
  return (
      <AIOInput
          type='radio'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="radio"

alt text

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayRequiredUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
checkIconobject or arrayundefinedUse the checkIcon prop to apply custom styles to the checkbox icon in the multiselect options.also can be an array with two members: the first member represents the unchecked custom checkbox, and the second member represents the checked custom checkbox.
multipleboolean or numberfalseEnables multiple selection mode. If true, allows selecting multiple options. If a number, limits the maximum number of selections.

radio multiple true

alt text

type="buttons"

alt text

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState('2');
  return (
      <AIOInput
          type='buttons'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="buttons"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
optionsarrayRequiredUse the options prop to provide a list of options to be displayed in a dropdown list below the input element.
optionobject of functionsundefinedSpecifies custom properties for rendering and controlling each option in the dropdown list.
deSelectboolean or functionfalseSet deSelect to true to make the value of the component undefined when the user clicks on a selected option again. Set deSelect to a function to call the provided function when the user clicks on a selected option again.
multipleboolean or numberfalseEnables multiple selection mode. If true, allows selecting multiple options. If a number, limits the maximum number of selections.

multiple buttons alt text

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState();
  return (
      <AIOInput
          type='date'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="date"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstringundefinedinput placeholder
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
textstringundefinedSpecifies the text for displaying in the date input.
patternstringundefinedSpecifies the pattern for displaying the date and time in the date input.
unit'year' or 'month' or 'day' or 'hour''day'Use the unit prop to specify the unit for adjusting the date input. Available options are 'year', 'month', 'day', and 'hour'.The default unit is 'day'.
jalalibooleanfalseSet jalali to true to use the Jalali (Persian) calendar for the date input. When jalali is set to true, the date input will display and accept dates according to the Persian calendar.
themearray of stringsundefinedAn array containing two color values. styling calendar by this colors.
sizenumber180Set the size of the calendar.
deSelectboolean or functionfalseIf set true, onChange will be called with undefined when clearing the value. If set as a function, this function will be called after clicking on the clear button.
caretboolean or jsx/htmltrueSet caret to false to hide the default caret. Set caret to a ReactNode to render a custom caret element instead of the default caret.
dateAttrsfunction returns attrs objectundefinedA function to customize the attributes of each date element in the calendar. It receives an object with properties dateArray, isToday, isDisabled, isActive, and isMatch and should return an object with styles to apply to the date element.
optionobject{}Specifies custom properties for rendering and controlling each date tag in the multipe mode of datepicker.
multipleboolean or numberfalseEnables multiple selection mode. If true, allows selecting multiple dates or times. If a number, limits the maximum number of selections.

pattern prop

Specifies the pattern for displaying the date and time in the date input.
Usage
  • Use the pattern prop to define the pattern for displaying the date and time in the date input.
  • You can use placeholders such as {weekDay}, {day}, {month}, {monthString}, {year}, and {hour} to represent the components of the date and time.

Available placeholders:

  • {weekDay}: Full name of the day of the week (e.g., Monday, Tuesday).
  • {day}: Day of the month (e.g., 01, 02, ..., 31).
  • {month}: Month of the year (e.g., 01, 02, ..., 12).
  • {monthString}: Full name of the month (e.g., January, February).
  • {year}: Year (e.g., 2022, 2023).
  • {hour}: Hour of the day (e.g., 00, 01, ..., 23).
<AIOInput
    type='date'
    value={value}
    onChange={(newValue)=>setValue(newValue)}
    
    pattern='{weekDay} {day} {monthString} {year}'
/>

alt text

jalali prop

make jalali calendar.

jalali={true}

alt text

unit prop

  • month
    unit='month'
    alt text
  • day
    unit='day'
    alt text
  • hour
    unit='hour'
    alt text

theme prop

set array of 2 colors to design calendar.

theme={['lightblue','#666']}

alt text

size prop

set a number to set size of calendar.

size={120}

alt text

multiple prop

Enables multiple selection mode. If true, allows selecting multiple dates or times. If a number, limits the maximum number of selections.

multiple={true}

alt text

option prop

Specifies custom properties for rendering and controlling each date tag in the multipe mode of datepicker. opton prop is a global prop used in many types . please read documentation of option prop in top of this document.

option={
  text:(date,details)=>`${details.weekDay} ${details.day} ${details.monthString} ${details.year}`,//change text of date tag
  close:(date,details)=>true,//close popover after seleting date
  tagAttrs:(date,details)=>{//set custom attributes of date tag
    return {
      style:{background:'orange'}
    }
  },
  tagBefore:(date,details)=><Icon/>,//any contetn before tags
  tagBefore:(date,details)=>'any cvontent',//any contetn after tags,
  ....
  //and other properties of public option prop
}

dateAttrs prop

The dateAttrs prop allows you to customize the attributes of each date element in the calendar. It is a function that receives an object with properties dateArray, isToday, isActive, and isMatch.
also you can disabled each date element for prevent select by user

Here's what each property represents:

  • dateArray : An array containing the year, month, day and hour of the date.
  • isToday : A boolean indicating whether the date is today's date.
  • isActive : A boolean indicating whether the date is currently selected or active.
  • isMatch : A boolean indicating whether the date matches any predefined criteria.

The dateAttrs function should return an object with styles to apply to the date element. Depending on your use case, you can customize the styles of each date element based on these properties. For example, you can change the background color of today's date or disable specific dates.

Here's an example of how you can use the dateAttrs prop:

dateAttrs={({ dateArray, isToday, isActive, isMatch }) => {
    let styles = {};
    if (isToday) {
        styles.background = 'orange';
    }
    return { style: styles };
}}

in this example today element will get background orange

dateAttrs={({ dateArray, isToday, isActive, isMatch }) => {
    if (isActive) {
        return {
          className:'active-date'
        }
    }
}}

in this example active date element will get className:'active-date'

isMatch function parameter in dateAttrs Prop function.

The isMatch function within the dateAttrs prop allows you to define custom logic to match specific date elements in the calendar based on various conditions. It takes an array of strings representing date comparison conditions and returns true if any of the conditions are met for the current date element.

dateAttrs={({ isMatch }) => {
    if (isMatch(['<,2022/02/03'])) {
        return { color: 'red' };
    }
    if (isMatch(['<>,2022/03/03,2023/04/05'])) {
        return { disabled: true };
    }
}}

Date Comparison Conditions

Each string in the array represents a date comparison condition in the format 'operator,date1,date2':

Operators

The comparison operator

OperatorExampleExample Description
'<'isMatch('<,2024/2/3')target is all dates before 2024/2/3
'<='isMatch('<,2024/2/3')target is all dates before or equal 2024/2/3
'>'isMatch('>,2024/2/3')target is all dates after 2024/2/3
'>='isMatch('>=,2024/2/3')target is all dates after or equal 2024/2/3
'='isMatch('=,2024/2/3')target is all dates equal 2024/2/3
'='isMatch('=,2024/2/3,2024/2/4')target is all dates equal 2024/2/3 or 2024/2/4
'!='isMatch('!=,2024/2/3')target is all dates not equal 2024/2/3
'!='isMatch('!=,2024/2/3,2024/2/4')target is all dates that is not equal 2024/2/3 or 2024/2/4
'<>'isMatch('<,2024/2/3,2025/1/1')target is all dates between 2024/2/3 and 2025/1/1
'<=>'isMatch('<,2024/2/3,2025/1/1')target is all dates that is between or equal 2024/2/3 and 2025/1/1
'!<>'isMatch('<,2024/2/3,2025/1/1')target is all dates that is not between 2024/2/3 and 2025/1/1
'!<=>'isMatch('<,2024/2/3,2025/1/1')target is all dates that is not between or equal 2024/2/3 and 2025/1/1
'w'isMatch('w,5')target is all days that is 5th day of week. index from 0
'w'isMatch('w,5,6')target is all days that is 5th or 6th day of week. index from 0
'!w'isMatch('!w,5')target is all days that is not 5th day of week. index from 0
'!w'isMatch('!w,5,6')target is all days that is not 5th or 6th day of week. index from 0
<AIOInput
    type='date'
    value={value}
    onChange={(newValue) => setValue(newValue)}
    dateAttrs={({ isMatch }) => {
        let attrs = {}
        if (isMatch(['<,2022/02/03'])) {
            attrs.style = { color: 'red' };
        }
        if (isMatch(['<>,2022/03/03,2023/04/05'])) {
            attrs.style = { color: 'orange' };
        }
        if(isMatch([>,2024/4/5])){
          attrs.disabled = true
        }
        return attrs
    }}
/>
In this example:
  • Dates before February 3, 2022, will have the color red.
  • Dates between March 3, 2022, and April 5, 2023, will have the color orange.
  • Dates after 2024/4/5 will be disabled

option prop

this will cause to close popover after select date.

option={{
  close:true
}}

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState({year:2022,month:4,day:12});
  return (
      <AIOInput
          type='time'
          value={value}
          unit={{year:true,month:true,day:true}}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="time"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstringundefinedinput placeholder
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
textstringundefinedSpecifies the pattern for displaying the date and time in the time input.
unitstring contain 'year','month','day','hour','minute','second''year,month,day'Use the unit prop to specify the unit for adjusting the time input. Available options are year, month, day, hour, minute and second.
jalalibooleanfalseSet jalali to true to use the Jalali (Persian) calendar for the time input. When jalali is set to true, the time input will display and accept dates according to the Persian calendar.
caretboolean or jsx/htmltrueSet caret to false to hide the default caret. Set caret to a ReactNode to render a custom caret element instead of the default caret.

unit prop

<AIOInput
    type='time'
    value={value}
    onChange={(newValue)=>setValue(newValue)}
    
    unit='hour,minute,second'
/>

alt text

<AIOInput
    type='time'
    value={value}
    onChange={(newValue)=>setValue(newValue)}
    unit='year,month,day'
/>

alt text

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState('https://imgv3.fotor.com/images/blog-cover-image/part-blurry-image.jpg');
  return (
      <AIOInput
          type='image'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="image"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
placeholderstringundefinedinput placeholder
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
deSelectboolean or functionfalseIf set true, onChange will be called with undefined when clearing the value. If set as a function, this function will be called after clicking on the clear button.
previewbooleanfalseIf set to true, a preview button will be shown on the image. Clicking it will open the image in a popup window.
widthnumber or stringundefinedThe width of the image input.
heightnumber or stringundefinedThe height of the image input.

basic example

import AIOInput from "aio-input";
function Example(){
  let [value,setValue] = useState();
  return (
      <AIOInput
          type='file'
          value={value}
          onChange={(newValue)=>setValue(newValue)}
      />
  )
}

other props in type="image"

PropsTypeDefaultDescription
disabledbooleanfalsemake input disabled
attrsobjectundefinedUse the attrs prop to set any additional attributes for the parent element of input.
styleobjectundefinedUse the style prop to apply custom CSS styles to the input element.
classNamestringundefinedcustom clasName
textstringundefinedSpecifies the text for displaying in the file input box.
afterhtml/jsxundefinedUse the after prop to render additional content after the input element within your component.
beforehtml/jsxundefinedUse the before prop to render additional content before the input element within your component.
subtextstringundefinedUse the subtext prop to display additional text below the input element.
loadingbooleanfalseSet loading to true to disable the input and display a spinning loader icon after the input.
previewbooleanfalseIf set to true, in list of selected file under input, small preview of file will be displayed.
multipleboolean or numberfalseEnables multiple selection mode. If true, allows selecting multiple files. If a number, limits the maximum number of file selections.
14.3.5

4 months ago

14.3.4

4 months ago

14.3.1

4 months ago

14.3.2

4 months ago

14.3.3

4 months ago

14.3.0

4 months ago

14.2.0

4 months ago

14.2.1

4 months ago

14.2.2

4 months ago

14.2.3

4 months ago

14.2.4

4 months ago

14.2.5

4 months ago

14.1.0

5 months ago

14.0.0

5 months ago

14.0.1

5 months ago

14.0.2

5 months ago

13.0.6

5 months ago

13.0.4

5 months ago

13.0.5

5 months ago

13.0.2

5 months ago

13.0.3

5 months ago

13.0.0

5 months ago

13.0.1

5 months ago

12.4.0

6 months ago

12.4.1

6 months ago

12.4.2

6 months ago

12.3.5

7 months ago

12.3.6

7 months ago

12.3.4

7 months ago

12.3.0

7 months ago

12.3.1

7 months ago

12.3.2

7 months ago

12.3.3

7 months ago

12.2.0

7 months ago

12.1.0

7 months ago

12.1.1

7 months ago

12.0.3

7 months ago

12.0.0

7 months ago

12.0.1

7 months ago

12.0.2

7 months ago

11.8.0

7 months ago

11.7.0

7 months ago

11.7.1

7 months ago

11.7.2

7 months ago

11.6.0

8 months ago

11.6.1

8 months ago

11.6.2

8 months ago

11.5.7

8 months ago

11.5.8

8 months ago

11.5.1

8 months ago

11.5.2

8 months ago

11.5.0

8 months ago

11.5.5

8 months ago

11.5.6

8 months ago

11.5.3

8 months ago

11.5.4

8 months ago

11.4.2

8 months ago

11.4.0

8 months ago

11.4.1

8 months ago

11.3.1

8 months ago

11.3.2

8 months ago

11.3.0

8 months ago

11.2.2

9 months ago

11.2.3

8 months ago

11.2.0

9 months ago

11.2.1

9 months ago

11.0.0

9 months ago

11.0.1

9 months ago

11.1.3

9 months ago

11.1.4

9 months ago

11.1.1

9 months ago

11.1.2

9 months ago

11.1.0

9 months ago

10.2.0

10 months ago

10.4.0

9 months ago

10.3.0

10 months ago

10.1.0

11 months ago

10.0.5

11 months ago

10.0.1

11 months ago

10.0.2

11 months ago

10.0.3

11 months ago

10.0.4

11 months ago

10.0.0

11 months ago

9.9.0

11 months ago

9.8.0

12 months ago

9.6.0

1 year ago

9.7.2

12 months ago

9.7.1

12 months ago

9.7.0

1 year ago

9.5.9

1 year ago

9.5.5

1 year ago

9.5.4

1 year ago

9.5.3

1 year ago

9.5.2

1 year ago

9.5.1

1 year ago

9.5.8

1 year ago

9.5.7

1 year ago

9.5.6

1 year ago

9.5.0

1 year ago

9.4.0

1 year ago

9.3.1

1 year ago

9.3.0

1 year ago

9.2.2

1 year ago

9.2.1

1 year ago

9.2.0

1 year ago

9.0.1

1 year ago

9.0.0

1 year ago

8.3.3

1 year ago

8.3.2

1 year ago

8.3.1

1 year ago

8.1.3

1 year ago

8.3.0

1 year ago

8.1.2

1 year ago

8.2.0

1 year ago

8.1.1

1 year ago

8.1.0

1 year ago

8.0.18

1 year ago

8.0.17

1 year ago

8.0.16

1 year ago

8.0.15

1 year ago

8.0.14

2 years ago

8.0.13

2 years ago

8.0.12

2 years ago

8.0.11

2 years ago

8.0.10

2 years ago

8.0.9

2 years ago

8.0.8

2 years ago

8.0.7

2 years ago

8.0.6

2 years ago

8.0.5

2 years ago

8.0.3

2 years ago

8.0.4

2 years ago

8.0.2

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.0.0

2 years ago

6.0.0

2 years ago

5.0.0

2 years ago

4.0.4

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago