@pingux/astro 2.50.0 → 2.51.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/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/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/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/package.json +6 -2
@@ -0,0 +1,102 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["children", "gridCellProps", "focusManager", "isFocusEscaped", "setIsFocusEscaped", "focusProps", "focusWithinProps", "isFocused", "isFocusWithin"];
|
4
|
+
import React, { forwardRef, useEffect } from 'react';
|
5
|
+
import { mergeProps } from 'react-aria';
|
6
|
+
import { FocusScope, useFocusManager } from '@react-aria/focus';
|
7
|
+
import PropTypes from 'prop-types';
|
8
|
+
import { Box } from '../../index';
|
9
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
|
+
export var escapeFocusDelegate = function escapeFocusDelegate(e, setIsFocusEscaped, focusManager, isFocusEscaped) {
|
11
|
+
if (e.keyCode === 13) {
|
12
|
+
setIsFocusEscaped(true);
|
13
|
+
focusManager.focusNext();
|
14
|
+
e.stopPropagation();
|
15
|
+
e.preventDefault();
|
16
|
+
} else if (isFocusEscaped) {
|
17
|
+
switch (e.keyCode) {
|
18
|
+
case 37:
|
19
|
+
e.stopPropagation();
|
20
|
+
break;
|
21
|
+
case 39:
|
22
|
+
e.stopPropagation();
|
23
|
+
break;
|
24
|
+
case 38:
|
25
|
+
focusManager.focusPrevious();
|
26
|
+
e.stopPropagation();
|
27
|
+
e.preventDefault();
|
28
|
+
break;
|
29
|
+
case 40:
|
30
|
+
focusManager.focusNext();
|
31
|
+
e.stopPropagation();
|
32
|
+
e.preventDefault();
|
33
|
+
break;
|
34
|
+
default:
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
};
|
39
|
+
var ExpandableItemChildrenContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
40
|
+
var children = props.children,
|
41
|
+
gridCellProps = props.gridCellProps,
|
42
|
+
focusManager = props.focusManager,
|
43
|
+
isFocusEscaped = props.isFocusEscaped,
|
44
|
+
setIsFocusEscaped = props.setIsFocusEscaped,
|
45
|
+
focusProps = props.focusProps,
|
46
|
+
focusWithinProps = props.focusWithinProps,
|
47
|
+
isFocused = props.isFocused,
|
48
|
+
isFocusWithin = props.isFocusWithin,
|
49
|
+
others = _objectWithoutProperties(props, _excluded);
|
50
|
+
var mergedProps = mergeProps(others, gridCellProps, focusProps, focusWithinProps);
|
51
|
+
|
52
|
+
// this handles instances where a user clicks into the container.
|
53
|
+
useEffect(function () {
|
54
|
+
if (isFocusWithin && !isFocusEscaped && !isFocused) {
|
55
|
+
setIsFocusEscaped(true);
|
56
|
+
}
|
57
|
+
}, [isFocusWithin]);
|
58
|
+
return ___EmotionJSX(Box, _extends({
|
59
|
+
ref: ref
|
60
|
+
}, mergedProps, {
|
61
|
+
tabIndex: 0,
|
62
|
+
onKeyDown: function onKeyDown(e) {
|
63
|
+
escapeFocusDelegate(e, setIsFocusEscaped, focusManager, isFocusEscaped);
|
64
|
+
}
|
65
|
+
}), children);
|
66
|
+
});
|
67
|
+
ExpandableItemChildrenContainer.propTypes = {
|
68
|
+
gridCellProps: PropTypes.shape({}),
|
69
|
+
focusManager: PropTypes.shape({}),
|
70
|
+
focusProps: PropTypes.shape({}),
|
71
|
+
focusWithinProps: PropTypes.shape({}),
|
72
|
+
isFocusEscaped: PropTypes.bool,
|
73
|
+
isFocused: PropTypes.bool,
|
74
|
+
isFocusWithin: PropTypes.bool,
|
75
|
+
expandableContainerOnBlur: PropTypes.func,
|
76
|
+
expandableContainerOnFocus: PropTypes.func,
|
77
|
+
setIsFocusEscaped: PropTypes.func
|
78
|
+
};
|
79
|
+
var ListViewFocusWrapper = function ListViewFocusWrapper(props) {
|
80
|
+
var children = props.children,
|
81
|
+
containerProps = props.containerProps,
|
82
|
+
isFocusEscaped = props.isFocusEscaped;
|
83
|
+
var focusManager = useFocusManager();
|
84
|
+
return ___EmotionJSX(FocusScope, {
|
85
|
+
restoreFocus: false,
|
86
|
+
contain: isFocusEscaped
|
87
|
+
}, ___EmotionJSX(FocusableItem, null, ___EmotionJSX(ExpandableItemChildrenContainer, _extends({}, containerProps, {
|
88
|
+
focusManager: focusManager
|
89
|
+
}), children)));
|
90
|
+
};
|
91
|
+
var FocusableItem = function FocusableItem(props) {
|
92
|
+
var focusManager = useFocusManager();
|
93
|
+
var childWithFocusHandle = /*#__PURE__*/React.cloneElement(props.children, {
|
94
|
+
focusManager: focusManager
|
95
|
+
});
|
96
|
+
return childWithFocusHandle;
|
97
|
+
};
|
98
|
+
ListViewFocusWrapper.propTypes = {
|
99
|
+
containerProps: PropTypes.shape({}),
|
100
|
+
isFocusEscaped: PropTypes.bool
|
101
|
+
};
|
102
|
+
export default ListViewFocusWrapper;
|
@@ -12,16 +12,15 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
12
12
|
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; }
|
13
13
|
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) { _defineProperty(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; }
|
14
14
|
import React, { useContext, useRef } from 'react';
|
15
|
-
import { mergeProps, useFocusRing } from 'react-aria';
|
15
|
+
import { mergeProps, useFocusRing, useGridListItem } from 'react-aria';
|
16
16
|
import { useHover } from '@react-aria/interactions';
|
17
|
-
import { useListItem } from '@react-aria/list';
|
18
17
|
import PropTypes from 'prop-types';
|
19
18
|
import { useStatusClasses } from '../../hooks';
|
20
19
|
import { Box, Loader } from '../../index';
|
21
20
|
import { ListViewContext } from './ListViewContext';
|
22
21
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
23
22
|
var ListViewItem = function ListViewItem(props) {
|
24
|
-
var _context;
|
23
|
+
var _context, _item$rendered;
|
25
24
|
var item = props.item,
|
26
25
|
_props$item$props = props.item.props,
|
27
26
|
listItemProps = _props$item$props.listItemProps,
|
@@ -46,24 +45,31 @@ var ListViewItem = function ListViewItem(props) {
|
|
46
45
|
var _useFocusRing2 = useFocusRing(),
|
47
46
|
focusProps = _useFocusRing2.focusProps,
|
48
47
|
isFocusVisible = _useFocusRing2.isFocusVisible;
|
48
|
+
var onPointerLeaveFunction = /* istanbul ignore next */function onPointerLeaveFunction() {
|
49
|
+
state.hover.setHoveredItem('');
|
50
|
+
};
|
49
51
|
var _useHover = useHover({
|
50
52
|
onHoverStart: function onHoverStart() {
|
51
53
|
state.hover.setHoveredItem(item.key);
|
54
|
+
},
|
55
|
+
onHoverEnd: /* istanbul ignore next */
|
56
|
+
function onHoverEnd() {
|
57
|
+
onPointerLeaveFunction();
|
52
58
|
}
|
53
59
|
}),
|
54
|
-
hoverProps = _useHover.hoverProps
|
55
|
-
|
56
|
-
var _useListItem = useListItem({
|
60
|
+
hoverProps = _useHover.hoverProps;
|
61
|
+
var _useGridListItem = useGridListItem({
|
57
62
|
node: item,
|
58
|
-
isVirtualized: true
|
59
|
-
isDisabled: isDisabled
|
63
|
+
isVirtualized: true
|
60
64
|
}, state, rowRef),
|
61
|
-
raRowProps =
|
62
|
-
gridCellProps =
|
65
|
+
raRowProps = _useGridListItem.rowProps,
|
66
|
+
gridCellProps = _useGridListItem.gridCellProps;
|
63
67
|
var isSelected = state.selectionManager.isSelected(item.key);
|
64
|
-
var mergedProps = mergeProps(raRowProps, hoverProps, isFocusable ? _objectSpread(_objectSpread({}, focusProps), focusWithinProps) : {}
|
68
|
+
var mergedProps = mergeProps(raRowProps, hoverProps, isFocusable ? _objectSpread(_objectSpread({}, focusProps), focusWithinProps) : {}, {
|
69
|
+
onPointerLeave: onPointerLeaveFunction
|
70
|
+
});
|
65
71
|
var _useStatusClasses = useStatusClasses(className, {
|
66
|
-
isHovered: isSelectable &&
|
72
|
+
isHovered: isSelectable && isHoverable && item.key === state.hover.hoveredItem,
|
67
73
|
isSelected: isSelected,
|
68
74
|
isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin,
|
69
75
|
hasSeparator: hasSeparator,
|
@@ -73,7 +79,11 @@ var ListViewItem = function ListViewItem(props) {
|
|
73
79
|
|
74
80
|
// Whether the current component should have legacy styles removed
|
75
81
|
// TODO: [Astro 3.0.0] Remove the legacy styles and update the code here.
|
76
|
-
var shouldOverRideLegacyStyles = _includesInstanceProperty(_context = _Object$keys(item.rendered.props)).call(_context, 'data');
|
82
|
+
var shouldOverRideLegacyStyles = _includesInstanceProperty(_context = _Object$keys(item === null || item === void 0 || (_item$rendered = item.rendered) === null || _item$rendered === void 0 ? void 0 : _item$rendered.props)).call(_context, 'data');
|
83
|
+
|
84
|
+
// Apply appropriate variant dependant on whether a legacy list item is used
|
85
|
+
/* istanbul ignore next */
|
86
|
+
var listItemVariant = shouldOverRideLegacyStyles ? 'listViewItem.styledListItem' : 'listViewItem.container';
|
77
87
|
return ___EmotionJSX(Box, _extends({
|
78
88
|
isDisabled: isDisabled,
|
79
89
|
isRow: true,
|
@@ -83,10 +93,8 @@ var ListViewItem = function ListViewItem(props) {
|
|
83
93
|
outline: 'none'
|
84
94
|
}
|
85
95
|
}), ___EmotionJSX(Box, _extends({
|
86
|
-
as: "div"
|
87
|
-
|
88
|
-
,
|
89
|
-
variant: shouldOverRideLegacyStyles ? 'listViewItem.styledListItem' : 'listViewItem.container'
|
96
|
+
as: "div",
|
97
|
+
variant: listItemVariant
|
90
98
|
}, gridCellProps, {
|
91
99
|
isFocused: isDisabled ? false : isFocusVisible,
|
92
100
|
isDisabled: isDisabled,
|
@@ -110,6 +110,36 @@ var rightOfData = {
|
|
110
110
|
alignSelf: 'center',
|
111
111
|
flexShrink: 0
|
112
112
|
};
|
113
|
+
var expandableFocusContainer = {
|
114
|
+
px: 'sm',
|
115
|
+
outline: 'none',
|
116
|
+
border: 'none',
|
117
|
+
'&.is-focused': {
|
118
|
+
boxShadow: '0 0 0 1px inset #D033FF'
|
119
|
+
}
|
120
|
+
};
|
121
|
+
var expandableStyledListItem = {
|
122
|
+
display: 'flex',
|
123
|
+
padding: '0px 15px 0px 25px',
|
124
|
+
flex: '1 1 0px',
|
125
|
+
minHeight: '80px',
|
126
|
+
flexGrow: 1,
|
127
|
+
justifyContent: 'center',
|
128
|
+
bg: 'white',
|
129
|
+
'&.is-hovered': {
|
130
|
+
bg: 'accent.99',
|
131
|
+
cursor: 'pointer'
|
132
|
+
},
|
133
|
+
'&.is-focused': {
|
134
|
+
boxShadow: '0 0 0 1px inset #D033FF'
|
135
|
+
}
|
136
|
+
};
|
137
|
+
var expandableRow = {
|
138
|
+
'&.has-separator': {
|
139
|
+
borderBottom: '1px solid',
|
140
|
+
borderBottomColor: 'line.light'
|
141
|
+
}
|
142
|
+
};
|
113
143
|
export default {
|
114
144
|
container: container,
|
115
145
|
controls: controls,
|
@@ -120,5 +150,8 @@ export default {
|
|
120
150
|
rightOfData: rightOfData,
|
121
151
|
styledContainer: styledContainer,
|
122
152
|
styledListItem: styledListItem,
|
123
|
-
loaderContainer: loaderContainer
|
153
|
+
loaderContainer: loaderContainer,
|
154
|
+
expandableFocusContainer: expandableFocusContainer,
|
155
|
+
expandableStyledListItem: expandableStyledListItem,
|
156
|
+
expandableRow: expandableRow
|
124
157
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useExpandableListViewItem';
|
@@ -0,0 +1,229 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
3
|
+
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; }
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5
|
+
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
6
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
7
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
10
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
11
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
12
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
13
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
14
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
15
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
16
|
+
import { useState } from 'react';
|
17
|
+
import { mergeProps, useFocusRing, useGridListItem } from 'react-aria';
|
18
|
+
import { useHover } from '@react-aria/interactions';
|
19
|
+
import { useStatusClasses } from '..';
|
20
|
+
var useExpandableListViewItem = function useExpandableListViewItem(props) {
|
21
|
+
var _expandableChildrenRe3;
|
22
|
+
var item = props.item,
|
23
|
+
_props$item$props = props.item.props,
|
24
|
+
listItemProps = _props$item$props.listItemProps,
|
25
|
+
rowProps = _props$item$props.rowProps,
|
26
|
+
state = props.state,
|
27
|
+
expandableItemRowRef = props.expandableItemRowRef,
|
28
|
+
expandableChildrenRef = props.expandableChildrenRef,
|
29
|
+
className = props.className;
|
30
|
+
var hasSeparator = true;
|
31
|
+
|
32
|
+
// convenience extractions from props
|
33
|
+
var key = item.key;
|
34
|
+
var dataId = item.props['data-id'];
|
35
|
+
var isDisabled = state.disabledKeys.has(key);
|
36
|
+
var isSelectable = state.selectionManager.selectionMode !== 'none';
|
37
|
+
var isExpanded = state.expandedKeys.has(key);
|
38
|
+
var isSelected = state.selectionManager.isSelected(key);
|
39
|
+
|
40
|
+
// initialize state
|
41
|
+
var _useState = useState(false),
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
43
|
+
isFocusEscaped = _useState2[0],
|
44
|
+
setIsFocusEscaped = _useState2[1];
|
45
|
+
|
46
|
+
// call spectrum hooks
|
47
|
+
var _useFocusRing = useFocusRing({
|
48
|
+
within: true
|
49
|
+
}),
|
50
|
+
isFocusVisibleWithin = _useFocusRing.isFocusVisible,
|
51
|
+
focusWithinProps = _useFocusRing.focusProps;
|
52
|
+
var _useFocusRing2 = useFocusRing(),
|
53
|
+
isFocusVisibleContainer = _useFocusRing2.isFocusVisible,
|
54
|
+
containerFocusProps = _useFocusRing2.focusProps;
|
55
|
+
var _useFocusRing3 = useFocusRing({
|
56
|
+
within: true
|
57
|
+
}),
|
58
|
+
isFocusWithinVisibleContainer = _useFocusRing3.isFocusVisible,
|
59
|
+
containerWithinFocusProps = _useFocusRing3.focusProps;
|
60
|
+
var _useFocusRing4 = useFocusRing(),
|
61
|
+
focusProps = _useFocusRing4.focusProps,
|
62
|
+
isFocusVisible = _useFocusRing4.isFocusVisible;
|
63
|
+
var _useHover = useHover({
|
64
|
+
onHoverStart: /* istanbul ignore next */
|
65
|
+
function onHoverStart() {
|
66
|
+
state.hover.setHoveredItem(item.key);
|
67
|
+
},
|
68
|
+
onHoverEnd: /* istanbul ignore next */
|
69
|
+
function onHoverEnd() {
|
70
|
+
state.hover.setHoveredItem('');
|
71
|
+
}
|
72
|
+
}),
|
73
|
+
hoverProps = _useHover.hoverProps;
|
74
|
+
var _useGridListItem = useGridListItem({
|
75
|
+
node: item,
|
76
|
+
isVirtualized: true
|
77
|
+
}, state, expandableItemRowRef),
|
78
|
+
raRowProps = _useGridListItem.rowProps,
|
79
|
+
gridCellProps = _useGridListItem.gridCellProps;
|
80
|
+
|
81
|
+
// remove row mouse event props
|
82
|
+
// delete raRowProps.onClick;
|
83
|
+
delete raRowProps.onMouseDown;
|
84
|
+
delete raRowProps.onPointerDown;
|
85
|
+
|
86
|
+
// declare custom functions
|
87
|
+
var expandItem = function expandItem() {
|
88
|
+
var _context;
|
89
|
+
var newSet = new _Set(_concatInstanceProperty(_context = []).call(_context, _Array$from(state.expandedKeys), [key]));
|
90
|
+
state.setExpandedKeys(newSet);
|
91
|
+
};
|
92
|
+
var toggleExpanded = function toggleExpanded() {
|
93
|
+
if (isExpanded) {
|
94
|
+
var _context2;
|
95
|
+
var set = new _Set(_concatInstanceProperty(_context2 = []).call(_context2, _Array$from(state.expandedKeys)));
|
96
|
+
set["delete"](key);
|
97
|
+
state.setExpandedKeys(set);
|
98
|
+
} else {
|
99
|
+
expandItem();
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
// overrides the row navigation.
|
104
|
+
// if escape is pressed, focus is returned to the expanded content container
|
105
|
+
|
106
|
+
var onKeyDownEscapeFocusRowOverride = function onKeyDownEscapeFocusRowOverride(e) {
|
107
|
+
if (e.keyCode === 27) {
|
108
|
+
var _expandableChildrenRe;
|
109
|
+
/* istanbul ignore next */
|
110
|
+
setIsFocusEscaped(false);
|
111
|
+
/* istanbul ignore next */
|
112
|
+
expandableChildrenRef === null || expandableChildrenRef === void 0 || (_expandableChildrenRe = expandableChildrenRef.current) === null || _expandableChildrenRe === void 0 ? void 0 : _expandableChildrenRe.focus();
|
113
|
+
}
|
114
|
+
};
|
115
|
+
|
116
|
+
// if the row is expanded, and key left is pressed:
|
117
|
+
// return focus to the expanded content container
|
118
|
+
var listenOnRowForLeft = function listenOnRowForLeft(e) {
|
119
|
+
if (e.keyCode === 37 && e.target === expandableItemRowRef.current && isExpanded) {
|
120
|
+
var _expandableChildrenRe2;
|
121
|
+
expandableChildrenRef === null || expandableChildrenRef === void 0 || (_expandableChildrenRe2 = expandableChildrenRef.current) === null || _expandableChildrenRe2 === void 0 ? void 0 : _expandableChildrenRe2.focus();
|
122
|
+
} else if ((e.keyCode === 13 || e.keyCode === 32) && e.target === expandableItemRowRef.current) {
|
123
|
+
toggleExpanded();
|
124
|
+
} else if (raRowProps.onKeyDownCapture) {
|
125
|
+
raRowProps.onKeyDownCapture(e);
|
126
|
+
}
|
127
|
+
};
|
128
|
+
|
129
|
+
// if the expanded content container is focused, this function will call
|
130
|
+
// it returns focus to the row on right press, and calls the native left press
|
131
|
+
var expandedChildrenKeyCaptureOverride = function expandedChildrenKeyCaptureOverride(e) {
|
132
|
+
var _expandableItemRowRef;
|
133
|
+
// if left go back ie dont stifle
|
134
|
+
// if right, stifle, but then send back to row, using ref.
|
135
|
+
switch (e.keyCode) {
|
136
|
+
case 37:
|
137
|
+
if (!isFocusEscaped) {
|
138
|
+
if (raRowProps.onKeyDownCapture) {
|
139
|
+
raRowProps.onKeyDownCapture(e);
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
break;
|
144
|
+
case 39:
|
145
|
+
expandableItemRowRef === null || expandableItemRowRef === void 0 || (_expandableItemRowRef = expandableItemRowRef.current) === null || _expandableItemRowRef === void 0 ? void 0 : _expandableItemRowRef.focus();
|
146
|
+
break;
|
147
|
+
default:
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
};
|
151
|
+
|
152
|
+
// merge props and create status css classes
|
153
|
+
var mergedProps = mergeProps(raRowProps, focusProps, focusWithinProps);
|
154
|
+
var _useStatusClasses = useStatusClasses(className, {
|
155
|
+
isHovered: isSelectable && item.key === state.hover.hoveredItem,
|
156
|
+
isSelected: isSelected,
|
157
|
+
isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin && !isFocusEscaped && !isFocusVisibleContainer
|
158
|
+
}),
|
159
|
+
classNames = _useStatusClasses.classNames;
|
160
|
+
var _useStatusClasses2 = useStatusClasses('', {
|
161
|
+
isFocused: isFocusVisibleContainer
|
162
|
+
}),
|
163
|
+
focusContainerClassName = _useStatusClasses2.classNames;
|
164
|
+
var _useStatusClasses3 = useStatusClasses('', {
|
165
|
+
hasSeparator: hasSeparator
|
166
|
+
}),
|
167
|
+
rowClassName = _useStatusClasses3.classNames;
|
168
|
+
var expandableRowProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
169
|
+
isDisabled: isDisabled,
|
170
|
+
ref: expandableItemRowRef
|
171
|
+
}, mergedProps), rowProps), {}, {
|
172
|
+
onKeyDownCapture: listenOnRowForLeft
|
173
|
+
}, isFocusEscaped && {
|
174
|
+
onKeyDown: onKeyDownEscapeFocusRowOverride
|
175
|
+
}), {}, {
|
176
|
+
sx: {
|
177
|
+
outline: 'none'
|
178
|
+
}
|
179
|
+
}, (isFocusVisibleContainer || isFocusEscaped) && {
|
180
|
+
onKeyDownCapture: function onKeyDownCapture(e) {
|
181
|
+
return expandedChildrenKeyCaptureOverride(e);
|
182
|
+
}
|
183
|
+
}), {}, {
|
184
|
+
className: rowClassName,
|
185
|
+
variant: 'listViewItem.expandableRow'
|
186
|
+
});
|
187
|
+
var cellProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, hoverProps), {}, {
|
188
|
+
variant: 'listViewItem.expandableStyledListItem',
|
189
|
+
sx: {
|
190
|
+
minHeight: '75px',
|
191
|
+
py: 'lg',
|
192
|
+
px: 'md'
|
193
|
+
}
|
194
|
+
}, gridCellProps), {}, {
|
195
|
+
isFocused: isDisabled ? false : isFocusVisible,
|
196
|
+
isDisabled: isDisabled,
|
197
|
+
isSelected: isSelected,
|
198
|
+
className: classNames,
|
199
|
+
'data-id': dataId
|
200
|
+
}, listItemProps), {}, {
|
201
|
+
'aria-expanded': isExpanded,
|
202
|
+
'aria-controls': (_expandableChildrenRe3 = expandableChildrenRef.current) === null || _expandableChildrenRe3 === void 0 ? void 0 : _expandableChildrenRe3.id
|
203
|
+
});
|
204
|
+
var expandableContainerProps = {
|
205
|
+
ref: expandableChildrenRef,
|
206
|
+
isFocusEscaped: isFocusEscaped,
|
207
|
+
setIsFocusEscaped: setIsFocusEscaped,
|
208
|
+
className: focusContainerClassName,
|
209
|
+
isFocused: isFocusVisibleContainer,
|
210
|
+
focusProps: containerFocusProps,
|
211
|
+
focusWithinProps: containerWithinFocusProps,
|
212
|
+
isFocusWithin: isFocusWithinVisibleContainer,
|
213
|
+
'data-testid': 'focuscontainer',
|
214
|
+
variant: 'listViewItem.expandableFocusContainer'
|
215
|
+
};
|
216
|
+
var expandableItemState = {
|
217
|
+
isExpanded: isExpanded,
|
218
|
+
isFocusEscaped: isFocusEscaped,
|
219
|
+
toggleExpanded: toggleExpanded,
|
220
|
+
gridCellProps: gridCellProps
|
221
|
+
};
|
222
|
+
return {
|
223
|
+
expandableRowProps: expandableRowProps,
|
224
|
+
cellProps: cellProps,
|
225
|
+
expandableContainerProps: expandableContainerProps,
|
226
|
+
expandableItemState: expandableItemState
|
227
|
+
};
|
228
|
+
};
|
229
|
+
export default useExpandableListViewItem;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pingux/astro",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.51.0-alpha.0",
|
4
4
|
"description": "React component library for Ping Identity's design system",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -56,11 +56,12 @@
|
|
56
56
|
"@react-aria/dnd": "^3.5.0",
|
57
57
|
"@react-aria/focus": "~3.8.0",
|
58
58
|
"@react-aria/grid": "~3.4.1",
|
59
|
+
"@react-aria/gridlist": "^3.7.2",
|
59
60
|
"@react-aria/i18n": "~3.6.0",
|
60
61
|
"@react-aria/interactions": "~3.11.0",
|
61
62
|
"@react-aria/label": "^3.1.0",
|
62
63
|
"@react-aria/link": "^3.1.1",
|
63
|
-
"@react-aria/list": "3.0.0-
|
64
|
+
"@react-aria/list": "^3.0.0-beta.0",
|
64
65
|
"@react-aria/listbox": "~3.10.2",
|
65
66
|
"@react-aria/live-announcer": "~3.1.1",
|
66
67
|
"@react-aria/overlays": "^3.7.0",
|
@@ -79,11 +80,14 @@
|
|
79
80
|
"@react-stately/layout": "^3.13.4",
|
80
81
|
"@react-stately/list": "~3.4.1",
|
81
82
|
"@react-stately/overlays": "^3.6.4",
|
83
|
+
"@react-stately/selection": "^3.14.2",
|
82
84
|
"@react-stately/table": "^3.9.0",
|
83
85
|
"@react-stately/tabs": "^3.6.3",
|
84
86
|
"@react-stately/tree": "^3.7.4",
|
85
87
|
"@react-stately/virtualizer": "~3.6.5",
|
86
88
|
"@react-types/accordion": "^3.0.0-alpha.18",
|
89
|
+
"@react-types/grid": "^3.2.3",
|
90
|
+
"@react-types/select": "^3.9.1",
|
87
91
|
"@react-types/shared": "^3.22.0",
|
88
92
|
"@storybook/addon-actions": "^7.1.0",
|
89
93
|
"@storybook/api": "^7.1.0",
|