@semcore/data-table 16.3.2 → 16.4.0-prerelease.3
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/CHANGELOG.md +14 -0
- package/lib/cjs/components/Body/Body.js +58 -53
- package/lib/cjs/components/Body/Body.js.map +1 -1
- package/lib/cjs/components/Body/Body.types.js.map +1 -1
- package/lib/cjs/components/Body/Cell.js +62 -107
- package/lib/cjs/components/Body/Cell.js.map +1 -1
- package/lib/cjs/components/Body/LimitOverlay.js +190 -0
- package/lib/cjs/components/Body/LimitOverlay.js.map +1 -0
- package/lib/cjs/components/Body/Row.js +161 -109
- package/lib/cjs/components/Body/Row.js.map +1 -1
- package/lib/cjs/components/Body/Row.types.js.map +1 -1
- package/lib/cjs/components/Body/style.shadow.css +94 -42
- package/lib/cjs/components/DataTable/DataTable.js +61 -41
- package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
- package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -1
- package/lib/cjs/components/DataTable/dataTable.shadow.css +1 -0
- package/lib/cjs/components/Head/Column.js +45 -92
- package/lib/cjs/components/Head/Column.js.map +1 -1
- package/lib/cjs/components/Head/Group.js +38 -41
- package/lib/cjs/components/Head/Group.js.map +1 -1
- package/lib/cjs/components/Head/Head.js +38 -41
- package/lib/cjs/components/Head/Head.js.map +1 -1
- package/lib/cjs/enhancers/focusableCell.js +63 -0
- package/lib/cjs/enhancers/focusableCell.js.map +1 -0
- package/lib/es6/components/Body/Body.js +57 -52
- package/lib/es6/components/Body/Body.js.map +1 -1
- package/lib/es6/components/Body/Body.types.js.map +1 -1
- package/lib/es6/components/Body/Cell.js +61 -106
- package/lib/es6/components/Body/Cell.js.map +1 -1
- package/lib/es6/components/Body/LimitOverlay.js +183 -0
- package/lib/es6/components/Body/LimitOverlay.js.map +1 -0
- package/lib/es6/components/Body/Row.js +160 -108
- package/lib/es6/components/Body/Row.js.map +1 -1
- package/lib/es6/components/Body/Row.types.js.map +1 -1
- package/lib/es6/components/Body/style.shadow.css +94 -42
- package/lib/es6/components/DataTable/DataTable.js +60 -40
- package/lib/es6/components/DataTable/DataTable.js.map +1 -1
- package/lib/es6/components/DataTable/DataTable.types.js.map +1 -1
- package/lib/es6/components/DataTable/dataTable.shadow.css +1 -0
- package/lib/es6/components/Head/Column.js +44 -91
- package/lib/es6/components/Head/Column.js.map +1 -1
- package/lib/es6/components/Head/Group.js +37 -40
- package/lib/es6/components/Head/Group.js.map +1 -1
- package/lib/es6/components/Head/Head.js +37 -40
- package/lib/es6/components/Head/Head.js.map +1 -1
- package/lib/es6/enhancers/focusableCell.js +56 -0
- package/lib/es6/enhancers/focusableCell.js.map +1 -0
- package/lib/esm/components/Body/Body.mjs +58 -56
- package/lib/esm/components/Body/Cell.mjs +62 -109
- package/lib/esm/components/Body/LimitOverlay.mjs +178 -0
- package/lib/esm/components/Body/Row.mjs +125 -85
- package/lib/esm/components/Body/style.shadow.css +94 -42
- package/lib/esm/components/DataTable/DataTable.mjs +59 -42
- package/lib/esm/components/DataTable/dataTable.shadow.css +1 -0
- package/lib/esm/components/Head/Column.mjs +45 -94
- package/lib/esm/components/Head/Group.mjs +38 -43
- package/lib/esm/components/Head/Head.mjs +38 -43
- package/lib/esm/enhancers/focusableCell.mjs +59 -0
- package/lib/types/components/Body/Body.types.d.ts +2 -1
- package/lib/types/components/Body/LimitOverlay.d.ts +17 -0
- package/lib/types/components/Body/Row.d.ts +1 -0
- package/lib/types/components/Body/Row.types.d.ts +3 -0
- package/lib/types/components/DataTable/DataTable.types.d.ts +19 -0
- package/lib/types/components/Head/Column.d.ts +5 -4
- package/lib/types/enhancers/focusableCell.d.ts +9 -0
- package/package.json +22 -22
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getFocusableIn } from "@semcore/core/lib/utils/focus-lock/getFocusableIn";
|
|
2
|
+
function handleFocusCell(lockedCell, target, currentTarget) {
|
|
3
|
+
if (target instanceof HTMLElement && currentTarget instanceof HTMLElement && target === currentTarget && target.matches(":focus-visible")) {
|
|
4
|
+
target.scrollIntoView({
|
|
5
|
+
behavior: "smooth",
|
|
6
|
+
block: "center",
|
|
7
|
+
inline: "center"
|
|
8
|
+
});
|
|
9
|
+
var focusableChildren = Array.from(currentTarget.children).flatMap(function(node) {
|
|
10
|
+
return getFocusableIn(node);
|
|
11
|
+
});
|
|
12
|
+
if (focusableChildren.length === 1) {
|
|
13
|
+
focusableChildren[0].focus();
|
|
14
|
+
} else if (focusableChildren.length > 1) {
|
|
15
|
+
lockedCell[0] = currentTarget;
|
|
16
|
+
lockedCell[1] = false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function handleKeydownFocusCell(lockedCell, e) {
|
|
21
|
+
if (e.currentTarget === lockedCell[0]) {
|
|
22
|
+
var focusableChildren = Array.from(lockedCell[0].children).flatMap(function(node) {
|
|
23
|
+
return getFocusableIn(node);
|
|
24
|
+
});
|
|
25
|
+
if (lockedCell[1]) {
|
|
26
|
+
if (e.key === "Escape") {
|
|
27
|
+
var _lockedCell$;
|
|
28
|
+
(_lockedCell$ = lockedCell[0]) === null || _lockedCell$ === void 0 || _lockedCell$.focus();
|
|
29
|
+
lockedCell[1] = false;
|
|
30
|
+
}
|
|
31
|
+
if (e.key.startsWith("Arrow")) {
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
}
|
|
35
|
+
if (e.key === "Tab") {
|
|
36
|
+
if (e.target === focusableChildren[0] && e.shiftKey) {
|
|
37
|
+
var _focusableChildren;
|
|
38
|
+
(_focusableChildren = focusableChildren[focusableChildren.length - 1]) === null || _focusableChildren === void 0 || _focusableChildren.focus();
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
} else if (e.target === focusableChildren[focusableChildren.length - 1] && !e.shiftKey) {
|
|
41
|
+
var _focusableChildren$;
|
|
42
|
+
(_focusableChildren$ = focusableChildren[0]) === null || _focusableChildren$ === void 0 || _focusableChildren$.focus();
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
}
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
}
|
|
47
|
+
} else if (e.key === "Enter") {
|
|
48
|
+
var _focusableChildren$2;
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
lockedCell[1] = true;
|
|
52
|
+
(_focusableChildren$2 = focusableChildren[0]) === null || _focusableChildren$2 === void 0 || _focusableChildren$2.focus();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
handleFocusCell,
|
|
58
|
+
handleKeydownFocusCell
|
|
59
|
+
};
|
|
@@ -78,7 +78,8 @@ export type BodyPropsInner<Data extends DataTableData, UniqKeyType> = DataTableB
|
|
|
78
78
|
accordionMode?: DataTableProps<any, any, any>['accordionMode'];
|
|
79
79
|
shadowVertical?: '' | 'end' | 'start' | 'median';
|
|
80
80
|
renderCellOverlay?: () => React.ReactNode;
|
|
81
|
-
|
|
81
|
+
limit?: DataTableProps<any, any, any>['limit'];
|
|
82
82
|
variant?: DataTableProps<any, any, any>['variant'];
|
|
83
|
+
totalRows?: number;
|
|
83
84
|
};
|
|
84
85
|
export type DataTableBodyType = (<Data extends DataTableData, UniqKeyType, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', DataTableBodyProps<Data, UniqKeyType>>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableBodyProps<any, any>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Intergalactic } from '@semcore/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { DTRow, DTRows } from './Row.types';
|
|
4
|
+
import type { DataTableProps } from '../DataTable/DataTable.types';
|
|
5
|
+
import type { DTColumn } from '../Head/Column.types';
|
|
6
|
+
type LimitOverlayProps<UniqKeyType> = {
|
|
7
|
+
columns: DTColumn[];
|
|
8
|
+
rows: DTRows<UniqKeyType>;
|
|
9
|
+
limit: Exclude<DataTableProps<any, any, any>['limit'], undefined>;
|
|
10
|
+
flatRows: DTRow<UniqKeyType>[];
|
|
11
|
+
hasGroups: boolean;
|
|
12
|
+
tableRef: React.RefObject<HTMLDivElement>;
|
|
13
|
+
scrollAreaRef: React.RefObject<HTMLDivElement>;
|
|
14
|
+
};
|
|
15
|
+
type LimitOverlayType = (<UniqKeyType, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', LimitOverlayProps<UniqKeyType>>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', LimitOverlayProps<any>>;
|
|
16
|
+
export declare const LimitOverlay: LimitOverlayType;
|
|
17
|
+
export {};
|
|
@@ -37,6 +37,7 @@ export declare class RowRoot<Data extends DataTableData, UniqKeyType> extends Co
|
|
|
37
37
|
rowIndex: number;
|
|
38
38
|
}) => void;
|
|
39
39
|
getCellProps(props: DataTableCellProps<UniqKeyType>): Record<string, any>;
|
|
40
|
+
get isRowHidden(): true | undefined;
|
|
40
41
|
render(): React.ReactNode;
|
|
41
42
|
private isReactNode;
|
|
42
43
|
private calculateRowHeight;
|
|
@@ -65,5 +65,8 @@ export type RowPropsInner<Data extends DataTableData, UniqKeyType> = JSX.Intrins
|
|
|
65
65
|
componentsMap: Map<UniqKeyType, RowRoot<Data, UniqKeyType>>;
|
|
66
66
|
calculateAriaRowIndex: () => void;
|
|
67
67
|
variant?: DataTableProps<any, any, any>['variant'];
|
|
68
|
+
limit?: DataTableProps<any, any, any>['limit'];
|
|
69
|
+
totalRows?: number;
|
|
70
|
+
hasGroups: boolean;
|
|
68
71
|
};
|
|
69
72
|
export type DataTableRowType = (<Data extends DataTableData, UniqKeyType, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', DataTableRowProps<Data, UniqKeyType>>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableRowProps<any, any>>;
|
|
@@ -117,11 +117,30 @@ export type DataTableProps<Data extends DataTableData, UniqKey extends keyof Dat
|
|
|
117
117
|
* Work only with table-in-table accordions. In accordions with custom components use mount/unmount hooks in components.
|
|
118
118
|
*/
|
|
119
119
|
onAccordionToggle?: (type: 'open' | 'close', uniqRowKey: UniqKeyType, rowIndex: number) => void;
|
|
120
|
+
/** Defines a limit configuration */
|
|
121
|
+
limit?: {
|
|
122
|
+
/**
|
|
123
|
+
* Start limit from this row
|
|
124
|
+
* @default 0
|
|
125
|
+
*/
|
|
126
|
+
fromRow?: number;
|
|
127
|
+
/**
|
|
128
|
+
* Start limit from this column
|
|
129
|
+
* @default 0
|
|
130
|
+
*/
|
|
131
|
+
fromColumn?: number;
|
|
132
|
+
/** Limit overlay */
|
|
133
|
+
renderOverlay: () => React.ReactNode;
|
|
134
|
+
};
|
|
120
135
|
/**
|
|
121
136
|
* Visual variant that adapts the table styling to different usage contexts
|
|
122
137
|
* @default 'default'
|
|
123
138
|
*/
|
|
124
139
|
variant?: 'default' | 'card';
|
|
140
|
+
/**
|
|
141
|
+
* Handle change expanded rows
|
|
142
|
+
*/
|
|
143
|
+
onExpandedRowsChange?: (expandedRows: Set<UniqKeyType>) => void;
|
|
125
144
|
};
|
|
126
145
|
export type ColumnItemConfig = Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<'div' | typeof Tooltip, 'div', DataTableColumnProps, {}, [
|
|
127
146
|
]>, 'children'> & {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Component } from '@semcore/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { ColumnPropsInner, DataTableColumnProps } from './Column.types';
|
|
4
|
+
import type { IFocusableCell, LockedCell } from '../../enhancers/focusableCell';
|
|
4
5
|
import type { DataTableData, SortDirection } from '../DataTable/DataTable.types';
|
|
5
6
|
type State = {
|
|
6
7
|
sortVisible: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare class Column<Data extends DataTableData, UniqKey extends keyof Data[number], UniqKeyType extends Data[number][UniqKey]> extends Component<DataTableColumnProps, {}, {}, [
|
|
9
|
-
], ColumnPropsInner<Data, UniqKey, UniqKeyType>> {
|
|
10
|
+
], ColumnPropsInner<Data, UniqKey, UniqKeyType>> implements IFocusableCell {
|
|
11
|
+
lockedCell: LockedCell;
|
|
10
12
|
static displayName: string;
|
|
11
13
|
static style: {
|
|
12
14
|
[key: string]: string;
|
|
13
15
|
};
|
|
14
|
-
lockedCell: [HTMLElement | null, boolean];
|
|
15
16
|
columnRef: React.RefObject<HTMLDivElement>;
|
|
16
17
|
sortWrapperRef: React.RefObject<HTMLDivElement>;
|
|
17
18
|
state: State;
|
|
@@ -24,8 +25,8 @@ export declare class Column<Data extends DataTableData, UniqKey extends keyof Da
|
|
|
24
25
|
handleMouseLeave: () => void;
|
|
25
26
|
handleBlur: (e: React.FocusEvent<HTMLElement>) => void;
|
|
26
27
|
handleSortClick: (e: React.SyntheticEvent<HTMLElement>) => void;
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
handleFocusableCellKeyDown: (e: React.KeyboardEvent) => void;
|
|
29
|
+
handleFocusableCellFocus: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
|
|
29
30
|
handleClick: (e: React.SyntheticEvent<HTMLElement>) => void;
|
|
30
31
|
render(): React.ReactNode;
|
|
31
32
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export type LockedCell = [HTMLElement | null, boolean];
|
|
3
|
+
export declare function handleFocusCell(lockedCell: LockedCell, target: Element, currentTarget: Element): void;
|
|
4
|
+
export declare function handleKeydownFocusCell(lockedCell: LockedCell, e: React.KeyboardEvent): void;
|
|
5
|
+
export interface IFocusableCell {
|
|
6
|
+
lockedCell: LockedCell;
|
|
7
|
+
handleFocusableCellKeyDown: (e: React.KeyboardEvent) => void;
|
|
8
|
+
handleFocusableCellFocus: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/data-table",
|
|
3
3
|
"description": "Semrush DataTable Component",
|
|
4
|
-
"version": "16.3
|
|
4
|
+
"version": "16.4.0-prerelease.3",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,34 +14,34 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/icon": "16.
|
|
18
|
-
"@semcore/button": "16.0.
|
|
19
|
-
"@semcore/checkbox": "16.
|
|
20
|
-
"@semcore/flex-box": "16.0.
|
|
21
|
-
"@semcore/scroll-area": "16.0.
|
|
22
|
-
"@semcore/spin": "16.0.
|
|
23
|
-
"@semcore/tooltip": "16.0.
|
|
24
|
-
"@semcore/widget-empty": "16.0.
|
|
17
|
+
"@semcore/icon": "16.5.1-prerelease.3",
|
|
18
|
+
"@semcore/button": "16.0.10-prerelease.3",
|
|
19
|
+
"@semcore/checkbox": "16.2.0-prerelease.3",
|
|
20
|
+
"@semcore/flex-box": "16.0.10-prerelease.3",
|
|
21
|
+
"@semcore/scroll-area": "16.0.10-prerelease.3",
|
|
22
|
+
"@semcore/spin": "16.0.10-prerelease.3",
|
|
23
|
+
"@semcore/tooltip": "16.0.10-prerelease.3",
|
|
24
|
+
"@semcore/widget-empty": "16.0.10-prerelease.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "18.16.15",
|
|
28
28
|
"csstype": "3.1.3",
|
|
29
29
|
"@semcore/testing-utils": "1.0.0",
|
|
30
|
-
"@semcore/
|
|
31
|
-
"@semcore/
|
|
32
|
-
"@semcore/
|
|
33
|
-
"@semcore/accordion": "16.
|
|
34
|
-
"@semcore/
|
|
35
|
-
"@semcore/
|
|
36
|
-
"@semcore/
|
|
37
|
-
"@semcore/
|
|
38
|
-
"@semcore/
|
|
39
|
-
"@semcore/spin-container": "16.0.
|
|
40
|
-
"@semcore/
|
|
41
|
-
"@semcore/
|
|
30
|
+
"@semcore/base-trigger": "16.4.2-prerelease.3",
|
|
31
|
+
"@semcore/dropdown-menu": "16.1.11-prerelease.3",
|
|
32
|
+
"@semcore/typography": "16.3.0-prerelease.3",
|
|
33
|
+
"@semcore/accordion": "16.7.0-prerelease.3",
|
|
34
|
+
"@semcore/divider": "16.0.10-prerelease.3",
|
|
35
|
+
"@semcore/portal": "16.0.10-prerelease.3",
|
|
36
|
+
"@semcore/progress-bar": "16.0.10-prerelease.3",
|
|
37
|
+
"@semcore/spin": "16.0.10-prerelease.3",
|
|
38
|
+
"@semcore/skeleton": "16.0.10-prerelease.3",
|
|
39
|
+
"@semcore/spin-container": "16.0.10-prerelease.3",
|
|
40
|
+
"@semcore/tooltip": "16.0.10-prerelease.3",
|
|
41
|
+
"@semcore/base-components": "16.4.0-prerelease.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@semcore/base-components": "^16.0.
|
|
44
|
+
"@semcore/base-components": "^16.4.0-prerelease.3"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|