@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,126 +1,126 @@
1
- <script setup lang="ts">
2
- // Кнопка застосунку: форми, модалки, фільтри, тулбари.
3
- //
4
- // href або to → посилання (компонент дає проєкт: SharedConfig.link), але на вигляд та сама кнопка: «Скасувати» поруч зі
5
- // «Зберегти» не має відрізнятись лише тому, що одне з них навігація.
6
-
7
- import { Loader2 } from '@lucide/vue'
8
- import { computed } from 'vue'
9
- import { SharedConfig } from '../../config'
10
-
11
- const props = withDefaults(defineProps<{
12
- // secondary — дефолт (звичайна дія); primary — головна в блоці;
13
- // ghost — відмова/закриття; danger — руйнівна (видалити).
14
- // Свій варіант проєкту (`ui-btn--violet`) — рядком, стилі глобально в проєкті.
15
- variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | (string & {})
16
- // xs — дії всередині рядка таблиці, де кнопка не має розпирати рядок.
17
- size?: 'xs' | 'sm' | 'md'
18
- href?: string
19
- to?: string | object
20
- type?: 'button' | 'submit'
21
- disabled?: boolean
22
- // Спінер + блокування: щоб не надіслати запит двічі.
23
- isLoading?: boolean
24
- }>(), {
25
- variant: 'secondary',
26
- size: 'md',
27
- type: 'button',
28
- })
29
-
30
- const isDisabled = computed(() => props.disabled || props.isLoading)
31
-
32
- const target = computed(() => props.to ?? props.href)
33
- const link = SharedConfig.get().link
34
- </script>
35
-
36
- <template>
37
- <!-- Один корінь (а не v-if/v-else двома тегами): інакше це фрагмент, і
38
- class/@click, навішані ззовні, не потрапляють на елемент. -->
39
- <component
40
- :is="target ? link.component : 'button'"
41
- v-bind="target ? { [link.prop]: target } : { type, disabled: isDisabled }"
42
- class="ui-btn"
43
- :class="[`ui-btn--${variant}`, `ui-btn--${size}`]"
44
- >
45
- <Loader2 v-if="isLoading" :size="15" class="ui-btn__spinner" />
46
- <slot />
47
- </component>
48
- </template>
49
-
50
- <style scoped lang="scss">
51
- @use 'sass:color';
52
-
53
- .ui-btn {
54
- display: inline-flex;
55
- align-items: center;
56
- justify-content: center;
57
- gap: 6px;
58
- border: 1px solid $color-border;
59
- border-radius: $radius;
60
- background: $color-surface;
61
- color: $color-text;
62
- font-size: 13px;
63
- font-weight: 600;
64
- line-height: 1;
65
- white-space: nowrap;
66
- text-decoration: none;
67
- cursor: pointer;
68
- transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
69
-
70
- // 36px — нижче межі 44px для пальця, тож на тач-екранах розширюємо саму
71
- // кнопку, а не тільки її вигляд.
72
- &--md { height: 36px; padding: 0 16px; }
73
- &--sm { height: 32px; padding: 0 12px; font-size: 12px; }
74
- &--xs { height: 24px; padding: 0 10px; font-size: 12px; font-weight: 400; gap: 4px; }
75
-
76
- @media (hover: none) {
77
- &--md { height: 44px; }
78
- &--sm { height: 40px; }
79
- &--xs { height: 32px; }
80
- }
81
-
82
- &--secondary:hover:not(:disabled) {
83
- background: $color-page-bg;
84
- border-color: color.adjust($color-border, $lightness: -6%);
85
- }
86
-
87
- // Вигляд головної кнопки — бренд проєкту: міксин `buttonPrimary` у контракті.
88
- &--primary { @include buttonPrimary; }
89
-
90
- // Ghost — вторинна (Скасувати / Закрити): прозоріша за дефолт.
91
- &--ghost {
92
- border-color: transparent;
93
- background: transparent;
94
- color: $color-muted;
95
-
96
- &:hover:not(:disabled) { background: $color-page-bg; color: $color-text; }
97
- }
98
-
99
- // Danger — руйнівна дія. Мʼякий червоний, а не заливка: кнопка «Видалити»
100
- // стоїть у футері поруч зі «Скасувати» і не має перетягувати увагу.
101
- &--danger {
102
- background: rgba($color-danger, 0.06);
103
- border-color: rgba($color-danger, 0.25);
104
- color: $color-danger;
105
-
106
- &:hover:not(:disabled) {
107
- background: rgba($color-danger, 0.12);
108
- border-color: rgba($color-danger, 0.4);
109
- }
110
- }
111
-
112
- &:disabled { opacity: 0.55; cursor: not-allowed; }
113
-
114
- &__spinner { animation: ui-btn-spin 0.9s linear infinite; }
115
- }
116
-
117
- @keyframes ui-btn-spin {
118
- to { transform: rotate(360deg); }
119
- }
120
-
121
- // Спінер — єдина анімація тут, і вона несе сенс («йде запит»). Але для тих,
122
- // хто просив прибрати рух, лишаємо статичну іконку.
123
- @media (prefers-reduced-motion: reduce) {
124
- .ui-btn__spinner { animation: none; }
125
- }
126
- </style>
1
+ <script setup lang="ts">
2
+ // Кнопка застосунку: форми, модалки, фільтри, тулбари.
3
+ //
4
+ // href або to → посилання (компонент дає проєкт: SharedConfig.link), але на вигляд та сама кнопка: «Скасувати» поруч зі
5
+ // «Зберегти» не має відрізнятись лише тому, що одне з них навігація.
6
+
7
+ import { Loader2 } from '@lucide/vue'
8
+ import { computed } from 'vue'
9
+ import { SharedConfig } from '../../config'
10
+
11
+ const props = withDefaults(defineProps<{
12
+ // secondary — дефолт (звичайна дія); primary — головна в блоці;
13
+ // ghost — відмова/закриття; danger — руйнівна (видалити).
14
+ // Свій варіант проєкту (`ui-btn--violet`) — рядком, стилі глобально в проєкті.
15
+ variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | (string & {})
16
+ // xs — дії всередині рядка таблиці, де кнопка не має розпирати рядок.
17
+ size?: 'xs' | 'sm' | 'md'
18
+ href?: string
19
+ to?: string | object
20
+ type?: 'button' | 'submit'
21
+ disabled?: boolean
22
+ // Спінер + блокування: щоб не надіслати запит двічі.
23
+ isLoading?: boolean
24
+ }>(), {
25
+ variant: 'secondary',
26
+ size: 'md',
27
+ type: 'button',
28
+ })
29
+
30
+ const isDisabled = computed(() => props.disabled || props.isLoading)
31
+
32
+ const target = computed(() => props.to ?? props.href)
33
+ const link = SharedConfig.get().link
34
+ </script>
35
+
36
+ <template>
37
+ <!-- Один корінь (а не v-if/v-else двома тегами): інакше це фрагмент, і
38
+ class/@click, навішані ззовні, не потрапляють на елемент. -->
39
+ <component
40
+ :is="target ? link.component : 'button'"
41
+ v-bind="target ? { [link.prop]: target } : { type, disabled: isDisabled }"
42
+ class="ui-btn"
43
+ :class="[`ui-btn--${variant}`, `ui-btn--${size}`]"
44
+ >
45
+ <Loader2 v-if="isLoading" :size="15" class="ui-btn__spinner" />
46
+ <slot />
47
+ </component>
48
+ </template>
49
+
50
+ <style scoped lang="scss">
51
+ @use 'sass:color';
52
+
53
+ .ui-btn {
54
+ display: inline-flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ gap: 6px;
58
+ border: 1px solid $color-border;
59
+ border-radius: $radius;
60
+ background: $color-surface;
61
+ color: $color-text;
62
+ font-size: 13px;
63
+ font-weight: 600;
64
+ line-height: 1;
65
+ white-space: nowrap;
66
+ text-decoration: none;
67
+ cursor: pointer;
68
+ transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
69
+
70
+ // 36px — нижче межі 44px для пальця, тож на тач-екранах розширюємо саму
71
+ // кнопку, а не тільки її вигляд.
72
+ &--md { height: 36px; padding: 0 16px; }
73
+ &--sm { height: 32px; padding: 0 12px; font-size: 12px; }
74
+ &--xs { height: 24px; padding: 0 10px; font-size: 12px; font-weight: 400; gap: 4px; }
75
+
76
+ @media (hover: none) {
77
+ &--md { height: 44px; }
78
+ &--sm { height: 40px; }
79
+ &--xs { height: 32px; }
80
+ }
81
+
82
+ &--secondary:hover:not(:disabled) {
83
+ background: $color-page-bg;
84
+ border-color: color.adjust($color-border, $lightness: -6%);
85
+ }
86
+
87
+ // Вигляд головної кнопки — бренд проєкту: міксин `buttonPrimary` у контракті.
88
+ &--primary { @include buttonPrimary; }
89
+
90
+ // Ghost — вторинна (Скасувати / Закрити): прозоріша за дефолт.
91
+ &--ghost {
92
+ border-color: transparent;
93
+ background: transparent;
94
+ color: $color-muted;
95
+
96
+ &:hover:not(:disabled) { background: $color-page-bg; color: $color-text; }
97
+ }
98
+
99
+ // Danger — руйнівна дія. Мʼякий червоний, а не заливка: кнопка «Видалити»
100
+ // стоїть у футері поруч зі «Скасувати» і не має перетягувати увагу.
101
+ &--danger {
102
+ background: rgba($color-danger, 0.06);
103
+ border-color: rgba($color-danger, 0.25);
104
+ color: $color-danger;
105
+
106
+ &:hover:not(:disabled) {
107
+ background: rgba($color-danger, 0.12);
108
+ border-color: rgba($color-danger, 0.4);
109
+ }
110
+ }
111
+
112
+ &:disabled { opacity: 0.55; cursor: not-allowed; }
113
+
114
+ &__spinner { animation: ui-btn-spin 0.9s linear infinite; }
115
+ }
116
+
117
+ @keyframes ui-btn-spin {
118
+ to { transform: rotate(360deg); }
119
+ }
120
+
121
+ // Спінер — єдина анімація тут, і вона несе сенс («йде запит»). Але для тих,
122
+ // хто просив прибрати рух, лишаємо статичну іконку.
123
+ @media (prefers-reduced-motion: reduce) {
124
+ .ui-btn__spinner { animation: none; }
125
+ }
126
+ </style>
@@ -1,88 +1,88 @@
1
- <script setup lang="ts">
2
- // Картка-секція: рамка, заголовок з іконкою й лічильником, місце під дію
3
- // праворуч і порожній стан.
4
- //
5
- // Та сама розмітка з тими самими 25 рядками SCSS була скопійована в пʼяти
6
- // картках картки водія — зміна відступу вимагала обходу всіх пʼяти, і вони
7
- // вже почали розходитись (десь був icon у заголовку, десь ні).
8
-
9
- import type { Component } from 'vue'
10
- import UiCount from './UiCount.vue'
11
-
12
- withDefaults(defineProps<{
13
- title: string
14
- icon?: Component
15
- /** Лічильник біля заголовка. 0 не малюємо — «нуль» каже порожній стан. */
16
- count?: number
17
- isEmpty?: boolean
18
- emptyText?: string
19
- /** Прибрати падінги вмісту — коли всередині своя сітка на всю ширину. */
20
- isFlush?: boolean
21
- }>(), { isEmpty: false, isFlush: false })
22
- </script>
23
-
24
- <template>
25
- <section class="ui-card">
26
- <h2 class="ui-card__title">
27
- <component :is="icon" v-if="icon" :size="15" />
28
- {{ title }}
29
- <UiCount v-if="count" :value="count" />
30
-
31
- <span class="ui-card__action"><slot name="action" /></span>
32
- </h2>
33
-
34
- <p v-if="isEmpty" class="ui-card__empty">{{ emptyText }}</p>
35
- <div v-else class="ui-card__body" :class="{ 'ui-card__body--flush': isFlush }">
36
- <slot />
37
- </div>
38
- </section>
39
- </template>
40
-
41
- <style scoped lang="scss">
42
- .ui-card {
43
- display: flex;
44
- flex-direction: column;
45
- gap: 12px;
46
- padding: 16px;
47
- background: $color-surface;
48
- border: 1px solid $color-border;
49
- border-radius: 12px;
50
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
51
-
52
- &__title {
53
- display: flex;
54
- align-items: center;
55
- gap: 8px;
56
- font-size: 12px;
57
- font-weight: 600;
58
- text-transform: uppercase;
59
- letter-spacing: 0.06em;
60
- color: $color-muted;
61
- }
62
-
63
- // Дія притиснута до правого краю заголовка. Порожній span нічого не займає,
64
- // тому окремий v-if не потрібен.
65
- &__action {
66
- display: inline-flex;
67
- align-items: center;
68
- gap: 6px;
69
- margin-left: auto;
70
- }
71
-
72
- &__body {
73
- display: flex;
74
- flex-direction: column;
75
- gap: 12px;
76
- min-width: 0;
77
-
78
- &--flush { gap: 0; }
79
- }
80
-
81
- &__empty {
82
- margin: 0;
83
- padding: 4px 0;
84
- font-size: 13px;
85
- color: $color-muted;
86
- }
87
- }
88
- </style>
1
+ <script setup lang="ts">
2
+ // Картка-секція: рамка, заголовок з іконкою й лічильником, місце під дію
3
+ // праворуч і порожній стан.
4
+ //
5
+ // Та сама розмітка з тими самими 25 рядками SCSS була скопійована в пʼяти
6
+ // картках картки водія — зміна відступу вимагала обходу всіх пʼяти, і вони
7
+ // вже почали розходитись (десь був icon у заголовку, десь ні).
8
+
9
+ import type { Component } from 'vue'
10
+ import UiCount from './UiCount.vue'
11
+
12
+ withDefaults(defineProps<{
13
+ title: string
14
+ icon?: Component
15
+ /** Лічильник біля заголовка. 0 не малюємо — «нуль» каже порожній стан. */
16
+ count?: number
17
+ isEmpty?: boolean
18
+ emptyText?: string
19
+ /** Прибрати падінги вмісту — коли всередині своя сітка на всю ширину. */
20
+ isFlush?: boolean
21
+ }>(), { isEmpty: false, isFlush: false })
22
+ </script>
23
+
24
+ <template>
25
+ <section class="ui-card">
26
+ <h2 class="ui-card__title">
27
+ <component :is="icon" v-if="icon" :size="15" />
28
+ {{ title }}
29
+ <UiCount v-if="count" :value="count" />
30
+
31
+ <span class="ui-card__action"><slot name="action" /></span>
32
+ </h2>
33
+
34
+ <p v-if="isEmpty" class="ui-card__empty">{{ emptyText }}</p>
35
+ <div v-else class="ui-card__body" :class="{ 'ui-card__body--flush': isFlush }">
36
+ <slot />
37
+ </div>
38
+ </section>
39
+ </template>
40
+
41
+ <style scoped lang="scss">
42
+ .ui-card {
43
+ display: flex;
44
+ flex-direction: column;
45
+ gap: 12px;
46
+ padding: 16px;
47
+ background: $color-surface;
48
+ border: 1px solid $color-border;
49
+ border-radius: 12px;
50
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
51
+
52
+ &__title {
53
+ display: flex;
54
+ align-items: center;
55
+ gap: 8px;
56
+ font-size: 12px;
57
+ font-weight: 600;
58
+ text-transform: uppercase;
59
+ letter-spacing: 0.06em;
60
+ color: $color-muted;
61
+ }
62
+
63
+ // Дія притиснута до правого краю заголовка. Порожній span нічого не займає,
64
+ // тому окремий v-if не потрібен.
65
+ &__action {
66
+ display: inline-flex;
67
+ align-items: center;
68
+ gap: 6px;
69
+ margin-left: auto;
70
+ }
71
+
72
+ &__body {
73
+ display: flex;
74
+ flex-direction: column;
75
+ gap: 12px;
76
+ min-width: 0;
77
+
78
+ &--flush { gap: 0; }
79
+ }
80
+
81
+ &__empty {
82
+ margin: 0;
83
+ padding: 4px 0;
84
+ font-size: 13px;
85
+ color: $color-muted;
86
+ }
87
+ }
88
+ </style>
@@ -1,35 +1,35 @@
1
- <script setup lang="ts">
2
- // Лічильник біля заголовка секції або вкладки («Авто ⑶»). Не бейдж: несе
3
- // кількість, а не стан, тому без тонів — сірий кружечок з числом.
4
-
5
- withDefaults(defineProps<{
6
- value: number
7
- /** У вкладках число активне разом із текстом вкладки — тоді темніше. */
8
- isStrong?: boolean
9
- }>(), { isStrong: false })
10
- </script>
11
-
12
- <template>
13
- <span class="ui-count" :class="{ 'ui-count--strong': isStrong }">{{ value }}</span>
14
- </template>
15
-
16
- <style scoped lang="scss">
17
- .ui-count {
18
- display: inline-flex;
19
- align-items: center;
20
- justify-content: center;
21
- min-width: 20px;
22
- height: 20px;
23
- padding: 0 6px;
24
- border-radius: 999px;
25
- background: $color-page-bg;
26
- font-size: 11px;
27
- color: $color-muted;
28
-
29
- &--strong {
30
- height: 18px;
31
- color: inherit;
32
- font-weight: 600;
33
- }
34
- }
35
- </style>
1
+ <script setup lang="ts">
2
+ // Лічильник біля заголовка секції або вкладки («Авто ⑶»). Не бейдж: несе
3
+ // кількість, а не стан, тому без тонів — сірий кружечок з числом.
4
+
5
+ withDefaults(defineProps<{
6
+ value: number
7
+ /** У вкладках число активне разом із текстом вкладки — тоді темніше. */
8
+ isStrong?: boolean
9
+ }>(), { isStrong: false })
10
+ </script>
11
+
12
+ <template>
13
+ <span class="ui-count" :class="{ 'ui-count--strong': isStrong }">{{ value }}</span>
14
+ </template>
15
+
16
+ <style scoped lang="scss">
17
+ .ui-count {
18
+ display: inline-flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ min-width: 20px;
22
+ height: 20px;
23
+ padding: 0 6px;
24
+ border-radius: 999px;
25
+ background: $color-page-bg;
26
+ font-size: 11px;
27
+ color: $color-muted;
28
+
29
+ &--strong {
30
+ height: 18px;
31
+ color: inherit;
32
+ font-weight: 600;
33
+ }
34
+ }
35
+ </style>