@gridkitjs/react 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +154 -63
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -81,6 +81,24 @@ function GroupIcon() {
|
|
|
81
81
|
function FilterIcon() {
|
|
82
82
|
return /* @__PURE__ */ jsx2(Icon, { children: /* @__PURE__ */ jsx2("path", { d: "M22 3H2l8 9.46V19l4 2v-8.54z" }) });
|
|
83
83
|
}
|
|
84
|
+
function ChevronLeftIcon() {
|
|
85
|
+
return /* @__PURE__ */ jsx2(Icon, { children: /* @__PURE__ */ jsx2("path", { d: "m15 18-6-6 6-6" }) });
|
|
86
|
+
}
|
|
87
|
+
function ChevronRightIcon() {
|
|
88
|
+
return /* @__PURE__ */ jsx2(Icon, { children: /* @__PURE__ */ jsx2("path", { d: "m9 18 6-6-6-6" }) });
|
|
89
|
+
}
|
|
90
|
+
function ChevronsLeftIcon() {
|
|
91
|
+
return /* @__PURE__ */ jsxs(Icon, { children: [
|
|
92
|
+
/* @__PURE__ */ jsx2("path", { d: "m11 17-5-5 5-5" }),
|
|
93
|
+
/* @__PURE__ */ jsx2("path", { d: "m18 17-5-5 5-5" })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function ChevronsRightIcon() {
|
|
97
|
+
return /* @__PURE__ */ jsxs(Icon, { children: [
|
|
98
|
+
/* @__PURE__ */ jsx2("path", { d: "m6 17 5-5-5-5" }),
|
|
99
|
+
/* @__PURE__ */ jsx2("path", { d: "m13 17 5-5-5-5" })
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
84
102
|
|
|
85
103
|
// src/DataGrid/isOwnEvent.ts
|
|
86
104
|
function isOwnEvent(event) {
|
|
@@ -119,7 +137,11 @@ function useGridNavigation({
|
|
|
119
137
|
};
|
|
120
138
|
const [gridFocus] = useState(() => createGridFocus(options));
|
|
121
139
|
gridFocus.setOptions(options);
|
|
122
|
-
const focus = useSyncExternalStore(
|
|
140
|
+
const focus = useSyncExternalStore(
|
|
141
|
+
gridFocus.subscribe,
|
|
142
|
+
gridFocus.getFocus,
|
|
143
|
+
gridFocus.getFocus
|
|
144
|
+
);
|
|
123
145
|
const [rows] = useState(() => ({
|
|
124
146
|
getHeaderRow: () => headerTableRef.current?.tHead?.rows[0] ?? null,
|
|
125
147
|
getBodyRow: (rowIndex) => findBodyRow(bodyTableRef.current, rowIndex)
|
|
@@ -221,7 +243,7 @@ function GridHeader({
|
|
|
221
243
|
panels.open("filter", { area: "header", columnId });
|
|
222
244
|
}
|
|
223
245
|
}
|
|
224
|
-
return /* @__PURE__ */ jsxs2("thead", { children: [
|
|
246
|
+
return /* @__PURE__ */ jsxs2("thead", { role: "rowgroup", children: [
|
|
225
247
|
/* @__PURE__ */ jsx3("tr", { className: "grid-header", role: "row", "aria-rowindex": 1, children: columns.map((entry, index) => {
|
|
226
248
|
const { column } = entry;
|
|
227
249
|
const resizing = resize.activeColumnId === entry.id;
|
|
@@ -904,6 +926,7 @@ function GridBody({
|
|
|
904
926
|
return /* @__PURE__ */ jsxs5(
|
|
905
927
|
"tbody",
|
|
906
928
|
{
|
|
929
|
+
role: "rowgroup",
|
|
907
930
|
className: "grid-body",
|
|
908
931
|
onFocus: (event) => {
|
|
909
932
|
const group = groupRowFrom(event.target);
|
|
@@ -1089,7 +1112,7 @@ function GridFooter({
|
|
|
1089
1112
|
rows,
|
|
1090
1113
|
locale
|
|
1091
1114
|
}) {
|
|
1092
|
-
return /* @__PURE__ */ jsx8("tfoot", { children: /* @__PURE__ */ jsx8("tr", { className: "grid-footer", role: "row", children: columns.map((entry) => {
|
|
1115
|
+
return /* @__PURE__ */ jsx8("tfoot", { role: "rowgroup", children: /* @__PURE__ */ jsx8("tr", { className: "grid-footer", role: "row", children: columns.map((entry) => {
|
|
1093
1116
|
const specs = aggregates.filter(
|
|
1094
1117
|
(candidate) => candidate.columnId === entry.id
|
|
1095
1118
|
);
|
|
@@ -1120,10 +1143,35 @@ function GridFooter({
|
|
|
1120
1143
|
// src/DataGrid/components/GridPager.tsx
|
|
1121
1144
|
import { paginationWindow } from "@gridkitjs/core";
|
|
1122
1145
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1146
|
+
function PagerNavButton({
|
|
1147
|
+
className,
|
|
1148
|
+
label,
|
|
1149
|
+
disabled,
|
|
1150
|
+
onClick,
|
|
1151
|
+
children
|
|
1152
|
+
}) {
|
|
1153
|
+
return /* @__PURE__ */ jsx9(
|
|
1154
|
+
"button",
|
|
1155
|
+
{
|
|
1156
|
+
type: "button",
|
|
1157
|
+
className: `grid-pager-button grid-pager-nav ${className}`,
|
|
1158
|
+
"aria-label": label,
|
|
1159
|
+
title: label,
|
|
1160
|
+
disabled,
|
|
1161
|
+
onClick,
|
|
1162
|
+
children
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1123
1166
|
function GridPager({ pager, config, messages }) {
|
|
1124
1167
|
const { pagination, pageCount, currentPage } = pager;
|
|
1125
1168
|
const variant = config?.variant ?? "compact";
|
|
1126
1169
|
const sizeOptions = config?.sizeOptions;
|
|
1170
|
+
const atFirst = pagination.pageIndex <= 0;
|
|
1171
|
+
const atLast = pagination.pageIndex >= pageCount - 1;
|
|
1172
|
+
const barStyle = {
|
|
1173
|
+
"--gridkit-pager-digits": String(String(Math.max(1, pageCount)).length)
|
|
1174
|
+
};
|
|
1127
1175
|
return /* @__PURE__ */ jsxs6(
|
|
1128
1176
|
"div",
|
|
1129
1177
|
{
|
|
@@ -1131,59 +1179,90 @@ function GridPager({ pager, config, messages }) {
|
|
|
1131
1179
|
role: "group",
|
|
1132
1180
|
"aria-label": messages.pagerLabel,
|
|
1133
1181
|
children: [
|
|
1134
|
-
/* @__PURE__ */
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
type: "button",
|
|
1138
|
-
className: "grid-pager-button",
|
|
1139
|
-
disabled: pagination.pageIndex <= 0,
|
|
1140
|
-
onClick: () => {
|
|
1141
|
-
pager.previousPage();
|
|
1142
|
-
},
|
|
1143
|
-
children: messages.previousPage
|
|
1144
|
-
}
|
|
1145
|
-
),
|
|
1146
|
-
variant === "numbered" ? paginationWindow(currentPage, pageCount, {
|
|
1147
|
-
boundaryCount: config?.boundaryCount,
|
|
1148
|
-
siblingCount: config?.siblingCount
|
|
1149
|
-
}).map(
|
|
1150
|
-
(entry, index) => entry === "ellipsis" ? /* @__PURE__ */ jsx9(
|
|
1151
|
-
"span",
|
|
1182
|
+
/* @__PURE__ */ jsxs6("div", { className: "grid-pager-bar", style: barStyle, children: [
|
|
1183
|
+
/* @__PURE__ */ jsx9(
|
|
1184
|
+
PagerNavButton,
|
|
1152
1185
|
{
|
|
1153
|
-
className: "grid-pager-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1186
|
+
className: "grid-pager-first",
|
|
1187
|
+
label: messages.firstPage,
|
|
1188
|
+
disabled: atFirst,
|
|
1189
|
+
onClick: () => {
|
|
1190
|
+
pager.goToPage(0);
|
|
1191
|
+
},
|
|
1192
|
+
children: /* @__PURE__ */ jsx9(ChevronsLeftIcon, {})
|
|
1193
|
+
}
|
|
1194
|
+
),
|
|
1195
|
+
/* @__PURE__ */ jsx9(
|
|
1196
|
+
PagerNavButton,
|
|
1160
1197
|
{
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
"aria-current": entry === currentPage ? "page" : void 0,
|
|
1198
|
+
className: "grid-pager-previous",
|
|
1199
|
+
label: messages.previousPage,
|
|
1200
|
+
disabled: atFirst,
|
|
1165
1201
|
onClick: () => {
|
|
1166
|
-
pager.
|
|
1202
|
+
pager.previousPage();
|
|
1167
1203
|
},
|
|
1168
|
-
children:
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1204
|
+
children: /* @__PURE__ */ jsx9(ChevronLeftIcon, {})
|
|
1205
|
+
}
|
|
1206
|
+
),
|
|
1207
|
+
variant === "numbered" ? paginationWindow(currentPage, pageCount, {
|
|
1208
|
+
boundaryCount: config?.boundaryCount,
|
|
1209
|
+
siblingCount: config?.siblingCount
|
|
1210
|
+
}).map(
|
|
1211
|
+
(entry, index) => entry === "ellipsis" ? /* @__PURE__ */ jsx9(
|
|
1212
|
+
"span",
|
|
1213
|
+
{
|
|
1214
|
+
className: "grid-pager-ellipsis",
|
|
1215
|
+
"aria-hidden": "true",
|
|
1216
|
+
children: "\u2026"
|
|
1217
|
+
},
|
|
1218
|
+
`ellipsis-${String(index)}`
|
|
1219
|
+
) : /* @__PURE__ */ jsx9(
|
|
1220
|
+
"button",
|
|
1221
|
+
{
|
|
1222
|
+
type: "button",
|
|
1223
|
+
className: "grid-pager-button grid-pager-page",
|
|
1224
|
+
"aria-label": messages.pageButtonLabel(entry),
|
|
1225
|
+
"aria-current": entry === currentPage ? "page" : void 0,
|
|
1226
|
+
onClick: () => {
|
|
1227
|
+
pager.goToPage(entry - 1);
|
|
1228
|
+
},
|
|
1229
|
+
children: entry
|
|
1230
|
+
},
|
|
1231
|
+
entry
|
|
1232
|
+
)
|
|
1233
|
+
) : /* @__PURE__ */ jsxs6("span", { className: "grid-pager-status-slot", children: [
|
|
1234
|
+
/* @__PURE__ */ jsx9("span", { className: "grid-pager-status", children: messages.pageStatus(
|
|
1235
|
+
pageCount === 0 ? 0 : currentPage,
|
|
1236
|
+
pageCount
|
|
1237
|
+
) }),
|
|
1238
|
+
/* @__PURE__ */ jsx9("span", { className: "grid-pager-status-sizer", "aria-hidden": "true", children: messages.pageStatus(pageCount, pageCount) })
|
|
1239
|
+
] }),
|
|
1240
|
+
/* @__PURE__ */ jsx9(
|
|
1241
|
+
PagerNavButton,
|
|
1242
|
+
{
|
|
1243
|
+
className: "grid-pager-next",
|
|
1244
|
+
label: messages.nextPage,
|
|
1245
|
+
disabled: atLast,
|
|
1246
|
+
onClick: () => {
|
|
1247
|
+
pager.nextPage();
|
|
1248
|
+
},
|
|
1249
|
+
children: /* @__PURE__ */ jsx9(ChevronRightIcon, {})
|
|
1250
|
+
}
|
|
1251
|
+
),
|
|
1252
|
+
/* @__PURE__ */ jsx9(
|
|
1253
|
+
PagerNavButton,
|
|
1254
|
+
{
|
|
1255
|
+
className: "grid-pager-last",
|
|
1256
|
+
label: messages.lastPage,
|
|
1257
|
+
disabled: atLast,
|
|
1258
|
+
onClick: () => {
|
|
1259
|
+
pager.goToPage(pageCount - 1);
|
|
1260
|
+
},
|
|
1261
|
+
children: /* @__PURE__ */ jsx9(ChevronsRightIcon, {})
|
|
1262
|
+
}
|
|
1171
1263
|
)
|
|
1172
|
-
|
|
1173
|
-
/* @__PURE__ */ jsx9(
|
|
1174
|
-
"button",
|
|
1175
|
-
{
|
|
1176
|
-
type: "button",
|
|
1177
|
-
className: "grid-pager-button",
|
|
1178
|
-
disabled: pagination.pageIndex >= pageCount - 1,
|
|
1179
|
-
onClick: () => {
|
|
1180
|
-
pager.nextPage();
|
|
1181
|
-
},
|
|
1182
|
-
children: messages.nextPage
|
|
1183
|
-
}
|
|
1184
|
-
),
|
|
1264
|
+
] }),
|
|
1185
1265
|
sizeOptions !== void 0 && sizeOptions.length > 0 && /* @__PURE__ */ jsxs6("label", { className: "grid-pager-page-size", children: [
|
|
1186
|
-
messages.pageSizeLabel,
|
|
1187
1266
|
/* @__PURE__ */ jsx9(
|
|
1188
1267
|
"select",
|
|
1189
1268
|
{
|
|
@@ -1193,7 +1272,8 @@ function GridPager({ pager, config, messages }) {
|
|
|
1193
1272
|
},
|
|
1194
1273
|
children: sizeOptions.map((size) => /* @__PURE__ */ jsx9("option", { value: size, children: size }, size))
|
|
1195
1274
|
}
|
|
1196
|
-
)
|
|
1275
|
+
),
|
|
1276
|
+
/* @__PURE__ */ jsx9("span", { className: "grid-pager-page-size-label", children: messages.pageSizeLabel })
|
|
1197
1277
|
] })
|
|
1198
1278
|
]
|
|
1199
1279
|
}
|
|
@@ -1891,10 +1971,10 @@ function CheckIcon() {
|
|
|
1891
1971
|
function ChevronDownIcon() {
|
|
1892
1972
|
return /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsx12("path", { d: "m6 9 6 6 6-6" }) });
|
|
1893
1973
|
}
|
|
1894
|
-
function
|
|
1974
|
+
function ChevronLeftIcon2() {
|
|
1895
1975
|
return /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsx12("path", { d: "m15 18-6-6 6-6" }) });
|
|
1896
1976
|
}
|
|
1897
|
-
function
|
|
1977
|
+
function ChevronRightIcon2() {
|
|
1898
1978
|
return /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsx12("path", { d: "m9 18 6-6-6-6" }) });
|
|
1899
1979
|
}
|
|
1900
1980
|
|
|
@@ -1931,7 +2011,7 @@ function MenuItem({
|
|
|
1931
2011
|
/* @__PURE__ */ jsx13("span", { className: "menu-item-icon", "aria-hidden": "true", children: checked === true ? /* @__PURE__ */ jsx13(CheckIcon, {}) : /* @__PURE__ */ jsx13(MenuIcon, { name: entry.icon }) }),
|
|
1932
2012
|
/* @__PURE__ */ jsx13("span", { className: "menu-item-label", children: entry.label }),
|
|
1933
2013
|
shortcut !== void 0 && /* @__PURE__ */ jsx13("span", { className: "menu-item-shortcut", "aria-hidden": "true", children: shortcut }),
|
|
1934
|
-
!isItem2 && /* @__PURE__ */ jsx13("span", { className: "menu-submenu-indicator", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
|
|
2014
|
+
!isItem2 && /* @__PURE__ */ jsx13("span", { className: "menu-submenu-indicator", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(ChevronRightIcon2, {}) })
|
|
1935
2015
|
]
|
|
1936
2016
|
}
|
|
1937
2017
|
);
|
|
@@ -2571,7 +2651,7 @@ function OperatorMenuButton({
|
|
|
2571
2651
|
children: [
|
|
2572
2652
|
/* @__PURE__ */ jsx16("span", { className: "filter-menu-submenu-icon", "aria-hidden": "true", children: active !== void 0 && /* @__PURE__ */ jsx16(CheckIcon, {}) }),
|
|
2573
2653
|
label,
|
|
2574
|
-
/* @__PURE__ */ jsx16("span", { className: "filter-menu-submenu-indicator", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
|
|
2654
|
+
/* @__PURE__ */ jsx16("span", { className: "filter-menu-submenu-indicator", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(ChevronRightIcon2, {}) })
|
|
2575
2655
|
]
|
|
2576
2656
|
}
|
|
2577
2657
|
),
|
|
@@ -3078,7 +3158,7 @@ function ExcelFilterEditor({
|
|
|
3078
3158
|
switchTo(null);
|
|
3079
3159
|
},
|
|
3080
3160
|
children: [
|
|
3081
|
-
/* @__PURE__ */ jsx20("span", { className: "filter-menu-back-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx20(
|
|
3161
|
+
/* @__PURE__ */ jsx20("span", { className: "filter-menu-back-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx20(ChevronLeftIcon2, {}) }),
|
|
3082
3162
|
messages.filterBackToValues
|
|
3083
3163
|
]
|
|
3084
3164
|
}
|
|
@@ -4043,7 +4123,11 @@ function useGridController(options) {
|
|
|
4043
4123
|
() => createGridController(options)
|
|
4044
4124
|
);
|
|
4045
4125
|
controller.setOptions(options);
|
|
4046
|
-
const state = useSyncExternalStore2(
|
|
4126
|
+
const state = useSyncExternalStore2(
|
|
4127
|
+
controller.subscribe,
|
|
4128
|
+
controller.getState,
|
|
4129
|
+
controller.getState
|
|
4130
|
+
);
|
|
4047
4131
|
return { controller, state, view: controller.getView() };
|
|
4048
4132
|
}
|
|
4049
4133
|
|
|
@@ -4224,8 +4308,8 @@ function DataGrid(props) {
|
|
|
4224
4308
|
const gridId = useId2();
|
|
4225
4309
|
const announce = useLiveAnnouncer(viewportRef);
|
|
4226
4310
|
const messages = useMemo5(
|
|
4227
|
-
() => resolveMessages(messageOverrides),
|
|
4228
|
-
[messageOverrides]
|
|
4311
|
+
() => resolveMessages(messageOverrides, locale),
|
|
4312
|
+
[messageOverrides, locale]
|
|
4229
4313
|
);
|
|
4230
4314
|
const { controller, state, view } = useGridController({
|
|
4231
4315
|
...props,
|
|
@@ -4564,6 +4648,7 @@ function DataGrid(props) {
|
|
|
4564
4648
|
"table",
|
|
4565
4649
|
{
|
|
4566
4650
|
ref: headerTableRef,
|
|
4651
|
+
role: "presentation",
|
|
4567
4652
|
style: { width: totalColumnWidth(view.columns) },
|
|
4568
4653
|
className: classNames(gridTableClassName, "gridkit-data-grid-header"),
|
|
4569
4654
|
children: [
|
|
@@ -4601,6 +4686,7 @@ function DataGrid(props) {
|
|
|
4601
4686
|
"table",
|
|
4602
4687
|
{
|
|
4603
4688
|
ref: bodyTableRef,
|
|
4689
|
+
role: "presentation",
|
|
4604
4690
|
style: { width: totalColumnWidth(view.columns) },
|
|
4605
4691
|
className: gridTableClassName,
|
|
4606
4692
|
children: [
|
|
@@ -4637,6 +4723,7 @@ function DataGrid(props) {
|
|
|
4637
4723
|
aggregates.length > 0 && /* @__PURE__ */ jsxs19(
|
|
4638
4724
|
"table",
|
|
4639
4725
|
{
|
|
4726
|
+
role: "presentation",
|
|
4640
4727
|
style: { width: totalColumnWidth(view.columns) },
|
|
4641
4728
|
className: classNames(
|
|
4642
4729
|
gridTableClassName,
|
|
@@ -4694,10 +4781,14 @@ function useGridSnapshot(gridRef, getSnapshot, fallback) {
|
|
|
4694
4781
|
},
|
|
4695
4782
|
[gridRef]
|
|
4696
4783
|
);
|
|
4697
|
-
return useSyncExternalStore3(
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4784
|
+
return useSyncExternalStore3(
|
|
4785
|
+
subscribe,
|
|
4786
|
+
() => {
|
|
4787
|
+
const api = gridRef.current;
|
|
4788
|
+
return api === null ? fallback : getSnapshot(api);
|
|
4789
|
+
},
|
|
4790
|
+
() => fallback
|
|
4791
|
+
);
|
|
4701
4792
|
}
|
|
4702
4793
|
|
|
4703
4794
|
// src/DataGrid/hooks/usePaginationState.ts
|