orcs-design-system 3.2.21 → 3.2.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.
|
@@ -63,7 +63,7 @@ export const ActionsMenuHeading = styled(props => {
|
|
|
63
63
|
componentId: "sc-yvbni2-5"
|
|
64
64
|
})(["color:", ";padding:8px;width:100%;font-size:", ";font-weight:", ";border-bottom:solid 1px ", ";white-space:nowrap;cursor:", ";"], props => themeGet("colors.white")(props), props => themeGet("fontSizes.1")(props), props => themeGet("fontWeights.1")(props), props => themeGet("colors.greyDarkest")(props), props => props.canClick ? "pointer" : "default");
|
|
65
65
|
export const ActionsMenuItem = styled(props => {
|
|
66
|
-
var _actionMenu$getItemPr;
|
|
66
|
+
var _actionMenu$getItemPr, _actionMenu$context, _actionMenu$context2;
|
|
67
67
|
const {
|
|
68
68
|
id,
|
|
69
69
|
onItemClick,
|
|
@@ -74,6 +74,7 @@ export const ActionsMenuItem = styled(props => {
|
|
|
74
74
|
...others
|
|
75
75
|
} = props;
|
|
76
76
|
const Component = as ? as : others.href ? "a" : "button";
|
|
77
|
+
const disabled = props.disabled;
|
|
77
78
|
let newProps = {
|
|
78
79
|
...others,
|
|
79
80
|
...((actionMenu === null || actionMenu === void 0 || (_actionMenu$getItemPr = actionMenu.getItemProps) === null || _actionMenu$getItemPr === void 0 ? void 0 : _actionMenu$getItemPr.call(actionMenu)) || {})
|
|
@@ -94,7 +95,12 @@ export const ActionsMenuItem = styled(props => {
|
|
|
94
95
|
}
|
|
95
96
|
return /*#__PURE__*/_jsx(Component, {
|
|
96
97
|
...newProps,
|
|
97
|
-
onClick: onClick
|
|
98
|
+
onClick: onClick,
|
|
99
|
+
disabled: disabled
|
|
100
|
+
// Hide from document when closed - related to HACK
|
|
101
|
+
,
|
|
102
|
+
"aria-hidden": !(actionMenu !== null && actionMenu !== void 0 && (_actionMenu$context = actionMenu.context) !== null && _actionMenu$context !== void 0 && _actionMenu$context.open),
|
|
103
|
+
tabIndex: !(actionMenu !== null && actionMenu !== void 0 && (_actionMenu$context2 = actionMenu.context) !== null && _actionMenu$context2 !== void 0 && _actionMenu$context2.open) && "-1"
|
|
98
104
|
});
|
|
99
105
|
}).attrs({
|
|
100
106
|
role: "menuitem"
|
|
@@ -116,7 +122,7 @@ export const ActionsMenuBody = _ref => {
|
|
|
116
122
|
onTriggerFocus,
|
|
117
123
|
closeMenu,
|
|
118
124
|
closeOnClick = false,
|
|
119
|
-
"data-testid": dataTestId,
|
|
125
|
+
"data-testid": dataTestId = "ActionsMenu",
|
|
120
126
|
...props
|
|
121
127
|
} = _ref;
|
|
122
128
|
const id = useId();
|
|
@@ -177,6 +183,7 @@ export const ActionsMenuBody = _ref => {
|
|
|
177
183
|
...actionMenu.getFloatingProps(props),
|
|
178
184
|
className: "actionMenu-content ".concat(visible ? "visible" : ""),
|
|
179
185
|
"aria-hidden": visible ? "false" : "true",
|
|
186
|
+
"data-testid": "".concat(dataTestId, "__menu"),
|
|
180
187
|
children: /*#__PURE__*/_jsx(Menu, {
|
|
181
188
|
menuWidth: menuWidth,
|
|
182
189
|
isOpen: toggleState,
|
|
@@ -398,6 +405,13 @@ ActionsMenuBody.__docgenInfo = {
|
|
|
398
405
|
},
|
|
399
406
|
"required": false
|
|
400
407
|
},
|
|
408
|
+
"data-testid": {
|
|
409
|
+
"defaultValue": {
|
|
410
|
+
"value": "\"ActionsMenu\"",
|
|
411
|
+
"computed": false
|
|
412
|
+
},
|
|
413
|
+
"required": false
|
|
414
|
+
},
|
|
401
415
|
"onTriggerFocus": {
|
|
402
416
|
"description": "",
|
|
403
417
|
"type": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { cloneElement, useState } from "react";
|
|
1
|
+
import React, { cloneElement, useEffect, useState } from "react";
|
|
2
2
|
import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal, safePolygon, FloatingFocusManager } from "@floating-ui/react";
|
|
3
3
|
import themeGet from "@styled-system/theme-get";
|
|
4
4
|
import styled from "styled-components";
|
|
@@ -26,7 +26,7 @@ const StyledPopover = styled.div.withConfig({
|
|
|
26
26
|
componentId: "sc-1bwoak-1"
|
|
27
27
|
})(["font-size:", ";line-height:", ";font-weight:", ";text-align:", ";word-break:break-word;color:", ";outline:0;padding:", ";border-radius:", ";width:", ";background:", ";border:1px solid ", ";box-shadow:", ";user-select:", ";pointer-events:none;opacity:0;&.visible{opacity:1;pointer-events:auto;}& a{font-size:", ";}&:before{content:\"\";z-index:2;height:0;width:0;border-style:solid;border-width:6px 6px 6px 0;border-color:transparent;border-right-color:", ";left:-5px;top:50%;margin-top:-6px;position:absolute;}&:after{content:\"\";z-index:1;position:absolute;border-color:transparent;border-right-color:", ";height:0;width:0;border-style:solid;border-width:6px 6px 6px 0;left:-6px;top:50%;margin-top:-6px;}&.top{&:before{left:50%;top:auto;margin-top:0;bottom:-8px;margin-left:-3px;transform:rotate(-90deg);}&:after{left:50%;top:auto;margin-top:0;bottom:-9px;margin-left:-3px;transform:rotate(-90deg);}}&.topRight,&.top-end{&:before{left:1px;top:auto;margin-top:0;bottom:-4px;margin-left:-5px;transform:rotate(-45deg);border-width:5px 10px 5px 0;}&:after{left:1px;top:auto;margin-top:0;bottom:-5px;margin-left:-6px;transform:rotate(-45deg);border-width:5px 10px 5px 0;}}&.bottomRight,&.bottom-end{&:before{left:1px;bottom:auto;margin-top:0;top:-4px;margin-left:-5px;transform:rotate(45deg);border-width:5px 10px 5px 0;}&:after{left:1px;bottom:auto;margin-top:0;top:-5px;margin-left:-6px;transform:rotate(45deg);border-width:5px 10px 5px 0;}}&.bottom{&:before{left:50%;top:-8px;margin-top:0;margin-left:-3px;transform:rotate(90deg);}&:after{left:50%;top:-9px;margin-top:0;margin-left:-3px;transform:rotate(90deg);}}&.bottomLeft,&.bottom-start{&:before{right:1px;left:auto;bottom:auto;margin-top:0;top:-4px;margin-right:-5px;transform:rotate(135deg);border-width:5px 10px 5px 0;}&:after{right:1px;left:auto;bottom:auto;margin-top:0;top:-5px;margin-right:-6px;transform:rotate(135deg);border-width:5px 10px 5px 0;}}&.left{&:before{left:auto;right:-5px;transform:rotate(180deg);}&:after{left:auto;right:-6px;transform:rotate(180deg);top:50%;margin-top:-6px;}}&.topLeft,&.top-start{&:before{right:1px;left:auto;top:auto;margin-top:0;bottom:-4px;margin-right:-5px;transform:rotate(225deg);border-width:5px 10px 5px 0;}&:after{right:1px;left:auto;top:auto;margin-top:0;bottom:-5px;margin-right:-6px;transform:rotate(225deg);border-width:5px 10px 5px 0;}}"], themeGet("fontSizes.0"), themeGet("fontSizes.1"), themeGet("fontWeights.1"), props => props.textAlign ? props.textAlign : "left", themeGet("colors.greyDarkest"), themeGet("space.3"), themeGet("radii.1"), props => props.width ? props.width : "200px", themeGet("colors.white"), themeGet("colors.greyLight"), themeGet("shadows.boxDefault"), props => props.enableSelectAll ? "all" : "auto", themeGet("fontSizes.0"), themeGet("colors.white"), themeGet("colors.grey"));
|
|
28
28
|
export default function Popover(_ref) {
|
|
29
|
-
var _children$type, _context$
|
|
29
|
+
var _children$type, _context$refs2;
|
|
30
30
|
let {
|
|
31
31
|
children,
|
|
32
32
|
direction = "right",
|
|
@@ -106,6 +106,23 @@ export default function Popover(_ref) {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
const directionClass = context.placement === DIRECTIONS_MAP[direction] ? direction : context.placement;
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
var _context$refs, _floatingEl$getElemen;
|
|
111
|
+
// Following code disables the tabbing of elements for popovers when it is not open.
|
|
112
|
+
const floatingEl = context === null || context === void 0 || (_context$refs = context.refs) === null || _context$refs === void 0 || (_context$refs = _context$refs.floating) === null || _context$refs === void 0 ? void 0 : _context$refs.current;
|
|
113
|
+
if (!floatingEl) return;
|
|
114
|
+
const childrenAnchors = Array.from((_floatingEl$getElemen = floatingEl.getElementsByTagName) === null || _floatingEl$getElemen === void 0 ? void 0 : _floatingEl$getElemen.call(floatingEl, "a"));
|
|
115
|
+
if (!childrenAnchors.length) return;
|
|
116
|
+
if (visible) {
|
|
117
|
+
childrenAnchors.forEach(anchor => {
|
|
118
|
+
anchor.tabIndex = "";
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
childrenAnchors.forEach(anchor => {
|
|
122
|
+
anchor.tabIndex = "-1";
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}, [visible, context]);
|
|
109
126
|
const Popover = /*#__PURE__*/_jsx(StyledPopover, {
|
|
110
127
|
textAlign: textAlign,
|
|
111
128
|
width: width,
|
|
@@ -127,7 +144,7 @@ export default function Popover(_ref) {
|
|
|
127
144
|
root: getFloatingUiRootElement(context.refs.reference),
|
|
128
145
|
preserveTabOrder: true,
|
|
129
146
|
children: text && (visible ? /*#__PURE__*/_jsx(FloatingFocusManager, {
|
|
130
|
-
initialFocus: (_context$
|
|
147
|
+
initialFocus: (_context$refs2 = context.refs) === null || _context$refs2 === void 0 ? void 0 : _context$refs2.reference,
|
|
131
148
|
context: context,
|
|
132
149
|
modal: false,
|
|
133
150
|
children: Popover
|