@sustaina/shared-ui 1.67.0 → 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 +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +128 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -12
- 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';
|
|
@@ -3429,6 +3429,7 @@ var AuditFooter = ({
|
|
|
3429
3429
|
updatedBy,
|
|
3430
3430
|
onDelete,
|
|
3431
3431
|
canDelete = true,
|
|
3432
|
+
canDeleteBehavior,
|
|
3432
3433
|
emptyValue = "-",
|
|
3433
3434
|
labels,
|
|
3434
3435
|
classNames,
|
|
@@ -3449,6 +3450,9 @@ var AuditFooter = ({
|
|
|
3449
3450
|
const timeFormatter = formatters?.time ?? ((value) => formatISODate(value, "H:i:s"));
|
|
3450
3451
|
const userFormatter = formatters?.user ?? ((value) => value ?? emptyValue);
|
|
3451
3452
|
const resolvedDeleteIcon = deleteIcon ?? /* @__PURE__ */ jsx(TrashIcon, { className: "w-5 h-5" });
|
|
3453
|
+
const resolvedCanDeleteBehavior = canDeleteBehavior ?? "hidden";
|
|
3454
|
+
const shouldShowDelete = canDelete || resolvedCanDeleteBehavior === "disabled";
|
|
3455
|
+
const deleteButtonClassName = canDelete ? cn("w-5 h-5 cursor-pointer text-red-500", classNames?.deleteButton) : cn("w-5 h-5 text-gray-300 cursor-not-allowed", classNames?.deleteButtonDisabled);
|
|
3452
3456
|
return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full h-14 mt-12 justify-between items-end px-3", classNames?.root), children: [
|
|
3453
3457
|
/* @__PURE__ */ jsxs(
|
|
3454
3458
|
"div",
|
|
@@ -3473,10 +3477,10 @@ var AuditFooter = ({
|
|
|
3473
3477
|
]
|
|
3474
3478
|
}
|
|
3475
3479
|
),
|
|
3476
|
-
|
|
3480
|
+
shouldShowDelete && /* @__PURE__ */ jsx(
|
|
3477
3481
|
"div",
|
|
3478
3482
|
{
|
|
3479
|
-
className:
|
|
3483
|
+
className: deleteButtonClassName,
|
|
3480
3484
|
onClick: canDelete ? onDelete : void 0,
|
|
3481
3485
|
"aria-label": deleteAriaLabel,
|
|
3482
3486
|
role: "button",
|
|
@@ -9192,7 +9196,11 @@ var modelOptions = [
|
|
|
9192
9196
|
"getVisibleLeafColumns",
|
|
9193
9197
|
"getLeftVisibleLeafColumns",
|
|
9194
9198
|
"getRightVisibleLeafColumns",
|
|
9195
|
-
"getCenterVisibleLeafColumns"
|
|
9199
|
+
"getCenterVisibleLeafColumns",
|
|
9200
|
+
"getFooterGroups",
|
|
9201
|
+
"getLeftFooterGroups",
|
|
9202
|
+
"getRightFooterGroups",
|
|
9203
|
+
"getCenterFooterGroups"
|
|
9196
9204
|
];
|
|
9197
9205
|
var DataTableDevTool = ({ table }) => {
|
|
9198
9206
|
const [open, setOpen] = useState(false);
|
|
@@ -9622,7 +9630,7 @@ var TableHeaderRows = ({
|
|
|
9622
9630
|
const { isLastLeftPinnedColumn } = getColumnPinningInfo(header.column);
|
|
9623
9631
|
const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextHeader.column);
|
|
9624
9632
|
const headerGroupLength = header.headerGroup.headers.length;
|
|
9625
|
-
const showSeparator = header.index !== headerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn;
|
|
9633
|
+
const showSeparator = header.index !== headerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!header.isPlaceholder || !nextHeader.isPlaceholder);
|
|
9626
9634
|
return /* @__PURE__ */ jsxs(
|
|
9627
9635
|
TableHead,
|
|
9628
9636
|
{
|
|
@@ -9637,7 +9645,7 @@ var TableHeaderRows = ({
|
|
|
9637
9645
|
),
|
|
9638
9646
|
style: {
|
|
9639
9647
|
...style,
|
|
9640
|
-
width: useColumnSizing ? header.
|
|
9648
|
+
width: useColumnSizing ? `calc(var(--header-${header.id}-size, ${header.getSize()}) * 1px)` : void 0,
|
|
9641
9649
|
minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
|
|
9642
9650
|
maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
|
|
9643
9651
|
...tableHeadCellProps?.style,
|
|
@@ -9688,7 +9696,7 @@ var TableFilterRow = ({
|
|
|
9688
9696
|
),
|
|
9689
9697
|
style: {
|
|
9690
9698
|
...style,
|
|
9691
|
-
width: useColumnSizing ? column.getSize() : void 0,
|
|
9699
|
+
width: useColumnSizing ? `calc(var(--col-${column.id}-size, ${column.getSize()}) * 1px)` : void 0,
|
|
9692
9700
|
minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
|
|
9693
9701
|
maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
|
|
9694
9702
|
...tableFilterCellProps?.style,
|
|
@@ -9772,7 +9780,7 @@ var TableDataRows = ({
|
|
|
9772
9780
|
),
|
|
9773
9781
|
style: {
|
|
9774
9782
|
...style,
|
|
9775
|
-
width: useColumnSizing ? cell.column.getSize() : void 0,
|
|
9783
|
+
width: useColumnSizing ? `calc(var(--col-${cell.column.id}-size, ${cell.column.getSize()}) * 1px)` : void 0,
|
|
9776
9784
|
minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
|
|
9777
9785
|
maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
|
|
9778
9786
|
...tableDataCellProps?.style,
|
|
@@ -9795,6 +9803,67 @@ var TableDataRows = ({
|
|
|
9795
9803
|
) })
|
|
9796
9804
|
] });
|
|
9797
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
|
+
};
|
|
9798
9867
|
var DataTable = ({
|
|
9799
9868
|
tableRef,
|
|
9800
9869
|
virtualizerRef,
|
|
@@ -9851,6 +9920,19 @@ var DataTable = ({
|
|
|
9851
9920
|
activeStatusContent
|
|
9852
9921
|
});
|
|
9853
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;
|
|
9854
9936
|
useBindRef_default({ ref: tableRef, value: table });
|
|
9855
9937
|
useBindRef_default({ ref: virtualizerRef, value: virtualizer });
|
|
9856
9938
|
return /* @__PURE__ */ jsxs(
|
|
@@ -9893,7 +9975,11 @@ var DataTable = ({
|
|
|
9893
9975
|
Table,
|
|
9894
9976
|
{
|
|
9895
9977
|
...components?.tableProps,
|
|
9896
|
-
style: {
|
|
9978
|
+
style: {
|
|
9979
|
+
tableLayout: virtualEnabled ? "fixed" : "auto",
|
|
9980
|
+
...components?.tableProps?.style,
|
|
9981
|
+
...columnSizeVars
|
|
9982
|
+
},
|
|
9897
9983
|
children: [
|
|
9898
9984
|
/* @__PURE__ */ jsxs(
|
|
9899
9985
|
TableHeader,
|
|
@@ -9924,7 +10010,23 @@ var DataTable = ({
|
|
|
9924
10010
|
]
|
|
9925
10011
|
}
|
|
9926
10012
|
),
|
|
9927
|
-
/* @__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(
|
|
9928
10030
|
TableDataRows,
|
|
9929
10031
|
{
|
|
9930
10032
|
table,
|
|
@@ -9940,7 +10042,23 @@ var DataTable = ({
|
|
|
9940
10042
|
onRowClick,
|
|
9941
10043
|
components
|
|
9942
10044
|
}
|
|
9943
|
-
) })
|
|
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
|
+
)
|
|
9944
10062
|
]
|
|
9945
10063
|
}
|
|
9946
10064
|
),
|