@progress/kendo-react-data-tools 9.4.0-develop.20 → 9.4.0-develop.21
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/clipboard/common.js +5 -5
- package/clipboard/common.mjs +81 -45
- package/dist/cdn/js/kendo-react-datatools.js +1 -1
- package/index.d.mts +66 -6
- package/index.d.ts +66 -6
- package/index.js +1 -1
- package/index.mjs +146 -136
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
package/clipboard/common.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
9
|
-
`,a=e.includes(i)?i:e.includes(`
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@progress/kendo-react-common");var T=(t=>(t.copy="copy",t.cut="cut",t.paste="paste",t))(T||{});const b=(t,e,n,a)=>{const s=g.getter(a),o=t.data.findIndex(l=>s(l)===s(e[0].dataItem))||0,i=e.length<2?n:e.length;return t.data.filter((l,r)=>r>=o&&r<o+i)||[]},C=t=>(t==null?void 0:t.map(n=>n.fields.map(a=>n.dataItem[a].toString())))||[],x=(t,e)=>{var l,r;const{event:n}=t,a=e.includes(`
|
|
10
9
|
`)?`
|
|
11
|
-
`:null,
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
`:null,s=(l=n.cellDelimiter)!=null?l:" ",o=(r=n.newLineDelimiter)!=null?r:`\r
|
|
11
|
+
`,i=e.includes(o)?o:a;return(i?e.split(i):[e]).map(d=>d.includes(s)?d.split(s):[d])},w=(t,e)=>{var n;return((n=t.event.nativeEvent)==null?void 0:n.type)==="paste"?x(t,e):C(t.previousCopiedItems)},S=(t,e)=>{var m,u,y;const{event:n}=t,a=(u=(m=t.dataItemKey)!=null?m:n.dataItemKey)!=null?u:"",s=g.getter(a),o=D(t),i=o.length?o[0].fields[0]:(y=n.columns[0].field)!=null?y:"",c=n.columns.map(I=>{var f;return(f=I.field)!=null?f:""}),l=c.indexOf(i),r=w(t,e),d=b(t,o,r.length,a);return r.slice(0,d.length).map((I,f)=>{const O=l+I.length,h=c.slice(l,O),P={[a]:s(d[f])};return h.forEach((F,R)=>P[F]=I[R]),{dataItem:P,fields:h}})},v=(t,e)=>{if(!e.length)return null;let n="";return e.forEach((a,s,o)=>n+=`${t[a]}${s<o.length-1?" ":""}`),n},L=(t,e,n)=>{var i,c;const a=(i=n.cellDelimiter)!=null?i:" ",s=(c=n.newLineDelimiter)!=null?c:`\r
|
|
12
|
+
`;return`${e.join(a)}${s}${t}`},D=t=>{var l,r;const{event:e,selectedState:n,data:a}=t,s=(r=(l=t.dataItemKey)!=null?l:e.dataItemKey)!=null?r:"",o=g.getter(s),i={},c=[];return Object.entries(n).forEach(([d,p])=>{i[d]=g.isArray(p)?p.map(m=>e.columns[m]).filter(m=>!m.declarationIndex||m.declarationIndex>=0):e.columns.filter(m=>!m.declarationIndex||m.declarationIndex>=0)}),a==null||a.map(d=>{const p=o(d)||"";return i[p]&&c.push({dataItem:d,fields:i[p].map(m=>{var u;return(u=m.field)!=null?u:""})}),d}),c},E=(t,e)=>{var s,o;const n=(s=e.newLineDelimiter)!=null?s:`\r
|
|
13
|
+
`,a=t.map((i,c)=>{var r;let l=(r=v(i.dataItem,i.fields))!=null?r:"";return e.copyHeaders&&c===0&&(l=L(l,i.fields,e)),l?[l]:[]}).join(n);return(o=navigator.clipboard)==null||o.writeText(a),a},K=(t,e)=>{let n="";if(t.type==="paste"){const a=t.nativeEvent?t.nativeEvent.clipboardData:"";n=a?a.getData("text").trim():""}else n=E(e,t);return n},$=t=>{const{event:e}=t,n=D(t)||[],a=K(e,n)||"",s=e.type==="paste"?S(t,a)||[]:[];return{copiedItems:n,pastedItems:s,clipboardData:a}};exports.ClipboardActionType=T;exports.addHeaders=L;exports.getClipboardData=K;exports.getClipboardItemsToPaste=x;exports.getClipboardText=E;exports.getItemsToPaste=w;exports.getItemsToUpdateOnPaste=b;exports.getPastedItems=S;exports.getPreviouslyCopiedItemsData=C;exports.getSelectedItems=D;exports.itemToString=v;exports.populateClipboardData=$;
|
package/clipboard/common.mjs
CHANGED
|
@@ -5,59 +5,95 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { getter as D, isArray as T } from "@progress/kendo-react-common";
|
|
9
|
+
var b = /* @__PURE__ */ ((t) => (t.copy = "copy", t.cut = "cut", t.paste = "paste", t))(b || {});
|
|
10
|
+
const C = (t, e, n, s) => {
|
|
11
|
+
const a = D(s), o = t.data.findIndex((c) => a(c) === a(e[0].dataItem)) || 0, i = e.length < 2 ? n : e.length;
|
|
12
|
+
return t.data.filter((c, l) => l >= o && l < o + i) || [];
|
|
13
|
+
}, E = (t) => (t == null ? void 0 : t.map((n) => n.fields.map((s) => n.dataItem[s].toString()))) || [], K = (t, e) => {
|
|
14
|
+
var c, l;
|
|
15
|
+
const { event: n } = t, s = e.includes(`
|
|
14
16
|
`) ? `
|
|
15
|
-
` : null, a =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
` : null, a = (c = n.cellDelimiter) != null ? c : " ", o = (l = n.newLineDelimiter) != null ? l : `\r
|
|
18
|
+
`, i = e.includes(o) ? o : s;
|
|
19
|
+
return (i ? e.split(i) : [e]).map((d) => d.includes(a) ? d.split(a) : [d]);
|
|
20
|
+
}, v = (t, e) => {
|
|
21
|
+
var n;
|
|
22
|
+
return ((n = t.event.nativeEvent) == null ? void 0 : n.type) === "paste" ? K(t, e) : E(t.previousCopiedItems);
|
|
23
|
+
}, F = (t, e) => {
|
|
24
|
+
var m, u, h;
|
|
25
|
+
const { event: n } = t, s = (u = (m = t.dataItemKey) != null ? m : n.dataItemKey) != null ? u : "", a = D(s), o = x(t), i = o.length ? o[0].fields[0] : (h = n.columns[0].field) != null ? h : "", r = n.columns.map((f) => {
|
|
26
|
+
var I;
|
|
27
|
+
return (I = f.field) != null ? I : "";
|
|
28
|
+
}), c = r.indexOf(i), l = v(t, e), d = C(t, o, l.length, s);
|
|
29
|
+
return l.slice(0, d.length).map((f, I) => {
|
|
30
|
+
const w = c + f.length, g = r.slice(c, w), y = { [s]: a(d[I]) };
|
|
31
|
+
return g.forEach((P, L) => y[P] = f[L]), {
|
|
32
|
+
dataItem: y,
|
|
33
|
+
fields: g
|
|
21
34
|
};
|
|
22
35
|
});
|
|
23
|
-
},
|
|
36
|
+
}, S = (t, e) => {
|
|
24
37
|
if (!e.length)
|
|
25
38
|
return null;
|
|
26
|
-
let
|
|
27
|
-
return e.forEach((
|
|
28
|
-
},
|
|
29
|
-
|
|
39
|
+
let n = "";
|
|
40
|
+
return e.forEach((s, a, o) => n += `${t[s]}${a < o.length - 1 ? " " : ""}`), n;
|
|
41
|
+
}, $ = (t, e, n) => {
|
|
42
|
+
var i, r;
|
|
43
|
+
const s = (i = n.cellDelimiter) != null ? i : " ", a = (r = n.newLineDelimiter) != null ? r : `\r
|
|
30
44
|
`;
|
|
31
|
-
return `${e.join(
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
return `${e.join(s)}${a}${t}`;
|
|
46
|
+
}, x = (t) => {
|
|
47
|
+
var c, l;
|
|
48
|
+
const { event: e, selectedState: n, data: s } = t, a = (l = (c = t.dataItemKey) != null ? c : e.dataItemKey) != null ? l : "", o = D(a), i = {}, r = [];
|
|
49
|
+
return Object.entries(n).forEach(([d, p]) => {
|
|
50
|
+
i[d] = T(p) ? p.map((m) => e.columns[m]).filter((m) => !m.declarationIndex || m.declarationIndex >= 0) : e.columns.filter((m) => !m.declarationIndex || m.declarationIndex >= 0);
|
|
51
|
+
}), s == null || s.map((d) => {
|
|
52
|
+
const p = o(d) || "";
|
|
53
|
+
return i[p] && r.push({
|
|
54
|
+
dataItem: d,
|
|
55
|
+
fields: i[p].map((m) => {
|
|
56
|
+
var u;
|
|
57
|
+
return (u = m.field) != null ? u : "";
|
|
58
|
+
})
|
|
59
|
+
}), d;
|
|
60
|
+
}), r;
|
|
61
|
+
}, O = (t, e) => {
|
|
62
|
+
var a, o;
|
|
63
|
+
const n = (a = e.newLineDelimiter) != null ? a : `\r
|
|
64
|
+
`, s = t.map((i, r) => {
|
|
65
|
+
var l;
|
|
66
|
+
let c = (l = S(i.dataItem, i.fields)) != null ? l : "";
|
|
67
|
+
return e.copyHeaders && r === 0 && (c = $(c, i.fields, e)), c ? [c] : [];
|
|
68
|
+
}).join(n);
|
|
69
|
+
return (o = navigator.clipboard) == null || o.writeText(s), s;
|
|
70
|
+
}, R = (t, e) => {
|
|
52
71
|
let n = "";
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
n =
|
|
72
|
+
if (t.type === "paste") {
|
|
73
|
+
const s = t.nativeEvent ? t.nativeEvent.clipboardData : "";
|
|
74
|
+
n = s ? s.getData("text").trim() : "";
|
|
56
75
|
} else
|
|
57
|
-
|
|
58
|
-
return
|
|
76
|
+
n = O(e, t);
|
|
77
|
+
return n;
|
|
78
|
+
}, G = (t) => {
|
|
79
|
+
const { event: e } = t, n = x(t) || [], s = R(e, n) || "", a = e.type === "paste" ? F(t, s) || [] : [];
|
|
80
|
+
return {
|
|
81
|
+
copiedItems: n,
|
|
82
|
+
pastedItems: a,
|
|
83
|
+
clipboardData: s
|
|
84
|
+
};
|
|
59
85
|
};
|
|
60
86
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
b as ClipboardActionType,
|
|
88
|
+
$ as addHeaders,
|
|
89
|
+
R as getClipboardData,
|
|
90
|
+
K as getClipboardItemsToPaste,
|
|
91
|
+
O as getClipboardText,
|
|
92
|
+
v as getItemsToPaste,
|
|
93
|
+
C as getItemsToUpdateOnPaste,
|
|
94
|
+
F as getPastedItems,
|
|
95
|
+
E as getPreviouslyCopiedItemsData,
|
|
96
|
+
x as getSelectedItems,
|
|
97
|
+
S as itemToString,
|
|
98
|
+
G as populateClipboardData
|
|
63
99
|
};
|