@dartech/arsenal-ui 1.4.38 → 1.4.40
Sign up to get free protection for your applications and to get access to all the features.
package/index.js
CHANGED
@@ -709,6 +709,17 @@ const ControlRadio = ({
|
|
709
709
|
if (typeof option === 'string') return option;
|
710
710
|
return labelKey ? option[labelKey] : option.label;
|
711
711
|
}, [labelKey]);
|
712
|
+
const setChecked = useCallback(optionValue => {
|
713
|
+
if (typeof optionValue === 'string') return optionValue === fieldProps.value;
|
714
|
+
return optionValue === (typeof fieldProps.value === 'string' ? fieldProps.value === 'true' : fieldProps.value);
|
715
|
+
}, [fieldProps.value]);
|
716
|
+
const localOnChange = useCallback(e => {
|
717
|
+
if (e.target.value === 'true' || e.target.value === 'false') {
|
718
|
+
onChange(e.target.value === 'true');
|
719
|
+
} else {
|
720
|
+
onChange(e);
|
721
|
+
}
|
722
|
+
}, [onChange]);
|
712
723
|
return jsxs(FormControl, Object.assign({
|
713
724
|
disabled: disabled,
|
714
725
|
error: !!error
|
@@ -720,11 +731,13 @@ const ControlRadio = ({
|
|
720
731
|
})), jsx(RadioGroup, Object.assign({}, fieldProps, {
|
721
732
|
row: row,
|
722
733
|
"aria-labelledby": "radio-buttons-group",
|
723
|
-
onChange: customOnChange ? customOnChange :
|
734
|
+
onChange: customOnChange ? customOnChange : localOnChange
|
724
735
|
}, {
|
725
736
|
children: _values.map((item, i) => jsx(FormControlLabel, {
|
726
737
|
value: getValue(item),
|
727
|
-
control: jsx(Radio, Object.assign({}, radioProps
|
738
|
+
control: jsx(Radio, Object.assign({}, radioProps, {
|
739
|
+
checked: setChecked(getValue(item))
|
740
|
+
})),
|
728
741
|
label: getLabel(item)
|
729
742
|
}, i))
|
730
743
|
})), !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message) && jsx(FormHelperText, Object.assign({
|
@@ -870,11 +883,15 @@ const ControlAutocomplete = _a => {
|
|
870
883
|
children: "*"
|
871
884
|
})]
|
872
885
|
}) : label,
|
886
|
+
InputLabelProps: {
|
887
|
+
shrink: !!(autocompleteProps === null || autocompleteProps === void 0 ? void 0 : autocompleteProps.placeholder)
|
888
|
+
},
|
873
889
|
sx: {
|
874
890
|
'.MuiInputLabel-root span': {
|
875
891
|
color: '#D6331F'
|
876
892
|
}
|
877
893
|
},
|
894
|
+
placeholder: autocompleteProps === null || autocompleteProps === void 0 ? void 0 : autocompleteProps.placeholder,
|
878
895
|
error: !!error,
|
879
896
|
inputRef: ref,
|
880
897
|
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
@@ -1044,6 +1061,9 @@ function ControlQueryAutocomplete(_a) {
|
|
1044
1061
|
children: "*"
|
1045
1062
|
})]
|
1046
1063
|
}) : label,
|
1064
|
+
InputLabelProps: {
|
1065
|
+
shrink: true
|
1066
|
+
},
|
1047
1067
|
sx: {
|
1048
1068
|
'.MuiInputLabel-root span': {
|
1049
1069
|
color: '#D6331F'
|
@@ -2026,6 +2046,11 @@ const getSinglePropertyFillOptions = ({
|
|
2026
2046
|
return options;
|
2027
2047
|
};
|
2028
2048
|
|
2049
|
+
const DEFAULT_ERROR_TEXT = {
|
2050
|
+
required: DEFAULT_REQUIRED_ERROR_TEXT,
|
2051
|
+
notValidNumber: 'Not valid number',
|
2052
|
+
notValidInteger: 'Not valid integer'
|
2053
|
+
};
|
2029
2054
|
const ControlNumberInput = _a => {
|
2030
2055
|
var _b, _c;
|
2031
2056
|
var {
|
@@ -2040,22 +2065,25 @@ const ControlNumberInput = _a => {
|
|
2040
2065
|
onChange: customOnChange,
|
2041
2066
|
decimal = false,
|
2042
2067
|
valueAsNumber = true,
|
2043
|
-
|
2044
|
-
|
2068
|
+
useFormattedInputValue = false,
|
2069
|
+
errorText
|
2045
2070
|
} = _a,
|
2046
|
-
textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "decimal", "valueAsNumber", "
|
2071
|
+
textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "decimal", "valueAsNumber", "useFormattedInputValue", "errorText"]);
|
2072
|
+
const textError = useMemo(() => {
|
2073
|
+
return errorText || DEFAULT_ERROR_TEXT;
|
2074
|
+
}, [errorText]);
|
2047
2075
|
const _d = useController({
|
2048
2076
|
name,
|
2049
2077
|
control,
|
2050
2078
|
defaultValue,
|
2051
2079
|
rules: {
|
2052
|
-
required: required ?
|
2080
|
+
required: required ? textError.required : false,
|
2053
2081
|
validate: val => {
|
2054
2082
|
if (val === null || val === 0) return true;
|
2055
2083
|
if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
|
2056
|
-
return
|
2084
|
+
return textError.notValidNumber;
|
2057
2085
|
} else if (!decimal && !digitsOnly.test(val)) {
|
2058
|
-
return
|
2086
|
+
return textError.notValidInteger;
|
2059
2087
|
}
|
2060
2088
|
return validate ? typeof validate === 'function' ? validate(val) : true : true;
|
2061
2089
|
}
|
@@ -2236,38 +2264,33 @@ const ControlDate = _a => {
|
|
2236
2264
|
console.error(e);
|
2237
2265
|
}
|
2238
2266
|
}, [format$1]);
|
2239
|
-
return
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
})
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
OpenPickerIcon: DateIconComponent$1
|
2252
|
-
}
|
2253
|
-
}, datePickerProps, {
|
2254
|
-
renderInput: params => jsx(TextField, Object.assign({}, params, {
|
2255
|
-
fullWidth: true,
|
2256
|
-
size: "small",
|
2257
|
-
sx: {
|
2258
|
-
'.MuiInputLabel-root span': {
|
2259
|
-
color: '#D6331F'
|
2260
|
-
}
|
2261
|
-
},
|
2262
|
-
variant: "outlined",
|
2263
|
-
name: name,
|
2264
|
-
error: !!error,
|
2265
|
-
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
2266
|
-
FormHelperTextProps: {
|
2267
|
-
variant: 'standard'
|
2267
|
+
return jsxs(Fragment, {
|
2268
|
+
children: [jsx(FormLabel, Object.assign({
|
2269
|
+
required: required
|
2270
|
+
}, {
|
2271
|
+
children: label
|
2272
|
+
})), jsx(DatePicker, Object.assign({}, field, localFormat ? {
|
2273
|
+
inputFormat: localFormat
|
2274
|
+
} : {}, {
|
2275
|
+
value: localFormat ? parse(field.value, localFormat, new Date()) : field.value,
|
2276
|
+
onChange: handleChange,
|
2277
|
+
components: {
|
2278
|
+
OpenPickerIcon: DateIconComponent$1
|
2268
2279
|
}
|
2269
|
-
},
|
2270
|
-
|
2280
|
+
}, datePickerProps, {
|
2281
|
+
renderInput: params => jsx(TextField, Object.assign({}, params, {
|
2282
|
+
fullWidth: true,
|
2283
|
+
size: "small",
|
2284
|
+
variant: "outlined",
|
2285
|
+
name: name,
|
2286
|
+
error: !!error,
|
2287
|
+
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
2288
|
+
FormHelperTextProps: {
|
2289
|
+
variant: 'standard'
|
2290
|
+
}
|
2291
|
+
}, textFieldProps))
|
2292
|
+
}))]
|
2293
|
+
});
|
2271
2294
|
};
|
2272
2295
|
|
2273
2296
|
const DateIconComponent = () => {
|
@@ -7086,6 +7109,10 @@ const inputThemeOptions = {
|
|
7086
7109
|
},
|
7087
7110
|
MuiFormLabel: {
|
7088
7111
|
styleOverrides: {
|
7112
|
+
root: {
|
7113
|
+
fontSize: 14,
|
7114
|
+
fontWeight: 500
|
7115
|
+
},
|
7089
7116
|
asterisk: {
|
7090
7117
|
color: '#D6331F',
|
7091
7118
|
'&$error': {
|
@@ -8003,4 +8030,4 @@ const Breadcrumbs = ({
|
|
8003
8030
|
}));
|
8004
8031
|
};
|
8005
8032
|
|
8006
|
-
export { AlertDialog, BackButton, Breadcrumbs, ContentLayout, ControlAceEditor, ControlArrayInput, ControlAutocomplete, ControlCheckbox, ControlDate, ControlDateTime, ControlDebouncedInput, ControlInput, ControlNumberInput, ControlPeriodInput, ControlPhoneInput, ControlQueryAutocomplete, ControlRadio, ControlSelect, ControlSwitch, ControlTime, CopyButton, CreateDefinition, CreatePropertiesList, CreatePropertiesListContext, CreatePropertyFormFields, DATE_DEFAULT_FORMAT, DATE_TIME_DEFAULT_FORMAT, DEFAULT_REQUIRED_ERROR_TEXT, DefinitionFiller, DefinitionValueView, InfoItem, JsonModalView, JsonPathPicker, JsonView, Loader, MenuIcon, MultiplePropertyFiller, PropertyFiller, PropertyType, PropertyValueField, RoundingMode, RouteTabs, Sidebar, SimpleTable, Status, StepperView, TIME_DEFAULT_FORMAT, TabPanel, Table, TableAction, TableActionCell, ViewPropertiesList, ViewProperty, capitalize, deepParseJson, defaultDefinitionArrayValue, defaultDefinitionObjectValue, digitsOnly, floatsOnly, formatDefinitionData, formatTableRowValue, getDemPropertyDateFormat, getEntityStarterValue, getJsonStringValue, getMultiplePropertyFillOptions, getSinglePropertyFillOptions, isDateType, isExpression, isPropertyValueEmpty, numberFormat, propertiesArrayToObject, propertiesObjectToArray, removeArrayItem, safeParseJson, sortArrayOfObjects, theme, useDebounce, useToggle, validateJson };
|
8033
|
+
export { AlertDialog, BackButton, Breadcrumbs, ContentLayout, ControlAceEditor, ControlArrayInput, ControlAutocomplete, ControlCheckbox, ControlDate, ControlDateTime, ControlDebouncedInput, ControlInput, ControlNumberInput, ControlPeriodInput, ControlPhoneInput, ControlQueryAutocomplete, ControlRadio, ControlSelect, ControlSwitch, ControlTime, CopyButton, CreateDefinition, CreatePropertiesList, CreatePropertiesListContext, CreatePropertyFormFields, DATE_DEFAULT_FORMAT, DATE_TIME_DEFAULT_FORMAT, DEFAULT_ERROR_TEXT, DEFAULT_REQUIRED_ERROR_TEXT, DefinitionFiller, DefinitionValueView, InfoItem, JsonModalView, JsonPathPicker, JsonView, Loader, MenuIcon, MultiplePropertyFiller, PropertyFiller, PropertyType, PropertyValueField, RoundingMode, RouteTabs, Sidebar, SimpleTable, Status, StepperView, TIME_DEFAULT_FORMAT, TabPanel, Table, TableAction, TableActionCell, ViewPropertiesList, ViewProperty, capitalize, deepParseJson, defaultDefinitionArrayValue, defaultDefinitionObjectValue, digitsOnly, floatsOnly, formatDefinitionData, formatTableRowValue, getDemPropertyDateFormat, getEntityStarterValue, getJsonStringValue, getMultiplePropertyFillOptions, getSinglePropertyFillOptions, isDateType, isExpression, isPropertyValueEmpty, numberFormat, propertiesArrayToObject, propertiesObjectToArray, removeArrayItem, safeParseJson, sortArrayOfObjects, theme, useDebounce, useToggle, validateJson };
|
package/package.json
CHANGED
@@ -2,6 +2,16 @@ import type { ReactNode } from 'react';
|
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
3
3
|
import { Control } from 'react-hook-form';
|
4
4
|
import { ValidateFunc } from '../../interfaces';
|
5
|
+
export interface ErrorText {
|
6
|
+
required: string;
|
7
|
+
notValidNumber: string;
|
8
|
+
notValidInteger: string;
|
9
|
+
}
|
10
|
+
export declare const DEFAULT_ERROR_TEXT: {
|
11
|
+
required: string;
|
12
|
+
notValidNumber: string;
|
13
|
+
notValidInteger: string;
|
14
|
+
};
|
5
15
|
type Props = TextFieldProps & {
|
6
16
|
/**
|
7
17
|
* React Hook Form control `name` propery
|
@@ -54,9 +64,9 @@ type Props = TextFieldProps & {
|
|
54
64
|
*/
|
55
65
|
useFormattedInputValue?: boolean;
|
56
66
|
/**
|
57
|
-
* Set
|
67
|
+
* Set error text
|
58
68
|
*/
|
59
|
-
|
69
|
+
errorText?: ErrorText;
|
60
70
|
};
|
61
|
-
export declare const ControlNumberInput: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, decimal, valueAsNumber,
|
71
|
+
export declare const ControlNumberInput: ({ control, validate, name, label, required, defaultValue, disabled, hideErrorMessage, onChange: customOnChange, decimal, valueAsNumber, useFormattedInputValue, errorText, ...textFieldProps }: Props) => JSX.Element;
|
62
72
|
export default ControlNumberInput;
|