@pibit.ai/cure-design-system 0.3.35 → 0.3.37
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -85
- package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
- package/dist/patterns/table/TableWrapper.js +677 -665
- package/dist/patterns/table/index.d.ts +2 -1
- package/dist/patterns/table/index.d.ts.map +1 -1
- package/dist/patterns/table/scrollCellIntoView.d.ts +48 -0
- package/dist/patterns/table/scrollCellIntoView.d.ts.map +1 -0
- package/dist/patterns/table/scrollCellIntoView.js +122 -0
- package/dist/patterns/table/useGridKeyboardNavigation.d.ts +14 -3
- package/dist/patterns/table/useGridKeyboardNavigation.d.ts.map +1 -1
- package/dist/patterns/table/useGridKeyboardNavigation.js +47 -46
- package/package.json +1 -1
|
@@ -10,7 +10,8 @@ export { TOOLBAR_ICONS } from './toolbar-icons';
|
|
|
10
10
|
export type { TableColumnSchema, TableColumnMenuSchema, TableColumnValueType } from './types';
|
|
11
11
|
export { TableToolbar, pickCoreToolbarProps, registerToolbarExtensions, getToolbarExtensions, RowHeightDropdown, HideFieldsDropdown, AlignDropdown, GroupByDropdown, ShowSummaryDropdown, SummaryFooterRow, ColumnHeaderMenu, RowActionsMenu, BulkActionBar, applyHideAndReorder, getDefaultAlignmentForType, getEffectiveAlignment, alignmentClass, getAggregationsForType, computeAggregation, groupRows, resolveColumnLabel, resolveSummaryDisplayValueType, ROW_HEIGHT_CLASS, AGGREGATION_LABELS, } from './toolbar';
|
|
12
12
|
export type { SearchToolConfig, SortToolConfig, FilterToolConfig, RowHeightToolConfig, HideFieldsToolConfig, AlignToolConfig, GroupByToolConfig, SummaryToolConfig, UndoRedoToolConfig, ToolbarExtensionComponents, LegacySortToolConfig, LegacyFilterToolConfig, RowHeightOption, SummaryFooterRowProps, ColumnMenuAction, ColumnMenuCapabilities, RowActionsConfig, CellAlignment, AggregationType, AggregationOption, RowGroup, } from './toolbar';
|
|
13
|
-
export { GridNavProvider, useGridKeyboardNavigation, isWithinCellEditor, findGridCell, focusGridCell, getGridNeighbor, getGridTabNeighbor, type GridNavDirection, type GridNeighbor, type GridNavValue, } from './useGridKeyboardNavigation';
|
|
13
|
+
export { GridNavProvider, useGridKeyboardNavigation, isWithinCellEditor, findGridCell, focusGridCell, getGridNeighbor, getGridTabNeighbor, type FocusGridCellOptions, type GridNavDirection, type GridNeighbor, type GridNavValue, } from './useGridKeyboardNavigation';
|
|
14
|
+
export { CELL_SCROLL_PADDING_PX, computeCellScrollDelta, getAxisScrollParent, getScrollportRect, measureStickyInsets, scrollGridCellIntoView, type CellScrollDelta, type EdgeRect, type GridScrollDirection, type StickyInsets, } from './scrollCellIntoView';
|
|
14
15
|
export { TableUndoRedoProvider, useTableUndoRedo, useTableUndoRedoScope, MAX_HISTORY, wrapColumnHeaderActionWithUndoRedo, wrapEditChromeWithUndoRedo, wrapRowActionsWithUndoRedo, wrapSummaryFooterWithUndoRedo, wrapToolbarWithUndoRedo, type TableUndoRedoRegistration, type TableUndoRedoScopeApi, type TableUndoRedoState, type TableUndoSnapshot, } from './useTableUndoRedo';
|
|
15
16
|
export { useIntegrateTableUndoRedo, type IntegrateTableUndoRedoOptions, type IntegrateTableUndoRedoResult, } from './integrateTableUndoRedo';
|
|
16
17
|
export { applyTableUndoSnapshot, captureTableUndoSnapshot, } from './tableUndoRedo';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,YAAY,EACV,4BAA4B,EAC5B,yBAAyB,EACzB,iBAAiB,EACjB,sB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,EAChB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,kCAAkC,EAClC,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,yBAAyB,EACzB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,GAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,KAAK,+BAA+B,GACrC,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,YAAY,EACV,4BAA4B,EAC5B,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB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,EAClB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,kCAAkC,EAClC,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,yBAAyB,EACzB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,GAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,KAAK,+BAA+B,GACrC,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps the active/focus cell fully visible while a range is being selected.
|
|
3
|
+
*
|
|
4
|
+
* The browser's implicit scroll from `element.focus()` is not enough here: it targets the inner
|
|
5
|
+
* focus wrapper (so cell padding and the 2px range border stay clipped) and it ignores sticky
|
|
6
|
+
* overlays, parking the cell underneath the sticky header or a sticky first/last column.
|
|
7
|
+
*/
|
|
8
|
+
export type GridScrollDirection = "up" | "down" | "left" | "right";
|
|
9
|
+
/** Gap kept between the cell and the visible edge so the range border is never flush/clipped. */
|
|
10
|
+
export declare const CELL_SCROLL_PADDING_PX = 4;
|
|
11
|
+
/** Widths/heights of the sticky overlays covering each edge of a scrollport. */
|
|
12
|
+
export type StickyInsets = {
|
|
13
|
+
top: number;
|
|
14
|
+
right: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
left: number;
|
|
17
|
+
};
|
|
18
|
+
export type EdgeRect = {
|
|
19
|
+
top: number;
|
|
20
|
+
right: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
left: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
export type CellScrollDelta = {
|
|
27
|
+
dx: number;
|
|
28
|
+
dy: number;
|
|
29
|
+
};
|
|
30
|
+
export declare const NO_STICKY_INSETS: StickyInsets;
|
|
31
|
+
/** Nearest ancestor (self included) that actually scrolls on `axis`, else the page scroller. */
|
|
32
|
+
export declare const getAxisScrollParent: (start: HTMLElement | null, axis: "x" | "y") => HTMLElement | null;
|
|
33
|
+
/** Visible box of a scroller: the page scroller's box is the viewport, not its full content. */
|
|
34
|
+
export declare const getScrollportRect: (scroller: HTMLElement) => EdgeRect;
|
|
35
|
+
/**
|
|
36
|
+
* How far sticky chrome (header row, sticky columns) intrudes on each edge of `port`.
|
|
37
|
+
*
|
|
38
|
+
* A sticky element only counts while it is actually parked against that edge — once it has
|
|
39
|
+
* scrolled away with its scrollport it covers nothing, and the clamped arithmetic returns 0.
|
|
40
|
+
*/
|
|
41
|
+
export declare const measureStickyInsets: (port: EdgeRect, cell: HTMLElement) => StickyInsets;
|
|
42
|
+
/** Scroll deltas that bring the whole cell inside `port` minus its sticky overlays. */
|
|
43
|
+
export declare const computeCellScrollDelta: (cell: EdgeRect, port: EdgeRect, insets?: StickyInsets, dir?: GridScrollDirection | null, padding?: number) => CellScrollDelta;
|
|
44
|
+
export declare const scrollGridCellIntoView: (cell: HTMLElement | null, options?: {
|
|
45
|
+
dir?: GridScrollDirection | null;
|
|
46
|
+
padding?: number;
|
|
47
|
+
}) => void;
|
|
48
|
+
//# sourceMappingURL=scrollCellIntoView.d.ts.map
|
|
@@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mBAAmB,GAAG,IAAW,EACtC,UAAS,MAA+B,KACvC,eAiBD,CAAC;AAUH,eAAO,MAAM,sBAAsB,GACjC,MAAM,WAAW,GAAG,IAAI,EACxB,UAAS;IAAE,GAAG,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,KACnE,IAyCF,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const R = 4, L = {
|
|
2
|
+
top: 0,
|
|
3
|
+
right: 0,
|
|
4
|
+
bottom: 0,
|
|
5
|
+
left: 0
|
|
6
|
+
}, u = 1, S = /(auto|scroll|overlay)/, C = (t) => ({
|
|
7
|
+
top: t.top,
|
|
8
|
+
right: t.right,
|
|
9
|
+
bottom: t.bottom,
|
|
10
|
+
left: t.left,
|
|
11
|
+
width: t.width,
|
|
12
|
+
height: t.height
|
|
13
|
+
}), b = (t, n) => {
|
|
14
|
+
const o = getComputedStyle(t), e = n === "x" ? o.overflowX : o.overflowY;
|
|
15
|
+
return S.test(e) ? n === "x" ? t.scrollWidth > t.clientWidth + u : t.scrollHeight > t.clientHeight + u : !1;
|
|
16
|
+
}, p = (t) => t === document.scrollingElement || t === document.documentElement || t === document.body, g = (t, n) => {
|
|
17
|
+
let o = t;
|
|
18
|
+
for (; o; ) {
|
|
19
|
+
if (b(o, n)) return o;
|
|
20
|
+
o = o.parentElement;
|
|
21
|
+
}
|
|
22
|
+
const e = document.scrollingElement;
|
|
23
|
+
return e && (n === "x" ? e.scrollWidth > e.clientWidth + u : e.scrollHeight > e.clientHeight + u) ? e : null;
|
|
24
|
+
}, a = (t) => {
|
|
25
|
+
if (p(t)) {
|
|
26
|
+
const n = window.innerWidth, o = window.innerHeight;
|
|
27
|
+
return { top: 0, right: n, bottom: o, left: 0, width: n, height: o };
|
|
28
|
+
}
|
|
29
|
+
return C(t.getBoundingClientRect());
|
|
30
|
+
}, f = (t, n) => {
|
|
31
|
+
const o = getComputedStyle(t);
|
|
32
|
+
return o.position !== "sticky" ? !1 : n === "x" ? o.left !== "auto" || o.right !== "auto" : o.top !== "auto" || o.bottom !== "auto";
|
|
33
|
+
}, m = (t, n) => {
|
|
34
|
+
var l;
|
|
35
|
+
const o = { ...L }, e = n.closest("table"), s = e == null ? void 0 : e.querySelector(":scope > thead");
|
|
36
|
+
if (s && f(s, "y")) {
|
|
37
|
+
const i = s.getBoundingClientRect();
|
|
38
|
+
i.top <= t.top + u && (o.top = Math.max(0, Math.min(i.bottom - t.top, t.height)));
|
|
39
|
+
}
|
|
40
|
+
const r = e == null ? void 0 : e.querySelector(":scope > tfoot");
|
|
41
|
+
if (r && f(r, "y")) {
|
|
42
|
+
const i = r.getBoundingClientRect();
|
|
43
|
+
i.bottom >= t.bottom - u && (o.bottom = Math.max(
|
|
44
|
+
0,
|
|
45
|
+
Math.min(t.bottom - i.top, t.height)
|
|
46
|
+
));
|
|
47
|
+
}
|
|
48
|
+
const h = ((l = n.closest("tr")) == null ? void 0 : l.children) ?? [];
|
|
49
|
+
for (const i of Array.from(h)) {
|
|
50
|
+
if (!(i instanceof HTMLElement) || i === n || !f(i, "x")) continue;
|
|
51
|
+
const c = i.getBoundingClientRect();
|
|
52
|
+
c.left <= t.left + u ? o.left = Math.max(
|
|
53
|
+
o.left,
|
|
54
|
+
Math.min(c.right - t.left, t.width)
|
|
55
|
+
) : c.right >= t.right - u && (o.right = Math.max(
|
|
56
|
+
o.right,
|
|
57
|
+
Math.min(t.right - c.left, t.width)
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
return o;
|
|
61
|
+
}, d = (t, n, o, e, s, r) => {
|
|
62
|
+
const h = e - o;
|
|
63
|
+
if (h <= 0) return 0;
|
|
64
|
+
const l = t < o - u ? t - r - o : 0, i = n > e + u ? n + r - e : 0;
|
|
65
|
+
return n - t > h ? s === "start" ? l : s === "end" ? i : n <= o || t >= e ? l || i : 0 : l !== 0 ? l : i;
|
|
66
|
+
}, y = (t, n, o = L, e = null, s = 4) => ({
|
|
67
|
+
dx: d(
|
|
68
|
+
t.left,
|
|
69
|
+
t.right,
|
|
70
|
+
n.left + o.left,
|
|
71
|
+
n.right - o.right,
|
|
72
|
+
e === "left" ? "start" : e === "right" ? "end" : null,
|
|
73
|
+
s
|
|
74
|
+
),
|
|
75
|
+
dy: d(
|
|
76
|
+
t.top,
|
|
77
|
+
t.bottom,
|
|
78
|
+
n.top + o.top,
|
|
79
|
+
n.bottom - o.bottom,
|
|
80
|
+
e === "up" ? "start" : e === "down" ? "end" : null,
|
|
81
|
+
s
|
|
82
|
+
)
|
|
83
|
+
}), x = (t) => {
|
|
84
|
+
var n;
|
|
85
|
+
return ((n = t.closest("table")) == null ? void 0 : n.parentElement) ?? t.parentElement;
|
|
86
|
+
}, _ = (t, n = {}) => {
|
|
87
|
+
if (!t || typeof document > "u") return;
|
|
88
|
+
const { dir: o = null, padding: e = 4 } = n, s = x(t);
|
|
89
|
+
if (!s) return;
|
|
90
|
+
const r = f(t, "x") ? null : g(s, "x"), h = f(t, "y") ? null : g(s, "y");
|
|
91
|
+
if (!r && !h) return;
|
|
92
|
+
const l = C(t.getBoundingClientRect());
|
|
93
|
+
if (r) {
|
|
94
|
+
const i = a(r), { dx: c } = y(
|
|
95
|
+
l,
|
|
96
|
+
i,
|
|
97
|
+
m(i, t),
|
|
98
|
+
o,
|
|
99
|
+
e
|
|
100
|
+
);
|
|
101
|
+
c !== 0 && (r.scrollLeft += c);
|
|
102
|
+
}
|
|
103
|
+
if (h) {
|
|
104
|
+
const i = a(h), { dy: c } = y(
|
|
105
|
+
l,
|
|
106
|
+
i,
|
|
107
|
+
m(i, t),
|
|
108
|
+
o,
|
|
109
|
+
e
|
|
110
|
+
);
|
|
111
|
+
c !== 0 && (h.scrollTop += c);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
export {
|
|
115
|
+
R as CELL_SCROLL_PADDING_PX,
|
|
116
|
+
L as NO_STICKY_INSETS,
|
|
117
|
+
y as computeCellScrollDelta,
|
|
118
|
+
g as getAxisScrollParent,
|
|
119
|
+
a as getScrollportRect,
|
|
120
|
+
m as measureStickyInsets,
|
|
121
|
+
_ as scrollGridCellIntoView
|
|
122
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from 'react';
|
|
2
2
|
export type GridNavDirection = "up" | "down" | "left" | "right";
|
|
3
|
+
/** Options for moving grid focus; `dir` lets the scroll align the edge being travelled toward. */
|
|
4
|
+
export type FocusGridCellOptions = {
|
|
5
|
+
dir?: GridNavDirection | null;
|
|
6
|
+
};
|
|
3
7
|
export interface GridNeighbor {
|
|
4
8
|
rowId: string;
|
|
5
9
|
columnKey: string;
|
|
@@ -9,7 +13,7 @@ export interface GridNeighbor {
|
|
|
9
13
|
export interface GridNavValue {
|
|
10
14
|
getNeighbor: (rowId: string, columnKey: string, dir: GridNavDirection) => GridNeighbor | null;
|
|
11
15
|
getTabNeighbor: (rowId: string, columnKey: string, forward: boolean) => GridNeighbor | null;
|
|
12
|
-
focusCell: (rowId: string, columnKey: string) => boolean;
|
|
16
|
+
focusCell: (rowId: string, columnKey: string, options?: FocusGridCellOptions) => boolean;
|
|
13
17
|
selectCell: (rowId: string, columnKey: string, sourceIndex?: number | null) => void;
|
|
14
18
|
setEditingCell: (cell: {
|
|
15
19
|
rowId: string;
|
|
@@ -21,8 +25,15 @@ export declare const isWithinCellEditor: (target: EventTarget | null) => boolean
|
|
|
21
25
|
export declare const findGridCell: (container: HTMLElement | null, rowId: string, columnKey: string) => HTMLElement | null;
|
|
22
26
|
export declare const getGridNeighbor: (container: HTMLElement | null, rowIds: readonly string[], columnKeys: readonly string[], rowId: string, columnKey: string, dir: GridNavDirection) => GridNeighbor | null;
|
|
23
27
|
export declare const getGridTabNeighbor: (container: HTMLElement | null, rowIds: readonly string[], columnKeys: readonly string[], rowId: string, columnKey: string, forward: boolean) => GridNeighbor | null;
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Focus a cell and bring it fully into view.
|
|
30
|
+
*
|
|
31
|
+
* The implicit scroll from `focus()` is suppressed: it targets the inner focus wrapper and ignores
|
|
32
|
+
* sticky chrome, so it leaves the cell's padding and range border clipped. `scrollGridCellIntoView`
|
|
33
|
+
* scrolls the `<td>` itself, accounting for the sticky header and sticky columns.
|
|
34
|
+
*/
|
|
35
|
+
export declare const focusGridCellElement: (cell: HTMLElement | null, options?: FocusGridCellOptions) => boolean;
|
|
36
|
+
export declare const focusGridCell: (container: HTMLElement | null, rowId: string, columnKey: string, options?: FocusGridCellOptions) => boolean;
|
|
26
37
|
export declare const GridNavProvider: ({ rowIds, columnKeys, containerRef, onSelectCell, onEditingCellChange, children, }: {
|
|
27
38
|
rowIds: string[];
|
|
28
39
|
columnKeys: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridKeyboardNavigation.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useGridKeyboardNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useGridKeyboardNavigation.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useGridKeyboardNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxG,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,kGAAkG;AAClG,MAAM,MAAM,oBAAoB,GAAG;IAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC;CACtB;A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B,SAAS,OAAO,KACf,YAAY,GAAG,IAgBjB,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,WAAW,GAAG,IAAI,EACxB,UAAS,oBAAyB,KACjC,OAMF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,WAAW,WAAW,GAAG,IAAI,EAC7B,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,UAAS,oBAAyB,KACjC,OAAmF,CAAC;AAEvF,eAAO,MAAM,eAAe,GAAI,oFAO7B;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACtF,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IACjF,QAAQ,EAAE,SAAS,CAAC;CACrB,4CA+BA,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAO,YAAY,GAAG,IAAkC,CAAC"}
|
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
import { jsx as C } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { useContext as p, useCallback as g, useMemo as h, createContext as G } from "react";
|
|
3
|
+
import { scrollGridCellIntoView as S } from "./scrollCellIntoView.js";
|
|
4
|
+
const x = G(null), v = (e, r) => `[data-grid-cell][data-grid-row-id="${CSS.escape(e)}"][data-grid-col-key="${CSS.escape(r)}"]`, M = (e) => e instanceof HTMLElement ? !!(e.closest('[contenteditable]:not([contenteditable="false"])') || e.closest("input, textarea, select") || e.closest('[role="textbox"]')) : !1, b = (e, r, t) => (e == null ? void 0 : e.querySelector(v(r, t))) ?? null, N = (e, r, t, l, c) => {
|
|
5
|
+
if (l < 0 || l >= r.length || c < 0 || c >= t.length) return null;
|
|
6
|
+
const s = r[l], u = t[c], i = b(e, s, u);
|
|
7
|
+
if (!i) return null;
|
|
8
|
+
const n = i.getAttribute("data-grid-source-index"), o = n != null && n !== "" ? Number(n) : NaN;
|
|
8
9
|
return {
|
|
9
10
|
rowId: s,
|
|
10
|
-
columnKey:
|
|
11
|
+
columnKey: u,
|
|
11
12
|
sourceIndex: Number.isNaN(o) ? null : o,
|
|
12
|
-
element:
|
|
13
|
+
element: i
|
|
13
14
|
};
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
let n =
|
|
18
|
-
return s === "up" ? n -= 1 : s === "down" ? n += 1 : s === "left" ? o -= 1 : s === "right" && (o += 1), N(e,
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
let n =
|
|
23
|
-
return o >=
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
return !t || typeof t.focus != "function" ? !1 : (t.focus(), !0);
|
|
27
|
-
},
|
|
15
|
+
}, m = (e, r, t, l, c, s) => {
|
|
16
|
+
const u = r.indexOf(l), i = t.indexOf(c);
|
|
17
|
+
if (u === -1 || i === -1) return null;
|
|
18
|
+
let n = u, o = i;
|
|
19
|
+
return s === "up" ? n -= 1 : s === "down" ? n += 1 : s === "left" ? o -= 1 : s === "right" && (o += 1), N(e, r, t, n, o);
|
|
20
|
+
}, I = (e, r, t, l, c, s) => {
|
|
21
|
+
const u = r.indexOf(l), i = t.indexOf(c);
|
|
22
|
+
if (u === -1 || i === -1) return null;
|
|
23
|
+
let n = u, o = i + (s ? 1 : -1);
|
|
24
|
+
return o >= t.length ? (o = 0, n += 1) : o < 0 && (o = t.length - 1, n -= 1), N(e, r, t, n, o);
|
|
25
|
+
}, O = (e) => (e == null ? void 0 : e.querySelector("[data-grid-focus]")) ?? e, T = (e, r = {}) => {
|
|
26
|
+
const t = O(e);
|
|
27
|
+
return !t || typeof t.focus != "function" ? !1 : (t.focus({ preventScroll: !0 }), S(e, { dir: r.dir ?? null }), !0);
|
|
28
|
+
}, E = (e, r, t, l = {}) => T(b(e, r, t), l), P = ({
|
|
28
29
|
rowIds: e,
|
|
29
|
-
columnKeys:
|
|
30
|
-
containerRef:
|
|
31
|
-
onSelectCell:
|
|
30
|
+
columnKeys: r,
|
|
31
|
+
containerRef: t,
|
|
32
|
+
onSelectCell: l,
|
|
32
33
|
onEditingCellChange: c,
|
|
33
34
|
children: s
|
|
34
35
|
}) => {
|
|
35
|
-
const
|
|
36
|
-
(d, f, a) =>
|
|
37
|
-
[
|
|
38
|
-
),
|
|
39
|
-
(d, f, a) =>
|
|
40
|
-
[
|
|
36
|
+
const u = g(
|
|
37
|
+
(d, f, a) => m(t.current, e, r, d, f, a),
|
|
38
|
+
[t, e, r]
|
|
39
|
+
), i = g(
|
|
40
|
+
(d, f, a) => I(t.current, e, r, d, f, a),
|
|
41
|
+
[t, e, r]
|
|
41
42
|
), n = g(
|
|
42
|
-
(d, f) =>
|
|
43
|
-
[
|
|
44
|
-
), o =
|
|
43
|
+
(d, f, a) => E(t.current, d, f, a),
|
|
44
|
+
[t]
|
|
45
|
+
), o = h(
|
|
45
46
|
() => ({
|
|
46
|
-
getNeighbor:
|
|
47
|
-
getTabNeighbor:
|
|
47
|
+
getNeighbor: u,
|
|
48
|
+
getTabNeighbor: i,
|
|
48
49
|
focusCell: n,
|
|
49
|
-
selectCell:
|
|
50
|
+
selectCell: l,
|
|
50
51
|
setEditingCell: c
|
|
51
52
|
}),
|
|
52
|
-
[
|
|
53
|
+
[u, i, n, l, c]
|
|
53
54
|
);
|
|
54
55
|
return /* @__PURE__ */ C(x.Provider, { value: o, children: s });
|
|
55
|
-
},
|
|
56
|
+
}, $ = () => p(x);
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
+
P as GridNavProvider,
|
|
58
59
|
b as findGridCell,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
E as focusGridCell,
|
|
61
|
+
T as focusGridCellElement,
|
|
62
|
+
m as getGridNeighbor,
|
|
63
|
+
I as getGridTabNeighbor,
|
|
64
|
+
M as isWithinCellEditor,
|
|
65
|
+
$ as useGridKeyboardNavigation
|
|
65
66
|
};
|