vlite3 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Button.vue.js +1 -1
- package/components/Dropdown/Dropdown.vue.d.ts +16 -12
- package/components/Dropdown/Dropdown.vue.js +127 -114
- package/components/Dropdown/DropdownItem.vue.js +2 -1
- package/components/Dropdown/DropdownMenu.vue.d.ts +3 -3
- package/components/Dropdown/DropdownMenu.vue.js +107 -99
- package/components/Dropdown/composables/useDropdownSelection.d.ts +1 -1
- package/components/Dropdown/composables/useDropdownSelection.js +28 -28
- package/components/NavbarCommandPalette.vue.d.ts +1 -0
- package/components/NavbarCommandPalette.vue.js +21 -20
- package/composables/useTheme.d.ts +1 -0
- package/composables/useTheme.js +20 -12
- package/index.js +118 -117
- package/package.json +1 -1
- package/types/styles.d.ts +11 -0
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as ee, ref as B, computed as v, watch as C, onMounted as te, onBeforeUnmount as le, openBlock as n, createElementBlock as c, createVNode as j, createCommentVNode as d, renderSlot as b, unref as r, normalizeStyle as se, normalizeClass as T, toDisplayString as E, createBlock as m, Fragment as N, renderList as ne, withCtx as P, createElementVNode as S, createSlots as oe, mergeProps as re, nextTick as ae } from "vue";
|
|
2
|
+
import O from "../Icon.vue.js";
|
|
3
3
|
import ce from "../Input.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import ie from "./DropdownItem.vue.js";
|
|
6
|
+
import de from "./DropdownBooleanItem.vue.js";
|
|
7
7
|
import ue from "./DropdownGroupedLayout.vue.js";
|
|
8
8
|
import { useDropdownNavigation as fe } from "./composables/useDropdownNavigation.js";
|
|
9
9
|
import { useDropdownIds as me } from "./composables/useDropdownIds.js";
|
|
10
|
-
import { $t as
|
|
11
|
-
|
|
10
|
+
import { $t as $ } from "../../utils/i18n.js";
|
|
11
|
+
import he from "./Dropdown.vue.js";
|
|
12
|
+
const ve = ["dir"], ye = {
|
|
12
13
|
key: 0,
|
|
13
14
|
class: "bg-body border-b z-10 rounded-t-md shrink-0"
|
|
14
|
-
},
|
|
15
|
+
}, ge = {
|
|
15
16
|
key: 1,
|
|
16
17
|
class: "shrink-0"
|
|
17
|
-
},
|
|
18
|
+
}, be = {
|
|
18
19
|
key: 0,
|
|
19
20
|
class: "px-2 py-6 text-center text-sm text-muted-foreground"
|
|
20
|
-
},
|
|
21
|
+
}, ke = {
|
|
21
22
|
key: 0,
|
|
22
23
|
class: "h-px bg-border my-1 mx-1"
|
|
23
|
-
},
|
|
24
|
+
}, we = ["onMouseenter"], pe = { class: "flex items-center gap-2 flex-1 min-w-0" }, xe = { class: "truncate" }, Se = {
|
|
24
25
|
key: 3,
|
|
25
26
|
class: "flex justify-center py-2"
|
|
26
|
-
},
|
|
27
|
+
}, Oe = {
|
|
27
28
|
key: 3,
|
|
28
29
|
class: "shrink-0"
|
|
29
|
-
},
|
|
30
|
+
}, Ve = /* @__PURE__ */ ee({
|
|
30
31
|
__name: "DropdownMenu",
|
|
31
32
|
props: {
|
|
32
33
|
options: { default: () => [] },
|
|
@@ -48,21 +49,21 @@ const he = ["dir"], ve = {
|
|
|
48
49
|
direction: { default: "ltr" }
|
|
49
50
|
},
|
|
50
51
|
emits: ["select", "close", "load-more", "search"],
|
|
51
|
-
setup(
|
|
52
|
-
const
|
|
53
|
-
const e =
|
|
52
|
+
setup(a, { emit: V }) {
|
|
53
|
+
const t = a, f = V, _ = B(null), h = B(""), { getMenuId: D, getAllRecursiveIds: z } = me(), H = v(() => {
|
|
54
|
+
const e = $("vlite.dropdown.empty");
|
|
54
55
|
return e !== "vlite.dropdown.empty" ? e : "No options found";
|
|
55
|
-
}), L =
|
|
56
|
-
const e =
|
|
56
|
+
}), L = v(() => {
|
|
57
|
+
const e = $("vlite.dropdown.search");
|
|
57
58
|
return e !== "vlite.dropdown.search" ? e : "Search...";
|
|
58
|
-
}),
|
|
59
|
+
}), u = v(() => t.options ? t.options.map((e) => typeof e == "string" || typeof e == "number" ? { label: String(e), value: String(e) } : e) : []), R = v(() => t.remote ? t.searchable : t.searchable && (u.value.length || 0) > 9);
|
|
59
60
|
let k = null;
|
|
60
|
-
|
|
61
|
+
C(h, (e) => {
|
|
61
62
|
t.remote && (k && clearTimeout(k), k = setTimeout(() => {
|
|
62
63
|
e !== void 0 && f("search", e);
|
|
63
64
|
}, t.debounceTime));
|
|
64
65
|
});
|
|
65
|
-
const
|
|
66
|
+
const A = (e) => {
|
|
66
67
|
const s = e.target;
|
|
67
68
|
s.scrollTop + s.clientHeight >= s.scrollHeight - 50 && t.hasMore && !t.loading && f("load-more");
|
|
68
69
|
}, w = (e, s) => {
|
|
@@ -70,63 +71,67 @@ const he = ["dir"], ve = {
|
|
|
70
71
|
}, {
|
|
71
72
|
focusedIndex: y,
|
|
72
73
|
isKeyboardMode: p,
|
|
73
|
-
filteredOptions:
|
|
74
|
-
handleKeyDown:
|
|
75
|
-
handleMouseMove:
|
|
74
|
+
filteredOptions: F,
|
|
75
|
+
handleKeyDown: I,
|
|
76
|
+
handleMouseMove: M,
|
|
76
77
|
onMouseEnterItem: x,
|
|
77
|
-
scrollToIndex:
|
|
78
|
+
scrollToIndex: K
|
|
78
79
|
} = fe({
|
|
79
|
-
options:
|
|
80
|
-
searchQuery:
|
|
81
|
-
containerRef:
|
|
80
|
+
options: u,
|
|
81
|
+
searchQuery: h,
|
|
82
|
+
containerRef: _,
|
|
82
83
|
emit: (e, ...s) => f(e, ...s),
|
|
83
84
|
handleSelect: (e, s) => w(e)
|
|
84
|
-
}), g =
|
|
85
|
+
}), g = v(() => t.remote ? h.value ? u.value : t.cachedOptions.length ? t.cachedOptions : u.value : F.value), U = (e) => {
|
|
85
86
|
if (!(!t.selected || typeof t.selected != "object") && e.key && e.key in t.selected)
|
|
86
87
|
return t.selected[e.key];
|
|
87
|
-
},
|
|
88
|
+
}, q = (e) => e.disabled ? !1 : Array.isArray(t.selected) ? t.selected.includes(e.value) : t.selected && typeof t.selected == "object" && e.key ? t.selected[e.key] === e.value : t.selected === e.value, G = (e) => !e.key || !t.selected || typeof t.selected != "object" ? !1 : !!t.selected[e.key], J = (e, s) => {
|
|
88
89
|
if (!s.key) return;
|
|
89
90
|
const l = {
|
|
90
91
|
label: s.label,
|
|
91
92
|
value: e,
|
|
92
93
|
key: s.key,
|
|
93
|
-
data: s.data
|
|
94
|
+
data: s.data,
|
|
95
|
+
_originalOption: s,
|
|
96
|
+
_path: [s]
|
|
94
97
|
};
|
|
95
98
|
f("select", l);
|
|
96
|
-
},
|
|
99
|
+
}, Q = (e, s) => {
|
|
97
100
|
let l = s.value;
|
|
98
101
|
e.key && (l = { [e.key]: l });
|
|
99
|
-
const
|
|
102
|
+
const o = s.option, i = o?._path || [o?._originalOption || o].filter(Boolean), Z = {
|
|
100
103
|
label: e.label,
|
|
101
104
|
value: l,
|
|
102
105
|
data: s.data,
|
|
103
|
-
key: e.key
|
|
106
|
+
key: e.key,
|
|
107
|
+
_originalOption: o?._originalOption || o,
|
|
108
|
+
_path: [e, ...i]
|
|
104
109
|
};
|
|
105
|
-
f("select",
|
|
106
|
-
},
|
|
110
|
+
f("select", Z);
|
|
111
|
+
}, W = async () => {
|
|
107
112
|
await ae();
|
|
108
113
|
let e = -1;
|
|
109
|
-
t.layout !== "grouped" && (t.selectedIndex !== null && t.selectedIndex >= 0 ? e = t.selectedIndex : t.selected !== void 0 && typeof t.selected != "object" && (e =
|
|
114
|
+
t.layout !== "grouped" && (t.selectedIndex !== null && t.selectedIndex >= 0 ? e = t.selectedIndex : t.selected !== void 0 && typeof t.selected != "object" && (e = u.value.findIndex((s) => s.value === t.selected)), e !== -1 && K(e));
|
|
110
115
|
};
|
|
111
|
-
|
|
116
|
+
C(
|
|
112
117
|
() => g.value,
|
|
113
118
|
() => {
|
|
114
119
|
y.value = -1;
|
|
115
120
|
}
|
|
116
121
|
), te(() => {
|
|
117
|
-
|
|
122
|
+
W(), window.addEventListener("keydown", I);
|
|
118
123
|
}), le(() => {
|
|
119
|
-
window.removeEventListener("keydown",
|
|
124
|
+
window.removeEventListener("keydown", I);
|
|
120
125
|
});
|
|
121
|
-
const
|
|
126
|
+
const X = (e) => e.labelI18n ? $(e.labelI18n) : e.label, Y = (e) => e.showChevron !== !1;
|
|
122
127
|
return (e, s) => (n(), c("div", {
|
|
123
128
|
class: "dropdown-menu w-full min-w-[150px] flex flex-col",
|
|
124
|
-
dir:
|
|
129
|
+
dir: a.direction
|
|
125
130
|
}, [
|
|
126
|
-
R.value ? (n(), c("div",
|
|
127
|
-
|
|
128
|
-
modelValue:
|
|
129
|
-
"onUpdate:modelValue": s[0] || (s[0] = (l) =>
|
|
131
|
+
R.value ? (n(), c("div", ye, [
|
|
132
|
+
j(ce, {
|
|
133
|
+
modelValue: h.value,
|
|
134
|
+
"onUpdate:modelValue": s[0] || (s[0] = (l) => h.value = l),
|
|
130
135
|
placeholder: L.value,
|
|
131
136
|
icon: "lucide:search",
|
|
132
137
|
size: "sm",
|
|
@@ -136,115 +141,118 @@ const he = ["dir"], ve = {
|
|
|
136
141
|
"icon-class": "h-3.5! w-3.5!",
|
|
137
142
|
"show-clear-button": !1
|
|
138
143
|
}, null, 8, ["modelValue", "placeholder"])
|
|
139
|
-
])) :
|
|
140
|
-
e.$slots.header ? (n(), c("div",
|
|
144
|
+
])) : d("", !0),
|
|
145
|
+
e.$slots.header ? (n(), c("div", ge, [
|
|
141
146
|
b(e.$slots, "header")
|
|
142
|
-
])) :
|
|
143
|
-
|
|
147
|
+
])) : d("", !0),
|
|
148
|
+
u.value.length > 0 || e.$slots.menu ? (n(), c("div", {
|
|
144
149
|
key: 2,
|
|
145
150
|
ref_key: "containerRef",
|
|
146
|
-
ref:
|
|
151
|
+
ref: _,
|
|
147
152
|
tabindex: "0",
|
|
148
153
|
role: "menu",
|
|
149
|
-
class:
|
|
154
|
+
class: T([
|
|
150
155
|
"w-full p-1 space-y-0.5 overflow-y-auto overflow-x-hidden focus:outline-none flex-1",
|
|
151
156
|
t.class
|
|
152
157
|
]),
|
|
153
158
|
style: se({ maxHeight: t.maxHeight }),
|
|
154
159
|
onMousemove: s[1] || (s[1] = //@ts-ignore
|
|
155
|
-
(...l) =>
|
|
156
|
-
onScroll:
|
|
160
|
+
(...l) => r(M) && r(M)(...l)),
|
|
161
|
+
onScroll: A
|
|
157
162
|
}, [
|
|
158
|
-
g.value.length === 0 &&
|
|
159
|
-
|
|
163
|
+
g.value.length === 0 && u.value.length > 0 && !a.loading ? (n(), c("div", be, E(H.value), 1)) : d("", !0),
|
|
164
|
+
a.layout === "grouped" ? (n(), m(ue, {
|
|
160
165
|
key: 1,
|
|
161
166
|
options: g.value,
|
|
162
|
-
selected:
|
|
163
|
-
selectable:
|
|
164
|
-
columns:
|
|
167
|
+
selected: a.selected,
|
|
168
|
+
selectable: a.selectable,
|
|
169
|
+
columns: a.columns,
|
|
165
170
|
onSelect: w
|
|
166
|
-
}, null, 8, ["options", "selected", "selectable", "columns"])) : (n(!0), c(
|
|
167
|
-
l.label === "---" ? (n(), c("div",
|
|
171
|
+
}, null, 8, ["options", "selected", "selectable", "columns"])) : (n(!0), c(N, { key: 2 }, ne(g.value, (l, o) => (n(), c(N, { key: o }, [
|
|
172
|
+
l.label === "---" ? (n(), c("div", ke)) : l.data?.isBoolean ? (n(), m(de, {
|
|
168
173
|
key: 1,
|
|
169
174
|
option: l,
|
|
170
|
-
value:
|
|
171
|
-
focused:
|
|
172
|
-
onChange:
|
|
173
|
-
onMouseenter: (i) =>
|
|
174
|
-
}, null, 8, ["option", "value", "focused", "onMouseenter"])) : l.children && l.children.length > 0 ? (n(),
|
|
175
|
+
value: G(l),
|
|
176
|
+
focused: r(p) && r(y) === o,
|
|
177
|
+
onChange: J,
|
|
178
|
+
onMouseenter: (i) => r(x)(o)
|
|
179
|
+
}, null, 8, ["option", "value", "focused", "onMouseenter"])) : l.children && l.children.length > 0 ? (n(), m(he, {
|
|
175
180
|
key: 2,
|
|
181
|
+
"is-nested": !0,
|
|
176
182
|
position: l.position || t.nestedPosition,
|
|
177
183
|
offset: l.offset || t.nestedOffset,
|
|
178
184
|
class: "w-full",
|
|
179
185
|
options: l.children,
|
|
180
|
-
selected:
|
|
181
|
-
menuId:
|
|
186
|
+
selected: U(l),
|
|
187
|
+
menuId: r(D)(l),
|
|
182
188
|
nestedPosition: t.nestedPosition,
|
|
183
189
|
nestedOffset: t.nestedOffset,
|
|
184
190
|
selectable: t.selectable,
|
|
185
|
-
ignoreClickOutside:
|
|
186
|
-
direction:
|
|
187
|
-
onOnSelect: (i) =>
|
|
191
|
+
ignoreClickOutside: r(z)(l.children),
|
|
192
|
+
direction: a.direction,
|
|
193
|
+
onOnSelect: (i) => Q(l, i)
|
|
188
194
|
}, {
|
|
189
|
-
trigger:
|
|
190
|
-
|
|
195
|
+
trigger: P(() => [
|
|
196
|
+
S("div", {
|
|
191
197
|
tabindex: 0,
|
|
192
198
|
"data-dropdown-item": "",
|
|
193
|
-
class:
|
|
194
|
-
|
|
195
|
-
l.disabled ? "opacity-50 cursor-not-allowed" : ""
|
|
199
|
+
class: T(["relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm font-medium outline-none transition-colors justify-between w-full focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:ring-1 focus-visible:ring-primary focus-visible:ring-offset-1", [
|
|
200
|
+
r(p) && r(y) === o ? "bg-accent text-accent-foreground" : "hover:bg-accent hover:text-accent-foreground",
|
|
201
|
+
l.disabled ? "opacity-50 cursor-not-allowed" : "",
|
|
202
|
+
l.triggerClass || l.class || ""
|
|
196
203
|
]]),
|
|
197
|
-
onMouseenter: (i) =>
|
|
204
|
+
onMouseenter: (i) => r(x)(o)
|
|
198
205
|
}, [
|
|
199
|
-
|
|
200
|
-
l.icon || l.emoji ? (n(),
|
|
206
|
+
S("div", pe, [
|
|
207
|
+
l.icon || l.emoji ? (n(), m(O, {
|
|
201
208
|
key: 0,
|
|
202
209
|
icon: l.icon,
|
|
203
210
|
emoji: l.emoji,
|
|
204
211
|
class: "mr-2 h-4 w-4 shrink-0 mt-0.5"
|
|
205
|
-
}, null, 8, ["icon", "emoji"])) :
|
|
206
|
-
|
|
212
|
+
}, null, 8, ["icon", "emoji"])) : d("", !0),
|
|
213
|
+
S("span", xe, E(X(l)), 1)
|
|
207
214
|
]),
|
|
208
|
-
|
|
209
|
-
|
|
215
|
+
Y(l) ? (n(), m(O, {
|
|
216
|
+
key: 0,
|
|
217
|
+
icon: a.direction === "rtl" ? "lucide:chevron-left" : "lucide:chevron-right",
|
|
210
218
|
class: "h-4 w-4 text-muted-foreground shrink-0 ml-2"
|
|
211
|
-
}, null, 8, ["icon"])
|
|
212
|
-
], 42,
|
|
219
|
+
}, null, 8, ["icon"])) : d("", !0)
|
|
220
|
+
], 42, we)
|
|
213
221
|
]),
|
|
214
222
|
_: 2
|
|
215
|
-
}, 1032, ["position", "offset", "options", "selected", "menuId", "nestedPosition", "nestedOffset", "selectable", "ignoreClickOutside", "direction", "onOnSelect"])) : (n(),
|
|
223
|
+
}, 1032, ["position", "offset", "options", "selected", "menuId", "nestedPosition", "nestedOffset", "selectable", "ignoreClickOutside", "direction", "onOnSelect"])) : (n(), m(ie, {
|
|
216
224
|
key: 3,
|
|
217
225
|
option: l,
|
|
218
|
-
index:
|
|
219
|
-
selected:
|
|
220
|
-
focused:
|
|
221
|
-
selectable:
|
|
226
|
+
index: o,
|
|
227
|
+
selected: q(l),
|
|
228
|
+
focused: r(p) && r(y) === o,
|
|
229
|
+
selectable: a.selectable,
|
|
222
230
|
onClick: (i) => w(l),
|
|
223
|
-
onMouseenter: (i) =>
|
|
231
|
+
onMouseenter: (i) => r(x)(o)
|
|
224
232
|
}, oe({ _: 2 }, [
|
|
225
233
|
e.$slots.item ? {
|
|
226
234
|
name: "default",
|
|
227
|
-
fn:
|
|
235
|
+
fn: P((i) => [
|
|
228
236
|
b(e.$slots, "item", re({ ref_for: !0 }, i))
|
|
229
237
|
]),
|
|
230
238
|
key: "0"
|
|
231
239
|
} : void 0
|
|
232
240
|
]), 1032, ["option", "index", "selected", "focused", "selectable", "onClick", "onMouseenter"]))
|
|
233
241
|
], 64))), 128)),
|
|
234
|
-
|
|
235
|
-
|
|
242
|
+
a.loading ? (n(), c("div", Se, [
|
|
243
|
+
j(O, {
|
|
236
244
|
icon: "lucide:loader-2",
|
|
237
245
|
class: "w-4 h-4 animate-spin text-muted-foreground"
|
|
238
246
|
})
|
|
239
|
-
])) :
|
|
247
|
+
])) : d("", !0),
|
|
240
248
|
b(e.$slots, "menu")
|
|
241
|
-
], 38)) :
|
|
242
|
-
e.$slots.footer ? (n(), c("div",
|
|
249
|
+
], 38)) : d("", !0),
|
|
250
|
+
e.$slots.footer ? (n(), c("div", Oe, [
|
|
243
251
|
b(e.$slots, "footer")
|
|
244
|
-
])) :
|
|
245
|
-
], 8,
|
|
252
|
+
])) : d("", !0)
|
|
253
|
+
], 8, ve));
|
|
246
254
|
}
|
|
247
255
|
});
|
|
248
256
|
export {
|
|
249
|
-
|
|
257
|
+
Ve as default
|
|
250
258
|
};
|
|
@@ -11,6 +11,6 @@ type EmitFn = (event: 'update:modelValue' | 'onSelect', ...args: any[]) => void;
|
|
|
11
11
|
export declare function useDropdownSelection(props: UseDropdownSelectionProps, emit: EmitFn): {
|
|
12
12
|
currentValue: import('vue').ComputedRef<any>;
|
|
13
13
|
selectedLabel: import('vue').ComputedRef<string>;
|
|
14
|
-
selectOption: (option: IDropdownOption) =>
|
|
14
|
+
selectOption: (option: IDropdownOption) => any;
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { deepMerge as
|
|
3
|
-
import { $t as
|
|
4
|
-
function h(r,
|
|
5
|
-
const
|
|
6
|
-
for (const
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
1
|
+
import { computed as o } from "vue";
|
|
2
|
+
import { deepMerge as v } from "../../../utils/object.js";
|
|
3
|
+
import { $t as V } from "../../../utils/i18n.js";
|
|
4
|
+
function h(r, c) {
|
|
5
|
+
const n = o(() => r.modelValue !== void 0 ? r.modelValue : r.selected), f = (e = [], a) => {
|
|
6
|
+
for (const l of e) {
|
|
7
|
+
const u = l.labelI18n ? V(l.labelI18n) : l.label;
|
|
8
|
+
if (l.value === a) return u;
|
|
9
|
+
if (l.key && typeof a == "object" && a !== null && l.key in a) {
|
|
10
|
+
if (l.children) {
|
|
11
|
+
const t = f(l.children, a[l.key]);
|
|
12
|
+
if (t) return `${u} / ${t}`;
|
|
13
13
|
}
|
|
14
|
-
return
|
|
14
|
+
return l.value === a[l.key], u;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
return "";
|
|
18
|
-
}, i =
|
|
18
|
+
}, i = o(() => !r.showSelectedLabel || !r.selectable || !r.options?.length ? "" : f(r.options, n.value));
|
|
19
19
|
return {
|
|
20
|
-
currentValue:
|
|
20
|
+
currentValue: n,
|
|
21
21
|
selectedLabel: i,
|
|
22
|
-
selectOption: (
|
|
23
|
-
if (typeof
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
selectOption: (e) => {
|
|
23
|
+
if (typeof e != "string" && e?.disabled) return;
|
|
24
|
+
const a = n.value;
|
|
25
|
+
let l = e?.value ?? e?.label;
|
|
26
|
+
const u = e.data;
|
|
27
|
+
let t;
|
|
28
|
+
if (e.key && (typeof l == "object" && l !== null && e.key in l || (l = { [e.key]: l })), a && typeof a == "object" && !Array.isArray(a) && e.key) {
|
|
29
|
+
const d = e.key, y = e.value ?? e.label, b = a[d] === y;
|
|
29
30
|
if (r.toggleSelection && b) {
|
|
30
|
-
const
|
|
31
|
-
delete d
|
|
32
|
-
return;
|
|
31
|
+
const s = { ...a };
|
|
32
|
+
return delete s[d], t = s, c("update:modelValue", t), c("onSelect", { value: t, data: u, option: e }), t;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
n("update:modelValue", s), n("onSelect", { value: s, data: a });
|
|
34
|
+
t = v(a, l), c("update:modelValue", t), c("onSelect", { value: t, data: u, option: e });
|
|
36
35
|
} else
|
|
37
|
-
r.toggleSelection &&
|
|
36
|
+
r.toggleSelection && a === (e.value ?? e.label) ? (t = void 0, c("update:modelValue", void 0), c("onSelect", { value: void 0, data: u, option: e })) : (t = l, c("update:modelValue", t), c("onSelect", { value: t, data: u, option: e }));
|
|
37
|
+
return t;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -36,6 +36,7 @@ interface Props {
|
|
|
36
36
|
maxResultsPerGroup?: number;
|
|
37
37
|
/** Whether the palette is enabled at all — when false, nothing mounts or listens */
|
|
38
38
|
enabled?: boolean;
|
|
39
|
+
triggerClass?: string;
|
|
39
40
|
}
|
|
40
41
|
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
41
42
|
placeholder: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as h, ref as b, onMounted as y, onUnmounted as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { $t as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as h, ref as b, onMounted as y, onUnmounted as g, watch as v, computed as m, openBlock as x, createElementBlock as w, Fragment as k, createElementVNode as l, normalizeClass as C, createVNode as u, toDisplayString as d, createCommentVNode as I } from "vue";
|
|
2
|
+
import P from "./Icon.vue.js";
|
|
3
|
+
import E from "./Modal.vue.js";
|
|
4
|
+
import K from "./CommandPaletteContent.vue.js";
|
|
5
|
+
import { $t as M } from "../utils/i18n.js";
|
|
6
|
+
const G = { class: "hidden sm:block truncate max-w-[180px] -text-fs-1.5" }, L = { class: "hidden ml-auto lg:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-mono font-medium border border-border/80 bg-background text-muted-foreground ml-1" }, D = /* @__PURE__ */ h({
|
|
7
7
|
__name: "NavbarCommandPalette",
|
|
8
8
|
props: {
|
|
9
9
|
items: { default: () => [] },
|
|
@@ -12,7 +12,8 @@ const M = { class: "hidden sm:block truncate max-w-[180px] -text-fs-1.5" }, G =
|
|
|
12
12
|
placeholder: { default: "Search commands, pages, and actions..." },
|
|
13
13
|
placeholderI18n: {},
|
|
14
14
|
maxResultsPerGroup: { default: 10 },
|
|
15
|
-
enabled: { type: Boolean, default: !0 }
|
|
15
|
+
enabled: { type: Boolean, default: !0 },
|
|
16
|
+
triggerClass: {}
|
|
16
17
|
},
|
|
17
18
|
setup(t) {
|
|
18
19
|
const n = t, o = b(!1), s = () => {
|
|
@@ -25,9 +26,9 @@ const M = { class: "hidden sm:block truncate max-w-[180px] -text-fs-1.5" }, G =
|
|
|
25
26
|
};
|
|
26
27
|
y(() => {
|
|
27
28
|
n.enabled && window.addEventListener("keydown", a);
|
|
28
|
-
}),
|
|
29
|
+
}), g(() => {
|
|
29
30
|
window.removeEventListener("keydown", a);
|
|
30
|
-
}),
|
|
31
|
+
}), v(
|
|
31
32
|
() => n.enabled,
|
|
32
33
|
(e) => {
|
|
33
34
|
e ? window.addEventListener("keydown", a) : (window.removeEventListener("keydown", a), o.value && i());
|
|
@@ -35,36 +36,36 @@ const M = { class: "hidden sm:block truncate max-w-[180px] -text-fs-1.5" }, G =
|
|
|
35
36
|
);
|
|
36
37
|
const c = m(() => {
|
|
37
38
|
if (n.placeholderI18n) {
|
|
38
|
-
const e =
|
|
39
|
+
const e = M(n.placeholderI18n);
|
|
39
40
|
if (e !== n.placeholderI18n) return e;
|
|
40
41
|
}
|
|
41
42
|
return n.placeholder;
|
|
42
43
|
}), p = m(
|
|
43
44
|
() => typeof navigator < "u" ? /mac/i.test(navigator.platform) : !0
|
|
44
45
|
);
|
|
45
|
-
return (e, r) => t.enabled ? (
|
|
46
|
+
return (e, r) => t.enabled ? (x(), w(k, { key: 0 }, [
|
|
46
47
|
l("button", {
|
|
47
48
|
type: "button",
|
|
48
|
-
class: "command-palette-trigger hidden md:inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-muted-foreground bg-muted/60 hover:bg-muted border border-border/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 select-none cursor-pointer shrink-0",
|
|
49
|
+
class: C(["command-palette-trigger hidden md:inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-muted-foreground bg-muted/60 hover:bg-muted border border-border/60 focus-visible:outline-none justify-between focus-visible:ring-2 focus-visible:ring-primary/50 select-none cursor-pointer shrink-0", t.triggerClass]),
|
|
49
50
|
"aria-label": "Open command palette",
|
|
50
51
|
onClick: s
|
|
51
52
|
}, [
|
|
52
|
-
u(
|
|
53
|
+
u(P, {
|
|
53
54
|
icon: "lucide:search",
|
|
54
55
|
class: "w-3.5 h-3.5 shrink-0"
|
|
55
56
|
}),
|
|
56
|
-
l("span",
|
|
57
|
-
l("kbd",
|
|
57
|
+
l("span", G, d(c.value.split(",")[0]) + "...", 1),
|
|
58
|
+
l("kbd", L, [
|
|
58
59
|
l("span", null, d(p.value ? "⌘" : "Ctrl"), 1),
|
|
59
60
|
l("span", null, d(t.shortcutKey.toUpperCase()), 1)
|
|
60
61
|
])
|
|
61
|
-
]),
|
|
62
|
-
u(
|
|
62
|
+
], 2),
|
|
63
|
+
u(E, {
|
|
63
64
|
show: o.value,
|
|
64
65
|
"onUpdate:show": r[0] || (r[0] = (f) => o.value = f),
|
|
65
66
|
maxWidth: "max-w-2xl",
|
|
66
67
|
bodyClass: "!p-0 flex flex-col h-full",
|
|
67
|
-
body:
|
|
68
|
+
body: K,
|
|
68
69
|
bodyProps: {
|
|
69
70
|
items: t.items,
|
|
70
71
|
menuItems: t.menuItems,
|
|
@@ -73,9 +74,9 @@ const M = { class: "hidden sm:block truncate max-w-[180px] -text-fs-1.5" }, G =
|
|
|
73
74
|
maxResultsPerGroup: t.maxResultsPerGroup
|
|
74
75
|
}
|
|
75
76
|
}, null, 8, ["show", "bodyProps"])
|
|
76
|
-
], 64)) :
|
|
77
|
+
], 64)) : I("", !0);
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
export {
|
|
80
|
-
|
|
81
|
+
D as default
|
|
81
82
|
};
|
package/composables/useTheme.js
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const t = o(
|
|
3
|
-
function
|
|
1
|
+
import { ref as a, watch as d, onMounted as r } from "vue";
|
|
2
|
+
const t = a(o());
|
|
3
|
+
function o() {
|
|
4
|
+
if (typeof window > "u") return "light";
|
|
4
5
|
const e = localStorage.getItem("builto-theme");
|
|
5
|
-
return e === "light" || e === "dark" ? e : window.matchMedia
|
|
6
|
+
return e === "light" || e === "dark" ? e : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
6
7
|
}
|
|
7
8
|
function n(e) {
|
|
8
9
|
document.documentElement.classList.remove("light", "dark"), document.documentElement.classList.add(e);
|
|
9
10
|
}
|
|
11
|
+
function l() {
|
|
12
|
+
typeof window > "u" || !window.matchMedia || window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => {
|
|
13
|
+
localStorage.getItem("builto-theme") || (t.value = e.matches ? "dark" : "light", n(t.value));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function u() {
|
|
17
|
+
t.value = o(), n(t.value), l();
|
|
18
|
+
}
|
|
10
19
|
function c() {
|
|
11
|
-
|
|
20
|
+
d(
|
|
12
21
|
t,
|
|
13
|
-
(
|
|
14
|
-
localStorage.setItem("builto-theme",
|
|
22
|
+
(i) => {
|
|
23
|
+
localStorage.setItem("builto-theme", i), n(i);
|
|
15
24
|
},
|
|
16
25
|
{ immediate: !0 }
|
|
17
|
-
),
|
|
18
|
-
|
|
26
|
+
), r(() => {
|
|
27
|
+
document.documentElement.classList.add("bg-body");
|
|
19
28
|
});
|
|
20
29
|
function e() {
|
|
21
30
|
t.value = t.value === "light" ? "dark" : "light";
|
|
22
31
|
}
|
|
23
|
-
return
|
|
24
|
-
document.documentElement.classList.add("bg-body");
|
|
25
|
-
}), {
|
|
32
|
+
return {
|
|
26
33
|
theme: t,
|
|
27
34
|
toggleTheme: e
|
|
28
35
|
};
|
|
29
36
|
}
|
|
30
37
|
export {
|
|
38
|
+
u as initializeTheme,
|
|
31
39
|
c as useTheme
|
|
32
40
|
};
|