@astral/ui 4.52.0 → 4.53.0

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.
Files changed (81) hide show
  1. package/components/DashboardContext/DashboardContext.d.ts +2 -3
  2. package/components/DashboardContext/DashboardContext.js +1 -0
  3. package/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.d.ts +2 -2
  4. package/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.js +2 -1
  5. package/components/DashboardLayout/Container/Container.d.ts +6 -0
  6. package/components/DashboardLayout/Container/Container.js +24 -0
  7. package/components/DashboardLayout/Container/constants.d.ts +6 -0
  8. package/components/DashboardLayout/Container/constants.js +7 -0
  9. package/components/DashboardLayout/Container/index.d.ts +1 -0
  10. package/components/DashboardLayout/Container/index.js +1 -0
  11. package/components/DashboardLayout/Container/styles.d.ts +5 -0
  12. package/components/DashboardLayout/Container/styles.js +55 -0
  13. package/components/DashboardLayout/DashboardLayout.d.ts +1 -1
  14. package/components/DashboardLayout/DashboardLayout.js +2 -2
  15. package/components/DashboardLayout/DashboardWrapper/DashboardWrapper.js +3 -2
  16. package/components/DashboardLayout/DashboardWrapper/constants.d.ts +6 -0
  17. package/components/DashboardLayout/DashboardWrapper/constants.js +7 -0
  18. package/components/DashboardLayout/DashboardWrapper/styles.d.ts +0 -6
  19. package/components/DashboardLayout/DashboardWrapper/styles.js +0 -45
  20. package/components/DashboardLayout/Header/useLogic/useLogic.d.ts +1 -1
  21. package/components/DashboardLayout/types.d.ts +5 -0
  22. package/components/DashboardLayoutSkeleton/DashboardLayoutSkeleton.js +3 -2
  23. package/components/DatePicker/hooks/useDatePickerOptions/useDatePickerOptions.d.ts +2 -0
  24. package/components/DatePicker/hooks/useDatePickerOptions/useDatePickerOptions.js +2 -1
  25. package/components/DatePicker/hooks/useMaskedValue/useMaskedValue.d.ts +4 -0
  26. package/components/DatePicker/hooks/useMaskedValue/useMaskedValue.js +37 -8
  27. package/components/DatePicker/useLogic/useLogic.d.ts +1 -0
  28. package/components/DatePicker/useLogic/useLogic.js +19 -13
  29. package/components/DateRangePicker/useLogic/useLogic.d.ts +2 -0
  30. package/components/DateRangePicker/useLogic/useLogic.js +27 -3
  31. package/components/DateRangePicker/useLogic/utils/index.d.ts +0 -1
  32. package/components/DateRangePicker/useLogic/utils/index.js +0 -1
  33. package/components/utils/date/format/index.d.ts +1 -0
  34. package/components/utils/date/format/index.js +1 -0
  35. package/{node/components/DateRangePicker/useLogic/utils → components/utils/date/format}/isMaskedDateSyntacticallyComplete/isMaskedDateSyntacticallyComplete.d.ts +1 -1
  36. package/components/utils/date/format/parseDate/parseDate.d.ts +1 -0
  37. package/components/utils/date/format/parseDate/parseDate.js +42 -13
  38. package/node/components/DashboardContext/DashboardContext.d.ts +2 -3
  39. package/node/components/DashboardContext/DashboardContext.js +1 -0
  40. package/node/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.d.ts +2 -2
  41. package/node/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.js +2 -1
  42. package/node/components/DashboardLayout/Container/Container.d.ts +6 -0
  43. package/node/components/DashboardLayout/Container/Container.js +28 -0
  44. package/node/components/DashboardLayout/Container/constants.d.ts +6 -0
  45. package/node/components/DashboardLayout/Container/constants.js +10 -0
  46. package/node/components/DashboardLayout/Container/index.d.ts +1 -0
  47. package/node/components/DashboardLayout/Container/index.js +17 -0
  48. package/node/components/DashboardLayout/Container/styles.d.ts +5 -0
  49. package/node/components/DashboardLayout/Container/styles.js +58 -0
  50. package/node/components/DashboardLayout/DashboardLayout.d.ts +1 -1
  51. package/node/components/DashboardLayout/DashboardLayout.js +2 -2
  52. package/node/components/DashboardLayout/DashboardWrapper/DashboardWrapper.js +2 -1
  53. package/node/components/DashboardLayout/DashboardWrapper/constants.d.ts +6 -0
  54. package/node/components/DashboardLayout/DashboardWrapper/constants.js +10 -0
  55. package/node/components/DashboardLayout/DashboardWrapper/styles.d.ts +0 -6
  56. package/node/components/DashboardLayout/DashboardWrapper/styles.js +4 -49
  57. package/node/components/DashboardLayout/Header/useLogic/useLogic.d.ts +1 -1
  58. package/node/components/DashboardLayout/types.d.ts +5 -0
  59. package/node/components/DashboardLayoutSkeleton/DashboardLayoutSkeleton.js +2 -1
  60. package/node/components/DatePicker/hooks/useDatePickerOptions/useDatePickerOptions.d.ts +2 -0
  61. package/node/components/DatePicker/hooks/useDatePickerOptions/useDatePickerOptions.js +2 -1
  62. package/node/components/DatePicker/hooks/useMaskedValue/useMaskedValue.d.ts +4 -0
  63. package/node/components/DatePicker/hooks/useMaskedValue/useMaskedValue.js +35 -6
  64. package/node/components/DatePicker/useLogic/useLogic.d.ts +1 -0
  65. package/node/components/DatePicker/useLogic/useLogic.js +19 -13
  66. package/node/components/DateRangePicker/useLogic/useLogic.d.ts +2 -0
  67. package/node/components/DateRangePicker/useLogic/useLogic.js +28 -4
  68. package/node/components/DateRangePicker/useLogic/utils/index.d.ts +0 -1
  69. package/node/components/DateRangePicker/useLogic/utils/index.js +0 -1
  70. package/node/components/utils/date/format/index.d.ts +1 -0
  71. package/node/components/utils/date/format/index.js +1 -0
  72. package/{components/DateRangePicker/useLogic/utils → node/components/utils/date/format}/isMaskedDateSyntacticallyComplete/isMaskedDateSyntacticallyComplete.d.ts +1 -1
  73. package/node/components/utils/date/format/parseDate/parseDate.d.ts +1 -0
  74. package/node/components/utils/date/format/parseDate/parseDate.js +45 -13
  75. package/package.json +1 -1
  76. /package/components/{DateRangePicker/useLogic/utils → utils/date/format}/isMaskedDateSyntacticallyComplete/index.d.ts +0 -0
  77. /package/components/{DateRangePicker/useLogic/utils → utils/date/format}/isMaskedDateSyntacticallyComplete/index.js +0 -0
  78. /package/components/{DateRangePicker/useLogic/utils → utils/date/format}/isMaskedDateSyntacticallyComplete/isMaskedDateSyntacticallyComplete.js +0 -0
  79. /package/node/components/{DateRangePicker/useLogic/utils → utils/date/format}/isMaskedDateSyntacticallyComplete/index.d.ts +0 -0
  80. /package/node/components/{DateRangePicker/useLogic/utils → utils/date/format}/isMaskedDateSyntacticallyComplete/index.js +0 -0
  81. /package/node/components/{DateRangePicker/useLogic/utils → utils/date/format}/isMaskedDateSyntacticallyComplete/isMaskedDateSyntacticallyComplete.js +0 -0
@@ -7,7 +7,6 @@ const usePopover_1 = require("../../usePopover");
7
7
  const useViewportType_1 = require("../../useViewportType");
8
8
  const constants_1 = require("../constants");
9
9
  const useDatePickerOptions_1 = require("../hooks/useDatePickerOptions");
10
- const useMaskedValue_1 = require("../hooks/useMaskedValue");
11
10
  const MinMaxDateContext_1 = require("../MinMaxDateContext");
12
11
  const useLogic = ({ label, value, maxDate = MinMaxDateContext_1.DEFAULT_MAX_DATE, minDate = MinMaxDateContext_1.DEFAULT_MIN_DATE, mask = constants_1.DEFAULT_DATE_MASK, onOpen, onClose, onBlur, onChange, forwardedRef, }) => {
13
12
  const ref = (0, useForwardedRef_1.useForwardedRef)(forwardedRef);
@@ -15,21 +14,11 @@ const useLogic = ({ label, value, maxDate = MinMaxDateContext_1.DEFAULT_MAX_DATE
15
14
  const { isOpen, actions } = (0, usePopover_1.usePopover)();
16
15
  const { open, close } = actions;
17
16
  const { isMobile } = (0, useViewportType_1.useViewportType)();
18
- const { maskedValue } = (0, useMaskedValue_1.useMaskedValue)({
19
- currentValue: value,
20
- mask,
21
- onChangeValue: onChange,
22
- });
23
17
  const isTitleShow = isMobile && typeof label === 'string';
24
18
  const handleOpen = (event) => {
25
19
  onOpen?.();
26
20
  open(event);
27
21
  };
28
- const handleClose = () => {
29
- onBlur?.();
30
- onClose?.();
31
- close();
32
- };
33
22
  const handleDayPick = (date) => {
34
23
  if (isMobile) {
35
24
  setSelectedDate(date);
@@ -42,7 +31,7 @@ const useLogic = ({ label, value, maxDate = MinMaxDateContext_1.DEFAULT_MAX_DATE
42
31
  onChange?.(date);
43
32
  }
44
33
  };
45
- const { onAccept, inputProps: calculatedInputProps, pickerProps, } = (0, useDatePickerOptions_1.useDatePickerOptions)({
34
+ const { onAccept, inputProps: calculatedInputProps, pickerProps, onMaskedValueBlur, } = (0, useDatePickerOptions_1.useDatePickerOptions)({
46
35
  currentValue: value,
47
36
  maxDate,
48
37
  minDate,
@@ -50,6 +39,22 @@ const useLogic = ({ label, value, maxDate = MinMaxDateContext_1.DEFAULT_MAX_DATE
50
39
  onDatePick: handleDayPick,
51
40
  onChange: handleChange,
52
41
  });
42
+ /** Blur: неполный ввод -Invalid Date в onChange (при isMobile onChange не шлём), потом внешний onBlur. */
43
+ const flushMaskedValueAndCallOnBlur = () => {
44
+ onMaskedValueBlur();
45
+ onBlur?.();
46
+ };
47
+ function handleClose() {
48
+ flushMaskedValueAndCallOnBlur();
49
+ onClose?.();
50
+ close();
51
+ }
52
+ const handleInputBlur = () => {
53
+ if (isOpen) {
54
+ return;
55
+ }
56
+ flushMaskedValueAndCallOnBlur();
57
+ };
53
58
  const handleConfirm = () => {
54
59
  onChange?.(selectedDate);
55
60
  handleClose();
@@ -61,7 +66,8 @@ const useLogic = ({ label, value, maxDate = MinMaxDateContext_1.DEFAULT_MAX_DATE
61
66
  title: isTitleShow ? label : undefined,
62
67
  };
63
68
  const DatePickerInputProps = {
64
- value: isMobile ? maskedValue : calculatedInputProps.value,
69
+ value: calculatedInputProps.value,
70
+ onBlur: handleInputBlur,
65
71
  };
66
72
  const confirmButtonProps = {
67
73
  onClick: handleConfirm,
@@ -7,12 +7,14 @@ export declare const useLogic: ({ value, minDate, maxDate, mask, onChange, onOpe
7
7
  ref: import("react").RefObject<HTMLInputElement | null>;
8
8
  value: string;
9
9
  onAccept: (_: string, maskRef: IMask.InputMask<IMask.AnyMaskedOptions>) => void;
10
+ onBlur: () => void;
10
11
  onClick: (e: SyntheticEvent) => void;
11
12
  };
12
13
  endDatePickerInputProps: {
13
14
  ref: import("react").RefObject<HTMLInputElement | null>;
14
15
  value: string;
15
16
  onAccept: (_: string, maskRef: IMask.InputMask<IMask.AnyMaskedOptions>) => void;
17
+ onBlur: () => void;
16
18
  onClick: (e: SyntheticEvent) => void;
17
19
  };
18
20
  popoverHoveredContextProviderProps: {
@@ -5,6 +5,7 @@ const react_1 = require("react");
5
5
  const DatePicker_1 = require("../../DatePicker");
6
6
  const useForwardedRef_1 = require("../../useForwardedRef");
7
7
  const usePopover_1 = require("../../usePopover");
8
+ const date_1 = require("../../utils/date");
8
9
  const hooks_1 = require("./hooks");
9
10
  const utils_1 = require("./utils");
10
11
  const useLogic = ({ value, minDate = DatePicker_1.DEFAULT_MIN_DATE, maxDate = DatePicker_1.DEFAULT_MAX_DATE, mask = DatePicker_1.DEFAULT_DATE_MASK, onChange, onOpen, onClose, onBlur, }, forwardedRef) => {
@@ -45,7 +46,7 @@ const useLogic = ({ value, minDate = DatePicker_1.DEFAULT_MIN_DATE, maxDate = Da
45
46
  const handleChangeStartDate = (startDateValue, startMaskString) => {
46
47
  const isStartComplete = startDateValue != null &&
47
48
  startMaskString != null &&
48
- (0, utils_1.isMaskedDateSyntacticallyComplete)(startMaskString, mask);
49
+ (0, date_1.isMaskedDateSyntacticallyComplete)(startMaskString, mask);
49
50
  if (isStartComplete &&
50
51
  value?.end &&
51
52
  startDateValue &&
@@ -58,7 +59,7 @@ const useLogic = ({ value, minDate = DatePicker_1.DEFAULT_MIN_DATE, maxDate = Da
58
59
  const handleChangeEndDate = (endDateValue, endMaskString) => {
59
60
  const isEndComplete = endDateValue != null &&
60
61
  endMaskString != null &&
61
- (0, utils_1.isMaskedDateSyntacticallyComplete)(endMaskString, mask);
62
+ (0, date_1.isMaskedDateSyntacticallyComplete)(endMaskString, mask);
62
63
  if (isEndComplete &&
63
64
  value?.start &&
64
65
  endDateValue &&
@@ -68,12 +69,12 @@ const useLogic = ({ value, minDate = DatePicker_1.DEFAULT_MIN_DATE, maxDate = Da
68
69
  }
69
70
  onChange?.({ ...value, end: endDateValue });
70
71
  };
71
- const { maskedValue: startMaskedValue, onMaskedValueChange: onMaskedStartValueChange, onMaskedDateChange: onMaskedStartDateChange, } = (0, DatePicker_1.useMaskedValue)({
72
+ const { maskedValue: startMaskedValue, onMaskedValueChange: onMaskedStartValueChange, onMaskedValueBlur: onMaskedStartValueBlur, onMaskedDateChange: onMaskedStartDateChange, } = (0, DatePicker_1.useMaskedValue)({
72
73
  currentValue: value?.start,
73
74
  mask,
74
75
  onChangeValue: handleChangeStartDate,
75
76
  });
76
- const { maskedValue: endMaskedValue, onMaskedValueChange: onMaskedEndValueChange, onMaskedDateChange: onMaskedEndDateChange, } = (0, DatePicker_1.useMaskedValue)({
77
+ const { maskedValue: endMaskedValue, onMaskedValueChange: onMaskedEndValueChange, onMaskedValueBlur: onMaskedEndValueBlur, onMaskedDateChange: onMaskedEndDateChange, } = (0, DatePicker_1.useMaskedValue)({
77
78
  currentValue: value?.end,
78
79
  mask,
79
80
  onChangeValue: handleChangeEndDate,
@@ -82,11 +83,32 @@ const useLogic = ({ value, minDate = DatePicker_1.DEFAULT_MIN_DATE, maxDate = Da
82
83
  onOpen?.();
83
84
  open(event);
84
85
  };
86
+ const flushActiveMaskedValueOnClose = () => {
87
+ if (activeInput === 'startDate') {
88
+ onMaskedStartValueBlur();
89
+ }
90
+ if (activeInput === 'endDate') {
91
+ onMaskedEndValueBlur();
92
+ }
93
+ };
85
94
  const handleClose = () => {
95
+ flushActiveMaskedValueOnClose();
86
96
  onBlur?.();
87
97
  onClose?.();
88
98
  close();
89
99
  };
100
+ const handleStartInputBlur = () => {
101
+ if (isOpen) {
102
+ return;
103
+ }
104
+ onMaskedStartValueBlur();
105
+ };
106
+ const handleEndInputBlur = () => {
107
+ if (isOpen) {
108
+ return;
109
+ }
110
+ onMaskedEndValueBlur();
111
+ };
90
112
  const handleClickStartInput = (e) => {
91
113
  setActiveInput('startDate');
92
114
  startInputRef.current?.focus();
@@ -141,12 +163,14 @@ const useLogic = ({ value, minDate = DatePicker_1.DEFAULT_MIN_DATE, maxDate = Da
141
163
  ref: startInputRef,
142
164
  value: startMaskedValue,
143
165
  onAccept: handleAcceptStart,
166
+ onBlur: handleStartInputBlur,
144
167
  onClick: handleClickStartInput,
145
168
  },
146
169
  endDatePickerInputProps: {
147
170
  ref: endInputRef,
148
171
  value: endMaskedValue,
149
172
  onAccept: handleAcceptEnd,
173
+ onBlur: handleEndInputBlur,
150
174
  onClick: handleClickEndInput,
151
175
  },
152
176
  popoverHoveredContextProviderProps: {
@@ -1,2 +1 @@
1
1
  export * from './getBoundaryDate';
2
- export * from './isMaskedDateSyntacticallyComplete';
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./getBoundaryDate"), exports);
18
- __exportStar(require("./isMaskedDateSyntacticallyComplete"), exports);
@@ -1,3 +1,4 @@
1
1
  export * from './formatDate';
2
+ export * from './isMaskedDateSyntacticallyComplete';
2
3
  export * from './maskDate';
3
4
  export * from './parseDate';
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./formatDate"), exports);
18
+ __exportStar(require("./isMaskedDateSyntacticallyComplete"), exports);
18
19
  __exportStar(require("./maskDate"), exports);
19
20
  __exportStar(require("./parseDate"), exports);
@@ -1,4 +1,4 @@
1
- import { type DateMask } from '../../../../utils/date/format';
1
+ import { type DateMask } from '../maskDate';
2
2
  /**
3
3
  * Все ли части строки по маске заполнены цифрами полностью (без промежуточных состояний IMask).
4
4
  */
@@ -1,5 +1,6 @@
1
1
  import { type DateMask } from '../maskDate';
2
2
  /**
3
3
  * утилита конвертации строковой даты созданной по маске обратно в Date
4
+ * Строгий разбор UTC через `dayjs` + `customParseFormat`; при невалидной строке — Invalid Date
4
5
  */
5
6
  export declare const parseDate: (date: string, mask: DateMask, separator?: string) => Date;
@@ -1,25 +1,57 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.parseDate = void 0;
4
- const buildIsoDate_1 = require("../../buildIsoDate");
7
+ const dayjs_1 = __importDefault(require("dayjs"));
8
+ const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
9
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
5
10
  const maskDate_1 = require("../maskDate");
6
- const orderMap = {
7
- [maskDate_1.DateMaskElements.Year]: 'year',
8
- [maskDate_1.DateMaskElements.Month]: 'month',
9
- [maskDate_1.DateMaskElements.Day]: 'day',
10
- [maskDate_1.DateMaskElements.Hour]: 'hour',
11
- [maskDate_1.DateMaskElements.Minute]: 'minute',
12
- [maskDate_1.DateMaskElements.Second]: 'second',
11
+ dayjs_1.default.extend(customParseFormat_1.default);
12
+ dayjs_1.default.extend(utc_1.default);
13
+ /**
14
+ * Токен маски UI → литерал формата `dayjs` (strict UTC).
15
+ * В маске час — `hh`, в дате используются сутки 0–23 как в `formatDate` (UTC), поэтому `HH`.
16
+ */
17
+ const maskElementToDayjs = {
18
+ [maskDate_1.DateMaskElements.Day]: 'DD',
19
+ [maskDate_1.DateMaskElements.Month]: 'MM',
20
+ [maskDate_1.DateMaskElements.Year]: 'YYYY',
21
+ [maskDate_1.DateMaskElements.Hour]: 'HH',
22
+ [maskDate_1.DateMaskElements.Minute]: 'mm',
23
+ [maskDate_1.DateMaskElements.Second]: 'ss',
24
+ };
25
+ const buildDayjsFormat = (mask, separator) => {
26
+ const parts = mask.split(separator);
27
+ const tokens = [];
28
+ for (const part of parts) {
29
+ const t = maskElementToDayjs[part];
30
+ if (t == null) {
31
+ return null;
32
+ }
33
+ tokens.push(t);
34
+ }
35
+ return tokens.join(separator);
13
36
  };
14
37
  /**
15
38
  * утилита конвертации строковой даты созданной по маске обратно в Date
39
+ * Строгий разбор UTC через `dayjs` + `customParseFormat`; при невалидной строке — Invalid Date
16
40
  */
17
41
  const parseDate = (date, mask, separator = '.') => {
18
42
  const dateArr = date.split(separator);
19
- const options = { year: 1900 };
20
- mask.split('.').forEach((element, index) => {
21
- options[orderMap[element]] = parseInt(dateArr[index]);
22
- });
23
- return (0, buildIsoDate_1.buildIsoDate)(options);
43
+ const maskSplit = mask.split(separator);
44
+ if (dateArr.length !== maskSplit.length) {
45
+ return new Date(Number.NaN);
46
+ }
47
+ const format = buildDayjsFormat(mask, separator);
48
+ if (format == null) {
49
+ return new Date(Number.NaN);
50
+ }
51
+ const parsed = dayjs_1.default.utc(date, format, true);
52
+ if (!parsed.isValid()) {
53
+ return new Date(Number.NaN);
54
+ }
55
+ return parsed.toDate();
24
56
  };
25
57
  exports.parseDate = parseDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.52.0",
3
+ "version": "4.53.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {