vlite3 1.1.6 → 1.1.8

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.
Files changed (37) hide show
  1. package/README.md +1 -0
  2. package/components/Chart/GaugeChart.vue.d.ts +120 -0
  3. package/components/Chart/PieChart.vue.d.ts +1 -1
  4. package/components/Chart/index.d.ts +2 -1
  5. package/components/Chart/types.d.ts +60 -1
  6. package/components/CommandPalette/CommandPaletteContent.vue2.js +1 -1
  7. package/components/CommandPalette/{CommandPaletteItem.vue.js → CommandPaletteItem.vue2.js} +1 -1
  8. package/components/DataTable/DataTable.vue.d.ts +1 -0
  9. package/components/DataTable/DataTable.vue.js +142 -132
  10. package/components/DataTable/DataTableHeader.vue.d.ts +1 -0
  11. package/components/DataTable/DataTableHeader.vue.js +17 -16
  12. package/components/DataTable/DataTableRow.vue.d.ts +1 -0
  13. package/components/DataTable/DataTableRow.vue.js +29 -25
  14. package/components/DataTable/types.d.ts +1 -0
  15. package/components/Dropdown/Dropdown.vue.d.ts +2 -1
  16. package/components/Dropdown/Dropdown.vue.js +37 -34
  17. package/components/Dropdown/DropdownMenu.vue.d.ts +3 -0
  18. package/components/Dropdown/DropdownMenu.vue.js +1 -1
  19. package/components/Dropdown/DropdownMenu.vue2.js +83 -72
  20. package/components/Dropdown/DropdownTrigger.vue.js +8 -4
  21. package/components/MultiSelect/MultiSelect.vue.d.ts +26 -1
  22. package/components/MultiSelect/MultiSelect.vue.js +135 -100
  23. package/components/NavbarCommandPalette.vue.js +1 -1
  24. package/components/Skeleton/Skeleton.vue.d.ts +30 -0
  25. package/components/Skeleton/Skeleton.vue.js +215 -0
  26. package/components/Skeleton/Skeleton.vue2.js +4 -0
  27. package/components/Skeleton/extract.d.ts +5 -0
  28. package/components/Skeleton/extract.js +83 -0
  29. package/components/Skeleton/index.d.ts +4 -0
  30. package/components/Skeleton/shared.d.ts +14 -0
  31. package/components/Skeleton/shared.js +29 -0
  32. package/components/Skeleton/types.d.ts +59 -0
  33. package/components/Skeleton/types.js +6 -0
  34. package/index.d.ts +1 -0
  35. package/index.js +217 -207
  36. package/package.json +1 -1
  37. package/style.css +1 -1
@@ -1,23 +1,25 @@
1
- import { defineComponent as P, ref as k, computed as d, watch as M, openBlock as r, createBlock as f, unref as h, withCtx as g, createCommentVNode as m, createElementVNode as y, withKeys as I, withModifiers as p, normalizeClass as c, createElementBlock as v, toDisplayString as $, Fragment as T, renderList as R, createVNode as L, createTextVNode as U } from "vue";
2
- import S from "../Icon.vue.js";
3
- import q from "../Dropdown/Dropdown.vue.js";
4
- import G from "../Dropdown/DropdownMenu.vue.js";
1
+ import { defineComponent as F, ref as V, computed as s, watch as E, openBlock as r, createBlock as f, unref as y, withCtx as d, createSlots as U, renderSlot as b, normalizeProps as q, guardReactiveProps as G, createCommentVNode as v, createElementVNode as p, withKeys as I, withModifiers as w, normalizeClass as m, createElementBlock as g, toDisplayString as S, Fragment as T, renderList as J, createVNode as N, createTextVNode as Q } from "vue";
2
+ import M from "../Icon.vue.js";
3
+ import W from "../Dropdown/Dropdown.vue.js";
4
+ import X from "../Dropdown/DropdownMenu.vue.js";
5
5
  import { $t as C } from "../../utils/i18n.js";
6
- import N from "../Badge.vue.js";
7
- import { useMultiSelectHydration as J } from "./composables/useMultiSelectHydration.js";
8
- const Q = ["tabindex", "data-testid"], W = {
6
+ import L from "../Badge.vue.js";
7
+ import { useMultiSelectHydration as Y } from "./composables/useMultiSelectHydration.js";
8
+ const Z = ["tabindex", "data-testid"], _ = {
9
9
  key: 0,
10
10
  class: "text-muted-foreground pl-0.5 truncate"
11
- }, X = { class: "truncate min-w-0" }, Y = ["onClick"], Z = {
11
+ }, ee = { class: "truncate min-w-0" }, te = ["onClick"], ae = {
12
12
  key: 0,
13
13
  class: "flex items-center gap-2 pl-2 shrink-0 text-muted-foreground"
14
- }, oe = /* @__PURE__ */ P({
14
+ }, ue = /* @__PURE__ */ F({
15
15
  __name: "MultiSelect",
16
16
  props: {
17
17
  modelValue: { default: () => [] },
18
18
  options: { default: () => [] },
19
19
  placeholder: {},
20
20
  placeholderI18n: {},
21
+ emptyMessage: { default: "No options found" },
22
+ searchEmptyMessage: {},
21
23
  disabled: { type: Boolean, default: !1 },
22
24
  readonly: { type: Boolean, default: !1 },
23
25
  searchable: { type: Boolean, default: !0 },
@@ -36,168 +38,201 @@ const Q = ["tabindex", "data-testid"], W = {
36
38
  },
37
39
  emits: ["update:modelValue", "change", "load-more", "search"],
38
40
  setup(t, { emit: j }) {
39
- const e = t, i = j, o = k(!1), D = d(() => {
40
- if (e.placeholderI18n) return C(e.placeholderI18n);
41
- if (e.placeholder) return e.placeholder;
42
- const a = C("vlite.multiSelect.placeholder");
43
- return a !== "vlite.multiSelect.placeholder" ? a : "Select items...";
44
- }), x = d(() => e.options ? e.options.map((a) => typeof a == "string" || typeof a == "number" ? { label: String(a), value: String(a) } : a) : []), B = k(!1), w = k(!1);
45
- M(
41
+ const a = t, i = j, o = V(!1), D = s(() => {
42
+ if (a.placeholderI18n) return C(a.placeholderI18n);
43
+ if (a.placeholder) return a.placeholder;
44
+ const e = C("vlite.multiSelect.placeholder");
45
+ return e !== "vlite.multiSelect.placeholder" ? e : "Select items...";
46
+ }), x = s(() => a.options ? a.options.map((e) => typeof e == "string" || typeof e == "number" ? { label: String(e), value: String(e) } : e) : []), B = V(!1), $ = V(!1);
47
+ E(
46
48
  x,
47
- (a) => {
48
- !B.value && a.length > 0 && (B.value = !0, setTimeout(() => {
49
- w.value = !0, s.hydrateSelected(e.modelValue || []);
49
+ (e) => {
50
+ !B.value && e.length > 0 && (B.value = !0, setTimeout(() => {
51
+ $.value = !0, u.hydrateSelected(a.modelValue || []);
50
52
  }, 10));
51
53
  },
52
54
  { immediate: !0 }
53
55
  );
54
- const V = d(() => {
55
- const a = [...x.value], n = new Set(a.map((l) => l.value ?? l.label));
56
- return s.selectedBuffer.value.forEach((l, u) => {
57
- n.has(u) || (a.unshift(l), n.add(u));
58
- }), a;
59
- }), s = J({
60
- fetchSelected: e.fetchSelected,
61
- getValues: () => e.modelValue || [],
62
- getOptions: () => V.value,
63
- isInitialLoadDone: () => w.value
56
+ const k = s(() => {
57
+ const e = [...x.value], l = new Set(e.map((n) => n.value ?? n.label));
58
+ return u.selectedBuffer.value.forEach((n, c) => {
59
+ l.has(c) || (e.unshift(n), l.add(c));
60
+ }), e;
61
+ }), u = Y({
62
+ fetchSelected: a.fetchSelected,
63
+ getValues: () => a.modelValue || [],
64
+ getOptions: () => k.value,
65
+ isInitialLoadDone: () => $.value
64
66
  });
65
- M(
66
- () => e.modelValue,
67
- (a) => {
68
- w.value && s.hydrateSelected(a || []);
67
+ E(
68
+ () => a.modelValue,
69
+ (e) => {
70
+ $.value && u.hydrateSelected(e || []);
69
71
  },
70
72
  { deep: !0 }
71
73
  );
72
- const b = d(() => V.value.filter((a) => {
73
- const n = a.value ?? a.label;
74
- return e.modelValue.includes(n);
75
- })), E = d(() => b.value.slice(0, e.maxVisible)), O = d(() => b.value.length - e.maxVisible), H = (a) => {
76
- if (e.disabled || e.readonly) return;
77
- const n = a.value ?? a.label;
78
- s.selectedBuffer.value.has(n) || s.selectedBuffer.value.set(n, a);
79
- const l = [...e.modelValue], u = l.indexOf(n);
80
- u === -1 ? l.push(n) : l.splice(u, 1), i("update:modelValue", l), i("change", l);
81
- }, K = (a) => {
82
- if (e.disabled || e.readonly) return;
83
- const n = e.modelValue.filter((l) => l !== a);
84
- i("update:modelValue", n), i("change", n);
85
- }, A = () => {
86
- e.disabled || e.readonly || (i("update:modelValue", []), i("change", []));
87
- }, F = d(() => {
88
- const a = e.rounded === "none" ? "rounded-none" : `rounded-${e.rounded}`, n = e.variant === "transparent" ? "px-2 py-0" : "px-3 py-1.5", l = e.variant === "transparent" ? "h-full min-h-[40px]" : "min-h-[40px]";
74
+ const h = s(() => k.value.filter((e) => {
75
+ const l = e.value ?? e.label;
76
+ return a.modelValue.includes(l);
77
+ })), P = s(() => h.value.slice(0, a.maxVisible)), O = s(() => h.value.length - a.maxVisible), H = (e) => {
78
+ if (a.disabled || a.readonly) return;
79
+ const l = e.value ?? e.label;
80
+ u.selectedBuffer.value.has(l) || u.selectedBuffer.value.set(l, e);
81
+ const n = [...a.modelValue], c = n.indexOf(l);
82
+ c === -1 ? n.push(l) : n.splice(c, 1), i("update:modelValue", n), i("change", n);
83
+ }, K = (e) => {
84
+ if (a.disabled || a.readonly) return;
85
+ const l = a.modelValue.filter((n) => n !== e);
86
+ i("update:modelValue", l), i("change", l);
87
+ }, R = () => {
88
+ a.disabled || a.readonly || (i("update:modelValue", []), i("change", []));
89
+ }, A = s(() => {
90
+ const e = a.rounded === "none" ? "rounded-none" : `rounded-${a.rounded}`, l = a.variant === "transparent" ? "px-2 py-0" : "px-3 py-1.5", n = a.variant === "transparent" ? "h-full min-h-[40px]" : "min-h-[40px]";
89
91
  return [
90
- `flex items-center justify-between w-full ${n} ${l} ${a} border text-sm transition-colors outline-none`,
91
- e.disabled ? "opacity-50 cursor-not-allowed bg-muted" : e.readonly ? `cursor-default ${e.variant === "transparent" || e.variant === "floating" ? "bg-transparent text-foreground" : "bg-background"}` : `cursor-pointer ${e.variant === "floating" || e.variant === "transparent" ? "bg-transparent text-foreground" : "bg-background hover:bg-gray-50/70"}`,
92
- e.variant === "outline" || e.variant === "floating" ? "border-input focus-visible:ring-1 focus-visible:ring-primary" : e.variant === "transparent" ? "border-transparent" : "border-transparent bg-muted",
93
- o.value && e.variant !== "transparent" ? "border-primary/20 ring-1 ring-primary/20" : ""
92
+ `flex items-center justify-between w-full ${l} ${n} ${e} border text-sm transition-colors outline-none`,
93
+ a.disabled ? "opacity-50 cursor-not-allowed bg-muted" : a.readonly ? `cursor-default ${a.variant === "transparent" || a.variant === "floating" ? "bg-transparent text-foreground" : "bg-background"}` : `cursor-pointer ${a.variant === "floating" || a.variant === "transparent" ? "bg-transparent text-foreground" : "bg-background hover:bg-gray-50/70"}`,
94
+ a.variant === "outline" || a.variant === "floating" ? "border-input focus-visible:ring-1 focus-visible:ring-primary" : a.variant === "transparent" ? "border-transparent" : "border-transparent bg-muted",
95
+ o.value && a.variant !== "transparent" ? "border-primary/20 ring-1 ring-primary/20" : ""
94
96
  ].join(" ");
95
- }), z = d(() => e.size === "sm" ? "xs" : "sm");
96
- return (a, n) => (r(), f(h(q), {
97
+ }), z = s(() => a.size === "sm" ? "xs" : "sm");
98
+ return (e, l) => (r(), f(y(W), {
97
99
  isOpen: o.value,
98
- "onUpdate:isOpen": n[5] || (n[5] = (l) => o.value = l),
100
+ "onUpdate:isOpen": l[5] || (l[5] = (n) => o.value = n),
99
101
  "close-on-select": !1,
100
102
  selectable: !0,
103
+ searchable: !1,
104
+ remote: !1,
101
105
  disabled: t.disabled || t.readonly
102
106
  }, {
103
- trigger: g(() => [
104
- y("div", {
105
- class: c(F.value),
107
+ trigger: d(() => [
108
+ p("div", {
109
+ class: m(A.value),
106
110
  tabindex: t.disabled || t.readonly ? -1 : 0,
107
111
  onKeydown: [
108
- n[0] || (n[0] = I(p((l) => !(t.disabled || t.readonly) && (o.value = !o.value), ["prevent"]), ["enter"])),
109
- n[1] || (n[1] = I(p((l) => !(t.disabled || t.readonly) && (o.value = !o.value), ["prevent"]), ["space"]))
112
+ l[0] || (l[0] = I(w((n) => !(t.disabled || t.readonly) && (o.value = !o.value), ["prevent"]), ["enter"])),
113
+ l[1] || (l[1] = I(w((n) => !(t.disabled || t.readonly) && (o.value = !o.value), ["prevent"]), ["space"]))
110
114
  ],
111
- "data-testid": a.$attrs["data-testid"] || (a.$attrs.name ? `multiselect-${a.$attrs.name}` : "multiselect")
115
+ "data-testid": e.$attrs["data-testid"] || (e.$attrs.name ? `multiselect-${e.$attrs.name}` : "multiselect")
112
116
  }, [
113
- y("div", {
114
- class: c(["flex gap-1.5 items-center flex-1 min-w-0", [t.wrap ? "flex-wrap py-0.5" : "flex-nowrap overflow-hidden py-1"]])
117
+ p("div", {
118
+ class: m(["flex gap-1.5 items-center flex-1 min-w-0", [t.wrap ? "flex-wrap py-0.5" : "flex-nowrap overflow-hidden py-1"]])
115
119
  }, [
116
- b.value.length === 0 ? (r(), v("span", W, $(D.value), 1)) : (r(), v(T, { key: 1 }, [
117
- (r(!0), v(T, null, R(E.value, (l) => (r(), f(N, {
118
- key: l.value,
120
+ h.value.length === 0 ? (r(), g("span", _, S(D.value), 1)) : (r(), g(T, { key: 1 }, [
121
+ (r(!0), g(T, null, J(P.value, (n) => (r(), f(L, {
122
+ key: n.value,
119
123
  variant: t.variant === "transparent" ? "outline" : "secondary",
120
124
  size: z.value,
121
125
  rounded: t.rounded === "none" ? "sm" : "full",
122
- class: c(["gap-1 pr-1 truncate min-w-0 shrink", [
126
+ class: m(["gap-1 pr-1 truncate min-w-0 shrink", [
123
127
  t.wrap ? "max-w-[150px]" : "",
124
128
  t.variant === "transparent" ? "border-transparent bg-muted/50 text-foreground font-medium shadow-none" : ""
125
129
  ]])
126
130
  }, {
127
- default: g(() => [
128
- y("span", X, $(l.labelI18n ? h(C)(l.labelI18n) : l.label), 1),
129
- t.disabled || t.readonly ? m("", !0) : (r(), v("button", {
131
+ default: d(() => [
132
+ p("span", ee, S(n.labelI18n ? y(C)(n.labelI18n) : n.label), 1),
133
+ t.disabled || t.readonly ? v("", !0) : (r(), g("button", {
130
134
  key: 0,
131
135
  type: "button",
132
- onClick: p((u) => K(l.value), ["stop"]),
133
- class: c([
136
+ onClick: w((c) => K(n.value), ["stop"]),
137
+ class: m([
134
138
  "rounded transition-colors shrink-0 flex items-center justify-center p-px",
135
139
  t.variant === "transparent" ? "text-muted-foreground hover:bg-black/10 hover:text-foreground" : "hover:bg-destructive/10 hover:text-destructive p-0.5 rounded-full"
136
140
  ])
137
141
  }, [
138
- L(S, {
142
+ N(M, {
139
143
  icon: "lucide:x",
140
144
  class: "w-3 h-3"
141
145
  })
142
- ], 10, Y))
146
+ ], 10, te))
143
147
  ]),
144
148
  _: 2
145
149
  }, 1032, ["variant", "size", "rounded", "class"]))), 128)),
146
- O.value > 0 ? (r(), f(N, {
150
+ O.value > 0 ? (r(), f(L, {
147
151
  key: 0,
148
152
  variant: t.variant === "transparent" ? "outline" : "secondary",
149
153
  size: z.value,
150
154
  rounded: t.rounded === "none" ? "sm" : "full",
151
- class: c([
155
+ class: m([
152
156
  "shrink-0",
153
157
  t.variant === "transparent" ? "border-transparent bg-muted/50 text-muted-foreground font-medium shadow-none" : ""
154
158
  ])
155
159
  }, {
156
- default: g(() => [
157
- U(" +" + $(O.value), 1)
160
+ default: d(() => [
161
+ Q(" +" + S(O.value), 1)
158
162
  ]),
159
163
  _: 1
160
- }, 8, ["variant", "size", "rounded", "class"])) : m("", !0)
164
+ }, 8, ["variant", "size", "rounded", "class"])) : v("", !0)
161
165
  ], 64))
162
166
  ], 2),
163
- t.showControls && !(t.disabled || t.readonly) ? (r(), v("div", Z, [
164
- b.value.length > 0 && !(t.disabled || t.readonly) ? (r(), f(S, {
167
+ t.showControls && !(t.disabled || t.readonly) ? (r(), g("div", ae, [
168
+ h.value.length > 0 && !(t.disabled || t.readonly) ? (r(), f(M, {
165
169
  key: 0,
166
170
  icon: "lucide:x",
167
171
  class: "w-4 h-4 hover:text-foreground transition-colors",
168
- onClick: p(A, ["stop"])
169
- })) : m("", !0),
170
- n[6] || (n[6] = y("div", { class: "w-px h-4 bg-border mx-0.5" }, null, -1)),
171
- L(S, {
172
+ onClick: w(R, ["stop"])
173
+ })) : v("", !0),
174
+ l[6] || (l[6] = p("div", { class: "w-px h-4 bg-border mx-0.5" }, null, -1)),
175
+ N(M, {
172
176
  icon: "lucide:chevron-down",
173
- class: c(["w-4 h-4 transition-transform duration-200", { "rotate-180": o.value }])
177
+ class: m(["w-4 h-4 transition-transform duration-200", { "rotate-180": o.value }])
174
178
  }, null, 8, ["class"])
175
- ])) : m("", !0)
176
- ], 42, Q)
179
+ ])) : v("", !0)
180
+ ], 42, Z)
177
181
  ]),
178
- default: g(() => [
179
- t.disabled || t.readonly ? m("", !0) : (r(), f(h(G), {
182
+ default: d(() => [
183
+ t.disabled || t.readonly ? v("", !0) : (r(), f(y(X), {
180
184
  key: 0,
181
185
  options: x.value,
182
- cachedOptions: V.value,
186
+ cachedOptions: k.value,
183
187
  selected: t.modelValue,
188
+ emptyMessage: t.emptyMessage,
189
+ searchEmptyMessage: t.searchEmptyMessage,
184
190
  class: "min-w-[300px]",
185
- loading: t.loading || h(s).isHydrating.value,
191
+ loading: t.loading || y(u).isHydrating.value,
186
192
  hasMore: t.hasMore,
187
193
  searchable: t.searchable,
188
194
  remote: t.remote,
189
195
  debounceTime: t.debounceTime,
190
196
  layout: t.layout,
191
197
  onSelect: H,
192
- onClose: n[2] || (n[2] = (l) => o.value = !1),
193
- onLoadMore: n[3] || (n[3] = (l) => a.$emit("load-more")),
194
- onSearch: n[4] || (n[4] = (l) => a.$emit("search", l))
195
- }, null, 8, ["options", "cachedOptions", "selected", "loading", "hasMore", "searchable", "remote", "debounceTime", "layout"]))
198
+ onClose: l[2] || (l[2] = (n) => o.value = !1),
199
+ onLoadMore: l[3] || (l[3] = (n) => e.$emit("load-more")),
200
+ onSearch: l[4] || (l[4] = (n) => e.$emit("search", n))
201
+ }, U({ _: 2 }, [
202
+ e.$slots.menu ? {
203
+ name: "menu",
204
+ fn: d(() => [
205
+ b(e.$slots, "menu")
206
+ ]),
207
+ key: "0"
208
+ } : void 0,
209
+ e.$slots.item ? {
210
+ name: "item",
211
+ fn: d((n) => [
212
+ b(e.$slots, "item", q(G(n)))
213
+ ]),
214
+ key: "1"
215
+ } : void 0,
216
+ e.$slots.header ? {
217
+ name: "header",
218
+ fn: d(() => [
219
+ b(e.$slots, "header")
220
+ ]),
221
+ key: "2"
222
+ } : void 0,
223
+ e.$slots.footer ? {
224
+ name: "footer",
225
+ fn: d(() => [
226
+ b(e.$slots, "footer")
227
+ ]),
228
+ key: "3"
229
+ } : void 0
230
+ ]), 1032, ["options", "cachedOptions", "selected", "emptyMessage", "searchEmptyMessage", "loading", "hasMore", "searchable", "remote", "debounceTime", "layout"]))
196
231
  ]),
197
- _: 1
232
+ _: 3
198
233
  }, 8, ["isOpen", "disabled"]));
199
234
  }
200
235
  });
201
236
  export {
202
- oe as default
237
+ ue as default
203
238
  };
@@ -3,7 +3,7 @@ import L from "./Icon.vue.js";
3
3
  import v from "./Modal.vue.js";
4
4
  import N from "./CommandPalette/CommandPaletteContent.vue.js";
5
5
  import { $t as U } from "../utils/i18n.js";
6
- /* empty css */
6
+ /* empty css */
7
7
  const V = { class: "block truncate -text-fs-1.5" }, S = { class: "ml-auto 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" }, A = /* @__PURE__ */ x({
8
8
  __name: "NavbarCommandPalette",
9
9
  props: {
@@ -0,0 +1,30 @@
1
+ import { SkeletonProps } from './types';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: {
5
+ fallback?(_: {}): any;
6
+ default?(_: {}): any;
7
+ default?(_: {}): any;
8
+ fixture?(_: {}): any;
9
+ };
10
+ refs: {
11
+ containerRef: HTMLDivElement;
12
+ fixtureRef: HTMLDivElement;
13
+ };
14
+ rootEl: HTMLDivElement;
15
+ };
16
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
17
+ declare const __VLS_component: import('vue').DefineComponent<SkeletonProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SkeletonProps> & Readonly<{}>, {
18
+ animate: import('./types').AnimationStyle;
19
+ auto: boolean;
20
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
21
+ containerRef: HTMLDivElement;
22
+ fixtureRef: HTMLDivElement;
23
+ }, HTMLDivElement>;
24
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
25
+ export default _default;
26
+ type __VLS_WithTemplateSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
@@ -0,0 +1,215 @@
1
+ import { defineComponent as ue, ref as c, shallowRef as de, computed as a, watch as ce, nextTick as ve, onMounted as me, onUnmounted as fe, openBlock as l, createElementBlock as v, normalizeClass as ye, createElementVNode as H, normalizeStyle as k, renderSlot as M, createCommentVNode as m, Fragment as pe, renderList as ge, isMemoSame as he, setBlockTracking as f, createBlock as L, resolveDynamicComponent as N, withCtx as D, createTextVNode as P, toDisplayString as $, unref as z } from "vue";
2
+ import { normalizeBone as J } from "./types.js";
3
+ import { getRegisteredBones as be, resolveResponsive as ke, getGlobalConfig as $e } from "./shared.js";
4
+ import { snapshotBones as we } from "./extract.js";
5
+ const Be = ["data-boneyard"], Re = { style: { position: "relative", width: "100%", height: "100%" } }, Ce = "rgba(0, 0, 0, 0.03)", Ee = "rgba(255, 255, 255, 0.05)", Se = 0.4, xe = 1, Me = 1, Ae = 0.1, Q = "0, 0, 0", Z = "255, 255, 255", ee = "0.04", te = "0", He = /* @__PURE__ */ ue({
6
+ __name: "Skeleton",
7
+ props: {
8
+ loading: { type: Boolean },
9
+ name: {},
10
+ initialBones: {},
11
+ auto: { type: Boolean, default: !1 },
12
+ color: {},
13
+ darkColor: {},
14
+ animate: { type: [String, Boolean], default: "pulse" },
15
+ stagger: { type: [Number, Boolean] },
16
+ transition: { type: [Number, Boolean] },
17
+ class: {},
18
+ snapshotConfig: {}
19
+ },
20
+ setup(w) {
21
+ const n = w, s = c(null), A = c(null), y = c(0), B = c(0), p = c(!1), u = Math.random().toString(36).slice(2, 8), O = de(null), g = $e(), ne = a(() => n.animate ?? g.animate ?? "pulse"), h = a(() => {
22
+ const e = ne.value;
23
+ return e === !0 ? "pulse" : e === !1 ? "solid" : e;
24
+ }), G = a(
25
+ () => p.value ? n.darkColor ?? g.darkColor ?? Ee : n.color ?? g.color ?? Ce
26
+ ), Y = a(
27
+ () => O.value ?? n.initialBones ?? (n.name ? be(n.name) : void 0)
28
+ ), F = a(
29
+ () => typeof window < "u" ? window.innerWidth : y.value
30
+ ), r = a(
31
+ () => Y.value && (F.value > 0 || y.value > 0) ? ke(Y.value, F.value || y.value) : null
32
+ ), b = a(() => {
33
+ const e = n.stagger ?? g.stagger;
34
+ return e === !0 ? 80 : e === !1 || !e ? 0 : e;
35
+ }), R = a(() => {
36
+ const e = n.transition ?? g.transition;
37
+ return e === !0 ? 300 : e === !1 || !e ? 0 : e;
38
+ }), d = c(!1);
39
+ let C = null;
40
+ ce(
41
+ () => n.loading,
42
+ (e, t) => {
43
+ t && !e && R.value > 0 && r.value && (C && clearTimeout(C), d.value = !0, C = setTimeout(() => {
44
+ d.value = !1, C = null;
45
+ }, R.value)), e && n.auto && ae();
46
+ },
47
+ { immediate: !0 }
48
+ );
49
+ const K = a(() => (n.loading || d.value) && !!r.value), oe = a(
50
+ () => n.loading && !r.value && !d.value && !n.auto
51
+ ), W = a(
52
+ () => B.value > 0 ? B.value : r.value?.height ?? 0
53
+ ), q = a(() => r.value?.height ?? 0), U = a(
54
+ () => W.value > 0 && q.value > 0 ? W.value / q.value : 1
55
+ );
56
+ function ae() {
57
+ ve(() => {
58
+ requestAnimationFrame(() => {
59
+ A.value && (O.value = we(
60
+ A.value,
61
+ n.name || "auto-skeleton",
62
+ n.snapshotConfig
63
+ ));
64
+ });
65
+ });
66
+ }
67
+ function _() {
68
+ if (!(typeof window > "u"))
69
+ try {
70
+ p.value = document.documentElement.classList.contains("dark") || !!s.value?.closest(".dark");
71
+ } catch {
72
+ p.value = !1;
73
+ }
74
+ }
75
+ function ie(e) {
76
+ return typeof e == "number" ? `${e}px` : /^[0-9.]+(%|px|em|rem)?(\s+[0-9.]+(%|px|em|rem)?)*(\s*\/\s*[0-9.]+(%|px|em|rem)?(\s+[0-9.]+(%|px|em|rem)?)*)?$/.test(
77
+ e
78
+ ) ? e : "0px";
79
+ }
80
+ function le(e, t, o) {
81
+ const i = J(e), V = ie(i.r);
82
+ return {
83
+ position: "absolute",
84
+ left: `${i.x}%`,
85
+ top: `${i.y * t}px`,
86
+ width: `${i.w}%`,
87
+ height: `${i.h * t}px`,
88
+ borderRadius: V,
89
+ overflow: "hidden",
90
+ // Start invisible if staggering, otherwise visible
91
+ opacity: b.value > 0 ? 0 : 1,
92
+ animation: b.value > 0 ? `by-${u} 0.3s ease-out ${o * b.value}ms forwards` : "none"
93
+ };
94
+ }
95
+ function re(e, t) {
96
+ const o = J(e);
97
+ return {
98
+ width: "100%",
99
+ height: "100%",
100
+ backgroundColor: t,
101
+ opacity: o.c ? Se : xe,
102
+ position: "relative"
103
+ };
104
+ }
105
+ function se(e, t) {
106
+ if (t === "pulse")
107
+ return {
108
+ position: "absolute",
109
+ inset: 0,
110
+ backgroundColor: `rgba(${e ? Z : Q}, ${ee})`,
111
+ animation: `bp-${u} 1.8s ease-in-out infinite`
112
+ };
113
+ if (t === "shimmer") {
114
+ const o = e ? Z : Q;
115
+ return {
116
+ position: "absolute",
117
+ inset: 0,
118
+ background: `linear-gradient(90deg, rgba(${o}, ${te}) 0%, rgba(${o}, ${ee}) 50%, rgba(${o}, ${te}) 100%)`,
119
+ // Using transform: translateX entirely fixes the ugly snapping at 100%
120
+ animation: `bs-${u} 2.5s infinite ease-in-out`
121
+ };
122
+ }
123
+ return {};
124
+ }
125
+ let I = null, T = null, E = null, S = null;
126
+ return me(() => {
127
+ if (_(), s.value) {
128
+ const e = s.value.getBoundingClientRect();
129
+ y.value = Math.round(e.width), e.height > 0 && (B.value = Math.round(e.height));
130
+ }
131
+ S = window.matchMedia("(prefers-color-scheme: dark)"), E = () => _(), S.addEventListener("change", E), T = new MutationObserver(_), T.observe(document.documentElement, {
132
+ attributes: !0,
133
+ attributeFilter: ["class"]
134
+ }), I = new ResizeObserver((e) => {
135
+ const t = e[0]?.contentRect;
136
+ y.value = Math.round(t?.width ?? 0), t && t.height > 0 && (B.value = Math.round(t.height));
137
+ }), s.value && I.observe(s.value);
138
+ }), fe(() => {
139
+ S && E && S.removeEventListener("change", E), T?.disconnect(), I?.disconnect();
140
+ }), (e, t) => (l(), v("div", {
141
+ ref_key: "containerRef",
142
+ ref: s,
143
+ class: ye(n.class),
144
+ style: { position: "relative" },
145
+ "data-boneyard": w.name
146
+ }, [
147
+ H("div", {
148
+ "data-boneyard-content": "true",
149
+ style: k({ visibility: K.value && !d.value ? "hidden" : void 0 })
150
+ }, [
151
+ oe.value ? M(e.$slots, "fallback", { key: 0 }) : M(e.$slots, "default", { key: 1 })
152
+ ], 4),
153
+ w.loading && w.auto && !O.value ? (l(), v("div", {
154
+ key: 0,
155
+ "data-boneyard-fixture": "",
156
+ ref_key: "fixtureRef",
157
+ ref: A,
158
+ style: { position: "absolute", inset: "0", "z-index": "-1", opacity: "0.001", "pointer-events": "none" },
159
+ "aria-hidden": "true"
160
+ }, [
161
+ M(e.$slots, "fixture", {}, () => [
162
+ M(e.$slots, "default")
163
+ ])
164
+ ], 512)) : m("", !0),
165
+ K.value && r.value ? (l(), v("div", {
166
+ key: 1,
167
+ "data-boneyard-overlay": "true",
168
+ style: k(`position:absolute;inset:0;overflow:hidden;opacity:${d.value ? 0 : 1};${R.value > 0 ? `transition:opacity ${R.value}ms ease-out;` : ""}pointer-events:none;will-change:opacity;contain:strict;`)
169
+ }, [
170
+ H("div", Re, [
171
+ (l(!0), v(pe, null, ge(r.value.bones, (o, i, V, x) => {
172
+ const X = [o, U.value, G.value, h.value, p.value, b.value];
173
+ if (x && x.key === `${i}-${o.x ?? o[0]}` && he(x, X)) return x;
174
+ const j = (l(), v("div", {
175
+ key: `${i}-${o.x ?? o[0]}`,
176
+ "data-boneyard-bone": "true",
177
+ style: k(le(o, U.value, i))
178
+ }, [
179
+ H("div", {
180
+ style: k(re(o, G.value))
181
+ }, [
182
+ h.value !== "solid" ? (l(), v("div", {
183
+ key: 0,
184
+ style: k(se(p.value, h.value))
185
+ }, null, 4)) : m("", !0)
186
+ ], 4)
187
+ ], 4));
188
+ return j.memo = X, j;
189
+ }, t, 0), 128)),
190
+ t[2] || (f(-1, !0), (t[2] = h.value === "pulse" ? (l(), L(N("style"), { key: 0 }, {
191
+ default: D(() => [
192
+ P(" @keyframes bp-" + $(z(u)) + " { 0%, 100% { opacity: " + $(Ae) + "; } 50% { opacity: " + $(Me) + "; } } ", 1)
193
+ ]),
194
+ _: 1
195
+ })) : m("", !0)).cacheIndex = 2, f(1), t[2]),
196
+ t[3] || (f(-1, !0), (t[3] = h.value === "shimmer" ? (l(), L(N("style"), { key: 1 }, {
197
+ default: D(() => [
198
+ P(" @keyframes bs-" + $(z(u)) + " { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } } ", 1)
199
+ ]),
200
+ _: 1
201
+ })) : m("", !0)).cacheIndex = 3, f(1), t[3]),
202
+ t[4] || (f(-1, !0), (t[4] = b.value > 0 ? (l(), L(N("style"), { key: 2 }, {
203
+ default: D(() => [
204
+ P(" @keyframes by-" + $(z(u)) + " { from { opacity: 0; } to { opacity: 1; } } ", 1)
205
+ ]),
206
+ _: 1
207
+ })) : m("", !0)).cacheIndex = 4, f(1), t[4])
208
+ ])
209
+ ], 4)) : m("", !0)
210
+ ], 10, Be));
211
+ }
212
+ });
213
+ export {
214
+ He as default
215
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./Skeleton.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,5 @@
1
+ import { SkeletonResult, SnapshotConfig } from './types';
2
+ /**
3
+ * Snapshot the exact visual layout of a rendered DOM element as skeleton bones.
4
+ */
5
+ export declare function snapshotBones(el: Element, name?: string, config?: SnapshotConfig): SkeletonResult;