@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.js CHANGED
@@ -91,6 +91,10 @@ const DataTableContext = React.createContext({
91
91
  },
92
92
  rowSelection: {},
93
93
  columnVisibility: {},
94
+ tableLabel: {
95
+ view: "View",
96
+ edit: "Edit",
97
+ },
94
98
  });
95
99
 
96
100
  const useDataTableContext = () => {
@@ -146,11 +150,13 @@ const TableSorter = () => {
146
150
  }) }))) }));
147
151
  };
148
152
 
149
- const ResetSortingButton = ({ text = "Reset Sorting", }) => {
153
+ const ResetSortingButton = () => {
150
154
  const { table } = useDataTableContext();
155
+ const { tableLabel } = useDataTableContext();
156
+ const { resetSorting } = tableLabel;
151
157
  return (jsxRuntime.jsx(react.Button, { onClick: () => {
152
158
  table.resetSorting();
153
- }, children: text }));
159
+ }, children: resetSorting }));
154
160
  };
155
161
 
156
162
  const EditSortingButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineSort, {}), title = "Edit Sorting", }) => {
@@ -361,10 +367,11 @@ const Filter = ({ column }) => {
361
367
  if (filterVariant === "select") {
362
368
  return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RadioGroup, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onValueChange: (details) => {
363
369
  column.setFilterValue(details.value);
364
- }, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: "0.5rem", children: filterOptions.map((item) => (jsxRuntime.jsx(Radio, { value: item, children: item }, item))) }) })] }, column.id));
370
+ }, children: jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: "0.5rem", children: [filterOptions.length === 0 && jsxRuntime.jsx(react.Text, { children: "No filter options" }), filterOptions.length > 0 &&
371
+ filterOptions.map((item) => (jsxRuntime.jsx(Radio, { value: item.value, children: item.label }, item.value)))] }) })] }, column.id));
365
372
  }
366
373
  if (filterVariant === "tag") {
367
- return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(TagFilter, { availableTags: filterOptions, selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
374
+ return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(TagFilter, { availableTags: filterOptions.map((item) => item.value), selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
368
375
  if (tags.length === 0) {
369
376
  return column.setFilterValue(undefined);
370
377
  }
@@ -427,17 +434,20 @@ const TableFilter = () => {
427
434
  }) }));
428
435
  };
429
436
 
430
- const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
437
+ const ResetFilteringButton = () => {
431
438
  const { table } = useDataTableContext();
439
+ const { tableLabel } = useDataTableContext();
440
+ const { filterReset } = tableLabel;
432
441
  return (jsxRuntime.jsx(react.Button, { onClick: () => {
433
442
  table.resetColumnFilters();
434
- }, children: text }));
443
+ }, children: filterReset }));
435
444
  };
436
445
 
437
446
  const FilterDialog = ({ icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
438
447
  const filterModal = react.useDisclosure();
439
- const { translate } = useDataTableContext();
440
- return (jsxRuntime.jsxs(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", translate.t("filter_dialog.button_text")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("filter_dialog.title") }) }), jsxRuntime.jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsxRuntime.jsx(TableFilter, {}) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(ResetFilteringButton, { text: translate.t("filter_dialog.reset") }), jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, variant: "subtle", children: translate.t("filter_dialog.close") })] }), jsxRuntime.jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
448
+ const { tableLabel } = useDataTableContext();
449
+ const { filterButtonText, filterTitle, filterClose } = tableLabel;
450
+ return (jsxRuntime.jsxs(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", filterButtonText] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: filterTitle }) }), jsxRuntime.jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsxRuntime.jsx(TableFilter, {}) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(ResetFilteringButton, {}), jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, variant: "subtle", children: filterClose })] }), jsxRuntime.jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
441
451
  };
442
452
 
443
453
  const MenuContent = React__namespace.forwardRef(function MenuContent(props, ref) {
@@ -556,11 +566,13 @@ const Pagination = () => {
556
566
  }, children: jsxRuntime.jsxs(react.HStack, { children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), jsxRuntime.jsx(PaginationItems, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) }));
557
567
  };
558
568
 
559
- const ResetSelectionButton = ({ text = "Reset Selection", }) => {
569
+ const ResetSelectionButton = () => {
560
570
  const { table } = useDataTableContext();
571
+ const { tableLabel } = useDataTableContext();
572
+ const { resetSelection } = tableLabel;
561
573
  return (jsxRuntime.jsx(react.Button, { onClick: () => {
562
574
  table.resetRowSelection();
563
- }, children: text }));
575
+ }, children: resetSelection }));
564
576
  };
565
577
 
566
578
  const RowCountText = () => {
@@ -2571,8 +2583,9 @@ const TableViewer = () => {
2571
2583
 
2572
2584
  const ViewDialog = ({ icon = jsxRuntime.jsx(io.IoMdEye, {}) }) => {
2573
2585
  const viewModel = react.useDisclosure();
2574
- const { translate } = useDataTableContext();
2575
- 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, " ", translate.t("view_dialog.button_text")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("view_dialog.title") }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }));
2586
+ const { tableLabel } = useDataTableContext();
2587
+ const { view } = tableLabel;
2588
+ 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, {})] })] }));
2576
2589
  };
2577
2590
 
2578
2591
  const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
@@ -2848,7 +2861,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
2848
2861
  setGlobalFilter,
2849
2862
  type: "client",
2850
2863
  translate,
2851
- columns,
2864
+ columns: columns,
2852
2865
  sorting,
2853
2866
  setSorting,
2854
2867
  columnFilters,
@@ -2864,6 +2877,10 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
2864
2877
  columnVisibility,
2865
2878
  setColumnVisibility,
2866
2879
  data,
2880
+ tableLabel: {
2881
+ view: "View",
2882
+ edit: "Edit",
2883
+ },
2867
2884
  }, children: children }));
2868
2885
  }
2869
2886
 
@@ -2881,7 +2898,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
2881
2898
  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, }) {
2882
2899
  const table = reactTable.useReactTable({
2883
2900
  _features: [DensityFeature],
2884
- data: query.data?.data ?? [],
2901
+ data: (query.data?.data ?? []),
2885
2902
  rowCount: query.data?.count ?? 0,
2886
2903
  columns: columns,
2887
2904
  getCoreRowModel: reactTable.getCoreRowModel(),
@@ -2927,12 +2944,12 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
2927
2944
  // for tanstack-table ts bug end
2928
2945
  });
2929
2946
  return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
2930
- table: { ...table },
2947
+ table: table,
2931
2948
  globalFilter,
2932
2949
  setGlobalFilter,
2933
2950
  type: "server",
2934
2951
  translate,
2935
- columns,
2952
+ columns: columns,
2936
2953
  sorting,
2937
2954
  setSorting,
2938
2955
  columnFilters,
@@ -2985,17 +3002,19 @@ const GlobalFilter = () => {
2985
3002
  } }) }) }));
2986
3003
  };
2987
3004
 
2988
- const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
3005
+ const ReloadButton = ({ variant = "icon", }) => {
2989
3006
  const { url } = useDataTableServerContext();
2990
3007
  const queryClient = reactQuery.useQueryClient();
3008
+ const { tableLabel } = useDataTableContext();
3009
+ const { reloadTooltip, reloadButtonText } = tableLabel;
2991
3010
  if (variant === "icon") {
2992
- return (jsxRuntime.jsx(Tooltip, { showArrow: true, content: "This is the tooltip content", children: jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => {
3011
+ return (jsxRuntime.jsx(Tooltip, { showArrow: true, content: reloadTooltip, children: jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => {
2993
3012
  queryClient.invalidateQueries({ queryKey: [url] });
2994
3013
  }, "aria-label": "refresh", children: jsxRuntime.jsx(io5.IoReload, {}) }) }));
2995
3014
  }
2996
3015
  return (jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
2997
3016
  queryClient.invalidateQueries({ queryKey: [url] });
2998
- }, children: [jsxRuntime.jsx(io5.IoReload, {}), " ", text] }));
3017
+ }, children: [jsxRuntime.jsx(io5.IoReload, {}), " ", reloadButtonText] }));
2999
3018
  };
3000
3019
 
3001
3020
  const FilterOptions = ({ column }) => {
@@ -3004,6 +3023,7 @@ const FilterOptions = ({ column }) => {
3004
3023
  const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
3005
3024
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: options.map((option) => {
3006
3025
  const selected = table.getColumn(column)?.getFilterValue() === option;
3026
+ const { label, value } = option;
3007
3027
  return (jsxRuntime.jsxs(react.Button, { size: "sm", onClick: () => {
3008
3028
  if (selected) {
3009
3029
  table.setColumnFilters((state) => {
@@ -3013,8 +3033,8 @@ const FilterOptions = ({ column }) => {
3013
3033
  });
3014
3034
  return;
3015
3035
  }
3016
- table.getColumn(column)?.setFilterValue(option);
3017
- }, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [option, selected && jsxRuntime.jsx(md.MdClose, {})] }, option));
3036
+ table.getColumn(column)?.setFilterValue(value);
3037
+ }, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [label, selected && jsxRuntime.jsx(md.MdClose, {})] }, option.value));
3018
3038
  }) }));
3019
3039
  };
3020
3040
 
@@ -3030,10 +3050,12 @@ const TableFilterTags = () => {
3030
3050
  };
3031
3051
 
3032
3052
  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, filterOptions = [], extraItems = jsxRuntime.jsx(jsxRuntime.Fragment, {}), loading = false, hasError = false, gridProps = {}, }) => {
3033
- const { translate } = useDataTableContext();
3034
- 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: translate.t("has_error"), children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsxRuntime.jsx(GlobalFilter, {}), showFilter && jsxRuntime.jsx(FilterDialog, {}), showReload && jsxRuntime.jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
3035
- return (jsxRuntime.jsxs(react.Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxRuntime.jsxs(react.Text, { children: [column, ":"] }), jsxRuntime.jsx(FilterOptions, { column: column })] }, column));
3036
- }) })), 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: translate.t("rowcount.total") }), jsxRuntime.jsx(RowCountText, {})] }))] }), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: showPagination && jsxRuntime.jsx(Pagination, {}) })] }))] }));
3053
+ const { tableLabel } = useDataTableContext();
3054
+ const { rowCountText, hasErrorText } = tableLabel;
3055
+ 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] })] }), filterOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((option) => {
3056
+ const { label, value } = option;
3057
+ return (jsxRuntime.jsxs(react.Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxRuntime.jsxs(react.Text, { children: [label, ":"] }), jsxRuntime.jsx(FilterOptions, { column: value })] }, value));
3058
+ }) })), 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, {}) })] }))] }));
3037
3059
  };
3038
3060
 
3039
3061
  const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
@@ -3055,7 +3077,7 @@ const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
3055
3077
  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 }))] }));
3056
3078
  });
3057
3079
 
3058
- const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
3080
+ const TableBody = ({ showSelector = false, canResize = true, }) => {
3059
3081
  "use no memo";
3060
3082
  const { table } = useDataTableContext();
3061
3083
  const SELECTION_BOX_WIDTH = 20;
@@ -3099,7 +3121,7 @@ const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize
3099
3121
  })] }, `chakra-table-row-${row.id}`));
3100
3122
  }) }));
3101
3123
  };
3102
- const TableRowSelector = ({ index, row, }) => {
3124
+ const TableRowSelector = ({ row, }) => {
3103
3125
  const { table } = useDataTableContext();
3104
3126
  const SELECTION_BOX_WIDTH = 20;
3105
3127
  return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
@@ -3136,14 +3158,57 @@ const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
3136
3158
  // styling resize and pinning start
3137
3159
  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
3138
3160
  ? null
3139
- : 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 && (
3140
- // <UpDownIcon />
3141
- 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}`))) }));
3161
+ : 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}`))) }));
3142
3162
  };
3143
3163
 
3144
- const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
3164
+ // Default text values
3165
+ const DEFAULT_HEADER_TEXTS = {
3166
+ pinColumn: "Pin Column",
3167
+ cancelPin: "Cancel Pin",
3168
+ sortAscending: "Sort Ascending",
3169
+ sortDescending: "Sort Descending",
3170
+ clearSorting: "Clear Sorting",
3171
+ };
3172
+ /**
3173
+ * TableHeader component with configurable text strings.
3174
+ *
3175
+ * @example
3176
+ * // Using default texts
3177
+ * <TableHeader />
3178
+ *
3179
+ * @example
3180
+ * // Customizing default texts for all columns
3181
+ * <TableHeader
3182
+ * defaultTexts={{
3183
+ * pinColumn: "Pin This Column",
3184
+ * sortAscending: "Sort A-Z"
3185
+ * }}
3186
+ * />
3187
+ *
3188
+ * @example
3189
+ * // Customizing texts per column via meta
3190
+ * const columns = [
3191
+ * columnHelper.accessor("name", {
3192
+ * header: "Name",
3193
+ * meta: {
3194
+ * headerTexts: {
3195
+ * pinColumn: "Pin Name Column",
3196
+ * sortAscending: "Sort Names A-Z"
3197
+ * }
3198
+ * }
3199
+ * })
3200
+ * ];
3201
+ */
3202
+ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, defaultTexts = {}, }) => {
3145
3203
  const { table } = useDataTableContext();
3146
3204
  const SELECTION_BOX_WIDTH = 20;
3205
+ // Merge default texts with provided defaults
3206
+ const mergedDefaultTexts = { ...DEFAULT_HEADER_TEXTS, ...defaultTexts };
3207
+ // Helper function to get text for a specific header
3208
+ const getHeaderText = (header, key) => {
3209
+ const columnMeta = header.column.columnDef.meta;
3210
+ return columnMeta?.headerTexts?.[key] || mergedDefaultTexts[key];
3211
+ };
3147
3212
  const getThProps = (header) => {
3148
3213
  const thProps = header.column.getIsPinned()
3149
3214
  ? {
@@ -3197,9 +3262,9 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
3197
3262
  ? null
3198
3263
  : reactTable.flexRender(header.column.columnDef.header, 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, {}))] })) }), jsxRuntime.jsx(react.Box, { children: header.column.getIsFiltered() && jsxRuntime.jsx(md.MdFilterListAlt, {}) })] }) }) }), jsxRuntime.jsxs(MenuContent, { children: [!header.column.getIsPinned() && (jsxRuntime.jsx(MenuItem, { asChild: true, value: "pin-column", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3199
3264
  header.column.pin("left");
3200
- }, children: [jsxRuntime.jsx(md.MdPushPin, {}), "Pin Column"] }) })), header.column.getIsPinned() && (jsxRuntime.jsx(MenuItem, { asChild: true, value: "cancel-pin", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3265
+ }, children: [jsxRuntime.jsx(md.MdPushPin, {}), getHeaderText(header, "pinColumn")] }) })), header.column.getIsPinned() && (jsxRuntime.jsx(MenuItem, { asChild: true, value: "cancel-pin", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3201
3266
  header.column.pin(false);
3202
- }, children: [jsxRuntime.jsx(md.MdCancel, {}), "Cancel Pin"] }) })), header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { asChild: true, value: "sort-ascend", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3267
+ }, children: [jsxRuntime.jsx(md.MdCancel, {}), getHeaderText(header, "cancelPin")] }) })), header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { asChild: true, value: "sort-ascend", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3203
3268
  table.setSorting((state) => {
3204
3269
  return [
3205
3270
  ...state.filter((column) => {
@@ -3208,7 +3273,7 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
3208
3273
  { id: header.id, desc: false },
3209
3274
  ];
3210
3275
  });
3211
- }, children: [jsxRuntime.jsx(gr.GrAscend, {}), "Sort Ascending"] }) }), jsxRuntime.jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3276
+ }, children: [jsxRuntime.jsx(gr.GrAscend, {}), getHeaderText(header, "sortAscending")] }) }), jsxRuntime.jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3212
3277
  table.setSorting((state) => {
3213
3278
  return [
3214
3279
  ...state.filter((column) => {
@@ -3217,9 +3282,9 @@ const TableHeader = ({ canResize = true, showSelector = false, isSticky = true,
3217
3282
  { id: header.id, desc: true },
3218
3283
  ];
3219
3284
  });
3220
- }, children: [jsxRuntime.jsx(gr.GrDescend, {}), "Sort Descending"] }) }), header.column.getIsSorted() && (jsxRuntime.jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3285
+ }, children: [jsxRuntime.jsx(gr.GrDescend, {}), getHeaderText(header, "sortDescending")] }) }), header.column.getIsSorted() && (jsxRuntime.jsx(MenuItem, { asChild: true, value: "clear-sorting", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
3221
3286
  header.column.clearSorting();
3222
- }, children: [jsxRuntime.jsx(md.MdClear, {}), "Clear Sorting"] }) }))] }))] })] }), canResize && (jsxRuntime.jsx(react.Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
3287
+ }, children: [jsxRuntime.jsx(md.MdClear, {}), getHeaderText(header, "clearSorting")] }) }))] }))] })] }), canResize && (jsxRuntime.jsx(react.Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
3223
3288
  ? "colorPalette.700"
3224
3289
  : "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
3225
3290
  borderRightColor: header.column.getIsResizing()
@@ -3236,11 +3301,11 @@ const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps =
3236
3301
  return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { ...tableProps, children: [jsxRuntime.jsx(TableHeader, { ...tableHeaderProps }), jsxRuntime.jsx(TableBody, { ...tableBodyProps }), showFooter && jsxRuntime.jsx(TableFooter, { ...tableFooterProps })] }) }));
3237
3302
  };
3238
3303
 
3239
- const TableCardContainer = ({ children, variant = "", ...props }) => {
3304
+ const TableCardContainer = ({ children, variant = "", gap = "1rem", gridTemplateColumns = "repeat(auto-fit, minmax(20rem, 1fr))", direction = "row", ...props }) => {
3240
3305
  if (variant === "carousel") {
3241
- return (jsxRuntime.jsx(react.Flex, { overflow: "scroll", gap: "1rem", children: children }));
3306
+ return (jsxRuntime.jsx(react.Flex, { overflow: "auto", gap: gap, direction: direction, ...props, children: children }));
3242
3307
  }
3243
- return (jsxRuntime.jsx(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", gap: "0.5rem", ...props, children: children }));
3308
+ return (jsxRuntime.jsx(react.Grid, { gridTemplateColumns: gridTemplateColumns, gap: gap, ...props, children: children }));
3244
3309
  };
3245
3310
 
3246
3311
  const DefaultCardTitle = () => {
@@ -3269,8 +3334,8 @@ const TableComponent = ({ render = () => {
3269
3334
  };
3270
3335
 
3271
3336
  const TableLoadingComponent = ({ render, }) => {
3272
- const { loading } = useDataTableContext();
3273
- return jsxRuntime.jsx(jsxRuntime.Fragment, { children: render(loading) });
3337
+ const { query } = useDataTableServerContext();
3338
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: render(query.isLoading) });
3274
3339
  };
3275
3340
 
3276
3341
  const SelectAllRowsToggle = ({ selectAllIcon = jsxRuntime.jsx(md.MdOutlineChecklist, {}), clearAllIcon = jsxRuntime.jsx(md.MdClear, {}), selectAllText = "", clearAllText = "", }) => {
@@ -3490,10 +3555,7 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
3490
3555
  };
3491
3556
 
3492
3557
  const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
3493
- const { table, columns, translate, data } = useDataTableContext();
3494
- const columnDef = table._getColumnDefs();
3495
- console.log(columnDef, "glp");
3496
- console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
3558
+ const { columns, translate, data } = useDataTableContext();
3497
3559
  const columnsMap = Object.fromEntries(columns.map((def) => {
3498
3560
  const { accessorKey, id } = def;
3499
3561
  if (accessorKey) {
@@ -3639,7 +3701,7 @@ const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, childre
3639
3701
  };
3640
3702
 
3641
3703
  function removeIndex(str) {
3642
- return str.replace(/\.\d+\./g, '.');
3704
+ return str.replace(/\.\d+\./g, ".");
3643
3705
  }
3644
3706
 
3645
3707
  const ArrayRenderer = ({ schema, column, prefix, }) => {
@@ -3657,7 +3719,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
3657
3719
  }, children: [jsxRuntime.jsx(react.Grid, { gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsxRuntime.jsx(SchemaRenderer, { column: `${index}`,
3658
3720
  prefix: `${colLabel}.`,
3659
3721
  // @ts-expect-error find suitable types
3660
- schema: { showTitle: false, ...(items ?? {}) } }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(react.Button, { variant: "ghost", onClick: () => {
3722
+ schema: { showLabel: false, ...(items ?? {}) } }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(react.Button, { variant: "ghost", onClick: () => {
3661
3723
  setValue(colLabel, fields.filter((_, curIndex) => {
3662
3724
  return curIndex !== index;
3663
3725
  }));
@@ -4549,7 +4611,7 @@ const NumberInputField = ({ schema, column, prefix, }) => {
4549
4611
  };
4550
4612
 
4551
4613
  const ObjectInput = ({ schema, column, prefix }) => {
4552
- const { properties, gridColumn = "span 12", gridRow = "span 1", required, showTitle = true, } = schema;
4614
+ const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
4553
4615
  const { translate } = useSchemaContext();
4554
4616
  const colLabel = `${prefix}${column}`;
4555
4617
  const isRequired = required?.some((columnId) => columnId === column);
@@ -4557,7 +4619,7 @@ const ObjectInput = ({ schema, column, prefix }) => {
4557
4619
  if (properties === undefined) {
4558
4620
  throw new Error(`properties is undefined when using ObjectInput`);
4559
4621
  }
4560
- return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [showTitle && (jsxRuntime.jsxs(react.Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] })), jsxRuntime.jsx(react.Grid, { bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: 2, borderRadius: 4, borderWidth: 1, borderColor: {
4622
+ return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [showLabel && (jsxRuntime.jsxs(react.Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] })), jsxRuntime.jsx(react.Grid, { bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: 2, borderRadius: 4, borderWidth: 1, borderColor: {
4561
4623
  base: "colorPalette.200",
4562
4624
  _dark: "colorPalette.800",
4563
4625
  }, gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: Object.keys(properties ?? {}).map((key) => {
@@ -4974,7 +5036,7 @@ const ArrayViewer = ({ schema, column, prefix }) => {
4974
5036
  }, children: jsxRuntime.jsx(react.Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsxRuntime.jsx(SchemaViewer, { column: `${index}`,
4975
5037
  prefix: `${colLabel}.`,
4976
5038
  // @ts-expect-error find suitable types
4977
- schema: { showTitle: false, ...(items ?? {}) } }) }) }, `form-${prefix}${column}.${index}`))) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
5039
+ schema: { showLabel: false, ...(items ?? {}) } }) }) }, `form-${prefix}${column}.${index}`))) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
4978
5040
  };
4979
5041
 
4980
5042
  const BooleanViewer = ({ schema, column, prefix, }) => {
@@ -5014,6 +5076,10 @@ const DateViewer = ({ column, schema, prefix }) => {
5014
5076
  gridRow, children: [jsxRuntime.jsxs(react.Text, { children: [" ", selectedDate !== undefined ? displayDate : ""] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
5015
5077
  };
5016
5078
 
5079
+ function translateWrapper({ prefix, column, label, translate, }) {
5080
+ return translate.t(removeIndex(`${prefix}${column}.${label}`));
5081
+ }
5082
+
5017
5083
  const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
5018
5084
  const { watch, formState: { errors }, } = reactHookForm.useFormContext();
5019
5085
  const { translate } = useSchemaContext();
@@ -5023,16 +5089,19 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
5023
5089
  const colLabel = `${prefix}${column}`;
5024
5090
  const watchEnum = watch(colLabel);
5025
5091
  const watchEnums = (watch(colLabel) ?? []);
5026
- return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
5092
+ const customTranslate = (label) => {
5093
+ return translateWrapper({ prefix, column, label, translate });
5094
+ };
5095
+ return (jsxRuntime.jsxs(Field, { label: `${customTranslate(`field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn,
5027
5096
  gridRow, children: [isMultiple && (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
5028
5097
  const item = enumValue;
5029
5098
  if (item === undefined) {
5030
5099
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
5031
5100
  }
5032
- return (jsxRuntime.jsx(Tag, { closable: true, children: !!renderDisplay === true
5101
+ return (jsxRuntime.jsx(Tag, { children: !!renderDisplay === true
5033
5102
  ? renderDisplay(item)
5034
- : translate.t(removeIndex(`${colLabel}.${item}`)) }));
5035
- }) })), !isMultiple && (jsxRuntime.jsx(react.Text, { children: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
5103
+ : customTranslate(item) }));
5104
+ }) })), !isMultiple && jsxRuntime.jsx(react.Text, { children: customTranslate(watchEnum) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: customTranslate(`field_required`) }))] }));
5036
5105
  };
5037
5106
 
5038
5107
  const FileViewer = ({ column, schema, prefix }) => {
@@ -5089,7 +5158,7 @@ const NumberViewer = ({ schema, column, prefix, }) => {
5089
5158
  };
5090
5159
 
5091
5160
  const ObjectViewer = ({ schema, column, prefix }) => {
5092
- const { properties, gridColumn = "span 12", gridRow = "span 1", required, showTitle = true, } = schema;
5161
+ const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
5093
5162
  const { translate } = useSchemaContext();
5094
5163
  const colLabel = `${prefix}${column}`;
5095
5164
  const isRequired = required?.some((columnId) => columnId === column);
@@ -5097,7 +5166,7 @@ const ObjectViewer = ({ schema, column, prefix }) => {
5097
5166
  if (properties === undefined) {
5098
5167
  throw new Error(`properties is undefined when using ObjectInput`);
5099
5168
  }
5100
- return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [showTitle && (jsxRuntime.jsxs(react.Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] })), jsxRuntime.jsx(react.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: {
5169
+ return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [showLabel && (jsxRuntime.jsxs(react.Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] })), jsxRuntime.jsx(react.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: {
5101
5170
  base: "colorPalette.200",
5102
5171
  _dark: "colorPalette.800",
5103
5172
  }, children: Object.keys(properties ?? {}).map((key) => {