@bsol-oss/react-datatable5 12.0.0-beta.2 → 12.0.0-beta.20
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 +90 -86
- package/dist/index.js +515 -486
- package/dist/index.mjs +512 -485
- package/dist/types/components/DataTable/DataTable.d.ts +1 -1
- package/dist/types/components/DataTable/DataTableServer.d.ts +1 -1
- package/dist/types/components/DataTable/DefaultTable.d.ts +9 -12
- package/dist/types/components/DataTable/components/TextCell.d.ts +10 -0
- package/dist/types/components/DataTable/context/DataTableContext.d.ts +2 -1
- package/dist/types/components/DataTable/controls/DensityFeature.d.ts +23 -0
- package/dist/types/components/DataTable/controls/DensityToggleButton.d.ts +6 -0
- package/dist/types/components/DataTable/controls/EditSortingButton.d.ts +7 -0
- package/dist/types/components/DataTable/controls/FilterDialog.d.ts +5 -0
- package/dist/types/components/DataTable/controls/PageSizeControl.d.ts +4 -0
- package/dist/types/components/DataTable/controls/Pagination.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ReloadButton.d.ts +5 -0
- package/dist/types/components/DataTable/controls/ResetFilteringButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/ResetSelectionButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/ResetSortingButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/RowCountText.d.ts +1 -0
- package/dist/types/components/DataTable/controls/SelectAllRowsToggle.d.ts +8 -0
- package/dist/types/components/DataTable/controls/TableControls.d.ts +21 -0
- package/dist/types/components/DataTable/controls/TableFilterTags.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableFilters.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableSelector.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableSorter.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableViewer.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ViewDialog.d.ts +5 -0
- package/dist/types/components/DataTable/display/CardHeader.d.ts +13 -0
- package/dist/types/components/DataTable/display/DataDisplay.d.ts +6 -0
- package/dist/types/components/DataTable/display/EmptyState.d.ts +5 -0
- package/dist/types/components/DataTable/display/ErrorAlert.d.ts +4 -0
- package/dist/types/components/DataTable/display/RecordDisplay.d.ts +9 -0
- package/dist/types/components/DataTable/display/Table.d.ts +10 -0
- package/dist/types/components/DataTable/display/TableBody.d.ts +21 -0
- package/dist/types/components/DataTable/display/TableCardContainer.d.ts +7 -0
- package/dist/types/components/DataTable/display/TableCards.d.ts +11 -0
- package/dist/types/components/DataTable/display/TableComponent.d.ts +6 -0
- package/dist/types/components/DataTable/display/TableDataDisplay.d.ts +6 -0
- package/dist/types/components/DataTable/display/TableFooter.d.ts +9 -0
- package/dist/types/components/DataTable/display/TableHeader.d.ts +9 -0
- package/dist/types/components/DataTable/display/TableLoadingComponent.d.ts +5 -0
- package/dist/types/components/DataTable/display/TextCell.d.ts +10 -0
- package/dist/types/components/DataTable/useDataTable.d.ts +1 -1
- package/dist/types/components/Form/SchemaFormContext.d.ts +13 -0
- package/dist/types/components/Form/components/core/DefaultForm.d.ts +7 -0
- package/dist/types/components/Form/components/core/FormBody.d.ts +1 -0
- package/dist/types/components/Form/components/core/FormRoot.d.ts +39 -0
- package/dist/types/components/Form/components/core/FormTitle.d.ts +1 -0
- package/dist/types/components/Form/components/core/SubmitButton.d.ts +1 -0
- package/dist/types/index.d.ts +37 -35
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,12 +4,13 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var react = require('@chakra-ui/react');
|
|
5
5
|
var ai = require('react-icons/ai');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var md = require('react-icons/md');
|
|
8
7
|
var lu = require('react-icons/lu');
|
|
9
|
-
var
|
|
8
|
+
var md = require('react-icons/md');
|
|
10
9
|
var fa6 = require('react-icons/fa6');
|
|
11
10
|
var bi = require('react-icons/bi');
|
|
12
11
|
var cg = require('react-icons/cg');
|
|
12
|
+
var Dayzed = require('@bsol-oss/dayzed-react19');
|
|
13
|
+
var hi2 = require('react-icons/hi2');
|
|
13
14
|
var io = require('react-icons/io');
|
|
14
15
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
15
16
|
var bindEventListener = require('bind-event-listener');
|
|
@@ -17,7 +18,7 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
17
18
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
18
19
|
var rafSchd = require('raf-schd');
|
|
19
20
|
var invariant = require('tiny-invariant');
|
|
20
|
-
var
|
|
21
|
+
var hi = require('react-icons/hi');
|
|
21
22
|
var reactTable = require('@tanstack/react-table');
|
|
22
23
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
23
24
|
var bs = require('react-icons/bs');
|
|
@@ -25,7 +26,6 @@ var usehooks = require('@uidotdev/usehooks');
|
|
|
25
26
|
var reactQuery = require('@tanstack/react-query');
|
|
26
27
|
var io5 = require('react-icons/io5');
|
|
27
28
|
var gr = require('react-icons/gr');
|
|
28
|
-
var hi = require('react-icons/hi');
|
|
29
29
|
var reactI18next = require('react-i18next');
|
|
30
30
|
var axios = require('axios');
|
|
31
31
|
var reactHookForm = require('react-hook-form');
|
|
@@ -98,6 +98,32 @@ react.Dialog.Description;
|
|
|
98
98
|
const DialogTrigger = react.Dialog.Trigger;
|
|
99
99
|
react.Dialog.ActionTrigger;
|
|
100
100
|
|
|
101
|
+
const TableSorter = () => {
|
|
102
|
+
const { table } = useDataTableContext();
|
|
103
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: headerGroup.headers.map((header) => {
|
|
104
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
105
|
+
? header.column.id
|
|
106
|
+
: header.column.columnDef.meta.displayName;
|
|
107
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: header.column.getCanSort() && (jsxRuntime.jsxs(react.Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsxs(react.Button, { variant: "ghost", onClick: () => {
|
|
108
|
+
header.column.toggleSorting();
|
|
109
|
+
}, children: [header.column.getIsSorted() === false && jsxRuntime.jsx(fa6.FaUpDown, {}), header.column.getIsSorted() === "asc" && jsxRuntime.jsx(bi.BiDownArrow, {}), header.column.getIsSorted() === "desc" && jsxRuntime.jsx(bi.BiUpArrow, {})] }), header.column.getIsSorted() && (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
110
|
+
header.column.clearSorting();
|
|
111
|
+
}, children: jsxRuntime.jsx(cg.CgClose, {}) }))] })) }));
|
|
112
|
+
}) }))) }));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
116
|
+
const { table } = useDataTableContext();
|
|
117
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
118
|
+
table.resetSorting();
|
|
119
|
+
}, children: text }));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const EditSortingButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
123
|
+
const sortingModal = react.useDisclosure();
|
|
124
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(DialogRoot, { size: ["full", "full", "md", "md"], children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { children: jsxRuntime.jsxs(react.Button, { as: "div", variant: "ghost", onClick: sortingModal.onOpen, children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsx(DialogTitle, {}), title] }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(TableSorter, {}), jsxRuntime.jsx(ResetSortingButton, {})] }) }), jsxRuntime.jsx(DialogFooter, {})] })] }) }));
|
|
125
|
+
};
|
|
126
|
+
|
|
101
127
|
const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
102
128
|
const { children, inputProps, rootRef, ...rest } = props;
|
|
103
129
|
return (jsxRuntime.jsxs(react.RadioGroup.Item, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.RadioGroup.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.RadioGroup.ItemIndicator, {}), children && (jsxRuntime.jsx(react.RadioGroup.ItemText, { children: children }))] }));
|
|
@@ -377,90 +403,141 @@ const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
|
377
403
|
const FilterDialog = ({ icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
|
|
378
404
|
const filterModal = react.useDisclosure();
|
|
379
405
|
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("
|
|
406
|
+
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 })] })] }));
|
|
381
407
|
};
|
|
382
408
|
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
.map((column) => {
|
|
416
|
-
const displayName = column.columnDef.meta === undefined
|
|
417
|
-
? column.id
|
|
418
|
-
: column.columnDef.meta.displayName;
|
|
419
|
-
return jsxRuntime.jsx("span", { children: displayName }, column.id);
|
|
420
|
-
}), jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
421
|
-
const nextIndex = index + 1;
|
|
422
|
-
if (nextIndex < order.length) {
|
|
423
|
-
handleChangeOrder(index, nextIndex);
|
|
424
|
-
}
|
|
425
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] }, columnId))) }), jsxRuntime.jsxs(react.Flex, { gap: "0.25rem", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
426
|
-
table.setColumnOrder(order);
|
|
427
|
-
}, children: "Apply" }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
428
|
-
table.setColumnOrder(originalOrder);
|
|
429
|
-
}, children: "Reset" })] })] }));
|
|
430
|
-
};
|
|
431
|
-
const TableOrderer = () => {
|
|
409
|
+
const MenuContent = React__namespace.forwardRef(function MenuContent(props, ref) {
|
|
410
|
+
const { portalled = true, portalRef, ...rest } = props;
|
|
411
|
+
return (jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Menu.Positioner, { children: jsxRuntime.jsx(react.Menu.Content, { ref: ref, ...rest }) }) }));
|
|
412
|
+
});
|
|
413
|
+
React__namespace.forwardRef(function MenuArrow(props, ref) {
|
|
414
|
+
return (jsxRuntime.jsx(react.Menu.Arrow, { ref: ref, ...props, children: jsxRuntime.jsx(react.Menu.ArrowTip, {}) }));
|
|
415
|
+
});
|
|
416
|
+
React__namespace.forwardRef(function MenuCheckboxItem(props, ref) {
|
|
417
|
+
return (jsxRuntime.jsxs(react.Menu.CheckboxItem, { ref: ref, ...props, children: [jsxRuntime.jsx(react.Menu.ItemIndicator, { hidden: false, children: jsxRuntime.jsx(lu.LuCheck, {}) }), props.children] }));
|
|
418
|
+
});
|
|
419
|
+
React__namespace.forwardRef(function MenuRadioItem(props, ref) {
|
|
420
|
+
const { children, ...rest } = props;
|
|
421
|
+
return (jsxRuntime.jsxs(react.Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsxRuntime.jsx(react.AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsxRuntime.jsx(react.Menu.ItemIndicator, { children: jsxRuntime.jsx(lu.LuCheck, {}) }) }), jsxRuntime.jsx(react.Menu.ItemText, { children: children })] }));
|
|
422
|
+
});
|
|
423
|
+
React__namespace.forwardRef(function MenuItemGroup(props, ref) {
|
|
424
|
+
const { title, children, ...rest } = props;
|
|
425
|
+
return (jsxRuntime.jsxs(react.Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsxRuntime.jsx(react.Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
426
|
+
});
|
|
427
|
+
React__namespace.forwardRef(function MenuTriggerItem(props, ref) {
|
|
428
|
+
const { startIcon, children, ...rest } = props;
|
|
429
|
+
return (jsxRuntime.jsxs(react.Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsxRuntime.jsx(lu.LuChevronRight, {})] }));
|
|
430
|
+
});
|
|
431
|
+
react.Menu.RadioItemGroup;
|
|
432
|
+
react.Menu.ContextTrigger;
|
|
433
|
+
const MenuRoot = react.Menu.Root;
|
|
434
|
+
react.Menu.Separator;
|
|
435
|
+
const MenuItem = react.Menu.Item;
|
|
436
|
+
react.Menu.ItemText;
|
|
437
|
+
react.Menu.ItemCommand;
|
|
438
|
+
const MenuTrigger = react.Menu.Trigger;
|
|
439
|
+
|
|
440
|
+
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
432
441
|
const { table } = useDataTableContext();
|
|
433
|
-
return (jsxRuntime.
|
|
442
|
+
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: () => {
|
|
443
|
+
table.setPageSize(Number(pageSize));
|
|
444
|
+
}, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }));
|
|
434
445
|
};
|
|
435
446
|
|
|
436
|
-
const
|
|
437
|
-
|
|
447
|
+
const { withContext } = react.createRecipeContext({ key: "button" });
|
|
448
|
+
// Replace "a" with your framework's link component
|
|
449
|
+
const LinkButton = withContext("a");
|
|
450
|
+
|
|
451
|
+
const [RootPropsProvider, useRootProps] = react.createContext({
|
|
452
|
+
name: "RootPropsProvider",
|
|
453
|
+
});
|
|
454
|
+
const variantMap = {
|
|
455
|
+
outline: { default: "ghost", ellipsis: "plain", current: "outline" },
|
|
456
|
+
solid: { default: "outline", ellipsis: "outline", current: "solid" },
|
|
457
|
+
subtle: { default: "ghost", ellipsis: "plain", current: "subtle" },
|
|
458
|
+
};
|
|
459
|
+
const PaginationRoot = React__namespace.forwardRef(function PaginationRoot(props, ref) {
|
|
460
|
+
const { size = "sm", variant = "outline", getHref, ...rest } = props;
|
|
461
|
+
return (jsxRuntime.jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsxRuntime.jsx(react.Pagination.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
|
|
462
|
+
});
|
|
463
|
+
const PaginationEllipsis = React__namespace.forwardRef(function PaginationEllipsis(props, ref) {
|
|
464
|
+
const { size, variantMap } = useRootProps();
|
|
465
|
+
return (jsxRuntime.jsx(react.Pagination.Ellipsis, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { as: "span", variant: variantMap.ellipsis, size: size, children: jsxRuntime.jsx(hi2.HiMiniEllipsisHorizontal, {}) }) }));
|
|
466
|
+
});
|
|
467
|
+
const PaginationItem = React__namespace.forwardRef(function PaginationItem(props, ref) {
|
|
468
|
+
const { page } = react.usePaginationContext();
|
|
469
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
470
|
+
const current = page === props.value;
|
|
471
|
+
const variant = current ? variantMap.current : variantMap.default;
|
|
472
|
+
if (getHref) {
|
|
473
|
+
return (jsxRuntime.jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
|
|
474
|
+
}
|
|
475
|
+
return (jsxRuntime.jsx(react.Pagination.Item, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { variant: variant, size: size, children: props.value }) }));
|
|
476
|
+
});
|
|
477
|
+
const PaginationPrevTrigger = React__namespace.forwardRef(function PaginationPrevTrigger(props, ref) {
|
|
478
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
479
|
+
const { previousPage } = react.usePaginationContext();
|
|
480
|
+
if (getHref) {
|
|
481
|
+
return (jsxRuntime.jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }));
|
|
482
|
+
}
|
|
483
|
+
return (jsxRuntime.jsx(react.Pagination.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }) }));
|
|
484
|
+
});
|
|
485
|
+
const PaginationNextTrigger = React__namespace.forwardRef(function PaginationNextTrigger(props, ref) {
|
|
486
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
487
|
+
const { nextPage } = react.usePaginationContext();
|
|
488
|
+
if (getHref) {
|
|
489
|
+
return (jsxRuntime.jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }));
|
|
490
|
+
}
|
|
491
|
+
return (jsxRuntime.jsx(react.Pagination.NextTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }) }));
|
|
492
|
+
});
|
|
493
|
+
const PaginationItems = (props) => {
|
|
494
|
+
return (jsxRuntime.jsx(react.Pagination.Context, { children: ({ pages }) => pages.map((page, index) => {
|
|
495
|
+
return page.type === "ellipsis" ? (jsxRuntime.jsx(PaginationEllipsis, { index: index, ...props }, index)) : (jsxRuntime.jsx(PaginationItem, { type: "page", value: page.value, ...props }, index));
|
|
496
|
+
}) }));
|
|
438
497
|
};
|
|
498
|
+
const PaginationPageText = React__namespace.forwardRef(function PaginationPageText(props, ref) {
|
|
499
|
+
const { format = "compact", ...rest } = props;
|
|
500
|
+
const { page, totalPages, pageRange, count } = react.usePaginationContext();
|
|
501
|
+
const content = React__namespace.useMemo(() => {
|
|
502
|
+
if (format === "short")
|
|
503
|
+
return `${page} / ${totalPages}`;
|
|
504
|
+
if (format === "compact")
|
|
505
|
+
return `${page} / ${totalPages}`;
|
|
506
|
+
return `${pageRange.start + 1} - ${Math.min(pageRange.end, count)} / ${count}`;
|
|
507
|
+
}, [format, page, totalPages, pageRange, count]);
|
|
508
|
+
return (jsxRuntime.jsx(react.Text, { fontWeight: "medium", ref: ref, ...rest, children: content }));
|
|
509
|
+
});
|
|
439
510
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
511
|
+
// TODO: not working in client side
|
|
512
|
+
const Pagination = () => {
|
|
513
|
+
const { table, type } = useDataTableContext();
|
|
514
|
+
const getCount = () => {
|
|
515
|
+
if (type === "client") {
|
|
516
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
517
|
+
}
|
|
518
|
+
return table.getRowCount();
|
|
519
|
+
};
|
|
520
|
+
return (jsxRuntime.jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
521
|
+
table.setPageIndex(e.page - 1);
|
|
522
|
+
}, children: jsxRuntime.jsxs(react.HStack, { children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), jsxRuntime.jsx(PaginationItems, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) }));
|
|
452
523
|
};
|
|
453
524
|
|
|
454
|
-
const
|
|
525
|
+
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
455
526
|
const { table } = useDataTableContext();
|
|
456
527
|
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
457
|
-
table.
|
|
528
|
+
table.resetRowSelection();
|
|
458
529
|
}, children: text }));
|
|
459
530
|
};
|
|
460
531
|
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
|
|
532
|
+
const RowCountText = () => {
|
|
533
|
+
const { table, type } = useDataTableContext();
|
|
534
|
+
const getCount = () => {
|
|
535
|
+
if (type === "client") {
|
|
536
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
537
|
+
}
|
|
538
|
+
return table.getRowCount();
|
|
539
|
+
};
|
|
540
|
+
return jsxRuntime.jsx(react.Text, { children: getCount() });
|
|
464
541
|
};
|
|
465
542
|
|
|
466
543
|
// pulling this into a separate file so adapter(s) that don't
|
|
@@ -2380,13 +2457,16 @@ function ColumnCard({ columnId }) {
|
|
|
2380
2457
|
onDrop: () => setDragging(false), // NEW
|
|
2381
2458
|
});
|
|
2382
2459
|
}, [columnId, table]);
|
|
2383
|
-
return (jsxRuntime.jsxs(react.Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsxRuntime.jsx(react.Flex, { alignItems: "center", padding: "0", cursor:
|
|
2460
|
+
return (jsxRuntime.jsxs(react.Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsxRuntime.jsx(react.Flex, { alignItems: "center", padding: "0", cursor: "grab", children: jsxRuntime.jsx(fa6.FaGripLinesVertical, { color: "gray.400" }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "space-between", alignItems: "center", children: jsxRuntime.jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
|
|
2384
2461
|
}
|
|
2385
2462
|
function CardContainer({ location, children }) {
|
|
2386
2463
|
const ref = React.useRef(null);
|
|
2387
2464
|
const [isDraggedOver, setIsDraggedOver] = React.useState(false);
|
|
2388
2465
|
React.useEffect(() => {
|
|
2389
2466
|
const el = ref.current;
|
|
2467
|
+
if (el === null) {
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2390
2470
|
invariant(el);
|
|
2391
2471
|
return dropTargetForElements({
|
|
2392
2472
|
element: el,
|
|
@@ -2458,149 +2538,37 @@ const TableViewer = () => {
|
|
|
2458
2538
|
const ViewDialog = ({ icon = jsxRuntime.jsx(io.IoMdEye, {}) }) => {
|
|
2459
2539
|
const viewModel = react.useDisclosure();
|
|
2460
2540
|
const { translate } = useDataTableContext();
|
|
2461
|
-
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("
|
|
2541
|
+
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, {})] })] }));
|
|
2462
2542
|
};
|
|
2463
2543
|
|
|
2464
|
-
const
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
return (jsxRuntime.jsx(react.
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
React__namespace.forwardRef(function MenuRadioItem(props, ref) {
|
|
2475
|
-
const { children, ...rest } = props;
|
|
2476
|
-
return (jsxRuntime.jsxs(react.Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsxRuntime.jsx(react.AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsxRuntime.jsx(react.Menu.ItemIndicator, { children: jsxRuntime.jsx(lu.LuCheck, {}) }) }), jsxRuntime.jsx(react.Menu.ItemText, { children: children })] }));
|
|
2477
|
-
});
|
|
2478
|
-
React__namespace.forwardRef(function MenuItemGroup(props, ref) {
|
|
2479
|
-
const { title, children, ...rest } = props;
|
|
2480
|
-
return (jsxRuntime.jsxs(react.Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsxRuntime.jsx(react.Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
2481
|
-
});
|
|
2482
|
-
React__namespace.forwardRef(function MenuTriggerItem(props, ref) {
|
|
2483
|
-
const { startIcon, children, ...rest } = props;
|
|
2484
|
-
return (jsxRuntime.jsxs(react.Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsxRuntime.jsx(lu.LuChevronRight, {})] }));
|
|
2544
|
+
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
2545
|
+
if (!!row.original === false) {
|
|
2546
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2547
|
+
}
|
|
2548
|
+
const isShowFirstColumn = !!titleColumnId || showTag;
|
|
2549
|
+
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto auto", gap: "1rem", children: [!!imageColumnId && (jsxRuntime.jsx(react.Image, { width: "100%", src: row.original[imageColumnId], ...imageProps })), isShowFirstColumn && (jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: [!!titleColumnId && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] })), showTag && (jsxRuntime.jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] }))] }));
|
|
2550
|
+
};
|
|
2551
|
+
|
|
2552
|
+
const DataTableServerContext = React.createContext({
|
|
2553
|
+
url: "",
|
|
2485
2554
|
});
|
|
2486
|
-
react.Menu.RadioItemGroup;
|
|
2487
|
-
react.Menu.ContextTrigger;
|
|
2488
|
-
const MenuRoot = react.Menu.Root;
|
|
2489
|
-
react.Menu.Separator;
|
|
2490
|
-
const MenuItem = react.Menu.Item;
|
|
2491
|
-
react.Menu.ItemText;
|
|
2492
|
-
react.Menu.ItemCommand;
|
|
2493
|
-
const MenuTrigger = react.Menu.Trigger;
|
|
2494
2555
|
|
|
2495
|
-
const
|
|
2496
|
-
const
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2556
|
+
const useDataTableServerContext = () => {
|
|
2557
|
+
const context = React.useContext(DataTableServerContext);
|
|
2558
|
+
const { query } = context;
|
|
2559
|
+
const isEmpty = (query.data?.count ?? 0) <= 0;
|
|
2560
|
+
return { ...context, isEmpty };
|
|
2500
2561
|
};
|
|
2501
2562
|
|
|
2502
|
-
const
|
|
2503
|
-
const {
|
|
2504
|
-
return (jsxRuntime.jsx(react.
|
|
2505
|
-
table.resetRowSelection();
|
|
2506
|
-
}, children: text }));
|
|
2563
|
+
const EmptyState$1 = ({ title = "No records", description = "Add a new events to get started or refine your search", }) => {
|
|
2564
|
+
const { isEmpty } = useDataTableServerContext();
|
|
2565
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isEmpty && (jsxRuntime.jsx(react.EmptyState.Root, { children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [jsxRuntime.jsx(react.EmptyState.Indicator, { children: jsxRuntime.jsx(hi.HiColorSwatch, {}) }), jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })] }) })) }));
|
|
2507
2566
|
};
|
|
2508
2567
|
|
|
2509
|
-
const
|
|
2510
|
-
const {
|
|
2511
|
-
const
|
|
2512
|
-
|
|
2513
|
-
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
2514
|
-
}
|
|
2515
|
-
return table.getRowCount();
|
|
2516
|
-
};
|
|
2517
|
-
return jsxRuntime.jsx(react.Text, { children: getCount() });
|
|
2518
|
-
};
|
|
2519
|
-
|
|
2520
|
-
const { withContext } = react.createRecipeContext({ key: "button" });
|
|
2521
|
-
// Replace "a" with your framework's link component
|
|
2522
|
-
const LinkButton = withContext("a");
|
|
2523
|
-
|
|
2524
|
-
const [RootPropsProvider, useRootProps] = react.createContext({
|
|
2525
|
-
name: "RootPropsProvider",
|
|
2526
|
-
});
|
|
2527
|
-
const variantMap = {
|
|
2528
|
-
outline: { default: "ghost", ellipsis: "plain", current: "outline" },
|
|
2529
|
-
solid: { default: "outline", ellipsis: "outline", current: "solid" },
|
|
2530
|
-
subtle: { default: "ghost", ellipsis: "plain", current: "subtle" },
|
|
2531
|
-
};
|
|
2532
|
-
const PaginationRoot = React__namespace.forwardRef(function PaginationRoot(props, ref) {
|
|
2533
|
-
const { size = "sm", variant = "outline", getHref, ...rest } = props;
|
|
2534
|
-
return (jsxRuntime.jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsxRuntime.jsx(react.Pagination.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
|
|
2535
|
-
});
|
|
2536
|
-
const PaginationEllipsis = React__namespace.forwardRef(function PaginationEllipsis(props, ref) {
|
|
2537
|
-
const { size, variantMap } = useRootProps();
|
|
2538
|
-
return (jsxRuntime.jsx(react.Pagination.Ellipsis, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { as: "span", variant: variantMap.ellipsis, size: size, children: jsxRuntime.jsx(hi2.HiMiniEllipsisHorizontal, {}) }) }));
|
|
2539
|
-
});
|
|
2540
|
-
const PaginationItem = React__namespace.forwardRef(function PaginationItem(props, ref) {
|
|
2541
|
-
const { page } = react.usePaginationContext();
|
|
2542
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2543
|
-
const current = page === props.value;
|
|
2544
|
-
const variant = current ? variantMap.current : variantMap.default;
|
|
2545
|
-
if (getHref) {
|
|
2546
|
-
return (jsxRuntime.jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
|
|
2547
|
-
}
|
|
2548
|
-
return (jsxRuntime.jsx(react.Pagination.Item, { ref: ref, ...props, asChild: true, children: jsxRuntime.jsx(react.Button, { variant: variant, size: size, children: props.value }) }));
|
|
2549
|
-
});
|
|
2550
|
-
const PaginationPrevTrigger = React__namespace.forwardRef(function PaginationPrevTrigger(props, ref) {
|
|
2551
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2552
|
-
const { previousPage } = react.usePaginationContext();
|
|
2553
|
-
if (getHref) {
|
|
2554
|
-
return (jsxRuntime.jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }));
|
|
2555
|
-
}
|
|
2556
|
-
return (jsxRuntime.jsx(react.Pagination.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronLeft, {}) }) }));
|
|
2557
|
-
});
|
|
2558
|
-
const PaginationNextTrigger = React__namespace.forwardRef(function PaginationNextTrigger(props, ref) {
|
|
2559
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2560
|
-
const { nextPage } = react.usePaginationContext();
|
|
2561
|
-
if (getHref) {
|
|
2562
|
-
return (jsxRuntime.jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }));
|
|
2563
|
-
}
|
|
2564
|
-
return (jsxRuntime.jsx(react.Pagination.NextTrigger, { ref: ref, asChild: true, ...props, children: jsxRuntime.jsx(react.IconButton, { variant: variantMap.default, size: size, children: jsxRuntime.jsx(hi2.HiChevronRight, {}) }) }));
|
|
2565
|
-
});
|
|
2566
|
-
const PaginationItems = (props) => {
|
|
2567
|
-
return (jsxRuntime.jsx(react.Pagination.Context, { children: ({ pages }) => pages.map((page, index) => {
|
|
2568
|
-
return page.type === "ellipsis" ? (jsxRuntime.jsx(PaginationEllipsis, { index: index, ...props }, index)) : (jsxRuntime.jsx(PaginationItem, { type: "page", value: page.value, ...props }, index));
|
|
2569
|
-
}) }));
|
|
2570
|
-
};
|
|
2571
|
-
const PaginationPageText = React__namespace.forwardRef(function PaginationPageText(props, ref) {
|
|
2572
|
-
const { format = "compact", ...rest } = props;
|
|
2573
|
-
const { page, totalPages, pageRange, count } = react.usePaginationContext();
|
|
2574
|
-
const content = React__namespace.useMemo(() => {
|
|
2575
|
-
if (format === "short")
|
|
2576
|
-
return `${page} / ${totalPages}`;
|
|
2577
|
-
if (format === "compact")
|
|
2578
|
-
return `${page} / ${totalPages}`;
|
|
2579
|
-
return `${pageRange.start + 1} - ${Math.min(pageRange.end, count)} / ${count}`;
|
|
2580
|
-
}, [format, page, totalPages, pageRange, count]);
|
|
2581
|
-
return (jsxRuntime.jsx(react.Text, { fontWeight: "medium", ref: ref, ...rest, children: content }));
|
|
2582
|
-
});
|
|
2583
|
-
|
|
2584
|
-
// TODO: not working in client side
|
|
2585
|
-
const Pagination = () => {
|
|
2586
|
-
const { table, type } = useDataTableContext();
|
|
2587
|
-
const getCount = () => {
|
|
2588
|
-
if (type === "client") {
|
|
2589
|
-
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
2590
|
-
}
|
|
2591
|
-
return table.getRowCount();
|
|
2592
|
-
};
|
|
2593
|
-
return (jsxRuntime.jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
2594
|
-
table.setPageIndex(e.page - 1);
|
|
2595
|
-
}, children: jsxRuntime.jsxs(react.HStack, { children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), jsxRuntime.jsx(PaginationItems, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) }));
|
|
2596
|
-
};
|
|
2597
|
-
|
|
2598
|
-
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
2599
|
-
if (!!row.original === false) {
|
|
2600
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2601
|
-
}
|
|
2602
|
-
const isShowFirstColumn = !!titleColumnId || showTag;
|
|
2603
|
-
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto auto", gap: "1rem", children: [!!imageColumnId && (jsxRuntime.jsx(react.Image, { width: "100%", src: row.original[imageColumnId], ...imageProps })), isShowFirstColumn && (jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: [!!titleColumnId && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] })), showTag && (jsxRuntime.jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] }))] }));
|
|
2568
|
+
const ErrorAlert = ({ showMessage = true }) => {
|
|
2569
|
+
const { query } = useDataTableServerContext();
|
|
2570
|
+
const { isError, error } = query;
|
|
2571
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isError && (jsxRuntime.jsxs(react.Alert.Root, { status: "error", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsxs(react.Alert.Content, { children: [jsxRuntime.jsx(react.Alert.Title, { children: error.name }), showMessage && (jsxRuntime.jsx(react.Alert.Description, { children: error.message }))] })] })) }));
|
|
2604
2572
|
};
|
|
2605
2573
|
|
|
2606
2574
|
const snakeToLabel = (str) => {
|
|
@@ -2846,13 +2814,25 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2846
2814
|
setGlobalFilter,
|
|
2847
2815
|
type: "client",
|
|
2848
2816
|
translate,
|
|
2817
|
+
columns,
|
|
2818
|
+
sorting,
|
|
2819
|
+
setSorting,
|
|
2820
|
+
columnFilters,
|
|
2821
|
+
setColumnFilters,
|
|
2822
|
+
pagination,
|
|
2823
|
+
setPagination,
|
|
2824
|
+
rowSelection,
|
|
2825
|
+
setRowSelection,
|
|
2826
|
+
columnOrder,
|
|
2827
|
+
setColumnOrder,
|
|
2828
|
+
density,
|
|
2829
|
+
setDensity,
|
|
2830
|
+
columnVisibility,
|
|
2831
|
+
setColumnVisibility,
|
|
2832
|
+
data,
|
|
2849
2833
|
}, children: children }));
|
|
2850
2834
|
}
|
|
2851
2835
|
|
|
2852
|
-
const DataTableServerContext = React.createContext({
|
|
2853
|
-
url: "",
|
|
2854
|
-
});
|
|
2855
|
-
|
|
2856
2836
|
/**
|
|
2857
2837
|
* DataTableServer will create a context to hold all values to
|
|
2858
2838
|
* help the render of the DataTable in serverside
|
|
@@ -2918,90 +2898,25 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2918
2898
|
setGlobalFilter,
|
|
2919
2899
|
type: "server",
|
|
2920
2900
|
translate,
|
|
2901
|
+
columns,
|
|
2902
|
+
sorting,
|
|
2903
|
+
setSorting,
|
|
2904
|
+
columnFilters,
|
|
2905
|
+
setColumnFilters,
|
|
2906
|
+
pagination,
|
|
2907
|
+
setPagination,
|
|
2908
|
+
rowSelection,
|
|
2909
|
+
setRowSelection,
|
|
2910
|
+
columnOrder,
|
|
2911
|
+
setColumnOrder,
|
|
2912
|
+
density,
|
|
2913
|
+
setDensity,
|
|
2914
|
+
columnVisibility,
|
|
2915
|
+
setColumnVisibility,
|
|
2916
|
+
data: query.data?.data ?? [],
|
|
2921
2917
|
}, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2922
2918
|
}
|
|
2923
2919
|
|
|
2924
|
-
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
2925
|
-
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
2926
|
-
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 }))] }));
|
|
2927
|
-
});
|
|
2928
|
-
|
|
2929
|
-
const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
2930
|
-
const { table } = useDataTableContext();
|
|
2931
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2932
|
-
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
2933
|
-
const handleRowHover = (index) => {
|
|
2934
|
-
setHoveredRow(index);
|
|
2935
|
-
};
|
|
2936
|
-
const getTdProps = (cell) => {
|
|
2937
|
-
const tdProps = cell.column.getIsPinned()
|
|
2938
|
-
? {
|
|
2939
|
-
left: showSelector
|
|
2940
|
-
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
2941
|
-
: `${cell.column.getStart("left")}px`,
|
|
2942
|
-
background: pinnedBgColor.light,
|
|
2943
|
-
position: "sticky",
|
|
2944
|
-
zIndex: -1,
|
|
2945
|
-
_dark: {
|
|
2946
|
-
backgroundColor: pinnedBgColor.dark,
|
|
2947
|
-
},
|
|
2948
|
-
}
|
|
2949
|
-
: {};
|
|
2950
|
-
return tdProps;
|
|
2951
|
-
};
|
|
2952
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2953
|
-
if (hoveredRow === -1) {
|
|
2954
|
-
return {};
|
|
2955
|
-
}
|
|
2956
|
-
if (hoveredRow === index) {
|
|
2957
|
-
return {
|
|
2958
|
-
opacity: "1",
|
|
2959
|
-
};
|
|
2960
|
-
}
|
|
2961
|
-
return {
|
|
2962
|
-
opacity: "0.8",
|
|
2963
|
-
};
|
|
2964
|
-
};
|
|
2965
|
-
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2966
|
-
return (jsxRuntime.jsxs(react.Table.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsxRuntime.jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow, alwaysShowSelector: alwaysShowSelector })), row.getVisibleCells().map((cell, index) => {
|
|
2967
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2968
|
-
// styling resize and pinning start
|
|
2969
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, backgroundColor: "white", ...getTdProps(cell), _dark: {
|
|
2970
|
-
backgroundColor: "gray.950",
|
|
2971
|
-
}, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2972
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2973
|
-
}) }));
|
|
2974
|
-
};
|
|
2975
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2976
|
-
const { table } = useDataTableContext();
|
|
2977
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2978
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2979
|
-
if (alwaysShowSelector) {
|
|
2980
|
-
return true;
|
|
2981
|
-
}
|
|
2982
|
-
if (current_row.getIsSelected()) {
|
|
2983
|
-
return true;
|
|
2984
|
-
}
|
|
2985
|
-
if (hoveredRow == current_index) {
|
|
2986
|
-
return true;
|
|
2987
|
-
}
|
|
2988
|
-
return false;
|
|
2989
|
-
};
|
|
2990
|
-
return (jsxRuntime.jsxs(react.Table.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2991
|
-
? {
|
|
2992
|
-
left: `0px`,
|
|
2993
|
-
backgroundColor: pinnedBgColor.light,
|
|
2994
|
-
position: "sticky",
|
|
2995
|
-
zIndex: 1,
|
|
2996
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2997
|
-
}
|
|
2998
|
-
: {}),
|
|
2999
|
-
// styling resize and pinning end
|
|
3000
|
-
display: "grid", children: [!isCheckBoxVisible(index, row) && (jsxRuntime.jsx(react.Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` })), isCheckBoxVisible(index, row) && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: row.getIsSelected(),
|
|
3001
|
-
disabled: !row.getCanSelect(),
|
|
3002
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
3003
|
-
};
|
|
3004
|
-
|
|
3005
2920
|
const Tooltip = React__namespace.forwardRef(function Tooltip(props, ref) {
|
|
3006
2921
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
3007
2922
|
if (disabled)
|
|
@@ -3036,13 +2951,6 @@ const GlobalFilter = () => {
|
|
|
3036
2951
|
} }) }) }));
|
|
3037
2952
|
};
|
|
3038
2953
|
|
|
3039
|
-
const useDataTableServerContext = () => {
|
|
3040
|
-
const context = React.useContext(DataTableServerContext);
|
|
3041
|
-
const { query } = context;
|
|
3042
|
-
const isEmpty = (query.data?.count ?? 0) <= 0;
|
|
3043
|
-
return { ...context, isEmpty };
|
|
3044
|
-
};
|
|
3045
|
-
|
|
3046
2954
|
const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
|
|
3047
2955
|
const { url } = useDataTableServerContext();
|
|
3048
2956
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -3089,11 +2997,86 @@ const TableFilterTags = () => {
|
|
|
3089
2997
|
|
|
3090
2998
|
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, }) => {
|
|
3091
2999
|
const { translate } = useDataTableContext();
|
|
3092
|
-
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr
|
|
3000
|
+
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr", 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("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) => {
|
|
3093
3001
|
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));
|
|
3094
3002
|
}) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Grid, { overflow: "auto", backgroundColor: "gray.50", _dark: {
|
|
3095
3003
|
backgroundColor: "gray.900",
|
|
3096
|
-
}, 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, {}) })] })] }));
|
|
3004
|
+
}, 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, {}) })] }))] }));
|
|
3005
|
+
};
|
|
3006
|
+
|
|
3007
|
+
const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
3008
|
+
const { title, description, icon, children, ...rest } = props;
|
|
3009
|
+
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
3010
|
+
});
|
|
3011
|
+
|
|
3012
|
+
const EmptyResult = (jsxRuntime.jsx(EmptyState, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
3013
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3014
|
+
const { table } = useDataTableContext();
|
|
3015
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
3016
|
+
return emptyComponent;
|
|
3017
|
+
}
|
|
3018
|
+
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3019
|
+
};
|
|
3020
|
+
|
|
3021
|
+
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
3022
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3023
|
+
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 }))] }));
|
|
3024
|
+
});
|
|
3025
|
+
|
|
3026
|
+
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
3027
|
+
"use no memo";
|
|
3028
|
+
const { table } = useDataTableContext();
|
|
3029
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3030
|
+
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
3031
|
+
const handleRowHover = (index) => {
|
|
3032
|
+
setHoveredRow(index);
|
|
3033
|
+
};
|
|
3034
|
+
const getTdProps = (cell) => {
|
|
3035
|
+
const tdProps = cell.column.getIsPinned()
|
|
3036
|
+
? {
|
|
3037
|
+
left: showSelector
|
|
3038
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3039
|
+
: `${cell.column.getStart("left")}px`,
|
|
3040
|
+
position: "relative",
|
|
3041
|
+
}
|
|
3042
|
+
: {};
|
|
3043
|
+
return tdProps;
|
|
3044
|
+
};
|
|
3045
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3046
|
+
if (hoveredRow === -1) {
|
|
3047
|
+
return {};
|
|
3048
|
+
}
|
|
3049
|
+
if (hoveredRow === index) {
|
|
3050
|
+
return {
|
|
3051
|
+
opacity: "1",
|
|
3052
|
+
};
|
|
3053
|
+
}
|
|
3054
|
+
return {
|
|
3055
|
+
opacity: "0.8",
|
|
3056
|
+
};
|
|
3057
|
+
};
|
|
3058
|
+
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3059
|
+
return (jsxRuntime.jsxs(react.Table.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsxRuntime.jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow })), row.getVisibleCells().map((cell, index) => {
|
|
3060
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3061
|
+
// styling resize and pinning start
|
|
3062
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3063
|
+
base: "colorPalette.900",
|
|
3064
|
+
_dark: "colorPalette.100",
|
|
3065
|
+
},
|
|
3066
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3067
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3068
|
+
}) }));
|
|
3069
|
+
};
|
|
3070
|
+
const TableRowSelector = ({ index, row, }) => {
|
|
3071
|
+
const { table } = useDataTableContext();
|
|
3072
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3073
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3074
|
+
base: "colorPalette.900",
|
|
3075
|
+
_dark: "colorPalette.100",
|
|
3076
|
+
},
|
|
3077
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
3078
|
+
disabled: !row.getCanSelect(),
|
|
3079
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3097
3080
|
};
|
|
3098
3081
|
|
|
3099
3082
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
@@ -3156,37 +3139,17 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3156
3139
|
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}`))) }));
|
|
3157
3140
|
};
|
|
3158
3141
|
|
|
3159
|
-
const TableHeader = ({ canResize = true,
|
|
3142
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3160
3143
|
const { table } = useDataTableContext();
|
|
3161
3144
|
const SELECTION_BOX_WIDTH = 20;
|
|
3162
|
-
const [hoveredCheckBox, setHoveredCheckBox] = React.useState(false);
|
|
3163
|
-
const handleRowHover = (isHovered) => {
|
|
3164
|
-
setHoveredCheckBox(isHovered);
|
|
3165
|
-
};
|
|
3166
|
-
const isCheckBoxVisible = () => {
|
|
3167
|
-
if (alwaysShowSelector) {
|
|
3168
|
-
return true;
|
|
3169
|
-
}
|
|
3170
|
-
if (table.getIsAllRowsSelected()) {
|
|
3171
|
-
return true;
|
|
3172
|
-
}
|
|
3173
|
-
if (hoveredCheckBox) {
|
|
3174
|
-
return true;
|
|
3175
|
-
}
|
|
3176
|
-
return false;
|
|
3177
|
-
};
|
|
3178
3145
|
const getThProps = (header) => {
|
|
3179
3146
|
const thProps = header.column.getIsPinned()
|
|
3180
3147
|
? {
|
|
3181
3148
|
left: showSelector
|
|
3182
3149
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3183
3150
|
: `${header.getStart("left")}px`,
|
|
3184
|
-
background: pinnedBgColor.light,
|
|
3185
3151
|
position: "sticky",
|
|
3186
3152
|
zIndex: 100 + 1,
|
|
3187
|
-
_dark: {
|
|
3188
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3189
|
-
},
|
|
3190
3153
|
}
|
|
3191
3154
|
: {};
|
|
3192
3155
|
return thProps;
|
|
@@ -3195,21 +3158,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3195
3158
|
position: "sticky",
|
|
3196
3159
|
top: 0,
|
|
3197
3160
|
};
|
|
3198
|
-
return (jsxRuntime.jsx(react.Table.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
zIndex: 1,
|
|
3206
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3207
|
-
}
|
|
3208
|
-
: {}),
|
|
3209
|
-
// styling resize and pinning end
|
|
3210
|
-
padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
3211
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3212
|
-
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), headerGroup.headers.map((header) => {
|
|
3161
|
+
return (jsxRuntime.jsx(react.Table.Header, { ...(isSticky ? stickyProps : {}), ...tableHeaderProps, children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", ...tableRowProps, children: [showSelector && (jsxRuntime.jsx(react.Table.ColumnHeader, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3162
|
+
base: "colorPalette.900",
|
|
3163
|
+
_dark: "colorPalette.100",
|
|
3164
|
+
},
|
|
3165
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: table.getIsAllRowsSelected(),
|
|
3166
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3167
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3213
3168
|
const resizeProps = {
|
|
3214
3169
|
onMouseDown: header.getResizeHandler(),
|
|
3215
3170
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3217,7 +3172,11 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3217
3172
|
};
|
|
3218
3173
|
return (jsxRuntime.jsxs(react.Table.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3219
3174
|
// styling resize and pinning start
|
|
3220
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3175
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3176
|
+
base: "colorPalette.800",
|
|
3177
|
+
_dark: "colorPalette.200",
|
|
3178
|
+
},
|
|
3179
|
+
bg: { base: "colorPalette.100", _dark: "colorPalette.900" }, ...getThProps(header), children: [jsxRuntime.jsxs(MenuRoot, { children: [jsxRuntime.jsx(MenuTrigger, { asChild: true, children: jsxRuntime.jsx(react.Flex, { padding: `${table.getDensityValue()}px`, alignItems: "center", justifyContent: "start", borderRadius: "0rem", overflow: "auto", _hover: {
|
|
3221
3180
|
backgroundColor: "gray.100",
|
|
3222
3181
|
_dark: {
|
|
3223
3182
|
backgroundColor: "gray.700",
|
|
@@ -3256,21 +3215,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3256
3215
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3257
3216
|
};
|
|
3258
3217
|
|
|
3259
|
-
const
|
|
3260
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3261
|
-
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
3262
|
-
});
|
|
3263
|
-
|
|
3264
|
-
const EmptyResult = (jsxRuntime.jsx(EmptyState$1, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
3265
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3266
|
-
const { table } = useDataTableContext();
|
|
3267
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3268
|
-
return emptyComponent;
|
|
3269
|
-
}
|
|
3270
|
-
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3271
|
-
};
|
|
3272
|
-
|
|
3273
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3218
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3274
3219
|
if (variant === "greedy") {
|
|
3275
3220
|
return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { canResize: false, ...{ ...tableProps }, children: [jsxRuntime.jsx(TableHeader, { canResize: false, ...tableHeaderProps }), jsxRuntime.jsx(TableBody, { canResize: false, ...tableBodyProps }), showFooter && (jsxRuntime.jsx(TableFooter, { canResize: false, ...tableFooterProps }))] }) }));
|
|
3276
3221
|
}
|
|
@@ -3530,16 +3475,82 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3530
3475
|
return columns;
|
|
3531
3476
|
};
|
|
3532
3477
|
|
|
3533
|
-
const
|
|
3534
|
-
const {
|
|
3535
|
-
|
|
3478
|
+
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3479
|
+
const { table, columns, translate, data } = useDataTableContext();
|
|
3480
|
+
const columnDef = table._getColumnDefs();
|
|
3481
|
+
console.log(columnDef, "glp");
|
|
3482
|
+
console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
|
|
3483
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3484
|
+
const { accessorKey, id } = def;
|
|
3485
|
+
if (accessorKey) {
|
|
3486
|
+
return [accessorKey, def];
|
|
3487
|
+
}
|
|
3488
|
+
return [id, def];
|
|
3489
|
+
}));
|
|
3490
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3491
|
+
const totalWidths = columns
|
|
3492
|
+
.map(({ size }) => {
|
|
3493
|
+
if (!!size === false) {
|
|
3494
|
+
return 0;
|
|
3495
|
+
}
|
|
3496
|
+
if (typeof size === "number") {
|
|
3497
|
+
return size;
|
|
3498
|
+
}
|
|
3499
|
+
return 0;
|
|
3500
|
+
})
|
|
3501
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3502
|
+
const columnWidths = columns
|
|
3503
|
+
.map(({ size }) => {
|
|
3504
|
+
if (!!size === false) {
|
|
3505
|
+
return "1fr";
|
|
3506
|
+
}
|
|
3507
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3508
|
+
})
|
|
3509
|
+
.join(" ");
|
|
3510
|
+
console.log({ columnWidths }, "hadfg");
|
|
3511
|
+
const cellProps = {
|
|
3512
|
+
flex: "1 0 0%",
|
|
3513
|
+
overflow: "auto",
|
|
3514
|
+
paddingX: "2",
|
|
3515
|
+
py: "1",
|
|
3516
|
+
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
3517
|
+
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
3518
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3519
|
+
borderBottomWidth: "1px",
|
|
3520
|
+
...{ colorPalette },
|
|
3521
|
+
};
|
|
3522
|
+
if (data.length <= 0) {
|
|
3523
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: emptyComponent });
|
|
3524
|
+
}
|
|
3525
|
+
return (jsxRuntime.jsxs(react.Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", color: { base: "colorPalette.900", _dark: "colorPalette.100" }, borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: [jsxRuntime.jsx(react.Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: columnHeaders.map((header) => {
|
|
3526
|
+
return (jsxRuntime.jsx(react.Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3527
|
+
}) }), data.map((record) => {
|
|
3528
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columnHeaders.map((header) => {
|
|
3529
|
+
const { cell } = columnsMap[header];
|
|
3530
|
+
const value = record[header];
|
|
3531
|
+
if (!!record === false) {
|
|
3532
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3533
|
+
}
|
|
3534
|
+
if (cell) {
|
|
3535
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3536
|
+
}
|
|
3537
|
+
if (typeof value === "object") {
|
|
3538
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: jsxRuntime.jsx(RecordDisplay, { object: value }) }));
|
|
3539
|
+
}
|
|
3540
|
+
return jsxRuntime.jsx(react.Box, { ...cellProps, children: value });
|
|
3541
|
+
}) }));
|
|
3542
|
+
})] }));
|
|
3536
3543
|
};
|
|
3537
3544
|
|
|
3538
|
-
const
|
|
3539
|
-
const {
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3545
|
+
const AccordionItemTrigger = React__namespace.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3546
|
+
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3547
|
+
return (jsxRuntime.jsxs(react.Accordion.ItemTrigger, { ...rest, ref: ref, children: [indicatorPlacement === "start" && (jsxRuntime.jsx(react.Accordion.ItemIndicator, { rotate: { base: "-90deg", _open: "0deg" }, children: jsxRuntime.jsx(lu.LuChevronDown, {}) })), jsxRuntime.jsx(react.HStack, { gap: "4", flex: "1", textAlign: "start", width: "full", children: children }), indicatorPlacement === "end" && (jsxRuntime.jsx(react.Accordion.ItemIndicator, { children: jsxRuntime.jsx(lu.LuChevronDown, {}) }))] }));
|
|
3548
|
+
});
|
|
3549
|
+
const AccordionItemContent = React__namespace.forwardRef(function AccordionItemContent(props, ref) {
|
|
3550
|
+
return (jsxRuntime.jsx(react.Accordion.ItemContent, { children: jsxRuntime.jsx(react.Accordion.ItemBody, { ...props, ref: ref }) }));
|
|
3551
|
+
});
|
|
3552
|
+
const AccordionRoot = react.Accordion.Root;
|
|
3553
|
+
const AccordionItem = react.Accordion.Item;
|
|
3543
3554
|
|
|
3544
3555
|
//@ts-expect-error TODO: find appropriate type
|
|
3545
3556
|
const SchemaFormContext = React.createContext({
|
|
@@ -3562,15 +3573,56 @@ const clearEmptyString = (object) => {
|
|
|
3562
3573
|
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== ""));
|
|
3563
3574
|
};
|
|
3564
3575
|
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
}
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3571
|
-
});
|
|
3572
|
-
|
|
3573
|
-
|
|
3576
|
+
const idPickerSanityCheck = (column, foreign_key) => {
|
|
3577
|
+
if (!!foreign_key == false) {
|
|
3578
|
+
throw new Error(`The key foreign_key does not exist in properties of column ${column} when using id-picker.`);
|
|
3579
|
+
}
|
|
3580
|
+
const { table, column: foreignKeyColumn, display_column } = foreign_key;
|
|
3581
|
+
if (!!table == false) {
|
|
3582
|
+
throw new Error(`The key table does not exist in properties of column ${table} when using id-picker.`);
|
|
3583
|
+
}
|
|
3584
|
+
if (!!display_column == false) {
|
|
3585
|
+
throw new Error(`The key display_column does not exist in properties of column ${column} when using id-picker.`);
|
|
3586
|
+
}
|
|
3587
|
+
if (!!foreignKeyColumn == false) {
|
|
3588
|
+
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, children, order = [], ignore = [], include = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, getUpdatedData = () => { }, }) => {
|
|
3592
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
3593
|
+
const [isError, setIsError] = React.useState(false);
|
|
3594
|
+
const [isSubmiting, setIsSubmiting] = React.useState(false);
|
|
3595
|
+
const [isConfirming, setIsConfirming] = React.useState(false);
|
|
3596
|
+
const [validatedData, setValidatedData] = React.useState();
|
|
3597
|
+
const [error, setError] = React.useState();
|
|
3598
|
+
return (jsxRuntime.jsx(SchemaFormContext.Provider, { value: {
|
|
3599
|
+
schema,
|
|
3600
|
+
serverUrl,
|
|
3601
|
+
order,
|
|
3602
|
+
ignore,
|
|
3603
|
+
include,
|
|
3604
|
+
// @ts-expect-error TODO: find appropriate types
|
|
3605
|
+
onSubmit,
|
|
3606
|
+
rowNumber,
|
|
3607
|
+
idMap,
|
|
3608
|
+
setIdMap,
|
|
3609
|
+
translate,
|
|
3610
|
+
requestOptions,
|
|
3611
|
+
isSuccess,
|
|
3612
|
+
setIsSuccess,
|
|
3613
|
+
isError,
|
|
3614
|
+
setIsError,
|
|
3615
|
+
isSubmiting,
|
|
3616
|
+
setIsSubmiting,
|
|
3617
|
+
isConfirming,
|
|
3618
|
+
setIsConfirming,
|
|
3619
|
+
validatedData,
|
|
3620
|
+
setValidatedData,
|
|
3621
|
+
error,
|
|
3622
|
+
setError,
|
|
3623
|
+
getUpdatedData,
|
|
3624
|
+
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: children }) }));
|
|
3625
|
+
};
|
|
3574
3626
|
|
|
3575
3627
|
function removeIndex(str) {
|
|
3576
3628
|
return str.replace(/\.\d+\./g, '.');
|
|
@@ -3585,7 +3637,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3585
3637
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3586
3638
|
const { formState: { errors }, setValue, watch, } = reactHookForm.useFormContext();
|
|
3587
3639
|
const fields = (watch(colLabel) ?? []);
|
|
3588
|
-
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
3640
|
+
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] }), fields.map((field, index) => (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", children: [jsxRuntime.jsx(react.Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: jsxRuntime.jsx(SchemaRenderer, { column: `${index}`,
|
|
3589
3641
|
prefix: `${colLabel}.`,
|
|
3590
3642
|
schema: items }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(react.Button, { variant: "ghost", onClick: () => {
|
|
3591
3643
|
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
@@ -3605,7 +3657,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3605
3657
|
return;
|
|
3606
3658
|
}
|
|
3607
3659
|
setValue(colLabel, [...fields, {}]);
|
|
3608
|
-
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3660
|
+
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3609
3661
|
};
|
|
3610
3662
|
|
|
3611
3663
|
const Field = React__namespace.forwardRef(function Field(props, ref) {
|
|
@@ -3620,10 +3672,10 @@ const BooleanPicker = ({ schema, column, prefix }) => {
|
|
|
3620
3672
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3621
3673
|
const colLabel = `${prefix}${column}`;
|
|
3622
3674
|
const value = watch(colLabel);
|
|
3623
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
3675
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3624
3676
|
gridRow, children: [jsxRuntime.jsx(CheckboxCard, { checked: value, variant: "surface", onChange: () => {
|
|
3625
3677
|
setValue(colLabel, !value);
|
|
3626
|
-
} }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3678
|
+
} }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3627
3679
|
};
|
|
3628
3680
|
|
|
3629
3681
|
const monthNamesShort = [
|
|
@@ -3721,10 +3773,11 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3721
3773
|
const colLabel = `${prefix}${column}`;
|
|
3722
3774
|
const [open, setOpen] = React.useState(false);
|
|
3723
3775
|
const selectedDate = watch(colLabel);
|
|
3724
|
-
|
|
3776
|
+
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3777
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3725
3778
|
gridRow, children: [jsxRuntime.jsxs(PopoverRoot, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: jsxRuntime.jsx(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
3726
3779
|
setOpen(true);
|
|
3727
|
-
}, children: selectedDate !== undefined ?
|
|
3780
|
+
}, children: selectedDate !== undefined ? `${formatedDate}` : "" }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(DatePicker$1
|
|
3728
3781
|
// @ts-expect-error TODO: find appropriate types
|
|
3729
3782
|
, {
|
|
3730
3783
|
// @ts-expect-error TODO: find appropriate types
|
|
@@ -3733,7 +3786,7 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3733
3786
|
onDateSelected: ({ date }) => {
|
|
3734
3787
|
setValue(colLabel, dayjs(date).format("YYYY-MM-DD"));
|
|
3735
3788
|
setOpen(false);
|
|
3736
|
-
} })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3789
|
+
} })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3737
3790
|
};
|
|
3738
3791
|
|
|
3739
3792
|
function filterArray(array, searchTerm) {
|
|
@@ -3766,25 +3819,24 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3766
3819
|
setSearchText(event.target.value);
|
|
3767
3820
|
setLimit(10);
|
|
3768
3821
|
};
|
|
3769
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
3822
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3770
3823
|
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3771
3824
|
const item = enumValue;
|
|
3772
3825
|
if (item === undefined) {
|
|
3773
3826
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
3774
3827
|
}
|
|
3775
3828
|
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
3776
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3777
3829
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3778
3830
|
}, children: !!renderDisplay === true
|
|
3779
3831
|
? renderDisplay(item)
|
|
3780
3832
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
3781
3833
|
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3782
3834
|
setOpenSearchResult(true);
|
|
3783
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
3835
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
3784
3836
|
setOpenSearchResult(true);
|
|
3785
3837
|
}, children: watchEnum === undefined
|
|
3786
3838
|
? ""
|
|
3787
|
-
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsxRuntime.jsx(react.Input, { placeholder: translate.t(`${column}.
|
|
3839
|
+
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsxRuntime.jsx(react.Input, { placeholder: translate.t(`${column}.type_to_search`), onChange: (event) => {
|
|
3788
3840
|
onSearchChange(event);
|
|
3789
3841
|
setOpenSearchResult(true);
|
|
3790
3842
|
}, autoComplete: "off", ref: ref }), jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(react.Text, { children: `${translate.t(`${column}.total`)}: ${count}, ${translate.t(`${column}.showing`)} ${limit}` }), jsxRuntime.jsxs(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children: filterArray(dataList, searchText ?? "").map((item) => {
|
|
@@ -3802,7 +3854,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3802
3854
|
}, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true
|
|
3803
3855
|
? renderDisplay(item)
|
|
3804
3856
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }, `${colLabel}-${item}`));
|
|
3805
|
-
}) }), isDirty && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: dataList.length <= 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: translate.t(removeIndex(`${colLabel}.
|
|
3857
|
+
}) }), isDirty && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: dataList.length <= 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: translate.t(removeIndex(`${colLabel}.empty_search_result`)) })) }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3806
3858
|
};
|
|
3807
3859
|
|
|
3808
3860
|
function isEnteringWindow(_ref) {
|
|
@@ -4164,7 +4216,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4164
4216
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4165
4217
|
const currentFiles = (watch(column) ?? []);
|
|
4166
4218
|
const colLabel = `${prefix}${column}`;
|
|
4167
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4219
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${colLabel}.field_label`)}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", display: "grid", gridTemplateRows: "auto 1fr auto", alignItems: "stretch", children: [jsxRuntime.jsx(FileDropzone, { onDrop: ({ files }) => {
|
|
4168
4220
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4169
4221
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4170
4222
|
}, placeholder: translate.t(removeIndex(`${colLabel}.fileDropzone`)) }), jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4173,7 +4225,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4173
4225
|
return name !== file.name;
|
|
4174
4226
|
}));
|
|
4175
4227
|
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [jsxRuntime.jsx(react.Box, { children: file.name }), jsxRuntime.jsx(ti.TiDeleteOutline, {})] }) }, file.name));
|
|
4176
|
-
}) }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4228
|
+
}) }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4177
4229
|
};
|
|
4178
4230
|
|
|
4179
4231
|
const getTableData = async ({ serverUrl, in_table, searching = "", where = [], limit = 10, offset = 0, }) => {
|
|
@@ -4290,7 +4342,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4290
4342
|
}
|
|
4291
4343
|
return record[display_column];
|
|
4292
4344
|
};
|
|
4293
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.
|
|
4345
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.field_label`)))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4294
4346
|
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [watchIds.map((id) => {
|
|
4295
4347
|
const item = idMap[id];
|
|
4296
4348
|
if (item === undefined) {
|
|
@@ -4303,7 +4355,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4303
4355
|
: item[display_column] }, id));
|
|
4304
4356
|
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4305
4357
|
setOpenSearchResult(true);
|
|
4306
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
4358
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
4307
4359
|
setOpenSearchResult(true);
|
|
4308
4360
|
}, children: getPickedValue() })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start", strategy: "fixed" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsxRuntime.jsx(react.Input, { placeholder: translate.t(removeIndex(`${colLabel}.typeToSearch`)), onChange: (event) => {
|
|
4309
4361
|
onSearchChange(event);
|
|
@@ -4328,7 +4380,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4328
4380
|
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true
|
|
4329
4381
|
? renderDisplay(item)
|
|
4330
4382
|
: item[display_column] }, item[column_ref]));
|
|
4331
|
-
}) }), isDirty && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: dataList.length <= 0 && (jsxRuntime.jsx(react.Text, { children: translate.t(removeIndex(`${colLabel}.
|
|
4383
|
+
}) }), isDirty && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: dataList.length <= 0 && (jsxRuntime.jsx(react.Text, { children: translate.t(removeIndex(`${colLabel}.empty_search_result`)) })) }))] }), jsxRuntime.jsx(PaginationRoot, { justifySelf: "center", count: count, pageSize: 10, defaultPage: 1, page: page + 1, onPageChange: (e) => setPage(e.page - 1), children: jsxRuntime.jsxs(react.HStack, { gap: "4", children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), count > 0 && jsxRuntime.jsx(PaginationPageText, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) })] }))] }) })] }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4332
4384
|
};
|
|
4333
4385
|
|
|
4334
4386
|
const NumberInputRoot = React__namespace.forwardRef(function NumberInput(props, ref) {
|
|
@@ -4346,9 +4398,9 @@ const NumberInputField = ({ schema, column, prefix, }) => {
|
|
|
4346
4398
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4347
4399
|
const colLabel = `${prefix}${column}`;
|
|
4348
4400
|
const value = watch(`${colLabel}`);
|
|
4349
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4401
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn, gridRow, children: [jsxRuntime.jsx(NumberInputRoot, { children: jsxRuntime.jsx(NumberInputField$1, { required: isRequired, value: value, onChange: (event) => {
|
|
4350
4402
|
setValue(`${colLabel}`, Number(event.target.value));
|
|
4351
|
-
} }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4403
|
+
} }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4352
4404
|
};
|
|
4353
4405
|
|
|
4354
4406
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
@@ -4360,13 +4412,13 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4360
4412
|
if (properties === undefined) {
|
|
4361
4413
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4362
4414
|
}
|
|
4363
|
-
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4415
|
+
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] }), jsxRuntime.jsx(react.Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: Object.keys(properties ?? {}).map((key) => {
|
|
4364
4416
|
return (
|
|
4365
4417
|
// @ts-expect-error find suitable types
|
|
4366
4418
|
jsxRuntime.jsx(ColumnRenderer, { column: `${key}`,
|
|
4367
4419
|
prefix: `${prefix}${column}.`,
|
|
4368
4420
|
properties }, `form-${colLabel}-${key}`));
|
|
4369
|
-
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4421
|
+
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4370
4422
|
};
|
|
4371
4423
|
|
|
4372
4424
|
const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
@@ -4378,7 +4430,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4378
4430
|
const [showNewEntries, setShowNewEntries] = React.useState(false);
|
|
4379
4431
|
const [newKey, setNewKey] = React.useState();
|
|
4380
4432
|
const [newValue, setNewValue] = React.useState();
|
|
4381
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.
|
|
4433
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4382
4434
|
return (jsxRuntime.jsxs(react.Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsxRuntime.jsx(react.Input, { value: key, onChange: (e) => {
|
|
4383
4435
|
const filtered = entries.filter(([target]) => {
|
|
4384
4436
|
return target !== key;
|
|
@@ -4418,7 +4470,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4418
4470
|
setShowNewEntries(true);
|
|
4419
4471
|
setNewKey(undefined);
|
|
4420
4472
|
setNewValue(undefined);
|
|
4421
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.
|
|
4473
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4422
4474
|
};
|
|
4423
4475
|
|
|
4424
4476
|
const StringInputField = ({ column, schema, prefix, }) => {
|
|
@@ -4427,7 +4479,7 @@ const StringInputField = ({ column, schema, prefix, }) => {
|
|
|
4427
4479
|
const { required, gridColumn, gridRow } = schema;
|
|
4428
4480
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4429
4481
|
const colLabel = `${prefix}${column}`;
|
|
4430
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4482
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", children: [jsxRuntime.jsx(react.Input, { ...register(`${colLabel}`, { required: isRequired }), autoComplete: "off" }), errors[colLabel] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4431
4483
|
};
|
|
4432
4484
|
|
|
4433
4485
|
const RadioCardItem = React__namespace.forwardRef(function RadioCardItem(props, ref) {
|
|
@@ -4591,9 +4643,9 @@ const ArrayViewer = ({ schema, column, prefix }) => {
|
|
|
4591
4643
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4592
4644
|
const { watch, formState: { errors }, } = reactHookForm.useFormContext();
|
|
4593
4645
|
const values = watch(colLabel) ?? [];
|
|
4594
|
-
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4646
|
+
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] }), values.map((field, index) => (jsxRuntime.jsx(react.Flex, { flexFlow: "column", children: jsxRuntime.jsx(react.Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: jsxRuntime.jsx(SchemaViewer, { column: `${index}`,
|
|
4595
4647
|
prefix: `${colLabel}.`,
|
|
4596
|
-
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4648
|
+
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4597
4649
|
};
|
|
4598
4650
|
|
|
4599
4651
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4603,10 +4655,10 @@ const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
|
4603
4655
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4604
4656
|
const colLabel = `${prefix}${column}`;
|
|
4605
4657
|
const value = watch(colLabel);
|
|
4606
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4658
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4607
4659
|
gridRow, children: [jsxRuntime.jsx(react.Text, { children: value
|
|
4608
4660
|
? translate.t(removeIndex(`${colLabel}.true`))
|
|
4609
|
-
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4661
|
+
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4610
4662
|
};
|
|
4611
4663
|
|
|
4612
4664
|
const DateViewer = ({ column, schema, prefix }) => {
|
|
@@ -4616,8 +4668,8 @@ const DateViewer = ({ column, schema, prefix }) => {
|
|
|
4616
4668
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4617
4669
|
const colLabel = `${prefix}${column}`;
|
|
4618
4670
|
const selectedDate = watch(colLabel);
|
|
4619
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4620
|
-
gridRow, children: [jsxRuntime.jsxs(react.Text, { children: [" ", selectedDate !== undefined ? selectedDate : ""] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.
|
|
4671
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4672
|
+
gridRow, children: [jsxRuntime.jsxs(react.Text, { children: [" ", selectedDate !== undefined ? selectedDate : ""] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4621
4673
|
};
|
|
4622
4674
|
|
|
4623
4675
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
@@ -4629,7 +4681,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4629
4681
|
const colLabel = `${prefix}${column}`;
|
|
4630
4682
|
const watchEnum = watch(colLabel);
|
|
4631
4683
|
const watchEnums = (watch(colLabel) ?? []);
|
|
4632
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4684
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4633
4685
|
gridRow, children: [isMultiple && (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
4634
4686
|
const item = enumValue;
|
|
4635
4687
|
if (item === undefined) {
|
|
@@ -4638,7 +4690,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4638
4690
|
return (jsxRuntime.jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4639
4691
|
? renderDisplay(item)
|
|
4640
4692
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
4641
|
-
}) })), !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}.
|
|
4693
|
+
}) })), !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`)) }))] }));
|
|
4642
4694
|
};
|
|
4643
4695
|
|
|
4644
4696
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
@@ -4648,7 +4700,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4648
4700
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4649
4701
|
const currentFiles = (watch(column) ?? []);
|
|
4650
4702
|
const colLabel = `${prefix}${column}`;
|
|
4651
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4703
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${colLabel}.field_label`)}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", display: "grid", gridTemplateRows: "auto 1fr auto", alignItems: "stretch", children: [jsxRuntime.jsx(FileDropzone, { onDrop: ({ files }) => {
|
|
4652
4704
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4653
4705
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4654
4706
|
}, placeholder: translate.t(`${colLabel}.fileDropzone`) }), jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4657,7 +4709,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4657
4709
|
return name !== file.name;
|
|
4658
4710
|
}));
|
|
4659
4711
|
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [jsxRuntime.jsx(react.Box, { children: file.name }), jsxRuntime.jsx(ti.TiDeleteOutline, {})] }) }, file.name));
|
|
4660
|
-
}) }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4712
|
+
}) }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4661
4713
|
};
|
|
4662
4714
|
|
|
4663
4715
|
const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
@@ -4679,7 +4731,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4679
4731
|
}
|
|
4680
4732
|
return record[display_column];
|
|
4681
4733
|
};
|
|
4682
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4734
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4683
4735
|
gridRow, children: [isMultiple && (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 1, children: watchIds.map((id) => {
|
|
4684
4736
|
const item = idMap[id];
|
|
4685
4737
|
if (item === undefined) {
|
|
@@ -4688,7 +4740,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4688
4740
|
return (jsxRuntime.jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4689
4741
|
? renderDisplay(item)
|
|
4690
4742
|
: item[display_column] }, id));
|
|
4691
|
-
}) })), !isMultiple && jsxRuntime.jsx(react.Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4743
|
+
}) })), !isMultiple && jsxRuntime.jsx(react.Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4692
4744
|
};
|
|
4693
4745
|
|
|
4694
4746
|
const NumberViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4698,7 +4750,7 @@ const NumberViewer = ({ schema, column, prefix, }) => {
|
|
|
4698
4750
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4699
4751
|
const colLabel = `${prefix}${column}`;
|
|
4700
4752
|
const value = watch(colLabel);
|
|
4701
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4753
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn, gridRow, children: [jsxRuntime.jsx(react.Text, { children: value }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4702
4754
|
};
|
|
4703
4755
|
|
|
4704
4756
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
@@ -4710,13 +4762,13 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
4710
4762
|
if (properties === undefined) {
|
|
4711
4763
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4712
4764
|
}
|
|
4713
|
-
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4765
|
+
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsxRuntime.jsx("span", { children: "*" })] }), jsxRuntime.jsx(react.Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: Object.keys(properties ?? {}).map((key) => {
|
|
4714
4766
|
return (
|
|
4715
4767
|
// @ts-expect-error find suitable types
|
|
4716
4768
|
jsxRuntime.jsx(ColumnViewer, { column: `${key}`,
|
|
4717
4769
|
prefix: `${prefix}${column}.`,
|
|
4718
4770
|
properties }, `form-objectviewer-${colLabel}-${key}`));
|
|
4719
|
-
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4771
|
+
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4720
4772
|
};
|
|
4721
4773
|
|
|
4722
4774
|
const RecordInput = ({ column, schema, prefix }) => {
|
|
@@ -4728,7 +4780,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4728
4780
|
const [showNewEntries, setShowNewEntries] = React.useState(false);
|
|
4729
4781
|
const [newKey, setNewKey] = React.useState();
|
|
4730
4782
|
const [newValue, setNewValue] = React.useState();
|
|
4731
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.
|
|
4783
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4732
4784
|
return (jsxRuntime.jsxs(react.Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsxRuntime.jsx(react.Input, { value: key, onChange: (e) => {
|
|
4733
4785
|
const filtered = entries.filter(([target]) => {
|
|
4734
4786
|
return target !== key;
|
|
@@ -4768,7 +4820,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4768
4820
|
setShowNewEntries(true);
|
|
4769
4821
|
setNewKey(undefined);
|
|
4770
4822
|
setNewValue(undefined);
|
|
4771
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.
|
|
4823
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4772
4824
|
};
|
|
4773
4825
|
|
|
4774
4826
|
const TagViewer = ({ column, schema, prefix }) => {
|
|
@@ -4863,7 +4915,7 @@ const StringViewer = ({ column, schema, prefix, }) => {
|
|
|
4863
4915
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4864
4916
|
const colLabel = `${prefix}${column}`;
|
|
4865
4917
|
const value = watch(colLabel);
|
|
4866
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4918
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", children: [jsxRuntime.jsx(react.Text, { children: value }), errors[colLabel] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4867
4919
|
};
|
|
4868
4920
|
|
|
4869
4921
|
const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
@@ -4927,30 +4979,23 @@ const ColumnViewer = ({ column, properties, prefix, }) => {
|
|
|
4927
4979
|
return jsxRuntime.jsx(SchemaViewer, { schema: colSchema, prefix, column });
|
|
4928
4980
|
};
|
|
4929
4981
|
|
|
4930
|
-
const
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
const
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
4943
|
-
}
|
|
4982
|
+
const SubmitButton = () => {
|
|
4983
|
+
const { translate, setValidatedData, setIsError, setIsConfirming } = useSchemaContext();
|
|
4984
|
+
const methods = reactHookForm.useFormContext();
|
|
4985
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4986
|
+
const onValid = (data) => {
|
|
4987
|
+
setValidatedData(data);
|
|
4988
|
+
setIsError(false);
|
|
4989
|
+
setIsConfirming(true);
|
|
4990
|
+
};
|
|
4991
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
4992
|
+
methods.handleSubmit(onValid)();
|
|
4993
|
+
}, formNoValidate: true, children: translate.t("submit") }));
|
|
4944
4994
|
};
|
|
4945
|
-
|
|
4946
|
-
|
|
4995
|
+
|
|
4996
|
+
const FormBody = () => {
|
|
4997
|
+
const { schema, requestUrl, order, ignore, include, onSubmit, rowNumber, translate, requestOptions, isSuccess, setIsSuccess, isError, setIsError, isSubmiting, setIsSubmiting, isConfirming, setIsConfirming, validatedData, setValidatedData, error, setError, getUpdatedData, } = useSchemaContext();
|
|
4947
4998
|
const methods = reactHookForm.useFormContext();
|
|
4948
|
-
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
4949
|
-
const [isError, setIsError] = React.useState(false);
|
|
4950
|
-
const [isSubmiting, setIsSubmiting] = React.useState(false);
|
|
4951
|
-
const [isConfirming, setIsConfirming] = React.useState(false);
|
|
4952
|
-
const [validatedData, setValidatedData] = React.useState();
|
|
4953
|
-
const [error, setError] = React.useState();
|
|
4954
4999
|
const { properties } = schema;
|
|
4955
5000
|
const onBeforeSubmit = () => {
|
|
4956
5001
|
setIsSubmiting(true);
|
|
@@ -4958,8 +5003,9 @@ const FormInternal = () => {
|
|
|
4958
5003
|
const onAfterSubmit = () => {
|
|
4959
5004
|
setIsSubmiting(false);
|
|
4960
5005
|
};
|
|
4961
|
-
const onSubmitError = () => {
|
|
5006
|
+
const onSubmitError = (error) => {
|
|
4962
5007
|
setIsError(true);
|
|
5008
|
+
setError(error);
|
|
4963
5009
|
};
|
|
4964
5010
|
const onSubmitSuccess = () => {
|
|
4965
5011
|
setIsSuccess(true);
|
|
@@ -4971,9 +5017,7 @@ const FormInternal = () => {
|
|
|
4971
5017
|
onSubmitSuccess();
|
|
4972
5018
|
}
|
|
4973
5019
|
catch (error) {
|
|
4974
|
-
|
|
4975
|
-
setError(error);
|
|
4976
|
-
onSubmitError();
|
|
5020
|
+
onSubmitError(error);
|
|
4977
5021
|
}
|
|
4978
5022
|
finally {
|
|
4979
5023
|
onAfterSubmit();
|
|
@@ -4996,12 +5040,6 @@ const FormInternal = () => {
|
|
|
4996
5040
|
}
|
|
4997
5041
|
await defaultOnSubmit(onSubmit(data));
|
|
4998
5042
|
};
|
|
4999
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5000
|
-
const onValid = (data) => {
|
|
5001
|
-
setValidatedData(data);
|
|
5002
|
-
setIsError(false);
|
|
5003
|
-
setIsConfirming(true);
|
|
5004
|
-
};
|
|
5005
5043
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
5006
5044
|
const included = include.length > 0 ? include : keys;
|
|
5007
5045
|
const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
|
|
@@ -5016,58 +5054,47 @@ const FormInternal = () => {
|
|
|
5016
5054
|
include,
|
|
5017
5055
|
});
|
|
5018
5056
|
if (isSuccess) {
|
|
5019
|
-
return (jsxRuntime.jsxs(react.
|
|
5057
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsxs(react.Alert.Root, { status: "success", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsx(react.Alert.Title, { children: translate.t("submit_success") })] }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(react.Button, { onClick: async () => {
|
|
5020
5058
|
setIsError(false);
|
|
5021
5059
|
setIsSubmiting(false);
|
|
5022
5060
|
setIsSuccess(false);
|
|
5023
5061
|
setIsConfirming(false);
|
|
5024
5062
|
setValidatedData(undefined);
|
|
5025
|
-
|
|
5026
|
-
|
|
5063
|
+
const data = await getUpdatedData();
|
|
5064
|
+
methods.reset(data);
|
|
5065
|
+
}, formNoValidate: true, children: translate.t("submit_again") }) })] }));
|
|
5027
5066
|
}
|
|
5028
5067
|
if (isConfirming) {
|
|
5029
|
-
return (jsxRuntime.jsxs(react.
|
|
5068
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsx(react.Grid, { gap: 4, gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat(${rowNumber ?? "auto-fit"}, auto)`, children: ordered.map((column) => {
|
|
5030
5069
|
return (jsxRuntime.jsx(ColumnViewer
|
|
5031
5070
|
// @ts-expect-error find suitable types
|
|
5032
5071
|
, {
|
|
5033
5072
|
// @ts-expect-error find suitable types
|
|
5034
5073
|
properties: properties, prefix: ``, column }, `form-viewer-${column}`));
|
|
5035
|
-
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
5074
|
+
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5036
5075
|
setIsConfirming(false);
|
|
5037
|
-
}, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
5076
|
+
}, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5038
5077
|
onFormSubmit(validatedData);
|
|
5039
|
-
}, children: translate.t("confirm") })] }), isSubmiting && (jsxRuntime.jsx(react.Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsxRuntime.jsx(react.Center, { h: "full", children: jsxRuntime.jsx(react.Spinner, { color: "teal.500" }) }) })), isError && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react.Alert.Root, { status: "error", children: jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [
|
|
5078
|
+
}, children: translate.t("confirm") })] }), isSubmiting && (jsxRuntime.jsx(react.Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsxRuntime.jsx(react.Center, { h: "full", children: jsxRuntime.jsx(react.Spinner, { color: "teal.500" }) }) })), isError && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react.Alert.Root, { status: "error", children: jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "b", children: [jsxRuntime.jsxs(AccordionItemTrigger, { children: [jsxRuntime.jsx(react.Alert.Indicator, {}), `${error}`] }), jsxRuntime.jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) }) }))] }));
|
|
5040
5079
|
}
|
|
5041
|
-
return (jsxRuntime.
|
|
5042
|
-
|
|
5080
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsx(react.Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat(${rowNumber ?? "auto-fit"}, auto)`, children: ordered.map((column) => {
|
|
5081
|
+
return (jsxRuntime.jsx(ColumnRenderer
|
|
5082
|
+
// @ts-expect-error find suitable types
|
|
5083
|
+
, {
|
|
5043
5084
|
// @ts-expect-error find suitable types
|
|
5044
|
-
, {
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
methods.reset();
|
|
5049
|
-
}, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
5050
|
-
methods.handleSubmit(onValid)();
|
|
5051
|
-
}, formNoValidate: true, children: translate.t("submit") })] })] }) }));
|
|
5085
|
+
properties: properties, prefix: ``, column }, `form-input-${column}`));
|
|
5086
|
+
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5087
|
+
methods.reset();
|
|
5088
|
+
}, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(SubmitButton, {})] })] }));
|
|
5052
5089
|
};
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
ignore,
|
|
5062
|
-
include,
|
|
5063
|
-
// @ts-expect-error TODO: find appropriate types
|
|
5064
|
-
onSubmit,
|
|
5065
|
-
rowNumber,
|
|
5066
|
-
idMap,
|
|
5067
|
-
setIdMap,
|
|
5068
|
-
translate,
|
|
5069
|
-
requestOptions,
|
|
5070
|
-
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(FormInternal, {}) }) }));
|
|
5090
|
+
|
|
5091
|
+
const FormTitle = () => {
|
|
5092
|
+
const { translate } = useSchemaContext();
|
|
5093
|
+
return jsxRuntime.jsx(react.Heading, { children: translate.t("title") });
|
|
5094
|
+
};
|
|
5095
|
+
|
|
5096
|
+
const DefaultForm = ({ formConfig, showTitle = true, }) => {
|
|
5097
|
+
return (jsxRuntime.jsx(FormRoot, { ...formConfig, children: jsxRuntime.jsxs(react.Grid, { gap: "2", children: [showTitle && jsxRuntime.jsx(FormTitle, {}), jsxRuntime.jsx(FormBody, {})] }) }));
|
|
5071
5098
|
};
|
|
5072
5099
|
|
|
5073
5100
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5105,15 +5132,17 @@ exports.DataDisplay = DataDisplay;
|
|
|
5105
5132
|
exports.DataTable = DataTable;
|
|
5106
5133
|
exports.DataTableServer = DataTableServer;
|
|
5107
5134
|
exports.DefaultCardTitle = DefaultCardTitle;
|
|
5135
|
+
exports.DefaultForm = DefaultForm;
|
|
5108
5136
|
exports.DefaultTable = DefaultTable;
|
|
5109
5137
|
exports.DensityToggleButton = DensityToggleButton;
|
|
5110
|
-
exports.EditOrderButton = EditOrderButton;
|
|
5111
5138
|
exports.EditSortingButton = EditSortingButton;
|
|
5112
|
-
exports.EmptyState = EmptyState;
|
|
5139
|
+
exports.EmptyState = EmptyState$1;
|
|
5113
5140
|
exports.ErrorAlert = ErrorAlert;
|
|
5114
5141
|
exports.FilterDialog = FilterDialog;
|
|
5115
5142
|
exports.FilterOptions = FilterOptions;
|
|
5116
|
-
exports.
|
|
5143
|
+
exports.FormBody = FormBody;
|
|
5144
|
+
exports.FormRoot = FormRoot;
|
|
5145
|
+
exports.FormTitle = FormTitle;
|
|
5117
5146
|
exports.GlobalFilter = GlobalFilter;
|
|
5118
5147
|
exports.PageSizeControl = PageSizeControl;
|
|
5119
5148
|
exports.Pagination = Pagination;
|
|
@@ -5129,12 +5158,12 @@ exports.TableCardContainer = TableCardContainer;
|
|
|
5129
5158
|
exports.TableCards = TableCards;
|
|
5130
5159
|
exports.TableComponent = TableComponent;
|
|
5131
5160
|
exports.TableControls = TableControls;
|
|
5161
|
+
exports.TableDataDisplay = TableDataDisplay;
|
|
5132
5162
|
exports.TableFilter = TableFilter;
|
|
5133
5163
|
exports.TableFilterTags = TableFilterTags;
|
|
5134
5164
|
exports.TableFooter = TableFooter;
|
|
5135
5165
|
exports.TableHeader = TableHeader;
|
|
5136
5166
|
exports.TableLoadingComponent = TableLoadingComponent;
|
|
5137
|
-
exports.TableOrderer = TableOrderer;
|
|
5138
5167
|
exports.TableSelector = TableSelector;
|
|
5139
5168
|
exports.TableSorter = TableSorter;
|
|
5140
5169
|
exports.TableViewer = TableViewer;
|