@pingux/astro 2.44.0 → 2.45.0-alpha.0

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 (25) hide show
  1. package/lib/cjs/components/AccordionGroup/Accordion.styles.d.ts +70 -0
  2. package/lib/cjs/components/AccordionGroup/AccordionGroup.d.ts +13 -0
  3. package/lib/cjs/components/AccordionGroup/AccordionGroup.js +16 -32
  4. package/lib/cjs/components/AccordionGroup/AccordionGroup.stories.d.ts +52 -0
  5. package/lib/cjs/components/AccordionGroup/AccordionGroup.stories.js +12 -7
  6. package/lib/cjs/components/AccordionGroup/AccordionGroup.test.d.ts +1 -0
  7. package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +13 -11
  8. package/lib/cjs/components/AccordionGroup/index.d.ts +1 -0
  9. package/lib/cjs/components/AccordionItem/AccordionItem.d.ts +17 -0
  10. package/lib/cjs/components/AccordionItem/AccordionItem.js +9 -34
  11. package/lib/cjs/components/AccordionItem/index.d.ts +1 -0
  12. package/lib/cjs/components/FileInputField/FileInputField.js +71 -28
  13. package/lib/cjs/components/FileInputField/FileInputField.test.js +2 -1
  14. package/lib/cjs/components/FileInputField/FileItem.js +6 -6
  15. package/lib/cjs/hooks/useField/useField.d.ts +185 -185
  16. package/lib/cjs/hooks/useRockerButton/useRockerButton.d.ts +19 -19
  17. package/lib/cjs/types/item.d.ts +6 -2
  18. package/lib/components/AccordionGroup/AccordionGroup.js +18 -31
  19. package/lib/components/AccordionGroup/AccordionGroup.stories.js +12 -7
  20. package/lib/components/AccordionGroup/AccordionGroup.test.js +13 -11
  21. package/lib/components/AccordionItem/AccordionItem.js +13 -35
  22. package/lib/components/FileInputField/FileInputField.js +73 -30
  23. package/lib/components/FileInputField/FileInputField.test.js +2 -1
  24. package/lib/components/FileInputField/FileItem.js +6 -6
  25. package/package.json +4 -2
@@ -20,50 +20,50 @@ declare const useRockerButton: (props: RockerButtonProps, state: {
20
20
  style?: React.CSSProperties | undefined;
21
21
  className?: string | undefined;
22
22
  'aria-activedescendant'?: string | undefined;
23
- 'aria-atomic'?: (boolean | "true" | "false") | undefined;
24
- 'aria-autocomplete'?: "list" | "none" | "inline" | "both" | undefined;
23
+ 'aria-atomic'?: (boolean | "false" | "true") | undefined;
24
+ 'aria-autocomplete'?: "list" | "none" | "both" | "inline" | undefined;
25
25
  'aria-braillelabel'?: string | undefined;
26
26
  'aria-brailleroledescription'?: string | undefined;
27
- 'aria-busy'?: (boolean | "true" | "false") | undefined;
28
- 'aria-checked'?: boolean | "true" | "false" | "mixed" | undefined;
27
+ 'aria-busy'?: (boolean | "false" | "true") | undefined;
28
+ 'aria-checked'?: boolean | "mixed" | "false" | "true" | undefined;
29
29
  'aria-colcount'?: number | undefined;
30
30
  'aria-colindex'?: number | undefined;
31
31
  'aria-colindextext'?: string | undefined;
32
32
  'aria-colspan'?: number | undefined;
33
33
  'aria-controls'?: string | undefined;
34
- 'aria-current'?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date" | undefined;
34
+ 'aria-current'?: boolean | "time" | "page" | "false" | "true" | "step" | "location" | "date" | undefined;
35
35
  'aria-describedby'?: string | undefined;
36
36
  'aria-description'?: string | undefined;
37
37
  'aria-details'?: string | undefined;
38
- 'aria-dropeffect'?: "link" | "none" | "copy" | "execute" | "move" | "popup" | undefined;
38
+ 'aria-dropeffect'?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
39
39
  'aria-errormessage'?: string | undefined;
40
- 'aria-expanded'?: (boolean | "true" | "false") | undefined;
40
+ 'aria-expanded'?: (boolean | "false" | "true") | undefined;
41
41
  'aria-flowto'?: string | undefined;
42
- 'aria-grabbed'?: (boolean | "true" | "false") | undefined;
43
- 'aria-haspopup'?: boolean | "dialog" | "menu" | "grid" | "true" | "false" | "listbox" | "tree" | undefined;
44
- 'aria-hidden'?: (boolean | "true" | "false") | undefined;
45
- 'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
42
+ 'aria-grabbed'?: (boolean | "false" | "true") | undefined;
43
+ 'aria-haspopup'?: boolean | "dialog" | "grid" | "listbox" | "menu" | "tree" | "false" | "true" | undefined;
44
+ 'aria-hidden'?: (boolean | "false" | "true") | undefined;
45
+ 'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
46
46
  'aria-keyshortcuts'?: string | undefined;
47
47
  'aria-label'?: string | undefined;
48
48
  'aria-labelledby'?: string | undefined;
49
49
  'aria-level'?: number | undefined;
50
50
  'aria-live'?: "off" | "assertive" | "polite" | undefined;
51
- 'aria-modal'?: (boolean | "true" | "false") | undefined;
52
- 'aria-multiline'?: (boolean | "true" | "false") | undefined;
53
- 'aria-multiselectable'?: (boolean | "true" | "false") | undefined;
54
- 'aria-orientation'?: "horizontal" | "vertical" | undefined;
51
+ 'aria-modal'?: (boolean | "false" | "true") | undefined;
52
+ 'aria-multiline'?: (boolean | "false" | "true") | undefined;
53
+ 'aria-multiselectable'?: (boolean | "false" | "true") | undefined;
54
+ 'aria-orientation'?: "vertical" | "horizontal" | undefined;
55
55
  'aria-owns'?: string | undefined;
56
56
  'aria-placeholder'?: string | undefined;
57
57
  'aria-posinset'?: number | undefined;
58
- 'aria-readonly'?: (boolean | "true" | "false") | undefined;
59
- 'aria-relevant'?: "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
60
- 'aria-required'?: (boolean | "true" | "false") | undefined;
58
+ 'aria-readonly'?: (boolean | "false" | "true") | undefined;
59
+ 'aria-relevant'?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
60
+ 'aria-required'?: (boolean | "false" | "true") | undefined;
61
61
  'aria-roledescription'?: string | undefined;
62
62
  'aria-rowcount'?: number | undefined;
63
63
  'aria-rowindex'?: number | undefined;
64
64
  'aria-rowindextext'?: string | undefined;
65
65
  'aria-rowspan'?: number | undefined;
66
- 'aria-selected'?: (boolean | "true" | "false") | undefined;
66
+ 'aria-selected'?: (boolean | "false" | "true") | undefined;
67
67
  'aria-setsize'?: number | undefined;
68
68
  'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
69
69
  'aria-valuemax'?: number | undefined;
@@ -1,4 +1,4 @@
1
- import { ElementType } from 'react';
1
+ import { ElementType, Key } from 'react';
2
2
  import type { ItemProps } from '@react-types/shared';
3
3
  import { DOMAttributes, StyleProps } from './shared';
4
4
  export interface Status {
@@ -7,11 +7,13 @@ export interface Status {
7
7
  declare module '@react-types/shared' {
8
8
  interface ItemProps<T> extends StyleProps, DOMAttributes {
9
9
  /** The rendered label for the item. */
10
- label?: string;
10
+ label?: string | React.ReactNode;
11
11
  /** Props for the accordion item content element. */
12
12
  regionProps?: StyleProps;
13
13
  /** Props for the accordion item content element. */
14
14
  containerProps?: StyleProps;
15
+ /** Props for the accordion item button element. */
16
+ buttonProps?: StyleProps;
15
17
  /** Whether the item has a separator */
16
18
  isSeparator?: boolean;
17
19
  /** Whether the item is pressed */
@@ -24,6 +26,8 @@ declare module '@react-types/shared' {
24
26
  href?: string;
25
27
  /** Inline styling prop for item */
26
28
  sx?: StyleProps;
29
+ /** Key for the item. */
30
+ key?: Key;
27
31
  }
28
32
  }
29
33
  export default ItemProps;
@@ -9,20 +9,21 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
9
9
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
10
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
11
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
12
- var _excluded = ["defaultExpandedKeys", "expandedKeys", "labelHeadingTag", "onExpandedChange"],
12
+ var _excluded = ["labelHeadingTag", "onExpandedChange"],
13
13
  _excluded2 = ["onFocus"];
14
14
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
15
15
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
16
16
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
18
18
  import React, { forwardRef, useImperativeHandle, useRef } from 'react';
19
+ import { mergeProps } from 'react-aria';
19
20
  import { useTreeState } from 'react-stately';
20
21
  import { useAccordion } from '@react-aria/accordion';
21
- import { mergeProps } from '@react-aria/utils';
22
- import PropTypes from 'prop-types';
22
+
23
+ // eslint-disable-next-line import/no-unresolved
24
+
23
25
  import { AccordionContext } from '../../context/AccordionContext';
24
26
  import { Box } from '../../index';
25
- import { isIterableProp } from '../../utils/devUtils/props/isIterable';
26
27
  import AccordionItem from '../AccordionItem';
27
28
 
28
29
  /**
@@ -33,18 +34,15 @@ import AccordionItem from '../AccordionItem';
33
34
  import { jsx as ___EmotionJSX } from "@emotion/react";
34
35
  var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
35
36
  var _context;
36
- var defaultExpandedKeys = props.defaultExpandedKeys,
37
- expandedKeys = props.expandedKeys,
38
- labelHeadingTag = props.labelHeadingTag,
37
+ var _props$labelHeadingTa = props.labelHeadingTag,
38
+ labelHeadingTag = _props$labelHeadingTa === void 0 ? 'span' : _props$labelHeadingTa,
39
39
  onExpandedChange = props.onExpandedChange,
40
40
  others = _objectWithoutProperties(props, _excluded);
41
41
  var state = useTreeState(props);
42
- var accordionRef = useRef();
42
+ var accordionRef = useRef(null);
43
43
 
44
44
  /* `autoFocus: true` is what makes the initial focus only take one click vs two. */
45
- var _useAccordion = useAccordion(_objectSpread({
46
- autoFocus: true
47
- }, props), state, accordionRef),
45
+ var _useAccordion = useAccordion(_objectSpread({}, props), state, accordionRef),
48
46
  accordionProps = _useAccordion.accordionProps;
49
47
  delete accordionProps.onMouseDown;
50
48
 
@@ -56,11 +54,19 @@ var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
56
54
  useImperativeHandle(ref, function () {
57
55
  return accordionRef.current;
58
56
  });
57
+ var mergedProps = mergeProps(theseProps, others);
58
+ var onFocusGroup = function onFocusGroup() {
59
+ if (state.selectionManager.isFocused === false) {
60
+ state.selectionManager.setFocused(true);
61
+ }
62
+ };
59
63
  return ___EmotionJSX(AccordionContext.Provider, {
60
64
  value: state
61
65
  }, ___EmotionJSX(Box, _extends({
62
66
  ref: accordionRef
63
- }, mergeProps(theseProps, others)), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
67
+ }, mergedProps, {
68
+ onFocus: onFocusGroup
69
+ }), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
64
70
  return ___EmotionJSX(AccordionItem, {
65
71
  "data-id": item['data-id'],
66
72
  item: item,
@@ -69,24 +75,5 @@ var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
69
75
  }, item.props.children);
70
76
  })));
71
77
  });
72
- AccordionGroup.propTypes = {
73
- /** Handler that is called when items are expanded or collapsed. */
74
- onExpandedChange: PropTypes.func,
75
- /** Item objects in the collection. */
76
- items: isIterableProp,
77
- /**
78
- * The item keys that are disabled. These items cannot be selected, focused, or otherwise
79
- * interacted with.
80
- */
81
- disabledKeys: isIterableProp,
82
- /** The currently expanded keys in the collection (controlled). */
83
- expandedKeys: isIterableProp,
84
- /** The initial expanded keys in the collection (uncontrolled). */
85
- defaultExpandedKeys: isIterableProp,
86
- /** Id of the selected element */
87
- id: PropTypes.string,
88
- /** HTML header element wrapping the label */
89
- labelHeadingTag: AccordionItem.propTypes.labelHeadingTag
90
- };
91
78
  AccordionGroup.displayName = 'AccordionGroup';
92
79
  export default AccordionGroup;
@@ -5,9 +5,9 @@ import { Item } from 'react-stately';
5
5
  import { withDesign } from 'storybook-addon-designs';
6
6
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
7
7
  import { AccordionGroup, Badge, Box, Button, Text, TextField } from '../../index';
8
- import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.ts';
8
+ import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
9
9
  import { validHeadingTags } from '../AccordionItem/AccordionItem';
10
- import AccordionReadme from './AccordionGroup.mdx';
10
+ import AccordionReadme from './AccordionGroup';
11
11
  import { jsx as ___EmotionJSX } from "@emotion/react";
12
12
  var itemArray = [{
13
13
  key: 't1',
@@ -138,9 +138,10 @@ export var Multiple = function Multiple() {
138
138
  items: itemArray,
139
139
  labelHeadingTag: "h3"
140
140
  }, function (item) {
141
+ var _label;
141
142
  return ___EmotionJSX(Item, {
142
143
  key: item.key,
143
- textValue: item.label,
144
+ textValue: (_label = item.label) === null || _label === void 0 ? void 0 : _label.toString(),
144
145
  label: item.label
145
146
  }, item.children);
146
147
  })
@@ -175,9 +176,10 @@ export var ControlledExpanded = function ControlledExpanded() {
175
176
  items: itemArray,
176
177
  labelHeadingTag: "h3"
177
178
  }, function (item) {
179
+ var _label2;
178
180
  return ___EmotionJSX(Item, {
179
181
  key: item.key,
180
- textValue: item.label,
182
+ textValue: (_label2 = item.label) === null || _label2 === void 0 ? void 0 : _label2.toString(),
181
183
  label: item.label
182
184
  }, item.children);
183
185
  })
@@ -197,9 +199,10 @@ export var UncontrolledExpanded = function UncontrolledExpanded() {
197
199
  items: itemArray,
198
200
  labelHeadingTag: "h3"
199
201
  }, function (item) {
202
+ var _label3;
200
203
  return ___EmotionJSX(Item, {
201
204
  key: item.key,
202
- textValue: item.label,
205
+ textValue: (_label3 = item.label) === null || _label3 === void 0 ? void 0 : _label3.toString(),
203
206
  label: item.label
204
207
  }, item.children);
205
208
  })
@@ -219,9 +222,10 @@ export var DisabledState = function DisabledState() {
219
222
  items: itemArrayDisabled,
220
223
  labelHeadingTag: "h3"
221
224
  }, function (item) {
225
+ var _label4;
222
226
  return ___EmotionJSX(Item, {
223
227
  key: item.key,
224
- textValue: item.label,
228
+ textValue: (_label4 = item.label) === null || _label4 === void 0 ? void 0 : _label4.toString(),
225
229
  label: item.label
226
230
  }, item.children);
227
231
  })
@@ -246,9 +250,10 @@ export var CustomPresentation = function CustomPresentation() {
246
250
  items: itemArrayDisabled,
247
251
  labelHeadingTag: "h3"
248
252
  }, function (item) {
253
+ var _label5;
249
254
  return ___EmotionJSX(Item, {
250
255
  key: item.key,
251
- textValue: item.label,
256
+ textValue: (_label5 = item.label) === null || _label5 === void 0 ? void 0 : _label5.toString(),
252
257
  label: item.label,
253
258
  buttonProps: {
254
259
  bg: item.key === 't2' ? 'darkseagreen' : 'skyblue'
@@ -98,7 +98,9 @@ var getComponentWithPopover = function getComponentWithPopover() {
98
98
  }, ___EmotionJSX(PopoverMenu, null, ___EmotionJSX(Button, {
99
99
  "data-testid": "popoverbutton"
100
100
  }, "Click me"), ___EmotionJSX(Menu, {
101
- onAction: function onAction() {}
101
+ onAction: function onAction() {
102
+ return false;
103
+ }
102
104
  }, ___EmotionJSX(Item, {
103
105
  key: "edit"
104
106
  }, "Edit"), ___EmotionJSX(Item, {
@@ -111,13 +113,15 @@ var getComponentWithPopover = function getComponentWithPopover() {
111
113
  }, "Delete")))), ___EmotionJSX(AccordionGroup, {
112
114
  items: items,
113
115
  defaultExpandedKeys: selectedAccordionKeys
114
- }, function (item) {
115
- return ___EmotionJSX(Item, {
116
- key: item.key,
117
- textValue: item.label,
118
- label: item.label
119
- }, item.text);
120
- })));
116
+ }, ___EmotionJSX(Item, {
117
+ key: items[0].key,
118
+ textValue: items[0].label,
119
+ label: items[0].label
120
+ }, items[0].text), ___EmotionJSX(Item, {
121
+ key: items[1].key,
122
+ textValue: items[1].label,
123
+ label: items[1].label
124
+ }, items[1].text))));
121
125
  };
122
126
  var getComponentWithMultipleAccordion = function getComponentWithMultipleAccordion() {
123
127
  return render(___EmotionJSX(Box, {
@@ -242,9 +246,7 @@ test('allows users to navigate accordion headers through the tab key', function
242
246
  firstItem = _buttons2[0],
243
247
  secondItem = _buttons2[1],
244
248
  thirdItem = _buttons2[2];
245
- act(function () {
246
- firstItem.focus();
247
- });
249
+ userEvent.tab();
248
250
  expect(firstItem).toHaveFocus();
249
251
  userEvent.tab();
250
252
  expect(secondItem).toHaveFocus();
@@ -1,18 +1,17 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
3
- var _context;
4
- var _excluded = ["label", "children", "textValue", "containerProps", "buttonProps", "regionProps"];
3
+ var _excluded = ["containerProps", "buttonProps", "regionProps"];
5
4
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
6
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
7
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
- import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'react';
5
+ import React, { useContext, useRef } from 'react';
9
6
  import { mergeProps, useButton } from 'react-aria';
10
7
  import MenuDown from '@pingux/mdi-react/MenuDownIcon';
11
8
  import MenuUp from '@pingux/mdi-react/MenuUpIcon';
12
9
  import { useAccordionItem } from '@react-aria/accordion';
13
10
  import { useFocusRing } from '@react-aria/focus';
14
11
  import { useHover } from '@react-aria/interactions';
15
- import PropTypes from 'prop-types';
12
+
13
+ // eslint-disable-next-line import/no-unresolved
14
+
16
15
  import { Button as ThemeUIButton } from 'theme-ui';
17
16
  import { AccordionContext } from '../../context/AccordionContext';
18
17
  import { useStatusClasses } from '../../hooks';
@@ -20,14 +19,11 @@ import { Box, Icon, Text } from '../../index';
20
19
  import { hoveredState } from '../AccordionGroup/Accordion.styles';
21
20
  import { jsx as ___EmotionJSX } from "@emotion/react";
22
21
  export var validHeadingTags = ['h1', 'h2', 'h3', 'h4'];
23
- var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
22
+ var AccordionItem = function AccordionItem(props) {
24
23
  var className = props.className,
25
24
  item = props.item,
26
25
  labelHeadingTag = props.labelHeadingTag;
27
26
  var _item$props = item.props,
28
- label = _item$props.label,
29
- children = _item$props.children,
30
- textValue = _item$props.textValue,
31
27
  _item$props$container = _item$props.containerProps,
32
28
  containerProps = _item$props$container === void 0 ? {} : _item$props$container,
33
29
  _item$props$buttonPro = _item$props.buttonProps,
@@ -36,23 +32,23 @@ var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
36
32
  regionProps = _item$props$regionPro === void 0 ? {} : _item$props$regionPro,
37
33
  others = _objectWithoutProperties(_item$props, _excluded);
38
34
  var state = useContext(AccordionContext);
39
- var buttonRef = useRef();
35
+ var buttonRef = useRef(null);
40
36
  var _useAccordionItem = useAccordionItem(props, state, buttonRef),
41
37
  accordionButtonProps = _useAccordionItem.buttonProps,
42
38
  accordionRegionProps = _useAccordionItem.regionProps;
43
- var _useHover = useHover(props),
44
- hoverProps = _useHover.hoverProps,
45
- isHovered = _useHover.isHovered;
46
39
  var _useFocusRing = useFocusRing(),
47
40
  focusProps = _useFocusRing.focusProps,
48
41
  isFocusVisible = _useFocusRing.isFocusVisible;
49
42
  var isOpen = state.expandedKeys.has(item.key);
50
43
  var isDisabled = state.disabledKeys.has(item.key);
44
+ var _useHover = useHover({
45
+ isDisabled: isDisabled
46
+ }),
47
+ hoverProps = _useHover.hoverProps,
48
+ isHovered = _useHover.isHovered;
51
49
 
52
50
  /* istanbul ignore next */
53
- useImperativeHandle(ref, function () {
54
- return buttonRef.current;
55
- });
51
+
56
52
  var _useButton = useButton(props, buttonRef),
57
53
  isPressed = _useButton.isPressed,
58
54
  raButtonProps = _useButton.buttonProps;
@@ -102,24 +98,6 @@ var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
102
98
  }, accordionRegionProps, regionProps, {
103
99
  className: itemClasses
104
100
  }), item.rendered));
105
- });
106
- AccordionItem.propTypes = {
107
- 'aria-label': PropTypes.string,
108
- labelHeadingTag: PropTypes.oneOf(_concatInstanceProperty(_context = []).call(_context, validHeadingTags, _mapInstanceProperty(validHeadingTags).call(validHeadingTags, function (heading) {
109
- return heading.toUpperCase();
110
- }))),
111
- item: PropTypes.shape({
112
- key: PropTypes.string,
113
- rendered: PropTypes.node,
114
- props: PropTypes.shape({
115
- label: PropTypes.node,
116
- children: PropTypes.node,
117
- textValue: PropTypes.string,
118
- containerProps: PropTypes.shape({}),
119
- buttonProps: PropTypes.shape({}),
120
- regionProps: PropTypes.shape({})
121
- })
122
- })
123
101
  };
124
102
  AccordionItem.displayName = 'AccordionItem';
125
103
  export default AccordionItem;
@@ -10,17 +10,18 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
10
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
11
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
12
12
  var _excluded = ["defaultButtonText", "defaultFileList", "fileList", "helperText", "isDisabled", "isLoading", "isMultiple", "onFileSelect", "onRemove", "status", "textProps"];
13
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
13
14
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
14
15
  import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
15
16
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
16
17
  import _URL from "@babel/runtime-corejs3/core-js-stable/url";
17
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
18
18
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
19
19
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
21
- import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';
22
- import { mergeProps, useVisuallyHidden } from 'react-aria';
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
22
+ import { mergeProps, useVisuallyHidden, VisuallyHidden } from 'react-aria';
23
23
  import { useDropzone } from 'react-dropzone';
24
+ import pluralize from 'pluralize';
24
25
  import PropTypes from 'prop-types';
25
26
  import { v4 as uuidv4 } from 'uuid';
26
27
  import { Box, FieldHelperText, Input, Label, Loader } from '../..';
@@ -33,6 +34,10 @@ import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusP
33
34
  import FileItem from './FileItem';
34
35
  import FileSelect from './FileSelect';
35
36
  import { jsx as ___EmotionJSX } from "@emotion/react";
37
+ var FILE_CHANGE_STATUS = {
38
+ ADDED: 'added',
39
+ DELETED: 'deleted'
40
+ };
36
41
  var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
37
42
  var defaultButtonText = _ref.defaultButtonText,
38
43
  defaultFileList = _ref.defaultFileList,
@@ -50,6 +55,14 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
50
55
  _useState2 = _slicedToArray(_useState, 2),
51
56
  uploadedFiles = _useState2[0],
52
57
  setUploadedFiles = _useState2[1];
58
+ var _useState3 = useState(null),
59
+ _useState4 = _slicedToArray(_useState3, 2),
60
+ fileChangeStatus = _useState4[0],
61
+ setFileChangeStatus = _useState4[1];
62
+ var _useState5 = useState(''),
63
+ _useState6 = _slicedToArray(_useState5, 2),
64
+ fileChangeMessage = _useState6[0],
65
+ setFileChangeMessage = _useState6[1];
53
66
  var inputRef = useRef();
54
67
  /* istanbul ignore next */
55
68
  useImperativeHandle(ref, function () {
@@ -73,7 +86,22 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
73
86
  inputRef.current.value = null;
74
87
  inputRef.current.click();
75
88
  }, [inputRef]);
76
- var handleFileUpload = useCallback(function (event, newFiles) {
89
+ useEffect(function () {
90
+ // TODO: The function works fine in Google Chrome, but sometimes voiceover skips the
91
+ // update/delete file status update on Safari
92
+
93
+ if (status === statuses.ERROR) {
94
+ setFileChangeMessage(helperText);
95
+ } else if (fileChangeStatus) {
96
+ var _context;
97
+ setFileChangeMessage(_concatInstanceProperty(_context = "".concat(pluralize('file', fileChangeStatus.fileCount, true), " ")).call(_context, fileChangeStatus.status, " successfully"));
98
+ }
99
+ setFileChangeStatus(null);
100
+ }, [fileChangeStatus, helperText, status]);
101
+ var handleFileUpload = function handleFileUpload(event, newFiles) {
102
+ if (status === statuses.ERROR) {
103
+ setFileChangeMessage('');
104
+ }
77
105
  if (onFileSelect) {
78
106
  onFileSelect(event, newFiles);
79
107
  }
@@ -81,7 +109,7 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
81
109
  if (!isMultiple) {
82
110
  arrayWithNewFiles = _sliceInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, 0, 1);
83
111
  }
84
- var newFilesWithIdAndLink = _mapInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
112
+ var filesWithIdAndLink = _mapInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
85
113
  return {
86
114
  fileObj: newFile,
87
115
  name: newFile.name,
@@ -92,16 +120,20 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
92
120
  });
93
121
  if (isMultiple) {
94
122
  setUploadedFiles(function (prevFiles) {
95
- var _context;
96
- return _concatInstanceProperty(_context = []).call(_context, prevFiles, newFilesWithIdAndLink);
123
+ var _context2;
124
+ return _concatInstanceProperty(_context2 = []).call(_context2, prevFiles, filesWithIdAndLink);
97
125
  });
98
126
  } else {
99
- setUploadedFiles(newFilesWithIdAndLink);
127
+ setUploadedFiles(filesWithIdAndLink);
100
128
  }
101
- }, [isMultiple, onFileSelect]);
102
- var onDrop = useCallback(function (acceptedFiles, fileRejections, event) {
129
+ setFileChangeStatus({
130
+ fileCount: filesWithIdAndLink.length,
131
+ status: FILE_CHANGE_STATUS.ADDED
132
+ });
133
+ };
134
+ var onDrop = function onDrop(acceptedFiles, fileRejections, event) {
103
135
  handleFileUpload(event, acceptedFiles);
104
- }, [handleFileUpload]);
136
+ };
105
137
  var _useDropzone = useDropzone({
106
138
  onDrop: onDrop,
107
139
  noKeyboard: true,
@@ -110,26 +142,31 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
110
142
  getRootProps = _useDropzone.getRootProps,
111
143
  getInputProps = _useDropzone.getInputProps,
112
144
  isDragActive = _useDropzone.isDragActive;
113
- var handleOnChange = useCallback(function (event) {
145
+ var handleOnChange = function handleOnChange(event) {
114
146
  handleFileUpload(event, event.target.files);
115
- }, [handleFileUpload]);
116
- var handleFileDelete = useCallback(function (e, fileId) {
117
- if (onRemove) {
118
- onRemove(e, fileId);
119
- }
120
- setUploadedFiles(function (prevFiles) {
121
- return _filterInstanceProperty(prevFiles).call(prevFiles, function (_ref2) {
122
- var id = _ref2.id;
123
- return id !== fileId;
124
- });
125
- });
126
- }, [onRemove]);
147
+ };
127
148
  var filesListNode = useMemo(function () {
149
+ var handleFileDelete = function handleFileDelete(e, fileId) {
150
+ setFileChangeMessage('');
151
+ if (onRemove) {
152
+ onRemove(e, fileId);
153
+ }
154
+ setUploadedFiles(function (prevFiles) {
155
+ return _filterInstanceProperty(prevFiles).call(prevFiles, function (_ref2) {
156
+ var id = _ref2.id;
157
+ return id !== fileId;
158
+ });
159
+ });
160
+ setFileChangeStatus({
161
+ fileCount: 1,
162
+ status: FILE_CHANGE_STATUS.DELETED
163
+ });
164
+ };
128
165
  var filesToRender = uploadedFilesImperative || uploadedFiles;
129
166
  if (!(filesToRender !== null && filesToRender !== void 0 && filesToRender.length)) {
130
167
  return null;
131
168
  }
132
- return _mapInstanceProperty(filesToRender).call(filesToRender, function (fileProps) {
169
+ return ___EmotionJSX(React.Fragment, null, _mapInstanceProperty(filesToRender).call(filesToRender, function (fileProps) {
133
170
  return ___EmotionJSX(FileItem, _extends({
134
171
  handleFileDelete: handleFileDelete,
135
172
  isDisabled: isDisabled || isLoading,
@@ -137,8 +174,8 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
137
174
  textProps: textProps,
138
175
  helperTextId: helperTextId
139
176
  }, fileProps));
140
- });
141
- }, [uploadedFilesImperative, uploadedFiles, handleFileDelete, isDisabled, isLoading, textProps]);
177
+ }));
178
+ }, [helperTextId, isDisabled, isLoading, onRemove, textProps, uploadedFiles, uploadedFilesImperative]);
142
179
  var _useStatusClasses = useStatusClasses('fileInputFieldWrapper', _defineProperty({
143
180
  isDragActive: isDragActive,
144
181
  isLoading: isLoading
@@ -179,10 +216,16 @@ var FileInputField = /*#__PURE__*/forwardRef(function (_ref, ref) {
179
216
  position: 'absolute'
180
217
  },
181
218
  "data-testid": "file-input-field__loader"
182
- })), helperText && ___EmotionJSX(FieldHelperText, {
219
+ })), helperText && ___EmotionJSX(Box, {
220
+ "aria-label": helperText
221
+ }, ___EmotionJSX(FieldHelperText, {
183
222
  status: status,
184
223
  id: helperTextId
185
- }, helperText));
224
+ }, helperText)), fileChangeMessage && ___EmotionJSX(Box, {
225
+ "aria-relevant": "all",
226
+ "aria-live": "assertive",
227
+ role: "status"
228
+ }, ___EmotionJSX(VisuallyHidden, null, ___EmotionJSX("h1", null, fileChangeMessage))));
186
229
  });
187
230
  FileInputField.displayName = 'FileInputField';
188
231
  FileInputField.propTypes = _objectSpread(_objectSpread(_objectSpread({
@@ -187,7 +187,8 @@ test('passing helper text should display it and correct aria attributes on input
187
187
  status: statuses.ERROR,
188
188
  defaultFileList: [testFileObject]
189
189
  });
190
- var helper = screen.getByText(testHelperText);
190
+ var helper = screen.getByRole('alert');
191
+ expect(helper).toHaveTextContent(testHelperText);
191
192
  expect(helper).toBeInTheDocument();
192
193
  expect(helper).toHaveClass("is-".concat(statuses.ERROR));
193
194
  var helperTextID = helper.getAttribute('id');
@@ -23,12 +23,12 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
23
23
  var FileItem = function FileItem(props) {
24
24
  var downloadLink = props.downloadLink,
25
25
  handleFileDelete = props.handleFileDelete,
26
+ helperTextId = props.helperTextId,
26
27
  id = props.id,
27
28
  isDisabled = props.isDisabled,
28
29
  name = props.name,
29
30
  status = props.status,
30
- textProps = props.textProps,
31
- helperTextId = props.helperTextId;
31
+ textProps = props.textProps;
32
32
  var handleDeleteButtonPress = useCallback(function (e) {
33
33
  return handleFileDelete(e, id);
34
34
  }, [id, handleFileDelete]);
@@ -76,11 +76,12 @@ var FileItem = function FileItem(props) {
76
76
  "aria-label": name,
77
77
  "data-testid": "file-uploaded__download-file-button",
78
78
  onPress: handleDownloadPress,
79
- "aria-describedby": helperTextId
79
+ "aria-describedby": helperTextId,
80
+ "aria-live": "polite"
80
81
  }, ___EmotionJSX(Text, _extends({
81
82
  color: "active"
82
83
  }, textProps), name)), ___EmotionJSX(IconButton, {
83
- "aria-label": "Delete ".concat(name, " file icon"),
84
+ "aria-label": "Delete ".concat(name),
84
85
  "data-testid": "file-uploaded__delete-file-button",
85
86
  isDisabled: isDisabled,
86
87
  onPress: handleDeleteButtonPress,
@@ -99,7 +100,7 @@ var FileItem = function FileItem(props) {
99
100
  }, visuallyHiddenProps, {
100
101
  download: true,
101
102
  ref: downloadRef,
102
- "aria-label": "download",
103
+ "aria-label": "download ".concat(name),
103
104
  "data-testid": "file-uploaded__download-link",
104
105
  tabIndex: -1
105
106
  })));
@@ -111,6 +112,5 @@ FileItem.propTypes = _objectSpread({
111
112
  id: PropTypes.string,
112
113
  isDisabled: PropTypes.bool,
113
114
  name: PropTypes.string,
114
- helperTextId: PropTypes.string,
115
115
  textProps: PropTypes.shape({})
116
116
  }, statusPropTypes);