@rock555/frontend-core 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) 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 → ExportButton.vue} +62 -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/FilterCheckbox.vue +1 -1
  25. package/src/components/ui/FilterSelect.vue +2 -0
  26. package/src/components/ui/UiActionTiles.vue +92 -92
  27. package/src/components/ui/UiBackLink.vue +39 -39
  28. package/src/components/ui/UiBadge.vue +60 -60
  29. package/src/components/ui/UiButton.vue +126 -126
  30. package/src/components/ui/UiCard.vue +88 -88
  31. package/src/components/ui/UiCount.vue +35 -35
  32. package/src/components/ui/UiKpiGrid.vue +144 -142
  33. package/src/components/ui/UiPopover.vue +62 -62
  34. package/src/components/ui/UiSearchInput.vue +102 -102
  35. package/src/components/ui/UiSegmented.vue +145 -145
  36. package/src/components/ui/UiTableCard.vue +116 -116
  37. package/src/components/ui/inputs/DateFormInput.vue +2 -2
  38. package/src/components/ui/inputs/FileInput.vue +5 -0
  39. package/src/components/ui/inputs/RadioSegmentFormInput.vue +0 -1
  40. package/src/components/ui/inputs/SelectFormInput.vue +1 -2
  41. package/src/components/ui/inputs/SmartField.vue +15 -13
  42. package/src/components/ui/inputs/TextareaFormInput.vue +2 -2
  43. package/src/components/ui/uiActionTiles.types.ts +10 -10
  44. package/src/components/ui/uiBadge.types.ts +11 -11
  45. package/src/components/ui/uiKpi.types.ts +19 -17
  46. package/src/composables/useAppForm.ts +67 -67
  47. package/src/composables/useConfirm.ts +21 -21
  48. package/src/composables/useFilterState.ts +70 -70
  49. package/src/composables/useServerList.ts +348 -348
  50. package/src/composables/useServerTable.ts +117 -117
  51. package/src/composables/useSharedAsync.ts +51 -51
  52. package/src/composables/useVirtualTable.ts +77 -77
  53. package/src/config.ts +156 -155
  54. package/src/errors/actionCancelled.ts +9 -9
  55. package/src/errors/apiError.helper.ts +161 -161
  56. package/src/errors/useHandleError.ts +33 -33
  57. package/src/helpers/calendarRange.helper.ts +74 -74
  58. package/src/helpers/month.helper.ts +63 -63
  59. package/src/helpers/periodLabel.helper.ts +70 -70
  60. package/src/helpers/periodPresets.helper.ts +76 -76
  61. package/src/helpers/sort.helper.ts +57 -57
  62. package/src/helpers/tableFields.helper.ts +205 -205
  63. package/src/helpers/urlParams.helper.ts +99 -99
  64. package/src/helpers/urlSchema.helper.ts +296 -296
  65. package/src/plugins/modals.plugin.ts +253 -253
  66. package/src/plugins/table.plugin.ts +173 -173
@@ -1,142 +1,144 @@
1
- <script setup lang="ts">
2
- // Ряд KPI-плашок над таблицею. Що показувати — вирішує фіча (своя computed
3
- // cards), кіт відповідає лише за вигляд і скелетон.
4
-
5
- import type { UiKpiCardItem } from './uiKpi.types'
6
-
7
- withDefaults(defineProps<{
8
- cards: UiKpiCardItem[]
9
- /** lg — коли карток 3–4 і є місце на великі цифри; md — коли їх багато. */
10
- size?: 'md' | 'lg'
11
- }>(), { size: 'md' })
12
- </script>
13
-
14
- <template>
15
- <section class="ui-kpi" :class="`ui-kpi--${size}`">
16
- <article v-for="card in cards" :key="card.key" class="ui-kpi__card">
17
- <div class="ui-kpi__icon" :class="card.tone && `ui-kpi__icon--${card.tone}`">
18
- <component :is="card.icon" :size="18" />
19
- </div>
20
- <div class="ui-kpi__body">
21
- <span v-if="card.value === null" class="ui-kpi__skeleton" />
22
- <div v-else class="ui-kpi__value" :class="card.tone && `ui-kpi__value--${card.tone}`">
23
- {{ card.value }}<span v-if="card.note" class="ui-kpi__note"><span class="ui-kpi__note-dot">·</span>{{ card.note }}</span>
24
- </div>
25
- <div class="ui-kpi__label">
26
- {{ card.label }}
27
- <!-- Для позначок біля підпису (напр. «комісія попередня»). -->
28
- <slot name="suffix" :card="card" />
29
- </div>
30
- </div>
31
- </article>
32
- </section>
33
- </template>
34
-
35
- <style scoped lang="scss">
36
- .ui-kpi {
37
- display: grid;
38
- // auto-fit + minmax = рівно стільки колонок, скільки влазить. Медіазапити
39
- // під кожну кількість карток не потрібні.
40
- grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
41
- gap: 8px;
42
-
43
- &__card {
44
- display: flex;
45
- align-items: center;
46
- gap: 10px;
47
- padding: 10px 12px;
48
- background: $color-surface;
49
- border: 1px solid $color-border;
50
- border-radius: 10px;
51
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
52
- }
53
-
54
- &__icon {
55
- width: 32px;
56
- height: 32px;
57
- display: inline-flex;
58
- align-items: center;
59
- justify-content: center;
60
- border-radius: 8px;
61
- background: $color-accent-dim;
62
- color: $color-accent-ink;
63
- flex-shrink: 0;
64
-
65
- &--positive { background: rgba($color-green, 0.12); color: $color-green-ink; }
66
- &--negative { background: rgba($color-danger, 0.12); color: $color-danger; }
67
- &--muted { background: $color-page-bg; color: $color-muted; }
68
- }
69
-
70
- &__body {
71
- display: flex;
72
- flex-direction: column;
73
- gap: 2px;
74
- min-width: 0;
75
- }
76
-
77
- &__value {
78
- font-size: 16px;
79
- font-weight: 700;
80
- color: $color-text;
81
- line-height: 1.15;
82
- font-variant-numeric: tabular-nums;
83
- white-space: nowrap;
84
- overflow: hidden;
85
- text-overflow: ellipsis;
86
-
87
- &--positive { color: $color-green-ink; }
88
- &--negative { color: $color-danger; }
89
- &--muted { color: $color-muted; }
90
- }
91
-
92
- // Приписка (частка): помітно дрібніша за число, звичайного кольору. Крапка з
93
- // повітрям з обох боків, щоб не злипалося з числом.
94
- &__note {
95
- font-size: 0.8em;
96
- font-weight: 600;
97
- }
98
-
99
- &__note-dot {
100
- margin: 0 6px 0 7px;
101
- color: $color-muted;
102
- }
103
-
104
- &__label {
105
- display: inline-flex;
106
- align-items: center;
107
- gap: 4px;
108
- font-size: 11px;
109
- color: $color-muted;
110
- }
111
-
112
- &__skeleton {
113
- width: 70px;
114
- height: 16px;
115
- border-radius: 4px;
116
- background: linear-gradient(90deg, $color-border 0%, $color-page-bg 50%, $color-border 100%);
117
- background-size: 200% 100%;
118
- animation: ui-kpi-shimmer 1.4s linear infinite;
119
- }
120
-
121
- &--lg {
122
- grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
123
- gap: 12px;
124
-
125
- .ui-kpi__card { gap: 12px; padding: 14px 16px; border-radius: 12px; }
126
- .ui-kpi__icon { width: 36px; height: 36px; border-radius: 10px; }
127
- .ui-kpi__body { gap: 4px; }
128
- .ui-kpi__value { font-size: 22px; line-height: 1.1; }
129
- .ui-kpi__label { font-size: 12px; }
130
- .ui-kpi__skeleton { width: 72px; height: 22px; border-radius: 6px; }
131
- }
132
- }
133
-
134
- @keyframes ui-kpi-shimmer {
135
- from { background-position: 200% 0; }
136
- to { background-position: -200% 0; }
137
- }
138
-
139
- @media (prefers-reduced-motion: reduce) {
140
- .ui-kpi__skeleton { animation: none; }
141
- }
142
- </style>
1
+ <script setup lang="ts">
2
+ // Ряд KPI-плашок над таблицею. Що показувати — вирішує фіча (своя computed
3
+ // cards), кіт відповідає лише за вигляд і скелетон.
4
+
5
+ import type { UiKpiCardItem } from './uiKpi.types'
6
+
7
+ withDefaults(defineProps<{
8
+ cards: UiKpiCardItem[]
9
+ /** lg — коли карток 3–4 і є місце на великі цифри; md — коли їх багато. */
10
+ size?: 'md' | 'lg'
11
+ }>(), { size: 'md' })
12
+ </script>
13
+
14
+ <template>
15
+ <section class="ui-kpi" :class="`ui-kpi--${size}`">
16
+ <article v-for="card in cards" :key="card.key" class="ui-kpi__card">
17
+ <div class="ui-kpi__icon" :class="card.tone && `ui-kpi__icon--${card.tone}`">
18
+ <component :is="card.icon" :size="18" />
19
+ </div>
20
+ <div class="ui-kpi__body">
21
+ <span v-if="card.value === null" class="ui-kpi__skeleton" />
22
+ <div v-else class="ui-kpi__value" :class="card.tone && `ui-kpi__value--${card.tone}`">
23
+ {{ card.value }}<span v-if="card.note" class="ui-kpi__note"><span class="ui-kpi__note-dot">·</span>{{ card.note }}</span>
24
+ </div>
25
+ <div class="ui-kpi__label" :title="card.labelHint">
26
+ {{ card.label }}
27
+ <!-- Для позначок біля підпису (напр. «комісія попередня»). -->
28
+ <slot name="suffix" :card="card" />
29
+ </div>
30
+ </div>
31
+ </article>
32
+ </section>
33
+ </template>
34
+
35
+ <style scoped lang="scss">
36
+ .ui-kpi {
37
+ display: grid;
38
+ // auto-fit + minmax = рівно стільки колонок, скільки влазить. Медіазапити
39
+ // під кожну кількість карток не потрібні.
40
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
41
+ gap: 8px;
42
+
43
+ &__card {
44
+ display: flex;
45
+ align-items: center;
46
+ gap: 10px;
47
+ padding: 10px 12px;
48
+ background: $color-surface;
49
+ border: 1px solid $color-border;
50
+ border-radius: 10px;
51
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
52
+ }
53
+
54
+ &__icon {
55
+ width: 32px;
56
+ height: 32px;
57
+ display: inline-flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ border-radius: 8px;
61
+ background: $color-accent-dim;
62
+ color: $color-accent-ink;
63
+ flex-shrink: 0;
64
+
65
+ &--positive { background: rgba($color-green, 0.12); color: $color-green-ink; }
66
+ &--negative { background: rgba($color-danger, 0.12); color: $color-danger; }
67
+ &--muted { background: $color-page-bg; color: $color-muted; }
68
+ }
69
+
70
+ &__body {
71
+ // Довгий підпис переноситься, а числа сусідніх карток лишаються в одну лінію.
72
+ align-self: flex-start;
73
+ display: flex;
74
+ flex-direction: column;
75
+ gap: 2px;
76
+ min-width: 0;
77
+ }
78
+
79
+ &__value {
80
+ font-size: 16px;
81
+ font-weight: 700;
82
+ color: $color-text;
83
+ line-height: 1.15;
84
+ font-variant-numeric: tabular-nums;
85
+ white-space: nowrap;
86
+ overflow: hidden;
87
+ text-overflow: ellipsis;
88
+
89
+ &--positive { color: $color-green-ink; }
90
+ &--negative { color: $color-danger; }
91
+ &--muted { color: $color-muted; }
92
+ }
93
+
94
+ // Приписка (частка): помітно дрібніша за число, звичайного кольору. Крапка з
95
+ // повітрям з обох боків, щоб не злипалося з числом.
96
+ &__note {
97
+ font-size: 0.8em;
98
+ font-weight: 600;
99
+ }
100
+
101
+ &__note-dot {
102
+ margin: 0 6px 0 7px;
103
+ color: $color-muted;
104
+ }
105
+
106
+ &__label {
107
+ display: inline-flex;
108
+ align-items: center;
109
+ gap: 4px;
110
+ font-size: 11px;
111
+ color: $color-muted;
112
+ }
113
+
114
+ &__skeleton {
115
+ width: 70px;
116
+ height: 16px;
117
+ border-radius: 4px;
118
+ background: linear-gradient(90deg, $color-border 0%, $color-page-bg 50%, $color-border 100%);
119
+ background-size: 200% 100%;
120
+ animation: ui-kpi-shimmer 1.4s linear infinite;
121
+ }
122
+
123
+ &--lg {
124
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
125
+ gap: 12px;
126
+
127
+ .ui-kpi__card { gap: 12px; padding: 14px 16px; border-radius: 12px; }
128
+ .ui-kpi__icon { width: 36px; height: 36px; border-radius: 10px; }
129
+ .ui-kpi__body { gap: 4px; }
130
+ .ui-kpi__value { font-size: 22px; line-height: 1.1; }
131
+ .ui-kpi__label { font-size: 12px; }
132
+ .ui-kpi__skeleton { width: 72px; height: 22px; border-radius: 6px; }
133
+ }
134
+ }
135
+
136
+ @keyframes ui-kpi-shimmer {
137
+ from { background-position: 200% 0; }
138
+ to { background-position: -200% 0; }
139
+ }
140
+
141
+ @media (prefers-reduced-motion: reduce) {
142
+ .ui-kpi__skeleton { animation: none; }
143
+ }
144
+ </style>
@@ -1,62 +1,62 @@
1
- <script setup lang="ts">
2
- // Поповер кита: тригер + панель. Каркас reka-ui (фокус-трап, Esc, клік повз,
3
- // позиціювання) — свій велосипед тут завжди недоробить a11y.
4
- //
5
- // Тригер віддаємо слотом, а не пропами: кнопкою бувають і UiButton, і чип, і
6
- // іконка, і перелічити їх пропами означало б переписувати компонент під кожен
7
- // новий випадок.
8
-
9
- import { PopoverArrow, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
10
-
11
- withDefaults(defineProps<{
12
- align?: 'start' | 'center' | 'end'
13
- side?: 'top' | 'right' | 'bottom' | 'left'
14
- /** Ширина панелі; не задано — по вмісту. */
15
- width?: number
16
- isArrow?: boolean
17
- }>(), {
18
- align: 'end',
19
- side: 'bottom',
20
- })
21
-
22
- // Відкритість назовні: батьківському тригеру часто треба підсвітитись, поки
23
- // панель відкрита (як у DateRangeField).
24
- const isOpen = defineModel<boolean>('open', { default: false })
25
- </script>
26
-
27
- <template>
28
- <PopoverRoot v-model:open="isOpen">
29
- <PopoverTrigger as-child>
30
- <slot name="trigger" :is-open="isOpen" />
31
- </PopoverTrigger>
32
-
33
- <PopoverPortal>
34
- <PopoverContent
35
- class="ui-pop"
36
- :align="align"
37
- :side="side"
38
- :side-offset="6"
39
- :style="width ? { width: `${width}px` } : undefined"
40
- >
41
- <PopoverArrow v-if="isArrow" class="ui-pop__arrow" />
42
- <slot :close="() => { isOpen = false }" />
43
- </PopoverContent>
44
- </PopoverPortal>
45
- </PopoverRoot>
46
- </template>
47
-
48
- <!-- Не scoped: корінь телепортованого контенту scope-атрибута не отримує
49
- (див. resources/js/CLAUDE.md §9), і фон із тінню просто не застосувались би. -->
50
- <style lang="scss">
51
- .ui-pop {
52
- z-index: 1000;
53
- background: $color-surface;
54
- border: 1px solid $color-border;
55
- border-radius: 12px;
56
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
57
-
58
- &__arrow {
59
- fill: $color-surface;
60
- }
61
- }
62
- </style>
1
+ <script setup lang="ts">
2
+ // Поповер кита: тригер + панель. Каркас reka-ui (фокус-трап, Esc, клік повз,
3
+ // позиціювання) — свій велосипед тут завжди недоробить a11y.
4
+ //
5
+ // Тригер віддаємо слотом, а не пропами: кнопкою бувають і UiButton, і чип, і
6
+ // іконка, і перелічити їх пропами означало б переписувати компонент під кожен
7
+ // новий випадок.
8
+
9
+ import { PopoverArrow, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
10
+
11
+ withDefaults(defineProps<{
12
+ align?: 'start' | 'center' | 'end'
13
+ side?: 'top' | 'right' | 'bottom' | 'left'
14
+ /** Ширина панелі; не задано — по вмісту. */
15
+ width?: number
16
+ isArrow?: boolean
17
+ }>(), {
18
+ align: 'end',
19
+ side: 'bottom',
20
+ })
21
+
22
+ // Відкритість назовні: батьківському тригеру часто треба підсвітитись, поки
23
+ // панель відкрита (як у DateRangeField).
24
+ const isOpen = defineModel<boolean>('open', { default: false })
25
+ </script>
26
+
27
+ <template>
28
+ <PopoverRoot v-model:open="isOpen">
29
+ <PopoverTrigger as-child>
30
+ <slot name="trigger" :is-open="isOpen" />
31
+ </PopoverTrigger>
32
+
33
+ <PopoverPortal>
34
+ <PopoverContent
35
+ class="ui-pop"
36
+ :align="align"
37
+ :side="side"
38
+ :side-offset="6"
39
+ :style="width ? { width: `${width}px` } : undefined"
40
+ >
41
+ <PopoverArrow v-if="isArrow" class="ui-pop__arrow" />
42
+ <slot :close="() => { isOpen = false }" />
43
+ </PopoverContent>
44
+ </PopoverPortal>
45
+ </PopoverRoot>
46
+ </template>
47
+
48
+ <!-- Не scoped: корінь телепортованого контенту scope-атрибута не отримує
49
+ (див. resources/js/CLAUDE.md §9), і фон із тінню просто не застосувались би. -->
50
+ <style lang="scss">
51
+ .ui-pop {
52
+ z-index: 1000;
53
+ background: $color-surface;
54
+ border: 1px solid $color-border;
55
+ border-radius: 12px;
56
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
57
+
58
+ &__arrow {
59
+ fill: $color-surface;
60
+ }
61
+ }
62
+ </style>
@@ -1,102 +1,102 @@
1
- <script setup lang="ts">
2
- // Поле фільтра: іконка + інпут без власної рамки в спільній пігулці.
3
- // Виглядає як FilterSelect поруч — інакше поле випадає з ряду фільтрів.
4
- //
5
- // Ширину задає батько класом на компоненті (`flex`/`min-width`/`max-width`):
6
- // це питання розкладки конкретного ряду, а не самого поля.
7
- //
8
- // Хрестик чистить поле одним кліком — лише коли є що чистити.
9
-
10
- import { SharedConfig } from '../../config'
11
- import { Search, X } from '@lucide/vue'
12
- import type { Component } from 'vue'
13
-
14
- withDefaults(defineProps<{
15
- modelValue: string
16
- placeholder: string
17
- icon?: Component
18
- /** Номер/код: моноширина й капс — символи рівняються і не плутаються. */
19
- isCode?: boolean
20
- }>(), {
21
- icon: () => Search,
22
- isCode: false,
23
- })
24
-
25
- const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
26
- </script>
27
-
28
- <template>
29
- <label class="ui-search">
30
- <component :is="icon" :size="14" />
31
- <input
32
- :value="modelValue"
33
- type="text"
34
- class="ui-search__input"
35
- :class="{ 'ui-search__input--code': isCode }"
36
- :placeholder="placeholder"
37
- @input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
38
- />
39
- <!-- type=button і .prevent: усередині <label> клік інакше пішов би в поле. -->
40
- <button
41
- v-if="modelValue"
42
- type="button"
43
- class="ui-search__clear"
44
- :title="SharedConfig.get().labels.clear"
45
- :aria-label="SharedConfig.get().labels.clearSearch"
46
- @click.prevent="emit('update:modelValue', '')"
47
- >
48
- <X :size="13" />
49
- </button>
50
- </label>
51
- </template>
52
-
53
- <style scoped lang="scss">
54
- .ui-search {
55
- display: inline-flex;
56
- align-items: center;
57
- gap: 6px;
58
- padding: 6px 10px;
59
- background: $color-page-bg;
60
- border: 1px solid $color-border;
61
- border-radius: 8px;
62
- color: $color-muted;
63
-
64
- &__input {
65
- flex: 1;
66
- min-width: 0;
67
- border: none;
68
- outline: none;
69
- background: transparent;
70
- font-size: 13px;
71
- color: $color-text;
72
-
73
- &--code {
74
- font-variant-numeric: tabular-nums;
75
- letter-spacing: 0.04em;
76
- text-transform: uppercase;
77
-
78
- // Підказка — людський текст, її капсити не треба.
79
- &::placeholder {
80
- text-transform: none;
81
- letter-spacing: 0;
82
- }
83
- }
84
- }
85
-
86
- &__clear {
87
- display: inline-flex;
88
- flex-shrink: 0;
89
- padding: 2px;
90
- border: none;
91
- border-radius: 4px;
92
- background: transparent;
93
- color: $color-muted;
94
- cursor: pointer;
95
-
96
- &:hover {
97
- color: $color-text;
98
- background: $color-border;
99
- }
100
- }
101
- }
102
- </style>
1
+ <script setup lang="ts">
2
+ // Поле фільтра: іконка + інпут без власної рамки в спільній пігулці.
3
+ // Виглядає як FilterSelect поруч — інакше поле випадає з ряду фільтрів.
4
+ //
5
+ // Ширину задає батько класом на компоненті (`flex`/`min-width`/`max-width`):
6
+ // це питання розкладки конкретного ряду, а не самого поля.
7
+ //
8
+ // Хрестик чистить поле одним кліком — лише коли є що чистити.
9
+
10
+ import { SharedConfig } from '../../config'
11
+ import { Search, X } from '@lucide/vue'
12
+ import type { Component } from 'vue'
13
+
14
+ withDefaults(defineProps<{
15
+ modelValue: string
16
+ placeholder: string
17
+ icon?: Component
18
+ /** Номер/код: моноширина й капс — символи рівняються і не плутаються. */
19
+ isCode?: boolean
20
+ }>(), {
21
+ icon: () => Search,
22
+ isCode: false,
23
+ })
24
+
25
+ const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
26
+ </script>
27
+
28
+ <template>
29
+ <label class="ui-search">
30
+ <component :is="icon" :size="14" />
31
+ <input
32
+ :value="modelValue"
33
+ type="text"
34
+ class="ui-search__input"
35
+ :class="{ 'ui-search__input--code': isCode }"
36
+ :placeholder="placeholder"
37
+ @input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
38
+ />
39
+ <!-- type=button і .prevent: усередині <label> клік інакше пішов би в поле. -->
40
+ <button
41
+ v-if="modelValue"
42
+ type="button"
43
+ class="ui-search__clear"
44
+ :title="SharedConfig.get().labels.clear"
45
+ :aria-label="SharedConfig.get().labels.clearSearch"
46
+ @click.prevent="emit('update:modelValue', '')"
47
+ >
48
+ <X :size="13" />
49
+ </button>
50
+ </label>
51
+ </template>
52
+
53
+ <style scoped lang="scss">
54
+ .ui-search {
55
+ display: inline-flex;
56
+ align-items: center;
57
+ gap: 6px;
58
+ padding: 6px 10px;
59
+ background: $color-page-bg;
60
+ border: 1px solid $color-border;
61
+ border-radius: 8px;
62
+ color: $color-muted;
63
+
64
+ &__input {
65
+ flex: 1;
66
+ min-width: 0;
67
+ border: none;
68
+ outline: none;
69
+ background: transparent;
70
+ font-size: 13px;
71
+ color: $color-text;
72
+
73
+ &--code {
74
+ font-variant-numeric: tabular-nums;
75
+ letter-spacing: 0.04em;
76
+ text-transform: uppercase;
77
+
78
+ // Підказка — людський текст, її капсити не треба.
79
+ &::placeholder {
80
+ text-transform: none;
81
+ letter-spacing: 0;
82
+ }
83
+ }
84
+ }
85
+
86
+ &__clear {
87
+ display: inline-flex;
88
+ flex-shrink: 0;
89
+ padding: 2px;
90
+ border: none;
91
+ border-radius: 4px;
92
+ background: transparent;
93
+ color: $color-muted;
94
+ cursor: pointer;
95
+
96
+ &:hover {
97
+ color: $color-text;
98
+ background: $color-border;
99
+ }
100
+ }
101
+ }
102
+ </style>