@robuust-digital/vue-components 1.3.1 → 2.0.0-rc.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.
- package/README.md +47 -52
- package/dist/_shared/ButtonBase-CQjlJ85F.js +87 -0
- package/dist/_shared/ChevronDownIcon-z-5U4fIb.js +55 -0
- package/dist/_shared/FormInput-abFMz_J4.js +82 -0
- package/dist/_shared/Modal-COVlUEud.js +193 -0
- package/dist/_shared/Tooltip-BKXJoJ1x.js +126 -0
- package/dist/_shared/XMarkIcon-90mcPzBs.js +19 -0
- package/dist/_shared/icon-spinner-CmxIOqaK.js +26 -0
- package/dist/combobox/combobox.css +203 -0
- package/dist/combobox/index.js +349 -0
- package/dist/combobox/styles.css +1 -0
- package/dist/core/accordion.css +47 -0
- package/dist/core/alert.css +169 -0
- package/dist/core/badge.css +121 -0
- package/dist/core/button.css +393 -0
- package/dist/core/checkbox.css +60 -0
- package/dist/core/empty-state.css +56 -0
- package/dist/core/index.js +779 -0
- package/dist/core/input.css +92 -0
- package/dist/core/pagination.css +48 -0
- package/dist/core/radio.css +61 -0
- package/dist/core/select.css +81 -0
- package/dist/core/styles.css +92 -0
- package/dist/core/table.css +87 -0
- package/dist/core/tabs.css +74 -0
- package/dist/core/textarea.css +48 -0
- package/dist/core/theme.css +11 -0
- package/dist/dialogs/drawer.css +72 -0
- package/dist/dialogs/index.js +200 -0
- package/dist/dialogs/modal.css +98 -0
- package/dist/dialogs/styles.css +2 -0
- package/dist/dropdown/dropdown.css +89 -0
- package/dist/dropdown/index.js +136 -0
- package/dist/dropdown/styles.css +1 -0
- package/dist/lightswitch/index.js +48 -0
- package/dist/lightswitch/lightswitch.css +68 -0
- package/dist/lightswitch/styles.css +1 -0
- package/dist/rich-text-editor/index.js +262 -0
- package/dist/rich-text-editor/rich-text.css +83 -0
- package/dist/rich-text-editor/styles.css +1 -0
- package/dist/toast/index.js +100 -0
- package/dist/toast/styles.css +1 -0
- package/dist/toast/toast.css +187 -0
- package/dist/tooltip/index.js +5 -0
- package/dist/tooltip/styles.css +1 -0
- package/dist/tooltip/tooltip.css +69 -0
- package/package.json +55 -52
- package/dist/nuxt-module.js +0 -27
- package/dist/style.css +0 -1
- package/dist/tailwind/base/index.js +0 -72
- package/dist/tailwind/components/accordion.js +0 -59
- package/dist/tailwind/components/alert.js +0 -166
- package/dist/tailwind/components/badge.js +0 -119
- package/dist/tailwind/components/button.js +0 -292
- package/dist/tailwind/components/checkbox.js +0 -70
- package/dist/tailwind/components/combobox.js +0 -226
- package/dist/tailwind/components/drawer.js +0 -104
- package/dist/tailwind/components/dropdown.js +0 -97
- package/dist/tailwind/components/empty-state.js +0 -69
- package/dist/tailwind/components/input.js +0 -101
- package/dist/tailwind/components/lightswitch.js +0 -79
- package/dist/tailwind/components/modal.js +0 -132
- package/dist/tailwind/components/pagination.js +0 -62
- package/dist/tailwind/components/radio.js +0 -75
- package/dist/tailwind/components/rich-text.js +0 -100
- package/dist/tailwind/components/select.js +0 -88
- package/dist/tailwind/components/table.js +0 -109
- package/dist/tailwind/components/tabs.js +0 -95
- package/dist/tailwind/components/textarea.js +0 -53
- package/dist/tailwind/components/toast.js +0 -188
- package/dist/tailwind/components/tooltip.js +0 -74
- package/dist/tailwind/index.js +0 -94
- package/dist/vue-components.es.js +0 -2401
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createElementBlock as o, openBlock as t, createElementVNode as r } from "vue";
|
|
2
|
+
const n = {
|
|
3
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4
|
+
fill: "none",
|
|
5
|
+
viewBox: "0 0 24 24"
|
|
6
|
+
};
|
|
7
|
+
function l(c, e) {
|
|
8
|
+
return t(), o("svg", n, e[0] || (e[0] = [
|
|
9
|
+
r("circle", {
|
|
10
|
+
cx: "12",
|
|
11
|
+
cy: "12",
|
|
12
|
+
r: "10",
|
|
13
|
+
stroke: "currentColor",
|
|
14
|
+
"stroke-width": "4",
|
|
15
|
+
style: { opacity: ".25" }
|
|
16
|
+
}, null, -1),
|
|
17
|
+
r("path", {
|
|
18
|
+
fill: "currentColor",
|
|
19
|
+
d: "M4 12a8 8 0 0 1 8-8V0C5.373 0 0 5.373 0 12zm2 5.291A7.96 7.96 0 0 1 4 12H0c0 3.042 1.135 5.824 3 7.938z"
|
|
20
|
+
}, null, -1)
|
|
21
|
+
]));
|
|
22
|
+
}
|
|
23
|
+
const s = { render: l };
|
|
24
|
+
export {
|
|
25
|
+
s as S
|
|
26
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--rvc-combobox-border-radius: var(--rvc-base-border-radius);
|
|
3
|
+
--rvc-combobox-border-width: var(--rvc-base-border-width);
|
|
4
|
+
--rvc-combobox-border-color: var(--rvc-base-border-color);
|
|
5
|
+
--rvc-combobox-font-size: var(--rvc-base-input-font-size);
|
|
6
|
+
--rvc-combobox-font-weight: var(--rvc-base-input-font-weight);
|
|
7
|
+
--rvc-combobox-box-shadow: var(--rvc-base-box-shadow);
|
|
8
|
+
--rvc-combobox-color: var(--rvc-base-input-color);
|
|
9
|
+
--rvc-combobox-bg-color: var(--rvc-base-input-bg-color);
|
|
10
|
+
--rvc-combobox-padding-x: var(--rvc-base-input-padding-x);
|
|
11
|
+
--rvc-combobox-height: var(--rvc-base-input-height);
|
|
12
|
+
--rvc-combobox-icon-size: var(--rvc-base-input-icon-size);
|
|
13
|
+
--rvc-combobox-icon-color: var(--rvc-base-input-icon-color);
|
|
14
|
+
--rvc-combobox-icon-loading-animation: var(--rvc-base-loading-animation);
|
|
15
|
+
--rvc-combobox-placeholder-color: var(--rvc-base-input-placeholder-color);
|
|
16
|
+
--rvc-combobox-clear-color: var(--rvc-base-input-icon-color);
|
|
17
|
+
--rvc-combobox-clear-color-hover: var(--color-slate-700);
|
|
18
|
+
--rvc-combobox-chip-icon-size: calc(var(--spacing) * 4);
|
|
19
|
+
--rvc-combobox-chip-color: var(--rvc-base-input-color);
|
|
20
|
+
--rvc-combobox-chip-color-hover: var(--color-slate-700);
|
|
21
|
+
--rvc-combobox-chips-spacing: calc(var(--spacing) * 2);
|
|
22
|
+
--rvc-combobox-options-offset: calc(var(--spacing) * 1);
|
|
23
|
+
--rvc-combobox-options-z-index: 10;
|
|
24
|
+
--rvc-combobox-options-max-height: calc(var(--spacing) * 60);
|
|
25
|
+
--rvc-combobox-options-padding-x: 0.1875rem;
|
|
26
|
+
--rvc-combobox-options-padding-y: 0.1875rem;
|
|
27
|
+
--rvc-combobox-option-padding-x: calc(var(--spacing) * 2);
|
|
28
|
+
--rvc-combobox-option-padding-y: calc(var(--spacing) * 1.5);
|
|
29
|
+
--rvc-combobox-option-bg-color-hover: var(--color-slate-100);
|
|
30
|
+
--rvc-combobox-option-bg-color-active: transparent;
|
|
31
|
+
--rvc-combobox-option-color-active: var(--rvc-base-input-color);
|
|
32
|
+
--rvc-combobox-option-font-weight-active: var(--font-weight-semibold);
|
|
33
|
+
|
|
34
|
+
/* Small variant */
|
|
35
|
+
--rvc-combobox-height-sm: 1.875rem;
|
|
36
|
+
--rvc-combobox-font-size-sm: calc(var(--rvc-base-input-font-size) * 0.9);
|
|
37
|
+
--rvc-combobox-padding-x-sm: calc(var(--rvc-base-input-padding-x) * 0.85);
|
|
38
|
+
--rvc-combobox-icon-size-sm: calc(var(--rvc-base-input-icon-size) * 0.85);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@layer components {
|
|
42
|
+
.rvc-combobox {
|
|
43
|
+
display: block;
|
|
44
|
+
|
|
45
|
+
.rvc-combobox-wrapper {
|
|
46
|
+
display: grid;
|
|
47
|
+
grid-template-columns: 1fr;
|
|
48
|
+
position: relative;
|
|
49
|
+
width: 100%;
|
|
50
|
+
|
|
51
|
+
/* Extra right padding */
|
|
52
|
+
&:has(.rvc-combobox-button svg) input {
|
|
53
|
+
padding-right: calc(var(--rvc-combobox-padding-x) + var(--rvc-combobox-icon-size) + 0.25rem);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
> svg {
|
|
57
|
+
margin-left: var(--rvc-combobox-padding-x);
|
|
58
|
+
justify-self: start;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
input {
|
|
63
|
+
border-radius: var(--rvc-combobox-border-radius);
|
|
64
|
+
border-width: var(--rvc-combobox-border-width);
|
|
65
|
+
border-color: var(--rvc-combobox-border-color);
|
|
66
|
+
padding-right: var(--rvc-combobox-padding-x);
|
|
67
|
+
padding-left: var(--rvc-combobox-padding-x);
|
|
68
|
+
background-color: var(--rvc-combobox-bg-color);
|
|
69
|
+
font-size: var(--rvc-combobox-font-size);
|
|
70
|
+
font-weight: var(--rvc-combobox-font-weight);
|
|
71
|
+
color: var(--rvc-combobox-color);
|
|
72
|
+
box-shadow: var(--rvc-combobox-box-shadow);
|
|
73
|
+
height: var(--rvc-combobox-height);
|
|
74
|
+
background-image: none;
|
|
75
|
+
width: 100%;
|
|
76
|
+
position: relative;
|
|
77
|
+
grid-column-start: 1;
|
|
78
|
+
grid-row-start: 1;
|
|
79
|
+
appearance: none;
|
|
80
|
+
outline-width: 0;
|
|
81
|
+
|
|
82
|
+
/* Extra left padding */
|
|
83
|
+
&:nth-child(2) {
|
|
84
|
+
padding-left: calc(var(--rvc-combobox-padding-x) + var(--rvc-combobox-icon-size) + 0.25rem);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&::placeholder {
|
|
88
|
+
color: var(--rvc-combobox-placeholder-color);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.rvc-combobox-button, .rvc-combobox-wrapper > svg {
|
|
93
|
+
color: var(--rvc-combobox-icon-color);
|
|
94
|
+
position: relative;
|
|
95
|
+
grid-column-start: 1;
|
|
96
|
+
grid-row-start: 1;
|
|
97
|
+
align-self: center;
|
|
98
|
+
z-index: 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rvc-combobox-button {
|
|
102
|
+
justify-self: end;
|
|
103
|
+
margin-right: var(--rvc-combobox-padding-x);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
svg {
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
|
|
109
|
+
&:not([class]), &.rvc-combobox-spinner {
|
|
110
|
+
width: var(--rvc-combobox-icon-size);
|
|
111
|
+
height: var(--rvc-combobox-icon-size);
|
|
112
|
+
color: var(--rvc-select-icon-color);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.rvc-combobox-spinner {
|
|
117
|
+
animation: var(--rvc-combobox-icon-loading-animation);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.rvc-combobox-clear {
|
|
121
|
+
> * {
|
|
122
|
+
color: var(--rvc-combobox-clear-color);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&:hover > * {
|
|
126
|
+
color: var(--rvc-combobox-clear-color-hover);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.rvc-combobox-chips {
|
|
131
|
+
margin-top: var(--rvc-combobox-chips-spacing);
|
|
132
|
+
gap: var(--rvc-combobox-chips-spacing);
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-wrap: wrap;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.rvc-combobox-chip {
|
|
138
|
+
color: var(--rvc-combobox-chip-color);
|
|
139
|
+
|
|
140
|
+
svg {
|
|
141
|
+
width: var(--rvc-combobox-chip-icon-size);
|
|
142
|
+
height: var(--rvc-combobox-chip-icon-size);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&:hover svg {
|
|
146
|
+
color: var(--rvc-combobox-chip-color-hover);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.rvc-combobox-options {
|
|
151
|
+
padding-inline: var(--rvc-combobox-options-padding-x);
|
|
152
|
+
padding-block: var(--rvc-combobox-options-padding-y);
|
|
153
|
+
top: calc(var(--rvc-combobox-height) + var(--rvc-combobox-options-offset));
|
|
154
|
+
border-radius: var(--rvc-combobox-border-radius);
|
|
155
|
+
border-width: var(--rvc-combobox-border-width);
|
|
156
|
+
border-color: var(--rvc-combobox-border-color);
|
|
157
|
+
background-color: var(--rvc-combobox-bg-color);
|
|
158
|
+
font-size: var(--rvc-combobox-font-size);
|
|
159
|
+
color: var(--rvc-combobox-color);
|
|
160
|
+
box-shadow: var(--rvc-combobox-box-shadow);
|
|
161
|
+
margin-top: var(--rvc-combobox-options-offset);
|
|
162
|
+
z-index: var(--rvc-combobox-options-z-index);
|
|
163
|
+
max-height: var(--rvc-combobox-options-max-height);
|
|
164
|
+
position: absolute;
|
|
165
|
+
width: 100%;
|
|
166
|
+
overflow-y: auto;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.rvc-combobox-option {
|
|
170
|
+
padding: var(--rvc-combobox-option-padding-y) var(--rvc-combobox-option-padding-x);
|
|
171
|
+
border-radius: var(--rvc-combobox-border-radius);
|
|
172
|
+
color: var(--rvc-combobox-color);
|
|
173
|
+
gap: calc(var(--spacing) * 2);
|
|
174
|
+
align-items: center;
|
|
175
|
+
position: relative;
|
|
176
|
+
display: flex;
|
|
177
|
+
user-select: none;
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
|
|
180
|
+
&.rvc-combobox-option-hover {
|
|
181
|
+
background-color: var(--rvc-combobox-option-bg-color-hover);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&.rvc-combobox-option-active {
|
|
185
|
+
background-color: var(--rvc-combobox-option-bg-color-active);
|
|
186
|
+
color: var(--rvc-combobox-option-color-active);
|
|
187
|
+
font-weight: var(--rvc-combobox-option-font-weight-active);
|
|
188
|
+
|
|
189
|
+
&.rvc-combobox-option-hover {
|
|
190
|
+
background-color: var(--rvc-combobox-option-bg-color-hover);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* Size variants */
|
|
196
|
+
&.rvc-combobox-sm {
|
|
197
|
+
--rvc-combobox-height: var(--rvc-combobox-height-sm);
|
|
198
|
+
--rvc-combobox-font-size: var(--rvc-combobox-font-size-sm);
|
|
199
|
+
--rvc-combobox-padding-x: var(--rvc-combobox-padding-x-sm);
|
|
200
|
+
--rvc-combobox-icon-size: var(--rvc-combobox-icon-size-sm);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { createElementBlock as d, openBlock as n, createElementVNode as r, ref as h, computed as K, createBlock as g, unref as c, mergeProps as F, withCtx as x, createCommentVNode as C, renderSlot as v, createVNode as y, resolveDynamicComponent as N, withModifiers as P, Fragment as j, renderList as z, createTextVNode as Z, toDisplayString as S, normalizeClass as U } from "vue";
|
|
2
|
+
import { useDebounceFn as G } from "@vueuse/core";
|
|
3
|
+
import { Combobox as H, ComboboxInput as J, ComboboxButton as Q, ComboboxOptions as W, ComboboxOption as X } from "@headlessui/vue";
|
|
4
|
+
import { r as Y, _ } from "../_shared/ChevronDownIcon-z-5U4fIb.js";
|
|
5
|
+
import { S as ee } from "../_shared/icon-spinner-CmxIOqaK.js";
|
|
6
|
+
function te(e, $) {
|
|
7
|
+
return n(), d("svg", {
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
viewBox: "0 0 16 16",
|
|
10
|
+
fill: "currentColor",
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
"data-slot": "icon"
|
|
13
|
+
}, [
|
|
14
|
+
r("path", {
|
|
15
|
+
"fill-rule": "evenodd",
|
|
16
|
+
d: "M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm2.78-4.22a.75.75 0 0 1-1.06 0L8 9.06l-1.72 1.72a.75.75 0 1 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 1.06-1.06L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 0 1 0 1.06Z",
|
|
17
|
+
"clip-rule": "evenodd"
|
|
18
|
+
})
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
function le(e, $) {
|
|
22
|
+
return n(), d("svg", {
|
|
23
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
+
viewBox: "0 0 20 20",
|
|
25
|
+
fill: "currentColor",
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
"data-slot": "icon"
|
|
28
|
+
}, [
|
|
29
|
+
r("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" })
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
const oe = { class: "relative" }, ae = { class: "flex gap-x-1" }, ne = { class: "rvc-combobox-wrapper" }, ie = {
|
|
33
|
+
key: 0,
|
|
34
|
+
class: "rvc-combobox-chips"
|
|
35
|
+
}, ue = ["onClick"], re = {
|
|
36
|
+
key: 0,
|
|
37
|
+
class: "relative cursor-default select-none py-2 pl-3 pr-9 text-slate-500"
|
|
38
|
+
}, se = { class: "flex items-center" }, ce = {
|
|
39
|
+
key: 1,
|
|
40
|
+
class: "relative cursor-default select-none py-2 pl-3 pr-9 text-slate-500"
|
|
41
|
+
}, de = { class: "block truncate" }, pe = /* @__PURE__ */ Object.assign({
|
|
42
|
+
inheritAttrs: !1
|
|
43
|
+
}, {
|
|
44
|
+
__name: "Combobox",
|
|
45
|
+
props: {
|
|
46
|
+
id: {
|
|
47
|
+
type: String,
|
|
48
|
+
required: !0
|
|
49
|
+
},
|
|
50
|
+
rootClass: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: ""
|
|
53
|
+
},
|
|
54
|
+
modelValue: {
|
|
55
|
+
type: [Number, String, Object, Array, null],
|
|
56
|
+
required: !1,
|
|
57
|
+
default: null
|
|
58
|
+
},
|
|
59
|
+
endpoint: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
requestParams: {
|
|
64
|
+
type: Object,
|
|
65
|
+
required: !1,
|
|
66
|
+
default: () => ({})
|
|
67
|
+
},
|
|
68
|
+
manualInput: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: !1,
|
|
71
|
+
default: !1
|
|
72
|
+
},
|
|
73
|
+
responseData: {
|
|
74
|
+
type: Function,
|
|
75
|
+
required: !1,
|
|
76
|
+
default: (e) => e
|
|
77
|
+
},
|
|
78
|
+
displayValue: {
|
|
79
|
+
type: Function,
|
|
80
|
+
required: !1,
|
|
81
|
+
default: (e) => (e == null ? void 0 : e.name) || null
|
|
82
|
+
},
|
|
83
|
+
optionText: {
|
|
84
|
+
type: Function,
|
|
85
|
+
required: !1,
|
|
86
|
+
default: (e) => (e == null ? void 0 : e.name) || null
|
|
87
|
+
},
|
|
88
|
+
disabled: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
required: !1,
|
|
91
|
+
default: !1
|
|
92
|
+
},
|
|
93
|
+
minLength: {
|
|
94
|
+
type: Number,
|
|
95
|
+
default: 2,
|
|
96
|
+
required: !1
|
|
97
|
+
},
|
|
98
|
+
itemKey: {
|
|
99
|
+
type: String,
|
|
100
|
+
required: !1,
|
|
101
|
+
default: "id"
|
|
102
|
+
},
|
|
103
|
+
clearable: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
required: !1
|
|
106
|
+
},
|
|
107
|
+
rootAttrs: {
|
|
108
|
+
type: Object,
|
|
109
|
+
default: () => {
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
multiple: {
|
|
113
|
+
type: Boolean
|
|
114
|
+
},
|
|
115
|
+
onSearch: {
|
|
116
|
+
type: Function,
|
|
117
|
+
default: () => null
|
|
118
|
+
},
|
|
119
|
+
searchOnly: {
|
|
120
|
+
type: Boolean
|
|
121
|
+
},
|
|
122
|
+
icon: {
|
|
123
|
+
type: [Object, Function],
|
|
124
|
+
default: null
|
|
125
|
+
},
|
|
126
|
+
prefixIcon: {
|
|
127
|
+
type: [Object, Function],
|
|
128
|
+
default: null
|
|
129
|
+
},
|
|
130
|
+
size: {
|
|
131
|
+
type: String,
|
|
132
|
+
default: "base",
|
|
133
|
+
validator: (e) => ["sm", "base"].includes(e)
|
|
134
|
+
},
|
|
135
|
+
debounce: {
|
|
136
|
+
type: Number,
|
|
137
|
+
default: 150
|
|
138
|
+
},
|
|
139
|
+
minLoadingTime: {
|
|
140
|
+
type: Number,
|
|
141
|
+
default: 0
|
|
142
|
+
},
|
|
143
|
+
onCancel: {
|
|
144
|
+
type: Function,
|
|
145
|
+
default: null
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
emits: ["update:modelValue", "update:requestParams", "combobox:noResults", "combobox:error"],
|
|
149
|
+
setup(e, { emit: $ }) {
|
|
150
|
+
const a = e, m = $, s = h([]), b = h(!1), k = h(null), L = h(!0), q = h(null), f = K({
|
|
151
|
+
get: () => a.multiple ? a.modelValue || [] : a.modelValue,
|
|
152
|
+
set: (t) => m("update:modelValue", t)
|
|
153
|
+
}), O = K({
|
|
154
|
+
get: () => a.requestParams,
|
|
155
|
+
set: (t) => m("update:requestParams", t)
|
|
156
|
+
}), D = (t) => new Promise((l) => {
|
|
157
|
+
setTimeout(l, t);
|
|
158
|
+
}), T = (t, l) => {
|
|
159
|
+
s.value = [], m("combobox:error", t), m("combobox:noResults", l);
|
|
160
|
+
}, A = async (t) => {
|
|
161
|
+
if (!a.onSearch) return;
|
|
162
|
+
if (a.searchOnly && !t) {
|
|
163
|
+
s.value = [];
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (t && t.length < a.minLength) {
|
|
167
|
+
s.value = [];
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
q.value && a.onCancel && a.onCancel(q.value), b.value = !0;
|
|
171
|
+
const l = Date.now();
|
|
172
|
+
try {
|
|
173
|
+
const { data: i, error: p, cancel: w } = await a.onSearch(t, O.value, a.endpoint);
|
|
174
|
+
q.value = w;
|
|
175
|
+
const o = a.responseData(i), u = Date.now() - l;
|
|
176
|
+
!o.length && p && T(p, t), u < a.minLoadingTime && await D(a.minLoadingTime - u), o != null && o.length ? s.value = o : (s.value = [], m("combobox:noResults", t));
|
|
177
|
+
} catch (i) {
|
|
178
|
+
i.cancelled || T(i, t);
|
|
179
|
+
} finally {
|
|
180
|
+
b.value = !1;
|
|
181
|
+
}
|
|
182
|
+
}, M = G(A, a.debounce), B = (t) => {
|
|
183
|
+
L.value ? (L.value = !1, A(t)) : M(t);
|
|
184
|
+
}, R = (t) => {
|
|
185
|
+
var l;
|
|
186
|
+
((l = t.target.value) == null ? void 0 : l.length) === 0 && (s.value = [], m("update:modelValue", null)), a.manualInput && m("update:modelValue", O.value.query);
|
|
187
|
+
}, V = (t) => {
|
|
188
|
+
var l;
|
|
189
|
+
return a.multiple ? f.value.some((i) => i[a.itemKey] === t) : ((l = f.value) == null ? void 0 : l[a.itemKey]) === t;
|
|
190
|
+
}, I = (t) => {
|
|
191
|
+
f.value = f.value.filter((l) => l[a.itemKey] !== t[a.itemKey]);
|
|
192
|
+
};
|
|
193
|
+
return (t, l) => (n(), g(c(H), F({
|
|
194
|
+
modelValue: f.value,
|
|
195
|
+
"onUpdate:modelValue": l[4] || (l[4] = (i) => f.value = i),
|
|
196
|
+
as: "div"
|
|
197
|
+
}, e.rootAttrs, {
|
|
198
|
+
multiple: e.multiple,
|
|
199
|
+
class: [
|
|
200
|
+
"rvc-combobox",
|
|
201
|
+
`rvc-combobox-${e.size}`,
|
|
202
|
+
e.rootClass
|
|
203
|
+
]
|
|
204
|
+
}), {
|
|
205
|
+
default: x(() => {
|
|
206
|
+
var i, p, w;
|
|
207
|
+
return [
|
|
208
|
+
r("div", oe, [
|
|
209
|
+
r("div", ae, [
|
|
210
|
+
r("div", ne, [
|
|
211
|
+
e.prefixIcon ? v(t.$slots, "prefixIcon", {
|
|
212
|
+
key: 0,
|
|
213
|
+
icon: e.prefixIcon
|
|
214
|
+
}, () => [
|
|
215
|
+
(n(), g(N(e.prefixIcon), { "aria-hidden": "true" }))
|
|
216
|
+
]) : C("", !0),
|
|
217
|
+
y(c(J), F(t.$attrs, {
|
|
218
|
+
id: e.id,
|
|
219
|
+
"display-value": e.displayValue,
|
|
220
|
+
disabled: e.disabled,
|
|
221
|
+
autocomplete: "off",
|
|
222
|
+
onChange: l[0] || (l[0] = (o) => B(o.target.value)),
|
|
223
|
+
onSearch: R,
|
|
224
|
+
onInput: l[1] || (l[1] = (o) => k.value = o.target.value)
|
|
225
|
+
}), null, 16, ["id", "display-value", "disabled"]),
|
|
226
|
+
y(c(Q), {
|
|
227
|
+
disabled: e.disabled,
|
|
228
|
+
class: "rvc-combobox-button",
|
|
229
|
+
onClick: l[2] || (l[2] = (o) => B(k.value || null))
|
|
230
|
+
}, {
|
|
231
|
+
default: x(() => {
|
|
232
|
+
var o;
|
|
233
|
+
return [
|
|
234
|
+
b.value ? v(t.$slots, "spinner", {
|
|
235
|
+
key: 0,
|
|
236
|
+
spinning: b.value
|
|
237
|
+
}, () => [
|
|
238
|
+
y(c(ee), { class: "rvc-combobox-spinner" })
|
|
239
|
+
]) : (!e.searchOnly || (o = s.value) != null && o.length) && !b.value ? v(t.$slots, "icon", {
|
|
240
|
+
key: 1,
|
|
241
|
+
icon: e.icon
|
|
242
|
+
}, () => [
|
|
243
|
+
(n(), g(N(e.icon ?? c(Y)), { "aria-hidden": "true" }))
|
|
244
|
+
]) : C("", !0)
|
|
245
|
+
];
|
|
246
|
+
}),
|
|
247
|
+
_: 3
|
|
248
|
+
}, 8, ["disabled"])
|
|
249
|
+
]),
|
|
250
|
+
e.clearable && ((i = e.modelValue) != null && i.length || (p = e.modelValue) != null && p.id) ? (n(), d("button", {
|
|
251
|
+
key: 0,
|
|
252
|
+
type: "button",
|
|
253
|
+
"aria-label": "Clear selection",
|
|
254
|
+
class: "rvc-combobox-clear",
|
|
255
|
+
onClick: l[3] || (l[3] = P((o) => m("update:modelValue", e.multiple ? [] : null), ["prevent"]))
|
|
256
|
+
}, [
|
|
257
|
+
v(t.$slots, "clear", {}, () => [
|
|
258
|
+
y(c(le))
|
|
259
|
+
])
|
|
260
|
+
])) : C("", !0)
|
|
261
|
+
]),
|
|
262
|
+
e.multiple && f.value.length ? (n(), d("ul", ie, [
|
|
263
|
+
(n(!0), d(j, null, z(f.value, (o) => (n(), d("li", {
|
|
264
|
+
key: `${e.id}-selected-option-${o[e.itemKey]}`
|
|
265
|
+
}, [
|
|
266
|
+
v(t.$slots, "chip", {
|
|
267
|
+
optionText: e.optionText(o),
|
|
268
|
+
option: o,
|
|
269
|
+
removeOption: I
|
|
270
|
+
}, () => [
|
|
271
|
+
y(_, {
|
|
272
|
+
color: "gray",
|
|
273
|
+
class: "rvc-combobox-chip",
|
|
274
|
+
size: e.size
|
|
275
|
+
}, {
|
|
276
|
+
default: x(() => [
|
|
277
|
+
Z(S(e.optionText(o)) + " ", 1),
|
|
278
|
+
r("button", {
|
|
279
|
+
type: "button",
|
|
280
|
+
"aria-label": "Remove option",
|
|
281
|
+
onClick: P((u) => I(o), ["prevent"])
|
|
282
|
+
}, [
|
|
283
|
+
y(c(te))
|
|
284
|
+
], 8, ue)
|
|
285
|
+
]),
|
|
286
|
+
_: 2
|
|
287
|
+
}, 1032, ["size"])
|
|
288
|
+
])
|
|
289
|
+
]))), 128))
|
|
290
|
+
])) : C("", !0),
|
|
291
|
+
(!e.searchOnly || (w = k.value) != null && w.length) && (!b.value || s.value.length) ? (n(), g(c(W), {
|
|
292
|
+
key: 1,
|
|
293
|
+
class: "rvc-combobox-options"
|
|
294
|
+
}, {
|
|
295
|
+
default: x(() => {
|
|
296
|
+
var o;
|
|
297
|
+
return [
|
|
298
|
+
((o = k.value) == null ? void 0 : o.length) < e.minLength ? (n(), d("div", re, [
|
|
299
|
+
r("div", se, [
|
|
300
|
+
r("em", null, "Minimal " + S(e.minLength) + " characters.", 1)
|
|
301
|
+
])
|
|
302
|
+
])) : !b.value && !s.value.length ? (n(), d("div", ce, l[5] || (l[5] = [
|
|
303
|
+
r("div", { class: "flex items-center" }, " No results found. ", -1)
|
|
304
|
+
]))) : (n(!0), d(j, { key: 2 }, z(s.value, (u) => (n(), g(c(X), {
|
|
305
|
+
key: u[e.itemKey],
|
|
306
|
+
value: u,
|
|
307
|
+
as: "template"
|
|
308
|
+
}, {
|
|
309
|
+
default: x(({ active: E }) => [
|
|
310
|
+
r("li", {
|
|
311
|
+
class: U([
|
|
312
|
+
"rvc-combobox-option",
|
|
313
|
+
{ "rvc-combobox-option-hover": E },
|
|
314
|
+
{ "rvc-combobox-option-active": V(u[e.itemKey]) }
|
|
315
|
+
])
|
|
316
|
+
}, [
|
|
317
|
+
v(t.$slots, "option", {
|
|
318
|
+
option: u,
|
|
319
|
+
isActive: V
|
|
320
|
+
}, () => [
|
|
321
|
+
v(t.$slots, "optionPrefix", {
|
|
322
|
+
option: u[e.itemKey],
|
|
323
|
+
isActive: V
|
|
324
|
+
}),
|
|
325
|
+
r("span", de, S(e.optionText(u)), 1),
|
|
326
|
+
v(t.$slots, "optionSuffix", {
|
|
327
|
+
option: u[e.itemKey],
|
|
328
|
+
isActive: V
|
|
329
|
+
})
|
|
330
|
+
])
|
|
331
|
+
], 2)
|
|
332
|
+
]),
|
|
333
|
+
_: 2
|
|
334
|
+
}, 1032, ["value"]))), 128))
|
|
335
|
+
];
|
|
336
|
+
}),
|
|
337
|
+
_: 3
|
|
338
|
+
})) : C("", !0)
|
|
339
|
+
])
|
|
340
|
+
];
|
|
341
|
+
}),
|
|
342
|
+
_: 3
|
|
343
|
+
}, 16, ["modelValue", "multiple", "class"]));
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
export {
|
|
347
|
+
pe as Combobox,
|
|
348
|
+
pe as default
|
|
349
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "./combobox.css";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--rvc-accordion-border-width: var(--rvc-base-border-width);
|
|
3
|
+
--rvc-accordion-border-style: var(--rvc-base-border-style);
|
|
4
|
+
--rvc-accordion-border-color: var(--rvc-base-border-color);
|
|
5
|
+
--rvc-accordion-padding-y: calc(var(--spacing) * 6);
|
|
6
|
+
--rvc-accordion-font-weight: var(--font-weight-normal);
|
|
7
|
+
--rvc-accordion-font-size: var(--text-base);
|
|
8
|
+
--rvc-accordion-color: var(--color-slate-600);
|
|
9
|
+
--rvc-accordion-summary-font-weight: var(--font-weight-medium);
|
|
10
|
+
--rvc-accordion-summary-font-size: var(--text-lg);
|
|
11
|
+
--rvc-accordion-summary-color: var(--color-black);
|
|
12
|
+
--rvc-accordion-summary-decoration-hover: underline;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@layer components {
|
|
16
|
+
.rvc-accordion {
|
|
17
|
+
details {
|
|
18
|
+
border-top-width: var(--rvc-accordion-border-width);
|
|
19
|
+
border-top-color: var(--rvc-accordion-border-color);
|
|
20
|
+
border-top-style: var(--rvc-accordion-border-style);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
summary {
|
|
24
|
+
padding-block: var(--rvc-accordion-padding-y);
|
|
25
|
+
font-weight: var(--rvc-accordion-summary-font-weight);
|
|
26
|
+
font-size: var(--rvc-accordion-summary-font-size);
|
|
27
|
+
color: var(--rvc-accordion-summary-color);
|
|
28
|
+
width: 100%;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
user-select: none;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
text-decoration: var(--rvc-accordion-summary-decoration-hover);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rvc-accordion-content {
|
|
41
|
+
padding-bottom: var(--rvc-accordion-padding-y);
|
|
42
|
+
font-weight: var(--rvc-accordion-font-weight);
|
|
43
|
+
font-size: var(--rvc-accordion-font-size);
|
|
44
|
+
color: var(--rvc-accordion-color);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|