@vc-shell/framework 1.0.39 → 1.0.40
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/core/composables/usePermissions/index.ts +1 -1
- package/core/composables/useSettings/index.ts +31 -5
- package/core/types/index.ts +12 -12
- package/dist/core/composables/useSettings/index.d.ts +10 -1
- package/dist/core/composables/useSettings/index.d.ts.map +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/framework.js +69 -69
- package/dist/framework.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/shared/blade-navigation/types/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-badge/index.d.ts +5 -0
- package/dist/ui/components/atoms/vc-badge/index.d.ts.map +1 -0
- package/dist/ui/components/atoms/vc-badge/vc-badge-model.d.ts +28 -0
- package/dist/ui/components/atoms/vc-badge/vc-badge-model.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-badge/vc-badge.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-badge/vc-badge.stories.d.ts.map +1 -0
- package/dist/ui/components/atoms/vc-button/index.d.ts +5 -0
- package/dist/ui/components/atoms/vc-button/index.d.ts.map +1 -0
- package/dist/ui/components/atoms/vc-button/vc-button-model.d.ts +28 -0
- package/dist/ui/components/atoms/vc-button/vc-button-model.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-button/vc-button.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-button/vc-button.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-checkbox/vc-checkbox.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-checkbox/vc-checkbox.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-container/vc-container.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-container/vc-container.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-hint/vc-hint.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-hint/vc-hint.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-icon/vc-icon.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-icon/vc-icon.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-image/vc-image.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-image/vc-image.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-label/vc-label.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-label/vc-label.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-link/vc-link.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-link/vc-link.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-progress/vc-progress.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-progress/vc-progress.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-status/vc-status.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-status/vc-status.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/atoms/vc-switch/vc-switch.stories.d.ts +0 -0
- package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/index.d.ts +4 -3
- package/dist/ui/components/index.d.ts.map +1 -0
- package/dist/{components → ui/components}/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.d.ts +0 -0
- package/dist/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/molecules/vc-form/vc-form.stories.d.ts +0 -0
- package/dist/ui/components/molecules/vc-form/vc-form.stories.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-input/index.d.ts +5 -0
- package/dist/ui/components/molecules/vc-input/index.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-input/vc-input-model.d.ts +140 -0
- package/dist/ui/components/molecules/vc-input/vc-input-model.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-input-currency/index.d.ts +5 -0
- package/dist/ui/components/molecules/vc-input-currency/index.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-input-currency/vc-input-currency-model.d.ts +124 -0
- package/dist/ui/components/molecules/vc-input-currency/vc-input-currency-model.d.ts.map +1 -0
- package/dist/{components → ui/components}/molecules/vc-pagination/vc-pagination.stories.d.ts +0 -0
- package/dist/ui/components/molecules/vc-pagination/vc-pagination.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/molecules/vc-rating/vc-rating.stories.d.ts +0 -0
- package/dist/ui/components/molecules/vc-rating/vc-rating.stories.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-select/index.d.ts +5 -0
- package/dist/ui/components/molecules/vc-select/index.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-select/vc-select-model.d.ts +207 -0
- package/dist/ui/components/molecules/vc-select/vc-select-model.d.ts.map +1 -0
- package/dist/{components → ui/components}/molecules/vc-textarea/vc-textarea.stories.d.ts +0 -0
- package/dist/ui/components/molecules/vc-textarea/vc-textarea.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/organisms/vc-app/vc-app.stories.d.ts +0 -0
- package/dist/ui/components/organisms/vc-app/vc-app.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/organisms/vc-blade/vc-blade.stories.d.ts +0 -0
- package/dist/ui/components/organisms/vc-blade/vc-blade.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/organisms/vc-login-form/vc-login-form.stories.d.ts +0 -0
- package/dist/ui/components/organisms/vc-login-form/vc-login-form.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/organisms/vc-popup/vc-popup.stories.d.ts +0 -0
- package/dist/ui/components/organisms/vc-popup/vc-popup.stories.d.ts.map +1 -0
- package/dist/{components → ui/components}/organisms/vc-table/vc-table.stories.d.ts +0 -0
- package/dist/ui/components/organisms/vc-table/vc-table.stories.d.ts.map +1 -0
- package/dist/ui/types/index.d.ts +13 -0
- package/dist/ui/types/index.d.ts.map +1 -0
- package/dist/ui/types/ts-helpers.d.ts +13 -0
- package/dist/ui/types/ts-helpers.d.ts.map +1 -0
- package/dist/vite.config.d.ts.map +1 -1
- package/package.json +27 -10
- package/shared/app-switcher/components/vc-app-switcher/vc-app-switcher.vue +9 -9
- package/shared/assets/components/assets-details/assets-details.vue +12 -12
- package/shared/blade-navigation/composables/useBladeNavigation/index.ts +4 -4
- package/shared/blade-navigation/types/index.ts +25 -25
- package/tailwind.config.js +4 -3
- package/ui/components/atoms/vc-badge/index.ts +7 -0
- package/ui/components/atoms/vc-badge/vc-badge-model.ts +30 -0
- package/{components → ui/components}/atoms/vc-badge/vc-badge.stories.ts +0 -0
- package/ui/components/atoms/vc-badge/vc-badge.vue +57 -0
- package/ui/components/atoms/vc-button/index.ts +7 -0
- package/ui/components/atoms/vc-button/vc-button-model.ts +30 -0
- package/{components → ui/components}/atoms/vc-button/vc-button.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-button/vc-button.vue +54 -54
- package/{components → ui/components}/atoms/vc-card/vc-card.vue +15 -15
- package/{components → ui/components}/atoms/vc-checkbox/vc-checkbox.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-checkbox/vc-checkbox.vue +21 -21
- package/{components → ui/components}/atoms/vc-col/vc-col.vue +2 -2
- package/{components → ui/components}/atoms/vc-container/vc-container.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-container/vc-container.vue +21 -19
- package/{components → ui/components}/atoms/vc-hint/vc-hint.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-hint/vc-hint.vue +1 -1
- package/{components → ui/components}/atoms/vc-icon/vc-icon.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-icon/vc-icon.vue +1 -1
- package/{components → ui/components}/atoms/vc-image/vc-image.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-image/vc-image.vue +9 -9
- package/{components → ui/components}/atoms/vc-info-row/vc-info-row.vue +3 -3
- package/{components → ui/components}/atoms/vc-label/vc-label.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-label/vc-label.vue +6 -6
- package/{components → ui/components}/atoms/vc-link/vc-link.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-link/vc-link.vue +3 -3
- package/ui/components/atoms/vc-loading/vc-loading.vue +33 -0
- package/{components → ui/components}/atoms/vc-progress/vc-progress.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-progress/vc-progress.vue +2 -2
- package/{components → ui/components}/atoms/vc-row/vc-row.vue +1 -1
- package/{components → ui/components}/atoms/vc-status/vc-status.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-status/vc-status.vue +4 -4
- package/{components → ui/components}/atoms/vc-status-icon/vc-status-icon.vue +3 -3
- package/{components → ui/components}/atoms/vc-switch/vc-switch.stories.ts +0 -0
- package/{components → ui/components}/atoms/vc-switch/vc-switch.vue +10 -10
- package/{components → ui/components}/atoms/vc-widget/vc-widget.vue +12 -12
- package/{components → ui/components}/index.ts +4 -3
- package/{components → ui/components}/molecules/vc-breadcrumbs/_internal/vc-breadcrumbs-item/vc-breadcrumbs-item.vue +17 -17
- package/{components → ui/components}/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.ts +0 -0
- package/{components → ui/components}/molecules/vc-breadcrumbs/vc-breadcrumbs.vue +1 -1
- package/{components/molecules/vc-input → ui/components/molecules/vc-currency-input}/vc-input.vue +30 -37
- package/{components → ui/components}/molecules/vc-editor/vc-editor.vue +4 -4
- package/{components → ui/components}/molecules/vc-file-upload/vc-file-upload.vue +6 -6
- package/{components → ui/components}/molecules/vc-form/vc-form.stories.ts +0 -0
- package/{components → ui/components}/molecules/vc-form/vc-form.vue +0 -0
- package/ui/components/molecules/vc-input/index.ts +8 -0
- package/ui/components/molecules/vc-input/vc-input-model.ts +150 -0
- package/ui/components/molecules/vc-input/vc-input.vue +324 -0
- package/ui/components/molecules/vc-input-currency/index.ts +8 -0
- package/ui/components/molecules/vc-input-currency/vc-input-currency-model.ts +128 -0
- package/ui/components/molecules/vc-input-currency/vc-input-currency.vue +86 -0
- package/{components → ui/components}/molecules/vc-multivalue/vc-multivalue.vue +41 -41
- package/{components → ui/components}/molecules/vc-notification/vc-notification.vue +5 -5
- package/{components → ui/components}/molecules/vc-pagination/vc-pagination.stories.ts +0 -0
- package/{components → ui/components}/molecules/vc-pagination/vc-pagination.vue +24 -24
- package/{components → ui/components}/molecules/vc-rating/vc-rating.stories.ts +0 -0
- package/{components → ui/components}/molecules/vc-rating/vc-rating.vue +6 -6
- package/ui/components/molecules/vc-select/index.ts +7 -0
- package/ui/components/molecules/vc-select/vc-select-model.ts +216 -0
- package/ui/components/molecules/vc-select/vc-select.vue +727 -0
- package/{components → ui/components}/molecules/vc-slider/vc-slider.vue +12 -12
- package/{components → ui/components}/molecules/vc-textarea/vc-textarea.stories.ts +0 -0
- package/{components → ui/components}/molecules/vc-textarea/vc-textarea.vue +17 -17
- package/{components → ui/components}/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue +20 -16
- package/{components → ui/components}/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue +31 -31
- package/{components → ui/components}/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue +9 -9
- package/{components → ui/components}/organisms/vc-app/_internal/vc-app-menu/vc-app-menu.vue +11 -11
- package/{components → ui/components}/organisms/vc-app/vc-app.stories.ts +0 -0
- package/{components → ui/components}/organisms/vc-app/vc-app.vue +9 -11
- package/{components → ui/components}/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue +10 -10
- package/{components → ui/components}/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue +17 -17
- package/{components → ui/components}/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue +4 -4
- package/{components → ui/components}/organisms/vc-blade/vc-blade.stories.ts +0 -0
- package/{components → ui/components}/organisms/vc-blade/vc-blade.vue +5 -5
- package/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue +426 -0
- package/{components → ui/components}/organisms/vc-gallery/_internal/vc-gallery-item/vc-gallery-item.vue +12 -12
- package/{components → ui/components}/organisms/vc-gallery/_internal/vc-gallery-preview/vc-gallery-preview.vue +9 -9
- package/{components → ui/components}/organisms/vc-gallery/vc-gallery.vue +6 -6
- package/{components → ui/components}/organisms/vc-login-form/vc-login-form.stories.ts +6 -6
- package/{components → ui/components}/organisms/vc-login-form/vc-login-form.vue +5 -5
- package/{components → ui/components}/organisms/vc-popup/vc-popup.stories.ts +0 -0
- package/{components → ui/components}/organisms/vc-popup/vc-popup.vue +13 -13
- package/{components → ui/components}/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue +6 -6
- package/{components → ui/components}/organisms/vc-table/_internal/vc-table-counter/vc-table-counter.vue +3 -3
- package/{components → ui/components}/organisms/vc-table/_internal/vc-table-filter/vc-table-filter.vue +13 -13
- package/{components → ui/components}/organisms/vc-table/_internal/vc-table-mobile-item/vc-table-mobile-item.vue +23 -23
- package/{components → ui/components}/organisms/vc-table/vc-table.stories.ts +3 -3
- package/{components → ui/components}/organisms/vc-table/vc-table.vue +42 -42
- package/ui/types/index.ts +38 -0
- package/ui/types/ts-helpers.ts +46 -0
- package/components/atoms/vc-badge/vc-badge.vue +0 -63
- package/components/atoms/vc-loading/vc-loading.vue +0 -30
- package/components/molecules/vc-input/vc-input.stories.ts +0 -26
- package/components/molecules/vc-select/vc-select.stories.ts +0 -25
- package/components/molecules/vc-select/vc-select.vue +0 -402
- package/components/organisms/vc-dynamic-property/vc-dynamic-property.vue +0 -292
- package/dist/components/atoms/vc-badge/vc-badge.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-button/vc-button.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-checkbox/vc-checkbox.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-container/vc-container.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-hint/vc-hint.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-icon/vc-icon.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-image/vc-image.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-label/vc-label.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-link/vc-link.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-progress/vc-progress.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-status/vc-status.stories.d.ts.map +0 -1
- package/dist/components/atoms/vc-switch/vc-switch.stories.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.d.ts.map +0 -1
- package/dist/components/molecules/vc-form/vc-form.stories.d.ts.map +0 -1
- package/dist/components/molecules/vc-input/vc-input.stories.d.ts +0 -7
- package/dist/components/molecules/vc-input/vc-input.stories.d.ts.map +0 -1
- package/dist/components/molecules/vc-pagination/vc-pagination.stories.d.ts.map +0 -1
- package/dist/components/molecules/vc-rating/vc-rating.stories.d.ts.map +0 -1
- package/dist/components/molecules/vc-select/vc-select.stories.d.ts +0 -7
- package/dist/components/molecules/vc-select/vc-select.stories.d.ts.map +0 -1
- package/dist/components/molecules/vc-textarea/vc-textarea.stories.d.ts.map +0 -1
- package/dist/components/organisms/vc-app/vc-app.stories.d.ts.map +0 -1
- package/dist/components/organisms/vc-blade/vc-blade.stories.d.ts.map +0 -1
- package/dist/components/organisms/vc-login-form/vc-login-form.stories.d.ts.map +0 -1
- package/dist/components/organisms/vc-popup/vc-popup.stories.d.ts.map +0 -1
- package/dist/components/organisms/vc-table/vc-table.stories.d.ts.map +0 -1
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="vc-select tw-box-border"
|
|
4
|
+
:class="{
|
|
5
|
+
'vc-select_opened': isOpened,
|
|
6
|
+
'vc-select_error': error,
|
|
7
|
+
'vc-select_disabled': disabled,
|
|
8
|
+
'tw-pb-[20px]': error || hint,
|
|
9
|
+
}"
|
|
10
|
+
>
|
|
11
|
+
<!-- Select label -->
|
|
12
|
+
<VcLabel v-if="label" class="tw-mb-2" :required="required">
|
|
13
|
+
<span>{{ label }}</span>
|
|
14
|
+
<template v-if="tooltip" v-slot:tooltip>
|
|
15
|
+
<span v-html="tooltip"></span>
|
|
16
|
+
</template>
|
|
17
|
+
</VcLabel>
|
|
18
|
+
|
|
19
|
+
<!-- Select field -->
|
|
20
|
+
<div class="tw-flex tw-flex-nowrap tw-items-start" ref="dropdownToggleRef">
|
|
21
|
+
<div class="tw-flex tw-flex-auto tw-text-left tw-max-w-full">
|
|
22
|
+
<slot name="control" :toggleHandler="toggleDropdown">
|
|
23
|
+
<div
|
|
24
|
+
class="tw-relative tw-flex tw-flex-auto tw-text-left tw-max-w-full"
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-pr-3"
|
|
28
|
+
v-if="$slots['prepend']"
|
|
29
|
+
>
|
|
30
|
+
<slot name="prepend"></slot>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="tw-relative tw-flex tw-flex-auto tw-overflow-x-clip">
|
|
33
|
+
<div
|
|
34
|
+
class="tw-truncate vc-select__field-wrapper tw-relative tw-box-border tw-border tw-border-solid tw-border-[color:var(--select-border-color)] tw-rounded-[var(--select-border-radius)] tw-bg-[color:var(--select-background-color)] tw-flex tw-flex-col tw-flex-nowrap tw-flex-auto tw-items-stretch"
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
class="tw-flex tw-flex-col tw-flex-nowrap tw-flex-auto tw-relative"
|
|
38
|
+
>
|
|
39
|
+
<div
|
|
40
|
+
class="tw-flex tw-flex-nowrap tw-flex-auto tw-h-full tw-px-3"
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-pr-3"
|
|
44
|
+
v-if="$slots['prepend-inner']"
|
|
45
|
+
>
|
|
46
|
+
<slot name="prepend-inner"></slot>
|
|
47
|
+
</div>
|
|
48
|
+
<div
|
|
49
|
+
class="tw-flex tw-flex-nowrap tw-flex-auto tw-h-full tw-truncate"
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
class="tw-flex tw-items-center tw-flex-wrap tw-pr-3 tw-pointer-events-none"
|
|
53
|
+
v-if="prefix"
|
|
54
|
+
>
|
|
55
|
+
{{ prefix }}
|
|
56
|
+
</div>
|
|
57
|
+
<div
|
|
58
|
+
class="tw-w-full tw-appearance-none tw-border-none tw-outline-none tw-min-h-[var(--select-height)] tw-flex tw-items-center tw-w-full tw-box-border tw-box-border tw-cursor-pointer invalid:tw-text-[color:var(--select-placeholder-color)] tw-truncate"
|
|
59
|
+
@click.stop="toggleDropdown"
|
|
60
|
+
>
|
|
61
|
+
<div v-if="!hasValue" class="tw-text-[#a5a5a5]">
|
|
62
|
+
{{ placeholder }}
|
|
63
|
+
</div>
|
|
64
|
+
<template
|
|
65
|
+
v-else-if="
|
|
66
|
+
selectedScope && selectedScope.length && hasValue
|
|
67
|
+
"
|
|
68
|
+
>
|
|
69
|
+
<template v-if="$slots['selected-item']">
|
|
70
|
+
<slot
|
|
71
|
+
name="selected-item"
|
|
72
|
+
v-for="(item, i) in selectedScope"
|
|
73
|
+
v-bind="item"
|
|
74
|
+
:key="i"
|
|
75
|
+
></slot>
|
|
76
|
+
</template>
|
|
77
|
+
<template v-else>
|
|
78
|
+
<div class="tw-flex tw-flex-wrap tw-gap-1 tw-py-1">
|
|
79
|
+
<div
|
|
80
|
+
v-for="(item, i) in selectedScope"
|
|
81
|
+
v-bind="item"
|
|
82
|
+
:key="i"
|
|
83
|
+
class="tw-flex tw-items-center"
|
|
84
|
+
>
|
|
85
|
+
<template v-if="multiple">
|
|
86
|
+
<div
|
|
87
|
+
class="tw-bg-[#fbfdfe] tw-border tw-border-solid tw-border-[color:#bdd1df] tw-rounded-[2px] tw-flex tw-items-center tw-h-[28px] tw-box-border tw-px-2"
|
|
88
|
+
>
|
|
89
|
+
<span>{{
|
|
90
|
+
getEmittingOptionValue(item.opt)
|
|
91
|
+
}}</span>
|
|
92
|
+
<VcIcon
|
|
93
|
+
v-if="!disabled"
|
|
94
|
+
class="tw-text-[#a9bfd2] tw-ml-2 tw-cursor-pointer hover:tw-text-[color:var(--select-clear-color-hover)]"
|
|
95
|
+
icon="fas fa-times"
|
|
96
|
+
size="s"
|
|
97
|
+
@click.stop="removeAtIndex(item.index)"
|
|
98
|
+
></VcIcon>
|
|
99
|
+
</div>
|
|
100
|
+
</template>
|
|
101
|
+
<template v-else-if="!multiple">
|
|
102
|
+
{{ getEmittingOptionValue(item.opt) }}
|
|
103
|
+
</template>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
</template>
|
|
108
|
+
</div>
|
|
109
|
+
<div
|
|
110
|
+
class="tw-flex tw-items-center tw-flex-wrap tw-pl-3 tw-pointer-events-none"
|
|
111
|
+
v-if="suffix"
|
|
112
|
+
>
|
|
113
|
+
{{ suffix }}
|
|
114
|
+
</div>
|
|
115
|
+
<div
|
|
116
|
+
v-if="clearable && hasValue && !disabled"
|
|
117
|
+
class="tw-cursor-pointer tw-flex tw-items-center tw-pl-3 tw-text-[color:var(--select-clear-color)] hover:tw-text-[color:var(--select-clear-color-hover)]"
|
|
118
|
+
@click="onReset"
|
|
119
|
+
>
|
|
120
|
+
<VcIcon size="s" icon="fas fa-times"></VcIcon>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
<div
|
|
124
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-pl-3"
|
|
125
|
+
v-if="$slots['append-inner']"
|
|
126
|
+
>
|
|
127
|
+
<slot name="append-inner"></slot>
|
|
128
|
+
</div>
|
|
129
|
+
<!-- Loading-->
|
|
130
|
+
<div
|
|
131
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-pl-3 tw-text-[color:var(--select-clear-color)]"
|
|
132
|
+
v-if="loading || listLoading"
|
|
133
|
+
>
|
|
134
|
+
<VcIcon
|
|
135
|
+
icon="fas fa-spinner tw-animate-spin"
|
|
136
|
+
size="m"
|
|
137
|
+
></VcIcon>
|
|
138
|
+
</div>
|
|
139
|
+
<!-- Select chevron-->
|
|
140
|
+
<div
|
|
141
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-pl-3"
|
|
142
|
+
v-if="!disabled"
|
|
143
|
+
>
|
|
144
|
+
<div
|
|
145
|
+
class="vc-select__chevron tw-cursor-pointer tw-flex-nowrap tw-text-[color:var(--select-chevron-color)] hover:tw-text-[color:var(--select-chevron-color-hover)]"
|
|
146
|
+
@click.stop="toggleDropdown"
|
|
147
|
+
>
|
|
148
|
+
<VcIcon size="s" icon="fas fa-chevron-down"></VcIcon>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
<div
|
|
155
|
+
class="tw-absolute tw-translate-y-full tw-left-0 tw-right-0 tw-bottom-0 tw-min-h-[20px]"
|
|
156
|
+
>
|
|
157
|
+
<Transition name="slide-up" mode="out-in">
|
|
158
|
+
<div v-if="error">
|
|
159
|
+
<slot name="error">
|
|
160
|
+
<VcHint
|
|
161
|
+
class="tw-mt-1 tw-text-[color:var(--select-border-color-error)]"
|
|
162
|
+
v-if="errorMessage"
|
|
163
|
+
>
|
|
164
|
+
{{ errorMessage }}
|
|
165
|
+
</VcHint>
|
|
166
|
+
</slot>
|
|
167
|
+
</div>
|
|
168
|
+
<div v-else>
|
|
169
|
+
<slot name="hint">
|
|
170
|
+
<VcHint
|
|
171
|
+
class="tw-text-[color:var(--select-placeholder-color)] tw-mt-1 tw-break-words tw-p-0"
|
|
172
|
+
v-if="hint"
|
|
173
|
+
>
|
|
174
|
+
{{ hint }}
|
|
175
|
+
</VcHint>
|
|
176
|
+
</slot>
|
|
177
|
+
</div>
|
|
178
|
+
</Transition>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<div
|
|
183
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-pl-3"
|
|
184
|
+
v-if="$slots['append']"
|
|
185
|
+
>
|
|
186
|
+
<slot name="append"></slot>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</slot>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<!-- <teleport to="#app">-->
|
|
193
|
+
<div
|
|
194
|
+
v-if="isOpened"
|
|
195
|
+
class="tw-flex tw-flex-col tw-box-border tw-max-h-[300px] tw-h-auto tw-z-10 tw-overflow-hidden tw-absolute tw-bg-[color:var(--select-background-color)] tw-border tw-border-solid tw-border-[color:var(--select-border-color)] tw-border-t-[color:var(--select-background-color)] tw-rounded-b-[var(--select-border-radius)] tw-p-2"
|
|
196
|
+
ref="dropdownRef"
|
|
197
|
+
v-click-outside="closeDropdown"
|
|
198
|
+
>
|
|
199
|
+
<input
|
|
200
|
+
v-if="searchable"
|
|
201
|
+
ref="searchRef"
|
|
202
|
+
class="tw-w-full tw-box-border tw-border tw-border-solid tw-border-[#eaecf2] tw-rounded-[4px] tw-h-[32px] tw-leading-[32px] tw-outline-none tw-mb-3 tw-px-2"
|
|
203
|
+
@input="onInput"
|
|
204
|
+
/>
|
|
205
|
+
|
|
206
|
+
<VcContainer :no-padding="true" ref="root">
|
|
207
|
+
<div
|
|
208
|
+
v-if="!(optionsList && optionsList.length)"
|
|
209
|
+
class="tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center"
|
|
210
|
+
>
|
|
211
|
+
<slot name="no-options">
|
|
212
|
+
<span class="tw-m-4 tw-text-xl tw-font-medium">No options</span>
|
|
213
|
+
</slot>
|
|
214
|
+
</div>
|
|
215
|
+
<div
|
|
216
|
+
v-else
|
|
217
|
+
class="tw-flex tw-items-center tw-min-h-[36px] tw-my-1 tw-box-border tw-px-2 tw-rounded-[3px] tw-cursor-pointer hover:tw-bg-[#eff7fc]"
|
|
218
|
+
v-for="(item, i) in optionScope"
|
|
219
|
+
:key="i"
|
|
220
|
+
@click="item.toggleOption(item.opt)"
|
|
221
|
+
:class="{ 'tw-bg-[#eff7fc]': item.selected }"
|
|
222
|
+
>
|
|
223
|
+
<slot name="option" v-bind="item">{{ item.label }}</slot>
|
|
224
|
+
</div>
|
|
225
|
+
<span ref="el" v-if="hasNextPage"></span>
|
|
226
|
+
</VcContainer>
|
|
227
|
+
</div>
|
|
228
|
+
<!-- </teleport>-->
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</template>
|
|
232
|
+
|
|
233
|
+
<script lang="ts" setup>
|
|
234
|
+
import { nextTick, ref, computed, watch, toRefs } from "vue";
|
|
235
|
+
import { VcIcon, VcLabel, VcContainer } from "@/ui/components";
|
|
236
|
+
import { clickOutside as vClickOutside } from "@/core/directives";
|
|
237
|
+
import { createPopper, Instance, State } from "@popperjs/core";
|
|
238
|
+
import { VcSelectEmits, VcSelectProps, OptionProp } from "./vc-select-model";
|
|
239
|
+
import { intersection, isEqual } from "lodash-es";
|
|
240
|
+
import { useIntersectionObserver } from "@vueuse/core";
|
|
241
|
+
|
|
242
|
+
const props = withDefaults(defineProps<VcSelectProps>(), {
|
|
243
|
+
optionValue: "id",
|
|
244
|
+
optionLabel: "title",
|
|
245
|
+
debounce: 500,
|
|
246
|
+
clearable: true,
|
|
247
|
+
name: "Field",
|
|
248
|
+
searchable: false,
|
|
249
|
+
required: false,
|
|
250
|
+
autofocus: true,
|
|
251
|
+
emitValue: true,
|
|
252
|
+
mapOptions: true,
|
|
253
|
+
placeholder: "Click to select...",
|
|
254
|
+
options: () => [],
|
|
255
|
+
});
|
|
256
|
+
const emit = defineEmits<VcSelectEmits>();
|
|
257
|
+
|
|
258
|
+
const { modelValue, options } = toRefs(props);
|
|
259
|
+
|
|
260
|
+
const isOpened = ref(false);
|
|
261
|
+
|
|
262
|
+
const searchRef = ref();
|
|
263
|
+
const popper = ref<Instance>();
|
|
264
|
+
const dropdownToggleRef = ref();
|
|
265
|
+
const dropdownRef = ref();
|
|
266
|
+
const root = ref();
|
|
267
|
+
const el = ref();
|
|
268
|
+
const listLoading = ref(false);
|
|
269
|
+
|
|
270
|
+
const filterString = ref();
|
|
271
|
+
|
|
272
|
+
const defaultValue = ref([]);
|
|
273
|
+
|
|
274
|
+
const optionsList = ref([]);
|
|
275
|
+
const optionsTemp = ref([]);
|
|
276
|
+
|
|
277
|
+
const totalItems = ref();
|
|
278
|
+
|
|
279
|
+
let emitValueFn;
|
|
280
|
+
let emitTimer;
|
|
281
|
+
let innerValueCache: Record<string, unknown>[] | string[];
|
|
282
|
+
|
|
283
|
+
useIntersectionObserver(
|
|
284
|
+
el,
|
|
285
|
+
([{ isIntersecting }]) => {
|
|
286
|
+
if (isIntersecting) {
|
|
287
|
+
onLoadMore();
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{ threshold: 1, root: root.value?.component }
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
watch(
|
|
294
|
+
modelValue,
|
|
295
|
+
async (newVal, oldVal) => {
|
|
296
|
+
if (newVal && !oldVal) {
|
|
297
|
+
const initial = optionsList.value.filter((x) => {
|
|
298
|
+
if (props.modelValue && Array.isArray(props.modelValue)) {
|
|
299
|
+
return intersection(optionsList.value, props.modelValue);
|
|
300
|
+
} else if (props.modelValue && typeof props.modelValue === "object") {
|
|
301
|
+
return optionsList.value.includes(props.modelValue);
|
|
302
|
+
} else {
|
|
303
|
+
return x[props.optionLabel as string] === props.modelValue;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
if (initial && initial.length) {
|
|
308
|
+
defaultValue.value = initial;
|
|
309
|
+
} else {
|
|
310
|
+
if (props.options && typeof props.options === "function") {
|
|
311
|
+
const data = await props.options(
|
|
312
|
+
undefined,
|
|
313
|
+
undefined,
|
|
314
|
+
Array.isArray(props.modelValue)
|
|
315
|
+
? props.modelValue
|
|
316
|
+
: [props.modelValue]
|
|
317
|
+
);
|
|
318
|
+
defaultValue.value = data.results.filter(
|
|
319
|
+
(x) => x[props.optionValue as string] === props.modelValue
|
|
320
|
+
);
|
|
321
|
+
} else if (props.options && Array.isArray(props.options)) {
|
|
322
|
+
defaultValue.value = props.options.filter(
|
|
323
|
+
(x) => x[props.optionValue as string] === props.modelValue
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
{ immediate: true }
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
watch(
|
|
333
|
+
options,
|
|
334
|
+
async () => {
|
|
335
|
+
if (props.options && typeof props.options === "function") {
|
|
336
|
+
try {
|
|
337
|
+
listLoading.value = true;
|
|
338
|
+
const data = await props.options();
|
|
339
|
+
optionsList.value = data.results;
|
|
340
|
+
totalItems.value = data.totalCount;
|
|
341
|
+
} finally {
|
|
342
|
+
listLoading.value = false;
|
|
343
|
+
}
|
|
344
|
+
} else if (props.options && Array.isArray(props.options)) {
|
|
345
|
+
optionsList.value = props.options;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
{ immediate: true }
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
watch(
|
|
352
|
+
() => optionsList.value,
|
|
353
|
+
(newVal) => {
|
|
354
|
+
optionsTemp.value = newVal;
|
|
355
|
+
},
|
|
356
|
+
{ immediate: true, deep: true }
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
async function onLoadMore() {
|
|
360
|
+
if (props.options && typeof props.options === "function") {
|
|
361
|
+
try {
|
|
362
|
+
listLoading.value = true;
|
|
363
|
+
const data = await props.options(
|
|
364
|
+
filterString.value,
|
|
365
|
+
optionsList.value.length
|
|
366
|
+
);
|
|
367
|
+
optionsList.value.push(...data.results);
|
|
368
|
+
} finally {
|
|
369
|
+
listLoading.value = false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const hasNextPage = computed(() => {
|
|
375
|
+
return optionsList.value.length < totalItems.value;
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
const getOptionValue = computed(() =>
|
|
379
|
+
getPropValueFn(props.optionValue, "value")
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
const getOptionLabel = computed(() =>
|
|
383
|
+
getPropValueFn(props.optionLabel, "label")
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
const innerValue = computed((): Record<string, unknown>[] | string[] => {
|
|
387
|
+
const mapNull = props.mapOptions === true && props.multiple !== true;
|
|
388
|
+
|
|
389
|
+
const val: Record<string, unknown>[] | string[] =
|
|
390
|
+
props.modelValue !== undefined &&
|
|
391
|
+
(props.modelValue !== null || mapNull === true)
|
|
392
|
+
? props.multiple === true && Array.isArray(props.modelValue)
|
|
393
|
+
? props.modelValue
|
|
394
|
+
: [props.modelValue]
|
|
395
|
+
: [];
|
|
396
|
+
|
|
397
|
+
if (props.mapOptions === true && Array.isArray(optionsList.value) === true) {
|
|
398
|
+
const cache =
|
|
399
|
+
props.mapOptions === true && innerValueCache !== undefined
|
|
400
|
+
? innerValueCache
|
|
401
|
+
: [];
|
|
402
|
+
|
|
403
|
+
const values = val.map((v) => getOption(v, cache));
|
|
404
|
+
|
|
405
|
+
return props.modelValue === null && mapNull === true
|
|
406
|
+
? values.filter((v) => v !== null)
|
|
407
|
+
: values;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return val;
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
watch(
|
|
414
|
+
innerValue,
|
|
415
|
+
(val) => {
|
|
416
|
+
innerValueCache = val;
|
|
417
|
+
},
|
|
418
|
+
{ immediate: true }
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
const selectedScope = computed(() => {
|
|
422
|
+
return innerValue.value.map((opt, i) => ({
|
|
423
|
+
index: i,
|
|
424
|
+
opt,
|
|
425
|
+
selected: true,
|
|
426
|
+
toggleOption,
|
|
427
|
+
removeAtIndex,
|
|
428
|
+
}));
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
const hasValue = computed(() => fieldValueIsFilled(innerValue.value));
|
|
432
|
+
|
|
433
|
+
const innerOptionsValue = computed(() =>
|
|
434
|
+
innerValue.value.map((opt) => getOptionValue.value(opt))
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
const optionScope = computed(() => {
|
|
438
|
+
return optionsTemp.value.map((opt, i) => {
|
|
439
|
+
return {
|
|
440
|
+
index: i,
|
|
441
|
+
opt,
|
|
442
|
+
selected: isOptionSelected(opt) === true,
|
|
443
|
+
label: getOptionLabel.value(opt),
|
|
444
|
+
toggleOption,
|
|
445
|
+
};
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
function getPropValueFn(propValue: OptionProp, defaultVal: OptionProp) {
|
|
450
|
+
const val = propValue !== undefined ? propValue : defaultVal;
|
|
451
|
+
|
|
452
|
+
return typeof val === "function"
|
|
453
|
+
? val
|
|
454
|
+
: (opt) =>
|
|
455
|
+
opt !== null && typeof opt === "object" && val in opt ? opt[val] : opt;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function getOption(
|
|
459
|
+
value: Record<string, unknown> | string,
|
|
460
|
+
valueCache: Array<Record<string, unknown> | string>
|
|
461
|
+
) {
|
|
462
|
+
const fn = (opt) => isEqual(getOptionValue.value(opt), value);
|
|
463
|
+
return (
|
|
464
|
+
defaultValue.value.find(fn) ||
|
|
465
|
+
optionsList.value.find(fn) ||
|
|
466
|
+
valueCache.find(fn) ||
|
|
467
|
+
value
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function fieldValueIsFilled(val: Record<string, unknown>[] | unknown[]) {
|
|
472
|
+
return val !== undefined && val !== null && ("" + val).length > 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function getEmittingOptionValue(opt: Record<string, unknown>) {
|
|
476
|
+
return props.emitValue === true
|
|
477
|
+
? getOptionLabel.value(opt)
|
|
478
|
+
: getOptionValue.value(opt);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function removeAtIndex(index: number) {
|
|
482
|
+
if (index > -1 && index < innerValue.value.length) {
|
|
483
|
+
if (props.multiple === true) {
|
|
484
|
+
const model = props.modelValue.slice();
|
|
485
|
+
model.splice(index, 1);
|
|
486
|
+
emit("update:modelValue", model);
|
|
487
|
+
} else {
|
|
488
|
+
emit("update:modelValue", null);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function isOptionSelected(opt: Record<string, unknown>) {
|
|
494
|
+
const val = getOptionValue.value(opt);
|
|
495
|
+
return innerOptionsValue.value.find((v) => isEqual(v, val)) !== void 0;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function closeDropdown() {
|
|
499
|
+
isOpened.value = false;
|
|
500
|
+
popper.value?.destroy();
|
|
501
|
+
emit("close");
|
|
502
|
+
|
|
503
|
+
onDropdownClose();
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const onDropdownClose = async () => {
|
|
507
|
+
if (props.options && typeof props.options === "function") {
|
|
508
|
+
optionsList.value = (await props.options()).results;
|
|
509
|
+
} else {
|
|
510
|
+
optionsList.value = props.options as Record<string, unknown>[];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
filterString.value = undefined;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
async function toggleDropdown() {
|
|
517
|
+
if (!props.disabled) {
|
|
518
|
+
if (isOpened.value) {
|
|
519
|
+
closeDropdown();
|
|
520
|
+
} else {
|
|
521
|
+
isOpened.value = true;
|
|
522
|
+
|
|
523
|
+
await nextTick(() => {
|
|
524
|
+
searchRef?.value?.focus();
|
|
525
|
+
popper.value = createPopper(
|
|
526
|
+
dropdownToggleRef.value,
|
|
527
|
+
dropdownRef.value,
|
|
528
|
+
{
|
|
529
|
+
placement: "bottom",
|
|
530
|
+
modifiers: [
|
|
531
|
+
{
|
|
532
|
+
name: "flip",
|
|
533
|
+
options: {
|
|
534
|
+
fallbackPlacements: ["top", "bottom"],
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: "preventOverflow",
|
|
539
|
+
options: {
|
|
540
|
+
mainAxis: false,
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: "sameWidthChangeBorders",
|
|
545
|
+
enabled: true,
|
|
546
|
+
phase: "beforeWrite",
|
|
547
|
+
requires: ["computeStyles"],
|
|
548
|
+
fn: ({ state }: { state: State }) => {
|
|
549
|
+
const placement = state.placement;
|
|
550
|
+
if (placement === "top") {
|
|
551
|
+
state.styles.popper.borderTop =
|
|
552
|
+
"1px solid var(--select-border-color)";
|
|
553
|
+
state.styles.popper.borderBottom =
|
|
554
|
+
"1px solid var(--select-background-color)";
|
|
555
|
+
state.styles.popper.borderRadius =
|
|
556
|
+
"var(--select-border-radius) var(--select-border-radius) 0 0";
|
|
557
|
+
} else {
|
|
558
|
+
state.styles.popper.borderBottom =
|
|
559
|
+
"1px solid var(--select-border-color)";
|
|
560
|
+
state.styles.popper.borderTop =
|
|
561
|
+
"1px solid var(--select-background-color)";
|
|
562
|
+
state.styles.popper.borderRadius =
|
|
563
|
+
"0 0 var(--select-border-radius) var(--select-border-radius)";
|
|
564
|
+
}
|
|
565
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
566
|
+
},
|
|
567
|
+
effect: ({ state }: { state: State }) => {
|
|
568
|
+
const ref = state.elements.reference as HTMLElement;
|
|
569
|
+
const placement = state.placement;
|
|
570
|
+
if (placement === "top") {
|
|
571
|
+
state.elements.popper.style.borderTop =
|
|
572
|
+
"1px solid var(--select-border-color)";
|
|
573
|
+
state.elements.popper.style.borderBottom =
|
|
574
|
+
"1px solid var(--select-background-color)";
|
|
575
|
+
state.elements.popper.style.borderRadius =
|
|
576
|
+
"var(--select-border-radius) var(--select-border-radius) 0 0";
|
|
577
|
+
} else {
|
|
578
|
+
state.elements.popper.style.borderBottom =
|
|
579
|
+
"1px solid var(--select-border-color)";
|
|
580
|
+
state.elements.popper.style.borderTop =
|
|
581
|
+
"1px solid var(--select-background-color)";
|
|
582
|
+
state.elements.popper.style.borderRadius =
|
|
583
|
+
"0 0 var(--select-border-radius) var(--select-border-radius)";
|
|
584
|
+
}
|
|
585
|
+
state.elements.popper.style.width = `${ref.offsetWidth}px`;
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
name: "offset",
|
|
590
|
+
options: {
|
|
591
|
+
offset: [0, -2],
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
}
|
|
596
|
+
);
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function toggleOption(opt: { [x: string]: string }) {
|
|
603
|
+
if (opt === void 0) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const optValue = getOptionValue.value(opt);
|
|
608
|
+
|
|
609
|
+
if (props.multiple !== true) {
|
|
610
|
+
if (
|
|
611
|
+
innerValue.value.length === 0 ||
|
|
612
|
+
isEqual(getOptionValue.value(innerValue.value[0]), optValue) !== true
|
|
613
|
+
) {
|
|
614
|
+
emit("update:modelValue", props.emitValue === true ? optValue : opt);
|
|
615
|
+
isOpened.value = false;
|
|
616
|
+
}
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (innerValue.value.length === 0) {
|
|
621
|
+
const val = props.emitValue === true ? optValue : opt;
|
|
622
|
+
emit("update:modelValue", props.multiple === true ? [val] : val);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const model = props.modelValue.slice();
|
|
627
|
+
const index = innerOptionsValue.value.findIndex((v) => isEqual(v, optValue));
|
|
628
|
+
|
|
629
|
+
if (index > -1) {
|
|
630
|
+
model.splice(index, 1);
|
|
631
|
+
} else {
|
|
632
|
+
const val = props.emitValue === true ? optValue : opt;
|
|
633
|
+
model.push(val);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
emit("update:modelValue", model);
|
|
637
|
+
|
|
638
|
+
if (isOpened.value) {
|
|
639
|
+
popper.value.update();
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
async function onSearch(value: string) {
|
|
644
|
+
filterString.value = value;
|
|
645
|
+
if (props.options && typeof props.options === "function") {
|
|
646
|
+
try {
|
|
647
|
+
listLoading.value = true;
|
|
648
|
+
optionsTemp.value = (await props.options(filterString.value)).results;
|
|
649
|
+
} finally {
|
|
650
|
+
listLoading.value = false;
|
|
651
|
+
}
|
|
652
|
+
} else {
|
|
653
|
+
optionsTemp.value = optionsList.value.filter((x) => {
|
|
654
|
+
return x[props.optionLabel as string]
|
|
655
|
+
.toLowerCase()
|
|
656
|
+
.includes(filterString.value.toLowerCase());
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function onInput(e: Event) {
|
|
662
|
+
if (!e || !e.target) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const newValue = (e.target as HTMLInputElement).value;
|
|
667
|
+
emitValue(newValue);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function emitValue(val: string) {
|
|
671
|
+
emitValueFn = () => {
|
|
672
|
+
emit("search", val);
|
|
673
|
+
onSearch(val);
|
|
674
|
+
emitValueFn = undefined;
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
if (props.debounce !== undefined) {
|
|
678
|
+
clearTimeout(emitTimer);
|
|
679
|
+
emitTimer = setTimeout(emitValueFn, +props.debounce);
|
|
680
|
+
} else {
|
|
681
|
+
emitValueFn();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function onReset() {
|
|
686
|
+
emit("update:modelValue", null);
|
|
687
|
+
}
|
|
688
|
+
</script>
|
|
689
|
+
|
|
690
|
+
<style lang="scss">
|
|
691
|
+
:root {
|
|
692
|
+
--select-height: 38px;
|
|
693
|
+
--select-border-radius: 3px;
|
|
694
|
+
--select-border-color: #d3dbe9;
|
|
695
|
+
--select-border-color-error: #f14e4e;
|
|
696
|
+
--select-background-color: #ffffff;
|
|
697
|
+
--select-background-color-disabled: #fafafa;
|
|
698
|
+
--select-placeholder-color: #a5a5a5;
|
|
699
|
+
--select-chevron-color: #43b0e6;
|
|
700
|
+
--select-chevron-color-hover: #319ed4;
|
|
701
|
+
--select-clear-color: #43b0e6;
|
|
702
|
+
--select-clear-color-hover: #319ed4;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
.vc-select {
|
|
706
|
+
&_disabled &__field-wrapper,
|
|
707
|
+
&_disabled &__field {
|
|
708
|
+
@apply tw-bg-[color:var(--select-background-color-disabled)] tw-text-[#424242];
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
&_error &__field-wrapper {
|
|
712
|
+
@apply tw-border tw-border-solid tw-border-[color:var(--select-border-color-error)];
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
&_disabled &__field {
|
|
716
|
+
@apply tw-cursor-auto;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
&_opened &__chevron {
|
|
720
|
+
@apply tw-rotate-180;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
&_opened &__field-wrapper {
|
|
724
|
+
@apply tw-rounded-t-[var(--select-border-radius)];
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
</style>
|