@sdata/web-vue 4.1.0 → 4.2.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/dist/sd.css +118 -0
- package/dist/sd.min.css +1 -1
- package/es/bloom-menu/bloom-menu.js +5 -0
- package/es/bloom-menu/bloom-menu.vue.d.ts +52 -0
- package/es/bloom-menu/bloom-menu.vue_vue_type_script_setup_true_lang.js +380 -0
- package/es/bloom-menu/index.d.ts +6 -0
- package/es/bloom-menu/index.js +10 -0
- package/es/bloom-menu/style/css.js +2 -0
- package/es/bloom-menu/style/index.css +135 -0
- package/es/bloom-menu/style/index.d.ts +2 -0
- package/es/bloom-menu/style/index.js +2 -0
- package/es/bloom-menu/style/index.scss +153 -0
- package/es/bloom-menu/style/token.scss +24 -0
- package/es/bloom-menu/types.d.ts +11 -0
- package/es/components.d.ts +1 -0
- package/es/index.css +118 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -1
- package/es/index.scss +1 -0
- package/es/locale/interface.d.ts +2 -0
- package/es/locale/lang/en-us.js +2 -0
- package/es/locale/lang/zh-cn.js +2 -0
- package/es/sd-vue.js +2 -0
- package/json/vetur-tags.json +3 -0
- package/json/web-types.json +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import bloom_menu_vue_vue_type_script_setup_true_lang_default from "./bloom-menu.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region components/bloom-menu/bloom-menu.vue
|
|
3
|
+
var bloom_menu_default = bloom_menu_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { bloom_menu_default as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Merge, UnknownRecord } from 'type-fest';
|
|
2
|
+
import type { HTMLAttributes, VNode } from 'vue';
|
|
3
|
+
import type { ButtonInstance } from '../button';
|
|
4
|
+
import type { BloomMenuItem, BloomMenuOffset } from './types';
|
|
5
|
+
type BloomMenuButtonProps = Merge<HTMLAttributes, ButtonInstance['$props']> & UnknownRecord;
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
items: readonly BloomMenuItem[];
|
|
8
|
+
modelValue?: boolean;
|
|
9
|
+
defaultOpen?: boolean;
|
|
10
|
+
columns?: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
triggerText?: string;
|
|
13
|
+
buttonProps?: BloomMenuButtonProps;
|
|
14
|
+
offset?: BloomMenuOffset;
|
|
15
|
+
closeAriaLabel?: string;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_Slots = {
|
|
18
|
+
trigger(props: {
|
|
19
|
+
open: () => void;
|
|
20
|
+
}): VNode[];
|
|
21
|
+
header(props: {
|
|
22
|
+
close: (restoreFocus?: boolean) => void;
|
|
23
|
+
}): VNode[];
|
|
24
|
+
icon(props: {
|
|
25
|
+
item: BloomMenuItem;
|
|
26
|
+
index: number;
|
|
27
|
+
}): VNode[];
|
|
28
|
+
item(props: {
|
|
29
|
+
item: BloomMenuItem;
|
|
30
|
+
index: number;
|
|
31
|
+
}): VNode[];
|
|
32
|
+
empty(): VNode[];
|
|
33
|
+
};
|
|
34
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
35
|
+
open: () => any;
|
|
36
|
+
close: () => any;
|
|
37
|
+
select: (item: BloomMenuItem, index: number) => any;
|
|
38
|
+
"update:modelValue": (value: boolean) => any;
|
|
39
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
40
|
+
onOpen?: (() => any) | undefined;
|
|
41
|
+
onClose?: (() => any) | undefined;
|
|
42
|
+
onSelect?: ((item: BloomMenuItem, index: number) => any) | undefined;
|
|
43
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
44
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
45
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
46
|
+
declare const _default: typeof __VLS_export;
|
|
47
|
+
export default _default;
|
|
48
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
49
|
+
new (): {
|
|
50
|
+
$slots: S;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { getPrefixCls } from "../_utils/global-config.js";
|
|
3
|
+
import IconClose from "../icon/icon-close/index.js";
|
|
4
|
+
import { useI18n } from "../locale/index.js";
|
|
5
|
+
import Trigger from "../trigger/index.js";
|
|
6
|
+
import Button from "../button/index.js";
|
|
7
|
+
import IconPlus from "../icon/icon-plus/index.js";
|
|
8
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
9
|
+
import { shift } from "@floating-ui/vue";
|
|
10
|
+
import { Motion, useReducedMotion } from "motion-v";
|
|
11
|
+
//#region components/bloom-menu/bloom-menu.vue?vue&type=script&setup=true&lang.ts
|
|
12
|
+
var _hoisted_1 = { ref: "panelRoot" };
|
|
13
|
+
var bloom_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "BloomMenu" }), {}, {
|
|
14
|
+
__name: "bloom-menu",
|
|
15
|
+
props: {
|
|
16
|
+
items: {},
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: () => void 0
|
|
20
|
+
},
|
|
21
|
+
defaultOpen: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
columns: { default: 3 },
|
|
26
|
+
title: { default: "Create" },
|
|
27
|
+
triggerText: { default: "Create" },
|
|
28
|
+
buttonProps: {},
|
|
29
|
+
offset: {},
|
|
30
|
+
closeAriaLabel: {}
|
|
31
|
+
},
|
|
32
|
+
emits: [
|
|
33
|
+
"update:modelValue",
|
|
34
|
+
"open",
|
|
35
|
+
"close",
|
|
36
|
+
"select"
|
|
37
|
+
],
|
|
38
|
+
setup(__props, { emit: __emit }) {
|
|
39
|
+
var _props$modelValue;
|
|
40
|
+
const emit = __emit;
|
|
41
|
+
const prefixCls = getPrefixCls("bloom-menu");
|
|
42
|
+
const { t } = useI18n();
|
|
43
|
+
const triggerButtonRef = useTemplateRef("triggerButton");
|
|
44
|
+
const panelRootRef = useTemplateRef("panelRoot");
|
|
45
|
+
const internalOpen = shallowRef(__props.defaultOpen);
|
|
46
|
+
const popupVisible = shallowRef((_props$modelValue = __props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : __props.defaultOpen);
|
|
47
|
+
const reducedMotion = useReducedMotion();
|
|
48
|
+
const triggerStyle = shallowRef({
|
|
49
|
+
width: 144,
|
|
50
|
+
height: 44,
|
|
51
|
+
backgroundColor: "transparent",
|
|
52
|
+
borderColor: "transparent",
|
|
53
|
+
borderRadius: "16px",
|
|
54
|
+
boxShadow: "none",
|
|
55
|
+
color: "currentColor"
|
|
56
|
+
});
|
|
57
|
+
const normalizedColumns = computed(() => Math.max(1, Math.floor(__props.columns)));
|
|
58
|
+
const rowCount = computed(() => Math.max(1, Math.ceil(__props.items.length / normalizedColumns.value)));
|
|
59
|
+
const isOpen = computed(() => {
|
|
60
|
+
var _props$modelValue2;
|
|
61
|
+
return (_props$modelValue2 = __props.modelValue) !== null && _props$modelValue2 !== void 0 ? _props$modelValue2 : internalOpen.value;
|
|
62
|
+
});
|
|
63
|
+
const rootClasses = computed(() => [prefixCls, { [`${prefixCls}-open`]: isOpen.value }]);
|
|
64
|
+
const centerMiddleware = computed(() => ({
|
|
65
|
+
name: "bloomMenuCenter",
|
|
66
|
+
fn: ({ rects }) => {
|
|
67
|
+
var _props$offset$left, _props$offset, _props$offset$top, _props$offset2;
|
|
68
|
+
return {
|
|
69
|
+
x: rects.reference.x + (rects.reference.width - rects.floating.width) / 2 + ((_props$offset$left = (_props$offset = __props.offset) === null || _props$offset === void 0 ? void 0 : _props$offset.left) !== null && _props$offset$left !== void 0 ? _props$offset$left : 0),
|
|
70
|
+
y: rects.reference.y + (rects.reference.height - rects.floating.height) / 2 + ((_props$offset$top = (_props$offset2 = __props.offset) === null || _props$offset2 === void 0 ? void 0 : _props$offset2.top) !== null && _props$offset$top !== void 0 ? _props$offset$top : 0)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
const floatingOptions = computed(() => ({
|
|
75
|
+
placement: "top",
|
|
76
|
+
middleware: [centerMiddleware.value, shift({ crossAxis: true })]
|
|
77
|
+
}));
|
|
78
|
+
const popupContentStyle = computed(() => ({ pointerEvents: isOpen.value ? void 0 : "none" }));
|
|
79
|
+
const panelStyle = computed(() => ({
|
|
80
|
+
"--bloom-menu-columns": normalizedColumns.value,
|
|
81
|
+
"--bloom-menu-source-width": `${triggerStyle.value.width}px`,
|
|
82
|
+
"--bloom-menu-source-height": `${triggerStyle.value.height}px`,
|
|
83
|
+
"--bloom-menu-source-background": triggerStyle.value.backgroundColor,
|
|
84
|
+
"--bloom-menu-source-border-color": triggerStyle.value.borderColor,
|
|
85
|
+
"--bloom-menu-source-border-radius": triggerStyle.value.borderRadius,
|
|
86
|
+
"--bloom-menu-source-box-shadow": triggerStyle.value.boxShadow,
|
|
87
|
+
"--bloom-menu-source-color": triggerStyle.value.color
|
|
88
|
+
}));
|
|
89
|
+
const panelCollapsed = computed(() => reducedMotion.value ? {} : {
|
|
90
|
+
width: "var(--bloom-menu-source-width)",
|
|
91
|
+
height: "var(--bloom-menu-source-height)",
|
|
92
|
+
color: "var(--bloom-menu-source-color)",
|
|
93
|
+
backgroundColor: "var(--bloom-menu-source-background)",
|
|
94
|
+
borderColor: "var(--bloom-menu-source-border-color)",
|
|
95
|
+
borderRadius: "var(--bloom-menu-source-border-radius)",
|
|
96
|
+
boxShadow: "var(--bloom-menu-source-box-shadow)"
|
|
97
|
+
});
|
|
98
|
+
const panelInitial = computed(() => _objectSpread2(_objectSpread2({}, panelCollapsed.value), {}, { opacity: reducedMotion.value ? 0 : .98 }));
|
|
99
|
+
const panelAnimate = computed(() => ({
|
|
100
|
+
width: "var(--bloom-menu-panel-width)",
|
|
101
|
+
height: "auto",
|
|
102
|
+
color: "var(--bloom-menu-panel-color)",
|
|
103
|
+
backgroundColor: "var(--bloom-menu-panel-background)",
|
|
104
|
+
borderColor: "var(--bloom-menu-panel-border-color)",
|
|
105
|
+
borderRadius: "var(--bloom-menu-panel-border-radius)",
|
|
106
|
+
boxShadow: "var(--bloom-menu-panel-shadow)",
|
|
107
|
+
opacity: 1
|
|
108
|
+
}));
|
|
109
|
+
const panelTarget = computed(() => isOpen.value ? panelAnimate.value : panelCollapsed.value);
|
|
110
|
+
const morphTransition = computed(() => reducedMotion.value ? { duration: .15 } : {
|
|
111
|
+
type: "spring",
|
|
112
|
+
stiffness: 300,
|
|
113
|
+
damping: 32,
|
|
114
|
+
mass: .9
|
|
115
|
+
});
|
|
116
|
+
const contentTransition = computed(() => ({
|
|
117
|
+
delay: isOpen.value && !reducedMotion.value ? .12 : 0,
|
|
118
|
+
duration: reducedMotion.value ? .15 : isOpen.value ? .2 : .12
|
|
119
|
+
}));
|
|
120
|
+
const gridInitial = computed(() => reducedMotion.value ? false : { clipPath: "inset(45% 34% 45% 34%)" });
|
|
121
|
+
const gridTransition = computed(() => ({
|
|
122
|
+
delay: reducedMotion.value ? 0 : .08,
|
|
123
|
+
duration: reducedMotion.value ? .15 : .45,
|
|
124
|
+
ease: [
|
|
125
|
+
.16,
|
|
126
|
+
1,
|
|
127
|
+
.3,
|
|
128
|
+
1
|
|
129
|
+
]
|
|
130
|
+
}));
|
|
131
|
+
function getTriggerElement(event) {
|
|
132
|
+
var _triggerButtonRef$val;
|
|
133
|
+
if ((event === null || event === void 0 ? void 0 : event.currentTarget) instanceof HTMLElement) return event.currentTarget;
|
|
134
|
+
return (_triggerButtonRef$val = triggerButtonRef.value) === null || _triggerButtonRef$val === void 0 ? void 0 : _triggerButtonRef$val.$el;
|
|
135
|
+
}
|
|
136
|
+
function captureTriggerStyle(event) {
|
|
137
|
+
const element = getTriggerElement(event);
|
|
138
|
+
if (!element || typeof window === "undefined") return;
|
|
139
|
+
const rect = element.getBoundingClientRect();
|
|
140
|
+
const style = window.getComputedStyle(element);
|
|
141
|
+
triggerStyle.value = {
|
|
142
|
+
width: rect.width,
|
|
143
|
+
height: rect.height,
|
|
144
|
+
backgroundColor: style.backgroundColor,
|
|
145
|
+
borderColor: style.borderColor,
|
|
146
|
+
borderRadius: style.borderRadius,
|
|
147
|
+
boxShadow: style.boxShadow,
|
|
148
|
+
color: style.color
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function setOpen(nextOpen) {
|
|
152
|
+
if (nextOpen === isOpen.value) return;
|
|
153
|
+
if (__props.modelValue === void 0) internalOpen.value = nextOpen;
|
|
154
|
+
emit("update:modelValue", nextOpen);
|
|
155
|
+
if (nextOpen) emit("open");
|
|
156
|
+
else emit("close");
|
|
157
|
+
}
|
|
158
|
+
function handlePopupVisibleChange(visible) {
|
|
159
|
+
if (visible) {
|
|
160
|
+
captureTriggerStyle();
|
|
161
|
+
setOpen(true);
|
|
162
|
+
} else {
|
|
163
|
+
var _panelRootRef$value;
|
|
164
|
+
if (document.activeElement instanceof HTMLElement && ((_panelRootRef$value = panelRootRef.value) === null || _panelRootRef$value === void 0 ? void 0 : _panelRootRef$value.contains(document.activeElement))) focusTrigger();
|
|
165
|
+
setOpen(false);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let closeTimer = 0;
|
|
169
|
+
function schedulePopupHide() {
|
|
170
|
+
window.clearTimeout(closeTimer);
|
|
171
|
+
closeTimer = window.setTimeout(() => {
|
|
172
|
+
if (!isOpen.value) popupVisible.value = false;
|
|
173
|
+
}, reducedMotion.value ? 150 : 450);
|
|
174
|
+
}
|
|
175
|
+
function open() {
|
|
176
|
+
captureTriggerStyle();
|
|
177
|
+
setOpen(true);
|
|
178
|
+
}
|
|
179
|
+
function focusTrigger() {
|
|
180
|
+
var _triggerButtonRef$val2;
|
|
181
|
+
(_triggerButtonRef$val2 = triggerButtonRef.value) === null || _triggerButtonRef$val2 === void 0 || (_triggerButtonRef$val2 = _triggerButtonRef$val2.$el) === null || _triggerButtonRef$val2 === void 0 || _triggerButtonRef$val2.focus();
|
|
182
|
+
}
|
|
183
|
+
function close(restoreFocus = false) {
|
|
184
|
+
setOpen(false);
|
|
185
|
+
if (restoreFocus) nextTick(focusTrigger);
|
|
186
|
+
}
|
|
187
|
+
function focusPanel(attempt = 0) {
|
|
188
|
+
nextTick(() => {
|
|
189
|
+
var _panelRootRef$value2, _panelRootRef$value3;
|
|
190
|
+
const firstItem = (_panelRootRef$value2 = panelRootRef.value) === null || _panelRootRef$value2 === void 0 ? void 0 : _panelRootRef$value2.querySelector(`.${prefixCls}-item:not(:disabled)`);
|
|
191
|
+
const closeButton = (_panelRootRef$value3 = panelRootRef.value) === null || _panelRootRef$value3 === void 0 ? void 0 : _panelRootRef$value3.querySelector(`.${prefixCls}-close`);
|
|
192
|
+
const target = firstItem !== null && firstItem !== void 0 ? firstItem : closeButton;
|
|
193
|
+
if (!target || getComputedStyle(target).visibility === "hidden") {
|
|
194
|
+
if (attempt < 30) requestAnimationFrame(() => focusPanel(attempt + 1));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
target.focus();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function selectItem(item, index) {
|
|
201
|
+
if (item.disabled) return;
|
|
202
|
+
emit("select", item, index);
|
|
203
|
+
close(true);
|
|
204
|
+
}
|
|
205
|
+
function getItemClasses(item, index) {
|
|
206
|
+
const column = index % normalizedColumns.value;
|
|
207
|
+
const row = Math.floor(index / normalizedColumns.value);
|
|
208
|
+
return [`${prefixCls}-item`, {
|
|
209
|
+
[`${prefixCls}-item-border-right`]: column < normalizedColumns.value - 1,
|
|
210
|
+
[`${prefixCls}-item-border-bottom`]: row < rowCount.value - 1,
|
|
211
|
+
[`${prefixCls}-item-disabled`]: item.disabled
|
|
212
|
+
}];
|
|
213
|
+
}
|
|
214
|
+
function getItemInitial() {
|
|
215
|
+
return reducedMotion.value ? { opacity: 0 } : {
|
|
216
|
+
opacity: 0,
|
|
217
|
+
scale: .85,
|
|
218
|
+
filter: "blur(6px)"
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function getItemTransition(index) {
|
|
222
|
+
const column = index % normalizedColumns.value;
|
|
223
|
+
const row = Math.floor(index / normalizedColumns.value);
|
|
224
|
+
const distance = Math.hypot(column - (normalizedColumns.value - 1) / 2, row - (rowCount.value - 1) / 2);
|
|
225
|
+
return {
|
|
226
|
+
delay: reducedMotion.value ? 0 : .1 + distance * .07,
|
|
227
|
+
type: "spring",
|
|
228
|
+
stiffness: 440,
|
|
229
|
+
damping: 34
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
onMounted(captureTriggerStyle);
|
|
233
|
+
watch(isOpen, (openState) => {
|
|
234
|
+
if (!openState) {
|
|
235
|
+
schedulePopupHide();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
window.clearTimeout(closeTimer);
|
|
239
|
+
popupVisible.value = true;
|
|
240
|
+
captureTriggerStyle();
|
|
241
|
+
focusPanel();
|
|
242
|
+
}, { immediate: true });
|
|
243
|
+
onBeforeUnmount(() => window.clearTimeout(closeTimer));
|
|
244
|
+
return (_ctx, _cache) => {
|
|
245
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass(rootClasses.value) }, [createVNode(unref(Trigger), {
|
|
246
|
+
"popup-visible": popupVisible.value,
|
|
247
|
+
trigger: "click",
|
|
248
|
+
"floating-options": floatingOptions.value,
|
|
249
|
+
"content-class": `${unref(prefixCls)}-popup`,
|
|
250
|
+
"content-style": popupContentStyle.value,
|
|
251
|
+
duration: 0,
|
|
252
|
+
"animation-name": "",
|
|
253
|
+
"render-to-body": "",
|
|
254
|
+
"esc-to-close": "",
|
|
255
|
+
"aria-has-popup": "dialog",
|
|
256
|
+
onPopupVisibleChange: handlePopupVisibleChange
|
|
257
|
+
}, {
|
|
258
|
+
content: withCtx(() => [createVNode(unref(Motion), {
|
|
259
|
+
"data-bloom-menu-panel": "",
|
|
260
|
+
initial: panelInitial.value,
|
|
261
|
+
animate: panelTarget.value,
|
|
262
|
+
transition: morphTransition.value,
|
|
263
|
+
style: normalizeStyle(panelStyle.value),
|
|
264
|
+
class: normalizeClass(`${unref(prefixCls)}-panel`),
|
|
265
|
+
role: "dialog",
|
|
266
|
+
"aria-label": __props.title
|
|
267
|
+
}, {
|
|
268
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1, [createVNode(unref(Motion), {
|
|
269
|
+
initial: { opacity: 0 },
|
|
270
|
+
animate: { opacity: isOpen.value ? 1 : 0 },
|
|
271
|
+
transition: contentTransition.value,
|
|
272
|
+
class: normalizeClass(`${unref(prefixCls)}-content`)
|
|
273
|
+
}, {
|
|
274
|
+
default: withCtx(() => [createElementVNode("div", { class: normalizeClass(`${unref(prefixCls)}-header`) }, [renderSlot(_ctx.$slots, "header", { close }, () => {
|
|
275
|
+
var _props$closeAriaLabel;
|
|
276
|
+
return [createElementVNode("span", { class: normalizeClass(`${unref(prefixCls)}-title`) }, toDisplayString(__props.title), 3), createVNode(unref(Button), {
|
|
277
|
+
type: "text",
|
|
278
|
+
shape: "circle",
|
|
279
|
+
size: "mini",
|
|
280
|
+
class: normalizeClass(`${unref(prefixCls)}-close`),
|
|
281
|
+
"aria-label": (_props$closeAriaLabel = __props.closeAriaLabel) !== null && _props$closeAriaLabel !== void 0 ? _props$closeAriaLabel : unref(t)("a11y.bloomMenuClose"),
|
|
282
|
+
onClick: _cache[0] || (_cache[0] = ($event) => close(true))
|
|
283
|
+
}, {
|
|
284
|
+
icon: withCtx(() => [createVNode(unref(IconClose))]),
|
|
285
|
+
_: 1
|
|
286
|
+
}, 8, ["class", "aria-label"])];
|
|
287
|
+
})], 2), __props.items.length ? (openBlock(), createBlock(unref(Motion), {
|
|
288
|
+
key: 0,
|
|
289
|
+
initial: gridInitial.value,
|
|
290
|
+
animate: { clipPath: "inset(0% 0% 0% 0%)" },
|
|
291
|
+
transition: gridTransition.value,
|
|
292
|
+
class: normalizeClass(`${unref(prefixCls)}-grid`)
|
|
293
|
+
}, {
|
|
294
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index) => {
|
|
295
|
+
return openBlock(), createBlock(unref(Button), {
|
|
296
|
+
key: item.value,
|
|
297
|
+
type: "text",
|
|
298
|
+
long: "",
|
|
299
|
+
class: normalizeClass(getItemClasses(item, index)),
|
|
300
|
+
disabled: item.disabled,
|
|
301
|
+
onClick: ($event) => selectItem(item, index)
|
|
302
|
+
}, {
|
|
303
|
+
default: withCtx(() => [createVNode(unref(Motion), {
|
|
304
|
+
initial: getItemInitial(),
|
|
305
|
+
animate: {
|
|
306
|
+
opacity: 1,
|
|
307
|
+
scale: 1,
|
|
308
|
+
filter: "blur(0px)"
|
|
309
|
+
},
|
|
310
|
+
transition: getItemTransition(index),
|
|
311
|
+
class: normalizeClass(`${unref(prefixCls)}-item-content`)
|
|
312
|
+
}, {
|
|
313
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "item", {
|
|
314
|
+
item,
|
|
315
|
+
index
|
|
316
|
+
}, () => [item.icon || _ctx.$slots.icon ? (openBlock(), createElementBlock("span", {
|
|
317
|
+
key: 0,
|
|
318
|
+
class: normalizeClass(`${unref(prefixCls)}-item-icon`)
|
|
319
|
+
}, [renderSlot(_ctx.$slots, "icon", {
|
|
320
|
+
item,
|
|
321
|
+
index
|
|
322
|
+
}, () => [item.icon ? (openBlock(), createBlock(resolveDynamicComponent(item.icon), { key: 0 })) : createCommentVNode("", true)])], 2)) : createCommentVNode("", true), createElementVNode("span", { class: normalizeClass(`${unref(prefixCls)}-item-label`) }, toDisplayString(item.label), 3)])]),
|
|
323
|
+
_: 2
|
|
324
|
+
}, 1032, [
|
|
325
|
+
"initial",
|
|
326
|
+
"transition",
|
|
327
|
+
"class"
|
|
328
|
+
])]),
|
|
329
|
+
_: 2
|
|
330
|
+
}, 1032, [
|
|
331
|
+
"class",
|
|
332
|
+
"disabled",
|
|
333
|
+
"onClick"
|
|
334
|
+
]);
|
|
335
|
+
}), 128))]),
|
|
336
|
+
_: 3
|
|
337
|
+
}, 8, [
|
|
338
|
+
"initial",
|
|
339
|
+
"transition",
|
|
340
|
+
"class"
|
|
341
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
342
|
+
key: 1,
|
|
343
|
+
class: normalizeClass(`${unref(prefixCls)}-empty`)
|
|
344
|
+
}, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(unref(t)("a11y.bloomMenuEmpty")), 1)])], 2))]),
|
|
345
|
+
_: 3
|
|
346
|
+
}, 8, [
|
|
347
|
+
"animate",
|
|
348
|
+
"transition",
|
|
349
|
+
"class"
|
|
350
|
+
])], 512)]),
|
|
351
|
+
_: 3
|
|
352
|
+
}, 8, [
|
|
353
|
+
"initial",
|
|
354
|
+
"animate",
|
|
355
|
+
"transition",
|
|
356
|
+
"style",
|
|
357
|
+
"class",
|
|
358
|
+
"aria-label"
|
|
359
|
+
])]),
|
|
360
|
+
default: withCtx(() => [createVNode(unref(Button), mergeProps(__props.buttonProps, {
|
|
361
|
+
ref: "triggerButton",
|
|
362
|
+
"data-bloom-menu-trigger": "",
|
|
363
|
+
class: `${unref(prefixCls)}-trigger`,
|
|
364
|
+
onPointerdown: captureTriggerStyle
|
|
365
|
+
}), {
|
|
366
|
+
default: withCtx(() => [createElementVNode("span", { class: normalizeClass(`${unref(prefixCls)}-trigger-content`) }, [renderSlot(_ctx.$slots, "trigger", { open }, () => [createTextVNode(toDisplayString(__props.triggerText) + " ", 1), createVNode(unref(IconPlus))])], 2)]),
|
|
367
|
+
_: 3
|
|
368
|
+
}, 16, ["class"])]),
|
|
369
|
+
_: 3
|
|
370
|
+
}, 8, [
|
|
371
|
+
"popup-visible",
|
|
372
|
+
"floating-options",
|
|
373
|
+
"content-class",
|
|
374
|
+
"content-style"
|
|
375
|
+
])], 2);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}));
|
|
379
|
+
//#endregion
|
|
380
|
+
export { bloom_menu_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SFCWithInstall } from '../_utils/types';
|
|
2
|
+
import _BloomMenu from './bloom-menu.vue';
|
|
3
|
+
export type { BloomMenuItem, BloomMenuOffset } from './types';
|
|
4
|
+
declare const BloomMenu: SFCWithInstall<typeof _BloomMenu>;
|
|
5
|
+
export type BloomMenuInstance = InstanceType<typeof _BloomMenu>;
|
|
6
|
+
export default BloomMenu;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getComponentPrefix, setGlobalConfig } from "../_utils/global-config.js";
|
|
2
|
+
import bloom_menu_default from "./bloom-menu.js";
|
|
3
|
+
//#region components/bloom-menu/index.ts
|
|
4
|
+
var BloomMenu = Object.assign(bloom_menu_default, { install: (app, options) => {
|
|
5
|
+
setGlobalConfig(app, options);
|
|
6
|
+
const componentPrefix = getComponentPrefix(options);
|
|
7
|
+
app.component(componentPrefix + bloom_menu_default.name, bloom_menu_default);
|
|
8
|
+
} });
|
|
9
|
+
//#endregion
|
|
10
|
+
export { BloomMenu as default };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/******** borderSize *******/
|
|
2
|
+
/******** borderStyle *******/
|
|
3
|
+
/******** radius *******/
|
|
4
|
+
/******** shadow distance *******/
|
|
5
|
+
/******** size *******/
|
|
6
|
+
/******** spacing *******/
|
|
7
|
+
/******** shadow *******/
|
|
8
|
+
/******** opacity *******/
|
|
9
|
+
/******** fontSize *******/
|
|
10
|
+
/******** fontWeight ********/
|
|
11
|
+
/******** Primary *******/
|
|
12
|
+
/******** success *******/
|
|
13
|
+
/******** warning *******/
|
|
14
|
+
/******** danger *******/
|
|
15
|
+
/******** link *******/
|
|
16
|
+
/******** radius *******/
|
|
17
|
+
/********* icon hover *********/
|
|
18
|
+
.sd-bloom-menu {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
font-family: inter, "-apple-system", blinkmacsystemfont, "PingFang SC", "Hiragino Sans GB", "noto sans", "Microsoft YaHei", "Helvetica Neue", helvetica, arial, sans-serif;
|
|
21
|
+
}
|
|
22
|
+
.sd-bloom-menu-trigger-content {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
gap: 8px;
|
|
25
|
+
align-items: center;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
}
|
|
28
|
+
.sd-bloom-menu-trigger-content svg {
|
|
29
|
+
width: 16px;
|
|
30
|
+
height: 16px;
|
|
31
|
+
}
|
|
32
|
+
.sd-bloom-menu-panel {
|
|
33
|
+
--bloom-menu-panel-width: min(86vw, 420px);
|
|
34
|
+
--bloom-menu-panel-color: var(--sd-color-text-1);
|
|
35
|
+
--bloom-menu-panel-background: var(--sd-color-bg-2);
|
|
36
|
+
--bloom-menu-panel-border-color: var(--sd-color-neutral-3);
|
|
37
|
+
--bloom-menu-panel-border-radius: var(--sd-border-radius-medium);
|
|
38
|
+
--bloom-menu-panel-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
border: 1px solid var(--sd-color-neutral-3);
|
|
41
|
+
}
|
|
42
|
+
.sd-bloom-menu-popup {
|
|
43
|
+
padding: 0;
|
|
44
|
+
}
|
|
45
|
+
.sd-bloom-menu-content {
|
|
46
|
+
width: 100%;
|
|
47
|
+
}
|
|
48
|
+
.sd-bloom-menu-header {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: space-between;
|
|
52
|
+
padding: 12px 16px;
|
|
53
|
+
color: var(--sd-color-text-2);
|
|
54
|
+
border-bottom: 1px solid var(--sd-color-neutral-3);
|
|
55
|
+
}
|
|
56
|
+
.sd-bloom-menu-title {
|
|
57
|
+
font-weight: 500;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
}
|
|
60
|
+
.sd-bloom-menu-close {
|
|
61
|
+
color: inherit;
|
|
62
|
+
}
|
|
63
|
+
.sd-bloom-menu-close:hover {
|
|
64
|
+
color: var(--sd-color-text-1);
|
|
65
|
+
}
|
|
66
|
+
.sd-bloom-menu-close svg {
|
|
67
|
+
width: 16px;
|
|
68
|
+
height: 16px;
|
|
69
|
+
}
|
|
70
|
+
.sd-bloom-menu-grid {
|
|
71
|
+
display: grid;
|
|
72
|
+
grid-template-columns: repeat(var(--bloom-menu-columns), minmax(0, 1fr));
|
|
73
|
+
}
|
|
74
|
+
.sd-bloom-menu-item {
|
|
75
|
+
min-width: 0;
|
|
76
|
+
height: auto;
|
|
77
|
+
padding: 24px 12px;
|
|
78
|
+
color: var(--sd-color-text-2);
|
|
79
|
+
border-radius: 0;
|
|
80
|
+
}
|
|
81
|
+
.sd-bloom-menu-item:hover:not(:disabled) {
|
|
82
|
+
color: var(--sd-color-text-1);
|
|
83
|
+
background: var(--sd-color-fill-2);
|
|
84
|
+
}
|
|
85
|
+
.sd-bloom-menu-item:focus-visible {
|
|
86
|
+
position: relative;
|
|
87
|
+
z-index: 1;
|
|
88
|
+
outline: 2px solid rgb(var(--sd-primary-6));
|
|
89
|
+
outline-offset: -2px;
|
|
90
|
+
}
|
|
91
|
+
.sd-bloom-menu-item-border-right {
|
|
92
|
+
border-right: 1px solid var(--sd-color-neutral-3);
|
|
93
|
+
}
|
|
94
|
+
.sd-bloom-menu-item-border-bottom {
|
|
95
|
+
border-bottom: 1px solid var(--sd-color-neutral-3);
|
|
96
|
+
}
|
|
97
|
+
.sd-bloom-menu-item-disabled, .sd-bloom-menu-item:disabled {
|
|
98
|
+
color: var(--sd-color-text-4);
|
|
99
|
+
cursor: not-allowed;
|
|
100
|
+
}
|
|
101
|
+
.sd-bloom-menu-item-content {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
align-items: center;
|
|
106
|
+
min-width: 0;
|
|
107
|
+
}
|
|
108
|
+
.sd-bloom-menu-item-icon {
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
font-size: 20px;
|
|
111
|
+
}
|
|
112
|
+
.sd-bloom-menu-item-icon svg {
|
|
113
|
+
width: 20px;
|
|
114
|
+
height: 20px;
|
|
115
|
+
}
|
|
116
|
+
.sd-bloom-menu-item-label {
|
|
117
|
+
max-width: 100%;
|
|
118
|
+
overflow: hidden;
|
|
119
|
+
font-weight: 500;
|
|
120
|
+
font-size: 14px;
|
|
121
|
+
white-space: nowrap;
|
|
122
|
+
text-overflow: ellipsis;
|
|
123
|
+
}
|
|
124
|
+
.sd-bloom-menu-empty {
|
|
125
|
+
padding: 24px 16px;
|
|
126
|
+
color: var(--sd-color-text-2);
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
text-align: center;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media (prefers-reduced-motion: reduce) {
|
|
132
|
+
.sd-bloom-menu-item, .sd-bloom-menu-close {
|
|
133
|
+
transition: none;
|
|
134
|
+
}
|
|
135
|
+
}
|