@pingux/astro 1.1.1-alpha.4 → 1.2.0-alpha.10
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/Breadcrumbs/BreadcrumbItem.js +3 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +24 -14
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +9 -0
- package/lib/cjs/components/Button/Button.js +5 -2
- package/lib/cjs/components/Button/Button.stories.js +71 -17
- package/lib/cjs/components/Button/Button.test.js +26 -0
- package/lib/cjs/components/CopyText/CopyButton.js +9 -2
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +338 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +295 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +287 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/index.js +18 -0
- package/lib/cjs/components/HelpHint/HelpHint.js +24 -6
- package/lib/cjs/components/HelpHint/HelpHint.stories.js +57 -0
- package/lib/cjs/components/HelpHint/HelpHint.test.js +80 -0
- package/lib/cjs/components/Link/Link.js +15 -4
- package/lib/cjs/components/Link/Link.stories.js +10 -0
- package/lib/cjs/components/Messages/Messages.reducer.js +2 -1
- package/lib/cjs/components/Messages/Messages.stories.js +10 -10
- package/lib/cjs/components/Messages/Messages.test.js +15 -1
- package/lib/cjs/components/Messages/index.js +21 -2
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +3 -1
- package/lib/cjs/components/NumberField/NumberField.js +3 -1
- package/lib/cjs/components/NumberField/NumberField.test.js +7 -0
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +2 -16
- package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +44 -0
- package/lib/cjs/components/TextField/TextField.stories.js +79 -2
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/index.js +10 -0
- package/lib/cjs/styles/theme.js +1 -0
- package/lib/cjs/styles/variants/boxes.js +13 -0
- package/lib/cjs/styles/variants/buttons.js +101 -2
- package/lib/cjs/styles/variants/index.js +11 -1
- package/lib/cjs/styles/variants/links.js +67 -0
- package/lib/cjs/styles/variants/text.js +23 -0
- package/lib/cjs/styles/variants/variants.js +2 -2
- package/lib/cjs/utils/devUtils/constants/animals.js +11 -0
- package/lib/cjs/utils/devUtils/constants/firstNames.js +11 -0
- package/lib/cjs/utils/devUtils/createMockData.js +96 -0
- package/lib/components/Breadcrumbs/BreadcrumbItem.js +4 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +24 -15
- package/lib/components/Breadcrumbs/Breadcrumbs.test.js +9 -0
- package/lib/components/Button/Button.js +6 -3
- package/lib/components/Button/Button.stories.js +53 -5
- package/lib/components/Button/Button.test.js +20 -0
- package/lib/components/CopyText/CopyButton.js +7 -2
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +296 -0
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +256 -0
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +246 -0
- package/lib/components/EnvironmentBreadcrumb/index.js +1 -0
- package/lib/components/HelpHint/HelpHint.js +25 -5
- package/lib/components/HelpHint/HelpHint.stories.js +34 -0
- package/lib/components/HelpHint/HelpHint.test.js +58 -0
- package/lib/components/Link/Link.js +16 -5
- package/lib/components/Link/Link.stories.js +8 -0
- package/lib/components/Messages/Messages.reducer.js +1 -1
- package/lib/components/Messages/Messages.stories.js +1 -1
- package/lib/components/Messages/Messages.test.js +11 -1
- package/lib/components/Messages/index.js +2 -1
- package/lib/components/MultivaluesField/MultivaluesField.js +3 -1
- package/lib/components/NumberField/NumberField.js +2 -1
- package/lib/components/NumberField/NumberField.test.js +7 -0
- package/lib/components/OverlayPanel/OverlayPanel.js +3 -16
- package/lib/components/OverlayPanel/OverlayPanel.test.js +38 -0
- package/lib/components/TextField/TextField.stories.js +72 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/index.js +1 -0
- package/lib/styles/theme.js +2 -1
- package/lib/styles/variants/boxes.js +13 -0
- package/lib/styles/variants/buttons.js +101 -2
- package/lib/styles/variants/index.js +1 -0
- package/lib/styles/variants/links.js +46 -0
- package/lib/styles/variants/text.js +23 -0
- package/lib/styles/variants/variants.js +2 -2
- package/lib/utils/devUtils/constants/animals.js +1 -0
- package/lib/utils/devUtils/constants/firstNames.js +1 -0
- package/lib/utils/devUtils/createMockData.js +68 -0
- package/package.json +2 -2
- package/lib/cjs/styles/variants/link.js +0 -27
- package/lib/styles/variants/link.js +0 -17
@@ -0,0 +1,246 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
2
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
3
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
4
|
+
import React from 'react';
|
5
|
+
import userEvent from '@testing-library/user-event';
|
6
|
+
import { Section } from '@react-stately/collections';
|
7
|
+
import { axe } from 'jest-axe';
|
8
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
9
|
+
import { EnvironmentBreadcrumb, Item, OverlayProvider } from '../../index';
|
10
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
|
+
var testEnvBreadcrumb = 'test-env-breadcrumb';
|
12
|
+
var testName = 'test-name';
|
13
|
+
var testSelectedItem = 'test-selected-item';
|
14
|
+
var testSearchLabel = 'test-Search-Label';
|
15
|
+
var items = [{
|
16
|
+
name: 'a'
|
17
|
+
}, {
|
18
|
+
name: 'b'
|
19
|
+
}, {
|
20
|
+
name: 'c'
|
21
|
+
}];
|
22
|
+
var itemsWithSections = [{
|
23
|
+
name: 'Heading 1',
|
24
|
+
options: [{
|
25
|
+
name: 'Foo'
|
26
|
+
}, {
|
27
|
+
name: 'Bar'
|
28
|
+
}, {
|
29
|
+
name: 'Baz'
|
30
|
+
}]
|
31
|
+
}];
|
32
|
+
var defaultProps = {
|
33
|
+
'data-testid': testEnvBreadcrumb,
|
34
|
+
name: testName,
|
35
|
+
selectedItem: testSelectedItem,
|
36
|
+
searchProps: {
|
37
|
+
label: testSearchLabel
|
38
|
+
},
|
39
|
+
items: items
|
40
|
+
};
|
41
|
+
var defaultWithSectionsProps = {
|
42
|
+
'data-testid': testEnvBreadcrumb,
|
43
|
+
name: testName,
|
44
|
+
selectedItem: testSelectedItem,
|
45
|
+
searchProps: {
|
46
|
+
label: testSearchLabel
|
47
|
+
},
|
48
|
+
items: itemsWithSections
|
49
|
+
};
|
50
|
+
var onSelectionChange = jest.fn();
|
51
|
+
|
52
|
+
var getComponent = function getComponent(props) {
|
53
|
+
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultProps, props), function (item) {
|
54
|
+
return ___EmotionJSX(Item, {
|
55
|
+
key: item.name
|
56
|
+
}, item.name);
|
57
|
+
})));
|
58
|
+
};
|
59
|
+
|
60
|
+
var getSectionsComponent = function getSectionsComponent() {
|
61
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
62
|
+
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultWithSectionsProps, props), function (section) {
|
63
|
+
return (// eslint-disable-next-line testing-library/no-node-access
|
64
|
+
___EmotionJSX(Section, {
|
65
|
+
key: section.name,
|
66
|
+
name: section.name,
|
67
|
+
items: section.options
|
68
|
+
}, function (item) {
|
69
|
+
return ___EmotionJSX(Item, {
|
70
|
+
key: item.name,
|
71
|
+
childItems: item.options
|
72
|
+
}, item.name);
|
73
|
+
})
|
74
|
+
);
|
75
|
+
})));
|
76
|
+
};
|
77
|
+
|
78
|
+
beforeAll(function () {
|
79
|
+
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function () {
|
80
|
+
return 1000;
|
81
|
+
});
|
82
|
+
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(function () {
|
83
|
+
return 1000;
|
84
|
+
});
|
85
|
+
window.HTMLElement.prototype.scrollIntoView = jest.fn();
|
86
|
+
jest.spyOn(window.screen, 'width', 'get').mockImplementation(function () {
|
87
|
+
return 1024;
|
88
|
+
});
|
89
|
+
jest.spyOn(window, 'requestAnimationFrame').mockImplementation(function (cb) {
|
90
|
+
return cb();
|
91
|
+
});
|
92
|
+
jest.useFakeTimers();
|
93
|
+
});
|
94
|
+
afterEach(function () {
|
95
|
+
jest.clearAllMocks();
|
96
|
+
onSelectionChange.mockClear();
|
97
|
+
});
|
98
|
+
afterAll(function () {
|
99
|
+
jest.restoreAllMocks();
|
100
|
+
});
|
101
|
+
test('should render environment breadcrumb component by default', function () {
|
102
|
+
getComponent();
|
103
|
+
var imageUploadButton = screen.getByTestId(testEnvBreadcrumb);
|
104
|
+
expect(imageUploadButton).toBeInstanceOf(HTMLDivElement);
|
105
|
+
expect(imageUploadButton).toBeInTheDocument();
|
106
|
+
});
|
107
|
+
test('should display name', function () {
|
108
|
+
getComponent();
|
109
|
+
expect(screen.getByText(testName)).toBeInTheDocument();
|
110
|
+
});
|
111
|
+
test('should display selectedItem', function () {
|
112
|
+
getComponent();
|
113
|
+
expect(screen.getByText(testSelectedItem)).toBeInTheDocument();
|
114
|
+
});
|
115
|
+
test('should call onNamePress when name pressed', function () {
|
116
|
+
var onNamePressMock = jest.fn();
|
117
|
+
getComponent({
|
118
|
+
onNamePress: onNamePressMock
|
119
|
+
});
|
120
|
+
expect(onNamePressMock).not.toHaveBeenCalled();
|
121
|
+
userEvent.click(screen.getByText(testName));
|
122
|
+
expect(onNamePressMock).toHaveBeenCalledTimes(1);
|
123
|
+
});
|
124
|
+
test('should not call onNamePress when current env button pressed', function () {
|
125
|
+
var onNamePressMock = jest.fn();
|
126
|
+
getComponent({
|
127
|
+
onNamePress: onNamePressMock
|
128
|
+
});
|
129
|
+
expect(onNamePressMock).not.toHaveBeenCalled();
|
130
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
131
|
+
expect(onNamePressMock).not.toHaveBeenCalled();
|
132
|
+
});
|
133
|
+
test('should render items passed in props', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
134
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
135
|
+
while (1) {
|
136
|
+
switch (_context.prev = _context.next) {
|
137
|
+
case 0:
|
138
|
+
getComponent();
|
139
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
140
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
141
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
142
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
143
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
144
|
+
|
145
|
+
case 6:
|
146
|
+
case "end":
|
147
|
+
return _context.stop();
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}, _callee);
|
151
|
+
})));
|
152
|
+
test('should render items with sections passed in props', function () {
|
153
|
+
getSectionsComponent();
|
154
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
155
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
156
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
157
|
+
expect(screen.getByRole('group')).toBeInTheDocument();
|
158
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
159
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
160
|
+
});
|
161
|
+
test('should call onSelectionChange when env clicked', function () {
|
162
|
+
var onSelectionChangeMock = jest.fn();
|
163
|
+
getComponent({
|
164
|
+
onSelectionChange: onSelectionChangeMock
|
165
|
+
});
|
166
|
+
expect(onSelectionChangeMock).not.toHaveBeenCalled();
|
167
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
168
|
+
userEvent.click(screen.getByText(items[0].name));
|
169
|
+
expect(onSelectionChangeMock).toHaveBeenNthCalledWith(1, items[0].name);
|
170
|
+
});
|
171
|
+
test('should disable item if his hey passed in the disabledKeys prop', function () {
|
172
|
+
getComponent({
|
173
|
+
disabledKeys: ['a']
|
174
|
+
});
|
175
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
176
|
+
expect(screen.getByText(items[0].name)).toHaveClass('is-disabled');
|
177
|
+
});
|
178
|
+
test('should call onPopoverOpen if it is passed in the props', function () {
|
179
|
+
var onPopoverOpenMock = jest.fn();
|
180
|
+
getComponent({
|
181
|
+
onPopoverOpen: onPopoverOpenMock
|
182
|
+
});
|
183
|
+
expect(onPopoverOpenMock).not.toHaveBeenCalled();
|
184
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
185
|
+
expect(onPopoverOpenMock).toHaveBeenCalled();
|
186
|
+
});
|
187
|
+
test('should call onPopoverClose if it is passed in the props', function () {
|
188
|
+
var onPopoverCloseMock = jest.fn();
|
189
|
+
getComponent({
|
190
|
+
onPopoverClose: onPopoverCloseMock
|
191
|
+
});
|
192
|
+
expect(onPopoverCloseMock).not.toHaveBeenCalled();
|
193
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
194
|
+
userEvent.click(screen.getByText(testName));
|
195
|
+
expect(onPopoverCloseMock).toHaveBeenCalled();
|
196
|
+
});
|
197
|
+
test('should close popover when other component clicked', function () {
|
198
|
+
getComponent();
|
199
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
200
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
201
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
202
|
+
userEvent.click(screen.getByText(testName));
|
203
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
204
|
+
expect(screen.queryAllByRole('option')).not.toHaveLength(3);
|
205
|
+
});
|
206
|
+
test('should render current env node if passed in props', function () {
|
207
|
+
var testSelectedItemId = 'testSelectedItemId';
|
208
|
+
getComponent({
|
209
|
+
selectedItem: ___EmotionJSX("div", {
|
210
|
+
"data-testid": testSelectedItemId
|
211
|
+
})
|
212
|
+
});
|
213
|
+
expect(screen.getByTestId(testSelectedItemId)).toBeInTheDocument();
|
214
|
+
});
|
215
|
+
test('should show empty state in search if there are no results', function () {
|
216
|
+
var testEmptySearchText = 'testEmptySearchText';
|
217
|
+
getComponent({
|
218
|
+
emptySearchText: testEmptySearchText
|
219
|
+
});
|
220
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
221
|
+
userEvent.type(screen.getByRole('searchbox'), '111');
|
222
|
+
expect(screen.getByText(testEmptySearchText)).toBeInTheDocument();
|
223
|
+
});
|
224
|
+
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
225
|
+
var _getComponent, container, results;
|
226
|
+
|
227
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
228
|
+
while (1) {
|
229
|
+
switch (_context2.prev = _context2.next) {
|
230
|
+
case 0:
|
231
|
+
jest.useRealTimers();
|
232
|
+
_getComponent = getComponent(), container = _getComponent.container;
|
233
|
+
_context2.next = 4;
|
234
|
+
return axe(container);
|
235
|
+
|
236
|
+
case 4:
|
237
|
+
results = _context2.sent;
|
238
|
+
expect(results).toHaveNoViolations();
|
239
|
+
|
240
|
+
case 6:
|
241
|
+
case "end":
|
242
|
+
return _context2.stop();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}, _callee2);
|
246
|
+
})));
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './EnvironmentBreadcrumb';
|
@@ -1,12 +1,32 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
3
|
import React, { forwardRef } from 'react';
|
4
|
-
import HelpIcon from 'mdi-react/HelpIcon';
|
5
4
|
import PropTypes from 'prop-types';
|
6
5
|
import IconButton from '../IconButton';
|
7
6
|
import TooltipTrigger, { Tooltip } from '../TooltipTrigger';
|
8
7
|
import Icon from '../Icon';
|
9
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
|
+
|
10
|
+
var HelpIcon = function HelpIcon() {
|
11
|
+
return ___EmotionJSX("svg", {
|
12
|
+
width: "7",
|
13
|
+
height: "9",
|
14
|
+
viewBox: "0 0 7 9",
|
15
|
+
fill: "none",
|
16
|
+
xmlns: "http://www.w3.org/2000/svg"
|
17
|
+
}, ___EmotionJSX("path", {
|
18
|
+
d: "M2.56685 7.306V9H4.29385V7.306H2.56685ZM0.795848 3.676H2.41285C2.41285 3.478 2.43485 3.29467 2.47885 3.126C2.52285 2.95 2.58885 2.79967 2.67685 2.675C2.77218 2.543 2.88951 2.44033 3.02885 2.367C3.17551 2.28633 3.34785 2.246 3.54585 2.246C3.83918 2.246 4.06651 2.32667 4.22785 2.488C4.39651 2.64933 4.48085 2.89867 4.48085 3.236C4.48818 3.434 4.45151 3.599 4.37085 3.731C4.29751 3.863 4.19851 3.984 4.07385 4.094C3.94918 4.204 3.81351 4.314 3.66685 4.424C3.52018 4.534 3.38085 4.666 3.24885 4.82C3.11685 4.96667 2.99951 5.14633 2.89685 5.359C2.80151 5.57167 2.74285 5.83567 2.72085 6.151V6.646H4.20585V6.228C4.23518 6.008 4.30485 5.82467 4.41485 5.678C4.53218 5.53133 4.66418 5.403 4.81085 5.293C4.95751 5.17567 5.11151 5.062 5.27285 4.952C5.44151 4.83467 5.59185 4.69533 5.72385 4.534C5.86318 4.37267 5.97685 4.17833 6.06485 3.951C6.16018 3.72367 6.20785 3.434 6.20785 3.082C6.20785 2.86933 6.16018 2.642 6.06485 2.4C5.97685 2.15067 5.82651 1.91967 5.61385 1.707C5.40118 1.49433 5.11885 1.31833 4.76685 1.179C4.42218 1.03233 3.98951 0.959 3.46885 0.959C3.06551 0.959 2.69885 1.02867 2.36885 1.168C2.04618 1.3 1.76751 1.487 1.53285 1.729C1.30551 1.971 1.12585 2.257 0.993848 2.587C0.869181 2.917 0.803181 3.28 0.795848 3.676Z",
|
19
|
+
fill: "#3B4A58"
|
20
|
+
}));
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* A `HelpHint` is a composed component using tooltip trigger and icon button.
|
24
|
+
*
|
25
|
+
* For customization the trigger icon,
|
26
|
+
* please see the [TooltipTrigger](./?path=/docs/tooltiptrigger--default) docs.
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
10
30
|
var HelpHint = /*#__PURE__*/forwardRef(function (props, ref) {
|
11
31
|
var children = props.children,
|
12
32
|
tooltipProps = props.tooltipProps,
|
@@ -14,14 +34,14 @@ var HelpHint = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
14
34
|
others = _objectWithoutProperties(props, ["children", "tooltipProps", "iconButtonProps"]);
|
15
35
|
|
16
36
|
return ___EmotionJSX(TooltipTrigger, _extends({
|
17
|
-
ref: ref
|
18
|
-
|
37
|
+
ref: ref,
|
38
|
+
direction: "top"
|
39
|
+
}, others, tooltipProps), ___EmotionJSX(IconButton, _extends({
|
19
40
|
variant: "helpHint",
|
20
41
|
"aria-label": "label help hint",
|
21
42
|
"data-testid": "help-hint__button"
|
22
43
|
}, iconButtonProps), ___EmotionJSX(Icon, {
|
23
|
-
icon: HelpIcon
|
24
|
-
size: "11px"
|
44
|
+
icon: HelpIcon
|
25
45
|
})), ___EmotionJSX(Tooltip, tooltipProps, children));
|
26
46
|
});
|
27
47
|
HelpHint.propTypes = {
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import HelpHint from '.';
|
3
|
+
import Box from '../Box';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
export default {
|
6
|
+
title: 'HelpHint',
|
7
|
+
component: HelpHint,
|
8
|
+
argTypes: {
|
9
|
+
children: {
|
10
|
+
description: 'Tooltip content',
|
11
|
+
defaultValue: 'Text of the tooltip right here...',
|
12
|
+
control: {
|
13
|
+
type: 'text'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
};
|
18
|
+
export var Default = function Default(args) {
|
19
|
+
return ___EmotionJSX(Box, {
|
20
|
+
p: 50
|
21
|
+
}, ___EmotionJSX(HelpHint, args));
|
22
|
+
};
|
23
|
+
export var WithTooltipAndIconButtonProps = function WithTooltipAndIconButtonProps() {
|
24
|
+
return ___EmotionJSX(Box, {
|
25
|
+
p: 50
|
26
|
+
}, ___EmotionJSX(HelpHint, {
|
27
|
+
tooltipProps: {
|
28
|
+
direction: 'bottom'
|
29
|
+
},
|
30
|
+
iconButtonProps: {
|
31
|
+
'aria-label': 'Help hint'
|
32
|
+
}
|
33
|
+
}, "Text of the tooltip right here..."));
|
34
|
+
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import userEvent from '@testing-library/user-event';
|
4
|
+
import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
5
|
+
import axeTest from '../../utils/testUtils/testAxe';
|
6
|
+
import HelpHint from './HelpHint';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
var testId = 'help-hint__button';
|
9
|
+
var tooltipValue = 'Some text';
|
10
|
+
var defaultProps = {
|
11
|
+
children: tooltipValue
|
12
|
+
};
|
13
|
+
|
14
|
+
var getComponent = function getComponent() {
|
15
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
16
|
+
return render(___EmotionJSX(HelpHint, _extends({}, defaultProps, props)));
|
17
|
+
}; // Need to be added to each test file to test accessibility using axe.
|
18
|
+
|
19
|
+
|
20
|
+
axeTest(getComponent);
|
21
|
+
test('renders HelpHint component', function () {
|
22
|
+
getComponent();
|
23
|
+
var helpHintButton = screen.getByTestId(testId);
|
24
|
+
expect(helpHintButton).toBeInTheDocument();
|
25
|
+
});
|
26
|
+
test('shows tooltip on hover', function () {
|
27
|
+
getComponent();
|
28
|
+
var helpHintButton = screen.getByTestId(testId);
|
29
|
+
expect(screen.queryByText(tooltipValue)).not.toBeInTheDocument();
|
30
|
+
fireEvent.mouseMove(helpHintButton);
|
31
|
+
fireEvent.mouseEnter(helpHintButton);
|
32
|
+
expect(screen.getByText(tooltipValue)).toBeInTheDocument();
|
33
|
+
});
|
34
|
+
test('shows tooltip on focus', function () {
|
35
|
+
getComponent();
|
36
|
+
var helpHintButton = screen.getByTestId(testId);
|
37
|
+
expect(screen.queryByText(tooltipValue)).not.toBeInTheDocument();
|
38
|
+
userEvent.tab();
|
39
|
+
expect(helpHintButton).toHaveFocus();
|
40
|
+
expect(screen.queryByText(tooltipValue)).toBeInTheDocument();
|
41
|
+
});
|
42
|
+
test('applies tooltipProps', function () {
|
43
|
+
getComponent({
|
44
|
+
tooltipProps: {
|
45
|
+
isOpen: true
|
46
|
+
}
|
47
|
+
});
|
48
|
+
expect(screen.getByText(tooltipValue)).toBeInTheDocument();
|
49
|
+
});
|
50
|
+
test('applies iconButtonProps', function () {
|
51
|
+
var newLabel = 'New label';
|
52
|
+
getComponent({
|
53
|
+
iconButtonProps: {
|
54
|
+
'aria-label': newLabel
|
55
|
+
}
|
56
|
+
});
|
57
|
+
expect(screen.getByLabelText(newLabel)).toBeInTheDocument();
|
58
|
+
});
|
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
|
5
5
|
import { Link as ThemeUILink } from 'theme-ui';
|
6
6
|
import { useLink } from '@react-aria/link';
|
7
7
|
import { useFocusRing } from '@react-aria/focus';
|
8
|
-
import { useHover } from '@react-aria/interactions';
|
8
|
+
import { useHover, usePress } from '@react-aria/interactions';
|
9
9
|
import { mergeProps } from '@react-aria/utils';
|
10
10
|
import { usePropWarning, useStatusClasses } from '../../hooks';
|
11
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -33,10 +33,17 @@ var Link = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
33
33
|
hoverProps = _useHover.hoverProps,
|
34
34
|
isHovered = _useHover.isHovered;
|
35
35
|
|
36
|
+
var _usePress = usePress({
|
37
|
+
ref: linkRef
|
38
|
+
}),
|
39
|
+
pressProps = _usePress.pressProps,
|
40
|
+
isPressed = _usePress.isPressed;
|
41
|
+
|
36
42
|
var _useStatusClasses = useStatusClasses(className, {
|
37
43
|
isDisabled: isDisabled,
|
38
44
|
isFocused: isFocusVisible,
|
39
|
-
isHovered: isHovered
|
45
|
+
isHovered: isHovered,
|
46
|
+
isPressed: isPressed
|
40
47
|
}),
|
41
48
|
classNames = _useStatusClasses.classNames;
|
42
49
|
|
@@ -44,7 +51,7 @@ var Link = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
44
51
|
className: classNames,
|
45
52
|
ref: linkRef,
|
46
53
|
role: "link"
|
47
|
-
}, others, mergeProps(hoverProps, focusProps, linkProps)));
|
54
|
+
}, others, mergeProps(hoverProps, focusProps, pressProps, linkProps)));
|
48
55
|
});
|
49
56
|
Link.propTypes = {
|
50
57
|
/** Whether the link is disabled. */
|
@@ -60,11 +67,15 @@ Link.propTypes = {
|
|
60
67
|
href: PropTypes.string,
|
61
68
|
|
62
69
|
/** Specifies the window where the linked page is loaded */
|
63
|
-
target: PropTypes.string
|
70
|
+
target: PropTypes.string,
|
71
|
+
|
72
|
+
/** The styling variation of the link. */
|
73
|
+
variant: PropTypes.string
|
64
74
|
};
|
65
75
|
Link.defaultProps = {
|
66
76
|
isDisabled: false,
|
67
|
-
as: 'a'
|
77
|
+
as: 'a',
|
78
|
+
variant: 'app'
|
68
79
|
};
|
69
80
|
Link.displayName = 'Link';
|
70
81
|
export default Link;
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
3
|
import React from 'react';
|
3
4
|
import Link from '.';
|
4
5
|
import { htmlElements } from '../../utils/devUtils/constants/htmlElements';
|
6
|
+
import variants from '../../styles/variants/links';
|
5
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
6
8
|
export default {
|
7
9
|
title: 'Link',
|
@@ -26,6 +28,12 @@ export default {
|
|
26
28
|
type: 'none'
|
27
29
|
},
|
28
30
|
defaultValue: '_blank'
|
31
|
+
},
|
32
|
+
variant: {
|
33
|
+
control: {
|
34
|
+
type: 'select',
|
35
|
+
options: _Object$keys(variants)
|
36
|
+
}
|
29
37
|
}
|
30
38
|
}
|
31
39
|
};
|
@@ -13,7 +13,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
13
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
14
14
|
|
15
15
|
import { messagesReducer as messagesReducerCore, multiMessagesReducer as multiMessagesReducerCore } from './utils';
|
16
|
-
var messagesReducer = messagesReducerCore;
|
16
|
+
export var messagesReducer = messagesReducerCore;
|
17
17
|
export var multiMessagesReducer = multiMessagesReducerCore;
|
18
18
|
|
19
19
|
var makeShowMessage = function makeShowMessage(status, timeout) {
|
@@ -23,7 +23,7 @@ import { Item } from '@react-stately/collections';
|
|
23
23
|
import AccountIcon from 'mdi-react/AccountIcon';
|
24
24
|
import statuses from '../../utils/devUtils/constants/statuses';
|
25
25
|
import { Box, Button, Messages } from '../..';
|
26
|
-
import messagesReducer,
|
26
|
+
import { messagesReducerStory as messagesReducer, multiMessagesReducerStory as multiMessagesReducer } from './index';
|
27
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
28
28
|
export default {
|
29
29
|
title: 'Messages',
|
@@ -9,7 +9,7 @@ import { Item } from '@react-stately/collections';
|
|
9
9
|
import userEvent from '@testing-library/user-event';
|
10
10
|
import axeTest from '../../utils/testUtils/testAxe';
|
11
11
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
12
|
-
import Messages from '.';
|
12
|
+
import Messages, { messagesReducerStory, multiMessagesReducerStory } from '.';
|
13
13
|
import Button from '../Button';
|
14
14
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
15
|
jest.mock('@react-aria/live-announcer');
|
@@ -173,4 +173,14 @@ describe('announcements', function () {
|
|
173
173
|
expect(messages.childElementCount).toBe(1);
|
174
174
|
expect(announce).toHaveBeenCalledWith('New message 1', 'polite');
|
175
175
|
});
|
176
|
+
});
|
177
|
+
test('should render messages with messagesReducerStory', function () {
|
178
|
+
getComponent();
|
179
|
+
messagesReducerStory.actions.showSuccessMessage();
|
180
|
+
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
181
|
+
});
|
182
|
+
test('should render messages with multiMessagesReducerStory', function () {
|
183
|
+
getComponent();
|
184
|
+
multiMessagesReducerStory.actions.showSuccessMessage();
|
185
|
+
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
176
186
|
});
|
@@ -22,6 +22,7 @@ import { useNumberField } from '@react-aria/numberfield';
|
|
22
22
|
import { useNumberFieldState } from '@react-stately/numberfield';
|
23
23
|
import { useLocale } from '@react-aria/i18n';
|
24
24
|
import { mergeProps } from '@react-aria/utils';
|
25
|
+
import omit from 'lodash/omit';
|
25
26
|
import statuses from '../../utils/devUtils/constants/statuses';
|
26
27
|
import { Box, FieldHelperText, Icon, IconButton, Input, Label } from '../../index';
|
27
28
|
import { useField, usePropWarning } from '../../hooks';
|
@@ -94,7 +95,7 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
95
|
ref: inputRef // we don't want to merge this props, we want to
|
95
96
|
// overwrite them like defaultValue, value, ect.
|
96
97
|
|
97
|
-
}, fieldControlProps, inputProps)), ControlArrows), helperText && ___EmotionJSX(FieldHelperText, {
|
98
|
+
}, fieldControlProps, omit(inputProps, 'name'))), ControlArrows), helperText && ___EmotionJSX(FieldHelperText, {
|
98
99
|
status: status
|
99
100
|
}, helperText)));
|
100
101
|
});
|
@@ -128,4 +128,11 @@ test('increment and decrement buttons shouldn\'t be able to be focused via keybo
|
|
128
128
|
expect(screen.getByLabelText('arrow-up')).not.toHaveFocus();
|
129
129
|
userEvent.tab();
|
130
130
|
expect(screen.getByLabelText('arrow-down')).not.toHaveFocus();
|
131
|
+
});
|
132
|
+
test('number field input receiving name attribute', function () {
|
133
|
+
var testName = 'testName';
|
134
|
+
getComponent({
|
135
|
+
name: testName
|
136
|
+
});
|
137
|
+
expect(screen.getByLabelText(testLabel)).toHaveAttribute('name', testName);
|
131
138
|
});
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
4
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
5
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, { forwardRef, useRef, useImperativeHandle
|
5
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
7
6
|
import PropTypes from 'prop-types';
|
8
7
|
import { FocusScope } from '@react-aria/focus';
|
9
8
|
import Box from '../Box';
|
@@ -26,14 +25,8 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
25
|
onClose = _useOverlayPanelState.onClose;
|
27
26
|
|
28
27
|
var overlayPanelRef = useRef();
|
29
|
-
|
30
|
-
var _useState = useState(true),
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
contain = _useState2[0],
|
33
|
-
setIsContained = _useState2[1];
|
34
28
|
/* istanbul ignore next */
|
35
29
|
|
36
|
-
|
37
30
|
useImperativeHandle(ref, function () {
|
38
31
|
return overlayPanelRef.current;
|
39
32
|
});
|
@@ -47,18 +40,12 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
47
40
|
e.stopPropagation();
|
48
41
|
|
49
42
|
if (e.key === 'Escape') {
|
50
|
-
|
43
|
+
onClose(state, triggerRef, onCloseProp);
|
51
44
|
}
|
52
45
|
};
|
53
46
|
|
54
|
-
useEffect(function () {
|
55
|
-
if (!contain && onClose) {
|
56
|
-
onClose(state, triggerRef, onCloseProp);
|
57
|
-
}
|
58
|
-
}, [contain]);
|
59
47
|
return ___EmotionJSX(FocusScope, {
|
60
|
-
autoFocus: true
|
61
|
-
contain: contain
|
48
|
+
autoFocus: true
|
62
49
|
}, ___EmotionJSX(Box, _extends({
|
63
50
|
variant: "overlayPanel.overlayPanel",
|
64
51
|
ref: overlayPanelRef
|
@@ -60,6 +60,13 @@ test('onClose callback fires when provided', function () {
|
|
60
60
|
});
|
61
61
|
expect(onClose).toHaveBeenCalled();
|
62
62
|
});
|
63
|
+
test('custom classname can be passed', function () {
|
64
|
+
getComponent({
|
65
|
+
className: 'testing-class'
|
66
|
+
});
|
67
|
+
var overlayPanel = screen.getByTestId(testId);
|
68
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
69
|
+
});
|
63
70
|
test('neither callback fires when not provided', function () {
|
64
71
|
var onClose = jest.fn();
|
65
72
|
getComponent({
|
@@ -110,4 +117,35 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
110
117
|
charCode: 27
|
111
118
|
});
|
112
119
|
expect(focusFunction).toHaveBeenCalled();
|
120
|
+
});
|
121
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
122
|
+
var onClose = jest.fn();
|
123
|
+
var focusFunction = jest.fn();
|
124
|
+
var state = {
|
125
|
+
close: onClose
|
126
|
+
};
|
127
|
+
var triggerRef = {
|
128
|
+
current: {
|
129
|
+
focus: focusFunction
|
130
|
+
}
|
131
|
+
};
|
132
|
+
getComponent({
|
133
|
+
state: state,
|
134
|
+
children: ___EmotionJSX("div", null, "Test"),
|
135
|
+
triggerRef: triggerRef
|
136
|
+
});
|
137
|
+
var overlayPanel = screen.getByTestId(testId);
|
138
|
+
fireEvent.keyDown(overlayPanel, {
|
139
|
+
key: 'KeyA',
|
140
|
+
code: 'KeyA',
|
141
|
+
keyCode: 65,
|
142
|
+
charCode: 65
|
143
|
+
});
|
144
|
+
fireEvent.keyUp(overlayPanel, {
|
145
|
+
key: 'KeyA',
|
146
|
+
code: 'KeyA',
|
147
|
+
keyCode: 65,
|
148
|
+
charCode: 65
|
149
|
+
});
|
150
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
113
151
|
});
|