@obolnetwork/obol-ui 1.0.13 → 1.0.14

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,9 +1,11 @@
1
- /// <reference types="react" />
1
+ import { FocusEventHandler } from "react";
2
2
  interface NumberFieldProps {
3
- value?: number;
4
- onChangeValue?(value: number): void;
5
3
  max?: number;
6
4
  min?: number;
5
+ value?: number;
6
+ onChangeValue?(value: number): void;
7
+ onBlur?: FocusEventHandler<HTMLInputElement> | undefined;
8
+ name?: string;
7
9
  }
8
10
  export declare const NumberField: import("react").ForwardRefExoticComponent<NumberFieldProps & import("react").RefAttributes<HTMLInputElement>>;
9
11
  export {};
@@ -23,9 +23,9 @@ export interface TableProps {
23
23
  columns: ColumnDef<any>[];
24
24
  }
25
25
  export interface SplitterTableProps extends TableProps {
26
- onAddRow(item: string): void;
26
+ onAddRow(item?: unknown): void;
27
27
  onRemoveRow(item: string | number): void;
28
- onUpdateRow(id: string, value: string, accessorKey: unknown): void;
28
+ onUpdateRow(id: string, value: string | number, accessorKey: unknown): void;
29
29
  removeButton?: boolean;
30
30
  }
31
31
  export declare const SplitterTable: React.FC<SplitterTableProps>;
package/dist/index.es.js CHANGED
@@ -1363,11 +1363,11 @@ var TextFieldWithCopy = forwardRef(function (props, ref) {
1363
1363
  TextFieldWithCopy.displayName = "TextFieldWithCopy";
1364
1364
 
1365
1365
  var NumberField = forwardRef(function (_a, ref) {
1366
- var _b = _a.max, max = _b === void 0 ? 10 : _b, _c = _a.min, min = _c === void 0 ? 1 : _c, value = _a.value, onChangeValue = _a.onChangeValue;
1366
+ var _b = _a.max, max = _b === void 0 ? 10 : _b, _c = _a.min, min = _c === void 0 ? 0 : _c, value = _a.value, onChangeValue = _a.onChangeValue, onBlur = _a.onBlur, name = _a.name;
1367
1367
  var _d = useState(value || min), qty = _d[0], setQty = _d[1];
1368
1368
  var handleOnDec = function (e) {
1369
1369
  e.preventDefault();
1370
- if (qty <= min) {
1370
+ if (qty < min) {
1371
1371
  setQty(min);
1372
1372
  }
1373
1373
  else {
@@ -1384,7 +1384,7 @@ var NumberField = forwardRef(function (_a, ref) {
1384
1384
  }
1385
1385
  };
1386
1386
  var handleOnChange = function (e) {
1387
- var value = e.target;
1387
+ var value = e.target.value;
1388
1388
  if (value > max) {
1389
1389
  setQty(max);
1390
1390
  }
@@ -1402,6 +1402,7 @@ var NumberField = forwardRef(function (_a, ref) {
1402
1402
  }, [qty, onChangeValue]);
1403
1403
  return (jsxs(Box, __assign({ css: {
1404
1404
  display: "flex",
1405
+ maxHeight: "$3xl",
1405
1406
  "input::-webkit-inner-spin-button": {
1406
1407
  "-webkit-appearance": "none",
1407
1408
  margin: 0,
@@ -1433,7 +1434,7 @@ var NumberField = forwardRef(function (_a, ref) {
1433
1434
  borderRadius: 0,
1434
1435
  width: "95px",
1435
1436
  },
1436
- } }, { children: [jsx(IconButton, __assign({ disabled: qty <= min, className: "dec-button", onClick: handleOnDec, borderDisabled: qty <= min }, { children: "-" })), jsx(TextField, { css: { borderRightStyle: "none", borderLeftStyle: "none" }, type: "number", ref: ref, value: qty, onChange: handleOnChange }), jsx(IconButton, __assign({ disabled: qty >= max, className: "inc-button", onClick: handleOnInc, borderDisabled: qty >= max }, { children: "+" }))] })));
1437
+ } }, { children: [jsx(IconButton, __assign({ disabled: qty <= min, className: "dec-button", onClick: handleOnDec, borderDisabled: qty <= min }, { children: "-" })), jsx(TextField, { css: { borderRightStyle: "none", borderLeftStyle: "none" }, type: "number", ref: ref, value: qty, onChange: handleOnChange, onBlur: onBlur, name: name }), jsx(IconButton, __assign({ disabled: qty >= max, className: "inc-button", onClick: handleOnInc, borderDisabled: qty >= max }, { children: "+" }))] })));
1437
1438
  });
1438
1439
  NumberField.displayName = "NumberField";
1439
1440
 
@@ -1757,14 +1758,14 @@ var ProgressTracker = function (props) {
1757
1758
  display: "flex",
1758
1759
  justifyContent: "space-between",
1759
1760
  alignItems: "center",
1760
- } }, { children: items.map(function (item, index) { return (jsx(Link, __assign({ disabled: item.status === "incomplete", href: item.status === "incomplete" ? "javascript:void(0)" : item.href }, { children: item.title }), ":l".concat(index))); }) }))] })) })));
1761
+ } }, { children: items.map(function (item, index) { return (jsx(Link, __assign({ disabled: item.status === "incomplete", href: item.status === "incomplete" ? "#" : item.href }, { children: item.title }), ":l".concat(index))); }) }))] })) })));
1761
1762
  };
1762
1763
 
1763
1764
  var StyledRadio = styled(RadioGroupPrimitive.Item, {
1764
1765
  all: "unset",
1765
1766
  backgroundColor: "$obolGreen",
1766
- width: 25,
1767
- height: 25,
1767
+ width: 22,
1768
+ height: 22,
1768
1769
  borderRadius: "100%",
1769
1770
  "&:hover": { filter: "brightness(90%)", cursor: "pointer" },
1770
1771
  });
@@ -1779,10 +1780,10 @@ var StyledIndicator = styled(RadioGroupPrimitive.Indicator, {
1779
1780
  content: '""',
1780
1781
  display: "absolute",
1781
1782
  position: "absolute",
1782
- width: 11,
1783
- height: 11,
1783
+ width: 10,
1784
+ height: 10,
1784
1785
  borderRadius: "50%",
1785
- boxShadow: "0 0 0 4px #0E1E22",
1786
+ boxShadow: "0 0 0 3px #0E1E22",
1786
1787
  backgroundColor: "#2FE4AB",
1787
1788
  },
1788
1789
  });
@@ -1792,6 +1793,7 @@ var RadioGroupRadio = StyledRadio;
1792
1793
  var RadioGroupIndicator = StyledIndicator;
1793
1794
  var RadioGroupItemLabel = styled("label", {
1794
1795
  color: "$textLight",
1796
+ fontWeight: "$bold",
1795
1797
  fontSize: "$3",
1796
1798
  lineHeight: 1,
1797
1799
  userSelect: "none",
@@ -1801,7 +1803,7 @@ var RadioGroupItemLabel = styled("label", {
1801
1803
  var RadioGroupItem = function (_a) {
1802
1804
  var value = _a.value, label = _a.label, _b = _a.index, index = _b === void 0 ? 1 : _b;
1803
1805
  var id = "id-:r".concat(index, ":");
1804
- return (jsxs(Box, __assign({ css: { display: "flex", margin: "10px 0", alignItems: "center" } }, { children: [jsx(RadioGroupRadio, __assign({ value: value, id: id }, { children: jsx(RadioGroupPrimitive.RadioGroupIndicator, {}) })), jsx(RadioGroupItemLabel, __assign({ htmlFor: id }, { children: label }))] })));
1806
+ return (jsxs(Box, __assign({ css: { display: "flex", margin: "10px 0", alignItems: "center" } }, { children: [jsx(RadioGroupRadio, __assign({ value: value, id: id }, { children: jsx(RadioGroupPrimitive.RadioGroupIndicator, { className: "indicator" }) })), jsx(RadioGroupItemLabel, __assign({ htmlFor: id }, { children: label }))] })));
1805
1807
  };
1806
1808
  var RadioGroupComponent = function (_a) {
1807
1809
  var items = _a.items, value = _a.value, onValueChange = _a.onValueChange, props = __rest(_a, ["items", "value", "onValueChange"]);
@@ -1846,6 +1848,7 @@ var Td = styled("td", {
1846
1848
  noPadding: {
1847
1849
  true: {
1848
1850
  p: 0,
1851
+ backgroundColor: "$bg03",
1849
1852
  },
1850
1853
  },
1851
1854
  size: {
@@ -1876,7 +1879,6 @@ var SplitterTable = function (_a) {
1876
1879
  var rows = _a.rows, columns = _a.columns, onAddRow = _a.onAddRow, onRemoveRow = _a.onRemoveRow, onUpdateRow = _a.onUpdateRow, _b = _a.removeButton, removeButton = _b === void 0 ? true : _b;
1877
1880
  return (jsxs(StyledTable, { children: [jsxs("thead", { children: [jsx(Td, {}), columns.map(function (column, index) { return (jsx(Td, __assign({ css: { textAlign: "start" } }, { children: column.header }), "header-".concat(index))); }), jsx(Td, {})] }), jsxs("tbody", { children: [rows.map(function (row, rowIndex) { return (jsxs("tr", { children: [jsx(Td, __assign({ size: "sm" }, { children: rowIndex + 1 })), columns.map(function (column, cellIndex) {
1878
1881
  var _a;
1879
- // if (column === "id") return null;
1880
1882
  var isTextField = !!column.cell;
1881
1883
  return (jsx(Td, __assign({ noPadding: true, css: {
1882
1884
  "input::-webkit-inner-spin-button": {
@@ -1887,10 +1889,17 @@ var SplitterTable = function (_a) {
1887
1889
  "input[type=number]": {
1888
1890
  "-moz-appearance": "textfield",
1889
1891
  },
1890
- } }, { children: isTextField ? (jsx(TextField, __assign({ defaultValue: row[column.accessorKey], onChange: function (e) {
1891
- return onUpdateRow(row.id, e.target.value, column.accessorKey);
1892
+ } }, { children: isTextField ? (jsx(TextField, __assign({ defaultValue: row[column.accessorKey], onInput: function (e) {
1893
+ if (Number(e.target.value) > 100)
1894
+ e.target.value = 100;
1895
+ }, onChange: function (e) {
1896
+ var _a, _b;
1897
+ var value = ((_b = (_a = column.cell) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.type) === "number"
1898
+ ? Number(e.target.value)
1899
+ : e.target.value;
1900
+ onUpdateRow(row.id, value, column.accessorKey);
1892
1901
  } }, (_a = column.cell) === null || _a === void 0 ? void 0 : _a.config))) : (row[column.accessorKey]) }), "cell ".concat(cellIndex)));
1893
- }), removeButton && (jsx(Td, __assign({ size: "sm" }, { children: jsx(IconButton, __assign({ ghost: true, onClick: function () { return onRemoveRow(row.id); } }, { children: jsx(TrashIcon, {}) })) })))] }, row.id)); }), jsx(AddNewRow, { handleOnClick: function () { return onAddRow(""); } })] })] }));
1902
+ }), removeButton && (jsx(Td, __assign({ size: "sm" }, { children: jsx(IconButton, __assign({ ghost: true, onClick: function () { return onRemoveRow(row.id); } }, { children: jsx(TrashIcon, {}) })) })))] }, row.id)); }), jsx(AddNewRow, { handleOnClick: function () { return onAddRow(); } })] })] }));
1894
1903
  };
1895
1904
  var Table = function (_a) {
1896
1905
  var rows = _a.rows, columns = _a.columns;
package/dist/index.js CHANGED
@@ -1395,11 +1395,11 @@ var TextFieldWithCopy = React.forwardRef(function (props, ref) {
1395
1395
  TextFieldWithCopy.displayName = "TextFieldWithCopy";
1396
1396
 
1397
1397
  var NumberField = React.forwardRef(function (_a, ref) {
1398
- var _b = _a.max, max = _b === void 0 ? 10 : _b, _c = _a.min, min = _c === void 0 ? 1 : _c, value = _a.value, onChangeValue = _a.onChangeValue;
1398
+ var _b = _a.max, max = _b === void 0 ? 10 : _b, _c = _a.min, min = _c === void 0 ? 0 : _c, value = _a.value, onChangeValue = _a.onChangeValue, onBlur = _a.onBlur, name = _a.name;
1399
1399
  var _d = React.useState(value || min), qty = _d[0], setQty = _d[1];
1400
1400
  var handleOnDec = function (e) {
1401
1401
  e.preventDefault();
1402
- if (qty <= min) {
1402
+ if (qty < min) {
1403
1403
  setQty(min);
1404
1404
  }
1405
1405
  else {
@@ -1416,7 +1416,7 @@ var NumberField = React.forwardRef(function (_a, ref) {
1416
1416
  }
1417
1417
  };
1418
1418
  var handleOnChange = function (e) {
1419
- var value = e.target;
1419
+ var value = e.target.value;
1420
1420
  if (value > max) {
1421
1421
  setQty(max);
1422
1422
  }
@@ -1434,6 +1434,7 @@ var NumberField = React.forwardRef(function (_a, ref) {
1434
1434
  }, [qty, onChangeValue]);
1435
1435
  return (jsxRuntime.jsxs(Box, __assign({ css: {
1436
1436
  display: "flex",
1437
+ maxHeight: "$3xl",
1437
1438
  "input::-webkit-inner-spin-button": {
1438
1439
  "-webkit-appearance": "none",
1439
1440
  margin: 0,
@@ -1465,7 +1466,7 @@ var NumberField = React.forwardRef(function (_a, ref) {
1465
1466
  borderRadius: 0,
1466
1467
  width: "95px",
1467
1468
  },
1468
- } }, { children: [jsxRuntime.jsx(IconButton, __assign({ disabled: qty <= min, className: "dec-button", onClick: handleOnDec, borderDisabled: qty <= min }, { children: "-" })), jsxRuntime.jsx(TextField, { css: { borderRightStyle: "none", borderLeftStyle: "none" }, type: "number", ref: ref, value: qty, onChange: handleOnChange }), jsxRuntime.jsx(IconButton, __assign({ disabled: qty >= max, className: "inc-button", onClick: handleOnInc, borderDisabled: qty >= max }, { children: "+" }))] })));
1469
+ } }, { children: [jsxRuntime.jsx(IconButton, __assign({ disabled: qty <= min, className: "dec-button", onClick: handleOnDec, borderDisabled: qty <= min }, { children: "-" })), jsxRuntime.jsx(TextField, { css: { borderRightStyle: "none", borderLeftStyle: "none" }, type: "number", ref: ref, value: qty, onChange: handleOnChange, onBlur: onBlur, name: name }), jsxRuntime.jsx(IconButton, __assign({ disabled: qty >= max, className: "inc-button", onClick: handleOnInc, borderDisabled: qty >= max }, { children: "+" }))] })));
1469
1470
  });
1470
1471
  NumberField.displayName = "NumberField";
1471
1472
 
@@ -1789,14 +1790,14 @@ var ProgressTracker = function (props) {
1789
1790
  display: "flex",
1790
1791
  justifyContent: "space-between",
1791
1792
  alignItems: "center",
1792
- } }, { children: items.map(function (item, index) { return (jsxRuntime.jsx(Link, __assign({ disabled: item.status === "incomplete", href: item.status === "incomplete" ? "javascript:void(0)" : item.href }, { children: item.title }), ":l".concat(index))); }) }))] })) })));
1793
+ } }, { children: items.map(function (item, index) { return (jsxRuntime.jsx(Link, __assign({ disabled: item.status === "incomplete", href: item.status === "incomplete" ? "#" : item.href }, { children: item.title }), ":l".concat(index))); }) }))] })) })));
1793
1794
  };
1794
1795
 
1795
1796
  var StyledRadio = styled(RadioGroupPrimitive__namespace.Item, {
1796
1797
  all: "unset",
1797
1798
  backgroundColor: "$obolGreen",
1798
- width: 25,
1799
- height: 25,
1799
+ width: 22,
1800
+ height: 22,
1800
1801
  borderRadius: "100%",
1801
1802
  "&:hover": { filter: "brightness(90%)", cursor: "pointer" },
1802
1803
  });
@@ -1811,10 +1812,10 @@ var StyledIndicator = styled(RadioGroupPrimitive__namespace.Indicator, {
1811
1812
  content: '""',
1812
1813
  display: "absolute",
1813
1814
  position: "absolute",
1814
- width: 11,
1815
- height: 11,
1815
+ width: 10,
1816
+ height: 10,
1816
1817
  borderRadius: "50%",
1817
- boxShadow: "0 0 0 4px #0E1E22",
1818
+ boxShadow: "0 0 0 3px #0E1E22",
1818
1819
  backgroundColor: "#2FE4AB",
1819
1820
  },
1820
1821
  });
@@ -1824,6 +1825,7 @@ var RadioGroupRadio = StyledRadio;
1824
1825
  var RadioGroupIndicator = StyledIndicator;
1825
1826
  var RadioGroupItemLabel = styled("label", {
1826
1827
  color: "$textLight",
1828
+ fontWeight: "$bold",
1827
1829
  fontSize: "$3",
1828
1830
  lineHeight: 1,
1829
1831
  userSelect: "none",
@@ -1833,7 +1835,7 @@ var RadioGroupItemLabel = styled("label", {
1833
1835
  var RadioGroupItem = function (_a) {
1834
1836
  var value = _a.value, label = _a.label, _b = _a.index, index = _b === void 0 ? 1 : _b;
1835
1837
  var id = "id-:r".concat(index, ":");
1836
- return (jsxRuntime.jsxs(Box, __assign({ css: { display: "flex", margin: "10px 0", alignItems: "center" } }, { children: [jsxRuntime.jsx(RadioGroupRadio, __assign({ value: value, id: id }, { children: jsxRuntime.jsx(RadioGroupPrimitive__namespace.RadioGroupIndicator, {}) })), jsxRuntime.jsx(RadioGroupItemLabel, __assign({ htmlFor: id }, { children: label }))] })));
1838
+ return (jsxRuntime.jsxs(Box, __assign({ css: { display: "flex", margin: "10px 0", alignItems: "center" } }, { children: [jsxRuntime.jsx(RadioGroupRadio, __assign({ value: value, id: id }, { children: jsxRuntime.jsx(RadioGroupPrimitive__namespace.RadioGroupIndicator, { className: "indicator" }) })), jsxRuntime.jsx(RadioGroupItemLabel, __assign({ htmlFor: id }, { children: label }))] })));
1837
1839
  };
1838
1840
  var RadioGroupComponent = function (_a) {
1839
1841
  var items = _a.items, value = _a.value, onValueChange = _a.onValueChange, props = __rest(_a, ["items", "value", "onValueChange"]);
@@ -1878,6 +1880,7 @@ var Td = styled("td", {
1878
1880
  noPadding: {
1879
1881
  true: {
1880
1882
  p: 0,
1883
+ backgroundColor: "$bg03",
1881
1884
  },
1882
1885
  },
1883
1886
  size: {
@@ -1908,7 +1911,6 @@ var SplitterTable = function (_a) {
1908
1911
  var rows = _a.rows, columns = _a.columns, onAddRow = _a.onAddRow, onRemoveRow = _a.onRemoveRow, onUpdateRow = _a.onUpdateRow, _b = _a.removeButton, removeButton = _b === void 0 ? true : _b;
1909
1912
  return (jsxRuntime.jsxs(StyledTable, { children: [jsxRuntime.jsxs("thead", { children: [jsxRuntime.jsx(Td, {}), columns.map(function (column, index) { return (jsxRuntime.jsx(Td, __assign({ css: { textAlign: "start" } }, { children: column.header }), "header-".concat(index))); }), jsxRuntime.jsx(Td, {})] }), jsxRuntime.jsxs("tbody", { children: [rows.map(function (row, rowIndex) { return (jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx(Td, __assign({ size: "sm" }, { children: rowIndex + 1 })), columns.map(function (column, cellIndex) {
1910
1913
  var _a;
1911
- // if (column === "id") return null;
1912
1914
  var isTextField = !!column.cell;
1913
1915
  return (jsxRuntime.jsx(Td, __assign({ noPadding: true, css: {
1914
1916
  "input::-webkit-inner-spin-button": {
@@ -1919,10 +1921,17 @@ var SplitterTable = function (_a) {
1919
1921
  "input[type=number]": {
1920
1922
  "-moz-appearance": "textfield",
1921
1923
  },
1922
- } }, { children: isTextField ? (jsxRuntime.jsx(TextField, __assign({ defaultValue: row[column.accessorKey], onChange: function (e) {
1923
- return onUpdateRow(row.id, e.target.value, column.accessorKey);
1924
+ } }, { children: isTextField ? (jsxRuntime.jsx(TextField, __assign({ defaultValue: row[column.accessorKey], onInput: function (e) {
1925
+ if (Number(e.target.value) > 100)
1926
+ e.target.value = 100;
1927
+ }, onChange: function (e) {
1928
+ var _a, _b;
1929
+ var value = ((_b = (_a = column.cell) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.type) === "number"
1930
+ ? Number(e.target.value)
1931
+ : e.target.value;
1932
+ onUpdateRow(row.id, value, column.accessorKey);
1924
1933
  } }, (_a = column.cell) === null || _a === void 0 ? void 0 : _a.config))) : (row[column.accessorKey]) }), "cell ".concat(cellIndex)));
1925
- }), removeButton && (jsxRuntime.jsx(Td, __assign({ size: "sm" }, { children: jsxRuntime.jsx(IconButton, __assign({ ghost: true, onClick: function () { return onRemoveRow(row.id); } }, { children: jsxRuntime.jsx(TrashIcon, {}) })) })))] }, row.id)); }), jsxRuntime.jsx(AddNewRow, { handleOnClick: function () { return onAddRow(""); } })] })] }));
1934
+ }), removeButton && (jsxRuntime.jsx(Td, __assign({ size: "sm" }, { children: jsxRuntime.jsx(IconButton, __assign({ ghost: true, onClick: function () { return onRemoveRow(row.id); } }, { children: jsxRuntime.jsx(TrashIcon, {}) })) })))] }, row.id)); }), jsxRuntime.jsx(AddNewRow, { handleOnClick: function () { return onAddRow(); } })] })] }));
1926
1935
  };
1927
1936
  var Table = function (_a) {
1928
1937
  var rows = _a.rows, columns = _a.columns;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-ui",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "license": "MIT",