asma-ui-table 1.1.14 → 1.1.15

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.
@@ -7987,7 +7987,31 @@ const usePersistedColumnOrder = (persistColumnOrderKey) => {
7987
7987
  }, [persistColumnOrderKey]);
7988
7988
  return persistedColumnOrder;
7989
7989
  };
7990
+ const pageSizeStorageKeySuffix = ":page-size";
7991
+ const getPersistedPageSizeKey = (uniqueKey) => {
7992
+ if (!uniqueKey)
7993
+ return void 0;
7994
+ return `${uniqueKey}${pageSizeStorageKeySuffix}`;
7995
+ };
7996
+ const usePersistedPageSize = (uniqueKey) => {
7997
+ const persistedPageSize = useMemo(() => {
7998
+ const storageKey = getPersistedPageSizeKey(uniqueKey);
7999
+ if (!storageKey)
8000
+ return void 0;
8001
+ try {
8002
+ const raw = localStorage.getItem(storageKey);
8003
+ if (!raw)
8004
+ return void 0;
8005
+ const parsed = JSON.parse(raw);
8006
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
8007
+ } catch {
8008
+ return void 0;
8009
+ }
8010
+ }, [uniqueKey]);
8011
+ return persistedPageSize;
8012
+ };
7990
8013
  const useStyledTable = (props) => {
8014
+ var _a;
7991
8015
  const {
7992
8016
  columns,
7993
8017
  data,
@@ -7997,16 +8021,18 @@ const useStyledTable = (props) => {
7997
8021
  tableInstanceRef,
7998
8022
  locale,
7999
8023
  persistColumnOrderKey,
8024
+ uniqueKey,
8000
8025
  ...rest
8001
8026
  } = props;
8002
8027
  const columnOrder = usePersistedColumnOrder(persistColumnOrderKey);
8028
+ const persistedPageSize = usePersistedPageSize(uniqueKey);
8003
8029
  const table = useReactTable({
8004
8030
  _features: [ExpandedRowsFeature, FocusedRowsFeature, OrderColumnsFeature],
8005
8031
  columns,
8006
8032
  data,
8007
8033
  meta: { locale: locale ?? "en" },
8008
8034
  initialState: {
8009
- pagination: { pageIndex: 0, pageSize: pageSize || 50 },
8035
+ pagination: { pageIndex: 0, pageSize: persistedPageSize ?? pageSize ?? 50 },
8010
8036
  columnVisibility: {
8011
8037
  ...initialState == null ? void 0 : initialState.columnVisibility,
8012
8038
  [SELECT_COLUMN_ID]: false
@@ -8031,6 +8057,17 @@ const useStyledTable = (props) => {
8031
8057
  tableInstanceRef.current = table;
8032
8058
  }
8033
8059
  usePersistColumnOrder(table, persistColumnOrderKey);
8060
+ const pageSizeState = (_a = table.getState().pagination) == null ? void 0 : _a.pageSize;
8061
+ useEffect(() => {
8062
+ const storageKey = getPersistedPageSizeKey(uniqueKey);
8063
+ if (!storageKey || !pageSizeState)
8064
+ return;
8065
+ try {
8066
+ localStorage.setItem(storageKey, JSON.stringify(pageSizeState));
8067
+ } catch (e) {
8068
+ console.error(e);
8069
+ }
8070
+ }, [pageSizeState, uniqueKey]);
8034
8071
  return { table };
8035
8072
  };
8036
8073
  const CheckboxWrapper = "_CheckboxWrapper_1b4zf_1";
@@ -9820,7 +9857,7 @@ const outlined = "_outlined_gteum_141";
9820
9857
  const text = "_text_gteum_255";
9821
9858
  const textGray = "_textGray_gteum_369";
9822
9859
  const textWhite = "_textWhite_gteum_426";
9823
- const style$4 = {
9860
+ const style$3 = {
9824
9861
  "asma-core-ui-button": "_asma-core-ui-button_gteum_1",
9825
9862
  contained,
9826
9863
  common: common$2,
@@ -9834,16 +9871,16 @@ const style$4 = {
9834
9871
  textWhite
9835
9872
  };
9836
9873
  const BtnStyles = {
9837
- contained: style$4["contained"],
9838
- outlined: style$4["outlined"],
9839
- text: style$4["text"],
9840
- textGray: style$4["textGray"],
9841
- textWhite: style$4["textWhite"],
9842
- large: style$4["large"],
9843
- small: style$4["small"],
9844
- medium: style$4["medium"],
9845
- error: style$4["error"],
9846
- common: style$4["common"]
9874
+ contained: style$3["contained"],
9875
+ outlined: style$3["outlined"],
9876
+ text: style$3["text"],
9877
+ textGray: style$3["textGray"],
9878
+ textWhite: style$3["textWhite"],
9879
+ large: style$3["large"],
9880
+ small: style$3["small"],
9881
+ medium: style$3["medium"],
9882
+ error: style$3["error"],
9883
+ common: style$3["common"]
9847
9884
  };
9848
9885
  const StyledButton = ({
9849
9886
  variant = "contained",
@@ -9864,7 +9901,7 @@ const StyledButton = ({
9864
9901
  {
9865
9902
  ...otherProps,
9866
9903
  className: clsx(
9867
- style$4["asma-core-ui-button"],
9904
+ style$3["asma-core-ui-button"],
9868
9905
  BtnStyles[variant],
9869
9906
  BtnStyles[color2],
9870
9907
  BtnStyles[size],
@@ -10702,7 +10739,7 @@ function getStyleValue(themeMapping, transform, propValueFinal, userValue = prop
10702
10739
  }
10703
10740
  return value;
10704
10741
  }
10705
- function style$3(options) {
10742
+ function style$2(options) {
10706
10743
  const {
10707
10744
  prop,
10708
10745
  cssProperty = options.prop,
@@ -10850,12 +10887,12 @@ function resolveCssProperty(props, keys, prop, transformer) {
10850
10887
  const propValue = props[prop];
10851
10888
  return handleBreakpoints(props, propValue, styleFromPropValue);
10852
10889
  }
10853
- function style$2(props, keys) {
10890
+ function style$1(props, keys) {
10854
10891
  const transformer = createUnarySpacing(props.theme);
10855
10892
  return Object.keys(props).map((prop) => resolveCssProperty(props, keys, prop, transformer)).reduce(merge, {});
10856
10893
  }
10857
10894
  function margin(props) {
10858
- return style$2(props, marginKeys);
10895
+ return style$1(props, marginKeys);
10859
10896
  }
10860
10897
  margin.propTypes = process.env.NODE_ENV !== "production" ? marginKeys.reduce((obj, key) => {
10861
10898
  obj[key] = responsivePropType$1;
@@ -10863,7 +10900,7 @@ margin.propTypes = process.env.NODE_ENV !== "production" ? marginKeys.reduce((ob
10863
10900
  }, {}) : {};
10864
10901
  margin.filterProps = marginKeys;
10865
10902
  function padding(props) {
10866
- return style$2(props, paddingKeys);
10903
+ return style$1(props, paddingKeys);
10867
10904
  }
10868
10905
  padding.propTypes = process.env.NODE_ENV !== "production" ? paddingKeys.reduce((obj, key) => {
10869
10906
  obj[key] = responsivePropType$1;
@@ -10921,48 +10958,48 @@ function borderTransform(value) {
10921
10958
  }
10922
10959
  return `${value}px solid`;
10923
10960
  }
10924
- const border = style$3({
10961
+ const border = style$2({
10925
10962
  prop: "border",
10926
10963
  themeKey: "borders",
10927
10964
  transform: borderTransform
10928
10965
  });
10929
- const borderTop = style$3({
10966
+ const borderTop = style$2({
10930
10967
  prop: "borderTop",
10931
10968
  themeKey: "borders",
10932
10969
  transform: borderTransform
10933
10970
  });
10934
- const borderRight = style$3({
10971
+ const borderRight = style$2({
10935
10972
  prop: "borderRight",
10936
10973
  themeKey: "borders",
10937
10974
  transform: borderTransform
10938
10975
  });
10939
- const borderBottom = style$3({
10976
+ const borderBottom = style$2({
10940
10977
  prop: "borderBottom",
10941
10978
  themeKey: "borders",
10942
10979
  transform: borderTransform
10943
10980
  });
10944
- const borderLeft = style$3({
10981
+ const borderLeft = style$2({
10945
10982
  prop: "borderLeft",
10946
10983
  themeKey: "borders",
10947
10984
  transform: borderTransform
10948
10985
  });
10949
- const borderColor = style$3({
10986
+ const borderColor = style$2({
10950
10987
  prop: "borderColor",
10951
10988
  themeKey: "palette"
10952
10989
  });
10953
- const borderTopColor = style$3({
10990
+ const borderTopColor = style$2({
10954
10991
  prop: "borderTopColor",
10955
10992
  themeKey: "palette"
10956
10993
  });
10957
- const borderRightColor = style$3({
10994
+ const borderRightColor = style$2({
10958
10995
  prop: "borderRightColor",
10959
10996
  themeKey: "palette"
10960
10997
  });
10961
- const borderBottomColor = style$3({
10998
+ const borderBottomColor = style$2({
10962
10999
  prop: "borderBottomColor",
10963
11000
  themeKey: "palette"
10964
11001
  });
10965
- const borderLeftColor = style$3({
11002
+ const borderLeftColor = style$2({
10966
11003
  prop: "borderLeftColor",
10967
11004
  themeKey: "palette"
10968
11005
  });
@@ -11023,31 +11060,31 @@ rowGap.propTypes = process.env.NODE_ENV !== "production" ? {
11023
11060
  rowGap: responsivePropType$1
11024
11061
  } : {};
11025
11062
  rowGap.filterProps = ["rowGap"];
11026
- const gridColumn = style$3({
11063
+ const gridColumn = style$2({
11027
11064
  prop: "gridColumn"
11028
11065
  });
11029
- const gridRow = style$3({
11066
+ const gridRow = style$2({
11030
11067
  prop: "gridRow"
11031
11068
  });
11032
- const gridAutoFlow = style$3({
11069
+ const gridAutoFlow = style$2({
11033
11070
  prop: "gridAutoFlow"
11034
11071
  });
11035
- const gridAutoColumns = style$3({
11072
+ const gridAutoColumns = style$2({
11036
11073
  prop: "gridAutoColumns"
11037
11074
  });
11038
- const gridAutoRows = style$3({
11075
+ const gridAutoRows = style$2({
11039
11076
  prop: "gridAutoRows"
11040
11077
  });
11041
- const gridTemplateColumns = style$3({
11078
+ const gridTemplateColumns = style$2({
11042
11079
  prop: "gridTemplateColumns"
11043
11080
  });
11044
- const gridTemplateRows = style$3({
11081
+ const gridTemplateRows = style$2({
11045
11082
  prop: "gridTemplateRows"
11046
11083
  });
11047
- const gridTemplateAreas = style$3({
11084
+ const gridTemplateAreas = style$2({
11048
11085
  prop: "gridTemplateAreas"
11049
11086
  });
11050
- const gridArea = style$3({
11087
+ const gridArea = style$2({
11051
11088
  prop: "gridArea"
11052
11089
  });
11053
11090
  compose(gap, columnGap, rowGap, gridColumn, gridRow, gridAutoFlow, gridAutoColumns, gridAutoRows, gridTemplateColumns, gridTemplateRows, gridTemplateAreas, gridArea);
@@ -11057,18 +11094,18 @@ function paletteTransform(value, userValue) {
11057
11094
  }
11058
11095
  return value;
11059
11096
  }
11060
- const color = style$3({
11097
+ const color = style$2({
11061
11098
  prop: "color",
11062
11099
  themeKey: "palette",
11063
11100
  transform: paletteTransform
11064
11101
  });
11065
- const bgcolor = style$3({
11102
+ const bgcolor = style$2({
11066
11103
  prop: "bgcolor",
11067
11104
  cssProperty: "backgroundColor",
11068
11105
  themeKey: "palette",
11069
11106
  transform: paletteTransform
11070
11107
  });
11071
- const backgroundColor = style$3({
11108
+ const backgroundColor = style$2({
11072
11109
  prop: "backgroundColor",
11073
11110
  themeKey: "palette",
11074
11111
  transform: paletteTransform
@@ -11077,7 +11114,7 @@ compose(color, bgcolor, backgroundColor);
11077
11114
  function sizingTransform(value) {
11078
11115
  return value <= 1 && value !== 0 ? `${value * 100}%` : value;
11079
11116
  }
11080
- const width = style$3({
11117
+ const width = style$2({
11081
11118
  prop: "width",
11082
11119
  transform: sizingTransform
11083
11120
  });
@@ -11095,33 +11132,33 @@ const maxWidth = (props) => {
11095
11132
  return null;
11096
11133
  };
11097
11134
  maxWidth.filterProps = ["maxWidth"];
11098
- const minWidth = style$3({
11135
+ const minWidth = style$2({
11099
11136
  prop: "minWidth",
11100
11137
  transform: sizingTransform
11101
11138
  });
11102
- const height = style$3({
11139
+ const height = style$2({
11103
11140
  prop: "height",
11104
11141
  transform: sizingTransform
11105
11142
  });
11106
- const maxHeight = style$3({
11143
+ const maxHeight = style$2({
11107
11144
  prop: "maxHeight",
11108
11145
  transform: sizingTransform
11109
11146
  });
11110
- const minHeight = style$3({
11147
+ const minHeight = style$2({
11111
11148
  prop: "minHeight",
11112
11149
  transform: sizingTransform
11113
11150
  });
11114
- style$3({
11151
+ style$2({
11115
11152
  prop: "size",
11116
11153
  cssProperty: "width",
11117
11154
  transform: sizingTransform
11118
11155
  });
11119
- style$3({
11156
+ style$2({
11120
11157
  prop: "size",
11121
11158
  cssProperty: "height",
11122
11159
  transform: sizingTransform
11123
11160
  });
11124
- const boxSizing = style$3({
11161
+ const boxSizing = style$2({
11125
11162
  prop: "boxSizing"
11126
11163
  });
11127
11164
  compose(width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing);
@@ -13105,7 +13142,7 @@ const selected = "_selected_cs6m8_190";
13105
13142
  const shadowed = "_shadowed_cs6m8_210";
13106
13143
  const resizer = "_resizer_cs6m8_243";
13107
13144
  const isResizing = "_isResizing_cs6m8_255";
13108
- const style$1 = {
13145
+ const style = {
13109
13146
  "asma-ui-table-styled-table": "_asma-ui-table-styled-table_cs6m8_1",
13110
13147
  "table-wrapper": "_table-wrapper_cs6m8_22",
13111
13148
  "table-shell": "_table-shell_cs6m8_29",
@@ -13227,12 +13264,12 @@ function TableHeaderCell({
13227
13264
  ref,
13228
13265
  colSpan: header.colSpan,
13229
13266
  className: clsx(
13230
- style$1["t-cell"],
13231
- hideHeader && style$1["hide-header"],
13267
+ style["t-cell"],
13268
+ hideHeader && style["hide-header"],
13232
13269
  // *
13233
13270
  // sticky actions
13234
- header.column.id === ACTIONS_COLUMN_ID && style$1["t-cell__actions"],
13235
- isFixed2 && style$1["t-cell__fixed"]
13271
+ header.column.id === ACTIONS_COLUMN_ID && style["t-cell__actions"],
13272
+ isFixed2 && style["t-cell__fixed"]
13236
13273
  ),
13237
13274
  style: {
13238
13275
  ...getTableHeaderStyle({ enableResizing, header, element: ref.current, tableWidth }),
@@ -13243,8 +13280,8 @@ function TableHeaderCell({
13243
13280
  {
13244
13281
  className: clsx(
13245
13282
  "flex items-center justify-left",
13246
- hideHeader ? style$1["hide-table-header"] : style$1["show-table-header"],
13247
- header.column.getCanSort() && style$1["sortable-column"],
13283
+ hideHeader ? style["hide-table-header"] : style["show-table-header"],
13284
+ header.column.getCanSort() && style["sortable-column"],
13248
13285
  header.column.columnDef.className
13249
13286
  ),
13250
13287
  onClick: (e) => {
@@ -13257,8 +13294,8 @@ function TableHeaderCell({
13257
13294
  children: [
13258
13295
  flexRender(header.column.columnDef.header, header.getContext()),
13259
13296
  {
13260
- asc: /* @__PURE__ */ jsxRuntimeExports.jsx(DropUpIcon, { className: style$1["sort-icon"] }),
13261
- desc: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownIcon, { className: style$1["sort-icon"] })
13297
+ asc: /* @__PURE__ */ jsxRuntimeExports.jsx(DropUpIcon, { className: style["sort-icon"] }),
13298
+ desc: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownIcon, { className: style["sort-icon"] })
13262
13299
  }[header.column.getIsSorted()] ?? null,
13263
13300
  tableCanResize && (!enableResizing ? header.id !== (lastColumn == null ? void 0 : lastColumn.id) : true) && header.column.getCanResize() && !INTERNAL_COLUMN_IDS.includes(header.column.id) && /* @__PURE__ */ jsxRuntimeExports.jsx(
13264
13301
  "div",
@@ -13283,7 +13320,7 @@ function TableHeaderCell({
13283
13320
  () => handleMouseUp({ styledTableProps, header })
13284
13321
  );
13285
13322
  },
13286
- className: `${style$1["resizer"]} ${header.column.getIsResizing() ? style$1["isResizing"] : ""}`
13323
+ className: `${style["resizer"]} ${header.column.getIsResizing() ? style["isResizing"] : ""}`
13287
13324
  }
13288
13325
  }
13289
13326
  )
@@ -13330,8 +13367,8 @@ function TableHeader({
13330
13367
  "thead",
13331
13368
  {
13332
13369
  className: cn(
13333
- style$1["table-header"],
13334
- stickyHeader && style$1["table-header--sticky"],
13370
+ style["table-header"],
13371
+ stickyHeader && style["table-header--sticky"],
13335
13372
  styledTableProps.tableHeaderClassName
13336
13373
  ),
13337
13374
  style: styles2,
@@ -13532,18 +13569,18 @@ function TableRow({
13532
13569
  "td",
13533
13570
  {
13534
13571
  className: clsx(
13535
- style$1["t-cell"],
13572
+ style["t-cell"],
13536
13573
  hasRowClickHandler && "cursor-pointer",
13537
13574
  tdClassName,
13538
- isActionsCell && style$1["action-cell"],
13539
- isActionsCell && Boolean(actions) && leftCells.length && style$1["shadowed"],
13540
- isActionsCell && ((getRowClassName == null ? void 0 : getRowClassName(row)) ? getRowClassName == null ? void 0 : getRowClassName(row) : style$1["action-cell-default-background"]),
13541
- isFixed2 && style$1["fixed-cell"],
13542
- isLastFixedCell && style$1["shadowed"],
13543
- row.getIsSelected() && style$1["selected"],
13544
- isFixed2 && ((getRowClassName == null ? void 0 : getRowClassName(row)) ? getRowClassName == null ? void 0 : getRowClassName(row) : style$1["fixed-cell-default-background"]),
13545
- isExpandedRow && style$1["expanded_row"],
13546
- (singleSelection || row.isFocused()) && style$1["single-selection"]
13575
+ isActionsCell && style["action-cell"],
13576
+ isActionsCell && Boolean(actions) && leftCells.length && style["shadowed"],
13577
+ isActionsCell && ((getRowClassName == null ? void 0 : getRowClassName(row)) ? getRowClassName == null ? void 0 : getRowClassName(row) : style["action-cell-default-background"]),
13578
+ isFixed2 && style["fixed-cell"],
13579
+ isLastFixedCell && style["shadowed"],
13580
+ row.getIsSelected() && style["selected"],
13581
+ isFixed2 && ((getRowClassName == null ? void 0 : getRowClassName(row)) ? getRowClassName == null ? void 0 : getRowClassName(row) : style["fixed-cell-default-background"]),
13582
+ isExpandedRow && style["expanded_row"],
13583
+ (singleSelection || row.isFocused()) && style["single-selection"]
13547
13584
  ),
13548
13585
  style: { left: isFixed2 ? cell.left : void 0 },
13549
13586
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -13589,7 +13626,7 @@ function TableRow({
13589
13626
  "data-index": index,
13590
13627
  "data-test": row.id,
13591
13628
  id: row.id,
13592
- className: clsx(style$1["t-row"], loading && style$1["is-loading"], getRowClassName == null ? void 0 : getRowClassName(row)),
13629
+ className: clsx(style["t-row"], loading && style["is-loading"], getRowClassName == null ? void 0 : getRowClassName(row)),
13593
13630
  style: {
13594
13631
  height: rowHeight ? `${rowHeight}px` : "inherit",
13595
13632
  ...enableDnd && dndStyle
@@ -13623,7 +13660,7 @@ function TableRow({
13623
13660
  "td",
13624
13661
  {
13625
13662
  "aria-hidden": true,
13626
- className: style$1["t-cell"],
13663
+ className: style["t-cell"],
13627
13664
  style: {
13628
13665
  width: String(paddingLeft) + "px",
13629
13666
  minWidth: String(paddingLeft) + "px",
@@ -13638,7 +13675,7 @@ function TableRow({
13638
13675
  "td",
13639
13676
  {
13640
13677
  "aria-hidden": true,
13641
- className: style$1["t-cell"],
13678
+ className: style["t-cell"],
13642
13679
  style: {
13643
13680
  width: String(paddingRight) + "px",
13644
13681
  minWidth: String(paddingRight) + "px",
@@ -13699,12 +13736,12 @@ function TableBody({
13699
13736
  const { columns, data, loading, enableDnd, rowHeight } = styledTableProps;
13700
13737
  const colSpan = table.getAllLeafColumns().length || columns.length || 1;
13701
13738
  if (loading && data.length === 0) {
13702
- return /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: style$1["tbody"], children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableSkeleton, { colSpan, rowHeight }) });
13739
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: style["tbody"], children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableSkeleton, { colSpan, rowHeight }) });
13703
13740
  }
13704
13741
  if (data.length === 0) {
13705
13742
  return null;
13706
13743
  }
13707
- return /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: style$1["tbody"], children: enableDnd ? /* @__PURE__ */ jsxRuntimeExports.jsx(SortableContext, { items: data, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableRows, { table, styledTableProps, columnWindow }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(TableRows, { table, styledTableProps, columnWindow }) });
13744
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: style["tbody"], children: enableDnd ? /* @__PURE__ */ jsxRuntimeExports.jsx(SortableContext, { items: data, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableRows, { table, styledTableProps, columnWindow }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(TableRows, { table, styledTableProps, columnWindow }) });
13708
13745
  }
13709
13746
  function LoadingIcon(props) {
13710
13747
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1rem", height: "1rem", viewBox: "0 0 24 24", ...props, children: [
@@ -13730,18 +13767,18 @@ function LoadingIcon(props) {
13730
13767
  ] });
13731
13768
  }
13732
13769
  const Fetching = ({ fetching = false }) => {
13733
- return fetching ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-10 bg-white/40 left-0 top-0 right-0 bottom-0 flex items-center justify-center ", children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingIcon, { className: style$1["loading-icon"], width: 50, height: 50 }) }) : null;
13770
+ return fetching ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-10 bg-white/40 left-0 top-0 right-0 bottom-0 flex items-center justify-center ", children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingIcon, { className: style["loading-icon"], width: 50, height: 50 }) }) : null;
13734
13771
  };
13735
- function ChevronRightIcon(props) {
13736
- return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1rem", height: "1rem", viewBox: "0 0 24 24", ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "currentColor", d: "M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z" }) });
13737
- }
13738
- const style = {
13772
+ const paginationStyle = {
13739
13773
  "table-pagination": "_table-pagination_pu6mb_1",
13740
13774
  "table-pagination__pages-list": "_table-pagination__pages-list_pu6mb_11",
13741
13775
  "table-pagination__pages-list__page": "_table-pagination__pages-list__page_pu6mb_16",
13742
13776
  "page-selected": "_page-selected_pu6mb_27",
13743
13777
  "check-icon": "_check-icon_pu6mb_30"
13744
13778
  };
13779
+ function ChevronRightIcon(props) {
13780
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1rem", height: "1rem", viewBox: "0 0 24 24", ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "currentColor", d: "M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z" }) });
13781
+ }
13745
13782
  function ChevronLeftIcon(props) {
13746
13783
  return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1rem", height: "1rem", viewBox: "0 0 24 24", ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "currentColor", d: "M15.41 16.58L10.83 12l4.58-4.59L14 6l-6 6l6 6z" }) });
13747
13784
  }
@@ -13774,19 +13811,11 @@ const StyledMenuItem = (props) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
13774
13811
  ]
13775
13812
  }
13776
13813
  );
13777
- const amountOfRows = [10, 20, 50];
13778
13814
  function TablePagination({
13779
13815
  table,
13780
- showRowSelect,
13781
13816
  locale
13782
13817
  }) {
13783
13818
  const { anchorEl, open, handleClose, handleOpen } = useToggleMenuVisibility();
13784
- const {
13785
- anchorEl: anchorElRows,
13786
- open: openRows,
13787
- handleClose: handleCloseRows,
13788
- handleOpen: handleOpenRows
13789
- } = useToggleMenuVisibility();
13790
13819
  const tablePaginationRef = useRef(null);
13791
13820
  const isNo = locale === "no";
13792
13821
  const popoverOrigin = useMemo(
@@ -13798,10 +13827,10 @@ function TablePagination({
13798
13827
  );
13799
13828
  const scrollToTop = useCallback(() => {
13800
13829
  var _a;
13801
- const asmaTableClass = style$1["asma-ui-table-styled-table"];
13830
+ const asmaTableClass = style["asma-ui-table-styled-table"];
13802
13831
  const tableContainer = (_a = tablePaginationRef.current) == null ? void 0 : _a.closest(`.${asmaTableClass}`);
13803
13832
  const scrollContainer = tableContainer == null ? void 0 : tableContainer.querySelector(
13804
- `.${style$1["table-scroll"]}, .${style$1["table-wrapper"]}`
13833
+ `.${style["table-scroll"]}, .${style["table-wrapper"]}`
13805
13834
  );
13806
13835
  if (scrollContainer) {
13807
13836
  scrollContainer.scrollTo({ top: 0, behavior: "smooth" });
@@ -13810,11 +13839,6 @@ function TablePagination({
13810
13839
  const pagesLength = table.getPageCount() || 1;
13811
13840
  const currentPage = table.getState().pagination.pageIndex + 1;
13812
13841
  const pages = useMemo(() => Array.from({ length: pagesLength }, (_, index) => index + 1), [pagesLength]);
13813
- const pageSize = table.getState().pagination.pageSize;
13814
- const amountOfRowsOptions = useMemo(() => {
13815
- const optionsSet = /* @__PURE__ */ new Set([...amountOfRows, pageSize]);
13816
- return Array.from(optionsSet).sort((a, b) => a - b);
13817
- }, []);
13818
13842
  const handlePageChange = useCallback(
13819
13843
  (page) => {
13820
13844
  table.setPageIndex(page - 1);
@@ -13823,76 +13847,8 @@ function TablePagination({
13823
13847
  },
13824
13848
  [table, handleClose, scrollToTop]
13825
13849
  );
13826
- const handleRowsChange = useCallback(
13827
- (size) => {
13828
- table.setPageSize(size);
13829
- handleCloseRows();
13830
- },
13831
- [table, handleCloseRows]
13832
- );
13833
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: tablePaginationRef, className: style["table-pagination"], children: [
13834
- showRowSelect && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
13835
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
13836
- StyledButton,
13837
- {
13838
- dataTest: "table-rows-count-button",
13839
- variant: "outlined",
13840
- size: "large",
13841
- onClick: handleOpenRows,
13842
- endIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(
13843
- ChevronDownIcon,
13844
- {
13845
- className: `${openRows ? "rotate-180" : "rotate-0"} transition-transform duration-300`,
13846
- height: 24,
13847
- width: 24
13848
- }
13849
- ),
13850
- children: [
13851
- pageSize,
13852
- " ",
13853
- isNo ? "rader" : "rows"
13854
- ]
13855
- }
13856
- ),
13857
- /* @__PURE__ */ jsxRuntimeExports.jsx(
13858
- Popover,
13859
- {
13860
- open: openRows,
13861
- anchorEl: anchorElRows,
13862
- slotProps: {
13863
- paper: {
13864
- sx: {
13865
- width: anchorElRows ? anchorElRows.clientWidth : void 0,
13866
- maxHeight: 288,
13867
- overflowY: "auto"
13868
- }
13869
- }
13870
- },
13871
- onClose: handleCloseRows,
13872
- anchorOrigin: popoverOrigin.anchorOrigin,
13873
- transformOrigin: popoverOrigin.transformOrigin,
13874
- classes: { paper: "border border-solid border-delta-200 py-2" },
13875
- children: amountOfRowsOptions.map((size) => /* @__PURE__ */ jsxRuntimeExports.jsx(
13876
- StyledMenuItem,
13877
- {
13878
- onClick: (e) => {
13879
- e.stopPropagation();
13880
- e.preventDefault();
13881
- handleRowsChange(size);
13882
- },
13883
- selected: pageSize === size,
13884
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-delta-700 text-sm font-normal", children: [
13885
- size,
13886
- " ",
13887
- isNo ? "rader" : "rows"
13888
- ] })
13889
- },
13890
- size
13891
- ))
13892
- }
13893
- )
13894
- ] }),
13895
- /* @__PURE__ */ jsxRuntimeExports.jsx(StyledTooltip, { title: isNo ? "Nåværende side" : "Current Page", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
13850
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
13851
+ /* @__PURE__ */ jsxRuntimeExports.jsx(StyledTooltip, { title: isNo ? "Nåværende side" : "Current Page", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: tablePaginationRef, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
13896
13852
  StyledButton,
13897
13853
  {
13898
13854
  dataTest: "current-page-button",
@@ -13985,43 +13941,130 @@ function TablePagination({
13985
13941
  ) }) })
13986
13942
  ] });
13987
13943
  }
13944
+ const rowCountOptions = [5, 10, 20, 50, 100];
13945
+ function TableRowCountSelect({
13946
+ table,
13947
+ locale
13948
+ }) {
13949
+ const { anchorEl, open, handleClose, handleOpen } = useToggleMenuVisibility();
13950
+ const pageSize = table.getState().pagination.pageSize;
13951
+ const isNo = locale === "no";
13952
+ const popoverOrigin = useMemo(
13953
+ () => ({
13954
+ anchorOrigin: { vertical: -5, horizontal: "center" },
13955
+ transformOrigin: { vertical: "bottom", horizontal: "center" }
13956
+ }),
13957
+ []
13958
+ );
13959
+ const amountOfRowsOptions = useMemo(() => {
13960
+ const optionsSet = /* @__PURE__ */ new Set([...rowCountOptions, pageSize]);
13961
+ return Array.from(optionsSet).sort((a, b) => a - b);
13962
+ }, [pageSize]);
13963
+ const handleRowsChange = useCallback(
13964
+ (size) => {
13965
+ table.setPageSize(size);
13966
+ handleClose();
13967
+ },
13968
+ [handleClose, table]
13969
+ );
13970
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
13971
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
13972
+ StyledButton,
13973
+ {
13974
+ dataTest: "table-rows-count-button",
13975
+ variant: "outlined",
13976
+ size: "large",
13977
+ onClick: handleOpen,
13978
+ endIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(
13979
+ ChevronDownIcon,
13980
+ {
13981
+ className: `${open ? "rotate-180" : "rotate-0"} transition-transform duration-300`,
13982
+ height: 24,
13983
+ width: 24
13984
+ }
13985
+ ),
13986
+ children: [
13987
+ pageSize,
13988
+ " ",
13989
+ isNo ? "rader" : "rows"
13990
+ ]
13991
+ }
13992
+ ),
13993
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
13994
+ Popover,
13995
+ {
13996
+ open,
13997
+ anchorEl,
13998
+ slotProps: {
13999
+ paper: {
14000
+ sx: {
14001
+ width: anchorEl ? anchorEl.clientWidth : void 0,
14002
+ maxHeight: 288,
14003
+ overflowY: "auto"
14004
+ }
14005
+ }
14006
+ },
14007
+ onClose: handleClose,
14008
+ anchorOrigin: popoverOrigin.anchorOrigin,
14009
+ transformOrigin: popoverOrigin.transformOrigin,
14010
+ classes: { paper: "border border-solid border-delta-200 py-2" },
14011
+ children: amountOfRowsOptions.map((size) => /* @__PURE__ */ jsxRuntimeExports.jsx(
14012
+ StyledMenuItem,
14013
+ {
14014
+ onClick: (e) => {
14015
+ e.stopPropagation();
14016
+ e.preventDefault();
14017
+ handleRowsChange(size);
14018
+ },
14019
+ selected: pageSize === size,
14020
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-delta-700 text-sm font-normal", children: [
14021
+ size,
14022
+ " ",
14023
+ isNo ? "rader" : "rows"
14024
+ ] })
14025
+ },
14026
+ size
14027
+ ))
14028
+ }
14029
+ )
14030
+ ] });
14031
+ }
14032
+ const MIN_ROWS_FOR_FOOTER = 5;
13988
14033
  function TableFooter({
13989
14034
  table,
13990
14035
  styledTableProps,
13991
14036
  canShowStickyFooter
13992
14037
  }) {
13993
- var _a, _b, _c;
13994
- if (styledTableProps.hideFooter || styledTableProps.data.length === 0)
13995
- return null;
13996
- const paginationAlignLeft = styledTableProps.paginationAlignLeft;
13997
- const pageSize = table.getState().pagination.pageSize;
13998
- const totalRows = table.getFilteredRowModel().rows.length;
13999
- const isManualPagination = !!table.options.manualPagination;
14000
- const pagesLength = table.getPageCount() || 1;
14001
- const shouldShowPagination = isManualPagination ? pagesLength > 1 : totalRows > pageSize;
14038
+ var _a;
14039
+ const totalRowCount = table.getRowCount();
14040
+ const pageCount = table.getPageCount() || 1;
14002
14041
  const footerNode = (_a = styledTableProps.footer) == null ? void 0 : _a.call(styledTableProps, table);
14003
14042
  const hasFooterNode = footerNode !== null && footerNode !== void 0 && footerNode !== false;
14004
- const hasAnythingToRender = hasFooterNode || shouldShowPagination;
14043
+ const locale = styledTableProps.locale || "en";
14044
+ const hasEnoughRowsForFooter = totalRowCount >= MIN_ROWS_FOR_FOOTER;
14045
+ if (styledTableProps.hideFooter || !hasEnoughRowsForFooter)
14046
+ return null;
14047
+ const paginationAlignLeft = styledTableProps.paginationAlignLeft;
14048
+ const shouldShowRowCountSelect = !styledTableProps.hideRowCountSelect;
14049
+ const shouldShowPagination = pageCount > 1;
14050
+ const shouldShowControls = shouldShowRowCountSelect || shouldShowPagination;
14051
+ const hasAnythingToRender = hasFooterNode || shouldShowControls;
14005
14052
  if (!hasAnythingToRender)
14006
14053
  return null;
14007
14054
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
14008
14055
  "div",
14009
14056
  {
14010
- className: canShowStickyFooter ? style$1["table-footer--sticky"] : style$1["table-footer--inline"],
14057
+ className: canShowStickyFooter ? style["table-footer--sticky"] : style["table-footer--inline"],
14011
14058
  style: paginationAlignLeft && {
14012
14059
  justifyContent: "flex-start"
14013
14060
  } || {},
14014
14061
  children: [
14015
- !paginationAlignLeft && ((_b = styledTableProps.footer) == null ? void 0 : _b.call(styledTableProps, table)),
14016
- shouldShowPagination && /* @__PURE__ */ jsxRuntimeExports.jsx(
14017
- TablePagination,
14018
- {
14019
- table,
14020
- showRowSelect: !!styledTableProps.showRowCountSelect,
14021
- locale: styledTableProps.locale || "en"
14022
- }
14023
- ),
14024
- paginationAlignLeft && ((_c = styledTableProps.footer) == null ? void 0 : _c.call(styledTableProps, table))
14062
+ !paginationAlignLeft && footerNode,
14063
+ shouldShowControls && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: paginationStyle["table-pagination"], children: [
14064
+ shouldShowRowCountSelect && /* @__PURE__ */ jsxRuntimeExports.jsx(TableRowCountSelect, { table, locale }),
14065
+ shouldShowPagination && /* @__PURE__ */ jsxRuntimeExports.jsx(TablePagination, { table, locale })
14066
+ ] }),
14067
+ paginationAlignLeft && footerNode
14025
14068
  ]
14026
14069
  }
14027
14070
  );
@@ -15182,9 +15225,9 @@ const StyledTable = (props) => {
15182
15225
  const isShortTable = !canShowStickyFooter && visibleRows > 0 && visibleRows <= rowsFit;
15183
15226
  const shouldExpandEmptyBody = !canShowStickyFooter && showNoRowsOverlay;
15184
15227
  const tableWrapperClass = cn(
15185
- canShowStickyFooter ? style$1["table-wrapper"] : isShortTable || shouldExpandEmptyBody ? style$1["table-wrapper--proxy-bottom"] : style$1["table-wrapper--proxy"],
15186
- fetching && style$1["table-wrapper-fetching"],
15187
- showNoRowsOverlay && style$1["table-wrapper--no-rows"],
15228
+ canShowStickyFooter ? style["table-wrapper"] : isShortTable || shouldExpandEmptyBody ? style["table-wrapper--proxy-bottom"] : style["table-wrapper--proxy"],
15229
+ fetching && style["table-wrapper-fetching"],
15230
+ showNoRowsOverlay && style["table-wrapper--no-rows"],
15188
15231
  className
15189
15232
  );
15190
15233
  const scrollRef = canShowStickyFooter ? wrapperRef : tableScrollRef;
@@ -15209,7 +15252,7 @@ const StyledTable = (props) => {
15209
15252
  clearHeight();
15210
15253
  };
15211
15254
  }, [showNoRowsOverlay, noRowsOverlayTop]);
15212
- const TableMarkup = /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: style$1["styled-table"], style: { width: table.getTotalSize(), minWidth: "100%" }, children: [
15255
+ const TableMarkup = /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: style["styled-table"], style: { width: table.getTotalSize(), minWidth: "100%" }, children: [
15213
15256
  /* @__PURE__ */ jsxRuntimeExports.jsx(
15214
15257
  TableHeader,
15215
15258
  {
@@ -15223,32 +15266,32 @@ const StyledTable = (props) => {
15223
15266
  /* @__PURE__ */ jsxRuntimeExports.jsx(Fetching, { fetching: !!fetching }),
15224
15267
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableBody, { table, styledTableProps: options, columnWindow })
15225
15268
  ] });
15226
- const NoRowsOverlay = showNoRowsOverlay ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style$1["no-rows-overlay-container"], style: { top: noRowsOverlayTop }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: noRowsContentRef, className: style$1["no-rows-overlay-content"], children: noRowsOverlay }) }) : null;
15269
+ const NoRowsOverlay = showNoRowsOverlay ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style["no-rows-overlay-container"], style: { top: noRowsOverlayTop }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: noRowsContentRef, className: style["no-rows-overlay-content"], children: noRowsOverlay }) }) : null;
15227
15270
  return /* @__PURE__ */ jsxRuntimeExports.jsx(RootContextProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DndProvider, { enabled: !!enableDnd, data, setData, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
15228
15271
  "div",
15229
15272
  {
15230
15273
  ref: containerRef,
15231
- className: cn(style$1["asma-ui-table-styled-table"], tableClassName),
15274
+ className: cn(style["asma-ui-table-styled-table"], tableClassName),
15232
15275
  "data-x-overflow": hasInternalOverflow ? "true" : "false",
15233
15276
  style: { height: height2 },
15234
15277
  children: [
15235
- /* @__PURE__ */ jsxRuntimeExports.jsx(OverlayShell, { enabled: canShowStickyFooter, className: style$1["table-shell"], children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: wrapperRef, className: tableWrapperClass, children: [
15236
- canShowStickyFooter ? TableMarkup : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: tableScrollRef, className: cn(style$1["table-scroll"]), children: [
15278
+ /* @__PURE__ */ jsxRuntimeExports.jsx(OverlayShell, { enabled: canShowStickyFooter, className: style["table-shell"], children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: wrapperRef, className: tableWrapperClass, children: [
15279
+ canShowStickyFooter ? TableMarkup : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: tableScrollRef, className: cn(style["table-scroll"]), children: [
15237
15280
  /* @__PURE__ */ jsxRuntimeExports.jsx(
15238
15281
  "div",
15239
15282
  {
15240
15283
  ref: tableXRef,
15241
- className: cn(style$1["table-x"], !isShortTable && style$1["table-x--fill-height"]),
15284
+ className: cn(style["table-x"], !isShortTable && style["table-x--fill-height"]),
15242
15285
  children: TableMarkup
15243
15286
  }
15244
15287
  ),
15245
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: hScrollRef, className: style$1["table-hscroll"], children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: hScrollContentRef, className: style$1["table-hscroll__content"] }) }),
15288
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: hScrollRef, className: style["table-hscroll"], children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: hScrollContentRef, className: style["table-hscroll__content"] }) }),
15246
15289
  /* @__PURE__ */ jsxRuntimeExports.jsx(
15247
15290
  "div",
15248
15291
  {
15249
15292
  className: cn(
15250
- style$1["table-bottom"],
15251
- isShortTable && style$1["table-bottom--sticky"]
15293
+ style["table-bottom"],
15294
+ isShortTable && style["table-bottom--sticky"]
15252
15295
  ),
15253
15296
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
15254
15297
  TableFooter,
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { Table } from '@tanstack/react-table';
3
- export declare function TablePagination<TData>({ table, showRowSelect, locale, }: {
3
+ export declare function TablePagination<TData>({ table, locale, }: {
4
4
  locale: 'en' | 'no';
5
- showRowSelect: boolean;
6
5
  table: Table<TData>;
7
6
  }): JSX.Element;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { Table } from '@tanstack/react-table';
3
+ export declare function TableRowCountSelect<TData>({ table, locale, }: {
4
+ locale: 'en' | 'no';
5
+ table: Table<TData>;
6
+ }): JSX.Element;
@@ -0,0 +1,2 @@
1
+ export declare const getPersistedPageSizeKey: (uniqueKey?: string) => string | undefined;
2
+ export declare const usePersistedPageSize: (uniqueKey?: string) => number | undefined;
@@ -92,7 +92,6 @@ export type StyledTableProps<TData, TCustomData> = {
92
92
  }) => ReactElement | null;
93
93
  getRowSelectionIds?: (ids: string[]) => void;
94
94
  hideHeader?: boolean;
95
- showRowCountSelect?: boolean;
96
95
  pageSize?: number;
97
96
  enableResizing?: boolean;
98
97
  enableDnd?: boolean;
@@ -104,6 +103,7 @@ export type StyledTableProps<TData, TCustomData> = {
104
103
  singleSelectionRow?: boolean;
105
104
  rowActionsState?: (row: Row<TData>) => RowActionsState | undefined;
106
105
  stickyFooter?: boolean;
106
+ hideRowCountSelect?: boolean;
107
107
  /**
108
108
  * @info A unique identifier for the table. This name is used to store the table's state in localStorage,
109
109
  * ensuring that the table state is persisted across sessions for the specific table instance.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.1.14",
6
+ "version": "1.1.15",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist/**/*",