@stella-source/stellasource-dsl 0.2.3 → 0.2.7

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.
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { TableProps } from "./types";
3
- declare function Table<T>({ columns, data, isLoading, serverSide, onPageChange, onSortChange, onFilterChange, onRowSelect, rowStatuses, showSelection, showRowOptions, showPagination, variant, paginationDetails, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, }: TableProps<T>): React.JSX.Element;
3
+ declare function Table<T>({ columns, data, isLoading, serverSide, onPageChange, onSortChange, onFilterChange, onRowSelect, rowStatuses, showSelection, showRowOptions, showPagination, variant, paginationDetails, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, }: TableProps<T>): React.JSX.Element;
4
4
  export default Table;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ interface EmptyTableStateProps {
3
+ id?: string;
4
+ className?: string;
5
+ header: string;
6
+ subHeader?: string;
7
+ showClearFilterButton?: boolean;
8
+ onClearFilters?: () => void;
9
+ colSpan: number;
10
+ size?: "small" | "large";
11
+ }
12
+ declare const EmptyTableState: ({ id, className, header, subHeader, showClearFilterButton, colSpan, size, onClearFilters, }: EmptyTableStateProps) => React.JSX.Element;
13
+ export default EmptyTableState;
@@ -12,7 +12,7 @@ declare const HeaderCell: import("styled-components/dist/types").IStyledComponen
12
12
  declare const HeaderCellPosition: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
13
13
  declare const TableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
14
14
  declare const TableWrapperScroll: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
15
- $filterMenuOpen: boolean;
15
+ $stopScroll: boolean;
16
16
  }>> & string;
17
17
  declare const StyledTable: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, never>> & string;
18
18
  declare const CustomIconButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("../IconButton/types").IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>, HeaderIconButtonProps>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("../IconButton/types").IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>, keyof import("react").Component<any, {}, any>>;
@@ -41,4 +41,11 @@ declare const LoadingShimmer: import("styled-components/dist/types").IStyledComp
41
41
  }>> & string;
42
42
  declare const CustomPagination: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../Pagination/types").PaginationProps, never>> & string & Omit<({ isLoading, rowsPerPage, totalRows, ariaLabel, onPageChange, startingPage, id, className, htmlProps, }: import("../Pagination/types").PaginationProps) => import("react").JSX.Element, keyof import("react").Component<any, {}, any>>;
43
43
  declare const KebabAlign: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
44
- export { HeaderCell, TableWrapper, TableWrapperScroll, StyledTable, CustomIconButton, SortButton, HeaderRow, FilterMenu, Checkbox, BodyCell, HeaderCellPosition, MenuButton, MenuItem, FilterBoxLabel, LoadingShimmer, FilterLabelTransparent, CustomPagination, CellRow, MenuItemGroup, KebabAlign, MenuItemOption, };
44
+ declare const EmptyTableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, never>> & string;
45
+ declare const EmptyTableSection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {
46
+ $size?: "small" | "large";
47
+ }>> & string;
48
+ declare const EmptyTableHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
49
+ declare const EmptyTableSubHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
50
+ declare const ClearFilterButtonRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
51
+ export { HeaderCell, TableWrapper, TableWrapperScroll, StyledTable, CustomIconButton, SortButton, HeaderRow, FilterMenu, Checkbox, BodyCell, HeaderCellPosition, MenuButton, MenuItem, FilterBoxLabel, LoadingShimmer, FilterLabelTransparent, CustomPagination, CellRow, MenuItemGroup, KebabAlign, MenuItemOption, EmptyTableCell, EmptyTableSection, EmptyTableHeader, EmptyTableSubHeader, ClearFilterButtonRow, };
@@ -38,6 +38,12 @@ export interface TableProps<T> {
38
38
  paginationDetails?: PaginationDetails;
39
39
  rowStatuses?: Record<number | string, RowStatus>;
40
40
  resetTrigger?: number;
41
+ emptyTableState: {
42
+ header: string;
43
+ subHeader?: string;
44
+ showClearFilterButton?: boolean;
45
+ onClearFilters?: () => void;
46
+ };
41
47
  }
42
48
  export interface CustomColumnMeta {
43
49
  headerAlign?: "left" | "right";
@@ -13,8 +13,8 @@ export declare enum QuoteCategory {
13
13
  interface TableUnitsAndTotalsProps {
14
14
  id?: string;
15
15
  className?: string;
16
- value: number;
17
- subValue?: number;
16
+ value: number | string;
17
+ subValue?: number | string;
18
18
  rightCategory?: `${QuoteCategory}`;
19
19
  }
20
20
  interface TotalPriceProps {
@@ -0,0 +1,4 @@
1
+ import { WhiteLabelCSSOverridesProps } from "./WhiteLabelCSSOverrides";
2
+ export declare const getValueFromColorVar: (color?: string) => string | undefined;
3
+ export declare const getButtonHover: (all: WhiteLabelCSSOverridesProps) => string;
4
+ export declare const getButtonHoverST: (all: WhiteLabelCSSOverridesProps) => string;
@@ -0,0 +1,9 @@
1
+ export interface WhiteLabelCSSOverridesProps {
2
+ primary?: string;
3
+ secondary?: string;
4
+ tertiary?: string;
5
+ quaternary?: string;
6
+ accent?: string;
7
+ }
8
+ declare const WhiteLabelCSSOverrides: import("react").NamedExoticComponent<import("styled-components").ExecutionProps & WhiteLabelCSSOverridesProps>;
9
+ export default WhiteLabelCSSOverrides;
@@ -1,2 +1 @@
1
1
  export declare const formatDynamicNumbersWithCommas: (num: number | string, decimalPlaces: number) => string;
2
- export declare const formatNumberWithDecimals: (num: number | string, decimalPlaces?: number, isCurrency?: boolean) => string;
@@ -3414,7 +3414,7 @@ var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
3414
3414
  * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
3415
3415
  * exposing only those methods and properties that are defined in the spec.
3416
3416
  */
3417
- var ResizeObserver$1 = /** @class */ (function () {
3417
+ var ResizeObserver$2 = /** @class */ (function () {
3418
3418
  /**
3419
3419
  * Creates a new instance of ResizeObserver.
3420
3420
  *
@@ -3440,7 +3440,7 @@ var ResizeObserver$1 = /** @class */ (function () {
3440
3440
  'unobserve',
3441
3441
  'disconnect'
3442
3442
  ].forEach(function (method) {
3443
- ResizeObserver$1.prototype[method] = function () {
3443
+ ResizeObserver$2.prototype[method] = function () {
3444
3444
  var _a;
3445
3445
  return (_a = observers.get(this))[method].apply(_a, arguments);
3446
3446
  };
@@ -3451,7 +3451,7 @@ var index = (function () {
3451
3451
  if (typeof global$1.ResizeObserver !== 'undefined') {
3452
3452
  return global$1.ResizeObserver;
3453
3453
  }
3454
- return ResizeObserver$1;
3454
+ return ResizeObserver$2;
3455
3455
  })();
3456
3456
 
3457
3457
  // =============================== Const ===============================
@@ -3691,7 +3691,7 @@ if (process.env.NODE_ENV !== 'production') {
3691
3691
  }
3692
3692
 
3693
3693
  var INTERNAL_PREFIX_KEY = 'rc-observer-key';
3694
- function ResizeObserver(props, ref) {
3694
+ function ResizeObserver$1(props, ref) {
3695
3695
  var children = props.children;
3696
3696
  var childNodes = typeof children === 'function' ? [children] : toArray$2(children);
3697
3697
  if (process.env.NODE_ENV !== 'production') {
@@ -3709,7 +3709,7 @@ function ResizeObserver(props, ref) {
3709
3709
  }), child);
3710
3710
  });
3711
3711
  }
3712
- var RefResizeObserver = /*#__PURE__*/a$j.forwardRef(ResizeObserver);
3712
+ var RefResizeObserver = /*#__PURE__*/a$j.forwardRef(ResizeObserver$1);
3713
3713
  if (process.env.NODE_ENV !== 'production') {
3714
3714
  RefResizeObserver.displayName = 'ResizeObserver';
3715
3715
  }
@@ -16779,7 +16779,6 @@ const variantSelector = (variant) => {
16779
16779
  }
16780
16780
 
16781
16781
  &:disabled {
16782
- background-color: var(--DSL-button-st-background-disabled);
16783
16782
  border: 1px solid var(--DSL-button-disabled);
16784
16783
  color: var(--DSL-button-disabled);
16785
16784
  & svg {
@@ -16813,7 +16812,6 @@ const variantSelector = (variant) => {
16813
16812
  }
16814
16813
 
16815
16814
  &:disabled {
16816
- background-color: var(--DSL-button-st-background-disabled);
16817
16815
  color: var(--DSL-button-disabled);
16818
16816
  & svg {
16819
16817
  fill: var(--DSL-button-disabled);
@@ -16853,6 +16851,7 @@ const ButtonComponent = styled.button.attrs({
16853
16851
  }
16854
16852
 
16855
16853
  /* Button CSS Variables */
16854
+ /* p = primary, st = secondary, tertiary */
16856
16855
  --DSL-button-branding: ${Styles.color.core.primary};
16857
16856
  --DSL-button-hover: ${Styles.color.blue.darkNavy};
16858
16857
  --DSL-button-active: ${Styles.color.blue.darkNavy};
@@ -17017,7 +17016,7 @@ const IconContainer = styled.div `
17017
17016
  `;
17018
17017
 
17019
17018
  const TextFieldContainer = ({ id, label, children, tooltipText, endIcon, className, rightCategory, leftCategory, helperText, dataTestId, helperTextAffectLayout = true, disabled = false, hideLabel = false, isLoading = false, hasError = false, isRequired = false, }) => {
17020
- return (a__default.createElement(Wrapper, { "data-testId": dataTestId, className: className },
17019
+ return (a__default.createElement(Wrapper, { "data-testid": dataTestId, className: className },
17021
17020
  a__default.createElement(Label, { tooltipText: tooltipText, required: isRequired, labelValue: label, hideLabel: hideLabel, id: `${id}-label`, htmlFor: `${id}-text-field` }),
17022
17021
  a__default.createElement(TextFieldWrapper, { id: id, "$hasError": hasError, "$isDisabled": disabled, "$isLoading": isLoading, "data-testid": "text-input-wrapper" },
17023
17022
  leftCategory && a__default.createElement(Category, null, leftCategory),
@@ -17107,19 +17106,6 @@ const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
17107
17106
  })}${decimalEnding ? "." : ""}${decimalZero ? "0" : ""}`
17108
17107
  : "";
17109
17108
  };
17110
- const formatNumberWithDecimals = (num, decimalPlaces = 2, isCurrency = false) => {
17111
- if (num === null || num === undefined || num === "")
17112
- return "";
17113
- const parsed = Number(num);
17114
- if (isNaN(parsed))
17115
- return "";
17116
- return parsed.toLocaleString("en-US", {
17117
- style: isCurrency ? "currency" : "decimal",
17118
- currency: isCurrency ? "USD" : undefined,
17119
- minimumFractionDigits: decimalPlaces,
17120
- maximumFractionDigits: decimalPlaces,
17121
- });
17122
- };
17123
17109
 
17124
17110
  const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, label, onChange, onBlur, onFocus, value, isRequired, maxLength, tooltipText, helperText, endIcon, placeholder = "0", textAlign = "left", isTruncated = false, helperTextAffectLayout = true, hideLabel = false, disabled = false, isLoading = false, hasError = false, thousandSeparator = true, decimalPlaces = 0, allowNegativeNumbers = false, ariaDescribedBy, }) => {
17125
17111
  const containerProps = {
@@ -20623,8 +20609,8 @@ const SelectCaret = styled(StellaIcon) `
20623
20609
  position: absolute;
20624
20610
  right: 0;
20625
20611
  pointer-events: none;
20626
- color: ${Styles.color.blue.primary};
20627
- fill: ${Styles.color.blue.primary};
20612
+ color: ${Styles.color.core.primary};
20613
+ fill: ${Styles.color.core.primary};
20628
20614
  transform: rotate(180deg);
20629
20615
  `;
20630
20616
  const RowInfo = styled.div `
@@ -20742,11 +20728,11 @@ const HeaderCell = styled.th `
20742
20728
  : "unset"};
20743
20729
  z-index: ${({ $isPinnedLeft, $isPinnedRight }) => $isPinnedLeft || $isPinnedRight ? 2 : 1};
20744
20730
  text-align: inherit;
20745
- padding: 8px 12px;
20731
+ padding: 0px 12px;
20746
20732
  font-weight: 400;
20747
20733
  font-size: 14px;
20748
20734
  color: ${Styles.color.grey.charcoal};
20749
- border-bottom: 1px solid ${Styles.color.grey.medium};
20735
+ border-bottom: 1px solid ${Styles.color.grey.light};
20750
20736
  background-color: ${Styles.color.grey.pale};
20751
20737
  transition: box-shadow 0.3s ease-out;
20752
20738
  & button {
@@ -20773,6 +20759,7 @@ const HeaderCellPosition = styled.div `
20773
20759
  `;
20774
20760
  const TableWrapper = styled.div `
20775
20761
  width: 100%;
20762
+ position: relative;
20776
20763
  overflow-x: hidden;
20777
20764
  border: 1px solid ${Styles.color.grey.light};
20778
20765
  border-radius: 5px;
@@ -20781,7 +20768,8 @@ const TableWrapper = styled.div `
20781
20768
  `;
20782
20769
  const TableWrapperScroll = styled.div `
20783
20770
  width: 100%;
20784
- overflow-x: ${({ $filterMenuOpen }) => ($filterMenuOpen ? "hidden" : "auto")};
20771
+ overflow-x: ${({ $stopScroll }) => ($stopScroll ? "hidden" : "auto")};
20772
+ overflow-y: hidden;
20785
20773
  `;
20786
20774
  const StyledTable = styled.table `
20787
20775
  width: 100%;
@@ -20820,6 +20808,11 @@ const HeaderRow = styled.tr `
20820
20808
  const CellRow = styled.tr `
20821
20809
  min-height: 50px;
20822
20810
  height: 50px;
20811
+ &:hover {
20812
+ & > td {
20813
+ background-color: ${Styles.color.blue.pale};
20814
+ }
20815
+ }
20823
20816
  `;
20824
20817
  const FilterMenu = styled.div `
20825
20818
  position: absolute;
@@ -20860,10 +20853,10 @@ const BodyCell = styled.td `
20860
20853
  : "unset"};
20861
20854
  z-index: ${({ $isPinnedLeft, $isPinnedRight }) => $isPinnedLeft || $isPinnedRight ? 1 : 0};
20862
20855
  background: white;
20863
- padding: 8px 12px;
20856
+ padding: 0px 12px;
20864
20857
  font-size: 12px;
20865
20858
  color: ${Styles.color.grey.charcoal};
20866
- border-bottom: ${({ $isLastRow }) => $isLastRow ? "none" : `1px solid ${Styles.color.grey.medium}`};
20859
+ border-bottom: ${({ $isLastRow }) => $isLastRow ? "none" : `1px solid ${Styles.color.grey.light}`};
20867
20860
  transition: box-shadow 0.3s ease-out;
20868
20861
  `;
20869
20862
  const MenuButton = styled.button `
@@ -21011,12 +21004,57 @@ const LoadingShimmer = styled.div `
21011
21004
  }
21012
21005
  `;
21013
21006
  const CustomPagination = styled(Pagination) `
21014
- border-top: 1px solid ${Styles.color.grey.medium};
21007
+ border-top: 1px solid ${Styles.color.grey.light};
21015
21008
  `;
21016
21009
  const KebabAlign = styled.div `
21017
21010
  display: flex;
21018
21011
  justify-content: end;
21019
21012
  `;
21013
+ // EmptyTableState
21014
+ const EmptyTableCell = styled.td `
21015
+ padding: 10rem;
21016
+ background-color: white;
21017
+ `;
21018
+ const EmptyTableSection = styled.section `
21019
+ width: ${({ $size }) => ($size === "small" ? "360px" : "450px")};
21020
+ display: flex;
21021
+ flex-direction: column;
21022
+ justify-content: center;
21023
+ align-items: center;
21024
+ position: absolute;
21025
+ gap: 20px;
21026
+ top: 50px;
21027
+ left: 0;
21028
+ right: 0;
21029
+ margin: 80px auto 0;
21030
+ `;
21031
+ const EmptyTableHeader = styled.p `
21032
+ display: flex;
21033
+ justify-content: center;
21034
+ align-items: center;
21035
+ color: ${Styles.color.grey.smoke};
21036
+ font-size: 22px;
21037
+ font-weight: 400;
21038
+ text-align: center;
21039
+ line-height: 22px;
21040
+ margin-bottom: 0px;
21041
+ `;
21042
+ const EmptyTableSubHeader = styled.p `
21043
+ display: flex;
21044
+ justify-content: center;
21045
+ align-items: center;
21046
+ color: ${Styles.color.grey.shadow};
21047
+ font-size: 18px;
21048
+ text-align: center;
21049
+ font-weight: 400;
21050
+ margin-top: 0px;
21051
+ `;
21052
+ const ClearFilterButtonRow = styled.div `
21053
+ display: "flex";
21054
+ justify-content: "center";
21055
+ align-items: "center";
21056
+ text-align: "center";
21057
+ `;
21020
21058
 
21021
21059
  const IndeterminateCheckbox = ({ isIndeterminate, isChecked, onChange, }) => {
21022
21060
  const ref = useRef(null);
@@ -21038,7 +21076,11 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21038
21076
  const [coords, setCoords] = useState({ top: 0, left: 0 });
21039
21077
  const [tempFilters, setTempFilters] = useState([]);
21040
21078
  const [currentAppliedFilters, setCurrentAppliedFilters] = useState([]);
21079
+ const [filterOptions, setFilterOptions] = useState([]);
21041
21080
  const [textAlign, setTextAlign] = useState("left");
21081
+ useEffect(() => {
21082
+ setFilterOptions(meta?.filterOptions || []);
21083
+ }, [meta]);
21042
21084
  const toggleMenu = (e) => {
21043
21085
  e.stopPropagation();
21044
21086
  if (buttonRef.current) {
@@ -21063,7 +21105,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21063
21105
  const insideButton = !!buttonRef.current?.contains(target);
21064
21106
  const insideMenu = !!menuRef.current?.contains(target);
21065
21107
  if (!insideButton && !insideMenu) {
21066
- setTempFilters(currentAppliedFilters);
21108
+ setTempFilters(filters?.[header.id] || currentAppliedFilters);
21067
21109
  showFilterMenu(false);
21068
21110
  }
21069
21111
  };
@@ -21095,7 +21137,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21095
21137
  a__default.createElement(HeaderCellPosition, { style: {
21096
21138
  justifyContent: textAlign === "left" ? "start" : "end",
21097
21139
  } },
21098
- textAlign === "left" && (a__default.createElement("span", null, flexRender(columnDef.header, header.getContext()))),
21140
+ textAlign === "left" && (a__default.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))),
21099
21141
  header.column.getCanFilter() && (a__default.createElement("div", { style: {
21100
21142
  display: "flex",
21101
21143
  alignItems: "center",
@@ -21122,7 +21164,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21122
21164
  } }),
21123
21165
  a__default.createElement(FilterBoxLabel, { htmlFor: "all-checkbox" }, "Select All"))),
21124
21166
  (serverSide
21125
- ? meta?.filterOptions
21167
+ ? filterOptions
21126
21168
  : Array.from(header.column.getFacetedUniqueValues().keys()))?.map((item) => {
21127
21169
  if (meta?.singleSelect) {
21128
21170
  return (a__default.createElement(MenuItemOption, { key: item, id: `${item}-button`, onClick: () => {
@@ -21157,7 +21199,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21157
21199
  setCurrentAppliedFilters([]);
21158
21200
  } }, "Clear Filter"))), document.body))),
21159
21201
  header.column.getCanSort() && (a__default.createElement(SortButton, { className: "icon", iconName: "sort", ariaLabel: "Sort Button", variant: "tertiary", "$active": sorting.some((s) => s.id === header.column.id), "$sort": column.getIsSorted(), onClick: (e) => header.column.getToggleSortingHandler()?.(e) })),
21160
- textAlign === "right" && (a__default.createElement("span", null, flexRender(columnDef.header, header.getContext()))))));
21202
+ textAlign === "right" && (a__default.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))))));
21161
21203
  };
21162
21204
 
21163
21205
  const RowOptions = ({ row, selectionMenuItems }) => {
@@ -21202,12 +21244,21 @@ const RowOptions = ({ row, selectionMenuItems }) => {
21202
21244
  })), document.body)));
21203
21245
  };
21204
21246
 
21247
+ const EmptyTableState = ({ id, className, header, subHeader, showClearFilterButton, colSpan, size = "large", onClearFilters, }) => {
21248
+ return (a__default.createElement("tr", null,
21249
+ a__default.createElement(EmptyTableCell, { colSpan: colSpan },
21250
+ a__default.createElement(EmptyTableSection, { "$size": size, id: id, className: className },
21251
+ a__default.createElement(EmptyTableHeader, null, header),
21252
+ a__default.createElement(EmptyTableSubHeader, null, subHeader),
21253
+ a__default.createElement(ClearFilterButtonRow, null, showClearFilterButton && (a__default.createElement(StellaButton, { label: "Clear Filters", onClick: () => onClearFilters?.(), variant: "secondary" })))))));
21254
+ };
21255
+
21205
21256
  // DataTable.tsx
21206
21257
  function Table({ columns, data, isLoading, serverSide = false, onPageChange, onSortChange, onFilterChange, onRowSelect, rowStatuses, showSelection = false, showRowOptions = false, showPagination = true, variant, paginationDetails = {
21207
21258
  startingPage: 1,
21208
21259
  rowsPerPage: 10,
21209
21260
  totalRows: data.length,
21210
- }, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, }) {
21261
+ }, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, }) {
21211
21262
  const [rowSelection, setRowSelection] = useState({});
21212
21263
  const [selectedRows] = useState({});
21213
21264
  const [pageIndex, setPageIndex] = useState(paginationDetails?.startingPage);
@@ -21215,6 +21266,8 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21215
21266
  pageIndex: paginationDetails?.startingPage - 1,
21216
21267
  pageSize: paginationDetails?.rowsPerPage || 10,
21217
21268
  });
21269
+ const [localData, setLocalData] = useState(data);
21270
+ const [localColumns, setLocalColumns] = useState(columns);
21218
21271
  const [totalData, setTotalData] = useState(paginationDetails?.totalRows);
21219
21272
  const [sorting, setSorting] = useState([]);
21220
21273
  const [filters, setFilters] = useState({});
@@ -21233,20 +21286,51 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21233
21286
  }, [rowStatuses]);
21234
21287
  useEffect(() => {
21235
21288
  setTotalData(paginationDetails?.totalRows);
21236
- }, [paginationDetails.totalRows, data]);
21237
- useEffect(() => {
21238
- const el = scrollRef?.current;
21289
+ setPagination({
21290
+ pageIndex: paginationDetails?.startingPage - 1,
21291
+ pageSize: paginationDetails?.rowsPerPage || 10,
21292
+ });
21293
+ setLocalColumns(columns);
21294
+ setLocalData(data);
21295
+ }, [paginationDetails, data, columns]);
21296
+ useLayoutEffect$1(() => {
21297
+ const el = scrollRef.current;
21239
21298
  if (!el)
21240
21299
  return;
21241
- const handleScroll = () => {
21242
- const atLeft = el.scrollLeft <= 0;
21243
- const atRight = el.scrollWidth - el.scrollLeft <= el.clientWidth + 1;
21300
+ let raf = 0;
21301
+ const update = () => {
21302
+ const maxScrollLeft = Math.max(0, el.scrollWidth - el.clientWidth);
21303
+ const hasOverflow = maxScrollLeft > 1; // tolerance for rounding
21304
+ let atLeft = el.scrollLeft <= 0;
21305
+ let atRight = el.scrollLeft >= maxScrollLeft - 1;
21306
+ if (!hasOverflow) {
21307
+ atLeft = true;
21308
+ atRight = true;
21309
+ }
21244
21310
  setScrollState({ atLeft, atRight });
21245
21311
  };
21246
- el.addEventListener("scroll", handleScroll);
21247
- handleScroll(); // initial check
21248
- return () => el.removeEventListener("scroll", handleScroll);
21249
- }, [scrollRef]);
21312
+ const schedule = () => {
21313
+ cancelAnimationFrame(raf);
21314
+ raf = requestAnimationFrame(update);
21315
+ };
21316
+ // Listen to scroll
21317
+ el.addEventListener("scroll", schedule);
21318
+ // Recalculate when sizes change
21319
+ const ro = new ResizeObserver(schedule);
21320
+ ro.observe(el);
21321
+ const tableEl = el.querySelector("table");
21322
+ if (tableEl)
21323
+ ro.observe(tableEl);
21324
+ window.addEventListener("resize", schedule);
21325
+ // Initial measurement after layout
21326
+ schedule();
21327
+ return () => {
21328
+ el.removeEventListener("scroll", schedule);
21329
+ window.removeEventListener("resize", schedule);
21330
+ ro.disconnect();
21331
+ cancelAnimationFrame(raf);
21332
+ };
21333
+ }, []);
21250
21334
  const handleInputChange = (rowId, field, value) => {
21251
21335
  setRowState((prev) => ({
21252
21336
  ...prev,
@@ -21267,7 +21351,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21267
21351
  size: 20,
21268
21352
  });
21269
21353
  }
21270
- cols.push(...columns);
21354
+ cols.push(...localColumns);
21271
21355
  if (showRowOptions) {
21272
21356
  cols.push({
21273
21357
  id: "options",
@@ -21279,9 +21363,16 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21279
21363
  });
21280
21364
  }
21281
21365
  return cols;
21282
- }, [columns, selectedRows, data, onRowSelect, showSelection, showRowOptions]);
21366
+ }, [
21367
+ localColumns,
21368
+ selectedRows,
21369
+ localData,
21370
+ onRowSelect,
21371
+ showSelection,
21372
+ showRowOptions,
21373
+ ]);
21283
21374
  const table = useReactTable({
21284
- data,
21375
+ data: localData,
21285
21376
  columns: enhancedColumns,
21286
21377
  state: {
21287
21378
  pagination,
@@ -21354,7 +21445,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21354
21445
  });
21355
21446
  };
21356
21447
  return (a__default.createElement(TableWrapper, { className: className, id: id, "data-testid": dataTestId, "data-auto": dataAuto },
21357
- a__default.createElement(TableWrapperScroll, { "$filterMenuOpen": Object.values(filterMenuOpen).some((value) => value), ref: scrollRef }, isLoading ? (a__default.createElement("div", null,
21448
+ a__default.createElement(TableWrapperScroll, { "$stopScroll": Object.values(filterMenuOpen).some((value) => value), ref: scrollRef }, isLoading ? (a__default.createElement("div", null,
21358
21449
  a__default.createElement("div", { style: {
21359
21450
  width: "100%",
21360
21451
  maxWidth: "100%",
@@ -21389,39 +21480,45 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21389
21480
  }));
21390
21481
  } }));
21391
21482
  }))))),
21392
- a__default.createElement("tbody", null, table.getRowModel().rows.map((row) => (a__default.createElement(CellRow, { key: row.id }, row.getVisibleCells().map((cell) => {
21393
- const value = flexRender(cell.column.columnDef.cell, {
21394
- ...cell.getContext(),
21395
- localValue: rowState[row.id]?.[cell.column.id],
21396
- onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
21397
- });
21398
- const meta = cell.column.columnDef.meta;
21399
- return (a__default.createElement(BodyCell, { key: cell.id, style: {
21400
- width: cell.column.getSize(),
21401
- textAlign: meta?.cellAlign ||
21402
- (typeof cell.getValue() === "number" ||
21403
- meta?.dataType === "number"
21404
- ? "right"
21405
- : "left"),
21406
- boxShadow: scrollState.atLeft &&
21407
- cell.column.getIsPinned() === "left"
21408
- ? "none"
21409
- : scrollState.atRight &&
21410
- cell.column.getIsPinned() === "right"
21483
+ a__default.createElement("tbody", null,
21484
+ table.getRowModel().rows.length === 0 && (a__default.createElement(EmptyTableState, { header: emptyTableState.header, subHeader: emptyTableState.subHeader, showClearFilterButton: emptyTableState.showClearFilterButton, onClearFilters: resetTable, colSpan: table.getVisibleLeafColumns().length, size: "large" })),
21485
+ table.getRowModel().rows.map((row) => (a__default.createElement(CellRow, { key: row.id }, row.getVisibleCells().map((cell) => {
21486
+ const value = flexRender(cell.column.columnDef.cell, {
21487
+ ...cell.getContext(),
21488
+ localValue: rowState[row.id]?.[cell.column.id],
21489
+ onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
21490
+ });
21491
+ const meta = cell.column.columnDef.meta;
21492
+ return (a__default.createElement(BodyCell, { key: cell.id, style: {
21493
+ width: cell.column.getSize(),
21494
+ textAlign: meta?.cellAlign ||
21495
+ (typeof cell.getValue() === "number" ||
21496
+ meta?.dataType === "number"
21497
+ ? "right"
21498
+ : "left"),
21499
+ boxShadow: scrollState.atLeft &&
21500
+ cell.column.getIsPinned() === "left"
21411
21501
  ? "none"
21412
- : undefined,
21413
- backgroundColor: table
21414
- .getSelectedRowModel()
21415
- .rows.find((r) => r.id === row.id)
21416
- ? "#EBF0FA"
21417
- : rowStatusesState?.[row.id] === "action-pending"
21418
- ? "#FFFDEB"
21419
- : rowStatusesState?.[row.id] === "completed"
21420
- ? "#F5F5F5"
21421
- : "white",
21422
- }, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": row.index === table.getRowModel().rows.length - 1 }, value));
21423
- })))))))),
21424
- showPagination && paginationDetails?.totalRows && (a__default.createElement(CustomPagination, { totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
21502
+ : scrollState.atRight &&
21503
+ cell.column.getIsPinned() === "right"
21504
+ ? "none"
21505
+ : undefined,
21506
+ backgroundColor: table
21507
+ .getSelectedRowModel()
21508
+ .rows.find((r) => r.id === row.id)
21509
+ ? "#EBF0FA"
21510
+ : rowStatusesState?.[row.id] === "action-pending"
21511
+ ? "#FFFDEB"
21512
+ : rowStatusesState?.[row.id] === "completed"
21513
+ ? "#F5F5F5"
21514
+ : "",
21515
+ }, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": serverSide
21516
+ ? row.index === table.getRowModel().rows.length - 1
21517
+ : row.index -
21518
+ pagination.pageSize * pagination.pageIndex ===
21519
+ table.getRowModel().rows.length - 1 }, value));
21520
+ })))))))),
21521
+ showPagination && paginationDetails?.totalRows > 0 && (a__default.createElement(CustomPagination, { totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
21425
21522
  setPageIndex(page);
21426
21523
  setPagination((prev) => ({
21427
21524
  ...prev,
@@ -21546,13 +21643,9 @@ const SubHeaderText = styled.span `
21546
21643
  const TableUnitsAndTotals = ({ id, className, value, subValue, variant, leftCategory = TableUnitsAndTotalsLeftCategory.US_CURRENCY, rightCategory, }) => {
21547
21644
  const isWeight = variant === QuoteVariants.TOTAL_WEIGHT;
21548
21645
  const leftCategoryValue = isWeight ? "" : leftCategory;
21549
- const header = (leftCategoryValue ?? "") +
21550
- formatNumberWithDecimals(value, 2, false) +
21551
- (rightCategory && isWeight ? ` ${rightCategory}` : "");
21552
- const subHeader = subValue !== undefined
21553
- ? (leftCategoryValue ?? "") +
21554
- formatNumberWithDecimals(subValue, 3, false) +
21555
- (rightCategory ? ` ${rightCategory}` : "")
21646
+ const header = `${leftCategoryValue ?? ""}${value} ${rightCategory && isWeight ? ` ${rightCategory}` : ""}`;
21647
+ const subHeader = subValue
21648
+ ? `${leftCategoryValue ?? ""}${subValue} ${rightCategory ? ` ${rightCategory}` : ""}`
21556
21649
  : undefined;
21557
21650
  return (a__default.createElement(Container, { id: id, className: className },
21558
21651
  a__default.createElement(Column, { "$align": "right" },