@dreamtree-org/twreact-ui 1.1.65 → 1.1.67
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/ai-schema.json +2279 -0
- package/dist/components/core/Table/ActionMenu.d.ts.map +1 -1
- package/dist/components/core/Table/MobileCard.d.ts.map +1 -1
- package/dist/components/core/Table/Table.d.ts +2 -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/components/core/Table/helpers.d.ts +7 -0
- package/dist/components/core/Table/helpers.d.ts.map +1 -1
- package/dist/components/core/Table/index.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +321 -128
- package/dist/index.js +321 -128
- package/dist/types/index.d.ts +16 -6
- package/dist/types/index.d.ts.map +1 -1
- package/mcp/catalog.snapshot.json +12 -6
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -90,17 +90,17 @@ function _iterableToArrayLimit(r, l) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
function _arrayLikeToArray$
|
|
93
|
+
function _arrayLikeToArray$2(r, a) {
|
|
94
94
|
(null == a || a > r.length) && (a = r.length);
|
|
95
95
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
96
96
|
return n;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function _unsupportedIterableToArray$
|
|
99
|
+
function _unsupportedIterableToArray$2(r, a) {
|
|
100
100
|
if (r) {
|
|
101
|
-
if ("string" == typeof r) return _arrayLikeToArray$
|
|
101
|
+
if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
|
|
102
102
|
var t = {}.toString.call(r).slice(8, -1);
|
|
103
|
-
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$
|
|
103
|
+
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$2(r, a) : void 0;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -109,7 +109,7 @@ function _nonIterableRest() {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
function _slicedToArray(r, e) {
|
|
112
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$
|
|
112
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function _objectWithoutPropertiesLoose$1(r, e) {
|
|
@@ -3161,8 +3161,8 @@ function cn$1() {
|
|
|
3161
3161
|
}
|
|
3162
3162
|
|
|
3163
3163
|
var _excluded$A = ["id", "className", "type", "label", "placeholder", "error", "success", "disabled", "required", "clearable", "icon", "iconPosition", "onClear", "showCount", "maxLength", "readOnly", "onChange", "value", "defaultValue"];
|
|
3164
|
-
function ownKeys$
|
|
3165
|
-
function _objectSpread$
|
|
3164
|
+
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; }
|
|
3165
|
+
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; }
|
|
3166
3166
|
var Input = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
3167
3167
|
var _ref$current$value2, _ref$current;
|
|
3168
3168
|
var id = props.id,
|
|
@@ -3277,7 +3277,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
3277
3277
|
className: "text-primary-400",
|
|
3278
3278
|
children: icon
|
|
3279
3279
|
})
|
|
3280
|
-
}), jsxRuntime.jsx("input", _objectSpread$
|
|
3280
|
+
}), jsxRuntime.jsx("input", _objectSpread$F({
|
|
3281
3281
|
id: inputId,
|
|
3282
3282
|
ref: ref,
|
|
3283
3283
|
type: inputType,
|
|
@@ -3338,8 +3338,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
3338
3338
|
});
|
|
3339
3339
|
|
|
3340
3340
|
var _excluded$z = ["className", "variant", "size", "disabled", "loading", "children", "leftIcon", "rightIcon", "fullWidth"];
|
|
3341
|
-
function ownKeys$
|
|
3342
|
-
function _objectSpread$
|
|
3341
|
+
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; }
|
|
3342
|
+
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; }
|
|
3343
3343
|
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
3344
3344
|
var className = _ref.className,
|
|
3345
3345
|
_ref$variant = _ref.variant,
|
|
@@ -3369,7 +3369,7 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3369
3369
|
// Full width
|
|
3370
3370
|
'w-full': fullWidth
|
|
3371
3371
|
}, className);
|
|
3372
|
-
return jsxRuntime.jsxs("button", _objectSpread$
|
|
3372
|
+
return jsxRuntime.jsxs("button", _objectSpread$E(_objectSpread$E({
|
|
3373
3373
|
ref: ref,
|
|
3374
3374
|
className: baseClasses,
|
|
3375
3375
|
disabled: disabled || loading
|
|
@@ -3388,7 +3388,7 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
3388
3388
|
Button.displayName = 'Button';
|
|
3389
3389
|
|
|
3390
3390
|
function _arrayWithoutHoles$1(r) {
|
|
3391
|
-
if (Array.isArray(r)) return _arrayLikeToArray$
|
|
3391
|
+
if (Array.isArray(r)) return _arrayLikeToArray$2(r);
|
|
3392
3392
|
}
|
|
3393
3393
|
|
|
3394
3394
|
function _iterableToArray$1(r) {
|
|
@@ -3400,12 +3400,12 @@ function _nonIterableSpread$1() {
|
|
|
3400
3400
|
}
|
|
3401
3401
|
|
|
3402
3402
|
function _toConsumableArray$1(r) {
|
|
3403
|
-
return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$
|
|
3403
|
+
return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread$1();
|
|
3404
3404
|
}
|
|
3405
3405
|
|
|
3406
3406
|
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"];
|
|
3407
|
-
function ownKeys$
|
|
3408
|
-
function _objectSpread$
|
|
3407
|
+
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; }
|
|
3408
|
+
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; }
|
|
3409
3409
|
/**
|
|
3410
3410
|
* Enhanced Select component (debounce removed)
|
|
3411
3411
|
* - Supports single and multi select
|
|
@@ -3426,7 +3426,7 @@ var flattenGroups = function flattenGroups() {
|
|
|
3426
3426
|
return groups.reduce(function (acc, g) {
|
|
3427
3427
|
var groupLabel = g.label;
|
|
3428
3428
|
g.options.forEach(function (opt) {
|
|
3429
|
-
return acc.push(_objectSpread$
|
|
3429
|
+
return acc.push(_objectSpread$D(_objectSpread$D({}, opt), {}, {
|
|
3430
3430
|
_group: groupLabel
|
|
3431
3431
|
}));
|
|
3432
3432
|
});
|
|
@@ -3522,7 +3522,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3522
3522
|
var flatOptions = React.useMemo(function () {
|
|
3523
3523
|
if (grouped) return flattenGroups(options);
|
|
3524
3524
|
return options.map(function (opt) {
|
|
3525
|
-
return _objectSpread$
|
|
3525
|
+
return _objectSpread$D({}, opt);
|
|
3526
3526
|
});
|
|
3527
3527
|
}, [options, grouped]);
|
|
3528
3528
|
var selectedValues = multiSelect ? Array.isArray(value) ? value : [] : value;
|
|
@@ -3547,7 +3547,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3547
3547
|
}
|
|
3548
3548
|
if (grouped) {
|
|
3549
3549
|
return options.map(function (g) {
|
|
3550
|
-
return _objectSpread$
|
|
3550
|
+
return _objectSpread$D(_objectSpread$D({}, g), {}, {
|
|
3551
3551
|
options: g.options.filter(function (o) {
|
|
3552
3552
|
return o.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
3553
3553
|
})
|
|
@@ -3817,7 +3817,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3817
3817
|
className: "text-xs border border-slate-200 p-0.5 rounded-md cursor-pointer hover:bg-gray-100",
|
|
3818
3818
|
onClick: function onClick() {
|
|
3819
3819
|
return setCollapsedGroups(function (prev) {
|
|
3820
|
-
return _objectSpread$
|
|
3820
|
+
return _objectSpread$D(_objectSpread$D({}, prev), {}, _defineProperty$4({}, group.label, !prev[group.label]));
|
|
3821
3821
|
});
|
|
3822
3822
|
},
|
|
3823
3823
|
children: jsxRuntime.jsx(ChevronDown, {
|
|
@@ -3911,7 +3911,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3911
3911
|
}), jsxRuntime.jsxs("div", {
|
|
3912
3912
|
ref: selectRef,
|
|
3913
3913
|
className: "relative",
|
|
3914
|
-
children: [jsxRuntime.jsxs("button", _objectSpread$
|
|
3914
|
+
children: [jsxRuntime.jsxs("button", _objectSpread$D(_objectSpread$D({
|
|
3915
3915
|
type: "button",
|
|
3916
3916
|
"aria-haspopup": "listbox",
|
|
3917
3917
|
"aria-expanded": isOpen,
|
|
@@ -3978,7 +3978,7 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
3978
3978
|
// escapes any ancestor overflow:hidden|auto|scroll. Coordinates
|
|
3979
3979
|
// are anchored to the trigger's viewport rect; width matches the
|
|
3980
3980
|
// trigger; maxHeight is driven by available space.
|
|
3981
|
-
style: _objectSpread$
|
|
3981
|
+
style: _objectSpread$D({
|
|
3982
3982
|
left: menuCoords ? "".concat(menuCoords.left, "px") : undefined,
|
|
3983
3983
|
top: menuCoords ? "".concat(menuCoords.top, "px") : undefined,
|
|
3984
3984
|
width: menuCoords ? "".concat(menuCoords.width, "px") : undefined
|
|
@@ -4065,6 +4065,11 @@ var DEFAULT_ACTIONS = [{
|
|
|
4065
4065
|
})
|
|
4066
4066
|
}];
|
|
4067
4067
|
|
|
4068
|
+
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; }
|
|
4069
|
+
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; }
|
|
4070
|
+
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; } } }; }
|
|
4071
|
+
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; } }
|
|
4072
|
+
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; }
|
|
4068
4073
|
/**
|
|
4069
4074
|
* Generate a unique key for a row based on id, _id, or index
|
|
4070
4075
|
*/
|
|
@@ -4074,6 +4079,116 @@ var getRowKey = function getRowKey(row, globalIndex) {
|
|
|
4074
4079
|
if (row._id !== undefined && row._id !== null) return String(row._id);
|
|
4075
4080
|
return String(globalIndex);
|
|
4076
4081
|
};
|
|
4082
|
+
/**
|
|
4083
|
+
* Resolve a value that may be supplied directly or as a per-row producer.
|
|
4084
|
+
* Used for an action's `label`, `icon`, `hidden` and `disabled`.
|
|
4085
|
+
*/
|
|
4086
|
+
var callIfFn = function callIfFn(value, row, index) {
|
|
4087
|
+
return typeof value === "function" ? value(row, index) : value;
|
|
4088
|
+
};
|
|
4089
|
+
/**
|
|
4090
|
+
* Does THIS row get an expand toggle?
|
|
4091
|
+
* `hasDetails` is either a boolean (every row) or a `(row, index)` predicate.
|
|
4092
|
+
*/
|
|
4093
|
+
var rowHasDetails = function rowHasDetails(hasDetails, row, index) {
|
|
4094
|
+
return typeof hasDetails === "function" ? !!hasDetails(row, index) : !!hasDetails;
|
|
4095
|
+
};
|
|
4096
|
+
/**
|
|
4097
|
+
* Best-effort accessible name for an action. `label` may be an arbitrary
|
|
4098
|
+
* ReactNode, so fall back to `name` and finally to a generic string.
|
|
4099
|
+
*/
|
|
4100
|
+
var getActionLabelText = function getActionLabelText(action) {
|
|
4101
|
+
return typeof (action === null || action === void 0 ? void 0 : action.label) === "string" && action.label.trim() || typeof (action === null || action === void 0 ? void 0 : action.name) === "string" && action.name.trim() || "Action";
|
|
4102
|
+
};
|
|
4103
|
+
/**
|
|
4104
|
+
* Patch `defaults` with `overrides`, matched by `name`.
|
|
4105
|
+
*
|
|
4106
|
+
* Result order is the defaults' order, then any unmatched or unnamed overrides
|
|
4107
|
+
* appended. Each match is a shallow spread, so `{ name: "edit", onClick }`
|
|
4108
|
+
* keeps the default's `label` and `icon`, and `{ name: "delete", hidden: true }`
|
|
4109
|
+
* removes a default without needing a dedicated API.
|
|
4110
|
+
*
|
|
4111
|
+
* @param {Array} overrides consumer-supplied actions
|
|
4112
|
+
* @param {Array} defaults the built-in action set
|
|
4113
|
+
* @returns {Array}
|
|
4114
|
+
*/
|
|
4115
|
+
var mergeDefaultActions = function mergeDefaultActions(overrides, defaults) {
|
|
4116
|
+
if (!Array.isArray(overrides)) return defaults;
|
|
4117
|
+
if (!Array.isArray(defaults) || defaults.length === 0) return overrides;
|
|
4118
|
+
var byName = new Map();
|
|
4119
|
+
var _iterator = _createForOfIteratorHelper$1(overrides),
|
|
4120
|
+
_step;
|
|
4121
|
+
try {
|
|
4122
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4123
|
+
var action = _step.value;
|
|
4124
|
+
if (action && action.name) byName.set(action.name, action);
|
|
4125
|
+
}
|
|
4126
|
+
} catch (err) {
|
|
4127
|
+
_iterator.e(err);
|
|
4128
|
+
} finally {
|
|
4129
|
+
_iterator.f();
|
|
4130
|
+
}
|
|
4131
|
+
var merged = defaults.map(function (d) {
|
|
4132
|
+
return d !== null && d !== void 0 && d.name && byName.has(d.name) ? _objectSpread$C(_objectSpread$C({}, d), byName.get(d.name)) : d;
|
|
4133
|
+
});
|
|
4134
|
+
var defaultNames = new Set(defaults.map(function (d) {
|
|
4135
|
+
return d === null || d === void 0 ? void 0 : d.name;
|
|
4136
|
+
}).filter(Boolean));
|
|
4137
|
+
var appended = overrides.filter(function (a) {
|
|
4138
|
+
return a && (!a.name || !defaultNames.has(a.name));
|
|
4139
|
+
});
|
|
4140
|
+
return [].concat(_toConsumableArray$1(merged), _toConsumableArray$1(appended));
|
|
4141
|
+
};
|
|
4142
|
+
var EMPTY_RESOLVED = Object.freeze({
|
|
4143
|
+
inlineActions: Object.freeze([]),
|
|
4144
|
+
menuActions: Object.freeze([])
|
|
4145
|
+
});
|
|
4146
|
+
/**
|
|
4147
|
+
* Normalize the `actions` prop for a single row.
|
|
4148
|
+
*
|
|
4149
|
+
* Accepts either an array or a `(row, index) => array` producer. Entries whose
|
|
4150
|
+
* `hidden` resolves truthy are dropped; `label`/`icon` are resolved against the
|
|
4151
|
+
* row; `disabled` is coerced to a boolean; `inline` entries are split out so
|
|
4152
|
+
* they can render as icon buttons in the cell rather than inside the menu.
|
|
4153
|
+
*
|
|
4154
|
+
* `render` is deliberately passed through untouched — it is already a
|
|
4155
|
+
* `(row) => ReactNode` renderer with its own contract, not a value producer.
|
|
4156
|
+
*
|
|
4157
|
+
* @param {Array|Function} actions array, or (row, index) => array
|
|
4158
|
+
* @param {object} row
|
|
4159
|
+
* @param {number} index the GLOBAL row index (startIndex + rowIndexInPage)
|
|
4160
|
+
* @returns {{ inlineActions: Array, menuActions: Array }}
|
|
4161
|
+
*/
|
|
4162
|
+
var resolveActions = function resolveActions(actions, row, index) {
|
|
4163
|
+
var source = typeof actions === "function" ? actions(row, index) : actions;
|
|
4164
|
+
if (!Array.isArray(source) || source.length === 0) return EMPTY_RESOLVED;
|
|
4165
|
+
var inlineActions = [];
|
|
4166
|
+
var menuActions = [];
|
|
4167
|
+
var _iterator2 = _createForOfIteratorHelper$1(source),
|
|
4168
|
+
_step2;
|
|
4169
|
+
try {
|
|
4170
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4171
|
+
var action = _step2.value;
|
|
4172
|
+
if (!action || _typeof$4(action) !== "object") continue;
|
|
4173
|
+
if (callIfFn(action.hidden, row, index)) continue;
|
|
4174
|
+
var resolved = _objectSpread$C(_objectSpread$C({}, action), {}, {
|
|
4175
|
+
label: callIfFn(action.label, row, index),
|
|
4176
|
+
icon: callIfFn(action.icon, row, index),
|
|
4177
|
+
disabled: !!callIfFn(action.disabled, row, index),
|
|
4178
|
+
inline: !!action.inline
|
|
4179
|
+
});
|
|
4180
|
+
(resolved.inline ? inlineActions : menuActions).push(resolved);
|
|
4181
|
+
}
|
|
4182
|
+
} catch (err) {
|
|
4183
|
+
_iterator2.e(err);
|
|
4184
|
+
} finally {
|
|
4185
|
+
_iterator2.f();
|
|
4186
|
+
}
|
|
4187
|
+
return {
|
|
4188
|
+
inlineActions: inlineActions,
|
|
4189
|
+
menuActions: menuActions
|
|
4190
|
+
};
|
|
4191
|
+
};
|
|
4077
4192
|
|
|
4078
4193
|
/**
|
|
4079
4194
|
* Custom hook to detect clicks outside of specified refs
|
|
@@ -4385,23 +4500,6 @@ function ActionMenu(_ref) {
|
|
|
4385
4500
|
var maxMenuHeight = 320;
|
|
4386
4501
|
var minMenuHeight = 80;
|
|
4387
4502
|
var margin = 8;
|
|
4388
|
-
React.useLayoutEffect(function () {
|
|
4389
|
-
computePosition();
|
|
4390
|
-
var handleResize = function handleResize() {
|
|
4391
|
-
window.requestAnimationFrame(function () {
|
|
4392
|
-
return computePosition();
|
|
4393
|
-
});
|
|
4394
|
-
};
|
|
4395
|
-
var handleScroll = function handleScroll() {
|
|
4396
|
-
onClose === null || onClose === void 0 || onClose();
|
|
4397
|
-
};
|
|
4398
|
-
window.addEventListener("resize", handleResize);
|
|
4399
|
-
window.addEventListener("scroll", handleScroll, true);
|
|
4400
|
-
return function () {
|
|
4401
|
-
window.removeEventListener("resize", handleResize);
|
|
4402
|
-
window.removeEventListener("scroll", handleScroll, true);
|
|
4403
|
-
};
|
|
4404
|
-
}, [anchorEl, actions, menuRef, onClose]);
|
|
4405
4503
|
var computePosition = function computePosition() {
|
|
4406
4504
|
if (!anchorEl || typeof window === "undefined") return;
|
|
4407
4505
|
var rect = anchorEl.getBoundingClientRect();
|
|
@@ -4452,25 +4550,30 @@ function ActionMenu(_ref) {
|
|
|
4452
4550
|
transformOrigin: transformOrigin,
|
|
4453
4551
|
maxHeight: allowedMaxHeight,
|
|
4454
4552
|
width: menuWidth,
|
|
4455
|
-
opacity:
|
|
4553
|
+
opacity: 1
|
|
4456
4554
|
});
|
|
4457
4555
|
};
|
|
4458
|
-
//
|
|
4556
|
+
// Measure & position before paint. A single effect owns both listeners:
|
|
4557
|
+
// resize repositions the menu, scroll closes it (repositioning a portaled
|
|
4558
|
+
// menu against a scrolling ancestor is not worth the jank).
|
|
4459
4559
|
React.useLayoutEffect(function () {
|
|
4460
4560
|
computePosition();
|
|
4461
|
-
var
|
|
4561
|
+
var handleResize = function handleResize() {
|
|
4462
4562
|
window.requestAnimationFrame(function () {
|
|
4463
4563
|
return computePosition();
|
|
4464
4564
|
});
|
|
4465
4565
|
};
|
|
4466
|
-
|
|
4467
|
-
|
|
4566
|
+
var handleScroll = function handleScroll() {
|
|
4567
|
+
onClose === null || onClose === void 0 || onClose();
|
|
4568
|
+
};
|
|
4569
|
+
window.addEventListener("resize", handleResize);
|
|
4570
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
4468
4571
|
return function () {
|
|
4469
|
-
window.removeEventListener("resize",
|
|
4470
|
-
window.removeEventListener("scroll",
|
|
4572
|
+
window.removeEventListener("resize", handleResize);
|
|
4573
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
4471
4574
|
};
|
|
4472
4575
|
// recompute when anchor or actions change (content height may change)
|
|
4473
|
-
}, [anchorEl, actions, menuRef]);
|
|
4576
|
+
}, [anchorEl, actions, menuRef, onClose]);
|
|
4474
4577
|
// Render into body
|
|
4475
4578
|
return /*#__PURE__*/ReactDOM.createPortal(jsxRuntime.jsx("div", {
|
|
4476
4579
|
ref: menuRef,
|
|
@@ -4492,32 +4595,34 @@ function ActionMenu(_ref) {
|
|
|
4492
4595
|
children: !Array.isArray(actions) || actions.length === 0 ? jsxRuntime.jsx("div", {
|
|
4493
4596
|
className: "px-3 py-2 text-sm text-primary-500",
|
|
4494
4597
|
children: "No actions"
|
|
4495
|
-
}) : actions.map(function (action) {
|
|
4598
|
+
}) : actions.map(function (action, idx) {
|
|
4599
|
+
var _action$name;
|
|
4600
|
+
var isDisabled = !!action.disabled;
|
|
4496
4601
|
return jsxRuntime.jsx("div", {
|
|
4497
4602
|
className: "px-1",
|
|
4498
|
-
children:
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
onClose === null || onClose === void 0 || onClose();
|
|
4504
|
-
},
|
|
4505
|
-
children: action.render(row)
|
|
4506
|
-
}) : jsxRuntime.jsxs("button", {
|
|
4507
|
-
className: cn$1("w-full text-left px-3 py-2 text-sm opacity-75 hover:opacity-100 flex items-center gap-2 rounded-md", menuBg, menuItemHover),
|
|
4603
|
+
children: jsxRuntime.jsx("button", {
|
|
4604
|
+
type: "button",
|
|
4605
|
+
disabled: isDisabled,
|
|
4606
|
+
"aria-disabled": isDisabled || undefined,
|
|
4607
|
+
className: cn$1("w-full text-left px-3 py-2 text-sm flex items-center gap-2 rounded-md", menuBg, isDisabled ? "opacity-50 cursor-not-allowed" : ["opacity-75 hover:opacity-100", menuItemHover]),
|
|
4508
4608
|
onClick: function onClick(e) {
|
|
4509
4609
|
e.stopPropagation();
|
|
4610
|
+
// Belt-and-braces: `action.render` output may contain its
|
|
4611
|
+
// own clickable content that bypasses the `disabled` attr.
|
|
4612
|
+
if (isDisabled) return;
|
|
4510
4613
|
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4511
4614
|
onClose === null || onClose === void 0 || onClose();
|
|
4512
4615
|
},
|
|
4513
|
-
children:
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4616
|
+
children: action.render ? action.render(row) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
4617
|
+
children: [action.icon && jsxRuntime.jsx("span", {
|
|
4618
|
+
className: "inline-flex",
|
|
4619
|
+
children: action.icon
|
|
4620
|
+
}), jsxRuntime.jsx("span", {
|
|
4621
|
+
children: action.label
|
|
4622
|
+
})]
|
|
4623
|
+
})
|
|
4519
4624
|
})
|
|
4520
|
-
}, action.name);
|
|
4625
|
+
}, (_action$name = action.name) !== null && _action$name !== void 0 ? _action$name : "action-".concat(idx));
|
|
4521
4626
|
})
|
|
4522
4627
|
})
|
|
4523
4628
|
}), document.body);
|
|
@@ -4538,6 +4643,7 @@ function TableRow(_ref) {
|
|
|
4538
4643
|
theme = _ref.theme,
|
|
4539
4644
|
onRowClick = _ref.onRowClick,
|
|
4540
4645
|
hasDetails = _ref.hasDetails,
|
|
4646
|
+
hasDetailsColumn = _ref.hasDetailsColumn,
|
|
4541
4647
|
showSerial = _ref.showSerial,
|
|
4542
4648
|
selectable = _ref.selectable,
|
|
4543
4649
|
visibleColumns = _ref.visibleColumns,
|
|
@@ -4561,6 +4667,15 @@ function TableRow(_ref) {
|
|
|
4561
4667
|
var actionCellKey = "actions-".concat(key);
|
|
4562
4668
|
var isSelected = selectedRows.has(key);
|
|
4563
4669
|
var isExpanded = expandedRows.has(key);
|
|
4670
|
+
// Only this row's actions are resolved. Memoized so that opening one row's
|
|
4671
|
+
// menu (which re-renders every row) does not re-invoke a function-valued
|
|
4672
|
+
// `actions` prop for all the other rows.
|
|
4673
|
+
var _React$useMemo = React.useMemo(function () {
|
|
4674
|
+
return resolveActions(actionsToUse, row, globalIndex);
|
|
4675
|
+
}, [actionsToUse, row, globalIndex]),
|
|
4676
|
+
inlineActions = _React$useMemo.inlineActions,
|
|
4677
|
+
menuActions = _React$useMemo.menuActions;
|
|
4678
|
+
var showDetailsToggle = rowHasDetails(hasDetails, row, globalIndex);
|
|
4564
4679
|
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4565
4680
|
row: row,
|
|
4566
4681
|
rowIndex: globalIndex
|
|
@@ -4580,14 +4695,16 @@ function TableRow(_ref) {
|
|
|
4580
4695
|
onClick: function onClick() {
|
|
4581
4696
|
return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, globalIndex);
|
|
4582
4697
|
},
|
|
4583
|
-
children: [
|
|
4698
|
+
children: [hasDetailsColumn && jsxRuntime.jsx("td", {
|
|
4584
4699
|
className: "px-4 py-4 text-sm",
|
|
4585
|
-
children: jsxRuntime.jsx("button", {
|
|
4700
|
+
children: showDetailsToggle && jsxRuntime.jsx("button", {
|
|
4701
|
+
type: "button",
|
|
4586
4702
|
onClick: function onClick(e) {
|
|
4587
4703
|
e.stopPropagation();
|
|
4588
4704
|
toggleExpandRow(row, rowIndexInPage);
|
|
4589
4705
|
},
|
|
4590
4706
|
"aria-expanded": isExpanded,
|
|
4707
|
+
"aria-label": isExpanded ? "Collapse row details" : "Expand row details",
|
|
4591
4708
|
className: "p-1 rounded hover:bg-gray-100",
|
|
4592
4709
|
children: isExpanded ? "▾" : "▸"
|
|
4593
4710
|
})
|
|
@@ -4627,36 +4744,58 @@ function TableRow(_ref) {
|
|
|
4627
4744
|
return e.stopPropagation();
|
|
4628
4745
|
},
|
|
4629
4746
|
children: jsxRuntime.jsxs("div", {
|
|
4630
|
-
className: "
|
|
4631
|
-
children: [
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
className: "
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4747
|
+
className: "flex items-center justify-end gap-1",
|
|
4748
|
+
children: [inlineActions.map(function (action, idx) {
|
|
4749
|
+
var _action$icon, _action$name;
|
|
4750
|
+
var actionLabel = getActionLabelText(action);
|
|
4751
|
+
return jsxRuntime.jsx("button", {
|
|
4752
|
+
type: "button",
|
|
4753
|
+
title: actionLabel,
|
|
4754
|
+
"aria-label": actionLabel,
|
|
4755
|
+
disabled: action.disabled,
|
|
4756
|
+
onClick: function onClick(e) {
|
|
4757
|
+
e.stopPropagation();
|
|
4758
|
+
if (action.disabled) return;
|
|
4759
|
+
handleOnAction(action, row);
|
|
4760
|
+
},
|
|
4761
|
+
className: cn$1("p-1 rounded", action.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-100"),
|
|
4762
|
+
children: action.render ? action.render(row) : (_action$icon = action.icon) !== null && _action$icon !== void 0 ? _action$icon : jsxRuntime.jsx("span", {
|
|
4763
|
+
className: "text-xs",
|
|
4764
|
+
children: actionLabel
|
|
4765
|
+
})
|
|
4766
|
+
}, (_action$name = action.name) !== null && _action$name !== void 0 ? _action$name : "inline-".concat(idx));
|
|
4767
|
+
}), menuActions.length > 0 && jsxRuntime.jsxs("div", {
|
|
4768
|
+
className: "relative inline-block",
|
|
4769
|
+
children: [jsxRuntime.jsx("button", {
|
|
4770
|
+
ref: function ref(el) {
|
|
4771
|
+
if (el) {
|
|
4772
|
+
actionButtonRefs.current[actionCellKey] = el;
|
|
4773
|
+
}
|
|
4774
|
+
},
|
|
4775
|
+
onClick: function onClick(e) {
|
|
4776
|
+
return toggleActions(e, actionCellKey, row);
|
|
4777
|
+
},
|
|
4778
|
+
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
4779
|
+
className: "p-1 rounded hover:bg-gray-100",
|
|
4780
|
+
title: "Actions",
|
|
4781
|
+
children: jsxRuntime.jsx(MoreVertical, {
|
|
4782
|
+
className: "h-4 w-4"
|
|
4783
|
+
})
|
|
4784
|
+
}), activeActionRowKey === actionCellKey && jsxRuntime.jsx(ActionMenu, {
|
|
4785
|
+
actions: menuActions,
|
|
4786
|
+
row: row,
|
|
4787
|
+
onAction: function onAction(action) {
|
|
4788
|
+
return handleOnAction(action, row);
|
|
4789
|
+
},
|
|
4790
|
+
menuRef: actionMenuRef,
|
|
4791
|
+
anchorEl: activeAnchorEl,
|
|
4792
|
+
onClose: closeActionMenu,
|
|
4793
|
+
theme: theme
|
|
4794
|
+
})]
|
|
4656
4795
|
})]
|
|
4657
4796
|
})
|
|
4658
4797
|
})]
|
|
4659
|
-
}),
|
|
4798
|
+
}), showDetailsToggle && isExpanded && DetailsComponent && jsxRuntime.jsx("tr", {
|
|
4660
4799
|
children: jsxRuntime.jsx("td", {
|
|
4661
4800
|
colSpan: visibleCount,
|
|
4662
4801
|
className: cn$1(_defineProperty$4(_defineProperty$4({
|
|
@@ -4708,6 +4847,14 @@ function MobileCard(_ref) {
|
|
|
4708
4847
|
var actionCellKey = "actions-".concat(key);
|
|
4709
4848
|
var isSelected = selectedRows.has(key);
|
|
4710
4849
|
var isExpanded = expandedRows.has(key);
|
|
4850
|
+
var _React$useMemo = React.useMemo(function () {
|
|
4851
|
+
return resolveActions(actionsToUse, row, globalIndex);
|
|
4852
|
+
}, [actionsToUse, row, globalIndex]),
|
|
4853
|
+
inlineActions = _React$useMemo.inlineActions,
|
|
4854
|
+
menuActions = _React$useMemo.menuActions;
|
|
4855
|
+
// Unlike the desktop row there is no column grid to keep aligned, so a
|
|
4856
|
+
// non-qualifying row simply renders no toggle and no placeholder.
|
|
4857
|
+
var showDetailsToggle = rowHasDetails(hasDetails, row, globalIndex);
|
|
4711
4858
|
var extraRowClass = typeof rowClass === "function" ? rowClass({
|
|
4712
4859
|
row: row,
|
|
4713
4860
|
rowIndex: globalIndex
|
|
@@ -4730,12 +4877,14 @@ function MobileCard(_ref) {
|
|
|
4730
4877
|
className: "flex items-center justify-between p-4 border-b bg-gray-50",
|
|
4731
4878
|
children: [jsxRuntime.jsxs("div", {
|
|
4732
4879
|
className: "flex items-center gap-3",
|
|
4733
|
-
children: [
|
|
4880
|
+
children: [showDetailsToggle && jsxRuntime.jsx("button", {
|
|
4881
|
+
type: "button",
|
|
4734
4882
|
onClick: function onClick(e) {
|
|
4735
4883
|
e.stopPropagation();
|
|
4736
4884
|
toggleExpandRow(row, rowIndexInPage);
|
|
4737
4885
|
},
|
|
4738
4886
|
"aria-expanded": isExpanded,
|
|
4887
|
+
"aria-label": isExpanded ? "Collapse row details" : "Expand row details",
|
|
4739
4888
|
className: "p-1 rounded hover:bg-gray-200",
|
|
4740
4889
|
children: isExpanded ? "▾" : "▸"
|
|
4741
4890
|
}), selectable && jsxRuntime.jsx("input", {
|
|
@@ -4754,32 +4903,56 @@ function MobileCard(_ref) {
|
|
|
4754
4903
|
children: ["#", globalIndex + 1]
|
|
4755
4904
|
})]
|
|
4756
4905
|
}), withAction && jsxRuntime.jsxs("div", {
|
|
4757
|
-
className: "
|
|
4758
|
-
children: [
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
},
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4906
|
+
className: "flex items-center gap-1",
|
|
4907
|
+
children: [inlineActions.map(function (action, idx) {
|
|
4908
|
+
var _action$icon, _action$name;
|
|
4909
|
+
var actionLabel = getActionLabelText(action);
|
|
4910
|
+
return jsxRuntime.jsx("button", {
|
|
4911
|
+
type: "button",
|
|
4912
|
+
title: actionLabel,
|
|
4913
|
+
"aria-label": actionLabel,
|
|
4914
|
+
disabled: action.disabled,
|
|
4915
|
+
onClick: function onClick(e) {
|
|
4916
|
+
// The card root binds onRowClick and there is no stopping
|
|
4917
|
+
// ancestor here, unlike the desktop actions <td>.
|
|
4918
|
+
e.stopPropagation();
|
|
4919
|
+
if (action.disabled) return;
|
|
4920
|
+
handleOnAction(action, row);
|
|
4921
|
+
},
|
|
4922
|
+
className: cn$1("p-1.5 rounded", action.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-200"),
|
|
4923
|
+
children: action.render ? action.render(row) : (_action$icon = action.icon) !== null && _action$icon !== void 0 ? _action$icon : jsxRuntime.jsx("span", {
|
|
4924
|
+
className: "text-xs",
|
|
4925
|
+
children: actionLabel
|
|
4926
|
+
})
|
|
4927
|
+
}, (_action$name = action.name) !== null && _action$name !== void 0 ? _action$name : "inline-".concat(idx));
|
|
4928
|
+
}), menuActions.length > 0 && jsxRuntime.jsxs("div", {
|
|
4929
|
+
className: "relative",
|
|
4930
|
+
children: [jsxRuntime.jsx("button", {
|
|
4931
|
+
ref: function ref(el) {
|
|
4932
|
+
if (el) {
|
|
4933
|
+
actionButtonRefs.current[actionCellKey] = el;
|
|
4934
|
+
}
|
|
4935
|
+
},
|
|
4936
|
+
onClick: function onClick(e) {
|
|
4937
|
+
return toggleActions(e, actionCellKey, row);
|
|
4938
|
+
},
|
|
4939
|
+
"aria-expanded": activeActionRowKey === actionCellKey,
|
|
4940
|
+
className: "p-1.5 rounded hover:bg-gray-200",
|
|
4941
|
+
title: "Actions",
|
|
4942
|
+
children: jsxRuntime.jsx(MoreVertical, {
|
|
4943
|
+
className: "h-4 w-4"
|
|
4944
|
+
})
|
|
4945
|
+
}), activeActionRowKey === actionCellKey && jsxRuntime.jsx(ActionMenu, {
|
|
4946
|
+
actions: menuActions,
|
|
4947
|
+
row: row,
|
|
4948
|
+
onAction: function onAction(action) {
|
|
4949
|
+
return handleOnAction(action, row);
|
|
4950
|
+
},
|
|
4951
|
+
menuRef: actionMenuRef,
|
|
4952
|
+
anchorEl: activeAnchorEl,
|
|
4953
|
+
onClose: closeActionMenu,
|
|
4954
|
+
theme: theme
|
|
4955
|
+
})]
|
|
4783
4956
|
})]
|
|
4784
4957
|
})]
|
|
4785
4958
|
}), jsxRuntime.jsx("div", {
|
|
@@ -4803,7 +4976,7 @@ function MobileCard(_ref) {
|
|
|
4803
4976
|
})]
|
|
4804
4977
|
}, column.key);
|
|
4805
4978
|
})
|
|
4806
|
-
}),
|
|
4979
|
+
}), showDetailsToggle && isExpanded && DetailsComponent && jsxRuntime.jsx("div", {
|
|
4807
4980
|
className: "border-t bg-gray-50 p-4",
|
|
4808
4981
|
children: jsxRuntime.jsx(DetailsComponent, {
|
|
4809
4982
|
row: row,
|
|
@@ -4813,7 +4986,7 @@ function MobileCard(_ref) {
|
|
|
4813
4986
|
}, key);
|
|
4814
4987
|
}
|
|
4815
4988
|
|
|
4816
|
-
var _excluded$x = ["data", "columns", "sortable", "filterable", "selectable", "pagination", "pageSize", "onSort", "onFilter", "onFetch", "onFilterChange", "onSelectionChange", "onRowClick", "hasDetails", "DetailsComponent", "className", "withAction", "onAction", "actions", "showSerial", "cellClass", "rowClass", "globalSearch", "limitOptions", "showLimitSelector", "onLimitChange", "showReloadButton", "renderReloadButton", "onReload", "stripedRows", "theme", "responsiveBreakpoint", "serverSide", "totalRecords", "pageNumber", "onPageChange", "TheadComponent", "TfootComponent"];
|
|
4989
|
+
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"];
|
|
4817
4990
|
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; }
|
|
4818
4991
|
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; }
|
|
4819
4992
|
var DEFAULT_DATA = [];
|
|
@@ -4855,6 +5028,8 @@ var Table = function Table(_ref) {
|
|
|
4855
5028
|
withAction = _ref$withAction === void 0 ? true : _ref$withAction,
|
|
4856
5029
|
onAction = _ref.onAction,
|
|
4857
5030
|
actions = _ref.actions,
|
|
5031
|
+
_ref$replaceDefaultAc = _ref.replaceDefaultActions,
|
|
5032
|
+
replaceDefaultActions = _ref$replaceDefaultAc === void 0 ? false : _ref$replaceDefaultAc,
|
|
4858
5033
|
_ref$showSerial = _ref.showSerial,
|
|
4859
5034
|
showSerial = _ref$showSerial === void 0 ? true : _ref$showSerial,
|
|
4860
5035
|
cellClass = _ref.cellClass,
|
|
@@ -4966,9 +5141,26 @@ var Table = function Table(_ref) {
|
|
|
4966
5141
|
var actionMenuRef = React.useRef(null);
|
|
4967
5142
|
var actionButtonRefs = React.useRef({});
|
|
4968
5143
|
// Memoized values
|
|
5144
|
+
//
|
|
5145
|
+
// Supplied actions PATCH the built-in set by `name` (so `{ name: "edit",
|
|
5146
|
+
// onClick }` keeps the default label + icon) unless `replaceDefaultActions`
|
|
5147
|
+
// is set. Stays either an array or a `(row, index) => array` producer, and
|
|
5148
|
+
// keeps a stable identity so the per-row memo in TableRow/MobileCard pays off.
|
|
4969
5149
|
var actionsToUse = React.useMemo(function () {
|
|
4970
|
-
|
|
4971
|
-
|
|
5150
|
+
if (actions === undefined) return DEFAULT_ACTIONS;
|
|
5151
|
+
if (replaceDefaultActions) return actions;
|
|
5152
|
+
if (typeof actions === "function") {
|
|
5153
|
+
return function (row, index) {
|
|
5154
|
+
return mergeDefaultActions(actions(row, index), DEFAULT_ACTIONS);
|
|
5155
|
+
};
|
|
5156
|
+
}
|
|
5157
|
+
return mergeDefaultActions(actions, DEFAULT_ACTIONS);
|
|
5158
|
+
}, [actions, replaceDefaultActions]);
|
|
5159
|
+
// `hasDetails` may be a predicate. The expand COLUMN exists whenever the prop
|
|
5160
|
+
// is truthy at all; whether a given row gets a toggle is decided per row.
|
|
5161
|
+
var hasDetailsColumn = React.useMemo(function () {
|
|
5162
|
+
return typeof hasDetails === "function" || !!hasDetails;
|
|
5163
|
+
}, [hasDetails]);
|
|
4972
5164
|
// Refs for stable initial values
|
|
4973
5165
|
var initialPageNumber = React.useRef(pageNumber);
|
|
4974
5166
|
var initialColumnsRef = React.useRef(initialColumns);
|
|
@@ -5072,8 +5264,8 @@ var Table = function Table(_ref) {
|
|
|
5072
5264
|
paginatedData = _useMemo.paginatedData,
|
|
5073
5265
|
totalPages = _useMemo.totalPages;
|
|
5074
5266
|
var visibleCount = React.useMemo(function () {
|
|
5075
|
-
return (showSerial ? 1 : 0) + visibleColumns.length + (selectable ? 1 : 0) + (
|
|
5076
|
-
}, [showSerial, visibleColumns.length, selectable,
|
|
5267
|
+
return (showSerial ? 1 : 0) + visibleColumns.length + (selectable ? 1 : 0) + (hasDetailsColumn ? 1 : 0) + (withAction ? 1 : 0) + 1;
|
|
5268
|
+
}, [showSerial, visibleColumns.length, selectable, hasDetailsColumn, withAction]);
|
|
5077
5269
|
var rowKeyMap = React.useMemo(function () {
|
|
5078
5270
|
return new Map(filteredData.map(function (r, i) {
|
|
5079
5271
|
return [getRowKey(r, i), r];
|
|
@@ -5263,6 +5455,7 @@ var Table = function Table(_ref) {
|
|
|
5263
5455
|
stripedColors: stripedColorsArray,
|
|
5264
5456
|
onRowClick: onRowClick,
|
|
5265
5457
|
hasDetails: hasDetails,
|
|
5458
|
+
hasDetailsColumn: hasDetailsColumn,
|
|
5266
5459
|
showSerial: showSerial,
|
|
5267
5460
|
selectable: selectable,
|
|
5268
5461
|
visibleColumns: Array.isArray(visibleColumns) ? visibleColumns : [],
|
|
@@ -5392,7 +5585,7 @@ var Table = function Table(_ref) {
|
|
|
5392
5585
|
children: [jsxRuntime.jsxs("thead", {
|
|
5393
5586
|
className: safeTheme.accentColor,
|
|
5394
5587
|
children: [jsxRuntime.jsxs("tr", {
|
|
5395
|
-
children: [
|
|
5588
|
+
children: [hasDetailsColumn && jsxRuntime.jsx("th", {
|
|
5396
5589
|
className: "w-8 px-4 py-3"
|
|
5397
5590
|
}), showSerial && jsxRuntime.jsx("th", {
|
|
5398
5591
|
className: "w-8 px-4 py-3 text-left text-xs font-medium text-primary-500 uppercase tracking-wider",
|
|
@@ -5452,7 +5645,7 @@ var Table = function Table(_ref) {
|
|
|
5452
5645
|
className: "w-12 px-4 py-3"
|
|
5453
5646
|
})]
|
|
5454
5647
|
}), filterable && jsxRuntime.jsxs("tr", {
|
|
5455
|
-
children: [
|
|
5648
|
+
children: [hasDetailsColumn && jsxRuntime.jsx("th", {
|
|
5456
5649
|
className: "pb-4"
|
|
5457
5650
|
}), showSerial && jsxRuntime.jsx("th", {
|
|
5458
5651
|
className: "pb-4"
|