@ithinkdt/ui 4.0.1 → 4.0.3

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.
@@ -1,2 +1,2 @@
1
- import { _ as dataFormActionsProps, a as DtUserRender, b as DataActions, c as DataTable, d as DataPagination, f as DataLocaleInput, g as DataFormActions, h as DataForm, i as DtUserDept, l as useDataTableDrag, m as DataFilter, n as StateButtonProps, o as renderUsers, p as useLocaleEdit, r as DtDeptRender, s as NRadios, t as NStateButton, u as DataSelection, v as DataDescriptions, x as NCheckboxes, y as DataCustom } from "./components-BXPJvdEe.js";
2
- export { DataActions, DataCustom, DataDescriptions, DataFilter, DataForm, DataFormActions, DataLocaleInput, DataPagination, DataSelection, DataTable, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios, NStateButton, StateButtonProps, dataFormActionsProps, renderUsers, useDataTableDrag, useLocaleEdit };
1
+ import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v, x as y, y as b } from "./components-Blh7O5zj.js";
2
+ export { n as DataActions, b as DataCustom, v as DataDescriptions, u as DataFilter, s as DataForm, o as DataFormActions, a as DataLocaleInput, i as DataPagination, _ as DataSelection, r as DataTable, m as DtDeptRender, c as DtUserDept, t as DtUserRender, y as NCheckboxes, h as NRadios, g as NStateButton, d as StateButtonProps, e as dataFormActionsProps, f as renderUsers, l as useDataTableDrag, p as useLocaleEdit };
@@ -0,0 +1,240 @@
1
+ import e, { c as t, cB as n, cE as r, cM as i } from "./use-style.js";
2
+ import { Fragment as a, createVNode as o, defineComponent as s, h as c, nextTick as l, reactive as u, ref as d, shallowRef as f, toRef as p, watch as m } from "vue";
3
+ import { promiseTimeout as h, useEventListener as g } from "@vueuse/core";
4
+ import { NTooltip as _ } from "ithinkdt-ui";
5
+ import { nanoid as v } from "nanoid";
6
+ import { debounce as y, throttle as b } from "@ithinkdt/common/fn";
7
+ import { useElementIntersectionRect as x } from "@ithinkdt/common/composables";
8
+ import { string2dom as S } from "@ithinkdt/common/dom";
9
+ var C = [
10
+ 2,
11
+ 3,
12
+ 5
13
+ ], w = t([
14
+ t(({ props: e }) => `:where(span${e.bPrefix}tooltip-host)`, { display: "inline-block" }),
15
+ t(({ props: e }) => `:where(${e.bPrefix}tooltip-host)`, {
16
+ maxWidth: "100%",
17
+ whiteSpace: "nowrap",
18
+ overflow: "hidden",
19
+ textOverflow: "ellipsis"
20
+ }),
21
+ ...C.map((e) => t(({ props: t }) => `:where(${t.bPrefix}tooltip-ell${e}:not(${t.bPrefix}tooltip-expanded))`, {
22
+ display: "-webkit-box",
23
+ WebkitLineClamp: e,
24
+ WebkitBoxOrient: "vertical",
25
+ whiteSpace: "normal"
26
+ })),
27
+ t(({ props: e }) => `:where(${e.bPrefix}tooltip-expandable)`, { cursor: "pointer" }),
28
+ t(({ props: e }) => `:where(${e.bPrefix}tooltip-expanded)`, {
29
+ cursor: "pointer",
30
+ whiteSpace: "normal",
31
+ lineHeight: "1.25"
32
+ })
33
+ ]), T = Symbol("tooltip-dir"), E = f();
34
+ function D(e) {
35
+ let t = e.firstChild;
36
+ if (!t) return !1;
37
+ let n = t instanceof Text ? {
38
+ width: e.scrollWidth,
39
+ height: e.scrollHeight
40
+ } : t.getBoundingClientRect?.() ?? {
41
+ width: t.clientWidth,
42
+ height: t.clientHeight
43
+ };
44
+ return n.width >= e.clientWidth + 1 || n.height >= e.clientHeight + 2;
45
+ }
46
+ var O, k, A;
47
+ const j = s({
48
+ name: "TooltipDirectiveProvider",
49
+ props: { delay: {
50
+ type: Number,
51
+ default: 180
52
+ } },
53
+ setup(t) {
54
+ A = e("-tooltip-directive", w);
55
+ let n = f(), r = u({
56
+ show: !1,
57
+ tip: void 0,
58
+ placement: "top",
59
+ x: 0,
60
+ y: 0
61
+ });
62
+ O = async () => {
63
+ if (!E.value) return;
64
+ t.delay > 0 && await h(t.delay);
65
+ let e = E.value;
66
+ if (e?.classList.contains(`${A.value}-tooltip-expanded`)) {
67
+ r.show = !1;
68
+ return;
69
+ }
70
+ let i = e?.[T];
71
+ if (!i) return;
72
+ i.binding.modifiers.expandable && e.classList.remove(`${A.value}-tooltip-expandable`);
73
+ let a = i.tip;
74
+ if (n.value = typeof a == "function" ? a : () => a || e.attributes.getNamedItem("title") || e.textContent, !i.binding.modifiers?.auto || D(e)) {
75
+ r.show = !0, i.binding.modifiers.expandable && e.classList.add(`${A.value}-tooltip-expandable`);
76
+ let t = e.getBoundingClientRect();
77
+ switch (r.placement = Object.keys(i.binding.modifiers).find((e) => [
78
+ "top",
79
+ "right",
80
+ "left",
81
+ "bottom"
82
+ ].find((t) => e.startsWith(t))) ?? "top", r.placement.split("-")[0]) {
83
+ case "top":
84
+ r.x = t.left + t.width / 2, r.y = t.top;
85
+ break;
86
+ case "right":
87
+ r.x = t.left + t.width, r.y = t.top + t.height / 2;
88
+ break;
89
+ case "left":
90
+ r.x = t.left, r.y = t.top + t.height / 2;
91
+ break;
92
+ case "bottom":
93
+ r.x = t.left + t.width / 2, r.y = t.bottom;
94
+ break;
95
+ }
96
+ } else r.show &&= !1;
97
+ };
98
+ let i = `ithinkdt-tooltip-${v()}`, a = b((e) => {
99
+ !k || k.contains(e) || e.closest(`.${i}`) || (r.show = !1, E.value = void 0);
100
+ }, 100, { leading: !1 });
101
+ return g("mouseover", (e) => {
102
+ k = E.value, a(e.target);
103
+ }, { capture: !0 }), () => o(_, {
104
+ trigger: "manual",
105
+ show: !!E.value && r.show,
106
+ scrollable: !0,
107
+ flip: !1,
108
+ x: r.x,
109
+ y: r.y,
110
+ placement: r.placement,
111
+ style: "max-width: 61.8vw; max-height: 61.8vh"
112
+ }, { default: () => [o("div", { class: i }, [n.value?.()])] });
113
+ }
114
+ });
115
+ var M = (e) => {
116
+ k = void 0, E.value = e.target, O?.();
117
+ }, N = (e) => {
118
+ e.target.classList.contains(`${A.value}-tooltip-expandable`) ? (e.target.classList.remove(`${A.value}-tooltip-expandable`), e.target.classList.add(`${A.value}-tooltip-expanded`), O()) : e.target.classList.contains(`${A.value}-tooltip-expanded`) && (e.target.classList.remove(`${A.value}-tooltip-expanded`), e.target.classList.add(`${A.value}-tooltip-expandable`), O());
119
+ };
120
+ const P = {
121
+ mounted(e, t) {
122
+ e[T] = {
123
+ binding: t,
124
+ tip: t.value
125
+ }, e.addEventListener("mouseenter", M), t.modifiers.auto && e.classList.add(`${A.value}-tooltip-host`), t.modifiers.expandable && (e.bindClick = !0, e.addEventListener("click", N));
126
+ for (let n of C) t.modifiers[`ell${n}`] && e.classList.add(`${A.value}-tooltip-ell${n}`);
127
+ },
128
+ updated(e, t) {
129
+ if (e[T]) {
130
+ e[T].binding = t, e[T].tip = t.value, e.classList.toggle(`${A.value}-tooltip-host`, t.modifiers.auto || !1);
131
+ for (let n of C) e.classList.toggle(`${A.value}-tooltip-ell${n}`, t.modifiers[`ell${n}`] || !1);
132
+ t.modifiers.expandable && !e.bindClick ? (e.bindClick = !0, e.addEventListener("click", N)) : e.bindClick && (e.bindClick = !1, e.removeEventListener("click", N)), E.value === e && O();
133
+ }
134
+ },
135
+ beforeUnmount(e) {
136
+ E.value === e && (E.value = void 0), e[T] && (e.removeEventListener("mouseenter", M), e.bindClick = !1, e.removeEventListener("click", N), e.classList.remove(`${A.value}-tooltip-host`, `${A.value}-tooltip-expandable`, `${A.value}-tooltip-expanded`, ...C.map((e) => `${A.value}-tooltip-ell${e}`)), delete e[T]);
137
+ }
138
+ };
139
+ var F, I, L = t([t(({ props: e }) => `:where(${e.bPrefix}spin-host)`, { position: "relative" }), n("spin-directive", {
140
+ zIndex: "999999",
141
+ position: "absolute",
142
+ color: "var(--color-primary)",
143
+ display: "flex",
144
+ flexDirection: "column",
145
+ justifyContent: "center",
146
+ alignItems: "center",
147
+ gap: "4px",
148
+ willChange: "background-color",
149
+ backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0)",
150
+ transition: "background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
151
+ }, [
152
+ r("tip, icon", {
153
+ willChange: "opacity",
154
+ opacity: "0",
155
+ transition: "opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
156
+ }),
157
+ r("tip:empty", { display: "none" }),
158
+ i("spining", { backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0.5)" }, [r("tip, icon", { opacity: "1" })])
159
+ ])]);
160
+ const R = s({
161
+ name: "SpinDirectiveProvider",
162
+ props: { dark: Boolean },
163
+ setup(t) {
164
+ return F = e("-spin-directive", L), I = p(t, "dark"), () => c(a);
165
+ }
166
+ });
167
+ var z = Symbol("spin-dir"), B = (e, { value: t, modifiers: n }) => {
168
+ if (e[z].loading.value = !!t, !e[z].loading.value) return;
169
+ let r = n.dark || !n.light && I.value;
170
+ e[z].spinEl.style.setProperty("--host-bg", r ? "0 0 0" : "255 255 255");
171
+ };
172
+ const V = {
173
+ beforeMount(e) {
174
+ if (e.classList.add(`${F.value}-spin-host`), e[z]) return;
175
+ let t = d(!1), n = S(`
176
+ <div class="${F.value}-spin-directive">
177
+ <svg class="${F.value}-spin-directive__icon" width="32" height="32" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
178
+ <g>
179
+ <animateTransform attributeName="transform" type="rotate" values="0 100 100;270 100 100" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animateTransform>
180
+ <circle fill="none" stroke="currentColor" stroke-width="18" stroke-linecap="round" cx="100" cy="100" r="92" stroke-dasharray="567" stroke-dashoffset="1848">
181
+ <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>
182
+ <animate attributeName="stroke-dashoffset" values="567;142;567" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animate>
183
+ </circle>
184
+ </g>
185
+ </svg>
186
+ <div class="${F.value}-spin-directive__tip"></div>
187
+ </div>
188
+ `.trim()), r, { stop: i, update: a } = x(e, (e) => {
189
+ r = e, Object.assign(n.style, {
190
+ left: 0,
191
+ top: 0,
192
+ width: r.width + "px",
193
+ height: r.height + "px"
194
+ });
195
+ }, { interval: 1e3 / 30 }), o, s = m(t, y(() => {
196
+ if (t.value) o === void 0 && (clearTimeout(o), o = void 0), a(), e.append(n), requestAnimationFrame(() => {
197
+ t.value && n.classList.add(`${F.value}-spin-directive--spining`);
198
+ });
199
+ else {
200
+ n.classList.remove(`${F.value}-spin-directive--spining`);
201
+ let e = () => {
202
+ n.remove(), t && clearTimeout(t), t = null, n.removeEventListener("transitioncancel", e), n.removeEventListener("transitionend", e);
203
+ };
204
+ n.addEventListener("transitioncancel", e), n.addEventListener("transitionend", e);
205
+ let t = setTimeout(e, 300);
206
+ }
207
+ }, 30));
208
+ e[z] = {
209
+ loading: t,
210
+ spinEl: n,
211
+ updateTip: () => {
212
+ let t = n.querySelector(`.${F.value}-spin-directive__tip`);
213
+ t.textContent = e.dataset.spinTip;
214
+ },
215
+ stop: () => {
216
+ i(), s();
217
+ }
218
+ };
219
+ },
220
+ mounted(e, t) {
221
+ e[z] && (B(e, t), e[z].updateTip(), !e[z].observer && l().then(() => {
222
+ (e[z].observer = new MutationObserver((t) => {
223
+ for (let n of t) if (n.type === "attributes" && n.attributeName === "data-spin-tip") {
224
+ e[z].updateTip();
225
+ return;
226
+ }
227
+ })).observe(e, {
228
+ attributes: !0,
229
+ attributeFilter: ["data-spin-tip"]
230
+ });
231
+ }));
232
+ },
233
+ updated(e, t) {
234
+ e[z] && B(e, t);
235
+ },
236
+ beforeUnmount(e) {
237
+ e[z] && (e[z].loading.value = !1, e[z].stop(), e[z].observer?.disconnect(), delete e[z]);
238
+ }
239
+ };
240
+ export { P as i, V as n, j as r, R as t };
@@ -1,2 +1,2 @@
1
- import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-pc2Vi93X.js";
2
- export { SpinDirectiveProvider, TooltipDirectiveProvider, vSpin, vTooltip };
1
+ import { i as e, n as t, r as n, t as r } from "./directives-DXNnV4xc.js";
2
+ export { r as SpinDirectiveProvider, n as TooltipDirectiveProvider, t as vSpin, e as vTooltip };