@uzum-tech/ui 1.12.22 → 1.13.1

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 (125) hide show
  1. package/dist/index.js +2846 -574
  2. package/dist/index.prod.js +4 -4
  3. package/es/_styles/common/dark.js +1 -1
  4. package/es/_styles/common/light.d.ts +1 -0
  5. package/es/_styles/common/light.js +1 -1
  6. package/es/chat/src/ChatMessages.js +6 -1
  7. package/es/chat/src/styles/index.cssr.js +5 -1
  8. package/es/collapse/index.d.ts +5 -4
  9. package/es/collapse/index.js +4 -2
  10. package/es/collapse/src/Collapse.d.ts +62 -123
  11. package/es/collapse/src/Collapse.js +7 -27
  12. package/es/collapse/src/CollapseItem.d.ts +8 -18
  13. package/es/collapse/src/CollapseItem.js +36 -24
  14. package/es/collapse/src/interface.d.ts +1 -10
  15. package/es/collapse/src/props/collapse.props.d.ts +100 -0
  16. package/es/collapse/src/props/collapse.props.js +29 -0
  17. package/es/collapse/src/props/collapseItem.props.d.ts +7 -0
  18. package/es/collapse/src/props/collapseItem.props.js +6 -0
  19. package/es/collapse/src/styles/index.cssr.js +6 -2
  20. package/es/collapse/src/types/collapse.types.d.ts +55 -0
  21. package/es/collapse/src/types/collapse.types.js +1 -0
  22. package/es/collapse/styles/light.d.ts +3 -0
  23. package/es/collapse/styles/light.js +5 -2
  24. package/es/components.d.ts +1 -0
  25. package/es/components.js +1 -0
  26. package/es/config-provider/src/internal-interface.d.ts +3 -0
  27. package/es/date-picker-v2/index.d.ts +5 -0
  28. package/es/date-picker-v2/index.js +2 -0
  29. package/es/date-picker-v2/src/DatePickerV2.d.ts +4765 -0
  30. package/es/date-picker-v2/src/DatePickerV2.js +750 -0
  31. package/es/date-picker-v2/src/composables/useCalendarScroll.d.ts +1133 -0
  32. package/es/date-picker-v2/src/composables/useCalendarScroll.js +61 -0
  33. package/es/date-picker-v2/src/config.d.ts +14 -0
  34. package/es/date-picker-v2/src/config.js +34 -0
  35. package/es/date-picker-v2/src/interface.d.ts +42 -0
  36. package/es/date-picker-v2/src/interface.js +1 -0
  37. package/es/date-picker-v2/src/panel/CalendarPanel.d.ts +1222 -0
  38. package/es/date-picker-v2/src/panel/CalendarPanel.js +186 -0
  39. package/es/date-picker-v2/src/panel/CalendarRangePanel.d.ts +1246 -0
  40. package/es/date-picker-v2/src/panel/CalendarRangePanel.js +205 -0
  41. package/es/date-picker-v2/src/styles/index.cssr.d.ts +2 -0
  42. package/es/date-picker-v2/src/styles/index.cssr.js +190 -0
  43. package/es/date-picker-v2/src/utils.d.ts +12 -0
  44. package/es/date-picker-v2/src/utils.js +92 -0
  45. package/es/date-picker-v2/styles/dark.d.ts +447 -0
  46. package/es/date-picker-v2/styles/dark.js +19 -0
  47. package/es/date-picker-v2/styles/index.d.ts +3 -0
  48. package/es/date-picker-v2/styles/index.js +2 -0
  49. package/es/date-picker-v2/styles/light.d.ts +477 -0
  50. package/es/date-picker-v2/styles/light.js +56 -0
  51. package/es/dialog/src/DialogProvider.d.ts +2 -0
  52. package/es/dropdown/src/Dropdown.d.ts +1 -1
  53. package/es/locales/common/enUS.js +1 -1
  54. package/es/popconfirm/src/Popconfirm.d.ts +1 -1
  55. package/es/popover/src/Popover.d.ts +1 -1
  56. package/es/qr-code/src/QrCode.d.ts +1 -1
  57. package/es/theme-editor/src/ThemeEditor.d.ts +1 -0
  58. package/es/themes/dark.js +2 -0
  59. package/es/themes/light.js +2 -0
  60. package/es/tooltip/src/Tooltip.d.ts +1 -1
  61. package/es/version.d.ts +1 -1
  62. package/es/version.js +1 -1
  63. package/lib/_styles/common/dark.js +1 -1
  64. package/lib/_styles/common/light.d.ts +1 -0
  65. package/lib/_styles/common/light.js +1 -1
  66. package/lib/chat/src/ChatMessages.js +6 -1
  67. package/lib/chat/src/styles/index.cssr.js +5 -1
  68. package/lib/collapse/index.d.ts +5 -4
  69. package/lib/collapse/index.js +5 -3
  70. package/lib/collapse/src/Collapse.d.ts +62 -123
  71. package/lib/collapse/src/Collapse.js +8 -28
  72. package/lib/collapse/src/CollapseItem.d.ts +8 -18
  73. package/lib/collapse/src/CollapseItem.js +35 -24
  74. package/lib/collapse/src/interface.d.ts +1 -10
  75. package/lib/collapse/src/props/collapse.props.d.ts +100 -0
  76. package/lib/collapse/src/props/collapse.props.js +32 -0
  77. package/lib/collapse/src/props/collapseItem.props.d.ts +7 -0
  78. package/lib/collapse/src/props/collapseItem.props.js +9 -0
  79. package/lib/collapse/src/styles/index.cssr.js +6 -2
  80. package/lib/collapse/src/types/collapse.types.d.ts +55 -0
  81. package/lib/collapse/src/types/collapse.types.js +2 -0
  82. package/lib/collapse/styles/light.d.ts +3 -0
  83. package/lib/collapse/styles/light.js +5 -2
  84. package/lib/components.d.ts +1 -0
  85. package/lib/components.js +1 -0
  86. package/lib/config-provider/src/internal-interface.d.ts +3 -0
  87. package/lib/date-picker-v2/index.d.ts +5 -0
  88. package/lib/date-picker-v2/index.js +11 -0
  89. package/lib/date-picker-v2/src/DatePickerV2.d.ts +4765 -0
  90. package/lib/date-picker-v2/src/DatePickerV2.js +756 -0
  91. package/lib/date-picker-v2/src/composables/useCalendarScroll.d.ts +1133 -0
  92. package/lib/date-picker-v2/src/composables/useCalendarScroll.js +64 -0
  93. package/lib/date-picker-v2/src/config.d.ts +14 -0
  94. package/lib/date-picker-v2/src/config.js +37 -0
  95. package/lib/date-picker-v2/src/interface.d.ts +42 -0
  96. package/lib/date-picker-v2/src/interface.js +4 -0
  97. package/lib/date-picker-v2/src/panel/CalendarPanel.d.ts +1222 -0
  98. package/lib/date-picker-v2/src/panel/CalendarPanel.js +188 -0
  99. package/lib/date-picker-v2/src/panel/CalendarRangePanel.d.ts +1246 -0
  100. package/lib/date-picker-v2/src/panel/CalendarRangePanel.js +207 -0
  101. package/lib/date-picker-v2/src/styles/index.cssr.d.ts +2 -0
  102. package/lib/date-picker-v2/src/styles/index.cssr.js +195 -0
  103. package/lib/date-picker-v2/src/utils.d.ts +12 -0
  104. package/lib/date-picker-v2/src/utils.js +101 -0
  105. package/lib/date-picker-v2/styles/dark.d.ts +447 -0
  106. package/lib/date-picker-v2/styles/dark.js +21 -0
  107. package/lib/date-picker-v2/styles/index.d.ts +3 -0
  108. package/lib/date-picker-v2/styles/index.js +10 -0
  109. package/lib/date-picker-v2/styles/light.d.ts +477 -0
  110. package/lib/date-picker-v2/styles/light.js +60 -0
  111. package/lib/dialog/src/DialogProvider.d.ts +2 -0
  112. package/lib/dropdown/src/Dropdown.d.ts +1 -1
  113. package/lib/locales/common/enUS.js +1 -1
  114. package/lib/popconfirm/src/Popconfirm.d.ts +1 -1
  115. package/lib/popover/src/Popover.d.ts +1 -1
  116. package/lib/qr-code/src/QrCode.d.ts +1 -1
  117. package/lib/theme-editor/src/ThemeEditor.d.ts +1 -0
  118. package/lib/themes/dark.js +2 -0
  119. package/lib/themes/light.js +2 -0
  120. package/lib/tooltip/src/Tooltip.d.ts +1 -1
  121. package/lib/version.d.ts +1 -1
  122. package/lib/version.js +1 -1
  123. package/package.json +1 -1
  124. package/volar.d.ts +1 -0
  125. package/web-types.json +153 -1
@@ -0,0 +1,205 @@
1
+ import { h, defineComponent, computed, inject } from 'vue';
2
+ import { UScrollbar, UBaseIcon } from '../../../_internal';
3
+ import { ChevronDownIcon } from '../../../_internal/icons';
4
+ import { generateDatesForMonth, generateAllMonths, generateYears, getMonthLabel, getWeekdayNames } from '../utils';
5
+ import { datePickerV2InjectionKey } from '../interface';
6
+ import { YEAR_GROUP_HEIGHT, START_YEAR, END_YEAR } from '../config';
7
+ import { useCalendarScroll } from '../composables/useCalendarScroll';
8
+ export default defineComponent({
9
+ name: 'CalendarRangePanel',
10
+ props: {
11
+ value: {
12
+ type: [Array, null],
13
+ default: null
14
+ },
15
+ displayYear: {
16
+ type: Number,
17
+ required: true
18
+ },
19
+ displayMonth: {
20
+ type: Number,
21
+ required: true
22
+ },
23
+ showYearDropdown: {
24
+ type: Boolean,
25
+ required: true
26
+ },
27
+ isSelecting: {
28
+ type: Boolean,
29
+ required: true
30
+ },
31
+ isDateDisabled: Function,
32
+ onDateClick: {
33
+ type: Function,
34
+ required: true
35
+ },
36
+ onDateMouseEnter: {
37
+ type: Function,
38
+ required: true
39
+ },
40
+ onMonthSelect: {
41
+ type: Function,
42
+ required: true
43
+ },
44
+ onYearSelect: {
45
+ type: Function,
46
+ required: true
47
+ },
48
+ onToggleYearDropdown: {
49
+ type: Function,
50
+ required: true
51
+ },
52
+ onMonthScroll: {
53
+ type: Function,
54
+ required: true
55
+ },
56
+ style: [Object, String],
57
+ themeClass: String
58
+ },
59
+ setup(props, { expose }) {
60
+ const injection = inject(datePickerV2InjectionKey);
61
+ const mergedClsPrefix = (injection === null || injection === void 0 ? void 0 : injection.mergedClsPrefixRef.value) || 'u';
62
+ const dateLocaleRef = injection === null || injection === void 0 ? void 0 : injection.dateLocaleRef;
63
+ const localeRef = injection === null || injection === void 0 ? void 0 : injection.localeRef;
64
+ const dateFnsOptions = computed(() => {
65
+ var _a;
66
+ const loc = (_a = dateLocaleRef === null || dateLocaleRef === void 0 ? void 0 : dateLocaleRef.value) === null || _a === void 0 ? void 0 : _a.locale;
67
+ return loc ? { locale: loc } : undefined;
68
+ });
69
+ const now = Date.now();
70
+ // Используем composable для скролла
71
+ const { monthScrollbarRef, yearScrollbarRef, calendarScrollbarRef, scrollToMonthInMonthList, scrollToYear, scrollToMonthInCalendar: scrollToMonthInCalendarRaw } = useCalendarScroll();
72
+ // Все месяцы для навигации (с локализацией)
73
+ const monthFormat = computed(() => { var _a, _b; return (_b = (_a = localeRef === null || localeRef === void 0 ? void 0 : localeRef.value) === null || _a === void 0 ? void 0 : _a.monthFormat) !== null && _b !== void 0 ? _b : 'MMM'; });
74
+ const allMonthsRef = computed(() => generateAllMonths(START_YEAR, END_YEAR, dateFnsOptions.value, monthFormat.value));
75
+ // Названия дней недели (с локализацией)
76
+ const dayFormat = computed(() => { var _a, _b; return (_b = (_a = localeRef === null || localeRef === void 0 ? void 0 : localeRef.value) === null || _a === void 0 ? void 0 : _a.dayFormat) !== null && _b !== void 0 ? _b : 'eeeeee'; });
77
+ const weekdayNamesRef = computed(() => getWeekdayNames(dateFnsOptions.value, dayFormat.value));
78
+ // Все годы для dropdown
79
+ const yearsRef = computed(() => generateYears());
80
+ // Группировка месяцев по годам для отображения с заголовками
81
+ const groupedMonthsRef = computed(() => {
82
+ const months = allMonthsRef.value;
83
+ const groups = [];
84
+ let currentYear = -1;
85
+ let currentGroup = [];
86
+ for (const month of months) {
87
+ if (month.year !== currentYear) {
88
+ if (currentGroup.length > 0) {
89
+ groups.push({ year: currentYear, months: currentGroup });
90
+ }
91
+ currentYear = month.year;
92
+ currentGroup = [];
93
+ }
94
+ currentGroup.push(month);
95
+ }
96
+ if (currentGroup.length > 0) {
97
+ groups.push({ year: currentYear, months: currentGroup });
98
+ }
99
+ return groups;
100
+ });
101
+ // Все месяцы текущего года с их днями для скролла
102
+ const yearMonthsWithDatesRef = computed(() => {
103
+ const year = props.displayYear;
104
+ const months = [];
105
+ for (let month = 0; month < 12; month++) {
106
+ months.push({
107
+ year,
108
+ month,
109
+ label: getMonthLabel(month, dateFnsOptions.value),
110
+ dates: generateDatesForMonth(year, month, null, // single value не используется для range
111
+ props.value, now, props.isDateDisabled)
112
+ });
113
+ }
114
+ return months;
115
+ });
116
+ function scrollToMonthInCalendar(month) {
117
+ const monthRows = yearMonthsWithDatesRef.value.map((item) => Math.ceil(item.dates.length / 7));
118
+ scrollToMonthInCalendarRaw(month, monthRows);
119
+ }
120
+ // Экспортируем методы для родительского компонента
121
+ expose({
122
+ scrollToMonthInMonthList,
123
+ scrollToYear,
124
+ scrollToMonthInCalendar
125
+ });
126
+ return {
127
+ mergedClsPrefix,
128
+ allMonthsRef,
129
+ groupedMonthsRef,
130
+ yearsRef,
131
+ yearMonthsWithDatesRef,
132
+ weekdayNamesRef,
133
+ monthScrollbarRef,
134
+ yearScrollbarRef,
135
+ calendarScrollbarRef,
136
+ now
137
+ };
138
+ },
139
+ render() {
140
+ const { mergedClsPrefix, displayYear, displayMonth, showYearDropdown, groupedMonthsRef, yearsRef, yearMonthsWithDatesRef, weekdayNamesRef } = this;
141
+ return (h("div", { class: [`${mergedClsPrefix}-date-picker-v2-panel`, this.themeClass], style: this.style },
142
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__left` },
143
+ h("div", { class: [
144
+ `${mergedClsPrefix}-date-picker-v2-panel__year-trigger`,
145
+ showYearDropdown &&
146
+ `${mergedClsPrefix}-date-picker-v2-panel__year-trigger--active`
147
+ ], onClick: this.onToggleYearDropdown },
148
+ h("span", null, displayYear),
149
+ h(UBaseIcon, { clsPrefix: mergedClsPrefix }, { default: () => h(ChevronDownIcon, null) })),
150
+ showYearDropdown ? (h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__year-dropdown` },
151
+ h(UScrollbar, { ref: "yearScrollbarRef", style: { maxHeight: '320px' } },
152
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__year-list` }, yearsRef.map((item) => (h("div", { key: item.year, class: [
153
+ `${mergedClsPrefix}-date-picker-v2-panel__year-item`,
154
+ item.year === displayYear &&
155
+ `${mergedClsPrefix}-date-picker-v2-panel__year-item--selected`
156
+ ], onClick: () => {
157
+ this.onYearSelect(item.year);
158
+ } }, item.year))))))) : (h(UScrollbar, { ref: "monthScrollbarRef", style: { flex: 1 }, onScroll: (e) => {
159
+ const target = e.target;
160
+ const scrollTop = target.scrollTop;
161
+ // Определяем год по позиции скролла
162
+ const yearIndex = Math.floor(scrollTop / YEAR_GROUP_HEIGHT);
163
+ const year = START_YEAR + yearIndex;
164
+ this.onMonthScroll(year);
165
+ } },
166
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__month-list` }, groupedMonthsRef.map((group) => (h("div", { key: group.year, class: `${mergedClsPrefix}-date-picker-v2-panel__year-group` },
167
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__year-header` }, group.year),
168
+ group.months.map((item) => (h("div", { key: String(item.year) + '-' + String(item.month), class: [
169
+ `${mergedClsPrefix}-date-picker-v2-panel__month-item`,
170
+ item.year === displayYear &&
171
+ item.month === displayMonth &&
172
+ `${mergedClsPrefix}-date-picker-v2-panel__month-item--selected`
173
+ ], onClick: () => {
174
+ this.onMonthSelect(item.year, item.month);
175
+ } }, item.label)))))))))),
176
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__right` },
177
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__weekdays` }, weekdayNamesRef.map((day, i) => (h("div", { key: day, class: [
178
+ `${mergedClsPrefix}-date-picker-v2-panel__weekday`,
179
+ i >= 5 &&
180
+ `${mergedClsPrefix}-date-picker-v2-panel__weekday--weekend`
181
+ ] }, day)))),
182
+ h(UScrollbar, { ref: "calendarScrollbarRef", style: { flex: 1 } },
183
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__calendar-scroll` }, yearMonthsWithDatesRef.map((monthData) => (h("div", { key: `${monthData.year}-${monthData.month}`, class: `${mergedClsPrefix}-date-picker-v2-panel__month-section` },
184
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__month-title` }, monthData.label),
185
+ h("div", { class: `${mergedClsPrefix}-date-picker-v2-panel__dates` }, monthData.dates.map((dateItem) => dateItem.isCurrentMonth ? (h("div", { key: dateItem.ts, class: [
186
+ `${mergedClsPrefix}-date-picker-v2-panel__date`,
187
+ dateItem.isCurrentDate &&
188
+ `${mergedClsPrefix}-date-picker-v2-panel__date--current`,
189
+ dateItem.selected &&
190
+ `${mergedClsPrefix}-date-picker-v2-panel__date--selected`,
191
+ dateItem.inRange &&
192
+ `${mergedClsPrefix}-date-picker-v2-panel__date--in-range`,
193
+ dateItem.isRangeStart &&
194
+ `${mergedClsPrefix}-date-picker-v2-panel__date--range-start`,
195
+ dateItem.isRangeEnd &&
196
+ `${mergedClsPrefix}-date-picker-v2-panel__date--range-end`,
197
+ dateItem.disabled &&
198
+ `${mergedClsPrefix}-date-picker-v2-panel__date--disabled`
199
+ ], onClick: () => {
200
+ this.onDateClick(dateItem.ts);
201
+ }, onMouseenter: () => {
202
+ this.onDateMouseEnter(dateItem.ts);
203
+ } }, dateItem.date)) : (h("div", { key: dateItem.ts, class: `${mergedClsPrefix}-date-picker-v2-panel__date ${mergedClsPrefix}-date-picker-v2-panel__date--empty` }))))))))))));
204
+ }
205
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("css-render").CNode;
2
+ export default _default;
@@ -0,0 +1,190 @@
1
+ import { c, cB, cE, cM } from '../../../_utils/cssr';
2
+ import { fadeInScaleUpTransition } from '../../../_styles/transitions/fade-in-scale-up.cssr';
3
+ export default c([cB('date-picker-v2', `
4
+ position: relative;
5
+ z-index: auto;
6
+ `, [cB('date-picker-v2-icon', `
7
+ color: var(--u-icon-color);
8
+ transition: color .3s var(--u-bezier);
9
+ `), cE('separator', `
10
+ color: var(--u-panel-text-color);
11
+ font-size: 14px;
12
+ user-select: none;
13
+ `), cM('disabled', [cB('date-picker-v2-icon', `
14
+ color: var(--u-icon-color-disabled);
15
+ `)])]), cB('date-picker-v2-panel', `
16
+ display: flex;
17
+ width: max-content;
18
+ height: 410px;
19
+ background-color: var(--u-panel-color);
20
+ border-radius: var(--u-panel-border-radius);
21
+ box-shadow: var(--u-panel-box-shadow);
22
+ overflow: hidden;
23
+ outline: none;
24
+ margin: 6px 0;
25
+ `, [fadeInScaleUpTransition(), cE('left', `
26
+ width: 138px;
27
+ border-right: 1px solid var(--u-divider-color);
28
+ display: flex;
29
+ flex-direction: column;
30
+ overflow: hidden;
31
+ `), cE('year-trigger', `
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: space-between;
35
+ padding: 11px 24px;
36
+ height: 42px;
37
+ box-sizing: border-box;
38
+ background-color: var(--u-year-trigger-color);
39
+ border-bottom: 1px solid var(--u-divider-color);
40
+ cursor: pointer;
41
+ font-size: 14px;
42
+ font-weight: 500;
43
+ color: var(--u-year-trigger-text-color);
44
+ transition: background-color .2s var(--u-bezier);
45
+ `, [c('&:hover', `
46
+ background-color: var(--u-year-trigger-color-hover);
47
+ `), cM('active', `
48
+ background-color: var(--u-year-trigger-color-hover);
49
+ `, [c('.u-icon', `
50
+ transform: rotate(180deg);
51
+ `)]), c('.u-icon', `
52
+ width: 20px;
53
+ height: 20px;
54
+ transition: transform .2s var(--u-bezier);
55
+ `)]), cE('year-dropdown', `
56
+ flex: 1;
57
+ overflow: hidden;
58
+ `), cE('year-list', `
59
+ padding: 8px 0;
60
+ `), cE('year-item', `
61
+ padding: 12px 24px;
62
+ font-size: 14px;
63
+ font-weight: 500;
64
+ color: var(--u-panel-text-color);
65
+ cursor: pointer;
66
+ transition: background-color .2s var(--u-bezier);
67
+ `, [c('&:hover', `
68
+ background-color: var(--u-month-item-color-hover);
69
+ `), cM('selected', `
70
+ color: var(--u-month-item-text-color-active);
71
+ background-color: var(--u-month-item-color-active);
72
+ `)]), cE('month-list', `
73
+ padding: 0;
74
+ `), cE('year-group', `
75
+ position: relative;
76
+ `), cE('year-header', `
77
+ z-index: 1;
78
+ padding: 11px 24px;
79
+ height: 42px;
80
+ box-sizing: border-box;
81
+ background-color: var(--u-year-trigger-color);
82
+ font-size: 14px;
83
+ font-weight: 500;
84
+ color: var(--u-year-trigger-text-color);
85
+ `), cE('month-item', `
86
+ padding: 14px 24px;
87
+ height: var(--u-month-item-height);
88
+ box-sizing: border-box;
89
+ font-size: 16px;
90
+ font-weight: 500;
91
+ color: var(--u-panel-text-color);
92
+ cursor: pointer;
93
+ transition: background-color .2s var(--u-bezier), color .2s var(--u-bezier);
94
+ `, [c('&:hover', `
95
+ background-color: var(--u-month-item-color-hover);
96
+ `), cM('selected', `
97
+ color: var(--u-month-item-text-color-active);
98
+ background-color: var(--u-month-item-color-active);
99
+ `)]), cE('right', `
100
+ flex: 1;
101
+ display: flex;
102
+ flex-direction: column;
103
+ overflow: hidden;
104
+ `), cE('weekdays', `
105
+ display: grid;
106
+ grid-template-columns: repeat(7, 1fr);
107
+ padding: 0 12px;
108
+ height: 42px;
109
+ align-items: center;
110
+ border-bottom: 1px solid var(--u-divider-color);
111
+ background-color: var(--u-panel-color);
112
+ position: sticky;
113
+ top: 0;
114
+ z-index: 1;
115
+ `), cE('weekday', `
116
+ text-align: center;
117
+ font-size: 14px;
118
+ font-weight: 500;
119
+ color: var(--u-weekday-text-color);
120
+ `, [cM('weekend', `
121
+ color: var(--u-weekend-text-color);
122
+ `)]), cE('calendar-scroll', `
123
+ padding: 0;
124
+ `), cE('month-section', `
125
+ margin-bottom: 16px;
126
+ `), cE('month-title', `
127
+ padding: 12px 12px 8px;
128
+ font-size: 14px;
129
+ font-weight: 600;
130
+ color: var(--u-panel-text-color);
131
+ `), cE('dates', `
132
+ display: grid;
133
+ grid-template-columns: repeat(7, 1fr);
134
+ gap: 4px;
135
+ padding: 0 12px;
136
+ `), cE('date', `
137
+ display: flex;
138
+ align-items: center;
139
+ justify-content: center;
140
+ width: 42px;
141
+ height: 42px;
142
+ font-size: 14px;
143
+ font-weight: 500;
144
+ color: var(--u-item-text-color);
145
+ border-radius: var(--u-item-border-radius);
146
+ cursor: pointer;
147
+ position: relative;
148
+ transition:
149
+ background-color .2s var(--u-bezier),
150
+ color .2s var(--u-bezier);
151
+ `, [c('&:hover', `
152
+ background-color: var(--u-item-color-hover);
153
+ `), cM('other-month', `
154
+ color: var(--u-item-text-color-other-month);
155
+ `), cM('empty', `
156
+ pointer-events: none;
157
+ cursor: default;
158
+ `, [c('&:hover', `
159
+ background-color: transparent;
160
+ `)]), cM('current', `
161
+ color: var(--u-item-text-color);
162
+ `, [c('&::before', `
163
+ content: '';
164
+ position: absolute;
165
+ bottom: 8px;
166
+ left: 50%;
167
+ transform: translateX(-50%);
168
+ width: 4px;
169
+ height: 2px;
170
+ border-radius: 1px;
171
+ background-color: var(--u-current-date-indicator-color);
172
+ `)]), cM('selected', `
173
+ background-color: var(--u-item-color-active);
174
+ color: var(--u-item-text-color-active);
175
+ `, [c('&:hover', `
176
+ background-color: var(--u-item-color-active);
177
+ `)]), cM('in-range', `
178
+ background-color: var(--u-item-color-included);
179
+ `), cM('range-start', `
180
+ background-color: var(--u-item-color-active);
181
+ color: var(--u-item-text-color-active);
182
+ `), cM('range-end', `
183
+ background-color: var(--u-item-color-active);
184
+ color: var(--u-item-text-color-active);
185
+ `), cM('disabled', `
186
+ color: var(--u-item-text-color-disabled);
187
+ cursor: not-allowed;
188
+ `, [c('&:hover', `
189
+ background-color: transparent;
190
+ `)])])])]);
@@ -0,0 +1,12 @@
1
+ import type { Locale } from 'date-fns';
2
+ import type { DateItem, MonthItem, YearItem } from './interface';
3
+ export interface DateFnsOptions {
4
+ locale: Locale;
5
+ }
6
+ export declare function generateDatesForMonth(year: number, month: number, value: number | null, rangeValue: [number, number] | null, now: number, isDateDisabled?: (ts: number) => boolean): DateItem[];
7
+ export declare function getMonthLabel(month: number, options?: DateFnsOptions): string;
8
+ export declare function getWeekdayNames(options?: DateFnsOptions, dayFormat?: string): string[];
9
+ export declare function generateMonthsForYear(year: number, options?: DateFnsOptions, monthFormat?: string): MonthItem[];
10
+ export declare function generateAllMonths(startYear?: number, endYear?: number, options?: DateFnsOptions, monthFormat?: string): MonthItem[];
11
+ export declare function generateYears(startYear?: number, endYear?: number): YearItem[];
12
+ export declare function formatDate(ts: number, formatStr?: string, options?: DateFnsOptions): string;
@@ -0,0 +1,92 @@
1
+ import { startOfMonth, endOfMonth, startOfWeek, endOfWeek, eachDayOfInterval, getYear, getMonth, getDate, getTime, isSameDay, isSameMonth, isWithinInterval, format, addDays } from 'date-fns';
2
+ import { START_YEAR, END_YEAR, MONTH_NAMES } from './config';
3
+ export function generateDatesForMonth(year, month, value, rangeValue, now, isDateDisabled) {
4
+ const date = new Date(year, month, 1);
5
+ const monthStart = startOfMonth(date);
6
+ const monthEnd = endOfMonth(date);
7
+ const calendarStart = startOfWeek(monthStart, { weekStartsOn: 1 });
8
+ const calendarEnd = endOfWeek(monthEnd, { weekStartsOn: 1 });
9
+ const days = eachDayOfInterval({ start: calendarStart, end: calendarEnd });
10
+ return days.map((day) => {
11
+ const ts = getTime(day);
12
+ const dayYear = getYear(day);
13
+ const dayMonth = getMonth(day);
14
+ const dayDate = getDate(day);
15
+ let selected = false;
16
+ let inRange = false;
17
+ let isRangeStart = false;
18
+ let isRangeEnd = false;
19
+ if (value !== null) {
20
+ selected = isSameDay(day, value);
21
+ }
22
+ if (rangeValue !== null) {
23
+ const [start, end] = rangeValue;
24
+ isRangeStart = isSameDay(day, start);
25
+ isRangeEnd = isSameDay(day, end);
26
+ if (start && end) {
27
+ inRange = isWithinInterval(day, {
28
+ start: new Date(Math.min(start, end)),
29
+ end: new Date(Math.max(start, end))
30
+ });
31
+ }
32
+ selected = isRangeStart || isRangeEnd;
33
+ }
34
+ return {
35
+ year: dayYear,
36
+ month: dayMonth,
37
+ date: dayDate,
38
+ ts,
39
+ isCurrentDate: isSameDay(day, now),
40
+ isCurrentMonth: isSameMonth(day, date),
41
+ selected,
42
+ inRange,
43
+ isRangeStart,
44
+ isRangeEnd,
45
+ disabled: isDateDisabled ? isDateDisabled(ts) : false
46
+ };
47
+ });
48
+ }
49
+ export function getMonthLabel(month, options) {
50
+ if (options === null || options === void 0 ? void 0 : options.locale) {
51
+ return format(new Date(2024, month, 1), 'MMM', options);
52
+ }
53
+ return MONTH_NAMES[month];
54
+ }
55
+ export function getWeekdayNames(options, dayFormat = 'eeeeee') {
56
+ if (options === null || options === void 0 ? void 0 : options.locale) {
57
+ const base = new Date(2024, 0, 1);
58
+ return Array.from({ length: 7 }, (_, i) => format(addDays(base, i), dayFormat, options));
59
+ }
60
+ return ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
61
+ }
62
+ export function generateMonthsForYear(year, options, monthFormat = 'MMM') {
63
+ const getLabel = (index) => (options === null || options === void 0 ? void 0 : options.locale)
64
+ ? format(new Date(year, index, 1), monthFormat, options)
65
+ : MONTH_NAMES[index];
66
+ return Array.from({ length: 12 }, (_, index) => ({
67
+ year,
68
+ month: index,
69
+ label: getLabel(index),
70
+ ts: getTime(new Date(year, index, 1))
71
+ }));
72
+ }
73
+ export function generateAllMonths(startYear = START_YEAR, endYear = END_YEAR, options, monthFormat = 'MMM') {
74
+ const months = [];
75
+ for (let year = startYear; year <= endYear; year++) {
76
+ months.push(...generateMonthsForYear(year, options, monthFormat));
77
+ }
78
+ return months;
79
+ }
80
+ export function generateYears(startYear = START_YEAR, endYear = END_YEAR) {
81
+ const years = [];
82
+ for (let year = startYear; year <= endYear; year++) {
83
+ years.push({
84
+ year,
85
+ ts: getTime(new Date(year, 0, 1))
86
+ });
87
+ }
88
+ return years;
89
+ }
90
+ export function formatDate(ts, formatStr = 'dd.MM.yyyy', options) {
91
+ return format(ts, formatStr, options !== null && options !== void 0 ? options : {});
92
+ }