@pingux/astro 2.50.0 → 2.51.0-alpha.1
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/FieldHelperText/FieldHelperText.styles.d.ts +832 -2
- package/lib/cjs/components/ListBox/ListBox.d.ts +11 -0
- package/lib/cjs/components/ListBox/ListBox.js +7 -45
- package/lib/cjs/components/ListBox/ListBox.styles.d.ts +3 -0
- package/lib/cjs/components/ListBox/ListBox.test.d.ts +1 -0
- package/lib/cjs/components/ListBox/ListBox.test.js +29 -28
- package/lib/cjs/components/ListBox/ListBoxContext.d.ts +2 -0
- package/lib/cjs/components/ListBox/ListBoxContext.js +1 -1
- package/lib/cjs/components/ListBox/ListBoxSection.d.ts +10 -0
- package/lib/cjs/components/ListBox/ListBoxSection.js +4 -4
- package/lib/cjs/components/ListBox/Option.d.ts +4 -0
- package/lib/cjs/components/ListBox/Option.js +11 -33
- package/lib/cjs/components/ListBox/index.d.ts +2 -0
- package/lib/cjs/components/ListView/ListView.js +26 -10
- package/lib/cjs/components/ListView/ListView.stories.js +179 -13
- package/lib/cjs/components/ListView/ListView.test.js +300 -35
- package/lib/cjs/components/ListView/ListViewExpandableItem.js +100 -0
- package/lib/cjs/components/ListView/ListViewFocusWrapper.js +117 -0
- package/lib/cjs/components/ListView/ListViewItem.js +24 -16
- package/lib/cjs/components/ListViewItem/ListViewItem.styles.js +34 -1
- package/lib/cjs/components/Text/Text.styles.d.ts +1664 -18
- package/lib/cjs/hooks/useExpandableListViewItem/index.d.ts +1 -0
- package/lib/cjs/hooks/useExpandableListViewItem/index.js +14 -0
- package/lib/cjs/hooks/useExpandableListViewItem/useExpandableListViewItem.d.ts +51 -0
- package/lib/cjs/hooks/useExpandableListViewItem/useExpandableListViewItem.js +237 -0
- package/lib/cjs/hooks/useSelectField/useSelectField.d.ts +2 -2
- package/lib/cjs/hooks/useSelectField/useSelectField.js +1 -1
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +27 -16
- package/lib/cjs/types/listBox.d.ts +49 -0
- package/lib/cjs/types/listBox.js +6 -0
- package/lib/components/ListBox/ListBox.js +8 -46
- package/lib/components/ListBox/ListBox.test.js +23 -28
- package/lib/components/ListBox/ListBoxContext.js +1 -1
- package/lib/components/ListBox/ListBoxSection.js +4 -4
- package/lib/components/ListBox/Option.js +11 -33
- package/lib/components/ListView/ListView.js +26 -10
- package/lib/components/ListView/ListView.stories.js +177 -14
- package/lib/components/ListView/ListView.test.js +300 -35
- package/lib/components/ListView/ListViewExpandableItem.js +86 -0
- package/lib/components/ListView/ListViewFocusWrapper.js +102 -0
- package/lib/components/ListView/ListViewItem.js +25 -17
- package/lib/components/ListViewItem/ListViewItem.styles.js +34 -1
- package/lib/hooks/useExpandableListViewItem/index.js +1 -0
- package/lib/hooks/useExpandableListViewItem/useExpandableListViewItem.js +229 -0
- package/lib/hooks/useSelectField/useSelectField.js +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/listBox.js +1 -0
- package/package.json +6 -2
@@ -0,0 +1,117 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
4
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
8
|
+
_Object$defineProperty(exports, "__esModule", {
|
9
|
+
value: true
|
10
|
+
});
|
11
|
+
exports.escapeFocusDelegate = exports["default"] = void 0;
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
13
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
15
|
+
var _reactAria = require("react-aria");
|
16
|
+
var _focus = require("@react-aria/focus");
|
17
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
18
|
+
var _index = require("../../index");
|
19
|
+
var _react2 = require("@emotion/react");
|
20
|
+
var _excluded = ["children", "gridCellProps", "focusManager", "isFocusEscaped", "setIsFocusEscaped", "focusProps", "focusWithinProps", "isFocused", "isFocusWithin"];
|
21
|
+
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); }
|
22
|
+
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; }
|
23
|
+
var escapeFocusDelegate = function escapeFocusDelegate(e, setIsFocusEscaped, focusManager, isFocusEscaped) {
|
24
|
+
if (e.keyCode === 13) {
|
25
|
+
setIsFocusEscaped(true);
|
26
|
+
focusManager.focusNext();
|
27
|
+
e.stopPropagation();
|
28
|
+
e.preventDefault();
|
29
|
+
} else if (isFocusEscaped) {
|
30
|
+
switch (e.keyCode) {
|
31
|
+
case 37:
|
32
|
+
e.stopPropagation();
|
33
|
+
break;
|
34
|
+
case 39:
|
35
|
+
e.stopPropagation();
|
36
|
+
break;
|
37
|
+
case 38:
|
38
|
+
focusManager.focusPrevious();
|
39
|
+
e.stopPropagation();
|
40
|
+
e.preventDefault();
|
41
|
+
break;
|
42
|
+
case 40:
|
43
|
+
focusManager.focusNext();
|
44
|
+
e.stopPropagation();
|
45
|
+
e.preventDefault();
|
46
|
+
break;
|
47
|
+
default:
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
};
|
52
|
+
exports.escapeFocusDelegate = escapeFocusDelegate;
|
53
|
+
var ExpandableItemChildrenContainer = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
54
|
+
var children = props.children,
|
55
|
+
gridCellProps = props.gridCellProps,
|
56
|
+
focusManager = props.focusManager,
|
57
|
+
isFocusEscaped = props.isFocusEscaped,
|
58
|
+
setIsFocusEscaped = props.setIsFocusEscaped,
|
59
|
+
focusProps = props.focusProps,
|
60
|
+
focusWithinProps = props.focusWithinProps,
|
61
|
+
isFocused = props.isFocused,
|
62
|
+
isFocusWithin = props.isFocusWithin,
|
63
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
64
|
+
var mergedProps = (0, _reactAria.mergeProps)(others, gridCellProps, focusProps, focusWithinProps);
|
65
|
+
|
66
|
+
// this handles instances where a user clicks into the container.
|
67
|
+
(0, _react.useEffect)(function () {
|
68
|
+
if (isFocusWithin && !isFocusEscaped && !isFocused) {
|
69
|
+
setIsFocusEscaped(true);
|
70
|
+
}
|
71
|
+
}, [isFocusWithin]);
|
72
|
+
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
73
|
+
ref: ref
|
74
|
+
}, mergedProps, {
|
75
|
+
tabIndex: 0,
|
76
|
+
onKeyDown: function onKeyDown(e) {
|
77
|
+
escapeFocusDelegate(e, setIsFocusEscaped, focusManager, isFocusEscaped);
|
78
|
+
}
|
79
|
+
}), children);
|
80
|
+
});
|
81
|
+
ExpandableItemChildrenContainer.propTypes = {
|
82
|
+
gridCellProps: _propTypes["default"].shape({}),
|
83
|
+
focusManager: _propTypes["default"].shape({}),
|
84
|
+
focusProps: _propTypes["default"].shape({}),
|
85
|
+
focusWithinProps: _propTypes["default"].shape({}),
|
86
|
+
isFocusEscaped: _propTypes["default"].bool,
|
87
|
+
isFocused: _propTypes["default"].bool,
|
88
|
+
isFocusWithin: _propTypes["default"].bool,
|
89
|
+
expandableContainerOnBlur: _propTypes["default"].func,
|
90
|
+
expandableContainerOnFocus: _propTypes["default"].func,
|
91
|
+
setIsFocusEscaped: _propTypes["default"].func
|
92
|
+
};
|
93
|
+
var ListViewFocusWrapper = function ListViewFocusWrapper(props) {
|
94
|
+
var children = props.children,
|
95
|
+
containerProps = props.containerProps,
|
96
|
+
isFocusEscaped = props.isFocusEscaped;
|
97
|
+
var focusManager = (0, _focus.useFocusManager)();
|
98
|
+
return (0, _react2.jsx)(_focus.FocusScope, {
|
99
|
+
restoreFocus: false,
|
100
|
+
contain: isFocusEscaped
|
101
|
+
}, (0, _react2.jsx)(FocusableItem, null, (0, _react2.jsx)(ExpandableItemChildrenContainer, (0, _extends2["default"])({}, containerProps, {
|
102
|
+
focusManager: focusManager
|
103
|
+
}), children)));
|
104
|
+
};
|
105
|
+
var FocusableItem = function FocusableItem(props) {
|
106
|
+
var focusManager = (0, _focus.useFocusManager)();
|
107
|
+
var childWithFocusHandle = /*#__PURE__*/_react["default"].cloneElement(props.children, {
|
108
|
+
focusManager: focusManager
|
109
|
+
});
|
110
|
+
return childWithFocusHandle;
|
111
|
+
};
|
112
|
+
ListViewFocusWrapper.propTypes = {
|
113
|
+
containerProps: _propTypes["default"].shape({}),
|
114
|
+
isFocusEscaped: _propTypes["default"].bool
|
115
|
+
};
|
116
|
+
var _default = ListViewFocusWrapper;
|
117
|
+
exports["default"] = _default;
|
@@ -22,7 +22,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
22
22
|
var _react = _interopRequireWildcard(require("react"));
|
23
23
|
var _reactAria = require("react-aria");
|
24
24
|
var _interactions = require("@react-aria/interactions");
|
25
|
-
var _list = require("@react-aria/list");
|
26
25
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
27
26
|
var _hooks = require("../../hooks");
|
28
27
|
var _index = require("../../index");
|
@@ -33,7 +32,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
33
32
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys2(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; }
|
34
33
|
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; }
|
35
34
|
var ListViewItem = function ListViewItem(props) {
|
36
|
-
var _context;
|
35
|
+
var _context, _item$rendered;
|
37
36
|
var item = props.item,
|
38
37
|
_props$item$props = props.item.props,
|
39
38
|
listItemProps = _props$item$props.listItemProps,
|
@@ -58,24 +57,31 @@ var ListViewItem = function ListViewItem(props) {
|
|
58
57
|
var _useFocusRing2 = (0, _reactAria.useFocusRing)(),
|
59
58
|
focusProps = _useFocusRing2.focusProps,
|
60
59
|
isFocusVisible = _useFocusRing2.isFocusVisible;
|
60
|
+
var onPointerLeaveFunction = /* istanbul ignore next */function onPointerLeaveFunction() {
|
61
|
+
state.hover.setHoveredItem('');
|
62
|
+
};
|
61
63
|
var _useHover = (0, _interactions.useHover)({
|
62
64
|
onHoverStart: function onHoverStart() {
|
63
65
|
state.hover.setHoveredItem(item.key);
|
66
|
+
},
|
67
|
+
onHoverEnd: /* istanbul ignore next */
|
68
|
+
function onHoverEnd() {
|
69
|
+
onPointerLeaveFunction();
|
64
70
|
}
|
65
71
|
}),
|
66
|
-
hoverProps = _useHover.hoverProps
|
67
|
-
|
68
|
-
var _useListItem = (0, _list.useListItem)({
|
72
|
+
hoverProps = _useHover.hoverProps;
|
73
|
+
var _useGridListItem = (0, _reactAria.useGridListItem)({
|
69
74
|
node: item,
|
70
|
-
isVirtualized: true
|
71
|
-
isDisabled: isDisabled
|
75
|
+
isVirtualized: true
|
72
76
|
}, state, rowRef),
|
73
|
-
raRowProps =
|
74
|
-
gridCellProps =
|
77
|
+
raRowProps = _useGridListItem.rowProps,
|
78
|
+
gridCellProps = _useGridListItem.gridCellProps;
|
75
79
|
var isSelected = state.selectionManager.isSelected(item.key);
|
76
|
-
var mergedProps = (0, _reactAria.mergeProps)(raRowProps, hoverProps, isFocusable ? _objectSpread(_objectSpread({}, focusProps), focusWithinProps) : {}
|
80
|
+
var mergedProps = (0, _reactAria.mergeProps)(raRowProps, hoverProps, isFocusable ? _objectSpread(_objectSpread({}, focusProps), focusWithinProps) : {}, {
|
81
|
+
onPointerLeave: onPointerLeaveFunction
|
82
|
+
});
|
77
83
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
78
|
-
isHovered: isSelectable &&
|
84
|
+
isHovered: isSelectable && isHoverable && item.key === state.hover.hoveredItem,
|
79
85
|
isSelected: isSelected,
|
80
86
|
isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin,
|
81
87
|
hasSeparator: hasSeparator,
|
@@ -85,7 +91,11 @@ var ListViewItem = function ListViewItem(props) {
|
|
85
91
|
|
86
92
|
// Whether the current component should have legacy styles removed
|
87
93
|
// TODO: [Astro 3.0.0] Remove the legacy styles and update the code here.
|
88
|
-
var shouldOverRideLegacyStyles = (0, _includes["default"])(_context = (0, _keys["default"])(item.rendered.props)).call(_context, 'data');
|
94
|
+
var shouldOverRideLegacyStyles = (0, _includes["default"])(_context = (0, _keys["default"])(item === null || item === void 0 || (_item$rendered = item.rendered) === null || _item$rendered === void 0 ? void 0 : _item$rendered.props)).call(_context, 'data');
|
95
|
+
|
96
|
+
// Apply appropriate variant dependant on whether a legacy list item is used
|
97
|
+
/* istanbul ignore next */
|
98
|
+
var listItemVariant = shouldOverRideLegacyStyles ? 'listViewItem.styledListItem' : 'listViewItem.container';
|
89
99
|
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
90
100
|
isDisabled: isDisabled,
|
91
101
|
isRow: true,
|
@@ -95,10 +105,8 @@ var ListViewItem = function ListViewItem(props) {
|
|
95
105
|
outline: 'none'
|
96
106
|
}
|
97
107
|
}), (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
98
|
-
as: "div"
|
99
|
-
|
100
|
-
,
|
101
|
-
variant: shouldOverRideLegacyStyles ? 'listViewItem.styledListItem' : 'listViewItem.container'
|
108
|
+
as: "div",
|
109
|
+
variant: listItemVariant
|
102
110
|
}, gridCellProps, {
|
103
111
|
isFocused: isDisabled ? false : isFocusVisible,
|
104
112
|
isDisabled: isDisabled,
|
@@ -117,6 +117,36 @@ var rightOfData = {
|
|
117
117
|
alignSelf: 'center',
|
118
118
|
flexShrink: 0
|
119
119
|
};
|
120
|
+
var expandableFocusContainer = {
|
121
|
+
px: 'sm',
|
122
|
+
outline: 'none',
|
123
|
+
border: 'none',
|
124
|
+
'&.is-focused': {
|
125
|
+
boxShadow: '0 0 0 1px inset #D033FF'
|
126
|
+
}
|
127
|
+
};
|
128
|
+
var expandableStyledListItem = {
|
129
|
+
display: 'flex',
|
130
|
+
padding: '0px 15px 0px 25px',
|
131
|
+
flex: '1 1 0px',
|
132
|
+
minHeight: '80px',
|
133
|
+
flexGrow: 1,
|
134
|
+
justifyContent: 'center',
|
135
|
+
bg: 'white',
|
136
|
+
'&.is-hovered': {
|
137
|
+
bg: 'accent.99',
|
138
|
+
cursor: 'pointer'
|
139
|
+
},
|
140
|
+
'&.is-focused': {
|
141
|
+
boxShadow: '0 0 0 1px inset #D033FF'
|
142
|
+
}
|
143
|
+
};
|
144
|
+
var expandableRow = {
|
145
|
+
'&.has-separator': {
|
146
|
+
borderBottom: '1px solid',
|
147
|
+
borderBottomColor: 'line.light'
|
148
|
+
}
|
149
|
+
};
|
120
150
|
var _default = {
|
121
151
|
container: container,
|
122
152
|
controls: controls,
|
@@ -127,6 +157,9 @@ var _default = {
|
|
127
157
|
rightOfData: rightOfData,
|
128
158
|
styledContainer: styledContainer,
|
129
159
|
styledListItem: styledListItem,
|
130
|
-
loaderContainer: loaderContainer
|
160
|
+
loaderContainer: loaderContainer,
|
161
|
+
expandableFocusContainer: expandableFocusContainer,
|
162
|
+
expandableStyledListItem: expandableStyledListItem,
|
163
|
+
expandableRow: expandableRow
|
131
164
|
};
|
132
165
|
exports["default"] = _default;
|