@gravity-ui/date-components 2.8.0 → 2.8.2
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/dist/cjs/components/Calendar/Calendar.js +5 -3
- package/dist/cjs/components/Calendar/index.js +21 -8
- package/dist/cjs/components/CalendarView/CalendarView.js +5 -3
- package/dist/cjs/components/CalendarView/hooks/useCalendarCellProps.js +5 -4
- package/dist/cjs/components/CalendarView/hooks/useCalendarGridProps.d.ts +0 -1
- package/dist/cjs/components/CalendarView/hooks/useCalendarGridProps.js +1 -2
- package/dist/cjs/components/CalendarView/hooks/useCalendarProps.js +5 -4
- package/dist/cjs/components/CalendarView/hooks/useCalendarState.js +5 -4
- package/dist/cjs/components/CalendarView/hooks/useRangeCalendarState.js +1 -2
- package/dist/cjs/components/CalendarView/i18n/index.js +5 -3
- package/dist/cjs/components/CalendarView/utils.js +4 -4
- package/dist/cjs/components/DateField/DateField.js +2 -3
- package/dist/cjs/components/DateField/hooks/useBaseDateFieldState.js +5 -4
- package/dist/cjs/components/DateField/hooks/useDateFieldProps.js +5 -4
- package/dist/cjs/components/DateField/hooks/useDateFieldState.js +6 -4
- package/dist/cjs/components/DateField/i18n/index.js +5 -3
- package/dist/cjs/components/DateField/index.js +18 -5
- package/dist/cjs/components/DateField/utils.js +20 -18
- package/dist/cjs/components/DatePicker/DatePicker.js +2 -3
- package/dist/cjs/components/DatePicker/MobileCalendar.js +3 -4
- package/dist/cjs/components/DatePicker/StubButton.js +1 -2
- package/dist/cjs/components/DatePicker/hooks/datePickerStateFactory.js +5 -4
- package/dist/cjs/components/DatePicker/hooks/useDatePickerProps.js +5 -3
- package/dist/cjs/components/DatePicker/i18n/index.js +5 -3
- package/dist/cjs/components/DatePicker/index.js +17 -4
- package/dist/cjs/components/DatePicker/utils/getDateTimeValue.js +1 -2
- package/dist/cjs/components/DatePicker/utils/index.js +16 -3
- package/dist/cjs/components/HiddenInput/HiddenInput.js +6 -5
- package/dist/cjs/components/RangeCalendar/RangeCalendar.js +5 -3
- package/dist/cjs/components/RangeCalendar/index.js +15 -2
- package/dist/cjs/components/RangeDateField/RangeDateField.js +2 -3
- package/dist/cjs/components/RangeDateField/hooks/useRangeDateFieldState.js +6 -4
- package/dist/cjs/components/RangeDateField/index.js +16 -3
- package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.js +1 -2
- package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.js +1 -2
- package/dist/cjs/components/RangeDateField/utils/index.js +17 -4
- package/dist/cjs/components/RangeDateField/utils/isValidRange.js +1 -2
- package/dist/cjs/components/RangeDatePicker/RangeDatePicker.js +2 -3
- package/dist/cjs/components/RangeDatePicker/index.js +16 -3
- package/dist/cjs/components/RelativeDateField/RelativeDateField.js +6 -5
- package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldProps.js +5 -4
- package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldState.js +5 -4
- package/dist/cjs/components/RelativeDateField/index.js +17 -4
- package/dist/cjs/components/RelativeDatePicker/RelativeDatePicker.js +6 -5
- package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js +3 -2
- package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js +5 -4
- package/dist/cjs/components/RelativeDatePicker/i18n/index.js +5 -3
- package/dist/cjs/components/RelativeDatePicker/index.js +17 -4
- package/dist/cjs/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js +9 -6
- package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.d.ts +0 -1
- package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js +2 -3
- package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/i18n/index.js +5 -3
- package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js +5 -4
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/Presets.js +7 -5
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/PresetsDoc.js +6 -5
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/i18n/en.json +17 -7
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/i18n/index.d.ts +1 -1
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/i18n/index.js +5 -3
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/i18n/ru.json +37 -7
- package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/utils.js +27 -11
- package/dist/cjs/components/RelativeRangeDatePicker/components/Zones/Zones.js +2 -3
- package/dist/cjs/components/RelativeRangeDatePicker/components/Zones/i18n/index.js +5 -3
- package/dist/cjs/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js +5 -4
- package/dist/cjs/components/RelativeRangeDatePicker/i18n/en.json +2 -1
- package/dist/cjs/components/RelativeRangeDatePicker/i18n/index.d.ts +1 -1
- package/dist/cjs/components/RelativeRangeDatePicker/i18n/index.js +5 -3
- package/dist/cjs/components/RelativeRangeDatePicker/i18n/ru.json +2 -1
- package/dist/cjs/components/RelativeRangeDatePicker/index.js +16 -3
- package/dist/cjs/components/RelativeRangeDatePicker/utils.js +5 -6
- package/dist/cjs/components/index.js +23 -10
- package/dist/cjs/components/types/events.d.ts +0 -1
- package/dist/cjs/components/types/style.d.ts +0 -1
- package/dist/cjs/components/utils/dates.js +3 -4
- package/dist/cjs/components/utils/getButtonSizeForInput.js +1 -2
- package/dist/cjs/components/utils/mergeProps.js +1 -2
- package/dist/cjs/components/utils/useDefaultTimeZone.js +5 -4
- package/dist/cjs/components/utils/validation/datePicker.js +1 -2
- package/dist/cjs/components/utils/validation/i18n/index.js +5 -3
- package/dist/cjs/index.js +15 -2
- package/dist/esm/components/CalendarView/hooks/useCalendarGridProps.d.ts +0 -1
- package/dist/esm/components/DateField/hooks/useDateFieldState.js +1 -0
- package/dist/esm/components/DatePicker/MobileCalendar.js +1 -1
- package/dist/esm/components/DatePicker/hooks/useDatePickerProps.js +4 -1
- package/dist/esm/components/RangeDateField/hooks/useRangeDateFieldState.js +1 -0
- package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js +2 -0
- package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js +3 -1
- package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.d.ts +0 -1
- package/dist/esm/components/RelativeRangeDatePicker/components/Presets/i18n/en.json +17 -7
- package/dist/esm/components/RelativeRangeDatePicker/components/Presets/i18n/index.d.ts +1 -1
- package/dist/esm/components/RelativeRangeDatePicker/components/Presets/i18n/ru.json +37 -7
- package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.js +23 -6
- package/dist/esm/components/RelativeRangeDatePicker/i18n/en.json +2 -1
- package/dist/esm/components/RelativeRangeDatePicker/i18n/index.d.ts +1 -1
- package/dist/esm/components/RelativeRangeDatePicker/i18n/ru.json +2 -1
- package/dist/esm/components/RelativeRangeDatePicker/utils.js +1 -1
- package/dist/esm/components/types/events.d.ts +0 -1
- package/dist/esm/components/types/style.d.ts +0 -1
- package/package.json +23 -17
|
@@ -25,13 +25,23 @@
|
|
|
25
25
|
"From start of month": "From start of month",
|
|
26
26
|
"From start of year": "From start of year",
|
|
27
27
|
"Previous month": "Previous month",
|
|
28
|
-
"Last
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
"Last second": "Last second",
|
|
29
|
+
"Last minute": "Last minute",
|
|
30
|
+
"Last {count} second": [
|
|
31
|
+
"Last {{count}} second",
|
|
32
|
+
"Last {{count}} seconds",
|
|
33
|
+
"Last {{count}} seconds"
|
|
34
|
+
],
|
|
35
|
+
"Last {count} minute": [
|
|
36
|
+
"Last {{count}} minute",
|
|
37
|
+
"Last {{count}} minutes",
|
|
38
|
+
"Last {{count}} minutes"
|
|
39
|
+
],
|
|
40
|
+
"Last {count} hour": ["Last {{count}} hour", "Last {{count}} hours", "Last {{count}} hours"],
|
|
41
|
+
"Last {count} day": ["Last {{count}} day", "Last {{count}} days", "Last {{count}} days"],
|
|
42
|
+
"Last {count} week": ["Last {{count}} week", "Last {{count}} weeks", "Last {{count}} weeks"],
|
|
43
|
+
"Last {count} month": ["Last {{count}} month", "Last {{count}} months", "Last {{count}} months"],
|
|
44
|
+
"Last {count} year": ["Last {{count}} year", "Last {{count}} years", "Last {{count}} years"],
|
|
35
45
|
"Main": "Main",
|
|
36
46
|
"Other": "Other",
|
|
37
47
|
"Range": "Range",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const i18n: (key: "
|
|
1
|
+
export declare const i18n: (key: "Last 5 minutes" | "Last 15 minutes" | "Last 30 minutes" | "Last hour" | "Last 3 hours" | "Last 6 hours" | "Last 12 hours" | "Last day" | "Last 3 days" | "Last week" | "Last month" | "Last 3 months" | "Last 6 months" | "Last year" | "Last 3 years" | "Today" | "Yesterday" | "Day before yesterday" | "This week" | "This month" | "This year" | "From start of day" | "From start of week" | "From start of month" | "From start of year" | "Previous month" | "Last second" | "Last minute" | "Main" | "Other" | "Range" | "From" | "To" | "Last {count} second" | "Last {count} minute" | "Last {count} hour" | "Last {count} day" | "Last {count} week" | "Last {count} month" | "Last {count} year", params?: import("@gravity-ui/i18n").Params | undefined) => string;
|
|
@@ -25,13 +25,43 @@
|
|
|
25
25
|
"From start of month": "С начала месяца",
|
|
26
26
|
"From start of year": "С начала года",
|
|
27
27
|
"Previous month": "Предыдущий месяц",
|
|
28
|
-
"Last
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
"Last second": "Последняя секунда",
|
|
29
|
+
"Last minute": "Последняя минута",
|
|
30
|
+
"Last {count} second": [
|
|
31
|
+
"Последняя {{count}} секунда",
|
|
32
|
+
"Последние {{count}} секунды",
|
|
33
|
+
"Последние {{count}} секунд"
|
|
34
|
+
],
|
|
35
|
+
"Last {count} minute": [
|
|
36
|
+
"Последняя {{count}} минута",
|
|
37
|
+
"Последние {{count}} минуты",
|
|
38
|
+
"Последние {{count}} минут"
|
|
39
|
+
],
|
|
40
|
+
"Last {count} hour": [
|
|
41
|
+
"Последний {{count}} час",
|
|
42
|
+
"Последние {{count}} часа",
|
|
43
|
+
"Последние {{count}} часов"
|
|
44
|
+
],
|
|
45
|
+
"Last {count} day": [
|
|
46
|
+
"Последний {{count}} день",
|
|
47
|
+
"Последние {{count}} дня",
|
|
48
|
+
"Последние {{count}} дней"
|
|
49
|
+
],
|
|
50
|
+
"Last {count} week": [
|
|
51
|
+
"Последняя {{count}} неделя",
|
|
52
|
+
"Последние {{count}} недели",
|
|
53
|
+
"Последние {{count}} недель"
|
|
54
|
+
],
|
|
55
|
+
"Last {count} month": [
|
|
56
|
+
"Последний {{count}} месяц",
|
|
57
|
+
"Последние {{count}} месяца",
|
|
58
|
+
"Последние {{count}} месяцев"
|
|
59
|
+
],
|
|
60
|
+
"Last {count} year": [
|
|
61
|
+
"Последний {{count}} год",
|
|
62
|
+
"Последние {{count}} года",
|
|
63
|
+
"Последние {{count}} лет"
|
|
64
|
+
],
|
|
35
65
|
"Main": "Основные",
|
|
36
66
|
"Other": "Другие",
|
|
37
67
|
"Range": "Период",
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { dateTimeParse } from '@gravity-ui/date-utils';
|
|
2
2
|
import { DEFAULT_DATE_PRESETS, DEFAULT_OTHERS_PRESETS, DEFAULT_TIME_PRESETS, allPresets, } from './defaultPresets';
|
|
3
3
|
import { i18n } from './i18n';
|
|
4
|
+
const lastRe = /^now-(\d+)([smhdwMy])$/;
|
|
5
|
+
const oneUnit = {
|
|
6
|
+
s: 'Last second',
|
|
7
|
+
m: 'Last minute',
|
|
8
|
+
h: 'Last hour',
|
|
9
|
+
d: 'Last day',
|
|
10
|
+
w: 'Last week',
|
|
11
|
+
M: 'Last month',
|
|
12
|
+
y: 'Last year',
|
|
13
|
+
};
|
|
14
|
+
const countUnit = {
|
|
15
|
+
s: 'Last {count} second',
|
|
16
|
+
m: 'Last {count} minute',
|
|
17
|
+
h: 'Last {count} hour',
|
|
18
|
+
d: 'Last {count} day',
|
|
19
|
+
w: 'Last {count} week',
|
|
20
|
+
M: 'Last {count} month',
|
|
21
|
+
y: 'Last {count} year',
|
|
22
|
+
};
|
|
4
23
|
export function getPresetTitle(start, end, presets = allPresets) {
|
|
5
24
|
const startText = start.replace(/\s+/g, '');
|
|
6
25
|
const endText = end.replace(/\s+/g, '');
|
|
@@ -10,21 +29,19 @@ export function getPresetTitle(start, end, presets = allPresets) {
|
|
|
10
29
|
}
|
|
11
30
|
}
|
|
12
31
|
if (end === 'now') {
|
|
13
|
-
const match =
|
|
32
|
+
const match = lastRe.exec(startText);
|
|
14
33
|
if (match) {
|
|
15
34
|
const [, count, unit] = match;
|
|
16
35
|
if (isDateUnit(unit)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
unit: i18n(unit, { count: Number(count) }),
|
|
20
|
-
});
|
|
36
|
+
const template = Number(count) === 1 ? oneUnit[unit] : countUnit[unit];
|
|
37
|
+
return i18n(template, { count });
|
|
21
38
|
}
|
|
22
39
|
}
|
|
23
40
|
}
|
|
24
41
|
return startText + ' — ' + endText;
|
|
25
42
|
}
|
|
26
43
|
function isDateUnit(value) {
|
|
27
|
-
return ['m', 'h', 'd', 'w', 'M', 'y'].includes(value);
|
|
44
|
+
return ['s', 'm', 'h', 'd', 'w', 'M', 'y'].includes(value);
|
|
28
45
|
}
|
|
29
46
|
export function filterPresets(presets, minValue) {
|
|
30
47
|
return presets.filter((preset) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const i18n: (key: "\"From\"" | "\"From\" is required." | "\"To\"" | "\"To\" is required." | "\"From\" can't be after \"To\"." | "to", params?: import("@gravity-ui/i18n").Params | undefined) => string;
|
|
1
|
+
export declare const i18n: (key: "\"From\"" | "\"From\" is required." | "\"To\"" | "\"To\" is required." | "\"From\" can't be after \"To\"." | "to" | "Range date picker", params?: import("@gravity-ui/i18n").Params | undefined) => string;
|
|
@@ -39,7 +39,7 @@ export function getDefaultTitle({ value, timeZone, alwaysShowAsAbsolute, format
|
|
|
39
39
|
if (!alwaysShowAsAbsolute &&
|
|
40
40
|
((_e = value.start) === null || _e === void 0 ? void 0 : _e.type) === 'relative' &&
|
|
41
41
|
((_f = value.end) === null || _f === void 0 ? void 0 : _f.type) === 'relative') {
|
|
42
|
-
return `${getPresetTitle(value.start.value, value.end.value, presets)}
|
|
42
|
+
return `${getPresetTitle(value.start.value, value.end.value, presets)}`;
|
|
43
43
|
}
|
|
44
44
|
const delimiter = ' — ';
|
|
45
45
|
return `${from}${delimiter}${to}${tz}`;
|
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/date-components",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|
|
8
8
|
"types": "./dist/esm/index.d.ts",
|
|
9
|
+
"type": "commonjs",
|
|
9
10
|
"exports": {
|
|
10
11
|
"./package.json": "./package.json",
|
|
11
12
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/esm/index.d.js",
|
|
15
|
+
"default": "./dist/esm/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/cjs/index.d.ts",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
20
|
+
}
|
|
15
21
|
}
|
|
16
22
|
},
|
|
17
23
|
"sideEffects": [
|
|
@@ -61,19 +67,19 @@
|
|
|
61
67
|
"@gravity-ui/stylelint-config": "^4.0.1",
|
|
62
68
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
63
69
|
"@gravity-ui/uikit": "^6.15.0",
|
|
64
|
-
"@storybook/addon-a11y": "^8.
|
|
65
|
-
"@storybook/addon-actions": "^8.
|
|
66
|
-
"@storybook/addon-essentials": "^8.
|
|
67
|
-
"@storybook/addon-storysource": "^8.
|
|
68
|
-
"@storybook/addon-viewport": "^8.
|
|
70
|
+
"@storybook/addon-a11y": "^8.2.9",
|
|
71
|
+
"@storybook/addon-actions": "^8.2.9",
|
|
72
|
+
"@storybook/addon-essentials": "^8.2.9",
|
|
73
|
+
"@storybook/addon-storysource": "^8.2.9",
|
|
74
|
+
"@storybook/addon-viewport": "^8.2.9",
|
|
69
75
|
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
|
|
70
|
-
"@storybook/blocks": "^8.
|
|
71
|
-
"@storybook/manager-api": "^8.
|
|
76
|
+
"@storybook/blocks": "^8.2.9",
|
|
77
|
+
"@storybook/manager-api": "^8.2.9",
|
|
72
78
|
"@storybook/preset-scss": "^1.0.3",
|
|
73
|
-
"@storybook/react": "^8.
|
|
74
|
-
"@storybook/react-webpack5": "^8.
|
|
75
|
-
"@storybook/theming": "^8.
|
|
76
|
-
"@storybook/types": "^8.
|
|
79
|
+
"@storybook/react": "^8.2.9",
|
|
80
|
+
"@storybook/react-webpack5": "^8.2.9",
|
|
81
|
+
"@storybook/theming": "^8.2.9",
|
|
82
|
+
"@storybook/types": "^8.2.9",
|
|
77
83
|
"@testing-library/dom": "^10.1.0",
|
|
78
84
|
"@testing-library/jest-dom": "^6.4.6",
|
|
79
85
|
"@testing-library/react": "^16.0.0",
|
|
@@ -100,12 +106,12 @@
|
|
|
100
106
|
"react-dom": "^18.3.1",
|
|
101
107
|
"rimraf": "^5.0.7",
|
|
102
108
|
"sass": "^1.77.1",
|
|
103
|
-
"storybook": "^8.
|
|
109
|
+
"storybook": "^8.2.9",
|
|
104
110
|
"stylelint": "^15.11.0",
|
|
105
111
|
"stylelint-use-logical": "^2.1.2",
|
|
106
112
|
"ts-jest": "^29.1.5",
|
|
107
113
|
"ts-node": "^10.9.2",
|
|
108
|
-
"typescript": "^5.4
|
|
114
|
+
"typescript": "^5.5.4"
|
|
109
115
|
},
|
|
110
116
|
"peerDependencies": {
|
|
111
117
|
"@gravity-ui/uikit": "^6.0.0",
|