@bsol-oss/react-datatable5 7.3.6 → 7.4.1

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,30 @@ 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
+ if (object === null) {
632
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "null" });
633
+ }
634
+ return (jsxRuntime.jsx(DataListRoot, { gap: 4, padding: 4, display: "grid", variant: "subtle", orientation: "horizontal", overflow: "auto", ...dataListProps, children: Object.entries(object).map(([field, value]) => {
635
+ return (jsxRuntime.jsx(DataListItem, { label: snakeToLabel(field), value: JSON.stringify(value) }, field));
636
+ }) }));
637
+ };
638
+
615
639
  const formatValue = (value) => {
616
640
  if (typeof value === "object") {
617
641
  return JSON.stringify(value);
@@ -632,6 +656,10 @@ const DataDisplay = ({ variant = "" }) => {
632
656
  if (variant == "horizontal") {
633
657
  return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
634
658
  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) => {
659
+ const value = cell.getValue();
660
+ if (typeof value === "object") {
661
+ return jsxRuntime.jsx(RecordDisplay, { object: value });
662
+ }
635
663
  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
664
  }) }) }) }, `chakra-table-card-${row.id}`));
637
665
  }) }));
@@ -639,12 +667,20 @@ const DataDisplay = ({ variant = "" }) => {
639
667
  if (variant == "stats") {
640
668
  return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
641
669
  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) => {
670
+ const value = cell.getValue();
671
+ if (typeof value === "object") {
672
+ return jsxRuntime.jsx(RecordDisplay, { object: value });
673
+ }
642
674
  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));
643
675
  }) }) }) }, `chakra-table-card-${row.id}`));
644
676
  }) }));
645
677
  }
646
678
  return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
647
679
  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) => {
680
+ const value = cell.getValue();
681
+ if (typeof value === "object") {
682
+ return jsxRuntime.jsx(RecordDisplay, { object: value });
683
+ }
648
684
  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));
649
685
  }) }) }) }, `chakra-table-card-${row.id}`));
650
686
  }) }));
@@ -1778,21 +1814,6 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
1778
1814
  }, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
1779
1815
  };
1780
1816
 
1781
- const ToggleTip = React__namespace.forwardRef(function ToggleTip(props, ref) {
1782
- const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
1783
- 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] }) }) })] }));
1784
- });
1785
- const InfoTip = React__namespace.forwardRef(function InfoTip(props, ref) {
1786
- const { children, ...rest } = props;
1787
- 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, {}) }) }));
1788
- });
1789
-
1790
- const DataListRoot = react.DataList.Root;
1791
- const DataListItem = React__namespace.forwardRef(function DataListItem(props, ref) {
1792
- const { label, info, value, children, grow, ...rest } = props;
1793
- 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] }));
1794
- });
1795
-
1796
1817
  const IdViewer = ({ value, in_table, column_ref, display_column, column, }) => {
1797
1818
  const { schema, serverUrl } = useSchemaContext();
1798
1819
  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, 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';
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,30 @@ 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
+ if (object === null) {
612
+ return jsx(Fragment, { children: "null" });
613
+ }
614
+ return (jsx(DataListRoot, { gap: 4, padding: 4, display: "grid", variant: "subtle", orientation: "horizontal", overflow: "auto", ...dataListProps, children: Object.entries(object).map(([field, value]) => {
615
+ return (jsx(DataListItem, { label: snakeToLabel(field), value: JSON.stringify(value) }, field));
616
+ }) }));
617
+ };
618
+
595
619
  const formatValue = (value) => {
596
620
  if (typeof value === "object") {
597
621
  return JSON.stringify(value);
@@ -612,6 +636,10 @@ const DataDisplay = ({ variant = "" }) => {
612
636
  if (variant == "horizontal") {
613
637
  return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
614
638
  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) => {
639
+ const value = cell.getValue();
640
+ if (typeof value === "object") {
641
+ return jsx(RecordDisplay, { object: value });
642
+ }
615
643
  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
644
  }) }) }) }, `chakra-table-card-${row.id}`));
617
645
  }) }));
@@ -619,12 +647,20 @@ const DataDisplay = ({ variant = "" }) => {
619
647
  if (variant == "stats") {
620
648
  return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
621
649
  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) => {
650
+ const value = cell.getValue();
651
+ if (typeof value === "object") {
652
+ return jsx(RecordDisplay, { object: value });
653
+ }
622
654
  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));
623
655
  }) }) }) }, `chakra-table-card-${row.id}`));
624
656
  }) }));
625
657
  }
626
658
  return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
627
659
  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) => {
660
+ const value = cell.getValue();
661
+ if (typeof value === "object") {
662
+ return jsx(RecordDisplay, { object: value });
663
+ }
628
664
  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));
629
665
  }) }) }) }, `chakra-table-card-${row.id}`));
630
666
  }) }));
@@ -1758,21 +1794,6 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
1758
1794
  }, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
1759
1795
  };
1760
1796
 
1761
- const ToggleTip = React.forwardRef(function ToggleTip(props, ref) {
1762
- const { showArrow, children, portalled = true, content, portalRef, ...rest } = props;
1763
- 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] }) }) })] }));
1764
- });
1765
- const InfoTip = React.forwardRef(function InfoTip(props, ref) {
1766
- const { children, ...rest } = props;
1767
- return (jsx(ToggleTip, { content: children, ...rest, ref: ref, children: jsx(IconButton, { variant: "ghost", "aria-label": "info", size: "2xs", colorPalette: "gray", children: jsx(HiOutlineInformationCircle, {}) }) }));
1768
- });
1769
-
1770
- const DataListRoot = DataList.Root;
1771
- const DataListItem = React.forwardRef(function DataListItem(props, ref) {
1772
- const { label, info, value, children, grow, ...rest } = props;
1773
- 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] }));
1774
- });
1775
-
1776
1797
  const IdViewer = ({ value, in_table, column_ref, display_column, column, }) => {
1777
1798
  const { schema, serverUrl } = useSchemaContext();
1778
1799
  if (schema.properties == undefined) {
@@ -0,0 +1,6 @@
1
+ import { DataListRootProps } from "@chakra-ui/react";
2
+ export interface RecordDisplayProps {
3
+ object: object | null;
4
+ dataListProps?: DataListRootProps;
5
+ }
6
+ export declare const RecordDisplay: ({ object, dataListProps, }: RecordDisplayProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "7.3.6",
3
+ "version": "7.4.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",