@pingux/astro 2.32.0-alpha.12 → 2.32.0-alpha.13
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 +47 -14
- 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/useImageUploadState/index.d.ts +1 -0
- package/lib/cjs/hooks/useImageUploadState/useImageUploadState.d.ts +28 -0
- package/lib/cjs/hooks/useImageUploadState/useImageUploadState.js +9 -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/utils/testUtils/setupTests.d.ts +4 -0
- package/lib/cjs/utils/testUtils/testAxe.d.ts +2 -0
- package/lib/cjs/utils/testUtils/testTheme.d.ts +21 -0
- package/lib/cjs/utils/testUtils/testWrapper.d.ts +5 -0
- package/lib/cjs/utils/testUtils/testWrapper.js +3 -2
- package/lib/components/ImageUploadField/ImageUploadField.test.js +47 -14
- 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/useImageUploadState/useImageUploadState.js +9 -6
- package/lib/hooks/useModalState/useModalState.js +0 -10
- package/lib/utils/testUtils/testWrapper.js +3 -2
- package/package.json +1 -1
@@ -8,25 +8,114 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
8
8
|
_Object$defineProperty(exports, "__esModule", {
|
9
9
|
value: true
|
10
10
|
});
|
11
|
-
exports["default"] = void 0;
|
11
|
+
exports.removeRefFromArrayHelper = exports.onKeyDownSection = exports["default"] = exports.addRefToArrayHelper = void 0;
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
13
|
+
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
14
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
15
|
+
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
13
16
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
14
17
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
15
18
|
var _react = _interopRequireWildcard(require("react"));
|
19
|
+
var _focus = require("@react-aria/focus");
|
16
20
|
var _listbox = require("@react-aria/listbox");
|
21
|
+
var _utils = require("@react-aria/utils");
|
17
22
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
18
23
|
var _TreeViewContext = require("../../context/TreeViewContext");
|
24
|
+
var _hooks = require("../../hooks");
|
19
25
|
var _index2 = require("../../index");
|
20
26
|
var _TreeView = require("./TreeView");
|
27
|
+
var _TreeViewKeyboardDelegate = require("./TreeViewKeyboardDelegate");
|
21
28
|
var _TreeViewRow = _interopRequireDefault(require("./TreeViewRow"));
|
22
29
|
var _react2 = require("@emotion/react");
|
23
30
|
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
31
|
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; }
|
32
|
+
var onKeyDownSection = function onKeyDownSection(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength, isFocused) {
|
33
|
+
switch (e.which) {
|
34
|
+
case 9:
|
35
|
+
if (isFocused) {
|
36
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onTabPress(e, refArray, focusManager, true, key);
|
37
|
+
}
|
38
|
+
break;
|
39
|
+
case 13:
|
40
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onEnterPress(e, state, key);
|
41
|
+
break;
|
42
|
+
case 32:
|
43
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onSpacePress(e, tree, key, isSelected);
|
44
|
+
break;
|
45
|
+
case 33:
|
46
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onPageUpPress(e, key, flatKeyArray, refArray, pageLength);
|
47
|
+
break;
|
48
|
+
case 34:
|
49
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onPageDownPress(e, key, flatKeyArray, refArray, pageLength);
|
50
|
+
break;
|
51
|
+
case 36:
|
52
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onHomePress(key, flatKeyArray, refArray);
|
53
|
+
e.preventDefault();
|
54
|
+
e.stopPropagation();
|
55
|
+
break;
|
56
|
+
case 35:
|
57
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onEndPress(key, flatKeyArray, refArray);
|
58
|
+
e.preventDefault();
|
59
|
+
e.stopPropagation();
|
60
|
+
break;
|
61
|
+
case 37:
|
62
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onLeftPress(e, focusManager, state, key, isExpanded, refArray);
|
63
|
+
break;
|
64
|
+
case 38:
|
65
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onUpPress(e, key, refArray, flatKeyArray);
|
66
|
+
e.preventDefault();
|
67
|
+
e.stopPropagation();
|
68
|
+
break;
|
69
|
+
case 39:
|
70
|
+
if (isFocused) {
|
71
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onRightPress(e, focusManager, state, key, isExpanded, refArray);
|
72
|
+
}
|
73
|
+
break;
|
74
|
+
case 40:
|
75
|
+
_TreeViewKeyboardDelegate.sectionPressHandlers.onDownPress(e, key, refArray, flatKeyArray);
|
76
|
+
e.preventDefault();
|
77
|
+
e.stopPropagation();
|
78
|
+
break;
|
79
|
+
default:
|
80
|
+
/* istanbul ignore next */
|
81
|
+
break;
|
82
|
+
}
|
83
|
+
};
|
84
|
+
exports.onKeyDownSection = onKeyDownSection;
|
85
|
+
var removeRefFromArrayHelper = function removeRefFromArrayHelper(prevState, keyToRemove) {
|
86
|
+
if ((0, _some["default"])(prevState).call(prevState, function (item) {
|
87
|
+
return item.key === keyToRemove;
|
88
|
+
})) {
|
89
|
+
var _context;
|
90
|
+
var newArray = (0, _concat["default"])(_context = []).call(_context, (0, _filter["default"])(prevState).call(prevState, function (_item) {
|
91
|
+
return _item.key !== keyToRemove;
|
92
|
+
}));
|
93
|
+
return newArray;
|
94
|
+
}
|
95
|
+
return prevState;
|
96
|
+
};
|
97
|
+
exports.removeRefFromArrayHelper = removeRefFromArrayHelper;
|
98
|
+
var addRefToArrayHelper = function addRefToArrayHelper(prevState, keyToAdd, refToAdd) {
|
99
|
+
if (!(0, _some["default"])(prevState).call(prevState, function (i) {
|
100
|
+
return i.key === keyToAdd;
|
101
|
+
})) {
|
102
|
+
var _context2;
|
103
|
+
var thisObj = {
|
104
|
+
key: keyToAdd,
|
105
|
+
thisRef: refToAdd
|
106
|
+
};
|
107
|
+
return (0, _concat["default"])(_context2 = []).call(_context2, prevState, [thisObj]);
|
108
|
+
}
|
109
|
+
return prevState;
|
110
|
+
};
|
111
|
+
exports.addRefToArrayHelper = addRefToArrayHelper;
|
25
112
|
var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
26
|
-
var
|
113
|
+
var _context3;
|
27
114
|
var item = props.item,
|
28
115
|
items = props.items,
|
29
116
|
title = props.title,
|
117
|
+
focusManager = props.focusManager,
|
118
|
+
onKeyDown = props.onKeyDown,
|
30
119
|
level = props.level,
|
31
120
|
position = props.position,
|
32
121
|
setSize = props.setSize;
|
@@ -37,51 +126,107 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
37
126
|
return treeSectionRef.current;
|
38
127
|
});
|
39
128
|
var _useTreeViewContext = (0, _TreeViewContext.useTreeViewContext)(),
|
40
|
-
state = _useTreeViewContext.state
|
129
|
+
state = _useTreeViewContext.state,
|
130
|
+
tree = _useTreeViewContext.tree,
|
131
|
+
refArray = _useTreeViewContext.refArray,
|
132
|
+
setRefs = _useTreeViewContext.setRefs,
|
133
|
+
flatKeyArray = _useTreeViewContext.flatKeyArray,
|
134
|
+
pageLength = _useTreeViewContext.pageLength,
|
135
|
+
setLastFocusedItem = _useTreeViewContext.setLastFocusedItem,
|
136
|
+
lastFocusedItem = _useTreeViewContext.lastFocusedItem;
|
41
137
|
var _useOption = (0, _listbox.useOption)({
|
42
138
|
key: key
|
43
139
|
}, state, treeSectionRef),
|
44
140
|
optionProps = _useOption.optionProps,
|
45
141
|
isDisabled = _useOption.isDisabled,
|
46
142
|
isSelected = _useOption.isSelected;
|
143
|
+
var _useFocusRing = (0, _focus.useFocusRing)(),
|
144
|
+
focusProps = _useFocusRing.focusProps,
|
145
|
+
isFocused = _useFocusRing.isFocused;
|
146
|
+
var _useFocusRing2 = (0, _focus.useFocusRing)({
|
147
|
+
within: true
|
148
|
+
}),
|
149
|
+
focusPropsWithin = _useFocusRing2.focusProps,
|
150
|
+
isFocusedWithin = _useFocusRing2.isFocused;
|
47
151
|
var isExpanded = state.expandedKeys.has(key);
|
152
|
+
var onKeyDownFunction = function onKeyDownFunction(e) {
|
153
|
+
onKeyDownSection(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength, isFocused);
|
154
|
+
if (onKeyDown) {
|
155
|
+
onKeyDown(e, key);
|
156
|
+
}
|
157
|
+
};
|
158
|
+
var addRefToArray = function addRefToArray(thisKey, thisRef) {
|
159
|
+
setRefs(function (prev) {
|
160
|
+
return addRefToArrayHelper(prev, thisKey, thisRef);
|
161
|
+
});
|
162
|
+
};
|
163
|
+
var removeRefFromArray = function removeRefFromArray() {
|
164
|
+
setRefs(function (prev) {
|
165
|
+
return removeRefFromArrayHelper(prev, key);
|
166
|
+
});
|
167
|
+
};
|
168
|
+
|
169
|
+
// adds and removes refs on mount and dismount
|
170
|
+
(0, _react.useEffect)(function () {
|
171
|
+
// this runs on mount
|
172
|
+
addRefToArray(key, treeSectionRef);
|
173
|
+
return function () {
|
174
|
+
// this runs on cleanup
|
175
|
+
removeRefFromArray(key, refArray);
|
176
|
+
};
|
177
|
+
}, []);
|
178
|
+
var mergedProps = (0, _utils.mergeProps)(focusPropsWithin, focusProps, optionProps, {
|
179
|
+
onFocus: function onFocus() {
|
180
|
+
return setLastFocusedItem(key);
|
181
|
+
}
|
182
|
+
});
|
183
|
+
var _useStatusClasses = (0, _hooks.useStatusClasses)('', {
|
184
|
+
isFocused: isFocused
|
185
|
+
}),
|
186
|
+
classNames = _useStatusClasses.classNames;
|
48
187
|
return (0, _react2.jsx)(_index2.Box, (0, _extends2["default"])({
|
49
188
|
ref: treeSectionRef,
|
50
189
|
as: "li",
|
51
|
-
sx: {
|
52
|
-
':not(:last-child)': {
|
53
|
-
pb: 'sm'
|
54
|
-
}
|
55
|
-
},
|
56
190
|
"aria-expanded": isExpanded,
|
57
|
-
"aria-disabled": isDisabled
|
191
|
+
"aria-disabled": isDisabled
|
192
|
+
}, mergedProps, {
|
193
|
+
role: "treeitem",
|
194
|
+
variant: "treeView.wrapper",
|
195
|
+
className: classNames,
|
196
|
+
"aria-selected": isSelected,
|
58
197
|
"aria-level": level,
|
59
198
|
"aria-setsize": setSize,
|
60
|
-
"aria-posinset": position + 1
|
61
|
-
|
62
|
-
|
63
|
-
|
199
|
+
"aria-posinset": position + 1,
|
200
|
+
onKeyDown: function onKeyDown(e) {
|
201
|
+
return onKeyDownFunction(e);
|
202
|
+
},
|
203
|
+
tabIndex: lastFocusedItem === key ? 0 : -1
|
64
204
|
}), (0, _react2.jsx)(_TreeViewRow["default"], {
|
65
205
|
item: item,
|
66
206
|
title: title,
|
67
207
|
items: items,
|
68
208
|
isExpanded: isExpanded,
|
69
209
|
isSelected: isSelected,
|
70
|
-
isDisabled: isDisabled
|
210
|
+
isDisabled: isDisabled,
|
211
|
+
isParentFocused: isFocusedWithin
|
71
212
|
}), isExpanded && (0, _react2.jsx)(_index2.Box, {
|
72
213
|
as: "ul",
|
73
214
|
role: "group",
|
74
215
|
key: "".concat(item.key, " ul"),
|
75
216
|
sx: {
|
76
|
-
pl: 'md'
|
217
|
+
pl: 'md',
|
218
|
+
'& :focus': {
|
219
|
+
border: 'none'
|
220
|
+
}
|
77
221
|
}
|
78
|
-
}, (0, _map["default"])(
|
222
|
+
}, (0, _map["default"])(_context3 = (0, _from["default"])(items)).call(_context3, function (_item, _index) {
|
79
223
|
var _item$value$items;
|
80
224
|
return (0, _TreeView.SectionOrItemRender)(((_item$value$items = _item.value.items) === null || _item$value$items === void 0 ? void 0 : _item$value$items.length) > 0, (0, _react2.jsx)(TreeViewSection, {
|
81
225
|
item: _item,
|
82
226
|
items: _item.children,
|
83
227
|
title: _item.value.title,
|
84
228
|
key: _item.value.title,
|
229
|
+
focusManager: focusManager,
|
85
230
|
level: level + 1,
|
86
231
|
position: _index,
|
87
232
|
setSize: items.length
|
@@ -89,6 +234,7 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
89
234
|
item: _item,
|
90
235
|
title: _item.value.title,
|
91
236
|
key: _item.value.title,
|
237
|
+
focusManager: focusManager,
|
92
238
|
level: level + 1,
|
93
239
|
position: _index,
|
94
240
|
setSize: items.length
|
@@ -101,6 +247,8 @@ TreeViewSection.propTypes = {
|
|
101
247
|
key: _propTypes["default"].string
|
102
248
|
}),
|
103
249
|
title: _propTypes["default"].string,
|
250
|
+
focusManager: _propTypes["default"].shape({}),
|
251
|
+
onKeyDown: _propTypes["default"].func,
|
104
252
|
level: _propTypes["default"].number,
|
105
253
|
position: _propTypes["default"].number,
|
106
254
|
setSize: _propTypes["default"].number
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports["default"] = void 0;
|
9
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
var _focus = require("@react-aria/focus");
|
12
|
+
var _react2 = require("@emotion/react");
|
13
|
+
var TreeViewWrapper = function TreeViewWrapper(props) {
|
14
|
+
var children = props.children;
|
15
|
+
var items = (0, _map["default"])(children).call(children, function (child) {
|
16
|
+
return {
|
17
|
+
item: child,
|
18
|
+
key: child.key
|
19
|
+
};
|
20
|
+
});
|
21
|
+
return (0, _react2.jsx)(_focus.FocusScope, {
|
22
|
+
restoreFocus: false,
|
23
|
+
contain: false
|
24
|
+
}, (0, _map["default"])(items).call(items, function (_ref) {
|
25
|
+
var item = _ref.item,
|
26
|
+
key = _ref.key;
|
27
|
+
return (0, _react2.jsx)(FocusableItem, {
|
28
|
+
key: key
|
29
|
+
}, item);
|
30
|
+
}));
|
31
|
+
};
|
32
|
+
var FocusableItem = function FocusableItem(props) {
|
33
|
+
var focusManager = (0, _focus.useFocusManager)();
|
34
|
+
var childWithFocusHandle = /*#__PURE__*/_react["default"].cloneElement(props.children, {
|
35
|
+
focusManager: focusManager
|
36
|
+
});
|
37
|
+
return childWithFocusHandle;
|
38
|
+
};
|
39
|
+
var _default = TreeViewWrapper;
|
40
|
+
exports["default"] = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as useImageUploadState } from './useImageUploadState';
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React, { RefObject } from 'react';
|
2
|
+
interface ImageUploadStateProps {
|
3
|
+
previewImage?: string;
|
4
|
+
defaultPreviewImage?: string | null;
|
5
|
+
fileTypes?: string[];
|
6
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
7
|
+
previewHeight?: string;
|
8
|
+
previewWidth?: string;
|
9
|
+
}
|
10
|
+
declare const useImageUploadState: (inputRef: RefObject<HTMLInputElement | null>, props?: ImageUploadStateProps) => {
|
11
|
+
defaultPreviewImage: string | null;
|
12
|
+
defaultPreviewNode: string | null | undefined;
|
13
|
+
fileName: string;
|
14
|
+
handleInputChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
15
|
+
handleLabelClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
16
|
+
handleOpenMenuChange: (isOpen: boolean) => void;
|
17
|
+
isImageType: boolean;
|
18
|
+
isMenuOpen: boolean;
|
19
|
+
pressPreviewButton: () => void;
|
20
|
+
previewImage: string | null;
|
21
|
+
removePreview: () => void;
|
22
|
+
showFileDialog: () => void | undefined;
|
23
|
+
widthHeightSx: {
|
24
|
+
height: string | undefined;
|
25
|
+
width: string | undefined;
|
26
|
+
};
|
27
|
+
};
|
28
|
+
export default useImageUploadState;
|
@@ -43,11 +43,15 @@ var useImageUploadState = function useImageUploadState(inputRef) {
|
|
43
43
|
if (previewImage && previewImage !== defaultPreviewImage) {
|
44
44
|
setIsMenuOpen(true);
|
45
45
|
} else {
|
46
|
-
|
46
|
+
var _inputRef$current;
|
47
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.click();
|
47
48
|
}
|
48
49
|
}, [defaultPreviewImage, previewImage, inputRef]);
|
49
50
|
var handleInputChange = (0, _react.useCallback)(function (event) {
|
50
51
|
var _event$target;
|
52
|
+
if (!event.target.files) {
|
53
|
+
return;
|
54
|
+
}
|
51
55
|
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];
|
52
56
|
if (fileTypes !== null && fileTypes !== void 0 && (0, _includes["default"])(fileTypes).call(fileTypes, eventFileType)) {
|
53
57
|
if (onChange && typeof onChange === 'function') {
|
@@ -60,9 +64,8 @@ var useImageUploadState = function useImageUploadState(inputRef) {
|
|
60
64
|
var _event$target2;
|
61
65
|
setIsImageType(true);
|
62
66
|
var reader = new FileReader();
|
63
|
-
reader.onload = function (
|
64
|
-
|
65
|
-
setPreviewImage(result);
|
67
|
+
reader.onload = function () {
|
68
|
+
setPreviewImage(reader.result);
|
66
69
|
};
|
67
70
|
reader.readAsDataURL((_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.files[0]);
|
68
71
|
} else {
|
@@ -84,8 +87,8 @@ var useImageUploadState = function useImageUploadState(inputRef) {
|
|
84
87
|
return setPreviewImage(defaultPreviewImage);
|
85
88
|
}, [defaultPreviewImage]);
|
86
89
|
var showFileDialog = (0, _react.useCallback)(function () {
|
87
|
-
var _inputRef$
|
88
|
-
return inputRef === null || inputRef === void 0 || (_inputRef$
|
90
|
+
var _inputRef$current2;
|
91
|
+
return inputRef === null || inputRef === void 0 || (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.click();
|
89
92
|
}, [inputRef]);
|
90
93
|
var handleLabelClick = (0, _react.useCallback)(function (e) {
|
91
94
|
e.preventDefault();
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useModalState';
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { OverlayTriggerState } from 'react-stately';
|
2
|
+
interface UseModalStateProps {
|
3
|
+
isDefaultOpen?: boolean;
|
4
|
+
isOpen?: boolean;
|
5
|
+
onOpenChange?: (isOpen: boolean) => void;
|
6
|
+
}
|
7
|
+
interface UseModalState {
|
8
|
+
/**
|
9
|
+
* Returns state-related data and functions for use with a Modal component.
|
10
|
+
* @param {Object} [props] Properties provided to the state
|
11
|
+
*
|
12
|
+
* `props.isDefaultOpen`: boolean - Whether the modal is open by default (uncontrolled).
|
13
|
+
* `props.isOpen`: boolean - Whether the modal is currently open (controlled).
|
14
|
+
* `props.onOpenChange`: boolean - Handler that is called when the open state changes.
|
15
|
+
*
|
16
|
+
* @returns {Object} `{ isOpen: Boolean, open: Function, close: Function, toggle: Function }`
|
17
|
+
*/
|
18
|
+
(props?: UseModalStateProps): OverlayTriggerState;
|
19
|
+
}
|
20
|
+
declare const useModalState: UseModalState;
|
21
|
+
export default useModalState;
|
@@ -6,15 +6,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports["default"] = void 0;
|
8
8
|
var _reactStately = require("react-stately");
|
9
|
-
/**
|
10
|
-
* Returns state-related data and functions for use with a Modal component.
|
11
|
-
* @param {Object} [props] Properties provided to the state
|
12
|
-
* @param {Boolean} [props.isDefaultOpen] Whether the modal is open by default (uncontrolled).
|
13
|
-
* @param {Boolean} [props.isOpen] Whether the modal is currently open (controlled).
|
14
|
-
* @param {Function} [props.onOpenChange] Handler that is called when the open state changes.
|
15
|
-
* `(isOpen: boolean) => void`
|
16
|
-
* @returns {Object} `{ isOpen: Boolean, open: Function, close: Function, toggle: Function }`
|
17
|
-
*/
|
18
9
|
var useModalState = function useModalState() {
|
19
10
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
20
11
|
var isDefaultOpen = props.isDefaultOpen,
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
fontWeights: {
|
3
|
+
0: number;
|
4
|
+
1: number;
|
5
|
+
};
|
6
|
+
fontSizes: {
|
7
|
+
md: string;
|
8
|
+
lg: string;
|
9
|
+
};
|
10
|
+
text: {
|
11
|
+
base: {
|
12
|
+
fontWeight: number;
|
13
|
+
fontSize: string;
|
14
|
+
};
|
15
|
+
title: {
|
16
|
+
fontWeight: number;
|
17
|
+
fontSize: string;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export default _default;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { RenderOptions } from '@testing-library/react';
|
3
|
+
declare const customRender: (ui: React.ReactElement, options?: RenderOptions) => import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement>;
|
4
|
+
export * from '@testing-library/react';
|
5
|
+
export { customRender as render };
|
@@ -43,7 +43,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
43
43
|
} : {
|
44
44
|
name: "zxbwtf-GlobalTestStyles",
|
45
45
|
styles: ".is-disabled{opacity:0.5;pointer-events:none;};label:GlobalTestStyles;",
|
46
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
46
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy91dGlscy90ZXN0VXRpbHMvdGVzdFdyYXBwZXIudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVVTIiwiZmlsZSI6Ii4uLy4uLy4uLy4uL3NyYy91dGlscy90ZXN0VXRpbHMvdGVzdFdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IFJlYWN0Tm9kZSB9IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IGNzcywgR2xvYmFsIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgcmVuZGVyLCBSZW5kZXJPcHRpb25zIH0gZnJvbSAnQHRlc3RpbmctbGlicmFyeS9yZWFjdCc7XG5pbXBvcnQgeyBUaGVtZVByb3ZpZGVyIH0gZnJvbSAndGhlbWUtdWknO1xuXG5pbXBvcnQgdGhlbWUgZnJvbSAnLi4vLi4vc3R5bGVzL3RoZW1lJztcblxuY29uc3QgR2xvYmFsVGVzdFN0eWxlczogUmVhY3QuRkMgPSAoKSA9PiAoXG4gIDxHbG9iYWxcbiAgICBzdHlsZXM9e1xuICAgICAgY3NzYFxuICAgICAgICAuaXMtZGlzYWJsZWQge1xuICAgICAgICAgIG9wYWNpdHk6IDAuNTtcbiAgICAgICAgICBwb2ludGVyLWV2ZW50czogbm9uZTtcbiAgICAgICAgfVxuICAgICAgYFxuICAgIH1cbiAgLz5cbik7XG5cbi8qKlxuICogVE9ETzogQ2hhbmdlIEplc3QgY29uZmlnIHNvIHRoaXMgZG9lc24ndCBoYXZlIHRvIGJlIGltcG9ydGVkIHJlbGF0aXZlbHkuLi5cbiAqIGh0dHBzOi8vdGVzdGluZy1saWJyYXJ5LmNvbS9kb2NzL3JlYWN0LXRlc3RpbmctbGlicmFyeS9zZXR1cC8jY29uZmlndXJpbmctamVzdC13aXRoLXRlc3QtdXRpbHNcbiAqXG4gKiBVc2UgdGhpcyB3cmFwcGVyIHdoZW4gdGVzdGluZyB0aGUgdGhlbWUgb3V0cHV0IGZvclxuICogYSBjb21wb25lbnQgdXNpbmcgLnRvSGF2ZVN0eWxlIG9yIC50b0hhdmVTdHlsZVJ1bGVcbiAqXG4gKiBTZWUgQnV0dG9uLnRlc3QuanMgYXMgYW4gZXhhbXBsZSBmb3IgaG93IHRvIGFwcGx5IGNvbmRpdGlvbmFsIGNsYXNzZXMgYW5kIHRoZW4gdGVzdGluZyB0aGF0XG4gKiB0aG9zZSBjbGFzc2VzIGhhdmUgdGhlIGFwcHJvcHJpYXRlIHN0eWxlcyB0aWVkIHRvIHRoZW0gaW4gdGhlIHRoZW1lLlxuICovXG5cbmludGVyZmFjZSBXcmFwcGVyUHJvcHMge1xuICBjaGlsZHJlbjogUmVhY3ROb2RlO1xufVxuXG5jb25zdCBXcmFwcGVyOiBSZWFjdC5GQzxXcmFwcGVyUHJvcHM+ID0gKHsgY2hpbGRyZW4gfSkgPT4gKFxuICA8VGhlbWVQcm92aWRlciB0aGVtZT17dGhlbWV9PlxuICAgIDxHbG9iYWxUZXN0U3R5bGVzIC8+XG4gICAge2NoaWxkcmVufVxuICA8L1RoZW1lUHJvdmlkZXI+XG4pO1xuXG5jb25zdCBjdXN0b21SZW5kZXIgPSAodWk6IFJlYWN0LlJlYWN0RWxlbWVudCwgb3B0aW9ucz86IFJlbmRlck9wdGlvbnMpID0+IHJlbmRlcih1aSxcbiAgeyB3cmFwcGVyOiBXcmFwcGVyIGFzIFJlYWN0LkZDLCAuLi5vcHRpb25zIH0sXG4pO1xuXG4vLyByZS1leHBvcnQgZXZlcnl0aGluZyAtXG5leHBvcnQgKiBmcm9tICdAdGVzdGluZy1saWJyYXJ5L3JlYWN0JztcblxuLy8gb3ZlcnJpZGUgcmVuZGVyIG1ldGhvZFxuZXhwb3J0IHsgY3VzdG9tUmVuZGVyIGFzIHJlbmRlciB9O1xuIl19 */",
|
47
47
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
48
48
|
};
|
49
49
|
var GlobalTestStyles = function GlobalTestStyles() {
|
@@ -62,6 +62,7 @@ var GlobalTestStyles = function GlobalTestStyles() {
|
|
62
62
|
* See Button.test.js as an example for how to apply conditional classes and then testing that
|
63
63
|
* those classes have the appropriate styles tied to them in the theme.
|
64
64
|
*/
|
65
|
+
|
65
66
|
var Wrapper = function Wrapper(_ref2) {
|
66
67
|
var children = _ref2.children;
|
67
68
|
return (0, _react2.jsx)(_themeUi.ThemeProvider, {
|
@@ -74,7 +75,7 @@ var customRender = function customRender(ui, options) {
|
|
74
75
|
}, options));
|
75
76
|
};
|
76
77
|
|
77
|
-
// re-export everything
|
78
|
+
// re-export everything -
|
78
79
|
|
79
80
|
// override render method
|
80
81
|
exports.render = customRender;
|