vlite3 0.5.5 → 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.
@@ -105,7 +105,7 @@ const D = ["type", "disabled"], q = /* @__PURE__ */ B({
105
105
  });
106
106
  return (n, r) => G((s(), h("button", {
107
107
  type: e.type,
108
- class: i(y.value),
108
+ class: i([y.value, "cursor-pointer"]),
109
109
  disabled: e.disabled || e.loading
110
110
  }, [
111
111
  e.loading ? (s(), d(g, {
@@ -1,5 +1,5 @@
1
- import o from "./ColorIro.vue2.js";
2
- /* empty css */
1
+ import o from "./ColorIro.vue.js";
2
+ /* empty css */
3
3
  export {
4
4
  o as default
5
5
  };
@@ -5,8 +5,8 @@ import O from "../Input.vue.js";
5
5
  /* empty css */
6
6
  import "../../core/config.js";
7
7
  import y from "../Button.vue.js";
8
- import E from "./ColorIro.vue2.js";
9
- /* empty css */
8
+ import E from "./ColorIro.vue.js";
9
+ /* empty css */
10
10
  import { useEyeDropper as P } from "@vueuse/core";
11
11
  const I = {
12
12
  key: 0,
@@ -34,6 +34,7 @@ type __VLS_Props = {
34
34
  fetchSelected?: (ids: any[]) => Promise<IDropdownOption[]>;
35
35
  triggerProps?: ButtonProps;
36
36
  direction?: 'ltr' | 'rtl';
37
+ isNested?: boolean;
37
38
  };
38
39
  declare function __VLS_template(): {
39
40
  attrs: Partial<{}>;
@@ -61,28 +62,38 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
61
62
  onSelect: (payload: {
62
63
  value: any;
63
64
  data?: any;
65
+ option?: IDropdownOption;
64
66
  }) => any;
65
67
  "update:modelValue": (value: any) => any;
66
- onOpen: () => any;
68
+ "load-more": () => any;
67
69
  onClose: () => any;
70
+ onOpen: () => any;
68
71
  "update:isOpen": (value: boolean) => any;
69
- "load-more": () => any;
70
72
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
71
73
  onSearch?: (query: string) => any;
72
74
  onOnSelect?: (payload: {
73
75
  value: any;
74
76
  data?: any;
77
+ option?: IDropdownOption;
75
78
  }) => any;
76
79
  "onUpdate:modelValue"?: (value: any) => any;
77
- onOnOpen?: () => any;
80
+ "onLoad-more"?: () => any;
78
81
  onOnClose?: () => any;
82
+ onOnOpen?: () => any;
79
83
  "onUpdate:isOpen"?: (value: boolean) => any;
80
- "onLoad-more"?: () => any;
81
84
  }>, {
82
85
  loading: boolean;
83
86
  selectable: boolean;
84
87
  options: (IDropdownOption | string | number)[];
85
88
  columns: number | string;
89
+ selectedIndex: number | null;
90
+ maxHeight: string;
91
+ layout: "default" | "grouped";
92
+ hasMore: boolean;
93
+ searchable: boolean;
94
+ remote: boolean;
95
+ debounceTime: number;
96
+ direction: "ltr" | "rtl";
86
97
  canCloseOutside: boolean;
87
98
  closeOnSelect: boolean;
88
99
  toggleSelection: boolean;
@@ -90,16 +101,9 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
90
101
  offset: [number, number];
91
102
  isOpen: boolean;
92
103
  teleport: boolean;
93
- selectedIndex: number | null;
94
- maxHeight: string;
95
104
  showSelectedLabel: boolean;
96
105
  doubleConfirmation: boolean;
97
- layout: "default" | "grouped";
98
- hasMore: boolean;
99
- searchable: boolean;
100
- remote: boolean;
101
- debounceTime: number;
102
- direction: "ltr" | "rtl";
106
+ isNested: boolean;
103
107
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
104
108
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
105
109
  export default _default;
@@ -1,10 +1,10 @@
1
- import { defineComponent as G, ref as r, computed as v, watch as w, reactive as J, toRefs as K, openBlock as N, createElementBlock as Q, normalizeStyle as W, createVNode as $, unref as g, withCtx as c, renderSlot as u, createBlock as X, normalizeClass as Y, createSlots as Z, normalizeProps as x, guardReactiveProps as H, createCommentVNode as _ } from "vue";
1
+ import { defineComponent as G, ref as r, computed as h, watch as $, reactive as J, toRefs as K, openBlock as x, createElementBlock as Q, normalizeStyle as W, createVNode as k, unref as b, withCtx as u, renderSlot as f, createBlock as X, normalizeClass as Y, createSlots as Z, normalizeProps as H, guardReactiveProps as M, createCommentVNode as _ } from "vue";
2
2
  import ee from "v-tooltip-lite";
3
3
  import "v-tooltip-lite/style.css";
4
4
  import te from "./DropdownMenu.vue.js";
5
5
  import ne from "./DropdownTrigger.vue.js";
6
- import oe from "../ConfirmationModal.vue.js";
7
- import { useDropdownIds as le } from "./composables/useDropdownIds.js";
6
+ import le from "../ConfirmationModal.vue.js";
7
+ import { useDropdownIds as oe } from "./composables/useDropdownIds.js";
8
8
  import { useDropdownSelection as ae } from "./composables/useDropdownSelection.js";
9
9
  const ve = /* @__PURE__ */ G({
10
10
  __name: "Dropdown",
@@ -41,84 +41,85 @@ const ve = /* @__PURE__ */ G({
41
41
  debounceTime: { default: 300 },
42
42
  fetchSelected: {},
43
43
  triggerProps: {},
44
- direction: { default: "ltr" }
44
+ direction: { default: "ltr" },
45
+ isNested: { type: Boolean, default: !1 }
45
46
  },
46
47
  emits: ["onSelect", "update:modelValue", "onOpen", "onClose", "update:isOpen", "load-more", "search"],
47
- setup(o, { emit: M }) {
48
- const l = o, y = M, h = r(!1), d = r(null), s = r({
48
+ setup(l, { emit: V }) {
49
+ const o = l, p = V, g = r(!1), d = r(null), s = r({
49
50
  title: "Confirm Selection",
50
51
  description: "Are you sure you want to select this option?",
51
52
  confirmText: "Confirm",
52
53
  cancelText: "Cancel",
53
54
  variant: "primary"
54
- }), A = v(() => l.position ? l.position : l.direction === "rtl" ? "bottom-end" : "bottom-start"), L = v(() => l.nestedPosition ? l.nestedPosition : l.direction === "rtl" ? "left-start" : "right-start"), b = r(l.isOpen || !1);
55
- w(
56
- () => l.isOpen,
55
+ }), A = h(() => o.position ? o.position : o.direction === "rtl" ? "bottom-end" : "bottom-start"), E = h(() => o.nestedPosition ? o.nestedPosition : o.direction === "rtl" ? "left-start" : "right-start"), O = r(o.isOpen || !1);
56
+ $(
57
+ () => o.isOpen,
57
58
  (e) => {
58
- e !== void 0 && (b.value = e);
59
+ e !== void 0 && (O.value = e);
59
60
  }
60
61
  );
61
- const k = (e) => {
62
- b.value = e, y("update:isOpen", e), y(e ? "onOpen" : "onClose");
63
- }, O = v(() => l.options ? l.options.map((e) => typeof e == "string" || typeof e == "number" ? { label: String(e), value: String(e) } : e) : []), f = r([]);
64
- w(
65
- O,
62
+ const B = (e) => {
63
+ O.value = e, p("update:isOpen", e), p(e ? "onOpen" : "onClose");
64
+ }, C = h(() => o.options ? o.options.map((e) => typeof e == "string" || typeof e == "number" ? { label: String(e), value: String(e) } : e) : []), m = r([]);
65
+ $(
66
+ C,
66
67
  (e) => {
67
68
  if (e)
68
- if (l.remote) {
69
- const t = [...f.value];
70
- e.forEach((n) => {
71
- t.some((a) => a.value !== void 0 && n.value !== void 0 ? typeof a.value == "object" && a.key && n.key ? a.key === n.key && a.value[a.key] === n.value[n.key] : a.value === n.value : a.label === n.label) || t.push(n);
72
- }), f.value = t;
69
+ if (o.remote) {
70
+ const n = [...m.value];
71
+ e.forEach((t) => {
72
+ n.some((a) => a.value !== void 0 && t.value !== void 0 ? typeof a.value == "object" && a.key && t.key ? a.key === t.key && a.value[a.key] === t.value[t.key] : a.value === t.value : a.label === t.label) || n.push(t);
73
+ }), m.value = n;
73
74
  } else
74
- f.value = e;
75
+ m.value = e;
75
76
  },
76
77
  { immediate: !0, deep: !0 }
77
78
  );
78
- const m = r(/* @__PURE__ */ new Map()), C = r(!1), V = async (e) => {
79
- if (!l.fetchSelected || e === void 0 || e === null) return;
80
- let t = [];
81
- Array.isArray(e) ? t = e : typeof e == "object" ? t = Object.values(e) : t = [e];
82
- const n = t.filter((i) => {
83
- const a = m.value.has(i), q = f.value.some((I) => (I.value ?? I.label) === i);
84
- return !a && !q;
79
+ const v = r(/* @__PURE__ */ new Map()), S = r(!1), L = async (e) => {
80
+ if (!o.fetchSelected || e === void 0 || e === null) return;
81
+ let n = [];
82
+ Array.isArray(e) ? n = e : typeof e == "object" ? n = Object.values(e) : n = [e];
83
+ const t = n.filter((i) => {
84
+ const a = v.value.has(i), N = m.value.some((c) => (c.value ?? c.label) === i);
85
+ return !a && !N;
85
86
  });
86
- if (n.length) {
87
- C.value = !0;
87
+ if (t.length) {
88
+ S.value = !0;
88
89
  try {
89
- (await l.fetchSelected(n)).forEach((a) => {
90
- m.value.set(a.value ?? a.label, a);
90
+ (await o.fetchSelected(t)).forEach((a) => {
91
+ v.value.set(a.value ?? a.label, a);
91
92
  });
92
93
  } catch (i) {
93
94
  console.error("[Dropdown] Hydration failed:", i);
94
95
  } finally {
95
- C.value = !1;
96
+ S.value = !1;
96
97
  }
97
98
  }
98
- }, p = v(() => {
99
- const e = [...f.value], t = new Set(e.map((n) => n.value ?? n.label));
100
- return m.value.forEach((n, i) => {
101
- t.has(i) || (e.unshift(n), t.add(i));
99
+ }, y = h(() => {
100
+ const e = [...m.value], n = new Set(e.map((t) => t.value ?? t.label));
101
+ return v.value.forEach((t, i) => {
102
+ n.has(i) || (e.unshift(t), n.add(i));
102
103
  }), e;
103
- }), { getAllRecursiveIds: j } = le(), z = J({
104
- ...K(l),
105
- options: p
106
- }), { currentValue: B, selectedLabel: T, selectOption: D } = ae(
104
+ }), { getAllRecursiveIds: j } = oe(), z = J({
105
+ ...K(o),
106
+ options: y
107
+ }), { currentValue: T, selectedLabel: P, selectOption: D } = ae(
107
108
  z,
108
- y
109
+ p
109
110
  );
110
- w(
111
- () => B.value,
111
+ $(
112
+ () => T.value,
112
113
  (e) => {
113
- V(e);
114
+ L(e);
114
115
  },
115
116
  { immediate: !0, deep: !0 }
116
117
  );
117
- const E = v(() => {
118
- const e = l.ignoreClickOutside || [], t = j(p.value);
119
- return [.../* @__PURE__ */ new Set([...e, ...t])];
120
- }), R = (e) => {
121
- l.doubleConfirmation || !!e.confirmation ? (d.value = e, typeof e.confirmation == "object" ? s.value = {
118
+ const R = h(() => {
119
+ const e = o.ignoreClickOutside || [], n = j(y.value);
120
+ return [.../* @__PURE__ */ new Set([...e, ...n])];
121
+ }), F = (e) => {
122
+ o.doubleConfirmation || !!e.confirmation ? (d.value = e, typeof e.confirmation == "object" ? s.value = {
122
123
  title: e.confirmation.title || "Confirm Selection",
123
124
  description: e.confirmation.description || "Are you sure you want to select this option?",
124
125
  confirmText: e.confirmation.confirmText || "Confirm",
@@ -130,101 +131,113 @@ const ve = /* @__PURE__ */ G({
130
131
  confirmText: "Confirm",
131
132
  cancelText: "Cancel",
132
133
  variant: "primary"
133
- }, h.value = !0, S()) : (P(e), l.closeOnSelect && S());
134
- }, P = (e) => {
135
- const t = e.value ?? e.label;
136
- m.value.has(t) || m.value.set(t, e), D(e);
137
- }, F = () => {
138
- d.value && (P(d.value), d.value = null, h.value = !1);
134
+ }, g.value = !0, w()) : (I(e), o.closeOnSelect && w());
135
+ }, I = (e) => {
136
+ const n = e.value ?? e.label;
137
+ v.value.has(n) || v.value.set(n, e);
138
+ const t = D(e);
139
+ if (!o.isNested) {
140
+ const i = e._originalOption || e, a = i.value ?? i.label;
141
+ (e._path || [i]).forEach((c) => {
142
+ typeof c.onSelect == "function" && c.onSelect({
143
+ value: a,
144
+ option: c,
145
+ data: y.value || [],
146
+ values: t
147
+ });
148
+ });
149
+ }
139
150
  }, U = () => {
140
- d.value = null, h.value = !1;
141
- }, S = () => {
142
- k(!1);
151
+ d.value && (I(d.value), d.value = null, g.value = !1);
152
+ }, q = () => {
153
+ d.value = null, g.value = !1;
154
+ }, w = () => {
155
+ B(!1);
143
156
  };
144
- return (e, t) => (N(), Q("div", {
157
+ return (e, n) => (x(), Q("div", {
145
158
  class: "relative inline-block text-left",
146
- style: W({ direction: o.direction })
159
+ style: W({ direction: l.direction })
147
160
  }, [
148
- $(g(ee), {
161
+ k(b(ee), {
149
162
  content: "",
150
163
  trigger: "click",
151
164
  arrow: !1,
152
- teleport: o.teleport,
153
- offset: o.offset,
165
+ teleport: l.teleport,
166
+ offset: l.offset,
154
167
  placement: A.value,
155
- isOpen: b.value,
156
- menuId: o.menuId,
157
- ignoreClickOutside: E.value,
168
+ isOpen: O.value,
169
+ menuId: l.menuId,
170
+ ignoreClickOutside: R.value,
158
171
  class: "w-full",
159
- className: "dropdown " + (o.className || ""),
160
- onOnShow: t[2] || (t[2] = (n) => e.$emit("onOpen")),
161
- onOnHide: t[3] || (t[3] = (n) => e.$emit("onClose")),
162
- "onUpdate:isOpen": k,
172
+ className: "dropdown " + (l.className || ""),
173
+ onOnShow: n[2] || (n[2] = (t) => e.$emit("onOpen")),
174
+ onOnHide: n[3] || (n[3] = (t) => e.$emit("onClose")),
175
+ "onUpdate:isOpen": B,
163
176
  triggerClass: "w-full",
164
177
  styles: { padding: "0" }
165
178
  }, {
166
- trigger: c(({ isOpen: n }) => [
167
- u(e.$slots, "trigger", x(H({ selectedLabel: g(T), isOpen: n })), () => [
168
- $(ne, {
169
- "selected-label": g(T),
170
- "is-open": n,
171
- direction: o.direction,
172
- triggerProps: o.triggerProps,
179
+ trigger: u(({ isOpen: t }) => [
180
+ f(e.$slots, "trigger", H(M({ selectedLabel: b(P), isOpen: t })), () => [
181
+ k(ne, {
182
+ "selected-label": b(P),
183
+ "is-open": t,
184
+ direction: l.direction,
185
+ triggerProps: l.triggerProps,
173
186
  class: "w-full"
174
187
  }, null, 8, ["selected-label", "is-open", "direction", "triggerProps"])
175
188
  ])
176
189
  ]),
177
- default: c(() => [
178
- u(e.$slots, "default"),
179
- O.value.length || p.value.length || e.$slots.menu || e.$slots.item || o.remote || o.searchable ? (N(), X(te, {
190
+ default: u(() => [
191
+ f(e.$slots, "default"),
192
+ C.value.length || y.value.length || e.$slots.menu || e.$slots.item || l.remote || l.searchable ? (x(), X(te, {
180
193
  key: 0,
181
- options: O.value,
182
- cachedOptions: p.value,
183
- class: Y(o.className),
184
- selected: g(B),
185
- selectedIndex: o.selectedIndex,
186
- maxHeight: o.maxHeight,
187
- nestedPosition: L.value,
188
- nestedOffset: o.nestedOffset,
189
- selectable: o.selectable,
190
- direction: o.direction,
191
- layout: o.layout,
192
- columns: o.columns,
193
- loading: o.loading || C.value,
194
- hasMore: o.hasMore,
195
- searchable: o.searchable,
196
- remote: o.remote,
197
- debounceTime: o.debounceTime,
198
- onSelect: R,
199
- onClose: S,
200
- onLoadMore: t[0] || (t[0] = (n) => e.$emit("load-more")),
201
- onSearch: t[1] || (t[1] = (n) => e.$emit("search", n))
194
+ options: C.value,
195
+ cachedOptions: y.value,
196
+ class: Y(l.className),
197
+ selected: b(T),
198
+ selectedIndex: l.selectedIndex,
199
+ maxHeight: l.maxHeight,
200
+ nestedPosition: E.value,
201
+ nestedOffset: l.nestedOffset,
202
+ selectable: l.selectable,
203
+ direction: l.direction,
204
+ layout: l.layout,
205
+ columns: l.columns,
206
+ loading: l.loading || S.value,
207
+ hasMore: l.hasMore,
208
+ searchable: l.searchable,
209
+ remote: l.remote,
210
+ debounceTime: l.debounceTime,
211
+ onSelect: F,
212
+ onClose: w,
213
+ onLoadMore: n[0] || (n[0] = (t) => e.$emit("load-more")),
214
+ onSearch: n[1] || (n[1] = (t) => e.$emit("search", t))
202
215
  }, Z({ _: 2 }, [
203
216
  e.$slots.menu ? {
204
217
  name: "menu",
205
- fn: c(() => [
206
- u(e.$slots, "menu")
218
+ fn: u(() => [
219
+ f(e.$slots, "menu")
207
220
  ]),
208
221
  key: "0"
209
222
  } : void 0,
210
223
  e.$slots.item ? {
211
224
  name: "item",
212
- fn: c((n) => [
213
- u(e.$slots, "item", x(H(n)))
225
+ fn: u((t) => [
226
+ f(e.$slots, "item", H(M(t)))
214
227
  ]),
215
228
  key: "1"
216
229
  } : void 0,
217
230
  e.$slots.header ? {
218
231
  name: "header",
219
- fn: c(() => [
220
- u(e.$slots, "header")
232
+ fn: u(() => [
233
+ f(e.$slots, "header")
221
234
  ]),
222
235
  key: "2"
223
236
  } : void 0,
224
237
  e.$slots.footer ? {
225
238
  name: "footer",
226
- fn: c(() => [
227
- u(e.$slots, "footer")
239
+ fn: u(() => [
240
+ f(e.$slots, "footer")
228
241
  ]),
229
242
  key: "3"
230
243
  } : void 0
@@ -232,15 +245,15 @@ const ve = /* @__PURE__ */ G({
232
245
  ]),
233
246
  _: 3
234
247
  }, 8, ["teleport", "offset", "placement", "isOpen", "menuId", "ignoreClickOutside", "className"]),
235
- $(oe, {
236
- show: h.value,
248
+ k(le, {
249
+ show: g.value,
237
250
  title: s.value.title,
238
251
  description: s.value.description,
239
252
  "confirm-text": s.value.confirmText,
240
253
  "cancel-text": s.value.cancelText,
241
254
  variant: s.value.variant,
242
- onConfirm: F,
243
- onCancel: U
255
+ onConfirm: U,
256
+ onCancel: q
244
257
  }, null, 8, ["show", "title", "description", "confirm-text", "cancel-text", "variant"])
245
258
  ], 4));
246
259
  }
@@ -31,7 +31,8 @@ const j = ["data-disabled"], C = { class: "flex flex-col flex-1 min-w-0" }, D =
31
31
  class: h(["relative w-full flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:ring-1 focus-visible:ring-primary focus-visible:ring-offset-1 data-disabled:pointer-events-none data-disabled:opacity-50", [
32
32
  e.selectable && e.selected && !e.option.children ? "bg-accent" : "",
33
33
  e.focused ? "bg-accent text-accent-foreground" : "hover:bg-accent hover:text-accent-foreground",
34
- e.option.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"
34
+ e.option.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
35
+ e.option.class || ""
35
36
  ]]),
36
37
  "data-disabled": e.option.disabled ? !0 : void 0,
37
38
  onClick: o[0] || (o[0] = (p) => r("click", e.option)),
@@ -52,17 +52,17 @@ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {},
52
52
  selectable: boolean;
53
53
  options: (IDropdownOption | string | number)[];
54
54
  columns: number | string;
55
+ cachedOptions: IDropdownOptions;
55
56
  selectedIndex: number | null;
56
57
  maxHeight: string;
58
+ nestedPosition: any;
59
+ nestedOffset: [number, number];
57
60
  layout: "default" | "grouped";
58
61
  hasMore: boolean;
59
62
  searchable: boolean;
60
63
  remote: boolean;
61
64
  debounceTime: number;
62
65
  direction: "ltr" | "rtl";
63
- nestedPosition: any;
64
- nestedOffset: [number, number];
65
- cachedOptions: IDropdownOptions;
66
66
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
67
67
  containerRef: HTMLDivElement;
68
68
  }, HTMLDivElement>;