@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.
- package/lib/cjs/components/AccordionGroup/Accordion.styles.d.ts +70 -0
- package/lib/cjs/components/AccordionGroup/AccordionGroup.d.ts +13 -0
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +16 -32
- package/lib/cjs/components/AccordionGroup/AccordionGroup.stories.d.ts +52 -0
- package/lib/cjs/components/AccordionGroup/AccordionGroup.stories.js +12 -7
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.d.ts +1 -0
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +13 -11
- package/lib/cjs/components/AccordionGroup/index.d.ts +1 -0
- package/lib/cjs/components/AccordionItem/AccordionItem.d.ts +17 -0
- package/lib/cjs/components/AccordionItem/AccordionItem.js +9 -34
- package/lib/cjs/components/AccordionItem/index.d.ts +1 -0
- package/lib/cjs/components/FileInputField/FileInputField.js +71 -28
- package/lib/cjs/components/FileInputField/FileInputField.test.js +2 -1
- package/lib/cjs/components/FileInputField/FileItem.js +6 -6
- package/lib/cjs/hooks/useField/useField.d.ts +185 -185
- package/lib/cjs/hooks/useRockerButton/useRockerButton.d.ts +19 -19
- package/lib/cjs/types/item.d.ts +6 -2
- package/lib/components/AccordionGroup/AccordionGroup.js +18 -31
- package/lib/components/AccordionGroup/AccordionGroup.stories.js +12 -7
- package/lib/components/AccordionGroup/AccordionGroup.test.js +13 -11
- package/lib/components/AccordionItem/AccordionItem.js +13 -35
- package/lib/components/FileInputField/FileInputField.js +73 -30
- package/lib/components/FileInputField/FileInputField.test.js +2 -1
- package/lib/components/FileInputField/FileItem.js +6 -6
- package/package.json +4 -2
@@ -0,0 +1,70 @@
|
|
1
|
+
export declare const hoveredState: {
|
2
|
+
'&.is-hovered': {
|
3
|
+
color: string;
|
4
|
+
};
|
5
|
+
};
|
6
|
+
declare const _default: {
|
7
|
+
title: {
|
8
|
+
display: string;
|
9
|
+
overflowWrap: string;
|
10
|
+
maxWidth: string;
|
11
|
+
wordWrap: string;
|
12
|
+
wordBreak: string;
|
13
|
+
fontSize: string;
|
14
|
+
fontWeight: number;
|
15
|
+
color: string;
|
16
|
+
'&.is-pressed': {
|
17
|
+
color: string;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
accordion: {
|
21
|
+
display: string;
|
22
|
+
mt: string;
|
23
|
+
mb: string;
|
24
|
+
alignItems: string;
|
25
|
+
};
|
26
|
+
body: {
|
27
|
+
display: string;
|
28
|
+
pt: string;
|
29
|
+
width: string;
|
30
|
+
'.is-open &': {
|
31
|
+
display: string;
|
32
|
+
};
|
33
|
+
};
|
34
|
+
header: {
|
35
|
+
'&.is-hovered': {
|
36
|
+
color: string;
|
37
|
+
};
|
38
|
+
display: string;
|
39
|
+
bg: string;
|
40
|
+
color: string;
|
41
|
+
padding: string;
|
42
|
+
flexGrow: number;
|
43
|
+
fontWeight: number;
|
44
|
+
'&.is-pressed': {
|
45
|
+
color: string;
|
46
|
+
};
|
47
|
+
'&.is-focused': {
|
48
|
+
outline: string;
|
49
|
+
outlineColor: string;
|
50
|
+
outlineOffset: string;
|
51
|
+
};
|
52
|
+
fontSize: string;
|
53
|
+
fontFamily: string;
|
54
|
+
overflowWrap: string;
|
55
|
+
maxWidth: string;
|
56
|
+
wordWrap: string;
|
57
|
+
wordBreak: string;
|
58
|
+
cursor: string;
|
59
|
+
height: string;
|
60
|
+
lineHeight: string;
|
61
|
+
minWidth: string;
|
62
|
+
outline: string;
|
63
|
+
alignItems: string;
|
64
|
+
justifyContent: string;
|
65
|
+
borderRadius: string;
|
66
|
+
flexShrink: number;
|
67
|
+
whiteSpace: string;
|
68
|
+
};
|
69
|
+
};
|
70
|
+
export default _default;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React, { Dispatch, SetStateAction } from 'react';
|
2
|
+
import { TreeProps } from 'react-stately';
|
3
|
+
/**
|
4
|
+
* Console Warning: "Cannot update a component (`Unknown`)...`"
|
5
|
+
* when using controlledExpanded prop is expected
|
6
|
+
* and related to a known issue within React Stately.
|
7
|
+
*/
|
8
|
+
interface AccordionProps extends Omit<TreeProps<object>, 'onExpandedChange'> {
|
9
|
+
labelHeadingTag?: string;
|
10
|
+
onExpandedChange?: Dispatch<SetStateAction<string[]>>;
|
11
|
+
}
|
12
|
+
declare const AccordionGroup: React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<unknown>>;
|
13
|
+
export default AccordionGroup;
|
@@ -21,17 +21,15 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
21
21
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
22
22
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
23
23
|
var _react = _interopRequireWildcard(require("react"));
|
24
|
+
var _reactAria = require("react-aria");
|
24
25
|
var _reactStately = require("react-stately");
|
25
26
|
var _accordion = require("@react-aria/accordion");
|
26
|
-
var _utils = require("@react-aria/utils");
|
27
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
28
27
|
var _AccordionContext = require("../../context/AccordionContext");
|
29
28
|
var _index = require("../../index");
|
30
|
-
var _isIterable = require("../../utils/devUtils/props/isIterable");
|
31
29
|
var _AccordionItem = _interopRequireDefault(require("../AccordionItem"));
|
32
30
|
var _react2 = require("@emotion/react");
|
33
|
-
var _excluded = ["
|
34
|
-
_excluded2 = ["onFocus"];
|
31
|
+
var _excluded = ["labelHeadingTag", "onExpandedChange"],
|
32
|
+
_excluded2 = ["onFocus"]; // eslint-disable-next-line import/no-unresolved
|
35
33
|
/**
|
36
34
|
* Console Warning: "Cannot update a component (`Unknown`)...`"
|
37
35
|
* when using controlledExpanded prop is expected
|
@@ -43,18 +41,15 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
43
41
|
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) { (0, _defineProperty2["default"])(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; }
|
44
42
|
var AccordionGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
45
43
|
var _context;
|
46
|
-
var
|
47
|
-
|
48
|
-
labelHeadingTag = props.labelHeadingTag,
|
44
|
+
var _props$labelHeadingTa = props.labelHeadingTag,
|
45
|
+
labelHeadingTag = _props$labelHeadingTa === void 0 ? 'span' : _props$labelHeadingTa,
|
49
46
|
onExpandedChange = props.onExpandedChange,
|
50
47
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
51
48
|
var state = (0, _reactStately.useTreeState)(props);
|
52
|
-
var accordionRef = (0, _react.useRef)();
|
49
|
+
var accordionRef = (0, _react.useRef)(null);
|
53
50
|
|
54
51
|
/* `autoFocus: true` is what makes the initial focus only take one click vs two. */
|
55
|
-
var _useAccordion = (0, _accordion.useAccordion)(_objectSpread({
|
56
|
-
autoFocus: true
|
57
|
-
}, props), state, accordionRef),
|
52
|
+
var _useAccordion = (0, _accordion.useAccordion)(_objectSpread({}, props), state, accordionRef),
|
58
53
|
accordionProps = _useAccordion.accordionProps;
|
59
54
|
delete accordionProps.onMouseDown;
|
60
55
|
|
@@ -66,11 +61,19 @@ var AccordionGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
66
61
|
(0, _react.useImperativeHandle)(ref, function () {
|
67
62
|
return accordionRef.current;
|
68
63
|
});
|
64
|
+
var mergedProps = (0, _reactAria.mergeProps)(theseProps, others);
|
65
|
+
var onFocusGroup = function onFocusGroup() {
|
66
|
+
if (state.selectionManager.isFocused === false) {
|
67
|
+
state.selectionManager.setFocused(true);
|
68
|
+
}
|
69
|
+
};
|
69
70
|
return (0, _react2.jsx)(_AccordionContext.AccordionContext.Provider, {
|
70
71
|
value: state
|
71
72
|
}, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
72
73
|
ref: accordionRef
|
73
|
-
},
|
74
|
+
}, mergedProps, {
|
75
|
+
onFocus: onFocusGroup
|
76
|
+
}), (0, _map["default"])(_context = (0, _from["default"])(state.collection)).call(_context, function (item) {
|
74
77
|
return (0, _react2.jsx)(_AccordionItem["default"], {
|
75
78
|
"data-id": item['data-id'],
|
76
79
|
item: item,
|
@@ -79,25 +82,6 @@ var AccordionGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
79
82
|
}, item.props.children);
|
80
83
|
})));
|
81
84
|
});
|
82
|
-
AccordionGroup.propTypes = {
|
83
|
-
/** Handler that is called when items are expanded or collapsed. */
|
84
|
-
onExpandedChange: _propTypes["default"].func,
|
85
|
-
/** Item objects in the collection. */
|
86
|
-
items: _isIterable.isIterableProp,
|
87
|
-
/**
|
88
|
-
* The item keys that are disabled. These items cannot be selected, focused, or otherwise
|
89
|
-
* interacted with.
|
90
|
-
*/
|
91
|
-
disabledKeys: _isIterable.isIterableProp,
|
92
|
-
/** The currently expanded keys in the collection (controlled). */
|
93
|
-
expandedKeys: _isIterable.isIterableProp,
|
94
|
-
/** The initial expanded keys in the collection (uncontrolled). */
|
95
|
-
defaultExpandedKeys: _isIterable.isIterableProp,
|
96
|
-
/** Id of the selected element */
|
97
|
-
id: _propTypes["default"].string,
|
98
|
-
/** HTML header element wrapping the label */
|
99
|
-
labelHeadingTag: _AccordionItem["default"].propTypes.labelHeadingTag
|
100
|
-
};
|
101
85
|
AccordionGroup.displayName = 'AccordionGroup';
|
102
86
|
var _default = AccordionGroup;
|
103
87
|
exports["default"] = _default;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
3
|
+
export default _default;
|
4
|
+
export declare const Default: {
|
5
|
+
(args: any): React.JSX.Element;
|
6
|
+
parameters: {
|
7
|
+
design: {
|
8
|
+
type: string;
|
9
|
+
url: string;
|
10
|
+
};
|
11
|
+
};
|
12
|
+
};
|
13
|
+
export declare const DifferentLevels: {
|
14
|
+
(): React.JSX.Element;
|
15
|
+
parameters: {
|
16
|
+
design: {
|
17
|
+
type: string;
|
18
|
+
url: string;
|
19
|
+
};
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export declare const Multiple: {
|
23
|
+
(): React.JSX.Element;
|
24
|
+
parameters: {
|
25
|
+
design: {
|
26
|
+
type: string;
|
27
|
+
url: string;
|
28
|
+
};
|
29
|
+
};
|
30
|
+
};
|
31
|
+
export declare const ControlledExpanded: () => React.JSX.Element;
|
32
|
+
export declare const UncontrolledExpanded: () => React.JSX.Element;
|
33
|
+
export declare const DisabledState: {
|
34
|
+
(): React.JSX.Element;
|
35
|
+
parameters: {
|
36
|
+
design: {
|
37
|
+
type: string;
|
38
|
+
url: string;
|
39
|
+
};
|
40
|
+
};
|
41
|
+
};
|
42
|
+
export declare const CustomPresentation: {
|
43
|
+
(): React.JSX.Element;
|
44
|
+
parameters: {
|
45
|
+
docs: {
|
46
|
+
description: {
|
47
|
+
story: string;
|
48
|
+
};
|
49
|
+
};
|
50
|
+
};
|
51
|
+
};
|
52
|
+
export declare const LabelWithBadge: (args: any) => React.JSX.Element;
|
@@ -16,9 +16,9 @@ var _reactStately = require("react-stately");
|
|
16
16
|
var _storybookAddonDesigns = require("storybook-addon-designs");
|
17
17
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
18
18
|
var _index = require("../../index");
|
19
|
-
var _figmaLinks = require("../../utils/designUtils/figmaLinks
|
19
|
+
var _figmaLinks = require("../../utils/designUtils/figmaLinks");
|
20
20
|
var _AccordionItem = require("../AccordionItem/AccordionItem");
|
21
|
-
var _AccordionGroup = _interopRequireDefault(require("./AccordionGroup
|
21
|
+
var _AccordionGroup = _interopRequireDefault(require("./AccordionGroup"));
|
22
22
|
var _react2 = require("@emotion/react");
|
23
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -154,9 +154,10 @@ var Multiple = function Multiple() {
|
|
154
154
|
items: itemArray,
|
155
155
|
labelHeadingTag: "h3"
|
156
156
|
}, function (item) {
|
157
|
+
var _label;
|
157
158
|
return (0, _react2.jsx)(_reactStately.Item, {
|
158
159
|
key: item.key,
|
159
|
-
textValue: item.label,
|
160
|
+
textValue: (_label = item.label) === null || _label === void 0 ? void 0 : _label.toString(),
|
160
161
|
label: item.label
|
161
162
|
}, item.children);
|
162
163
|
})
|
@@ -192,9 +193,10 @@ var ControlledExpanded = function ControlledExpanded() {
|
|
192
193
|
items: itemArray,
|
193
194
|
labelHeadingTag: "h3"
|
194
195
|
}, function (item) {
|
196
|
+
var _label2;
|
195
197
|
return (0, _react2.jsx)(_reactStately.Item, {
|
196
198
|
key: item.key,
|
197
|
-
textValue: item.label,
|
199
|
+
textValue: (_label2 = item.label) === null || _label2 === void 0 ? void 0 : _label2.toString(),
|
198
200
|
label: item.label
|
199
201
|
}, item.children);
|
200
202
|
})
|
@@ -215,9 +217,10 @@ var UncontrolledExpanded = function UncontrolledExpanded() {
|
|
215
217
|
items: itemArray,
|
216
218
|
labelHeadingTag: "h3"
|
217
219
|
}, function (item) {
|
220
|
+
var _label3;
|
218
221
|
return (0, _react2.jsx)(_reactStately.Item, {
|
219
222
|
key: item.key,
|
220
|
-
textValue: item.label,
|
223
|
+
textValue: (_label3 = item.label) === null || _label3 === void 0 ? void 0 : _label3.toString(),
|
221
224
|
label: item.label
|
222
225
|
}, item.children);
|
223
226
|
})
|
@@ -238,9 +241,10 @@ var DisabledState = function DisabledState() {
|
|
238
241
|
items: itemArrayDisabled,
|
239
242
|
labelHeadingTag: "h3"
|
240
243
|
}, function (item) {
|
244
|
+
var _label4;
|
241
245
|
return (0, _react2.jsx)(_reactStately.Item, {
|
242
246
|
key: item.key,
|
243
|
-
textValue: item.label,
|
247
|
+
textValue: (_label4 = item.label) === null || _label4 === void 0 ? void 0 : _label4.toString(),
|
244
248
|
label: item.label
|
245
249
|
}, item.children);
|
246
250
|
})
|
@@ -266,9 +270,10 @@ var CustomPresentation = function CustomPresentation() {
|
|
266
270
|
items: itemArrayDisabled,
|
267
271
|
labelHeadingTag: "h3"
|
268
272
|
}, function (item) {
|
273
|
+
var _label5;
|
269
274
|
return (0, _react2.jsx)(_reactStately.Item, {
|
270
275
|
key: item.key,
|
271
|
-
textValue: item.label,
|
276
|
+
textValue: (_label5 = item.label) === null || _label5 === void 0 ? void 0 : _label5.toString(),
|
272
277
|
label: item.label,
|
273
278
|
buttonProps: {
|
274
279
|
bg: item.key === 't2' ? 'darkseagreen' : 'skyblue'
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -101,7 +101,9 @@ var getComponentWithPopover = function getComponentWithPopover() {
|
|
101
101
|
}, (0, _react2.jsx)(_index.PopoverMenu, null, (0, _react2.jsx)(_index.Button, {
|
102
102
|
"data-testid": "popoverbutton"
|
103
103
|
}, "Click me"), (0, _react2.jsx)(_index.Menu, {
|
104
|
-
onAction: function onAction() {
|
104
|
+
onAction: function onAction() {
|
105
|
+
return false;
|
106
|
+
}
|
105
107
|
}, (0, _react2.jsx)(_reactStately.Item, {
|
106
108
|
key: "edit"
|
107
109
|
}, "Edit"), (0, _react2.jsx)(_reactStately.Item, {
|
@@ -114,13 +116,15 @@ var getComponentWithPopover = function getComponentWithPopover() {
|
|
114
116
|
}, "Delete")))), (0, _react2.jsx)(_["default"], {
|
115
117
|
items: items,
|
116
118
|
defaultExpandedKeys: selectedAccordionKeys
|
117
|
-
},
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
119
|
+
}, (0, _react2.jsx)(_reactStately.Item, {
|
120
|
+
key: items[0].key,
|
121
|
+
textValue: items[0].label,
|
122
|
+
label: items[0].label
|
123
|
+
}, items[0].text), (0, _react2.jsx)(_reactStately.Item, {
|
124
|
+
key: items[1].key,
|
125
|
+
textValue: items[1].label,
|
126
|
+
label: items[1].label
|
127
|
+
}, items[1].text))));
|
124
128
|
};
|
125
129
|
var getComponentWithMultipleAccordion = function getComponentWithMultipleAccordion() {
|
126
130
|
return (0, _testWrapper.render)((0, _react2.jsx)(_index.Box, {
|
@@ -245,9 +249,7 @@ test('allows users to navigate accordion headers through the tab key', function
|
|
245
249
|
firstItem = _buttons2[0],
|
246
250
|
secondItem = _buttons2[1],
|
247
251
|
thirdItem = _buttons2[2];
|
248
|
-
|
249
|
-
firstItem.focus();
|
250
|
-
});
|
252
|
+
_userEvent["default"].tab();
|
251
253
|
expect(firstItem).toHaveFocus();
|
252
254
|
_userEvent["default"].tab();
|
253
255
|
expect(secondItem).toHaveFocus();
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './AccordionGroup';
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Node } from '@react-types/shared';
|
3
|
+
export declare const validHeadingTags: string[];
|
4
|
+
interface AccordionItemProps<T> {
|
5
|
+
item: Node<T>;
|
6
|
+
className?: string;
|
7
|
+
labelHeadingTag: string;
|
8
|
+
'aria-label'?: string;
|
9
|
+
'data-id'?: string;
|
10
|
+
children: React.ReactNode;
|
11
|
+
buttonProps?: object;
|
12
|
+
}
|
13
|
+
declare const AccordionItem: {
|
14
|
+
(props: AccordionItemProps<object>): React.JSX.Element;
|
15
|
+
displayName: string;
|
16
|
+
};
|
17
|
+
export default AccordionItem;
|
@@ -10,8 +10,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
10
10
|
});
|
11
11
|
exports.validHeadingTags = exports["default"] = void 0;
|
12
12
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
13
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
14
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
15
13
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
16
14
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
17
15
|
var _react = _interopRequireWildcard(require("react"));
|
@@ -21,27 +19,22 @@ var _MenuUpIcon = _interopRequireDefault(require("@pingux/mdi-react/MenuUpIcon")
|
|
21
19
|
var _accordion = require("@react-aria/accordion");
|
22
20
|
var _focus = require("@react-aria/focus");
|
23
21
|
var _interactions = require("@react-aria/interactions");
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
25
22
|
var _themeUi = require("theme-ui");
|
26
23
|
var _AccordionContext = require("../../context/AccordionContext");
|
27
24
|
var _hooks = require("../../hooks");
|
28
25
|
var _index = require("../../index");
|
29
26
|
var _Accordion = require("../AccordionGroup/Accordion.styles");
|
30
27
|
var _react2 = require("@emotion/react");
|
31
|
-
var
|
32
|
-
var _excluded = ["label", "children", "textValue", "containerProps", "buttonProps", "regionProps"];
|
28
|
+
var _excluded = ["containerProps", "buttonProps", "regionProps"]; // eslint-disable-next-line import/no-unresolved
|
33
29
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
34
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
35
31
|
var validHeadingTags = ['h1', 'h2', 'h3', 'h4'];
|
36
32
|
exports.validHeadingTags = validHeadingTags;
|
37
|
-
var AccordionItem =
|
33
|
+
var AccordionItem = function AccordionItem(props) {
|
38
34
|
var className = props.className,
|
39
35
|
item = props.item,
|
40
36
|
labelHeadingTag = props.labelHeadingTag;
|
41
37
|
var _item$props = item.props,
|
42
|
-
label = _item$props.label,
|
43
|
-
children = _item$props.children,
|
44
|
-
textValue = _item$props.textValue,
|
45
38
|
_item$props$container = _item$props.containerProps,
|
46
39
|
containerProps = _item$props$container === void 0 ? {} : _item$props$container,
|
47
40
|
_item$props$buttonPro = _item$props.buttonProps,
|
@@ -50,23 +43,23 @@ var AccordionItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
50
43
|
regionProps = _item$props$regionPro === void 0 ? {} : _item$props$regionPro,
|
51
44
|
others = (0, _objectWithoutProperties2["default"])(_item$props, _excluded);
|
52
45
|
var state = (0, _react.useContext)(_AccordionContext.AccordionContext);
|
53
|
-
var buttonRef = (0, _react.useRef)();
|
46
|
+
var buttonRef = (0, _react.useRef)(null);
|
54
47
|
var _useAccordionItem = (0, _accordion.useAccordionItem)(props, state, buttonRef),
|
55
48
|
accordionButtonProps = _useAccordionItem.buttonProps,
|
56
49
|
accordionRegionProps = _useAccordionItem.regionProps;
|
57
|
-
var _useHover = (0, _interactions.useHover)(props),
|
58
|
-
hoverProps = _useHover.hoverProps,
|
59
|
-
isHovered = _useHover.isHovered;
|
60
50
|
var _useFocusRing = (0, _focus.useFocusRing)(),
|
61
51
|
focusProps = _useFocusRing.focusProps,
|
62
52
|
isFocusVisible = _useFocusRing.isFocusVisible;
|
63
53
|
var isOpen = state.expandedKeys.has(item.key);
|
64
54
|
var isDisabled = state.disabledKeys.has(item.key);
|
55
|
+
var _useHover = (0, _interactions.useHover)({
|
56
|
+
isDisabled: isDisabled
|
57
|
+
}),
|
58
|
+
hoverProps = _useHover.hoverProps,
|
59
|
+
isHovered = _useHover.isHovered;
|
65
60
|
|
66
61
|
/* istanbul ignore next */
|
67
|
-
|
68
|
-
return buttonRef.current;
|
69
|
-
});
|
62
|
+
|
70
63
|
var _useButton = (0, _reactAria.useButton)(props, buttonRef),
|
71
64
|
isPressed = _useButton.isPressed,
|
72
65
|
raButtonProps = _useButton.buttonProps;
|
@@ -116,24 +109,6 @@ var AccordionItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
116
109
|
}, accordionRegionProps, regionProps, {
|
117
110
|
className: itemClasses
|
118
111
|
}), item.rendered));
|
119
|
-
});
|
120
|
-
AccordionItem.propTypes = {
|
121
|
-
'aria-label': _propTypes["default"].string,
|
122
|
-
labelHeadingTag: _propTypes["default"].oneOf((0, _concat["default"])(_context = []).call(_context, validHeadingTags, (0, _map["default"])(validHeadingTags).call(validHeadingTags, function (heading) {
|
123
|
-
return heading.toUpperCase();
|
124
|
-
}))),
|
125
|
-
item: _propTypes["default"].shape({
|
126
|
-
key: _propTypes["default"].string,
|
127
|
-
rendered: _propTypes["default"].node,
|
128
|
-
props: _propTypes["default"].shape({
|
129
|
-
label: _propTypes["default"].node,
|
130
|
-
children: _propTypes["default"].node,
|
131
|
-
textValue: _propTypes["default"].string,
|
132
|
-
containerProps: _propTypes["default"].shape({}),
|
133
|
-
buttonProps: _propTypes["default"].shape({}),
|
134
|
-
regionProps: _propTypes["default"].shape({})
|
135
|
-
})
|
136
|
-
})
|
137
112
|
};
|
138
113
|
AccordionItem.displayName = 'AccordionItem';
|
139
114
|
var _default = AccordionItem;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './AccordionItem';
|
@@ -15,11 +15,11 @@ _Object$defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
16
16
|
});
|
17
17
|
exports["default"] = void 0;
|
18
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
18
19
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
19
20
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
20
21
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
21
22
|
var _url = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/url"));
|
22
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
23
23
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
24
24
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
25
25
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
@@ -28,6 +28,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-c
|
|
28
28
|
var _react = _interopRequireWildcard(require("react"));
|
29
29
|
var _reactAria = require("react-aria");
|
30
30
|
var _reactDropzone = require("react-dropzone");
|
31
|
+
var _pluralize = _interopRequireDefault(require("pluralize"));
|
31
32
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
32
33
|
var _uuid = require("uuid");
|
33
34
|
var _ = require("../..");
|
@@ -44,7 +45,11 @@ var _excluded = ["defaultButtonText", "defaultFileList", "fileList", "helperText
|
|
44
45
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
45
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
46
47
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
47
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
48
|
+
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) { (0, _defineProperty2["default"])(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; }
|
49
|
+
var FILE_CHANGE_STATUS = {
|
50
|
+
ADDED: 'added',
|
51
|
+
DELETED: 'deleted'
|
52
|
+
};
|
48
53
|
var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
49
54
|
var defaultButtonText = _ref.defaultButtonText,
|
50
55
|
defaultFileList = _ref.defaultFileList,
|
@@ -62,6 +67,14 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
62
67
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
63
68
|
uploadedFiles = _useState2[0],
|
64
69
|
setUploadedFiles = _useState2[1];
|
70
|
+
var _useState3 = (0, _react.useState)(null),
|
71
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
72
|
+
fileChangeStatus = _useState4[0],
|
73
|
+
setFileChangeStatus = _useState4[1];
|
74
|
+
var _useState5 = (0, _react.useState)(''),
|
75
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
76
|
+
fileChangeMessage = _useState6[0],
|
77
|
+
setFileChangeMessage = _useState6[1];
|
65
78
|
var inputRef = (0, _react.useRef)();
|
66
79
|
/* istanbul ignore next */
|
67
80
|
(0, _react.useImperativeHandle)(ref, function () {
|
@@ -85,7 +98,22 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
85
98
|
inputRef.current.value = null;
|
86
99
|
inputRef.current.click();
|
87
100
|
}, [inputRef]);
|
88
|
-
|
101
|
+
(0, _react.useEffect)(function () {
|
102
|
+
// TODO: The function works fine in Google Chrome, but sometimes voiceover skips the
|
103
|
+
// update/delete file status update on Safari
|
104
|
+
|
105
|
+
if (status === _statuses["default"].ERROR) {
|
106
|
+
setFileChangeMessage(helperText);
|
107
|
+
} else if (fileChangeStatus) {
|
108
|
+
var _context;
|
109
|
+
setFileChangeMessage((0, _concat["default"])(_context = "".concat((0, _pluralize["default"])('file', fileChangeStatus.fileCount, true), " ")).call(_context, fileChangeStatus.status, " successfully"));
|
110
|
+
}
|
111
|
+
setFileChangeStatus(null);
|
112
|
+
}, [fileChangeStatus, helperText, status]);
|
113
|
+
var handleFileUpload = function handleFileUpload(event, newFiles) {
|
114
|
+
if (status === _statuses["default"].ERROR) {
|
115
|
+
setFileChangeMessage('');
|
116
|
+
}
|
89
117
|
if (onFileSelect) {
|
90
118
|
onFileSelect(event, newFiles);
|
91
119
|
}
|
@@ -93,7 +121,7 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
93
121
|
if (!isMultiple) {
|
94
122
|
arrayWithNewFiles = (0, _slice["default"])(arrayWithNewFiles).call(arrayWithNewFiles, 0, 1);
|
95
123
|
}
|
96
|
-
var
|
124
|
+
var filesWithIdAndLink = (0, _map["default"])(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
|
97
125
|
return {
|
98
126
|
fileObj: newFile,
|
99
127
|
name: newFile.name,
|
@@ -104,16 +132,20 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
104
132
|
});
|
105
133
|
if (isMultiple) {
|
106
134
|
setUploadedFiles(function (prevFiles) {
|
107
|
-
var
|
108
|
-
return (0, _concat["default"])(
|
135
|
+
var _context2;
|
136
|
+
return (0, _concat["default"])(_context2 = []).call(_context2, prevFiles, filesWithIdAndLink);
|
109
137
|
});
|
110
138
|
} else {
|
111
|
-
setUploadedFiles(
|
139
|
+
setUploadedFiles(filesWithIdAndLink);
|
112
140
|
}
|
113
|
-
|
114
|
-
|
141
|
+
setFileChangeStatus({
|
142
|
+
fileCount: filesWithIdAndLink.length,
|
143
|
+
status: FILE_CHANGE_STATUS.ADDED
|
144
|
+
});
|
145
|
+
};
|
146
|
+
var onDrop = function onDrop(acceptedFiles, fileRejections, event) {
|
115
147
|
handleFileUpload(event, acceptedFiles);
|
116
|
-
}
|
148
|
+
};
|
117
149
|
var _useDropzone = (0, _reactDropzone.useDropzone)({
|
118
150
|
onDrop: onDrop,
|
119
151
|
noKeyboard: true,
|
@@ -122,26 +154,31 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
122
154
|
getRootProps = _useDropzone.getRootProps,
|
123
155
|
getInputProps = _useDropzone.getInputProps,
|
124
156
|
isDragActive = _useDropzone.isDragActive;
|
125
|
-
var handleOnChange =
|
157
|
+
var handleOnChange = function handleOnChange(event) {
|
126
158
|
handleFileUpload(event, event.target.files);
|
127
|
-
}
|
128
|
-
var handleFileDelete = (0, _react.useCallback)(function (e, fileId) {
|
129
|
-
if (onRemove) {
|
130
|
-
onRemove(e, fileId);
|
131
|
-
}
|
132
|
-
setUploadedFiles(function (prevFiles) {
|
133
|
-
return (0, _filter["default"])(prevFiles).call(prevFiles, function (_ref2) {
|
134
|
-
var id = _ref2.id;
|
135
|
-
return id !== fileId;
|
136
|
-
});
|
137
|
-
});
|
138
|
-
}, [onRemove]);
|
159
|
+
};
|
139
160
|
var filesListNode = (0, _react.useMemo)(function () {
|
161
|
+
var handleFileDelete = function handleFileDelete(e, fileId) {
|
162
|
+
setFileChangeMessage('');
|
163
|
+
if (onRemove) {
|
164
|
+
onRemove(e, fileId);
|
165
|
+
}
|
166
|
+
setUploadedFiles(function (prevFiles) {
|
167
|
+
return (0, _filter["default"])(prevFiles).call(prevFiles, function (_ref2) {
|
168
|
+
var id = _ref2.id;
|
169
|
+
return id !== fileId;
|
170
|
+
});
|
171
|
+
});
|
172
|
+
setFileChangeStatus({
|
173
|
+
fileCount: 1,
|
174
|
+
status: FILE_CHANGE_STATUS.DELETED
|
175
|
+
});
|
176
|
+
};
|
140
177
|
var filesToRender = uploadedFilesImperative || uploadedFiles;
|
141
178
|
if (!(filesToRender !== null && filesToRender !== void 0 && filesToRender.length)) {
|
142
179
|
return null;
|
143
180
|
}
|
144
|
-
return (0, _map["default"])(filesToRender).call(filesToRender, function (fileProps) {
|
181
|
+
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _map["default"])(filesToRender).call(filesToRender, function (fileProps) {
|
145
182
|
return (0, _react2.jsx)(_FileItem["default"], (0, _extends2["default"])({
|
146
183
|
handleFileDelete: handleFileDelete,
|
147
184
|
isDisabled: isDisabled || isLoading,
|
@@ -149,8 +186,8 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
149
186
|
textProps: textProps,
|
150
187
|
helperTextId: helperTextId
|
151
188
|
}, fileProps));
|
152
|
-
});
|
153
|
-
}, [
|
189
|
+
}));
|
190
|
+
}, [helperTextId, isDisabled, isLoading, onRemove, textProps, uploadedFiles, uploadedFilesImperative]);
|
154
191
|
var _useStatusClasses = (0, _useStatusClasses3["default"])('fileInputFieldWrapper', (0, _defineProperty2["default"])({
|
155
192
|
isDragActive: isDragActive,
|
156
193
|
isLoading: isLoading
|
@@ -191,10 +228,16 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
191
228
|
position: 'absolute'
|
192
229
|
},
|
193
230
|
"data-testid": "file-input-field__loader"
|
194
|
-
})), helperText && (0, _react2.jsx)(_.
|
231
|
+
})), helperText && (0, _react2.jsx)(_.Box, {
|
232
|
+
"aria-label": helperText
|
233
|
+
}, (0, _react2.jsx)(_.FieldHelperText, {
|
195
234
|
status: status,
|
196
235
|
id: helperTextId
|
197
|
-
}, helperText))
|
236
|
+
}, helperText)), fileChangeMessage && (0, _react2.jsx)(_.Box, {
|
237
|
+
"aria-relevant": "all",
|
238
|
+
"aria-live": "assertive",
|
239
|
+
role: "status"
|
240
|
+
}, (0, _react2.jsx)(_reactAria.VisuallyHidden, null, (0, _react2.jsx)("h1", null, fileChangeMessage))));
|
198
241
|
});
|
199
242
|
FileInputField.displayName = 'FileInputField';
|
200
243
|
FileInputField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|