@rolster/react-components 18.12.5 → 18.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1555,18 +1555,18 @@ const controlIsValid = (props) => {
1555
1555
  function instanceOfReactControlProps(props) {
1556
1556
  return (typeof props === 'object' && ('state' in props || 'validators' in props));
1557
1557
  }
1558
- function getReactControlProps(props, validators) {
1559
- if (props === undefined || props === null) {
1558
+ function createReactControlProps(...argsProps) {
1559
+ if (argsProps.length < 1) {
1560
1560
  return { state: undefined, validators: undefined };
1561
1561
  }
1562
- if (instanceOfReactControlProps(props)) {
1563
- return props;
1562
+ const [state, validators] = argsProps;
1563
+ if (argsProps.length < 2 && instanceOfReactControlProps(state)) {
1564
+ return state;
1564
1565
  }
1565
- const state = props;
1566
- return { state, validators };
1566
+ return { state: state, validators };
1567
1567
  }
1568
- function useReactControl(reactProps, validatorsFn) {
1569
- const props = getReactControlProps(reactProps, validatorsFn);
1568
+ function useReactControl(controlProps, controlValidators) {
1569
+ const props = createReactControlProps(controlProps, controlValidators);
1570
1570
  const [state, setCurrentState] = react.useState(props.state);
1571
1571
  const [value, setValue] = react.useState(props.state);
1572
1572
  const [touched, setTouched] = react.useState(props.touched || false);