@otwb/ui 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/auto-imports.d.ts +15 -0
- package/auto-imports.js +34 -0
- package/dist/components-mcRUKEL_.js +1650 -0
- package/dist/components.js +5 -0
- package/dist/directives-CRvPGywW.js +183 -0
- package/dist/directives.js +3 -0
- package/dist/index.js +1224 -0
- package/dist/page.js +519 -0
- package/dist/use-i18n-Dx7V4KrY.js +6 -0
- package/dist/use-style-DcT-1dj4.js +29 -0
- package/dist/use-style.js +2 -0
- package/esm/components.d.ts +448 -0
- package/esm/components.js +1 -0
- package/esm/design.d.ts +243 -0
- package/esm/directives.d.ts +42 -0
- package/esm/directives.js +1 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.js +1 -0
- package/esm/page.d.ts +170 -0
- package/esm/page.js +1 -0
- package/esm/use-style.d.ts +10 -0
- package/esm/use-style.js +1 -0
- package/locale.d.ts +78 -0
- package/package.json +99 -0
- package/unocss-preset.d.ts +5 -0
- package/unocss-preset.js +94 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./use-i18n-Dx7V4KrY.js";
|
|
2
|
+
import "./directives-CRvPGywW.js";
|
|
3
|
+
import "./use-style-DcT-1dj4.js";
|
|
4
|
+
import { a as NRadios, c as DataSelection, d as useLocaleEdit, f as DataFilter, g as NCheckboxes, h as DataActions, i as renderUsers, l as DataPagination, m as DataCustom, n as DtUserDept, o as DataTable, p as DataForm, r as DtUserRender, s as useDataTableDrag, t as DtDeptRender, u as DataLocaleInput } from "./components-mcRUKEL_.js";
|
|
5
|
+
export { DataActions, DataCustom, DataFilter, DataForm, DataLocaleInput, DataPagination, DataSelection, DataTable, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios, renderUsers, useDataTableDrag, useLocaleEdit };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { g as useStyle, i as cM, n as cB, r as cE, t as c } from "./use-style-DcT-1dj4.js";
|
|
2
|
+
import { Fragment, createVNode, defineComponent, h, nextTick, reactive, ref, shallowRef, toRef, watch } from "vue";
|
|
3
|
+
import { promiseTimeout, useEventListener } from "@vueuse/core";
|
|
4
|
+
import { NTooltip } from "ithinkdt-ui";
|
|
5
|
+
import { useElementIntersectionRect } from "@otwb/common/composables";
|
|
6
|
+
import { string2dom } from "@otwb/common/dom";
|
|
7
|
+
import { debounce } from "@otwb/common/fn";
|
|
8
|
+
var Tooltip = /* @__PURE__ */ Symbol("tooltip-dir"), current = /* @__PURE__ */ shallowRef(), _update;
|
|
9
|
+
const TooltipDirectiveProvider = /* @__PURE__ */ defineComponent({
|
|
10
|
+
name: "TooltipDirectiveProvider",
|
|
11
|
+
props: { delay: {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 180
|
|
14
|
+
} },
|
|
15
|
+
setup(d) {
|
|
16
|
+
let k = shallowRef(), A = reactive({
|
|
17
|
+
show: !1,
|
|
18
|
+
tip: void 0,
|
|
19
|
+
placement: "top",
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0
|
|
22
|
+
});
|
|
23
|
+
return _update = async () => {
|
|
24
|
+
if (!current.value) return;
|
|
25
|
+
d.delay > 0 && await promiseTimeout(d.delay);
|
|
26
|
+
let j = current.value, M = j?.[Tooltip];
|
|
27
|
+
if (!M) return;
|
|
28
|
+
let N = M.tip;
|
|
29
|
+
k.value = typeof N == "function" ? N : () => N || j.attributes.getNamedItem("title") || j.textContent;
|
|
30
|
+
let { auto: P } = M.binding.modifiers;
|
|
31
|
+
if (!P || j.firstChild.offsetWidth > j.clientWidth || j.firstChild.offsetHeight > j.clientHeight) {
|
|
32
|
+
A.show = !0;
|
|
33
|
+
let d = j.getBoundingClientRect();
|
|
34
|
+
switch (A.placement = Object.keys(M.binding.modifiers).find((d) => [
|
|
35
|
+
"top",
|
|
36
|
+
"right",
|
|
37
|
+
"left",
|
|
38
|
+
"bottom"
|
|
39
|
+
].find((k) => d.startsWith(k))) ?? "top", A.placement.split("-")[0]) {
|
|
40
|
+
case "top":
|
|
41
|
+
A.x = d.left + d.width / 2, A.y = d.top;
|
|
42
|
+
break;
|
|
43
|
+
case "right":
|
|
44
|
+
A.x = d.left + d.width, A.y = d.top + d.height / 2;
|
|
45
|
+
break;
|
|
46
|
+
case "left":
|
|
47
|
+
A.x = d.left, A.y = d.top + d.height / 2;
|
|
48
|
+
break;
|
|
49
|
+
case "bottom":
|
|
50
|
+
A.x = d.left + d.width / 2, A.y = d.bottom;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
} else A.show &&= !1;
|
|
54
|
+
}, useEventListener("mouseover", (d) => {
|
|
55
|
+
let k = d.target;
|
|
56
|
+
!current.value || current.value?.contains(k) || (A.show = !1, current.value = void 0);
|
|
57
|
+
}, { capture: !0 }), () => createVNode(NTooltip, {
|
|
58
|
+
trigger: "manual",
|
|
59
|
+
show: !!current.value && A.show,
|
|
60
|
+
x: A.x,
|
|
61
|
+
y: A.y,
|
|
62
|
+
placement: A.placement,
|
|
63
|
+
keepAliveOnHover: !0
|
|
64
|
+
}, { default: () => [k.value?.()] });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
var _listener = (d) => {
|
|
68
|
+
current.value = d.target, _update?.();
|
|
69
|
+
};
|
|
70
|
+
const vTooltip = {
|
|
71
|
+
mounted(d, k) {
|
|
72
|
+
d[Tooltip] = {
|
|
73
|
+
binding: k,
|
|
74
|
+
tip: k.value
|
|
75
|
+
}, d.addEventListener("mouseenter", _listener);
|
|
76
|
+
},
|
|
77
|
+
updated(d, k) {
|
|
78
|
+
d[Tooltip].binding = k, d[Tooltip].tip = k.value, _update();
|
|
79
|
+
},
|
|
80
|
+
beforeUnmount(d) {
|
|
81
|
+
d[Tooltip] && d.removeEventListener("mouseenter", _listener), current.value === d && (current.value = void 0), delete d[Tooltip];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var clsPrefix, isDark, style = /* @__PURE__ */ c([c(({ props: d }) => `:where(${d.bPrefix}spin-host)`, { position: "relative" }), cB("spin-directive", {
|
|
85
|
+
zIndex: "999999",
|
|
86
|
+
position: "absolute",
|
|
87
|
+
color: "var(--color-primary)",
|
|
88
|
+
display: "flex",
|
|
89
|
+
flexDirection: "column",
|
|
90
|
+
justifyContent: "center",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
gap: "4px",
|
|
93
|
+
willChange: "background-color",
|
|
94
|
+
backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0)",
|
|
95
|
+
transition: "background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
96
|
+
}, [
|
|
97
|
+
cE("tip, icon", {
|
|
98
|
+
willChange: "opacity",
|
|
99
|
+
opacity: "0",
|
|
100
|
+
transition: "opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
101
|
+
}),
|
|
102
|
+
cE("tip:empty", { display: "none" }),
|
|
103
|
+
cM("spining", { backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0.5)" }, [cE("tip, icon", { opacity: "1" })])
|
|
104
|
+
])]);
|
|
105
|
+
const SpinDirectiveProvider = /* @__PURE__ */ defineComponent({
|
|
106
|
+
name: "SpinDirectiveProvider",
|
|
107
|
+
props: { dark: Boolean },
|
|
108
|
+
setup(k) {
|
|
109
|
+
return clsPrefix = useStyle("-spin-directive", style), isDark = toRef(k, "dark"), () => h(Fragment);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
var Spin = /* @__PURE__ */ Symbol("spin-dir"), updateLoading = (d, { value: k, modifiers: A }) => {
|
|
113
|
+
if (d[Spin].loading.value = !!k, !d[Spin].loading.value) return;
|
|
114
|
+
let j = A.dark || !A.light && isDark.value;
|
|
115
|
+
d[Spin].spinEl.style.setProperty("--host-bg", j ? "0 0 0" : "255 255 255");
|
|
116
|
+
};
|
|
117
|
+
const vSpin = {
|
|
118
|
+
beforeMount(d) {
|
|
119
|
+
if (d.classList.add(`${clsPrefix.value}-spin-host`), d[Spin]) return;
|
|
120
|
+
let k = ref(!1), A = string2dom(`
|
|
121
|
+
<div class="${clsPrefix.value}-spin-directive">
|
|
122
|
+
<svg class="${clsPrefix.value}-spin-directive__icon" width="32" height="32" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
123
|
+
<g>
|
|
124
|
+
<animateTransform attributeName="transform" type="rotate" values="0 100 100;270 100 100" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animateTransform>
|
|
125
|
+
<circle fill="none" stroke="currentColor" stroke-width="18" stroke-linecap="round" cx="100" cy="100" r="92" stroke-dasharray="567" stroke-dashoffset="1848">
|
|
126
|
+
<animateTransform attributeName="transform" type="rotate" values="0 100 100;135 100 100;450 100 100" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animateTransform>
|
|
127
|
+
<animate attributeName="stroke-dashoffset" values="567;142;567" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animate>
|
|
128
|
+
</circle>
|
|
129
|
+
</g>
|
|
130
|
+
</svg>
|
|
131
|
+
<div class="${clsPrefix.value}-spin-directive__tip"></div>
|
|
132
|
+
</div>
|
|
133
|
+
`.trim()), j, { stop: M, update: N } = useElementIntersectionRect(d, (d) => {
|
|
134
|
+
j = d, Object.assign(A.style, {
|
|
135
|
+
left: 0,
|
|
136
|
+
top: 0,
|
|
137
|
+
width: j.width + "px",
|
|
138
|
+
height: j.height + "px"
|
|
139
|
+
});
|
|
140
|
+
}, { interval: 1e3 / 30 }), P, F = watch(k, debounce(() => {
|
|
141
|
+
if (k.value) P === void 0 && (clearTimeout(P), P = void 0), N(), d.append(A), requestAnimationFrame(() => {
|
|
142
|
+
k.value && A.classList.add(`${clsPrefix.value}-spin-directive--spining`);
|
|
143
|
+
});
|
|
144
|
+
else {
|
|
145
|
+
A.classList.remove(`${clsPrefix.value}-spin-directive--spining`);
|
|
146
|
+
let d = () => {
|
|
147
|
+
A.remove(), k && clearTimeout(k), k = null, A.removeEventListener("transitioncancel", d), A.removeEventListener("transitionend", d);
|
|
148
|
+
};
|
|
149
|
+
A.addEventListener("transitioncancel", d), A.addEventListener("transitionend", d);
|
|
150
|
+
let k = setTimeout(d, 300);
|
|
151
|
+
}
|
|
152
|
+
}, 30));
|
|
153
|
+
d[Spin] = {
|
|
154
|
+
loading: k,
|
|
155
|
+
spinEl: A,
|
|
156
|
+
updateTip: () => {
|
|
157
|
+
let k = A.querySelector(`.${clsPrefix.value}-spin-directive__tip`);
|
|
158
|
+
k.textContent = d.dataset.spinTip;
|
|
159
|
+
},
|
|
160
|
+
stop: () => {
|
|
161
|
+
M(), F();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
mounted(d, k) {
|
|
166
|
+
updateLoading(d, k), d[Spin].updateTip(), !d[Spin].observer && nextTick().then(() => {
|
|
167
|
+
(d[Spin].observer = new MutationObserver((k) => {
|
|
168
|
+
for (let A of k) if (A.type === "attributes" && A.attributeName === "data-spin-tip") {
|
|
169
|
+
d[Spin].updateTip();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
})).observe(d, {
|
|
173
|
+
attributes: !0,
|
|
174
|
+
attributeFilter: ["data-spin-tip"]
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
updated: updateLoading,
|
|
179
|
+
beforeUnmount(d) {
|
|
180
|
+
d[Spin].loading.value = !1, d[Spin].stop(), d[Spin].observer?.disconnect(), delete d[Spin];
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
export { vTooltip as i, vSpin as n, TooltipDirectiveProvider as r, SpinDirectiveProvider as t };
|