@pingux/astro 1.28.2-alpha.1 → 1.28.2-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/Messages/Message.js +23 -7
- package/lib/cjs/components/Messages/Messages.test.js +25 -70
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +2 -1
- package/lib/components/Messages/Message.js +22 -6
- package/lib/components/Messages/Messages.test.js +25 -67
- package/lib/recipes/RadioButtonsWithLinks.stories.js +2 -1
- package/package.json +1 -1
@@ -14,7 +14,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
14
14
|
value: true
|
15
15
|
});
|
16
16
|
|
17
|
-
exports.icons = exports["default"] = void 0;
|
17
|
+
exports.icons = exports["default"] = exports.ARIA_STATUSES = void 0;
|
18
18
|
|
19
19
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
20
20
|
|
@@ -30,8 +30,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
30
30
|
|
31
31
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
32
32
|
|
33
|
-
var _liveAnnouncer = require("@react-aria/live-announcer");
|
34
|
-
|
35
33
|
var _AlertCircleIcon = _interopRequireDefault(require("mdi-react/AlertCircleIcon"));
|
36
34
|
|
37
35
|
var _CheckCircleIcon = _interopRequireDefault(require("mdi-react/CheckCircleIcon"));
|
@@ -69,6 +67,12 @@ var icons = {
|
|
69
67
|
warning: _AlertIcon["default"]
|
70
68
|
};
|
71
69
|
exports.icons = icons;
|
70
|
+
var ARIA_STATUSES = {
|
71
|
+
SUCCESS: 'Success Message',
|
72
|
+
ERROR: 'Error Message',
|
73
|
+
WARNING: 'Warning Message'
|
74
|
+
};
|
75
|
+
exports.ARIA_STATUSES = ARIA_STATUSES;
|
72
76
|
|
73
77
|
var CloseButton = function CloseButton(_ref) {
|
74
78
|
var color = _ref.color,
|
@@ -115,9 +119,6 @@ var Message = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
115
119
|
}
|
116
120
|
};
|
117
121
|
|
118
|
-
(0, _react.useEffect)(function () {
|
119
|
-
(0, _liveAnnouncer.announce)(children, 'polite');
|
120
|
-
}, []);
|
121
122
|
var innerRef = (0, _react.useRef)(null);
|
122
123
|
|
123
124
|
var _useState = (0, _react.useState)(0),
|
@@ -134,13 +135,28 @@ var Message = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
134
135
|
}),
|
135
136
|
wrapperClasses = _useStatusClasses3.classNames;
|
136
137
|
|
138
|
+
var ariaStatus = function ariaStatus(ariaStatusClass) {
|
139
|
+
if (ariaStatusClass === 'is-success') {
|
140
|
+
return ARIA_STATUSES.SUCCESS;
|
141
|
+
} else if (ariaStatusClass === 'is-error') {
|
142
|
+
return ARIA_STATUSES.ERROR;
|
143
|
+
} else if (ariaStatusClass === 'is-warning') {
|
144
|
+
return ARIA_STATUSES.WARNING;
|
145
|
+
}
|
146
|
+
|
147
|
+
return '';
|
148
|
+
};
|
149
|
+
|
137
150
|
return (0, _react2.jsx)(_Box["default"], {
|
138
151
|
variant: "messages.transition",
|
139
152
|
className: wrapperClasses,
|
140
153
|
sx: {
|
141
154
|
maxHeight: !isHidden ? innerHeight : 0
|
142
155
|
},
|
143
|
-
"data-id": dataId
|
156
|
+
"data-id": dataId,
|
157
|
+
role: "status",
|
158
|
+
"aria-live": "polite",
|
159
|
+
"aria-label": ariaStatus(statusClasses)
|
144
160
|
}, (0, _react2.jsx)(_Box["default"], {
|
145
161
|
ref: innerRef
|
146
162
|
}, (0, _react2.jsx)(_Box["default"], {
|
@@ -10,19 +10,15 @@ var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
|
10
10
|
|
11
11
|
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
12
12
|
|
13
|
-
var
|
13
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
14
14
|
|
15
|
-
var
|
16
|
-
|
17
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
15
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
18
16
|
|
19
|
-
var
|
17
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
20
18
|
|
21
19
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
22
20
|
|
23
|
-
var _react =
|
24
|
-
|
25
|
-
var _liveAnnouncer = require("@react-aria/live-announcer");
|
21
|
+
var _react = _interopRequireDefault(require("react"));
|
26
22
|
|
27
23
|
var _collections = require("@react-stately/collections");
|
28
24
|
|
@@ -34,7 +30,7 @@ var _testWrapper = require("../../utils/testUtils/testWrapper");
|
|
34
30
|
|
35
31
|
var _ = _interopRequireWildcard(require("."));
|
36
32
|
|
37
|
-
var
|
33
|
+
var _Message = require("../Messages/Message");
|
38
34
|
|
39
35
|
var _react2 = require("@emotion/react");
|
40
36
|
|
@@ -47,7 +43,6 @@ jest.mock('@react-aria/live-announcer', function () {
|
|
47
43
|
announce: jest.fn()
|
48
44
|
};
|
49
45
|
});
|
50
|
-
var mockAnnounce = _liveAnnouncer.announce;
|
51
46
|
var testId = 'test-messages';
|
52
47
|
var defaultProps = {
|
53
48
|
'data-testid': testId
|
@@ -81,37 +76,6 @@ var getWithDynamicList = function getWithDynamicList() {
|
|
81
76
|
return renderFn((0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, defaultProps, props), function (item) {
|
82
77
|
return (0, _react2.jsx)(_collections.Item, item, item.text);
|
83
78
|
}));
|
84
|
-
};
|
85
|
-
|
86
|
-
var MessagesWithButton = function MessagesWithButton(props) {
|
87
|
-
var _useState = (0, _react.useState)([]),
|
88
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
89
|
-
messages = _useState2[0],
|
90
|
-
setMessages = _useState2[1];
|
91
|
-
|
92
|
-
var addMessage = function addMessage() {
|
93
|
-
var _context;
|
94
|
-
|
95
|
-
setMessages((0, _concat["default"])(_context = []).call(_context, messages, [{
|
96
|
-
key: "message".concat(messages.length + 1),
|
97
|
-
text: "New message ".concat(messages.length + 1),
|
98
|
-
status: 'default'
|
99
|
-
}]));
|
100
|
-
};
|
101
|
-
|
102
|
-
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Button["default"], {
|
103
|
-
onPress: addMessage
|
104
|
-
}, "Click me!"), (0, _react2.jsx)(_["default"], (0, _extends2["default"])({
|
105
|
-
items: messages
|
106
|
-
}, props), function (item) {
|
107
|
-
return (0, _react2.jsx)(_collections.Item, item, item.text);
|
108
|
-
}));
|
109
|
-
};
|
110
|
-
|
111
|
-
var getWithButton = function getWithButton() {
|
112
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
113
|
-
var renderFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _testWrapper.render;
|
114
|
-
return renderFn((0, _react2.jsx)(MessagesWithButton, (0, _extends2["default"])({}, defaultProps, props)));
|
115
79
|
}; // Need to be added to each test file to test accessibility using axe.
|
116
80
|
|
117
81
|
|
@@ -191,40 +155,31 @@ test('Item accepts a data-id and the data-id can be found in the DOM', function
|
|
191
155
|
|
192
156
|
expect(firstMessage).toHaveAttribute('data-id', 'message1');
|
193
157
|
});
|
194
|
-
|
195
|
-
|
196
|
-
// Mock navigator.platform so we take that codepath.
|
197
|
-
var platformMock;
|
198
|
-
beforeEach(function () {
|
199
|
-
platformMock = jest.spyOn(navigator, 'platform', 'get').mockImplementation(function () {
|
200
|
-
return 'MacIntel';
|
201
|
-
});
|
202
|
-
});
|
203
|
-
afterEach(function () {
|
204
|
-
jest.clearAllMocks();
|
205
|
-
platformMock.mockRestore();
|
206
|
-
});
|
207
|
-
test('should announce on render', function () {
|
208
|
-
getWithDynamicList({
|
209
|
-
items: items
|
210
|
-
});
|
211
|
-
(0, _forEach["default"])(items).call(items, function (item) {
|
212
|
-
return expect(mockAnnounce).toHaveBeenCalledWith(item.text, 'polite');
|
213
|
-
});
|
214
|
-
});
|
215
|
-
test('should announce on adding item', function () {
|
216
|
-
getWithButton();
|
158
|
+
test('message has role and aria-live attributes', function () {
|
159
|
+
getComponent();
|
217
160
|
|
218
|
-
|
161
|
+
var _screen$getByTestId3 = _testWrapper.screen.getByTestId(testId),
|
162
|
+
firstMessage = _screen$getByTestId3.firstChild;
|
219
163
|
|
220
|
-
|
164
|
+
expect(firstMessage).toHaveAttribute('role', 'status');
|
165
|
+
expect(firstMessage).toHaveAttribute('aria-live', 'polite');
|
166
|
+
});
|
167
|
+
test('messages with a status have an aria-label announcing the status', function () {
|
168
|
+
getComponent();
|
221
169
|
|
222
|
-
|
170
|
+
var successMessage = _testWrapper.screen.getAllByRole('status')[1];
|
223
171
|
|
224
|
-
|
172
|
+
expect(successMessage).toHaveAttribute('aria-label', _Message.ARIA_STATUSES[0]);
|
173
|
+
});
|
174
|
+
test('messages without a status do not have an aria-label announcing the status', function () {
|
175
|
+
var _context;
|
225
176
|
|
226
|
-
|
227
|
-
|
177
|
+
getComponent();
|
178
|
+
|
179
|
+
var statusMessage = _testWrapper.screen.getAllByRole('status')[0];
|
180
|
+
|
181
|
+
(0, _map["default"])(_context = (0, _keys["default"])(_Message.ARIA_STATUSES)).call(_context, function (key) {
|
182
|
+
return expect(statusMessage).not.toHaveAttribute('aria-label', _Message.ARIA_STATUSES[key]);
|
228
183
|
});
|
229
184
|
});
|
230
185
|
test('should render messages with messagesReducerStory', function () {
|
@@ -110,7 +110,8 @@ var Default = function Default() {
|
|
110
110
|
fontWeight: 2
|
111
111
|
}
|
112
112
|
}, "Permissions"), (0, _react2.jsx)(_index.IconButton, {
|
113
|
-
onPress: onPress
|
113
|
+
onPress: onPress,
|
114
|
+
"aria-label": "close icon button"
|
114
115
|
}, (0, _react2.jsx)(_index.Icon, {
|
115
116
|
icon: _CloseIcon["default"]
|
116
117
|
}))), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
|
@@ -4,9 +4,8 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
4
4
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
5
5
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
6
|
var _excluded = ["color"];
|
7
|
-
import React, { forwardRef,
|
7
|
+
import React, { forwardRef, useRef, useState, useLayoutEffect } from 'react';
|
8
8
|
import PropTypes from 'prop-types';
|
9
|
-
import { announce } from '@react-aria/live-announcer';
|
10
9
|
import AlertCircleIcon from 'mdi-react/AlertCircleIcon';
|
11
10
|
import CheckCircleIcon from 'mdi-react/CheckCircleIcon';
|
12
11
|
import CloseIcon from 'mdi-react/CloseIcon';
|
@@ -25,6 +24,11 @@ export var icons = {
|
|
25
24
|
error: AlertCircleIcon,
|
26
25
|
warning: AlertIcon
|
27
26
|
};
|
27
|
+
export var ARIA_STATUSES = {
|
28
|
+
SUCCESS: 'Success Message',
|
29
|
+
ERROR: 'Error Message',
|
30
|
+
WARNING: 'Warning Message'
|
31
|
+
};
|
28
32
|
|
29
33
|
var CloseButton = function CloseButton(_ref) {
|
30
34
|
var color = _ref.color,
|
@@ -72,9 +76,6 @@ var Message = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
72
76
|
}
|
73
77
|
};
|
74
78
|
|
75
|
-
useEffect(function () {
|
76
|
-
announce(children, 'polite');
|
77
|
-
}, []);
|
78
79
|
var innerRef = useRef(null);
|
79
80
|
|
80
81
|
var _useState = useState(0),
|
@@ -91,13 +92,28 @@ var Message = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
91
92
|
}),
|
92
93
|
wrapperClasses = _useStatusClasses3.classNames;
|
93
94
|
|
95
|
+
var ariaStatus = function ariaStatus(ariaStatusClass) {
|
96
|
+
if (ariaStatusClass === 'is-success') {
|
97
|
+
return ARIA_STATUSES.SUCCESS;
|
98
|
+
} else if (ariaStatusClass === 'is-error') {
|
99
|
+
return ARIA_STATUSES.ERROR;
|
100
|
+
} else if (ariaStatusClass === 'is-warning') {
|
101
|
+
return ARIA_STATUSES.WARNING;
|
102
|
+
}
|
103
|
+
|
104
|
+
return '';
|
105
|
+
};
|
106
|
+
|
94
107
|
return ___EmotionJSX(Box, {
|
95
108
|
variant: "messages.transition",
|
96
109
|
className: wrapperClasses,
|
97
110
|
sx: {
|
98
111
|
maxHeight: !isHidden ? innerHeight : 0
|
99
112
|
},
|
100
|
-
"data-id": dataId
|
113
|
+
"data-id": dataId,
|
114
|
+
role: "status",
|
115
|
+
"aria-live": "polite",
|
116
|
+
"aria-label": ariaStatus(statusClasses)
|
101
117
|
}, ___EmotionJSX(Box, {
|
102
118
|
ref: innerRef
|
103
119
|
}, ___EmotionJSX(Box, {
|
@@ -1,23 +1,20 @@
|
|
1
|
-
import
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
2
3
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
3
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
4
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
5
4
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
6
|
-
import React
|
7
|
-
import { announce } from '@react-aria/live-announcer';
|
5
|
+
import React from 'react';
|
8
6
|
import { Item } from '@react-stately/collections';
|
9
7
|
import userEvent from '@testing-library/user-event';
|
10
8
|
import axeTest from '../../utils/testUtils/testAxe';
|
11
9
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
12
10
|
import Messages, { messagesReducerStory, multiMessagesReducerStory } from '.';
|
13
|
-
import
|
11
|
+
import { ARIA_STATUSES } from '../Messages/Message';
|
14
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
13
|
jest.mock('@react-aria/live-announcer', function () {
|
16
14
|
return {
|
17
15
|
announce: jest.fn()
|
18
16
|
};
|
19
17
|
});
|
20
|
-
var mockAnnounce = announce;
|
21
18
|
var testId = 'test-messages';
|
22
19
|
var defaultProps = {
|
23
20
|
'data-testid': testId
|
@@ -51,37 +48,6 @@ var getWithDynamicList = function getWithDynamicList() {
|
|
51
48
|
return renderFn(___EmotionJSX(Messages, _extends({}, defaultProps, props), function (item) {
|
52
49
|
return ___EmotionJSX(Item, item, item.text);
|
53
50
|
}));
|
54
|
-
};
|
55
|
-
|
56
|
-
var MessagesWithButton = function MessagesWithButton(props) {
|
57
|
-
var _useState = useState([]),
|
58
|
-
_useState2 = _slicedToArray(_useState, 2),
|
59
|
-
messages = _useState2[0],
|
60
|
-
setMessages = _useState2[1];
|
61
|
-
|
62
|
-
var addMessage = function addMessage() {
|
63
|
-
var _context;
|
64
|
-
|
65
|
-
setMessages(_concatInstanceProperty(_context = []).call(_context, messages, [{
|
66
|
-
key: "message".concat(messages.length + 1),
|
67
|
-
text: "New message ".concat(messages.length + 1),
|
68
|
-
status: 'default'
|
69
|
-
}]));
|
70
|
-
};
|
71
|
-
|
72
|
-
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Button, {
|
73
|
-
onPress: addMessage
|
74
|
-
}, "Click me!"), ___EmotionJSX(Messages, _extends({
|
75
|
-
items: messages
|
76
|
-
}, props), function (item) {
|
77
|
-
return ___EmotionJSX(Item, item, item.text);
|
78
|
-
}));
|
79
|
-
};
|
80
|
-
|
81
|
-
var getWithButton = function getWithButton() {
|
82
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
83
|
-
var renderFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : render;
|
84
|
-
return renderFn(___EmotionJSX(MessagesWithButton, _extends({}, defaultProps, props)));
|
85
51
|
}; // Need to be added to each test file to test accessibility using axe.
|
86
52
|
|
87
53
|
|
@@ -147,36 +113,28 @@ test('Item accepts a data-id and the data-id can be found in the DOM', function
|
|
147
113
|
|
148
114
|
expect(firstMessage).toHaveAttribute('data-id', 'message1');
|
149
115
|
});
|
150
|
-
|
151
|
-
|
152
|
-
// Mock navigator.platform so we take that codepath.
|
153
|
-
var platformMock;
|
154
|
-
beforeEach(function () {
|
155
|
-
platformMock = jest.spyOn(navigator, 'platform', 'get').mockImplementation(function () {
|
156
|
-
return 'MacIntel';
|
157
|
-
});
|
158
|
-
});
|
159
|
-
afterEach(function () {
|
160
|
-
jest.clearAllMocks();
|
161
|
-
platformMock.mockRestore();
|
162
|
-
});
|
163
|
-
test('should announce on render', function () {
|
164
|
-
getWithDynamicList({
|
165
|
-
items: items
|
166
|
-
});
|
116
|
+
test('message has role and aria-live attributes', function () {
|
117
|
+
getComponent();
|
167
118
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
119
|
+
var _screen$getByTestId3 = screen.getByTestId(testId),
|
120
|
+
firstMessage = _screen$getByTestId3.firstChild;
|
121
|
+
|
122
|
+
expect(firstMessage).toHaveAttribute('role', 'status');
|
123
|
+
expect(firstMessage).toHaveAttribute('aria-live', 'polite');
|
124
|
+
});
|
125
|
+
test('messages with a status have an aria-label announcing the status', function () {
|
126
|
+
getComponent();
|
127
|
+
var successMessage = screen.getAllByRole('status')[1];
|
128
|
+
expect(successMessage).toHaveAttribute('aria-label', ARIA_STATUSES[0]);
|
129
|
+
});
|
130
|
+
test('messages without a status do not have an aria-label announcing the status', function () {
|
131
|
+
var _context;
|
132
|
+
|
133
|
+
getComponent();
|
134
|
+
var statusMessage = screen.getAllByRole('status')[0];
|
135
|
+
|
136
|
+
_mapInstanceProperty(_context = _Object$keys(ARIA_STATUSES)).call(_context, function (key) {
|
137
|
+
return expect(statusMessage).not.toHaveAttribute('aria-label', ARIA_STATUSES[key]);
|
180
138
|
});
|
181
139
|
});
|
182
140
|
test('should render messages with messagesReducerStory', function () {
|
@@ -78,7 +78,8 @@ export var Default = function Default() {
|
|
78
78
|
fontWeight: 2
|
79
79
|
}
|
80
80
|
}, "Permissions"), ___EmotionJSX(IconButton, {
|
81
|
-
onPress: onPress
|
81
|
+
onPress: onPress,
|
82
|
+
"aria-label": "close icon button"
|
82
83
|
}, ___EmotionJSX(Icon, {
|
83
84
|
icon: CloseIcon
|
84
85
|
}))), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|