@sustaina/shared-ui 1.67.1 → 1.68.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.
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +122 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { forwardRef, memo, isValidElement, useMemo, useRef, useEffect, useCallback, useLayoutEffect, useState
|
|
2
|
+
import React__default, { forwardRef, memo, createElement, isValidElement, useMemo, useRef, useEffect, useCallback, useLayoutEffect, useState } from 'react';
|
|
3
3
|
import { useRouter } from '@tanstack/react-router';
|
|
4
4
|
import { create } from 'zustand';
|
|
5
5
|
import clsx2, { clsx } from 'clsx';
|
|
@@ -23,7 +23,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
|
|
|
23
23
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
24
24
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
25
25
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
26
|
-
import { reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel
|
|
26
|
+
import { flexRender, reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel } from '@tanstack/react-table';
|
|
27
27
|
import { initReactI18next, useTranslation, I18nextProvider } from 'react-i18next';
|
|
28
28
|
import i18n from 'i18next';
|
|
29
29
|
import StarterKit from '@tiptap/starter-kit';
|
|
@@ -9196,7 +9196,11 @@ var modelOptions = [
|
|
|
9196
9196
|
"getVisibleLeafColumns",
|
|
9197
9197
|
"getLeftVisibleLeafColumns",
|
|
9198
9198
|
"getRightVisibleLeafColumns",
|
|
9199
|
-
"getCenterVisibleLeafColumns"
|
|
9199
|
+
"getCenterVisibleLeafColumns",
|
|
9200
|
+
"getFooterGroups",
|
|
9201
|
+
"getLeftFooterGroups",
|
|
9202
|
+
"getRightFooterGroups",
|
|
9203
|
+
"getCenterFooterGroups"
|
|
9200
9204
|
];
|
|
9201
9205
|
var DataTableDevTool = ({ table }) => {
|
|
9202
9206
|
const [open, setOpen] = useState(false);
|
|
@@ -9626,7 +9630,7 @@ var TableHeaderRows = ({
|
|
|
9626
9630
|
const { isLastLeftPinnedColumn } = getColumnPinningInfo(header.column);
|
|
9627
9631
|
const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextHeader.column);
|
|
9628
9632
|
const headerGroupLength = header.headerGroup.headers.length;
|
|
9629
|
-
const showSeparator = header.index !== headerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn;
|
|
9633
|
+
const showSeparator = header.index !== headerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!header.isPlaceholder || !nextHeader.isPlaceholder);
|
|
9630
9634
|
return /* @__PURE__ */ jsxs(
|
|
9631
9635
|
TableHead,
|
|
9632
9636
|
{
|
|
@@ -9641,7 +9645,7 @@ var TableHeaderRows = ({
|
|
|
9641
9645
|
),
|
|
9642
9646
|
style: {
|
|
9643
9647
|
...style,
|
|
9644
|
-
width: useColumnSizing ? header.
|
|
9648
|
+
width: useColumnSizing ? `calc(var(--header-${header.id}-size, ${header.getSize()}) * 1px)` : void 0,
|
|
9645
9649
|
minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
|
|
9646
9650
|
maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
|
|
9647
9651
|
...tableHeadCellProps?.style,
|
|
@@ -9692,7 +9696,7 @@ var TableFilterRow = ({
|
|
|
9692
9696
|
),
|
|
9693
9697
|
style: {
|
|
9694
9698
|
...style,
|
|
9695
|
-
width: useColumnSizing ? column.getSize() : void 0,
|
|
9699
|
+
width: useColumnSizing ? `calc(var(--col-${column.id}-size, ${column.getSize()}) * 1px)` : void 0,
|
|
9696
9700
|
minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
|
|
9697
9701
|
maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
|
|
9698
9702
|
...tableFilterCellProps?.style,
|
|
@@ -9776,7 +9780,7 @@ var TableDataRows = ({
|
|
|
9776
9780
|
),
|
|
9777
9781
|
style: {
|
|
9778
9782
|
...style,
|
|
9779
|
-
width: useColumnSizing ? cell.column.getSize() : void 0,
|
|
9783
|
+
width: useColumnSizing ? `calc(var(--col-${cell.column.id}-size, ${cell.column.getSize()}) * 1px)` : void 0,
|
|
9780
9784
|
minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
|
|
9781
9785
|
maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
|
|
9782
9786
|
...tableDataCellProps?.style,
|
|
@@ -9799,6 +9803,67 @@ var TableDataRows = ({
|
|
|
9799
9803
|
) })
|
|
9800
9804
|
] });
|
|
9801
9805
|
};
|
|
9806
|
+
var MemoizedTableDataRows = React__default.memo(
|
|
9807
|
+
TableDataRows,
|
|
9808
|
+
(prev, next) => prev.table.options.data === next.table.options.data
|
|
9809
|
+
);
|
|
9810
|
+
var TableFooterRows = ({
|
|
9811
|
+
table,
|
|
9812
|
+
columnResizing,
|
|
9813
|
+
components,
|
|
9814
|
+
virtual
|
|
9815
|
+
}) => {
|
|
9816
|
+
const hasAnyFooter = table.getAllColumns().some((col) => col.columnDef.footer != null);
|
|
9817
|
+
if (!hasAnyFooter) return null;
|
|
9818
|
+
return /* @__PURE__ */ jsx(Fragment, { children: table.getFooterGroups().map((footerGroup) => {
|
|
9819
|
+
const tableFooterRowProps = typeof components?.tableFooterRowProps === "function" ? components.tableFooterRowProps({ footerGroup, table }) : components?.tableFooterRowProps;
|
|
9820
|
+
return /* @__PURE__ */ jsx(TableRow, { ...tableFooterRowProps, children: footerGroup.headers.map((footer) => {
|
|
9821
|
+
const { classes, style } = getColumnPinningStyles(footer.column);
|
|
9822
|
+
const useColumnSizing = footer.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
|
|
9823
|
+
const tableFooterCellProps = typeof components?.tableFooterCellProps === "function" ? components.tableFooterCellProps({ footer, table }) : components?.tableFooterCellProps;
|
|
9824
|
+
const nextFooter = footerGroup.headers[footer.index + 1] ?? footer;
|
|
9825
|
+
const { isLastLeftPinnedColumn } = getColumnPinningInfo(footer.column);
|
|
9826
|
+
const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextFooter.column);
|
|
9827
|
+
const footerGroupLength = footer.headerGroup.headers.length;
|
|
9828
|
+
const showSeparator = footer.index !== footerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!footer.isPlaceholder || !nextFooter.isPlaceholder);
|
|
9829
|
+
return /* @__PURE__ */ jsxs(
|
|
9830
|
+
TableHead,
|
|
9831
|
+
{
|
|
9832
|
+
"data-testid": `footer-cell-${footer.id}`,
|
|
9833
|
+
colSpan: footer.colSpan,
|
|
9834
|
+
...tableFooterCellProps,
|
|
9835
|
+
...footer.column.columnDef?.meta?.footerProps,
|
|
9836
|
+
className: cn(
|
|
9837
|
+
classes,
|
|
9838
|
+
tableFooterCellProps?.className,
|
|
9839
|
+
footer.column.columnDef?.meta?.footerProps?.className
|
|
9840
|
+
),
|
|
9841
|
+
style: {
|
|
9842
|
+
...style,
|
|
9843
|
+
width: useColumnSizing ? `calc(var(--col-${footer.column.id}-size, ${footer.column.getSize()}) * 1px)` : void 0,
|
|
9844
|
+
minWidth: useColumnSizing ? footer.column.columnDef.minSize : void 0,
|
|
9845
|
+
maxWidth: useColumnSizing ? footer.column.columnDef.maxSize : void 0,
|
|
9846
|
+
...tableFooterCellProps?.style,
|
|
9847
|
+
...footer.column.columnDef?.meta?.footerProps?.style
|
|
9848
|
+
},
|
|
9849
|
+
children: [
|
|
9850
|
+
footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext()),
|
|
9851
|
+
/* @__PURE__ */ jsx(
|
|
9852
|
+
ColumnSeparator_default,
|
|
9853
|
+
{
|
|
9854
|
+
...components?.columnSeparatorProps?.headerCell,
|
|
9855
|
+
...footer.column.columnDef?.meta?.columnSeparatorProps,
|
|
9856
|
+
show: footer.column.columnDef?.meta?.columnSeparatorProps?.show ?? components?.columnSeparatorProps?.headerCell?.show ?? showSeparator
|
|
9857
|
+
}
|
|
9858
|
+
),
|
|
9859
|
+
!footer.isPlaceholder && /* @__PURE__ */ jsx(ColumnResizer_default, { header: footer, ...components?.columnResizerProps })
|
|
9860
|
+
]
|
|
9861
|
+
},
|
|
9862
|
+
footer.id
|
|
9863
|
+
);
|
|
9864
|
+
}) }, footerGroup.id);
|
|
9865
|
+
}) });
|
|
9866
|
+
};
|
|
9802
9867
|
var DataTable = ({
|
|
9803
9868
|
tableRef,
|
|
9804
9869
|
virtualizerRef,
|
|
@@ -9855,6 +9920,19 @@ var DataTable = ({
|
|
|
9855
9920
|
activeStatusContent
|
|
9856
9921
|
});
|
|
9857
9922
|
const fetchMoreOnScrollReached = useScrollFetch({ scrollFetch, containerRef: tableContainerRef });
|
|
9923
|
+
const columnResizingEnabled = columnResizing?.enabled;
|
|
9924
|
+
const { columnSizing, columnSizingInfo } = table.getState();
|
|
9925
|
+
const columnSizeVars = useMemo(() => {
|
|
9926
|
+
if (!columnResizingEnabled && !virtualEnabled) return {};
|
|
9927
|
+
const headers = table.getFlatHeaders();
|
|
9928
|
+
const colSizes = {};
|
|
9929
|
+
for (const header of headers) {
|
|
9930
|
+
colSizes[`--header-${header.id}-size`] = header.getSize();
|
|
9931
|
+
colSizes[`--col-${header.column.id}-size`] = header.column.getSize();
|
|
9932
|
+
}
|
|
9933
|
+
return colSizes;
|
|
9934
|
+
}, [columnSizing, columnSizingInfo, columnResizingEnabled, virtualEnabled]);
|
|
9935
|
+
const isResizing = columnResizingEnabled && !!columnSizingInfo.isResizingColumn;
|
|
9858
9936
|
useBindRef_default({ ref: tableRef, value: table });
|
|
9859
9937
|
useBindRef_default({ ref: virtualizerRef, value: virtualizer });
|
|
9860
9938
|
return /* @__PURE__ */ jsxs(
|
|
@@ -9897,7 +9975,11 @@ var DataTable = ({
|
|
|
9897
9975
|
Table,
|
|
9898
9976
|
{
|
|
9899
9977
|
...components?.tableProps,
|
|
9900
|
-
style: {
|
|
9978
|
+
style: {
|
|
9979
|
+
tableLayout: virtualEnabled ? "fixed" : "auto",
|
|
9980
|
+
...components?.tableProps?.style,
|
|
9981
|
+
...columnSizeVars
|
|
9982
|
+
},
|
|
9901
9983
|
children: [
|
|
9902
9984
|
/* @__PURE__ */ jsxs(
|
|
9903
9985
|
TableHeader,
|
|
@@ -9928,7 +10010,23 @@ var DataTable = ({
|
|
|
9928
10010
|
]
|
|
9929
10011
|
}
|
|
9930
10012
|
),
|
|
9931
|
-
/* @__PURE__ */ jsx(TableBody, { ...components?.tableBodyProps, children: /* @__PURE__ */ jsx(
|
|
10013
|
+
/* @__PURE__ */ jsx(TableBody, { ...components?.tableBodyProps, children: isResizing ? /* @__PURE__ */ jsx(
|
|
10014
|
+
MemoizedTableDataRows,
|
|
10015
|
+
{
|
|
10016
|
+
table,
|
|
10017
|
+
rowModel,
|
|
10018
|
+
virtualEnabled,
|
|
10019
|
+
virtualItems,
|
|
10020
|
+
virtualizer,
|
|
10021
|
+
paddingTop,
|
|
10022
|
+
paddingBottom,
|
|
10023
|
+
visibleColumnCount,
|
|
10024
|
+
columnResizing,
|
|
10025
|
+
virtual,
|
|
10026
|
+
onRowClick,
|
|
10027
|
+
components
|
|
10028
|
+
}
|
|
10029
|
+
) : /* @__PURE__ */ jsx(
|
|
9932
10030
|
TableDataRows,
|
|
9933
10031
|
{
|
|
9934
10032
|
table,
|
|
@@ -9944,7 +10042,23 @@ var DataTable = ({
|
|
|
9944
10042
|
onRowClick,
|
|
9945
10043
|
components
|
|
9946
10044
|
}
|
|
9947
|
-
) })
|
|
10045
|
+
) }),
|
|
10046
|
+
/* @__PURE__ */ jsx(
|
|
10047
|
+
TableFooter,
|
|
10048
|
+
{
|
|
10049
|
+
...components?.tableFooterProps,
|
|
10050
|
+
className: cn("sticky bottom-0 z-10 bg-white", components?.tableFooterProps?.className),
|
|
10051
|
+
children: /* @__PURE__ */ jsx(
|
|
10052
|
+
TableFooterRows,
|
|
10053
|
+
{
|
|
10054
|
+
table,
|
|
10055
|
+
columnResizing,
|
|
10056
|
+
virtual,
|
|
10057
|
+
components
|
|
10058
|
+
}
|
|
10059
|
+
)
|
|
10060
|
+
}
|
|
10061
|
+
)
|
|
9948
10062
|
]
|
|
9949
10063
|
}
|
|
9950
10064
|
),
|