@dreamtree-org/twreact-ui 1.1.71 → 1.1.72
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/components/core/Checkbox.d.ts.map +1 -1
- package/dist/components/core/Switch.d.ts.map +1 -1
- package/dist/components/core/Table/FieldInput.d.ts +3 -2
- package/dist/components/core/Table/FieldInput.d.ts.map +1 -1
- package/dist/components/core/Table/Table.d.ts.map +1 -1
- package/dist/components/core/Table/TableRow.d.ts +2 -1
- package/dist/components/core/Table/TableRow.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +333 -60
- package/dist/index.js +333 -60
- package/mcp/catalog.snapshot.json +16 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3191,8 +3191,8 @@ function cn$1() {
|
|
|
3191
3191
|
}
|
|
3192
3192
|
|
|
3193
3193
|
var _excluded$A = ["id", "className", "type", "label", "placeholder", "error", "success", "disabled", "required", "clearable", "icon", "iconPosition", "onClear", "showCount", "maxLength", "readOnly", "onChange", "value", "defaultValue"];
|
|
3194
|
-
function ownKeys$
|
|
3195
|
-
function _objectSpread$
|
|
3194
|
+
function ownKeys$G(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; }
|
|
3195
|
+
function _objectSpread$G(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$G(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$G(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3196
3196
|
var Input = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
3197
3197
|
var _ref$current$value2, _ref$current;
|
|
3198
3198
|
var id = props.id,
|
|
@@ -3307,7 +3307,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
3307
3307
|
className: "text-primary-400",
|
|
3308
3308
|
children: icon
|
|
3309
3309
|
})
|
|
3310
|
-
}), jsxRuntime.jsx("input", _objectSpread$
|
|
3310
|
+
}), jsxRuntime.jsx("input", _objectSpread$G({
|
|
3311
3311
|
id: inputId,
|
|
3312
3312
|
ref: ref,
|
|
3313
3313
|
type: inputType,
|
|
@@ -3368,8 +3368,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
3368
3368
|
});
|
|
3369
3369
|
|
|
3370
3370
|
var _excluded$z = ["className", "variant", "size", "disabled", "loading", "children", "leftIcon", "rightIcon", "fullWidth"];
|
|
3371
|
-
function ownKeys$
|
|
3372
|
-
function _objectSpread$
|
|
3371
|
+
function ownKeys$F(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; }
|
|
3372
|
+
function _objectSpread$F(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$F(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$F(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3373
3373
|
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
3374
3374
|
var className = _ref.className,
|
|
3375
3375
|
_ref$variant = _ref.variant,
|
|
@@ -3399,7 +3399,7 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3399
3399
|
// Full width
|
|
3400
3400
|
'w-full': fullWidth
|
|
3401
3401
|
}, className);
|
|
3402
|
-
return jsxRuntime.jsxs("button", _objectSpread$
|
|
3402
|
+
return jsxRuntime.jsxs("button", _objectSpread$F(_objectSpread$F({
|
|
3403
3403
|
ref: ref,
|
|
3404
3404
|
className: baseClasses,
|
|
3405
3405
|
disabled: disabled || loading
|
|
@@ -3434,8 +3434,8 @@ function _toConsumableArray$1(r) {
|
|
|
3434
3434
|
}
|
|
3435
3435
|
|
|
3436
3436
|
var _excluded$y = ["options", "value", "onChange", "placeholder", "label", "error", "disabled", "required", "multiSelect", "searchable", "grouped", "onMenuItemRender", "className", "allowClear", "creatable", "onCreateOption", "onSearch", "loading", "selectAllOption", "closeOnSelect", "maxTagCount", "renderGroupLabel", "name"];
|
|
3437
|
-
function ownKeys$
|
|
3438
|
-
function _objectSpread$
|
|
3437
|
+
function ownKeys$E(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; }
|
|
3438
|
+
function _objectSpread$E(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$E(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$E(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3439
3439
|
/**
|
|
3440
3440
|
* Enhanced Select component (debounce removed)
|
|
3441
3441
|
* - Supports single and multi select
|
|
@@ -3456,7 +3456,7 @@ var flattenGroups = function flattenGroups() {
|
|
|
3456
3456
|
return groups.reduce(function (acc, g) {
|
|
3457
3457
|
var groupLabel = g.label;
|
|
3458
3458
|
g.options.forEach(function (opt) {
|
|
3459
|
-
return acc.push(_objectSpread$
|
|
3459
|
+
return acc.push(_objectSpread$E(_objectSpread$E({}, opt), {}, {
|
|
3460
3460
|
_group: groupLabel
|
|
3461
3461
|
}));
|
|
3462
3462
|
});
|
|
@@ -3552,7 +3552,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3552
3552
|
var flatOptions = React.useMemo(function () {
|
|
3553
3553
|
if (grouped) return flattenGroups(options);
|
|
3554
3554
|
return options.map(function (opt) {
|
|
3555
|
-
return _objectSpread$
|
|
3555
|
+
return _objectSpread$E({}, opt);
|
|
3556
3556
|
});
|
|
3557
3557
|
}, [options, grouped]);
|
|
3558
3558
|
var selectedValues = multiSelect ? Array.isArray(value) ? value : [] : value;
|
|
@@ -3577,7 +3577,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3577
3577
|
}
|
|
3578
3578
|
if (grouped) {
|
|
3579
3579
|
return options.map(function (g) {
|
|
3580
|
-
return _objectSpread$
|
|
3580
|
+
return _objectSpread$E(_objectSpread$E({}, g), {}, {
|
|
3581
3581
|
options: g.options.filter(function (o) {
|
|
3582
3582
|
return o.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
3583
3583
|
})
|
|
@@ -3847,7 +3847,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3847
3847
|
className: "text-xs border border-slate-200 p-0.5 rounded-md cursor-pointer hover:bg-gray-100",
|
|
3848
3848
|
onClick: function onClick() {
|
|
3849
3849
|
return setCollapsedGroups(function (prev) {
|
|
3850
|
-
return _objectSpread$
|
|
3850
|
+
return _objectSpread$E(_objectSpread$E({}, prev), {}, _defineProperty$4({}, group.label, !prev[group.label]));
|
|
3851
3851
|
});
|
|
3852
3852
|
},
|
|
3853
3853
|
children: jsxRuntime.jsx(ChevronDown, {
|
|
@@ -3941,7 +3941,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3941
3941
|
}), jsxRuntime.jsxs("div", {
|
|
3942
3942
|
ref: selectRef,
|
|
3943
3943
|
className: "relative",
|
|
3944
|
-
children: [jsxRuntime.jsxs("button", _objectSpread$
|
|
3944
|
+
children: [jsxRuntime.jsxs("button", _objectSpread$E(_objectSpread$E({
|
|
3945
3945
|
type: "button",
|
|
3946
3946
|
"aria-haspopup": "listbox",
|
|
3947
3947
|
"aria-expanded": isOpen,
|
|
@@ -4008,7 +4008,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
4008
4008
|
// escapes any ancestor overflow:hidden|auto|scroll. Coordinates
|
|
4009
4009
|
// are anchored to the trigger's viewport rect; width matches the
|
|
4010
4010
|
// trigger; maxHeight is driven by available space.
|
|
4011
|
-
style: _objectSpread$
|
|
4011
|
+
style: _objectSpread$E({
|
|
4012
4012
|
left: menuCoords ? "".concat(menuCoords.left, "px") : undefined,
|
|
4013
4013
|
top: menuCoords ? "".concat(menuCoords.top, "px") : undefined,
|
|
4014
4014
|
width: menuCoords ? "".concat(menuCoords.width, "px") : undefined
|
|
@@ -4490,8 +4490,8 @@ var DEFAULT_ACTIONS = [{
|
|
|
4490
4490
|
})
|
|
4491
4491
|
}];
|
|
4492
4492
|
|
|
4493
|
-
function ownKeys$
|
|
4494
|
-
function _objectSpread$
|
|
4493
|
+
function ownKeys$D(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; }
|
|
4494
|
+
function _objectSpread$D(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$D(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$D(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4495
4495
|
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
4496
4496
|
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
4497
4497
|
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -4555,7 +4555,7 @@ var mergeDefaultActions = function mergeDefaultActions(overrides, defaults) {
|
|
|
4555
4555
|
_iterator.f();
|
|
4556
4556
|
}
|
|
4557
4557
|
var merged = defaults.map(function (d) {
|
|
4558
|
-
return d !== null && d !== void 0 && d.name && byName.has(d.name) ? _objectSpread$
|
|
4558
|
+
return d !== null && d !== void 0 && d.name && byName.has(d.name) ? _objectSpread$D(_objectSpread$D({}, d), byName.get(d.name)) : d;
|
|
4559
4559
|
});
|
|
4560
4560
|
var defaultNames = new Set(defaults.map(function (d) {
|
|
4561
4561
|
return d === null || d === void 0 ? void 0 : d.name;
|
|
@@ -4597,7 +4597,7 @@ var resolveActions = function resolveActions(actions, row, index) {
|
|
|
4597
4597
|
var action = _step2.value;
|
|
4598
4598
|
if (!action || _typeof$4(action) !== "object") continue;
|
|
4599
4599
|
if (callIfFn(action.hidden, row, index)) continue;
|
|
4600
|
-
var resolved = _objectSpread$
|
|
4600
|
+
var resolved = _objectSpread$D(_objectSpread$D({}, action), {}, {
|
|
4601
4601
|
label: callIfFn(action.label, row, index),
|
|
4602
4602
|
icon: callIfFn(action.icon, row, index),
|
|
4603
4603
|
disabled: !!callIfFn(action.disabled, row, index),
|
|
@@ -5134,6 +5134,8 @@ function ActionMenu(_ref) {
|
|
|
5134
5134
|
}), document.body);
|
|
5135
5135
|
}
|
|
5136
5136
|
|
|
5137
|
+
function ownKeys$C(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; }
|
|
5138
|
+
function _objectSpread$C(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$C(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$C(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5137
5139
|
/**
|
|
5138
5140
|
* Desktop table row component
|
|
5139
5141
|
*/
|
|
@@ -5182,6 +5184,8 @@ function TableRow(_ref) {
|
|
|
5182
5184
|
renderInteractiveCellInput = _ref$renderInteractiv === void 0 ? null : _ref$renderInteractiv,
|
|
5183
5185
|
_ref$invalidCellSet = _ref.invalidCellSet,
|
|
5184
5186
|
invalidCellSet = _ref$invalidCellSet === void 0 ? null : _ref$invalidCellSet,
|
|
5187
|
+
_ref$pendingEdits = _ref.pendingEdits,
|
|
5188
|
+
pendingEdits = _ref$pendingEdits === void 0 ? null : _ref$pendingEdits,
|
|
5185
5189
|
_ref$isNewRow = _ref.isNewRow,
|
|
5186
5190
|
isNewRow = _ref$isNewRow === void 0 ? false : _ref$isNewRow,
|
|
5187
5191
|
_ref$onDeleteNewRow = _ref.onDeleteNewRow,
|
|
@@ -5209,6 +5213,10 @@ function TableRow(_ref) {
|
|
|
5209
5213
|
var stripeBg = stripedRows && !isSelected && Array.isArray(stripeColors) && stripeColors.length > 0 ? stripeColors[globalIndex % stripeColors.length] : undefined;
|
|
5210
5214
|
var rowKey = isNewRow ? row._key : key;
|
|
5211
5215
|
var isRowActive = interactive && (activeCell === null || activeCell === void 0 ? void 0 : activeCell.rowKey) === rowKey;
|
|
5216
|
+
var effectiveRow = React.useMemo(function () {
|
|
5217
|
+
if (!interactive || !pendingEdits || !pendingEdits[rowKey]) return row;
|
|
5218
|
+
return _objectSpread$C(_objectSpread$C({}, row), pendingEdits[rowKey]);
|
|
5219
|
+
}, [interactive, pendingEdits, rowKey, row]);
|
|
5212
5220
|
return jsxRuntime.jsxs(React.Fragment, {
|
|
5213
5221
|
children: [jsxRuntime.jsxs("tr", {
|
|
5214
5222
|
style: stripeBg ? {
|
|
@@ -5221,7 +5229,7 @@ function TableRow(_ref) {
|
|
|
5221
5229
|
"bg-amber-50/40": isNewRow && !isSelected && !isRowActive
|
|
5222
5230
|
}, safeExtraRowClass),
|
|
5223
5231
|
onClick: function onClick() {
|
|
5224
|
-
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(
|
|
5232
|
+
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(effectiveRow, globalIndex);
|
|
5225
5233
|
},
|
|
5226
5234
|
children: [hasDetailsColumn && jsxRuntime.jsx("td", {
|
|
5227
5235
|
className: "px-4 py-4 text-sm",
|
|
@@ -5229,7 +5237,7 @@ function TableRow(_ref) {
|
|
|
5229
5237
|
type: "button",
|
|
5230
5238
|
onClick: function onClick(e) {
|
|
5231
5239
|
e.stopPropagation();
|
|
5232
|
-
toggleExpandRow(
|
|
5240
|
+
toggleExpandRow(effectiveRow, rowIndexInPage);
|
|
5233
5241
|
},
|
|
5234
5242
|
"aria-expanded": isExpanded,
|
|
5235
5243
|
"aria-label": isExpanded ? "Collapse row details" : "Expand row details",
|
|
@@ -5249,12 +5257,12 @@ function TableRow(_ref) {
|
|
|
5249
5257
|
className: "rounded border-gray-300",
|
|
5250
5258
|
checked: isSelected,
|
|
5251
5259
|
onChange: function onChange() {
|
|
5252
|
-
return handleSelectRow(
|
|
5260
|
+
return handleSelectRow(effectiveRow, rowIndexInPage);
|
|
5253
5261
|
}
|
|
5254
5262
|
})
|
|
5255
5263
|
}), visibleColumns.map(function (column, columnIndex) {
|
|
5256
5264
|
var extraCellClass = typeof cellClass === "function" ? cellClass({
|
|
5257
|
-
row:
|
|
5265
|
+
row: effectiveRow,
|
|
5258
5266
|
rowIndex: globalIndex,
|
|
5259
5267
|
column: column,
|
|
5260
5268
|
columnIndex: columnIndex
|
|
@@ -5273,15 +5281,15 @@ function TableRow(_ref) {
|
|
|
5273
5281
|
}, safeExtraCellClass),
|
|
5274
5282
|
onClick: function onClick(e) {
|
|
5275
5283
|
if (interactive && onCellClick) {
|
|
5276
|
-
onCellClick(rowKey, column.key,
|
|
5284
|
+
onCellClick(rowKey, column.key, effectiveRow, column, globalIndex);
|
|
5277
5285
|
}
|
|
5278
5286
|
},
|
|
5279
5287
|
onDoubleClick: function onDoubleClick(e) {
|
|
5280
5288
|
if (interactive && onCellDoubleClick && column.editable !== false) {
|
|
5281
|
-
onCellDoubleClick(rowKey, column.key,
|
|
5289
|
+
onCellDoubleClick(rowKey, column.key, effectiveRow, column, globalIndex);
|
|
5282
5290
|
}
|
|
5283
5291
|
},
|
|
5284
|
-
children: isCellEditing && renderInteractiveCellInput ? renderInteractiveCellInput(column,
|
|
5292
|
+
children: isCellEditing && renderInteractiveCellInput ? renderInteractiveCellInput(column, effectiveRow, globalIndex, rowKey) : renderCell(column, effectiveRow, globalIndex)
|
|
5285
5293
|
}, column.key);
|
|
5286
5294
|
}), jsxRuntime.jsx("td", {
|
|
5287
5295
|
className: "px-4 py-4"
|
|
@@ -5552,6 +5560,7 @@ function FieldInput(_ref) {
|
|
|
5552
5560
|
var column = _ref.column,
|
|
5553
5561
|
value = _ref.value,
|
|
5554
5562
|
_onChange = _ref.onChange,
|
|
5563
|
+
onKeyDown = _ref.onKeyDown,
|
|
5555
5564
|
_ref$isEditing = _ref.isEditing,
|
|
5556
5565
|
isEditing = _ref$isEditing === void 0 ? true : _ref$isEditing,
|
|
5557
5566
|
_ref$row = _ref.row,
|
|
@@ -5564,14 +5573,22 @@ function FieldInput(_ref) {
|
|
|
5564
5573
|
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus;
|
|
5565
5574
|
var currentValue = value !== null && value !== void 0 ? value : "";
|
|
5566
5575
|
var inputType = column.type || column.inputType || "text";
|
|
5576
|
+
var stopProp = function stopProp(e) {
|
|
5577
|
+
e.stopPropagation();
|
|
5578
|
+
};
|
|
5567
5579
|
// Check if custom onRender renderer is provided on the column definition
|
|
5568
5580
|
if (typeof column.onRender === "function") {
|
|
5569
|
-
return
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5581
|
+
return jsxRuntime.jsx("div", {
|
|
5582
|
+
onClick: stopProp,
|
|
5583
|
+
onMouseDown: stopProp,
|
|
5584
|
+
children: column.onRender(row, rowIndex, column, {
|
|
5585
|
+
value: currentValue,
|
|
5586
|
+
onChange: function onChange(newVal) {
|
|
5587
|
+
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(newVal);
|
|
5588
|
+
},
|
|
5589
|
+
onKeyDown: onKeyDown,
|
|
5590
|
+
isEditing: isEditing
|
|
5591
|
+
})
|
|
5575
5592
|
});
|
|
5576
5593
|
}
|
|
5577
5594
|
// Textarea / Longtext
|
|
@@ -5583,6 +5600,9 @@ function FieldInput(_ref) {
|
|
|
5583
5600
|
onChange: function onChange(e) {
|
|
5584
5601
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
5585
5602
|
},
|
|
5603
|
+
onKeyDown: onKeyDown,
|
|
5604
|
+
onClick: stopProp,
|
|
5605
|
+
onMouseDown: stopProp,
|
|
5586
5606
|
placeholder: "Enter ".concat(column.label || column.key, "..."),
|
|
5587
5607
|
className: cn$1("w-full px-2 py-1 text-sm border rounded outline-none transition-all focus:ring-2 focus:ring-primary-500 bg-white resize-y min-h-[2.5rem]", className)
|
|
5588
5608
|
});
|
|
@@ -5601,6 +5621,9 @@ function FieldInput(_ref) {
|
|
|
5601
5621
|
onChange: function onChange(e) {
|
|
5602
5622
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
5603
5623
|
},
|
|
5624
|
+
onKeyDown: onKeyDown,
|
|
5625
|
+
onClick: stopProp,
|
|
5626
|
+
onMouseDown: stopProp,
|
|
5604
5627
|
className: cn$1("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-white", className),
|
|
5605
5628
|
children: [jsxRuntime.jsxs("option", {
|
|
5606
5629
|
value: "",
|
|
@@ -5618,6 +5641,8 @@ function FieldInput(_ref) {
|
|
|
5618
5641
|
var checked = Boolean(currentValue);
|
|
5619
5642
|
return jsxRuntime.jsx("div", {
|
|
5620
5643
|
className: cn$1("flex items-center justify-center py-1", className),
|
|
5644
|
+
onClick: stopProp,
|
|
5645
|
+
onMouseDown: stopProp,
|
|
5621
5646
|
children: jsxRuntime.jsx("input", {
|
|
5622
5647
|
type: "checkbox",
|
|
5623
5648
|
autoFocus: autoFocus,
|
|
@@ -5625,6 +5650,7 @@ function FieldInput(_ref) {
|
|
|
5625
5650
|
onChange: function onChange(e) {
|
|
5626
5651
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.checked);
|
|
5627
5652
|
},
|
|
5653
|
+
onKeyDown: onKeyDown,
|
|
5628
5654
|
className: "w-4 h-4 text-primary-600 border-gray-300 rounded focus:ring-primary-500 cursor-pointer"
|
|
5629
5655
|
})
|
|
5630
5656
|
});
|
|
@@ -5638,6 +5664,9 @@ function FieldInput(_ref) {
|
|
|
5638
5664
|
onChange: function onChange(e) {
|
|
5639
5665
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
5640
5666
|
},
|
|
5667
|
+
onKeyDown: onKeyDown,
|
|
5668
|
+
onClick: stopProp,
|
|
5669
|
+
onMouseDown: stopProp,
|
|
5641
5670
|
className: cn$1("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-white", className)
|
|
5642
5671
|
});
|
|
5643
5672
|
}
|
|
@@ -5650,6 +5679,9 @@ function FieldInput(_ref) {
|
|
|
5650
5679
|
onChange: function onChange(e) {
|
|
5651
5680
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value === "" ? "" : Number(e.target.value));
|
|
5652
5681
|
},
|
|
5682
|
+
onKeyDown: onKeyDown,
|
|
5683
|
+
onClick: stopProp,
|
|
5684
|
+
onMouseDown: stopProp,
|
|
5653
5685
|
placeholder: "Enter ".concat(column.label || column.key, "..."),
|
|
5654
5686
|
className: cn$1("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-white", className)
|
|
5655
5687
|
});
|
|
@@ -5662,6 +5694,9 @@ function FieldInput(_ref) {
|
|
|
5662
5694
|
onChange: function onChange(e) {
|
|
5663
5695
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
5664
5696
|
},
|
|
5697
|
+
onKeyDown: onKeyDown,
|
|
5698
|
+
onClick: stopProp,
|
|
5699
|
+
onMouseDown: stopProp,
|
|
5665
5700
|
placeholder: "Enter ".concat(column.label || column.key, "..."),
|
|
5666
5701
|
className: cn$1("w-full px-2 py-1 text-sm border rounded outline-none focus:ring-2 focus:ring-primary-500 bg-white", className)
|
|
5667
5702
|
});
|
|
@@ -6136,13 +6171,24 @@ var Table = function Table(_ref) {
|
|
|
6136
6171
|
}
|
|
6137
6172
|
}, _callee, null, [[2, 5, 6, 7]]);
|
|
6138
6173
|
})), [isDirty, isSaving, tableData, dirtyEdits, newRows, onSave]);
|
|
6174
|
+
var handleClearChanges = React.useCallback(function () {
|
|
6175
|
+
setPendingEdits({});
|
|
6176
|
+
setNewRows([]);
|
|
6177
|
+
setEditingCell(null);
|
|
6178
|
+
setActiveCell(null);
|
|
6179
|
+
}, []);
|
|
6139
6180
|
var handleCellClick = React.useCallback(function (rowKey, colKey, row, column, globalIndex) {
|
|
6140
6181
|
setActiveCell({
|
|
6141
6182
|
rowKey: rowKey,
|
|
6142
6183
|
colKey: colKey,
|
|
6143
6184
|
rowIndex: globalIndex
|
|
6144
6185
|
});
|
|
6145
|
-
setEditingCell(
|
|
6186
|
+
setEditingCell(function (prev) {
|
|
6187
|
+
if (prev && prev.rowKey === rowKey && prev.colKey === colKey) {
|
|
6188
|
+
return prev;
|
|
6189
|
+
}
|
|
6190
|
+
return null;
|
|
6191
|
+
});
|
|
6146
6192
|
}, []);
|
|
6147
6193
|
var handleCellDoubleClick = React.useCallback(function (rowKey, colKey, row, column, globalIndex) {
|
|
6148
6194
|
setActiveCell({
|
|
@@ -6158,21 +6204,6 @@ var Table = function Table(_ref) {
|
|
|
6158
6204
|
});
|
|
6159
6205
|
}
|
|
6160
6206
|
}, []);
|
|
6161
|
-
var renderInteractiveCellInput = React.useCallback(function (column, row, globalIndex, rowKey) {
|
|
6162
|
-
var _row$column$key;
|
|
6163
|
-
var value = pendingEdits[rowKey] && pendingEdits[rowKey][column.key] !== undefined ? pendingEdits[rowKey][column.key] : (_row$column$key = row[column.key]) !== null && _row$column$key !== void 0 ? _row$column$key : "";
|
|
6164
|
-
return jsxRuntime.jsx(FieldInput, {
|
|
6165
|
-
column: column,
|
|
6166
|
-
value: value,
|
|
6167
|
-
onChange: function onChange(newVal) {
|
|
6168
|
-
return handleCellValueChange(rowKey, column.key, newVal);
|
|
6169
|
-
},
|
|
6170
|
-
isEditing: true,
|
|
6171
|
-
row: row,
|
|
6172
|
-
rowIndex: globalIndex,
|
|
6173
|
-
autoFocus: (editingCell === null || editingCell === void 0 ? void 0 : editingCell.rowKey) === rowKey && (editingCell === null || editingCell === void 0 ? void 0 : editingCell.colKey) === column.key
|
|
6174
|
-
});
|
|
6175
|
-
}, [pendingEdits, handleCellValueChange, editingCell]);
|
|
6176
6207
|
useClickOutside([tableContainerRef], interactive && Boolean(editingCell), function () {
|
|
6177
6208
|
setEditingCell(null);
|
|
6178
6209
|
});
|
|
@@ -6323,6 +6354,129 @@ var Table = function Table(_ref) {
|
|
|
6323
6354
|
};
|
|
6324
6355
|
});
|
|
6325
6356
|
}, [limitOptions]);
|
|
6357
|
+
var handleTableKeyDown = React.useCallback(function (e) {
|
|
6358
|
+
if (!interactive) return;
|
|
6359
|
+
var key = e.key,
|
|
6360
|
+
shiftKey = e.shiftKey;
|
|
6361
|
+
// Escape: stop editing
|
|
6362
|
+
if (key === "Escape") {
|
|
6363
|
+
if (editingCell) {
|
|
6364
|
+
e.preventDefault();
|
|
6365
|
+
setEditingCell(null);
|
|
6366
|
+
}
|
|
6367
|
+
return;
|
|
6368
|
+
}
|
|
6369
|
+
// Enter: Save changes only when there are modified changes (isDirty)
|
|
6370
|
+
if (key === "Enter") {
|
|
6371
|
+
var _e$target;
|
|
6372
|
+
if (((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName) === "TEXTAREA" && shiftKey) {
|
|
6373
|
+
return;
|
|
6374
|
+
}
|
|
6375
|
+
if (isDirty) {
|
|
6376
|
+
e.preventDefault();
|
|
6377
|
+
setEditingCell(null);
|
|
6378
|
+
if (isValid && !isSaving) {
|
|
6379
|
+
handleSave();
|
|
6380
|
+
}
|
|
6381
|
+
}
|
|
6382
|
+
return;
|
|
6383
|
+
}
|
|
6384
|
+
var currentCell = activeCell || editingCell;
|
|
6385
|
+
if (!currentCell) return;
|
|
6386
|
+
var allRows = [].concat(_toConsumableArray$1(paginatedData), _toConsumableArray$1(newRows));
|
|
6387
|
+
if (allRows.length === 0 || visibleColumns.length === 0) return;
|
|
6388
|
+
var rIdx = allRows.findIndex(function (r, idx) {
|
|
6389
|
+
var rKey = r._key || getRowKey(r, startIndex + idx);
|
|
6390
|
+
return rKey === currentCell.rowKey;
|
|
6391
|
+
});
|
|
6392
|
+
var cIdx = visibleColumns.findIndex(function (c) {
|
|
6393
|
+
return c.key === currentCell.colKey;
|
|
6394
|
+
});
|
|
6395
|
+
if (rIdx === -1 || cIdx === -1) return;
|
|
6396
|
+
var nextRIdx = rIdx;
|
|
6397
|
+
var nextCIdx = cIdx;
|
|
6398
|
+
if (key === "Tab") {
|
|
6399
|
+
e.preventDefault();
|
|
6400
|
+
if (shiftKey) {
|
|
6401
|
+
if (cIdx > 0) {
|
|
6402
|
+
nextCIdx = cIdx - 1;
|
|
6403
|
+
} else if (rIdx > 0) {
|
|
6404
|
+
nextRIdx = rIdx - 1;
|
|
6405
|
+
nextCIdx = visibleColumns.length - 1;
|
|
6406
|
+
}
|
|
6407
|
+
} else {
|
|
6408
|
+
if (cIdx < visibleColumns.length - 1) {
|
|
6409
|
+
nextCIdx = cIdx + 1;
|
|
6410
|
+
} else if (rIdx < allRows.length - 1) {
|
|
6411
|
+
nextRIdx = rIdx + 1;
|
|
6412
|
+
nextCIdx = 0;
|
|
6413
|
+
}
|
|
6414
|
+
}
|
|
6415
|
+
} else if (key === "ArrowRight") {
|
|
6416
|
+
var _e$target2, _e$target$value;
|
|
6417
|
+
if (editingCell && ((_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.selectionStart) !== undefined && e.target.selectionStart < String((_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : "").length) {
|
|
6418
|
+
return;
|
|
6419
|
+
}
|
|
6420
|
+
if (cIdx < visibleColumns.length - 1) {
|
|
6421
|
+
e.preventDefault();
|
|
6422
|
+
nextCIdx = cIdx + 1;
|
|
6423
|
+
}
|
|
6424
|
+
} else if (key === "ArrowLeft") {
|
|
6425
|
+
var _e$target3;
|
|
6426
|
+
if (editingCell && ((_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.selectionStart) !== undefined && e.target.selectionStart > 0) {
|
|
6427
|
+
return;
|
|
6428
|
+
}
|
|
6429
|
+
if (cIdx > 0) {
|
|
6430
|
+
e.preventDefault();
|
|
6431
|
+
nextCIdx = cIdx - 1;
|
|
6432
|
+
}
|
|
6433
|
+
} else if (key === "ArrowDown") {
|
|
6434
|
+
var _e$target4;
|
|
6435
|
+
if (((_e$target4 = e.target) === null || _e$target4 === void 0 ? void 0 : _e$target4.tagName) === "SELECT") return;
|
|
6436
|
+
if (rIdx < allRows.length - 1) {
|
|
6437
|
+
e.preventDefault();
|
|
6438
|
+
nextRIdx = rIdx + 1;
|
|
6439
|
+
}
|
|
6440
|
+
} else if (key === "ArrowUp") {
|
|
6441
|
+
var _e$target5;
|
|
6442
|
+
if (((_e$target5 = e.target) === null || _e$target5 === void 0 ? void 0 : _e$target5.tagName) === "SELECT") return;
|
|
6443
|
+
if (rIdx > 0) {
|
|
6444
|
+
e.preventDefault();
|
|
6445
|
+
nextRIdx = rIdx - 1;
|
|
6446
|
+
}
|
|
6447
|
+
} else {
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6450
|
+
var targetRow = allRows[nextRIdx];
|
|
6451
|
+
var targetCol = visibleColumns[nextCIdx];
|
|
6452
|
+
if (!targetRow || !targetCol) return;
|
|
6453
|
+
var targetRowKey = targetRow._key || getRowKey(targetRow, startIndex + nextRIdx);
|
|
6454
|
+
var nextCellObj = {
|
|
6455
|
+
rowKey: targetRowKey,
|
|
6456
|
+
colKey: targetCol.key,
|
|
6457
|
+
rowIndex: startIndex + nextRIdx
|
|
6458
|
+
};
|
|
6459
|
+
setActiveCell(nextCellObj);
|
|
6460
|
+
if (editingCell && targetCol.editable !== false) {
|
|
6461
|
+
setEditingCell(nextCellObj);
|
|
6462
|
+
}
|
|
6463
|
+
}, [interactive, editingCell, activeCell, isDirty, isValid, isSaving, handleSave, paginatedData, newRows, visibleColumns, startIndex]);
|
|
6464
|
+
var renderInteractiveCellInput = React.useCallback(function (column, row, globalIndex, rowKey) {
|
|
6465
|
+
var _row$column$key;
|
|
6466
|
+
var value = pendingEdits[rowKey] && pendingEdits[rowKey][column.key] !== undefined ? pendingEdits[rowKey][column.key] : (_row$column$key = row[column.key]) !== null && _row$column$key !== void 0 ? _row$column$key : "";
|
|
6467
|
+
return jsxRuntime.jsx(FieldInput, {
|
|
6468
|
+
column: column,
|
|
6469
|
+
value: value,
|
|
6470
|
+
onChange: function onChange(newVal) {
|
|
6471
|
+
return handleCellValueChange(rowKey, column.key, newVal);
|
|
6472
|
+
},
|
|
6473
|
+
onKeyDown: handleTableKeyDown,
|
|
6474
|
+
isEditing: true,
|
|
6475
|
+
row: row,
|
|
6476
|
+
rowIndex: globalIndex,
|
|
6477
|
+
autoFocus: (editingCell === null || editingCell === void 0 ? void 0 : editingCell.rowKey) === rowKey && (editingCell === null || editingCell === void 0 ? void 0 : editingCell.colKey) === column.key
|
|
6478
|
+
});
|
|
6479
|
+
}, [pendingEdits, handleCellValueChange, handleTableKeyDown, editingCell]);
|
|
6326
6480
|
// Callbacks
|
|
6327
6481
|
var toggleColumnVisibility = React.useCallback(function (key) {
|
|
6328
6482
|
setColumnsState(function (prev) {
|
|
@@ -6545,11 +6699,14 @@ var Table = function Table(_ref) {
|
|
|
6545
6699
|
onCellClick: handleCellClick,
|
|
6546
6700
|
onCellDoubleClick: handleCellDoubleClick,
|
|
6547
6701
|
renderInteractiveCellInput: renderInteractiveCellInput,
|
|
6548
|
-
invalidCellSet: invalidCellSet
|
|
6702
|
+
invalidCellSet: invalidCellSet,
|
|
6703
|
+
pendingEdits: pendingEdits
|
|
6549
6704
|
};
|
|
6550
6705
|
return jsxRuntime.jsxs("div", {
|
|
6551
6706
|
ref: tableContainerRef,
|
|
6552
|
-
|
|
6707
|
+
tabIndex: interactive ? 0 : undefined,
|
|
6708
|
+
onKeyDown: handleTableKeyDown,
|
|
6709
|
+
className: cn$1("w-full border rounded-lg md:rounded-md outline-none focus:ring-1 focus:ring-primary-400", className),
|
|
6553
6710
|
children: [TheadComponent && typeof TheadComponent === "function" ? jsxRuntime.jsx(TheadComponent, {
|
|
6554
6711
|
columns: columnsState,
|
|
6555
6712
|
data: filteredData
|
|
@@ -6596,15 +6753,26 @@ var Table = function Table(_ref) {
|
|
|
6596
6753
|
onClick: handleSave,
|
|
6597
6754
|
disabled: !isValid || isSaving,
|
|
6598
6755
|
title: !isValid ? "Cannot save: ".concat(((_validationErrors$ = validationErrors[0]) === null || _validationErrors$ === void 0 ? void 0 : _validationErrors$.message) || "Validation failed") : "Save changes",
|
|
6599
|
-
className: cn$1("px-4 py-2 font-medium rounded-lg text-sm flex items-center gap-2 transition-all shadow-sm", isValid ? "bg-
|
|
6756
|
+
className: cn$1("px-4 py-2 font-medium rounded-lg text-sm flex items-center gap-2 transition-all shadow-sm", isValid ? "bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-white cursor-pointer" : "bg-gray-200 text-gray-400 border border-gray-300 cursor-not-allowed opacity-75"),
|
|
6600
6757
|
children: [jsxRuntime.jsx(Save, {
|
|
6601
6758
|
className: "w-4 h-4"
|
|
6602
6759
|
}), jsxRuntime.jsx("span", {
|
|
6603
6760
|
children: isSaving ? "Saving..." : "Save Changes"
|
|
6604
6761
|
}), pendingCount > 0 && jsxRuntime.jsx("span", {
|
|
6605
|
-
className: cn$1("ml-1 px-2 py-0.5 text-xs rounded-full font-bold", isValid ? "bg-
|
|
6762
|
+
className: cn$1("ml-1 px-2 py-0.5 text-xs rounded-full font-bold", isValid ? "bg-primary-700 text-white" : "bg-gray-300 text-gray-600"),
|
|
6606
6763
|
children: pendingCount
|
|
6607
6764
|
})]
|
|
6765
|
+
}), jsxRuntime.jsxs("button", {
|
|
6766
|
+
type: "button",
|
|
6767
|
+
onClick: handleClearChanges,
|
|
6768
|
+
disabled: isSaving,
|
|
6769
|
+
title: "Discard all pending modifications",
|
|
6770
|
+
className: "px-4 py-2 font-medium rounded-lg text-sm flex items-center gap-2 transition-all border border-primary-300 text-primary-700 bg-white hover:bg-primary-50 active:bg-primary-100 cursor-pointer shadow-sm disabled:opacity-50",
|
|
6771
|
+
children: [jsxRuntime.jsx(X, {
|
|
6772
|
+
className: "w-4 h-4 text-primary-600"
|
|
6773
|
+
}), jsxRuntime.jsx("span", {
|
|
6774
|
+
children: "Clear Changes"
|
|
6775
|
+
})]
|
|
6608
6776
|
}), !isValid && validationErrors.length > 0 && jsxRuntime.jsxs("div", {
|
|
6609
6777
|
className: "flex items-center gap-1.5 px-3 py-1.5 bg-warning-50 border border-warning-200 text-warning-800 rounded-md text-xs font-medium",
|
|
6610
6778
|
children: [jsxRuntime.jsx(AlertCircle, {
|
|
@@ -12657,7 +12825,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
12657
12825
|
});
|
|
12658
12826
|
});
|
|
12659
12827
|
|
|
12660
|
-
var _excluded$v = ["id", "name", "checked", "defaultChecked", "onChange", "disabled", "size", "trackClass", "thumbClass", "className", "topLabel", "bottomLabel", "rightLabel", "leftLabel", "ariaLabel"];
|
|
12828
|
+
var _excluded$v = ["id", "name", "checked", "defaultChecked", "onChange", "disabled", "size", "color", "trackClass", "thumbClass", "className", "topLabel", "bottomLabel", "rightLabel", "leftLabel", "ariaLabel"];
|
|
12661
12829
|
function ownKeys$z(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; }
|
|
12662
12830
|
function _objectSpread$z(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$z(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$z(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12663
12831
|
/**
|
|
@@ -12689,6 +12857,52 @@ var SIZE_MAP$2 = {
|
|
|
12689
12857
|
knobTranslate: "translate-x-6"
|
|
12690
12858
|
}
|
|
12691
12859
|
};
|
|
12860
|
+
var COLOR_PRESETS$1 = {
|
|
12861
|
+
primary: {
|
|
12862
|
+
bg: "bg-primary-600",
|
|
12863
|
+
ring: "focus-visible:ring-primary-300"
|
|
12864
|
+
},
|
|
12865
|
+
secondary: {
|
|
12866
|
+
bg: "bg-secondary-600",
|
|
12867
|
+
ring: "focus-visible:ring-secondary-300"
|
|
12868
|
+
},
|
|
12869
|
+
success: {
|
|
12870
|
+
bg: "bg-success-600",
|
|
12871
|
+
ring: "focus-visible:ring-success-300"
|
|
12872
|
+
},
|
|
12873
|
+
green: {
|
|
12874
|
+
bg: "bg-success-600",
|
|
12875
|
+
ring: "focus-visible:ring-success-300"
|
|
12876
|
+
},
|
|
12877
|
+
error: {
|
|
12878
|
+
bg: "bg-error-600",
|
|
12879
|
+
ring: "focus-visible:ring-error-300"
|
|
12880
|
+
},
|
|
12881
|
+
danger: {
|
|
12882
|
+
bg: "bg-error-600",
|
|
12883
|
+
ring: "focus-visible:ring-error-300"
|
|
12884
|
+
},
|
|
12885
|
+
red: {
|
|
12886
|
+
bg: "bg-error-600",
|
|
12887
|
+
ring: "focus-visible:ring-error-300"
|
|
12888
|
+
},
|
|
12889
|
+
warning: {
|
|
12890
|
+
bg: "bg-warning-600",
|
|
12891
|
+
ring: "focus-visible:ring-warning-300"
|
|
12892
|
+
},
|
|
12893
|
+
blue: {
|
|
12894
|
+
bg: "bg-blue-600",
|
|
12895
|
+
ring: "focus-visible:ring-blue-300"
|
|
12896
|
+
},
|
|
12897
|
+
indigo: {
|
|
12898
|
+
bg: "bg-indigo-600",
|
|
12899
|
+
ring: "focus-visible:ring-indigo-300"
|
|
12900
|
+
},
|
|
12901
|
+
purple: {
|
|
12902
|
+
bg: "bg-purple-600",
|
|
12903
|
+
ring: "focus-visible:ring-purple-300"
|
|
12904
|
+
}
|
|
12905
|
+
};
|
|
12692
12906
|
var Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
|
|
12693
12907
|
var id = props.id,
|
|
12694
12908
|
name = props.name,
|
|
@@ -12700,6 +12914,8 @@ var Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
|
|
|
12700
12914
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
12701
12915
|
_props$size = props.size,
|
|
12702
12916
|
size = _props$size === void 0 ? "md" : _props$size,
|
|
12917
|
+
_props$color = props.color,
|
|
12918
|
+
color = _props$color === void 0 ? "primary" : _props$color,
|
|
12703
12919
|
trackClass = props.trackClass,
|
|
12704
12920
|
thumbClass = props.thumbClass,
|
|
12705
12921
|
_props$className = props.className,
|
|
@@ -12735,16 +12951,18 @@ var Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
|
|
|
12735
12951
|
}
|
|
12736
12952
|
};
|
|
12737
12953
|
var sizeStuff = SIZE_MAP$2[size] || SIZE_MAP$2.md;
|
|
12954
|
+
var isPreset = COLOR_PRESETS$1[color];
|
|
12738
12955
|
// Classes for the track (we use inline style for arbitrary trackClass when ON)
|
|
12739
|
-
var trackClasses = cn$1("relative inline-flex items-center rounded-full transition-colors duration-200 ease-in-out", sizeStuff.track, isOn ? "" : "bg-gray-100", disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer", trackClass // Accepting trackClass as a class name
|
|
12956
|
+
var trackClasses = cn$1("relative inline-flex items-center rounded-full transition-colors duration-200 ease-in-out", sizeStuff.track, isOn ? trackClass ? "" : isPreset ? isPreset.bg : "" : "bg-gray-100", disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer", trackClass // Accepting trackClass as a class name
|
|
12740
12957
|
);
|
|
12741
12958
|
// Knob classes (thumb)
|
|
12742
12959
|
var knobBase = cn$1("inline-block rounded-full bg-white shadow transform ring-0 transition-transform duration-200 ease-in-out", sizeStuff.knob, thumbClass // Accepting thumbClass as a class name
|
|
12743
12960
|
);
|
|
12744
12961
|
var knobTransform = isOn ? sizeStuff.knobTranslate : "translate-x-1";
|
|
12745
|
-
var
|
|
12746
|
-
var
|
|
12747
|
-
|
|
12962
|
+
var ringClass = isPreset ? isPreset.ring : "focus-visible:ring-primary-300";
|
|
12963
|
+
var focusClasses = disabled ? "" : "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 ".concat(ringClass);
|
|
12964
|
+
var trackStyle = isOn && !trackClass && !isPreset ? {
|
|
12965
|
+
backgroundColor: color
|
|
12748
12966
|
} : undefined; // Fallback to default trackClass if trackClass is not a class
|
|
12749
12967
|
var accessibleLabel = ariaLabel || rightLabel || leftLabel || topLabel || bottomLabel || "Toggle";
|
|
12750
12968
|
var containerIsColumn = Boolean(topLabel || bottomLabel);
|
|
@@ -13459,7 +13677,7 @@ var Accordion = /*#__PURE__*/React.forwardRef(function Accordion(_ref, ref) {
|
|
|
13459
13677
|
});
|
|
13460
13678
|
Accordion.displayName = "Accordion";
|
|
13461
13679
|
|
|
13462
|
-
var _excluded$s = ["id", "name", "label", "checked", "defaultChecked", "onChange", "disabled", "required", "className", "size", "labelPosition", "value", "ariaLabel", "variant", "indeterminate", "borderColor", "iconClass", "checkedClass"];
|
|
13680
|
+
var _excluded$s = ["id", "name", "label", "checked", "defaultChecked", "onChange", "disabled", "required", "className", "size", "labelPosition", "value", "ariaLabel", "variant", "indeterminate", "borderColor", "color", "iconClass", "checkedClass"];
|
|
13463
13681
|
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; }
|
|
13464
13682
|
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; }
|
|
13465
13683
|
var SIZE_CLASSES = {
|
|
@@ -13479,6 +13697,52 @@ var SIZE_CLASSES = {
|
|
|
13479
13697
|
icon: "w-4 h-4"
|
|
13480
13698
|
}
|
|
13481
13699
|
};
|
|
13700
|
+
var COLOR_PRESETS = {
|
|
13701
|
+
primary: {
|
|
13702
|
+
checked: "peer-checked:bg-primary-600 peer-checked:border-primary-600 peer-checked:text-white",
|
|
13703
|
+
ring: "peer-focus:ring-primary-300"
|
|
13704
|
+
},
|
|
13705
|
+
secondary: {
|
|
13706
|
+
checked: "peer-checked:bg-secondary-600 peer-checked:border-secondary-600 peer-checked:text-white",
|
|
13707
|
+
ring: "peer-focus:ring-secondary-300"
|
|
13708
|
+
},
|
|
13709
|
+
success: {
|
|
13710
|
+
checked: "peer-checked:bg-success-600 peer-checked:border-success-600 peer-checked:text-white",
|
|
13711
|
+
ring: "peer-focus:ring-success-300"
|
|
13712
|
+
},
|
|
13713
|
+
green: {
|
|
13714
|
+
checked: "peer-checked:bg-success-600 peer-checked:border-success-600 peer-checked:text-white",
|
|
13715
|
+
ring: "peer-focus:ring-success-300"
|
|
13716
|
+
},
|
|
13717
|
+
error: {
|
|
13718
|
+
checked: "peer-checked:bg-error-600 peer-checked:border-error-600 peer-checked:text-white",
|
|
13719
|
+
ring: "peer-focus:ring-error-300"
|
|
13720
|
+
},
|
|
13721
|
+
danger: {
|
|
13722
|
+
checked: "peer-checked:bg-error-600 peer-checked:border-error-600 peer-checked:text-white",
|
|
13723
|
+
ring: "peer-focus:ring-error-300"
|
|
13724
|
+
},
|
|
13725
|
+
red: {
|
|
13726
|
+
checked: "peer-checked:bg-error-600 peer-checked:border-error-600 peer-checked:text-white",
|
|
13727
|
+
ring: "peer-focus:ring-error-300"
|
|
13728
|
+
},
|
|
13729
|
+
warning: {
|
|
13730
|
+
checked: "peer-checked:bg-warning-600 peer-checked:border-warning-600 peer-checked:text-white",
|
|
13731
|
+
ring: "peer-focus:ring-warning-300"
|
|
13732
|
+
},
|
|
13733
|
+
blue: {
|
|
13734
|
+
checked: "peer-checked:bg-blue-600 peer-checked:border-blue-600 peer-checked:text-white",
|
|
13735
|
+
ring: "peer-focus:ring-blue-300"
|
|
13736
|
+
},
|
|
13737
|
+
indigo: {
|
|
13738
|
+
checked: "peer-checked:bg-indigo-600 peer-checked:border-indigo-600 peer-checked:text-white",
|
|
13739
|
+
ring: "peer-focus:ring-indigo-300"
|
|
13740
|
+
},
|
|
13741
|
+
purple: {
|
|
13742
|
+
checked: "peer-checked:bg-purple-600 peer-checked:border-purple-600 peer-checked:text-white",
|
|
13743
|
+
ring: "peer-focus:ring-purple-300"
|
|
13744
|
+
}
|
|
13745
|
+
};
|
|
13482
13746
|
var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
13483
13747
|
var _props$wrapperProps;
|
|
13484
13748
|
var id = _ref.id,
|
|
@@ -13504,6 +13768,8 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13504
13768
|
indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
|
|
13505
13769
|
_ref$borderColor = _ref.borderColor,
|
|
13506
13770
|
borderColor = _ref$borderColor === void 0 ? "#ccc" : _ref$borderColor,
|
|
13771
|
+
_ref$color = _ref.color,
|
|
13772
|
+
color = _ref$color === void 0 ? "primary" : _ref$color,
|
|
13507
13773
|
iconClass = _ref.iconClass,
|
|
13508
13774
|
checkedClass = _ref.checkedClass,
|
|
13509
13775
|
props = _objectWithoutProperties$1(_ref, _excluded$s);
|
|
@@ -13537,6 +13803,13 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13537
13803
|
var iconBase = "pointer-events-none transform transition-all duration-150 ease-out";
|
|
13538
13804
|
var iconShown = "opacity-100 scale-100";
|
|
13539
13805
|
var iconHidden = "opacity-0 scale-75";
|
|
13806
|
+
var isPreset = COLOR_PRESETS[color];
|
|
13807
|
+
var colorClasses = isPreset ? "".concat(isPreset.checked, " peer-focus:ring-2 peer-focus:ring-offset-1 ").concat(isPreset.ring) : "peer-focus:ring-2 peer-focus:ring-offset-1 peer-focus:ring-primary-300";
|
|
13808
|
+
var customColorStyle = currentChecked && !isPreset && !checkedClass ? {
|
|
13809
|
+
backgroundColor: color,
|
|
13810
|
+
borderColor: color,
|
|
13811
|
+
color: "#ffffff"
|
|
13812
|
+
} : {};
|
|
13540
13813
|
return jsxRuntime.jsxs("div", _objectSpread$w(_objectSpread$w({
|
|
13541
13814
|
className: wrapperCls
|
|
13542
13815
|
}, (_props$wrapperProps = props === null || props === void 0 ? void 0 : props.wrapperProps) !== null && _props$wrapperProps !== void 0 ? _props$wrapperProps : {}), {}, {
|
|
@@ -13547,7 +13820,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13547
13820
|
}), jsxRuntime.jsxs("div", {
|
|
13548
13821
|
className: boxOuterCls,
|
|
13549
13822
|
style: disabled ? {} : {
|
|
13550
|
-
borderColor: borderColor
|
|
13823
|
+
borderColor: currentChecked && (isPreset || customColorStyle.borderColor) ? undefined : borderColor
|
|
13551
13824
|
},
|
|
13552
13825
|
"aria-disabled": disabled,
|
|
13553
13826
|
children: [jsxRuntime.jsx("input", _objectSpread$w({
|
|
@@ -13566,11 +13839,11 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13566
13839
|
"aria-label": ariaLabel,
|
|
13567
13840
|
"aria-checked": Boolean(currentChecked)
|
|
13568
13841
|
}, props)), jsxRuntime.jsx("div", {
|
|
13569
|
-
className: "pointer-events-none z-0 flex items-center justify-center rounded-sm w-full h-full transition-colors duration-150 ease-in-out " + "
|
|
13842
|
+
className: "pointer-events-none z-0 flex items-center justify-center rounded-sm w-full h-full transition-colors duration-150 ease-in-out " + "".concat(colorClasses, " ") + "".concat(disabled ? "bg-gray-100 border-gray-400 text-primary-400" : "bg-white border-gray-500", " ").concat(checkedClass ? checkedClass : ""),
|
|
13570
13843
|
style: currentChecked && checkedClass ? {
|
|
13571
13844
|
backgroundColor: "",
|
|
13572
13845
|
borderColor: ""
|
|
13573
|
-
} :
|
|
13846
|
+
} : customColorStyle,
|
|
13574
13847
|
"aria-hidden": "true",
|
|
13575
13848
|
children: jsxRuntime.jsx(Check, {
|
|
13576
13849
|
className: "".concat(sizeClass.icon, " ").concat(iconBase, " ").concat(currentChecked ? iconShown : iconHidden, " ").concat(iconClass || ""),
|