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.
@@ -1,32 +1,33 @@
1
- import { defineComponent as Z, defineAsyncComponent as ee, ref as j, computed as h, watch as T, onMounted as te, onBeforeUnmount as le, openBlock as n, createElementBlock as c, createVNode as S, createCommentVNode as u, renderSlot as b, unref as o, normalizeStyle as se, normalizeClass as _, toDisplayString as D, createBlock as v, Fragment as E, renderList as ne, withCtx as N, createElementVNode as $, createSlots as oe, mergeProps as re, nextTick as ae } from "vue";
2
- import I from "../Icon.vue.js";
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 de from "./DropdownItem.vue.js";
6
- import ie from "./DropdownBooleanItem.vue.js";
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 M } from "../../utils/i18n.js";
11
- const he = ["dir"], ve = {
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
- }, ye = {
15
+ }, ge = {
15
16
  key: 1,
16
17
  class: "shrink-0"
17
- }, ge = {
18
+ }, be = {
18
19
  key: 0,
19
20
  class: "px-2 py-6 text-center text-sm text-muted-foreground"
20
- }, be = {
21
+ }, ke = {
21
22
  key: 0,
22
23
  class: "h-px bg-border my-1 mx-1"
23
- }, ke = ["onMouseenter"], we = { class: "flex items-center gap-2 flex-1 min-w-0" }, pe = { class: "truncate" }, xe = {
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
- }, Se = {
27
+ }, Oe = {
27
28
  key: 3,
28
29
  class: "shrink-0"
29
- }, Ee = /* @__PURE__ */ Z({
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(r, { emit: V }) {
52
- const P = ee(() => import("./Dropdown.vue2.js")), t = r, f = V, O = j(null), m = j(""), { getMenuId: z, getAllRecursiveIds: H } = me(), A = h(() => {
53
- const e = M("vlite.dropdown.empty");
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 = h(() => {
56
- const e = M("vlite.dropdown.search");
56
+ }), L = v(() => {
57
+ const e = $("vlite.dropdown.search");
57
58
  return e !== "vlite.dropdown.search" ? e : "Search...";
58
- }), d = h(() => t.options ? t.options.map((e) => typeof e == "string" || typeof e == "number" ? { label: String(e), value: String(e) } : e) : []), R = h(() => t.remote ? t.searchable : t.searchable && (d.value.length || 0) > 9);
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
- T(m, (e) => {
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 F = (e) => {
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: K,
74
- handleKeyDown: B,
75
- handleMouseMove: C,
74
+ filteredOptions: F,
75
+ handleKeyDown: I,
76
+ handleMouseMove: M,
76
77
  onMouseEnterItem: x,
77
- scrollToIndex: U
78
+ scrollToIndex: K
78
79
  } = fe({
79
- options: d,
80
- searchQuery: m,
81
- containerRef: O,
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 = h(() => t.remote ? m.value ? d.value : t.cachedOptions.length ? t.cachedOptions : d.value : K.value), q = (e) => {
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
- }, G = (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, J = (e) => !e.key || !t.selected || typeof t.selected != "object" ? !1 : !!t.selected[e.key], Q = (e, s) => {
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
- }, W = (e, s) => {
99
+ }, Q = (e, s) => {
97
100
  let l = s.value;
98
101
  e.key && (l = { [e.key]: l });
99
- const a = {
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", a);
106
- }, X = async () => {
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 = d.value.findIndex((s) => s.value === t.selected)), e !== -1 && U(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
- T(
116
+ C(
112
117
  () => g.value,
113
118
  () => {
114
119
  y.value = -1;
115
120
  }
116
121
  ), te(() => {
117
- X(), window.addEventListener("keydown", B);
122
+ W(), window.addEventListener("keydown", I);
118
123
  }), le(() => {
119
- window.removeEventListener("keydown", B);
124
+ window.removeEventListener("keydown", I);
120
125
  });
121
- const Y = (e) => e.labelI18n ? M(e.labelI18n) : e.label;
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: r.direction
129
+ dir: a.direction
125
130
  }, [
126
- R.value ? (n(), c("div", ve, [
127
- S(ce, {
128
- modelValue: m.value,
129
- "onUpdate:modelValue": s[0] || (s[0] = (l) => m.value = 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
- ])) : u("", !0),
140
- e.$slots.header ? (n(), c("div", ye, [
144
+ ])) : d("", !0),
145
+ e.$slots.header ? (n(), c("div", ge, [
141
146
  b(e.$slots, "header")
142
- ])) : u("", !0),
143
- d.value.length > 0 || e.$slots.menu ? (n(), c("div", {
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: O,
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) => o(C) && o(C)(...l)),
156
- onScroll: F
160
+ (...l) => r(M) && r(M)(...l)),
161
+ onScroll: A
157
162
  }, [
158
- g.value.length === 0 && d.value.length > 0 && !r.loading ? (n(), c("div", ge, D(A.value), 1)) : u("", !0),
159
- r.layout === "grouped" ? (n(), v(ue, {
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: r.selected,
163
- selectable: r.selectable,
164
- columns: r.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(E, { key: 2 }, ne(g.value, (l, a) => (n(), c(E, { key: a }, [
167
- l.label === "---" ? (n(), c("div", be)) : l.data?.isBoolean ? (n(), v(ie, {
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: J(l),
171
- focused: o(p) && o(y) === a,
172
- onChange: Q,
173
- onMouseenter: (i) => o(x)(a)
174
- }, null, 8, ["option", "value", "focused", "onMouseenter"])) : l.children && l.children.length > 0 ? (n(), v(o(P), {
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: q(l),
181
- menuId: o(z)(l),
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: o(H)(l.children),
186
- direction: r.direction,
187
- onOnSelect: (i) => W(l, i)
191
+ ignoreClickOutside: r(z)(l.children),
192
+ direction: a.direction,
193
+ onOnSelect: (i) => Q(l, i)
188
194
  }, {
189
- trigger: N(() => [
190
- $("div", {
195
+ trigger: P(() => [
196
+ S("div", {
191
197
  tabindex: 0,
192
198
  "data-dropdown-item": "",
193
- class: _(["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", [
194
- o(p) && o(y) === a ? "bg-accent text-accent-foreground" : "hover:bg-accent hover:text-accent-foreground",
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) => o(x)(a)
204
+ onMouseenter: (i) => r(x)(o)
198
205
  }, [
199
- $("div", we, [
200
- l.icon || l.emoji ? (n(), v(I, {
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"])) : u("", !0),
206
- $("span", pe, D(Y(l)), 1)
212
+ }, null, 8, ["icon", "emoji"])) : d("", !0),
213
+ S("span", xe, E(X(l)), 1)
207
214
  ]),
208
- S(I, {
209
- icon: r.direction === "rtl" ? "lucide:chevron-left" : "lucide:chevron-right",
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, ke)
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(), v(de, {
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: a,
219
- selected: G(l),
220
- focused: o(p) && o(y) === a,
221
- selectable: r.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) => o(x)(a)
231
+ onMouseenter: (i) => r(x)(o)
224
232
  }, oe({ _: 2 }, [
225
233
  e.$slots.item ? {
226
234
  name: "default",
227
- fn: N((i) => [
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
- r.loading ? (n(), c("div", xe, [
235
- S(I, {
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
- ])) : u("", !0),
247
+ ])) : d("", !0),
240
248
  b(e.$slots, "menu")
241
- ], 38)) : u("", !0),
242
- e.$slots.footer ? (n(), c("div", Se, [
249
+ ], 38)) : d("", !0),
250
+ e.$slots.footer ? (n(), c("div", Oe, [
243
251
  b(e.$slots, "footer")
244
- ])) : u("", !0)
245
- ], 8, he));
252
+ ])) : d("", !0)
253
+ ], 8, ve));
246
254
  }
247
255
  });
248
256
  export {
249
- Ee as default
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) => void;
14
+ selectOption: (option: IDropdownOption) => any;
15
15
  };
16
16
  export {};
@@ -1,40 +1,40 @@
1
- import { computed as f } from "vue";
2
- import { deepMerge as g } from "../../../utils/object.js";
3
- import { $t as k } from "../../../utils/i18n.js";
4
- function h(r, n) {
5
- const u = f(() => r.modelValue !== void 0 ? r.modelValue : r.selected), o = (l = [], t) => {
6
- for (const e of l) {
7
- const a = e.labelI18n ? k(e.labelI18n) : e.label;
8
- if (e.value === t) return a;
9
- if (e.key && typeof t == "object" && t !== null && e.key in t) {
10
- if (e.children) {
11
- const c = o(e.children, t[e.key]);
12
- if (c) return `${a} / ${c}`;
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 e.value === t[e.key], a;
14
+ return l.value === a[l.key], u;
15
15
  }
16
16
  }
17
17
  return "";
18
- }, i = f(() => !r.showSelectedLabel || !r.selectable || !r.options?.length ? "" : o(r.options, u.value));
18
+ }, i = o(() => !r.showSelectedLabel || !r.selectable || !r.options?.length ? "" : f(r.options, n.value));
19
19
  return {
20
- currentValue: u,
20
+ currentValue: n,
21
21
  selectedLabel: i,
22
- selectOption: (l) => {
23
- if (typeof l != "string" && l?.disabled) return;
24
- const t = u.value;
25
- let e = l?.value ?? l?.label;
26
- const a = l.data;
27
- if (l.key && (typeof e == "object" && e !== null && l.key in e || (e = { [l.key]: e })), t && typeof t == "object" && !Array.isArray(t) && l.key) {
28
- const c = l.key, y = l.value ?? l.label, b = t[c] === y;
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 d = { ...t };
31
- delete d[c], n("update:modelValue", d), n("onSelect", { value: d, data: a });
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
- const s = g(t, e);
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 && t === (l.value ?? l.label) ? (n("update:modelValue", void 0), n("onSelect", { value: void 0, data: a })) : (n("update:modelValue", e), n("onSelect", { value: e, data: a }));
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 v, watch as x, computed as m, openBlock as w, createElementBlock as g, Fragment as k, createElementVNode as l, createVNode as u, toDisplayString as d, createCommentVNode as C } from "vue";
2
- import I from "./Icon.vue.js";
3
- import P from "./Modal.vue.js";
4
- import E from "./CommandPaletteContent.vue.js";
5
- import { $t as K } from "../utils/i18n.js";
6
- const M = { class: "hidden sm:block truncate max-w-[180px] -text-fs-1.5" }, G = { class: "hidden 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" }, V = /* @__PURE__ */ h({
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
- }), v(() => {
29
+ }), g(() => {
29
30
  window.removeEventListener("keydown", a);
30
- }), x(
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 = K(n.placeholderI18n);
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 ? (w(), g(k, { key: 0 }, [
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(I, {
53
+ u(P, {
53
54
  icon: "lucide:search",
54
55
  class: "w-3.5 h-3.5 shrink-0"
55
56
  }),
56
- l("span", M, d(c.value.split(",")[0]) + "...", 1),
57
- l("kbd", G, [
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(P, {
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: E,
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)) : C("", !0);
77
+ ], 64)) : I("", !0);
77
78
  }
78
79
  });
79
80
  export {
80
- V as default
81
+ D as default
81
82
  };
@@ -1,4 +1,5 @@
1
1
  type Theme = 'light' | 'dark';
2
+ export declare function initializeTheme(): void;
2
3
  export declare function useTheme(): {
3
4
  theme: import('vue').Ref<Theme, Theme>;
4
5
  toggleTheme: () => void;
@@ -1,32 +1,40 @@
1
- import { ref as o, watch as m, onMounted as d } from "vue";
2
- const t = o(i());
3
- function i() {
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 && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
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
- m(
20
+ d(
12
21
  t,
13
- (a) => {
14
- localStorage.setItem("builto-theme", a), n(a);
22
+ (i) => {
23
+ localStorage.setItem("builto-theme", i), n(i);
15
24
  },
16
25
  { immediate: !0 }
17
- ), window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (a) => {
18
- localStorage.getItem("builto-theme") || (t.value = a.matches ? "dark" : "light");
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 d(() => {
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
  };