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