@stella-source/stellasource-dsl 0.2.9 → 1.2.10

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.
@@ -13,6 +13,7 @@ interface HeaderCellProps {
13
13
  atRight: boolean;
14
14
  };
15
15
  onFilterMenuInteraction?: (id: string | number, active: boolean) => void;
16
+ onFilterApply?: () => void;
16
17
  }
17
- declare const TableHeaderCell: ({ header, serverSide, filters, sorting, scrollPosition, onFilterMenuInteraction, }: HeaderCellProps) => React.JSX.Element;
18
+ declare const TableHeaderCell: ({ header, serverSide, filters, sorting, scrollPosition, onFilterMenuInteraction, onFilterApply, }: HeaderCellProps) => React.JSX.Element;
18
19
  export default TableHeaderCell;
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { TableUnitsAndTotals as TableUnitsAndTotalsProps } from "./types";
3
- declare const TableUnitsAndTotals: ({ id, className, value, subValue, variant, leftCategory, rightCategory, }: TableUnitsAndTotalsProps) => React.JSX.Element;
2
+ import { TableUnitsAndTotalsProps } from "./types";
3
+ declare const TableUnitsAndTotals: ({ id, className, value, subValue, valueRightCategory, valueLeftCategory, subValueRightCategory, subValueLeftCategory }: TableUnitsAndTotalsProps) => React.JSX.Element;
4
4
  export default TableUnitsAndTotals;
@@ -1,32 +1,19 @@
1
- export declare enum QuoteVariants {
2
- TOTAL_PRICE = "total-price",
3
- TOTAL_WEIGHT = "total-weight"
4
- }
5
- export declare enum QuoteCategory {
6
- ITEM = "/item",
7
- HOUR = "/hr",
8
- CWT = "CWT",
9
- LBS = "lbs",
10
- KG = "kg",
11
- TON = "ton"
12
- }
13
- interface TableUnitsAndTotalsProps {
1
+ interface TableUnitsAndTotalsCoreProps {
14
2
  id?: string;
15
3
  className?: string;
16
4
  value: number | string;
17
- subValue?: number | string;
18
- rightCategory?: `${QuoteCategory}`;
19
- }
20
- interface TotalPriceProps {
21
- variant: `${QuoteVariants.TOTAL_PRICE}`;
22
- leftCategory?: `${TableUnitsAndTotalsLeftCategory}`;
5
+ valueRightCategory?: string;
6
+ valueLeftCategory?: string;
23
7
  }
24
- interface TotalWeightProps {
25
- variant: `${QuoteVariants.TOTAL_WEIGHT}`;
26
- leftCategory?: never;
8
+ interface TableUnitsAndTotalsSubValueProps {
9
+ subValue: number | string;
10
+ subValueRightCategory?: string;
11
+ subValueLeftCategory?: string;
27
12
  }
28
- export type TableUnitsAndTotals = TableUnitsAndTotalsProps & (TotalPriceProps | TotalWeightProps);
29
- export declare enum TableUnitsAndTotalsLeftCategory {
30
- US_CURRENCY = "$"
13
+ interface TableUnitsAndTotalsWithoutSubValueProps {
14
+ subValue?: never;
15
+ subValueRightCategory?: never;
16
+ subValueLeftCategory?: never;
31
17
  }
18
+ export type TableUnitsAndTotalsProps = TableUnitsAndTotalsCoreProps & (TableUnitsAndTotalsSubValueProps | TableUnitsAndTotalsWithoutSubValueProps);
32
19
  export {};
@@ -21066,7 +21066,7 @@ const IndeterminateCheckbox = ({ isIndeterminate, isChecked, onChange, }) => {
21066
21066
  return (a__default.createElement(Checkbox, { ref: ref, checked: isChecked, onChange: (e) => onChange?.(e) }));
21067
21067
  };
21068
21068
 
21069
- const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition, onFilterMenuInteraction, }) => {
21069
+ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition, onFilterMenuInteraction, onFilterApply, }) => {
21070
21070
  const column = header.column;
21071
21071
  const columnDef = column.columnDef;
21072
21072
  const meta = columnDef.meta;
@@ -21172,6 +21172,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21172
21172
  setCurrentAppliedFilters([item]);
21173
21173
  column?.setFilterValue([item]);
21174
21174
  showFilterMenu(false);
21175
+ onFilterApply?.();
21175
21176
  }, "$applied": tempFilters?.includes(item) }, item));
21176
21177
  }
21177
21178
  return (a__default.createElement(MenuItem, { key: item },
@@ -21192,12 +21193,14 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21192
21193
  setCurrentAppliedFilters(tempFilters);
21193
21194
  column?.setFilterValue(tempFilters?.length > 0 ? tempFilters : []);
21194
21195
  showFilterMenu(false);
21196
+ onFilterApply?.();
21195
21197
  } }, "Apply Selection")),
21196
21198
  filters?.[header.id]?.length > 0 && (a__default.createElement(MenuButton, { key: "clear", onClick: () => {
21197
21199
  column?.setFilterValue([]);
21198
21200
  showFilterMenu(false);
21199
21201
  setTempFilters([]);
21200
21202
  setCurrentAppliedFilters([]);
21203
+ onFilterApply?.();
21201
21204
  } }, "Clear Filter"))), document.body))),
21202
21205
  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) })),
21203
21206
  textAlign === "right" && (a__default.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))))));
@@ -21478,6 +21481,12 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21478
21481
  ...prev,
21479
21482
  [id]: active,
21480
21483
  }));
21484
+ }, onFilterApply: () => {
21485
+ setPageIndex(1);
21486
+ setPagination((prev) => ({
21487
+ ...prev,
21488
+ pageIndex: 0,
21489
+ }));
21481
21490
  } }));
21482
21491
  }))))),
21483
21492
  a__default.createElement("tbody", null,
@@ -21589,25 +21598,6 @@ const Sync = ({ dataTestId, onClick, className, id, showTime = false, labelPosit
21589
21598
  a__default.createElement(CustomLabel, { htmlFor: id, id: `${id}-label`, labelValue: showTime ? `Last Updated at ${time}` : "" })));
21590
21599
  };
21591
21600
 
21592
- var QuoteVariants;
21593
- (function (QuoteVariants) {
21594
- QuoteVariants["TOTAL_PRICE"] = "total-price";
21595
- QuoteVariants["TOTAL_WEIGHT"] = "total-weight";
21596
- })(QuoteVariants || (QuoteVariants = {}));
21597
- var QuoteCategory;
21598
- (function (QuoteCategory) {
21599
- QuoteCategory["ITEM"] = "/item";
21600
- QuoteCategory["HOUR"] = "/hr";
21601
- QuoteCategory["CWT"] = "CWT";
21602
- QuoteCategory["LBS"] = "lbs";
21603
- QuoteCategory["KG"] = "kg";
21604
- QuoteCategory["TON"] = "ton";
21605
- })(QuoteCategory || (QuoteCategory = {}));
21606
- var TableUnitsAndTotalsLeftCategory;
21607
- (function (TableUnitsAndTotalsLeftCategory) {
21608
- TableUnitsAndTotalsLeftCategory["US_CURRENCY"] = "$";
21609
- })(TableUnitsAndTotalsLeftCategory || (TableUnitsAndTotalsLeftCategory = {}));
21610
-
21611
21601
  const Container = styled.div `
21612
21602
  display: flex;
21613
21603
  justify-content: space-between;
@@ -21640,18 +21630,18 @@ const SubHeaderText = styled.span `
21640
21630
  line-height: normal;
21641
21631
  `;
21642
21632
 
21643
- const TableUnitsAndTotals = ({ id, className, value, subValue, variant, leftCategory = TableUnitsAndTotalsLeftCategory.US_CURRENCY, rightCategory, }) => {
21644
- const isWeight = variant === QuoteVariants.TOTAL_WEIGHT;
21645
- const leftCategoryValue = isWeight ? "" : leftCategory;
21646
- const header = `${leftCategoryValue ?? ""}${value} ${rightCategory && isWeight ? ` ${rightCategory}` : ""}`;
21647
- const subHeader = subValue
21648
- ? `${leftCategoryValue ?? ""}${subValue} ${rightCategory ? ` ${rightCategory}` : ""}`
21649
- : undefined;
21633
+ const TableUnitsAndTotals = ({ id, className, value, subValue, valueRightCategory, valueLeftCategory, subValueRightCategory, subValueLeftCategory }) => {
21634
+ let header = valueLeftCategory ?? "";
21635
+ header += value;
21636
+ header += valueRightCategory ? ` ${valueRightCategory}` : "";
21637
+ let subHeader = subValueLeftCategory ?? "";
21638
+ subHeader += subValue;
21639
+ subHeader += subValueRightCategory ? ` ${subValueRightCategory}` : "";
21650
21640
  return (a__default.createElement(Container, { id: id, className: className },
21651
21641
  a__default.createElement(Column, { "$align": "right" },
21652
21642
  a__default.createElement(HeaderText, null, header),
21653
- subHeader && a__default.createElement(SubHeaderText, null, subHeader))));
21643
+ subValue && a__default.createElement(SubHeaderText, null, subHeader))));
21654
21644
  };
21655
21645
 
21656
- export { HelperText, IconButton, Label, Loader, NumberInput, Pagination, PasswordInput, QuoteCategory, QuoteVariants, StellaButton, StellaButtonVariant, StellaIcon, Styles, Sync, Table, TableUnitsAndTotals, TableUnitsAndTotalsLeftCategory, TextInput, Tooltip };
21646
+ export { HelperText, IconButton, Label, Loader, NumberInput, Pagination, PasswordInput, StellaButton, StellaButtonVariant, StellaIcon, Styles, Sync, Table, TableUnitsAndTotals, TextInput, Tooltip };
21657
21647
  //# sourceMappingURL=index.esm.js.map