@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 +8 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +8 -8
- package/dist/es/index.js.map +1 -1
- package/package.json +3 -3
package/dist/es/index.js
CHANGED
|
@@ -1553,18 +1553,18 @@ const controlIsValid = (props) => {
|
|
|
1553
1553
|
function instanceOfReactControlProps(props) {
|
|
1554
1554
|
return (typeof props === 'object' && ('state' in props || 'validators' in props));
|
|
1555
1555
|
}
|
|
1556
|
-
function
|
|
1557
|
-
if (
|
|
1556
|
+
function createReactControlProps(...argsProps) {
|
|
1557
|
+
if (argsProps.length < 1) {
|
|
1558
1558
|
return { state: undefined, validators: undefined };
|
|
1559
1559
|
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
const [state, validators] = argsProps;
|
|
1561
|
+
if (argsProps.length < 2 && instanceOfReactControlProps(state)) {
|
|
1562
|
+
return state;
|
|
1562
1563
|
}
|
|
1563
|
-
|
|
1564
|
-
return { state, validators };
|
|
1564
|
+
return { state: state, validators };
|
|
1565
1565
|
}
|
|
1566
|
-
function useReactControl(
|
|
1567
|
-
const props =
|
|
1566
|
+
function useReactControl(controlProps, controlValidators) {
|
|
1567
|
+
const props = createReactControlProps(controlProps, controlValidators);
|
|
1568
1568
|
const [state, setCurrentState] = useState(props.state);
|
|
1569
1569
|
const [value, setValue] = useState(props.state);
|
|
1570
1570
|
const [touched, setTouched] = useState(props.touched || false);
|