@bsol-oss/react-datatable5 11.0.0-beta.1 → 11.0.0-beta.2

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
@@ -2380,7 +2380,7 @@ function ColumnCard({ columnId }) {
2380
2380
  onDrop: () => setDragging(false), // NEW
2381
2381
  });
2382
2382
  }, [columnId, table]);
2383
- return (jsxRuntime.jsxs(react.Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsxRuntime.jsx(react.Flex, { alignItems: "center", padding: "0", children: jsxRuntime.jsx(fa6.FaGripLinesVertical, { color: "gray.400" }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "space-between", alignItems: "center", children: jsxRuntime.jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
2383
+ return (jsxRuntime.jsxs(react.Grid, { ref: ref, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", style: dragging ? { opacity: 0.4 } : {}, children: [jsxRuntime.jsx(react.Flex, { alignItems: "center", padding: "0", cursor: 'grab', children: jsxRuntime.jsx(fa6.FaGripLinesVertical, { color: "gray.400" }) }), jsxRuntime.jsx(react.Flex, { justifyContent: "space-between", alignItems: "center", children: jsxRuntime.jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
2384
2384
  }
2385
2385
  function CardContainer({ location, children }) {
2386
2386
  const ref = React.useRef(null);
@@ -2418,9 +2418,11 @@ function CardContainer({ location, children }) {
2418
2418
  }
2419
2419
  const TableViewer = () => {
2420
2420
  const { table } = useDataTableContext();
2421
- const [order, setOrder] = React.useState(table.getAllLeafColumns().map((column) => {
2422
- return column.id;
2423
- }));
2421
+ const order = table.getState().columnOrder.length > 0
2422
+ ? table.getState().columnOrder
2423
+ : table.getAllLeafColumns().map(({ id }) => {
2424
+ return id;
2425
+ });
2424
2426
  React.useEffect(() => {
2425
2427
  return monitorForElements({
2426
2428
  onDrop({ source, location }) {
@@ -2445,11 +2447,10 @@ const TableViewer = () => {
2445
2447
  ...columnAfter,
2446
2448
  ].filter((id) => id != "<marker>");
2447
2449
  table.setColumnOrder(newOrder);
2448
- setOrder(newOrder);
2449
2450
  },
2450
2451
  });
2451
- }, [order, table]);
2452
- return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.25rem", children: table.getState().columnOrder.map((columnId, index) => {
2452
+ }, [table]);
2453
+ return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.25rem", children: order.map((columnId, index) => {
2453
2454
  return (jsxRuntime.jsx(CardContainer, { location: index, children: jsxRuntime.jsx(ColumnCard, { columnId: columnId }) }));
2454
2455
  }) }));
2455
2456
  };
@@ -2624,21 +2625,6 @@ const RecordDisplay = ({ object, boxProps, translate, prefix = "", }) => {
2624
2625
  }) }));
2625
2626
  };
2626
2627
 
2627
- const formatValue = (value) => {
2628
- if (typeof value === "object") {
2629
- return JSON.stringify(value);
2630
- }
2631
- if (typeof value === "string") {
2632
- return value;
2633
- }
2634
- if (typeof value === "number" || typeof value === "boolean") {
2635
- return `${value}`;
2636
- }
2637
- if (value === undefined) {
2638
- return `undefined`;
2639
- }
2640
- throw new Error(`value is unknown, ${typeof value}`);
2641
- };
2642
2628
  const DataDisplay = ({ variant = "", translate }) => {
2643
2629
  const { table } = useDataTableContext();
2644
2630
  const getLabel = ({ columnId }) => {
@@ -2647,6 +2633,24 @@ const DataDisplay = ({ variant = "", translate }) => {
2647
2633
  }
2648
2634
  return snakeToLabel(columnId);
2649
2635
  };
2636
+ const formatValue = (value) => {
2637
+ if (typeof value === "object") {
2638
+ return JSON.stringify(value);
2639
+ }
2640
+ if (typeof value === "string") {
2641
+ return value;
2642
+ }
2643
+ if (typeof value === "number" || typeof value === "boolean") {
2644
+ return `${value}`;
2645
+ }
2646
+ if (value === undefined) {
2647
+ if (translate !== undefined) {
2648
+ return translate.t(`undefined`);
2649
+ }
2650
+ return `undefined`;
2651
+ }
2652
+ throw new Error(`value is unknown, ${typeof value}`);
2653
+ };
2650
2654
  if (variant == "horizontal") {
2651
2655
  return (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
2652
2656
  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) => {
package/dist/index.mjs CHANGED
@@ -2360,7 +2360,7 @@ function ColumnCard({ columnId }) {
2360
2360
  onDrop: () => setDragging(false), // NEW
2361
2361
  });
2362
2362
  }, [columnId, table]);
2363
- 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", children: jsx(FaGripLinesVertical, { color: "gray.400" }) }), jsx(Flex, { justifyContent: "space-between", alignItems: "center", children: jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
2363
+ 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: "gray.400" }) }), jsx(Flex, { justifyContent: "space-between", alignItems: "center", children: jsx(CheckboxCard, { variant: "surface", label: displayName, checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }) })] }));
2364
2364
  }
2365
2365
  function CardContainer({ location, children }) {
2366
2366
  const ref = useRef(null);
@@ -2398,9 +2398,11 @@ function CardContainer({ location, children }) {
2398
2398
  }
2399
2399
  const TableViewer = () => {
2400
2400
  const { table } = useDataTableContext();
2401
- const [order, setOrder] = useState(table.getAllLeafColumns().map((column) => {
2402
- return column.id;
2403
- }));
2401
+ const order = table.getState().columnOrder.length > 0
2402
+ ? table.getState().columnOrder
2403
+ : table.getAllLeafColumns().map(({ id }) => {
2404
+ return id;
2405
+ });
2404
2406
  useEffect(() => {
2405
2407
  return monitorForElements({
2406
2408
  onDrop({ source, location }) {
@@ -2425,11 +2427,10 @@ const TableViewer = () => {
2425
2427
  ...columnAfter,
2426
2428
  ].filter((id) => id != "<marker>");
2427
2429
  table.setColumnOrder(newOrder);
2428
- setOrder(newOrder);
2429
2430
  },
2430
2431
  });
2431
- }, [order, table]);
2432
- return (jsx(Flex, { flexFlow: "column", gap: "0.25rem", children: table.getState().columnOrder.map((columnId, index) => {
2432
+ }, [table]);
2433
+ return (jsx(Flex, { flexFlow: "column", gap: "0.25rem", children: order.map((columnId, index) => {
2433
2434
  return (jsx(CardContainer, { location: index, children: jsx(ColumnCard, { columnId: columnId }) }));
2434
2435
  }) }));
2435
2436
  };
@@ -2604,21 +2605,6 @@ const RecordDisplay = ({ object, boxProps, translate, prefix = "", }) => {
2604
2605
  }) }));
2605
2606
  };
2606
2607
 
2607
- const formatValue = (value) => {
2608
- if (typeof value === "object") {
2609
- return JSON.stringify(value);
2610
- }
2611
- if (typeof value === "string") {
2612
- return value;
2613
- }
2614
- if (typeof value === "number" || typeof value === "boolean") {
2615
- return `${value}`;
2616
- }
2617
- if (value === undefined) {
2618
- return `undefined`;
2619
- }
2620
- throw new Error(`value is unknown, ${typeof value}`);
2621
- };
2622
2608
  const DataDisplay = ({ variant = "", translate }) => {
2623
2609
  const { table } = useDataTableContext();
2624
2610
  const getLabel = ({ columnId }) => {
@@ -2627,6 +2613,24 @@ const DataDisplay = ({ variant = "", translate }) => {
2627
2613
  }
2628
2614
  return snakeToLabel(columnId);
2629
2615
  };
2616
+ const formatValue = (value) => {
2617
+ if (typeof value === "object") {
2618
+ return JSON.stringify(value);
2619
+ }
2620
+ if (typeof value === "string") {
2621
+ return value;
2622
+ }
2623
+ if (typeof value === "number" || typeof value === "boolean") {
2624
+ return `${value}`;
2625
+ }
2626
+ if (value === undefined) {
2627
+ if (translate !== undefined) {
2628
+ return translate.t(`undefined`);
2629
+ }
2630
+ return `undefined`;
2631
+ }
2632
+ throw new Error(`value is unknown, ${typeof value}`);
2633
+ };
2630
2634
  if (variant == "horizontal") {
2631
2635
  return (jsx(Flex, { flexFlow: "column", gap: "1", children: table.getRowModel().rows.map((row) => {
2632
2636
  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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "11.0.0-beta.1",
3
+ "version": "11.0.0-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",