@bsol-oss/react-datatable5 12.0.0-beta.5 → 12.0.0-beta.51
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 +183 -87
- package/dist/index.js +888 -359
- package/dist/index.mjs +893 -365
- package/dist/types/components/DataTable/DataTable.d.ts +4 -2
- package/dist/types/components/DataTable/DataTableServer.d.ts +4 -2
- 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
|
|
|
@@ -2808,10 +2895,23 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2808
2895
|
*
|
|
2809
2896
|
* @link https://tanstack.com/table/latest/docs/guide/column-defs
|
|
2810
2897
|
*/
|
|
2811
|
-
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,
|
|
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, tableLabel = {
|
|
2899
|
+
view: "View",
|
|
2900
|
+
edit: "Edit",
|
|
2901
|
+
filterButtonText: "Filter",
|
|
2902
|
+
filterTitle: "Filter",
|
|
2903
|
+
filterReset: "Reset",
|
|
2904
|
+
filterClose: "Close",
|
|
2905
|
+
reloadTooltip: "Reload",
|
|
2906
|
+
reloadButtonText: "Reload",
|
|
2907
|
+
resetSelection: "Reset Selection",
|
|
2908
|
+
resetSorting: "Reset Sorting",
|
|
2909
|
+
rowCountText: "Row Count",
|
|
2910
|
+
hasErrorText: "Has Error",
|
|
2911
|
+
}, }) {
|
|
2812
2912
|
const table = useReactTable({
|
|
2813
2913
|
_features: [DensityFeature],
|
|
2814
|
-
data: query.data?.data ?? [],
|
|
2914
|
+
data: (query.data?.data ?? []),
|
|
2815
2915
|
rowCount: query.data?.count ?? 0,
|
|
2816
2916
|
columns: columns,
|
|
2817
2917
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -2857,95 +2957,31 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2857
2957
|
// for tanstack-table ts bug end
|
|
2858
2958
|
});
|
|
2859
2959
|
return (jsx(DataTableContext.Provider, { value: {
|
|
2860
|
-
table:
|
|
2960
|
+
table: table,
|
|
2861
2961
|
globalFilter,
|
|
2862
2962
|
setGlobalFilter,
|
|
2863
2963
|
type: "server",
|
|
2864
2964
|
translate,
|
|
2965
|
+
columns: columns,
|
|
2966
|
+
sorting,
|
|
2967
|
+
setSorting,
|
|
2968
|
+
columnFilters,
|
|
2969
|
+
setColumnFilters,
|
|
2970
|
+
pagination,
|
|
2971
|
+
setPagination,
|
|
2972
|
+
rowSelection,
|
|
2973
|
+
setRowSelection,
|
|
2974
|
+
columnOrder,
|
|
2975
|
+
setColumnOrder,
|
|
2976
|
+
density,
|
|
2977
|
+
setDensity,
|
|
2978
|
+
columnVisibility,
|
|
2979
|
+
setColumnVisibility,
|
|
2980
|
+
data: query.data?.data ?? [],
|
|
2981
|
+
tableLabel,
|
|
2865
2982
|
}, children: jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2866
2983
|
}
|
|
2867
2984
|
|
|
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
2985
|
const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
2950
2986
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
2951
2987
|
if (disabled)
|
|
@@ -2980,17 +3016,19 @@ const GlobalFilter = () => {
|
|
|
2980
3016
|
} }) }) }));
|
|
2981
3017
|
};
|
|
2982
3018
|
|
|
2983
|
-
const ReloadButton = ({
|
|
3019
|
+
const ReloadButton = ({ variant = "icon", }) => {
|
|
2984
3020
|
const { url } = useDataTableServerContext();
|
|
2985
3021
|
const queryClient = useQueryClient();
|
|
3022
|
+
const { tableLabel } = useDataTableContext();
|
|
3023
|
+
const { reloadTooltip, reloadButtonText } = tableLabel;
|
|
2986
3024
|
if (variant === "icon") {
|
|
2987
|
-
return (jsx(Tooltip, { showArrow: true, content:
|
|
3025
|
+
return (jsx(Tooltip, { showArrow: true, content: reloadTooltip, children: jsx(Button, { variant: "ghost", onClick: () => {
|
|
2988
3026
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2989
3027
|
}, "aria-label": "refresh", children: jsx(IoReload, {}) }) }));
|
|
2990
3028
|
}
|
|
2991
3029
|
return (jsxs(Button, { variant: "ghost", onClick: () => {
|
|
2992
3030
|
queryClient.invalidateQueries({ queryKey: [url] });
|
|
2993
|
-
}, children: [jsx(IoReload, {}), " ",
|
|
3031
|
+
}, children: [jsx(IoReload, {}), " ", reloadButtonText] }));
|
|
2994
3032
|
};
|
|
2995
3033
|
|
|
2996
3034
|
const FilterOptions = ({ column }) => {
|
|
@@ -2999,6 +3037,7 @@ const FilterOptions = ({ column }) => {
|
|
|
2999
3037
|
const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
|
|
3000
3038
|
return (jsx(Fragment, { children: options.map((option) => {
|
|
3001
3039
|
const selected = table.getColumn(column)?.getFilterValue() === option;
|
|
3040
|
+
const { label, value } = option;
|
|
3002
3041
|
return (jsxs(Button$1, { size: "sm", onClick: () => {
|
|
3003
3042
|
if (selected) {
|
|
3004
3043
|
table.setColumnFilters((state) => {
|
|
@@ -3008,8 +3047,8 @@ const FilterOptions = ({ column }) => {
|
|
|
3008
3047
|
});
|
|
3009
3048
|
return;
|
|
3010
3049
|
}
|
|
3011
|
-
table.getColumn(column)?.setFilterValue(
|
|
3012
|
-
}, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [
|
|
3050
|
+
table.getColumn(column)?.setFilterValue(value);
|
|
3051
|
+
}, variant: selected ? "solid" : "outline", display: "flex", gap: "0.25rem", children: [label, selected && jsx(MdClose, {})] }, option.value));
|
|
3013
3052
|
}) }));
|
|
3014
3053
|
};
|
|
3015
3054
|
|
|
@@ -3024,16 +3063,91 @@ const TableFilterTags = () => {
|
|
|
3024
3063
|
}) }));
|
|
3025
3064
|
};
|
|
3026
3065
|
|
|
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
|
-
|
|
3066
|
+
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 = {}, }) => {
|
|
3067
|
+
const { tableLabel } = useDataTableContext();
|
|
3068
|
+
const { rowCountText, hasErrorText } = tableLabel;
|
|
3069
|
+
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) => {
|
|
3070
|
+
const { label, value } = option;
|
|
3071
|
+
return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [label, ":"] }), jsx(FilterOptions, { column: value })] }, value));
|
|
3072
|
+
}) })), 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, {}) })] }))] }));
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
3076
|
+
const { title, description, icon, children, ...rest } = props;
|
|
3077
|
+
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] }) }));
|
|
3078
|
+
});
|
|
3079
|
+
|
|
3080
|
+
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" })] }) }));
|
|
3081
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3082
|
+
const { table } = useDataTableContext();
|
|
3083
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
3084
|
+
return emptyComponent;
|
|
3085
|
+
}
|
|
3086
|
+
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 }));
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
3090
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3091
|
+
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 }))] }));
|
|
3092
|
+
});
|
|
3093
|
+
|
|
3094
|
+
const TableBody = ({ showSelector = false, canResize = true, }) => {
|
|
3095
|
+
"use no memo";
|
|
3096
|
+
const { table } = useDataTableContext();
|
|
3097
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3098
|
+
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
3099
|
+
const handleRowHover = (index) => {
|
|
3100
|
+
setHoveredRow(index);
|
|
3101
|
+
};
|
|
3102
|
+
const getTdProps = (cell) => {
|
|
3103
|
+
const tdProps = cell.column.getIsPinned()
|
|
3104
|
+
? {
|
|
3105
|
+
left: showSelector
|
|
3106
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3107
|
+
: `${cell.column.getStart("left")}px`,
|
|
3108
|
+
position: "relative",
|
|
3109
|
+
}
|
|
3110
|
+
: {};
|
|
3111
|
+
return tdProps;
|
|
3112
|
+
};
|
|
3113
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3114
|
+
if (hoveredRow === -1) {
|
|
3115
|
+
return {};
|
|
3116
|
+
}
|
|
3117
|
+
if (hoveredRow === index) {
|
|
3118
|
+
return {
|
|
3119
|
+
opacity: "1",
|
|
3120
|
+
};
|
|
3121
|
+
}
|
|
3122
|
+
return {
|
|
3123
|
+
opacity: "0.8",
|
|
3124
|
+
};
|
|
3125
|
+
};
|
|
3126
|
+
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3127
|
+
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) => {
|
|
3128
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3129
|
+
// styling resize and pinning start
|
|
3130
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3131
|
+
base: "colorPalette.900",
|
|
3132
|
+
_dark: "colorPalette.100",
|
|
3133
|
+
},
|
|
3134
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3135
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3136
|
+
}) }));
|
|
3137
|
+
};
|
|
3138
|
+
const TableRowSelector = ({ row, }) => {
|
|
3139
|
+
const { table } = useDataTableContext();
|
|
3140
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3141
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3142
|
+
base: "colorPalette.900",
|
|
3143
|
+
_dark: "colorPalette.100",
|
|
3144
|
+
},
|
|
3145
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
3146
|
+
disabled: !row.getCanSelect(),
|
|
3147
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3034
3148
|
};
|
|
3035
3149
|
|
|
3036
|
-
const TableFooter = ({
|
|
3150
|
+
const TableFooter = ({ showSelector = false, alwaysShowSelector = true, }) => {
|
|
3037
3151
|
const table = useDataTableContext().table;
|
|
3038
3152
|
const SELECTION_BOX_WIDTH = 20;
|
|
3039
3153
|
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
@@ -3052,65 +3166,62 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3052
3166
|
}
|
|
3053
3167
|
return false;
|
|
3054
3168
|
};
|
|
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(),
|
|
3169
|
+
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
3170
|
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3087
3171
|
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
3172
|
// styling resize and pinning start
|
|
3089
|
-
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid",
|
|
3173
|
+
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
3174
|
? 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}`))) }));
|
|
3175
|
+
: 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
3176
|
};
|
|
3095
3177
|
|
|
3096
|
-
|
|
3178
|
+
// Default text values
|
|
3179
|
+
const DEFAULT_HEADER_TEXTS = {
|
|
3180
|
+
pinColumn: "Pin Column",
|
|
3181
|
+
cancelPin: "Cancel Pin",
|
|
3182
|
+
sortAscending: "Sort Ascending",
|
|
3183
|
+
sortDescending: "Sort Descending",
|
|
3184
|
+
clearSorting: "Clear Sorting",
|
|
3185
|
+
};
|
|
3186
|
+
/**
|
|
3187
|
+
* TableHeader component with configurable text strings.
|
|
3188
|
+
*
|
|
3189
|
+
* @example
|
|
3190
|
+
* // Using default texts
|
|
3191
|
+
* <TableHeader />
|
|
3192
|
+
*
|
|
3193
|
+
* @example
|
|
3194
|
+
* // Customizing default texts for all columns
|
|
3195
|
+
* <TableHeader
|
|
3196
|
+
* defaultTexts={{
|
|
3197
|
+
* pinColumn: "Pin This Column",
|
|
3198
|
+
* sortAscending: "Sort A-Z"
|
|
3199
|
+
* }}
|
|
3200
|
+
* />
|
|
3201
|
+
*
|
|
3202
|
+
* @example
|
|
3203
|
+
* // Customizing texts per column via meta
|
|
3204
|
+
* const columns = [
|
|
3205
|
+
* columnHelper.accessor("name", {
|
|
3206
|
+
* header: "Name",
|
|
3207
|
+
* meta: {
|
|
3208
|
+
* headerTexts: {
|
|
3209
|
+
* pinColumn: "Pin Name Column",
|
|
3210
|
+
* sortAscending: "Sort Names A-Z"
|
|
3211
|
+
* }
|
|
3212
|
+
* }
|
|
3213
|
+
* })
|
|
3214
|
+
* ];
|
|
3215
|
+
*/
|
|
3216
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, defaultTexts = {}, }) => {
|
|
3097
3217
|
const { table } = useDataTableContext();
|
|
3098
3218
|
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;
|
|
3219
|
+
// Merge default texts with provided defaults
|
|
3220
|
+
const mergedDefaultTexts = { ...DEFAULT_HEADER_TEXTS, ...defaultTexts };
|
|
3221
|
+
// Helper function to get text for a specific header
|
|
3222
|
+
const getHeaderText = (header, key) => {
|
|
3223
|
+
const columnMeta = header.column.columnDef.meta;
|
|
3224
|
+
return columnMeta?.headerTexts?.[key] || mergedDefaultTexts[key];
|
|
3114
3225
|
};
|
|
3115
3226
|
const getThProps = (header) => {
|
|
3116
3227
|
const thProps = header.column.getIsPinned()
|
|
@@ -3118,12 +3229,8 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3118
3229
|
left: showSelector
|
|
3119
3230
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3120
3231
|
: `${header.getStart("left")}px`,
|
|
3121
|
-
background: pinnedBgColor.light,
|
|
3122
3232
|
position: "sticky",
|
|
3123
3233
|
zIndex: 100 + 1,
|
|
3124
|
-
_dark: {
|
|
3125
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3126
|
-
},
|
|
3127
3234
|
}
|
|
3128
3235
|
: {};
|
|
3129
3236
|
return thProps;
|
|
@@ -3132,21 +3239,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3132
3239
|
position: "sticky",
|
|
3133
3240
|
top: 0,
|
|
3134
3241
|
};
|
|
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) => {
|
|
3242
|
+
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: {
|
|
3243
|
+
base: "colorPalette.900",
|
|
3244
|
+
_dark: "colorPalette.100",
|
|
3245
|
+
},
|
|
3246
|
+
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(),
|
|
3247
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3248
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3150
3249
|
const resizeProps = {
|
|
3151
3250
|
onMouseDown: header.getResizeHandler(),
|
|
3152
3251
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3154,18 +3253,32 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3154
3253
|
};
|
|
3155
3254
|
return (jsxs(Table$1.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3156
3255
|
// 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
|
-
|
|
3256
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3257
|
+
base: "colorPalette.800",
|
|
3258
|
+
_dark: "colorPalette.200",
|
|
3259
|
+
},
|
|
3260
|
+
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: {
|
|
3261
|
+
base: "colorPalette.800",
|
|
3262
|
+
_dark: "colorPalette.200",
|
|
3263
|
+
_hover: {
|
|
3264
|
+
base: "colorPalette.700",
|
|
3265
|
+
_dark: "colorPalette.300",
|
|
3266
|
+
},
|
|
3267
|
+
},
|
|
3268
|
+
bg: {
|
|
3269
|
+
base: "colorPalette.100",
|
|
3270
|
+
_dark: "colorPalette.900",
|
|
3271
|
+
_hover: {
|
|
3272
|
+
base: "colorPalette.200",
|
|
3273
|
+
_dark: "colorPalette.800",
|
|
3161
3274
|
},
|
|
3162
3275
|
}, children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
3163
3276
|
? null
|
|
3164
3277
|
: 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
3278
|
header.column.pin("left");
|
|
3166
|
-
}, children: [jsx(MdPushPin, {}),
|
|
3279
|
+
}, children: [jsx(MdPushPin, {}), getHeaderText(header, "pinColumn")] }) })), header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "cancel-pin", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3167
3280
|
header.column.pin(false);
|
|
3168
|
-
}, children: [jsx(MdCancel, {}),
|
|
3281
|
+
}, 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
3282
|
table.setSorting((state) => {
|
|
3170
3283
|
return [
|
|
3171
3284
|
...state.filter((column) => {
|
|
@@ -3174,7 +3287,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3174
3287
|
{ id: header.id, desc: false },
|
|
3175
3288
|
];
|
|
3176
3289
|
});
|
|
3177
|
-
}, children: [jsx(GrAscend, {}),
|
|
3290
|
+
}, children: [jsx(GrAscend, {}), getHeaderText(header, "sortAscending")] }) }), jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3178
3291
|
table.setSorting((state) => {
|
|
3179
3292
|
return [
|
|
3180
3293
|
...state.filter((column) => {
|
|
@@ -3183,42 +3296,30 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3183
3296
|
{ id: header.id, desc: true },
|
|
3184
3297
|
];
|
|
3185
3298
|
});
|
|
3186
|
-
}, children: [jsx(GrDescend, {}),
|
|
3299
|
+
}, children: [jsx(GrDescend, {}), getHeaderText(header, "sortDescending")] }) }), header.column.getIsSorted() && (jsx(MenuItem, { asChild: true, value: "clear-sorting", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
3187
3300
|
header.column.clearSorting();
|
|
3188
|
-
}, children: [jsx(MdClear, {}),
|
|
3301
|
+
}, children: [jsx(MdClear, {}), getHeaderText(header, "clearSorting")] }) }))] }))] })] }), canResize && (jsx(Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing()
|
|
3302
|
+
? "colorPalette.700"
|
|
3303
|
+
: "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
|
|
3189
3304
|
borderRightColor: header.column.getIsResizing()
|
|
3190
|
-
? "
|
|
3191
|
-
: "
|
|
3305
|
+
? "colorPalette.700"
|
|
3306
|
+
: "colorPalette.400",
|
|
3192
3307
|
}, ...resizeProps }))] }, `chakra-table-header-${header.id}`));
|
|
3193
3308
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3194
3309
|
};
|
|
3195
3310
|
|
|
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 = "", }) => {
|
|
3311
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3211
3312
|
if (variant === "greedy") {
|
|
3212
3313
|
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
3314
|
}
|
|
3214
3315
|
return (jsx(TableControls, { ...controlProps, children: jsxs(Table, { ...tableProps, children: [jsx(TableHeader, { ...tableHeaderProps }), jsx(TableBody, { ...tableBodyProps }), showFooter && jsx(TableFooter, { ...tableFooterProps })] }) }));
|
|
3215
3316
|
};
|
|
3216
3317
|
|
|
3217
|
-
const TableCardContainer = ({ children, variant = "", ...props }) => {
|
|
3318
|
+
const TableCardContainer = ({ children, variant = "", gap = "1rem", gridTemplateColumns = "repeat(auto-fit, minmax(20rem, 1fr))", direction = "row", ...props }) => {
|
|
3218
3319
|
if (variant === "carousel") {
|
|
3219
|
-
return (jsx(Flex, { overflow: "
|
|
3320
|
+
return (jsx(Flex, { overflow: "auto", gap: gap, direction: direction, ...props, children: children }));
|
|
3220
3321
|
}
|
|
3221
|
-
return (jsx(Grid, { gridTemplateColumns:
|
|
3322
|
+
return (jsx(Grid, { gridTemplateColumns: gridTemplateColumns, gap: gap, ...props, children: children }));
|
|
3222
3323
|
};
|
|
3223
3324
|
|
|
3224
3325
|
const DefaultCardTitle = () => {
|
|
@@ -3247,8 +3348,8 @@ const TableComponent = ({ render = () => {
|
|
|
3247
3348
|
};
|
|
3248
3349
|
|
|
3249
3350
|
const TableLoadingComponent = ({ render, }) => {
|
|
3250
|
-
const {
|
|
3251
|
-
return jsx(Fragment, { children: render(
|
|
3351
|
+
const { query } = useDataTableServerContext();
|
|
3352
|
+
return jsx(Fragment, { children: render(query.isLoading) });
|
|
3252
3353
|
};
|
|
3253
3354
|
|
|
3254
3355
|
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
@@ -3467,6 +3568,70 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3467
3568
|
return columns;
|
|
3468
3569
|
};
|
|
3469
3570
|
|
|
3571
|
+
const TableDataDisplay = ({ colorPalette, emptyComponent, }) => {
|
|
3572
|
+
const { columns, translate, data } = useDataTableContext();
|
|
3573
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3574
|
+
const { accessorKey, id } = def;
|
|
3575
|
+
if (accessorKey) {
|
|
3576
|
+
return [accessorKey, def];
|
|
3577
|
+
}
|
|
3578
|
+
return [id, def];
|
|
3579
|
+
}));
|
|
3580
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3581
|
+
const totalWidths = columns
|
|
3582
|
+
.map(({ size }) => {
|
|
3583
|
+
if (!!size === false) {
|
|
3584
|
+
return 0;
|
|
3585
|
+
}
|
|
3586
|
+
if (typeof size === "number") {
|
|
3587
|
+
return size;
|
|
3588
|
+
}
|
|
3589
|
+
return 0;
|
|
3590
|
+
})
|
|
3591
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3592
|
+
const columnWidths = columns
|
|
3593
|
+
.map(({ size }) => {
|
|
3594
|
+
if (!!size === false) {
|
|
3595
|
+
return "1fr";
|
|
3596
|
+
}
|
|
3597
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3598
|
+
})
|
|
3599
|
+
.join(" ");
|
|
3600
|
+
console.log({ columnWidths }, "hadfg");
|
|
3601
|
+
const cellProps = {
|
|
3602
|
+
flex: "1 0 0%",
|
|
3603
|
+
overflow: "auto",
|
|
3604
|
+
paddingX: "2",
|
|
3605
|
+
py: "1",
|
|
3606
|
+
color: { base: "colorPalette.900", _dark: "colorPalette.100" },
|
|
3607
|
+
bgColor: { base: "colorPalette.50", _dark: "colorPalette.950" },
|
|
3608
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3609
|
+
borderBottomWidth: "1px",
|
|
3610
|
+
...{ colorPalette },
|
|
3611
|
+
};
|
|
3612
|
+
if (data.length <= 0) {
|
|
3613
|
+
return jsx(Fragment, { children: emptyComponent });
|
|
3614
|
+
}
|
|
3615
|
+
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) => {
|
|
3616
|
+
return (jsx(Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3617
|
+
}) }), data.map((record) => {
|
|
3618
|
+
return (jsx(Fragment, { children: columnHeaders.map((header) => {
|
|
3619
|
+
const { cell } = columnsMap[header];
|
|
3620
|
+
const value = record[header];
|
|
3621
|
+
if (!!record === false) {
|
|
3622
|
+
return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3623
|
+
}
|
|
3624
|
+
if (cell) {
|
|
3625
|
+
return (jsx(Box, { ...cellProps, children: cell({ row: { original: record } }) }));
|
|
3626
|
+
}
|
|
3627
|
+
if (typeof value === "object") {
|
|
3628
|
+
return (jsx(Box, { ...cellProps, children: jsx(RecordDisplay, { object: value }) }));
|
|
3629
|
+
}
|
|
3630
|
+
return jsx(Box, { ...cellProps, children: value });
|
|
3631
|
+
}) }));
|
|
3632
|
+
})] }));
|
|
3633
|
+
};
|
|
3634
|
+
|
|
3470
3635
|
const AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3471
3636
|
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3472
3637
|
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 +3715,7 @@ const FormRoot = ({ schema, idMap, setIdMap, form, serverUrl, translate, childre
|
|
|
3550
3715
|
};
|
|
3551
3716
|
|
|
3552
3717
|
function removeIndex(str) {
|
|
3553
|
-
return str.replace(/\.\d+\./g,
|
|
3718
|
+
return str.replace(/\.\d+\./g, ".");
|
|
3554
3719
|
}
|
|
3555
3720
|
|
|
3556
3721
|
const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
@@ -3562,13 +3727,17 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3562
3727
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3563
3728
|
const { formState: { errors }, setValue, watch, } = useFormContext();
|
|
3564
3729
|
const fields = (watch(colLabel) ?? []);
|
|
3565
|
-
return (jsxs(
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3730
|
+
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: {
|
|
3731
|
+
base: "colorPalette.200",
|
|
3732
|
+
_dark: "colorPalette.800",
|
|
3733
|
+
}, children: [jsx(Grid, { gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsx(SchemaRenderer, { column: `${index}`,
|
|
3734
|
+
prefix: `${colLabel}.`,
|
|
3735
|
+
// @ts-expect-error find suitable types
|
|
3736
|
+
schema: { showLabel: false, ...(items ?? {}) } }) }), jsx(Flex, { justifyContent: "end", children: jsx(Button$1, { variant: "ghost", onClick: () => {
|
|
3737
|
+
setValue(colLabel, fields.filter((_, curIndex) => {
|
|
3738
|
+
return curIndex !== index;
|
|
3739
|
+
}));
|
|
3740
|
+
}, children: jsx(Icon, { children: jsx(CgTrash, {}) }) }) })] }, `${colLabel}.${index}`))) }), jsx(Flex, { children: jsx(Button$1, { onClick: () => {
|
|
3572
3741
|
if (type === "number") {
|
|
3573
3742
|
setValue(colLabel, [...fields, 0]);
|
|
3574
3743
|
return;
|
|
@@ -3582,7 +3751,7 @@ const ArrayRenderer = ({ schema, column, prefix, }) => {
|
|
|
3582
3751
|
return;
|
|
3583
3752
|
}
|
|
3584
3753
|
setValue(colLabel, [...fields, {}]);
|
|
3585
|
-
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3754
|
+
}, children: translate.t(removeIndex(`${colLabel}.add`)) }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3586
3755
|
};
|
|
3587
3756
|
|
|
3588
3757
|
const Field = React.forwardRef(function Field(props, ref) {
|
|
@@ -3593,14 +3762,26 @@ const Field = React.forwardRef(function Field(props, ref) {
|
|
|
3593
3762
|
const BooleanPicker = ({ schema, column, prefix }) => {
|
|
3594
3763
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
3595
3764
|
const { translate } = useSchemaContext();
|
|
3596
|
-
const { required, gridColumn, gridRow } = schema;
|
|
3765
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
3597
3766
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3598
3767
|
const colLabel = `${prefix}${column}`;
|
|
3599
3768
|
const value = watch(colLabel);
|
|
3600
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
3769
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3601
3770
|
gridRow, children: [jsx(CheckboxCard, { checked: value, variant: "surface", onChange: () => {
|
|
3602
3771
|
setValue(colLabel, !value);
|
|
3603
|
-
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3772
|
+
} }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3773
|
+
};
|
|
3774
|
+
|
|
3775
|
+
const CustomInput = ({ column, schema, prefix }) => {
|
|
3776
|
+
const formContext = useFormContext();
|
|
3777
|
+
const { inputRender } = schema;
|
|
3778
|
+
return (inputRender &&
|
|
3779
|
+
inputRender({
|
|
3780
|
+
column,
|
|
3781
|
+
schema,
|
|
3782
|
+
prefix,
|
|
3783
|
+
formContext,
|
|
3784
|
+
}));
|
|
3604
3785
|
};
|
|
3605
3786
|
|
|
3606
3787
|
const monthNamesShort = [
|
|
@@ -3690,28 +3871,54 @@ const PopoverRoot = Popover.Root;
|
|
|
3690
3871
|
const PopoverBody = Popover.Body;
|
|
3691
3872
|
const PopoverTrigger = Popover.Trigger;
|
|
3692
3873
|
|
|
3874
|
+
dayjs.extend(utc);
|
|
3693
3875
|
const DatePicker = ({ column, schema, prefix }) => {
|
|
3694
3876
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
3695
3877
|
const { translate } = useSchemaContext();
|
|
3696
|
-
const { required, gridColumn, gridRow } = schema;
|
|
3878
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", displayDateFormat = "YYYY-MM-DD", dateFormat = "YYYY-MM-DD[T]HH:mm:ss[Z]", } = schema;
|
|
3697
3879
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3698
3880
|
const colLabel = `${prefix}${column}`;
|
|
3699
3881
|
const [open, setOpen] = useState(false);
|
|
3700
3882
|
const selectedDate = watch(colLabel);
|
|
3701
|
-
const
|
|
3702
|
-
|
|
3703
|
-
|
|
3883
|
+
const displayDate = dayjs.utc(selectedDate).format(displayDateFormat);
|
|
3884
|
+
useEffect(() => {
|
|
3885
|
+
try {
|
|
3886
|
+
if (selectedDate) {
|
|
3887
|
+
// Parse the selectedDate as UTC or in a specific timezone to avoid +8 hour shift
|
|
3888
|
+
// For example, parse as UTC:
|
|
3889
|
+
const parsedDate = dayjs.utc(selectedDate);
|
|
3890
|
+
// Or if you want to parse in local timezone without shifting:
|
|
3891
|
+
// const parsedDate = dayjs.tz(selectedDate, dayjs.tz.guess());
|
|
3892
|
+
if (!parsedDate.isValid())
|
|
3893
|
+
return;
|
|
3894
|
+
// Format according to dateFormat from schema
|
|
3895
|
+
const formatted = parsedDate.format(dateFormat);
|
|
3896
|
+
// Update the form value only if different to avoid loops
|
|
3897
|
+
if (formatted !== selectedDate) {
|
|
3898
|
+
setValue(colLabel, formatted, {
|
|
3899
|
+
shouldValidate: true,
|
|
3900
|
+
shouldDirty: true,
|
|
3901
|
+
});
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
catch (e) {
|
|
3906
|
+
console.error(e);
|
|
3907
|
+
}
|
|
3908
|
+
}, [selectedDate, dateFormat, colLabel, setValue]);
|
|
3909
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3910
|
+
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
3911
|
setOpen(true);
|
|
3705
|
-
}, children: selectedDate !== undefined ? `${
|
|
3912
|
+
}, justifyContent: "start", children: [jsx(MdDateRange, {}), selectedDate !== undefined ? `${displayDate}` : ""] }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
|
|
3706
3913
|
// @ts-expect-error TODO: find appropriate types
|
|
3707
3914
|
, {
|
|
3708
3915
|
// @ts-expect-error TODO: find appropriate types
|
|
3709
3916
|
selected: new Date(selectedDate),
|
|
3710
3917
|
// @ts-expect-error TODO: find appropriate types
|
|
3711
3918
|
onDateSelected: ({ date }) => {
|
|
3712
|
-
setValue(colLabel, dayjs(date).format(
|
|
3919
|
+
setValue(colLabel, dayjs(date).format(dateFormat));
|
|
3713
3920
|
setOpen(false);
|
|
3714
|
-
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
3921
|
+
} })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
3715
3922
|
};
|
|
3716
3923
|
|
|
3717
3924
|
function filterArray(array, searchTerm) {
|
|
@@ -3724,12 +3931,12 @@ function filterArray(array, searchTerm) {
|
|
|
3724
3931
|
});
|
|
3725
3932
|
}
|
|
3726
3933
|
|
|
3727
|
-
const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
3934
|
+
const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLimit = false, }) => {
|
|
3728
3935
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
3729
3936
|
const { translate } = useSchemaContext();
|
|
3730
|
-
const { required } = schema;
|
|
3937
|
+
const { required, variant } = schema;
|
|
3731
3938
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
3732
|
-
const { gridColumn, gridRow, renderDisplay } = schema;
|
|
3939
|
+
const { gridColumn = "span 4", gridRow = "span 1", renderDisplay } = schema;
|
|
3733
3940
|
const [searchText, setSearchText] = useState();
|
|
3734
3941
|
const [limit, setLimit] = useState(10);
|
|
3735
3942
|
const [openSearchResult, setOpenSearchResult] = useState();
|
|
@@ -3744,28 +3951,61 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3744
3951
|
setSearchText(event.target.value);
|
|
3745
3952
|
setLimit(10);
|
|
3746
3953
|
};
|
|
3747
|
-
|
|
3954
|
+
if (variant === "radio") {
|
|
3955
|
+
return (jsx(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3956
|
+
gridRow, children: jsx(RadioGroup$1.Root, { defaultValue: "1", children: jsx(HStack, { gap: "6", children: filterArray(dataList, searchText ?? "").map((item) => {
|
|
3957
|
+
return (jsxs(RadioGroup$1.Item, { onClick: () => {
|
|
3958
|
+
if (!isMultiple) {
|
|
3959
|
+
setOpenSearchResult(false);
|
|
3960
|
+
setValue(colLabel, item);
|
|
3961
|
+
return;
|
|
3962
|
+
}
|
|
3963
|
+
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3964
|
+
setValue(colLabel, [...newSet]);
|
|
3965
|
+
}, value: item, children: [jsx(RadioGroup$1.ItemHiddenInput, {}), jsx(RadioGroup$1.ItemIndicator, {}), jsx(RadioGroup$1.ItemText, { children: !!renderDisplay === true
|
|
3966
|
+
? renderDisplay(item)
|
|
3967
|
+
: translate.t(removeIndex(`${colLabel}.${item}`)) })] }, `${colLabel}-${item}`));
|
|
3968
|
+
}) }) }) }));
|
|
3969
|
+
}
|
|
3970
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3748
3971
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchEnums.map((enumValue) => {
|
|
3749
3972
|
const item = enumValue;
|
|
3750
|
-
if (item ===
|
|
3751
|
-
return jsx(Fragment, {
|
|
3973
|
+
if (!!item === false) {
|
|
3974
|
+
return jsx(Fragment, {});
|
|
3752
3975
|
}
|
|
3753
3976
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
3754
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3755
3977
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3756
3978
|
}, children: !!renderDisplay === true
|
|
3757
3979
|
? renderDisplay(item)
|
|
3758
3980
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
3759
3981
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
3760
3982
|
setOpenSearchResult(true);
|
|
3761
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
3983
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
3762
3984
|
setOpenSearchResult(true);
|
|
3763
|
-
}, children: watchEnum ===
|
|
3985
|
+
}, justifyContent: "start", children: !!watchEnum === false
|
|
3764
3986
|
? ""
|
|
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(`${
|
|
3987
|
+
: 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
3988
|
onSearchChange(event);
|
|
3767
3989
|
setOpenSearchResult(true);
|
|
3768
|
-
}, autoComplete: "off", ref: ref }), jsx(PopoverTitle, {}), jsx(Text, { children: `${translate.t(`${
|
|
3990
|
+
}, 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
|
|
3991
|
+
.filter((item) => {
|
|
3992
|
+
const searchTerm = (searchText || "").toLowerCase();
|
|
3993
|
+
if (!searchTerm)
|
|
3994
|
+
return true;
|
|
3995
|
+
// Check if the original enum value contains the search text
|
|
3996
|
+
const enumValueMatch = item
|
|
3997
|
+
.toLowerCase()
|
|
3998
|
+
.includes(searchTerm);
|
|
3999
|
+
// Check if the display value (translation) contains the search text
|
|
4000
|
+
const displayValue = !!renderDisplay === true
|
|
4001
|
+
? renderDisplay(item)
|
|
4002
|
+
: translate.t(removeIndex(`${colLabel}.${item}`));
|
|
4003
|
+
// Convert to string and check if it includes the search term
|
|
4004
|
+
const displayValueString = String(displayValue).toLowerCase();
|
|
4005
|
+
const displayValueMatch = displayValueString.includes(searchTerm);
|
|
4006
|
+
return enumValueMatch || displayValueMatch;
|
|
4007
|
+
})
|
|
4008
|
+
.map((item) => {
|
|
3769
4009
|
const selected = isMultiple
|
|
3770
4010
|
? watchEnums.some((enumValue) => item === enumValue)
|
|
3771
4011
|
: watchEnum == item;
|
|
@@ -3777,10 +4017,10 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3777
4017
|
}
|
|
3778
4018
|
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
3779
4019
|
setValue(colLabel, [...newSet]);
|
|
3780
|
-
}, ...(selected ? { color: "
|
|
4020
|
+
}, ...(selected ? { color: "colorPalette.400/50" } : {}), children: !!renderDisplay === true
|
|
3781
4021
|
? renderDisplay(item)
|
|
3782
4022
|
: translate.t(removeIndex(`${colLabel}.${item}`)) }, `${colLabel}-${item}`));
|
|
3783
|
-
}) }), isDirty && (jsx(Fragment, { children: dataList.length <= 0 && (jsx(Fragment, { children: translate.t(removeIndex(`${colLabel}.
|
|
4023
|
+
}) }), 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
4024
|
};
|
|
3785
4025
|
|
|
3786
4026
|
function isEnteringWindow(_ref) {
|
|
@@ -4132,17 +4372,17 @@ const FileDropzone = ({ children = undefined, gridProps = {}, onDrop = () => { }
|
|
|
4132
4372
|
const filesArray = [...event.target.files];
|
|
4133
4373
|
onDrop({ files: filesArray });
|
|
4134
4374
|
};
|
|
4135
|
-
return (jsxs(Grid, { ...getColor(isDraggedOver), ref: ref, cursor: "pointer", onClick: handleClick, borderStyle: "dashed", borderColor: "
|
|
4375
|
+
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
4376
|
};
|
|
4137
4377
|
|
|
4138
4378
|
const FilePicker = ({ column, schema, prefix }) => {
|
|
4139
4379
|
const { setValue, formState: { errors }, watch, } = useFormContext();
|
|
4140
4380
|
const { translate } = useSchemaContext();
|
|
4141
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4381
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", } = schema;
|
|
4142
4382
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4143
4383
|
const currentFiles = (watch(column) ?? []);
|
|
4144
4384
|
const colLabel = `${prefix}${column}`;
|
|
4145
|
-
return (jsxs(Field, { label: `${translate.t(`${colLabel}.
|
|
4385
|
+
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
4386
|
const newFiles = files.filter(({ name }) => !currentFiles.some((cur) => cur.name === name));
|
|
4147
4387
|
setValue(colLabel, [...currentFiles, ...newFiles]);
|
|
4148
4388
|
}, placeholder: translate.t(removeIndex(`${colLabel}.fileDropzone`)) }), jsx(Flex, { flexFlow: "column", gap: 1, children: currentFiles.map((file) => {
|
|
@@ -4150,10 +4390,19 @@ const FilePicker = ({ column, schema, prefix }) => {
|
|
|
4150
4390
|
setValue(column, currentFiles.filter(({ name }) => {
|
|
4151
4391
|
return name !== file.name;
|
|
4152
4392
|
}));
|
|
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}.
|
|
4393
|
+
}, 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));
|
|
4394
|
+
}) }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4155
4395
|
};
|
|
4156
4396
|
|
|
4397
|
+
const ToggleTip = React.forwardRef(function ToggleTip(props, ref) {
|
|
4398
|
+
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
4399
|
+
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] }) }) })] }));
|
|
4400
|
+
});
|
|
4401
|
+
const InfoTip = React.forwardRef(function InfoTip(props, ref) {
|
|
4402
|
+
const { children, ...rest } = props;
|
|
4403
|
+
return (jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsx(IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "colorPalette", children: jsx(HiOutlineInformationCircle, {}) }) }));
|
|
4404
|
+
});
|
|
4405
|
+
|
|
4157
4406
|
const getTableData = async ({ serverUrl, in_table, searching = "", where = [], limit = 10, offset = 0, }) => {
|
|
4158
4407
|
if (serverUrl === undefined || serverUrl.length == 0) {
|
|
4159
4408
|
throw new Error("The serverUrl is missing");
|
|
@@ -4185,15 +4434,18 @@ const getTableData = async ({ serverUrl, in_table, searching = "", where = [], l
|
|
|
4185
4434
|
const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
4186
4435
|
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
4187
4436
|
const { serverUrl, idMap, setIdMap, translate, schema: parentSchema, } = useSchemaContext();
|
|
4188
|
-
const { required, gridColumn, gridRow, renderDisplay, foreign_key } = schema;
|
|
4437
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", renderDisplay, foreign_key, } = schema;
|
|
4189
4438
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4190
4439
|
const { table, column: column_ref, display_column, } = foreign_key;
|
|
4191
|
-
const [searchText, setSearchText] = useState();
|
|
4440
|
+
const [searchText, setSearchText] = useState("");
|
|
4192
4441
|
const [limit, setLimit] = useState(10);
|
|
4193
4442
|
const [openSearchResult, setOpenSearchResult] = useState();
|
|
4194
4443
|
const [page, setPage] = useState(0);
|
|
4195
4444
|
const ref = useRef(null);
|
|
4196
4445
|
const colLabel = `${prefix}${column}`;
|
|
4446
|
+
const watchId = watch(colLabel);
|
|
4447
|
+
const watchIds = isMultiple ? (watch(colLabel) ?? []) : [];
|
|
4448
|
+
// Query for search results
|
|
4197
4449
|
const query = useQuery({
|
|
4198
4450
|
queryKey: [`idpicker`, { column, searchText, limit, page }],
|
|
4199
4451
|
queryFn: async () => {
|
|
@@ -4202,7 +4454,7 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4202
4454
|
searching: searchText ?? "",
|
|
4203
4455
|
in_table: table,
|
|
4204
4456
|
limit: limit,
|
|
4205
|
-
offset: page *
|
|
4457
|
+
offset: page * limit,
|
|
4206
4458
|
});
|
|
4207
4459
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
4208
4460
|
return [
|
|
@@ -4217,27 +4469,27 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4217
4469
|
});
|
|
4218
4470
|
return data;
|
|
4219
4471
|
},
|
|
4220
|
-
enabled:
|
|
4472
|
+
enabled: openSearchResult === true,
|
|
4221
4473
|
staleTime: 300000,
|
|
4222
4474
|
});
|
|
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({
|
|
4475
|
+
// Query for currently selected items (to display them properly)
|
|
4476
|
+
const queryDefault = useQuery({
|
|
4230
4477
|
queryKey: [
|
|
4231
|
-
`idpicker`,
|
|
4232
|
-
{ form: parentSchema.title, column,
|
|
4478
|
+
`idpicker-default`,
|
|
4479
|
+
{ form: parentSchema.title, column, id: isMultiple ? watchIds : watchId },
|
|
4233
4480
|
],
|
|
4234
4481
|
queryFn: async () => {
|
|
4482
|
+
if (!watchId && (!watchIds || watchIds.length === 0)) {
|
|
4483
|
+
return { data: [] };
|
|
4484
|
+
}
|
|
4485
|
+
const searchValue = isMultiple ? watchIds.join(",") : watchId;
|
|
4235
4486
|
const data = await getTableData({
|
|
4236
4487
|
serverUrl,
|
|
4237
|
-
searching:
|
|
4488
|
+
searching: searchValue,
|
|
4238
4489
|
in_table: table,
|
|
4239
|
-
|
|
4240
|
-
|
|
4490
|
+
where: [{ id: column_ref, value: isMultiple ? watchIds : watchId }],
|
|
4491
|
+
limit: isMultiple ? watchIds.length : 1,
|
|
4492
|
+
offset: 0,
|
|
4241
4493
|
});
|
|
4242
4494
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
4243
4495
|
return [
|
|
@@ -4252,12 +4504,45 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4252
4504
|
});
|
|
4253
4505
|
return data;
|
|
4254
4506
|
},
|
|
4507
|
+
enabled: isMultiple
|
|
4508
|
+
? Array.isArray(watchIds) && watchIds.length > 0
|
|
4509
|
+
: !!watchId,
|
|
4255
4510
|
});
|
|
4511
|
+
// Effect to load selected values when component mounts
|
|
4512
|
+
useEffect(() => {
|
|
4513
|
+
if (isMultiple ? watchIds.length > 0 : !!watchId) {
|
|
4514
|
+
queryDefault.refetch();
|
|
4515
|
+
}
|
|
4516
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4517
|
+
}, []);
|
|
4518
|
+
// Effect to trigger initial data fetch when popover opens
|
|
4519
|
+
useEffect(() => {
|
|
4520
|
+
if (openSearchResult) {
|
|
4521
|
+
// Reset search text when opening the popover
|
|
4522
|
+
setSearchText("");
|
|
4523
|
+
// Reset page to first page
|
|
4524
|
+
setPage(0);
|
|
4525
|
+
// Fetch initial data
|
|
4526
|
+
query.refetch();
|
|
4527
|
+
}
|
|
4528
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4529
|
+
}, [openSearchResult]);
|
|
4256
4530
|
const onSearchChange = async (event) => {
|
|
4257
4531
|
setSearchText(event.target.value);
|
|
4258
4532
|
setPage(0);
|
|
4259
|
-
|
|
4533
|
+
query.refetch();
|
|
4534
|
+
};
|
|
4535
|
+
const handleLimitChange = (event) => {
|
|
4536
|
+
const newLimit = Number(event.target.value);
|
|
4537
|
+
setLimit(newLimit);
|
|
4538
|
+
// Reset to first page when changing limit
|
|
4539
|
+
setPage(0);
|
|
4540
|
+
// Trigger a new search with the updated limit
|
|
4541
|
+
query.refetch();
|
|
4260
4542
|
};
|
|
4543
|
+
const { isLoading, isFetching, data, isPending, isError } = query;
|
|
4544
|
+
const dataList = data?.data ?? [];
|
|
4545
|
+
const count = data?.count ?? 0;
|
|
4261
4546
|
const getPickedValue = () => {
|
|
4262
4547
|
if (Object.keys(idMap).length <= 0) {
|
|
4263
4548
|
return "";
|
|
@@ -4266,47 +4551,57 @@ const IdPicker = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4266
4551
|
if (record === undefined) {
|
|
4267
4552
|
return "";
|
|
4268
4553
|
}
|
|
4554
|
+
if (!!renderDisplay === true) {
|
|
4555
|
+
return renderDisplay(record);
|
|
4556
|
+
}
|
|
4269
4557
|
return record[display_column];
|
|
4270
4558
|
};
|
|
4271
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.
|
|
4559
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(removeIndex(`${column}.field_label`)))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4272
4560
|
gridRow, children: [isMultiple && (jsxs(Flex, { flexFlow: "wrap", gap: 1, children: [watchIds.map((id) => {
|
|
4273
4561
|
const item = idMap[id];
|
|
4274
4562
|
if (item === undefined) {
|
|
4275
4563
|
return (jsx(Text, { children: translate.t(removeIndex(`${colLabel}.undefined`)) }, id));
|
|
4276
4564
|
}
|
|
4277
4565
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
4278
|
-
setValue(
|
|
4566
|
+
setValue(colLabel, watchIds.filter((itemId) => itemId !== item[column_ref]));
|
|
4279
4567
|
}, children: !!renderDisplay === true
|
|
4280
4568
|
? renderDisplay(item)
|
|
4281
4569
|
: item[display_column] }, id));
|
|
4282
4570
|
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4283
4571
|
setOpenSearchResult(true);
|
|
4284
|
-
}, children: translate.t(removeIndex(`${colLabel}.
|
|
4572
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
4285
4573
|
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
|
-
|
|
4574
|
+
}, 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: {
|
|
4575
|
+
padding: "4px 8px",
|
|
4576
|
+
borderRadius: "4px",
|
|
4577
|
+
border: "1px solid #ccc",
|
|
4578
|
+
fontSize: "14px",
|
|
4579
|
+
}, 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) => {
|
|
4580
|
+
const selected = isMultiple
|
|
4581
|
+
? watchIds.some((id) => item[column_ref] === id)
|
|
4582
|
+
: watchId === item[column_ref];
|
|
4583
|
+
return (jsx(Box, { cursor: "pointer", onClick: () => {
|
|
4584
|
+
if (!isMultiple) {
|
|
4585
|
+
setOpenSearchResult(false);
|
|
4586
|
+
setValue(colLabel, item[column_ref]);
|
|
4587
|
+
return;
|
|
4588
|
+
}
|
|
4589
|
+
// For multiple selection, don't add if already selected
|
|
4590
|
+
if (selected)
|
|
4591
|
+
return;
|
|
4592
|
+
const newSet = new Set([
|
|
4593
|
+
...(watchIds ?? []),
|
|
4594
|
+
item[column_ref],
|
|
4595
|
+
]);
|
|
4596
|
+
setValue(colLabel, [...newSet]);
|
|
4597
|
+
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected
|
|
4598
|
+
? { color: "colorPalette.400/50", fontWeight: "bold" }
|
|
4599
|
+
: {}), children: !!renderDisplay === true
|
|
4600
|
+
? renderDisplay(item)
|
|
4601
|
+
: item[display_column] }, item[column_ref]));
|
|
4602
|
+
}) })) : (jsx(Text, { children: searchText
|
|
4603
|
+
? translate.t(removeIndex(`${colLabel}.empty_search_result`))
|
|
4604
|
+
: 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
4605
|
};
|
|
4311
4606
|
|
|
4312
4607
|
const NumberInputRoot = React.forwardRef(function NumberInput$1(props, ref) {
|
|
@@ -4320,17 +4615,17 @@ NumberInput.Label;
|
|
|
4320
4615
|
const NumberInputField = ({ schema, column, prefix, }) => {
|
|
4321
4616
|
const { setValue, formState: { errors }, watch, } = useFormContext();
|
|
4322
4617
|
const { translate } = useSchemaContext();
|
|
4323
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4618
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4324
4619
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4325
4620
|
const colLabel = `${prefix}${column}`;
|
|
4326
4621
|
const value = watch(`${colLabel}`);
|
|
4327
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4622
|
+
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
4623
|
setValue(`${colLabel}`, Number(event.target.value));
|
|
4329
|
-
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4624
|
+
} }) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4330
4625
|
};
|
|
4331
4626
|
|
|
4332
4627
|
const ObjectInput = ({ schema, column, prefix }) => {
|
|
4333
|
-
const { properties,
|
|
4628
|
+
const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
|
|
4334
4629
|
const { translate } = useSchemaContext();
|
|
4335
4630
|
const colLabel = `${prefix}${column}`;
|
|
4336
4631
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -4338,25 +4633,28 @@ const ObjectInput = ({ schema, column, prefix }) => {
|
|
|
4338
4633
|
if (properties === undefined) {
|
|
4339
4634
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4340
4635
|
}
|
|
4341
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label",
|
|
4636
|
+
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: {
|
|
4637
|
+
base: "colorPalette.200",
|
|
4638
|
+
_dark: "colorPalette.800",
|
|
4639
|
+
}, gap: "4", padding: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: Object.keys(properties ?? {}).map((key) => {
|
|
4342
4640
|
return (
|
|
4343
4641
|
// @ts-expect-error find suitable types
|
|
4344
4642
|
jsx(ColumnRenderer, { column: `${key}`,
|
|
4345
4643
|
prefix: `${prefix}${column}.`,
|
|
4346
4644
|
properties }, `form-${colLabel}-${key}`));
|
|
4347
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
4645
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4348
4646
|
};
|
|
4349
4647
|
|
|
4350
4648
|
const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
4351
4649
|
const { formState: { errors }, setValue, getValues, } = useFormContext();
|
|
4352
4650
|
const { translate } = useSchemaContext();
|
|
4353
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4651
|
+
const { required, gridColumn = "span 12", gridRow = "span 1" } = schema;
|
|
4354
4652
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4355
4653
|
const entries = Object.entries(getValues(column) ?? {});
|
|
4356
4654
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4357
4655
|
const [newKey, setNewKey] = useState();
|
|
4358
4656
|
const [newValue, setNewValue] = useState();
|
|
4359
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
4657
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4360
4658
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4361
4659
|
const filtered = entries.filter(([target]) => {
|
|
4362
4660
|
return target !== key;
|
|
@@ -4396,16 +4694,16 @@ const RecordInput$1 = ({ column, schema, prefix }) => {
|
|
|
4396
4694
|
setShowNewEntries(true);
|
|
4397
4695
|
setNewKey(undefined);
|
|
4398
4696
|
setNewValue(undefined);
|
|
4399
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
4697
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4400
4698
|
};
|
|
4401
4699
|
|
|
4402
4700
|
const StringInputField = ({ column, schema, prefix, }) => {
|
|
4403
4701
|
const { register, formState: { errors }, } = useFormContext();
|
|
4404
4702
|
const { translate } = useSchemaContext();
|
|
4405
|
-
const { required, gridColumn, gridRow } = schema;
|
|
4703
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4406
4704
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4407
4705
|
const colLabel = `${prefix}${column}`;
|
|
4408
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
4706
|
+
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
4707
|
};
|
|
4410
4708
|
|
|
4411
4709
|
const RadioCardItem = React.forwardRef(function RadioCardItem(props, ref) {
|
|
@@ -4503,9 +4801,180 @@ const TagPicker = ({ column, schema, prefix }) => {
|
|
|
4503
4801
|
}), errors[`${column}`] && (jsx(Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4504
4802
|
};
|
|
4505
4803
|
|
|
4804
|
+
const TextAreaInput = ({ column, schema, prefix, }) => {
|
|
4805
|
+
const { register, formState: { errors }, } = useFormContext();
|
|
4806
|
+
const { translate } = useSchemaContext();
|
|
4807
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4808
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
4809
|
+
const colLabel = `${prefix}${column}`;
|
|
4810
|
+
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`)) }))] }) }));
|
|
4811
|
+
};
|
|
4812
|
+
|
|
4813
|
+
function TimePicker$1({ hour, setHour, minute, setMinute, meridiem, setMeridiem, meridiemLabel = {
|
|
4814
|
+
am: "am",
|
|
4815
|
+
pm: "pm",
|
|
4816
|
+
}, onChange = (_newValue) => { }, }) {
|
|
4817
|
+
// Refs for focus management
|
|
4818
|
+
const hourInputRef = useRef(null);
|
|
4819
|
+
const minuteInputRef = useRef(null);
|
|
4820
|
+
useRef(null);
|
|
4821
|
+
// Centralized handler for key events, value changes, and focus management
|
|
4822
|
+
const handleKeyDown = (e, field) => {
|
|
4823
|
+
const input = e.target;
|
|
4824
|
+
const value = input.value;
|
|
4825
|
+
// Handle navigation between fields
|
|
4826
|
+
if (e.key === "Tab") {
|
|
4827
|
+
// Tab is handled by the browser, no need to override
|
|
4828
|
+
return;
|
|
4829
|
+
}
|
|
4830
|
+
if (e.key === ":" && field === "hour") {
|
|
4831
|
+
e.preventDefault();
|
|
4832
|
+
minuteInputRef.current?.focus();
|
|
4833
|
+
return;
|
|
4834
|
+
}
|
|
4835
|
+
if (e.key === "Backspace" && value === "") {
|
|
4836
|
+
e.preventDefault();
|
|
4837
|
+
if (field === "minute") {
|
|
4838
|
+
hourInputRef.current?.focus();
|
|
4839
|
+
}
|
|
4840
|
+
else if (field === "meridiem") {
|
|
4841
|
+
minuteInputRef.current?.focus();
|
|
4842
|
+
}
|
|
4843
|
+
return;
|
|
4844
|
+
}
|
|
4845
|
+
// Handle number inputs
|
|
4846
|
+
if (field === "hour") {
|
|
4847
|
+
if (e.key.match(/^[0-9]$/)) {
|
|
4848
|
+
const newValue = value + e.key;
|
|
4849
|
+
const numValue = parseInt(newValue, 10);
|
|
4850
|
+
console.log("newValue", newValue, numValue);
|
|
4851
|
+
if (numValue > 12) {
|
|
4852
|
+
const digitValue = parseInt(e.key, 10);
|
|
4853
|
+
setHour(digitValue);
|
|
4854
|
+
onChange({ hour: digitValue, minute, meridiem });
|
|
4855
|
+
return;
|
|
4856
|
+
}
|
|
4857
|
+
// Auto-advance to minutes if we have a valid hour (1-12)
|
|
4858
|
+
if (numValue >= 1 && numValue <= 12) {
|
|
4859
|
+
// Set the hour value
|
|
4860
|
+
setHour(numValue);
|
|
4861
|
+
onChange({ hour: numValue, minute, meridiem });
|
|
4862
|
+
// Move to minute input
|
|
4863
|
+
e.preventDefault();
|
|
4864
|
+
minuteInputRef.current?.focus();
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
}
|
|
4868
|
+
else if (field === "minute") {
|
|
4869
|
+
if (e.key.match(/^[0-9]$/)) {
|
|
4870
|
+
const newValue = value + e.key;
|
|
4871
|
+
const numValue = parseInt(newValue, 10);
|
|
4872
|
+
console.log("newValue minute", newValue, numValue, numValue > 60, numValue >= 0 && numValue <= 59, e.key);
|
|
4873
|
+
if (numValue > 60) {
|
|
4874
|
+
const digitValue = parseInt(e.key, 10);
|
|
4875
|
+
setMinute(digitValue);
|
|
4876
|
+
onChange({ hour, minute: digitValue, meridiem });
|
|
4877
|
+
return;
|
|
4878
|
+
}
|
|
4879
|
+
// Auto-advance to meridiem if we have a valid minute (0-59)
|
|
4880
|
+
if (numValue >= 0 && numValue <= 59) {
|
|
4881
|
+
// Set the minute value
|
|
4882
|
+
setMinute(numValue);
|
|
4883
|
+
onChange({ hour, minute: numValue, meridiem });
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
};
|
|
4888
|
+
// Handle meridiem button click
|
|
4889
|
+
const handleMeridiemClick = (newMeridiem) => {
|
|
4890
|
+
setMeridiem(newMeridiem);
|
|
4891
|
+
onChange({ hour, minute, meridiem: newMeridiem });
|
|
4892
|
+
};
|
|
4893
|
+
const handleClear = () => {
|
|
4894
|
+
setHour(null);
|
|
4895
|
+
setMinute(null);
|
|
4896
|
+
setMeridiem(null);
|
|
4897
|
+
onChange({ hour: null, minute: null, meridiem: null });
|
|
4898
|
+
// Focus the hour field after clearing
|
|
4899
|
+
hourInputRef.current?.focus();
|
|
4900
|
+
};
|
|
4901
|
+
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, {}) })] }) }));
|
|
4902
|
+
}
|
|
4903
|
+
|
|
4904
|
+
const TimePicker = ({ column, schema, prefix }) => {
|
|
4905
|
+
const { watch, formState: { errors }, setValue, } = useFormContext();
|
|
4906
|
+
const { translate } = useSchemaContext();
|
|
4907
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", timeFormat = "HH:mm:ss", displayTimeFormat = "hh:mm A", } = schema;
|
|
4908
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
4909
|
+
const colLabel = `${prefix}${column}`;
|
|
4910
|
+
const [open, setOpen] = useState(false);
|
|
4911
|
+
const value = watch(colLabel);
|
|
4912
|
+
const displayedTime = dayjs(`1970-01-01T${value}Z`).isValid()
|
|
4913
|
+
? dayjs(`1970-01-01T${value}Z`).utc().format(displayTimeFormat)
|
|
4914
|
+
: "";
|
|
4915
|
+
// Parse the initial time parts from the ISO time string (HH:mm:ss)
|
|
4916
|
+
const parseTime = (isoTime) => {
|
|
4917
|
+
if (!isoTime)
|
|
4918
|
+
return { hour: 12, minute: 0, meridiem: "am" };
|
|
4919
|
+
const parsed = dayjs(`1970-01-01T${isoTime}Z`).utc();
|
|
4920
|
+
if (!parsed.isValid())
|
|
4921
|
+
return { hour: 12, minute: 0, meridiem: "am" };
|
|
4922
|
+
let hour = parsed.hour();
|
|
4923
|
+
const minute = parsed.minute();
|
|
4924
|
+
const meridiem = hour >= 12 ? "pm" : "am";
|
|
4925
|
+
if (hour === 0)
|
|
4926
|
+
hour = 12;
|
|
4927
|
+
else if (hour > 12)
|
|
4928
|
+
hour -= 12;
|
|
4929
|
+
return { hour, minute, meridiem };
|
|
4930
|
+
};
|
|
4931
|
+
const initialTime = parseTime(value);
|
|
4932
|
+
const [hour, setHour] = useState(initialTime.hour);
|
|
4933
|
+
const [minute, setMinute] = useState(initialTime.minute);
|
|
4934
|
+
const [meridiem, setMeridiem] = useState(initialTime.meridiem);
|
|
4935
|
+
useEffect(() => {
|
|
4936
|
+
const { hour, minute, meridiem } = parseTime(value);
|
|
4937
|
+
setHour(hour);
|
|
4938
|
+
setMinute(minute);
|
|
4939
|
+
setMeridiem(meridiem);
|
|
4940
|
+
}, [value]);
|
|
4941
|
+
// Convert hour, minute, meridiem to 24-hour ISO time string
|
|
4942
|
+
const toIsoTime = (hour, minute, meridiem) => {
|
|
4943
|
+
if (hour === null || minute === null || meridiem === null)
|
|
4944
|
+
return null;
|
|
4945
|
+
let h = hour;
|
|
4946
|
+
if (meridiem === "am" && hour === 12)
|
|
4947
|
+
h = 0;
|
|
4948
|
+
else if (meridiem === "pm" && hour < 12)
|
|
4949
|
+
h = hour + 12;
|
|
4950
|
+
return dayjs(`1970-01-01T${h.toString().padStart(2, "0")}:${minute.toString().padStart(2, "0")}:00Z`)
|
|
4951
|
+
.utc()
|
|
4952
|
+
.format(timeFormat);
|
|
4953
|
+
};
|
|
4954
|
+
// Handle changes to time parts
|
|
4955
|
+
const handleTimeChange = ({ hour: newHour, minute: newMinute, meridiem: newMeridiem, }) => {
|
|
4956
|
+
setHour(newHour);
|
|
4957
|
+
setMinute(newMinute);
|
|
4958
|
+
setMeridiem(newMeridiem);
|
|
4959
|
+
const isoTime = toIsoTime(newHour, newMinute, newMeridiem);
|
|
4960
|
+
setValue(colLabel, isoTime, { shouldValidate: true, shouldDirty: true });
|
|
4961
|
+
};
|
|
4962
|
+
const containerRef = useRef(null);
|
|
4963
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4964
|
+
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: () => {
|
|
4965
|
+
setOpen(true);
|
|
4966
|
+
}, 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: {
|
|
4967
|
+
am: translate.t(removeIndex(`common.am`)),
|
|
4968
|
+
pm: translate.t(removeIndex(`common.pm`)),
|
|
4969
|
+
} }) }) }) }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4970
|
+
};
|
|
4971
|
+
|
|
4506
4972
|
const SchemaRenderer = ({ schema, prefix, column, }) => {
|
|
4507
4973
|
const colSchema = schema;
|
|
4508
|
-
const { type, variant, properties: innerProperties, foreign_key, items, } = schema;
|
|
4974
|
+
const { type, variant, properties: innerProperties, foreign_key, format, items, } = schema;
|
|
4975
|
+
if (variant === "custom-input") {
|
|
4976
|
+
return jsx(CustomInput, { schema: colSchema, prefix, column });
|
|
4977
|
+
}
|
|
4509
4978
|
if (type === "string") {
|
|
4510
4979
|
if ((schema.enum ?? []).length > 0) {
|
|
4511
4980
|
return jsx(EnumPicker, { schema: colSchema, prefix, column });
|
|
@@ -4514,9 +4983,15 @@ const SchemaRenderer = ({ schema, prefix, column, }) => {
|
|
|
4514
4983
|
idPickerSanityCheck(column, foreign_key);
|
|
4515
4984
|
return jsx(IdPicker, { schema: colSchema, prefix, column });
|
|
4516
4985
|
}
|
|
4517
|
-
if (
|
|
4986
|
+
if (format === "date") {
|
|
4518
4987
|
return jsx(DatePicker, { schema: colSchema, prefix, column });
|
|
4519
4988
|
}
|
|
4989
|
+
if (format === "time") {
|
|
4990
|
+
return jsx(TimePicker, { schema: colSchema, prefix, column });
|
|
4991
|
+
}
|
|
4992
|
+
if (variant === "text-area") {
|
|
4993
|
+
return jsx(TextAreaInput, { schema: colSchema, prefix, column });
|
|
4994
|
+
}
|
|
4520
4995
|
return jsx(StringInputField, { schema: colSchema, prefix, column });
|
|
4521
4996
|
}
|
|
4522
4997
|
if (type === "number" || type === "integer") {
|
|
@@ -4563,85 +5038,102 @@ const ColumnRenderer = ({ column, properties, prefix, }) => {
|
|
|
4563
5038
|
};
|
|
4564
5039
|
|
|
4565
5040
|
const ArrayViewer = ({ schema, column, prefix }) => {
|
|
4566
|
-
const {
|
|
5041
|
+
const { gridColumn = "span 12", gridRow = "span 1", required, items, } = schema;
|
|
4567
5042
|
const { translate } = useSchemaContext();
|
|
4568
5043
|
const colLabel = `${prefix}${column}`;
|
|
4569
5044
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4570
5045
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4571
5046
|
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
|
-
|
|
5047
|
+
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: {
|
|
5048
|
+
base: "colorPalette.200",
|
|
5049
|
+
_dark: "colorPalette.800",
|
|
5050
|
+
}, children: jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: jsx(SchemaViewer, { column: `${index}`,
|
|
5051
|
+
prefix: `${colLabel}.`,
|
|
5052
|
+
// @ts-expect-error find suitable types
|
|
5053
|
+
schema: { showLabel: false, ...(items ?? {}) } }) }) }, `form-${prefix}${column}.${index}`))) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4575
5054
|
};
|
|
4576
5055
|
|
|
4577
5056
|
const BooleanViewer = ({ schema, column, prefix, }) => {
|
|
4578
5057
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4579
5058
|
const { translate } = useSchemaContext();
|
|
4580
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5059
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4581
5060
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4582
5061
|
const colLabel = `${prefix}${column}`;
|
|
4583
5062
|
const value = watch(colLabel);
|
|
4584
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
5063
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4585
5064
|
gridRow, children: [jsx(Text, { children: value
|
|
4586
5065
|
? translate.t(removeIndex(`${colLabel}.true`))
|
|
4587
|
-
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
5066
|
+
: translate.t(removeIndex(`${colLabel}.false`)) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
5067
|
+
};
|
|
5068
|
+
|
|
5069
|
+
const CustomViewer = ({ column, schema, prefix }) => {
|
|
5070
|
+
const formContext = useFormContext();
|
|
5071
|
+
const { inputViewerRender } = schema;
|
|
5072
|
+
return (inputViewerRender &&
|
|
5073
|
+
inputViewerRender({
|
|
5074
|
+
column,
|
|
5075
|
+
schema,
|
|
5076
|
+
prefix,
|
|
5077
|
+
formContext,
|
|
5078
|
+
}));
|
|
4588
5079
|
};
|
|
4589
5080
|
|
|
4590
5081
|
const DateViewer = ({ column, schema, prefix }) => {
|
|
4591
5082
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4592
5083
|
const { translate } = useSchemaContext();
|
|
4593
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5084
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", displayDateFormat = "YYYY-MM-DD", } = schema;
|
|
4594
5085
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4595
5086
|
const colLabel = `${prefix}${column}`;
|
|
4596
5087
|
const selectedDate = watch(colLabel);
|
|
4597
|
-
|
|
4598
|
-
|
|
5088
|
+
const displayDate = dayjs.utc(selectedDate).format(displayDateFormat);
|
|
5089
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
5090
|
+
gridRow, children: [jsxs(Text, { children: [" ", selectedDate !== undefined ? displayDate : ""] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4599
5091
|
};
|
|
4600
5092
|
|
|
5093
|
+
function translateWrapper({ prefix, column, label, translate, }) {
|
|
5094
|
+
return translate.t(removeIndex(`${prefix}${column}.${label}`));
|
|
5095
|
+
}
|
|
5096
|
+
|
|
4601
5097
|
const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
4602
5098
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4603
5099
|
const { translate } = useSchemaContext();
|
|
4604
5100
|
const { required } = schema;
|
|
4605
5101
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4606
|
-
const { gridColumn, gridRow, renderDisplay } = schema;
|
|
5102
|
+
const { gridColumn = "span 4", gridRow = "span 1", renderDisplay } = schema;
|
|
4607
5103
|
const colLabel = `${prefix}${column}`;
|
|
4608
5104
|
const watchEnum = watch(colLabel);
|
|
4609
5105
|
const watchEnums = (watch(colLabel) ?? []);
|
|
4610
|
-
|
|
5106
|
+
const customTranslate = (label) => {
|
|
5107
|
+
return translateWrapper({ prefix, column, label, translate });
|
|
5108
|
+
};
|
|
5109
|
+
return (jsxs(Field, { label: `${customTranslate(`field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4611
5110
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchEnums.map((enumValue) => {
|
|
4612
5111
|
const item = enumValue;
|
|
4613
5112
|
if (item === undefined) {
|
|
4614
5113
|
return jsx(Fragment, { children: "undefined" });
|
|
4615
5114
|
}
|
|
4616
|
-
return (jsx(Tag, {
|
|
5115
|
+
return (jsx(Tag, { children: !!renderDisplay === true
|
|
4617
5116
|
? renderDisplay(item)
|
|
4618
|
-
:
|
|
4619
|
-
}) })), !isMultiple &&
|
|
5117
|
+
: customTranslate(item) }));
|
|
5118
|
+
}) })), !isMultiple && jsx(Text, { children: customTranslate(watchEnum) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: customTranslate(`field_required`) }))] }));
|
|
4620
5119
|
};
|
|
4621
5120
|
|
|
4622
5121
|
const FileViewer = ({ column, schema, prefix }) => {
|
|
4623
|
-
const {
|
|
5122
|
+
const { watch } = useFormContext();
|
|
4624
5123
|
const { translate } = useSchemaContext();
|
|
4625
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5124
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", } = schema;
|
|
4626
5125
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4627
5126
|
const currentFiles = (watch(column) ?? []);
|
|
4628
5127
|
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`)) }))] }));
|
|
5128
|
+
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) => {
|
|
5129
|
+
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));
|
|
5130
|
+
}) }) }));
|
|
4639
5131
|
};
|
|
4640
5132
|
|
|
4641
5133
|
const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
4642
5134
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4643
5135
|
const { idMap, translate } = useSchemaContext();
|
|
4644
|
-
const { required, gridColumn, gridRow, renderDisplay, foreign_key } = schema;
|
|
5136
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", renderDisplay, foreign_key, } = schema;
|
|
4645
5137
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4646
5138
|
const { display_column } = foreign_key;
|
|
4647
5139
|
const colLabel = `${prefix}${column}`;
|
|
@@ -4657,7 +5149,7 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4657
5149
|
}
|
|
4658
5150
|
return record[display_column];
|
|
4659
5151
|
};
|
|
4660
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.
|
|
5152
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
4661
5153
|
gridRow, children: [isMultiple && (jsx(Flex, { flexFlow: "wrap", gap: 1, children: watchIds.map((id) => {
|
|
4662
5154
|
const item = idMap[id];
|
|
4663
5155
|
if (item === undefined) {
|
|
@@ -4666,21 +5158,21 @@ const IdViewer = ({ column, schema, prefix, isMultiple = false, }) => {
|
|
|
4666
5158
|
return (jsx(Tag, { closable: true, children: !!renderDisplay === true
|
|
4667
5159
|
? renderDisplay(item)
|
|
4668
5160
|
: item[display_column] }, id));
|
|
4669
|
-
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
5161
|
+
}) })), !isMultiple && jsx(Text, { children: getPickedValue() }), errors[`${colLabel}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4670
5162
|
};
|
|
4671
5163
|
|
|
4672
5164
|
const NumberViewer = ({ schema, column, prefix, }) => {
|
|
4673
5165
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4674
5166
|
const { translate } = useSchemaContext();
|
|
4675
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5167
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4676
5168
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4677
5169
|
const colLabel = `${prefix}${column}`;
|
|
4678
5170
|
const value = watch(colLabel);
|
|
4679
|
-
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
5171
|
+
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
5172
|
};
|
|
4681
5173
|
|
|
4682
5174
|
const ObjectViewer = ({ schema, column, prefix }) => {
|
|
4683
|
-
const { properties,
|
|
5175
|
+
const { properties, gridColumn = "span 12", gridRow = "span 1", required, showLabel = true, } = schema;
|
|
4684
5176
|
const { translate } = useSchemaContext();
|
|
4685
5177
|
const colLabel = `${prefix}${column}`;
|
|
4686
5178
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
@@ -4688,25 +5180,28 @@ const ObjectViewer = ({ schema, column, prefix }) => {
|
|
|
4688
5180
|
if (properties === undefined) {
|
|
4689
5181
|
throw new Error(`properties is undefined when using ObjectInput`);
|
|
4690
5182
|
}
|
|
4691
|
-
return (jsxs(Box, { gridRow, gridColumn, children: [jsxs(Box, { as: "label",
|
|
5183
|
+
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: {
|
|
5184
|
+
base: "colorPalette.200",
|
|
5185
|
+
_dark: "colorPalette.800",
|
|
5186
|
+
}, children: Object.keys(properties ?? {}).map((key) => {
|
|
4692
5187
|
return (
|
|
4693
5188
|
// @ts-expect-error find suitable types
|
|
4694
5189
|
jsx(ColumnViewer, { column: `${key}`,
|
|
4695
5190
|
prefix: `${prefix}${column}.`,
|
|
4696
5191
|
properties }, `form-objectviewer-${colLabel}-${key}`));
|
|
4697
|
-
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.
|
|
5192
|
+
}) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }));
|
|
4698
5193
|
};
|
|
4699
5194
|
|
|
4700
5195
|
const RecordInput = ({ column, schema, prefix }) => {
|
|
4701
5196
|
const { formState: { errors }, setValue, getValues, } = useFormContext();
|
|
4702
5197
|
const { translate } = useSchemaContext();
|
|
4703
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5198
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4704
5199
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4705
5200
|
const entries = Object.entries(getValues(column) ?? {});
|
|
4706
5201
|
const [showNewEntries, setShowNewEntries] = useState(false);
|
|
4707
5202
|
const [newKey, setNewKey] = useState();
|
|
4708
5203
|
const [newValue, setNewValue] = useState();
|
|
4709
|
-
return (jsxs(Field, { label: `${translate.t(`${column}.
|
|
5204
|
+
return (jsxs(Field, { label: `${translate.t(`${column}.field_label`)}`, required: isRequired, alignItems: "stretch", gridColumn, gridRow, children: [entries.map(([key, value]) => {
|
|
4710
5205
|
return (jsxs(Grid, { templateColumns: "1fr 1fr auto", gap: 1, children: [jsx(Input, { value: key, onChange: (e) => {
|
|
4711
5206
|
const filtered = entries.filter(([target]) => {
|
|
4712
5207
|
return target !== key;
|
|
@@ -4746,7 +5241,17 @@ const RecordInput = ({ column, schema, prefix }) => {
|
|
|
4746
5241
|
setShowNewEntries(true);
|
|
4747
5242
|
setNewKey(undefined);
|
|
4748
5243
|
setNewValue(undefined);
|
|
4749
|
-
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.
|
|
5244
|
+
}, children: translate.t(`${column}.addNew`) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
5245
|
+
};
|
|
5246
|
+
|
|
5247
|
+
const StringViewer = ({ column, schema, prefix, }) => {
|
|
5248
|
+
const { watch, formState: { errors }, } = useFormContext();
|
|
5249
|
+
const { translate } = useSchemaContext();
|
|
5250
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
5251
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
5252
|
+
const colLabel = `${prefix}${column}`;
|
|
5253
|
+
const value = watch(colLabel);
|
|
5254
|
+
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
5255
|
};
|
|
4751
5256
|
|
|
4752
5257
|
const TagViewer = ({ column, schema, prefix }) => {
|
|
@@ -4834,19 +5339,36 @@ const TagViewer = ({ column, schema, prefix }) => {
|
|
|
4834
5339
|
}), errors[`${column}`] && (jsx(Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4835
5340
|
};
|
|
4836
5341
|
|
|
4837
|
-
const
|
|
5342
|
+
const TextAreaViewer = ({ column, schema, prefix, }) => {
|
|
4838
5343
|
const { watch, formState: { errors }, } = useFormContext();
|
|
4839
5344
|
const { translate } = useSchemaContext();
|
|
4840
|
-
const { required, gridColumn, gridRow } = schema;
|
|
5345
|
+
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4841
5346
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4842
5347
|
const colLabel = `${prefix}${column}`;
|
|
4843
5348
|
const value = watch(colLabel);
|
|
4844
|
-
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.
|
|
5349
|
+
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`)) }))] }) }));
|
|
5350
|
+
};
|
|
5351
|
+
|
|
5352
|
+
const TimeViewer = ({ column, schema, prefix, }) => {
|
|
5353
|
+
const { watch, formState: { errors }, } = useFormContext();
|
|
5354
|
+
const { translate } = useSchemaContext();
|
|
5355
|
+
const { required, gridColumn = "span 4", gridRow = "span 1", displayTimeFormat = "hh:mm A" } = schema;
|
|
5356
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
5357
|
+
const colLabel = `${prefix}${column}`;
|
|
5358
|
+
const selectedDate = watch(colLabel);
|
|
5359
|
+
const displayedTime = dayjs(`1970-01-01T${selectedDate}Z`).isValid()
|
|
5360
|
+
? dayjs(`1970-01-01T${selectedDate}Z`).utc().format(displayTimeFormat)
|
|
5361
|
+
: "";
|
|
5362
|
+
return (jsxs(Field, { label: `${translate.t(removeIndex(`${column}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
5363
|
+
gridRow, children: [jsx(Text, { children: displayedTime }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: translate.t(`${column}.field_required`) }))] }));
|
|
4845
5364
|
};
|
|
4846
5365
|
|
|
4847
5366
|
const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
4848
5367
|
const colSchema = schema;
|
|
4849
|
-
const { type, variant, properties: innerProperties, foreign_key, items, } = schema;
|
|
5368
|
+
const { type, variant, properties: innerProperties, foreign_key, items, format, } = schema;
|
|
5369
|
+
if (variant === "custom-input") {
|
|
5370
|
+
return jsx(CustomViewer, { schema: colSchema, prefix, column });
|
|
5371
|
+
}
|
|
4850
5372
|
if (type === "string") {
|
|
4851
5373
|
if ((schema.enum ?? []).length > 0) {
|
|
4852
5374
|
return jsx(EnumViewer, { schema: colSchema, prefix, column });
|
|
@@ -4855,9 +5377,15 @@ const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
|
4855
5377
|
idPickerSanityCheck(column, foreign_key);
|
|
4856
5378
|
return jsx(IdViewer, { schema: colSchema, prefix, column });
|
|
4857
5379
|
}
|
|
4858
|
-
if (
|
|
5380
|
+
if (format === "time") {
|
|
5381
|
+
return jsx(TimeViewer, { schema: colSchema, prefix, column });
|
|
5382
|
+
}
|
|
5383
|
+
if (format === "date") {
|
|
4859
5384
|
return jsx(DateViewer, { schema: colSchema, prefix, column });
|
|
4860
5385
|
}
|
|
5386
|
+
if (variant === "text-area") {
|
|
5387
|
+
return jsx(TextAreaViewer, { schema: colSchema, prefix, column });
|
|
5388
|
+
}
|
|
4861
5389
|
return jsx(StringViewer, { schema: colSchema, prefix, column });
|
|
4862
5390
|
}
|
|
4863
5391
|
if (type === "number" || type === "integer") {
|
|
@@ -4980,7 +5508,7 @@ const FormBody = () => {
|
|
|
4980
5508
|
include,
|
|
4981
5509
|
});
|
|
4982
5510
|
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("
|
|
5511
|
+
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
5512
|
setIsError(false);
|
|
4985
5513
|
setIsSubmiting(false);
|
|
4986
5514
|
setIsSuccess(false);
|
|
@@ -4988,10 +5516,10 @@ const FormBody = () => {
|
|
|
4988
5516
|
setValidatedData(undefined);
|
|
4989
5517
|
const data = await getUpdatedData();
|
|
4990
5518
|
methods.reset(data);
|
|
4991
|
-
}, formNoValidate: true, children: translate.t("
|
|
5519
|
+
}, formNoValidate: true, children: translate.t("submit_again") }) })] }));
|
|
4992
5520
|
}
|
|
4993
5521
|
if (isConfirming) {
|
|
4994
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: 4, gridTemplateColumns: "repeat(12, 1fr)", gridTemplateRows:
|
|
5522
|
+
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
5523
|
return (jsx(ColumnViewer
|
|
4996
5524
|
// @ts-expect-error find suitable types
|
|
4997
5525
|
, {
|
|
@@ -5003,7 +5531,7 @@ const FormBody = () => {
|
|
|
5003
5531
|
onFormSubmit(validatedData);
|
|
5004
5532
|
}, 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
5533
|
}
|
|
5006
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)",
|
|
5534
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: ordered.map((column) => {
|
|
5007
5535
|
return (jsx(ColumnRenderer
|
|
5008
5536
|
// @ts-expect-error find suitable types
|
|
5009
5537
|
, {
|
|
@@ -5019,8 +5547,8 @@ const FormTitle = () => {
|
|
|
5019
5547
|
return jsx(Heading, { children: translate.t("title") });
|
|
5020
5548
|
};
|
|
5021
5549
|
|
|
5022
|
-
const DefaultForm = ({ formConfig, }) => {
|
|
5023
|
-
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
5550
|
+
const DefaultForm = ({ formConfig, showTitle = true, }) => {
|
|
5551
|
+
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [showTitle && jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
5024
5552
|
};
|
|
5025
5553
|
|
|
5026
5554
|
const useForm = ({ preLoadedValues, keyPrefix }) => {
|
|
@@ -5053,4 +5581,4 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
|
|
|
5053
5581
|
}
|
|
5054
5582
|
};
|
|
5055
5583
|
|
|
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 };
|
|
5584
|
+
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 };
|