@gridkitjs/react 0.0.0-dev-20261108231045 → 0.0.0-dev-20261108231420
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 +219 -126
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useId as useId2,
|
|
7
7
|
useImperativeHandle as useImperativeHandle3,
|
|
8
8
|
useMemo as useMemo5,
|
|
9
|
-
useRef as
|
|
9
|
+
useRef as useRef21,
|
|
10
10
|
useState as useState18
|
|
11
11
|
} from "react";
|
|
12
12
|
import {
|
|
@@ -2544,7 +2544,7 @@ function useGridOverlay({
|
|
|
2544
2544
|
}
|
|
2545
2545
|
|
|
2546
2546
|
// src/DataGrid/panels/GridPanels.tsx
|
|
2547
|
-
import { useRef as
|
|
2547
|
+
import { useRef as useRef14 } from "react";
|
|
2548
2548
|
|
|
2549
2549
|
// src/DataGrid/columnChooser/ColumnChooser.tsx
|
|
2550
2550
|
import { useLayoutEffect as useLayoutEffect6, useRef as useRef8, useState as useState6 } from "react";
|
|
@@ -2644,19 +2644,45 @@ import {
|
|
|
2644
2644
|
useImperativeHandle as useImperativeHandle2,
|
|
2645
2645
|
useLayoutEffect as useLayoutEffect10,
|
|
2646
2646
|
useMemo as useMemo4,
|
|
2647
|
-
useReducer,
|
|
2647
|
+
useReducer as useReducer2,
|
|
2648
2648
|
useRef as useRef12,
|
|
2649
|
-
useState as
|
|
2649
|
+
useState as useState9
|
|
2650
2650
|
} from "react";
|
|
2651
2651
|
import {
|
|
2652
|
-
describeColumnFilter as describeColumnFilter2,
|
|
2653
2652
|
draftToFilter as draftToFilter2,
|
|
2654
2653
|
filterChecklist,
|
|
2655
|
-
|
|
2656
|
-
initialFilterEditorDraft as initialFilterEditorDraft2,
|
|
2654
|
+
filterDraftChanged as filterDraftChanged3,
|
|
2657
2655
|
selectAllState
|
|
2658
2656
|
} from "@gridkitjs/core";
|
|
2659
2657
|
|
|
2658
|
+
// src/DataGrid/filterMenu/excelEditorState.ts
|
|
2659
|
+
import {
|
|
2660
|
+
describeColumnFilter,
|
|
2661
|
+
filterDraftChanged,
|
|
2662
|
+
filterEditorReducer,
|
|
2663
|
+
initialFilterEditorDraft
|
|
2664
|
+
} from "@gridkitjs/core";
|
|
2665
|
+
function openValues(filter, columnId, values) {
|
|
2666
|
+
const shape = describeColumnFilter(filter, columnId);
|
|
2667
|
+
return {
|
|
2668
|
+
over: filter,
|
|
2669
|
+
shape,
|
|
2670
|
+
draft: initialFilterEditorDraft(shape, values)
|
|
2671
|
+
};
|
|
2672
|
+
}
|
|
2673
|
+
function initialExcelEditorState(opened) {
|
|
2674
|
+
return { opened, draft: opened.draft };
|
|
2675
|
+
}
|
|
2676
|
+
function showsAlike(a, b) {
|
|
2677
|
+
return a.shape.kind === b.shape.kind && a.draft.options === b.draft.options && !filterDraftChanged(a.draft, b.draft);
|
|
2678
|
+
}
|
|
2679
|
+
function excelEditorReducer(state, action) {
|
|
2680
|
+
if (action.type === "filterChanged") {
|
|
2681
|
+
return showsAlike(state.opened, action.opened) ? { ...state, opened: action.opened } : initialExcelEditorState(action.opened);
|
|
2682
|
+
}
|
|
2683
|
+
return { ...state, draft: filterEditorReducer(state.draft, action) };
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2660
2686
|
// src/DataGrid/menu/useMenuButton.ts
|
|
2661
2687
|
import {
|
|
2662
2688
|
useLayoutEffect as useLayoutEffect7,
|
|
@@ -2789,16 +2815,14 @@ import {
|
|
|
2789
2815
|
useId,
|
|
2790
2816
|
useImperativeHandle,
|
|
2791
2817
|
useLayoutEffect as useLayoutEffect8,
|
|
2792
|
-
|
|
2793
|
-
|
|
2818
|
+
useReducer,
|
|
2819
|
+
useRef as useRef10
|
|
2794
2820
|
} from "react";
|
|
2795
2821
|
import {
|
|
2796
|
-
|
|
2797
|
-
conditionsFromRows,
|
|
2798
|
-
describeColumnFilter,
|
|
2822
|
+
conditionsFromRows as conditionsFromRows2,
|
|
2799
2823
|
draftToFilter,
|
|
2800
|
-
|
|
2801
|
-
|
|
2824
|
+
filterDraftChanged as filterDraftChanged2,
|
|
2825
|
+
filterEditorReducer as filterEditorReducer3
|
|
2802
2826
|
} from "@gridkitjs/core";
|
|
2803
2827
|
|
|
2804
2828
|
// src/DataGrid/filterMenu/ConditionRow.tsx
|
|
@@ -2919,9 +2943,14 @@ function ConditionRow({
|
|
|
2919
2943
|
);
|
|
2920
2944
|
}
|
|
2921
2945
|
|
|
2922
|
-
// src/DataGrid/filterMenu/
|
|
2923
|
-
import {
|
|
2924
|
-
|
|
2946
|
+
// src/DataGrid/filterMenu/simpleEditorState.ts
|
|
2947
|
+
import {
|
|
2948
|
+
conditionRowsFrom,
|
|
2949
|
+
conditionsFromRows,
|
|
2950
|
+
describeColumnFilter as describeColumnFilter2,
|
|
2951
|
+
filterEditorReducer as filterEditorReducer2,
|
|
2952
|
+
initialFilterEditorDraft as initialFilterEditorDraft2
|
|
2953
|
+
} from "@gridkitjs/core";
|
|
2925
2954
|
var NO_ROWS = [];
|
|
2926
2955
|
var NO_VALUES = {
|
|
2927
2956
|
options: [],
|
|
@@ -2929,6 +2958,77 @@ var NO_VALUES = {
|
|
|
2929
2958
|
truncated: false,
|
|
2930
2959
|
blanks: 0
|
|
2931
2960
|
};
|
|
2961
|
+
function filterDraftShown(shape, rows, columnId, type) {
|
|
2962
|
+
const draft = initialFilterEditorDraft2(shape, {
|
|
2963
|
+
...NO_VALUES,
|
|
2964
|
+
columnType: type
|
|
2965
|
+
});
|
|
2966
|
+
if (shape.kind !== "conditions") {
|
|
2967
|
+
return draft;
|
|
2968
|
+
}
|
|
2969
|
+
const shown = conditionsFromRows(rows, columnId, type);
|
|
2970
|
+
return shown.invalid.length > 0 ? draft : filterEditorReducer2(draft, {
|
|
2971
|
+
type: "setConditions",
|
|
2972
|
+
conditions: shown.conditions
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
function openConditions(filter, columnId, operators, type, operator) {
|
|
2976
|
+
const shape = describeColumnFilter2(filter, columnId);
|
|
2977
|
+
const rows = conditionRowsFrom(shape, operators, type);
|
|
2978
|
+
return {
|
|
2979
|
+
over: filter,
|
|
2980
|
+
custom: shape.kind === "custom" || shape.kind === "values" && operator === void 0,
|
|
2981
|
+
draft: {
|
|
2982
|
+
// Its typed values kept, as picking the operator in the row keeps them.
|
|
2983
|
+
rows: operator === void 0 ? rows : rows.map(
|
|
2984
|
+
(row, index) => index === 0 ? { ...row, operator } : row
|
|
2985
|
+
),
|
|
2986
|
+
combinator: shape.kind === "conditions" ? shape.combinator : "and"
|
|
2987
|
+
},
|
|
2988
|
+
filterDraft: filterDraftShown(shape, rows, columnId, type)
|
|
2989
|
+
};
|
|
2990
|
+
}
|
|
2991
|
+
function initialSimpleEditorState(opened) {
|
|
2992
|
+
return { opened, draft: opened.draft, invalid: NO_ROWS };
|
|
2993
|
+
}
|
|
2994
|
+
function sameConditionsDraft(a, b) {
|
|
2995
|
+
return a.combinator === b.combinator && a.rows.length === b.rows.length && a.rows.every((row, index) => {
|
|
2996
|
+
const other = b.rows[index];
|
|
2997
|
+
return other !== void 0 && row.operator === other.operator && row.text === other.text && row.textTo === other.textTo;
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
function showsAlike2(a, b) {
|
|
3001
|
+
return a.custom === b.custom && sameConditionsDraft(a.draft, b.draft);
|
|
3002
|
+
}
|
|
3003
|
+
function simpleEditorReducer(state, action) {
|
|
3004
|
+
switch (action.type) {
|
|
3005
|
+
case "editRow":
|
|
3006
|
+
return {
|
|
3007
|
+
...state,
|
|
3008
|
+
draft: {
|
|
3009
|
+
...state.draft,
|
|
3010
|
+
rows: state.draft.rows.map(
|
|
3011
|
+
(row, index) => index === action.index ? action.row : row
|
|
3012
|
+
)
|
|
3013
|
+
},
|
|
3014
|
+
invalid: NO_ROWS
|
|
3015
|
+
};
|
|
3016
|
+
case "setCombinator":
|
|
3017
|
+
return {
|
|
3018
|
+
...state,
|
|
3019
|
+
draft: { ...state.draft, combinator: action.combinator },
|
|
3020
|
+
invalid: NO_ROWS
|
|
3021
|
+
};
|
|
3022
|
+
case "markInvalid":
|
|
3023
|
+
return { ...state, invalid: action.rows };
|
|
3024
|
+
case "filterChanged":
|
|
3025
|
+
return showsAlike2(state.opened, action.opened) ? { ...state, opened: action.opened } : initialSimpleEditorState(action.opened);
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3029
|
+
// src/DataGrid/filterMenu/SimpleFilterEditor.tsx
|
|
3030
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3031
|
+
var COMBINATORS = ["and", "or"];
|
|
2932
3032
|
function holdsUnreadable(row) {
|
|
2933
3033
|
return Array.from(row?.querySelectorAll("input") ?? []).some(
|
|
2934
3034
|
(input) => input.validity.badInput
|
|
@@ -2974,42 +3074,34 @@ function SimpleFilterEditor({
|
|
|
2974
3074
|
ref
|
|
2975
3075
|
}) {
|
|
2976
3076
|
const type = column.column.type;
|
|
2977
|
-
const
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
return {
|
|
2988
|
-
custom: shape.kind === "custom" || shape.kind === "values" && operator === void 0,
|
|
2989
|
-
draft: draft2
|
|
2990
|
-
};
|
|
2991
|
-
});
|
|
2992
|
-
const [draft, setDraft] = useState8(opened.draft);
|
|
2993
|
-
const [invalid, setInvalid] = useState8(NO_ROWS);
|
|
3077
|
+
const filter = controller.getState().filter;
|
|
3078
|
+
const open = (over) => openConditions(over, column.id, menu.operators, type, operator);
|
|
3079
|
+
const [{ opened, draft, invalid }, dispatch] = useReducer(
|
|
3080
|
+
simpleEditorReducer,
|
|
3081
|
+
filter,
|
|
3082
|
+
(over) => initialSimpleEditorState(open(over))
|
|
3083
|
+
);
|
|
3084
|
+
if (filter !== opened.over) {
|
|
3085
|
+
dispatch({ type: "filterChanged", opened: open(filter) });
|
|
3086
|
+
}
|
|
2994
3087
|
const rowElements = useRef10([]);
|
|
2995
3088
|
const invalidMessageId = useId();
|
|
2996
3089
|
const combinatorName = useId();
|
|
2997
|
-
function update(next) {
|
|
2998
|
-
setDraft(next);
|
|
2999
|
-
setInvalid(NO_ROWS);
|
|
3000
|
-
}
|
|
3001
3090
|
function applyConditions(conditions) {
|
|
3002
|
-
const applied =
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3091
|
+
const applied = filterEditorReducer3(opened.filterDraft, {
|
|
3092
|
+
type: "setConditions",
|
|
3093
|
+
conditions,
|
|
3094
|
+
combinator: draft.combinator
|
|
3095
|
+
});
|
|
3096
|
+
if (filterDraftChanged2(opened.filterDraft, applied)) {
|
|
3097
|
+
applyFilter(
|
|
3098
|
+
draftToFilter(applied, column.id, controller.getState().filter)
|
|
3099
|
+
);
|
|
3100
|
+
}
|
|
3009
3101
|
}
|
|
3010
3102
|
useImperativeHandle(ref, () => ({
|
|
3011
3103
|
apply: () => {
|
|
3012
|
-
const parsed =
|
|
3104
|
+
const parsed = conditionsFromRows2(draft.rows, column.id, type);
|
|
3013
3105
|
const unreadable = draft.rows.map(
|
|
3014
3106
|
(_, index) => holdsUnreadable(rowElements.current[index])
|
|
3015
3107
|
);
|
|
@@ -3020,10 +3112,10 @@ function SimpleFilterEditor({
|
|
|
3020
3112
|
applyConditions(parsed.conditions);
|
|
3021
3113
|
return true;
|
|
3022
3114
|
}
|
|
3023
|
-
if (draft
|
|
3115
|
+
if (sameConditionsDraft(draft, opened.draft) && !unreadable.includes(true)) {
|
|
3024
3116
|
return true;
|
|
3025
3117
|
}
|
|
3026
|
-
|
|
3118
|
+
dispatch({ type: "markInvalid", rows: marked });
|
|
3027
3119
|
return false;
|
|
3028
3120
|
}
|
|
3029
3121
|
}));
|
|
@@ -3045,7 +3137,7 @@ function SimpleFilterEditor({
|
|
|
3045
3137
|
combinator: draft.combinator,
|
|
3046
3138
|
messages,
|
|
3047
3139
|
onChange: (combinator) => {
|
|
3048
|
-
|
|
3140
|
+
dispatch({ type: "setCombinator", combinator });
|
|
3049
3141
|
}
|
|
3050
3142
|
}
|
|
3051
3143
|
),
|
|
@@ -3063,12 +3155,7 @@ function SimpleFilterEditor({
|
|
|
3063
3155
|
invalidMessageId: invalid.includes(index) ? invalidMessageId : void 0,
|
|
3064
3156
|
focusRef: index === 0 ? initialFocusRef : void 0,
|
|
3065
3157
|
onChange: (next) => {
|
|
3066
|
-
|
|
3067
|
-
...draft,
|
|
3068
|
-
rows: draft.rows.map(
|
|
3069
|
-
(current, at) => at === index ? next : current
|
|
3070
|
-
)
|
|
3071
|
-
});
|
|
3158
|
+
dispatch({ type: "editRow", index, row: next });
|
|
3072
3159
|
}
|
|
3073
3160
|
}
|
|
3074
3161
|
)
|
|
@@ -3079,7 +3166,7 @@ function SimpleFilterEditor({
|
|
|
3079
3166
|
}
|
|
3080
3167
|
|
|
3081
3168
|
// src/DataGrid/filterMenu/ValueChecklist.tsx
|
|
3082
|
-
import { useLayoutEffect as useLayoutEffect9, useRef as useRef11, useState as
|
|
3169
|
+
import { useLayoutEffect as useLayoutEffect9, useRef as useRef11, useState as useState8 } from "react";
|
|
3083
3170
|
import {
|
|
3084
3171
|
attachChecklist,
|
|
3085
3172
|
createRowVirtualizer
|
|
@@ -3101,8 +3188,8 @@ function ValueChecklist({
|
|
|
3101
3188
|
}) {
|
|
3102
3189
|
const listRef = useRef11(null);
|
|
3103
3190
|
const checklistRef = useRef11(null);
|
|
3104
|
-
const [virtualizer, setVirtualizer] =
|
|
3105
|
-
const [range, setRange] =
|
|
3191
|
+
const [virtualizer, setVirtualizer] = useState8(null);
|
|
3192
|
+
const [range, setRange] = useState8(NO_RANGE);
|
|
3106
3193
|
const latest = useRef11({ items, onToggle });
|
|
3107
3194
|
useLayoutEffect9(() => {
|
|
3108
3195
|
latest.current = { items, onToggle };
|
|
@@ -3184,6 +3271,10 @@ function ValueChecklist({
|
|
|
3184
3271
|
|
|
3185
3272
|
// src/DataGrid/filterMenu/ExcelFilterEditor.tsx
|
|
3186
3273
|
import { Fragment as Fragment7, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3274
|
+
var OPENED_ON_VALUES = {
|
|
3275
|
+
kind: "values",
|
|
3276
|
+
focusOnMount: false
|
|
3277
|
+
};
|
|
3187
3278
|
function toggleOf(item) {
|
|
3188
3279
|
return item.kind === "blanks" ? { type: "setIncludeBlanks", includeBlanks: !item.checked } : { type: "toggleValue", value: item.value };
|
|
3189
3280
|
}
|
|
@@ -3197,19 +3288,20 @@ function ExcelFilterEditor({
|
|
|
3197
3288
|
columnValues,
|
|
3198
3289
|
ref
|
|
3199
3290
|
}) {
|
|
3200
|
-
const
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3291
|
+
const filter = controller.getState().filter;
|
|
3292
|
+
const open = (over) => openValues(over, column.id, columnValues(column.id));
|
|
3293
|
+
const [{ opened, draft }, dispatch] = useReducer2(
|
|
3294
|
+
excelEditorReducer,
|
|
3295
|
+
filter,
|
|
3296
|
+
(over) => initialExcelEditorState(open(over))
|
|
3297
|
+
);
|
|
3298
|
+
if (filter !== opened.over) {
|
|
3299
|
+
dispatch({ type: "filterChanged", opened: open(filter) });
|
|
3300
|
+
}
|
|
3301
|
+
const [mode, setMode] = useState9(OPENED_ON_VALUES);
|
|
3209
3302
|
const conditions = useRef12(null);
|
|
3210
3303
|
const conditionsFocus = useRef12(null);
|
|
3211
3304
|
const operatorButton = useRef12(null);
|
|
3212
|
-
const switched = useRef12(false);
|
|
3213
3305
|
const selectAllRef = useRef12(null);
|
|
3214
3306
|
const selectAll = useMemo4(() => selectAllState(draft), [draft]);
|
|
3215
3307
|
const checklist = useMemo4(
|
|
@@ -3225,22 +3317,18 @@ function ExcelFilterEditor({
|
|
|
3225
3317
|
}
|
|
3226
3318
|
});
|
|
3227
3319
|
useLayoutEffect10(() => {
|
|
3228
|
-
if (
|
|
3229
|
-
|
|
3230
|
-
|
|
3320
|
+
if (mode.kind === "condition") {
|
|
3321
|
+
conditionsFocus.current?.focus();
|
|
3322
|
+
} else if (mode.focusOnMount) {
|
|
3323
|
+
operatorButton.current?.focus();
|
|
3231
3324
|
}
|
|
3232
|
-
}, [
|
|
3233
|
-
function switchTo(chosen) {
|
|
3234
|
-
switched.current = true;
|
|
3235
|
-
setOperator(chosen);
|
|
3236
|
-
}
|
|
3325
|
+
}, [mode]);
|
|
3237
3326
|
useImperativeHandle2(ref, () => ({
|
|
3238
3327
|
apply: () => {
|
|
3239
|
-
if (
|
|
3328
|
+
if (mode.kind === "condition") {
|
|
3240
3329
|
return conditions.current?.apply() ?? true;
|
|
3241
3330
|
}
|
|
3242
|
-
|
|
3243
|
-
if (picked) {
|
|
3331
|
+
if (filterDraftChanged3(opened.draft, draft)) {
|
|
3244
3332
|
applyFilter(
|
|
3245
3333
|
draftToFilter2(draft, column.id, controller.getState().filter)
|
|
3246
3334
|
);
|
|
@@ -3248,7 +3336,7 @@ function ExcelFilterEditor({
|
|
|
3248
3336
|
return true;
|
|
3249
3337
|
}
|
|
3250
3338
|
}));
|
|
3251
|
-
if (
|
|
3339
|
+
if (mode.kind === "condition") {
|
|
3252
3340
|
return /* @__PURE__ */ jsxs15(Fragment7, { children: [
|
|
3253
3341
|
/* @__PURE__ */ jsxs15(
|
|
3254
3342
|
"button",
|
|
@@ -3256,7 +3344,7 @@ function ExcelFilterEditor({
|
|
|
3256
3344
|
type: "button",
|
|
3257
3345
|
className: "filter-menu-back",
|
|
3258
3346
|
onClick: () => {
|
|
3259
|
-
|
|
3347
|
+
setMode({ kind: "values", focusOnMount: true });
|
|
3260
3348
|
},
|
|
3261
3349
|
children: [
|
|
3262
3350
|
/* @__PURE__ */ jsx20("span", { className: "filter-menu-back-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx20(ChevronLeftIcon2, {}) }),
|
|
@@ -3276,7 +3364,7 @@ function ExcelFilterEditor({
|
|
|
3276
3364
|
conditionsFocus.current = element;
|
|
3277
3365
|
},
|
|
3278
3366
|
applyFilter,
|
|
3279
|
-
operator
|
|
3367
|
+
operator: mode.operator
|
|
3280
3368
|
}
|
|
3281
3369
|
)
|
|
3282
3370
|
] });
|
|
@@ -3290,7 +3378,9 @@ function ExcelFilterEditor({
|
|
|
3290
3378
|
menu,
|
|
3291
3379
|
active: shape.kind === "conditions" ? shape.conditions.map((condition) => condition.operator) : void 0,
|
|
3292
3380
|
messages,
|
|
3293
|
-
onChoose:
|
|
3381
|
+
onChoose: (operator) => {
|
|
3382
|
+
setMode({ kind: "condition", operator });
|
|
3383
|
+
}
|
|
3294
3384
|
}
|
|
3295
3385
|
),
|
|
3296
3386
|
(shape.kind === "conditions" || shape.kind === "custom") && /* @__PURE__ */ jsx20("p", { className: "filter-menu-custom", children: shape.kind === "conditions" ? messages.filterByCondition : messages.customFilter }),
|
|
@@ -3462,23 +3552,29 @@ function FilterMenu({
|
|
|
3462
3552
|
);
|
|
3463
3553
|
}
|
|
3464
3554
|
|
|
3465
|
-
// src/DataGrid/
|
|
3466
|
-
import { useEffect as useEffect5,
|
|
3467
|
-
function
|
|
3468
|
-
const
|
|
3555
|
+
// src/DataGrid/useAnnounceWhenDrawn.ts
|
|
3556
|
+
import { useEffect as useEffect5, useState as useState10 } from "react";
|
|
3557
|
+
function useAnnounceWhenDrawn(announce) {
|
|
3558
|
+
const [requested, setRequested] = useState10(null);
|
|
3469
3559
|
useEffect5(() => {
|
|
3470
|
-
if (
|
|
3471
|
-
|
|
3472
|
-
announce(
|
|
3473
|
-
messages.filterResults(
|
|
3474
|
-
controller.getView().rows.length,
|
|
3475
|
-
controller.getOptions().dataSource?.length ?? 0
|
|
3476
|
-
)
|
|
3477
|
-
);
|
|
3560
|
+
if (requested?.drawn() === true) {
|
|
3561
|
+
announce(requested.text());
|
|
3478
3562
|
}
|
|
3479
|
-
});
|
|
3563
|
+
}, [requested, announce]);
|
|
3564
|
+
return setRequested;
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
// src/DataGrid/filterMenu/useApplyFilter.ts
|
|
3568
|
+
function useApplyFilter(controller, messages, announce) {
|
|
3569
|
+
const announceWhenDrawn = useAnnounceWhenDrawn(announce);
|
|
3480
3570
|
return (filter) => {
|
|
3481
|
-
|
|
3571
|
+
announceWhenDrawn({
|
|
3572
|
+
drawn: () => controller.getState().filter === filter,
|
|
3573
|
+
text: () => messages.filterResults(
|
|
3574
|
+
controller.getView().rows.length,
|
|
3575
|
+
controller.getOptions().dataSource?.length ?? 0
|
|
3576
|
+
)
|
|
3577
|
+
});
|
|
3482
3578
|
controller.setFilter(filter);
|
|
3483
3579
|
};
|
|
3484
3580
|
}
|
|
@@ -3515,7 +3611,7 @@ function GridPanels({
|
|
|
3515
3611
|
commands,
|
|
3516
3612
|
messages
|
|
3517
3613
|
}) {
|
|
3518
|
-
const initialFocus =
|
|
3614
|
+
const initialFocus = useRef14(null);
|
|
3519
3615
|
const applyFilter = useApplyFilter(
|
|
3520
3616
|
controller,
|
|
3521
3617
|
messages,
|
|
@@ -3584,7 +3680,7 @@ function panelApi(panels, controller) {
|
|
|
3584
3680
|
}
|
|
3585
3681
|
|
|
3586
3682
|
// src/DataGrid/panels/useGridPanels.ts
|
|
3587
|
-
import { useRef as
|
|
3683
|
+
import { useRef as useRef15 } from "react";
|
|
3588
3684
|
function toolbarItem(root, itemId) {
|
|
3589
3685
|
const items = root.querySelectorAll(
|
|
3590
3686
|
":scope > .gridkit-toolbar > [data-gridkit-toolbar-item]"
|
|
@@ -3610,7 +3706,7 @@ function useGridPanels({
|
|
|
3610
3706
|
headerTableRef,
|
|
3611
3707
|
overlay
|
|
3612
3708
|
}) {
|
|
3613
|
-
const openings =
|
|
3709
|
+
const openings = useRef15(0);
|
|
3614
3710
|
function placeFor(root, target) {
|
|
3615
3711
|
const element = target.area === "toolbar" ? toolbarItem(root, target.itemId) : target.area === "header" ? headerCell2(headerTableRef.current, target.columnId) : null;
|
|
3616
3712
|
if (element !== null) {
|
|
@@ -3656,7 +3752,7 @@ function useGridPanels({
|
|
|
3656
3752
|
}
|
|
3657
3753
|
|
|
3658
3754
|
// src/DataGrid/toolbar/GridToolbar.tsx
|
|
3659
|
-
import { useLayoutEffect as useLayoutEffect12, useRef as
|
|
3755
|
+
import { useLayoutEffect as useLayoutEffect12, useRef as useRef18 } from "react";
|
|
3660
3756
|
import {
|
|
3661
3757
|
resolveToolbar,
|
|
3662
3758
|
splitToolbarItems,
|
|
@@ -3725,7 +3821,7 @@ function ToolbarMenuButton({
|
|
|
3725
3821
|
}
|
|
3726
3822
|
|
|
3727
3823
|
// src/DataGrid/toolbar/ToolbarSearch.tsx
|
|
3728
|
-
import { useEffect as useEffect6, useRef as
|
|
3824
|
+
import { useEffect as useEffect6, useRef as useRef16, useState as useState12 } from "react";
|
|
3729
3825
|
import {
|
|
3730
3826
|
searchTextOf,
|
|
3731
3827
|
setSearchText
|
|
@@ -3741,8 +3837,8 @@ function ToolbarSearch({
|
|
|
3741
3837
|
}) {
|
|
3742
3838
|
const applied = searchTextOf(controller.getState().filter);
|
|
3743
3839
|
const [draft, setDraft] = useState12(null);
|
|
3744
|
-
const timer =
|
|
3745
|
-
const
|
|
3840
|
+
const timer = useRef16(void 0);
|
|
3841
|
+
const announceWhenDrawn = useAnnounceWhenDrawn(announce);
|
|
3746
3842
|
const text = draft !== null && draft.over === applied ? draft.text : applied;
|
|
3747
3843
|
function apply(next, over) {
|
|
3748
3844
|
clearTimeout(timer.current);
|
|
@@ -3753,16 +3849,13 @@ function ToolbarSearch({
|
|
|
3753
3849
|
}
|
|
3754
3850
|
const searched = setSearchText(filter, next);
|
|
3755
3851
|
if (searched !== filter) {
|
|
3756
|
-
|
|
3852
|
+
announceWhenDrawn({
|
|
3853
|
+
drawn: () => searchTextOf(controller.getState().filter) === next,
|
|
3854
|
+
text: () => messages.searchResults(controller.getView().rows.length)
|
|
3855
|
+
});
|
|
3757
3856
|
controller.setFilter(searched);
|
|
3758
3857
|
}
|
|
3759
3858
|
}
|
|
3760
|
-
useEffect6(() => {
|
|
3761
|
-
if (unannounced.current === applied) {
|
|
3762
|
-
unannounced.current = null;
|
|
3763
|
-
announce(messages.searchResults(controller.getView().rows.length));
|
|
3764
|
-
}
|
|
3765
|
-
});
|
|
3766
3859
|
useEffect6(
|
|
3767
3860
|
() => () => {
|
|
3768
3861
|
clearTimeout(timer.current);
|
|
@@ -3800,12 +3893,12 @@ function ToolbarSearch({
|
|
|
3800
3893
|
}
|
|
3801
3894
|
|
|
3802
3895
|
// src/DataGrid/toolbar/useToolbarOverflow.ts
|
|
3803
|
-
import { useLayoutEffect as useLayoutEffect11, useRef as
|
|
3896
|
+
import { useLayoutEffect as useLayoutEffect11, useRef as useRef17, useState as useState13 } from "react";
|
|
3804
3897
|
import { observeToolbarOverflow } from "@gridkitjs/dom";
|
|
3805
3898
|
function useToolbarOverflow(toolbarRef, items) {
|
|
3806
3899
|
const [fit, setFit] = useState13(items.length);
|
|
3807
|
-
const overflow =
|
|
3808
|
-
const measuredLayout =
|
|
3900
|
+
const overflow = useRef17(null);
|
|
3901
|
+
const measuredLayout = useRef17("");
|
|
3809
3902
|
const layout = JSON.stringify(
|
|
3810
3903
|
items.map((item) => [
|
|
3811
3904
|
item.type,
|
|
@@ -3912,7 +4005,7 @@ function Toolbar({
|
|
|
3912
4005
|
messages,
|
|
3913
4006
|
announce
|
|
3914
4007
|
}) {
|
|
3915
|
-
const toolbarRef =
|
|
4008
|
+
const toolbarRef = useRef18(null);
|
|
3916
4009
|
const items = resolveToolbar(entries, {
|
|
3917
4010
|
commands: commands.commands,
|
|
3918
4011
|
contextFor: commands.contextFor,
|
|
@@ -4213,14 +4306,14 @@ function useGridController(options) {
|
|
|
4213
4306
|
}
|
|
4214
4307
|
|
|
4215
4308
|
// src/DataGrid/useInfiniteScroll.ts
|
|
4216
|
-
import { useEffect as useEffect7, useRef as
|
|
4309
|
+
import { useEffect as useEffect7, useRef as useRef19 } from "react";
|
|
4217
4310
|
import { attachInfiniteScroll } from "@gridkitjs/dom";
|
|
4218
4311
|
function useInfiniteScroll({
|
|
4219
4312
|
rootRef,
|
|
4220
4313
|
sentinelRef,
|
|
4221
4314
|
config
|
|
4222
4315
|
}) {
|
|
4223
|
-
const scroll =
|
|
4316
|
+
const scroll = useRef19(null);
|
|
4224
4317
|
useEffect7(() => {
|
|
4225
4318
|
const root = rootRef.current;
|
|
4226
4319
|
if (root === null) {
|
|
@@ -4248,10 +4341,10 @@ function useInfiniteScroll({
|
|
|
4248
4341
|
}
|
|
4249
4342
|
|
|
4250
4343
|
// src/DataGrid/useLiveAnnouncer.ts
|
|
4251
|
-
import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect14, useRef as
|
|
4344
|
+
import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect14, useRef as useRef20 } from "react";
|
|
4252
4345
|
import { createLiveAnnouncer } from "@gridkitjs/dom";
|
|
4253
4346
|
function useLiveAnnouncer(containerRef) {
|
|
4254
|
-
const announcer =
|
|
4347
|
+
const announcer = useRef20(null);
|
|
4255
4348
|
useLayoutEffect14(() => {
|
|
4256
4349
|
const container = containerRef.current;
|
|
4257
4350
|
if (container === null) {
|
|
@@ -4379,14 +4472,14 @@ function DataGrid(props) {
|
|
|
4379
4472
|
const hoverRows = hoverable?.rows ?? true;
|
|
4380
4473
|
const hoverColumns = hoverable?.columns ?? true;
|
|
4381
4474
|
const hoverCells = hoverable?.cells ?? true;
|
|
4382
|
-
const viewportRef =
|
|
4383
|
-
const gridRef =
|
|
4384
|
-
const headerTableRef =
|
|
4385
|
-
const bodyTableRef =
|
|
4386
|
-
const bodyScrollRef =
|
|
4387
|
-
const sentinelRef =
|
|
4475
|
+
const viewportRef = useRef21(null);
|
|
4476
|
+
const gridRef = useRef21(null);
|
|
4477
|
+
const headerTableRef = useRef21(null);
|
|
4478
|
+
const bodyTableRef = useRef21(null);
|
|
4479
|
+
const bodyScrollRef = useRef21(null);
|
|
4480
|
+
const sentinelRef = useRef21(null);
|
|
4388
4481
|
const viewportWidth = useElementWidth(viewportRef, resizeMode === "fit");
|
|
4389
|
-
const subscribersRef =
|
|
4482
|
+
const subscribersRef = useRef21(/* @__PURE__ */ new Set());
|
|
4390
4483
|
const gridId = useId2();
|
|
4391
4484
|
const announce = useLiveAnnouncer(viewportRef);
|
|
4392
4485
|
const messages = useMemo5(
|