@varlet/ui 3.17.0 → 3.18.0-alpha.1781190469654
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/es/action-sheet/style/index.mjs +1 -1
- package/es/app-bar/AppBar.mjs +2 -0
- package/es/app-bar/appBar.css +1 -1
- package/es/app-bar/props.mjs +8 -0
- package/es/badge/badge.css +1 -1
- package/es/bottom-navigation-item/BottomNavigationItem.mjs +1 -1
- package/es/bottom-navigation-item/bottomNavigationItem.css +1 -1
- package/es/button/Button.mjs +13 -6
- package/es/button/button.css +1 -1
- package/es/button/props.mjs +2 -0
- package/es/collapse-transition/useCollapseTransition.mjs +27 -8
- package/es/data-table/DataTable.mjs +656 -0
- package/es/data-table/DataTableBodyCell.mjs +210 -0
- package/es/data-table/DataTableHeaderCell.mjs +237 -0
- package/es/data-table/DataTableSfc.css +0 -0
- package/es/data-table/dataTable.css +1 -0
- package/es/data-table/index.mjs +12 -0
- package/es/data-table/props.mjs +94 -0
- package/es/data-table/span.mjs +29 -0
- package/es/data-table/style/index.mjs +17 -0
- package/es/data-table/useBodyRows.mjs +141 -0
- package/es/data-table/useColumnSizes.mjs +175 -0
- package/es/data-table/useColumnsFixedOffsets.mjs +90 -0
- package/es/data-table/useContainerScroll.mjs +35 -0
- package/es/data-table/useExpandRow.mjs +46 -0
- package/es/data-table/useFootRows.mjs +49 -0
- package/es/data-table/useHeaderRows.mjs +113 -0
- package/es/data-table/usePagination.mjs +101 -0
- package/es/data-table/useSelectionColumn.mjs +242 -0
- package/es/data-table/useSorter.mjs +70 -0
- package/es/data-table/useTreeExpand.mjs +69 -0
- package/es/icon/icon.css +1 -1
- package/es/index.bundle.mjs +25 -1
- package/es/index.mjs +21 -1
- package/es/locale/en-US.mjs +3 -1
- package/es/locale/fa-IR.mjs +3 -1
- package/es/locale/ja-JP.mjs +3 -1
- package/es/locale/zh-CN.mjs +3 -1
- package/es/locale/zh-TW.mjs +3 -1
- package/es/menu/Menu.mjs +1 -0
- package/es/menu/menu.css +1 -1
- package/es/menu-select/MenuSelect.mjs +1 -1
- package/es/menu-select/menuSelect.css +1 -1
- package/es/otp-input/OtpInput.mjs +39 -12
- package/es/pagination/pagination.css +1 -1
- package/es/rail-navigation/RailNavigation.mjs +87 -0
- package/es/rail-navigation/RailNavigationSfc.css +0 -0
- package/es/rail-navigation/index.mjs +12 -0
- package/es/rail-navigation/props.mjs +21 -0
- package/es/rail-navigation/provide.mjs +12 -0
- package/es/rail-navigation/railNavigation.css +1 -0
- package/es/rail-navigation/style/index.mjs +3 -0
- package/es/rail-navigation-item/RailNavigationItem.mjs +177 -0
- package/es/rail-navigation-item/RailNavigationItemSfc.css +0 -0
- package/es/rail-navigation-item/index.mjs +12 -0
- package/es/rail-navigation-item/props.mjs +19 -0
- package/es/rail-navigation-item/provide.mjs +17 -0
- package/es/rail-navigation-item/railNavigationItem.css +1 -0
- package/es/rail-navigation-item/style/index.mjs +6 -0
- package/es/select/Select.mjs +1 -1
- package/es/select/select.css +1 -1
- package/es/style.mjs +4 -0
- package/es/styles/common.css +1 -1
- package/es/table/Table.mjs +22 -9
- package/es/table/props.mjs +3 -1
- package/es/table/table.css +1 -1
- package/es/themes/dark/appBar.mjs +3 -0
- package/es/themes/dark/bottomNavigationItem.mjs +1 -0
- package/es/themes/dark/button.mjs +3 -0
- package/es/themes/dark/dataTable.mjs +31 -0
- package/es/themes/dark/index.mjs +6 -2
- package/es/themes/dark/railNavigation.mjs +12 -0
- package/es/themes/dark/railNavigationItem.mjs +18 -0
- package/es/themes/dark/table.mjs +4 -1
- package/es/themes/dark/treeMenu.mjs +32 -0
- package/es/themes/md3-dark/appBar.mjs +3 -0
- package/es/themes/md3-dark/bottomNavigationItem.mjs +1 -0
- package/es/themes/md3-dark/button.mjs +3 -0
- package/es/themes/md3-dark/dataTable.mjs +31 -0
- package/es/themes/md3-dark/index.mjs +6 -2
- package/es/themes/md3-dark/railNavigation.mjs +12 -0
- package/es/themes/md3-dark/railNavigationItem.mjs +18 -0
- package/es/themes/md3-dark/table.mjs +4 -1
- package/es/themes/md3-dark/treeMenu.mjs +32 -0
- package/es/themes/md3-light/appBar.mjs +3 -0
- package/es/themes/md3-light/bottomNavigationItem.mjs +1 -0
- package/es/themes/md3-light/button.mjs +3 -0
- package/es/themes/md3-light/dataTable.mjs +31 -0
- package/es/themes/md3-light/index.mjs +6 -2
- package/es/themes/md3-light/pagination.mjs +1 -1
- package/es/themes/md3-light/railNavigation.mjs +12 -0
- package/es/themes/md3-light/railNavigationItem.mjs +18 -0
- package/es/themes/md3-light/table.mjs +4 -1
- package/es/themes/md3-light/treeMenu.mjs +32 -0
- package/es/tree-menu/TreeMenu.mjs +223 -0
- package/es/tree-menu/TreeMenuOption.mjs +206 -0
- package/es/tree-menu/TreeMenuSfc.css +0 -0
- package/es/tree-menu/index.mjs +12 -0
- package/es/tree-menu/props.mjs +40 -0
- package/es/tree-menu/style/index.mjs +6 -0
- package/es/tree-menu/treeMenu.css +1 -0
- package/es/varlet.css +1 -1
- package/es/varlet.esm.js +10532 -9190
- package/highlight/web-types.en-US.json +414 -1
- package/highlight/web-types.zh-CN.json +148 -1
- package/lib/varlet.cjs.js +10842 -9190
- package/lib/varlet.css +1 -1
- package/package.json +7 -7
- package/types/appBar.d.ts +6 -0
- package/types/button.d.ts +2 -0
- package/types/buttonGroup.d.ts +1 -1
- package/types/dataTable.d.ts +173 -0
- package/types/index.d.ts +8 -0
- package/types/railNavigation.d.ts +27 -0
- package/types/railNavigationItem.d.ts +38 -0
- package/types/styleVars.d.ts +84 -0
- package/types/table.d.ts +2 -0
- package/types/treeMenu.d.ts +80 -0
- package/umd/varlet.js +7 -7
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { call, isArray } from "@varlet/shared";
|
|
2
|
+
import { useVModel } from "@varlet/use";
|
|
3
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
4
|
+
import { createNamespace } from "../utils/components.mjs";
|
|
5
|
+
import { toSizeUnit } from "../utils/elements.mjs";
|
|
6
|
+
import { props } from "./props.mjs";
|
|
7
|
+
import TreeMenuOptionComponent from "./TreeMenuOption.mjs";
|
|
8
|
+
const { name, n, classes } = createNamespace("tree-menu");
|
|
9
|
+
import { renderSlot as _renderSlot, createCommentVNode as _createCommentVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createBlock as _createBlock, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle } from "vue";
|
|
10
|
+
function __render__(_ctx, _cache) {
|
|
11
|
+
const _component_tree_menu_option = _resolveComponent("tree-menu-option");
|
|
12
|
+
return _openBlock(), _createElementBlock(
|
|
13
|
+
"nav",
|
|
14
|
+
{
|
|
15
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"))),
|
|
16
|
+
style: _normalizeStyle(_ctx.styles)
|
|
17
|
+
},
|
|
18
|
+
[
|
|
19
|
+
_ctx.$slots.start ? _renderSlot(_ctx.$slots, "start", { key: 0 }) : _createCommentVNode("v-if", true),
|
|
20
|
+
(_openBlock(true), _createElementBlock(
|
|
21
|
+
_Fragment,
|
|
22
|
+
null,
|
|
23
|
+
_renderList(_ctx.treeMeta.options, (option) => {
|
|
24
|
+
return _openBlock(), _createBlock(_component_tree_menu_option, {
|
|
25
|
+
key: option.value,
|
|
26
|
+
option,
|
|
27
|
+
ripple: _ctx.ripple,
|
|
28
|
+
onSelect: _ctx.handleSelect,
|
|
29
|
+
onToggle: _ctx.handleToggle
|
|
30
|
+
}, null, 8, ["option", "ripple", "onSelect", "onToggle"]);
|
|
31
|
+
}),
|
|
32
|
+
128
|
|
33
|
+
/* KEYED_FRAGMENT */
|
|
34
|
+
)),
|
|
35
|
+
_ctx.$slots.end ? _renderSlot(_ctx.$slots, "end", { key: 1 }) : _createCommentVNode("v-if", true)
|
|
36
|
+
],
|
|
37
|
+
6
|
|
38
|
+
/* CLASS, STYLE */
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const __sfc__ = defineComponent({
|
|
42
|
+
name,
|
|
43
|
+
components: {
|
|
44
|
+
TreeMenuOption: TreeMenuOptionComponent
|
|
45
|
+
},
|
|
46
|
+
props,
|
|
47
|
+
setup(props2) {
|
|
48
|
+
const active = useVModel(props2, "active");
|
|
49
|
+
const expandedValues = useVModel(props2, "expandedValues", {
|
|
50
|
+
defaultValue: []
|
|
51
|
+
});
|
|
52
|
+
const treeMeta = ref({
|
|
53
|
+
options: [],
|
|
54
|
+
optionByValue: /* @__PURE__ */ new Map()
|
|
55
|
+
});
|
|
56
|
+
const styles = computed(() => {
|
|
57
|
+
if (props2.indent == null) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
"--tree-menu-item-indent": toSizeUnit(props2.indent)
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
watch(
|
|
65
|
+
() => [props2.options, props2.valueKey, props2.labelKey, props2.iconKey, props2.childrenKey],
|
|
66
|
+
() => {
|
|
67
|
+
treeMeta.value = createTreeMeta();
|
|
68
|
+
updateTreeState();
|
|
69
|
+
},
|
|
70
|
+
{ immediate: true }
|
|
71
|
+
);
|
|
72
|
+
watch(
|
|
73
|
+
() => active.value,
|
|
74
|
+
(value) => {
|
|
75
|
+
if (value == null) {
|
|
76
|
+
expandedValues.value = [];
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
expandAncestors(value);
|
|
80
|
+
},
|
|
81
|
+
{ immediate: true }
|
|
82
|
+
);
|
|
83
|
+
watch(
|
|
84
|
+
[active, expandedValues, () => props2.disabled],
|
|
85
|
+
() => {
|
|
86
|
+
updateTreeState();
|
|
87
|
+
},
|
|
88
|
+
{ immediate: true }
|
|
89
|
+
);
|
|
90
|
+
function createTreeMeta() {
|
|
91
|
+
const map = /* @__PURE__ */ new Map();
|
|
92
|
+
const options = normalize(props2.options);
|
|
93
|
+
options.forEach(visit);
|
|
94
|
+
function normalize(options2, parent, level = 0) {
|
|
95
|
+
return options2.reduce((normalizedOptions, option) => {
|
|
96
|
+
if (option.show === false) {
|
|
97
|
+
return normalizedOptions;
|
|
98
|
+
}
|
|
99
|
+
const type = option.type;
|
|
100
|
+
const value = option[props2.valueKey];
|
|
101
|
+
const rawChildren = option[props2.childrenKey];
|
|
102
|
+
const normalizedOption = {
|
|
103
|
+
option,
|
|
104
|
+
type,
|
|
105
|
+
value,
|
|
106
|
+
label: option[props2.labelKey],
|
|
107
|
+
icon: option[props2.iconKey],
|
|
108
|
+
active: false,
|
|
109
|
+
activePath: false,
|
|
110
|
+
disabled: false,
|
|
111
|
+
expanded: false,
|
|
112
|
+
hasChildren: false,
|
|
113
|
+
children: [],
|
|
114
|
+
parent,
|
|
115
|
+
level
|
|
116
|
+
};
|
|
117
|
+
const childLevel = type === "group" ? level : level + 1;
|
|
118
|
+
normalizedOption.children = isArray(rawChildren) ? normalize(rawChildren, normalizedOption, childLevel) : [];
|
|
119
|
+
normalizedOption.hasChildren = !type && normalizedOption.children.length > 0;
|
|
120
|
+
normalizedOptions.push(normalizedOption);
|
|
121
|
+
return normalizedOptions;
|
|
122
|
+
}, []);
|
|
123
|
+
}
|
|
124
|
+
function visit(option) {
|
|
125
|
+
map.set(option.value, option);
|
|
126
|
+
option.children.forEach(visit);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
options,
|
|
130
|
+
optionByValue: map
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function updateTreeState() {
|
|
134
|
+
var _a;
|
|
135
|
+
const expandedValueSet = new Set((_a = expandedValues.value) != null ? _a : []);
|
|
136
|
+
const activeOption = active.value == null ? void 0 : treeMeta.value.optionByValue.get(active.value);
|
|
137
|
+
const activePathValueSet = new Set(activeOption ? getAncestorValues(activeOption) : []);
|
|
138
|
+
treeMeta.value.options.forEach((option) => {
|
|
139
|
+
updateOptionState(option, expandedValueSet, activePathValueSet);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function updateOptionState(option, expandedValueSet, activePathValueSet) {
|
|
143
|
+
option.active = active.value === option.value;
|
|
144
|
+
option.activePath = activePathValueSet.has(option.value);
|
|
145
|
+
option.disabled = props2.disabled || !!option.option.disabled;
|
|
146
|
+
option.expanded = expandedValueSet.has(option.value);
|
|
147
|
+
option.children.forEach((child) => {
|
|
148
|
+
updateOptionState(child, expandedValueSet, activePathValueSet);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function getDescendantValues(option) {
|
|
152
|
+
const values = [];
|
|
153
|
+
function visit(child) {
|
|
154
|
+
values.push(child.value);
|
|
155
|
+
child.children.forEach(visit);
|
|
156
|
+
}
|
|
157
|
+
option.children.forEach(visit);
|
|
158
|
+
return values;
|
|
159
|
+
}
|
|
160
|
+
function getAncestorValues(option) {
|
|
161
|
+
const values = [];
|
|
162
|
+
let parent = option.parent;
|
|
163
|
+
while (parent) {
|
|
164
|
+
values.push(parent.value);
|
|
165
|
+
parent = parent.parent;
|
|
166
|
+
}
|
|
167
|
+
return values;
|
|
168
|
+
}
|
|
169
|
+
function expandAncestors(value) {
|
|
170
|
+
const option = treeMeta.value.optionByValue.get(value);
|
|
171
|
+
if (!option) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const target = new Set(expandedValues.value);
|
|
175
|
+
getAncestorValues(option).forEach((value2) => {
|
|
176
|
+
target.add(value2);
|
|
177
|
+
});
|
|
178
|
+
expandedValues.value = [...target];
|
|
179
|
+
}
|
|
180
|
+
function handleSelect(option) {
|
|
181
|
+
if (active.value === option.value) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
active.value = option.value;
|
|
185
|
+
call(props2.onChange, option.value, option.option);
|
|
186
|
+
}
|
|
187
|
+
function handleToggle(option) {
|
|
188
|
+
const target = new Set(expandedValues.value);
|
|
189
|
+
const expanded = target.has(option.value);
|
|
190
|
+
if (expanded) {
|
|
191
|
+
target.delete(option.value);
|
|
192
|
+
getDescendantValues(option).forEach((value) => target.delete(value));
|
|
193
|
+
expandedValues.value = [...target];
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (props2.accordion) {
|
|
197
|
+
const siblings = option.parent ? option.parent.children : treeMeta.value.options;
|
|
198
|
+
siblings.forEach((sibling) => {
|
|
199
|
+
if (sibling.value === option.value) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
target.delete(sibling.value);
|
|
203
|
+
getDescendantValues(sibling).forEach((value) => target.delete(value));
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
target.add(option.value);
|
|
207
|
+
expandedValues.value = [...target];
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
n,
|
|
211
|
+
classes,
|
|
212
|
+
treeMeta,
|
|
213
|
+
styles,
|
|
214
|
+
handleSelect,
|
|
215
|
+
handleToggle
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
__sfc__.render = __render__;
|
|
220
|
+
var stdin_default = __sfc__;
|
|
221
|
+
export {
|
|
222
|
+
stdin_default as default
|
|
223
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { call, callOrReturn, isString } from "@varlet/shared";
|
|
2
|
+
import { defineComponent, h, withDirectives } from "vue";
|
|
3
|
+
import VarCollapseTransition from "../collapse-transition/index.mjs";
|
|
4
|
+
import VarIcon from "../icon/index.mjs";
|
|
5
|
+
import Ripple from "../ripple/index.mjs";
|
|
6
|
+
import { createNamespace, defineListenerProp, MaybeVNode } from "../utils/components.mjs";
|
|
7
|
+
const { n, classes } = createNamespace("tree-menu");
|
|
8
|
+
import { normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, createVNode as _createVNode, renderList as _renderList, Fragment as _Fragment, createBlock as _createBlock, createElementVNode as _createElementVNode, withCtx as _withCtx } from "vue";
|
|
9
|
+
function __render__(_ctx, _cache) {
|
|
10
|
+
const _component_maybe_v_node = _resolveComponent("maybe-v-node");
|
|
11
|
+
const _component_var_tree_menu_option = _resolveComponent("var-tree-menu-option");
|
|
12
|
+
const _component_var_collapse_transition = _resolveComponent("var-collapse-transition");
|
|
13
|
+
return _openBlock(), _createElementBlock(
|
|
14
|
+
"div",
|
|
15
|
+
{
|
|
16
|
+
class: _normalizeClass(_ctx.n("option"))
|
|
17
|
+
},
|
|
18
|
+
[
|
|
19
|
+
_ctx.option.type === "divider" ? (_openBlock(), _createElementBlock(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
key: 0,
|
|
23
|
+
class: _normalizeClass(_ctx.n("divider"))
|
|
24
|
+
},
|
|
25
|
+
null,
|
|
26
|
+
2
|
|
27
|
+
/* CLASS */
|
|
28
|
+
)) : _ctx.option.type === "group" ? (_openBlock(), _createElementBlock(
|
|
29
|
+
_Fragment,
|
|
30
|
+
{ key: 1 },
|
|
31
|
+
[
|
|
32
|
+
_createVNode(_component_maybe_v_node, {
|
|
33
|
+
is: _ctx.renderGroupLabel()
|
|
34
|
+
}, null, 8, ["is"]),
|
|
35
|
+
_createElementVNode("div", null, [
|
|
36
|
+
(_openBlock(true), _createElementBlock(
|
|
37
|
+
_Fragment,
|
|
38
|
+
null,
|
|
39
|
+
_renderList(_ctx.option.children, (child) => {
|
|
40
|
+
return _openBlock(), _createBlock(_component_var_tree_menu_option, {
|
|
41
|
+
key: child.value,
|
|
42
|
+
option: child,
|
|
43
|
+
ripple: _ctx.ripple,
|
|
44
|
+
onSelect: _ctx.onSelect,
|
|
45
|
+
onToggle: _ctx.onToggle
|
|
46
|
+
}, null, 8, ["option", "ripple", "onSelect", "onToggle"]);
|
|
47
|
+
}),
|
|
48
|
+
128
|
|
49
|
+
/* KEYED_FRAGMENT */
|
|
50
|
+
))
|
|
51
|
+
])
|
|
52
|
+
],
|
|
53
|
+
64
|
|
54
|
+
/* STABLE_FRAGMENT */
|
|
55
|
+
)) : (_openBlock(), _createBlock(_component_maybe_v_node, {
|
|
56
|
+
key: 2,
|
|
57
|
+
is: _ctx.renderItem()
|
|
58
|
+
}, null, 8, ["is"])),
|
|
59
|
+
_ctx.option.hasChildren ? (_openBlock(), _createBlock(_component_var_collapse_transition, {
|
|
60
|
+
key: 3,
|
|
61
|
+
expand: _ctx.option.expanded
|
|
62
|
+
}, {
|
|
63
|
+
default: _withCtx(() => [
|
|
64
|
+
_createElementVNode(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
class: _normalizeClass(_ctx.n("children"))
|
|
68
|
+
},
|
|
69
|
+
[
|
|
70
|
+
(_openBlock(true), _createElementBlock(
|
|
71
|
+
_Fragment,
|
|
72
|
+
null,
|
|
73
|
+
_renderList(_ctx.option.children, (child) => {
|
|
74
|
+
return _openBlock(), _createBlock(_component_var_tree_menu_option, {
|
|
75
|
+
key: child.value,
|
|
76
|
+
option: child,
|
|
77
|
+
ripple: _ctx.ripple,
|
|
78
|
+
onSelect: _ctx.onSelect,
|
|
79
|
+
onToggle: _ctx.onToggle
|
|
80
|
+
}, null, 8, ["option", "ripple", "onSelect", "onToggle"]);
|
|
81
|
+
}),
|
|
82
|
+
128
|
|
83
|
+
/* KEYED_FRAGMENT */
|
|
84
|
+
))
|
|
85
|
+
],
|
|
86
|
+
2
|
|
87
|
+
/* CLASS */
|
|
88
|
+
)
|
|
89
|
+
]),
|
|
90
|
+
_: 1
|
|
91
|
+
/* STABLE */
|
|
92
|
+
}, 8, ["expand"])) : _createCommentVNode("v-if", true)
|
|
93
|
+
],
|
|
94
|
+
2
|
|
95
|
+
/* CLASS */
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const __sfc__ = defineComponent({
|
|
99
|
+
name: "VarTreeMenuOption",
|
|
100
|
+
components: {
|
|
101
|
+
VarCollapseTransition,
|
|
102
|
+
VarIcon,
|
|
103
|
+
MaybeVNode
|
|
104
|
+
},
|
|
105
|
+
directives: { Ripple },
|
|
106
|
+
props: {
|
|
107
|
+
option: {
|
|
108
|
+
type: Object,
|
|
109
|
+
required: true
|
|
110
|
+
},
|
|
111
|
+
ripple: Boolean,
|
|
112
|
+
onSelect: defineListenerProp(),
|
|
113
|
+
onToggle: defineListenerProp()
|
|
114
|
+
},
|
|
115
|
+
setup(props) {
|
|
116
|
+
function handleClick() {
|
|
117
|
+
if (props.option.disabled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (props.option.hasChildren) {
|
|
121
|
+
call(props.onToggle, props.option);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
call(props.onSelect, props.option);
|
|
125
|
+
}
|
|
126
|
+
function renderItem() {
|
|
127
|
+
const node = renderDefaultItem();
|
|
128
|
+
const render = props.option.option.render;
|
|
129
|
+
if (!render) {
|
|
130
|
+
return node;
|
|
131
|
+
}
|
|
132
|
+
return render({ node }, props.option.option, props.option.active);
|
|
133
|
+
}
|
|
134
|
+
function renderGroupLabel() {
|
|
135
|
+
const label = renderLabel();
|
|
136
|
+
if (!label) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
return h("div", { class: n("group-label") }, [h(MaybeVNode, { is: label })]);
|
|
140
|
+
}
|
|
141
|
+
function renderDefaultItem() {
|
|
142
|
+
return withDirectives(
|
|
143
|
+
h(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
class: classes(
|
|
147
|
+
n("item"),
|
|
148
|
+
[props.option.active, n("--item-active")],
|
|
149
|
+
[props.option.activePath, n("--item-active-path")],
|
|
150
|
+
[props.option.disabled, n("--item-disabled")],
|
|
151
|
+
[props.ripple && !props.option.disabled, n("--item-ripple-enabled")]
|
|
152
|
+
),
|
|
153
|
+
style: {
|
|
154
|
+
"--tree-menu-level": props.option.level
|
|
155
|
+
},
|
|
156
|
+
onClick: handleClick
|
|
157
|
+
},
|
|
158
|
+
[
|
|
159
|
+
h("span", { class: n("item-indicator") }),
|
|
160
|
+
h("span", { class: n("item-content") }, [
|
|
161
|
+
renderIcon(),
|
|
162
|
+
h("span", { class: n("label") }, [h(MaybeVNode, { is: renderLabel() })]),
|
|
163
|
+
renderExpandIcon()
|
|
164
|
+
])
|
|
165
|
+
]
|
|
166
|
+
),
|
|
167
|
+
[[Ripple, { disabled: !props.ripple || props.option.disabled }]]
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function renderIcon() {
|
|
171
|
+
const iconVNode = callOrReturn(props.option.icon, props.option.option, props.option.active);
|
|
172
|
+
if (!iconVNode) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
return h("span", { class: n("icon-container") }, [
|
|
176
|
+
isString(iconVNode) ? h(VarIcon, {
|
|
177
|
+
class: n("icon"),
|
|
178
|
+
name: iconVNode,
|
|
179
|
+
namespace: props.option.option.namespace,
|
|
180
|
+
varTreeMenuCover: ""
|
|
181
|
+
}) : h(MaybeVNode, { class: n("icon"), is: iconVNode })
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
function renderLabel() {
|
|
185
|
+
return callOrReturn(props.option.label, props.option.option, props.option.active);
|
|
186
|
+
}
|
|
187
|
+
function renderExpandIcon() {
|
|
188
|
+
if (!props.option.hasChildren) {
|
|
189
|
+
return h("span", { class: n("expand-placeholder") });
|
|
190
|
+
}
|
|
191
|
+
return h("span", { class: classes(n("expand-icon"), [props.option.expanded, n("--expand-icon-expanded")]) }, [
|
|
192
|
+
h(VarIcon, { name: "chevron-down", varTreeMenuCover: "" })
|
|
193
|
+
]);
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
renderGroupLabel,
|
|
197
|
+
renderItem,
|
|
198
|
+
n
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
__sfc__.render = __render__;
|
|
203
|
+
var stdin_default = __sfc__;
|
|
204
|
+
export {
|
|
205
|
+
stdin_default as default
|
|
206
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { withInstall, withPropsDefaultsSetter } from "../utils/components.mjs";
|
|
2
|
+
import { props as treeMenuProps } from "./props.mjs";
|
|
3
|
+
import TreeMenu from "./TreeMenu.mjs";
|
|
4
|
+
withInstall(TreeMenu);
|
|
5
|
+
withPropsDefaultsSetter(TreeMenu, treeMenuProps);
|
|
6
|
+
const _TreeMenuComponent = TreeMenu;
|
|
7
|
+
var stdin_default = TreeMenu;
|
|
8
|
+
export {
|
|
9
|
+
_TreeMenuComponent,
|
|
10
|
+
stdin_default as default,
|
|
11
|
+
treeMenuProps
|
|
12
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineListenerProp } from "../utils/components.mjs";
|
|
2
|
+
const props = {
|
|
3
|
+
active: [Number, String],
|
|
4
|
+
options: {
|
|
5
|
+
type: Array,
|
|
6
|
+
default: () => []
|
|
7
|
+
},
|
|
8
|
+
expandedValues: Array,
|
|
9
|
+
valueKey: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: "value"
|
|
12
|
+
},
|
|
13
|
+
labelKey: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "label"
|
|
16
|
+
},
|
|
17
|
+
iconKey: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "icon"
|
|
20
|
+
},
|
|
21
|
+
childrenKey: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "children"
|
|
24
|
+
},
|
|
25
|
+
accordion: Boolean,
|
|
26
|
+
indent: {
|
|
27
|
+
type: [String, Number]
|
|
28
|
+
},
|
|
29
|
+
ripple: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
disabled: Boolean,
|
|
34
|
+
onChange: defineListenerProp(),
|
|
35
|
+
"onUpdate:active": defineListenerProp(),
|
|
36
|
+
"onUpdate:expandedValues": defineListenerProp()
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
props
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root { --tree-menu-background: var(--color-surface-container-high); --tree-menu-item-text-color: var(--color-text); --tree-menu-padding: 8px 0; --tree-menu-item-gap: 0px; --tree-menu-item-height: 40px; --tree-menu-item-padding: 0 16px; --tree-menu-item-border-radius: 0; --tree-menu-item-indent: 16px; --tree-menu-item-icon-size: 22px; --tree-menu-item-icon-margin-right: 24px; --tree-menu-item-label-font-size: var(--font-size-md); --tree-menu-item-label-line-height: 1.5; --tree-menu-group-label-height: 32px; --tree-menu-group-label-padding: 0 16px; --tree-menu-group-label-color: var(--color-on-surface-variant); --tree-menu-group-label-font-size: var(--font-size-sm); --tree-menu-divider-margin: 8px 0; --tree-menu-divider-color: rgba(0, 0, 0, 0.12); --tree-menu-item-hover-background: rgba(85, 85, 85, 0.06); --tree-menu-item-pressed-background: rgba(85, 85, 85, 0.1); --tree-menu-item-active-background: hsla(var(--hsl-primary), 0.1); --tree-menu-item-active-text-color: var(--color-primary); --tree-menu-item-disabled-opacity: var(--opacity-disabled); --tree-menu-item-indicator-border-radius: 0; --tree-menu-item-indicator-active-transition-duration: 0ms; --tree-menu-expand-icon-color: var(--color-on-surface-variant); --tree-menu-expand-icon-size: 20px;}.var-tree-menu { display: block; min-width: 0; padding: var(--tree-menu-padding); color: var(--tree-menu-item-text-color); background: var(--tree-menu-background); -webkit-tap-highlight-color: transparent; transition: color 0.25s, background-color 0.25s;}.var-tree-menu__option + .var-tree-menu__option,.var-tree-menu__children > .var-tree-menu__option:first-child { margin-top: var(--tree-menu-item-gap);}.var-tree-menu__group-label { box-sizing: border-box; min-width: 0; height: var(--tree-menu-group-label-height); padding: var(--tree-menu-group-label-padding); display: flex; align-items: center; color: var(--tree-menu-group-label-color); font-size: var(--tree-menu-group-label-font-size); line-height: 1.5; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}.var-tree-menu__divider { height: 1px; margin: var(--tree-menu-divider-margin); background-color: var(--tree-menu-divider-color);}.var-tree-menu__item { position: relative; box-sizing: border-box; min-width: 0; height: var(--tree-menu-item-height); padding: var(--tree-menu-item-padding); display: flex; align-items: center; color: var(--tree-menu-item-text-color); cursor: pointer; overflow: hidden; border-radius: var(--tree-menu-item-border-radius); user-select: none; transition: color 0.25s;}.var-tree-menu__item-indicator { position: absolute; z-index: 0; top: 50%; left: 50%; width: 100%; height: 100%; border-radius: var(--tree-menu-item-indicator-border-radius); transform: translate(-50%, -50%); pointer-events: none;}.var-tree-menu__item-indicator::before,.var-tree-menu__item-indicator::after { content: ''; position: absolute; z-index: 0; top: 0; left: 0; width: 100%; height: 100%; border-radius: inherit;}.var-tree-menu__item-indicator::before { background-color: var(--tree-menu-item-hover-background); opacity: 0; transition: opacity 150ms, background-color 150ms;}.var-tree-menu__item-indicator::after { background: var(--tree-menu-item-active-background); transform: scaleX(0); transform-origin: center;}.var-tree-menu__item:hover .var-tree-menu__item-indicator::before { opacity: 1;}.var-tree-menu__item:active:not(.var-tree-menu--item-ripple-enabled):not(.var-tree-menu--item-disabled) .var-tree-menu__item-indicator::before { background-color: var(--tree-menu-item-pressed-background); opacity: 1;}.var-tree-menu--item-active,.var-tree-menu--item-active-path { color: var(--tree-menu-item-active-text-color);}.var-tree-menu--item-active .var-tree-menu__expand-icon,.var-tree-menu--item-active-path .var-tree-menu__expand-icon { color: var(--tree-menu-item-active-text-color);}.var-tree-menu--item-active .var-tree-menu__item-indicator::after { transform: scaleX(1); transition: transform var(--tree-menu-item-indicator-active-transition-duration) cubic-bezier(0.2, 0, 0, 1), background-color var(--tree-menu-item-indicator-active-transition-duration) cubic-bezier(0.2, 0, 0, 1);}.var-tree-menu--item-ripple-enabled.var-tree-menu--item-active .var-tree-menu__item-indicator::after { transition: none;}.var-tree-menu--item-active:hover .var-tree-menu__item-indicator::before { opacity: 0;}.var-tree-menu--item-disabled { cursor: not-allowed; opacity: var(--tree-menu-item-disabled-opacity);}.var-tree-menu--item-disabled:hover .var-tree-menu__item-indicator::before { opacity: 0;}.var-tree-menu__item-content { position: relative; z-index: 1; min-width: 0; flex: 1; margin-left: calc(var(--tree-menu-item-indent) * var(--tree-menu-level)); display: flex; align-items: center;}.var-tree-menu__icon-container { width: var(--tree-menu-item-icon-size); min-width: var(--tree-menu-item-icon-size); height: var(--tree-menu-item-icon-size); display: inline-flex; align-items: center; justify-content: center; margin-right: var(--tree-menu-item-icon-margin-right);}.var-tree-menu__icon { font-size: var(--tree-menu-item-icon-size);}.var-tree-menu__label { min-width: 0; height: var(--tree-menu-item-height); flex: 1; display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--tree-menu-item-label-font-size); line-height: var(--tree-menu-item-label-line-height);}.var-tree-menu__expand-icon,.var-tree-menu__expand-placeholder { width: var(--tree-menu-expand-icon-size); min-width: var(--tree-menu-expand-icon-size); height: var(--tree-menu-expand-icon-size); margin-left: 8px;}.var-tree-menu__expand-icon { display: inline-flex; align-items: center; justify-content: center; color: var(--tree-menu-expand-icon-color); font-size: var(--tree-menu-expand-icon-size); transform: rotate(-90deg); transition: color 0.25s, transform 0.25s;}.var-tree-menu--expand-icon-expanded { transform: rotate(0deg);}
|