@bsol-oss/react-datatable5 12.0.0-beta.44 → 12.0.0-beta.46
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 +89 -24
- package/dist/index.js +125 -56
- package/dist/index.mjs +125 -56
- package/dist/types/components/DataTable/context/DataTableContext.d.ts +14 -0
- package/dist/types/components/DataTable/controls/ReloadButton.d.ts +1 -2
- package/dist/types/components/DataTable/controls/ResetFilteringButton.d.ts +1 -4
- package/dist/types/components/DataTable/controls/ResetSelectionButton.d.ts +1 -4
- package/dist/types/components/DataTable/controls/ResetSortingButton.d.ts +1 -4
- package/dist/types/components/DataTable/controls/TableControls.d.ts +4 -1
- package/dist/types/components/DataTable/display/TableBody.d.ts +1 -2
- package/dist/types/components/DataTable/display/TableCardContainer.d.ts +6 -3
- package/dist/types/components/DataTable/display/TableHeader.d.ts +43 -1
- package/dist/types/components/Form/components/types/CustomJSONSchema7.d.ts +1 -1
- package/dist/types/components/Form/utils/translateWrapper.d.ts +6 -0
- package/dist/types/index.d.ts +16 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -71,6 +71,10 @@ const DataTableContext = createContext({
|
|
|
71
71
|
},
|
|
72
72
|
rowSelection: {},
|
|
73
73
|
columnVisibility: {},
|
|
74
|
+
tableLabel: {
|
|
75
|
+
view: "View",
|
|
76
|
+
edit: "Edit",
|
|
77
|
+
},
|
|
74
78
|
});
|
|
75
79
|
|
|
76
80
|
const useDataTableContext = () => {
|
|
@@ -126,11 +130,13 @@ const TableSorter = () => {
|
|
|
126
130
|
}) }))) }));
|
|
127
131
|
};
|
|
128
132
|
|
|
129
|
-
const ResetSortingButton = (
|
|
133
|
+
const ResetSortingButton = () => {
|
|
130
134
|
const { table } = useDataTableContext();
|
|
135
|
+
const { tableLabel } = useDataTableContext();
|
|
136
|
+
const { resetSorting } = tableLabel;
|
|
131
137
|
return (jsx(Button$1, { onClick: () => {
|
|
132
138
|
table.resetSorting();
|
|
133
|
-
}, children:
|
|
139
|
+
}, children: resetSorting }));
|
|
134
140
|
};
|
|
135
141
|
|
|
136
142
|
const EditSortingButton = ({ text, icon = jsx(MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
@@ -341,10 +347,11 @@ const Filter = ({ column }) => {
|
|
|
341
347
|
if (filterVariant === "select") {
|
|
342
348
|
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(RadioGroup, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onValueChange: (details) => {
|
|
343
349
|
column.setFilterValue(details.value);
|
|
344
|
-
}, children:
|
|
350
|
+
}, children: jsxs(Flex, { flexFlow: "wrap", gap: "0.5rem", children: [filterOptions.length === 0 && jsx(Text, { children: "No filter options" }), filterOptions.length > 0 &&
|
|
351
|
+
filterOptions.map((item) => (jsx(Radio, { value: item.value, children: item.label }, item.value)))] }) })] }, column.id));
|
|
345
352
|
}
|
|
346
353
|
if (filterVariant === "tag") {
|
|
347
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(TagFilter, { availableTags: filterOptions, selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
354
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(TagFilter, { availableTags: filterOptions.map((item) => item.value), selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
348
355
|
if (tags.length === 0) {
|
|
349
356
|
return column.setFilterValue(undefined);
|
|
350
357
|
}
|
|
@@ -407,17 +414,20 @@ const TableFilter = () => {
|
|
|
407
414
|
}) }));
|
|
408
415
|
};
|
|
409
416
|
|
|
410
|
-
const ResetFilteringButton = (
|
|
417
|
+
const ResetFilteringButton = () => {
|
|
411
418
|
const { table } = useDataTableContext();
|
|
419
|
+
const { tableLabel } = useDataTableContext();
|
|
420
|
+
const { filterReset } = tableLabel;
|
|
412
421
|
return (jsx(Button$1, { onClick: () => {
|
|
413
422
|
table.resetColumnFilters();
|
|
414
|
-
}, children:
|
|
423
|
+
}, children: filterReset }));
|
|
415
424
|
};
|
|
416
425
|
|
|
417
426
|
const FilterDialog = ({ icon = jsx(MdFilterAlt, {}), }) => {
|
|
418
427
|
const filterModal = useDisclosure();
|
|
419
|
-
const {
|
|
420
|
-
|
|
428
|
+
const { tableLabel } = useDataTableContext();
|
|
429
|
+
const { filterButtonText, filterTitle, filterClose } = tableLabel;
|
|
430
|
+
return (jsxs(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: [jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", filterButtonText] }) }), jsxs(DialogContent, { children: [jsx(DialogHeader, { children: jsx(DialogTitle, { children: filterTitle }) }), jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsx(TableFilter, {}) }), jsxs(DialogFooter, { children: [jsx(ResetFilteringButton, {}), jsx(Button$1, { onClick: filterModal.onClose, variant: "subtle", children: filterClose })] }), jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
|
|
421
431
|
};
|
|
422
432
|
|
|
423
433
|
const MenuContent = React.forwardRef(function MenuContent(props, ref) {
|
|
@@ -536,11 +546,13 @@ const Pagination = () => {
|
|
|
536
546
|
}, children: jsxs(HStack, { children: [jsx(PaginationPrevTrigger, {}), jsx(PaginationItems, {}), jsx(PaginationNextTrigger, {})] }) }));
|
|
537
547
|
};
|
|
538
548
|
|
|
539
|
-
const ResetSelectionButton = (
|
|
549
|
+
const ResetSelectionButton = () => {
|
|
540
550
|
const { table } = useDataTableContext();
|
|
551
|
+
const { tableLabel } = useDataTableContext();
|
|
552
|
+
const { resetSelection } = tableLabel;
|
|
541
553
|
return (jsx(Button$1, { onClick: () => {
|
|
542
554
|
table.resetRowSelection();
|
|
543
|
-
}, children:
|
|
555
|
+
}, children: resetSelection }));
|
|
544
556
|
};
|
|
545
557
|
|
|
546
558
|
const RowCountText = () => {
|
|
@@ -2551,8 +2563,9 @@ const TableViewer = () => {
|
|
|
2551
2563
|
|
|
2552
2564
|
const ViewDialog = ({ icon = jsx(IoMdEye, {}) }) => {
|
|
2553
2565
|
const viewModel = useDisclosure();
|
|
2554
|
-
const {
|
|
2555
|
-
|
|
2566
|
+
const { tableLabel } = useDataTableContext();
|
|
2567
|
+
const { view } = tableLabel;
|
|
2568
|
+
return (jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", view] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsx(DialogHeader, { children: jsx(DialogTitle, { children: view }) }), jsx(DialogBody, { children: jsx(TableViewer, {}) }), jsx(DialogFooter, {})] })] }));
|
|
2556
2569
|
};
|
|
2557
2570
|
|
|
2558
2571
|
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
@@ -2828,7 +2841,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2828
2841
|
setGlobalFilter,
|
|
2829
2842
|
type: "client",
|
|
2830
2843
|
translate,
|
|
2831
|
-
columns,
|
|
2844
|
+
columns: columns,
|
|
2832
2845
|
sorting,
|
|
2833
2846
|
setSorting,
|
|
2834
2847
|
columnFilters,
|
|
@@ -2844,6 +2857,10 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2844
2857
|
columnVisibility,
|
|
2845
2858
|
setColumnVisibility,
|
|
2846
2859
|
data,
|
|
2860
|
+
tableLabel: {
|
|
2861
|
+
view: "View",
|
|
2862
|
+
edit: "Edit",
|
|
2863
|
+
},
|
|
2847
2864
|
}, children: children }));
|
|
2848
2865
|
}
|
|
2849
2866
|
|
|
@@ -2861,7 +2878,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2861
2878
|
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, }) {
|
|
2862
2879
|
const table = useReactTable({
|
|
2863
2880
|
_features: [DensityFeature],
|
|
2864
|
-
data: query.data?.data ?? [],
|
|
2881
|
+
data: (query.data?.data ?? []),
|
|
2865
2882
|
rowCount: query.data?.count ?? 0,
|
|
2866
2883
|
columns: columns,
|
|
2867
2884
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -2907,12 +2924,12 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2907
2924
|
// for tanstack-table ts bug end
|
|
2908
2925
|
});
|
|
2909
2926
|
return (jsx(DataTableContext.Provider, { value: {
|
|
2910
|
-
table:
|
|
2927
|
+
table: table,
|
|
2911
2928
|
globalFilter,
|
|
2912
2929
|
setGlobalFilter,
|
|
2913
2930
|
type: "server",
|
|
2914
2931
|
translate,
|
|
2915
|
-
columns,
|
|
2932
|
+
columns: columns,
|
|
2916
2933
|
sorting,
|
|
2917
2934
|
setSorting,
|
|
2918
2935
|
columnFilters,
|
|
@@ -2965,17 +2982,19 @@ const GlobalFilter = () => {
|
|
|
2965
2982
|
} }) }) }));
|
|
2966
2983
|
};
|
|
2967
2984
|
|
|
2968
|
-
const ReloadButton = ({
|
|
2985
|
+
const ReloadButton = ({ variant = "icon", }) => {
|
|
2969
2986
|
const { url } = useDataTableServerContext();
|
|
2970
2987
|
const queryClient = useQueryClient();
|
|
2988
|
+
const { tableLabel } = useDataTableContext();
|
|
2989
|
+
const { reloadTooltip, reloadButtonText } = tableLabel;
|
|
2971
2990
|
if (variant === "icon") {
|
|
2972
|
-
return (jsx(Tooltip, { showArrow: true, content:
|
|
2991
|
+
return (jsx(Tooltip, { showArrow: true, content: reloadTooltip, children: jsx(Button, { variant: "ghost", onClick: () => {
|
|
2973
2992
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2974
2993
|
}, "aria-label": "refresh", children: jsx(IoReload, {}) }) }));
|
|
2975
2994
|
}
|
|
2976
2995
|
return (jsxs(Button, { variant: "ghost", onClick: () => {
|
|
2977
2996
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2978
|
-
}, children: [jsx(IoReload, {}), " ",
|
|
2997
|
+
}, children: [jsx(IoReload, {}), " ", reloadButtonText] }));
|
|
2979
2998
|
};
|
|
2980
2999
|
|
|
2981
3000
|
const FilterOptions = ({ column }) => {
|
|
@@ -2984,6 +3003,7 @@ const FilterOptions = ({ column }) => {
|
|
|
2984
3003
|
const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
|
|
2985
3004
|
return (jsx(Fragment, { children: options.map((option) => {
|
|
2986
3005
|
const selected = table.getColumn(column)?.getFilterValue() === option;
|
|
3006
|
+
const { label, value } = option;
|
|
2987
3007
|
return (jsxs(Button$1, { size: "sm", onClick: () => {
|
|
2988
3008
|
if (selected) {
|
|
2989
3009
|
table.setColumnFilters((state) => {
|
|
@@ -2993,8 +3013,8 @@ const FilterOptions = ({ column }) => {
|
|
|
2993
3013
|
});
|
|
2994
3014
|
return;
|
|
2995
3015
|
}
|
|
2996
|
-
table.getColumn(column)?.setFilterValue(
|
|
2997
|
-
}, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [
|
|
3016
|
+
table.getColumn(column)?.setFilterValue(value);
|
|
3017
|
+
}, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [label, selected && jsx(MdClose, {})] }, option.value));
|
|
2998
3018
|
}) }));
|
|
2999
3019
|
};
|
|
3000
3020
|
|
|
@@ -3010,10 +3030,12 @@ const TableFilterTags = () => {
|
|
|
3010
3030
|
};
|
|
3011
3031
|
|
|
3012
3032
|
const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children = jsx(Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, showPagination = true, showPageSizeControl = true, showPageCountText = true, showView = true, filterOptions = [], extraItems = jsx(Fragment, {}), loading = false, hasError = false, gridProps = {}, }) => {
|
|
3013
|
-
const {
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3033
|
+
const { tableLabel } = useDataTableContext();
|
|
3034
|
+
const { rowCountText, hasErrorText } = tableLabel;
|
|
3035
|
+
return (jsxs(Grid, { templateRows: "auto 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", ...gridProps, children: [jsxs(Flex, { flexFlow: "column", gap: 2, children: [jsxs(Flex, { justifyContent: "space-between", children: [jsx(Box, { children: showView && jsx(ViewDialog, { icon: jsx(MdOutlineViewColumn, {}) }) }), jsxs(Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsx(Spinner, { size: "sm" }), hasError && (jsx(Tooltip, { content: hasErrorText, children: jsx(Icon, { as: BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsx(GlobalFilter, {}), showFilter && jsx(FilterDialog, {}), showReload && jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsx(Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((option) => {
|
|
3036
|
+
const { label, value } = option;
|
|
3037
|
+
return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [label, ":"] }), jsx(FilterOptions, { column: value })] }, value));
|
|
3038
|
+
}) })), showFilterTags && (jsx(Flex, { children: jsx(TableFilterTags, {}) }))] }), jsx(Grid, { overflow: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, children: children }), (showPageSizeControl || showPageCountText || showPagination) && (jsxs(Flex, { justifyContent: "space-between", children: [jsxs(Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsx(PageSizeControl, {}), showPageCountText && (jsxs(Flex, { children: [jsx(Text, { paddingRight: "0.5rem", children: rowCountText }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(Pagination, {}) })] }))] }));
|
|
3017
3039
|
};
|
|
3018
3040
|
|
|
3019
3041
|
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
@@ -3035,7 +3057,7 @@ const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
|
3035
3057
|
return (jsxs(Checkbox$1.Root, { ref: rootRef, ...rest, children: [jsx(Checkbox$1.HiddenInput, { ref: ref, ...inputProps }), jsx(Checkbox$1.Control, { children: icon || jsx(Checkbox$1.Indicator, {}) }), children != null && (jsx(Checkbox$1.Label, { children: children }))] }));
|
|
3036
3058
|
});
|
|
3037
3059
|
|
|
3038
|
-
const TableBody = ({ showSelector = false,
|
|
3060
|
+
const TableBody = ({ showSelector = false, canResize = true, }) => {
|
|
3039
3061
|
"use no memo";
|
|
3040
3062
|
const { table } = useDataTableContext();
|
|
3041
3063
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -3079,7 +3101,7 @@ const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize
|
|
|
3079
3101
|
})] }, `chakra-table-row-${row.id}`));
|
|
3080
3102
|
}) }));
|
|
3081
3103
|
};
|
|
3082
|
-
const TableRowSelector = ({
|
|
3104
|
+
const TableRowSelector = ({ row, }) => {
|
|
3083
3105
|
const { table } = useDataTableContext();
|
|
3084
3106
|
const SELECTION_BOX_WIDTH = 20;
|
|
3085
3107
|
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
@@ -3116,14 +3138,57 @@ const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
|
3116
3138
|
// styling resize and pinning start
|
|
3117
3139
|
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", children: jsx(MenuRoot$1, { children: jsx(MenuTrigger$1, { asChild: true, children: jsx(Box, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3118
3140
|
? null
|
|
3119
|
-
: flexRender(header.column.columnDef.footer, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && (
|
|
3120
|
-
// <UpDownIcon />
|
|
3121
|
-
jsx(Fragment, {})), header.column.getIsSorted() === "asc" && (jsx(BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsx(BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3141
|
+
: flexRender(header.column.columnDef.footer, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && jsx(Fragment, {}), header.column.getIsSorted() === "asc" && (jsx(BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsx(BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3122
3142
|
};
|
|
3123
3143
|
|
|
3124
|
-
|
|
3144
|
+
// Default text values
|
|
3145
|
+
const DEFAULT_HEADER_TEXTS = {
|
|
3146
|
+
pinColumn: "Pin Column",
|
|
3147
|
+
cancelPin: "Cancel Pin",
|
|
3148
|
+
sortAscending: "Sort Ascending",
|
|
3149
|
+
sortDescending: "Sort Descending",
|
|
3150
|
+
clearSorting: "Clear Sorting",
|
|
3151
|
+
};
|
|
3152
|
+
/**
|
|
3153
|
+
* TableHeader component with configurable text strings.
|
|
3154
|
+
*
|
|
3155
|
+
* @example
|
|
3156
|
+
* // Using default texts
|
|
3157
|
+
* <TableHeader />
|
|
3158
|
+
*
|
|
3159
|
+
* @example
|
|
3160
|
+
* // Customizing default texts for all columns
|
|
3161
|
+
* <TableHeader
|
|
3162
|
+
* defaultTexts={{
|
|
3163
|
+
* pinColumn: "Pin This Column",
|
|
3164
|
+
* sortAscending: "Sort A-Z"
|
|
3165
|
+
* }}
|
|
3166
|
+
* />
|
|
3167
|
+
*
|
|
3168
|
+
* @example
|
|
3169
|
+
* // Customizing texts per column via meta
|
|
3170
|
+
* const columns = [
|
|
3171
|
+
* columnHelper.accessor("name", {
|
|
3172
|
+
* header: "Name",
|
|
3173
|
+
* meta: {
|
|
3174
|
+
* headerTexts: {
|
|
3175
|
+
* pinColumn: "Pin Name Column",
|
|
3176
|
+
* sortAscending: "Sort Names A-Z"
|
|
3177
|
+
* }
|
|
3178
|
+
* }
|
|
3179
|
+
* })
|
|
3180
|
+
* ];
|
|
3181
|
+
*/
|
|
3182
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, defaultTexts = {}, }) => {
|
|
3125
3183
|
const { table } = useDataTableContext();
|
|
3126
3184
|
const SELECTION_BOX_WIDTH = 20;
|
|
3185
|
+
// Merge default texts with provided defaults
|
|
3186
|
+
const mergedDefaultTexts = { ...DEFAULT_HEADER_TEXTS, ...defaultTexts };
|
|
3187
|
+
// Helper function to get text for a specific header
|
|
3188
|
+
const getHeaderText = (header, key) => {
|
|
3189
|
+
const columnMeta = header.column.columnDef.meta;
|
|
3190
|
+
return columnMeta?.headerTexts?.[key] || mergedDefaultTexts[key];
|
|
3191
|
+
};
|
|
3127
3192
|
const getThProps = (header) => {
|
|
3128
3193
|
const thProps = header.column.getIsPinned()
|
|
3129
3194
|
? {
|
|
@@ -3177,9 +3242,9 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
|
|
|
3177
3242
|
? null
|
|
3178
3243
|
: flexRender(header.column.columnDef.header, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && jsx(Fragment, {}), header.column.getIsSorted() === "asc" && (jsx(BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsx(BiDownArrow, {}))] })) }), jsx(Box, { children: header.column.getIsFiltered() && jsx(MdFilterListAlt, {}) })] }) }) }), jsxs(MenuContent, { children: [!header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "pin-column", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3179
3244
|
header.column.pin("left");
|
|
3180
|
-
}, children: [jsx(MdPushPin, {}),
|
|
3245
|
+
}, children: [jsx(MdPushPin, {}), getHeaderText(header, "pinColumn")] }) })), header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "cancel-pin", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3181
3246
|
header.column.pin(false);
|
|
3182
|
-
}, children: [jsx(MdCancel, {}),
|
|
3247
|
+
}, children: [jsx(MdCancel, {}), getHeaderText(header, "cancelPin")] }) })), header.column.getCanSort() && (jsxs(Fragment, { children: [jsx(MenuItem, { asChild: true, value: "sort-ascend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3183
3248
|
table.setSorting((state) => {
|
|
3184
3249
|
return [
|
|
3185
3250
|
...state.filter((column) => {
|
|
@@ -3188,7 +3253,7 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
|
|
|
3188
3253
|
{ id: header.id, desc: false },
|
|
3189
3254
|
];
|
|
3190
3255
|
});
|
|
3191
|
-
}, children: [jsx(GrAscend, {}),
|
|
3256
|
+
}, children: [jsx(GrAscend, {}), getHeaderText(header, "sortAscending")] }) }), jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3192
3257
|
table.setSorting((state) => {
|
|
3193
3258
|
return [
|
|
3194
3259
|
...state.filter((column) => {
|
|
@@ -3197,9 +3262,9 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
|
|
|
3197
3262
|
{ id: header.id, desc: true },
|
|
3198
3263
|
];
|
|
3199
3264
|
});
|
|
3200
|
-
}, children: [jsx(GrDescend, {}),
|
|
3265
|
+
}, children: [jsx(GrDescend, {}), getHeaderText(header, "sortDescending")] }) }), header.column.getIsSorted() && (jsx(MenuItem, { asChild: true, value: "clear-sorting", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3201
3266
|
header.column.clearSorting();
|
|
3202
|
-
}, children: [jsx(MdClear, {}),
|
|
3267
|
+
}, children: [jsx(MdClear, {}), getHeaderText(header, "clearSorting")] }) }))] }))] })] }), canResize && (jsx(Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3203
3268
|
? "colorPalette.700"
|
|
3204
3269
|
: "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
|
|
3205
3270
|
borderRightColor: header.column.getIsResizing()
|
|
@@ -3216,11 +3281,11 @@ const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps =
|
|
|
3216
3281
|
return (jsx(TableControls, { ...controlProps, children: jsxs(Table, { ...tableProps, children: [jsx(TableHeader, { ...tableHeaderProps }), jsx(TableBody, { ...tableBodyProps }), showFooter && jsx(TableFooter, { ...tableFooterProps })] }) }));
|
|
3217
3282
|
};
|
|
3218
3283
|
|
|
3219
|
-
const TableCardContainer = ({ children, variant = "", ...props }) => {
|
|
3284
|
+
const TableCardContainer = ({ children, variant = "", gap = "1rem", gridTemplateColumns = "repeat(auto-fit, minmax(20rem, 1fr))", direction = "row", ...props }) => {
|
|
3220
3285
|
if (variant === "carousel") {
|
|
3221
|
-
return (jsx(Flex, { overflow: "
|
|
3286
|
+
return (jsx(Flex, { overflow: "auto", gap: gap, direction: direction, ...props, children: children }));
|
|
3222
3287
|
}
|
|
3223
|
-
return (jsx(Grid, { gridTemplateColumns:
|
|
3288
|
+
return (jsx(Grid, { gridTemplateColumns: gridTemplateColumns, gap: gap, ...props, children: children }));
|
|
3224
3289
|
};
|
|
3225
3290
|
|
|
3226
3291
|
const DefaultCardTitle = () => {
|
|
@@ -3249,8 +3314,8 @@ const TableComponent = ({ render = () => {
|
|
|
3249
3314
|
};
|
|
3250
3315
|
|
|
3251
3316
|
const TableLoadingComponent = ({ render, }) => {
|
|
3252
|
-
const {
|
|
3253
|
-
return jsx(Fragment, { children: render(
|
|
3317
|
+
const { query } = useDataTableServerContext();
|
|
3318
|
+
return jsx(Fragment, { children: render(query.isLoading) });
|
|
3254
3319
|
};
|
|
3255
3320
|
|
|
3256
3321
|
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
@@ -3470,10 +3535,7 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3470
3535
|
};
|
|
3471
3536
|
|
|
3472
3537
|
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3473
|
-
const {
|
|
3474
|
-
const columnDef = table._getColumnDefs();
|
|
3475
|
-
console.log(columnDef, "glp");
|
|
3476
|
-
console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
|
|
3538
|
+
const { columns, translate, data } = useDataTableContext();
|
|
3477
3539
|
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3478
3540
|
const { accessorKey, id } = def;
|
|
3479
3541
|
if (accessorKey) {
|
|
@@ -3619,7 +3681,7 @@ const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, childre
|
|
|
3619
3681
|
};
|
|
3620
3682
|
|
|
3621
3683
|
function removeIndex(str) {
|
|
3622
|
-
return str.replace(/\.\d+\./g,
|
|
3684
|
+
return str.replace(/\.\d+\./g, ".");
|
|
3623
3685
|
}
|
|
3624
3686
|
|
|
3625
3687
|
const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
@@ -3637,7 +3699,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3637
3699
|
}, children: [jsx(Grid, { gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsx(SchemaRenderer, { column: `${index}`,
|
|
3638
3700
|
prefix: `${colLabel}.`,
|
|
3639
3701
|
// @ts-expect-error find suitable types
|
|
3640
|
-
schema: {
|
|
3702
|
+
schema: { showLabel: false, ...(items ?? {}) } }) }), jsx(Flex, { justifyContent: "end", children: jsx(Button$1, { variant: "ghost", onClick: () => {
|
|
3641
3703
|
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
3642
3704
|
return curIndex !== index;
|
|
3643
3705
|
}));
|
|
@@ -4529,7 +4591,7 @@ const NumberInputField = ({ schema, column, prefix, }) => {
|
|
|
4529
4591
|
};
|
|
4530
4592
|
|
|
4531
4593
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
4532
|
-
const { properties, gridColumn = "span 12", gridRow = "span 1", required,
|
|
4594
|
+
const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
|
|
4533
4595
|
const { translate } = useSchemaContext();
|
|
4534
4596
|
const colLabel = `${prefix}${column}`;
|
|
4535
4597
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -4537,7 +4599,7 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4537
4599
|
if (properties === undefined) {
|
|
4538
4600
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4539
4601
|
}
|
|
4540
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [
|
|
4602
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [showLabel && (jsxs(Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] })), jsx(Grid, { bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: 2, borderRadius: 4, borderWidth: 1, borderColor: {
|
|
4541
4603
|
base: "colorPalette.200",
|
|
4542
4604
|
_dark: "colorPalette.800",
|
|
4543
4605
|
}, gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: Object.keys(properties ?? {}).map((key) => {
|
|
@@ -4954,7 +5016,7 @@ const ArrayViewer = ({ schema, column, prefix }) => {
|
|
|
4954
5016
|
}, children: jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsx(SchemaViewer, { column: `${index}`,
|
|
4955
5017
|
prefix: `${colLabel}.`,
|
|
4956
5018
|
// @ts-expect-error find suitable types
|
|
4957
|
-
schema: {
|
|
5019
|
+
schema: { showLabel: false, ...(items ?? {}) } }) }) }, `form-${prefix}${column}.${index}`))) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4958
5020
|
};
|
|
4959
5021
|
|
|
4960
5022
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4994,6 +5056,10 @@ const DateViewer = ({ column, schema, prefix }) => {
|
|
|
4994
5056
|
gridRow, children: [jsxs(Text, { children: [" ", selectedDate !== undefined ? displayDate : ""] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4995
5057
|
};
|
|
4996
5058
|
|
|
5059
|
+
function translateWrapper({ prefix, column, label, translate, }) {
|
|
5060
|
+
return translate.t(removeIndex(`${prefix}${column}.${label}`));
|
|
5061
|
+
}
|
|
5062
|
+
|
|
4997
5063
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
4998
5064
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4999
5065
|
const { translate } = useSchemaContext();
|
|
@@ -5003,16 +5069,19 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
5003
5069
|
const colLabel = `${prefix}${column}`;
|
|
5004
5070
|
const watchEnum = watch(colLabel);
|
|
5005
5071
|
const watchEnums = (watch(colLabel) ?? []);
|
|
5006
|
-
|
|
5072
|
+
const customTranslate = (label) => {
|
|
5073
|
+
return translateWrapper({ prefix, column, label, translate });
|
|
5074
|
+
};
|
|
5075
|
+
return (jsxs(Field, { label: `${customTranslate(`field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
5007
5076
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
5008
5077
|
const item = enumValue;
|
|
5009
5078
|
if (item === undefined) {
|
|
5010
5079
|
return jsx(Fragment, { children: "undefined" });
|
|
5011
5080
|
}
|
|
5012
|
-
return (jsx(Tag, {
|
|
5081
|
+
return (jsx(Tag, { children: !!renderDisplay === true
|
|
5013
5082
|
? renderDisplay(item)
|
|
5014
|
-
:
|
|
5015
|
-
}) })), !isMultiple &&
|
|
5083
|
+
: customTranslate(item) }));
|
|
5084
|
+
}) })), !isMultiple && jsx(Text, { children: customTranslate(watchEnum) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: customTranslate(`field_required`) }))] }));
|
|
5016
5085
|
};
|
|
5017
5086
|
|
|
5018
5087
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
@@ -5069,7 +5138,7 @@ const NumberViewer = ({ schema, column, prefix, }) => {
|
|
|
5069
5138
|
};
|
|
5070
5139
|
|
|
5071
5140
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
5072
|
-
const { properties, gridColumn = "span 12", gridRow = "span 1", required,
|
|
5141
|
+
const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
|
|
5073
5142
|
const { translate } = useSchemaContext();
|
|
5074
5143
|
const colLabel = `${prefix}${column}`;
|
|
5075
5144
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -5077,7 +5146,7 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
5077
5146
|
if (properties === undefined) {
|
|
5078
5147
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
5079
5148
|
}
|
|
5080
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [
|
|
5149
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [showLabel && (jsxs(Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] })), jsx(Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: "1", borderRadius: "md", borderWidth: "thin", borderColor: {
|
|
5081
5150
|
base: "colorPalette.200",
|
|
5082
5151
|
_dark: "colorPalette.800",
|
|
5083
5152
|
}, children: Object.keys(properties ?? {}).map((key) => {
|
|
@@ -8,5 +8,19 @@ export interface DataTableContext<TData = unknown> extends DataTableProps {
|
|
|
8
8
|
setGlobalFilter: OnChangeFn<string>;
|
|
9
9
|
type: "client" | "server";
|
|
10
10
|
translate: UseTranslationResponse<any, unknown>;
|
|
11
|
+
tableLabel: {
|
|
12
|
+
view: string;
|
|
13
|
+
edit: string;
|
|
14
|
+
filterButtonText: string;
|
|
15
|
+
filterTitle: string;
|
|
16
|
+
filterReset: string;
|
|
17
|
+
filterClose: string;
|
|
18
|
+
reloadTooltip: string;
|
|
19
|
+
reloadButtonText: string;
|
|
20
|
+
resetSelection: string;
|
|
21
|
+
resetSorting: string;
|
|
22
|
+
rowCountText: string;
|
|
23
|
+
hasErrorText: string;
|
|
24
|
+
};
|
|
11
25
|
}
|
|
12
26
|
export declare const DataTableContext: import("react").Context<DataTableContext<unknown>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export interface ReloadButtonProps {
|
|
2
|
-
text?: string;
|
|
3
2
|
variant?: string;
|
|
4
3
|
}
|
|
5
|
-
export declare const ReloadButton: ({
|
|
4
|
+
export declare const ReloadButton: ({ variant, }: ReloadButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
text?: string;
|
|
3
|
-
}
|
|
4
|
-
export declare const ResetFilteringButton: ({ text, }: ResetFilteringButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare const ResetFilteringButton: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
text?: string;
|
|
3
|
-
}
|
|
4
|
-
export declare const ResetSelectionButton: ({ text, }: ResetSelectionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare const ResetSelectionButton: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
text?: string;
|
|
3
|
-
}
|
|
4
|
-
export declare const ResetSortingButton: ({ text, }: ResetSortingButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare const ResetSortingButton: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,7 +14,10 @@ export interface TableControlsProps {
|
|
|
14
14
|
showPageSizeControl?: boolean;
|
|
15
15
|
showPageCountText?: boolean;
|
|
16
16
|
showView?: boolean;
|
|
17
|
-
filterOptions?:
|
|
17
|
+
filterOptions?: {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
18
21
|
extraItems?: ReactNode;
|
|
19
22
|
loading?: boolean;
|
|
20
23
|
hasError?: boolean;
|
|
@@ -16,6 +16,5 @@ export interface TableRowSelectorProps<TData> {
|
|
|
16
16
|
light: string;
|
|
17
17
|
dark: string;
|
|
18
18
|
};
|
|
19
|
-
alwaysShowSelector?: boolean;
|
|
20
19
|
}
|
|
21
|
-
export declare const TableBody: ({ showSelector,
|
|
20
|
+
export declare const TableBody: ({ showSelector, canResize, }: TableBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BoxProps, FlexProps } from "@chakra-ui/react";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
export interface TableCardContainerProps extends
|
|
3
|
+
export interface TableCardContainerProps extends BoxProps {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
variant?: "carousel" | "";
|
|
6
|
+
gap?: string;
|
|
7
|
+
gridTemplateColumns?: string;
|
|
8
|
+
direction?: FlexProps["direction"];
|
|
6
9
|
}
|
|
7
|
-
export declare const TableCardContainer: ({ children, variant, ...props }: TableCardContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const TableCardContainer: ({ children, variant, gap, gridTemplateColumns, direction, ...props }: TableCardContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
import { TableHeaderProps as ChakraTableHeaderProps, TableRowProps } from "@chakra-ui/react";
|
|
2
|
+
export interface TableHeaderTexts {
|
|
3
|
+
pinColumn?: string;
|
|
4
|
+
cancelPin?: string;
|
|
5
|
+
sortAscending?: string;
|
|
6
|
+
sortDescending?: string;
|
|
7
|
+
clearSorting?: string;
|
|
8
|
+
}
|
|
2
9
|
export interface TableHeaderProps {
|
|
3
10
|
canResize?: boolean;
|
|
4
11
|
showSelector?: boolean;
|
|
5
12
|
isSticky?: boolean;
|
|
6
13
|
tableHeaderProps?: ChakraTableHeaderProps;
|
|
7
14
|
tableRowProps?: TableRowProps;
|
|
15
|
+
/**
|
|
16
|
+
* Default text configuration for all columns.
|
|
17
|
+
* Can be overridden per column via meta.headerTexts.
|
|
18
|
+
*/
|
|
19
|
+
defaultTexts?: TableHeaderTexts;
|
|
8
20
|
}
|
|
9
|
-
|
|
21
|
+
/**
|
|
22
|
+
* TableHeader component with configurable text strings.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Using default texts
|
|
26
|
+
* <TableHeader />
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Customizing default texts for all columns
|
|
30
|
+
* <TableHeader
|
|
31
|
+
* defaultTexts={{
|
|
32
|
+
* pinColumn: "Pin This Column",
|
|
33
|
+
* sortAscending: "Sort A-Z"
|
|
34
|
+
* }}
|
|
35
|
+
* />
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Customizing texts per column via meta
|
|
39
|
+
* const columns = [
|
|
40
|
+
* columnHelper.accessor("name", {
|
|
41
|
+
* header: "Name",
|
|
42
|
+
* meta: {
|
|
43
|
+
* headerTexts: {
|
|
44
|
+
* pinColumn: "Pin Name Column",
|
|
45
|
+
* sortAscending: "Sort Names A-Z"
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* })
|
|
49
|
+
* ];
|
|
50
|
+
*/
|
|
51
|
+
export declare const TableHeader: ({ canResize, showSelector, isSticky, tableHeaderProps, tableRowProps, defaultTexts, }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|