@dartech/arsenal-ui 1.4.39 → 1.4.41
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/index.js
CHANGED
@@ -883,11 +883,15 @@ const ControlAutocomplete = _a => {
|
|
883
883
|
children: "*"
|
884
884
|
})]
|
885
885
|
}) : label,
|
886
|
+
InputLabelProps: {
|
887
|
+
shrink: !!(autocompleteProps === null || autocompleteProps === void 0 ? void 0 : autocompleteProps.placeholder)
|
888
|
+
},
|
886
889
|
sx: {
|
887
890
|
'.MuiInputLabel-root span': {
|
888
891
|
color: '#D6331F'
|
889
892
|
}
|
890
893
|
},
|
894
|
+
placeholder: autocompleteProps === null || autocompleteProps === void 0 ? void 0 : autocompleteProps.placeholder,
|
891
895
|
error: !!error,
|
892
896
|
inputRef: ref,
|
893
897
|
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
@@ -1057,6 +1061,9 @@ function ControlQueryAutocomplete(_a) {
|
|
1057
1061
|
children: "*"
|
1058
1062
|
})]
|
1059
1063
|
}) : label,
|
1064
|
+
InputLabelProps: {
|
1065
|
+
shrink: true
|
1066
|
+
},
|
1060
1067
|
sx: {
|
1061
1068
|
'.MuiInputLabel-root span': {
|
1062
1069
|
color: '#D6331F'
|
@@ -2039,6 +2046,11 @@ const getSinglePropertyFillOptions = ({
|
|
2039
2046
|
return options;
|
2040
2047
|
};
|
2041
2048
|
|
2049
|
+
const DEFAULT_ERROR_TEXT = {
|
2050
|
+
required: DEFAULT_REQUIRED_ERROR_TEXT,
|
2051
|
+
notValidNumber: 'Not valid number',
|
2052
|
+
notValidInteger: 'Not valid integer'
|
2053
|
+
};
|
2042
2054
|
const ControlNumberInput = _a => {
|
2043
2055
|
var _b, _c;
|
2044
2056
|
var {
|
@@ -2053,22 +2065,25 @@ const ControlNumberInput = _a => {
|
|
2053
2065
|
onChange: customOnChange,
|
2054
2066
|
decimal = false,
|
2055
2067
|
valueAsNumber = true,
|
2056
|
-
|
2057
|
-
|
2068
|
+
useFormattedInputValue = false,
|
2069
|
+
errorText
|
2058
2070
|
} = _a,
|
2059
|
-
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]);
|
2060
2075
|
const _d = useController({
|
2061
2076
|
name,
|
2062
2077
|
control,
|
2063
2078
|
defaultValue,
|
2064
2079
|
rules: {
|
2065
|
-
required: required ?
|
2080
|
+
required: required ? textError.required : false,
|
2066
2081
|
validate: val => {
|
2067
2082
|
if (val === null || val === 0) return true;
|
2068
2083
|
if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
|
2069
|
-
return
|
2084
|
+
return textError.notValidNumber;
|
2070
2085
|
} else if (!decimal && !digitsOnly.test(val)) {
|
2071
|
-
return
|
2086
|
+
return textError.notValidInteger;
|
2072
2087
|
}
|
2073
2088
|
return validate ? typeof validate === 'function' ? validate(val) : true : true;
|
2074
2089
|
}
|
@@ -2212,12 +2227,13 @@ const ControlDate = _a => {
|
|
2212
2227
|
name,
|
2213
2228
|
required,
|
2214
2229
|
label,
|
2230
|
+
placeholder,
|
2215
2231
|
format: format$1 = DATE_DEFAULT_FORMAT,
|
2216
2232
|
hideErrorMessage = false,
|
2217
2233
|
textFieldProps = {},
|
2218
2234
|
requiredErrorText = ''
|
2219
2235
|
} = _a,
|
2220
|
-
datePickerProps = __rest(_a, ["control", "name", "required", "label", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText"]);
|
2236
|
+
datePickerProps = __rest(_a, ["control", "name", "required", "label", "placeholder", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText"]);
|
2221
2237
|
const [localFormat, setLocalFormat] = useState(DATE_DEFAULT_FORMAT);
|
2222
2238
|
const {
|
2223
2239
|
field,
|
@@ -2249,38 +2265,36 @@ const ControlDate = _a => {
|
|
2249
2265
|
console.error(e);
|
2250
2266
|
}
|
2251
2267
|
}, [format$1]);
|
2252
|
-
return
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
})
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
OpenPickerIcon: DateIconComponent$1
|
2265
|
-
}
|
2266
|
-
}, datePickerProps, {
|
2267
|
-
renderInput: params => jsx(TextField, Object.assign({}, params, {
|
2268
|
-
fullWidth: true,
|
2269
|
-
size: "small",
|
2270
|
-
sx: {
|
2271
|
-
'.MuiInputLabel-root span': {
|
2272
|
-
color: '#D6331F'
|
2273
|
-
}
|
2274
|
-
},
|
2275
|
-
variant: "outlined",
|
2276
|
-
name: name,
|
2277
|
-
error: !!error,
|
2278
|
-
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
2279
|
-
FormHelperTextProps: {
|
2280
|
-
variant: 'standard'
|
2268
|
+
return jsxs(Fragment, {
|
2269
|
+
children: [jsx(FormLabel, Object.assign({
|
2270
|
+
required: required
|
2271
|
+
}, {
|
2272
|
+
children: label
|
2273
|
+
})), jsx(DatePicker, Object.assign({}, field, localFormat ? {
|
2274
|
+
inputFormat: localFormat
|
2275
|
+
} : {}, {
|
2276
|
+
value: localFormat ? parse(field.value, localFormat, new Date()) : field.value,
|
2277
|
+
onChange: handleChange,
|
2278
|
+
components: {
|
2279
|
+
OpenPickerIcon: DateIconComponent$1
|
2281
2280
|
}
|
2282
|
-
},
|
2283
|
-
|
2281
|
+
}, datePickerProps, {
|
2282
|
+
renderInput: params => jsx(TextField, Object.assign({}, params, {
|
2283
|
+
fullWidth: true,
|
2284
|
+
size: "small",
|
2285
|
+
variant: "outlined",
|
2286
|
+
name: name,
|
2287
|
+
error: !!error,
|
2288
|
+
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
2289
|
+
FormHelperTextProps: {
|
2290
|
+
variant: 'standard'
|
2291
|
+
},
|
2292
|
+
inputProps: Object.assign(Object.assign({}, params.inputProps), {
|
2293
|
+
placeholder: placeholder
|
2294
|
+
})
|
2295
|
+
}, textFieldProps))
|
2296
|
+
}))]
|
2297
|
+
});
|
2284
2298
|
};
|
2285
2299
|
|
2286
2300
|
const DateIconComponent = () => {
|
@@ -7099,6 +7113,10 @@ const inputThemeOptions = {
|
|
7099
7113
|
},
|
7100
7114
|
MuiFormLabel: {
|
7101
7115
|
styleOverrides: {
|
7116
|
+
root: {
|
7117
|
+
fontSize: 14,
|
7118
|
+
fontWeight: 500
|
7119
|
+
},
|
7102
7120
|
asterisk: {
|
7103
7121
|
color: '#D6331F',
|
7104
7122
|
'&$error': {
|
@@ -8016,4 +8034,4 @@ const Breadcrumbs = ({
|
|
8016
8034
|
}));
|
8017
8035
|
};
|
8018
8036
|
|
8019
|
-
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 };
|
8037
|
+
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
@@ -14,9 +14,10 @@ type ControlDateProps = Partial<DatePickerProps<unknown, unknown>> & {
|
|
14
14
|
name: string;
|
15
15
|
label?: ReactNode;
|
16
16
|
format?: string;
|
17
|
+
placeholder?: string;
|
17
18
|
hideErrorMessage?: boolean;
|
18
19
|
textFieldProps?: TextFieldProps;
|
19
20
|
requiredErrorText?: string;
|
20
21
|
};
|
21
|
-
export declare const ControlDate: ({ control, name, required, label, format, hideErrorMessage, textFieldProps, requiredErrorText, ...datePickerProps }: ControlDateProps) => JSX.Element;
|
22
|
+
export declare const ControlDate: ({ control, name, required, label, placeholder, format, hideErrorMessage, textFieldProps, requiredErrorText, ...datePickerProps }: ControlDateProps) => JSX.Element;
|
22
23
|
export default ControlDate;
|
@@ -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;
|