@steroidsjs/core 3.0.0-beta.116 → 3.0.0-beta.118

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.
@@ -26,7 +26,13 @@ var showNotification = function (message, level, params) {
26
26
  return function (dispatch) {
27
27
  var _a = params, position = _a.position, timeOut = _a.timeOut;
28
28
  var id = (0, uniqueId_1["default"])();
29
- dispatch({ type: exports.NOTIFICATIONS_SHOW, id: id, message: message, level: level || 'success', position: position });
29
+ dispatch({
30
+ type: exports.NOTIFICATIONS_SHOW,
31
+ id: id,
32
+ message: message,
33
+ level: level || 'success',
34
+ position: position
35
+ });
30
36
  if (timeOut > 0) {
31
37
  setTimeout(function () { return dispatch((0, exports.closeNotification)(id)); }, timeOut);
32
38
  }
@@ -84,7 +84,8 @@ var MetricsComponent = /** @class */ (function () {
84
84
  (function (w, d, s, l, i) {
85
85
  w[l] = w[l] || [];
86
86
  w[l].push({
87
- 'gtm.start': new Date().getTime(), event: 'gtm.js'
87
+ 'gtm.start': new Date().getTime(),
88
+ event: 'gtm.js'
88
89
  });
89
90
  var f = d.getElementsByTagName(s)[0];
90
91
  var j = d.createElement(s);
@@ -16622,6 +16622,15 @@
16622
16622
  "example": "'Visible'",
16623
16623
  "defaultValue": null
16624
16624
  },
16625
+ {
16626
+ "name": "maskOptions",
16627
+ "decorators": [],
16628
+ "description": "Опции маски для полей",
16629
+ "required": false,
16630
+ "type": "{from: MaskitoOptions, to: MaskitoOptions}",
16631
+ "example": null,
16632
+ "defaultValue": null
16633
+ },
16625
16634
  {
16626
16635
  "name": "model",
16627
16636
  "decorators": [],
@@ -16871,6 +16880,22 @@
16871
16880
  "type": "boolean",
16872
16881
  "example": null
16873
16882
  },
16883
+ {
16884
+ "name": "maskInputFromRef",
16885
+ "decorators": [],
16886
+ "description": "",
16887
+ "required": false,
16888
+ "type": "{}",
16889
+ "example": null
16890
+ },
16891
+ {
16892
+ "name": "maskInputFromTo",
16893
+ "decorators": [],
16894
+ "description": "",
16895
+ "required": false,
16896
+ "type": "{}",
16897
+ "example": null
16898
+ },
16874
16899
  {
16875
16900
  "name": "showRemove",
16876
16901
  "decorators": [],
@@ -17082,6 +17107,15 @@
17082
17107
  "example": "'Visible'",
17083
17108
  "defaultValue": null
17084
17109
  },
17110
+ {
17111
+ "name": "maskOptions",
17112
+ "decorators": [],
17113
+ "description": "Опции маски для поля ввода",
17114
+ "required": false,
17115
+ "type": "MaskitoOptions",
17116
+ "example": null,
17117
+ "defaultValue": null
17118
+ },
17085
17119
  {
17086
17120
  "name": "model",
17087
17121
  "decorators": [],
@@ -17265,6 +17299,14 @@
17265
17299
  "type": "boolean",
17266
17300
  "example": null
17267
17301
  },
17302
+ {
17303
+ "name": "maskInputRef",
17304
+ "decorators": [],
17305
+ "description": "",
17306
+ "required": false,
17307
+ "type": "{}",
17308
+ "example": null
17309
+ },
17268
17310
  {
17269
17311
  "name": "showRemove",
17270
17312
  "decorators": [],
@@ -17398,6 +17440,15 @@
17398
17440
  "example": null,
17399
17441
  "defaultValue": null
17400
17442
  },
17443
+ {
17444
+ "name": "maskOptions",
17445
+ "decorators": [],
17446
+ "description": "Опции маски для полей",
17447
+ "required": false,
17448
+ "type": "{from: MaskitoOptions, to: MaskitoOptions}",
17449
+ "example": null,
17450
+ "defaultValue": null
17451
+ },
17401
17452
  {
17402
17453
  "name": "pickerProps",
17403
17454
  "decorators": [],
package/en.json CHANGED
@@ -962,5 +962,6 @@
962
962
  "Кастомный placeholder для инпута": "",
963
963
  "Кастомная иконка, заменяющая иконку раскрытия по умолчанию": "",
964
964
  "Показать иконку c лева от элемента": "",
965
+ "Опции маски для полей": "",
965
966
  "Флаг, который позволяет использовать вложенные роуты c указанием вложенного пути": ""
966
967
  }
@@ -158,6 +158,9 @@ function useApplication(config) {
158
158
  }
159
159
  return (React.createElement(react_redux_1.Provider, { store: components.store.store }, content));
160
160
  }, [components, config, useGlobal]);
161
- return { renderApplication: renderApplication, components: components };
161
+ return {
162
+ renderApplication: renderApplication,
163
+ components: components
164
+ };
162
165
  }
163
166
  exports["default"] = useApplication;
package/hooks/useFetch.js CHANGED
@@ -160,6 +160,11 @@ function useFetch(rawConfig) {
160
160
  (0, react_use_1.useUpdateEffect)(function () {
161
161
  fetch();
162
162
  }, [fetch]);
163
- return { data: data, isLoading: isLoading, fetch: fetch, axiosError: axiosError };
163
+ return {
164
+ data: data,
165
+ isLoading: isLoading,
166
+ fetch: fetch,
167
+ axiosError: axiosError
168
+ };
164
169
  }
165
170
  exports["default"] = useFetch;
package/hooks/useList.js CHANGED
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  };
39
39
  exports.__esModule = true;
40
40
  exports.createInitialValues = exports.getDefaultSearchModel = exports.normalizeSortProps = exports.defaultConfig = void 0;
41
+ /* eslint-disable @typescript-eslint/no-use-before-define */
41
42
  var react_1 = __importStar(require("react"));
42
43
  var get_1 = __importDefault(require("lodash-es/get"));
43
44
  var union_1 = __importDefault(require("lodash-es/union"));
@@ -156,10 +157,16 @@ function useList(config) {
156
157
  var searchFormFields = (_b = config.searchForm) === null || _b === void 0 ? void 0 : _b.fields;
157
158
  var SearchForm = require('../ui/list/SearchForm')["default"];
158
159
  var initialValuesSearchForm = (0, react_1.useMemo)(function () { return (searchFormFields || []).reduce(function (acc, field) {
160
+ var _a;
159
161
  var attribute = typeof field === 'string' ? field : field.attribute;
160
- acc[attribute] = initialQuery === null || initialQuery === void 0 ? void 0 : initialQuery[attribute];
162
+ if ((_a = config.searchForm) === null || _a === void 0 ? void 0 : _a.initialValues) {
163
+ acc[attribute] = config.searchForm.initialValues[attribute];
164
+ }
165
+ else {
166
+ acc[attribute] = initialQuery === null || initialQuery === void 0 ? void 0 : initialQuery[attribute];
167
+ }
161
168
  return acc;
162
- }, {}); }, [searchFormFields, initialQuery]);
169
+ }, {}); }, [searchFormFields, config.searchForm, initialQuery]);
163
170
  var searchFormProps = __assign(__assign({ listId: config.listId }, config.searchForm), { model: searchModel, initialValues: initialValuesSearchForm });
164
171
  var renderSearchForm = function () { return react_1["default"].createElement(SearchForm, __assign({}, searchFormProps)); };
165
172
  // Form id
package/index.d.ts CHANGED
@@ -95,16 +95,16 @@ declare interface IUiComponent {
95
95
  * Переопределение view React компонента для кастомизации отображения
96
96
  * @example MyCustomView
97
97
  */
98
- view?: CustomView;
98
+ view?: CustomView,
99
99
 
100
100
  /**
101
101
  * Дополнительный CSS-класс для элемента отображения
102
102
  */
103
- className?: CssClassName;
103
+ className?: CssClassName,
104
104
 
105
105
  /**
106
106
  * Объект CSS стилей
107
107
  * @example {width: '45%'}
108
108
  */
109
- style?: CustomStyle;
109
+ style?: CustomStyle,
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "3.0.0-beta.116",
3
+ "version": "3.0.0-beta.118",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -65,7 +65,7 @@
65
65
  "@babel/preset-env": "^7.13.15",
66
66
  "@babel/preset-react": "^7.13.13",
67
67
  "@babel/preset-typescript": "^7.13.0",
68
- "@steroidsjs/eslint-config": "^2.1.4",
68
+ "@steroidsjs/eslint-config": "^2.1.6",
69
69
  "@testing-library/dom": "^8.20.0",
70
70
  "@testing-library/jest-dom": "^5.16.5",
71
71
  "@testing-library/react": "^13.4.0",
@@ -39,7 +39,10 @@ var useMonthGrid = function (currentMonthFirstDayDate, setCurrentMonthFirstDayDa
39
39
  // Пройдемся по всем дням месяца и добавим их в массив
40
40
  for (var dayNumber = 1; dayNumber <= lastDayOfCurrentMonth; dayNumber++) {
41
41
  var date = new Date(Date.UTC(currentYear, month, dayNumber));
42
- daysInCurrentMonth.push({ date: date, dayNumber: dayNumber });
42
+ daysInCurrentMonth.push({
43
+ date: date,
44
+ dayNumber: dayNumber
45
+ });
43
46
  }
44
47
  return {
45
48
  currentMonth: month,
@@ -52,9 +52,15 @@ function Button(props) {
52
52
  ? props.url
53
53
  : (routePath ? (0, router_2.buildUrl)(routePath, props.toRouteParams) : null);
54
54
  // Flags: isLoading, isFailed
55
- var _a = (0, react_1.useState)({ isLoading: false, isFailed: false }), _b = _a[0], isLoading = _b.isLoading, isFailed = _b.isFailed, setStateFlags = _a[1];
55
+ var _a = (0, react_1.useState)({
56
+ isLoading: false,
57
+ isFailed: false
58
+ }), _b = _a[0], isLoading = _b.isLoading, isFailed = _b.isFailed, setStateFlags = _a[1];
56
59
  React.useEffect(function () {
57
- setStateFlags({ isLoading: props.isLoading, isFailed: props.isFailed });
60
+ setStateFlags({
61
+ isLoading: props.isLoading,
62
+ isFailed: props.isFailed
63
+ });
58
64
  }, [props.isLoading, props.isFailed]);
59
65
  // Form submitting
60
66
  var context = (0, react_1.useContext)(Form_1.FormContext);
@@ -48,7 +48,10 @@ DateField.defaultProps = {
48
48
  required: false,
49
49
  showRemove: true,
50
50
  valueFormat: 'YYYY-MM-DD',
51
- maskOptions: (0, kit_1.maskitoDateOptionsGenerator)({ mode: 'dd/mm/yyyy', separator: '.' }),
51
+ maskOptions: (0, kit_1.maskitoDateOptionsGenerator)({
52
+ mode: 'dd/mm/yyyy',
53
+ separator: '.'
54
+ }),
52
55
  size: 'md'
53
56
  };
54
57
  exports["default"] = (0, fieldWrapper_1["default"])('DateField', DateField);
@@ -23,7 +23,7 @@ function useDateRange(props) {
23
23
  // Tracking focus for input being edited
24
24
  var _a = (0, react_1.useState)('from'), focus = _a[0], setFocus = _a[1];
25
25
  var isFirstMount = (0, react_use_1.useFirstMountState)();
26
- // Local refs to handle auto-focus
26
+ // Refs to handle auto-focus
27
27
  var valueFromRef = (0, react_1.useRef)('');
28
28
  var valueToRef = (0, react_1.useRef)('');
29
29
  // Close handler
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+ import { MaskitoOptions } from '@maskito/core';
1
3
  import { ICalendarProps } from '../../content/Calendar/Calendar';
2
4
  import { IDateInputStateInput, IDateInputStateOutput } from '../DateField/useDateInputState';
3
5
  import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../../form/Field/fieldWrapper';
@@ -72,6 +74,19 @@ export interface IDateRangeFieldProps extends IDateInputStateInput, Omit<IFieldW
72
74
  * @example true
73
75
  */
74
76
  hasInitialFocus?: boolean;
77
+ /**
78
+ * Опции маски для полей
79
+ */
80
+ maskOptions?: {
81
+ /**
82
+ * Опции маски для поля from
83
+ */
84
+ from: MaskitoOptions;
85
+ /**
86
+ * Опции маски для поля to
87
+ */
88
+ to: MaskitoOptions;
89
+ };
75
90
  [key: string]: any;
76
91
  }
77
92
  export interface IDateRangeFieldViewProps extends IDateInputStateOutput, Omit<IFieldWrapperOutputProps, 'input'>, Pick<IDateRangeFieldProps, 'size' | 'icon' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'disabled' | 'noBorder' | 'style'> {
@@ -79,6 +94,14 @@ export interface IDateRangeFieldViewProps extends IDateInputStateOutput, Omit<IF
79
94
  inputPropsTo?: any;
80
95
  errorsFrom?: string[];
81
96
  errorsTo?: string[];
97
+ /**
98
+ * Ref для input элемента, который накладывает маску на поле from
99
+ */
100
+ maskInputFromRef?: React.RefCallback<HTMLElement>;
101
+ /**
102
+ * Ref для input элемента, который накладывает маску на поле to
103
+ */
104
+ maskInputFromTo?: React.RefCallback<HTMLElement>;
82
105
  }
83
106
  declare const _default: import("../../form/Field/fieldWrapper").FieldWrapperComponent<IDateRangeFieldProps>;
84
107
  export default _default;
@@ -10,17 +10,45 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
13
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
38
  };
16
39
  exports.__esModule = true;
17
- var react_1 = require("react");
40
+ var react_1 = __importStar(require("react"));
41
+ var kit_1 = require("@maskito/kit");
42
+ var react_2 = require("@maskito/react");
18
43
  var useDateRange_1 = __importDefault(require("../../form/DateField/useDateRange"));
19
44
  var hooks_1 = require("../../../hooks");
20
45
  var useDateInputState_1 = __importDefault(require("../DateField/useDateInputState"));
21
46
  var fieldWrapper_1 = __importDefault(require("../../form/Field/fieldWrapper"));
22
47
  function DateRangeField(props) {
48
+ var _a, _b;
23
49
  var components = (0, hooks_1.useComponents)();
50
+ var maskInputFromRef = (0, react_2.useMaskito)({ options: (_a = props.maskOptions) === null || _a === void 0 ? void 0 : _a.from });
51
+ var maskInputToRef = (0, react_2.useMaskito)({ options: (_b = props.maskOptions) === null || _b === void 0 ? void 0 : _b.to });
24
52
  // Global onChange (from props)
25
53
  var onChange = (0, react_1.useCallback)(function () {
26
54
  var _a;
@@ -32,7 +60,7 @@ function DateRangeField(props) {
32
60
  }
33
61
  }, [props.attributeFrom, props.attributeTo, props.inputFrom.value, props.inputTo.value, props.onChange]);
34
62
  // Input 'from'
35
- var _a = (0, useDateInputState_1["default"])({
63
+ var _c = (0, useDateInputState_1["default"])({
36
64
  displayFormat: props.displayFormat,
37
65
  valueFormat: props.valueFormat,
38
66
  input: props.inputFrom,
@@ -41,9 +69,9 @@ function DateRangeField(props) {
41
69
  required: props.required,
42
70
  inputProps: props.inputPropsFrom,
43
71
  onChange: onChange
44
- }), isOpenedFrom = _a.isOpened, onCloseFrom = _a.onClose, inputPropsFrom = _a.inputProps, onClearFrom = _a.onClear;
72
+ }), isOpenedFrom = _c.isOpened, onCloseFrom = _c.onClose, inputPropsFrom = _c.inputProps, onClearFrom = _c.onClear;
45
73
  // Input 'to'
46
- var _b = (0, useDateInputState_1["default"])({
74
+ var _d = (0, useDateInputState_1["default"])({
47
75
  displayFormat: props.displayFormat,
48
76
  valueFormat: props.valueFormat,
49
77
  input: props.inputTo,
@@ -52,8 +80,8 @@ function DateRangeField(props) {
52
80
  required: props.required,
53
81
  inputProps: props.inputPropsTo,
54
82
  onChange: onChange
55
- }), isOpenedTo = _b.isOpened, onCloseTo = _b.onClose, inputPropsTo = _b.inputProps, onClearTo = _b.onClear;
56
- var _c = (0, useDateRange_1["default"])({
83
+ }), isOpenedTo = _d.isOpened, onCloseTo = _d.onClose, inputPropsTo = _d.inputProps, onClearTo = _d.onClear;
84
+ var _e = (0, useDateRange_1["default"])({
57
85
  onClearFrom: onClearFrom,
58
86
  onCloseTo: onCloseTo,
59
87
  onCloseFrom: onCloseFrom,
@@ -66,7 +94,18 @@ function DateRangeField(props) {
66
94
  hasInitialFocus: props.hasInitialFocus,
67
95
  displayFormat: props.displayFormat,
68
96
  valueFormat: props.valueFormat
69
- }), focus = _c.focus, onClose = _c.onClose, onClear = _c.onClear, extendedInputPropsFrom = _c.extendedInputPropsFrom, extendedInputPropsTo = _c.extendedInputPropsTo;
97
+ }), focus = _e.focus, onClose = _e.onClose, onClear = _e.onClear, extendedInputPropsFrom = _e.extendedInputPropsFrom, extendedInputPropsTo = _e.extendedInputPropsTo;
98
+ react_1["default"].useEffect(function () {
99
+ if (extendedInputPropsFrom.ref && extendedInputPropsTo.ref) {
100
+ maskInputFromRef(extendedInputPropsFrom.ref.current);
101
+ maskInputToRef(extendedInputPropsTo.ref.current);
102
+ }
103
+ }, [
104
+ extendedInputPropsFrom.ref,
105
+ extendedInputPropsTo.ref,
106
+ maskInputFromRef,
107
+ maskInputToRef,
108
+ ]);
70
109
  // Calendar props
71
110
  var calendarProps = (0, react_1.useMemo)(function () { return ({
72
111
  value: [props.inputFrom.value, props.inputTo.value],
@@ -88,6 +127,16 @@ DateRangeField.defaultProps = {
88
127
  hasInitialFocus: false,
89
128
  icon: true,
90
129
  noBorder: false,
91
- size: 'md'
130
+ size: 'md',
131
+ maskOptions: {
132
+ from: (0, kit_1.maskitoDateOptionsGenerator)({
133
+ mode: 'dd/mm/yyyy',
134
+ separator: '.'
135
+ }),
136
+ to: (0, kit_1.maskitoDateOptionsGenerator)({
137
+ mode: 'dd/mm/yyyy',
138
+ separator: '.'
139
+ })
140
+ }
92
141
  };
93
142
  exports["default"] = (0, fieldWrapper_1["default"])('DateRangeField', DateRangeField, { attributeSuffixes: ['from', 'to'] });
@@ -1,3 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { MaskitoOptions } from '@maskito/core';
1
3
  import { ICalendarProps } from '../../content/Calendar/Calendar';
2
4
  import { IDateInputStateInput, IDateInputStateOutput } from '../../form/DateField/useDateInputState';
3
5
  /**
@@ -17,9 +19,17 @@ export interface IDateTimeFieldProps extends IDateInputStateInput, IUiComponent
17
19
  * Свойства для компонента панели времени
18
20
  */
19
21
  timePanelViewProps?: any;
22
+ /**
23
+ * Опции маски для поля ввода
24
+ */
25
+ maskOptions?: MaskitoOptions;
20
26
  [key: string]: any;
21
27
  }
22
28
  export interface IDateTimeFieldViewProps extends IDateInputStateOutput, Pick<IDateTimeFieldProps, 'size' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'timePanelViewProps'> {
29
+ /**
30
+ * Ref для input элемента, который накладывает маску
31
+ */
32
+ maskInputRef?: React.RefCallback<HTMLElement>;
23
33
  [key: string]: any;
24
34
  }
25
35
  declare const _default: import("../../form/Field/fieldWrapper").FieldWrapperComponent<IDateTimeFieldProps>;
@@ -15,17 +15,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  exports.__esModule = true;
17
17
  var react_1 = require("react");
18
+ var kit_1 = require("@maskito/kit");
19
+ var react_2 = require("@maskito/react");
18
20
  var useDateTime_1 = __importDefault(require("../DateField/useDateTime"));
19
21
  var useDateInputState_1 = __importDefault(require("../../form/DateField/useDateInputState"));
20
22
  var fieldWrapper_1 = __importDefault(require("../../form/Field/fieldWrapper"));
21
23
  var hooks_1 = require("../../../hooks");
22
- var DATE_TIME_SEPARATOR = ' ';
24
+ var DATE_TIME_SEPARATOR = ', ';
23
25
  /**
24
26
  * DateTimeField
25
27
  * Поля ввода с выпадающими списками для выбора даты и времени
26
28
  */
27
29
  function DateTimeField(props) {
28
30
  var components = (0, hooks_1.useComponents)();
31
+ var maskInputRef = (0, react_2.useMaskito)({ options: props.maskOptions });
29
32
  var _a = (0, useDateInputState_1["default"])({
30
33
  input: props.input,
31
34
  disabled: props.disabled,
@@ -56,7 +59,7 @@ function DateTimeField(props) {
56
59
  value: timeValue,
57
60
  onSelect: onTimeSelect
58
61
  }); }, [onClose, onTimeSelect, timeValue]);
59
- return components.ui.renderView(props.view || 'form.DateTimeFieldView', __assign(__assign({}, props.viewProps), { isOpened: isOpened, onClear: onClear, onClose: onClose, inputProps: inputProps, calendarProps: calendarProps, timePanelViewProps: timePanelViewProps, size: props.size, icon: props.icon, label: props.label, errors: props.errors, className: props.className, showRemove: props.showRemove, isInvalid: props.isInvalid, disabled: props.disabled, style: props.style }));
62
+ return components.ui.renderView(props.view || 'form.DateTimeFieldView', __assign(__assign({}, props.viewProps), { isOpened: isOpened, onClear: onClear, onClose: onClose, inputProps: inputProps, calendarProps: calendarProps, timePanelViewProps: timePanelViewProps, size: props.size, icon: props.icon, label: props.label, errors: props.errors, className: props.className, showRemove: props.showRemove, isInvalid: props.isInvalid, disabled: props.disabled, style: props.style, maskInputRef: maskInputRef }));
60
63
  }
61
64
  DateTimeField.defaultProps = {
62
65
  disabled: false,
@@ -67,6 +70,11 @@ DateTimeField.defaultProps = {
67
70
  useUTC: false,
68
71
  dateInUTC: false,
69
72
  size: 'md',
70
- icon: true
73
+ icon: true,
74
+ maskOptions: (0, kit_1.maskitoDateTimeOptionsGenerator)({
75
+ dateMode: 'dd/mm/yyyy',
76
+ timeMode: 'HH:MM',
77
+ dateSeparator: '.'
78
+ })
71
79
  };
72
80
  exports["default"] = (0, fieldWrapper_1["default"])('DateTimeField', DateTimeField);
@@ -1,3 +1,4 @@
1
+ import { MaskitoOptions } from '@maskito/core';
1
2
  import { ICalendarProps } from '../../content/Calendar/Calendar';
2
3
  import { IDateRangeFieldProps } from '../../form/DateRangeField/DateRangeField';
3
4
  import { IDateInputStateInput, IDateInputStateOutput } from '../../form/DateField/useDateInputState';
@@ -53,6 +54,19 @@ export interface IDateTimeRangeFieldProps extends Omit<IDateInputStateInput, 'in
53
54
  * @example true
54
55
  */
55
56
  hasInitialFocus?: boolean;
57
+ /**
58
+ * Опции маски для полей
59
+ */
60
+ maskOptions?: {
61
+ /**
62
+ * Опции маски для поля from
63
+ */
64
+ from: MaskitoOptions;
65
+ /**
66
+ * Опции маски для поля to
67
+ */
68
+ to: MaskitoOptions;
69
+ };
56
70
  [key: string]: any;
57
71
  }
58
72
  export interface IDateTimeRangeFieldViewProps extends IDateInputStateOutput, Omit<IFieldWrapperOutputProps, 'input'>, Pick<IDateRangeFieldProps, 'size' | 'icon' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'disabled' | 'noBorder' | 'style'> {
@@ -10,19 +10,47 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
13
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
38
  };
16
39
  exports.__esModule = true;
17
- var react_1 = require("react");
40
+ var react_1 = __importStar(require("react"));
41
+ var kit_1 = require("@maskito/kit");
42
+ var react_2 = require("@maskito/react");
18
43
  var useDateRange_1 = __importDefault(require("../../form/DateField/useDateRange"));
19
44
  var useDateTime_1 = __importDefault(require("../../form/DateField/useDateTime"));
20
45
  var useDateInputState_1 = __importDefault(require("../../form/DateField/useDateInputState"));
21
46
  var fieldWrapper_1 = __importDefault(require("../../form/Field/fieldWrapper"));
22
47
  var hooks_1 = require("../../../hooks");
23
- var DATE_TIME_SEPARATOR = ' ';
48
+ var DATE_TIME_SEPARATOR = ', ';
24
49
  function DateTimeRangeField(props) {
50
+ var _a, _b;
25
51
  var components = (0, hooks_1.useComponents)();
52
+ var maskInputFromRef = (0, react_2.useMaskito)({ options: (_a = props.maskOptions) === null || _a === void 0 ? void 0 : _a.from });
53
+ var maskInputToRef = (0, react_2.useMaskito)({ options: (_b = props.maskOptions) === null || _b === void 0 ? void 0 : _b.to });
26
54
  // Global onChange (from props)
27
55
  var onChange = (0, react_1.useCallback)(function () {
28
56
  var _a;
@@ -34,7 +62,7 @@ function DateTimeRangeField(props) {
34
62
  }
35
63
  }, [props.attributeFrom, props.attributeTo, props.inputFrom.value, props.inputTo.value, props.onChange]);
36
64
  // Input 'from'
37
- var _a = (0, useDateInputState_1["default"])({
65
+ var _c = (0, useDateInputState_1["default"])({
38
66
  displayFormat: props.displayFormat,
39
67
  valueFormat: props.valueFormat,
40
68
  input: props.inputFrom,
@@ -45,9 +73,9 @@ function DateTimeRangeField(props) {
45
73
  useUTC: props.useUTC,
46
74
  dateInUTC: props.dateInUTC,
47
75
  onChange: onChange
48
- }), isOpenedFrom = _a.isOpened, onCloseFrom = _a.onClose, inputPropsFrom = _a.inputProps, onClearFrom = _a.onClear, onNow = _a.onNow;
76
+ }), isOpenedFrom = _c.isOpened, onCloseFrom = _c.onClose, inputPropsFrom = _c.inputProps, onClearFrom = _c.onClear, onNow = _c.onNow;
49
77
  // Input 'to'
50
- var _b = (0, useDateInputState_1["default"])({
78
+ var _d = (0, useDateInputState_1["default"])({
51
79
  displayFormat: props.displayFormat,
52
80
  valueFormat: props.valueFormat,
53
81
  input: props.inputTo,
@@ -58,24 +86,24 @@ function DateTimeRangeField(props) {
58
86
  useUTC: props.useUTC,
59
87
  dateInUTC: props.dateInUTC,
60
88
  onChange: onChange
61
- }), isOpenedTo = _b.isOpened, onCloseTo = _b.onClose, inputPropsTo = _b.inputProps, onClearTo = _b.onClear;
62
- var _c = (0, useDateTime_1["default"])({
89
+ }), isOpenedTo = _d.isOpened, onCloseTo = _d.onClose, inputPropsTo = _d.inputProps, onClearTo = _d.onClear;
90
+ var _e = (0, useDateTime_1["default"])({
63
91
  displayFormat: props.displayFormat,
64
92
  valueFormat: props.valueFormat,
65
93
  dateTimeSeparator: DATE_TIME_SEPARATOR,
66
94
  useUTC: props.useUTC,
67
95
  dateInUTC: props.dateInUTC,
68
96
  input: props.inputFrom
69
- }), dateValueFormat = _c.dateValueFormat, dateValueFrom = _c.dateValue, timeValueFrom = _c.timeValue, onDateFromSelect = _c.onDateSelect, onTimeFromSelect = _c.onTimeSelect;
70
- var _d = (0, useDateTime_1["default"])({
97
+ }), dateValueFormat = _e.dateValueFormat, dateValueFrom = _e.dateValue, timeValueFrom = _e.timeValue, onDateFromSelect = _e.onDateSelect, onTimeFromSelect = _e.onTimeSelect;
98
+ var _f = (0, useDateTime_1["default"])({
71
99
  displayFormat: props.displayFormat,
72
100
  valueFormat: props.valueFormat,
73
101
  dateTimeSeparator: DATE_TIME_SEPARATOR,
74
102
  useUTC: props.useUTC,
75
103
  dateInUTC: props.dateInUTC,
76
104
  input: props.inputTo
77
- }), dateValueTo = _d.dateValue, timeValueTo = _d.timeValue, onDateToSelect = _d.onDateSelect, onTimeToSelect = _d.onTimeSelect;
78
- var _e = (0, useDateRange_1["default"])({
105
+ }), dateValueTo = _f.dateValue, timeValueTo = _f.timeValue, onDateToSelect = _f.onDateSelect, onTimeToSelect = _f.onTimeSelect;
106
+ var _g = (0, useDateRange_1["default"])({
79
107
  onClearFrom: onClearFrom,
80
108
  onCloseTo: onCloseTo,
81
109
  onCloseFrom: onCloseFrom,
@@ -88,7 +116,18 @@ function DateTimeRangeField(props) {
88
116
  hasInitialFocus: props.hasInitialFocus,
89
117
  displayFormat: props.displayFormat,
90
118
  valueFormat: props.valueFormat
91
- }), focus = _e.focus, onClose = _e.onClose, onClear = _e.onClear, extendedInputPropsFrom = _e.extendedInputPropsFrom, extendedInputPropsTo = _e.extendedInputPropsTo;
119
+ }), focus = _g.focus, onClose = _g.onClose, onClear = _g.onClear, extendedInputPropsFrom = _g.extendedInputPropsFrom, extendedInputPropsTo = _g.extendedInputPropsTo;
120
+ react_1["default"].useEffect(function () {
121
+ if (extendedInputPropsFrom.ref && extendedInputPropsTo.ref) {
122
+ maskInputFromRef(extendedInputPropsFrom.ref.current);
123
+ maskInputToRef(extendedInputPropsTo.ref.current);
124
+ }
125
+ }, [
126
+ extendedInputPropsFrom.ref,
127
+ extendedInputPropsTo.ref,
128
+ maskInputFromRef,
129
+ maskInputToRef,
130
+ ]);
92
131
  // Calendar props
93
132
  var calendarProps = (0, react_1.useMemo)(function () { return (__assign({ value: [dateValueFrom, dateValueTo], onChange: focus === 'from' ? onDateFromSelect : onDateToSelect, valueFormat: dateValueFormat }, props.calendarProps)); }, [dateValueFormat, dateValueFrom, dateValueTo, focus, onDateFromSelect, onDateToSelect, props.calendarProps]);
94
133
  // TimePanel props
@@ -115,6 +154,18 @@ DateTimeRangeField.defaultProps = {
115
154
  useUTC: false,
116
155
  dateInUTC: false,
117
156
  icon: true,
118
- size: 'md'
157
+ size: 'md',
158
+ maskOptions: {
159
+ from: (0, kit_1.maskitoDateTimeOptionsGenerator)({
160
+ dateMode: 'dd/mm/yyyy',
161
+ timeMode: 'HH:MM',
162
+ dateSeparator: '.'
163
+ }),
164
+ to: (0, kit_1.maskitoDateTimeOptionsGenerator)({
165
+ dateMode: 'dd/mm/yyyy',
166
+ timeMode: 'HH:MM',
167
+ dateSeparator: '.'
168
+ })
169
+ }
119
170
  };
120
171
  exports["default"] = (0, fieldWrapper_1["default"])('DateTimeRangeField', DateTimeRangeField, { attributeSuffixes: ['from', 'to'] });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
3
  exports.useInputFieldWarningByType = exports.INPUT_TYPES_SUPPORTED_SELECTION = void 0;
4
+ /* eslint-disable no-console */
4
5
  /* eslint-disable max-len */
5
6
  /* eslint-disable no-unused-expressions */
6
7
  var react_use_1 = require("react-use");
@@ -47,9 +47,15 @@ function ProgressBar(props) {
47
47
  return props.label(props.percent);
48
48
  });
49
49
  if (props.type === 'line') {
50
- return components.ui.renderView('layout.LineProgressBarView', { percent: props.percent, status: props.status, size: props.size, label: getLabel() });
50
+ return components.ui.renderView('layout.LineProgressBarView', { percent: props.percent,
51
+ status: props.status,
52
+ size: props.size,
53
+ label: getLabel() });
51
54
  }
52
- return components.ui.renderView('layout.CircleProgressBarView', { percent: props.percent, status: props.status, size: props.size, label: getLabel() });
55
+ return components.ui.renderView('layout.CircleProgressBarView', { percent: props.percent,
56
+ status: props.status,
57
+ size: props.size,
58
+ label: getLabel() });
53
59
  }
54
60
  ProgressBar.defaultProps = {
55
61
  status: 'normal',
@@ -20,10 +20,20 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
20
20
  if (process.env.IS_SSR) {
21
21
  return null;
22
22
  }
23
- var style = { left: null, right: null, top: null };
23
+ var style = {
24
+ left: null,
25
+ right: null,
26
+ top: null
27
+ };
24
28
  var arrowPosition = null;
25
29
  var _a = parentRef.getBoundingClientRect(), top = _a.top, right = _a.right, left = _a.left, width = _a.width, height = _a.height;
26
- var parentDimensions = { top: top, right: right, left: left, width: width, height: height };
30
+ var parentDimensions = {
31
+ top: top,
32
+ right: right,
33
+ left: left,
34
+ width: width,
35
+ height: height
36
+ };
27
37
  parentDimensions.top += window.scrollY;
28
38
  // eslint-disable-next-line default-case
29
39
  switch (position) {
@@ -202,6 +212,10 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
202
212
  style.top = parentDimensions.top + parentDimensions.height - componentSize.height;
203
213
  }
204
214
  }
205
- return { style: style, position: position, arrowPosition: arrowPosition };
215
+ return {
216
+ style: style,
217
+ position: position,
218
+ arrowPosition: arrowPosition
219
+ };
206
220
  }
207
221
  exports["default"] = calculateComponentAbsolutePosition;
package/utils/data.js CHANGED
@@ -144,6 +144,7 @@ var shouldUpdate = function (objA, objB, deepPaths) {
144
144
  ? (0, exports.shouldUpdate)(objA[key], objB[key], deepPath)
145
145
  : (0, exports.shouldUpdateSingle)(objA[key], objB[key]);
146
146
  if (hasChanges) {
147
+ // eslint-disable-next-line no-console
147
148
  console.log(0, 'shouldUpdate changed key:', key, objA[key], objB[key]);
148
149
  return { value: true };
149
150
  }