@stella-source/stellasource-dsl 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -16799,7 +16799,6 @@ const variantSelector = (variant) => {
16799
16799
  }
16800
16800
 
16801
16801
  &:disabled {
16802
- background-color: var(--DSL-button-st-background-disabled);
16803
16802
  border: 1px solid var(--DSL-button-disabled);
16804
16803
  color: var(--DSL-button-disabled);
16805
16804
  & svg {
@@ -16833,7 +16832,6 @@ const variantSelector = (variant) => {
16833
16832
  }
16834
16833
 
16835
16834
  &:disabled {
16836
- background-color: var(--DSL-button-st-background-disabled);
16837
16835
  color: var(--DSL-button-disabled);
16838
16836
  & svg {
16839
16837
  fill: var(--DSL-button-disabled);
@@ -16873,6 +16871,7 @@ const ButtonComponent = styled.button.attrs({
16873
16871
  }
16874
16872
 
16875
16873
  /* Button CSS Variables */
16874
+ /* p = primary, st = secondary, tertiary */
16876
16875
  --DSL-button-branding: ${Styles.color.core.primary};
16877
16876
  --DSL-button-hover: ${Styles.color.blue.darkNavy};
16878
16877
  --DSL-button-active: ${Styles.color.blue.darkNavy};
@@ -17037,7 +17036,7 @@ const IconContainer = styled.div `
17037
17036
  `;
17038
17037
 
17039
17038
  const TextFieldContainer = ({ id, label, children, tooltipText, endIcon, className, rightCategory, leftCategory, helperText, dataTestId, helperTextAffectLayout = true, disabled = false, hideLabel = false, isLoading = false, hasError = false, isRequired = false, }) => {
17040
- return (a$j.createElement(Wrapper, { "data-testId": dataTestId, className: className },
17039
+ return (a$j.createElement(Wrapper, { "data-testid": dataTestId, className: className },
17041
17040
  a$j.createElement(Label, { tooltipText: tooltipText, required: isRequired, labelValue: label, hideLabel: hideLabel, id: `${id}-label`, htmlFor: `${id}-text-field` }),
17042
17041
  a$j.createElement(TextFieldWrapper, { id: id, "$hasError": hasError, "$isDisabled": disabled, "$isLoading": isLoading, "data-testid": "text-input-wrapper" },
17043
17042
  leftCategory && a$j.createElement(Category, null, leftCategory),
@@ -17127,19 +17126,6 @@ const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
17127
17126
  })}${decimalEnding ? "." : ""}${decimalZero ? "0" : ""}`
17128
17127
  : "";
17129
17128
  };
17130
- const formatNumberWithDecimals = (num, decimalPlaces = 2, isCurrency = false) => {
17131
- if (num === null || num === undefined || num === "")
17132
- return "";
17133
- const parsed = Number(num);
17134
- if (isNaN(parsed))
17135
- return "";
17136
- return parsed.toLocaleString("en-US", {
17137
- style: isCurrency ? "currency" : "decimal",
17138
- currency: isCurrency ? "USD" : undefined,
17139
- minimumFractionDigits: decimalPlaces,
17140
- maximumFractionDigits: decimalPlaces,
17141
- });
17142
- };
17143
17129
 
17144
17130
  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, }) => {
17145
17131
  const containerProps = {
@@ -20643,8 +20629,8 @@ const SelectCaret = styled(StellaIcon) `
20643
20629
  position: absolute;
20644
20630
  right: 0;
20645
20631
  pointer-events: none;
20646
- color: ${Styles.color.blue.primary};
20647
- fill: ${Styles.color.blue.primary};
20632
+ color: ${Styles.color.core.primary};
20633
+ fill: ${Styles.color.core.primary};
20648
20634
  transform: rotate(180deg);
20649
20635
  `;
20650
20636
  const RowInfo = styled.div `
@@ -20762,11 +20748,11 @@ const HeaderCell = styled.th `
20762
20748
  : "unset"};
20763
20749
  z-index: ${({ $isPinnedLeft, $isPinnedRight }) => $isPinnedLeft || $isPinnedRight ? 2 : 1};
20764
20750
  text-align: inherit;
20765
- padding: 8px 12px;
20751
+ padding: 0px 12px;
20766
20752
  font-weight: 400;
20767
20753
  font-size: 14px;
20768
20754
  color: ${Styles.color.grey.charcoal};
20769
- border-bottom: 1px solid ${Styles.color.grey.medium};
20755
+ border-bottom: 1px solid ${Styles.color.grey.light};
20770
20756
  background-color: ${Styles.color.grey.pale};
20771
20757
  transition: box-shadow 0.3s ease-out;
20772
20758
  & button {
@@ -20793,6 +20779,7 @@ const HeaderCellPosition = styled.div `
20793
20779
  `;
20794
20780
  const TableWrapper = styled.div `
20795
20781
  width: 100%;
20782
+ position: relative;
20796
20783
  overflow-x: hidden;
20797
20784
  border: 1px solid ${Styles.color.grey.light};
20798
20785
  border-radius: 5px;
@@ -20801,7 +20788,7 @@ const TableWrapper = styled.div `
20801
20788
  `;
20802
20789
  const TableWrapperScroll = styled.div `
20803
20790
  width: 100%;
20804
- overflow-x: ${({ $filterMenuOpen }) => ($filterMenuOpen ? "hidden" : "auto")};
20791
+ overflow-x: ${({ $stopScroll }) => ($stopScroll ? "hidden" : "auto")};
20805
20792
  `;
20806
20793
  const StyledTable = styled.table `
20807
20794
  width: 100%;
@@ -20840,6 +20827,11 @@ const HeaderRow = styled.tr `
20840
20827
  const CellRow = styled.tr `
20841
20828
  min-height: 50px;
20842
20829
  height: 50px;
20830
+ &:hover {
20831
+ & > td {
20832
+ background-color: ${Styles.color.blue.pale};
20833
+ }
20834
+ }
20843
20835
  `;
20844
20836
  const FilterMenu = styled.div `
20845
20837
  position: absolute;
@@ -20880,10 +20872,10 @@ const BodyCell = styled.td `
20880
20872
  : "unset"};
20881
20873
  z-index: ${({ $isPinnedLeft, $isPinnedRight }) => $isPinnedLeft || $isPinnedRight ? 1 : 0};
20882
20874
  background: white;
20883
- padding: 8px 12px;
20875
+ padding: 0px 12px;
20884
20876
  font-size: 12px;
20885
20877
  color: ${Styles.color.grey.charcoal};
20886
- border-bottom: ${({ $isLastRow }) => $isLastRow ? "none" : `1px solid ${Styles.color.grey.medium}`};
20878
+ border-bottom: ${({ $isLastRow }) => $isLastRow ? "none" : `1px solid ${Styles.color.grey.light}`};
20887
20879
  transition: box-shadow 0.3s ease-out;
20888
20880
  `;
20889
20881
  const MenuButton = styled.button `
@@ -21031,12 +21023,57 @@ const LoadingShimmer = styled.div `
21031
21023
  }
21032
21024
  `;
21033
21025
  const CustomPagination = styled(Pagination) `
21034
- border-top: 1px solid ${Styles.color.grey.medium};
21026
+ border-top: 1px solid ${Styles.color.grey.light};
21035
21027
  `;
21036
21028
  const KebabAlign = styled.div `
21037
21029
  display: flex;
21038
21030
  justify-content: end;
21039
21031
  `;
21032
+ // EmptyTableState
21033
+ const EmptyTableCell = styled.td `
21034
+ padding: 10rem;
21035
+ background-color: white;
21036
+ `;
21037
+ const EmptyTableSection = styled.section `
21038
+ width: ${({ $size }) => ($size === "small" ? "360px" : "450px")};
21039
+ display: flex;
21040
+ flex-direction: column;
21041
+ justify-content: center;
21042
+ align-items: center;
21043
+ position: absolute;
21044
+ gap: 20px;
21045
+ top: 50px;
21046
+ left: 0;
21047
+ right: 0;
21048
+ margin: 80px auto 0;
21049
+ `;
21050
+ const EmptyTableHeader = styled.p `
21051
+ display: flex;
21052
+ justify-content: center;
21053
+ align-items: center;
21054
+ color: ${Styles.color.grey.smoke};
21055
+ font-size: 22px;
21056
+ font-weight: 400;
21057
+ text-align: center;
21058
+ line-height: 22px;
21059
+ margin-bottom: 0px;
21060
+ `;
21061
+ const EmptyTableSubHeader = styled.p `
21062
+ display: flex;
21063
+ justify-content: center;
21064
+ align-items: center;
21065
+ color: ${Styles.color.grey.shadow};
21066
+ font-size: 18px;
21067
+ text-align: center;
21068
+ font-weight: 400;
21069
+ margin-top: 0px;
21070
+ `;
21071
+ const ClearFilterButtonRow = styled.div `
21072
+ display: "flex";
21073
+ justify-content: "center";
21074
+ align-items: "center";
21075
+ text-align: "center";
21076
+ `;
21040
21077
 
21041
21078
  const IndeterminateCheckbox = ({ isIndeterminate, isChecked, onChange, }) => {
21042
21079
  const ref = a$j.useRef(null);
@@ -21115,7 +21152,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21115
21152
  a$j.createElement(HeaderCellPosition, { style: {
21116
21153
  justifyContent: textAlign === "left" ? "start" : "end",
21117
21154
  } },
21118
- textAlign === "left" && (a$j.createElement("span", null, flexRender(columnDef.header, header.getContext()))),
21155
+ textAlign === "left" && (a$j.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))),
21119
21156
  header.column.getCanFilter() && (a$j.createElement("div", { style: {
21120
21157
  display: "flex",
21121
21158
  alignItems: "center",
@@ -21177,7 +21214,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21177
21214
  setCurrentAppliedFilters([]);
21178
21215
  } }, "Clear Filter"))), document.body))),
21179
21216
  header.column.getCanSort() && (a$j.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) })),
21180
- textAlign === "right" && (a$j.createElement("span", null, flexRender(columnDef.header, header.getContext()))))));
21217
+ textAlign === "right" && (a$j.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))))));
21181
21218
  };
21182
21219
 
21183
21220
  const RowOptions = ({ row, selectionMenuItems }) => {
@@ -21222,12 +21259,21 @@ const RowOptions = ({ row, selectionMenuItems }) => {
21222
21259
  })), document.body)));
21223
21260
  };
21224
21261
 
21262
+ const EmptyTableState = ({ id, className, header, subHeader, showClearFilterButton, colSpan, size = "large", onClearFilters, }) => {
21263
+ return (a$j.createElement("tr", null,
21264
+ a$j.createElement(EmptyTableCell, { colSpan: colSpan },
21265
+ a$j.createElement(EmptyTableSection, { "$size": size, id: id, className: className },
21266
+ a$j.createElement(EmptyTableHeader, null, header),
21267
+ a$j.createElement(EmptyTableSubHeader, null, subHeader),
21268
+ a$j.createElement(ClearFilterButtonRow, null, showClearFilterButton && (a$j.createElement(StellaButton, { label: "Clear Filters", onClick: () => onClearFilters?.(), variant: "secondary" })))))));
21269
+ };
21270
+
21225
21271
  // DataTable.tsx
21226
21272
  function Table({ columns, data, isLoading, serverSide = false, onPageChange, onSortChange, onFilterChange, onRowSelect, rowStatuses, showSelection = false, showRowOptions = false, showPagination = true, variant, paginationDetails = {
21227
21273
  startingPage: 1,
21228
21274
  rowsPerPage: 10,
21229
21275
  totalRows: data.length,
21230
- }, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, }) {
21276
+ }, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, }) {
21231
21277
  const [rowSelection, setRowSelection] = a$j.useState({});
21232
21278
  const [selectedRows] = a$j.useState({});
21233
21279
  const [pageIndex, setPageIndex] = a$j.useState(paginationDetails?.startingPage);
@@ -21253,7 +21299,11 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21253
21299
  }, [rowStatuses]);
21254
21300
  a$j.useEffect(() => {
21255
21301
  setTotalData(paginationDetails?.totalRows);
21256
- }, [paginationDetails.totalRows, data]);
21302
+ setPagination({
21303
+ pageIndex: paginationDetails?.startingPage - 1,
21304
+ pageSize: paginationDetails?.rowsPerPage || 10,
21305
+ });
21306
+ }, [paginationDetails, data]);
21257
21307
  a$j.useEffect(() => {
21258
21308
  const el = scrollRef?.current;
21259
21309
  if (!el)
@@ -21374,7 +21424,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21374
21424
  });
21375
21425
  };
21376
21426
  return (a$j.createElement(TableWrapper, { className: className, id: id, "data-testid": dataTestId, "data-auto": dataAuto },
21377
- a$j.createElement(TableWrapperScroll, { "$filterMenuOpen": Object.values(filterMenuOpen).some((value) => value), ref: scrollRef }, isLoading ? (a$j.createElement("div", null,
21427
+ a$j.createElement(TableWrapperScroll, { "$stopScroll": Object.values(filterMenuOpen).some((value) => value), ref: scrollRef }, isLoading ? (a$j.createElement("div", null,
21378
21428
  a$j.createElement("div", { style: {
21379
21429
  width: "100%",
21380
21430
  maxWidth: "100%",
@@ -21409,39 +21459,45 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21409
21459
  }));
21410
21460
  } }));
21411
21461
  }))))),
21412
- a$j.createElement("tbody", null, table.getRowModel().rows.map((row) => (a$j.createElement(CellRow, { key: row.id }, row.getVisibleCells().map((cell) => {
21413
- const value = flexRender(cell.column.columnDef.cell, {
21414
- ...cell.getContext(),
21415
- localValue: rowState[row.id]?.[cell.column.id],
21416
- onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
21417
- });
21418
- const meta = cell.column.columnDef.meta;
21419
- return (a$j.createElement(BodyCell, { key: cell.id, style: {
21420
- width: cell.column.getSize(),
21421
- textAlign: meta?.cellAlign ||
21422
- (typeof cell.getValue() === "number" ||
21423
- meta?.dataType === "number"
21424
- ? "right"
21425
- : "left"),
21426
- boxShadow: scrollState.atLeft &&
21427
- cell.column.getIsPinned() === "left"
21428
- ? "none"
21429
- : scrollState.atRight &&
21430
- cell.column.getIsPinned() === "right"
21462
+ a$j.createElement("tbody", null,
21463
+ table.getRowModel().rows.length === 0 && (a$j.createElement(EmptyTableState, { header: emptyTableState.header, subHeader: emptyTableState.subHeader, showClearFilterButton: emptyTableState.showClearFilterButton, onClearFilters: resetTable, colSpan: table.getVisibleLeafColumns().length, size: "large" })),
21464
+ table.getRowModel().rows.map((row) => (a$j.createElement(CellRow, { key: row.id }, row.getVisibleCells().map((cell) => {
21465
+ const value = flexRender(cell.column.columnDef.cell, {
21466
+ ...cell.getContext(),
21467
+ localValue: rowState[row.id]?.[cell.column.id],
21468
+ onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
21469
+ });
21470
+ const meta = cell.column.columnDef.meta;
21471
+ return (a$j.createElement(BodyCell, { key: cell.id, style: {
21472
+ width: cell.column.getSize(),
21473
+ textAlign: meta?.cellAlign ||
21474
+ (typeof cell.getValue() === "number" ||
21475
+ meta?.dataType === "number"
21476
+ ? "right"
21477
+ : "left"),
21478
+ boxShadow: scrollState.atLeft &&
21479
+ cell.column.getIsPinned() === "left"
21431
21480
  ? "none"
21432
- : undefined,
21433
- backgroundColor: table
21434
- .getSelectedRowModel()
21435
- .rows.find((r) => r.id === row.id)
21436
- ? "#EBF0FA"
21437
- : rowStatusesState?.[row.id] === "action-pending"
21438
- ? "#FFFDEB"
21439
- : rowStatusesState?.[row.id] === "completed"
21440
- ? "#F5F5F5"
21441
- : "white",
21442
- }, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": row.index === table.getRowModel().rows.length - 1 }, value));
21443
- })))))))),
21444
- showPagination && paginationDetails?.totalRows && (a$j.createElement(CustomPagination, { totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
21481
+ : scrollState.atRight &&
21482
+ cell.column.getIsPinned() === "right"
21483
+ ? "none"
21484
+ : undefined,
21485
+ backgroundColor: table
21486
+ .getSelectedRowModel()
21487
+ .rows.find((r) => r.id === row.id)
21488
+ ? "#EBF0FA"
21489
+ : rowStatusesState?.[row.id] === "action-pending"
21490
+ ? "#FFFDEB"
21491
+ : rowStatusesState?.[row.id] === "completed"
21492
+ ? "#F5F5F5"
21493
+ : "",
21494
+ }, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": serverSide
21495
+ ? row.index === table.getRowModel().rows.length - 1
21496
+ : row.index -
21497
+ pagination.pageSize * pagination.pageIndex ===
21498
+ table.getRowModel().rows.length - 1 }, value));
21499
+ })))))))),
21500
+ showPagination && paginationDetails?.totalRows > 0 && (a$j.createElement(CustomPagination, { totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
21445
21501
  setPageIndex(page);
21446
21502
  setPagination((prev) => ({
21447
21503
  ...prev,
@@ -21512,12 +21568,12 @@ const Sync = ({ dataTestId, onClick, className, id, showTime = false, labelPosit
21512
21568
  a$j.createElement(CustomLabel, { htmlFor: id, id: `${id}-label`, labelValue: showTime ? `Last Updated at ${time}` : "" })));
21513
21569
  };
21514
21570
 
21515
- var QuoteVariants;
21571
+ exports.QuoteVariants = void 0;
21516
21572
  (function (QuoteVariants) {
21517
21573
  QuoteVariants["TOTAL_PRICE"] = "total-price";
21518
21574
  QuoteVariants["TOTAL_WEIGHT"] = "total-weight";
21519
- })(QuoteVariants || (QuoteVariants = {}));
21520
- var QuoteCategory;
21575
+ })(exports.QuoteVariants || (exports.QuoteVariants = {}));
21576
+ exports.QuoteCategory = void 0;
21521
21577
  (function (QuoteCategory) {
21522
21578
  QuoteCategory["ITEM"] = "/item";
21523
21579
  QuoteCategory["HOUR"] = "/hr";
@@ -21525,11 +21581,11 @@ var QuoteCategory;
21525
21581
  QuoteCategory["LBS"] = "lbs";
21526
21582
  QuoteCategory["KG"] = "kg";
21527
21583
  QuoteCategory["TON"] = "ton";
21528
- })(QuoteCategory || (QuoteCategory = {}));
21529
- var TableUnitsAndTotalsLeftCategory;
21584
+ })(exports.QuoteCategory || (exports.QuoteCategory = {}));
21585
+ exports.TableUnitsAndTotalsLeftCategory = void 0;
21530
21586
  (function (TableUnitsAndTotalsLeftCategory) {
21531
21587
  TableUnitsAndTotalsLeftCategory["US_CURRENCY"] = "$";
21532
- })(TableUnitsAndTotalsLeftCategory || (TableUnitsAndTotalsLeftCategory = {}));
21588
+ })(exports.TableUnitsAndTotalsLeftCategory || (exports.TableUnitsAndTotalsLeftCategory = {}));
21533
21589
 
21534
21590
  const Container = styled.div `
21535
21591
  display: flex;
@@ -21563,16 +21619,12 @@ const SubHeaderText = styled.span `
21563
21619
  line-height: normal;
21564
21620
  `;
21565
21621
 
21566
- const TableUnitsAndTotals = ({ id, className, value, subValue, variant, leftCategory = TableUnitsAndTotalsLeftCategory.US_CURRENCY, rightCategory, }) => {
21567
- const isWeight = variant === QuoteVariants.TOTAL_WEIGHT;
21622
+ const TableUnitsAndTotals = ({ id, className, value, subValue, variant, leftCategory = exports.TableUnitsAndTotalsLeftCategory.US_CURRENCY, rightCategory, }) => {
21623
+ const isWeight = variant === exports.QuoteVariants.TOTAL_WEIGHT;
21568
21624
  const leftCategoryValue = isWeight ? "" : leftCategory;
21569
- const header = (leftCategoryValue ?? "") +
21570
- formatNumberWithDecimals(value, 2, false) +
21571
- (rightCategory && isWeight ? ` ${rightCategory}` : "");
21572
- const subHeader = subValue !== undefined
21573
- ? (leftCategoryValue ?? "") +
21574
- formatNumberWithDecimals(subValue, 3, false) +
21575
- (rightCategory ? ` ${rightCategory}` : "")
21625
+ const header = `${leftCategoryValue ?? ""}${value} ${rightCategory && isWeight ? ` ${rightCategory}` : ""}`;
21626
+ const subHeader = subValue
21627
+ ? `${leftCategoryValue ?? ""}${subValue} ${rightCategory ? ` ${rightCategory}` : ""}`
21576
21628
  : undefined;
21577
21629
  return (a$j.createElement(Container, { id: id, className: className },
21578
21630
  a$j.createElement(Column, { "$align": "right" },