@pingux/astro 1.2.0-alpha.9 → 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.
Files changed (72) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +32 -25
  3. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +148 -169
  4. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +25 -30
  5. package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +29 -14
  6. package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +3 -3
  7. package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +16 -18
  8. package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
  9. package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
  10. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
  11. package/lib/cjs/components/Button/Button.js +14 -2
  12. package/lib/cjs/components/Button/Button.stories.js +33 -33
  13. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
  14. package/lib/cjs/components/Link/Link.js +2 -1
  15. package/lib/cjs/components/ListView/ListView.js +9 -13
  16. package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
  17. package/lib/cjs/components/Modal/Modal.stories.js +1 -1
  18. package/lib/cjs/components/RockerButton/RockerButton.js +14 -22
  19. package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
  20. package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +4 -22
  21. package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -14
  22. package/lib/cjs/components/SearchField/SearchField.stories.js +1 -15
  23. package/lib/cjs/components/TextAreaField/TextAreaField.js +54 -9
  24. package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +31 -52
  25. package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
  26. package/lib/cjs/context/AccordionGridContext/index.js +20 -0
  27. package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
  28. package/lib/cjs/hooks/useField/useField.js +5 -0
  29. package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
  30. package/lib/cjs/layouts/ListLayout.stories.js +6 -6
  31. package/lib/cjs/recipes/ArrayField.stories.js +1 -1
  32. package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
  33. package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
  34. package/lib/cjs/styles/variants/boxes.js +9 -0
  35. package/lib/cjs/styles/variants/buttons.js +20 -0
  36. package/lib/components/AccordionGridGroup/AccordionGridGroup.js +32 -24
  37. package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +143 -166
  38. package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -25
  39. package/lib/components/AccordionGridItem/AccordionGridItem.js +29 -15
  40. package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -4
  41. package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +19 -20
  42. package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
  43. package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
  44. package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
  45. package/lib/components/Button/Button.js +15 -3
  46. package/lib/components/Button/Button.stories.js +17 -15
  47. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
  48. package/lib/components/Link/Link.js +2 -1
  49. package/lib/components/ListView/ListView.js +9 -12
  50. package/lib/components/ListViewItem/ListViewItem.js +14 -3
  51. package/lib/components/Modal/Modal.stories.js +1 -1
  52. package/lib/components/RockerButton/RockerButton.js +14 -21
  53. package/lib/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
  54. package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +2 -17
  55. package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -11
  56. package/lib/components/SearchField/SearchField.stories.js +0 -11
  57. package/lib/components/TextAreaField/TextAreaField.js +54 -10
  58. package/lib/components/TextAreaField/TextAreaField.stories.js +26 -42
  59. package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
  60. package/lib/context/AccordionGridContext/index.js +5 -0
  61. package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
  62. package/lib/hooks/useField/useField.js +5 -0
  63. package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
  64. package/lib/layouts/ListLayout.stories.js +6 -6
  65. package/lib/recipes/ArrayField.stories.js +1 -1
  66. package/lib/recipes/ConditionalFilter.stories.js +7 -3
  67. package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
  68. package/lib/styles/variants/boxes.js +9 -0
  69. package/lib/styles/variants/buttons.js +20 -0
  70. package/package.json +2 -2
  71. package/lib/cjs/components/AccordionGridGroup/AccordionGridContext.js +0 -17
  72. package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
@@ -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, { useContext, forwardRef } from '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 { AccordionGridContext } from '../AccordionGridGroup/AccordionGridContext';
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 _useContext = useContext(AccordionGridContext),
21
- state = _useContext.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, { useContext, forwardRef } from '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, usePress } from '@react-aria/interactions';
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 { AccordionGridContext } from '../AccordionGridGroup/AccordionGridContext';
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", "key", "isSelected"]);
24
+ others = _objectWithoutProperties(props, ["item", "className", "children", "isSelected"]);
26
25
 
27
- var _useContext = useContext(AccordionGridContext),
28
- state = _useContext.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, ref),
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 _usePress = usePress({
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: 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(Text, null, "Render me!"))));
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: "text",
44
+ variant: "link",
45
45
  "data-id": "home"
46
46
  }, "Home"), ___EmotionJSX(Item, {
47
47
  key: "trendy",
48
- variant: "text",
48
+ variant: "link",
49
49
  "data-id": "trendy"
50
50
  }, "Trendy"), ___EmotionJSX(Item, {
51
51
  key: "march 2020 assets",
52
- variant: "text",
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
- others = _objectWithoutProperties(props, ["className", "isDisabled", "isLoading", "onHoverStart", "onHoverChange", "onHoverEnd", "onPress", "onPressStart", "onPressEnd", "onPressChange", "onPressUp", "children"]);
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 Box from '../Box';
7
- import Button from '.';
8
- import Icon from '../Icon';
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
- /** Filter function to generate a filtered list of nodes.
275
- * (nodes: Iterable<Node>) => Iterable<Node>
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
- others = _objectWithoutProperties(props, ["className", "isDisabled"]);
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 disabledKeys = props.disabledKeys,
62
- loadingState = props.loadingState,
63
- selectedKeys = props.selectedKeys,
60
+ var loadingState = props.loadingState,
64
61
  onLoadMore = props.onLoadMore,
65
- onSelectionChange = props.onSelectionChange,
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
- selectionMode: selectionMode,
122
- onSelectionChange: onSelectionChange
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({}, mergeProps(gridProps), {
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
- 'selectionMode': 'single'
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$props = props.item.props,
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 = raRowProps['aria-selected'];
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 mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps);
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: "text",
141
+ variant: "link",
142
142
  onPress: state.close,
143
143
  "aria-label": "Cancel"
144
144
  }, "Cancel"))))
@@ -17,26 +17,18 @@ import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'reac
17
17
  import PropTypes from 'prop-types';
18
18
  import { Item } from '@react-stately/collections';
19
19
  import { useFocusRing } from '@react-aria/focus';
20
- import { mergeProps } from '@react-aria/utils';
21
20
  import { useRockerButton, useStatusClasses, usePropWarning } from '../../hooks';
22
- import Button from '../Button';
21
+ import { Box } from '../../index';
23
22
  import { RockerContext } from '../RockerButtonGroup';
24
23
  import { jsx as ___EmotionJSX } from "@emotion/react";
25
24
  export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref) {
26
25
  var className = props.className,
27
- item = props.item,
28
- buttonGroupDisabled = props.isDisabled;
29
- var defaultSelectedStyles = {
30
- bg: 'active'
31
- };
26
+ item = props.item;
32
27
  var key = item.key,
33
28
  rendered = item.rendered,
34
29
  itemProps = item.props;
35
- var _itemProps$selectedSt = itemProps.selectedStyles,
36
- selectedStyles = _itemProps$selectedSt === void 0 ? defaultSelectedStyles : _itemProps$selectedSt,
37
- rockerButtonDisabled = itemProps.isDisabled;
38
- var isDisabled = buttonGroupDisabled || rockerButtonDisabled;
39
30
  var state = useContext(RockerContext);
31
+ var isDisabled = state.disabledKeys.has(key);
40
32
 
41
33
  var _useFocusRing = useFocusRing(),
42
34
  isFocusVisible = _useFocusRing.isFocusVisible,
@@ -46,7 +38,8 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
46
38
 
47
39
  var _useStatusClasses = useStatusClasses(className, {
48
40
  isFocused: isFocusVisible,
49
- isSelected: isSelected
41
+ isSelected: isSelected,
42
+ isDisabled: isDisabled
50
43
  }),
51
44
  classNames = _useStatusClasses.classNames;
52
45
 
@@ -60,25 +53,25 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
60
53
 
61
54
  var _useRockerButton = useRockerButton({
62
55
  item: item,
63
- isDisabled: isDisabled
56
+ isDisabled: isDisabled,
57
+ isSelected: isSelected
64
58
  }, state, rockerButtonRef),
65
59
  rockerButtonProps = _useRockerButton.rockerButtonProps;
66
60
 
67
- return ___EmotionJSX(Button, _extends({
61
+ return ___EmotionJSX(Box, _extends({
62
+ as: "button",
68
63
  className: classNames,
69
- variant: "rocker"
70
- }, itemProps, mergeProps(focusProps, rockerButtonProps), {
71
- ref: rockerButtonRef,
64
+ variant: "buttons.rocker"
65
+ }, rockerButtonProps, {
66
+ ref: rockerButtonRef
67
+ }, focusProps, itemProps, {
72
68
  sx: {
73
- '&.is-selected': _objectSpread({}, selectedStyles)
69
+ '&.is-selected': _objectSpread({}, itemProps.selectedStyles)
74
70
  }
75
71
  }), rendered);
76
72
  });
77
73
  CollectionRockerButton.displayName = 'CollectionRockerButton';
78
74
  CollectionRockerButton.propTypes = {
79
- /** Whether the button is disabled. */
80
- isDisabled: PropTypes.bool,
81
-
82
75
  /** Allows custom styles to be passed to button. */
83
76
  selectedStyles: PropTypes.shape({}),
84
77
  // adding to surface in props table
@@ -34,10 +34,10 @@ var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
34
34
  var _context;
35
35
 
36
36
  var children = props.children,
37
- isDisabled = props.isDisabled,
38
37
  onSelectionChange = props.onSelectionChange,
39
38
  tabListProps = props.tabListProps,
40
- others = _objectWithoutProperties(props, ["children", "isDisabled", "onSelectionChange", "tabListProps"]);
39
+ disabledKeys = props.disabledKeys,
40
+ others = _objectWithoutProperties(props, ["children", "onSelectionChange", "tabListProps", "disabledKeys"]);
41
41
 
42
42
  var buttonGroupRef = useRef();
43
43
  usePropWarning(props, 'disabled', 'isDisabled');
@@ -67,8 +67,7 @@ var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
67
67
  }), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
68
68
  return ___EmotionJSX(CollectionRockerButton, {
69
69
  key: item.key,
70
- item: item,
71
- isDisabled: isDisabled
70
+ item: item
72
71
  });
73
72
  }))));
74
73
  });
@@ -79,14 +78,11 @@ RockerButtonGroup.propTypes = {
79
78
  /** The button key that is currently selected. (controlled) */
80
79
  selectedKey: PropTypes.string,
81
80
 
82
- /** Whether the entire button group is disabled. */
83
- isDisabled: PropTypes.bool,
81
+ /** Which keys should be disabled. */
82
+ disabledKeys: PropTypes.arrayOf(PropTypes.string),
84
83
 
85
84
  /** Handler that is called when the selected button has changed. */
86
85
  onSelectionChange: PropTypes.func
87
86
  };
88
- RockerButtonGroup.defaultProps = {
89
- isDisabled: false
90
- };
91
87
  RockerButtonGroup.displayName = 'RockerButtonGroup';
92
88
  export default RockerButtonGroup;
@@ -96,23 +96,8 @@ export var withCustomSelectedColors = function withCustomSelectedColors() {
96
96
  };
97
97
  export var DisabledSingleButton = function DisabledSingleButton() {
98
98
  return ___EmotionJSX(RockerButtonGroup, {
99
- defaultSelectedKey: "or"
100
- }, ___EmotionJSX(RockerButton, {
101
- name: "and",
102
- key: "and",
103
- isDisabled: true
104
- }, "And"), ___EmotionJSX(RockerButton, {
105
- name: "or",
106
- key: "or"
107
- }, "Or"), ___EmotionJSX(RockerButton, {
108
- name: "maybe",
109
- key: "maybe"
110
- }, "Maybe"));
111
- };
112
- export var DisabledRockerButtonGroup = function DisabledRockerButtonGroup() {
113
- return ___EmotionJSX(RockerButtonGroup, {
114
- isDisabled: true,
115
- defaultSelectedKey: "and"
99
+ defaultSelectedKey: "or",
100
+ disabledKeys: ['and']
116
101
  }, ___EmotionJSX(RockerButton, {
117
102
  name: "and",
118
103
  key: "and"
@@ -66,9 +66,11 @@ test('buttonGroup is not disabled by default', function () {
66
66
  expect(buttonKey).not.toHaveClass('is-disabled');
67
67
  });
68
68
  });
69
- test('each button is disabled when isDisabled prop is passed to RockerButtonGroup', function () {
69
+ test('rocker button is disabled when its key is included in disabledKeys', function () {
70
70
  getComponent({
71
- isDisabled: true
71
+ disabledKeys: _mapInstanceProperty(testButtons).call(testButtons, function (button) {
72
+ return button.key;
73
+ })
72
74
  });
73
75
 
74
76
  _forEachInstanceProperty(testButtons).call(testButtons, function (button) {
@@ -82,24 +84,16 @@ test('rockerButton renders selectedStyles prop when selected', function () {
82
84
  expect(buttonColorKey).toHaveClass('is-selected');
83
85
  });
84
86
  test('selected button can be changed by keyboard interaction', function () {
85
- getComponent(); // FIXME: Keyboard events must fire twice tests - unsure why at this time.
86
-
87
- userEvent.tab();
87
+ getComponent();
88
88
  userEvent.tab();
89
89
  var button0 = screen.getByText(testButtons[0].key);
90
90
  expect(button0).toHaveClass('is-selected');
91
91
  var button1 = screen.getByText(testButtons[1].key);
92
92
  expect(button1).not.toHaveClass('is-selected');
93
- userEvent.tab();
94
- userEvent.tab();
95
93
  fireEvent.keyDown(screen.getByText(testButtons[0].key), {
96
94
  key: 'ArrowRight',
97
95
  code: 'ArrowRight'
98
96
  });
99
- fireEvent.keyDown(screen.getByText(testButtons[1].key), {
100
- key: 'ArrowRight',
101
- code: 'ArrowRight'
102
- });
103
97
  expect(screen.getByText(testButtons[1].key)).toHaveClass('is-selected');
104
98
  expect(screen.getByText(testButtons[0].key)).not.toHaveClass('is-selected');
105
99
  });
@@ -101,17 +101,6 @@ export var NoClearButton = function NoClearButton() {
101
101
 
102
102
  });
103
103
  };
104
- export var MaxLength = function MaxLength(args) {
105
- return ___EmotionJSX(SearchField, _extends({}, args, {
106
- icon: SearchIcon,
107
- "aria-label": "Search Groups",
108
- onSubmit: function onSubmit(text) {
109
- return alert(text);
110
- } // eslint-disable-line no-alert
111
- ,
112
- maxLength: 9
113
- }));
114
- };
115
104
  export var ControlledWithDebouncedInput = function ControlledWithDebouncedInput() {
116
105
  var _useState3 = useState(''),
117
106
  _useState4 = _slicedToArray(_useState3, 2),