@pingux/astro 1.17.0-alpha.0 → 1.17.0-alpha.11
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/Button/Button.stories.js +8 -3
- package/lib/cjs/components/Chip/Chip.stories.js +18 -1
- package/lib/cjs/components/CollapsiblePanel/CollapsiblePanel.js +2 -0
- package/lib/cjs/components/CollapsiblePanel/CollapsiblePanel.stories.js +125 -32
- package/lib/cjs/components/CollapsiblePanelContainer/CollapsiblePanelContainer.js +4 -22
- package/lib/cjs/components/CollapsiblePanelContainer/CollapsiblePanelContainer.test.js +8 -8
- package/lib/cjs/components/CollapsiblePanelItem/CollapsiblePanelItem.js +2 -2
- package/lib/cjs/components/Image/Image.js +14 -3
- package/lib/cjs/components/Image/Image.stories.js +17 -8
- package/lib/cjs/components/Image/Image.test.js +9 -0
- package/lib/cjs/components/ListView/ListView.js +1 -0
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +142 -21
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +1 -1
- package/lib/cjs/components/RockerButton/RockerButton.js +5 -9
- package/lib/cjs/styles/variants/boxes.js +19 -0
- package/lib/cjs/styles/variants/buttons.js +20 -3
- package/lib/cjs/styles/variants/collapsiblePanel.js +26 -7
- package/lib/cjs/styles/variants/overlayPanel.js +2 -2
- package/lib/components/Button/Button.stories.js +8 -3
- package/lib/components/Chip/Chip.stories.js +14 -0
- package/lib/components/CollapsiblePanel/CollapsiblePanel.js +2 -0
- package/lib/components/CollapsiblePanel/CollapsiblePanel.stories.js +113 -31
- package/lib/components/CollapsiblePanelContainer/CollapsiblePanelContainer.js +1 -15
- package/lib/components/CollapsiblePanelContainer/CollapsiblePanelContainer.test.js +6 -6
- package/lib/components/CollapsiblePanelItem/CollapsiblePanelItem.js +2 -2
- package/lib/components/Image/Image.js +15 -4
- package/lib/components/Image/Image.stories.js +17 -8
- package/lib/components/Image/Image.test.js +9 -0
- package/lib/components/ListView/ListView.js +1 -0
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +142 -20
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +1 -1
- package/lib/components/RockerButton/RockerButton.js +6 -10
- package/lib/styles/variants/boxes.js +19 -0
- package/lib/styles/variants/buttons.js +20 -3
- package/lib/styles/variants/collapsiblePanel.js +26 -7
- package/lib/styles/variants/overlayPanel.js +2 -2
- package/package.json +1 -1
@@ -1,14 +1,32 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
7
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
1
8
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import
|
9
|
+
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
12
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
13
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
14
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
15
|
+
|
16
|
+
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; }
|
17
|
+
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
19
|
+
|
20
|
+
import React, { useRef, useState, useMemo } from 'react';
|
3
21
|
import AccountGroupIcon from 'mdi-react/AccountGroupIcon';
|
4
|
-
import Clear from 'mdi-react/CloseIcon';
|
5
22
|
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
6
|
-
import
|
23
|
+
import CheckIcon from 'mdi-react/CheckIcon';
|
24
|
+
import Clear from 'mdi-react/CloseIcon';
|
7
25
|
import SearchIcon from 'mdi-react/SearchIcon';
|
8
26
|
import AccountIcon from 'mdi-react/AccountIcon';
|
9
27
|
import CollapsiblePanel from './CollapsiblePanel';
|
10
28
|
import { useOverlayPanelState } from '../../hooks';
|
11
|
-
import { Breadcrumbs, Box, Button, Chip, ListView, Item, Icon, IconButton, CollapsiblePanelItem, OverlayPanel, OverlayProvider, SearchField, Text } from '../../index';
|
29
|
+
import { Breadcrumbs, Box, Button, CheckboxField, Chip, ListView, Item, Icon, IconButton, CollapsiblePanelItem, OverlayPanel, OverlayProvider, SearchField, Text } from '../../index';
|
12
30
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
31
|
export default {
|
14
32
|
title: 'CollapsiblePanel',
|
@@ -34,13 +52,14 @@ export default {
|
|
34
52
|
}
|
35
53
|
}
|
36
54
|
};
|
37
|
-
var
|
55
|
+
var data = [{
|
38
56
|
id: '1',
|
39
57
|
icon: 'Group',
|
40
58
|
key: 'Avengers',
|
41
59
|
name: 'Avengers',
|
42
60
|
subtitle: 'Default',
|
43
|
-
chipValue: '25'
|
61
|
+
chipValue: '25',
|
62
|
+
isDefaultSelected: true
|
44
63
|
}, {
|
45
64
|
id: '2',
|
46
65
|
icon: 'Group',
|
@@ -61,7 +80,8 @@ var items = [{
|
|
61
80
|
key: 'Digital Investors',
|
62
81
|
name: 'Digital Investors',
|
63
82
|
subtitle: 'N America',
|
64
|
-
chipValue: '12'
|
83
|
+
chipValue: '12',
|
84
|
+
isDefaultSelected: true
|
65
85
|
}, {
|
66
86
|
id: '5',
|
67
87
|
icon: 'Group',
|
@@ -98,33 +118,45 @@ var items = [{
|
|
98
118
|
subtitle: '',
|
99
119
|
chipValue: '29'
|
100
120
|
}];
|
101
|
-
var mockData = [{
|
102
|
-
id: '10',
|
103
|
-
key: 'Avengers',
|
104
|
-
name: 'Avengers'
|
105
|
-
}, {
|
106
|
-
id: '11',
|
107
|
-
key: 'Digital Investors',
|
108
|
-
name: 'Digital Investors'
|
109
|
-
}, {
|
110
|
-
id: '12',
|
111
|
-
key: 'A very long title as well',
|
112
|
-
name: 'A very long title as well'
|
113
|
-
}];
|
114
|
-
|
115
|
-
var changeSelection = function changeSelection(selected) {
|
116
|
-
console.log(selected);
|
117
|
-
};
|
118
|
-
|
119
121
|
export var Default = function Default(args) {
|
120
122
|
return ___EmotionJSX(CollapsiblePanel, args);
|
121
123
|
};
|
122
124
|
export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args) {
|
125
|
+
var _useState = useState(data),
|
126
|
+
_useState2 = _slicedToArray(_useState, 2),
|
127
|
+
items = _useState2[0],
|
128
|
+
setItems = _useState2[1];
|
129
|
+
|
123
130
|
var _useOverlayPanelState = useOverlayPanelState(),
|
124
131
|
state = _useOverlayPanelState.state,
|
125
132
|
onClose = _useOverlayPanelState.onClose;
|
126
133
|
|
127
134
|
var triggerRef = useRef();
|
135
|
+
var selectedItems = useMemo(function () {
|
136
|
+
var _context;
|
137
|
+
|
138
|
+
return _sortInstanceProperty(_context = _filterInstanceProperty(items).call(items, function (item) {
|
139
|
+
return item.isDefaultSelected || item.isSelected;
|
140
|
+
}) // sort elements to display "default selected" at first place
|
141
|
+
).call(_context, function (a, b) {
|
142
|
+
return Number(!!b.isDefaultSelected) - Number(!!a.isDefaultSelected);
|
143
|
+
});
|
144
|
+
}, [items]);
|
145
|
+
|
146
|
+
var changeSelection = function changeSelection(key) {
|
147
|
+
setItems(function (prevItems) {
|
148
|
+
return _mapInstanceProperty(prevItems).call(prevItems, function (el) {
|
149
|
+
if (el.key === key) {
|
150
|
+
return _objectSpread(_objectSpread({}, el), {}, {
|
151
|
+
isSelected: !el.isSelected
|
152
|
+
});
|
153
|
+
}
|
154
|
+
|
155
|
+
return el;
|
156
|
+
});
|
157
|
+
});
|
158
|
+
};
|
159
|
+
|
128
160
|
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
129
161
|
ref: triggerRef,
|
130
162
|
onPress: state.open
|
@@ -181,7 +213,10 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
181
213
|
pt: "25px"
|
182
214
|
}, ___EmotionJSX(Box, {
|
183
215
|
isRow: true,
|
184
|
-
justifyContent: "space-between"
|
216
|
+
justifyContent: "space-between",
|
217
|
+
sx: {
|
218
|
+
marginTop: '5px'
|
219
|
+
}
|
185
220
|
}, ___EmotionJSX(Box, {
|
186
221
|
width: "100%"
|
187
222
|
}, ___EmotionJSX(SearchField, {
|
@@ -190,11 +225,13 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
190
225
|
placeholder: "Search",
|
191
226
|
width: "100%",
|
192
227
|
mt: "0px",
|
193
|
-
mr: "sm"
|
228
|
+
mr: "sm",
|
229
|
+
mb: "xs"
|
194
230
|
}), ___EmotionJSX(ListView, {
|
195
231
|
items: items,
|
196
232
|
style: {
|
197
|
-
width: '
|
233
|
+
width: '100%',
|
234
|
+
outline: 'none'
|
198
235
|
}
|
199
236
|
}, function (item) {
|
200
237
|
return ___EmotionJSX(Item, {
|
@@ -202,8 +239,12 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
202
239
|
textValue: item.name,
|
203
240
|
"data-id": item.key,
|
204
241
|
listItemProps: {
|
242
|
+
isRow: true,
|
205
243
|
sx: {
|
206
244
|
bg: 'white',
|
245
|
+
width: '100%',
|
246
|
+
justifyContent: 'space-between',
|
247
|
+
alignItems: 'center',
|
207
248
|
'&.is-hovered': {
|
208
249
|
bg: 'accent.99'
|
209
250
|
}
|
@@ -233,9 +274,46 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
233
274
|
}
|
234
275
|
})), ___EmotionJSX(Text, {
|
235
276
|
variant: "listSubtitle"
|
236
|
-
}, item.subtitle)))
|
277
|
+
}, item.subtitle))), item.isDefaultSelected ? ___EmotionJSX(Box, {
|
278
|
+
isRow: true,
|
279
|
+
sx: {
|
280
|
+
border: '1px solid',
|
281
|
+
borderColor: 'neutral.80',
|
282
|
+
borderRadius: 5,
|
283
|
+
minHeight: 22,
|
284
|
+
justifyContent: 'center',
|
285
|
+
alignItems: 'center',
|
286
|
+
p: 'xs',
|
287
|
+
maxWidth: '50%'
|
288
|
+
}
|
289
|
+
}, ___EmotionJSX(Icon, {
|
290
|
+
icon: CheckIcon,
|
291
|
+
color: "neutral.20",
|
292
|
+
size: 13,
|
293
|
+
sx: {
|
294
|
+
flexShrink: 0
|
295
|
+
}
|
296
|
+
}), ___EmotionJSX(Text, {
|
297
|
+
sx: {
|
298
|
+
fontSize: 'sm',
|
299
|
+
pl: 'xs',
|
300
|
+
maxHeight: 32,
|
301
|
+
overflow: 'hidden'
|
302
|
+
}
|
303
|
+
}, "Added by Filter")) : ___EmotionJSX(CheckboxField, {
|
304
|
+
controlProps: {
|
305
|
+
color: 'neutral.10',
|
306
|
+
'aria-label': 'Select'
|
307
|
+
},
|
308
|
+
onChange: function onChange() {
|
309
|
+
return changeSelection(item.key);
|
310
|
+
},
|
311
|
+
isSelected: _someInstanceProperty(selectedItems).call(selectedItems, function (el) {
|
312
|
+
return el.key === item.key;
|
313
|
+
})
|
314
|
+
}));
|
237
315
|
})), ___EmotionJSX(CollapsiblePanel, _extends({
|
238
|
-
items:
|
316
|
+
items: selectedItems,
|
239
317
|
onSelectionChange: changeSelection,
|
240
318
|
selectedFilterCount: "1000+"
|
241
319
|
}, args), function (item) {
|
@@ -245,7 +323,11 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
245
323
|
"data-id": item.key
|
246
324
|
}, ___EmotionJSX(CollapsiblePanelItem, {
|
247
325
|
text: item.name,
|
248
|
-
icon:
|
326
|
+
icon: item.isDefaultSelected ? CheckIcon : Clear,
|
327
|
+
onPress: function onPress() {
|
328
|
+
return changeSelection(item.key);
|
329
|
+
},
|
330
|
+
isDefaultSelected: item.isDefaultSelected
|
249
331
|
}));
|
250
332
|
})))));
|
251
333
|
};
|
@@ -1,20 +1,6 @@
|
|
1
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
3
|
var _excluded = ["selectedFilterCount", "className", "children", "closeAriaLabel", "isDefaultOpen", "isOpen", "onOpenChange", "openAriaLabel"];
|
13
|
-
|
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
|
-
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
17
|
-
|
18
4
|
import React, { forwardRef } from 'react';
|
19
5
|
import PropTypes from 'prop-types';
|
20
6
|
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
@@ -90,7 +76,7 @@ var CollapsiblePanelContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
90
76
|
"data-testid": "collapsible-panel-badge",
|
91
77
|
margin: "auto",
|
92
78
|
selectedFilterCount: selectedFilterCount
|
93
|
-
})),
|
79
|
+
})), children);
|
94
80
|
});
|
95
81
|
CollapsiblePanelContainer.propTypes = {
|
96
82
|
/** Amount of selected items indicator. */
|
@@ -55,13 +55,13 @@ test('updates aria label when button is clicked', function () {
|
|
55
55
|
state: state
|
56
56
|
});
|
57
57
|
var button = screen.getByTestId(collapsiblePanelButtonId);
|
58
|
+
var container = screen.getByTestId(testId);
|
58
59
|
userEvent.click(button);
|
59
|
-
var collapsiblePanel = screen.queryByTestId(collapsiblePanelId);
|
60
60
|
expect(button).toHaveAttribute('aria-label', 'Close filter menu?');
|
61
|
-
expect(
|
61
|
+
expect(container).toHaveClass('is-open');
|
62
62
|
userEvent.click(button);
|
63
63
|
expect(button).toHaveAttribute('aria-label', 'Open filter menu?');
|
64
|
-
expect(
|
64
|
+
expect(container).not.toHaveClass('is-open');
|
65
65
|
});
|
66
66
|
test('shows children when isOpen is true', function () {
|
67
67
|
getComponent({
|
@@ -73,9 +73,9 @@ test('shows children when isOpen is true', function () {
|
|
73
73
|
test('should hide children when pressing the escape key', function () {
|
74
74
|
getComponent();
|
75
75
|
var button = screen.getByTestId(collapsiblePanelButtonId);
|
76
|
+
var container = screen.getByTestId(testId);
|
76
77
|
userEvent.click(button);
|
77
|
-
|
78
|
-
expect(collapsiblePanel).toBeInTheDocument();
|
78
|
+
expect(container).toHaveClass('is-open');
|
79
79
|
userEvent.type(button, '{esc}');
|
80
|
-
expect(
|
80
|
+
expect(container).not.toHaveClass('is-open');
|
81
81
|
});
|
@@ -23,8 +23,8 @@ var CollapsiblePanelItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
23
|
variant: "collapsiblePanellItem"
|
24
24
|
}, text), iconElement && (isDefaultSelected ? iconElement : ___EmotionJSX(IconButton, {
|
25
25
|
sx: {
|
26
|
-
width:
|
27
|
-
height:
|
26
|
+
width: 20,
|
27
|
+
height: 20,
|
28
28
|
alignSelf: 'auto',
|
29
29
|
'& path': {
|
30
30
|
fill: 'inherit'
|
@@ -14,7 +14,7 @@ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectW
|
|
14
14
|
|
15
15
|
var _templateObject;
|
16
16
|
|
17
|
-
var _excluded = ["className", "fallbackImage", "fallbackTimeout", "isDisabled", "src", "sx"];
|
17
|
+
var _excluded = ["className", "fallbackImage", "fallbackTimeout", "isDisabled", "src", "alt", "sx"];
|
18
18
|
|
19
19
|
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; }
|
20
20
|
|
@@ -25,7 +25,7 @@ import PropTypes from 'prop-types';
|
|
25
25
|
import { Image as ThemeUIImage } from 'theme-ui';
|
26
26
|
import { useHover } from '@react-aria/interactions';
|
27
27
|
import { keyframes } from '@emotion/react';
|
28
|
-
import { usePropWarning, useStatusClasses, useFallbackImage } from '../../hooks';
|
28
|
+
import { usePropWarning, useStatusClasses, useFallbackImage, useAriaLabelWarning } from '../../hooks';
|
29
29
|
import { Box } from '../../index';
|
30
30
|
import { neutral } from '../../styles/colors';
|
31
31
|
/**
|
@@ -41,6 +41,7 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
41
41
|
fallbackTimeout = props.fallbackTimeout,
|
42
42
|
isDisabled = props.isDisabled,
|
43
43
|
src = props.src,
|
44
|
+
alt = props.alt,
|
44
45
|
sx = props.sx,
|
45
46
|
others = _objectWithoutProperties(props, _excluded);
|
46
47
|
|
@@ -86,6 +87,8 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
86
87
|
return imgRef.current;
|
87
88
|
});
|
88
89
|
usePropWarning(props, 'disabled', 'isDisabled');
|
90
|
+
var ariaLabel = props['aria-label'] || alt;
|
91
|
+
useAriaLabelWarning('Image', ariaLabel);
|
89
92
|
|
90
93
|
var _useHover = useHover(props),
|
91
94
|
hoverProps = _useHover.hoverProps,
|
@@ -142,7 +145,7 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
142
145
|
var themeUiImage = ___EmotionJSX(ThemeUIImage, _extends({
|
143
146
|
className: classNames,
|
144
147
|
ref: imgRef,
|
145
|
-
alt:
|
148
|
+
alt: alt,
|
146
149
|
role: "img",
|
147
150
|
src: imgSrc,
|
148
151
|
sx: sx
|
@@ -176,7 +179,15 @@ Image.propTypes = {
|
|
176
179
|
fallbackImage: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
177
180
|
|
178
181
|
/** Time in milliseconds that component should wait for a response from src address. */
|
179
|
-
fallbackTimeout: PropTypes.number
|
182
|
+
fallbackTimeout: PropTypes.number,
|
183
|
+
|
184
|
+
/** Descriptive text for an image. This is *highly* recommended in most cases.
|
185
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt).
|
186
|
+
* */
|
187
|
+
alt: PropTypes.string,
|
188
|
+
|
189
|
+
/** Defines a string value that labels the current element. */
|
190
|
+
'aria-label': PropTypes.string
|
180
191
|
};
|
181
192
|
Image.defaultProps = {
|
182
193
|
isDisabled: false,
|
@@ -35,12 +35,15 @@ export default {
|
|
35
35
|
export var Default = function Default(_ref) {
|
36
36
|
var args = _extends({}, _ref);
|
37
37
|
|
38
|
-
return ___EmotionJSX(Image, args
|
38
|
+
return ___EmotionJSX(Image, _extends({}, args, {
|
39
|
+
alt: "Ping identity square logo"
|
40
|
+
}));
|
39
41
|
};
|
40
42
|
export var Avatar = function Avatar() {
|
41
43
|
return ___EmotionJSX(Image, {
|
42
44
|
src: pingImg,
|
43
|
-
variant: "images.avatar"
|
45
|
+
variant: "images.avatar",
|
46
|
+
alt: "Ping identity round avatar"
|
44
47
|
});
|
45
48
|
};
|
46
49
|
export var CustomSizeAndRadius = function CustomSizeAndRadius() {
|
@@ -51,13 +54,15 @@ export var CustomSizeAndRadius = function CustomSizeAndRadius() {
|
|
51
54
|
height: '70px',
|
52
55
|
borderRadius: 8,
|
53
56
|
bg: 'neutral.90'
|
54
|
-
}
|
57
|
+
},
|
58
|
+
alt: "Terry Crews in a red suite"
|
55
59
|
});
|
56
60
|
};
|
57
61
|
export var Disabled = function Disabled() {
|
58
62
|
return ___EmotionJSX(Image, {
|
59
63
|
src: pingImg,
|
60
|
-
isDisabled: true
|
64
|
+
isDisabled: true,
|
65
|
+
alt: "Ping identity square logo"
|
61
66
|
});
|
62
67
|
};
|
63
68
|
export var FallbackImage = function FallbackImage() {
|
@@ -67,7 +72,8 @@ export var FallbackImage = function FallbackImage() {
|
|
67
72
|
sx: {
|
68
73
|
width: '150px',
|
69
74
|
height: '150px'
|
70
|
-
}
|
75
|
+
},
|
76
|
+
alt: "Random image"
|
71
77
|
});
|
72
78
|
};
|
73
79
|
export var WithSkeletonLoadSuccess = function WithSkeletonLoadSuccess(_ref2) {
|
@@ -78,7 +84,8 @@ export var WithSkeletonLoadSuccess = function WithSkeletonLoadSuccess(_ref2) {
|
|
78
84
|
sx: {
|
79
85
|
width: '150px',
|
80
86
|
height: '150px'
|
81
|
-
}
|
87
|
+
},
|
88
|
+
alt: "Random image"
|
82
89
|
});
|
83
90
|
};
|
84
91
|
WithSkeletonLoadSuccess.args = {
|
@@ -90,7 +97,8 @@ export var WithSkeletonLoadTimeout = function WithSkeletonLoadTimeout() {
|
|
90
97
|
sx: {
|
91
98
|
width: '150px',
|
92
99
|
height: '150px'
|
93
|
-
}
|
100
|
+
},
|
101
|
+
alt: "Random image"
|
94
102
|
});
|
95
103
|
};
|
96
104
|
export var UpdatingImageSrc = function UpdatingImageSrc() {
|
@@ -116,6 +124,7 @@ export var UpdatingImageSrc = function UpdatingImageSrc() {
|
|
116
124
|
width: '200px',
|
117
125
|
height: '200px',
|
118
126
|
mt: '25px'
|
119
|
-
}
|
127
|
+
},
|
128
|
+
alt: image === pingImg ? 'Ping identity square logo' : 'Terry Crews in a red suite'
|
120
129
|
}));
|
121
130
|
};
|
@@ -76,6 +76,15 @@ test('image shows disabled status', function () {
|
|
76
76
|
var img = screen.getByRole('img');
|
77
77
|
expect(img).toHaveClass('is-disabled');
|
78
78
|
});
|
79
|
+
test('image with alt text', function () {
|
80
|
+
getComponent({
|
81
|
+
alt: 'Test'
|
82
|
+
});
|
83
|
+
act(function () {
|
84
|
+
fallbackImageObj.onImageLoad();
|
85
|
+
});
|
86
|
+
expect(screen.getByAltText('Test')).toBeInTheDocument();
|
87
|
+
});
|
79
88
|
test('image source is able to be changed', function () {
|
80
89
|
var src2 = 'second-src';
|
81
90
|
|
@@ -149,6 +149,7 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
149
149
|
|
150
150
|
layout.isLoading = isLoading;
|
151
151
|
var focusedItem = gridCollection.getFirstKey();
|
152
|
+
delete gridProps.onMouseDown;
|
152
153
|
return ___EmotionJSX(ListViewContext.Provider, {
|
153
154
|
value: {
|
154
155
|
state: state,
|