@bsol-oss/react-datatable5 12.0.0-beta.2 → 12.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +89 -88
- package/dist/index.js +542 -533
- package/dist/index.mjs +539 -532
- package/dist/types/components/DataTable/DataTable.d.ts +1 -1
- package/dist/types/components/DataTable/DataTableServer.d.ts +1 -1
- package/dist/types/components/DataTable/DefaultTable.d.ts +9 -12
- package/dist/types/components/DataTable/components/TextCell.d.ts +10 -0
- package/dist/types/components/DataTable/context/DataTableContext.d.ts +2 -1
- package/dist/types/components/DataTable/controls/DensityFeature.d.ts +23 -0
- package/dist/types/components/DataTable/controls/DensityToggleButton.d.ts +6 -0
- package/dist/types/components/DataTable/controls/EditSortingButton.d.ts +7 -0
- package/dist/types/components/DataTable/controls/FilterDialog.d.ts +5 -0
- package/dist/types/components/DataTable/controls/PageSizeControl.d.ts +4 -0
- package/dist/types/components/DataTable/controls/Pagination.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ReloadButton.d.ts +5 -0
- package/dist/types/components/DataTable/controls/ResetFilteringButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/ResetSelectionButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/ResetSortingButton.d.ts +4 -0
- package/dist/types/components/DataTable/controls/RowCountText.d.ts +1 -0
- package/dist/types/components/DataTable/controls/SelectAllRowsToggle.d.ts +8 -0
- package/dist/types/components/DataTable/controls/TableControls.d.ts +23 -0
- package/dist/types/components/DataTable/controls/TableFilterTags.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableFilters.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableSelector.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableSorter.d.ts +1 -0
- package/dist/types/components/DataTable/controls/TableViewer.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ViewDialog.d.ts +5 -0
- package/dist/types/components/DataTable/display/CardHeader.d.ts +13 -0
- package/dist/types/components/DataTable/display/DataDisplay.d.ts +6 -0
- package/dist/types/components/DataTable/display/EmptyState.d.ts +5 -0
- package/dist/types/components/DataTable/display/ErrorAlert.d.ts +4 -0
- package/dist/types/components/DataTable/display/RecordDisplay.d.ts +9 -0
- package/dist/types/components/DataTable/display/Table.d.ts +10 -0
- package/dist/types/components/DataTable/display/TableBody.d.ts +21 -0
- package/dist/types/components/DataTable/display/TableCardContainer.d.ts +7 -0
- package/dist/types/components/DataTable/display/TableCards.d.ts +11 -0
- package/dist/types/components/DataTable/display/TableComponent.d.ts +6 -0
- package/dist/types/components/DataTable/display/TableDataDisplay.d.ts +6 -0
- package/dist/types/components/DataTable/display/TableFooter.d.ts +5 -0
- package/dist/types/components/DataTable/display/TableHeader.d.ts +9 -0
- package/dist/types/components/DataTable/display/TableLoadingComponent.d.ts +5 -0
- package/dist/types/components/DataTable/display/TextCell.d.ts +10 -0
- package/dist/types/components/DataTable/useDataTable.d.ts +1 -1
- package/dist/types/components/Form/SchemaFormContext.d.ts +13 -0
- package/dist/types/components/Form/components/core/DefaultForm.d.ts +7 -0
- package/dist/types/components/Form/components/core/FormBody.d.ts +1 -0
- package/dist/types/components/Form/components/core/FormRoot.d.ts +39 -0
- package/dist/types/components/Form/components/core/FormTitle.d.ts +1 -0
- package/dist/types/components/Form/components/core/SubmitButton.d.ts +1 -0
- package/dist/types/index.d.ts +37 -35
- package/package.json +2 -2
package/dist/index.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: "colorPalette.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) => {
|
|
@@ -2601,7 +2569,7 @@ const RecordDisplay = ({ object, boxProps, translate, prefix = "", }) => {
|
|
|
2601
2569
|
return jsx(Fragment, { children: "null" });
|
|
2602
2570
|
}
|
|
2603
2571
|
return (jsx(Grid, { rowGap: 1, padding: 1, overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
2604
|
-
return (jsxs(Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsx(Text, { color: "
|
|
2572
|
+
return (jsxs(Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsx(Text, { color: "colorPalette.400", children: getColumn({ field }) }), typeof value === "object" ? (jsx(RecordDisplay, { object: value, prefix: `${prefix}${field}.`, translate: translate })) : (jsx(Text, { children: JSON.stringify(value) }))] }, field));
|
|
2605
2573
|
}) }));
|
|
2606
2574
|
};
|
|
2607
2575
|
|
|
@@ -2651,7 +2619,7 @@ const CellRenderer = ({ cell }) => {
|
|
|
2651
2619
|
paddingY: 2,
|
|
2652
2620
|
}, object: value })] }, cell.id));
|
|
2653
2621
|
}
|
|
2654
|
-
return (jsxs(Box, { gridColumn, gridRow, children: [jsx(Box, { color:
|
|
2622
|
+
return (jsxs(Box, { gridColumn, gridRow, children: [jsx(Box, { color: "colorPalette.400", children: getLabel({ columnId: cell.column.id }) }), jsx(Box, { wordBreak: "break-word", textOverflow: "ellipsis", overflow: "hidden", children: `${formatValue(cell.getValue())}` })] }, cell.id));
|
|
2655
2623
|
};
|
|
2656
2624
|
const DataDisplay = ({ variant = "" }) => {
|
|
2657
2625
|
const { table, translate } = useDataTableContext();
|
|
@@ -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();
|
|
@@ -3067,16 +2975,89 @@ const TableFilterTags = () => {
|
|
|
3067
2975
|
}) }));
|
|
3068
2976
|
};
|
|
3069
2977
|
|
|
3070
|
-
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, }) => {
|
|
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, gridProps = {}, }) => {
|
|
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", ...gridProps, 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
|
-
}) })), showFilterTags && (jsx(Flex, { children: jsx(TableFilterTags, {}) }))] }), jsx(Grid, { overflow: "auto",
|
|
3075
|
-
|
|
3076
|
-
|
|
2982
|
+
}) })), showFilterTags && (jsx(Flex, { children: jsx(TableFilterTags, {}) }))] }), jsx(Grid, { overflow: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, 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, {}) })] }))] }));
|
|
2983
|
+
};
|
|
2984
|
+
|
|
2985
|
+
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
2986
|
+
const { title, description, icon, children, ...rest } = props;
|
|
2987
|
+
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] }) }));
|
|
2988
|
+
});
|
|
2989
|
+
|
|
2990
|
+
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" })] }) }));
|
|
2991
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
2992
|
+
const { table } = useDataTableContext();
|
|
2993
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
2994
|
+
return emptyComponent;
|
|
2995
|
+
}
|
|
2996
|
+
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...props, children: children }));
|
|
2997
|
+
};
|
|
2998
|
+
|
|
2999
|
+
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
3000
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3001
|
+
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 }))] }));
|
|
3002
|
+
});
|
|
3003
|
+
|
|
3004
|
+
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
3005
|
+
"use no memo";
|
|
3006
|
+
const { table } = useDataTableContext();
|
|
3007
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3008
|
+
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
3009
|
+
const handleRowHover = (index) => {
|
|
3010
|
+
setHoveredRow(index);
|
|
3011
|
+
};
|
|
3012
|
+
const getTdProps = (cell) => {
|
|
3013
|
+
const tdProps = cell.column.getIsPinned()
|
|
3014
|
+
? {
|
|
3015
|
+
left: showSelector
|
|
3016
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3017
|
+
: `${cell.column.getStart("left")}px`,
|
|
3018
|
+
position: "relative",
|
|
3019
|
+
}
|
|
3020
|
+
: {};
|
|
3021
|
+
return tdProps;
|
|
3022
|
+
};
|
|
3023
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3024
|
+
if (hoveredRow === -1) {
|
|
3025
|
+
return {};
|
|
3026
|
+
}
|
|
3027
|
+
if (hoveredRow === index) {
|
|
3028
|
+
return {
|
|
3029
|
+
opacity: "1",
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
return {
|
|
3033
|
+
opacity: "0.8",
|
|
3034
|
+
};
|
|
3035
|
+
};
|
|
3036
|
+
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3037
|
+
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) => {
|
|
3038
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3039
|
+
// styling resize and pinning start
|
|
3040
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3041
|
+
base: "colorPalette.900",
|
|
3042
|
+
_dark: "colorPalette.100",
|
|
3043
|
+
},
|
|
3044
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3045
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3046
|
+
}) }));
|
|
3047
|
+
};
|
|
3048
|
+
const TableRowSelector = ({ index, row, }) => {
|
|
3049
|
+
const { table } = useDataTableContext();
|
|
3050
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3051
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3052
|
+
base: "colorPalette.900",
|
|
3053
|
+
_dark: "colorPalette.100",
|
|
3054
|
+
},
|
|
3055
|
+
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(),
|
|
3056
|
+
disabled: !row.getCanSelect(),
|
|
3057
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3077
3058
|
};
|
|
3078
3059
|
|
|
3079
|
-
const TableFooter = ({
|
|
3060
|
+
const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
3080
3061
|
const table = useDataTableContext().table;
|
|
3081
3062
|
const SELECTION_BOX_WIDTH = 20;
|
|
3082
3063
|
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
@@ -3095,78 +3076,28 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3095
3076
|
}
|
|
3096
3077
|
return false;
|
|
3097
3078
|
};
|
|
3098
|
-
|
|
3099
|
-
const thProps = header.column.getIsPinned()
|
|
3100
|
-
? {
|
|
3101
|
-
left: showSelector
|
|
3102
|
-
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3103
|
-
: `${header.getStart("left") + table.getDensityValue() * 2}px`,
|
|
3104
|
-
background: pinnedBgColor.light,
|
|
3105
|
-
position: "sticky",
|
|
3106
|
-
zIndex: 1,
|
|
3107
|
-
_dark: {
|
|
3108
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3109
|
-
},
|
|
3110
|
-
}
|
|
3111
|
-
: {};
|
|
3112
|
-
return thProps;
|
|
3113
|
-
};
|
|
3114
|
-
return (jsx(Table$1.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxs(Table$1.Row, { display: "flex", children: [showSelector && (jsxs(Table$1.Header
|
|
3115
|
-
// styling resize and pinning start
|
|
3116
|
-
, {
|
|
3117
|
-
// styling resize and pinning start
|
|
3118
|
-
padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
3119
|
-
? {
|
|
3120
|
-
left: `0px`,
|
|
3121
|
-
backgroundColor: pinnedBgColor.light,
|
|
3122
|
-
position: "sticky",
|
|
3123
|
-
zIndex: 1,
|
|
3124
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3125
|
-
}
|
|
3126
|
-
: {}),
|
|
3127
|
-
// styling resize and pinning end
|
|
3128
|
-
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(),
|
|
3079
|
+
return (jsx(Table$1.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxs(Table$1.Row, { display: "flex", children: [showSelector && (jsxs(Table$1.Header, { 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(),
|
|
3129
3080
|
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3130
3081
|
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` }))] })), footerGroup.headers.map((header) => (jsx(Table$1.Cell, { padding: "0", columnSpan: `${header.colSpan}`,
|
|
3131
3082
|
// styling resize and pinning start
|
|
3132
|
-
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid",
|
|
3083
|
+
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", children: jsx(MenuRoot$1, { children: jsx(MenuTrigger$1, { asChild: true, children: jsx(Box, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3133
3084
|
? null
|
|
3134
3085
|
: flexRender(header.column.columnDef.footer, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && (
|
|
3135
3086
|
// <UpDownIcon />
|
|
3136
3087
|
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
3088
|
};
|
|
3138
3089
|
|
|
3139
|
-
const TableHeader = ({ canResize = true,
|
|
3090
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3140
3091
|
const { table } = useDataTableContext();
|
|
3141
3092
|
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
3093
|
const getThProps = (header) => {
|
|
3159
3094
|
const thProps = header.column.getIsPinned()
|
|
3160
3095
|
? {
|
|
3161
3096
|
left: showSelector
|
|
3162
3097
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3163
3098
|
: `${header.getStart("left")}px`,
|
|
3164
|
-
background: pinnedBgColor.light,
|
|
3165
3099
|
position: "sticky",
|
|
3166
3100
|
zIndex: 100 + 1,
|
|
3167
|
-
_dark: {
|
|
3168
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3169
|
-
},
|
|
3170
3101
|
}
|
|
3171
3102
|
: {};
|
|
3172
3103
|
return thProps;
|
|
@@ -3175,21 +3106,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3175
3106
|
position: "sticky",
|
|
3176
3107
|
top: 0,
|
|
3177
3108
|
};
|
|
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) => {
|
|
3109
|
+
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), bgColor: "transparent", ...tableHeaderProps, children: table.getHeaderGroups().map((headerGroup) => (jsxs(Table$1.Row, { display: "flex", bgColor: "transparent", ...tableRowProps, children: [showSelector && (jsx(Table$1.ColumnHeader, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3110
|
+
base: "colorPalette.900",
|
|
3111
|
+
_dark: "colorPalette.100",
|
|
3112
|
+
},
|
|
3113
|
+
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(),
|
|
3114
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3115
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3193
3116
|
const resizeProps = {
|
|
3194
3117
|
onMouseDown: header.getResizeHandler(),
|
|
3195
3118
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3197,10 +3120,24 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3197
3120
|
};
|
|
3198
3121
|
return (jsxs(Table$1.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3199
3122
|
// styling resize and pinning start
|
|
3200
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3123
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3124
|
+
base: "colorPalette.800",
|
|
3125
|
+
_dark: "colorPalette.200",
|
|
3126
|
+
},
|
|
3127
|
+
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", color: {
|
|
3128
|
+
base: "colorPalette.800",
|
|
3129
|
+
_dark: "colorPalette.200",
|
|
3130
|
+
_hover: {
|
|
3131
|
+
base: "colorPalette.700",
|
|
3132
|
+
_dark: "colorPalette.300",
|
|
3133
|
+
},
|
|
3134
|
+
},
|
|
3135
|
+
bg: {
|
|
3136
|
+
base: "colorPalette.100",
|
|
3137
|
+
_dark: "colorPalette.900",
|
|
3138
|
+
_hover: {
|
|
3139
|
+
base: "colorPalette.200",
|
|
3140
|
+
_dark: "colorPalette.800",
|
|
3204
3141
|
},
|
|
3205
3142
|
}, children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3206
3143
|
? null
|
|
@@ -3228,29 +3165,17 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3228
3165
|
});
|
|
3229
3166
|
}, children: [jsx(GrDescend, {}), "Sort Descending"] }) }), header.column.getIsSorted() && (jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3230
3167
|
header.column.clearSorting();
|
|
3231
|
-
}, children: [jsx(MdClear, {}), "Clear Sorting"] }) }))] }))] })] }), canResize && (jsx(Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3168
|
+
}, children: [jsx(MdClear, {}), "Clear Sorting"] }) }))] }))] })] }), canResize && (jsx(Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3169
|
+
? "colorPalette.700"
|
|
3170
|
+
: "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
|
|
3232
3171
|
borderRightColor: header.column.getIsResizing()
|
|
3233
|
-
? "
|
|
3234
|
-
: "
|
|
3172
|
+
? "colorPalette.700"
|
|
3173
|
+
: "colorPalette.400",
|
|
3235
3174
|
}, ...resizeProps }))] }, `chakra-table-header-${header.id}`));
|
|
3236
3175
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3237
3176
|
};
|
|
3238
3177
|
|
|
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 = "", }) => {
|
|
3178
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3254
3179
|
if (variant === "greedy") {
|
|
3255
3180
|
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
3181
|
}
|
|
@@ -3510,16 +3435,82 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3510
3435
|
return columns;
|
|
3511
3436
|
};
|
|
3512
3437
|
|
|
3513
|
-
const
|
|
3514
|
-
const {
|
|
3515
|
-
|
|
3438
|
+
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3439
|
+
const { table, columns, translate, data } = useDataTableContext();
|
|
3440
|
+
const columnDef = table._getColumnDefs();
|
|
3441
|
+
console.log(columnDef, "glp");
|
|
3442
|
+
console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
|
|
3443
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3444
|
+
const { accessorKey, id } = def;
|
|
3445
|
+
if (accessorKey) {
|
|
3446
|
+
return [accessorKey, def];
|
|
3447
|
+
}
|
|
3448
|
+
return [id, def];
|
|
3449
|
+
}));
|
|
3450
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3451
|
+
const totalWidths = columns
|
|
3452
|
+
.map(({ size }) => {
|
|
3453
|
+
if (!!size === false) {
|
|
3454
|
+
return 0;
|
|
3455
|
+
}
|
|
3456
|
+
if (typeof size === "number") {
|
|
3457
|
+
return size;
|
|
3458
|
+
}
|
|
3459
|
+
return 0;
|
|
3460
|
+
})
|
|
3461
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3462
|
+
const columnWidths = columns
|
|
3463
|
+
.map(({ size }) => {
|
|
3464
|
+
if (!!size === false) {
|
|
3465
|
+
return "1fr";
|
|
3466
|
+
}
|
|
3467
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3468
|
+
})
|
|
3469
|
+
.join(" ");
|
|
3470
|
+
console.log({ columnWidths }, "hadfg");
|
|
3471
|
+
const cellProps = {
|
|
3472
|
+
flex: "1 0 0%",
|
|
3473
|
+
overflow: "auto",
|
|
3474
|
+
paddingX: "2",
|
|
3475
|
+
py: "1",
|
|
3476
|
+
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
3477
|
+
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
3478
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3479
|
+
borderBottomWidth: "1px",
|
|
3480
|
+
...{ colorPalette },
|
|
3481
|
+
};
|
|
3482
|
+
if (data.length <= 0) {
|
|
3483
|
+
return jsx(Fragment, { children: emptyComponent });
|
|
3484
|
+
}
|
|
3485
|
+
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) => {
|
|
3486
|
+
return (jsx(Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3487
|
+
}) }), data.map((record) => {
|
|
3488
|
+
return (jsx(Fragment, { children: columnHeaders.map((header) => {
|
|
3489
|
+
const { cell } = columnsMap[header];
|
|
3490
|
+
const value = record[header];
|
|
3491
|
+
if (!!record === false) {
|
|
3492
|
+
return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3493
|
+
}
|
|
3494
|
+
if (cell) {
|
|
3495
|
+
return (jsx(Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3496
|
+
}
|
|
3497
|
+
if (typeof value === "object") {
|
|
3498
|
+
return (jsx(Box, { ...cellProps, children: jsx(RecordDisplay, { object: value }) }));
|
|
3499
|
+
}
|
|
3500
|
+
return jsx(Box, { ...cellProps, children: value });
|
|
3501
|
+
}) }));
|
|
3502
|
+
})] }));
|
|
3516
3503
|
};
|
|
3517
3504
|
|
|
3518
|
-
const
|
|
3519
|
-
const {
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3505
|
+
const AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3506
|
+
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3507
|
+
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, {}) }))] }));
|
|
3508
|
+
});
|
|
3509
|
+
const AccordionItemContent = React.forwardRef(function AccordionItemContent(props, ref) {
|
|
3510
|
+
return (jsx(Accordion.ItemContent, { children: jsx(Accordion.ItemBody, { ...props, ref: ref }) }));
|
|
3511
|
+
});
|
|
3512
|
+
const AccordionRoot = Accordion.Root;
|
|
3513
|
+
const AccordionItem = Accordion.Item;
|
|
3523
3514
|
|
|
3524
3515
|
//@ts-expect-error TODO: find appropriate type
|
|
3525
3516
|
const SchemaFormContext = createContext({
|
|
@@ -3542,15 +3533,56 @@ const clearEmptyString = (object) => {
|
|
|
3542
3533
|
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== ""));
|
|
3543
3534
|
};
|
|
3544
3535
|
|
|
3545
|
-
const
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
}
|
|
3549
|
-
const
|
|
3550
|
-
|
|
3551
|
-
});
|
|
3552
|
-
|
|
3553
|
-
|
|
3536
|
+
const idPickerSanityCheck = (column, foreign_key) => {
|
|
3537
|
+
if (!!foreign_key == false) {
|
|
3538
|
+
throw new Error(`The key foreign_key does not exist in properties of column ${column} when using id-picker.`);
|
|
3539
|
+
}
|
|
3540
|
+
const { table, column: foreignKeyColumn, display_column } = foreign_key;
|
|
3541
|
+
if (!!table == false) {
|
|
3542
|
+
throw new Error(`The key table does not exist in properties of column ${table} when using id-picker.`);
|
|
3543
|
+
}
|
|
3544
|
+
if (!!display_column == false) {
|
|
3545
|
+
throw new Error(`The key display_column does not exist in properties of column ${column} when using id-picker.`);
|
|
3546
|
+
}
|
|
3547
|
+
if (!!foreignKeyColumn == false) {
|
|
3548
|
+
throw new Error(`The key column does not exist in properties of column ${column} when using id-picker.`);
|
|
3549
|
+
}
|
|
3550
|
+
};
|
|
3551
|
+
const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, children, order = [], ignore = [], include = [], onSubmit = undefined, rowNumber = undefined, requestOptions = {}, getUpdatedData = () => { }, }) => {
|
|
3552
|
+
const [isSuccess, setIsSuccess] = useState(false);
|
|
3553
|
+
const [isError, setIsError] = useState(false);
|
|
3554
|
+
const [isSubmiting, setIsSubmiting] = useState(false);
|
|
3555
|
+
const [isConfirming, setIsConfirming] = useState(false);
|
|
3556
|
+
const [validatedData, setValidatedData] = useState();
|
|
3557
|
+
const [error, setError] = useState();
|
|
3558
|
+
return (jsx(SchemaFormContext.Provider, { value: {
|
|
3559
|
+
schema,
|
|
3560
|
+
serverUrl,
|
|
3561
|
+
order,
|
|
3562
|
+
ignore,
|
|
3563
|
+
include,
|
|
3564
|
+
// @ts-expect-error TODO: find appropriate types
|
|
3565
|
+
onSubmit,
|
|
3566
|
+
rowNumber,
|
|
3567
|
+
idMap,
|
|
3568
|
+
setIdMap,
|
|
3569
|
+
translate,
|
|
3570
|
+
requestOptions,
|
|
3571
|
+
isSuccess,
|
|
3572
|
+
setIsSuccess,
|
|
3573
|
+
isError,
|
|
3574
|
+
setIsError,
|
|
3575
|
+
isSubmiting,
|
|
3576
|
+
setIsSubmiting,
|
|
3577
|
+
isConfirming,
|
|
3578
|
+
setIsConfirming,
|
|
3579
|
+
validatedData,
|
|
3580
|
+
setValidatedData,
|
|
3581
|
+
error,
|
|
3582
|
+
setError,
|
|
3583
|
+
getUpdatedData,
|
|
3584
|
+
}, children: jsx(FormProvider, { ...form, children: children }) }));
|
|
3585
|
+
};
|
|
3554
3586
|
|
|
3555
3587
|
function removeIndex(str) {
|
|
3556
3588
|
return str.replace(/\.\d+\./g, '.');
|
|
@@ -3565,7 +3597,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3565
3597
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3566
3598
|
const { formState: { errors }, setValue, watch, } = useFormContext();
|
|
3567
3599
|
const fields = (watch(colLabel) ?? []);
|
|
3568
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
3600
|
+
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
3601
|
prefix: `${colLabel}.`,
|
|
3570
3602
|
schema: items }) }), jsx(Flex, { justifyContent: "end", children: jsx(Button$1, { variant: "ghost", onClick: () => {
|
|
3571
3603
|
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
@@ -3585,7 +3617,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3585
3617
|
return;
|
|
3586
3618
|
}
|
|
3587
3619
|
setValue(colLabel, [...fields, {}]);
|
|
3588
|
-
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3620
|
+
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3589
3621
|
};
|
|
3590
3622
|
|
|
3591
3623
|
const Field = React.forwardRef(function Field(props, ref) {
|
|
@@ -3600,10 +3632,10 @@ const BooleanPicker = ({ schema, column, prefix }) => {
|
|
|
3600
3632
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3601
3633
|
const colLabel = `${prefix}${column}`;
|
|
3602
3634
|
const value = watch(colLabel);
|
|
3603
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
3635
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3604
3636
|
gridRow, children: [jsx(CheckboxCard, { checked: value, variant: "surface", onChange: () => {
|
|
3605
3637
|
setValue(colLabel, !value);
|
|
3606
|
-
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3638
|
+
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3607
3639
|
};
|
|
3608
3640
|
|
|
3609
3641
|
const monthNamesShort = [
|
|
@@ -3701,10 +3733,11 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3701
3733
|
const colLabel = `${prefix}${column}`;
|
|
3702
3734
|
const [open, setOpen] = useState(false);
|
|
3703
3735
|
const selectedDate = watch(colLabel);
|
|
3704
|
-
|
|
3736
|
+
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3737
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3705
3738
|
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
3739
|
setOpen(true);
|
|
3707
|
-
}, children: selectedDate !== undefined ?
|
|
3740
|
+
}, children: selectedDate !== undefined ? `${formatedDate}` : "" }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
|
|
3708
3741
|
// @ts-expect-error TODO: find appropriate types
|
|
3709
3742
|
, {
|
|
3710
3743
|
// @ts-expect-error TODO: find appropriate types
|
|
@@ -3713,7 +3746,7 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3713
3746
|
onDateSelected: ({ date }) => {
|
|
3714
3747
|
setValue(colLabel, dayjs(date).format("YYYY-MM-DD"));
|
|
3715
3748
|
setOpen(false);
|
|
3716
|
-
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3749
|
+
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3717
3750
|
};
|
|
3718
3751
|
|
|
3719
3752
|
function filterArray(array, searchTerm) {
|
|
@@ -3746,25 +3779,24 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3746
3779
|
setSearchText(event.target.value);
|
|
3747
3780
|
setLimit(10);
|
|
3748
3781
|
};
|
|
3749
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
3782
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3750
3783
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3751
3784
|
const item = enumValue;
|
|
3752
3785
|
if (item === undefined) {
|
|
3753
3786
|
return jsx(Fragment, { children: "undefined" });
|
|
3754
3787
|
}
|
|
3755
3788
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
3756
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3757
3789
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3758
3790
|
}, children: !!renderDisplay === true
|
|
3759
3791
|
? renderDisplay(item)
|
|
3760
3792
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
3761
3793
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3762
3794
|
setOpenSearchResult(true);
|
|
3763
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
3795
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
3764
3796
|
setOpenSearchResult(true);
|
|
3765
3797
|
}, children: watchEnum === undefined
|
|
3766
3798
|
? ""
|
|
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}.
|
|
3799
|
+
: 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
3800
|
onSearchChange(event);
|
|
3769
3801
|
setOpenSearchResult(true);
|
|
3770
3802
|
}, 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) => {
|
|
@@ -3779,10 +3811,10 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3779
3811
|
}
|
|
3780
3812
|
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3781
3813
|
setValue(colLabel, [...newSet]);
|
|
3782
|
-
}, ...(selected ? { color: "
|
|
3814
|
+
}, ...(selected ? { color: "colorPalette.400/50" } : {}), children: !!renderDisplay === true
|
|
3783
3815
|
? renderDisplay(item)
|
|
3784
3816
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }, `${colLabel}-${item}`));
|
|
3785
|
-
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Fragment, { children: translate.t(removeIndex(`${colLabel}.
|
|
3817
|
+
}) }), 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
3818
|
};
|
|
3787
3819
|
|
|
3788
3820
|
function isEnteringWindow(_ref) {
|
|
@@ -4134,7 +4166,7 @@ const FileDropzone = ({ children = undefined, gridProps = {}, onDrop = () => { }
|
|
|
4134
4166
|
const filesArray = [...event.target.files];
|
|
4135
4167
|
onDrop({ files: filesArray });
|
|
4136
4168
|
};
|
|
4137
|
-
return (jsxs(Grid, { ...getColor(isDraggedOver), ref: ref, cursor: "pointer", onClick: handleClick, borderStyle: "dashed", borderColor: "
|
|
4169
|
+
return (jsxs(Grid, { ...getColor(isDraggedOver), ref: ref, cursor: "pointer", onClick: handleClick, borderStyle: "dashed", borderColor: "colorPalette.400", alignContent: "center", justifyContent: "center", borderWidth: 1, borderRadius: 4, ...gridProps, children: [children, !!children === false && (jsxs(Fragment, { children: [jsx(Flex, { children: placeholder }), jsx(Input, { type: "file", multiple: true, style: { display: "none" }, ref: fileInput, onChange: handleChange })] }))] }));
|
|
4138
4170
|
};
|
|
4139
4171
|
|
|
4140
4172
|
const FilePicker = ({ column, schema, prefix }) => {
|
|
@@ -4144,7 +4176,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4144
4176
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4145
4177
|
const currentFiles = (watch(column) ?? []);
|
|
4146
4178
|
const colLabel = `${prefix}${column}`;
|
|
4147
|
-
return (jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4179
|
+
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
4180
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4149
4181
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4150
4182
|
}, placeholder: translate.t(removeIndex(`${colLabel}.fileDropzone`)) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4153,7 +4185,7 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4153
4185
|
return name !== file.name;
|
|
4154
4186
|
}));
|
|
4155
4187
|
}, 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}.
|
|
4188
|
+
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4157
4189
|
};
|
|
4158
4190
|
|
|
4159
4191
|
const getTableData = async ({ serverUrl, in_table, searching = "", where = [], limit = 10, offset = 0, }) => {
|
|
@@ -4270,7 +4302,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4270
4302
|
}
|
|
4271
4303
|
return record[display_column];
|
|
4272
4304
|
};
|
|
4273
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.
|
|
4305
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.field_label`)))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4274
4306
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchIds.map((id) => {
|
|
4275
4307
|
const item = idMap[id];
|
|
4276
4308
|
if (item === undefined) {
|
|
@@ -4283,7 +4315,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4283
4315
|
: item[display_column] }, id));
|
|
4284
4316
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4285
4317
|
setOpenSearchResult(true);
|
|
4286
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
4318
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
4287
4319
|
setOpenSearchResult(true);
|
|
4288
4320
|
}, 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
4321
|
onSearchChange(event);
|
|
@@ -4305,10 +4337,10 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4305
4337
|
item[column_ref],
|
|
4306
4338
|
]);
|
|
4307
4339
|
setValue(colLabel, [...newSet]);
|
|
4308
|
-
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "
|
|
4340
|
+
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "colorPalette.400/50" } : {}), children: !!renderDisplay === true
|
|
4309
4341
|
? renderDisplay(item)
|
|
4310
4342
|
: item[display_column] }, item[column_ref]));
|
|
4311
|
-
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.
|
|
4343
|
+
}) }), 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
4344
|
};
|
|
4313
4345
|
|
|
4314
4346
|
const NumberInputRoot = React.forwardRef(function NumberInput$1(props, ref) {
|
|
@@ -4326,9 +4358,9 @@ const NumberInputField = ({ schema, column, prefix, }) => {
|
|
|
4326
4358
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4327
4359
|
const colLabel = `${prefix}${column}`;
|
|
4328
4360
|
const value = watch(`${colLabel}`);
|
|
4329
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4361
|
+
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
4362
|
setValue(`${colLabel}`, Number(event.target.value));
|
|
4331
|
-
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4363
|
+
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4332
4364
|
};
|
|
4333
4365
|
|
|
4334
4366
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
@@ -4340,13 +4372,13 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4340
4372
|
if (properties === undefined) {
|
|
4341
4373
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4342
4374
|
}
|
|
4343
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4375
|
+
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
4376
|
return (
|
|
4345
4377
|
// @ts-expect-error find suitable types
|
|
4346
4378
|
jsx(ColumnRenderer, { column: `${key}`,
|
|
4347
4379
|
prefix: `${prefix}${column}.`,
|
|
4348
4380
|
properties }, `form-${colLabel}-${key}`));
|
|
4349
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4381
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4350
4382
|
};
|
|
4351
4383
|
|
|
4352
4384
|
const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
@@ -4358,7 +4390,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4358
4390
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4359
4391
|
const [newKey, setNewKey] = useState();
|
|
4360
4392
|
const [newValue, setNewValue] = useState();
|
|
4361
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
4393
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4362
4394
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4363
4395
|
const filtered = entries.filter(([target]) => {
|
|
4364
4396
|
return target !== key;
|
|
@@ -4398,7 +4430,7 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4398
4430
|
setShowNewEntries(true);
|
|
4399
4431
|
setNewKey(undefined);
|
|
4400
4432
|
setNewValue(undefined);
|
|
4401
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4433
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4402
4434
|
};
|
|
4403
4435
|
|
|
4404
4436
|
const StringInputField = ({ column, schema, prefix, }) => {
|
|
@@ -4407,7 +4439,7 @@ const StringInputField = ({ column, schema, prefix, }) => {
|
|
|
4407
4439
|
const { required, gridColumn, gridRow } = schema;
|
|
4408
4440
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4409
4441
|
const colLabel = `${prefix}${column}`;
|
|
4410
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4442
|
+
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
4443
|
};
|
|
4412
4444
|
|
|
4413
4445
|
const RadioCardItem = React.forwardRef(function RadioCardItem(props, ref) {
|
|
@@ -4571,9 +4603,9 @@ const ArrayViewer = ({ schema, column, prefix }) => {
|
|
|
4571
4603
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4572
4604
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4573
4605
|
const values = watch(colLabel) ?? [];
|
|
4574
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4606
|
+
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
4607
|
prefix: `${colLabel}.`,
|
|
4576
|
-
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4608
|
+
schema: items }) }) }, `form-${prefix}${column}.${index}`))), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4577
4609
|
};
|
|
4578
4610
|
|
|
4579
4611
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4583,10 +4615,10 @@ const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
|
4583
4615
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4584
4616
|
const colLabel = `${prefix}${column}`;
|
|
4585
4617
|
const value = watch(colLabel);
|
|
4586
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4618
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4587
4619
|
gridRow, children: [jsx(Text, { children: value
|
|
4588
4620
|
? translate.t(removeIndex(`${colLabel}.true`))
|
|
4589
|
-
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4621
|
+
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4590
4622
|
};
|
|
4591
4623
|
|
|
4592
4624
|
const DateViewer = ({ column, schema, prefix }) => {
|
|
@@ -4596,8 +4628,8 @@ const DateViewer = ({ column, schema, prefix }) => {
|
|
|
4596
4628
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4597
4629
|
const colLabel = `${prefix}${column}`;
|
|
4598
4630
|
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}.
|
|
4631
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4632
|
+
gridRow, children: [jsxs(Text, { children: [" ", selectedDate !== undefined ? selectedDate : ""] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4601
4633
|
};
|
|
4602
4634
|
|
|
4603
4635
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
@@ -4609,7 +4641,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4609
4641
|
const colLabel = `${prefix}${column}`;
|
|
4610
4642
|
const watchEnum = watch(colLabel);
|
|
4611
4643
|
const watchEnums = (watch(colLabel) ?? []);
|
|
4612
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4644
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4613
4645
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
4614
4646
|
const item = enumValue;
|
|
4615
4647
|
if (item === undefined) {
|
|
@@ -4618,7 +4650,7 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
4618
4650
|
return (jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4619
4651
|
? renderDisplay(item)
|
|
4620
4652
|
: 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}.
|
|
4653
|
+
}) })), !isMultiple && (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4622
4654
|
};
|
|
4623
4655
|
|
|
4624
4656
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
@@ -4628,7 +4660,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4628
4660
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4629
4661
|
const currentFiles = (watch(column) ?? []);
|
|
4630
4662
|
const colLabel = `${prefix}${column}`;
|
|
4631
|
-
return (jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4663
|
+
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
4664
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4633
4665
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4634
4666
|
}, placeholder: translate.t(`${colLabel}.fileDropzone`) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4637,7 +4669,7 @@ const FileViewer = ({ column, schema, prefix }) => {
|
|
|
4637
4669
|
return name !== file.name;
|
|
4638
4670
|
}));
|
|
4639
4671
|
}, 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}.
|
|
4672
|
+
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4641
4673
|
};
|
|
4642
4674
|
|
|
4643
4675
|
const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
@@ -4659,7 +4691,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4659
4691
|
}
|
|
4660
4692
|
return record[display_column];
|
|
4661
4693
|
};
|
|
4662
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
4694
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4663
4695
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchIds.map((id) => {
|
|
4664
4696
|
const item = idMap[id];
|
|
4665
4697
|
if (item === undefined) {
|
|
@@ -4668,7 +4700,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4668
4700
|
return (jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4669
4701
|
? renderDisplay(item)
|
|
4670
4702
|
: item[display_column] }, id));
|
|
4671
|
-
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4703
|
+
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4672
4704
|
};
|
|
4673
4705
|
|
|
4674
4706
|
const NumberViewer = ({ schema, column, prefix, }) => {
|
|
@@ -4678,7 +4710,7 @@ const NumberViewer = ({ schema, column, prefix, }) => {
|
|
|
4678
4710
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4679
4711
|
const colLabel = `${prefix}${column}`;
|
|
4680
4712
|
const value = watch(colLabel);
|
|
4681
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4713
|
+
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
4714
|
};
|
|
4683
4715
|
|
|
4684
4716
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
@@ -4690,13 +4722,13 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
4690
4722
|
if (properties === undefined) {
|
|
4691
4723
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4692
4724
|
}
|
|
4693
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4725
|
+
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
4726
|
return (
|
|
4695
4727
|
// @ts-expect-error find suitable types
|
|
4696
4728
|
jsx(ColumnViewer, { column: `${key}`,
|
|
4697
4729
|
prefix: `${prefix}${column}.`,
|
|
4698
4730
|
properties }, `form-objectviewer-${colLabel}-${key}`));
|
|
4699
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4731
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4700
4732
|
};
|
|
4701
4733
|
|
|
4702
4734
|
const RecordInput = ({ column, schema, prefix }) => {
|
|
@@ -4708,7 +4740,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4708
4740
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4709
4741
|
const [newKey, setNewKey] = useState();
|
|
4710
4742
|
const [newValue, setNewValue] = useState();
|
|
4711
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
4743
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4712
4744
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4713
4745
|
const filtered = entries.filter(([target]) => {
|
|
4714
4746
|
return target !== key;
|
|
@@ -4748,7 +4780,7 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4748
4780
|
setShowNewEntries(true);
|
|
4749
4781
|
setNewKey(undefined);
|
|
4750
4782
|
setNewValue(undefined);
|
|
4751
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4783
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4752
4784
|
};
|
|
4753
4785
|
|
|
4754
4786
|
const TagViewer = ({ column, schema, prefix }) => {
|
|
@@ -4843,7 +4875,7 @@ const StringViewer = ({ column, schema, prefix, }) => {
|
|
|
4843
4875
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4844
4876
|
const colLabel = `${prefix}${column}`;
|
|
4845
4877
|
const value = watch(colLabel);
|
|
4846
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4878
|
+
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
4879
|
};
|
|
4848
4880
|
|
|
4849
4881
|
const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
@@ -4907,30 +4939,23 @@ const ColumnViewer = ({ column, properties, prefix, }) => {
|
|
|
4907
4939
|
return jsx(SchemaViewer, { schema: colSchema, prefix, column });
|
|
4908
4940
|
};
|
|
4909
4941
|
|
|
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
|
-
}
|
|
4942
|
+
const SubmitButton = () => {
|
|
4943
|
+
const { translate, setValidatedData, setIsError, setIsConfirming } = useSchemaContext();
|
|
4944
|
+
const methods = useFormContext();
|
|
4945
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4946
|
+
const onValid = (data) => {
|
|
4947
|
+
setValidatedData(data);
|
|
4948
|
+
setIsError(false);
|
|
4949
|
+
setIsConfirming(true);
|
|
4950
|
+
};
|
|
4951
|
+
return (jsx(Button$1, { onClick: () => {
|
|
4952
|
+
methods.handleSubmit(onValid)();
|
|
4953
|
+
}, formNoValidate: true, children: translate.t("submit") }));
|
|
4924
4954
|
};
|
|
4925
|
-
|
|
4926
|
-
|
|
4955
|
+
|
|
4956
|
+
const FormBody = () => {
|
|
4957
|
+
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
4958
|
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
4959
|
const { properties } = schema;
|
|
4935
4960
|
const onBeforeSubmit = () => {
|
|
4936
4961
|
setIsSubmiting(true);
|
|
@@ -4938,8 +4963,9 @@ const FormInternal = () => {
|
|
|
4938
4963
|
const onAfterSubmit = () => {
|
|
4939
4964
|
setIsSubmiting(false);
|
|
4940
4965
|
};
|
|
4941
|
-
const onSubmitError = () => {
|
|
4966
|
+
const onSubmitError = (error) => {
|
|
4942
4967
|
setIsError(true);
|
|
4968
|
+
setError(error);
|
|
4943
4969
|
};
|
|
4944
4970
|
const onSubmitSuccess = () => {
|
|
4945
4971
|
setIsSuccess(true);
|
|
@@ -4951,9 +4977,7 @@ const FormInternal = () => {
|
|
|
4951
4977
|
onSubmitSuccess();
|
|
4952
4978
|
}
|
|
4953
4979
|
catch (error) {
|
|
4954
|
-
|
|
4955
|
-
setError(error);
|
|
4956
|
-
onSubmitError();
|
|
4980
|
+
onSubmitError(error);
|
|
4957
4981
|
}
|
|
4958
4982
|
finally {
|
|
4959
4983
|
onAfterSubmit();
|
|
@@ -4976,12 +5000,6 @@ const FormInternal = () => {
|
|
|
4976
5000
|
}
|
|
4977
5001
|
await defaultOnSubmit(onSubmit(data));
|
|
4978
5002
|
};
|
|
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
5003
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
4986
5004
|
const included = include.length > 0 ? include : keys;
|
|
4987
5005
|
const not_exist = included.filter((columnA) => !order.some((columnB) => columnA === columnB));
|
|
@@ -4996,58 +5014,47 @@ const FormInternal = () => {
|
|
|
4996
5014
|
include,
|
|
4997
5015
|
});
|
|
4998
5016
|
if (isSuccess) {
|
|
4999
|
-
return (jsxs(
|
|
5017
|
+
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
5018
|
setIsError(false);
|
|
5001
5019
|
setIsSubmiting(false);
|
|
5002
5020
|
setIsSuccess(false);
|
|
5003
5021
|
setIsConfirming(false);
|
|
5004
5022
|
setValidatedData(undefined);
|
|
5005
|
-
|
|
5006
|
-
|
|
5023
|
+
const data = await getUpdatedData();
|
|
5024
|
+
methods.reset(data);
|
|
5025
|
+
}, formNoValidate: true, children: translate.t("submit_again") }) })] }));
|
|
5007
5026
|
}
|
|
5008
5027
|
if (isConfirming) {
|
|
5009
|
-
return (jsxs(
|
|
5028
|
+
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
5029
|
return (jsx(ColumnViewer
|
|
5011
5030
|
// @ts-expect-error find suitable types
|
|
5012
5031
|
, {
|
|
5013
5032
|
// @ts-expect-error find suitable types
|
|
5014
5033
|
properties: properties, prefix: ``, column }, `form-viewer-${column}`));
|
|
5015
|
-
}) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button, { onClick: () => {
|
|
5034
|
+
}) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button$1, { onClick: () => {
|
|
5016
5035
|
setIsConfirming(false);
|
|
5017
|
-
}, variant: "subtle", children: translate.t("cancel") }), jsx(Button, { onClick: () => {
|
|
5036
|
+
}, variant: "subtle", children: translate.t("cancel") }), jsx(Button$1, { onClick: () => {
|
|
5018
5037
|
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: [
|
|
5038
|
+
}, 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
5039
|
}
|
|
5021
|
-
return (
|
|
5022
|
-
|
|
5040
|
+
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) => {
|
|
5041
|
+
return (jsx(ColumnRenderer
|
|
5042
|
+
// @ts-expect-error find suitable types
|
|
5043
|
+
, {
|
|
5023
5044
|
// @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") })] })] }) }));
|
|
5045
|
+
properties: properties, prefix: ``, column }, `form-input-${column}`));
|
|
5046
|
+
}) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button$1, { onClick: () => {
|
|
5047
|
+
methods.reset();
|
|
5048
|
+
}, variant: "subtle", children: translate.t("reset") }), jsx(SubmitButton, {})] })] }));
|
|
5032
5049
|
};
|
|
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, {}) }) }));
|
|
5050
|
+
|
|
5051
|
+
const FormTitle = () => {
|
|
5052
|
+
const { translate } = useSchemaContext();
|
|
5053
|
+
return jsx(Heading, { children: translate.t("title") });
|
|
5054
|
+
};
|
|
5055
|
+
|
|
5056
|
+
const DefaultForm = ({ formConfig, showTitle = true, }) => {
|
|
5057
|
+
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [showTitle && jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
5051
5058
|
};
|
|
5052
5059
|
|
|
5053
5060
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5080,4 +5087,4 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
|
|
|
5080
5087
|
}
|
|
5081
5088
|
};
|
|
5082
5089
|
|
|
5083
|
-
export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultTable, DensityToggleButton,
|
|
5090
|
+
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 };
|