@bsol-oss/react-datatable5 7.3.5 → 7.4.0
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.js
CHANGED
|
@@ -12,13 +12,13 @@ var bi = require('react-icons/bi');
|
|
|
12
12
|
var cg = require('react-icons/cg');
|
|
13
13
|
var io = require('react-icons/io');
|
|
14
14
|
var hi2 = require('react-icons/hi2');
|
|
15
|
+
var hi = require('react-icons/hi');
|
|
15
16
|
var reactTable = require('@tanstack/react-table');
|
|
16
17
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
17
18
|
var bs = require('react-icons/bs');
|
|
18
19
|
var gr = require('react-icons/gr');
|
|
19
20
|
var reactQuery = require('@tanstack/react-query');
|
|
20
21
|
var io5 = require('react-icons/io5');
|
|
21
|
-
var hi = require('react-icons/hi');
|
|
22
22
|
var adapter = require('@atlaskit/pragmatic-drag-and-drop/element/adapter');
|
|
23
23
|
var invariant = require('tiny-invariant');
|
|
24
24
|
var axios = require('axios');
|
|
@@ -612,6 +612,27 @@ const snakeToLabel = (str) => {
|
|
|
612
612
|
.join(" "); // Join with space
|
|
613
613
|
};
|
|
614
614
|
|
|
615
|
+
const ToggleTip = React__namespace.forwardRef(function ToggleTip(props, ref) {
|
|
616
|
+
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
617
|
+
return (jsxRuntime.jsxs(react.Popover.Root, { ...rest, positioning: { ...rest.positioning, gutter: 4 }, children: [jsxRuntime.jsx(react.Popover.Trigger, { asChild: true, children: children }), jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Popover.Positioner, { children: jsxRuntime.jsxs(react.Popover.Content, { width: "auto", px: "2", py: "1", textStyle: "xs", rounded: "sm", ref: ref, children: [showArrow && (jsxRuntime.jsx(react.Popover.Arrow, { children: jsxRuntime.jsx(react.Popover.ArrowTip, {}) })), content] }) }) })] }));
|
|
618
|
+
});
|
|
619
|
+
const InfoTip = React__namespace.forwardRef(function InfoTip(props, ref) {
|
|
620
|
+
const { children, ...rest } = props;
|
|
621
|
+
return (jsxRuntime.jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsxRuntime.jsx(react.IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "gray", children: jsxRuntime.jsx(hi.HiOutlineInformationCircle, {}) }) }));
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
const DataListRoot = react.DataList.Root;
|
|
625
|
+
const DataListItem = React__namespace.forwardRef(function DataListItem(props, ref) {
|
|
626
|
+
const { label, info, value, children, grow, ...rest } = props;
|
|
627
|
+
return (jsxRuntime.jsxs(react.DataList.Item, { ref: ref, ...rest, children: [jsxRuntime.jsxs(react.DataList.ItemLabel, { flex: grow ? "1" : undefined, children: [label, info && jsxRuntime.jsx(InfoTip, { children: info })] }), jsxRuntime.jsx(react.DataList.ItemValue, { flex: grow ? "1" : undefined, children: value }), children] }));
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const RecordDisplay = ({ object, dataListProps, }) => {
|
|
631
|
+
return (jsxRuntime.jsx(DataListRoot, { gap: 4, padding: 4, display: "grid", variant: "subtle", orientation: "horizontal", overflow: "auto", ...dataListProps, children: Object.entries(object).map(([field, value]) => {
|
|
632
|
+
return (jsxRuntime.jsx(DataListItem, { label: snakeToLabel(field), value: JSON.stringify(value) }, field));
|
|
633
|
+
}) }));
|
|
634
|
+
};
|
|
635
|
+
|
|
615
636
|
const formatValue = (value) => {
|
|
616
637
|
if (typeof value === "object") {
|
|
617
638
|
return JSON.stringify(value);
|
|
@@ -632,6 +653,10 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
632
653
|
if (variant == "horizontal") {
|
|
633
654
|
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
634
655
|
return (jsxRuntime.jsx(react.Card.Root, { children: jsxRuntime.jsx(react.Card.Body, { children: jsxRuntime.jsx(react.DataList.Root, { gap: 4, padding: 4, display: "grid", variant: "subtle", orientation: "horizontal", overflow: "auto", children: row.getVisibleCells().map((cell) => {
|
|
656
|
+
const value = cell.getValue();
|
|
657
|
+
if (typeof value === "object") {
|
|
658
|
+
return jsxRuntime.jsx(RecordDisplay, { object: value });
|
|
659
|
+
}
|
|
635
660
|
return (jsxRuntime.jsxs(react.DataList.Item, { children: [jsxRuntime.jsx(react.DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsxRuntime.jsx(react.DataList.ItemValue, { wordBreak: "break-word", textOverflow: "ellipsis", overflow: "hidden", children: `${formatValue(cell.getValue())}` })] }, cell.id));
|
|
636
661
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
637
662
|
}) }));
|
|
@@ -1689,6 +1714,7 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1689
1714
|
serverUrl,
|
|
1690
1715
|
in_table: in_table,
|
|
1691
1716
|
limit: limit,
|
|
1717
|
+
where: [{ id: column_ref, value: watchId }],
|
|
1692
1718
|
});
|
|
1693
1719
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
1694
1720
|
return [
|
|
@@ -1714,15 +1740,13 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1714
1740
|
setSearchText(event.target.value);
|
|
1715
1741
|
setLimit(10);
|
|
1716
1742
|
};
|
|
1717
|
-
const
|
|
1743
|
+
const watchId = watch(column);
|
|
1744
|
+
const watchIds = (watch(column) ?? []);
|
|
1718
1745
|
const getPickedValue = () => {
|
|
1719
|
-
if (selectedIds.length <= 0) {
|
|
1720
|
-
return "";
|
|
1721
|
-
}
|
|
1722
1746
|
if (Object.keys(idMap).length <= 0) {
|
|
1723
1747
|
return "";
|
|
1724
1748
|
}
|
|
1725
|
-
const record = idMap[
|
|
1749
|
+
const record = idMap[watchId];
|
|
1726
1750
|
if (record === undefined) {
|
|
1727
1751
|
return "";
|
|
1728
1752
|
}
|
|
@@ -1735,7 +1759,7 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1735
1759
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
1736
1760
|
}
|
|
1737
1761
|
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
1738
|
-
setValue(column,
|
|
1762
|
+
setValue(column, watchIds.filter((id) => id != item[column_ref]));
|
|
1739
1763
|
}, children: !!renderDisplay === true
|
|
1740
1764
|
? renderDisplay(item)
|
|
1741
1765
|
: item[display_column] }));
|
|
@@ -1751,15 +1775,17 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1751
1775
|
}, children: close ?? "Close" }), jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children:
|
|
1752
1776
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1753
1777
|
dataList.map((item) => {
|
|
1754
|
-
const selected =
|
|
1778
|
+
const selected = isMultiple
|
|
1779
|
+
? watchIds.some((id) => item[column_ref] === id)
|
|
1780
|
+
: watchId === item[column_ref];
|
|
1755
1781
|
return (jsxRuntime.jsx(react.Box, { cursor: "pointer", onClick: () => {
|
|
1756
1782
|
if (!isMultiple) {
|
|
1757
1783
|
setOpenSearchResult(false);
|
|
1758
|
-
setValue(column,
|
|
1784
|
+
setValue(column, item[column_ref]);
|
|
1759
1785
|
return;
|
|
1760
1786
|
}
|
|
1761
1787
|
const newSet = new Set([
|
|
1762
|
-
...(
|
|
1788
|
+
...(watchIds ?? []),
|
|
1763
1789
|
item[column_ref],
|
|
1764
1790
|
]);
|
|
1765
1791
|
setValue(column, [...newSet]);
|
|
@@ -1777,21 +1803,6 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1777
1803
|
}, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
1778
1804
|
};
|
|
1779
1805
|
|
|
1780
|
-
const ToggleTip = React__namespace.forwardRef(function ToggleTip(props, ref) {
|
|
1781
|
-
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
1782
|
-
return (jsxRuntime.jsxs(react.Popover.Root, { ...rest, positioning: { ...rest.positioning, gutter: 4 }, children: [jsxRuntime.jsx(react.Popover.Trigger, { asChild: true, children: children }), jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Popover.Positioner, { children: jsxRuntime.jsxs(react.Popover.Content, { width: "auto", px: "2", py: "1", textStyle: "xs", rounded: "sm", ref: ref, children: [showArrow && (jsxRuntime.jsx(react.Popover.Arrow, { children: jsxRuntime.jsx(react.Popover.ArrowTip, {}) })), content] }) }) })] }));
|
|
1783
|
-
});
|
|
1784
|
-
const InfoTip = React__namespace.forwardRef(function InfoTip(props, ref) {
|
|
1785
|
-
const { children, ...rest } = props;
|
|
1786
|
-
return (jsxRuntime.jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsxRuntime.jsx(react.IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "gray", children: jsxRuntime.jsx(hi.HiOutlineInformationCircle, {}) }) }));
|
|
1787
|
-
});
|
|
1788
|
-
|
|
1789
|
-
const DataListRoot = react.DataList.Root;
|
|
1790
|
-
const DataListItem = React__namespace.forwardRef(function DataListItem(props, ref) {
|
|
1791
|
-
const { label, info, value, children, grow, ...rest } = props;
|
|
1792
|
-
return (jsxRuntime.jsxs(react.DataList.Item, { ref: ref, ...rest, children: [jsxRuntime.jsxs(react.DataList.ItemLabel, { flex: grow ? "1" : undefined, children: [label, info && jsxRuntime.jsx(InfoTip, { children: info })] }), jsxRuntime.jsx(react.DataList.ItemValue, { flex: grow ? "1" : undefined, children: value }), children] }));
|
|
1793
|
-
});
|
|
1794
|
-
|
|
1795
1806
|
const IdViewer = ({ value, in_table, column_ref, display_column, column, }) => {
|
|
1796
1807
|
const { schema, serverUrl } = useSchemaContext();
|
|
1797
1808
|
if (schema.properties == undefined) {
|
|
@@ -2221,6 +2232,7 @@ const EnumPicker = ({ column, isMultiple = false }) => {
|
|
|
2221
2232
|
const [limit, setLimit] = React.useState(10);
|
|
2222
2233
|
const [openSearchResult, setOpenSearchResult] = React.useState();
|
|
2223
2234
|
const ref = React.useRef(null);
|
|
2235
|
+
const watchEnum = watch(column);
|
|
2224
2236
|
const watchEnums = (watch(column) ?? []);
|
|
2225
2237
|
const properties = (schema.properties[column] ?? {});
|
|
2226
2238
|
const dataList = properties.enum ?? [];
|
|
@@ -2244,17 +2256,19 @@ const EnumPicker = ({ column, isMultiple = false }) => {
|
|
|
2244
2256
|
setOpenSearchResult(true);
|
|
2245
2257
|
}, children: "Add" })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
2246
2258
|
setOpenSearchResult(true);
|
|
2247
|
-
}, children:
|
|
2259
|
+
}, children: watchEnum })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(react.Input, { placeholder: "Type to search", onChange: (event) => {
|
|
2248
2260
|
onSearchChange(event);
|
|
2249
2261
|
setOpenSearchResult(true);
|
|
2250
2262
|
}, autoComplete: "off", ref: ref }), jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsxs(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsxRuntime.jsx(react.Text, { children: `Search Result: ${count}, Showing ${limit}` }), jsxRuntime.jsx(Button, { onClick: async () => {
|
|
2251
2263
|
setOpenSearchResult(false);
|
|
2252
2264
|
}, children: "close" }), jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children: dataList.map((item) => {
|
|
2253
|
-
const selected =
|
|
2265
|
+
const selected = isMultiple
|
|
2266
|
+
? watchEnums.some((enumValue) => item === enumValue)
|
|
2267
|
+
: watchEnum == item;
|
|
2254
2268
|
return (jsxRuntime.jsx(react.Box, { cursor: "pointer", onClick: () => {
|
|
2255
2269
|
if (!isMultiple) {
|
|
2256
2270
|
setOpenSearchResult(false);
|
|
2257
|
-
setValue(column,
|
|
2271
|
+
setValue(column, item);
|
|
2258
2272
|
return;
|
|
2259
2273
|
}
|
|
2260
2274
|
const newSet = new Set([...(watchEnums ?? []), item]);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Flex, Text, Tag as Tag$1, Input, useDisclosure, DialogBackdrop, Menu, createRecipeContext, createContext as createContext$1, Pagination, usePaginationContext, Image,
|
|
2
|
+
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Flex, Text, Tag as Tag$1, Input, useDisclosure, DialogBackdrop, Menu, createRecipeContext, createContext as createContext$1, Pagination, usePaginationContext, Image, Popover, DataList, Card, Checkbox as Checkbox$1, Table as Table$1, Tooltip as Tooltip$1, Icon, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, EmptyState as EmptyState$2, VStack, List, CheckboxCard as CheckboxCard$1, Alert, Group, InputElement, Field as Field$1, NumberInput, Accordion, Show, RadioCard, CheckboxGroup, Heading, Center } 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, useMemo } from 'react';
|
|
@@ -11,13 +11,13 @@ import { BiDownArrow, BiUpArrow } from 'react-icons/bi';
|
|
|
11
11
|
import { CgClose } from 'react-icons/cg';
|
|
12
12
|
import { IoMdEye, IoMdCheckbox } from 'react-icons/io';
|
|
13
13
|
import { HiMiniEllipsisHorizontal, HiChevronLeft, HiChevronRight } from 'react-icons/hi2';
|
|
14
|
+
import { HiOutlineInformationCircle, HiColorSwatch } from 'react-icons/hi';
|
|
14
15
|
import { makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, flexRender, createColumnHelper } from '@tanstack/react-table';
|
|
15
16
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
16
17
|
import { BsExclamationCircleFill } from 'react-icons/bs';
|
|
17
18
|
import { GrAscend, GrDescend } from 'react-icons/gr';
|
|
18
19
|
import { useQueryClient, useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
19
20
|
import { IoReload } from 'react-icons/io5';
|
|
20
|
-
import { HiColorSwatch, HiOutlineInformationCircle } from 'react-icons/hi';
|
|
21
21
|
import { monitorForElements, draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
22
22
|
import invariant from 'tiny-invariant';
|
|
23
23
|
import axios from 'axios';
|
|
@@ -592,6 +592,27 @@ const snakeToLabel = (str) => {
|
|
|
592
592
|
.join(" "); // Join with space
|
|
593
593
|
};
|
|
594
594
|
|
|
595
|
+
const ToggleTip = React.forwardRef(function ToggleTip(props, ref) {
|
|
596
|
+
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
597
|
+
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] }) }) })] }));
|
|
598
|
+
});
|
|
599
|
+
const InfoTip = React.forwardRef(function InfoTip(props, ref) {
|
|
600
|
+
const { children, ...rest } = props;
|
|
601
|
+
return (jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsx(IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "gray", children: jsx(HiOutlineInformationCircle, {}) }) }));
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
const DataListRoot = DataList.Root;
|
|
605
|
+
const DataListItem = React.forwardRef(function DataListItem(props, ref) {
|
|
606
|
+
const { label, info, value, children, grow, ...rest } = props;
|
|
607
|
+
return (jsxs(DataList.Item, { ref: ref, ...rest, children: [jsxs(DataList.ItemLabel, { flex: grow ? "1" : undefined, children: [label, info && jsx(InfoTip, { children: info })] }), jsx(DataList.ItemValue, { flex: grow ? "1" : undefined, children: value }), children] }));
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
const RecordDisplay = ({ object, dataListProps, }) => {
|
|
611
|
+
return (jsx(DataListRoot, { gap: 4, padding: 4, display: "grid", variant: "subtle", orientation: "horizontal", overflow: "auto", ...dataListProps, children: Object.entries(object).map(([field, value]) => {
|
|
612
|
+
return (jsx(DataListItem, { label: snakeToLabel(field), value: JSON.stringify(value) }, field));
|
|
613
|
+
}) }));
|
|
614
|
+
};
|
|
615
|
+
|
|
595
616
|
const formatValue = (value) => {
|
|
596
617
|
if (typeof value === "object") {
|
|
597
618
|
return JSON.stringify(value);
|
|
@@ -612,6 +633,10 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
612
633
|
if (variant == "horizontal") {
|
|
613
634
|
return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
614
635
|
return (jsx(Card.Root, { children: jsx(Card.Body, { children: jsx(DataList.Root, { gap: 4, padding: 4, display: "grid", variant: "subtle", orientation: "horizontal", overflow: "auto", children: row.getVisibleCells().map((cell) => {
|
|
636
|
+
const value = cell.getValue();
|
|
637
|
+
if (typeof value === "object") {
|
|
638
|
+
return jsx(RecordDisplay, { object: value });
|
|
639
|
+
}
|
|
615
640
|
return (jsxs(DataList.Item, { children: [jsx(DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsx(DataList.ItemValue, { wordBreak: "break-word", textOverflow: "ellipsis", overflow: "hidden", children: `${formatValue(cell.getValue())}` })] }, cell.id));
|
|
616
641
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
617
642
|
}) }));
|
|
@@ -1669,6 +1694,7 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1669
1694
|
serverUrl,
|
|
1670
1695
|
in_table: in_table,
|
|
1671
1696
|
limit: limit,
|
|
1697
|
+
where: [{ id: column_ref, value: watchId }],
|
|
1672
1698
|
});
|
|
1673
1699
|
const newMap = Object.fromEntries((data ?? { data: [] }).data.map((item) => {
|
|
1674
1700
|
return [
|
|
@@ -1694,15 +1720,13 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1694
1720
|
setSearchText(event.target.value);
|
|
1695
1721
|
setLimit(10);
|
|
1696
1722
|
};
|
|
1697
|
-
const
|
|
1723
|
+
const watchId = watch(column);
|
|
1724
|
+
const watchIds = (watch(column) ?? []);
|
|
1698
1725
|
const getPickedValue = () => {
|
|
1699
|
-
if (selectedIds.length <= 0) {
|
|
1700
|
-
return "";
|
|
1701
|
-
}
|
|
1702
1726
|
if (Object.keys(idMap).length <= 0) {
|
|
1703
1727
|
return "";
|
|
1704
1728
|
}
|
|
1705
|
-
const record = idMap[
|
|
1729
|
+
const record = idMap[watchId];
|
|
1706
1730
|
if (record === undefined) {
|
|
1707
1731
|
return "";
|
|
1708
1732
|
}
|
|
@@ -1715,7 +1739,7 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1715
1739
|
return jsx(Fragment, { children: "undefined" });
|
|
1716
1740
|
}
|
|
1717
1741
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
1718
|
-
setValue(column,
|
|
1742
|
+
setValue(column, watchIds.filter((id) => id != item[column_ref]));
|
|
1719
1743
|
}, children: !!renderDisplay === true
|
|
1720
1744
|
? renderDisplay(item)
|
|
1721
1745
|
: item[display_column] }));
|
|
@@ -1731,15 +1755,17 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1731
1755
|
}, children: close ?? "Close" }), jsx(Flex, { flexFlow: "column wrap", children:
|
|
1732
1756
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1733
1757
|
dataList.map((item) => {
|
|
1734
|
-
const selected =
|
|
1758
|
+
const selected = isMultiple
|
|
1759
|
+
? watchIds.some((id) => item[column_ref] === id)
|
|
1760
|
+
: watchId === item[column_ref];
|
|
1735
1761
|
return (jsx(Box, { cursor: "pointer", onClick: () => {
|
|
1736
1762
|
if (!isMultiple) {
|
|
1737
1763
|
setOpenSearchResult(false);
|
|
1738
|
-
setValue(column,
|
|
1764
|
+
setValue(column, item[column_ref]);
|
|
1739
1765
|
return;
|
|
1740
1766
|
}
|
|
1741
1767
|
const newSet = new Set([
|
|
1742
|
-
...(
|
|
1768
|
+
...(watchIds ?? []),
|
|
1743
1769
|
item[column_ref],
|
|
1744
1770
|
]);
|
|
1745
1771
|
setValue(column, [...newSet]);
|
|
@@ -1757,21 +1783,6 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1757
1783
|
}, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
1758
1784
|
};
|
|
1759
1785
|
|
|
1760
|
-
const ToggleTip = React.forwardRef(function ToggleTip(props, ref) {
|
|
1761
|
-
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
1762
|
-
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] }) }) })] }));
|
|
1763
|
-
});
|
|
1764
|
-
const InfoTip = React.forwardRef(function InfoTip(props, ref) {
|
|
1765
|
-
const { children, ...rest } = props;
|
|
1766
|
-
return (jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsx(IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "gray", children: jsx(HiOutlineInformationCircle, {}) }) }));
|
|
1767
|
-
});
|
|
1768
|
-
|
|
1769
|
-
const DataListRoot = DataList.Root;
|
|
1770
|
-
const DataListItem = React.forwardRef(function DataListItem(props, ref) {
|
|
1771
|
-
const { label, info, value, children, grow, ...rest } = props;
|
|
1772
|
-
return (jsxs(DataList.Item, { ref: ref, ...rest, children: [jsxs(DataList.ItemLabel, { flex: grow ? "1" : undefined, children: [label, info && jsx(InfoTip, { children: info })] }), jsx(DataList.ItemValue, { flex: grow ? "1" : undefined, children: value }), children] }));
|
|
1773
|
-
});
|
|
1774
|
-
|
|
1775
1786
|
const IdViewer = ({ value, in_table, column_ref, display_column, column, }) => {
|
|
1776
1787
|
const { schema, serverUrl } = useSchemaContext();
|
|
1777
1788
|
if (schema.properties == undefined) {
|
|
@@ -2201,6 +2212,7 @@ const EnumPicker = ({ column, isMultiple = false }) => {
|
|
|
2201
2212
|
const [limit, setLimit] = useState(10);
|
|
2202
2213
|
const [openSearchResult, setOpenSearchResult] = useState();
|
|
2203
2214
|
const ref = useRef(null);
|
|
2215
|
+
const watchEnum = watch(column);
|
|
2204
2216
|
const watchEnums = (watch(column) ?? []);
|
|
2205
2217
|
const properties = (schema.properties[column] ?? {});
|
|
2206
2218
|
const dataList = properties.enum ?? [];
|
|
@@ -2224,17 +2236,19 @@ const EnumPicker = ({ column, isMultiple = false }) => {
|
|
|
2224
2236
|
setOpenSearchResult(true);
|
|
2225
2237
|
}, children: "Add" })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
2226
2238
|
setOpenSearchResult(true);
|
|
2227
|
-
}, children:
|
|
2239
|
+
}, children: 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, { children: [jsx(Input, { placeholder: "Type to search", onChange: (event) => {
|
|
2228
2240
|
onSearchChange(event);
|
|
2229
2241
|
setOpenSearchResult(true);
|
|
2230
2242
|
}, autoComplete: "off", ref: ref }), jsx(PopoverTitle, {}), jsxs(Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsx(Text, { children: `Search Result: ${count}, Showing ${limit}` }), jsx(Button, { onClick: async () => {
|
|
2231
2243
|
setOpenSearchResult(false);
|
|
2232
2244
|
}, children: "close" }), jsx(Flex, { flexFlow: "column wrap", children: dataList.map((item) => {
|
|
2233
|
-
const selected =
|
|
2245
|
+
const selected = isMultiple
|
|
2246
|
+
? watchEnums.some((enumValue) => item === enumValue)
|
|
2247
|
+
: watchEnum == item;
|
|
2234
2248
|
return (jsx(Box, { cursor: "pointer", onClick: () => {
|
|
2235
2249
|
if (!isMultiple) {
|
|
2236
2250
|
setOpenSearchResult(false);
|
|
2237
|
-
setValue(column,
|
|
2251
|
+
setValue(column, item);
|
|
2238
2252
|
return;
|
|
2239
2253
|
}
|
|
2240
2254
|
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DataListRootProps } from "@chakra-ui/react";
|
|
2
|
+
export interface RecordDisplayProps {
|
|
3
|
+
object: Record<string, string>;
|
|
4
|
+
dataListProps?: DataListRootProps;
|
|
5
|
+
}
|
|
6
|
+
export declare const RecordDisplay: ({ object, dataListProps, }: RecordDisplayProps) => import("react/jsx-runtime").JSX.Element;
|