@pingux/astro 2.32.0-alpha.11 → 2.32.0-alpha.12
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/ImageUploadField/ImageUploadField.test.js +14 -47
- package/lib/cjs/components/TreeView/TreeView.js +11 -99
- package/lib/cjs/components/TreeView/TreeView.stories.js +10 -23
- package/lib/cjs/components/TreeView/TreeView.styles.js +2 -22
- package/lib/cjs/components/TreeView/TreeView.test.js +11 -91
- package/lib/cjs/components/TreeView/TreeViewItem.js +14 -112
- package/lib/cjs/components/TreeView/TreeViewRow.js +5 -20
- package/lib/cjs/components/TreeView/TreeViewSection.js +16 -164
- package/lib/cjs/hooks/useImageUploadState/useImageUploadState.js +6 -9
- package/lib/cjs/hooks/useModalState/useModalState.js +9 -0
- package/lib/cjs/utils/testUtils/testWrapper.js +2 -3
- package/lib/components/ImageUploadField/ImageUploadField.test.js +14 -47
- package/lib/components/TreeView/TreeView.js +12 -100
- package/lib/components/TreeView/TreeView.stories.js +10 -23
- package/lib/components/TreeView/TreeView.styles.js +2 -22
- package/lib/components/TreeView/TreeView.test.js +12 -92
- package/lib/components/TreeView/TreeViewItem.js +14 -111
- package/lib/components/TreeView/TreeViewRow.js +5 -20
- package/lib/components/TreeView/TreeViewSection.js +16 -161
- package/lib/hooks/useImageUploadState/useImageUploadState.js +6 -9
- package/lib/hooks/useModalState/useModalState.js +10 -0
- package/lib/utils/testUtils/testWrapper.js +2 -3
- package/package.json +1 -1
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.js +0 -200
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.test.js +0 -511
- package/lib/cjs/components/TreeView/TreeViewWrapper.js +0 -40
- package/lib/cjs/hooks/useImageUploadState/index.d.ts +0 -1
- package/lib/cjs/hooks/useImageUploadState/useImageUploadState.d.ts +0 -28
- package/lib/cjs/hooks/useModalState/index.d.ts +0 -1
- package/lib/cjs/hooks/useModalState/useModalState.d.ts +0 -21
- package/lib/cjs/hooks/useModalState/useModalState.test.d.ts +0 -1
- package/lib/cjs/utils/testUtils/setupTests.d.ts +0 -4
- package/lib/cjs/utils/testUtils/testAxe.d.ts +0 -2
- package/lib/cjs/utils/testUtils/testTheme.d.ts +0 -21
- package/lib/cjs/utils/testUtils/testWrapper.d.ts +0 -5
- package/lib/components/TreeView/TreeViewKeyboardDelegate.js +0 -176
- package/lib/components/TreeView/TreeViewKeyboardDelegate.test.js +0 -496
- package/lib/components/TreeView/TreeViewWrapper.js +0 -31
@@ -1,61 +1,15 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import React, { forwardRef,
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
3
3
|
import FileIcon from '@pingux/mdi-react/FileIcon';
|
4
|
-
import { useFocusRing } from '@react-aria/focus';
|
5
4
|
import { useOption } from '@react-aria/listbox';
|
6
|
-
import { mergeProps } from '@react-aria/utils';
|
7
5
|
import PropTypes from 'prop-types';
|
8
6
|
import { useTreeViewContext } from '../../context/TreeViewContext';
|
9
|
-
import { useStatusClasses } from '../../hooks';
|
10
7
|
import { Box } from '../../index';
|
11
|
-
import { itemPressHandlers } from './TreeViewKeyboardDelegate';
|
12
8
|
import TreeViewRow from './TreeViewRow';
|
13
|
-
import { addRefToArrayHelper, removeRefFromArrayHelper } from './TreeViewSection';
|
14
9
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
|
-
export var onKeyDownItem = function onKeyDownItem(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength) {
|
16
|
-
switch (e.which) {
|
17
|
-
case 32:
|
18
|
-
itemPressHandlers.onSpacePress(e, tree, key, isSelected);
|
19
|
-
break;
|
20
|
-
case 38:
|
21
|
-
itemPressHandlers.onUpPress(e, key, refArray, flatKeyArray);
|
22
|
-
e.preventDefault();
|
23
|
-
e.stopPropagation();
|
24
|
-
break;
|
25
|
-
case 40:
|
26
|
-
itemPressHandlers.onDownPress(e, key, refArray, flatKeyArray);
|
27
|
-
e.preventDefault();
|
28
|
-
e.stopPropagation();
|
29
|
-
break;
|
30
|
-
case 37:
|
31
|
-
case 39:
|
32
|
-
itemPressHandlers.onRightLeftItemPress(e);
|
33
|
-
break;
|
34
|
-
case 33:
|
35
|
-
itemPressHandlers.onPageUpPress(e, key, flatKeyArray, refArray, pageLength);
|
36
|
-
break;
|
37
|
-
case 34:
|
38
|
-
itemPressHandlers.onPageDownPress(e, key, flatKeyArray, refArray, pageLength);
|
39
|
-
break;
|
40
|
-
case 36:
|
41
|
-
itemPressHandlers.onHomePress(key, flatKeyArray, refArray);
|
42
|
-
e.preventDefault();
|
43
|
-
e.stopPropagation();
|
44
|
-
break;
|
45
|
-
case 35:
|
46
|
-
itemPressHandlers.onEndPress(key, flatKeyArray, refArray);
|
47
|
-
e.preventDefault();
|
48
|
-
e.stopPropagation();
|
49
|
-
break;
|
50
|
-
default:
|
51
|
-
break;
|
52
|
-
}
|
53
|
-
};
|
54
10
|
var TreeViewItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
55
11
|
var item = props.item,
|
56
12
|
title = props.title,
|
57
|
-
focusManager = props.focusManager,
|
58
|
-
onKeyDown = props.onKeyDown,
|
59
13
|
level = props.level,
|
60
14
|
position = props.position,
|
61
15
|
setSize = props.setSize;
|
@@ -65,16 +19,8 @@ var TreeViewItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
65
19
|
useImperativeHandle(ref, function () {
|
66
20
|
return treeItemRef.current;
|
67
21
|
});
|
68
|
-
|
69
|
-
/* istanbul ignore next */
|
70
22
|
var _useTreeViewContext = useTreeViewContext(),
|
71
|
-
state = _useTreeViewContext.state
|
72
|
-
tree = _useTreeViewContext.tree,
|
73
|
-
refArray = _useTreeViewContext.refArray,
|
74
|
-
setRefs = _useTreeViewContext.setRefs,
|
75
|
-
flatKeyArray = _useTreeViewContext.flatKeyArray,
|
76
|
-
pageLength = _useTreeViewContext.pageLength,
|
77
|
-
setLastFocusedItem = _useTreeViewContext.setLastFocusedItem;
|
23
|
+
state = _useTreeViewContext.state;
|
78
24
|
var _useOption = useOption({
|
79
25
|
key: key
|
80
26
|
}, state, treeItemRef),
|
@@ -82,65 +28,24 @@ var TreeViewItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
82
28
|
isSelected = _useOption.isSelected,
|
83
29
|
isDisabled = _useOption.isDisabled;
|
84
30
|
var isExpanded = state.expandedKeys.has(key);
|
85
|
-
var onKeyDownFunction = function onKeyDownFunction(e) {
|
86
|
-
/* istanbul ignore next */
|
87
|
-
onKeyDownItem(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength);
|
88
|
-
if (onKeyDown) {
|
89
|
-
onKeyDown(e, key);
|
90
|
-
}
|
91
|
-
};
|
92
|
-
|
93
|
-
// ignoring from tests, but this is actually being unit tested
|
94
|
-
/* istanbul ignore next */
|
95
|
-
var removeRefFromArray = function removeRefFromArray() {
|
96
|
-
setRefs(function (prev) {
|
97
|
-
return removeRefFromArrayHelper(prev, key);
|
98
|
-
});
|
99
|
-
};
|
100
|
-
var addRefToArray = function addRefToArray() {
|
101
|
-
setRefs(function (prev) {
|
102
|
-
return addRefToArrayHelper(prev, key, treeItemRef);
|
103
|
-
});
|
104
|
-
};
|
105
|
-
|
106
|
-
// adds and removes refs on mount and dismount
|
107
|
-
/* istanbul ignore next */
|
108
|
-
useEffect(function () {
|
109
|
-
// this runs on mount
|
110
|
-
addRefToArray();
|
111
|
-
return function () {
|
112
|
-
// this runs on cleanup
|
113
|
-
removeRefFromArray(key, refArray);
|
114
|
-
};
|
115
|
-
}, []);
|
116
|
-
var _useFocusRing = useFocusRing(),
|
117
|
-
isFocusVisible = _useFocusRing.isFocusVisible,
|
118
|
-
focusProps = _useFocusRing.focusProps;
|
119
|
-
var mergedProps = mergeProps(focusProps, optionProps, {
|
120
|
-
onFocus: function onFocus() {
|
121
|
-
return setLastFocusedItem(key);
|
122
|
-
}
|
123
|
-
});
|
124
|
-
var _useStatusClasses = useStatusClasses('', {
|
125
|
-
isFocused: isFocusVisible
|
126
|
-
}),
|
127
|
-
classNames = _useStatusClasses.classNames;
|
128
31
|
return ___EmotionJSX(Box, _extends({
|
129
32
|
as: "li",
|
130
33
|
isRow: true,
|
131
34
|
ref: treeItemRef,
|
132
|
-
"aria-disabled": isDisabled
|
133
|
-
}, mergedProps, {
|
134
|
-
role: "treeitem",
|
135
|
-
variant: "treeView.wrapper",
|
136
|
-
className: classNames,
|
137
|
-
"aria-selected": isSelected,
|
35
|
+
"aria-disabled": isDisabled,
|
138
36
|
"aria-level": level,
|
139
37
|
"aria-posinset": position + 1,
|
140
|
-
"aria-setsize": setSize
|
141
|
-
|
142
|
-
|
143
|
-
|
38
|
+
"aria-setsize": setSize
|
39
|
+
}, optionProps, {
|
40
|
+
role: "treeitem",
|
41
|
+
sx: {
|
42
|
+
width: '100%',
|
43
|
+
ml: '36px',
|
44
|
+
':not(:last-child)': {
|
45
|
+
pb: 'sm'
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"aria-selected": isSelected
|
144
49
|
}), ___EmotionJSX(TreeViewRow, {
|
145
50
|
item: item,
|
146
51
|
title: title,
|
@@ -154,10 +59,8 @@ TreeViewItem.propTypes = {
|
|
154
59
|
item: PropTypes.shape({
|
155
60
|
key: PropTypes.string
|
156
61
|
}),
|
157
|
-
focusManager: PropTypes.shape({}),
|
158
62
|
name: PropTypes.string,
|
159
63
|
title: PropTypes.string,
|
160
|
-
onKeyDown: PropTypes.func,
|
161
64
|
level: PropTypes.number,
|
162
65
|
position: PropTypes.number,
|
163
66
|
setSize: PropTypes.number
|
@@ -9,7 +9,7 @@ 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 = ["title", "mainIcon", "lastIcon", "item", "items", "isExpanded", "isSelected", "isDisabled", "
|
12
|
+
var _excluded = ["title", "mainIcon", "lastIcon", "item", "items", "isExpanded", "isSelected", "isDisabled", "iconButtonProps"];
|
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 React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
@@ -35,7 +35,6 @@ var TreeViewRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
35
35
|
isExpanded = props.isExpanded,
|
36
36
|
isSelected = props.isSelected,
|
37
37
|
isDisabled = props.isDisabled,
|
38
|
-
isParentFocused = props.isParentFocused,
|
39
38
|
iconButtonProps = props.iconButtonProps,
|
40
39
|
others = _objectWithoutProperties(props, _excluded);
|
41
40
|
var treeRowRef = useRef();
|
@@ -74,19 +73,13 @@ var TreeViewRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
74
73
|
}),
|
75
74
|
classNames = _useStatusClasses.classNames;
|
76
75
|
var mergedProps = mergeProps(hoverProps, pressProps, others);
|
77
|
-
|
78
|
-
// console.log(`ROW: ${key} has parent focus: ${isParentFocused}`)
|
79
|
-
|
80
76
|
return ___EmotionJSX(Box, _extends({
|
81
77
|
ref: treeRowRef,
|
82
78
|
isRow: true,
|
83
79
|
alignItems: "center",
|
84
80
|
gap: "xs",
|
85
81
|
sx: {
|
86
|
-
flexGrow: 1
|
87
|
-
'& :focus': {
|
88
|
-
border: 'none'
|
89
|
-
}
|
82
|
+
flexGrow: 1
|
90
83
|
},
|
91
84
|
className: classNames,
|
92
85
|
key: "".concat(key, " box")
|
@@ -99,22 +92,15 @@ var TreeViewRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
99
92
|
size: 25,
|
100
93
|
title: "".concat(title, " expand or collapse button")
|
101
94
|
},
|
102
|
-
buttonProps:
|
95
|
+
buttonProps: {
|
103
96
|
'aria-label': "".concat(title, " expand or collapse button")
|
104
|
-
}
|
105
|
-
tabIndex: 0
|
106
|
-
}), !isParentFocused && {
|
107
|
-
tabIndex: -1
|
108
|
-
})
|
97
|
+
}
|
109
98
|
}), ___EmotionJSX(Box, {
|
110
99
|
isRow: true,
|
111
100
|
className: classNames,
|
112
101
|
alignItems: "center",
|
113
102
|
gap: "xs",
|
114
|
-
variant: "treeView.treeRow"
|
115
|
-
sx: !items && {
|
116
|
-
ml: '36px'
|
117
|
-
}
|
103
|
+
variant: "treeView.treeRow"
|
118
104
|
}, ___EmotionJSX(Icon, {
|
119
105
|
color: "focus",
|
120
106
|
icon: mainIcon,
|
@@ -135,7 +121,6 @@ TreeViewRow.propTypes = {
|
|
135
121
|
isSelected: PropTypes.bool,
|
136
122
|
isDisabled: PropTypes.bool,
|
137
123
|
isExpanded: PropTypes.bool,
|
138
|
-
isParentFocused: PropTypes.bool,
|
139
124
|
title: PropTypes.string,
|
140
125
|
items: PropTypes.arrayOf(PropTypes.shape({})),
|
141
126
|
iconButtonProps: PropTypes.shape({
|
@@ -1,105 +1,19 @@
|
|
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";
|
5
2
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
6
3
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
7
|
-
import React, { forwardRef,
|
8
|
-
import { useFocusRing } from '@react-aria/focus';
|
4
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
9
5
|
import { useOption } from '@react-aria/listbox';
|
10
|
-
import { mergeProps } from '@react-aria/utils';
|
11
6
|
import PropTypes from 'prop-types';
|
12
7
|
import { useTreeViewContext } from '../../context/TreeViewContext';
|
13
|
-
import { useStatusClasses } from '../../hooks';
|
14
8
|
import { Box, TreeViewItem } from '../../index';
|
15
9
|
import { SectionOrItemRender } from './TreeView';
|
16
|
-
import { sectionPressHandlers } from './TreeViewKeyboardDelegate';
|
17
10
|
import TreeViewRow from './TreeViewRow';
|
18
11
|
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
|
-
};
|
96
12
|
var TreeViewSection = /*#__PURE__*/forwardRef(function (props, ref) {
|
97
|
-
var
|
13
|
+
var _context;
|
98
14
|
var item = props.item,
|
99
15
|
items = props.items,
|
100
16
|
title = props.title,
|
101
|
-
focusManager = props.focusManager,
|
102
|
-
onKeyDown = props.onKeyDown,
|
103
17
|
level = props.level,
|
104
18
|
position = props.position,
|
105
19
|
setSize = props.setSize;
|
@@ -110,107 +24,51 @@ var TreeViewSection = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
110
24
|
return treeSectionRef.current;
|
111
25
|
});
|
112
26
|
var _useTreeViewContext = useTreeViewContext(),
|
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;
|
27
|
+
state = _useTreeViewContext.state;
|
121
28
|
var _useOption = useOption({
|
122
29
|
key: key
|
123
30
|
}, state, treeSectionRef),
|
124
31
|
optionProps = _useOption.optionProps,
|
125
32
|
isDisabled = _useOption.isDisabled,
|
126
33
|
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;
|
135
34
|
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;
|
171
35
|
return ___EmotionJSX(Box, _extends({
|
172
36
|
ref: treeSectionRef,
|
173
37
|
as: "li",
|
38
|
+
sx: {
|
39
|
+
':not(:last-child)': {
|
40
|
+
pb: 'sm'
|
41
|
+
}
|
42
|
+
},
|
174
43
|
"aria-expanded": isExpanded,
|
175
|
-
"aria-disabled": isDisabled
|
176
|
-
}, mergedProps, {
|
177
|
-
role: "treeitem",
|
178
|
-
variant: "treeView.wrapper",
|
179
|
-
className: classNames,
|
180
|
-
"aria-selected": isSelected,
|
44
|
+
"aria-disabled": isDisabled,
|
181
45
|
"aria-level": level,
|
182
46
|
"aria-setsize": setSize,
|
183
|
-
"aria-posinset": position + 1
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
tabIndex: lastFocusedItem === key ? 0 : -1
|
47
|
+
"aria-posinset": position + 1
|
48
|
+
}, optionProps, {
|
49
|
+
role: "treeitem",
|
50
|
+
"aria-selected": isSelected
|
188
51
|
}), ___EmotionJSX(TreeViewRow, {
|
189
52
|
item: item,
|
190
53
|
title: title,
|
191
54
|
items: items,
|
192
55
|
isExpanded: isExpanded,
|
193
56
|
isSelected: isSelected,
|
194
|
-
isDisabled: isDisabled
|
195
|
-
isParentFocused: isFocusedWithin
|
57
|
+
isDisabled: isDisabled
|
196
58
|
}), isExpanded && ___EmotionJSX(Box, {
|
197
59
|
as: "ul",
|
198
60
|
role: "group",
|
199
61
|
key: "".concat(item.key, " ul"),
|
200
62
|
sx: {
|
201
|
-
pl: 'md'
|
202
|
-
'& :focus': {
|
203
|
-
border: 'none'
|
204
|
-
}
|
63
|
+
pl: 'md'
|
205
64
|
}
|
206
|
-
}, _mapInstanceProperty(
|
65
|
+
}, _mapInstanceProperty(_context = _Array$from(items)).call(_context, function (_item, _index) {
|
207
66
|
var _item$value$items;
|
208
67
|
return SectionOrItemRender(((_item$value$items = _item.value.items) === null || _item$value$items === void 0 ? void 0 : _item$value$items.length) > 0, ___EmotionJSX(TreeViewSection, {
|
209
68
|
item: _item,
|
210
69
|
items: _item.children,
|
211
70
|
title: _item.value.title,
|
212
71
|
key: _item.value.title,
|
213
|
-
focusManager: focusManager,
|
214
72
|
level: level + 1,
|
215
73
|
position: _index,
|
216
74
|
setSize: items.length
|
@@ -218,7 +76,6 @@ var TreeViewSection = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
218
76
|
item: _item,
|
219
77
|
title: _item.value.title,
|
220
78
|
key: _item.value.title,
|
221
|
-
focusManager: focusManager,
|
222
79
|
level: level + 1,
|
223
80
|
position: _index,
|
224
81
|
setSize: items.length
|
@@ -231,8 +88,6 @@ TreeViewSection.propTypes = {
|
|
231
88
|
key: PropTypes.string
|
232
89
|
}),
|
233
90
|
title: PropTypes.string,
|
234
|
-
focusManager: PropTypes.shape({}),
|
235
|
-
onKeyDown: PropTypes.func,
|
236
91
|
level: PropTypes.number,
|
237
92
|
position: PropTypes.number,
|
238
93
|
setSize: PropTypes.number
|
@@ -35,15 +35,11 @@ var useImageUploadState = function useImageUploadState(inputRef) {
|
|
35
35
|
if (previewImage && previewImage !== defaultPreviewImage) {
|
36
36
|
setIsMenuOpen(true);
|
37
37
|
} else {
|
38
|
-
|
39
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.click();
|
38
|
+
inputRef.current.click();
|
40
39
|
}
|
41
40
|
}, [defaultPreviewImage, previewImage, inputRef]);
|
42
41
|
var handleInputChange = useCallback(function (event) {
|
43
42
|
var _event$target;
|
44
|
-
if (!event.target.files) {
|
45
|
-
return;
|
46
|
-
}
|
47
43
|
var eventFileType = (_event$target = event.target) === null || _event$target === void 0 || (_event$target = _event$target.files[0]) === null || _event$target === void 0 || (_event$target = _event$target.type) === null || _event$target === void 0 ? void 0 : _event$target.split('/')[0];
|
48
44
|
if (fileTypes !== null && fileTypes !== void 0 && _includesInstanceProperty(fileTypes).call(fileTypes, eventFileType)) {
|
49
45
|
if (onChange && typeof onChange === 'function') {
|
@@ -56,8 +52,9 @@ var useImageUploadState = function useImageUploadState(inputRef) {
|
|
56
52
|
var _event$target2;
|
57
53
|
setIsImageType(true);
|
58
54
|
var reader = new FileReader();
|
59
|
-
reader.onload = function () {
|
60
|
-
|
55
|
+
reader.onload = function (_ref) {
|
56
|
+
var result = _ref.target.result;
|
57
|
+
setPreviewImage(result);
|
61
58
|
};
|
62
59
|
reader.readAsDataURL((_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.files[0]);
|
63
60
|
} else {
|
@@ -79,8 +76,8 @@ var useImageUploadState = function useImageUploadState(inputRef) {
|
|
79
76
|
return setPreviewImage(defaultPreviewImage);
|
80
77
|
}, [defaultPreviewImage]);
|
81
78
|
var showFileDialog = useCallback(function () {
|
82
|
-
var _inputRef$
|
83
|
-
return inputRef === null || inputRef === void 0 || (_inputRef$
|
79
|
+
var _inputRef$current;
|
80
|
+
return inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.click();
|
84
81
|
}, [inputRef]);
|
85
82
|
var handleLabelClick = useCallback(function (e) {
|
86
83
|
e.preventDefault();
|
@@ -1,4 +1,14 @@
|
|
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
|
+
*/
|
2
12
|
var useModalState = function useModalState() {
|
3
13
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
4
14
|
var isDefaultOpen = props.isDefaultOpen,
|
@@ -22,7 +22,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
22
22
|
} : {
|
23
23
|
name: "zxbwtf-GlobalTestStyles",
|
24
24
|
styles: ".is-disabled{opacity:0.5;pointer-events:none;};label:GlobalTestStyles;",
|
25
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
25
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91dGlscy90ZXN0VXRpbHMvdGVzdFdyYXBwZXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBVVMiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL3V0aWxzL3Rlc3RVdGlscy90ZXN0V3JhcHBlci5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCBmcm9tICdyZWFjdCc7XG5pbXBvcnQgeyBjc3MsIEdsb2JhbCB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcbmltcG9ydCB7IHJlbmRlciB9IGZyb20gJ0B0ZXN0aW5nLWxpYnJhcnkvcmVhY3QnO1xuaW1wb3J0IHsgVGhlbWVQcm92aWRlciB9IGZyb20gJ3RoZW1lLXVpJztcblxuaW1wb3J0IHRoZW1lIGZyb20gJy4uLy4uL3N0eWxlcy90aGVtZSc7XG5cbmNvbnN0IEdsb2JhbFRlc3RTdHlsZXMgPSAoKSA9PiAoXG4gIDxHbG9iYWxcbiAgICBzdHlsZXM9e1xuICAgICAgY3NzYFxuICAgICAgICAuaXMtZGlzYWJsZWQge1xuICAgICAgICAgIG9wYWNpdHk6IDAuNTtcbiAgICAgICAgICBwb2ludGVyLWV2ZW50czogbm9uZTtcbiAgICAgICAgfVxuICAgICAgYFxuICAgIH1cbiAgLz5cbik7XG5cbi8qKlxuICogVE9ETzogQ2hhbmdlIEplc3QgY29uZmlnIHNvIHRoaXMgZG9lc24ndCBoYXZlIHRvIGJlIGltcG9ydGVkIHJlbGF0aXZlbHkuLi5cbiAqIGh0dHBzOi8vdGVzdGluZy1saWJyYXJ5LmNvbS9kb2NzL3JlYWN0LXRlc3RpbmctbGlicmFyeS9zZXR1cC8jY29uZmlndXJpbmctamVzdC13aXRoLXRlc3QtdXRpbHNcbiAqXG4gKiBVc2UgdGhpcyB3cmFwcGVyIHdoZW4gdGVzdGluZyB0aGUgdGhlbWUgb3V0cHV0IGZvclxuICogYSBjb21wb25lbnQgdXNpbmcgLnRvSGF2ZVN0eWxlIG9yIC50b0hhdmVTdHlsZVJ1bGVcbiAqXG4gKiBTZWUgQnV0dG9uLnRlc3QuanMgYXMgYW4gZXhhbXBsZSBmb3IgaG93IHRvIGFwcGx5IGNvbmRpdGlvbmFsIGNsYXNzZXMgYW5kIHRoZW4gdGVzdGluZyB0aGF0XG4gKiB0aG9zZSBjbGFzc2VzIGhhdmUgdGhlIGFwcHJvcHJpYXRlIHN0eWxlcyB0aWVkIHRvIHRoZW0gaW4gdGhlIHRoZW1lLlxuICovXG5jb25zdCBXcmFwcGVyID0gKHsgY2hpbGRyZW4gfSkgPT4ge1xuICByZXR1cm4gKFxuICAgIDxUaGVtZVByb3ZpZGVyIHRoZW1lPXt0aGVtZX0+XG4gICAgICA8R2xvYmFsVGVzdFN0eWxlcyAvPlxuICAgICAge2NoaWxkcmVufVxuICAgIDwvVGhlbWVQcm92aWRlcj5cbiAgKTtcbn07XG5cbmNvbnN0IGN1c3RvbVJlbmRlciA9ICh1aSwgb3B0aW9ucykgPT4gcmVuZGVyKHVpLCB7IHdyYXBwZXI6IFdyYXBwZXIsIC4uLm9wdGlvbnMgfSk7XG5cbi8vIHJlLWV4cG9ydCBldmVyeXRoaW5nXG5leHBvcnQgKiBmcm9tICdAdGVzdGluZy1saWJyYXJ5L3JlYWN0JztcblxuLy8gb3ZlcnJpZGUgcmVuZGVyIG1ldGhvZFxuZXhwb3J0IHsgY3VzdG9tUmVuZGVyIGFzIHJlbmRlciB9O1xuIl19 */",
|
26
26
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
27
27
|
};
|
28
28
|
var GlobalTestStyles = function GlobalTestStyles() {
|
@@ -41,7 +41,6 @@ var GlobalTestStyles = function GlobalTestStyles() {
|
|
41
41
|
* See Button.test.js as an example for how to apply conditional classes and then testing that
|
42
42
|
* those classes have the appropriate styles tied to them in the theme.
|
43
43
|
*/
|
44
|
-
|
45
44
|
var Wrapper = function Wrapper(_ref2) {
|
46
45
|
var children = _ref2.children;
|
47
46
|
return ___EmotionJSX(ThemeProvider, {
|
@@ -54,7 +53,7 @@ var customRender = function customRender(ui, options) {
|
|
54
53
|
}, options));
|
55
54
|
};
|
56
55
|
|
57
|
-
// re-export everything
|
56
|
+
// re-export everything
|
58
57
|
export * from '@testing-library/react';
|
59
58
|
|
60
59
|
// override render method
|