@dartech/arsenal-ui 1.4.41 → 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, isMatch, isValid } from 'date-fns';
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({
@@ -2231,10 +2231,18 @@ const ControlDate = _a => {
2231
2231
  format: format$1 = DATE_DEFAULT_FORMAT,
2232
2232
  hideErrorMessage = false,
2233
2233
  textFieldProps = {},
2234
- requiredErrorText = ''
2234
+ requiredErrorText = '',
2235
+ validate,
2236
+ validateErrorText
2235
2237
  } = _a,
2236
- datePickerProps = __rest(_a, ["control", "name", "required", "label", "placeholder", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText"]);
2238
+ datePickerProps = __rest(_a, ["control", "name", "required", "label", "placeholder", "format", "hideErrorMessage", "textFieldProps", "requiredErrorText", "validate", "validateErrorText"]);
2237
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
+ };
2238
2246
  const {
2239
2247
  field,
2240
2248
  fieldState: {
@@ -2245,12 +2253,7 @@ const ControlDate = _a => {
2245
2253
  name,
2246
2254
  rules: {
2247
2255
  required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
2248
- validate: val => {
2249
- if (val === '' || isMatch(val, localFormat)) {
2250
- return true;
2251
- }
2252
- return 'Incorrect date format';
2253
- }
2256
+ validate: validate ? validate : defaultValidate
2254
2257
  }
2255
2258
  });
2256
2259
  const handleChange = useCallback(date => {
@@ -2312,10 +2315,18 @@ const ControlDateTime = _a => {
2312
2315
  format: format$1 = DATE_TIME_DEFAULT_FORMAT,
2313
2316
  hideErrorMessage = false,
2314
2317
  textFieldProps,
2315
- requiredErrorText = ''
2318
+ requiredErrorText = '',
2319
+ validate,
2320
+ validateErrorText
2316
2321
  } = _a,
2317
- 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"]);
2318
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
+ };
2319
2330
  const {
2320
2331
  field,
2321
2332
  fieldState: {
@@ -2326,12 +2337,7 @@ const ControlDateTime = _a => {
2326
2337
  name,
2327
2338
  rules: {
2328
2339
  required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
2329
- validate: val => {
2330
- if (isMatch(val, localFormat)) {
2331
- return true;
2332
- }
2333
- return 'Incorrect date format';
2334
- }
2340
+ validate: validate ? validate : defaultValidate
2335
2341
  }
2336
2342
  });
2337
2343
  const handleChange = useCallback(date => {
@@ -8034,4 +8040,4 @@ const Breadcrumbs = ({
8034
8040
  }));
8035
8041
  };
8036
8042
 
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 };
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.4.41",
3
+ "version": "1.4.42",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -11,3 +11,4 @@ export declare const defaultDefinitionObjectValue: {
11
11
  properties: {};
12
12
  };
13
13
  export declare const DEFAULT_REQUIRED_ERROR_TEXT = "Please, fill this field";
14
+ export declare const DEFAULT_DATE_VALIDATION_ERROR_TEXT = "Incorrect date format";
@@ -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`
@@ -18,6 +18,8 @@ type ControlDateProps = Partial<DatePickerProps<unknown, unknown>> & {
18
18
  hideErrorMessage?: boolean;
19
19
  textFieldProps?: TextFieldProps;
20
20
  requiredErrorText?: string;
21
+ validate?: Validate<any, any>;
22
+ validateErrorText?: string;
21
23
  };
22
- export declare const ControlDate: ({ control, name, required, label, placeholder, 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;
23
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;