@scalar/components 0.16.20 → 0.16.22
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/dist/components/ScalarButton/ScalarButton.vue.js +28 -28
- package/dist/components/ScalarCheckboxInput/ScalarCheckbox.vue.js +7 -7
- package/dist/components/ScalarCheckboxInput/ScalarCheckboxGroup.vue.js +15 -15
- package/dist/components/ScalarCheckboxInput/ScalarCheckboxInput.vue.js +10 -10
- package/dist/components/ScalarCheckboxInput/ScalarCheckboxRadioGroup.vue.js +15 -15
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.js +6 -6
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue2.js +20 -20
- package/dist/components/ScalarColorModeToggle/ScalarColorModeToggle.vue.js +7 -7
- package/dist/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue2.js +13 -13
- package/dist/components/ScalarCombobox/ScalarCombobox.vue.js +20 -20
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue.js +25 -25
- package/dist/components/ScalarCombobox/ScalarComboboxOption.vue.js +9 -9
- package/dist/components/ScalarCombobox/ScalarComboboxOptionGroup.vue.js +9 -9
- package/dist/components/ScalarCombobox/ScalarComboboxOptions.vue.js +51 -51
- package/dist/components/ScalarContextMenu/ScalarContextMenu.vue.js +8 -8
- package/dist/components/ScalarDropdown/ScalarDropdown.vue.js +36 -36
- package/dist/components/ScalarDropdown/ScalarDropdownButton.vue2.js +11 -11
- package/dist/components/ScalarDropdown/ScalarDropdownItem.vue2.js +14 -14
- package/dist/components/ScalarDropdown/ScalarDropdownMenu.vue.js +12 -12
- package/dist/components/ScalarFileUpload/ScalarFileUpload.vue.js +47 -47
- package/dist/components/ScalarFileUpload/ScalarFileUploadInput.vue.js +23 -23
- package/dist/components/ScalarFileUpload/ScalarFileUploadInputCompact.vue.js +17 -17
- package/dist/components/ScalarFileUpload/ScalarFileUploadLoading.vue.js +9 -9
- package/dist/components/ScalarFloating/ScalarFloating.vue.js +30 -30
- package/dist/components/ScalarForm/ScalarFormError.vue.js +8 -8
- package/dist/components/ScalarForm/ScalarFormField.vue.js +14 -14
- package/dist/components/ScalarForm/ScalarFormInput.vue.js +9 -9
- package/dist/components/ScalarForm/ScalarFormInputGroup.vue.js +8 -8
- package/dist/components/ScalarHeader/ScalarHeaderButton.vue.js +12 -12
- package/dist/components/ScalarIcon/ScalarIcon.vue2.js +8 -8
- package/dist/components/ScalarIcon/ScalarIconLegacyAdapter.vue.js +10 -10
- package/dist/components/ScalarIconButton/ScalarIconButton.vue.js +18 -18
- package/dist/components/ScalarListbox/ScalarListbox.vue.js +28 -28
- package/dist/components/ScalarListbox/ScalarListboxCheckbox.vue.js +9 -9
- package/dist/components/ScalarListbox/ScalarListboxInput.vue.js +11 -11
- package/dist/components/ScalarListbox/ScalarListboxItem.vue.js +10 -10
- package/dist/components/ScalarLoading/ScalarLoading.vue2.js +13 -13
- package/dist/components/ScalarMarkdown/ScalarMarkdown.vue.js +13 -13
- package/dist/components/ScalarMarkdown/ScalarMarkdownSummary.vue.js +16 -16
- package/dist/components/ScalarMenu/ScalarMenuButton.vue.js +16 -16
- package/dist/components/ScalarMenu/ScalarMenuLink.vue.js +17 -17
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue.js +11 -11
- package/dist/components/ScalarMenu/ScalarMenuProducts.vue.js +24 -24
- package/dist/components/ScalarMenu/ScalarMenuTeamPicker.vue.js +17 -17
- package/dist/components/ScalarMenu/ScalarMenuTeamProfile.vue.js +14 -14
- package/dist/components/ScalarMenu/ScalarMenuWorkspacePicker.vue.js +8 -8
- package/dist/components/ScalarModal/ScalarModal.vue2.js +34 -34
- package/dist/components/ScalarPopover/ScalarPopover.vue.js +25 -25
- package/dist/components/ScalarSearchInput/ScalarSearchInput.vue.js +26 -26
- package/dist/components/ScalarSearchResults/ScalarSearchResultItem.vue.js +30 -30
- package/dist/components/ScalarSearchResults/ScalarSearchResultList.vue.js +8 -8
- package/dist/components/ScalarSidebar/ScalarSidebarButton.vue.js +24 -24
- package/dist/components/ScalarSidebar/ScalarSidebarGroup.vue.js +51 -51
- package/dist/components/ScalarSidebar/ScalarSidebarGroupToggle.vue.js +18 -18
- package/dist/components/ScalarSidebar/ScalarSidebarIndent.vue2.js +14 -14
- package/dist/components/ScalarSidebar/ScalarSidebarItem.vue.js +7 -7
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue.js +12 -12
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue.js +46 -46
- package/dist/components/ScalarSidebar/ScalarSidebarSearchInput.vue.js +30 -30
- package/dist/components/ScalarSidebar/ScalarSidebarSection.vue.js +18 -18
- package/dist/components/ScalarSidebar/ScalarSidebarSpacer.vue.js +8 -8
- package/dist/components/ScalarTeleport/ScalarTeleport.vue.js +12 -12
- package/dist/components/ScalarTextInput/ScalarTextInput.vue.js +34 -34
- package/dist/components/ScalarToggle/ScalarToggle.vue.js +20 -20
- package/dist/components/ScalarToggle/ScalarToggleGroup.vue.js +14 -14
- package/dist/components/ScalarVirtualText/ScalarVirtualText.vue.js +25 -25
- package/package.json +8 -8
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as o, createElementBlock as
|
|
2
|
-
import { cva as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as o, createElementBlock as n, openBlock as r, normalizeClass as l, unref as t, renderSlot as s } from "vue";
|
|
2
|
+
import { cva as i, cx as d } from "@scalar/use-hooks/useBindCx";
|
|
3
|
+
const m = ["aria-selected"], b = /* @__PURE__ */ o({
|
|
4
4
|
__name: "ScalarComboboxOption",
|
|
5
5
|
props: {
|
|
6
6
|
active: { type: Boolean },
|
|
7
7
|
selected: { type: Boolean }
|
|
8
8
|
},
|
|
9
|
-
setup(
|
|
10
|
-
const a =
|
|
9
|
+
setup(e) {
|
|
10
|
+
const a = i({
|
|
11
11
|
base: [
|
|
12
12
|
// Group
|
|
13
13
|
"group/item",
|
|
@@ -23,17 +23,17 @@ const p = ["aria-selected"], b = /* @__PURE__ */ o({
|
|
|
23
23
|
active: { true: "bg-b-2" }
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
return (
|
|
26
|
+
return (c, u) => (r(), n("li", {
|
|
27
27
|
"aria-selected": e.selected,
|
|
28
|
-
class:
|
|
28
|
+
class: l(t(d)(t(a)({ active: e.active, selected: e.selected }))),
|
|
29
29
|
role: "option",
|
|
30
30
|
tabindex: "-1"
|
|
31
31
|
}, [
|
|
32
|
-
c
|
|
32
|
+
s(c.$slots, "default", {
|
|
33
33
|
active: e.active,
|
|
34
34
|
selected: e.selected
|
|
35
35
|
})
|
|
36
|
-
], 10,
|
|
36
|
+
], 10, m));
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
export {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { defineComponent as a, useId as i, createElementBlock as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as a, useId as i, createElementBlock as t, openBlock as l, createCommentVNode as n, renderSlot as o } from "vue";
|
|
2
|
+
const r = ["id", "aria-labelledby", "role"], c = ["id"], m = /* @__PURE__ */ a({
|
|
3
3
|
__name: "ScalarComboboxOptionGroup",
|
|
4
4
|
props: {
|
|
5
5
|
id: { default: () => i() },
|
|
6
6
|
hidden: { type: Boolean, default: !1 }
|
|
7
7
|
},
|
|
8
|
-
setup(
|
|
9
|
-
return (
|
|
8
|
+
setup(e) {
|
|
9
|
+
return (d, s) => (l(), t("div", {
|
|
10
10
|
id: e.id,
|
|
11
11
|
"aria-labelledby": e.id ? `${e.id}-label` : void 0,
|
|
12
12
|
class: "contents",
|
|
13
13
|
role: e.hidden ? void 0 : "group"
|
|
14
14
|
}, [
|
|
15
|
-
e.hidden ?
|
|
15
|
+
e.hidden ? n("", !0) : (l(), t("div", {
|
|
16
16
|
key: 0,
|
|
17
17
|
id: `${e.id}-label`,
|
|
18
18
|
class: "min-w-0 truncate px-2.5 py-1.5 text-c-2"
|
|
19
19
|
}, [
|
|
20
|
-
|
|
21
|
-
], 8,
|
|
22
|
-
|
|
23
|
-
], 8,
|
|
20
|
+
o(d.$slots, "label")
|
|
21
|
+
], 8, c)),
|
|
22
|
+
o(d.$slots, "default")
|
|
23
|
+
], 8, r));
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
export {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as W, mergeModels as O, useModel as X, useSlots as Y, useId as z, computed as w, ref as
|
|
1
|
+
import { defineComponent as W, mergeModels as O, useModel as X, useSlots as Y, useId as z, computed as w, ref as I, onMounted as D, watch as Z, createElementBlock as v, openBlock as s, Fragment as m, createElementVNode as k, withDirectives as G, createVNode as h, unref as V, withKeys as C, withModifiers as y, vModelText as _, createBlock as S, createCommentVNode as K, renderList as q, withCtx as g, renderSlot as B, toDisplayString as F, createTextVNode as ee, vShow as te } from "vue";
|
|
2
2
|
import { ScalarIconMagnifyingGlass as le, ScalarIconPlus as oe } from "@scalar/icons";
|
|
3
3
|
import P from "./ScalarComboboxOption.vue.js";
|
|
4
4
|
import ne from "./ScalarComboboxOptionGroup.vue.js";
|
|
5
5
|
import { isGroups as R } from "./types.js";
|
|
6
6
|
import ie from "../ScalarListbox/ScalarListboxCheckbox.vue.js";
|
|
7
|
-
const
|
|
7
|
+
const ae = { class: "relative flex" }, se = ["aria-activedescendant", "placeholder"], de = ["aria-multiselectable"], ue = { class: "inline-block min-w-0 flex-1 truncate text-c-1" }, be = /* @__PURE__ */ W({
|
|
8
8
|
inheritAttrs: !1,
|
|
9
9
|
__name: "ScalarComboboxOptions",
|
|
10
10
|
props: /* @__PURE__ */ O({
|
|
@@ -16,9 +16,9 @@ const se = { class: "relative flex" }, ae = ["aria-activedescendant", "placehold
|
|
|
16
16
|
modelModifiers: {}
|
|
17
17
|
}),
|
|
18
18
|
emits: /* @__PURE__ */ O(["add"], ["update:modelValue"]),
|
|
19
|
-
setup(
|
|
20
|
-
const d =
|
|
21
|
-
function
|
|
19
|
+
setup(f, { emit: U }) {
|
|
20
|
+
const d = f, j = U, i = X(f, "modelValue"), M = Y(), $ = `scalar-combobox-items-${z()}`, p = { id: `${z()}-add`, label: "Add a new option" };
|
|
21
|
+
function b(t) {
|
|
22
22
|
return `${$}-${t.id}`;
|
|
23
23
|
}
|
|
24
24
|
const r = w(
|
|
@@ -32,24 +32,24 @@ const se = { class: "relative flex" }, ae = ["aria-activedescendant", "placehold
|
|
|
32
32
|
[{ label: "", options: d.options }]
|
|
33
33
|
)
|
|
34
34
|
// G is OptionGroup<O>
|
|
35
|
-
), u =
|
|
35
|
+
), u = I(""), l = I(i.value?.[0] ?? r.value[0]);
|
|
36
36
|
D(() => {
|
|
37
37
|
u.value = "", l.value = i.value?.[0] ?? r.value[0], i.value[0] && setTimeout(() => {
|
|
38
38
|
const e = i.value[0];
|
|
39
|
-
e && document?.getElementById(
|
|
39
|
+
e && document?.getElementById(b(e))?.scrollIntoView({ block: "nearest" });
|
|
40
40
|
}, 10);
|
|
41
41
|
}), Z(
|
|
42
42
|
() => u.value,
|
|
43
43
|
() => l.value = N.value[0]
|
|
44
44
|
);
|
|
45
|
-
const
|
|
45
|
+
const x = w(
|
|
46
46
|
() => u.value === "" ? r.value : r.value.filter((t) => t.label.toLowerCase().includes(u.value.toLowerCase()))
|
|
47
47
|
), N = w(
|
|
48
|
-
() =>
|
|
48
|
+
() => M.add ? [...x.value, p] : x.value
|
|
49
49
|
);
|
|
50
50
|
function A(t) {
|
|
51
51
|
if (t) {
|
|
52
|
-
if (t.id ===
|
|
52
|
+
if (t.id === p.id) {
|
|
53
53
|
T();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
@@ -60,10 +60,10 @@ const se = { class: "relative flex" }, ae = ["aria-activedescendant", "placehold
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
function E(t) {
|
|
63
|
-
const e = N.value,
|
|
63
|
+
const e = N.value, c = e.findIndex(
|
|
64
64
|
(n) => n.id === l.value?.id
|
|
65
65
|
) + t;
|
|
66
|
-
|
|
66
|
+
c < 0 || c > e.length - 1 || (l.value = e[c], l.value && document?.getElementById(b(l.value))?.scrollIntoView({
|
|
67
67
|
behavior: "smooth",
|
|
68
68
|
block: "nearest"
|
|
69
69
|
}));
|
|
@@ -71,79 +71,79 @@ const se = { class: "relative flex" }, ae = ["aria-activedescendant", "placehold
|
|
|
71
71
|
function T() {
|
|
72
72
|
j("add"), u.value = "";
|
|
73
73
|
}
|
|
74
|
-
const L =
|
|
75
|
-
return D(() => setTimeout(() => L.value?.focus(), 0)), (t, e) => (
|
|
76
|
-
k("div",
|
|
77
|
-
|
|
74
|
+
const L = I(null);
|
|
75
|
+
return D(() => setTimeout(() => L.value?.focus(), 0)), (t, e) => (s(), v(m, null, [
|
|
76
|
+
k("div", ae, [
|
|
77
|
+
h(V(le), { class: "pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-c-3 size-4" }),
|
|
78
78
|
G(k("input", {
|
|
79
79
|
ref_key: "input",
|
|
80
80
|
ref: L,
|
|
81
81
|
"onUpdate:modelValue": e[0] || (e[0] = (o) => u.value = o),
|
|
82
|
-
"aria-activedescendant": l.value ?
|
|
82
|
+
"aria-activedescendant": l.value ? b(l.value) : void 0,
|
|
83
83
|
"aria-autocomplete": "list",
|
|
84
84
|
"aria-controls": $,
|
|
85
85
|
class: "min-w-0 flex-1 rounded border-0 py-2.5 pl-8 pr-3 leading-none text-c-1 -outline-offset-1",
|
|
86
86
|
"data-1p-ignore": "",
|
|
87
|
-
placeholder:
|
|
87
|
+
placeholder: f.placeholder,
|
|
88
88
|
role: "combobox",
|
|
89
89
|
tabindex: "0",
|
|
90
90
|
type: "text",
|
|
91
91
|
onKeydown: [
|
|
92
|
-
e[1] || (e[1] =
|
|
93
|
-
e[2] || (e[2] =
|
|
94
|
-
e[3] || (e[3] =
|
|
92
|
+
e[1] || (e[1] = C(y((o) => E(1), ["prevent"]), ["down"])),
|
|
93
|
+
e[2] || (e[2] = C(y((o) => l.value && A(l.value), ["prevent"]), ["enter"])),
|
|
94
|
+
e[3] || (e[3] = C(y((o) => E(-1), ["prevent"]), ["up"]))
|
|
95
95
|
]
|
|
96
|
-
}, null, 40,
|
|
96
|
+
}, null, 40, se), [
|
|
97
97
|
[_, u.value]
|
|
98
98
|
])
|
|
99
99
|
]),
|
|
100
100
|
G(k("ul", {
|
|
101
101
|
id: $,
|
|
102
|
-
"aria-multiselectable":
|
|
102
|
+
"aria-multiselectable": f.multiselect,
|
|
103
103
|
class: "border-t p-0.75 custom-scroll overscroll-contain flex-1 min-h-0",
|
|
104
104
|
role: "listbox",
|
|
105
105
|
tabindex: "-1"
|
|
106
106
|
}, [
|
|
107
|
-
(
|
|
108
|
-
id: `${$}-group-${
|
|
109
|
-
key:
|
|
107
|
+
(s(!0), v(m, null, q(H.value, (o, c) => (s(), S(ne, {
|
|
108
|
+
id: `${$}-group-${c}`,
|
|
109
|
+
key: c,
|
|
110
110
|
hidden: (
|
|
111
111
|
// Only show the group label if there are some results
|
|
112
|
-
!o.options.some((n) =>
|
|
112
|
+
!o.options.some((n) => x.value.some((a) => a.id === n.id)) || // And it has a label
|
|
113
113
|
!o.label
|
|
114
114
|
)
|
|
115
115
|
}, {
|
|
116
|
-
label:
|
|
117
|
-
t.$slots.group ?
|
|
116
|
+
label: g(() => [
|
|
117
|
+
t.$slots.group ? B(t.$slots, "group", {
|
|
118
118
|
key: 0,
|
|
119
119
|
group: o
|
|
120
|
-
}) : (
|
|
120
|
+
}) : (s(), v(m, { key: 1 }, [
|
|
121
121
|
ee(F(o.label), 1)
|
|
122
122
|
], 64))
|
|
123
123
|
]),
|
|
124
|
-
default:
|
|
125
|
-
(
|
|
124
|
+
default: g(() => [
|
|
125
|
+
(s(!0), v(m, null, q(x.value, (n) => (s(), v(m, {
|
|
126
126
|
key: n.id
|
|
127
127
|
}, [
|
|
128
|
-
o.options.some((
|
|
128
|
+
o.options.some((a) => a.id === n.id) ? (s(), S(P, {
|
|
129
129
|
key: 0,
|
|
130
|
-
id:
|
|
130
|
+
id: b(n),
|
|
131
131
|
active: l.value?.id === n.id,
|
|
132
|
-
selected: i.value.some((
|
|
133
|
-
onClick: (
|
|
132
|
+
selected: i.value.some((a) => a.id === n.id),
|
|
133
|
+
onClick: (a) => A(n),
|
|
134
134
|
onMousedown: e[4] || (e[4] = y(() => {
|
|
135
135
|
}, ["prevent"])),
|
|
136
|
-
onMouseenter: (
|
|
136
|
+
onMouseenter: (a) => l.value = n
|
|
137
137
|
}, {
|
|
138
|
-
default:
|
|
139
|
-
t.$slots.option ?
|
|
138
|
+
default: g(({ active: a, selected: J }) => [
|
|
139
|
+
t.$slots.option ? B(t.$slots, "option", {
|
|
140
140
|
key: 0,
|
|
141
|
-
active:
|
|
141
|
+
active: a,
|
|
142
142
|
option: n,
|
|
143
143
|
selected: J
|
|
144
|
-
}) : (
|
|
145
|
-
|
|
146
|
-
multiselect:
|
|
144
|
+
}) : (s(), v(m, { key: 1 }, [
|
|
145
|
+
h(V(ie), {
|
|
146
|
+
multiselect: f.multiselect,
|
|
147
147
|
selected: i.value.some((Q) => Q.id === n.id)
|
|
148
148
|
}, null, 8, ["multiselect", "selected"]),
|
|
149
149
|
k("span", ue, F(n.label), 1)
|
|
@@ -155,23 +155,23 @@ const se = { class: "relative flex" }, ae = ["aria-activedescendant", "placehold
|
|
|
155
155
|
]),
|
|
156
156
|
_: 2
|
|
157
157
|
}, 1032, ["id", "hidden"]))), 128)),
|
|
158
|
-
|
|
158
|
+
M.add ? (s(), S(P, {
|
|
159
159
|
key: 0,
|
|
160
|
-
id: p
|
|
161
|
-
active: l.value?.id ===
|
|
160
|
+
id: b(p),
|
|
161
|
+
active: l.value?.id === p.id,
|
|
162
162
|
onClick: T,
|
|
163
163
|
onMousedown: e[5] || (e[5] = y(() => {
|
|
164
164
|
}, ["prevent"])),
|
|
165
|
-
onMouseenter: e[6] || (e[6] = (o) => l.value =
|
|
165
|
+
onMouseenter: e[6] || (e[6] = (o) => l.value = p)
|
|
166
166
|
}, {
|
|
167
|
-
default:
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
default: g(({ active: o }) => [
|
|
168
|
+
h(V(oe), { class: "size-4 p-px" }),
|
|
169
|
+
B(t.$slots, "add", { active: o })
|
|
170
170
|
]),
|
|
171
171
|
_: 3
|
|
172
172
|
}, 8, ["id", "active"])) : K("", !0)
|
|
173
173
|
], 8, de), [
|
|
174
|
-
[te,
|
|
174
|
+
[te, x.value.length || M.add]
|
|
175
175
|
])
|
|
176
176
|
], 64));
|
|
177
177
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as d, createBlock as r, openBlock as i, unref as e, withCtx as t, createVNode as n, normalizeClass as f, renderSlot as
|
|
2
|
-
import { ContextMenuRoot as u, ContextMenuTrigger as c, ContextMenuPortal as g, ContextMenuContent as C, ContextMenuItem as
|
|
1
|
+
import { defineComponent as d, createBlock as r, openBlock as i, unref as e, withCtx as t, createVNode as n, normalizeClass as f, renderSlot as o } from "vue";
|
|
2
|
+
import { ContextMenuRoot as u, ContextMenuTrigger as c, ContextMenuPortal as g, ContextMenuContent as C, ContextMenuItem as m } from "radix-vue";
|
|
3
3
|
const M = /* @__PURE__ */ d({
|
|
4
4
|
__name: "ScalarContextMenu",
|
|
5
5
|
props: {
|
|
@@ -9,16 +9,16 @@ const M = /* @__PURE__ */ d({
|
|
|
9
9
|
disabled: { type: Boolean, default: !1 },
|
|
10
10
|
triggerClass: {}
|
|
11
11
|
},
|
|
12
|
-
setup(
|
|
13
|
-
const l =
|
|
14
|
-
return (
|
|
12
|
+
setup(s) {
|
|
13
|
+
const l = s;
|
|
14
|
+
return (a, p) => (i(), r(e(u), null, {
|
|
15
15
|
default: t(() => [
|
|
16
16
|
n(e(c), {
|
|
17
17
|
class: f(s.triggerClass),
|
|
18
18
|
disabled: l.disabled
|
|
19
19
|
}, {
|
|
20
20
|
default: t(() => [
|
|
21
|
-
a
|
|
21
|
+
o(a.$slots, "trigger")
|
|
22
22
|
]),
|
|
23
23
|
_: 3
|
|
24
24
|
}, 8, ["class", "disabled"]),
|
|
@@ -30,9 +30,9 @@ const M = /* @__PURE__ */ d({
|
|
|
30
30
|
sideOffset: l.sideOffset
|
|
31
31
|
}, {
|
|
32
32
|
default: t(() => [
|
|
33
|
-
n(e(
|
|
33
|
+
n(e(m), null, {
|
|
34
34
|
default: t(() => [
|
|
35
|
-
a
|
|
35
|
+
o(a.$slots, "content")
|
|
36
36
|
]),
|
|
37
37
|
_: 3
|
|
38
38
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as B, mergeModels as D, ref as b, useModel as g, useId as
|
|
1
|
+
import { defineComponent as B, mergeModels as D, ref as b, useModel as g, useId as $, watch as I, computed as K, createBlock as L, openBlock as M, unref as m, mergeProps as R, createSlots as N, withCtx as A, renderSlot as C, createVNode as q, createElementVNode as O, withKeys as a, withModifiers as r, nextTick as E } from "vue";
|
|
2
2
|
import { useBindCx as U } from "@scalar/use-hooks/useBindCx";
|
|
3
3
|
import { onClickOutside as V } from "@vueuse/core";
|
|
4
4
|
import j from "./ScalarDropdownMenu.vue.js";
|
|
@@ -20,24 +20,24 @@ const P = ["id", "aria-activedescendant", "aria-labelledby", "onKeydown"], G = {
|
|
|
20
20
|
openModifiers: {}
|
|
21
21
|
}),
|
|
22
22
|
emits: ["update:open"],
|
|
23
|
-
setup(
|
|
24
|
-
const l = b(),
|
|
25
|
-
async function
|
|
26
|
-
n.value = !n.value, await
|
|
23
|
+
setup(k) {
|
|
24
|
+
const l = b(), i = b(), n = g(k, "open"), { active: o } = z(), v = $(), f = b(v), y = $();
|
|
25
|
+
async function x() {
|
|
26
|
+
n.value = !n.value, await E(), n.value && i.value?.focus();
|
|
27
27
|
}
|
|
28
28
|
async function h(e) {
|
|
29
29
|
if (["ArrowDown", "ArrowUp", " ", "Enter"].includes(e.key))
|
|
30
30
|
e.preventDefault();
|
|
31
31
|
else return;
|
|
32
|
-
n.value || (n.value = !0), await
|
|
32
|
+
n.value || (n.value = !0), await E(), i.value?.focus(), ["ArrowDown", " ", "Enter"].includes(e.key) ? c(1) : e.key === "ArrowUp" && c(-1);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
I(
|
|
35
35
|
() => l.value?.targetRef,
|
|
36
36
|
(e, t) => {
|
|
37
|
-
e && (e.id ? f.value = e.id : (f.value = v, e.setAttribute("id", f.value)), e.setAttribute("aria-haspopup", "menu"), e.setAttribute("aria-expanded", `${n.value}`), n.value && e.setAttribute("aria-controls", y), e.addEventListener("click",
|
|
37
|
+
e && (e.id ? f.value = e.id : (f.value = v, e.setAttribute("id", f.value)), e.setAttribute("aria-haspopup", "menu"), e.setAttribute("aria-expanded", `${n.value}`), n.value && e.setAttribute("aria-controls", y), e.addEventListener("click", x), e.addEventListener("keydown", h)), t && t !== e && (t.id === v && t.removeAttribute("id"), t.removeAttribute("aria-controls"), t.removeAttribute("aria-haspopup"), t.removeAttribute("aria-expanded"), t.removeEventListener("click", x), t.removeEventListener("keydown", h));
|
|
38
38
|
},
|
|
39
39
|
{ immediate: !0 }
|
|
40
|
-
),
|
|
40
|
+
), I(
|
|
41
41
|
n,
|
|
42
42
|
(e) => {
|
|
43
43
|
const t = l.value?.targetRef;
|
|
@@ -48,75 +48,75 @@ const P = ["id", "aria-activedescendant", "aria-labelledby", "onKeydown"], G = {
|
|
|
48
48
|
async function u() {
|
|
49
49
|
l.value?.targetRef?.focus(), n.value = !1;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
if (!o.value || !
|
|
53
|
-
const e =
|
|
51
|
+
function w() {
|
|
52
|
+
if (!o.value || !i.value) return;
|
|
53
|
+
const e = i.value.querySelector(
|
|
54
54
|
`#${o.value}[role="menuitem"]:not([aria-disabled="true"])`
|
|
55
55
|
);
|
|
56
56
|
e && (e.click(), u());
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
if (!n.value || !
|
|
58
|
+
function c(e) {
|
|
59
|
+
if (!n.value || !i.value) return;
|
|
60
60
|
const t = Array.from(
|
|
61
|
-
|
|
61
|
+
i.value.querySelectorAll(
|
|
62
62
|
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
63
63
|
)
|
|
64
64
|
);
|
|
65
65
|
if (t.length === 0) return;
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
66
|
+
const d = t.findIndex((p) => p.id === o.value);
|
|
67
|
+
if (d === -1) {
|
|
68
68
|
const p = t[e > 0 ? 0 : t.length - 1];
|
|
69
69
|
p?.id && (o.value = p.id);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const s =
|
|
72
|
+
const s = d + e;
|
|
73
73
|
if (s < 0 || s > t.length - 1)
|
|
74
74
|
return;
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const _ = t[s];
|
|
76
|
+
_?.id && (o.value = _.id);
|
|
77
77
|
}
|
|
78
|
-
V(
|
|
78
|
+
V(i, u, {
|
|
79
79
|
ignore: [K(() => l.value?.targetRef)]
|
|
80
80
|
});
|
|
81
81
|
const { cx: S } = U();
|
|
82
|
-
return (e, t) => (M(), L(m(F),
|
|
82
|
+
return (e, t) => (M(), L(m(F), R({
|
|
83
83
|
ref_key: "floatingRef",
|
|
84
84
|
ref: l
|
|
85
85
|
}, e.$props, {
|
|
86
|
-
placement:
|
|
86
|
+
placement: k.placement ?? "bottom-start"
|
|
87
87
|
}), N({
|
|
88
88
|
default: A(() => [
|
|
89
|
-
|
|
89
|
+
C(e.$slots, "default", { open: n.value })
|
|
90
90
|
]),
|
|
91
91
|
_: 2
|
|
92
92
|
}, [
|
|
93
93
|
n.value ? {
|
|
94
94
|
name: "floating",
|
|
95
|
-
fn: A(({ width:
|
|
96
|
-
q(j,
|
|
97
|
-
style: { width:
|
|
95
|
+
fn: A(({ width: d }) => [
|
|
96
|
+
q(j, R({
|
|
97
|
+
style: { width: d }
|
|
98
98
|
}, m(S)("max-h-[inherit] max-w-[inherit]")), {
|
|
99
99
|
menu: A(() => [
|
|
100
100
|
O("div", {
|
|
101
101
|
id: m(y),
|
|
102
102
|
ref_key: "menuRef",
|
|
103
|
-
ref:
|
|
103
|
+
ref: i,
|
|
104
104
|
"aria-activedescendant": m(o),
|
|
105
105
|
"aria-labelledby": f.value,
|
|
106
106
|
class: "flex flex-col p-0.75 outline-none",
|
|
107
107
|
role: "menu",
|
|
108
108
|
tabindex: "-1",
|
|
109
|
-
onClick:
|
|
109
|
+
onClick: r(u, ["stop"]),
|
|
110
110
|
onKeydown: [
|
|
111
|
-
t[0] || (t[0] = a(
|
|
112
|
-
a(
|
|
113
|
-
a(
|
|
114
|
-
a(
|
|
115
|
-
a(
|
|
116
|
-
t[1] || (t[1] = a(
|
|
111
|
+
t[0] || (t[0] = a(r((s) => c(1), ["prevent", "stop"]), ["down"])),
|
|
112
|
+
a(r(w, ["prevent", "stop"]), ["enter"]),
|
|
113
|
+
a(r(u, ["prevent", "stop"]), ["escape"]),
|
|
114
|
+
a(r(w, ["prevent", "stop"]), ["space"]),
|
|
115
|
+
a(r(u, ["prevent", "stop"]), ["tab"]),
|
|
116
|
+
t[1] || (t[1] = a(r((s) => c(-1), ["prevent", "stop"]), ["up"]))
|
|
117
117
|
]
|
|
118
118
|
}, [
|
|
119
|
-
|
|
119
|
+
C(e.$slots, "items", { open: n.value })
|
|
120
120
|
], 40, P)
|
|
121
121
|
]),
|
|
122
122
|
_: 3
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as o, createBlock as
|
|
2
|
-
import { cva as
|
|
3
|
-
const
|
|
4
|
-
...
|
|
1
|
+
import { defineComponent as o, createBlock as i, openBlock as s, resolveDynamicComponent as r, normalizeClass as d, unref as t, withCtx as l, renderSlot as c } from "vue";
|
|
2
|
+
import { cva as u, cx as b } from "@scalar/use-hooks/useBindCx";
|
|
3
|
+
const m = {}, x = /* @__PURE__ */ o({
|
|
4
|
+
...m,
|
|
5
5
|
__name: "ScalarDropdownButton",
|
|
6
6
|
props: {
|
|
7
7
|
is: { default: "button" },
|
|
8
8
|
active: { type: Boolean },
|
|
9
9
|
disabled: { type: Boolean }
|
|
10
10
|
},
|
|
11
|
-
setup(
|
|
12
|
-
const a =
|
|
11
|
+
setup(e) {
|
|
12
|
+
const a = u({
|
|
13
13
|
base: [
|
|
14
14
|
// Layout
|
|
15
15
|
"block h-8 min-w-0 gap-1.5 rounded px-2.5 py-1.5 text-left",
|
|
@@ -24,18 +24,18 @@ const u = {}, _ = /* @__PURE__ */ o({
|
|
|
24
24
|
},
|
|
25
25
|
compoundVariants: [{ disabled: !1, active: !0, class: "bg-b-2" }]
|
|
26
26
|
});
|
|
27
|
-
return (
|
|
27
|
+
return (n, p) => (s(), i(r(e.is), {
|
|
28
28
|
"aria-disabled": e.disabled,
|
|
29
|
-
class:
|
|
29
|
+
class: d(["item", t(b)("scalar-dropdown-item", t(a)({ active: e.active, disabled: e.disabled }))]),
|
|
30
30
|
type: e.is === "button" ? "button" : void 0
|
|
31
31
|
}, {
|
|
32
|
-
default:
|
|
33
|
-
|
|
32
|
+
default: l(() => [
|
|
33
|
+
c(n.$slots, "default", {}, void 0, !0)
|
|
34
34
|
]),
|
|
35
35
|
_: 3
|
|
36
36
|
}, 8, ["aria-disabled", "class", "type"]));
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
x as default
|
|
41
41
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { useDropdownItem as
|
|
4
|
-
const
|
|
5
|
-
...
|
|
1
|
+
import { defineComponent as n, useId as l, createBlock as r, openBlock as a, unref as u, withCtx as m, renderSlot as s } from "vue";
|
|
2
|
+
import f from "./ScalarDropdownButton.vue.js";
|
|
3
|
+
import { useDropdownItem as c } from "./useDropdown.js";
|
|
4
|
+
const p = {}, w = /* @__PURE__ */ n({
|
|
5
|
+
...p,
|
|
6
6
|
__name: "ScalarDropdownItem",
|
|
7
7
|
props: {
|
|
8
|
-
id: { default: () =>
|
|
8
|
+
id: { default: () => l() },
|
|
9
9
|
disabled: { type: Boolean }
|
|
10
10
|
},
|
|
11
11
|
emits: ["click"],
|
|
12
|
-
setup(
|
|
13
|
-
const { active:
|
|
14
|
-
return (
|
|
12
|
+
setup(e) {
|
|
13
|
+
const { active: o } = c();
|
|
14
|
+
return (d, t) => (a(), r(f, {
|
|
15
15
|
id: e.id,
|
|
16
|
-
active:
|
|
16
|
+
active: u(o) === e.id,
|
|
17
17
|
disabled: e.disabled,
|
|
18
18
|
role: "menuitem",
|
|
19
19
|
tabindex: "-1",
|
|
20
|
-
onClick:
|
|
21
|
-
onMouseenter:
|
|
20
|
+
onClick: t[0] || (t[0] = (i) => d.$emit("click", i)),
|
|
21
|
+
onMouseenter: t[1] || (t[1] = (i) => o.value = e.id)
|
|
22
22
|
}, {
|
|
23
|
-
default:
|
|
24
|
-
|
|
23
|
+
default: m(() => [
|
|
24
|
+
s(d.$slots, "default", {}, void 0, !0)
|
|
25
25
|
]),
|
|
26
26
|
_: 3
|
|
27
27
|
}, 8, ["id", "active", "disabled"]));
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useBindCx as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
...
|
|
1
|
+
import { defineComponent as l, createBlock as a, openBlock as c, resolveDynamicComponent as i, normalizeProps as d, guardReactiveProps as m, unref as t, withCtx as f, createElementVNode as s, renderSlot as o, createVNode as p } from "vue";
|
|
2
|
+
import { useBindCx as _ } from "@scalar/use-hooks/useBindCx";
|
|
3
|
+
import u from "../ScalarFloating/ScalarFloatingBackdrop.vue.js";
|
|
4
|
+
const h = { class: "custom-scroll min-h-0 flex-1" }, v = { class: "flex flex-col p-0.75" }, x = {}, B = /* @__PURE__ */ l({
|
|
5
|
+
...x,
|
|
6
6
|
inheritAttrs: !1,
|
|
7
7
|
__name: "ScalarDropdownMenu",
|
|
8
8
|
props: {
|
|
9
9
|
is: {}
|
|
10
10
|
},
|
|
11
|
-
setup(
|
|
12
|
-
const { cx:
|
|
13
|
-
return (e, C) => (
|
|
14
|
-
default:
|
|
15
|
-
|
|
11
|
+
setup(r) {
|
|
12
|
+
const { cx: n } = _();
|
|
13
|
+
return (e, C) => (c(), a(i(r.is ?? "div"), d(m(t(n)("relative flex w-56"))), {
|
|
14
|
+
default: f(() => [
|
|
15
|
+
s("div", h, [
|
|
16
16
|
o(e.$slots, "menu", {}, () => [
|
|
17
|
-
|
|
17
|
+
s("div", v, [
|
|
18
18
|
o(e.$slots, "default")
|
|
19
19
|
])
|
|
20
20
|
]),
|
|
21
21
|
o(e.$slots, "backdrop", {}, () => [
|
|
22
|
-
p(
|
|
22
|
+
p(t(u))
|
|
23
23
|
])
|
|
24
24
|
])
|
|
25
25
|
]),
|