@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/dist/index.esm.js CHANGED
@@ -227,6 +227,22 @@ const Calendar = createLucideIcon$1("Calendar", [
227
227
  */
228
228
 
229
229
 
230
+ const CheckCircle2 = createLucideIcon$1("CheckCircle2", [
231
+ [
232
+ "path",
233
+ {
234
+ d: "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z",
235
+ key: "14v8dr"
236
+ }
237
+ ],
238
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
239
+ ]);
240
+
241
+ /**
242
+ * lucide-react v0.0.1 - ISC
243
+ */
244
+
245
+
230
246
  const CheckCircle = createLucideIcon$1("CheckCircle", [
231
247
  ["path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14", key: "g774vq" }],
232
248
  ["polyline", { points: "22 4 12 14.01 9 11.01", key: "6xbx8j" }]
@@ -637,6 +653,17 @@ const User = createLucideIcon$1("User", [
637
653
  */
638
654
 
639
655
 
656
+ const XCircle = createLucideIcon$1("XCircle", [
657
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
658
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
659
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
660
+ ]);
661
+
662
+ /**
663
+ * lucide-react v0.0.1 - ISC
664
+ */
665
+
666
+
640
667
  const X = createLucideIcon$1("X", [
641
668
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
642
669
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
@@ -5682,7 +5709,7 @@ function FieldInput(_ref) {
5682
5709
  });
5683
5710
  }
5684
5711
 
5685
- 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"],
5712
+ 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"],
5686
5713
  _excluded2$4 = ["_key", "_isNew"];
5687
5714
  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; }
5688
5715
  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; }
@@ -5695,7 +5722,7 @@ var DEFAULT_THEME = {
5695
5722
  menuBg: "bg-white",
5696
5723
  menuItemHover: "hover:bg-gray-50"
5697
5724
  };
5698
- var Table = function Table(_ref) {
5725
+ var Table = /*#__PURE__*/forwardRef(function Table(_ref, ref) {
5699
5726
  var _validationErrors$;
5700
5727
  var _ref$data = _ref.data,
5701
5728
  initialData = _ref$data === void 0 ? DEFAULT_DATA : _ref$data,
@@ -5765,6 +5792,14 @@ var Table = function Table(_ref) {
5765
5792
  onEdit = _ref.onEdit,
5766
5793
  onRowAdd = _ref.onRowAdd,
5767
5794
  onRowDelete = _ref.onRowDelete,
5795
+ _ref$editKeyBinding = _ref.editKeyBinding,
5796
+ editKeyBinding = _ref$editKeyBinding === void 0 ? "e" : _ref$editKeyBinding,
5797
+ _ref$newRowPosition = _ref.newRowPosition,
5798
+ newRowPosition = _ref$newRowPosition === void 0 ? "bottom" : _ref$newRowPosition,
5799
+ addRowRef = _ref.addRowRef,
5800
+ onInitAddRow = _ref.onInitAddRow,
5801
+ renderAddRowButton = _ref.renderAddRowButton,
5802
+ renderExternalAddRow = _ref.renderExternalAddRow,
5768
5803
  props = _objectWithoutProperties$1(_ref, _excluded$x);
5769
5804
  theme = _objectSpread$B(_objectSpread$B({}, DEFAULT_THEME), theme);
5770
5805
  // State
@@ -6042,9 +6077,10 @@ var Table = function Table(_ref) {
6042
6077
  return _objectSpread$B(_objectSpread$B({}, prev), {}, _defineProperty$4({}, rowKey, nextRowEdits));
6043
6078
  });
6044
6079
  }, [newRows, tableData, onEdit]);
6045
- var handleAddRow = useCallback(function () {
6080
+ var _handleAddRow = useCallback(function (positionOverride) {
6046
6081
  var _columnsState$find, _columnsState$;
6047
- var newKey = "new-".concat(Date.now());
6082
+ var targetPos = typeof positionOverride === "string" && (positionOverride === "top" || positionOverride === "bottom") ? positionOverride : newRowPosition || "bottom";
6083
+ var newKey = "new-".concat(Date.now(), "-").concat(Math.random().toString(36).substring(2, 6));
6048
6084
  var newRowObj = {
6049
6085
  _key: newKey,
6050
6086
  _isNew: true
@@ -6054,23 +6090,51 @@ var Table = function Table(_ref) {
6054
6090
  newRowObj[col.key] = (_col$defaultValue = col.defaultValue) !== null && _col$defaultValue !== void 0 ? _col$defaultValue : "";
6055
6091
  });
6056
6092
  setNewRows(function (prev) {
6093
+ if (targetPos === "top") {
6094
+ return [newRowObj].concat(_toConsumableArray$1(prev));
6095
+ }
6057
6096
  return [].concat(_toConsumableArray$1(prev), [newRowObj]);
6058
6097
  });
6059
6098
  var firstColKey = ((_columnsState$find = columnsState.find(function (c) {
6060
6099
  return c.isVisible !== false;
6061
6100
  })) === null || _columnsState$find === void 0 ? void 0 : _columnsState$find.key) || ((_columnsState$ = columnsState[0]) === null || _columnsState$ === void 0 ? void 0 : _columnsState$.key);
6101
+ var initialRowIndex = targetPos === "top" ? 0 : tableData.length + newRows.length;
6062
6102
  setActiveCell({
6063
6103
  rowKey: newKey,
6064
6104
  colKey: firstColKey,
6065
- rowIndex: tableData.length + newRows.length
6105
+ rowIndex: initialRowIndex
6066
6106
  });
6067
6107
  setEditingCell({
6068
6108
  rowKey: newKey,
6069
6109
  colKey: firstColKey,
6070
- rowIndex: tableData.length + newRows.length
6110
+ rowIndex: initialRowIndex
6111
+ });
6112
+ onRowAdd === null || onRowAdd === void 0 || onRowAdd(newRowObj, targetPos);
6113
+ }, [columnsState, tableData.length, newRows.length, onRowAdd, newRowPosition]);
6114
+ useImperativeHandle(ref, function () {
6115
+ return {
6116
+ addRow: function addRow(pos) {
6117
+ return _handleAddRow(pos);
6118
+ },
6119
+ addNewRow: function addNewRow(pos) {
6120
+ return _handleAddRow(pos);
6121
+ },
6122
+ handleAddRow: function handleAddRow(pos) {
6123
+ return _handleAddRow(pos);
6124
+ },
6125
+ tableContainerRef: tableContainerRef.current
6126
+ };
6127
+ }, [_handleAddRow]);
6128
+ useEffect(function () {
6129
+ if (addRowRef) {
6130
+ addRowRef.current = function (pos) {
6131
+ return _handleAddRow(pos);
6132
+ };
6133
+ }
6134
+ onInitAddRow === null || onInitAddRow === void 0 || onInitAddRow(function (pos) {
6135
+ return _handleAddRow(pos);
6071
6136
  });
6072
- onRowAdd === null || onRowAdd === void 0 || onRowAdd(newRowObj);
6073
- }, [columnsState, tableData.length, newRows.length, onRowAdd]);
6137
+ }, [addRowRef, onInitAddRow, _handleAddRow]);
6074
6138
  var handleDeleteNewRow = useCallback(function (rowKey) {
6075
6139
  setNewRows(function (prev) {
6076
6140
  return prev.filter(function (r) {
@@ -6334,6 +6398,15 @@ var Table = function Table(_ref) {
6334
6398
  };
6335
6399
  });
6336
6400
  }, [limitOptions]);
6401
+ var isEditKey = useCallback(function (key, e) {
6402
+ if (typeof editKeyBinding === "function") {
6403
+ return editKeyBinding(e);
6404
+ }
6405
+ if (typeof editKeyBinding === "string" && editKeyBinding.trim() !== "") {
6406
+ return key.toLowerCase() === editKeyBinding.toLowerCase();
6407
+ }
6408
+ return key.toLowerCase() === "e" || key === "Insert";
6409
+ }, [editKeyBinding]);
6337
6410
  var handleTableKeyDown = useCallback(function (e) {
6338
6411
  if (!interactive) return;
6339
6412
  var key = e.key,
@@ -6346,24 +6419,33 @@ var Table = function Table(_ref) {
6346
6419
  }
6347
6420
  return;
6348
6421
  }
6349
- // Enter: Save changes only when there are modified changes (isDirty)
6350
- if (key === "Enter") {
6422
+ // Enter: Save changes when there are modified changes (isDirty)
6423
+ if (key === "Enter" && isDirty) {
6351
6424
  var _e$target;
6352
6425
  if (((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName) === "TEXTAREA" && shiftKey) {
6353
6426
  return;
6354
6427
  }
6355
- if (isDirty) {
6356
- e.preventDefault();
6357
- setEditingCell(null);
6358
- if (isValid && !isSaving) {
6359
- handleSave();
6360
- }
6428
+ e.preventDefault();
6429
+ setEditingCell(null);
6430
+ if (isValid && !isSaving) {
6431
+ handleSave();
6361
6432
  }
6362
6433
  return;
6363
6434
  }
6435
+ // Standard Edit Key ('e' or custom editKeyBinding) when focused on active cell and not editing: enter edit mode
6436
+ if (isEditKey(key, e) && activeCell && !editingCell) {
6437
+ var col = visibleColumns.find(function (c) {
6438
+ return c.key === activeCell.colKey;
6439
+ });
6440
+ if (col && col.editable !== false) {
6441
+ e.preventDefault();
6442
+ setEditingCell(activeCell);
6443
+ return;
6444
+ }
6445
+ }
6364
6446
  var currentCell = activeCell || editingCell;
6365
6447
  if (!currentCell) return;
6366
- var allRows = [].concat(_toConsumableArray$1(paginatedData), _toConsumableArray$1(newRows));
6448
+ var allRows = newRowPosition === "top" ? [].concat(_toConsumableArray$1(newRows), _toConsumableArray$1(paginatedData)) : [].concat(_toConsumableArray$1(paginatedData), _toConsumableArray$1(newRows));
6367
6449
  if (allRows.length === 0 || visibleColumns.length === 0) return;
6368
6450
  var rIdx = allRows.findIndex(function (r, idx) {
6369
6451
  var rKey = r._key || getRowKey(r, startIndex + idx);
@@ -6682,6 +6764,26 @@ var Table = function Table(_ref) {
6682
6764
  invalidCellSet: invalidCellSet,
6683
6765
  pendingEdits: pendingEdits
6684
6766
  };
6767
+ var renderAddRowClickableRow = useCallback(function () {
6768
+ return jsx("tr", {
6769
+ onClick: function onClick() {
6770
+ return _handleAddRow(newRowPosition);
6771
+ },
6772
+ 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",
6773
+ children: jsx("td", {
6774
+ colSpan: visibleCount,
6775
+ className: "px-6 py-3.5 text-left text-sm font-semibold text-primary-700 group-hover:text-primary-800",
6776
+ children: jsxs("div", {
6777
+ className: "flex items-center justify-start gap-2",
6778
+ children: [jsx(Plus, {
6779
+ className: "w-4 h-4 text-primary-600 group-hover:scale-110 transition-transform"
6780
+ }), jsx("span", {
6781
+ children: "Click here to add new record instantly...."
6782
+ })]
6783
+ })
6784
+ })
6785
+ });
6786
+ }, [_handleAddRow, newRowPosition, visibleCount]);
6685
6787
  return jsxs("div", {
6686
6788
  ref: tableContainerRef,
6687
6789
  tabIndex: interactive ? 0 : undefined,
@@ -6726,7 +6828,14 @@ var Table = function Table(_ref) {
6726
6828
  })]
6727
6829
  }), jsxs("div", {
6728
6830
  className: "flex flex-col sm:flex-row items-start sm:items-center gap-3 w-full md:w-auto",
6729
- children: [interactive && isDirty && jsxs("div", {
6831
+ children: [interactive && (renderAddRowButton || renderExternalAddRow) && jsx("div", {
6832
+ className: "flex items-center gap-2",
6833
+ children: typeof (renderAddRowButton || renderExternalAddRow) === "function" ? (renderAddRowButton || renderExternalAddRow)({
6834
+ addRow: _handleAddRow,
6835
+ handleAddRow: _handleAddRow,
6836
+ newRowPosition: newRowPosition
6837
+ }) : renderAddRowButton || renderExternalAddRow
6838
+ }), interactive && isDirty && jsxs("div", {
6730
6839
  className: "flex items-center gap-2 flex-wrap",
6731
6840
  children: [jsxs("button", {
6732
6841
  type: "button",
@@ -6922,9 +7031,9 @@ var Table = function Table(_ref) {
6922
7031
  className: "pb-4"
6923
7032
  })]
6924
7033
  })]
6925
- }), jsxs("tbody", {
7034
+ }), jsx("tbody", {
6926
7035
  className: "divide-y divide-gray-200",
6927
- children: [loading ? jsx("tr", {
7036
+ children: loading ? jsx("tr", {
6928
7037
  children: jsx("td", {
6929
7038
  colSpan: visibleCount,
6930
7039
  className: "px-6 py-8 text-center",
@@ -6938,32 +7047,43 @@ var Table = function Table(_ref) {
6938
7047
  })]
6939
7048
  })
6940
7049
  })
6941
- }) : paginatedData.length === 0 && newRows.length === 0 ? jsx("tr", {
6942
- children: jsx("td", {
6943
- colSpan: visibleCount,
6944
- className: "px-6 py-8 text-center",
6945
- children: jsxs("div", {
6946
- className: "flex flex-col items-center gap-2",
6947
- children: [jsx("div", {
6948
- className: "text-primary-400",
6949
- children: jsx(List, {
6950
- className: "h-8 w-8"
6951
- })
6952
- }), jsx("span", {
6953
- className: "text-sm text-primary-500",
6954
- children: "No results found."
6955
- })]
7050
+ }) : paginatedData.length === 0 && newRows.length === 0 ? jsxs(Fragment, {
7051
+ children: [interactive && newRowPosition === "top" && renderAddRowClickableRow(), jsx("tr", {
7052
+ children: jsx("td", {
7053
+ colSpan: visibleCount,
7054
+ className: "px-6 py-8 text-center",
7055
+ children: jsxs("div", {
7056
+ className: "flex flex-col items-center gap-2",
7057
+ children: [jsx("div", {
7058
+ className: "text-primary-400",
7059
+ children: jsx(List, {
7060
+ className: "h-8 w-8"
7061
+ })
7062
+ }), jsx("span", {
7063
+ className: "text-sm text-primary-500",
7064
+ children: "No results found."
7065
+ })]
7066
+ })
6956
7067
  })
6957
- })
7068
+ }), interactive && newRowPosition !== "top" && renderAddRowClickableRow()]
6958
7069
  }) : jsxs(Fragment, {
6959
- children: [paginatedData.map(function (row, rowIndexInPage) {
7070
+ children: [interactive && newRowPosition === "top" && renderAddRowClickableRow(), interactive && newRowPosition === "top" && newRows.map(function (newRow, newIdx) {
7071
+ return jsx(TableRow, _objectSpread$B({
7072
+ row: newRow,
7073
+ rowIndexInPage: newIdx,
7074
+ startIndex: 0,
7075
+ visibleCount: visibleCount,
7076
+ isNewRow: true,
7077
+ onDeleteNewRow: handleDeleteNewRow
7078
+ }, rowSharedProps), newRow._key);
7079
+ }), paginatedData.map(function (row, rowIndexInPage) {
6960
7080
  return jsx(TableRow, _objectSpread$B({
6961
7081
  row: row,
6962
7082
  rowIndexInPage: rowIndexInPage,
6963
7083
  startIndex: startIndex,
6964
7084
  visibleCount: visibleCount
6965
7085
  }, rowSharedProps), getRowKey(row, startIndex + rowIndexInPage));
6966
- }), interactive && newRows.map(function (newRow, newIdx) {
7086
+ }), interactive && newRowPosition !== "top" && newRows.map(function (newRow, newIdx) {
6967
7087
  return jsx(TableRow, _objectSpread$B({
6968
7088
  row: newRow,
6969
7089
  rowIndexInPage: paginatedData.length + newIdx,
@@ -6972,23 +7092,8 @@ var Table = function Table(_ref) {
6972
7092
  isNewRow: true,
6973
7093
  onDeleteNewRow: handleDeleteNewRow
6974
7094
  }, rowSharedProps), newRow._key);
6975
- })]
6976
- }), interactive && jsx("tr", {
6977
- onClick: handleAddRow,
6978
- 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",
6979
- children: jsx("td", {
6980
- colSpan: visibleCount,
6981
- className: "px-6 py-3.5 text-left text-sm font-semibold text-primary-700 group-hover:text-primary-800",
6982
- children: jsxs("div", {
6983
- className: "flex items-center justify-start gap-2",
6984
- children: [jsx(Plus, {
6985
- className: "w-4 h-4 text-primary-600 group-hover:scale-110 transition-transform"
6986
- }), jsx("span", {
6987
- children: "Click here to add new record instantly...."
6988
- })]
6989
- })
6990
- })
6991
- })]
7095
+ }), interactive && newRowPosition !== "top" && renderAddRowClickableRow()]
7096
+ })
6992
7097
  })]
6993
7098
  }))
6994
7099
  }), isMobileView && jsx("div", {
@@ -7036,7 +7141,7 @@ var Table = function Table(_ref) {
7036
7141
  theme: safeTheme
7037
7142
  })]
7038
7143
  });
7039
- };
7144
+ });
7040
7145
 
7041
7146
  var isCheckBoxInput = (element) => element.type === 'checkbox';
7042
7147
 
@@ -13657,7 +13762,7 @@ var Accordion = /*#__PURE__*/forwardRef(function Accordion(_ref, ref) {
13657
13762
  });
13658
13763
  Accordion.displayName = "Accordion";
13659
13764
 
13660
- var _excluded$s = ["id", "name", "label", "checked", "defaultChecked", "onChange", "disabled", "required", "className", "size", "labelPosition", "value", "ariaLabel", "variant", "indeterminate", "borderColor", "color", "iconClass", "checkedClass"];
13765
+ var _excluded$s = ["id", "name", "label", "checked", "defaultChecked", "onChange", "disabled", "required", "className", "size", "labelPosition", "value", "ariaLabel", "variant", "indeterminate", "borderColor", "color", "iconClass", "checkedClass", "wrapperProps"];
13661
13766
  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; }
13662
13767
  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; }
13663
13768
  var SIZE_CLASSES = {
@@ -13724,7 +13829,6 @@ var COLOR_PRESETS = {
13724
13829
  }
13725
13830
  };
13726
13831
  var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
13727
- var _props$wrapperProps;
13728
13832
  var id = _ref.id,
13729
13833
  name = _ref.name,
13730
13834
  label = _ref.label,
@@ -13752,6 +13856,7 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
13752
13856
  color = _ref$color === void 0 ? "primary" : _ref$color,
13753
13857
  iconClass = _ref.iconClass,
13754
13858
  checkedClass = _ref.checkedClass,
13859
+ wrapperProps = _ref.wrapperProps,
13755
13860
  props = _objectWithoutProperties$1(_ref, _excluded$s);
13756
13861
  var autoId = useId();
13757
13862
  var inputId = id || "".concat(autoId, "-checkbox");
@@ -13792,7 +13897,7 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
13792
13897
  } : {};
13793
13898
  return jsxs("div", _objectSpread$w(_objectSpread$w({
13794
13899
  className: wrapperCls
13795
- }, (_props$wrapperProps = props === null || props === void 0 ? void 0 : props.wrapperProps) !== null && _props$wrapperProps !== void 0 ? _props$wrapperProps : {}), {}, {
13900
+ }, wrapperProps !== null && wrapperProps !== void 0 ? wrapperProps : {}), {}, {
13796
13901
  children: [label && labelPosition === "left" && jsx("label", {
13797
13902
  htmlFor: inputId,
13798
13903
  className: "".concat(sizeClass.label, " select-none mr-2"),
@@ -13811,7 +13916,6 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
13811
13916
  className: "peer absolute inset-0 m-0 p-0 opacity-0 z-10",
13812
13917
  // ensure we set checked only from the boolean (avoid undefined)
13813
13918
  checked: Boolean(currentChecked),
13814
- defaultChecked: defaultChecked,
13815
13919
  onChange: handleChange,
13816
13920
  disabled: disabled,
13817
13921
  required: required,
@@ -13838,6 +13942,7 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
13838
13942
  })]
13839
13943
  }));
13840
13944
  });
13945
+ Checkbox.displayName = "Checkbox";
13841
13946
 
13842
13947
  var _excluded$r = ["value", "defaultValue", "onChange", "swatches", "showAlpha", "size", "disabled", "className", "label", "id"];
13843
13948
  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; }
@@ -19200,13 +19305,57 @@ Dialog.Footer = function (_ref6) {
19200
19305
  }));
19201
19306
  };
19202
19307
 
19203
- var _excluded$7 = ["id", "title", "message", "type", "duration", "onClose", "position"];
19308
+ var _excluded$7 = ["id", "title", "message", "description", "type", "duration", "onClose", "position", "statusIcon", "actions", "color", "footerNote", "showFooterNote", "portal", "className"];
19204
19309
  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; }
19205
19310
  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; }
19206
- var Toast = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
19311
+ var STATUS_CONFIG = {
19312
+ success: {
19313
+ icon: CheckCircle2,
19314
+ iconClass: 'text-emerald-500 dark:text-emerald-400',
19315
+ progressClass: 'bg-emerald-500 dark:bg-emerald-400'
19316
+ },
19317
+ error: {
19318
+ icon: XCircle,
19319
+ iconClass: 'text-rose-500 dark:text-rose-400',
19320
+ progressClass: 'bg-rose-500 dark:bg-rose-400'
19321
+ },
19322
+ warning: {
19323
+ icon: AlertTriangle,
19324
+ iconClass: 'text-amber-500 dark:text-amber-400',
19325
+ progressClass: 'bg-amber-500 dark:bg-amber-400'
19326
+ },
19327
+ info: {
19328
+ icon: Info,
19329
+ iconClass: 'text-sky-500 dark:text-sky-400',
19330
+ progressClass: 'bg-sky-500 dark:bg-sky-400'
19331
+ },
19332
+ "default": {
19333
+ icon: Bell,
19334
+ iconClass: 'text-primary-500 dark:text-primary-400',
19335
+ progressClass: 'bg-primary-500 dark:bg-primary-400'
19336
+ }
19337
+ };
19338
+ var POSITION_CLASSES = {
19339
+ 'top-right': 'top-4 right-4 items-end',
19340
+ 'top-left': 'top-4 left-4 items-start',
19341
+ 'bottom-right': 'bottom-4 right-4 items-end',
19342
+ 'bottom-left': 'bottom-4 left-4 items-start',
19343
+ 'top-center': 'top-4 left-1/2 transform -translate-x-1/2 items-center',
19344
+ 'bottom-center': 'bottom-4 left-1/2 transform -translate-x-1/2 items-center'
19345
+ };
19346
+ var STANDALONE_POSITION_CLASSES = {
19347
+ 'top-right': 'top-4 right-4',
19348
+ 'top-left': 'top-4 left-4',
19349
+ 'bottom-right': 'bottom-4 right-4',
19350
+ 'bottom-left': 'bottom-4 left-4',
19351
+ 'top-center': 'top-4 left-1/2 transform -translate-x-1/2',
19352
+ 'bottom-center': 'bottom-4 left-1/2 transform -translate-x-1/2'
19353
+ };
19354
+ var Toast = /*#__PURE__*/forwardRef(function (_ref, ref) {
19207
19355
  var id = _ref.id,
19208
19356
  title = _ref.title,
19209
19357
  message = _ref.message,
19358
+ description = _ref.description,
19210
19359
  _ref$type = _ref.type,
19211
19360
  type = _ref$type === void 0 ? 'info' : _ref$type,
19212
19361
  _ref$duration = _ref.duration,
@@ -19214,153 +19363,277 @@ var Toast = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
19214
19363
  onClose = _ref.onClose,
19215
19364
  _ref$position = _ref.position,
19216
19365
  position = _ref$position === void 0 ? 'top-right' : _ref$position,
19366
+ statusIcon = _ref.statusIcon,
19367
+ _ref$actions = _ref.actions,
19368
+ actions = _ref$actions === void 0 ? [] : _ref$actions,
19369
+ color = _ref.color,
19370
+ footerNote = _ref.footerNote,
19371
+ _ref$showFooterNote = _ref.showFooterNote,
19372
+ showFooterNote = _ref$showFooterNote === void 0 ? false : _ref$showFooterNote,
19373
+ _ref$portal = _ref.portal,
19374
+ portal = _ref$portal === void 0 ? true : _ref$portal,
19375
+ _ref$className = _ref.className,
19376
+ className = _ref$className === void 0 ? '' : _ref$className,
19217
19377
  props = _objectWithoutProperties$1(_ref, _excluded$7);
19218
19378
  var _useState = useState(true),
19219
19379
  _useState2 = _slicedToArray(_useState, 2),
19220
19380
  isVisible = _useState2[0],
19221
19381
  setIsVisible = _useState2[1];
19222
- useEffect(function () {
19223
- if (duration > 0) {
19224
- var timer = setTimeout(function () {
19225
- handleClose();
19226
- }, duration);
19227
- return function () {
19228
- return clearTimeout(timer);
19229
- };
19230
- }
19231
- }, [duration]);
19232
- var handleClose = function handleClose() {
19233
- setIsVisible(false);
19382
+ var _useState3 = useState(false),
19383
+ _useState4 = _slicedToArray(_useState3, 2),
19384
+ isLeaving = _useState4[0],
19385
+ setIsLeaving = _useState4[1];
19386
+ var _useState5 = useState(false),
19387
+ _useState6 = _slicedToArray(_useState5, 2),
19388
+ isPaused = _useState6[0],
19389
+ setIsPaused = _useState6[1];
19390
+ var progressBarRef = useRef(null);
19391
+ var timerTextRef = useRef(null);
19392
+ var startTimeRef = useRef(null);
19393
+ var remainingRef = useRef(duration);
19394
+ var timerRef = useRef(null);
19395
+ var animFrameRef = useRef(null);
19396
+ var handleClose = useCallback(function () {
19397
+ if (isLeaving) return;
19398
+ setIsLeaving(true);
19234
19399
  setTimeout(function () {
19400
+ setIsVisible(false);
19235
19401
  onClose === null || onClose === void 0 || onClose(id);
19236
19402
  }, 300);
19237
- };
19238
- var icons = {
19239
- success: jsx(CheckCircle, {
19240
- className: "h-5 w-5 text-success-500"
19241
- }),
19242
- error: jsx(AlertCircle, {
19243
- className: "h-5 w-5 text-error-500"
19244
- }),
19245
- warning: jsx(AlertTriangle, {
19246
- className: "h-5 w-5 text-warning-500"
19247
- }),
19248
- info: jsx(Info, {
19249
- className: "h-5 w-5 text-primary-500"
19250
- })
19251
- };
19252
- var positionClasses = {
19253
- 'top-right': 'top-4 right-4',
19254
- 'top-left': 'top-4 left-4',
19255
- 'bottom-right': 'bottom-4 right-4',
19256
- 'bottom-left': 'bottom-4 left-4',
19257
- 'top-center': 'top-4 left-1/2 transform -translate-x-1/2',
19258
- 'bottom-center': 'bottom-4 left-1/2 transform -translate-x-1/2'
19259
- };
19403
+ }, [id, onClose, isLeaving]);
19404
+ var handleStopTimer = useCallback(function (e) {
19405
+ e === null || e === void 0 || e.stopPropagation();
19406
+ setIsPaused(true);
19407
+ if (timerRef.current) clearTimeout(timerRef.current);
19408
+ if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
19409
+ }, []);
19410
+ // Direct DOM-based progress updates to prevent 60 FPS React re-renders and glitches
19411
+ useEffect(function () {
19412
+ if (duration <= 0) return;
19413
+ if (isPaused) {
19414
+ if (timerRef.current) clearTimeout(timerRef.current);
19415
+ if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
19416
+ return;
19417
+ }
19418
+ startTimeRef.current = Date.now();
19419
+ timerRef.current = setTimeout(function () {
19420
+ handleClose();
19421
+ }, remainingRef.current);
19422
+ var _updateProgress = function updateProgress() {
19423
+ var elapsed = startTimeRef.current ? Date.now() - startTimeRef.current : 0;
19424
+ var currentRemaining = Math.max(0, remainingRef.current - elapsed);
19425
+ var pct = currentRemaining / duration * 100;
19426
+ if (progressBarRef.current) {
19427
+ progressBarRef.current.style.width = "".concat(pct, "%");
19428
+ }
19429
+ if (timerTextRef.current) {
19430
+ var secs = Math.ceil(currentRemaining / 1000);
19431
+ timerTextRef.current.textContent = "This message will close in ".concat(secs, " seconds. ");
19432
+ }
19433
+ if (currentRemaining > 0 && !isPaused) {
19434
+ animFrameRef.current = requestAnimationFrame(_updateProgress);
19435
+ }
19436
+ };
19437
+ animFrameRef.current = requestAnimationFrame(_updateProgress);
19438
+ return function () {
19439
+ if (timerRef.current) clearTimeout(timerRef.current);
19440
+ if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
19441
+ if (!isPaused && startTimeRef.current) {
19442
+ var elapsed = Date.now() - startTimeRef.current;
19443
+ remainingRef.current = Math.max(0, remainingRef.current - elapsed);
19444
+ }
19445
+ };
19446
+ }, [duration, isPaused, handleClose]);
19260
19447
  if (!isVisible) return null;
19261
- return /*#__PURE__*/createPortal(jsx("div", _objectSpread$b(_objectSpread$b({
19448
+ var statusStyle = STATUS_CONFIG[type] || STATUS_CONFIG.info || STATUS_CONFIG["default"];
19449
+ var StatusIconComponent = statusStyle.icon;
19450
+ var bodyText = description || message;
19451
+ var toastContent = jsxs("div", _objectSpread$b(_objectSpread$b({
19262
19452
  ref: ref,
19263
- className: cn$1('fixed z-50 max-w-sm rounded-lg border border-gray-200 bg-white p-4 shadow-lg animate-slide-up', positionClasses[position])
19453
+ onMouseEnter: function onMouseEnter() {
19454
+ return setIsPaused(true);
19455
+ },
19456
+ onMouseLeave: function onMouseLeave() {
19457
+ return setIsPaused(false);
19458
+ },
19459
+ 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)
19264
19460
  }, props), {}, {
19265
- children: jsxs("div", {
19266
- className: "flex items-start",
19267
- children: [jsx("div", {
19268
- className: "flex-shrink-0",
19269
- children: icons[type]
19270
- }), jsxs("div", {
19271
- className: "ml-3 flex-1",
19272
- children: [title && jsx("h4", {
19273
- className: "text-sm font-medium text-primary-900",
19274
- children: title
19275
- }), message && jsx("p", {
19276
- className: "mt-1 text-sm text-primary-600",
19277
- children: message
19461
+ children: [jsx("div", {
19462
+ className: "p-4",
19463
+ children: jsxs("div", {
19464
+ className: "flex items-start gap-3 justify-between",
19465
+ children: [jsx("span", {
19466
+ className: "flex-shrink-0 mt-0.5",
19467
+ children: statusIcon ? statusIcon : jsx(StatusIconComponent, {
19468
+ className: cn$1('h-5 w-5', statusStyle.iconClass)
19469
+ })
19470
+ }), jsxs("div", {
19471
+ className: "flex-1 min-w-0 pr-2",
19472
+ children: [title && jsx("h4", {
19473
+ className: "text-sm font-semibold text-slate-900 dark:text-slate-100 leading-snug",
19474
+ children: title
19475
+ }), bodyText && jsx("p", {
19476
+ className: "mt-1 text-xs text-slate-600 dark:text-slate-400 leading-relaxed whitespace-pre-line",
19477
+ children: bodyText
19478
+ }), actions && actions.length > 0 && jsx("div", {
19479
+ className: "mt-3 flex items-center gap-2 flex-wrap",
19480
+ children: actions.map(function (actItem, idx) {
19481
+ return jsx("button", {
19482
+ type: "button",
19483
+ onClick: function onClick(e) {
19484
+ var _actItem$onClick;
19485
+ (_actItem$onClick = actItem.onClick) === null || _actItem$onClick === void 0 || _actItem$onClick.call(actItem, e);
19486
+ if (actItem.dismiss !== false) {
19487
+ handleClose();
19488
+ }
19489
+ },
19490
+ 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),
19491
+ children: actItem.label
19492
+ }, actItem.id || actItem.label || "act-".concat(idx));
19493
+ })
19494
+ })]
19495
+ }), jsx("button", {
19496
+ type: "button",
19497
+ "aria-label": "Close notification",
19498
+ 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",
19499
+ onClick: handleClose,
19500
+ children: jsx(X, {
19501
+ className: "h-4 w-4"
19502
+ })
19278
19503
  })]
19279
- }), jsx("button", {
19280
- type: "button",
19281
- className: "ml-4 flex-shrink-0 rounded-md p-1 text-primary-400 hover:text-primary-600 hover:bg-gray-100",
19282
- onClick: handleClose,
19283
- children: jsx(X, {
19284
- className: "h-4 w-4"
19504
+ })
19505
+ }), (showFooterNote || footerNote) && duration > 0 && jsx("div", {
19506
+ 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",
19507
+ children: jsx("span", {
19508
+ children: footerNote ? footerNote : jsxs(Fragment, {
19509
+ children: [jsxs("span", {
19510
+ ref: timerTextRef,
19511
+ children: ["This message will close in ", Math.ceil(duration / 1000), " seconds.", ' ']
19512
+ }), jsx("button", {
19513
+ type: "button",
19514
+ onClick: handleStopTimer,
19515
+ className: "font-medium text-slate-700 dark:text-zinc-200 hover:underline inline",
19516
+ children: "Click to stop."
19517
+ })]
19285
19518
  })
19286
- })]
19287
- })
19288
- })), document.body);
19519
+ })
19520
+ }), duration > 0 && jsx("div", {
19521
+ className: "absolute bottom-0 left-0 right-0 h-0.5 bg-slate-100 dark:bg-zinc-800/80 overflow-hidden rounded-b-xl",
19522
+ children: jsx("div", {
19523
+ ref: progressBarRef,
19524
+ className: cn$1('h-full transition-all ease-linear', color ? '' : statusStyle.progressClass),
19525
+ style: {
19526
+ width: '100%',
19527
+ backgroundColor: color || undefined
19528
+ }
19529
+ })
19530
+ })]
19531
+ }));
19532
+ if (portal) {
19533
+ return /*#__PURE__*/createPortal(toastContent, document.body);
19534
+ }
19535
+ return toastContent;
19289
19536
  });
19290
19537
  Toast.displayName = 'Toast';
19291
- // Toast Container Component
19538
+ // Toast Container Component for vertical stacking & scrollable overflow without visible scrollbars
19292
19539
  var ToastContainer = function ToastContainer(_ref2) {
19293
19540
  var _ref2$toasts = _ref2.toasts,
19294
19541
  toasts = _ref2$toasts === void 0 ? [] : _ref2$toasts,
19295
19542
  _ref2$position = _ref2.position,
19296
19543
  position = _ref2$position === void 0 ? 'top-right' : _ref2$position,
19297
- onRemove = _ref2.onRemove;
19298
- return jsx("div", {
19299
- className: "fixed z-50 space-y-2",
19300
- style: _defineProperty$4(_defineProperty$4({}, position.includes('top') ? 'top' : 'bottom', '1rem'), position.includes('right') ? 'right' : position.includes('left') ? 'left' : 'left', position.includes('center') ? '50%' : '1rem'),
19301
- children: toasts.map(function (toast) {
19302
- return jsx(Toast, _objectSpread$b(_objectSpread$b({}, toast), {}, {
19303
- position: position,
19304
- onClose: onRemove
19305
- }), toast.id);
19544
+ onRemove = _ref2.onRemove,
19545
+ _ref2$className = _ref2.className,
19546
+ className = _ref2$className === void 0 ? '' : _ref2$className;
19547
+ if (!toasts || toasts.length === 0) {
19548
+ return null;
19549
+ }
19550
+ var posClass = POSITION_CLASSES[position] || POSITION_CLASSES['top-right'];
19551
+ return /*#__PURE__*/createPortal(jsx("div", {
19552
+ 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),
19553
+ children: toasts.map(function (t) {
19554
+ return jsx("div", {
19555
+ className: "pointer-events-auto w-full max-w-md",
19556
+ children: jsx(Toast, _objectSpread$b(_objectSpread$b({}, t), {}, {
19557
+ portal: false,
19558
+ position: position,
19559
+ onClose: onRemove
19560
+ }))
19561
+ }, t.id);
19306
19562
  })
19307
- });
19563
+ }), document.body);
19308
19564
  };
19309
19565
  // Toast Hook
19310
19566
  var useToast = function useToast() {
19311
- var _useState3 = useState([]),
19312
- _useState4 = _slicedToArray(_useState3, 2),
19313
- toasts = _useState4[0],
19314
- setToasts = _useState4[1];
19315
- var addToast = function addToast(toast) {
19316
- var id = Date.now().toString();
19567
+ var _useState7 = useState([]),
19568
+ _useState8 = _slicedToArray(_useState7, 2),
19569
+ toasts = _useState8[0],
19570
+ setToasts = _useState8[1];
19571
+ var addToast = useCallback(function (toastOptions) {
19572
+ var id = toastOptions.id || "".concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 7));
19573
+ var newToast = _objectSpread$b(_objectSpread$b({}, toastOptions), {}, {
19574
+ id: id
19575
+ });
19317
19576
  setToasts(function (prev) {
19318
- return [].concat(_toConsumableArray$1(prev), [_objectSpread$b(_objectSpread$b({}, toast), {}, {
19319
- id: id
19320
- })]);
19577
+ return [].concat(_toConsumableArray$1(prev), [newToast]);
19321
19578
  });
19322
- };
19323
- var removeToast = function removeToast(id) {
19579
+ return id;
19580
+ }, []);
19581
+ var removeToast = useCallback(function (id) {
19324
19582
  setToasts(function (prev) {
19325
- return prev.filter(function (toast) {
19326
- return toast.id !== id;
19583
+ return prev.filter(function (t) {
19584
+ return t.id !== id;
19327
19585
  });
19328
19586
  });
19587
+ }, []);
19588
+ var clearToasts = useCallback(function () {
19589
+ setToasts([]);
19590
+ }, []);
19591
+ var toast = useCallback(function (options) {
19592
+ return addToast(typeof options === 'string' ? {
19593
+ message: options
19594
+ } : options);
19595
+ }, [addToast]);
19596
+ toast.success = function (title, message, options) {
19597
+ return addToast(_objectSpread$b({
19598
+ title: title,
19599
+ message: message,
19600
+ type: 'success'
19601
+ }, _typeof$4(options) === 'object' ? options : {}));
19329
19602
  };
19330
- var toast = {
19331
- success: function success(title, message, options) {
19332
- return addToast(_objectSpread$b({
19333
- title: title,
19334
- message: message,
19335
- type: 'success'
19336
- }, options));
19337
- },
19338
- error: function error(title, message, options) {
19339
- return addToast(_objectSpread$b({
19340
- title: title,
19341
- message: message,
19342
- type: 'error'
19343
- }, options));
19344
- },
19345
- warning: function warning(title, message, options) {
19346
- return addToast(_objectSpread$b({
19347
- title: title,
19348
- message: message,
19349
- type: 'warning'
19350
- }, options));
19351
- },
19352
- info: function info(title, message, options) {
19353
- return addToast(_objectSpread$b({
19354
- title: title,
19355
- message: message,
19356
- type: 'info'
19357
- }, options));
19358
- }
19603
+ toast.error = function (title, message, options) {
19604
+ return addToast(_objectSpread$b({
19605
+ title: title,
19606
+ message: message,
19607
+ type: 'error'
19608
+ }, _typeof$4(options) === 'object' ? options : {}));
19609
+ };
19610
+ toast.warning = function (title, message, options) {
19611
+ return addToast(_objectSpread$b({
19612
+ title: title,
19613
+ message: message,
19614
+ type: 'warning'
19615
+ }, _typeof$4(options) === 'object' ? options : {}));
19616
+ };
19617
+ toast.info = function (title, message, options) {
19618
+ return addToast(_objectSpread$b({
19619
+ title: title,
19620
+ message: message,
19621
+ type: 'info'
19622
+ }, _typeof$4(options) === 'object' ? options : {}));
19623
+ };
19624
+ toast["default"] = function (title, message, options) {
19625
+ return addToast(_objectSpread$b({
19626
+ title: title,
19627
+ message: message,
19628
+ type: 'default'
19629
+ }, _typeof$4(options) === 'object' ? options : {}));
19359
19630
  };
19360
19631
  return {
19361
19632
  toast: toast,
19362
19633
  toasts: toasts,
19363
- removeToast: removeToast
19634
+ removeToast: removeToast,
19635
+ clearToasts: clearToasts,
19636
+ addToast: addToast
19364
19637
  };
19365
19638
  };
19366
19639