@krak-stack/registry 0.1.49 → 0.1.50
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/CHANGELOG.md +7 -0
- package/dist/components/ui/data-table.js +25 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## 0.1.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Render configured empty groups and their actions in DataTable table and gallery views even when no resource rows exist. Preserve loading, error, and normal empty states when no groups are available.
|
|
8
|
+
- Persist Group by selections alongside column and view preferences, including explicitly cleared grouping. Keep existing saved preferences compatible and use the initial grouping when no grouping preference has been saved.
|
|
9
|
+
|
|
3
10
|
## 0.1.49
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -979,6 +979,7 @@ import { jsx as jsx14, jsxs as jsxs8, Fragment } from "react/jsx-runtime";
|
|
|
979
979
|
var DataTablePersistedUiStateSchema = Schema.Struct({
|
|
980
980
|
columnVisibility: Schema.Record(Schema.String, Schema.Boolean),
|
|
981
981
|
columnSizing: Schema.Record(Schema.String, Schema.Number),
|
|
982
|
+
grouping: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
982
983
|
view: Schema.Literals(["table", "gallery"])
|
|
983
984
|
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
984
985
|
var dataTableStorageRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
@@ -1071,11 +1072,11 @@ var DEFAULT_UI_STATE = {
|
|
|
1071
1072
|
var persistedUiFromState = (state) => ({
|
|
1072
1073
|
columnVisibility: state.columnVisibility,
|
|
1073
1074
|
columnSizing: state.columnSizing,
|
|
1075
|
+
grouping: state.grouping,
|
|
1074
1076
|
view: state.view
|
|
1075
1077
|
});
|
|
1076
1078
|
var transientUiFromState = (state) => ({
|
|
1077
1079
|
rowSelection: state.rowSelection,
|
|
1078
|
-
grouping: state.grouping,
|
|
1079
1080
|
collapsedGroups: state.collapsedGroups
|
|
1080
1081
|
});
|
|
1081
1082
|
var clampWidth = (column, width) => Math.min(column.maxWidth ?? DEFAULT_MAX_WIDTH, Math.max(column.minWidth ?? DEFAULT_MIN_WIDTH, width));
|
|
@@ -2355,11 +2356,11 @@ var GroupActions = ({
|
|
|
2355
2356
|
});
|
|
2356
2357
|
};
|
|
2357
2358
|
var GroupedTable = ({
|
|
2358
|
-
tableAtom
|
|
2359
|
+
tableAtom,
|
|
2360
|
+
sections
|
|
2359
2361
|
}) => {
|
|
2360
2362
|
const [store, setStore] = useTableAtom(tableAtom);
|
|
2361
2363
|
const model = deriveModel(store);
|
|
2362
|
-
const sections = groupDataTableRows(model.sortedRows, getActiveGrouping(store));
|
|
2363
2364
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
2364
2365
|
const renderSections = (items) => items.flatMap((section) => {
|
|
2365
2366
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
@@ -2597,12 +2598,15 @@ var DataTableBody = ({
|
|
|
2597
2598
|
}) => {
|
|
2598
2599
|
const [store] = useTableAtom(tableAtom);
|
|
2599
2600
|
const model = deriveModel(store);
|
|
2600
|
-
const
|
|
2601
|
+
const fields = getActiveGrouping(store);
|
|
2602
|
+
const grouped = fields.length > 0;
|
|
2601
2603
|
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
2604
|
+
const sections = groupDataTableRows(rows, fields);
|
|
2602
2605
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
2603
|
-
if (
|
|
2606
|
+
if (sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error) {
|
|
2604
2607
|
return /* @__PURE__ */ jsx14(GroupedTable, {
|
|
2605
|
-
tableAtom
|
|
2608
|
+
tableAtom,
|
|
2609
|
+
sections
|
|
2606
2610
|
});
|
|
2607
2611
|
}
|
|
2608
2612
|
return /* @__PURE__ */ jsx14(TableBody, {
|
|
@@ -2706,6 +2710,7 @@ var DataTableGallery = ({
|
|
|
2706
2710
|
const model = deriveModel(store);
|
|
2707
2711
|
const fields = getActiveGrouping(store);
|
|
2708
2712
|
const rows = fields.length ? model.sortedRows : model.pageRows;
|
|
2713
|
+
const sections = groupDataTableRows(rows, fields);
|
|
2709
2714
|
if (store.config.status.error) {
|
|
2710
2715
|
return /* @__PURE__ */ jsx14("div", {
|
|
2711
2716
|
className: "text-destructive rounded-lg border border-dashed p-10 text-center",
|
|
@@ -2720,7 +2725,7 @@ var DataTableGallery = ({
|
|
|
2720
2725
|
})
|
|
2721
2726
|
});
|
|
2722
2727
|
}
|
|
2723
|
-
if (!rows.length) {
|
|
2728
|
+
if (!rows.length && !sections.length) {
|
|
2724
2729
|
return /* @__PURE__ */ jsx14("div", {
|
|
2725
2730
|
className: "text-muted-foreground rounded-lg border border-dashed p-10 text-center",
|
|
2726
2731
|
children: store.config.status.empty ?? store.config.labels.empty
|
|
@@ -2799,7 +2804,7 @@ var DataTableGallery = ({
|
|
|
2799
2804
|
});
|
|
2800
2805
|
return /* @__PURE__ */ jsx14("div", {
|
|
2801
2806
|
className: "space-y-4",
|
|
2802
|
-
children: renderSections(
|
|
2807
|
+
children: renderSections(sections)
|
|
2803
2808
|
});
|
|
2804
2809
|
};
|
|
2805
2810
|
var DataTablePagination = ({
|
|
@@ -2845,15 +2850,17 @@ var HydratedDataTable = ({
|
|
|
2845
2850
|
setPersistedUiState,
|
|
2846
2851
|
...props
|
|
2847
2852
|
}) => {
|
|
2848
|
-
const [
|
|
2853
|
+
const [initialGrouping] = useState(() => {
|
|
2849
2854
|
const grouping = props.features?.grouping;
|
|
2850
|
-
return
|
|
2851
|
-
...transientUiFromState(DEFAULT_UI_STATE),
|
|
2852
|
-
grouping: grouping && grouping.initial ? grouping.initial : []
|
|
2853
|
-
});
|
|
2855
|
+
return grouping && grouping.initial ? grouping.initial : [];
|
|
2854
2856
|
});
|
|
2857
|
+
const [transientUiAtom] = useState(() => Atom.make(transientUiFromState(DEFAULT_UI_STATE)));
|
|
2855
2858
|
const [transientUiState, setTransientUiState] = useAtom(transientUiAtom);
|
|
2856
|
-
const uiState = useMemo(() => ({
|
|
2859
|
+
const uiState = useMemo(() => ({
|
|
2860
|
+
...persistedUiState,
|
|
2861
|
+
...transientUiState,
|
|
2862
|
+
grouping: persistedUiState.grouping ?? initialGrouping
|
|
2863
|
+
}), [persistedUiState, transientUiState, initialGrouping]);
|
|
2857
2864
|
const setUiState = useCallback((state) => {
|
|
2858
2865
|
setPersistedUiState(persistedUiFromState(state));
|
|
2859
2866
|
setTransientUiState(transientUiFromState(state));
|
|
@@ -2946,7 +2953,10 @@ var DataTable = (props) => {
|
|
|
2946
2953
|
runtime: dataTableStorageRuntime,
|
|
2947
2954
|
key: `data-table:${pathname}:${columnIds}:${viewCapability}:ui`,
|
|
2948
2955
|
schema: DataTablePersistedUiStateSchema,
|
|
2949
|
-
defaultValue: () =>
|
|
2956
|
+
defaultValue: () => ({
|
|
2957
|
+
...persistedUiFromState(DEFAULT_UI_STATE),
|
|
2958
|
+
grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
|
|
2959
|
+
})
|
|
2950
2960
|
});
|
|
2951
2961
|
});
|
|
2952
2962
|
const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
|