@progress/kendo-react-data-tools 7.5.0-develop.8 → 8.0.0-develop.1
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/dist/cdn/js/kendo-react-datatools.js +1 -1
- package/index.d.mts +29 -3
- package/index.d.ts +29 -3
- package/navigation/TableKeyboardNavigation.js +1 -1
- package/navigation/TableKeyboardNavigation.mjs +121 -91
- package/navigation/utils.js +1 -1
- package/navigation/utils.mjs +101 -75
- package/package-metadata.mjs +1 -1
- package/package.json +10 -10
- package/pager/Pager.js +1 -1
- package/pager/Pager.mjs +107 -103
- package/selection/TableSelection.js +1 -1
- package/selection/TableSelection.mjs +79 -69
- package/selection/utils.js +1 -1
- package/selection/utils.mjs +85 -84
package/selection/utils.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@progress/kendo-react-common"),v=require("./constants.js"),M="items",y={},F=(e,t)=>!e||Array.isArray(e)&&e.length===0?[t]:e.findIndex(d=>d===t)>-1?e.filter(d=>d!==t):[...e,t],b=e=>{let t=e;for(;t;){if(t.hasAttribute(v.TABLE_PREVENT_SELECTION_ELEMENT))return!0;t=t.parentElement}return!1},R=(e,t)=>{let o=e;for(;o;){if(o.tagName===t)return o;if(o.tagName==="TABLE")return null;o=o.parentElement}return null},_=e=>{if(!e)return;const t=e.getAttribute(v.TABLE_ROW_INDEX_ATTRIBUTE);return t?parseInt(t,10):void 0},N=e=>{if(!e)return;const t=e.getAttribute(v.TABLE_COL_INDEX_ATTRIBUTE);return t?parseInt(t,10):void 0},G=e=>{const t=e.subItemsField||M,o=s.getter(e.dataItemKey);return s.mapTree(e.data,t,d=>s.extendDataItem(d,t,{[e.selectedField]:e.selectedState[o(d)]}))},U=e=>{const{event:t,dataItemKey:o,selectedState:d}=e,{syntheticEvent:c,nativeEvent:n,dataItems:f,componentId:i,mode:E,cell:x,selectedField:T}=t,{target:S,ctrlKey:w,metaKey:p,altKey:I,shiftKey:K}=n;if(c.isDefaultPrevented()&&!K||n.keyCode!==s.Keys.space&&n.keyCode!==s.Keys.enter&&n.keyCode!==s.Keys.right&&n.keyCode!==s.Keys.left&&n.keyCode!==s.Keys.up&&n.keyCode!==s.Keys.down)return d;c.preventDefault();const D=R(S,"TD"),m=R(S,"TR");let r=N(D),u=_(m),l={};return D&&m&&u!==void 0&&r!==void 0&&(n.keyCode===s.Keys.right&&r++,n.keyCode===s.Keys.left&&r--,n.keyCode===s.Keys.down&&u++,n.keyCode===s.Keys.up&&u--,l=L({selectedState:d,dataItemKey:o,event:{ctrlKey:w,metaKey:p,altKey:I,shiftKey:K,dataItems:f,cell:x,mode:E,selectedField:T,componentId:i,startColIndex:r,endColIndex:r,startRowIndex:u,endRowIndex:u,isDrag:!1,syntheticEvent:c,nativeEvent:n,target:t.target,dataItem:null}})),l},L=e=>{const{event:t,dataItemKey:o,selectedState:d}=e,{dataItems:c,startRowIndex:n,endRowIndex:f,startColIndex:i,endColIndex:E,cell:x,isDrag:T,ctrlKey:S,shiftKey:w,metaKey:p,componentId:I,mode:K,dataItem:D}=t,m=s.getter(o);let r={};const u=D!==null;if(K==="single"){const l=c.slice(n,n+1)[0],g=m(l);y[I]={rowIndex:n,colIndex:i},r[g]=x?[i]:!0}else if(T||!w&&!S&&!p&&!u){T||(y[I]={rowIndex:n,colIndex:i});const l=[];for(let a=i;a<=E;a++)l.push(a);c.slice(n,f+1).forEach(a=>{const h=m(a);r[h]=x?[...l]:!0})}else if(S||p||u){y[I]={rowIndex:n,colIndex:i};const g=c.slice(n,f+1)[0],a=m(g);r={...d},r[a]=x&&!u?F(r[a],i):!r[a]}else if(w){const l=y[I]&&y[I].rowIndex||0,g=y[I]&&y[I].colIndex||0,a=Math.min(l,n,f),h=Math.max(l,n,f),O=Math.min(g,i,E),k=Math.max(g,i,E),A=[];for(let C=O;C<=k;C++)A.push(C);c.slice(a,h+1).forEach(C=>{const B=m(C);r[B]=x?[...A]:!0})}return r},X=s.hasRelativeStackingContext(),q=e=>{if(!e||!X)return null;let t=e.parentElement;for(;t;){if(window.getComputedStyle(t).transform!=="none")return t;t=t.parentElement}},V=e=>{if(e&&e.ownerDocument&&e!==e.ownerDocument.body){const t=e.getBoundingClientRect();return{left:t.left-e.scrollLeft,top:t.top-e.scrollTop}}return{left:0,top:0}},j=e=>{const t=e?typeof e.enabled=="boolean"?e.enabled:!0:!1,o=e?!!e.drag:!1,d=e&&e.mode?e.mode:"multiple",c=!!(e&&e.cell);return{enabled:t,drag:o,mode:d,cell:c}};exports.closestTagName=R;exports.getColumnIndex=N;exports.getOffset=V;exports.getRowIndex=_;exports.getSelectedState=L;exports.getSelectedStateFromKeyDown=U;exports.getSelectionOptions=j;exports.isInNonSelectable=b;exports.relativeContextElement=q;exports.setSelectedState=G;
|
package/selection/utils.mjs
CHANGED
|
@@ -6,129 +6,130 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import { getter as _, mapTree as
|
|
10
|
-
import { TABLE_PREVENT_SELECTION_ELEMENT as
|
|
11
|
-
const
|
|
9
|
+
import { getter as _, mapTree as k, extendDataItem as B, Keys as i, hasRelativeStackingContext as O } from "@progress/kendo-react-common";
|
|
10
|
+
import { TABLE_PREVENT_SELECTION_ELEMENT as M, TABLE_ROW_INDEX_ATTRIBUTE as F, TABLE_COL_INDEX_ATTRIBUTE as G } from "./constants.mjs";
|
|
11
|
+
const U = "items", x = {}, X = (e, t) => !e || Array.isArray(e) && e.length === 0 ? [t] : e.findIndex((d) => d === t) > -1 ? e.filter((d) => d !== t) : [...e, t], J = (e) => {
|
|
12
12
|
let t = e;
|
|
13
13
|
for (; t; ) {
|
|
14
|
-
if (t.hasAttribute(
|
|
14
|
+
if (t.hasAttribute(M))
|
|
15
15
|
return !0;
|
|
16
16
|
t = t.parentElement;
|
|
17
17
|
}
|
|
18
18
|
return !1;
|
|
19
19
|
}, A = (e, t) => {
|
|
20
|
-
let
|
|
21
|
-
for (;
|
|
22
|
-
if (
|
|
23
|
-
return
|
|
24
|
-
if (
|
|
20
|
+
let o = e;
|
|
21
|
+
for (; o; ) {
|
|
22
|
+
if (o.tagName === t)
|
|
23
|
+
return o;
|
|
24
|
+
if (o.tagName === "TABLE")
|
|
25
25
|
return null;
|
|
26
|
-
|
|
26
|
+
o = o.parentElement;
|
|
27
27
|
}
|
|
28
28
|
return null;
|
|
29
|
-
},
|
|
29
|
+
}, b = (e) => {
|
|
30
30
|
if (!e)
|
|
31
31
|
return;
|
|
32
|
-
const t = e.getAttribute(
|
|
32
|
+
const t = e.getAttribute(F);
|
|
33
33
|
return t ? parseInt(t, 10) : void 0;
|
|
34
34
|
}, V = (e) => {
|
|
35
35
|
if (!e)
|
|
36
36
|
return;
|
|
37
|
-
const t = e.getAttribute(
|
|
37
|
+
const t = e.getAttribute(G);
|
|
38
38
|
return t ? parseInt(t, 10) : void 0;
|
|
39
39
|
}, Q = (e) => {
|
|
40
|
-
const t = e.subItemsField ||
|
|
41
|
-
return
|
|
40
|
+
const t = e.subItemsField || U, o = _(e.dataItemKey);
|
|
41
|
+
return k(
|
|
42
42
|
e.data,
|
|
43
43
|
t,
|
|
44
|
-
(
|
|
45
|
-
[e.selectedField]: e.selectedState[
|
|
44
|
+
(d) => B(d, t, {
|
|
45
|
+
[e.selectedField]: e.selectedState[o(d)]
|
|
46
46
|
})
|
|
47
47
|
);
|
|
48
48
|
}, Y = (e) => {
|
|
49
|
-
const { event: t, dataItemKey:
|
|
50
|
-
if (
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
const { event: t, dataItemKey: o, selectedState: d } = e, { syntheticEvent: a, nativeEvent: n, dataItems: E, componentId: c, mode: T, cell: g, selectedField: p } = t, { target: C, ctrlKey: w, metaKey: S, altKey: I, shiftKey: h } = n;
|
|
50
|
+
if (a.isDefaultPrevented() && !h || n.keyCode !== i.space && n.keyCode !== i.enter && n.keyCode !== i.right && n.keyCode !== i.left && n.keyCode !== i.up && n.keyCode !== i.down)
|
|
51
|
+
return d;
|
|
52
|
+
a.preventDefault();
|
|
53
|
+
const D = A(C, "TD"), m = A(C, "TR");
|
|
54
|
+
let r = V(D), u = b(m), s = {};
|
|
55
|
+
return D && m && u !== void 0 && r !== void 0 && (n.keyCode === i.right && r++, n.keyCode === i.left && r--, n.keyCode === i.down && u++, n.keyCode === i.up && u--, s = H({
|
|
56
|
+
selectedState: d,
|
|
57
|
+
dataItemKey: o,
|
|
57
58
|
event: {
|
|
58
|
-
ctrlKey:
|
|
59
|
-
metaKey:
|
|
59
|
+
ctrlKey: w,
|
|
60
|
+
metaKey: S,
|
|
60
61
|
altKey: I,
|
|
61
|
-
shiftKey:
|
|
62
|
+
shiftKey: h,
|
|
62
63
|
dataItems: E,
|
|
63
|
-
cell:
|
|
64
|
+
cell: g,
|
|
64
65
|
mode: T,
|
|
65
|
-
selectedField:
|
|
66
|
-
componentId:
|
|
67
|
-
startColIndex:
|
|
68
|
-
endColIndex:
|
|
69
|
-
startRowIndex:
|
|
70
|
-
endRowIndex:
|
|
66
|
+
selectedField: p,
|
|
67
|
+
componentId: c,
|
|
68
|
+
startColIndex: r,
|
|
69
|
+
endColIndex: r,
|
|
70
|
+
startRowIndex: u,
|
|
71
|
+
endRowIndex: u,
|
|
71
72
|
isDrag: !1,
|
|
72
|
-
syntheticEvent:
|
|
73
|
-
nativeEvent:
|
|
73
|
+
syntheticEvent: a,
|
|
74
|
+
nativeEvent: n,
|
|
74
75
|
target: t.target,
|
|
75
76
|
dataItem: null
|
|
76
77
|
}
|
|
77
|
-
})),
|
|
78
|
+
})), s;
|
|
78
79
|
}, H = (e) => {
|
|
79
|
-
const { event: t, dataItemKey:
|
|
80
|
-
dataItems:
|
|
81
|
-
startRowIndex:
|
|
80
|
+
const { event: t, dataItemKey: o, selectedState: d } = e, {
|
|
81
|
+
dataItems: a,
|
|
82
|
+
startRowIndex: n,
|
|
82
83
|
endRowIndex: E,
|
|
83
|
-
startColIndex:
|
|
84
|
+
startColIndex: c,
|
|
84
85
|
endColIndex: T,
|
|
85
|
-
cell:
|
|
86
|
-
isDrag:
|
|
87
|
-
ctrlKey:
|
|
88
|
-
shiftKey:
|
|
89
|
-
metaKey:
|
|
86
|
+
cell: g,
|
|
87
|
+
isDrag: p,
|
|
88
|
+
ctrlKey: C,
|
|
89
|
+
shiftKey: w,
|
|
90
|
+
metaKey: S,
|
|
90
91
|
componentId: I,
|
|
91
|
-
mode:
|
|
92
|
-
dataItem:
|
|
93
|
-
} = t,
|
|
94
|
-
let
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
92
|
+
mode: h,
|
|
93
|
+
dataItem: D
|
|
94
|
+
} = t, m = _(o);
|
|
95
|
+
let r = {};
|
|
96
|
+
const u = D !== null;
|
|
97
|
+
if (h === "single") {
|
|
98
|
+
const s = a.slice(n, n + 1)[0], f = m(s);
|
|
98
99
|
x[I] = {
|
|
99
|
-
rowIndex:
|
|
100
|
-
colIndex:
|
|
101
|
-
},
|
|
102
|
-
} else if (
|
|
103
|
-
|
|
104
|
-
rowIndex:
|
|
105
|
-
colIndex:
|
|
100
|
+
rowIndex: n,
|
|
101
|
+
colIndex: c
|
|
102
|
+
}, r[f] = g ? [c] : !0;
|
|
103
|
+
} else if (p || !w && !C && !S && !u) {
|
|
104
|
+
p || (x[I] = {
|
|
105
|
+
rowIndex: n,
|
|
106
|
+
colIndex: c
|
|
106
107
|
});
|
|
107
|
-
const
|
|
108
|
-
for (let l =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
108
|
+
const s = [];
|
|
109
|
+
for (let l = c; l <= T; l++)
|
|
110
|
+
s.push(l);
|
|
111
|
+
a.slice(n, E + 1).forEach((l) => {
|
|
112
|
+
const R = m(l);
|
|
113
|
+
r[R] = g ? [...s] : !0;
|
|
113
114
|
});
|
|
114
|
-
} else if (
|
|
115
|
+
} else if (C || S || u) {
|
|
115
116
|
x[I] = {
|
|
116
|
-
rowIndex:
|
|
117
|
-
colIndex:
|
|
117
|
+
rowIndex: n,
|
|
118
|
+
colIndex: c
|
|
118
119
|
};
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
} else if (
|
|
122
|
-
const
|
|
123
|
-
for (let
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
120
|
+
const f = a.slice(n, E + 1)[0], l = m(f);
|
|
121
|
+
r = { ...d }, r[l] = g && !u ? X(r[l], c) : !r[l];
|
|
122
|
+
} else if (w) {
|
|
123
|
+
const s = x[I] && x[I].rowIndex || 0, f = x[I] && x[I].colIndex || 0, l = Math.min(s, n, E), R = Math.max(s, n, E), K = Math.min(f, c, T), L = Math.max(f, c, T), v = [];
|
|
124
|
+
for (let y = K; y <= L; y++)
|
|
125
|
+
v.push(y);
|
|
126
|
+
a.slice(l, R + 1).forEach((y) => {
|
|
127
|
+
const N = m(y);
|
|
128
|
+
r[N] = g ? [...v] : !0;
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
|
-
return
|
|
131
|
-
}, W =
|
|
131
|
+
return r;
|
|
132
|
+
}, W = O(), Z = (e) => {
|
|
132
133
|
if (!e || !W)
|
|
133
134
|
return null;
|
|
134
135
|
let t = e.parentElement;
|
|
@@ -147,14 +148,14 @@ const X = "items", x = {}, b = (e, t) => !e || Array.isArray(e) && e.length ===
|
|
|
147
148
|
}
|
|
148
149
|
return { left: 0, top: 0 };
|
|
149
150
|
}, P = (e) => {
|
|
150
|
-
const t = e ? typeof e.enabled == "boolean" ? e.enabled : !0 : !1,
|
|
151
|
-
return { enabled: t, drag:
|
|
151
|
+
const t = e ? typeof e.enabled == "boolean" ? e.enabled : !0 : !1, o = e ? !!e.drag : !1, d = e && e.mode ? e.mode : "multiple", a = !!(e && e.cell);
|
|
152
|
+
return { enabled: t, drag: o, mode: d, cell: a };
|
|
152
153
|
};
|
|
153
154
|
export {
|
|
154
155
|
A as closestTagName,
|
|
155
156
|
V as getColumnIndex,
|
|
156
157
|
$ as getOffset,
|
|
157
|
-
|
|
158
|
+
b as getRowIndex,
|
|
158
159
|
H as getSelectedState,
|
|
159
160
|
Y as getSelectedStateFromKeyDown,
|
|
160
161
|
P as getSelectionOptions,
|