orcs-design-system 3.2.20 → 3.2.22
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,6 +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$context$o, _actionMenu$context, _actionMenu$getItemPr;
|
|
66
67
|
const {
|
|
67
68
|
id,
|
|
68
69
|
onItemClick,
|
|
@@ -73,9 +74,11 @@ export const ActionsMenuItem = styled(props => {
|
|
|
73
74
|
...others
|
|
74
75
|
} = props;
|
|
75
76
|
const Component = as ? as : others.href ? "a" : "button";
|
|
77
|
+
const disabled = (_actionMenu$context$o = !(actionMenu !== null && actionMenu !== void 0 && (_actionMenu$context = actionMenu.context) !== null && _actionMenu$context !== void 0 && _actionMenu$context.open)) !== null && _actionMenu$context$o !== void 0 ? _actionMenu$context$o : false;
|
|
76
78
|
let newProps = {
|
|
77
79
|
...others,
|
|
78
|
-
...actionMenu.getItemProps()
|
|
80
|
+
...((actionMenu === null || actionMenu === void 0 || (_actionMenu$getItemPr = actionMenu.getItemProps) === null || _actionMenu$getItemPr === void 0 ? void 0 : _actionMenu$getItemPr.call(actionMenu)) || {}),
|
|
81
|
+
disabled
|
|
79
82
|
};
|
|
80
83
|
const {
|
|
81
84
|
onClick: originalOnClick
|
|
@@ -88,7 +91,8 @@ export const ActionsMenuItem = styled(props => {
|
|
|
88
91
|
newProps = {
|
|
89
92
|
...others,
|
|
90
93
|
type: "button",
|
|
91
|
-
["data-action-menu-id"]: id
|
|
94
|
+
["data-action-menu-id"]: id,
|
|
95
|
+
disabled
|
|
92
96
|
};
|
|
93
97
|
}
|
|
94
98
|
return /*#__PURE__*/_jsx(Component, {
|
|
@@ -136,11 +140,10 @@ export const ActionsMenuBody = _ref => {
|
|
|
136
140
|
"aria-label": ariaLabel,
|
|
137
141
|
onFocus: onTriggerFocus,
|
|
138
142
|
id,
|
|
139
|
-
onClick: onToggle,
|
|
140
143
|
...actionMenu.getReferenceProps({
|
|
141
|
-
ref: triggerRef,
|
|
142
144
|
...props,
|
|
143
|
-
|
|
145
|
+
onClick: onToggle,
|
|
146
|
+
ref: triggerRef,
|
|
144
147
|
"data-state": actionMenu.open ? "open" : "closed",
|
|
145
148
|
"data-testid": dataTestId
|
|
146
149
|
})
|
|
@@ -152,7 +155,10 @@ export const ActionsMenuBody = _ref => {
|
|
|
152
155
|
})
|
|
153
156
|
});
|
|
154
157
|
if (customTriggerComponent) {
|
|
155
|
-
triggerComponent = /*#__PURE__*/React.cloneElement(customTriggerComponent,
|
|
158
|
+
triggerComponent = /*#__PURE__*/React.cloneElement(customTriggerComponent, {
|
|
159
|
+
...triggerProps,
|
|
160
|
+
...((customTriggerComponent === null || customTriggerComponent === void 0 ? void 0 : customTriggerComponent.props) || {})
|
|
161
|
+
});
|
|
156
162
|
}
|
|
157
163
|
const value = useMemo(() => ({
|
|
158
164
|
id,
|
|
@@ -163,32 +169,43 @@ export const ActionsMenuBody = _ref => {
|
|
|
163
169
|
},
|
|
164
170
|
actionMenu
|
|
165
171
|
}), [closeOnClick, closeMenu, id, actionMenu]);
|
|
172
|
+
const visible = actionMenu.context.open;
|
|
173
|
+
const ActionMenuContent = /*#__PURE__*/_jsx(StyledActionsMenuContainer, {
|
|
174
|
+
ref: ref,
|
|
175
|
+
style: {
|
|
176
|
+
...actionMenu.floatingStyles,
|
|
177
|
+
zIndex: getFloatingUiZIndex(actionMenu.refs.reference)
|
|
178
|
+
},
|
|
179
|
+
"aria-labelledby": actionMenu.labelId,
|
|
180
|
+
...actionMenu.getFloatingProps(props),
|
|
181
|
+
className: "actionMenu-content ".concat(visible ? "visible" : ""),
|
|
182
|
+
"aria-hidden": visible ? "false" : "true",
|
|
183
|
+
children: /*#__PURE__*/_jsx(Menu, {
|
|
184
|
+
menuWidth: menuWidth,
|
|
185
|
+
isOpen: toggleState,
|
|
186
|
+
children: children
|
|
187
|
+
})
|
|
188
|
+
});
|
|
166
189
|
const component = /*#__PURE__*/_jsx(ActionMenuContext.Provider, {
|
|
167
190
|
value: value,
|
|
168
191
|
children: /*#__PURE__*/_jsxs(Wrapper, {
|
|
169
192
|
...props,
|
|
170
193
|
children: [triggerComponent, /*#__PURE__*/_jsx(FloatingPortal, {
|
|
171
194
|
root: getFloatingUiRootElement(actionMenu.refs.reference),
|
|
172
|
-
children: toggleState
|
|
195
|
+
children: toggleState ? /*#__PURE__*/_jsx(FloatingFocusManager, {
|
|
173
196
|
context: actionMenu.context,
|
|
174
197
|
modal: false,
|
|
175
198
|
guards: false,
|
|
176
|
-
children:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
menuWidth: menuWidth,
|
|
187
|
-
isOpen: toggleState,
|
|
188
|
-
children: children
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
})
|
|
199
|
+
children: ActionMenuContent
|
|
200
|
+
}) : (
|
|
201
|
+
/*
|
|
202
|
+
* HACK: Fixing all the broken tests in teamform-app-ui is too time consuming
|
|
203
|
+
* right this moment with a lot of the tests asserting against ActionsMenu items.
|
|
204
|
+
* Rendering the markup even when closed but in a hidden state ensures that tests pass.
|
|
205
|
+
* Ideally, we would update all the tests in teamform-app-ui to open the ActionsMenu
|
|
206
|
+
* before assertion.
|
|
207
|
+
**/
|
|
208
|
+
ActionMenuContent)
|
|
192
209
|
})]
|
|
193
210
|
})
|
|
194
211
|
});
|
|
@@ -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",
|
|
@@ -98,37 +98,64 @@ export default function Popover(_ref) {
|
|
|
98
98
|
} else if ((children === null || children === void 0 || (_children$type = children.type) === null || _children$type === void 0 ? void 0 : _children$type.$$typeof) === Symbol.for("react.forward_ref")) {
|
|
99
99
|
triggerComponent = /*#__PURE__*/cloneElement(children, triggerProps);
|
|
100
100
|
} else {
|
|
101
|
+
var _children$props;
|
|
101
102
|
triggerComponent = /*#__PURE__*/_jsx("div", {
|
|
102
103
|
...triggerProps,
|
|
104
|
+
"data-testid": "".concat((children === null || children === void 0 || (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props["data-testid"]) || "popover", "-trigger"),
|
|
103
105
|
children: children
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
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]);
|
|
126
|
+
const Popover = /*#__PURE__*/_jsx(StyledPopover, {
|
|
127
|
+
textAlign: textAlign,
|
|
128
|
+
width: width,
|
|
129
|
+
enableSelectAll: enableSelectAll,
|
|
130
|
+
className: "Tooltip popover ".concat(visible ? "visible" : "", " ").concat(directionClass),
|
|
131
|
+
ref: refs.setFloating,
|
|
132
|
+
style: {
|
|
133
|
+
...floatingStyles,
|
|
134
|
+
zIndex: getFloatingUiZIndex(context.refs.reference)
|
|
135
|
+
},
|
|
136
|
+
...getFloatingProps(),
|
|
137
|
+
ariaLabel: ariaLabel,
|
|
138
|
+
"aria-hidden": visible ? "false" : "true",
|
|
139
|
+
children: text
|
|
140
|
+
});
|
|
107
141
|
return /*#__PURE__*/_jsxs(Box, {
|
|
108
142
|
...props,
|
|
109
143
|
children: [triggerComponent, /*#__PURE__*/_jsx(FloatingPortal, {
|
|
110
144
|
root: getFloatingUiRootElement(context.refs.reference),
|
|
111
145
|
preserveTabOrder: true,
|
|
112
|
-
children: text && visible
|
|
113
|
-
initialFocus: (_context$
|
|
146
|
+
children: text && (visible ? /*#__PURE__*/_jsx(FloatingFocusManager, {
|
|
147
|
+
initialFocus: (_context$refs2 = context.refs) === null || _context$refs2 === void 0 ? void 0 : _context$refs2.reference,
|
|
114
148
|
context: context,
|
|
115
149
|
modal: false,
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
zIndex: getFloatingUiZIndex(context.refs.reference)
|
|
126
|
-
},
|
|
127
|
-
...getFloatingProps(),
|
|
128
|
-
ariaLabel: ariaLabel,
|
|
129
|
-
children: text
|
|
130
|
-
})
|
|
131
|
-
})
|
|
150
|
+
children: Popover
|
|
151
|
+
}) : Popover
|
|
152
|
+
/*
|
|
153
|
+
* HACK: Fixing all the broken tests in teamform-app-ui is too time consuming
|
|
154
|
+
* right this moment with a lot of the tests asserting against Popover items.
|
|
155
|
+
* Rendering the markup even when closed but in a hidden state ensures that tests pass.
|
|
156
|
+
* Ideally, we would update all the tests in teamform-app-ui to open the Popover
|
|
157
|
+
* before assertion.
|
|
158
|
+
**/)
|
|
132
159
|
})]
|
|
133
160
|
});
|
|
134
161
|
}
|