adata-ui 2.1.40-beta → 2.1.40-beta.2
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.
- package/components/elements/a-select-row/ASelectRowV2.vue +213 -0
- package/components/elements/button/AButtonV2.vue +89 -0
- package/components/elements/segmented/ASegmentedV2.vue +58 -0
- package/components/elements/select/ASelectV2.vue +581 -0
- package/components/elements/show-more/AShowMoreV2.vue +26 -0
- package/components/features/pk-mobile-services/APkMobileServices.vue +5 -27
- package/components/forms/checkbox/ACheckboxV2.vue +229 -0
- package/components/forms/input/AInputV2.vue +542 -0
- package/components/forms/toggle/AToggleV2.vue +71 -0
- package/components/navigation/header/NavList.vue +28 -48
- package/components/navigation/header/ProductMenu.vue +16 -10
- package/components/navigation/pill-tabs/APillTabsV2.vue +118 -0
- package/components/overlays/modal/AModalV2.vue +388 -0
- package/composables/useActiveNavigation.ts +84 -0
- package/composables/useChipOverflow.ts +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
<script generic="T" lang="ts" setup>
|
|
2
|
+
import type { Placement } from '@floating-ui/vue'
|
|
3
|
+
import { autoUpdate, flip, size as floatingSize, offset, shift, useFloating } from '@floating-ui/vue'
|
|
4
|
+
import { onClickOutside, useToggle } from '@vueuse/core'
|
|
5
|
+
import { useChipOverflow } from '#adata-ui/composables/useChipOverflow'
|
|
6
|
+
|
|
7
|
+
import pkg from 'lodash'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
label: string
|
|
11
|
+
required?: boolean
|
|
12
|
+
options: T[]
|
|
13
|
+
hideOverflow?: boolean
|
|
14
|
+
keyToShow?: string
|
|
15
|
+
getOnlyKey?: boolean
|
|
16
|
+
keyToSelect?: string
|
|
17
|
+
clearable?: boolean
|
|
18
|
+
hasButtons?: boolean
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
size?: 'sm' | 'md'
|
|
21
|
+
error?: string | string[]
|
|
22
|
+
startIcon?: object
|
|
23
|
+
searchable?: boolean
|
|
24
|
+
searchLabel?: string
|
|
25
|
+
searchKey?: string | string[]
|
|
26
|
+
searchFromOut?: boolean
|
|
27
|
+
multiple?: boolean
|
|
28
|
+
minimalWords?: boolean
|
|
29
|
+
canChipRemove?: boolean
|
|
30
|
+
showFirstItem?: boolean
|
|
31
|
+
buttonBg?: string
|
|
32
|
+
dropdownAnchor?: HTMLElement | string | null
|
|
33
|
+
dropdownWidth?: number | string
|
|
34
|
+
dropdownMaxHeight?: number | string
|
|
35
|
+
dropdownAlign?: 'start' | 'center' | 'end'
|
|
36
|
+
changeableModelValue?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Emits {
|
|
40
|
+
(e: 'onChange', option?: T | T[]): void
|
|
41
|
+
(e: 'onSubmit', value?: T | T[]): void
|
|
42
|
+
(e: 'onClear'): void
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
46
|
+
required: false,
|
|
47
|
+
hideOverflow: false,
|
|
48
|
+
getOnlyKey: false,
|
|
49
|
+
keyToShow: 'name',
|
|
50
|
+
keyToSelect: 'id',
|
|
51
|
+
clearable: true,
|
|
52
|
+
hasButtons: false,
|
|
53
|
+
disabled: false,
|
|
54
|
+
size: 'sm',
|
|
55
|
+
error: undefined,
|
|
56
|
+
startIcon: undefined,
|
|
57
|
+
searchable: false,
|
|
58
|
+
searchLabel: 'Поиск...',
|
|
59
|
+
searchKey: 'name',
|
|
60
|
+
searchFromOut: false,
|
|
61
|
+
multiple: false,
|
|
62
|
+
minimalWords: false,
|
|
63
|
+
canChipRemove: true,
|
|
64
|
+
showFirstItem: false,
|
|
65
|
+
buttonBg: '',
|
|
66
|
+
dropdownAnchor: null,
|
|
67
|
+
dropdownWidth: undefined,
|
|
68
|
+
dropdownMaxHeight: undefined,
|
|
69
|
+
dropdownAlign: 'start',
|
|
70
|
+
changeableModelValue: false,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const emits = defineEmits<Emits>()
|
|
74
|
+
|
|
75
|
+
const modelValue = defineModel<T | T[] | null | any>({ required: true })
|
|
76
|
+
const search = defineModel<T | null | any>('search')
|
|
77
|
+
const isOpen = defineModel<boolean>('open', { default: false })
|
|
78
|
+
|
|
79
|
+
const { isEqual } = pkg
|
|
80
|
+
|
|
81
|
+
const reference = ref<HTMLElement | null>(null)
|
|
82
|
+
const floating = ref<HTMLElement | null>(null)
|
|
83
|
+
|
|
84
|
+
function toCssSize(v?: number | string): string | null {
|
|
85
|
+
if (v == null || v === '') return null
|
|
86
|
+
return typeof v === 'number' ? `${v}px` : v
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const anchorEl = computed<HTMLElement | null>(() => {
|
|
90
|
+
const a = props.dropdownAnchor
|
|
91
|
+
if (!a) return null
|
|
92
|
+
return typeof a === 'string' ? document.querySelector<HTMLElement>(a) : a
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const positionReference = computed(() => {
|
|
96
|
+
const trigger = reference.value
|
|
97
|
+
const anchor = anchorEl.value
|
|
98
|
+
if (!trigger || !anchor) return trigger
|
|
99
|
+
return {
|
|
100
|
+
contextElement: trigger,
|
|
101
|
+
getBoundingClientRect() {
|
|
102
|
+
const t = trigger.getBoundingClientRect()
|
|
103
|
+
const c = anchor.getBoundingClientRect()
|
|
104
|
+
return {
|
|
105
|
+
x: c.x,
|
|
106
|
+
y: t.y,
|
|
107
|
+
left: c.left,
|
|
108
|
+
right: c.right,
|
|
109
|
+
top: t.top,
|
|
110
|
+
bottom: t.bottom,
|
|
111
|
+
width: c.width,
|
|
112
|
+
height: t.height,
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const dropdownPlacement = computed<Placement>(() => {
|
|
119
|
+
if (props.dropdownAlign === 'center') return 'bottom'
|
|
120
|
+
if (props.dropdownAlign === 'end') return 'bottom-end'
|
|
121
|
+
return 'bottom-start'
|
|
122
|
+
})
|
|
123
|
+
const dropdownFallback = computed<Placement[]>(() => {
|
|
124
|
+
if (props.dropdownAlign === 'center') return ['top']
|
|
125
|
+
if (props.dropdownAlign === 'end') return ['top-end']
|
|
126
|
+
return ['top-start']
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const { x, y, strategy, update } = useFloating(positionReference, floating, {
|
|
130
|
+
placement: dropdownPlacement,
|
|
131
|
+
strategy: 'absolute',
|
|
132
|
+
middleware: computed(() => [
|
|
133
|
+
offset(6),
|
|
134
|
+
flip({ fallbackPlacements: dropdownFallback.value }),
|
|
135
|
+
shift({ padding: 8 }),
|
|
136
|
+
floatingSize({
|
|
137
|
+
apply({ availableHeight, elements, rects }) {
|
|
138
|
+
const el = elements.floating as HTMLElement
|
|
139
|
+
const widthOverride = toCssSize(props.dropdownWidth)
|
|
140
|
+
el.style.width = widthOverride ?? `${rects.reference.width}px`
|
|
141
|
+
const maxHeightOverride = toCssSize(props.dropdownMaxHeight)
|
|
142
|
+
el.style.maxHeight = maxHeightOverride
|
|
143
|
+
? `min(${maxHeightOverride}, ${availableHeight}px)`
|
|
144
|
+
: `${Math.max(140, Math.min(availableHeight, 320))}px`
|
|
145
|
+
el.style.overflowY = props.hideOverflow ? 'hidden' : 'auto'
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
]),
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
let cleanup: (() => void) | null = null
|
|
152
|
+
watch(isOpen, (open) => {
|
|
153
|
+
if (open && reference.value && floating.value) {
|
|
154
|
+
cleanup = autoUpdate(reference.value, floating.value, update)
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
cleanup?.()
|
|
158
|
+
cleanup = null
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
onUnmounted(() => cleanup?.())
|
|
162
|
+
|
|
163
|
+
const wrapper = ref<HTMLDivElement | null>(null)
|
|
164
|
+
const toggleOpen = useToggle(isOpen)
|
|
165
|
+
const searchValue = ref('')
|
|
166
|
+
|
|
167
|
+
onClickOutside(wrapper, () => {
|
|
168
|
+
if (isOpen.value) toggleOpen(false)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
watch(isOpen, (open) => {
|
|
172
|
+
if (!open) searchValue.value = ''
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
function findOptionByKey(key: unknown): T | null {
|
|
176
|
+
if (!props.getOnlyKey) return null
|
|
177
|
+
return props.options.find(opt => isEqual(opt[props.keyToSelect as keyof T], key)) ?? null
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const valueToShow = computed<T | T[] | null>(() => {
|
|
181
|
+
if (props.multiple) {
|
|
182
|
+
if (!Array.isArray(modelValue.value) || modelValue.value.length === 0) return null
|
|
183
|
+
if (props.getOnlyKey) {
|
|
184
|
+
const keys = modelValue.value as any[]
|
|
185
|
+
const found = props.options.filter(opt =>
|
|
186
|
+
keys.some(k => isEqual(k, opt[props.keyToSelect as keyof T])),
|
|
187
|
+
)
|
|
188
|
+
return found.length ? found : null
|
|
189
|
+
}
|
|
190
|
+
return modelValue.value as T[]
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (props.getOnlyKey) {
|
|
194
|
+
const match = findOptionByKey(modelValue.value)
|
|
195
|
+
if (match) return match
|
|
196
|
+
}
|
|
197
|
+
else if (modelValue.value != null && modelValue.value !== '') {
|
|
198
|
+
return modelValue.value as T
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (props.showFirstItem || !props.label) {
|
|
202
|
+
return props.options[0] ?? null
|
|
203
|
+
}
|
|
204
|
+
return null
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
const componentOptions = computed(() => {
|
|
208
|
+
const needle = searchValue.value.toLowerCase()
|
|
209
|
+
if (!needle) return props.options
|
|
210
|
+
const keys = Array.isArray(props.searchKey) ? props.searchKey : [props.searchKey]
|
|
211
|
+
return props.options.filter((item) => {
|
|
212
|
+
return keys.some(k =>
|
|
213
|
+
String(item[k as keyof T] ?? '').toLowerCase().includes(needle),
|
|
214
|
+
)
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
function selectedKey(item: T) {
|
|
219
|
+
return props.getOnlyKey ? item[props.keyToSelect as keyof T] : item
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function isItemSelected(item: T): boolean {
|
|
223
|
+
const key = selectedKey(item)
|
|
224
|
+
if (props.multiple) {
|
|
225
|
+
if (!Array.isArray(modelValue.value)) return false
|
|
226
|
+
return modelValue.value.some(el => isEqual(el, key))
|
|
227
|
+
}
|
|
228
|
+
return isEqual(modelValue.value, key)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function onSelect(item: T) {
|
|
232
|
+
if (props.multiple) {
|
|
233
|
+
const current = (Array.isArray(modelValue.value) ? [...modelValue.value] : []) as any[]
|
|
234
|
+
const key = selectedKey(item)
|
|
235
|
+
const index = current.findIndex(el => isEqual(el, key))
|
|
236
|
+
if (index !== -1) current.splice(index, 1)
|
|
237
|
+
else current.push(key)
|
|
238
|
+
modelValue.value = current
|
|
239
|
+
emits('onChange', modelValue.value as T[])
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
modelValue.value = selectedKey(item)
|
|
243
|
+
emits('onChange', item)
|
|
244
|
+
toggleOpen(false)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function onClear() {
|
|
248
|
+
modelValue.value = props.multiple ? [] : null
|
|
249
|
+
emits('onClear')
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function onClearFromMulti(index: number) {
|
|
253
|
+
if (!Array.isArray(modelValue.value)) return
|
|
254
|
+
const next = [...modelValue.value]
|
|
255
|
+
next.splice(index, 1)
|
|
256
|
+
modelValue.value = next
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
defineExpose({ onClear })
|
|
260
|
+
|
|
261
|
+
const valueColumn = ref<HTMLElement | null>(null)
|
|
262
|
+
const measureRow = ref<HTMLElement | null>(null)
|
|
263
|
+
const selectedCount = computed(() =>
|
|
264
|
+
Array.isArray(valueToShow.value) ? valueToShow.value.length : 0,
|
|
265
|
+
)
|
|
266
|
+
const { visibleCount: visibleChipCount, hiddenCount: hiddenChipCount } = useChipOverflow({
|
|
267
|
+
container: valueColumn,
|
|
268
|
+
measure: measureRow,
|
|
269
|
+
count: selectedCount,
|
|
270
|
+
gap: 6,
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
const triggerLayoutClass = computed(() => {
|
|
274
|
+
if (props.multiple || !props.label) {
|
|
275
|
+
return props.size === 'md' ? 'h-10 py-1.5' : 'h-9 py-1.5'
|
|
276
|
+
}
|
|
277
|
+
return props.size === 'md' ? 'h-10 pt-3 pb-0.5' : 'h-9 pt-3.5 pb-0.5'
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
const showFloatingLabel = computed(() => !!props.label && !props.multiple)
|
|
281
|
+
|
|
282
|
+
const isDefaultSelection = computed(() => {
|
|
283
|
+
if (props.multiple) {
|
|
284
|
+
return !Array.isArray(modelValue.value) || modelValue.value.length === 0
|
|
285
|
+
}
|
|
286
|
+
return modelValue.value == null || modelValue.value === ''
|
|
287
|
+
})
|
|
288
|
+
</script>
|
|
289
|
+
|
|
290
|
+
<template>
|
|
291
|
+
<div ref="wrapper" class="select-v2 relative w-full text-sm">
|
|
292
|
+
<button
|
|
293
|
+
ref="reference"
|
|
294
|
+
:disabled="disabled"
|
|
295
|
+
:class="[
|
|
296
|
+
triggerLayoutClass,
|
|
297
|
+
clearable ? 'pr-16' : 'pr-9',
|
|
298
|
+
{ 'select-v2__trigger--error': error },
|
|
299
|
+
disabled
|
|
300
|
+
? 'border-gray-200 bg-gray-100/70 dark:border-gray-700 dark:bg-white/[0.03]'
|
|
301
|
+
: (buttonBg || 'border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900'),
|
|
302
|
+
]"
|
|
303
|
+
class="select-v2__trigger text-deepblue-900 relative flex w-full items-center gap-2 rounded-[10px] border border-solid pl-4 transition-colors duration-200 hover:border-blue-500 focus-visible:border-blue-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600/20 dark:text-gray-200 dark:hover:border-blue-400 dark:focus-visible:border-blue-400 dark:focus-visible:ring-blue-400/20"
|
|
304
|
+
@click="toggleOpen()"
|
|
305
|
+
>
|
|
306
|
+
<span
|
|
307
|
+
v-if="showFloatingLabel"
|
|
308
|
+
:data-size="size"
|
|
309
|
+
class="select-v2__label pointer-events-none absolute left-4 top-1.5 text-[10px] leading-none text-gray-500 dark:text-gray-400"
|
|
310
|
+
:class="valueToShow ? 'select-v2__label--floated' : 'select-v2__label--placeholder'"
|
|
311
|
+
>
|
|
312
|
+
{{ label }}<span v-if="required" class="text-red-500 dark:text-red-400"> *</span>
|
|
313
|
+
</span>
|
|
314
|
+
|
|
315
|
+
<component
|
|
316
|
+
:is="startIcon"
|
|
317
|
+
v-if="startIcon"
|
|
318
|
+
class="shrink-0"
|
|
319
|
+
/>
|
|
320
|
+
|
|
321
|
+
<span ref="valueColumn" class="relative w-full min-w-0 overflow-hidden text-start leading-tight">
|
|
322
|
+
<template v-if="!multiple">
|
|
323
|
+
<span v-if="valueToShow" class="block truncate leading-tight">
|
|
324
|
+
<slot name="single-selected" :value="valueToShow">{{ (valueToShow as any)[keyToShow] }}</slot>
|
|
325
|
+
</span>
|
|
326
|
+
<span v-else class="text-gray-500 dark:text-gray-400">​</span>
|
|
327
|
+
</template>
|
|
328
|
+
|
|
329
|
+
<template v-else>
|
|
330
|
+
<template v-if="Array.isArray(valueToShow) && valueToShow.length">
|
|
331
|
+
<span class="flex w-full min-w-0 items-center gap-1.5 overflow-hidden py-0.5">
|
|
332
|
+
<span
|
|
333
|
+
v-for="(item, index) in (valueToShow as any[]).slice(0, visibleChipCount)"
|
|
334
|
+
:key="index"
|
|
335
|
+
class="select-v2__chip inline-flex min-w-0 max-w-[180px] items-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-2 py-0.5 text-xs dark:border-gray-700 dark:bg-white/[0.06]"
|
|
336
|
+
@click.stop="canChipRemove ? onClearFromMulti(index) : (isOpen = true)"
|
|
337
|
+
>
|
|
338
|
+
<span class="truncate">{{ item[keyToShow] }}</span>
|
|
339
|
+
<button
|
|
340
|
+
v-if="canChipRemove"
|
|
341
|
+
class="flex shrink-0 items-center justify-center rounded-full p-0.5 transition-colors hover:bg-gray-200 dark:hover:bg-white/[0.12]"
|
|
342
|
+
>
|
|
343
|
+
<a-icon-x-mark class="size-2.5" />
|
|
344
|
+
</button>
|
|
345
|
+
</span>
|
|
346
|
+
<span
|
|
347
|
+
v-if="hiddenChipCount > 0"
|
|
348
|
+
class="inline-flex shrink-0 items-center whitespace-nowrap rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700 dark:border-blue-800 dark:bg-blue-900/30 dark:text-blue-400"
|
|
349
|
+
>
|
|
350
|
+
+{{ hiddenChipCount }}
|
|
351
|
+
</span>
|
|
352
|
+
</span>
|
|
353
|
+
|
|
354
|
+
<span
|
|
355
|
+
ref="measureRow"
|
|
356
|
+
aria-hidden="true"
|
|
357
|
+
class="pointer-events-none invisible absolute left-0 top-0 flex h-0 items-center gap-1.5"
|
|
358
|
+
>
|
|
359
|
+
<span
|
|
360
|
+
v-for="(item, index) in (valueToShow as any[])"
|
|
361
|
+
:key="`measure-${index}`"
|
|
362
|
+
class="inline-flex max-w-[180px] items-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-2 py-0.5 text-xs"
|
|
363
|
+
>
|
|
364
|
+
<span class="truncate">{{ item[keyToShow] }}</span>
|
|
365
|
+
<span
|
|
366
|
+
v-if="canChipRemove"
|
|
367
|
+
class="flex shrink-0 items-center justify-center rounded-full p-0.5"
|
|
368
|
+
>
|
|
369
|
+
<a-icon-x-mark class="size-2.5" />
|
|
370
|
+
</span>
|
|
371
|
+
</span>
|
|
372
|
+
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium">
|
|
373
|
+
+{{ selectedCount }}
|
|
374
|
+
</span>
|
|
375
|
+
</span>
|
|
376
|
+
</template>
|
|
377
|
+
<span v-else class="text-gray-500 dark:text-gray-400">{{ label }}</span>
|
|
378
|
+
</template>
|
|
379
|
+
</span>
|
|
380
|
+
|
|
381
|
+
<button
|
|
382
|
+
v-if="valueToShow && clearable && !isDefaultSelection"
|
|
383
|
+
class="absolute right-9 top-1/2 flex -translate-y-1/2 items-center justify-center rounded-full p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-white/[0.08] dark:hover:text-gray-300"
|
|
384
|
+
@click.stop="onClear"
|
|
385
|
+
>
|
|
386
|
+
<a-icon-x-mark class="!m-0 size-3.5" />
|
|
387
|
+
</button>
|
|
388
|
+
|
|
389
|
+
<span
|
|
390
|
+
:class="{ 'rotate-180': isOpen }"
|
|
391
|
+
class="absolute right-3 top-1/2 -translate-y-1/2 transition-transform duration-200"
|
|
392
|
+
>
|
|
393
|
+
<a-icon-chevron-down class="!m-0 size-4 text-gray-400 dark:text-gray-500" />
|
|
394
|
+
</span>
|
|
395
|
+
</button>
|
|
396
|
+
|
|
397
|
+
<transition
|
|
398
|
+
enter-active-class="select-v2__dropdown-enter-active"
|
|
399
|
+
enter-from-class="select-v2__dropdown-enter-from"
|
|
400
|
+
enter-to-class="select-v2__dropdown-enter-to"
|
|
401
|
+
leave-active-class="select-v2__dropdown-leave-active"
|
|
402
|
+
leave-from-class="select-v2__dropdown-leave-from"
|
|
403
|
+
leave-to-class="select-v2__dropdown-leave-to"
|
|
404
|
+
>
|
|
405
|
+
<div
|
|
406
|
+
v-if="isOpen"
|
|
407
|
+
ref="floating"
|
|
408
|
+
class="select-v2__dropdown z-[10000] rounded-xl border border-gray-200 bg-white shadow-lg shadow-gray-900/10 dark:border-gray-700 dark:bg-gray-900 dark:shadow-black/30"
|
|
409
|
+
:style="{
|
|
410
|
+
position: strategy,
|
|
411
|
+
left: x != null ? `${x}px` : '',
|
|
412
|
+
top: y != null ? `${y}px` : '',
|
|
413
|
+
}"
|
|
414
|
+
>
|
|
415
|
+
<slot :options="options" name="options">
|
|
416
|
+
<ul class="select-v2__list flex flex-col gap-1 p-1.5">
|
|
417
|
+
<li v-if="searchFromOut" class="px-1 pb-1.5">
|
|
418
|
+
<a-input-standard
|
|
419
|
+
v-model="search"
|
|
420
|
+
:label="searchLabel"
|
|
421
|
+
:size="size"
|
|
422
|
+
clearable
|
|
423
|
+
color="gray"
|
|
424
|
+
/>
|
|
425
|
+
</li>
|
|
426
|
+
|
|
427
|
+
<li v-if="searchable" class="px-1 pb-1.5">
|
|
428
|
+
<a-input-standard
|
|
429
|
+
v-model="searchValue"
|
|
430
|
+
:label="searchLabel"
|
|
431
|
+
:size="size"
|
|
432
|
+
clearable
|
|
433
|
+
color="gray"
|
|
434
|
+
/>
|
|
435
|
+
</li>
|
|
436
|
+
|
|
437
|
+
<li v-for="(option, index) in componentOptions" :key="index">
|
|
438
|
+
<button
|
|
439
|
+
:disabled="!multiple && isItemSelected(option)"
|
|
440
|
+
:class="{ 'select-v2__option--selected': isItemSelected(option) }"
|
|
441
|
+
class="select-v2__option flex w-full items-center justify-between rounded-lg px-3 py-2 text-start text-sm transition-colors duration-100 hover:bg-gray-50 dark:hover:bg-gray-800/60"
|
|
442
|
+
@click="onSelect(option)"
|
|
443
|
+
>
|
|
444
|
+
<span>
|
|
445
|
+
<slot name="option" :option="option">{{ (option as any)[keyToShow] }}</slot>
|
|
446
|
+
</span>
|
|
447
|
+
<a-icon-check
|
|
448
|
+
v-if="isItemSelected(option)"
|
|
449
|
+
class="size-4 shrink-0 text-blue-600 dark:text-blue-400"
|
|
450
|
+
/>
|
|
451
|
+
</button>
|
|
452
|
+
</li>
|
|
453
|
+
</ul>
|
|
454
|
+
</slot>
|
|
455
|
+
|
|
456
|
+
<div
|
|
457
|
+
v-if="props.hasButtons"
|
|
458
|
+
class="flex w-full flex-col gap-2 border-t border-gray-200 p-3 xl:flex-row dark:border-gray-700"
|
|
459
|
+
>
|
|
460
|
+
<slot name="buttons">
|
|
461
|
+
<a-button
|
|
462
|
+
view="outline"
|
|
463
|
+
color="gray"
|
|
464
|
+
block
|
|
465
|
+
@click="onClear"
|
|
466
|
+
>
|
|
467
|
+
Сбросить
|
|
468
|
+
</a-button>
|
|
469
|
+
<a-button block @click="emits('onSubmit', modelValue)">
|
|
470
|
+
Применить
|
|
471
|
+
</a-button>
|
|
472
|
+
</slot>
|
|
473
|
+
</div>
|
|
474
|
+
</div>
|
|
475
|
+
</transition>
|
|
476
|
+
</div>
|
|
477
|
+
</template>
|
|
478
|
+
|
|
479
|
+
<style scoped>
|
|
480
|
+
.select-v2__trigger:disabled {
|
|
481
|
+
pointer-events: none;
|
|
482
|
+
cursor: not-allowed;
|
|
483
|
+
opacity: 0.7;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.select-v2__trigger--error {
|
|
487
|
+
border-color: theme('colors.red.500');
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
.select-v2__dropdown-enter-active,
|
|
491
|
+
.select-v2__dropdown-leave-active {
|
|
492
|
+
transition:
|
|
493
|
+
opacity 180ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
494
|
+
transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.select-v2__dropdown-enter-from,
|
|
498
|
+
.select-v2__dropdown-leave-to {
|
|
499
|
+
opacity: 0;
|
|
500
|
+
transform: translateY(-4px);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.select-v2__dropdown-enter-to,
|
|
504
|
+
.select-v2__dropdown-leave-from {
|
|
505
|
+
opacity: 1;
|
|
506
|
+
transform: translateY(0);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.select-v2__list {
|
|
510
|
+
max-height: 250px;
|
|
511
|
+
overflow-y: auto;
|
|
512
|
+
overflow-x: hidden;
|
|
513
|
+
scrollbar-width: none;
|
|
514
|
+
-ms-overflow-style: none;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.select-v2__list::-webkit-scrollbar {
|
|
518
|
+
width: 0;
|
|
519
|
+
height: 0;
|
|
520
|
+
display: none;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.select-v2__option--selected {
|
|
524
|
+
background-color: theme('colors.blue.50');
|
|
525
|
+
font-weight: 500;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
:is(.dark) .select-v2__option--selected {
|
|
529
|
+
background-color: rgb(30 64 175 / 0.12);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
.select-v2__chip {
|
|
533
|
+
cursor: pointer;
|
|
534
|
+
transition: background-color 150ms;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.select-v2__chip:hover {
|
|
538
|
+
background-color: theme('colors.gray.100');
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
:is(.dark) .select-v2__chip:hover {
|
|
542
|
+
background-color: rgb(255 255 255 / 0.08);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.select-v2__option {
|
|
546
|
+
cursor: pointer;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.select-v2__option:disabled {
|
|
550
|
+
cursor: default;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.select-v2__label {
|
|
554
|
+
transform-origin: 0 0;
|
|
555
|
+
transform: translateY(0) scale(1);
|
|
556
|
+
transition:
|
|
557
|
+
transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
558
|
+
color 200ms ease-out;
|
|
559
|
+
will-change: transform;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.select-v2__label--floated {
|
|
563
|
+
transform: translateY(0) scale(1);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.select-v2__label--placeholder {
|
|
567
|
+
transform: translateY(7px) scale(1.4);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.select-v2__label--placeholder[data-size="sm"] {
|
|
571
|
+
transform: translateY(5px) scale(1.4);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
@media (prefers-reduced-motion: reduce) {
|
|
575
|
+
.select-v2__dropdown-enter-active,
|
|
576
|
+
.select-v2__dropdown-leave-active,
|
|
577
|
+
.select-v2__label {
|
|
578
|
+
transition: none;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
withDefaults(defineProps<{ loading?: boolean }>(), { loading: false })
|
|
3
|
+
|
|
4
|
+
const emit = defineEmits<{ (e: 'click'): void }>()
|
|
5
|
+
|
|
6
|
+
const { t } = useI18n()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div class="flex items-center gap-3">
|
|
11
|
+
<hr class="h-px flex-1 border-0 bg-gray-200 dark:bg-white/10">
|
|
12
|
+
<button
|
|
13
|
+
type="button"
|
|
14
|
+
:disabled="loading"
|
|
15
|
+
class="inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-white px-4 py-1.5 text-sm font-medium text-gray-700 transition-colors duration-150 hover:border-gray-300 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300 dark:hover:border-gray-700 dark:hover:bg-white/[0.06]"
|
|
16
|
+
@click="emit('click')"
|
|
17
|
+
>
|
|
18
|
+
<a-icon-loader-circle v-if="loading" class="size-4 animate-spin" />
|
|
19
|
+
<slot>
|
|
20
|
+
<span>{{ t('actions.showMore') }}</span>
|
|
21
|
+
<a-icon-chevron-down v-if="!loading" class="size-4" />
|
|
22
|
+
</slot>
|
|
23
|
+
</button>
|
|
24
|
+
<hr class="h-px flex-1 border-0 bg-gray-200 dark:bg-white/10">
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { PAGES } from '#adata-ui/shared/constans/pages'
|
|
3
2
|
import { usePkServicesLinks } from '#adata-ui/composables/useHeaderNavigationLinks'
|
|
4
|
-
import {
|
|
3
|
+
import { useActiveNavigation } from '#adata-ui/composables/useActiveNavigation'
|
|
5
4
|
import { NuxtLinkLocale } from '#components'
|
|
6
5
|
|
|
7
6
|
const services = usePkServicesLinks()
|
|
8
|
-
const
|
|
9
|
-
const localePath = useLocalePath()
|
|
10
|
-
const { landing } = useUrls()
|
|
11
|
-
const { locale } = useI18n()
|
|
12
|
-
|
|
13
|
-
const pageUrl = useRequestURL()
|
|
7
|
+
const { isActiveService } = useActiveNavigation()
|
|
14
8
|
|
|
15
9
|
const blockStyles = [
|
|
16
10
|
'first-border-gradient',
|
|
@@ -23,22 +17,6 @@ const blockStyles = [
|
|
|
23
17
|
'eighth-border-gradient',
|
|
24
18
|
'ninth-border-gradient',
|
|
25
19
|
]
|
|
26
|
-
const linkByIndex = [
|
|
27
|
-
PAGES.pk.main,
|
|
28
|
-
PAGES.pk.employees,
|
|
29
|
-
PAGES.pk.connections,
|
|
30
|
-
PAGES.pk.offshore,
|
|
31
|
-
PAGES.pk.foreign,
|
|
32
|
-
PAGES.pk.unload,
|
|
33
|
-
PAGES.pk.compare,
|
|
34
|
-
PAGES.pk.sanctions,
|
|
35
|
-
buildLocalizedUrl(locale, landing, '/all-services'),
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
const normalize = (path: string) => {
|
|
39
|
-
const cleaned = path.replace(/\/+$/, '')
|
|
40
|
-
return cleaned === '' ? '/' : cleaned
|
|
41
|
-
}
|
|
42
20
|
</script>
|
|
43
21
|
|
|
44
22
|
<template>
|
|
@@ -46,15 +24,15 @@ const normalize = (path: string) => {
|
|
|
46
24
|
<component
|
|
47
25
|
v-for="(service, index) in services"
|
|
48
26
|
:key="index"
|
|
49
|
-
:is="
|
|
50
|
-
:to="
|
|
27
|
+
:is="isActiveService(service.to) ? 'div' : NuxtLinkLocale"
|
|
28
|
+
:to="isActiveService(service.to) ? '' : service.to"
|
|
51
29
|
:class="['flex flex-col items-center gap-2 p-2', blockStyles[index]]"
|
|
52
30
|
>
|
|
53
31
|
<div
|
|
54
32
|
class="size-10 p-2 rounded-lg"
|
|
55
33
|
:class="[
|
|
56
34
|
'bg-deepblue-900/5 dark:bg-gray-200/5',
|
|
57
|
-
{'!bg-blue-700 text-white dark:!bg-blue-500 ':
|
|
35
|
+
{'!bg-blue-700 text-white dark:!bg-blue-500 ': isActiveService(service.to)}
|
|
58
36
|
]"
|
|
59
37
|
>
|
|
60
38
|
<component
|