@ithinkdt/ui 4.0.0-50 → 4.0.0-501

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,5 @@
1
- import "./use-i18n-Dx7V4KrY.js";
2
- import "./directives-DUuJW647.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-BC8oa62b.js";
5
- export { DataActions, DataCustom, DataFilter, DataForm, DataLocaleInput, DataPagination, DataSelection, DataTable, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios, renderUsers, useDataTableDrag, useLocaleEdit };
1
+ import "./use-i18n-D-AJ8KbA.js";
2
+ import "./directives-Bpfh9AKg.js";
3
+ import "./use-style-mj2B1q0l.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-C-o-dBCE.js";
5
+ export { DataActions, DataCustom, DataDescriptions, DataFilter, DataForm, DataFormActions, DataLocaleInput, DataPagination, DataSelection, DataTable, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios, NStateButton, StateButtonProps, dataFormActionsProps, renderUsers, useDataTableDrag, useLocaleEdit };
@@ -1,11 +1,12 @@
1
- import { g as useStyle, i as cM, n as cB, r as cE, t as c } from "./use-style-DcT-1dj4.js";
1
+ import { g as useStyle, i as cM, n as cB, r as cE, t as c } from "./use-style-mj2B1q0l.js";
2
2
  import { Fragment, createVNode, defineComponent, h, nextTick, reactive, ref, shallowRef, toRef, watch } from "vue";
3
3
  import { promiseTimeout, useEventListener } from "@vueuse/core";
4
4
  import { NTooltip } from "ithinkdt-ui";
5
+ import { nanoid } from "nanoid";
6
+ import { debounce, throttle } from "@ithinkdt/common/fn";
5
7
  import { useElementIntersectionRect } from "@ithinkdt/common/composables";
6
8
  import { string2dom } from "@ithinkdt/common/dom";
7
- import { debounce } from "@ithinkdt/common/fn";
8
- var Tooltip = /* @__PURE__ */ Symbol("tooltip-dir"), current = /* @__PURE__ */ shallowRef(), _update;
9
+ var Tooltip = /* @__PURE__ */ Symbol("tooltip-dir"), current = /* @__PURE__ */ shallowRef(), _update, _current;
9
10
  const TooltipDirectiveProvider = /* @__PURE__ */ defineComponent({
10
11
  name: "TooltipDirectiveProvider",
11
12
  props: { delay: {
@@ -13,69 +14,79 @@ const TooltipDirectiveProvider = /* @__PURE__ */ defineComponent({
13
14
  default: 180
14
15
  } },
15
16
  setup(d) {
16
- let k = shallowRef(), A = reactive({
17
+ let M = shallowRef(), N = reactive({
17
18
  show: !1,
18
19
  tip: void 0,
19
20
  placement: "top",
20
21
  x: 0,
21
22
  y: 0
22
23
  });
23
- return _update = async () => {
24
+ _update = async () => {
24
25
  if (!current.value) return;
25
26
  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) => [
27
+ let P = current.value, F = P?.[Tooltip];
28
+ if (!F) return;
29
+ let I = F.tip;
30
+ M.value = typeof I == "function" ? I : () => I || P.attributes.getNamedItem("title") || P.textContent;
31
+ let { auto: L } = F.binding.modifiers;
32
+ if (!L || P.firstChild.offsetWidth > P.clientWidth || P.firstChild.offsetHeight > P.clientHeight) {
33
+ N.show = !0;
34
+ let d = P.getBoundingClientRect();
35
+ switch (N.placement = Object.keys(F.binding.modifiers).find((d) => [
35
36
  "top",
36
37
  "right",
37
38
  "left",
38
39
  "bottom"
39
- ].find((k) => d.startsWith(k))) ?? "top", A.placement.split("-")[0]) {
40
+ ].find((M) => d.startsWith(M))) ?? "top", N.placement.split("-")[0]) {
40
41
  case "top":
41
- A.x = d.left + d.width / 2, A.y = d.top;
42
+ N.x = d.left + d.width / 2, N.y = d.top;
42
43
  break;
43
44
  case "right":
44
- A.x = d.left + d.width, A.y = d.top + d.height / 2;
45
+ N.x = d.left + d.width, N.y = d.top + d.height / 2;
45
46
  break;
46
47
  case "left":
47
- A.x = d.left, A.y = d.top + d.height / 2;
48
+ N.x = d.left, N.y = d.top + d.height / 2;
48
49
  break;
49
50
  case "bottom":
50
- A.x = d.left + d.width / 2, A.y = d.bottom;
51
+ N.x = d.left + d.width / 2, N.y = d.bottom;
51
52
  break;
52
53
  }
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);
54
+ } else N.show &&= !1;
55
+ };
56
+ let P = `ithinkdt-tooltip-${nanoid()}`, F = throttle((d) => {
57
+ !_current || _current.contains(d) || d.closest(`.${P}`) || (N.show = !1, current.value = void 0);
58
+ }, 100, { leading: !1 });
59
+ return useEventListener("mouseover", (d) => {
60
+ _current = current.value, F(d.target);
57
61
  }, { capture: !0 }), () => createVNode(NTooltip, {
58
62
  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?.()] });
63
+ show: !!current.value && N.show,
64
+ x: N.x,
65
+ y: N.y,
66
+ placement: N.placement,
67
+ internalInheritedEventHandlers: [{
68
+ onMouseenter: () => {
69
+ console.log("111");
70
+ },
71
+ onMouseleave: () => {
72
+ console.log("222");
73
+ }
74
+ }]
75
+ }, { default: () => [createVNode("div", { class: P }, [M.value?.()])] });
65
76
  }
66
77
  });
67
78
  var _listener = (d) => {
68
- current.value = d.target, _update?.();
79
+ _current = void 0, current.value = d.target, _update?.();
69
80
  };
70
81
  const vTooltip = {
71
- mounted(d, k) {
82
+ mounted(d, M) {
72
83
  d[Tooltip] = {
73
- binding: k,
74
- tip: k.value
84
+ binding: M,
85
+ tip: M.value
75
86
  }, d.addEventListener("mouseenter", _listener);
76
87
  },
77
- updated(d, k) {
78
- d[Tooltip].binding = k, d[Tooltip].tip = k.value, _update();
88
+ updated(d, M) {
89
+ d[Tooltip].binding = M, d[Tooltip].tip = M.value, _update();
79
90
  },
80
91
  beforeUnmount(d) {
81
92
  d[Tooltip] && d.removeEventListener("mouseenter", _listener), current.value === d && (current.value = void 0), delete d[Tooltip];
@@ -105,19 +116,19 @@ var clsPrefix, isDark, style = /* @__PURE__ */ c([c(({ props: d }) => `:where(${
105
116
  const SpinDirectiveProvider = /* @__PURE__ */ defineComponent({
106
117
  name: "SpinDirectiveProvider",
107
118
  props: { dark: Boolean },
108
- setup(k) {
109
- return clsPrefix = useStyle("-spin-directive", style), isDark = toRef(k, "dark"), () => h(Fragment);
119
+ setup(M) {
120
+ return clsPrefix = useStyle("-spin-directive", style), isDark = toRef(M, "dark"), () => h(Fragment);
110
121
  }
111
122
  });
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");
123
+ var Spin = /* @__PURE__ */ Symbol("spin-dir"), updateLoading = (d, { value: M, modifiers: N }) => {
124
+ if (d[Spin].loading.value = !!M, !d[Spin].loading.value) return;
125
+ let P = N.dark || !N.light && isDark.value;
126
+ d[Spin].spinEl.style.setProperty("--host-bg", P ? "0 0 0" : "255 255 255");
116
127
  };
117
128
  const vSpin = {
118
129
  beforeMount(d) {
119
130
  if (d.classList.add(`${clsPrefix.value}-spin-host`), d[Spin]) return;
120
- let k = ref(!1), A = string2dom(`
131
+ let M = ref(!1), N = string2dom(`
121
132
  <div class="${clsPrefix.value}-spin-directive">
122
133
  <svg class="${clsPrefix.value}-spin-directive__icon" width="32" height="32" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
123
134
  <g>
@@ -130,42 +141,42 @@ const vSpin = {
130
141
  </svg>
131
142
  <div class="${clsPrefix.value}-spin-directive__tip"></div>
132
143
  </div>
133
- `.trim()), j, { stop: M, update: N } = useElementIntersectionRect(d, (d) => {
134
- j = d, Object.assign(A.style, {
144
+ `.trim()), P, { stop: F, update: I } = useElementIntersectionRect(d, (d) => {
145
+ P = d, Object.assign(N.style, {
135
146
  left: 0,
136
147
  top: 0,
137
- width: j.width + "px",
138
- height: j.height + "px"
148
+ width: P.width + "px",
149
+ height: P.height + "px"
139
150
  });
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`);
151
+ }, { interval: 1e3 / 30 }), L, R = watch(M, debounce(() => {
152
+ if (M.value) L === void 0 && (clearTimeout(L), L = void 0), I(), d.append(N), requestAnimationFrame(() => {
153
+ M.value && N.classList.add(`${clsPrefix.value}-spin-directive--spining`);
143
154
  });
144
155
  else {
145
- A.classList.remove(`${clsPrefix.value}-spin-directive--spining`);
156
+ N.classList.remove(`${clsPrefix.value}-spin-directive--spining`);
146
157
  let d = () => {
147
- A.remove(), k && clearTimeout(k), k = null, A.removeEventListener("transitioncancel", d), A.removeEventListener("transitionend", d);
158
+ N.remove(), M && clearTimeout(M), M = null, N.removeEventListener("transitioncancel", d), N.removeEventListener("transitionend", d);
148
159
  };
149
- A.addEventListener("transitioncancel", d), A.addEventListener("transitionend", d);
150
- let k = setTimeout(d, 300);
160
+ N.addEventListener("transitioncancel", d), N.addEventListener("transitionend", d);
161
+ let M = setTimeout(d, 300);
151
162
  }
152
163
  }, 30));
153
164
  d[Spin] = {
154
- loading: k,
155
- spinEl: A,
165
+ loading: M,
166
+ spinEl: N,
156
167
  updateTip: () => {
157
- let k = A.querySelector(`.${clsPrefix.value}-spin-directive__tip`);
158
- k.textContent = d.dataset.spinTip;
168
+ let M = N.querySelector(`.${clsPrefix.value}-spin-directive__tip`);
169
+ M.textContent = d.dataset.spinTip;
159
170
  },
160
171
  stop: () => {
161
- M(), F();
172
+ F(), R();
162
173
  }
163
174
  };
164
175
  },
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") {
176
+ mounted(d, M) {
177
+ updateLoading(d, M), d[Spin].updateTip(), !d[Spin].observer && nextTick().then(() => {
178
+ (d[Spin].observer = new MutationObserver((M) => {
179
+ for (let N of M) if (N.type === "attributes" && N.attributeName === "data-spin-tip") {
169
180
  d[Spin].updateTip();
170
181
  return;
171
182
  }
@@ -1,3 +1,3 @@
1
- import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-DUuJW647.js";
2
- import "./use-style-DcT-1dj4.js";
1
+ import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-Bpfh9AKg.js";
2
+ import "./use-style-mj2B1q0l.js";
3
3
  export { SpinDirectiveProvider, TooltipDirectiveProvider, vSpin, vTooltip };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { n as useI18n, t as UI_I18N_INJECTION } from "./use-i18n-Dx7V4KrY.js";
2
- import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-DUuJW647.js";
3
- import { g as useStyle, i as cM, n as cB, r as cE, t as c } from "./use-style-DcT-1dj4.js";
1
+ import { n as useI18n, t as UI_I18N_INJECTION } from "./use-i18n-D-AJ8KbA.js";
2
+ import { i as vTooltip, n as vSpin, r as TooltipDirectiveProvider, t as SpinDirectiveProvider } from "./directives-Bpfh9AKg.js";
3
+ import { g as useStyle, i as cM, n as cB, r as cE, t as c } from "./use-style-mj2B1q0l.js";
4
4
  import { Fragment, computed, createVNode, defineComponent, inject, isVNode, mergeProps, provide, reactive, ref, renderSlot, shallowRef, toRef, toValue, unref, useTemplateRef, watch, withDirectives } from "vue";
5
5
  import { computedAsync, promiseTimeout, useElementHover, useElementSize, useEventListener, useFullscreen, watchDebounced } from "@vueuse/core";
6
6
  import { NAvatar, NBadge, NBreadcrumb, NBreadcrumbItem, NButton, NDrawer, NDrawerContent, NDropdown, NEmpty, NIcon, NList, NListItem, NMenu, NPagination, NPopover, NScrollbar, NText, NThing, useThemeVars } from "ithinkdt-ui";
@@ -630,7 +630,7 @@ function useCtxMenu(z, B, V) {
630
630
  {
631
631
  key: "reload",
632
632
  label: H("common.layout.tabs.reloadTab"),
633
- disabled: U.tab && U.tab.key !== B.value,
633
+ disabled: !U.tab || U.tab.key !== B.value,
634
634
  icon: () => createVNode(NIcon, { size: 20 }, { default: () => [createVNode("svg", {
635
635
  xmlns: "http://www.w3.org/2000/svg",
636
636
  "xmlns:xlink": "http://www.w3.org/1999/xlink",
@@ -665,7 +665,7 @@ function useCtxMenu(z, B, V) {
665
665
  {
666
666
  key: "open",
667
667
  label: H("common.layout.tabs.openTabBlank"),
668
- disabled: U.tab?.key !== B.value,
668
+ disabled: !U.tab,
669
669
  icon: () => createVNode(NIcon, { size: 20 }, { default: () => [createVNode("svg", {
670
670
  xmlns: "http://www.w3.org/2000/svg",
671
671
  "xmlns:xlink": "http://www.w3.org/1999/xlink",
@@ -756,19 +756,7 @@ function useCtxMenu(z, B, V) {
756
756
  V();
757
757
  return;
758
758
  }
759
- if (!U.tab) {
760
- let z = H.find((d) => d.key === B.value);
761
- switch (d) {
762
- case "open":
763
- window.open(z.href, "_blank");
764
- break;
765
- case "reload":
766
- z.reloading ||= (z.reloading = !0, await promiseTimeout(220), !1);
767
- break;
768
- }
769
- return;
770
- }
771
- switch (d) {
759
+ if (U.tab) switch (d) {
772
760
  case "open":
773
761
  window.open(U.tab.href, "_blank");
774
762
  break;