@bsol-oss/react-datatable5 7.4.1 → 7.5.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.d.ts
CHANGED
|
@@ -489,6 +489,12 @@ interface RangeDatePickerProps extends Props, RangeCalendarProps {
|
|
|
489
489
|
|
|
490
490
|
declare module "@tanstack/react-table" {
|
|
491
491
|
interface ColumnMeta<TData extends RowData, TValue> {
|
|
492
|
+
/**
|
|
493
|
+
* If `showCustomDisplay` is `true`, it will use the cell render to render the value.
|
|
494
|
+
*
|
|
495
|
+
* Effective in components: `DataDisplay`
|
|
496
|
+
*/
|
|
497
|
+
showCustomDisplay?: boolean;
|
|
492
498
|
/**
|
|
493
499
|
* The display name of the column, used for rendering headers.
|
|
494
500
|
*/
|
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');
|
|
16
15
|
var reactTable = require('@tanstack/react-table');
|
|
17
16
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
18
17
|
var bs = require('react-icons/bs');
|
|
19
18
|
var gr = require('react-icons/gr');
|
|
20
19
|
var reactQuery = require('@tanstack/react-query');
|
|
21
20
|
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,27 +612,12 @@ const snakeToLabel = (str) => {
|
|
|
612
612
|
.join(" "); // Join with space
|
|
613
613
|
};
|
|
614
614
|
|
|
615
|
-
const
|
|
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, }) => {
|
|
615
|
+
const RecordDisplay = ({ object, boxProps }) => {
|
|
631
616
|
if (object === null) {
|
|
632
617
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "null" });
|
|
633
618
|
}
|
|
634
|
-
return (jsxRuntime.jsx(
|
|
635
|
-
return (jsxRuntime.jsx(
|
|
619
|
+
return (jsxRuntime.jsx(react.Box, { rowGap: 1, columnGap: 2, display: "grid", gridTemplateColumns: "auto 1fr", overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
620
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(react.Text, { color: "gray.400", children: snakeToLabel(field) }), jsxRuntime.jsx(react.Text, { children: typeof value === "object" ? JSON.stringify(value) : value })] }));
|
|
636
621
|
}) }));
|
|
637
622
|
};
|
|
638
623
|
|
|
@@ -656,9 +641,19 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
656
641
|
if (variant == "horizontal") {
|
|
657
642
|
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
658
643
|
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) => {
|
|
644
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
645
|
+
if (showCustomDataDisplay) {
|
|
646
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
647
|
+
}
|
|
659
648
|
const value = cell.getValue();
|
|
660
649
|
if (typeof value === "object") {
|
|
661
|
-
return jsxRuntime.jsx(
|
|
650
|
+
return (jsxRuntime.jsxs(react.DataList.Item, { children: [jsxRuntime.jsx(react.DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsxRuntime.jsx(RecordDisplay, { boxProps: {
|
|
651
|
+
borderWidth: 1,
|
|
652
|
+
borderRadius: 4,
|
|
653
|
+
borderColor: "gray.400",
|
|
654
|
+
paddingX: 4,
|
|
655
|
+
paddingY: 2,
|
|
656
|
+
}, object: value })] }, cell.id));
|
|
662
657
|
}
|
|
663
658
|
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));
|
|
664
659
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
@@ -667,9 +662,19 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
667
662
|
if (variant == "stats") {
|
|
668
663
|
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
669
664
|
return (jsxRuntime.jsx(react.Card.Root, { children: jsxRuntime.jsx(react.Card.Body, { children: jsxRuntime.jsx(react.DataList.Root, { gap: 4, padding: 4, display: "flex", flexFlow: "row", variant: "subtle", overflow: "auto", children: row.getVisibleCells().map((cell) => {
|
|
665
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
666
|
+
if (showCustomDataDisplay) {
|
|
667
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
668
|
+
}
|
|
670
669
|
const value = cell.getValue();
|
|
671
670
|
if (typeof value === "object") {
|
|
672
|
-
return jsxRuntime.jsx(
|
|
671
|
+
return (jsxRuntime.jsxs(react.DataList.Item, { display: "inline-flex", flexFlow: "column", justifyContent: "center", alignItems: "center", flex: "1 0 0%", children: [jsxRuntime.jsx(react.DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsxRuntime.jsx(RecordDisplay, { boxProps: {
|
|
672
|
+
borderWidth: 1,
|
|
673
|
+
borderRadius: 4,
|
|
674
|
+
borderColor: "gray.400",
|
|
675
|
+
paddingX: 4,
|
|
676
|
+
paddingY: 2,
|
|
677
|
+
}, object: value })] }));
|
|
673
678
|
}
|
|
674
679
|
return (jsxRuntime.jsxs(react.DataList.Item, { display: "flex", justifyContent: "center", alignItems: "center", flex: "1 0 0%", 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));
|
|
675
680
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
@@ -677,9 +682,19 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
677
682
|
}
|
|
678
683
|
return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
679
684
|
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", gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", children: row.getVisibleCells().map((cell) => {
|
|
685
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
686
|
+
if (showCustomDataDisplay) {
|
|
687
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
688
|
+
}
|
|
680
689
|
const value = cell.getValue();
|
|
681
690
|
if (typeof value === "object") {
|
|
682
|
-
return jsxRuntime.jsx(
|
|
691
|
+
return (jsxRuntime.jsxs(react.DataList.Item, { children: [jsxRuntime.jsx(react.DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsxRuntime.jsx(RecordDisplay, { boxProps: {
|
|
692
|
+
borderWidth: 1,
|
|
693
|
+
borderRadius: 4,
|
|
694
|
+
borderColor: "gray.400",
|
|
695
|
+
paddingX: 4,
|
|
696
|
+
paddingY: 2,
|
|
697
|
+
}, object: value })] }, cell.id));
|
|
683
698
|
}
|
|
684
699
|
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));
|
|
685
700
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
@@ -1814,6 +1829,21 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1814
1829
|
}, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
1815
1830
|
};
|
|
1816
1831
|
|
|
1832
|
+
const ToggleTip = React__namespace.forwardRef(function ToggleTip(props, ref) {
|
|
1833
|
+
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
1834
|
+
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] }) }) })] }));
|
|
1835
|
+
});
|
|
1836
|
+
const InfoTip = React__namespace.forwardRef(function InfoTip(props, ref) {
|
|
1837
|
+
const { children, ...rest } = props;
|
|
1838
|
+
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, {}) }) }));
|
|
1839
|
+
});
|
|
1840
|
+
|
|
1841
|
+
const DataListRoot = react.DataList.Root;
|
|
1842
|
+
const DataListItem = React__namespace.forwardRef(function DataListItem(props, ref) {
|
|
1843
|
+
const { label, info, value, children, grow, ...rest } = props;
|
|
1844
|
+
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] }));
|
|
1845
|
+
});
|
|
1846
|
+
|
|
1817
1847
|
const IdViewer = ({ value, in_table, column_ref, display_column, column, }) => {
|
|
1818
1848
|
const { schema, serverUrl } = useSchemaContext();
|
|
1819
1849
|
if (schema.properties == undefined) {
|
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, Card, DataList, 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, Popover, 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 {
|
|
15
|
-
import { makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, flexRender, createColumnHelper } from '@tanstack/react-table';
|
|
14
|
+
import { flexRender, makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, createColumnHelper } from '@tanstack/react-table';
|
|
16
15
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
17
16
|
import { BsExclamationCircleFill } from 'react-icons/bs';
|
|
18
17
|
import { GrAscend, GrDescend } from 'react-icons/gr';
|
|
19
18
|
import { useQueryClient, useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
20
19
|
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,27 +592,12 @@ const snakeToLabel = (str) => {
|
|
|
592
592
|
.join(" "); // Join with space
|
|
593
593
|
};
|
|
594
594
|
|
|
595
|
-
const
|
|
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, }) => {
|
|
595
|
+
const RecordDisplay = ({ object, boxProps }) => {
|
|
611
596
|
if (object === null) {
|
|
612
597
|
return jsx(Fragment, { children: "null" });
|
|
613
598
|
}
|
|
614
|
-
return (jsx(
|
|
615
|
-
return (jsx(
|
|
599
|
+
return (jsx(Box, { rowGap: 1, columnGap: 2, display: "grid", gridTemplateColumns: "auto 1fr", overflow: "auto", ...boxProps, children: Object.entries(object).map(([field, value]) => {
|
|
600
|
+
return (jsxs(Fragment, { children: [jsx(Text, { color: "gray.400", children: snakeToLabel(field) }), jsx(Text, { children: typeof value === "object" ? JSON.stringify(value) : value })] }));
|
|
616
601
|
}) }));
|
|
617
602
|
};
|
|
618
603
|
|
|
@@ -636,9 +621,19 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
636
621
|
if (variant == "horizontal") {
|
|
637
622
|
return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
638
623
|
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) => {
|
|
624
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
625
|
+
if (showCustomDataDisplay) {
|
|
626
|
+
return (jsx(Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
627
|
+
}
|
|
639
628
|
const value = cell.getValue();
|
|
640
629
|
if (typeof value === "object") {
|
|
641
|
-
return jsx(
|
|
630
|
+
return (jsxs(DataList.Item, { children: [jsx(DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsx(RecordDisplay, { boxProps: {
|
|
631
|
+
borderWidth: 1,
|
|
632
|
+
borderRadius: 4,
|
|
633
|
+
borderColor: "gray.400",
|
|
634
|
+
paddingX: 4,
|
|
635
|
+
paddingY: 2,
|
|
636
|
+
}, object: value })] }, cell.id));
|
|
642
637
|
}
|
|
643
638
|
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));
|
|
644
639
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
@@ -647,9 +642,19 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
647
642
|
if (variant == "stats") {
|
|
648
643
|
return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
649
644
|
return (jsx(Card.Root, { children: jsx(Card.Body, { children: jsx(DataList.Root, { gap: 4, padding: 4, display: "flex", flexFlow: "row", variant: "subtle", overflow: "auto", children: row.getVisibleCells().map((cell) => {
|
|
645
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
646
|
+
if (showCustomDataDisplay) {
|
|
647
|
+
return (jsx(Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
648
|
+
}
|
|
650
649
|
const value = cell.getValue();
|
|
651
650
|
if (typeof value === "object") {
|
|
652
|
-
return jsx(
|
|
651
|
+
return (jsxs(DataList.Item, { display: "inline-flex", flexFlow: "column", justifyContent: "center", alignItems: "center", flex: "1 0 0%", children: [jsx(DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsx(RecordDisplay, { boxProps: {
|
|
652
|
+
borderWidth: 1,
|
|
653
|
+
borderRadius: 4,
|
|
654
|
+
borderColor: "gray.400",
|
|
655
|
+
paddingX: 4,
|
|
656
|
+
paddingY: 2,
|
|
657
|
+
}, object: value })] }));
|
|
653
658
|
}
|
|
654
659
|
return (jsxs(DataList.Item, { display: "flex", justifyContent: "center", alignItems: "center", flex: "1 0 0%", 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));
|
|
655
660
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
@@ -657,9 +662,19 @@ const DataDisplay = ({ variant = "" }) => {
|
|
|
657
662
|
}
|
|
658
663
|
return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
|
|
659
664
|
return (jsx(Card.Root, { children: jsx(Card.Body, { children: jsx(DataList.Root, { gap: 4, padding: 4, display: "grid", variant: "subtle", gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", children: row.getVisibleCells().map((cell) => {
|
|
665
|
+
const showCustomDataDisplay = cell.column.columnDef.meta?.showCustomDisplay ?? false;
|
|
666
|
+
if (showCustomDataDisplay) {
|
|
667
|
+
return (jsx(Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
668
|
+
}
|
|
660
669
|
const value = cell.getValue();
|
|
661
670
|
if (typeof value === "object") {
|
|
662
|
-
return jsx(
|
|
671
|
+
return (jsxs(DataList.Item, { children: [jsx(DataList.ItemLabel, { children: snakeToLabel(cell.column.id) }), jsx(RecordDisplay, { boxProps: {
|
|
672
|
+
borderWidth: 1,
|
|
673
|
+
borderRadius: 4,
|
|
674
|
+
borderColor: "gray.400",
|
|
675
|
+
paddingX: 4,
|
|
676
|
+
paddingY: 2,
|
|
677
|
+
}, object: value })] }, cell.id));
|
|
663
678
|
}
|
|
664
679
|
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));
|
|
665
680
|
}) }) }) }, `chakra-table-card-${row.id}`));
|
|
@@ -1794,6 +1809,21 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1794
1809
|
}, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
1795
1810
|
};
|
|
1796
1811
|
|
|
1812
|
+
const ToggleTip = React.forwardRef(function ToggleTip(props, ref) {
|
|
1813
|
+
const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
|
|
1814
|
+
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] }) }) })] }));
|
|
1815
|
+
});
|
|
1816
|
+
const InfoTip = React.forwardRef(function InfoTip(props, ref) {
|
|
1817
|
+
const { children, ...rest } = props;
|
|
1818
|
+
return (jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsx(IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "gray", children: jsx(HiOutlineInformationCircle, {}) }) }));
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1821
|
+
const DataListRoot = DataList.Root;
|
|
1822
|
+
const DataListItem = React.forwardRef(function DataListItem(props, ref) {
|
|
1823
|
+
const { label, info, value, children, grow, ...rest } = props;
|
|
1824
|
+
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] }));
|
|
1825
|
+
});
|
|
1826
|
+
|
|
1797
1827
|
const IdViewer = ({ value, in_table, column_ref, display_column, column, }) => {
|
|
1798
1828
|
const { schema, serverUrl } = useSchemaContext();
|
|
1799
1829
|
if (schema.properties == undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BoxProps } from "@chakra-ui/react";
|
|
2
2
|
export interface RecordDisplayProps {
|
|
3
3
|
object: object | null;
|
|
4
|
-
|
|
4
|
+
boxProps?: BoxProps;
|
|
5
5
|
}
|
|
6
|
-
export declare const RecordDisplay: ({ object,
|
|
6
|
+
export declare const RecordDisplay: ({ object, boxProps }: RecordDisplayProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { Column, RowData } from "@tanstack/react-table";
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
declare module "@tanstack/react-table" {
|
|
4
4
|
interface ColumnMeta<TData extends RowData, TValue> {
|
|
5
|
+
/**
|
|
6
|
+
* If `showCustomDisplay` is `true`, it will use the cell render to render the value.
|
|
7
|
+
*
|
|
8
|
+
* Effective in components: `DataDisplay`
|
|
9
|
+
*/
|
|
10
|
+
showCustomDisplay?: boolean;
|
|
5
11
|
/**
|
|
6
12
|
* The display name of the column, used for rendering headers.
|
|
7
13
|
*/
|