straw-ui-vue 0.1.0
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.
- package/README.md +42 -0
- package/dist/_virtual/_plugin-vue_export-helper.cjs +1 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/components/st-button/index.d.ts +162 -0
- package/dist/components/st-button/st-button.vue.cjs +1 -0
- package/dist/components/st-button/st-button.vue.d.ts +29 -0
- package/dist/components/st-button/st-button.vue.js +5 -0
- package/dist/components/st-button/st-button.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-button/st-button.vue_vue_type_script_setup_true_lang.js +81 -0
- package/dist/components/st-button/types.d.ts +49 -0
- package/dist/components/st-button.cjs +1 -0
- package/dist/components/st-button.js +6 -0
- package/dist/components/st-checkbox/index.d.ts +153 -0
- package/dist/components/st-checkbox/st-checkbox.vue.cjs +1 -0
- package/dist/components/st-checkbox/st-checkbox.vue.d.ts +27 -0
- package/dist/components/st-checkbox/st-checkbox.vue.js +5 -0
- package/dist/components/st-checkbox/st-checkbox.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-checkbox/st-checkbox.vue_vue_type_script_setup_true_lang.js +109 -0
- package/dist/components/st-checkbox/types.d.ts +20 -0
- package/dist/components/st-checkbox-group/index.d.ts +171 -0
- package/dist/components/st-checkbox-group/st-checkbox-group.vue.cjs +1 -0
- package/dist/components/st-checkbox-group/st-checkbox-group.vue.d.ts +29 -0
- package/dist/components/st-checkbox-group/st-checkbox-group.vue.js +5 -0
- package/dist/components/st-checkbox-group/st-checkbox-group.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-checkbox-group/st-checkbox-group.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/components/st-checkbox-group/types.d.ts +43 -0
- package/dist/components/st-checkbox-group.cjs +1 -0
- package/dist/components/st-checkbox-group.js +6 -0
- package/dist/components/st-checkbox.cjs +1 -0
- package/dist/components/st-checkbox.js +6 -0
- package/dist/components/st-dialog/index.d.ts +243 -0
- package/dist/components/st-dialog/st-dialog.vue.cjs +1 -0
- package/dist/components/st-dialog/st-dialog.vue.d.ts +41 -0
- package/dist/components/st-dialog/st-dialog.vue.js +5 -0
- package/dist/components/st-dialog/st-dialog.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-dialog/st-dialog.vue_vue_type_script_setup_true_lang.js +175 -0
- package/dist/components/st-dialog/types.d.ts +29 -0
- package/dist/components/st-dialog.cjs +1 -0
- package/dist/components/st-dialog.js +6 -0
- package/dist/components/st-input/index.d.ts +315 -0
- package/dist/components/st-input/st-input.vue.cjs +1 -0
- package/dist/components/st-input/st-input.vue.d.ts +48 -0
- package/dist/components/st-input/st-input.vue.js +7 -0
- package/dist/components/st-input/st-input.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-input/st-input.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/st-input/types.d.ts +68 -0
- package/dist/components/st-input.cjs +1 -0
- package/dist/components/st-input.js +6 -0
- package/dist/components/st-menu/index.d.ts +217 -0
- package/dist/components/st-menu/st-menu-node.vue.cjs +1 -0
- package/dist/components/st-menu/st-menu-node.vue.d.ts +14 -0
- package/dist/components/st-menu/st-menu-node.vue.js +5 -0
- package/dist/components/st-menu/st-menu-node.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-menu/st-menu-node.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/components/st-menu/st-menu.vue.cjs +1 -0
- package/dist/components/st-menu/st-menu.vue.d.ts +26 -0
- package/dist/components/st-menu/st-menu.vue.js +5 -0
- package/dist/components/st-menu/st-menu.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-menu/st-menu.vue_vue_type_script_setup_true_lang.js +86 -0
- package/dist/components/st-menu/types.d.ts +82 -0
- package/dist/components/st-menu.cjs +1 -0
- package/dist/components/st-menu.js +7 -0
- package/dist/components/st-popover/index.d.ts +243 -0
- package/dist/components/st-popover/st-popover.vue.cjs +1 -0
- package/dist/components/st-popover/st-popover.vue.d.ts +37 -0
- package/dist/components/st-popover/st-popover.vue.js +5 -0
- package/dist/components/st-popover/st-popover.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-popover/st-popover.vue_vue_type_script_setup_true_lang.js +355 -0
- package/dist/components/st-popover/types.d.ts +103 -0
- package/dist/components/st-popover.cjs +1 -0
- package/dist/components/st-popover.js +6 -0
- package/dist/components/st-radio/index.d.ts +135 -0
- package/dist/components/st-radio/st-radio.vue.cjs +1 -0
- package/dist/components/st-radio/st-radio.vue.d.ts +28 -0
- package/dist/components/st-radio/st-radio.vue.js +5 -0
- package/dist/components/st-radio/st-radio.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-radio/st-radio.vue_vue_type_script_setup_true_lang.js +88 -0
- package/dist/components/st-radio/types.d.ts +15 -0
- package/dist/components/st-radio-group/index.d.ts +180 -0
- package/dist/components/st-radio-group/st-radio-group.vue.cjs +1 -0
- package/dist/components/st-radio-group/st-radio-group.vue.d.ts +35 -0
- package/dist/components/st-radio-group/st-radio-group.vue.js +5 -0
- package/dist/components/st-radio-group/st-radio-group.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-radio-group/st-radio-group.vue_vue_type_script_setup_true_lang.js +66 -0
- package/dist/components/st-radio-group/types.d.ts +43 -0
- package/dist/components/st-radio-group.cjs +1 -0
- package/dist/components/st-radio-group.js +6 -0
- package/dist/components/st-radio.cjs +1 -0
- package/dist/components/st-radio.js +6 -0
- package/dist/components/st-select/index.d.ts +306 -0
- package/dist/components/st-select/st-select.vue.cjs +1 -0
- package/dist/components/st-select/st-select.vue.d.ts +47 -0
- package/dist/components/st-select/st-select.vue.js +5 -0
- package/dist/components/st-select/st-select.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-select/st-select.vue_vue_type_script_setup_true_lang.js +200 -0
- package/dist/components/st-select/types.d.ts +85 -0
- package/dist/components/st-select.cjs +1 -0
- package/dist/components/st-select.js +6 -0
- package/dist/components/st-sidebar/index.d.ts +63 -0
- package/dist/components/st-sidebar/st-sidebar.vue.cjs +1 -0
- package/dist/components/st-sidebar/st-sidebar.vue.d.ts +11 -0
- package/dist/components/st-sidebar/st-sidebar.vue.js +5 -0
- package/dist/components/st-sidebar/st-sidebar.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-sidebar/st-sidebar.vue_vue_type_script_setup_true_lang.js +108 -0
- package/dist/components/st-sidebar/types.d.ts +56 -0
- package/dist/components/st-sidebar-item/index.d.ts +63 -0
- package/dist/components/st-sidebar-item/st-sidebar-item.vue.cjs +1 -0
- package/dist/components/st-sidebar-item/st-sidebar-item.vue.d.ts +11 -0
- package/dist/components/st-sidebar-item/st-sidebar-item.vue.js +5 -0
- package/dist/components/st-sidebar-item/st-sidebar-item.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-sidebar-item/st-sidebar-item.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/components/st-sidebar-item/types.d.ts +19 -0
- package/dist/components/st-sidebar-item.cjs +1 -0
- package/dist/components/st-sidebar-item.js +6 -0
- package/dist/components/st-sidebar.cjs +1 -0
- package/dist/components/st-sidebar.js +6 -0
- package/dist/components/st-splitter/index.d.ts +88 -0
- package/dist/components/st-splitter/st-splitter.vue.cjs +1 -0
- package/dist/components/st-splitter/st-splitter.vue.d.ts +16 -0
- package/dist/components/st-splitter/st-splitter.vue.js +5 -0
- package/dist/components/st-splitter/st-splitter.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-splitter/st-splitter.vue_vue_type_script_setup_true_lang.js +29 -0
- package/dist/components/st-splitter/types.d.ts +192 -0
- package/dist/components/st-splitter/useSplitter.cjs +1 -0
- package/dist/components/st-splitter/useSplitter.d.ts +24 -0
- package/dist/components/st-splitter/useSplitter.js +129 -0
- package/dist/components/st-splitter-panel/index.d.ts +180 -0
- package/dist/components/st-splitter-panel/st-splitter-panel.vue.cjs +1 -0
- package/dist/components/st-splitter-panel/st-splitter-panel.vue.d.ts +33 -0
- package/dist/components/st-splitter-panel/st-splitter-panel.vue.js +5 -0
- package/dist/components/st-splitter-panel/st-splitter-panel.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-splitter-panel/st-splitter-panel.vue_vue_type_script_setup_true_lang.js +164 -0
- package/dist/components/st-splitter-panel/types.d.ts +27 -0
- package/dist/components/st-splitter-panel.cjs +1 -0
- package/dist/components/st-splitter-panel.js +6 -0
- package/dist/components/st-splitter.cjs +1 -0
- package/dist/components/st-splitter.js +7 -0
- package/dist/components/st-toggle/index.d.ts +159 -0
- package/dist/components/st-toggle/st-toggle.vue.cjs +1 -0
- package/dist/components/st-toggle/st-toggle.vue.d.ts +25 -0
- package/dist/components/st-toggle/st-toggle.vue.js +5 -0
- package/dist/components/st-toggle/st-toggle.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-toggle/st-toggle.vue_vue_type_script_setup_true_lang.js +62 -0
- package/dist/components/st-toggle/types.d.ts +38 -0
- package/dist/components/st-toggle.cjs +1 -0
- package/dist/components/st-toggle.js +6 -0
- package/dist/components/st-tooltip/index.d.ts +183 -0
- package/dist/components/st-tooltip/st-tooltip.vue.cjs +1 -0
- package/dist/components/st-tooltip/st-tooltip.vue.d.ts +29 -0
- package/dist/components/st-tooltip/st-tooltip.vue.js +5 -0
- package/dist/components/st-tooltip/st-tooltip.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-tooltip/st-tooltip.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/components/st-tooltip/types.d.ts +79 -0
- package/dist/components/st-tooltip.cjs +1 -0
- package/dist/components/st-tooltip.js +6 -0
- package/dist/components/st-tree/index.d.ts +114 -0
- package/dist/components/st-tree/st-tree-node.vue.cjs +1 -0
- package/dist/components/st-tree/st-tree-node.vue.d.ts +4 -0
- package/dist/components/st-tree/st-tree-node.vue.js +5 -0
- package/dist/components/st-tree/st-tree-node.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-tree/st-tree-node.vue_vue_type_script_setup_true_lang.js +87 -0
- package/dist/components/st-tree/st-tree.vue.cjs +1 -0
- package/dist/components/st-tree/st-tree.vue.d.ts +50 -0
- package/dist/components/st-tree/st-tree.vue.js +5 -0
- package/dist/components/st-tree/st-tree.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/st-tree/st-tree.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/components/st-tree/types.d.ts +87 -0
- package/dist/components/st-tree.cjs +1 -0
- package/dist/components/st-tree.js +6 -0
- package/dist/components/types.d.ts +41 -0
- package/dist/index.cjs +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +3005 -0
- package/dist/index.js +47 -0
- package/dist/utils/cn.cjs +1 -0
- package/dist/utils/cn.d.ts +11 -0
- package/dist/utils/cn.js +8 -0
- package/dist/utils/cva/index.cjs +1 -0
- package/dist/utils/cva/index.d.ts +9 -0
- package/dist/utils/cva/index.js +25 -0
- package/dist/utils/cva/types.d.ts +45 -0
- package/dist/utils/directive/index.cjs +1 -0
- package/dist/utils/directive/index.d.ts +4 -0
- package/dist/utils/directive/index.js +10 -0
- package/dist/utils/directive/intersection.cjs +1 -0
- package/dist/utils/directive/intersection.d.ts +6 -0
- package/dist/utils/directive/intersection.js +20 -0
- package/dist/utils/directive/interval.cjs +1 -0
- package/dist/utils/directive/interval.d.ts +6 -0
- package/dist/utils/directive/interval.js +14 -0
- package/dist/utils/directive/move.cjs +1 -0
- package/dist/utils/directive/move.d.ts +6 -0
- package/dist/utils/directive/move.js +42 -0
- package/dist/utils/directive/resize.cjs +1 -0
- package/dist/utils/directive/resize.d.ts +6 -0
- package/dist/utils/directive/resize.js +17 -0
- package/dist/utils/with-install.cjs +1 -0
- package/dist/utils/with-install.d.ts +4 -0
- package/dist/utils/with-install.js +10 -0
- package/package.json +87 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
import t from "../st-input/st-input.vue.js";
|
|
3
|
+
import n from "../st-popover/st-popover.vue.js";
|
|
4
|
+
import { Fragment as r, computed as i, createBlock as ee, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createSlots as c, createVNode as te, defineComponent as l, mergeModels as u, normalizeClass as d, normalizeStyle as f, openBlock as p, ref as m, renderList as h, renderSlot as g, toDisplayString as _, unref as ne, useAttrs as v, useModel as y, useSlots as re, withCtx as b } from "vue";
|
|
5
|
+
//#region src/components/st-select/st-select.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var ie = { class: "st-select__dropdown max-h-60 w-full overflow-auto px-1 py-1.5" }, x = { class: "st-select__group-label px-3 py-2 text-xs font-semibold text-muted-foreground" }, S = ["onClick"], C = { class: "flex-1 truncate text-foreground" }, w = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "st-select__check text-primary"
|
|
9
|
+
}, T = ["onClick"], E = { class: "flex-1 truncate text-foreground" }, D = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "st-select__check text-primary"
|
|
12
|
+
}, O = {
|
|
13
|
+
key: 1,
|
|
14
|
+
class: "st-select__empty px-3 py-2 text-center text-muted-foreground"
|
|
15
|
+
}, k = /*@__PURE__*/ l({
|
|
16
|
+
name: "StSelect",
|
|
17
|
+
inheritAttrs: !1,
|
|
18
|
+
__name: "st-select",
|
|
19
|
+
props: /*@__PURE__*/ u({
|
|
20
|
+
list: { default: () => [] },
|
|
21
|
+
labelKey: { default: "label" },
|
|
22
|
+
valueKey: { default: "value" },
|
|
23
|
+
placeholder: { default: "" },
|
|
24
|
+
disabled: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: !1
|
|
27
|
+
},
|
|
28
|
+
clearable: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: !1
|
|
31
|
+
},
|
|
32
|
+
multiple: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !1
|
|
35
|
+
},
|
|
36
|
+
filterable: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: !1
|
|
39
|
+
},
|
|
40
|
+
group: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !1
|
|
43
|
+
},
|
|
44
|
+
popoverClass: { default: "" },
|
|
45
|
+
popoverStyle: { default: "" }
|
|
46
|
+
}, {
|
|
47
|
+
modelValue: { default: void 0 },
|
|
48
|
+
modelModifiers: {}
|
|
49
|
+
}),
|
|
50
|
+
emits: /*@__PURE__*/ u([
|
|
51
|
+
"update:modelValue",
|
|
52
|
+
"change",
|
|
53
|
+
"clear",
|
|
54
|
+
"visibleChange",
|
|
55
|
+
"removeTag",
|
|
56
|
+
"filter"
|
|
57
|
+
], ["update:modelValue"]),
|
|
58
|
+
setup(l, { expose: u, emit: k }) {
|
|
59
|
+
re();
|
|
60
|
+
let A = v(), j = l, M = k, N = y(l, "modelValue"), P = m(null), ae = m(null), F = m(!1), I = m(""), L = m(!1), R = m(!1), z = m(0), B = (e) => String(e.label), V = (e) => e.value, H = (e, t) => e[t], U = i(() => j.list.map((e) => {
|
|
61
|
+
if (typeof e == "object" && e) {
|
|
62
|
+
let t = e, n = H(t, j.labelKey), r = H(t, j.valueKey);
|
|
63
|
+
return {
|
|
64
|
+
label: String(n ?? ""),
|
|
65
|
+
value: r,
|
|
66
|
+
disabled: e.disabled,
|
|
67
|
+
children: e.children
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
label: String(e),
|
|
72
|
+
value: e
|
|
73
|
+
};
|
|
74
|
+
})), W = i(() => {
|
|
75
|
+
if (!j.group) return U.value;
|
|
76
|
+
let e = [];
|
|
77
|
+
return U.value.forEach((t) => {
|
|
78
|
+
t.children && t.children.length > 0 && e.push(...t.children);
|
|
79
|
+
}), e;
|
|
80
|
+
}), G = i(() => {
|
|
81
|
+
if (!j.filterable || !I.value) return j.group ? W.value : U.value;
|
|
82
|
+
let e = I.value.toLowerCase();
|
|
83
|
+
return (j.group ? W.value : U.value).filter((t) => t.label.toLowerCase().includes(e));
|
|
84
|
+
}), K = i(() => {
|
|
85
|
+
if (!j.group) return [];
|
|
86
|
+
if (!j.filterable || !I.value) return U.value.filter((e) => e.children && e.children.length > 0).map((e) => ({
|
|
87
|
+
label: e.label,
|
|
88
|
+
children: e.children
|
|
89
|
+
}));
|
|
90
|
+
let e = I.value.toLowerCase();
|
|
91
|
+
return U.value.filter((e) => e.children && e.children.length > 0).map((t) => ({
|
|
92
|
+
label: t.label,
|
|
93
|
+
children: t.children.filter((t) => t.label.toLowerCase().includes(e))
|
|
94
|
+
})).filter((e) => e.children.length > 0);
|
|
95
|
+
}), q = i(() => {
|
|
96
|
+
if (!j.multiple || !Array.isArray(N.value)) return [];
|
|
97
|
+
let e = N.value, t = j.group ? W.value : U.value;
|
|
98
|
+
return e.map((e) => {
|
|
99
|
+
let n = t.find((t) => t.value === e);
|
|
100
|
+
return n ? n.label : "";
|
|
101
|
+
}).filter((e) => e !== "");
|
|
102
|
+
}), J = i(() => {
|
|
103
|
+
if (j.multiple || N.value === void 0) return "";
|
|
104
|
+
let e = (j.group ? W.value : U.value).find((e) => e.value === N.value);
|
|
105
|
+
return e ? e.label : "";
|
|
106
|
+
}), Y = (e) => j.multiple && Array.isArray(N.value) ? N.value.includes(e.value) : N.value === e.value, oe = i(() => e("st-select", A.class, { "st-select--focused": F.value })), X = i(() => e("st-select__arrow", "inline-flex items-center transition-transform duration-200", { "rotate-180": F.value })), se = i(() => !j.clearable || j.disabled ? !1 : j.multiple ? Array.isArray(N.value) && N.value.length > 0 && R.value : N.value !== void 0 && N.value !== null && R.value), ce = i(() => j.filterable && L.value && !j.multiple ? I.value : j.multiple ? q.value.join(",") : J.value), le = i(() => j.filterable && L.value && !j.multiple ? J.value || j.placeholder || "请选择" : (j.multiple ? q.value.length > 0 : J.value) ? "" : j.placeholder || "请选择"), ue = i(() => j.popoverStyle ? j.popoverStyle : z.value > 0 ? { width: `${z.value}px` } : {}), Z = (t) => e("st-select__option", "flex items-center gap-2 px-3 py-1.25 rounded-radius cursor-pointer transition-colors duration-100 select-none whitespace-nowrap text-3.25 leading-5 text-foreground", "hover:bg-accent", {
|
|
107
|
+
"st-select__option--selected bg-accent": Y(t),
|
|
108
|
+
"st-select__option--disabled cursor-not-allowed opacity-50": t.disabled
|
|
109
|
+
}), Q = (e) => {
|
|
110
|
+
if (!e.disabled) if (j.multiple) {
|
|
111
|
+
let t = Array.isArray(N.value) ? [...N.value] : [], n = t.indexOf(e.value);
|
|
112
|
+
n > -1 ? t.splice(n, 1) : t.push(e.value), N.value = t, M("change", t);
|
|
113
|
+
} else N.value = e.value, M("change", e.value), F.value = !1, I.value = "";
|
|
114
|
+
}, $ = () => {
|
|
115
|
+
j.disabled || (N.value, N.value = j.multiple ? [] : void 0, M("clear"), M("change", j.multiple ? [] : void 0));
|
|
116
|
+
}, de = () => {
|
|
117
|
+
R.value = !0;
|
|
118
|
+
}, fe = () => {
|
|
119
|
+
R.value = !1;
|
|
120
|
+
}, pe = (e) => {
|
|
121
|
+
M("filter", e.target.value);
|
|
122
|
+
}, me = (e) => {
|
|
123
|
+
j.filterable && L.value && (I.value = String(e));
|
|
124
|
+
}, he = (e) => {
|
|
125
|
+
M("visibleChange", e), e ? (P.value && (z.value = P.value.$el.getBoundingClientRect().width), j.filterable && !j.multiple && (L.value = !0)) : (L.value = !1, I.value = "");
|
|
126
|
+
};
|
|
127
|
+
return u({
|
|
128
|
+
focus: () => {
|
|
129
|
+
P.value?.focus();
|
|
130
|
+
},
|
|
131
|
+
blur: () => {
|
|
132
|
+
P.value?.blur();
|
|
133
|
+
},
|
|
134
|
+
clear: () => {
|
|
135
|
+
$();
|
|
136
|
+
}
|
|
137
|
+
}), (e, i) => (p(), ee(n, {
|
|
138
|
+
ref_key: "popoverRef",
|
|
139
|
+
ref: ae,
|
|
140
|
+
visible: F.value,
|
|
141
|
+
"onUpdate:visible": i[0] ||= (e) => F.value = e,
|
|
142
|
+
disabled: j.disabled,
|
|
143
|
+
"show-arrow": !1,
|
|
144
|
+
class: d(j.popoverClass),
|
|
145
|
+
style: f(ue.value),
|
|
146
|
+
placement: "bottom-left",
|
|
147
|
+
trigger: "click",
|
|
148
|
+
onVisibleChange: he
|
|
149
|
+
}, {
|
|
150
|
+
trigger: b(() => [te(t, {
|
|
151
|
+
ref_key: "selectRef",
|
|
152
|
+
ref: P,
|
|
153
|
+
class: d(oe.value),
|
|
154
|
+
style: f(ne(A).style),
|
|
155
|
+
clearable: se.value,
|
|
156
|
+
disabled: j.disabled,
|
|
157
|
+
placeholder: le.value,
|
|
158
|
+
readonly: !j.filterable,
|
|
159
|
+
"model-value": ce.value,
|
|
160
|
+
onClear: $,
|
|
161
|
+
onInput: pe,
|
|
162
|
+
"onUpdate:modelValue": me,
|
|
163
|
+
onMouseenter: de,
|
|
164
|
+
onMouseleave: fe
|
|
165
|
+
}, c({
|
|
166
|
+
suffix: b(() => [s("span", { class: d(X.value) }, [...i[1] ||= [s("i", { class: "i-ri-arrow-down-s-line" }, null, -1)]], 2)]),
|
|
167
|
+
_: 2
|
|
168
|
+
}, [e.$slots.prefix ? {
|
|
169
|
+
name: "prefix",
|
|
170
|
+
fn: b(() => [g(e.$slots, "prefix")]),
|
|
171
|
+
key: "0"
|
|
172
|
+
} : void 0]), 1032, [
|
|
173
|
+
"class",
|
|
174
|
+
"style",
|
|
175
|
+
"clearable",
|
|
176
|
+
"disabled",
|
|
177
|
+
"placeholder",
|
|
178
|
+
"readonly",
|
|
179
|
+
"model-value"
|
|
180
|
+
])]),
|
|
181
|
+
content: b(() => [s("div", ie, [G.value.length > 0 ? (p(), o(r, { key: 0 }, [j.group ? (p(!0), o(r, { key: 0 }, h(K.value, (e) => (p(), o(r, { key: e.label }, [s("div", x, _(e.label), 1), (p(!0), o(r, null, h(e.children, (e) => (p(), o("div", {
|
|
182
|
+
key: V(e),
|
|
183
|
+
class: d(Z(e)),
|
|
184
|
+
onClick: (t) => Q(e)
|
|
185
|
+
}, [s("span", C, _(B(e)), 1), Y(e) ? (p(), o("span", w, [...i[2] ||= [s("i", { class: "i-ri-check-line" }, null, -1)]])) : a("", !0)], 10, S))), 128))], 64))), 128)) : (p(!0), o(r, { key: 1 }, h(G.value, (e) => (p(), o("div", {
|
|
186
|
+
key: V(e),
|
|
187
|
+
class: d(Z(e)),
|
|
188
|
+
onClick: (t) => Q(e)
|
|
189
|
+
}, [s("span", E, _(B(e)), 1), Y(e) ? (p(), o("span", D, [...i[3] ||= [s("i", { class: "i-ri-check-line" }, null, -1)]])) : a("", !0)], 10, T))), 128))], 64)) : (p(), o(r, { key: 1 }, [e.$slots.empty ? g(e.$slots, "empty", { key: 0 }) : (p(), o("div", O, "暂无数据"))], 64))])]),
|
|
190
|
+
_: 3
|
|
191
|
+
}, 8, [
|
|
192
|
+
"visible",
|
|
193
|
+
"disabled",
|
|
194
|
+
"class",
|
|
195
|
+
"style"
|
|
196
|
+
]));
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { k as default };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select 选项数据结构
|
|
3
|
+
*/
|
|
4
|
+
export interface SelectOption {
|
|
5
|
+
/** 显示文本 */
|
|
6
|
+
label: string;
|
|
7
|
+
/** 选项值 */
|
|
8
|
+
value: string | number;
|
|
9
|
+
/** 是否禁用 */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** 子选项列表(用于分组) */
|
|
12
|
+
children?: SelectOption[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Select 组件属性接口
|
|
17
|
+
*/
|
|
18
|
+
export interface SelectProps {
|
|
19
|
+
/** 选项列表 */
|
|
20
|
+
list?: SelectOption[];
|
|
21
|
+
/** 显示文本的字段名 */
|
|
22
|
+
labelKey?: string;
|
|
23
|
+
/** 值的字段名 */
|
|
24
|
+
valueKey?: string;
|
|
25
|
+
/** 占位符文本 */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** 是否禁用 */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** 是否可清空 */
|
|
30
|
+
clearable?: boolean;
|
|
31
|
+
/** 是否多选 */
|
|
32
|
+
multiple?: boolean;
|
|
33
|
+
/** 是否可筛选 */
|
|
34
|
+
filterable?: boolean;
|
|
35
|
+
/** 是否分组 */
|
|
36
|
+
group?: boolean;
|
|
37
|
+
/** popover 下拉菜单的类名 */
|
|
38
|
+
popoverClass?: string;
|
|
39
|
+
/** popover 下拉菜单的样式 */
|
|
40
|
+
popoverStyle?: string | Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Select 组件事件接口
|
|
45
|
+
*/
|
|
46
|
+
export interface SelectEmits {
|
|
47
|
+
/** 更新绑定值事件 */
|
|
48
|
+
'update:modelValue': [value: string | number | (string | number)[] | undefined];
|
|
49
|
+
/** 值改变事件 */
|
|
50
|
+
change: [value: string | number | (string | number)[] | undefined];
|
|
51
|
+
/** 清空事件 */
|
|
52
|
+
clear: [];
|
|
53
|
+
/** 下拉菜单显示状态改变事件 */
|
|
54
|
+
visibleChange: [visible: boolean];
|
|
55
|
+
/** 移除标签事件(多选模式) */
|
|
56
|
+
removeTag: [value: string | number];
|
|
57
|
+
/** 筛选事件 */
|
|
58
|
+
filter: [value: string];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Select 组件插槽接口
|
|
63
|
+
*/
|
|
64
|
+
export interface SelectSlots {
|
|
65
|
+
/** 默认插槽 */
|
|
66
|
+
default?: () => unknown;
|
|
67
|
+
/** 空状态插槽 */
|
|
68
|
+
empty?: () => unknown;
|
|
69
|
+
/** 前缀插槽 */
|
|
70
|
+
prefix?: () => unknown;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Select 暴露的方法接口
|
|
75
|
+
*/
|
|
76
|
+
export interface SelectExpose {
|
|
77
|
+
/** 聚焦方法 */
|
|
78
|
+
focus: () => void;
|
|
79
|
+
/** 失焦方法 */
|
|
80
|
+
blur: () => void;
|
|
81
|
+
/** 清空方法 */
|
|
82
|
+
clear: () => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils/with-install.cjs"),t=require("./st-select/st-select.vue.cjs");var n=e.withInstall(t.default);exports.StSelect=n,exports.default=n;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export declare const StSidebar: {
|
|
2
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
3
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
4
|
+
P: {};
|
|
5
|
+
B: {};
|
|
6
|
+
D: {};
|
|
7
|
+
C: {};
|
|
8
|
+
M: {};
|
|
9
|
+
Defaults: {};
|
|
10
|
+
}, Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, {}>;
|
|
11
|
+
__isFragment?: never;
|
|
12
|
+
__isTeleport?: never;
|
|
13
|
+
__isSuspense?: never;
|
|
14
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
15
|
+
$slots: import("./types.d.ts").StSidebarSlots;
|
|
16
|
+
})>>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
19
|
+
P: {};
|
|
20
|
+
B: {};
|
|
21
|
+
D: {};
|
|
22
|
+
C: {};
|
|
23
|
+
M: {};
|
|
24
|
+
Defaults: {};
|
|
25
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
26
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
27
|
+
P: {};
|
|
28
|
+
B: {};
|
|
29
|
+
D: {};
|
|
30
|
+
C: {};
|
|
31
|
+
M: {};
|
|
32
|
+
Defaults: {};
|
|
33
|
+
}, Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, {}>;
|
|
34
|
+
__isFragment?: never;
|
|
35
|
+
__isTeleport?: never;
|
|
36
|
+
__isSuspense?: never;
|
|
37
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
38
|
+
$slots: import("./types.d.ts").StSidebarSlots;
|
|
39
|
+
})>>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, {
|
|
40
|
+
[x: string]: any;
|
|
41
|
+
}>;
|
|
42
|
+
__isFragment?: never;
|
|
43
|
+
__isTeleport?: never;
|
|
44
|
+
__isSuspense?: never;
|
|
45
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
46
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
47
|
+
P: {};
|
|
48
|
+
B: {};
|
|
49
|
+
D: {};
|
|
50
|
+
C: {};
|
|
51
|
+
M: {};
|
|
52
|
+
Defaults: {};
|
|
53
|
+
}, Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, {}>;
|
|
54
|
+
__isFragment?: never;
|
|
55
|
+
__isTeleport?: never;
|
|
56
|
+
__isSuspense?: never;
|
|
57
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("./types.d.ts").StSidebarProps> & Readonly<{}>, import("./types.d.ts").StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
58
|
+
$slots: import("./types.d.ts").StSidebarSlots;
|
|
59
|
+
})>>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
60
|
+
[x: string]: any;
|
|
61
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & (import("vue").ComponentCustomProps & import("vue").Plugin)));
|
|
62
|
+
export default StSidebar;
|
|
63
|
+
export type * from './types.d.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require("./st-sidebar.vue_vue_type_script_setup_true_lang.cjs").default;exports.default=e;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StSidebarExpose, StSidebarProps, StSidebarSlots } from './types.d.ts';
|
|
2
|
+
type __VLS_Slots = StSidebarSlots;
|
|
3
|
+
declare const __VLS_base: import("vue").DefineComponent<StSidebarProps, StSidebarExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<StSidebarProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
8
|
+
new (): {
|
|
9
|
+
$slots: S;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../../utils/cn.cjs");let t=require("vue");var n=[`onClick`],r=[`innerHTML`],i={key:1},a=(0,t.defineComponent)({inheritAttrs:!1,__name:`st-sidebar`,setup(a,{expose:o}){let s=(0,t.useAttrs)(),c=(0,t.useTemplateRef)(`navRef`),l=(0,t.useTemplateRef)(`contentRef`),u=new Map,d=new Map,f=(0,t.ref)([]),p=(0,t.ref)(null),m=null,h=(0,t.computed)(()=>e.cn(`st-sidebar`,`flex h-full overflow-hidden`,s.class)),g=e.cn(`st-sidebar__nav`,`w-50 min-w-0 flex-shrink-0`,`overflow-y-auto px-1 py-1.5`,`border-r border-border`,`bg-sidebar`),_=e.cn(`st-sidebar__content`,`flex-1 min-w-0`,`overflow-y-auto`,`scrollbar-thin scrollbar-thumb-scrollbar scrollbar-track-transparent`),v=t=>e.cn(`st-sidebar__nav-item`,`relative flex items-center gap-2`,`px-3 py-1.25`,`rounded-radius`,`cursor-pointer select-none whitespace-nowrap`,`transition-colors duration-100`,`text-3.25 leading-5 text-foreground`,`hover:bg-accent`,{"st-sidebar__nav-item--active bg-accent text-foreground font-semibold before:content-empty before:absolute before:left-0 before:top-1 before:bottom-1 before:w-0.75 before:bg-primary before:rounded-radius":p.value===t});function y(e,t){t instanceof HTMLElement?d.set(e,t):d.delete(e)}function b(){f.value=[...u.values()]}function x(){if(l.value){m=new IntersectionObserver(e=>{let t=[];for(let n of e)if(n.isIntersecting){for(let[e,r]of u)if(r.el===n.target){t.push({id:e,ratio:n.intersectionRatio});break}}t.length>0&&(t.sort((e,t)=>t.ratio-e.ratio),p.value=t[0].id)},{root:l.value,rootMargin:`0px 0px -60% 0px`,threshold:[0,.25,.5]});for(let[,e]of u)m.observe(e.el)}}function S(e){u.set(e.id,e),m&&m.observe(e.el),b(),!p.value&&f.value.length===1&&(p.value=e.id)}function C(e){let t=u.get(e);t&&m&&m.unobserve(t.el),u.delete(e),d.delete(e),b(),p.value===e&&(p.value=f.value[0]?.id??null)}function w(e,t){let n=u.get(e);n&&(n.label=t,b())}function T(e){let t=u.get(e);t&&(t.el.scrollIntoView({behavior:`smooth`,block:`start`}),p.value=e)}function E(){if(!p.value||!c.value)return;let e=d.get(p.value);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})}return(0,t.watch)(p,()=>{(0,t.nextTick)(()=>{E()})}),(0,t.provide)(`sidebarContext`,{registerItem:S,unregisterItem:C,updateItemLabel:w,activeId:p,scrollToItem:T}),(0,t.onMounted)(()=>{x()}),(0,t.onBeforeUnmount)(()=>{m&&=(m.disconnect(),null)}),o({scrollToItem:T,activeId:p}),(e,a)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)(h.value),style:(0,t.normalizeStyle)((0,t.unref)(s).style)},[(0,t.createElementVNode)(`aside`,{ref_key:`navRef`,ref:c,class:(0,t.normalizeClass)((0,t.unref)(g))},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(f.value,e=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:e.id,ref_for:!0,ref:t=>y(e.id,t),class:(0,t.normalizeClass)(v(e.id)),onClick:t=>T(e.id)},[e.labelHtml?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,innerHTML:e.labelHtml},null,8,r)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,i,(0,t.toDisplayString)(e.label),1))],10,n))),128))],2),(0,t.createElementVNode)(`main`,{ref_key:`contentRef`,ref:l,class:(0,t.normalizeClass)((0,t.unref)(_))},[(0,t.renderSlot)(e.$slots,`default`)],2)],6))}});exports.default=a;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
import { Fragment as t, computed as n, createElementBlock as r, createElementVNode as i, defineComponent as a, nextTick as o, normalizeClass as s, normalizeStyle as c, onBeforeUnmount as l, onMounted as u, openBlock as d, provide as f, ref as p, renderList as m, renderSlot as h, toDisplayString as g, unref as _, useAttrs as v, useTemplateRef as y, watch as b } from "vue";
|
|
3
|
+
//#region src/components/st-sidebar/st-sidebar.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var x = ["onClick"], S = ["innerHTML"], C = { key: 1 }, w = /*@__PURE__*/ a({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "st-sidebar",
|
|
7
|
+
setup(a, { expose: w }) {
|
|
8
|
+
let T = v(), E = y("navRef"), D = y("contentRef"), O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), A = p([]), j = p(null), M = null, N = n(() => e("st-sidebar", "flex h-full overflow-hidden", T.class)), P = e("st-sidebar__nav", "w-50 min-w-0 flex-shrink-0", "overflow-y-auto px-1 py-1.5", "border-r border-border", "bg-sidebar"), F = e("st-sidebar__content", "flex-1 min-w-0", "overflow-y-auto", "scrollbar-thin scrollbar-thumb-scrollbar scrollbar-track-transparent"), I = (t) => e("st-sidebar__nav-item", "relative flex items-center gap-2", "px-3 py-1.25", "rounded-radius", "cursor-pointer select-none whitespace-nowrap", "transition-colors duration-100", "text-3.25 leading-5 text-foreground", "hover:bg-accent", { "st-sidebar__nav-item--active bg-accent text-foreground font-semibold before:content-empty before:absolute before:left-0 before:top-1 before:bottom-1 before:w-0.75 before:bg-primary before:rounded-radius": j.value === t });
|
|
9
|
+
function L(e, t) {
|
|
10
|
+
t instanceof HTMLElement ? k.set(e, t) : k.delete(e);
|
|
11
|
+
}
|
|
12
|
+
function R() {
|
|
13
|
+
A.value = [...O.values()];
|
|
14
|
+
}
|
|
15
|
+
function z() {
|
|
16
|
+
if (D.value) {
|
|
17
|
+
M = new IntersectionObserver((e) => {
|
|
18
|
+
let t = [];
|
|
19
|
+
for (let n of e) if (n.isIntersecting) {
|
|
20
|
+
for (let [e, r] of O) if (r.el === n.target) {
|
|
21
|
+
t.push({
|
|
22
|
+
id: e,
|
|
23
|
+
ratio: n.intersectionRatio
|
|
24
|
+
});
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
t.length > 0 && (t.sort((e, t) => t.ratio - e.ratio), j.value = t[0].id);
|
|
29
|
+
}, {
|
|
30
|
+
root: D.value,
|
|
31
|
+
rootMargin: "0px 0px -60% 0px",
|
|
32
|
+
threshold: [
|
|
33
|
+
0,
|
|
34
|
+
.25,
|
|
35
|
+
.5
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
for (let [, e] of O) M.observe(e.el);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function B(e) {
|
|
42
|
+
O.set(e.id, e), M && M.observe(e.el), R(), !j.value && A.value.length === 1 && (j.value = e.id);
|
|
43
|
+
}
|
|
44
|
+
function V(e) {
|
|
45
|
+
let t = O.get(e);
|
|
46
|
+
t && M && M.unobserve(t.el), O.delete(e), k.delete(e), R(), j.value === e && (j.value = A.value[0]?.id ?? null);
|
|
47
|
+
}
|
|
48
|
+
function H(e, t) {
|
|
49
|
+
let n = O.get(e);
|
|
50
|
+
n && (n.label = t, R());
|
|
51
|
+
}
|
|
52
|
+
function U(e) {
|
|
53
|
+
let t = O.get(e);
|
|
54
|
+
t && (t.el.scrollIntoView({
|
|
55
|
+
behavior: "smooth",
|
|
56
|
+
block: "start"
|
|
57
|
+
}), j.value = e);
|
|
58
|
+
}
|
|
59
|
+
function W() {
|
|
60
|
+
if (!j.value || !E.value) return;
|
|
61
|
+
let e = k.get(j.value);
|
|
62
|
+
e && e.scrollIntoView({
|
|
63
|
+
behavior: "smooth",
|
|
64
|
+
block: "nearest"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return b(j, () => {
|
|
68
|
+
o(() => {
|
|
69
|
+
W();
|
|
70
|
+
});
|
|
71
|
+
}), f("sidebarContext", {
|
|
72
|
+
registerItem: B,
|
|
73
|
+
unregisterItem: V,
|
|
74
|
+
updateItemLabel: H,
|
|
75
|
+
activeId: j,
|
|
76
|
+
scrollToItem: U
|
|
77
|
+
}), u(() => {
|
|
78
|
+
z();
|
|
79
|
+
}), l(() => {
|
|
80
|
+
M &&= (M.disconnect(), null);
|
|
81
|
+
}), w({
|
|
82
|
+
scrollToItem: U,
|
|
83
|
+
activeId: j
|
|
84
|
+
}), (e, n) => (d(), r("div", {
|
|
85
|
+
class: s(N.value),
|
|
86
|
+
style: c(_(T).style)
|
|
87
|
+
}, [i("aside", {
|
|
88
|
+
ref_key: "navRef",
|
|
89
|
+
ref: E,
|
|
90
|
+
class: s(_(P))
|
|
91
|
+
}, [(d(!0), r(t, null, m(A.value, (e) => (d(), r("div", {
|
|
92
|
+
key: e.id,
|
|
93
|
+
ref_for: !0,
|
|
94
|
+
ref: (t) => L(e.id, t),
|
|
95
|
+
class: s(I(e.id)),
|
|
96
|
+
onClick: (t) => U(e.id)
|
|
97
|
+
}, [e.labelHtml ? (d(), r("span", {
|
|
98
|
+
key: 0,
|
|
99
|
+
innerHTML: e.labelHtml
|
|
100
|
+
}, null, 8, S)) : (d(), r("span", C, g(e.label), 1))], 10, x))), 128))], 2), i("main", {
|
|
101
|
+
ref_key: "contentRef",
|
|
102
|
+
ref: D,
|
|
103
|
+
class: s(_(F))
|
|
104
|
+
}, [h(e.$slots, "default")], 2)], 6));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
//#endregion
|
|
108
|
+
export { w as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 侧边栏项信息
|
|
5
|
+
*/
|
|
6
|
+
export interface StSidebarItemInfo {
|
|
7
|
+
/** 项唯一标识 */
|
|
8
|
+
id: string;
|
|
9
|
+
/** 项标签文本 */
|
|
10
|
+
label: string;
|
|
11
|
+
/** 项标签HTML内容 */
|
|
12
|
+
labelHtml: string;
|
|
13
|
+
/** 项DOM元素 */
|
|
14
|
+
el: HTMLElement;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 侧边栏上下文
|
|
19
|
+
*/
|
|
20
|
+
export interface StSidebarContext {
|
|
21
|
+
/** 注册侧边栏项 */
|
|
22
|
+
registerItem: (info: StSidebarItemInfo) => void;
|
|
23
|
+
/** 注销侧边栏项 */
|
|
24
|
+
unregisterItem: (id: string) => void;
|
|
25
|
+
/** 更新侧边栏项标签 */
|
|
26
|
+
updateItemLabel: (id: string, label: string) => void;
|
|
27
|
+
/** 当前激活项ID */
|
|
28
|
+
activeId: Ref<string | null>;
|
|
29
|
+
/** 滚动到指定项 */
|
|
30
|
+
scrollToItem: (id: string) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 侧边栏组件属性
|
|
35
|
+
*/
|
|
36
|
+
export interface StSidebarProps {}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 侧边栏组件插槽类型
|
|
40
|
+
*/
|
|
41
|
+
export interface StSidebarSlots {
|
|
42
|
+
/** 默认插槽 */
|
|
43
|
+
default?: () => unknown;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 侧边栏组件暴露方法
|
|
48
|
+
*/
|
|
49
|
+
export interface StSidebarExpose {
|
|
50
|
+
/** 滚动到指定项 */
|
|
51
|
+
scrollToItem: (id: string) => void;
|
|
52
|
+
/** 当前激活项ID */
|
|
53
|
+
activeId: Ref<string | null>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export declare const StSidebarItem: {
|
|
2
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
3
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
4
|
+
P: {};
|
|
5
|
+
B: {};
|
|
6
|
+
D: {};
|
|
7
|
+
C: {};
|
|
8
|
+
M: {};
|
|
9
|
+
Defaults: {};
|
|
10
|
+
}, Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
11
|
+
__isFragment?: never;
|
|
12
|
+
__isTeleport?: never;
|
|
13
|
+
__isSuspense?: never;
|
|
14
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
15
|
+
$slots: import("./types.d.ts").StSidebarItemSlots;
|
|
16
|
+
})>>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
19
|
+
P: {};
|
|
20
|
+
B: {};
|
|
21
|
+
D: {};
|
|
22
|
+
C: {};
|
|
23
|
+
M: {};
|
|
24
|
+
Defaults: {};
|
|
25
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
26
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
27
|
+
P: {};
|
|
28
|
+
B: {};
|
|
29
|
+
D: {};
|
|
30
|
+
C: {};
|
|
31
|
+
M: {};
|
|
32
|
+
Defaults: {};
|
|
33
|
+
}, Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
34
|
+
__isFragment?: never;
|
|
35
|
+
__isTeleport?: never;
|
|
36
|
+
__isSuspense?: never;
|
|
37
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
38
|
+
$slots: import("./types.d.ts").StSidebarItemSlots;
|
|
39
|
+
})>>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, {
|
|
40
|
+
[x: string]: any;
|
|
41
|
+
}>;
|
|
42
|
+
__isFragment?: never;
|
|
43
|
+
__isTeleport?: never;
|
|
44
|
+
__isSuspense?: never;
|
|
45
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
46
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
47
|
+
P: {};
|
|
48
|
+
B: {};
|
|
49
|
+
D: {};
|
|
50
|
+
C: {};
|
|
51
|
+
M: {};
|
|
52
|
+
Defaults: {};
|
|
53
|
+
}, Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
54
|
+
__isFragment?: never;
|
|
55
|
+
__isTeleport?: never;
|
|
56
|
+
__isSuspense?: never;
|
|
57
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("./types.d.ts").StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
58
|
+
$slots: import("./types.d.ts").StSidebarItemSlots;
|
|
59
|
+
})>>, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
60
|
+
[x: string]: any;
|
|
61
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & (import("vue").ComponentCustomProps & import("vue").Plugin)));
|
|
62
|
+
export default StSidebarItem;
|
|
63
|
+
export type * from './types.d.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require("./st-sidebar-item.vue_vue_type_script_setup_true_lang.cjs").default;exports.default=e;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StSidebarItemProps, StSidebarItemSlots } from './types.d.ts';
|
|
2
|
+
type __VLS_Slots = StSidebarItemSlots;
|
|
3
|
+
declare const __VLS_base: import("vue").DefineComponent<StSidebarItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<StSidebarItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
8
|
+
new (): {
|
|
9
|
+
$slots: S;
|
|
10
|
+
};
|
|
11
|
+
};
|
package/dist/components/st-sidebar-item/st-sidebar-item.vue_vue_type_script_setup_true_lang.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../../utils/cn.cjs");let t=require("vue");var n=(0,t.defineComponent)({inheritAttrs:!1,__name:`st-sidebar-item`,props:{label:{}},setup(n){let r=n,i=(0,t.useAttrs)(),a=`sidebar-item-${Math.random().toString(36).slice(2,9)}`,o=(0,t.useTemplateRef)(`labelExtractRef`),s=(0,t.useTemplateRef)(`contentRef`),c=(0,t.inject)(`sidebarContext`,null),l=e.cn(`st-sidebar-item`,`scroll-mt-0`),u=e.cn(`st-sidebar-item__content`);return(0,t.onMounted)(async()=>{if(await(0,t.nextTick)(),!c||!s.value)return;let e=r.label??``,n=o.value?.innerHTML??``;c.registerItem({id:a,label:e,labelHtml:n,el:s.value})}),(0,t.onUnmounted)(()=>{c?.unregisterItem(a)}),(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{id:a,class:(0,t.normalizeClass)((0,t.unref)(e.cn)((0,t.unref)(l),(0,t.unref)(i).class)),style:(0,t.normalizeStyle)((0,t.unref)(i).style)},[(0,t.createElementVNode)(`div`,{ref_key:`labelExtractRef`,ref:o,"aria-hidden":`true`,class:`hidden`},[(0,t.renderSlot)(n.$slots,`label`)],512),(0,t.createElementVNode)(`div`,{ref_key:`contentRef`,ref:s,class:(0,t.normalizeClass)((0,t.unref)(u))},[(0,t.renderSlot)(n.$slots,`default`)],2)],6))}});exports.default=n;
|