bani-ui 1.0.2-alpha.6 → 1.0.2-alpha.8
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/es/Button-Bwzevixh.js +103 -0
- package/dist/es/ButtonGroup-iYDLXmLV.js +36 -0
- package/dist/es/Icon-C5WM3GNh.js +57 -0
- package/dist/es/Loading-DEDOSX2q.js +269 -0
- package/dist/es/Message-CQJbBQH-.js +202 -0
- package/dist/es/Popconfirm-DGlIr8wm.js +116 -0
- package/dist/es/Tooltip-CQ0AQJf-.js +262 -0
- package/dist/es/hooks-D92zul9o.js +78 -0
- package/dist/es/index.js +30 -11
- package/dist/es/locale/lang/af.js +257 -0
- package/dist/es/locale/lang/ar-eg.js +228 -0
- package/dist/es/locale/lang/ar.js +239 -0
- package/dist/es/locale/lang/az.js +251 -0
- package/dist/es/locale/lang/bg.js +262 -0
- package/dist/es/locale/lang/bn.js +247 -0
- package/dist/es/locale/lang/ca.js +249 -0
- package/dist/es/locale/lang/ckb.js +225 -0
- package/dist/es/locale/lang/cs.js +254 -0
- package/dist/es/locale/lang/da.js +253 -0
- package/dist/es/locale/lang/de.js +238 -0
- package/dist/es/locale/lang/el.js +252 -0
- package/dist/es/locale/lang/en.js +197 -0
- package/dist/es/locale/lang/eo.js +250 -0
- package/dist/es/locale/lang/es.js +249 -0
- package/dist/es/locale/lang/et.js +248 -0
- package/dist/es/locale/lang/eu.js +249 -0
- package/dist/es/locale/lang/fa.js +211 -0
- package/dist/es/locale/lang/fi.js +252 -0
- package/dist/es/locale/lang/fr.js +203 -0
- package/dist/es/locale/lang/he.js +248 -0
- package/dist/es/locale/lang/hi.js +211 -0
- package/dist/es/locale/lang/hr.js +252 -0
- package/dist/es/locale/lang/hu.js +252 -0
- package/dist/es/locale/lang/hy-am.js +252 -0
- package/dist/es/locale/lang/id.js +247 -0
- package/dist/es/locale/lang/index.js +136 -0
- package/dist/es/locale/lang/it.js +253 -0
- package/dist/es/locale/lang/ja.js +245 -0
- package/dist/es/locale/lang/kk.js +252 -0
- package/dist/es/locale/lang/km.js +211 -0
- package/dist/es/locale/lang/ko.js +224 -0
- package/dist/es/locale/lang/ku.js +252 -0
- package/dist/es/locale/lang/ky.js +252 -0
- package/dist/es/locale/lang/lo.js +211 -0
- package/dist/es/locale/lang/lt.js +249 -0
- package/dist/es/locale/lang/lv.js +252 -0
- package/dist/es/locale/lang/mg.js +247 -0
- package/dist/es/locale/lang/mn.js +252 -0
- package/dist/es/locale/lang/ms.js +215 -0
- package/dist/es/locale/lang/my.js +211 -0
- package/dist/es/locale/lang/nb-no.js +249 -0
- package/dist/es/locale/lang/nl.js +228 -0
- package/dist/es/locale/lang/no.js +211 -0
- package/dist/es/locale/lang/pa.js +250 -0
- package/dist/es/locale/lang/pl.js +245 -0
- package/dist/es/locale/lang/pt-br.js +245 -0
- package/dist/es/locale/lang/pt.js +262 -0
- package/dist/es/locale/lang/ro.js +252 -0
- package/dist/es/locale/lang/ru.js +235 -0
- package/dist/es/locale/lang/sk.js +254 -0
- package/dist/es/locale/lang/sl.js +253 -0
- package/dist/es/locale/lang/sr.js +244 -0
- package/dist/es/locale/lang/sv.js +251 -0
- package/dist/es/locale/lang/sw.js +219 -0
- package/dist/es/locale/lang/ta.js +258 -0
- package/dist/es/locale/lang/te.js +211 -0
- package/dist/es/locale/lang/th.js +251 -0
- package/dist/es/locale/lang/tk.js +256 -0
- package/dist/es/locale/lang/tr.js +248 -0
- package/dist/es/locale/lang/ug-cn.js +252 -0
- package/dist/es/locale/lang/uk.js +249 -0
- package/dist/es/locale/lang/uz-uz.js +250 -0
- package/dist/es/locale/lang/vi.js +197 -0
- package/dist/es/locale/lang/zh-cn.js +197 -0
- package/dist/es/locale/lang/zh-hk.js +209 -0
- package/dist/es/locale/lang/zh-mo.js +209 -0
- package/dist/es/locale/lang/zh-tw.js +209 -0
- package/dist/es/utils-Uf9tqvV5.js +69 -0
- package/dist/es/vendor-R0ZbR4ac.js +3515 -0
- package/dist/index.css +1 -1
- package/dist/theme/Button.css +259 -1
- package/dist/theme/ButtonGroup.css +48 -1
- package/dist/theme/Icon.css +25 -1
- package/dist/theme/Loading.css +55 -0
- package/dist/theme/Message.css +97 -1
- package/dist/theme/Popconfirm.css +11 -0
- package/dist/theme/Tooltip.css +74 -0
- package/dist/theme/index.css +197 -1
- package/dist/types/components/Loading/directive.d.ts +12 -0
- package/dist/types/components/Loading/index.d.ts +11 -0
- package/dist/types/components/Loading/service.d.ts +11 -0
- package/dist/types/components/Loading/types.d.ts +19 -0
- package/dist/types/components/Popconfirm/index.d.ts +53 -0
- package/dist/types/components/Popconfirm/types.d.ts +18 -0
- package/dist/types/components/Tooltip/index.d.ts +65 -0
- package/dist/types/components/Tooltip/types.d.ts +24 -0
- package/dist/types/components/Tooltip/useEventsToTiggerNode.d.ts +9 -0
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts +3 -1
- package/dist/types/hooks/useClickOutside.d.ts +2 -0
- package/dist/types/hooks/useLocale.d.ts +5 -0
- package/dist/types/locale/index.d.ts +74 -0
- package/dist/types/locale/lang/af.d.ts +195 -0
- package/dist/types/locale/lang/ar-eg.d.ts +195 -0
- package/dist/types/locale/lang/ar.d.ts +195 -0
- package/dist/types/locale/lang/az.d.ts +198 -0
- package/dist/types/locale/lang/bg.d.ts +195 -0
- package/dist/types/locale/lang/bn.d.ts +195 -0
- package/dist/types/locale/lang/ca.d.ts +195 -0
- package/dist/types/locale/lang/ckb.d.ts +195 -0
- package/dist/types/locale/lang/cs.d.ts +197 -0
- package/dist/types/locale/lang/da.d.ts +195 -0
- package/dist/types/locale/lang/de.d.ts +197 -0
- package/dist/types/locale/lang/el.d.ts +195 -0
- package/dist/types/locale/lang/en.d.ts +195 -0
- package/dist/types/locale/lang/eo.d.ts +195 -0
- package/dist/types/locale/lang/es.d.ts +195 -0
- package/dist/types/locale/lang/et.d.ts +195 -0
- package/dist/types/locale/lang/eu.d.ts +195 -0
- package/dist/types/locale/lang/fa.d.ts +195 -0
- package/dist/types/locale/lang/fi.d.ts +195 -0
- package/dist/types/locale/lang/fr.d.ts +195 -0
- package/dist/types/locale/lang/he.d.ts +195 -0
- package/dist/types/locale/lang/hi.d.ts +195 -0
- package/dist/types/locale/lang/hr.d.ts +195 -0
- package/dist/types/locale/lang/hu.d.ts +195 -0
- package/dist/types/locale/lang/hy-am.d.ts +195 -0
- package/dist/types/locale/lang/id.d.ts +195 -0
- package/dist/types/locale/lang/it.d.ts +195 -0
- package/dist/types/locale/lang/ja.d.ts +195 -0
- package/dist/types/locale/lang/kk.d.ts +195 -0
- package/dist/types/locale/lang/km.d.ts +195 -0
- package/dist/types/locale/lang/ko.d.ts +195 -0
- package/dist/types/locale/lang/ku.d.ts +195 -0
- package/dist/types/locale/lang/ky.d.ts +195 -0
- package/dist/types/locale/lang/lo.d.ts +195 -0
- package/dist/types/locale/lang/lt.d.ts +195 -0
- package/dist/types/locale/lang/lv.d.ts +195 -0
- package/dist/types/locale/lang/mg.d.ts +195 -0
- package/dist/types/locale/lang/mn.d.ts +195 -0
- package/dist/types/locale/lang/ms.d.ts +197 -0
- package/dist/types/locale/lang/my.d.ts +195 -0
- package/dist/types/locale/lang/nb-no.d.ts +195 -0
- package/dist/types/locale/lang/nl.d.ts +195 -0
- package/dist/types/locale/lang/no.d.ts +195 -0
- package/dist/types/locale/lang/pa.d.ts +195 -0
- package/dist/types/locale/lang/pl.d.ts +195 -0
- package/dist/types/locale/lang/pt-br.d.ts +195 -0
- package/dist/types/locale/lang/pt.d.ts +195 -0
- package/dist/types/locale/lang/ro.d.ts +195 -0
- package/dist/types/locale/lang/ru.d.ts +195 -0
- package/dist/types/locale/lang/sk.d.ts +197 -0
- package/dist/types/locale/lang/sl.d.ts +195 -0
- package/dist/types/locale/lang/sr.d.ts +195 -0
- package/dist/types/locale/lang/sv.d.ts +195 -0
- package/dist/types/locale/lang/sw.d.ts +195 -0
- package/dist/types/locale/lang/ta.d.ts +195 -0
- package/dist/types/locale/lang/te.d.ts +195 -0
- package/dist/types/locale/lang/th.d.ts +195 -0
- package/dist/types/locale/lang/tk.d.ts +195 -0
- package/dist/types/locale/lang/tr.d.ts +195 -0
- package/dist/types/locale/lang/ug-cn.d.ts +195 -0
- package/dist/types/locale/lang/uk.d.ts +195 -0
- package/dist/types/locale/lang/uz-uz.d.ts +195 -0
- package/dist/types/locale/lang/vi.d.ts +195 -0
- package/dist/types/locale/lang/zh-cn.d.ts +195 -0
- package/dist/types/locale/lang/zh-hk.d.ts +195 -0
- package/dist/types/locale/lang/zh-mo.d.ts +195 -0
- package/dist/types/locale/lang/zh-tw.d.ts +195 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/style.d.ts +1 -0
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.css.br +0 -0
- package/dist/umd/index.css.gz +0 -0
- package/dist/umd/index.umd.cjs +12 -12
- package/dist/umd/index.umd.cjs.br +0 -0
- package/dist/umd/index.umd.cjs.gz +0 -0
- package/package.json +3 -3
- package/dist/es/Button-eQN4Iutg.js +0 -85
- package/dist/es/ButtonGroup-BequUrIT.js +0 -29
- package/dist/es/Icon-CL9G-J0o.js +0 -50
- package/dist/es/Message-BZ2T08zu.js +0 -166
- package/dist/es/hooks-CkxWXunh.js +0 -40
- package/dist/es/utils-CKyHXHob.js +0 -35
- package/dist/es/vendor-CZxuzErw.js +0 -1500
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { defineComponent, inject, computed, useSlots, ref, openBlock, createBlock, resolveDynamicComponent, unref, normalizeClass, withCtx, renderSlot, createVNode, normalizeStyle, createCommentVNode } from "vue";
|
|
2
|
+
import { _ as _sfc_main$1 } from "./Icon-C5WM3GNh.js";
|
|
3
|
+
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
|
|
4
|
+
import { library } from "@fortawesome/fontawesome-svg-core";
|
|
5
|
+
import { t as throttle } from "./vendor-R0ZbR4ac.js";
|
|
6
|
+
import { w as withInstall } from "./utils-Uf9tqvV5.js";
|
|
7
|
+
const BUTTON_GROUP_CTX_KEY = Symbol(
|
|
8
|
+
"BUTTON_GROUP_CTX_KEY"
|
|
9
|
+
);
|
|
10
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
|
+
...{
|
|
12
|
+
name: "BnButton"
|
|
13
|
+
},
|
|
14
|
+
__name: "Button",
|
|
15
|
+
props: {
|
|
16
|
+
tag: { default: "button" },
|
|
17
|
+
type: {},
|
|
18
|
+
size: {},
|
|
19
|
+
plain: { type: Boolean },
|
|
20
|
+
round: { type: Boolean },
|
|
21
|
+
circle: { type: Boolean },
|
|
22
|
+
disabled: { type: Boolean },
|
|
23
|
+
autofocus: { type: Boolean },
|
|
24
|
+
nativeType: { default: "button" },
|
|
25
|
+
icon: {},
|
|
26
|
+
loading: { type: Boolean },
|
|
27
|
+
loadingIcon: {},
|
|
28
|
+
useThrottle: { type: Boolean, default: true },
|
|
29
|
+
throttleDuration: { default: 500 }
|
|
30
|
+
},
|
|
31
|
+
emits: ["click"],
|
|
32
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
33
|
+
library.add(faSpinner);
|
|
34
|
+
const props = __props;
|
|
35
|
+
const ctx = inject(BUTTON_GROUP_CTX_KEY, void 0);
|
|
36
|
+
const size = computed(() => (ctx == null ? void 0 : ctx.size) ?? props.size ?? "");
|
|
37
|
+
const type = computed(() => (ctx == null ? void 0 : ctx.type) ?? props.type ?? "");
|
|
38
|
+
const disabled = computed(() => (ctx == null ? void 0 : ctx.disabled) || props.disabled || false);
|
|
39
|
+
const emits = __emit;
|
|
40
|
+
const slots = useSlots();
|
|
41
|
+
const _ref = ref();
|
|
42
|
+
const iconStyle = computed(() => ({
|
|
43
|
+
marginRight: slots.default ? "6px" : "0px"
|
|
44
|
+
}));
|
|
45
|
+
const handleBthClick = (e) => emits("click", e);
|
|
46
|
+
const handleBthClickThrottle = throttle(
|
|
47
|
+
handleBthClick,
|
|
48
|
+
props.throttleDuration,
|
|
49
|
+
{ trailing: false }
|
|
50
|
+
);
|
|
51
|
+
__expose({
|
|
52
|
+
ref: _ref,
|
|
53
|
+
disabled,
|
|
54
|
+
size,
|
|
55
|
+
type
|
|
56
|
+
});
|
|
57
|
+
return (_ctx, _cache) => {
|
|
58
|
+
return openBlock(), createBlock(resolveDynamicComponent(props.tag), {
|
|
59
|
+
ref_key: "_ref",
|
|
60
|
+
ref: _ref,
|
|
61
|
+
class: normalizeClass(["er-button", {
|
|
62
|
+
[`er-button--${type.value}`]: type.value,
|
|
63
|
+
[`er-button--${size.value}`]: size.value,
|
|
64
|
+
"is-plain": __props.plain,
|
|
65
|
+
"is-round": __props.round,
|
|
66
|
+
"is-circle": __props.circle,
|
|
67
|
+
"is-disabled": disabled.value,
|
|
68
|
+
"is-loading": __props.loading
|
|
69
|
+
}]),
|
|
70
|
+
autofocus: __props.autofocus,
|
|
71
|
+
type: __props.tag === "button" ? __props.nativeType : void 0,
|
|
72
|
+
disabled: disabled.value || __props.loading,
|
|
73
|
+
onClick: _cache[0] || (_cache[0] = (e) => __props.useThrottle ? unref(handleBthClickThrottle)(e) : handleBthClick(e))
|
|
74
|
+
}, {
|
|
75
|
+
default: withCtx(() => [
|
|
76
|
+
__props.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }, () => [
|
|
77
|
+
createVNode(_sfc_main$1, {
|
|
78
|
+
class: "loading-icon",
|
|
79
|
+
icon: __props.loadingIcon ?? unref(faSpinner),
|
|
80
|
+
style: normalizeStyle(iconStyle.value),
|
|
81
|
+
size: "1x",
|
|
82
|
+
spin: ""
|
|
83
|
+
}, null, 8, ["icon", "style"])
|
|
84
|
+
]) : createCommentVNode("", true),
|
|
85
|
+
__props.icon && !__props.loading ? (openBlock(), createBlock(_sfc_main$1, {
|
|
86
|
+
key: 1,
|
|
87
|
+
icon: __props.icon,
|
|
88
|
+
size: "1x",
|
|
89
|
+
style: normalizeStyle(iconStyle.value)
|
|
90
|
+
}, null, 8, ["icon", "style"])) : createCommentVNode("", true),
|
|
91
|
+
renderSlot(_ctx.$slots, "default")
|
|
92
|
+
]),
|
|
93
|
+
_: 3
|
|
94
|
+
}, 8, ["autofocus", "type", "disabled", "class"]);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const BnButton = withInstall(_sfc_main);
|
|
99
|
+
export {
|
|
100
|
+
BUTTON_GROUP_CTX_KEY as B,
|
|
101
|
+
_sfc_main as _,
|
|
102
|
+
BnButton as a
|
|
103
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineComponent, provide, reactive, toRef, openBlock, createElementBlock, renderSlot } from "vue";
|
|
2
|
+
import { B as BUTTON_GROUP_CTX_KEY } from "./Button-Bwzevixh.js";
|
|
3
|
+
import { w as withInstall } from "./utils-Uf9tqvV5.js";
|
|
4
|
+
import "@fortawesome/free-solid-svg-icons";
|
|
5
|
+
const _hoisted_1 = { class: "er-button-group" };
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
...{
|
|
8
|
+
name: "BnButtonGroup"
|
|
9
|
+
},
|
|
10
|
+
__name: "ButtonGroup",
|
|
11
|
+
props: {
|
|
12
|
+
size: {},
|
|
13
|
+
type: {},
|
|
14
|
+
disabled: { type: Boolean }
|
|
15
|
+
},
|
|
16
|
+
setup(__props) {
|
|
17
|
+
const props = __props;
|
|
18
|
+
provide(
|
|
19
|
+
BUTTON_GROUP_CTX_KEY,
|
|
20
|
+
reactive({
|
|
21
|
+
size: toRef(props, "size"),
|
|
22
|
+
type: toRef(props, "type"),
|
|
23
|
+
disabled: toRef(props, "disabled")
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
return (_ctx, _cache) => {
|
|
27
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
28
|
+
renderSlot(_ctx.$slots, "default")
|
|
29
|
+
]);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const BnButtonGroup = withInstall(_sfc_main);
|
|
34
|
+
export {
|
|
35
|
+
BnButtonGroup as B
|
|
36
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, mergeProps, createVNode, unref, normalizeProps, guardReactiveProps } from "vue";
|
|
2
|
+
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
|
3
|
+
import { p as omit } from "./vendor-R0ZbR4ac.js";
|
|
4
|
+
import { w as withInstall } from "./utils-Uf9tqvV5.js";
|
|
5
|
+
import "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
...{
|
|
8
|
+
name: "BnIcon",
|
|
9
|
+
inheritAttrs: false
|
|
10
|
+
},
|
|
11
|
+
__name: "Icon",
|
|
12
|
+
props: {
|
|
13
|
+
border: { type: Boolean },
|
|
14
|
+
fixedWidth: { type: Boolean },
|
|
15
|
+
flip: {},
|
|
16
|
+
icon: {},
|
|
17
|
+
mask: {},
|
|
18
|
+
listItem: { type: Boolean },
|
|
19
|
+
pull: {},
|
|
20
|
+
pulse: { type: Boolean },
|
|
21
|
+
rotation: {},
|
|
22
|
+
swapOpacity: { type: Boolean },
|
|
23
|
+
size: {},
|
|
24
|
+
spin: { type: Boolean },
|
|
25
|
+
transform: {},
|
|
26
|
+
symbol: { type: [Boolean, String] },
|
|
27
|
+
title: {},
|
|
28
|
+
inverse: { type: Boolean },
|
|
29
|
+
bounce: { type: Boolean },
|
|
30
|
+
shake: { type: Boolean },
|
|
31
|
+
beat: { type: Boolean },
|
|
32
|
+
fade: { type: Boolean },
|
|
33
|
+
beatFade: { type: Boolean },
|
|
34
|
+
spinPulse: { type: Boolean },
|
|
35
|
+
spinReverse: { type: Boolean },
|
|
36
|
+
type: {},
|
|
37
|
+
color: {}
|
|
38
|
+
},
|
|
39
|
+
setup(__props) {
|
|
40
|
+
const props = __props;
|
|
41
|
+
const filterProps = computed(() => omit(props, ["type", "color"]));
|
|
42
|
+
const customStyles = computed(() => ({ color: props.color ?? void 0 }));
|
|
43
|
+
return (_ctx, _cache) => {
|
|
44
|
+
return openBlock(), createElementBlock("i", mergeProps({
|
|
45
|
+
class: ["er-icon", [`er-icon--${__props.type}`]],
|
|
46
|
+
style: customStyles.value
|
|
47
|
+
}, _ctx.$attrs), [
|
|
48
|
+
createVNode(unref(FontAwesomeIcon), normalizeProps(guardReactiveProps(filterProps.value)), null, 16)
|
|
49
|
+
], 16);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const BnIcon = withInstall(_sfc_main);
|
|
54
|
+
export {
|
|
55
|
+
BnIcon as B,
|
|
56
|
+
_sfc_main as _
|
|
57
|
+
};
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { defineComponent, useCssVars, computed, openBlock, createBlock, Transition, withCtx, withDirectives, createElementVNode, normalizeClass, createCommentVNode, createElementBlock, toDisplayString, vShow, nextTick, ref, reactive, createApp } from "vue";
|
|
2
|
+
import { e as useZIndex } from "./hooks-D92zul9o.js";
|
|
3
|
+
import { _ as _sfc_main$1 } from "./Icon-C5WM3GNh.js";
|
|
4
|
+
import { m as isString, k as isNil, a as defer, e as delay } from "./vendor-R0ZbR4ac.js";
|
|
5
|
+
const _hoisted_1 = { class: "er-loading__spinner" };
|
|
6
|
+
const _hoisted_2 = {
|
|
7
|
+
key: 1,
|
|
8
|
+
class: "er-loading-text"
|
|
9
|
+
};
|
|
10
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
|
+
...{
|
|
12
|
+
name: "BnLoading",
|
|
13
|
+
inheritAttrs: false
|
|
14
|
+
},
|
|
15
|
+
__name: "Loading",
|
|
16
|
+
props: {
|
|
17
|
+
visible: {},
|
|
18
|
+
background: {},
|
|
19
|
+
spinner: {},
|
|
20
|
+
text: {},
|
|
21
|
+
fullscreen: {},
|
|
22
|
+
lock: {},
|
|
23
|
+
beforeClose: { type: Function },
|
|
24
|
+
closed: { type: Function },
|
|
25
|
+
target: {},
|
|
26
|
+
body: { type: Boolean },
|
|
27
|
+
zIndex: {},
|
|
28
|
+
onAfterLeave: { type: Function }
|
|
29
|
+
},
|
|
30
|
+
setup(__props) {
|
|
31
|
+
useCssVars((_ctx) => ({
|
|
32
|
+
"v098d7d6e": _ctx.background,
|
|
33
|
+
"v1880a613": _ctx.zIndex
|
|
34
|
+
}));
|
|
35
|
+
const props = __props;
|
|
36
|
+
const iconName = computed(() => {
|
|
37
|
+
if (isString(props.spinner)) {
|
|
38
|
+
return props.spinner;
|
|
39
|
+
}
|
|
40
|
+
return "spinner";
|
|
41
|
+
});
|
|
42
|
+
return (_ctx, _cache) => {
|
|
43
|
+
return openBlock(), createBlock(Transition, {
|
|
44
|
+
name: "fade-in-linear",
|
|
45
|
+
onAfterLeave: __props.onAfterLeave
|
|
46
|
+
}, {
|
|
47
|
+
default: withCtx(() => [
|
|
48
|
+
withDirectives(createElementVNode("div", {
|
|
49
|
+
class: normalizeClass(["er-loading er-loading__mask", { "is-fullscreen": __props.fullscreen }])
|
|
50
|
+
}, [
|
|
51
|
+
createElementVNode("div", _hoisted_1, [
|
|
52
|
+
props.spinner !== false ? (openBlock(), createBlock(_sfc_main$1, {
|
|
53
|
+
key: 0,
|
|
54
|
+
icon: iconName.value,
|
|
55
|
+
spin: ""
|
|
56
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
57
|
+
__props.text ? (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(__props.text), 1)) : createCommentVNode("", true)
|
|
58
|
+
])
|
|
59
|
+
], 2), [
|
|
60
|
+
[vShow, props.visible.value]
|
|
61
|
+
])
|
|
62
|
+
]),
|
|
63
|
+
_: 1
|
|
64
|
+
}, 8, ["onAfterLeave"]);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const RELATIVE_CLASS = "er-loading-parent--relative";
|
|
69
|
+
const HIDDEN_CLASS = "er-loading-parent--hiden";
|
|
70
|
+
const LOADING_NUMB_KEY = "er-loading-numb";
|
|
71
|
+
const instanceMap = /* @__PURE__ */ new Map();
|
|
72
|
+
const { nextZIndex } = useZIndex(3e4);
|
|
73
|
+
function createLoadingComponent(options) {
|
|
74
|
+
const visible = ref(options.visible);
|
|
75
|
+
const afterLeaveFlag = ref(false);
|
|
76
|
+
const handleAfterLeave = () => {
|
|
77
|
+
if (!afterLeaveFlag.value) return;
|
|
78
|
+
destory();
|
|
79
|
+
};
|
|
80
|
+
const data = reactive({
|
|
81
|
+
...options,
|
|
82
|
+
onAfterLeave: handleAfterLeave
|
|
83
|
+
});
|
|
84
|
+
const setText = (text) => data.text = text;
|
|
85
|
+
const destory = () => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
const target = data.parent;
|
|
88
|
+
subtLoadingNumb(target);
|
|
89
|
+
if (getLoadingNumb(target)) return;
|
|
90
|
+
delay(() => {
|
|
91
|
+
removeRelativeClass(target);
|
|
92
|
+
removeHiddenClass(target);
|
|
93
|
+
}, 1);
|
|
94
|
+
instanceMap.delete(target ?? document.body);
|
|
95
|
+
(_b = (_a = vm.$el) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.removeChild(vm.$el);
|
|
96
|
+
app.unmount();
|
|
97
|
+
};
|
|
98
|
+
let afterLeaveTimer;
|
|
99
|
+
const close = () => {
|
|
100
|
+
var _a;
|
|
101
|
+
if (options.beforeClose && !options.beforeClose()) return;
|
|
102
|
+
afterLeaveFlag.value = true;
|
|
103
|
+
clearTimeout(afterLeaveTimer);
|
|
104
|
+
afterLeaveTimer = defer(handleAfterLeave);
|
|
105
|
+
visible.value = false;
|
|
106
|
+
(_a = options.closed) == null ? void 0 : _a.call(options);
|
|
107
|
+
};
|
|
108
|
+
const app = createApp(_sfc_main, {
|
|
109
|
+
...data,
|
|
110
|
+
zIndex: data.fullscreen ? nextZIndex() : void 0,
|
|
111
|
+
visible
|
|
112
|
+
});
|
|
113
|
+
const vm = app.mount(document.createElement("div"));
|
|
114
|
+
return {
|
|
115
|
+
get $el() {
|
|
116
|
+
return vm.$el;
|
|
117
|
+
},
|
|
118
|
+
vm,
|
|
119
|
+
close,
|
|
120
|
+
visible,
|
|
121
|
+
setText
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function resolveOptions(options) {
|
|
125
|
+
let target;
|
|
126
|
+
if (isString(options.target)) {
|
|
127
|
+
target = document.querySelector(options.target) ?? document.body;
|
|
128
|
+
} else {
|
|
129
|
+
target = options.target || document.body;
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
parent: target === document.body || options.body ? document.body : target,
|
|
133
|
+
background: options.background ?? "rgba(0, 0, 0, 0.5)",
|
|
134
|
+
spinner: options.spinner,
|
|
135
|
+
text: options.text,
|
|
136
|
+
fullscreen: target === document.body && (options.fullscreen ?? true),
|
|
137
|
+
lock: options.lock ?? false,
|
|
138
|
+
visible: options.visible ?? true,
|
|
139
|
+
target
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function addRelativeClass(target = document.body) {
|
|
143
|
+
target.classList.add(RELATIVE_CLASS);
|
|
144
|
+
}
|
|
145
|
+
function removeRelativeClass(target = document.body) {
|
|
146
|
+
target.classList.remove(RELATIVE_CLASS);
|
|
147
|
+
}
|
|
148
|
+
function addHiddenClass(target = document.body) {
|
|
149
|
+
target.classList.add(HIDDEN_CLASS);
|
|
150
|
+
}
|
|
151
|
+
function removeHiddenClass(target = document.body) {
|
|
152
|
+
target.classList.remove(HIDDEN_CLASS);
|
|
153
|
+
}
|
|
154
|
+
function getLoadingNumb(target = document.body) {
|
|
155
|
+
return target.getAttribute(LOADING_NUMB_KEY);
|
|
156
|
+
}
|
|
157
|
+
function removeLoadingNumb(target = document.body) {
|
|
158
|
+
target.removeAttribute(LOADING_NUMB_KEY);
|
|
159
|
+
}
|
|
160
|
+
function addLoadingNumb(target = document.body) {
|
|
161
|
+
const numb = getLoadingNumb(target) ?? "0";
|
|
162
|
+
target.setAttribute(LOADING_NUMB_KEY, `${Number.parseInt(numb) + 1}`);
|
|
163
|
+
}
|
|
164
|
+
function subtLoadingNumb(target = document.body) {
|
|
165
|
+
const numb = getLoadingNumb(target);
|
|
166
|
+
if (numb) {
|
|
167
|
+
const newNumb = Number.parseInt(numb) - 1;
|
|
168
|
+
if (newNumb === 0) {
|
|
169
|
+
removeLoadingNumb(target);
|
|
170
|
+
} else {
|
|
171
|
+
target.setAttribute(LOADING_NUMB_KEY, `${newNumb}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function addClass(options, parent = document.body) {
|
|
176
|
+
if (options.lock) {
|
|
177
|
+
addHiddenClass(parent);
|
|
178
|
+
} else {
|
|
179
|
+
removeHiddenClass(parent);
|
|
180
|
+
}
|
|
181
|
+
addRelativeClass(parent);
|
|
182
|
+
}
|
|
183
|
+
let fullscreenInstance = null;
|
|
184
|
+
function Loading(options = {}) {
|
|
185
|
+
var _a;
|
|
186
|
+
const resolved = resolveOptions(options);
|
|
187
|
+
const target = resolved.parent ?? document.body;
|
|
188
|
+
if (resolved.fullscreen && !isNil(fullscreenInstance)) {
|
|
189
|
+
return fullscreenInstance;
|
|
190
|
+
}
|
|
191
|
+
addLoadingNumb(resolved == null ? void 0 : resolved.parent);
|
|
192
|
+
if (instanceMap.has(target)) {
|
|
193
|
+
return instanceMap.get(target);
|
|
194
|
+
}
|
|
195
|
+
const instance = createLoadingComponent({
|
|
196
|
+
...resolved,
|
|
197
|
+
closed: () => {
|
|
198
|
+
var _a2;
|
|
199
|
+
(_a2 = resolved.closed) == null ? void 0 : _a2.call(resolved);
|
|
200
|
+
if (resolved.fullscreen) {
|
|
201
|
+
fullscreenInstance = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
addClass(options, resolved == null ? void 0 : resolved.parent);
|
|
206
|
+
(_a = resolved.parent) == null ? void 0 : _a.appendChild(instance.$el);
|
|
207
|
+
nextTick(() => instance.visible.value = !!resolved.visible);
|
|
208
|
+
if (resolved.fullscreen) {
|
|
209
|
+
fullscreenInstance = instance;
|
|
210
|
+
}
|
|
211
|
+
instanceMap.set(target, instance);
|
|
212
|
+
return instance;
|
|
213
|
+
}
|
|
214
|
+
const INSTANCE_KEY = Symbol("loading");
|
|
215
|
+
function createInstance(el, binding) {
|
|
216
|
+
const getProp = (name) => {
|
|
217
|
+
return el.getAttribute(`er-loading-${name}`);
|
|
218
|
+
};
|
|
219
|
+
const getModifier = (name) => {
|
|
220
|
+
return binding.modifiers[name];
|
|
221
|
+
};
|
|
222
|
+
const fullscreen = getModifier("fullscreen");
|
|
223
|
+
const options = {
|
|
224
|
+
text: getProp("text"),
|
|
225
|
+
spinner: getProp("spinner"),
|
|
226
|
+
background: getProp("background"),
|
|
227
|
+
target: fullscreen ? void 0 : el,
|
|
228
|
+
body: getModifier("body"),
|
|
229
|
+
lock: getModifier("lock"),
|
|
230
|
+
fullscreen
|
|
231
|
+
};
|
|
232
|
+
el[INSTANCE_KEY] = {
|
|
233
|
+
options,
|
|
234
|
+
instance: Loading(options)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const vLoading = {
|
|
238
|
+
mounted(el, binding) {
|
|
239
|
+
if (binding.value) createInstance(el, binding);
|
|
240
|
+
},
|
|
241
|
+
updated(el, binding) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
if (binding.oldValue === binding.value) return;
|
|
244
|
+
if (binding.value && !binding.oldValue) {
|
|
245
|
+
createInstance(el, binding);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
(_b = (_a = el[INSTANCE_KEY]) == null ? void 0 : _a.instance) == null ? void 0 : _b.close();
|
|
249
|
+
},
|
|
250
|
+
unmounted(el) {
|
|
251
|
+
var _a;
|
|
252
|
+
(_a = el[INSTANCE_KEY]) == null ? void 0 : _a.instance.close();
|
|
253
|
+
el[INSTANCE_KEY] = void 0;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const BnLoading = {
|
|
257
|
+
name: "BnLoading",
|
|
258
|
+
install(app) {
|
|
259
|
+
app.directive("loading", vLoading);
|
|
260
|
+
app.config.globalProperties.$loading = Loading;
|
|
261
|
+
},
|
|
262
|
+
directive: vLoading,
|
|
263
|
+
service: Loading
|
|
264
|
+
};
|
|
265
|
+
export {
|
|
266
|
+
BnLoading as B,
|
|
267
|
+
Loading as L,
|
|
268
|
+
vLoading as v
|
|
269
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, onMounted, watch, openBlock, createBlock, Transition, withCtx, withDirectives, createElementVNode, normalizeStyle, normalizeClass, createVNode, renderSlot, unref, createCommentVNode, createElementBlock, withModifiers, vShow, shallowReactive, isVNode, h, render } from "vue";
|
|
2
|
+
import { d as useOffset, a as useEventListener, e as useZIndex, b as useId } from "./hooks-D92zul9o.js";
|
|
3
|
+
import { t as typeIconMap, R as RenderVnode, b as withInstallFunction } from "./utils-Uf9tqvV5.js";
|
|
4
|
+
import { _ as _sfc_main$1 } from "./Icon-C5WM3GNh.js";
|
|
5
|
+
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
import { b as bind, e as delay, g as forEach, m as isString, f as findIndex, h as get, s as set } from "./vendor-R0ZbR4ac.js";
|
|
7
|
+
const messageTypes = [
|
|
8
|
+
"info",
|
|
9
|
+
"success",
|
|
10
|
+
"warning",
|
|
11
|
+
"danger",
|
|
12
|
+
"error"
|
|
13
|
+
];
|
|
14
|
+
const _hoisted_1 = { class: "er-message__content" };
|
|
15
|
+
const _hoisted_2 = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "er-message__close"
|
|
18
|
+
};
|
|
19
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
20
|
+
...{
|
|
21
|
+
name: "BnMessage"
|
|
22
|
+
},
|
|
23
|
+
__name: "Message",
|
|
24
|
+
props: {
|
|
25
|
+
id: {},
|
|
26
|
+
message: {},
|
|
27
|
+
duration: { default: 3e3 },
|
|
28
|
+
showClose: { type: Boolean },
|
|
29
|
+
center: { type: Boolean },
|
|
30
|
+
type: { default: "info" },
|
|
31
|
+
offset: { default: 10 },
|
|
32
|
+
zIndex: {},
|
|
33
|
+
transitionName: { default: "fade-up" },
|
|
34
|
+
onDestory: {}
|
|
35
|
+
},
|
|
36
|
+
setup(__props, { expose: __expose }) {
|
|
37
|
+
const props = __props;
|
|
38
|
+
const visible = ref(false);
|
|
39
|
+
const messageRef = ref();
|
|
40
|
+
const iconName = computed(() => typeIconMap.get(props.type) ?? faCircleInfo);
|
|
41
|
+
const boxHeight = ref(0);
|
|
42
|
+
const { topOffset, bottomOffset } = useOffset({
|
|
43
|
+
getLastBottomOffset: bind(getLastBottomOffset, props),
|
|
44
|
+
offset: props.offset,
|
|
45
|
+
boxHeight
|
|
46
|
+
});
|
|
47
|
+
const cssStyle = computed(() => ({
|
|
48
|
+
top: topOffset.value + "px",
|
|
49
|
+
zIndex: props.zIndex
|
|
50
|
+
}));
|
|
51
|
+
let timer;
|
|
52
|
+
function startTimmer() {
|
|
53
|
+
if (props.duration === 0) return;
|
|
54
|
+
timer = delay(close, props.duration);
|
|
55
|
+
}
|
|
56
|
+
function clearTimer() {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
}
|
|
59
|
+
function close() {
|
|
60
|
+
visible.value = false;
|
|
61
|
+
}
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
visible.value = true;
|
|
64
|
+
startTimmer();
|
|
65
|
+
});
|
|
66
|
+
watch(visible, (val) => {
|
|
67
|
+
if (!val) boxHeight.value = -props.offset;
|
|
68
|
+
});
|
|
69
|
+
useEventListener(document, "keydown", (e) => {
|
|
70
|
+
const { code } = e;
|
|
71
|
+
if (code === "Escape") {
|
|
72
|
+
close();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
__expose({
|
|
76
|
+
bottomOffset,
|
|
77
|
+
close
|
|
78
|
+
});
|
|
79
|
+
return (_ctx, _cache) => {
|
|
80
|
+
return openBlock(), createBlock(Transition, {
|
|
81
|
+
name: __props.transitionName,
|
|
82
|
+
onEnter: _cache[0] || (_cache[0] = ($event) => boxHeight.value = messageRef.value.getBoundingClientRect().height),
|
|
83
|
+
onAfterLeave: _cache[1] || (_cache[1] = ($event) => !visible.value && __props.onDestory())
|
|
84
|
+
}, {
|
|
85
|
+
default: withCtx(() => [
|
|
86
|
+
withDirectives(createElementVNode("div", {
|
|
87
|
+
ref_key: "messageRef",
|
|
88
|
+
ref: messageRef,
|
|
89
|
+
class: normalizeClass(["er-message", {
|
|
90
|
+
[`er-message--${__props.type}`]: __props.type,
|
|
91
|
+
"is-close": __props.showClose,
|
|
92
|
+
"text-center": __props.center
|
|
93
|
+
}]),
|
|
94
|
+
style: normalizeStyle(cssStyle.value),
|
|
95
|
+
role: "alert",
|
|
96
|
+
onMouseenter: clearTimer,
|
|
97
|
+
onMouseleave: startTimmer
|
|
98
|
+
}, [
|
|
99
|
+
createVNode(_sfc_main$1, {
|
|
100
|
+
class: "er-message__icon",
|
|
101
|
+
icon: iconName.value
|
|
102
|
+
}, null, 8, ["icon"]),
|
|
103
|
+
createElementVNode("div", _hoisted_1, [
|
|
104
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
105
|
+
__props.message ? (openBlock(), createBlock(unref(RenderVnode), {
|
|
106
|
+
key: 0,
|
|
107
|
+
vNode: __props.message
|
|
108
|
+
}, null, 8, ["vNode"])) : createCommentVNode("", true)
|
|
109
|
+
])
|
|
110
|
+
]),
|
|
111
|
+
__props.showClose ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
112
|
+
createVNode(_sfc_main$1, {
|
|
113
|
+
icon: "xmark",
|
|
114
|
+
onClick: withModifiers(close, ["stop"])
|
|
115
|
+
})
|
|
116
|
+
])) : createCommentVNode("", true)
|
|
117
|
+
], 38), [
|
|
118
|
+
[vShow, visible.value]
|
|
119
|
+
])
|
|
120
|
+
]),
|
|
121
|
+
_: 3
|
|
122
|
+
}, 8, ["name"]);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const instances = shallowReactive([]);
|
|
127
|
+
const { nextZIndex } = useZIndex();
|
|
128
|
+
const messageDefaults = {
|
|
129
|
+
type: "info",
|
|
130
|
+
duration: 3e3,
|
|
131
|
+
offset: 10,
|
|
132
|
+
transitionName: "fade-up"
|
|
133
|
+
};
|
|
134
|
+
function normalizeOptions(options) {
|
|
135
|
+
const result = !options || isVNode(options) || isString(options) ? {
|
|
136
|
+
message: options
|
|
137
|
+
} : options;
|
|
138
|
+
return { ...messageDefaults, ...result };
|
|
139
|
+
}
|
|
140
|
+
function createMessage(props) {
|
|
141
|
+
const id = useId().value;
|
|
142
|
+
const container = document.createElement("div");
|
|
143
|
+
const destory = () => {
|
|
144
|
+
const idx = findIndex(instances, { id });
|
|
145
|
+
if (idx === -1) return;
|
|
146
|
+
instances.splice(idx, 1);
|
|
147
|
+
render(null, container);
|
|
148
|
+
};
|
|
149
|
+
const _props = {
|
|
150
|
+
...props,
|
|
151
|
+
id,
|
|
152
|
+
zIndex: nextZIndex(),
|
|
153
|
+
onDestory: destory
|
|
154
|
+
};
|
|
155
|
+
const vnode = h(_sfc_main, _props);
|
|
156
|
+
render(vnode, container);
|
|
157
|
+
document.body.appendChild(container.firstElementChild);
|
|
158
|
+
const vm = vnode.component;
|
|
159
|
+
const handler = {
|
|
160
|
+
close: () => vm.exposed.close()
|
|
161
|
+
};
|
|
162
|
+
const instance = {
|
|
163
|
+
props: _props,
|
|
164
|
+
id,
|
|
165
|
+
vm,
|
|
166
|
+
vnode,
|
|
167
|
+
handler
|
|
168
|
+
};
|
|
169
|
+
instances.push(instance);
|
|
170
|
+
return instance;
|
|
171
|
+
}
|
|
172
|
+
const message = function(options = {}) {
|
|
173
|
+
const normalized = normalizeOptions(options);
|
|
174
|
+
const instance = createMessage(normalized);
|
|
175
|
+
return instance.handler;
|
|
176
|
+
};
|
|
177
|
+
function getLastBottomOffset() {
|
|
178
|
+
const idx = findIndex(instances, { id: this.id });
|
|
179
|
+
if (idx <= 0) return 0;
|
|
180
|
+
return get(instances, [idx - 1, "vm", "exposed", "bottomOffset", "value"]);
|
|
181
|
+
}
|
|
182
|
+
function closeAll(type) {
|
|
183
|
+
forEach(instances, (instance) => {
|
|
184
|
+
if (type) {
|
|
185
|
+
instance.props.type === type && instance.handler.close();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
instance.handler.close();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
forEach(
|
|
192
|
+
messageTypes,
|
|
193
|
+
(type) => set(message, type, (options) => {
|
|
194
|
+
const normalized = normalizeOptions(options);
|
|
195
|
+
return message({ ...normalized, type });
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
message.closeAll = closeAll;
|
|
199
|
+
const BnMessage = withInstallFunction(message, "$message");
|
|
200
|
+
export {
|
|
201
|
+
BnMessage as B
|
|
202
|
+
};
|