@dartech/arsenal-ui 1.4.40 → 1.4.42
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
@@ -35,7 +35,7 @@ import { langs } from '@uiw/codemirror-extensions-langs';
|
|
35
35
|
import { abcdef } from '@uiw/codemirror-theme-abcdef';
|
36
36
|
import Switch from '@mui/material/Switch';
|
37
37
|
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
38
|
-
import { format, parse,
|
38
|
+
import { format, parse, isValid, isMatch } from 'date-fns';
|
39
39
|
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
|
40
40
|
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
|
41
41
|
import Chip from '@mui/material/Chip';
|
@@ -257,6 +257,7 @@ const defaultDefinitionObjectValue = {
|
|
257
257
|
properties: {}
|
258
258
|
};
|
259
259
|
const DEFAULT_REQUIRED_ERROR_TEXT = 'Please, fill this field';
|
260
|
+
const DEFAULT_DATE_VALIDATION_ERROR_TEXT = 'Incorrect date format';
|
260
261
|
|
261
262
|
/**
|
262
263
|
* Material UI `TextField` controlled component. Used with react-hook-form
|
@@ -648,8 +649,7 @@ const ControlCheckbox = _a => {
|
|
648
649
|
onChange: customOnChange ? customOnChange : onChange,
|
649
650
|
name: name,
|
650
651
|
inputRef: ref,
|
651
|
-
disabled: disabled
|
652
|
-
defaultChecked: checked
|
652
|
+
disabled: disabled
|
653
653
|
}, checkboxProps)),
|
654
654
|
label: label
|
655
655
|
}), !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message) && jsx(FormHelperText, Object.assign({
|
@@ -2227,13 +2227,22 @@ const ControlDate = _a => {
|
|
2227
2227
|
name,
|
2228
2228
|
required,
|
2229
2229
|
label,
|
2230
|
+
placeholder,
|
2230
2231
|
format: format$1 = DATE_DEFAULT_FORMAT,
|
2231
2232
|
hideErrorMessage = false,
|
2232
2233
|
textFieldProps = {},
|
2233
|
-
requiredErrorText = ''
|
2234
|
+
requiredErrorText = '',
|
2235
|
+
validate,
|
2236
|
+
validateErrorText
|
2234
2237
|
} = _a,
|
2235
|
-
datePickerProps = __rest(_a, ["control", "name", "required", "label", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText"]);
|
2238
|
+
datePickerProps = __rest(_a, ["control", "name", "required", "label", "placeholder", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText", "validate", "validateErrorText"]);
|
2236
2239
|
const [localFormat, setLocalFormat] = useState(DATE_DEFAULT_FORMAT);
|
2240
|
+
const defaultValidate = val => {
|
2241
|
+
if (val === '' || isMatch(val, localFormat)) {
|
2242
|
+
return true;
|
2243
|
+
}
|
2244
|
+
return validateErrorText ? validateErrorText : DEFAULT_DATE_VALIDATION_ERROR_TEXT;
|
2245
|
+
};
|
2237
2246
|
const {
|
2238
2247
|
field,
|
2239
2248
|
fieldState: {
|
@@ -2244,12 +2253,7 @@ const ControlDate = _a => {
|
|
2244
2253
|
name,
|
2245
2254
|
rules: {
|
2246
2255
|
required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
|
2247
|
-
validate:
|
2248
|
-
if (val === '' || isMatch(val, localFormat)) {
|
2249
|
-
return true;
|
2250
|
-
}
|
2251
|
-
return 'Incorrect date format';
|
2252
|
-
}
|
2256
|
+
validate: validate ? validate : defaultValidate
|
2253
2257
|
}
|
2254
2258
|
});
|
2255
2259
|
const handleChange = useCallback(date => {
|
@@ -2287,7 +2291,10 @@ const ControlDate = _a => {
|
|
2287
2291
|
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
2288
2292
|
FormHelperTextProps: {
|
2289
2293
|
variant: 'standard'
|
2290
|
-
}
|
2294
|
+
},
|
2295
|
+
inputProps: Object.assign(Object.assign({}, params.inputProps), {
|
2296
|
+
placeholder: placeholder
|
2297
|
+
})
|
2291
2298
|
}, textFieldProps))
|
2292
2299
|
}))]
|
2293
2300
|
});
|
@@ -2308,10 +2315,18 @@ const ControlDateTime = _a => {
|
|
2308
2315
|
format: format$1 = DATE_TIME_DEFAULT_FORMAT,
|
2309
2316
|
hideErrorMessage = false,
|
2310
2317
|
textFieldProps,
|
2311
|
-
requiredErrorText = ''
|
2318
|
+
requiredErrorText = '',
|
2319
|
+
validate,
|
2320
|
+
validateErrorText
|
2312
2321
|
} = _a,
|
2313
|
-
dateTimePickerProps = __rest(_a, ["control", "name", "required", "label", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText"]);
|
2322
|
+
dateTimePickerProps = __rest(_a, ["control", "name", "required", "label", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText", "validate", "validateErrorText"]);
|
2314
2323
|
const [localFormat, setLocalFormat] = useState();
|
2324
|
+
const defaultValidate = val => {
|
2325
|
+
if (val === '' || isMatch(val, localFormat)) {
|
2326
|
+
return true;
|
2327
|
+
}
|
2328
|
+
return validateErrorText ? validateErrorText : DEFAULT_DATE_VALIDATION_ERROR_TEXT;
|
2329
|
+
};
|
2315
2330
|
const {
|
2316
2331
|
field,
|
2317
2332
|
fieldState: {
|
@@ -2322,12 +2337,7 @@ const ControlDateTime = _a => {
|
|
2322
2337
|
name,
|
2323
2338
|
rules: {
|
2324
2339
|
required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
|
2325
|
-
validate:
|
2326
|
-
if (isMatch(val, localFormat)) {
|
2327
|
-
return true;
|
2328
|
-
}
|
2329
|
-
return 'Incorrect date format';
|
2330
|
-
}
|
2340
|
+
validate: validate ? validate : defaultValidate
|
2331
2341
|
}
|
2332
2342
|
});
|
2333
2343
|
const handleChange = useCallback(date => {
|
@@ -8030,4 +8040,4 @@ const Breadcrumbs = ({
|
|
8030
8040
|
}));
|
8031
8041
|
};
|
8032
8042
|
|
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 };
|
8043
|
+
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_DATE_VALIDATION_ERROR_TEXT, 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
package/src/consts/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ReactNode } from 'react';
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
3
3
|
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
4
|
-
import { Control } from 'react-hook-form';
|
4
|
+
import { Control, Validate } from 'react-hook-form';
|
5
5
|
type ControlDateProps = Partial<DatePickerProps<unknown, unknown>> & {
|
6
6
|
/**
|
7
7
|
* React Hook Form `control`
|
@@ -14,9 +14,12 @@ 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;
|
21
|
+
validate?: Validate<any, any>;
|
22
|
+
validateErrorText?: string;
|
20
23
|
};
|
21
|
-
export declare const ControlDate: ({ control, name, required, label, format, hideErrorMessage, textFieldProps, requiredErrorText, ...datePickerProps }: ControlDateProps) => JSX.Element;
|
24
|
+
export declare const ControlDate: ({ control, name, required, label, placeholder, format, hideErrorMessage, textFieldProps, requiredErrorText, validate, validateErrorText, ...datePickerProps }: ControlDateProps) => JSX.Element;
|
22
25
|
export default ControlDate;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ReactNode } from 'react';
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
3
3
|
import { DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';
|
4
|
-
import { Control } from 'react-hook-form';
|
4
|
+
import { Control, Validate } from 'react-hook-form';
|
5
5
|
type dateTimePickerProps = Partial<DateTimePickerProps<unknown, unknown>> & {
|
6
6
|
/**
|
7
7
|
* React Hook Form `control`
|
@@ -17,6 +17,8 @@ type dateTimePickerProps = Partial<DateTimePickerProps<unknown, unknown>> & {
|
|
17
17
|
hideErrorMessage?: boolean;
|
18
18
|
textFieldProps?: TextFieldProps;
|
19
19
|
requiredErrorText?: string;
|
20
|
+
validate?: Validate<any, any>;
|
21
|
+
validateErrorText?: string;
|
20
22
|
};
|
21
|
-
export declare const ControlDateTime: ({ control, name, required, label, format, hideErrorMessage, textFieldProps, requiredErrorText, ...dateTimePickerProps }: dateTimePickerProps) => JSX.Element;
|
23
|
+
export declare const ControlDateTime: ({ control, name, required, label, format, hideErrorMessage, textFieldProps, requiredErrorText, validate, validateErrorText, ...dateTimePickerProps }: dateTimePickerProps) => JSX.Element;
|
22
24
|
export default ControlDateTime;
|