@dartech/arsenal-ui 1.4.42 → 1.4.43
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +30 -31
- package/package.json +1 -1
- package/src/lib/Forms/ControlArrayInput.d.ts +5 -2
package/index.js
CHANGED
@@ -2466,36 +2466,41 @@ const ControlTime = ({
|
|
2466
2466
|
}));
|
2467
2467
|
};
|
2468
2468
|
|
2469
|
-
const ControlArrayInput =
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2469
|
+
const ControlArrayInput = _a => {
|
2470
|
+
var _b, _c, _d;
|
2471
|
+
var {
|
2472
|
+
name,
|
2473
|
+
control,
|
2474
|
+
label,
|
2475
|
+
required,
|
2476
|
+
defaultValue = null,
|
2477
|
+
onChange: customOnChange,
|
2478
|
+
textFieldLabel
|
2479
|
+
} = _a,
|
2480
|
+
textFieldProps = __rest(_a, ["name", "control", "label", "required", "defaultValue", "onChange", "textFieldLabel"]);
|
2477
2481
|
const [localValue, setLoacalValue] = useState('');
|
2478
2482
|
const [error, setError] = useState(null);
|
2479
|
-
const
|
2483
|
+
const _e = useController({
|
2480
2484
|
control,
|
2481
2485
|
name,
|
2482
|
-
defaultValue
|
2486
|
+
defaultValue,
|
2483
2487
|
rules: {
|
2484
2488
|
required: required && DEFAULT_REQUIRED_ERROR_TEXT
|
2485
2489
|
}
|
2486
2490
|
}),
|
2487
|
-
|
2491
|
+
_f = _e.field,
|
2488
2492
|
{
|
2489
|
-
onChange,
|
2493
|
+
onChange: innerOnChange,
|
2490
2494
|
value: values
|
2491
|
-
} =
|
2492
|
-
fieldData = __rest(
|
2495
|
+
} = _f,
|
2496
|
+
fieldData = __rest(_f, ["onChange", "value"]),
|
2493
2497
|
{
|
2494
2498
|
// fieldState: { error },
|
2495
2499
|
formState: {
|
2496
2500
|
errors
|
2497
2501
|
}
|
2498
|
-
} =
|
2502
|
+
} = _e;
|
2503
|
+
const onChange = useMemo(() => customOnChange ? customOnChange : innerOnChange, [customOnChange, innerOnChange]);
|
2499
2504
|
const handleInputChange = useCallback(e => {
|
2500
2505
|
const {
|
2501
2506
|
value
|
@@ -2524,17 +2529,10 @@ const ControlArrayInput = ({
|
|
2524
2529
|
}
|
2525
2530
|
}, [handleAdd]);
|
2526
2531
|
return jsxs(Fragment, {
|
2527
|
-
children: [jsx(
|
2528
|
-
|
2532
|
+
children: [jsx(FormLabel, Object.assign({
|
2533
|
+
required: required
|
2529
2534
|
}, {
|
2530
|
-
children:
|
2531
|
-
children: [label, ' ', jsx(Box, Object.assign({
|
2532
|
-
component: "span",
|
2533
|
-
color: "#D6331F"
|
2534
|
-
}, {
|
2535
|
-
children: "*"
|
2536
|
-
}))]
|
2537
|
-
}) : label
|
2535
|
+
children: label
|
2538
2536
|
})), jsx(Box, Object.assign({
|
2539
2537
|
display: "flex",
|
2540
2538
|
flexWrap: "wrap"
|
@@ -2553,15 +2551,15 @@ const ControlArrayInput = ({
|
|
2553
2551
|
}, control.register(name), {
|
2554
2552
|
onChange: onChange,
|
2555
2553
|
value: values
|
2556
|
-
}, fieldData)), jsx(TextField, {
|
2554
|
+
}, fieldData)), jsx(TextField, Object.assign({
|
2557
2555
|
fullWidth: true,
|
2558
2556
|
variant: "outlined",
|
2559
2557
|
size: "small",
|
2560
|
-
label: `Add ${label}`,
|
2558
|
+
label: textFieldLabel || textFieldLabel === '' ? textFieldLabel : `Add ${label}`,
|
2561
2559
|
value: localValue,
|
2562
2560
|
onChange: handleInputChange,
|
2563
|
-
error: !!((
|
2564
|
-
helperText: (
|
2561
|
+
error: !!((_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message),
|
2562
|
+
helperText: (_c = errors[name]) === null || _c === void 0 ? void 0 : _c.message,
|
2565
2563
|
FormHelperTextProps: {
|
2566
2564
|
variant: 'standard'
|
2567
2565
|
},
|
@@ -2578,8 +2576,9 @@ const ControlArrayInput = ({
|
|
2578
2576
|
})
|
2579
2577
|
})
|
2580
2578
|
}))
|
2581
|
-
}
|
2582
|
-
|
2579
|
+
},
|
2580
|
+
inputProps: Object.assign({}, (_d = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _d !== void 0 ? _d : {})
|
2581
|
+
}, textFieldProps)), error && jsx(FormHelperText, Object.assign({
|
2583
2582
|
error: true
|
2584
2583
|
}, {
|
2585
2584
|
children: error
|
package/package.json
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
import { ReactNode } from 'react';
|
2
2
|
import { Control } from 'react-hook-form';
|
3
|
-
|
3
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
4
|
+
type Props = TextFieldProps & {
|
4
5
|
name: string;
|
5
6
|
control: Control<any>;
|
6
7
|
label: ReactNode;
|
7
8
|
required?: boolean;
|
8
9
|
defaultValue?: [] | null;
|
10
|
+
onChange?: any;
|
11
|
+
textFieldLabel?: string;
|
9
12
|
};
|
10
|
-
export declare const ControlArrayInput: ({ name, control, label, required, defaultValue, }: Props) => JSX.Element;
|
13
|
+
export declare const ControlArrayInput: ({ name, control, label, required, defaultValue, onChange: customOnChange, textFieldLabel, ...textFieldProps }: Props) => JSX.Element;
|
11
14
|
export {};
|