@progress/kendo-react-data-tools 9.4.0-develop.20 → 9.4.0-develop.22

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.
@@ -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 f=require("@progress/kendo-react-common"),h="items";var I=(t=>(t.copy="copy",t.cut="cut",t.paste="paste",t))(I||{});const C=(t,e,s)=>{const n=t.cellDelimiter||" ",i=t.newLineDelimiter||`\r
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,l=a?e.split(a):[e],m=s.copiedItems.length?s.copiedItems[0].fields[0]:t.columns[0].field||"";return l.map(o=>{const c=o.includes(n)?o.split(n):[o],p=t.columns.map(u=>u.field||""),d=p.indexOf(m),g=p.slice(d,d+c.length),D={};return p.slice(d,d+c.length).forEach((u,b)=>D[u]=c[b]),{dataItem:D,fields:g}})},w=(t,e)=>{if(!e.length)return null;let s="";return e.forEach((n,i,a)=>s+=`${t[n]}${i<a.length-1?" ":""}`),s},y=(t,e,s)=>{const n=s.cellDelimiter||" ",i=s.newLineDelimiter||`\r
12
- `;return`${e.join(n)}${i}${t}`},L=t=>{const{event:e,selectedState:s,data:n,dataItemKey:i}=t,a={},l={copiedItems:[],pastedItems:[],clipboardData:""},m=t.subItemsField||h;return Object.entries(s).forEach(([r,o])=>{a[r]=f.isArray(o)?o.map(c=>e.columns[c]):e.columns}),f.mapTree(n,m,r=>{const o=r[i||e.dataItemKey||""]||"";return a[o]&&l.copiedItems.push({dataItem:r,fields:a[o].map(c=>c.field||"")}),r}),l},E=(t,e)=>{const s=e.newLineDelimiter||`\r
13
- `,n=t.copiedItems.map((i,a)=>{let l=w(i.dataItem,i.fields)||"";return e.copyHeaders&&a===0&&(l=y(l,i.fields,e)),l?[l]:[]}).join(s);return navigator.clipboard.writeText(n),n},F=t=>{const{event:e}=t,s=L(t);let n="";if(e.type==="paste"){const i=e.nativeEvent?e.nativeEvent.clipboardData:"";n=i?i.getData("text").trim():"",s.pastedItems=C(e,n,s)}else s.pastedItems=[],n=E(s,e);return s.clipboardData=n,s};exports.ClipboardActionType=I;exports.populateClipboardData=F;
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=$;
@@ -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 { isArray as h, mapTree as g } from "@progress/kendo-react-common";
9
- const w = "items";
10
- var L = /* @__PURE__ */ ((t) => (t.copy = "copy", t.cut = "cut", t.paste = "paste", t))(L || {});
11
- const b = (t, e, s) => {
12
- const n = t.cellDelimiter || " ", i = t.newLineDelimiter || `\r
13
- `, l = e.includes(i) ? i : e.includes(`
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 = l ? e.split(l) : [e], m = s.copiedItems.length ? s.copiedItems[0].fields[0] : t.columns[0].field || "";
16
- return a.map((c) => {
17
- const o = c.includes(n) ? c.split(n) : [c], p = t.columns.map((u) => u.field || ""), d = p.indexOf(m), f = p.slice(d, d + o.length), D = {};
18
- return p.slice(d, d + o.length).forEach((u, I) => D[u] = o[I]), {
19
- dataItem: D,
20
- fields: f
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
- }, C = (t, e) => {
36
+ }, S = (t, e) => {
24
37
  if (!e.length)
25
38
  return null;
26
- let s = "";
27
- return e.forEach((n, i, l) => s += `${t[n]}${i < l.length - 1 ? " " : ""}`), s;
28
- }, E = (t, e, s) => {
29
- const n = s.cellDelimiter || " ", i = s.newLineDelimiter || `\r
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(n)}${i}${t}`;
32
- }, F = (t) => {
33
- const { event: e, selectedState: s, data: n, dataItemKey: i } = t, l = {}, a = { copiedItems: [], pastedItems: [], clipboardData: "" }, m = t.subItemsField || w;
34
- return Object.entries(s).forEach(([r, c]) => {
35
- l[r] = h(c) ? c.map((o) => e.columns[o]) : e.columns;
36
- }), g(n, m, (r) => {
37
- const c = r[i || e.dataItemKey || ""] || "";
38
- return l[c] && a.copiedItems.push({
39
- dataItem: r,
40
- fields: l[c].map((o) => o.field || "")
41
- }), r;
42
- }), a;
43
- }, x = (t, e) => {
44
- const s = e.newLineDelimiter || `\r
45
- `, n = t.copiedItems.map((i, l) => {
46
- let a = C(i.dataItem, i.fields) || "";
47
- return e.copyHeaders && l === 0 && (a = E(a, i.fields, e)), a ? [a] : [];
48
- }).join(s);
49
- return navigator.clipboard.writeText(n), n;
50
- }, O = (t) => {
51
- const { event: e } = t, s = F(t);
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 (e.type === "paste") {
54
- const i = e.nativeEvent ? e.nativeEvent.clipboardData : "";
55
- n = i ? i.getData("text").trim() : "", s.pastedItems = b(e, n, s);
72
+ if (t.type === "paste") {
73
+ const s = t.nativeEvent ? t.nativeEvent.clipboardData : "";
74
+ n = s ? s.getData("text").trim() : "";
56
75
  } else
57
- s.pastedItems = [], n = x(s, e);
58
- return s.clipboardData = n, s;
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
- L as ClipboardActionType,
62
- O as populateClipboardData
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
  };