@dreamtree-org/twreact-ui 1.1.72 → 1.2.0
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/README.md +19 -5
- package/dist/components/core/Table/Table.d.ts +2 -53
- package/dist/components/core/Table/Table.d.ts.map +1 -1
- package/dist/components/feedback/Toast.d.ts +6 -8
- package/dist/components/feedback/Toast.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +448 -175
- package/dist/index.js +447 -174
- package/mcp/catalog.snapshot.json +47 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -247,6 +247,22 @@ const Calendar = createLucideIcon$1("Calendar", [
|
|
|
247
247
|
*/
|
|
248
248
|
|
|
249
249
|
|
|
250
|
+
const CheckCircle2 = createLucideIcon$1("CheckCircle2", [
|
|
251
|
+
[
|
|
252
|
+
"path",
|
|
253
|
+
{
|
|
254
|
+
d: "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z",
|
|
255
|
+
key: "14v8dr"
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
259
|
+
]);
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* lucide-react v0.0.1 - ISC
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
|
|
250
266
|
const CheckCircle = createLucideIcon$1("CheckCircle", [
|
|
251
267
|
["path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14", key: "g774vq" }],
|
|
252
268
|
["polyline", { points: "22 4 12 14.01 9 11.01", key: "6xbx8j" }]
|
|
@@ -657,6 +673,17 @@ const User = createLucideIcon$1("User", [
|
|
|
657
673
|
*/
|
|
658
674
|
|
|
659
675
|
|
|
676
|
+
const XCircle = createLucideIcon$1("XCircle", [
|
|
677
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
678
|
+
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
|
|
679
|
+
["path", { d: "m9 9 6 6", key: "z0biqf" }]
|
|
680
|
+
]);
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* lucide-react v0.0.1 - ISC
|
|
684
|
+
*/
|
|
685
|
+
|
|
686
|
+
|
|
660
687
|
const X = createLucideIcon$1("X", [
|
|
661
688
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
662
689
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
@@ -5702,7 +5729,7 @@ function FieldInput(_ref) {
|
|
|
5702
5729
|
});
|
|
5703
5730
|
}
|
|
5704
5731
|
|
|
5705
|
-
var _excluded$x = ["data", "columns", "sortable", "filterable", "selectable", "pagination", "pageSize", "onSort", "onFilter", "onFetch", "onFilterChange", "onSelectionChange", "onRowClick", "hasDetails", "DetailsComponent", "className", "withAction", "onAction", "actions", "replaceDefaultActions", "showSerial", "cellClass", "rowClass", "globalSearch", "limitOptions", "showLimitSelector", "onLimitChange", "showReloadButton", "renderReloadButton", "onReload", "stripedRows", "theme", "responsiveBreakpoint", "serverSide", "totalRecords", "pageNumber", "onPageChange", "TheadComponent", "TfootComponent", "interactive", "onSave", "onEdit", "onRowAdd", "onRowDelete"],
|
|
5732
|
+
var _excluded$x = ["data", "columns", "sortable", "filterable", "selectable", "pagination", "pageSize", "onSort", "onFilter", "onFetch", "onFilterChange", "onSelectionChange", "onRowClick", "hasDetails", "DetailsComponent", "className", "withAction", "onAction", "actions", "replaceDefaultActions", "showSerial", "cellClass", "rowClass", "globalSearch", "limitOptions", "showLimitSelector", "onLimitChange", "showReloadButton", "renderReloadButton", "onReload", "stripedRows", "theme", "responsiveBreakpoint", "serverSide", "totalRecords", "pageNumber", "onPageChange", "TheadComponent", "TfootComponent", "interactive", "onSave", "onEdit", "onRowAdd", "onRowDelete", "editKeyBinding", "newRowPosition", "addRowRef", "onInitAddRow", "renderAddRowButton", "renderExternalAddRow"],
|
|
5706
5733
|
_excluded2$4 = ["_key", "_isNew"];
|
|
5707
5734
|
function ownKeys$B(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5708
5735
|
function _objectSpread$B(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$B(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$B(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -5715,7 +5742,7 @@ var DEFAULT_THEME = {
|
|
|
5715
5742
|
menuBg: "bg-white",
|
|
5716
5743
|
menuItemHover: "hover:bg-gray-50"
|
|
5717
5744
|
};
|
|
5718
|
-
var Table = function Table(_ref) {
|
|
5745
|
+
var Table = /*#__PURE__*/React.forwardRef(function Table(_ref, ref) {
|
|
5719
5746
|
var _validationErrors$;
|
|
5720
5747
|
var _ref$data = _ref.data,
|
|
5721
5748
|
initialData = _ref$data === void 0 ? DEFAULT_DATA : _ref$data,
|
|
@@ -5785,6 +5812,14 @@ var Table = function Table(_ref) {
|
|
|
5785
5812
|
onEdit = _ref.onEdit,
|
|
5786
5813
|
onRowAdd = _ref.onRowAdd,
|
|
5787
5814
|
onRowDelete = _ref.onRowDelete,
|
|
5815
|
+
_ref$editKeyBinding = _ref.editKeyBinding,
|
|
5816
|
+
editKeyBinding = _ref$editKeyBinding === void 0 ? "e" : _ref$editKeyBinding,
|
|
5817
|
+
_ref$newRowPosition = _ref.newRowPosition,
|
|
5818
|
+
newRowPosition = _ref$newRowPosition === void 0 ? "bottom" : _ref$newRowPosition,
|
|
5819
|
+
addRowRef = _ref.addRowRef,
|
|
5820
|
+
onInitAddRow = _ref.onInitAddRow,
|
|
5821
|
+
renderAddRowButton = _ref.renderAddRowButton,
|
|
5822
|
+
renderExternalAddRow = _ref.renderExternalAddRow,
|
|
5788
5823
|
props = _objectWithoutProperties$1(_ref, _excluded$x);
|
|
5789
5824
|
theme = _objectSpread$B(_objectSpread$B({}, DEFAULT_THEME), theme);
|
|
5790
5825
|
// State
|
|
@@ -6062,9 +6097,10 @@ var Table = function Table(_ref) {
|
|
|
6062
6097
|
return _objectSpread$B(_objectSpread$B({}, prev), {}, _defineProperty$4({}, rowKey, nextRowEdits));
|
|
6063
6098
|
});
|
|
6064
6099
|
}, [newRows, tableData, onEdit]);
|
|
6065
|
-
var
|
|
6100
|
+
var _handleAddRow = React.useCallback(function (positionOverride) {
|
|
6066
6101
|
var _columnsState$find, _columnsState$;
|
|
6067
|
-
var
|
|
6102
|
+
var targetPos = typeof positionOverride === "string" && (positionOverride === "top" || positionOverride === "bottom") ? positionOverride : newRowPosition || "bottom";
|
|
6103
|
+
var newKey = "new-".concat(Date.now(), "-").concat(Math.random().toString(36).substring(2, 6));
|
|
6068
6104
|
var newRowObj = {
|
|
6069
6105
|
_key: newKey,
|
|
6070
6106
|
_isNew: true
|
|
@@ -6074,23 +6110,51 @@ var Table = function Table(_ref) {
|
|
|
6074
6110
|
newRowObj[col.key] = (_col$defaultValue = col.defaultValue) !== null && _col$defaultValue !== void 0 ? _col$defaultValue : "";
|
|
6075
6111
|
});
|
|
6076
6112
|
setNewRows(function (prev) {
|
|
6113
|
+
if (targetPos === "top") {
|
|
6114
|
+
return [newRowObj].concat(_toConsumableArray$1(prev));
|
|
6115
|
+
}
|
|
6077
6116
|
return [].concat(_toConsumableArray$1(prev), [newRowObj]);
|
|
6078
6117
|
});
|
|
6079
6118
|
var firstColKey = ((_columnsState$find = columnsState.find(function (c) {
|
|
6080
6119
|
return c.isVisible !== false;
|
|
6081
6120
|
})) === null || _columnsState$find === void 0 ? void 0 : _columnsState$find.key) || ((_columnsState$ = columnsState[0]) === null || _columnsState$ === void 0 ? void 0 : _columnsState$.key);
|
|
6121
|
+
var initialRowIndex = targetPos === "top" ? 0 : tableData.length + newRows.length;
|
|
6082
6122
|
setActiveCell({
|
|
6083
6123
|
rowKey: newKey,
|
|
6084
6124
|
colKey: firstColKey,
|
|
6085
|
-
rowIndex:
|
|
6125
|
+
rowIndex: initialRowIndex
|
|
6086
6126
|
});
|
|
6087
6127
|
setEditingCell({
|
|
6088
6128
|
rowKey: newKey,
|
|
6089
6129
|
colKey: firstColKey,
|
|
6090
|
-
rowIndex:
|
|
6130
|
+
rowIndex: initialRowIndex
|
|
6091
6131
|
});
|
|
6092
|
-
onRowAdd === null || onRowAdd === void 0 || onRowAdd(newRowObj);
|
|
6093
|
-
}, [columnsState, tableData.length, newRows.length, onRowAdd]);
|
|
6132
|
+
onRowAdd === null || onRowAdd === void 0 || onRowAdd(newRowObj, targetPos);
|
|
6133
|
+
}, [columnsState, tableData.length, newRows.length, onRowAdd, newRowPosition]);
|
|
6134
|
+
React.useImperativeHandle(ref, function () {
|
|
6135
|
+
return {
|
|
6136
|
+
addRow: function addRow(pos) {
|
|
6137
|
+
return _handleAddRow(pos);
|
|
6138
|
+
},
|
|
6139
|
+
addNewRow: function addNewRow(pos) {
|
|
6140
|
+
return _handleAddRow(pos);
|
|
6141
|
+
},
|
|
6142
|
+
handleAddRow: function handleAddRow(pos) {
|
|
6143
|
+
return _handleAddRow(pos);
|
|
6144
|
+
},
|
|
6145
|
+
tableContainerRef: tableContainerRef.current
|
|
6146
|
+
};
|
|
6147
|
+
}, [_handleAddRow]);
|
|
6148
|
+
React.useEffect(function () {
|
|
6149
|
+
if (addRowRef) {
|
|
6150
|
+
addRowRef.current = function (pos) {
|
|
6151
|
+
return _handleAddRow(pos);
|
|
6152
|
+
};
|
|
6153
|
+
}
|
|
6154
|
+
onInitAddRow === null || onInitAddRow === void 0 || onInitAddRow(function (pos) {
|
|
6155
|
+
return _handleAddRow(pos);
|
|
6156
|
+
});
|
|
6157
|
+
}, [addRowRef, onInitAddRow, _handleAddRow]);
|
|
6094
6158
|
var handleDeleteNewRow = React.useCallback(function (rowKey) {
|
|
6095
6159
|
setNewRows(function (prev) {
|
|
6096
6160
|
return prev.filter(function (r) {
|
|
@@ -6354,6 +6418,15 @@ var Table = function Table(_ref) {
|
|
|
6354
6418
|
};
|
|
6355
6419
|
});
|
|
6356
6420
|
}, [limitOptions]);
|
|
6421
|
+
var isEditKey = React.useCallback(function (key, e) {
|
|
6422
|
+
if (typeof editKeyBinding === "function") {
|
|
6423
|
+
return editKeyBinding(e);
|
|
6424
|
+
}
|
|
6425
|
+
if (typeof editKeyBinding === "string" && editKeyBinding.trim() !== "") {
|
|
6426
|
+
return key.toLowerCase() === editKeyBinding.toLowerCase();
|
|
6427
|
+
}
|
|
6428
|
+
return key.toLowerCase() === "e" || key === "Insert";
|
|
6429
|
+
}, [editKeyBinding]);
|
|
6357
6430
|
var handleTableKeyDown = React.useCallback(function (e) {
|
|
6358
6431
|
if (!interactive) return;
|
|
6359
6432
|
var key = e.key,
|
|
@@ -6366,24 +6439,33 @@ var Table = function Table(_ref) {
|
|
|
6366
6439
|
}
|
|
6367
6440
|
return;
|
|
6368
6441
|
}
|
|
6369
|
-
// Enter: Save changes
|
|
6370
|
-
if (key === "Enter") {
|
|
6442
|
+
// Enter: Save changes when there are modified changes (isDirty)
|
|
6443
|
+
if (key === "Enter" && isDirty) {
|
|
6371
6444
|
var _e$target;
|
|
6372
6445
|
if (((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName) === "TEXTAREA" && shiftKey) {
|
|
6373
6446
|
return;
|
|
6374
6447
|
}
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
handleSave();
|
|
6380
|
-
}
|
|
6448
|
+
e.preventDefault();
|
|
6449
|
+
setEditingCell(null);
|
|
6450
|
+
if (isValid && !isSaving) {
|
|
6451
|
+
handleSave();
|
|
6381
6452
|
}
|
|
6382
6453
|
return;
|
|
6383
6454
|
}
|
|
6455
|
+
// Standard Edit Key ('e' or custom editKeyBinding) when focused on active cell and not editing: enter edit mode
|
|
6456
|
+
if (isEditKey(key, e) && activeCell && !editingCell) {
|
|
6457
|
+
var col = visibleColumns.find(function (c) {
|
|
6458
|
+
return c.key === activeCell.colKey;
|
|
6459
|
+
});
|
|
6460
|
+
if (col && col.editable !== false) {
|
|
6461
|
+
e.preventDefault();
|
|
6462
|
+
setEditingCell(activeCell);
|
|
6463
|
+
return;
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6384
6466
|
var currentCell = activeCell || editingCell;
|
|
6385
6467
|
if (!currentCell) return;
|
|
6386
|
-
var allRows = [].concat(_toConsumableArray$1(paginatedData), _toConsumableArray$1(newRows));
|
|
6468
|
+
var allRows = newRowPosition === "top" ? [].concat(_toConsumableArray$1(newRows), _toConsumableArray$1(paginatedData)) : [].concat(_toConsumableArray$1(paginatedData), _toConsumableArray$1(newRows));
|
|
6387
6469
|
if (allRows.length === 0 || visibleColumns.length === 0) return;
|
|
6388
6470
|
var rIdx = allRows.findIndex(function (r, idx) {
|
|
6389
6471
|
var rKey = r._key || getRowKey(r, startIndex + idx);
|
|
@@ -6702,6 +6784,26 @@ var Table = function Table(_ref) {
|
|
|
6702
6784
|
invalidCellSet: invalidCellSet,
|
|
6703
6785
|
pendingEdits: pendingEdits
|
|
6704
6786
|
};
|
|
6787
|
+
var renderAddRowClickableRow = React.useCallback(function () {
|
|
6788
|
+
return jsxRuntime.jsx("tr", {
|
|
6789
|
+
onClick: function onClick() {
|
|
6790
|
+
return _handleAddRow(newRowPosition);
|
|
6791
|
+
},
|
|
6792
|
+
className: "bg-primary-50/40 hover:bg-primary-100/70 active:bg-primary-100 transition-colors border-t-2 border-b-2 border-dashed border-primary-300 cursor-pointer group",
|
|
6793
|
+
children: jsxRuntime.jsx("td", {
|
|
6794
|
+
colSpan: visibleCount,
|
|
6795
|
+
className: "px-6 py-3.5 text-left text-sm font-semibold text-primary-700 group-hover:text-primary-800",
|
|
6796
|
+
children: jsxRuntime.jsxs("div", {
|
|
6797
|
+
className: "flex items-center justify-start gap-2",
|
|
6798
|
+
children: [jsxRuntime.jsx(Plus, {
|
|
6799
|
+
className: "w-4 h-4 text-primary-600 group-hover:scale-110 transition-transform"
|
|
6800
|
+
}), jsxRuntime.jsx("span", {
|
|
6801
|
+
children: "Click here to add new record instantly...."
|
|
6802
|
+
})]
|
|
6803
|
+
})
|
|
6804
|
+
})
|
|
6805
|
+
});
|
|
6806
|
+
}, [_handleAddRow, newRowPosition, visibleCount]);
|
|
6705
6807
|
return jsxRuntime.jsxs("div", {
|
|
6706
6808
|
ref: tableContainerRef,
|
|
6707
6809
|
tabIndex: interactive ? 0 : undefined,
|
|
@@ -6746,7 +6848,14 @@ var Table = function Table(_ref) {
|
|
|
6746
6848
|
})]
|
|
6747
6849
|
}), jsxRuntime.jsxs("div", {
|
|
6748
6850
|
className: "flex flex-col sm:flex-row items-start sm:items-center gap-3 w-full md:w-auto",
|
|
6749
|
-
children: [interactive &&
|
|
6851
|
+
children: [interactive && (renderAddRowButton || renderExternalAddRow) && jsxRuntime.jsx("div", {
|
|
6852
|
+
className: "flex items-center gap-2",
|
|
6853
|
+
children: typeof (renderAddRowButton || renderExternalAddRow) === "function" ? (renderAddRowButton || renderExternalAddRow)({
|
|
6854
|
+
addRow: _handleAddRow,
|
|
6855
|
+
handleAddRow: _handleAddRow,
|
|
6856
|
+
newRowPosition: newRowPosition
|
|
6857
|
+
}) : renderAddRowButton || renderExternalAddRow
|
|
6858
|
+
}), interactive && isDirty && jsxRuntime.jsxs("div", {
|
|
6750
6859
|
className: "flex items-center gap-2 flex-wrap",
|
|
6751
6860
|
children: [jsxRuntime.jsxs("button", {
|
|
6752
6861
|
type: "button",
|
|
@@ -6942,9 +7051,9 @@ var Table = function Table(_ref) {
|
|
|
6942
7051
|
className: "pb-4"
|
|
6943
7052
|
})]
|
|
6944
7053
|
})]
|
|
6945
|
-
}), jsxRuntime.
|
|
7054
|
+
}), jsxRuntime.jsx("tbody", {
|
|
6946
7055
|
className: "divide-y divide-gray-200",
|
|
6947
|
-
children:
|
|
7056
|
+
children: loading ? jsxRuntime.jsx("tr", {
|
|
6948
7057
|
children: jsxRuntime.jsx("td", {
|
|
6949
7058
|
colSpan: visibleCount,
|
|
6950
7059
|
className: "px-6 py-8 text-center",
|
|
@@ -6958,32 +7067,43 @@ var Table = function Table(_ref) {
|
|
|
6958
7067
|
})]
|
|
6959
7068
|
})
|
|
6960
7069
|
})
|
|
6961
|
-
}) : paginatedData.length === 0 && newRows.length === 0 ? jsxRuntime.
|
|
6962
|
-
children: jsxRuntime.jsx("
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
7070
|
+
}) : paginatedData.length === 0 && newRows.length === 0 ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
7071
|
+
children: [interactive && newRowPosition === "top" && renderAddRowClickableRow(), jsxRuntime.jsx("tr", {
|
|
7072
|
+
children: jsxRuntime.jsx("td", {
|
|
7073
|
+
colSpan: visibleCount,
|
|
7074
|
+
className: "px-6 py-8 text-center",
|
|
7075
|
+
children: jsxRuntime.jsxs("div", {
|
|
7076
|
+
className: "flex flex-col items-center gap-2",
|
|
7077
|
+
children: [jsxRuntime.jsx("div", {
|
|
7078
|
+
className: "text-primary-400",
|
|
7079
|
+
children: jsxRuntime.jsx(List, {
|
|
7080
|
+
className: "h-8 w-8"
|
|
7081
|
+
})
|
|
7082
|
+
}), jsxRuntime.jsx("span", {
|
|
7083
|
+
className: "text-sm text-primary-500",
|
|
7084
|
+
children: "No results found."
|
|
7085
|
+
})]
|
|
7086
|
+
})
|
|
6976
7087
|
})
|
|
6977
|
-
})
|
|
7088
|
+
}), interactive && newRowPosition !== "top" && renderAddRowClickableRow()]
|
|
6978
7089
|
}) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
6979
|
-
children: [
|
|
7090
|
+
children: [interactive && newRowPosition === "top" && renderAddRowClickableRow(), interactive && newRowPosition === "top" && newRows.map(function (newRow, newIdx) {
|
|
7091
|
+
return jsxRuntime.jsx(TableRow, _objectSpread$B({
|
|
7092
|
+
row: newRow,
|
|
7093
|
+
rowIndexInPage: newIdx,
|
|
7094
|
+
startIndex: 0,
|
|
7095
|
+
visibleCount: visibleCount,
|
|
7096
|
+
isNewRow: true,
|
|
7097
|
+
onDeleteNewRow: handleDeleteNewRow
|
|
7098
|
+
}, rowSharedProps), newRow._key);
|
|
7099
|
+
}), paginatedData.map(function (row, rowIndexInPage) {
|
|
6980
7100
|
return jsxRuntime.jsx(TableRow, _objectSpread$B({
|
|
6981
7101
|
row: row,
|
|
6982
7102
|
rowIndexInPage: rowIndexInPage,
|
|
6983
7103
|
startIndex: startIndex,
|
|
6984
7104
|
visibleCount: visibleCount
|
|
6985
7105
|
}, rowSharedProps), getRowKey(row, startIndex + rowIndexInPage));
|
|
6986
|
-
}), interactive && newRows.map(function (newRow, newIdx) {
|
|
7106
|
+
}), interactive && newRowPosition !== "top" && newRows.map(function (newRow, newIdx) {
|
|
6987
7107
|
return jsxRuntime.jsx(TableRow, _objectSpread$B({
|
|
6988
7108
|
row: newRow,
|
|
6989
7109
|
rowIndexInPage: paginatedData.length + newIdx,
|
|
@@ -6992,23 +7112,8 @@ var Table = function Table(_ref) {
|
|
|
6992
7112
|
isNewRow: true,
|
|
6993
7113
|
onDeleteNewRow: handleDeleteNewRow
|
|
6994
7114
|
}, rowSharedProps), newRow._key);
|
|
6995
|
-
})]
|
|
6996
|
-
})
|
|
6997
|
-
onClick: handleAddRow,
|
|
6998
|
-
className: "bg-primary-50/40 hover:bg-primary-100/70 active:bg-primary-100 transition-colors border-t-2 border-dashed border-primary-300 cursor-pointer group",
|
|
6999
|
-
children: jsxRuntime.jsx("td", {
|
|
7000
|
-
colSpan: visibleCount,
|
|
7001
|
-
className: "px-6 py-3.5 text-left text-sm font-semibold text-primary-700 group-hover:text-primary-800",
|
|
7002
|
-
children: jsxRuntime.jsxs("div", {
|
|
7003
|
-
className: "flex items-center justify-start gap-2",
|
|
7004
|
-
children: [jsxRuntime.jsx(Plus, {
|
|
7005
|
-
className: "w-4 h-4 text-primary-600 group-hover:scale-110 transition-transform"
|
|
7006
|
-
}), jsxRuntime.jsx("span", {
|
|
7007
|
-
children: "Click here to add new record instantly...."
|
|
7008
|
-
})]
|
|
7009
|
-
})
|
|
7010
|
-
})
|
|
7011
|
-
})]
|
|
7115
|
+
}), interactive && newRowPosition !== "top" && renderAddRowClickableRow()]
|
|
7116
|
+
})
|
|
7012
7117
|
})]
|
|
7013
7118
|
}))
|
|
7014
7119
|
}), isMobileView && jsxRuntime.jsx("div", {
|
|
@@ -7056,7 +7161,7 @@ var Table = function Table(_ref) {
|
|
|
7056
7161
|
theme: safeTheme
|
|
7057
7162
|
})]
|
|
7058
7163
|
});
|
|
7059
|
-
};
|
|
7164
|
+
});
|
|
7060
7165
|
|
|
7061
7166
|
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
7062
7167
|
|
|
@@ -13677,7 +13782,7 @@ var Accordion = /*#__PURE__*/React.forwardRef(function Accordion(_ref, ref) {
|
|
|
13677
13782
|
});
|
|
13678
13783
|
Accordion.displayName = "Accordion";
|
|
13679
13784
|
|
|
13680
|
-
var _excluded$s = ["id", "name", "label", "checked", "defaultChecked", "onChange", "disabled", "required", "className", "size", "labelPosition", "value", "ariaLabel", "variant", "indeterminate", "borderColor", "color", "iconClass", "checkedClass"];
|
|
13785
|
+
var _excluded$s = ["id", "name", "label", "checked", "defaultChecked", "onChange", "disabled", "required", "className", "size", "labelPosition", "value", "ariaLabel", "variant", "indeterminate", "borderColor", "color", "iconClass", "checkedClass", "wrapperProps"];
|
|
13681
13786
|
function ownKeys$w(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13682
13787
|
function _objectSpread$w(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$w(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$w(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13683
13788
|
var SIZE_CLASSES = {
|
|
@@ -13744,7 +13849,6 @@ var COLOR_PRESETS = {
|
|
|
13744
13849
|
}
|
|
13745
13850
|
};
|
|
13746
13851
|
var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
13747
|
-
var _props$wrapperProps;
|
|
13748
13852
|
var id = _ref.id,
|
|
13749
13853
|
name = _ref.name,
|
|
13750
13854
|
label = _ref.label,
|
|
@@ -13772,6 +13876,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13772
13876
|
color = _ref$color === void 0 ? "primary" : _ref$color,
|
|
13773
13877
|
iconClass = _ref.iconClass,
|
|
13774
13878
|
checkedClass = _ref.checkedClass,
|
|
13879
|
+
wrapperProps = _ref.wrapperProps,
|
|
13775
13880
|
props = _objectWithoutProperties$1(_ref, _excluded$s);
|
|
13776
13881
|
var autoId = React.useId();
|
|
13777
13882
|
var inputId = id || "".concat(autoId, "-checkbox");
|
|
@@ -13812,7 +13917,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13812
13917
|
} : {};
|
|
13813
13918
|
return jsxRuntime.jsxs("div", _objectSpread$w(_objectSpread$w({
|
|
13814
13919
|
className: wrapperCls
|
|
13815
|
-
},
|
|
13920
|
+
}, wrapperProps !== null && wrapperProps !== void 0 ? wrapperProps : {}), {}, {
|
|
13816
13921
|
children: [label && labelPosition === "left" && jsxRuntime.jsx("label", {
|
|
13817
13922
|
htmlFor: inputId,
|
|
13818
13923
|
className: "".concat(sizeClass.label, " select-none mr-2"),
|
|
@@ -13831,7 +13936,6 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13831
13936
|
className: "peer absolute inset-0 m-0 p-0 opacity-0 z-10",
|
|
13832
13937
|
// ensure we set checked only from the boolean (avoid undefined)
|
|
13833
13938
|
checked: Boolean(currentChecked),
|
|
13834
|
-
defaultChecked: defaultChecked,
|
|
13835
13939
|
onChange: handleChange,
|
|
13836
13940
|
disabled: disabled,
|
|
13837
13941
|
required: required,
|
|
@@ -13858,6 +13962,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13858
13962
|
})]
|
|
13859
13963
|
}));
|
|
13860
13964
|
});
|
|
13965
|
+
Checkbox.displayName = "Checkbox";
|
|
13861
13966
|
|
|
13862
13967
|
var _excluded$r = ["value", "defaultValue", "onChange", "swatches", "showAlpha", "size", "disabled", "className", "label", "id"];
|
|
13863
13968
|
function ownKeys$v(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -19220,13 +19325,57 @@ Dialog.Footer = function (_ref6) {
|
|
|
19220
19325
|
}));
|
|
19221
19326
|
};
|
|
19222
19327
|
|
|
19223
|
-
var _excluded$7 = ["id", "title", "message", "type", "duration", "onClose", "position"];
|
|
19328
|
+
var _excluded$7 = ["id", "title", "message", "description", "type", "duration", "onClose", "position", "statusIcon", "actions", "color", "footerNote", "showFooterNote", "portal", "className"];
|
|
19224
19329
|
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19225
19330
|
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19331
|
+
var STATUS_CONFIG = {
|
|
19332
|
+
success: {
|
|
19333
|
+
icon: CheckCircle2,
|
|
19334
|
+
iconClass: 'text-emerald-500 dark:text-emerald-400',
|
|
19335
|
+
progressClass: 'bg-emerald-500 dark:bg-emerald-400'
|
|
19336
|
+
},
|
|
19337
|
+
error: {
|
|
19338
|
+
icon: XCircle,
|
|
19339
|
+
iconClass: 'text-rose-500 dark:text-rose-400',
|
|
19340
|
+
progressClass: 'bg-rose-500 dark:bg-rose-400'
|
|
19341
|
+
},
|
|
19342
|
+
warning: {
|
|
19343
|
+
icon: AlertTriangle,
|
|
19344
|
+
iconClass: 'text-amber-500 dark:text-amber-400',
|
|
19345
|
+
progressClass: 'bg-amber-500 dark:bg-amber-400'
|
|
19346
|
+
},
|
|
19347
|
+
info: {
|
|
19348
|
+
icon: Info,
|
|
19349
|
+
iconClass: 'text-sky-500 dark:text-sky-400',
|
|
19350
|
+
progressClass: 'bg-sky-500 dark:bg-sky-400'
|
|
19351
|
+
},
|
|
19352
|
+
"default": {
|
|
19353
|
+
icon: Bell,
|
|
19354
|
+
iconClass: 'text-primary-500 dark:text-primary-400',
|
|
19355
|
+
progressClass: 'bg-primary-500 dark:bg-primary-400'
|
|
19356
|
+
}
|
|
19357
|
+
};
|
|
19358
|
+
var POSITION_CLASSES = {
|
|
19359
|
+
'top-right': 'top-4 right-4 items-end',
|
|
19360
|
+
'top-left': 'top-4 left-4 items-start',
|
|
19361
|
+
'bottom-right': 'bottom-4 right-4 items-end',
|
|
19362
|
+
'bottom-left': 'bottom-4 left-4 items-start',
|
|
19363
|
+
'top-center': 'top-4 left-1/2 transform -translate-x-1/2 items-center',
|
|
19364
|
+
'bottom-center': 'bottom-4 left-1/2 transform -translate-x-1/2 items-center'
|
|
19365
|
+
};
|
|
19366
|
+
var STANDALONE_POSITION_CLASSES = {
|
|
19367
|
+
'top-right': 'top-4 right-4',
|
|
19368
|
+
'top-left': 'top-4 left-4',
|
|
19369
|
+
'bottom-right': 'bottom-4 right-4',
|
|
19370
|
+
'bottom-left': 'bottom-4 left-4',
|
|
19371
|
+
'top-center': 'top-4 left-1/2 transform -translate-x-1/2',
|
|
19372
|
+
'bottom-center': 'bottom-4 left-1/2 transform -translate-x-1/2'
|
|
19373
|
+
};
|
|
19226
19374
|
var Toast = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
19227
19375
|
var id = _ref.id,
|
|
19228
19376
|
title = _ref.title,
|
|
19229
19377
|
message = _ref.message,
|
|
19378
|
+
description = _ref.description,
|
|
19230
19379
|
_ref$type = _ref.type,
|
|
19231
19380
|
type = _ref$type === void 0 ? 'info' : _ref$type,
|
|
19232
19381
|
_ref$duration = _ref.duration,
|
|
@@ -19234,153 +19383,277 @@ var Toast = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
19234
19383
|
onClose = _ref.onClose,
|
|
19235
19384
|
_ref$position = _ref.position,
|
|
19236
19385
|
position = _ref$position === void 0 ? 'top-right' : _ref$position,
|
|
19386
|
+
statusIcon = _ref.statusIcon,
|
|
19387
|
+
_ref$actions = _ref.actions,
|
|
19388
|
+
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
19389
|
+
color = _ref.color,
|
|
19390
|
+
footerNote = _ref.footerNote,
|
|
19391
|
+
_ref$showFooterNote = _ref.showFooterNote,
|
|
19392
|
+
showFooterNote = _ref$showFooterNote === void 0 ? false : _ref$showFooterNote,
|
|
19393
|
+
_ref$portal = _ref.portal,
|
|
19394
|
+
portal = _ref$portal === void 0 ? true : _ref$portal,
|
|
19395
|
+
_ref$className = _ref.className,
|
|
19396
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
19237
19397
|
props = _objectWithoutProperties$1(_ref, _excluded$7);
|
|
19238
19398
|
var _useState = React.useState(true),
|
|
19239
19399
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19240
19400
|
isVisible = _useState2[0],
|
|
19241
19401
|
setIsVisible = _useState2[1];
|
|
19242
|
-
React.
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19246
|
-
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
|
|
19250
|
-
|
|
19251
|
-
|
|
19252
|
-
var
|
|
19253
|
-
|
|
19402
|
+
var _useState3 = React.useState(false),
|
|
19403
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19404
|
+
isLeaving = _useState4[0],
|
|
19405
|
+
setIsLeaving = _useState4[1];
|
|
19406
|
+
var _useState5 = React.useState(false),
|
|
19407
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
19408
|
+
isPaused = _useState6[0],
|
|
19409
|
+
setIsPaused = _useState6[1];
|
|
19410
|
+
var progressBarRef = React.useRef(null);
|
|
19411
|
+
var timerTextRef = React.useRef(null);
|
|
19412
|
+
var startTimeRef = React.useRef(null);
|
|
19413
|
+
var remainingRef = React.useRef(duration);
|
|
19414
|
+
var timerRef = React.useRef(null);
|
|
19415
|
+
var animFrameRef = React.useRef(null);
|
|
19416
|
+
var handleClose = React.useCallback(function () {
|
|
19417
|
+
if (isLeaving) return;
|
|
19418
|
+
setIsLeaving(true);
|
|
19254
19419
|
setTimeout(function () {
|
|
19420
|
+
setIsVisible(false);
|
|
19255
19421
|
onClose === null || onClose === void 0 || onClose(id);
|
|
19256
19422
|
}, 300);
|
|
19257
|
-
};
|
|
19258
|
-
var
|
|
19259
|
-
|
|
19260
|
-
|
|
19261
|
-
|
|
19262
|
-
|
|
19263
|
-
|
|
19264
|
-
|
|
19265
|
-
|
|
19266
|
-
|
|
19267
|
-
|
|
19268
|
-
|
|
19269
|
-
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19273
|
-
|
|
19274
|
-
|
|
19275
|
-
|
|
19276
|
-
|
|
19277
|
-
|
|
19278
|
-
|
|
19279
|
-
|
|
19423
|
+
}, [id, onClose, isLeaving]);
|
|
19424
|
+
var handleStopTimer = React.useCallback(function (e) {
|
|
19425
|
+
e === null || e === void 0 || e.stopPropagation();
|
|
19426
|
+
setIsPaused(true);
|
|
19427
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
19428
|
+
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
19429
|
+
}, []);
|
|
19430
|
+
// Direct DOM-based progress updates to prevent 60 FPS React re-renders and glitches
|
|
19431
|
+
React.useEffect(function () {
|
|
19432
|
+
if (duration <= 0) return;
|
|
19433
|
+
if (isPaused) {
|
|
19434
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
19435
|
+
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
19436
|
+
return;
|
|
19437
|
+
}
|
|
19438
|
+
startTimeRef.current = Date.now();
|
|
19439
|
+
timerRef.current = setTimeout(function () {
|
|
19440
|
+
handleClose();
|
|
19441
|
+
}, remainingRef.current);
|
|
19442
|
+
var _updateProgress = function updateProgress() {
|
|
19443
|
+
var elapsed = startTimeRef.current ? Date.now() - startTimeRef.current : 0;
|
|
19444
|
+
var currentRemaining = Math.max(0, remainingRef.current - elapsed);
|
|
19445
|
+
var pct = currentRemaining / duration * 100;
|
|
19446
|
+
if (progressBarRef.current) {
|
|
19447
|
+
progressBarRef.current.style.width = "".concat(pct, "%");
|
|
19448
|
+
}
|
|
19449
|
+
if (timerTextRef.current) {
|
|
19450
|
+
var secs = Math.ceil(currentRemaining / 1000);
|
|
19451
|
+
timerTextRef.current.textContent = "This message will close in ".concat(secs, " seconds. ");
|
|
19452
|
+
}
|
|
19453
|
+
if (currentRemaining > 0 && !isPaused) {
|
|
19454
|
+
animFrameRef.current = requestAnimationFrame(_updateProgress);
|
|
19455
|
+
}
|
|
19456
|
+
};
|
|
19457
|
+
animFrameRef.current = requestAnimationFrame(_updateProgress);
|
|
19458
|
+
return function () {
|
|
19459
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
19460
|
+
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
19461
|
+
if (!isPaused && startTimeRef.current) {
|
|
19462
|
+
var elapsed = Date.now() - startTimeRef.current;
|
|
19463
|
+
remainingRef.current = Math.max(0, remainingRef.current - elapsed);
|
|
19464
|
+
}
|
|
19465
|
+
};
|
|
19466
|
+
}, [duration, isPaused, handleClose]);
|
|
19280
19467
|
if (!isVisible) return null;
|
|
19281
|
-
|
|
19468
|
+
var statusStyle = STATUS_CONFIG[type] || STATUS_CONFIG.info || STATUS_CONFIG["default"];
|
|
19469
|
+
var StatusIconComponent = statusStyle.icon;
|
|
19470
|
+
var bodyText = description || message;
|
|
19471
|
+
var toastContent = jsxRuntime.jsxs("div", _objectSpread$b(_objectSpread$b({
|
|
19282
19472
|
ref: ref,
|
|
19283
|
-
|
|
19473
|
+
onMouseEnter: function onMouseEnter() {
|
|
19474
|
+
return setIsPaused(true);
|
|
19475
|
+
},
|
|
19476
|
+
onMouseLeave: function onMouseLeave() {
|
|
19477
|
+
return setIsPaused(false);
|
|
19478
|
+
},
|
|
19479
|
+
className: cn$1('relative overflow-hidden rounded-xl border border-slate-200/90 bg-white/95 shadow-xl backdrop-blur-md transition-all duration-300', 'dark:border-slate-800/80 dark:bg-[#18181b] dark:text-slate-100 dark:shadow-2xl', 'max-w-md w-full', isLeaving ? 'opacity-0 scale-95 translate-y-1' : 'animate-slide-up opacity-100 scale-100', portal ? ['fixed z-50', STANDALONE_POSITION_CLASSES[position] || STANDALONE_POSITION_CLASSES['top-right']] : '', className)
|
|
19284
19480
|
}, props), {}, {
|
|
19285
|
-
children: jsxRuntime.
|
|
19286
|
-
className: "
|
|
19287
|
-
children:
|
|
19288
|
-
className: "flex-
|
|
19289
|
-
children:
|
|
19290
|
-
|
|
19291
|
-
|
|
19292
|
-
|
|
19293
|
-
|
|
19294
|
-
|
|
19295
|
-
|
|
19296
|
-
|
|
19297
|
-
|
|
19481
|
+
children: [jsxRuntime.jsx("div", {
|
|
19482
|
+
className: "p-4",
|
|
19483
|
+
children: jsxRuntime.jsxs("div", {
|
|
19484
|
+
className: "flex items-start gap-3 justify-between",
|
|
19485
|
+
children: [jsxRuntime.jsx("span", {
|
|
19486
|
+
className: "flex-shrink-0 mt-0.5",
|
|
19487
|
+
children: statusIcon ? statusIcon : jsxRuntime.jsx(StatusIconComponent, {
|
|
19488
|
+
className: cn$1('h-5 w-5', statusStyle.iconClass)
|
|
19489
|
+
})
|
|
19490
|
+
}), jsxRuntime.jsxs("div", {
|
|
19491
|
+
className: "flex-1 min-w-0 pr-2",
|
|
19492
|
+
children: [title && jsxRuntime.jsx("h4", {
|
|
19493
|
+
className: "text-sm font-semibold text-slate-900 dark:text-slate-100 leading-snug",
|
|
19494
|
+
children: title
|
|
19495
|
+
}), bodyText && jsxRuntime.jsx("p", {
|
|
19496
|
+
className: "mt-1 text-xs text-slate-600 dark:text-slate-400 leading-relaxed whitespace-pre-line",
|
|
19497
|
+
children: bodyText
|
|
19498
|
+
}), actions && actions.length > 0 && jsxRuntime.jsx("div", {
|
|
19499
|
+
className: "mt-3 flex items-center gap-2 flex-wrap",
|
|
19500
|
+
children: actions.map(function (actItem, idx) {
|
|
19501
|
+
return jsxRuntime.jsx("button", {
|
|
19502
|
+
type: "button",
|
|
19503
|
+
onClick: function onClick(e) {
|
|
19504
|
+
var _actItem$onClick;
|
|
19505
|
+
(_actItem$onClick = actItem.onClick) === null || _actItem$onClick === void 0 || _actItem$onClick.call(actItem, e);
|
|
19506
|
+
if (actItem.dismiss !== false) {
|
|
19507
|
+
handleClose();
|
|
19508
|
+
}
|
|
19509
|
+
},
|
|
19510
|
+
className: cn$1('px-3 py-1.5 text-xs font-medium rounded-lg transition-colors border shadow-xs', actItem.variant === 'primary' ? 'bg-primary-600 hover:bg-primary-700 text-white border-primary-600' : 'bg-slate-100 dark:bg-zinc-800/80 text-slate-700 dark:text-zinc-200 border-slate-200 dark:border-zinc-700 hover:bg-slate-200 dark:hover:bg-zinc-700', actItem.className),
|
|
19511
|
+
children: actItem.label
|
|
19512
|
+
}, actItem.id || actItem.label || "act-".concat(idx));
|
|
19513
|
+
})
|
|
19514
|
+
})]
|
|
19515
|
+
}), jsxRuntime.jsx("button", {
|
|
19516
|
+
type: "button",
|
|
19517
|
+
"aria-label": "Close notification",
|
|
19518
|
+
className: "flex-shrink-0 rounded-lg p-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 hover:bg-slate-100 dark:hover:bg-zinc-800/70 transition-colors outline-none focus:ring-2 focus:ring-primary-500",
|
|
19519
|
+
onClick: handleClose,
|
|
19520
|
+
children: jsxRuntime.jsx(X, {
|
|
19521
|
+
className: "h-4 w-4"
|
|
19522
|
+
})
|
|
19298
19523
|
})]
|
|
19299
|
-
})
|
|
19300
|
-
|
|
19301
|
-
|
|
19302
|
-
|
|
19303
|
-
children: jsxRuntime.
|
|
19304
|
-
|
|
19524
|
+
})
|
|
19525
|
+
}), (showFooterNote || footerNote) && duration > 0 && jsxRuntime.jsx("div", {
|
|
19526
|
+
className: "px-4 py-2 bg-slate-50 dark:bg-zinc-950/40 border-t border-slate-100 dark:border-zinc-800/50 text-[11px] text-slate-500 dark:text-zinc-400 flex items-center justify-between",
|
|
19527
|
+
children: jsxRuntime.jsx("span", {
|
|
19528
|
+
children: footerNote ? footerNote : jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
19529
|
+
children: [jsxRuntime.jsxs("span", {
|
|
19530
|
+
ref: timerTextRef,
|
|
19531
|
+
children: ["This message will close in ", Math.ceil(duration / 1000), " seconds.", ' ']
|
|
19532
|
+
}), jsxRuntime.jsx("button", {
|
|
19533
|
+
type: "button",
|
|
19534
|
+
onClick: handleStopTimer,
|
|
19535
|
+
className: "font-medium text-slate-700 dark:text-zinc-200 hover:underline inline",
|
|
19536
|
+
children: "Click to stop."
|
|
19537
|
+
})]
|
|
19305
19538
|
})
|
|
19306
|
-
})
|
|
19307
|
-
})
|
|
19308
|
-
|
|
19539
|
+
})
|
|
19540
|
+
}), duration > 0 && jsxRuntime.jsx("div", {
|
|
19541
|
+
className: "absolute bottom-0 left-0 right-0 h-0.5 bg-slate-100 dark:bg-zinc-800/80 overflow-hidden rounded-b-xl",
|
|
19542
|
+
children: jsxRuntime.jsx("div", {
|
|
19543
|
+
ref: progressBarRef,
|
|
19544
|
+
className: cn$1('h-full transition-all ease-linear', color ? '' : statusStyle.progressClass),
|
|
19545
|
+
style: {
|
|
19546
|
+
width: '100%',
|
|
19547
|
+
backgroundColor: color || undefined
|
|
19548
|
+
}
|
|
19549
|
+
})
|
|
19550
|
+
})]
|
|
19551
|
+
}));
|
|
19552
|
+
if (portal) {
|
|
19553
|
+
return /*#__PURE__*/ReactDOM.createPortal(toastContent, document.body);
|
|
19554
|
+
}
|
|
19555
|
+
return toastContent;
|
|
19309
19556
|
});
|
|
19310
19557
|
Toast.displayName = 'Toast';
|
|
19311
|
-
// Toast Container Component
|
|
19558
|
+
// Toast Container Component for vertical stacking & scrollable overflow without visible scrollbars
|
|
19312
19559
|
var ToastContainer = function ToastContainer(_ref2) {
|
|
19313
19560
|
var _ref2$toasts = _ref2.toasts,
|
|
19314
19561
|
toasts = _ref2$toasts === void 0 ? [] : _ref2$toasts,
|
|
19315
19562
|
_ref2$position = _ref2.position,
|
|
19316
19563
|
position = _ref2$position === void 0 ? 'top-right' : _ref2$position,
|
|
19317
|
-
onRemove = _ref2.onRemove
|
|
19318
|
-
|
|
19319
|
-
className
|
|
19320
|
-
|
|
19321
|
-
|
|
19322
|
-
|
|
19323
|
-
|
|
19324
|
-
|
|
19325
|
-
|
|
19564
|
+
onRemove = _ref2.onRemove,
|
|
19565
|
+
_ref2$className = _ref2.className,
|
|
19566
|
+
className = _ref2$className === void 0 ? '' : _ref2$className;
|
|
19567
|
+
if (!toasts || toasts.length === 0) {
|
|
19568
|
+
return null;
|
|
19569
|
+
}
|
|
19570
|
+
var posClass = POSITION_CLASSES[position] || POSITION_CLASSES['top-right'];
|
|
19571
|
+
return /*#__PURE__*/ReactDOM.createPortal(jsxRuntime.jsx("div", {
|
|
19572
|
+
className: cn$1('fixed z-50 flex flex-col gap-3 max-h-[calc(100vh-2rem)] overflow-y-auto overflow-x-hidden p-2 pointer-events-none', '[scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden', posClass, className),
|
|
19573
|
+
children: toasts.map(function (t) {
|
|
19574
|
+
return jsxRuntime.jsx("div", {
|
|
19575
|
+
className: "pointer-events-auto w-full max-w-md",
|
|
19576
|
+
children: jsxRuntime.jsx(Toast, _objectSpread$b(_objectSpread$b({}, t), {}, {
|
|
19577
|
+
portal: false,
|
|
19578
|
+
position: position,
|
|
19579
|
+
onClose: onRemove
|
|
19580
|
+
}))
|
|
19581
|
+
}, t.id);
|
|
19326
19582
|
})
|
|
19327
|
-
});
|
|
19583
|
+
}), document.body);
|
|
19328
19584
|
};
|
|
19329
19585
|
// Toast Hook
|
|
19330
19586
|
var useToast = function useToast() {
|
|
19331
|
-
var
|
|
19332
|
-
|
|
19333
|
-
toasts =
|
|
19334
|
-
setToasts =
|
|
19335
|
-
var addToast = function
|
|
19336
|
-
var id = Date.now().toString();
|
|
19587
|
+
var _useState7 = React.useState([]),
|
|
19588
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
19589
|
+
toasts = _useState8[0],
|
|
19590
|
+
setToasts = _useState8[1];
|
|
19591
|
+
var addToast = React.useCallback(function (toastOptions) {
|
|
19592
|
+
var id = toastOptions.id || "".concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 7));
|
|
19593
|
+
var newToast = _objectSpread$b(_objectSpread$b({}, toastOptions), {}, {
|
|
19594
|
+
id: id
|
|
19595
|
+
});
|
|
19337
19596
|
setToasts(function (prev) {
|
|
19338
|
-
return [].concat(_toConsumableArray$1(prev), [
|
|
19339
|
-
id: id
|
|
19340
|
-
})]);
|
|
19597
|
+
return [].concat(_toConsumableArray$1(prev), [newToast]);
|
|
19341
19598
|
});
|
|
19342
|
-
|
|
19343
|
-
|
|
19599
|
+
return id;
|
|
19600
|
+
}, []);
|
|
19601
|
+
var removeToast = React.useCallback(function (id) {
|
|
19344
19602
|
setToasts(function (prev) {
|
|
19345
|
-
return prev.filter(function (
|
|
19346
|
-
return
|
|
19603
|
+
return prev.filter(function (t) {
|
|
19604
|
+
return t.id !== id;
|
|
19347
19605
|
});
|
|
19348
19606
|
});
|
|
19607
|
+
}, []);
|
|
19608
|
+
var clearToasts = React.useCallback(function () {
|
|
19609
|
+
setToasts([]);
|
|
19610
|
+
}, []);
|
|
19611
|
+
var toast = React.useCallback(function (options) {
|
|
19612
|
+
return addToast(typeof options === 'string' ? {
|
|
19613
|
+
message: options
|
|
19614
|
+
} : options);
|
|
19615
|
+
}, [addToast]);
|
|
19616
|
+
toast.success = function (title, message, options) {
|
|
19617
|
+
return addToast(_objectSpread$b({
|
|
19618
|
+
title: title,
|
|
19619
|
+
message: message,
|
|
19620
|
+
type: 'success'
|
|
19621
|
+
}, _typeof$4(options) === 'object' ? options : {}));
|
|
19349
19622
|
};
|
|
19350
|
-
|
|
19351
|
-
|
|
19352
|
-
|
|
19353
|
-
|
|
19354
|
-
|
|
19355
|
-
|
|
19356
|
-
|
|
19357
|
-
|
|
19358
|
-
|
|
19359
|
-
|
|
19360
|
-
|
|
19361
|
-
|
|
19362
|
-
|
|
19363
|
-
|
|
19364
|
-
|
|
19365
|
-
|
|
19366
|
-
|
|
19367
|
-
|
|
19368
|
-
|
|
19369
|
-
|
|
19370
|
-
|
|
19371
|
-
|
|
19372
|
-
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
}, options));
|
|
19378
|
-
}
|
|
19623
|
+
toast.error = function (title, message, options) {
|
|
19624
|
+
return addToast(_objectSpread$b({
|
|
19625
|
+
title: title,
|
|
19626
|
+
message: message,
|
|
19627
|
+
type: 'error'
|
|
19628
|
+
}, _typeof$4(options) === 'object' ? options : {}));
|
|
19629
|
+
};
|
|
19630
|
+
toast.warning = function (title, message, options) {
|
|
19631
|
+
return addToast(_objectSpread$b({
|
|
19632
|
+
title: title,
|
|
19633
|
+
message: message,
|
|
19634
|
+
type: 'warning'
|
|
19635
|
+
}, _typeof$4(options) === 'object' ? options : {}));
|
|
19636
|
+
};
|
|
19637
|
+
toast.info = function (title, message, options) {
|
|
19638
|
+
return addToast(_objectSpread$b({
|
|
19639
|
+
title: title,
|
|
19640
|
+
message: message,
|
|
19641
|
+
type: 'info'
|
|
19642
|
+
}, _typeof$4(options) === 'object' ? options : {}));
|
|
19643
|
+
};
|
|
19644
|
+
toast["default"] = function (title, message, options) {
|
|
19645
|
+
return addToast(_objectSpread$b({
|
|
19646
|
+
title: title,
|
|
19647
|
+
message: message,
|
|
19648
|
+
type: 'default'
|
|
19649
|
+
}, _typeof$4(options) === 'object' ? options : {}));
|
|
19379
19650
|
};
|
|
19380
19651
|
return {
|
|
19381
19652
|
toast: toast,
|
|
19382
19653
|
toasts: toasts,
|
|
19383
|
-
removeToast: removeToast
|
|
19654
|
+
removeToast: removeToast,
|
|
19655
|
+
clearToasts: clearToasts,
|
|
19656
|
+
addToast: addToast
|
|
19384
19657
|
};
|
|
19385
19658
|
};
|
|
19386
19659
|
|