@bsol-oss/react-datatable5 12.0.0-beta.2 → 12.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +89 -88
- package/dist/index.js +542 -533
- package/dist/index.mjs +539 -532
- 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 +23 -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 +5 -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: "colorPalette.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) => {
|
|
@@ -2621,7 +2589,7 @@ const RecordDisplay = ({ object, boxProps, translate, prefix = "", }) => {
|
|
|
2621
2589
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "null" });
|
|
2622
2590
|
}
|
|
2623
2591
|
return (jsxRuntime.jsx(react.Grid, { rowGap: 1, padding: 1, overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
2624
|
-
return (jsxRuntime.jsxs(react.Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsxRuntime.jsx(react.Text, { color: "
|
|
2592
|
+
return (jsxRuntime.jsxs(react.Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsxRuntime.jsx(react.Text, { color: "colorPalette.400", children: getColumn({ field }) }), typeof value === "object" ? (jsxRuntime.jsx(RecordDisplay, { object: value, prefix: `${prefix}${field}.`, translate: translate })) : (jsxRuntime.jsx(react.Text, { children: JSON.stringify(value) }))] }, field));
|
|
2625
2593
|
}) }));
|
|
2626
2594
|
};
|
|
2627
2595
|
|
|
@@ -2671,7 +2639,7 @@ const CellRenderer = ({ cell }) => {
|
|
|
2671
2639
|
paddingY: 2,
|
|
2672
2640
|
}, object: value })] }, cell.id));
|
|
2673
2641
|
}
|
|
2674
|
-
return (jsxRuntime.jsxs(react.Box, { gridColumn, gridRow, children: [jsxRuntime.jsx(react.Box, { color:
|
|
2642
|
+
return (jsxRuntime.jsxs(react.Box, { gridColumn, gridRow, children: [jsxRuntime.jsx(react.Box, { color: "colorPalette.400", children: getLabel({ columnId: cell.column.id }) }), jsxRuntime.jsx(react.Box, { wordBreak: "break-word", textOverflow: "ellipsis", overflow: "hidden", children: `${formatValue(cell.getValue())}` })] }, cell.id));
|
|
2675
2643
|
};
|
|
2676
2644
|
const DataDisplay = ({ variant = "" }) => {
|
|
2677
2645
|
const { table, translate } = useDataTableContext();
|
|
@@ -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();
|
|
@@ -3087,16 +2995,89 @@ const TableFilterTags = () => {
|
|
|
3087
2995
|
}) }));
|
|
3088
2996
|
};
|
|
3089
2997
|
|
|
3090
|
-
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, }) => {
|
|
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, gridProps = {}, }) => {
|
|
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", ...gridProps, children: [jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsx(react.Box, { children: showView && jsxRuntime.jsx(ViewDialog, { icon: jsxRuntime.jsx(md.MdOutlineViewColumn, {}) }) }), jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsxRuntime.jsx(react.Spinner, { size: "sm" }), hasError && (jsxRuntime.jsx(Tooltip, { content: translate.t("has_error"), children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsxRuntime.jsx(GlobalFilter, {}), showFilter && jsxRuntime.jsx(FilterDialog, {}), showReload && jsxRuntime.jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
|
|
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
|
-
}) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Grid, { overflow: "auto",
|
|
3095
|
-
|
|
3096
|
-
|
|
3002
|
+
}) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Grid, { overflow: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, children: children }), (showPageSizeControl || showPageCountText || showPagination) && (jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsxs(react.Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsxRuntime.jsx(PageSizeControl, {}), showPageCountText && (jsxRuntime.jsxs(react.Flex, { children: [jsxRuntime.jsx(react.Text, { paddingRight: "0.5rem", children: translate.t("rowcount.total") }), jsxRuntime.jsx(RowCountText, {})] }))] }), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: showPagination && jsxRuntime.jsx(Pagination, {}) })] }))] }));
|
|
3003
|
+
};
|
|
3004
|
+
|
|
3005
|
+
const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
3006
|
+
const { title, description, icon, children, ...rest } = props;
|
|
3007
|
+
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] }) }));
|
|
3008
|
+
});
|
|
3009
|
+
|
|
3010
|
+
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" })] }) }));
|
|
3011
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3012
|
+
const { table } = useDataTableContext();
|
|
3013
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
3014
|
+
return emptyComponent;
|
|
3015
|
+
}
|
|
3016
|
+
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...props, children: children }));
|
|
3017
|
+
};
|
|
3018
|
+
|
|
3019
|
+
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
3020
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3021
|
+
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 }))] }));
|
|
3022
|
+
});
|
|
3023
|
+
|
|
3024
|
+
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
3025
|
+
"use no memo";
|
|
3026
|
+
const { table } = useDataTableContext();
|
|
3027
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3028
|
+
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
3029
|
+
const handleRowHover = (index) => {
|
|
3030
|
+
setHoveredRow(index);
|
|
3031
|
+
};
|
|
3032
|
+
const getTdProps = (cell) => {
|
|
3033
|
+
const tdProps = cell.column.getIsPinned()
|
|
3034
|
+
? {
|
|
3035
|
+
left: showSelector
|
|
3036
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3037
|
+
: `${cell.column.getStart("left")}px`,
|
|
3038
|
+
position: "relative",
|
|
3039
|
+
}
|
|
3040
|
+
: {};
|
|
3041
|
+
return tdProps;
|
|
3042
|
+
};
|
|
3043
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3044
|
+
if (hoveredRow === -1) {
|
|
3045
|
+
return {};
|
|
3046
|
+
}
|
|
3047
|
+
if (hoveredRow === index) {
|
|
3048
|
+
return {
|
|
3049
|
+
opacity: "1",
|
|
3050
|
+
};
|
|
3051
|
+
}
|
|
3052
|
+
return {
|
|
3053
|
+
opacity: "0.8",
|
|
3054
|
+
};
|
|
3055
|
+
};
|
|
3056
|
+
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3057
|
+
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) => {
|
|
3058
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3059
|
+
// styling resize and pinning start
|
|
3060
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3061
|
+
base: "colorPalette.900",
|
|
3062
|
+
_dark: "colorPalette.100",
|
|
3063
|
+
},
|
|
3064
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3065
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3066
|
+
}) }));
|
|
3067
|
+
};
|
|
3068
|
+
const TableRowSelector = ({ index, row, }) => {
|
|
3069
|
+
const { table } = useDataTableContext();
|
|
3070
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3071
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3072
|
+
base: "colorPalette.900",
|
|
3073
|
+
_dark: "colorPalette.100",
|
|
3074
|
+
},
|
|
3075
|
+
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(),
|
|
3076
|
+
disabled: !row.getCanSelect(),
|
|
3077
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3097
3078
|
};
|
|
3098
3079
|
|
|
3099
|
-
const TableFooter = ({
|
|
3080
|
+
const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
3100
3081
|
const table = useDataTableContext().table;
|
|
3101
3082
|
const SELECTION_BOX_WIDTH = 20;
|
|
3102
3083
|
const [hoveredCheckBox, setHoveredCheckBox] = React.useState(false);
|
|
@@ -3115,78 +3096,28 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3115
3096
|
}
|
|
3116
3097
|
return false;
|
|
3117
3098
|
};
|
|
3118
|
-
|
|
3119
|
-
const thProps = header.column.getIsPinned()
|
|
3120
|
-
? {
|
|
3121
|
-
left: showSelector
|
|
3122
|
-
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3123
|
-
: `${header.getStart("left") + table.getDensityValue() * 2}px`,
|
|
3124
|
-
background: pinnedBgColor.light,
|
|
3125
|
-
position: "sticky",
|
|
3126
|
-
zIndex: 1,
|
|
3127
|
-
_dark: {
|
|
3128
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3129
|
-
},
|
|
3130
|
-
}
|
|
3131
|
-
: {};
|
|
3132
|
-
return thProps;
|
|
3133
|
-
};
|
|
3134
|
-
return (jsxRuntime.jsx(react.Table.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", children: [showSelector && (jsxRuntime.jsxs(react.Table.Header
|
|
3135
|
-
// styling resize and pinning start
|
|
3136
|
-
, {
|
|
3137
|
-
// styling resize and pinning start
|
|
3138
|
-
padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
3139
|
-
? {
|
|
3140
|
-
left: `0px`,
|
|
3141
|
-
backgroundColor: pinnedBgColor.light,
|
|
3142
|
-
position: "sticky",
|
|
3143
|
-
zIndex: 1,
|
|
3144
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3145
|
-
}
|
|
3146
|
-
: {}),
|
|
3147
|
-
// styling resize and pinning end
|
|
3148
|
-
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(),
|
|
3099
|
+
return (jsxRuntime.jsx(react.Table.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", children: [showSelector && (jsxRuntime.jsxs(react.Table.Header, { padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
3149
3100
|
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3150
3101
|
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), footerGroup.headers.map((header) => (jsxRuntime.jsx(react.Table.Cell, { padding: "0", columnSpan: `${header.colSpan}`,
|
|
3151
3102
|
// styling resize and pinning start
|
|
3152
|
-
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid",
|
|
3103
|
+
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", children: jsxRuntime.jsx(react.MenuRoot, { children: jsxRuntime.jsx(react.MenuTrigger, { asChild: true, children: jsxRuntime.jsx(react.Box, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", children: jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3153
3104
|
? null
|
|
3154
3105
|
: reactTable.flexRender(header.column.columnDef.footer, header.getContext()), jsxRuntime.jsx(react.Box, { children: header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [header.column.getIsSorted() === false && (
|
|
3155
3106
|
// <UpDownIcon />
|
|
3156
3107
|
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
3108
|
};
|
|
3158
3109
|
|
|
3159
|
-
const TableHeader = ({ canResize = true,
|
|
3110
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3160
3111
|
const { table } = useDataTableContext();
|
|
3161
3112
|
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
3113
|
const getThProps = (header) => {
|
|
3179
3114
|
const thProps = header.column.getIsPinned()
|
|
3180
3115
|
? {
|
|
3181
3116
|
left: showSelector
|
|
3182
3117
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3183
3118
|
: `${header.getStart("left")}px`,
|
|
3184
|
-
background: pinnedBgColor.light,
|
|
3185
3119
|
position: "sticky",
|
|
3186
3120
|
zIndex: 100 + 1,
|
|
3187
|
-
_dark: {
|
|
3188
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3189
|
-
},
|
|
3190
3121
|
}
|
|
3191
3122
|
: {};
|
|
3192
3123
|
return thProps;
|
|
@@ -3195,21 +3126,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3195
3126
|
position: "sticky",
|
|
3196
3127
|
top: 0,
|
|
3197
3128
|
};
|
|
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) => {
|
|
3129
|
+
return (jsxRuntime.jsx(react.Table.Header, { ...(isSticky ? stickyProps : {}), bgColor: "transparent", ...tableHeaderProps, children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", bgColor: "transparent", ...tableRowProps, children: [showSelector && (jsxRuntime.jsx(react.Table.ColumnHeader, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3130
|
+
base: "colorPalette.900",
|
|
3131
|
+
_dark: "colorPalette.100",
|
|
3132
|
+
},
|
|
3133
|
+
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(),
|
|
3134
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3135
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3213
3136
|
const resizeProps = {
|
|
3214
3137
|
onMouseDown: header.getResizeHandler(),
|
|
3215
3138
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3217,10 +3140,24 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3217
3140
|
};
|
|
3218
3141
|
return (jsxRuntime.jsxs(react.Table.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3219
3142
|
// styling resize and pinning start
|
|
3220
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3143
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3144
|
+
base: "colorPalette.800",
|
|
3145
|
+
_dark: "colorPalette.200",
|
|
3146
|
+
},
|
|
3147
|
+
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", color: {
|
|
3148
|
+
base: "colorPalette.800",
|
|
3149
|
+
_dark: "colorPalette.200",
|
|
3150
|
+
_hover: {
|
|
3151
|
+
base: "colorPalette.700",
|
|
3152
|
+
_dark: "colorPalette.300",
|
|
3153
|
+
},
|
|
3154
|
+
},
|
|
3155
|
+
bg: {
|
|
3156
|
+
base: "colorPalette.100",
|
|
3157
|
+
_dark: "colorPalette.900",
|
|
3158
|
+
_hover: {
|
|
3159
|
+
base: "colorPalette.200",
|
|
3160
|
+
_dark: "colorPalette.800",
|
|
3224
3161
|
},
|
|
3225
3162
|
}, children: jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3226
3163
|
? null
|
|
@@ -3248,29 +3185,17 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3248
3185
|
});
|
|
3249
3186
|
}, children: [jsxRuntime.jsx(gr.GrDescend, {}), "Sort Descending"] }) }), header.column.getIsSorted() && (jsxRuntime.jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3250
3187
|
header.column.clearSorting();
|
|
3251
|
-
}, children: [jsxRuntime.jsx(md.MdClear, {}), "Clear Sorting"] }) }))] }))] })] }), canResize && (jsxRuntime.jsx(react.Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3188
|
+
}, children: [jsxRuntime.jsx(md.MdClear, {}), "Clear Sorting"] }) }))] }))] })] }), canResize && (jsxRuntime.jsx(react.Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3189
|
+
? "colorPalette.700"
|
|
3190
|
+
: "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
|
|
3252
3191
|
borderRightColor: header.column.getIsResizing()
|
|
3253
|
-
? "
|
|
3254
|
-
: "
|
|
3192
|
+
? "colorPalette.700"
|
|
3193
|
+
: "colorPalette.400",
|
|
3255
3194
|
}, ...resizeProps }))] }, `chakra-table-header-${header.id}`));
|
|
3256
3195
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3257
3196
|
};
|
|
3258
3197
|
|
|
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 = "", }) => {
|
|
3198
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3274
3199
|
if (variant === "greedy") {
|
|
3275
3200
|
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
3201
|
}
|
|
@@ -3530,16 +3455,82 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3530
3455
|
return columns;
|
|
3531
3456
|
};
|
|
3532
3457
|
|
|
3533
|
-
const
|
|
3534
|
-
const {
|
|
3535
|
-
|
|
3458
|
+
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3459
|
+
const { table, columns, translate, data } = useDataTableContext();
|
|
3460
|
+
const columnDef = table._getColumnDefs();
|
|
3461
|
+
console.log(columnDef, "glp");
|
|
3462
|
+
console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
|
|
3463
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3464
|
+
const { accessorKey, id } = def;
|
|
3465
|
+
if (accessorKey) {
|
|
3466
|
+
return [accessorKey, def];
|
|
3467
|
+
}
|
|
3468
|
+
return [id, def];
|
|
3469
|
+
}));
|
|
3470
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3471
|
+
const totalWidths = columns
|
|
3472
|
+
.map(({ size }) => {
|
|
3473
|
+
if (!!size === false) {
|
|
3474
|
+
return 0;
|
|
3475
|
+
}
|
|
3476
|
+
if (typeof size === "number") {
|
|
3477
|
+
return size;
|
|
3478
|
+
}
|
|
3479
|
+
return 0;
|
|
3480
|
+
})
|
|
3481
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3482
|
+
const columnWidths = columns
|
|
3483
|
+
.map(({ size }) => {
|
|
3484
|
+
if (!!size === false) {
|
|
3485
|
+
return "1fr";
|
|
3486
|
+
}
|
|
3487
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3488
|
+
})
|
|
3489
|
+
.join(" ");
|
|
3490
|
+
console.log({ columnWidths }, "hadfg");
|
|
3491
|
+
const cellProps = {
|
|
3492
|
+
flex: "1 0 0%",
|
|
3493
|
+
overflow: "auto",
|
|
3494
|
+
paddingX: "2",
|
|
3495
|
+
py: "1",
|
|
3496
|
+
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
3497
|
+
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
3498
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3499
|
+
borderBottomWidth: "1px",
|
|
3500
|
+
...{ colorPalette },
|
|
3501
|
+
};
|
|
3502
|
+
if (data.length <= 0) {
|
|
3503
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: emptyComponent });
|
|
3504
|
+
}
|
|
3505
|
+
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) => {
|
|
3506
|
+
return (jsxRuntime.jsx(react.Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3507
|
+
}) }), data.map((record) => {
|
|
3508
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columnHeaders.map((header) => {
|
|
3509
|
+
const { cell } = columnsMap[header];
|
|
3510
|
+
const value = record[header];
|
|
3511
|
+
if (!!record === false) {
|
|
3512
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3513
|
+
}
|
|
3514
|
+
if (cell) {
|
|
3515
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3516
|
+
}
|
|
3517
|
+
if (typeof value === "object") {
|
|
3518
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: jsxRuntime.jsx(RecordDisplay, { object: value }) }));
|
|
3519
|
+
}
|
|
3520
|
+
return jsxRuntime.jsx(react.Box, { ...cellProps, children: value });
|
|
3521
|
+
}) }));
|
|
3522
|
+
})] }));
|
|
3536
3523
|
};
|
|
3537
3524
|
|
|
3538
|
-
const
|
|
3539
|
-
const {
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3525
|
+
const AccordionItemTrigger = React__namespace.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3526
|
+
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3527
|
+
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, {}) }))] }));
|
|
3528
|
+
});
|
|
3529
|
+
const AccordionItemContent = React__namespace.forwardRef(function AccordionItemContent(props, ref) {
|
|
3530
|
+
return (jsxRuntime.jsx(react.Accordion.ItemContent, { children: jsxRuntime.jsx(react.Accordion.ItemBody, { ...props, ref: ref }) }));
|
|
3531
|
+
});
|
|
3532
|
+
const AccordionRoot = react.Accordion.Root;
|
|
3533
|
+
const AccordionItem = react.Accordion.Item;
|
|
3543
3534
|
|
|
3544
3535
|
//@ts-expect-error TODO: find appropriate type
|
|
3545
3536
|
const SchemaFormContext = React.createContext({
|
|
@@ -3562,15 +3553,56 @@ const clearEmptyString = (object) => {
|
|
|
3562
3553
|
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== ""));
|
|
3563
3554
|
};
|
|
3564
3555
|
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
}
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3571
|
-
});
|
|
3572
|
-
|
|
3573
|
-
|
|
3556
|
+
const idPickerSanityCheck = (column, foreign_key) => {
|
|
3557
|
+
if (!!foreign_key == false) {
|
|
3558
|
+
throw new Error(`The key foreign_key does not exist in properties of column ${column} when using id-picker.`);
|
|
3559
|
+
}
|
|
3560
|
+
const { table, column: foreignKeyColumn, display_column } = foreign_key;
|
|
3561
|
+
if (!!table == false) {
|
|
3562
|
+
throw new Error(`The key table does not exist in properties of column ${table} when using id-picker.`);
|
|
3563
|
+
}
|
|
3564
|
+
if (!!display_column == false) {
|
|
3565
|
+
throw new Error(`The key display_column does not exist in properties of column ${column} when using id-picker.`);
|
|
3566
|
+
}
|
|
3567
|
+
if (!!foreignKeyColumn == false) {
|
|
3568
|
+
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
3569
|
+
}
|
|
3570
|
+
};
|
|
3571
|
+
const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, children, order = [], ignore = [], include = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, getUpdatedData = () => { }, }) => {
|
|
3572
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
3573
|
+
const [isError, setIsError] = React.useState(false);
|
|
3574
|
+
const [isSubmiting, setIsSubmiting] = React.useState(false);
|
|
3575
|
+
const [isConfirming, setIsConfirming] = React.useState(false);
|
|
3576
|
+
const [validatedData, setValidatedData] = React.useState();
|
|
3577
|
+
const [error, setError] = React.useState();
|
|
3578
|
+
return (jsxRuntime.jsx(SchemaFormContext.Provider, { value: {
|
|
3579
|
+
schema,
|
|
3580
|
+
serverUrl,
|
|
3581
|
+
order,
|
|
3582
|
+
ignore,
|
|
3583
|
+
include,
|
|
3584
|
+
// @ts-expect-error TODO: find appropriate types
|
|
3585
|
+
onSubmit,
|
|
3586
|
+
rowNumber,
|
|
3587
|
+
idMap,
|
|
3588
|
+
setIdMap,
|
|
3589
|
+
translate,
|
|
3590
|
+
requestOptions,
|
|
3591
|
+
isSuccess,
|
|
3592
|
+
setIsSuccess,
|
|
3593
|
+
isError,
|
|
3594
|
+
setIsError,
|
|
3595
|
+
isSubmiting,
|
|
3596
|
+
setIsSubmiting,
|
|
3597
|
+
isConfirming,
|
|
3598
|
+
setIsConfirming,
|
|
3599
|
+
validatedData,
|
|
3600
|
+
setValidatedData,
|
|
3601
|
+
error,
|
|
3602
|
+
setError,
|
|
3603
|
+
getUpdatedData,
|
|
3604
|
+
}, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: children }) }));
|
|
3605
|
+
};
|
|
3574
3606
|
|
|
3575
3607
|
function removeIndex(str) {
|
|
3576
3608
|
return str.replace(/\.\d+\./g, '.');
|
|
@@ -3585,7 +3617,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3585
3617
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3586
3618
|
const { formState: { errors }, setValue, watch, } = reactHookForm.useFormContext();
|
|
3587
3619
|
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}.
|
|
3620
|
+
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
3621
|
prefix: `${colLabel}.`,
|
|
3590
3622
|
schema: items }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "end", children: jsxRuntime.jsx(react.Button, { variant: "ghost", onClick: () => {
|
|
3591
3623
|
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
@@ -3605,7 +3637,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3605
3637
|
return;
|
|
3606
3638
|
}
|
|
3607
3639
|
setValue(colLabel, [...fields, {}]);
|
|
3608
|
-
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3640
|
+
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3609
3641
|
};
|
|
3610
3642
|
|
|
3611
3643
|
const Field = React__namespace.forwardRef(function Field(props, ref) {
|
|
@@ -3620,10 +3652,10 @@ const BooleanPicker = ({ schema, column, prefix }) => {
|
|
|
3620
3652
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3621
3653
|
const colLabel = `${prefix}${column}`;
|
|
3622
3654
|
const value = watch(colLabel);
|
|
3623
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
3655
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3624
3656
|
gridRow, children: [jsxRuntime.jsx(CheckboxCard, { checked: value, variant: "surface", onChange: () => {
|
|
3625
3657
|
setValue(colLabel, !value);
|
|
3626
|
-
} }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3658
|
+
} }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3627
3659
|
};
|
|
3628
3660
|
|
|
3629
3661
|
const monthNamesShort = [
|
|
@@ -3721,10 +3753,11 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3721
3753
|
const colLabel = `${prefix}${column}`;
|
|
3722
3754
|
const [open, setOpen] = React.useState(false);
|
|
3723
3755
|
const selectedDate = watch(colLabel);
|
|
3724
|
-
|
|
3756
|
+
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3757
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3725
3758
|
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
3759
|
setOpen(true);
|
|
3727
|
-
}, children: selectedDate !== undefined ?
|
|
3760
|
+
}, children: selectedDate !== undefined ? `${formatedDate}` : "" }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(DatePicker$1
|
|
3728
3761
|
// @ts-expect-error TODO: find appropriate types
|
|
3729
3762
|
, {
|
|
3730
3763
|
// @ts-expect-error TODO: find appropriate types
|
|
@@ -3733,7 +3766,7 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3733
3766
|
onDateSelected: ({ date }) => {
|
|
3734
3767
|
setValue(colLabel, dayjs(date).format("YYYY-MM-DD"));
|
|
3735
3768
|
setOpen(false);
|
|
3736
|
-
} })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3769
|
+
} })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3737
3770
|
};
|
|
3738
3771
|
|
|
3739
3772
|
function filterArray(array, searchTerm) {
|
|
@@ -3766,25 +3799,24 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3766
3799
|
setSearchText(event.target.value);
|
|
3767
3800
|
setLimit(10);
|
|
3768
3801
|
};
|
|
3769
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
3802
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3770
3803
|
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3771
3804
|
const item = enumValue;
|
|
3772
3805
|
if (item === undefined) {
|
|
3773
3806
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
3774
3807
|
}
|
|
3775
3808
|
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
3776
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3777
3809
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3778
3810
|
}, children: !!renderDisplay === true
|
|
3779
3811
|
? renderDisplay(item)
|
|
3780
3812
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
3781
3813
|
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3782
3814
|
setOpenSearchResult(true);
|
|
3783
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
3815
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
3784
3816
|
setOpenSearchResult(true);
|
|
3785
3817
|
}, children: watchEnum === undefined
|
|
3786
3818
|
? ""
|
|
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}.
|
|
3819
|
+
: 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
3820
|
onSearchChange(event);
|
|
3789
3821
|
setOpenSearchResult(true);
|
|
3790
3822
|
}, 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) => {
|
|
@@ -3799,10 +3831,10 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3799
3831
|
}
|
|
3800
3832
|
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3801
3833
|
setValue(colLabel, [...newSet]);
|
|
3802
|
-
}, ...(selected ? { color: "
|
|
3834
|
+
}, ...(selected ? { color: "colorPalette.400/50" } : {}), children: !!renderDisplay === true
|
|
3803
3835
|
? renderDisplay(item)
|
|
3804
3836
|
: 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}.
|
|
3837
|
+
}) }), 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
3838
|
};
|
|
3807
3839
|
|
|
3808
3840
|
function isEnteringWindow(_ref) {
|
|
@@ -4154,7 +4186,7 @@ const FileDropzone = ({ children = undefined, gridProps = {}, onDrop = () => { }
|
|
|
4154
4186
|
const filesArray = [...event.target.files];
|
|
4155
4187
|
onDrop({ files: filesArray });
|
|
4156
4188
|
};
|
|
4157
|
-
return (jsxRuntime.jsxs(react.Grid, { ...getColor(isDraggedOver), ref: ref, cursor: "pointer", onClick: handleClick, borderStyle: "dashed", borderColor: "
|
|
4189
|
+
return (jsxRuntime.jsxs(react.Grid, { ...getColor(isDraggedOver), ref: ref, cursor: "pointer", onClick: handleClick, borderStyle: "dashed", borderColor: "colorPalette.400", alignContent: "center", justifyContent: "center", borderWidth: 1, borderRadius: 4, ...gridProps, children: [children, !!children === false && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(react.Flex, { children: placeholder }), jsxRuntime.jsx(react.Input, { type: "file", multiple: true, style: { display: "none" }, ref: fileInput, onChange: handleChange })] }))] }));
|
|
4158
4190
|
};
|
|
4159
4191
|
|
|
4160
4192
|
const FilePicker = ({ column, schema, prefix }) => {
|
|
@@ -4164,7 +4196,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4164
4196
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4165
4197
|
const currentFiles = (watch(column) ?? []);
|
|
4166
4198
|
const colLabel = `${prefix}${column}`;
|
|
4167
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4199
|
+
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
4200
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4169
4201
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4170
4202
|
}, placeholder: translate.t(removeIndex(`${colLabel}.fileDropzone`)) }), jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4173,7 +4205,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4173
4205
|
return name !== file.name;
|
|
4174
4206
|
}));
|
|
4175
4207
|
}, 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}.
|
|
4208
|
+
}) }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4177
4209
|
};
|
|
4178
4210
|
|
|
4179
4211
|
const getTableData = async ({ serverUrl, in_table, searching = "", where = [], limit = 10, offset = 0, }) => {
|
|
@@ -4290,7 +4322,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4290
4322
|
}
|
|
4291
4323
|
return record[display_column];
|
|
4292
4324
|
};
|
|
4293
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.
|
|
4325
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.field_label`)))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4294
4326
|
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [watchIds.map((id) => {
|
|
4295
4327
|
const item = idMap[id];
|
|
4296
4328
|
if (item === undefined) {
|
|
@@ -4303,7 +4335,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4303
4335
|
: item[display_column] }, id));
|
|
4304
4336
|
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4305
4337
|
setOpenSearchResult(true);
|
|
4306
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
4338
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
4307
4339
|
setOpenSearchResult(true);
|
|
4308
4340
|
}, 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
4341
|
onSearchChange(event);
|
|
@@ -4325,10 +4357,10 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4325
4357
|
item[column_ref],
|
|
4326
4358
|
]);
|
|
4327
4359
|
setValue(colLabel, [...newSet]);
|
|
4328
|
-
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "
|
|
4360
|
+
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "colorPalette.400/50" } : {}), children: !!renderDisplay === true
|
|
4329
4361
|
? renderDisplay(item)
|
|
4330
4362
|
: 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}.
|
|
4363
|
+
}) }), 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
4364
|
};
|
|
4333
4365
|
|
|
4334
4366
|
const NumberInputRoot = React__namespace.forwardRef(function NumberInput(props, ref) {
|
|
@@ -4346,9 +4378,9 @@ const NumberInputField = ({ schema, column, prefix, }) => {
|
|
|
4346
4378
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4347
4379
|
const colLabel = `${prefix}${column}`;
|
|
4348
4380
|
const value = watch(`${colLabel}`);
|
|
4349
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4381
|
+
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
4382
|
setValue(`${colLabel}`, Number(event.target.value));
|
|
4351
|
-
} }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4383
|
+
} }) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4352
4384
|
};
|
|
4353
4385
|
|
|
4354
4386
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
@@ -4360,13 +4392,13 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4360
4392
|
if (properties === undefined) {
|
|
4361
4393
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4362
4394
|
}
|
|
4363
|
-
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4395
|
+
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
4396
|
return (
|
|
4365
4397
|
// @ts-expect-error find suitable types
|
|
4366
4398
|
jsxRuntime.jsx(ColumnRenderer, { column: `${key}`,
|
|
4367
4399
|
prefix: `${prefix}${column}.`,
|
|
4368
4400
|
properties }, `form-${colLabel}-${key}`));
|
|
4369
|
-
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4401
|
+
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4370
4402
|
};
|
|
4371
4403
|
|
|
4372
4404
|
const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
@@ -4378,7 +4410,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4378
4410
|
const [showNewEntries, setShowNewEntries] = React.useState(false);
|
|
4379
4411
|
const [newKey, setNewKey] = React.useState();
|
|
4380
4412
|
const [newValue, setNewValue] = React.useState();
|
|
4381
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.
|
|
4413
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4382
4414
|
return (jsxRuntime.jsxs(react.Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsxRuntime.jsx(react.Input, { value: key, onChange: (e) => {
|
|
4383
4415
|
const filtered = entries.filter(([target]) => {
|
|
4384
4416
|
return target !== key;
|
|
@@ -4418,7 +4450,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4418
4450
|
setShowNewEntries(true);
|
|
4419
4451
|
setNewKey(undefined);
|
|
4420
4452
|
setNewValue(undefined);
|
|
4421
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.
|
|
4453
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4422
4454
|
};
|
|
4423
4455
|
|
|
4424
4456
|
const StringInputField = ({ column, schema, prefix, }) => {
|
|
@@ -4427,7 +4459,7 @@ const StringInputField = ({ column, schema, prefix, }) => {
|
|
|
4427
4459
|
const { required, gridColumn, gridRow } = schema;
|
|
4428
4460
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4429
4461
|
const colLabel = `${prefix}${column}`;
|
|
4430
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4462
|
+
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
4463
|
};
|
|
4432
4464
|
|
|
4433
4465
|
const RadioCardItem = React__namespace.forwardRef(function RadioCardItem(props, ref) {
|
|
@@ -4591,9 +4623,9 @@ const ArrayViewer = ({ schema, column, prefix }) => {
|
|
|
4591
4623
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4592
4624
|
const { watch, formState: { errors }, } = reactHookForm.useFormContext();
|
|
4593
4625
|
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}.
|
|
4626
|
+
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
4627
|
prefix: `${colLabel}.`,
|
|
4596
|
-
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4628
|
+
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4597
4629
|
};
|
|
4598
4630
|
|
|
4599
4631
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4603,10 +4635,10 @@ const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
|
4603
4635
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4604
4636
|
const colLabel = `${prefix}${column}`;
|
|
4605
4637
|
const value = watch(colLabel);
|
|
4606
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4638
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4607
4639
|
gridRow, children: [jsxRuntime.jsx(react.Text, { children: value
|
|
4608
4640
|
? 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}.
|
|
4641
|
+
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4610
4642
|
};
|
|
4611
4643
|
|
|
4612
4644
|
const DateViewer = ({ column, schema, prefix }) => {
|
|
@@ -4616,8 +4648,8 @@ const DateViewer = ({ column, schema, prefix }) => {
|
|
|
4616
4648
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4617
4649
|
const colLabel = `${prefix}${column}`;
|
|
4618
4650
|
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}.
|
|
4651
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4652
|
+
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
4653
|
};
|
|
4622
4654
|
|
|
4623
4655
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
@@ -4629,7 +4661,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4629
4661
|
const colLabel = `${prefix}${column}`;
|
|
4630
4662
|
const watchEnum = watch(colLabel);
|
|
4631
4663
|
const watchEnums = (watch(colLabel) ?? []);
|
|
4632
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4664
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4633
4665
|
gridRow, children: [isMultiple && (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
4634
4666
|
const item = enumValue;
|
|
4635
4667
|
if (item === undefined) {
|
|
@@ -4638,7 +4670,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4638
4670
|
return (jsxRuntime.jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4639
4671
|
? renderDisplay(item)
|
|
4640
4672
|
: 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}.
|
|
4673
|
+
}) })), !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
4674
|
};
|
|
4643
4675
|
|
|
4644
4676
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
@@ -4648,7 +4680,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4648
4680
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4649
4681
|
const currentFiles = (watch(column) ?? []);
|
|
4650
4682
|
const colLabel = `${prefix}${column}`;
|
|
4651
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4683
|
+
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
4684
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4653
4685
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4654
4686
|
}, placeholder: translate.t(`${colLabel}.fileDropzone`) }), jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4657,7 +4689,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4657
4689
|
return name !== file.name;
|
|
4658
4690
|
}));
|
|
4659
4691
|
}, 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}.
|
|
4692
|
+
}) }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4661
4693
|
};
|
|
4662
4694
|
|
|
4663
4695
|
const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
@@ -4679,7 +4711,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4679
4711
|
}
|
|
4680
4712
|
return record[display_column];
|
|
4681
4713
|
};
|
|
4682
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4714
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4683
4715
|
gridRow, children: [isMultiple && (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: 1, children: watchIds.map((id) => {
|
|
4684
4716
|
const item = idMap[id];
|
|
4685
4717
|
if (item === undefined) {
|
|
@@ -4688,7 +4720,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4688
4720
|
return (jsxRuntime.jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4689
4721
|
? renderDisplay(item)
|
|
4690
4722
|
: 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}.
|
|
4723
|
+
}) })), !isMultiple && jsxRuntime.jsx(react.Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4692
4724
|
};
|
|
4693
4725
|
|
|
4694
4726
|
const NumberViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4698,7 +4730,7 @@ const NumberViewer = ({ schema, column, prefix, }) => {
|
|
|
4698
4730
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4699
4731
|
const colLabel = `${prefix}${column}`;
|
|
4700
4732
|
const value = watch(colLabel);
|
|
4701
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4733
|
+
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
4734
|
};
|
|
4703
4735
|
|
|
4704
4736
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
@@ -4710,13 +4742,13 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
4710
4742
|
if (properties === undefined) {
|
|
4711
4743
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4712
4744
|
}
|
|
4713
|
-
return (jsxRuntime.jsxs(react.Box, { gridRow, gridColumn, children: [jsxRuntime.jsxs(react.Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4745
|
+
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
4746
|
return (
|
|
4715
4747
|
// @ts-expect-error find suitable types
|
|
4716
4748
|
jsxRuntime.jsx(ColumnViewer, { column: `${key}`,
|
|
4717
4749
|
prefix: `${prefix}${column}.`,
|
|
4718
4750
|
properties }, `form-objectviewer-${colLabel}-${key}`));
|
|
4719
|
-
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4751
|
+
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4720
4752
|
};
|
|
4721
4753
|
|
|
4722
4754
|
const RecordInput = ({ column, schema, prefix }) => {
|
|
@@ -4728,7 +4760,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4728
4760
|
const [showNewEntries, setShowNewEntries] = React.useState(false);
|
|
4729
4761
|
const [newKey, setNewKey] = React.useState();
|
|
4730
4762
|
const [newValue, setNewValue] = React.useState();
|
|
4731
|
-
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.
|
|
4763
|
+
return (jsxRuntime.jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4732
4764
|
return (jsxRuntime.jsxs(react.Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsxRuntime.jsx(react.Input, { value: key, onChange: (e) => {
|
|
4733
4765
|
const filtered = entries.filter(([target]) => {
|
|
4734
4766
|
return target !== key;
|
|
@@ -4768,7 +4800,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4768
4800
|
setShowNewEntries(true);
|
|
4769
4801
|
setNewKey(undefined);
|
|
4770
4802
|
setNewValue(undefined);
|
|
4771
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.
|
|
4803
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4772
4804
|
};
|
|
4773
4805
|
|
|
4774
4806
|
const TagViewer = ({ column, schema, prefix }) => {
|
|
@@ -4863,7 +4895,7 @@ const StringViewer = ({ column, schema, prefix, }) => {
|
|
|
4863
4895
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4864
4896
|
const colLabel = `${prefix}${column}`;
|
|
4865
4897
|
const value = watch(colLabel);
|
|
4866
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4898
|
+
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
4899
|
};
|
|
4868
4900
|
|
|
4869
4901
|
const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
@@ -4927,30 +4959,23 @@ const ColumnViewer = ({ column, properties, prefix, }) => {
|
|
|
4927
4959
|
return jsxRuntime.jsx(SchemaViewer, { schema: colSchema, prefix, column });
|
|
4928
4960
|
};
|
|
4929
4961
|
|
|
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
|
-
}
|
|
4962
|
+
const SubmitButton = () => {
|
|
4963
|
+
const { translate, setValidatedData, setIsError, setIsConfirming } = useSchemaContext();
|
|
4964
|
+
const methods = reactHookForm.useFormContext();
|
|
4965
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4966
|
+
const onValid = (data) => {
|
|
4967
|
+
setValidatedData(data);
|
|
4968
|
+
setIsError(false);
|
|
4969
|
+
setIsConfirming(true);
|
|
4970
|
+
};
|
|
4971
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
4972
|
+
methods.handleSubmit(onValid)();
|
|
4973
|
+
}, formNoValidate: true, children: translate.t("submit") }));
|
|
4944
4974
|
};
|
|
4945
|
-
|
|
4946
|
-
|
|
4975
|
+
|
|
4976
|
+
const FormBody = () => {
|
|
4977
|
+
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
4978
|
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
4979
|
const { properties } = schema;
|
|
4955
4980
|
const onBeforeSubmit = () => {
|
|
4956
4981
|
setIsSubmiting(true);
|
|
@@ -4958,8 +4983,9 @@ const FormInternal = () => {
|
|
|
4958
4983
|
const onAfterSubmit = () => {
|
|
4959
4984
|
setIsSubmiting(false);
|
|
4960
4985
|
};
|
|
4961
|
-
const onSubmitError = () => {
|
|
4986
|
+
const onSubmitError = (error) => {
|
|
4962
4987
|
setIsError(true);
|
|
4988
|
+
setError(error);
|
|
4963
4989
|
};
|
|
4964
4990
|
const onSubmitSuccess = () => {
|
|
4965
4991
|
setIsSuccess(true);
|
|
@@ -4971,9 +4997,7 @@ const FormInternal = () => {
|
|
|
4971
4997
|
onSubmitSuccess();
|
|
4972
4998
|
}
|
|
4973
4999
|
catch (error) {
|
|
4974
|
-
|
|
4975
|
-
setError(error);
|
|
4976
|
-
onSubmitError();
|
|
5000
|
+
onSubmitError(error);
|
|
4977
5001
|
}
|
|
4978
5002
|
finally {
|
|
4979
5003
|
onAfterSubmit();
|
|
@@ -4996,12 +5020,6 @@ const FormInternal = () => {
|
|
|
4996
5020
|
}
|
|
4997
5021
|
await defaultOnSubmit(onSubmit(data));
|
|
4998
5022
|
};
|
|
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
5023
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
5006
5024
|
const included = include.length > 0 ? include : keys;
|
|
5007
5025
|
const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
|
|
@@ -5016,58 +5034,47 @@ const FormInternal = () => {
|
|
|
5016
5034
|
include,
|
|
5017
5035
|
});
|
|
5018
5036
|
if (isSuccess) {
|
|
5019
|
-
return (jsxRuntime.jsxs(react.
|
|
5037
|
+
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
5038
|
setIsError(false);
|
|
5021
5039
|
setIsSubmiting(false);
|
|
5022
5040
|
setIsSuccess(false);
|
|
5023
5041
|
setIsConfirming(false);
|
|
5024
5042
|
setValidatedData(undefined);
|
|
5025
|
-
|
|
5026
|
-
|
|
5043
|
+
const data = await getUpdatedData();
|
|
5044
|
+
methods.reset(data);
|
|
5045
|
+
}, formNoValidate: true, children: translate.t("submit_again") }) })] }));
|
|
5027
5046
|
}
|
|
5028
5047
|
if (isConfirming) {
|
|
5029
|
-
return (jsxRuntime.jsxs(react.
|
|
5048
|
+
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
5049
|
return (jsxRuntime.jsx(ColumnViewer
|
|
5031
5050
|
// @ts-expect-error find suitable types
|
|
5032
5051
|
, {
|
|
5033
5052
|
// @ts-expect-error find suitable types
|
|
5034
5053
|
properties: properties, prefix: ``, column }, `form-viewer-${column}`));
|
|
5035
|
-
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
5054
|
+
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5036
5055
|
setIsConfirming(false);
|
|
5037
|
-
}, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(Button, { onClick: () => {
|
|
5056
|
+
}, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5038
5057
|
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: [
|
|
5058
|
+
}, 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
5059
|
}
|
|
5041
|
-
return (jsxRuntime.
|
|
5042
|
-
|
|
5060
|
+
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) => {
|
|
5061
|
+
return (jsxRuntime.jsx(ColumnRenderer
|
|
5062
|
+
// @ts-expect-error find suitable types
|
|
5063
|
+
, {
|
|
5043
5064
|
// @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") })] })] }) }));
|
|
5065
|
+
properties: properties, prefix: ``, column }, `form-input-${column}`));
|
|
5066
|
+
}) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
5067
|
+
methods.reset();
|
|
5068
|
+
}, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(SubmitButton, {})] })] }));
|
|
5052
5069
|
};
|
|
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, {}) }) }));
|
|
5070
|
+
|
|
5071
|
+
const FormTitle = () => {
|
|
5072
|
+
const { translate } = useSchemaContext();
|
|
5073
|
+
return jsxRuntime.jsx(react.Heading, { children: translate.t("title") });
|
|
5074
|
+
};
|
|
5075
|
+
|
|
5076
|
+
const DefaultForm = ({ formConfig, showTitle = true, }) => {
|
|
5077
|
+
return (jsxRuntime.jsx(FormRoot, { ...formConfig, children: jsxRuntime.jsxs(react.Grid, { gap: "2", children: [showTitle && jsxRuntime.jsx(FormTitle, {}), jsxRuntime.jsx(FormBody, {})] }) }));
|
|
5071
5078
|
};
|
|
5072
5079
|
|
|
5073
5080
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5105,15 +5112,17 @@ exports.DataDisplay = DataDisplay;
|
|
|
5105
5112
|
exports.DataTable = DataTable;
|
|
5106
5113
|
exports.DataTableServer = DataTableServer;
|
|
5107
5114
|
exports.DefaultCardTitle = DefaultCardTitle;
|
|
5115
|
+
exports.DefaultForm = DefaultForm;
|
|
5108
5116
|
exports.DefaultTable = DefaultTable;
|
|
5109
5117
|
exports.DensityToggleButton = DensityToggleButton;
|
|
5110
|
-
exports.EditOrderButton = EditOrderButton;
|
|
5111
5118
|
exports.EditSortingButton = EditSortingButton;
|
|
5112
|
-
exports.EmptyState = EmptyState;
|
|
5119
|
+
exports.EmptyState = EmptyState$1;
|
|
5113
5120
|
exports.ErrorAlert = ErrorAlert;
|
|
5114
5121
|
exports.FilterDialog = FilterDialog;
|
|
5115
5122
|
exports.FilterOptions = FilterOptions;
|
|
5116
|
-
exports.
|
|
5123
|
+
exports.FormBody = FormBody;
|
|
5124
|
+
exports.FormRoot = FormRoot;
|
|
5125
|
+
exports.FormTitle = FormTitle;
|
|
5117
5126
|
exports.GlobalFilter = GlobalFilter;
|
|
5118
5127
|
exports.PageSizeControl = PageSizeControl;
|
|
5119
5128
|
exports.Pagination = Pagination;
|
|
@@ -5129,12 +5138,12 @@ exports.TableCardContainer = TableCardContainer;
|
|
|
5129
5138
|
exports.TableCards = TableCards;
|
|
5130
5139
|
exports.TableComponent = TableComponent;
|
|
5131
5140
|
exports.TableControls = TableControls;
|
|
5141
|
+
exports.TableDataDisplay = TableDataDisplay;
|
|
5132
5142
|
exports.TableFilter = TableFilter;
|
|
5133
5143
|
exports.TableFilterTags = TableFilterTags;
|
|
5134
5144
|
exports.TableFooter = TableFooter;
|
|
5135
5145
|
exports.TableHeader = TableHeader;
|
|
5136
5146
|
exports.TableLoadingComponent = TableLoadingComponent;
|
|
5137
|
-
exports.TableOrderer = TableOrderer;
|
|
5138
5147
|
exports.TableSelector = TableSelector;
|
|
5139
5148
|
exports.TableSorter = TableSorter;
|
|
5140
5149
|
exports.TableViewer = TableViewer;
|