@obolnetwork/obol-ui 1.0.24 → 1.0.27

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { CSS } from "../../../stitches.config";
2
3
  export declare type RowDef<T> = {
3
4
  id: string;
4
5
  isRemovable?: boolean;
@@ -16,6 +17,7 @@ export declare type CellDef = {
16
17
  export declare type ColumnDef<T> = {
17
18
  accessorKey: keyof T;
18
19
  header: string | React.ReactNode;
20
+ css?: CSS;
19
21
  cell?: CellDef;
20
22
  };
21
23
  export interface TableProps {
package/dist/index.es.js CHANGED
@@ -2,7 +2,7 @@ import { createStitches } from '@stitches/react';
2
2
  import * as TabsPrimitive from '@radix-ui/react-tabs';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
4
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
5
- import React, { forwardRef, useState, useRef, useEffect, useLayoutEffect } from 'react';
5
+ import React, { forwardRef, useState, useRef, useImperativeHandle, useEffect, useLayoutEffect } from 'react';
6
6
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
7
7
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
8
8
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
@@ -1386,22 +1386,28 @@ var Content$2 = styled(TooltipContent, {
1386
1386
  fill: "$bg05",
1387
1387
  },
1388
1388
  });
1389
- var TextFieldWithCopy = forwardRef(function (props) {
1390
- var _a = useState(), inputValue = _a[0], setInputValue = _a[1];
1391
- var _b = useState(false), isCopied = _b[0], setIsCopied = _b[1];
1392
- var ref = useRef(null);
1389
+ var TextFieldWithCopy = forwardRef(function (_a, ref) {
1390
+ var value = _a.value, onChange = _a.onChange, props = __rest(_a, ["value", "onChange"]);
1391
+ var _b = useState(value || ""), inputValue = _b[0], setInputValue = _b[1];
1392
+ var _c = useState(false), isCopied = _c[0], setIsCopied = _c[1];
1393
+ var innerRef = useRef(null);
1394
+ useImperativeHandle(ref, function () { return innerRef.current; });
1393
1395
  var copyToClipBoard = function (content) {
1394
1396
  if (content) {
1395
- navigator.clipboard.writeText(content);
1397
+ navigator.clipboard.writeText(content.toString());
1396
1398
  setIsCopied(true);
1397
1399
  }
1398
1400
  };
1399
1401
  useTimeout(function () {
1400
1402
  setIsCopied(false);
1401
1403
  }, isCopied ? 3000 : null);
1402
- return (jsxs(Box, __assign({ css: { display: "flex", width: "$full" } }, { children: [jsx(TextField, __assign({ withCopy: true, ref: ref, value: inputValue, onChange: function (e) { return setInputValue(e.target.value); } }, props, { css: { width: "$full" } })), jsxs(Tooltip, __assign({ open: isCopied }, { children: [jsx(TooltipTrigger, __assign({ asChild: true }, { children: jsx(IconButton, __assign({ onClick: function () {
1403
- return copyToClipBoard(ref && ref.current && ref.current.value);
1404
- } }, { children: !isCopied ? jsx(CopyIcon, {}) : jsx(CheckIcon, {}) })) })), jsxs(Content$2, __assign({ side: "bottom", sideOffset: 5 }, { children: ["Copied!", jsx(TooltipArrow, {})] }))] }))] })));
1404
+ var handleOnChange = function (e) {
1405
+ setInputValue(e.target.value);
1406
+ if (onChange) {
1407
+ onChange(e);
1408
+ }
1409
+ };
1410
+ return (jsxs(Box, __assign({ css: { display: "flex", width: "$full" } }, { children: [jsx(TextField, __assign({}, props, { withCopy: true, ref: innerRef, value: inputValue, onChange: handleOnChange, css: { width: "$full" } })), jsxs(Tooltip, __assign({ open: isCopied }, { children: [jsx(TooltipTrigger, __assign({ asChild: true }, { children: jsx(IconButton, __assign({ onClick: function () { return copyToClipBoard(inputValue); } }, { children: !isCopied ? jsx(CopyIcon, {}) : jsx(CheckIcon, {}) })) })), jsxs(Content$2, __assign({ side: "bottom", sideOffset: 5 }, { children: ["Copied!", jsx(TooltipArrow, {})] }))] }))] })));
1405
1411
  });
1406
1412
  TextFieldWithCopy.displayName = "TextFieldWithCopy";
1407
1413
 
@@ -2001,7 +2007,10 @@ var AddNewRow = function (_a) {
2001
2007
  };
2002
2008
  var SplitterTable = function (_a) {
2003
2009
  var rows = _a.rows, columns = _a.columns, onAddRow = _a.onAddRow, onRemoveRow = _a.onRemoveRow, onUpdateRow = _a.onUpdateRow, _b = _a.totalSplitFooter, totalSplitFooter = _b === void 0 ? 100 : _b;
2004
- return (jsxs(StyledTable, { children: [jsx("thead", { children: jsxs("tr", { children: [jsx(Th, {}), columns.map(function (column, index) { return (jsx(Th, __assign({ css: { textAlign: "start" } }, { children: column.header }), "header-".concat(index))); }), jsx(Th, {})] }) }), jsxs("tbody", { children: [rows.map(function (_a, rowIndex) {
2010
+ return (jsxs(StyledTable, { children: [jsx("thead", { children: jsxs("tr", { children: [jsx(Th, {}), columns.map(function (_a, index) {
2011
+ var css = _a.css, column = __rest(_a, ["css"]);
2012
+ return (jsx(Th, __assign({ css: __assign({ textAlign: "start" }, css) }, { children: column.header }), "header-".concat(index)));
2013
+ }), jsx(Th, {})] }) }), jsxs("tbody", { children: [rows.map(function (_a, rowIndex) {
2005
2014
  var _b = _a.isRemovable, isRemovable = _b === void 0 ? true : _b, _c = _a.isEditable, isEditable = _c === void 0 ? true : _c, row = __rest(_a, ["isRemovable", "isEditable"]);
2006
2015
  return (jsxs("tr", { children: [jsx(Td, __assign({ textCenter: true, size: "sm" }, { children: rowIndex + 1 })), columns.map(function (column, cellIndex) {
2007
2016
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2053,7 +2062,10 @@ var SplitterTable = function (_a) {
2053
2062
  };
2054
2063
  var Table = function (_a) {
2055
2064
  var rows = _a.rows, columns = _a.columns;
2056
- return (jsxs(StyledTable, { children: [jsx("thead", { children: jsx("tr", { children: columns.map(function (column, index) { return (jsx(Th, __assign({ css: { textAlign: "start" } }, { children: column.header }), "header-".concat(index))); }) }) }), jsx("tbody", { children: rows.map(function (row, rowIndex) { return (jsx("tr", { children: columns.map(function (column, cellIndex) {
2065
+ return (jsxs(StyledTable, { children: [jsx("thead", { children: jsx("tr", { children: columns.map(function (_a, index) {
2066
+ var css = _a.css, column = __rest(_a, ["css"]);
2067
+ return (jsx(Th, __assign({ css: __assign({ textAlign: "start" }, css) }, { children: column.header }), "header-".concat(index)));
2068
+ }) }) }), jsx("tbody", { children: rows.map(function (row, rowIndex) { return (jsx("tr", { children: columns.map(function (column, cellIndex) {
2057
2069
  return (jsx(Td, __assign({ css: { color: "$light" } }, { children: row[column.accessorKey] }), "cell ".concat(cellIndex)));
2058
2070
  }) }, "row ".concat(rowIndex))); }) })] }));
2059
2071
  };
@@ -2066,11 +2078,11 @@ var Advisory = function (_a) {
2066
2078
  var handleOnAccept = function (value) {
2067
2079
  onUpdateState(value);
2068
2080
  };
2069
- return (jsxs(Box, __assign({ css: {
2081
+ return (jsxs(Box, __assign({ className: "advisory-container", css: {
2070
2082
  display: "flex",
2071
2083
  border: "2px solid $bg04",
2072
2084
  borderRadius: "$3",
2073
- height: "752px",
2085
+ minHeight: "752px",
2074
2086
  } }, { children: [jsx(Box, __assign({ css: {
2075
2087
  display: "flex",
2076
2088
  fd: "column",
package/dist/index.js CHANGED
@@ -1418,22 +1418,28 @@ var Content$2 = styled(TooltipContent, {
1418
1418
  fill: "$bg05",
1419
1419
  },
1420
1420
  });
1421
- var TextFieldWithCopy = React.forwardRef(function (props) {
1422
- var _a = React.useState(), inputValue = _a[0], setInputValue = _a[1];
1423
- var _b = React.useState(false), isCopied = _b[0], setIsCopied = _b[1];
1424
- var ref = React.useRef(null);
1421
+ var TextFieldWithCopy = React.forwardRef(function (_a, ref) {
1422
+ var value = _a.value, onChange = _a.onChange, props = __rest(_a, ["value", "onChange"]);
1423
+ var _b = React.useState(value || ""), inputValue = _b[0], setInputValue = _b[1];
1424
+ var _c = React.useState(false), isCopied = _c[0], setIsCopied = _c[1];
1425
+ var innerRef = React.useRef(null);
1426
+ React.useImperativeHandle(ref, function () { return innerRef.current; });
1425
1427
  var copyToClipBoard = function (content) {
1426
1428
  if (content) {
1427
- navigator.clipboard.writeText(content);
1429
+ navigator.clipboard.writeText(content.toString());
1428
1430
  setIsCopied(true);
1429
1431
  }
1430
1432
  };
1431
1433
  useTimeout(function () {
1432
1434
  setIsCopied(false);
1433
1435
  }, isCopied ? 3000 : null);
1434
- return (jsxRuntime.jsxs(Box, __assign({ css: { display: "flex", width: "$full" } }, { children: [jsxRuntime.jsx(TextField, __assign({ withCopy: true, ref: ref, value: inputValue, onChange: function (e) { return setInputValue(e.target.value); } }, props, { css: { width: "$full" } })), jsxRuntime.jsxs(Tooltip, __assign({ open: isCopied }, { children: [jsxRuntime.jsx(TooltipTrigger, __assign({ asChild: true }, { children: jsxRuntime.jsx(IconButton, __assign({ onClick: function () {
1435
- return copyToClipBoard(ref && ref.current && ref.current.value);
1436
- } }, { children: !isCopied ? jsxRuntime.jsx(CopyIcon, {}) : jsxRuntime.jsx(CheckIcon, {}) })) })), jsxRuntime.jsxs(Content$2, __assign({ side: "bottom", sideOffset: 5 }, { children: ["Copied!", jsxRuntime.jsx(TooltipArrow, {})] }))] }))] })));
1436
+ var handleOnChange = function (e) {
1437
+ setInputValue(e.target.value);
1438
+ if (onChange) {
1439
+ onChange(e);
1440
+ }
1441
+ };
1442
+ return (jsxRuntime.jsxs(Box, __assign({ css: { display: "flex", width: "$full" } }, { children: [jsxRuntime.jsx(TextField, __assign({}, props, { withCopy: true, ref: innerRef, value: inputValue, onChange: handleOnChange, css: { width: "$full" } })), jsxRuntime.jsxs(Tooltip, __assign({ open: isCopied }, { children: [jsxRuntime.jsx(TooltipTrigger, __assign({ asChild: true }, { children: jsxRuntime.jsx(IconButton, __assign({ onClick: function () { return copyToClipBoard(inputValue); } }, { children: !isCopied ? jsxRuntime.jsx(CopyIcon, {}) : jsxRuntime.jsx(CheckIcon, {}) })) })), jsxRuntime.jsxs(Content$2, __assign({ side: "bottom", sideOffset: 5 }, { children: ["Copied!", jsxRuntime.jsx(TooltipArrow, {})] }))] }))] })));
1437
1443
  });
1438
1444
  TextFieldWithCopy.displayName = "TextFieldWithCopy";
1439
1445
 
@@ -2033,7 +2039,10 @@ var AddNewRow = function (_a) {
2033
2039
  };
2034
2040
  var SplitterTable = function (_a) {
2035
2041
  var rows = _a.rows, columns = _a.columns, onAddRow = _a.onAddRow, onRemoveRow = _a.onRemoveRow, onUpdateRow = _a.onUpdateRow, _b = _a.totalSplitFooter, totalSplitFooter = _b === void 0 ? 100 : _b;
2036
- return (jsxRuntime.jsxs(StyledTable, { children: [jsxRuntime.jsx("thead", { children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx(Th, {}), columns.map(function (column, index) { return (jsxRuntime.jsx(Th, __assign({ css: { textAlign: "start" } }, { children: column.header }), "header-".concat(index))); }), jsxRuntime.jsx(Th, {})] }) }), jsxRuntime.jsxs("tbody", { children: [rows.map(function (_a, rowIndex) {
2042
+ return (jsxRuntime.jsxs(StyledTable, { children: [jsxRuntime.jsx("thead", { children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx(Th, {}), columns.map(function (_a, index) {
2043
+ var css = _a.css, column = __rest(_a, ["css"]);
2044
+ return (jsxRuntime.jsx(Th, __assign({ css: __assign({ textAlign: "start" }, css) }, { children: column.header }), "header-".concat(index)));
2045
+ }), jsxRuntime.jsx(Th, {})] }) }), jsxRuntime.jsxs("tbody", { children: [rows.map(function (_a, rowIndex) {
2037
2046
  var _b = _a.isRemovable, isRemovable = _b === void 0 ? true : _b, _c = _a.isEditable, isEditable = _c === void 0 ? true : _c, row = __rest(_a, ["isRemovable", "isEditable"]);
2038
2047
  return (jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx(Td, __assign({ textCenter: true, size: "sm" }, { children: rowIndex + 1 })), columns.map(function (column, cellIndex) {
2039
2048
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2085,7 +2094,10 @@ var SplitterTable = function (_a) {
2085
2094
  };
2086
2095
  var Table = function (_a) {
2087
2096
  var rows = _a.rows, columns = _a.columns;
2088
- return (jsxRuntime.jsxs(StyledTable, { children: [jsxRuntime.jsx("thead", { children: jsxRuntime.jsx("tr", { children: columns.map(function (column, index) { return (jsxRuntime.jsx(Th, __assign({ css: { textAlign: "start" } }, { children: column.header }), "header-".concat(index))); }) }) }), jsxRuntime.jsx("tbody", { children: rows.map(function (row, rowIndex) { return (jsxRuntime.jsx("tr", { children: columns.map(function (column, cellIndex) {
2097
+ return (jsxRuntime.jsxs(StyledTable, { children: [jsxRuntime.jsx("thead", { children: jsxRuntime.jsx("tr", { children: columns.map(function (_a, index) {
2098
+ var css = _a.css, column = __rest(_a, ["css"]);
2099
+ return (jsxRuntime.jsx(Th, __assign({ css: __assign({ textAlign: "start" }, css) }, { children: column.header }), "header-".concat(index)));
2100
+ }) }) }), jsxRuntime.jsx("tbody", { children: rows.map(function (row, rowIndex) { return (jsxRuntime.jsx("tr", { children: columns.map(function (column, cellIndex) {
2089
2101
  return (jsxRuntime.jsx(Td, __assign({ css: { color: "$light" } }, { children: row[column.accessorKey] }), "cell ".concat(cellIndex)));
2090
2102
  }) }, "row ".concat(rowIndex))); }) })] }));
2091
2103
  };
@@ -2098,11 +2110,11 @@ var Advisory = function (_a) {
2098
2110
  var handleOnAccept = function (value) {
2099
2111
  onUpdateState(value);
2100
2112
  };
2101
- return (jsxRuntime.jsxs(Box, __assign({ css: {
2113
+ return (jsxRuntime.jsxs(Box, __assign({ className: "advisory-container", css: {
2102
2114
  display: "flex",
2103
2115
  border: "2px solid $bg04",
2104
2116
  borderRadius: "$3",
2105
- height: "752px",
2117
+ minHeight: "752px",
2106
2118
  } }, { children: [jsxRuntime.jsx(Box, __assign({ css: {
2107
2119
  display: "flex",
2108
2120
  fd: "column",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-ui",
3
- "version": "1.0.24",
3
+ "version": "1.0.27",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "license": "MIT",