@progress/kendo-react-data-tools 7.5.0-develop.2 → 7.5.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/dist/cdn/js/kendo-react-datatools.js +1 -1
- package/index.d.mts +31 -11
- package/index.d.ts +31 -11
- 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 +11 -11
- 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/index.d.ts
CHANGED
|
@@ -94,9 +94,6 @@ export declare interface BooleanFilterProps extends TextFilterProps {
|
|
|
94
94
|
defaultItem?: any;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
/**
|
|
98
|
-
* @hidden
|
|
99
|
-
*/
|
|
100
97
|
export declare interface CellProps {
|
|
101
98
|
/**
|
|
102
99
|
* @hidden
|
|
@@ -199,11 +196,11 @@ export declare interface ClipboardDataEvent {
|
|
|
199
196
|
*/
|
|
200
197
|
type: ClipboardActionType;
|
|
201
198
|
/**
|
|
202
|
-
* Represents the native
|
|
199
|
+
* Represents the native [ClipboardEvent]({% slug api_grid_gridcellssettings %})
|
|
203
200
|
*/
|
|
204
201
|
nativeEvent?: ClipboardEvent;
|
|
205
202
|
/**
|
|
206
|
-
* All the Grid columns.
|
|
203
|
+
* All the Grid columns. It takes value of type of [ColumnBaseProps]({% slug api_data-tools_columnbaseprops %})<[CellProps]({% slug api_data-tools_cellprops %})>[]
|
|
207
204
|
*/
|
|
208
205
|
columns: ColumnBaseProps[];
|
|
209
206
|
/**
|
|
@@ -277,9 +274,6 @@ export declare interface ClipboardSettings {
|
|
|
277
274
|
/** @hidden */
|
|
278
275
|
export declare const closestTagName: (target: HTMLElement | null, tagName: 'TD' | 'TR' | 'TABLE') => HTMLElement | null;
|
|
279
276
|
|
|
280
|
-
/**
|
|
281
|
-
* @hidden
|
|
282
|
-
*/
|
|
283
277
|
export declare interface ColumnBaseProps<CellProps = CellProps> {
|
|
284
278
|
/**
|
|
285
279
|
* The field to which the column is bound.
|
|
@@ -1647,6 +1641,7 @@ export declare class Pager extends React_2.Component<PagerProps, PagerState> {
|
|
|
1647
1641
|
messagesMap: PropTypes.Requireable<(...args: any[]) => any>;
|
|
1648
1642
|
size: PropTypes.Requireable<string | null>;
|
|
1649
1643
|
dir: PropTypes.Requireable<string>;
|
|
1644
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
1650
1645
|
};
|
|
1651
1646
|
/**
|
|
1652
1647
|
* @hidden
|
|
@@ -1656,6 +1651,7 @@ export declare class Pager extends React_2.Component<PagerProps, PagerState> {
|
|
|
1656
1651
|
info: boolean;
|
|
1657
1652
|
type: string;
|
|
1658
1653
|
size: string;
|
|
1654
|
+
disabled: boolean;
|
|
1659
1655
|
};
|
|
1660
1656
|
private _element;
|
|
1661
1657
|
private get isRtl();
|
|
@@ -1769,6 +1765,10 @@ export declare interface PagerProps {
|
|
|
1769
1765
|
* By default, navigation is disabled and the Pager content is accessible in the normal tab sequence.
|
|
1770
1766
|
*/
|
|
1771
1767
|
navigatable?: boolean;
|
|
1768
|
+
/**
|
|
1769
|
+
* Controls the disabled state of the Pager. Defaults to `false`.
|
|
1770
|
+
*/
|
|
1771
|
+
disabled?: boolean;
|
|
1772
1772
|
}
|
|
1773
1773
|
|
|
1774
1774
|
/**
|
|
@@ -1990,7 +1990,7 @@ export declare interface TableDragSelectionReleaseEvent {
|
|
|
1990
1990
|
*/
|
|
1991
1991
|
export declare const tableKeyboardNavigation: {
|
|
1992
1992
|
onConstructor: (options: {
|
|
1993
|
-
navigatable
|
|
1993
|
+
navigatable?: boolean | undefined;
|
|
1994
1994
|
contextStateRef: {
|
|
1995
1995
|
current?: TableKeyboardNavigationContextType;
|
|
1996
1996
|
};
|
|
@@ -2025,6 +2025,7 @@ export declare const tableKeyboardNavigation: {
|
|
|
2025
2025
|
navigationStateRef: {
|
|
2026
2026
|
current?: TableKeyboardNavigationStateType;
|
|
2027
2027
|
};
|
|
2028
|
+
focusFirst?: boolean;
|
|
2028
2029
|
}) => void;
|
|
2029
2030
|
onFocus: (event: React_2.FocusEvent<HTMLDivElement>, options: {
|
|
2030
2031
|
contextStateRef: {
|
|
@@ -2041,6 +2042,7 @@ export declare const tableKeyboardNavigation: {
|
|
|
2041
2042
|
onNavigationAction?: ((options: {
|
|
2042
2043
|
event: React_2.KeyboardEvent<HTMLElement>;
|
|
2043
2044
|
focusElement: any;
|
|
2045
|
+
action?: "moveToNextPage" | "moveToPrevPage" | "reorderToLeft" | "reorderToRight" | undefined;
|
|
2044
2046
|
}) => void) | undefined;
|
|
2045
2047
|
}) => void;
|
|
2046
2048
|
generateMatrix: (options: {
|
|
@@ -2049,6 +2051,15 @@ export declare const tableKeyboardNavigation: {
|
|
|
2049
2051
|
current?: TableKeyboardNavigationStateType;
|
|
2050
2052
|
};
|
|
2051
2053
|
}) => void;
|
|
2054
|
+
focusFirstDataElement: (options: {
|
|
2055
|
+
scope?: HTMLElement | undefined;
|
|
2056
|
+
contextStateRef: {
|
|
2057
|
+
current?: TableKeyboardNavigationContextType | undefined;
|
|
2058
|
+
};
|
|
2059
|
+
navigationStateRef: {
|
|
2060
|
+
current?: TableKeyboardNavigationStateType | undefined;
|
|
2061
|
+
};
|
|
2062
|
+
}, event?: any) => void;
|
|
2052
2063
|
};
|
|
2053
2064
|
|
|
2054
2065
|
/**
|
|
@@ -2100,7 +2111,7 @@ export declare interface TableKeyboardNavigationStateType {
|
|
|
2100
2111
|
* @hidden
|
|
2101
2112
|
*/
|
|
2102
2113
|
export declare const tableKeyboardNavigationTools: {
|
|
2103
|
-
generateNavigatableId: (navigationId: string, idPrefix: string, type?: 'column' | 'cell' | 'nodata') => string;
|
|
2114
|
+
generateNavigatableId: (navigationId: string, idPrefix: string, type?: 'column' | 'cell' | 'group' | 'expand' | 'nodata') => string;
|
|
2104
2115
|
getNavigatableId: (element: Element | null) => string | undefined;
|
|
2105
2116
|
getNavigatableLevel: (element: Element | null) => number | undefined;
|
|
2106
2117
|
getNavigatableElement: (scope: HTMLElement, options?: {
|
|
@@ -2126,7 +2137,7 @@ export declare const tableKeyboardNavigationTools: {
|
|
|
2126
2137
|
contextStateRef: {
|
|
2127
2138
|
current?: TableKeyboardNavigationContextType;
|
|
2128
2139
|
};
|
|
2129
|
-
event
|
|
2140
|
+
event?: any;
|
|
2130
2141
|
}) => void;
|
|
2131
2142
|
getIdPrefix: (navigationStateRef: {
|
|
2132
2143
|
current?: TableKeyboardNavigationStateType;
|
|
@@ -2153,6 +2164,15 @@ export declare const tableKeyboardNavigationTools: {
|
|
|
2153
2164
|
current?: TableKeyboardNavigationStateType;
|
|
2154
2165
|
}) => number;
|
|
2155
2166
|
getFilterColumnId: (columnId: string) => string;
|
|
2167
|
+
focusFirstDataElement: (options: {
|
|
2168
|
+
scope?: HTMLElement;
|
|
2169
|
+
contextStateRef: {
|
|
2170
|
+
current?: TableKeyboardNavigationContextType;
|
|
2171
|
+
};
|
|
2172
|
+
navigationStateRef: {
|
|
2173
|
+
current?: TableKeyboardNavigationStateType;
|
|
2174
|
+
};
|
|
2175
|
+
}, event?: any) => void;
|
|
2156
2176
|
};
|
|
2157
2177
|
|
|
2158
2178
|
/** @hidden */
|
|
@@ -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"),t=require("./utils.js"),C=e=>{const{navigatable:r,contextStateRef:o,navigationStateRef:a,idPrefix:i}=e;r&&(o.current={activeId:"",level:0},a.current={activeElementIsFocused:!1,prevNavigationIndexes:void 0,idPrefix:i||s.guid(),navigationMatrix:[],lastHeaderIndex:-1})},D=e=>{const{scope:r,contextStateRef:o,navigationStateRef:a}=e;if(o.current&&a.current&&r){I(e);const i=t.getFirstDataCell(a.current.navigationMatrix);if(i){const n=t.tableKeyboardNavigationTools.getActiveNavDataElement(r,i);n&&(o.current.activeId=i,n.setAttribute("tabIndex","0"))}}},T=e=>{const{contextStateRef:r,navigationStateRef:o,document:a}=e;if(r.current&&o.current&&a){const i=s.getActiveElement(a),n=t.tableKeyboardNavigationTools.getNavigatableId(i);n&&n===r.current.activeId&&(o.current.activeElementIsFocused=!0)}},R=e=>{const{scope:r,contextStateRef:o,navigationStateRef:a,focusFirst:i}=e;if(i&&(C(e),D(e),t.focusFirstDataElement(e)),I(e),o.current&&a.current&&r){if(!t.tableKeyboardNavigationTools.getActiveNavDataElement(r,o.current.activeId)){const f=t.getFirstDataCell(a.current.navigationMatrix),c=t.tableKeyboardNavigationTools.getActiveNavDataElement(r,f);f&&c&&(o.current.activeId=f,c.setAttribute("tabIndex","0"),a.current.activeElementIsFocused&&c.focus())}a.current.activeElementIsFocused=!1}},S=(e,r)=>{const{contextStateRef:o}=r;if(e.isDefaultPrevented()||!o.current)return;const a=e.target,i=t.tableKeyboardNavigationTools.getNavigatableId(a);if(i&&i!==o.current.activeId){const n=t.tableKeyboardNavigationTools.getClosestScope(a);if(!n)return;const f=t.tableKeyboardNavigationTools.getActiveNavDataElement(n,o.current.activeId);f&&f.setAttribute("tabIndex","-1"),a.setAttribute("tabIndex","0"),o.current.activeId=i}},h=(e,r)=>{const{contextStateRef:o,navigationStateRef:a,onNavigationAction:i}=r;if(e.isDefaultPrevented()||!o.current||!a.current)return;let n;if(e.keyCode===s.Keys.esc){n=t.tableKeyboardNavigationTools.getClosestNavigatableElement(e.target),t.tableKeyboardNavigationTools.focusElement({elementForFocus:n,event:e,contextStateRef:o});return}const f=e.target,c=f.className.indexOf("k-checkbox")===-1?f:t.tableKeyboardNavigationTools.getClosestNavigatableElement(f),g=t.tableKeyboardNavigationTools.getNavigatableId(c),y=g==null?void 0:g.endsWith("column"),m=t.tableKeyboardNavigationTools.getNavigatableLevel(c),u=t.tableKeyboardNavigationTools.getClosestScope(c),v=a.current.navigationMatrix,N=e.metaKey||e.ctrlKey,b=t.getCurrentIdIndexes(a,v,g);if(m!==void 0&&u){if(e.keyCode===s.Keys.enter){const l=t.tableKeyboardNavigationTools.getNavigatableElement(c,{level:m+1});if(l){t.tableKeyboardNavigationTools.focusElement({elementForFocus:l,event:e,contextStateRef:o,prevElement:c});return}else{n=t.tableKeyboardNavigationTools.getFocusableElements(c)[0],t.tableKeyboardNavigationTools.focusElement({elementForFocus:n,event:e,contextStateRef:o,prevElement:c});return}}if(e.keyCode===s.Keys.home&&b)if(N)t.focusFirstDataElement({scope:u,navigationStateRef:a,contextStateRef:o},e);else{const l=t.getFirstRowDataCell(a.current.navigationMatrix,b[0]);n=t.tableKeyboardNavigationTools.getActiveNavDataElement(u,l),t.tableKeyboardNavigationTools.focusElement({elementForFocus:n,event:e,contextStateRef:o})}if(e.keyCode===s.Keys.end&&b)if(N){const l=t.getLastDataCell(a.current.navigationMatrix);n=t.tableKeyboardNavigationTools.getActiveNavDataElement(u,l),t.tableKeyboardNavigationTools.focusElement({elementForFocus:n,event:e,contextStateRef:o})}else{const l=t.getLastRowDataCell(a.current.navigationMatrix,b[0]);n=t.tableKeyboardNavigationTools.getActiveNavDataElement(u,l),t.tableKeyboardNavigationTools.focusElement({elementForFocus:n,event:e,contextStateRef:o})}if(e.keyCode===s.Keys.up||e.keyCode===s.Keys.down||e.keyCode===s.Keys.left||e.keyCode===s.Keys.right){const l=e.keyCode===s.Keys.up||e.keyCode===s.Keys.left,d=e.keyCode===s.Keys.up||e.keyCode===s.Keys.down;if(b){const[E,K]=b,[x,p]=d?t.findNextIdByRowIndex(E,K,g,v,l):t.findNextIdByCellIndex(E,K,g,v,l);x&&(n=t.tableKeyboardNavigationTools.getActiveNavDataElement(u,x),t.tableKeyboardNavigationTools.focusElement({elementForFocus:n,event:e,contextStateRef:o,prevElement:c}),a.current.prevNavigationIndexes=p)}}if(N&&e.keyCode===s.Keys.left&&y){i&&i({focusElement:c,event:e,action:"reorderToLeft"}),e.preventDefault();return}if(N&&e.keyCode===s.Keys.right&&y){i&&i({focusElement:c,event:e,action:"reorderToRight"}),e.preventDefault();return}if(e.keyCode===s.Keys.pageUp){i&&i({focusElement:n,event:e,action:"moveToNextPage"}),e.preventDefault();return}if(e.keyCode===s.Keys.pageDown){i&&i({focusElement:n,event:e,action:"moveToPrevPage"}),e.preventDefault();return}i&&i({focusElement:n,event:e})}},I=e=>{const{navigationStateRef:r,scope:o}=e;if(!r.current||!o)return;const a=[],i=t.getHeaderElement(o),n=t.getBodyElement(o),f=t.getNoRecordsElement(o)||{children:[]};if(!i||!n)return;const c=Array.from(i.children),g=Array.from(n.children);[...c,...g,f].forEach((y,m)=>{Array.from(y.children).forEach(u=>{const v=t.getNavigatableId(u);if(!v)return;const N=u.rowSpan||1,b=u.colSpan||1;let l;for(let d=m,E=m+N;d<E;d++){if(a[d]||(a[d]=[]),l===void 0){const K=a[d].findIndex(x=>!x);l=K>-1?K:a[d].length}a[d][l]=v||""}for(let d=l+1,E=l+b;d<E;d++)a[m][d]=v||""})}),r.current.navigationMatrix=a.filter(y=>!!y),r.current.lastHeaderIndex=c.length-1},F={onConstructor:C,onComponentDidMount:D,onGetSnapshotBeforeUpdate:T,onComponentDidUpdate:R,onFocus:S,onKeyDown:h,generateMatrix:I,focusFirstDataElement:t.focusFirstDataElement};exports.tableKeyboardNavigation=F;
|
|
@@ -6,140 +6,170 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import { guid as
|
|
10
|
-
import {
|
|
11
|
-
const
|
|
12
|
-
const { navigatable:
|
|
13
|
-
|
|
9
|
+
import { guid as k, getActiveElement as A, Keys as l } from "@progress/kendo-react-common";
|
|
10
|
+
import { focusFirstDataElement as D, getFirstDataCell as N, tableKeyboardNavigationTools as o, getCurrentIdIndexes as F, getFirstRowDataCell as w, getLastRowDataCell as M, getLastDataCell as P, getHeaderElement as K, getBodyElement as L, getNoRecordsElement as T, getNavigatableId as B, findNextIdByRowIndex as H, findNextIdByCellIndex as U } from "./utils.mjs";
|
|
11
|
+
const R = (e) => {
|
|
12
|
+
const { navigatable: c, contextStateRef: n, navigationStateRef: t, idPrefix: r } = e;
|
|
13
|
+
c && (n.current = {
|
|
14
14
|
activeId: "",
|
|
15
15
|
level: 0
|
|
16
16
|
}, t.current = {
|
|
17
17
|
activeElementIsFocused: !1,
|
|
18
18
|
prevNavigationIndexes: void 0,
|
|
19
|
-
idPrefix:
|
|
19
|
+
idPrefix: r || k(),
|
|
20
20
|
navigationMatrix: [],
|
|
21
21
|
lastHeaderIndex: -1
|
|
22
22
|
});
|
|
23
|
-
},
|
|
24
|
-
const { scope:
|
|
25
|
-
if (n.current && t.current &&
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
23
|
+
}, h = (e) => {
|
|
24
|
+
const { scope: c, contextStateRef: n, navigationStateRef: t } = e;
|
|
25
|
+
if (n.current && t.current && c) {
|
|
26
|
+
b(e);
|
|
27
|
+
const r = N(t.current.navigationMatrix);
|
|
28
|
+
if (r) {
|
|
29
|
+
const a = o.getActiveNavDataElement(c, r);
|
|
30
|
+
a && (n.current.activeId = r, a.setAttribute("tabIndex", "0"));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
},
|
|
34
|
-
const { contextStateRef:
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
|
|
33
|
+
}, O = (e) => {
|
|
34
|
+
const { contextStateRef: c, navigationStateRef: n, document: t } = e;
|
|
35
|
+
if (c.current && n.current && t) {
|
|
36
|
+
const r = A(t), a = o.getNavigatableId(r);
|
|
37
|
+
a && a === c.current.activeId && (n.current.activeElementIsFocused = !0);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
40
|
-
const { scope:
|
|
41
|
-
if (
|
|
42
|
-
if (!
|
|
43
|
-
const
|
|
44
|
-
|
|
39
|
+
}, G = (e) => {
|
|
40
|
+
const { scope: c, contextStateRef: n, navigationStateRef: t, focusFirst: r } = e;
|
|
41
|
+
if (r && (R(e), h(e), D(e)), b(e), n.current && t.current && c) {
|
|
42
|
+
if (!o.getActiveNavDataElement(c, n.current.activeId)) {
|
|
43
|
+
const f = N(t.current.navigationMatrix), i = o.getActiveNavDataElement(c, f);
|
|
44
|
+
f && i && (n.current.activeId = f, i.setAttribute("tabIndex", "0"), t.current.activeElementIsFocused && i.focus());
|
|
45
45
|
}
|
|
46
46
|
t.current.activeElementIsFocused = !1;
|
|
47
47
|
}
|
|
48
|
-
},
|
|
49
|
-
const { contextStateRef: n } =
|
|
48
|
+
}, V = (e, c) => {
|
|
49
|
+
const { contextStateRef: n } = c;
|
|
50
50
|
if (e.isDefaultPrevented() || !n.current)
|
|
51
51
|
return;
|
|
52
|
-
const t = e.target,
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
52
|
+
const t = e.target, r = o.getNavigatableId(t);
|
|
53
|
+
if (r && r !== n.current.activeId) {
|
|
54
|
+
const a = o.getClosestScope(t);
|
|
55
|
+
if (!a)
|
|
56
56
|
return;
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const f = o.getActiveNavDataElement(a, n.current.activeId);
|
|
58
|
+
f && f.setAttribute("tabIndex", "-1"), t.setAttribute("tabIndex", "0"), n.current.activeId = r;
|
|
59
59
|
}
|
|
60
|
-
},
|
|
60
|
+
}, W = (e, c) => {
|
|
61
61
|
const {
|
|
62
62
|
contextStateRef: n,
|
|
63
63
|
navigationStateRef: t,
|
|
64
|
-
onNavigationAction:
|
|
65
|
-
} =
|
|
64
|
+
onNavigationAction: r
|
|
65
|
+
} = c;
|
|
66
66
|
if (e.isDefaultPrevented() || !n.current || !t.current)
|
|
67
67
|
return;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
a.focusElement({ elementForFocus:
|
|
68
|
+
let a;
|
|
69
|
+
if (e.keyCode === l.esc) {
|
|
70
|
+
a = o.getClosestNavigatableElement(e.target), o.focusElement({ elementForFocus: a, event: e, contextStateRef: n });
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
if (e.keyCode ===
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
elementForFocus:
|
|
73
|
+
const f = e.target, i = f.className.indexOf("k-checkbox") === -1 ? f : o.getClosestNavigatableElement(f), g = o.getNavigatableId(i), E = g == null ? void 0 : g.endsWith("column"), x = o.getNavigatableLevel(i), u = o.getClosestScope(i), v = t.current.navigationMatrix, I = e.metaKey || e.ctrlKey, m = F(t, v, g);
|
|
74
|
+
if (x !== void 0 && u) {
|
|
75
|
+
if (e.keyCode === l.enter) {
|
|
76
|
+
const s = o.getNavigatableElement(i, { level: x + 1 });
|
|
77
|
+
if (s) {
|
|
78
|
+
o.focusElement({
|
|
79
|
+
elementForFocus: s,
|
|
80
80
|
event: e,
|
|
81
81
|
contextStateRef: n,
|
|
82
82
|
prevElement: i
|
|
83
83
|
});
|
|
84
84
|
return;
|
|
85
85
|
} else {
|
|
86
|
-
|
|
87
|
-
a.focusElement({ elementForFocus: E, event: e, contextStateRef: n, prevElement: i });
|
|
86
|
+
a = o.getFocusableElements(i)[0], o.focusElement({ elementForFocus: a, event: e, contextStateRef: n, prevElement: i });
|
|
88
87
|
return;
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
if (e.keyCode ===
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
90
|
+
if (e.keyCode === l.home && m)
|
|
91
|
+
if (I)
|
|
92
|
+
D(
|
|
93
|
+
{
|
|
94
|
+
scope: u,
|
|
95
|
+
navigationStateRef: t,
|
|
96
|
+
contextStateRef: n
|
|
97
|
+
},
|
|
98
|
+
e
|
|
99
|
+
);
|
|
100
|
+
else {
|
|
101
|
+
const s = w(t.current.navigationMatrix, m[0]);
|
|
102
|
+
a = o.getActiveNavDataElement(u, s), o.focusElement({ elementForFocus: a, event: e, contextStateRef: n });
|
|
103
|
+
}
|
|
104
|
+
if (e.keyCode === l.end && m)
|
|
105
|
+
if (I) {
|
|
106
|
+
const s = P(t.current.navigationMatrix);
|
|
107
|
+
a = o.getActiveNavDataElement(u, s), o.focusElement({ elementForFocus: a, event: e, contextStateRef: n });
|
|
108
|
+
} else {
|
|
109
|
+
const s = M(t.current.navigationMatrix, m[0]);
|
|
110
|
+
a = o.getActiveNavDataElement(u, s), o.focusElement({ elementForFocus: a, event: e, contextStateRef: n });
|
|
105
111
|
}
|
|
112
|
+
if (e.keyCode === l.up || e.keyCode === l.down || e.keyCode === l.left || e.keyCode === l.right) {
|
|
113
|
+
const s = e.keyCode === l.up || e.keyCode === l.left, d = e.keyCode === l.up || e.keyCode === l.down;
|
|
114
|
+
if (m) {
|
|
115
|
+
const [p, C] = m, [y, S] = d ? H(p, C, g, v, s) : U(p, C, g, v, s);
|
|
116
|
+
y && (a = o.getActiveNavDataElement(u, y), o.focusElement({ elementForFocus: a, event: e, contextStateRef: n, prevElement: i }), t.current.prevNavigationIndexes = S);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (I && e.keyCode === l.left && E) {
|
|
120
|
+
r && r({ focusElement: i, event: e, action: "reorderToLeft" }), e.preventDefault();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (I && e.keyCode === l.right && E) {
|
|
124
|
+
r && r({ focusElement: i, event: e, action: "reorderToRight" }), e.preventDefault();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (e.keyCode === l.pageUp) {
|
|
128
|
+
r && r({ focusElement: a, event: e, action: "moveToNextPage" }), e.preventDefault();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (e.keyCode === l.pageDown) {
|
|
132
|
+
r && r({ focusElement: a, event: e, action: "moveToPrevPage" }), e.preventDefault();
|
|
133
|
+
return;
|
|
106
134
|
}
|
|
135
|
+
r && r({ focusElement: a, event: e });
|
|
107
136
|
}
|
|
108
|
-
},
|
|
109
|
-
const { navigationStateRef:
|
|
110
|
-
if (!
|
|
137
|
+
}, b = (e) => {
|
|
138
|
+
const { navigationStateRef: c, scope: n } = e;
|
|
139
|
+
if (!c.current || !n)
|
|
111
140
|
return;
|
|
112
|
-
const t = [],
|
|
113
|
-
if (!
|
|
141
|
+
const t = [], r = K(n), a = L(n), f = T(n) || { children: [] };
|
|
142
|
+
if (!r || !a)
|
|
114
143
|
return;
|
|
115
|
-
const i = Array.from(
|
|
116
|
-
[...i, ...
|
|
117
|
-
Array.from(
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
144
|
+
const i = Array.from(r.children), g = Array.from(a.children);
|
|
145
|
+
[...i, ...g, f].forEach((E, x) => {
|
|
146
|
+
Array.from(E.children).forEach((u) => {
|
|
147
|
+
const v = B(u);
|
|
148
|
+
if (!v)
|
|
120
149
|
return;
|
|
121
|
-
const
|
|
122
|
-
let
|
|
123
|
-
for (let
|
|
124
|
-
if (t[
|
|
125
|
-
const
|
|
126
|
-
|
|
150
|
+
const I = u.rowSpan || 1, m = u.colSpan || 1;
|
|
151
|
+
let s;
|
|
152
|
+
for (let d = x, p = x + I; d < p; d++) {
|
|
153
|
+
if (t[d] || (t[d] = []), s === void 0) {
|
|
154
|
+
const C = t[d].findIndex((y) => !y);
|
|
155
|
+
s = C > -1 ? C : t[d].length;
|
|
127
156
|
}
|
|
128
|
-
t[
|
|
157
|
+
t[d][s] = v || "";
|
|
129
158
|
}
|
|
130
|
-
for (let
|
|
131
|
-
t[
|
|
159
|
+
for (let d = s + 1, p = s + m; d < p; d++)
|
|
160
|
+
t[x][d] = v || "";
|
|
132
161
|
});
|
|
133
|
-
}),
|
|
134
|
-
},
|
|
135
|
-
onConstructor:
|
|
136
|
-
onComponentDidMount:
|
|
137
|
-
onGetSnapshotBeforeUpdate:
|
|
138
|
-
onComponentDidUpdate:
|
|
139
|
-
onFocus:
|
|
140
|
-
onKeyDown:
|
|
141
|
-
generateMatrix:
|
|
162
|
+
}), c.current.navigationMatrix = t.filter((E) => !!E), c.current.lastHeaderIndex = i.length - 1;
|
|
163
|
+
}, z = {
|
|
164
|
+
onConstructor: R,
|
|
165
|
+
onComponentDidMount: h,
|
|
166
|
+
onGetSnapshotBeforeUpdate: O,
|
|
167
|
+
onComponentDidUpdate: G,
|
|
168
|
+
onFocus: V,
|
|
169
|
+
onKeyDown: W,
|
|
170
|
+
generateMatrix: b,
|
|
171
|
+
focusFirstDataElement: D
|
|
142
172
|
};
|
|
143
173
|
export {
|
|
144
|
-
|
|
174
|
+
z as tableKeyboardNavigation
|
|
145
175
|
};
|
package/navigation/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 c=require("@progress/kendo-react-common"),a=require("./constants.js"),d=(e,t,r="cell")=>`${t}_${e}_${r}`,f=e=>{if(e)return parseInt(e.getAttribute(a.KEYBOARD_NAV_DATA_LEVEL)||"",10)},E=e=>{if(!e)return;const t=e.getAttribute(a.KEYBOARD_NAV_DATA_ID);return t||void 0},u=e=>e?!!e.getAttribute(a.KEYBOARD_NAV_DATA_ID):!1,N=(e,t={level:0})=>e.querySelector(`[${a.KEYBOARD_NAV_DATA_LEVEL}='${t.level}']`),_=e=>e&&e.parentElement&&e.parentElement.closest(`[${a.KEYBOARD_NAV_DATA_LEVEL}]`),g=(e,t)=>e.querySelector(`[${a.KEYBOARD_NAV_DATA_ID}='${t}']`),D=e=>e&&e.parentElement&&e.parentElement.closest(`[${a.KEYBOARD_NAV_DATA_SCOPE}]`),I=e=>e.querySelector(`[${a.KEYBOARD_NAV_DATA_HEADER}]`),v=e=>e.querySelector(`[${a.KEYBOARD_NAV_DATA_BODY}]`),O=e=>e.querySelector(".k-grid-norecords"),b=(e,t)=>{const{scope:r,navigationStateRef:n,contextStateRef:o}=e;if(!n.current||!r)return;const l=R(n.current.navigationMatrix),s=g(r,l);A({elementForFocus:s,contextStateRef:o,event:t})},m=(e,t={focusable:!1})=>{const r=t.focusable?c.FOCUSABLE_ELEMENTS:c.TABBABLE_ELEMENTS;return Array.from(e.querySelectorAll(r.join(",")))},x=(e,t={level:0})=>{if(!e)return[];const r=c.FOCUSABLE_ELEMENTS.map(n=>n+`[${a.KEYBOARD_NAV_DATA_LEVEL}='${t.level}']`).join(",");return Array.from(e.querySelectorAll(r))},C=(e={level:0})=>{const t=c.FOCUSABLE_ELEMENTS.map(r=>r+`[${a.KEYBOARD_NAV_DATA_LEVEL}='${e.level}']`).join(",");return r=>r.matches(t)},A=e=>{const{elementForFocus:t,event:r,contextStateRef:n,prevElement:o}=e;if(n.current&&t&&t.focus){r==null||r.preventDefault();const l=t.querySelector(".k-checkbox-wrap .k-checkbox");l&&l.focus?l.focus():t.focus(),u(t)&&(t.setAttribute("tabIndex","0"),n.current.activeId=E(t)),o&&u(o)&&o.setAttribute("tabIndex","-1")}},B=e=>e.current?e.current.idPrefix:"",L=(e,t,r,n,o)=>{if(!r)return[];let l=e+(o?-1:1);for(;l>=0&&l<n.length;){const s=n[l][t];if(s!==r)return[s,[l,t]];l=l+(o?-1:1)}return[]},y=(e,t,r,n,o)=>{if(!r)return[];let l=t+(o?-1:1);for(;l>=0&&l<n[e].length;){const s=n[e][l];if(s!==r)return[s,[e,l]];l=l+(o?-1:1)}return[]},i=(e,t)=>{if(t){for(let r=0;r<e.length;r++)for(let n=0;n<e[r].length;n++)if(e[r][n]===t)return[r,n]}},F=e=>e.current?e.current.navigationMatrix.length:0,R=e=>e.flat().find(t=>t.endsWith("cell")),S=e=>e.flat().reverse().find(t=>t.endsWith("cell")),V=(e,t)=>e[t][0],$=(e,t)=>Array.from(e[t]).reverse()[0],T=e=>e?`${e}${a.KEYBOARD_NAV_FILTER_COL_SUFFIX}`:"",p=(e,t,r)=>{let n;if(e.current&&e.current.prevNavigationIndexes){const[o,l]=e.current.prevNavigationIndexes;t[o][l]===r?n=e.current.prevNavigationIndexes:n=i(t,r)}else n=i(t,r);return n},K={generateNavigatableId:d,getNavigatableId:E,getNavigatableLevel:f,getNavigatableElement:N,getClosestNavigatableElement:_,getActiveNavDataElement:g,getClosestScope:D,getHeaderElement:I,getBodyElement:v,getFocusableElements:m,getNavigatableElements:x,filterNavigatableElements:C,focusElement:A,getIdPrefix:B,isNavigatable:u,findNextIdByRowIndex:L,findNextIdByCellIndex:y,findId:i,getNextNavigationIndex:F,getFilterColumnId:T,focusFirstDataElement:b};exports.filterNavigatableElements=C;exports.findId=i;exports.findNextIdByCellIndex=y;exports.findNextIdByRowIndex=L;exports.focusElement=A;exports.focusFirstDataElement=b;exports.generateNavigatableId=d;exports.getActiveNavDataElement=g;exports.getBodyElement=v;exports.getClosestNavigatableElement=_;exports.getClosestScope=D;exports.getCurrentIdIndexes=p;exports.getFilterColumnId=T;exports.getFirstDataCell=R;exports.getFirstRowDataCell=V;exports.getFocusableElements=m;exports.getHeaderElement=I;exports.getIdPrefix=B;exports.getLastDataCell=S;exports.getLastRowDataCell=$;exports.getNavigatableElement=N;exports.getNavigatableElements=x;exports.getNavigatableId=E;exports.getNavigatableLevel=f;exports.getNextNavigationIndex=F;exports.getNoRecordsElement=O;exports.isNavigatable=u;exports.tableKeyboardNavigationTools=K;
|