asma-ui-table 1.2.0 → 1.3.0

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.
@@ -9,7 +9,7 @@ import React__default, { useMemo, useLayoutEffect, useEffect, useRef, useCallbac
9
9
  import * as ReactDOM from "react-dom";
10
10
  import ReactDOM__default, { unstable_batchedUpdates, createPortal, flushSync } from "react-dom";
11
11
  import { twMerge } from "tailwind-merge";
12
- import { MenuItem, Tooltip, Popover, Skeleton } from "@mui/material";
12
+ import { Tooltip, MenuItem, Popover, Skeleton } from "@mui/material";
13
13
  import PropTypes from "prop-types";
14
14
  import { ThemeContext } from "@emotion/react";
15
15
  const isCustomAction = (action) => {
@@ -8010,6 +8010,14 @@ const usePersistedPageSize = (uniqueKey) => {
8010
8010
  }, [uniqueKey]);
8011
8011
  return persistedPageSize;
8012
8012
  };
8013
+ const RowSelectionTooltipFeature = {
8014
+ createRow: (row, table) => {
8015
+ row.getRowSelectionTooltip = () => {
8016
+ var _a, _b;
8017
+ return (_b = (_a = table.options).getRowSelectionTooltip) == null ? void 0 : _b.call(_a, row);
8018
+ };
8019
+ }
8020
+ };
8013
8021
  const useStyledTable = (props) => {
8014
8022
  var _a;
8015
8023
  const {
@@ -8026,13 +8034,14 @@ const useStyledTable = (props) => {
8026
8034
  } = props;
8027
8035
  const columnOrder = usePersistedColumnOrder(persistColumnOrderKey);
8028
8036
  const persistedPageSize = usePersistedPageSize(uniqueKey);
8037
+ const resolvedPageSize = persistedPageSize ?? pageSize ?? 50;
8029
8038
  const table = useReactTable({
8030
- _features: [ExpandedRowsFeature, FocusedRowsFeature, OrderColumnsFeature],
8039
+ _features: [ExpandedRowsFeature, FocusedRowsFeature, OrderColumnsFeature, RowSelectionTooltipFeature],
8031
8040
  columns,
8032
8041
  data,
8033
8042
  meta: { locale: locale ?? "en" },
8034
8043
  initialState: {
8035
- pagination: { pageIndex: 0, pageSize: persistedPageSize ?? pageSize ?? 50 },
8044
+ pagination: { pageIndex: 0, pageSize: resolvedPageSize },
8036
8045
  columnVisibility: {
8037
8046
  ...initialState == null ? void 0 : initialState.columnVisibility,
8038
8047
  [SELECT_COLUMN_ID]: false
@@ -8057,17 +8066,32 @@ const useStyledTable = (props) => {
8057
8066
  tableInstanceRef.current = table;
8058
8067
  }
8059
8068
  usePersistColumnOrder(table, persistColumnOrderKey);
8069
+ const storageKey = getPersistedPageSizeKey(uniqueKey);
8060
8070
  const pageSizeState = (_a = table.getState().pagination) == null ? void 0 : _a.pageSize;
8071
+ const hydratedStorageKeyRef = useRef(void 0);
8061
8072
  useEffect(() => {
8062
- const storageKey = getPersistedPageSizeKey(uniqueKey);
8063
- if (!storageKey || !pageSizeState)
8073
+ var _a2;
8074
+ hydratedStorageKeyRef.current = void 0;
8075
+ const currentPageSize = (_a2 = table.getState().pagination) == null ? void 0 : _a2.pageSize;
8076
+ if (currentPageSize === resolvedPageSize)
8077
+ return;
8078
+ table.setPageIndex(0);
8079
+ table.setPageSize(resolvedPageSize);
8080
+ }, [resolvedPageSize, storageKey, table]);
8081
+ useEffect(() => {
8082
+ if (!storageKey || pageSizeState == null)
8064
8083
  return;
8084
+ if (hydratedStorageKeyRef.current !== storageKey) {
8085
+ if (pageSizeState !== resolvedPageSize)
8086
+ return;
8087
+ hydratedStorageKeyRef.current = storageKey;
8088
+ }
8065
8089
  try {
8066
8090
  localStorage.setItem(storageKey, JSON.stringify(pageSizeState));
8067
8091
  } catch (e) {
8068
8092
  console.error(e);
8069
8093
  }
8070
- }, [pageSizeState, uniqueKey]);
8094
+ }, [pageSizeState, resolvedPageSize, storageKey]);
8071
8095
  return { table };
8072
8096
  };
8073
8097
  const CheckboxWrapper = "_CheckboxWrapper_1b4zf_1";
@@ -9710,229 +9734,6 @@ const StyledCheckbox = ({
9710
9734
  }
9711
9735
  );
9712
9736
  };
9713
- function selectColumn(isFixed2, rowHeight) {
9714
- return {
9715
- id: SELECT_COLUMN_ID,
9716
- minSize: 38,
9717
- maxSize: 38,
9718
- size: 38,
9719
- header: ({ table }) => {
9720
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
9721
- "button",
9722
- {
9723
- type: "button",
9724
- className: "pl-2 flex size-full items-center justify-start",
9725
- onClick: () => table.toggleAllRowsSelected(),
9726
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
9727
- StyledCheckbox,
9728
- {
9729
- size: "small",
9730
- dataTest: "cell-select-all",
9731
- checked: table.getIsAllRowsSelected(),
9732
- indeterminate: table.getIsSomeRowsSelected(),
9733
- hideWrapper: true
9734
- }
9735
- )
9736
- }
9737
- );
9738
- },
9739
- cell: ({ cell }) => {
9740
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
9741
- "button",
9742
- {
9743
- type: "button",
9744
- style: { height: rowHeight ? rowHeight : "auto" },
9745
- className: "pl-2 flex w-full items-center justify-start m-0 p-0",
9746
- onClick: () => cell.row.toggleSelected(),
9747
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
9748
- StyledCheckbox,
9749
- {
9750
- size: "small",
9751
- dataTest: "cell-select",
9752
- checked: cell.row.getIsSelected(),
9753
- hideWrapper: true,
9754
- disabled: !cell.row.getCanSelect(),
9755
- onMouseUp: (e) => {
9756
- e.preventDefault();
9757
- e.stopPropagation();
9758
- }
9759
- }
9760
- )
9761
- }
9762
- );
9763
- },
9764
- fixedLeft: isFixed2
9765
- };
9766
- }
9767
- function ChevronDownIcon(props) {
9768
- 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: "M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z" }) });
9769
- }
9770
- function generateExpandColumn(isFixed2, rowHeight) {
9771
- return {
9772
- id: EXPAND_COLUMN_ID,
9773
- minSize: 50,
9774
- maxSize: 50,
9775
- size: 50,
9776
- enableHiding: false,
9777
- enableSorting: false,
9778
- header: () => null,
9779
- cell: ({ cell }) => {
9780
- const isExpanded = cell.row.getIsExpanded();
9781
- const canExpand = cell.row.getCanExpand();
9782
- return canExpand ? /* @__PURE__ */ jsxRuntimeExports.jsx(
9783
- "span",
9784
- {
9785
- className: "flex w-full outline-none focus:outline-none items-center justify-center",
9786
- onClick: () => cell.row.getToggleExpandedHandler()(),
9787
- style: { height: rowHeight ? rowHeight : "auto" },
9788
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
9789
- ChevronDownIcon,
9790
- {
9791
- width: 24,
9792
- height: 24,
9793
- style: {
9794
- rotate: isExpanded ? "180deg" : "0deg",
9795
- transitionTimingFunction: "cubic-bezier(0.4, 0, 0.2, 1)",
9796
- transitionDuration: "500ms"
9797
- }
9798
- }
9799
- )
9800
- }
9801
- ) : null;
9802
- },
9803
- fixedLeft: isFixed2
9804
- };
9805
- }
9806
- const useToggleMenuVisibility = () => {
9807
- const [anchorEl, setAnchorEl] = useState(null);
9808
- const [open, setOpen] = useState(false);
9809
- const handleOpen = useCallback((event) => {
9810
- setAnchorEl(event.currentTarget);
9811
- setOpen(true);
9812
- }, []);
9813
- const handleClose = useCallback(() => {
9814
- setOpen(false);
9815
- }, []);
9816
- return { open, handleClose, handleOpen, anchorEl };
9817
- };
9818
- function DotsVerticalIcon(props) {
9819
- 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(
9820
- "path",
9821
- {
9822
- fill: "currentColor",
9823
- d: "M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2"
9824
- }
9825
- ) });
9826
- }
9827
- const StyledMenuItem$1 = (props) => {
9828
- var _a;
9829
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
9830
- MenuItem,
9831
- {
9832
- ...props,
9833
- classes: {
9834
- root: clsx("px-3 py-2.5", (_a = props.classes) == null ? void 0 : _a.root),
9835
- ...props.classes
9836
- },
9837
- sx: {
9838
- "&.Mui-disabled": {
9839
- pointerEvents: "auto",
9840
- cursor: "not-allowed",
9841
- "&:hover": {
9842
- backgroundColor: "transparent !important"
9843
- }
9844
- },
9845
- ...props.sx
9846
- }
9847
- }
9848
- );
9849
- };
9850
- const contained = "_contained_gteum_27";
9851
- const common$2 = "_common_gteum_27";
9852
- const medium = "_medium_gteum_69";
9853
- const small = "_small_gteum_74";
9854
- const large = "_large_gteum_79";
9855
- const error = "_error_gteum_84";
9856
- const outlined = "_outlined_gteum_141";
9857
- const text = "_text_gteum_255";
9858
- const textGray = "_textGray_gteum_369";
9859
- const textWhite = "_textWhite_gteum_426";
9860
- const style$3 = {
9861
- "asma-core-ui-button": "_asma-core-ui-button_gteum_1",
9862
- contained,
9863
- common: common$2,
9864
- medium,
9865
- small,
9866
- large,
9867
- error,
9868
- outlined,
9869
- text,
9870
- textGray,
9871
- textWhite
9872
- };
9873
- const BtnStyles = {
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"]
9884
- };
9885
- const StyledButton = ({
9886
- variant = "contained",
9887
- className = "",
9888
- size = "medium",
9889
- children,
9890
- refLink,
9891
- startIcon,
9892
- endIcon,
9893
- dataTest,
9894
- error: error2,
9895
- ...otherProps
9896
- }) => {
9897
- const isLarge = size === "large" || size === "medium";
9898
- const color2 = error2 ? "error" : "common";
9899
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
9900
- "button",
9901
- {
9902
- ...otherProps,
9903
- className: clsx(
9904
- style$3["asma-core-ui-button"],
9905
- BtnStyles[variant],
9906
- BtnStyles[color2],
9907
- BtnStyles[size],
9908
- className
9909
- ),
9910
- ref: refLink,
9911
- "data-test": dataTest,
9912
- children: [
9913
- startIcon,
9914
- children && /* @__PURE__ */ jsxRuntimeExports.jsx(
9915
- "div",
9916
- {
9917
- style: {
9918
- overflow: "hidden",
9919
- textOverflow: "ellipsis",
9920
- whiteSpace: "nowrap",
9921
- display: "flex",
9922
- alignItems: "center",
9923
- justifyContent: "center",
9924
- gap: isLarge ? "8px" : "4px",
9925
- paddingLeft: isLarge ? "8px" : "4px",
9926
- paddingRight: isLarge ? "8px" : "4px"
9927
- },
9928
- children
9929
- }
9930
- ),
9931
- endIcon
9932
- ]
9933
- }
9934
- );
9935
- };
9936
9737
  function _extends() {
9937
9738
  _extends = Object.assign ? Object.assign.bind() : function(target) {
9938
9739
  for (var i = 1; i < arguments.length; i++) {
@@ -10739,7 +10540,7 @@ function getStyleValue(themeMapping, transform, propValueFinal, userValue = prop
10739
10540
  }
10740
10541
  return value;
10741
10542
  }
10742
- function style$2(options) {
10543
+ function style$3(options) {
10743
10544
  const {
10744
10545
  prop,
10745
10546
  cssProperty = options.prop,
@@ -10887,12 +10688,12 @@ function resolveCssProperty(props, keys, prop, transformer) {
10887
10688
  const propValue = props[prop];
10888
10689
  return handleBreakpoints(props, propValue, styleFromPropValue);
10889
10690
  }
10890
- function style$1(props, keys) {
10691
+ function style$2(props, keys) {
10891
10692
  const transformer = createUnarySpacing(props.theme);
10892
10693
  return Object.keys(props).map((prop) => resolveCssProperty(props, keys, prop, transformer)).reduce(merge, {});
10893
10694
  }
10894
10695
  function margin(props) {
10895
- return style$1(props, marginKeys);
10696
+ return style$2(props, marginKeys);
10896
10697
  }
10897
10698
  margin.propTypes = process.env.NODE_ENV !== "production" ? marginKeys.reduce((obj, key) => {
10898
10699
  obj[key] = responsivePropType$1;
@@ -10900,7 +10701,7 @@ margin.propTypes = process.env.NODE_ENV !== "production" ? marginKeys.reduce((ob
10900
10701
  }, {}) : {};
10901
10702
  margin.filterProps = marginKeys;
10902
10703
  function padding(props) {
10903
- return style$1(props, paddingKeys);
10704
+ return style$2(props, paddingKeys);
10904
10705
  }
10905
10706
  padding.propTypes = process.env.NODE_ENV !== "production" ? paddingKeys.reduce((obj, key) => {
10906
10707
  obj[key] = responsivePropType$1;
@@ -10958,48 +10759,48 @@ function borderTransform(value) {
10958
10759
  }
10959
10760
  return `${value}px solid`;
10960
10761
  }
10961
- const border = style$2({
10762
+ const border = style$3({
10962
10763
  prop: "border",
10963
10764
  themeKey: "borders",
10964
10765
  transform: borderTransform
10965
10766
  });
10966
- const borderTop = style$2({
10767
+ const borderTop = style$3({
10967
10768
  prop: "borderTop",
10968
10769
  themeKey: "borders",
10969
10770
  transform: borderTransform
10970
10771
  });
10971
- const borderRight = style$2({
10772
+ const borderRight = style$3({
10972
10773
  prop: "borderRight",
10973
10774
  themeKey: "borders",
10974
10775
  transform: borderTransform
10975
10776
  });
10976
- const borderBottom = style$2({
10777
+ const borderBottom = style$3({
10977
10778
  prop: "borderBottom",
10978
10779
  themeKey: "borders",
10979
10780
  transform: borderTransform
10980
10781
  });
10981
- const borderLeft = style$2({
10782
+ const borderLeft = style$3({
10982
10783
  prop: "borderLeft",
10983
10784
  themeKey: "borders",
10984
10785
  transform: borderTransform
10985
10786
  });
10986
- const borderColor = style$2({
10787
+ const borderColor = style$3({
10987
10788
  prop: "borderColor",
10988
10789
  themeKey: "palette"
10989
10790
  });
10990
- const borderTopColor = style$2({
10791
+ const borderTopColor = style$3({
10991
10792
  prop: "borderTopColor",
10992
10793
  themeKey: "palette"
10993
10794
  });
10994
- const borderRightColor = style$2({
10795
+ const borderRightColor = style$3({
10995
10796
  prop: "borderRightColor",
10996
10797
  themeKey: "palette"
10997
10798
  });
10998
- const borderBottomColor = style$2({
10799
+ const borderBottomColor = style$3({
10999
10800
  prop: "borderBottomColor",
11000
10801
  themeKey: "palette"
11001
10802
  });
11002
- const borderLeftColor = style$2({
10803
+ const borderLeftColor = style$3({
11003
10804
  prop: "borderLeftColor",
11004
10805
  themeKey: "palette"
11005
10806
  });
@@ -11060,31 +10861,31 @@ rowGap.propTypes = process.env.NODE_ENV !== "production" ? {
11060
10861
  rowGap: responsivePropType$1
11061
10862
  } : {};
11062
10863
  rowGap.filterProps = ["rowGap"];
11063
- const gridColumn = style$2({
10864
+ const gridColumn = style$3({
11064
10865
  prop: "gridColumn"
11065
10866
  });
11066
- const gridRow = style$2({
10867
+ const gridRow = style$3({
11067
10868
  prop: "gridRow"
11068
10869
  });
11069
- const gridAutoFlow = style$2({
10870
+ const gridAutoFlow = style$3({
11070
10871
  prop: "gridAutoFlow"
11071
10872
  });
11072
- const gridAutoColumns = style$2({
10873
+ const gridAutoColumns = style$3({
11073
10874
  prop: "gridAutoColumns"
11074
10875
  });
11075
- const gridAutoRows = style$2({
10876
+ const gridAutoRows = style$3({
11076
10877
  prop: "gridAutoRows"
11077
10878
  });
11078
- const gridTemplateColumns = style$2({
10879
+ const gridTemplateColumns = style$3({
11079
10880
  prop: "gridTemplateColumns"
11080
10881
  });
11081
- const gridTemplateRows = style$2({
10882
+ const gridTemplateRows = style$3({
11082
10883
  prop: "gridTemplateRows"
11083
10884
  });
11084
- const gridTemplateAreas = style$2({
10885
+ const gridTemplateAreas = style$3({
11085
10886
  prop: "gridTemplateAreas"
11086
10887
  });
11087
- const gridArea = style$2({
10888
+ const gridArea = style$3({
11088
10889
  prop: "gridArea"
11089
10890
  });
11090
10891
  compose(gap, columnGap, rowGap, gridColumn, gridRow, gridAutoFlow, gridAutoColumns, gridAutoRows, gridTemplateColumns, gridTemplateRows, gridTemplateAreas, gridArea);
@@ -11094,18 +10895,18 @@ function paletteTransform(value, userValue) {
11094
10895
  }
11095
10896
  return value;
11096
10897
  }
11097
- const color = style$2({
10898
+ const color = style$3({
11098
10899
  prop: "color",
11099
10900
  themeKey: "palette",
11100
10901
  transform: paletteTransform
11101
10902
  });
11102
- const bgcolor = style$2({
10903
+ const bgcolor = style$3({
11103
10904
  prop: "bgcolor",
11104
10905
  cssProperty: "backgroundColor",
11105
10906
  themeKey: "palette",
11106
10907
  transform: paletteTransform
11107
10908
  });
11108
- const backgroundColor = style$2({
10909
+ const backgroundColor = style$3({
11109
10910
  prop: "backgroundColor",
11110
10911
  themeKey: "palette",
11111
10912
  transform: paletteTransform
@@ -11114,7 +10915,7 @@ compose(color, bgcolor, backgroundColor);
11114
10915
  function sizingTransform(value) {
11115
10916
  return value <= 1 && value !== 0 ? `${value * 100}%` : value;
11116
10917
  }
11117
- const width = style$2({
10918
+ const width = style$3({
11118
10919
  prop: "width",
11119
10920
  transform: sizingTransform
11120
10921
  });
@@ -11132,33 +10933,33 @@ const maxWidth = (props) => {
11132
10933
  return null;
11133
10934
  };
11134
10935
  maxWidth.filterProps = ["maxWidth"];
11135
- const minWidth = style$2({
10936
+ const minWidth = style$3({
11136
10937
  prop: "minWidth",
11137
10938
  transform: sizingTransform
11138
10939
  });
11139
- const height = style$2({
10940
+ const height = style$3({
11140
10941
  prop: "height",
11141
10942
  transform: sizingTransform
11142
10943
  });
11143
- const maxHeight = style$2({
10944
+ const maxHeight = style$3({
11144
10945
  prop: "maxHeight",
11145
10946
  transform: sizingTransform
11146
10947
  });
11147
- const minHeight = style$2({
10948
+ const minHeight = style$3({
11148
10949
  prop: "minHeight",
11149
10950
  transform: sizingTransform
11150
10951
  });
11151
- style$2({
10952
+ style$3({
11152
10953
  prop: "size",
11153
10954
  cssProperty: "width",
11154
10955
  transform: sizingTransform
11155
10956
  });
11156
- style$2({
10957
+ style$3({
11157
10958
  prop: "size",
11158
10959
  cssProperty: "height",
11159
10960
  transform: sizingTransform
11160
10961
  });
11161
- const boxSizing = style$2({
10962
+ const boxSizing = style$3({
11162
10963
  prop: "boxSizing"
11163
10964
  });
11164
10965
  compose(width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing);
@@ -11748,11 +11549,11 @@ function createMixins(breakpoints, mixins) {
11748
11549
  }
11749
11550
  }, mixins);
11750
11551
  }
11751
- const common = {
11552
+ const common$1 = {
11752
11553
  black: "#000",
11753
11554
  white: "#fff"
11754
11555
  };
11755
- const common$1 = common;
11556
+ const common$2 = common$1;
11756
11557
  const grey = {
11757
11558
  50: "#fafafa",
11758
11559
  100: "#f5f5f5",
@@ -11888,8 +11689,8 @@ const light = {
11888
11689
  // The background colors used to style the surfaces.
11889
11690
  // Consistency between these values is important.
11890
11691
  background: {
11891
- paper: common$1.white,
11892
- default: common$1.white
11692
+ paper: common$2.white,
11693
+ default: common$2.white
11893
11694
  },
11894
11695
  // The colors used to style the action elements.
11895
11696
  action: {
@@ -11913,7 +11714,7 @@ const light = {
11913
11714
  };
11914
11715
  const dark = {
11915
11716
  text: {
11916
- primary: common$1.white,
11717
+ primary: common$2.white,
11917
11718
  secondary: "rgba(255, 255, 255, 0.7)",
11918
11719
  disabled: "rgba(255, 255, 255, 0.5)",
11919
11720
  icon: "rgba(255, 255, 255, 0.5)"
@@ -11924,7 +11725,7 @@ const dark = {
11924
11725
  default: "#121212"
11925
11726
  },
11926
11727
  action: {
11927
- active: common$1.white,
11728
+ active: common$2.white,
11928
11729
  hover: "rgba(255, 255, 255, 0.08)",
11929
11730
  hoverOpacity: 0.08,
11930
11731
  selected: "rgba(255, 255, 255, 0.16)",
@@ -12106,7 +11907,7 @@ const theme2 = createTheme({ palette: {
12106
11907
  }
12107
11908
  const paletteOutput = deepmerge(_extends({
12108
11909
  // A collection of common colors.
12109
- common: _extends({}, common$1),
11910
+ common: _extends({}, common$2),
12110
11911
  // prevent mutable object.
12111
11912
  // The palette mode, can be light or dark.
12112
11913
  mode,
@@ -12627,6 +12428,231 @@ const StyledTooltip = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(
12627
12428
  ...props
12628
12429
  }
12629
12430
  );
12431
+ function selectColumn(isFixed2, rowHeight) {
12432
+ return {
12433
+ id: SELECT_COLUMN_ID,
12434
+ minSize: 38,
12435
+ maxSize: 38,
12436
+ size: 38,
12437
+ header: ({ table }) => {
12438
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
12439
+ "button",
12440
+ {
12441
+ type: "button",
12442
+ className: "pl-2 flex size-full items-center justify-start",
12443
+ onClick: () => table.toggleAllRowsSelected(),
12444
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
12445
+ StyledCheckbox,
12446
+ {
12447
+ size: "small",
12448
+ dataTest: "cell-select-all",
12449
+ checked: table.getIsAllRowsSelected(),
12450
+ indeterminate: table.getIsSomeRowsSelected(),
12451
+ hideWrapper: true
12452
+ }
12453
+ )
12454
+ }
12455
+ );
12456
+ },
12457
+ cell: ({ cell }) => {
12458
+ const disabled = !cell.row.getCanSelect();
12459
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
12460
+ "button",
12461
+ {
12462
+ type: "button",
12463
+ style: { height: rowHeight ? rowHeight : "auto" },
12464
+ className: "pl-2 flex w-full items-center justify-start m-0 p-0",
12465
+ disabled,
12466
+ onClick: () => cell.row.toggleSelected(),
12467
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(StyledTooltip, { arrow: true, title: cell.row.getRowSelectionTooltip(), children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: disabled ? "cursor-not-allowed" : "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
12468
+ StyledCheckbox,
12469
+ {
12470
+ size: "small",
12471
+ dataTest: "cell-select",
12472
+ checked: cell.row.getIsSelected(),
12473
+ hideWrapper: true,
12474
+ disabled,
12475
+ onMouseUp: (e) => {
12476
+ e.preventDefault();
12477
+ e.stopPropagation();
12478
+ }
12479
+ }
12480
+ ) }) })
12481
+ }
12482
+ );
12483
+ },
12484
+ fixedLeft: isFixed2
12485
+ };
12486
+ }
12487
+ function ChevronDownIcon(props) {
12488
+ 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: "M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z" }) });
12489
+ }
12490
+ function generateExpandColumn(isFixed2, rowHeight) {
12491
+ return {
12492
+ id: EXPAND_COLUMN_ID,
12493
+ minSize: 50,
12494
+ maxSize: 50,
12495
+ size: 50,
12496
+ enableHiding: false,
12497
+ enableSorting: false,
12498
+ header: () => null,
12499
+ cell: ({ cell }) => {
12500
+ const isExpanded = cell.row.getIsExpanded();
12501
+ const canExpand = cell.row.getCanExpand();
12502
+ return canExpand ? /* @__PURE__ */ jsxRuntimeExports.jsx(
12503
+ "span",
12504
+ {
12505
+ className: "flex w-full outline-none focus:outline-none items-center justify-center",
12506
+ onClick: () => cell.row.getToggleExpandedHandler()(),
12507
+ style: { height: rowHeight ? rowHeight : "auto" },
12508
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
12509
+ ChevronDownIcon,
12510
+ {
12511
+ width: 24,
12512
+ height: 24,
12513
+ style: {
12514
+ rotate: isExpanded ? "180deg" : "0deg",
12515
+ transitionTimingFunction: "cubic-bezier(0.4, 0, 0.2, 1)",
12516
+ transitionDuration: "500ms"
12517
+ }
12518
+ }
12519
+ )
12520
+ }
12521
+ ) : null;
12522
+ },
12523
+ fixedLeft: isFixed2
12524
+ };
12525
+ }
12526
+ const useToggleMenuVisibility = () => {
12527
+ const [anchorEl, setAnchorEl] = useState(null);
12528
+ const [open, setOpen] = useState(false);
12529
+ const handleOpen = useCallback((event) => {
12530
+ setAnchorEl(event.currentTarget);
12531
+ setOpen(true);
12532
+ }, []);
12533
+ const handleClose = useCallback(() => {
12534
+ setOpen(false);
12535
+ }, []);
12536
+ return { open, handleClose, handleOpen, anchorEl };
12537
+ };
12538
+ function DotsVerticalIcon(props) {
12539
+ 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(
12540
+ "path",
12541
+ {
12542
+ fill: "currentColor",
12543
+ d: "M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2"
12544
+ }
12545
+ ) });
12546
+ }
12547
+ const StyledMenuItem$1 = (props) => {
12548
+ var _a;
12549
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
12550
+ MenuItem,
12551
+ {
12552
+ ...props,
12553
+ classes: {
12554
+ root: clsx("px-3 py-2.5", (_a = props.classes) == null ? void 0 : _a.root),
12555
+ ...props.classes
12556
+ },
12557
+ sx: {
12558
+ "&.Mui-disabled": {
12559
+ pointerEvents: "auto",
12560
+ cursor: "not-allowed",
12561
+ "&:hover": {
12562
+ backgroundColor: "transparent !important"
12563
+ }
12564
+ },
12565
+ ...props.sx
12566
+ }
12567
+ }
12568
+ );
12569
+ };
12570
+ const contained = "_contained_gteum_27";
12571
+ const common = "_common_gteum_27";
12572
+ const medium = "_medium_gteum_69";
12573
+ const small = "_small_gteum_74";
12574
+ const large = "_large_gteum_79";
12575
+ const error = "_error_gteum_84";
12576
+ const outlined = "_outlined_gteum_141";
12577
+ const text = "_text_gteum_255";
12578
+ const textGray = "_textGray_gteum_369";
12579
+ const textWhite = "_textWhite_gteum_426";
12580
+ const style$1 = {
12581
+ "asma-core-ui-button": "_asma-core-ui-button_gteum_1",
12582
+ contained,
12583
+ common,
12584
+ medium,
12585
+ small,
12586
+ large,
12587
+ error,
12588
+ outlined,
12589
+ text,
12590
+ textGray,
12591
+ textWhite
12592
+ };
12593
+ const BtnStyles = {
12594
+ contained: style$1["contained"],
12595
+ outlined: style$1["outlined"],
12596
+ text: style$1["text"],
12597
+ textGray: style$1["textGray"],
12598
+ textWhite: style$1["textWhite"],
12599
+ large: style$1["large"],
12600
+ small: style$1["small"],
12601
+ medium: style$1["medium"],
12602
+ error: style$1["error"],
12603
+ common: style$1["common"]
12604
+ };
12605
+ const StyledButton = ({
12606
+ variant = "contained",
12607
+ className = "",
12608
+ size = "medium",
12609
+ children,
12610
+ refLink,
12611
+ startIcon,
12612
+ endIcon,
12613
+ dataTest,
12614
+ error: error2,
12615
+ ...otherProps
12616
+ }) => {
12617
+ const isLarge = size === "large" || size === "medium";
12618
+ const color2 = error2 ? "error" : "common";
12619
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
12620
+ "button",
12621
+ {
12622
+ ...otherProps,
12623
+ className: clsx(
12624
+ style$1["asma-core-ui-button"],
12625
+ BtnStyles[variant],
12626
+ BtnStyles[color2],
12627
+ BtnStyles[size],
12628
+ className
12629
+ ),
12630
+ ref: refLink,
12631
+ "data-test": dataTest,
12632
+ children: [
12633
+ startIcon,
12634
+ children && /* @__PURE__ */ jsxRuntimeExports.jsx(
12635
+ "div",
12636
+ {
12637
+ style: {
12638
+ overflow: "hidden",
12639
+ textOverflow: "ellipsis",
12640
+ whiteSpace: "nowrap",
12641
+ display: "flex",
12642
+ alignItems: "center",
12643
+ justifyContent: "center",
12644
+ gap: isLarge ? "8px" : "4px",
12645
+ paddingLeft: isLarge ? "8px" : "4px",
12646
+ paddingRight: isLarge ? "8px" : "4px"
12647
+ },
12648
+ children
12649
+ }
12650
+ ),
12651
+ endIcon
12652
+ ]
12653
+ }
12654
+ );
12655
+ };
12630
12656
  function CircleWarningOutlineIcon(props) {
12631
12657
  return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16 ", ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { fill: "none", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", children: [
12632
12658
  /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "8", cy: "8", r: "6.25" }),
@@ -0,0 +1,2 @@
1
+ import type { TableFeature } from '@tanstack/react-table';
2
+ export declare const RowSelectionTooltipFeature: TableFeature;
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ import type { Row, RowData } from '@tanstack/react-table';
2
+ import type { ReactNode } from 'react';
3
+ export interface RowSelectionTooltipOptions<TData extends RowData> {
4
+ getRowSelectionTooltip?: (row: Row<TData>) => ReactNode;
5
+ }
6
+ export interface RowSelectionTooltipRow<TData extends RowData> {
7
+ getRowSelectionTooltip: () => ReturnType<NonNullable<RowSelectionTooltipOptions<TData>['getRowSelectionTooltip']>>;
8
+ }
@@ -1,18 +1,20 @@
1
- import type { ColumnPinningColumnDef, ColumnSizingColumnDef, GroupingColumnDef, RowData, SortingColumnDef, VisibilityColumnDef, AccessorFn, ColumnDefTemplate, CellContext, ColumnMeta, HeaderContext, Row, TableOptions, Table, ColumnDef } from '@tanstack/react-table';
1
+ import type { ColumnPinningColumnDef, ColumnSizingColumnDef, GroupingColumnDef, RowData, SortingColumnDef, VisibilityColumnDef, AccessorFn, ColumnDefTemplate, CellContext, ColumnMeta, HeaderContext, Row, RowModel, TableOptions, Table, ColumnDef } from '@tanstack/react-table';
2
2
  export type * from '@tanstack/react-table';
3
3
  import type { CSSProperties, MouseEvent, MutableRefObject, ReactElement, ReactNode } from 'react';
4
4
  import type { ExpandedRow, ExpandedRowsInstance, ExpandedRowsOptions, ExpandedRowsTableState } from './custom-features/expand-rows';
5
5
  import type { TooltipProps } from '@mui/material';
6
6
  import type { FocusedRowsOptions, FocusedRowsTableState, FocusedRow, FocusedRowsInstance } from './custom-features/focus-rows';
7
7
  import type { OrderedColumnsOptions, OrderedColumnsTableState } from './custom-features/order-columns';
8
+ import type { RowSelectionTooltipOptions, RowSelectionTooltipRow } from './custom-features/row-selection-tooltip';
8
9
  declare module '@tanstack/react-table' {
9
10
  interface TableState extends ExpandedRowsTableState, FocusedRowsTableState, OrderedColumnsTableState {
10
11
  }
11
- interface TableOptionsResolved<TData extends RowData> extends ExpandedRowsOptions, FocusedRowsOptions, OrderedColumnsOptions {
12
+ interface TableOptionsResolved<TData extends RowData> extends ExpandedRowsOptions, FocusedRowsOptions, OrderedColumnsOptions, RowSelectionTooltipOptions<TData> {
12
13
  }
13
- interface Row<TData extends RowData> extends ExpandedRow, FocusedRow {
14
+ interface Row<TData extends RowData> extends ExpandedRow, FocusedRow, RowSelectionTooltipRow<TData> {
14
15
  }
15
16
  interface Table<TData extends RowData> extends ExpandedRowsInstance, FocusedRowsInstance {
17
+ getCoreRowModel: () => RowModel<TData>;
16
18
  }
17
19
  interface ColumnDefExtensions<TData extends RowData, TValue = unknown> extends VisibilityColumnDef, ColumnPinningColumnDef, SortingColumnDef<TData>, GroupingColumnDef<TData, TValue>, ColumnSizingColumnDef {
18
20
  className?: string;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.0",
6
+ "version": "1.3.0",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist/**/*",