@mshuja288/aksuicore 0.4.0 → 0.4.1

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 CHANGED
@@ -847,6 +847,21 @@ function useIsClient2() {
847
847
  () => false
848
848
  );
849
849
  }
850
+ function useHoverTooltipsEnabled() {
851
+ return useSyncExternalStore(
852
+ (onStoreChange) => {
853
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
854
+ return () => {
855
+ };
856
+ }
857
+ const media = window.matchMedia("(hover: hover) and (pointer: fine)");
858
+ media.addEventListener("change", onStoreChange);
859
+ return () => media.removeEventListener("change", onStoreChange);
860
+ },
861
+ () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(hover: hover) and (pointer: fine)").matches,
862
+ () => false
863
+ );
864
+ }
850
865
  var EXPORT_FORMAT_OPTIONS = [
851
866
  { format: "csv", label: "CSV" },
852
867
  { format: "xlsx", label: "Excel" },
@@ -942,6 +957,19 @@ function MoreIcon() {
942
957
  /* @__PURE__ */ jsx("circle", { cx: "15.5", cy: "10", r: "1.5", fill: "currentColor" })
943
958
  ] });
944
959
  }
960
+ function ToolsIcon() {
961
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
962
+ "path",
963
+ {
964
+ d: "M11.5 3.5h5v5M16.2 3.8 10 10M8.2 5.2H3.8v11h11V12",
965
+ fill: "none",
966
+ stroke: "currentColor",
967
+ strokeWidth: "1.6",
968
+ strokeLinecap: "round",
969
+ strokeLinejoin: "round"
970
+ }
971
+ ) });
972
+ }
945
973
  function DetailList({ lines }) {
946
974
  return /* @__PURE__ */ jsx("dl", { className: "record-detail-list", children: lines.map((line) => /* @__PURE__ */ jsxs("div", { className: "record-detail-row", children: [
947
975
  /* @__PURE__ */ jsx("dt", { children: line.label }),
@@ -985,6 +1013,7 @@ function RecordWorkspace({
985
1013
  const [filters, setFilters] = useState({});
986
1014
  const [sort, setSort] = useState(null);
987
1015
  const [sideOpen, setSideOpen] = useState(false);
1016
+ const [toolsDrawerOpen, setToolsDrawerOpen] = useState(false);
988
1017
  const [downloadOpen, setDownloadOpen] = useState(false);
989
1018
  const [columnsOpen, setColumnsOpen] = useState(false);
990
1019
  const [previewEnabled, setPreviewEnabled] = useState(false);
@@ -992,9 +1021,10 @@ function RecordWorkspace({
992
1021
  const [tooltip, setTooltip] = useState(null);
993
1022
  const [pageSize, setPageSize] = useState("15");
994
1023
  const [page, setPage] = useState(1);
995
- const [actionsMenuKey, setActionsMenuKey] = useState(null);
1024
+ const [actionsMenu, setActionsMenu] = useState(null);
996
1025
  const actionsMenuRef = useRef(null);
997
1026
  const isClient = useIsClient2();
1027
+ const hoverTooltipsEnabled = useHoverTooltipsEnabled();
998
1028
  useEffect(() => {
999
1029
  if (isControlled) {
1000
1030
  return;
@@ -1071,6 +1101,7 @@ function RecordWorkspace({
1071
1101
  [filterableColumns, filters]
1072
1102
  );
1073
1103
  const hiddenColumnCount = columns.length - visibleColumns.length;
1104
+ const toolsBadgeCount = activeFilterCount + (hiddenColumnCount > 0 ? 1 : 0) + (previewEnabled ? 1 : 0);
1074
1105
  const showAll = pageSize === "all";
1075
1106
  const numericPageSize = showAll ? Math.max(sorted.length, 1) : Number(pageSize);
1076
1107
  const pageCount = showAll ? 1 : Math.max(1, Math.ceil(sorted.length / numericPageSize));
@@ -1086,18 +1117,36 @@ function RecordWorkspace({
1086
1117
  key: column.exportKey ?? column.key,
1087
1118
  header: column.header
1088
1119
  }));
1120
+ const canShowTooltip = hoverTooltipsEnabled && !previewEnabled && actionsMenu === null;
1089
1121
  useEffect(() => {
1090
- if (actionsMenuKey === null) {
1122
+ if (actionsMenu === null) {
1091
1123
  return;
1092
1124
  }
1093
1125
  function onPointerDown(event) {
1094
1126
  if (actionsMenuRef.current && !actionsMenuRef.current.contains(event.target)) {
1095
- setActionsMenuKey(null);
1127
+ setActionsMenu(null);
1096
1128
  }
1097
1129
  }
1098
1130
  document.addEventListener("mousedown", onPointerDown);
1099
1131
  return () => document.removeEventListener("mousedown", onPointerDown);
1100
- }, [actionsMenuKey]);
1132
+ }, [actionsMenu]);
1133
+ useEffect(() => {
1134
+ if (!toolsDrawerOpen) {
1135
+ return;
1136
+ }
1137
+ function onKeyDown(event) {
1138
+ if (event.key === "Escape") {
1139
+ setToolsDrawerOpen(false);
1140
+ }
1141
+ }
1142
+ document.addEventListener("keydown", onKeyDown);
1143
+ const previousOverflow = document.body.style.overflow;
1144
+ document.body.style.overflow = "hidden";
1145
+ return () => {
1146
+ document.removeEventListener("keydown", onKeyDown);
1147
+ document.body.style.overflow = previousOverflow;
1148
+ };
1149
+ }, [toolsDrawerOpen]);
1101
1150
  function requestDownload(format) {
1102
1151
  if (!onDownload || downloadBusy) {
1103
1152
  return;
@@ -1152,13 +1201,244 @@ function RecordWorkspace({
1152
1201
  }
1153
1202
  }
1154
1203
  function showTooltip(item, event) {
1204
+ if (!canShowTooltip) {
1205
+ return;
1206
+ }
1155
1207
  const padding = 16;
1156
1208
  const width = 280;
1157
1209
  const x = Math.min(event.clientX + 14, window.innerWidth - width - padding);
1158
1210
  const y = Math.min(event.clientY + 14, window.innerHeight - padding - 24);
1159
1211
  setTooltip({ x, y, lines: detailLines(item) });
1160
1212
  }
1213
+ function openRowActions(item, event) {
1214
+ event.stopPropagation();
1215
+ setTooltip(null);
1216
+ const key = rowKey(item);
1217
+ if (actionsMenu?.key === key) {
1218
+ setActionsMenu(null);
1219
+ return;
1220
+ }
1221
+ const rect = event.currentTarget.getBoundingClientRect();
1222
+ const menuWidth = 168;
1223
+ const menuHeight = 148;
1224
+ const x = Math.min(Math.max(8, rect.right - menuWidth), window.innerWidth - menuWidth - 8);
1225
+ const y = Math.min(rect.bottom + 6, window.innerHeight - menuHeight - 8);
1226
+ setActionsMenu({ key, item, x, y });
1227
+ }
1161
1228
  const summary = sorted.length === 0 ? "0 records" : showAll ? `1\u2013${sorted.length} of ${sorted.length}` : `${start + 1}\u2013${Math.min(start + numericPageSize, sorted.length)} of ${sorted.length}`;
1229
+ function renderToolsBody({ compactIcons }) {
1230
+ if (compactIcons) {
1231
+ return /* @__PURE__ */ jsxs("div", { className: "side-rail-icons", children: [
1232
+ /* @__PURE__ */ jsxs("label", { className: "side-rail-icon preview-check-icon", title: "Preview", children: [
1233
+ /* @__PURE__ */ jsx(
1234
+ "input",
1235
+ {
1236
+ type: "checkbox",
1237
+ checked: previewEnabled,
1238
+ onChange: (event) => setPreviewEnabledValue(event.target.checked),
1239
+ "aria-label": "Preview"
1240
+ }
1241
+ ),
1242
+ /* @__PURE__ */ jsx(PreviewIcon, {})
1243
+ ] }),
1244
+ showAdd ? /* @__PURE__ */ jsx("button", { type: "button", className: "ghost side-rail-icon", title: addLabel, "aria-label": addLabel, onClick: onAdd, children: /* @__PURE__ */ jsx(PlusIcon, {}) }) : null,
1245
+ showColumns ? /* @__PURE__ */ jsxs(
1246
+ "button",
1247
+ {
1248
+ type: "button",
1249
+ className: "ghost side-rail-icon",
1250
+ title: "Columns",
1251
+ "aria-label": "Columns",
1252
+ onClick: () => {
1253
+ setSideOpen(true);
1254
+ setColumnsOpen(true);
1255
+ },
1256
+ children: [
1257
+ /* @__PURE__ */ jsx(ColumnsIcon, {}),
1258
+ hiddenColumnCount > 0 ? /* @__PURE__ */ jsx("span", { className: "filter-badge", children: hiddenColumnCount }) : null
1259
+ ]
1260
+ }
1261
+ ) : null,
1262
+ showDownload ? /* @__PURE__ */ jsx(
1263
+ "button",
1264
+ {
1265
+ type: "button",
1266
+ className: "ghost side-rail-icon",
1267
+ title: "Download",
1268
+ "aria-label": "Download",
1269
+ disabled: downloadBusy,
1270
+ onClick: () => {
1271
+ setSideOpen(true);
1272
+ setDownloadOpen(true);
1273
+ },
1274
+ children: /* @__PURE__ */ jsx(DownloadIcon, {})
1275
+ }
1276
+ ) : null,
1277
+ showFilters ? /* @__PURE__ */ jsxs(
1278
+ "button",
1279
+ {
1280
+ type: "button",
1281
+ className: "ghost side-rail-icon",
1282
+ title: "Show filters",
1283
+ "aria-label": "Show filters",
1284
+ onClick: () => setSideOpen(true),
1285
+ children: [
1286
+ /* @__PURE__ */ jsx(FilterIcon, {}),
1287
+ activeFilterCount > 0 ? /* @__PURE__ */ jsx("span", { className: "filter-badge", children: activeFilterCount }) : null
1288
+ ]
1289
+ }
1290
+ ) : null,
1291
+ showFilters ? /* @__PURE__ */ jsx(
1292
+ "button",
1293
+ {
1294
+ type: "button",
1295
+ className: "ghost side-rail-icon",
1296
+ title: "Reset filters",
1297
+ "aria-label": "Reset filters",
1298
+ disabled: activeFilterCount === 0,
1299
+ onClick: clearFilters,
1300
+ children: /* @__PURE__ */ jsx(ResetIcon, {})
1301
+ }
1302
+ ) : null
1303
+ ] });
1304
+ }
1305
+ return /* @__PURE__ */ jsxs("div", { className: "side-rail-body", children: [
1306
+ /* @__PURE__ */ jsxs("div", { className: "preview-check", children: [
1307
+ /* @__PURE__ */ jsx(
1308
+ "input",
1309
+ {
1310
+ type: "checkbox",
1311
+ checked: previewEnabled,
1312
+ onChange: (event) => setPreviewEnabledValue(event.target.checked),
1313
+ "aria-label": "Preview"
1314
+ }
1315
+ ),
1316
+ /* @__PURE__ */ jsx(PreviewIcon, {}),
1317
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "Preview" })
1318
+ ] }),
1319
+ showAdd ? /* @__PURE__ */ jsxs(
1320
+ "button",
1321
+ {
1322
+ type: "button",
1323
+ className: "side-rail-add",
1324
+ onClick: () => {
1325
+ setToolsDrawerOpen(false);
1326
+ onAdd?.();
1327
+ },
1328
+ children: [
1329
+ /* @__PURE__ */ jsx(PlusIcon, {}),
1330
+ /* @__PURE__ */ jsx("span", { children: addLabel })
1331
+ ]
1332
+ }
1333
+ ) : null,
1334
+ showColumns ? /* @__PURE__ */ jsxs("div", { className: "side-rail-columns", children: [
1335
+ /* @__PURE__ */ jsxs(
1336
+ "button",
1337
+ {
1338
+ type: "button",
1339
+ className: "ghost side-rail-columns-toggle",
1340
+ "aria-expanded": columnsOpen,
1341
+ onClick: () => setColumnsOpen((open) => !open),
1342
+ children: [
1343
+ /* @__PURE__ */ jsx(ColumnsIcon, {}),
1344
+ /* @__PURE__ */ jsxs("span", { children: [
1345
+ "Columns",
1346
+ hiddenColumnCount > 0 ? ` (${visibleColumns.length}/${columns.length})` : ""
1347
+ ] })
1348
+ ]
1349
+ }
1350
+ ),
1351
+ columnsOpen ? /* @__PURE__ */ jsxs("div", { className: "side-rail-columns-panel", role: "group", "aria-label": "Visible columns", children: [
1352
+ /* @__PURE__ */ jsxs("div", { className: "side-rail-columns-actions", children: [
1353
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ghost", onClick: selectAllColumns, children: "Select all" }),
1354
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ghost", onClick: resetColumns, children: "Reset" })
1355
+ ] }),
1356
+ /* @__PURE__ */ jsx("div", { className: "side-rail-columns-list", children: columns.map((column) => {
1357
+ const checked = resolvedVisibleKeys.includes(column.key);
1358
+ const disableUncheck = checked && resolvedVisibleKeys.length <= 1;
1359
+ return /* @__PURE__ */ jsxs("label", { className: "side-rail-column-option", children: [
1360
+ /* @__PURE__ */ jsx(
1361
+ "input",
1362
+ {
1363
+ type: "checkbox",
1364
+ checked,
1365
+ disabled: disableUncheck,
1366
+ onChange: (event) => toggleColumnVisible(column.key, event.target.checked)
1367
+ }
1368
+ ),
1369
+ /* @__PURE__ */ jsx("span", { children: column.header })
1370
+ ] }, column.key);
1371
+ }) })
1372
+ ] }) : null
1373
+ ] }) : null,
1374
+ showDownload ? /* @__PURE__ */ jsxs("div", { className: "side-rail-download", children: [
1375
+ /* @__PURE__ */ jsxs(
1376
+ "button",
1377
+ {
1378
+ type: "button",
1379
+ className: "ghost side-rail-download-toggle",
1380
+ "aria-expanded": downloadOpen,
1381
+ disabled: downloadBusy,
1382
+ onClick: () => setDownloadOpen((open) => !open),
1383
+ children: [
1384
+ /* @__PURE__ */ jsx(DownloadIcon, {}),
1385
+ /* @__PURE__ */ jsx("span", { children: downloadBusy ? "Downloading\u2026" : "Download" })
1386
+ ]
1387
+ }
1388
+ ),
1389
+ downloadOpen ? /* @__PURE__ */ jsx("div", { className: "side-rail-download-formats", role: "group", "aria-label": "Download format", children: EXPORT_FORMAT_OPTIONS.map((option) => /* @__PURE__ */ jsx(
1390
+ "button",
1391
+ {
1392
+ type: "button",
1393
+ className: "ghost side-rail-download-format",
1394
+ disabled: downloadBusy,
1395
+ onClick: () => requestDownload(option.format),
1396
+ children: option.label
1397
+ },
1398
+ option.format
1399
+ )) }) : null
1400
+ ] }) : null,
1401
+ showFilters ? /* @__PURE__ */ jsxs("div", { className: "side-rail-filters", children: [
1402
+ /* @__PURE__ */ jsxs("div", { className: "filter-panel-head", children: [
1403
+ /* @__PURE__ */ jsx("h3", { children: "Filters" }),
1404
+ /* @__PURE__ */ jsxs(
1405
+ "button",
1406
+ {
1407
+ type: "button",
1408
+ className: "ghost filter-clear",
1409
+ title: "Reset filters",
1410
+ "aria-label": "Reset filters",
1411
+ disabled: activeFilterCount === 0,
1412
+ onClick: clearFilters,
1413
+ children: [
1414
+ /* @__PURE__ */ jsx(ResetIcon, {}),
1415
+ /* @__PURE__ */ jsx("span", { children: "Reset" })
1416
+ ]
1417
+ }
1418
+ )
1419
+ ] }),
1420
+ /* @__PURE__ */ jsx("div", { className: "filter-panel-stack", children: filterableColumns.map((column) => /* @__PURE__ */ jsxs("label", { children: [
1421
+ column.header,
1422
+ column.filterOptions ? /* @__PURE__ */ jsx(
1423
+ Select,
1424
+ {
1425
+ value: filters[column.key] ?? "",
1426
+ options: [{ value: "", label: column.filterPlaceholder ?? "All" }, ...column.filterOptions],
1427
+ onChange: (value) => changeFilter(column.key, value),
1428
+ placeholder: column.filterPlaceholder ?? "All"
1429
+ }
1430
+ ) : /* @__PURE__ */ jsx(
1431
+ "input",
1432
+ {
1433
+ value: filters[column.key] ?? "",
1434
+ onChange: (event) => changeFilter(column.key, event.target.value),
1435
+ placeholder: `Filter ${column.header.toLowerCase()}`
1436
+ }
1437
+ )
1438
+ ] }, column.key)) })
1439
+ ] }) : null
1440
+ ] });
1441
+ }
1162
1442
  function renderRowActions(item) {
1163
1443
  const key = rowKey(item);
1164
1444
  const updateAllowed = canUpdate ? canUpdate(item) : Boolean(onUpdate);
@@ -1193,66 +1473,45 @@ function RecordWorkspace({
1193
1473
  }
1194
1474
  ) : null
1195
1475
  ] }),
1196
- /* @__PURE__ */ jsxs("div", { className: "row-actions row-actions-mobile", ref: actionsMenuKey === key ? actionsMenuRef : void 0, children: [
1197
- /* @__PURE__ */ jsx(
1198
- "button",
1199
- {
1200
- type: "button",
1201
- className: "ghost row-action-menu-trigger",
1202
- "aria-haspopup": "menu",
1203
- "aria-expanded": actionsMenuKey === key,
1204
- "aria-label": "Row actions",
1205
- onClick: () => setActionsMenuKey((current) => current === key ? null : key),
1206
- children: /* @__PURE__ */ jsx(MoreIcon, {})
1207
- }
1208
- ),
1209
- actionsMenuKey === key ? /* @__PURE__ */ jsxs("div", { className: "row-action-menu", role: "menu", children: [
1210
- onView ? /* @__PURE__ */ jsx(
1211
- "button",
1212
- {
1213
- type: "button",
1214
- role: "menuitem",
1215
- className: "ghost",
1216
- onClick: () => {
1217
- setActionsMenuKey(null);
1218
- onView(item);
1219
- },
1220
- children: "View"
1221
- }
1222
- ) : null,
1223
- onUpdate ? /* @__PURE__ */ jsx(
1224
- "button",
1225
- {
1226
- type: "button",
1227
- role: "menuitem",
1228
- className: "ghost",
1229
- disabled: !updateAllowed,
1230
- onClick: () => {
1231
- setActionsMenuKey(null);
1232
- onUpdate(item);
1233
- },
1234
- children: "Update"
1235
- }
1236
- ) : null,
1237
- onDelete ? /* @__PURE__ */ jsx(
1238
- "button",
1239
- {
1240
- type: "button",
1241
- role: "menuitem",
1242
- className: "ghost danger",
1243
- disabled: !deleteAllowed,
1244
- onClick: () => {
1245
- setActionsMenuKey(null);
1246
- onDelete(item);
1247
- },
1248
- children: "Delete"
1249
- }
1250
- ) : null
1251
- ] }) : null
1252
- ] })
1476
+ /* @__PURE__ */ jsx("div", { className: "row-actions row-actions-mobile", children: /* @__PURE__ */ jsx(
1477
+ "button",
1478
+ {
1479
+ type: "button",
1480
+ className: actionsMenu?.key === key ? "ghost row-action-menu-trigger open" : "ghost row-action-menu-trigger",
1481
+ "aria-haspopup": "menu",
1482
+ "aria-expanded": actionsMenu?.key === key,
1483
+ "aria-label": "Row actions",
1484
+ onClick: (event) => openRowActions(item, event),
1485
+ children: /* @__PURE__ */ jsx(MoreIcon, {})
1486
+ }
1487
+ ) })
1253
1488
  ] });
1254
1489
  }
1255
- return /* @__PURE__ */ jsxs("div", { className: "list-workspace", "aria-label": title, children: [
1490
+ const actionsMenuItem = actionsMenu?.item;
1491
+ const actionsUpdateAllowed = actionsMenuItem ? canUpdate ? canUpdate(actionsMenuItem) : Boolean(onUpdate) : false;
1492
+ const actionsDeleteAllowed = actionsMenuItem ? canDelete ? canDelete(actionsMenuItem) : Boolean(onDelete) : false;
1493
+ return /* @__PURE__ */ jsxs("div", { className: toolsDrawerOpen ? "list-workspace tools-drawer-open" : "list-workspace", "aria-label": title, children: [
1494
+ /* @__PURE__ */ jsxs("div", { className: "tools-mobile-bar", children: [
1495
+ /* @__PURE__ */ jsx("div", { className: "tools-mobile-bar-start", children: showAdd ? /* @__PURE__ */ jsxs("button", { type: "button", className: "tools-mobile-add", onClick: onAdd, children: [
1496
+ /* @__PURE__ */ jsx(PlusIcon, {}),
1497
+ /* @__PURE__ */ jsx("span", { children: addLabel })
1498
+ ] }) : /* @__PURE__ */ jsx("p", { className: "tools-mobile-title", children: title }) }),
1499
+ /* @__PURE__ */ jsxs(
1500
+ "button",
1501
+ {
1502
+ type: "button",
1503
+ className: "ghost tools-mobile-toggle",
1504
+ "aria-expanded": toolsDrawerOpen,
1505
+ "aria-controls": "aksui-tools-drawer",
1506
+ onClick: () => setToolsDrawerOpen(true),
1507
+ children: [
1508
+ /* @__PURE__ */ jsx(ToolsIcon, {}),
1509
+ /* @__PURE__ */ jsx("span", { children: "Tools" }),
1510
+ toolsBadgeCount > 0 ? /* @__PURE__ */ jsx("span", { className: "filter-badge", children: toolsBadgeCount }) : null
1511
+ ]
1512
+ }
1513
+ )
1514
+ ] }),
1256
1515
  /* @__PURE__ */ jsxs(
1257
1516
  "div",
1258
1517
  {
@@ -1295,16 +1554,10 @@ function RecordWorkspace({
1295
1554
  {
1296
1555
  className: selected ? "data-row selected" : "data-row",
1297
1556
  onMouseEnter: (event) => {
1298
- if (!previewEnabled) {
1299
- showTooltip(item, event);
1300
- }
1557
+ showTooltip(item, event);
1301
1558
  focusRecord(item);
1302
1559
  },
1303
- onMouseMove: (event) => {
1304
- if (!previewEnabled) {
1305
- showTooltip(item, event);
1306
- }
1307
- },
1560
+ onMouseMove: (event) => showTooltip(item, event),
1308
1561
  onMouseLeave: () => setTooltip(null),
1309
1562
  onClick: () => focusRecord(item),
1310
1563
  children: [
@@ -1336,7 +1589,7 @@ function RecordWorkspace({
1336
1589
  /* @__PURE__ */ jsx("p", { className: "preview-kicker", children: "Preview" }),
1337
1590
  /* @__PURE__ */ jsx("h3", { children: previewTitle ?? "No record selected" })
1338
1591
  ] }) }),
1339
- /* @__PURE__ */ jsx("div", { className: "preview-panel-body", children: previewItem ? /* @__PURE__ */ jsx(DetailList, { lines: detailLines(previewItem) }) : /* @__PURE__ */ jsx("p", { className: "preview-empty", children: "Hover or click a row to preview its details here." }) })
1592
+ /* @__PURE__ */ jsx("div", { className: "preview-panel-body", children: previewItem ? /* @__PURE__ */ jsx(DetailList, { lines: detailLines(previewItem) }) : /* @__PURE__ */ jsx("p", { className: "preview-empty", children: "Select a row to preview its details here." }) })
1340
1593
  ] }) : null,
1341
1594
  /* @__PURE__ */ jsxs("aside", { className: sideOpen ? "side-rail open" : "side-rail", "aria-label": "Actions and filters", children: [
1342
1595
  /* @__PURE__ */ jsxs(
@@ -1353,210 +1606,102 @@ function RecordWorkspace({
1353
1606
  ]
1354
1607
  }
1355
1608
  ),
1356
- sideOpen ? /* @__PURE__ */ jsxs("div", { className: "side-rail-body", children: [
1357
- /* @__PURE__ */ jsxs("div", { className: "preview-check", children: [
1358
- /* @__PURE__ */ jsx(
1359
- "input",
1360
- {
1361
- type: "checkbox",
1362
- checked: previewEnabled,
1363
- onChange: (event) => setPreviewEnabledValue(event.target.checked),
1364
- "aria-label": "Preview"
1365
- }
1366
- ),
1367
- /* @__PURE__ */ jsx(PreviewIcon, {}),
1368
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "Preview" })
1369
- ] }),
1370
- showAdd ? /* @__PURE__ */ jsxs("button", { type: "button", className: "side-rail-add", onClick: onAdd, children: [
1371
- /* @__PURE__ */ jsx(PlusIcon, {}),
1372
- /* @__PURE__ */ jsx("span", { children: addLabel })
1373
- ] }) : null,
1374
- showColumns ? /* @__PURE__ */ jsxs("div", { className: "side-rail-columns", children: [
1375
- /* @__PURE__ */ jsxs(
1376
- "button",
1377
- {
1378
- type: "button",
1379
- className: "ghost side-rail-columns-toggle",
1380
- "aria-expanded": columnsOpen,
1381
- onClick: () => setColumnsOpen((open) => !open),
1382
- children: [
1383
- /* @__PURE__ */ jsx(ColumnsIcon, {}),
1384
- /* @__PURE__ */ jsxs("span", { children: [
1385
- "Columns",
1386
- hiddenColumnCount > 0 ? ` (${visibleColumns.length}/${columns.length})` : ""
1387
- ] })
1388
- ]
1389
- }
1390
- ),
1391
- columnsOpen ? /* @__PURE__ */ jsxs("div", { className: "side-rail-columns-panel", role: "group", "aria-label": "Visible columns", children: [
1392
- /* @__PURE__ */ jsxs("div", { className: "side-rail-columns-actions", children: [
1393
- /* @__PURE__ */ jsx("button", { type: "button", className: "ghost", onClick: selectAllColumns, children: "Select all" }),
1394
- /* @__PURE__ */ jsx("button", { type: "button", className: "ghost", onClick: resetColumns, children: "Reset" })
1395
- ] }),
1396
- /* @__PURE__ */ jsx("div", { className: "side-rail-columns-list", children: columns.map((column) => {
1397
- const checked = resolvedVisibleKeys.includes(column.key);
1398
- const disableUncheck = checked && resolvedVisibleKeys.length <= 1;
1399
- return /* @__PURE__ */ jsxs("label", { className: "side-rail-column-option", children: [
1400
- /* @__PURE__ */ jsx(
1401
- "input",
1402
- {
1403
- type: "checkbox",
1404
- checked,
1405
- disabled: disableUncheck,
1406
- onChange: (event) => toggleColumnVisible(column.key, event.target.checked)
1407
- }
1408
- ),
1409
- /* @__PURE__ */ jsx("span", { children: column.header })
1410
- ] }, column.key);
1411
- }) })
1412
- ] }) : null
1413
- ] }) : null,
1414
- showDownload ? /* @__PURE__ */ jsxs("div", { className: "side-rail-download", children: [
1415
- /* @__PURE__ */ jsxs(
1416
- "button",
1417
- {
1418
- type: "button",
1419
- className: "ghost side-rail-download-toggle",
1420
- "aria-expanded": downloadOpen,
1421
- disabled: downloadBusy,
1422
- onClick: () => setDownloadOpen((open) => !open),
1423
- children: [
1424
- /* @__PURE__ */ jsx(DownloadIcon, {}),
1425
- /* @__PURE__ */ jsx("span", { children: downloadBusy ? "Downloading\u2026" : "Download" })
1426
- ]
1427
- }
1428
- ),
1429
- downloadOpen ? /* @__PURE__ */ jsx("div", { className: "side-rail-download-formats", role: "group", "aria-label": "Download format", children: EXPORT_FORMAT_OPTIONS.map((option) => /* @__PURE__ */ jsx(
1430
- "button",
1431
- {
1432
- type: "button",
1433
- className: "ghost side-rail-download-format",
1434
- disabled: downloadBusy,
1435
- onClick: () => requestDownload(option.format),
1436
- children: option.label
1437
- },
1438
- option.format
1439
- )) }) : null
1440
- ] }) : null,
1441
- showFilters ? /* @__PURE__ */ jsxs("div", { className: "side-rail-filters", children: [
1442
- /* @__PURE__ */ jsxs("div", { className: "filter-panel-head", children: [
1443
- /* @__PURE__ */ jsx("h3", { children: "Filters" }),
1444
- /* @__PURE__ */ jsxs(
1445
- "button",
1446
- {
1447
- type: "button",
1448
- className: "ghost filter-clear",
1449
- title: "Reset filters",
1450
- "aria-label": "Reset filters",
1451
- disabled: activeFilterCount === 0,
1452
- onClick: clearFilters,
1453
- children: [
1454
- /* @__PURE__ */ jsx(ResetIcon, {}),
1455
- /* @__PURE__ */ jsx("span", { children: "Reset" })
1456
- ]
1457
- }
1458
- )
1459
- ] }),
1460
- /* @__PURE__ */ jsx("div", { className: "filter-panel-stack", children: filterableColumns.map((column) => /* @__PURE__ */ jsxs("label", { children: [
1461
- column.header,
1462
- column.filterOptions ? /* @__PURE__ */ jsx(
1463
- Select,
1464
- {
1465
- value: filters[column.key] ?? "",
1466
- options: [{ value: "", label: column.filterPlaceholder ?? "All" }, ...column.filterOptions],
1467
- onChange: (value) => changeFilter(column.key, value),
1468
- placeholder: column.filterPlaceholder ?? "All"
1469
- }
1470
- ) : /* @__PURE__ */ jsx(
1471
- "input",
1472
- {
1473
- value: filters[column.key] ?? "",
1474
- onChange: (event) => changeFilter(column.key, event.target.value),
1475
- placeholder: `Filter ${column.header.toLowerCase()}`
1476
- }
1477
- )
1478
- ] }, column.key)) })
1479
- ] }) : null
1480
- ] }) : /* @__PURE__ */ jsxs("div", { className: "side-rail-icons", children: [
1481
- /* @__PURE__ */ jsxs("label", { className: "side-rail-icon preview-check-icon", title: "Preview", children: [
1482
- /* @__PURE__ */ jsx(
1483
- "input",
1484
- {
1485
- type: "checkbox",
1486
- checked: previewEnabled,
1487
- onChange: (event) => setPreviewEnabledValue(event.target.checked),
1488
- "aria-label": "Preview"
1489
- }
1490
- ),
1491
- /* @__PURE__ */ jsx(PreviewIcon, {})
1492
- ] }),
1493
- showAdd ? /* @__PURE__ */ jsx("button", { type: "button", className: "ghost side-rail-icon", title: addLabel, "aria-label": addLabel, onClick: onAdd, children: /* @__PURE__ */ jsx(PlusIcon, {}) }) : null,
1494
- showColumns ? /* @__PURE__ */ jsxs(
1495
- "button",
1496
- {
1497
- type: "button",
1498
- className: "ghost side-rail-icon",
1499
- title: "Columns",
1500
- "aria-label": "Columns",
1501
- onClick: () => {
1502
- setSideOpen(true);
1503
- setColumnsOpen(true);
1504
- },
1505
- children: [
1506
- /* @__PURE__ */ jsx(ColumnsIcon, {}),
1507
- hiddenColumnCount > 0 ? /* @__PURE__ */ jsx("span", { className: "filter-badge", children: hiddenColumnCount }) : null
1508
- ]
1509
- }
1510
- ) : null,
1511
- showDownload ? /* @__PURE__ */ jsx(
1512
- "button",
1513
- {
1514
- type: "button",
1515
- className: "ghost side-rail-icon",
1516
- title: "Download",
1517
- "aria-label": "Download",
1518
- "aria-expanded": downloadOpen,
1519
- disabled: downloadBusy,
1520
- onClick: () => {
1521
- setSideOpen(true);
1522
- setDownloadOpen(true);
1523
- },
1524
- children: /* @__PURE__ */ jsx(DownloadIcon, {})
1525
- }
1526
- ) : null,
1527
- showFilters ? /* @__PURE__ */ jsxs(
1528
- "button",
1529
- {
1530
- type: "button",
1531
- className: "ghost side-rail-icon",
1532
- title: "Show filters",
1533
- "aria-label": "Show filters",
1534
- onClick: () => setSideOpen(true),
1535
- children: [
1536
- /* @__PURE__ */ jsx(FilterIcon, {}),
1537
- activeFilterCount > 0 ? /* @__PURE__ */ jsx("span", { className: "filter-badge", children: activeFilterCount }) : null
1538
- ]
1539
- }
1540
- ) : null,
1541
- showFilters ? /* @__PURE__ */ jsx(
1542
- "button",
1543
- {
1544
- type: "button",
1545
- className: "ghost side-rail-icon",
1546
- title: "Reset filters",
1547
- "aria-label": "Reset filters",
1548
- disabled: activeFilterCount === 0,
1549
- onClick: clearFilters,
1550
- children: /* @__PURE__ */ jsx(ResetIcon, {})
1551
- }
1552
- ) : null
1553
- ] })
1609
+ sideOpen ? renderToolsBody({ compactIcons: false }) : renderToolsBody({ compactIcons: true })
1554
1610
  ] })
1555
1611
  ]
1556
1612
  }
1557
1613
  ),
1614
+ isClient ? createPortal(
1615
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1616
+ /* @__PURE__ */ jsx(
1617
+ "button",
1618
+ {
1619
+ type: "button",
1620
+ className: toolsDrawerOpen ? "tools-drawer-backdrop open" : "tools-drawer-backdrop",
1621
+ "aria-label": "Close tools",
1622
+ tabIndex: toolsDrawerOpen ? 0 : -1,
1623
+ onClick: () => setToolsDrawerOpen(false)
1624
+ }
1625
+ ),
1626
+ /* @__PURE__ */ jsxs(
1627
+ "aside",
1628
+ {
1629
+ id: "aksui-tools-drawer",
1630
+ className: toolsDrawerOpen ? "tools-drawer open" : "tools-drawer",
1631
+ "aria-label": "Workspace tools",
1632
+ "aria-hidden": !toolsDrawerOpen,
1633
+ children: [
1634
+ /* @__PURE__ */ jsxs("div", { className: "tools-drawer-head", children: [
1635
+ /* @__PURE__ */ jsxs("div", { children: [
1636
+ /* @__PURE__ */ jsx("p", { className: "tools-drawer-kicker", children: "Workspace" }),
1637
+ /* @__PURE__ */ jsx("h3", { children: "Tools" })
1638
+ ] }),
1639
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ghost tools-drawer-close", onClick: () => setToolsDrawerOpen(false), children: "Close" })
1640
+ ] }),
1641
+ /* @__PURE__ */ jsx("div", { className: "tools-drawer-body", children: renderToolsBody({ compactIcons: false }) })
1642
+ ]
1643
+ }
1644
+ )
1645
+ ] }),
1646
+ document.body
1647
+ ) : null,
1558
1648
  form,
1559
- isClient && tooltip && !previewEnabled ? createPortal(
1649
+ isClient && actionsMenu && actionsMenuItem ? createPortal(
1650
+ /* @__PURE__ */ jsxs(
1651
+ "div",
1652
+ {
1653
+ ref: actionsMenuRef,
1654
+ className: "row-action-menu row-action-menu-portal",
1655
+ role: "menu",
1656
+ style: { left: actionsMenu.x, top: actionsMenu.y },
1657
+ children: [
1658
+ onView ? /* @__PURE__ */ jsx(
1659
+ "button",
1660
+ {
1661
+ type: "button",
1662
+ role: "menuitem",
1663
+ className: "ghost",
1664
+ onClick: () => {
1665
+ setActionsMenu(null);
1666
+ onView(actionsMenuItem);
1667
+ },
1668
+ children: "View"
1669
+ }
1670
+ ) : null,
1671
+ onUpdate ? /* @__PURE__ */ jsx(
1672
+ "button",
1673
+ {
1674
+ type: "button",
1675
+ role: "menuitem",
1676
+ className: "ghost",
1677
+ disabled: !actionsUpdateAllowed,
1678
+ onClick: () => {
1679
+ setActionsMenu(null);
1680
+ onUpdate(actionsMenuItem);
1681
+ },
1682
+ children: "Update"
1683
+ }
1684
+ ) : null,
1685
+ onDelete ? /* @__PURE__ */ jsx(
1686
+ "button",
1687
+ {
1688
+ type: "button",
1689
+ role: "menuitem",
1690
+ className: "ghost danger",
1691
+ disabled: !actionsDeleteAllowed,
1692
+ onClick: () => {
1693
+ setActionsMenu(null);
1694
+ onDelete(actionsMenuItem);
1695
+ },
1696
+ children: "Delete"
1697
+ }
1698
+ ) : null
1699
+ ]
1700
+ }
1701
+ ),
1702
+ document.body
1703
+ ) : null,
1704
+ isClient && tooltip && canShowTooltip ? createPortal(
1560
1705
  /* @__PURE__ */ jsxs("div", { className: "record-tooltip", style: { left: tooltip.x, top: tooltip.y }, role: "tooltip", children: [
1561
1706
  /* @__PURE__ */ jsx("p", { className: "record-tooltip-title", children: title }),
1562
1707
  /* @__PURE__ */ jsx(DetailList, { lines: tooltip.lines })