@pingux/astro 1.12.0 → 1.13.0-alpha.2
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/lib/cjs/components/Avatar/Avatar.js +8 -3
- package/lib/cjs/components/Avatar/Avatar.test.js +10 -0
- package/lib/cjs/components/Button/Button.js +9 -3
- package/lib/cjs/components/CodeView/CodeView.test.js +4 -4
- package/lib/cjs/components/ComboBox/ComboBoxInput.js +2 -1
- package/lib/cjs/components/CopyText/CopyButton.js +1 -1
- package/lib/cjs/components/CopyText/CopyText.js +5 -1
- package/lib/cjs/components/CopyText/CopyText.test.js +11 -20
- package/lib/cjs/components/IconButtonToggle/IconButtonToggle.js +78 -0
- package/lib/cjs/components/IconButtonToggle/IconButtonToggle.stories.js +76 -0
- package/lib/cjs/components/IconButtonToggle/IconButtonToggle.test.js +60 -0
- package/lib/cjs/components/IconButtonToggle/index.js +18 -0
- package/lib/cjs/components/Menu/Menu.js +4 -1
- package/lib/cjs/components/Menu/Menu.test.js +3 -0
- package/lib/cjs/hooks/index.js +18 -0
- package/lib/cjs/hooks/useComponentToggle/index.js +18 -0
- package/lib/cjs/hooks/useComponentToggle/useComponentToggle.js +70 -0
- package/lib/cjs/hooks/useComponentToggle/useComponentToggle.test.js +133 -0
- package/lib/cjs/index.js +72 -49
- package/lib/cjs/recipes/OneWayToBidirectionalArrow.stories.js +160 -0
- package/lib/cjs/styles/variants/boxes.js +1 -0
- package/lib/cjs/styles/variants/buttons.js +8 -1
- package/lib/components/Avatar/Avatar.js +8 -3
- package/lib/components/Avatar/Avatar.test.js +8 -0
- package/lib/components/Button/Button.js +9 -3
- package/lib/components/CodeView/CodeView.test.js +4 -4
- package/lib/components/ComboBox/ComboBoxInput.js +2 -1
- package/lib/components/CopyText/CopyButton.js +1 -1
- package/lib/components/CopyText/CopyText.js +5 -1
- package/lib/components/CopyText/CopyText.test.js +11 -16
- package/lib/components/IconButtonToggle/IconButtonToggle.js +59 -0
- package/lib/components/IconButtonToggle/IconButtonToggle.stories.js +40 -0
- package/lib/components/IconButtonToggle/IconButtonToggle.test.js +46 -0
- package/lib/components/IconButtonToggle/index.js +1 -0
- package/lib/components/Menu/Menu.js +3 -1
- package/lib/components/Menu/Menu.test.js +2 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/useComponentToggle/index.js +1 -0
- package/lib/hooks/useComponentToggle/useComponentToggle.js +55 -0
- package/lib/hooks/useComponentToggle/useComponentToggle.test.js +105 -0
- package/lib/index.js +2 -0
- package/lib/recipes/OneWayToBidirectionalArrow.stories.js +137 -0
- package/lib/styles/variants/boxes.js +1 -0
- package/lib/styles/variants/buttons.js +8 -1
- package/package.json +1 -1
- package/NOTICE.html +0 -4311
@@ -0,0 +1,160 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
|
11
|
+
exports["default"] = exports.Default = void 0;
|
12
|
+
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
14
|
+
|
15
|
+
var _DragVerticalIcon = _interopRequireDefault(require("mdi-react/DragVerticalIcon"));
|
16
|
+
|
17
|
+
var _DeleteIcon = _interopRequireDefault(require("mdi-react/DeleteIcon"));
|
18
|
+
|
19
|
+
var _CogsIcon = _interopRequireDefault(require("mdi-react/CogsIcon"));
|
20
|
+
|
21
|
+
var _Box = _interopRequireDefault(require("../components/Box"));
|
22
|
+
|
23
|
+
var _index = require("../index");
|
24
|
+
|
25
|
+
var _react2 = require("@emotion/react");
|
26
|
+
|
27
|
+
var _default = {
|
28
|
+
title: 'Recipes/OneWayToBidirectionalArrow'
|
29
|
+
};
|
30
|
+
exports["default"] = _default;
|
31
|
+
var items = [{
|
32
|
+
name: 'Last Name',
|
33
|
+
id: '1'
|
34
|
+
}, {
|
35
|
+
name: 'First Name',
|
36
|
+
id: '2'
|
37
|
+
}, {
|
38
|
+
name: 'Third Option',
|
39
|
+
id: '3'
|
40
|
+
}];
|
41
|
+
|
42
|
+
var Default = function Default() {
|
43
|
+
var CustomOnSvg = function CustomOnSvg() {
|
44
|
+
return (0, _react2.jsx)("svg", {
|
45
|
+
width: "24",
|
46
|
+
height: "24",
|
47
|
+
viewBox: "0 0 24 24",
|
48
|
+
fill: "none",
|
49
|
+
xmlns: "http://www.w3.org/2000/svg"
|
50
|
+
}, (0, _react2.jsx)("path", {
|
51
|
+
d: "M8 10V13H14V18H8V21L2 15.5L8 10Z",
|
52
|
+
fill: "#CACED3"
|
53
|
+
}), (0, _react2.jsx)("path", {
|
54
|
+
d: "M9.83325 10.6251V6.37511H15.4999V2.94678L21.0533 8.50011L15.4999 14.0534V10.6251H9.83325Z",
|
55
|
+
fill: "#4462ED"
|
56
|
+
}), (0, _react2.jsx)("path", {
|
57
|
+
d: "M8 10V13H14V18H8V21L2 15.5L8 10ZM22 8.5L16 3V6H10V11H16V14L22 8.5Z",
|
58
|
+
fill: "#515F6B"
|
59
|
+
}));
|
60
|
+
};
|
61
|
+
|
62
|
+
var CustomOffSvg = function CustomOffSvg() {
|
63
|
+
return (0, _react2.jsx)("svg", {
|
64
|
+
width: "24",
|
65
|
+
height: "24",
|
66
|
+
viewBox: "0 0 24 24",
|
67
|
+
fill: "none",
|
68
|
+
xmlns: "http://www.w3.org/2000/svg"
|
69
|
+
}, (0, _react2.jsx)("path", {
|
70
|
+
d: "M8 10V13H14V18H8V21L2 15.5L8 10Z",
|
71
|
+
fill: "#CACED3"
|
72
|
+
}), (0, _react2.jsx)("path", {
|
73
|
+
d: "M9.83331 10.6251V6.37511H15.5V2.94678L21.0533 8.50011L15.5 14.0534V10.6251H9.83331Z",
|
74
|
+
fill: "#4462ED"
|
75
|
+
}));
|
76
|
+
};
|
77
|
+
|
78
|
+
return (0, _react2.jsx)(_Box["default"], {
|
79
|
+
sx: {
|
80
|
+
alignItems: 'center'
|
81
|
+
},
|
82
|
+
isRow: true
|
83
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
84
|
+
icon: _DragVerticalIcon["default"],
|
85
|
+
size: 25,
|
86
|
+
color: "neutral.50"
|
87
|
+
}), (0, _react2.jsx)(_index.ComboBoxField, {
|
88
|
+
items: items,
|
89
|
+
defaultSelectedKey: "Last Name",
|
90
|
+
containerProps: {
|
91
|
+
width: '275px'
|
92
|
+
},
|
93
|
+
labelProps: {
|
94
|
+
mb: 0
|
95
|
+
},
|
96
|
+
"aria-label": "Row one value",
|
97
|
+
controlProps: {
|
98
|
+
'aria-label': 'test'
|
99
|
+
}
|
100
|
+
}, function (item) {
|
101
|
+
return (0, _react2.jsx)(_index.Item, {
|
102
|
+
key: item.name,
|
103
|
+
"data-id": item.name
|
104
|
+
}, item.name);
|
105
|
+
}), (0, _react2.jsx)(_Box["default"], {
|
106
|
+
sx: {
|
107
|
+
ml: '5px',
|
108
|
+
mr: '5px',
|
109
|
+
flexShrink: 0
|
110
|
+
}
|
111
|
+
}, (0, _react2.jsx)(_index.IconButtonToggle, {
|
112
|
+
toggledIcon: CustomOnSvg,
|
113
|
+
defaultIcon: CustomOffSvg,
|
114
|
+
title: "Bidirectional/ Outbound toggle",
|
115
|
+
iconProps: {
|
116
|
+
size: 20
|
117
|
+
},
|
118
|
+
buttonProps: {
|
119
|
+
variant: 'svgIconButton'
|
120
|
+
}
|
121
|
+
})), (0, _react2.jsx)(_index.ComboBoxField, {
|
122
|
+
items: items,
|
123
|
+
defaultSelectedKey: "First Name",
|
124
|
+
containerProps: {
|
125
|
+
width: '275px'
|
126
|
+
},
|
127
|
+
labelProps: {
|
128
|
+
mb: 0
|
129
|
+
},
|
130
|
+
controlProps: {
|
131
|
+
'aria-label': 'Row one Pingone value'
|
132
|
+
}
|
133
|
+
}, function (item) {
|
134
|
+
return (0, _react2.jsx)(_index.Item, {
|
135
|
+
key: item.name,
|
136
|
+
"data-id": item.name
|
137
|
+
}, item.name);
|
138
|
+
}), (0, _react2.jsx)(_Box["default"], {
|
139
|
+
isRow: true,
|
140
|
+
alignItems: "center",
|
141
|
+
sx: {
|
142
|
+
marginLeft: '12px',
|
143
|
+
marginRight: '12px'
|
144
|
+
}
|
145
|
+
}, (0, _react2.jsx)(_index.IconButton, null, (0, _react2.jsx)(_index.Icon, {
|
146
|
+
icon: _CogsIcon["default"],
|
147
|
+
color: "neutral.30",
|
148
|
+
size: 20,
|
149
|
+
title: "edit icon"
|
150
|
+
})), (0, _react2.jsx)(_index.IconButton, {
|
151
|
+
ml: "5px"
|
152
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
153
|
+
icon: _DeleteIcon["default"],
|
154
|
+
color: "neutral.30",
|
155
|
+
size: 20,
|
156
|
+
title: "delete icon"
|
157
|
+
}))));
|
158
|
+
};
|
159
|
+
|
160
|
+
exports.Default = Default;
|
@@ -136,6 +136,12 @@ var iconButton = {
|
|
136
136
|
}
|
137
137
|
};
|
138
138
|
|
139
|
+
var svgIconButton = _objectSpread(_objectSpread({}, iconButton), {}, {
|
140
|
+
path: {
|
141
|
+
fill: 'default'
|
142
|
+
}
|
143
|
+
});
|
144
|
+
|
139
145
|
var square = _objectSpread(_objectSpread({}, iconButton), {}, {
|
140
146
|
borderRadius: '2px'
|
141
147
|
});
|
@@ -721,6 +727,7 @@ var _default = {
|
|
721
727
|
colorBlock: colorBlock,
|
722
728
|
menuTab: menuTab,
|
723
729
|
collapsiblePanelToggle: collapsiblePanelToggle,
|
724
|
-
neutralText: neutralText
|
730
|
+
neutralText: neutralText,
|
731
|
+
svgIconButton: svgIconButton
|
725
732
|
};
|
726
733
|
exports["default"] = _default;
|
@@ -10,13 +10,18 @@ import { Avatar as ThemeUIAvatar } from 'theme-ui';
|
|
10
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
11
|
var Avatar = /*#__PURE__*/forwardRef(function (props, ref) {
|
12
12
|
return ___EmotionJSX(ThemeUIAvatar, _extends({
|
13
|
-
ref: ref
|
14
|
-
alt: "Avatar"
|
13
|
+
ref: ref
|
15
14
|
}, props));
|
16
15
|
});
|
17
16
|
Avatar.propTypes = {
|
18
17
|
/** Source of avatar. */
|
19
|
-
src: PropTypes.string.isRequired
|
18
|
+
src: PropTypes.string.isRequired,
|
19
|
+
|
20
|
+
/** Alternative text for avatar. */
|
21
|
+
alt: PropTypes.string
|
22
|
+
};
|
23
|
+
Avatar.defaultProps = {
|
24
|
+
alt: 'Avatar'
|
20
25
|
};
|
21
26
|
Avatar.displayName = 'Avatar';
|
22
27
|
export default Avatar;
|
@@ -21,4 +21,12 @@ test('an avatar is rendered', function () {
|
|
21
21
|
var img = screen.getByRole('img');
|
22
22
|
expect(img).toBeInstanceOf(HTMLImageElement);
|
23
23
|
expect(img).toBeInTheDocument();
|
24
|
+
expect(img).toHaveAttribute('alt', 'Avatar');
|
25
|
+
});
|
26
|
+
test('an avatar is rendered with custom alt', function () {
|
27
|
+
getComponent({
|
28
|
+
alt: 'Custom Alt'
|
29
|
+
});
|
30
|
+
var img = screen.getByRole('img');
|
31
|
+
expect(img).toHaveAttribute('alt', 'Custom Alt');
|
24
32
|
});
|
@@ -9,7 +9,7 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["className", "isDisabled", "isLoading", "onHoverStart", "onHoverChange", "onHoverEnd", "onPress", "onPressStart", "onPressEnd", "onPressChange", "onPressUp", "children", "variant"];
|
12
|
+
var _excluded = ["className", "isDisabled", "isLoading", "onHoverStart", "onHoverChange", "onHoverEnd", "onPress", "onPressStart", "onPressEnd", "onPressChange", "onPressUp", "children", "variant", "tabIndex"];
|
13
13
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
15
15
|
|
@@ -39,6 +39,7 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
39
39
|
onPressUp = props.onPressUp,
|
40
40
|
children = props.children,
|
41
41
|
variant = props.variant,
|
42
|
+
tabIndex = props.tabIndex,
|
42
43
|
others = _objectWithoutProperties(props, _excluded);
|
43
44
|
|
44
45
|
var buttonRef = useRef();
|
@@ -94,7 +95,9 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
95
|
alignItems: 'center'
|
95
96
|
},
|
96
97
|
variant: variant
|
97
|
-
}, others, mergeProps(hoverProps, focusProps, buttonProps)
|
98
|
+
}, others, mergeProps(hoverProps, focusProps, _objectSpread(_objectSpread({}, buttonProps), {}, {
|
99
|
+
tabIndex: tabIndex
|
100
|
+
}))), isLoading ? ___EmotionJSX("span", {
|
98
101
|
style: {
|
99
102
|
visibility: 'hidden'
|
100
103
|
}
|
@@ -166,7 +169,10 @@ Button.propTypes = {
|
|
166
169
|
onPressUp: PropTypes.func,
|
167
170
|
|
168
171
|
/** The styling variation of the button. */
|
169
|
-
variant: PropTypes.string
|
172
|
+
variant: PropTypes.string,
|
173
|
+
|
174
|
+
/** The focus variation of the button. */
|
175
|
+
tabIndex: PropTypes.number
|
170
176
|
};
|
171
177
|
Button.defaultProps = {
|
172
178
|
isDisabled: false,
|
@@ -60,7 +60,7 @@ test('renders component in the default state', function () {
|
|
60
60
|
});
|
61
61
|
test('copy button is hovered and renders tooltip via mouse', function () {
|
62
62
|
getComponent();
|
63
|
-
var copyBtn = screen.getByLabelText('copy');
|
63
|
+
var copyBtn = screen.getByLabelText('copy to clipboard');
|
64
64
|
expect(copyBtn).not.toHaveFocus();
|
65
65
|
userEvent.hover(copyBtn);
|
66
66
|
expect(copyBtn).toHaveClass('is-hovered');
|
@@ -69,7 +69,7 @@ test('copy button is hovered and renders tooltip via mouse', function () {
|
|
69
69
|
});
|
70
70
|
test('copy button is focused and renders tooltip via keyboard', function () {
|
71
71
|
getComponent();
|
72
|
-
var copyBtn = screen.getByLabelText('copy');
|
72
|
+
var copyBtn = screen.getByLabelText('copy to clipboard');
|
73
73
|
expect(copyBtn).not.toHaveFocus();
|
74
74
|
userEvent.tab();
|
75
75
|
expect(copyBtn).toHaveFocus();
|
@@ -105,7 +105,7 @@ test('click on copy button copies data to the clipboard', /*#__PURE__*/_asyncToG
|
|
105
105
|
switch (_context2.prev = _context2.next) {
|
106
106
|
case 0:
|
107
107
|
getComponent();
|
108
|
-
button = screen.getByLabelText('copy');
|
108
|
+
button = screen.getByLabelText('copy to clipboard');
|
109
109
|
_context2.next = 4;
|
110
110
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
111
111
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
@@ -140,7 +140,7 @@ test('after button click, the tooltip renders with the text "Copied!"', /*#__PUR
|
|
140
140
|
switch (_context4.prev = _context4.next) {
|
141
141
|
case 0:
|
142
142
|
getComponent();
|
143
|
-
button = screen.getByLabelText('copy');
|
143
|
+
button = screen.getByLabelText('copy to clipboard');
|
144
144
|
_context4.next = 4;
|
145
145
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
146
146
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
@@ -117,7 +117,8 @@ var ComboBoxInput = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
117
117
|
variant: "comboBox"
|
118
118
|
}, triggerProps, {
|
119
119
|
ref: triggerRef,
|
120
|
-
isDisabled: isDisabled || isReadOnly
|
120
|
+
isDisabled: isDisabled || isReadOnly,
|
121
|
+
tabIndex: -1
|
121
122
|
}), ___EmotionJSX(Icon, {
|
122
123
|
icon: MenuDown,
|
123
124
|
sx: isOpen ? {
|
@@ -9,7 +9,7 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
9
9
|
var CopyButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
10
10
|
return ___EmotionJSX(IconButton, _extends({
|
11
11
|
ref: ref,
|
12
|
-
"aria-label": "copy",
|
12
|
+
"aria-label": "copy to clipboard",
|
13
13
|
variant: "buttons.copy"
|
14
14
|
}, omit(props, 'iconProps')), ___EmotionJSX(Icon, _extends({
|
15
15
|
icon: ContentCopy,
|
@@ -9,6 +9,7 @@ import PropTypes from 'prop-types';
|
|
9
9
|
import { useFocusRing } from '@react-aria/focus';
|
10
10
|
import { Pressable, useHover } from '@react-aria/interactions';
|
11
11
|
import { mergeProps } from '@react-aria/utils';
|
12
|
+
import { announce } from '@react-aria/live-announcer';
|
12
13
|
import { Box, Button, Tooltip, TooltipTrigger } from '../../index';
|
13
14
|
import CopyButton from './CopyButton';
|
14
15
|
import useCopyToClipboard from '../../hooks/useCopyToClipboard';
|
@@ -68,6 +69,8 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
68
69
|
|
69
70
|
useEffect(function () {
|
70
71
|
if (isCopied) {
|
72
|
+
announce('Copied!', 'polite');
|
73
|
+
|
71
74
|
var timer = _setTimeout(function () {
|
72
75
|
setIsCopied(false);
|
73
76
|
}, 1000);
|
@@ -83,7 +86,8 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
83
86
|
var content = mode === 'link' || mode === 'nonClickableContent' ? children : ___EmotionJSX(Button, _extends({
|
84
87
|
variant: "quiet",
|
85
88
|
onPress: copyToClipboard,
|
86
|
-
"aria-label": "copy-content"
|
89
|
+
"aria-label": "copy-content",
|
90
|
+
tabIndex: -1
|
87
91
|
}, focusProps), children);
|
88
92
|
var tooltip = isCopied ? 'Copied!' : tooltipText;
|
89
93
|
var isTooltipOpen = isFocusVisible || isHovered || isCopied;
|
@@ -60,14 +60,9 @@ describe('Text mode', function () {
|
|
60
60
|
expect(screen.queryByRole('tooltip')).toBeInTheDocument();
|
61
61
|
expect(screen.queryByRole('tooltip')).toHaveTextContent('Copy to clipboard');
|
62
62
|
});
|
63
|
-
test('
|
63
|
+
test('copy button is focused with keyboard', function () {
|
64
64
|
getComponent();
|
65
|
-
var
|
66
|
-
expect(contentBtn).not.toHaveFocus();
|
67
|
-
userEvent.tab();
|
68
|
-
expect(contentBtn).toHaveFocus();
|
69
|
-
expect(contentBtn).toHaveClass('is-focused');
|
70
|
-
var copyBtn = screen.getByLabelText('copy');
|
65
|
+
var copyBtn = screen.getByLabelText('copy to clipboard');
|
71
66
|
expect(copyBtn).not.toHaveFocus();
|
72
67
|
userEvent.tab();
|
73
68
|
expect(copyBtn).toHaveFocus();
|
@@ -128,7 +123,7 @@ describe('Text mode', function () {
|
|
128
123
|
switch (_context4.prev = _context4.next) {
|
129
124
|
case 0:
|
130
125
|
getComponent();
|
131
|
-
button = screen.getByLabelText('copy');
|
126
|
+
button = screen.getByLabelText('copy to clipboard');
|
132
127
|
_context4.next = 4;
|
133
128
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
134
129
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
@@ -166,7 +161,7 @@ describe('Text mode', function () {
|
|
166
161
|
getComponent({
|
167
162
|
textToCopy: textToCopy
|
168
163
|
});
|
169
|
-
button = screen.getByLabelText('copy');
|
164
|
+
button = screen.getByLabelText('copy to clipboard');
|
170
165
|
_context6.next = 5;
|
171
166
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
172
167
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
@@ -202,7 +197,7 @@ describe('Text mode', function () {
|
|
202
197
|
case 0:
|
203
198
|
global.navigator.clipboard = undefined;
|
204
199
|
getComponent();
|
205
|
-
button = screen.getByLabelText('copy');
|
200
|
+
button = screen.getByLabelText('copy to clipboard');
|
206
201
|
_context8.next = 5;
|
207
202
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
208
203
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
@@ -247,7 +242,7 @@ describe('Text mode', function () {
|
|
247
242
|
getComponent();
|
248
243
|
spy = jest.spyOn(console, 'error');
|
249
244
|
expect(spy).not.toHaveBeenCalled();
|
250
|
-
button = screen.getByLabelText('copy');
|
245
|
+
button = screen.getByLabelText('copy to clipboard');
|
251
246
|
_context10.next = 9;
|
252
247
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
253
248
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
@@ -283,7 +278,7 @@ describe('Text mode', function () {
|
|
283
278
|
switch (_context12.prev = _context12.next) {
|
284
279
|
case 0:
|
285
280
|
getComponent();
|
286
|
-
button = screen.getByLabelText('copy');
|
281
|
+
button = screen.getByLabelText('copy to clipboard');
|
287
282
|
_context12.next = 4;
|
288
283
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
289
284
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
@@ -318,7 +313,7 @@ describe('Text mode', function () {
|
|
318
313
|
switch (_context14.prev = _context14.next) {
|
319
314
|
case 0:
|
320
315
|
getComponent();
|
321
|
-
button = screen.getByLabelText('copy');
|
316
|
+
button = screen.getByLabelText('copy to clipboard');
|
322
317
|
_context14.next = 4;
|
323
318
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
324
319
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
@@ -374,14 +369,14 @@ describe('Link mode', function () {
|
|
374
369
|
fireEvent.mouseMove(container);
|
375
370
|
fireEvent.mouseEnter(container);
|
376
371
|
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
377
|
-
var button = screen.getByLabelText('copy');
|
372
|
+
var button = screen.getByLabelText('copy to clipboard');
|
378
373
|
fireEvent.mouseMove(button);
|
379
374
|
fireEvent.mouseEnter(button);
|
380
375
|
expect(screen.queryByRole('tooltip')).toBeInTheDocument();
|
381
376
|
});
|
382
377
|
test('copy button is focused with keyboard', function () {
|
383
378
|
getComponent();
|
384
|
-
var copyBtn = screen.getByLabelText('copy');
|
379
|
+
var copyBtn = screen.getByLabelText('copy to clipboard');
|
385
380
|
expect(copyBtn).not.toHaveFocus();
|
386
381
|
userEvent.tab();
|
387
382
|
userEvent.tab();
|
@@ -405,7 +400,7 @@ describe('Link mode', function () {
|
|
405
400
|
switch (_context16.prev = _context16.next) {
|
406
401
|
case 0:
|
407
402
|
getComponent();
|
408
|
-
button = screen.getByLabelText('copy');
|
403
|
+
button = screen.getByLabelText('copy to clipboard');
|
409
404
|
_context16.next = 4;
|
410
405
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
411
406
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import IconButton from '../IconButton';
|
5
|
+
import Icon from '../Icon';
|
6
|
+
import { useComponentToggle } from '../../hooks';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
|
9
|
+
var IconButtonToggle = function IconButtonToggle(props) {
|
10
|
+
var toggledIcon = props.toggledIcon,
|
11
|
+
defaultIcon = props.defaultIcon,
|
12
|
+
buttonProps = props.buttonProps,
|
13
|
+
iconProps = props.iconProps,
|
14
|
+
isToggled = props.isToggled,
|
15
|
+
onToggle = props.onToggle,
|
16
|
+
title = props.title;
|
17
|
+
var conditionalRenderProps = {
|
18
|
+
ComponentToRenderIfTrue: toggledIcon,
|
19
|
+
ComponentToRenderIfFalse: defaultIcon,
|
20
|
+
condition: isToggled,
|
21
|
+
onConditionChange: onToggle
|
22
|
+
};
|
23
|
+
|
24
|
+
var _useComponentToggle = useComponentToggle(conditionalRenderProps),
|
25
|
+
handleConditionChange = _useComponentToggle.handleConditionChange,
|
26
|
+
RenderedComponent = _useComponentToggle.RenderedComponent;
|
27
|
+
|
28
|
+
return ___EmotionJSX(IconButton, _extends({
|
29
|
+
onPress: handleConditionChange
|
30
|
+
}, buttonProps, {
|
31
|
+
title: title
|
32
|
+
}), ___EmotionJSX(Icon, _extends({
|
33
|
+
icon: RenderedComponent
|
34
|
+
}, iconProps)));
|
35
|
+
};
|
36
|
+
|
37
|
+
IconButtonToggle.propTypes = {
|
38
|
+
/** Props object that is spread into the icon element. */
|
39
|
+
iconProps: PropTypes.shape({}),
|
40
|
+
|
41
|
+
/** Props object that is spread into the button element. */
|
42
|
+
buttonProps: PropTypes.shape({}),
|
43
|
+
|
44
|
+
/** The icon that will render by default. */
|
45
|
+
defaultIcon: PropTypes.elementType.isRequired,
|
46
|
+
|
47
|
+
/** The icon that will render after toggling the icon. */
|
48
|
+
toggledIcon: PropTypes.elementType.isRequired,
|
49
|
+
|
50
|
+
/** Whether or not the icon is toggled. (use only when controlled) */
|
51
|
+
isToggled: PropTypes.bool,
|
52
|
+
|
53
|
+
/** Function that is passed into the IconButton within this component. */
|
54
|
+
onToggle: PropTypes.func,
|
55
|
+
|
56
|
+
/** Content will be displayed in a tooltip on hover or focus. */
|
57
|
+
title: PropTypes.string
|
58
|
+
};
|
59
|
+
export default IconButtonToggle;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
|
+
import React, { useState } from 'react';
|
4
|
+
import EyeIcon from 'mdi-react/EyeOutlineIcon';
|
5
|
+
import EyeOffIcon from 'mdi-react/EyeOffOutlineIcon';
|
6
|
+
import IconButtonToggle from '.';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
export default {
|
9
|
+
title: 'IconButtonToggle',
|
10
|
+
component: IconButtonToggle
|
11
|
+
};
|
12
|
+
export var Default = function Default(args) {
|
13
|
+
return ___EmotionJSX(IconButtonToggle, _extends({}, args, {
|
14
|
+
toggledIcon: EyeIcon,
|
15
|
+
defaultIcon: EyeOffIcon,
|
16
|
+
buttonProps: {
|
17
|
+
'aria-label': 'eye icon'
|
18
|
+
}
|
19
|
+
}));
|
20
|
+
};
|
21
|
+
export var Controlled = function Controlled(args) {
|
22
|
+
var _useState = useState(false),
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
24
|
+
isToggled = _useState2[0],
|
25
|
+
onToggledChange = _useState2[1];
|
26
|
+
|
27
|
+
var handleToggleChange = function handleToggleChange() {
|
28
|
+
onToggledChange(!isToggled);
|
29
|
+
};
|
30
|
+
|
31
|
+
return ___EmotionJSX(IconButtonToggle, _extends({}, args, {
|
32
|
+
toggledIcon: EyeIcon,
|
33
|
+
defaultIcon: EyeOffIcon,
|
34
|
+
onToggle: handleToggleChange,
|
35
|
+
isToggled: isToggled,
|
36
|
+
buttonProps: {
|
37
|
+
'aria-label': 'eye icon'
|
38
|
+
}
|
39
|
+
}));
|
40
|
+
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import EyeIcon from 'mdi-react/EyeOutlineIcon';
|
4
|
+
import EyeOffIcon from 'mdi-react/EyeOffOutlineIcon';
|
5
|
+
import axeTest from '../../utils/testUtils/testAxe';
|
6
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
7
|
+
import IconButtonToggle from '.';
|
8
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
|
+
var iconTestId = 'test-icon';
|
10
|
+
|
11
|
+
var OnIcon = function OnIcon(props) {
|
12
|
+
return ___EmotionJSX(EyeIcon, _extends({
|
13
|
+
"data-testid": iconTestId
|
14
|
+
}, props));
|
15
|
+
};
|
16
|
+
|
17
|
+
var OffIcon = function OffIcon(props) {
|
18
|
+
return ___EmotionJSX(EyeOffIcon, _extends({
|
19
|
+
"data-testid": iconTestId
|
20
|
+
}, props));
|
21
|
+
};
|
22
|
+
|
23
|
+
var testId = 'test-button';
|
24
|
+
var defaultProps = {
|
25
|
+
buttonProps: {
|
26
|
+
'data-testid': testId,
|
27
|
+
'aria-label': 'Eye'
|
28
|
+
},
|
29
|
+
defaultIcon: OffIcon,
|
30
|
+
toggledIcon: OnIcon
|
31
|
+
};
|
32
|
+
|
33
|
+
var getComponent = function getComponent() {
|
34
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
35
|
+
return render(___EmotionJSX(IconButtonToggle, _extends({}, defaultProps, props)));
|
36
|
+
}; // Need to be added to each test file to test accessibility using axe.
|
37
|
+
|
38
|
+
|
39
|
+
axeTest(getComponent);
|
40
|
+
test('default icon button', function () {
|
41
|
+
getComponent();
|
42
|
+
var button = screen.getByRole('button');
|
43
|
+
expect(button).toHaveAttribute('data-testid', testId);
|
44
|
+
expect(button).toBeInstanceOf(HTMLButtonElement);
|
45
|
+
expect(button).toBeInTheDocument();
|
46
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './IconButtonToggle';
|
@@ -27,6 +27,7 @@ import { MenuContext } from '../../context/MenuContext';
|
|
27
27
|
import { usePropWarning } from '../../hooks';
|
28
28
|
import MenuItem from '../MenuItem';
|
29
29
|
import Box from '../Box';
|
30
|
+
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
30
31
|
/**
|
31
32
|
* Menu component intended to be used as a wrapper for MenuItem.
|
32
33
|
* This component is typically used alongside others such as PopoverMenu.
|
@@ -71,7 +72,8 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
71
72
|
return ___EmotionJSX(Box, _extends({
|
72
73
|
as: "ul",
|
73
74
|
ref: menuRef,
|
74
|
-
variant: "menu"
|
75
|
+
variant: "menu",
|
76
|
+
"aria-orientation": ORIENTATION.VERTICAL
|
75
77
|
}, others, mergeProps(focusProps, menuProps)), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
|
76
78
|
return ___EmotionJSX(MenuItem, {
|
77
79
|
key: item.key,
|
@@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event';
|
|
7
7
|
import axeTest from '../../utils/testUtils/testAxe';
|
8
8
|
import { render, screen, fireEvent } from '../../utils/testUtils/testWrapper';
|
9
9
|
import { Menu, Item } from '../../index';
|
10
|
+
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
10
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
12
|
var testTitle = 'Test Title';
|
12
13
|
var defaultProps = {
|
@@ -41,6 +42,7 @@ test('should render basic menu with children', function () {
|
|
41
42
|
expect(menu).toBeInTheDocument();
|
42
43
|
var menuItems = screen.queryAllByRole('menuitem');
|
43
44
|
expect(menuItems).toHaveLength(3);
|
45
|
+
expect(menu).toHaveAttribute('aria-orientation', ORIENTATION.VERTICAL);
|
44
46
|
});
|
45
47
|
test('should render items when selectionMode is set to single', function () {
|
46
48
|
getComponent({
|
package/lib/hooks/index.js
CHANGED
@@ -6,6 +6,8 @@ export { default as useLabelHeight } from './useLabelHeight';
|
|
6
6
|
export { default as useModalState } from './useModalState';
|
7
7
|
export { default as useOverlayPanelState } from './useOverlayPanelState';
|
8
8
|
export { default as usePropWarning } from './usePropWarning';
|
9
|
+
export { default as useProgressiveState } from './useProgressiveState';
|
10
|
+
export { default as useComponentToggle } from './useComponentToggle';
|
9
11
|
export { default as useNavBarPress } from './useNavBarPress';
|
10
12
|
export { default as useRockerButton } from './useRockerButton';
|
11
13
|
export { default as useSelectField } from './useSelectField';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useComponentToggle';
|