@bsol-oss/react-datatable5 12.0.0-beta.5 → 12.0.0-beta.50
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 +181 -86
- package/dist/index.js +873 -358
- package/dist/index.mjs +878 -364
- package/dist/types/components/DataTable/DataTable.d.ts +4 -2
- 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/context/DataTableContext.d.ts +19 -3
- package/dist/types/components/DataTable/context/useDataTableContext.d.ts +2 -2
- 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 +4 -0
- package/dist/types/components/DataTable/controls/ResetFilteringButton.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ResetSelectionButton.d.ts +1 -0
- package/dist/types/components/DataTable/controls/ResetSortingButton.d.ts +1 -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 +26 -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 +20 -0
- package/dist/types/components/DataTable/display/TableCardContainer.d.ts +10 -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 +51 -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/components/core/DefaultForm.d.ts +2 -1
- package/dist/types/components/Form/components/core/FormRoot.d.ts +2 -1
- package/dist/types/components/Form/components/fields/CustomInput.d.ts +8 -0
- package/dist/types/components/Form/components/fields/DatePicker.d.ts +2 -7
- package/dist/types/components/Form/components/fields/EnumPicker.d.ts +2 -1
- package/dist/types/components/Form/components/fields/FilePicker.d.ts +2 -5
- package/dist/types/components/Form/components/fields/StringInputField.d.ts +2 -5
- package/dist/types/components/Form/components/fields/TextAreaInput.d.ts +12 -0
- package/dist/types/components/Form/components/fields/TimePicker.d.ts +7 -0
- package/dist/types/components/Form/components/fields/types.d.ts +6 -0
- package/dist/types/components/Form/components/types/CustomJSONSchema7.d.ts +19 -1
- package/dist/types/components/Form/components/viewers/CustomViewer.d.ts +8 -0
- package/dist/types/components/Form/components/viewers/TextAreaViewer.d.ts +12 -0
- package/dist/types/components/Form/components/viewers/TimeViewer.d.ts +7 -0
- package/dist/types/components/Form/utils/translateWrapper.d.ts +6 -0
- package/dist/types/components/TimePicker/TimePicker.d.ts +20 -0
- package/dist/types/index.d.ts +48 -32
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
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,
|
|
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, Textarea, 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
6
|
import { LuX, LuCheck, LuChevronRight, LuChevronDown } from 'react-icons/lu';
|
|
7
|
-
import { MdOutlineSort, MdFilterAlt, MdSearch, MdClose, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdOutlineChecklist } from 'react-icons/md';
|
|
7
|
+
import { MdOutlineSort, MdFilterAlt, MdSearch, MdClose, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdOutlineChecklist, MdDateRange } from 'react-icons/md';
|
|
8
8
|
import { FaUpDown, FaGripLinesVertical } from 'react-icons/fa6';
|
|
9
9
|
import { BiDownArrow, BiUpArrow, BiError } from 'react-icons/bi';
|
|
10
|
-
import { CgClose } from 'react-icons/cg';
|
|
10
|
+
import { CgClose, CgTrash } from 'react-icons/cg';
|
|
11
11
|
import Dayzed from '@bsol-oss/dayzed-react19';
|
|
12
12
|
import { HiMiniEllipsisHorizontal, HiChevronLeft, HiChevronRight } from 'react-icons/hi2';
|
|
13
|
-
import { IoMdEye, IoMdCheckbox } from 'react-icons/io';
|
|
13
|
+
import { IoMdEye, IoMdCheckbox, IoMdClock } from 'react-icons/io';
|
|
14
14
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
15
15
|
import { bind, bindAll } from 'bind-event-listener';
|
|
16
16
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
17
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
18
18
|
import rafSchd from 'raf-schd';
|
|
19
19
|
import invariant from 'tiny-invariant';
|
|
20
|
-
import { HiColorSwatch } from 'react-icons/hi';
|
|
20
|
+
import { HiColorSwatch, HiOutlineInformationCircle } from 'react-icons/hi';
|
|
21
21
|
import { flexRender, makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, createColumnHelper } from '@tanstack/react-table';
|
|
22
22
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
23
23
|
import { BsExclamationCircleFill } from 'react-icons/bs';
|
|
@@ -29,6 +29,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
29
29
|
import axios from 'axios';
|
|
30
30
|
import { FormProvider, useFormContext, useForm as useForm$1 } from 'react-hook-form';
|
|
31
31
|
import dayjs from 'dayjs';
|
|
32
|
+
import utc from 'dayjs/plugin/utc';
|
|
32
33
|
import { TiDeleteOutline } from 'react-icons/ti';
|
|
33
34
|
|
|
34
35
|
const DataTableContext = createContext({
|
|
@@ -37,6 +38,53 @@ const DataTableContext = createContext({
|
|
|
37
38
|
setGlobalFilter: () => { },
|
|
38
39
|
type: "client",
|
|
39
40
|
translate: {},
|
|
41
|
+
data: [],
|
|
42
|
+
columns: [],
|
|
43
|
+
columnOrder: [],
|
|
44
|
+
columnFilters: [],
|
|
45
|
+
density: "sm",
|
|
46
|
+
sorting: [],
|
|
47
|
+
setPagination: function () {
|
|
48
|
+
throw new Error("Function not implemented.");
|
|
49
|
+
},
|
|
50
|
+
setSorting: function () {
|
|
51
|
+
throw new Error("Function not implemented.");
|
|
52
|
+
},
|
|
53
|
+
setColumnFilters: function () {
|
|
54
|
+
throw new Error("Function not implemented.");
|
|
55
|
+
},
|
|
56
|
+
setRowSelection: function () {
|
|
57
|
+
throw new Error("Function not implemented.");
|
|
58
|
+
},
|
|
59
|
+
setColumnOrder: function () {
|
|
60
|
+
throw new Error("Function not implemented.");
|
|
61
|
+
},
|
|
62
|
+
setDensity: function () {
|
|
63
|
+
throw new Error("Function not implemented.");
|
|
64
|
+
},
|
|
65
|
+
setColumnVisibility: function () {
|
|
66
|
+
throw new Error("Function not implemented.");
|
|
67
|
+
},
|
|
68
|
+
pagination: {
|
|
69
|
+
pageIndex: 0,
|
|
70
|
+
pageSize: 10,
|
|
71
|
+
},
|
|
72
|
+
rowSelection: {},
|
|
73
|
+
columnVisibility: {},
|
|
74
|
+
tableLabel: {
|
|
75
|
+
view: "View",
|
|
76
|
+
edit: "Edit",
|
|
77
|
+
filterButtonText: "Filter",
|
|
78
|
+
filterTitle: "Filter",
|
|
79
|
+
filterReset: "Reset",
|
|
80
|
+
filterClose: "Close",
|
|
81
|
+
reloadTooltip: "Reload",
|
|
82
|
+
reloadButtonText: "Reload",
|
|
83
|
+
resetSelection: "Reset Selection",
|
|
84
|
+
resetSorting: "Reset Sorting",
|
|
85
|
+
rowCountText: "Row Count",
|
|
86
|
+
hasErrorText: "Has Error",
|
|
87
|
+
},
|
|
40
88
|
});
|
|
41
89
|
|
|
42
90
|
const useDataTableContext = () => {
|
|
@@ -92,11 +140,13 @@ const TableSorter = () => {
|
|
|
92
140
|
}) }))) }));
|
|
93
141
|
};
|
|
94
142
|
|
|
95
|
-
const ResetSortingButton = (
|
|
143
|
+
const ResetSortingButton = () => {
|
|
96
144
|
const { table } = useDataTableContext();
|
|
145
|
+
const { tableLabel } = useDataTableContext();
|
|
146
|
+
const { resetSorting } = tableLabel;
|
|
97
147
|
return (jsx(Button$1, { onClick: () => {
|
|
98
148
|
table.resetSorting();
|
|
99
|
-
}, children:
|
|
149
|
+
}, children: resetSorting }));
|
|
100
150
|
};
|
|
101
151
|
|
|
102
152
|
const EditSortingButton = ({ text, icon = jsx(MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
@@ -307,10 +357,11 @@ const Filter = ({ column }) => {
|
|
|
307
357
|
if (filterVariant === "select") {
|
|
308
358
|
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(RadioGroup, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onValueChange: (details) => {
|
|
309
359
|
column.setFilterValue(details.value);
|
|
310
|
-
}, children:
|
|
360
|
+
}, children: jsxs(Flex, { flexFlow: "wrap", gap: "0.5rem", children: [filterOptions.length === 0 && jsx(Text, { children: "No filter options" }), filterOptions.length > 0 &&
|
|
361
|
+
filterOptions.map((item) => (jsx(Radio, { value: item.value, children: item.label }, item.value)))] }) })] }, column.id));
|
|
311
362
|
}
|
|
312
363
|
if (filterVariant === "tag") {
|
|
313
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(TagFilter, { availableTags: filterOptions, selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
364
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(TagFilter, { availableTags: filterOptions.map((item) => item.value), selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
314
365
|
if (tags.length === 0) {
|
|
315
366
|
return column.setFilterValue(undefined);
|
|
316
367
|
}
|
|
@@ -373,17 +424,20 @@ const TableFilter = () => {
|
|
|
373
424
|
}) }));
|
|
374
425
|
};
|
|
375
426
|
|
|
376
|
-
const ResetFilteringButton = (
|
|
427
|
+
const ResetFilteringButton = () => {
|
|
377
428
|
const { table } = useDataTableContext();
|
|
429
|
+
const { tableLabel } = useDataTableContext();
|
|
430
|
+
const { filterReset } = tableLabel;
|
|
378
431
|
return (jsx(Button$1, { onClick: () => {
|
|
379
432
|
table.resetColumnFilters();
|
|
380
|
-
}, children:
|
|
433
|
+
}, children: filterReset }));
|
|
381
434
|
};
|
|
382
435
|
|
|
383
436
|
const FilterDialog = ({ icon = jsx(MdFilterAlt, {}), }) => {
|
|
384
437
|
const filterModal = useDisclosure();
|
|
385
|
-
const {
|
|
386
|
-
|
|
438
|
+
const { tableLabel } = useDataTableContext();
|
|
439
|
+
const { filterButtonText, filterTitle, filterClose } = tableLabel;
|
|
440
|
+
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, " ", filterButtonText] }) }), jsxs(DialogContent, { children: [jsx(DialogHeader, { children: jsx(DialogTitle, { children: filterTitle }) }), jsx(DialogBody, { display: "flex", flexFlow: "column", children: jsx(TableFilter, {}) }), jsxs(DialogFooter, { children: [jsx(ResetFilteringButton, {}), jsx(Button$1, { onClick: filterModal.onClose, variant: "subtle", children: filterClose })] }), jsx(DialogCloseTrigger, { onClick: filterModal.onClose })] })] }));
|
|
387
441
|
};
|
|
388
442
|
|
|
389
443
|
const MenuContent = React.forwardRef(function MenuContent(props, ref) {
|
|
@@ -502,11 +556,13 @@ const Pagination = () => {
|
|
|
502
556
|
}, children: jsxs(HStack, { children: [jsx(PaginationPrevTrigger, {}), jsx(PaginationItems, {}), jsx(PaginationNextTrigger, {})] }) }));
|
|
503
557
|
};
|
|
504
558
|
|
|
505
|
-
const ResetSelectionButton = (
|
|
559
|
+
const ResetSelectionButton = () => {
|
|
506
560
|
const { table } = useDataTableContext();
|
|
561
|
+
const { tableLabel } = useDataTableContext();
|
|
562
|
+
const { resetSelection } = tableLabel;
|
|
507
563
|
return (jsx(Button$1, { onClick: () => {
|
|
508
564
|
table.resetRowSelection();
|
|
509
|
-
}, children:
|
|
565
|
+
}, children: resetSelection }));
|
|
510
566
|
};
|
|
511
567
|
|
|
512
568
|
const RowCountText = () => {
|
|
@@ -2421,8 +2477,8 @@ CheckboxCard$1.Indicator;
|
|
|
2421
2477
|
function ColumnCard({ columnId }) {
|
|
2422
2478
|
const ref = useRef(null);
|
|
2423
2479
|
const [dragging, setDragging] = useState(false); // NEW
|
|
2424
|
-
const { table } = useDataTableContext();
|
|
2425
|
-
const displayName = columnId;
|
|
2480
|
+
const { table, translate } = useDataTableContext();
|
|
2481
|
+
const displayName = translate.t(columnId);
|
|
2426
2482
|
const column = table.getColumn(columnId);
|
|
2427
2483
|
invariant(column);
|
|
2428
2484
|
useEffect(() => {
|
|
@@ -2437,7 +2493,7 @@ function ColumnCard({ columnId }) {
|
|
|
2437
2493
|
onDrop: () => setDragging(false), // NEW
|
|
2438
2494
|
});
|
|
2439
2495
|
}, [columnId, table]);
|
|
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: "
|
|
2496
|
+
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() }) })] }));
|
|
2441
2497
|
}
|
|
2442
2498
|
function CardContainer({ location, children }) {
|
|
2443
2499
|
const ref = useRef(null);
|
|
@@ -2517,8 +2573,9 @@ const TableViewer = () => {
|
|
|
2517
2573
|
|
|
2518
2574
|
const ViewDialog = ({ icon = jsx(IoMdEye, {}) }) => {
|
|
2519
2575
|
const viewModel = useDisclosure();
|
|
2520
|
-
const {
|
|
2521
|
-
|
|
2576
|
+
const { tableLabel } = useDataTableContext();
|
|
2577
|
+
const { view } = tableLabel;
|
|
2578
|
+
return (jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { as: Box, variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", view] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsx(DialogHeader, { children: jsx(DialogTitle, { children: view }) }), jsx(DialogBody, { children: jsx(TableViewer, {}) }), jsx(DialogFooter, {})] })] }));
|
|
2522
2579
|
};
|
|
2523
2580
|
|
|
2524
2581
|
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
@@ -2569,7 +2626,7 @@ const RecordDisplay = ({ object, boxProps, translate, prefix = "", }) => {
|
|
|
2569
2626
|
return jsx(Fragment, { children: "null" });
|
|
2570
2627
|
}
|
|
2571
2628
|
return (jsx(Grid, { rowGap: 1, padding: 1, overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
2572
|
-
return (jsxs(Grid, { columnGap: 2, gridTemplateColumns: "auto 1fr", children: [jsx(Text, { color: "
|
|
2629
|
+
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));
|
|
2573
2630
|
}) }));
|
|
2574
2631
|
};
|
|
2575
2632
|
|
|
@@ -2619,7 +2676,7 @@ const CellRenderer = ({ cell }) => {
|
|
|
2619
2676
|
paddingY: 2,
|
|
2620
2677
|
}, object: value })] }, cell.id));
|
|
2621
2678
|
}
|
|
2622
|
-
return (jsxs(Box, { gridColumn, gridRow, children: [jsx(Box, { color:
|
|
2679
|
+
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));
|
|
2623
2680
|
};
|
|
2624
2681
|
const DataDisplay = ({ variant = "" }) => {
|
|
2625
2682
|
const { table, translate } = useDataTableContext();
|
|
@@ -2741,7 +2798,20 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
2741
2798
|
*
|
|
2742
2799
|
* @link https://tanstack.com/table/latest/docs/guide/column-defs
|
|
2743
2800
|
*/
|
|
2744
|
-
function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, translate, children,
|
|
2801
|
+
function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, translate, children, tableLabel = {
|
|
2802
|
+
view: "View",
|
|
2803
|
+
edit: "Edit",
|
|
2804
|
+
filterButtonText: "Filter",
|
|
2805
|
+
filterTitle: "Filter",
|
|
2806
|
+
filterReset: "Reset",
|
|
2807
|
+
filterClose: "Close",
|
|
2808
|
+
reloadTooltip: "Reload",
|
|
2809
|
+
reloadButtonText: "Reload",
|
|
2810
|
+
resetSelection: "Reset Selection",
|
|
2811
|
+
resetSorting: "Reset Sorting",
|
|
2812
|
+
rowCountText: "Row Count",
|
|
2813
|
+
hasErrorText: "Has Error",
|
|
2814
|
+
}, }) {
|
|
2745
2815
|
const table = useReactTable({
|
|
2746
2816
|
_features: [DensityFeature],
|
|
2747
2817
|
data: data,
|
|
@@ -2794,6 +2864,23 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2794
2864
|
setGlobalFilter,
|
|
2795
2865
|
type: "client",
|
|
2796
2866
|
translate,
|
|
2867
|
+
columns: columns,
|
|
2868
|
+
sorting,
|
|
2869
|
+
setSorting,
|
|
2870
|
+
columnFilters,
|
|
2871
|
+
setColumnFilters,
|
|
2872
|
+
pagination,
|
|
2873
|
+
setPagination,
|
|
2874
|
+
rowSelection,
|
|
2875
|
+
setRowSelection,
|
|
2876
|
+
columnOrder,
|
|
2877
|
+
setColumnOrder,
|
|
2878
|
+
density,
|
|
2879
|
+
setDensity,
|
|
2880
|
+
columnVisibility,
|
|
2881
|
+
setColumnVisibility,
|
|
2882
|
+
data,
|
|
2883
|
+
tableLabel,
|
|
2797
2884
|
}, children: children }));
|
|
2798
2885
|
}
|
|
2799
2886
|
|
|
@@ -2811,7 +2898,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2811
2898
|
function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, query, url, translate, children, }) {
|
|
2812
2899
|
const table = useReactTable({
|
|
2813
2900
|
_features: [DensityFeature],
|
|
2814
|
-
data: query.data?.data ?? [],
|
|
2901
|
+
data: (query.data?.data ?? []),
|
|
2815
2902
|
rowCount: query.data?.count ?? 0,
|
|
2816
2903
|
columns: columns,
|
|
2817
2904
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -2857,95 +2944,30 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2857
2944
|
// for tanstack-table ts bug end
|
|
2858
2945
|
});
|
|
2859
2946
|
return (jsx(DataTableContext.Provider, { value: {
|
|
2860
|
-
table:
|
|
2947
|
+
table: table,
|
|
2861
2948
|
globalFilter,
|
|
2862
2949
|
setGlobalFilter,
|
|
2863
2950
|
type: "server",
|
|
2864
2951
|
translate,
|
|
2952
|
+
columns: columns,
|
|
2953
|
+
sorting,
|
|
2954
|
+
setSorting,
|
|
2955
|
+
columnFilters,
|
|
2956
|
+
setColumnFilters,
|
|
2957
|
+
pagination,
|
|
2958
|
+
setPagination,
|
|
2959
|
+
rowSelection,
|
|
2960
|
+
setRowSelection,
|
|
2961
|
+
columnOrder,
|
|
2962
|
+
setColumnOrder,
|
|
2963
|
+
density,
|
|
2964
|
+
setDensity,
|
|
2965
|
+
columnVisibility,
|
|
2966
|
+
setColumnVisibility,
|
|
2967
|
+
data: query.data?.data ?? [],
|
|
2865
2968
|
}, children: jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2866
2969
|
}
|
|
2867
2970
|
|
|
2868
|
-
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
2869
|
-
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
2870
|
-
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 }))] }));
|
|
2871
|
-
});
|
|
2872
|
-
|
|
2873
|
-
const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
2874
|
-
const { table } = useDataTableContext();
|
|
2875
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2876
|
-
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
2877
|
-
const handleRowHover = (index) => {
|
|
2878
|
-
setHoveredRow(index);
|
|
2879
|
-
};
|
|
2880
|
-
const getTdProps = (cell) => {
|
|
2881
|
-
const tdProps = cell.column.getIsPinned()
|
|
2882
|
-
? {
|
|
2883
|
-
left: showSelector
|
|
2884
|
-
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
2885
|
-
: `${cell.column.getStart("left")}px`,
|
|
2886
|
-
background: pinnedBgColor.light,
|
|
2887
|
-
position: "sticky",
|
|
2888
|
-
zIndex: -1,
|
|
2889
|
-
_dark: {
|
|
2890
|
-
backgroundColor: pinnedBgColor.dark,
|
|
2891
|
-
},
|
|
2892
|
-
}
|
|
2893
|
-
: {};
|
|
2894
|
-
return tdProps;
|
|
2895
|
-
};
|
|
2896
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2897
|
-
if (hoveredRow === -1) {
|
|
2898
|
-
return {};
|
|
2899
|
-
}
|
|
2900
|
-
if (hoveredRow === index) {
|
|
2901
|
-
return {
|
|
2902
|
-
opacity: "1",
|
|
2903
|
-
};
|
|
2904
|
-
}
|
|
2905
|
-
return {
|
|
2906
|
-
opacity: "0.8",
|
|
2907
|
-
};
|
|
2908
|
-
};
|
|
2909
|
-
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2910
|
-
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) => {
|
|
2911
|
-
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2912
|
-
// styling resize and pinning start
|
|
2913
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, backgroundColor: "white", ...getTdProps(cell), _dark: {
|
|
2914
|
-
backgroundColor: "gray.950",
|
|
2915
|
-
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2916
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2917
|
-
}) }));
|
|
2918
|
-
};
|
|
2919
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2920
|
-
const { table } = useDataTableContext();
|
|
2921
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2922
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2923
|
-
if (alwaysShowSelector) {
|
|
2924
|
-
return true;
|
|
2925
|
-
}
|
|
2926
|
-
if (current_row.getIsSelected()) {
|
|
2927
|
-
return true;
|
|
2928
|
-
}
|
|
2929
|
-
if (hoveredRow == current_index) {
|
|
2930
|
-
return true;
|
|
2931
|
-
}
|
|
2932
|
-
return false;
|
|
2933
|
-
};
|
|
2934
|
-
return (jsxs(Table$1.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2935
|
-
? {
|
|
2936
|
-
left: `0px`,
|
|
2937
|
-
backgroundColor: pinnedBgColor.light,
|
|
2938
|
-
position: "sticky",
|
|
2939
|
-
zIndex: 1,
|
|
2940
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2941
|
-
}
|
|
2942
|
-
: {}),
|
|
2943
|
-
// styling resize and pinning end
|
|
2944
|
-
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(),
|
|
2945
|
-
disabled: !row.getCanSelect(),
|
|
2946
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
2947
|
-
};
|
|
2948
|
-
|
|
2949
2971
|
const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
2950
2972
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
2951
2973
|
if (disabled)
|
|
@@ -2980,17 +3002,19 @@ const GlobalFilter = () => {
|
|
|
2980
3002
|
} }) }) }));
|
|
2981
3003
|
};
|
|
2982
3004
|
|
|
2983
|
-
const ReloadButton = ({
|
|
3005
|
+
const ReloadButton = ({ variant = "icon", }) => {
|
|
2984
3006
|
const { url } = useDataTableServerContext();
|
|
2985
3007
|
const queryClient = useQueryClient();
|
|
3008
|
+
const { tableLabel } = useDataTableContext();
|
|
3009
|
+
const { reloadTooltip, reloadButtonText } = tableLabel;
|
|
2986
3010
|
if (variant === "icon") {
|
|
2987
|
-
return (jsx(Tooltip, { showArrow: true, content:
|
|
3011
|
+
return (jsx(Tooltip, { showArrow: true, content: reloadTooltip, children: jsx(Button, { variant: "ghost", onClick: () => {
|
|
2988
3012
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2989
3013
|
}, "aria-label": "refresh", children: jsx(IoReload, {}) }) }));
|
|
2990
3014
|
}
|
|
2991
3015
|
return (jsxs(Button, { variant: "ghost", onClick: () => {
|
|
2992
3016
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2993
|
-
}, children: [jsx(IoReload, {}), " ",
|
|
3017
|
+
}, children: [jsx(IoReload, {}), " ", reloadButtonText] }));
|
|
2994
3018
|
};
|
|
2995
3019
|
|
|
2996
3020
|
const FilterOptions = ({ column }) => {
|
|
@@ -2999,6 +3023,7 @@ const FilterOptions = ({ column }) => {
|
|
|
2999
3023
|
const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
|
|
3000
3024
|
return (jsx(Fragment, { children: options.map((option) => {
|
|
3001
3025
|
const selected = table.getColumn(column)?.getFilterValue() === option;
|
|
3026
|
+
const { label, value } = option;
|
|
3002
3027
|
return (jsxs(Button$1, { size: "sm", onClick: () => {
|
|
3003
3028
|
if (selected) {
|
|
3004
3029
|
table.setColumnFilters((state) => {
|
|
@@ -3008,8 +3033,8 @@ const FilterOptions = ({ column }) => {
|
|
|
3008
3033
|
});
|
|
3009
3034
|
return;
|
|
3010
3035
|
}
|
|
3011
|
-
table.getColumn(column)?.setFilterValue(
|
|
3012
|
-
}, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [
|
|
3036
|
+
table.getColumn(column)?.setFilterValue(value);
|
|
3037
|
+
}, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [label, selected && jsx(MdClose, {})] }, option.value));
|
|
3013
3038
|
}) }));
|
|
3014
3039
|
};
|
|
3015
3040
|
|
|
@@ -3024,16 +3049,91 @@ const TableFilterTags = () => {
|
|
|
3024
3049
|
}) }));
|
|
3025
3050
|
};
|
|
3026
3051
|
|
|
3027
|
-
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, }) => {
|
|
3028
|
-
const {
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3052
|
+
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 = {}, }) => {
|
|
3053
|
+
const { tableLabel } = useDataTableContext();
|
|
3054
|
+
const { rowCountText, hasErrorText } = tableLabel;
|
|
3055
|
+
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: hasErrorText, 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((option) => {
|
|
3056
|
+
const { label, value } = option;
|
|
3057
|
+
return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [label, ":"] }), jsx(FilterOptions, { column: value })] }, value));
|
|
3058
|
+
}) })), 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: rowCountText }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(Pagination, {}) })] }))] }));
|
|
3059
|
+
};
|
|
3060
|
+
|
|
3061
|
+
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
3062
|
+
const { title, description, icon, children, ...rest } = props;
|
|
3063
|
+
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] }) }));
|
|
3064
|
+
});
|
|
3065
|
+
|
|
3066
|
+
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" })] }) }));
|
|
3067
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3068
|
+
const { table } = useDataTableContext();
|
|
3069
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
3070
|
+
return emptyComponent;
|
|
3071
|
+
}
|
|
3072
|
+
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 }));
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
3076
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3077
|
+
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 }))] }));
|
|
3078
|
+
});
|
|
3079
|
+
|
|
3080
|
+
const TableBody = ({ showSelector = false, canResize = true, }) => {
|
|
3081
|
+
"use no memo";
|
|
3082
|
+
const { table } = useDataTableContext();
|
|
3083
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3084
|
+
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
3085
|
+
const handleRowHover = (index) => {
|
|
3086
|
+
setHoveredRow(index);
|
|
3087
|
+
};
|
|
3088
|
+
const getTdProps = (cell) => {
|
|
3089
|
+
const tdProps = cell.column.getIsPinned()
|
|
3090
|
+
? {
|
|
3091
|
+
left: showSelector
|
|
3092
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3093
|
+
: `${cell.column.getStart("left")}px`,
|
|
3094
|
+
position: "relative",
|
|
3095
|
+
}
|
|
3096
|
+
: {};
|
|
3097
|
+
return tdProps;
|
|
3098
|
+
};
|
|
3099
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3100
|
+
if (hoveredRow === -1) {
|
|
3101
|
+
return {};
|
|
3102
|
+
}
|
|
3103
|
+
if (hoveredRow === index) {
|
|
3104
|
+
return {
|
|
3105
|
+
opacity: "1",
|
|
3106
|
+
};
|
|
3107
|
+
}
|
|
3108
|
+
return {
|
|
3109
|
+
opacity: "0.8",
|
|
3110
|
+
};
|
|
3111
|
+
};
|
|
3112
|
+
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3113
|
+
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) => {
|
|
3114
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3115
|
+
// styling resize and pinning start
|
|
3116
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3117
|
+
base: "colorPalette.900",
|
|
3118
|
+
_dark: "colorPalette.100",
|
|
3119
|
+
},
|
|
3120
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3121
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3122
|
+
}) }));
|
|
3123
|
+
};
|
|
3124
|
+
const TableRowSelector = ({ row, }) => {
|
|
3125
|
+
const { table } = useDataTableContext();
|
|
3126
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3127
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3128
|
+
base: "colorPalette.900",
|
|
3129
|
+
_dark: "colorPalette.100",
|
|
3130
|
+
},
|
|
3131
|
+
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(),
|
|
3132
|
+
disabled: !row.getCanSelect(),
|
|
3133
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3034
3134
|
};
|
|
3035
3135
|
|
|
3036
|
-
const TableFooter = ({
|
|
3136
|
+
const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
3037
3137
|
const table = useDataTableContext().table;
|
|
3038
3138
|
const SELECTION_BOX_WIDTH = 20;
|
|
3039
3139
|
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
@@ -3052,65 +3152,62 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3052
3152
|
}
|
|
3053
3153
|
return false;
|
|
3054
3154
|
};
|
|
3055
|
-
|
|
3056
|
-
const thProps = header.column.getIsPinned()
|
|
3057
|
-
? {
|
|
3058
|
-
left: showSelector
|
|
3059
|
-
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3060
|
-
: `${header.getStart("left") + table.getDensityValue() * 2}px`,
|
|
3061
|
-
background: pinnedBgColor.light,
|
|
3062
|
-
position: "sticky",
|
|
3063
|
-
zIndex: 1,
|
|
3064
|
-
_dark: {
|
|
3065
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3066
|
-
},
|
|
3067
|
-
}
|
|
3068
|
-
: {};
|
|
3069
|
-
return thProps;
|
|
3070
|
-
};
|
|
3071
|
-
return (jsx(Table$1.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxs(Table$1.Row, { display: "flex", children: [showSelector && (jsxs(Table$1.Header
|
|
3072
|
-
// styling resize and pinning start
|
|
3073
|
-
, {
|
|
3074
|
-
// styling resize and pinning start
|
|
3075
|
-
padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
3076
|
-
? {
|
|
3077
|
-
left: `0px`,
|
|
3078
|
-
backgroundColor: pinnedBgColor.light,
|
|
3079
|
-
position: "sticky",
|
|
3080
|
-
zIndex: 1,
|
|
3081
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3082
|
-
}
|
|
3083
|
-
: {}),
|
|
3084
|
-
// styling resize and pinning end
|
|
3085
|
-
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(),
|
|
3155
|
+
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(),
|
|
3086
3156
|
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3087
3157
|
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}`,
|
|
3088
3158
|
// styling resize and pinning start
|
|
3089
|
-
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid",
|
|
3159
|
+
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
|
|
3090
3160
|
? null
|
|
3091
|
-
: flexRender(header.column.columnDef.footer, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && (
|
|
3092
|
-
// <UpDownIcon />
|
|
3093
|
-
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}`))) }));
|
|
3161
|
+
: flexRender(header.column.columnDef.footer, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && 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}`))) }));
|
|
3094
3162
|
};
|
|
3095
3163
|
|
|
3096
|
-
|
|
3164
|
+
// Default text values
|
|
3165
|
+
const DEFAULT_HEADER_TEXTS = {
|
|
3166
|
+
pinColumn: "Pin Column",
|
|
3167
|
+
cancelPin: "Cancel Pin",
|
|
3168
|
+
sortAscending: "Sort Ascending",
|
|
3169
|
+
sortDescending: "Sort Descending",
|
|
3170
|
+
clearSorting: "Clear Sorting",
|
|
3171
|
+
};
|
|
3172
|
+
/**
|
|
3173
|
+
* TableHeader component with configurable text strings.
|
|
3174
|
+
*
|
|
3175
|
+
* @example
|
|
3176
|
+
* // Using default texts
|
|
3177
|
+
* <TableHeader />
|
|
3178
|
+
*
|
|
3179
|
+
* @example
|
|
3180
|
+
* // Customizing default texts for all columns
|
|
3181
|
+
* <TableHeader
|
|
3182
|
+
* defaultTexts={{
|
|
3183
|
+
* pinColumn: "Pin This Column",
|
|
3184
|
+
* sortAscending: "Sort A-Z"
|
|
3185
|
+
* }}
|
|
3186
|
+
* />
|
|
3187
|
+
*
|
|
3188
|
+
* @example
|
|
3189
|
+
* // Customizing texts per column via meta
|
|
3190
|
+
* const columns = [
|
|
3191
|
+
* columnHelper.accessor("name", {
|
|
3192
|
+
* header: "Name",
|
|
3193
|
+
* meta: {
|
|
3194
|
+
* headerTexts: {
|
|
3195
|
+
* pinColumn: "Pin Name Column",
|
|
3196
|
+
* sortAscending: "Sort Names A-Z"
|
|
3197
|
+
* }
|
|
3198
|
+
* }
|
|
3199
|
+
* })
|
|
3200
|
+
* ];
|
|
3201
|
+
*/
|
|
3202
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, defaultTexts = {}, }) => {
|
|
3097
3203
|
const { table } = useDataTableContext();
|
|
3098
3204
|
const SELECTION_BOX_WIDTH = 20;
|
|
3099
|
-
|
|
3100
|
-
const
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
return true;
|
|
3106
|
-
}
|
|
3107
|
-
if (table.getIsAllRowsSelected()) {
|
|
3108
|
-
return true;
|
|
3109
|
-
}
|
|
3110
|
-
if (hoveredCheckBox) {
|
|
3111
|
-
return true;
|
|
3112
|
-
}
|
|
3113
|
-
return false;
|
|
3205
|
+
// Merge default texts with provided defaults
|
|
3206
|
+
const mergedDefaultTexts = { ...DEFAULT_HEADER_TEXTS, ...defaultTexts };
|
|
3207
|
+
// Helper function to get text for a specific header
|
|
3208
|
+
const getHeaderText = (header, key) => {
|
|
3209
|
+
const columnMeta = header.column.columnDef.meta;
|
|
3210
|
+
return columnMeta?.headerTexts?.[key] || mergedDefaultTexts[key];
|
|
3114
3211
|
};
|
|
3115
3212
|
const getThProps = (header) => {
|
|
3116
3213
|
const thProps = header.column.getIsPinned()
|
|
@@ -3118,12 +3215,8 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3118
3215
|
left: showSelector
|
|
3119
3216
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3120
3217
|
: `${header.getStart("left")}px`,
|
|
3121
|
-
background: pinnedBgColor.light,
|
|
3122
3218
|
position: "sticky",
|
|
3123
3219
|
zIndex: 100 + 1,
|
|
3124
|
-
_dark: {
|
|
3125
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3126
|
-
},
|
|
3127
3220
|
}
|
|
3128
3221
|
: {};
|
|
3129
3222
|
return thProps;
|
|
@@ -3132,21 +3225,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3132
3225
|
position: "sticky",
|
|
3133
3226
|
top: 0,
|
|
3134
3227
|
};
|
|
3135
|
-
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
zIndex: 1,
|
|
3143
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3144
|
-
}
|
|
3145
|
-
: {}),
|
|
3146
|
-
// styling resize and pinning end
|
|
3147
|
-
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(),
|
|
3148
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3149
|
-
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) => {
|
|
3228
|
+
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: {
|
|
3229
|
+
base: "colorPalette.900",
|
|
3230
|
+
_dark: "colorPalette.100",
|
|
3231
|
+
},
|
|
3232
|
+
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(),
|
|
3233
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3234
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3150
3235
|
const resizeProps = {
|
|
3151
3236
|
onMouseDown: header.getResizeHandler(),
|
|
3152
3237
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3154,18 +3239,32 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3154
3239
|
};
|
|
3155
3240
|
return (jsxs(Table$1.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3156
3241
|
// styling resize and pinning start
|
|
3157
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3242
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3243
|
+
base: "colorPalette.800",
|
|
3244
|
+
_dark: "colorPalette.200",
|
|
3245
|
+
},
|
|
3246
|
+
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: {
|
|
3247
|
+
base: "colorPalette.800",
|
|
3248
|
+
_dark: "colorPalette.200",
|
|
3249
|
+
_hover: {
|
|
3250
|
+
base: "colorPalette.700",
|
|
3251
|
+
_dark: "colorPalette.300",
|
|
3252
|
+
},
|
|
3253
|
+
},
|
|
3254
|
+
bg: {
|
|
3255
|
+
base: "colorPalette.100",
|
|
3256
|
+
_dark: "colorPalette.900",
|
|
3257
|
+
_hover: {
|
|
3258
|
+
base: "colorPalette.200",
|
|
3259
|
+
_dark: "colorPalette.800",
|
|
3161
3260
|
},
|
|
3162
3261
|
}, children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3163
3262
|
? null
|
|
3164
3263
|
: flexRender(header.column.columnDef.header, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && jsx(Fragment, {}), header.column.getIsSorted() === "asc" && (jsx(BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsx(BiDownArrow, {}))] })) }), jsx(Box, { children: header.column.getIsFiltered() && jsx(MdFilterListAlt, {}) })] }) }) }), jsxs(MenuContent, { children: [!header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "pin-column", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3165
3264
|
header.column.pin("left");
|
|
3166
|
-
}, children: [jsx(MdPushPin, {}),
|
|
3265
|
+
}, children: [jsx(MdPushPin, {}), getHeaderText(header, "pinColumn")] }) })), header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "cancel-pin", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3167
3266
|
header.column.pin(false);
|
|
3168
|
-
}, children: [jsx(MdCancel, {}),
|
|
3267
|
+
}, children: [jsx(MdCancel, {}), getHeaderText(header, "cancelPin")] }) })), header.column.getCanSort() && (jsxs(Fragment, { children: [jsx(MenuItem, { asChild: true, value: "sort-ascend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3169
3268
|
table.setSorting((state) => {
|
|
3170
3269
|
return [
|
|
3171
3270
|
...state.filter((column) => {
|
|
@@ -3174,7 +3273,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3174
3273
|
{ id: header.id, desc: false },
|
|
3175
3274
|
];
|
|
3176
3275
|
});
|
|
3177
|
-
}, children: [jsx(GrAscend, {}),
|
|
3276
|
+
}, children: [jsx(GrAscend, {}), getHeaderText(header, "sortAscending")] }) }), jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3178
3277
|
table.setSorting((state) => {
|
|
3179
3278
|
return [
|
|
3180
3279
|
...state.filter((column) => {
|
|
@@ -3183,42 +3282,30 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3183
3282
|
{ id: header.id, desc: true },
|
|
3184
3283
|
];
|
|
3185
3284
|
});
|
|
3186
|
-
}, children: [jsx(GrDescend, {}),
|
|
3285
|
+
}, children: [jsx(GrDescend, {}), getHeaderText(header, "sortDescending")] }) }), header.column.getIsSorted() && (jsx(MenuItem, { asChild: true, value: "clear-sorting", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3187
3286
|
header.column.clearSorting();
|
|
3188
|
-
}, children: [jsx(MdClear, {}),
|
|
3287
|
+
}, children: [jsx(MdClear, {}), getHeaderText(header, "clearSorting")] }) }))] }))] })] }), canResize && (jsx(Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3288
|
+
? "colorPalette.700"
|
|
3289
|
+
: "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
|
|
3189
3290
|
borderRightColor: header.column.getIsResizing()
|
|
3190
|
-
? "
|
|
3191
|
-
: "
|
|
3291
|
+
? "colorPalette.700"
|
|
3292
|
+
: "colorPalette.400",
|
|
3192
3293
|
}, ...resizeProps }))] }, `chakra-table-header-${header.id}`));
|
|
3193
3294
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3194
3295
|
};
|
|
3195
3296
|
|
|
3196
|
-
const
|
|
3197
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3198
|
-
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] }) }));
|
|
3199
|
-
});
|
|
3200
|
-
|
|
3201
|
-
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" })] }) }));
|
|
3202
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3203
|
-
const { table } = useDataTableContext();
|
|
3204
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3205
|
-
return emptyComponent;
|
|
3206
|
-
}
|
|
3207
|
-
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3208
|
-
};
|
|
3209
|
-
|
|
3210
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3297
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3211
3298
|
if (variant === "greedy") {
|
|
3212
3299
|
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 }))] }) }));
|
|
3213
3300
|
}
|
|
3214
3301
|
return (jsx(TableControls, { ...controlProps, children: jsxs(Table, { ...tableProps, children: [jsx(TableHeader, { ...tableHeaderProps }), jsx(TableBody, { ...tableBodyProps }), showFooter && jsx(TableFooter, { ...tableFooterProps })] }) }));
|
|
3215
3302
|
};
|
|
3216
3303
|
|
|
3217
|
-
const TableCardContainer = ({ children, variant = "", ...props }) => {
|
|
3304
|
+
const TableCardContainer = ({ children, variant = "", gap = "1rem", gridTemplateColumns = "repeat(auto-fit, minmax(20rem, 1fr))", direction = "row", ...props }) => {
|
|
3218
3305
|
if (variant === "carousel") {
|
|
3219
|
-
return (jsx(Flex, { overflow: "
|
|
3306
|
+
return (jsx(Flex, { overflow: "auto", gap: gap, direction: direction, ...props, children: children }));
|
|
3220
3307
|
}
|
|
3221
|
-
return (jsx(Grid, { gridTemplateColumns:
|
|
3308
|
+
return (jsx(Grid, { gridTemplateColumns: gridTemplateColumns, gap: gap, ...props, children: children }));
|
|
3222
3309
|
};
|
|
3223
3310
|
|
|
3224
3311
|
const DefaultCardTitle = () => {
|
|
@@ -3247,8 +3334,8 @@ const TableComponent = ({ render = () => {
|
|
|
3247
3334
|
};
|
|
3248
3335
|
|
|
3249
3336
|
const TableLoadingComponent = ({ render, }) => {
|
|
3250
|
-
const {
|
|
3251
|
-
return jsx(Fragment, { children: render(
|
|
3337
|
+
const { query } = useDataTableServerContext();
|
|
3338
|
+
return jsx(Fragment, { children: render(query.isLoading) });
|
|
3252
3339
|
};
|
|
3253
3340
|
|
|
3254
3341
|
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
@@ -3467,6 +3554,70 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3467
3554
|
return columns;
|
|
3468
3555
|
};
|
|
3469
3556
|
|
|
3557
|
+
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3558
|
+
const { columns, translate, data } = useDataTableContext();
|
|
3559
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3560
|
+
const { accessorKey, id } = def;
|
|
3561
|
+
if (accessorKey) {
|
|
3562
|
+
return [accessorKey, def];
|
|
3563
|
+
}
|
|
3564
|
+
return [id, def];
|
|
3565
|
+
}));
|
|
3566
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3567
|
+
const totalWidths = columns
|
|
3568
|
+
.map(({ size }) => {
|
|
3569
|
+
if (!!size === false) {
|
|
3570
|
+
return 0;
|
|
3571
|
+
}
|
|
3572
|
+
if (typeof size === "number") {
|
|
3573
|
+
return size;
|
|
3574
|
+
}
|
|
3575
|
+
return 0;
|
|
3576
|
+
})
|
|
3577
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3578
|
+
const columnWidths = columns
|
|
3579
|
+
.map(({ size }) => {
|
|
3580
|
+
if (!!size === false) {
|
|
3581
|
+
return "1fr";
|
|
3582
|
+
}
|
|
3583
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3584
|
+
})
|
|
3585
|
+
.join(" ");
|
|
3586
|
+
console.log({ columnWidths }, "hadfg");
|
|
3587
|
+
const cellProps = {
|
|
3588
|
+
flex: "1 0 0%",
|
|
3589
|
+
overflow: "auto",
|
|
3590
|
+
paddingX: "2",
|
|
3591
|
+
py: "1",
|
|
3592
|
+
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
3593
|
+
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
3594
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3595
|
+
borderBottomWidth: "1px",
|
|
3596
|
+
...{ colorPalette },
|
|
3597
|
+
};
|
|
3598
|
+
if (data.length <= 0) {
|
|
3599
|
+
return jsx(Fragment, { children: emptyComponent });
|
|
3600
|
+
}
|
|
3601
|
+
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) => {
|
|
3602
|
+
return (jsx(Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3603
|
+
}) }), data.map((record) => {
|
|
3604
|
+
return (jsx(Fragment, { children: columnHeaders.map((header) => {
|
|
3605
|
+
const { cell } = columnsMap[header];
|
|
3606
|
+
const value = record[header];
|
|
3607
|
+
if (!!record === false) {
|
|
3608
|
+
return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3609
|
+
}
|
|
3610
|
+
if (cell) {
|
|
3611
|
+
return (jsx(Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3612
|
+
}
|
|
3613
|
+
if (typeof value === "object") {
|
|
3614
|
+
return (jsx(Box, { ...cellProps, children: jsx(RecordDisplay, { object: value }) }));
|
|
3615
|
+
}
|
|
3616
|
+
return jsx(Box, { ...cellProps, children: value });
|
|
3617
|
+
}) }));
|
|
3618
|
+
})] }));
|
|
3619
|
+
};
|
|
3620
|
+
|
|
3470
3621
|
const AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3471
3622
|
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3472
3623
|
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, {}) }))] }));
|
|
@@ -3550,7 +3701,7 @@ const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, childre
|
|
|
3550
3701
|
};
|
|
3551
3702
|
|
|
3552
3703
|
function removeIndex(str) {
|
|
3553
|
-
return str.replace(/\.\d+\./g,
|
|
3704
|
+
return str.replace(/\.\d+\./g, ".");
|
|
3554
3705
|
}
|
|
3555
3706
|
|
|
3556
3707
|
const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
@@ -3562,13 +3713,17 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3562
3713
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3563
3714
|
const { formState: { errors }, setValue, watch, } = useFormContext();
|
|
3564
3715
|
const fields = (watch(colLabel) ?? []);
|
|
3565
|
-
return (jsxs(
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3716
|
+
return (jsxs(Flex, { gridRow, gridColumn, flexFlow: "column", gap: 2, children: [jsxs(Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] }), jsx(Flex, { flexFlow: "column", gap: 2, children: fields.map((field, index) => (jsxs(Grid, { gridTemplateColumns: '1fr auto', gap: 2, bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: 2, borderRadius: 4, borderWidth: 1, borderColor: {
|
|
3717
|
+
base: "colorPalette.200",
|
|
3718
|
+
_dark: "colorPalette.800",
|
|
3719
|
+
}, children: [jsx(Grid, { gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsx(SchemaRenderer, { column: `${index}`,
|
|
3720
|
+
prefix: `${colLabel}.`,
|
|
3721
|
+
// @ts-expect-error find suitable types
|
|
3722
|
+
schema: { showLabel: false, ...(items ?? {}) } }) }), jsx(Flex, { justifyContent: "end", children: jsx(Button$1, { variant: "ghost", onClick: () => {
|
|
3723
|
+
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
3724
|
+
return curIndex !== index;
|
|
3725
|
+
}));
|
|
3726
|
+
}, children: jsx(Icon, { children: jsx(CgTrash, {}) }) }) })] }, `${colLabel}.${index}`))) }), jsx(Flex, { children: jsx(Button$1, { onClick: () => {
|
|
3572
3727
|
if (type === "number") {
|
|
3573
3728
|
setValue(colLabel, [...fields, 0]);
|
|
3574
3729
|
return;
|
|
@@ -3582,7 +3737,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3582
3737
|
return;
|
|
3583
3738
|
}
|
|
3584
3739
|
setValue(colLabel, [...fields, {}]);
|
|
3585
|
-
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3740
|
+
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3586
3741
|
};
|
|
3587
3742
|
|
|
3588
3743
|
const Field = React.forwardRef(function Field(props, ref) {
|
|
@@ -3593,14 +3748,26 @@ const Field = React.forwardRef(function Field(props, ref) {
|
|
|
3593
3748
|
const BooleanPicker = ({ schema, column, prefix }) => {
|
|
3594
3749
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
3595
3750
|
const { translate } = useSchemaContext();
|
|
3596
|
-
const { required, gridColumn, gridRow } = schema;
|
|
3751
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
3597
3752
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3598
3753
|
const colLabel = `${prefix}${column}`;
|
|
3599
3754
|
const value = watch(colLabel);
|
|
3600
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
3755
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3601
3756
|
gridRow, children: [jsx(CheckboxCard, { checked: value, variant: "surface", onChange: () => {
|
|
3602
3757
|
setValue(colLabel, !value);
|
|
3603
|
-
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3758
|
+
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3761
|
+
const CustomInput = ({ column, schema, prefix }) => {
|
|
3762
|
+
const formContext = useFormContext();
|
|
3763
|
+
const { inputRender } = schema;
|
|
3764
|
+
return (inputRender &&
|
|
3765
|
+
inputRender({
|
|
3766
|
+
column,
|
|
3767
|
+
schema,
|
|
3768
|
+
prefix,
|
|
3769
|
+
formContext,
|
|
3770
|
+
}));
|
|
3604
3771
|
};
|
|
3605
3772
|
|
|
3606
3773
|
const monthNamesShort = [
|
|
@@ -3690,28 +3857,54 @@ const PopoverRoot = Popover.Root;
|
|
|
3690
3857
|
const PopoverBody = Popover.Body;
|
|
3691
3858
|
const PopoverTrigger = Popover.Trigger;
|
|
3692
3859
|
|
|
3860
|
+
dayjs.extend(utc);
|
|
3693
3861
|
const DatePicker = ({ column, schema, prefix }) => {
|
|
3694
3862
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
3695
3863
|
const { translate } = useSchemaContext();
|
|
3696
|
-
const { required, gridColumn, gridRow } = schema;
|
|
3864
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", displayDateFormat = "YYYY-MM-DD", dateFormat = "YYYY-MM-DD[T]HH:mm:ss[Z]", } = schema;
|
|
3697
3865
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3698
3866
|
const colLabel = `${prefix}${column}`;
|
|
3699
3867
|
const [open, setOpen] = useState(false);
|
|
3700
3868
|
const selectedDate = watch(colLabel);
|
|
3701
|
-
const
|
|
3702
|
-
|
|
3703
|
-
|
|
3869
|
+
const displayDate = dayjs.utc(selectedDate).format(displayDateFormat);
|
|
3870
|
+
useEffect(() => {
|
|
3871
|
+
try {
|
|
3872
|
+
if (selectedDate) {
|
|
3873
|
+
// Parse the selectedDate as UTC or in a specific timezone to avoid +8 hour shift
|
|
3874
|
+
// For example, parse as UTC:
|
|
3875
|
+
const parsedDate = dayjs.utc(selectedDate);
|
|
3876
|
+
// Or if you want to parse in local timezone without shifting:
|
|
3877
|
+
// const parsedDate = dayjs.tz(selectedDate, dayjs.tz.guess());
|
|
3878
|
+
if (!parsedDate.isValid())
|
|
3879
|
+
return;
|
|
3880
|
+
// Format according to dateFormat from schema
|
|
3881
|
+
const formatted = parsedDate.format(dateFormat);
|
|
3882
|
+
// Update the form value only if different to avoid loops
|
|
3883
|
+
if (formatted !== selectedDate) {
|
|
3884
|
+
setValue(colLabel, formatted, {
|
|
3885
|
+
shouldValidate: true,
|
|
3886
|
+
shouldDirty: true,
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
catch (e) {
|
|
3892
|
+
console.error(e);
|
|
3893
|
+
}
|
|
3894
|
+
}, [selectedDate, dateFormat, colLabel, setValue]);
|
|
3895
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3896
|
+
gridRow, children: [jsxs(PopoverRoot, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
3704
3897
|
setOpen(true);
|
|
3705
|
-
}, children: selectedDate !== undefined ? `${
|
|
3898
|
+
}, justifyContent: "start", children: [jsx(MdDateRange, {}), selectedDate !== undefined ? `${displayDate}` : ""] }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
|
|
3706
3899
|
// @ts-expect-error TODO: find appropriate types
|
|
3707
3900
|
, {
|
|
3708
3901
|
// @ts-expect-error TODO: find appropriate types
|
|
3709
3902
|
selected: new Date(selectedDate),
|
|
3710
3903
|
// @ts-expect-error TODO: find appropriate types
|
|
3711
3904
|
onDateSelected: ({ date }) => {
|
|
3712
|
-
setValue(colLabel, dayjs(date).format(
|
|
3905
|
+
setValue(colLabel, dayjs(date).format(dateFormat));
|
|
3713
3906
|
setOpen(false);
|
|
3714
|
-
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3907
|
+
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3715
3908
|
};
|
|
3716
3909
|
|
|
3717
3910
|
function filterArray(array, searchTerm) {
|
|
@@ -3724,12 +3917,12 @@ function filterArray(array, searchTerm) {
|
|
|
3724
3917
|
});
|
|
3725
3918
|
}
|
|
3726
3919
|
|
|
3727
|
-
const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
3920
|
+
const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLimit = false, }) => {
|
|
3728
3921
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
3729
3922
|
const { translate } = useSchemaContext();
|
|
3730
|
-
const { required } = schema;
|
|
3923
|
+
const { required, variant } = schema;
|
|
3731
3924
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3732
|
-
const { gridColumn, gridRow, renderDisplay } = schema;
|
|
3925
|
+
const { gridColumn = "span 4", gridRow = "span 1", renderDisplay } = schema;
|
|
3733
3926
|
const [searchText, setSearchText] = useState();
|
|
3734
3927
|
const [limit, setLimit] = useState(10);
|
|
3735
3928
|
const [openSearchResult, setOpenSearchResult] = useState();
|
|
@@ -3744,28 +3937,61 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3744
3937
|
setSearchText(event.target.value);
|
|
3745
3938
|
setLimit(10);
|
|
3746
3939
|
};
|
|
3747
|
-
|
|
3940
|
+
if (variant === "radio") {
|
|
3941
|
+
return (jsx(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3942
|
+
gridRow, children: jsx(RadioGroup$1.Root, { defaultValue: "1", children: jsx(HStack, { gap: "6", children: filterArray(dataList, searchText ?? "").map((item) => {
|
|
3943
|
+
return (jsxs(RadioGroup$1.Item, { onClick: () => {
|
|
3944
|
+
if (!isMultiple) {
|
|
3945
|
+
setOpenSearchResult(false);
|
|
3946
|
+
setValue(colLabel, item);
|
|
3947
|
+
return;
|
|
3948
|
+
}
|
|
3949
|
+
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3950
|
+
setValue(colLabel, [...newSet]);
|
|
3951
|
+
}, value: item, children: [jsx(RadioGroup$1.ItemHiddenInput, {}), jsx(RadioGroup$1.ItemIndicator, {}), jsx(RadioGroup$1.ItemText, { children: !!renderDisplay === true
|
|
3952
|
+
? renderDisplay(item)
|
|
3953
|
+
: translate.t(removeIndex(`${colLabel}.${item}`)) })] }, `${colLabel}-${item}`));
|
|
3954
|
+
}) }) }) }));
|
|
3955
|
+
}
|
|
3956
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3748
3957
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3749
3958
|
const item = enumValue;
|
|
3750
|
-
if (item ===
|
|
3751
|
-
return jsx(Fragment, {
|
|
3959
|
+
if (!!item === false) {
|
|
3960
|
+
return jsx(Fragment, {});
|
|
3752
3961
|
}
|
|
3753
3962
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
3754
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3755
3963
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3756
3964
|
}, children: !!renderDisplay === true
|
|
3757
3965
|
? renderDisplay(item)
|
|
3758
3966
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
3759
3967
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3760
3968
|
setOpenSearchResult(true);
|
|
3761
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
3969
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
3762
3970
|
setOpenSearchResult(true);
|
|
3763
|
-
}, children: watchEnum ===
|
|
3971
|
+
}, justifyContent: "start", children: !!watchEnum === false
|
|
3764
3972
|
? ""
|
|
3765
|
-
: 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(`${
|
|
3973
|
+
: translate.t(removeIndex(`${colLabel}.${watchEnum ?? "null"}`)) })), 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(`${colLabel}.type_to_search`), onChange: (event) => {
|
|
3766
3974
|
onSearchChange(event);
|
|
3767
3975
|
setOpenSearchResult(true);
|
|
3768
|
-
}, autoComplete: "off", ref: ref }), jsx(PopoverTitle, {}), jsx(Text, { children: `${translate.t(`${
|
|
3976
|
+
}, autoComplete: "off", ref: ref }), jsx(PopoverTitle, {}), showTotalAndLimit && (jsx(Text, { children: `${translate.t(removeIndex(`${colLabel}.total`))}: ${count}, ${translate.t(removeIndex(`${colLabel}.showing`))} ${limit}` })), jsxs(Grid, { overflow: "auto", maxHeight: "20rem", children: [jsx(Flex, { flexFlow: "column wrap", children: dataList
|
|
3977
|
+
.filter((item) => {
|
|
3978
|
+
const searchTerm = (searchText || "").toLowerCase();
|
|
3979
|
+
if (!searchTerm)
|
|
3980
|
+
return true;
|
|
3981
|
+
// Check if the original enum value contains the search text
|
|
3982
|
+
const enumValueMatch = item
|
|
3983
|
+
.toLowerCase()
|
|
3984
|
+
.includes(searchTerm);
|
|
3985
|
+
// Check if the display value (translation) contains the search text
|
|
3986
|
+
const displayValue = !!renderDisplay === true
|
|
3987
|
+
? renderDisplay(item)
|
|
3988
|
+
: translate.t(removeIndex(`${colLabel}.${item}`));
|
|
3989
|
+
// Convert to string and check if it includes the search term
|
|
3990
|
+
const displayValueString = String(displayValue).toLowerCase();
|
|
3991
|
+
const displayValueMatch = displayValueString.includes(searchTerm);
|
|
3992
|
+
return enumValueMatch || displayValueMatch;
|
|
3993
|
+
})
|
|
3994
|
+
.map((item) => {
|
|
3769
3995
|
const selected = isMultiple
|
|
3770
3996
|
? watchEnums.some((enumValue) => item === enumValue)
|
|
3771
3997
|
: watchEnum == item;
|
|
@@ -3777,10 +4003,10 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3777
4003
|
}
|
|
3778
4004
|
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3779
4005
|
setValue(colLabel, [...newSet]);
|
|
3780
|
-
}, ...(selected ? { color: "
|
|
4006
|
+
}, ...(selected ? { color: "colorPalette.400/50" } : {}), children: !!renderDisplay === true
|
|
3781
4007
|
? renderDisplay(item)
|
|
3782
4008
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }, `${colLabel}-${item}`));
|
|
3783
|
-
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Fragment, { children: translate.t(removeIndex(`${colLabel}.
|
|
4009
|
+
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Fragment, { children: translate.t(removeIndex(`${colLabel}.empty_search_result`)) })) }))] })] }) })] }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3784
4010
|
};
|
|
3785
4011
|
|
|
3786
4012
|
function isEnteringWindow(_ref) {
|
|
@@ -4132,17 +4358,17 @@ const FileDropzone = ({ children = undefined, gridProps = {}, onDrop = () => { }
|
|
|
4132
4358
|
const filesArray = [...event.target.files];
|
|
4133
4359
|
onDrop({ files: filesArray });
|
|
4134
4360
|
};
|
|
4135
|
-
return (jsxs(Grid, { ...getColor(isDraggedOver), ref: ref, cursor: "pointer", onClick: handleClick, borderStyle: "dashed", borderColor: "
|
|
4361
|
+
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 })] }))] }));
|
|
4136
4362
|
};
|
|
4137
4363
|
|
|
4138
4364
|
const FilePicker = ({ column, schema, prefix }) => {
|
|
4139
4365
|
const { setValue, formState: { errors }, watch, } = useFormContext();
|
|
4140
4366
|
const { translate } = useSchemaContext();
|
|
4141
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4367
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", } = schema;
|
|
4142
4368
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4143
4369
|
const currentFiles = (watch(column) ?? []);
|
|
4144
4370
|
const colLabel = `${prefix}${column}`;
|
|
4145
|
-
return (jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4371
|
+
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 }) => {
|
|
4146
4372
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4147
4373
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4148
4374
|
}, placeholder: translate.t(removeIndex(`${colLabel}.fileDropzone`)) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4150,10 +4376,19 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4150
4376
|
setValue(column, currentFiles.filter(({ name }) => {
|
|
4151
4377
|
return name !== file.name;
|
|
4152
4378
|
}));
|
|
4153
|
-
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [jsx(Box, { children: file.name }), jsx(TiDeleteOutline, {})] }) }, file.name));
|
|
4154
|
-
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4379
|
+
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [file.type.startsWith("image/") && (jsx(Image, { src: URL.createObjectURL(file), alt: file.name, boxSize: "50px", objectFit: "cover", borderRadius: "md", marginRight: "2" })), jsx(Box, { children: file.name }), jsx(TiDeleteOutline, {})] }) }, file.name));
|
|
4380
|
+
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4155
4381
|
};
|
|
4156
4382
|
|
|
4383
|
+
const ToggleTip = React.forwardRef(function ToggleTip(props, ref) {
|
|
4384
|
+
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
4385
|
+
return (jsxs(Popover.Root, { ...rest, positioning: { ...rest.positioning, gutter: 4 }, children: [jsx(Popover.Trigger, { asChild: true, children: children }), jsx(Portal, { disabled: !portalled, container: portalRef, children: jsx(Popover.Positioner, { children: jsxs(Popover.Content, { width: "auto", px: "2", py: "1", textStyle: "xs", rounded: "sm", ref: ref, children: [showArrow && (jsx(Popover.Arrow, { children: jsx(Popover.ArrowTip, {}) })), content] }) }) })] }));
|
|
4386
|
+
});
|
|
4387
|
+
const InfoTip = React.forwardRef(function InfoTip(props, ref) {
|
|
4388
|
+
const { children, ...rest } = props;
|
|
4389
|
+
return (jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsx(IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "colorPalette", children: jsx(HiOutlineInformationCircle, {}) }) }));
|
|
4390
|
+
});
|
|
4391
|
+
|
|
4157
4392
|
const getTableData = async ({ serverUrl, in_table, searching = "", where = [], limit = 10, offset = 0, }) => {
|
|
4158
4393
|
if (serverUrl === undefined || serverUrl.length == 0) {
|
|
4159
4394
|
throw new Error("The serverUrl is missing");
|
|
@@ -4185,15 +4420,18 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
|
|
|
4185
4420
|
const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
4186
4421
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
4187
4422
|
const { serverUrl, idMap, setIdMap, translate, schema: parentSchema, } = useSchemaContext();
|
|
4188
|
-
const { required, gridColumn, gridRow, renderDisplay, foreign_key } = schema;
|
|
4423
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", renderDisplay, foreign_key, } = schema;
|
|
4189
4424
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4190
4425
|
const { table, column: column_ref, display_column, } = foreign_key;
|
|
4191
|
-
const [searchText, setSearchText] = useState();
|
|
4426
|
+
const [searchText, setSearchText] = useState("");
|
|
4192
4427
|
const [limit, setLimit] = useState(10);
|
|
4193
4428
|
const [openSearchResult, setOpenSearchResult] = useState();
|
|
4194
4429
|
const [page, setPage] = useState(0);
|
|
4195
4430
|
const ref = useRef(null);
|
|
4196
4431
|
const colLabel = `${prefix}${column}`;
|
|
4432
|
+
const watchId = watch(colLabel);
|
|
4433
|
+
const watchIds = isMultiple ? (watch(colLabel) ?? []) : [];
|
|
4434
|
+
// Query for search results
|
|
4197
4435
|
const query = useQuery({
|
|
4198
4436
|
queryKey: [`idpicker`, { column, searchText, limit, page }],
|
|
4199
4437
|
queryFn: async () => {
|
|
@@ -4202,7 +4440,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4202
4440
|
searching: searchText ?? "",
|
|
4203
4441
|
in_table: table,
|
|
4204
4442
|
limit: limit,
|
|
4205
|
-
offset: page *
|
|
4443
|
+
offset: page * limit,
|
|
4206
4444
|
});
|
|
4207
4445
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
4208
4446
|
return [
|
|
@@ -4217,27 +4455,27 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4217
4455
|
});
|
|
4218
4456
|
return data;
|
|
4219
4457
|
},
|
|
4220
|
-
enabled:
|
|
4458
|
+
enabled: openSearchResult === true,
|
|
4221
4459
|
staleTime: 300000,
|
|
4222
4460
|
});
|
|
4223
|
-
|
|
4224
|
-
const
|
|
4225
|
-
const count = data?.count ?? 0;
|
|
4226
|
-
const isDirty = (searchText?.length ?? 0) > 0;
|
|
4227
|
-
const watchId = watch(colLabel);
|
|
4228
|
-
const watchIds = (watch(colLabel) ?? []);
|
|
4229
|
-
useQuery({
|
|
4461
|
+
// Query for currently selected items (to display them properly)
|
|
4462
|
+
const queryDefault = useQuery({
|
|
4230
4463
|
queryKey: [
|
|
4231
|
-
`idpicker`,
|
|
4232
|
-
{ form: parentSchema.title, column,
|
|
4464
|
+
`idpicker-default`,
|
|
4465
|
+
{ form: parentSchema.title, column, id: isMultiple ? watchIds : watchId },
|
|
4233
4466
|
],
|
|
4234
4467
|
queryFn: async () => {
|
|
4468
|
+
if (!watchId && (!watchIds || watchIds.length === 0)) {
|
|
4469
|
+
return { data: [] };
|
|
4470
|
+
}
|
|
4471
|
+
const searchValue = isMultiple ? watchIds.join(",") : watchId;
|
|
4235
4472
|
const data = await getTableData({
|
|
4236
4473
|
serverUrl,
|
|
4237
|
-
searching:
|
|
4474
|
+
searching: searchValue,
|
|
4238
4475
|
in_table: table,
|
|
4239
|
-
|
|
4240
|
-
|
|
4476
|
+
where: [{ id: column_ref, value: isMultiple ? watchIds : watchId }],
|
|
4477
|
+
limit: isMultiple ? watchIds.length : 1,
|
|
4478
|
+
offset: 0,
|
|
4241
4479
|
});
|
|
4242
4480
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
4243
4481
|
return [
|
|
@@ -4252,12 +4490,45 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4252
4490
|
});
|
|
4253
4491
|
return data;
|
|
4254
4492
|
},
|
|
4493
|
+
enabled: isMultiple
|
|
4494
|
+
? Array.isArray(watchIds) && watchIds.length > 0
|
|
4495
|
+
: !!watchId,
|
|
4255
4496
|
});
|
|
4497
|
+
// Effect to load selected values when component mounts
|
|
4498
|
+
useEffect(() => {
|
|
4499
|
+
if (isMultiple ? watchIds.length > 0 : !!watchId) {
|
|
4500
|
+
queryDefault.refetch();
|
|
4501
|
+
}
|
|
4502
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4503
|
+
}, []);
|
|
4504
|
+
// Effect to trigger initial data fetch when popover opens
|
|
4505
|
+
useEffect(() => {
|
|
4506
|
+
if (openSearchResult) {
|
|
4507
|
+
// Reset search text when opening the popover
|
|
4508
|
+
setSearchText("");
|
|
4509
|
+
// Reset page to first page
|
|
4510
|
+
setPage(0);
|
|
4511
|
+
// Fetch initial data
|
|
4512
|
+
query.refetch();
|
|
4513
|
+
}
|
|
4514
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4515
|
+
}, [openSearchResult]);
|
|
4256
4516
|
const onSearchChange = async (event) => {
|
|
4257
4517
|
setSearchText(event.target.value);
|
|
4258
4518
|
setPage(0);
|
|
4259
|
-
|
|
4519
|
+
query.refetch();
|
|
4520
|
+
};
|
|
4521
|
+
const handleLimitChange = (event) => {
|
|
4522
|
+
const newLimit = Number(event.target.value);
|
|
4523
|
+
setLimit(newLimit);
|
|
4524
|
+
// Reset to first page when changing limit
|
|
4525
|
+
setPage(0);
|
|
4526
|
+
// Trigger a new search with the updated limit
|
|
4527
|
+
query.refetch();
|
|
4260
4528
|
};
|
|
4529
|
+
const { isLoading, isFetching, data, isPending, isError } = query;
|
|
4530
|
+
const dataList = data?.data ?? [];
|
|
4531
|
+
const count = data?.count ?? 0;
|
|
4261
4532
|
const getPickedValue = () => {
|
|
4262
4533
|
if (Object.keys(idMap).length <= 0) {
|
|
4263
4534
|
return "";
|
|
@@ -4266,47 +4537,57 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4266
4537
|
if (record === undefined) {
|
|
4267
4538
|
return "";
|
|
4268
4539
|
}
|
|
4540
|
+
if (!!renderDisplay === true) {
|
|
4541
|
+
return renderDisplay(record);
|
|
4542
|
+
}
|
|
4269
4543
|
return record[display_column];
|
|
4270
4544
|
};
|
|
4271
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.
|
|
4545
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.field_label`)))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4272
4546
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchIds.map((id) => {
|
|
4273
4547
|
const item = idMap[id];
|
|
4274
4548
|
if (item === undefined) {
|
|
4275
4549
|
return (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.undefined`)) }, id));
|
|
4276
4550
|
}
|
|
4277
4551
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
4278
|
-
setValue(
|
|
4552
|
+
setValue(colLabel, watchIds.filter((itemId) => itemId !== item[column_ref]));
|
|
4279
4553
|
}, children: !!renderDisplay === true
|
|
4280
4554
|
? renderDisplay(item)
|
|
4281
4555
|
: item[display_column] }, id));
|
|
4282
4556
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4283
4557
|
setOpenSearchResult(true);
|
|
4284
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
4558
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
4285
4559
|
setOpenSearchResult(true);
|
|
4286
|
-
}, 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}.
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4560
|
+
}, justifyContent: "start", children: queryDefault.isLoading ? jsx(Spinner, { size: "sm" }) : 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}.type_to_search`)), onChange: onSearchChange, autoComplete: "off", ref: ref, value: searchText }), jsx(PopoverTitle, {}), openSearchResult && (jsxs(Fragment, { children: [(isFetching || isLoading || isPending) && jsx(Spinner, {}), isError && (jsx(Icon, { color: "red.400", children: jsx(BiError, {}) })), jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [jsxs(Flex, { alignItems: "center", gap: "2", children: [jsx(InfoTip, { children: `${translate.t(removeIndex(`${colLabel}.total`))} ${count}, ${translate.t(removeIndex(`${colLabel}.showing`))} ${limit} ${translate.t(removeIndex(`${colLabel}.per_page`), "per page")}` }), jsxs(Text, { fontSize: "sm", fontWeight: "bold", children: [count, jsxs(Text, { as: "span", fontSize: "xs", ml: "1", color: "gray.500", children: ["/ ", count > 0 ? `${page * limit + 1}-${Math.min((page + 1) * limit, count)}` : '0'] })] })] }), jsx(Box, { children: jsxs("select", { value: limit, onChange: handleLimitChange, style: {
|
|
4561
|
+
padding: "4px 8px",
|
|
4562
|
+
borderRadius: "4px",
|
|
4563
|
+
border: "1px solid #ccc",
|
|
4564
|
+
fontSize: "14px",
|
|
4565
|
+
}, children: [jsx("option", { value: "5", children: "5" }), jsx("option", { value: "10", children: "10" }), jsx("option", { value: "20", children: "20" }), jsx("option", { value: "30", children: "30" })] }) })] }), jsx(Grid, { overflowY: "auto", children: dataList.length > 0 ? (jsx(Flex, { flexFlow: "column wrap", gap: 1, children: dataList.map((item) => {
|
|
4566
|
+
const selected = isMultiple
|
|
4567
|
+
? watchIds.some((id) => item[column_ref] === id)
|
|
4568
|
+
: watchId === item[column_ref];
|
|
4569
|
+
return (jsx(Box, { cursor: "pointer", onClick: () => {
|
|
4570
|
+
if (!isMultiple) {
|
|
4571
|
+
setOpenSearchResult(false);
|
|
4572
|
+
setValue(colLabel, item[column_ref]);
|
|
4573
|
+
return;
|
|
4574
|
+
}
|
|
4575
|
+
// For multiple selection, don't add if already selected
|
|
4576
|
+
if (selected)
|
|
4577
|
+
return;
|
|
4578
|
+
const newSet = new Set([
|
|
4579
|
+
...(watchIds ?? []),
|
|
4580
|
+
item[column_ref],
|
|
4581
|
+
]);
|
|
4582
|
+
setValue(colLabel, [...newSet]);
|
|
4583
|
+
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected
|
|
4584
|
+
? { color: "colorPalette.400/50", fontWeight: "bold" }
|
|
4585
|
+
: {}), children: !!renderDisplay === true
|
|
4586
|
+
? renderDisplay(item)
|
|
4587
|
+
: item[display_column] }, item[column_ref]));
|
|
4588
|
+
}) })) : (jsx(Text, { children: searchText
|
|
4589
|
+
? translate.t(removeIndex(`${colLabel}.empty_search_result`))
|
|
4590
|
+
: translate.t(removeIndex(`${colLabel}.initial_results`)) })) }), jsx(PaginationRoot, { justifySelf: "center", count: count, pageSize: limit, 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`)) }))] }));
|
|
4310
4591
|
};
|
|
4311
4592
|
|
|
4312
4593
|
const NumberInputRoot = React.forwardRef(function NumberInput$1(props, ref) {
|
|
@@ -4320,17 +4601,17 @@ NumberInput.Label;
|
|
|
4320
4601
|
const NumberInputField = ({ schema, column, prefix, }) => {
|
|
4321
4602
|
const { setValue, formState: { errors }, watch, } = useFormContext();
|
|
4322
4603
|
const { translate } = useSchemaContext();
|
|
4323
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4604
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4324
4605
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4325
4606
|
const colLabel = `${prefix}${column}`;
|
|
4326
4607
|
const value = watch(`${colLabel}`);
|
|
4327
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4608
|
+
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) => {
|
|
4328
4609
|
setValue(`${colLabel}`, Number(event.target.value));
|
|
4329
|
-
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4610
|
+
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4330
4611
|
};
|
|
4331
4612
|
|
|
4332
4613
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
4333
|
-
const { properties,
|
|
4614
|
+
const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
|
|
4334
4615
|
const { translate } = useSchemaContext();
|
|
4335
4616
|
const colLabel = `${prefix}${column}`;
|
|
4336
4617
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -4338,25 +4619,28 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4338
4619
|
if (properties === undefined) {
|
|
4339
4620
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4340
4621
|
}
|
|
4341
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label",
|
|
4622
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [showLabel && (jsxs(Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] })), jsx(Grid, { bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: 2, borderRadius: 4, borderWidth: 1, borderColor: {
|
|
4623
|
+
base: "colorPalette.200",
|
|
4624
|
+
_dark: "colorPalette.800",
|
|
4625
|
+
}, gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: Object.keys(properties ?? {}).map((key) => {
|
|
4342
4626
|
return (
|
|
4343
4627
|
// @ts-expect-error find suitable types
|
|
4344
4628
|
jsx(ColumnRenderer, { column: `${key}`,
|
|
4345
4629
|
prefix: `${prefix}${column}.`,
|
|
4346
4630
|
properties }, `form-${colLabel}-${key}`));
|
|
4347
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4631
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4348
4632
|
};
|
|
4349
4633
|
|
|
4350
4634
|
const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
4351
4635
|
const { formState: { errors }, setValue, getValues, } = useFormContext();
|
|
4352
4636
|
const { translate } = useSchemaContext();
|
|
4353
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4637
|
+
const { required, gridColumn = "span 12", gridRow = "span 1" } = schema;
|
|
4354
4638
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4355
4639
|
const entries = Object.entries(getValues(column) ?? {});
|
|
4356
4640
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4357
4641
|
const [newKey, setNewKey] = useState();
|
|
4358
4642
|
const [newValue, setNewValue] = useState();
|
|
4359
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
4643
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4360
4644
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4361
4645
|
const filtered = entries.filter(([target]) => {
|
|
4362
4646
|
return target !== key;
|
|
@@ -4396,16 +4680,16 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4396
4680
|
setShowNewEntries(true);
|
|
4397
4681
|
setNewKey(undefined);
|
|
4398
4682
|
setNewValue(undefined);
|
|
4399
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4683
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4400
4684
|
};
|
|
4401
4685
|
|
|
4402
4686
|
const StringInputField = ({ column, schema, prefix, }) => {
|
|
4403
4687
|
const { register, formState: { errors }, } = useFormContext();
|
|
4404
4688
|
const { translate } = useSchemaContext();
|
|
4405
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4689
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4406
4690
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4407
4691
|
const colLabel = `${prefix}${column}`;
|
|
4408
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4692
|
+
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn, gridRow: gridRow, children: [jsx(Input, { ...register(`${colLabel}`, { required: isRequired }), autoComplete: "off" }), errors[colLabel] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4409
4693
|
};
|
|
4410
4694
|
|
|
4411
4695
|
const RadioCardItem = React.forwardRef(function RadioCardItem(props, ref) {
|
|
@@ -4503,9 +4787,180 @@ const TagPicker = ({ column, schema, prefix }) => {
|
|
|
4503
4787
|
}), errors[`${column}`] && (jsx(Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4504
4788
|
};
|
|
4505
4789
|
|
|
4790
|
+
const TextAreaInput = ({ column, schema, prefix, }) => {
|
|
4791
|
+
const { register, formState: { errors }, } = useFormContext();
|
|
4792
|
+
const { translate } = useSchemaContext();
|
|
4793
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4794
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
4795
|
+
const colLabel = `${prefix}${column}`;
|
|
4796
|
+
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(Textarea, { ...register(`${colLabel}`, { required: isRequired }), autoComplete: "off" }), errors[colLabel] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4797
|
+
};
|
|
4798
|
+
|
|
4799
|
+
function TimePicker$1({ hour, setHour, minute, setMinute, meridiem, setMeridiem, meridiemLabel = {
|
|
4800
|
+
am: "am",
|
|
4801
|
+
pm: "pm",
|
|
4802
|
+
}, onChange = (_newValue) => { }, }) {
|
|
4803
|
+
// Refs for focus management
|
|
4804
|
+
const hourInputRef = useRef(null);
|
|
4805
|
+
const minuteInputRef = useRef(null);
|
|
4806
|
+
useRef(null);
|
|
4807
|
+
// Centralized handler for key events, value changes, and focus management
|
|
4808
|
+
const handleKeyDown = (e, field) => {
|
|
4809
|
+
const input = e.target;
|
|
4810
|
+
const value = input.value;
|
|
4811
|
+
// Handle navigation between fields
|
|
4812
|
+
if (e.key === "Tab") {
|
|
4813
|
+
// Tab is handled by the browser, no need to override
|
|
4814
|
+
return;
|
|
4815
|
+
}
|
|
4816
|
+
if (e.key === ":" && field === "hour") {
|
|
4817
|
+
e.preventDefault();
|
|
4818
|
+
minuteInputRef.current?.focus();
|
|
4819
|
+
return;
|
|
4820
|
+
}
|
|
4821
|
+
if (e.key === "Backspace" && value === "") {
|
|
4822
|
+
e.preventDefault();
|
|
4823
|
+
if (field === "minute") {
|
|
4824
|
+
hourInputRef.current?.focus();
|
|
4825
|
+
}
|
|
4826
|
+
else if (field === "meridiem") {
|
|
4827
|
+
minuteInputRef.current?.focus();
|
|
4828
|
+
}
|
|
4829
|
+
return;
|
|
4830
|
+
}
|
|
4831
|
+
// Handle number inputs
|
|
4832
|
+
if (field === "hour") {
|
|
4833
|
+
if (e.key.match(/^[0-9]$/)) {
|
|
4834
|
+
const newValue = value + e.key;
|
|
4835
|
+
const numValue = parseInt(newValue, 10);
|
|
4836
|
+
console.log("newValue", newValue, numValue);
|
|
4837
|
+
if (numValue > 12) {
|
|
4838
|
+
const digitValue = parseInt(e.key, 10);
|
|
4839
|
+
setHour(digitValue);
|
|
4840
|
+
onChange({ hour: digitValue, minute, meridiem });
|
|
4841
|
+
return;
|
|
4842
|
+
}
|
|
4843
|
+
// Auto-advance to minutes if we have a valid hour (1-12)
|
|
4844
|
+
if (numValue >= 1 && numValue <= 12) {
|
|
4845
|
+
// Set the hour value
|
|
4846
|
+
setHour(numValue);
|
|
4847
|
+
onChange({ hour: numValue, minute, meridiem });
|
|
4848
|
+
// Move to minute input
|
|
4849
|
+
e.preventDefault();
|
|
4850
|
+
minuteInputRef.current?.focus();
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
else if (field === "minute") {
|
|
4855
|
+
if (e.key.match(/^[0-9]$/)) {
|
|
4856
|
+
const newValue = value + e.key;
|
|
4857
|
+
const numValue = parseInt(newValue, 10);
|
|
4858
|
+
console.log("newValue minute", newValue, numValue, numValue > 60, numValue >= 0 && numValue <= 59, e.key);
|
|
4859
|
+
if (numValue > 60) {
|
|
4860
|
+
const digitValue = parseInt(e.key, 10);
|
|
4861
|
+
setMinute(digitValue);
|
|
4862
|
+
onChange({ hour, minute: digitValue, meridiem });
|
|
4863
|
+
return;
|
|
4864
|
+
}
|
|
4865
|
+
// Auto-advance to meridiem if we have a valid minute (0-59)
|
|
4866
|
+
if (numValue >= 0 && numValue <= 59) {
|
|
4867
|
+
// Set the minute value
|
|
4868
|
+
setMinute(numValue);
|
|
4869
|
+
onChange({ hour, minute: numValue, meridiem });
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
};
|
|
4874
|
+
// Handle meridiem button click
|
|
4875
|
+
const handleMeridiemClick = (newMeridiem) => {
|
|
4876
|
+
setMeridiem(newMeridiem);
|
|
4877
|
+
onChange({ hour, minute, meridiem: newMeridiem });
|
|
4878
|
+
};
|
|
4879
|
+
const handleClear = () => {
|
|
4880
|
+
setHour(null);
|
|
4881
|
+
setMinute(null);
|
|
4882
|
+
setMeridiem(null);
|
|
4883
|
+
onChange({ hour: null, minute: null, meridiem: null });
|
|
4884
|
+
// Focus the hour field after clearing
|
|
4885
|
+
hourInputRef.current?.focus();
|
|
4886
|
+
};
|
|
4887
|
+
return (jsx(Flex, { direction: "column", gap: 3, children: jsxs(Grid, { justifyContent: "center", alignItems: "center", templateColumns: "60px 10px 60px 90px auto", gap: "2", width: "auto", minWidth: "250px", children: [jsx(Input, { ref: hourInputRef, type: "text", value: hour === null ? "" : hour.toString().padStart(2, "0"), onKeyDown: (e) => handleKeyDown(e, "hour"), placeholder: "HH", maxLength: 2, textAlign: "center" }), jsx(Text, { children: ":" }), jsx(Input, { ref: minuteInputRef, type: "text", value: minute === null ? "" : minute.toString().padStart(2, "0"), onKeyDown: (e) => handleKeyDown(e, "minute"), placeholder: "MM", maxLength: 2, textAlign: "center" }), jsxs(Flex, { gap: "1", children: [jsx(Button$1, { size: "sm", colorScheme: meridiem === "am" ? "blue" : "gray", variant: meridiem === "am" ? "solid" : "outline", onClick: () => handleMeridiemClick("am"), width: "40px", children: meridiemLabel.am }), jsx(Button$1, { size: "sm", colorScheme: meridiem === "pm" ? "blue" : "gray", variant: meridiem === "pm" ? "solid" : "outline", onClick: () => handleMeridiemClick("pm"), width: "40px", children: meridiemLabel.pm })] }), jsx(Button$1, { onClick: handleClear, size: "sm", variant: "ghost", children: jsx(MdCancel, {}) })] }) }));
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
const TimePicker = ({ column, schema, prefix }) => {
|
|
4891
|
+
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
4892
|
+
const { translate } = useSchemaContext();
|
|
4893
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", timeFormat = "HH:mm:ss", displayTimeFormat = "hh:mm A", } = schema;
|
|
4894
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
4895
|
+
const colLabel = `${prefix}${column}`;
|
|
4896
|
+
const [open, setOpen] = useState(false);
|
|
4897
|
+
const value = watch(colLabel);
|
|
4898
|
+
const displayedTime = dayjs(`1970-01-01T${value}Z`).isValid()
|
|
4899
|
+
? dayjs(`1970-01-01T${value}Z`).utc().format(displayTimeFormat)
|
|
4900
|
+
: "";
|
|
4901
|
+
// Parse the initial time parts from the ISO time string (HH:mm:ss)
|
|
4902
|
+
const parseTime = (isoTime) => {
|
|
4903
|
+
if (!isoTime)
|
|
4904
|
+
return { hour: 12, minute: 0, meridiem: "am" };
|
|
4905
|
+
const parsed = dayjs(`1970-01-01T${isoTime}Z`).utc();
|
|
4906
|
+
if (!parsed.isValid())
|
|
4907
|
+
return { hour: 12, minute: 0, meridiem: "am" };
|
|
4908
|
+
let hour = parsed.hour();
|
|
4909
|
+
const minute = parsed.minute();
|
|
4910
|
+
const meridiem = hour >= 12 ? "pm" : "am";
|
|
4911
|
+
if (hour === 0)
|
|
4912
|
+
hour = 12;
|
|
4913
|
+
else if (hour > 12)
|
|
4914
|
+
hour -= 12;
|
|
4915
|
+
return { hour, minute, meridiem };
|
|
4916
|
+
};
|
|
4917
|
+
const initialTime = parseTime(value);
|
|
4918
|
+
const [hour, setHour] = useState(initialTime.hour);
|
|
4919
|
+
const [minute, setMinute] = useState(initialTime.minute);
|
|
4920
|
+
const [meridiem, setMeridiem] = useState(initialTime.meridiem);
|
|
4921
|
+
useEffect(() => {
|
|
4922
|
+
const { hour, minute, meridiem } = parseTime(value);
|
|
4923
|
+
setHour(hour);
|
|
4924
|
+
setMinute(minute);
|
|
4925
|
+
setMeridiem(meridiem);
|
|
4926
|
+
}, [value]);
|
|
4927
|
+
// Convert hour, minute, meridiem to 24-hour ISO time string
|
|
4928
|
+
const toIsoTime = (hour, minute, meridiem) => {
|
|
4929
|
+
if (hour === null || minute === null || meridiem === null)
|
|
4930
|
+
return null;
|
|
4931
|
+
let h = hour;
|
|
4932
|
+
if (meridiem === "am" && hour === 12)
|
|
4933
|
+
h = 0;
|
|
4934
|
+
else if (meridiem === "pm" && hour < 12)
|
|
4935
|
+
h = hour + 12;
|
|
4936
|
+
return dayjs(`1970-01-01T${h.toString().padStart(2, "0")}:${minute.toString().padStart(2, "0")}:00Z`)
|
|
4937
|
+
.utc()
|
|
4938
|
+
.format(timeFormat);
|
|
4939
|
+
};
|
|
4940
|
+
// Handle changes to time parts
|
|
4941
|
+
const handleTimeChange = ({ hour: newHour, minute: newMinute, meridiem: newMeridiem, }) => {
|
|
4942
|
+
setHour(newHour);
|
|
4943
|
+
setMinute(newMinute);
|
|
4944
|
+
setMeridiem(newMeridiem);
|
|
4945
|
+
const isoTime = toIsoTime(newHour, newMinute, newMeridiem);
|
|
4946
|
+
setValue(colLabel, isoTime, { shouldValidate: true, shouldDirty: true });
|
|
4947
|
+
};
|
|
4948
|
+
const containerRef = useRef(null);
|
|
4949
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4950
|
+
gridRow, children: [jsxs(Popover.Root, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsx(Popover.Trigger, { asChild: true, children: jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
4951
|
+
setOpen(true);
|
|
4952
|
+
}, justifyContent: "start", children: [jsx(IoMdClock, {}), !!value ? `${displayedTime}` : ""] }) }), jsx(Portal, { children: jsx(Popover.Positioner, { children: jsx(Popover.Content, { ref: containerRef, children: jsx(Popover.Body, { children: jsx(TimePicker$1, { hour: hour, setHour: setHour, minute: minute, setMinute: setMinute, meridiem: meridiem, setMeridiem: setMeridiem, onChange: handleTimeChange, meridiemLabel: {
|
|
4953
|
+
am: translate.t(removeIndex(`common.am`)),
|
|
4954
|
+
pm: translate.t(removeIndex(`common.pm`)),
|
|
4955
|
+
} }) }) }) }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4956
|
+
};
|
|
4957
|
+
|
|
4506
4958
|
const SchemaRenderer = ({ schema, prefix, column, }) => {
|
|
4507
4959
|
const colSchema = schema;
|
|
4508
|
-
const { type, variant, properties: innerProperties, foreign_key, items, } = schema;
|
|
4960
|
+
const { type, variant, properties: innerProperties, foreign_key, format, items, } = schema;
|
|
4961
|
+
if (variant === "custom-input") {
|
|
4962
|
+
return jsx(CustomInput, { schema: colSchema, prefix, column });
|
|
4963
|
+
}
|
|
4509
4964
|
if (type === "string") {
|
|
4510
4965
|
if ((schema.enum ?? []).length > 0) {
|
|
4511
4966
|
return jsx(EnumPicker, { schema: colSchema, prefix, column });
|
|
@@ -4514,9 +4969,15 @@ const SchemaRenderer = ({ schema, prefix, column, }) => {
|
|
|
4514
4969
|
idPickerSanityCheck(column, foreign_key);
|
|
4515
4970
|
return jsx(IdPicker, { schema: colSchema, prefix, column });
|
|
4516
4971
|
}
|
|
4517
|
-
if (
|
|
4972
|
+
if (format === "date") {
|
|
4518
4973
|
return jsx(DatePicker, { schema: colSchema, prefix, column });
|
|
4519
4974
|
}
|
|
4975
|
+
if (format === "time") {
|
|
4976
|
+
return jsx(TimePicker, { schema: colSchema, prefix, column });
|
|
4977
|
+
}
|
|
4978
|
+
if (variant === "text-area") {
|
|
4979
|
+
return jsx(TextAreaInput, { schema: colSchema, prefix, column });
|
|
4980
|
+
}
|
|
4520
4981
|
return jsx(StringInputField, { schema: colSchema, prefix, column });
|
|
4521
4982
|
}
|
|
4522
4983
|
if (type === "number" || type === "integer") {
|
|
@@ -4563,85 +5024,102 @@ const ColumnRenderer = ({ column, properties, prefix, }) => {
|
|
|
4563
5024
|
};
|
|
4564
5025
|
|
|
4565
5026
|
const ArrayViewer = ({ schema, column, prefix }) => {
|
|
4566
|
-
const {
|
|
5027
|
+
const { gridColumn = "span 12", gridRow = "span 1", required, items, } = schema;
|
|
4567
5028
|
const { translate } = useSchemaContext();
|
|
4568
5029
|
const colLabel = `${prefix}${column}`;
|
|
4569
5030
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4570
5031
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4571
5032
|
const values = watch(colLabel) ?? [];
|
|
4572
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label", gridColumn: "1/span12", children: [`${translate.t(removeIndex(`${colLabel}.
|
|
4573
|
-
|
|
4574
|
-
|
|
5033
|
+
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(Flex, { flexFlow: "column", gap: 1, children: values.map((field, index) => (jsx(Flex, { flexFlow: "column", bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: "2", borderRadius: "md", borderWidth: "thin", borderColor: {
|
|
5034
|
+
base: "colorPalette.200",
|
|
5035
|
+
_dark: "colorPalette.800",
|
|
5036
|
+
}, children: jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsx(SchemaViewer, { column: `${index}`,
|
|
5037
|
+
prefix: `${colLabel}.`,
|
|
5038
|
+
// @ts-expect-error find suitable types
|
|
5039
|
+
schema: { showLabel: false, ...(items ?? {}) } }) }) }, `form-${prefix}${column}.${index}`))) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4575
5040
|
};
|
|
4576
5041
|
|
|
4577
5042
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
4578
5043
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4579
5044
|
const { translate } = useSchemaContext();
|
|
4580
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5045
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4581
5046
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4582
5047
|
const colLabel = `${prefix}${column}`;
|
|
4583
5048
|
const value = watch(colLabel);
|
|
4584
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
5049
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4585
5050
|
gridRow, children: [jsx(Text, { children: value
|
|
4586
5051
|
? translate.t(removeIndex(`${colLabel}.true`))
|
|
4587
|
-
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
5052
|
+
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
5053
|
+
};
|
|
5054
|
+
|
|
5055
|
+
const CustomViewer = ({ column, schema, prefix }) => {
|
|
5056
|
+
const formContext = useFormContext();
|
|
5057
|
+
const { inputViewerRender } = schema;
|
|
5058
|
+
return (inputViewerRender &&
|
|
5059
|
+
inputViewerRender({
|
|
5060
|
+
column,
|
|
5061
|
+
schema,
|
|
5062
|
+
prefix,
|
|
5063
|
+
formContext,
|
|
5064
|
+
}));
|
|
4588
5065
|
};
|
|
4589
5066
|
|
|
4590
5067
|
const DateViewer = ({ column, schema, prefix }) => {
|
|
4591
5068
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4592
5069
|
const { translate } = useSchemaContext();
|
|
4593
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5070
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", displayDateFormat = "YYYY-MM-DD", } = schema;
|
|
4594
5071
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4595
5072
|
const colLabel = `${prefix}${column}`;
|
|
4596
5073
|
const selectedDate = watch(colLabel);
|
|
4597
|
-
|
|
4598
|
-
|
|
5074
|
+
const displayDate = dayjs.utc(selectedDate).format(displayDateFormat);
|
|
5075
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
5076
|
+
gridRow, children: [jsxs(Text, { children: [" ", selectedDate !== undefined ? displayDate : ""] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4599
5077
|
};
|
|
4600
5078
|
|
|
5079
|
+
function translateWrapper({ prefix, column, label, translate, }) {
|
|
5080
|
+
return translate.t(removeIndex(`${prefix}${column}.${label}`));
|
|
5081
|
+
}
|
|
5082
|
+
|
|
4601
5083
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
4602
5084
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4603
5085
|
const { translate } = useSchemaContext();
|
|
4604
5086
|
const { required } = schema;
|
|
4605
5087
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4606
|
-
const { gridColumn, gridRow, renderDisplay } = schema;
|
|
5088
|
+
const { gridColumn = "span 4", gridRow = "span 1", renderDisplay } = schema;
|
|
4607
5089
|
const colLabel = `${prefix}${column}`;
|
|
4608
5090
|
const watchEnum = watch(colLabel);
|
|
4609
5091
|
const watchEnums = (watch(colLabel) ?? []);
|
|
4610
|
-
|
|
5092
|
+
const customTranslate = (label) => {
|
|
5093
|
+
return translateWrapper({ prefix, column, label, translate });
|
|
5094
|
+
};
|
|
5095
|
+
return (jsxs(Field, { label: `${customTranslate(`field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4611
5096
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
4612
5097
|
const item = enumValue;
|
|
4613
5098
|
if (item === undefined) {
|
|
4614
5099
|
return jsx(Fragment, { children: "undefined" });
|
|
4615
5100
|
}
|
|
4616
|
-
return (jsx(Tag, {
|
|
5101
|
+
return (jsx(Tag, { children: !!renderDisplay === true
|
|
4617
5102
|
? renderDisplay(item)
|
|
4618
|
-
:
|
|
4619
|
-
}) })), !isMultiple &&
|
|
5103
|
+
: customTranslate(item) }));
|
|
5104
|
+
}) })), !isMultiple && jsx(Text, { children: customTranslate(watchEnum) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: customTranslate(`field_required`) }))] }));
|
|
4620
5105
|
};
|
|
4621
5106
|
|
|
4622
5107
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
4623
|
-
const {
|
|
5108
|
+
const { watch } = useFormContext();
|
|
4624
5109
|
const { translate } = useSchemaContext();
|
|
4625
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5110
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", } = schema;
|
|
4626
5111
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4627
5112
|
const currentFiles = (watch(column) ?? []);
|
|
4628
5113
|
const colLabel = `${prefix}${column}`;
|
|
4629
|
-
return (
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
}, placeholder: translate.t(`${colLabel}.fileDropzone`) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
4633
|
-
return (jsx(Card.Root, { variant: "subtle", children: jsxs(Card.Body, { gap: "2", cursor: "pointer", onClick: () => {
|
|
4634
|
-
setValue(column, currentFiles.filter(({ name }) => {
|
|
4635
|
-
return name !== file.name;
|
|
4636
|
-
}));
|
|
4637
|
-
}, display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [jsx(Box, { children: file.name }), jsx(TiDeleteOutline, {})] }) }, file.name));
|
|
4638
|
-
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.fieldRequired`)) }))] }));
|
|
5114
|
+
return (jsx(Field, { label: `${translate.t(`${colLabel}.field_label`)}`, required: isRequired, gridColumn: gridColumn, gridRow: gridRow, display: "grid", gridTemplateRows: "auto 1fr auto", alignItems: "stretch", children: jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
5115
|
+
return (jsx(Card.Root, { variant: "subtle", children: jsxs(Card.Body, { gap: "2", display: "flex", flexFlow: "row", alignItems: "center", padding: "2", children: [file.type.startsWith("image/") && (jsx(Image, { src: URL.createObjectURL(file), alt: file.name, boxSize: "50px", objectFit: "cover", borderRadius: "md", marginRight: "2" })), jsx(Box, { children: file.name })] }) }, file.name));
|
|
5116
|
+
}) }) }));
|
|
4639
5117
|
};
|
|
4640
5118
|
|
|
4641
5119
|
const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
4642
5120
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4643
5121
|
const { idMap, translate } = useSchemaContext();
|
|
4644
|
-
const { required, gridColumn, gridRow, renderDisplay, foreign_key } = schema;
|
|
5122
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", renderDisplay, foreign_key, } = schema;
|
|
4645
5123
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4646
5124
|
const { display_column } = foreign_key;
|
|
4647
5125
|
const colLabel = `${prefix}${column}`;
|
|
@@ -4657,7 +5135,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4657
5135
|
}
|
|
4658
5136
|
return record[display_column];
|
|
4659
5137
|
};
|
|
4660
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
5138
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4661
5139
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchIds.map((id) => {
|
|
4662
5140
|
const item = idMap[id];
|
|
4663
5141
|
if (item === undefined) {
|
|
@@ -4666,21 +5144,21 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4666
5144
|
return (jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4667
5145
|
? renderDisplay(item)
|
|
4668
5146
|
: item[display_column] }, id));
|
|
4669
|
-
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
5147
|
+
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4670
5148
|
};
|
|
4671
5149
|
|
|
4672
5150
|
const NumberViewer = ({ schema, column, prefix, }) => {
|
|
4673
5151
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4674
5152
|
const { translate } = useSchemaContext();
|
|
4675
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5153
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4676
5154
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4677
5155
|
const colLabel = `${prefix}${column}`;
|
|
4678
5156
|
const value = watch(colLabel);
|
|
4679
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
5157
|
+
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`)) }))] }));
|
|
4680
5158
|
};
|
|
4681
5159
|
|
|
4682
5160
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
4683
|
-
const { properties,
|
|
5161
|
+
const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
|
|
4684
5162
|
const { translate } = useSchemaContext();
|
|
4685
5163
|
const colLabel = `${prefix}${column}`;
|
|
4686
5164
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -4688,25 +5166,28 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
4688
5166
|
if (properties === undefined) {
|
|
4689
5167
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4690
5168
|
}
|
|
4691
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label",
|
|
5169
|
+
return (jsxs(Box, { gridRow, gridColumn, children: [showLabel && (jsxs(Box, { as: "label", children: [`${translate.t(removeIndex(`${colLabel}.field_label`))}`, isRequired && jsx("span", { children: "*" })] })), jsx(Grid, { gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", bgColor: { base: "colorPalette.100", _dark: "colorPalette.900" }, p: "1", borderRadius: "md", borderWidth: "thin", borderColor: {
|
|
5170
|
+
base: "colorPalette.200",
|
|
5171
|
+
_dark: "colorPalette.800",
|
|
5172
|
+
}, children: Object.keys(properties ?? {}).map((key) => {
|
|
4692
5173
|
return (
|
|
4693
5174
|
// @ts-expect-error find suitable types
|
|
4694
5175
|
jsx(ColumnViewer, { column: `${key}`,
|
|
4695
5176
|
prefix: `${prefix}${column}.`,
|
|
4696
5177
|
properties }, `form-objectviewer-${colLabel}-${key}`));
|
|
4697
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
5178
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4698
5179
|
};
|
|
4699
5180
|
|
|
4700
5181
|
const RecordInput = ({ column, schema, prefix }) => {
|
|
4701
5182
|
const { formState: { errors }, setValue, getValues, } = useFormContext();
|
|
4702
5183
|
const { translate } = useSchemaContext();
|
|
4703
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5184
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4704
5185
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4705
5186
|
const entries = Object.entries(getValues(column) ?? {});
|
|
4706
5187
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4707
5188
|
const [newKey, setNewKey] = useState();
|
|
4708
5189
|
const [newValue, setNewValue] = useState();
|
|
4709
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
5190
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4710
5191
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4711
5192
|
const filtered = entries.filter(([target]) => {
|
|
4712
5193
|
return target !== key;
|
|
@@ -4746,7 +5227,17 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4746
5227
|
setShowNewEntries(true);
|
|
4747
5228
|
setNewKey(undefined);
|
|
4748
5229
|
setNewValue(undefined);
|
|
4749
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
5230
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
5231
|
+
};
|
|
5232
|
+
|
|
5233
|
+
const StringViewer = ({ column, schema, prefix, }) => {
|
|
5234
|
+
const { watch, formState: { errors }, } = useFormContext();
|
|
5235
|
+
const { translate } = useSchemaContext();
|
|
5236
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
5237
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
5238
|
+
const colLabel = `${prefix}${column}`;
|
|
5239
|
+
const value = watch(colLabel);
|
|
5240
|
+
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`)) }))] }) }));
|
|
4750
5241
|
};
|
|
4751
5242
|
|
|
4752
5243
|
const TagViewer = ({ column, schema, prefix }) => {
|
|
@@ -4834,19 +5325,36 @@ const TagViewer = ({ column, schema, prefix }) => {
|
|
|
4834
5325
|
}), errors[`${column}`] && (jsx(Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4835
5326
|
};
|
|
4836
5327
|
|
|
4837
|
-
const
|
|
5328
|
+
const TextAreaViewer = ({ column, schema, prefix, }) => {
|
|
4838
5329
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4839
5330
|
const { translate } = useSchemaContext();
|
|
4840
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5331
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4841
5332
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4842
5333
|
const colLabel = `${prefix}${column}`;
|
|
4843
5334
|
const value = watch(colLabel);
|
|
4844
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
5335
|
+
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn, gridRow: gridRow, children: [jsx(Text, { whiteSpace: "pre-wrap", children: value }), " ", errors[colLabel] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
5336
|
+
};
|
|
5337
|
+
|
|
5338
|
+
const TimeViewer = ({ column, schema, prefix, }) => {
|
|
5339
|
+
const { watch, formState: { errors }, } = useFormContext();
|
|
5340
|
+
const { translate } = useSchemaContext();
|
|
5341
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", displayTimeFormat = "hh:mm A" } = schema;
|
|
5342
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
5343
|
+
const colLabel = `${prefix}${column}`;
|
|
5344
|
+
const selectedDate = watch(colLabel);
|
|
5345
|
+
const displayedTime = dayjs(`1970-01-01T${selectedDate}Z`).isValid()
|
|
5346
|
+
? dayjs(`1970-01-01T${selectedDate}Z`).utc().format(displayTimeFormat)
|
|
5347
|
+
: "";
|
|
5348
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
5349
|
+
gridRow, children: [jsx(Text, { children: displayedTime }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4845
5350
|
};
|
|
4846
5351
|
|
|
4847
5352
|
const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
4848
5353
|
const colSchema = schema;
|
|
4849
|
-
const { type, variant, properties: innerProperties, foreign_key, items, } = schema;
|
|
5354
|
+
const { type, variant, properties: innerProperties, foreign_key, items, format, } = schema;
|
|
5355
|
+
if (variant === "custom-input") {
|
|
5356
|
+
return jsx(CustomViewer, { schema: colSchema, prefix, column });
|
|
5357
|
+
}
|
|
4850
5358
|
if (type === "string") {
|
|
4851
5359
|
if ((schema.enum ?? []).length > 0) {
|
|
4852
5360
|
return jsx(EnumViewer, { schema: colSchema, prefix, column });
|
|
@@ -4855,9 +5363,15 @@ const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
|
4855
5363
|
idPickerSanityCheck(column, foreign_key);
|
|
4856
5364
|
return jsx(IdViewer, { schema: colSchema, prefix, column });
|
|
4857
5365
|
}
|
|
4858
|
-
if (
|
|
5366
|
+
if (format === "time") {
|
|
5367
|
+
return jsx(TimeViewer, { schema: colSchema, prefix, column });
|
|
5368
|
+
}
|
|
5369
|
+
if (format === "date") {
|
|
4859
5370
|
return jsx(DateViewer, { schema: colSchema, prefix, column });
|
|
4860
5371
|
}
|
|
5372
|
+
if (variant === "text-area") {
|
|
5373
|
+
return jsx(TextAreaViewer, { schema: colSchema, prefix, column });
|
|
5374
|
+
}
|
|
4861
5375
|
return jsx(StringViewer, { schema: colSchema, prefix, column });
|
|
4862
5376
|
}
|
|
4863
5377
|
if (type === "number" || type === "integer") {
|
|
@@ -4980,7 +5494,7 @@ const FormBody = () => {
|
|
|
4980
5494
|
include,
|
|
4981
5495
|
});
|
|
4982
5496
|
if (isSuccess) {
|
|
4983
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsxs(Alert.Root, { status: "success", children: [jsx(Alert.Indicator, {}), jsx(Alert.Title, { children: translate.t("
|
|
5497
|
+
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 () => {
|
|
4984
5498
|
setIsError(false);
|
|
4985
5499
|
setIsSubmiting(false);
|
|
4986
5500
|
setIsSuccess(false);
|
|
@@ -4988,10 +5502,10 @@ const FormBody = () => {
|
|
|
4988
5502
|
setValidatedData(undefined);
|
|
4989
5503
|
const data = await getUpdatedData();
|
|
4990
5504
|
methods.reset(data);
|
|
4991
|
-
}, formNoValidate: true, children: translate.t("
|
|
5505
|
+
}, formNoValidate: true, children: translate.t("submit_again") }) })] }));
|
|
4992
5506
|
}
|
|
4993
5507
|
if (isConfirming) {
|
|
4994
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: 4, gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows:
|
|
5508
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: 4, gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows: "repeat(12, max-content)", autoFlow: "row", children: ordered.map((column) => {
|
|
4995
5509
|
return (jsx(ColumnViewer
|
|
4996
5510
|
// @ts-expect-error find suitable types
|
|
4997
5511
|
, {
|
|
@@ -5003,7 +5517,7 @@ const FormBody = () => {
|
|
|
5003
5517
|
onFormSubmit(validatedData);
|
|
5004
5518
|
}, 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)}` })] }) }) }) }) }))] }));
|
|
5005
5519
|
}
|
|
5006
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)",
|
|
5520
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: ordered.map((column) => {
|
|
5007
5521
|
return (jsx(ColumnRenderer
|
|
5008
5522
|
// @ts-expect-error find suitable types
|
|
5009
5523
|
, {
|
|
@@ -5019,8 +5533,8 @@ const FormTitle = () => {
|
|
|
5019
5533
|
return jsx(Heading, { children: translate.t("title") });
|
|
5020
5534
|
};
|
|
5021
5535
|
|
|
5022
|
-
const DefaultForm = ({ formConfig, }) => {
|
|
5023
|
-
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
5536
|
+
const DefaultForm = ({ formConfig, showTitle = true, }) => {
|
|
5537
|
+
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [showTitle && jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
5024
5538
|
};
|
|
5025
5539
|
|
|
5026
5540
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5053,4 +5567,4 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
|
|
|
5053
5567
|
}
|
|
5054
5568
|
};
|
|
5055
5569
|
|
|
5056
|
-
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, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableSelector, TableSorter, TableViewer, TextCell, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
|
|
5570
|
+
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 };
|