@m4l/components 0.1.26 → 0.1.28

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.
Files changed (112) hide show
  1. package/assets/Logo/index.228dcb5a.js +42 -35
  2. package/commonjs.565e6834.js +5 -5
  3. package/components/CommonActions/components/ActionCancel/index.e498eeb2.js +17 -0
  4. package/components/CommonActions/components/ActionFormCancel/index.4ff0ad73.js +64 -0
  5. package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +28 -22
  6. package/components/CommonActions/components/ActionIntro/index.60ef7bd7.js +18 -0
  7. package/components/CommonActions/components/Actions/index.0645e30f.js +867 -0
  8. package/components/DataGrid/index.76d8fd25.js +1075 -0
  9. package/components/DynamicFilter/index.342ba5fe.js +1577 -0
  10. package/components/ErrorLabel/index.c8615f16.js +13 -12
  11. package/components/Icon/index.619c31c4.js +96 -0
  12. package/components/Icon/types.d.ts +2 -1
  13. package/components/Image/index.93d5f37f.js +190 -0
  14. package/components/Loadable/index.f5518558.js +8 -8
  15. package/components/ModalDialog/index.9ea10764.js +184 -0
  16. package/components/NoItemSelected/{index.9609a7f7.js → index.46d2f632.js} +52 -41
  17. package/components/ObjectLogs/index.f941fb79.js +288 -0
  18. package/components/Page/index.4237c241.js +22 -20
  19. package/components/PaperForm/index.ec9cb8c9.js +112 -0
  20. package/components/Period/index.2941fbda.js +249 -0
  21. package/components/PropertyValue/index.dfcfe1ba.js +147 -0
  22. package/components/PropertyValue/styles.d.ts +2 -1
  23. package/components/PropertyValue/types.d.ts +3 -3
  24. package/components/Resizeable/index.45995d2b.js +19 -19
  25. package/components/ScrollBar/index.39eeb2de.js +26 -21
  26. package/components/ScrollToTop/index.e06f98f6.js +8 -7
  27. package/components/SplitLayout/index.4032673d.js +35 -33
  28. package/components/animate/LoadingScreen/index.1d0c4307.js +33 -33
  29. package/components/animate/MotionContainer/index.8d9f9d80.js +25 -22
  30. package/components/animate/MotionLazyContainer/index.572dd012.js +10 -10
  31. package/components/animate/features.0fbf41e1.js +3 -3
  32. package/components/animate/variants/bounce.784aaaaa.js +16 -13
  33. package/components/animate/variants/container.11f82b76.js +8 -6
  34. package/components/animate/variants/fade.b561c0fc.js +32 -28
  35. package/components/animate/variants/transition.bd46b9ce.js +17 -12
  36. package/components/formatters/BooleanFormatter/index.8da35c9c.js +55 -0
  37. package/components/formatters/DateFormatter/index.1b9baacc.js +69 -0
  38. package/components/formatters/index.689a8086.js +119 -0
  39. package/components/hook-form/RHFAutocomplete/index.59a68f9f.js +224 -0
  40. package/components/hook-form/RHFAutocompleteAsync/index.c3083062.js +87 -0
  41. package/components/hook-form/RHFCheckbox/index.6dcec9e2.js +49 -39
  42. package/components/hook-form/RHFDateTime/index.9231a7c7.js +69 -56
  43. package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +23 -23
  44. package/components/hook-form/RHFPeriod/index.64a228d5.js +55 -0
  45. package/components/hook-form/RHFRadioGroup/index.b3335e13.js +29 -29
  46. package/components/hook-form/RHFSelect/index.b6ca8bb2.js +24 -24
  47. package/components/hook-form/RHFTextField/index.f9aaaa90.js +146 -0
  48. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/index.d.ts +0 -0
  49. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/styles.d.ts +4 -3
  50. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/subcomponents/Skeleton/index.d.ts +0 -0
  51. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/subcomponents/Skeleton/styles.d.ts +0 -0
  52. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/types.d.ts +0 -0
  53. package/components/hook-form/RHFUpload/index.d5cc7c13.js +285 -0
  54. package/components/mui_extended/Accordion/index.a02ac6ae.js +107 -0
  55. package/components/mui_extended/Avatar/index.fe06afd7.js +51 -0
  56. package/components/mui_extended/BoxIcon/index.e638ecc8.js +10 -10
  57. package/components/mui_extended/Breadcrumbs/index.5e37d903.js +49 -44
  58. package/components/mui_extended/Button/index.53b56958.js +178 -0
  59. package/components/mui_extended/CircularProgress/index.ad569afd.js +8 -6
  60. package/components/mui_extended/IconButton/index.a321e5cb.js +120 -0
  61. package/components/mui_extended/IconButton/index.d.ts +1 -1
  62. package/components/mui_extended/LinkWithRoute/index.16436ab8.js +25 -21
  63. package/components/mui_extended/Pager/index.c0865b70.js +141 -0
  64. package/components/mui_extended/Popover/index.705275a4.js +278 -0
  65. package/components/mui_extended/Tab/index.e0653a0a.js +25 -21
  66. package/components/mui_extended/Typography/index.e5494696.js +25 -21
  67. package/contexts/ModalContext/index.b92fa565.js +153 -0
  68. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/index.d.ts +0 -0
  69. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/styles.d.ts +0 -0
  70. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/types.d.ts +0 -0
  71. package/contexts/RHFormContext/index.b142190a.js +63 -0
  72. package/hooks/useFormAddEdit/index.d4845f1a.js +40 -22
  73. package/hooks/useModal/index.5fee01a3.js +11 -0
  74. package/index.js +153 -153
  75. package/package.json +2 -1
  76. package/react-data-grid.d46d625e.js +2206 -1663
  77. package/react-draggable.20e95c61.js +800 -553
  78. package/react-json-view.f56a7f8e.js +2344 -2340
  79. package/react-resizable.5277deaf.js +470 -298
  80. package/react-splitter-layout.7810ac1b.js +130 -128
  81. package/utils/index.214d9542.js +500 -354
  82. package/components/CommonActions/components/ActionCancel/index.6736b782.js +0 -17
  83. package/components/CommonActions/components/ActionFormCancel/index.281ee166.js +0 -49
  84. package/components/CommonActions/components/ActionIntro/index.4665a611.js +0 -18
  85. package/components/CommonActions/components/Actions/index.cd7b2671.js +0 -742
  86. package/components/DataGrid/index.2caf6231.js +0 -894
  87. package/components/DynamicFilter/index.f2377369.js +0 -1157
  88. package/components/Icon/index.f569765b.js +0 -82
  89. package/components/Image/index.c9da2d5a.js +0 -152
  90. package/components/ModalDialog/index.bee344a5.js +0 -168
  91. package/components/ObjectLogs/index.6b6f95e6.js +0 -266
  92. package/components/PaperForm/index.3f8c7ef2.js +0 -105
  93. package/components/Period/index.a112ce37.js +0 -175
  94. package/components/PropertyValue/index.ab3dd7e9.js +0 -116
  95. package/components/contexts/RHFormContext/index.33dba822.js +0 -56
  96. package/components/formatters/BooleanFormatter/index.3ec56305.js +0 -42
  97. package/components/formatters/DateFormatter/index.08d8823b.js +0 -57
  98. package/components/formatters/index.6959c2de.js +0 -106
  99. package/components/hook-form/RHFAutocomplete/index.5eee9d7c.js +0 -174
  100. package/components/hook-form/RHFAutocompleteAsync/index.757b5080.js +0 -65
  101. package/components/hook-form/RHFPeriod/index.979d0898.js +0 -51
  102. package/components/hook-form/RHFTextField/index.ba2a8f67.js +0 -129
  103. package/components/hook-form/RHFUpload/index.6347159a.js +0 -258
  104. package/components/mui_extended/Accordion/index.49f5df8e.js +0 -103
  105. package/components/mui_extended/Avatar/index.dadb0528.js +0 -37
  106. package/components/mui_extended/Button/index.52d18aea.js +0 -144
  107. package/components/mui_extended/IconButton/index.4b5ce8b5.js +0 -103
  108. package/components/mui_extended/Pager/index.951b6975.js +0 -126
  109. package/components/mui_extended/Popover/index.4da8587a.js +0 -252
  110. package/contexts/ModalContext/index.5388dfd5.js +0 -136
  111. package/hooks/useModal/index.3b1ff084.js +0 -11
  112. package/node_modules.168cb897.js +0 -55
@@ -1,1590 +1,2043 @@
1
- import { forwardRef as pt, useRef as ce, createContext as xt, useContext as ut, useState as Y, useMemo as Q, useImperativeHandle as Ho, useCallback as je, useEffect as wt, useLayoutEffect as Ko, memo as ae } from "react";
2
- import se from "clsx";
3
- import { jsx as I, jsxs as ne, Fragment as ze } from "react/jsx-runtime";
4
- function G(e, t) {
5
- t === void 0 && (t = {});
6
- var n = t.insertAt;
7
- if (!(!e || typeof document > "u")) {
8
- var i = document.head || document.getElementsByTagName("head")[0], l = document.createElement("style");
9
- l.type = "text/css", n === "top" && i.firstChild ? i.insertBefore(l, i.firstChild) : i.appendChild(l), l.styleSheet ? l.styleSheet.cssText = e : l.appendChild(document.createTextNode(e));
1
+ import { forwardRef, useRef, createContext, useContext, useState, useMemo, useImperativeHandle, useCallback, useEffect, useLayoutEffect as useLayoutEffect$1, memo } from "react";
2
+ import clsx from "clsx";
3
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
+ function styleInject(css, ref) {
5
+ if (ref === void 0)
6
+ ref = {};
7
+ var insertAt = ref.insertAt;
8
+ if (!css || typeof document === "undefined") {
9
+ return;
10
+ }
11
+ var head = document.head || document.getElementsByTagName("head")[0];
12
+ var style = document.createElement("style");
13
+ style.type = "text/css";
14
+ if (insertAt === "top") {
15
+ if (head.firstChild) {
16
+ head.insertBefore(style, head.firstChild);
17
+ } else {
18
+ head.appendChild(style);
19
+ }
20
+ } else {
21
+ head.appendChild(style);
22
+ }
23
+ if (style.styleSheet) {
24
+ style.styleSheet.cssText = css;
25
+ } else {
26
+ style.appendChild(document.createTextNode(css));
10
27
  }
11
28
  }
12
- var _o = ".c1wupbe700-beta13{background-color:inherit;border-block-end:1px solid var(--rdg-border-color);border-inline-end:1px solid var(--rdg-border-color);contain:size style;grid-row-start:var(--rdg-grid-row-start);outline:none;overflow:hidden;overflow:clip;padding-block:0;padding-inline:8px;position:relative;text-overflow:ellipsis;white-space:nowrap}.c1wupbe700-beta13[aria-selected=true]{outline:2px solid var(--rdg-selection-color);outline-offset:-2px}.cd0kgiy700-beta13 .c1wupbe700-beta13{contain:content}.c1730fa4700-beta13{position:sticky;z-index:1}.c9dpaye700-beta13{box-shadow:calc(2px*var(--rdg-sign)) 0 5px -2px hsla(0,0%,53%,.3)}";
13
- G(_o, { insertAt: "top" });
14
- const jo = "c1wupbe700-beta13", Bo = `rdg-cell ${jo}`, Go = "cd0kgiy700-beta13", Vo = "c1730fa4700-beta13", qo = `rdg-cell-frozen ${Vo}`, Uo = "c9dpaye700-beta13", Xo = `rdg-cell-frozen-last ${Uo}`;
15
- var Yo = '.r104f42s700-beta13{--rdg-color:#000;--rdg-border-color:#ddd;--rdg-summary-border-color:#aaa;--rdg-background-color:#fff;--rdg-header-background-color:#f9f9f9;--rdg-row-hover-background-color:#f5f5f5;--rdg-row-selected-background-color:#dbecfa;--row-selected-hover-background-color:#c9e3f8;--rdg-checkbox-color:#005194;--rdg-checkbox-focus-color:#61b8ff;--rdg-checkbox-disabled-border-color:#ccc;--rdg-checkbox-disabled-background-color:#ddd;--rdg-selection-color:#66afe9;--rdg-font-size:14px;content-visibility:auto;background-color:var(--rdg-background-color);block-size:350px;border:1px solid var(--rdg-border-color);box-sizing:border-box;color:var(--rdg-color);color-scheme:var(--rdg-color-scheme,light dark);contain:strict;contain:size layout style paint;display:grid;font-size:var(--rdg-font-size);overflow:auto;user-select:none}@supports not (contain:strict){.r104f42s700-beta13{position:relative;z-index:0}}.r104f42s700-beta13 *,.r104f42s700-beta13 :after,.r104f42s700-beta13 :before{box-sizing:inherit}.r104f42s700-beta13:before{content:"";grid-column:1/-1;grid-row:1/-1}.r104f42s700-beta13.rdg-dark{--rdg-color-scheme:dark;--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}.r104f42s700-beta13.rdg-light{--rdg-color-scheme:light}@media (prefers-color-scheme:dark){.r104f42s700-beta13:not(.rdg-light){--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}}.v7ly7s700-beta13.r1otpg64700-beta13{cursor:move}.fc4f4zb700-beta13{grid-column:1/-1;pointer-events:none;z-index:4}';
16
- G(Yo, { insertAt: "top" });
17
- const Jo = "r104f42s700-beta13", Qo = `rdg ${Jo}`, Zo = "v7ly7s700-beta13", en = `rdg-viewport-dragging ${Zo}`, tn = "fc4f4zb700-beta13";
18
- var on = '.r1otpg64700-beta13{background-color:var(--rdg-background-color);display:contents;line-height:var(--rdg-row-height)}.r1otpg64700-beta13:hover{background-color:var(--rdg-row-hover-background-color)}.r1otpg64700-beta13[aria-selected=true]{background-color:var(--rdg-row-selected-background-color)}.r1otpg64700-beta13[aria-selected=true]:hover{background-color:var(--row-selected-hover-background-color)}.rel5gk2700-beta13{outline:2px solid var(--rdg-selection-color);outline-offset:-2px}.r1qymf1z700-beta13:before{border-inline-start:2px solid var(--rdg-selection-color);content:"";display:inline-block;height:100%;inset-inline-start:0;position:sticky}';
19
- G(on, { insertAt: "top" });
20
- const nn = "r1otpg64700-beta13", mt = `rdg-row ${nn}`, rn = "rel5gk2700-beta13", Ve = "rdg-row-selected", cn = "r1qymf1z700-beta13";
21
- var sn = '.cd9l4jz700-beta13{align-items:center;cursor:pointer;display:flex;inset:0;justify-content:center;margin-inline-end:1px;position:absolute}.c1noyk41700-beta13{all:unset}.cdwjxv8700-beta13{background-color:var(--rdg-background-color);block-size:20px;border:2px solid var(--rdg-border-color);content:"";inline-size:20px}.c1noyk41700-beta13:checked+.cdwjxv8700-beta13{background-color:var(--rdg-checkbox-color);outline:4px solid var(--rdg-background-color);outline-offset:-6px}.c1noyk41700-beta13:focus+.cdwjxv8700-beta13{border-color:var(--rdg-checkbox-focus-color)}.cca4mwn700-beta13{cursor:default}.cca4mwn700-beta13 .cdwjxv8700-beta13{background-color:var(--rdg-checkbox-disabled-background-color);border-color:var(--rdg-checkbox-disabled-border-color)}';
22
- G(sn, { insertAt: "top" });
23
- const ln = "cd9l4jz700-beta13", dn = `rdg-checkbox-label ${ln}`, an = "c1noyk41700-beta13", un = `rdg-checkbox-input ${an}`, fn = "cdwjxv8700-beta13", gn = `rdg-checkbox ${fn}`, bn = "cca4mwn700-beta13", hn = `rdg-checkbox-label-disabled ${bn}`, pn = /* @__PURE__ */ pt(function({
24
- onChange: t,
25
- ...n
26
- }, i) {
27
- function l(c) {
28
- t(c.target.checked, c.nativeEvent.shiftKey);
29
- }
30
- return /* @__PURE__ */ ne("label", {
31
- className: se(dn, n.disabled && hn),
32
- children: [/* @__PURE__ */ I("input", {
29
+ var css_248z$f = ".c1wupbe700-beta13{background-color:inherit;border-block-end:1px solid var(--rdg-border-color);border-inline-end:1px solid var(--rdg-border-color);contain:size style;grid-row-start:var(--rdg-grid-row-start);outline:none;overflow:hidden;overflow:clip;padding-block:0;padding-inline:8px;position:relative;text-overflow:ellipsis;white-space:nowrap}.c1wupbe700-beta13[aria-selected=true]{outline:2px solid var(--rdg-selection-color);outline-offset:-2px}.cd0kgiy700-beta13 .c1wupbe700-beta13{contain:content}.c1730fa4700-beta13{position:sticky;z-index:1}.c9dpaye700-beta13{box-shadow:calc(2px*var(--rdg-sign)) 0 5px -2px hsla(0,0%,53%,.3)}";
30
+ styleInject(css_248z$f, { "insertAt": "top" });
31
+ const cell = "c1wupbe700-beta13";
32
+ const cellClassname = `rdg-cell ${cell}`;
33
+ const cellAutoResizeClassname = "cd0kgiy700-beta13";
34
+ const cellFrozen = "c1730fa4700-beta13";
35
+ const cellFrozenClassname = `rdg-cell-frozen ${cellFrozen}`;
36
+ const cellFrozenLast = "c9dpaye700-beta13";
37
+ const cellFrozenLastClassname = `rdg-cell-frozen-last ${cellFrozenLast}`;
38
+ var css_248z$e = '.r104f42s700-beta13{--rdg-color:#000;--rdg-border-color:#ddd;--rdg-summary-border-color:#aaa;--rdg-background-color:#fff;--rdg-header-background-color:#f9f9f9;--rdg-row-hover-background-color:#f5f5f5;--rdg-row-selected-background-color:#dbecfa;--row-selected-hover-background-color:#c9e3f8;--rdg-checkbox-color:#005194;--rdg-checkbox-focus-color:#61b8ff;--rdg-checkbox-disabled-border-color:#ccc;--rdg-checkbox-disabled-background-color:#ddd;--rdg-selection-color:#66afe9;--rdg-font-size:14px;content-visibility:auto;background-color:var(--rdg-background-color);block-size:350px;border:1px solid var(--rdg-border-color);box-sizing:border-box;color:var(--rdg-color);color-scheme:var(--rdg-color-scheme,light dark);contain:strict;contain:size layout style paint;display:grid;font-size:var(--rdg-font-size);overflow:auto;user-select:none}@supports not (contain:strict){.r104f42s700-beta13{position:relative;z-index:0}}.r104f42s700-beta13 *,.r104f42s700-beta13 :after,.r104f42s700-beta13 :before{box-sizing:inherit}.r104f42s700-beta13:before{content:"";grid-column:1/-1;grid-row:1/-1}.r104f42s700-beta13.rdg-dark{--rdg-color-scheme:dark;--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}.r104f42s700-beta13.rdg-light{--rdg-color-scheme:light}@media (prefers-color-scheme:dark){.r104f42s700-beta13:not(.rdg-light){--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}}.v7ly7s700-beta13.r1otpg64700-beta13{cursor:move}.fc4f4zb700-beta13{grid-column:1/-1;pointer-events:none;z-index:4}';
39
+ styleInject(css_248z$e, { "insertAt": "top" });
40
+ const root = "r104f42s700-beta13";
41
+ const rootClassname = `rdg ${root}`;
42
+ const viewportDragging = "v7ly7s700-beta13";
43
+ const viewportDraggingClassname = `rdg-viewport-dragging ${viewportDragging}`;
44
+ const focusSinkClassname = "fc4f4zb700-beta13";
45
+ var css_248z$d = '.r1otpg64700-beta13{background-color:var(--rdg-background-color);display:contents;line-height:var(--rdg-row-height)}.r1otpg64700-beta13:hover{background-color:var(--rdg-row-hover-background-color)}.r1otpg64700-beta13[aria-selected=true]{background-color:var(--rdg-row-selected-background-color)}.r1otpg64700-beta13[aria-selected=true]:hover{background-color:var(--row-selected-hover-background-color)}.rel5gk2700-beta13{outline:2px solid var(--rdg-selection-color);outline-offset:-2px}.r1qymf1z700-beta13:before{border-inline-start:2px solid var(--rdg-selection-color);content:"";display:inline-block;height:100%;inset-inline-start:0;position:sticky}';
46
+ styleInject(css_248z$d, { "insertAt": "top" });
47
+ const row = "r1otpg64700-beta13";
48
+ const rowClassname = `rdg-row ${row}`;
49
+ const rowSelected = "rel5gk2700-beta13";
50
+ const rowSelectedClassname = `rdg-row-selected`;
51
+ const rowSelectedWithFrozenCell = "r1qymf1z700-beta13";
52
+ var css_248z$c = '.cd9l4jz700-beta13{align-items:center;cursor:pointer;display:flex;inset:0;justify-content:center;margin-inline-end:1px;position:absolute}.c1noyk41700-beta13{all:unset}.cdwjxv8700-beta13{background-color:var(--rdg-background-color);block-size:20px;border:2px solid var(--rdg-border-color);content:"";inline-size:20px}.c1noyk41700-beta13:checked+.cdwjxv8700-beta13{background-color:var(--rdg-checkbox-color);outline:4px solid var(--rdg-background-color);outline-offset:-6px}.c1noyk41700-beta13:focus+.cdwjxv8700-beta13{border-color:var(--rdg-checkbox-focus-color)}.cca4mwn700-beta13{cursor:default}.cca4mwn700-beta13 .cdwjxv8700-beta13{background-color:var(--rdg-checkbox-disabled-background-color);border-color:var(--rdg-checkbox-disabled-border-color)}';
53
+ styleInject(css_248z$c, { "insertAt": "top" });
54
+ const checkboxLabel = "cd9l4jz700-beta13";
55
+ const checkboxLabelClassname = `rdg-checkbox-label ${checkboxLabel}`;
56
+ const checkboxInput = "c1noyk41700-beta13";
57
+ const checkboxInputClassname = `rdg-checkbox-input ${checkboxInput}`;
58
+ const checkbox = "cdwjxv8700-beta13";
59
+ const checkboxClassname = `rdg-checkbox ${checkbox}`;
60
+ const checkboxLabelDisabled = "cca4mwn700-beta13";
61
+ const checkboxLabelDisabledClassname = `rdg-checkbox-label-disabled ${checkboxLabelDisabled}`;
62
+ const CheckboxFormatter = /* @__PURE__ */ forwardRef(function CheckboxFormatter2({
63
+ onChange,
64
+ ...props
65
+ }, ref) {
66
+ function handleChange(e) {
67
+ onChange(e.target.checked, e.nativeEvent.shiftKey);
68
+ }
69
+ return /* @__PURE__ */ jsxs("label", {
70
+ className: clsx(checkboxLabelClassname, props.disabled && checkboxLabelDisabledClassname),
71
+ children: [/* @__PURE__ */ jsx("input", {
33
72
  type: "checkbox",
34
- ref: i,
35
- ...n,
36
- className: un,
37
- onChange: l
38
- }), /* @__PURE__ */ I("div", {
39
- className: gn
73
+ ref,
74
+ ...props,
75
+ className: checkboxInputClassname,
76
+ onChange: handleChange
77
+ }), /* @__PURE__ */ jsx("div", {
78
+ className: checkboxClassname
40
79
  })]
41
80
  });
42
- }), Be = typeof window > "u" ? wt : Ko;
43
- function Ct(e) {
44
- const t = ce(null);
45
- return Be(() => {
46
- !e || t.current?.focus({
47
- preventScroll: !0
81
+ });
82
+ const useLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect$1;
83
+ function useFocusRef(isSelected) {
84
+ const ref = useRef(null);
85
+ useLayoutEffect(() => {
86
+ if (!isSelected)
87
+ return;
88
+ ref.current?.focus({
89
+ preventScroll: true
48
90
  });
49
- }, [e]), {
50
- ref: t,
51
- tabIndex: e ? 0 : -1
91
+ }, [isSelected]);
92
+ return {
93
+ ref,
94
+ tabIndex: isSelected ? 0 : -1
52
95
  };
53
96
  }
54
- const Yt = /* @__PURE__ */ xt(void 0), xn = Yt.Provider;
55
- function kt() {
56
- return ut(Yt);
97
+ const DataGridDefaultComponentsContext = /* @__PURE__ */ createContext(void 0);
98
+ const DataGridDefaultComponentsProvider = DataGridDefaultComponentsContext.Provider;
99
+ function useDefaultComponents() {
100
+ return useContext(DataGridDefaultComponentsContext);
57
101
  }
58
- function Vr({
59
- value: e,
60
- isCellSelected: t,
61
- disabled: n,
62
- onChange: i,
63
- "aria-label": l,
64
- "aria-labelledby": c
102
+ function SelectCellFormatter({
103
+ value,
104
+ isCellSelected,
105
+ disabled,
106
+ onChange,
107
+ "aria-label": ariaLabel,
108
+ "aria-labelledby": ariaLabelledBy
65
109
  }) {
66
110
  const {
67
- ref: d,
68
- tabIndex: C
69
- } = Ct(t), f = kt().checkboxFormatter;
70
- return /* @__PURE__ */ I(f, {
71
- "aria-label": l,
72
- "aria-labelledby": c,
73
- ref: d,
74
- tabIndex: C,
75
- disabled: n,
76
- checked: e,
77
- onChange: i
111
+ ref,
112
+ tabIndex
113
+ } = useFocusRef(isCellSelected);
114
+ const Formatter = useDefaultComponents().checkboxFormatter;
115
+ return /* @__PURE__ */ jsx(Formatter, {
116
+ "aria-label": ariaLabel,
117
+ "aria-labelledby": ariaLabelledBy,
118
+ ref,
119
+ tabIndex,
120
+ disabled,
121
+ checked: value,
122
+ onChange
78
123
  });
79
124
  }
80
- function wn(e) {
125
+ function ValueFormatter(props) {
81
126
  try {
82
- return /* @__PURE__ */ I(ze, {
83
- children: e.row[e.column.key]
127
+ return /* @__PURE__ */ jsx(Fragment, {
128
+ children: props.row[props.column.key]
84
129
  });
85
130
  } catch {
86
131
  return null;
87
132
  }
88
133
  }
89
- var mn = ".gch972y700-beta13{outline:none}.cz2qf0d700-beta13{stroke:currentColor;stroke-width:1.5px;fill:transparent;margin-inline-start:4px;vertical-align:middle}.cz2qf0d700-beta13>path{transition:d .1s}";
90
- G(mn, { insertAt: "top" });
91
- const Cn = "gch972y700-beta13", kn = `rdg-group-cell-content ${Cn}`, yn = "cz2qf0d700-beta13", Rn = `rdg-caret ${yn}`;
92
- function vn({
93
- groupKey: e,
94
- isExpanded: t,
95
- isCellSelected: n,
96
- toggleGroup: i
134
+ var css_248z$b = ".gch972y700-beta13{outline:none}.cz2qf0d700-beta13{stroke:currentColor;stroke-width:1.5px;fill:transparent;margin-inline-start:4px;vertical-align:middle}.cz2qf0d700-beta13>path{transition:d .1s}";
135
+ styleInject(css_248z$b, { "insertAt": "top" });
136
+ const groupCellContent = "gch972y700-beta13";
137
+ const groupCellContentClassname = `rdg-group-cell-content ${groupCellContent}`;
138
+ const caret = "cz2qf0d700-beta13";
139
+ const caretClassname = `rdg-caret ${caret}`;
140
+ function ToggleGroupFormatter({
141
+ groupKey,
142
+ isExpanded,
143
+ isCellSelected,
144
+ toggleGroup
97
145
  }) {
98
146
  const {
99
- ref: l,
100
- tabIndex: c
101
- } = Ct(n);
102
- function d({
103
- key: f
147
+ ref,
148
+ tabIndex
149
+ } = useFocusRef(isCellSelected);
150
+ function handleKeyDown({
151
+ key
104
152
  }) {
105
- f === "Enter" && i();
106
- }
107
- return /* @__PURE__ */ ne("span", {
108
- ref: l,
109
- className: kn,
110
- tabIndex: c,
111
- onKeyDown: d,
112
- children: [e, /* @__PURE__ */ I("svg", {
153
+ if (key === "Enter") {
154
+ toggleGroup();
155
+ }
156
+ }
157
+ const d = isExpanded ? "M1 1 L 7 7 L 13 1" : "M1 7 L 7 1 L 13 7";
158
+ return /* @__PURE__ */ jsxs("span", {
159
+ ref,
160
+ className: groupCellContentClassname,
161
+ tabIndex,
162
+ onKeyDown: handleKeyDown,
163
+ children: [groupKey, /* @__PURE__ */ jsx("svg", {
113
164
  viewBox: "0 0 14 8",
114
165
  width: "14",
115
166
  height: "8",
116
- className: Rn,
117
- "aria-hidden": !0,
118
- children: /* @__PURE__ */ I("path", {
119
- d: t ? "M1 1 L 7 7 L 13 1" : "M1 7 L 7 1 L 13 7"
167
+ className: caretClassname,
168
+ "aria-hidden": true,
169
+ children: /* @__PURE__ */ jsx("path", {
170
+ d
120
171
  })
121
172
  })]
122
173
  });
123
174
  }
124
- const Jt = /* @__PURE__ */ xt(void 0), Qt = Jt.Provider, Zt = /* @__PURE__ */ xt(void 0), In = Zt.Provider;
125
- function qr() {
126
- const e = ut(Jt), t = ut(Zt);
127
- if (e === void 0 || t === void 0)
175
+ const RowSelectionContext = /* @__PURE__ */ createContext(void 0);
176
+ const RowSelectionProvider = RowSelectionContext.Provider;
177
+ const RowSelectionChangeContext = /* @__PURE__ */ createContext(void 0);
178
+ const RowSelectionChangeProvider = RowSelectionChangeContext.Provider;
179
+ function useRowSelection() {
180
+ const rowSelectionContext = useContext(RowSelectionContext);
181
+ const rowSelectionChangeContext = useContext(RowSelectionChangeContext);
182
+ if (rowSelectionContext === void 0 || rowSelectionChangeContext === void 0) {
128
183
  throw new Error("useRowSelection must be used within DataGrid cells");
129
- return [e, t];
184
+ }
185
+ return [rowSelectionContext, rowSelectionChangeContext];
130
186
  }
131
- const ft = "select-row";
132
- function Z(e, t, n) {
133
- const i = typeof e.colSpan == "function" ? e.colSpan(n) : 1;
134
- if (Number.isInteger(i) && i > 1 && (!e.frozen || e.idx + i - 1 <= t))
135
- return i;
187
+ const SELECT_COLUMN_KEY = "select-row";
188
+ function getColSpan(column, lastFrozenColumnIndex, args) {
189
+ const colSpan = typeof column.colSpan === "function" ? column.colSpan(args) : 1;
190
+ if (Number.isInteger(colSpan) && colSpan > 1 && (!column.frozen || column.idx + colSpan - 1 <= lastFrozenColumnIndex)) {
191
+ return colSpan;
192
+ }
193
+ return void 0;
136
194
  }
137
- function gt(e) {
138
- e?.scrollIntoView({
195
+ function scrollIntoView(element) {
196
+ element?.scrollIntoView({
139
197
  inline: "nearest",
140
198
  block: "nearest"
141
199
  });
142
200
  }
143
- const Sn = /* @__PURE__ */ new Set(["Unidentified", "Alt", "AltGraph", "CapsLock", "Control", "Fn", "FnLock", "Meta", "NumLock", "ScrollLock", "Shift", "Tab", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "End", "Home", "PageDown", "PageUp", "Insert", "ContextMenu", "Escape", "Pause", "Play", "PrintScreen", "F1", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"]);
144
- function qt(e) {
201
+ const nonInputKeys = /* @__PURE__ */ new Set(["Unidentified", "Alt", "AltGraph", "CapsLock", "Control", "Fn", "FnLock", "Meta", "NumLock", "ScrollLock", "Shift", "Tab", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "End", "Home", "PageDown", "PageUp", "Insert", "ContextMenu", "Escape", "Pause", "Play", "PrintScreen", "F1", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"]);
202
+ function isCtrlKeyHeldDown(e) {
145
203
  return (e.ctrlKey || e.metaKey) && e.key !== "Control";
146
204
  }
147
- function zn(e) {
148
- return !Sn.has(e.key);
205
+ function isDefaultCellInput(event) {
206
+ return !nonInputKeys.has(event.key);
149
207
  }
150
- function En({
151
- key: e,
152
- target: t
208
+ function onEditorNavigation({
209
+ key,
210
+ target
153
211
  }) {
154
- return e === "Tab" && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) ? t.matches(".rdg-editor-container > :only-child, .rdg-editor-container > label:only-child > :only-child") : !1;
212
+ if (key === "Tab" && (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement)) {
213
+ return target.matches(".rdg-editor-container > :only-child, .rdg-editor-container > label:only-child > :only-child");
214
+ }
215
+ return false;
155
216
  }
156
- function Dn({
157
- selectedPosition: e,
158
- columns: t,
159
- rows: n,
160
- isGroupRow: i
217
+ function isSelectedCellEditable({
218
+ selectedPosition,
219
+ columns,
220
+ rows,
221
+ isGroupRow
161
222
  }) {
162
- const l = t[e.idx], c = n[e.rowIdx];
163
- return !i(c) && eo(l, c);
223
+ const column = columns[selectedPosition.idx];
224
+ const row2 = rows[selectedPosition.rowIdx];
225
+ return !isGroupRow(row2) && isCellEditable(column, row2);
164
226
  }
165
- function eo(e, t) {
166
- return e.editor != null && !e.rowGroup && (typeof e.editable == "function" ? e.editable(t) : e.editable) !== !1;
227
+ function isCellEditable(column, row2) {
228
+ return column.editor != null && !column.rowGroup && (typeof column.editable === "function" ? column.editable(row2) : column.editable) !== false;
167
229
  }
168
- function to({
169
- rows: e,
170
- summaryRows: t,
171
- rowIdx: n,
172
- lastFrozenColumnIndex: i,
173
- column: l,
174
- isGroupRow: c
230
+ function getSelectedCellColSpan({
231
+ rows,
232
+ summaryRows,
233
+ rowIdx,
234
+ lastFrozenColumnIndex,
235
+ column,
236
+ isGroupRow
175
237
  }) {
176
- if (n === -1)
177
- return Z(l, i, {
238
+ if (rowIdx === -1) {
239
+ return getColSpan(column, lastFrozenColumnIndex, {
178
240
  type: "HEADER"
179
241
  });
180
- if (n >= 0 && n < e.length) {
181
- const d = e[n];
182
- return c(d) ? void 0 : Z(l, i, {
183
- type: "ROW",
184
- row: d
185
- });
186
242
  }
187
- if (t)
188
- return Z(l, i, {
243
+ if (rowIdx >= 0 && rowIdx < rows.length) {
244
+ const row2 = rows[rowIdx];
245
+ if (!isGroupRow(row2)) {
246
+ return getColSpan(column, lastFrozenColumnIndex, {
247
+ type: "ROW",
248
+ row: row2
249
+ });
250
+ }
251
+ return void 0;
252
+ }
253
+ if (summaryRows) {
254
+ return getColSpan(column, lastFrozenColumnIndex, {
189
255
  type: "SUMMARY",
190
- row: t[n - e.length]
256
+ row: summaryRows[rowIdx - rows.length]
191
257
  });
258
+ }
259
+ return void 0;
192
260
  }
193
- function Fn({
194
- cellNavigationMode: e,
195
- columns: t,
196
- colSpanColumns: n,
197
- rows: i,
198
- summaryRows: l,
199
- minRowIdx: c,
200
- maxRowIdx: d,
261
+ function getNextSelectedCellPosition({
262
+ cellNavigationMode,
263
+ columns,
264
+ colSpanColumns,
265
+ rows,
266
+ summaryRows,
267
+ minRowIdx,
268
+ maxRowIdx,
201
269
  currentPosition: {
202
- idx: C
270
+ idx: currentIdx
203
271
  },
204
- nextPosition: f,
205
- lastFrozenColumnIndex: k,
206
- isCellWithinBounds: b,
207
- isGroupRow: w
272
+ nextPosition,
273
+ lastFrozenColumnIndex,
274
+ isCellWithinBounds,
275
+ isGroupRow
208
276
  }) {
209
277
  let {
210
- idx: g,
211
- rowIdx: s
212
- } = f;
213
- const v = (p) => {
214
- if (s >= 0 && s < i.length) {
215
- const E = i[s];
216
- if (w(E))
278
+ idx: nextIdx,
279
+ rowIdx: nextRowIdx
280
+ } = nextPosition;
281
+ const setColSpan = (moveRight) => {
282
+ if (nextRowIdx >= 0 && nextRowIdx < rows.length) {
283
+ const row2 = rows[nextRowIdx];
284
+ if (isGroupRow(row2))
217
285
  return;
218
286
  }
219
- for (const E of n) {
220
- const A = E.idx;
221
- if (A > g)
287
+ for (const column of colSpanColumns) {
288
+ const colIdx = column.idx;
289
+ if (colIdx > nextIdx)
222
290
  break;
223
- const _ = to({
224
- rows: i,
225
- summaryRows: l,
226
- rowIdx: s,
227
- lastFrozenColumnIndex: k,
228
- column: E,
229
- isGroupRow: w
291
+ const colSpan = getSelectedCellColSpan({
292
+ rows,
293
+ summaryRows,
294
+ rowIdx: nextRowIdx,
295
+ lastFrozenColumnIndex,
296
+ column,
297
+ isGroupRow
230
298
  });
231
- if (_ && g > A && g < _ + A) {
232
- g = A + (p ? _ : 0);
299
+ if (colSpan && nextIdx > colIdx && nextIdx < colSpan + colIdx) {
300
+ nextIdx = colIdx + (moveRight ? colSpan : 0);
233
301
  break;
234
302
  }
235
303
  }
236
304
  };
237
- if (b(f) && v(g - C > 0), e !== "NONE") {
238
- const p = t.length;
239
- g === p ? e === "CHANGE_ROW" ? s === d || (g = 0, s += 1) : g = 0 : g === -1 && (e === "CHANGE_ROW" ? s === c || (s -= 1, g = p - 1) : g = p - 1, v(!1));
305
+ if (isCellWithinBounds(nextPosition)) {
306
+ setColSpan(nextIdx - currentIdx > 0);
307
+ }
308
+ if (cellNavigationMode !== "NONE") {
309
+ const columnsCount = columns.length;
310
+ const isAfterLastColumn = nextIdx === columnsCount;
311
+ const isBeforeFirstColumn = nextIdx === -1;
312
+ if (isAfterLastColumn) {
313
+ if (cellNavigationMode === "CHANGE_ROW") {
314
+ const isLastRow = nextRowIdx === maxRowIdx;
315
+ if (!isLastRow) {
316
+ nextIdx = 0;
317
+ nextRowIdx += 1;
318
+ }
319
+ } else {
320
+ nextIdx = 0;
321
+ }
322
+ } else if (isBeforeFirstColumn) {
323
+ if (cellNavigationMode === "CHANGE_ROW") {
324
+ const isFirstRow = nextRowIdx === minRowIdx;
325
+ if (!isFirstRow) {
326
+ nextRowIdx -= 1;
327
+ nextIdx = columnsCount - 1;
328
+ }
329
+ } else {
330
+ nextIdx = columnsCount - 1;
331
+ }
332
+ setColSpan(false);
333
+ }
240
334
  }
241
335
  return {
242
- idx: g,
243
- rowIdx: s
336
+ idx: nextIdx,
337
+ rowIdx: nextRowIdx
244
338
  };
245
339
  }
246
- function $n({
247
- cellNavigationMode: e,
248
- maxColIdx: t,
249
- minRowIdx: n,
250
- maxRowIdx: i,
340
+ function canExitGrid({
341
+ cellNavigationMode,
342
+ maxColIdx,
343
+ minRowIdx,
344
+ maxRowIdx,
251
345
  selectedPosition: {
252
- rowIdx: l,
253
- idx: c
346
+ rowIdx,
347
+ idx
254
348
  },
255
- shiftKey: d
349
+ shiftKey
256
350
  }) {
257
- return e === "NONE" || e === "CHANGE_ROW" ? d ? c === 0 && l === n : c === t && l === i : !1;
351
+ if (cellNavigationMode === "NONE" || cellNavigationMode === "CHANGE_ROW") {
352
+ const atLastCellInRow = idx === maxColIdx;
353
+ const atFirstCellInRow = idx === 0;
354
+ const atLastRow = rowIdx === maxRowIdx;
355
+ const atFirstRow = rowIdx === minRowIdx;
356
+ return shiftKey ? atFirstCellInRow && atFirstRow : atLastCellInRow && atLastRow;
357
+ }
358
+ return false;
258
359
  }
259
- function qe(e, t) {
260
- return t !== void 0 ? {
261
- "--rdg-grid-row-start": e,
262
- "--rdg-row-height": `${t}px`
263
- } : {
264
- "--rdg-grid-row-start": e
360
+ function getRowStyle(rowIdx, height) {
361
+ if (height !== void 0) {
362
+ return {
363
+ "--rdg-grid-row-start": rowIdx,
364
+ "--rdg-row-height": `${height}px`
365
+ };
366
+ }
367
+ return {
368
+ "--rdg-grid-row-start": rowIdx
265
369
  };
266
370
  }
267
- function Ee(e, t) {
371
+ function getCellStyle(column, colSpan) {
268
372
  return {
269
- gridColumnStart: e.idx + 1,
270
- gridColumnEnd: t !== void 0 ? `span ${t}` : void 0,
271
- insetInlineStart: e.frozen ? `var(--rdg-frozen-left-${e.idx})` : void 0
373
+ gridColumnStart: column.idx + 1,
374
+ gridColumnEnd: colSpan !== void 0 ? `span ${colSpan}` : void 0,
375
+ insetInlineStart: column.frozen ? `var(--rdg-frozen-left-${column.idx})` : void 0
272
376
  };
273
377
  }
274
- function De(e, ...t) {
275
- return se(Bo, ...t, e.frozen && qo, e.isLastFrozenColumn && Xo);
378
+ function getCellClassname(column, ...extraClasses) {
379
+ return clsx(cellClassname, ...extraClasses, column.frozen && cellFrozenClassname, column.isLastFrozenColumn && cellFrozenLastClassname);
276
380
  }
277
381
  const {
278
- min: Se,
279
- max: Ge,
280
- round: Ln,
281
- floor: bt,
282
- sign: An,
283
- abs: On,
284
- ceil: Tn
382
+ min,
383
+ max,
384
+ round,
385
+ floor,
386
+ sign,
387
+ abs,
388
+ ceil
285
389
  } = Math;
286
- function dt(e) {
287
- if (typeof e != "function")
390
+ function assertIsValidKeyGetter(keyGetter) {
391
+ if (typeof keyGetter !== "function") {
288
392
  throw new Error("Please specify the rowKeyGetter prop to use selection");
393
+ }
289
394
  }
290
- function ht(e, {
291
- minWidth: t,
292
- maxWidth: n
395
+ function clampColumnWidth(width, {
396
+ minWidth,
397
+ maxWidth
293
398
  }) {
294
- return e = Ge(e, t), typeof n == "number" && n >= t ? Se(e, n) : e;
399
+ width = max(width, minWidth);
400
+ if (typeof maxWidth === "number" && maxWidth >= minWidth) {
401
+ return min(width, maxWidth);
402
+ }
403
+ return width;
295
404
  }
296
- function Nn({
297
- rawColumns: e,
298
- columnWidths: t,
299
- viewportWidth: n,
300
- scrollLeft: i,
301
- defaultColumnOptions: l,
302
- rawGroupBy: c,
303
- enableVirtualization: d
405
+ function useCalculatedColumns({
406
+ rawColumns,
407
+ columnWidths,
408
+ viewportWidth,
409
+ scrollLeft,
410
+ defaultColumnOptions,
411
+ rawGroupBy,
412
+ enableVirtualization
304
413
  }) {
305
- const C = l?.width, f = l?.minWidth ?? 80, k = l?.maxWidth, b = l?.formatter ?? wn, w = l?.sortable ?? !1, g = l?.resizable ?? !1, {
306
- columns: s,
307
- colSpanColumns: v,
308
- lastFrozenColumnIndex: p,
309
- groupBy: E
310
- } = Q(() => {
311
- const O = [];
312
- let y = -1;
313
- const z = e.map((h) => {
314
- const x = c?.includes(h.key) ?? !1, D = x || h.frozen || !1, m = {
315
- ...h,
414
+ const defaultWidth = defaultColumnOptions?.width;
415
+ const defaultMinWidth = defaultColumnOptions?.minWidth ?? 80;
416
+ const defaultMaxWidth = defaultColumnOptions?.maxWidth;
417
+ const defaultFormatter = defaultColumnOptions?.formatter ?? ValueFormatter;
418
+ const defaultSortable = defaultColumnOptions?.sortable ?? false;
419
+ const defaultResizable = defaultColumnOptions?.resizable ?? false;
420
+ const {
421
+ columns,
422
+ colSpanColumns,
423
+ lastFrozenColumnIndex,
424
+ groupBy
425
+ } = useMemo(() => {
426
+ const groupBy2 = [];
427
+ let lastFrozenColumnIndex2 = -1;
428
+ const columns2 = rawColumns.map((rawColumn) => {
429
+ const rowGroup = rawGroupBy?.includes(rawColumn.key) ?? false;
430
+ const frozen = rowGroup || rawColumn.frozen || false;
431
+ const column = {
432
+ ...rawColumn,
316
433
  idx: 0,
317
- frozen: D,
318
- isLastFrozenColumn: !1,
319
- rowGroup: x,
320
- width: h.width ?? C,
321
- minWidth: h.minWidth ?? f,
322
- maxWidth: h.maxWidth ?? k,
323
- sortable: h.sortable ?? w,
324
- resizable: h.resizable ?? g,
325
- formatter: h.formatter ?? b
434
+ frozen,
435
+ isLastFrozenColumn: false,
436
+ rowGroup,
437
+ width: rawColumn.width ?? defaultWidth,
438
+ minWidth: rawColumn.minWidth ?? defaultMinWidth,
439
+ maxWidth: rawColumn.maxWidth ?? defaultMaxWidth,
440
+ sortable: rawColumn.sortable ?? defaultSortable,
441
+ resizable: rawColumn.resizable ?? defaultResizable,
442
+ formatter: rawColumn.formatter ?? defaultFormatter
326
443
  };
327
- return x && (m.groupFormatter ?? (m.groupFormatter = vn)), D && y++, m;
444
+ if (rowGroup) {
445
+ column.groupFormatter ?? (column.groupFormatter = ToggleGroupFormatter);
446
+ }
447
+ if (frozen) {
448
+ lastFrozenColumnIndex2++;
449
+ }
450
+ return column;
328
451
  });
329
- z.sort(({
330
- key: h,
331
- frozen: x
452
+ columns2.sort(({
453
+ key: aKey,
454
+ frozen: frozenA
332
455
  }, {
333
- key: D,
334
- frozen: m
335
- }) => h === ft ? -1 : D === ft ? 1 : c?.includes(h) ? c.includes(D) ? c.indexOf(h) - c.indexOf(D) : -1 : c?.includes(D) ? 1 : x ? m ? 0 : -1 : m ? 1 : 0);
336
- const S = [];
337
- return z.forEach((h, x) => {
338
- h.idx = x, h.rowGroup && O.push(h.key), h.colSpan != null && S.push(h);
339
- }), y !== -1 && (z[y].isLastFrozenColumn = !0), {
340
- columns: z,
341
- colSpanColumns: S,
342
- lastFrozenColumnIndex: y,
343
- groupBy: O
456
+ key: bKey,
457
+ frozen: frozenB
458
+ }) => {
459
+ if (aKey === SELECT_COLUMN_KEY)
460
+ return -1;
461
+ if (bKey === SELECT_COLUMN_KEY)
462
+ return 1;
463
+ if (rawGroupBy?.includes(aKey)) {
464
+ if (rawGroupBy.includes(bKey)) {
465
+ return rawGroupBy.indexOf(aKey) - rawGroupBy.indexOf(bKey);
466
+ }
467
+ return -1;
468
+ }
469
+ if (rawGroupBy?.includes(bKey))
470
+ return 1;
471
+ if (frozenA) {
472
+ if (frozenB)
473
+ return 0;
474
+ return -1;
475
+ }
476
+ if (frozenB)
477
+ return 1;
478
+ return 0;
479
+ });
480
+ const colSpanColumns2 = [];
481
+ columns2.forEach((column, idx) => {
482
+ column.idx = idx;
483
+ if (column.rowGroup) {
484
+ groupBy2.push(column.key);
485
+ }
486
+ if (column.colSpan != null) {
487
+ colSpanColumns2.push(column);
488
+ }
489
+ });
490
+ if (lastFrozenColumnIndex2 !== -1) {
491
+ columns2[lastFrozenColumnIndex2].isLastFrozenColumn = true;
492
+ }
493
+ return {
494
+ columns: columns2,
495
+ colSpanColumns: colSpanColumns2,
496
+ lastFrozenColumnIndex: lastFrozenColumnIndex2,
497
+ groupBy: groupBy2
344
498
  };
345
- }, [e, C, f, k, b, g, w, c]), {
346
- layoutCssVars: A,
347
- totalFrozenColumnWidth: _,
348
- columnMetrics: H
349
- } = Q(() => {
350
- const O = /* @__PURE__ */ new Map();
351
- let y = 0, z = 0, S = "", h = 0, x = 0;
352
- for (const m of s) {
353
- let F = Pn(m, t, n);
354
- F === void 0 ? x++ : (F = ht(F, m), h += F, O.set(m, {
355
- width: F,
356
- left: 0
357
- }));
499
+ }, [rawColumns, defaultWidth, defaultMinWidth, defaultMaxWidth, defaultFormatter, defaultResizable, defaultSortable, rawGroupBy]);
500
+ const {
501
+ layoutCssVars,
502
+ totalFrozenColumnWidth,
503
+ columnMetrics
504
+ } = useMemo(() => {
505
+ const columnMetrics2 = /* @__PURE__ */ new Map();
506
+ let left = 0;
507
+ let totalFrozenColumnWidth2 = 0;
508
+ let templateColumns = "";
509
+ let allocatedWidth = 0;
510
+ let unassignedColumnsCount = 0;
511
+ for (const column of columns) {
512
+ let width = getSpecifiedWidth(column, columnWidths, viewportWidth);
513
+ if (width === void 0) {
514
+ unassignedColumnsCount++;
515
+ } else {
516
+ width = clampColumnWidth(width, column);
517
+ allocatedWidth += width;
518
+ columnMetrics2.set(column, {
519
+ width,
520
+ left: 0
521
+ });
522
+ }
358
523
  }
359
- for (const m of s) {
360
- let F;
361
- if (O.has(m)) {
362
- const V = O.get(m);
363
- V.left = y, {
364
- width: F
365
- } = V;
524
+ for (const column of columns) {
525
+ let width;
526
+ if (columnMetrics2.has(column)) {
527
+ const columnMetric = columnMetrics2.get(column);
528
+ columnMetric.left = left;
529
+ ({
530
+ width
531
+ } = columnMetric);
366
532
  } else {
367
- const V = n - h, ee = Ln(V / x);
368
- F = ht(ee, m), h += F, x--, O.set(m, {
369
- width: F,
370
- left: y
533
+ const unallocatedWidth = viewportWidth - allocatedWidth;
534
+ const unallocatedColumnWidth = round(unallocatedWidth / unassignedColumnsCount);
535
+ width = clampColumnWidth(unallocatedColumnWidth, column);
536
+ allocatedWidth += width;
537
+ unassignedColumnsCount--;
538
+ columnMetrics2.set(column, {
539
+ width,
540
+ left
371
541
  });
372
542
  }
373
- y += F, S += `${F}px `;
543
+ left += width;
544
+ templateColumns += `${width}px `;
374
545
  }
375
- if (p !== -1) {
376
- const m = O.get(s[p]);
377
- z = m.left + m.width;
546
+ if (lastFrozenColumnIndex !== -1) {
547
+ const columnMetric = columnMetrics2.get(columns[lastFrozenColumnIndex]);
548
+ totalFrozenColumnWidth2 = columnMetric.left + columnMetric.width;
378
549
  }
379
- const D = {
380
- gridTemplateColumns: S
550
+ const layoutCssVars2 = {
551
+ gridTemplateColumns: templateColumns
381
552
  };
382
- for (let m = 0; m <= p; m++) {
383
- const F = s[m];
384
- D[`--rdg-frozen-left-${F.idx}`] = `${O.get(F).left}px`;
553
+ for (let i = 0; i <= lastFrozenColumnIndex; i++) {
554
+ const column = columns[i];
555
+ layoutCssVars2[`--rdg-frozen-left-${column.idx}`] = `${columnMetrics2.get(column).left}px`;
385
556
  }
386
557
  return {
387
- layoutCssVars: D,
388
- totalFrozenColumnWidth: z,
389
- columnMetrics: O
558
+ layoutCssVars: layoutCssVars2,
559
+ totalFrozenColumnWidth: totalFrozenColumnWidth2,
560
+ columnMetrics: columnMetrics2
390
561
  };
391
- }, [t, s, n, p]), [M, T] = Q(() => {
392
- if (!d)
393
- return [0, s.length - 1];
394
- const O = i + _, y = i + n, z = s.length - 1, S = Se(p + 1, z);
395
- if (O >= y)
396
- return [S, S];
397
- let h = S;
398
- for (; h < z; ) {
562
+ }, [columnWidths, columns, viewportWidth, lastFrozenColumnIndex]);
563
+ const [colOverscanStartIdx, colOverscanEndIdx] = useMemo(() => {
564
+ if (!enableVirtualization) {
565
+ return [0, columns.length - 1];
566
+ }
567
+ const viewportLeft = scrollLeft + totalFrozenColumnWidth;
568
+ const viewportRight = scrollLeft + viewportWidth;
569
+ const lastColIdx = columns.length - 1;
570
+ const firstUnfrozenColumnIdx = min(lastFrozenColumnIndex + 1, lastColIdx);
571
+ if (viewportLeft >= viewportRight) {
572
+ return [firstUnfrozenColumnIdx, firstUnfrozenColumnIdx];
573
+ }
574
+ let colVisibleStartIdx = firstUnfrozenColumnIdx;
575
+ while (colVisibleStartIdx < lastColIdx) {
399
576
  const {
400
- left: F,
401
- width: V
402
- } = H.get(s[h]);
403
- if (F + V > O)
577
+ left,
578
+ width
579
+ } = columnMetrics.get(columns[colVisibleStartIdx]);
580
+ if (left + width > viewportLeft) {
404
581
  break;
405
- h++;
582
+ }
583
+ colVisibleStartIdx++;
406
584
  }
407
- let x = h;
408
- for (; x < z; ) {
585
+ let colVisibleEndIdx = colVisibleStartIdx;
586
+ while (colVisibleEndIdx < lastColIdx) {
409
587
  const {
410
- left: F,
411
- width: V
412
- } = H.get(s[x]);
413
- if (F + V >= y)
588
+ left,
589
+ width
590
+ } = columnMetrics.get(columns[colVisibleEndIdx]);
591
+ if (left + width >= viewportRight) {
414
592
  break;
415
- x++;
593
+ }
594
+ colVisibleEndIdx++;
416
595
  }
417
- const D = Ge(S, h - 1), m = Se(z, x + 1);
418
- return [D, m];
419
- }, [H, s, p, i, _, n, d]);
596
+ const colOverscanStartIdx2 = max(firstUnfrozenColumnIdx, colVisibleStartIdx - 1);
597
+ const colOverscanEndIdx2 = min(lastColIdx, colVisibleEndIdx + 1);
598
+ return [colOverscanStartIdx2, colOverscanEndIdx2];
599
+ }, [columnMetrics, columns, lastFrozenColumnIndex, scrollLeft, totalFrozenColumnWidth, viewportWidth, enableVirtualization]);
420
600
  return {
421
- columns: s,
422
- colSpanColumns: v,
423
- colOverscanStartIdx: M,
424
- colOverscanEndIdx: T,
425
- layoutCssVars: A,
426
- columnMetrics: H,
427
- lastFrozenColumnIndex: p,
428
- totalFrozenColumnWidth: _,
429
- groupBy: E
601
+ columns,
602
+ colSpanColumns,
603
+ colOverscanStartIdx,
604
+ colOverscanEndIdx,
605
+ layoutCssVars,
606
+ columnMetrics,
607
+ lastFrozenColumnIndex,
608
+ totalFrozenColumnWidth,
609
+ groupBy
430
610
  };
431
611
  }
432
- function Pn({
433
- key: e,
434
- width: t
435
- }, n, i) {
436
- if (n.has(e))
437
- return n.get(e);
438
- if (typeof t == "number")
439
- return t;
440
- if (typeof t == "string" && /^\d+%$/.test(t))
441
- return bt(i * parseInt(t, 10) / 100);
612
+ function getSpecifiedWidth({
613
+ key,
614
+ width
615
+ }, columnWidths, viewportWidth) {
616
+ if (columnWidths.has(key)) {
617
+ return columnWidths.get(key);
618
+ }
619
+ if (typeof width === "number") {
620
+ return width;
621
+ }
622
+ if (typeof width === "string" && /^\d+%$/.test(width)) {
623
+ return floor(viewportWidth * parseInt(width, 10) / 100);
624
+ }
625
+ return void 0;
442
626
  }
443
- function Mn() {
444
- const e = ce(null), [t, n] = Y(1), [i, l] = Y(1);
445
- return Be(() => {
627
+ function useGridDimensions() {
628
+ const gridRef = useRef(null);
629
+ const [inlineSize, setInlineSize] = useState(1);
630
+ const [blockSize, setBlockSize] = useState(1);
631
+ useLayoutEffect(() => {
446
632
  const {
447
- ResizeObserver: c
633
+ ResizeObserver
448
634
  } = window;
449
- if (c == null)
635
+ if (ResizeObserver == null)
450
636
  return;
451
637
  const {
452
- clientWidth: d,
453
- clientHeight: C,
454
- offsetWidth: f,
455
- offsetHeight: k
456
- } = e.current, {
457
- width: b,
458
- height: w
459
- } = e.current.getBoundingClientRect(), g = b - f + d, s = w - k + C;
460
- n(Ut(g)), l(s);
461
- const v = new c((p) => {
462
- const E = p[0].contentBoxSize[0];
463
- n(Ut(E.inlineSize)), l(E.blockSize);
638
+ clientWidth,
639
+ clientHeight,
640
+ offsetWidth,
641
+ offsetHeight
642
+ } = gridRef.current;
643
+ const {
644
+ width,
645
+ height
646
+ } = gridRef.current.getBoundingClientRect();
647
+ const initialWidth = width - offsetWidth + clientWidth;
648
+ const initialHeight = height - offsetHeight + clientHeight;
649
+ setInlineSize(handleDevicePixelRatio(initialWidth));
650
+ setBlockSize(initialHeight);
651
+ const resizeObserver = new ResizeObserver((entries) => {
652
+ const size = entries[0].contentBoxSize[0];
653
+ setInlineSize(handleDevicePixelRatio(size.inlineSize));
654
+ setBlockSize(size.blockSize);
464
655
  });
465
- return v.observe(e.current), () => {
466
- v.disconnect();
656
+ resizeObserver.observe(gridRef.current);
657
+ return () => {
658
+ resizeObserver.disconnect();
467
659
  };
468
- }, []), [e, t, i];
660
+ }, []);
661
+ return [gridRef, inlineSize, blockSize];
469
662
  }
470
- function Ut(e) {
471
- return e - (devicePixelRatio === 1 ? 0 : Tn(devicePixelRatio));
663
+ function handleDevicePixelRatio(size) {
664
+ return size - (devicePixelRatio === 1 ? 0 : ceil(devicePixelRatio));
472
665
  }
473
- function J(e) {
474
- const t = ce(e);
475
- return wt(() => {
476
- t.current = e;
477
- }), je((...n) => {
478
- t.current(...n);
666
+ function useLatestFunc(fn) {
667
+ const ref = useRef(fn);
668
+ useEffect(() => {
669
+ ref.current = fn;
670
+ });
671
+ return useCallback((...args) => {
672
+ ref.current(...args);
479
673
  }, []);
480
674
  }
481
- function Ue(e) {
482
- const [t, n] = Y(!1);
483
- t && !e && n(!1);
484
- const i = je((d) => {
485
- d !== null && (gt(d), !d.contains(document.activeElement) && d.focus({
486
- preventScroll: !0
487
- }));
675
+ function useRovingCellRef(isSelected) {
676
+ const [isChildFocused, setIsChildFocused] = useState(false);
677
+ if (isChildFocused && !isSelected) {
678
+ setIsChildFocused(false);
679
+ }
680
+ const ref = useCallback((cell2) => {
681
+ if (cell2 === null)
682
+ return;
683
+ scrollIntoView(cell2);
684
+ if (cell2.contains(document.activeElement))
685
+ return;
686
+ cell2.focus({
687
+ preventScroll: true
688
+ });
488
689
  }, []);
489
- function l(d) {
490
- d.target !== d.currentTarget && n(!0);
690
+ function onFocus(event) {
691
+ if (event.target !== event.currentTarget) {
692
+ setIsChildFocused(true);
693
+ }
491
694
  }
695
+ const isFocused = isSelected && !isChildFocused;
492
696
  return {
493
- ref: e ? i : void 0,
494
- tabIndex: e && !t ? 0 : -1,
495
- onFocus: e ? l : void 0
697
+ ref: isSelected ? ref : void 0,
698
+ tabIndex: isFocused ? 0 : -1,
699
+ onFocus: isSelected ? onFocus : void 0
496
700
  };
497
701
  }
498
- function Wn({
499
- columns: e,
500
- colSpanColumns: t,
501
- rows: n,
502
- summaryRows: i,
503
- colOverscanStartIdx: l,
504
- colOverscanEndIdx: c,
505
- lastFrozenColumnIndex: d,
506
- rowOverscanStartIdx: C,
507
- rowOverscanEndIdx: f,
508
- isGroupRow: k
702
+ function useViewportColumns({
703
+ columns,
704
+ colSpanColumns,
705
+ rows,
706
+ summaryRows,
707
+ colOverscanStartIdx,
708
+ colOverscanEndIdx,
709
+ lastFrozenColumnIndex,
710
+ rowOverscanStartIdx,
711
+ rowOverscanEndIdx,
712
+ isGroupRow
509
713
  }) {
510
- const b = Q(() => {
511
- if (l === 0)
714
+ const startIdx = useMemo(() => {
715
+ if (colOverscanStartIdx === 0)
512
716
  return 0;
513
- let w = l;
514
- const g = (s, v) => v !== void 0 && s + v > l ? (w = s, !0) : !1;
515
- for (const s of t) {
516
- const v = s.idx;
517
- if (v >= w || g(v, Z(s, d, {
717
+ let startIdx2 = colOverscanStartIdx;
718
+ const updateStartIdx = (colIdx, colSpan) => {
719
+ if (colSpan !== void 0 && colIdx + colSpan > colOverscanStartIdx) {
720
+ startIdx2 = colIdx;
721
+ return true;
722
+ }
723
+ return false;
724
+ };
725
+ for (const column of colSpanColumns) {
726
+ const colIdx = column.idx;
727
+ if (colIdx >= startIdx2)
728
+ break;
729
+ if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
518
730
  type: "HEADER"
519
- })))
731
+ }))) {
520
732
  break;
521
- for (let p = C; p <= f; p++) {
522
- const E = n[p];
523
- if (!k(E) && g(v, Z(s, d, {
733
+ }
734
+ for (let rowIdx = rowOverscanStartIdx; rowIdx <= rowOverscanEndIdx; rowIdx++) {
735
+ const row2 = rows[rowIdx];
736
+ if (isGroupRow(row2))
737
+ continue;
738
+ if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
524
739
  type: "ROW",
525
- row: E
526
- })))
740
+ row: row2
741
+ }))) {
527
742
  break;
743
+ }
528
744
  }
529
- if (i != null) {
530
- for (const p of i)
531
- if (g(v, Z(s, d, {
745
+ if (summaryRows != null) {
746
+ for (const row2 of summaryRows) {
747
+ if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
532
748
  type: "SUMMARY",
533
- row: p
534
- })))
749
+ row: row2
750
+ }))) {
535
751
  break;
752
+ }
753
+ }
536
754
  }
537
755
  }
538
- return w;
539
- }, [C, f, n, i, l, d, t, k]);
540
- return Q(() => {
541
- const w = [];
542
- for (let g = 0; g <= c; g++) {
543
- const s = e[g];
544
- g < b && !s.frozen || w.push(s);
756
+ return startIdx2;
757
+ }, [rowOverscanStartIdx, rowOverscanEndIdx, rows, summaryRows, colOverscanStartIdx, lastFrozenColumnIndex, colSpanColumns, isGroupRow]);
758
+ return useMemo(() => {
759
+ const viewportColumns = [];
760
+ for (let colIdx = 0; colIdx <= colOverscanEndIdx; colIdx++) {
761
+ const column = columns[colIdx];
762
+ if (colIdx < startIdx && !column.frozen)
763
+ continue;
764
+ viewportColumns.push(column);
545
765
  }
546
- return w;
547
- }, [b, c, e]);
766
+ return viewportColumns;
767
+ }, [startIdx, colOverscanEndIdx, columns]);
548
768
  }
549
- function Hn(e) {
550
- return Array.isArray(e);
769
+ function isReadonlyArray(arr) {
770
+ return Array.isArray(arr);
551
771
  }
552
- function Kn({
553
- rawRows: e,
554
- rowHeight: t,
555
- clientHeight: n,
556
- scrollTop: i,
557
- groupBy: l,
558
- rowGrouper: c,
559
- expandedGroupIds: d,
560
- enableVirtualization: C
772
+ function useViewportRows({
773
+ rawRows,
774
+ rowHeight,
775
+ clientHeight,
776
+ scrollTop,
777
+ groupBy,
778
+ rowGrouper,
779
+ expandedGroupIds,
780
+ enableVirtualization
561
781
  }) {
562
- const [f, k] = Q(() => {
563
- if (l.length === 0 || c == null)
564
- return [void 0, e.length];
565
- const H = (M, [T, ...O], y) => {
566
- let z = 0;
567
- const S = {};
568
- for (const [h, x] of Object.entries(c(M, T))) {
569
- const [D, m] = O.length === 0 ? [x, x.length] : H(x, O, y + z + 1);
570
- S[h] = {
571
- childRows: x,
572
- childGroups: D,
573
- startRowIndex: y + z
574
- }, z += m + 1;
782
+ const [groupedRows, rowsCount] = useMemo(() => {
783
+ if (groupBy.length === 0 || rowGrouper == null)
784
+ return [void 0, rawRows.length];
785
+ const groupRows = (rows2, [groupByKey, ...remainingGroupByKeys], startRowIndex) => {
786
+ let groupRowsCount = 0;
787
+ const groups = {};
788
+ for (const [key, childRows] of Object.entries(rowGrouper(rows2, groupByKey))) {
789
+ const [childGroups, childRowsCount] = remainingGroupByKeys.length === 0 ? [childRows, childRows.length] : groupRows(childRows, remainingGroupByKeys, startRowIndex + groupRowsCount + 1);
790
+ groups[key] = {
791
+ childRows,
792
+ childGroups,
793
+ startRowIndex: startRowIndex + groupRowsCount
794
+ };
795
+ groupRowsCount += childRowsCount + 1;
575
796
  }
576
- return [S, z];
797
+ return [groups, groupRowsCount];
577
798
  };
578
- return H(e, l, 0);
579
- }, [l, c, e]), [b, w] = Q(() => {
580
- const H = /* @__PURE__ */ new Set();
581
- if (!f)
582
- return [e, O];
583
- const M = [], T = (y, z, S) => {
584
- if (Hn(y)) {
585
- M.push(...y);
799
+ return groupRows(rawRows, groupBy, 0);
800
+ }, [groupBy, rowGrouper, rawRows]);
801
+ const [rows, isGroupRow] = useMemo(() => {
802
+ const allGroupRows = /* @__PURE__ */ new Set();
803
+ if (!groupedRows)
804
+ return [rawRows, isGroupRow2];
805
+ const flattenedRows = [];
806
+ const expandGroup = (rows2, parentId, level) => {
807
+ if (isReadonlyArray(rows2)) {
808
+ flattenedRows.push(...rows2);
586
809
  return;
587
810
  }
588
- Object.keys(y).forEach((h, x, D) => {
589
- const m = z !== void 0 ? `${z}__${h}` : h, F = d?.has(m) ?? !1, {
590
- childRows: V,
591
- childGroups: ee,
592
- startRowIndex: ue
593
- } = y[h], le = {
594
- id: m,
595
- parentId: z,
596
- groupKey: h,
597
- isExpanded: F,
598
- childRows: V,
599
- level: S,
600
- posInSet: x,
601
- startRowIndex: ue,
602
- setSize: D.length
811
+ Object.keys(rows2).forEach((groupKey, posInSet, keys) => {
812
+ const id = parentId !== void 0 ? `${parentId}__${groupKey}` : groupKey;
813
+ const isExpanded = expandedGroupIds?.has(id) ?? false;
814
+ const {
815
+ childRows,
816
+ childGroups,
817
+ startRowIndex
818
+ } = rows2[groupKey];
819
+ const groupRow2 = {
820
+ id,
821
+ parentId,
822
+ groupKey,
823
+ isExpanded,
824
+ childRows,
825
+ level,
826
+ posInSet,
827
+ startRowIndex,
828
+ setSize: keys.length
603
829
  };
604
- M.push(le), H.add(le), F && T(ee, m, S + 1);
830
+ flattenedRows.push(groupRow2);
831
+ allGroupRows.add(groupRow2);
832
+ if (isExpanded) {
833
+ expandGroup(childGroups, id, level + 1);
834
+ }
605
835
  });
606
836
  };
607
- return T(f, void 0, 0), [M, O];
608
- function O(y) {
609
- return H.has(y);
837
+ expandGroup(groupedRows, void 0, 0);
838
+ return [flattenedRows, isGroupRow2];
839
+ function isGroupRow2(row2) {
840
+ return allGroupRows.has(row2);
610
841
  }
611
- }, [d, f, e]), {
612
- totalRowHeight: g,
613
- gridTemplateRows: s,
614
- getRowTop: v,
615
- getRowHeight: p,
616
- findRowIdx: E
617
- } = Q(() => {
618
- if (typeof t == "number")
842
+ }, [expandedGroupIds, groupedRows, rawRows]);
843
+ const {
844
+ totalRowHeight,
845
+ gridTemplateRows,
846
+ getRowTop,
847
+ getRowHeight,
848
+ findRowIdx
849
+ } = useMemo(() => {
850
+ if (typeof rowHeight === "number") {
619
851
  return {
620
- totalRowHeight: t * b.length,
621
- gridTemplateRows: ` repeat(${b.length}, ${t}px)`,
622
- getRowTop: (y) => y * t,
623
- getRowHeight: () => t,
624
- findRowIdx: (y) => bt(y / t)
852
+ totalRowHeight: rowHeight * rows.length,
853
+ gridTemplateRows: ` repeat(${rows.length}, ${rowHeight}px)`,
854
+ getRowTop: (rowIdx) => rowIdx * rowHeight,
855
+ getRowHeight: () => rowHeight,
856
+ findRowIdx: (offset) => floor(offset / rowHeight)
625
857
  };
626
- let H = 0, M = " ";
627
- const T = b.map((y) => {
628
- const z = w(y) ? t({
858
+ }
859
+ let totalRowHeight2 = 0;
860
+ let gridTemplateRows2 = " ";
861
+ const rowPositions = rows.map((row2) => {
862
+ const currentRowHeight = isGroupRow(row2) ? rowHeight({
629
863
  type: "GROUP",
630
- row: y
631
- }) : t({
864
+ row: row2
865
+ }) : rowHeight({
632
866
  type: "ROW",
633
- row: y
634
- }), S = {
635
- top: H,
636
- height: z
867
+ row: row2
868
+ });
869
+ const position = {
870
+ top: totalRowHeight2,
871
+ height: currentRowHeight
637
872
  };
638
- return M += `${z}px `, H += z, S;
639
- }), O = (y) => Ge(0, Se(b.length - 1, y));
873
+ gridTemplateRows2 += `${currentRowHeight}px `;
874
+ totalRowHeight2 += currentRowHeight;
875
+ return position;
876
+ });
877
+ const validateRowIdx = (rowIdx) => {
878
+ return max(0, min(rows.length - 1, rowIdx));
879
+ };
640
880
  return {
641
- totalRowHeight: H,
642
- gridTemplateRows: M,
643
- getRowTop: (y) => T[O(y)].top,
644
- getRowHeight: (y) => T[O(y)].height,
645
- findRowIdx(y) {
646
- let z = 0, S = T.length - 1;
647
- for (; z <= S; ) {
648
- const h = z + bt((S - z) / 2), x = T[h].top;
649
- if (x === y)
650
- return h;
651
- if (x < y ? z = h + 1 : x > y && (S = h - 1), z > S)
652
- return S;
881
+ totalRowHeight: totalRowHeight2,
882
+ gridTemplateRows: gridTemplateRows2,
883
+ getRowTop: (rowIdx) => rowPositions[validateRowIdx(rowIdx)].top,
884
+ getRowHeight: (rowIdx) => rowPositions[validateRowIdx(rowIdx)].height,
885
+ findRowIdx(offset) {
886
+ let start = 0;
887
+ let end = rowPositions.length - 1;
888
+ while (start <= end) {
889
+ const middle = start + floor((end - start) / 2);
890
+ const currentOffset = rowPositions[middle].top;
891
+ if (currentOffset === offset)
892
+ return middle;
893
+ if (currentOffset < offset) {
894
+ start = middle + 1;
895
+ } else if (currentOffset > offset) {
896
+ end = middle - 1;
897
+ }
898
+ if (start > end)
899
+ return end;
653
900
  }
654
901
  return 0;
655
902
  }
656
903
  };
657
- }, [w, t, b]);
658
- let A = 0, _ = b.length - 1;
659
- if (C) {
660
- const M = E(i), T = E(i + n);
661
- A = Ge(0, M - 4), _ = Se(b.length - 1, T + 4);
904
+ }, [isGroupRow, rowHeight, rows]);
905
+ let rowOverscanStartIdx = 0;
906
+ let rowOverscanEndIdx = rows.length - 1;
907
+ if (enableVirtualization) {
908
+ const overscanThreshold = 4;
909
+ const rowVisibleStartIdx = findRowIdx(scrollTop);
910
+ const rowVisibleEndIdx = findRowIdx(scrollTop + clientHeight);
911
+ rowOverscanStartIdx = max(0, rowVisibleStartIdx - overscanThreshold);
912
+ rowOverscanEndIdx = min(rows.length - 1, rowVisibleEndIdx + overscanThreshold);
662
913
  }
663
914
  return {
664
- rowOverscanStartIdx: A,
665
- rowOverscanEndIdx: _,
666
- rows: b,
667
- rowsCount: k,
668
- totalRowHeight: g,
669
- gridTemplateRows: s,
670
- isGroupRow: w,
671
- getRowTop: v,
672
- getRowHeight: p,
673
- findRowIdx: E
915
+ rowOverscanStartIdx,
916
+ rowOverscanEndIdx,
917
+ rows,
918
+ rowsCount,
919
+ totalRowHeight,
920
+ gridTemplateRows,
921
+ isGroupRow,
922
+ getRowTop,
923
+ getRowHeight,
924
+ findRowIdx
674
925
  };
675
926
  }
676
- var _n = ".h1tr5c9i700-beta13{cursor:pointer;display:flex}.h1tr5c9i700-beta13:focus{outline:none}.h19r0msv700-beta13{flex-grow:1;overflow:hidden;overflow:clip;text-overflow:ellipsis}";
677
- G(_n, { insertAt: "top" });
678
- const jn = "h1tr5c9i700-beta13", Bn = `rdg-header-sort-cell ${jn}`, Gn = "h19r0msv700-beta13", Vn = `rdg-header-sort-name ${Gn}`;
679
- function qn({
680
- column: e,
681
- sortDirection: t,
682
- priority: n,
683
- onSort: i,
684
- isCellSelected: l
927
+ var css_248z$a = ".h1tr5c9i700-beta13{cursor:pointer;display:flex}.h1tr5c9i700-beta13:focus{outline:none}.h19r0msv700-beta13{flex-grow:1;overflow:hidden;overflow:clip;text-overflow:ellipsis}";
928
+ styleInject(css_248z$a, { "insertAt": "top" });
929
+ const headerSortCell = "h1tr5c9i700-beta13";
930
+ const headerSortCellClassname = `rdg-header-sort-cell ${headerSortCell}`;
931
+ const headerSortName = "h19r0msv700-beta13";
932
+ const headerSortNameClassname = `rdg-header-sort-name ${headerSortName}`;
933
+ function HeaderRenderer({
934
+ column,
935
+ sortDirection,
936
+ priority,
937
+ onSort,
938
+ isCellSelected
685
939
  }) {
686
- return e.sortable ? /* @__PURE__ */ I(Un, {
687
- onSort: i,
688
- sortDirection: t,
689
- priority: n,
690
- isCellSelected: l,
691
- children: e.name
692
- }) : /* @__PURE__ */ I(ze, {
693
- children: e.name
940
+ if (!column.sortable)
941
+ return /* @__PURE__ */ jsx(Fragment, {
942
+ children: column.name
943
+ });
944
+ return /* @__PURE__ */ jsx(SortableHeaderCell, {
945
+ onSort,
946
+ sortDirection,
947
+ priority,
948
+ isCellSelected,
949
+ children: column.name
694
950
  });
695
951
  }
696
- function Un({
697
- onSort: e,
698
- sortDirection: t,
699
- priority: n,
700
- children: i,
701
- isCellSelected: l
952
+ function SortableHeaderCell({
953
+ onSort,
954
+ sortDirection,
955
+ priority,
956
+ children,
957
+ isCellSelected
702
958
  }) {
703
- const c = kt().sortIcon, {
704
- ref: d,
705
- tabIndex: C
706
- } = Ct(l);
707
- function f(b) {
708
- (b.key === " " || b.key === "Enter") && (b.preventDefault(), e(b.ctrlKey || b.metaKey));
709
- }
710
- function k(b) {
711
- e(b.ctrlKey || b.metaKey);
712
- }
713
- return /* @__PURE__ */ ne("span", {
714
- ref: d,
715
- tabIndex: C,
716
- className: Bn,
717
- onClick: k,
718
- onKeyDown: f,
719
- children: [/* @__PURE__ */ I("span", {
720
- className: Vn,
721
- children: i
722
- }), /* @__PURE__ */ ne("span", {
723
- children: [/* @__PURE__ */ I(c, {
724
- sortDirection: t
725
- }), n]
959
+ const SortIcon2 = useDefaultComponents().sortIcon;
960
+ const {
961
+ ref,
962
+ tabIndex
963
+ } = useFocusRef(isCellSelected);
964
+ function handleKeyDown(event) {
965
+ if (event.key === " " || event.key === "Enter") {
966
+ event.preventDefault();
967
+ onSort(event.ctrlKey || event.metaKey);
968
+ }
969
+ }
970
+ function handleClick(event) {
971
+ onSort(event.ctrlKey || event.metaKey);
972
+ }
973
+ return /* @__PURE__ */ jsxs("span", {
974
+ ref,
975
+ tabIndex,
976
+ className: headerSortCellClassname,
977
+ onClick: handleClick,
978
+ onKeyDown: handleKeyDown,
979
+ children: [/* @__PURE__ */ jsx("span", {
980
+ className: headerSortNameClassname,
981
+ children
982
+ }), /* @__PURE__ */ jsxs("span", {
983
+ children: [/* @__PURE__ */ jsx(SortIcon2, {
984
+ sortDirection
985
+ }), priority]
726
986
  })]
727
987
  });
728
988
  }
729
- var Xn = '.celq7o9700-beta13{touch-action:none}.celq7o9700-beta13:after{content:"";cursor:col-resize;inline-size:10px;inset-block-end:0;inset-block-start:0;inset-inline-end:0;position:absolute}';
730
- G(Xn, { insertAt: "top" });
731
- const Yn = "celq7o9700-beta13", Jn = `rdg-cell-resizable ${Yn}`;
732
- function Qn({
733
- column: e,
734
- colSpan: t,
735
- isCellSelected: n,
736
- onColumnResize: i,
737
- allRowsSelected: l,
738
- onAllRowsSelectionChange: c,
739
- sortColumns: d,
740
- onSortColumnsChange: C,
741
- selectCell: f,
742
- shouldFocusGrid: k,
743
- direction: b
989
+ var css_248z$9 = '.celq7o9700-beta13{touch-action:none}.celq7o9700-beta13:after{content:"";cursor:col-resize;inline-size:10px;inset-block-end:0;inset-block-start:0;inset-inline-end:0;position:absolute}';
990
+ styleInject(css_248z$9, { "insertAt": "top" });
991
+ const cellResizable = "celq7o9700-beta13";
992
+ const cellResizableClassname = `rdg-cell-resizable ${cellResizable}`;
993
+ function HeaderCell({
994
+ column,
995
+ colSpan,
996
+ isCellSelected,
997
+ onColumnResize,
998
+ allRowsSelected,
999
+ onAllRowsSelectionChange,
1000
+ sortColumns,
1001
+ onSortColumnsChange,
1002
+ selectCell,
1003
+ shouldFocusGrid,
1004
+ direction
744
1005
  }) {
745
- const w = b === "rtl", {
746
- ref: g,
747
- tabIndex: s,
748
- onFocus: v
749
- } = Ue(n), p = d?.findIndex((x) => x.columnKey === e.key), E = p !== void 0 && p > -1 ? d[p] : void 0, A = E?.direction, _ = E !== void 0 && d.length > 1 ? p + 1 : void 0, H = A && !_ ? A === "ASC" ? "ascending" : "descending" : void 0, M = De(e, e.headerCellClass, e.resizable && Jn), T = e.headerRenderer ?? qn;
750
- function O(x) {
751
- if (x.pointerType === "mouse" && x.buttons !== 1)
1006
+ const isRtl = direction === "rtl";
1007
+ const {
1008
+ ref,
1009
+ tabIndex,
1010
+ onFocus
1011
+ } = useRovingCellRef(isCellSelected);
1012
+ const sortIndex = sortColumns?.findIndex((sort) => sort.columnKey === column.key);
1013
+ const sortColumn = sortIndex !== void 0 && sortIndex > -1 ? sortColumns[sortIndex] : void 0;
1014
+ const sortDirection = sortColumn?.direction;
1015
+ const priority = sortColumn !== void 0 && sortColumns.length > 1 ? sortIndex + 1 : void 0;
1016
+ const ariaSort = sortDirection && !priority ? sortDirection === "ASC" ? "ascending" : "descending" : void 0;
1017
+ const className = getCellClassname(column, column.headerCellClass, column.resizable && cellResizableClassname);
1018
+ const HeaderRenderer$1 = column.headerRenderer ?? HeaderRenderer;
1019
+ function onPointerDown(event) {
1020
+ if (event.pointerType === "mouse" && event.buttons !== 1) {
752
1021
  return;
1022
+ }
1023
+ const {
1024
+ currentTarget,
1025
+ pointerId
1026
+ } = event;
753
1027
  const {
754
- currentTarget: D,
755
- pointerId: m
756
- } = x, {
757
- right: F,
758
- left: V
759
- } = D.getBoundingClientRect(), ee = w ? x.clientX - V : F - x.clientX;
760
- if (ee > 11)
1028
+ right,
1029
+ left
1030
+ } = currentTarget.getBoundingClientRect();
1031
+ const offset = isRtl ? event.clientX - left : right - event.clientX;
1032
+ if (offset > 11) {
761
1033
  return;
762
- function ue(Fe) {
1034
+ }
1035
+ function onPointerMove(event2) {
763
1036
  const {
764
- right: fe,
765
- left: ge
766
- } = D.getBoundingClientRect(), te = w ? fe + ee - Fe.clientX : Fe.clientX + ee - ge;
767
- te > 0 && i(e, ht(te, e));
1037
+ right: right2,
1038
+ left: left2
1039
+ } = currentTarget.getBoundingClientRect();
1040
+ const width = isRtl ? right2 + offset - event2.clientX : event2.clientX + offset - left2;
1041
+ if (width > 0) {
1042
+ onColumnResize(column, clampColumnWidth(width, column));
1043
+ }
768
1044
  }
769
- function le() {
770
- D.removeEventListener("pointermove", ue), D.removeEventListener("lostpointercapture", le);
1045
+ function onLostPointerCapture() {
1046
+ currentTarget.removeEventListener("pointermove", onPointerMove);
1047
+ currentTarget.removeEventListener("lostpointercapture", onLostPointerCapture);
771
1048
  }
772
- D.setPointerCapture(m), D.addEventListener("pointermove", ue), D.addEventListener("lostpointercapture", le);
1049
+ currentTarget.setPointerCapture(pointerId);
1050
+ currentTarget.addEventListener("pointermove", onPointerMove);
1051
+ currentTarget.addEventListener("lostpointercapture", onLostPointerCapture);
773
1052
  }
774
- function y(x) {
775
- if (C == null)
1053
+ function onSort(ctrlClick) {
1054
+ if (onSortColumnsChange == null)
776
1055
  return;
777
1056
  const {
778
- sortDescendingFirst: D
779
- } = e;
780
- if (E === void 0) {
781
- const m = {
782
- columnKey: e.key,
783
- direction: D ? "DESC" : "ASC"
1057
+ sortDescendingFirst
1058
+ } = column;
1059
+ if (sortColumn === void 0) {
1060
+ const nextSort = {
1061
+ columnKey: column.key,
1062
+ direction: sortDescendingFirst ? "DESC" : "ASC"
784
1063
  };
785
- C(d && x ? [...d, m] : [m]);
1064
+ onSortColumnsChange(sortColumns && ctrlClick ? [...sortColumns, nextSort] : [nextSort]);
786
1065
  } else {
787
- let m;
788
- if ((D && A === "DESC" || !D && A === "ASC") && (m = {
789
- columnKey: e.key,
790
- direction: A === "ASC" ? "DESC" : "ASC"
791
- }), x) {
792
- const F = [...d];
793
- m ? F[p] = m : F.splice(p, 1), C(F);
794
- } else
795
- C(m ? [m] : []);
1066
+ let nextSortColumn;
1067
+ if (sortDescendingFirst && sortDirection === "DESC" || !sortDescendingFirst && sortDirection === "ASC") {
1068
+ nextSortColumn = {
1069
+ columnKey: column.key,
1070
+ direction: sortDirection === "ASC" ? "DESC" : "ASC"
1071
+ };
1072
+ }
1073
+ if (ctrlClick) {
1074
+ const nextSortColumns = [...sortColumns];
1075
+ if (nextSortColumn) {
1076
+ nextSortColumns[sortIndex] = nextSortColumn;
1077
+ } else {
1078
+ nextSortColumns.splice(sortIndex, 1);
1079
+ }
1080
+ onSortColumnsChange(nextSortColumns);
1081
+ } else {
1082
+ onSortColumnsChange(nextSortColumn ? [nextSortColumn] : []);
1083
+ }
796
1084
  }
797
1085
  }
798
- function z() {
799
- f(e.idx);
1086
+ function onClick() {
1087
+ selectCell(column.idx);
800
1088
  }
801
- function S(x) {
1089
+ function onDoubleClick(event) {
802
1090
  const {
803
- right: D,
804
- left: m
805
- } = x.currentTarget.getBoundingClientRect();
806
- (w ? x.clientX - m : D - x.clientX) > 11 || i(e, "auto");
1091
+ right,
1092
+ left
1093
+ } = event.currentTarget.getBoundingClientRect();
1094
+ const offset = isRtl ? event.clientX - left : right - event.clientX;
1095
+ if (offset > 11) {
1096
+ return;
1097
+ }
1098
+ onColumnResize(column, "auto");
807
1099
  }
808
- function h(x) {
809
- v?.(x), k && f(0);
1100
+ function handleFocus(event) {
1101
+ onFocus?.(event);
1102
+ if (shouldFocusGrid) {
1103
+ selectCell(0);
1104
+ }
810
1105
  }
811
- return /* @__PURE__ */ I("div", {
1106
+ return /* @__PURE__ */ jsx("div", {
812
1107
  role: "columnheader",
813
- "aria-colindex": e.idx + 1,
814
- "aria-selected": n,
815
- "aria-sort": H,
816
- "aria-colspan": t,
817
- ref: g,
818
- tabIndex: k ? 0 : s,
819
- className: M,
1108
+ "aria-colindex": column.idx + 1,
1109
+ "aria-selected": isCellSelected,
1110
+ "aria-sort": ariaSort,
1111
+ "aria-colspan": colSpan,
1112
+ ref,
1113
+ tabIndex: shouldFocusGrid ? 0 : tabIndex,
1114
+ className,
820
1115
  style: {
821
- ...Ee(e, t),
822
- minWidth: e.minWidth,
823
- maxWidth: e.maxWidth ?? void 0
1116
+ ...getCellStyle(column, colSpan),
1117
+ minWidth: column.minWidth,
1118
+ maxWidth: column.maxWidth ?? void 0
824
1119
  },
825
- onFocus: h,
826
- onClick: z,
827
- onDoubleClick: e.resizable ? S : void 0,
828
- onPointerDown: e.resizable ? O : void 0,
829
- children: /* @__PURE__ */ I(T, {
830
- column: e,
831
- sortDirection: A,
832
- priority: _,
833
- onSort: y,
834
- allRowsSelected: l,
835
- onAllRowsSelectionChange: c,
836
- isCellSelected: n
1120
+ onFocus: handleFocus,
1121
+ onClick,
1122
+ onDoubleClick: column.resizable ? onDoubleClick : void 0,
1123
+ onPointerDown: column.resizable ? onPointerDown : void 0,
1124
+ children: /* @__PURE__ */ jsx(HeaderRenderer$1, {
1125
+ column,
1126
+ sortDirection,
1127
+ priority,
1128
+ onSort,
1129
+ allRowsSelected,
1130
+ onAllRowsSelectionChange,
1131
+ isCellSelected
837
1132
  })
838
1133
  });
839
1134
  }
840
- var Zn = ".h197vzie700-beta13{background-color:var(--rdg-header-background-color);display:contents;font-weight:700;line-height:var(--rdg-header-row-height)}.h197vzie700-beta13>.c1wupbe700-beta13{inset-block-start:0;position:sticky;z-index:2}.h197vzie700-beta13>.c1730fa4700-beta13{z-index:3}";
841
- G(Zn, { insertAt: "top" });
842
- const er = "h197vzie700-beta13", tr = `rdg-header-row ${er}`;
843
- function or({
844
- columns: e,
845
- allRowsSelected: t,
846
- onAllRowsSelectionChange: n,
847
- onColumnResize: i,
848
- sortColumns: l,
849
- onSortColumnsChange: c,
850
- lastFrozenColumnIndex: d,
851
- selectedCellIdx: C,
852
- selectCell: f,
853
- shouldFocusGrid: k,
854
- direction: b
1135
+ var css_248z$8 = ".h197vzie700-beta13{background-color:var(--rdg-header-background-color);display:contents;font-weight:700;line-height:var(--rdg-header-row-height)}.h197vzie700-beta13>.c1wupbe700-beta13{inset-block-start:0;position:sticky;z-index:2}.h197vzie700-beta13>.c1730fa4700-beta13{z-index:3}";
1136
+ styleInject(css_248z$8, { "insertAt": "top" });
1137
+ const headerRow = "h197vzie700-beta13";
1138
+ const headerRowClassname = `rdg-header-row ${headerRow}`;
1139
+ function HeaderRow({
1140
+ columns,
1141
+ allRowsSelected,
1142
+ onAllRowsSelectionChange,
1143
+ onColumnResize,
1144
+ sortColumns,
1145
+ onSortColumnsChange,
1146
+ lastFrozenColumnIndex,
1147
+ selectedCellIdx,
1148
+ selectCell,
1149
+ shouldFocusGrid,
1150
+ direction
855
1151
  }) {
856
- const w = [];
857
- for (let g = 0; g < e.length; g++) {
858
- const s = e[g], v = Z(s, d, {
1152
+ const cells = [];
1153
+ for (let index = 0; index < columns.length; index++) {
1154
+ const column = columns[index];
1155
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
859
1156
  type: "HEADER"
860
1157
  });
861
- v !== void 0 && (g += v - 1), w.push(/* @__PURE__ */ I(Qn, {
862
- column: s,
863
- colSpan: v,
864
- isCellSelected: C === s.idx,
865
- onColumnResize: i,
866
- allRowsSelected: t,
867
- onAllRowsSelectionChange: n,
868
- onSortColumnsChange: c,
869
- sortColumns: l,
870
- selectCell: f,
871
- shouldFocusGrid: k && g === 0,
872
- direction: b
873
- }, s.key));
874
- }
875
- return /* @__PURE__ */ I("div", {
1158
+ if (colSpan !== void 0) {
1159
+ index += colSpan - 1;
1160
+ }
1161
+ cells.push(/* @__PURE__ */ jsx(HeaderCell, {
1162
+ column,
1163
+ colSpan,
1164
+ isCellSelected: selectedCellIdx === column.idx,
1165
+ onColumnResize,
1166
+ allRowsSelected,
1167
+ onAllRowsSelectionChange,
1168
+ onSortColumnsChange,
1169
+ sortColumns,
1170
+ selectCell,
1171
+ shouldFocusGrid: shouldFocusGrid && index === 0,
1172
+ direction
1173
+ }, column.key));
1174
+ }
1175
+ return /* @__PURE__ */ jsx("div", {
876
1176
  role: "row",
877
1177
  "aria-rowindex": 1,
878
- className: se(tr, C === -1 && Ve),
879
- style: qe(1),
880
- children: w
1178
+ className: clsx(headerRowClassname, selectedCellIdx === -1 && rowSelectedClassname),
1179
+ style: getRowStyle(1),
1180
+ children: cells
881
1181
  });
882
1182
  }
883
- const nr = /* @__PURE__ */ ae(or);
884
- var rr = ".c1bmg16t700-beta13,.ccpfvsn700-beta13{background-color:#ccf}.c1bmg16t700-beta13.ccpfvsn700-beta13{background-color:#99f}";
885
- G(rr, { insertAt: "top" });
886
- const ir = "ccpfvsn700-beta13", cr = `rdg-cell-copied ${ir}`, sr = "c1bmg16t700-beta13", lr = `rdg-cell-dragged-over ${sr}`;
887
- function dr({
888
- column: e,
889
- colSpan: t,
890
- isCellSelected: n,
891
- isCopied: i,
892
- isDraggedOver: l,
893
- row: c,
894
- dragHandle: d,
895
- onRowClick: C,
896
- onRowDoubleClick: f,
897
- onRowChange: k,
898
- selectCell: b,
899
- ...w
1183
+ const HeaderRow$1 = /* @__PURE__ */ memo(HeaderRow);
1184
+ var css_248z$7 = ".c1bmg16t700-beta13,.ccpfvsn700-beta13{background-color:#ccf}.c1bmg16t700-beta13.ccpfvsn700-beta13{background-color:#99f}";
1185
+ styleInject(css_248z$7, { "insertAt": "top" });
1186
+ const cellCopied = "ccpfvsn700-beta13";
1187
+ const cellCopiedClassname = `rdg-cell-copied ${cellCopied}`;
1188
+ const cellDraggedOver = "c1bmg16t700-beta13";
1189
+ const cellDraggedOverClassname = `rdg-cell-dragged-over ${cellDraggedOver}`;
1190
+ function Cell({
1191
+ column,
1192
+ colSpan,
1193
+ isCellSelected,
1194
+ isCopied,
1195
+ isDraggedOver,
1196
+ row: row2,
1197
+ dragHandle,
1198
+ onRowClick,
1199
+ onRowDoubleClick,
1200
+ onRowChange,
1201
+ selectCell,
1202
+ ...props
900
1203
  }) {
901
1204
  const {
902
- ref: g,
903
- tabIndex: s,
904
- onFocus: v
905
- } = Ue(n), {
906
- cellClass: p
907
- } = e, E = De(e, typeof p == "function" ? p(c) : p, i && cr, l && lr);
908
- function A(T) {
909
- b(c, e, T);
1205
+ ref,
1206
+ tabIndex,
1207
+ onFocus
1208
+ } = useRovingCellRef(isCellSelected);
1209
+ const {
1210
+ cellClass
1211
+ } = column;
1212
+ const className = getCellClassname(column, typeof cellClass === "function" ? cellClass(row2) : cellClass, isCopied && cellCopiedClassname, isDraggedOver && cellDraggedOverClassname);
1213
+ function selectCellWrapper(openEditor) {
1214
+ selectCell(row2, column, openEditor);
910
1215
  }
911
- function _() {
912
- A(e.editorOptions?.editOnClick), C?.(c, e);
1216
+ function handleClick() {
1217
+ selectCellWrapper(column.editorOptions?.editOnClick);
1218
+ onRowClick?.(row2, column);
913
1219
  }
914
- function H() {
915
- A();
1220
+ function handleContextMenu() {
1221
+ selectCellWrapper();
916
1222
  }
917
- function M() {
918
- A(!0), f?.(c, e);
1223
+ function handleDoubleClick() {
1224
+ selectCellWrapper(true);
1225
+ onRowDoubleClick?.(row2, column);
919
1226
  }
920
- return /* @__PURE__ */ I("div", {
1227
+ return /* @__PURE__ */ jsx("div", {
921
1228
  role: "gridcell",
922
- "aria-colindex": e.idx + 1,
923
- "aria-selected": n,
924
- "aria-colspan": t,
925
- "aria-readonly": !eo(e, c) || void 0,
926
- ref: g,
927
- tabIndex: s,
928
- className: E,
929
- style: Ee(e, t),
930
- onClick: _,
931
- onDoubleClick: M,
932
- onContextMenu: H,
933
- onFocus: v,
934
- ...w,
935
- children: !e.rowGroup && /* @__PURE__ */ ne(ze, {
936
- children: [/* @__PURE__ */ I(e.formatter, {
937
- column: e,
938
- row: c,
939
- isCellSelected: n,
940
- onRowChange: k
941
- }), d]
1229
+ "aria-colindex": column.idx + 1,
1230
+ "aria-selected": isCellSelected,
1231
+ "aria-colspan": colSpan,
1232
+ "aria-readonly": !isCellEditable(column, row2) || void 0,
1233
+ ref,
1234
+ tabIndex,
1235
+ className,
1236
+ style: getCellStyle(column, colSpan),
1237
+ onClick: handleClick,
1238
+ onDoubleClick: handleDoubleClick,
1239
+ onContextMenu: handleContextMenu,
1240
+ onFocus,
1241
+ ...props,
1242
+ children: !column.rowGroup && /* @__PURE__ */ jsxs(Fragment, {
1243
+ children: [/* @__PURE__ */ jsx(column.formatter, {
1244
+ column,
1245
+ row: row2,
1246
+ isCellSelected,
1247
+ onRowChange
1248
+ }), dragHandle]
942
1249
  })
943
1250
  });
944
1251
  }
945
- const ar = /* @__PURE__ */ ae(dr);
946
- function ur({
947
- className: e,
948
- rowIdx: t,
949
- gridRowStart: n,
950
- height: i,
951
- selectedCellIdx: l,
952
- isRowSelected: c,
953
- copiedCellIdx: d,
954
- draggedOverCellIdx: C,
955
- lastFrozenColumnIndex: f,
956
- row: k,
957
- viewportColumns: b,
958
- selectedCellEditor: w,
959
- selectedCellDragHandle: g,
960
- onRowClick: s,
961
- onRowDoubleClick: v,
962
- rowClass: p,
963
- setDraggedOverRowIdx: E,
964
- onMouseEnter: A,
965
- onRowChange: _,
966
- selectCell: H,
967
- ...M
968
- }, T) {
969
- const O = J((S) => {
970
- _(t, S);
1252
+ const Cell$1 = /* @__PURE__ */ memo(Cell);
1253
+ function Row({
1254
+ className,
1255
+ rowIdx,
1256
+ gridRowStart,
1257
+ height,
1258
+ selectedCellIdx,
1259
+ isRowSelected,
1260
+ copiedCellIdx,
1261
+ draggedOverCellIdx,
1262
+ lastFrozenColumnIndex,
1263
+ row: row2,
1264
+ viewportColumns,
1265
+ selectedCellEditor,
1266
+ selectedCellDragHandle,
1267
+ onRowClick,
1268
+ onRowDoubleClick,
1269
+ rowClass,
1270
+ setDraggedOverRowIdx,
1271
+ onMouseEnter,
1272
+ onRowChange,
1273
+ selectCell,
1274
+ ...props
1275
+ }, ref) {
1276
+ const handleRowChange = useLatestFunc((newRow) => {
1277
+ onRowChange(rowIdx, newRow);
971
1278
  });
972
- function y(S) {
973
- E?.(t), A?.(S);
974
- }
975
- e = se(mt, `rdg-row-${t % 2 === 0 ? "even" : "odd"}`, p?.(k), e, l === -1 && Ve);
976
- const z = [];
977
- for (let S = 0; S < b.length; S++) {
978
- const h = b[S], {
979
- idx: x
980
- } = h, D = Z(h, f, {
1279
+ function handleDragEnter(event) {
1280
+ setDraggedOverRowIdx?.(rowIdx);
1281
+ onMouseEnter?.(event);
1282
+ }
1283
+ className = clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, rowClass?.(row2), className, selectedCellIdx === -1 && rowSelectedClassname);
1284
+ const cells = [];
1285
+ for (let index = 0; index < viewportColumns.length; index++) {
1286
+ const column = viewportColumns[index];
1287
+ const {
1288
+ idx
1289
+ } = column;
1290
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
981
1291
  type: "ROW",
982
- row: k
1292
+ row: row2
983
1293
  });
984
- D !== void 0 && (S += D - 1);
985
- const m = l === x;
986
- m && w ? z.push(w) : z.push(/* @__PURE__ */ I(ar, {
987
- column: h,
988
- colSpan: D,
989
- row: k,
990
- isCopied: d === x,
991
- isDraggedOver: C === x,
992
- isCellSelected: m,
993
- dragHandle: m ? g : void 0,
994
- onRowClick: s,
995
- onRowDoubleClick: v,
996
- onRowChange: O,
997
- selectCell: H
998
- }, h.key));
999
- }
1000
- return /* @__PURE__ */ I(Qt, {
1001
- value: c,
1002
- children: /* @__PURE__ */ I("div", {
1294
+ if (colSpan !== void 0) {
1295
+ index += colSpan - 1;
1296
+ }
1297
+ const isCellSelected = selectedCellIdx === idx;
1298
+ if (isCellSelected && selectedCellEditor) {
1299
+ cells.push(selectedCellEditor);
1300
+ } else {
1301
+ cells.push(/* @__PURE__ */ jsx(Cell$1, {
1302
+ column,
1303
+ colSpan,
1304
+ row: row2,
1305
+ isCopied: copiedCellIdx === idx,
1306
+ isDraggedOver: draggedOverCellIdx === idx,
1307
+ isCellSelected,
1308
+ dragHandle: isCellSelected ? selectedCellDragHandle : void 0,
1309
+ onRowClick,
1310
+ onRowDoubleClick,
1311
+ onRowChange: handleRowChange,
1312
+ selectCell
1313
+ }, column.key));
1314
+ }
1315
+ }
1316
+ return /* @__PURE__ */ jsx(RowSelectionProvider, {
1317
+ value: isRowSelected,
1318
+ children: /* @__PURE__ */ jsx("div", {
1003
1319
  role: "row",
1004
- ref: T,
1005
- className: e,
1006
- onMouseEnter: y,
1007
- style: qe(n, i),
1008
- ...M,
1009
- children: z
1320
+ ref,
1321
+ className,
1322
+ onMouseEnter: handleDragEnter,
1323
+ style: getRowStyle(gridRowStart, height),
1324
+ ...props,
1325
+ children: cells
1010
1326
  })
1011
1327
  });
1012
1328
  }
1013
- const fr = /* @__PURE__ */ ae(/* @__PURE__ */ pt(ur));
1014
- function gr({
1015
- id: e,
1016
- groupKey: t,
1017
- childRows: n,
1018
- isExpanded: i,
1019
- isCellSelected: l,
1020
- column: c,
1021
- row: d,
1022
- groupColumnIndex: C,
1023
- toggleGroup: f
1329
+ const Row$1 = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(Row));
1330
+ function GroupCell({
1331
+ id,
1332
+ groupKey,
1333
+ childRows,
1334
+ isExpanded,
1335
+ isCellSelected,
1336
+ column,
1337
+ row: row2,
1338
+ groupColumnIndex,
1339
+ toggleGroup: toggleGroupWrapper
1024
1340
  }) {
1025
1341
  const {
1026
- ref: k,
1027
- tabIndex: b,
1028
- onFocus: w
1029
- } = Ue(l);
1030
- function g() {
1031
- f(e);
1032
- }
1033
- const s = c.rowGroup && C === c.idx;
1034
- return /* @__PURE__ */ I("div", {
1342
+ ref,
1343
+ tabIndex,
1344
+ onFocus
1345
+ } = useRovingCellRef(isCellSelected);
1346
+ function toggleGroup() {
1347
+ toggleGroupWrapper(id);
1348
+ }
1349
+ const isLevelMatching = column.rowGroup && groupColumnIndex === column.idx;
1350
+ return /* @__PURE__ */ jsx("div", {
1035
1351
  role: "gridcell",
1036
- "aria-colindex": c.idx + 1,
1037
- "aria-selected": l,
1038
- ref: k,
1039
- tabIndex: b,
1040
- className: De(c),
1352
+ "aria-colindex": column.idx + 1,
1353
+ "aria-selected": isCellSelected,
1354
+ ref,
1355
+ tabIndex,
1356
+ className: getCellClassname(column),
1041
1357
  style: {
1042
- ...Ee(c),
1043
- cursor: s ? "pointer" : "default"
1358
+ ...getCellStyle(column),
1359
+ cursor: isLevelMatching ? "pointer" : "default"
1044
1360
  },
1045
- onClick: s ? g : void 0,
1046
- onFocus: w,
1047
- children: (!c.rowGroup || C === c.idx) && c.groupFormatter && /* @__PURE__ */ I(c.groupFormatter, {
1048
- groupKey: t,
1049
- childRows: n,
1050
- column: c,
1051
- row: d,
1052
- isExpanded: i,
1053
- isCellSelected: l,
1054
- toggleGroup: g
1361
+ onClick: isLevelMatching ? toggleGroup : void 0,
1362
+ onFocus,
1363
+ children: (!column.rowGroup || groupColumnIndex === column.idx) && column.groupFormatter && /* @__PURE__ */ jsx(column.groupFormatter, {
1364
+ groupKey,
1365
+ childRows,
1366
+ column,
1367
+ row: row2,
1368
+ isExpanded,
1369
+ isCellSelected,
1370
+ toggleGroup
1055
1371
  })
1056
- }, c.key);
1372
+ }, column.key);
1057
1373
  }
1058
- const br = /* @__PURE__ */ ae(gr);
1059
- var hr = ".gyxx7e9700-beta13:not([aria-selected=true]){background-color:var(--rdg-header-background-color)}.gyxx7e9700-beta13>.c1wupbe700-beta13:not(:last-child):not(.c9dpaye700-beta13){border-inline-end:none}";
1060
- G(hr, { insertAt: "top" });
1061
- const pr = "gyxx7e9700-beta13", xr = `rdg-group-row ${pr}`;
1062
- function wr({
1063
- id: e,
1064
- groupKey: t,
1065
- viewportColumns: n,
1066
- childRows: i,
1067
- rowIdx: l,
1068
- row: c,
1069
- gridRowStart: d,
1070
- height: C,
1071
- level: f,
1072
- isExpanded: k,
1073
- selectedCellIdx: b,
1074
- isRowSelected: w,
1075
- selectGroup: g,
1076
- toggleGroup: s,
1077
- ...v
1374
+ const GroupCell$1 = /* @__PURE__ */ memo(GroupCell);
1375
+ var css_248z$6 = ".gyxx7e9700-beta13:not([aria-selected=true]){background-color:var(--rdg-header-background-color)}.gyxx7e9700-beta13>.c1wupbe700-beta13:not(:last-child):not(.c9dpaye700-beta13){border-inline-end:none}";
1376
+ styleInject(css_248z$6, { "insertAt": "top" });
1377
+ const groupRow = "gyxx7e9700-beta13";
1378
+ const groupRowClassname = `rdg-group-row ${groupRow}`;
1379
+ function GroupedRow({
1380
+ id,
1381
+ groupKey,
1382
+ viewportColumns,
1383
+ childRows,
1384
+ rowIdx,
1385
+ row: row2,
1386
+ gridRowStart,
1387
+ height,
1388
+ level,
1389
+ isExpanded,
1390
+ selectedCellIdx,
1391
+ isRowSelected,
1392
+ selectGroup,
1393
+ toggleGroup,
1394
+ ...props
1078
1395
  }) {
1079
- const p = n[0].key === ft ? f + 1 : f;
1080
- function E() {
1081
- g(l);
1396
+ const idx = viewportColumns[0].key === SELECT_COLUMN_KEY ? level + 1 : level;
1397
+ function handleSelectGroup() {
1398
+ selectGroup(rowIdx);
1082
1399
  }
1083
- return /* @__PURE__ */ I(Qt, {
1084
- value: w,
1085
- children: /* @__PURE__ */ I("div", {
1400
+ return /* @__PURE__ */ jsx(RowSelectionProvider, {
1401
+ value: isRowSelected,
1402
+ children: /* @__PURE__ */ jsx("div", {
1086
1403
  role: "row",
1087
- "aria-level": f,
1088
- "aria-expanded": k,
1089
- className: se(mt, xr, `rdg-row-${l % 2 === 0 ? "even" : "odd"}`, b === -1 && Ve),
1090
- onClick: E,
1091
- style: qe(d, C),
1092
- ...v,
1093
- children: n.map((A) => /* @__PURE__ */ I(br, {
1094
- id: e,
1095
- groupKey: t,
1096
- childRows: i,
1097
- isExpanded: k,
1098
- isCellSelected: b === A.idx,
1099
- column: A,
1100
- row: c,
1101
- groupColumnIndex: p,
1102
- toggleGroup: s
1103
- }, A.key))
1404
+ "aria-level": level,
1405
+ "aria-expanded": isExpanded,
1406
+ className: clsx(rowClassname, groupRowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, selectedCellIdx === -1 && rowSelectedClassname),
1407
+ onClick: handleSelectGroup,
1408
+ style: getRowStyle(gridRowStart, height),
1409
+ ...props,
1410
+ children: viewportColumns.map((column) => /* @__PURE__ */ jsx(GroupCell$1, {
1411
+ id,
1412
+ groupKey,
1413
+ childRows,
1414
+ isExpanded,
1415
+ isCellSelected: selectedCellIdx === column.idx,
1416
+ column,
1417
+ row: row2,
1418
+ groupColumnIndex: idx,
1419
+ toggleGroup
1420
+ }, column.key))
1104
1421
  })
1105
1422
  });
1106
1423
  }
1107
- const mr = /* @__PURE__ */ ae(wr);
1108
- var Cr = ".s1n3hxke700-beta13{inset-block-end:var(--rdg-summary-row-bottom);inset-block-start:var(--rdg-summary-row-top)}";
1109
- G(Cr, { insertAt: "top" });
1110
- const kr = "s1n3hxke700-beta13";
1111
- function yr({
1112
- column: e,
1113
- colSpan: t,
1114
- row: n,
1115
- isCellSelected: i,
1116
- selectCell: l
1424
+ const GroupRowRenderer = /* @__PURE__ */ memo(GroupedRow);
1425
+ var css_248z$5 = ".s1n3hxke700-beta13{inset-block-end:var(--rdg-summary-row-bottom);inset-block-start:var(--rdg-summary-row-top)}";
1426
+ styleInject(css_248z$5, { "insertAt": "top" });
1427
+ const summaryCellClassname = "s1n3hxke700-beta13";
1428
+ function SummaryCell({
1429
+ column,
1430
+ colSpan,
1431
+ row: row2,
1432
+ isCellSelected,
1433
+ selectCell
1117
1434
  }) {
1118
1435
  const {
1119
- ref: c,
1120
- tabIndex: d,
1121
- onFocus: C
1122
- } = Ue(i), {
1123
- summaryFormatter: f,
1124
- summaryCellClass: k
1125
- } = e, b = De(e, kr, typeof k == "function" ? k(n) : k);
1126
- function w() {
1127
- l(n, e);
1128
- }
1129
- return /* @__PURE__ */ I("div", {
1436
+ ref,
1437
+ tabIndex,
1438
+ onFocus
1439
+ } = useRovingCellRef(isCellSelected);
1440
+ const {
1441
+ summaryFormatter: SummaryFormatter,
1442
+ summaryCellClass
1443
+ } = column;
1444
+ const className = getCellClassname(column, summaryCellClassname, typeof summaryCellClass === "function" ? summaryCellClass(row2) : summaryCellClass);
1445
+ function onClick() {
1446
+ selectCell(row2, column);
1447
+ }
1448
+ return /* @__PURE__ */ jsx("div", {
1130
1449
  role: "gridcell",
1131
- "aria-colindex": e.idx + 1,
1132
- "aria-colspan": t,
1133
- "aria-selected": i,
1134
- ref: c,
1135
- tabIndex: d,
1136
- className: b,
1137
- style: Ee(e, t),
1138
- onClick: w,
1139
- onFocus: C,
1140
- children: f && /* @__PURE__ */ I(f, {
1141
- column: e,
1142
- row: n,
1143
- isCellSelected: i
1450
+ "aria-colindex": column.idx + 1,
1451
+ "aria-colspan": colSpan,
1452
+ "aria-selected": isCellSelected,
1453
+ ref,
1454
+ tabIndex,
1455
+ className,
1456
+ style: getCellStyle(column, colSpan),
1457
+ onClick,
1458
+ onFocus,
1459
+ children: SummaryFormatter && /* @__PURE__ */ jsx(SummaryFormatter, {
1460
+ column,
1461
+ row: row2,
1462
+ isCellSelected
1144
1463
  })
1145
1464
  });
1146
1465
  }
1147
- const Rr = /* @__PURE__ */ ae(yr);
1148
- var vr = ".snfqesz700-beta13.r1otpg64700-beta13{line-height:var(--rdg-summary-row-height)}.snfqesz700-beta13.r1otpg64700-beta13>.c1wupbe700-beta13{position:sticky}.s1jijrjz700-beta13>.c1wupbe700-beta13{border-block-start:2px solid var(--rdg-summary-border-color)}";
1149
- G(vr, { insertAt: "top" });
1150
- const Ir = "snfqesz700-beta13", Sr = "s1jijrjz700-beta13", zr = `rdg-summary-row ${Ir}`;
1151
- function Er({
1152
- rowIdx: e,
1153
- gridRowStart: t,
1154
- row: n,
1155
- viewportColumns: i,
1156
- top: l,
1157
- bottom: c,
1158
- lastFrozenColumnIndex: d,
1159
- selectedCellIdx: C,
1160
- selectCell: f,
1161
- "aria-rowindex": k
1466
+ const SummaryCell$1 = /* @__PURE__ */ memo(SummaryCell);
1467
+ var css_248z$4 = ".snfqesz700-beta13.r1otpg64700-beta13{line-height:var(--rdg-summary-row-height)}.snfqesz700-beta13.r1otpg64700-beta13>.c1wupbe700-beta13{position:sticky}.s1jijrjz700-beta13>.c1wupbe700-beta13{border-block-start:2px solid var(--rdg-summary-border-color)}";
1468
+ styleInject(css_248z$4, { "insertAt": "top" });
1469
+ const summaryRow = "snfqesz700-beta13";
1470
+ const summaryRowBorderClassname = "s1jijrjz700-beta13";
1471
+ const summaryRowClassname = `rdg-summary-row ${summaryRow}`;
1472
+ function SummaryRow({
1473
+ rowIdx,
1474
+ gridRowStart,
1475
+ row: row2,
1476
+ viewportColumns,
1477
+ top,
1478
+ bottom,
1479
+ lastFrozenColumnIndex,
1480
+ selectedCellIdx,
1481
+ selectCell,
1482
+ "aria-rowindex": ariaRowIndex
1162
1483
  }) {
1163
- const b = [];
1164
- for (let w = 0; w < i.length; w++) {
1165
- const g = i[w], s = Z(g, d, {
1484
+ const cells = [];
1485
+ for (let index = 0; index < viewportColumns.length; index++) {
1486
+ const column = viewportColumns[index];
1487
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
1166
1488
  type: "SUMMARY",
1167
- row: n
1489
+ row: row2
1168
1490
  });
1169
- s !== void 0 && (w += s - 1);
1170
- const v = C === g.idx;
1171
- b.push(/* @__PURE__ */ I(Rr, {
1172
- column: g,
1173
- colSpan: s,
1174
- row: n,
1175
- isCellSelected: v,
1176
- selectCell: f
1177
- }, g.key));
1178
- }
1179
- return /* @__PURE__ */ I("div", {
1491
+ if (colSpan !== void 0) {
1492
+ index += colSpan - 1;
1493
+ }
1494
+ const isCellSelected = selectedCellIdx === column.idx;
1495
+ cells.push(/* @__PURE__ */ jsx(SummaryCell$1, {
1496
+ column,
1497
+ colSpan,
1498
+ row: row2,
1499
+ isCellSelected,
1500
+ selectCell
1501
+ }, column.key));
1502
+ }
1503
+ return /* @__PURE__ */ jsx("div", {
1180
1504
  role: "row",
1181
- "aria-rowindex": k,
1182
- className: se(mt, `rdg-row-${e % 2 === 0 ? "even" : "odd"}`, zr, e === 0 && Sr, C === -1 && Ve),
1505
+ "aria-rowindex": ariaRowIndex,
1506
+ className: clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? "even" : "odd"}`, summaryRowClassname, rowIdx === 0 && summaryRowBorderClassname, selectedCellIdx === -1 && rowSelectedClassname),
1183
1507
  style: {
1184
- ...qe(t),
1185
- "--rdg-summary-row-top": l !== void 0 ? `${l}px` : void 0,
1186
- "--rdg-summary-row-bottom": c !== void 0 ? `${c}px` : void 0
1508
+ ...getRowStyle(gridRowStart),
1509
+ "--rdg-summary-row-top": top !== void 0 ? `${top}px` : void 0,
1510
+ "--rdg-summary-row-bottom": bottom !== void 0 ? `${bottom}px` : void 0
1187
1511
  },
1188
- children: b
1512
+ children: cells
1189
1513
  });
1190
1514
  }
1191
- const Dr = /* @__PURE__ */ ae(Er);
1192
- var Fr = ".c1tngyp1700-beta13.rdg-cell{padding:0}";
1193
- G(Fr, { insertAt: "top" });
1194
- const $r = "c1tngyp1700-beta13";
1195
- function Lr({
1196
- column: e,
1197
- colSpan: t,
1198
- row: n,
1199
- onRowChange: i,
1200
- closeEditor: l
1515
+ const SummaryRow$1 = /* @__PURE__ */ memo(SummaryRow);
1516
+ var css_248z$3 = ".c1tngyp1700-beta13.rdg-cell{padding:0}";
1517
+ styleInject(css_248z$3, { "insertAt": "top" });
1518
+ const cellEditing = "c1tngyp1700-beta13";
1519
+ function EditCell({
1520
+ column,
1521
+ colSpan,
1522
+ row: row2,
1523
+ onRowChange,
1524
+ closeEditor
1201
1525
  }) {
1202
- const c = ce(), d = e.editorOptions?.commitOnOutsideClick !== !1, C = J(() => {
1203
- b(!0);
1526
+ const frameRequestRef = useRef();
1527
+ const commitOnOutsideClick = column.editorOptions?.commitOnOutsideClick !== false;
1528
+ const commitOnOutsideMouseDown = useLatestFunc(() => {
1529
+ onClose(true);
1204
1530
  });
1205
- wt(() => {
1206
- if (!d)
1531
+ useEffect(() => {
1532
+ if (!commitOnOutsideClick)
1207
1533
  return;
1208
- function s() {
1209
- c.current = requestAnimationFrame(C);
1534
+ function onWindowCaptureMouseDown() {
1535
+ frameRequestRef.current = requestAnimationFrame(commitOnOutsideMouseDown);
1210
1536
  }
1211
- return addEventListener("mousedown", s, {
1212
- capture: !0
1213
- }), () => {
1214
- removeEventListener("mousedown", s, {
1215
- capture: !0
1216
- }), f();
1537
+ addEventListener("mousedown", onWindowCaptureMouseDown, {
1538
+ capture: true
1539
+ });
1540
+ return () => {
1541
+ removeEventListener("mousedown", onWindowCaptureMouseDown, {
1542
+ capture: true
1543
+ });
1544
+ cancelFrameRequest();
1217
1545
  };
1218
- }, [d, C]);
1219
- function f() {
1220
- cancelAnimationFrame(c.current);
1546
+ }, [commitOnOutsideClick, commitOnOutsideMouseDown]);
1547
+ function cancelFrameRequest() {
1548
+ cancelAnimationFrame(frameRequestRef.current);
1221
1549
  }
1222
- function k(s) {
1223
- s.key === "Escape" ? (s.stopPropagation(), b()) : s.key === "Enter" ? (s.stopPropagation(), b(!0)) : (e.editorOptions?.onNavigation ?? En)(s) || s.stopPropagation();
1550
+ function onKeyDown(event) {
1551
+ if (event.key === "Escape") {
1552
+ event.stopPropagation();
1553
+ onClose();
1554
+ } else if (event.key === "Enter") {
1555
+ event.stopPropagation();
1556
+ onClose(true);
1557
+ } else {
1558
+ const onNavigation = column.editorOptions?.onNavigation ?? onEditorNavigation;
1559
+ if (!onNavigation(event)) {
1560
+ event.stopPropagation();
1561
+ }
1562
+ }
1224
1563
  }
1225
- function b(s) {
1226
- s ? i(n, !0) : l();
1564
+ function onClose(commitChanges) {
1565
+ if (commitChanges) {
1566
+ onRowChange(row2, true);
1567
+ } else {
1568
+ closeEditor();
1569
+ }
1227
1570
  }
1228
1571
  const {
1229
- cellClass: w
1230
- } = e, g = De(e, "rdg-editor-container", typeof w == "function" ? w(n) : w, !e.editorOptions?.renderFormatter && $r);
1231
- return /* @__PURE__ */ I("div", {
1572
+ cellClass
1573
+ } = column;
1574
+ const className = getCellClassname(column, "rdg-editor-container", typeof cellClass === "function" ? cellClass(row2) : cellClass, !column.editorOptions?.renderFormatter && cellEditing);
1575
+ return /* @__PURE__ */ jsx("div", {
1232
1576
  role: "gridcell",
1233
- "aria-colindex": e.idx + 1,
1234
- "aria-colspan": t,
1235
- "aria-selected": !0,
1236
- className: g,
1237
- style: Ee(e, t),
1238
- onKeyDown: k,
1239
- onMouseDownCapture: d ? f : void 0,
1240
- children: e.editor != null && /* @__PURE__ */ ne(ze, {
1241
- children: [/* @__PURE__ */ I(e.editor, {
1242
- column: e,
1243
- row: n,
1244
- onRowChange: i,
1245
- onClose: b
1246
- }), e.editorOptions?.renderFormatter && /* @__PURE__ */ I(e.formatter, {
1247
- column: e,
1248
- row: n,
1249
- isCellSelected: !0,
1250
- onRowChange: i
1577
+ "aria-colindex": column.idx + 1,
1578
+ "aria-colspan": colSpan,
1579
+ "aria-selected": true,
1580
+ className,
1581
+ style: getCellStyle(column, colSpan),
1582
+ onKeyDown,
1583
+ onMouseDownCapture: commitOnOutsideClick ? cancelFrameRequest : void 0,
1584
+ children: column.editor != null && /* @__PURE__ */ jsxs(Fragment, {
1585
+ children: [/* @__PURE__ */ jsx(column.editor, {
1586
+ column,
1587
+ row: row2,
1588
+ onRowChange,
1589
+ onClose
1590
+ }), column.editorOptions?.renderFormatter && /* @__PURE__ */ jsx(column.formatter, {
1591
+ column,
1592
+ row: row2,
1593
+ isCellSelected: true,
1594
+ onRowChange
1251
1595
  })]
1252
1596
  })
1253
1597
  });
1254
1598
  }
1255
- var Ar = ".cadd3bp700-beta13{background-color:var(--rdg-selection-color);block-size:8px;cursor:move;inline-size:8px;inset-block-end:0;inset-inline-end:0;position:absolute}.cadd3bp700-beta13:hover{background-color:var(--rdg-background-color);block-size:16px;border:2px solid var(--rdg-selection-color);inline-size:16px}";
1256
- G(Ar, { insertAt: "top" });
1257
- const Or = "cadd3bp700-beta13", Tr = `rdg-cell-drag-handle ${Or}`;
1258
- function Nr({
1259
- rows: e,
1260
- columns: t,
1261
- selectedPosition: n,
1262
- latestDraggedOverRowIdx: i,
1263
- isCellEditable: l,
1264
- onRowsChange: c,
1265
- onFill: d,
1266
- setDragging: C,
1267
- setDraggedOverRowIdx: f
1599
+ var css_248z$2 = ".cadd3bp700-beta13{background-color:var(--rdg-selection-color);block-size:8px;cursor:move;inline-size:8px;inset-block-end:0;inset-inline-end:0;position:absolute}.cadd3bp700-beta13:hover{background-color:var(--rdg-background-color);block-size:16px;border:2px solid var(--rdg-selection-color);inline-size:16px}";
1600
+ styleInject(css_248z$2, { "insertAt": "top" });
1601
+ const cellDragHandle = "cadd3bp700-beta13";
1602
+ const cellDragHandleClassname = `rdg-cell-drag-handle ${cellDragHandle}`;
1603
+ function DragHandle({
1604
+ rows,
1605
+ columns,
1606
+ selectedPosition,
1607
+ latestDraggedOverRowIdx,
1608
+ isCellEditable: isCellEditable2,
1609
+ onRowsChange,
1610
+ onFill,
1611
+ setDragging,
1612
+ setDraggedOverRowIdx
1268
1613
  }) {
1269
- function k(s) {
1270
- if (s.buttons !== 1)
1614
+ function handleMouseDown(event) {
1615
+ if (event.buttons !== 1)
1271
1616
  return;
1272
- C(!0), window.addEventListener("mouseover", v), window.addEventListener("mouseup", p);
1273
- function v(E) {
1274
- E.buttons !== 1 && p();
1617
+ setDragging(true);
1618
+ window.addEventListener("mouseover", onMouseOver);
1619
+ window.addEventListener("mouseup", onMouseUp);
1620
+ function onMouseOver(event2) {
1621
+ if (event2.buttons !== 1)
1622
+ onMouseUp();
1275
1623
  }
1276
- function p() {
1277
- window.removeEventListener("mouseover", v), window.removeEventListener("mouseup", p), C(!1), b();
1624
+ function onMouseUp() {
1625
+ window.removeEventListener("mouseover", onMouseOver);
1626
+ window.removeEventListener("mouseup", onMouseUp);
1627
+ setDragging(false);
1628
+ handleDragEnd();
1278
1629
  }
1279
1630
  }
1280
- function b() {
1281
- const s = i.current;
1282
- if (s === void 0)
1631
+ function handleDragEnd() {
1632
+ const overRowIdx = latestDraggedOverRowIdx.current;
1633
+ if (overRowIdx === void 0)
1283
1634
  return;
1284
1635
  const {
1285
- rowIdx: v
1286
- } = n, p = v < s ? v + 1 : s, E = v < s ? s + 1 : v;
1287
- g(p, E), f(void 0);
1636
+ rowIdx
1637
+ } = selectedPosition;
1638
+ const startRowIndex = rowIdx < overRowIdx ? rowIdx + 1 : overRowIdx;
1639
+ const endRowIndex = rowIdx < overRowIdx ? overRowIdx + 1 : rowIdx;
1640
+ updateRows(startRowIndex, endRowIndex);
1641
+ setDraggedOverRowIdx(void 0);
1288
1642
  }
1289
- function w(s) {
1290
- s.stopPropagation(), g(n.rowIdx + 1, e.length);
1643
+ function handleDoubleClick(event) {
1644
+ event.stopPropagation();
1645
+ updateRows(selectedPosition.rowIdx + 1, rows.length);
1291
1646
  }
1292
- function g(s, v) {
1647
+ function updateRows(startRowIdx, endRowIdx) {
1293
1648
  const {
1294
- idx: p,
1295
- rowIdx: E
1296
- } = n, A = t[p], _ = e[E], H = [...e], M = [];
1297
- for (let T = s; T < v; T++)
1298
- if (l({
1299
- rowIdx: T,
1300
- idx: p
1649
+ idx,
1650
+ rowIdx
1651
+ } = selectedPosition;
1652
+ const column = columns[idx];
1653
+ const sourceRow = rows[rowIdx];
1654
+ const updatedRows = [...rows];
1655
+ const indexes = [];
1656
+ for (let i = startRowIdx; i < endRowIdx; i++) {
1657
+ if (isCellEditable2({
1658
+ rowIdx: i,
1659
+ idx
1301
1660
  })) {
1302
- const O = d({
1303
- columnKey: A.key,
1304
- sourceRow: _,
1305
- targetRow: e[T]
1661
+ const updatedRow = onFill({
1662
+ columnKey: column.key,
1663
+ sourceRow,
1664
+ targetRow: rows[i]
1306
1665
  });
1307
- O !== e[T] && (H[T] = O, M.push(T));
1666
+ if (updatedRow !== rows[i]) {
1667
+ updatedRows[i] = updatedRow;
1668
+ indexes.push(i);
1669
+ }
1308
1670
  }
1309
- M.length > 0 && c?.(H, {
1310
- indexes: M,
1311
- column: A
1312
- });
1671
+ }
1672
+ if (indexes.length > 0) {
1673
+ onRowsChange?.(updatedRows, {
1674
+ indexes,
1675
+ column
1676
+ });
1677
+ }
1313
1678
  }
1314
- return /* @__PURE__ */ I("div", {
1315
- className: Tr,
1316
- onMouseDown: k,
1317
- onDoubleClick: w
1679
+ return /* @__PURE__ */ jsx("div", {
1680
+ className: cellDragHandleClassname,
1681
+ onMouseDown: handleMouseDown,
1682
+ onDoubleClick: handleDoubleClick
1318
1683
  });
1319
1684
  }
1320
- var Pr = ".a888944700-beta13{fill:currentColor}.a888944700-beta13>path{transition:d .1s}";
1321
- G(Pr, { insertAt: "top" });
1322
- const Mr = "a888944700-beta13", Wr = `rdg-sort-arrow ${Mr}`;
1323
- function Hr({
1324
- sortDirection: e
1685
+ var css_248z$1 = ".a888944700-beta13{fill:currentColor}.a888944700-beta13>path{transition:d .1s}";
1686
+ styleInject(css_248z$1, { "insertAt": "top" });
1687
+ const arrow = "a888944700-beta13";
1688
+ const arrowClassname = `rdg-sort-arrow ${arrow}`;
1689
+ function SortIcon({
1690
+ sortDirection
1325
1691
  }) {
1326
- return e !== void 0 ? /* @__PURE__ */ I("svg", {
1692
+ return sortDirection !== void 0 ? /* @__PURE__ */ jsx("svg", {
1327
1693
  viewBox: "0 0 12 8",
1328
1694
  width: "12",
1329
1695
  height: "8",
1330
- className: Wr,
1331
- "aria-hidden": !0,
1332
- children: /* @__PURE__ */ I("path", {
1333
- d: e === "ASC" ? "M0 8 6 0 12 8" : "M0 0 6 8 12 0"
1696
+ className: arrowClassname,
1697
+ "aria-hidden": true,
1698
+ children: /* @__PURE__ */ jsx("path", {
1699
+ d: sortDirection === "ASC" ? "M0 8 6 0 12 8" : "M0 0 6 8 12 0"
1334
1700
  })
1335
1701
  }) : null;
1336
1702
  }
1337
- const Xt = {
1703
+ const initialPosition = {
1338
1704
  idx: -1,
1339
1705
  rowIdx: -2,
1340
1706
  mode: "SELECT"
1341
1707
  };
1342
- function Kr({
1343
- columns: e,
1344
- rows: t,
1345
- summaryRows: n,
1346
- rowKeyGetter: i,
1347
- onRowsChange: l,
1348
- rowHeight: c,
1349
- headerRowHeight: d,
1350
- summaryRowHeight: C,
1351
- selectedRows: f,
1352
- onSelectedRowsChange: k,
1353
- sortColumns: b,
1354
- onSortColumnsChange: w,
1355
- defaultColumnOptions: g,
1356
- groupBy: s,
1357
- rowGrouper: v,
1358
- expandedGroupIds: p,
1359
- onExpandedGroupIdsChange: E,
1360
- onRowClick: A,
1361
- onRowDoubleClick: _,
1362
- onScroll: H,
1363
- onColumnResize: M,
1364
- onFill: T,
1365
- onCopy: O,
1366
- onPaste: y,
1367
- cellNavigationMode: z,
1368
- enableVirtualization: S,
1369
- components: h,
1370
- className: x,
1371
- style: D,
1372
- rowClass: m,
1373
- direction: F,
1374
- "aria-label": V,
1375
- "aria-labelledby": ee,
1376
- "aria-describedby": ue,
1377
- "data-testid": le
1378
- }, Fe) {
1379
- const fe = kt();
1380
- c ?? (c = 35);
1381
- const ge = d ?? (typeof c == "number" ? c : 35), te = C ?? (typeof c == "number" ? c : 35), oo = h?.rowRenderer ?? fe?.rowRenderer ?? fr, yt = h?.sortIcon ?? fe?.sortIcon ?? Hr, Rt = h?.checkboxFormatter ?? fe?.checkboxFormatter ?? pn, vt = h?.noRowsFallback ?? fe?.noRowsFallback, $e = z ?? "NONE";
1382
- S ?? (S = !0), F ?? (F = "ltr");
1383
- const [no, ro] = Y(0), [Xe, io] = Y(0), [co, It] = Y(() => /* @__PURE__ */ new Map()), [u, be] = Y(Xt), [he, St] = Y(null), [zt, so] = Y(!1), [Ce, lo] = Y(void 0), [re, Et] = Y(null), Ye = ce(u), Dt = ce(Ce), Je = ce(-1), Le = ce(null), [de, ao, Ft] = Mn(), oe = 1, pe = n?.length ?? 0, Ae = Ft - ge - pe * te, ke = f != null && k != null, uo = u.rowIdx === -1, Oe = F === "rtl", Qe = Oe ? "ArrowRight" : "ArrowLeft", $t = Oe ? "ArrowLeft" : "ArrowRight", fo = Q(() => ({
1384
- sortIcon: yt,
1385
- checkboxFormatter: Rt
1386
- }), [yt, Rt]), go = Q(() => {
1708
+ function DataGrid({
1709
+ columns: rawColumns,
1710
+ rows: rawRows,
1711
+ summaryRows,
1712
+ rowKeyGetter,
1713
+ onRowsChange,
1714
+ rowHeight,
1715
+ headerRowHeight: rawHeaderRowHeight,
1716
+ summaryRowHeight: rawSummaryRowHeight,
1717
+ selectedRows,
1718
+ onSelectedRowsChange,
1719
+ sortColumns,
1720
+ onSortColumnsChange,
1721
+ defaultColumnOptions,
1722
+ groupBy: rawGroupBy,
1723
+ rowGrouper,
1724
+ expandedGroupIds,
1725
+ onExpandedGroupIdsChange,
1726
+ onRowClick,
1727
+ onRowDoubleClick,
1728
+ onScroll,
1729
+ onColumnResize,
1730
+ onFill,
1731
+ onCopy,
1732
+ onPaste,
1733
+ cellNavigationMode: rawCellNavigationMode,
1734
+ enableVirtualization,
1735
+ components,
1736
+ className,
1737
+ style,
1738
+ rowClass,
1739
+ direction,
1740
+ "aria-label": ariaLabel,
1741
+ "aria-labelledby": ariaLabelledBy,
1742
+ "aria-describedby": ariaDescribedBy,
1743
+ "data-testid": testId
1744
+ }, ref) {
1745
+ const defaultComponents = useDefaultComponents();
1746
+ rowHeight ?? (rowHeight = 35);
1747
+ const headerRowHeight = rawHeaderRowHeight ?? (typeof rowHeight === "number" ? rowHeight : 35);
1748
+ const summaryRowHeight = rawSummaryRowHeight ?? (typeof rowHeight === "number" ? rowHeight : 35);
1749
+ const RowRenderer = components?.rowRenderer ?? defaultComponents?.rowRenderer ?? Row$1;
1750
+ const sortIcon = components?.sortIcon ?? defaultComponents?.sortIcon ?? SortIcon;
1751
+ const checkboxFormatter = components?.checkboxFormatter ?? defaultComponents?.checkboxFormatter ?? CheckboxFormatter;
1752
+ const noRowsFallback = components?.noRowsFallback ?? defaultComponents?.noRowsFallback;
1753
+ const cellNavigationMode = rawCellNavigationMode ?? "NONE";
1754
+ enableVirtualization ?? (enableVirtualization = true);
1755
+ direction ?? (direction = "ltr");
1756
+ const [scrollTop, setScrollTop] = useState(0);
1757
+ const [scrollLeft, setScrollLeft] = useState(0);
1758
+ const [columnWidths, setColumnWidths] = useState(() => /* @__PURE__ */ new Map());
1759
+ const [selectedPosition, setSelectedPosition] = useState(initialPosition);
1760
+ const [copiedCell, setCopiedCell] = useState(null);
1761
+ const [isDragging, setDragging] = useState(false);
1762
+ const [draggedOverRowIdx, setOverRowIdx] = useState(void 0);
1763
+ const [autoResizeColumn, setAutoResizeColumn] = useState(null);
1764
+ const prevSelectedPosition = useRef(selectedPosition);
1765
+ const latestDraggedOverRowIdx = useRef(draggedOverRowIdx);
1766
+ const lastSelectedRowIdx = useRef(-1);
1767
+ const rowRef = useRef(null);
1768
+ const [gridRef, gridWidth, gridHeight] = useGridDimensions();
1769
+ const headerRowsCount = 1;
1770
+ const summaryRowsCount = summaryRows?.length ?? 0;
1771
+ const clientHeight = gridHeight - headerRowHeight - summaryRowsCount * summaryRowHeight;
1772
+ const isSelectable = selectedRows != null && onSelectedRowsChange != null;
1773
+ const isHeaderRowSelected = selectedPosition.rowIdx === -1;
1774
+ const isRtl = direction === "rtl";
1775
+ const leftKey = isRtl ? "ArrowRight" : "ArrowLeft";
1776
+ const rightKey = isRtl ? "ArrowLeft" : "ArrowRight";
1777
+ const defaultGridComponents = useMemo(() => ({
1778
+ sortIcon,
1779
+ checkboxFormatter
1780
+ }), [sortIcon, checkboxFormatter]);
1781
+ const allRowsSelected = useMemo(() => {
1387
1782
  const {
1388
- length: o
1389
- } = t;
1390
- return o !== 0 && f != null && i != null && f.size >= o && t.every((r) => f.has(i(r)));
1391
- }, [t, f, i]), {
1392
- columns: B,
1393
- colSpanColumns: Lt,
1394
- colOverscanStartIdx: bo,
1395
- colOverscanEndIdx: At,
1396
- layoutCssVars: Ze,
1397
- columnMetrics: Ot,
1398
- lastFrozenColumnIndex: U,
1399
- totalFrozenColumnWidth: et,
1400
- groupBy: Tt
1401
- } = Nn({
1402
- rawColumns: e,
1403
- columnWidths: co,
1404
- scrollLeft: Xe,
1405
- viewportWidth: ao,
1406
- defaultColumnOptions: g,
1407
- rawGroupBy: v ? s : void 0,
1408
- enableVirtualization: S
1409
- }), {
1410
- rowOverscanStartIdx: ye,
1411
- rowOverscanEndIdx: Re,
1412
- rows: W,
1413
- rowsCount: Nt,
1414
- totalRowHeight: Pt,
1415
- gridTemplateRows: ho,
1416
- isGroupRow: X,
1417
- getRowTop: tt,
1418
- getRowHeight: ot,
1419
- findRowIdx: Mt
1420
- } = Kn({
1421
- rawRows: t,
1422
- groupBy: Tt,
1423
- rowGrouper: v,
1424
- rowHeight: c,
1425
- clientHeight: Ae,
1426
- scrollTop: no,
1427
- expandedGroupIds: p,
1428
- enableVirtualization: S
1429
- }), xe = Wn({
1430
- columns: B,
1431
- colSpanColumns: Lt,
1432
- colOverscanStartIdx: bo,
1433
- colOverscanEndIdx: At,
1434
- lastFrozenColumnIndex: U,
1435
- rowOverscanStartIdx: ye,
1436
- rowOverscanEndIdx: Re,
1437
- rows: W,
1438
- summaryRows: n,
1439
- isGroupRow: X
1440
- }), ie = Tt.length > 0 && typeof v == "function", po = ie ? -1 : 0, Te = B.length - 1, ve = -1, Ie = oe + W.length + pe - 2, nt = Me(u), Ne = Gt(u), xo = J(Wt), wo = J(So), mo = J(Pe), Co = J((o, r, R) => {
1441
- const a = W.indexOf(o);
1442
- we({
1443
- rowIdx: a,
1444
- idx: r.idx
1445
- }, R);
1446
- }), ko = J((o) => {
1447
- we({
1448
- rowIdx: o,
1783
+ length
1784
+ } = rawRows;
1785
+ return length !== 0 && selectedRows != null && rowKeyGetter != null && selectedRows.size >= length && rawRows.every((row2) => selectedRows.has(rowKeyGetter(row2)));
1786
+ }, [rawRows, selectedRows, rowKeyGetter]);
1787
+ const {
1788
+ columns,
1789
+ colSpanColumns,
1790
+ colOverscanStartIdx,
1791
+ colOverscanEndIdx,
1792
+ layoutCssVars,
1793
+ columnMetrics,
1794
+ lastFrozenColumnIndex,
1795
+ totalFrozenColumnWidth,
1796
+ groupBy
1797
+ } = useCalculatedColumns({
1798
+ rawColumns,
1799
+ columnWidths,
1800
+ scrollLeft,
1801
+ viewportWidth: gridWidth,
1802
+ defaultColumnOptions,
1803
+ rawGroupBy: rowGrouper ? rawGroupBy : void 0,
1804
+ enableVirtualization
1805
+ });
1806
+ const {
1807
+ rowOverscanStartIdx,
1808
+ rowOverscanEndIdx,
1809
+ rows,
1810
+ rowsCount,
1811
+ totalRowHeight,
1812
+ gridTemplateRows,
1813
+ isGroupRow,
1814
+ getRowTop,
1815
+ getRowHeight,
1816
+ findRowIdx
1817
+ } = useViewportRows({
1818
+ rawRows,
1819
+ groupBy,
1820
+ rowGrouper,
1821
+ rowHeight,
1822
+ clientHeight,
1823
+ scrollTop,
1824
+ expandedGroupIds,
1825
+ enableVirtualization
1826
+ });
1827
+ const viewportColumns = useViewportColumns({
1828
+ columns,
1829
+ colSpanColumns,
1830
+ colOverscanStartIdx,
1831
+ colOverscanEndIdx,
1832
+ lastFrozenColumnIndex,
1833
+ rowOverscanStartIdx,
1834
+ rowOverscanEndIdx,
1835
+ rows,
1836
+ summaryRows,
1837
+ isGroupRow
1838
+ });
1839
+ const hasGroups = groupBy.length > 0 && typeof rowGrouper === "function";
1840
+ const minColIdx = hasGroups ? -1 : 0;
1841
+ const maxColIdx = columns.length - 1;
1842
+ const minRowIdx = -1;
1843
+ const maxRowIdx = headerRowsCount + rows.length + summaryRowsCount - 2;
1844
+ const selectedCellIsWithinSelectionBounds = isCellWithinSelectionBounds(selectedPosition);
1845
+ const selectedCellIsWithinViewportBounds = isCellWithinViewportBounds(selectedPosition);
1846
+ const selectRowLatest = useLatestFunc(selectRow);
1847
+ const selectAllRowsLatest = useLatestFunc(selectAllRows);
1848
+ const handleFormatterRowChangeLatest = useLatestFunc(updateRow);
1849
+ const selectViewportCellLatest = useLatestFunc((row2, column, enableEditor) => {
1850
+ const rowIdx = rows.indexOf(row2);
1851
+ selectCell({
1852
+ rowIdx,
1853
+ idx: column.idx
1854
+ }, enableEditor);
1855
+ });
1856
+ const selectGroupLatest = useLatestFunc((rowIdx) => {
1857
+ selectCell({
1858
+ rowIdx,
1449
1859
  idx: -1
1450
1860
  });
1451
- }), yo = J((o) => {
1452
- we({
1861
+ });
1862
+ const selectHeaderCellLatest = useLatestFunc((idx) => {
1863
+ selectCell({
1453
1864
  rowIdx: -1,
1454
- idx: o
1865
+ idx
1455
1866
  });
1456
- }), Ro = J((o, r) => {
1457
- const R = n.indexOf(o) + oe + W.length - 1;
1458
- we({
1459
- rowIdx: R,
1460
- idx: r.idx
1867
+ });
1868
+ const selectSummaryCellLatest = useLatestFunc((summaryRow2, column) => {
1869
+ const rowIdx = summaryRows.indexOf(summaryRow2) + headerRowsCount + rows.length - 1;
1870
+ selectCell({
1871
+ rowIdx,
1872
+ idx: column.idx
1461
1873
  });
1462
- }), vo = J(Ht);
1463
- Be(() => {
1464
- if (!nt || at(u, Ye.current)) {
1465
- Ye.current = u;
1874
+ });
1875
+ const toggleGroupLatest = useLatestFunc(toggleGroup);
1876
+ useLayoutEffect(() => {
1877
+ if (!selectedCellIsWithinSelectionBounds || isSamePosition(selectedPosition, prevSelectedPosition.current)) {
1878
+ prevSelectedPosition.current = selectedPosition;
1466
1879
  return;
1467
1880
  }
1468
- Ye.current = u, u.idx === -1 && (Le.current.focus({
1469
- preventScroll: !0
1470
- }), gt(Le.current));
1471
- }), Be(() => {
1472
- if (re === null)
1881
+ prevSelectedPosition.current = selectedPosition;
1882
+ if (selectedPosition.idx === -1) {
1883
+ rowRef.current.focus({
1884
+ preventScroll: true
1885
+ });
1886
+ scrollIntoView(rowRef.current);
1887
+ }
1888
+ });
1889
+ useLayoutEffect(() => {
1890
+ if (autoResizeColumn === null)
1473
1891
  return;
1474
- const o = de.current.querySelector(`[aria-colindex="${re.idx + 1}"]`), {
1475
- width: r
1476
- } = o.getBoundingClientRect();
1477
- It((R) => {
1478
- const a = new Map(R);
1479
- return a.set(re.key, r), a;
1480
- }), Et(null), M?.(re.idx, r);
1481
- }, [re, de, M]), Ho(Fe, () => ({
1482
- element: de.current,
1483
- scrollToColumn: $o,
1484
- scrollToRow(o) {
1892
+ const columnElement = gridRef.current.querySelector(`[aria-colindex="${autoResizeColumn.idx + 1}"]`);
1893
+ const {
1894
+ width
1895
+ } = columnElement.getBoundingClientRect();
1896
+ setColumnWidths((columnWidths2) => {
1897
+ const newColumnWidths = new Map(columnWidths2);
1898
+ newColumnWidths.set(autoResizeColumn.key, width);
1899
+ return newColumnWidths;
1900
+ });
1901
+ setAutoResizeColumn(null);
1902
+ onColumnResize?.(autoResizeColumn.idx, width);
1903
+ }, [autoResizeColumn, gridRef, onColumnResize]);
1904
+ useImperativeHandle(ref, () => ({
1905
+ element: gridRef.current,
1906
+ scrollToColumn,
1907
+ scrollToRow(rowIdx) {
1485
1908
  const {
1486
- current: r
1487
- } = de;
1488
- !r || r.scrollTo({
1489
- top: tt(o),
1909
+ current
1910
+ } = gridRef;
1911
+ if (!current)
1912
+ return;
1913
+ current.scrollTo({
1914
+ top: getRowTop(rowIdx),
1490
1915
  behavior: "smooth"
1491
1916
  });
1492
1917
  },
1493
- selectCell: we
1918
+ selectCell
1494
1919
  }));
1495
- const Io = je((o, r) => {
1496
- if (r === "auto") {
1497
- Et(o);
1920
+ const handleColumnResize = useCallback((column, width) => {
1921
+ if (width === "auto") {
1922
+ setAutoResizeColumn(column);
1498
1923
  return;
1499
1924
  }
1500
- It((R) => {
1501
- const a = new Map(R);
1502
- return a.set(o.key, r), a;
1503
- }), M?.(o.idx, r);
1504
- }, [M]), rt = je((o) => {
1505
- lo(o), Dt.current = o;
1925
+ setColumnWidths((columnWidths2) => {
1926
+ const newColumnWidths = new Map(columnWidths2);
1927
+ newColumnWidths.set(column.key, width);
1928
+ return newColumnWidths;
1929
+ });
1930
+ onColumnResize?.(column.idx, width);
1931
+ }, [onColumnResize]);
1932
+ const setDraggedOverRowIdx = useCallback((rowIdx) => {
1933
+ setOverRowIdx(rowIdx);
1934
+ latestDraggedOverRowIdx.current = rowIdx;
1506
1935
  }, []);
1507
- function Wt({
1508
- row: o,
1509
- checked: r,
1510
- isShiftClick: R
1936
+ function selectRow({
1937
+ row: row2,
1938
+ checked,
1939
+ isShiftClick
1511
1940
  }) {
1512
- if (!k)
1941
+ if (!onSelectedRowsChange)
1513
1942
  return;
1514
- dt(i);
1515
- const a = new Set(f);
1516
- if (X(o)) {
1517
- for (const $ of o.childRows) {
1518
- const L = i($);
1519
- r ? a.add(L) : a.delete(L);
1943
+ assertIsValidKeyGetter(rowKeyGetter);
1944
+ const newSelectedRows = new Set(selectedRows);
1945
+ if (isGroupRow(row2)) {
1946
+ for (const childRow of row2.childRows) {
1947
+ const rowKey2 = rowKeyGetter(childRow);
1948
+ if (checked) {
1949
+ newSelectedRows.add(rowKey2);
1950
+ } else {
1951
+ newSelectedRows.delete(rowKey2);
1952
+ }
1520
1953
  }
1521
- k(a);
1954
+ onSelectedRowsChange(newSelectedRows);
1522
1955
  return;
1523
1956
  }
1524
- const N = i(o);
1525
- if (r) {
1526
- a.add(N);
1527
- const $ = Je.current, L = W.indexOf(o);
1528
- if (Je.current = L, R && $ !== -1 && $ !== L) {
1529
- const K = An(L - $);
1530
- for (let P = $ + K; P !== L; P += K) {
1531
- const q = W[P];
1532
- X(q) || a.add(i(q));
1957
+ const rowKey = rowKeyGetter(row2);
1958
+ if (checked) {
1959
+ newSelectedRows.add(rowKey);
1960
+ const previousRowIdx = lastSelectedRowIdx.current;
1961
+ const rowIdx = rows.indexOf(row2);
1962
+ lastSelectedRowIdx.current = rowIdx;
1963
+ if (isShiftClick && previousRowIdx !== -1 && previousRowIdx !== rowIdx) {
1964
+ const step = sign(rowIdx - previousRowIdx);
1965
+ for (let i = previousRowIdx + step; i !== rowIdx; i += step) {
1966
+ const row3 = rows[i];
1967
+ if (isGroupRow(row3))
1968
+ continue;
1969
+ newSelectedRows.add(rowKeyGetter(row3));
1533
1970
  }
1534
1971
  }
1535
- } else
1536
- a.delete(N), Je.current = -1;
1537
- k(a);
1972
+ } else {
1973
+ newSelectedRows.delete(rowKey);
1974
+ lastSelectedRowIdx.current = -1;
1975
+ }
1976
+ onSelectedRowsChange(newSelectedRows);
1538
1977
  }
1539
- function So(o) {
1540
- if (!k)
1978
+ function selectAllRows(checked) {
1979
+ if (!onSelectedRowsChange)
1541
1980
  return;
1542
- dt(i);
1543
- const r = new Set(f);
1544
- for (const R of t) {
1545
- const a = i(R);
1546
- o ? r.add(a) : r.delete(a);
1981
+ assertIsValidKeyGetter(rowKeyGetter);
1982
+ const newSelectedRows = new Set(selectedRows);
1983
+ for (const row2 of rawRows) {
1984
+ const rowKey = rowKeyGetter(row2);
1985
+ if (checked) {
1986
+ newSelectedRows.add(rowKey);
1987
+ } else {
1988
+ newSelectedRows.delete(rowKey);
1989
+ }
1547
1990
  }
1548
- k(r);
1991
+ onSelectedRowsChange(newSelectedRows);
1549
1992
  }
1550
- function Ht(o) {
1551
- if (!E)
1993
+ function toggleGroup(expandedGroupId) {
1994
+ if (!onExpandedGroupIdsChange)
1552
1995
  return;
1553
- const r = new Set(p);
1554
- r.has(o) ? r.delete(o) : r.add(o), E(r);
1996
+ const newExpandedGroupIds = new Set(expandedGroupIds);
1997
+ if (newExpandedGroupIds.has(expandedGroupId)) {
1998
+ newExpandedGroupIds.delete(expandedGroupId);
1999
+ } else {
2000
+ newExpandedGroupIds.add(expandedGroupId);
2001
+ }
2002
+ onExpandedGroupIdsChange(newExpandedGroupIds);
1555
2003
  }
1556
- function Kt(o) {
1557
- if (!(o.target instanceof Element))
2004
+ function handleKeyDown(event) {
2005
+ if (!(event.target instanceof Element))
1558
2006
  return;
1559
- const r = o.target.closest(".rdg-cell") !== null, R = ie && o.target === Le.current;
1560
- if (!r && !R)
2007
+ const isCellEvent = event.target.closest(".rdg-cell") !== null;
2008
+ const isRowEvent = hasGroups && event.target === rowRef.current;
2009
+ if (!isCellEvent && !isRowEvent)
1561
2010
  return;
1562
2011
  const {
1563
- key: a,
1564
- keyCode: N
1565
- } = o, {
1566
- rowIdx: $
1567
- } = u;
1568
- if (Ne && (y != null || O != null) && qt(o) && !X(W[$]) && u.mode === "SELECT") {
1569
- if (N === 67) {
1570
- Eo();
2012
+ key,
2013
+ keyCode
2014
+ } = event;
2015
+ const {
2016
+ rowIdx
2017
+ } = selectedPosition;
2018
+ if (selectedCellIsWithinViewportBounds && (onPaste != null || onCopy != null) && isCtrlKeyHeldDown(event) && !isGroupRow(rows[rowIdx]) && selectedPosition.mode === "SELECT") {
2019
+ const cKey = 67;
2020
+ const vKey = 86;
2021
+ if (keyCode === cKey) {
2022
+ handleCopy();
1571
2023
  return;
1572
2024
  }
1573
- if (N === 86) {
1574
- Do();
2025
+ if (keyCode === vKey) {
2026
+ handlePaste();
1575
2027
  return;
1576
2028
  }
1577
2029
  }
1578
- if (Bt($)) {
1579
- const L = W[$];
1580
- if (X(L) && u.idx === -1 && (a === Qe && L.isExpanded || a === $t && !L.isExpanded)) {
1581
- o.preventDefault(), Ht(L.id);
2030
+ if (isRowIdxWithinViewportBounds(rowIdx)) {
2031
+ const row2 = rows[rowIdx];
2032
+ if (isGroupRow(row2) && selectedPosition.idx === -1 && (key === leftKey && row2.isExpanded || key === rightKey && !row2.isExpanded)) {
2033
+ event.preventDefault();
2034
+ toggleGroup(row2.id);
1582
2035
  return;
1583
2036
  }
1584
2037
  }
1585
- switch (o.key) {
2038
+ switch (event.key) {
1586
2039
  case "Escape":
1587
- St(null);
2040
+ setCopiedCell(null);
1588
2041
  return;
1589
2042
  case "ArrowUp":
1590
2043
  case "ArrowDown":
@@ -1595,521 +2048,611 @@ function Kr({
1595
2048
  case "End":
1596
2049
  case "PageUp":
1597
2050
  case "PageDown":
1598
- Ao(o);
2051
+ navigate(event);
1599
2052
  break;
1600
2053
  default:
1601
- Fo(o);
2054
+ handleCellInput(event);
1602
2055
  break;
1603
2056
  }
1604
2057
  }
1605
- function zo(o) {
2058
+ function handleScroll(event) {
1606
2059
  const {
1607
- scrollTop: r,
1608
- scrollLeft: R
1609
- } = o.currentTarget;
1610
- ro(r), io(On(R)), H?.(o);
2060
+ scrollTop: scrollTop2,
2061
+ scrollLeft: scrollLeft2
2062
+ } = event.currentTarget;
2063
+ setScrollTop(scrollTop2);
2064
+ setScrollLeft(abs(scrollLeft2));
2065
+ onScroll?.(event);
1611
2066
  }
1612
- function it(o) {
1613
- return ie ? t.indexOf(W[o]) : o;
2067
+ function getRawRowIdx(rowIdx) {
2068
+ return hasGroups ? rawRows.indexOf(rows[rowIdx]) : rowIdx;
1614
2069
  }
1615
- function Pe(o, r) {
1616
- if (typeof l != "function")
2070
+ function updateRow(rowIdx, row2) {
2071
+ if (typeof onRowsChange !== "function")
1617
2072
  return;
1618
- const R = it(o);
1619
- if (r === t[R])
2073
+ const rawRowIdx = getRawRowIdx(rowIdx);
2074
+ if (row2 === rawRows[rawRowIdx])
1620
2075
  return;
1621
- const a = [...t];
1622
- a[R] = r, l(a, {
1623
- indexes: [R],
1624
- column: B[u.idx]
2076
+ const updatedRows = [...rawRows];
2077
+ updatedRows[rawRowIdx] = row2;
2078
+ onRowsChange(updatedRows, {
2079
+ indexes: [rawRowIdx],
2080
+ column: columns[selectedPosition.idx]
1625
2081
  });
1626
2082
  }
1627
- function _t() {
1628
- u.mode === "EDIT" && Pe(u.rowIdx, u.row);
2083
+ function commitEditorChanges() {
2084
+ if (selectedPosition.mode !== "EDIT")
2085
+ return;
2086
+ updateRow(selectedPosition.rowIdx, selectedPosition.row);
1629
2087
  }
1630
- function Eo() {
2088
+ function handleCopy() {
1631
2089
  const {
1632
- idx: o,
1633
- rowIdx: r
1634
- } = u, R = t[it(r)], a = B[o].key;
1635
- St({
1636
- row: R,
1637
- columnKey: a
1638
- }), O?.({
1639
- sourceRow: R,
1640
- sourceColumnKey: a
2090
+ idx,
2091
+ rowIdx
2092
+ } = selectedPosition;
2093
+ const sourceRow = rawRows[getRawRowIdx(rowIdx)];
2094
+ const sourceColumnKey = columns[idx].key;
2095
+ setCopiedCell({
2096
+ row: sourceRow,
2097
+ columnKey: sourceColumnKey
2098
+ });
2099
+ onCopy?.({
2100
+ sourceRow,
2101
+ sourceColumnKey
1641
2102
  });
1642
2103
  }
1643
- function Do() {
1644
- if (!y || !l || he === null || !We(u))
2104
+ function handlePaste() {
2105
+ if (!onPaste || !onRowsChange || copiedCell === null || !isCellEditable2(selectedPosition)) {
1645
2106
  return;
2107
+ }
1646
2108
  const {
1647
- idx: o,
1648
- rowIdx: r
1649
- } = u, R = t[it(r)], a = y({
1650
- sourceRow: he.row,
1651
- sourceColumnKey: he.columnKey,
1652
- targetRow: R,
1653
- targetColumnKey: B[o].key
2109
+ idx,
2110
+ rowIdx
2111
+ } = selectedPosition;
2112
+ const targetRow = rawRows[getRawRowIdx(rowIdx)];
2113
+ const updatedTargetRow = onPaste({
2114
+ sourceRow: copiedCell.row,
2115
+ sourceColumnKey: copiedCell.columnKey,
2116
+ targetRow,
2117
+ targetColumnKey: columns[idx].key
1654
2118
  });
1655
- Pe(r, a);
2119
+ updateRow(rowIdx, updatedTargetRow);
1656
2120
  }
1657
- function Fo(o) {
1658
- if (!Ne)
2121
+ function handleCellInput(event) {
2122
+ if (!selectedCellIsWithinViewportBounds)
1659
2123
  return;
1660
- const r = W[u.rowIdx];
1661
- if (X(r))
2124
+ const row2 = rows[selectedPosition.rowIdx];
2125
+ if (isGroupRow(row2))
1662
2126
  return;
1663
2127
  const {
1664
- key: R,
1665
- shiftKey: a
1666
- } = o;
1667
- if (ke && a && R === " ") {
1668
- dt(i);
1669
- const $ = i(r);
1670
- Wt({
1671
- row: r,
1672
- checked: !f.has($),
1673
- isShiftClick: !1
1674
- }), o.preventDefault();
2128
+ key,
2129
+ shiftKey
2130
+ } = event;
2131
+ if (isSelectable && shiftKey && key === " ") {
2132
+ assertIsValidKeyGetter(rowKeyGetter);
2133
+ const rowKey = rowKeyGetter(row2);
2134
+ selectRow({
2135
+ row: row2,
2136
+ checked: !selectedRows.has(rowKey),
2137
+ isShiftClick: false
2138
+ });
2139
+ event.preventDefault();
1675
2140
  return;
1676
2141
  }
1677
- B[u.idx].editorOptions?.onCellKeyDown?.(o), !o.isDefaultPrevented() && We(u) && zn(o) && be(({
1678
- idx: $,
1679
- rowIdx: L
1680
- }) => ({
1681
- idx: $,
1682
- rowIdx: L,
1683
- mode: "EDIT",
1684
- row: r,
1685
- originalRow: r
1686
- }));
1687
- }
1688
- function jt(o) {
1689
- return o >= po && o <= Te;
1690
- }
1691
- function Bt(o) {
1692
- return o >= 0 && o < W.length;
1693
- }
1694
- function Me({
1695
- idx: o,
1696
- rowIdx: r
2142
+ const column = columns[selectedPosition.idx];
2143
+ column.editorOptions?.onCellKeyDown?.(event);
2144
+ if (event.isDefaultPrevented())
2145
+ return;
2146
+ if (isCellEditable2(selectedPosition) && isDefaultCellInput(event)) {
2147
+ setSelectedPosition(({
2148
+ idx,
2149
+ rowIdx
2150
+ }) => ({
2151
+ idx,
2152
+ rowIdx,
2153
+ mode: "EDIT",
2154
+ row: row2,
2155
+ originalRow: row2
2156
+ }));
2157
+ }
2158
+ }
2159
+ function isColIdxWithinSelectionBounds(idx) {
2160
+ return idx >= minColIdx && idx <= maxColIdx;
2161
+ }
2162
+ function isRowIdxWithinViewportBounds(rowIdx) {
2163
+ return rowIdx >= 0 && rowIdx < rows.length;
2164
+ }
2165
+ function isCellWithinSelectionBounds({
2166
+ idx,
2167
+ rowIdx
1697
2168
  }) {
1698
- return r >= ve && r <= Ie && jt(o);
2169
+ return rowIdx >= minRowIdx && rowIdx <= maxRowIdx && isColIdxWithinSelectionBounds(idx);
1699
2170
  }
1700
- function Gt({
1701
- idx: o,
1702
- rowIdx: r
2171
+ function isCellWithinViewportBounds({
2172
+ idx,
2173
+ rowIdx
1703
2174
  }) {
1704
- return Bt(r) && jt(o);
1705
- }
1706
- function We(o) {
1707
- return Gt(o) && Dn({
1708
- columns: B,
1709
- rows: W,
1710
- selectedPosition: o,
1711
- isGroupRow: X
2175
+ return isRowIdxWithinViewportBounds(rowIdx) && isColIdxWithinSelectionBounds(idx);
2176
+ }
2177
+ function isCellEditable2(position) {
2178
+ return isCellWithinViewportBounds(position) && isSelectedCellEditable({
2179
+ columns,
2180
+ rows,
2181
+ selectedPosition: position,
2182
+ isGroupRow
1712
2183
  });
1713
2184
  }
1714
- function we(o, r) {
1715
- if (!!Me(o))
1716
- if (_t(), r && We(o)) {
1717
- const R = W[o.rowIdx];
1718
- be({
1719
- ...o,
1720
- mode: "EDIT",
1721
- row: R,
1722
- originalRow: R
1723
- });
1724
- } else
1725
- at(u, o) ? gt(de.current?.querySelector('[tabindex="0"]')) : be({
1726
- ...o,
1727
- mode: "SELECT"
1728
- });
2185
+ function selectCell(position, enableEditor) {
2186
+ if (!isCellWithinSelectionBounds(position))
2187
+ return;
2188
+ commitEditorChanges();
2189
+ if (enableEditor && isCellEditable2(position)) {
2190
+ const row2 = rows[position.rowIdx];
2191
+ setSelectedPosition({
2192
+ ...position,
2193
+ mode: "EDIT",
2194
+ row: row2,
2195
+ originalRow: row2
2196
+ });
2197
+ } else if (isSamePosition(selectedPosition, position)) {
2198
+ scrollIntoView(gridRef.current?.querySelector('[tabindex="0"]'));
2199
+ } else {
2200
+ setSelectedPosition({
2201
+ ...position,
2202
+ mode: "SELECT"
2203
+ });
2204
+ }
1729
2205
  }
1730
- function $o(o) {
2206
+ function scrollToColumn(idx) {
1731
2207
  const {
1732
- current: r
1733
- } = de;
1734
- if (!!r && o > U) {
2208
+ current
2209
+ } = gridRef;
2210
+ if (!current)
2211
+ return;
2212
+ if (idx > lastFrozenColumnIndex) {
1735
2213
  const {
1736
- rowIdx: R
1737
- } = u;
1738
- if (!Me({
1739
- rowIdx: R,
1740
- idx: o
2214
+ rowIdx
2215
+ } = selectedPosition;
2216
+ if (!isCellWithinSelectionBounds({
2217
+ rowIdx,
2218
+ idx
1741
2219
  }))
1742
2220
  return;
1743
2221
  const {
1744
- clientWidth: a
1745
- } = r, N = B[o], {
1746
- left: $,
1747
- width: L
1748
- } = Ot.get(N);
1749
- let K = $ + L;
1750
- const P = to({
1751
- rows: W,
1752
- summaryRows: n,
1753
- rowIdx: R,
1754
- lastFrozenColumnIndex: U,
1755
- column: N,
1756
- isGroupRow: X
2222
+ clientWidth
2223
+ } = current;
2224
+ const column = columns[idx];
2225
+ const {
2226
+ left,
2227
+ width
2228
+ } = columnMetrics.get(column);
2229
+ let right = left + width;
2230
+ const colSpan = getSelectedCellColSpan({
2231
+ rows,
2232
+ summaryRows,
2233
+ rowIdx,
2234
+ lastFrozenColumnIndex,
2235
+ column,
2236
+ isGroupRow
1757
2237
  });
1758
- if (P !== void 0) {
2238
+ if (colSpan !== void 0) {
1759
2239
  const {
1760
- left: Ke,
1761
- width: me
1762
- } = Ot.get(B[N.idx + P - 1]);
1763
- K = Ke + me;
2240
+ left: left2,
2241
+ width: width2
2242
+ } = columnMetrics.get(columns[column.idx + colSpan - 1]);
2243
+ right = left2 + width2;
2244
+ }
2245
+ const isCellAtLeftBoundary = left < scrollLeft + totalFrozenColumnWidth;
2246
+ const isCellAtRightBoundary = right > clientWidth + scrollLeft;
2247
+ const sign2 = isRtl ? -1 : 1;
2248
+ if (isCellAtLeftBoundary) {
2249
+ current.scrollLeft = (left - totalFrozenColumnWidth) * sign2;
2250
+ } else if (isCellAtRightBoundary) {
2251
+ current.scrollLeft = (right - clientWidth) * sign2;
1764
2252
  }
1765
- const q = $ < Xe + et, He = K > a + Xe, j = Oe ? -1 : 1;
1766
- q ? r.scrollLeft = ($ - et) * j : He && (r.scrollLeft = (K - a) * j);
1767
2253
  }
1768
2254
  }
1769
- function Lo(o, r, R) {
2255
+ function getNextPosition(key, ctrlKey, shiftKey) {
1770
2256
  const {
1771
- idx: a,
1772
- rowIdx: N
1773
- } = u, $ = W[N], L = nt && a === -1;
1774
- if (o === Qe && L && X($) && !$.isExpanded && $.level !== 0) {
1775
- let K = -1;
1776
- for (let P = u.rowIdx - 1; P >= 0; P--) {
1777
- const q = W[P];
1778
- if (X(q) && q.id === $.parentId) {
1779
- K = P;
2257
+ idx,
2258
+ rowIdx
2259
+ } = selectedPosition;
2260
+ const row2 = rows[rowIdx];
2261
+ const isRowSelected = selectedCellIsWithinSelectionBounds && idx === -1;
2262
+ if (key === leftKey && isRowSelected && isGroupRow(row2) && !row2.isExpanded && row2.level !== 0) {
2263
+ let parentRowIdx = -1;
2264
+ for (let i = selectedPosition.rowIdx - 1; i >= 0; i--) {
2265
+ const parentRow = rows[i];
2266
+ if (isGroupRow(parentRow) && parentRow.id === row2.parentId) {
2267
+ parentRowIdx = i;
1780
2268
  break;
1781
2269
  }
1782
2270
  }
1783
- if (K !== -1)
2271
+ if (parentRowIdx !== -1) {
1784
2272
  return {
1785
- idx: a,
1786
- rowIdx: K
2273
+ idx,
2274
+ rowIdx: parentRowIdx
1787
2275
  };
2276
+ }
1788
2277
  }
1789
- switch (o) {
2278
+ switch (key) {
1790
2279
  case "ArrowUp":
1791
2280
  return {
1792
- idx: a,
1793
- rowIdx: N - 1
2281
+ idx,
2282
+ rowIdx: rowIdx - 1
1794
2283
  };
1795
2284
  case "ArrowDown":
1796
2285
  return {
1797
- idx: a,
1798
- rowIdx: N + 1
2286
+ idx,
2287
+ rowIdx: rowIdx + 1
1799
2288
  };
1800
- case Qe:
2289
+ case leftKey:
1801
2290
  return {
1802
- idx: a - 1,
1803
- rowIdx: N
2291
+ idx: idx - 1,
2292
+ rowIdx
1804
2293
  };
1805
- case $t:
2294
+ case rightKey:
1806
2295
  return {
1807
- idx: a + 1,
1808
- rowIdx: N
2296
+ idx: idx + 1,
2297
+ rowIdx
1809
2298
  };
1810
2299
  case "Tab":
1811
2300
  return {
1812
- idx: a + (R ? -1 : 1),
1813
- rowIdx: N
2301
+ idx: idx + (shiftKey ? -1 : 1),
2302
+ rowIdx
1814
2303
  };
1815
2304
  case "Home":
1816
- return L ? {
1817
- idx: a,
1818
- rowIdx: 0
1819
- } : {
2305
+ if (isRowSelected)
2306
+ return {
2307
+ idx,
2308
+ rowIdx: 0
2309
+ };
2310
+ return {
1820
2311
  idx: 0,
1821
- rowIdx: r ? ve : N
2312
+ rowIdx: ctrlKey ? minRowIdx : rowIdx
1822
2313
  };
1823
2314
  case "End":
1824
- return L ? {
1825
- idx: a,
1826
- rowIdx: W.length - 1
1827
- } : {
1828
- idx: Te,
1829
- rowIdx: r ? Ie : N
2315
+ if (isRowSelected)
2316
+ return {
2317
+ idx,
2318
+ rowIdx: rows.length - 1
2319
+ };
2320
+ return {
2321
+ idx: maxColIdx,
2322
+ rowIdx: ctrlKey ? maxRowIdx : rowIdx
1830
2323
  };
1831
2324
  case "PageUp": {
1832
- if (u.rowIdx === ve)
1833
- return u;
1834
- const K = tt(N) + ot(N) - Ae;
2325
+ if (selectedPosition.rowIdx === minRowIdx)
2326
+ return selectedPosition;
2327
+ const nextRowY = getRowTop(rowIdx) + getRowHeight(rowIdx) - clientHeight;
1835
2328
  return {
1836
- idx: a,
1837
- rowIdx: K > 0 ? Mt(K) : 0
2329
+ idx,
2330
+ rowIdx: nextRowY > 0 ? findRowIdx(nextRowY) : 0
1838
2331
  };
1839
2332
  }
1840
2333
  case "PageDown": {
1841
- if (u.rowIdx >= W.length)
1842
- return u;
1843
- const K = tt(N) + Ae;
2334
+ if (selectedPosition.rowIdx >= rows.length)
2335
+ return selectedPosition;
2336
+ const nextRowY = getRowTop(rowIdx) + clientHeight;
1844
2337
  return {
1845
- idx: a,
1846
- rowIdx: K < Pt ? Mt(K) : W.length - 1
2338
+ idx,
2339
+ rowIdx: nextRowY < totalRowHeight ? findRowIdx(nextRowY) : rows.length - 1
1847
2340
  };
1848
2341
  }
1849
2342
  default:
1850
- return u;
2343
+ return selectedPosition;
1851
2344
  }
1852
2345
  }
1853
- function Ao(o) {
2346
+ function navigate(event) {
1854
2347
  const {
1855
- key: r,
1856
- shiftKey: R
1857
- } = o;
1858
- let a = $e;
1859
- if (r === "Tab") {
1860
- if ($n({
1861
- shiftKey: R,
1862
- cellNavigationMode: $e,
1863
- maxColIdx: Te,
1864
- minRowIdx: ve,
1865
- maxRowIdx: Ie,
1866
- selectedPosition: u
2348
+ key,
2349
+ shiftKey
2350
+ } = event;
2351
+ let mode = cellNavigationMode;
2352
+ if (key === "Tab") {
2353
+ if (canExitGrid({
2354
+ shiftKey,
2355
+ cellNavigationMode,
2356
+ maxColIdx,
2357
+ minRowIdx,
2358
+ maxRowIdx,
2359
+ selectedPosition
1867
2360
  })) {
1868
- _t();
2361
+ commitEditorChanges();
1869
2362
  return;
1870
2363
  }
1871
- a = $e === "NONE" ? "CHANGE_ROW" : $e;
2364
+ mode = cellNavigationMode === "NONE" ? "CHANGE_ROW" : cellNavigationMode;
1872
2365
  }
1873
- o.preventDefault();
1874
- const N = qt(o), $ = Lo(r, N, R);
1875
- if (at(u, $))
2366
+ event.preventDefault();
2367
+ const ctrlKey = isCtrlKeyHeldDown(event);
2368
+ const nextPosition = getNextPosition(key, ctrlKey, shiftKey);
2369
+ if (isSamePosition(selectedPosition, nextPosition))
1876
2370
  return;
1877
- const L = Fn({
1878
- columns: B,
1879
- colSpanColumns: Lt,
1880
- rows: W,
1881
- summaryRows: n,
1882
- minRowIdx: ve,
1883
- maxRowIdx: Ie,
1884
- lastFrozenColumnIndex: U,
1885
- cellNavigationMode: a,
1886
- currentPosition: u,
1887
- nextPosition: $,
1888
- isCellWithinBounds: Me,
1889
- isGroupRow: X
2371
+ const nextSelectedCellPosition = getNextSelectedCellPosition({
2372
+ columns,
2373
+ colSpanColumns,
2374
+ rows,
2375
+ summaryRows,
2376
+ minRowIdx,
2377
+ maxRowIdx,
2378
+ lastFrozenColumnIndex,
2379
+ cellNavigationMode: mode,
2380
+ currentPosition: selectedPosition,
2381
+ nextPosition,
2382
+ isCellWithinBounds: isCellWithinSelectionBounds,
2383
+ isGroupRow
1890
2384
  });
1891
- we(L);
2385
+ selectCell(nextSelectedCellPosition);
1892
2386
  }
1893
- function Oo(o) {
1894
- if (Ce === void 0)
2387
+ function getDraggedOverCellIdx(currentRowIdx) {
2388
+ if (draggedOverRowIdx === void 0)
1895
2389
  return;
1896
2390
  const {
1897
- rowIdx: r
1898
- } = u;
1899
- return (r < Ce ? r < o && o <= Ce : r > o && o >= Ce) ? u.idx : void 0;
2391
+ rowIdx
2392
+ } = selectedPosition;
2393
+ const isDraggedOver = rowIdx < draggedOverRowIdx ? rowIdx < currentRowIdx && currentRowIdx <= draggedOverRowIdx : rowIdx > currentRowIdx && currentRowIdx >= draggedOverRowIdx;
2394
+ return isDraggedOver ? selectedPosition.idx : void 0;
1900
2395
  }
1901
- function To() {
1902
- if (re === null)
1903
- return Ze;
2396
+ function getLayoutCssVars() {
2397
+ if (autoResizeColumn === null)
2398
+ return layoutCssVars;
1904
2399
  const {
1905
- gridTemplateColumns: o
1906
- } = Ze, r = o.split(" ");
1907
- return r[re.idx] = "max-content", {
1908
- ...Ze,
1909
- gridTemplateColumns: r.join(" ")
2400
+ gridTemplateColumns
2401
+ } = layoutCssVars;
2402
+ const newSizes = gridTemplateColumns.split(" ");
2403
+ newSizes[autoResizeColumn.idx] = "max-content";
2404
+ return {
2405
+ ...layoutCssVars,
2406
+ gridTemplateColumns: newSizes.join(" ")
1910
2407
  };
1911
2408
  }
1912
- function No(o) {
1913
- if (!(u.rowIdx !== o || u.mode === "EDIT" || ie || T == null))
1914
- return /* @__PURE__ */ I(Nr, {
1915
- rows: t,
1916
- columns: B,
1917
- selectedPosition: u,
1918
- isCellEditable: We,
1919
- latestDraggedOverRowIdx: Dt,
1920
- onRowsChange: l,
1921
- onFill: T,
1922
- setDragging: so,
1923
- setDraggedOverRowIdx: rt
1924
- });
2409
+ function getDragHandle(rowIdx) {
2410
+ if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === "EDIT" || hasGroups || onFill == null) {
2411
+ return;
2412
+ }
2413
+ return /* @__PURE__ */ jsx(DragHandle, {
2414
+ rows: rawRows,
2415
+ columns,
2416
+ selectedPosition,
2417
+ isCellEditable: isCellEditable2,
2418
+ latestDraggedOverRowIdx,
2419
+ onRowsChange,
2420
+ onFill,
2421
+ setDragging,
2422
+ setDraggedOverRowIdx
2423
+ });
1925
2424
  }
1926
- function Po(o) {
1927
- if (u.rowIdx !== o || u.mode === "SELECT")
2425
+ function getCellEditor(rowIdx) {
2426
+ if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === "SELECT")
1928
2427
  return;
1929
2428
  const {
1930
- idx: r,
1931
- row: R
1932
- } = u, a = B[r], N = Z(a, U, {
2429
+ idx,
2430
+ row: row2
2431
+ } = selectedPosition;
2432
+ const column = columns[idx];
2433
+ const colSpan = getColSpan(column, lastFrozenColumnIndex, {
1933
2434
  type: "ROW",
1934
- row: R
1935
- }), $ = () => {
1936
- be(({
1937
- idx: K,
1938
- rowIdx: P
2435
+ row: row2
2436
+ });
2437
+ const closeEditor = () => {
2438
+ setSelectedPosition(({
2439
+ idx: idx2,
2440
+ rowIdx: rowIdx2
1939
2441
  }) => ({
1940
- idx: K,
1941
- rowIdx: P,
2442
+ idx: idx2,
2443
+ rowIdx: rowIdx2,
1942
2444
  mode: "SELECT"
1943
2445
  }));
1944
- }, L = (K, P) => {
1945
- P ? (Pe(u.rowIdx, K), $()) : be((q) => ({
1946
- ...q,
1947
- row: K
1948
- }));
1949
2446
  };
1950
- return W[u.rowIdx] !== u.originalRow && $(), /* @__PURE__ */ I(Lr, {
1951
- column: a,
1952
- colSpan: N,
1953
- row: R,
1954
- onRowChange: L,
1955
- closeEditor: $
1956
- }, a.key);
1957
- }
1958
- function ct(o) {
1959
- const r = B[u.idx];
1960
- return r !== void 0 && u.rowIdx === o && !xe.includes(r) ? u.idx > At ? [...xe, r] : [...xe.slice(0, U + 1), r, ...xe.slice(U + 1)] : xe;
1961
- }
1962
- function Mo() {
1963
- const o = [];
1964
- let r = 0;
2447
+ const onRowChange = (row3, commitChanges) => {
2448
+ if (commitChanges) {
2449
+ updateRow(selectedPosition.rowIdx, row3);
2450
+ closeEditor();
2451
+ } else {
2452
+ setSelectedPosition((position) => ({
2453
+ ...position,
2454
+ row: row3
2455
+ }));
2456
+ }
2457
+ };
2458
+ if (rows[selectedPosition.rowIdx] !== selectedPosition.originalRow) {
2459
+ closeEditor();
2460
+ }
2461
+ return /* @__PURE__ */ jsx(EditCell, {
2462
+ column,
2463
+ colSpan,
2464
+ row: row2,
2465
+ onRowChange,
2466
+ closeEditor
2467
+ }, column.key);
2468
+ }
2469
+ function getRowViewportColumns(rowIdx) {
2470
+ const selectedColumn = columns[selectedPosition.idx];
2471
+ if (selectedColumn !== void 0 && selectedPosition.rowIdx === rowIdx && !viewportColumns.includes(selectedColumn)) {
2472
+ return selectedPosition.idx > colOverscanEndIdx ? [...viewportColumns, selectedColumn] : [...viewportColumns.slice(0, lastFrozenColumnIndex + 1), selectedColumn, ...viewportColumns.slice(lastFrozenColumnIndex + 1)];
2473
+ }
2474
+ return viewportColumns;
2475
+ }
2476
+ function getViewportRows() {
2477
+ const rowElements = [];
2478
+ let startRowIndex = 0;
1965
2479
  const {
1966
- idx: R,
1967
- rowIdx: a
1968
- } = u, N = Ne && a < ye ? ye - 1 : ye, $ = Ne && a > Re ? Re + 1 : Re;
1969
- for (let L = N; L <= $; L++) {
1970
- const K = L === ye - 1 || L === Re + 1, P = K ? a : L;
1971
- let q = xe;
1972
- const He = B[R];
1973
- He !== void 0 && (K ? q = [He] : q = ct(P));
1974
- const j = W[P], Ke = oe + P + 1;
1975
- if (X(j)) {
2480
+ idx: selectedIdx,
2481
+ rowIdx: selectedRowIdx
2482
+ } = selectedPosition;
2483
+ const startRowIdx = selectedCellIsWithinViewportBounds && selectedRowIdx < rowOverscanStartIdx ? rowOverscanStartIdx - 1 : rowOverscanStartIdx;
2484
+ const endRowIdx = selectedCellIsWithinViewportBounds && selectedRowIdx > rowOverscanEndIdx ? rowOverscanEndIdx + 1 : rowOverscanEndIdx;
2485
+ for (let viewportRowIdx = startRowIdx; viewportRowIdx <= endRowIdx; viewportRowIdx++) {
2486
+ const isRowOutsideViewport = viewportRowIdx === rowOverscanStartIdx - 1 || viewportRowIdx === rowOverscanEndIdx + 1;
2487
+ const rowIdx = isRowOutsideViewport ? selectedRowIdx : viewportRowIdx;
2488
+ let rowColumns = viewportColumns;
2489
+ const selectedColumn = columns[selectedIdx];
2490
+ if (selectedColumn !== void 0) {
2491
+ if (isRowOutsideViewport) {
2492
+ rowColumns = [selectedColumn];
2493
+ } else {
2494
+ rowColumns = getRowViewportColumns(rowIdx);
2495
+ }
2496
+ }
2497
+ const row2 = rows[rowIdx];
2498
+ const gridRowStart = headerRowsCount + rowIdx + 1;
2499
+ if (isGroupRow(row2)) {
1976
2500
  ({
1977
- startRowIndex: r
1978
- } = j);
1979
- const _e = ke && j.childRows.every((Wo) => f.has(i(Wo)));
1980
- o.push(/* @__PURE__ */ I(mr, {
1981
- "aria-level": j.level + 1,
1982
- "aria-setsize": j.setSize,
1983
- "aria-posinset": j.posInSet + 1,
1984
- "aria-rowindex": oe + r + 1,
1985
- "aria-selected": ke ? _e : void 0,
1986
- id: j.id,
1987
- groupKey: j.groupKey,
1988
- viewportColumns: q,
1989
- childRows: j.childRows,
1990
- rowIdx: P,
1991
- row: j,
1992
- gridRowStart: Ke,
1993
- height: ot(P),
1994
- level: j.level,
1995
- isExpanded: j.isExpanded,
1996
- selectedCellIdx: a === P ? R : void 0,
1997
- isRowSelected: _e,
1998
- selectGroup: ko,
1999
- toggleGroup: vo
2000
- }, j.id));
2501
+ startRowIndex
2502
+ } = row2);
2503
+ const isGroupRowSelected = isSelectable && row2.childRows.every((cr) => selectedRows.has(rowKeyGetter(cr)));
2504
+ rowElements.push(/* @__PURE__ */ jsx(GroupRowRenderer, {
2505
+ "aria-level": row2.level + 1,
2506
+ "aria-setsize": row2.setSize,
2507
+ "aria-posinset": row2.posInSet + 1,
2508
+ "aria-rowindex": headerRowsCount + startRowIndex + 1,
2509
+ "aria-selected": isSelectable ? isGroupRowSelected : void 0,
2510
+ id: row2.id,
2511
+ groupKey: row2.groupKey,
2512
+ viewportColumns: rowColumns,
2513
+ childRows: row2.childRows,
2514
+ rowIdx,
2515
+ row: row2,
2516
+ gridRowStart,
2517
+ height: getRowHeight(rowIdx),
2518
+ level: row2.level,
2519
+ isExpanded: row2.isExpanded,
2520
+ selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : void 0,
2521
+ isRowSelected: isGroupRowSelected,
2522
+ selectGroup: selectGroupLatest,
2523
+ toggleGroup: toggleGroupLatest
2524
+ }, row2.id));
2001
2525
  continue;
2002
2526
  }
2003
- r++;
2004
- let me, lt = !1;
2005
- typeof i == "function" ? (me = i(j), lt = f?.has(me) ?? !1) : me = ie ? r : P, o.push(/* @__PURE__ */ I(oo, {
2006
- "aria-rowindex": oe + (ie ? r : P) + 1,
2007
- "aria-selected": ke ? lt : void 0,
2008
- rowIdx: P,
2009
- row: j,
2010
- viewportColumns: q,
2011
- isRowSelected: lt,
2012
- onRowClick: A,
2013
- onRowDoubleClick: _,
2014
- rowClass: m,
2015
- gridRowStart: Ke,
2016
- height: ot(P),
2017
- copiedCellIdx: he !== null && he.row === j ? B.findIndex((_e) => _e.key === he.columnKey) : void 0,
2018
- selectedCellIdx: a === P ? R : void 0,
2019
- draggedOverCellIdx: Oo(P),
2020
- setDraggedOverRowIdx: zt ? rt : void 0,
2021
- lastFrozenColumnIndex: U,
2022
- onRowChange: mo,
2023
- selectCell: Co,
2024
- selectedCellDragHandle: No(P),
2025
- selectedCellEditor: Po(P)
2026
- }, me));
2527
+ startRowIndex++;
2528
+ let key;
2529
+ let isRowSelected = false;
2530
+ if (typeof rowKeyGetter === "function") {
2531
+ key = rowKeyGetter(row2);
2532
+ isRowSelected = selectedRows?.has(key) ?? false;
2533
+ } else {
2534
+ key = hasGroups ? startRowIndex : rowIdx;
2535
+ }
2536
+ rowElements.push(/* @__PURE__ */ jsx(RowRenderer, {
2537
+ "aria-rowindex": headerRowsCount + (hasGroups ? startRowIndex : rowIdx) + 1,
2538
+ "aria-selected": isSelectable ? isRowSelected : void 0,
2539
+ rowIdx,
2540
+ row: row2,
2541
+ viewportColumns: rowColumns,
2542
+ isRowSelected,
2543
+ onRowClick,
2544
+ onRowDoubleClick,
2545
+ rowClass,
2546
+ gridRowStart,
2547
+ height: getRowHeight(rowIdx),
2548
+ copiedCellIdx: copiedCell !== null && copiedCell.row === row2 ? columns.findIndex((c) => c.key === copiedCell.columnKey) : void 0,
2549
+ selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : void 0,
2550
+ draggedOverCellIdx: getDraggedOverCellIdx(rowIdx),
2551
+ setDraggedOverRowIdx: isDragging ? setDraggedOverRowIdx : void 0,
2552
+ lastFrozenColumnIndex,
2553
+ onRowChange: handleFormatterRowChangeLatest,
2554
+ selectCell: selectViewportCellLatest,
2555
+ selectedCellDragHandle: getDragHandle(rowIdx),
2556
+ selectedCellEditor: getCellEditor(rowIdx)
2557
+ }, key));
2027
2558
  }
2028
- return o;
2029
- }
2030
- (u.idx > Te || u.rowIdx > Ie) && (be(Xt), rt(void 0));
2031
- let st = `${ge}px`;
2032
- W.length > 0 && (st += ho), pe > 0 && (st += ` repeat(${pe}, ${te}px)`);
2033
- const Vt = u.idx === -1 && u.rowIdx !== -2;
2034
- return /* @__PURE__ */ ne("div", {
2035
- role: ie ? "treegrid" : "grid",
2036
- "aria-label": V,
2037
- "aria-labelledby": ee,
2038
- "aria-describedby": ue,
2039
- "aria-multiselectable": ke ? !0 : void 0,
2040
- "aria-colcount": B.length,
2041
- "aria-rowcount": oe + Nt + pe,
2042
- className: se(Qo, x, zt && en, re !== null && Go),
2559
+ return rowElements;
2560
+ }
2561
+ if (selectedPosition.idx > maxColIdx || selectedPosition.rowIdx > maxRowIdx) {
2562
+ setSelectedPosition(initialPosition);
2563
+ setDraggedOverRowIdx(void 0);
2564
+ }
2565
+ let templateRows = `${headerRowHeight}px`;
2566
+ if (rows.length > 0) {
2567
+ templateRows += gridTemplateRows;
2568
+ }
2569
+ if (summaryRowsCount > 0) {
2570
+ templateRows += ` repeat(${summaryRowsCount}, ${summaryRowHeight}px)`;
2571
+ }
2572
+ const isGroupRowFocused = selectedPosition.idx === -1 && selectedPosition.rowIdx !== -2;
2573
+ return /* @__PURE__ */ jsxs("div", {
2574
+ role: hasGroups ? "treegrid" : "grid",
2575
+ "aria-label": ariaLabel,
2576
+ "aria-labelledby": ariaLabelledBy,
2577
+ "aria-describedby": ariaDescribedBy,
2578
+ "aria-multiselectable": isSelectable ? true : void 0,
2579
+ "aria-colcount": columns.length,
2580
+ "aria-rowcount": headerRowsCount + rowsCount + summaryRowsCount,
2581
+ className: clsx(rootClassname, className, isDragging && viewportDraggingClassname, autoResizeColumn !== null && cellAutoResizeClassname),
2043
2582
  style: {
2044
- ...D,
2045
- scrollPaddingInlineStart: u.idx > U ? `${et}px` : void 0,
2046
- scrollPaddingBlock: u.rowIdx >= 0 && u.rowIdx < W.length ? `${ge}px ${pe * te}px` : void 0,
2047
- gridTemplateRows: st,
2048
- "--rdg-header-row-height": `${ge}px`,
2049
- "--rdg-summary-row-height": `${te}px`,
2050
- "--rdg-sign": Oe ? -1 : 1,
2051
- ...To()
2583
+ ...style,
2584
+ scrollPaddingInlineStart: selectedPosition.idx > lastFrozenColumnIndex ? `${totalFrozenColumnWidth}px` : void 0,
2585
+ scrollPaddingBlock: selectedPosition.rowIdx >= 0 && selectedPosition.rowIdx < rows.length ? `${headerRowHeight}px ${summaryRowsCount * summaryRowHeight}px` : void 0,
2586
+ gridTemplateRows: templateRows,
2587
+ "--rdg-header-row-height": `${headerRowHeight}px`,
2588
+ "--rdg-summary-row-height": `${summaryRowHeight}px`,
2589
+ "--rdg-sign": isRtl ? -1 : 1,
2590
+ ...getLayoutCssVars()
2052
2591
  },
2053
- dir: F,
2054
- ref: de,
2055
- onScroll: zo,
2056
- onKeyDown: Kt,
2057
- "data-testid": le,
2058
- children: [ie && /* @__PURE__ */ I("div", {
2059
- ref: Le,
2060
- tabIndex: Vt ? 0 : -1,
2061
- className: se(tn, Vt && [rn, U !== -1 && cn]),
2592
+ dir: direction,
2593
+ ref: gridRef,
2594
+ onScroll: handleScroll,
2595
+ onKeyDown: handleKeyDown,
2596
+ "data-testid": testId,
2597
+ children: [hasGroups && /* @__PURE__ */ jsx("div", {
2598
+ ref: rowRef,
2599
+ tabIndex: isGroupRowFocused ? 0 : -1,
2600
+ className: clsx(focusSinkClassname, isGroupRowFocused && [rowSelected, lastFrozenColumnIndex !== -1 && rowSelectedWithFrozenCell]),
2062
2601
  style: {
2063
- gridRowStart: u.rowIdx + 2
2602
+ gridRowStart: selectedPosition.rowIdx + 2
2064
2603
  },
2065
- onKeyDown: Kt
2066
- }), /* @__PURE__ */ ne(xn, {
2067
- value: fo,
2068
- children: [/* @__PURE__ */ I(nr, {
2069
- columns: ct(-1),
2070
- onColumnResize: Io,
2071
- allRowsSelected: go,
2072
- onAllRowsSelectionChange: wo,
2073
- sortColumns: b,
2074
- onSortColumnsChange: w,
2075
- lastFrozenColumnIndex: U,
2076
- selectedCellIdx: uo ? u.idx : void 0,
2077
- selectCell: yo,
2078
- shouldFocusGrid: !nt,
2079
- direction: F
2080
- }), W.length === 0 && vt ? vt : /* @__PURE__ */ ne(ze, {
2081
- children: [/* @__PURE__ */ I(In, {
2082
- value: xo,
2083
- children: Mo()
2084
- }), n?.map((o, r) => {
2085
- const R = oe + W.length + r + 1, a = oe + W.length + r - 1, N = u.rowIdx === a, $ = Ae > Pt ? Ft - te * (n.length - r) : void 0, L = $ === void 0 ? te * (n.length - 1 - r) : void 0;
2086
- return /* @__PURE__ */ I(Dr, {
2087
- "aria-rowindex": oe + Nt + r + 1,
2088
- rowIdx: r,
2089
- gridRowStart: R,
2090
- row: o,
2091
- top: $,
2092
- bottom: L,
2093
- viewportColumns: ct(a),
2094
- lastFrozenColumnIndex: U,
2095
- selectedCellIdx: N ? u.idx : void 0,
2096
- selectCell: Ro
2097
- }, r);
2604
+ onKeyDown: handleKeyDown
2605
+ }), /* @__PURE__ */ jsxs(DataGridDefaultComponentsProvider, {
2606
+ value: defaultGridComponents,
2607
+ children: [/* @__PURE__ */ jsx(HeaderRow$1, {
2608
+ columns: getRowViewportColumns(-1),
2609
+ onColumnResize: handleColumnResize,
2610
+ allRowsSelected,
2611
+ onAllRowsSelectionChange: selectAllRowsLatest,
2612
+ sortColumns,
2613
+ onSortColumnsChange,
2614
+ lastFrozenColumnIndex,
2615
+ selectedCellIdx: isHeaderRowSelected ? selectedPosition.idx : void 0,
2616
+ selectCell: selectHeaderCellLatest,
2617
+ shouldFocusGrid: !selectedCellIsWithinSelectionBounds,
2618
+ direction
2619
+ }), rows.length === 0 && noRowsFallback ? noRowsFallback : /* @__PURE__ */ jsxs(Fragment, {
2620
+ children: [/* @__PURE__ */ jsx(RowSelectionChangeProvider, {
2621
+ value: selectRowLatest,
2622
+ children: getViewportRows()
2623
+ }), summaryRows?.map((row2, rowIdx) => {
2624
+ const gridRowStart = headerRowsCount + rows.length + rowIdx + 1;
2625
+ const summaryRowIdx = headerRowsCount + rows.length + rowIdx - 1;
2626
+ const isSummaryRowSelected = selectedPosition.rowIdx === summaryRowIdx;
2627
+ const top = clientHeight > totalRowHeight ? gridHeight - summaryRowHeight * (summaryRows.length - rowIdx) : void 0;
2628
+ const bottom = top === void 0 ? summaryRowHeight * (summaryRows.length - 1 - rowIdx) : void 0;
2629
+ return /* @__PURE__ */ jsx(SummaryRow$1, {
2630
+ "aria-rowindex": headerRowsCount + rowsCount + rowIdx + 1,
2631
+ rowIdx,
2632
+ gridRowStart,
2633
+ row: row2,
2634
+ top,
2635
+ bottom,
2636
+ viewportColumns: getRowViewportColumns(summaryRowIdx),
2637
+ lastFrozenColumnIndex,
2638
+ selectedCellIdx: isSummaryRowSelected ? selectedPosition.idx : void 0,
2639
+ selectCell: selectSummaryCellLatest
2640
+ }, rowIdx);
2098
2641
  })]
2099
2642
  })]
2100
2643
  })]
2101
2644
  });
2102
2645
  }
2103
- function at(e, t) {
2104
- return e.idx === t.idx && e.rowIdx === t.rowIdx;
2646
+ function isSamePosition(p1, p2) {
2647
+ return p1.idx === p2.idx && p1.rowIdx === p2.rowIdx;
2105
2648
  }
2106
- const Ur = /* @__PURE__ */ pt(Kr);
2107
- var _r = ".t16y9g8l700-beta13{appearance:none;background-color:var(--rdg-background-color);block-size:100%;border:2px solid #ccc;box-sizing:border-box;color:var(--rdg-color);font-family:inherit;font-size:var(--rdg-font-size);inline-size:100%;padding-block:0;padding-inline:6px;vertical-align:top}.t16y9g8l700-beta13:focus{border-color:var(--rdg-selection-color);outline:none}.t16y9g8l700-beta13::placeholder{color:#999;opacity:1}";
2108
- G(_r, { insertAt: "top" });
2649
+ const DataGrid$1 = /* @__PURE__ */ forwardRef(DataGrid);
2650
+ var css_248z = ".t16y9g8l700-beta13{appearance:none;background-color:var(--rdg-background-color);block-size:100%;border:2px solid #ccc;box-sizing:border-box;color:var(--rdg-color);font-family:inherit;font-size:var(--rdg-font-size);inline-size:100%;padding-block:0;padding-inline:6px;vertical-align:top}.t16y9g8l700-beta13:focus{border-color:var(--rdg-selection-color);outline:none}.t16y9g8l700-beta13::placeholder{color:#999;opacity:1}";
2651
+ styleInject(css_248z, { "insertAt": "top" });
2109
2652
  export {
2110
- Ur as D,
2111
- qn as H,
2112
- ft as S,
2113
- Vr as a,
2114
- qr as u
2653
+ DataGrid$1 as D,
2654
+ HeaderRenderer as H,
2655
+ SELECT_COLUMN_KEY as S,
2656
+ SelectCellFormatter as a,
2657
+ useRowSelection as u
2115
2658
  };