@pingux/astro 1.16.1-alpha.0 → 1.17.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/Button/Button.stories.js +8 -3
- package/lib/cjs/components/Button/Button.test.js +5 -0
- 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/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/Link/Link.test.js +5 -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/Button/Button.test.js +3 -0
- 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/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/Link/Link.test.js +3 -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
@@ -9,6 +9,8 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
10
10
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
11
11
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
12
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
13
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
12
14
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
13
15
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
14
16
|
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
@@ -16,7 +18,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
16
18
|
|
17
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; }
|
18
20
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
20
22
|
|
21
23
|
import React, { useState, useMemo } from 'react';
|
22
24
|
import { axe } from 'jest-axe';
|
@@ -83,6 +85,54 @@ var ComboBoxWithCustomFilter = function ComboBoxWithCustomFilter() {
|
|
83
85
|
});
|
84
86
|
};
|
85
87
|
|
88
|
+
var ComboBoxWithAddOption = function ComboBoxWithAddOption() {
|
89
|
+
var _useState3 = useState(items),
|
90
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
91
|
+
options = _useState4[0],
|
92
|
+
setOptions = _useState4[1];
|
93
|
+
|
94
|
+
var _useState5 = useState(''),
|
95
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
96
|
+
inputValue = _useState6[0],
|
97
|
+
setInputValue = _useState6[1];
|
98
|
+
|
99
|
+
var _useState7 = useState(''),
|
100
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
101
|
+
selectedKey = _useState8[0],
|
102
|
+
setSelectedKey = _useState8[1];
|
103
|
+
|
104
|
+
var onSelectionChange = function onSelectionChange(key) {
|
105
|
+
if (key && !_findInstanceProperty(options).call(options, function (_ref2) {
|
106
|
+
var name = _ref2.name;
|
107
|
+
return name === key;
|
108
|
+
})) {
|
109
|
+
var _context;
|
110
|
+
|
111
|
+
setOptions(_concatInstanceProperty(_context = []).call(_context, options, [{
|
112
|
+
key: key,
|
113
|
+
name: key
|
114
|
+
}]));
|
115
|
+
}
|
116
|
+
|
117
|
+
setInputValue(key);
|
118
|
+
setSelectedKey(key);
|
119
|
+
};
|
120
|
+
|
121
|
+
return ___EmotionJSX(ComboBoxField, {
|
122
|
+
label: "Example label",
|
123
|
+
defaultItems: options,
|
124
|
+
inputValue: inputValue,
|
125
|
+
selectedKey: selectedKey,
|
126
|
+
onInputChange: setInputValue,
|
127
|
+
onSelectionChange: onSelectionChange,
|
128
|
+
hasAddOption: true
|
129
|
+
}, function (item) {
|
130
|
+
return ___EmotionJSX(Item, {
|
131
|
+
key: item.name
|
132
|
+
}, item.name);
|
133
|
+
});
|
134
|
+
};
|
135
|
+
|
86
136
|
beforeAll(function () {
|
87
137
|
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function () {
|
88
138
|
return 1000;
|
@@ -357,41 +407,41 @@ test('should use default contains filtering', function () {
|
|
357
407
|
});
|
358
408
|
test('should be able to use controlled filtering', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
359
409
|
var options, input;
|
360
|
-
return _regeneratorRuntime.wrap(function _callee$(
|
410
|
+
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
361
411
|
while (1) {
|
362
|
-
switch (
|
412
|
+
switch (_context2.prev = _context2.next) {
|
363
413
|
case 0:
|
364
414
|
render(___EmotionJSX(ComboBoxWithCustomFilter, null));
|
365
415
|
input = screen.queryByRole('combobox'); // Should list all without filterable input
|
366
416
|
|
367
417
|
userEvent.type(input, '{arrowdown}');
|
368
|
-
|
418
|
+
_context2.next = 5;
|
369
419
|
return screen.findAllByRole('option');
|
370
420
|
|
371
421
|
case 5:
|
372
|
-
options =
|
422
|
+
options = _context2.sent;
|
373
423
|
expect(options).toHaveLength(items.length); // Should only list the second option
|
374
424
|
|
375
425
|
userEvent.type(input, 'k');
|
376
|
-
|
426
|
+
_context2.next = 10;
|
377
427
|
return screen.findAllByRole('option');
|
378
428
|
|
379
429
|
case 10:
|
380
|
-
options =
|
430
|
+
options = _context2.sent;
|
381
431
|
expect(options[0]).toHaveTextContent(items[1].name);
|
382
432
|
|
383
433
|
case 12:
|
384
434
|
case "end":
|
385
|
-
return
|
435
|
+
return _context2.stop();
|
386
436
|
}
|
387
437
|
}
|
388
438
|
}, _callee);
|
389
439
|
})));
|
390
440
|
test('should be able to use custom default filtering', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
391
441
|
var options, defaultFilter, input;
|
392
|
-
return _regeneratorRuntime.wrap(function _callee2$(
|
442
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
393
443
|
while (1) {
|
394
|
-
switch (
|
444
|
+
switch (_context3.prev = _context3.next) {
|
395
445
|
case 0:
|
396
446
|
defaultFilter = function defaultFilter(option, inputValue) {
|
397
447
|
return _startsWithInstanceProperty(option).call(option, inputValue);
|
@@ -403,33 +453,33 @@ test('should be able to use custom default filtering', /*#__PURE__*/_asyncToGene
|
|
403
453
|
input = screen.queryByRole('combobox'); // Should list all without filterable input
|
404
454
|
|
405
455
|
userEvent.type(input, '{arrowdown}');
|
406
|
-
|
456
|
+
_context3.next = 6;
|
407
457
|
return screen.findAllByRole('option');
|
408
458
|
|
409
459
|
case 6:
|
410
|
-
options =
|
460
|
+
options = _context3.sent;
|
411
461
|
expect(options).toHaveLength(items.length); // Should only list the second option
|
412
462
|
|
413
463
|
userEvent.type(input, 'K');
|
414
|
-
|
464
|
+
_context3.next = 11;
|
415
465
|
return screen.findAllByRole('option');
|
416
466
|
|
417
467
|
case 11:
|
418
|
-
options =
|
468
|
+
options = _context3.sent;
|
419
469
|
expect(options[0]).toHaveTextContent(items[1].name);
|
420
470
|
|
421
471
|
case 13:
|
422
472
|
case "end":
|
423
|
-
return
|
473
|
+
return _context3.stop();
|
424
474
|
}
|
425
475
|
}
|
426
476
|
}, _callee2);
|
427
477
|
})));
|
428
478
|
test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
429
479
|
var newItems, input, options;
|
430
|
-
return _regeneratorRuntime.wrap(function _callee3$(
|
480
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
431
481
|
while (1) {
|
432
|
-
switch (
|
482
|
+
switch (_context4.prev = _context4.next) {
|
433
483
|
case 0:
|
434
484
|
newItems = _mapInstanceProperty(items).call(items, function (item) {
|
435
485
|
return _objectSpread(_objectSpread({}, item), {}, {
|
@@ -441,11 +491,11 @@ test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenera
|
|
441
491
|
});
|
442
492
|
input = screen.queryByRole('combobox');
|
443
493
|
userEvent.click(input);
|
444
|
-
|
494
|
+
_context4.next = 6;
|
445
495
|
return screen.findAllByRole('option');
|
446
496
|
|
447
497
|
case 6:
|
448
|
-
options =
|
498
|
+
options = _context4.sent;
|
449
499
|
userEvent.click(options[0]);
|
450
500
|
expect(input).toHaveValue(newItems[0].textValue); // Check that on clicking again "textValue" still returning
|
451
501
|
|
@@ -454,7 +504,7 @@ test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenera
|
|
454
504
|
|
455
505
|
case 11:
|
456
506
|
case "end":
|
457
|
-
return
|
507
|
+
return _context4.stop();
|
458
508
|
}
|
459
509
|
}
|
460
510
|
}, _callee3);
|
@@ -777,25 +827,56 @@ test('onSelectionChange works properly with custom value', function () {
|
|
777
827
|
userEvent.type(input, '{selectall}{backspace}{enter}');
|
778
828
|
expect(onSelectionChange).toHaveBeenCalledWith('');
|
779
829
|
});
|
830
|
+
test('add option shows when "hasAddOption" is provided', function () {
|
831
|
+
render(___EmotionJSX(ComboBoxWithAddOption, null));
|
832
|
+
var input = screen.queryByRole('combobox');
|
833
|
+
expect(input).toHaveValue('');
|
834
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
835
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
836
|
+
var inputValue = 'New value';
|
837
|
+
userEvent.type(input, inputValue);
|
838
|
+
expect(input).toHaveValue(inputValue);
|
839
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
840
|
+
var option = screen.queryByRole('option');
|
841
|
+
expect(option).toBeInTheDocument();
|
842
|
+
expect(option).toHaveClass('is-focused');
|
843
|
+
expect(option).toHaveTextContent("ADD: ".concat(inputValue));
|
844
|
+
});
|
845
|
+
test('if "hasAddOption" is provided, then custom value is added to listbox on blur', function () {
|
846
|
+
render(___EmotionJSX(ComboBoxWithAddOption, null));
|
847
|
+
var input = screen.queryByRole('combobox');
|
848
|
+
var inputValue = 'New value';
|
849
|
+
userEvent.type(input, inputValue);
|
850
|
+
expect(input).toHaveValue(inputValue); // blur input
|
851
|
+
|
852
|
+
userEvent.tab();
|
853
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
854
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
855
|
+
userEvent.click(input);
|
856
|
+
expect(input).toHaveValue(inputValue);
|
857
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
858
|
+
var options = screen.queryAllByRole('option');
|
859
|
+
expect(options[options.length - 1]).toHaveTextContent(inputValue);
|
860
|
+
});
|
780
861
|
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
781
862
|
var _getComponent6, container, results;
|
782
863
|
|
783
|
-
return _regeneratorRuntime.wrap(function _callee4$(
|
864
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
784
865
|
while (1) {
|
785
|
-
switch (
|
866
|
+
switch (_context5.prev = _context5.next) {
|
786
867
|
case 0:
|
787
868
|
jest.useRealTimers();
|
788
869
|
_getComponent6 = getComponent(), container = _getComponent6.container;
|
789
|
-
|
870
|
+
_context5.next = 4;
|
790
871
|
return axe(container);
|
791
872
|
|
792
873
|
case 4:
|
793
|
-
results =
|
874
|
+
results = _context5.sent;
|
794
875
|
expect(results).toHaveNoViolations();
|
795
876
|
|
796
877
|
case 6:
|
797
878
|
case "end":
|
798
|
-
return
|
879
|
+
return _context5.stop();
|
799
880
|
}
|
800
881
|
}
|
801
882
|
}, _callee4);
|
@@ -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
|
|
@@ -43,6 +43,9 @@ test('link shows focus status', function () {
|
|
43
43
|
userEvent.tab();
|
44
44
|
expect(link).toHaveFocus();
|
45
45
|
expect(link).toHaveClass('is-focused');
|
46
|
+
userEvent.tab();
|
47
|
+
expect(link).not.toHaveFocus();
|
48
|
+
expect(link).not.toHaveClass('is-focused');
|
46
49
|
});
|
47
50
|
test('link shows disabled status', function () {
|
48
51
|
// Needs href to have a tabindex
|
@@ -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,
|
@@ -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
|