smartsell-ui-kit 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.cjs +27 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/{types-CSdgG6bT.d.cts → types-SEt2ljGe.d.cts} +2 -0
- package/dist/{types-CSdgG6bT.d.ts → types-SEt2ljGe.d.ts} +2 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -227,6 +227,11 @@ receives the clicked item and its visible row index. The desktop table row and t
|
|
|
227
227
|
mobile card use the same callback; the only visual change is the pointer cursor. Built-in row
|
|
228
228
|
action buttons stop propagation so their handlers do not also trigger `onRowClick`.
|
|
229
229
|
|
|
230
|
+
Use `rowClickOpensActions` to make a row open its existing overflow actions menu. The
|
|
231
|
+
menu must exist, so set `maxInlineActions={0}` when every action should appear there.
|
|
232
|
+
Without either row-click property, rows stay passive. When both are provided,
|
|
233
|
+
`rowClickOpensActions` takes precedence over `onRowClick`.
|
|
234
|
+
|
|
230
235
|
```tsx
|
|
231
236
|
<Table
|
|
232
237
|
items={customers}
|
package/dist/index.cjs
CHANGED
|
@@ -4927,12 +4927,15 @@ function ChevronIcon({ direction }) {
|
|
|
4927
4927
|
}
|
|
4928
4928
|
);
|
|
4929
4929
|
}
|
|
4930
|
-
function OverflowMenu({ label, children }) {
|
|
4930
|
+
function OverflowMenu({ label, children, openRequest }) {
|
|
4931
4931
|
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
4932
4932
|
const [menuPosition, setMenuPosition] = (0, import_react14.useState)(null);
|
|
4933
4933
|
const containerRef = (0, import_react14.useRef)(null);
|
|
4934
4934
|
const buttonRef = (0, import_react14.useRef)(null);
|
|
4935
4935
|
const menuRef = (0, import_react14.useRef)(null);
|
|
4936
|
+
(0, import_react14.useEffect)(() => {
|
|
4937
|
+
if (openRequest) setIsOpen(true);
|
|
4938
|
+
}, [openRequest]);
|
|
4936
4939
|
const updateMenuPosition = () => {
|
|
4937
4940
|
var _a, _b, _c;
|
|
4938
4941
|
const triggerRect = (_a = buttonRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
@@ -5056,6 +5059,7 @@ function TableBase({
|
|
|
5056
5059
|
mobileColumns,
|
|
5057
5060
|
getRowId: getCustomRowId,
|
|
5058
5061
|
onRowClick,
|
|
5062
|
+
rowClickOpensActions = false,
|
|
5059
5063
|
actions,
|
|
5060
5064
|
stickyActionsColumn = true,
|
|
5061
5065
|
maxInlineActions = DEFAULT_MAX_INLINE_ACTIONS,
|
|
@@ -5086,6 +5090,7 @@ function TableBase({
|
|
|
5086
5090
|
const containerRef = (0, import_react14.useRef)(null);
|
|
5087
5091
|
const [containerWidth, setContainerWidth] = (0, import_react14.useState)(null);
|
|
5088
5092
|
const [isSettingsModalOpen, setIsSettingsModalOpen] = (0, import_react14.useState)(false);
|
|
5093
|
+
const [requestedActions, setRequestedActions] = (0, import_react14.useState)({ rowId: "", count: 0 });
|
|
5089
5094
|
const resolvedLabels = mergeTableLabels({
|
|
5090
5095
|
...labels != null ? labels : {},
|
|
5091
5096
|
...translations != null ? translations : {}
|
|
@@ -5145,7 +5150,15 @@ function TableBase({
|
|
|
5145
5150
|
ariaLabel,
|
|
5146
5151
|
normalizedPage
|
|
5147
5152
|
);
|
|
5148
|
-
const hasRowClick = Boolean(onRowClick);
|
|
5153
|
+
const hasRowClick = Boolean(onRowClick || rowClickOpensActions);
|
|
5154
|
+
const handleRowClick = (item, rowIndex) => {
|
|
5155
|
+
if (rowClickOpensActions) {
|
|
5156
|
+
const rowId = getRowId(item, rowIndex, getCustomRowId);
|
|
5157
|
+
setRequestedActions((current) => ({ rowId, count: current.count + 1 }));
|
|
5158
|
+
} else {
|
|
5159
|
+
onRowClick == null ? void 0 : onRowClick(item, rowIndex);
|
|
5160
|
+
}
|
|
5161
|
+
};
|
|
5149
5162
|
const shouldStickActionsColumn = Boolean(actions) && stickyActionsColumn;
|
|
5150
5163
|
const getStickyActionsCellStyle = (backgroundColor, backgroundImage, isHeader = false) => ({
|
|
5151
5164
|
position: "sticky",
|
|
@@ -5258,9 +5271,16 @@ function TableBase({
|
|
|
5258
5271
|
inlineActions.map(
|
|
5259
5272
|
(action) => renderActionButton(action, item, rowIndex, "inline")
|
|
5260
5273
|
),
|
|
5261
|
-
overflowActions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5262
|
-
|
|
5263
|
-
|
|
5274
|
+
overflowActions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5275
|
+
OverflowMenu,
|
|
5276
|
+
{
|
|
5277
|
+
label: resolvedLabels.actionsMenuLabel,
|
|
5278
|
+
openRequest: requestedActions.rowId === getRowId(item, rowIndex, getCustomRowId) ? requestedActions.count : void 0,
|
|
5279
|
+
children: overflowActions.map(
|
|
5280
|
+
(action) => renderActionButton(action, item, rowIndex, "menu")
|
|
5281
|
+
)
|
|
5282
|
+
}
|
|
5283
|
+
) : null
|
|
5264
5284
|
]
|
|
5265
5285
|
}
|
|
5266
5286
|
);
|
|
@@ -5392,7 +5412,7 @@ function TableBase({
|
|
|
5392
5412
|
"px-3.5 py-3 shadow-none",
|
|
5393
5413
|
hasRowClick ? "cursor-pointer" : ""
|
|
5394
5414
|
].join(" "),
|
|
5395
|
-
onClick:
|
|
5415
|
+
onClick: hasRowClick ? () => handleRowClick(item, rowIndex) : void 0,
|
|
5396
5416
|
children: [
|
|
5397
5417
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5398
5418
|
"div",
|
|
@@ -5563,7 +5583,7 @@ function TableBase({
|
|
|
5563
5583
|
isAlternateRow ? "bg-[var(--theme-background)]" : "bg-[var(--theme-surface)]",
|
|
5564
5584
|
hasRowClick ? "cursor-pointer" : ""
|
|
5565
5585
|
].join(" "),
|
|
5566
|
-
onClick:
|
|
5586
|
+
onClick: hasRowClick ? () => handleRowClick(item, rowIndex) : void 0,
|
|
5567
5587
|
children: [
|
|
5568
5588
|
desktopColumns.map((column, columnIndex) => {
|
|
5569
5589
|
return renderDesktopCell(
|