@pingux/astro 1.16.1-alpha.0 → 1.17.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/ComboBoxField/ComboBoxField.js +40 -7
- package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +58 -2
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +123 -25
- 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/MultivaluesField/MultivaluesField.stories.js +142 -21
- package/lib/components/ComboBoxField/ComboBoxField.js +40 -8
- package/lib/components/ComboBoxField/ComboBoxField.stories.js +51 -0
- package/lib/components/ComboBoxField/ComboBoxField.test.js +106 -25
- 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/MultivaluesField/MultivaluesField.stories.js +142 -20
- package/package.json +1 -1
@@ -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
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import { Box, Item, MultivaluesField, OverlayProvider } from '../..';
|
5
5
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -7,7 +7,9 @@ export default {
|
|
7
7
|
title: 'Form/MultivaluesField',
|
8
8
|
component: MultivaluesField,
|
9
9
|
argTypes: {
|
10
|
-
direction: {
|
10
|
+
direction: {
|
11
|
+
defaultValue: 'bottom'
|
12
|
+
},
|
11
13
|
hasAutoFocus: {},
|
12
14
|
hasNoStatusIndicator: {},
|
13
15
|
isDisabled: {},
|
@@ -89,7 +91,27 @@ var items = [{
|
|
89
91
|
name: 'Shark',
|
90
92
|
key: 'Shark'
|
91
93
|
}];
|
94
|
+
|
95
|
+
var setOverlayStyle = function setOverlayStyle(direction, isOpen, mr, ml, mt) {
|
96
|
+
return {
|
97
|
+
marginRight: direction === 'right' && isOpen ? mr : 0,
|
98
|
+
marginLeft: direction === 'left' && isOpen ? ml : 0,
|
99
|
+
marginTop: direction === 'top' && isOpen ? mt : 0
|
100
|
+
};
|
101
|
+
};
|
102
|
+
|
92
103
|
export var Default = function Default(args) {
|
104
|
+
var _useState = useState(false),
|
105
|
+
_useState2 = _slicedToArray(_useState, 2),
|
106
|
+
isOpen = _useState2[0],
|
107
|
+
setIsOpen = _useState2[1];
|
108
|
+
|
109
|
+
var direction = args.direction;
|
110
|
+
|
111
|
+
var onOpenChange = function onOpenChange() {
|
112
|
+
setIsOpen(true);
|
113
|
+
};
|
114
|
+
|
93
115
|
return (// const items = [
|
94
116
|
// { id: 1, name: 'Aardvark', key: 'Aardvark' },
|
95
117
|
// { id: 2, name: 'Kangaroo', key: 'Kangaroo' },
|
@@ -99,9 +121,14 @@ export var Default = function Default(args) {
|
|
99
121
|
// { id: 6, name: 'Orangutan', key: 'Orangutan' },
|
100
122
|
// { id: 7, name: 'Shark', key: 'Shark' },
|
101
123
|
// ];
|
102
|
-
___EmotionJSX(OverlayProvider
|
124
|
+
___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
125
|
+
, {
|
126
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
127
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
103
128
|
items: items
|
104
|
-
}, args
|
129
|
+
}, args, {
|
130
|
+
onOpenChange: onOpenChange
|
131
|
+
}), function (item) {
|
105
132
|
return ___EmotionJSX(Item, {
|
106
133
|
key: item.key,
|
107
134
|
"data-id": item.name
|
@@ -110,10 +137,26 @@ export var Default = function Default(args) {
|
|
110
137
|
);
|
111
138
|
};
|
112
139
|
export var WithCustomValues = function WithCustomValues(args) {
|
113
|
-
|
140
|
+
var _useState3 = useState(false),
|
141
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
142
|
+
isOpen = _useState4[0],
|
143
|
+
setIsOpen = _useState4[1];
|
144
|
+
|
145
|
+
var direction = args.direction;
|
146
|
+
|
147
|
+
var onOpenChange = function onOpenChange() {
|
148
|
+
setIsOpen(true);
|
149
|
+
};
|
150
|
+
|
151
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
152
|
+
, {
|
153
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
154
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
114
155
|
items: items,
|
115
156
|
mode: "non-restrictive"
|
116
|
-
}, args
|
157
|
+
}, args, {
|
158
|
+
onOpenChange: onOpenChange
|
159
|
+
}), function (item) {
|
117
160
|
return ___EmotionJSX(Item, {
|
118
161
|
key: item.key,
|
119
162
|
"data-id": item.name
|
@@ -126,10 +169,26 @@ WithCustomValues.argTypes = {
|
|
126
169
|
}
|
127
170
|
};
|
128
171
|
export var WithDisabledKeys = function WithDisabledKeys(args) {
|
129
|
-
|
172
|
+
var _useState5 = useState(false),
|
173
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
174
|
+
isOpen = _useState6[0],
|
175
|
+
setIsOpen = _useState6[1];
|
176
|
+
|
177
|
+
var direction = args.direction;
|
178
|
+
|
179
|
+
var onOpenChange = function onOpenChange() {
|
180
|
+
setIsOpen(true);
|
181
|
+
};
|
182
|
+
|
183
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
184
|
+
, {
|
185
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
186
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
130
187
|
disabledKeys: ['Aardvark'],
|
131
188
|
items: items
|
132
|
-
}, args
|
189
|
+
}, args, {
|
190
|
+
onOpenChange: onOpenChange
|
191
|
+
}), function (item) {
|
133
192
|
return ___EmotionJSX(Item, {
|
134
193
|
key: item.key,
|
135
194
|
"data-id": item.name
|
@@ -137,10 +196,26 @@ export var WithDisabledKeys = function WithDisabledKeys(args) {
|
|
137
196
|
}));
|
138
197
|
};
|
139
198
|
export var Uncontrolled = function Uncontrolled(args) {
|
140
|
-
|
199
|
+
var _useState7 = useState(false),
|
200
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
201
|
+
isOpen = _useState8[0],
|
202
|
+
setIsOpen = _useState8[1];
|
203
|
+
|
204
|
+
var direction = args.direction;
|
205
|
+
|
206
|
+
var onOpenChange = function onOpenChange() {
|
207
|
+
setIsOpen(true);
|
208
|
+
};
|
209
|
+
|
210
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
211
|
+
, {
|
212
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
213
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
141
214
|
defaultSelectedKeys: ['Aardvark', 'Snake'],
|
142
215
|
items: items
|
143
|
-
}, args
|
216
|
+
}, args, {
|
217
|
+
onOpenChange: onOpenChange
|
218
|
+
}), function (item) {
|
144
219
|
return ___EmotionJSX(Item, {
|
145
220
|
key: item.key,
|
146
221
|
"data-id": item.name
|
@@ -148,17 +223,32 @@ export var Uncontrolled = function Uncontrolled(args) {
|
|
148
223
|
}));
|
149
224
|
};
|
150
225
|
export var Controlled = function Controlled(args) {
|
151
|
-
var
|
152
|
-
|
153
|
-
selectedKeys =
|
154
|
-
setSelectedKeys =
|
226
|
+
var _useState9 = useState(['Aardvark', 'Snake']),
|
227
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
228
|
+
selectedKeys = _useState10[0],
|
229
|
+
setSelectedKeys = _useState10[1];
|
230
|
+
|
231
|
+
var _useState11 = useState(false),
|
232
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
233
|
+
isOpen = _useState12[0],
|
234
|
+
setIsOpen = _useState12[1];
|
235
|
+
|
236
|
+
var direction = args.direction;
|
155
237
|
|
156
|
-
|
238
|
+
var onOpenChange = function onOpenChange() {
|
239
|
+
setIsOpen(true);
|
240
|
+
};
|
241
|
+
|
242
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
243
|
+
, {
|
244
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
245
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
157
246
|
label: "Field Label"
|
158
247
|
}, args, {
|
159
248
|
items: items,
|
160
249
|
onSelectionChange: setSelectedKeys,
|
161
|
-
selectedKeys: selectedKeys
|
250
|
+
selectedKeys: selectedKeys,
|
251
|
+
onOpenChange: onOpenChange
|
162
252
|
}), function (item) {
|
163
253
|
return ___EmotionJSX(Item, {
|
164
254
|
key: item.key,
|
@@ -167,6 +257,17 @@ export var Controlled = function Controlled(args) {
|
|
167
257
|
}));
|
168
258
|
};
|
169
259
|
export var WithCustomSize = function WithCustomSize(args) {
|
260
|
+
var _useState13 = useState(false),
|
261
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
262
|
+
isOpen = _useState14[0],
|
263
|
+
setIsOpen = _useState14[1];
|
264
|
+
|
265
|
+
var direction = args.direction;
|
266
|
+
|
267
|
+
var onOpenChange = function onOpenChange() {
|
268
|
+
setIsOpen(true);
|
269
|
+
};
|
270
|
+
|
170
271
|
return ___EmotionJSX(Box, {
|
171
272
|
sx: {
|
172
273
|
width: '100%',
|
@@ -175,9 +276,14 @@ export var WithCustomSize = function WithCustomSize(args) {
|
|
175
276
|
}
|
176
277
|
}, ___EmotionJSX(Box, {
|
177
278
|
width: 300
|
178
|
-
}, ___EmotionJSX(OverlayProvider
|
279
|
+
}, ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
280
|
+
, {
|
281
|
+
style: setOverlayStyle(direction, isOpen, '25%', '25%', '75%')
|
282
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
179
283
|
items: items
|
180
|
-
}, args
|
284
|
+
}, args, {
|
285
|
+
onOpenChange: onOpenChange
|
286
|
+
}), function (item) {
|
181
287
|
return ___EmotionJSX(Item, {
|
182
288
|
key: item.key,
|
183
289
|
"data-id": item.name
|
@@ -185,10 +291,26 @@ export var WithCustomSize = function WithCustomSize(args) {
|
|
185
291
|
}))));
|
186
292
|
};
|
187
293
|
export var WithReadOnlyValues = function WithReadOnlyValues(args) {
|
188
|
-
|
294
|
+
var _useState15 = useState(false),
|
295
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
296
|
+
isOpen = _useState16[0],
|
297
|
+
setIsOpen = _useState16[1];
|
298
|
+
|
299
|
+
var direction = args.direction;
|
300
|
+
|
301
|
+
var onOpenChange = function onOpenChange() {
|
302
|
+
setIsOpen(true);
|
303
|
+
};
|
304
|
+
|
305
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
306
|
+
, {
|
307
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
308
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
189
309
|
readOnlyKeys: ['Aardvark', 'Snake'],
|
190
310
|
items: items
|
191
|
-
}, args
|
311
|
+
}, args, {
|
312
|
+
onOpenChange: onOpenChange
|
313
|
+
}), function (item) {
|
192
314
|
return ___EmotionJSX(Item, {
|
193
315
|
key: item.key,
|
194
316
|
"data-id": item.name
|