@ithinkdt/ui 4.0.0-9 → 4.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.
@@ -0,0 +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 };
@@ -0,0 +1,240 @@
1
+ import { g as useStyle, i as cM, n as cB, r as cE, t as c } from "./use-style-BGq0HdRK.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 { nanoid } from "nanoid";
6
+ import { debounce, throttle } from "@ithinkdt/common/fn";
7
+ import { useElementIntersectionRect } from "@ithinkdt/common/composables";
8
+ import { string2dom } from "@ithinkdt/common/dom";
9
+ var SUPPORT_LINE_CLAMP = [
10
+ 2,
11
+ 3,
12
+ 5
13
+ ], style$1 = /* @__PURE__ */ c([
14
+ c(({ props: e }) => `:where(span${e.bPrefix}tooltip-host)`, { display: "inline-block" }),
15
+ c(({ props: e }) => `:where(${e.bPrefix}tooltip-host)`, {
16
+ maxWidth: "100%",
17
+ whiteSpace: "nowrap",
18
+ overflow: "hidden",
19
+ textOverflow: "ellipsis"
20
+ }),
21
+ ...SUPPORT_LINE_CLAMP.map((e) => c(({ 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
+ c(({ props: e }) => `:where(${e.bPrefix}tooltip-expandable)`, { cursor: "pointer" }),
28
+ c(({ props: e }) => `:where(${e.bPrefix}tooltip-expanded)`, {
29
+ cursor: "pointer",
30
+ whiteSpace: "normal",
31
+ lineHeight: "1.25"
32
+ })
33
+ ]), Tooltip = /* @__PURE__ */ Symbol("tooltip-dir"), current = /* @__PURE__ */ shallowRef();
34
+ function detectOverflow(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 _update, _current, clsPrefix$1;
47
+ const TooltipDirectiveProvider = /* @__PURE__ */ defineComponent({
48
+ name: "TooltipDirectiveProvider",
49
+ props: { delay: {
50
+ type: Number,
51
+ default: 180
52
+ } },
53
+ setup(t) {
54
+ clsPrefix$1 = useStyle("-tooltip-directive", style$1);
55
+ let n = shallowRef(), r = reactive({
56
+ show: !1,
57
+ tip: void 0,
58
+ placement: "top",
59
+ x: 0,
60
+ y: 0
61
+ });
62
+ _update = async () => {
63
+ if (!current.value) return;
64
+ t.delay > 0 && await promiseTimeout(t.delay);
65
+ let e = current.value;
66
+ if (e?.classList.contains(`${clsPrefix$1.value}-tooltip-expanded`)) {
67
+ r.show = !1;
68
+ return;
69
+ }
70
+ let i = e?.[Tooltip];
71
+ if (!i) return;
72
+ i.binding.modifiers.expandable && e.classList.remove(`${clsPrefix$1.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 || detectOverflow(e)) {
75
+ r.show = !0, i.binding.modifiers.expandable && e.classList.add(`${clsPrefix$1.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-${nanoid()}`, a = throttle((e) => {
99
+ !_current || _current.contains(e) || e.closest(`.${i}`) || (r.show = !1, current.value = void 0);
100
+ }, 100, { leading: !1 });
101
+ return useEventListener("mouseover", (e) => {
102
+ _current = current.value, a(e.target);
103
+ }, { capture: !0 }), () => createVNode(NTooltip, {
104
+ trigger: "manual",
105
+ show: !!current.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: () => [createVNode("div", { class: i }, [n.value?.()])] });
113
+ }
114
+ });
115
+ var _mouseenter = (e) => {
116
+ _current = void 0, current.value = e.target, _update?.();
117
+ }, _click = (e) => {
118
+ e.target.classList.contains(`${clsPrefix$1.value}-tooltip-expandable`) ? (e.target.classList.remove(`${clsPrefix$1.value}-tooltip-expandable`), e.target.classList.add(`${clsPrefix$1.value}-tooltip-expanded`), _update()) : e.target.classList.contains(`${clsPrefix$1.value}-tooltip-expanded`) && (e.target.classList.remove(`${clsPrefix$1.value}-tooltip-expanded`), e.target.classList.add(`${clsPrefix$1.value}-tooltip-expandable`), _update());
119
+ };
120
+ const vTooltip = {
121
+ mounted(e, t) {
122
+ e[Tooltip] = {
123
+ binding: t,
124
+ tip: t.value
125
+ }, e.addEventListener("mouseenter", _mouseenter), t.modifiers.auto && e.classList.add(`${clsPrefix$1.value}-tooltip-host`), t.modifiers.expandable && (e.bindClick = !0, e.addEventListener("click", _click));
126
+ for (let n of SUPPORT_LINE_CLAMP) t.modifiers[`ell${n}`] && e.classList.add(`${clsPrefix$1.value}-tooltip-ell${n}`);
127
+ },
128
+ updated(e, t) {
129
+ if (e[Tooltip]) {
130
+ e[Tooltip].binding = t, e[Tooltip].tip = t.value, e.classList.toggle(`${clsPrefix$1.value}-tooltip-host`, t.modifiers.auto || !1);
131
+ for (let n of SUPPORT_LINE_CLAMP) e.classList.toggle(`${clsPrefix$1.value}-tooltip-ell${n}`, t.modifiers[`ell${n}`] || !1);
132
+ t.modifiers.expandable && !e.bindClick ? (e.bindClick = !0, e.addEventListener("click", _click)) : e.bindClick && (e.bindClick = !1, e.removeEventListener("click", _click)), current.value === e && _update();
133
+ }
134
+ },
135
+ beforeUnmount(e) {
136
+ current.value === e && (current.value = void 0), e[Tooltip] && (e.removeEventListener("mouseenter", _mouseenter), e.bindClick = !1, e.removeEventListener("click", _click), e.classList.remove(`${clsPrefix$1.value}-tooltip-host`, `${clsPrefix$1.value}-tooltip-expandable`, `${clsPrefix$1.value}-tooltip-expanded`, ...SUPPORT_LINE_CLAMP.map((e) => `${clsPrefix$1.value}-tooltip-ell${e}`)), delete e[Tooltip]);
137
+ }
138
+ };
139
+ var clsPrefix, isDark, style = /* @__PURE__ */ c([c(({ props: e }) => `:where(${e.bPrefix}spin-host)`, { position: "relative" }), cB("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
+ cE("tip, icon", {
153
+ willChange: "opacity",
154
+ opacity: "0",
155
+ transition: "opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
156
+ }),
157
+ cE("tip:empty", { display: "none" }),
158
+ cM("spining", { backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0.5)" }, [cE("tip, icon", { opacity: "1" })])
159
+ ])]);
160
+ const SpinDirectiveProvider = /* @__PURE__ */ defineComponent({
161
+ name: "SpinDirectiveProvider",
162
+ props: { dark: Boolean },
163
+ setup(t) {
164
+ return clsPrefix = useStyle("-spin-directive", style), isDark = toRef(t, "dark"), () => h(Fragment);
165
+ }
166
+ });
167
+ var Spin = /* @__PURE__ */ Symbol("spin-dir"), updateLoading = (e, { value: t, modifiers: n }) => {
168
+ if (e[Spin].loading.value = !!t, !e[Spin].loading.value) return;
169
+ let r = n.dark || !n.light && isDark.value;
170
+ e[Spin].spinEl.style.setProperty("--host-bg", r ? "0 0 0" : "255 255 255");
171
+ };
172
+ const vSpin = {
173
+ beforeMount(e) {
174
+ if (e.classList.add(`${clsPrefix.value}-spin-host`), e[Spin]) return;
175
+ let t = ref(!1), n = string2dom(`
176
+ <div class="${clsPrefix.value}-spin-directive">
177
+ <svg class="${clsPrefix.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="${clsPrefix.value}-spin-directive__tip"></div>
187
+ </div>
188
+ `.trim()), r, { stop: i, update: a } = useElementIntersectionRect(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 = watch(t, debounce(() => {
196
+ if (t.value) o === void 0 && (clearTimeout(o), o = void 0), a(), e.append(n), requestAnimationFrame(() => {
197
+ t.value && n.classList.add(`${clsPrefix.value}-spin-directive--spining`);
198
+ });
199
+ else {
200
+ n.classList.remove(`${clsPrefix.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[Spin] = {
209
+ loading: t,
210
+ spinEl: n,
211
+ updateTip: () => {
212
+ let t = n.querySelector(`.${clsPrefix.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[Spin] && (updateLoading(e, t), e[Spin].updateTip(), !e[Spin].observer && nextTick().then(() => {
222
+ (e[Spin].observer = new MutationObserver((t) => {
223
+ for (let n of t) if (n.type === "attributes" && n.attributeName === "data-spin-tip") {
224
+ e[Spin].updateTip();
225
+ return;
226
+ }
227
+ })).observe(e, {
228
+ attributes: !0,
229
+ attributeFilter: ["data-spin-tip"]
230
+ });
231
+ }));
232
+ },
233
+ updated(e, t) {
234
+ e[Spin] && updateLoading(e, t);
235
+ },
236
+ beforeUnmount(e) {
237
+ e[Spin] && (e[Spin].loading.value = !1, e[Spin].stop(), e[Spin].observer?.disconnect(), delete e[Spin]);
238
+ }
239
+ };
240
+ export { vTooltip as i, vSpin as n, TooltipDirectiveProvider as r, SpinDirectiveProvider as t };
@@ -0,0 +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 };