@jobber/components 6.55.0 → 6.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -245,6 +245,11 @@ interface BaseDataListItemActionsProps<T extends DataListObject> {
|
|
|
245
245
|
* Callback when an item is clicked.
|
|
246
246
|
*/
|
|
247
247
|
readonly onClick?: (item: T, event?: React.MouseEvent<HTMLElement>) => void;
|
|
248
|
+
/**
|
|
249
|
+
* Disable the custom context menu. This allows the browser's native context menu to be shown.
|
|
250
|
+
* @default false
|
|
251
|
+
*/
|
|
252
|
+
readonly disableContextMenu?: boolean;
|
|
248
253
|
}
|
|
249
254
|
export interface DataListBulkActionsProps {
|
|
250
255
|
/**
|
package/dist/DataListItem-cjs.js
CHANGED
|
@@ -59,9 +59,11 @@ function DataListItemInternal({ children, item, }) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function useGetItemActions(item) {
|
|
62
|
+
var _a;
|
|
62
63
|
const { itemActionComponent } = DataListContext.useDataListContext();
|
|
63
64
|
const itemActions = (itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.children) || [];
|
|
64
65
|
const actionsArray = React.Children.toArray(itemActions);
|
|
66
|
+
const disableContextMenu = (_a = itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.disableContextMenu) !== null && _a !== void 0 ? _a : false;
|
|
65
67
|
const actions = React.useMemo(() => {
|
|
66
68
|
return actionsArray.filter(action => {
|
|
67
69
|
if (React.isValidElement(action) && action.props.visible) {
|
|
@@ -73,6 +75,7 @@ function useGetItemActions(item) {
|
|
|
73
75
|
return {
|
|
74
76
|
actions: actions,
|
|
75
77
|
hasActions: Boolean(actions.length),
|
|
78
|
+
disableContextMenu,
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
81
|
|
|
@@ -81,12 +84,12 @@ function DataListItem({ item, layout, }) {
|
|
|
81
84
|
const [showMenu, setShowMenu] = React.useState(false);
|
|
82
85
|
const [contextPosition, setContextPosition] = React.useState();
|
|
83
86
|
const generatedItem = React.useMemo(() => DataList_utils.generateListItemElement(item), [item]);
|
|
84
|
-
const { actions, hasActions } = useGetItemActions(item);
|
|
87
|
+
const { actions, hasActions, disableContextMenu } = useGetItemActions(item);
|
|
85
88
|
const isContextMenuVisible = Boolean(contextPosition);
|
|
86
89
|
const shouldShowContextMenu = showMenu && isContextMenuVisible && hasActions;
|
|
87
90
|
const shouldShowHoverMenu = showMenu && hasActions && !hasInLayoutActions && !shouldShowContextMenu;
|
|
88
91
|
return (React.createElement(DataListLayoutContext$1.DataListLayoutActionsContext.Provider, { value: { activeItem: item } },
|
|
89
|
-
React.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: handleContextMenu, className: classnames(DataList_module.styles.listItem, {
|
|
92
|
+
React.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: disableContextMenu ? undefined : handleContextMenu, className: classnames(DataList_module.styles.listItem, {
|
|
90
93
|
[DataList_module.styles.active]: showMenu && isContextMenuVisible,
|
|
91
94
|
}), key: item.id },
|
|
92
95
|
React.createElement(DataListItemInternal, { item: item },
|
package/dist/DataListItem-es.js
CHANGED
|
@@ -57,9 +57,11 @@ function DataListItemInternal({ children, item, }) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
function useGetItemActions(item) {
|
|
60
|
+
var _a;
|
|
60
61
|
const { itemActionComponent } = useDataListContext();
|
|
61
62
|
const itemActions = (itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.children) || [];
|
|
62
63
|
const actionsArray = Children.toArray(itemActions);
|
|
64
|
+
const disableContextMenu = (_a = itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props.disableContextMenu) !== null && _a !== void 0 ? _a : false;
|
|
63
65
|
const actions = useMemo(() => {
|
|
64
66
|
return actionsArray.filter(action => {
|
|
65
67
|
if (isValidElement(action) && action.props.visible) {
|
|
@@ -71,6 +73,7 @@ function useGetItemActions(item) {
|
|
|
71
73
|
return {
|
|
72
74
|
actions: actions,
|
|
73
75
|
hasActions: Boolean(actions.length),
|
|
76
|
+
disableContextMenu,
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -79,12 +82,12 @@ function DataListItem({ item, layout, }) {
|
|
|
79
82
|
const [showMenu, setShowMenu] = useState(false);
|
|
80
83
|
const [contextPosition, setContextPosition] = useState();
|
|
81
84
|
const generatedItem = useMemo(() => generateListItemElement(item), [item]);
|
|
82
|
-
const { actions, hasActions } = useGetItemActions(item);
|
|
85
|
+
const { actions, hasActions, disableContextMenu } = useGetItemActions(item);
|
|
83
86
|
const isContextMenuVisible = Boolean(contextPosition);
|
|
84
87
|
const shouldShowContextMenu = showMenu && isContextMenuVisible && hasActions;
|
|
85
88
|
const shouldShowHoverMenu = showMenu && hasActions && !hasInLayoutActions && !shouldShowContextMenu;
|
|
86
89
|
return (React__default.createElement(DataListLayoutActionsContext.Provider, { value: { activeItem: item } },
|
|
87
|
-
React__default.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: handleContextMenu, className: classnames(styles.listItem, {
|
|
90
|
+
React__default.createElement("div", { onMouseEnter: handleShowMenu, onMouseLeave: handleHideMenu, onFocus: handleShowMenu, onBlur: handleHideMenu, onContextMenu: disableContextMenu ? undefined : handleContextMenu, className: classnames(styles.listItem, {
|
|
88
91
|
[styles.active]: showMenu && isContextMenuVisible,
|
|
89
92
|
}), key: item.id },
|
|
90
93
|
React__default.createElement(DataListItemInternal, { item: item },
|