@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,200 +1,200 @@
1
- <script setup lang="ts">
2
- // Простий переглядач зображень (lightbox). Тільки перегляд — жодних дій над файлом.
3
- // Зум: колесо миші (у точку курсора) або подвійний клік. Пан: перетягування, коли наближено.
4
- // Закрити: × або Esc (область клавіш модалки, BaseModal).
5
-
6
- import { X } from '@lucide/vue'
7
- import { computed, ref } from 'vue'
8
- import { SharedConfig } from '../../config'
9
- import { useCurrentModal } from '../../plugins/modals.plugin'
10
-
11
- interface Props {
12
- url: string
13
- name?: string
14
- }
15
-
16
- defineProps<Props>()
17
-
18
- const { close } = useCurrentModal()
19
-
20
- const MIN_SCALE = 1
21
- const MAX_SCALE = 5
22
- const DBL_CLICK_SCALE = 2.5
23
- const WHEEL_STEP = 1.15
24
-
25
- const stage = ref<HTMLElement | null>(null)
26
- const scale = ref(MIN_SCALE)
27
- const offset = ref({ x: 0, y: 0 })
28
- const isPanning = ref(false)
29
- let panStart = { x: 0, y: 0, offsetX: 0, offsetY: 0 }
30
-
31
- const isZoomed = computed(() => scale.value > MIN_SCALE)
32
- const imageStyle = computed(() => ({
33
- transform: `translate(${offset.value.x}px, ${offset.value.y}px) scale(${scale.value})`,
34
- }))
35
-
36
- function clamp(value: number, min: number, max: number): number {
37
- return Math.min(max, Math.max(min, value))
38
- }
39
-
40
- function reset() {
41
- scale.value = MIN_SCALE
42
- offset.value = { x: 0, y: 0 }
43
- }
44
-
45
- // Зум у точку курсора: точка під ним лишається на місці.
46
- // offset' = c - (c - offset) * (scale' / scale), де c — курсор відносно центру сцени.
47
- function zoomAt(clientX: number, clientY: number, nextScale: number) {
48
- const el = stage.value
49
- if (!el) return
50
-
51
- const next = clamp(nextScale, MIN_SCALE, MAX_SCALE)
52
- if (next === MIN_SCALE) { reset(); return }
53
-
54
- const rect = el.getBoundingClientRect()
55
- const cursorX = clientX - (rect.left + rect.width / 2)
56
- const cursorY = clientY - (rect.top + rect.height / 2)
57
- const ratio = next / scale.value
58
-
59
- offset.value = {
60
- x: cursorX - (cursorX - offset.value.x) * ratio,
61
- y: cursorY - (cursorY - offset.value.y) * ratio,
62
- }
63
- scale.value = next
64
- }
65
-
66
- function onWheel(event: WheelEvent) {
67
- event.preventDefault()
68
- zoomAt(event.clientX, event.clientY, scale.value * (event.deltaY < 0 ? WHEEL_STEP : 1 / WHEEL_STEP))
69
- }
70
-
71
- function onDblClick(event: MouseEvent) {
72
- if (isZoomed.value) reset()
73
- else zoomAt(event.clientX, event.clientY, DBL_CLICK_SCALE)
74
- }
75
-
76
- function onPointerDown(event: PointerEvent) {
77
- if (!isZoomed.value) return
78
- isPanning.value = true
79
- panStart = { x: event.clientX, y: event.clientY, offsetX: offset.value.x, offsetY: offset.value.y }
80
- ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)
81
- }
82
-
83
- function onPointerMove(event: PointerEvent) {
84
- if (!isPanning.value) return
85
- offset.value = {
86
- x: panStart.offsetX + (event.clientX - panStart.x),
87
- y: panStart.offsetY + (event.clientY - panStart.y),
88
- }
89
- }
90
-
91
- function onPointerUp(event: PointerEvent) {
92
- if (!isPanning.value) return
93
- isPanning.value = false
94
- ;(event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId)
95
- }
96
-
97
- </script>
98
-
99
- <template>
100
- <div class="viewer">
101
- <div
102
- ref="stage"
103
- class="viewer__stage"
104
- :class="{
105
- 'viewer__stage--zoomed': isZoomed,
106
- 'viewer__stage--panning': isPanning,
107
- }"
108
- @wheel="onWheel"
109
- @dblclick="onDblClick"
110
- @pointerdown="onPointerDown"
111
- @pointermove="onPointerMove"
112
- @pointerup="onPointerUp"
113
- @pointercancel="onPointerUp"
114
- >
115
- <img
116
- class="viewer__img"
117
- :class="{ 'viewer__img--smooth': !isPanning }"
118
- :src="url"
119
- :alt="name ?? ''"
120
- :style="imageStyle"
121
- draggable="false"
122
- />
123
-
124
- <button type="button" class="viewer__close" :aria-label="SharedConfig.get().labels.close" @click="close()">
125
- <X :size="18" />
126
- </button>
127
- </div>
128
-
129
- <p v-if="name" class="viewer__caption">{{ name }}</p>
130
- </div>
131
- </template>
132
-
133
- <style scoped lang="scss">
134
- .viewer {
135
- position: relative;
136
- margin: auto; // .modal-block має align-items: flex-start — центруємо самі
137
- display: flex;
138
- flex-direction: column;
139
- align-items: center;
140
- gap: 8px;
141
- max-width: 100%;
142
-
143
- &__stage {
144
- position: relative;
145
- overflow: hidden; // кадруємо наближену картинку по рамці
146
- border-radius: 12px;
147
- background: rgba(15, 20, 30, 0.4);
148
- line-height: 0;
149
- cursor: zoom-in;
150
- touch-action: none; // щоб пан пальцем не скролив сторінку
151
-
152
- &--zoomed { cursor: grab; }
153
- &--panning { cursor: grabbing; }
154
- }
155
-
156
- &__img {
157
- display: block;
158
- max-width: min(92vw, 1200px);
159
- max-height: 78vh;
160
- object-fit: contain;
161
- user-select: none;
162
- will-change: transform;
163
-
164
- // Плавно — лише для зуму. Під час пану анімація «мазала» б за курсором.
165
- &--smooth { transition: transform 120ms ease-out; }
166
- }
167
-
168
- &__close {
169
- position: absolute;
170
- top: 8px;
171
- right: 8px;
172
-
173
- width: 32px;
174
- height: 32px;
175
- display: inline-flex;
176
- align-items: center;
177
- justify-content: center;
178
-
179
- border: none;
180
- border-radius: 50%;
181
- background: rgba(15, 20, 30, 0.55);
182
- color: #fff;
183
-
184
- transition: background-color 120ms ease;
185
-
186
- &:hover { background: rgba(15, 20, 30, 0.8); }
187
- }
188
-
189
- &__caption {
190
- margin: 0;
191
- max-width: 100%;
192
- font-size: 12px;
193
- color: #fff;
194
- text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
195
- overflow: hidden;
196
- text-overflow: ellipsis;
197
- white-space: nowrap;
198
- }
199
- }
200
- </style>
1
+ <script setup lang="ts">
2
+ // Простий переглядач зображень (lightbox). Тільки перегляд — жодних дій над файлом.
3
+ // Зум: колесо миші (у точку курсора) або подвійний клік. Пан: перетягування, коли наближено.
4
+ // Закрити: × або Esc (область клавіш модалки, BaseModal).
5
+
6
+ import { X } from '@lucide/vue'
7
+ import { computed, ref } from 'vue'
8
+ import { SharedConfig } from '../../config'
9
+ import { useCurrentModal } from '../../plugins/modals.plugin'
10
+
11
+ interface Props {
12
+ url: string
13
+ name?: string
14
+ }
15
+
16
+ defineProps<Props>()
17
+
18
+ const { close } = useCurrentModal()
19
+
20
+ const MIN_SCALE = 1
21
+ const MAX_SCALE = 5
22
+ const DBL_CLICK_SCALE = 2.5
23
+ const WHEEL_STEP = 1.15
24
+
25
+ const stage = ref<HTMLElement | null>(null)
26
+ const scale = ref(MIN_SCALE)
27
+ const offset = ref({ x: 0, y: 0 })
28
+ const isPanning = ref(false)
29
+ let panStart = { x: 0, y: 0, offsetX: 0, offsetY: 0 }
30
+
31
+ const isZoomed = computed(() => scale.value > MIN_SCALE)
32
+ const imageStyle = computed(() => ({
33
+ transform: `translate(${offset.value.x}px, ${offset.value.y}px) scale(${scale.value})`,
34
+ }))
35
+
36
+ function clamp(value: number, min: number, max: number): number {
37
+ return Math.min(max, Math.max(min, value))
38
+ }
39
+
40
+ function reset() {
41
+ scale.value = MIN_SCALE
42
+ offset.value = { x: 0, y: 0 }
43
+ }
44
+
45
+ // Зум у точку курсора: точка під ним лишається на місці.
46
+ // offset' = c - (c - offset) * (scale' / scale), де c — курсор відносно центру сцени.
47
+ function zoomAt(clientX: number, clientY: number, nextScale: number) {
48
+ const el = stage.value
49
+ if (!el) return
50
+
51
+ const next = clamp(nextScale, MIN_SCALE, MAX_SCALE)
52
+ if (next === MIN_SCALE) { reset(); return }
53
+
54
+ const rect = el.getBoundingClientRect()
55
+ const cursorX = clientX - (rect.left + rect.width / 2)
56
+ const cursorY = clientY - (rect.top + rect.height / 2)
57
+ const ratio = next / scale.value
58
+
59
+ offset.value = {
60
+ x: cursorX - (cursorX - offset.value.x) * ratio,
61
+ y: cursorY - (cursorY - offset.value.y) * ratio,
62
+ }
63
+ scale.value = next
64
+ }
65
+
66
+ function onWheel(event: WheelEvent) {
67
+ event.preventDefault()
68
+ zoomAt(event.clientX, event.clientY, scale.value * (event.deltaY < 0 ? WHEEL_STEP : 1 / WHEEL_STEP))
69
+ }
70
+
71
+ function onDblClick(event: MouseEvent) {
72
+ if (isZoomed.value) reset()
73
+ else zoomAt(event.clientX, event.clientY, DBL_CLICK_SCALE)
74
+ }
75
+
76
+ function onPointerDown(event: PointerEvent) {
77
+ if (!isZoomed.value) return
78
+ isPanning.value = true
79
+ panStart = { x: event.clientX, y: event.clientY, offsetX: offset.value.x, offsetY: offset.value.y }
80
+ ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)
81
+ }
82
+
83
+ function onPointerMove(event: PointerEvent) {
84
+ if (!isPanning.value) return
85
+ offset.value = {
86
+ x: panStart.offsetX + (event.clientX - panStart.x),
87
+ y: panStart.offsetY + (event.clientY - panStart.y),
88
+ }
89
+ }
90
+
91
+ function onPointerUp(event: PointerEvent) {
92
+ if (!isPanning.value) return
93
+ isPanning.value = false
94
+ ;(event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId)
95
+ }
96
+
97
+ </script>
98
+
99
+ <template>
100
+ <div class="viewer">
101
+ <div
102
+ ref="stage"
103
+ class="viewer__stage"
104
+ :class="{
105
+ 'viewer__stage--zoomed': isZoomed,
106
+ 'viewer__stage--panning': isPanning,
107
+ }"
108
+ @wheel="onWheel"
109
+ @dblclick="onDblClick"
110
+ @pointerdown="onPointerDown"
111
+ @pointermove="onPointerMove"
112
+ @pointerup="onPointerUp"
113
+ @pointercancel="onPointerUp"
114
+ >
115
+ <img
116
+ class="viewer__img"
117
+ :class="{ 'viewer__img--smooth': !isPanning }"
118
+ :src="url"
119
+ :alt="name ?? ''"
120
+ :style="imageStyle"
121
+ draggable="false"
122
+ />
123
+
124
+ <button type="button" class="viewer__close" :aria-label="SharedConfig.get().labels.close" @click="close()">
125
+ <X :size="18" />
126
+ </button>
127
+ </div>
128
+
129
+ <p v-if="name" class="viewer__caption">{{ name }}</p>
130
+ </div>
131
+ </template>
132
+
133
+ <style scoped lang="scss">
134
+ .viewer {
135
+ position: relative;
136
+ margin: auto; // .modal-block має align-items: flex-start — центруємо самі
137
+ display: flex;
138
+ flex-direction: column;
139
+ align-items: center;
140
+ gap: 8px;
141
+ max-width: 100%;
142
+
143
+ &__stage {
144
+ position: relative;
145
+ overflow: hidden; // кадруємо наближену картинку по рамці
146
+ border-radius: 12px;
147
+ background: rgba(15, 20, 30, 0.4);
148
+ line-height: 0;
149
+ cursor: zoom-in;
150
+ touch-action: none; // щоб пан пальцем не скролив сторінку
151
+
152
+ &--zoomed { cursor: grab; }
153
+ &--panning { cursor: grabbing; }
154
+ }
155
+
156
+ &__img {
157
+ display: block;
158
+ max-width: min(92vw, 1200px);
159
+ max-height: 78vh;
160
+ object-fit: contain;
161
+ user-select: none;
162
+ will-change: transform;
163
+
164
+ // Плавно — лише для зуму. Під час пану анімація «мазала» б за курсором.
165
+ &--smooth { transition: transform 120ms ease-out; }
166
+ }
167
+
168
+ &__close {
169
+ position: absolute;
170
+ top: 8px;
171
+ right: 8px;
172
+
173
+ width: 32px;
174
+ height: 32px;
175
+ display: inline-flex;
176
+ align-items: center;
177
+ justify-content: center;
178
+
179
+ border: none;
180
+ border-radius: 50%;
181
+ background: rgba(15, 20, 30, 0.55);
182
+ color: #fff;
183
+
184
+ transition: background-color 120ms ease;
185
+
186
+ &:hover { background: rgba(15, 20, 30, 0.8); }
187
+ }
188
+
189
+ &__caption {
190
+ margin: 0;
191
+ max-width: 100%;
192
+ font-size: 12px;
193
+ color: #fff;
194
+ text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
195
+ overflow: hidden;
196
+ text-overflow: ellipsis;
197
+ white-space: nowrap;
198
+ }
199
+ }
200
+ </style>
@@ -1,126 +1,126 @@
1
- <script setup lang="ts">
2
- // Шапка колонки, у якій кілька чисел — і стільки ж сортувань. Назва зверху,
3
- // під нею дрібні кнопки-підписи («зібрано / внесено / борг», «сума / частка»).
4
- //
5
- // Розбивати таку колонку на кілька не варіант: заголовки з'їли б пів таблиці, а
6
- // числа розійшлись би по екрану, хоча читають їх разом. Тому видимій колонці
7
- // ставимо enableSorting: false (інакше клік по будь-якому місцю th перебивав би
8
- // вибір конкретної кнопки), а за кожну кнопку відповідає власний ПРИХОВАНИЙ
9
- // стовпець.
10
- //
11
- // Стан тримає TanStack, а не шапка. Поки вона рахувала його сама, на сторінці з
12
- // мультисортуванням її номер пріоритету жив за своїми правилами й розходився з
13
- // номерами звичайних колонок.
14
-
15
- import type { Table } from '@tanstack/vue-table'
16
- import { computed } from 'vue'
17
- import type { MultiSortPart } from './multiSortHeader.types'
18
-
19
- const props = defineProps<{
20
- label: string
21
- /**
22
- * Рядок таблиці шапці неважливий — вона чіпає лише `getColumn` і `getState`,
23
- * тож `any` тут нічого не втрачає. Параметризувати не можна: `Table<T>`
24
- * інваріантна за T, а кличуть шапку з `h(MultiSortHeader, { table })`, де
25
- * вивести T нізвідки — і `Table<DriverStatRow>` не сходився з `Table<unknown>`.
26
- */
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- table: Table<any>
29
- parts: ReadonlyArray<MultiSortPart>
30
- /** Клік додає ключ у стек, а не замінює його. Він же вмикає номери. */
31
- isMultiSort?: boolean
32
- }>()
33
-
34
- const items = computed(() => props.parts.map(part => ({
35
- ...part,
36
- column: props.table.getColumn(part.id),
37
- })))
38
-
39
- // Номер показуємо лише коли ключів справді кілька — інакше «1» біля єдиного
40
- // сортування нічого не додає.
41
- const isPrioShown = computed(() => props.table.getState().sorting.length > 1)
42
- </script>
43
-
44
- <template>
45
- <!-- t__th-stack — спільний каркас дворядкової шапки: inline-block, тож обидва
46
- рядки підхоплюють вирівнювання комірки (meta.align: right). -->
47
- <span class="t__th-stack multi-sort-th">
48
- <span>{{ label }}</span>
49
-
50
- <span class="multi-sort-th__parts">
51
- <template v-for="(item, i) in items" :key="item.id">
52
- <span v-if="i" class="multi-sort-th__sep">/</span>
53
-
54
- <!-- stop: у th висить обробник сортування колонки. Зараз він вимкнений,
55
- але без stop кнопка почне сортувати «не тим», щойно його ввімкнуть. -->
56
- <button
57
- v-if="item.column"
58
- type="button"
59
- class="multi-sort-th__btn"
60
- :class="{ 'multi-sort-th__btn--on': !!item.column.getIsSorted() }"
61
- :title="item.hint"
62
- @click.stop="item.column.toggleSorting(undefined, isMultiSort)"
63
- >
64
- {{ item.label }}
65
- <span v-if="item.column.getIsSorted()">
66
- {{ item.column.getIsSorted() === 'asc' ? '↑' : '↓' }}
67
- </span>
68
- <sup
69
- v-if="item.column.getIsSorted() && isPrioShown"
70
- class="multi-sort-th__prio"
71
- >{{ item.column.getSortIndex() + 1 }}</sup>
72
- </button>
73
- </template>
74
- </span>
75
- </span>
76
- </template>
77
-
78
- <style scoped lang="scss">
79
- .multi-sort-th {
80
- &__parts {
81
- display: block;
82
- margin-top: 1px;
83
- // Дрібніше за назву: це підпис до неї, а не другий заголовок.
84
- font-size: 10px;
85
- font-weight: 400;
86
- text-transform: none;
87
- letter-spacing: 0;
88
- }
89
-
90
- &__sep {
91
- // Роздільник не клікабельний, тому й тихіший за самі підписи.
92
- margin: 0 2px;
93
- opacity: 0.4;
94
- }
95
-
96
- &__btn {
97
- padding: 0;
98
- border: none;
99
- background: none;
100
- font: inherit;
101
- color: inherit;
102
- // Неактивні підписи приглушені — активний виділяється сам, без заливки.
103
- opacity: 0.7;
104
-
105
- &:hover { opacity: 1; }
106
-
107
- &:focus-visible {
108
- outline: 1px solid $color-accent;
109
- outline-offset: 2px;
110
- border-radius: 3px;
111
- }
112
-
113
- &--on {
114
- opacity: 1;
115
- font-weight: 600;
116
- color: $color-accent-ink;
117
- }
118
- }
119
-
120
- &__prio {
121
- margin-left: 1px;
122
- font-size: 9px;
123
- font-variant-numeric: tabular-nums;
124
- }
125
- }
126
- </style>
1
+ <script setup lang="ts">
2
+ // Шапка колонки, у якій кілька чисел — і стільки ж сортувань. Назва зверху,
3
+ // під нею дрібні кнопки-підписи («зібрано / внесено / борг», «сума / частка»).
4
+ //
5
+ // Розбивати таку колонку на кілька не варіант: заголовки з'їли б пів таблиці, а
6
+ // числа розійшлись би по екрану, хоча читають їх разом. Тому видимій колонці
7
+ // ставимо enableSorting: false (інакше клік по будь-якому місцю th перебивав би
8
+ // вибір конкретної кнопки), а за кожну кнопку відповідає власний ПРИХОВАНИЙ
9
+ // стовпець.
10
+ //
11
+ // Стан тримає TanStack, а не шапка. Поки вона рахувала його сама, на сторінці з
12
+ // мультисортуванням її номер пріоритету жив за своїми правилами й розходився з
13
+ // номерами звичайних колонок.
14
+
15
+ import type { Table } from '@tanstack/vue-table'
16
+ import { computed } from 'vue'
17
+ import type { MultiSortPart } from './multiSortHeader.types'
18
+
19
+ const props = defineProps<{
20
+ label: string
21
+ /**
22
+ * Рядок таблиці шапці неважливий — вона чіпає лише `getColumn` і `getState`,
23
+ * тож `any` тут нічого не втрачає. Параметризувати не можна: `Table<T>`
24
+ * інваріантна за T, а кличуть шапку з `h(MultiSortHeader, { table })`, де
25
+ * вивести T нізвідки — і `Table<DriverStatRow>` не сходився з `Table<unknown>`.
26
+ */
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ table: Table<any>
29
+ parts: ReadonlyArray<MultiSortPart>
30
+ /** Клік додає ключ у стек, а не замінює його. Він же вмикає номери. */
31
+ isMultiSort?: boolean
32
+ }>()
33
+
34
+ const items = computed(() => props.parts.map(part => ({
35
+ ...part,
36
+ column: props.table.getColumn(part.id),
37
+ })))
38
+
39
+ // Номер показуємо лише коли ключів справді кілька — інакше «1» біля єдиного
40
+ // сортування нічого не додає.
41
+ const isPrioShown = computed(() => props.table.getState().sorting.length > 1)
42
+ </script>
43
+
44
+ <template>
45
+ <!-- t__th-stack — спільний каркас дворядкової шапки: inline-block, тож обидва
46
+ рядки підхоплюють вирівнювання комірки (meta.align: right). -->
47
+ <span class="t__th-stack multi-sort-th">
48
+ <span>{{ label }}</span>
49
+
50
+ <span class="multi-sort-th__parts">
51
+ <template v-for="(item, i) in items" :key="item.id">
52
+ <span v-if="i" class="multi-sort-th__sep">/</span>
53
+
54
+ <!-- stop: у th висить обробник сортування колонки. Зараз він вимкнений,
55
+ але без stop кнопка почне сортувати «не тим», щойно його ввімкнуть. -->
56
+ <button
57
+ v-if="item.column"
58
+ type="button"
59
+ class="multi-sort-th__btn"
60
+ :class="{ 'multi-sort-th__btn--on': !!item.column.getIsSorted() }"
61
+ :title="item.hint"
62
+ @click.stop="item.column.toggleSorting(undefined, isMultiSort)"
63
+ >
64
+ {{ item.label }}
65
+ <span v-if="item.column.getIsSorted()">
66
+ {{ item.column.getIsSorted() === 'asc' ? '↑' : '↓' }}
67
+ </span>
68
+ <sup
69
+ v-if="item.column.getIsSorted() && isPrioShown"
70
+ class="multi-sort-th__prio"
71
+ >{{ item.column.getSortIndex() + 1 }}</sup>
72
+ </button>
73
+ </template>
74
+ </span>
75
+ </span>
76
+ </template>
77
+
78
+ <style scoped lang="scss">
79
+ .multi-sort-th {
80
+ &__parts {
81
+ display: block;
82
+ margin-top: 1px;
83
+ // Дрібніше за назву: це підпис до неї, а не другий заголовок.
84
+ font-size: 10px;
85
+ font-weight: 400;
86
+ text-transform: none;
87
+ letter-spacing: 0;
88
+ }
89
+
90
+ &__sep {
91
+ // Роздільник не клікабельний, тому й тихіший за самі підписи.
92
+ margin: 0 2px;
93
+ opacity: 0.4;
94
+ }
95
+
96
+ &__btn {
97
+ padding: 0;
98
+ border: none;
99
+ background: none;
100
+ font: inherit;
101
+ color: inherit;
102
+ // Неактивні підписи приглушені — активний виділяється сам, без заливки.
103
+ opacity: 0.7;
104
+
105
+ &:hover { opacity: 1; }
106
+
107
+ &:focus-visible {
108
+ outline: 1px solid $color-accent;
109
+ outline-offset: 2px;
110
+ border-radius: 3px;
111
+ }
112
+
113
+ &--on {
114
+ opacity: 1;
115
+ font-weight: 600;
116
+ color: $color-accent-ink;
117
+ }
118
+ }
119
+
120
+ &__prio {
121
+ margin-left: 1px;
122
+ font-size: 9px;
123
+ font-variant-numeric: tabular-nums;
124
+ }
125
+ }
126
+ </style>