@bsol-oss/react-datatable5 12.0.0-beta.80 → 12.0.0-beta.81
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.ts +365 -353
- package/dist/index.js +1009 -831
- package/dist/index.mjs +1012 -834
- package/dist/types/components/DataTable/display/Table.d.ts +2 -1
- package/dist/types/components/DataTable/hooks/useResponsiveColumnVisibility.d.ts +13 -0
- package/dist/types/components/Form/components/fields/StringInputField.d.ts +4 -0
- package/dist/types/index.d.ts +64 -57
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,13 +18,12 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
18
18
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
19
19
|
var rafSchd = require('raf-schd');
|
|
20
20
|
var invariant = require('tiny-invariant');
|
|
21
|
-
var hi = require('react-icons/hi');
|
|
22
|
-
var reactTable = require('@tanstack/react-table');
|
|
23
|
-
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
24
|
-
var bs = require('react-icons/bs');
|
|
25
|
-
var usehooks = require('@uidotdev/usehooks');
|
|
26
21
|
var reactQuery = require('@tanstack/react-query');
|
|
27
22
|
var io5 = require('react-icons/io5');
|
|
23
|
+
var usehooks = require('@uidotdev/usehooks');
|
|
24
|
+
var bs = require('react-icons/bs');
|
|
25
|
+
var hi = require('react-icons/hi');
|
|
26
|
+
var reactTable = require('@tanstack/react-table');
|
|
28
27
|
var gr = require('react-icons/gr');
|
|
29
28
|
var reactI18next = require('react-i18next');
|
|
30
29
|
var axios = require('axios');
|
|
@@ -35,6 +34,7 @@ var dayjs = require('dayjs');
|
|
|
35
34
|
var utc = require('dayjs/plugin/utc');
|
|
36
35
|
var timezone = require('dayjs/plugin/timezone');
|
|
37
36
|
var ti = require('react-icons/ti');
|
|
37
|
+
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
38
38
|
|
|
39
39
|
function _interopNamespaceDefault(e) {
|
|
40
40
|
var n = Object.create(null);
|
|
@@ -2622,13 +2622,12 @@ const ViewDialog = ({ icon = jsxRuntime.jsx(io.IoMdEye, {}) }) => {
|
|
|
2622
2622
|
return (jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", view] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: view }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }));
|
|
2623
2623
|
};
|
|
2624
2624
|
|
|
2625
|
-
const
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
};
|
|
2625
|
+
const Tooltip = React__namespace.forwardRef(function Tooltip(props, ref) {
|
|
2626
|
+
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
2627
|
+
if (disabled)
|
|
2628
|
+
return children;
|
|
2629
|
+
return (jsxRuntime.jsxs(react.Tooltip.Root, { ...rest, children: [jsxRuntime.jsx(react.Tooltip.Trigger, { asChild: true, children: children }), jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Tooltip.Positioner, { children: jsxRuntime.jsxs(react.Tooltip.Content, { ref: ref, ...contentProps, children: [showArrow && (jsxRuntime.jsx(react.Tooltip.Arrow, { children: jsxRuntime.jsx(react.Tooltip.ArrowTip, {}) })), content] }) }) })] }));
|
|
2630
|
+
});
|
|
2632
2631
|
|
|
2633
2632
|
const DataTableServerContext = React.createContext({
|
|
2634
2633
|
url: "",
|
|
@@ -2641,697 +2640,435 @@ const useDataTableServerContext = () => {
|
|
|
2641
2640
|
return { ...context, isEmpty };
|
|
2642
2641
|
};
|
|
2643
2642
|
|
|
2644
|
-
const
|
|
2645
|
-
const {
|
|
2646
|
-
|
|
2643
|
+
const ReloadButton = ({ variant = "icon", }) => {
|
|
2644
|
+
const { url } = useDataTableServerContext();
|
|
2645
|
+
const queryClient = reactQuery.useQueryClient();
|
|
2646
|
+
const { tableLabel } = useDataTableContext();
|
|
2647
|
+
const { reloadTooltip, reloadButtonText } = tableLabel;
|
|
2648
|
+
if (variant === "icon") {
|
|
2649
|
+
return (jsxRuntime.jsx(Tooltip, { showArrow: true, content: reloadTooltip, children: jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => {
|
|
2650
|
+
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2651
|
+
}, "aria-label": "refresh", children: jsxRuntime.jsx(io5.IoReload, {}) }) }));
|
|
2652
|
+
}
|
|
2653
|
+
return (jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
|
|
2654
|
+
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2655
|
+
}, children: [jsxRuntime.jsx(io5.IoReload, {}), " ", reloadButtonText] }));
|
|
2647
2656
|
};
|
|
2648
2657
|
|
|
2649
|
-
const
|
|
2650
|
-
const {
|
|
2651
|
-
|
|
2652
|
-
|
|
2658
|
+
const InputGroup = React__namespace.forwardRef(function InputGroup(props, ref) {
|
|
2659
|
+
const { startElement, startElementProps, endElement, endElementProps, children, startOffset = "6px", endOffset = "6px", ...rest } = props;
|
|
2660
|
+
return (jsxRuntime.jsxs(react.Group, { ref: ref, ...rest, children: [startElement && (jsxRuntime.jsx(react.InputElement, { pointerEvents: "none", ...startElementProps, children: startElement })), React__namespace.cloneElement(children, {
|
|
2661
|
+
...(startElement && {
|
|
2662
|
+
ps: `calc(var(--input-height) - ${startOffset})`,
|
|
2663
|
+
}),
|
|
2664
|
+
...(endElement && { pe: `calc(var(--input-height) - ${endOffset})` }),
|
|
2665
|
+
// @ts-expect-error chakra generated files
|
|
2666
|
+
...children.props,
|
|
2667
|
+
}), endElement && (jsxRuntime.jsx(react.InputElement, { placement: "end", ...endElementProps, children: endElement }))] }));
|
|
2668
|
+
});
|
|
2669
|
+
|
|
2670
|
+
const GlobalFilter = () => {
|
|
2671
|
+
const { table, tableLabel } = useDataTableContext();
|
|
2672
|
+
const { globalFilterPlaceholder } = tableLabel;
|
|
2673
|
+
const [searchTerm, setSearchTerm] = React.useState("");
|
|
2674
|
+
const debouncedSearchTerm = usehooks.useDebounce(searchTerm, 500);
|
|
2675
|
+
React.useEffect(() => {
|
|
2676
|
+
const searchHN = async () => {
|
|
2677
|
+
table.setGlobalFilter(debouncedSearchTerm);
|
|
2678
|
+
};
|
|
2679
|
+
searchHN();
|
|
2680
|
+
}, [debouncedSearchTerm]);
|
|
2681
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(InputGroup, { flex: "1", startElement: jsxRuntime.jsx(md.MdSearch, {}), children: jsxRuntime.jsx(react.Input, { placeholder: globalFilterPlaceholder, variant: "outline", onChange: (e) => {
|
|
2682
|
+
setSearchTerm(e.target.value);
|
|
2683
|
+
} }) }) }));
|
|
2653
2684
|
};
|
|
2654
2685
|
|
|
2655
|
-
const
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2686
|
+
const SelectAllRowsToggle = ({ selectAllIcon = jsxRuntime.jsx(md.MdOutlineChecklist, {}), clearAllIcon = jsxRuntime.jsx(md.MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
2687
|
+
const { table } = useDataTableContext();
|
|
2688
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!selectAllText === false && (jsxRuntime.jsx(react.IconButton, { variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
2689
|
+
table.getToggleAllRowsSelectedHandler()(event);
|
|
2690
|
+
}, children: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon })), !!selectAllText !== false && (jsxRuntime.jsxs(react.Button, { variant: "ghost", onClick: (event) => {
|
|
2691
|
+
table.getToggleAllRowsSelectedHandler()(event);
|
|
2692
|
+
}, children: [table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, table.getIsAllRowsSelected() ? clearAllText : selectAllText] }))] }));
|
|
2660
2693
|
};
|
|
2661
2694
|
|
|
2662
|
-
const
|
|
2663
|
-
const
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
return snakeToLabel(field);
|
|
2668
|
-
};
|
|
2669
|
-
if (object === null) {
|
|
2670
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "null" });
|
|
2671
|
-
}
|
|
2672
|
-
return (jsxRuntime.jsx(react.Grid, { rowGap: 1, padding: 1, overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
2673
|
-
return (jsxRuntime.jsxs(react.Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsxRuntime.jsx(react.Text, { color: "colorPalette.400", children: getColumn({ field }) }), typeof value === "object" ? (jsxRuntime.jsx(RecordDisplay, { object: value, prefix: `${prefix}${field}.`, translate: translate })) : (jsxRuntime.jsx(react.Text, { children: JSON.stringify(value) }))] }, field));
|
|
2674
|
-
}) }));
|
|
2695
|
+
const TableSelector = () => {
|
|
2696
|
+
const { table } = useDataTableContext();
|
|
2697
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [table.getSelectedRowModel().rows.length > 0 && (jsxRuntime.jsxs(react.Button, { onClick: () => { }, variant: "ghost", display: "flex", gap: "0.25rem", children: [jsxRuntime.jsx(react.Box, { fontSize: "sm", children: `${table.getSelectedRowModel().rows.length}` }), jsxRuntime.jsx(io.IoMdCheckbox, {})] })), !table.getIsAllPageRowsSelected() && jsxRuntime.jsx(SelectAllRowsToggle, {}), table.getSelectedRowModel().rows.length > 0 && (jsxRuntime.jsx(react.IconButton, { variant: "ghost", onClick: () => {
|
|
2698
|
+
table.resetRowSelection();
|
|
2699
|
+
}, "aria-label": "reset selection", children: jsxRuntime.jsx(md.MdClear, {}) }))] }));
|
|
2675
2700
|
};
|
|
2676
2701
|
|
|
2677
|
-
const
|
|
2678
|
-
const {
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
if (typeof value === "object") {
|
|
2687
|
-
return JSON.stringify(value);
|
|
2688
|
-
}
|
|
2689
|
-
if (typeof value === "string") {
|
|
2690
|
-
return value;
|
|
2691
|
-
}
|
|
2692
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
2693
|
-
return `${value}`;
|
|
2694
|
-
}
|
|
2695
|
-
if (value === undefined) {
|
|
2696
|
-
if (translate !== undefined) {
|
|
2697
|
-
return translate.t(`undefined`);
|
|
2698
|
-
}
|
|
2699
|
-
return `undefined`;
|
|
2700
|
-
}
|
|
2701
|
-
throw new Error(`value is unknown, ${typeof value}`);
|
|
2702
|
-
};
|
|
2703
|
-
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
2704
|
-
const gridColumn = cell.column.columnDef.meta?.gridColumn ?? [
|
|
2705
|
-
"span 12",
|
|
2706
|
-
"span 6",
|
|
2707
|
-
"span 3",
|
|
2708
|
-
];
|
|
2709
|
-
const gridRow = cell.column.columnDef.meta?.gridRow ?? {};
|
|
2710
|
-
if (showCustomDataDisplay) {
|
|
2711
|
-
return (jsxRuntime.jsx(react.Flex, { gridColumn, gridRow, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2712
|
-
}
|
|
2713
|
-
const value = cell.getValue();
|
|
2714
|
-
if (typeof value === "object") {
|
|
2715
|
-
return (jsxRuntime.jsxs(react.Box, { gridColumn, gridRow, children: [jsxRuntime.jsx(react.Box, { children: getLabel({ columnId: cell.column.id }) }), jsxRuntime.jsx(RecordDisplay, { boxProps: {
|
|
2716
|
-
borderWidth: 1,
|
|
2717
|
-
borderRadius: 4,
|
|
2718
|
-
borderColor: "gray.400",
|
|
2719
|
-
paddingX: 4,
|
|
2720
|
-
paddingY: 2,
|
|
2721
|
-
}, object: value })] }, cell.id));
|
|
2722
|
-
}
|
|
2723
|
-
return (jsxRuntime.jsxs(react.Box, { gridColumn, gridRow, children: [jsxRuntime.jsx(react.Box, { color: "colorPalette.400", children: getLabel({ columnId: cell.column.id }) }), jsxRuntime.jsx(react.Box, { wordBreak: "break-word", textOverflow: "ellipsis", overflow: "hidden", children: `${formatValue(cell.getValue())}` })] }, cell.id));
|
|
2702
|
+
const TableFilterTags = () => {
|
|
2703
|
+
const { table } = useDataTableContext();
|
|
2704
|
+
return (jsxRuntime.jsx(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }) => {
|
|
2705
|
+
return (jsxRuntime.jsx(Tag, { gap: "0.5rem", closable: true, cursor: "pointer", onClick: () => {
|
|
2706
|
+
table.setColumnFilters(table.getState().columnFilters.filter((filter) => {
|
|
2707
|
+
return filter.value != value;
|
|
2708
|
+
}));
|
|
2709
|
+
}, children: `${id}: ${value}` }, `${id}-${value}`));
|
|
2710
|
+
}) }));
|
|
2724
2711
|
};
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
if (!column.getIsVisible()) {
|
|
2736
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2712
|
+
|
|
2713
|
+
const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children = jsxRuntime.jsx(jsxRuntime.Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, showPagination = true, showPageSizeControl = true, showPageCountText = true, showView = true, filterTagsOptions = [], extraItems = jsxRuntime.jsx(jsxRuntime.Fragment, {}), loading = false, hasError = false, gridProps = {}, }) => {
|
|
2714
|
+
const { tableLabel, table } = useDataTableContext();
|
|
2715
|
+
const { rowCountText, hasErrorText } = tableLabel;
|
|
2716
|
+
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", ...gridProps, children: [jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsx(react.Box, { children: showView && jsxRuntime.jsx(ViewDialog, { icon: jsxRuntime.jsx(md.MdOutlineViewColumn, {}) }) }), jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsxRuntime.jsx(react.Spinner, { size: "sm" }), hasError && (jsxRuntime.jsx(Tooltip, { content: hasErrorText, children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsxRuntime.jsx(GlobalFilter, {}), showFilter && jsxRuntime.jsx(FilterDialog, {}), showReload && jsxRuntime.jsx(ReloadButton, {}), extraItems] })] }), filterTagsOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterTagsOptions.map((option) => {
|
|
2717
|
+
const { column, options } = option;
|
|
2718
|
+
const tableColumn = table.getColumn(column);
|
|
2719
|
+
return (jsxRuntime.jsxs(react.Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [tableColumn?.columnDef.meta?.displayName && (jsxRuntime.jsx(react.Text, { children: tableColumn?.columnDef.meta?.displayName })), jsxRuntime.jsx(TagFilter, { availableTags: options, selectedTags: tableColumn?.getFilterValue() ?? [], selectOne: true, onTagChange: (tags) => {
|
|
2720
|
+
if (tags.length === 0) {
|
|
2721
|
+
return tableColumn?.setFilterValue(undefined);
|
|
2737
2722
|
}
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
return cell.id === `${rowId}_${column.id}`;
|
|
2742
|
-
});
|
|
2743
|
-
return jsxRuntime.jsx(CellRenderer, { cell: foundCell });
|
|
2744
|
-
}) })] }, `chakra-table-card-${childCell?.id}`));
|
|
2745
|
-
}
|
|
2746
|
-
return jsxRuntime.jsx(CellRenderer, { cell: childCell });
|
|
2747
|
-
}) }) }, `chakra-table-card-${rowId}`));
|
|
2748
|
-
}) }));
|
|
2723
|
+
tableColumn?.setFilterValue(tags);
|
|
2724
|
+
} })] }, column));
|
|
2725
|
+
}) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Grid, { overflow: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, children: children }), (showPageSizeControl || showPageCountText || showPagination) && (jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsxs(react.Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsxRuntime.jsx(PageSizeControl, {}), showPageCountText && (jsxRuntime.jsxs(react.Flex, { children: [jsxRuntime.jsx(react.Text, { paddingRight: "0.5rem", children: rowCountText }), jsxRuntime.jsx(RowCountText, {})] }))] }), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: showPagination && jsxRuntime.jsx(Pagination, {}) })] }))] }));
|
|
2749
2726
|
};
|
|
2750
2727
|
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
}
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2728
|
+
const EmptyState$1 = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
2729
|
+
const { title, description, icon, children, ...rest } = props;
|
|
2730
|
+
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
2731
|
+
});
|
|
2732
|
+
|
|
2733
|
+
/**
|
|
2734
|
+
* Hook to automatically hide/show columns based on container width.
|
|
2735
|
+
* Columns are hidden based on their responsivePriority (lower = hide first).
|
|
2736
|
+
* Only activates when canResize={false}.
|
|
2737
|
+
*/
|
|
2738
|
+
const useResponsiveColumnVisibility = ({ containerRef, enabled, showSelector = false, }) => {
|
|
2739
|
+
const { table, setColumnVisibility } = useDataTableContext();
|
|
2740
|
+
const autoHiddenRef = React.useRef(new Set());
|
|
2741
|
+
const userBaselineRef = React.useRef(null);
|
|
2742
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
2743
|
+
React.useEffect(() => {
|
|
2744
|
+
if (!enabled || !containerRef.current) {
|
|
2745
|
+
// Reset when disabled
|
|
2746
|
+
if (!enabled) {
|
|
2747
|
+
userBaselineRef.current = null;
|
|
2748
|
+
autoHiddenRef.current = new Set();
|
|
2749
|
+
}
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2752
|
+
// Capture baseline visibility when hook is first enabled
|
|
2753
|
+
if (userBaselineRef.current === null) {
|
|
2754
|
+
userBaselineRef.current = { ...table.getState().columnVisibility };
|
|
2755
|
+
}
|
|
2756
|
+
const updateColumnVisibility = () => {
|
|
2757
|
+
const container = containerRef.current;
|
|
2758
|
+
if (!container || !userBaselineRef.current)
|
|
2759
|
+
return;
|
|
2760
|
+
const containerWidth = container.clientWidth;
|
|
2761
|
+
// Get all columns
|
|
2762
|
+
const allColumns = table.getAllLeafColumns();
|
|
2763
|
+
// Get current visibility state
|
|
2764
|
+
const currentVisibility = table.getState().columnVisibility;
|
|
2765
|
+
// Determine user-hidden columns based on baseline
|
|
2766
|
+
// Columns that are hidden in baseline are considered user-hidden
|
|
2767
|
+
const userBaseline = userBaselineRef.current;
|
|
2768
|
+
const userHiddenColumns = new Set();
|
|
2769
|
+
for (const col of allColumns) {
|
|
2770
|
+
// If column was hidden in baseline, it's user-hidden
|
|
2771
|
+
if (userBaseline[col.id] === false) {
|
|
2772
|
+
userHiddenColumns.add(col.id);
|
|
2789
2773
|
}
|
|
2790
|
-
|
|
2791
|
-
|
|
2774
|
+
}
|
|
2775
|
+
// Consider all columns except those hidden by user in baseline
|
|
2776
|
+
const columnsToConsider = allColumns.filter((col) => {
|
|
2777
|
+
return !userHiddenColumns.has(col.id);
|
|
2778
|
+
});
|
|
2779
|
+
// Calculate priority for each column
|
|
2780
|
+
// Lower priority = hide first, Infinity = never auto-hide
|
|
2781
|
+
const columnsWithPriority = columnsToConsider.map((col, index) => {
|
|
2782
|
+
const priority = col.columnDef.meta?.responsivePriority ?? Infinity;
|
|
2783
|
+
return {
|
|
2784
|
+
column: col,
|
|
2785
|
+
priority,
|
|
2786
|
+
size: col.getSize(),
|
|
2787
|
+
index,
|
|
2788
|
+
};
|
|
2789
|
+
});
|
|
2790
|
+
// Sort by priority (ascending), then by index for stable ordering
|
|
2791
|
+
columnsWithPriority.sort((a, b) => {
|
|
2792
|
+
if (a.priority !== b.priority) {
|
|
2793
|
+
return a.priority - b.priority;
|
|
2792
2794
|
}
|
|
2793
|
-
return
|
|
2795
|
+
return a.index - b.index;
|
|
2794
2796
|
});
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2797
|
+
// Calculate available width (account for selector column if present)
|
|
2798
|
+
const availableWidth = showSelector
|
|
2799
|
+
? containerWidth - SELECTION_BOX_WIDTH
|
|
2800
|
+
: containerWidth;
|
|
2801
|
+
// Calculate which columns can fit
|
|
2802
|
+
let totalWidth = 0;
|
|
2803
|
+
const columnsToShow = new Set();
|
|
2804
|
+
// Always keep at least one column visible
|
|
2805
|
+
let minColumnsShown = 0;
|
|
2806
|
+
for (const { column, priority } of columnsWithPriority) {
|
|
2807
|
+
// If this is the first column and we haven't shown any, always show it
|
|
2808
|
+
if (minColumnsShown === 0) {
|
|
2809
|
+
columnsToShow.add(column.id);
|
|
2810
|
+
totalWidth += column.getSize();
|
|
2811
|
+
minColumnsShown = 1;
|
|
2812
|
+
continue;
|
|
2813
|
+
}
|
|
2814
|
+
// Check if adding this column would exceed available width
|
|
2815
|
+
const newTotalWidth = totalWidth + column.getSize();
|
|
2816
|
+
// If priority is Infinity, always show (never auto-hide)
|
|
2817
|
+
if (priority === Infinity) {
|
|
2818
|
+
columnsToShow.add(column.id);
|
|
2819
|
+
totalWidth = newTotalWidth;
|
|
2820
|
+
}
|
|
2821
|
+
else if (newTotalWidth <= availableWidth) {
|
|
2822
|
+
// Column fits, show it
|
|
2823
|
+
columnsToShow.add(column.id);
|
|
2824
|
+
totalWidth = newTotalWidth;
|
|
2825
|
+
}
|
|
2826
|
+
else ;
|
|
2800
2827
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
|
|
2828
|
+
// Update auto-hidden columns
|
|
2829
|
+
const newAutoHidden = new Set();
|
|
2830
|
+
const newVisibility = { ...currentVisibility };
|
|
2831
|
+
// Update visibility for all columns
|
|
2832
|
+
for (const col of allColumns) {
|
|
2833
|
+
const isUserHidden = userHiddenColumns.has(col.id);
|
|
2834
|
+
if (isUserHidden) {
|
|
2835
|
+
// Respect user preference to hide
|
|
2836
|
+
newVisibility[col.id] = false;
|
|
2837
|
+
}
|
|
2838
|
+
else {
|
|
2839
|
+
const shouldBeVisible = columnsToShow.has(col.id);
|
|
2840
|
+
if (!shouldBeVisible) {
|
|
2841
|
+
// Column should be auto-hidden
|
|
2842
|
+
newAutoHidden.add(col.id);
|
|
2843
|
+
newVisibility[col.id] = false;
|
|
2844
|
+
}
|
|
2845
|
+
else {
|
|
2846
|
+
// Column should be visible
|
|
2847
|
+
newVisibility[col.id] = true;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2806
2850
|
}
|
|
2807
|
-
|
|
2808
|
-
|
|
2851
|
+
// Update auto-hidden ref
|
|
2852
|
+
autoHiddenRef.current = newAutoHidden;
|
|
2853
|
+
// Only update if visibility actually changed
|
|
2854
|
+
const visibilityChanged = Object.keys(newVisibility).some((key) => newVisibility[key] !== currentVisibility[key]) ||
|
|
2855
|
+
Object.keys(currentVisibility).some((key) => newVisibility[key] !== currentVisibility[key]);
|
|
2856
|
+
if (visibilityChanged) {
|
|
2857
|
+
setColumnVisibility(newVisibility);
|
|
2809
2858
|
}
|
|
2810
|
-
return 32;
|
|
2811
2859
|
};
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2860
|
+
// Initial calculation
|
|
2861
|
+
updateColumnVisibility();
|
|
2862
|
+
// Set up ResizeObserver
|
|
2863
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
2864
|
+
updateColumnVisibility();
|
|
2865
|
+
});
|
|
2866
|
+
resizeObserver.observe(containerRef.current);
|
|
2867
|
+
return () => {
|
|
2868
|
+
resizeObserver.disconnect();
|
|
2869
|
+
};
|
|
2870
|
+
}, [enabled, containerRef, table, setColumnVisibility, showSelector]);
|
|
2821
2871
|
};
|
|
2822
|
-
//end of custom feature code
|
|
2823
2872
|
|
|
2824
|
-
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2827
|
-
const
|
|
2828
|
-
//
|
|
2829
|
-
|
|
2830
|
-
|
|
2873
|
+
const EmptyResult = (jsxRuntime.jsx(EmptyState$1, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
2874
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, showLoading = false, showSelector = false, ...props }) => {
|
|
2875
|
+
const { table } = useDataTableContext();
|
|
2876
|
+
const containerRef = React.useRef(null);
|
|
2877
|
+
// Enable responsive column hiding when canResize is false
|
|
2878
|
+
useResponsiveColumnVisibility({
|
|
2879
|
+
containerRef,
|
|
2880
|
+
enabled: !canResize,
|
|
2881
|
+
showSelector,
|
|
2831
2882
|
});
|
|
2832
|
-
//
|
|
2833
|
-
|
|
2883
|
+
// Skip empty check when loading to allow skeleton to render
|
|
2884
|
+
if (!showLoading && table.getRowModel().rows.length <= 0) {
|
|
2885
|
+
return emptyComponent;
|
|
2886
|
+
}
|
|
2887
|
+
return (jsxRuntime.jsx(react.Box, { ref: containerRef, width: "100%", overflow: "auto", children: jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: 'outline', width: canResize ? table.getCenterTotalSize() : undefined, display: 'grid', alignContent: 'start', overflowY: 'auto', bg: { base: 'colorPalette.50', _dark: 'colorPalette.950' }, ...props, children: children }) }));
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2890
|
+
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
2891
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
2892
|
+
return (jsxRuntime.jsxs(react.Checkbox.Root, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.Checkbox.HiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.Checkbox.Control, { children: icon || jsxRuntime.jsx(react.Checkbox.Indicator, {}) }), children != null && (jsxRuntime.jsx(react.Checkbox.Label, { children: children }))] }));
|
|
2893
|
+
});
|
|
2894
|
+
|
|
2895
|
+
const TableBody = ({ showSelector = false, canResize = true, }) => {
|
|
2896
|
+
"use no memo";
|
|
2897
|
+
const { table } = useDataTableContext();
|
|
2898
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
2899
|
+
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
2900
|
+
const handleRowHover = (index) => {
|
|
2901
|
+
setHoveredRow(index);
|
|
2902
|
+
};
|
|
2903
|
+
const getTdProps = (cell) => {
|
|
2904
|
+
const tdProps = cell.column.getIsPinned()
|
|
2905
|
+
? {
|
|
2906
|
+
left: showSelector
|
|
2907
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
2908
|
+
: `${cell.column.getStart("left")}px`,
|
|
2909
|
+
position: "relative",
|
|
2910
|
+
}
|
|
2911
|
+
: {};
|
|
2912
|
+
return tdProps;
|
|
2913
|
+
};
|
|
2914
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2915
|
+
if (hoveredRow === -1) {
|
|
2916
|
+
return {};
|
|
2917
|
+
}
|
|
2918
|
+
if (hoveredRow === index) {
|
|
2919
|
+
return {
|
|
2920
|
+
opacity: "1",
|
|
2921
|
+
};
|
|
2922
|
+
}
|
|
2923
|
+
return {
|
|
2924
|
+
opacity: "0.8",
|
|
2925
|
+
};
|
|
2926
|
+
};
|
|
2927
|
+
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2928
|
+
return (jsxRuntime.jsxs(react.Table.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsxRuntime.jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow })), row.getVisibleCells().map((cell, index) => {
|
|
2929
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2930
|
+
// styling resize and pinning start
|
|
2931
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`,
|
|
2932
|
+
// this is to avoid the cell from being too wide
|
|
2933
|
+
minWidth: `0`, color: {
|
|
2934
|
+
base: "colorPalette.900",
|
|
2935
|
+
_dark: "colorPalette.100",
|
|
2936
|
+
},
|
|
2937
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2938
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
2939
|
+
}) }));
|
|
2940
|
+
};
|
|
2941
|
+
const TableRowSelector = ({ row, }) => {
|
|
2942
|
+
const { table } = useDataTableContext();
|
|
2943
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
2944
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
2945
|
+
base: "colorPalette.900",
|
|
2946
|
+
_dark: "colorPalette.100",
|
|
2947
|
+
},
|
|
2948
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
2949
|
+
disabled: !row.getCanSelect(),
|
|
2950
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
2951
|
+
};
|
|
2952
|
+
|
|
2953
|
+
const TableCardContainer = ({ children, variant = "", gap = "1rem", gridTemplateColumns = "repeat(auto-fit, minmax(20rem, 1fr))", direction = "row", ...props }) => {
|
|
2954
|
+
if (variant === "carousel") {
|
|
2955
|
+
return (jsxRuntime.jsx(react.Flex, { overflow: "auto", gap: gap, direction: direction, ...props, children: children }));
|
|
2956
|
+
}
|
|
2957
|
+
return (jsxRuntime.jsx(react.Grid, { gridTemplateColumns: gridTemplateColumns, gap: gap, ...props, children: children }));
|
|
2958
|
+
};
|
|
2959
|
+
|
|
2960
|
+
const DefaultCardTitle = () => {
|
|
2961
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2962
|
+
};
|
|
2963
|
+
const TableCards = ({ isSelectable = false, showDisplayNameOnly = false, renderTitle = DefaultCardTitle, cardBodyProps = {}, }) => {
|
|
2964
|
+
const { table } = useDataTableContext();
|
|
2965
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getRowModel().rows.map((row) => {
|
|
2966
|
+
return (jsxRuntime.jsx(react.Card.Root, { flex: "1 0 20rem", children: jsxRuntime.jsxs(react.Card.Body, { display: "flex", flexFlow: "column", gap: "0.5rem", ...cardBodyProps, children: [isSelectable && (jsxRuntime.jsx(Checkbox, { isChecked: row.getIsSelected(),
|
|
2967
|
+
disabled: !row.getCanSelect(),
|
|
2968
|
+
// indeterminate: row.getIsSomeSelected(),
|
|
2969
|
+
onChange: row.getToggleSelectedHandler() })), renderTitle(row), jsxRuntime.jsx(react.Grid, { templateColumns: "auto 1fr", gap: "1rem", children: row.getVisibleCells().map((cell) => {
|
|
2970
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(react.Box, { children: [showDisplayNameOnly && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", children: cell.column.columnDef.meta?.displayName ??
|
|
2971
|
+
cell.column.id })), !showDisplayNameOnly && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.header,
|
|
2972
|
+
// @ts-expect-error Assuming the CellContext interface is the same as HeaderContext
|
|
2973
|
+
cell.getContext()) }))] }, `chakra-table-cardcolumnid-${row.id}`), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-cardcolumn-${row.id}`)] }));
|
|
2974
|
+
}) })] }) }, `chakra-table-card-${row.id}`));
|
|
2975
|
+
}) }));
|
|
2976
|
+
};
|
|
2977
|
+
|
|
2978
|
+
const TableComponent = ({ render = () => {
|
|
2979
|
+
throw Error("Not Implemented");
|
|
2980
|
+
}, }) => {
|
|
2981
|
+
const { table } = useDataTableContext();
|
|
2982
|
+
return render(table);
|
|
2983
|
+
};
|
|
2984
|
+
|
|
2985
|
+
const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
2986
|
+
const table = useDataTableContext().table;
|
|
2987
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
2988
|
+
const [hoveredCheckBox, setHoveredCheckBox] = React.useState(false);
|
|
2989
|
+
const handleRowHover = (isHovered) => {
|
|
2990
|
+
setHoveredCheckBox(isHovered);
|
|
2991
|
+
};
|
|
2992
|
+
const isCheckBoxVisible = () => {
|
|
2993
|
+
if (alwaysShowSelector) {
|
|
2994
|
+
return true;
|
|
2995
|
+
}
|
|
2996
|
+
if (table.getIsAllRowsSelected()) {
|
|
2997
|
+
return true;
|
|
2998
|
+
}
|
|
2999
|
+
if (hoveredCheckBox) {
|
|
3000
|
+
return true;
|
|
3001
|
+
}
|
|
3002
|
+
return false;
|
|
3003
|
+
};
|
|
3004
|
+
return (jsxRuntime.jsx(react.Table.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", children: [showSelector && (jsxRuntime.jsxs(react.Table.Header, { padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
3005
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3006
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), footerGroup.headers.map((header) => (jsxRuntime.jsx(react.Table.Cell, { padding: "0", columnSpan: `${header.colSpan}`,
|
|
3007
|
+
// styling resize and pinning start
|
|
3008
|
+
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", children: jsxRuntime.jsx(react.MenuRoot, { children: jsxRuntime.jsx(react.MenuTrigger, { asChild: true, children: jsxRuntime.jsx(react.Box, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", children: jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3009
|
+
? null
|
|
3010
|
+
: reactTable.flexRender(header.column.columnDef.footer, header.getContext()), jsxRuntime.jsx(react.Box, { children: header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [header.column.getIsSorted() === false && jsxRuntime.jsx(jsxRuntime.Fragment, {}), header.column.getIsSorted() === "asc" && (jsxRuntime.jsx(bi.BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsxRuntime.jsx(bi.BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3011
|
+
};
|
|
3012
|
+
|
|
3013
|
+
// Default text values
|
|
3014
|
+
const DEFAULT_HEADER_TEXTS = {
|
|
3015
|
+
pinColumn: "Pin Column",
|
|
3016
|
+
cancelPin: "Cancel Pin",
|
|
3017
|
+
sortAscending: "Sort Ascending",
|
|
3018
|
+
sortDescending: "Sort Descending",
|
|
3019
|
+
clearSorting: "Clear Sorting",
|
|
2834
3020
|
};
|
|
2835
3021
|
/**
|
|
2836
|
-
*
|
|
2837
|
-
* help the render of the DataTable in serverside
|
|
3022
|
+
* TableHeader component with configurable text strings.
|
|
2838
3023
|
*
|
|
3024
|
+
* @example
|
|
3025
|
+
* // Using default texts
|
|
3026
|
+
* <TableHeader />
|
|
2839
3027
|
*
|
|
2840
|
-
*
|
|
2841
|
-
*
|
|
3028
|
+
* @example
|
|
3029
|
+
* // Customizing default texts for all columns
|
|
3030
|
+
* <TableHeader
|
|
3031
|
+
* defaultTexts={{
|
|
3032
|
+
* pinColumn: "Pin This Column",
|
|
3033
|
+
* sortAscending: "Sort A-Z"
|
|
3034
|
+
* }}
|
|
3035
|
+
* />
|
|
2842
3036
|
*
|
|
2843
|
-
* @
|
|
3037
|
+
* @example
|
|
3038
|
+
* // Customizing texts per column via meta
|
|
3039
|
+
* const columns = [
|
|
3040
|
+
* columnHelper.accessor("name", {
|
|
3041
|
+
* header: "Name",
|
|
3042
|
+
* meta: {
|
|
3043
|
+
* headerTexts: {
|
|
3044
|
+
* pinColumn: "Pin Name Column",
|
|
3045
|
+
* sortAscending: "Sort Names A-Z"
|
|
3046
|
+
* }
|
|
3047
|
+
* }
|
|
3048
|
+
* })
|
|
3049
|
+
* ];
|
|
2844
3050
|
*/
|
|
2845
|
-
|
|
2846
|
-
view: 'View',
|
|
2847
|
-
edit: 'Edit',
|
|
2848
|
-
filterButtonText: 'Filter',
|
|
2849
|
-
filterTitle: 'Filter',
|
|
2850
|
-
filterReset: 'Reset',
|
|
2851
|
-
filterClose: 'Close',
|
|
2852
|
-
reloadTooltip: 'Reload',
|
|
2853
|
-
reloadButtonText: 'Reload',
|
|
2854
|
-
resetSelection: 'Reset Selection',
|
|
2855
|
-
resetSorting: 'Reset Sorting',
|
|
2856
|
-
rowCountText: 'Row Count',
|
|
2857
|
-
hasErrorText: 'Has Error',
|
|
2858
|
-
globalFilterPlaceholder: 'Search',
|
|
2859
|
-
trueLabel: 'True',
|
|
2860
|
-
falseLabel: 'False',
|
|
2861
|
-
}, }) {
|
|
2862
|
-
const table = reactTable.useReactTable({
|
|
2863
|
-
_features: [DensityFeature],
|
|
2864
|
-
data: data,
|
|
2865
|
-
rowCount: data.length,
|
|
2866
|
-
columns: columns,
|
|
2867
|
-
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
2868
|
-
getFilteredRowModel: reactTable.getFilteredRowModel(),
|
|
2869
|
-
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
2870
|
-
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
2871
|
-
defaultColumn: {
|
|
2872
|
-
size: 150, //starting column size
|
|
2873
|
-
minSize: 10, //enforced during column resizing
|
|
2874
|
-
maxSize: 10000, //enforced during column resizing
|
|
2875
|
-
},
|
|
2876
|
-
enableRowSelection: enableRowSelection,
|
|
2877
|
-
enableMultiRowSelection: enableMultiRowSelection,
|
|
2878
|
-
enableSubRowSelection: enableSubRowSelection,
|
|
2879
|
-
columnResizeMode: 'onChange',
|
|
2880
|
-
// global filter start
|
|
2881
|
-
filterFns: {
|
|
2882
|
-
fuzzy: fuzzyFilter,
|
|
2883
|
-
},
|
|
2884
|
-
globalFilterFn: 'fuzzy',
|
|
2885
|
-
state: {
|
|
2886
|
-
pagination,
|
|
2887
|
-
sorting,
|
|
2888
|
-
columnFilters,
|
|
2889
|
-
rowSelection,
|
|
2890
|
-
columnOrder,
|
|
2891
|
-
globalFilter,
|
|
2892
|
-
density,
|
|
2893
|
-
columnVisibility,
|
|
2894
|
-
},
|
|
2895
|
-
onPaginationChange: setPagination,
|
|
2896
|
-
onSortingChange: setSorting,
|
|
2897
|
-
onColumnFiltersChange: setColumnFilters,
|
|
2898
|
-
onRowSelectionChange: setRowSelection,
|
|
2899
|
-
onColumnOrderChange: (state) => {
|
|
2900
|
-
setColumnOrder(state);
|
|
2901
|
-
},
|
|
2902
|
-
onGlobalFilterChange: (state) => {
|
|
2903
|
-
setGlobalFilter(state);
|
|
2904
|
-
},
|
|
2905
|
-
onDensityChange: setDensity,
|
|
2906
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
2907
|
-
});
|
|
2908
|
-
return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
|
|
2909
|
-
table: table,
|
|
2910
|
-
globalFilter,
|
|
2911
|
-
setGlobalFilter,
|
|
2912
|
-
type: 'client',
|
|
2913
|
-
translate,
|
|
2914
|
-
columns: columns,
|
|
2915
|
-
sorting,
|
|
2916
|
-
setSorting,
|
|
2917
|
-
columnFilters,
|
|
2918
|
-
setColumnFilters,
|
|
2919
|
-
pagination,
|
|
2920
|
-
setPagination,
|
|
2921
|
-
rowSelection,
|
|
2922
|
-
setRowSelection,
|
|
2923
|
-
columnOrder,
|
|
2924
|
-
setColumnOrder,
|
|
2925
|
-
density,
|
|
2926
|
-
setDensity,
|
|
2927
|
-
columnVisibility,
|
|
2928
|
-
setColumnVisibility,
|
|
2929
|
-
data,
|
|
2930
|
-
tableLabel,
|
|
2931
|
-
}, children: children }));
|
|
2932
|
-
}
|
|
2933
|
-
|
|
2934
|
-
/**
|
|
2935
|
-
* DataTableServer will create a context to hold all values to
|
|
2936
|
-
* help the render of the DataTable in serverside
|
|
2937
|
-
*
|
|
2938
|
-
* The query is required to be a GET request that can receive
|
|
2939
|
-
* specified params and return a specified response
|
|
2940
|
-
*
|
|
2941
|
-
* The `useDataTableServer` can help to create the specified request and response
|
|
2942
|
-
*
|
|
2943
|
-
* @link https://tanstack.com/table/latest/docs/guide/column-defs
|
|
2944
|
-
*/
|
|
2945
|
-
function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, query, url, translate, children, tableLabel = {
|
|
2946
|
-
view: "View",
|
|
2947
|
-
edit: "Edit",
|
|
2948
|
-
filterButtonText: "Filter",
|
|
2949
|
-
filterTitle: "Filter",
|
|
2950
|
-
filterReset: "Reset",
|
|
2951
|
-
filterClose: "Close",
|
|
2952
|
-
reloadTooltip: "Reload",
|
|
2953
|
-
reloadButtonText: "Reload",
|
|
2954
|
-
resetSelection: "Reset Selection",
|
|
2955
|
-
resetSorting: "Reset Sorting",
|
|
2956
|
-
rowCountText: "Row Count",
|
|
2957
|
-
hasErrorText: "Has Error",
|
|
2958
|
-
globalFilterPlaceholder: "Search",
|
|
2959
|
-
trueLabel: "True",
|
|
2960
|
-
falseLabel: "False",
|
|
2961
|
-
}, }) {
|
|
2962
|
-
const table = reactTable.useReactTable({
|
|
2963
|
-
_features: [DensityFeature],
|
|
2964
|
-
data: (query.data?.data ?? []),
|
|
2965
|
-
rowCount: query.data?.count ?? 0,
|
|
2966
|
-
columns: columns,
|
|
2967
|
-
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
2968
|
-
manualPagination: true,
|
|
2969
|
-
manualSorting: true,
|
|
2970
|
-
columnResizeMode: "onChange",
|
|
2971
|
-
defaultColumn: {
|
|
2972
|
-
size: 150, //starting column size
|
|
2973
|
-
minSize: 10, //enforced during column resizing
|
|
2974
|
-
maxSize: 10000, //enforced during column resizing
|
|
2975
|
-
},
|
|
2976
|
-
enableRowSelection: enableRowSelection,
|
|
2977
|
-
enableMultiRowSelection: enableMultiRowSelection,
|
|
2978
|
-
enableSubRowSelection: enableSubRowSelection,
|
|
2979
|
-
state: {
|
|
2980
|
-
pagination,
|
|
2981
|
-
sorting,
|
|
2982
|
-
columnFilters,
|
|
2983
|
-
rowSelection,
|
|
2984
|
-
columnOrder,
|
|
2985
|
-
globalFilter,
|
|
2986
|
-
density,
|
|
2987
|
-
columnVisibility,
|
|
2988
|
-
},
|
|
2989
|
-
onPaginationChange: setPagination,
|
|
2990
|
-
onSortingChange: setSorting,
|
|
2991
|
-
onColumnFiltersChange: setColumnFilters,
|
|
2992
|
-
onRowSelectionChange: setRowSelection,
|
|
2993
|
-
onColumnOrderChange: (state) => {
|
|
2994
|
-
setColumnOrder(state);
|
|
2995
|
-
},
|
|
2996
|
-
onGlobalFilterChange: (state) => {
|
|
2997
|
-
setGlobalFilter(state);
|
|
2998
|
-
},
|
|
2999
|
-
onDensityChange: setDensity,
|
|
3000
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
3001
|
-
// for tanstack-table ts bug start
|
|
3002
|
-
filterFns: {
|
|
3003
|
-
fuzzy: () => {
|
|
3004
|
-
return false;
|
|
3005
|
-
},
|
|
3006
|
-
},
|
|
3007
|
-
// for tanstack-table ts bug end
|
|
3008
|
-
});
|
|
3009
|
-
return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
|
|
3010
|
-
table: table,
|
|
3011
|
-
globalFilter,
|
|
3012
|
-
setGlobalFilter,
|
|
3013
|
-
type: "server",
|
|
3014
|
-
translate,
|
|
3015
|
-
columns: columns,
|
|
3016
|
-
sorting,
|
|
3017
|
-
setSorting,
|
|
3018
|
-
columnFilters,
|
|
3019
|
-
setColumnFilters,
|
|
3020
|
-
pagination,
|
|
3021
|
-
setPagination,
|
|
3022
|
-
rowSelection,
|
|
3023
|
-
setRowSelection,
|
|
3024
|
-
columnOrder,
|
|
3025
|
-
setColumnOrder,
|
|
3026
|
-
density,
|
|
3027
|
-
setDensity,
|
|
3028
|
-
columnVisibility,
|
|
3029
|
-
setColumnVisibility,
|
|
3030
|
-
data: query.data?.data ?? [],
|
|
3031
|
-
tableLabel,
|
|
3032
|
-
}, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
3033
|
-
}
|
|
3034
|
-
|
|
3035
|
-
const InputGroup = React__namespace.forwardRef(function InputGroup(props, ref) {
|
|
3036
|
-
const { startElement, startElementProps, endElement, endElementProps, children, startOffset = "6px", endOffset = "6px", ...rest } = props;
|
|
3037
|
-
return (jsxRuntime.jsxs(react.Group, { ref: ref, ...rest, children: [startElement && (jsxRuntime.jsx(react.InputElement, { pointerEvents: "none", ...startElementProps, children: startElement })), React__namespace.cloneElement(children, {
|
|
3038
|
-
...(startElement && {
|
|
3039
|
-
ps: `calc(var(--input-height) - ${startOffset})`,
|
|
3040
|
-
}),
|
|
3041
|
-
...(endElement && { pe: `calc(var(--input-height) - ${endOffset})` }),
|
|
3042
|
-
// @ts-expect-error chakra generated files
|
|
3043
|
-
...children.props,
|
|
3044
|
-
}), endElement && (jsxRuntime.jsx(react.InputElement, { placement: "end", ...endElementProps, children: endElement }))] }));
|
|
3045
|
-
});
|
|
3046
|
-
|
|
3047
|
-
const GlobalFilter = () => {
|
|
3048
|
-
const { table, tableLabel } = useDataTableContext();
|
|
3049
|
-
const { globalFilterPlaceholder } = tableLabel;
|
|
3050
|
-
const [searchTerm, setSearchTerm] = React.useState("");
|
|
3051
|
-
const debouncedSearchTerm = usehooks.useDebounce(searchTerm, 500);
|
|
3052
|
-
React.useEffect(() => {
|
|
3053
|
-
const searchHN = async () => {
|
|
3054
|
-
table.setGlobalFilter(debouncedSearchTerm);
|
|
3055
|
-
};
|
|
3056
|
-
searchHN();
|
|
3057
|
-
}, [debouncedSearchTerm]);
|
|
3058
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(InputGroup, { flex: "1", startElement: jsxRuntime.jsx(md.MdSearch, {}), children: jsxRuntime.jsx(react.Input, { placeholder: globalFilterPlaceholder, variant: "outline", onChange: (e) => {
|
|
3059
|
-
setSearchTerm(e.target.value);
|
|
3060
|
-
} }) }) }));
|
|
3061
|
-
};
|
|
3062
|
-
|
|
3063
|
-
const Tooltip = React__namespace.forwardRef(function Tooltip(props, ref) {
|
|
3064
|
-
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
3065
|
-
if (disabled)
|
|
3066
|
-
return children;
|
|
3067
|
-
return (jsxRuntime.jsxs(react.Tooltip.Root, { ...rest, children: [jsxRuntime.jsx(react.Tooltip.Trigger, { asChild: true, children: children }), jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Tooltip.Positioner, { children: jsxRuntime.jsxs(react.Tooltip.Content, { ref: ref, ...contentProps, children: [showArrow && (jsxRuntime.jsx(react.Tooltip.Arrow, { children: jsxRuntime.jsx(react.Tooltip.ArrowTip, {}) })), content] }) }) })] }));
|
|
3068
|
-
});
|
|
3069
|
-
|
|
3070
|
-
const ReloadButton = ({ variant = "icon", }) => {
|
|
3071
|
-
const { url } = useDataTableServerContext();
|
|
3072
|
-
const queryClient = reactQuery.useQueryClient();
|
|
3073
|
-
const { tableLabel } = useDataTableContext();
|
|
3074
|
-
const { reloadTooltip, reloadButtonText } = tableLabel;
|
|
3075
|
-
if (variant === "icon") {
|
|
3076
|
-
return (jsxRuntime.jsx(Tooltip, { showArrow: true, content: reloadTooltip, children: jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => {
|
|
3077
|
-
queryClient.invalidateQueries({ queryKey: [url] });
|
|
3078
|
-
}, "aria-label": "refresh", children: jsxRuntime.jsx(io5.IoReload, {}) }) }));
|
|
3079
|
-
}
|
|
3080
|
-
return (jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3081
|
-
queryClient.invalidateQueries({ queryKey: [url] });
|
|
3082
|
-
}, children: [jsxRuntime.jsx(io5.IoReload, {}), " ", reloadButtonText] }));
|
|
3083
|
-
};
|
|
3084
|
-
|
|
3085
|
-
const TableFilterTags = () => {
|
|
3086
|
-
const { table } = useDataTableContext();
|
|
3087
|
-
return (jsxRuntime.jsx(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }) => {
|
|
3088
|
-
return (jsxRuntime.jsx(Tag, { gap: "0.5rem", closable: true, cursor: "pointer", onClick: () => {
|
|
3089
|
-
table.setColumnFilters(table.getState().columnFilters.filter((filter) => {
|
|
3090
|
-
return filter.value != value;
|
|
3091
|
-
}));
|
|
3092
|
-
}, children: `${id}: ${value}` }, `${id}-${value}`));
|
|
3093
|
-
}) }));
|
|
3094
|
-
};
|
|
3095
|
-
|
|
3096
|
-
const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children = jsxRuntime.jsx(jsxRuntime.Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, showPagination = true, showPageSizeControl = true, showPageCountText = true, showView = true, filterTagsOptions = [], extraItems = jsxRuntime.jsx(jsxRuntime.Fragment, {}), loading = false, hasError = false, gridProps = {}, }) => {
|
|
3097
|
-
const { tableLabel, table } = useDataTableContext();
|
|
3098
|
-
const { rowCountText, hasErrorText } = tableLabel;
|
|
3099
|
-
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", ...gridProps, children: [jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsx(react.Box, { children: showView && jsxRuntime.jsx(ViewDialog, { icon: jsxRuntime.jsx(md.MdOutlineViewColumn, {}) }) }), jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsxRuntime.jsx(react.Spinner, { size: "sm" }), hasError && (jsxRuntime.jsx(Tooltip, { content: hasErrorText, children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsxRuntime.jsx(GlobalFilter, {}), showFilter && jsxRuntime.jsx(FilterDialog, {}), showReload && jsxRuntime.jsx(ReloadButton, {}), extraItems] })] }), filterTagsOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterTagsOptions.map((option) => {
|
|
3100
|
-
const { column, options } = option;
|
|
3101
|
-
const tableColumn = table.getColumn(column);
|
|
3102
|
-
return (jsxRuntime.jsxs(react.Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [tableColumn?.columnDef.meta?.displayName && (jsxRuntime.jsx(react.Text, { children: tableColumn?.columnDef.meta?.displayName })), jsxRuntime.jsx(TagFilter, { availableTags: options, selectedTags: tableColumn?.getFilterValue() ?? [], selectOne: true, onTagChange: (tags) => {
|
|
3103
|
-
if (tags.length === 0) {
|
|
3104
|
-
return tableColumn?.setFilterValue(undefined);
|
|
3105
|
-
}
|
|
3106
|
-
tableColumn?.setFilterValue(tags);
|
|
3107
|
-
} })] }, column));
|
|
3108
|
-
}) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Grid, { overflow: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, children: children }), (showPageSizeControl || showPageCountText || showPagination) && (jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsxs(react.Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsxRuntime.jsx(PageSizeControl, {}), showPageCountText && (jsxRuntime.jsxs(react.Flex, { children: [jsxRuntime.jsx(react.Text, { paddingRight: "0.5rem", children: rowCountText }), jsxRuntime.jsx(RowCountText, {})] }))] }), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: showPagination && jsxRuntime.jsx(Pagination, {}) })] }))] }));
|
|
3109
|
-
};
|
|
3110
|
-
|
|
3111
|
-
const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
3112
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3113
|
-
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
3114
|
-
});
|
|
3115
|
-
|
|
3116
|
-
const EmptyResult = (jsxRuntime.jsx(EmptyState, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
3117
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, showLoading = false, ...props }) => {
|
|
3118
|
-
const { table } = useDataTableContext();
|
|
3119
|
-
// Skip empty check when loading to allow skeleton to render
|
|
3120
|
-
if (!showLoading && table.getRowModel().rows.length <= 0) {
|
|
3121
|
-
return emptyComponent;
|
|
3122
|
-
}
|
|
3123
|
-
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: 'outline', width: canResize ? table.getCenterTotalSize() : undefined, display: 'grid', alignContent: 'start', overflowY: 'auto', bg: { base: 'colorPalette.50', _dark: 'colorPalette.950' }, ...props, children: children }));
|
|
3124
|
-
};
|
|
3125
|
-
|
|
3126
|
-
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
3127
|
-
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3128
|
-
return (jsxRuntime.jsxs(react.Checkbox.Root, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.Checkbox.HiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.Checkbox.Control, { children: icon || jsxRuntime.jsx(react.Checkbox.Indicator, {}) }), children != null && (jsxRuntime.jsx(react.Checkbox.Label, { children: children }))] }));
|
|
3129
|
-
});
|
|
3130
|
-
|
|
3131
|
-
const TableBody = ({ showSelector = false, canResize = true, }) => {
|
|
3132
|
-
"use no memo";
|
|
3051
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, defaultTexts = {}, }) => {
|
|
3133
3052
|
const { table } = useDataTableContext();
|
|
3134
3053
|
const SELECTION_BOX_WIDTH = 20;
|
|
3135
|
-
|
|
3136
|
-
const
|
|
3137
|
-
|
|
3054
|
+
// Merge default texts with provided defaults
|
|
3055
|
+
const mergedDefaultTexts = { ...DEFAULT_HEADER_TEXTS, ...defaultTexts };
|
|
3056
|
+
// Helper function to get text for a specific header
|
|
3057
|
+
const getHeaderText = (header, key) => {
|
|
3058
|
+
const columnMeta = header.column.columnDef.meta;
|
|
3059
|
+
return columnMeta?.headerTexts?.[key] || mergedDefaultTexts[key];
|
|
3138
3060
|
};
|
|
3139
|
-
const
|
|
3140
|
-
const
|
|
3061
|
+
const getThProps = (header) => {
|
|
3062
|
+
const thProps = header.column.getIsPinned()
|
|
3141
3063
|
? {
|
|
3142
3064
|
left: showSelector
|
|
3143
|
-
? `${
|
|
3144
|
-
: `${
|
|
3145
|
-
position: "
|
|
3065
|
+
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3066
|
+
: `${header.getStart("left")}px`,
|
|
3067
|
+
position: "sticky",
|
|
3068
|
+
zIndex: 100 + 1,
|
|
3146
3069
|
}
|
|
3147
3070
|
: {};
|
|
3148
|
-
return
|
|
3149
|
-
};
|
|
3150
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3151
|
-
if (hoveredRow === -1) {
|
|
3152
|
-
return {};
|
|
3153
|
-
}
|
|
3154
|
-
if (hoveredRow === index) {
|
|
3155
|
-
return {
|
|
3156
|
-
opacity: "1",
|
|
3157
|
-
};
|
|
3158
|
-
}
|
|
3159
|
-
return {
|
|
3160
|
-
opacity: "0.8",
|
|
3161
|
-
};
|
|
3162
|
-
};
|
|
3163
|
-
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3164
|
-
return (jsxRuntime.jsxs(react.Table.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsxRuntime.jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow })), row.getVisibleCells().map((cell, index) => {
|
|
3165
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3166
|
-
// styling resize and pinning start
|
|
3167
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`,
|
|
3168
|
-
// this is to avoid the cell from being too wide
|
|
3169
|
-
minWidth: `0`, color: {
|
|
3170
|
-
base: "colorPalette.900",
|
|
3171
|
-
_dark: "colorPalette.100",
|
|
3172
|
-
},
|
|
3173
|
-
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3174
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
3175
|
-
}) }));
|
|
3176
|
-
};
|
|
3177
|
-
const TableRowSelector = ({ row, }) => {
|
|
3178
|
-
const { table } = useDataTableContext();
|
|
3179
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
3180
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3181
|
-
base: "colorPalette.900",
|
|
3182
|
-
_dark: "colorPalette.100",
|
|
3183
|
-
},
|
|
3184
|
-
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
3185
|
-
disabled: !row.getCanSelect(),
|
|
3186
|
-
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3187
|
-
};
|
|
3188
|
-
|
|
3189
|
-
const TableBodySkeleton = ({ showSelector = false, canResize = true, }) => {
|
|
3190
|
-
'use no memo';
|
|
3191
|
-
const { table } = useDataTableContext();
|
|
3192
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
3193
|
-
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
3194
|
-
const handleRowHover = (index) => {
|
|
3195
|
-
setHoveredRow(index);
|
|
3196
|
-
};
|
|
3197
|
-
const getTdProps = (column) => {
|
|
3198
|
-
const tdProps = column.getIsPinned()
|
|
3199
|
-
? {
|
|
3200
|
-
left: showSelector
|
|
3201
|
-
? `${column.getStart('left') + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3202
|
-
: `${column.getStart('left')}px`,
|
|
3203
|
-
position: 'relative',
|
|
3204
|
-
}
|
|
3205
|
-
: {};
|
|
3206
|
-
return tdProps;
|
|
3207
|
-
};
|
|
3208
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3209
|
-
if (hoveredRow === -1) {
|
|
3210
|
-
return {};
|
|
3211
|
-
}
|
|
3212
|
-
if (hoveredRow === index) {
|
|
3213
|
-
return {
|
|
3214
|
-
opacity: '1',
|
|
3215
|
-
};
|
|
3216
|
-
}
|
|
3217
|
-
return {
|
|
3218
|
-
opacity: '0.8',
|
|
3219
|
-
};
|
|
3220
|
-
};
|
|
3221
|
-
// Get the number of skeleton rows based on current pageSize
|
|
3222
|
-
const pageSize = table.getState().pagination.pageSize;
|
|
3223
|
-
const visibleColumns = table.getVisibleLeafColumns();
|
|
3224
|
-
return (jsxRuntime.jsx(react.Table.Body, { children: Array.from({ length: pageSize }).map((_, rowIndex) => {
|
|
3225
|
-
return (jsxRuntime.jsxs(react.Table.Row, { display: 'flex', zIndex: 1, onMouseEnter: () => handleRowHover(rowIndex), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index: rowIndex }), children: [showSelector && jsxRuntime.jsx(TableRowSelectorSkeleton, {}), visibleColumns.map((column, colIndex) => {
|
|
3226
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3227
|
-
// styling resize and pinning start
|
|
3228
|
-
flex: `${canResize ? '0' : '1'} 0 ${column.getSize()}px`,
|
|
3229
|
-
// this is to avoid the cell from being too wide
|
|
3230
|
-
minWidth: `0`, color: {
|
|
3231
|
-
base: 'colorPalette.900',
|
|
3232
|
-
_dark: 'colorPalette.100',
|
|
3233
|
-
},
|
|
3234
|
-
bg: { base: 'colorPalette.50', _dark: 'colorPalette.950' }, ...getTdProps(column), children: jsxRuntime.jsx(react.Skeleton, { height: "20px", width: "80%" }) }, `chakra-table-skeleton-cell-${rowIndex}-${colIndex}`));
|
|
3235
|
-
})] }, `chakra-table-skeleton-row-${rowIndex}`));
|
|
3236
|
-
}) }));
|
|
3237
|
-
};
|
|
3238
|
-
const TableRowSelectorSkeleton = () => {
|
|
3239
|
-
const { table } = useDataTableContext();
|
|
3240
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
3241
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: 'grid', color: {
|
|
3242
|
-
base: 'colorPalette.900',
|
|
3243
|
-
_dark: 'colorPalette.100',
|
|
3244
|
-
},
|
|
3245
|
-
bg: { base: 'colorPalette.50', _dark: 'colorPalette.950' }, justifyItems: 'center', alignItems: 'center', children: jsxRuntime.jsx(react.Skeleton, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }) }));
|
|
3246
|
-
};
|
|
3247
|
-
|
|
3248
|
-
const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
3249
|
-
const table = useDataTableContext().table;
|
|
3250
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
3251
|
-
const [hoveredCheckBox, setHoveredCheckBox] = React.useState(false);
|
|
3252
|
-
const handleRowHover = (isHovered) => {
|
|
3253
|
-
setHoveredCheckBox(isHovered);
|
|
3254
|
-
};
|
|
3255
|
-
const isCheckBoxVisible = () => {
|
|
3256
|
-
if (alwaysShowSelector) {
|
|
3257
|
-
return true;
|
|
3258
|
-
}
|
|
3259
|
-
if (table.getIsAllRowsSelected()) {
|
|
3260
|
-
return true;
|
|
3261
|
-
}
|
|
3262
|
-
if (hoveredCheckBox) {
|
|
3263
|
-
return true;
|
|
3264
|
-
}
|
|
3265
|
-
return false;
|
|
3266
|
-
};
|
|
3267
|
-
return (jsxRuntime.jsx(react.Table.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", children: [showSelector && (jsxRuntime.jsxs(react.Table.Header, { padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
3268
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3269
|
-
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), footerGroup.headers.map((header) => (jsxRuntime.jsx(react.Table.Cell, { padding: "0", columnSpan: `${header.colSpan}`,
|
|
3270
|
-
// styling resize and pinning start
|
|
3271
|
-
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", children: jsxRuntime.jsx(react.MenuRoot, { children: jsxRuntime.jsx(react.MenuTrigger, { asChild: true, children: jsxRuntime.jsx(react.Box, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", children: jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3272
|
-
? null
|
|
3273
|
-
: reactTable.flexRender(header.column.columnDef.footer, header.getContext()), jsxRuntime.jsx(react.Box, { children: header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [header.column.getIsSorted() === false && jsxRuntime.jsx(jsxRuntime.Fragment, {}), header.column.getIsSorted() === "asc" && (jsxRuntime.jsx(bi.BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsxRuntime.jsx(bi.BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3274
|
-
};
|
|
3275
|
-
|
|
3276
|
-
// Default text values
|
|
3277
|
-
const DEFAULT_HEADER_TEXTS = {
|
|
3278
|
-
pinColumn: "Pin Column",
|
|
3279
|
-
cancelPin: "Cancel Pin",
|
|
3280
|
-
sortAscending: "Sort Ascending",
|
|
3281
|
-
sortDescending: "Sort Descending",
|
|
3282
|
-
clearSorting: "Clear Sorting",
|
|
3283
|
-
};
|
|
3284
|
-
/**
|
|
3285
|
-
* TableHeader component with configurable text strings.
|
|
3286
|
-
*
|
|
3287
|
-
* @example
|
|
3288
|
-
* // Using default texts
|
|
3289
|
-
* <TableHeader />
|
|
3290
|
-
*
|
|
3291
|
-
* @example
|
|
3292
|
-
* // Customizing default texts for all columns
|
|
3293
|
-
* <TableHeader
|
|
3294
|
-
* defaultTexts={{
|
|
3295
|
-
* pinColumn: "Pin This Column",
|
|
3296
|
-
* sortAscending: "Sort A-Z"
|
|
3297
|
-
* }}
|
|
3298
|
-
* />
|
|
3299
|
-
*
|
|
3300
|
-
* @example
|
|
3301
|
-
* // Customizing texts per column via meta
|
|
3302
|
-
* const columns = [
|
|
3303
|
-
* columnHelper.accessor("name", {
|
|
3304
|
-
* header: "Name",
|
|
3305
|
-
* meta: {
|
|
3306
|
-
* headerTexts: {
|
|
3307
|
-
* pinColumn: "Pin Name Column",
|
|
3308
|
-
* sortAscending: "Sort Names A-Z"
|
|
3309
|
-
* }
|
|
3310
|
-
* }
|
|
3311
|
-
* })
|
|
3312
|
-
* ];
|
|
3313
|
-
*/
|
|
3314
|
-
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, defaultTexts = {}, }) => {
|
|
3315
|
-
const { table } = useDataTableContext();
|
|
3316
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
3317
|
-
// Merge default texts with provided defaults
|
|
3318
|
-
const mergedDefaultTexts = { ...DEFAULT_HEADER_TEXTS, ...defaultTexts };
|
|
3319
|
-
// Helper function to get text for a specific header
|
|
3320
|
-
const getHeaderText = (header, key) => {
|
|
3321
|
-
const columnMeta = header.column.columnDef.meta;
|
|
3322
|
-
return columnMeta?.headerTexts?.[key] || mergedDefaultTexts[key];
|
|
3323
|
-
};
|
|
3324
|
-
const getThProps = (header) => {
|
|
3325
|
-
const thProps = header.column.getIsPinned()
|
|
3326
|
-
? {
|
|
3327
|
-
left: showSelector
|
|
3328
|
-
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3329
|
-
: `${header.getStart("left")}px`,
|
|
3330
|
-
position: "sticky",
|
|
3331
|
-
zIndex: 100 + 1,
|
|
3332
|
-
}
|
|
3333
|
-
: {};
|
|
3334
|
-
return thProps;
|
|
3071
|
+
return thProps;
|
|
3335
3072
|
};
|
|
3336
3073
|
const stickyProps = {
|
|
3337
3074
|
position: "sticky",
|
|
@@ -3406,94 +3143,35 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
|
|
|
3406
3143
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3407
3144
|
};
|
|
3408
3145
|
|
|
3409
|
-
const
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { canResize: false, showLoading: isLoading, ...tableProps, children: [jsxRuntime.jsx(TableHeader, { canResize: false, ...tableHeaderProps }), bodyComponent, showFooter && (jsxRuntime.jsx(TableFooter, { canResize: false, ...tableFooterProps }))] }) }));
|
|
3413
|
-
}
|
|
3414
|
-
const bodyComponent = isLoading ? (jsxRuntime.jsx(TableBodySkeleton, { showSelector: tableBodyProps.showSelector, canResize: tableBodyProps.canResize })) : (jsxRuntime.jsx(TableBody, { ...tableBodyProps }));
|
|
3415
|
-
return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { showLoading: isLoading, ...tableProps, children: [jsxRuntime.jsx(TableHeader, { ...tableHeaderProps }), bodyComponent, showFooter && jsxRuntime.jsx(TableFooter, { ...tableFooterProps })] }) }));
|
|
3416
|
-
};
|
|
3417
|
-
|
|
3418
|
-
/**
|
|
3419
|
-
* DefaultTableServer is a wrapper around DefaultTable that automatically
|
|
3420
|
-
* detects server-side loading state from DataTableServerContext.
|
|
3421
|
-
*
|
|
3422
|
-
* Use this component when working with DataTableServer to automatically
|
|
3423
|
-
* show skeleton loading state during data fetching.
|
|
3424
|
-
*
|
|
3425
|
-
* @example
|
|
3426
|
-
* ```tsx
|
|
3427
|
-
* <DataTableServer columns={columns} {...datatableServer}>
|
|
3428
|
-
* <DefaultTableServer />
|
|
3429
|
-
* </DataTableServer>
|
|
3430
|
-
* ```
|
|
3431
|
-
*/
|
|
3432
|
-
const DefaultTableServer = ({ isLoading: isLoadingOverride, ...props }) => {
|
|
3433
|
-
// Automatically detect loading state from server context
|
|
3434
|
-
const serverContext = useDataTableServerContext();
|
|
3435
|
-
const isLoading = isLoadingOverride ?? serverContext?.query?.isLoading ?? false;
|
|
3436
|
-
return jsxRuntime.jsx(DefaultTable, { ...props, isLoading: isLoading });
|
|
3146
|
+
const TableLoadingComponent = ({ render, }) => {
|
|
3147
|
+
const { query } = useDataTableServerContext();
|
|
3148
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: render(query.isLoading) });
|
|
3437
3149
|
};
|
|
3438
3150
|
|
|
3439
|
-
const
|
|
3440
|
-
if (
|
|
3441
|
-
return (jsxRuntime.jsx(react.Flex, { overflow: "
|
|
3151
|
+
const TextCell = ({ label, containerProps = {}, textProps = {}, children, }) => {
|
|
3152
|
+
if (label) {
|
|
3153
|
+
return (jsxRuntime.jsx(react.Flex, { alignItems: "center", height: "100%", ...containerProps, children: jsxRuntime.jsx(Tooltip, { content: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", children: label }), children: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", ...textProps, children: children }) }) }));
|
|
3442
3154
|
}
|
|
3443
|
-
return (jsxRuntime.jsx(react.
|
|
3155
|
+
return (jsxRuntime.jsx(react.Flex, { alignItems: "center", height: "100%", ...containerProps, children: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", ...textProps, children: children }) }));
|
|
3444
3156
|
};
|
|
3445
3157
|
|
|
3446
|
-
const
|
|
3447
|
-
|
|
3448
|
-
};
|
|
3449
|
-
|
|
3450
|
-
const
|
|
3451
|
-
return (jsxRuntime.jsx(jsxRuntime.
|
|
3452
|
-
return (jsxRuntime.jsx(react.Card.Root, { flex: "1 0 20rem", children: jsxRuntime.jsxs(react.Card.Body, { display: "flex", flexFlow: "column", gap: "0.5rem", ...cardBodyProps, children: [isSelectable && (jsxRuntime.jsx(Checkbox, { isChecked: row.getIsSelected(),
|
|
3453
|
-
disabled: !row.getCanSelect(),
|
|
3454
|
-
// indeterminate: row.getIsSomeSelected(),
|
|
3455
|
-
onChange: row.getToggleSelectedHandler() })), renderTitle(row), jsxRuntime.jsx(react.Grid, { templateColumns: "auto 1fr", gap: "1rem", children: row.getVisibleCells().map((cell) => {
|
|
3456
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(react.Box, { children: [showDisplayNameOnly && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", children: cell.column.columnDef.meta?.displayName ??
|
|
3457
|
-
cell.column.id })), !showDisplayNameOnly && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.header,
|
|
3458
|
-
// @ts-expect-error Assuming the CellContext interface is the same as HeaderContext
|
|
3459
|
-
cell.getContext()) }))] }, `chakra-table-cardcolumnid-${row.id}`), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-cardcolumn-${row.id}`)] }));
|
|
3460
|
-
}) })] }) }, `chakra-table-card-${row.id}`));
|
|
3461
|
-
}) }));
|
|
3158
|
+
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
3159
|
+
if (!!row.original === false) {
|
|
3160
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
3161
|
+
}
|
|
3162
|
+
const isShowFirstColumn = !!titleColumnId || showTag;
|
|
3163
|
+
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto auto", gap: "1rem", children: [!!imageColumnId && (jsxRuntime.jsx(react.Image, { width: "100%", src: row.original[imageColumnId], ...imageProps })), isShowFirstColumn && (jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: [!!titleColumnId && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] })), showTag && (jsxRuntime.jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] }))] }));
|
|
3462
3164
|
};
|
|
3463
3165
|
|
|
3464
|
-
const
|
|
3465
|
-
|
|
3466
|
-
}, })
|
|
3467
|
-
const { table } = useDataTableContext();
|
|
3468
|
-
return render(table);
|
|
3166
|
+
const EmptyState = ({ title = "No records", description = "Add a new events to get started or refine your search", }) => {
|
|
3167
|
+
const { isEmpty } = useDataTableServerContext();
|
|
3168
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isEmpty && (jsxRuntime.jsx(react.EmptyState.Root, { children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [jsxRuntime.jsx(react.EmptyState.Indicator, { children: jsxRuntime.jsx(hi.HiColorSwatch, {}) }), jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })] }) })) }));
|
|
3469
3169
|
};
|
|
3470
3170
|
|
|
3471
|
-
const
|
|
3171
|
+
const ErrorAlert = ({ showMessage = true }) => {
|
|
3472
3172
|
const { query } = useDataTableServerContext();
|
|
3473
|
-
|
|
3474
|
-
};
|
|
3475
|
-
|
|
3476
|
-
const SelectAllRowsToggle = ({ selectAllIcon = jsxRuntime.jsx(md.MdOutlineChecklist, {}), clearAllIcon = jsxRuntime.jsx(md.MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
3477
|
-
const { table } = useDataTableContext();
|
|
3478
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!selectAllText === false && (jsxRuntime.jsx(react.IconButton, { variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
3479
|
-
table.getToggleAllRowsSelectedHandler()(event);
|
|
3480
|
-
}, children: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon })), !!selectAllText !== false && (jsxRuntime.jsxs(react.Button, { variant: "ghost", onClick: (event) => {
|
|
3481
|
-
table.getToggleAllRowsSelectedHandler()(event);
|
|
3482
|
-
}, children: [table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, table.getIsAllRowsSelected() ? clearAllText : selectAllText] }))] }));
|
|
3483
|
-
};
|
|
3484
|
-
|
|
3485
|
-
const TableSelector = () => {
|
|
3486
|
-
const { table } = useDataTableContext();
|
|
3487
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [table.getSelectedRowModel().rows.length > 0 && (jsxRuntime.jsxs(react.Button, { onClick: () => { }, variant: "ghost", display: "flex", gap: "0.25rem", children: [jsxRuntime.jsx(react.Box, { fontSize: "sm", children: `${table.getSelectedRowModel().rows.length}` }), jsxRuntime.jsx(io.IoMdCheckbox, {})] })), !table.getIsAllPageRowsSelected() && jsxRuntime.jsx(SelectAllRowsToggle, {}), table.getSelectedRowModel().rows.length > 0 && (jsxRuntime.jsx(react.IconButton, { variant: "ghost", onClick: () => {
|
|
3488
|
-
table.resetRowSelection();
|
|
3489
|
-
}, "aria-label": "reset selection", children: jsxRuntime.jsx(md.MdClear, {}) }))] }));
|
|
3490
|
-
};
|
|
3491
|
-
|
|
3492
|
-
const TextCell = ({ label, containerProps = {}, textProps = {}, children, }) => {
|
|
3493
|
-
if (label) {
|
|
3494
|
-
return (jsxRuntime.jsx(react.Flex, { alignItems: "center", height: "100%", ...containerProps, children: jsxRuntime.jsx(Tooltip, { content: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", children: label }), children: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", ...textProps, children: children }) }) }));
|
|
3495
|
-
}
|
|
3496
|
-
return (jsxRuntime.jsx(react.Flex, { alignItems: "center", height: "100%", ...containerProps, children: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", ...textProps, children: children }) }));
|
|
3173
|
+
const { isError, error } = query;
|
|
3174
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isError && (jsxRuntime.jsxs(react.Alert.Root, { status: "error", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsxs(react.Alert.Content, { children: [jsxRuntime.jsx(react.Alert.Title, { children: error.name }), showMessage && (jsxRuntime.jsx(react.Alert.Description, { children: error.message }))] })] })) }));
|
|
3497
3175
|
};
|
|
3498
3176
|
|
|
3499
3177
|
const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: defaultPagination = {
|
|
@@ -3625,6 +3303,28 @@ const idListSanityCheck = (param, idList, properties) => {
|
|
|
3625
3303
|
}
|
|
3626
3304
|
};
|
|
3627
3305
|
|
|
3306
|
+
const snakeToLabel = (str) => {
|
|
3307
|
+
return str
|
|
3308
|
+
.split("_") // Split by underscore
|
|
3309
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize each word
|
|
3310
|
+
.join(" "); // Join with space
|
|
3311
|
+
};
|
|
3312
|
+
|
|
3313
|
+
const RecordDisplay = ({ object, boxProps, translate, prefix = "", }) => {
|
|
3314
|
+
const getColumn = ({ field }) => {
|
|
3315
|
+
if (translate !== undefined) {
|
|
3316
|
+
return translate.t(`${prefix}${field}`);
|
|
3317
|
+
}
|
|
3318
|
+
return snakeToLabel(field);
|
|
3319
|
+
};
|
|
3320
|
+
if (object === null) {
|
|
3321
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "null" });
|
|
3322
|
+
}
|
|
3323
|
+
return (jsxRuntime.jsx(react.Grid, { rowGap: 1, padding: 1, overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
3324
|
+
return (jsxRuntime.jsxs(react.Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsxRuntime.jsx(react.Text, { color: "colorPalette.400", children: getColumn({ field }) }), typeof value === "object" ? (jsxRuntime.jsx(RecordDisplay, { object: value, prefix: `${prefix}${field}.`, translate: translate })) : (jsxRuntime.jsx(react.Text, { children: JSON.stringify(value) }))] }, field));
|
|
3325
|
+
}) }));
|
|
3326
|
+
};
|
|
3327
|
+
|
|
3628
3328
|
const widthSanityCheck = (widthList, ignoreList, properties) => {
|
|
3629
3329
|
const widthListToolong = widthList.length > Object.keys(properties).length;
|
|
3630
3330
|
if (widthListToolong) {
|
|
@@ -3682,70 +3382,6 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3682
3382
|
return columns;
|
|
3683
3383
|
};
|
|
3684
3384
|
|
|
3685
|
-
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3686
|
-
const { columns, translate, data } = useDataTableContext();
|
|
3687
|
-
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3688
|
-
const { accessorKey, id } = def;
|
|
3689
|
-
if (accessorKey) {
|
|
3690
|
-
return [accessorKey, def];
|
|
3691
|
-
}
|
|
3692
|
-
return [id, def];
|
|
3693
|
-
}));
|
|
3694
|
-
const columnHeaders = Object.keys(columnsMap);
|
|
3695
|
-
const totalWidths = columns
|
|
3696
|
-
.map(({ size }) => {
|
|
3697
|
-
if (!!size === false) {
|
|
3698
|
-
return 0;
|
|
3699
|
-
}
|
|
3700
|
-
if (typeof size === "number") {
|
|
3701
|
-
return size;
|
|
3702
|
-
}
|
|
3703
|
-
return 0;
|
|
3704
|
-
})
|
|
3705
|
-
.reduce((previous, current) => previous + current, 0);
|
|
3706
|
-
const columnWidths = columns
|
|
3707
|
-
.map(({ size }) => {
|
|
3708
|
-
if (!!size === false) {
|
|
3709
|
-
return "1fr";
|
|
3710
|
-
}
|
|
3711
|
-
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3712
|
-
})
|
|
3713
|
-
.join(" ");
|
|
3714
|
-
console.log({ columnWidths }, "hadfg");
|
|
3715
|
-
const cellProps = {
|
|
3716
|
-
flex: "1 0 0%",
|
|
3717
|
-
overflow: "auto",
|
|
3718
|
-
paddingX: "2",
|
|
3719
|
-
py: "1",
|
|
3720
|
-
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
3721
|
-
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
3722
|
-
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3723
|
-
borderBottomWidth: "1px",
|
|
3724
|
-
...{ colorPalette },
|
|
3725
|
-
};
|
|
3726
|
-
if (data.length <= 0) {
|
|
3727
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: emptyComponent });
|
|
3728
|
-
}
|
|
3729
|
-
return (jsxRuntime.jsxs(react.Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", color: { base: "colorPalette.900", _dark: "colorPalette.100" }, borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: [jsxRuntime.jsx(react.Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: columnHeaders.map((header) => {
|
|
3730
|
-
return (jsxRuntime.jsx(react.Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3731
|
-
}) }), data.map((record) => {
|
|
3732
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columnHeaders.map((header) => {
|
|
3733
|
-
const { cell } = columnsMap[header];
|
|
3734
|
-
const value = record[header];
|
|
3735
|
-
if (!!record === false) {
|
|
3736
|
-
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3737
|
-
}
|
|
3738
|
-
if (cell) {
|
|
3739
|
-
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3740
|
-
}
|
|
3741
|
-
if (typeof value === "object") {
|
|
3742
|
-
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: jsxRuntime.jsx(RecordDisplay, { object: value }) }));
|
|
3743
|
-
}
|
|
3744
|
-
return jsxRuntime.jsx(react.Box, { ...cellProps, children: value });
|
|
3745
|
-
}) }));
|
|
3746
|
-
})] }));
|
|
3747
|
-
};
|
|
3748
|
-
|
|
3749
3385
|
//@ts-expect-error TODO: find appropriate type
|
|
3750
3386
|
const SchemaFormContext = React.createContext({
|
|
3751
3387
|
schema: {},
|
|
@@ -5237,7 +4873,7 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
|
|
|
5237
4873
|
};
|
|
5238
4874
|
|
|
5239
4875
|
const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
5240
|
-
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
4876
|
+
const { watch, getValues, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
5241
4877
|
const { serverUrl, idMap, setIdMap, schema: parentSchema, idPickerLabels, } = useSchemaContext();
|
|
5242
4878
|
const formI18n = useFormI18n(column, prefix);
|
|
5243
4879
|
const { required, gridColumn = 'span 12', gridRow = 'span 1', renderDisplay, foreign_key, } = schema;
|
|
@@ -5249,8 +4885,26 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
5249
4885
|
const [page, setPage] = React.useState(0);
|
|
5250
4886
|
const ref = React.useRef(null);
|
|
5251
4887
|
const colLabel = formI18n.colLabel;
|
|
5252
|
-
const
|
|
5253
|
-
const
|
|
4888
|
+
const watchedValue = watch(colLabel);
|
|
4889
|
+
const watchId = !isMultiple ? watchedValue : undefined;
|
|
4890
|
+
const watchIds = isMultiple
|
|
4891
|
+
? (Array.isArray(watchedValue) ? watchedValue : [])
|
|
4892
|
+
: [];
|
|
4893
|
+
// Get initial values immediately to ensure query can trigger on mount
|
|
4894
|
+
const initialValue = getValues(colLabel);
|
|
4895
|
+
const initialId = !isMultiple ? initialValue : undefined;
|
|
4896
|
+
const initialIds = isMultiple
|
|
4897
|
+
? (Array.isArray(initialValue) ? initialValue : [])
|
|
4898
|
+
: [];
|
|
4899
|
+
// Use watched values if they exist (including empty string for single select),
|
|
4900
|
+
// otherwise fall back to initial values from getValues()
|
|
4901
|
+
// This ensures the query can trigger on mount with initial values
|
|
4902
|
+
// For single: use watchId if it's not undefined/null, otherwise use initialId
|
|
4903
|
+
// For multiple: use watchIds if watchedValue is defined, otherwise use initialIds
|
|
4904
|
+
const currentId = watchId !== undefined && watchId !== null ? watchId : initialId;
|
|
4905
|
+
const currentIds = watchedValue !== undefined && watchedValue !== null && isMultiple
|
|
4906
|
+
? watchIds
|
|
4907
|
+
: initialIds;
|
|
5254
4908
|
// Query for search results
|
|
5255
4909
|
const query = reactQuery.useQuery({
|
|
5256
4910
|
queryKey: [`idpicker`, { column, searchText, limit, page }],
|
|
@@ -5290,33 +4944,43 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
5290
4944
|
staleTime: 300000,
|
|
5291
4945
|
});
|
|
5292
4946
|
// Query for currently selected items (to display them properly)
|
|
4947
|
+
// Use currentId/currentIds in queryKey so it includes initial values and updates when watched values change
|
|
5293
4948
|
const queryDefault = reactQuery.useQuery({
|
|
5294
4949
|
queryKey: [
|
|
5295
4950
|
`idpicker-default`,
|
|
5296
|
-
{
|
|
4951
|
+
{
|
|
4952
|
+
form: parentSchema.title,
|
|
4953
|
+
column,
|
|
4954
|
+
id: isMultiple ? currentIds : currentId,
|
|
4955
|
+
},
|
|
5297
4956
|
],
|
|
5298
4957
|
queryFn: async () => {
|
|
4958
|
+
// Use current values (which include initial) for the query
|
|
4959
|
+
const queryId = currentId;
|
|
4960
|
+
const queryIds = currentIds;
|
|
5299
4961
|
if (customQueryFn) {
|
|
4962
|
+
// For customQueryFn, pass where clause to fetch specific IDs
|
|
5300
4963
|
const { data, idMap } = await customQueryFn({
|
|
5301
|
-
searching:
|
|
5302
|
-
limit: isMultiple ?
|
|
4964
|
+
searching: '',
|
|
4965
|
+
limit: isMultiple ? queryIds.length : 1,
|
|
5303
4966
|
offset: 0,
|
|
4967
|
+
where: [{ id: column_ref, value: isMultiple ? queryIds : queryId }],
|
|
5304
4968
|
});
|
|
5305
4969
|
setIdMap((state) => {
|
|
5306
4970
|
return { ...state, ...idMap };
|
|
5307
4971
|
});
|
|
5308
4972
|
return data;
|
|
5309
4973
|
}
|
|
5310
|
-
if (!
|
|
4974
|
+
if (!queryId && (!queryIds || queryIds.length === 0)) {
|
|
5311
4975
|
return { data: [] };
|
|
5312
4976
|
}
|
|
5313
|
-
const searchValue = isMultiple ?
|
|
4977
|
+
const searchValue = isMultiple ? queryIds.join(',') : queryId;
|
|
5314
4978
|
const data = await getTableData({
|
|
5315
4979
|
serverUrl,
|
|
5316
4980
|
searching: searchValue,
|
|
5317
4981
|
in_table: table,
|
|
5318
|
-
where: [{ id: column_ref, value: isMultiple ?
|
|
5319
|
-
limit: isMultiple ?
|
|
4982
|
+
where: [{ id: column_ref, value: isMultiple ? queryIds : queryId }],
|
|
4983
|
+
limit: isMultiple ? queryIds.length : 1,
|
|
5320
4984
|
offset: 0,
|
|
5321
4985
|
});
|
|
5322
4986
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
@@ -5333,16 +4997,9 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
5333
4997
|
return data;
|
|
5334
4998
|
},
|
|
5335
4999
|
enabled: isMultiple
|
|
5336
|
-
? Array.isArray(
|
|
5337
|
-
: !!
|
|
5000
|
+
? Array.isArray(currentIds) && currentIds.length > 0
|
|
5001
|
+
: !!currentId,
|
|
5338
5002
|
});
|
|
5339
|
-
// Effect to load selected values when component mounts
|
|
5340
|
-
React.useEffect(() => {
|
|
5341
|
-
if (isMultiple ? watchIds.length > 0 : !!watchId) {
|
|
5342
|
-
queryDefault.refetch();
|
|
5343
|
-
}
|
|
5344
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5345
|
-
}, []);
|
|
5346
5003
|
// Effect to trigger initial data fetch when popover opens
|
|
5347
5004
|
React.useEffect(() => {
|
|
5348
5005
|
if (openSearchResult) {
|
|
@@ -5375,7 +5032,8 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
5375
5032
|
if (Object.keys(idMap).length <= 0) {
|
|
5376
5033
|
return '';
|
|
5377
5034
|
}
|
|
5378
|
-
|
|
5035
|
+
// Use currentId which includes initial values
|
|
5036
|
+
const record = idMap[currentId];
|
|
5379
5037
|
if (record === undefined) {
|
|
5380
5038
|
return '';
|
|
5381
5039
|
}
|
|
@@ -7214,6 +6872,526 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
|
|
|
7214
6872
|
}
|
|
7215
6873
|
};
|
|
7216
6874
|
|
|
6875
|
+
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
6876
|
+
const { columns, translate, data } = useDataTableContext();
|
|
6877
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
6878
|
+
const { accessorKey, id } = def;
|
|
6879
|
+
if (accessorKey) {
|
|
6880
|
+
return [accessorKey, def];
|
|
6881
|
+
}
|
|
6882
|
+
return [id, def];
|
|
6883
|
+
}));
|
|
6884
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
6885
|
+
const totalWidths = columns
|
|
6886
|
+
.map(({ size }) => {
|
|
6887
|
+
if (!!size === false) {
|
|
6888
|
+
return 0;
|
|
6889
|
+
}
|
|
6890
|
+
if (typeof size === "number") {
|
|
6891
|
+
return size;
|
|
6892
|
+
}
|
|
6893
|
+
return 0;
|
|
6894
|
+
})
|
|
6895
|
+
.reduce((previous, current) => previous + current, 0);
|
|
6896
|
+
const columnWidths = columns
|
|
6897
|
+
.map(({ size }) => {
|
|
6898
|
+
if (!!size === false) {
|
|
6899
|
+
return "1fr";
|
|
6900
|
+
}
|
|
6901
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
6902
|
+
})
|
|
6903
|
+
.join(" ");
|
|
6904
|
+
console.log({ columnWidths }, "hadfg");
|
|
6905
|
+
const cellProps = {
|
|
6906
|
+
flex: "1 0 0%",
|
|
6907
|
+
overflow: "auto",
|
|
6908
|
+
paddingX: "2",
|
|
6909
|
+
py: "1",
|
|
6910
|
+
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
6911
|
+
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
6912
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
6913
|
+
borderBottomWidth: "1px",
|
|
6914
|
+
...{ colorPalette },
|
|
6915
|
+
};
|
|
6916
|
+
if (data.length <= 0) {
|
|
6917
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: emptyComponent });
|
|
6918
|
+
}
|
|
6919
|
+
return (jsxRuntime.jsxs(react.Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", color: { base: "colorPalette.900", _dark: "colorPalette.100" }, borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: [jsxRuntime.jsx(react.Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: columnHeaders.map((header) => {
|
|
6920
|
+
return (jsxRuntime.jsx(react.Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
6921
|
+
}) }), data.map((record) => {
|
|
6922
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columnHeaders.map((header) => {
|
|
6923
|
+
const { cell } = columnsMap[header];
|
|
6924
|
+
const value = record[header];
|
|
6925
|
+
if (!!record === false) {
|
|
6926
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
6927
|
+
}
|
|
6928
|
+
if (cell) {
|
|
6929
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
6930
|
+
}
|
|
6931
|
+
if (typeof value === "object") {
|
|
6932
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: jsxRuntime.jsx(RecordDisplay, { object: value }) }));
|
|
6933
|
+
}
|
|
6934
|
+
return jsxRuntime.jsx(react.Box, { ...cellProps, children: value });
|
|
6935
|
+
}) }));
|
|
6936
|
+
})] }));
|
|
6937
|
+
};
|
|
6938
|
+
|
|
6939
|
+
const TableBodySkeleton = ({ showSelector = false, canResize = true, }) => {
|
|
6940
|
+
'use no memo';
|
|
6941
|
+
const { table } = useDataTableContext();
|
|
6942
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
6943
|
+
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
6944
|
+
const handleRowHover = (index) => {
|
|
6945
|
+
setHoveredRow(index);
|
|
6946
|
+
};
|
|
6947
|
+
const getTdProps = (column) => {
|
|
6948
|
+
const tdProps = column.getIsPinned()
|
|
6949
|
+
? {
|
|
6950
|
+
left: showSelector
|
|
6951
|
+
? `${column.getStart('left') + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
6952
|
+
: `${column.getStart('left')}px`,
|
|
6953
|
+
position: 'relative',
|
|
6954
|
+
}
|
|
6955
|
+
: {};
|
|
6956
|
+
return tdProps;
|
|
6957
|
+
};
|
|
6958
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
6959
|
+
if (hoveredRow === -1) {
|
|
6960
|
+
return {};
|
|
6961
|
+
}
|
|
6962
|
+
if (hoveredRow === index) {
|
|
6963
|
+
return {
|
|
6964
|
+
opacity: '1',
|
|
6965
|
+
};
|
|
6966
|
+
}
|
|
6967
|
+
return {
|
|
6968
|
+
opacity: '0.8',
|
|
6969
|
+
};
|
|
6970
|
+
};
|
|
6971
|
+
// Get the number of skeleton rows based on current pageSize
|
|
6972
|
+
const pageSize = table.getState().pagination.pageSize;
|
|
6973
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
6974
|
+
return (jsxRuntime.jsx(react.Table.Body, { children: Array.from({ length: pageSize }).map((_, rowIndex) => {
|
|
6975
|
+
return (jsxRuntime.jsxs(react.Table.Row, { display: 'flex', zIndex: 1, onMouseEnter: () => handleRowHover(rowIndex), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index: rowIndex }), children: [showSelector && jsxRuntime.jsx(TableRowSelectorSkeleton, {}), visibleColumns.map((column, colIndex) => {
|
|
6976
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
6977
|
+
// styling resize and pinning start
|
|
6978
|
+
flex: `${canResize ? '0' : '1'} 0 ${column.getSize()}px`,
|
|
6979
|
+
// this is to avoid the cell from being too wide
|
|
6980
|
+
minWidth: `0`, color: {
|
|
6981
|
+
base: 'colorPalette.900',
|
|
6982
|
+
_dark: 'colorPalette.100',
|
|
6983
|
+
},
|
|
6984
|
+
bg: { base: 'colorPalette.50', _dark: 'colorPalette.950' }, ...getTdProps(column), children: jsxRuntime.jsx(react.Skeleton, { height: "20px", width: "80%" }) }, `chakra-table-skeleton-cell-${rowIndex}-${colIndex}`));
|
|
6985
|
+
})] }, `chakra-table-skeleton-row-${rowIndex}`));
|
|
6986
|
+
}) }));
|
|
6987
|
+
};
|
|
6988
|
+
const TableRowSelectorSkeleton = () => {
|
|
6989
|
+
const { table } = useDataTableContext();
|
|
6990
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
6991
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: 'grid', color: {
|
|
6992
|
+
base: 'colorPalette.900',
|
|
6993
|
+
_dark: 'colorPalette.100',
|
|
6994
|
+
},
|
|
6995
|
+
bg: { base: 'colorPalette.50', _dark: 'colorPalette.950' }, justifyItems: 'center', alignItems: 'center', children: jsxRuntime.jsx(react.Skeleton, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }) }));
|
|
6996
|
+
};
|
|
6997
|
+
|
|
6998
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = '', isLoading = false, }) => {
|
|
6999
|
+
if (variant === 'greedy') {
|
|
7000
|
+
const bodyComponent = isLoading ? (jsxRuntime.jsx(TableBodySkeleton, { showSelector: tableBodyProps.showSelector, canResize: false })) : (jsxRuntime.jsx(TableBody, { ...tableBodyProps, canResize: false, ...tableBodyProps }));
|
|
7001
|
+
return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { canResize: false,
|
|
7002
|
+
showLoading: isLoading,
|
|
7003
|
+
showSelector: tableHeaderProps.showSelector ??
|
|
7004
|
+
tableBodyProps.showSelector ??
|
|
7005
|
+
false,
|
|
7006
|
+
...tableProps, children: [jsxRuntime.jsx(TableHeader, { canResize: false, ...tableHeaderProps }), bodyComponent, showFooter && (jsxRuntime.jsx(TableFooter, { canResize: false, ...tableFooterProps }))] }) }));
|
|
7007
|
+
}
|
|
7008
|
+
const bodyComponent = isLoading ? (jsxRuntime.jsx(TableBodySkeleton, { showSelector: tableBodyProps.showSelector, canResize: tableBodyProps.canResize })) : (jsxRuntime.jsx(TableBody, { ...tableBodyProps }));
|
|
7009
|
+
return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { showLoading: isLoading,
|
|
7010
|
+
showSelector: tableHeaderProps.showSelector ??
|
|
7011
|
+
tableBodyProps.showSelector ??
|
|
7012
|
+
false,
|
|
7013
|
+
...tableProps, children: [jsxRuntime.jsx(TableHeader, { ...tableHeaderProps }), bodyComponent, showFooter && jsxRuntime.jsx(TableFooter, { ...tableFooterProps })] }) }));
|
|
7014
|
+
};
|
|
7015
|
+
|
|
7016
|
+
/**
|
|
7017
|
+
* DefaultTableServer is a wrapper around DefaultTable that automatically
|
|
7018
|
+
* detects server-side loading state from DataTableServerContext.
|
|
7019
|
+
*
|
|
7020
|
+
* Use this component when working with DataTableServer to automatically
|
|
7021
|
+
* show skeleton loading state during data fetching.
|
|
7022
|
+
*
|
|
7023
|
+
* @example
|
|
7024
|
+
* ```tsx
|
|
7025
|
+
* <DataTableServer columns={columns} {...datatableServer}>
|
|
7026
|
+
* <DefaultTableServer />
|
|
7027
|
+
* </DataTableServer>
|
|
7028
|
+
* ```
|
|
7029
|
+
*/
|
|
7030
|
+
const DefaultTableServer = ({ isLoading: isLoadingOverride, ...props }) => {
|
|
7031
|
+
// Automatically detect loading state from server context
|
|
7032
|
+
const serverContext = useDataTableServerContext();
|
|
7033
|
+
const isLoading = isLoadingOverride ?? serverContext?.query?.isLoading ?? false;
|
|
7034
|
+
return jsxRuntime.jsx(DefaultTable, { ...props, isLoading: isLoading });
|
|
7035
|
+
};
|
|
7036
|
+
|
|
7037
|
+
const CellRenderer = ({ cell }) => {
|
|
7038
|
+
const { translate } = useDataTableContext();
|
|
7039
|
+
const getLabel = ({ columnId }) => {
|
|
7040
|
+
if (translate !== undefined) {
|
|
7041
|
+
return translate.t(`${columnId}`);
|
|
7042
|
+
}
|
|
7043
|
+
return snakeToLabel(columnId);
|
|
7044
|
+
};
|
|
7045
|
+
const formatValue = (value) => {
|
|
7046
|
+
if (typeof value === "object") {
|
|
7047
|
+
return JSON.stringify(value);
|
|
7048
|
+
}
|
|
7049
|
+
if (typeof value === "string") {
|
|
7050
|
+
return value;
|
|
7051
|
+
}
|
|
7052
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
7053
|
+
return `${value}`;
|
|
7054
|
+
}
|
|
7055
|
+
if (value === undefined) {
|
|
7056
|
+
if (translate !== undefined) {
|
|
7057
|
+
return translate.t(`undefined`);
|
|
7058
|
+
}
|
|
7059
|
+
return `undefined`;
|
|
7060
|
+
}
|
|
7061
|
+
throw new Error(`value is unknown, ${typeof value}`);
|
|
7062
|
+
};
|
|
7063
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
7064
|
+
const gridColumn = cell.column.columnDef.meta?.gridColumn ?? [
|
|
7065
|
+
"span 12",
|
|
7066
|
+
"span 6",
|
|
7067
|
+
"span 3",
|
|
7068
|
+
];
|
|
7069
|
+
const gridRow = cell.column.columnDef.meta?.gridRow ?? {};
|
|
7070
|
+
if (showCustomDataDisplay) {
|
|
7071
|
+
return (jsxRuntime.jsx(react.Flex, { gridColumn, gridRow, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
7072
|
+
}
|
|
7073
|
+
const value = cell.getValue();
|
|
7074
|
+
if (typeof value === "object") {
|
|
7075
|
+
return (jsxRuntime.jsxs(react.Box, { gridColumn, gridRow, children: [jsxRuntime.jsx(react.Box, { children: getLabel({ columnId: cell.column.id }) }), jsxRuntime.jsx(RecordDisplay, { boxProps: {
|
|
7076
|
+
borderWidth: 1,
|
|
7077
|
+
borderRadius: 4,
|
|
7078
|
+
borderColor: "gray.400",
|
|
7079
|
+
paddingX: 4,
|
|
7080
|
+
paddingY: 2,
|
|
7081
|
+
}, object: value })] }, cell.id));
|
|
7082
|
+
}
|
|
7083
|
+
return (jsxRuntime.jsxs(react.Box, { gridColumn, gridRow, children: [jsxRuntime.jsx(react.Box, { color: "colorPalette.400", children: getLabel({ columnId: cell.column.id }) }), jsxRuntime.jsx(react.Box, { wordBreak: "break-word", textOverflow: "ellipsis", overflow: "hidden", children: `${formatValue(cell.getValue())}` })] }, cell.id));
|
|
7084
|
+
};
|
|
7085
|
+
const DataDisplay = ({ variant = "" }) => {
|
|
7086
|
+
const { table, translate } = useDataTableContext();
|
|
7087
|
+
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
7088
|
+
const rowId = row.id;
|
|
7089
|
+
return (jsxRuntime.jsx(react.Card.Root, { children: jsxRuntime.jsx(react.Card.Body, { display: "grid", gap: 4, padding: 4, gridTemplateColumns: "repeat(12, 1fr)", children: table.getAllColumns().map((column) => {
|
|
7090
|
+
const childCell = row.getAllCells().find((cell) => {
|
|
7091
|
+
return cell.id === `${rowId}_${column.id}`;
|
|
7092
|
+
});
|
|
7093
|
+
if (column.columns.length > 0) {
|
|
7094
|
+
return (jsxRuntime.jsxs(react.Card.Root, { margin: "1", gridColumn: "span 12", children: [jsxRuntime.jsx(react.Card.Header, { color: "gray.400", children: translate.t(column.id) }), jsxRuntime.jsx(react.Card.Body, { display: "grid", gap: "4", gridTemplateColumns: "repeat(12, 1fr)", children: column.columns.map((column) => {
|
|
7095
|
+
if (!column.getIsVisible()) {
|
|
7096
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
7097
|
+
}
|
|
7098
|
+
const foundCell = row
|
|
7099
|
+
.getVisibleCells()
|
|
7100
|
+
.find((cell) => {
|
|
7101
|
+
return cell.id === `${rowId}_${column.id}`;
|
|
7102
|
+
});
|
|
7103
|
+
return jsxRuntime.jsx(CellRenderer, { cell: foundCell });
|
|
7104
|
+
}) })] }, `chakra-table-card-${childCell?.id}`));
|
|
7105
|
+
}
|
|
7106
|
+
return jsxRuntime.jsx(CellRenderer, { cell: childCell });
|
|
7107
|
+
}) }) }, `chakra-table-card-${rowId}`));
|
|
7108
|
+
}) }));
|
|
7109
|
+
};
|
|
7110
|
+
|
|
7111
|
+
// Reference: https://tanstack.com/table/latest/docs/framework/react/examples/custom-features
|
|
7112
|
+
// TypeScript setup for our new feature with all of the same type-safety as stock TanStack Table features
|
|
7113
|
+
// end of TS setup!
|
|
7114
|
+
// Here is all of the actual javascript code for our new feature
|
|
7115
|
+
const DensityFeature = {
|
|
7116
|
+
// define the new feature's initial state
|
|
7117
|
+
getInitialState: (state) => {
|
|
7118
|
+
return {
|
|
7119
|
+
density: "sm",
|
|
7120
|
+
...state,
|
|
7121
|
+
};
|
|
7122
|
+
},
|
|
7123
|
+
// define the new feature's default options
|
|
7124
|
+
getDefaultOptions: (table) => {
|
|
7125
|
+
return {
|
|
7126
|
+
enableDensity: true,
|
|
7127
|
+
onDensityChange: reactTable.makeStateUpdater("density", table),
|
|
7128
|
+
};
|
|
7129
|
+
},
|
|
7130
|
+
// if you need to add a default column definition...
|
|
7131
|
+
// getDefaultColumnDef: <TData extends RowData>(): Partial<ColumnDef<TData>> => {
|
|
7132
|
+
// return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
|
|
7133
|
+
// },
|
|
7134
|
+
// define the new feature's table instance methods
|
|
7135
|
+
createTable: (table) => {
|
|
7136
|
+
table.setDensity = (updater) => {
|
|
7137
|
+
const safeUpdater = (old) => {
|
|
7138
|
+
let newState = reactTable.functionalUpdate(updater, old);
|
|
7139
|
+
return newState;
|
|
7140
|
+
};
|
|
7141
|
+
return table.options.onDensityChange?.(safeUpdater);
|
|
7142
|
+
};
|
|
7143
|
+
table.toggleDensity = (value) => {
|
|
7144
|
+
table.setDensity((old) => {
|
|
7145
|
+
if (value)
|
|
7146
|
+
return value;
|
|
7147
|
+
if (old === "sm") {
|
|
7148
|
+
return "md";
|
|
7149
|
+
}
|
|
7150
|
+
if (old === "md") {
|
|
7151
|
+
return "lg";
|
|
7152
|
+
}
|
|
7153
|
+
return "sm";
|
|
7154
|
+
});
|
|
7155
|
+
};
|
|
7156
|
+
table.getDensityValue = (value) => {
|
|
7157
|
+
let density;
|
|
7158
|
+
if (value) {
|
|
7159
|
+
density = value;
|
|
7160
|
+
}
|
|
7161
|
+
else {
|
|
7162
|
+
density = table.getState().density;
|
|
7163
|
+
}
|
|
7164
|
+
if (density === "sm") {
|
|
7165
|
+
return 8;
|
|
7166
|
+
}
|
|
7167
|
+
if (density === "md") {
|
|
7168
|
+
return 16;
|
|
7169
|
+
}
|
|
7170
|
+
return 32;
|
|
7171
|
+
};
|
|
7172
|
+
},
|
|
7173
|
+
// if you need to add row instance APIs...
|
|
7174
|
+
// createRow: <TData extends RowData>(row, table): void => {},
|
|
7175
|
+
// if you need to add cell instance APIs...
|
|
7176
|
+
// createCell: <TData extends RowData>(cell, column, row, table): void => {},
|
|
7177
|
+
// if you need to add column instance APIs...
|
|
7178
|
+
// createColumn: <TData extends RowData>(column, table): void => {},
|
|
7179
|
+
// if you need to add header instance APIs...
|
|
7180
|
+
// createHeader: <TData extends RowData>(header, table): void => {},
|
|
7181
|
+
};
|
|
7182
|
+
//end of custom feature code
|
|
7183
|
+
|
|
7184
|
+
// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)
|
|
7185
|
+
const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
7186
|
+
// Rank the item
|
|
7187
|
+
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), value);
|
|
7188
|
+
// Store the itemRank info
|
|
7189
|
+
addMeta({
|
|
7190
|
+
itemRank,
|
|
7191
|
+
});
|
|
7192
|
+
// Return if the item should be filtered in/out
|
|
7193
|
+
return itemRank.passed;
|
|
7194
|
+
};
|
|
7195
|
+
/**
|
|
7196
|
+
* DataTable will create a context to hold all values to
|
|
7197
|
+
* help the render of the DataTable in serverside
|
|
7198
|
+
*
|
|
7199
|
+
*
|
|
7200
|
+
* The query is required to be a GET request that can receive
|
|
7201
|
+
* specified params and return a specified response
|
|
7202
|
+
*
|
|
7203
|
+
* @link https://tanstack.com/table/latest/docs/guide/column-defs
|
|
7204
|
+
*/
|
|
7205
|
+
function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, translate, children, tableLabel = {
|
|
7206
|
+
view: 'View',
|
|
7207
|
+
edit: 'Edit',
|
|
7208
|
+
filterButtonText: 'Filter',
|
|
7209
|
+
filterTitle: 'Filter',
|
|
7210
|
+
filterReset: 'Reset',
|
|
7211
|
+
filterClose: 'Close',
|
|
7212
|
+
reloadTooltip: 'Reload',
|
|
7213
|
+
reloadButtonText: 'Reload',
|
|
7214
|
+
resetSelection: 'Reset Selection',
|
|
7215
|
+
resetSorting: 'Reset Sorting',
|
|
7216
|
+
rowCountText: 'Row Count',
|
|
7217
|
+
hasErrorText: 'Has Error',
|
|
7218
|
+
globalFilterPlaceholder: 'Search',
|
|
7219
|
+
trueLabel: 'True',
|
|
7220
|
+
falseLabel: 'False',
|
|
7221
|
+
}, }) {
|
|
7222
|
+
const table = reactTable.useReactTable({
|
|
7223
|
+
_features: [DensityFeature],
|
|
7224
|
+
data: data,
|
|
7225
|
+
rowCount: data.length,
|
|
7226
|
+
columns: columns,
|
|
7227
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
7228
|
+
getFilteredRowModel: reactTable.getFilteredRowModel(),
|
|
7229
|
+
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
7230
|
+
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
7231
|
+
defaultColumn: {
|
|
7232
|
+
size: 150, //starting column size
|
|
7233
|
+
minSize: 10, //enforced during column resizing
|
|
7234
|
+
maxSize: 10000, //enforced during column resizing
|
|
7235
|
+
},
|
|
7236
|
+
enableRowSelection: enableRowSelection,
|
|
7237
|
+
enableMultiRowSelection: enableMultiRowSelection,
|
|
7238
|
+
enableSubRowSelection: enableSubRowSelection,
|
|
7239
|
+
columnResizeMode: 'onChange',
|
|
7240
|
+
// global filter start
|
|
7241
|
+
filterFns: {
|
|
7242
|
+
fuzzy: fuzzyFilter,
|
|
7243
|
+
},
|
|
7244
|
+
globalFilterFn: 'fuzzy',
|
|
7245
|
+
state: {
|
|
7246
|
+
pagination,
|
|
7247
|
+
sorting,
|
|
7248
|
+
columnFilters,
|
|
7249
|
+
rowSelection,
|
|
7250
|
+
columnOrder,
|
|
7251
|
+
globalFilter,
|
|
7252
|
+
density,
|
|
7253
|
+
columnVisibility,
|
|
7254
|
+
},
|
|
7255
|
+
onPaginationChange: setPagination,
|
|
7256
|
+
onSortingChange: setSorting,
|
|
7257
|
+
onColumnFiltersChange: setColumnFilters,
|
|
7258
|
+
onRowSelectionChange: setRowSelection,
|
|
7259
|
+
onColumnOrderChange: (state) => {
|
|
7260
|
+
setColumnOrder(state);
|
|
7261
|
+
},
|
|
7262
|
+
onGlobalFilterChange: (state) => {
|
|
7263
|
+
setGlobalFilter(state);
|
|
7264
|
+
},
|
|
7265
|
+
onDensityChange: setDensity,
|
|
7266
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
7267
|
+
});
|
|
7268
|
+
return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
|
|
7269
|
+
table: table,
|
|
7270
|
+
globalFilter,
|
|
7271
|
+
setGlobalFilter,
|
|
7272
|
+
type: 'client',
|
|
7273
|
+
translate,
|
|
7274
|
+
columns: columns,
|
|
7275
|
+
sorting,
|
|
7276
|
+
setSorting,
|
|
7277
|
+
columnFilters,
|
|
7278
|
+
setColumnFilters,
|
|
7279
|
+
pagination,
|
|
7280
|
+
setPagination,
|
|
7281
|
+
rowSelection,
|
|
7282
|
+
setRowSelection,
|
|
7283
|
+
columnOrder,
|
|
7284
|
+
setColumnOrder,
|
|
7285
|
+
density,
|
|
7286
|
+
setDensity,
|
|
7287
|
+
columnVisibility,
|
|
7288
|
+
setColumnVisibility,
|
|
7289
|
+
data,
|
|
7290
|
+
tableLabel,
|
|
7291
|
+
}, children: children }));
|
|
7292
|
+
}
|
|
7293
|
+
|
|
7294
|
+
/**
|
|
7295
|
+
* DataTableServer will create a context to hold all values to
|
|
7296
|
+
* help the render of the DataTable in serverside
|
|
7297
|
+
*
|
|
7298
|
+
* The query is required to be a GET request that can receive
|
|
7299
|
+
* specified params and return a specified response
|
|
7300
|
+
*
|
|
7301
|
+
* The `useDataTableServer` can help to create the specified request and response
|
|
7302
|
+
*
|
|
7303
|
+
* @link https://tanstack.com/table/latest/docs/guide/column-defs
|
|
7304
|
+
*/
|
|
7305
|
+
function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, query, url, translate, children, tableLabel = {
|
|
7306
|
+
view: "View",
|
|
7307
|
+
edit: "Edit",
|
|
7308
|
+
filterButtonText: "Filter",
|
|
7309
|
+
filterTitle: "Filter",
|
|
7310
|
+
filterReset: "Reset",
|
|
7311
|
+
filterClose: "Close",
|
|
7312
|
+
reloadTooltip: "Reload",
|
|
7313
|
+
reloadButtonText: "Reload",
|
|
7314
|
+
resetSelection: "Reset Selection",
|
|
7315
|
+
resetSorting: "Reset Sorting",
|
|
7316
|
+
rowCountText: "Row Count",
|
|
7317
|
+
hasErrorText: "Has Error",
|
|
7318
|
+
globalFilterPlaceholder: "Search",
|
|
7319
|
+
trueLabel: "True",
|
|
7320
|
+
falseLabel: "False",
|
|
7321
|
+
}, }) {
|
|
7322
|
+
const table = reactTable.useReactTable({
|
|
7323
|
+
_features: [DensityFeature],
|
|
7324
|
+
data: (query.data?.data ?? []),
|
|
7325
|
+
rowCount: query.data?.count ?? 0,
|
|
7326
|
+
columns: columns,
|
|
7327
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
7328
|
+
manualPagination: true,
|
|
7329
|
+
manualSorting: true,
|
|
7330
|
+
columnResizeMode: "onChange",
|
|
7331
|
+
defaultColumn: {
|
|
7332
|
+
size: 150, //starting column size
|
|
7333
|
+
minSize: 10, //enforced during column resizing
|
|
7334
|
+
maxSize: 10000, //enforced during column resizing
|
|
7335
|
+
},
|
|
7336
|
+
enableRowSelection: enableRowSelection,
|
|
7337
|
+
enableMultiRowSelection: enableMultiRowSelection,
|
|
7338
|
+
enableSubRowSelection: enableSubRowSelection,
|
|
7339
|
+
state: {
|
|
7340
|
+
pagination,
|
|
7341
|
+
sorting,
|
|
7342
|
+
columnFilters,
|
|
7343
|
+
rowSelection,
|
|
7344
|
+
columnOrder,
|
|
7345
|
+
globalFilter,
|
|
7346
|
+
density,
|
|
7347
|
+
columnVisibility,
|
|
7348
|
+
},
|
|
7349
|
+
onPaginationChange: setPagination,
|
|
7350
|
+
onSortingChange: setSorting,
|
|
7351
|
+
onColumnFiltersChange: setColumnFilters,
|
|
7352
|
+
onRowSelectionChange: setRowSelection,
|
|
7353
|
+
onColumnOrderChange: (state) => {
|
|
7354
|
+
setColumnOrder(state);
|
|
7355
|
+
},
|
|
7356
|
+
onGlobalFilterChange: (state) => {
|
|
7357
|
+
setGlobalFilter(state);
|
|
7358
|
+
},
|
|
7359
|
+
onDensityChange: setDensity,
|
|
7360
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
7361
|
+
// for tanstack-table ts bug start
|
|
7362
|
+
filterFns: {
|
|
7363
|
+
fuzzy: () => {
|
|
7364
|
+
return false;
|
|
7365
|
+
},
|
|
7366
|
+
},
|
|
7367
|
+
// for tanstack-table ts bug end
|
|
7368
|
+
});
|
|
7369
|
+
return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
|
|
7370
|
+
table: table,
|
|
7371
|
+
globalFilter,
|
|
7372
|
+
setGlobalFilter,
|
|
7373
|
+
type: "server",
|
|
7374
|
+
translate,
|
|
7375
|
+
columns: columns,
|
|
7376
|
+
sorting,
|
|
7377
|
+
setSorting,
|
|
7378
|
+
columnFilters,
|
|
7379
|
+
setColumnFilters,
|
|
7380
|
+
pagination,
|
|
7381
|
+
setPagination,
|
|
7382
|
+
rowSelection,
|
|
7383
|
+
setRowSelection,
|
|
7384
|
+
columnOrder,
|
|
7385
|
+
setColumnOrder,
|
|
7386
|
+
density,
|
|
7387
|
+
setDensity,
|
|
7388
|
+
columnVisibility,
|
|
7389
|
+
setColumnVisibility,
|
|
7390
|
+
data: query.data?.data ?? [],
|
|
7391
|
+
tableLabel,
|
|
7392
|
+
}, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
7393
|
+
}
|
|
7394
|
+
|
|
7217
7395
|
exports.CardHeader = CardHeader;
|
|
7218
7396
|
exports.DataDisplay = DataDisplay;
|
|
7219
7397
|
exports.DataTable = DataTable;
|
|
@@ -7224,7 +7402,7 @@ exports.DefaultTable = DefaultTable;
|
|
|
7224
7402
|
exports.DefaultTableServer = DefaultTableServer;
|
|
7225
7403
|
exports.DensityToggleButton = DensityToggleButton;
|
|
7226
7404
|
exports.EditSortingButton = EditSortingButton;
|
|
7227
|
-
exports.EmptyState = EmptyState
|
|
7405
|
+
exports.EmptyState = EmptyState;
|
|
7228
7406
|
exports.ErrorAlert = ErrorAlert;
|
|
7229
7407
|
exports.FilterDialog = FilterDialog;
|
|
7230
7408
|
exports.FormBody = FormBody;
|