@owocow/saber-ui 0.0.9 → 0.1.11

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.
@@ -0,0 +1,254 @@
1
+ import le from "@nuxt/ui/components/Button.vue";
2
+ import ne from "@nuxt/ui/runtime/vue/components/Icon.vue";
3
+ import { defineComponent as ie, useModel as oe, ref as ce, computed as W, openBlock as c, createElementBlock as g, normalizeClass as s, unref as l, createElementVNode as h, renderSlot as M, createBlock as _, withCtx as C, normalizeProps as re, guardReactiveProps as ue, createCommentVNode as A, createVNode as G, Transition as de, toDisplayString as K, Fragment as H, renderList as N, mergeModels as X } from "vue";
4
+ import { tv as me } from "tailwind-variants";
5
+ import { _ as pe } from "./SaberNavigationSearch.vue_vue_type_script_setup_true_lang-Bj96kMla.js";
6
+ const xe = /* @__PURE__ */ ie({
7
+ name: "SaberAppSidebar",
8
+ __name: "SaberAppSidebar",
9
+ props: /* @__PURE__ */ X({
10
+ sections: {},
11
+ searchGroups: { default: () => [] },
12
+ activeKey: {},
13
+ shortcut: { default: "meta_k" },
14
+ ui: {}
15
+ }, {
16
+ activeSection: { default: void 0 },
17
+ activeSectionModifiers: {}
18
+ }),
19
+ emits: /* @__PURE__ */ X(["select", "section-select"], ["update:activeSection"]),
20
+ setup(V, { emit: Y }) {
21
+ const e = V, $ = Y, F = oe(V, "activeSection"), T = ce(!1), w = W(() => e.sections.find((t) => t.key === F.value)), a = me({
22
+ slots: {
23
+ root: "flex h-full min-h-0 flex-col overflow-hidden",
24
+ header: "shrink-0 pl-0 pr-3 pl-1",
25
+ logo: "flex h-11 items-center mb-1.5",
26
+ viewport: "min-h-0 flex-1 overflow-y-auto pr-3 pl-1",
27
+ panel: "flex min-h-full flex-col gap-1",
28
+ sectionList: "flex flex-col",
29
+ group: "flex flex-col",
30
+ groupLabel: "px-2 py-2 text-[11px] uppercase tracking-wider text-muted/70",
31
+ childList: "flex flex-col",
32
+ nestedHeader: "flex items-center",
33
+ footer: "shrink-0 pr-4 pb-1",
34
+ sectionItem: "flex w-full items-center rounded-md px-2 py-2 text-sm font-normal mb-0.5 gap-2 text-left transition",
35
+ sectionItemLeadingIcon: "size-4.5 shrink-0",
36
+ sectionItemLabel: "min-w-0 flex-1 truncate text-left",
37
+ sectionItemTrailingIcon: "size-4 shrink-0",
38
+ childItem: "flex w-full items-center rounded-md px-2 py-1.5 font-normal text-sm mb-0.5 gap-2 text-left transition",
39
+ childItemLeadingIcon: "size-4 shrink-0",
40
+ childItemLabel: "min-w-0 flex-1 truncate text-left",
41
+ backButton: "flex w-full items-center rounded-md px-2 py-2 gap-2 text-left transition",
42
+ backButtonIcon: "size-4.5 shrink-0",
43
+ backButtonLabel: "truncate text-sm font-medium flex-1 text-center pr-10"
44
+ }
45
+ })(), z = W(() => {
46
+ var t, i, o, r, u, d, m, p, v, f, b, B;
47
+ return {
48
+ enterActive: ((i = (t = e.ui) == null ? void 0 : t.transition) == null ? void 0 : i.enterActive) ?? "transition duration-200 ease-out",
49
+ leaveActive: ((r = (o = e.ui) == null ? void 0 : o.transition) == null ? void 0 : r.leaveActive) ?? "transition duration-200 ease-out pointer-events-none",
50
+ enterFrom: T.value ? ((d = (u = e.ui) == null ? void 0 : u.transition) == null ? void 0 : d.backwardEnterFrom) ?? "-translate-x-2 opacity-0 blur-[2px]" : ((p = (m = e.ui) == null ? void 0 : m.transition) == null ? void 0 : p.forwardEnterFrom) ?? "translate-x-2 opacity-0 blur-[2px]",
51
+ leaveTo: T.value ? ((f = (v = e.ui) == null ? void 0 : v.transition) == null ? void 0 : f.backwardLeaveTo) ?? "translate-x-2 opacity-0 blur-[2px]" : ((B = (b = e.ui) == null ? void 0 : b.transition) == null ? void 0 : B.forwardLeaveTo) ?? "-translate-x-2 opacity-0 blur-[2px]"
52
+ };
53
+ });
54
+ function E(t) {
55
+ return t.groups.flatMap((i) => i.items);
56
+ }
57
+ function P(t) {
58
+ return E(t).some((i) => i.key === e.activeKey);
59
+ }
60
+ function Z(t) {
61
+ var o, r, u, d, m, p, v, f;
62
+ const i = P(t) ? ["font-medium", (r = (o = e.ui) == null ? void 0 : o.sectionItem) == null ? void 0 : r.active] : ["text-default", (d = (u = e.ui) == null ? void 0 : u.sectionItem) == null ? void 0 : d.inactive];
63
+ return a.sectionItem({ class: [(p = (m = e.ui) == null ? void 0 : m.sectionItem) == null ? void 0 : p.base, i, (f = (v = e.ui) == null ? void 0 : v.sectionItem) == null ? void 0 : f.hover] });
64
+ }
65
+ function ee(t) {
66
+ var o, r, u, d, m, p, v, f;
67
+ const i = t.key === e.activeKey ? ["font-medium", (r = (o = e.ui) == null ? void 0 : o.childItem) == null ? void 0 : r.active] : ["text-default", (d = (u = e.ui) == null ? void 0 : u.childItem) == null ? void 0 : d.inactive];
68
+ return a.childItem({ class: [(p = (m = e.ui) == null ? void 0 : m.childItem) == null ? void 0 : p.base, i, (f = (v = e.ui) == null ? void 0 : v.childItem) == null ? void 0 : f.hover] });
69
+ }
70
+ function te(t) {
71
+ var o;
72
+ const i = E(t);
73
+ if (i.length === 1) {
74
+ $("select", {
75
+ source: "direct",
76
+ item: i[0],
77
+ sectionKey: t.key,
78
+ groupKey: (o = t.groups[0]) == null ? void 0 : o.key
79
+ });
80
+ return;
81
+ }
82
+ T.value = !1, F.value = t.key, $("section-select", t);
83
+ }
84
+ function ae() {
85
+ T.value = !0, F.value = void 0;
86
+ }
87
+ function se(t, i, o) {
88
+ $("select", { source: "item", item: t, sectionKey: i, groupKey: o });
89
+ }
90
+ return (t, i) => {
91
+ var u, d, m, p, v, f;
92
+ const o = ne, r = le;
93
+ return c(), g("aside", {
94
+ class: s(l(a).root({ class: (u = e.ui) == null ? void 0 : u.root }))
95
+ }, [
96
+ h("header", {
97
+ class: s(l(a).header({ class: (d = e.ui) == null ? void 0 : d.header }))
98
+ }, [
99
+ h("div", {
100
+ class: s(l(a).logo({ class: (m = e.ui) == null ? void 0 : m.logo }))
101
+ }, [
102
+ M(t.$slots, "logo")
103
+ ], 2),
104
+ e.searchGroups.length ? (c(), _(pe, {
105
+ key: 0,
106
+ groups: e.searchGroups,
107
+ shortcut: e.shortcut,
108
+ ui: (p = e.ui) == null ? void 0 : p.search,
109
+ onSelect: i[0] || (i[0] = (b) => $("select", b))
110
+ }, {
111
+ empty: C((b) => [
112
+ M(t.$slots, "search-empty", re(ue(b)))
113
+ ]),
114
+ _: 3
115
+ }, 8, ["groups", "shortcut", "ui"])) : A("", !0)
116
+ ], 2),
117
+ h("nav", {
118
+ class: s(l(a).viewport({ class: (v = e.ui) == null ? void 0 : v.viewport }))
119
+ }, [
120
+ G(de, {
121
+ mode: "out-in",
122
+ "enter-active-class": z.value.enterActive,
123
+ "leave-active-class": z.value.leaveActive,
124
+ "enter-from-class": z.value.enterFrom,
125
+ "leave-to-class": z.value.leaveTo
126
+ }, {
127
+ default: C(() => {
128
+ var b, B, U, D, R, j, q, J;
129
+ return [
130
+ w.value ? (c(), g("div", {
131
+ key: w.value.key,
132
+ class: s(l(a).panel({ class: (b = e.ui) == null ? void 0 : b.panel }))
133
+ }, [
134
+ h("div", {
135
+ class: s(l(a).nestedHeader({ class: (B = e.ui) == null ? void 0 : B.nestedHeader }))
136
+ }, [
137
+ G(r, {
138
+ "data-testid": "back-button",
139
+ color: "neutral",
140
+ variant: "ghost",
141
+ class: s(l(a).backButton({ class: [(D = (U = e.ui) == null ? void 0 : U.backButton) == null ? void 0 : D.base, (j = (R = e.ui) == null ? void 0 : R.backButton) == null ? void 0 : j.hover] })),
142
+ onClick: ae
143
+ }, {
144
+ default: C(() => {
145
+ var n, x, y, I;
146
+ return [
147
+ G(o, {
148
+ name: "solar:alt-arrow-left-linear",
149
+ class: s(l(a).backButtonIcon({ class: (x = (n = e.ui) == null ? void 0 : n.backButton) == null ? void 0 : x.icon }))
150
+ }, null, 8, ["class"]),
151
+ h("span", {
152
+ class: s(l(a).backButtonLabel({ class: (I = (y = e.ui) == null ? void 0 : y.backButton) == null ? void 0 : I.label }))
153
+ }, K(w.value.label), 3)
154
+ ];
155
+ }),
156
+ _: 1
157
+ }, 8, ["class"])
158
+ ], 2),
159
+ (c(!0), g(H, null, N(w.value.groups, (n) => {
160
+ var x, y, I;
161
+ return c(), g("div", {
162
+ key: n.key,
163
+ class: s(l(a).group({ class: (x = e.ui) == null ? void 0 : x.group }))
164
+ }, [
165
+ n.label ? (c(), g("p", {
166
+ key: 0,
167
+ class: s(l(a).groupLabel({ class: (y = e.ui) == null ? void 0 : y.groupLabel }))
168
+ }, K(n.label), 3)) : A("", !0),
169
+ h("div", {
170
+ class: s(l(a).childList({ class: (I = e.ui) == null ? void 0 : I.childList }))
171
+ }, [
172
+ (c(!0), g(H, null, N(n.items, (k) => (c(), _(r, {
173
+ key: k.key,
174
+ "data-testid": `item-${k.key}`,
175
+ "data-active": k.key === e.activeKey,
176
+ color: "neutral",
177
+ variant: "ghost",
178
+ class: s(ee(k)),
179
+ onClick: (L) => se(k, w.value.key, n.key)
180
+ }, {
181
+ default: C(() => {
182
+ var L, S, O, Q;
183
+ return [
184
+ k.icon ? (c(), _(o, {
185
+ key: 0,
186
+ name: k.icon,
187
+ class: s(l(a).childItemLeadingIcon({ class: (S = (L = e.ui) == null ? void 0 : L.childItem) == null ? void 0 : S.leadingIcon }))
188
+ }, null, 8, ["name", "class"])) : A("", !0),
189
+ h("span", {
190
+ class: s(l(a).childItemLabel({ class: (Q = (O = e.ui) == null ? void 0 : O.childItem) == null ? void 0 : Q.label }))
191
+ }, K(k.label), 3)
192
+ ];
193
+ }),
194
+ _: 2
195
+ }, 1032, ["data-testid", "data-active", "class", "onClick"]))), 128))
196
+ ], 2)
197
+ ], 2);
198
+ }), 128))
199
+ ], 2)) : (c(), g("div", {
200
+ key: "root",
201
+ class: s(l(a).panel({ class: (q = e.ui) == null ? void 0 : q.panel }))
202
+ }, [
203
+ h("div", {
204
+ class: s(l(a).sectionList({ class: (J = e.ui) == null ? void 0 : J.sectionList }))
205
+ }, [
206
+ (c(!0), g(H, null, N(e.sections, (n) => (c(), _(r, {
207
+ key: n.key,
208
+ "data-testid": `section-${n.key}`,
209
+ "data-section": n.key,
210
+ "data-active": P(n),
211
+ color: "neutral",
212
+ variant: "ghost",
213
+ class: s(Z(n)),
214
+ onClick: (x) => te(n)
215
+ }, {
216
+ default: C(() => {
217
+ var x, y, I, k, L, S;
218
+ return [
219
+ n.icon ? (c(), _(o, {
220
+ key: 0,
221
+ name: n.icon,
222
+ class: s(l(a).sectionItemLeadingIcon({ class: (y = (x = e.ui) == null ? void 0 : x.sectionItem) == null ? void 0 : y.leadingIcon }))
223
+ }, null, 8, ["name", "class"])) : A("", !0),
224
+ h("span", {
225
+ class: s(l(a).sectionItemLabel({ class: (k = (I = e.ui) == null ? void 0 : I.sectionItem) == null ? void 0 : k.label }))
226
+ }, K(n.label), 3),
227
+ E(n).length > 1 ? (c(), _(o, {
228
+ key: 1,
229
+ name: "solar:alt-arrow-right-linear",
230
+ class: s(l(a).sectionItemTrailingIcon({ class: (S = (L = e.ui) == null ? void 0 : L.sectionItem) == null ? void 0 : S.trailingIcon }))
231
+ }, null, 8, ["class"])) : A("", !0)
232
+ ];
233
+ }),
234
+ _: 2
235
+ }, 1032, ["data-testid", "data-section", "data-active", "class", "onClick"]))), 128))
236
+ ], 2)
237
+ ], 2))
238
+ ];
239
+ }),
240
+ _: 1
241
+ }, 8, ["enter-active-class", "leave-active-class", "enter-from-class", "leave-to-class"])
242
+ ], 2),
243
+ h("footer", {
244
+ class: s(l(a).footer({ class: (f = e.ui) == null ? void 0 : f.footer }))
245
+ }, [
246
+ M(t.$slots, "footer")
247
+ ], 2)
248
+ ], 2);
249
+ };
250
+ }
251
+ });
252
+ export {
253
+ xe as _
254
+ };
@@ -0,0 +1,137 @@
1
+ import D from "@nuxt/ui/components/DashboardSearch.vue";
2
+ import V from "@nuxt/ui/components/Button.vue";
3
+ import j from "@nuxt/ui/components/Kbd.vue";
4
+ import { defineComponent as A, useModel as k, computed as S, openBlock as i, createElementBlock as T, normalizeClass as m, unref as r, createVNode as L, withCtx as U, createElementVNode as F, Fragment as G, renderList as O, createBlock as R, renderSlot as W, normalizeProps as q, guardReactiveProps as H, mergeModels as w } from "vue";
5
+ import { tv as J } from "tailwind-variants";
6
+ const te = /* @__PURE__ */ A({
7
+ name: "SaberNavigationSearch",
8
+ __name: "SaberNavigationSearch",
9
+ props: /* @__PURE__ */ w({
10
+ groups: {},
11
+ label: { default: "搜索菜单" },
12
+ placeholder: { default: "搜索菜单" },
13
+ shortcut: { default: "meta_k" },
14
+ kbds: { default: () => ["meta", "k"] },
15
+ ui: {}
16
+ }, {
17
+ open: { type: Boolean, default: !1 },
18
+ openModifiers: {},
19
+ searchTerm: { default: "" },
20
+ searchTermModifiers: {}
21
+ }),
22
+ emits: /* @__PURE__ */ w(["select"], ["update:open", "update:searchTerm"]),
23
+ setup(s, { emit: B }) {
24
+ const e = s, I = B, a = k(s, "open"), u = k(s, "searchTerm");
25
+ function z(o, t) {
26
+ I("select", {
27
+ source: "search",
28
+ item: o,
29
+ sectionKey: t.sectionKey,
30
+ groupKey: t.key
31
+ }), a.value = !1, u.value = "";
32
+ }
33
+ const C = S(
34
+ () => e.groups.map((o) => ({
35
+ id: o.key,
36
+ label: o.label,
37
+ items: o.items.map((t) => ({
38
+ ...t,
39
+ onSelect: () => z(t, o)
40
+ }))
41
+ }))
42
+ ), K = {
43
+ fuseOptions: {
44
+ keys: ["label", "description"],
45
+ useTokenSearch: !0,
46
+ threshold: 0.2
47
+ },
48
+ resultLimit: 12,
49
+ matchAllWhenSearchEmpty: !0
50
+ }, M = {
51
+ modal: "sm:max-w-xl sm:h-[28rem] rounded-lg shadow-xs",
52
+ root: "bg-default divide-y divide-default",
53
+ input: "[&>input]:h-12 border-muted/60",
54
+ content: "min-h-0",
55
+ viewport: "py-2 px-9 minimal-scrollbar",
56
+ group: "border-none px-0 pb-4",
57
+ label: "py-1.5 pl-0 text-[11px] font-normal text-muted",
58
+ item: "items-center gap-2 rounded-full p-2 -mx-2 w-full",
59
+ itemLeadingIcon: "size-4 text-default",
60
+ itemLabel: "hidden",
61
+ itemLabelBase: "font-medium text-default",
62
+ itemDescription: "text-sm text-default",
63
+ empty: "py-12 text-sm text-muted"
64
+ }, N = S(() => {
65
+ var o;
66
+ return {
67
+ ...M,
68
+ // 业务项目仍然可以覆盖 Saber UI 默认值
69
+ ...(o = e.ui) == null ? void 0 : o.panel
70
+ };
71
+ }), l = J({
72
+ slots: {
73
+ root: "mb-3",
74
+ button: "w-full h-8.5 rounded-md justify-start text-xs text-dimmed font-normal",
75
+ buttonTrailing: "ml-auto flex items-center gap-0.5",
76
+ buttonLeadingIcon: "size-4 shrink-0"
77
+ }
78
+ })();
79
+ return (o, t) => {
80
+ var c, d, p, b, f, h, g, v, x;
81
+ const E = j, P = V, $ = D;
82
+ return i(), T("div", {
83
+ class: m(r(l).root({ class: (c = e.ui) == null ? void 0 : c.root }))
84
+ }, [
85
+ L(P, {
86
+ "data-testid": "search-button",
87
+ color: "neutral",
88
+ variant: "outline",
89
+ icon: "solar:magnifier-linear",
90
+ label: e.label,
91
+ class: m(r(l).button({ class: [(p = (d = e.ui) == null ? void 0 : d.button) == null ? void 0 : p.base, (f = (b = e.ui) == null ? void 0 : b.button) == null ? void 0 : f.hover] })),
92
+ ui: {
93
+ leadingIcon: r(l).buttonLeadingIcon({ class: (g = (h = e.ui) == null ? void 0 : h.button) == null ? void 0 : g.leadingIcon }),
94
+ label: (x = (v = e.ui) == null ? void 0 : v.button) == null ? void 0 : x.label
95
+ },
96
+ onClick: t[0] || (t[0] = (n) => a.value = !0)
97
+ }, {
98
+ trailing: U(() => {
99
+ var n, y;
100
+ return [
101
+ F("span", {
102
+ class: m(r(l).buttonTrailing({ class: (y = (n = e.ui) == null ? void 0 : n.button) == null ? void 0 : y.trailing }))
103
+ }, [
104
+ (i(!0), T(G, null, O(e.kbds, (_) => (i(), R(E, {
105
+ key: _,
106
+ value: _,
107
+ variant: "subtle"
108
+ }, null, 8, ["value"]))), 128))
109
+ ], 2)
110
+ ];
111
+ }),
112
+ _: 1
113
+ }, 8, ["label", "class", "ui"]),
114
+ L($, {
115
+ open: a.value,
116
+ "onUpdate:open": t[1] || (t[1] = (n) => a.value = n),
117
+ "search-term": u.value,
118
+ "onUpdate:searchTerm": t[2] || (t[2] = (n) => u.value = n),
119
+ groups: C.value,
120
+ shortcut: e.shortcut,
121
+ placeholder: e.placeholder,
122
+ fuse: K,
123
+ "color-mode": !1,
124
+ ui: N.value
125
+ }, {
126
+ empty: U((n) => [
127
+ W(o.$slots, "empty", q(H(n)))
128
+ ]),
129
+ _: 3
130
+ }, 8, ["open", "search-term", "groups", "shortcut", "placeholder", "ui"])
131
+ ], 2);
132
+ };
133
+ }
134
+ });
135
+ export {
136
+ te as _
137
+ };
@@ -1,4 +1,4 @@
1
- import { _ as f } from "../SaberAppSidebar.vue_vue_type_script_setup_true_lang-CZ3nsbEh.js";
1
+ import { _ as f } from "../SaberAppSidebar.vue_vue_type_script_setup_true_lang-CEWQTjEi.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as f } from "../SaberNavigationSearch.vue_vue_type_script_setup_true_lang-BdCVvmQo.js";
1
+ import { _ as f } from "../SaberNavigationSearch.vue_vue_type_script_setup_true_lang-Bj96kMla.js";
2
2
  export {
3
3
  f as default
4
4
  };
package/dist/index.mjs CHANGED
@@ -9,8 +9,8 @@ import { _ as P } from "./SaberInfoProvider.vue_vue_type_script_setup_true_lang-
9
9
  import { _ as z } from "./SaberModalWithMobile.vue_vue_type_script_setup_true_lang-aQlToncY.js";
10
10
  import { _ as A } from "./SaberStatus.vue_vue_type_script_setup_true_lang-D9aRVCow.js";
11
11
  import { _ as F } from "./SaberSwitchBar.vue_vue_type_script_setup_true_lang-CDx3Dcas.js";
12
- import { _ as U } from "./SaberAppSidebar.vue_vue_type_script_setup_true_lang-CZ3nsbEh.js";
13
- import { _ as V } from "./SaberNavigationSearch.vue_vue_type_script_setup_true_lang-BdCVvmQo.js";
12
+ import { _ as U } from "./SaberAppSidebar.vue_vue_type_script_setup_true_lang-CEWQTjEi.js";
13
+ import { _ as V } from "./SaberNavigationSearch.vue_vue_type_script_setup_true_lang-Bj96kMla.js";
14
14
  import { k as W } from "./plugin-Dr3z0YFg.js";
15
15
  import { _ as be, a as fe, b as ue, c as Se, d as _e, e as pe } from "./plugin-Dr3z0YFg.js";
16
16
  import { _ as xe } from "./SaberModal.vue_vue_type_script_setup_true_lang-DJno3jA3.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owocow/saber-ui",
3
- "version": "0.0.9",
3
+ "version": "0.1.11",
4
4
  "description": "Saber application foundation for Vue 3 projects built on Nuxt UI",
5
5
  "type": "module",
6
6
  "sideEffects": false,