@pingux/astro 1.2.0-alpha.6 → 1.2.1
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 +43 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +32 -25
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +148 -169
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +25 -30
- package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +29 -14
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +3 -3
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +16 -18
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/cjs/components/Button/Button.js +14 -2
- package/lib/cjs/components/Button/Button.stories.js +33 -33
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/cjs/components/Link/Link.js +2 -1
- package/lib/cjs/components/ListView/ListView.js +9 -13
- package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
- package/lib/cjs/components/Modal/Modal.stories.js +1 -1
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +2 -16
- package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +44 -0
- package/lib/cjs/components/RockerButton/RockerButton.js +14 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +4 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -14
- package/lib/cjs/components/SearchField/SearchField.stories.js +1 -15
- package/lib/cjs/components/TextAreaField/TextAreaField.js +54 -9
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +31 -52
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
- package/lib/cjs/context/AccordionGridContext/index.js +20 -0
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/hooks/useField/useField.js +5 -0
- package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/cjs/layouts/ListLayout.stories.js +6 -6
- package/lib/cjs/recipes/ArrayField.stories.js +1 -1
- package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/cjs/styles/variants/boxes.js +9 -0
- package/lib/cjs/styles/variants/buttons.js +20 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +32 -24
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +143 -166
- package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -25
- package/lib/components/AccordionGridItem/AccordionGridItem.js +29 -15
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -4
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +19 -20
- package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/components/Button/Button.js +15 -3
- package/lib/components/Button/Button.stories.js +17 -15
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/ListView/ListView.js +9 -12
- package/lib/components/ListViewItem/ListViewItem.js +14 -3
- package/lib/components/Modal/Modal.stories.js +1 -1
- package/lib/components/OverlayPanel/OverlayPanel.js +3 -16
- package/lib/components/OverlayPanel/OverlayPanel.test.js +38 -0
- package/lib/components/RockerButton/RockerButton.js +14 -21
- package/lib/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +2 -17
- package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -11
- package/lib/components/SearchField/SearchField.stories.js +0 -11
- package/lib/components/TextAreaField/TextAreaField.js +54 -10
- package/lib/components/TextAreaField/TextAreaField.stories.js +26 -42
- package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
- package/lib/context/AccordionGridContext/index.js +5 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/hooks/useField/useField.js +5 -0
- package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/layouts/ListLayout.stories.js +6 -6
- package/lib/recipes/ArrayField.stories.js +1 -1
- package/lib/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/styles/variants/boxes.js +9 -0
- package/lib/styles/variants/buttons.js +20 -0
- package/package.json +3 -3
- package/lib/cjs/components/AccordionGridGroup/AccordionGridContext.js +0 -17
- package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
@@ -3,14 +3,15 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
3
3
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
4
4
|
import _toArray from "@babel/runtime-corejs3/helpers/esm/toArray";
|
5
5
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, {
|
6
|
+
import React, { useEffect, useRef } from 'react';
|
7
7
|
import PropTypes from 'prop-types';
|
8
8
|
import { useGridRow } from '@react-aria/grid';
|
9
9
|
import { mergeProps } from '@react-aria/utils';
|
10
|
-
import {
|
10
|
+
import { useAccordionGridContext } from '../../context/AccordionGridContext';
|
11
11
|
import Box from '../Box';
|
12
12
|
import AccordionGridItemHeader from './AccordionGridItemHeader';
|
13
13
|
import AccordionGridItemBody from './AccordionGridItemBody';
|
14
|
+
import { useStatusClasses } from '../../hooks';
|
14
15
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
16
|
|
16
17
|
var AccordionGridItem = function AccordionGridItem(props) {
|
@@ -20,7 +21,8 @@ var AccordionGridItem = function AccordionGridItem(props) {
|
|
20
21
|
headerProps = props.headerProps,
|
21
22
|
bodyProps = props.bodyProps,
|
22
23
|
children = props.children,
|
23
|
-
|
24
|
+
className = props.className,
|
25
|
+
others = _objectWithoutProperties(props, ["item", "headerProps", "bodyProps", "children", "className"]);
|
24
26
|
|
25
27
|
var _React$Children$toArr = React.Children.toArray(children),
|
26
28
|
_React$Children$toArr2 = _toArray(_React$Children$toArr),
|
@@ -30,10 +32,18 @@ var AccordionGridItem = function AccordionGridItem(props) {
|
|
30
32
|
|
31
33
|
var cellNode = _concatInstanceProperty(_context = []).call(_context, item.childNodes)[0];
|
32
34
|
|
33
|
-
var
|
34
|
-
state =
|
35
|
+
var _useAccordionGridCont = useAccordionGridContext(),
|
36
|
+
state = _useAccordionGridCont.state; // Treat first cell as a row, fixes focus and keyboard interactions
|
35
37
|
|
36
|
-
|
38
|
+
|
39
|
+
var isDisabled = state.disabledKeys.has(cellNode.key);
|
40
|
+
var isSelected = state.selectionManager.isSelected(cellNode.key); // Sync selection between the first cell and the row
|
41
|
+
|
42
|
+
useEffect(function () {
|
43
|
+
if (isSelected !== state.selectionManager.isSelected(item.key)) {
|
44
|
+
state.selectionManager.toggleSelection(item.key);
|
45
|
+
}
|
46
|
+
}, [isSelected, state.selectionManager, item.key]);
|
37
47
|
var rowRef = useRef();
|
38
48
|
var cellRef = useRef();
|
39
49
|
var cellBodyRef = useRef();
|
@@ -43,20 +53,24 @@ var AccordionGridItem = function AccordionGridItem(props) {
|
|
43
53
|
}, state, rowRef),
|
44
54
|
rowProps = _useGridRow.rowProps;
|
45
55
|
|
46
|
-
var
|
47
|
-
|
48
|
-
as: "div",
|
56
|
+
var _useStatusClasses = useStatusClasses(className, {
|
57
|
+
isSelected: isSelected,
|
49
58
|
isDisabled: isDisabled
|
59
|
+
}),
|
60
|
+
classNames = _useStatusClasses.classNames;
|
61
|
+
|
62
|
+
return ___EmotionJSX(Box, _extends({
|
63
|
+
as: "div"
|
50
64
|
}, mergeProps(rowProps, others), {
|
51
|
-
|
52
|
-
|
65
|
+
"aria-selected": isSelected,
|
66
|
+
className: classNames,
|
67
|
+
ref: rowRef
|
53
68
|
}), ___EmotionJSX(AccordionGridItemHeader, _extends({
|
54
69
|
item: item,
|
55
|
-
|
56
|
-
|
57
|
-
}, headerProps, {
|
70
|
+
ref: cellRef,
|
71
|
+
isDisabled: isDisabled,
|
58
72
|
isSelected: isSelected
|
59
|
-
}), header), ___EmotionJSX(AccordionGridItemBody, _extends({
|
73
|
+
}, headerProps), header), ___EmotionJSX(AccordionGridItemBody, _extends({
|
60
74
|
item: item,
|
61
75
|
ref: cellBodyRef,
|
62
76
|
isSelected: isSelected
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
|
-
import React, {
|
3
|
+
import React, { forwardRef } from 'react';
|
4
4
|
import { mergeProps } from '@react-aria/utils';
|
5
5
|
import PropTypes from 'prop-types';
|
6
6
|
import { useGridCell } from '@react-aria/grid';
|
7
7
|
import { useHover } from '@react-aria/interactions';
|
8
|
-
import {
|
8
|
+
import { useAccordionGridContext } from '../../context/AccordionGridContext';
|
9
9
|
import Box from '../Box';
|
10
10
|
import { useStatusClasses } from '../../hooks';
|
11
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -17,8 +17,8 @@ var AccordionGridItemBody = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
17
17
|
children = props.children,
|
18
18
|
isSelected = props.isSelected;
|
19
19
|
|
20
|
-
var
|
21
|
-
state =
|
20
|
+
var _useAccordionGridCont = useAccordionGridContext(),
|
21
|
+
state = _useAccordionGridCont.state;
|
22
22
|
|
23
23
|
var cellNode = _concatInstanceProperty(_context = []).call(_context, item.childNodes)[1];
|
24
24
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
4
|
-
import React, {
|
4
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
5
5
|
import { mergeProps } from '@react-aria/utils';
|
6
6
|
import { useFocusRing } from '@react-aria/focus';
|
7
7
|
import PropTypes from 'prop-types';
|
8
8
|
import { useGridCell } from '@react-aria/grid';
|
9
|
-
import { useHover
|
9
|
+
import { useHover } from '@react-aria/interactions';
|
10
10
|
import MenuDown from 'mdi-react/MenuDownIcon';
|
11
11
|
import MenuUp from 'mdi-react/MenuUpIcon';
|
12
|
-
import {
|
12
|
+
import { useAccordionGridContext } from '../../context/AccordionGridContext';
|
13
13
|
import Box from '../Box';
|
14
14
|
import Icon from '../Icon';
|
15
15
|
import { useStatusClasses } from '../../hooks';
|
@@ -20,20 +20,27 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
20
20
|
var item = props.item,
|
21
21
|
className = props.className,
|
22
22
|
children = props.children,
|
23
|
-
key = props.key,
|
24
23
|
isSelected = props.isSelected,
|
25
|
-
others = _objectWithoutProperties(props, ["item", "className", "children", "
|
24
|
+
others = _objectWithoutProperties(props, ["item", "className", "children", "isSelected"]);
|
26
25
|
|
27
|
-
var
|
28
|
-
state =
|
26
|
+
var _useAccordionGridCont = useAccordionGridContext(),
|
27
|
+
state = _useAccordionGridCont.state;
|
28
|
+
|
29
|
+
var cellRef = useRef();
|
30
|
+
/* istanbul ignore next */
|
31
|
+
|
32
|
+
useImperativeHandle(ref, function () {
|
33
|
+
return cellRef.current;
|
34
|
+
});
|
29
35
|
|
30
36
|
var cellNode = _concatInstanceProperty(_context = []).call(_context, item.childNodes)[0];
|
31
37
|
|
32
38
|
var _useGridCell = useGridCell({
|
33
39
|
node: cellNode,
|
34
40
|
focusMode: 'cell'
|
35
|
-
}, state,
|
36
|
-
gridCellProps = _useGridCell.gridCellProps
|
41
|
+
}, state, cellRef),
|
42
|
+
gridCellProps = _useGridCell.gridCellProps,
|
43
|
+
isPressed = _useGridCell.isPressed;
|
37
44
|
|
38
45
|
var _useHover = useHover({}),
|
39
46
|
hoverProps = _useHover.hoverProps,
|
@@ -48,14 +55,7 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
48
55
|
focusProps = _useFocusRing2.focusProps,
|
49
56
|
isFocusVisible = _useFocusRing2.isFocusVisible;
|
50
57
|
|
51
|
-
var
|
52
|
-
ref: ref,
|
53
|
-
isPressed: item.props.isPressed
|
54
|
-
}),
|
55
|
-
pressProps = _usePress.pressProps,
|
56
|
-
isPressed = _usePress.isPressed;
|
57
|
-
|
58
|
-
var mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps, pressProps);
|
58
|
+
var mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps);
|
59
59
|
|
60
60
|
var _useStatusClasses = useStatusClasses(className, {
|
61
61
|
isPressed: isPressed,
|
@@ -68,9 +68,8 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
68
68
|
var ariaLabel = props['aria-label'];
|
69
69
|
return ___EmotionJSX(Box, _extends({
|
70
70
|
as: "div",
|
71
|
-
ref:
|
71
|
+
ref: cellRef
|
72
72
|
}, mergedProps, {
|
73
|
-
role: "gridcell",
|
74
73
|
variant: "accordion.accordionGridHeader",
|
75
74
|
isFocused: isFocusVisible,
|
76
75
|
isSelected: isSelected,
|
@@ -93,8 +92,8 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
93
92
|
AccordionGridItemHeader.propTypes = {
|
94
93
|
'aria-label': PropTypes.string,
|
95
94
|
isSelected: PropTypes.bool,
|
96
|
-
key: PropTypes.string,
|
97
95
|
item: PropTypes.shape({
|
96
|
+
key: PropTypes.string,
|
98
97
|
childNodes: PropTypes.arrayOf(PropTypes.shape({})),
|
99
98
|
props: PropTypes.shape({
|
100
99
|
isPressed: PropTypes.bool
|
@@ -32,8 +32,9 @@ var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
32
32
|
|
33
33
|
var _useAccordion = useAccordion(props, state, accordionRef),
|
34
34
|
accordionProps = _useAccordion.accordionProps;
|
35
|
-
/* istanbul ignore next */
|
36
35
|
|
36
|
+
delete accordionProps.onMouseDown;
|
37
|
+
/* istanbul ignore next */
|
37
38
|
|
38
39
|
useImperativeHandle(ref, function () {
|
39
40
|
return accordionRef.current;
|
@@ -7,7 +7,7 @@ import axeTest from '../../utils/testUtils/testAxe';
|
|
7
7
|
import { act, fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
8
8
|
import Text from '../Text';
|
9
9
|
import AccordionGroup from '../AccordionGroup';
|
10
|
-
import { OverlayPanel } from '../../index';
|
10
|
+
import { OverlayPanel, TextField } from '../../index';
|
11
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
12
|
var testId = 'test-accordion';
|
13
13
|
var defaultProps = {
|
@@ -31,7 +31,11 @@ var getComponent = function getComponent() {
|
|
31
31
|
textValue: "Duplicate",
|
32
32
|
"data-id": "third",
|
33
33
|
label: "Accordion item"
|
34
|
-
}, ___EmotionJSX(
|
34
|
+
}, ___EmotionJSX(TextField, {
|
35
|
+
role: "form",
|
36
|
+
label: "Example Label",
|
37
|
+
"data-testid": "testField"
|
38
|
+
}))));
|
35
39
|
};
|
36
40
|
|
37
41
|
var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
|
@@ -214,6 +218,16 @@ test('expanded keys expands an accordion item', function () {
|
|
214
218
|
var selectedItem = buttons[0];
|
215
219
|
expect(selectedItem).toHaveAttribute('aria-expanded', 'true');
|
216
220
|
});
|
221
|
+
test('able to click a textfield that is the rendered child of an accordion', function () {
|
222
|
+
getComponent({
|
223
|
+
expandedKeys: ['third']
|
224
|
+
});
|
225
|
+
var field = screen.getByTestId('testField');
|
226
|
+
var input = screen.getByRole('form');
|
227
|
+
userEvent.click(input);
|
228
|
+
userEvent.type(input, 'banana');
|
229
|
+
expect(field).toHaveClass('has-focus-within');
|
230
|
+
});
|
217
231
|
test('Item accepts a data-id and the data-id can be found in the DOM', function () {
|
218
232
|
getComponent();
|
219
233
|
var buttons = screen.getAllByRole('button');
|
@@ -41,15 +41,15 @@ export var Default = function Default(args) {
|
|
41
41
|
onAction: onAction
|
42
42
|
}, args), ___EmotionJSX(Item, {
|
43
43
|
key: "home",
|
44
|
-
variant: "
|
44
|
+
variant: "link",
|
45
45
|
"data-id": "home"
|
46
46
|
}, "Home"), ___EmotionJSX(Item, {
|
47
47
|
key: "trendy",
|
48
|
-
variant: "
|
48
|
+
variant: "link",
|
49
49
|
"data-id": "trendy"
|
50
50
|
}, "Trendy"), ___EmotionJSX(Item, {
|
51
51
|
key: "march 2020 assets",
|
52
|
-
variant: "
|
52
|
+
variant: "link",
|
53
53
|
"data-id": "march"
|
54
54
|
}, "March 2020 Assets"));
|
55
55
|
};
|
@@ -21,7 +21,7 @@ import { useButton } from '@react-aria/button';
|
|
21
21
|
import { useHover } from '@react-aria/interactions';
|
22
22
|
import { useFocusRing } from '@react-aria/focus';
|
23
23
|
import { mergeProps } from '@react-aria/utils';
|
24
|
-
import { useStatusClasses, usePropWarning } from '../../hooks';
|
24
|
+
import { useStatusClasses, usePropWarning, useAriaLabelWarning, useDeprecationWarning } from '../../hooks';
|
25
25
|
import Loader from '../Loader';
|
26
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
27
|
var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -37,7 +37,8 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
37
37
|
onPressChange = props.onPressChange,
|
38
38
|
onPressUp = props.onPressUp,
|
39
39
|
children = props.children,
|
40
|
-
|
40
|
+
variant = props.variant,
|
41
|
+
others = _objectWithoutProperties(props, ["className", "isDisabled", "isLoading", "onHoverStart", "onHoverChange", "onHoverEnd", "onPress", "onPressStart", "onPressEnd", "onPressChange", "onPressUp", "children", "variant"]);
|
41
42
|
|
42
43
|
var buttonRef = useRef();
|
43
44
|
usePropWarning(props, 'disabled', 'isDisabled');
|
@@ -69,7 +70,17 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
69
70
|
}),
|
70
71
|
classNames = _useStatusClasses.classNames;
|
71
72
|
|
73
|
+
useDeprecationWarning('The "icon" variant for `Button` is deprecated in Astro-UI 1.0.0, use the `IconButton` component instead.', {
|
74
|
+
isActive: props.variant === 'icon'
|
75
|
+
});
|
76
|
+
useDeprecationWarning('The "danger" variant for `Button` will be deprecated in Astro-UI 2.0.0, use the `critical` variant instead.', {
|
77
|
+
isActive: props.variant === 'danger'
|
78
|
+
});
|
79
|
+
useDeprecationWarning('The "text" variant for `Button` will be deprecated in Astro-UI 2.0.0, use the `link` variant instead.', {
|
80
|
+
isActive: props.variant === 'text'
|
81
|
+
});
|
72
82
|
var ariaLabel = props['aria-label'];
|
83
|
+
useAriaLabelWarning('Button', ariaLabel, variant === 'filter');
|
73
84
|
return ___EmotionJSX(ThemeUIButton, _extends({
|
74
85
|
"aria-label": ariaLabel,
|
75
86
|
ref: buttonRef,
|
@@ -80,7 +91,8 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
80
91
|
display: 'flex',
|
81
92
|
justifyContent: 'center',
|
82
93
|
alignItems: 'center'
|
83
|
-
}
|
94
|
+
},
|
95
|
+
variant: variant
|
84
96
|
}, others, mergeProps(hoverProps, focusProps, buttonProps)), isLoading ? ___EmotionJSX("span", {
|
85
97
|
style: {
|
86
98
|
visibility: 'hidden'
|
@@ -3,11 +3,9 @@ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectW
|
|
3
3
|
import React from 'react';
|
4
4
|
import AddCircleIcon from 'mdi-react/AddCircleIcon';
|
5
5
|
import CreateIcon from 'mdi-react/CreateIcon';
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import Icon from '
|
9
|
-
import Text from '../Text';
|
10
|
-
import { buttonVariants } from '../../utils/devUtils/constants/variants'; // removing the iconButton variants from this story.
|
6
|
+
import FilterIcon from 'mdi-react/FilterIcon';
|
7
|
+
import { buttonVariants } from '../../utils/devUtils/constants/variants';
|
8
|
+
import { Box, Button, Icon, SearchField, Text } from '../../index'; // removing the iconButton variants from this story.
|
11
9
|
|
12
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
11
|
var variants = buttonVariants;
|
@@ -69,16 +67,6 @@ export var TextIconButton = function TextIconButton() {
|
|
69
67
|
size: 20
|
70
68
|
}), "Add a Form"));
|
71
69
|
};
|
72
|
-
export var TextButton = function TextButton() {
|
73
|
-
return ___EmotionJSX(Button, {
|
74
|
-
mb: "sm",
|
75
|
-
variant: "text",
|
76
|
-
"aria-label": "Add option"
|
77
|
-
}, ___EmotionJSX(Text, {
|
78
|
-
variant: "label",
|
79
|
-
color: "active"
|
80
|
-
}, " + Add Option"));
|
81
|
-
};
|
82
70
|
export var InlineButton = function InlineButton() {
|
83
71
|
return ___EmotionJSX(Button, {
|
84
72
|
mb: "sm",
|
@@ -110,4 +98,18 @@ ColorBlockButton.story = {
|
|
110
98
|
defaultValue: false
|
111
99
|
}
|
112
100
|
}
|
101
|
+
};
|
102
|
+
export var FilterButton = function FilterButton() {
|
103
|
+
return ___EmotionJSX(Box, {
|
104
|
+
p: "xx",
|
105
|
+
isRow: true,
|
106
|
+
gap: "md"
|
107
|
+
}, ___EmotionJSX(SearchField, {
|
108
|
+
"aria-label": "search items"
|
109
|
+
}), ___EmotionJSX(Button, {
|
110
|
+
variant: "filter",
|
111
|
+
"aria-label": "filter button"
|
112
|
+
}, ___EmotionJSX(Icon, {
|
113
|
+
icon: FilterIcon
|
114
|
+
})));
|
113
115
|
};
|
@@ -271,9 +271,11 @@ EnvironmentBreadcrumb.propTypes = {
|
|
271
271
|
/** The list of environments. */
|
272
272
|
items: isIterableProp,
|
273
273
|
|
274
|
-
/**
|
275
|
-
*
|
276
|
-
*
|
274
|
+
/**
|
275
|
+
* Filter function to generate a filtered list of nodes.
|
276
|
+
*
|
277
|
+
* `(nodes: Iterable<Node>) => Iterable<Node>`
|
278
|
+
*/
|
277
279
|
itemsFilter: PropTypes.func,
|
278
280
|
|
279
281
|
/** Callback function that fires when the dropdown is opened. */
|
@@ -12,7 +12,8 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
12
12
|
var Link = /*#__PURE__*/forwardRef(function (props, ref) {
|
13
13
|
var className = props.className,
|
14
14
|
isDisabled = props.isDisabled,
|
15
|
-
|
15
|
+
onPress = props.onPress,
|
16
|
+
others = _objectWithoutProperties(props, ["className", "isDisabled", "onPress"]);
|
16
17
|
|
17
18
|
var linkRef = useRef();
|
18
19
|
usePropWarning(props, 'disabled', 'isDisabled');
|
@@ -19,7 +19,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
19
19
|
import React, { useMemo, forwardRef, useRef, useImperativeHandle } from 'react';
|
20
20
|
import { GridCollection, useGridState } from '@react-stately/grid';
|
21
21
|
import { GridKeyboardDelegate, useGrid } from '@react-aria/grid';
|
22
|
-
import { mergeProps } from '@react-aria/utils';
|
23
22
|
import { ListLayout } from '@react-stately/layout';
|
24
23
|
import { useListState } from '@react-stately/list';
|
25
24
|
import PropTypes from 'prop-types';
|
@@ -58,12 +57,9 @@ export function useListLayout(state) {
|
|
58
57
|
return layout;
|
59
58
|
}
|
60
59
|
var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
61
|
-
var
|
62
|
-
loadingState = props.loadingState,
|
63
|
-
selectedKeys = props.selectedKeys,
|
60
|
+
var loadingState = props.loadingState,
|
64
61
|
onLoadMore = props.onLoadMore,
|
65
|
-
|
66
|
-
selectionMode = props.selectionMode;
|
62
|
+
selectionStyle = props.selectionStyle;
|
67
63
|
var isLoading = loadingState === loadingStates.LOADING_MORE || loadingState === loadingStates.LOADING;
|
68
64
|
|
69
65
|
var renderWrapper = function renderWrapper(parent, reusableView) {
|
@@ -115,11 +111,9 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
115
111
|
});
|
116
112
|
}, [collection]);
|
117
113
|
var state = useGridState(_objectSpread(_objectSpread({}, props), {}, {
|
118
|
-
disabledKeys: disabledKeys,
|
119
|
-
selectedKeys: selectedKeys,
|
120
114
|
collection: gridCollection,
|
121
|
-
|
122
|
-
|
115
|
+
focusMode: 'cell',
|
116
|
+
selectionBehavior: selectionStyle === 'highlight' ? 'replace' : 'toggle'
|
123
117
|
}));
|
124
118
|
var layout = useListLayout(state);
|
125
119
|
var keyboardDelegate = useMemo(function () {
|
@@ -154,7 +148,7 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
154
148
|
state: state,
|
155
149
|
keyboardDelegate: keyboardDelegate
|
156
150
|
}
|
157
|
-
}, ___EmotionJSX(Virtualizer, _extends({},
|
151
|
+
}, ___EmotionJSX(Virtualizer, _extends({}, gridProps, {
|
158
152
|
onLoadMore: onLoadMore,
|
159
153
|
ref: listViewRef,
|
160
154
|
focusedKey: focusedKey,
|
@@ -221,6 +215,9 @@ ListView.propTypes = {
|
|
221
215
|
/** The type of selection that is allowed in the collection. */
|
222
216
|
selectionMode: PropTypes.oneOf(['none', 'single', 'multiple']),
|
223
217
|
|
218
|
+
/** */
|
219
|
+
selectionStyle: PropTypes.oneOf(['highlight', undefined]),
|
220
|
+
|
224
221
|
/** Callback function that fires when the selected key changes. */
|
225
222
|
onSelectionChange: PropTypes.func,
|
226
223
|
|
@@ -233,6 +230,6 @@ ListView.propTypes = {
|
|
233
230
|
};
|
234
231
|
ListView.defaultProps = {
|
235
232
|
'aria-label': 'listView',
|
236
|
-
|
233
|
+
selectionMode: 'single'
|
237
234
|
};
|
238
235
|
export default ListView;
|
@@ -6,6 +6,7 @@ import { useFocusRing } from '@react-aria/focus';
|
|
6
6
|
import PropTypes from 'prop-types';
|
7
7
|
import { useGridCell, useGridRow } from '@react-aria/grid';
|
8
8
|
import { useHover } from '@react-aria/interactions';
|
9
|
+
import { useSelectableItem } from '@react-aria/selection';
|
9
10
|
import { ListViewContext } from '../ListView/ListViewContext';
|
10
11
|
import Box from '../Box';
|
11
12
|
import { useStatusClasses } from '../../hooks';
|
@@ -15,7 +16,9 @@ var ListViewItem = function ListViewItem(props) {
|
|
15
16
|
var _context;
|
16
17
|
|
17
18
|
var item = props.item,
|
18
|
-
_props$item
|
19
|
+
_props$item = props.item,
|
20
|
+
key = _props$item.key,
|
21
|
+
_props$item$props = _props$item.props,
|
19
22
|
listItemProps = _props$item$props.listItemProps,
|
20
23
|
rowProps = _props$item$props.rowProps,
|
21
24
|
_props$item$props$has = _props$item$props.hasSeparator,
|
@@ -51,7 +54,7 @@ var ListViewItem = function ListViewItem(props) {
|
|
51
54
|
}, state, rowRef),
|
52
55
|
raRowProps = _useGridRow.rowProps;
|
53
56
|
|
54
|
-
var isSelected =
|
57
|
+
var isSelected = state.selectionManager.isSelected(item.key);
|
55
58
|
|
56
59
|
var _useGridCell = useGridCell({
|
57
60
|
node: cellNode,
|
@@ -59,7 +62,15 @@ var ListViewItem = function ListViewItem(props) {
|
|
59
62
|
}, state, cellRef),
|
60
63
|
gridCellProps = _useGridCell.gridCellProps;
|
61
64
|
|
62
|
-
var
|
65
|
+
var _useSelectableItem = useSelectableItem({
|
66
|
+
isDisabled: isDisabled,
|
67
|
+
selectionManager: state.selectionManager,
|
68
|
+
key: key,
|
69
|
+
ref: cellRef
|
70
|
+
}),
|
71
|
+
selectableItemProps = _useSelectableItem.itemProps;
|
72
|
+
|
73
|
+
var mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps, selectableItemProps);
|
63
74
|
|
64
75
|
var _useStatusClasses = useStatusClasses(className, {
|
65
76
|
isHovered: isHovered,
|
@@ -138,7 +138,7 @@ export var DarkVariant = function DarkVariant() {
|
|
138
138
|
onPress: state.close,
|
139
139
|
"aria-label": "Yes"
|
140
140
|
}, "Yes"), ___EmotionJSX(Button, {
|
141
|
-
variant: "
|
141
|
+
variant: "link",
|
142
142
|
onPress: state.close,
|
143
143
|
"aria-label": "Cancel"
|
144
144
|
}, "Cancel"))))
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
4
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
5
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, { forwardRef, useRef, useImperativeHandle
|
5
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
7
6
|
import PropTypes from 'prop-types';
|
8
7
|
import { FocusScope } from '@react-aria/focus';
|
9
8
|
import Box from '../Box';
|
@@ -26,14 +25,8 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
25
|
onClose = _useOverlayPanelState.onClose;
|
27
26
|
|
28
27
|
var overlayPanelRef = useRef();
|
29
|
-
|
30
|
-
var _useState = useState(true),
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
contain = _useState2[0],
|
33
|
-
setIsContained = _useState2[1];
|
34
28
|
/* istanbul ignore next */
|
35
29
|
|
36
|
-
|
37
30
|
useImperativeHandle(ref, function () {
|
38
31
|
return overlayPanelRef.current;
|
39
32
|
});
|
@@ -47,18 +40,12 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
47
40
|
e.stopPropagation();
|
48
41
|
|
49
42
|
if (e.key === 'Escape') {
|
50
|
-
|
43
|
+
onClose(state, triggerRef, onCloseProp);
|
51
44
|
}
|
52
45
|
};
|
53
46
|
|
54
|
-
useEffect(function () {
|
55
|
-
if (!contain && onClose) {
|
56
|
-
onClose(state, triggerRef, onCloseProp);
|
57
|
-
}
|
58
|
-
}, [contain]);
|
59
47
|
return ___EmotionJSX(FocusScope, {
|
60
|
-
autoFocus: true
|
61
|
-
contain: contain
|
48
|
+
autoFocus: true
|
62
49
|
}, ___EmotionJSX(Box, _extends({
|
63
50
|
variant: "overlayPanel.overlayPanel",
|
64
51
|
ref: overlayPanelRef
|
@@ -60,6 +60,13 @@ test('onClose callback fires when provided', function () {
|
|
60
60
|
});
|
61
61
|
expect(onClose).toHaveBeenCalled();
|
62
62
|
});
|
63
|
+
test('custom classname can be passed', function () {
|
64
|
+
getComponent({
|
65
|
+
className: 'testing-class'
|
66
|
+
});
|
67
|
+
var overlayPanel = screen.getByTestId(testId);
|
68
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
69
|
+
});
|
63
70
|
test('neither callback fires when not provided', function () {
|
64
71
|
var onClose = jest.fn();
|
65
72
|
getComponent({
|
@@ -110,4 +117,35 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
110
117
|
charCode: 27
|
111
118
|
});
|
112
119
|
expect(focusFunction).toHaveBeenCalled();
|
120
|
+
});
|
121
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
122
|
+
var onClose = jest.fn();
|
123
|
+
var focusFunction = jest.fn();
|
124
|
+
var state = {
|
125
|
+
close: onClose
|
126
|
+
};
|
127
|
+
var triggerRef = {
|
128
|
+
current: {
|
129
|
+
focus: focusFunction
|
130
|
+
}
|
131
|
+
};
|
132
|
+
getComponent({
|
133
|
+
state: state,
|
134
|
+
children: ___EmotionJSX("div", null, "Test"),
|
135
|
+
triggerRef: triggerRef
|
136
|
+
});
|
137
|
+
var overlayPanel = screen.getByTestId(testId);
|
138
|
+
fireEvent.keyDown(overlayPanel, {
|
139
|
+
key: 'KeyA',
|
140
|
+
code: 'KeyA',
|
141
|
+
keyCode: 65,
|
142
|
+
charCode: 65
|
143
|
+
});
|
144
|
+
fireEvent.keyUp(overlayPanel, {
|
145
|
+
key: 'KeyA',
|
146
|
+
code: 'KeyA',
|
147
|
+
keyCode: 65,
|
148
|
+
charCode: 65
|
149
|
+
});
|
150
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
113
151
|
});
|