@ithinkdt/ui 4.0.0-601 → 4.0.0-800

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,5 +1,2 @@
1
- import "./use-i18n-Dx7V4KrY.js";
2
- import "./use-style-D9hLG26i.js";
3
- import "./directives-8VsgmCuO.js";
4
- 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-CDuTve1u.js";
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-DYFd5z-C.js";
5
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,237 @@
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
+ x: r.x,
107
+ y: r.y,
108
+ placement: r.placement
109
+ }, { default: () => [createVNode("div", { class: i }, [n.value?.()])] });
110
+ }
111
+ });
112
+ var _mouseenter = (e) => {
113
+ _current = void 0, current.value = e.target, _update?.();
114
+ }, _click = (e) => {
115
+ 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());
116
+ };
117
+ const vTooltip = {
118
+ mounted(e, t) {
119
+ e[Tooltip] = {
120
+ binding: t,
121
+ tip: t.value
122
+ }, 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));
123
+ for (let n of SUPPORT_LINE_CLAMP) t.modifiers[`ell${n}`] && e.classList.add(`${clsPrefix$1.value}-tooltip-ell${n}`);
124
+ },
125
+ updated(e, t) {
126
+ if (e[Tooltip]) {
127
+ e[Tooltip].binding = t, e[Tooltip].tip = t.value, e.classList.toggle(`${clsPrefix$1.value}-tooltip-host`, t.modifiers.auto || !1);
128
+ for (let n of SUPPORT_LINE_CLAMP) e.classList.toggle(`${clsPrefix$1.value}-tooltip-ell${n}`, t.modifiers[`ell${n}`] || !1);
129
+ 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();
130
+ }
131
+ },
132
+ beforeUnmount(e) {
133
+ 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]);
134
+ }
135
+ };
136
+ var clsPrefix, isDark, style = /* @__PURE__ */ c([c(({ props: e }) => `:where(${e.bPrefix}spin-host)`, { position: "relative" }), cB("spin-directive", {
137
+ zIndex: "999999",
138
+ position: "absolute",
139
+ color: "var(--color-primary)",
140
+ display: "flex",
141
+ flexDirection: "column",
142
+ justifyContent: "center",
143
+ alignItems: "center",
144
+ gap: "4px",
145
+ willChange: "background-color",
146
+ backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0)",
147
+ transition: "background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
148
+ }, [
149
+ cE("tip, icon", {
150
+ willChange: "opacity",
151
+ opacity: "0",
152
+ transition: "opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
153
+ }),
154
+ cE("tip:empty", { display: "none" }),
155
+ cM("spining", { backgroundColor: "rgb(var(--host-bg, 255 255 255) / 0.5)" }, [cE("tip, icon", { opacity: "1" })])
156
+ ])]);
157
+ const SpinDirectiveProvider = /* @__PURE__ */ defineComponent({
158
+ name: "SpinDirectiveProvider",
159
+ props: { dark: Boolean },
160
+ setup(t) {
161
+ return clsPrefix = useStyle("-spin-directive", style), isDark = toRef(t, "dark"), () => h(Fragment);
162
+ }
163
+ });
164
+ var Spin = /* @__PURE__ */ Symbol("spin-dir"), updateLoading = (e, { value: t, modifiers: n }) => {
165
+ if (e[Spin].loading.value = !!t, !e[Spin].loading.value) return;
166
+ let r = n.dark || !n.light && isDark.value;
167
+ e[Spin].spinEl.style.setProperty("--host-bg", r ? "0 0 0" : "255 255 255");
168
+ };
169
+ const vSpin = {
170
+ beforeMount(e) {
171
+ if (e.classList.add(`${clsPrefix.value}-spin-host`), e[Spin]) return;
172
+ let t = ref(!1), n = string2dom(`
173
+ <div class="${clsPrefix.value}-spin-directive">
174
+ <svg class="${clsPrefix.value}-spin-directive__icon" width="32" height="32" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
175
+ <g>
176
+ <animateTransform attributeName="transform" type="rotate" values="0 100 100;270 100 100" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animateTransform>
177
+ <circle fill="none" stroke="currentColor" stroke-width="18" stroke-linecap="round" cx="100" cy="100" r="92" stroke-dasharray="567" stroke-dashoffset="1848">
178
+ <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>
179
+ <animate attributeName="stroke-dashoffset" values="567;142;567" begin="0s" dur="1.6s" fill="freeze" repeatCount="indefinite"></animate>
180
+ </circle>
181
+ </g>
182
+ </svg>
183
+ <div class="${clsPrefix.value}-spin-directive__tip"></div>
184
+ </div>
185
+ `.trim()), r, { stop: i, update: a } = useElementIntersectionRect(e, (e) => {
186
+ r = e, Object.assign(n.style, {
187
+ left: 0,
188
+ top: 0,
189
+ width: r.width + "px",
190
+ height: r.height + "px"
191
+ });
192
+ }, { interval: 1e3 / 30 }), o, s = watch(t, debounce(() => {
193
+ if (t.value) o === void 0 && (clearTimeout(o), o = void 0), a(), e.append(n), requestAnimationFrame(() => {
194
+ t.value && n.classList.add(`${clsPrefix.value}-spin-directive--spining`);
195
+ });
196
+ else {
197
+ n.classList.remove(`${clsPrefix.value}-spin-directive--spining`);
198
+ let e = () => {
199
+ n.remove(), t && clearTimeout(t), t = null, n.removeEventListener("transitioncancel", e), n.removeEventListener("transitionend", e);
200
+ };
201
+ n.addEventListener("transitioncancel", e), n.addEventListener("transitionend", e);
202
+ let t = setTimeout(e, 300);
203
+ }
204
+ }, 30));
205
+ e[Spin] = {
206
+ loading: t,
207
+ spinEl: n,
208
+ updateTip: () => {
209
+ let t = n.querySelector(`.${clsPrefix.value}-spin-directive__tip`);
210
+ t.textContent = e.dataset.spinTip;
211
+ },
212
+ stop: () => {
213
+ i(), s();
214
+ }
215
+ };
216
+ },
217
+ mounted(e, t) {
218
+ e[Spin] && (updateLoading(e, t), e[Spin].updateTip(), !e[Spin].observer && nextTick().then(() => {
219
+ (e[Spin].observer = new MutationObserver((t) => {
220
+ for (let n of t) if (n.type === "attributes" && n.attributeName === "data-spin-tip") {
221
+ e[Spin].updateTip();
222
+ return;
223
+ }
224
+ })).observe(e, {
225
+ attributes: !0,
226
+ attributeFilter: ["data-spin-tip"]
227
+ });
228
+ }));
229
+ },
230
+ updated(e, t) {
231
+ e[Spin] && updateLoading(e, t);
232
+ },
233
+ beforeUnmount(e) {
234
+ e[Spin] && (e[Spin].loading.value = !1, e[Spin].stop(), e[Spin].observer?.disconnect(), delete e[Spin]);
235
+ }
236
+ };
237
+ export { vTooltip as i, vSpin as n, TooltipDirectiveProvider as r, SpinDirectiveProvider as t };
@@ -1,3 +1,2 @@
1
- import "./use-style-D9hLG26i.js";
2
- import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-8VsgmCuO.js";
1
+ import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-CBQhJ3zJ.js";
3
2
  export { SpinDirectiveProvider, TooltipDirectiveProvider, vSpin, vTooltip };