@stella-source/stellasource-dsl 4.0.0 → 5.1.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.
Files changed (30) hide show
  1. package/dist/cjs/index.js +103 -39
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/RadioButton/RadioButton.d.ts +4 -0
  4. package/dist/cjs/types/components/RadioButton/RadioButton.stories.d.ts +14 -0
  5. package/dist/cjs/types/components/RadioButton/styles.d.ts +38 -0
  6. package/dist/cjs/types/components/RadioButton/types.d.ts +13 -0
  7. package/dist/cjs/types/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
  8. package/dist/cjs/types/components/RadioButtonGroup/RadioButtonGroup.stories.d.ts +87 -0
  9. package/dist/cjs/types/components/RadioButtonGroup/styles.d.ts +8 -0
  10. package/dist/cjs/types/components/RadioButtonGroup/types.d.ts +22 -0
  11. package/dist/cjs/types/components/Table/Table.d.ts +1 -1
  12. package/dist/cjs/types/components/Table/Table.stories.d.ts +8 -0
  13. package/dist/cjs/types/components/Table/styles.d.ts +8 -1
  14. package/dist/cjs/types/components/Table/types.d.ts +4 -5
  15. package/dist/esm/index.esm.js +103 -39
  16. package/dist/esm/index.esm.js.map +1 -1
  17. package/dist/esm/types/components/RadioButton/RadioButton.d.ts +4 -0
  18. package/dist/esm/types/components/RadioButton/RadioButton.stories.d.ts +14 -0
  19. package/dist/esm/types/components/RadioButton/styles.d.ts +38 -0
  20. package/dist/esm/types/components/RadioButton/types.d.ts +13 -0
  21. package/dist/esm/types/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
  22. package/dist/esm/types/components/RadioButtonGroup/RadioButtonGroup.stories.d.ts +87 -0
  23. package/dist/esm/types/components/RadioButtonGroup/styles.d.ts +8 -0
  24. package/dist/esm/types/components/RadioButtonGroup/types.d.ts +22 -0
  25. package/dist/esm/types/components/Table/Table.d.ts +1 -1
  26. package/dist/esm/types/components/Table/Table.stories.d.ts +8 -0
  27. package/dist/esm/types/components/Table/styles.d.ts +8 -1
  28. package/dist/esm/types/components/Table/types.d.ts +4 -5
  29. package/dist/index.d.ts +5 -6
  30. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -22378,6 +22378,37 @@ const ClearFilterButtonRow = styled.div `
22378
22378
  align-items: "center";
22379
22379
  text-align: "center";
22380
22380
  `;
22381
+ const ExpandedContentRow = styled.tr `
22382
+ background-color: ${Styles.color.grey.pale};
22383
+ `;
22384
+ const ExpandedContentCell = styled.td `
22385
+ padding: 12px 16px;
22386
+ border-bottom: 1px solid ${Styles.color.grey.light};
22387
+ background-color: ${Styles.color.grey.pale};
22388
+ `;
22389
+ const ExpandChevronButton = styled.button `
22390
+ display: flex;
22391
+ align-items: center;
22392
+ justify-content: center;
22393
+ background: none;
22394
+ border: none;
22395
+ cursor: pointer;
22396
+ padding: 4px;
22397
+ border-radius: 4px;
22398
+ transition:
22399
+ transform 0.2s ease,
22400
+ background-color 0.15s ease;
22401
+
22402
+ & > svg {
22403
+ transition: transform 0.2s ease;
22404
+ transform: ${({ $expanded }) => $expanded ? "rotate(90deg)" : "rotate(0deg)"};
22405
+ fill: ${Styles.color.grey.charcoal};
22406
+ }
22407
+
22408
+ &:hover {
22409
+ background-color: ${Styles.color.grey.light};
22410
+ }
22411
+ `;
22381
22412
  const ActionBar = styled.div `
22382
22413
  display: flex;
22383
22414
  justify-content: space-between;
@@ -22618,7 +22649,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
22618
22649
  startingPage: 1,
22619
22650
  rowsPerPage: 10,
22620
22651
  totalRows: data.length,
22621
- }, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, defaultFilters, staticFilters, enableShowHide, globalActions, }) {
22652
+ }, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, defaultFilters, staticFilters, enableShowHide, globalActions, showExpandedRowToggle = false, renderExpandedRow, }) {
22622
22653
  const [rowSelection, setRowSelection] = a$n.useState({});
22623
22654
  const [selectedRows] = a$n.useState({});
22624
22655
  const [pageIndex, setPageIndex] = a$n.useState(paginationDetails?.startingPage);
@@ -22678,6 +22709,14 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
22678
22709
  });
22679
22710
  const [rowStatusesState, setRowStatusesState] = a$n.useState(rowStatuses || {});
22680
22711
  const [filterMenuOpen, setFilterMenuOpen] = a$n.useState({});
22712
+ const [expandedRows, setExpandedRows] = a$n.useState(new Set());
22713
+ const toggleRowExpanded = (rowId) => {
22714
+ setExpandedRows((prev) => {
22715
+ const next = new Set(prev);
22716
+ next.has(rowId) ? next.delete(rowId) : next.add(rowId);
22717
+ return next;
22718
+ });
22719
+ };
22681
22720
  a$n.useEffect(() => {
22682
22721
  setRowStatusesState(rowStatuses || {});
22683
22722
  }, [rowStatuses]);
@@ -22751,6 +22790,18 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
22751
22790
  };
22752
22791
  const enhancedColumns = a$n.useMemo(() => {
22753
22792
  const cols = [];
22793
+ if (showExpandedRowToggle) {
22794
+ cols.push({
22795
+ id: "expand",
22796
+ header: "",
22797
+ cell: ({ row }) => !!renderExpandedRow?.(row) ? (a$n.createElement(ExpandChevronButton, { "$expanded": expandedRows.has(row.id), onClick: (e) => {
22798
+ e.stopPropagation();
22799
+ toggleRowExpanded(row.id);
22800
+ }, "aria-label": expandedRows.has(row.id) ? "Collapse row" : "Expand row" },
22801
+ a$n.createElement(StellaIcon, { iconName: "chevron-right", size: 14 }))) : (a$n.createElement(a$n.Fragment, null)),
22802
+ size: 36,
22803
+ });
22804
+ }
22754
22805
  if (showSelection) {
22755
22806
  cols.push({
22756
22807
  id: "select",
@@ -22782,6 +22833,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
22782
22833
  onRowSelect,
22783
22834
  showSelection,
22784
22835
  showRowOptions,
22836
+ expandedRows,
22785
22837
  ]);
22786
22838
  const table = useReactTable({
22787
22839
  data: localData,
@@ -22887,7 +22939,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
22887
22939
  };
22888
22940
  return (a$n.createElement(a$n.Fragment, null,
22889
22941
  !isLoading && (a$n.createElement(ActionBar, null,
22890
- a$n.createElement(GlobalActionWrapper, null, globalActions?.map((action) => action.element)),
22942
+ a$n.createElement(GlobalActionWrapper, null, globalActions?.(table)),
22891
22943
  a$n.createElement(GlobalActionWrapper, null, enableShowHide && (a$n.createElement(a$n.Fragment, null,
22892
22944
  a$n.createElement(IconButton, { ref: visibilityButtonRef, ariaLabel: "Column show hide button", variant: "tertiary", iconName: "table", onClick: () => {
22893
22945
  const rect = visibilityButtonRef.current?.getBoundingClientRect();
@@ -22965,44 +23017,56 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
22965
23017
  }))))),
22966
23018
  a$n.createElement("tbody", null,
22967
23019
  table.getRowModel().rows.length === 0 && (a$n.createElement(EmptyTableState, { header: emptyTableState?.header || "No data available.", subHeader: emptyTableState?.subHeader, showClearFilterButton: emptyTableState?.showClearFilterButton, onClearFilters: resetTable, colSpan: table.getVisibleLeafColumns().length, size: "large" })),
22968
- table.getRowModel().rows.map((row) => (a$n.createElement(CellRow, { key: row.id, onClick: () => onRowClick?.(row.original), "$isClickable": !!onRowClick }, row.getVisibleCells().map((cell) => {
22969
- const value = flexRender(cell.column.columnDef.cell, {
22970
- ...cell.getContext(),
22971
- localValue: rowState[row.id]?.[cell.column.id],
22972
- onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
22973
- });
22974
- const meta = cell.column.columnDef
22975
- .meta;
22976
- return (a$n.createElement(BodyCell, { key: cell.id, style: {
22977
- width: cell.column.getSize(),
22978
- textAlign: meta?.cellAlign ||
22979
- (typeof cell.getValue() === "number" ||
22980
- meta?.dataType === "number"
22981
- ? "right"
22982
- : "left"),
22983
- boxShadow: scrollState.atLeft &&
22984
- cell.column.getIsPinned() === "left"
22985
- ? "none"
22986
- : scrollState.atRight &&
22987
- cell.column.getIsPinned() === "right"
23020
+ table.getRowModel().rows.map((row) => (a$n.createElement(a$n.Fragment, { key: row.id },
23021
+ a$n.createElement(CellRow, { onClick: () => {
23022
+ if (!showExpandedRowToggle &&
23023
+ !!renderExpandedRow?.(row))
23024
+ toggleRowExpanded(row.id);
23025
+ onRowClick?.(row.original);
23026
+ }, "$isClickable": !!onRowClick }, row.getVisibleCells().map((cell) => {
23027
+ const value = flexRender(cell.column.columnDef.cell, {
23028
+ ...cell.getContext(),
23029
+ localValue: rowState[row.id]?.[cell.column.id],
23030
+ onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
23031
+ });
23032
+ const meta = cell.column.columnDef
23033
+ .meta;
23034
+ return (a$n.createElement(BodyCell, { key: cell.id, style: {
23035
+ width: cell.column.getSize(),
23036
+ textAlign: meta?.cellAlign ||
23037
+ (typeof cell.getValue() === "number" ||
23038
+ meta?.dataType === "number"
23039
+ ? "right"
23040
+ : "left"),
23041
+ boxShadow: scrollState.atLeft &&
23042
+ cell.column.getIsPinned() === "left"
22988
23043
  ? "none"
22989
- : undefined,
22990
- backgroundColor: table
22991
- .getSelectedRowModel()
22992
- .rows.find((r) => r.id === row.id)
22993
- ? "#EBF0FA"
22994
- : rowStatusesState?.[row.id] === "action-pending"
22995
- ? "#FFFDEB"
22996
- : rowStatusesState?.[row.id] === "completed"
22997
- ? "#F5F5F5"
22998
- : "",
22999
- }, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": serverSide
23000
- ? row.index ===
23001
- table.getRowModel().rows.length - 1
23002
- : row.index -
23003
- pagination.pageSize * pagination.pageIndex ===
23004
- table.getRowModel().rows.length - 1 }, value));
23005
- })))))))),
23044
+ : scrollState.atRight &&
23045
+ cell.column.getIsPinned() === "right"
23046
+ ? "none"
23047
+ : undefined,
23048
+ backgroundColor: table
23049
+ .getSelectedRowModel()
23050
+ .rows.find((r) => r.id === row.id)
23051
+ ? "#EBF0FA"
23052
+ : rowStatusesState?.[row.id] ===
23053
+ "action-pending"
23054
+ ? "#FFFDEB"
23055
+ : rowStatusesState?.[row.id] === "completed"
23056
+ ? "#F5F5F5"
23057
+ : "",
23058
+ }, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": serverSide
23059
+ ? row.index ===
23060
+ table.getRowModel().rows.length - 1
23061
+ : row.index -
23062
+ pagination.pageSize *
23063
+ pagination.pageIndex ===
23064
+ table.getRowModel().rows.length - 1 }, value));
23065
+ })),
23066
+ expandedRows.has(row.id) &&
23067
+ renderExpandedRow &&
23068
+ !!renderExpandedRow(row) && (a$n.createElement(ExpandedContentRow, null,
23069
+ a$n.createElement(ExpandedContentCell, { colSpan: table.getVisibleLeafColumns().length }, renderExpandedRow(row))))))))))),
23006
23070
  showPagination && paginationDetails?.totalRows > 0 && (a$n.createElement(CustomPagination, { "$hasData": table.getRowModel().rows.length > 0, totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
23007
23071
  table.toggleAllRowsSelected(false);
23008
23072
  setPageIndex(page);