@owocow/saber-ui 0.1.13 → 0.1.15

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 (40) hide show
  1. package/dist/SaberAppLayout.vue_vue_type_script_setup_true_lang-Hr4TdNqR.js +487 -0
  2. package/dist/{SaberDictSelect.vue_vue_type_script_setup_true_lang-B8PTKNKX.js → SaberDictSelect.vue_vue_type_script_setup_true_lang-BKdOdlFX.js} +1 -1
  3. package/dist/SaberDistrictSelect.vue_vue_type_script_setup_true_lang-jkl2AOay.js +272 -0
  4. package/dist/{SaberInfo.vue_vue_type_script_setup_true_lang-B3W5VsGR.js → SaberInfo.vue_vue_type_script_setup_true_lang-B_1ugpqI.js} +1 -1
  5. package/dist/SaberPopSelect.vue_vue_type_script_setup_true_lang-eH8jkkzK.js +162 -0
  6. package/dist/SaberSwitchBar.vue_vue_type_script_setup_true_lang-CIbFBx5r.js +47 -0
  7. package/dist/components/SaberAppLayout.mjs +1 -1
  8. package/dist/components/SaberInfo.mjs +1 -1
  9. package/dist/components/SaberPagination.vue.d.ts +48 -0
  10. package/dist/components/SaberSwitchBar.mjs +1 -1
  11. package/dist/components/layout/SaberAppLayout.types.d.ts +8 -0
  12. package/dist/components/layout/SaberAppLayout.vue.d.ts +5 -0
  13. package/dist/composables/index.d.ts +1 -1
  14. package/dist/composables/use-page-header.d.ts +3 -1
  15. package/dist/composables/use-page-header.mjs +27 -15
  16. package/dist/composables/use-table.d.ts +1 -0
  17. package/dist/composables/use-table.mjs +45 -42
  18. package/dist/composables.mjs +22 -20
  19. package/dist/control-size.d.ts +33 -0
  20. package/dist/forms/components/SaberFilterBar.vue.d.ts +3 -0
  21. package/dist/forms/components/SaberFormModal.vue.d.ts +2 -0
  22. package/dist/forms/components/fields/SaberDistrictSelect.vue.d.ts +5 -0
  23. package/dist/forms/components/fields/SaberInput.vue.d.ts +5 -0
  24. package/dist/forms/components/fields/SaberInputNumber.vue.d.ts +10 -2
  25. package/dist/forms/components/fields/SaberPopSelect.vue.d.ts +4 -1
  26. package/dist/forms/components/fields/SaberSelect.vue.d.ts +10 -2
  27. package/dist/forms/dict-select.mjs +1 -1
  28. package/dist/forms/district-select.mjs +1 -1
  29. package/dist/forms/index.d.ts +1 -0
  30. package/dist/forms/pop-select.mjs +1 -1
  31. package/dist/forms.mjs +4 -4
  32. package/dist/index.d.ts +4 -1
  33. package/dist/index.mjs +175 -98
  34. package/dist/plugin-Cg7MKH3t.js +438 -0
  35. package/package.json +1 -1
  36. package/dist/SaberAppLayout.vue_vue_type_script_setup_true_lang-R7F5K7kj.js +0 -418
  37. package/dist/SaberDistrictSelect.vue_vue_type_script_setup_true_lang-BX8nLC35.js +0 -257
  38. package/dist/SaberPopSelect.vue_vue_type_script_setup_true_lang-BcS27NXI.js +0 -125
  39. package/dist/SaberSwitchBar.vue_vue_type_script_setup_true_lang-CDx3Dcas.js +0 -47
  40. package/dist/plugin-Dr3z0YFg.js +0 -396
@@ -1,418 +0,0 @@
1
- import Oe from "@nuxt/ui/components/Button.vue";
2
- import $e from "@nuxt/ui/components/Drawer.vue";
3
- import { getCurrentInstance as se, getCurrentScope as Be, hasInjectionContext as ue, inject as De, watch as z, shallowRef as T, watchEffect as Me, toValue as M, computed as u, onMounted as Le, unref as Ue, defineComponent as je, useSlots as Fe, useModel as te, ref as ae, useId as Ie, nextTick as ze, openBlock as x, createElementBlock as S, normalizeStyle as A, normalizeClass as d, renderSlot as h, normalizeProps as $, guardReactiveProps as B, Fragment as H, createCommentVNode as D, createVNode as G, withCtx as ne, createElementVNode as f, toDisplayString as oe, createBlock as Te, mergeModels as le } from "vue";
4
- import { tv as R } from "tailwind-variants";
5
- import { providePageHeader as Ne } from "./composables/use-page-header.mjs";
6
- import { _ as Ee } from "./SaberNavigationSearch.vue_vue_type_script_setup_true_lang-Bj96kMla.js";
7
- const V = /* @__PURE__ */ new WeakMap(), Pe = /* @__NO_SIDE_EFFECTS__ */ (...t) => {
8
- var r;
9
- const e = t[0], l = (r = se()) === null || r === void 0 ? void 0 : r.proxy, n = l ?? Be();
10
- if (n == null && !ue()) throw new Error("injectLocal must be called in setup");
11
- return n && V.has(n) && e in V.get(n) ? V.get(n)[e] : De(...t);
12
- }, Ae = typeof window < "u" && typeof document < "u";
13
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
14
- const He = Object.prototype.toString, Ge = (t) => He.call(t) === "[object Object]";
15
- function ie(t) {
16
- return t.endsWith("rem") ? Number.parseFloat(t) * 16 : Number.parseFloat(t);
17
- }
18
- function K(t) {
19
- return Array.isArray(t) ? t : [t];
20
- }
21
- function Re(t, r, e) {
22
- return z(t, r, {
23
- ...e,
24
- immediate: !0
25
- });
26
- }
27
- const de = Ae ? window : void 0;
28
- function Ve(t) {
29
- var r;
30
- const e = M(t);
31
- return (r = e == null ? void 0 : e.$el) !== null && r !== void 0 ? r : e;
32
- }
33
- function Ke(...t) {
34
- const r = (l, n, c, o) => (l.addEventListener(n, c, o), () => l.removeEventListener(n, c, o)), e = u(() => {
35
- const l = K(M(t[0])).filter((n) => n != null);
36
- return l.every((n) => typeof n != "string") ? l : void 0;
37
- });
38
- return Re(() => {
39
- var l, n;
40
- return [
41
- (l = (n = e.value) === null || n === void 0 ? void 0 : n.map((c) => Ve(c))) !== null && l !== void 0 ? l : [de].filter((c) => c != null),
42
- K(M(e.value ? t[1] : t[0])),
43
- K(Ue(e.value ? t[2] : t[1])),
44
- M(e.value ? t[3] : t[2])
45
- ];
46
- }, ([l, n, c, o], b, L) => {
47
- if (!(l != null && l.length) || !(n != null && n.length) || !(c != null && c.length)) return;
48
- const k = Ge(o) ? { ...o } : o, p = l.flatMap((g) => n.flatMap((i) => c.map((w) => r(g, i, w, k))));
49
- L(() => {
50
- p.forEach((g) => g());
51
- });
52
- }, { flush: "post" });
53
- }
54
- // @__NO_SIDE_EFFECTS__
55
- function Qe() {
56
- const t = T(!1), r = se();
57
- return r && Le(() => {
58
- t.value = !0;
59
- }, r), t;
60
- }
61
- // @__NO_SIDE_EFFECTS__
62
- function Je(t) {
63
- const r = /* @__PURE__ */ Qe();
64
- return u(() => (r.value, !!t()));
65
- }
66
- const Xe = Symbol("vueuse-ssr-width");
67
- // @__NO_SIDE_EFFECTS__
68
- function Ye() {
69
- const t = ue() ? /* @__PURE__ */ Pe(Xe, null) : null;
70
- return typeof t == "number" ? t : void 0;
71
- }
72
- function re(t, r = {}) {
73
- const { window: e = de, ssrWidth: l = /* @__PURE__ */ Ye() } = r, n = /* @__PURE__ */ Je(() => e && "matchMedia" in e && typeof e.matchMedia == "function"), c = T(typeof l == "number"), o = T(), b = T(!1), L = (k) => {
74
- b.value = k.matches;
75
- };
76
- return Me(() => {
77
- if (c.value) {
78
- c.value = !n.value;
79
- const k = M(t).split(",");
80
- b.value = k.some((p) => {
81
- const g = p.includes("not all"), i = p.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), w = p.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
82
- let y = !!(i || w);
83
- return i && y && (y = l >= ie(i[1])), w && y && (y = l <= ie(w[1])), g ? !y : y;
84
- });
85
- return;
86
- }
87
- n.value && (o.value = e.matchMedia(M(t)), b.value = o.value.matches);
88
- }), Ke(o, "change", L, { passive: !0 }), u(() => b.value);
89
- }
90
- const nt = /* @__PURE__ */ je({
91
- name: "SaberAppLayout",
92
- __name: "SaberAppLayout",
93
- props: /* @__PURE__ */ le({
94
- title: { default: void 0 },
95
- description: { default: void 0 },
96
- maxWidth: { type: [Number, String, Boolean], default: void 0 },
97
- navigationKey: { default: void 0 },
98
- sidebarWidth: { default: 240 },
99
- phoneBreakpoint: { default: 768 },
100
- padBreakpoint: { default: 1024 },
101
- searchGroups: { default: () => [] },
102
- searchShortcut: { default: "meta_k" },
103
- searchLabel: { default: "搜索" },
104
- menuOpenLabel: { default: "菜单" },
105
- menuCloseLabel: { default: "关闭" },
106
- menuOpenIcon: { default: "solar:hamburger-menu-linear" },
107
- menuCloseIcon: { default: "solar:close-circle-linear" },
108
- ui: { default: () => ({}) }
109
- }, {
110
- drawerOpen: { type: Boolean, default: !1 },
111
- drawerOpenModifiers: {},
112
- searchOpen: { type: Boolean, default: !1 },
113
- searchOpenModifiers: {}
114
- }),
115
- emits: /* @__PURE__ */ le(["searchSelect"], ["update:drawerOpen", "update:searchOpen"]),
116
- setup(t, { emit: r }) {
117
- const e = t, l = r, n = Fe(), c = R({
118
- slots: {
119
- root: "flex h-dvh items-start gap-2 overflow-hidden p-1.5 text-default",
120
- desktopSidebar: "sticky top-0 h-full shrink-0 self-start",
121
- main: "relative flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-y-auto rounded-lg border border-default bg-default",
122
- header: "sticky top-0 z-10 mx-auto flex w-full shrink-0 items-center justify-between gap-4 overflow-hidden bg-default/70 backdrop-blur-md",
123
- headerHeading: "min-w-0",
124
- title: "truncate text-xl",
125
- description: "mt-1 text-sm text-muted",
126
- headerSuffix: "flex shrink-0 items-center gap-2",
127
- pageHeaderSuffixTarget: "contents",
128
- content: "mx-auto w-full flex-1",
129
- phoneDrawerContent: "h-full min-h-0 w-full min-w-0 p-2",
130
- phoneSidebarFrame: "h-full min-h-0 w-full",
131
- padDrawerContent: "h-full min-h-0 w-full min-w-0 p-2",
132
- padSidebarFrame: "mx-auto h-full min-h-0",
133
- overlay: "fixed inset-0 z-40 border-0 bg-black/35 p-0 backdrop-blur-[1px]",
134
- dock: "fixed bottom-[calc(0.75rem+env(safe-area-inset-bottom))] left-1/2 z-60 flex w-42 -translate-x-1/2 items-center gap-1 rounded-2xl border border-default bg-default/95 p-1 shadow-lg backdrop-blur-md"
135
- },
136
- variants: {
137
- mode: {
138
- phone: {
139
- root: "p-1.5",
140
- header: "p-4",
141
- title: "text-xl",
142
- content: "px-3 pb-[calc(6rem+env(safe-area-inset-bottom))]"
143
- },
144
- pad: {
145
- root: "p-1.5",
146
- header: "p-4",
147
- title: "text-2xl",
148
- content: "px-4 pb-[calc(6rem+env(safe-area-inset-bottom))]"
149
- },
150
- desktop: {
151
- root: "p-2",
152
- header: "px-6 py-4.5 min-[1441px]:px-8 min-[1441px]:py-6",
153
- title: "text-2xl",
154
- content: "px-6 pb-0 min-[1441px]:px-8"
155
- }
156
- }
157
- }
158
- }), o = te(t, "drawerOpen"), b = te(t, "searchOpen"), L = re(`(max-width: ${e.phoneBreakpoint}px)`), k = re(`(max-width: ${e.padBreakpoint}px)`), p = u(() => L.value ? "phone" : k.value ? "pad" : "desktop"), g = u(() => p.value !== "desktop"), i = u(() => c({ mode: p.value })), w = ae(null), y = Ne(w), N = u(() => y.title ?? e.title), E = u(() => y.description ?? e.description), Q = u(() => {
159
- if (typeof e.maxWidth == "number")
160
- return Number.isFinite(e.maxWidth) && e.maxWidth > 0 ? `${e.maxWidth}px` : void 0;
161
- if (!(e.maxWidth === "full" || e.maxWidth === !1 || e.maxWidth === void 0))
162
- return e.maxWidth.trim() || void 0;
163
- }), ce = u(
164
- () => e.maxWidth === void 0 || typeof e.maxWidth == "number" && (!Number.isFinite(e.maxWidth) || e.maxWidth <= 0)
165
- ), J = u(
166
- () => Q.value ? { maxWidth: Q.value } : void 0
167
- ), X = u(() => ce.value ? "min-[1921px]:max-w-[1620px]" : void 0), pe = u(() => typeof e.sidebarWidth == "number" ? Number.isFinite(e.sidebarWidth) && e.sidebarWidth > 0 ? `${e.sidebarWidth}px` : "240px" : e.sidebarWidth.trim() || "240px"), fe = u(() => ({ "--saber-app-layout-sidebar-width": pe.value })), me = { width: "var(--saber-app-layout-sidebar-width)" }, ve = { width: "var(--saber-app-layout-sidebar-width)" }, P = `saber-app-layout-navigation-${Ie().replaceAll(":", "")}`, Y = ae(null);
168
- function F(a) {
169
- return typeof a == "object" && a !== null && !Array.isArray(a);
170
- }
171
- function he(a) {
172
- return F(a) && Object.values(a).every((s) => typeof s == "boolean");
173
- }
174
- function be(a) {
175
- return typeof a == "function";
176
- }
177
- function ye(a, s) {
178
- return s === void 0 ? a : be(s) ? (m) => s(R({ base: m })({ class: a })) : R({ base: a })({ class: s });
179
- }
180
- function U(a, s) {
181
- const m = {}, O = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(s ?? {})]);
182
- for (const v of O) {
183
- const j = a[v], I = s == null ? void 0 : s[v], _ = F(I) && !he(I);
184
- if (F(j) || j === void 0 && _)
185
- m[v] = U(
186
- F(j) ? j : {},
187
- _ ? I : void 0
188
- );
189
- else {
190
- const ee = ye(j, I);
191
- ee !== void 0 && (m[v] = ee);
192
- }
193
- }
194
- return m;
195
- }
196
- const xe = {
197
- root: "mb-0 min-w-0 flex-1",
198
- button: {
199
- base: "h-10 w-20 rounded-full border-0 bg-transparent px-3 shadow-none",
200
- trailing: "hidden",
201
- label: "text-(--ui-text) text-sm",
202
- leadingIcon: "text-(--ui-text)"
203
- }
204
- }, ge = {
205
- base: "h-10 shrink-0 rounded-full px-3 font-normal"
206
- }, we = u(
207
- () => U(
208
- { content: "z-50 h-[calc(100dvh-4rem)] max-h-none rounded-t-lg bg-default" },
209
- e.ui.phoneDrawer
210
- )
211
- ), Se = u(
212
- () => U(
213
- { content: "z-50 h-dvh max-w-none rounded-r-lg bg-default" },
214
- e.ui.padDrawer
215
- )
216
- ), ke = u(
217
- () => U(xe, e.ui.search)
218
- ), We = u(
219
- () => U(ge, e.ui.menuButton)
220
- );
221
- function Z() {
222
- g.value && (o.value = !0);
223
- }
224
- function W() {
225
- o.value = !1;
226
- }
227
- function q() {
228
- o.value ? W() : Z();
229
- }
230
- function Ce(a) {
231
- l("searchSelect", a), b.value = !1, W();
232
- }
233
- z(() => e.navigationKey, W), z(p, W), z(o, async (a, s) => {
234
- var m, O;
235
- a || !s || (await ze(), (O = (m = Y.value) == null ? void 0 : m.$el) == null || O.focus());
236
- });
237
- const C = u(() => ({
238
- mode: p.value,
239
- drawerOpen: o.value,
240
- openDrawer: Z,
241
- closeDrawer: W,
242
- toggleDrawer: q
243
- }));
244
- return (a, s) => {
245
- const m = $e, O = Oe;
246
- return x(), S("div", {
247
- "data-testid": "app-layout",
248
- class: d(i.value.root({ class: e.ui.root })),
249
- style: A(fe.value)
250
- }, [
251
- p.value === "desktop" ? (x(), S("aside", {
252
- key: 0,
253
- "data-testid": "desktop-sidebar",
254
- class: d(i.value.desktopSidebar({ class: e.ui.desktopSidebar })),
255
- style: me
256
- }, [
257
- h(a.$slots, "sidebar", $(B(C.value)))
258
- ], 2)) : p.value === "phone" ? (x(), S(H, { key: 1 }, [
259
- o.value ? (x(), S("button", {
260
- key: 0,
261
- "data-testid": "compact-nav-overlay",
262
- type: "button",
263
- tabindex: "-1",
264
- "aria-label": "关闭导航",
265
- class: d(i.value.overlay({ class: e.ui.overlay })),
266
- onClick: W
267
- }, null, 2)) : D("", !0),
268
- G(m, {
269
- open: o.value,
270
- "onUpdate:open": s[0] || (s[0] = (v) => o.value = v),
271
- direction: "bottom",
272
- modal: !1,
273
- overlay: !1,
274
- handle: !0,
275
- title: t.menuOpenLabel,
276
- ui: we.value
277
- }, {
278
- content: ne(() => [
279
- f("div", {
280
- id: P,
281
- "data-testid": "phone-drawer-content",
282
- class: d(i.value.phoneDrawerContent({ class: e.ui.phoneDrawerContent }))
283
- }, [
284
- f("div", {
285
- "data-testid": "phone-sidebar-frame",
286
- class: d(i.value.phoneSidebarFrame({ class: e.ui.phoneSidebarFrame }))
287
- }, [
288
- n["phone-sidebar"] ? h(a.$slots, "phone-sidebar", $(B(C.value)), void 0, void 0, 0) : h(a.$slots, "sidebar", $(B(C.value)), void 0, void 0, 1)
289
- ], 2)
290
- ], 2)
291
- ]),
292
- _: 3
293
- }, 8, ["open", "title", "ui"])
294
- ], 64)) : (x(), S(H, { key: 2 }, [
295
- o.value ? (x(), S("button", {
296
- key: 0,
297
- "data-testid": "compact-nav-overlay",
298
- type: "button",
299
- tabindex: "-1",
300
- "aria-label": "关闭导航",
301
- class: d(i.value.overlay({ class: e.ui.overlay })),
302
- onClick: W
303
- }, null, 2)) : D("", !0),
304
- G(m, {
305
- open: o.value,
306
- "onUpdate:open": s[1] || (s[1] = (v) => o.value = v),
307
- direction: "left",
308
- modal: !1,
309
- overlay: !1,
310
- handle: !1,
311
- title: t.menuOpenLabel,
312
- ui: Se.value
313
- }, {
314
- content: ne(() => [
315
- f("div", {
316
- id: P,
317
- "data-testid": "pad-drawer-content",
318
- class: d(i.value.padDrawerContent({ class: e.ui.padDrawerContent }))
319
- }, [
320
- f("div", {
321
- "data-testid": "pad-sidebar-frame",
322
- class: d(i.value.padSidebarFrame({ class: e.ui.padSidebarFrame })),
323
- style: ve
324
- }, [
325
- n["pad-sidebar"] ? h(a.$slots, "pad-sidebar", $(B(C.value)), void 0, void 0, 0) : h(a.$slots, "sidebar", $(B(C.value)), void 0, void 0, 1)
326
- ], 2)
327
- ], 2)
328
- ]),
329
- _: 3
330
- }, 8, ["open", "title", "ui"])
331
- ], 64)),
332
- f("main", {
333
- "data-testid": "app-layout-main",
334
- class: d(i.value.main({ class: e.ui.main }))
335
- }, [
336
- f("header", {
337
- "data-testid": "app-layout-header",
338
- class: d([i.value.header({ class: e.ui.header }), X.value]),
339
- style: A(J.value)
340
- }, [
341
- f("div", {
342
- "data-testid": "app-layout-header-heading",
343
- class: d(i.value.headerHeading({ class: e.ui.headerHeading }))
344
- }, [
345
- N.value ? h(a.$slots, "header-title", { title: N.value }, () => [
346
- f("h1", {
347
- "data-testid": "app-layout-title",
348
- class: d(i.value.title({ class: e.ui.title }))
349
- }, oe(N.value), 3)
350
- ], void 0, 0) : D("", !0),
351
- E.value ? h(a.$slots, "header-description", { description: E.value }, () => [
352
- f("p", {
353
- "data-testid": "app-layout-description",
354
- class: d(i.value.description({ class: e.ui.description }))
355
- }, oe(E.value), 3)
356
- ], void 0, 1) : D("", !0)
357
- ], 2),
358
- f("div", {
359
- "data-testid": "app-layout-header-suffix",
360
- class: d(i.value.headerSuffix({ class: e.ui.headerSuffix }))
361
- }, [
362
- h(a.$slots, "header-suffix"),
363
- f("div", {
364
- ref_key: "suffixTarget",
365
- ref: w,
366
- "data-testid": "app-layout-suffix-target",
367
- class: d(i.value.pageHeaderSuffixTarget({ class: e.ui.pageHeaderSuffixTarget }))
368
- }, null, 2)
369
- ], 2)
370
- ], 6),
371
- f("div", {
372
- "data-testid": "app-layout-content",
373
- class: d([i.value.content({ class: e.ui.content }), X.value]),
374
- style: A(J.value)
375
- }, [
376
- h(a.$slots, "default")
377
- ], 6)
378
- ], 2),
379
- g.value ? (x(), S("div", {
380
- key: 3,
381
- "data-testid": "compact-nav-dock",
382
- class: d(i.value.dock({ class: e.ui.dock }))
383
- }, [
384
- n.dock ? h(a.$slots, "dock", $(B(C.value)), void 0, void 0, 0) : (x(), S(H, { key: 1 }, [
385
- t.searchGroups.length ? (x(), Te(Ee, {
386
- key: 0,
387
- open: b.value,
388
- "onUpdate:open": s[2] || (s[2] = (v) => b.value = v),
389
- groups: t.searchGroups,
390
- label: t.searchLabel,
391
- shortcut: t.searchShortcut,
392
- kbds: [],
393
- ui: ke.value,
394
- onSelect: Ce
395
- }, null, 8, ["open", "groups", "label", "shortcut", "ui"])) : D("", !0),
396
- G(O, {
397
- ref_key: "menuButton",
398
- ref: Y,
399
- "data-testid": "compact-menu-button",
400
- color: "neutral",
401
- variant: "ghost",
402
- icon: o.value ? t.menuCloseIcon : t.menuOpenIcon,
403
- label: o.value ? t.menuCloseLabel : t.menuOpenLabel,
404
- "aria-controls": P,
405
- "aria-expanded": o.value,
406
- "aria-haspopup": "dialog",
407
- ui: We.value,
408
- onClick: q
409
- }, null, 8, ["icon", "label", "aria-expanded", "ui"])
410
- ], 64))
411
- ], 2)) : D("", !0)
412
- ], 6);
413
- };
414
- }
415
- });
416
- export {
417
- nt as _
418
- };
@@ -1,257 +0,0 @@
1
- import te from "@nuxt/ui/components/Popover.vue";
2
- import oe from "@nuxt/ui/runtime/vue/components/Icon.vue";
3
- import le from "@nuxt/ui/components/Input.vue";
4
- import ne from "@nuxt/ui/components/Button.vue";
5
- import { defineComponent as ae, useModel as se, ref as x, inject as ie, computed as i, onMounted as ce, watch as K, nextTick as de, openBlock as l, createBlock as g, withCtx as j, createVNode as M, createSlots as re, createElementVNode as f, normalizeClass as k, toDisplayString as b, withModifiers as U, createElementBlock as s, Fragment as z, renderList as B, createCommentVNode as D, mergeModels as Q } from "vue";
6
- import { D as ue } from "./district-service-cOu1tbQG.js";
7
- const ve = { class: "w-120 p-2 flex flex-col gap-2" }, me = {
8
- key: 0,
9
- class: "max-h-64 overflow-y-auto flex flex-col gap-0.5"
10
- }, fe = ["onClick"], pe = { class: "flex-1 truncate" }, he = {
11
- key: 1,
12
- class: "flex items-center justify-center h-10 text-sm text-muted"
13
- }, _e = {
14
- key: 1,
15
- class: "flex divide-x divide-default border border-default rounded-sm overflow-hidden"
16
- }, ye = { class: "flex-1 max-h-64 overflow-y-auto py-1 minimal-scrollbar" }, xe = ["onClick"], ge = { class: "truncate" }, ke = { class: "flex-1 max-h-64 overflow-y-auto py-1 minimal-scrollbar" }, be = ["onClick"], Ce = { class: "truncate" }, we = {
17
- key: 1,
18
- class: "flex items-center justify-center h-full text-sm text-muted/50 py-4"
19
- }, Ve = { class: "flex-1 max-h-64 overflow-y-auto py-1 minimal-scrollbar" }, $e = ["onClick"], je = { class: "truncate" }, ze = {
20
- key: 1,
21
- class: "flex items-center justify-center h-full text-sm text-muted/50 py-4"
22
- }, Pe = /* @__PURE__ */ ae({
23
- name: "SaberDistrictSelect",
24
- __name: "SaberDistrictSelect",
25
- props: /* @__PURE__ */ Q({
26
- districts: {},
27
- placeholder: { default: "请选择省 / 市 / 区" },
28
- clearable: { type: Boolean, default: !0 },
29
- disabled: { type: Boolean, default: !1 },
30
- loading: { type: Boolean, default: void 0 }
31
- }, {
32
- modelValue: { default: void 0 },
33
- modelModifiers: {}
34
- }),
35
- emits: /* @__PURE__ */ Q(["change"], ["update:modelValue"]),
36
- setup(C, { expose: T, emit: A }) {
37
- const h = C, L = A, a = se(C, "modelValue"), w = x(!1), P = x(null), u = x(null), c = x(null), _ = x(""), n = ie(ue, void 0), S = i(() => h.districts === void 0), V = i(
38
- () => h.districts ?? (n == null ? void 0 : n.districts.value) ?? []
39
- ), $ = i(
40
- () => h.loading ?? (S.value ? (n == null ? void 0 : n.loading.value) ?? !1 : !1)
41
- ), G = i(() => $.value ? "行政区加载中..." : h.placeholder);
42
- async function E() {
43
- if (!(!S.value || !n || n.districts.value.length))
44
- try {
45
- await n.load();
46
- } catch (t) {
47
- console.error("[SaberUI] Failed to load district data.", t);
48
- }
49
- }
50
- ce(() => void E()), K(() => h.districts, (t) => {
51
- t === void 0 && E();
52
- }), K(w, async (t) => {
53
- var o, v, p;
54
- if (!t) {
55
- _.value = "";
56
- return;
57
- }
58
- if (a.value) {
59
- const m = V.value.find((y) => {
60
- var e;
61
- return y.adcode === ((e = a.value) == null ? void 0 : e.provinceCode);
62
- }) ?? null;
63
- u.value = m, c.value = ((o = m == null ? void 0 : m.districts) == null ? void 0 : o.find((y) => {
64
- var e;
65
- return y.adcode === ((e = a.value) == null ? void 0 : e.cityCode);
66
- })) ?? null;
67
- } else
68
- u.value = null, c.value = null;
69
- await de(), (p = (v = P.value) == null ? void 0 : v.input) == null || p.focus();
70
- });
71
- const N = i(() => {
72
- var t;
73
- return ((t = u.value) == null ? void 0 : t.districts) ?? [];
74
- }), R = i(() => {
75
- var t;
76
- return ((t = c.value) == null ? void 0 : t.districts) ?? [];
77
- });
78
- function H(t) {
79
- u.value = t, c.value = null;
80
- }
81
- function J(t) {
82
- c.value = t;
83
- }
84
- function W(t) {
85
- !u.value || !c.value || O({
86
- province: u.value.name,
87
- provinceCode: u.value.adcode,
88
- city: c.value.name,
89
- cityCode: c.value.adcode,
90
- district: t.name,
91
- districtCode: t.adcode
92
- });
93
- }
94
- const X = i(() => {
95
- const t = [];
96
- for (const o of V.value)
97
- for (const v of o.districts ?? [])
98
- for (const p of v.districts ?? [])
99
- t.push({
100
- label: `${o.name} / ${v.name} / ${p.name}`,
101
- province: o.name,
102
- provinceCode: o.adcode,
103
- city: v.name,
104
- cityCode: v.adcode,
105
- district: p.name,
106
- districtCode: p.adcode
107
- });
108
- return t;
109
- }), F = i(() => {
110
- const t = _.value.trim();
111
- return t ? X.value.filter((o) => o.province.includes(t) || o.city.includes(t) || o.district.includes(t)).slice(0, 50) : [];
112
- });
113
- function O(t) {
114
- a.value = t, L("change", t), w.value = !1;
115
- }
116
- function Y() {
117
- a.value = void 0, u.value = null, c.value = null, L("change", void 0);
118
- }
119
- const Z = i(() => a.value ? `${a.value.province} / ${a.value.city} / ${a.value.district}` : G.value), q = i(() => a.value != null), ee = i(() => _.value.trim().length > 0);
120
- return T({
121
- districts: V,
122
- loading: $,
123
- error: i(() => (n == null ? void 0 : n.error.value) ?? null),
124
- reload: () => n == null ? void 0 : n.load(!0)
125
- }), (t, o) => {
126
- const v = ne, p = le, m = oe, y = te;
127
- return l(), g(y, {
128
- open: w.value,
129
- "onUpdate:open": o[3] || (o[3] = (e) => w.value = e),
130
- content: { align: "start", sideOffset: 4 }
131
- }, {
132
- content: j(() => [
133
- f("div", ve, [
134
- M(p, {
135
- ref_key: "searchInputRef",
136
- ref: P,
137
- modelValue: _.value,
138
- "onUpdate:modelValue": o[2] || (o[2] = (e) => _.value = e),
139
- placeholder: "搜索省 / 市 / 区...",
140
- ui: { base: "h-9", leadingIcon: "size-4" },
141
- "leading-icon": "i-solar:minimalistic-magnifer-outline"
142
- }, null, 8, ["modelValue"]),
143
- ee.value ? (l(), s("div", me, [
144
- F.value.length > 0 ? (l(!0), s(z, { key: 0 }, B(F.value, (e) => {
145
- var d, r;
146
- return l(), s("div", {
147
- key: e.districtCode,
148
- class: k(["flex items-center h-9 px-3 rounded-sm cursor-pointer select-none text-sm hover:bg-muted", ((d = a.value) == null ? void 0 : d.districtCode) === e.districtCode ? "bg-accented/70" : ""]),
149
- onClick: (I) => O(e)
150
- }, [
151
- f("span", pe, b(e.label), 1),
152
- ((r = a.value) == null ? void 0 : r.districtCode) === e.districtCode ? (l(), g(m, {
153
- key: 0,
154
- name: "i-lucide:check",
155
- class: "size-4 shrink-0 ml-2 text-primary"
156
- })) : D("", !0)
157
- ], 10, fe);
158
- }), 128)) : (l(), s("div", he, "无匹配结果"))
159
- ])) : (l(), s("div", _e, [
160
- f("div", ye, [
161
- (l(!0), s(z, null, B(V.value, (e) => {
162
- var d, r;
163
- return l(), s("div", {
164
- key: e.adcode,
165
- class: k(["flex items-center justify-between h-9 px-3 cursor-pointer select-none text-sm", ((d = u.value) == null ? void 0 : d.adcode) === e.adcode ? "bg-accented/70" : "hover:bg-muted"]),
166
- onClick: (I) => H(e)
167
- }, [
168
- f("span", ge, b(e.name), 1),
169
- ((r = u.value) == null ? void 0 : r.adcode) === e.adcode ? (l(), g(m, {
170
- key: 0,
171
- name: "i-lucide:chevron-right",
172
- class: "size-4 shrink-0 ml-1 text-muted"
173
- })) : D("", !0)
174
- ], 10, xe);
175
- }), 128))
176
- ]),
177
- f("div", ke, [
178
- N.value.length > 0 ? (l(!0), s(z, { key: 0 }, B(N.value, (e) => {
179
- var d, r;
180
- return l(), s("div", {
181
- key: e.adcode,
182
- class: k(["flex items-center justify-between h-9 px-3 cursor-pointer select-none text-sm", ((d = c.value) == null ? void 0 : d.adcode) === e.adcode ? "bg-accented/70" : "hover:bg-muted"]),
183
- onClick: (I) => J(e)
184
- }, [
185
- f("span", Ce, b(e.name), 1),
186
- ((r = c.value) == null ? void 0 : r.adcode) === e.adcode ? (l(), g(m, {
187
- key: 0,
188
- name: "i-lucide:chevron-right",
189
- class: "size-4 shrink-0 ml-1 text-muted"
190
- })) : D("", !0)
191
- ], 10, be);
192
- }), 128)) : (l(), s("div", we, "请选择省份"))
193
- ]),
194
- f("div", Ve, [
195
- R.value.length > 0 ? (l(!0), s(z, { key: 0 }, B(R.value, (e) => {
196
- var d, r;
197
- return l(), s("div", {
198
- key: e.adcode,
199
- class: k(["flex items-center justify-between h-9 px-3 cursor-pointer select-none text-sm", ((d = a.value) == null ? void 0 : d.districtCode) === e.adcode ? "bg-accented/70" : "hover:bg-muted"]),
200
- onClick: (I) => W(e)
201
- }, [
202
- f("span", je, b(e.name), 1),
203
- ((r = a.value) == null ? void 0 : r.districtCode) === e.adcode ? (l(), g(m, {
204
- key: 0,
205
- name: "i-lucide:check",
206
- class: "size-3.5 shrink-0 ml-1 text-primary"
207
- })) : D("", !0)
208
- ], 10, $e);
209
- }), 128)) : (l(), s("div", ze, "请选择城市"))
210
- ])
211
- ]))
212
- ])
213
- ]),
214
- default: j(() => [
215
- M(v, {
216
- color: "neutral",
217
- variant: "outline",
218
- disabled: C.disabled || $.value,
219
- loading: $.value,
220
- ui: { base: "rounded-sm justify-between h-10", trailingIcon: "size-4" },
221
- "trailing-icon": "i-lucide:chevron-down",
222
- class: "w-full saberButton"
223
- }, re({
224
- default: j(() => [
225
- f("span", {
226
- class: k(["truncate", q.value ? "" : "text-muted/60 font-normal"])
227
- }, b(Z.value), 3)
228
- ]),
229
- _: 2
230
- }, [
231
- q.value && C.clearable ? {
232
- name: "trailing",
233
- fn: j(() => [
234
- M(v, {
235
- color: "neutral",
236
- variant: "ghost",
237
- icon: "i-solar:close-circle-outline",
238
- ui: { base: "p-1 min-w-0 -mr-1.5", leadingIcon: "size-4" },
239
- onPointerdown: o[0] || (o[0] = U(() => {
240
- }, ["stop", "prevent"])),
241
- onMousedown: o[1] || (o[1] = U(() => {
242
- }, ["stop", "prevent"])),
243
- onClick: U(Y, ["stop", "prevent"])
244
- })
245
- ]),
246
- key: "0"
247
- } : void 0
248
- ]), 1032, ["disabled", "loading"])
249
- ]),
250
- _: 1
251
- }, 8, ["open"]);
252
- };
253
- }
254
- });
255
- export {
256
- Pe as _
257
- };