tw-react-components 0.0.175 → 0.0.177

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/index.esm.js CHANGED
@@ -1617,7 +1617,7 @@ function DataTable({ className, columns, rows, sorting, pagination, actions = []
1617
1617
  .map((action, actionIndex) => {
1618
1618
  var _a;
1619
1619
  const notification = (_a = action.hasNotification) === null || _a === void 0 ? void 0 : _a.call(action, item, rowIndex);
1620
- return (jsxs("div", { className: "relative", children: [jsx(Button, { size: "small", prefixIcon: action.icon, color: action.color, onClick: handleActionClicked(action, item, rowIndex), children: action.label, dataTestId: `${dataTestId}-action-button-${rowIndex}-${actionIndex}` }), notification &&
1620
+ return (jsxs("div", { className: "relative", children: [jsx(Button, { size: "small", prefixIcon: action.icon, color: action.color, loading: action.loading, onClick: handleActionClicked(action, item, rowIndex), children: action.label, dataTestId: `${dataTestId}-action-button-${rowIndex}-${actionIndex}` }), notification &&
1621
1621
  (notification === true ? (jsx(Hint.Dot, {})) : notification.type === 'dot' ? (jsx(Hint.Dot, Object.assign({}, notification.props))) : (jsx(Hint.Badge, Object.assign({}, notification.props))))] }, actionIndex));
1622
1622
  }) }) }))] }, rowIndex),
1623
1623
  rowExtraContent && expandedRows[rowExtraContent.idGetter(item)] && (jsx(Table.Row, { dataTestId: `${dataTestId}-expanded-row-${rowIndex}`, children: jsx(Table.Cell, { className: "p-0", colSpan: columnsLength, dataTestId: `${dataTestId}-expanded-cell-${rowIndex}`, children: jsx(rowExtraContent.component, { item: item, rowIndex: rowIndex }) }) }, `${rowIndex}-expanded`)),
@@ -1683,8 +1683,13 @@ const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, on
1683
1683
  const [loading, setLoading] = useState(false);
1684
1684
  const handleConfirm = () => __awaiter(void 0, void 0, void 0, function* () {
1685
1685
  setLoading(true);
1686
- yield onConfirm();
1687
- setLoading(false);
1686
+ try {
1687
+ yield onConfirm();
1688
+ }
1689
+ catch (_a) {
1690
+ setLoading(false);
1691
+ }
1692
+ onClose();
1688
1693
  });
1689
1694
  return (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { dataTestId: `${dataTestId}-content`, children: [jsx(Dialog.Header, { dataTestId: `${dataTestId}-header`, children: jsx(Dialog.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), children, jsxs(Dialog.Footer, { dataTestId: `${dataTestId}-footer`, children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", disabled: loading, "data-testid": `${dataTestId}-no-button`, children: noLabel !== null && noLabel !== void 0 ? noLabel : 'No' }) }), jsx(Button, { color: "green", loading: loading, onClick: handleConfirm, "data-testid": `${dataTestId}-yes-button`, children: yesLabel !== null && yesLabel !== void 0 ? yesLabel : 'Yes' })] })] }) }));
1690
1695
  };
@@ -1788,8 +1793,13 @@ function ListSorterDialog({ className, open, title, items, idResolver, renderer,
1788
1793
  }, [items, open]);
1789
1794
  const handleSubmit = () => __awaiter(this, void 0, void 0, function* () {
1790
1795
  setLoading(true);
1791
- yield onSubmit(sortedItems);
1792
- setLoading(false);
1796
+ try {
1797
+ yield onSubmit(sortedItems);
1798
+ }
1799
+ catch (_a) {
1800
+ setLoading(false);
1801
+ }
1802
+ onClose();
1793
1803
  });
1794
1804
  const customRenderer = (item, index, listeners) => (jsxs(Flex, { align: "center", className: "gap-4 p-4 focus:outline-hidden dark:bg-slate-900 hover:dark:bg-slate-800", "data-testid": `${dataTestId}-item-${index}`, children: [jsx(Flex, Object.assign({ align: "center", justify: "center", className: "cursor-move rounded-lg p-2 hover:bg-slate-200 dark:hover:bg-slate-700", "data-testid": `${dataTestId}-drag-handle-${index}` }, listeners, { children: jsx(ArrowUpDownIcon, { className: "h-5 w-5" }) })), renderer(item, index, listeners)] }));
1795
1805
  return (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: className, onPointerDownOutside: (event) => event.preventDefault(), dataTestId: `${dataTestId}-content`, children: [jsx(Dialog.Header, { dataTestId: `${dataTestId}-header`, children: jsx(Dialog.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), jsx(ListSorter, { className: "divide-y overflow-auto rounded-lg border dark:divide-slate-700 dark:border-slate-700 dark:text-white", items: sortedItems, idResolver: idResolver, renderer: customRenderer, onChange: setSortedItems, dataTestId: `${dataTestId}-sorter` }), jsxs(Dialog.Footer, { dataTestId: `${dataTestId}-footer`, children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", disabled: loading, dataTestId: `${dataTestId}-cancel-button`, children: cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : 'Cancel' }) }), jsx(Button, { color: "green", loading: loading, onClick: handleSubmit, dataTestId: `${dataTestId}-submit-button`, children: submitLabel !== null && submitLabel !== void 0 ? submitLabel : 'Submit' })] })] }) }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tw-react-components",
3
3
  "description": "A set of React components build with TailwindCSS to make a nice dashboard.",
4
- "version": "0.0.175",
4
+ "version": "0.0.177",
5
5
  "license": "MIT",
6
6
  "homepage": "https://bacali95.github.io/tw-react-components",
7
7
  "type": "module",
@@ -43,6 +43,7 @@ export type DataTableAction<T> = {
43
43
  } | boolean;
44
44
  color?: Color;
45
45
  hide?: boolean | ((item: T) => boolean);
46
+ loading?: boolean;
46
47
  onClick: (item: T, rowIndex: number) => void;
47
48
  };
48
49
  export type DataTableProps<T> = {