sevago-library 1.3.17 → 1.3.18

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/index.esm.js CHANGED
@@ -74669,23 +74669,11 @@ const buttonRootSx = {
74669
74669
  minWidth: 100,
74670
74670
  textTransform: "none",
74671
74671
  borderRadius: BORDER_RADIUS_ELEMENT_SMALL,
74672
- width: "fit-content",
74673
- [TABLET_MEDIA]: {
74674
- minWidth: 120,
74675
- minHeight: 44,
74676
- px: 2.5,
74677
- py: 1,
74678
- "& .MuiButton-startIcon .material-symbols-rounded, & .MuiButton-endIcon .material-symbols-rounded": {
74679
- fontSize: 22
74680
- }
74681
- }
74672
+ width: "fit-content"
74682
74673
  };
74683
74674
  const buttonContentSx = {
74684
74675
  ...TYPOGRAPHY.textSm.regular,
74685
- whiteSpace: "nowrap",
74686
- [TABLET_MEDIA]: {
74687
- ...TYPOGRAPHY.textMd.medium
74688
- }
74676
+ whiteSpace: "nowrap"
74689
74677
  };
74690
74678
  const ButtonElement = ({
74691
74679
  content,
@@ -76257,21 +76245,31 @@ const DISABLED_DEFAULT = Object.keys(TableActions).reduce(
76257
76245
  },
76258
76246
  {}
76259
76247
  );
76248
+ const getSxArray = (sx) => {
76249
+ if (!sx) return [];
76250
+ return Array.isArray(sx) ? [...sx] : [sx];
76251
+ };
76252
+ const mergeSxProps = (...sxList) => {
76253
+ return sxList.flatMap((sx) => getSxArray(sx));
76254
+ };
76260
76255
  const getStyleCell = (column, palette, disableRow) => {
76261
- return {
76262
- width: `${column.width}px !important`,
76263
- minWidth: `${column.width}px !important`,
76264
- maxWidth: `${column.width}px !important`,
76265
- padding: PADDING_GAP_ITEM,
76266
- borderRadius: "0 !important",
76267
- color: disableRow ? palette.divider : "none",
76268
- ...column.stickyCss ? {
76269
- position: "sticky",
76270
- backgroundColor: palette.background.default,
76271
- ...column.stickyCss
76272
- } : {},
76273
- ...column.sx ? column.sx : {}
76274
- };
76256
+ return mergeSxProps(
76257
+ {
76258
+ width: `${column.width}px !important`,
76259
+ minWidth: `${column.width}px !important`,
76260
+ maxWidth: `${column.width}px !important`,
76261
+ padding: PADDING_GAP_ITEM,
76262
+ borderRadius: "0 !important",
76263
+ color: disableRow ? palette.divider : "none",
76264
+ ...column.stickyCss ? {
76265
+ position: "sticky",
76266
+ backgroundColor: palette.background.default,
76267
+ ...column.stickyCss
76268
+ } : {}
76269
+ },
76270
+ column.sx,
76271
+ column.cellSx
76272
+ );
76275
76273
  };
76276
76274
  const getStyleRow = (hasOnClick, palette, index, rowSx, indexLoadingRow) => {
76277
76275
  return {
@@ -76365,10 +76363,10 @@ function TableRowPart({
76365
76363
  TableCell,
76366
76364
  {
76367
76365
  align: column.align,
76368
- sx: {
76369
- ...getStyleCell(column, palette, disabled.DISABLED_ROW),
76370
- ...isFirstDataCol ? { pl: (theme) => `calc(${theme.spacing(1)} + ${level * 16}px)` } : {}
76371
- },
76366
+ sx: mergeSxProps(
76367
+ getStyleCell(column, palette, disabled.DISABLED_ROW),
76368
+ isFirstDataCol ? { pl: (theme) => `calc(${theme.spacing(1)} + ${level * 16}px)` } : void 0
76369
+ ),
76372
76370
  onClick: column.id === "actions" || column.id === "selectCheckbox" ? (e) => {
76373
76371
  e.stopPropagation();
76374
76372
  } : void 0,
@@ -76493,45 +76491,104 @@ const TreeToggleCell = ({
76493
76491
  const TableContainerPart = ({ children }) => {
76494
76492
  return /* @__PURE__ */ jsx(Box, { sx: { overflowY: "auto", flex: 1 }, children: /* @__PURE__ */ jsx(TableContainer, { sx: { maxHeight: "100%", overflow: "auto" }, children }) });
76495
76493
  };
76496
- const TableHeadPart = ({ columns }) => {
76494
+ const GROUPED_HEADER_ROW_HEIGHT = 44;
76495
+ const toHeaderCell = (column, rowSpan) => ({
76496
+ id: column.id,
76497
+ label: column.label,
76498
+ width: column.width,
76499
+ align: column.align,
76500
+ alignHead: column.alignHead,
76501
+ sx: mergeSxProps(column.sx, column.headSx),
76502
+ stickyCss: column.stickyCss,
76503
+ rowSpan
76504
+ });
76505
+ function TableHeadPart({ columns, headerGroups }) {
76497
76506
  const { palette } = useTheme$4();
76498
- return /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: columns.map((column) => {
76507
+ const headerRows = useMemo(() => {
76508
+ var _a;
76509
+ if (!(headerGroups == null ? void 0 : headerGroups.length)) return [columns.map((column) => toHeaderCell(column))];
76510
+ const groupByColumnId = /* @__PURE__ */ new Map();
76511
+ headerGroups.forEach((group) => {
76512
+ group.columnIds.forEach((columnId) => {
76513
+ groupByColumnId.set(columnId, group);
76514
+ });
76515
+ });
76516
+ const topCells = [];
76517
+ const bottomCells = [];
76518
+ let columnIndex = 0;
76519
+ while (columnIndex < columns.length) {
76520
+ const column = columns[columnIndex];
76521
+ const group = groupByColumnId.get(column.id);
76522
+ if (!group) {
76523
+ topCells.push(toHeaderCell(column, 2));
76524
+ columnIndex += 1;
76525
+ continue;
76526
+ }
76527
+ let colSpan = 1;
76528
+ while (columnIndex + colSpan < columns.length && ((_a = groupByColumnId.get(columns[columnIndex + colSpan].id)) == null ? void 0 : _a.id) === group.id) {
76529
+ colSpan += 1;
76530
+ }
76531
+ topCells.push({
76532
+ id: `${group.id}-${columnIndex}`,
76533
+ label: group.label,
76534
+ alignHead: group.align ?? "center",
76535
+ sx: group.sx,
76536
+ colSpan
76537
+ });
76538
+ for (let subColumnIndex = 0; subColumnIndex < colSpan; subColumnIndex += 1) {
76539
+ bottomCells.push(toHeaderCell(columns[columnIndex + subColumnIndex]));
76540
+ }
76541
+ columnIndex += colSpan;
76542
+ }
76543
+ if (!bottomCells.length) return [columns.map((column) => toHeaderCell(column))];
76544
+ return [topCells, bottomCells];
76545
+ }, [columns, headerGroups]);
76546
+ const isGroupedHeader = headerRows.length > 1;
76547
+ return /* @__PURE__ */ jsx(TableHead, { children: headerRows.map((headerRow, rowIndex) => /* @__PURE__ */ jsx(TableRow, { children: headerRow.map((cell) => {
76499
76548
  var _a;
76500
76549
  return /* @__PURE__ */ jsx(
76501
76550
  TableCell,
76502
76551
  {
76503
- align: column.align,
76504
- sx: {
76505
- width: `${column.width}px !important`,
76506
- minWidth: `${column.width}px !important`,
76507
- maxWidth: `${column.width}px !important`,
76508
- fontWeight: 550,
76509
- padding: PADDING_GAP_ITEM,
76510
- borderRadius: "0 !important",
76511
- backgroundColor: "#F9FAFB",
76512
- verticalAlign: "top",
76513
- textAlign: column.alignHead ? column.alignHead : "center",
76514
- borderTop: BORDER_TABLE,
76515
- ...column.stickyCss ? {
76516
- ...column.stickyCss,
76552
+ align: cell.align,
76553
+ colSpan: cell.colSpan,
76554
+ rowSpan: cell.rowSpan,
76555
+ sx: mergeSxProps(
76556
+ {
76557
+ ...cell.width != null ? {
76558
+ width: `${cell.width}px !important`,
76559
+ minWidth: `${cell.width}px !important`,
76560
+ maxWidth: `${cell.width}px !important`
76561
+ } : {},
76562
+ height: isGroupedHeader ? GROUPED_HEADER_ROW_HEIGHT : void 0,
76563
+ fontWeight: 550,
76564
+ padding: PADDING_GAP_ITEM,
76565
+ borderRadius: "0 !important",
76566
+ backgroundColor: "#F9FAFB",
76567
+ verticalAlign: isGroupedHeader && cell.rowSpan ? "middle" : "top",
76568
+ textAlign: cell.alignHead ? cell.alignHead : "center",
76569
+ borderTop: rowIndex === 0 ? BORDER_TABLE : "none",
76570
+ top: isGroupedHeader ? rowIndex * GROUPED_HEADER_ROW_HEIGHT : 0
76571
+ },
76572
+ cell.stickyCss ? {
76573
+ ...cell.stickyCss,
76517
76574
  position: "sticky",
76518
76575
  backgroundColor: palette.background.paper,
76519
76576
  zIndex: 4,
76520
- borderRight: ((_a = column.stickyCss) == null ? void 0 : _a.left) != null ? BORDER_TABLE : ""
76577
+ borderRight: ((_a = cell.stickyCss) == null ? void 0 : _a.left) != null ? BORDER_TABLE : ""
76521
76578
  } : {},
76522
- ...column.sx ? column.sx : {}
76523
- },
76524
- children: /* @__PURE__ */ jsx(Typography$1, { variant: "subtitle1", children: column.label })
76579
+ cell.sx
76580
+ ),
76581
+ children: /* @__PURE__ */ jsx(Typography$1, { variant: "subtitle1", children: cell.label })
76525
76582
  },
76526
- column.id
76583
+ cell.id
76527
76584
  );
76528
- }) }) });
76529
- };
76585
+ }) }, rowIndex)) });
76586
+ }
76530
76587
  const TableBaseComponent = ({
76531
76588
  columns,
76589
+ headerGroups,
76532
76590
  rows = [],
76533
76591
  loading = false,
76534
- indexLoadingRow,
76535
76592
  stickyHeader = true,
76536
76593
  tableSx,
76537
76594
  tableRef,
@@ -76559,7 +76616,7 @@ const TableBaseComponent = ({
76559
76616
  ...Array.isArray(tableSx) ? tableSx : [tableSx]
76560
76617
  ],
76561
76618
  children: [
76562
- /* @__PURE__ */ jsx(TableHeadPart, { columns }),
76619
+ /* @__PURE__ */ jsx(TableHeadPart, { columns, headerGroups }),
76563
76620
  /* @__PURE__ */ jsx(TableBody, { children: loading ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: columns.length, children: renderLoading() }) }) : rows.length ? rows.map((row, index) => /* @__PURE__ */ jsx(React__default.Fragment, { children: renderRow(row, index) }, index)) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: columns.length, children: renderEmpty() }) }) })
76564
76621
  ]
76565
76622
  }
@@ -76570,6 +76627,7 @@ function TableRendererComponent({
76570
76627
  loading = false,
76571
76628
  rows,
76572
76629
  columns: initialColumns,
76630
+ headerGroups,
76573
76631
  indexLoadingRow,
76574
76632
  isStickyActions = false,
76575
76633
  rowSx = {},
@@ -76869,9 +76927,25 @@ function TableRendererComponent({
76869
76927
  render: (row, index) => /* @__PURE__ */ jsx(StackRowAlignJustCenter, { gap: 1, onClick: (e) => e.stopPropagation(), children: renderActionsContent(row, index) })
76870
76928
  });
76871
76929
  }
76872
- return updateColumns;
76930
+ if (!(headerGroups == null ? void 0 : headerGroups.length)) return updateColumns;
76931
+ const groupByColumnId = /* @__PURE__ */ new Map();
76932
+ headerGroups.forEach((group) => {
76933
+ group.columnIds.forEach((columnId) => {
76934
+ groupByColumnId.set(columnId, group);
76935
+ });
76936
+ });
76937
+ return updateColumns.map((column) => {
76938
+ const group = groupByColumnId.get(column.id);
76939
+ if (!group || !group.childrenHeadSx && !group.childrenCellSx) return column;
76940
+ return {
76941
+ ...column,
76942
+ ...group.childrenHeadSx ? { headSx: mergeSxProps(group.childrenHeadSx, column.headSx) } : {},
76943
+ ...group.childrenCellSx ? { cellSx: mergeSxProps(group.childrenCellSx, column.cellSx) } : {}
76944
+ };
76945
+ });
76873
76946
  }, [
76874
76947
  initialColumns,
76948
+ headerGroups,
76875
76949
  enableTree,
76876
76950
  onSelectRows,
76877
76951
  lengthActions,
@@ -76926,6 +77000,7 @@ function TableRendererComponent({
76926
77000
  TableBaseComponent,
76927
77001
  {
76928
77002
  columns,
77003
+ headerGroups,
76929
77004
  rows: visibleRows,
76930
77005
  loading,
76931
77006
  indexLoadingRow,
@@ -76950,7 +77025,6 @@ function TableRendererComponent({
76950
77025
  function RowCollapsePart({
76951
77026
  columns,
76952
77027
  row,
76953
- indexRow,
76954
77028
  collapse,
76955
77029
  collapseTableWidth,
76956
77030
  renderDefaultRow,
@@ -77086,6 +77160,10 @@ const tableArgTypes = {
77086
77160
  control: false,
77087
77161
  table: { type: { summary: "Column<R>[]" } }
77088
77162
  },
77163
+ headerGroups: {
77164
+ control: false,
77165
+ table: { type: { summary: "TableHeaderGroup[]" } }
77166
+ },
77089
77167
  rows: {
77090
77168
  control: false,
77091
77169
  table: { type: { summary: "R[]" } }
@@ -79196,8 +79274,10 @@ export {
79196
79274
  getPopperProps,
79197
79275
  getStyleCell,
79198
79276
  getStyleRow,
79277
+ getSxArray,
79199
79278
  highlightText,
79200
79279
  highlightYellow,
79280
+ mergeSxProps,
79201
79281
  number_util as numberUtil,
79202
79282
  object_util as objectUtil,
79203
79283
  other_util as otherUtil,