@ithinkdt/ui 4.0.18 → 4.1.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.
@@ -1,14 +1,14 @@
1
1
  import e, { c as t, cB as n, cE as r, cM as i, useClsPrefix as a } from "./use-style.js";
2
- import { i as o } from "./directives-Chz4DK1u.js";
3
- import { C as s } from "./components-BHfgt7FW.js";
4
- import { computed as c, createVNode as l, defineComponent as u, inject as d, isVNode as f, ref as p, shallowRef as m, toValue as h, useTemplateRef as g, watch as _, withDirectives as v } from "vue";
5
- import { toReactive as y, until as b } from "@vueuse/core";
6
- import { NButton as x, NDataTable as S, NFlex as C, NIcon as w, NTooltip as T, dataTableProps as E } from "ithinkdt-ui";
7
- import { useTableRangeSelect as D } from "@ithinkdt/common/composables";
2
+ import { i as o } from "./directives-G7hy3akL.js";
3
+ import { C as s } from "./components-Gbs1QIjp.js";
4
+ import { t as c } from "./use-table-range-select-BTC3NnsD.js";
5
+ import { computed as l, createVNode as u, defineComponent as d, inject as f, isVNode as p, ref as m, shallowRef as h, toValue as g, useTemplateRef as _, watch as v, withDirectives as y } from "vue";
6
+ import { toReactive as b, until as x } from "@vueuse/core";
7
+ import { NButton as S, NDataTable as C, NFlex as w, NIcon as T, NTooltip as E, dataTableProps as D } from "ithinkdt-ui";
8
8
  import { PAGE_INJECTION as O } from "@ithinkdt/page";
9
9
  //#region src/components/DataTable.jsx
10
10
  function k(e) {
11
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
11
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !p(e);
12
12
  }
13
13
  function A(e, t) {
14
14
  return (e ?? []).map((e) => {
@@ -16,23 +16,23 @@ function A(e, t) {
16
16
  csvTitle: e.exportTitle,
17
17
  ...e,
18
18
  title: () => {
19
- let t = h(e.title), n = t && v(l("div", null, [t]), [[
19
+ let t = g(e.title), n = t && y(u("div", null, [t]), [[
20
20
  o,
21
- () => h(e.title),
21
+ () => g(e.title),
22
22
  void 0,
23
23
  { auto: !0 }
24
24
  ]]);
25
- return e.tooltip ? l(C, {
25
+ return e.tooltip ? u(w, {
26
26
  size: 3,
27
27
  wrap: !1,
28
28
  inline: !0,
29
29
  style: "max-width: 100%"
30
- }, { default: () => [n, l(T, null, {
31
- default: h(e.tooltip),
32
- trigger: () => l(x, {
30
+ }, { default: () => [n, u(E, null, {
31
+ default: g(e.tooltip),
32
+ trigger: () => u(S, {
33
33
  text: !0,
34
34
  style: "font-size: 1.25em; opacity: 0.8"
35
- }, { default: () => [l(w, null, { default: () => [l(s, null, null)] })] })
35
+ }, { default: () => [u(T, null, { default: () => [u(s, null, null)] })] })
36
36
  })] }) : n;
37
37
  }
38
38
  };
@@ -42,9 +42,9 @@ function A(e, t) {
42
42
  let r = e.render ?? ((e) => e);
43
43
  e.ellipsis !== !1 && (n.ellipsis = !1, n.render = (...t) => {
44
44
  let n = r(...t);
45
- return n && (f(n) || ((function() {
45
+ return n && (p(n) || ((function() {
46
46
  return n;
47
- })(), n = l("span", null, [n])), v(n, [[
47
+ })(), n = u("span", null, [n])), y(n, [[
48
48
  o,
49
49
  () => e.ellipsisTooltip ? e.ellipsisTooltip(...t) : n,
50
50
  void 0,
@@ -64,7 +64,7 @@ function A(e, t) {
64
64
  return n.key === "$actions" && (n.cellProps ??= () => ({ style: { padding: "0 2px" } })), n;
65
65
  }).filter((e) => e?.hidden !== !0);
66
66
  }
67
- var j = /* @__PURE__ */ u({
67
+ var j = /* @__PURE__ */ d({
68
68
  name: "DataTable",
69
69
  props: {
70
70
  data: {
@@ -99,8 +99,8 @@ var j = /* @__PURE__ */ u({
99
99
  type: String,
100
100
  default: "normal"
101
101
  },
102
- rowClassName: E.rowClassName,
103
- rowProps: E.rowProps,
102
+ rowClassName: D.rowClassName,
103
+ rowProps: D.rowProps,
104
104
  maxHeight: [String, Number]
105
105
  },
106
106
  emits: [
@@ -110,58 +110,58 @@ var j = /* @__PURE__ */ u({
110
110
  "highlight"
111
111
  ],
112
112
  setup(t, { slots: n, emit: r, expose: i }) {
113
- let { keyField: o } = d(O), s = a(), u = `${s.value}-datatable`;
113
+ let { keyField: o } = f(O), s = a(), d = `${s.value}-datatable`;
114
114
  e("-datatable", M, s);
115
- let f = g("table-ref"), h = ({ sortField: e, sortOrder: t } = {}, n) => {
116
- e == n?.sortField && t == n?.sortOrder || f.value?.sort(e, t ? t + "end" : !1);
115
+ let p = _("table-ref"), g = ({ sortField: e, sortOrder: t } = {}, n) => {
116
+ e == n?.sortField && t == n?.sortOrder || p.value?.sort(e, t ? t + "end" : !1);
117
117
  };
118
- _(() => ({ ...t.sorter }), h, { deep: !0 });
119
- let v = c(() => {
118
+ v(() => ({ ...t.sorter }), g, { deep: !0 });
119
+ let y = l(() => {
120
120
  let e = t.keyField || o || "key";
121
121
  return (t) => t[e];
122
- }), x = m({
122
+ }), S = h({
123
123
  cache: [],
124
124
  scrollToView(...e) {
125
- this.cache.push(e);
125
+ S.value.cache.push(e);
126
126
  }
127
127
  });
128
- b(f).changed().then(() => {
129
- h(t.sorter);
130
- let e = x.value.cache;
131
- x.value = f.value, x.value.scrollToView = (e) => {
132
- let n = t.data.findIndex((t) => v.value(t) === e);
128
+ x(p).changed().then(() => {
129
+ g(t.sorter);
130
+ let e = S.value.cache;
131
+ S.value = p.value, S.value.scrollToView = (e) => {
132
+ let n = t.data.findIndex((t) => y.value(t) === e);
133
133
  if (n === -1) return;
134
- let r = f.value.$el.querySelector(`.${u}__row-marker:nth-child(${n + 1})`);
135
- f.value.scrollTo({
134
+ let r = p.value.$el.querySelector(`.${d}__row-marker:nth-child(${n + 1})`);
135
+ p.value.scrollTo({
136
136
  top: r.offsetTop,
137
137
  behavior: "smooth"
138
138
  });
139
139
  };
140
- for (let t of e) x.value.scrollToView(...t);
141
- }), i(y(x));
142
- let C = p(0), w = m([]);
143
- _(() => t.columns, () => {
144
- C.value = 0, w.value = A(t.columns, C);
140
+ for (let t of e) S.value.scrollToView(...t);
141
+ }), i(b(S));
142
+ let w = m(0), T = h([]);
143
+ v(() => t.columns, () => {
144
+ w.value = 0, T.value = A(t.columns, w);
145
145
  }, {
146
146
  immediate: !0,
147
147
  deep: 2
148
148
  });
149
- let T = p();
150
- _(() => t.highlight, (e) => {
151
- T.value = typeof e == "boolean" ? null : e ?? null;
149
+ let E = m();
150
+ v(() => t.highlight, (e) => {
151
+ E.value = typeof e == "boolean" ? null : e ?? null;
152
152
  }, { immediate: !0 });
153
- let E = c(() => (e, n) => [
153
+ let D = l(() => (e, n) => [
154
154
  t.rowClassName?.(e, n) || "",
155
- `${u}__row-marker`,
156
- T.value != null && v.value(e) === T.value ? `${u}__row-highlight` : ""
157
- ].join(" ")), j = c(() => (e, n) => {
155
+ `${d}__row-marker`,
156
+ E.value != null && y.value(e) === E.value ? `${d}__row-highlight` : ""
157
+ ].join(" ")), j = l(() => (e, n) => {
158
158
  let i = t.rowProps?.(e, n);
159
159
  return {
160
160
  ...i,
161
- "data-row-key": v.value(e),
161
+ "data-row-key": y.value(e),
162
162
  onClick: (n) => {
163
- let a = v.value(e);
164
- t.highlight === !0 && (T.value = a), r("highlight", a), i?.onClick?.(n);
163
+ let a = y.value(e);
164
+ t.highlight === !0 && (E.value = a), r("highlight", a), i?.onClick?.(n);
165
165
  }
166
166
  };
167
167
  }), N = (e) => {
@@ -180,25 +180,25 @@ var j = /* @__PURE__ */ u({
180
180
  key: n.key,
181
181
  width: e
182
182
  });
183
- }, { range: I, pause: L, resume: R } = D(f, {
183
+ }, { range: I, pause: L, resume: R } = c(p, {
184
184
  immediate: t.rangeSelect,
185
- clsPrefix: c(() => `${s.value}-`)
185
+ clsPrefix: l(() => `${s.value}-`)
186
186
  });
187
- return _(() => t.rangeSelect, (e) => {
187
+ return v(() => t.rangeSelect, (e) => {
188
188
  e ? R() : L();
189
- }), () => l(S, {
189
+ }), () => u(C, {
190
190
  ref: "table-ref",
191
191
  class: [
192
- u,
193
- t.appear === "sticky" ? `${u}--sticky` : "",
194
- I.value?.ing ? `${u}--cell-selecting` : ""
192
+ d,
193
+ t.appear === "sticky" ? `${d}--sticky` : "",
194
+ I.value?.ing ? `${d}--cell-selecting` : ""
195
195
  ],
196
196
  data: t.data,
197
- columns: w.value,
198
- rowKey: v.value,
197
+ columns: T.value,
198
+ rowKey: y.value,
199
199
  tableLayout: "fixed",
200
- scrollX: C.value,
201
- rowClassName: E.value,
200
+ scrollX: w.value,
201
+ rowClassName: D.value,
202
202
  rowProps: j.value,
203
203
  checkedRowKeys: t.selectedKeys,
204
204
  style: { "--n-tr-highlight-color": t.highlightColor },
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./use-i18n-BUP_StIp.js";
2
2
  import t, { cB as n, cE as r, useClsPrefix as i } from "./use-style.js";
3
- import { i as a } from "./directives-Chz4DK1u.js";
3
+ import { i as a } from "./directives-G7hy3akL.js";
4
4
  import { Fragment as o, computed as s, createTextVNode as c, createVNode as l, defineAsyncComponent as u, defineComponent as d, h as f, inject as p, isVNode as m, markRaw as h, mergeProps as g, nextTick as _, onBeforeUnmount as v, reactive as y, ref as b, renderSlot as x, shallowRef as S, toRaw as C, toRef as w, toValue as T, unref as E, useTemplateRef as D, watch as O, withDirectives as k } from "vue";
5
5
  import { onClickOutside as A, until as j, useElementHover as M, useFullscreen as N } from "@vueuse/core";
6
6
  import { NAnchor as P, NAnchorLink as F, NAvatar as I, NAvatarGroup as ee, NBadge as te, NButton as L, NCard as ne, NCheckbox as R, NCheckboxGroup as re, NDropdown as ie, NEllipsis as ae, NEmpty as oe, NFlex as z, NForm as se, NFormItem as ce, NGi as le, NGrid as ue, NIcon as B, NInput as V, NList as de, NListItem as fe, NPagination as pe, NPopover as H, NRadio as me, NRadioButton as he, NRadioGroup as ge, NScrollbar as _e, NSelect as ve, NSpin as ye, NTag as be, NText as xe, NTooltip as Se, NTransfer as Ce, NTree as we, NTreeSelect as Te, formProps as U, useDialog as Ee } from "ithinkdt-ui";
@@ -1175,7 +1175,7 @@ var bt = /* @__PURE__ */ d({
1175
1175
  size: "20",
1176
1176
  depth: "3"
1177
1177
  }, { default: () => [o.value ? l(Qe, null, null) : l(Ze, null, null)] })] }), u = (t) => {
1178
- let n = t.split("-")[0];
1178
+ let n = t.split("-", 1)[0];
1179
1179
  return e.supports.some((e) => e.value !== t && e.value.startsWith(n)) ? t : n;
1180
1180
  }, d = `__slots${De(6)}`;
1181
1181
  O(() => e.supports, (e) => {
@@ -1947,12 +1947,8 @@ var jt = /* @__PURE__ */ d({
1947
1947
  disabled: t.disabled || void 0,
1948
1948
  value: r,
1949
1949
  filter: (e, t) => t.label.includes(e) || t.value.includes(e),
1950
- "onUpdate:value": (e) => {
1951
- i?.(e);
1952
- },
1953
- onUpdateValue: (e) => {
1954
- a?.(e);
1955
- }
1950
+ "onUpdate:value": i,
1951
+ onUpdateValue: a
1956
1952
  }), null), k = ({ option: e, handleClose: n }) => l(be, {
1957
1953
  type: t.type === "user" ? "primary" : "info",
1958
1954
  closable: !0,
@@ -1970,7 +1966,7 @@ var jt = /* @__PURE__ */ d({
1970
1966
  showIcon: !1,
1971
1967
  title: t.placeholder,
1972
1968
  style: { width: "700px" },
1973
- content: () => l("div", { style: { height: "550px" } }, [D({ style: { height: "100%" } }, t.type === "user" ? f.value : p.value, e.value, (t) => e.value = t)]),
1969
+ content: () => l("div", { style: { height: "550px" } }, [D({ style: { height: "100%" } }, t.type === "user" ? f.value : p.value, e.value, (t) => e.value = t, void 0)]),
1974
1970
  positiveText: a.value.positiveText,
1975
1971
  negativeText: a.value.negativeText,
1976
1972
  onPositiveClick() {
@@ -2027,7 +2023,7 @@ var jt = /* @__PURE__ */ d({
2027
2023
  });
2028
2024
  function Q(e, t, { placement: n = "left", size: r = 24, tooltip: i = !0, username: a = !1, renderInfo: o }) {
2029
2025
  let s = e.nickname.split(" ").at(-1), c = s;
2030
- if (/^[\u4E00-\u9FA5]+$/.test(s)) {
2026
+ if (/^[\u{4E00}-\u{9FA5}]+$/u.test(s)) {
2031
2027
  let e = s.length;
2032
2028
  c = e === 3 || e === 4 ? s.slice(-2) : e > 4 ? s.slice(0, 1) : s;
2033
2029
  } else s.length > 4 && (c = l(B, null, { default: () => [l(nt, null, null)] }));
@@ -2162,6 +2158,6 @@ var Mt = /* @__PURE__ */ d({
2162
2158
  });
2163
2159
  };
2164
2160
  }
2165
- }), It = u(() => import("./DataTable-CMFYAmRF.js").then((e) => e.DataTable));
2161
+ }), It = u(() => import("./DataTable-BVifHuTW.js").then((e) => e.DataTable));
2166
2162
  //#endregion
2167
2163
  export { Re as C, ot as S, gt as _, jt as a, pt as b, At as c, Tt as d, Ct as f, _t as g, yt as h, Mt as i, Ot as l, bt as m, Ft as n, Nt as o, X as p, Pt as r, $ as s, It as t, Et as u, Y as v, Le as w, ct as x, J as y };
package/esm/components.js CHANGED
@@ -1,2 +1,2 @@
1
- import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, w as b, x, y as S } from "./components-BHfgt7FW.js";
1
+ import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, w as b, x, y as S } from "./components-Gbs1QIjp.js";
2
2
  export { e as DataActions, x as DataCustom, r as DataDescriptions, s as DataFilter, t as DataForm, y as DataFormActions, d as DataLocaleInput, m as DataPagination, a as DataSelection, _ as DataTable, l as DtDeptRender, n as DtUserDept, p as DtUserRender, v as FullscreenButton, u as FullscreenWrapper, b as NCheckboxes, i as NRadios, f as NStateButton, h as StateButtonProps, o as ViewProfile, S as dataFormActionsProps, g as renderUsers, c as useLocaleEdit };
@@ -1,10 +1,150 @@
1
+ import { MaybeComputedElementRef, Pausable } from '@vueuse/core'
1
2
  import Sortable from 'sortablejs'
2
- import { MaybeRef, TemplateRef } from 'vue'
3
+ import { InjectionKey, MaybeRef, ShallowRef, TemplateRef } from 'vue'
3
4
 
4
5
  export declare function useDataTableDrag<T>(
5
6
  tableRef: TemplateRef<HTMLElement>,
6
- { data, onSort, ...options }: {
7
+ options: Omit<Sortable.Options, 'onSort'> & {
7
8
  data: MaybeRef<T[]>
8
9
  onSort: (info: { from: number, to: number }) => void
9
- } & Omit<Sortable.Options, 'onSort'>,
10
+ },
10
11
  ): void
12
+
13
+ /**
14
+ * options for {@link useTableRangeSelect}
15
+ */
16
+ export interface UseTableRangeSelectOptions {
17
+ /**
18
+ * 是否立即启用,默认值从 vue 依赖注入获取
19
+ */
20
+ immediate?: boolean
21
+ /**
22
+ * 是否复制到剪贴板,默认值从 vue 依赖注入获取
23
+ */
24
+ toClipboard?: MaybeRef<boolean | 'onCopy' | undefined>
25
+
26
+ /**
27
+ * 获取单元格内容,默认值从 vue 依赖注入获取
28
+ *
29
+ * @param cell - 单元格
30
+ * @returns 单元格内容
31
+ */
32
+ getCellContent?: (cell: HTMLTableCellElement) => string
33
+
34
+ /**
35
+ * 类名前缀
36
+ * @defaultValue ''
37
+ */
38
+ clsPrefix?: MaybeRef<string | undefined>
39
+
40
+ /**
41
+ * 鼠标按下回调
42
+ * @param event - 鼠标事件
43
+ * @returns false 阻止选择
44
+ */
45
+ onMousedown?: (event: MouseEvent, data: { tr: HTMLTableRowElement, td: HTMLTableCellElement, tbody: HTMLTableSectionElement }) => void | false
46
+
47
+ /**
48
+ * 选中回调
49
+ * @param data - 选中范围数据
50
+ * @returns 是否继续复制到剪贴板(toClipboard 为 'auto')
51
+ */
52
+ onSelect?: (data: {
53
+ /**
54
+ * 选中范围的起始行
55
+ */
56
+ fromRow: number
57
+ /**
58
+ * 选中范围的起始列
59
+ */
60
+ fromCol: number
61
+ /**
62
+ * 选中范围的结束行
63
+ */
64
+ toRow: number
65
+ /**
66
+ * 选中范围的结束列
67
+ */
68
+ toCol: number
69
+ /**
70
+ * 获取选中范围的单元格内容
71
+ */
72
+ getContent: () => string[][]
73
+ /**
74
+ * tbody 元素
75
+ */
76
+ tbody: HTMLTableSectionElement
77
+ }) => void | false
78
+ }
79
+
80
+ export interface UseTableRangeSelectDefaultOptions {
81
+ /**
82
+ * 是否立即启用
83
+ * @defaultValue true
84
+ */
85
+ immediate?: MaybeRef<boolean>
86
+
87
+ /**
88
+ * 是否复制到剪贴板
89
+ * @defaultValue 'onCopy'
90
+ */
91
+ toClipboard?: MaybeRef<'auto' | 'onCopy' | false>
92
+
93
+ /**
94
+ * 获取单元格内容
95
+ * @defaultValue cell =&gt; cell.textContent
96
+ *
97
+ * @param cell - 单元格
98
+ * @returns 单元格内容
99
+ */
100
+ getCellContent?: (cell: HTMLTableCellElement) => string
101
+
102
+ /**
103
+ * 默认类名前缀
104
+ * @defaultValue ''
105
+ */
106
+ clsPrefix?: MaybeRef<string>
107
+ }
108
+
109
+ type UseTableRangeSelectFn = ((target: MaybeComputedElementRef, options?: UseTableRangeSelectOptions) => Pausable & {
110
+ range: Readonly<ShallowRef<{
111
+ /**
112
+ * 是否正在选择中
113
+ */
114
+ ing: boolean
115
+ /**
116
+ * 是否按下鼠标
117
+ */
118
+ mousedown: boolean
119
+ /**
120
+ * 选中范围的起始列
121
+ */
122
+ x0: number
123
+ /**
124
+ * 选中范围的起始行
125
+ */
126
+ y0: number
127
+ /**
128
+ * 选中范围的结束列
129
+ */
130
+ x1: number
131
+ /**
132
+ * 选中范围的结束行
133
+ */
134
+ y1: number
135
+ }>>
136
+ }) & {
137
+ /**
138
+ * 默认选项从 vue 注入 Key
139
+ */
140
+ DEFAULT_OPTIONS: InjectionKey<UseTableRangeSelectDefaultOptions>
141
+ }
142
+
143
+ /**
144
+ * 使用表格范围选择
145
+ * - vue-composable
146
+ *
147
+ * @param target - 目标元素
148
+ * @param options - 配置
149
+ */
150
+ export declare const useTableRangeSelect: UseTableRangeSelectFn & {}
@@ -1,14 +1,15 @@
1
- import { nextTick as e, ref as t, watch as n } from "vue";
2
- import { unrefElement as r } from "@vueuse/core";
3
- import { Sortable as i } from "sortablejs";
1
+ import { t as e } from "./use-table-range-select-BTC3NnsD.js";
2
+ import { nextTick as t, ref as n, watch as r } from "vue";
3
+ import { unrefElement as i } from "@vueuse/core";
4
+ import { Sortable as a } from "sortablejs";
4
5
  //#region src/composables/use-data-table-drag.js
5
- function a(a, { data: o, onSort: s, ...c }) {
6
- n([t(o), a], async ([t, n]) => {
7
- if (t.length === 0) return;
8
- await e();
9
- let a = r(n)?.querySelector(".n-data-table-base-table-body .n-data-table-tbody");
10
- if (!a) return;
11
- let o = i.create(a, {
6
+ function o(e, { data: o, onSort: s, ...c }) {
7
+ r([n(o), e], async ([e, n]) => {
8
+ if (e.length === 0) return;
9
+ await t();
10
+ let r = i(n)?.querySelector(":scope .n-data-table-base-table-body .n-data-table-tbody");
11
+ if (!r) return;
12
+ let o = a.create(r, {
12
13
  animation: 150,
13
14
  ...c,
14
15
  onSort(e) {
@@ -24,4 +25,4 @@ function a(a, { data: o, onSort: s, ...c }) {
24
25
  }, { immediate: !0 });
25
26
  }
26
27
  //#endregion
27
- export { a as useDataTableDrag };
28
+ export { o as useDataTableDrag, e as useTableRangeSelect };
@@ -83,7 +83,7 @@ var O, k, A, j = /* @__PURE__ */ s({
83
83
  "right",
84
84
  "left",
85
85
  "bottom"
86
- ].find((t) => e.startsWith(t))) ?? "top", r.placement.split("-")[0]) {
86
+ ].find((t) => e.startsWith(t))) ?? "top", r.placement.split("-", 1)[0]) {
87
87
  case "top":
88
88
  r.x = t.left + t.width / 2, r.y = t.top;
89
89
  break;
package/esm/directives.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as e, n as t, r as n, t as r } from "./directives-Chz4DK1u.js";
1
+ import { i as e, n as t, r as n, t as r } from "./directives-G7hy3akL.js";
2
2
  export { r as SpinDirectiveProvider, n as TooltipDirectiveProvider, t as vSpin, e as vTooltip };
package/esm/index.d.ts CHANGED
@@ -4,11 +4,11 @@ import { I18nComposable, ParseMessage } from '@ithinkdt/common/i18n'
4
4
 
5
5
  import { UILocale } from '../locale.js'
6
6
 
7
+ export { UILocale } from '../locale.js'
8
+
7
9
  export * from './directives.js'
8
10
  export * from './design.js'
9
11
 
10
- export { UILocale }
11
-
12
12
  /** Props for {@link UIProvider} */
13
13
  export interface UIProviderProps {
14
14
  i18n?: I18nComposable<ParseMessage<UILocale, 'common'>>
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as e, t } from "./use-i18n-BUP_StIp.js";
2
2
  import n, { c as r, cB as i, cE as a, cM as o } from "./use-style.js";
3
- import { i as s, n as c, r as l, t as u } from "./directives-Chz4DK1u.js";
3
+ import { i as s, n as c, r as l, t as u } from "./directives-G7hy3akL.js";
4
4
  import { Fragment as d, computed as f, createVNode as p, defineComponent as m, inject as h, isVNode as g, mergeProps as _, provide as v, reactive as y, ref as b, renderSlot as x, shallowRef as S, toRef as C, toValue as w, unref as T, useTemplateRef as E, watch as D, withDirectives as O } from "vue";
5
5
  import { computedAsync as ee, promiseTimeout as k, useElementHover as A, useElementSize as te, useEventListener as ne, watchDebounced as re } from "@vueuse/core";
6
6
  import { NAvatar as j, NBadge as ie, NBreadcrumb as ae, NBreadcrumbItem as oe, NButton as M, NDrawer as se, NDrawerContent as ce, NDropdown as N, NEmpty as le, NIcon as P, NInput as F, NList as I, NListItem as L, NMenu as R, NPagination as z, NPopover as B, NScrollbar as V, NText as H, NThing as U, useThemeVars as W } from "ithinkdt-ui";
@@ -32,7 +32,7 @@ var _e = /* @__PURE__ */ m({
32
32
  },
33
33
  emit: ["logout", "change-pwd"],
34
34
  setup(t, { emit: n, slots: r }) {
35
- let i = f(() => /^[\u4E00-\u9FA5]+$/.test(t.nickname) ? t.nickname?.slice(t.nickname?.length > 3 ? 2 : 1) : t.nickname?.split(" ")[0]), { t: a } = e(), o = p(P, { size: "28" }, { default: () => [p("svg", {
35
+ let i = f(() => /^[\u{4E00}-\u{9FA5}]+$/u.test(t.nickname) ? t.nickname?.slice(t.nickname?.length > 3 ? 2 : 1) : t.nickname?.split(" ", 1)[0]), { t: a } = e(), o = p(P, { size: "28" }, { default: () => [p("svg", {
36
36
  xmlns: "http://www.w3.org/2000/svg",
37
37
  width: "1em",
38
38
  height: "1em",
package/esm/page.d.ts CHANGED
@@ -71,7 +71,7 @@ declare module '@ithinkdt/page' {
71
71
  }
72
72
 
73
73
  file: {
74
- fileProps?: ShallowMaybeRef<{
74
+ fileProps?: ShallowMaybeRef<PublicProps & {
75
75
  type?: 'file' | 'image' | undefined
76
76
  multiple?: boolean | undefined
77
77
  max?: number | undefined
@@ -79,13 +79,13 @@ declare module '@ithinkdt/page' {
79
79
  /** 最大文件大小(单位:KB) */
80
80
  maxSize?: number | undefined
81
81
  onBeforeUpload?: UploadProps['onBeforeUpload']
82
- } & PublicProps>
82
+ }>
83
83
  fileSlots?: {
84
84
  default?: (() => VNode[]) | undefined
85
85
  }
86
86
  }
87
87
  upload: {
88
- uploadProps?: ShallowMaybeRef<{
88
+ uploadProps?: ShallowMaybeRef<PublicProps & {
89
89
  type?: 'file' | 'image' | undefined
90
90
  multiple?: boolean | undefined
91
91
  max?: number | undefined
@@ -94,7 +94,7 @@ declare module '@ithinkdt/page' {
94
94
  maxSize?: number | undefined
95
95
  onBeforeUpload?: UploadProps['onBeforeUpload']
96
96
  defaultUpload?: boolean | undefined
97
- } & PublicProps>
97
+ }>
98
98
  uploadSlots?: {
99
99
  default?: (() => VNode[]) | undefined
100
100
  }
package/esm/page.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as e } from "./use-i18n-BUP_StIp.js";
2
- import { _ as t, a as n, c as r, i, o as a, w as o } from "./components-BHfgt7FW.js";
2
+ import { _ as t, a as n, c as r, i, o as a, w as o } from "./components-Gbs1QIjp.js";
3
3
  import { computed as s, createVNode as c, defineAsyncComponent as l, defineComponent as u, h as d, isVNode as f, mergeProps as p, nextTick as m, ref as h, renderSlot as g, shallowRef as _, toValue as v, unref as y } from "vue";
4
4
  import { until as b, useClipboard as x } from "@vueuse/core";
5
5
  import { NButton as S, NCheckbox as C, NColorPicker as w, NDrawer as T, NDrawerContent as E, NFlex as D, NIcon as O, NInput as k, NInputNumber as A, NModal as j, NScrollbar as M, NSelect as N, NText as P, NUpload as F, useMessage as I } from "ithinkdt-ui";
@@ -112,7 +112,7 @@ function K({ getDeptsByCode: e, getUsersByUsername: t, getFileInfos: n, previewF
112
112
  if (r == null) return;
113
113
  let { dictType: o, options: l, multiple: u, statusMap: d } = W(a);
114
114
  if (l ? t !== l && (t = l, n = new Map(l.map((e) => [e[a.valueField || "value"], e]))) : e !== o && (e = o, !n && e && (n = U(e))), !u) {
115
- if (r = r.toString(), d && r in d) {
115
+ if (r = r.toString(), d && Object.hasOwn(d, r)) {
116
116
  let e = d[r] ?? "default";
117
117
  return [
118
118
  "primary",
@@ -339,8 +339,15 @@ function X({ getUserGroups: e, getUsersByGroup: t, getDeptsByCode: i, getUsersBy
339
339
  O("");
340
340
  }, k()) : (n = void 0, t = C) : (n = void 0, e !== b && (e = b, !t && e && (t = H(e))));
341
341
  let A = T.multiple ? l?.map(E) : E(l);
342
- if (g) if (T.multiple) {
342
+ if (g) {
343
343
  let e;
344
+ if (!T.multiple) {
345
+ let e = y(t)?.find((e) => e[T.valueField || "value"] === A);
346
+ return c(P, {
347
+ depth: 2,
348
+ style: "line-height: 1.25"
349
+ }, { default: () => [e ? T.renderLabel ? T.renderLabel(e) ?? "" : e[T.labelField || "label"] ?? "" : A ?? ""] });
350
+ }
344
351
  return c(P, {
345
352
  depth: 2,
346
353
  style: "line-height: 1.25"
@@ -348,12 +355,6 @@ function X({ getUserGroups: e, getUsersByGroup: t, getDeptsByCode: i, getUsersBy
348
355
  let r = e ? T.renderLabel ? T.renderLabel(e) ?? "" : e[T.labelField || "label"] ?? "" : A[t] ?? "";
349
356
  return c("span", { key: e ? e[T.valueField || "value"] : A[t] ?? "" }, [r, t < n.length - 1 ? ", " : ""]);
350
357
  })) ? e : { default: () => [e] });
351
- } else {
352
- let e = y(t)?.find((e) => e[T.valueField || "value"] === A);
353
- return c(P, {
354
- depth: 2,
355
- style: "line-height: 1.25"
356
- }, { default: () => [e ? T.renderLabel ? T.renderLabel(e) ?? "" : e[T.labelField || "label"] ?? "" : A ?? ""] });
357
358
  }
358
359
  return r = T.multiple, i = u, w === "number" && !a && (a = (e, ...t) => {
359
360
  i(r ? e?.map(S) : S(e), ...t);
package/esm/use-style.js CHANGED
@@ -1,31 +1,31 @@
1
- import { useMergedClsPrefix as e } from "ithinkdt-ui/es/_mixins/use-config";
2
- import t from "ithinkdt-ui/es/_mixins/use-style";
3
- import { c as n, cB as r, cE as i, cM as a } from "ithinkdt-ui/es/_utils/cssr/index";
1
+ import { useMergedClsPrefix as e, useMergedClsPrefix as t } from "ithinkdt-ui/es/_mixins/use-config";
2
+ import n from "ithinkdt-ui/es/_mixins/use-style";
3
+ import { c as r, cB as i, cE as a, cM as o } from "ithinkdt-ui/es/_utils/cssr/index";
4
4
  //#region src/use-style.js
5
- function o(n, r, i, a) {
6
- return i ??= e(), t(n, r, i, a), i;
5
+ function s(t, r, i, a) {
6
+ return i ??= e(), n(t, r, i, a), i;
7
7
  }
8
- var s = { width: "100%" }, c = { height: "100%" }, l = {
9
- ...s,
10
- ...c
11
- }, u = { display: "flex" }, d = {
12
- ...u,
8
+ var c = { width: "100%" }, l = { height: "100%" }, u = {
9
+ ...c,
10
+ ...l
11
+ }, d = { display: "flex" }, f = {
12
+ ...d,
13
13
  flexDirection: "column"
14
- }, f = {
15
- ...u,
16
- alignItems: "center"
17
14
  }, p = {
18
- ...u,
19
- justifyContent: "center"
15
+ ...d,
16
+ alignItems: "center"
20
17
  }, m = {
21
- ...u,
22
- justifyContent: "space-between"
18
+ ...d,
19
+ justifyContent: "center"
23
20
  }, h = {
24
- ...f,
25
- ...p
26
- }, g = (e) => ({
27
- ...u,
21
+ ...d,
22
+ justifyContent: "space-between"
23
+ }, g = {
24
+ ...p,
25
+ ...m
26
+ }, _ = (e) => ({
27
+ ...d,
28
28
  gap: e
29
29
  });
30
30
  //#endregion
31
- export { n as c, r as cB, i as cE, a as cM, o as default, u as flex, f as flexAlignCenter, h as flexCenter, d as flexDirCol, g as flexGap, p as flexJustifyCenter, m as flexJustifySB, c as fullHeight, l as fullWH, s as fullWidth, e as useClsPrefix };
31
+ export { r as c, i as cB, a as cE, o as cM, s as default, d as flex, p as flexAlignCenter, g as flexCenter, f as flexDirCol, _ as flexGap, m as flexJustifyCenter, h as flexJustifySB, l as fullHeight, u as fullWH, c as fullWidth, t as useClsPrefix };
@@ -0,0 +1,111 @@
1
+ import { computed as e, inject as t, readonly as n, ref as r, shallowRef as i, unref as a, watch as o } from "vue";
2
+ import { onClickOutside as s, unrefElement as c, useClipboard as l, useEventListener as u } from "@vueuse/core";
3
+ import { isNullish as d } from "@ithinkdt/common/object";
4
+ //#region src/composables/use-table-range-select.js
5
+ var f = Symbol();
6
+ function p(p, m = {}) {
7
+ let h = i(), g = e(() => c(p)), _ = t(f, {}), v = e(() => a(m.clsPrefix) ?? a(_.clsPrefix) ?? ""), y = e(() => a(m.toClipboard) ?? a(_.toClipboard) ?? "onCopy"), b = m.getCellContent ?? _.getCellContent ?? ((e) => e.textContent), x = r(a(m.immediate) ?? a(_.immediate) ?? !0);
8
+ u(g, "mousedown", (e) => {
9
+ if (h.value &&= void 0, !x.value) return;
10
+ let t = e.target.closest("td"), n = t?.closest("tr"), r = n?.closest("tbody");
11
+ !t || !n || !r || m?.onMousedown?.(e, {
12
+ tr: n,
13
+ td: t,
14
+ tbody: r
15
+ }) === !1 || (h.value = {
16
+ ing: !1,
17
+ mousedown: !0,
18
+ x0: t.cellIndex,
19
+ y0: n.rowIndex
20
+ });
21
+ }, {
22
+ passive: !0,
23
+ capture: !0
24
+ }), u(g, "mousemove", (e) => {
25
+ if (!x.value || !h.value?.mousedown) return;
26
+ let t = e.target.closest("td"), n = t?.closest("tr"), r = n?.closest("tbody");
27
+ !t || !n || !r || !h.value.x1 && t.cellIndex === h.value.x0 && n.rowIndex === h.value.y0 || (h.value = {
28
+ ...h.value,
29
+ ing: !0,
30
+ x1: t.cellIndex,
31
+ y1: n.rowIndex
32
+ }, "getSelection" in globalThis ? getSelection().removeAllRanges() : document.selection && document.selection.empty());
33
+ }, {
34
+ passive: !0,
35
+ capture: !0
36
+ });
37
+ let { copy: S } = l({ legacy: !0 });
38
+ u("mouseup", () => {
39
+ if (!x.value || !h.value) return;
40
+ h.value = {
41
+ ...h.value,
42
+ ing: !1,
43
+ mousedown: !1
44
+ };
45
+ let e = g.value?.querySelector(":scope tbody"), { x0: t, x1: n, y0: r, y1: i } = h.value ?? {};
46
+ if (!m?.onSelect && y.value !== "auto" || !e || d(n)) return;
47
+ let [a, o] = [t, n].toSorted((e, t) => e - t), [s, c] = [r, i].toSorted((e, t) => e - t);
48
+ m?.onSelect?.({
49
+ fromRow: s,
50
+ fromCol: a,
51
+ toRow: c,
52
+ toCol: o,
53
+ getContent: C,
54
+ tbody: e
55
+ }) !== !1 && y.value === "auto" && S(C().map((e) => e.join(" ")).join("\n")).catch(() => {
56
+ console.warn("[useTableRangeSelect] 复制到剪贴板失败");
57
+ });
58
+ }, {
59
+ passive: !0,
60
+ capture: !0
61
+ }), s(g, () => {
62
+ h.value &&= void 0;
63
+ });
64
+ let C = () => {
65
+ let e = g.value?.querySelector(":scope tbody"), { x0: t, x1: n, y0: r, y1: i } = h.value ?? {};
66
+ if (!x.value || !e || d(n)) return [];
67
+ let [a, o] = [t, n].toSorted((e, t) => e - t), [s, c] = [r, i].toSorted((e, t) => e - t), l = [];
68
+ for (let t = s; t <= c; t++) {
69
+ let n = e.rows[t];
70
+ if (!n) continue;
71
+ let r = [];
72
+ for (let e = a; e <= o; e++) {
73
+ let i = n.cells[e];
74
+ if (i && t >= s && t <= c && e >= a && e <= o) {
75
+ let e = b(i) || "";
76
+ e = e.replace(/\t/g, " ").replace(/\r/g, "").replace(/\n/g, ""), r.push(e);
77
+ }
78
+ }
79
+ r.length > 0 && l.push(r);
80
+ }
81
+ return l;
82
+ };
83
+ return o([g, h], ([e, { x0: t, x1: n, y0: r, y1: i } = {}]) => {
84
+ let a = e?.querySelector(":scope tbody");
85
+ if (!a) return;
86
+ let [o, s] = [t, n].toSorted((e, t) => e - t), [c, l] = [r, i].toSorted((e, t) => e - t);
87
+ for (let e = 0; e < a.rows.length; e++) {
88
+ let t = a.rows[e];
89
+ for (let n = 0; n < t.cells.length; n++) {
90
+ let r = t.cells[n];
91
+ r.classList.toggle(`${v.value}cell-selected`, e >= c && e <= l && n >= o && n <= s), r.classList.toggle(`${v.value}cell-selected--first-row`, e === c), r.classList.toggle(`${v.value}cell-selected--first-col`, n === o), r.classList.toggle(`${v.value}cell-selected--last-row`, e === l), r.classList.toggle(`${v.value}cell-selected--last-col`, n === s);
92
+ }
93
+ }
94
+ }), u(document, "copy", (e) => {
95
+ if (y.value !== "onCopy") return;
96
+ let t = C();
97
+ !x.value || t.length === 0 || (e.clipboardData.setData("text/plain", t.map((e) => e.join(" ")).join("\n")), e.preventDefault());
98
+ }, { passive: !1 }), {
99
+ range: n(h),
100
+ isActive: n(x),
101
+ pause: () => {
102
+ x.value = !1, h.value = void 0;
103
+ },
104
+ resume: () => {
105
+ x.value = !0;
106
+ }
107
+ };
108
+ }
109
+ p.DEFAULT_OPTIONS = f;
110
+ //#endregion
111
+ export { p as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/ui",
3
- "version": "4.0.18",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT UI",
@@ -67,13 +67,13 @@
67
67
  "sortablejs": "^1.15.7",
68
68
  "@types/sortablejs": "^1.15.9",
69
69
  "nanoid": "^5.1.11",
70
- "@ithinkdt/common": "^4.0.10"
70
+ "@ithinkdt/common": "^4.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "@ithinkdt/page": ">=4.0",
73
+ "@ithinkdt/page": ">=4.1",
74
74
  "vue": ">=3.5",
75
- "vue-router": ">=4.5",
76
- "ithinkdt-ui": ">=1.5",
75
+ "vue-router": ">=5.1",
76
+ "ithinkdt-ui": ">=1.9",
77
77
  "unocss": ">=66"
78
78
  },
79
79
  "peerDependenciesMeta": {
@@ -88,12 +88,12 @@
88
88
  "@vitejs/plugin-vue-jsx": "^5.1.5",
89
89
  "ithinkdt-ui": "^1.9.4",
90
90
  "typescript": "~6.0.3",
91
- "unocss": "^66.7.0",
91
+ "unocss": "^66.7.2",
92
92
  "vite": "^8.0.16",
93
- "vue": "^3.5.35",
93
+ "vue": "^3.5.38",
94
94
  "vue-router": "^5.1.0",
95
95
  "@vue/test-utils": "^2.4.11",
96
- "@ithinkdt/page": "^4.0.22"
96
+ "@ithinkdt/page": "^4.1.0"
97
97
  },
98
98
  "scripts": {
99
99
  "dev": "vite build --watch",