@mshuja288/aksuicore 0.4.2 → 0.4.3
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/index.cjs +94 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +94 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/patterns/RecordWorkspace.tsx +116 -10
package/dist/index.d.cts
CHANGED
|
@@ -237,7 +237,11 @@ declare function RecordWorkspace<T>({ title, columns, items, rowKey, empty, onAd
|
|
|
237
237
|
importBusy?: boolean;
|
|
238
238
|
/** Column checklist in the side rail. Default true. */
|
|
239
239
|
showColumnPicker?: boolean;
|
|
240
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* Persist visible column keys in localStorage under this key.
|
|
242
|
+
* Also persists filter values at `${columnPrefsKey}.filters`.
|
|
243
|
+
* Preview + side-rail open/collapsed use a shared key across all tables (`aksui.workspace.chrome`).
|
|
244
|
+
*/
|
|
241
245
|
columnPrefsKey?: string;
|
|
242
246
|
/** Controlled visible column keys. */
|
|
243
247
|
visibleColumnKeys?: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -237,7 +237,11 @@ declare function RecordWorkspace<T>({ title, columns, items, rowKey, empty, onAd
|
|
|
237
237
|
importBusy?: boolean;
|
|
238
238
|
/** Column checklist in the side rail. Default true. */
|
|
239
239
|
showColumnPicker?: boolean;
|
|
240
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* Persist visible column keys in localStorage under this key.
|
|
242
|
+
* Also persists filter values at `${columnPrefsKey}.filters`.
|
|
243
|
+
* Preview + side-rail open/collapsed use a shared key across all tables (`aksui.workspace.chrome`).
|
|
244
|
+
*/
|
|
241
245
|
columnPrefsKey?: string;
|
|
242
246
|
/** Controlled visible column keys. */
|
|
243
247
|
visibleColumnKeys?: string[];
|
package/dist/index.js
CHANGED
|
@@ -875,6 +875,37 @@ var BULK_IMPORT_MODE_OPTIONS = [
|
|
|
875
875
|
function defaultVisibleKeys(columns) {
|
|
876
876
|
return columns.filter((column) => column.defaultVisible !== false).map((column) => column.key);
|
|
877
877
|
}
|
|
878
|
+
var WORKSPACE_CHROME_KEY = "aksui.workspace.chrome";
|
|
879
|
+
function readWorkspaceChrome() {
|
|
880
|
+
if (typeof window === "undefined") {
|
|
881
|
+
return { previewEnabled: false, sideOpen: false };
|
|
882
|
+
}
|
|
883
|
+
try {
|
|
884
|
+
const raw = window.localStorage.getItem(WORKSPACE_CHROME_KEY);
|
|
885
|
+
if (!raw) {
|
|
886
|
+
return { previewEnabled: false, sideOpen: false };
|
|
887
|
+
}
|
|
888
|
+
const parsed = JSON.parse(raw);
|
|
889
|
+
return {
|
|
890
|
+
previewEnabled: Boolean(parsed.previewEnabled),
|
|
891
|
+
sideOpen: Boolean(parsed.sideOpen)
|
|
892
|
+
};
|
|
893
|
+
} catch {
|
|
894
|
+
return { previewEnabled: false, sideOpen: false };
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
function writeWorkspaceChrome(chrome) {
|
|
898
|
+
if (typeof window === "undefined") {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
try {
|
|
902
|
+
window.localStorage.setItem(WORKSPACE_CHROME_KEY, JSON.stringify(chrome));
|
|
903
|
+
} catch {
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
function filtersPrefsKey(columnPrefsKey) {
|
|
907
|
+
return columnPrefsKey ? `${columnPrefsKey}.filters` : void 0;
|
|
908
|
+
}
|
|
878
909
|
function readStoredColumnKeys(prefsKey, fallback, allowed) {
|
|
879
910
|
if (!prefsKey || typeof window === "undefined") {
|
|
880
911
|
return fallback;
|
|
@@ -903,6 +934,45 @@ function writeStoredColumnKeys(prefsKey, keys) {
|
|
|
903
934
|
} catch {
|
|
904
935
|
}
|
|
905
936
|
}
|
|
937
|
+
function readStoredFilters(prefsKey, allowed) {
|
|
938
|
+
if (!prefsKey || typeof window === "undefined") {
|
|
939
|
+
return {};
|
|
940
|
+
}
|
|
941
|
+
try {
|
|
942
|
+
const raw = window.localStorage.getItem(prefsKey);
|
|
943
|
+
if (!raw) {
|
|
944
|
+
return {};
|
|
945
|
+
}
|
|
946
|
+
const parsed = JSON.parse(raw);
|
|
947
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
948
|
+
return {};
|
|
949
|
+
}
|
|
950
|
+
const next = {};
|
|
951
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
952
|
+
if (allowed.has(key) && typeof value === "string" && value.trim()) {
|
|
953
|
+
next[key] = value;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return next;
|
|
957
|
+
} catch {
|
|
958
|
+
return {};
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function writeStoredFilters(prefsKey, filters) {
|
|
962
|
+
if (!prefsKey || typeof window === "undefined") {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
try {
|
|
966
|
+
const trimmed = {};
|
|
967
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
968
|
+
if (value.trim()) {
|
|
969
|
+
trimmed[key] = value;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
window.localStorage.setItem(prefsKey, JSON.stringify(trimmed));
|
|
973
|
+
} catch {
|
|
974
|
+
}
|
|
975
|
+
}
|
|
906
976
|
function compareColumnValues(column, left, right) {
|
|
907
977
|
const leftRaw = column.display ? column.display(left) : column.value(left);
|
|
908
978
|
const rightRaw = column.display ? column.display(right) : column.value(right);
|
|
@@ -1026,9 +1096,12 @@ function RecordWorkspace({
|
|
|
1026
1096
|
const [internalVisibleKeys, setInternalVisibleKeys] = useState(
|
|
1027
1097
|
() => readStoredColumnKeys(columnPrefsKey, fallbackKeys, allowedKeys)
|
|
1028
1098
|
);
|
|
1029
|
-
const
|
|
1099
|
+
const filterStorageKey = filtersPrefsKey(columnPrefsKey);
|
|
1100
|
+
const [filters, setFilters] = useState(
|
|
1101
|
+
() => readStoredFilters(filterStorageKey, allowedKeys)
|
|
1102
|
+
);
|
|
1030
1103
|
const [sort, setSort] = useState(null);
|
|
1031
|
-
const [sideOpen, setSideOpen] = useState(
|
|
1104
|
+
const [sideOpen, setSideOpen] = useState(() => readWorkspaceChrome().sideOpen);
|
|
1032
1105
|
const [toolsDrawerOpen, setToolsDrawerOpen] = useState(false);
|
|
1033
1106
|
const [downloadOpen, setDownloadOpen] = useState(false);
|
|
1034
1107
|
const [bulkOpen, setBulkOpen] = useState(false);
|
|
@@ -1037,7 +1110,7 @@ function RecordWorkspace({
|
|
|
1037
1110
|
const [bulkReport, setBulkReport] = useState(null);
|
|
1038
1111
|
const bulkFileInputRef = useRef(null);
|
|
1039
1112
|
const [columnsOpen, setColumnsOpen] = useState(false);
|
|
1040
|
-
const [previewEnabled, setPreviewEnabled] = useState(
|
|
1113
|
+
const [previewEnabled, setPreviewEnabled] = useState(() => readWorkspaceChrome().previewEnabled);
|
|
1041
1114
|
const [previewKey, setPreviewKey] = useState(null);
|
|
1042
1115
|
const [tooltip, setTooltip] = useState(null);
|
|
1043
1116
|
const [pageSize, setPageSize] = useState("15");
|
|
@@ -1052,6 +1125,9 @@ function RecordWorkspace({
|
|
|
1052
1125
|
}
|
|
1053
1126
|
setInternalVisibleKeys(readStoredColumnKeys(columnPrefsKey, fallbackKeys, allowedKeys));
|
|
1054
1127
|
}, [allowedKeys, columnPrefsKey, fallbackKeys, isControlled]);
|
|
1128
|
+
useEffect(() => {
|
|
1129
|
+
setFilters(readStoredFilters(filtersPrefsKey(columnPrefsKey), allowedKeys));
|
|
1130
|
+
}, [allowedKeys, columnPrefsKey]);
|
|
1055
1131
|
const resolvedVisibleKeys = useMemo(() => {
|
|
1056
1132
|
const source = isControlled ? visibleColumnKeys : internalVisibleKeys;
|
|
1057
1133
|
const filtered2 = source.filter((key) => allowedKeys.has(key));
|
|
@@ -1212,13 +1288,22 @@ function RecordWorkspace({
|
|
|
1212
1288
|
}
|
|
1213
1289
|
const previewTitle = previewItem && visibleColumns[0] ? cellText(visibleColumns[0], previewItem) : null;
|
|
1214
1290
|
function changeFilter(key, value) {
|
|
1215
|
-
setFilters((current) =>
|
|
1291
|
+
setFilters((current) => {
|
|
1292
|
+
const next = { ...current, [key]: value };
|
|
1293
|
+
writeStoredFilters(filterStorageKey, next);
|
|
1294
|
+
return next;
|
|
1295
|
+
});
|
|
1216
1296
|
setPage(1);
|
|
1217
1297
|
}
|
|
1218
1298
|
function clearFilters() {
|
|
1219
1299
|
setFilters({});
|
|
1300
|
+
writeStoredFilters(filterStorageKey, {});
|
|
1220
1301
|
setPage(1);
|
|
1221
1302
|
}
|
|
1303
|
+
function setSideOpenValue(open) {
|
|
1304
|
+
setSideOpen(open);
|
|
1305
|
+
writeWorkspaceChrome({ previewEnabled, sideOpen: open });
|
|
1306
|
+
}
|
|
1222
1307
|
function toggleSort(column) {
|
|
1223
1308
|
if (column.sortable === false) {
|
|
1224
1309
|
return;
|
|
@@ -1236,6 +1321,7 @@ function RecordWorkspace({
|
|
|
1236
1321
|
}
|
|
1237
1322
|
function setPreviewEnabledValue(enabled) {
|
|
1238
1323
|
setPreviewEnabled(enabled);
|
|
1324
|
+
writeWorkspaceChrome({ previewEnabled: enabled, sideOpen });
|
|
1239
1325
|
setTooltip(null);
|
|
1240
1326
|
if (!enabled) {
|
|
1241
1327
|
setPreviewKey(null);
|
|
@@ -1296,7 +1382,7 @@ function RecordWorkspace({
|
|
|
1296
1382
|
title: "Columns",
|
|
1297
1383
|
"aria-label": "Columns",
|
|
1298
1384
|
onClick: () => {
|
|
1299
|
-
|
|
1385
|
+
setSideOpenValue(true);
|
|
1300
1386
|
setColumnsOpen(true);
|
|
1301
1387
|
},
|
|
1302
1388
|
children: [
|
|
@@ -1314,7 +1400,7 @@ function RecordWorkspace({
|
|
|
1314
1400
|
"aria-label": "Download",
|
|
1315
1401
|
disabled: downloadBusy,
|
|
1316
1402
|
onClick: () => {
|
|
1317
|
-
|
|
1403
|
+
setSideOpenValue(true);
|
|
1318
1404
|
setDownloadOpen(true);
|
|
1319
1405
|
},
|
|
1320
1406
|
children: /* @__PURE__ */ jsx(DownloadIcon, {})
|
|
@@ -1329,7 +1415,7 @@ function RecordWorkspace({
|
|
|
1329
1415
|
"aria-label": "Bulk entry",
|
|
1330
1416
|
disabled: importBusy,
|
|
1331
1417
|
onClick: () => {
|
|
1332
|
-
|
|
1418
|
+
setSideOpenValue(true);
|
|
1333
1419
|
setBulkOpen(true);
|
|
1334
1420
|
},
|
|
1335
1421
|
children: /* @__PURE__ */ jsx(UploadIcon, {})
|
|
@@ -1731,7 +1817,7 @@ function RecordWorkspace({
|
|
|
1731
1817
|
className: "ghost side-rail-toggle",
|
|
1732
1818
|
"aria-expanded": sideOpen,
|
|
1733
1819
|
title: sideOpen ? "Collapse" : "Expand",
|
|
1734
|
-
onClick: () =>
|
|
1820
|
+
onClick: () => setSideOpenValue(!sideOpen),
|
|
1735
1821
|
children: [
|
|
1736
1822
|
/* @__PURE__ */ jsx(ChevronIcon, { open: sideOpen }),
|
|
1737
1823
|
sideOpen ? /* @__PURE__ */ jsx("span", { children: "Collapse" }) : null
|