@rock555/frontend-core 2.0.2 → 2.0.3

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 (58) hide show
  1. package/README.md +95 -95
  2. package/package.json +98 -98
  3. package/src/components/GlobalPendingBar.vue +85 -85
  4. package/src/components/SearchPicker.vue +84 -84
  5. package/src/components/filters/DateRangeField.vue +692 -692
  6. package/src/components/filters/ExportCsvButton.vue +60 -60
  7. package/src/components/filters/FiltersBar.vue +150 -150
  8. package/src/components/filters/MonthField.vue +309 -309
  9. package/src/components/filters/SortControl.vue +162 -162
  10. package/src/components/filters/SortControlPanel.vue +242 -242
  11. package/src/components/filters/sortControl.types.ts +25 -25
  12. package/src/components/modals/ConfirmModal.vue +58 -58
  13. package/src/components/modals/ImageViewerModal.vue +200 -200
  14. package/src/components/tables/MultiSortHeader.vue +126 -126
  15. package/src/components/tables/TableBodyRow.vue +62 -62
  16. package/src/components/tables/TableFooterRow.vue +54 -54
  17. package/src/components/tables/TableHeaderRow.vue +75 -75
  18. package/src/components/tables/TableLoadedCount.vue +61 -61
  19. package/src/components/tables/TableLoadedFooter.vue +44 -44
  20. package/src/components/tables/TableSkeletonRows.vue +40 -40
  21. package/src/components/tables/TableVirtualPad.vue +16 -16
  22. package/src/components/tables/cells/BoolBadgeCell.vue +32 -32
  23. package/src/components/tables/multiSortHeader.types.ts +16 -16
  24. package/src/components/ui/UiActionTiles.vue +92 -92
  25. package/src/components/ui/UiBackLink.vue +39 -39
  26. package/src/components/ui/UiBadge.vue +60 -60
  27. package/src/components/ui/UiButton.vue +126 -126
  28. package/src/components/ui/UiCard.vue +88 -88
  29. package/src/components/ui/UiCount.vue +35 -35
  30. package/src/components/ui/UiKpiGrid.vue +142 -142
  31. package/src/components/ui/UiPopover.vue +62 -62
  32. package/src/components/ui/UiSearchInput.vue +102 -102
  33. package/src/components/ui/UiSegmented.vue +145 -145
  34. package/src/components/ui/UiTableCard.vue +116 -116
  35. package/src/components/ui/uiActionTiles.types.ts +10 -10
  36. package/src/components/ui/uiBadge.types.ts +11 -11
  37. package/src/components/ui/uiKpi.types.ts +17 -17
  38. package/src/composables/useAppForm.ts +67 -67
  39. package/src/composables/useConfirm.ts +21 -21
  40. package/src/composables/useFilterState.ts +70 -70
  41. package/src/composables/useServerList.ts +348 -348
  42. package/src/composables/useServerTable.ts +117 -117
  43. package/src/composables/useSharedAsync.ts +51 -51
  44. package/src/composables/useVirtualTable.ts +77 -77
  45. package/src/config.ts +155 -155
  46. package/src/errors/actionCancelled.ts +9 -9
  47. package/src/errors/apiError.helper.ts +161 -161
  48. package/src/errors/useHandleError.ts +33 -33
  49. package/src/helpers/calendarRange.helper.ts +74 -74
  50. package/src/helpers/month.helper.ts +63 -63
  51. package/src/helpers/periodLabel.helper.ts +70 -70
  52. package/src/helpers/periodPresets.helper.ts +76 -76
  53. package/src/helpers/sort.helper.ts +57 -57
  54. package/src/helpers/tableFields.helper.ts +205 -205
  55. package/src/helpers/urlParams.helper.ts +99 -99
  56. package/src/helpers/urlSchema.helper.ts +296 -296
  57. package/src/plugins/modals.plugin.ts +253 -253
  58. package/src/plugins/table.plugin.ts +173 -173
@@ -1,692 +1,692 @@
1
- <script setup lang="ts" generic="TPeriod extends Period | null = Period">
2
- // Єдине поле вибору періоду для всіх фільтрів. Замість двох нативних
3
- // <input type="date"> + дебаунс — одне поле-тригер, що відкриває поповер із
4
- // календарем + пресетами. Ключове: вибір усередині — ЧЕРНЕТКА, назовні нічого
5
- // не летить, поки не натиснуто «Застосувати». Це прибирає стрибок «почав
6
- // міняти початок — а воно вже відправило запит».
7
- //
8
- // mode:
9
- // day — вільний діапазон (статистика/платежі): будь-які start/end, але
10
- // застосувати можна лише коли обрані ОБИДВА кінці.
11
- // week — вибір прилипає до цілих тижнів (Пн–Вс) для звітів: агрегатори дають
12
- // точні суми лише в межах тижня. Пресети-місяці — теж дозволені.
13
-
14
- import { SharedConfig } from '../../config'
15
- import { today, getLocalTimeZone, type DateValue } from '@internationalized/date'
16
- import { CalendarRange, Check, ChevronLeft, ChevronRight, X } from '@lucide/vue'
17
- import {
18
- PopoverContent,
19
- PopoverPortal,
20
- PopoverRoot,
21
- PopoverTrigger,
22
- RangeCalendarCell,
23
- RangeCalendarCellTrigger,
24
- RangeCalendarGrid,
25
- RangeCalendarGridBody,
26
- RangeCalendarGridHead,
27
- RangeCalendarGridRow,
28
- RangeCalendarHeadCell,
29
- RangeCalendarRoot,
30
- type DateRange,
31
- } from 'reka-ui'
32
- import { computed, ref, shallowRef, watch } from 'vue'
33
- import type { Period } from '../../helpers/period.helper'
34
- import { CalendarRangeHelper } from '../../helpers/calendarRange.helper'
35
- import {
36
- PeriodPresetsHelper,
37
- type PeriodPreset,
38
- type PeriodPresetGroups,
39
- } from '../../helpers/periodPresets.helper'
40
-
41
- const props = withDefaults(defineProps<{
42
- // null — період не обрано («усі дати»): списку без обовʼязкової дати нічого
43
- // підставляти за замовчуванням.
44
- period: TPeriod
45
- // Підпис тригера, коли період не обрано.
46
- emptyLabel?: string
47
- // Хрестик поруч із полем знімає період (emit null).
48
- isClearable?: boolean
49
- mode?: 'day' | 'week'
50
- // Свій набір пресетів (напр. звіти: тиждень/місяць/квартал/рік). Не задано —
51
- // дефолтний за mode.
52
- presets?: PeriodPresetGroups
53
- // Тригер тягнеться на всю доступну ширину (напр. у модалці в один рядок з кнопкою).
54
- block?: boolean
55
- }>(), {
56
- mode: 'day',
57
- })
58
-
59
- const labels = SharedConfig.get().labels
60
-
61
- const emit = defineEmits<{ 'update:period': [period: TPeriod] }>()
62
-
63
- const EMPTY_RANGE: DateRange = { start: undefined, end: undefined }
64
-
65
- function toRange(period: Period | null): DateRange {
66
- return period ? CalendarRangeHelper.toRange(period) : { ...EMPTY_RANGE }
67
- }
68
-
69
- const isOpen = ref(false)
70
- // Чернетка вибору. Комітиться лише «Застосувати» / кліком по пресету.
71
- const draft = shallowRef<DateRange>(toRange(props.period))
72
- // Місяць, який показує календар. Керується стрілками шапки + сіткою років/місяців.
73
- const placeholder = shallowRef<DateValue>(
74
- CalendarRangeHelper.toCalendarDate(props.period?.from) ?? today(getLocalTimeZone()),
75
- )
76
- // Навігація як у нативному пікері: заголовок-кнопка перемикає вигляд
77
- // days → years → (клік по року) → months → (клік по місяцю) → days. Без дропдаунів.
78
- type PickerView = 'days' | 'months' | 'years'
79
- const pickerView = ref<PickerView>('days')
80
-
81
- // Відкриття — завжди зі свіжого зовнішнього значення (скидає недокручену
82
- // чернетку від минулого разу) + вертаємо календар на місяць початку періоду.
83
- watch(isOpen, (open) => {
84
- if (open) {
85
- draft.value = toRange(props.period)
86
- placeholder.value = CalendarRangeHelper.toCalendarDate(props.period?.from) ?? today(getLocalTimeZone())
87
- pickerView.value = 'days'
88
- }
89
- })
90
-
91
- // Пресети: свій набір або дефолтний за mode.
92
- const presetGroups = computed<PeriodPresetGroups>(() =>
93
- props.presets ?? (props.mode === 'week' ? PeriodPresetsHelper.week() : PeriodPresetsHelper.day()),
94
- )
95
-
96
- // --- Сітка вибору місяця/року ------------------------------------------------
97
- const YEARS_PER_PAGE = 12
98
- const MONTH_LONG_FMT = new Intl.DateTimeFormat('uk-UA', { month: 'long' })
99
- const MONTH_SHORT_FMT = new Intl.DateTimeFormat('uk-UA', { month: 'short' })
100
- const NOW_YEAR = new Date().getFullYear()
101
- const NOW_MONTH = new Date().getMonth() + 1
102
-
103
- function capitalize(s: string): string {
104
- return s.charAt(0).toUpperCase() + s.slice(1)
105
- }
106
-
107
- const monthItems = Array.from({ length: 12 }, (_, i) => ({
108
- value: i + 1,
109
- label: capitalize(MONTH_SHORT_FMT.format(new Date(2020, i, 1))),
110
- }))
111
-
112
- // Сторінка з 12 років навколо плейсхолдера (рівний тайлінг від 2000, без стелі/підлоги).
113
- const yearsPageStart = computed(() => {
114
- const y = placeholder.value.year
115
- return y - (((y - 2000) % YEARS_PER_PAGE) + YEARS_PER_PAGE) % YEARS_PER_PAGE
116
- })
117
- const yearItems = computed(() =>
118
- Array.from({ length: YEARS_PER_PAGE }, (_, i) => yearsPageStart.value + i),
119
- )
120
-
121
- // Підпис місяця для конкретної сітки днів ("Травень 2026").
122
- function monthLabel(d: DateValue): string {
123
- return `${capitalize(MONTH_LONG_FMT.format(new Date(d.year, d.month - 1, 1)))} ${d.year}`
124
- }
125
-
126
- const headingLabel = computed(() => {
127
- const p = placeholder.value
128
- if (pickerView.value === 'years') return `${yearsPageStart.value} – ${yearsPageStart.value + YEARS_PER_PAGE - 1}`
129
- if (pickerView.value === 'months') return String(p.year)
130
- // Days: сам місяць підписаний під кожною сіткою — тут показуємо лише рік(и),
131
- // це заодно вхід у вибір року. Роки різні (грудень-січень) — діапазон.
132
- const b = p.add({ months: 1 })
133
- return p.year === b.year ? String(p.year) : `${p.year} – ${b.year}`
134
- })
135
-
136
- function toggleView(): void {
137
- pickerView.value = pickerView.value === 'days' ? 'years' : 'days'
138
- }
139
-
140
- // Стрілки: гортають місяць / рік / сторінку років — залежно від вигляду.
141
- function nav(dir: 1 | -1): void {
142
- const p = placeholder.value
143
- const step = pickerView.value === 'years'
144
- ? { years: YEARS_PER_PAGE }
145
- : pickerView.value === 'months'
146
- ? { years: 1 }
147
- : { months: 1 }
148
- placeholder.value = dir === 1 ? p.add(step) : p.subtract(step)
149
- }
150
-
151
- function pickYear(year: number): void {
152
- placeholder.value = placeholder.value.set({ year })
153
- pickerView.value = 'months'
154
- }
155
-
156
- function pickMonth(month: number): void {
157
- placeholder.value = placeholder.value.set({ month })
158
- pickerView.value = 'days'
159
- }
160
-
161
- const triggerLabel = computed(() => props.period ? CalendarRangeHelper.label(props.period) : props.emptyLabel ?? labels.allDates)
162
-
163
- const draftPeriod = computed(() => CalendarRangeHelper.toPeriod(draft.value))
164
- const isApplyDisabled = computed(() => draftPeriod.value === null)
165
-
166
- // week-режим: докручуємо вибір до цілих тижнів на кожній зміні календаря.
167
- function onCalendarUpdate(range: DateRange): void {
168
- draft.value = props.mode === 'week' ? CalendarRangeHelper.snapToWeeks(range) : range
169
- }
170
-
171
- // Пресет — однозначний повний період: застосовуємо одразу й закриваємо.
172
- function applyPreset(preset: PeriodPreset): void {
173
- emit('update:period', preset.make() as TPeriod)
174
- isOpen.value = false
175
- }
176
-
177
- function apply(): void {
178
- if (draftPeriod.value) {
179
- emit('update:period', draftPeriod.value as TPeriod)
180
- isOpen.value = false
181
- }
182
- }
183
-
184
- function clear(): void {
185
- draft.value = { start: undefined, end: undefined }
186
- }
187
- </script>
188
-
189
- <template>
190
- <span class="drf" :class="{ 'drf--block': block }">
191
- <PopoverRoot v-model:open="isOpen">
192
- <PopoverTrigger
193
- class="drf-trigger"
194
- :class="{ 'drf-trigger--open': isOpen, 'drf-trigger--block': block, 'drf-trigger--empty': !period }"
195
- >
196
- <CalendarRange :size="14" />
197
- <span class="drf-trigger__label">{{ triggerLabel }}</span>
198
- </PopoverTrigger>
199
-
200
- <PopoverPortal>
201
- <PopoverContent align="start" :side-offset="6" class="drf-pop">
202
- <div class="drf-body">
203
- <!-- Пресети (згруповані). Порожній набір (напр. у модалці) — колонку
204
- ховаємо, лишається сам календар. -->
205
- <div v-if="presetGroups.length" class="drf-presets">
206
- <template v-for="(group, gi) in presetGroups" :key="gi">
207
- <div v-if="gi > 0" class="drf-presets__sep" />
208
- <button
209
- v-for="preset in group"
210
- :key="preset.label"
211
- type="button"
212
- class="drf-presets__item"
213
- @click="applyPreset(preset)"
214
- >
215
- {{ preset.label }}
216
- </button>
217
- </template>
218
- </div>
219
-
220
- <!-- Календар -->
221
- <RangeCalendarRoot
222
- v-slot="{ weekDays, grid }"
223
- :model-value="draft"
224
- :placeholder="placeholder"
225
- :week-starts-on="CalendarRangeHelper.WEEK_STARTS_ON"
226
- weekday-format="short"
227
- locale="uk"
228
- :number-of-months="2"
229
- fixed-weeks
230
- class="drf-cal"
231
- :class="`drf-cal--${mode}`"
232
- @update:model-value="onCalendarUpdate"
233
- @update:placeholder="placeholder = $event"
234
- >
235
- <!-- Шапка: стрілки + заголовок-кнопка. Клік по заголовку відкриває
236
- сітку років → місяців (як окремий екран у нативному пікері). -->
237
- <div class="drf-cal__header">
238
- <button type="button" class="drf-cal__nav" @click="nav(-1)">
239
- <ChevronLeft :size="16" />
240
- </button>
241
- <button type="button" class="drf-cal__title" @click="toggleView">
242
- {{ headingLabel }}
243
- </button>
244
- <button type="button" class="drf-cal__nav" @click="nav(1)">
245
- <ChevronRight :size="16" />
246
- </button>
247
- </div>
248
-
249
- <!-- Сітка років -->
250
- <div v-if="pickerView === 'years'" class="drf-cal__pick">
251
- <button
252
- v-for="y in yearItems"
253
- :key="y"
254
- type="button"
255
- class="drf-cal__pick-item"
256
- :class="{ 'is-active': y === placeholder.year, 'is-now': y === NOW_YEAR }"
257
- @click="pickYear(y)"
258
- >
259
- {{ y }}
260
- </button>
261
- </div>
262
-
263
- <!-- Сітка місяців -->
264
- <div v-else-if="pickerView === 'months'" class="drf-cal__pick">
265
- <button
266
- v-for="m in monthItems"
267
- :key="m.value"
268
- type="button"
269
- class="drf-cal__pick-item"
270
- :class="{
271
- 'is-active': m.value === placeholder.month,
272
- 'is-now': m.value === NOW_MONTH && placeholder.year === NOW_YEAR,
273
- }"
274
- @click="pickMonth(m.value)"
275
- >
276
- {{ m.label }}
277
- </button>
278
- </div>
279
-
280
- <div v-else class="drf-cal__months">
281
- <RangeCalendarGrid
282
- v-for="month in grid"
283
- :key="month.value.toString()"
284
- class="drf-cal__grid"
285
- >
286
- <!-- Підпис КОНКРЕТНОЇ сітки: видно, де травень, а де червень.
287
- <caption> — валідний перший нащадок <table> (reka рендерить
288
- сітку таблицею), лягає над нею. -->
289
- <caption class="drf-cal__grid-title">{{ monthLabel(month.value) }}</caption>
290
- <RangeCalendarGridHead>
291
- <RangeCalendarGridRow class="drf-cal__row drf-cal__row--head">
292
- <RangeCalendarHeadCell
293
- v-for="day in weekDays"
294
- :key="day"
295
- class="drf-cal__weekday"
296
- >
297
- {{ day }}
298
- </RangeCalendarHeadCell>
299
- </RangeCalendarGridRow>
300
- </RangeCalendarGridHead>
301
-
302
- <RangeCalendarGridBody>
303
- <RangeCalendarGridRow
304
- v-for="(weekDates, wi) in month.rows"
305
- :key="`w-${wi}`"
306
- class="drf-cal__row"
307
- >
308
- <RangeCalendarCell
309
- v-for="weekDate in weekDates"
310
- :key="weekDate.toString()"
311
- :date="weekDate"
312
- class="drf-cal__cell"
313
- >
314
- <RangeCalendarCellTrigger
315
- :day="weekDate"
316
- :month="month.value"
317
- class="drf-cal__day"
318
- />
319
- </RangeCalendarCell>
320
- </RangeCalendarGridRow>
321
- </RangeCalendarGridBody>
322
- </RangeCalendarGrid>
323
- </div>
324
- </RangeCalendarRoot>
325
- </div>
326
-
327
- <!-- Звіти точні лише в межах тижня — тому вибір тут кратний тижням. -->
328
- <p v-if="mode === 'week'" class="drf-note">
329
- {{ labels.periodWeeksOnly }}
330
- </p>
331
-
332
- <!-- Футер: нічого не летить назовні, поки не «Застосувати» -->
333
- <footer class="drf-foot">
334
- <button type="button" class="drf-foot__ghost" @click="clear">
335
- <X :size="14" /> {{ labels.clear }}
336
- </button>
337
- <div class="drf-foot__right">
338
- <button type="button" class="drf-foot__ghost" @click="isOpen = false">{{ labels.cancel }}</button>
339
- <button
340
- type="button"
341
- class="drf-foot__apply"
342
- :disabled="isApplyDisabled"
343
- :title="isApplyDisabled ? labels.periodPickBoth : undefined"
344
- @click="apply"
345
- >
346
- <Check :size="14" /> {{ labels.apply }}
347
- </button>
348
- </div>
349
- </footer>
350
- </PopoverContent>
351
- </PopoverPortal>
352
- </PopoverRoot>
353
- <!-- Поза тригером: кнопка в кнопці — невалідний HTML і клік відкрив би календар. -->
354
- <button
355
- v-if="isClearable && period"
356
- type="button"
357
- class="drf-clear"
358
- :title="labels.allDates"
359
- :aria-label="labels.periodRemove"
360
- @click="emit('update:period', null as TPeriod)"
361
- >
362
- <X :size="13" />
363
- </button>
364
- </span>
365
- </template>
366
-
367
- <style scoped lang="scss">
368
- .drf {
369
- display: inline-flex;
370
- align-items: center;
371
- gap: 2px;
372
-
373
- &--block { display: flex; flex: 1; }
374
- }
375
-
376
- .drf-clear {
377
- display: inline-flex;
378
- padding: 4px;
379
- border: none;
380
- border-radius: 4px;
381
- background: transparent;
382
- color: $color-muted;
383
- cursor: pointer;
384
-
385
- &:hover { color: $color-text; background: $color-border; }
386
- }
387
-
388
- .drf-trigger {
389
- display: inline-flex;
390
- align-items: center;
391
- gap: 8px;
392
- height: 32px;
393
- padding: 0 10px;
394
- background: $color-page-bg;
395
- border: 1px solid $color-border;
396
- border-radius: 8px;
397
- color: $color-text;
398
- font-size: 13px;
399
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
400
-
401
- &:hover { border-color: rgba(0, 0, 0, 0.2); }
402
-
403
- &--open {
404
- border-color: $color-accent;
405
- box-shadow: 0 0 0 2px $color-accent-dim;
406
- }
407
-
408
- // Тягнеться на всю ширину рядка; лейбл забирає вільне місце, дата — ліворуч.
409
- &--block {
410
- flex: 1;
411
- justify-content: flex-start;
412
-
413
- .drf-trigger__label { flex: 1; text-align: left; }
414
- }
415
-
416
- svg { color: $color-muted; flex-shrink: 0; }
417
- &__label { font-variant-numeric: tabular-nums; white-space: nowrap; }
418
- }
419
-
420
- .drf-body {
421
- display: flex;
422
- align-items: stretch;
423
-
424
- @media (max-width: 640px) {
425
- flex-direction: column;
426
- }
427
- }
428
-
429
- .drf-presets {
430
- display: flex;
431
- flex-direction: column;
432
- gap: 2px;
433
- width: 148px;
434
- padding: 8px;
435
- border-right: 1px solid $color-border;
436
-
437
- @media (max-width: 640px) {
438
- width: auto;
439
- border-right: none;
440
- border-bottom: 1px solid $color-border;
441
- flex-direction: row;
442
- flex-wrap: wrap;
443
- }
444
-
445
- &__sep {
446
- height: 1px;
447
- margin: 4px 6px;
448
- background: $color-border;
449
-
450
- @media (max-width: 640px) { display: none; }
451
- }
452
-
453
- &__item {
454
- width: 100%;
455
- padding: 6px 10px;
456
- border: 0;
457
- border-radius: 8px;
458
- background: none;
459
- text-align: left;
460
- font-size: 12px;
461
- color: $color-text;
462
- transition: background 0.12s ease;
463
-
464
- &:hover { background: $color-page-bg; }
465
-
466
- @media (max-width: 640px) { width: auto; }
467
- }
468
- }
469
-
470
- .drf-note {
471
- padding: 8px 12px;
472
- border-top: 1px solid $color-border;
473
- font-size: 12px;
474
- color: $color-muted;
475
- text-align: center;
476
- }
477
-
478
- .drf-cal {
479
- padding: 10px;
480
-
481
- &__header {
482
- display: flex;
483
- align-items: center;
484
- justify-content: space-between;
485
- margin-bottom: 8px;
486
- }
487
-
488
- // Заголовок-кнопка (місяць-рік / діапазон років). Клік → сітка вибору.
489
- &__title {
490
- flex: 1;
491
- height: 26px;
492
- padding: 0 10px;
493
- border: 0;
494
- border-radius: 8px;
495
- background: none;
496
- font-size: 12px;
497
- font-weight: 600;
498
- color: $color-text;
499
- text-transform: capitalize;
500
- transition: background 0.12s ease;
501
-
502
- &:hover { background: $color-page-bg; }
503
- }
504
-
505
- // Сітка вибору року/місяця (4×3).
506
- &__pick {
507
- display: grid;
508
- grid-template-columns: repeat(4, 1fr);
509
- gap: 8px;
510
- padding: 10px 8px 6px;
511
- }
512
-
513
- &__pick-item {
514
- height: 34px;
515
- min-width: 60px;
516
- padding: 0 12px;
517
- border: 0;
518
- border-radius: 8px;
519
- background: none;
520
- font-size: 12px;
521
- color: $color-text;
522
- font-variant-numeric: tabular-nums;
523
- transition: background 0.12s ease, color 0.12s ease;
524
-
525
- &:hover { background: $color-accent-dim; }
526
-
527
- // Поточний реальний рік/місяць — тонке кільце.
528
- &.is-now { box-shadow: inset 0 0 0 1px $color-border; }
529
-
530
- // Обраний (плейсхолдер) — акцент.
531
- &.is-active {
532
- background: $color-selected;
533
- color: $color-on-selected;
534
- font-weight: 600;
535
- }
536
- }
537
-
538
- &__nav {
539
- display: inline-flex;
540
- align-items: center;
541
- justify-content: center;
542
- width: 26px;
543
- height: 26px;
544
- border: 1px solid $color-border;
545
- border-radius: 8px;
546
- background: $color-surface;
547
- color: $color-text;
548
-
549
- &:hover { border-color: rgba(0, 0, 0, 0.2); }
550
- &[data-disabled] { opacity: 0.4; pointer-events: none; }
551
- }
552
-
553
- &__months {
554
- display: flex;
555
- gap: 14px;
556
-
557
- @media (max-width: 640px) {
558
- flex-direction: column;
559
- gap: 10px;
560
- }
561
- }
562
-
563
- // Підпис конкретної сітки місяця ("Травень 2026").
564
- &__grid-title {
565
- caption-side: top;
566
- margin-bottom: 6px;
567
- font-size: 12px;
568
- font-weight: 600;
569
- color: $color-text;
570
- text-transform: capitalize;
571
- text-align: center;
572
- }
573
-
574
- &__row {
575
- display: grid;
576
- grid-template-columns: repeat(7, 1fr);
577
- }
578
-
579
- &__weekday {
580
- padding-bottom: 5px;
581
- font-size: 10px;
582
- font-weight: 500;
583
- color: $color-muted;
584
- text-align: center;
585
- text-transform: capitalize;
586
- }
587
-
588
- &__cell { text-align: center; }
589
-
590
- // Клітинка-день. data-* атрибути ставить reka; на них весь вигляд станів.
591
- &__day {
592
- display: inline-flex;
593
- align-items: center;
594
- justify-content: center;
595
- width: 30px;
596
- height: 28px;
597
- border: 0;
598
- border-radius: 8px;
599
- background: none;
600
- font-size: 12px;
601
- color: $color-text;
602
- font-variant-numeric: tabular-nums;
603
- transition: background 0.1s ease, color 0.1s ease;
604
-
605
- &:hover { background: $color-accent-dim; }
606
-
607
- // Поза поточним місяцем — приглушено.
608
- &[data-outside-view] { color: $color-muted; opacity: 0.5; }
609
-
610
- // Сьогодні — тонке кільце.
611
- &[data-today] { box-shadow: inset 0 0 0 1px $color-border; }
612
-
613
- // Усередині діапазону — м'який фон, прямокутник (краї скруглить start/end).
614
- &[data-highlighted],
615
- &[data-selected] {
616
- background: $color-accent-dim;
617
- border-radius: 0;
618
- }
619
-
620
- // Кінці діапазону — акцент.
621
- &[data-selection-start],
622
- &[data-selection-end] {
623
- background: $color-selected;
624
- color: $color-on-selected;
625
- }
626
- &[data-selection-start] { border-radius: 8px 0 0 8px; }
627
- &[data-selection-end] { border-radius: 0 8px 8px 0; }
628
-
629
- &[data-disabled] { color: $color-muted; opacity: 0.35; pointer-events: none; }
630
- }
631
- }
632
-
633
- .drf-foot {
634
- display: flex;
635
- align-items: center;
636
- justify-content: space-between;
637
- gap: 8px;
638
- padding: 8px 12px;
639
- border-top: 1px solid $color-border;
640
-
641
- &__right { display: flex; align-items: center; gap: 8px; }
642
-
643
- &__ghost {
644
- display: inline-flex;
645
- align-items: center;
646
- gap: 5px;
647
- height: 30px;
648
- padding: 0 10px;
649
- border: 0;
650
- border-radius: 8px;
651
- background: none;
652
- font-size: 12px;
653
- color: $color-muted;
654
- transition: background 0.12s ease, color 0.12s ease;
655
-
656
- &:hover { background: $color-page-bg; color: $color-text; }
657
- }
658
-
659
- &__apply {
660
- display: inline-flex;
661
- align-items: center;
662
- gap: 5px;
663
- height: 30px;
664
- padding: 0 14px;
665
- border: 0;
666
- border-radius: 8px;
667
- background: $color-selected;
668
- color: $color-on-selected;
669
- font-size: 12px;
670
- font-weight: 600;
671
- transition: opacity 0.12s ease;
672
-
673
- &:disabled { opacity: 0.45; }
674
- }
675
- }
676
- </style>
677
-
678
- <!-- Не scoped: PopoverContent телепортується в body, і його КОРІНЬ не отримує
679
- scope-атрибут (reka форвардить/фрагмент), тому scoped-правило .drf-pop до
680
- нього не чіпляється. Внутрішні .drf-* scope мають — тому оформлені, а сам
681
- контейнер лишався прозорим. Заливку/тінь/z-index вішаємо тут. Клас
682
- достатньо специфічний, щоб не текти. -->
683
- <style lang="scss">
684
- .drf-pop {
685
- z-index: 1000;
686
- background: $color-surface;
687
- border: 1px solid $color-border;
688
- border-radius: 12px;
689
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
690
- overflow: hidden;
691
- }
692
- </style>
1
+ <script setup lang="ts" generic="TPeriod extends Period | null = Period">
2
+ // Єдине поле вибору періоду для всіх фільтрів. Замість двох нативних
3
+ // <input type="date"> + дебаунс — одне поле-тригер, що відкриває поповер із
4
+ // календарем + пресетами. Ключове: вибір усередині — ЧЕРНЕТКА, назовні нічого
5
+ // не летить, поки не натиснуто «Застосувати». Це прибирає стрибок «почав
6
+ // міняти початок — а воно вже відправило запит».
7
+ //
8
+ // mode:
9
+ // day — вільний діапазон (статистика/платежі): будь-які start/end, але
10
+ // застосувати можна лише коли обрані ОБИДВА кінці.
11
+ // week — вибір прилипає до цілих тижнів (Пн–Вс) для звітів: агрегатори дають
12
+ // точні суми лише в межах тижня. Пресети-місяці — теж дозволені.
13
+
14
+ import { SharedConfig } from '../../config'
15
+ import { today, getLocalTimeZone, type DateValue } from '@internationalized/date'
16
+ import { CalendarRange, Check, ChevronLeft, ChevronRight, X } from '@lucide/vue'
17
+ import {
18
+ PopoverContent,
19
+ PopoverPortal,
20
+ PopoverRoot,
21
+ PopoverTrigger,
22
+ RangeCalendarCell,
23
+ RangeCalendarCellTrigger,
24
+ RangeCalendarGrid,
25
+ RangeCalendarGridBody,
26
+ RangeCalendarGridHead,
27
+ RangeCalendarGridRow,
28
+ RangeCalendarHeadCell,
29
+ RangeCalendarRoot,
30
+ type DateRange,
31
+ } from 'reka-ui'
32
+ import { computed, ref, shallowRef, watch } from 'vue'
33
+ import type { Period } from '../../helpers/period.helper'
34
+ import { CalendarRangeHelper } from '../../helpers/calendarRange.helper'
35
+ import {
36
+ PeriodPresetsHelper,
37
+ type PeriodPreset,
38
+ type PeriodPresetGroups,
39
+ } from '../../helpers/periodPresets.helper'
40
+
41
+ const props = withDefaults(defineProps<{
42
+ // null — період не обрано («усі дати»): списку без обовʼязкової дати нічого
43
+ // підставляти за замовчуванням.
44
+ period: TPeriod
45
+ // Підпис тригера, коли період не обрано.
46
+ emptyLabel?: string
47
+ // Хрестик поруч із полем знімає період (emit null).
48
+ isClearable?: boolean
49
+ mode?: 'day' | 'week'
50
+ // Свій набір пресетів (напр. звіти: тиждень/місяць/квартал/рік). Не задано —
51
+ // дефолтний за mode.
52
+ presets?: PeriodPresetGroups
53
+ // Тригер тягнеться на всю доступну ширину (напр. у модалці в один рядок з кнопкою).
54
+ block?: boolean
55
+ }>(), {
56
+ mode: 'day',
57
+ })
58
+
59
+ const labels = SharedConfig.get().labels
60
+
61
+ const emit = defineEmits<{ 'update:period': [period: TPeriod] }>()
62
+
63
+ const EMPTY_RANGE: DateRange = { start: undefined, end: undefined }
64
+
65
+ function toRange(period: Period | null): DateRange {
66
+ return period ? CalendarRangeHelper.toRange(period) : { ...EMPTY_RANGE }
67
+ }
68
+
69
+ const isOpen = ref(false)
70
+ // Чернетка вибору. Комітиться лише «Застосувати» / кліком по пресету.
71
+ const draft = shallowRef<DateRange>(toRange(props.period))
72
+ // Місяць, який показує календар. Керується стрілками шапки + сіткою років/місяців.
73
+ const placeholder = shallowRef<DateValue>(
74
+ CalendarRangeHelper.toCalendarDate(props.period?.from) ?? today(getLocalTimeZone()),
75
+ )
76
+ // Навігація як у нативному пікері: заголовок-кнопка перемикає вигляд
77
+ // days → years → (клік по року) → months → (клік по місяцю) → days. Без дропдаунів.
78
+ type PickerView = 'days' | 'months' | 'years'
79
+ const pickerView = ref<PickerView>('days')
80
+
81
+ // Відкриття — завжди зі свіжого зовнішнього значення (скидає недокручену
82
+ // чернетку від минулого разу) + вертаємо календар на місяць початку періоду.
83
+ watch(isOpen, (open) => {
84
+ if (open) {
85
+ draft.value = toRange(props.period)
86
+ placeholder.value = CalendarRangeHelper.toCalendarDate(props.period?.from) ?? today(getLocalTimeZone())
87
+ pickerView.value = 'days'
88
+ }
89
+ })
90
+
91
+ // Пресети: свій набір або дефолтний за mode.
92
+ const presetGroups = computed<PeriodPresetGroups>(() =>
93
+ props.presets ?? (props.mode === 'week' ? PeriodPresetsHelper.week() : PeriodPresetsHelper.day()),
94
+ )
95
+
96
+ // --- Сітка вибору місяця/року ------------------------------------------------
97
+ const YEARS_PER_PAGE = 12
98
+ const MONTH_LONG_FMT = new Intl.DateTimeFormat('uk-UA', { month: 'long' })
99
+ const MONTH_SHORT_FMT = new Intl.DateTimeFormat('uk-UA', { month: 'short' })
100
+ const NOW_YEAR = new Date().getFullYear()
101
+ const NOW_MONTH = new Date().getMonth() + 1
102
+
103
+ function capitalize(s: string): string {
104
+ return s.charAt(0).toUpperCase() + s.slice(1)
105
+ }
106
+
107
+ const monthItems = Array.from({ length: 12 }, (_, i) => ({
108
+ value: i + 1,
109
+ label: capitalize(MONTH_SHORT_FMT.format(new Date(2020, i, 1))),
110
+ }))
111
+
112
+ // Сторінка з 12 років навколо плейсхолдера (рівний тайлінг від 2000, без стелі/підлоги).
113
+ const yearsPageStart = computed(() => {
114
+ const y = placeholder.value.year
115
+ return y - (((y - 2000) % YEARS_PER_PAGE) + YEARS_PER_PAGE) % YEARS_PER_PAGE
116
+ })
117
+ const yearItems = computed(() =>
118
+ Array.from({ length: YEARS_PER_PAGE }, (_, i) => yearsPageStart.value + i),
119
+ )
120
+
121
+ // Підпис місяця для конкретної сітки днів ("Травень 2026").
122
+ function monthLabel(d: DateValue): string {
123
+ return `${capitalize(MONTH_LONG_FMT.format(new Date(d.year, d.month - 1, 1)))} ${d.year}`
124
+ }
125
+
126
+ const headingLabel = computed(() => {
127
+ const p = placeholder.value
128
+ if (pickerView.value === 'years') return `${yearsPageStart.value} – ${yearsPageStart.value + YEARS_PER_PAGE - 1}`
129
+ if (pickerView.value === 'months') return String(p.year)
130
+ // Days: сам місяць підписаний під кожною сіткою — тут показуємо лише рік(и),
131
+ // це заодно вхід у вибір року. Роки різні (грудень-січень) — діапазон.
132
+ const b = p.add({ months: 1 })
133
+ return p.year === b.year ? String(p.year) : `${p.year} – ${b.year}`
134
+ })
135
+
136
+ function toggleView(): void {
137
+ pickerView.value = pickerView.value === 'days' ? 'years' : 'days'
138
+ }
139
+
140
+ // Стрілки: гортають місяць / рік / сторінку років — залежно від вигляду.
141
+ function nav(dir: 1 | -1): void {
142
+ const p = placeholder.value
143
+ const step = pickerView.value === 'years'
144
+ ? { years: YEARS_PER_PAGE }
145
+ : pickerView.value === 'months'
146
+ ? { years: 1 }
147
+ : { months: 1 }
148
+ placeholder.value = dir === 1 ? p.add(step) : p.subtract(step)
149
+ }
150
+
151
+ function pickYear(year: number): void {
152
+ placeholder.value = placeholder.value.set({ year })
153
+ pickerView.value = 'months'
154
+ }
155
+
156
+ function pickMonth(month: number): void {
157
+ placeholder.value = placeholder.value.set({ month })
158
+ pickerView.value = 'days'
159
+ }
160
+
161
+ const triggerLabel = computed(() => props.period ? CalendarRangeHelper.label(props.period) : props.emptyLabel ?? labels.allDates)
162
+
163
+ const draftPeriod = computed(() => CalendarRangeHelper.toPeriod(draft.value))
164
+ const isApplyDisabled = computed(() => draftPeriod.value === null)
165
+
166
+ // week-режим: докручуємо вибір до цілих тижнів на кожній зміні календаря.
167
+ function onCalendarUpdate(range: DateRange): void {
168
+ draft.value = props.mode === 'week' ? CalendarRangeHelper.snapToWeeks(range) : range
169
+ }
170
+
171
+ // Пресет — однозначний повний період: застосовуємо одразу й закриваємо.
172
+ function applyPreset(preset: PeriodPreset): void {
173
+ emit('update:period', preset.make() as TPeriod)
174
+ isOpen.value = false
175
+ }
176
+
177
+ function apply(): void {
178
+ if (draftPeriod.value) {
179
+ emit('update:period', draftPeriod.value as TPeriod)
180
+ isOpen.value = false
181
+ }
182
+ }
183
+
184
+ function clear(): void {
185
+ draft.value = { start: undefined, end: undefined }
186
+ }
187
+ </script>
188
+
189
+ <template>
190
+ <span class="drf" :class="{ 'drf--block': block }">
191
+ <PopoverRoot v-model:open="isOpen">
192
+ <PopoverTrigger
193
+ class="drf-trigger"
194
+ :class="{ 'drf-trigger--open': isOpen, 'drf-trigger--block': block, 'drf-trigger--empty': !period }"
195
+ >
196
+ <CalendarRange :size="14" />
197
+ <span class="drf-trigger__label">{{ triggerLabel }}</span>
198
+ </PopoverTrigger>
199
+
200
+ <PopoverPortal>
201
+ <PopoverContent align="start" :side-offset="6" class="drf-pop">
202
+ <div class="drf-body">
203
+ <!-- Пресети (згруповані). Порожній набір (напр. у модалці) — колонку
204
+ ховаємо, лишається сам календар. -->
205
+ <div v-if="presetGroups.length" class="drf-presets">
206
+ <template v-for="(group, gi) in presetGroups" :key="gi">
207
+ <div v-if="gi > 0" class="drf-presets__sep" />
208
+ <button
209
+ v-for="preset in group"
210
+ :key="preset.label"
211
+ type="button"
212
+ class="drf-presets__item"
213
+ @click="applyPreset(preset)"
214
+ >
215
+ {{ preset.label }}
216
+ </button>
217
+ </template>
218
+ </div>
219
+
220
+ <!-- Календар -->
221
+ <RangeCalendarRoot
222
+ v-slot="{ weekDays, grid }"
223
+ :model-value="draft"
224
+ :placeholder="placeholder"
225
+ :week-starts-on="CalendarRangeHelper.WEEK_STARTS_ON"
226
+ weekday-format="short"
227
+ locale="uk"
228
+ :number-of-months="2"
229
+ fixed-weeks
230
+ class="drf-cal"
231
+ :class="`drf-cal--${mode}`"
232
+ @update:model-value="onCalendarUpdate"
233
+ @update:placeholder="placeholder = $event"
234
+ >
235
+ <!-- Шапка: стрілки + заголовок-кнопка. Клік по заголовку відкриває
236
+ сітку років → місяців (як окремий екран у нативному пікері). -->
237
+ <div class="drf-cal__header">
238
+ <button type="button" class="drf-cal__nav" @click="nav(-1)">
239
+ <ChevronLeft :size="16" />
240
+ </button>
241
+ <button type="button" class="drf-cal__title" @click="toggleView">
242
+ {{ headingLabel }}
243
+ </button>
244
+ <button type="button" class="drf-cal__nav" @click="nav(1)">
245
+ <ChevronRight :size="16" />
246
+ </button>
247
+ </div>
248
+
249
+ <!-- Сітка років -->
250
+ <div v-if="pickerView === 'years'" class="drf-cal__pick">
251
+ <button
252
+ v-for="y in yearItems"
253
+ :key="y"
254
+ type="button"
255
+ class="drf-cal__pick-item"
256
+ :class="{ 'is-active': y === placeholder.year, 'is-now': y === NOW_YEAR }"
257
+ @click="pickYear(y)"
258
+ >
259
+ {{ y }}
260
+ </button>
261
+ </div>
262
+
263
+ <!-- Сітка місяців -->
264
+ <div v-else-if="pickerView === 'months'" class="drf-cal__pick">
265
+ <button
266
+ v-for="m in monthItems"
267
+ :key="m.value"
268
+ type="button"
269
+ class="drf-cal__pick-item"
270
+ :class="{
271
+ 'is-active': m.value === placeholder.month,
272
+ 'is-now': m.value === NOW_MONTH && placeholder.year === NOW_YEAR,
273
+ }"
274
+ @click="pickMonth(m.value)"
275
+ >
276
+ {{ m.label }}
277
+ </button>
278
+ </div>
279
+
280
+ <div v-else class="drf-cal__months">
281
+ <RangeCalendarGrid
282
+ v-for="month in grid"
283
+ :key="month.value.toString()"
284
+ class="drf-cal__grid"
285
+ >
286
+ <!-- Підпис КОНКРЕТНОЇ сітки: видно, де травень, а де червень.
287
+ <caption> — валідний перший нащадок <table> (reka рендерить
288
+ сітку таблицею), лягає над нею. -->
289
+ <caption class="drf-cal__grid-title">{{ monthLabel(month.value) }}</caption>
290
+ <RangeCalendarGridHead>
291
+ <RangeCalendarGridRow class="drf-cal__row drf-cal__row--head">
292
+ <RangeCalendarHeadCell
293
+ v-for="day in weekDays"
294
+ :key="day"
295
+ class="drf-cal__weekday"
296
+ >
297
+ {{ day }}
298
+ </RangeCalendarHeadCell>
299
+ </RangeCalendarGridRow>
300
+ </RangeCalendarGridHead>
301
+
302
+ <RangeCalendarGridBody>
303
+ <RangeCalendarGridRow
304
+ v-for="(weekDates, wi) in month.rows"
305
+ :key="`w-${wi}`"
306
+ class="drf-cal__row"
307
+ >
308
+ <RangeCalendarCell
309
+ v-for="weekDate in weekDates"
310
+ :key="weekDate.toString()"
311
+ :date="weekDate"
312
+ class="drf-cal__cell"
313
+ >
314
+ <RangeCalendarCellTrigger
315
+ :day="weekDate"
316
+ :month="month.value"
317
+ class="drf-cal__day"
318
+ />
319
+ </RangeCalendarCell>
320
+ </RangeCalendarGridRow>
321
+ </RangeCalendarGridBody>
322
+ </RangeCalendarGrid>
323
+ </div>
324
+ </RangeCalendarRoot>
325
+ </div>
326
+
327
+ <!-- Звіти точні лише в межах тижня — тому вибір тут кратний тижням. -->
328
+ <p v-if="mode === 'week'" class="drf-note">
329
+ {{ labels.periodWeeksOnly }}
330
+ </p>
331
+
332
+ <!-- Футер: нічого не летить назовні, поки не «Застосувати» -->
333
+ <footer class="drf-foot">
334
+ <button type="button" class="drf-foot__ghost" @click="clear">
335
+ <X :size="14" /> {{ labels.clear }}
336
+ </button>
337
+ <div class="drf-foot__right">
338
+ <button type="button" class="drf-foot__ghost" @click="isOpen = false">{{ labels.cancel }}</button>
339
+ <button
340
+ type="button"
341
+ class="drf-foot__apply"
342
+ :disabled="isApplyDisabled"
343
+ :title="isApplyDisabled ? labels.periodPickBoth : undefined"
344
+ @click="apply"
345
+ >
346
+ <Check :size="14" /> {{ labels.apply }}
347
+ </button>
348
+ </div>
349
+ </footer>
350
+ </PopoverContent>
351
+ </PopoverPortal>
352
+ </PopoverRoot>
353
+ <!-- Поза тригером: кнопка в кнопці — невалідний HTML і клік відкрив би календар. -->
354
+ <button
355
+ v-if="isClearable && period"
356
+ type="button"
357
+ class="drf-clear"
358
+ :title="labels.allDates"
359
+ :aria-label="labels.periodRemove"
360
+ @click="emit('update:period', null as TPeriod)"
361
+ >
362
+ <X :size="13" />
363
+ </button>
364
+ </span>
365
+ </template>
366
+
367
+ <style scoped lang="scss">
368
+ .drf {
369
+ display: inline-flex;
370
+ align-items: center;
371
+ gap: 2px;
372
+
373
+ &--block { display: flex; flex: 1; }
374
+ }
375
+
376
+ .drf-clear {
377
+ display: inline-flex;
378
+ padding: 4px;
379
+ border: none;
380
+ border-radius: 4px;
381
+ background: transparent;
382
+ color: $color-muted;
383
+ cursor: pointer;
384
+
385
+ &:hover { color: $color-text; background: $color-border; }
386
+ }
387
+
388
+ .drf-trigger {
389
+ display: inline-flex;
390
+ align-items: center;
391
+ gap: 8px;
392
+ height: 32px;
393
+ padding: 0 10px;
394
+ background: $color-page-bg;
395
+ border: 1px solid $color-border;
396
+ border-radius: 8px;
397
+ color: $color-text;
398
+ font-size: 13px;
399
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
400
+
401
+ &:hover { border-color: rgba(0, 0, 0, 0.2); }
402
+
403
+ &--open {
404
+ border-color: $color-accent;
405
+ box-shadow: 0 0 0 2px $color-accent-dim;
406
+ }
407
+
408
+ // Тягнеться на всю ширину рядка; лейбл забирає вільне місце, дата — ліворуч.
409
+ &--block {
410
+ flex: 1;
411
+ justify-content: flex-start;
412
+
413
+ .drf-trigger__label { flex: 1; text-align: left; }
414
+ }
415
+
416
+ svg { color: $color-muted; flex-shrink: 0; }
417
+ &__label { font-variant-numeric: tabular-nums; white-space: nowrap; }
418
+ }
419
+
420
+ .drf-body {
421
+ display: flex;
422
+ align-items: stretch;
423
+
424
+ @media (max-width: 640px) {
425
+ flex-direction: column;
426
+ }
427
+ }
428
+
429
+ .drf-presets {
430
+ display: flex;
431
+ flex-direction: column;
432
+ gap: 2px;
433
+ width: 148px;
434
+ padding: 8px;
435
+ border-right: 1px solid $color-border;
436
+
437
+ @media (max-width: 640px) {
438
+ width: auto;
439
+ border-right: none;
440
+ border-bottom: 1px solid $color-border;
441
+ flex-direction: row;
442
+ flex-wrap: wrap;
443
+ }
444
+
445
+ &__sep {
446
+ height: 1px;
447
+ margin: 4px 6px;
448
+ background: $color-border;
449
+
450
+ @media (max-width: 640px) { display: none; }
451
+ }
452
+
453
+ &__item {
454
+ width: 100%;
455
+ padding: 6px 10px;
456
+ border: 0;
457
+ border-radius: 8px;
458
+ background: none;
459
+ text-align: left;
460
+ font-size: 12px;
461
+ color: $color-text;
462
+ transition: background 0.12s ease;
463
+
464
+ &:hover { background: $color-page-bg; }
465
+
466
+ @media (max-width: 640px) { width: auto; }
467
+ }
468
+ }
469
+
470
+ .drf-note {
471
+ padding: 8px 12px;
472
+ border-top: 1px solid $color-border;
473
+ font-size: 12px;
474
+ color: $color-muted;
475
+ text-align: center;
476
+ }
477
+
478
+ .drf-cal {
479
+ padding: 10px;
480
+
481
+ &__header {
482
+ display: flex;
483
+ align-items: center;
484
+ justify-content: space-between;
485
+ margin-bottom: 8px;
486
+ }
487
+
488
+ // Заголовок-кнопка (місяць-рік / діапазон років). Клік → сітка вибору.
489
+ &__title {
490
+ flex: 1;
491
+ height: 26px;
492
+ padding: 0 10px;
493
+ border: 0;
494
+ border-radius: 8px;
495
+ background: none;
496
+ font-size: 12px;
497
+ font-weight: 600;
498
+ color: $color-text;
499
+ text-transform: capitalize;
500
+ transition: background 0.12s ease;
501
+
502
+ &:hover { background: $color-page-bg; }
503
+ }
504
+
505
+ // Сітка вибору року/місяця (4×3).
506
+ &__pick {
507
+ display: grid;
508
+ grid-template-columns: repeat(4, 1fr);
509
+ gap: 8px;
510
+ padding: 10px 8px 6px;
511
+ }
512
+
513
+ &__pick-item {
514
+ height: 34px;
515
+ min-width: 60px;
516
+ padding: 0 12px;
517
+ border: 0;
518
+ border-radius: 8px;
519
+ background: none;
520
+ font-size: 12px;
521
+ color: $color-text;
522
+ font-variant-numeric: tabular-nums;
523
+ transition: background 0.12s ease, color 0.12s ease;
524
+
525
+ &:hover { background: $color-accent-dim; }
526
+
527
+ // Поточний реальний рік/місяць — тонке кільце.
528
+ &.is-now { box-shadow: inset 0 0 0 1px $color-border; }
529
+
530
+ // Обраний (плейсхолдер) — акцент.
531
+ &.is-active {
532
+ background: $color-selected;
533
+ color: $color-on-selected;
534
+ font-weight: 600;
535
+ }
536
+ }
537
+
538
+ &__nav {
539
+ display: inline-flex;
540
+ align-items: center;
541
+ justify-content: center;
542
+ width: 26px;
543
+ height: 26px;
544
+ border: 1px solid $color-border;
545
+ border-radius: 8px;
546
+ background: $color-surface;
547
+ color: $color-text;
548
+
549
+ &:hover { border-color: rgba(0, 0, 0, 0.2); }
550
+ &[data-disabled] { opacity: 0.4; pointer-events: none; }
551
+ }
552
+
553
+ &__months {
554
+ display: flex;
555
+ gap: 14px;
556
+
557
+ @media (max-width: 640px) {
558
+ flex-direction: column;
559
+ gap: 10px;
560
+ }
561
+ }
562
+
563
+ // Підпис конкретної сітки місяця ("Травень 2026").
564
+ &__grid-title {
565
+ caption-side: top;
566
+ margin-bottom: 6px;
567
+ font-size: 12px;
568
+ font-weight: 600;
569
+ color: $color-text;
570
+ text-transform: capitalize;
571
+ text-align: center;
572
+ }
573
+
574
+ &__row {
575
+ display: grid;
576
+ grid-template-columns: repeat(7, 1fr);
577
+ }
578
+
579
+ &__weekday {
580
+ padding-bottom: 5px;
581
+ font-size: 10px;
582
+ font-weight: 500;
583
+ color: $color-muted;
584
+ text-align: center;
585
+ text-transform: capitalize;
586
+ }
587
+
588
+ &__cell { text-align: center; }
589
+
590
+ // Клітинка-день. data-* атрибути ставить reka; на них весь вигляд станів.
591
+ &__day {
592
+ display: inline-flex;
593
+ align-items: center;
594
+ justify-content: center;
595
+ width: 30px;
596
+ height: 28px;
597
+ border: 0;
598
+ border-radius: 8px;
599
+ background: none;
600
+ font-size: 12px;
601
+ color: $color-text;
602
+ font-variant-numeric: tabular-nums;
603
+ transition: background 0.1s ease, color 0.1s ease;
604
+
605
+ &:hover { background: $color-accent-dim; }
606
+
607
+ // Поза поточним місяцем — приглушено.
608
+ &[data-outside-view] { color: $color-muted; opacity: 0.5; }
609
+
610
+ // Сьогодні — тонке кільце.
611
+ &[data-today] { box-shadow: inset 0 0 0 1px $color-border; }
612
+
613
+ // Усередині діапазону — м'який фон, прямокутник (краї скруглить start/end).
614
+ &[data-highlighted],
615
+ &[data-selected] {
616
+ background: $color-accent-dim;
617
+ border-radius: 0;
618
+ }
619
+
620
+ // Кінці діапазону — акцент.
621
+ &[data-selection-start],
622
+ &[data-selection-end] {
623
+ background: $color-selected;
624
+ color: $color-on-selected;
625
+ }
626
+ &[data-selection-start] { border-radius: 8px 0 0 8px; }
627
+ &[data-selection-end] { border-radius: 0 8px 8px 0; }
628
+
629
+ &[data-disabled] { color: $color-muted; opacity: 0.35; pointer-events: none; }
630
+ }
631
+ }
632
+
633
+ .drf-foot {
634
+ display: flex;
635
+ align-items: center;
636
+ justify-content: space-between;
637
+ gap: 8px;
638
+ padding: 8px 12px;
639
+ border-top: 1px solid $color-border;
640
+
641
+ &__right { display: flex; align-items: center; gap: 8px; }
642
+
643
+ &__ghost {
644
+ display: inline-flex;
645
+ align-items: center;
646
+ gap: 5px;
647
+ height: 30px;
648
+ padding: 0 10px;
649
+ border: 0;
650
+ border-radius: 8px;
651
+ background: none;
652
+ font-size: 12px;
653
+ color: $color-muted;
654
+ transition: background 0.12s ease, color 0.12s ease;
655
+
656
+ &:hover { background: $color-page-bg; color: $color-text; }
657
+ }
658
+
659
+ &__apply {
660
+ display: inline-flex;
661
+ align-items: center;
662
+ gap: 5px;
663
+ height: 30px;
664
+ padding: 0 14px;
665
+ border: 0;
666
+ border-radius: 8px;
667
+ background: $color-selected;
668
+ color: $color-on-selected;
669
+ font-size: 12px;
670
+ font-weight: 600;
671
+ transition: opacity 0.12s ease;
672
+
673
+ &:disabled { opacity: 0.45; }
674
+ }
675
+ }
676
+ </style>
677
+
678
+ <!-- Не scoped: PopoverContent телепортується в body, і його КОРІНЬ не отримує
679
+ scope-атрибут (reka форвардить/фрагмент), тому scoped-правило .drf-pop до
680
+ нього не чіпляється. Внутрішні .drf-* scope мають — тому оформлені, а сам
681
+ контейнер лишався прозорим. Заливку/тінь/z-index вішаємо тут. Клас
682
+ достатньо специфічний, щоб не текти. -->
683
+ <style lang="scss">
684
+ .drf-pop {
685
+ z-index: 1000;
686
+ background: $color-surface;
687
+ border: 1px solid $color-border;
688
+ border-radius: 12px;
689
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
690
+ overflow: hidden;
691
+ }
692
+ </style>