@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/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
|
|
1559
|
-
if (
|
|
1558
|
+
function createReactControlProps(...argsProps) {
|
|
1559
|
+
if (argsProps.length < 1) {
|
|
1560
1560
|
return { state: undefined, validators: undefined };
|
|
1561
1561
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1562
|
+
const [state, validators] = argsProps;
|
|
1563
|
+
if (argsProps.length < 2 && instanceOfReactControlProps(state)) {
|
|
1564
|
+
return state;
|
|
1564
1565
|
}
|
|
1565
|
-
|
|
1566
|
-
return { state, validators };
|
|
1566
|
+
return { state: state, validators };
|
|
1567
1567
|
}
|
|
1568
|
-
function useReactControl(
|
|
1569
|
-
const props =
|
|
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);
|