@pingux/astro 1.2.0-alpha.14 → 1.2.0-alpha.15

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 (47) hide show
  1. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +32 -25
  2. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +148 -169
  3. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +25 -30
  4. package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +29 -14
  5. package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +3 -3
  6. package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +16 -18
  7. package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
  8. package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
  9. package/lib/cjs/components/ListView/ListView.js +9 -13
  10. package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
  11. package/lib/cjs/components/RockerButton/RockerButton.js +14 -22
  12. package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
  13. package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +4 -22
  14. package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -14
  15. package/lib/cjs/components/TextAreaField/TextAreaField.js +53 -8
  16. package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +33 -1
  17. package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
  18. package/lib/cjs/context/AccordionGridContext/index.js +20 -0
  19. package/lib/cjs/hooks/useField/useField.js +5 -0
  20. package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
  21. package/lib/cjs/styles/variants/boxes.js +9 -0
  22. package/lib/cjs/styles/variants/buttons.js +2 -0
  23. package/lib/components/AccordionGridGroup/AccordionGridGroup.js +32 -24
  24. package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +143 -166
  25. package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -25
  26. package/lib/components/AccordionGridItem/AccordionGridItem.js +29 -15
  27. package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -4
  28. package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +19 -20
  29. package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
  30. package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
  31. package/lib/components/ListView/ListView.js +9 -12
  32. package/lib/components/ListViewItem/ListViewItem.js +14 -3
  33. package/lib/components/RockerButton/RockerButton.js +14 -21
  34. package/lib/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
  35. package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +2 -17
  36. package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -11
  37. package/lib/components/TextAreaField/TextAreaField.js +53 -9
  38. package/lib/components/TextAreaField/TextAreaField.stories.js +27 -0
  39. package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
  40. package/lib/context/AccordionGridContext/index.js +5 -0
  41. package/lib/hooks/useField/useField.js +5 -0
  42. package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
  43. package/lib/styles/variants/boxes.js +9 -0
  44. package/lib/styles/variants/buttons.js +2 -0
  45. package/package.json +1 -1
  46. package/lib/cjs/components/AccordionGridGroup/AccordionGridContext.js +0 -17
  47. 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, { useContext, useRef } from '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 { AccordionGridContext } from '../AccordionGridGroup/AccordionGridContext';
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
- others = _objectWithoutProperties(props, ["item", "headerProps", "bodyProps", "children"]);
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 _useContext = useContext(AccordionGridContext),
34
- state = _useContext.state;
35
+ var _useAccordionGridCont = useAccordionGridContext(),
36
+ state = _useAccordionGridCont.state; // Treat first cell as a row, fixes focus and keyboard interactions
35
37
 
36
- var isDisabled = state.disabledKeys.has(item.key);
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 isSelected = state.selectionManager.isSelected(item.key);
47
- return ___EmotionJSX(Box, _extends({
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
- ref: rowRef,
52
- role: "row"
65
+ "aria-selected": isSelected,
66
+ className: classNames,
67
+ ref: rowRef
53
68
  }), ___EmotionJSX(AccordionGridItemHeader, _extends({
54
69
  item: item,
55
- cellNode: cellNode,
56
- ref: cellRef
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, { 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');
@@ -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,
@@ -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
  });
@@ -14,8 +14,9 @@ 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, useEffect } from 'react';
17
+ import React, { forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from 'react';
18
18
  import PropTypes from 'prop-types';
19
+ import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
19
20
  import { useColumnStyles, useField, useLabelHeight, usePropWarning } from '../../hooks';
20
21
  import statuses from '../../utils/devUtils/constants/statuses';
21
22
  import Box from '../Box';
@@ -31,7 +32,8 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
31
32
  var helperText = props.helperText,
32
33
  isUnresizable = props.isUnresizable,
33
34
  rows = props.rows,
34
- status = props.status;
35
+ status = props.status,
36
+ slots = props.slots;
35
37
  var statusClasses = {
36
38
  isUnresizable: isUnresizable
37
39
  };
@@ -45,6 +47,9 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
45
47
 
46
48
  var textAreaRef = useRef();
47
49
  var labelRef = useRef();
50
+ var containerRef = useRef();
51
+ var inputContainerRef = useRef();
52
+ var slotContainer = useRef();
48
53
  usePropWarning(props, 'disabled', 'isDisabled');
49
54
  /* istanbul ignore next */
50
55
 
@@ -57,6 +62,24 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
57
62
  /* istanbul ignore next */
58
63
  labelRef.current.style.width = textAreaRef.current.style.width;
59
64
  };
65
+ /* istanbul ignore next */
66
+
67
+
68
+ var resizeSlotContainer = function resizeSlotContainer() {
69
+ inputContainerRef.current.style.width = textAreaRef.current.style.width;
70
+ };
71
+
72
+ var onResize = useCallback(function () {
73
+ /* istanbul ignore next */
74
+ if (slots === null || slots === void 0 ? void 0 : slots.inContainer) {
75
+ resizeSlotContainer();
76
+ }
77
+ }, [slotContainer]);
78
+ useResizeObserver({
79
+ ref: textAreaRef,
80
+ onResize: onResize
81
+ });
82
+ useLayoutEffect(onResize, [onResize]);
60
83
 
61
84
  var _useLabelHeight = useLabelHeight({
62
85
  labelRef: labelRef,
@@ -68,18 +91,22 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
68
91
  labelMode: props.labelMode
69
92
  });
70
93
  useEffect(function () {
94
+ var thisRef = textAreaRef.current;
95
+
71
96
  if (!props.isUnresizable && props.labelMode === 'float') {
72
- textAreaRef.current.addEventListener('mousemove', props.resizeCallback ? props.resizeCallback : resizeFloatLabel);
97
+ thisRef.addEventListener('mousemove', props.resizeCallback ? props.resizeCallback : resizeFloatLabel);
73
98
  }
74
99
 
75
100
  return function () {
76
- textAreaRef.current.removeEventListener('mousemove', props.resizeCallback ? props.resizeCallback : resizeFloatLabel);
101
+ thisRef.removeEventListener('mousemove', props.resizeCallback ? props.resizeCallback : resizeFloatLabel);
77
102
  };
78
- }, []);
103
+ }, [props.isUnresizable, props.labelMode, props.resizeCallback]);
79
104
  return ___EmotionJSX(Box, _extends({
80
105
  variant: "forms.input.wrapper"
81
106
  }, fieldContainerProps, {
82
- sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx)
107
+ sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx),
108
+ ref: containerRef,
109
+ maxWidth: "100%"
83
110
  }), ___EmotionJSX(Label, _extends({
84
111
  ref: labelRef
85
112
  }, fieldLabelProps, {
@@ -87,12 +114,23 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
87
114
  gridRow: '1/5'
88
115
  }
89
116
  })), ___EmotionJSX(Box, {
117
+ isRow: true,
90
118
  variant: "forms.input.container",
91
- className: fieldControlProps.className
119
+ className: fieldControlProps.className,
120
+ minWidth: "40px",
121
+ maxWidth: "100%",
122
+ ref: inputContainerRef
92
123
  }, ___EmotionJSX(TextArea, _extends({
93
124
  ref: textAreaRef,
94
125
  rows: rows
95
- }, fieldControlProps))), helperText && ___EmotionJSX(FieldHelperText, {
126
+ }, fieldControlProps, {
127
+ sx: (slots === null || slots === void 0 ? void 0 : slots.inContainer) && {
128
+ paddingRight: '35px'
129
+ }
130
+ })), (slots === null || slots === void 0 ? void 0 : slots.inContainer) && ___EmotionJSX(Box, {
131
+ variant: "boxes.textFieldInContainerSlot",
132
+ ref: slotContainer
133
+ }, slots === null || slots === void 0 ? void 0 : slots.inContainer)), helperText && ___EmotionJSX(FieldHelperText, {
96
134
  status: status
97
135
  }, helperText));
98
136
  });
@@ -187,7 +225,13 @@ TextAreaField.propTypes = {
187
225
  controlProps: PropTypes.shape({}),
188
226
 
189
227
  /** Props object that is spread directly into the label element. */
190
- labelProps: PropTypes.shape({})
228
+ labelProps: PropTypes.shape({}),
229
+
230
+ /** Provides a way to insert markup in specified places. */
231
+ slots: PropTypes.shape({
232
+ /** The given node will be inserted into the field container. */
233
+ inContainer: PropTypes.node
234
+ })
191
235
  };
192
236
  TextAreaField.defaultProps = {
193
237
  hasAutoFocus: false,