@dataverse-kit/grid-kit 0.3.0 → 0.5.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/hosts/GroupedGrid.d.ts.map +1 -1
- package/dist/hosts/ReadOnlyGrid.d.ts +10 -3
- package/dist/hosts/ReadOnlyGrid.d.ts.map +1 -1
- package/dist/index.esm.js +30 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -10
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2071,15 +2071,19 @@ function DataGrid(props) {
|
|
|
2071
2071
|
}
|
|
2072
2072
|
|
|
2073
2073
|
/**
|
|
2074
|
-
* Read-only grid: `<DataGrid>` with selection off
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2074
|
+
* Read-only grid: `<DataGrid>` with selection off and editing off. Mirrors the
|
|
2075
|
+
* Grid Customizer's "Read-Only Grid" type — a presentation preset.
|
|
2076
|
+
*
|
|
2077
|
+
* The full `toolbar` config is forwarded (including `commands`) so a read-only
|
|
2078
|
+
* grid can still host non-selection toolbar actions — New / Refresh / Export and
|
|
2079
|
+
* the injected Filter / Columns. Selection-DEPENDENT commands (delete/activate)
|
|
2080
|
+
* are inert here because `selectionMode` is forced to `"none"` (nothing can be
|
|
2081
|
+
* selected); the consumer is expected to omit them. Previously this preset
|
|
2082
|
+
* stripped `commands` entirely (search-only); forwarding them is what lets the
|
|
2083
|
+
* read-only bar consolidate into a single host toolbar instead of an external one.
|
|
2077
2084
|
*/
|
|
2078
2085
|
function ReadOnlyGrid(props) {
|
|
2079
|
-
|
|
2080
|
-
? { showSearch: props.toolbar.showSearch, searchPlaceholder: props.toolbar.searchPlaceholder, onSearch: props.toolbar.onSearch }
|
|
2081
|
-
: undefined;
|
|
2082
|
-
return jsxRuntime.jsx(DataGrid, { ...props, selectionMode: "none", editable: false, toolbar: toolbar });
|
|
2086
|
+
return jsxRuntime.jsx(DataGrid, { ...props, selectionMode: "none", editable: false });
|
|
2083
2087
|
}
|
|
2084
2088
|
|
|
2085
2089
|
// Shared card-layout primitives for the card hosts (`<CardGrid>` flat cards +
|
|
@@ -2254,13 +2258,29 @@ const GROUP_CHEVRON_WIDTH = 36;
|
|
|
2254
2258
|
* groups + count badges), reusing the same columns/registry as `<DataGrid>`.
|
|
2255
2259
|
*/
|
|
2256
2260
|
function GroupedGrid(props) {
|
|
2257
|
-
const { items, columns, group, selectionMode = 'none', isLoading, pagination, onPageChange, aggregateItems, toolbar, compact, alternateRowColors, fill, height, rowCommands } = props;
|
|
2261
|
+
const { items, columns, group, selectionMode = 'none', onSelectionChanged, isLoading, pagination, onPageChange, aggregateItems, toolbar, compact, alternateRowColors, fill, height, rowCommands } = props;
|
|
2258
2262
|
const edit = useEditState();
|
|
2259
|
-
const { ctx } = useGridContext(props, edit);
|
|
2263
|
+
const { ctx, getKeyFn } = useGridContext(props, edit);
|
|
2260
2264
|
const dlColumns = React.useMemo(() => toDetailsListColumns(columns, ctx), [columns, ctx]);
|
|
2261
2265
|
// Per-row right-click menu (DetailsList path, same as DataGrid/NestedInline). No-op when
|
|
2262
2266
|
// rowCommands is unset (onItemContextMenu is undefined → no handler attached).
|
|
2263
2267
|
const { onItemContextMenu, contextMenuElement } = useRowContextMenu(rowCommands);
|
|
2268
|
+
// Fluent Selection so a toolbar's selection-gated commands can read the checked rows via
|
|
2269
|
+
// onSelectionChanged. Ported verbatim from <DataGrid> (the grouped DetailsList supports
|
|
2270
|
+
// selection + groups together: the Selection is over the flattened `orderedItems`, and
|
|
2271
|
+
// group headers select-all per group). `getKey` (= the consumer's getKey via getKeyFn) keys
|
|
2272
|
+
// the selection per row; null-safe for enableShimmer placeholder rows. selectionMode='none'
|
|
2273
|
+
// (the default) passes no selection → display-only / per-row-menu-only grids are unchanged.
|
|
2274
|
+
const safeRowKey = (it, index) => it == null ? `__gridkit_shimmer_${index ?? 0}` : getKeyFn(it);
|
|
2275
|
+
const onSelectionChangedRef = React.useRef(onSelectionChanged);
|
|
2276
|
+
onSelectionChangedRef.current = onSelectionChanged;
|
|
2277
|
+
const selectionRef = React.useRef();
|
|
2278
|
+
if (!selectionRef.current) {
|
|
2279
|
+
selectionRef.current = new react.Selection({
|
|
2280
|
+
getKey: (it, index) => safeRowKey(it, index),
|
|
2281
|
+
onSelectionChanged: () => onSelectionChangedRef.current?.(selectionRef.current.getSelection()),
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2264
2284
|
// Bucket by groupBy → ordered items + IGroup[] (DetailsList needs contiguous
|
|
2265
2285
|
// group ranges). See buildGroups (pure + unit-tested).
|
|
2266
2286
|
const { orderedItems, groups } = React.useMemo(() => buildGroups(items, group), [items, group]);
|
|
@@ -2292,7 +2312,7 @@ function GroupedGrid(props) {
|
|
|
2292
2312
|
});
|
|
2293
2313
|
}
|
|
2294
2314
|
: undefined, [alternateRowColors]);
|
|
2295
|
-
return (jsxRuntime.jsxs(react.Stack, { styles: fillStackStyles(fill, height), children: [toolbar && jsxRuntime.jsx(GridToolbar, { config: toolbar }), jsxRuntime.jsx(FillRegion, { fill: fill, children: jsxRuntime.jsx(react.ShimmeredDetailsList, { items: orderedItems, columns: dlColumns, groups: groups, selectionMode: mapSelectionMode$1(selectionMode), layoutMode: react.DetailsListLayoutMode.justified, compact: compact, setKey: "grid-kit-grouped", onRenderRow: onRenderRow, onItemContextMenu: onItemContextMenu, styles: dynamicsCellRenderers.getDetailsListStyles(), ariaLabelForGrid: "Grouped grid", groupProps: {
|
|
2315
|
+
return (jsxRuntime.jsxs(react.Stack, { styles: fillStackStyles(fill, height), children: [toolbar && jsxRuntime.jsx(GridToolbar, { config: toolbar }), jsxRuntime.jsx(FillRegion, { fill: fill, children: jsxRuntime.jsx(react.ShimmeredDetailsList, { items: orderedItems, columns: dlColumns, groups: groups, selectionMode: mapSelectionMode$1(selectionMode), selection: selectionMode !== 'none' ? selectionRef.current : undefined, getKey: (it, index) => safeRowKey(it, index), layoutMode: react.DetailsListLayoutMode.justified, compact: compact, setKey: "grid-kit-grouped", onRenderRow: onRenderRow, onItemContextMenu: onItemContextMenu, styles: dynamicsCellRenderers.getDetailsListStyles(), ariaLabelForGrid: "Grouped grid", groupProps: {
|
|
2296
2316
|
showEmptyGroups: false,
|
|
2297
2317
|
// Render a subtotal under each EXPANDED group. Fluent v8 calls the group
|
|
2298
2318
|
// footer renderer even for collapsed groups, so guard on isCollapsed —
|