@bwp-web/components 1.9.4 → 1.9.6

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
@@ -2516,7 +2516,18 @@ function BiampTableColumnVisibility({
2516
2516
  slotProps,
2517
2517
  ...popoverProps
2518
2518
  }) {
2519
- const allVisible = table.getAllLeafColumns().every((col) => col.getIsVisible());
2519
+ const hideableColumns = table.getAllLeafColumns().filter((col) => col.getCanHide());
2520
+ const allVisible = hideableColumns.every((col) => col.getIsVisible());
2521
+ const toggleAllHideable = () => {
2522
+ const next = !allVisible;
2523
+ table.setColumnVisibility((prev) => {
2524
+ const updated = { ...prev };
2525
+ for (const col of hideableColumns) {
2526
+ updated[col.id] = next;
2527
+ }
2528
+ return updated;
2529
+ });
2530
+ };
2520
2531
  return /* @__PURE__ */ jsx15(
2521
2532
  Popover2,
2522
2533
  {
@@ -2539,30 +2550,22 @@ function BiampTableColumnVisibility({
2539
2550
  },
2540
2551
  ...popoverProps,
2541
2552
  children: /* @__PURE__ */ jsxs9(List, { dense: true, disablePadding: true, children: [
2542
- /* @__PURE__ */ jsxs9(
2543
- ListItem,
2544
- {
2545
- dense: true,
2546
- sx: columnListItemSx,
2547
- onClick: () => table.toggleAllColumnsVisible(!allVisible),
2548
- children: [
2549
- /* @__PURE__ */ jsx15(
2550
- Checkbox3,
2551
- {
2552
- checked: allVisible,
2553
- slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
2554
- }
2555
- ),
2556
- /* @__PURE__ */ jsx15(Typography5, { variant: "caption", fontWeight: 600, children: showAllLabel })
2557
- ]
2558
- }
2559
- ),
2553
+ /* @__PURE__ */ jsxs9(ListItem, { dense: true, sx: columnListItemSx, onClick: toggleAllHideable, children: [
2554
+ /* @__PURE__ */ jsx15(
2555
+ Checkbox3,
2556
+ {
2557
+ checked: allVisible,
2558
+ slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
2559
+ }
2560
+ ),
2561
+ /* @__PURE__ */ jsx15(Typography5, { variant: "caption", fontWeight: 600, children: showAllLabel })
2562
+ ] }),
2560
2563
  /* @__PURE__ */ jsx15(Divider2, {}),
2561
2564
  /* @__PURE__ */ jsx15(
2562
2565
  Box9,
2563
2566
  {
2564
2567
  sx: { maxHeight: 340, overflow: "auto", overscrollBehavior: "none" },
2565
- children: table.getAllLeafColumns().map((column) => {
2568
+ children: hideableColumns.map((column) => {
2566
2569
  const columnName = column.columnDef.meta?.columnLabel ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
2567
2570
  return /* @__PURE__ */ jsxs9(
2568
2571
  ListItem,
@@ -3231,6 +3234,15 @@ function getDefaultColumnVisibilityFromDefs(columns) {
3231
3234
  }
3232
3235
  return defaults;
3233
3236
  }
3237
+ function getNonHideableColumnIds(columns) {
3238
+ const ids = [];
3239
+ for (const col of columns) {
3240
+ if (col.id != null && col.enableHiding === false) {
3241
+ ids.push(col.id);
3242
+ }
3243
+ }
3244
+ return ids;
3245
+ }
3234
3246
  function getDirtyColumnVisibility(visibility, defaults) {
3235
3247
  const dirty = {};
3236
3248
  for (const [id, visible] of Object.entries(visibility)) {
@@ -3264,9 +3276,15 @@ function useBiampServerSideTable({
3264
3276
  onExpandedChange,
3265
3277
  getSubRows
3266
3278
  }) {
3267
- const { defaultColumnVisibility, columnIdToField, fieldToColumnId } = useMemo2(
3279
+ const {
3280
+ defaultColumnVisibility,
3281
+ nonHideableColumnIds,
3282
+ columnIdToField,
3283
+ fieldToColumnId
3284
+ } = useMemo2(
3268
3285
  () => ({
3269
3286
  defaultColumnVisibility: getDefaultColumnVisibilityFromDefs(columns),
3287
+ nonHideableColumnIds: getNonHideableColumnIds(columns),
3270
3288
  ...getOrderFieldMappings(columns)
3271
3289
  }),
3272
3290
  [columns]
@@ -3285,13 +3303,16 @@ function useBiampServerSideTable({
3285
3303
  () => hasSelection ? selectedIdsToRowSelection(selectedRowIds) : void 0,
3286
3304
  [hasSelection, selectedRowIds]
3287
3305
  );
3288
- const mergedVisibility = useMemo2(
3289
- () => toVisibilityState({
3306
+ const mergedVisibility = useMemo2(() => {
3307
+ const merged = {
3290
3308
  ...defaultColumnVisibility,
3291
3309
  ...columnVisibility
3292
- }),
3293
- [defaultColumnVisibility, columnVisibility]
3294
- );
3310
+ };
3311
+ for (const id of nonHideableColumnIds) {
3312
+ merged[id] = true;
3313
+ }
3314
+ return toVisibilityState(merged);
3315
+ }, [defaultColumnVisibility, columnVisibility, nonHideableColumnIds]);
3295
3316
  return useReactTable({
3296
3317
  data,
3297
3318
  columns,
@@ -3328,9 +3349,11 @@ function useBiampServerSideTable({
3328
3349
  // Column visibility
3329
3350
  onColumnVisibilityChange: onColumnVisibilityChange ? (updater) => {
3330
3351
  const next = typeof updater === "function" ? updater(mergedVisibility) : updater;
3331
- onColumnVisibilityChange(
3332
- getDirtyColumnVisibility(next, defaultColumnVisibility)
3333
- );
3352
+ const dirty = getDirtyColumnVisibility(next, defaultColumnVisibility);
3353
+ for (const id of nonHideableColumnIds) {
3354
+ delete dirty[id];
3355
+ }
3356
+ onColumnVisibilityChange(dirty);
3334
3357
  } : void 0,
3335
3358
  // Row selection — only when selectedRowIds is provided
3336
3359
  ...hasSelection && {
@@ -4019,6 +4042,7 @@ export {
4019
4042
  getDefaultColumnVisibility,
4020
4043
  getDefaultColumnVisibilityFromDefs,
4021
4044
  getDirtyColumnVisibility,
4045
+ getNonHideableColumnIds,
4022
4046
  getOrderFieldMappings,
4023
4047
  orderToSorting,
4024
4048
  rowSelectionToSelectedIds,