@bwp-web/components 1.9.3 → 1.9.5

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
@@ -749,7 +749,7 @@ function BiampSidebarIcon({
749
749
  const { expanded } = useContext2(BiampSidebarContext);
750
750
  const layoutDrawer = useBiampLayoutDrawer();
751
751
  const displayedSelectedIcon = selectedIcon ?? icon;
752
- return /* @__PURE__ */ jsx3(Tooltip, { title: expanded ? "" : name ?? "", placement: "right", arrow: true, children: /* @__PURE__ */ jsxs3(
752
+ return /* @__PURE__ */ jsxs3(
753
753
  ListItemButton,
754
754
  {
755
755
  selected,
@@ -779,17 +779,26 @@ function BiampSidebarIcon({
779
779
  ...props,
780
780
  children: [
781
781
  /* @__PURE__ */ jsx3(
782
- Box2,
782
+ Tooltip,
783
783
  {
784
- sx: {
785
- width: "48px",
786
- height: "48px",
787
- display: "flex",
788
- alignItems: "center",
789
- justifyContent: "center",
790
- flexShrink: 0
791
- },
792
- children: selected ? displayedSelectedIcon : icon
784
+ title: expanded ? "" : name ?? "",
785
+ placement: "right",
786
+ arrow: true,
787
+ disableInteractive: true,
788
+ children: /* @__PURE__ */ jsx3(
789
+ Box2,
790
+ {
791
+ sx: {
792
+ width: "48px",
793
+ height: "48px",
794
+ display: "flex",
795
+ alignItems: "center",
796
+ justifyContent: "center",
797
+ flexShrink: 0
798
+ },
799
+ children: selected ? displayedSelectedIcon : icon
800
+ }
801
+ )
793
802
  }
794
803
  ),
795
804
  name && /* @__PURE__ */ jsx3(
@@ -811,7 +820,7 @@ function BiampSidebarIcon({
811
820
  )
812
821
  ]
813
822
  }
814
- ) });
823
+ );
815
824
  }
816
825
  function BiampSidebarComponent({
817
826
  children,
@@ -2507,7 +2516,18 @@ function BiampTableColumnVisibility({
2507
2516
  slotProps,
2508
2517
  ...popoverProps
2509
2518
  }) {
2510
- const allVisible = table.getAllLeafColumns().every((col) => col.getIsVisible());
2519
+ const hideableColumns = table.getAllLeafColumns().filter((col) => col.getCanHide() && !col.columnDef.meta?.alwaysShow);
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
+ };
2511
2531
  return /* @__PURE__ */ jsx15(
2512
2532
  Popover2,
2513
2533
  {
@@ -2530,30 +2550,22 @@ function BiampTableColumnVisibility({
2530
2550
  },
2531
2551
  ...popoverProps,
2532
2552
  children: /* @__PURE__ */ jsxs9(List, { dense: true, disablePadding: true, children: [
2533
- /* @__PURE__ */ jsxs9(
2534
- ListItem,
2535
- {
2536
- dense: true,
2537
- sx: columnListItemSx,
2538
- onClick: () => table.toggleAllColumnsVisible(!allVisible),
2539
- children: [
2540
- /* @__PURE__ */ jsx15(
2541
- Checkbox3,
2542
- {
2543
- checked: allVisible,
2544
- slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
2545
- }
2546
- ),
2547
- /* @__PURE__ */ jsx15(Typography5, { variant: "caption", fontWeight: 600, children: showAllLabel })
2548
- ]
2549
- }
2550
- ),
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
+ ] }),
2551
2563
  /* @__PURE__ */ jsx15(Divider2, {}),
2552
2564
  /* @__PURE__ */ jsx15(
2553
2565
  Box9,
2554
2566
  {
2555
2567
  sx: { maxHeight: 340, overflow: "auto", overscrollBehavior: "none" },
2556
- children: table.getAllLeafColumns().map((column) => {
2568
+ children: hideableColumns.map((column) => {
2557
2569
  const columnName = column.columnDef.meta?.columnLabel ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
2558
2570
  return /* @__PURE__ */ jsxs9(
2559
2571
  ListItem,
@@ -3222,6 +3234,15 @@ function getDefaultColumnVisibilityFromDefs(columns) {
3222
3234
  }
3223
3235
  return defaults;
3224
3236
  }
3237
+ function getAlwaysShowColumnIds(columns) {
3238
+ const ids = [];
3239
+ for (const col of columns) {
3240
+ if (col.id != null && col.meta?.alwaysShow) {
3241
+ ids.push(col.id);
3242
+ }
3243
+ }
3244
+ return ids;
3245
+ }
3225
3246
  function getDirtyColumnVisibility(visibility, defaults) {
3226
3247
  const dirty = {};
3227
3248
  for (const [id, visible] of Object.entries(visibility)) {
@@ -3255,9 +3276,15 @@ function useBiampServerSideTable({
3255
3276
  onExpandedChange,
3256
3277
  getSubRows
3257
3278
  }) {
3258
- const { defaultColumnVisibility, columnIdToField, fieldToColumnId } = useMemo2(
3279
+ const {
3280
+ defaultColumnVisibility,
3281
+ alwaysShowColumnIds,
3282
+ columnIdToField,
3283
+ fieldToColumnId
3284
+ } = useMemo2(
3259
3285
  () => ({
3260
3286
  defaultColumnVisibility: getDefaultColumnVisibilityFromDefs(columns),
3287
+ alwaysShowColumnIds: getAlwaysShowColumnIds(columns),
3261
3288
  ...getOrderFieldMappings(columns)
3262
3289
  }),
3263
3290
  [columns]
@@ -3276,13 +3303,16 @@ function useBiampServerSideTable({
3276
3303
  () => hasSelection ? selectedIdsToRowSelection(selectedRowIds) : void 0,
3277
3304
  [hasSelection, selectedRowIds]
3278
3305
  );
3279
- const mergedVisibility = useMemo2(
3280
- () => toVisibilityState({
3306
+ const mergedVisibility = useMemo2(() => {
3307
+ const merged = {
3281
3308
  ...defaultColumnVisibility,
3282
3309
  ...columnVisibility
3283
- }),
3284
- [defaultColumnVisibility, columnVisibility]
3285
- );
3310
+ };
3311
+ for (const id of alwaysShowColumnIds) {
3312
+ merged[id] = true;
3313
+ }
3314
+ return toVisibilityState(merged);
3315
+ }, [defaultColumnVisibility, columnVisibility, alwaysShowColumnIds]);
3286
3316
  return useReactTable({
3287
3317
  data,
3288
3318
  columns,
@@ -3319,9 +3349,11 @@ function useBiampServerSideTable({
3319
3349
  // Column visibility
3320
3350
  onColumnVisibilityChange: onColumnVisibilityChange ? (updater) => {
3321
3351
  const next = typeof updater === "function" ? updater(mergedVisibility) : updater;
3322
- onColumnVisibilityChange(
3323
- getDirtyColumnVisibility(next, defaultColumnVisibility)
3324
- );
3352
+ const dirty = getDirtyColumnVisibility(next, defaultColumnVisibility);
3353
+ for (const id of alwaysShowColumnIds) {
3354
+ delete dirty[id];
3355
+ }
3356
+ onColumnVisibilityChange(dirty);
3325
3357
  } : void 0,
3326
3358
  // Row selection — only when selectedRowIds is provided
3327
3359
  ...hasSelection && {
@@ -4006,6 +4038,7 @@ export {
4006
4038
  buildCsvString,
4007
4039
  clearDynamicSvgIconCache,
4008
4040
  exportToCsv,
4041
+ getAlwaysShowColumnIds,
4009
4042
  getColumnVisibilityDirtyCount,
4010
4043
  getDefaultColumnVisibility,
4011
4044
  getDefaultColumnVisibilityFromDefs,