@gridkitjs/react 0.0.0-dev-20261118081957 → 0.0.0-dev-20261118115237
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.js +88 -41
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -34,10 +34,12 @@ import {
|
|
|
34
34
|
} from "@gridkitjs/core";
|
|
35
35
|
import {
|
|
36
36
|
buildKeyShortcuts,
|
|
37
|
+
inlineStep,
|
|
37
38
|
intentOf,
|
|
38
39
|
KEYBOARD_STEP,
|
|
39
40
|
resolveColumnFilterMenu
|
|
40
41
|
} from "@gridkitjs/core/renderer";
|
|
42
|
+
import { writingDirection } from "@gridkitjs/dom";
|
|
41
43
|
|
|
42
44
|
// src/DataGrid/ariaAttr.ts
|
|
43
45
|
function ariaAttr(condition, key, value) {
|
|
@@ -228,16 +230,18 @@ function GridHeader({
|
|
|
228
230
|
},
|
|
229
231
|
onKeyDown: (event) => {
|
|
230
232
|
if (!isOwnEvent(event)) return;
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
const step = inlineStep(
|
|
234
|
+
event.key,
|
|
235
|
+
writingDirection(event.currentTarget)
|
|
236
|
+
);
|
|
237
|
+
if (step !== null && event.ctrlKey && entry.reorderable) {
|
|
234
238
|
event.preventDefault();
|
|
235
|
-
drag.moveByKeyboard(entry,
|
|
239
|
+
drag.moveByKeyboard(entry, step);
|
|
236
240
|
return;
|
|
237
241
|
}
|
|
238
|
-
if (
|
|
242
|
+
if (step !== null && event.altKey && entry.resizable) {
|
|
239
243
|
event.preventDefault();
|
|
240
|
-
resize.nudge(entry,
|
|
244
|
+
resize.nudge(entry, step * KEYBOARD_STEP);
|
|
241
245
|
return;
|
|
242
246
|
}
|
|
243
247
|
if (event.key === "Enter" && event.altKey && entry.resizable) {
|
|
@@ -454,7 +458,8 @@ import {
|
|
|
454
458
|
import {
|
|
455
459
|
createGridFocus,
|
|
456
460
|
findBodyRow,
|
|
457
|
-
measurePageSize
|
|
461
|
+
measurePageSize,
|
|
462
|
+
writingDirection as writingDirection2
|
|
458
463
|
} from "@gridkitjs/dom";
|
|
459
464
|
function tabIndexFor(columnIndex, focusedColumnIndex) {
|
|
460
465
|
return columnIndex === focusedColumnIndex ? 0 : -1;
|
|
@@ -518,7 +523,8 @@ function useGridNavigation({
|
|
|
518
523
|
if (gridFocus.handleKey(
|
|
519
524
|
event.key,
|
|
520
525
|
event,
|
|
521
|
-
measurePageSize(bodyTableRef.current)
|
|
526
|
+
measurePageSize(bodyTableRef.current),
|
|
527
|
+
writingDirection2(event.currentTarget)
|
|
522
528
|
)) {
|
|
523
529
|
event.preventDefault();
|
|
524
530
|
}
|
|
@@ -685,6 +691,20 @@ var GridGroupRow_default = GridGroupRow;
|
|
|
685
691
|
|
|
686
692
|
// src/DataGrid/components/GridGroupSummaryRow.tsx
|
|
687
693
|
import { memo as memo2 } from "react";
|
|
694
|
+
|
|
695
|
+
// src/DataGrid/textAlign.ts
|
|
696
|
+
function textAlignFor(alignment) {
|
|
697
|
+
switch (alignment) {
|
|
698
|
+
case "left":
|
|
699
|
+
return "start";
|
|
700
|
+
case "right":
|
|
701
|
+
return "end";
|
|
702
|
+
case "center":
|
|
703
|
+
return "center";
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/DataGrid/components/GridGroupSummaryRow.tsx
|
|
688
708
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
689
709
|
function GridGroupSummaryRowComponent({
|
|
690
710
|
groupId,
|
|
@@ -719,7 +739,9 @@ function GridGroupSummaryRowComponent({
|
|
|
719
739
|
role: "gridcell",
|
|
720
740
|
"data-gridkit-column": entry.id,
|
|
721
741
|
className: "gridkit-grid-group-summary-cell",
|
|
722
|
-
style: {
|
|
742
|
+
style: {
|
|
743
|
+
textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment)
|
|
744
|
+
},
|
|
723
745
|
children: [
|
|
724
746
|
entry.id === columns[0]?.id && /* @__PURE__ */ jsx5(
|
|
725
747
|
"span",
|
|
@@ -824,7 +846,7 @@ function GridRowComponent({
|
|
|
824
846
|
column.wrap?.cells ? "is-wrapped" : "",
|
|
825
847
|
column.cellClassName ?? ""
|
|
826
848
|
),
|
|
827
|
-
style: { textAlign: alignment },
|
|
849
|
+
style: { textAlign: textAlignFor(alignment) },
|
|
828
850
|
children: column.cellTemplate ? column.cellTemplate({
|
|
829
851
|
value,
|
|
830
852
|
row,
|
|
@@ -1146,7 +1168,9 @@ function GridFooter({
|
|
|
1146
1168
|
role: "gridcell",
|
|
1147
1169
|
"data-gridkit-column": entry.id,
|
|
1148
1170
|
className: "gridkit-grid-footer-cell",
|
|
1149
|
-
style: {
|
|
1171
|
+
style: {
|
|
1172
|
+
textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment)
|
|
1173
|
+
},
|
|
1150
1174
|
children: specs.map(
|
|
1151
1175
|
(spec) => renderAggregate(
|
|
1152
1176
|
results.get(spec.id ?? spec.columnId),
|
|
@@ -1320,7 +1344,11 @@ import { createPortal as createPortal2 } from "react-dom";
|
|
|
1320
1344
|
import {
|
|
1321
1345
|
resolveColumnLabel as resolveColumnLabel2
|
|
1322
1346
|
} from "@gridkitjs/core";
|
|
1323
|
-
import {
|
|
1347
|
+
import {
|
|
1348
|
+
inlineStep as inlineStep2,
|
|
1349
|
+
resolveKeyboardDropTarget
|
|
1350
|
+
} from "@gridkitjs/core/renderer";
|
|
1351
|
+
import { writingDirection as writingDirection3 } from "@gridkitjs/dom";
|
|
1324
1352
|
|
|
1325
1353
|
// src/DataGrid/useGroupByDrag.ts
|
|
1326
1354
|
import {
|
|
@@ -1511,13 +1539,13 @@ function GroupByBar({
|
|
|
1511
1539
|
chipDrag.startDrag(entry.columnId, event);
|
|
1512
1540
|
},
|
|
1513
1541
|
onKeyDown: (event) => {
|
|
1514
|
-
const
|
|
1515
|
-
|
|
1542
|
+
const step = inlineStep2(
|
|
1543
|
+
event.key,
|
|
1544
|
+
writingDirection3(event.currentTarget)
|
|
1545
|
+
);
|
|
1546
|
+
if (step !== null && event.ctrlKey) {
|
|
1516
1547
|
event.preventDefault();
|
|
1517
|
-
moveByKeyboard(
|
|
1518
|
-
entry.columnId,
|
|
1519
|
-
event.key === "ArrowLeft" ? -1 : 1
|
|
1520
|
-
);
|
|
1548
|
+
moveByKeyboard(entry.columnId, step);
|
|
1521
1549
|
}
|
|
1522
1550
|
},
|
|
1523
1551
|
children: [
|
|
@@ -1963,20 +1991,27 @@ import {
|
|
|
1963
1991
|
import { useLayoutEffect as useLayoutEffect3, useRef as useRef5 } from "react";
|
|
1964
1992
|
import { createPortal as createPortal3 } from "react-dom";
|
|
1965
1993
|
import {
|
|
1966
|
-
attachOverlay
|
|
1994
|
+
attachOverlay,
|
|
1995
|
+
writingDirection as writingDirection4
|
|
1967
1996
|
} from "@gridkitjs/dom";
|
|
1968
1997
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1969
1998
|
var ANCHOR_GAP = 4;
|
|
1970
1999
|
function attachedFocus(focus) {
|
|
1971
2000
|
return typeof focus === "object" && !(focus instanceof HTMLElement) ? focus.current ?? "first" : focus;
|
|
1972
2001
|
}
|
|
1973
|
-
function
|
|
2002
|
+
function themeClassNameOf(element) {
|
|
1974
2003
|
const scope = element?.closest(".gridkit-light, .gridkit-dark");
|
|
1975
2004
|
if (scope === null || scope === void 0) {
|
|
1976
2005
|
return "";
|
|
1977
2006
|
}
|
|
1978
2007
|
return scope.classList.contains("gridkit-dark") ? "gridkit-dark" : "gridkit-light";
|
|
1979
2008
|
}
|
|
2009
|
+
function overlayScope(element) {
|
|
2010
|
+
return {
|
|
2011
|
+
themeClassName: themeClassNameOf(element),
|
|
2012
|
+
direction: writingDirection4(element ?? document.documentElement)
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
1980
2015
|
function Overlay({
|
|
1981
2016
|
anchor,
|
|
1982
2017
|
placement,
|
|
@@ -1987,7 +2022,7 @@ function Overlay({
|
|
|
1987
2022
|
returnFocusFallback,
|
|
1988
2023
|
ignoreScrollAfterInput,
|
|
1989
2024
|
trapFocus,
|
|
1990
|
-
|
|
2025
|
+
scope,
|
|
1991
2026
|
onDismiss,
|
|
1992
2027
|
children
|
|
1993
2028
|
}) {
|
|
@@ -2031,7 +2066,8 @@ function Overlay({
|
|
|
2031
2066
|
"div",
|
|
2032
2067
|
{
|
|
2033
2068
|
ref: panelRef,
|
|
2034
|
-
className: classNames("gridkit-overlay", themeClassName),
|
|
2069
|
+
className: classNames("gridkit-overlay", scope.themeClassName),
|
|
2070
|
+
dir: scope.direction,
|
|
2035
2071
|
children
|
|
2036
2072
|
}
|
|
2037
2073
|
),
|
|
@@ -2139,7 +2175,7 @@ function MenuItem({
|
|
|
2139
2175
|
function GridMenu({
|
|
2140
2176
|
entries,
|
|
2141
2177
|
label,
|
|
2142
|
-
|
|
2178
|
+
scope,
|
|
2143
2179
|
onRun,
|
|
2144
2180
|
onClose,
|
|
2145
2181
|
onCloseSubmenu,
|
|
@@ -2259,14 +2295,14 @@ function GridMenu({
|
|
|
2259
2295
|
placement: "right-start",
|
|
2260
2296
|
offset: submenu.offset,
|
|
2261
2297
|
initialFocus: submenu.focus,
|
|
2262
|
-
|
|
2298
|
+
scope,
|
|
2263
2299
|
onDismiss: closeSubmenu,
|
|
2264
2300
|
children: /* @__PURE__ */ jsx13(
|
|
2265
2301
|
GridMenu,
|
|
2266
2302
|
{
|
|
2267
2303
|
entries: openEntry.items,
|
|
2268
2304
|
label: openEntry.label,
|
|
2269
|
-
|
|
2305
|
+
scope,
|
|
2270
2306
|
onRun,
|
|
2271
2307
|
onClose,
|
|
2272
2308
|
onCloseSubmenu: closeSubmenu,
|
|
@@ -2295,14 +2331,14 @@ function GridContextMenu({
|
|
|
2295
2331
|
gap: menu.anchor instanceof Element ? ANCHOR_GAP : 0,
|
|
2296
2332
|
returnFocusTo: menu.cell ?? void 0,
|
|
2297
2333
|
returnFocusFallback,
|
|
2298
|
-
|
|
2334
|
+
scope: menu.scope,
|
|
2299
2335
|
onDismiss: close,
|
|
2300
2336
|
children: /* @__PURE__ */ jsx14(
|
|
2301
2337
|
GridMenu,
|
|
2302
2338
|
{
|
|
2303
2339
|
entries: menu.entries,
|
|
2304
2340
|
label: menu.label,
|
|
2305
|
-
|
|
2341
|
+
scope: menu.scope,
|
|
2306
2342
|
onRun: run,
|
|
2307
2343
|
onClose: close
|
|
2308
2344
|
}
|
|
@@ -2338,7 +2374,8 @@ import {
|
|
|
2338
2374
|
bodyCellFrom as bodyCellFrom2,
|
|
2339
2375
|
bodyRowFrom as bodyRowFrom2,
|
|
2340
2376
|
findBodyRow as findBodyRow2,
|
|
2341
|
-
groupRowFrom as groupRowFrom2
|
|
2377
|
+
groupRowFrom as groupRowFrom2,
|
|
2378
|
+
writingDirection as writingDirection5
|
|
2342
2379
|
} from "@gridkitjs/dom";
|
|
2343
2380
|
function headerCell(parts, columnIndex) {
|
|
2344
2381
|
const element = parts.headerTable?.tHead?.rows[0]?.cells[columnIndex];
|
|
@@ -2366,6 +2403,9 @@ function viewOf(element, parts) {
|
|
|
2366
2403
|
function clamp(value, min, max) {
|
|
2367
2404
|
return Math.min(Math.max(value, min), max);
|
|
2368
2405
|
}
|
|
2406
|
+
function inlineStartOf(element, box) {
|
|
2407
|
+
return writingDirection5(element) === "rtl" ? box.right : box.left;
|
|
2408
|
+
}
|
|
2369
2409
|
function onCell(target, cell, parts) {
|
|
2370
2410
|
if (cell === null) {
|
|
2371
2411
|
return null;
|
|
@@ -2379,14 +2419,18 @@ function onCell(target, cell, parts) {
|
|
|
2379
2419
|
target,
|
|
2380
2420
|
cell,
|
|
2381
2421
|
anchor: {
|
|
2382
|
-
x: clamp(
|
|
2422
|
+
x: clamp(inlineStartOf(cell.element, box), view.left, view.right),
|
|
2383
2423
|
y: clamp(box.bottom, view.top, view.bottom)
|
|
2384
2424
|
}
|
|
2385
2425
|
};
|
|
2386
2426
|
}
|
|
2387
2427
|
function onBody(body) {
|
|
2388
|
-
const
|
|
2389
|
-
return {
|
|
2428
|
+
const box = body.getBoundingClientRect();
|
|
2429
|
+
return {
|
|
2430
|
+
target: { area: "body" },
|
|
2431
|
+
cell: null,
|
|
2432
|
+
anchor: { x: inlineStartOf(body, box), y: box.top }
|
|
2433
|
+
};
|
|
2390
2434
|
}
|
|
2391
2435
|
function headerPlaceAt(element, parts) {
|
|
2392
2436
|
const cell = element.closest("th[data-gridkit-column]");
|
|
@@ -2557,7 +2601,7 @@ function useContextMenu({
|
|
|
2557
2601
|
label: labelOf(target),
|
|
2558
2602
|
anchor: point ?? anchor,
|
|
2559
2603
|
cell: cell?.element ?? null,
|
|
2560
|
-
|
|
2604
|
+
scope: overlayScope(rootRef.current)
|
|
2561
2605
|
}
|
|
2562
2606
|
});
|
|
2563
2607
|
return true;
|
|
@@ -2809,7 +2853,7 @@ function useMenuButton({
|
|
|
2809
2853
|
setState({
|
|
2810
2854
|
kind: "open",
|
|
2811
2855
|
anchor: button,
|
|
2812
|
-
|
|
2856
|
+
scope: overlayScope(button),
|
|
2813
2857
|
gap: gap(button),
|
|
2814
2858
|
focusItem: onLast ? itemCount - 1 : 0
|
|
2815
2859
|
});
|
|
@@ -2900,14 +2944,14 @@ function OperatorMenuButton({
|
|
|
2900
2944
|
placement: "right-start",
|
|
2901
2945
|
gap: state.gap,
|
|
2902
2946
|
returnFocusTo: state.anchor,
|
|
2903
|
-
|
|
2947
|
+
scope: state.scope,
|
|
2904
2948
|
onDismiss: close,
|
|
2905
2949
|
children: /* @__PURE__ */ jsx16(
|
|
2906
2950
|
GridMenu,
|
|
2907
2951
|
{
|
|
2908
2952
|
entries,
|
|
2909
2953
|
label,
|
|
2910
|
-
|
|
2954
|
+
scope: state.scope,
|
|
2911
2955
|
behaviourRef,
|
|
2912
2956
|
onRun: (item) => {
|
|
2913
2957
|
item.run();
|
|
@@ -3763,7 +3807,7 @@ function GridPanels({
|
|
|
3763
3807
|
returnFocusFallback,
|
|
3764
3808
|
ignoreScrollAfterInput: true,
|
|
3765
3809
|
trapFocus,
|
|
3766
|
-
|
|
3810
|
+
scope: panel.scope,
|
|
3767
3811
|
onDismiss: close,
|
|
3768
3812
|
children: /* @__PURE__ */ jsx22(
|
|
3769
3813
|
Panel,
|
|
@@ -3810,6 +3854,9 @@ function panelApi(panels, controller) {
|
|
|
3810
3854
|
|
|
3811
3855
|
// src/DataGrid/panels/useGridPanels.ts
|
|
3812
3856
|
import { useRef as useRef16 } from "react";
|
|
3857
|
+
import {
|
|
3858
|
+
writingDirection as writingDirection6
|
|
3859
|
+
} from "@gridkitjs/dom";
|
|
3813
3860
|
function toolbarItem(root, itemId) {
|
|
3814
3861
|
const items = root.querySelectorAll(
|
|
3815
3862
|
":scope > .gridkit-toolbar > [data-gridkit-toolbar-item]"
|
|
@@ -3846,9 +3893,9 @@ function useGridPanels({
|
|
|
3846
3893
|
returnFocusTo: element
|
|
3847
3894
|
};
|
|
3848
3895
|
}
|
|
3849
|
-
const { right, top } = root.getBoundingClientRect();
|
|
3896
|
+
const { left, right, top } = root.getBoundingClientRect();
|
|
3850
3897
|
return {
|
|
3851
|
-
anchor: { x: right, y: top },
|
|
3898
|
+
anchor: { x: writingDirection6(root) === "rtl" ? left : right, y: top },
|
|
3852
3899
|
placement: "bottom-end",
|
|
3853
3900
|
returnFocusTo: void 0
|
|
3854
3901
|
};
|
|
@@ -3869,7 +3916,7 @@ function useGridPanels({
|
|
|
3869
3916
|
kind,
|
|
3870
3917
|
target,
|
|
3871
3918
|
...placeFor(root, target),
|
|
3872
|
-
|
|
3919
|
+
scope: overlayScope(root)
|
|
3873
3920
|
}
|
|
3874
3921
|
});
|
|
3875
3922
|
},
|
|
@@ -3931,14 +3978,14 @@ function ToolbarMenuButton({
|
|
|
3931
3978
|
gap: state.gap,
|
|
3932
3979
|
returnFocusTo: state.anchor,
|
|
3933
3980
|
returnFocusFallback,
|
|
3934
|
-
|
|
3981
|
+
scope: state.scope,
|
|
3935
3982
|
onDismiss: close,
|
|
3936
3983
|
children: /* @__PURE__ */ jsx23(
|
|
3937
3984
|
GridMenu,
|
|
3938
3985
|
{
|
|
3939
3986
|
entries,
|
|
3940
3987
|
label,
|
|
3941
|
-
|
|
3988
|
+
scope: state.scope,
|
|
3942
3989
|
behaviourRef,
|
|
3943
3990
|
onRun: (item) => {
|
|
3944
3991
|
item.run();
|