@pingux/astro 2.32.0-alpha.8 → 2.32.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/TreeView/TreeView.js +99 -11
- package/lib/cjs/components/TreeView/TreeView.stories.js +23 -10
- package/lib/cjs/components/TreeView/TreeView.styles.js +22 -2
- package/lib/cjs/components/TreeView/TreeView.test.js +91 -11
- package/lib/cjs/components/TreeView/TreeViewItem.js +112 -14
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.js +200 -0
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.test.js +511 -0
- package/lib/cjs/components/TreeView/TreeViewRow.js +20 -5
- package/lib/cjs/components/TreeView/TreeViewSection.js +164 -16
- package/lib/cjs/components/TreeView/TreeViewWrapper.js +40 -0
- package/lib/cjs/hooks/useField/index.d.ts +1 -0
- package/lib/cjs/hooks/useField/useField.d.ts +1686 -0
- package/lib/cjs/hooks/useField/useField.js +7 -16
- package/lib/cjs/hooks/useField/useField.test.d.ts +1 -0
- package/lib/cjs/hooks/useField/useField.test.js +6 -6
- package/lib/cjs/hooks/useModalState/index.d.ts +1 -0
- package/lib/cjs/hooks/useModalState/useModalState.d.ts +21 -0
- package/lib/cjs/hooks/useModalState/useModalState.js +0 -9
- package/lib/cjs/hooks/useModalState/useModalState.test.d.ts +1 -0
- package/lib/cjs/hooks/useMountTransition/index.d.ts +1 -0
- package/lib/cjs/hooks/useMountTransition/useMountTransition.d.ts +14 -0
- package/lib/cjs/hooks/useMountTransition/useMountTransition.js +0 -9
- package/lib/cjs/hooks/useMountTransition/useMountTransition.test.d.ts +1 -0
- package/lib/cjs/hooks/useMountTransition/useMountTransition.test.js +2 -2
- package/lib/cjs/hooks/useStatusClasses/index.d.ts +1 -0
- package/lib/cjs/hooks/useStatusClasses/useStatusClasses.d.ts +18 -0
- package/lib/cjs/hooks/useStatusClasses/useStatusClasses.js +0 -9
- package/lib/cjs/hooks/useStatusClasses/useStatusClasses.test.d.ts +1 -0
- package/lib/components/TreeView/TreeView.js +100 -12
- package/lib/components/TreeView/TreeView.stories.js +23 -10
- package/lib/components/TreeView/TreeView.styles.js +22 -2
- package/lib/components/TreeView/TreeView.test.js +92 -12
- package/lib/components/TreeView/TreeViewItem.js +111 -14
- package/lib/components/TreeView/TreeViewKeyboardDelegate.js +176 -0
- package/lib/components/TreeView/TreeViewKeyboardDelegate.test.js +496 -0
- package/lib/components/TreeView/TreeViewRow.js +20 -5
- package/lib/components/TreeView/TreeViewSection.js +161 -16
- package/lib/components/TreeView/TreeViewWrapper.js +31 -0
- package/lib/hooks/useField/useField.js +7 -16
- package/lib/hooks/useField/useField.test.js +6 -6
- package/lib/hooks/useModalState/useModalState.js +0 -10
- package/lib/hooks/useMountTransition/useMountTransition.js +0 -10
- package/lib/hooks/useMountTransition/useMountTransition.test.js +2 -2
- package/lib/hooks/useStatusClasses/useStatusClasses.js +0 -10
- package/package.json +1 -1
@@ -1,19 +1,105 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
4
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
2
5
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
3
6
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
4
|
-
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
7
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
8
|
+
import { useFocusRing } from '@react-aria/focus';
|
5
9
|
import { useOption } from '@react-aria/listbox';
|
10
|
+
import { mergeProps } from '@react-aria/utils';
|
6
11
|
import PropTypes from 'prop-types';
|
7
12
|
import { useTreeViewContext } from '../../context/TreeViewContext';
|
13
|
+
import { useStatusClasses } from '../../hooks';
|
8
14
|
import { Box, TreeViewItem } from '../../index';
|
9
15
|
import { SectionOrItemRender } from './TreeView';
|
16
|
+
import { sectionPressHandlers } from './TreeViewKeyboardDelegate';
|
10
17
|
import TreeViewRow from './TreeViewRow';
|
11
18
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
19
|
+
export var onKeyDownSection = function onKeyDownSection(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength, isFocused) {
|
20
|
+
switch (e.which) {
|
21
|
+
case 9:
|
22
|
+
if (isFocused) {
|
23
|
+
sectionPressHandlers.onTabPress(e, refArray, focusManager, true, key);
|
24
|
+
}
|
25
|
+
break;
|
26
|
+
case 13:
|
27
|
+
sectionPressHandlers.onEnterPress(e, state, key);
|
28
|
+
break;
|
29
|
+
case 32:
|
30
|
+
sectionPressHandlers.onSpacePress(e, tree, key, isSelected);
|
31
|
+
break;
|
32
|
+
case 33:
|
33
|
+
sectionPressHandlers.onPageUpPress(e, key, flatKeyArray, refArray, pageLength);
|
34
|
+
break;
|
35
|
+
case 34:
|
36
|
+
sectionPressHandlers.onPageDownPress(e, key, flatKeyArray, refArray, pageLength);
|
37
|
+
break;
|
38
|
+
case 36:
|
39
|
+
sectionPressHandlers.onHomePress(key, flatKeyArray, refArray);
|
40
|
+
e.preventDefault();
|
41
|
+
e.stopPropagation();
|
42
|
+
break;
|
43
|
+
case 35:
|
44
|
+
sectionPressHandlers.onEndPress(key, flatKeyArray, refArray);
|
45
|
+
e.preventDefault();
|
46
|
+
e.stopPropagation();
|
47
|
+
break;
|
48
|
+
case 37:
|
49
|
+
sectionPressHandlers.onLeftPress(e, focusManager, state, key, isExpanded, refArray);
|
50
|
+
break;
|
51
|
+
case 38:
|
52
|
+
sectionPressHandlers.onUpPress(e, key, refArray, flatKeyArray);
|
53
|
+
e.preventDefault();
|
54
|
+
e.stopPropagation();
|
55
|
+
break;
|
56
|
+
case 39:
|
57
|
+
if (isFocused) {
|
58
|
+
sectionPressHandlers.onRightPress(e, focusManager, state, key, isExpanded, refArray);
|
59
|
+
}
|
60
|
+
break;
|
61
|
+
case 40:
|
62
|
+
sectionPressHandlers.onDownPress(e, key, refArray, flatKeyArray);
|
63
|
+
e.preventDefault();
|
64
|
+
e.stopPropagation();
|
65
|
+
break;
|
66
|
+
default:
|
67
|
+
/* istanbul ignore next */
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
};
|
71
|
+
export var removeRefFromArrayHelper = function removeRefFromArrayHelper(prevState, keyToRemove) {
|
72
|
+
if (_someInstanceProperty(prevState).call(prevState, function (item) {
|
73
|
+
return item.key === keyToRemove;
|
74
|
+
})) {
|
75
|
+
var _context;
|
76
|
+
var newArray = _concatInstanceProperty(_context = []).call(_context, _filterInstanceProperty(prevState).call(prevState, function (_item) {
|
77
|
+
return _item.key !== keyToRemove;
|
78
|
+
}));
|
79
|
+
return newArray;
|
80
|
+
}
|
81
|
+
return prevState;
|
82
|
+
};
|
83
|
+
export var addRefToArrayHelper = function addRefToArrayHelper(prevState, keyToAdd, refToAdd) {
|
84
|
+
if (!_someInstanceProperty(prevState).call(prevState, function (i) {
|
85
|
+
return i.key === keyToAdd;
|
86
|
+
})) {
|
87
|
+
var _context2;
|
88
|
+
var thisObj = {
|
89
|
+
key: keyToAdd,
|
90
|
+
thisRef: refToAdd
|
91
|
+
};
|
92
|
+
return _concatInstanceProperty(_context2 = []).call(_context2, prevState, [thisObj]);
|
93
|
+
}
|
94
|
+
return prevState;
|
95
|
+
};
|
12
96
|
var TreeViewSection = /*#__PURE__*/forwardRef(function (props, ref) {
|
13
|
-
var
|
97
|
+
var _context3;
|
14
98
|
var item = props.item,
|
15
99
|
items = props.items,
|
16
100
|
title = props.title,
|
101
|
+
focusManager = props.focusManager,
|
102
|
+
onKeyDown = props.onKeyDown,
|
17
103
|
level = props.level,
|
18
104
|
position = props.position,
|
19
105
|
setSize = props.setSize;
|
@@ -24,51 +110,107 @@ var TreeViewSection = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
24
110
|
return treeSectionRef.current;
|
25
111
|
});
|
26
112
|
var _useTreeViewContext = useTreeViewContext(),
|
27
|
-
state = _useTreeViewContext.state
|
113
|
+
state = _useTreeViewContext.state,
|
114
|
+
tree = _useTreeViewContext.tree,
|
115
|
+
refArray = _useTreeViewContext.refArray,
|
116
|
+
setRefs = _useTreeViewContext.setRefs,
|
117
|
+
flatKeyArray = _useTreeViewContext.flatKeyArray,
|
118
|
+
pageLength = _useTreeViewContext.pageLength,
|
119
|
+
setLastFocusedItem = _useTreeViewContext.setLastFocusedItem,
|
120
|
+
lastFocusedItem = _useTreeViewContext.lastFocusedItem;
|
28
121
|
var _useOption = useOption({
|
29
122
|
key: key
|
30
123
|
}, state, treeSectionRef),
|
31
124
|
optionProps = _useOption.optionProps,
|
32
125
|
isDisabled = _useOption.isDisabled,
|
33
126
|
isSelected = _useOption.isSelected;
|
127
|
+
var _useFocusRing = useFocusRing(),
|
128
|
+
focusProps = _useFocusRing.focusProps,
|
129
|
+
isFocused = _useFocusRing.isFocused;
|
130
|
+
var _useFocusRing2 = useFocusRing({
|
131
|
+
within: true
|
132
|
+
}),
|
133
|
+
focusPropsWithin = _useFocusRing2.focusProps,
|
134
|
+
isFocusedWithin = _useFocusRing2.isFocused;
|
34
135
|
var isExpanded = state.expandedKeys.has(key);
|
136
|
+
var onKeyDownFunction = function onKeyDownFunction(e) {
|
137
|
+
onKeyDownSection(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength, isFocused);
|
138
|
+
if (onKeyDown) {
|
139
|
+
onKeyDown(e, key);
|
140
|
+
}
|
141
|
+
};
|
142
|
+
var addRefToArray = function addRefToArray(thisKey, thisRef) {
|
143
|
+
setRefs(function (prev) {
|
144
|
+
return addRefToArrayHelper(prev, thisKey, thisRef);
|
145
|
+
});
|
146
|
+
};
|
147
|
+
var removeRefFromArray = function removeRefFromArray() {
|
148
|
+
setRefs(function (prev) {
|
149
|
+
return removeRefFromArrayHelper(prev, key);
|
150
|
+
});
|
151
|
+
};
|
152
|
+
|
153
|
+
// adds and removes refs on mount and dismount
|
154
|
+
useEffect(function () {
|
155
|
+
// this runs on mount
|
156
|
+
addRefToArray(key, treeSectionRef);
|
157
|
+
return function () {
|
158
|
+
// this runs on cleanup
|
159
|
+
removeRefFromArray(key, refArray);
|
160
|
+
};
|
161
|
+
}, []);
|
162
|
+
var mergedProps = mergeProps(focusPropsWithin, focusProps, optionProps, {
|
163
|
+
onFocus: function onFocus() {
|
164
|
+
return setLastFocusedItem(key);
|
165
|
+
}
|
166
|
+
});
|
167
|
+
var _useStatusClasses = useStatusClasses('', {
|
168
|
+
isFocused: isFocused
|
169
|
+
}),
|
170
|
+
classNames = _useStatusClasses.classNames;
|
35
171
|
return ___EmotionJSX(Box, _extends({
|
36
172
|
ref: treeSectionRef,
|
37
173
|
as: "li",
|
38
|
-
sx: {
|
39
|
-
':not(:last-child)': {
|
40
|
-
pb: 'sm'
|
41
|
-
}
|
42
|
-
},
|
43
174
|
"aria-expanded": isExpanded,
|
44
|
-
"aria-disabled": isDisabled
|
175
|
+
"aria-disabled": isDisabled
|
176
|
+
}, mergedProps, {
|
177
|
+
role: "treeitem",
|
178
|
+
variant: "treeView.wrapper",
|
179
|
+
className: classNames,
|
180
|
+
"aria-selected": isSelected,
|
45
181
|
"aria-level": level,
|
46
182
|
"aria-setsize": setSize,
|
47
|
-
"aria-posinset": position + 1
|
48
|
-
|
49
|
-
|
50
|
-
|
183
|
+
"aria-posinset": position + 1,
|
184
|
+
onKeyDown: function onKeyDown(e) {
|
185
|
+
return onKeyDownFunction(e);
|
186
|
+
},
|
187
|
+
tabIndex: lastFocusedItem === key ? 0 : -1
|
51
188
|
}), ___EmotionJSX(TreeViewRow, {
|
52
189
|
item: item,
|
53
190
|
title: title,
|
54
191
|
items: items,
|
55
192
|
isExpanded: isExpanded,
|
56
193
|
isSelected: isSelected,
|
57
|
-
isDisabled: isDisabled
|
194
|
+
isDisabled: isDisabled,
|
195
|
+
isParentFocused: isFocusedWithin
|
58
196
|
}), isExpanded && ___EmotionJSX(Box, {
|
59
197
|
as: "ul",
|
60
198
|
role: "group",
|
61
199
|
key: "".concat(item.key, " ul"),
|
62
200
|
sx: {
|
63
|
-
pl: 'md'
|
201
|
+
pl: 'md',
|
202
|
+
'& :focus': {
|
203
|
+
border: 'none'
|
204
|
+
}
|
64
205
|
}
|
65
|
-
}, _mapInstanceProperty(
|
206
|
+
}, _mapInstanceProperty(_context3 = _Array$from(items)).call(_context3, function (_item, _index) {
|
66
207
|
var _item$value$items;
|
67
208
|
return SectionOrItemRender(((_item$value$items = _item.value.items) === null || _item$value$items === void 0 ? void 0 : _item$value$items.length) > 0, ___EmotionJSX(TreeViewSection, {
|
68
209
|
item: _item,
|
69
210
|
items: _item.children,
|
70
211
|
title: _item.value.title,
|
71
212
|
key: _item.value.title,
|
213
|
+
focusManager: focusManager,
|
72
214
|
level: level + 1,
|
73
215
|
position: _index,
|
74
216
|
setSize: items.length
|
@@ -76,6 +218,7 @@ var TreeViewSection = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
76
218
|
item: _item,
|
77
219
|
title: _item.value.title,
|
78
220
|
key: _item.value.title,
|
221
|
+
focusManager: focusManager,
|
79
222
|
level: level + 1,
|
80
223
|
position: _index,
|
81
224
|
setSize: items.length
|
@@ -88,6 +231,8 @@ TreeViewSection.propTypes = {
|
|
88
231
|
key: PropTypes.string
|
89
232
|
}),
|
90
233
|
title: PropTypes.string,
|
234
|
+
focusManager: PropTypes.shape({}),
|
235
|
+
onKeyDown: PropTypes.func,
|
91
236
|
level: PropTypes.number,
|
92
237
|
position: PropTypes.number,
|
93
238
|
setSize: PropTypes.number
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
2
|
+
import React from 'react';
|
3
|
+
import { FocusScope, useFocusManager } from '@react-aria/focus';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
var TreeViewWrapper = function TreeViewWrapper(props) {
|
6
|
+
var children = props.children;
|
7
|
+
var items = _mapInstanceProperty(children).call(children, function (child) {
|
8
|
+
return {
|
9
|
+
item: child,
|
10
|
+
key: child.key
|
11
|
+
};
|
12
|
+
});
|
13
|
+
return ___EmotionJSX(FocusScope, {
|
14
|
+
restoreFocus: false,
|
15
|
+
contain: false
|
16
|
+
}, _mapInstanceProperty(items).call(items, function (_ref) {
|
17
|
+
var item = _ref.item,
|
18
|
+
key = _ref.key;
|
19
|
+
return ___EmotionJSX(FocusableItem, {
|
20
|
+
key: key
|
21
|
+
}, item);
|
22
|
+
}));
|
23
|
+
};
|
24
|
+
var FocusableItem = function FocusableItem(props) {
|
25
|
+
var focusManager = useFocusManager();
|
26
|
+
var childWithFocusHandle = /*#__PURE__*/React.cloneElement(props.children, {
|
27
|
+
focusManager: focusManager
|
28
|
+
});
|
29
|
+
return childWithFocusHandle;
|
30
|
+
};
|
31
|
+
export default TreeViewWrapper;
|
@@ -9,7 +9,7 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
9
9
|
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
|
-
var _excluded = ["autocomplete", "autoComplete", "autoCorrect", "
|
12
|
+
var _excluded = ["autocomplete", "autoComplete", "autoCorrect", "className", "containerProps", "controlProps", "defaultValue", "hasAutoFocus", "hasNoStatusIndicator", "hintText", "id", "isDefaultSelected", "isDisabled", "isIndeterminate", "isReadOnly", "isRequired", "isRestrictiveMultivalues", "label", "labelMode", "labelProps", "maxLength", "name", "onBlur", "onChange", "onFocus", "placeholder", "role", "spellCheck", "status", "statusClasses", "type", "value", "wrapperProps"];
|
13
13
|
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; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
15
|
import { useEffect, useState } from 'react';
|
@@ -27,24 +27,21 @@ import { useStatusClasses } from '..';
|
|
27
27
|
* @param {{}} props Props for the field
|
28
28
|
* @returns {{}} Prop objects to be spread into field components.
|
29
29
|
*/
|
30
|
-
|
31
|
-
|
30
|
+
|
31
|
+
// TODO: replace with LabelProps instead of ThemeUILabelProps
|
32
|
+
// once Label component is rewritten to ts
|
33
|
+
var useField = function useField(props) {
|
32
34
|
var autocomplete = props.autocomplete,
|
33
35
|
autoComplete = props.autoComplete,
|
34
36
|
autoCorrect = props.autoCorrect,
|
35
|
-
children = props.children,
|
36
37
|
className = props.className,
|
37
38
|
_props$containerProps = props.containerProps,
|
38
39
|
containerProps = _props$containerProps === void 0 ? {} : _props$containerProps,
|
39
40
|
_props$controlProps = props.controlProps,
|
40
41
|
controlProps = _props$controlProps === void 0 ? {} : _props$controlProps,
|
41
|
-
defaultText = props.defaultText,
|
42
42
|
defaultValue = props.defaultValue,
|
43
|
-
direction = props.direction,
|
44
|
-
disabledKeys = props.disabledKeys,
|
45
43
|
hasAutoFocus = props.hasAutoFocus,
|
46
44
|
hasNoStatusIndicator = props.hasNoStatusIndicator,
|
47
|
-
helperText = props.helperText,
|
48
45
|
hintText = props.hintText,
|
49
46
|
id = props.id,
|
50
47
|
isDefaultSelected = props.isDefaultSelected,
|
@@ -53,7 +50,6 @@ var useField = function useField() {
|
|
53
50
|
isReadOnly = props.isReadOnly,
|
54
51
|
isRequired = props.isRequired,
|
55
52
|
isRestrictiveMultivalues = props.isRestrictiveMultivalues,
|
56
|
-
isSelected = props.isSelected,
|
57
53
|
label = props.label,
|
58
54
|
labelMode = props.labelMode,
|
59
55
|
_props$labelProps = props.labelProps,
|
@@ -63,15 +59,9 @@ var useField = function useField() {
|
|
63
59
|
onBlur = props.onBlur,
|
64
60
|
_props$onChange = props.onChange,
|
65
61
|
onChange = _props$onChange === void 0 ? noop : _props$onChange,
|
66
|
-
onClear = props.onClear,
|
67
62
|
onFocus = props.onFocus,
|
68
|
-
onFocusChange = props.onFocusChange,
|
69
|
-
onLoadMore = props.onLoadMore,
|
70
|
-
onOpenChange = props.onOpenChange,
|
71
|
-
onSelectionChange = props.onSelectionChange,
|
72
63
|
placeholder = props.placeholder,
|
73
64
|
role = props.role,
|
74
|
-
selectedKey = props.selectedKey,
|
75
65
|
spellCheck = props.spellCheck,
|
76
66
|
_props$status = props.status,
|
77
67
|
status = _props$status === void 0 ? statuses.DEFAULT : _props$status,
|
@@ -107,6 +97,7 @@ var useField = function useField() {
|
|
107
97
|
} else {
|
108
98
|
setHasValue(false);
|
109
99
|
}
|
100
|
+
|
110
101
|
// adding this function resolves the error brought up in UIP-5116
|
111
102
|
if (e.persist) {
|
112
103
|
e.persist();
|
@@ -146,7 +137,7 @@ var useField = function useField() {
|
|
146
137
|
isReadOnly: isReadOnly
|
147
138
|
}, "is-".concat(status), true), statusClasses), labelProps === null || labelProps === void 0 ? void 0 : labelProps.statusClasses)),
|
148
139
|
labelClasses = _useStatusClasses3.classNames;
|
149
|
-
var _getAriaAttributeProp = getAriaAttributeProps(others),
|
140
|
+
var _getAriaAttributeProp = getAriaAttributeProps(omit(others, ['children', 'defaultText', 'direction', 'disabledKeys', 'helperText', 'isSelected', 'onClear', 'onFocusChange', 'onLoadMore', 'onOpenChange', 'onRemove', 'onSelectionChange', 'selectedKey'])),
|
150
141
|
ariaProps = _getAriaAttributeProp.ariaProps,
|
151
142
|
nonAriaProps = _getAriaAttributeProp.nonAriaProps;
|
152
143
|
|
@@ -60,11 +60,11 @@ var defaultProps = {
|
|
60
60
|
};
|
61
61
|
test('default useField', function () {
|
62
62
|
renderHook(function () {
|
63
|
-
return useField();
|
63
|
+
return useField({});
|
64
64
|
});
|
65
65
|
});
|
66
66
|
test('should return props objects for field components', function () {
|
67
|
-
var _context, _context2;
|
67
|
+
var _defaultProps$contain, _context, _context2;
|
68
68
|
var _renderHook = renderHook(function () {
|
69
69
|
return useField(defaultProps);
|
70
70
|
}),
|
@@ -76,7 +76,7 @@ test('should return props objects for field components', function () {
|
|
76
76
|
fieldLabelProps = _result$current.fieldLabelProps;
|
77
77
|
expect(fieldContainerProps).toEqual({
|
78
78
|
className: 'field-container has-value is-tested is-container',
|
79
|
-
id: defaultProps.containerProps.id,
|
79
|
+
id: (_defaultProps$contain = defaultProps.containerProps) === null || _defaultProps$contain === void 0 ? void 0 : _defaultProps$contain.id,
|
80
80
|
onBlur: expect.any(Function),
|
81
81
|
onFocus: expect.any(Function),
|
82
82
|
sx: expect.objectContaining({
|
@@ -151,7 +151,7 @@ test('should support autocomplete additionally', function () {
|
|
151
151
|
test('should return isFloatLabelActive class for container', function () {
|
152
152
|
var _renderHook3 = renderHook(function (initialProps) {
|
153
153
|
return useField(_objectSpread(_objectSpread({}, initialProps), {}, {
|
154
|
-
placeholder:
|
154
|
+
placeholder: undefined
|
155
155
|
}));
|
156
156
|
}, {
|
157
157
|
initialProps: defaultProps
|
@@ -224,8 +224,8 @@ test('should return hasValue class for container when onChange updates internal
|
|
224
224
|
var numCalls = 0;
|
225
225
|
var _renderHook5 = renderHook(function () {
|
226
226
|
return useField(_objectSpread(_objectSpread({}, defaultProps), {}, {
|
227
|
-
defaultValue:
|
228
|
-
placeholder:
|
227
|
+
defaultValue: undefined,
|
228
|
+
placeholder: undefined,
|
229
229
|
onChange: onChange,
|
230
230
|
value: ''
|
231
231
|
}));
|
@@ -1,14 +1,4 @@
|
|
1
1
|
import { useOverlayTriggerState } from 'react-stately';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Returns state-related data and functions for use with a Modal component.
|
5
|
-
* @param {Object} [props] Properties provided to the state
|
6
|
-
* @param {Boolean} [props.isDefaultOpen] Whether the modal is open by default (uncontrolled).
|
7
|
-
* @param {Boolean} [props.isOpen] Whether the modal is currently open (controlled).
|
8
|
-
* @param {Function} [props.onOpenChange] Handler that is called when the open state changes.
|
9
|
-
* `(isOpen: boolean) => void`
|
10
|
-
* @returns {Object} `{ isOpen: Boolean, open: Function, close: Function, toggle: Function }`
|
11
|
-
*/
|
12
2
|
var useModalState = function useModalState() {
|
13
3
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
14
4
|
var isDefaultOpen = props.isDefaultOpen,
|
@@ -1,16 +1,6 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
2
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
3
3
|
import { useEffect, useState } from 'react';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Allows for css transitions to be applied to components, while mounting or unmounting.
|
7
|
-
* @param {Object} [props] Properties provided to the state
|
8
|
-
* @param {Boolean} [props.isMounted] Whether the component has been mounted.
|
9
|
-
* @param {Number} [props.unmountDelay] Number value of the length of the transition in ms.
|
10
|
-
* `(isOpen: boolean) => void`
|
11
|
-
* @returns {Boolean} `isTransitioning`
|
12
|
-
*/
|
13
|
-
|
14
4
|
var useMountTransition = function useMountTransition(isMounted, unmountDelay) {
|
15
5
|
var _useState = useState(false),
|
16
6
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -23,7 +23,7 @@ var ControlledWithTransition = function ControlledWithTransition() {
|
|
23
23
|
var _useOverlayPanelState = useOverlayPanelState(),
|
24
24
|
state = _useOverlayPanelState.state,
|
25
25
|
onClose = _useOverlayPanelState.onClose;
|
26
|
-
var triggerRef = useRef();
|
26
|
+
var triggerRef = useRef(null);
|
27
27
|
return (
|
28
28
|
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
29
29
|
// readers when an overlay is open.
|
@@ -42,7 +42,7 @@ var ControlledWithTransition = function ControlledWithTransition() {
|
|
42
42
|
},
|
43
43
|
"aria-expanded": state.isOpen
|
44
44
|
}, defaultCloseButtonProps), "Close Panel"), ___EmotionJSX("p", {
|
45
|
-
|
45
|
+
"padding-top": "md"
|
46
46
|
}, _JSON$stringify(state.isOpen)))))
|
47
47
|
);
|
48
48
|
};
|
@@ -1,16 +1,6 @@
|
|
1
1
|
import classnames from 'classnames';
|
2
2
|
import kebabCase from 'lodash/kebabCase';
|
3
3
|
import mapKeys from 'lodash/mapKeys';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Converts status information into classes which can be supplied to the rendered component's
|
7
|
-
* `className` prop.
|
8
|
-
* @param {string} [defaultClass] An optional default class that will be added
|
9
|
-
* @param {{}} [statuses] A mapping of conditional statuses and the current value of each one
|
10
|
-
* @returns {{classNames: string}} A string of classes based on the input. Status keys will be
|
11
|
-
* converted to kebab-case.
|
12
|
-
* e.g. useStatusClasses('thing', { isDisabled: true }) => "thing is-disabled"
|
13
|
-
*/
|
14
4
|
var useStatusClasses = function useStatusClasses(defaultClass) {
|
15
5
|
var statuses = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
16
6
|
var kebabStatuses = mapKeys(statuses, function (_v, k) {
|