@dartech/arsenal-ui 1.4.56 → 1.4.58
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +49 -36
- package/package.json +1 -1
- package/src/interfaces/definition.d.ts +1 -1
- package/src/lib/Forms/ControlTime.d.ts +6 -2
package/index.js
CHANGED
@@ -2261,10 +2261,15 @@ const propertiesArrayToObject = (properties, isGlobalParameter) => {
|
|
2261
2261
|
resultProperty['isViewableInList'] = property.isViewableInList;
|
2262
2262
|
}
|
2263
2263
|
if (uiSettings) {
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2264
|
+
if (typeof uiSettings === 'string') {
|
2265
|
+
try {
|
2266
|
+
resultProperty.uiSettings = JSON.parse(uiSettings);
|
2267
|
+
} catch (e) {
|
2268
|
+
console.log(e);
|
2269
|
+
resultProperty.uiSettings = uiSettings;
|
2270
|
+
}
|
2271
|
+
} else {
|
2272
|
+
resultProperty.uiSettings = uiSettings;
|
2268
2273
|
}
|
2269
2274
|
} else {
|
2270
2275
|
resultProperty.uiSettings = null;
|
@@ -2312,13 +2317,13 @@ function propertiesObjectToArray(properties, fields) {
|
|
2312
2317
|
propObj.defaultValue = '';
|
2313
2318
|
}
|
2314
2319
|
}
|
2315
|
-
if (propObj['uiSettings']) {
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
}
|
2320
|
+
// if (propObj['uiSettings']) {
|
2321
|
+
// try {
|
2322
|
+
// propObj.uiSettings = JSON.stringify(propObj.uiSettings, null, 2);
|
2323
|
+
// } catch (error) {
|
2324
|
+
// propObj.uiSettings = '';
|
2325
|
+
// }
|
2326
|
+
// }
|
2322
2327
|
if (propObj['isMultiple']) {
|
2323
2328
|
if ('defaultValues' in propObj) {
|
2324
2329
|
propObj['defaultValue'] = propObj.defaultValues;
|
@@ -2734,7 +2739,7 @@ const ControlDate = _a => {
|
|
2734
2739
|
OpenPickerIcon: DateIconComponent$1
|
2735
2740
|
}
|
2736
2741
|
}, datePickerProps, {
|
2737
|
-
renderInput:
|
2742
|
+
renderInput: props => jsx(TextField, Object.assign({}, props, {
|
2738
2743
|
fullWidth: true,
|
2739
2744
|
size: "small",
|
2740
2745
|
variant: "outlined",
|
@@ -2744,7 +2749,7 @@ const ControlDate = _a => {
|
|
2744
2749
|
FormHelperTextProps: {
|
2745
2750
|
variant: 'standard'
|
2746
2751
|
},
|
2747
|
-
inputProps: Object.assign(Object.assign({},
|
2752
|
+
inputProps: Object.assign(Object.assign({}, props.inputProps), {
|
2748
2753
|
placeholder: placeholder
|
2749
2754
|
})
|
2750
2755
|
}, textFieldProps))
|
@@ -2839,54 +2844,58 @@ const ControlDateTime = _a => {
|
|
2839
2844
|
}));
|
2840
2845
|
};
|
2841
2846
|
|
2842
|
-
const ControlTime =
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2847
|
+
const ControlTime = _a => {
|
2848
|
+
var {
|
2849
|
+
control,
|
2850
|
+
name,
|
2851
|
+
required,
|
2852
|
+
label,
|
2853
|
+
textFieldProps = {},
|
2854
|
+
format: format$1 = TIME_DEFAULT_FORMAT,
|
2855
|
+
hideErrorMessage = false,
|
2856
|
+
requiredErrorText = '',
|
2857
|
+
placeholder
|
2858
|
+
} = _a,
|
2859
|
+
timePickerProps = __rest(_a, ["control", "name", "required", "label", "textFieldProps", "format", "hideErrorMessage", "requiredErrorText", "placeholder"]);
|
2860
|
+
const _b = useController({
|
2852
2861
|
control,
|
2853
2862
|
name,
|
2854
2863
|
rules: {
|
2855
|
-
required: required ?
|
2864
|
+
required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
|
2856
2865
|
validate: val => {
|
2857
|
-
if (isMatch(val,
|
2866
|
+
if (isMatch(val, format$1)) {
|
2858
2867
|
return true;
|
2859
2868
|
}
|
2860
2869
|
return 'Incorrect date format';
|
2861
2870
|
}
|
2862
2871
|
}
|
2863
2872
|
}),
|
2864
|
-
|
2873
|
+
_c = _b.field,
|
2865
2874
|
{
|
2866
2875
|
onChange,
|
2867
2876
|
ref,
|
2868
2877
|
value
|
2869
|
-
} =
|
2870
|
-
fieldProps = __rest(
|
2878
|
+
} = _c,
|
2879
|
+
fieldProps = __rest(_c, ["onChange", "ref", "value"]),
|
2871
2880
|
{
|
2872
2881
|
fieldState: {
|
2873
2882
|
error
|
2874
2883
|
}
|
2875
|
-
} =
|
2884
|
+
} = _b;
|
2876
2885
|
const [fieldValue, setFieldValue] = useState(null);
|
2877
2886
|
const handleChange = date => {
|
2878
2887
|
setFieldValue(date);
|
2879
|
-
onChange(isValid(date) ? format(date,
|
2888
|
+
onChange(isValid(date) ? format(date, format$1) : date);
|
2880
2889
|
};
|
2881
2890
|
useEffect(() => {
|
2882
|
-
if (value &&
|
2883
|
-
let parsedValue = parse(value,
|
2891
|
+
if (value && format$1) {
|
2892
|
+
let parsedValue = parse(value, format$1, new Date());
|
2884
2893
|
if (!isValid(parsedValue)) {
|
2885
2894
|
parsedValue = parse(value, 'HH:mm:ss.SSS', new Date());
|
2886
2895
|
}
|
2887
2896
|
setFieldValue(parsedValue);
|
2888
2897
|
}
|
2889
|
-
}, [value,
|
2898
|
+
}, [value, format$1]);
|
2890
2899
|
return jsx(TimePicker, Object.assign({}, fieldProps, {
|
2891
2900
|
mask: "",
|
2892
2901
|
inputRef: ref,
|
@@ -2897,8 +2906,9 @@ const ControlTime = ({
|
|
2897
2906
|
}) : label,
|
2898
2907
|
ampm: false,
|
2899
2908
|
value: fieldValue,
|
2900
|
-
inputFormat:
|
2901
|
-
onChange: handleChange
|
2909
|
+
inputFormat: format$1,
|
2910
|
+
onChange: handleChange
|
2911
|
+
}, timePickerProps, {
|
2902
2912
|
renderInput: props => jsx(TextField, Object.assign({}, props, {
|
2903
2913
|
fullWidth: true,
|
2904
2914
|
size: "small",
|
@@ -2907,10 +2917,13 @@ const ControlTime = ({
|
|
2907
2917
|
color: '#D6331F'
|
2908
2918
|
}
|
2909
2919
|
},
|
2920
|
+
inputProps: Object.assign(Object.assign({}, props.inputProps), {
|
2921
|
+
placeholder: placeholder
|
2922
|
+
}),
|
2910
2923
|
variant: "outlined",
|
2911
2924
|
name: name,
|
2912
2925
|
error: !!error,
|
2913
|
-
helperText: !
|
2926
|
+
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
2914
2927
|
FormHelperTextProps: {
|
2915
2928
|
variant: 'standard'
|
2916
2929
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
2
|
+
import { TimePickerProps } from '@mui/x-date-pickers/TimePicker';
|
1
3
|
import { ReactNode } from 'react';
|
2
4
|
import { Control } from 'react-hook-form';
|
3
|
-
type Props = {
|
5
|
+
type Props = Partial<TimePickerProps<unknown, unknown>> & {
|
4
6
|
/**
|
5
7
|
* React Hook Form `control`
|
6
8
|
*/
|
@@ -10,10 +12,12 @@ type Props = {
|
|
10
12
|
*/
|
11
13
|
required?: boolean;
|
12
14
|
name: string;
|
15
|
+
placeholder?: string;
|
16
|
+
textFieldProps?: TextFieldProps;
|
13
17
|
label?: ReactNode;
|
14
18
|
format?: string;
|
15
19
|
hideErrorMessage?: boolean;
|
16
20
|
requiredErrorText?: string;
|
17
21
|
};
|
18
|
-
export declare const ControlTime: ({ control, name, required, label, format, hideErrorMessage, requiredErrorText, }: Props) => JSX.Element;
|
22
|
+
export declare const ControlTime: ({ control, name, required, label, textFieldProps, format, hideErrorMessage, requiredErrorText, placeholder, ...timePickerProps }: Props) => JSX.Element;
|
19
23
|
export default ControlTime;
|