@bsol-oss/react-datatable5 9.2.0 → 11.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -26,11 +26,11 @@ var reactQuery = require('@tanstack/react-query');
26
26
  var io5 = require('react-icons/io5');
27
27
  var gr = require('react-icons/gr');
28
28
  var hi = require('react-icons/hi');
29
+ var reactI18next = require('react-i18next');
29
30
  var axios = require('axios');
30
31
  var reactHookForm = require('react-hook-form');
31
32
  var dayjs = require('dayjs');
32
33
  var ti = require('react-icons/ti');
33
- var reactI18next = require('react-i18next');
34
34
 
35
35
  function _interopNamespaceDefault(e) {
36
36
  var n = Object.create(null);
@@ -56,6 +56,7 @@ const DataTableContext = React.createContext({
56
56
  globalFilter: "",
57
57
  setGlobalFilter: () => { },
58
58
  type: "client",
59
+ translate: {},
59
60
  });
60
61
 
61
62
  const useDataTableContext = () => {
@@ -95,7 +96,7 @@ react.Dialog.Backdrop;
95
96
  const DialogTitle = react.Dialog.Title;
96
97
  react.Dialog.Description;
97
98
  const DialogTrigger = react.Dialog.Trigger;
98
- const DialogActionTrigger = react.Dialog.ActionTrigger;
99
+ react.Dialog.ActionTrigger;
99
100
 
100
101
  const Radio = React__namespace.forwardRef(function Radio(props, ref) {
101
102
  const { children, inputProps, rootRef, ...rest } = props;
@@ -373,9 +374,10 @@ const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
373
374
  }, children: text }));
374
375
  };
375
376
 
376
- const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
377
+ const FilterDialog = ({ icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
377
378
  const filterModal = react.useDisclosure();
378
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: title }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "1rem", children: [jsxRuntime.jsx(TableFilter, {}), jsxRuntime.jsx(ResetFilteringButton, { text: resetText })] }) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(DialogActionTrigger, { asChild: true, children: jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, children: closeText }) }), jsxRuntime.jsx(react.Button, { children: "Save" })] }), jsxRuntime.jsx(DialogCloseTrigger, {})] })] }) }) }));
379
+ const { translate } = useDataTableContext();
380
+ 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("filterDialog.buttonText")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("filterDialog.title") }) }), jsxRuntime.jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsxRuntime.jsx(TableFilter, {}) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(ResetFilteringButton, { text: translate.t("filterDialog.reset") }), jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, variant: "subtle", children: translate.t("filterDialog.close") })] }), jsxRuntime.jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
379
381
  };
380
382
 
381
383
  const ColumnOrderChanger = ({ columns }) => {
@@ -2452,9 +2454,10 @@ const TableViewer = () => {
2452
2454
  }) }));
2453
2455
  };
2454
2456
 
2455
- const EditViewButton = ({ text, icon = jsxRuntime.jsx(io.IoMdEye, {}), title = "Edit View", }) => {
2457
+ const ViewDialog = ({ icon = jsxRuntime.jsx(io.IoMdEye, {}) }) => {
2456
2458
  const viewModel = react.useDisclosure();
2457
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: 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, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsx(DialogTitle, {}), title] }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }) }));
2459
+ const { translate } = useDataTableContext();
2460
+ 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("viewDialog.buttonText")] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: translate.t("viewDialog.title") }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(TableViewer, {}) }), jsxRuntime.jsx(DialogFooter, {})] })] }));
2458
2461
  };
2459
2462
 
2460
2463
  const MenuContent = React__namespace.forwardRef(function MenuContent(props, ref) {
@@ -2490,9 +2493,9 @@ const MenuTrigger = react.Menu.Trigger;
2490
2493
 
2491
2494
  const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
2492
2495
  const { table } = useDataTableContext();
2493
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(MenuRoot, { children: [jsxRuntime.jsx(MenuTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsxRuntime.jsx(bi.BiDownArrow, {})] }) }), jsxRuntime.jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsxRuntime.jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
2494
- table.setPageSize(Number(pageSize));
2495
- }, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }) }));
2496
+ return (jsxRuntime.jsxs(MenuRoot, { children: [jsxRuntime.jsx(MenuTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsxRuntime.jsx(bi.BiDownArrow, {})] }) }), jsxRuntime.jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsxRuntime.jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
2497
+ table.setPageSize(Number(pageSize));
2498
+ }, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }));
2496
2499
  };
2497
2500
 
2498
2501
  const ResetSelectionButton = ({ text = "Reset Selection", }) => {
@@ -2578,7 +2581,7 @@ const PaginationPageText = React__namespace.forwardRef(function PaginationPageTe
2578
2581
  });
2579
2582
 
2580
2583
  // TODO: not working in client side
2581
- const TablePagination = () => {
2584
+ const Pagination = () => {
2582
2585
  const { table, type } = useDataTableContext();
2583
2586
  const getCount = () => {
2584
2587
  if (type === "client") {
@@ -2801,7 +2804,7 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
2801
2804
  *
2802
2805
  * @link https://tanstack.com/table/latest/docs/guide/column-defs
2803
2806
  */
2804
- 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, children, }) {
2807
+ 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, }) {
2805
2808
  const table = reactTable.useReactTable({
2806
2809
  _features: [DensityFeature],
2807
2810
  data: data,
@@ -2850,9 +2853,10 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
2850
2853
  });
2851
2854
  return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
2852
2855
  table: table,
2853
- globalFilter: globalFilter,
2854
- setGlobalFilter: setGlobalFilter,
2856
+ globalFilter,
2857
+ setGlobalFilter,
2855
2858
  type: "client",
2859
+ translate,
2856
2860
  }, children: children }));
2857
2861
  }
2858
2862
 
@@ -2871,7 +2875,7 @@ const DataTableServerContext = React.createContext({
2871
2875
  *
2872
2876
  * @link https://tanstack.com/table/latest/docs/guide/column-defs
2873
2877
  */
2874
- 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, children, url, }) {
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, }) {
2875
2879
  const table = reactTable.useReactTable({
2876
2880
  _features: [DensityFeature],
2877
2881
  data: query.data?.data ?? [],
@@ -2924,6 +2928,7 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
2924
2928
  globalFilter,
2925
2929
  setGlobalFilter,
2926
2930
  type: "server",
2931
+ translate,
2927
2932
  }, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
2928
2933
  }
2929
2934
 
@@ -3093,12 +3098,13 @@ const TableFilterTags = () => {
3093
3098
  }) }));
3094
3099
  };
3095
3100
 
3096
- const TableControls = ({ totalText = "Total:", fitTableWidth = false, fitTableHeight = false, isMobile = false, children = jsxRuntime.jsx(jsxRuntime.Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, showPagination = true, showPageSizeControl = true, showPageCountText = true, filterOptions = [], extraItems = jsxRuntime.jsx(jsxRuntime.Fragment, {}), loading = false, hasError = false, }) => {
3097
- return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr auto", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", children: [jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsx(react.Box, { children: jsxRuntime.jsx(EditViewButton, { text: isMobile ? undefined : "View", 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: "An error occurred while fetching data", children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsxRuntime.jsx(GlobalFilter, {}), showFilter && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(EditFilterButton, { text: isMobile ? undefined : "Advanced Filter" }) })), showReload && jsxRuntime.jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
3101
+ 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, }) => {
3102
+ const { translate } = useDataTableContext();
3103
+ return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr auto", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", 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("hasError"), 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) => {
3098
3104
  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));
3099
3105
  }) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Grid, { overflow: "auto", backgroundColor: "gray.50", _dark: {
3100
3106
  backgroundColor: "gray.900",
3101
- }, children: children }), 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: totalText }), jsxRuntime.jsx(RowCountText, {})] }))] }), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: showPagination && jsxRuntime.jsx(TablePagination, {}) })] })] }));
3107
+ }, children: children }), 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, {}) })] })] }));
3102
3108
  };
3103
3109
 
3104
3110
  const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
@@ -3357,7 +3363,7 @@ const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: def
3357
3363
  columnVisibility: {},
3358
3364
  globalFilter: "",
3359
3365
  density: "sm",
3360
- }, } = {
3366
+ }, keyPrefix = "", } = {
3361
3367
  default: {
3362
3368
  sorting: [],
3363
3369
  pagination: {
@@ -3380,6 +3386,7 @@ const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: def
3380
3386
  const [globalFilter, setGlobalFilter] = React.useState(defaultGlobalFilter);
3381
3387
  const [density, setDensity] = React.useState(defaultDensity);
3382
3388
  const [columnVisibility, setColumnVisibility] = React.useState(defaultColumnVisibility);
3389
+ const translate = reactI18next.useTranslation("", { keyPrefix });
3383
3390
  return {
3384
3391
  sorting,
3385
3392
  setSorting,
@@ -3397,6 +3404,7 @@ const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: def
3397
3404
  setDensity,
3398
3405
  columnVisibility,
3399
3406
  setColumnVisibility,
3407
+ translate,
3400
3408
  };
3401
3409
  };
3402
3410
 
@@ -3415,10 +3423,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
3415
3423
  columnVisibility: {},
3416
3424
  globalFilter: "",
3417
3425
  density: "sm",
3418
- },
3419
- // debounce = true,
3420
- // debounceDelay = 1000,
3421
- }) => {
3426
+ }, keyPrefix, }) => {
3422
3427
  const [sorting, setSorting] = React.useState(defaultSorting);
3423
3428
  const [columnFilters, setColumnFilters] = React.useState(defaultColumnFilters); // can set initial column filter state here
3424
3429
  const [pagination, setPagination] = React.useState(defaultPagination);
@@ -3448,6 +3453,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
3448
3453
  data: [],
3449
3454
  },
3450
3455
  });
3456
+ const translate = reactI18next.useTranslation("", { keyPrefix });
3451
3457
  return {
3452
3458
  sorting,
3453
3459
  setSorting,
@@ -3466,6 +3472,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
3466
3472
  columnVisibility,
3467
3473
  setColumnVisibility,
3468
3474
  query,
3475
+ translate,
3469
3476
  };
3470
3477
  };
3471
3478
 
@@ -3548,11 +3555,12 @@ const ErrorAlert = ({ showMessage = true }) => {
3548
3555
  const SchemaFormContext = React.createContext({
3549
3556
  schema: {},
3550
3557
  serverUrl: "",
3558
+ requestUrl: "",
3551
3559
  order: [],
3552
3560
  ignore: [],
3553
3561
  onSubmit: async () => { },
3554
3562
  rowNumber: 0,
3555
- displayText: {},
3563
+ requestOptions: {},
3556
3564
  });
3557
3565
 
3558
3566
  const PopoverContent = React__namespace.forwardRef(function PopoverContent(props, ref) {
@@ -3579,10 +3587,11 @@ const Field = React__namespace.forwardRef(function Field(props, ref) {
3579
3587
  });
3580
3588
 
3581
3589
  const useSchemaContext = () => {
3582
- const { schema, serverUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, } = React.useContext(SchemaFormContext);
3590
+ const { schema, serverUrl, requestUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, requestOptions, } = React.useContext(SchemaFormContext);
3583
3591
  return {
3584
3592
  schema,
3585
3593
  serverUrl,
3594
+ requestUrl,
3586
3595
  order,
3587
3596
  ignore,
3588
3597
  onSubmit,
@@ -3590,6 +3599,7 @@ const useSchemaContext = () => {
3590
3599
  idMap,
3591
3600
  setIdMap,
3592
3601
  translate,
3602
+ requestOptions,
3593
3603
  };
3594
3604
  };
3595
3605
 
@@ -3603,10 +3613,6 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
3603
3613
  const options = {
3604
3614
  method: "GET",
3605
3615
  url: `${serverUrl}/api/g/${in_table}`,
3606
- headers: {
3607
- Apikey: "YOUR_SECRET_TOKEN",
3608
- "Content-Type": "application/json",
3609
- },
3610
3616
  params: {
3611
3617
  searching,
3612
3618
  where,
@@ -4534,7 +4540,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
4534
4540
  }
4535
4541
  };
4536
4542
  const FormInternal = () => {
4537
- const { schema, serverUrl, order, ignore, onSubmit, rowNumber, idMap, translate, } = useSchemaContext();
4543
+ const { schema, requestUrl, order, ignore, onSubmit, rowNumber, idMap, translate, requestOptions, } = useSchemaContext();
4538
4544
  const methods = reactHookForm.useFormContext();
4539
4545
  const [isSuccess, setIsSuccess] = React.useState(false);
4540
4546
  const [isError, setIsError] = React.useState(false);
@@ -4573,12 +4579,9 @@ const FormInternal = () => {
4573
4579
  const defaultSubmitPromise = (data) => {
4574
4580
  const options = {
4575
4581
  method: "POST",
4576
- url: `${serverUrl}/api/g/${schema.title}`,
4577
- headers: {
4578
- Apikey: "YOUR_SECRET_TOKEN",
4579
- "Content-Type": "application/json",
4580
- },
4582
+ url: `${requestUrl}`,
4581
4583
  data: clearEmptyString(data),
4584
+ ...requestOptions,
4582
4585
  };
4583
4586
  return axios.request(options);
4584
4587
  };
@@ -4765,7 +4768,7 @@ const FormInternal = () => {
4765
4768
  methods.handleSubmit(onValid)();
4766
4769
  }, formNoValidate: true, children: translate.t("submit") })] }), isError && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["isError", jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" ", `${error}`] })] }))] }));
4767
4770
  };
4768
- const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, preLoadedValues = {}, rowNumber = undefined, }) => {
4771
+ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, preLoadedValues = {}, rowNumber = undefined, requestOptions = {}, }) => {
4769
4772
  const { properties } = schema;
4770
4773
  idListSanityCheck("order", order, properties);
4771
4774
  idListSanityCheck("ignore", ignore, properties);
@@ -4781,6 +4784,7 @@ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [],
4781
4784
  idMap,
4782
4785
  setIdMap,
4783
4786
  translate,
4787
+ requestOptions,
4784
4788
  }, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FormInternal, {}) }) }));
4785
4789
  };
4786
4790
 
@@ -4819,16 +4823,16 @@ exports.DataTableServer = DataTableServer;
4819
4823
  exports.DefaultCardTitle = DefaultCardTitle;
4820
4824
  exports.DefaultTable = DefaultTable;
4821
4825
  exports.DensityToggleButton = DensityToggleButton;
4822
- exports.EditFilterButton = EditFilterButton;
4823
4826
  exports.EditOrderButton = EditOrderButton;
4824
4827
  exports.EditSortingButton = EditSortingButton;
4825
- exports.EditViewButton = EditViewButton;
4826
4828
  exports.EmptyState = EmptyState;
4827
4829
  exports.ErrorAlert = ErrorAlert;
4830
+ exports.FilterDialog = FilterDialog;
4828
4831
  exports.FilterOptions = FilterOptions;
4829
4832
  exports.Form = Form;
4830
4833
  exports.GlobalFilter = GlobalFilter;
4831
4834
  exports.PageSizeControl = PageSizeControl;
4835
+ exports.Pagination = Pagination;
4832
4836
  exports.RecordDisplay = RecordDisplay;
4833
4837
  exports.ReloadButton = ReloadButton;
4834
4838
  exports.ResetFilteringButton = ResetFilteringButton;
@@ -4847,11 +4851,11 @@ exports.TableFooter = TableFooter;
4847
4851
  exports.TableHeader = TableHeader;
4848
4852
  exports.TableLoadingComponent = TableLoadingComponent;
4849
4853
  exports.TableOrderer = TableOrderer;
4850
- exports.TablePagination = TablePagination;
4851
4854
  exports.TableSelector = TableSelector;
4852
4855
  exports.TableSorter = TableSorter;
4853
4856
  exports.TableViewer = TableViewer;
4854
4857
  exports.TextCell = TextCell;
4858
+ exports.ViewDialog = ViewDialog;
4855
4859
  exports.getColumns = getColumns;
4856
4860
  exports.getMultiDates = getMultiDates;
4857
4861
  exports.getRangeDates = getRangeDates;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Flex, Text, Tag as Tag$1, Input, useDisclosure, DialogBackdrop, CheckboxCard as CheckboxCard$1, Menu, createRecipeContext, createContext as createContext$1, Pagination, usePaginationContext, Image, Card, DataList, Checkbox as Checkbox$1, Table as Table$1, Tooltip as Tooltip$1, Group, InputElement, Icon, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, EmptyState as EmptyState$2, VStack, List, Alert, Popover, Field as Field$1, HoverCard, NumberInput, Accordion, Show, RadioCard, CheckboxGroup, Heading, Center } from '@chakra-ui/react';
2
+ import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Flex, Text, Tag as Tag$1, Input, useDisclosure, DialogBackdrop, CheckboxCard as CheckboxCard$1, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, Image, Card, DataList, Checkbox as Checkbox$1, Table as Table$1, Tooltip as Tooltip$1, Group, InputElement, Icon, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, EmptyState as EmptyState$2, VStack, List, Alert, Popover, Field as Field$1, HoverCard, NumberInput, Accordion, Show, RadioCard, CheckboxGroup, Heading, Center } from '@chakra-ui/react';
3
3
  import { AiOutlineColumnWidth } from 'react-icons/ai';
4
4
  import * as React from 'react';
5
5
  import React__default, { createContext, useContext, useState, useEffect, useRef } from 'react';
@@ -25,17 +25,18 @@ import { useQueryClient, useQuery } from '@tanstack/react-query';
25
25
  import { IoReload } from 'react-icons/io5';
26
26
  import { GrAscend, GrDescend } from 'react-icons/gr';
27
27
  import { HiColorSwatch, HiOutlineInformationCircle } from 'react-icons/hi';
28
+ import { useTranslation } from 'react-i18next';
28
29
  import axios from 'axios';
29
30
  import { useFormContext, FormProvider, useForm as useForm$1 } from 'react-hook-form';
30
31
  import dayjs from 'dayjs';
31
32
  import { TiDeleteOutline } from 'react-icons/ti';
32
- import { useTranslation } from 'react-i18next';
33
33
 
34
34
  const DataTableContext = createContext({
35
35
  table: {},
36
36
  globalFilter: "",
37
37
  setGlobalFilter: () => { },
38
38
  type: "client",
39
+ translate: {},
39
40
  });
40
41
 
41
42
  const useDataTableContext = () => {
@@ -75,7 +76,7 @@ Dialog.Backdrop;
75
76
  const DialogTitle = Dialog.Title;
76
77
  Dialog.Description;
77
78
  const DialogTrigger = Dialog.Trigger;
78
- const DialogActionTrigger = Dialog.ActionTrigger;
79
+ Dialog.ActionTrigger;
79
80
 
80
81
  const Radio = React.forwardRef(function Radio(props, ref) {
81
82
  const { children, inputProps, rootRef, ...rest } = props;
@@ -353,9 +354,10 @@ const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
353
354
  }, children: text }));
354
355
  };
355
356
 
356
- const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsx(MdFilterAlt, {}), }) => {
357
+ const FilterDialog = ({ icon = jsx(MdFilterAlt, {}), }) => {
357
358
  const filterModal = useDisclosure();
358
- return (jsx(Fragment, { children: jsx(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: jsxs(DialogRoot, { children: [jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", text] }) }), jsxs(DialogContent, { children: [jsx(DialogHeader, { children: jsx(DialogTitle, { children: title }) }), jsx(DialogBody, { children: jsxs(Flex, { flexFlow: "column", gap: "1rem", children: [jsx(TableFilter, {}), jsx(ResetFilteringButton, { text: resetText })] }) }), jsxs(DialogFooter, { children: [jsx(DialogActionTrigger, { asChild: true, children: jsx(Button$1, { onClick: filterModal.onClose, children: closeText }) }), jsx(Button$1, { children: "Save" })] }), jsx(DialogCloseTrigger, {})] })] }) }) }));
359
+ const { translate } = useDataTableContext();
360
+ 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, " ", translate.t("filterDialog.buttonText")] }) }), jsxs(DialogContent, { children: [jsx(DialogHeader, { children: jsx(DialogTitle, { children: translate.t("filterDialog.title") }) }), jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsx(TableFilter, {}) }), jsxs(DialogFooter, { children: [jsx(ResetFilteringButton, { text: translate.t("filterDialog.reset") }), jsx(Button$1, { onClick: filterModal.onClose, variant: "subtle", children: translate.t("filterDialog.close") })] }), jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
359
361
  };
360
362
 
361
363
  const ColumnOrderChanger = ({ columns }) => {
@@ -2432,9 +2434,10 @@ const TableViewer = () => {
2432
2434
  }) }));
2433
2435
  };
2434
2436
 
2435
- const EditViewButton = ({ text, icon = jsx(IoMdEye, {}), title = "Edit View", }) => {
2437
+ const ViewDialog = ({ icon = jsx(IoMdEye, {}) }) => {
2436
2438
  const viewModel = useDisclosure();
2437
- return (jsx(Fragment, { children: jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", text] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsxs(DialogHeader, { children: [jsx(DialogTitle, {}), title] }), jsx(DialogBody, { children: jsx(TableViewer, {}) }), jsx(DialogFooter, {})] })] }) }));
2439
+ const { translate } = useDataTableContext();
2440
+ return (jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", translate.t("viewDialog.buttonText")] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsx(DialogHeader, { children: jsx(DialogTitle, { children: translate.t("viewDialog.title") }) }), jsx(DialogBody, { children: jsx(TableViewer, {}) }), jsx(DialogFooter, {})] })] }));
2438
2441
  };
2439
2442
 
2440
2443
  const MenuContent = React.forwardRef(function MenuContent(props, ref) {
@@ -2470,9 +2473,9 @@ const MenuTrigger = Menu.Trigger;
2470
2473
 
2471
2474
  const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
2472
2475
  const { table } = useDataTableContext();
2473
- return (jsx(Fragment, { children: jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsxs(Button$1, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsx(BiDownArrow, {})] }) }), jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
2474
- table.setPageSize(Number(pageSize));
2475
- }, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }) }));
2476
+ return (jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsxs(Button$1, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsx(BiDownArrow, {})] }) }), jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
2477
+ table.setPageSize(Number(pageSize));
2478
+ }, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }));
2476
2479
  };
2477
2480
 
2478
2481
  const ResetSelectionButton = ({ text = "Reset Selection", }) => {
@@ -2507,11 +2510,11 @@ const variantMap = {
2507
2510
  };
2508
2511
  const PaginationRoot = React.forwardRef(function PaginationRoot(props, ref) {
2509
2512
  const { size = "sm", variant = "outline", getHref, ...rest } = props;
2510
- return (jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsx(Pagination.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
2513
+ return (jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsx(Pagination$1.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
2511
2514
  });
2512
2515
  const PaginationEllipsis = React.forwardRef(function PaginationEllipsis(props, ref) {
2513
2516
  const { size, variantMap } = useRootProps();
2514
- return (jsx(Pagination.Ellipsis, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { as: "span", variant: variantMap.ellipsis, size: size, children: jsx(HiMiniEllipsisHorizontal, {}) }) }));
2517
+ return (jsx(Pagination$1.Ellipsis, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { as: "span", variant: variantMap.ellipsis, size: size, children: jsx(HiMiniEllipsisHorizontal, {}) }) }));
2515
2518
  });
2516
2519
  const PaginationItem = React.forwardRef(function PaginationItem(props, ref) {
2517
2520
  const { page } = usePaginationContext();
@@ -2521,7 +2524,7 @@ const PaginationItem = React.forwardRef(function PaginationItem(props, ref) {
2521
2524
  if (getHref) {
2522
2525
  return (jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
2523
2526
  }
2524
- return (jsx(Pagination.Item, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { variant: variant, size: size, children: props.value }) }));
2527
+ return (jsx(Pagination$1.Item, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { variant: variant, size: size, children: props.value }) }));
2525
2528
  });
2526
2529
  const PaginationPrevTrigger = React.forwardRef(function PaginationPrevTrigger(props, ref) {
2527
2530
  const { size, variantMap, getHref } = useRootProps();
@@ -2529,7 +2532,7 @@ const PaginationPrevTrigger = React.forwardRef(function PaginationPrevTrigger(pr
2529
2532
  if (getHref) {
2530
2533
  return (jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }));
2531
2534
  }
2532
- return (jsx(Pagination.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }) }));
2535
+ return (jsx(Pagination$1.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }) }));
2533
2536
  });
2534
2537
  const PaginationNextTrigger = React.forwardRef(function PaginationNextTrigger(props, ref) {
2535
2538
  const { size, variantMap, getHref } = useRootProps();
@@ -2537,10 +2540,10 @@ const PaginationNextTrigger = React.forwardRef(function PaginationNextTrigger(pr
2537
2540
  if (getHref) {
2538
2541
  return (jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }));
2539
2542
  }
2540
- return (jsx(Pagination.NextTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }) }));
2543
+ return (jsx(Pagination$1.NextTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }) }));
2541
2544
  });
2542
2545
  const PaginationItems = (props) => {
2543
- return (jsx(Pagination.Context, { children: ({ pages }) => pages.map((page, index) => {
2546
+ return (jsx(Pagination$1.Context, { children: ({ pages }) => pages.map((page, index) => {
2544
2547
  return page.type === "ellipsis" ? (jsx(PaginationEllipsis, { index: index, ...props }, index)) : (jsx(PaginationItem, { type: "page", value: page.value, ...props }, index));
2545
2548
  }) }));
2546
2549
  };
@@ -2558,7 +2561,7 @@ const PaginationPageText = React.forwardRef(function PaginationPageText(props, r
2558
2561
  });
2559
2562
 
2560
2563
  // TODO: not working in client side
2561
- const TablePagination = () => {
2564
+ const Pagination = () => {
2562
2565
  const { table, type } = useDataTableContext();
2563
2566
  const getCount = () => {
2564
2567
  if (type === "client") {
@@ -2781,7 +2784,7 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
2781
2784
  *
2782
2785
  * @link https://tanstack.com/table/latest/docs/guide/column-defs
2783
2786
  */
2784
- 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, children, }) {
2787
+ 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, }) {
2785
2788
  const table = useReactTable({
2786
2789
  _features: [DensityFeature],
2787
2790
  data: data,
@@ -2830,9 +2833,10 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
2830
2833
  });
2831
2834
  return (jsx(DataTableContext.Provider, { value: {
2832
2835
  table: table,
2833
- globalFilter: globalFilter,
2834
- setGlobalFilter: setGlobalFilter,
2836
+ globalFilter,
2837
+ setGlobalFilter,
2835
2838
  type: "client",
2839
+ translate,
2836
2840
  }, children: children }));
2837
2841
  }
2838
2842
 
@@ -2851,7 +2855,7 @@ const DataTableServerContext = createContext({
2851
2855
  *
2852
2856
  * @link https://tanstack.com/table/latest/docs/guide/column-defs
2853
2857
  */
2854
- 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, children, url, }) {
2858
+ 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, }) {
2855
2859
  const table = useReactTable({
2856
2860
  _features: [DensityFeature],
2857
2861
  data: query.data?.data ?? [],
@@ -2904,6 +2908,7 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
2904
2908
  globalFilter,
2905
2909
  setGlobalFilter,
2906
2910
  type: "server",
2911
+ translate,
2907
2912
  }, children: jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
2908
2913
  }
2909
2914
 
@@ -3073,12 +3078,13 @@ const TableFilterTags = () => {
3073
3078
  }) }));
3074
3079
  };
3075
3080
 
3076
- const TableControls = ({ totalText = "Total:", fitTableWidth = false, fitTableHeight = false, isMobile = false, children = jsx(Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, showPagination = true, showPageSizeControl = true, showPageCountText = true, filterOptions = [], extraItems = jsx(Fragment, {}), loading = false, hasError = false, }) => {
3077
- return (jsxs(Grid, { templateRows: "auto 1fr auto", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", children: [jsxs(Flex, { flexFlow: "column", gap: 2, children: [jsxs(Flex, { justifyContent: "space-between", children: [jsx(Box, { children: jsx(EditViewButton, { text: isMobile ? undefined : "View", icon: jsx(MdOutlineViewColumn, {}) }) }), jsxs(Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsx(Spinner, { size: "sm" }), hasError && (jsx(Tooltip, { content: "An error occurred while fetching data", children: jsx(Icon, { as: BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsx(GlobalFilter, {}), showFilter && (jsx(Fragment, { children: jsx(EditFilterButton, { text: isMobile ? undefined : "Advanced Filter" }) })), showReload && jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsx(Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
3081
+ 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, }) => {
3082
+ const { translate } = useDataTableContext();
3083
+ return (jsxs(Grid, { templateRows: "auto 1fr auto", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", 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: translate.t("hasError"), 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((column) => {
3078
3084
  return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [column, ":"] }), jsx(FilterOptions, { column: column })] }, column));
3079
3085
  }) })), showFilterTags && (jsx(Flex, { children: jsx(TableFilterTags, {}) }))] }), jsx(Grid, { overflow: "auto", backgroundColor: "gray.50", _dark: {
3080
3086
  backgroundColor: "gray.900",
3081
- }, children: children }), 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: totalText }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(TablePagination, {}) })] })] }));
3087
+ }, children: children }), 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: translate.t("rowcount.total") }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(Pagination, {}) })] })] }));
3082
3088
  };
3083
3089
 
3084
3090
  const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
@@ -3337,7 +3343,7 @@ const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: def
3337
3343
  columnVisibility: {},
3338
3344
  globalFilter: "",
3339
3345
  density: "sm",
3340
- }, } = {
3346
+ }, keyPrefix = "", } = {
3341
3347
  default: {
3342
3348
  sorting: [],
3343
3349
  pagination: {
@@ -3360,6 +3366,7 @@ const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: def
3360
3366
  const [globalFilter, setGlobalFilter] = useState(defaultGlobalFilter);
3361
3367
  const [density, setDensity] = useState(defaultDensity);
3362
3368
  const [columnVisibility, setColumnVisibility] = useState(defaultColumnVisibility);
3369
+ const translate = useTranslation("", { keyPrefix });
3363
3370
  return {
3364
3371
  sorting,
3365
3372
  setSorting,
@@ -3377,6 +3384,7 @@ const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: def
3377
3384
  setDensity,
3378
3385
  columnVisibility,
3379
3386
  setColumnVisibility,
3387
+ translate,
3380
3388
  };
3381
3389
  };
3382
3390
 
@@ -3395,10 +3403,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
3395
3403
  columnVisibility: {},
3396
3404
  globalFilter: "",
3397
3405
  density: "sm",
3398
- },
3399
- // debounce = true,
3400
- // debounceDelay = 1000,
3401
- }) => {
3406
+ }, keyPrefix, }) => {
3402
3407
  const [sorting, setSorting] = useState(defaultSorting);
3403
3408
  const [columnFilters, setColumnFilters] = useState(defaultColumnFilters); // can set initial column filter state here
3404
3409
  const [pagination, setPagination] = useState(defaultPagination);
@@ -3428,6 +3433,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
3428
3433
  data: [],
3429
3434
  },
3430
3435
  });
3436
+ const translate = useTranslation("", { keyPrefix });
3431
3437
  return {
3432
3438
  sorting,
3433
3439
  setSorting,
@@ -3446,6 +3452,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
3446
3452
  columnVisibility,
3447
3453
  setColumnVisibility,
3448
3454
  query,
3455
+ translate,
3449
3456
  };
3450
3457
  };
3451
3458
 
@@ -3528,11 +3535,12 @@ const ErrorAlert = ({ showMessage = true }) => {
3528
3535
  const SchemaFormContext = createContext({
3529
3536
  schema: {},
3530
3537
  serverUrl: "",
3538
+ requestUrl: "",
3531
3539
  order: [],
3532
3540
  ignore: [],
3533
3541
  onSubmit: async () => { },
3534
3542
  rowNumber: 0,
3535
- displayText: {},
3543
+ requestOptions: {},
3536
3544
  });
3537
3545
 
3538
3546
  const PopoverContent = React.forwardRef(function PopoverContent(props, ref) {
@@ -3559,10 +3567,11 @@ const Field = React.forwardRef(function Field(props, ref) {
3559
3567
  });
3560
3568
 
3561
3569
  const useSchemaContext = () => {
3562
- const { schema, serverUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, } = useContext(SchemaFormContext);
3570
+ const { schema, serverUrl, requestUrl, order, ignore, onSubmit, rowNumber, idMap, setIdMap, translate, requestOptions, } = useContext(SchemaFormContext);
3563
3571
  return {
3564
3572
  schema,
3565
3573
  serverUrl,
3574
+ requestUrl,
3566
3575
  order,
3567
3576
  ignore,
3568
3577
  onSubmit,
@@ -3570,6 +3579,7 @@ const useSchemaContext = () => {
3570
3579
  idMap,
3571
3580
  setIdMap,
3572
3581
  translate,
3582
+ requestOptions,
3573
3583
  };
3574
3584
  };
3575
3585
 
@@ -3583,10 +3593,6 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
3583
3593
  const options = {
3584
3594
  method: "GET",
3585
3595
  url: `${serverUrl}/api/g/${in_table}`,
3586
- headers: {
3587
- Apikey: "YOUR_SECRET_TOKEN",
3588
- "Content-Type": "application/json",
3589
- },
3590
3596
  params: {
3591
3597
  searching,
3592
3598
  where,
@@ -4514,7 +4520,7 @@ const idPickerSanityCheck = (column, foreign_key) => {
4514
4520
  }
4515
4521
  };
4516
4522
  const FormInternal = () => {
4517
- const { schema, serverUrl, order, ignore, onSubmit, rowNumber, idMap, translate, } = useSchemaContext();
4523
+ const { schema, requestUrl, order, ignore, onSubmit, rowNumber, idMap, translate, requestOptions, } = useSchemaContext();
4518
4524
  const methods = useFormContext();
4519
4525
  const [isSuccess, setIsSuccess] = useState(false);
4520
4526
  const [isError, setIsError] = useState(false);
@@ -4553,12 +4559,9 @@ const FormInternal = () => {
4553
4559
  const defaultSubmitPromise = (data) => {
4554
4560
  const options = {
4555
4561
  method: "POST",
4556
- url: `${serverUrl}/api/g/${schema.title}`,
4557
- headers: {
4558
- Apikey: "YOUR_SECRET_TOKEN",
4559
- "Content-Type": "application/json",
4560
- },
4562
+ url: `${requestUrl}`,
4561
4563
  data: clearEmptyString(data),
4564
+ ...requestOptions,
4562
4565
  };
4563
4566
  return axios.request(options);
4564
4567
  };
@@ -4745,7 +4748,7 @@ const FormInternal = () => {
4745
4748
  methods.handleSubmit(onValid)();
4746
4749
  }, formNoValidate: true, children: translate.t("submit") })] }), isError && (jsxs(Fragment, { children: ["isError", jsxs(Fragment, { children: [" ", `${error}`] })] }))] }));
4747
4750
  };
4748
- const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, preLoadedValues = {}, rowNumber = undefined, }) => {
4751
+ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [], ignore = [], onSubmit = undefined, preLoadedValues = {}, rowNumber = undefined, requestOptions = {}, }) => {
4749
4752
  const { properties } = schema;
4750
4753
  idListSanityCheck("order", order, properties);
4751
4754
  idListSanityCheck("ignore", ignore, properties);
@@ -4761,6 +4764,7 @@ const Form = ({ schema, idMap, setIdMap, form, serverUrl, translate, order = [],
4761
4764
  idMap,
4762
4765
  setIdMap,
4763
4766
  translate,
4767
+ requestOptions,
4764
4768
  }, children: jsx(FormProvider, { ...form, children: jsx(FormInternal, {}) }) }));
4765
4769
  };
4766
4770
 
@@ -4792,4 +4796,4 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
4792
4796
  }
4793
4797
  };
4794
4798
 
4795
- export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultTable, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, EmptyState, ErrorAlert, FilterOptions, Form, GlobalFilter, PageSizeControl, RecordDisplay, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, getColumns, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
4799
+ export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultTable, DensityToggleButton, EditOrderButton, EditSortingButton, EmptyState, ErrorAlert, FilterDialog, FilterOptions, Form, GlobalFilter, PageSizeControl, Pagination, RecordDisplay, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TableSelector, TableSorter, TableViewer, TextCell, ViewDialog, getColumns, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };