@ithinkdt/ui 4.0.18 → 4.0.19
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.
- package/esm/{DataTable-CMFYAmRF.js → DataTable-2vtI02wP.js} +58 -58
- package/esm/{components-BHfgt7FW.js → components-DLa9-kdK.js} +1 -1
- package/esm/components.js +1 -1
- package/esm/composables.d.ts +142 -2
- package/esm/composables.js +12 -11
- package/esm/page.js +1 -1
- package/esm/use-table-range-select-Da6t9Vlf.js +111 -0
- package/package.json +2 -2
|
@@ -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
2
|
import { i as o } from "./directives-Chz4DK1u.js";
|
|
3
|
-
import { C as s } from "./components-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { C as s } from "./components-DLa9-kdK.js";
|
|
4
|
+
import { t as c } from "./use-table-range-select-Da6t9Vlf.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]" && !
|
|
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 =
|
|
19
|
+
let t = g(e.title), n = t && y(u("div", null, [t]), [[
|
|
20
20
|
o,
|
|
21
|
-
() =>
|
|
21
|
+
() => g(e.title),
|
|
22
22
|
void 0,
|
|
23
23
|
{ auto: !0 }
|
|
24
24
|
]]);
|
|
25
|
-
return e.tooltip ?
|
|
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,
|
|
31
|
-
default:
|
|
32
|
-
trigger: () =>
|
|
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: () => [
|
|
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 && (
|
|
45
|
+
return n && (p(n) || ((function() {
|
|
46
46
|
return n;
|
|
47
|
-
})(), 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__ */
|
|
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:
|
|
103
|
-
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 } =
|
|
113
|
+
let { keyField: o } = f(O), s = a(), d = `${s.value}-datatable`;
|
|
114
114
|
e("-datatable", M, s);
|
|
115
|
-
let
|
|
116
|
-
e == n?.sortField && t == n?.sortOrder ||
|
|
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
|
-
|
|
119
|
-
let
|
|
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
|
-
}),
|
|
122
|
+
}), S = h({
|
|
123
123
|
cache: [],
|
|
124
124
|
scrollToView(...e) {
|
|
125
|
-
|
|
125
|
+
S.value.cache.push(e);
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
let e =
|
|
131
|
-
|
|
132
|
-
let n = t.data.findIndex((t) =>
|
|
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 =
|
|
135
|
-
|
|
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)
|
|
141
|
-
}), i(
|
|
142
|
-
let
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
let E = m();
|
|
150
|
+
v(() => t.highlight, (e) => {
|
|
151
|
+
E.value = typeof e == "boolean" ? null : e ?? null;
|
|
152
152
|
}, { immediate: !0 });
|
|
153
|
-
let
|
|
153
|
+
let D = l(() => (e, n) => [
|
|
154
154
|
t.rowClassName?.(e, n) || "",
|
|
155
|
-
`${
|
|
156
|
-
|
|
157
|
-
].join(" ")), j =
|
|
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":
|
|
161
|
+
"data-row-key": y.value(e),
|
|
162
162
|
onClick: (n) => {
|
|
163
|
-
let a =
|
|
164
|
-
t.highlight === !0 && (
|
|
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 } =
|
|
183
|
+
}, { range: I, pause: L, resume: R } = c(p, {
|
|
184
184
|
immediate: t.rangeSelect,
|
|
185
|
-
clsPrefix:
|
|
185
|
+
clsPrefix: l(() => `${s.value}-`)
|
|
186
186
|
});
|
|
187
|
-
return
|
|
187
|
+
return v(() => t.rangeSelect, (e) => {
|
|
188
188
|
e ? R() : L();
|
|
189
|
-
}), () =>
|
|
189
|
+
}), () => u(C, {
|
|
190
190
|
ref: "table-ref",
|
|
191
191
|
class: [
|
|
192
|
-
|
|
193
|
-
t.appear === "sticky" ? `${
|
|
194
|
-
I.value?.ing ? `${
|
|
192
|
+
d,
|
|
193
|
+
t.appear === "sticky" ? `${d}--sticky` : "",
|
|
194
|
+
I.value?.ing ? `${d}--cell-selecting` : ""
|
|
195
195
|
],
|
|
196
196
|
data: t.data,
|
|
197
|
-
columns:
|
|
198
|
-
rowKey:
|
|
197
|
+
columns: T.value,
|
|
198
|
+
rowKey: y.value,
|
|
199
199
|
tableLayout: "fixed",
|
|
200
|
-
scrollX:
|
|
201
|
-
rowClassName:
|
|
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 },
|
|
@@ -2162,6 +2162,6 @@ var Mt = /* @__PURE__ */ d({
|
|
|
2162
2162
|
});
|
|
2163
2163
|
};
|
|
2164
2164
|
}
|
|
2165
|
-
}), It = u(() => import("./DataTable-
|
|
2165
|
+
}), It = u(() => import("./DataTable-2vtI02wP.js").then((e) => e.DataTable));
|
|
2166
2166
|
//#endregion
|
|
2167
2167
|
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-
|
|
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-DLa9-kdK.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 };
|
package/esm/composables.d.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
+
options: {
|
|
7
8
|
data: MaybeRef<T[]>
|
|
8
9
|
onSort: (info: { from: number, to: number }) => void
|
|
9
10
|
} & Omit<Sortable.Options, 'onSort'>,
|
|
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 => 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 & {}
|
package/esm/composables.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "./use-table-range-select-Da6t9Vlf.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
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
await
|
|
9
|
-
let
|
|
10
|
-
if (!
|
|
11
|
-
let o =
|
|
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(".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 {
|
|
28
|
+
export { o as useDataTableDrag, e as useTableRangeSelect };
|
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-
|
|
2
|
+
import { _ as t, a as n, c as r, i, o as a, w as o } from "./components-DLa9-kdK.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";
|
|
@@ -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
|
+
}, globalThis.getSelection ? 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("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("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("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.
|
|
3
|
+
"version": "4.0.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "iThinkDT UI",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"sortablejs": "^1.15.7",
|
|
68
68
|
"@types/sortablejs": "^1.15.9",
|
|
69
69
|
"nanoid": "^5.1.11",
|
|
70
|
-
"@ithinkdt/common": "^4.0.
|
|
70
|
+
"@ithinkdt/common": "^4.0.12"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@ithinkdt/page": ">=4.0",
|