@bsol-oss/react-datatable5 12.0.0-beta.2 → 12.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +90 -86
- package/dist/index.js +515 -486
- package/dist/index.mjs +512 -485
- package/dist/types/components/DataTable/DataTable.d.ts +1 -1
- package/dist/types/components/DataTable/DataTableServer.d.ts +1 -1
- package/dist/types/components/DataTable/DefaultTable.d.ts +9 -12
- package/dist/types/components/DataTable/components/TextCell.d.ts +10 -0
- package/dist/types/components/DataTable/context/DataTableContext.d.ts +2 -1
- package/dist/types/components/DataTable/controls/DensityFeature.d.ts +23 -0
- package/dist/types/components/DataTable/controls/DensityToggleButton.d.ts +6 -0
- package/dist/types/components/DataTable/controls/EditSortingButton.d.ts +7 -0
- package/dist/types/components/DataTable/controls/FilterDialog.d.ts +5 -0
- package/dist/types/components/DataTable/controls/PageSizeControl.d.ts +4 -0
- package/dist/types/components/DataTable/controls/Pagination.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ReloadButton.d.ts +5 -0
- package/dist/types/components/DataTable/controls/ResetFilteringButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/ResetSelectionButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/ResetSortingButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/RowCountText.d.ts +1 -0
- package/dist/types/components/DataTable/controls/SelectAllRowsToggle.d.ts +8 -0
- package/dist/types/components/DataTable/controls/TableControls.d.ts +21 -0
- package/dist/types/components/DataTable/controls/TableFilterTags.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableFilters.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableSelector.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableSorter.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableViewer.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ViewDialog.d.ts +5 -0
- package/dist/types/components/DataTable/display/CardHeader.d.ts +13 -0
- package/dist/types/components/DataTable/display/DataDisplay.d.ts +6 -0
- package/dist/types/components/DataTable/display/EmptyState.d.ts +5 -0
- package/dist/types/components/DataTable/display/ErrorAlert.d.ts +4 -0
- package/dist/types/components/DataTable/display/RecordDisplay.d.ts +9 -0
- package/dist/types/components/DataTable/display/Table.d.ts +10 -0
- package/dist/types/components/DataTable/display/TableBody.d.ts +21 -0
- package/dist/types/components/DataTable/display/TableCardContainer.d.ts +7 -0
- package/dist/types/components/DataTable/display/TableCards.d.ts +11 -0
- package/dist/types/components/DataTable/display/TableComponent.d.ts +6 -0
- package/dist/types/components/DataTable/display/TableDataDisplay.d.ts +6 -0
- package/dist/types/components/DataTable/display/TableFooter.d.ts +9 -0
- package/dist/types/components/DataTable/display/TableHeader.d.ts +9 -0
- package/dist/types/components/DataTable/display/TableLoadingComponent.d.ts +5 -0
- package/dist/types/components/DataTable/display/TextCell.d.ts +10 -0
- package/dist/types/components/DataTable/useDataTable.d.ts +1 -1
- package/dist/types/components/Form/SchemaFormContext.d.ts +13 -0
- package/dist/types/components/Form/components/core/DefaultForm.d.ts +7 -0
- package/dist/types/components/Form/components/core/FormBody.d.ts +1 -0
- package/dist/types/components/Form/components/core/FormRoot.d.ts +39 -0
- package/dist/types/components/Form/components/core/FormTitle.d.ts +1 -0
- package/dist/types/components/Form/components/core/SubmitButton.d.ts +1 -0
- package/dist/types/index.d.ts +37 -35
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For,
|
|
2
|
+
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Tag as Tag$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, CheckboxCard as CheckboxCard$1, Image, EmptyState as EmptyState$2, VStack, Alert, Card, Tooltip as Tooltip$1, Group, InputElement, Icon, List, Table as Table$1, Checkbox as Checkbox$1, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Accordion, Field as Field$1, Popover, NumberInput, Show, RadioCard, CheckboxGroup, Center, Heading } from '@chakra-ui/react';
|
|
3
3
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { createContext, useContext, useState, useEffect, useRef } from 'react';
|
|
6
|
-
import { MdFilterAlt, MdArrowUpward, MdArrowDownward, MdOutlineMoveDown, MdOutlineSort, MdSearch, MdClose, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdOutlineChecklist } from 'react-icons/md';
|
|
7
6
|
import { LuX, LuCheck, LuChevronRight, LuChevronDown } from 'react-icons/lu';
|
|
8
|
-
import
|
|
7
|
+
import { MdOutlineSort, MdFilterAlt, MdSearch, MdClose, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdOutlineChecklist } from 'react-icons/md';
|
|
9
8
|
import { FaUpDown, FaGripLinesVertical } from 'react-icons/fa6';
|
|
10
9
|
import { BiDownArrow, BiUpArrow, BiError } from 'react-icons/bi';
|
|
11
10
|
import { CgClose } from 'react-icons/cg';
|
|
11
|
+
import Dayzed from '@bsol-oss/dayzed-react19';
|
|
12
|
+
import { HiMiniEllipsisHorizontal, HiChevronLeft, HiChevronRight } from 'react-icons/hi2';
|
|
12
13
|
import { IoMdEye, IoMdCheckbox } from 'react-icons/io';
|
|
13
14
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
14
15
|
import { bind, bindAll } from 'bind-event-listener';
|
|
@@ -16,7 +17,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
16
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
17
18
|
import rafSchd from 'raf-schd';
|
|
18
19
|
import invariant from 'tiny-invariant';
|
|
19
|
-
import {
|
|
20
|
+
import { HiColorSwatch } from 'react-icons/hi';
|
|
20
21
|
import { flexRender, makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, createColumnHelper } from '@tanstack/react-table';
|
|
21
22
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
22
23
|
import { BsExclamationCircleFill } from 'react-icons/bs';
|
|
@@ -24,10 +25,9 @@ import { useDebounce } from '@uidotdev/usehooks';
|
|
|
24
25
|
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
25
26
|
import { IoReload } from 'react-icons/io5';
|
|
26
27
|
import { GrAscend, GrDescend } from 'react-icons/gr';
|
|
27
|
-
import { HiColorSwatch } from 'react-icons/hi';
|
|
28
28
|
import { useTranslation } from 'react-i18next';
|
|
29
29
|
import axios from 'axios';
|
|
30
|
-
import {
|
|
30
|
+
import { FormProvider, useFormContext, useForm as useForm$1 } from 'react-hook-form';
|
|
31
31
|
import dayjs from 'dayjs';
|
|
32
32
|
import { TiDeleteOutline } from 'react-icons/ti';
|
|
33
33
|
|
|
@@ -78,6 +78,32 @@ Dialog.Description;
|
|
|
78
78
|
const DialogTrigger = Dialog.Trigger;
|
|
79
79
|
Dialog.ActionTrigger;
|
|
80
80
|
|
|
81
|
+
const TableSorter = () => {
|
|
82
|
+
const { table } = useDataTableContext();
|
|
83
|
+
return (jsx(Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsx(Fragment, { children: headerGroup.headers.map((header) => {
|
|
84
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
85
|
+
? header.column.id
|
|
86
|
+
: header.column.columnDef.meta.displayName;
|
|
87
|
+
return (jsx(Fragment, { children: header.column.getCanSort() && (jsxs(Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsx(Text, { children: displayName }), jsxs(Button$1, { variant: "ghost", onClick: () => {
|
|
88
|
+
header.column.toggleSorting();
|
|
89
|
+
}, children: [header.column.getIsSorted() === false && jsx(FaUpDown, {}), header.column.getIsSorted() === "asc" && jsx(BiDownArrow, {}), header.column.getIsSorted() === "desc" && jsx(BiUpArrow, {})] }), header.column.getIsSorted() && (jsx(Button$1, { onClick: () => {
|
|
90
|
+
header.column.clearSorting();
|
|
91
|
+
}, children: jsx(CgClose, {}) }))] })) }));
|
|
92
|
+
}) }))) }));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
96
|
+
const { table } = useDataTableContext();
|
|
97
|
+
return (jsx(Button$1, { onClick: () => {
|
|
98
|
+
table.resetSorting();
|
|
99
|
+
}, children: text }));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const EditSortingButton = ({ text, icon = jsx(MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
103
|
+
const sortingModal = useDisclosure();
|
|
104
|
+
return (jsx(Fragment, { children: jsxs(DialogRoot, { size: ["full", "full", "md", "md"], children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { children: jsxs(Button$1, { as: "div", variant: "ghost", onClick: sortingModal.onOpen, children: [icon, " ", text] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsxs(DialogHeader, { children: [jsx(DialogTitle, {}), title] }), jsx(DialogBody, { children: jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(TableSorter, {}), jsx(ResetSortingButton, {})] }) }), jsx(DialogFooter, {})] })] }) }));
|
|
105
|
+
};
|
|
106
|
+
|
|
81
107
|
const Radio = React.forwardRef(function Radio(props, ref) {
|
|
82
108
|
const { children, inputProps, rootRef, ...rest } = props;
|
|
83
109
|
return (jsxs(RadioGroup$1.Item, { ref: rootRef, ...rest, children: [jsx(RadioGroup$1.ItemHiddenInput, { ref: ref, ...inputProps }), jsx(RadioGroup$1.ItemIndicator, {}), children && (jsx(RadioGroup$1.ItemText, { children: children }))] }));
|
|
@@ -357,90 +383,141 @@ const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
|
357
383
|
const FilterDialog = ({ icon = jsx(MdFilterAlt, {}), }) => {
|
|
358
384
|
const filterModal = useDisclosure();
|
|
359
385
|
const { translate } = useDataTableContext();
|
|
360
|
-
return (jsxs(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: [jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", translate.t("
|
|
386
|
+
return (jsxs(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: [jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", translate.t("filter_dialog.button_text")] }) }), jsxs(DialogContent, { children: [jsx(DialogHeader, { children: jsx(DialogTitle, { children: translate.t("filter_dialog.title") }) }), jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsx(TableFilter, {}) }), jsxs(DialogFooter, { children: [jsx(ResetFilteringButton, { text: translate.t("filter_dialog.reset") }), jsx(Button$1, { onClick: filterModal.onClose, variant: "subtle", children: translate.t("filter_dialog.close") })] }), jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
|
|
361
387
|
};
|
|
362
388
|
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
.map((column) => {
|
|
396
|
-
const displayName = column.columnDef.meta === undefined
|
|
397
|
-
? column.id
|
|
398
|
-
: column.columnDef.meta.displayName;
|
|
399
|
-
return jsx("span", { children: displayName }, column.id);
|
|
400
|
-
}), jsx(IconButton, { onClick: () => {
|
|
401
|
-
const nextIndex = index + 1;
|
|
402
|
-
if (nextIndex < order.length) {
|
|
403
|
-
handleChangeOrder(index, nextIndex);
|
|
404
|
-
}
|
|
405
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsx(MdArrowDownward, {}) })] }, columnId))) }), jsxs(Flex, { gap: "0.25rem", children: [jsx(Button$1, { onClick: () => {
|
|
406
|
-
table.setColumnOrder(order);
|
|
407
|
-
}, children: "Apply" }), jsx(Button$1, { onClick: () => {
|
|
408
|
-
table.setColumnOrder(originalOrder);
|
|
409
|
-
}, children: "Reset" })] })] }));
|
|
410
|
-
};
|
|
411
|
-
const TableOrderer = () => {
|
|
389
|
+
const MenuContent = React.forwardRef(function MenuContent(props, ref) {
|
|
390
|
+
const { portalled = true, portalRef, ...rest } = props;
|
|
391
|
+
return (jsx(Portal, { disabled: !portalled, container: portalRef, children: jsx(Menu.Positioner, { children: jsx(Menu.Content, { ref: ref, ...rest }) }) }));
|
|
392
|
+
});
|
|
393
|
+
React.forwardRef(function MenuArrow(props, ref) {
|
|
394
|
+
return (jsx(Menu.Arrow, { ref: ref, ...props, children: jsx(Menu.ArrowTip, {}) }));
|
|
395
|
+
});
|
|
396
|
+
React.forwardRef(function MenuCheckboxItem(props, ref) {
|
|
397
|
+
return (jsxs(Menu.CheckboxItem, { ref: ref, ...props, children: [jsx(Menu.ItemIndicator, { hidden: false, children: jsx(LuCheck, {}) }), props.children] }));
|
|
398
|
+
});
|
|
399
|
+
React.forwardRef(function MenuRadioItem(props, ref) {
|
|
400
|
+
const { children, ...rest } = props;
|
|
401
|
+
return (jsxs(Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsx(AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsx(Menu.ItemIndicator, { children: jsx(LuCheck, {}) }) }), jsx(Menu.ItemText, { children: children })] }));
|
|
402
|
+
});
|
|
403
|
+
React.forwardRef(function MenuItemGroup(props, ref) {
|
|
404
|
+
const { title, children, ...rest } = props;
|
|
405
|
+
return (jsxs(Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsx(Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
406
|
+
});
|
|
407
|
+
React.forwardRef(function MenuTriggerItem(props, ref) {
|
|
408
|
+
const { startIcon, children, ...rest } = props;
|
|
409
|
+
return (jsxs(Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsx(LuChevronRight, {})] }));
|
|
410
|
+
});
|
|
411
|
+
Menu.RadioItemGroup;
|
|
412
|
+
Menu.ContextTrigger;
|
|
413
|
+
const MenuRoot = Menu.Root;
|
|
414
|
+
Menu.Separator;
|
|
415
|
+
const MenuItem = Menu.Item;
|
|
416
|
+
Menu.ItemText;
|
|
417
|
+
Menu.ItemCommand;
|
|
418
|
+
const MenuTrigger = Menu.Trigger;
|
|
419
|
+
|
|
420
|
+
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
412
421
|
const { table } = useDataTableContext();
|
|
413
|
-
return (
|
|
422
|
+
return (jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsxs(Button$1, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsx(BiDownArrow, {})] }) }), jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
|
|
423
|
+
table.setPageSize(Number(pageSize));
|
|
424
|
+
}, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }));
|
|
414
425
|
};
|
|
415
426
|
|
|
416
|
-
const
|
|
417
|
-
|
|
427
|
+
const { withContext } = createRecipeContext({ key: "button" });
|
|
428
|
+
// Replace "a" with your framework's link component
|
|
429
|
+
const LinkButton = withContext("a");
|
|
430
|
+
|
|
431
|
+
const [RootPropsProvider, useRootProps] = createContext$1({
|
|
432
|
+
name: "RootPropsProvider",
|
|
433
|
+
});
|
|
434
|
+
const variantMap = {
|
|
435
|
+
outline: { default: "ghost", ellipsis: "plain", current: "outline" },
|
|
436
|
+
solid: { default: "outline", ellipsis: "outline", current: "solid" },
|
|
437
|
+
subtle: { default: "ghost", ellipsis: "plain", current: "subtle" },
|
|
438
|
+
};
|
|
439
|
+
const PaginationRoot = React.forwardRef(function PaginationRoot(props, ref) {
|
|
440
|
+
const { size = "sm", variant = "outline", getHref, ...rest } = props;
|
|
441
|
+
return (jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsx(Pagination$1.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
|
|
442
|
+
});
|
|
443
|
+
const PaginationEllipsis = React.forwardRef(function PaginationEllipsis(props, ref) {
|
|
444
|
+
const { size, variantMap } = useRootProps();
|
|
445
|
+
return (jsx(Pagination$1.Ellipsis, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { as: "span", variant: variantMap.ellipsis, size: size, children: jsx(HiMiniEllipsisHorizontal, {}) }) }));
|
|
446
|
+
});
|
|
447
|
+
const PaginationItem = React.forwardRef(function PaginationItem(props, ref) {
|
|
448
|
+
const { page } = usePaginationContext();
|
|
449
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
450
|
+
const current = page === props.value;
|
|
451
|
+
const variant = current ? variantMap.current : variantMap.default;
|
|
452
|
+
if (getHref) {
|
|
453
|
+
return (jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
|
|
454
|
+
}
|
|
455
|
+
return (jsx(Pagination$1.Item, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { variant: variant, size: size, children: props.value }) }));
|
|
456
|
+
});
|
|
457
|
+
const PaginationPrevTrigger = React.forwardRef(function PaginationPrevTrigger(props, ref) {
|
|
458
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
459
|
+
const { previousPage } = usePaginationContext();
|
|
460
|
+
if (getHref) {
|
|
461
|
+
return (jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }));
|
|
462
|
+
}
|
|
463
|
+
return (jsx(Pagination$1.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }) }));
|
|
464
|
+
});
|
|
465
|
+
const PaginationNextTrigger = React.forwardRef(function PaginationNextTrigger(props, ref) {
|
|
466
|
+
const { size, variantMap, getHref } = useRootProps();
|
|
467
|
+
const { nextPage } = usePaginationContext();
|
|
468
|
+
if (getHref) {
|
|
469
|
+
return (jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }));
|
|
470
|
+
}
|
|
471
|
+
return (jsx(Pagination$1.NextTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }) }));
|
|
472
|
+
});
|
|
473
|
+
const PaginationItems = (props) => {
|
|
474
|
+
return (jsx(Pagination$1.Context, { children: ({ pages }) => pages.map((page, index) => {
|
|
475
|
+
return page.type === "ellipsis" ? (jsx(PaginationEllipsis, { index: index, ...props }, index)) : (jsx(PaginationItem, { type: "page", value: page.value, ...props }, index));
|
|
476
|
+
}) }));
|
|
418
477
|
};
|
|
478
|
+
const PaginationPageText = React.forwardRef(function PaginationPageText(props, ref) {
|
|
479
|
+
const { format = "compact", ...rest } = props;
|
|
480
|
+
const { page, totalPages, pageRange, count } = usePaginationContext();
|
|
481
|
+
const content = React.useMemo(() => {
|
|
482
|
+
if (format === "short")
|
|
483
|
+
return `${page} / ${totalPages}`;
|
|
484
|
+
if (format === "compact")
|
|
485
|
+
return `${page} / ${totalPages}`;
|
|
486
|
+
return `${pageRange.start + 1} - ${Math.min(pageRange.end, count)} / ${count}`;
|
|
487
|
+
}, [format, page, totalPages, pageRange, count]);
|
|
488
|
+
return (jsx(Text, { fontWeight: "medium", ref: ref, ...rest, children: content }));
|
|
489
|
+
});
|
|
419
490
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
491
|
+
// TODO: not working in client side
|
|
492
|
+
const Pagination = () => {
|
|
493
|
+
const { table, type } = useDataTableContext();
|
|
494
|
+
const getCount = () => {
|
|
495
|
+
if (type === "client") {
|
|
496
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
497
|
+
}
|
|
498
|
+
return table.getRowCount();
|
|
499
|
+
};
|
|
500
|
+
return (jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
501
|
+
table.setPageIndex(e.page - 1);
|
|
502
|
+
}, children: jsxs(HStack, { children: [jsx(PaginationPrevTrigger, {}), jsx(PaginationItems, {}), jsx(PaginationNextTrigger, {})] }) }));
|
|
432
503
|
};
|
|
433
504
|
|
|
434
|
-
const
|
|
505
|
+
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
435
506
|
const { table } = useDataTableContext();
|
|
436
507
|
return (jsx(Button$1, { onClick: () => {
|
|
437
|
-
table.
|
|
508
|
+
table.resetRowSelection();
|
|
438
509
|
}, children: text }));
|
|
439
510
|
};
|
|
440
511
|
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
|
|
512
|
+
const RowCountText = () => {
|
|
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 jsx(Text, { children: getCount() });
|
|
444
521
|
};
|
|
445
522
|
|
|
446
523
|
// pulling this into a separate file so adapter(s) that don't
|
|
@@ -2360,13 +2437,16 @@ function ColumnCard({ columnId }) {
|
|
|
2360
2437
|
onDrop: () => setDragging(false), // NEW
|
|
2361
2438
|
});
|
|
2362
2439
|
}, [columnId, table]);
|
|
2363
|
-
return (jsxs(Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsx(Flex, { alignItems: "center", padding: "0", cursor:
|
|
2440
|
+
return (jsxs(Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsx(Flex, { alignItems: "center", padding: "0", cursor: "grab", children: jsx(FaGripLinesVertical, { color: "gray.400" }) }), jsx(Flex, { justifyContent: "space-between", alignItems: "center", children: jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
|
|
2364
2441
|
}
|
|
2365
2442
|
function CardContainer({ location, children }) {
|
|
2366
2443
|
const ref = useRef(null);
|
|
2367
2444
|
const [isDraggedOver, setIsDraggedOver] = useState(false);
|
|
2368
2445
|
useEffect(() => {
|
|
2369
2446
|
const el = ref.current;
|
|
2447
|
+
if (el === null) {
|
|
2448
|
+
return;
|
|
2449
|
+
}
|
|
2370
2450
|
invariant(el);
|
|
2371
2451
|
return dropTargetForElements({
|
|
2372
2452
|
element: el,
|
|
@@ -2438,149 +2518,37 @@ const TableViewer = () => {
|
|
|
2438
2518
|
const ViewDialog = ({ icon = jsx(IoMdEye, {}) }) => {
|
|
2439
2519
|
const viewModel = useDisclosure();
|
|
2440
2520
|
const { translate } = useDataTableContext();
|
|
2441
|
-
return (jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", translate.t("
|
|
2521
|
+
return (jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", translate.t("view_dialog.button_text")] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsx(DialogHeader, { children: jsx(DialogTitle, { children: translate.t("view_dialog.title") }) }), jsx(DialogBody, { children: jsx(TableViewer, {}) }), jsx(DialogFooter, {})] })] }));
|
|
2442
2522
|
};
|
|
2443
2523
|
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
return (jsx(
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
React.forwardRef(function MenuRadioItem(props, ref) {
|
|
2455
|
-
const { children, ...rest } = props;
|
|
2456
|
-
return (jsxs(Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsx(AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsx(Menu.ItemIndicator, { children: jsx(LuCheck, {}) }) }), jsx(Menu.ItemText, { children: children })] }));
|
|
2457
|
-
});
|
|
2458
|
-
React.forwardRef(function MenuItemGroup(props, ref) {
|
|
2459
|
-
const { title, children, ...rest } = props;
|
|
2460
|
-
return (jsxs(Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsx(Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
2461
|
-
});
|
|
2462
|
-
React.forwardRef(function MenuTriggerItem(props, ref) {
|
|
2463
|
-
const { startIcon, children, ...rest } = props;
|
|
2464
|
-
return (jsxs(Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsx(LuChevronRight, {})] }));
|
|
2524
|
+
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
2525
|
+
if (!!row.original === false) {
|
|
2526
|
+
return jsx(Fragment, {});
|
|
2527
|
+
}
|
|
2528
|
+
const isShowFirstColumn = !!titleColumnId || showTag;
|
|
2529
|
+
return (jsxs(Grid, { templateRows: "auto auto", gap: "1rem", children: [!!imageColumnId && (jsx(Image, { width: "100%", src: row.original[imageColumnId], ...imageProps })), isShowFirstColumn && (jsxs(Flex, { gap: "0.5rem", flexFlow: "wrap", children: [!!titleColumnId && (jsx(Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] })), showTag && (jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] }))] }));
|
|
2530
|
+
};
|
|
2531
|
+
|
|
2532
|
+
const DataTableServerContext = createContext({
|
|
2533
|
+
url: "",
|
|
2465
2534
|
});
|
|
2466
|
-
Menu.RadioItemGroup;
|
|
2467
|
-
Menu.ContextTrigger;
|
|
2468
|
-
const MenuRoot = Menu.Root;
|
|
2469
|
-
Menu.Separator;
|
|
2470
|
-
const MenuItem = Menu.Item;
|
|
2471
|
-
Menu.ItemText;
|
|
2472
|
-
Menu.ItemCommand;
|
|
2473
|
-
const MenuTrigger = Menu.Trigger;
|
|
2474
2535
|
|
|
2475
|
-
const
|
|
2476
|
-
const
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2536
|
+
const useDataTableServerContext = () => {
|
|
2537
|
+
const context = useContext(DataTableServerContext);
|
|
2538
|
+
const { query } = context;
|
|
2539
|
+
const isEmpty = (query.data?.count ?? 0) <= 0;
|
|
2540
|
+
return { ...context, isEmpty };
|
|
2480
2541
|
};
|
|
2481
2542
|
|
|
2482
|
-
const
|
|
2483
|
-
const {
|
|
2484
|
-
return (jsx(
|
|
2485
|
-
table.resetRowSelection();
|
|
2486
|
-
}, children: text }));
|
|
2543
|
+
const EmptyState$1 = ({ title = "No records", description = "Add a new events to get started or refine your search", }) => {
|
|
2544
|
+
const { isEmpty } = useDataTableServerContext();
|
|
2545
|
+
return (jsx(Fragment, { children: isEmpty && (jsx(EmptyState$2.Root, { children: jsxs(EmptyState$2.Content, { children: [jsx(EmptyState$2.Indicator, { children: jsx(HiColorSwatch, {}) }), jsxs(VStack, { textAlign: "center", children: [jsx(EmptyState$2.Title, { children: title }), jsx(EmptyState$2.Description, { children: description })] })] }) })) }));
|
|
2487
2546
|
};
|
|
2488
2547
|
|
|
2489
|
-
const
|
|
2490
|
-
const {
|
|
2491
|
-
const
|
|
2492
|
-
|
|
2493
|
-
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
2494
|
-
}
|
|
2495
|
-
return table.getRowCount();
|
|
2496
|
-
};
|
|
2497
|
-
return jsx(Text, { children: getCount() });
|
|
2498
|
-
};
|
|
2499
|
-
|
|
2500
|
-
const { withContext } = createRecipeContext({ key: "button" });
|
|
2501
|
-
// Replace "a" with your framework's link component
|
|
2502
|
-
const LinkButton = withContext("a");
|
|
2503
|
-
|
|
2504
|
-
const [RootPropsProvider, useRootProps] = createContext$1({
|
|
2505
|
-
name: "RootPropsProvider",
|
|
2506
|
-
});
|
|
2507
|
-
const variantMap = {
|
|
2508
|
-
outline: { default: "ghost", ellipsis: "plain", current: "outline" },
|
|
2509
|
-
solid: { default: "outline", ellipsis: "outline", current: "solid" },
|
|
2510
|
-
subtle: { default: "ghost", ellipsis: "plain", current: "subtle" },
|
|
2511
|
-
};
|
|
2512
|
-
const PaginationRoot = React.forwardRef(function PaginationRoot(props, ref) {
|
|
2513
|
-
const { size = "sm", variant = "outline", getHref, ...rest } = props;
|
|
2514
|
-
return (jsx(RootPropsProvider, { value: { size, variantMap: variantMap[variant], getHref }, children: jsx(Pagination$1.Root, { ref: ref, type: getHref ? "link" : "button", ...rest }) }));
|
|
2515
|
-
});
|
|
2516
|
-
const PaginationEllipsis = React.forwardRef(function PaginationEllipsis(props, ref) {
|
|
2517
|
-
const { size, variantMap } = useRootProps();
|
|
2518
|
-
return (jsx(Pagination$1.Ellipsis, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { as: "span", variant: variantMap.ellipsis, size: size, children: jsx(HiMiniEllipsisHorizontal, {}) }) }));
|
|
2519
|
-
});
|
|
2520
|
-
const PaginationItem = React.forwardRef(function PaginationItem(props, ref) {
|
|
2521
|
-
const { page } = usePaginationContext();
|
|
2522
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2523
|
-
const current = page === props.value;
|
|
2524
|
-
const variant = current ? variantMap.current : variantMap.default;
|
|
2525
|
-
if (getHref) {
|
|
2526
|
-
return (jsx(LinkButton, { href: getHref(props.value), variant: variant, size: size, children: props.value }));
|
|
2527
|
-
}
|
|
2528
|
-
return (jsx(Pagination$1.Item, { ref: ref, ...props, asChild: true, children: jsx(Button$1, { variant: variant, size: size, children: props.value }) }));
|
|
2529
|
-
});
|
|
2530
|
-
const PaginationPrevTrigger = React.forwardRef(function PaginationPrevTrigger(props, ref) {
|
|
2531
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2532
|
-
const { previousPage } = usePaginationContext();
|
|
2533
|
-
if (getHref) {
|
|
2534
|
-
return (jsx(LinkButton, { href: previousPage != null ? getHref(previousPage) : undefined, variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }));
|
|
2535
|
-
}
|
|
2536
|
-
return (jsx(Pagination$1.PrevTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronLeft, {}) }) }));
|
|
2537
|
-
});
|
|
2538
|
-
const PaginationNextTrigger = React.forwardRef(function PaginationNextTrigger(props, ref) {
|
|
2539
|
-
const { size, variantMap, getHref } = useRootProps();
|
|
2540
|
-
const { nextPage } = usePaginationContext();
|
|
2541
|
-
if (getHref) {
|
|
2542
|
-
return (jsx(LinkButton, { href: nextPage != null ? getHref(nextPage) : undefined, variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }));
|
|
2543
|
-
}
|
|
2544
|
-
return (jsx(Pagination$1.NextTrigger, { ref: ref, asChild: true, ...props, children: jsx(IconButton, { variant: variantMap.default, size: size, children: jsx(HiChevronRight, {}) }) }));
|
|
2545
|
-
});
|
|
2546
|
-
const PaginationItems = (props) => {
|
|
2547
|
-
return (jsx(Pagination$1.Context, { children: ({ pages }) => pages.map((page, index) => {
|
|
2548
|
-
return page.type === "ellipsis" ? (jsx(PaginationEllipsis, { index: index, ...props }, index)) : (jsx(PaginationItem, { type: "page", value: page.value, ...props }, index));
|
|
2549
|
-
}) }));
|
|
2550
|
-
};
|
|
2551
|
-
const PaginationPageText = React.forwardRef(function PaginationPageText(props, ref) {
|
|
2552
|
-
const { format = "compact", ...rest } = props;
|
|
2553
|
-
const { page, totalPages, pageRange, count } = usePaginationContext();
|
|
2554
|
-
const content = React.useMemo(() => {
|
|
2555
|
-
if (format === "short")
|
|
2556
|
-
return `${page} / ${totalPages}`;
|
|
2557
|
-
if (format === "compact")
|
|
2558
|
-
return `${page} / ${totalPages}`;
|
|
2559
|
-
return `${pageRange.start + 1} - ${Math.min(pageRange.end, count)} / ${count}`;
|
|
2560
|
-
}, [format, page, totalPages, pageRange, count]);
|
|
2561
|
-
return (jsx(Text, { fontWeight: "medium", ref: ref, ...rest, children: content }));
|
|
2562
|
-
});
|
|
2563
|
-
|
|
2564
|
-
// TODO: not working in client side
|
|
2565
|
-
const Pagination = () => {
|
|
2566
|
-
const { table, type } = useDataTableContext();
|
|
2567
|
-
const getCount = () => {
|
|
2568
|
-
if (type === "client") {
|
|
2569
|
-
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
2570
|
-
}
|
|
2571
|
-
return table.getRowCount();
|
|
2572
|
-
};
|
|
2573
|
-
return (jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
2574
|
-
table.setPageIndex(e.page - 1);
|
|
2575
|
-
}, children: jsxs(HStack, { children: [jsx(PaginationPrevTrigger, {}), jsx(PaginationItems, {}), jsx(PaginationNextTrigger, {})] }) }));
|
|
2576
|
-
};
|
|
2577
|
-
|
|
2578
|
-
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
2579
|
-
if (!!row.original === false) {
|
|
2580
|
-
return jsx(Fragment, {});
|
|
2581
|
-
}
|
|
2582
|
-
const isShowFirstColumn = !!titleColumnId || showTag;
|
|
2583
|
-
return (jsxs(Grid, { templateRows: "auto auto", gap: "1rem", children: [!!imageColumnId && (jsx(Image, { width: "100%", src: row.original[imageColumnId], ...imageProps })), isShowFirstColumn && (jsxs(Flex, { gap: "0.5rem", flexFlow: "wrap", children: [!!titleColumnId && (jsx(Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] })), showTag && (jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] }))] }));
|
|
2548
|
+
const ErrorAlert = ({ showMessage = true }) => {
|
|
2549
|
+
const { query } = useDataTableServerContext();
|
|
2550
|
+
const { isError, error } = query;
|
|
2551
|
+
return (jsx(Fragment, { children: isError && (jsxs(Alert.Root, { status: "error", children: [jsx(Alert.Indicator, {}), jsxs(Alert.Content, { children: [jsx(Alert.Title, { children: error.name }), showMessage && (jsx(Alert.Description, { children: error.message }))] })] })) }));
|
|
2584
2552
|
};
|
|
2585
2553
|
|
|
2586
2554
|
const snakeToLabel = (str) => {
|
|
@@ -2826,13 +2794,25 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2826
2794
|
setGlobalFilter,
|
|
2827
2795
|
type: "client",
|
|
2828
2796
|
translate,
|
|
2797
|
+
columns,
|
|
2798
|
+
sorting,
|
|
2799
|
+
setSorting,
|
|
2800
|
+
columnFilters,
|
|
2801
|
+
setColumnFilters,
|
|
2802
|
+
pagination,
|
|
2803
|
+
setPagination,
|
|
2804
|
+
rowSelection,
|
|
2805
|
+
setRowSelection,
|
|
2806
|
+
columnOrder,
|
|
2807
|
+
setColumnOrder,
|
|
2808
|
+
density,
|
|
2809
|
+
setDensity,
|
|
2810
|
+
columnVisibility,
|
|
2811
|
+
setColumnVisibility,
|
|
2812
|
+
data,
|
|
2829
2813
|
}, children: children }));
|
|
2830
2814
|
}
|
|
2831
2815
|
|
|
2832
|
-
const DataTableServerContext = createContext({
|
|
2833
|
-
url: "",
|
|
2834
|
-
});
|
|
2835
|
-
|
|
2836
2816
|
/**
|
|
2837
2817
|
* DataTableServer will create a context to hold all values to
|
|
2838
2818
|
* help the render of the DataTable in serverside
|
|
@@ -2898,90 +2878,25 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2898
2878
|
setGlobalFilter,
|
|
2899
2879
|
type: "server",
|
|
2900
2880
|
translate,
|
|
2881
|
+
columns,
|
|
2882
|
+
sorting,
|
|
2883
|
+
setSorting,
|
|
2884
|
+
columnFilters,
|
|
2885
|
+
setColumnFilters,
|
|
2886
|
+
pagination,
|
|
2887
|
+
setPagination,
|
|
2888
|
+
rowSelection,
|
|
2889
|
+
setRowSelection,
|
|
2890
|
+
columnOrder,
|
|
2891
|
+
setColumnOrder,
|
|
2892
|
+
density,
|
|
2893
|
+
setDensity,
|
|
2894
|
+
columnVisibility,
|
|
2895
|
+
setColumnVisibility,
|
|
2896
|
+
data: query.data?.data ?? [],
|
|
2901
2897
|
}, children: jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2902
2898
|
}
|
|
2903
2899
|
|
|
2904
|
-
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
2905
|
-
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
2906
|
-
return (jsxs(Checkbox$1.Root, { ref: rootRef, ...rest, children: [jsx(Checkbox$1.HiddenInput, { ref: ref, ...inputProps }), jsx(Checkbox$1.Control, { children: icon || jsx(Checkbox$1.Indicator, {}) }), children != null && (jsx(Checkbox$1.Label, { children: children }))] }));
|
|
2907
|
-
});
|
|
2908
|
-
|
|
2909
|
-
const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
2910
|
-
const { table } = useDataTableContext();
|
|
2911
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2912
|
-
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
2913
|
-
const handleRowHover = (index) => {
|
|
2914
|
-
setHoveredRow(index);
|
|
2915
|
-
};
|
|
2916
|
-
const getTdProps = (cell) => {
|
|
2917
|
-
const tdProps = cell.column.getIsPinned()
|
|
2918
|
-
? {
|
|
2919
|
-
left: showSelector
|
|
2920
|
-
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
2921
|
-
: `${cell.column.getStart("left")}px`,
|
|
2922
|
-
background: pinnedBgColor.light,
|
|
2923
|
-
position: "sticky",
|
|
2924
|
-
zIndex: -1,
|
|
2925
|
-
_dark: {
|
|
2926
|
-
backgroundColor: pinnedBgColor.dark,
|
|
2927
|
-
},
|
|
2928
|
-
}
|
|
2929
|
-
: {};
|
|
2930
|
-
return tdProps;
|
|
2931
|
-
};
|
|
2932
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2933
|
-
if (hoveredRow === -1) {
|
|
2934
|
-
return {};
|
|
2935
|
-
}
|
|
2936
|
-
if (hoveredRow === index) {
|
|
2937
|
-
return {
|
|
2938
|
-
opacity: "1",
|
|
2939
|
-
};
|
|
2940
|
-
}
|
|
2941
|
-
return {
|
|
2942
|
-
opacity: "0.8",
|
|
2943
|
-
};
|
|
2944
|
-
};
|
|
2945
|
-
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2946
|
-
return (jsxs(Table$1.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow, alwaysShowSelector: alwaysShowSelector })), row.getVisibleCells().map((cell, index) => {
|
|
2947
|
-
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2948
|
-
// styling resize and pinning start
|
|
2949
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, backgroundColor: "white", ...getTdProps(cell), _dark: {
|
|
2950
|
-
backgroundColor: "gray.950",
|
|
2951
|
-
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2952
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2953
|
-
}) }));
|
|
2954
|
-
};
|
|
2955
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2956
|
-
const { table } = useDataTableContext();
|
|
2957
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2958
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2959
|
-
if (alwaysShowSelector) {
|
|
2960
|
-
return true;
|
|
2961
|
-
}
|
|
2962
|
-
if (current_row.getIsSelected()) {
|
|
2963
|
-
return true;
|
|
2964
|
-
}
|
|
2965
|
-
if (hoveredRow == current_index) {
|
|
2966
|
-
return true;
|
|
2967
|
-
}
|
|
2968
|
-
return false;
|
|
2969
|
-
};
|
|
2970
|
-
return (jsxs(Table$1.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2971
|
-
? {
|
|
2972
|
-
left: `0px`,
|
|
2973
|
-
backgroundColor: pinnedBgColor.light,
|
|
2974
|
-
position: "sticky",
|
|
2975
|
-
zIndex: 1,
|
|
2976
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2977
|
-
}
|
|
2978
|
-
: {}),
|
|
2979
|
-
// styling resize and pinning end
|
|
2980
|
-
display: "grid", children: [!isCheckBoxVisible(index, row) && (jsx(Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` })), isCheckBoxVisible(index, row) && (jsx(Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: row.getIsSelected(),
|
|
2981
|
-
disabled: !row.getCanSelect(),
|
|
2982
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
2983
|
-
};
|
|
2984
|
-
|
|
2985
2900
|
const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
2986
2901
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
2987
2902
|
if (disabled)
|
|
@@ -3016,13 +2931,6 @@ const GlobalFilter = () => {
|
|
|
3016
2931
|
} }) }) }));
|
|
3017
2932
|
};
|
|
3018
2933
|
|
|
3019
|
-
const useDataTableServerContext = () => {
|
|
3020
|
-
const context = useContext(DataTableServerContext);
|
|
3021
|
-
const { query } = context;
|
|
3022
|
-
const isEmpty = (query.data?.count ?? 0) <= 0;
|
|
3023
|
-
return { ...context, isEmpty };
|
|
3024
|
-
};
|
|
3025
|
-
|
|
3026
2934
|
const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
|
|
3027
2935
|
const { url } = useDataTableServerContext();
|
|
3028
2936
|
const queryClient = useQueryClient();
|
|
@@ -3069,11 +2977,86 @@ const TableFilterTags = () => {
|
|
|
3069
2977
|
|
|
3070
2978
|
const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children = jsx(Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, showPagination = true, showPageSizeControl = true, showPageCountText = true, showView = true, filterOptions = [], extraItems = jsx(Fragment, {}), loading = false, hasError = false, }) => {
|
|
3071
2979
|
const { translate } = useDataTableContext();
|
|
3072
|
-
return (jsxs(Grid, { templateRows: "auto 1fr
|
|
2980
|
+
return (jsxs(Grid, { templateRows: "auto 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", gap: "0.5rem", children: [jsxs(Flex, { flexFlow: "column", gap: 2, children: [jsxs(Flex, { justifyContent: "space-between", children: [jsx(Box, { children: showView && jsx(ViewDialog, { icon: jsx(MdOutlineViewColumn, {}) }) }), jsxs(Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsx(Spinner, { size: "sm" }), hasError && (jsx(Tooltip, { content: translate.t("has_error"), children: jsx(Icon, { as: BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsx(GlobalFilter, {}), showFilter && jsx(FilterDialog, {}), showReload && jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsx(Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
|
|
3073
2981
|
return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [column, ":"] }), jsx(FilterOptions, { column: column })] }, column));
|
|
3074
2982
|
}) })), showFilterTags && (jsx(Flex, { children: jsx(TableFilterTags, {}) }))] }), jsx(Grid, { overflow: "auto", backgroundColor: "gray.50", _dark: {
|
|
3075
2983
|
backgroundColor: "gray.900",
|
|
3076
|
-
}, children: children }), jsxs(Flex, { justifyContent: "space-between", children: [jsxs(Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsx(PageSizeControl, {}), showPageCountText && (jsxs(Flex, { children: [jsx(Text, { paddingRight: "0.5rem", children: translate.t("rowcount.total") }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(Pagination, {}) })] })] }));
|
|
2984
|
+
}, children: children }), (showPageSizeControl || showPageCountText || showPagination) && (jsxs(Flex, { justifyContent: "space-between", children: [jsxs(Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsx(PageSizeControl, {}), showPageCountText && (jsxs(Flex, { children: [jsx(Text, { paddingRight: "0.5rem", children: translate.t("rowcount.total") }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(Pagination, {}) })] }))] }));
|
|
2985
|
+
};
|
|
2986
|
+
|
|
2987
|
+
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
2988
|
+
const { title, description, icon, children, ...rest } = props;
|
|
2989
|
+
return (jsx(EmptyState$2.Root, { ref: ref, ...rest, children: jsxs(EmptyState$2.Content, { children: [icon && (jsx(EmptyState$2.Indicator, { children: icon })), description ? (jsxs(VStack, { textAlign: "center", children: [jsx(EmptyState$2.Title, { children: title }), jsx(EmptyState$2.Description, { children: description })] })) : (jsx(EmptyState$2.Title, { children: title })), children] }) }));
|
|
2990
|
+
});
|
|
2991
|
+
|
|
2992
|
+
const EmptyResult = (jsx(EmptyState, { icon: jsx(HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxs(List.Root, { variant: "marker", children: [jsx(List.Item, { children: "Try removing filters" }), jsx(List.Item, { children: "Try different keywords" })] }) }));
|
|
2993
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
2994
|
+
const { table } = useDataTableContext();
|
|
2995
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
2996
|
+
return emptyComponent;
|
|
2997
|
+
}
|
|
2998
|
+
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
2999
|
+
};
|
|
3000
|
+
|
|
3001
|
+
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
3002
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3003
|
+
return (jsxs(Checkbox$1.Root, { ref: rootRef, ...rest, children: [jsx(Checkbox$1.HiddenInput, { ref: ref, ...inputProps }), jsx(Checkbox$1.Control, { children: icon || jsx(Checkbox$1.Indicator, {}) }), children != null && (jsx(Checkbox$1.Label, { children: children }))] }));
|
|
3004
|
+
});
|
|
3005
|
+
|
|
3006
|
+
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
3007
|
+
"use no memo";
|
|
3008
|
+
const { table } = useDataTableContext();
|
|
3009
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3010
|
+
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
3011
|
+
const handleRowHover = (index) => {
|
|
3012
|
+
setHoveredRow(index);
|
|
3013
|
+
};
|
|
3014
|
+
const getTdProps = (cell) => {
|
|
3015
|
+
const tdProps = cell.column.getIsPinned()
|
|
3016
|
+
? {
|
|
3017
|
+
left: showSelector
|
|
3018
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3019
|
+
: `${cell.column.getStart("left")}px`,
|
|
3020
|
+
position: "relative",
|
|
3021
|
+
}
|
|
3022
|
+
: {};
|
|
3023
|
+
return tdProps;
|
|
3024
|
+
};
|
|
3025
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3026
|
+
if (hoveredRow === -1) {
|
|
3027
|
+
return {};
|
|
3028
|
+
}
|
|
3029
|
+
if (hoveredRow === index) {
|
|
3030
|
+
return {
|
|
3031
|
+
opacity: "1",
|
|
3032
|
+
};
|
|
3033
|
+
}
|
|
3034
|
+
return {
|
|
3035
|
+
opacity: "0.8",
|
|
3036
|
+
};
|
|
3037
|
+
};
|
|
3038
|
+
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3039
|
+
return (jsxs(Table$1.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow })), row.getVisibleCells().map((cell, index) => {
|
|
3040
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3041
|
+
// styling resize and pinning start
|
|
3042
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3043
|
+
base: "colorPalette.900",
|
|
3044
|
+
_dark: "colorPalette.100",
|
|
3045
|
+
},
|
|
3046
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3047
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3048
|
+
}) }));
|
|
3049
|
+
};
|
|
3050
|
+
const TableRowSelector = ({ index, row, }) => {
|
|
3051
|
+
const { table } = useDataTableContext();
|
|
3052
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3053
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3054
|
+
base: "colorPalette.900",
|
|
3055
|
+
_dark: "colorPalette.100",
|
|
3056
|
+
},
|
|
3057
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
3058
|
+
disabled: !row.getCanSelect(),
|
|
3059
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3077
3060
|
};
|
|
3078
3061
|
|
|
3079
3062
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
@@ -3136,37 +3119,17 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3136
3119
|
jsx(Fragment, {})), header.column.getIsSorted() === "asc" && (jsx(BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsx(BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3137
3120
|
};
|
|
3138
3121
|
|
|
3139
|
-
const TableHeader = ({ canResize = true,
|
|
3122
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3140
3123
|
const { table } = useDataTableContext();
|
|
3141
3124
|
const SELECTION_BOX_WIDTH = 20;
|
|
3142
|
-
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
3143
|
-
const handleRowHover = (isHovered) => {
|
|
3144
|
-
setHoveredCheckBox(isHovered);
|
|
3145
|
-
};
|
|
3146
|
-
const isCheckBoxVisible = () => {
|
|
3147
|
-
if (alwaysShowSelector) {
|
|
3148
|
-
return true;
|
|
3149
|
-
}
|
|
3150
|
-
if (table.getIsAllRowsSelected()) {
|
|
3151
|
-
return true;
|
|
3152
|
-
}
|
|
3153
|
-
if (hoveredCheckBox) {
|
|
3154
|
-
return true;
|
|
3155
|
-
}
|
|
3156
|
-
return false;
|
|
3157
|
-
};
|
|
3158
3125
|
const getThProps = (header) => {
|
|
3159
3126
|
const thProps = header.column.getIsPinned()
|
|
3160
3127
|
? {
|
|
3161
3128
|
left: showSelector
|
|
3162
3129
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3163
3130
|
: `${header.getStart("left")}px`,
|
|
3164
|
-
background: pinnedBgColor.light,
|
|
3165
3131
|
position: "sticky",
|
|
3166
3132
|
zIndex: 100 + 1,
|
|
3167
|
-
_dark: {
|
|
3168
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3169
|
-
},
|
|
3170
3133
|
}
|
|
3171
3134
|
: {};
|
|
3172
3135
|
return thProps;
|
|
@@ -3175,21 +3138,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3175
3138
|
position: "sticky",
|
|
3176
3139
|
top: 0,
|
|
3177
3140
|
};
|
|
3178
|
-
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
zIndex: 1,
|
|
3186
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3187
|
-
}
|
|
3188
|
-
: {}),
|
|
3189
|
-
// styling resize and pinning end
|
|
3190
|
-
padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsx(Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
3191
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3192
|
-
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsx(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) => {
|
|
3141
|
+
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...tableHeaderProps, children: table.getHeaderGroups().map((headerGroup) => (jsxs(Table$1.Row, { display: "flex", ...tableRowProps, children: [showSelector && (jsx(Table$1.ColumnHeader, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3142
|
+
base: "colorPalette.900",
|
|
3143
|
+
_dark: "colorPalette.100",
|
|
3144
|
+
},
|
|
3145
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: table.getIsAllRowsSelected(),
|
|
3146
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3147
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3193
3148
|
const resizeProps = {
|
|
3194
3149
|
onMouseDown: header.getResizeHandler(),
|
|
3195
3150
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3197,7 +3152,11 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3197
3152
|
};
|
|
3198
3153
|
return (jsxs(Table$1.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3199
3154
|
// styling resize and pinning start
|
|
3200
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3155
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3156
|
+
base: "colorPalette.800",
|
|
3157
|
+
_dark: "colorPalette.200",
|
|
3158
|
+
},
|
|
3159
|
+
bg: { base: "colorPalette.100", _dark: "colorPalette.900" }, ...getThProps(header), children: [jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsx(Flex, { padding: `${table.getDensityValue()}px`, alignItems: "center", justifyContent: "start", borderRadius: "0rem", overflow: "auto", _hover: {
|
|
3201
3160
|
backgroundColor: "gray.100",
|
|
3202
3161
|
_dark: {
|
|
3203
3162
|
backgroundColor: "gray.700",
|
|
@@ -3236,21 +3195,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3236
3195
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3237
3196
|
};
|
|
3238
3197
|
|
|
3239
|
-
const
|
|
3240
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3241
|
-
return (jsx(EmptyState$2.Root, { ref: ref, ...rest, children: jsxs(EmptyState$2.Content, { children: [icon && (jsx(EmptyState$2.Indicator, { children: icon })), description ? (jsxs(VStack, { textAlign: "center", children: [jsx(EmptyState$2.Title, { children: title }), jsx(EmptyState$2.Description, { children: description })] })) : (jsx(EmptyState$2.Title, { children: title })), children] }) }));
|
|
3242
|
-
});
|
|
3243
|
-
|
|
3244
|
-
const EmptyResult = (jsx(EmptyState$1, { icon: jsx(HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxs(List.Root, { variant: "marker", children: [jsx(List.Item, { children: "Try removing filters" }), jsx(List.Item, { children: "Try different keywords" })] }) }));
|
|
3245
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3246
|
-
const { table } = useDataTableContext();
|
|
3247
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3248
|
-
return emptyComponent;
|
|
3249
|
-
}
|
|
3250
|
-
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3251
|
-
};
|
|
3252
|
-
|
|
3253
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3198
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3254
3199
|
if (variant === "greedy") {
|
|
3255
3200
|
return (jsx(TableControls, { ...controlProps, children: jsxs(Table, { canResize: false, ...{ ...tableProps }, children: [jsx(TableHeader, { canResize: false, ...tableHeaderProps }), jsx(TableBody, { canResize: false, ...tableBodyProps }), showFooter && (jsx(TableFooter, { canResize: false, ...tableFooterProps }))] }) }));
|
|
3256
3201
|
}
|
|
@@ -3510,16 +3455,82 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3510
3455
|
return columns;
|
|
3511
3456
|
};
|
|
3512
3457
|
|
|
3513
|
-
const
|
|
3514
|
-
const {
|
|
3515
|
-
|
|
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 jsx(Fragment, { children: emptyComponent });
|
|
3504
|
+
}
|
|
3505
|
+
return (jsxs(Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", color: { base: "colorPalette.900", _dark: "colorPalette.100" }, borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: [jsx(Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: columnHeaders.map((header) => {
|
|
3506
|
+
return (jsx(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 (jsx(Fragment, { children: columnHeaders.map((header) => {
|
|
3509
|
+
const { cell } = columnsMap[header];
|
|
3510
|
+
const value = record[header];
|
|
3511
|
+
if (!!record === false) {
|
|
3512
|
+
return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3513
|
+
}
|
|
3514
|
+
if (cell) {
|
|
3515
|
+
return (jsx(Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3516
|
+
}
|
|
3517
|
+
if (typeof value === "object") {
|
|
3518
|
+
return (jsx(Box, { ...cellProps, children: jsx(RecordDisplay, { object: value }) }));
|
|
3519
|
+
}
|
|
3520
|
+
return jsx(Box, { ...cellProps, children: value });
|
|
3521
|
+
}) }));
|
|
3522
|
+
})] }));
|
|
3516
3523
|
};
|
|
3517
3524
|
|
|
3518
|
-
const
|
|
3519
|
-
const {
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3525
|
+
const AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3526
|
+
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3527
|
+
return (jsxs(Accordion.ItemTrigger, { ...rest, ref: ref, children: [indicatorPlacement === "start" && (jsx(Accordion.ItemIndicator, { rotate: { base: "-90deg", _open: "0deg" }, children: jsx(LuChevronDown, {}) })), jsx(HStack, { gap: "4", flex: "1", textAlign: "start", width: "full", children: children }), indicatorPlacement === "end" && (jsx(Accordion.ItemIndicator, { children: jsx(LuChevronDown, {}) }))] }));
|
|
3528
|
+
});
|
|
3529
|
+
const AccordionItemContent = React.forwardRef(function AccordionItemContent(props, ref) {
|
|
3530
|
+
return (jsx(Accordion.ItemContent, { children: jsx(Accordion.ItemBody, { ...props, ref: ref }) }));
|
|
3531
|
+
});
|
|
3532
|
+
const AccordionRoot = Accordion.Root;
|
|
3533
|
+
const AccordionItem = Accordion.Item;
|
|
3523
3534
|
|
|
3524
3535
|
//@ts-expect-error TODO: find appropriate type
|
|
3525
3536
|
const SchemaFormContext = createContext({
|
|
@@ -3542,15 +3553,56 @@ const clearEmptyString = (object) => {
|
|
|
3542
3553
|
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== ""));
|
|
3543
3554
|
};
|
|
3544
3555
|
|
|
3545
|
-
const
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
}
|
|
3549
|
-
const
|
|
3550
|
-
|
|
3551
|
-
});
|
|
3552
|
-
|
|
3553
|
-
|
|
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] = useState(false);
|
|
3573
|
+
const [isError, setIsError] = useState(false);
|
|
3574
|
+
const [isSubmiting, setIsSubmiting] = useState(false);
|
|
3575
|
+
const [isConfirming, setIsConfirming] = useState(false);
|
|
3576
|
+
const [validatedData, setValidatedData] = useState();
|
|
3577
|
+
const [error, setError] = useState();
|
|
3578
|
+
return (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: jsx(FormProvider, { ...form, children: children }) }));
|
|
3605
|
+
};
|
|
3554
3606
|
|
|
3555
3607
|
function removeIndex(str) {
|
|
3556
3608
|
return str.replace(/\.\d+\./g, '.');
|
|
@@ -3565,7 +3617,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3565
3617
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3566
3618
|
const { formState: { errors }, setValue, watch, } = useFormContext();
|
|
3567
3619
|
const fields = (watch(colLabel) ?? []);
|
|
3568
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
3620
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] }), fields.map((field, index) => (jsxs(Flex, { flexFlow: "column", children: [jsx(Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: jsx(SchemaRenderer, { column: `${index}`,
|
|
3569
3621
|
prefix: `${colLabel}.`,
|
|
3570
3622
|
schema: items }) }), jsx(Flex, { justifyContent: "end", children: jsx(Button$1, { variant: "ghost", onClick: () => {
|
|
3571
3623
|
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
@@ -3585,7 +3637,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3585
3637
|
return;
|
|
3586
3638
|
}
|
|
3587
3639
|
setValue(colLabel, [...fields, {}]);
|
|
3588
|
-
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3640
|
+
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3589
3641
|
};
|
|
3590
3642
|
|
|
3591
3643
|
const Field = React.forwardRef(function Field(props, ref) {
|
|
@@ -3600,10 +3652,10 @@ const BooleanPicker = ({ schema, column, prefix }) => {
|
|
|
3600
3652
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3601
3653
|
const colLabel = `${prefix}${column}`;
|
|
3602
3654
|
const value = watch(colLabel);
|
|
3603
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
3655
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3604
3656
|
gridRow, children: [jsx(CheckboxCard, { checked: value, variant: "surface", onChange: () => {
|
|
3605
3657
|
setValue(colLabel, !value);
|
|
3606
|
-
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3658
|
+
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3607
3659
|
};
|
|
3608
3660
|
|
|
3609
3661
|
const monthNamesShort = [
|
|
@@ -3701,10 +3753,11 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3701
3753
|
const colLabel = `${prefix}${column}`;
|
|
3702
3754
|
const [open, setOpen] = useState(false);
|
|
3703
3755
|
const selectedDate = watch(colLabel);
|
|
3704
|
-
|
|
3756
|
+
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3757
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3705
3758
|
gridRow, children: [jsxs(PopoverRoot, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsx(PopoverTrigger, { asChild: true, children: jsx(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
3706
3759
|
setOpen(true);
|
|
3707
|
-
}, children: selectedDate !== undefined ?
|
|
3760
|
+
}, children: selectedDate !== undefined ? `${formatedDate}` : "" }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
|
|
3708
3761
|
// @ts-expect-error TODO: find appropriate types
|
|
3709
3762
|
, {
|
|
3710
3763
|
// @ts-expect-error TODO: find appropriate types
|
|
@@ -3713,7 +3766,7 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3713
3766
|
onDateSelected: ({ date }) => {
|
|
3714
3767
|
setValue(colLabel, dayjs(date).format("YYYY-MM-DD"));
|
|
3715
3768
|
setOpen(false);
|
|
3716
|
-
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3769
|
+
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3717
3770
|
};
|
|
3718
3771
|
|
|
3719
3772
|
function filterArray(array, searchTerm) {
|
|
@@ -3746,25 +3799,24 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3746
3799
|
setSearchText(event.target.value);
|
|
3747
3800
|
setLimit(10);
|
|
3748
3801
|
};
|
|
3749
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
3802
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3750
3803
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3751
3804
|
const item = enumValue;
|
|
3752
3805
|
if (item === undefined) {
|
|
3753
3806
|
return jsx(Fragment, { children: "undefined" });
|
|
3754
3807
|
}
|
|
3755
3808
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
3756
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3757
3809
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3758
3810
|
}, children: !!renderDisplay === true
|
|
3759
3811
|
? renderDisplay(item)
|
|
3760
3812
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
3761
3813
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3762
3814
|
setOpenSearchResult(true);
|
|
3763
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
3815
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
3764
3816
|
setOpenSearchResult(true);
|
|
3765
3817
|
}, children: watchEnum === undefined
|
|
3766
3818
|
? ""
|
|
3767
|
-
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsx(PopoverTrigger, {}), jsx(PopoverContent, { children: jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsx(Input, { placeholder: translate.t(`${column}.
|
|
3819
|
+
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsx(PopoverTrigger, {}), jsx(PopoverContent, { children: jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsx(Input, { placeholder: translate.t(`${column}.type_to_search`), onChange: (event) => {
|
|
3768
3820
|
onSearchChange(event);
|
|
3769
3821
|
setOpenSearchResult(true);
|
|
3770
3822
|
}, autoComplete: "off", ref: ref }), jsx(PopoverTitle, {}), jsx(Text, { children: `${translate.t(`${column}.total`)}: ${count}, ${translate.t(`${column}.showing`)} ${limit}` }), jsxs(Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsx(Flex, { flexFlow: "column wrap", children: filterArray(dataList, searchText ?? "").map((item) => {
|
|
@@ -3782,7 +3834,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3782
3834
|
}, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true
|
|
3783
3835
|
? renderDisplay(item)
|
|
3784
3836
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }, `${colLabel}-${item}`));
|
|
3785
|
-
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Fragment, { children: translate.t(removeIndex(`${colLabel}.
|
|
3837
|
+
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Fragment, { children: translate.t(removeIndex(`${colLabel}.empty_search_result`)) })) }))] })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3786
3838
|
};
|
|
3787
3839
|
|
|
3788
3840
|
function isEnteringWindow(_ref) {
|
|
@@ -4144,7 +4196,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4144
4196
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4145
4197
|
const currentFiles = (watch(column) ?? []);
|
|
4146
4198
|
const colLabel = `${prefix}${column}`;
|
|
4147
|
-
return (jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4199
|
+
return (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: [jsx(FileDropzone, { onDrop: ({ files }) => {
|
|
4148
4200
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4149
4201
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4150
4202
|
}, placeholder: translate.t(removeIndex(`${colLabel}.fileDropzone`)) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4153,7 +4205,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4153
4205
|
return name !== file.name;
|
|
4154
4206
|
}));
|
|
4155
4207
|
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [jsx(Box, { children: file.name }), jsx(TiDeleteOutline, {})] }) }, file.name));
|
|
4156
|
-
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4208
|
+
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4157
4209
|
};
|
|
4158
4210
|
|
|
4159
4211
|
const getTableData = async ({ serverUrl, in_table, searching = "", where = [], limit = 10, offset = 0, }) => {
|
|
@@ -4270,7 +4322,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4270
4322
|
}
|
|
4271
4323
|
return record[display_column];
|
|
4272
4324
|
};
|
|
4273
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.
|
|
4325
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.field_label`)))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4274
4326
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchIds.map((id) => {
|
|
4275
4327
|
const item = idMap[id];
|
|
4276
4328
|
if (item === undefined) {
|
|
@@ -4283,7 +4335,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4283
4335
|
: item[display_column] }, id));
|
|
4284
4336
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4285
4337
|
setOpenSearchResult(true);
|
|
4286
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
4338
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
4287
4339
|
setOpenSearchResult(true);
|
|
4288
4340
|
}, children: getPickedValue() })), jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start", strategy: "fixed" }, children: [jsx(PopoverTrigger, {}), jsx(PopoverContent, { children: jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsx(Input, { placeholder: translate.t(removeIndex(`${colLabel}.typeToSearch`)), onChange: (event) => {
|
|
4289
4341
|
onSearchChange(event);
|
|
@@ -4308,7 +4360,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4308
4360
|
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true
|
|
4309
4361
|
? renderDisplay(item)
|
|
4310
4362
|
: item[display_column] }, item[column_ref]));
|
|
4311
|
-
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.
|
|
4363
|
+
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.empty_search_result`)) })) }))] }), jsx(PaginationRoot, { justifySelf: "center", count: count, pageSize: 10, defaultPage: 1, page: page + 1, onPageChange: (e) => setPage(e.page - 1), children: jsxs(HStack, { gap: "4", children: [jsx(PaginationPrevTrigger, {}), count > 0 && jsx(PaginationPageText, {}), jsx(PaginationNextTrigger, {})] }) })] }))] }) })] }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4312
4364
|
};
|
|
4313
4365
|
|
|
4314
4366
|
const NumberInputRoot = React.forwardRef(function NumberInput$1(props, ref) {
|
|
@@ -4326,9 +4378,9 @@ const NumberInputField = ({ schema, column, prefix, }) => {
|
|
|
4326
4378
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4327
4379
|
const colLabel = `${prefix}${column}`;
|
|
4328
4380
|
const value = watch(`${colLabel}`);
|
|
4329
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4381
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn, gridRow, children: [jsx(NumberInputRoot, { children: jsx(NumberInputField$1, { required: isRequired, value: value, onChange: (event) => {
|
|
4330
4382
|
setValue(`${colLabel}`, Number(event.target.value));
|
|
4331
|
-
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4383
|
+
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4332
4384
|
};
|
|
4333
4385
|
|
|
4334
4386
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
@@ -4340,13 +4392,13 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4340
4392
|
if (properties === undefined) {
|
|
4341
4393
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4342
4394
|
}
|
|
4343
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4395
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] }), jsx(Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: Object.keys(properties ?? {}).map((key) => {
|
|
4344
4396
|
return (
|
|
4345
4397
|
// @ts-expect-error find suitable types
|
|
4346
4398
|
jsx(ColumnRenderer, { column: `${key}`,
|
|
4347
4399
|
prefix: `${prefix}${column}.`,
|
|
4348
4400
|
properties }, `form-${colLabel}-${key}`));
|
|
4349
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4401
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4350
4402
|
};
|
|
4351
4403
|
|
|
4352
4404
|
const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
@@ -4358,7 +4410,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4358
4410
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4359
4411
|
const [newKey, setNewKey] = useState();
|
|
4360
4412
|
const [newValue, setNewValue] = useState();
|
|
4361
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
4413
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4362
4414
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4363
4415
|
const filtered = entries.filter(([target]) => {
|
|
4364
4416
|
return target !== key;
|
|
@@ -4398,7 +4450,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4398
4450
|
setShowNewEntries(true);
|
|
4399
4451
|
setNewKey(undefined);
|
|
4400
4452
|
setNewValue(undefined);
|
|
4401
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4453
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4402
4454
|
};
|
|
4403
4455
|
|
|
4404
4456
|
const StringInputField = ({ column, schema, prefix, }) => {
|
|
@@ -4407,7 +4459,7 @@ const StringInputField = ({ column, schema, prefix, }) => {
|
|
|
4407
4459
|
const { required, gridColumn, gridRow } = schema;
|
|
4408
4460
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4409
4461
|
const colLabel = `${prefix}${column}`;
|
|
4410
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4462
|
+
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", children: [jsx(Input, { ...register(`${colLabel}`, { required: isRequired }), autoComplete: "off" }), errors[colLabel] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4411
4463
|
};
|
|
4412
4464
|
|
|
4413
4465
|
const RadioCardItem = React.forwardRef(function RadioCardItem(props, ref) {
|
|
@@ -4571,9 +4623,9 @@ const ArrayViewer = ({ schema, column, prefix }) => {
|
|
|
4571
4623
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4572
4624
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4573
4625
|
const values = watch(colLabel) ?? [];
|
|
4574
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4626
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] }), values.map((field, index) => (jsx(Flex, { flexFlow: "column", children: jsx(Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: jsx(SchemaViewer, { column: `${index}`,
|
|
4575
4627
|
prefix: `${colLabel}.`,
|
|
4576
|
-
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4628
|
+
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4577
4629
|
};
|
|
4578
4630
|
|
|
4579
4631
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4583,10 +4635,10 @@ const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
|
4583
4635
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4584
4636
|
const colLabel = `${prefix}${column}`;
|
|
4585
4637
|
const value = watch(colLabel);
|
|
4586
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4638
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4587
4639
|
gridRow, children: [jsx(Text, { children: value
|
|
4588
4640
|
? translate.t(removeIndex(`${colLabel}.true`))
|
|
4589
|
-
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4641
|
+
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4590
4642
|
};
|
|
4591
4643
|
|
|
4592
4644
|
const DateViewer = ({ column, schema, prefix }) => {
|
|
@@ -4596,8 +4648,8 @@ const DateViewer = ({ column, schema, prefix }) => {
|
|
|
4596
4648
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4597
4649
|
const colLabel = `${prefix}${column}`;
|
|
4598
4650
|
const selectedDate = watch(colLabel);
|
|
4599
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4600
|
-
gridRow, children: [jsxs(Text, { children: [" ", selectedDate !== undefined ? selectedDate : ""] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4651
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4652
|
+
gridRow, children: [jsxs(Text, { children: [" ", selectedDate !== undefined ? selectedDate : ""] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4601
4653
|
};
|
|
4602
4654
|
|
|
4603
4655
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
@@ -4609,7 +4661,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4609
4661
|
const colLabel = `${prefix}${column}`;
|
|
4610
4662
|
const watchEnum = watch(colLabel);
|
|
4611
4663
|
const watchEnums = (watch(colLabel) ?? []);
|
|
4612
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4664
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4613
4665
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
4614
4666
|
const item = enumValue;
|
|
4615
4667
|
if (item === undefined) {
|
|
@@ -4618,7 +4670,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4618
4670
|
return (jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4619
4671
|
? renderDisplay(item)
|
|
4620
4672
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
4621
|
-
}) })), !isMultiple && (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4673
|
+
}) })), !isMultiple && (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4622
4674
|
};
|
|
4623
4675
|
|
|
4624
4676
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
@@ -4628,7 +4680,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4628
4680
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4629
4681
|
const currentFiles = (watch(column) ?? []);
|
|
4630
4682
|
const colLabel = `${prefix}${column}`;
|
|
4631
|
-
return (jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4683
|
+
return (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: [jsx(FileDropzone, { onDrop: ({ files }) => {
|
|
4632
4684
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4633
4685
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4634
4686
|
}, placeholder: translate.t(`${colLabel}.fileDropzone`) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4637,7 +4689,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4637
4689
|
return name !== file.name;
|
|
4638
4690
|
}));
|
|
4639
4691
|
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [jsx(Box, { children: file.name }), jsx(TiDeleteOutline, {})] }) }, file.name));
|
|
4640
|
-
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4692
|
+
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4641
4693
|
};
|
|
4642
4694
|
|
|
4643
4695
|
const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
@@ -4659,7 +4711,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4659
4711
|
}
|
|
4660
4712
|
return record[display_column];
|
|
4661
4713
|
};
|
|
4662
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4714
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4663
4715
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchIds.map((id) => {
|
|
4664
4716
|
const item = idMap[id];
|
|
4665
4717
|
if (item === undefined) {
|
|
@@ -4668,7 +4720,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4668
4720
|
return (jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4669
4721
|
? renderDisplay(item)
|
|
4670
4722
|
: item[display_column] }, id));
|
|
4671
|
-
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4723
|
+
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4672
4724
|
};
|
|
4673
4725
|
|
|
4674
4726
|
const NumberViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4678,7 +4730,7 @@ const NumberViewer = ({ schema, column, prefix, }) => {
|
|
|
4678
4730
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4679
4731
|
const colLabel = `${prefix}${column}`;
|
|
4680
4732
|
const value = watch(colLabel);
|
|
4681
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4733
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn, gridRow, children: [jsx(Text, { children: value }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4682
4734
|
};
|
|
4683
4735
|
|
|
4684
4736
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
@@ -4690,13 +4742,13 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
4690
4742
|
if (properties === undefined) {
|
|
4691
4743
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4692
4744
|
}
|
|
4693
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4745
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] }), jsx(Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat("auto-fit", auto)`, children: Object.keys(properties ?? {}).map((key) => {
|
|
4694
4746
|
return (
|
|
4695
4747
|
// @ts-expect-error find suitable types
|
|
4696
4748
|
jsx(ColumnViewer, { column: `${key}`,
|
|
4697
4749
|
prefix: `${prefix}${column}.`,
|
|
4698
4750
|
properties }, `form-objectviewer-${colLabel}-${key}`));
|
|
4699
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4751
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4700
4752
|
};
|
|
4701
4753
|
|
|
4702
4754
|
const RecordInput = ({ column, schema, prefix }) => {
|
|
@@ -4708,7 +4760,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4708
4760
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4709
4761
|
const [newKey, setNewKey] = useState();
|
|
4710
4762
|
const [newValue, setNewValue] = useState();
|
|
4711
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
4763
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4712
4764
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4713
4765
|
const filtered = entries.filter(([target]) => {
|
|
4714
4766
|
return target !== key;
|
|
@@ -4748,7 +4800,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4748
4800
|
setShowNewEntries(true);
|
|
4749
4801
|
setNewKey(undefined);
|
|
4750
4802
|
setNewValue(undefined);
|
|
4751
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4803
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4752
4804
|
};
|
|
4753
4805
|
|
|
4754
4806
|
const TagViewer = ({ column, schema, prefix }) => {
|
|
@@ -4843,7 +4895,7 @@ const StringViewer = ({ column, schema, prefix, }) => {
|
|
|
4843
4895
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4844
4896
|
const colLabel = `${prefix}${column}`;
|
|
4845
4897
|
const value = watch(colLabel);
|
|
4846
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4898
|
+
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", children: [jsx(Text, { children: value }), errors[colLabel] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4847
4899
|
};
|
|
4848
4900
|
|
|
4849
4901
|
const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
@@ -4907,30 +4959,23 @@ const ColumnViewer = ({ column, properties, prefix, }) => {
|
|
|
4907
4959
|
return jsx(SchemaViewer, { schema: colSchema, prefix, column });
|
|
4908
4960
|
};
|
|
4909
4961
|
|
|
4910
|
-
const
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
const
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
4923
|
-
}
|
|
4962
|
+
const SubmitButton = () => {
|
|
4963
|
+
const { translate, setValidatedData, setIsError, setIsConfirming } = useSchemaContext();
|
|
4964
|
+
const methods = 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 (jsx(Button$1, { onClick: () => {
|
|
4972
|
+
methods.handleSubmit(onValid)();
|
|
4973
|
+
}, formNoValidate: true, children: translate.t("submit") }));
|
|
4924
4974
|
};
|
|
4925
|
-
|
|
4926
|
-
|
|
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();
|
|
4927
4978
|
const methods = useFormContext();
|
|
4928
|
-
const [isSuccess, setIsSuccess] = useState(false);
|
|
4929
|
-
const [isError, setIsError] = useState(false);
|
|
4930
|
-
const [isSubmiting, setIsSubmiting] = useState(false);
|
|
4931
|
-
const [isConfirming, setIsConfirming] = useState(false);
|
|
4932
|
-
const [validatedData, setValidatedData] = useState();
|
|
4933
|
-
const [error, setError] = useState();
|
|
4934
4979
|
const { properties } = schema;
|
|
4935
4980
|
const onBeforeSubmit = () => {
|
|
4936
4981
|
setIsSubmiting(true);
|
|
@@ -4938,8 +4983,9 @@ const FormInternal = () => {
|
|
|
4938
4983
|
const onAfterSubmit = () => {
|
|
4939
4984
|
setIsSubmiting(false);
|
|
4940
4985
|
};
|
|
4941
|
-
const onSubmitError = () => {
|
|
4986
|
+
const onSubmitError = (error) => {
|
|
4942
4987
|
setIsError(true);
|
|
4988
|
+
setError(error);
|
|
4943
4989
|
};
|
|
4944
4990
|
const onSubmitSuccess = () => {
|
|
4945
4991
|
setIsSuccess(true);
|
|
@@ -4951,9 +4997,7 @@ const FormInternal = () => {
|
|
|
4951
4997
|
onSubmitSuccess();
|
|
4952
4998
|
}
|
|
4953
4999
|
catch (error) {
|
|
4954
|
-
|
|
4955
|
-
setError(error);
|
|
4956
|
-
onSubmitError();
|
|
5000
|
+
onSubmitError(error);
|
|
4957
5001
|
}
|
|
4958
5002
|
finally {
|
|
4959
5003
|
onAfterSubmit();
|
|
@@ -4976,12 +5020,6 @@ const FormInternal = () => {
|
|
|
4976
5020
|
}
|
|
4977
5021
|
await defaultOnSubmit(onSubmit(data));
|
|
4978
5022
|
};
|
|
4979
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4980
|
-
const onValid = (data) => {
|
|
4981
|
-
setValidatedData(data);
|
|
4982
|
-
setIsError(false);
|
|
4983
|
-
setIsConfirming(true);
|
|
4984
|
-
};
|
|
4985
5023
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
4986
5024
|
const included = include.length > 0 ? include : keys;
|
|
4987
5025
|
const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
|
|
@@ -4996,58 +5034,47 @@ const FormInternal = () => {
|
|
|
4996
5034
|
include,
|
|
4997
5035
|
});
|
|
4998
5036
|
if (isSuccess) {
|
|
4999
|
-
return (jsxs(
|
|
5037
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsxs(Alert.Root, { status: "success", children: [jsx(Alert.Indicator, {}), jsx(Alert.Title, { children: translate.t("submit_success") })] }), jsx(Flex, { justifyContent: "end", children: jsx(Button$1, { onClick: async () => {
|
|
5000
5038
|
setIsError(false);
|
|
5001
5039
|
setIsSubmiting(false);
|
|
5002
5040
|
setIsSuccess(false);
|
|
5003
5041
|
setIsConfirming(false);
|
|
5004
5042
|
setValidatedData(undefined);
|
|
5005
|
-
|
|
5006
|
-
|
|
5043
|
+
const data = await getUpdatedData();
|
|
5044
|
+
methods.reset(data);
|
|
5045
|
+
}, formNoValidate: true, children: translate.t("submit_again") }) })] }));
|
|
5007
5046
|
}
|
|
5008
5047
|
if (isConfirming) {
|
|
5009
|
-
return (jsxs(
|
|
5048
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: 4, gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat(${rowNumber ?? "auto-fit"}, auto)`, children: ordered.map((column) => {
|
|
5010
5049
|
return (jsx(ColumnViewer
|
|
5011
5050
|
// @ts-expect-error find suitable types
|
|
5012
5051
|
, {
|
|
5013
5052
|
// @ts-expect-error find suitable types
|
|
5014
5053
|
properties: properties, prefix: ``, column }, `form-viewer-${column}`));
|
|
5015
|
-
}) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button, { onClick: () => {
|
|
5054
|
+
}) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button$1, { onClick: () => {
|
|
5016
5055
|
setIsConfirming(false);
|
|
5017
|
-
}, variant: "subtle", children: translate.t("cancel") }), jsx(Button, { onClick: () => {
|
|
5056
|
+
}, variant: "subtle", children: translate.t("cancel") }), jsx(Button$1, { onClick: () => {
|
|
5018
5057
|
onFormSubmit(validatedData);
|
|
5019
|
-
}, children: translate.t("confirm") })] }), isSubmiting && (jsx(Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsx(Center, { h: "full", children: jsx(Spinner, { color: "teal.500" }) }) })), isError && (jsx(Fragment, { children: jsx(Alert.Root, { status: "error", children: jsx(Alert.Title, { children: jsx(AccordionRoot, { collapsible: true, defaultValue: [
|
|
5058
|
+
}, children: translate.t("confirm") })] }), isSubmiting && (jsx(Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsx(Center, { h: "full", children: jsx(Spinner, { color: "teal.500" }) }) })), isError && (jsx(Fragment, { children: jsx(Alert.Root, { status: "error", children: jsx(Alert.Title, { children: jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "b", children: [jsxs(AccordionItemTrigger, { children: [jsx(Alert.Indicator, {}), `${error}`] }), jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) }) }))] }));
|
|
5020
5059
|
}
|
|
5021
|
-
return (
|
|
5022
|
-
|
|
5060
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: `repeat(${rowNumber ?? "auto-fit"}, auto)`, children: ordered.map((column) => {
|
|
5061
|
+
return (jsx(ColumnRenderer
|
|
5062
|
+
// @ts-expect-error find suitable types
|
|
5063
|
+
, {
|
|
5023
5064
|
// @ts-expect-error find suitable types
|
|
5024
|
-
, {
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
methods.reset();
|
|
5029
|
-
}, variant: "subtle", children: translate.t("reset") }), jsx(Button, { onClick: () => {
|
|
5030
|
-
methods.handleSubmit(onValid)();
|
|
5031
|
-
}, formNoValidate: true, children: translate.t("submit") })] })] }) }));
|
|
5065
|
+
properties: properties, prefix: ``, column }, `form-input-${column}`));
|
|
5066
|
+
}) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button$1, { onClick: () => {
|
|
5067
|
+
methods.reset();
|
|
5068
|
+
}, variant: "subtle", children: translate.t("reset") }), jsx(SubmitButton, {})] })] }));
|
|
5032
5069
|
};
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
ignore,
|
|
5042
|
-
include,
|
|
5043
|
-
// @ts-expect-error TODO: find appropriate types
|
|
5044
|
-
onSubmit,
|
|
5045
|
-
rowNumber,
|
|
5046
|
-
idMap,
|
|
5047
|
-
setIdMap,
|
|
5048
|
-
translate,
|
|
5049
|
-
requestOptions,
|
|
5050
|
-
}, children: jsx(FormProvider, { ...form, children: jsx(FormInternal, {}) }) }));
|
|
5070
|
+
|
|
5071
|
+
const FormTitle = () => {
|
|
5072
|
+
const { translate } = useSchemaContext();
|
|
5073
|
+
return jsx(Heading, { children: translate.t("title") });
|
|
5074
|
+
};
|
|
5075
|
+
|
|
5076
|
+
const DefaultForm = ({ formConfig, showTitle = true, }) => {
|
|
5077
|
+
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [showTitle && jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
5051
5078
|
};
|
|
5052
5079
|
|
|
5053
5080
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5080,4 +5107,4 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
|
|
|
5080
5107
|
}
|
|
5081
5108
|
};
|
|
5082
5109
|
|
|
5083
|
-
export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultTable, DensityToggleButton,
|
|
5110
|
+
export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultForm, DefaultTable, DensityToggleButton, EditSortingButton, EmptyState$1 as EmptyState, ErrorAlert, FilterDialog, FilterOptions, FormBody, FormRoot, FormTitle, GlobalFilter, PageSizeControl, Pagination, RecordDisplay, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableDataDisplay, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableSelector, TableSorter, TableViewer, TextCell, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
|