orcs-design-system 3.2.4 → 3.2.6
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/es/GlobalStyles.js +1 -31
- package/es/SystemThemeProvider.js +11 -5
- package/es/assets/Colour/Colour.stories.js +211 -0
- package/es/assets/Colour/index.js +3 -3
- package/es/components/ActionsMenu/ActionsMenu.stories.js +260 -233
- package/es/components/ActionsMenu/index.js +144 -229
- package/es/components/Avatar/Avatar.stories.js +212 -196
- package/es/components/Avatar/index.js +280 -307
- package/es/components/Badge/Badge.stories.js +71 -46
- package/es/components/Badge/index.js +71 -74
- package/es/components/Box/Box.stories.js +51 -35
- package/es/components/Box/index.js +33 -34
- package/es/components/Button/Button.stories.js +161 -145
- package/es/components/Button/ButtonLink.stories.js +152 -139
- package/es/components/Button/index.js +79 -99
- package/es/components/ButtonGroup/ButtonGroup.stories.js +43 -42
- package/es/components/ButtonGroup/ButtonGroupItem.stories.js +11 -13
- package/es/components/ButtonGroup/index.js +103 -99
- package/es/components/Card/Card.stories.js +94 -62
- package/es/components/Card/index.js +50 -71
- package/es/components/Checkbox/Checkbox.stories.js +37 -43
- package/es/components/Checkbox/index.js +61 -76
- package/es/components/DatePicker/DatePicker.stories.js +86 -118
- package/es/components/DatePicker/index.js +71 -187
- package/es/components/Divider/Divider.stories.js +39 -42
- package/es/components/Divider/index.js +21 -27
- package/es/components/Expandable/Expandable.stories.js +46 -36
- package/es/components/Expandable/index.js +55 -82
- package/es/components/Flex/Flex.stories.js +19 -5
- package/es/components/Flex/FlexItem.stories.js +10 -9
- package/es/components/Flex/index.js +34 -27
- package/es/components/Grid/Grid.stories.js +129 -55
- package/es/components/Grid/index.js +25 -24
- package/es/components/Header/Header.stories.js +101 -92
- package/es/components/Header/index.js +433 -436
- package/es/components/HeaderSimple/HeaderSimple.stories.js +23 -27
- package/es/components/HeaderSimple/index.js +73 -68
- package/es/components/Icon/Icon.stories.js +58 -57
- package/es/components/Icon/index.js +48 -46
- package/es/components/Loading/Loading.stories.js +32 -39
- package/es/components/Loading/index.js +44 -51
- package/es/components/Modal/Modal.stories.js +172 -153
- package/es/components/Modal/index.js +126 -134
- package/es/components/Notification/Notification.stories.js +59 -58
- package/es/components/Notification/index.js +123 -133
- package/es/components/Popover/Popover.stories.js +134 -102
- package/es/components/Popover/index.js +65 -111
- package/es/components/ProgressBar/ProgressBar.stories.js +36 -39
- package/es/components/ProgressBar/index.js +29 -34
- package/es/components/RadioButton/RadioButton.stories.js +32 -37
- package/es/components/RadioButton/index.js +170 -184
- package/es/components/Range/Range.stories.js +19 -19
- package/es/components/Range/index.js +35 -45
- package/es/components/Select/Select.stories.js +107 -128
- package/es/components/Select/index.js +324 -336
- package/es/components/SideNav/NavItem.js +112 -122
- package/es/components/SideNav/SideNav.stories.js +84 -57
- package/es/components/SideNav/index.js +161 -185
- package/es/components/Sidebar/Sidebar.stories.js +50 -33
- package/es/components/Sidebar/index.js +152 -155
- package/es/components/Spacer/Spacer.stories.js +35 -32
- package/es/components/Spacer/index.js +20 -20
- package/es/components/StatusDot/StatusDot.stories.js +103 -90
- package/es/components/StatusDot/index.js +36 -38
- package/es/components/StyledLink/StyledLink.stories.js +68 -69
- package/es/components/StyledLink/index.js +47 -48
- package/es/components/Table/Table.stories.js +118 -112
- package/es/components/Table/getExpandColumnConfig.js +67 -62
- package/es/components/Table/index.js +24 -27
- package/es/components/Table/muiStyleOverrides.js +10 -8
- package/es/components/Tabs/Tab.stories.js +55 -38
- package/es/components/Tabs/TabsContainer.stories.js +30 -22
- package/es/components/Tabs/index.js +95 -92
- package/es/components/Tag/Tag.stories.js +250 -220
- package/es/components/Tag/index.js +118 -190
- package/es/components/TextArea/TextArea.stories.js +76 -89
- package/es/components/TextArea/index.js +117 -115
- package/es/components/TextInput/TextInput.stories.js +41 -61
- package/es/components/TextInput/index.js +127 -171
- package/es/components/Toggle/Toggle.stories.js +63 -62
- package/es/components/Toggle/index.js +43 -77
- package/es/components/TreeNav/TreeNav.stories.js +7 -8
- package/es/components/TreeNav/index.js +72 -69
- package/es/components/Typography/Typography.stories.js +174 -0
- package/es/components/Typography/index.js +252 -308
- package/es/components.test.js +1 -1
- package/es/hooks/isVisible.js +6 -10
- package/es/hooks/keepInView.js +27 -32
- package/es/hooks/keypress.js +14 -14
- package/es/hooks/useInputFocus.js +5 -5
- package/es/hooks/usePrevious.js +3 -3
- package/es/systemThemeCollapsed.js +53 -53
- package/es/systemtheme.js +53 -53
- package/es/utils/selectUtil.js +1 -1
- package/es/utils/selectUtil.test.js +6 -6
- package/package.json +29 -38
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
5
|
-
var _excluded = ["as"],
|
|
6
|
-
_excluded2 = ["theme", "onToggle", "toggleState", "direction", "menuTopPosition", "menuLeftPosition", "menuRightPosition", "menuWidth", "customTriggerComponent", "children", "ariaLabel", "onTriggerFocus", "closeMenu", "closeOnClick"],
|
|
7
|
-
_excluded3 = ["children", "customTriggerComponent", "direction", "isOpen", "theme", "closeOnClick", "ariaLabel"];
|
|
8
|
-
function ownKeys(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; }
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
1
|
import React, { useState, useEffect, useImperativeHandle, useCallback, createContext, useContext, useMemo, useRef, useId } from "react";
|
|
11
2
|
import styled, { css, keyframes, ThemeProvider } from "styled-components";
|
|
12
3
|
import PropTypes from "prop-types";
|
|
@@ -14,178 +5,105 @@ import { space, layout } from "styled-system";
|
|
|
14
5
|
import { themeGet } from "@styled-system/theme-get";
|
|
15
6
|
import { useKeepInView } from "../../hooks/keepInView";
|
|
16
7
|
import { commonKeys } from "../../hooks/keypress";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const ActionMenuContext = /*#__PURE__*/createContext({});
|
|
10
|
+
const crossTransform1 = keyframes(["0%{transform:translate(0,-6px);border-radius:2px;}50%{transform:translate(0,0);border-radius:2px;}75%{transform:rotate(-45deg) translate(0,0);border-radius:2px;}100%{transform:rotate(-45deg) translate(0,0) scaleX(4);border-radius:0;}"]);
|
|
11
|
+
const crossTransform2 = keyframes(["0%{transform:translate(0,6px);border-radius:2px;}50%{transform:translate(0,0);border-radius:2px;}75%{transform:rotate(45deg) translate(0,0);border-radius:2px;}100%{transform:rotate(45deg) translate(0,0) scaleX(4);border-radius:0;}"]);
|
|
12
|
+
const Wrapper = styled.div.withConfig({
|
|
21
13
|
displayName: "ActionsMenu__Wrapper",
|
|
22
14
|
componentId: "sc-yvbni2-0"
|
|
23
15
|
})(["", " ", " position:relative;width:auto;"], space, layout);
|
|
24
|
-
|
|
16
|
+
const Control = styled.button.withConfig({
|
|
25
17
|
displayName: "ActionsMenu__Control",
|
|
26
18
|
componentId: "sc-yvbni2-1"
|
|
27
|
-
})(["position:relative;background-color:", ";border:none;display:flex;align-items:center;justify-content:center;-moz-appearance:none;-webkit-appearance:none;appearance:none;box-shadow:none;text-decoration:none;text-align:center;border-radius:", ";transition:", ";cursor:pointer;width:30px;height:30px;&:hover,&:focus{outline:0;background-color:", ";}"],
|
|
28
|
-
|
|
29
|
-
}, function (props) {
|
|
30
|
-
return themeGet("radii.2")(props);
|
|
31
|
-
}, function (props) {
|
|
32
|
-
return themeGet("transition.transitionDefault")(props);
|
|
33
|
-
}, function (props) {
|
|
34
|
-
return themeGet("colors.greyLight")(props);
|
|
35
|
-
});
|
|
36
|
-
var Icon = styled.div.withConfig({
|
|
19
|
+
})(["position:relative;background-color:", ";border:none;display:flex;align-items:center;justify-content:center;-moz-appearance:none;-webkit-appearance:none;appearance:none;box-shadow:none;text-decoration:none;text-align:center;border-radius:", ";transition:", ";cursor:pointer;width:30px;height:30px;&:hover,&:focus{outline:0;background-color:", ";}"], props => themeGet("colors.greyLighter")(props), props => themeGet("radii.2")(props), props => themeGet("transition.transitionDefault")(props), props => themeGet("colors.greyLight")(props));
|
|
20
|
+
const Icon = styled.div.withConfig({
|
|
37
21
|
displayName: "ActionsMenu__Icon",
|
|
38
22
|
componentId: "sc-yvbni2-2"
|
|
39
|
-
})(["border-radius:2px;height:4px;width:4px;background-color:", ";&:before,&:after{content:\"\";display:block;position:absolute;border-radius:2px;height:4px;width:4px;background-color:", ";transition:", ";transform-origin:50% 50%;}&:before{transform:translate(0,-6px) scaleX(1);}&:after{transform:translate(0,6px) scaleX(1);}", ";"],
|
|
40
|
-
|
|
41
|
-
}, function (props) {
|
|
42
|
-
return themeGet("colors.greyDarker")(props);
|
|
43
|
-
}, function (props) {
|
|
44
|
-
return themeGet("transition.transitionDefault")(props);
|
|
45
|
-
}, function (props) {
|
|
46
|
-
return props.isOpen ? css(["&:before{animation:400ms ", " ease-in-out forwards;}&:after{animation:400ms ", " ease-in-out forwards;}"], crossTransform1, crossTransform2) : css([""]);
|
|
47
|
-
});
|
|
48
|
-
var Menu = styled.div.withConfig({
|
|
23
|
+
})(["border-radius:2px;height:4px;width:4px;background-color:", ";&:before,&:after{content:\"\";display:block;position:absolute;border-radius:2px;height:4px;width:4px;background-color:", ";transition:", ";transform-origin:50% 50%;}&:before{transform:translate(0,-6px) scaleX(1);}&:after{transform:translate(0,6px) scaleX(1);}", ";"], props => themeGet("colors.greyDarker")(props), props => themeGet("colors.greyDarker")(props), props => themeGet("transition.transitionDefault")(props), props => props.isOpen ? css(["&:before{animation:400ms ", " ease-in-out forwards;}&:after{animation:400ms ", " ease-in-out forwards;}"], crossTransform1, crossTransform2) : css([""]));
|
|
24
|
+
const Menu = styled.div.withConfig({
|
|
49
25
|
displayName: "ActionsMenu__Menu",
|
|
50
26
|
componentId: "sc-yvbni2-3"
|
|
51
|
-
})(["display:", ";position:absolute;left:", ";right:", ";top:", ";width:", ";z-index:5;background-color:", ";border-radius:", ";transform:scale(0);opacity:0;pointer-events:none;transform-origin:", ";transition:all 300ms;transition-timing-function:cubic-bezier(0,1.4,1,1);", ";"],
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return props.menuRightPosition ? props.menuRightPosition : props.direction == "left" ? "34px" : "auto";
|
|
57
|
-
}, function (props) {
|
|
58
|
-
return props.menuTopPosition ? props.menuTopPosition : "0";
|
|
59
|
-
}, function (props) {
|
|
60
|
-
return props.menuWidth ? props.menuWidth : "auto";
|
|
61
|
-
}, function (props) {
|
|
62
|
-
return themeGet("colors.greyDarker")(props);
|
|
63
|
-
}, function (props) {
|
|
64
|
-
return themeGet("radii.2")(props);
|
|
65
|
-
}, function (props) {
|
|
66
|
-
return props.direction == "left" ? "top right" : "top left";
|
|
67
|
-
}, function (props) {
|
|
68
|
-
return props.isOpen ? css(["transform:scale(1);opacity:1;pointer-events:auto;"]) : css([""]);
|
|
69
|
-
});
|
|
70
|
-
export var ActionsMenuHeading = styled(function (props) {
|
|
71
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
72
|
-
onKeyUp: function onKeyUp(e) {
|
|
27
|
+
})(["display:", ";position:absolute;left:", ";right:", ";top:", ";width:", ";z-index:5;background-color:", ";border-radius:", ";transform:scale(0);opacity:0;pointer-events:none;transform-origin:", ";transition:all 300ms;transition-timing-function:cubic-bezier(0,1.4,1,1);", ";"], props => props.isOpen ? "block" : "none", props => props.menuLeftPosition ? props.menuLeftPosition : props.direction == "left" ? "auto" : "34px", props => props.menuRightPosition ? props.menuRightPosition : props.direction == "left" ? "34px" : "auto", props => props.menuTopPosition ? props.menuTopPosition : "0", props => props.menuWidth ? props.menuWidth : "auto", props => themeGet("colors.greyDarker")(props), props => themeGet("radii.2")(props), props => props.direction == "left" ? "top right" : "top left", props => props.isOpen ? css(["transform:scale(1);opacity:1;pointer-events:auto;"]) : css([""]));
|
|
28
|
+
export const ActionsMenuHeading = styled(props => {
|
|
29
|
+
return /*#__PURE__*/_jsx("div", {
|
|
30
|
+
...props,
|
|
31
|
+
onKeyUp: e => {
|
|
73
32
|
if (e.key === commonKeys.ENTER && props !== null && props !== void 0 && props.canClick) {
|
|
74
33
|
props === null || props === void 0 || props.onClick();
|
|
75
34
|
}
|
|
76
35
|
}
|
|
77
|
-
})
|
|
36
|
+
});
|
|
78
37
|
}).attrs({
|
|
79
38
|
tabIndex: "0",
|
|
80
39
|
role: "button"
|
|
81
40
|
}).withConfig({
|
|
82
41
|
displayName: "ActionsMenu__ActionsMenuHeading",
|
|
83
42
|
componentId: "sc-yvbni2-4"
|
|
84
|
-
})(["color:", ";padding:8px;width:100%;font-size:", ";font-weight:", ";border-bottom:solid 1px ", ";white-space:nowrap;cursor:", ";"],
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var newProps = others;
|
|
103
|
-
var _newProps = newProps,
|
|
104
|
-
originalOnClick = _newProps.onClick;
|
|
105
|
-
var onClick = useMemo(function () {
|
|
106
|
-
return function (e) {
|
|
107
|
-
onItemClick === null || onItemClick === void 0 || onItemClick(e);
|
|
108
|
-
originalOnClick === null || originalOnClick === void 0 || originalOnClick(e);
|
|
109
|
-
};
|
|
43
|
+
})(["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");
|
|
44
|
+
export const ActionsMenuItem = styled(props => {
|
|
45
|
+
const {
|
|
46
|
+
id,
|
|
47
|
+
onItemClick
|
|
48
|
+
} = useContext(ActionMenuContext);
|
|
49
|
+
const {
|
|
50
|
+
as,
|
|
51
|
+
...others
|
|
52
|
+
} = props;
|
|
53
|
+
const Component = as ? as : others.href ? "a" : "button";
|
|
54
|
+
let newProps = others;
|
|
55
|
+
const {
|
|
56
|
+
onClick: originalOnClick
|
|
57
|
+
} = newProps;
|
|
58
|
+
const onClick = useMemo(() => e => {
|
|
59
|
+
onItemClick === null || onItemClick === void 0 || onItemClick(e);
|
|
60
|
+
originalOnClick === null || originalOnClick === void 0 || originalOnClick(e);
|
|
110
61
|
}, [originalOnClick, onItemClick]);
|
|
111
62
|
if (Component === "button") {
|
|
112
|
-
newProps =
|
|
113
|
-
|
|
114
|
-
|
|
63
|
+
newProps = {
|
|
64
|
+
...others,
|
|
65
|
+
type: "button",
|
|
66
|
+
["data-action-menu-id"]: id
|
|
67
|
+
};
|
|
115
68
|
}
|
|
116
|
-
return /*#__PURE__*/
|
|
69
|
+
return /*#__PURE__*/_jsx(Component, {
|
|
70
|
+
...newProps,
|
|
117
71
|
onClick: onClick
|
|
118
|
-
})
|
|
72
|
+
});
|
|
119
73
|
}).attrs({
|
|
120
74
|
role: "listitem"
|
|
121
75
|
}).withConfig({
|
|
122
76
|
displayName: "ActionsMenu__ActionsMenuItem",
|
|
123
77
|
componentId: "sc-yvbni2-5"
|
|
124
|
-
})(["white-space:nowrap;display:block;width:100%;text-align:left;cursor:pointer;margin:0;padding:8px;appearance:none;background-color:", ";border:none;border-bottom:solid 1px ", ";border-radius:0;color:", ";font-size:", ";line-height:", ";font-family:", ";font-weight:", ";text-decoration:none;transition:", ";&:hover,&:focus{outline:0;background-color:", ";}&:first-child{border-radius:", " ", " 0 0;}&:last-child{border:0;border-radius:0 0 ", " ", ";}&:only-child{border-radius:", ";}"],
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
154
|
-
var theme = _ref.theme,
|
|
155
|
-
onToggle = _ref.onToggle,
|
|
156
|
-
toggleState = _ref.toggleState,
|
|
157
|
-
direction = _ref.direction,
|
|
158
|
-
menuTopPosition = _ref.menuTopPosition,
|
|
159
|
-
menuLeftPosition = _ref.menuLeftPosition,
|
|
160
|
-
menuRightPosition = _ref.menuRightPosition,
|
|
161
|
-
menuWidth = _ref.menuWidth,
|
|
162
|
-
customTriggerComponent = _ref.customTriggerComponent,
|
|
163
|
-
children = _ref.children,
|
|
164
|
-
_ref$ariaLabel = _ref.ariaLabel,
|
|
165
|
-
ariaLabel = _ref$ariaLabel === void 0 ? "Options Menu" : _ref$ariaLabel,
|
|
166
|
-
onTriggerFocus = _ref.onTriggerFocus,
|
|
167
|
-
closeMenu = _ref.closeMenu,
|
|
168
|
-
_ref$closeOnClick = _ref.closeOnClick,
|
|
169
|
-
closeOnClick = _ref$closeOnClick === void 0 ? false : _ref$closeOnClick,
|
|
170
|
-
props = _objectWithoutProperties(_ref, _excluded2);
|
|
171
|
-
var _useState = useState(false),
|
|
172
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
173
|
-
isTabbed = _useState2[0],
|
|
174
|
-
setTabbed = _useState2[1];
|
|
175
|
-
var id = useId();
|
|
176
|
-
var wrapperRef = useRef();
|
|
177
|
-
var _useState3 = useState({
|
|
178
|
-
menuLeftPosition: menuLeftPosition,
|
|
179
|
-
menuRightPosition: menuRightPosition,
|
|
180
|
-
menuTopPosition: menuTopPosition
|
|
181
|
-
}),
|
|
182
|
-
_useState4 = _slicedToArray(_useState3, 1),
|
|
183
|
-
menuPosition = _useState4[0];
|
|
184
|
-
var _useState5 = useState(direction),
|
|
185
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
186
|
-
inViewDirection = _useState6[0],
|
|
187
|
-
setInViewDirection = _useState6[1];
|
|
188
|
-
var setMenuPosition = useCallback(function (newDirection) {
|
|
78
|
+
})(["white-space:nowrap;display:block;width:100%;text-align:left;cursor:pointer;margin:0;padding:8px;appearance:none;background-color:", ";border:none;border-bottom:solid 1px ", ";border-radius:0;color:", ";font-size:", ";line-height:", ";font-family:", ";font-weight:", ";text-decoration:none;transition:", ";&:hover,&:focus{outline:0;background-color:", ";}&:first-child{border-radius:", " ", " 0 0;}&:last-child{border:0;border-radius:0 0 ", " ", ";}&:only-child{border-radius:", ";}"], props => props.selected ? themeGet("colors.successDark")(props) : "transparent", props => themeGet("colors.greyDarkest")(props), props => themeGet("colors.white")(props), props => themeGet("fontSizes.1")(props), props => themeGet("fontSizes.1")(props), props => themeGet("fonts.main")(props), props => themeGet("fontWeights.2")(props), props => themeGet("transition.transitionDefault")(props), props => themeGet("colors.primaryDark")(props), props => themeGet("radii.2")(props), props => themeGet("radii.2")(props), props => themeGet("radii.2")(props), props => themeGet("radii.2")(props), props => themeGet("radii.2")(props));
|
|
79
|
+
export const ActionsMenuBody = _ref => {
|
|
80
|
+
let {
|
|
81
|
+
theme,
|
|
82
|
+
onToggle,
|
|
83
|
+
toggleState,
|
|
84
|
+
direction,
|
|
85
|
+
menuTopPosition,
|
|
86
|
+
menuLeftPosition,
|
|
87
|
+
menuRightPosition,
|
|
88
|
+
menuWidth,
|
|
89
|
+
customTriggerComponent,
|
|
90
|
+
children,
|
|
91
|
+
ariaLabel = "Options Menu",
|
|
92
|
+
onTriggerFocus,
|
|
93
|
+
closeMenu,
|
|
94
|
+
closeOnClick = false,
|
|
95
|
+
...props
|
|
96
|
+
} = _ref;
|
|
97
|
+
const [isTabbed, setTabbed] = useState(false);
|
|
98
|
+
const id = useId();
|
|
99
|
+
const wrapperRef = useRef();
|
|
100
|
+
const [menuPosition] = useState({
|
|
101
|
+
menuLeftPosition,
|
|
102
|
+
menuRightPosition,
|
|
103
|
+
menuTopPosition
|
|
104
|
+
});
|
|
105
|
+
const [inViewDirection, setInViewDirection] = useState(direction);
|
|
106
|
+
const setMenuPosition = useCallback(newDirection => {
|
|
189
107
|
if (typeof menuLeftPosition !== "undefined" || typeof menuRightPosition !== "undefined") {
|
|
190
108
|
if (menuPosition.menuLeftPosition) {
|
|
191
109
|
menuPosition.menuRightPosition = menuPosition.menuLeftPosition;
|
|
@@ -197,49 +115,46 @@ export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
|
197
115
|
}
|
|
198
116
|
setInViewDirection(newDirection);
|
|
199
117
|
}, [menuLeftPosition, menuRightPosition, menuPosition, setInViewDirection]);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
ref = _useKeepInView2[0],
|
|
206
|
-
setIsShown = _useKeepInView2[1];
|
|
207
|
-
useEffect(function () {
|
|
118
|
+
const [ref, setIsShown] = useKeepInView({
|
|
119
|
+
direction,
|
|
120
|
+
callback: setMenuPosition
|
|
121
|
+
});
|
|
122
|
+
useEffect(() => {
|
|
208
123
|
setIsShown(toggleState);
|
|
209
124
|
}, [toggleState, setIsShown]);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
closeMenu(e);
|
|
217
|
-
}
|
|
125
|
+
let triggerBtn = null;
|
|
126
|
+
const value = useMemo(() => ({
|
|
127
|
+
id,
|
|
128
|
+
onItemClick: e => {
|
|
129
|
+
if (closeOnClick && !isTabbed) {
|
|
130
|
+
closeMenu(e);
|
|
218
131
|
}
|
|
219
|
-
}
|
|
220
|
-
}, [closeOnClick, isTabbed, closeMenu, id]);
|
|
132
|
+
}
|
|
133
|
+
}), [closeOnClick, isTabbed, closeMenu, id]);
|
|
221
134
|
if (customTriggerComponent) {
|
|
222
135
|
triggerBtn = /*#__PURE__*/React.cloneElement(customTriggerComponent, {
|
|
223
136
|
onClick: onToggle,
|
|
224
137
|
"aria-label": ariaLabel,
|
|
225
138
|
"aria-expanded": "".concat(toggleState),
|
|
226
139
|
onFocus: onTriggerFocus,
|
|
227
|
-
id
|
|
140
|
+
id
|
|
228
141
|
});
|
|
229
142
|
} else {
|
|
230
|
-
triggerBtn = /*#__PURE__*/
|
|
143
|
+
triggerBtn = /*#__PURE__*/_jsx(Control, {
|
|
231
144
|
"aria-label": ariaLabel,
|
|
232
145
|
"aria-expanded": "".concat(toggleState),
|
|
233
146
|
onClick: onToggle,
|
|
234
147
|
onFocus: onTriggerFocus,
|
|
235
|
-
id: id
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
148
|
+
id: id,
|
|
149
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
150
|
+
isOpen: toggleState
|
|
151
|
+
})
|
|
152
|
+
});
|
|
239
153
|
}
|
|
240
|
-
|
|
154
|
+
const component = /*#__PURE__*/_jsxs(Wrapper, {
|
|
155
|
+
...props,
|
|
241
156
|
ref: wrapperRef,
|
|
242
|
-
onKeyUp:
|
|
157
|
+
onKeyUp: e => {
|
|
243
158
|
if ([commonKeys.ESCAPE, commonKeys.ESC].includes(e.key)) {
|
|
244
159
|
closeMenu(e);
|
|
245
160
|
document.getElementById(id).focus();
|
|
@@ -248,33 +163,37 @@ export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
|
248
163
|
setTabbed === null || setTabbed === void 0 || setTabbed(true);
|
|
249
164
|
}
|
|
250
165
|
},
|
|
251
|
-
onBlur:
|
|
252
|
-
setTimeout(
|
|
166
|
+
onBlur: e => {
|
|
167
|
+
setTimeout(() => {
|
|
253
168
|
var _wrapperRef$current, _document$getElementB;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
169
|
+
const focusedElement = document.activeElement;
|
|
170
|
+
const isChild = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.contains(focusedElement);
|
|
171
|
+
const isModalChild = (_document$getElementB = document.getElementById("modal-overlay")) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.contains(focusedElement);
|
|
172
|
+
const isModalAndTabbed = isTabbed && isModalChild;
|
|
258
173
|
if (isChild || isModalAndTabbed) return;
|
|
259
174
|
setTabbed === null || setTabbed === void 0 || setTabbed(false);
|
|
260
175
|
closeMenu(e);
|
|
261
176
|
}, 0);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
177
|
+
},
|
|
178
|
+
children: [triggerBtn, /*#__PURE__*/_jsx(Menu, {
|
|
179
|
+
isOpen: toggleState,
|
|
180
|
+
direction: inViewDirection,
|
|
181
|
+
menuTopPosition: menuPosition.menuTopPosition,
|
|
182
|
+
menuLeftPosition: menuPosition.menuLeftPosition,
|
|
183
|
+
menuRightPosition: menuPosition.menuRightPosition,
|
|
184
|
+
menuWidth: menuWidth,
|
|
185
|
+
ref: ref,
|
|
186
|
+
role: "list",
|
|
187
|
+
children: /*#__PURE__*/_jsx(ActionMenuContext.Provider, {
|
|
188
|
+
value: value,
|
|
189
|
+
children: children
|
|
190
|
+
})
|
|
191
|
+
})]
|
|
192
|
+
});
|
|
193
|
+
return theme ? /*#__PURE__*/_jsx(ThemeProvider, {
|
|
194
|
+
theme: theme,
|
|
195
|
+
children: component
|
|
196
|
+
}) : component;
|
|
278
197
|
};
|
|
279
198
|
ActionsMenuBody.propTypes = {
|
|
280
199
|
onTriggerFocus: PropTypes.func,
|
|
@@ -292,38 +211,32 @@ ActionsMenuBody.propTypes = {
|
|
|
292
211
|
theme: PropTypes.object,
|
|
293
212
|
ariaLabel: PropTypes.string
|
|
294
213
|
};
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
isOpen =
|
|
301
|
-
theme
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
closeMenu: function closeMenu() {
|
|
314
|
-
setToggle(false);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
});
|
|
318
|
-
var onToggle = function onToggle(e) {
|
|
214
|
+
const ActionsMenu = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
215
|
+
let {
|
|
216
|
+
children,
|
|
217
|
+
customTriggerComponent,
|
|
218
|
+
direction,
|
|
219
|
+
isOpen = false,
|
|
220
|
+
theme,
|
|
221
|
+
closeOnClick = true,
|
|
222
|
+
ariaLabel = "Options Menu",
|
|
223
|
+
...props
|
|
224
|
+
} = _ref2;
|
|
225
|
+
const [toggleState, setToggle] = useState(isOpen);
|
|
226
|
+
useImperativeHandle(ref, () => ({
|
|
227
|
+
closeMenu: () => {
|
|
228
|
+
setToggle(false);
|
|
229
|
+
}
|
|
230
|
+
}));
|
|
231
|
+
const onToggle = e => {
|
|
319
232
|
e.stopPropagation();
|
|
320
233
|
setToggle(!toggleState);
|
|
321
234
|
};
|
|
322
|
-
|
|
235
|
+
const closeMenu = e => {
|
|
323
236
|
e.stopPropagation();
|
|
324
237
|
setToggle(false);
|
|
325
238
|
};
|
|
326
|
-
return /*#__PURE__*/
|
|
239
|
+
return /*#__PURE__*/_jsx(ActionsMenuBody, {
|
|
327
240
|
onToggle: onToggle,
|
|
328
241
|
closeMenu: closeMenu,
|
|
329
242
|
toggleState: toggleState,
|
|
@@ -331,8 +244,10 @@ var ActionsMenu = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
331
244
|
direction: direction,
|
|
332
245
|
theme: theme,
|
|
333
246
|
ariaLabel: ariaLabel,
|
|
334
|
-
closeOnClick: closeOnClick
|
|
335
|
-
|
|
247
|
+
closeOnClick: closeOnClick,
|
|
248
|
+
...props,
|
|
249
|
+
children: children
|
|
250
|
+
});
|
|
336
251
|
});
|
|
337
252
|
ActionsMenu.propTypes = {
|
|
338
253
|
isOpen: PropTypes.bool,
|