@pingux/astro 1.0.0-alpha.9 → 1.1.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/CHANGELOG.md +257 -0
- package/README.md +5 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -0
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +1 -1
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +1 -1
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +33 -1
- package/lib/cjs/components/AccordionItem/AccordionItem.js +5 -4
- package/lib/cjs/components/Button/Button.js +6 -26
- package/lib/cjs/components/Button/Button.stories.js +7 -12
- package/lib/cjs/components/Button/Button.test.js +2 -25
- package/lib/cjs/components/Chip/Chip.js +26 -10
- package/lib/cjs/components/Chip/Chip.stories.js +44 -5
- package/lib/cjs/components/Chip/Chip.test.js +9 -0
- package/lib/cjs/components/{DropdownField/index.js → Chip/ChipContext.js} +8 -7
- package/lib/cjs/components/ColorField/ColorField.js +1 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +7 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +25 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +44 -0
- package/lib/cjs/components/FileInputField/FileItem.js +2 -1
- package/lib/cjs/components/IconButton/IconButton.js +17 -7
- package/lib/cjs/components/IconButton/IconButton.stories.js +8 -17
- package/lib/cjs/components/IconButton/IconButton.test.js +4 -6
- package/lib/cjs/components/ImageUploadField/ImagePreviewButton.js +2 -1
- package/lib/cjs/components/List/List.js +3 -0
- package/lib/cjs/components/List/List.stories.js +7 -2
- package/lib/cjs/components/ListBox/ListBox.js +3 -6
- package/lib/cjs/components/ListBox/ListBox.test.js +2 -0
- package/lib/cjs/components/ListBox/Option.js +6 -0
- package/lib/cjs/components/ListItem/ListItem.stories.js +0 -2
- package/lib/cjs/components/ListView/ListView.js +4 -3
- package/lib/cjs/components/ListView/ListView.stories.js +580 -39
- package/lib/cjs/components/ListViewItem/ListViewItem.js +3 -6
- package/lib/cjs/components/Messages/Message.js +2 -2
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +3 -2
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +15 -14
- package/lib/cjs/components/PopoverContainer/PopoverContainer.test.js +15 -0
- package/lib/cjs/components/Stepper/Stepper.js +1 -0
- package/lib/cjs/components/Tab/Tab.js +5 -3
- package/lib/cjs/components/Tabs/Tabs.js +3 -0
- package/lib/cjs/components/Tabs/Tabs.stories.js +3 -4
- package/lib/cjs/components/Tabs/Tabs.test.js +44 -15
- package/lib/cjs/components/TextArea/TextArea.js +5 -1
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +10 -0
- package/lib/cjs/components/TooltipTrigger/TooltipTrigger.stories.js +45 -2
- package/lib/cjs/index.js +48 -136
- package/lib/cjs/layouts/ListLayout.stories.js +2 -1
- package/lib/cjs/layouts/SchemaFormLayout.stories.js +2 -21
- package/lib/cjs/recipes/ArrayField.stories.js +3 -3
- package/lib/cjs/styles/forms/input.js +4 -0
- package/lib/cjs/styles/theme.js +0 -3
- package/lib/cjs/styles/variants/accordion.js +7 -9
- package/lib/cjs/styles/variants/boxes.js +22 -19
- package/lib/cjs/styles/variants/buttons.js +48 -29
- package/lib/cjs/styles/variants/variants.js +0 -3
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
- package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +23 -1
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +1 -1
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +1 -1
- package/lib/components/AccordionGroup/AccordionGroup.test.js +30 -1
- package/lib/components/AccordionItem/AccordionItem.js +6 -5
- package/lib/components/Button/Button.js +8 -26
- package/lib/components/Button/Button.stories.js +7 -11
- package/lib/components/Button/Button.test.js +2 -21
- package/lib/components/Chip/Chip.js +25 -10
- package/lib/components/Chip/Chip.stories.js +41 -5
- package/lib/components/Chip/Chip.test.js +9 -0
- package/lib/components/Chip/ChipContext.js +3 -0
- package/lib/components/ColorField/ColorField.js +1 -0
- package/lib/components/ComboBoxField/ComboBoxField.js +7 -0
- package/lib/components/ComboBoxField/ComboBoxField.stories.js +21 -0
- package/lib/components/ComboBoxField/ComboBoxField.test.js +35 -0
- package/lib/components/FileInputField/FileItem.js +2 -1
- package/lib/components/IconButton/IconButton.js +17 -9
- package/lib/components/IconButton/IconButton.stories.js +7 -13
- package/lib/components/IconButton/IconButton.test.js +4 -6
- package/lib/components/ImageUploadField/ImagePreviewButton.js +2 -1
- package/lib/components/List/List.js +2 -0
- package/lib/components/List/List.stories.js +6 -2
- package/lib/components/ListBox/ListBox.js +3 -5
- package/lib/components/ListBox/ListBox.test.js +2 -0
- package/lib/components/ListBox/Option.js +6 -0
- package/lib/components/ListItem/ListItem.stories.js +0 -2
- package/lib/components/ListView/ListView.js +4 -3
- package/lib/components/ListView/ListView.stories.js +577 -39
- package/lib/components/ListViewItem/ListViewItem.js +3 -5
- package/lib/components/Messages/Message.js +2 -2
- package/lib/components/MultivaluesField/MultivaluesField.js +3 -2
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +7 -5
- package/lib/components/PopoverContainer/PopoverContainer.test.js +16 -1
- package/lib/components/Stepper/Stepper.js +1 -0
- package/lib/components/Tab/Tab.js +5 -3
- package/lib/components/Tabs/Tabs.js +3 -0
- package/lib/components/Tabs/Tabs.stories.js +3 -4
- package/lib/components/Tabs/Tabs.test.js +40 -15
- package/lib/components/TextArea/TextArea.js +5 -1
- package/lib/components/TextAreaField/TextAreaField.test.js +8 -0
- package/lib/components/TooltipTrigger/TooltipTrigger.stories.js +33 -1
- package/lib/index.js +0 -8
- package/lib/layouts/ListLayout.stories.js +2 -1
- package/lib/layouts/SchemaFormLayout.stories.js +2 -19
- package/lib/recipes/ArrayField.stories.js +3 -3
- package/lib/styles/forms/input.js +4 -0
- package/lib/styles/theme.js +0 -3
- package/lib/styles/variants/accordion.js +7 -9
- package/lib/styles/variants/boxes.js +21 -19
- package/lib/styles/variants/buttons.js +47 -29
- package/lib/styles/variants/variants.js +0 -2
- package/package.json +1 -1
- package/lib/cjs/components/Dropdown/Dropdown.js +0 -112
- package/lib/cjs/components/Dropdown/Dropdown.test.js +0 -80
- package/lib/cjs/components/Dropdown/index.js +0 -18
- package/lib/cjs/components/DropdownField/DropdownField.js +0 -187
- package/lib/cjs/components/DropdownField/DropdownField.stories.js +0 -278
- package/lib/cjs/components/DropdownField/DropdownField.test.js +0 -80
- package/lib/cjs/components/Panel/Panel.js +0 -101
- package/lib/cjs/components/Panel/Panel.stories.js +0 -57
- package/lib/cjs/components/Panel/Panel.test.js +0 -72
- package/lib/cjs/components/Panel/index.js +0 -18
- package/lib/cjs/components/Popover/Popover.js +0 -87
- package/lib/cjs/components/Popover/Popover.stories.js +0 -80
- package/lib/cjs/components/Popover/Popover.test.js +0 -91
- package/lib/cjs/components/Popover/index.js +0 -18
- package/lib/cjs/recipes/InputBoxWithLinkedChip.stories.js +0 -67
- package/lib/cjs/styles/variants/popover.js +0 -86
- package/lib/components/Dropdown/Dropdown.js +0 -90
- package/lib/components/Dropdown/Dropdown.test.js +0 -62
- package/lib/components/Dropdown/index.js +0 -1
- package/lib/components/DropdownField/DropdownField.js +0 -155
- package/lib/components/DropdownField/DropdownField.stories.js +0 -222
- package/lib/components/DropdownField/DropdownField.test.js +0 -60
- package/lib/components/DropdownField/index.js +0 -1
- package/lib/components/Panel/Panel.js +0 -71
- package/lib/components/Panel/Panel.stories.js +0 -35
- package/lib/components/Panel/Panel.test.js +0 -52
- package/lib/components/Panel/index.js +0 -1
- package/lib/components/Popover/Popover.js +0 -65
- package/lib/components/Popover/Popover.stories.js +0 -52
- package/lib/components/Popover/Popover.test.js +0 -75
- package/lib/components/Popover/index.js +0 -2
- package/lib/recipes/InputBoxWithLinkedChip.stories.js +0 -43
- package/lib/styles/variants/popover.js +0 -76
@@ -1,6 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
|
+
import { ChipContext } from './ChipContext';
|
4
5
|
import Box from '../Box/Box';
|
5
6
|
import Text from '../Text/Text';
|
6
7
|
import * as colors from '../../styles/colors';
|
@@ -12,21 +13,31 @@ import * as colors from '../../styles/colors';
|
|
12
13
|
|
13
14
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
15
|
var Chip = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
15
|
-
var
|
16
|
+
var bg = props.bg,
|
17
|
+
children = props.children,
|
16
18
|
textColor = props.textColor,
|
17
19
|
textProps = props.textProps,
|
18
|
-
label = props.label
|
19
|
-
|
20
|
+
label = props.label,
|
21
|
+
isUppercase = props.isUppercase;
|
22
|
+
return ___EmotionJSX(ChipContext.Provider, {
|
23
|
+
value: {
|
24
|
+
bg: bg
|
25
|
+
}
|
26
|
+
}, ___EmotionJSX(Box, _extends({
|
20
27
|
isRow: true,
|
21
28
|
variant: "boxes.chip",
|
29
|
+
sx: isUppercase && {
|
30
|
+
paddingBottom: '3px'
|
31
|
+
},
|
22
32
|
ref: ref
|
23
33
|
}, props), ___EmotionJSX(Text, _extends({
|
24
34
|
variant: "label",
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
35
|
+
color: textColor,
|
36
|
+
sx: isUppercase && {
|
37
|
+
textTransform: 'uppercase',
|
38
|
+
fontSize: '11px'
|
39
|
+
}
|
40
|
+
}, textProps), label), children));
|
30
41
|
});
|
31
42
|
Chip.propTypes = {
|
32
43
|
/** The text color of the chip. */
|
@@ -39,10 +50,14 @@ Chip.propTypes = {
|
|
39
50
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
40
51
|
|
41
52
|
/** Props object that is spread directly into the textfield. */
|
42
|
-
textProps: PropTypes.shape({})
|
53
|
+
textProps: PropTypes.shape({}),
|
54
|
+
|
55
|
+
/** When true, display chip label as uppercase. */
|
56
|
+
isUppercase: PropTypes.bool
|
43
57
|
};
|
44
58
|
Chip.defaultProps = {
|
45
59
|
textColor: 'white',
|
46
|
-
bg: colors.neutral[10]
|
60
|
+
bg: colors.neutral[10],
|
61
|
+
isUppercase: false
|
47
62
|
};
|
48
63
|
export default Chip;
|
@@ -3,8 +3,11 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
3
3
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
4
4
|
import React from 'react';
|
5
5
|
import Clear from 'mdi-react/CloseIcon';
|
6
|
-
import
|
7
|
-
import
|
6
|
+
import ContentCopy from 'mdi-react/ContentCopyIcon';
|
7
|
+
import Earth from 'mdi-react/EarthIcon';
|
8
|
+
import Chip from '../Chip';
|
9
|
+
import Icon from '../Icon';
|
10
|
+
import IconButton from '../IconButton';
|
8
11
|
import { flatColorList } from '../../styles/colors.js';
|
9
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
13
|
export default {
|
@@ -40,6 +43,12 @@ export default {
|
|
40
43
|
control: {
|
41
44
|
type: 'text'
|
42
45
|
}
|
46
|
+
},
|
47
|
+
isUppercase: {
|
48
|
+
defaultValue: false,
|
49
|
+
control: {
|
50
|
+
type: 'boolean'
|
51
|
+
}
|
43
52
|
}
|
44
53
|
}
|
45
54
|
};
|
@@ -59,13 +68,40 @@ export var ChipWithCustomColors = function ChipWithCustomColors() {
|
|
59
68
|
});
|
60
69
|
};
|
61
70
|
export var ChipWithIcon = function ChipWithIcon() {
|
62
|
-
return ___EmotionJSX(Chip, {
|
63
|
-
label: "Chip with Icon",
|
71
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Chip, {
|
72
|
+
label: "Chip with Icon Button",
|
64
73
|
bg: "navy"
|
74
|
+
}, ___EmotionJSX(IconButton, {
|
75
|
+
"aria-label": "Clear Chip with Icon Button",
|
76
|
+
variant: "inverted"
|
65
77
|
}, ___EmotionJSX(Icon, {
|
66
78
|
icon: Clear,
|
67
79
|
ml: "xs",
|
80
|
+
size: "14px"
|
81
|
+
}))), ___EmotionJSX("div", {
|
82
|
+
style: {
|
83
|
+
padding: '5px'
|
84
|
+
}
|
85
|
+
}), ___EmotionJSX(Chip, {
|
86
|
+
label: "Chip with Icon Button"
|
87
|
+
}, ___EmotionJSX(IconButton, {
|
88
|
+
"aria-label": "Clear Chip with Icon Button",
|
89
|
+
variant: "inverted"
|
90
|
+
}, ___EmotionJSX(Icon, {
|
91
|
+
icon: Earth,
|
92
|
+
ml: "xs",
|
93
|
+
size: "14px"
|
94
|
+
}))), ___EmotionJSX("div", {
|
95
|
+
style: {
|
96
|
+
padding: '5px'
|
97
|
+
}
|
98
|
+
}), ___EmotionJSX(Chip, {
|
99
|
+
label: "Chip with Icon",
|
100
|
+
bg: "green"
|
101
|
+
}, ___EmotionJSX(Icon, {
|
102
|
+
icon: ContentCopy,
|
103
|
+
ml: "xs",
|
68
104
|
size: "14px",
|
69
105
|
color: "white"
|
70
|
-
}));
|
106
|
+
})));
|
71
107
|
};
|
@@ -31,4 +31,13 @@ test('renders children within Chip component', function () {
|
|
31
31
|
});
|
32
32
|
var mockedChildren = screen.getByRole('button');
|
33
33
|
expect(mockedChildren).toBeInTheDocument();
|
34
|
+
});
|
35
|
+
test('renders Chip component with uppercase', function () {
|
36
|
+
var label = 'uppercase';
|
37
|
+
var isUppercase = true;
|
38
|
+
getComponent({
|
39
|
+
label: label,
|
40
|
+
isUppercase: isUppercase
|
41
|
+
});
|
42
|
+
expect(screen.queryByText('uppercase')).toHaveStyleRule('text-transform', 'uppercase');
|
34
43
|
});
|
@@ -108,6 +108,7 @@ var ColorField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
108
108
|
return _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "rgba(".concat(colorValue === null || colorValue === void 0 ? void 0 : colorValue.red, ", ")).call(_context4, colorValue === null || colorValue === void 0 ? void 0 : colorValue.green, ", ")).call(_context3, colorValue === null || colorValue === void 0 ? void 0 : colorValue.blue, ", ")).call(_context2, colorValue === null || colorValue === void 0 ? void 0 : colorValue.alpha, ")");
|
109
109
|
}, []);
|
110
110
|
return ___EmotionJSX(Box, fieldContainerProps, label && ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Button, _extends({
|
111
|
+
"aria-label": "Select color",
|
111
112
|
bg: getRgbaFromState(state),
|
112
113
|
onPress: handleButtonPress,
|
113
114
|
ref: triggerRef,
|
@@ -116,6 +116,12 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
116
116
|
useImperativeHandle(ref, function () {
|
117
117
|
return inputRef.current;
|
118
118
|
});
|
119
|
+
/* istanbul ignore next */
|
120
|
+
|
121
|
+
var onSelectionChangeHandler = function onSelectionChangeHandler(key) {
|
122
|
+
var newVal = key || selectedKey || '';
|
123
|
+
if (onSelectionChange) onSelectionChange(newVal);
|
124
|
+
};
|
119
125
|
|
120
126
|
var _useFilter = useFilter({
|
121
127
|
sensitivity: 'base'
|
@@ -123,6 +129,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
123
129
|
contains = _useFilter.contains;
|
124
130
|
|
125
131
|
var state = useComboBoxState(_objectSpread(_objectSpread({}, comboBoxOptions), {}, {
|
132
|
+
onSelectionChange: hasCustomValue ? onSelectionChangeHandler : onSelectionChange,
|
126
133
|
defaultFilter: contains
|
127
134
|
}));
|
128
135
|
|
@@ -330,6 +330,27 @@ export var ControlledFiltering = function ControlledFiltering() {
|
|
330
330
|
}, item.name);
|
331
331
|
}));
|
332
332
|
};
|
333
|
+
export var ControlledWithCustomValue = function ControlledWithCustomValue() {
|
334
|
+
var _useState9 = useState(''),
|
335
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
336
|
+
inputValue = _useState10[0],
|
337
|
+
setInputValue = _useState10[1];
|
338
|
+
|
339
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
|
340
|
+
label: "Example label",
|
341
|
+
defaultItems: items
|
342
|
+
}, actions, {
|
343
|
+
inputValue: inputValue,
|
344
|
+
selectedKey: inputValue,
|
345
|
+
onInputChange: setInputValue,
|
346
|
+
onSelectionChange: setInputValue,
|
347
|
+
hasCustomValue: true
|
348
|
+
}), function (item) {
|
349
|
+
return ___EmotionJSX(Item, {
|
350
|
+
key: item.name
|
351
|
+
}, item.name);
|
352
|
+
}));
|
353
|
+
};
|
333
354
|
export var AllowCustomValue = function AllowCustomValue() {
|
334
355
|
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
|
335
356
|
label: "Example label",
|
@@ -639,6 +639,41 @@ test('two listbox can not be open at the same time', function () {
|
|
639
639
|
name: 'Tango'
|
640
640
|
})).toBeInTheDocument();
|
641
641
|
});
|
642
|
+
test('should handle selecting custom option', function () {
|
643
|
+
getComponent({
|
644
|
+
hasCustomValue: true
|
645
|
+
});
|
646
|
+
var input = screen.queryByRole('combobox');
|
647
|
+
expect(input).toHaveValue(''); // type something
|
648
|
+
|
649
|
+
userEvent.type(input, 'custom'); // set input value as selected
|
650
|
+
|
651
|
+
userEvent.type(input, '{enter}', {
|
652
|
+
skipClick: true
|
653
|
+
});
|
654
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
655
|
+
expect(screen.queryByRole('combobox')).toHaveValue('custom'); // blur input
|
656
|
+
|
657
|
+
userEvent.tab();
|
658
|
+
expect(input).toHaveValue('custom');
|
659
|
+
});
|
660
|
+
test('onSelectionChange works properly with custom value', function () {
|
661
|
+
var onSelectionChange = jest.fn();
|
662
|
+
getComponent({
|
663
|
+
hasCustomValue: true,
|
664
|
+
onSelectionChange: onSelectionChange,
|
665
|
+
onInputChange: onSelectionChange
|
666
|
+
});
|
667
|
+
var input = screen.queryByRole('combobox');
|
668
|
+
expect(input).toHaveValue('');
|
669
|
+
expect(onSelectionChange).not.toHaveBeenCalled(); // Should fire when input value was typed, and enter was pressed
|
670
|
+
|
671
|
+
userEvent.type(input, 'custom{enter}');
|
672
|
+
expect(onSelectionChange).toHaveBeenCalledWith('custom'); // Should fire when input is cleared
|
673
|
+
|
674
|
+
userEvent.type(input, '{selectall}{backspace}{enter}');
|
675
|
+
expect(onSelectionChange).toHaveBeenCalledWith('');
|
676
|
+
});
|
642
677
|
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
643
678
|
var _getComponent6, container, results;
|
644
679
|
|
@@ -14,13 +14,15 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
14
14
|
|
15
15
|
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; }
|
16
16
|
|
17
|
-
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
17
|
+
import React, { forwardRef, useRef, useImperativeHandle, useContext } from 'react';
|
18
18
|
import PropTypes from 'prop-types';
|
19
19
|
import { IconButton as ThemeUIIconButton } from 'theme-ui';
|
20
|
+
import { useButton } from '@react-aria/button';
|
20
21
|
import { useFocusRing } from '@react-aria/focus';
|
21
|
-
import { Pressable, useHover
|
22
|
+
import { Pressable, useHover } from '@react-aria/interactions';
|
22
23
|
import { mergeProps } from '@react-aria/utils';
|
23
24
|
import { useAriaLabelWarning, useStatusClasses } from '../../hooks';
|
25
|
+
import { ChipContext } from '../Chip/ChipContext';
|
24
26
|
import TooltipTrigger, { Tooltip } from '../TooltipTrigger';
|
25
27
|
/**
|
26
28
|
* Convenience wrapper for a Button + Icon. This component applies specific styles necessary for
|
@@ -51,11 +53,12 @@ var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
51
53
|
return buttonRef.current;
|
52
54
|
});
|
53
55
|
|
54
|
-
var
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
var _useButton = useButton(_objectSpread({}, props), buttonRef),
|
57
|
+
buttonProps = _useButton.buttonProps,
|
58
|
+
isPressed = _useButton.isPressed;
|
59
|
+
|
60
|
+
var _useContext = useContext(ChipContext),
|
61
|
+
chipBg = _useContext.bg;
|
59
62
|
|
60
63
|
var _useHover = useHover(props),
|
61
64
|
hoverProps = _useHover.hoverProps,
|
@@ -80,8 +83,13 @@ var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
80
83
|
tabIndex: 0,
|
81
84
|
ref: buttonRef,
|
82
85
|
className: classNames,
|
83
|
-
"aria-label": ariaLabel
|
84
|
-
|
86
|
+
"aria-label": ariaLabel,
|
87
|
+
sx: chipBg && isHovered && {
|
88
|
+
'path': {
|
89
|
+
fill: chipBg
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}, mergeProps(hoverProps, focusProps, buttonProps, others)), children);
|
85
93
|
|
86
94
|
if (title) {
|
87
95
|
return ___EmotionJSX(TooltipTrigger, {
|
@@ -35,29 +35,23 @@ export default {
|
|
35
35
|
isDisabled: {},
|
36
36
|
variant: {
|
37
37
|
control: {
|
38
|
-
type: '
|
39
|
-
|
38
|
+
type: 'select',
|
39
|
+
options: ['iconButton', 'inverted', 'square', 'invertedSquare']
|
40
|
+
},
|
41
|
+
defaultValue: 'iconButton'
|
40
42
|
}
|
41
43
|
}
|
42
44
|
};
|
43
45
|
export var Default = function Default(args) {
|
44
46
|
return ___EmotionJSX(IconButton, _extends({
|
45
|
-
"aria-label": "
|
47
|
+
"aria-label": "default icon button"
|
46
48
|
}, args), ___EmotionJSX(Icon, {
|
47
49
|
icon: CreateIcon
|
48
50
|
}));
|
49
51
|
};
|
50
|
-
export var Inverted = function Inverted() {
|
51
|
-
return ___EmotionJSX(IconButton, {
|
52
|
-
"aria-label": "my-label",
|
53
|
-
variant: "inverted"
|
54
|
-
}, ___EmotionJSX(Icon, {
|
55
|
-
icon: CreateIcon
|
56
|
-
}));
|
57
|
-
};
|
58
52
|
export var WithTooltip = function WithTooltip() {
|
59
53
|
return ___EmotionJSX(IconButton, {
|
60
|
-
"aria-label": "
|
54
|
+
"aria-label": "icon button with tooltip",
|
61
55
|
title: "Edit"
|
62
56
|
}, ___EmotionJSX(Icon, {
|
63
57
|
icon: CreateIcon
|
@@ -65,7 +59,7 @@ export var WithTooltip = function WithTooltip() {
|
|
65
59
|
};
|
66
60
|
export var Disabled = function Disabled() {
|
67
61
|
return ___EmotionJSX(IconButton, {
|
68
|
-
"aria-label": "
|
62
|
+
"aria-label": "disabled icon button",
|
69
63
|
isDisabled: true
|
70
64
|
}, ___EmotionJSX(Icon, {
|
71
65
|
icon: CreateIcon
|
@@ -17,7 +17,8 @@ var Icon = function Icon(props) {
|
|
17
17
|
var testId = 'test-button';
|
18
18
|
var defaultProps = {
|
19
19
|
'data-testid': testId,
|
20
|
-
icon: Icon
|
20
|
+
icon: Icon,
|
21
|
+
'aria-label': 'Create'
|
21
22
|
};
|
22
23
|
|
23
24
|
var getComponent = function getComponent() {
|
@@ -32,7 +33,6 @@ test('default icon button', function () {
|
|
32
33
|
var button = screen.getByRole('button');
|
33
34
|
expect(button).toHaveAttribute('data-testid', testId);
|
34
35
|
expect(button).toBeInstanceOf(HTMLButtonElement);
|
35
|
-
expect(button).toHaveAttribute('tabindex', '0');
|
36
36
|
expect(button).toBeInTheDocument();
|
37
37
|
});
|
38
38
|
test('icon button hover', function () {
|
@@ -116,10 +116,8 @@ test('tooltip is not shown on hover or focus when prop is not passed', function
|
|
116
116
|
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
117
117
|
});
|
118
118
|
test('the button should be getting aria label attribute', function () {
|
119
|
-
var testLabel = '
|
120
|
-
getComponent(
|
121
|
-
'aria-label': testLabel
|
122
|
-
});
|
119
|
+
var testLabel = defaultProps['aria-label'];
|
120
|
+
getComponent();
|
123
121
|
expect(screen.getByLabelText(testLabel)).toBeInTheDocument();
|
124
122
|
});
|
125
123
|
test('show button isDisabled status', function () {
|
@@ -92,7 +92,8 @@ var ImagePreviewButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
92
92
|
ref: buttonRef,
|
93
93
|
variant: "imageUpload",
|
94
94
|
sx: widthHeightSx,
|
95
|
-
"data-testid": "image-preview-button"
|
95
|
+
"data-testid": "image-preview-button",
|
96
|
+
"aria-label": "Image preview"
|
96
97
|
}, mergeProps(focusProps, others)), previewImage && isImageType ? imagePreview : noImagePreview, isLoading && loadingPreview, (isHovered || isFocusVisible) && !isLoading && hoveredPreview));
|
97
98
|
});
|
98
99
|
ImagePreviewButton.propTypes = {
|
@@ -2,6 +2,7 @@ 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
4
|
import Box from '../Box/Box';
|
5
|
+
import { useDeprecationWarning } from '../../hooks';
|
5
6
|
/**
|
6
7
|
* The intended use of List is to hold a collection of <ListItem/> components.
|
7
8
|
* Accepts most of the styling props from [styled-system](https://styled-system.com/table).
|
@@ -12,6 +13,7 @@ var List = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
13
|
var children = props.children,
|
13
14
|
others = _objectWithoutProperties(props, ["children"]);
|
14
15
|
|
16
|
+
useDeprecationWarning('The List component will be deprecated in Astro-UI 2.0.0, use ListView instead.');
|
15
17
|
return ___EmotionJSX(Box, _extends({
|
16
18
|
ref: ref,
|
17
19
|
role: "list",
|
@@ -3,10 +3,14 @@ import List from '.';
|
|
3
3
|
import ListItem from '../ListItem';
|
4
4
|
import Text from '../Text';
|
5
5
|
import Separator from '../Separator';
|
6
|
+
import withDeprecationWarning from '../../utils/devUtils/decorators/withDeprecationWarning';
|
6
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
8
|
export default {
|
8
|
-
title: 'List',
|
9
|
-
component: [List, ListItem]
|
9
|
+
title: 'Deprecated/List',
|
10
|
+
component: [List, ListItem],
|
11
|
+
decorators: [function (Story, context) {
|
12
|
+
return withDeprecationWarning(Story, context, 'The `List` component will be deprecated in Astro-UI 2.0.0, use `ListView` instead.');
|
13
|
+
}]
|
10
14
|
};
|
11
15
|
export var Default = function Default() {
|
12
16
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
|
@@ -24,7 +24,6 @@ import { useCollator } from '@react-aria/i18n';
|
|
24
24
|
import { ListLayout } from '@react-stately/layout';
|
25
25
|
import { ListBoxContext } from './ListBoxContext';
|
26
26
|
import { Option } from './index.js';
|
27
|
-
import { useAriaLabelWarning } from '../../hooks';
|
28
27
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
29
28
|
import Loader from '../Loader';
|
30
29
|
import ListBoxSection from './ListBoxSection';
|
@@ -77,13 +76,12 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
77
76
|
selectedKeys = props.selectedKeys,
|
78
77
|
selectionMode = props.selectionMode,
|
79
78
|
state = props.state,
|
79
|
+
ariaLabel = props['aria-label'],
|
80
80
|
ariaLabelledby = props['aria-labelledby'],
|
81
81
|
ariaDescribedby = props['aria-describedby'],
|
82
82
|
ariaDetails = props['aria-details'],
|
83
|
-
others = _objectWithoutProperties(props, ["defaultSelectedKeys", "disabledKeys", "hasAutoFocus", "hasFocusWrap", "hasNoEmptySelection", "hasVirtualFocus", "id", "isLoading", "isFocusedOnHover", "isSelectedOnPressUp", "isVirtualized", "items", "keyboardDelegate", "label", "onLoadMore", "onScroll", "onSelectionChange", "renderEmptyState", "selectedKeys", "selectionMode", "state", "aria-labelledby", "aria-describedby", "aria-details"]);
|
83
|
+
others = _objectWithoutProperties(props, ["defaultSelectedKeys", "disabledKeys", "hasAutoFocus", "hasFocusWrap", "hasNoEmptySelection", "hasVirtualFocus", "id", "isLoading", "isFocusedOnHover", "isSelectedOnPressUp", "isVirtualized", "items", "keyboardDelegate", "label", "onLoadMore", "onScroll", "onSelectionChange", "renderEmptyState", "selectedKeys", "selectionMode", "state", "aria-label", "aria-labelledby", "aria-describedby", "aria-details"]);
|
84
84
|
|
85
|
-
var ariaLabel = props['aria-label'];
|
86
|
-
useAriaLabelWarning('ListBox', ariaLabel);
|
87
85
|
var focusStrategy = state.focusStrategy; // Object matching React Aria API with all options
|
88
86
|
|
89
87
|
var listBoxOptions = {
|
@@ -107,7 +105,7 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
107
105
|
shouldFocusWrap: hasFocusWrap,
|
108
106
|
shouldSelectOnPressUp: isSelectedOnPressUp,
|
109
107
|
shouldUseVirtualFocus: hasVirtualFocus,
|
110
|
-
'aria-label': ariaLabel
|
108
|
+
'aria-label': ariaLabel,
|
111
109
|
'aria-labelledby': ariaLabelledby,
|
112
110
|
'aria-describedby': ariaDescribedby,
|
113
111
|
'aria-details': ariaDetails
|
@@ -29,11 +29,13 @@ var itemsWithSections = [{
|
|
29
29
|
}];
|
30
30
|
var defaultProps = {
|
31
31
|
'data-testid': testId,
|
32
|
+
'aria-label': 'listbox',
|
32
33
|
'aria-labelledby': 'label',
|
33
34
|
items: items
|
34
35
|
};
|
35
36
|
var defaultWithSectionsProps = {
|
36
37
|
'data-testid': testId,
|
38
|
+
'aria-label': 'listbox',
|
37
39
|
'aria-labelledby': 'label',
|
38
40
|
items: itemsWithSections
|
39
41
|
};
|
@@ -63,7 +63,13 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
63
63
|
isSelected: isSelected
|
64
64
|
}),
|
65
65
|
classNames = _useStatusClasses.classNames;
|
66
|
+
/* Related to UIP-4992
|
67
|
+
* Need to remove these properties to avoid errors in the console on the external app.
|
68
|
+
* By the way, these properties return "undefined", so it shouldn't create issues */
|
66
69
|
|
70
|
+
|
71
|
+
delete optionProps.onPressStart;
|
72
|
+
delete optionProps.onPressUp;
|
67
73
|
return ___EmotionJSX(Box, _extends({
|
68
74
|
as: "li",
|
69
75
|
isRow: true,
|
@@ -32,7 +32,6 @@ export var Default = function Default(args) {
|
|
32
32
|
isRow: true,
|
33
33
|
alignSelf: "center"
|
34
34
|
}, ___EmotionJSX(IconButton, {
|
35
|
-
variant: "icon",
|
36
35
|
size: 26
|
37
36
|
}, ___EmotionJSX(Icon, {
|
38
37
|
icon: MoreVertIcon,
|
@@ -64,7 +63,6 @@ export var WithSubtitle = function WithSubtitle(args) {
|
|
64
63
|
isRow: true,
|
65
64
|
alignSelf: "center"
|
66
65
|
}, ___EmotionJSX(IconButton, {
|
67
|
-
variant: "icon",
|
68
66
|
size: 26
|
69
67
|
}, ___EmotionJSX(Icon, {
|
70
68
|
icon: MoreVertIcon,
|
@@ -37,18 +37,19 @@ export var collectionTypes = {
|
|
37
37
|
PLACEHOLDER: 'placeholder'
|
38
38
|
};
|
39
39
|
export function useListLayout(state) {
|
40
|
+
var ROW_HEIGHT = 81;
|
40
41
|
var collator = useCollator({
|
41
42
|
usage: 'search',
|
42
43
|
sensitivity: 'base'
|
43
44
|
});
|
44
45
|
var layout = useMemo(function () {
|
45
46
|
return new ListLayout({
|
46
|
-
estimatedRowHeight:
|
47
|
+
estimatedRowHeight: ROW_HEIGHT,
|
47
48
|
estimatedHeadingHeight: 26,
|
48
49
|
paddingRight: 4,
|
49
50
|
paddingLeft: 4,
|
50
|
-
loaderHeight:
|
51
|
-
placeholderHeight:
|
51
|
+
loaderHeight: ROW_HEIGHT,
|
52
|
+
placeholderHeight: ROW_HEIGHT,
|
52
53
|
collator: collator
|
53
54
|
});
|
54
55
|
}, [collator]);
|