@pingux/astro 1.2.0-alpha.9 → 1.2.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/CHANGELOG.md +43 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +32 -25
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +148 -169
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +25 -30
- package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +29 -14
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +3 -3
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +16 -18
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/cjs/components/Button/Button.js +14 -2
- package/lib/cjs/components/Button/Button.stories.js +33 -33
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/cjs/components/Link/Link.js +2 -1
- package/lib/cjs/components/ListView/ListView.js +9 -13
- package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
- package/lib/cjs/components/Modal/Modal.stories.js +1 -1
- package/lib/cjs/components/RockerButton/RockerButton.js +14 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +4 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -14
- package/lib/cjs/components/SearchField/SearchField.stories.js +1 -15
- package/lib/cjs/components/TextAreaField/TextAreaField.js +54 -9
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +31 -52
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
- package/lib/cjs/context/AccordionGridContext/index.js +20 -0
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/hooks/useField/useField.js +5 -0
- package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/cjs/layouts/ListLayout.stories.js +6 -6
- package/lib/cjs/recipes/ArrayField.stories.js +1 -1
- package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/cjs/styles/variants/boxes.js +9 -0
- package/lib/cjs/styles/variants/buttons.js +20 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +32 -24
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +143 -166
- package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -25
- package/lib/components/AccordionGridItem/AccordionGridItem.js +29 -15
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -4
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +19 -20
- package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/components/Button/Button.js +15 -3
- package/lib/components/Button/Button.stories.js +17 -15
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/ListView/ListView.js +9 -12
- package/lib/components/ListViewItem/ListViewItem.js +14 -3
- package/lib/components/Modal/Modal.stories.js +1 -1
- package/lib/components/RockerButton/RockerButton.js +14 -21
- package/lib/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +2 -17
- package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -11
- package/lib/components/SearchField/SearchField.stories.js +0 -11
- package/lib/components/TextAreaField/TextAreaField.js +54 -10
- package/lib/components/TextAreaField/TextAreaField.stories.js +26 -42
- package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
- package/lib/context/AccordionGridContext/index.js +5 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/hooks/useField/useField.js +5 -0
- package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/layouts/ListLayout.stories.js +6 -6
- package/lib/recipes/ArrayField.stories.js +1 -1
- package/lib/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/styles/variants/boxes.js +9 -0
- package/lib/styles/variants/buttons.js +20 -0
- package/package.json +2 -2
- package/lib/cjs/components/AccordionGridGroup/AccordionGridContext.js +0 -17
- package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
@@ -397,6 +397,7 @@ var chipDeleteButton = {
|
|
397
397
|
};
|
398
398
|
|
399
399
|
var rocker = _objectSpread(_objectSpread({}, base), {}, {
|
400
|
+
border: '0',
|
400
401
|
display: 'inline-flex',
|
401
402
|
height: '26px',
|
402
403
|
lineHeight: '26px',
|
@@ -408,6 +409,7 @@ var rocker = _objectSpread(_objectSpread({}, base), {}, {
|
|
408
409
|
textTransform: 'uppercase',
|
409
410
|
bg: 'accent.95',
|
410
411
|
'&.is-selected': {
|
412
|
+
bg: 'active',
|
411
413
|
color: 'white'
|
412
414
|
},
|
413
415
|
'&.is-focused': _objectSpread({}, defaultFocus)
|
@@ -561,6 +563,23 @@ var tooltipInline = _objectSpread(_objectSpread({}, text), {}, {
|
|
561
563
|
}
|
562
564
|
});
|
563
565
|
|
566
|
+
var defaultVariant = _objectSpread(_objectSpread({}, base), {}, {
|
567
|
+
bg: 'white',
|
568
|
+
border: '1px solid',
|
569
|
+
borderColor: 'active',
|
570
|
+
'&.is-hovered': _objectSpread({}, defaultHover),
|
571
|
+
'&.is-pressed': _objectSpread({}, defaultActive),
|
572
|
+
'&.is-focused': _objectSpread({}, defaultFocus)
|
573
|
+
});
|
574
|
+
|
575
|
+
var filter = _objectSpread(_objectSpread({}, defaultVariant), {}, {
|
576
|
+
px: 'sm',
|
577
|
+
borderColor: 'neutral.80',
|
578
|
+
height: 40,
|
579
|
+
color: 'active',
|
580
|
+
display: 'flex'
|
581
|
+
});
|
582
|
+
|
564
583
|
var colorBlock = {
|
565
584
|
bg: 'neutral.95',
|
566
585
|
border: '1px solid',
|
@@ -633,6 +652,7 @@ var _default = {
|
|
633
652
|
environmentBreadcrumb: environmentBreadcrumb,
|
634
653
|
expandableRow: expandableRow,
|
635
654
|
fileInputField: fileInputField,
|
655
|
+
filter: filter,
|
636
656
|
iconButton: iconButton,
|
637
657
|
imageUpload: imageUpload,
|
638
658
|
inline: inline,
|
@@ -18,11 +18,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
18
18
|
import React, { useMemo, forwardRef, useImperativeHandle, useRef } from 'react';
|
19
19
|
import { GridCollection, useGridState } from '@react-stately/grid';
|
20
20
|
import { GridKeyboardDelegate, useGrid } from '@react-aria/grid';
|
21
|
-
import { mergeProps } from '@react-aria/utils';
|
22
21
|
import { useListState } from '@react-stately/list';
|
23
22
|
import PropTypes from 'prop-types';
|
24
23
|
import { useCollator, useLocale } from '@react-aria/i18n';
|
25
|
-
import { AccordionGridContext } from '
|
24
|
+
import { AccordionGridContext } from '../../context/AccordionGridContext';
|
26
25
|
import AccordionGridItem from '../AccordionGridItem';
|
27
26
|
import Box from '../Box';
|
28
27
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
@@ -46,9 +45,7 @@ export var collectionTypes = {
|
|
46
45
|
var AccordionGridGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
47
46
|
var _context2;
|
48
47
|
|
49
|
-
var disabledKeys = props.disabledKeys
|
50
|
-
selectedKeys = props.selectedKeys,
|
51
|
-
onSelectionChange = props.onSelectionChange;
|
48
|
+
var disabledKeys = props.disabledKeys;
|
52
49
|
var accordionGridRef = useRef();
|
53
50
|
/* istanbul ignore next */
|
54
51
|
|
@@ -73,9 +70,11 @@ var AccordionGridGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
73
70
|
columnCount: 1,
|
74
71
|
items: _mapInstanceProperty(_context = _Array$from(collection)).call(_context, function (item) {
|
75
72
|
return _objectSpread(_objectSpread({}, item), {}, {
|
73
|
+
key: "row-".concat(item.key),
|
76
74
|
hasChildNodes: true,
|
77
75
|
childNodes: [{
|
78
|
-
key:
|
76
|
+
key: item.key,
|
77
|
+
// use key for first cell, fixes selection after changes from UIP-5170
|
79
78
|
type: 'cell',
|
80
79
|
index: 0,
|
81
80
|
value: null,
|
@@ -101,12 +100,11 @@ var AccordionGridGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
101
100
|
}, [collection]);
|
102
101
|
var state = useGridState(_objectSpread(_objectSpread({}, props), {}, {
|
103
102
|
disabledKeys: disabledKeys,
|
104
|
-
selectedKeys: selectedKeys,
|
105
103
|
collection: gridCollection,
|
106
|
-
selectionMode: 'multiple'
|
107
|
-
|
108
|
-
|
109
|
-
|
104
|
+
selectionMode: 'multiple'
|
105
|
+
})); // Required to enable header selection
|
106
|
+
|
107
|
+
state.selectionManager.allowsCellSelection = true;
|
110
108
|
var keyboardDelegate = useMemo(function () {
|
111
109
|
return new GridKeyboardDelegate({
|
112
110
|
collection: state.collection,
|
@@ -119,7 +117,6 @@ var AccordionGridGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
119
117
|
}, [state, accordionGridRef, direction, collator]);
|
120
118
|
|
121
119
|
var _useGrid = useGrid(_objectSpread(_objectSpread({}, props), {}, {
|
122
|
-
isVirtualized: true,
|
123
120
|
keyboardDelegate: keyboardDelegate
|
124
121
|
}), state, accordionGridRef),
|
125
122
|
gridProps = _useGrid.gridProps;
|
@@ -129,7 +126,7 @@ var AccordionGridGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
129
126
|
state: state,
|
130
127
|
keyboardDelegate: keyboardDelegate
|
131
128
|
}
|
132
|
-
}, ___EmotionJSX(Box, _extends({},
|
129
|
+
}, ___EmotionJSX(Box, _extends({}, gridProps, {
|
133
130
|
ref: accordionGridRef
|
134
131
|
}), _mapInstanceProperty(_context2 = _Array$from(state.collection)).call(_context2, function (item) {
|
135
132
|
return ___EmotionJSX(AccordionGridItem, _extends({
|
@@ -139,6 +136,27 @@ var AccordionGridGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
139
136
|
})));
|
140
137
|
});
|
141
138
|
AccordionGridGroup.propTypes = {
|
139
|
+
/**
|
140
|
+
* The currently selected keys in the collection (uncontrolled).
|
141
|
+
*
|
142
|
+
* `selectedKeys="all"` can be used to select every key.
|
143
|
+
*/
|
144
|
+
defaultSelectedKeys: isIterableProp,
|
145
|
+
|
146
|
+
/**
|
147
|
+
* The currently selected keys in the collection (controlled).
|
148
|
+
*
|
149
|
+
* `selectedKeys="all"` can be used to select every key.
|
150
|
+
*/
|
151
|
+
selectedKeys: isIterableProp,
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Callback function that fires when the selected key changes.
|
155
|
+
*
|
156
|
+
* `(selectedKeys: Set) => void`
|
157
|
+
*/
|
158
|
+
onSelectionChange: PropTypes.func,
|
159
|
+
|
142
160
|
/**
|
143
161
|
* The item keys that are disabled. These items cannot be selected, focused, or otherwise
|
144
162
|
* interacted with.
|
@@ -164,17 +182,7 @@ AccordionGridGroup.propTypes = {
|
|
164
182
|
* Identifies the element (or elements) that provide a detailed, extended description for
|
165
183
|
* the object.
|
166
184
|
*/
|
167
|
-
'aria-details': PropTypes.string
|
168
|
-
|
169
|
-
/**
|
170
|
-
* The currently selected keys in the collection (controlled).
|
171
|
-
*
|
172
|
-
* `selectedKeys="all"` can be used to select every key.
|
173
|
-
*/
|
174
|
-
selectedKeys: isIterableProp,
|
175
|
-
|
176
|
-
/** Callback function that fires when the selected key changes. */
|
177
|
-
onSelectionChange: PropTypes.func
|
185
|
+
'aria-details': PropTypes.string
|
178
186
|
};
|
179
187
|
AccordionGridGroup.defaultProps = {
|
180
188
|
'aria-label': 'accordion'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
2
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import { Item } from '@react-stately/collections';
|
5
5
|
import CreateIcon from 'mdi-react/CreateIcon';
|
@@ -72,188 +72,165 @@ export default {
|
|
72
72
|
}
|
73
73
|
}
|
74
74
|
};
|
75
|
-
export var Default = function Default() {
|
76
|
-
var _useState = useState([]),
|
77
|
-
_useState2 = _slicedToArray(_useState, 2),
|
78
|
-
selectedKeys = _useState2[0],
|
79
|
-
setselectedKeys = _useState2[1];
|
80
75
|
|
81
|
-
|
82
|
-
|
76
|
+
var Header = function Header(props) {
|
77
|
+
var item = props.item;
|
78
|
+
return ___EmotionJSX(Box, {
|
79
|
+
isRow: true,
|
80
|
+
sx: {
|
81
|
+
flexGrow: 1
|
82
|
+
}
|
83
|
+
}, ___EmotionJSX(Box, {
|
84
|
+
isRow: true,
|
85
|
+
alignSelf: "center",
|
86
|
+
sx: {
|
87
|
+
flexGrow: 1,
|
88
|
+
width: '50%'
|
89
|
+
}
|
90
|
+
}, ___EmotionJSX(Text, {
|
91
|
+
sx: {
|
92
|
+
fontWeight: 3,
|
93
|
+
textOverflow: 'ellipsis',
|
94
|
+
whiteSpace: 'nowrap',
|
95
|
+
overflow: 'hidden'
|
96
|
+
},
|
97
|
+
variant: "itemTitle",
|
98
|
+
alignSelf: "center"
|
99
|
+
}, item.name)), ___EmotionJSX(Box, {
|
100
|
+
isRow: true,
|
101
|
+
alignSelf: "center",
|
102
|
+
sx: {
|
103
|
+
flexGrow: 1,
|
104
|
+
width: '50%'
|
105
|
+
}
|
106
|
+
}, ___EmotionJSX(Text, {
|
107
|
+
sx: {
|
108
|
+
fontWeight: 0,
|
109
|
+
textOverflow: 'ellipsis',
|
110
|
+
whiteSpace: 'nowrap',
|
111
|
+
overflow: 'hidden'
|
112
|
+
},
|
113
|
+
alignSelf: "center"
|
114
|
+
}, item.organizations.length, " Organizations"), ___EmotionJSX(Box, {
|
115
|
+
isRow: true,
|
116
|
+
alignSelf: "center",
|
117
|
+
sx: {
|
118
|
+
ml: 'auto'
|
119
|
+
}
|
120
|
+
}, ___EmotionJSX(IconButton, {
|
121
|
+
"aria-label": "create-icon",
|
122
|
+
sx: {
|
123
|
+
mr: '4px',
|
124
|
+
height: '26px',
|
125
|
+
width: '26px'
|
126
|
+
}
|
127
|
+
}, ___EmotionJSX(CreateIcon, null)), ___EmotionJSX(IconButton, {
|
128
|
+
"aria-label": "vertical-lines-icon",
|
129
|
+
sx: {
|
130
|
+
mr: '4px',
|
131
|
+
height: '26px',
|
132
|
+
width: '26px'
|
133
|
+
}
|
134
|
+
}, ___EmotionJSX(MoreVertIcon, null)))));
|
135
|
+
};
|
136
|
+
|
137
|
+
var Body = function Body(props) {
|
138
|
+
var _context;
|
139
|
+
|
140
|
+
var item = props.item;
|
141
|
+
return ___EmotionJSX(Box, {
|
142
|
+
isRow: true
|
143
|
+
}, ___EmotionJSX(Box, {
|
144
|
+
sx: {
|
145
|
+
flexGrow: 1,
|
146
|
+
width: 'calc(50% - 20px)'
|
147
|
+
}
|
148
|
+
}, ___EmotionJSX(Link, {
|
149
|
+
"aria-label": "permissions",
|
150
|
+
variant: "link",
|
151
|
+
sx: {
|
152
|
+
marginTop: '15px',
|
153
|
+
whiteSpace: 'nowrap',
|
154
|
+
overflow: 'hidden',
|
155
|
+
textOverflow: 'ellipsis',
|
156
|
+
textDecoration: 'none'
|
157
|
+
},
|
158
|
+
href: "https://www.pingidentity.com",
|
159
|
+
target: "_blank"
|
160
|
+
}, "View permissions")), ___EmotionJSX(Box, {
|
161
|
+
sx: {
|
162
|
+
flexGrow: 1,
|
163
|
+
width: '50%'
|
164
|
+
}
|
165
|
+
}, _mapInstanceProperty(_context = item.organizations).call(_context, function (org) {
|
166
|
+
var _context2;
|
167
|
+
|
83
168
|
return ___EmotionJSX(Box, {
|
84
|
-
|
169
|
+
key: "box".concat(org.name),
|
85
170
|
sx: {
|
86
|
-
|
87
|
-
|
88
|
-
}, ___EmotionJSX(Box, {
|
89
|
-
isRow: true,
|
90
|
-
alignSelf: "center",
|
91
|
-
sx: {
|
92
|
-
flexGrow: 1,
|
93
|
-
width: '50%'
|
94
|
-
}
|
95
|
-
}, ___EmotionJSX(Text, {
|
96
|
-
sx: {
|
97
|
-
fontWeight: 3,
|
98
|
-
textOverflow: 'ellipsis',
|
99
|
-
whiteSpace: 'nowrap',
|
100
|
-
overflow: 'hidden'
|
101
|
-
},
|
102
|
-
variant: "itemTitle",
|
103
|
-
alignSelf: "center"
|
104
|
-
}, item.name)), ___EmotionJSX(Box, {
|
105
|
-
isRow: true,
|
106
|
-
alignSelf: "center",
|
107
|
-
sx: {
|
108
|
-
flexGrow: 1,
|
109
|
-
width: '50%'
|
171
|
+
marginTop: '15px',
|
172
|
+
mb: '15px'
|
110
173
|
}
|
111
174
|
}, ___EmotionJSX(Text, {
|
112
175
|
sx: {
|
113
|
-
fontWeight: 0,
|
114
176
|
textOverflow: 'ellipsis',
|
115
177
|
whiteSpace: 'nowrap',
|
116
178
|
overflow: 'hidden'
|
117
179
|
},
|
118
|
-
|
119
|
-
},
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
"aria-label": "vertical-lines-icon",
|
134
|
-
sx: {
|
135
|
-
mr: '4px',
|
136
|
-
height: '26px',
|
137
|
-
width: '26px'
|
138
|
-
}
|
139
|
-
}, ___EmotionJSX(MoreVertIcon, null)))));
|
140
|
-
};
|
141
|
-
|
142
|
-
var Body = function Body(props) {
|
143
|
-
var _context;
|
180
|
+
key: "text".concat(org.name)
|
181
|
+
}, org.name), _mapInstanceProperty(_context2 = org.populations).call(_context2, function (pop) {
|
182
|
+
return ___EmotionJSX(Text, {
|
183
|
+
key: pop,
|
184
|
+
sx: {
|
185
|
+
marginLeft: 'md',
|
186
|
+
mt: '10px',
|
187
|
+
textOverflow: 'ellipsis',
|
188
|
+
whiteSpace: 'nowrap',
|
189
|
+
overflow: 'hidden'
|
190
|
+
}
|
191
|
+
}, pop, ")");
|
192
|
+
}));
|
193
|
+
})));
|
194
|
+
};
|
144
195
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
}, ___EmotionJSX(Box, {
|
196
|
+
export var Default = function Default() {
|
197
|
+
return (// See story source for info about the data used
|
198
|
+
___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
|
149
199
|
sx: {
|
150
|
-
|
151
|
-
|
200
|
+
fontWeight: 3,
|
201
|
+
fontSize: '13px'
|
152
202
|
}
|
153
|
-
}, ___EmotionJSX(
|
154
|
-
"aria-label": "permissions",
|
155
|
-
variant: "link",
|
156
|
-
sx: {
|
157
|
-
marginTop: '15px',
|
158
|
-
whiteSpace: 'nowrap',
|
159
|
-
overflow: 'hidden',
|
160
|
-
textOverflow: 'ellipsis',
|
161
|
-
textDecoration: 'none'
|
162
|
-
},
|
163
|
-
href: "https://www.pingidentity.com",
|
164
|
-
target: "_blank"
|
165
|
-
}, "View permissions")), ___EmotionJSX(Box, {
|
203
|
+
}, "Role"), ___EmotionJSX(Separator, {
|
166
204
|
sx: {
|
167
|
-
|
168
|
-
width: '50%'
|
205
|
+
mb: 0
|
169
206
|
}
|
170
|
-
},
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
207
|
+
}), ___EmotionJSX(AccordionGridGroup, {
|
208
|
+
items: data,
|
209
|
+
defaultSelectedKeys: ['Environment']
|
210
|
+
}, function (item) {
|
211
|
+
return ___EmotionJSX(Item, {
|
212
|
+
key: item.key,
|
213
|
+
textValue: item.name
|
214
|
+
}, ___EmotionJSX(Header, {
|
215
|
+
item: item
|
216
|
+
}), ___EmotionJSX(Body, {
|
217
|
+
item: item
|
218
|
+
}), item.key !== 'Organization' ? ___EmotionJSX(Separator, {
|
175
219
|
sx: {
|
176
|
-
|
177
|
-
|
220
|
+
m: 0,
|
221
|
+
bg: 'neutral.90'
|
178
222
|
}
|
179
|
-
}
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
key: pop,
|
189
|
-
sx: {
|
190
|
-
marginLeft: 'md',
|
191
|
-
mt: '10px',
|
192
|
-
textOverflow: 'ellipsis',
|
193
|
-
whiteSpace: 'nowrap',
|
194
|
-
overflow: 'hidden'
|
195
|
-
}
|
196
|
-
}, pop, ")");
|
197
|
-
}));
|
198
|
-
})));
|
199
|
-
};
|
223
|
+
}) : null);
|
224
|
+
}))
|
225
|
+
);
|
226
|
+
};
|
227
|
+
export var Controlled = function Controlled() {
|
228
|
+
var _useState = useState(['Client']),
|
229
|
+
_useState2 = _slicedToArray(_useState, 2),
|
230
|
+
selectedKeys = _useState2[0],
|
231
|
+
setSelectedKeys = _useState2[1];
|
200
232
|
|
201
|
-
return (//
|
202
|
-
// {
|
203
|
-
// name: 'Client Application Developer',
|
204
|
-
// key: '1',
|
205
|
-
// organizations: [
|
206
|
-
// {
|
207
|
-
// name: 'Montana (Environment)',
|
208
|
-
// populations: [
|
209
|
-
// 'Administrators (Population)',
|
210
|
-
// 'Other Population (Population)',
|
211
|
-
// ],
|
212
|
-
// },
|
213
|
-
// {
|
214
|
-
// name: 'Boston (Environment)',
|
215
|
-
// populations: [
|
216
|
-
// ],
|
217
|
-
// },
|
218
|
-
// ],
|
219
|
-
// },
|
220
|
-
// {
|
221
|
-
// name: 'Environment Admin',
|
222
|
-
// key: '2',
|
223
|
-
// organizations: [
|
224
|
-
// {
|
225
|
-
// name: 'Montana (Environment)',
|
226
|
-
// populations: [
|
227
|
-
// 'Administrators (Population)',
|
228
|
-
// 'Other Population (Population)',
|
229
|
-
// ],
|
230
|
-
// },
|
231
|
-
// {
|
232
|
-
// name: 'Boston (Environment)',
|
233
|
-
// populations: [
|
234
|
-
// ],
|
235
|
-
// },
|
236
|
-
// ],
|
237
|
-
// },
|
238
|
-
// {
|
239
|
-
// name: 'Organization Admin',
|
240
|
-
// key: '3',
|
241
|
-
// organizations: [
|
242
|
-
// {
|
243
|
-
// name: 'Montana (Environment)',
|
244
|
-
// populations: [
|
245
|
-
// 'Administrators (Population)',
|
246
|
-
// 'Other Population (Population)',
|
247
|
-
// ],
|
248
|
-
// },
|
249
|
-
// {
|
250
|
-
// name: 'Boston (Environment)',
|
251
|
-
// populations: [
|
252
|
-
// ],
|
253
|
-
// },
|
254
|
-
// ],
|
255
|
-
// },
|
256
|
-
// ];
|
233
|
+
return (// See story source for info about the data used
|
257
234
|
___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
|
258
235
|
sx: {
|
259
236
|
fontWeight: 3,
|
@@ -266,7 +243,7 @@ export var Default = function Default() {
|
|
266
243
|
}), ___EmotionJSX(AccordionGridGroup, {
|
267
244
|
items: data,
|
268
245
|
selectedKeys: selectedKeys,
|
269
|
-
onSelectionChange:
|
246
|
+
onSelectionChange: setSelectedKeys
|
270
247
|
}, function (item) {
|
271
248
|
return ___EmotionJSX(Item, {
|
272
249
|
key: item.key,
|
@@ -1,9 +1,11 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
2
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
1
3
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
4
|
import React from 'react';
|
3
5
|
import { Item } from '@react-stately/collections';
|
4
6
|
import userEvent from '@testing-library/user-event';
|
5
7
|
import axeTest from '../../utils/testUtils/testAxe';
|
6
|
-
import { act, fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
8
|
+
import { act, fireEvent, render, screen, waitFor } from '../../utils/testUtils/testWrapper';
|
7
9
|
import { Link, Box, OverlayPanel } from '../../index';
|
8
10
|
import AccordionGridGroup from '../AccordionGridGroup';
|
9
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -50,20 +52,6 @@ axeTest(getComponent, {
|
|
50
52
|
}
|
51
53
|
}
|
52
54
|
});
|
53
|
-
test('button press', function () {
|
54
|
-
var onPress = jest.fn();
|
55
|
-
getComponent({
|
56
|
-
onPress: onPress
|
57
|
-
});
|
58
|
-
var buttons = screen.getAllByRole('gridcell');
|
59
|
-
var selectedItem = buttons[0];
|
60
|
-
expect(selectedItem).toBeInTheDocument();
|
61
|
-
expect(selectedItem).not.toHaveClass('is-pressed');
|
62
|
-
expect(onPress).not.toHaveBeenCalled(); // Hold down the button to see pressed styles
|
63
|
-
|
64
|
-
fireEvent.mouseDown(selectedItem);
|
65
|
-
expect(selectedItem).toHaveClass('is-pressed');
|
66
|
-
});
|
67
55
|
test('button press uses callback', function () {
|
68
56
|
var onPress = jest.fn();
|
69
57
|
getComponent({
|
@@ -74,8 +62,7 @@ test('button press uses callback', function () {
|
|
74
62
|
expect(selectedItem).not.toHaveClass('is-pressed');
|
75
63
|
expect(onPress).not.toHaveBeenCalled(); // Hold down the button to see pressed styles
|
76
64
|
|
77
|
-
|
78
|
-
fireEvent.mouseUp(selectedItem);
|
65
|
+
userEvent.click(selectedItem);
|
79
66
|
expect(onPress).toHaveBeenCalled();
|
80
67
|
});
|
81
68
|
test('toggle accordion on mouse click', function () {
|
@@ -175,14 +162,26 @@ test('disabled keys prop disables an accordion item, and disables focus', functi
|
|
175
162
|
expect(selectedRow).toHaveClass('is-disabled');
|
176
163
|
expect(selectedRow).not.toHaveClass('is-focused');
|
177
164
|
});
|
178
|
-
test('default expanded keys expands an accordion item', function () {
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
});
|
165
|
+
test('default expanded keys expands an accordion item', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
166
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
167
|
+
while (1) {
|
168
|
+
switch (_context.prev = _context.next) {
|
169
|
+
case 0:
|
170
|
+
getComponent({
|
171
|
+
selectedKeys: ['first']
|
172
|
+
});
|
173
|
+
_context.next = 3;
|
174
|
+
return waitFor(function () {
|
175
|
+
return expect(screen.getAllByRole('row')[0]).toHaveAttribute('aria-selected', 'true');
|
176
|
+
});
|
177
|
+
|
178
|
+
case 3:
|
179
|
+
case "end":
|
180
|
+
return _context.stop();
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}, _callee);
|
184
|
+
})));
|
186
185
|
test('items do not automatically expand if wrapped in an open OverlayPanel', function () {
|
187
186
|
getComponentInOverlayPanel();
|
188
187
|
var row = screen.getAllByRole('row');
|
@@ -3,14 +3,15 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
3
3
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
4
4
|
import _toArray from "@babel/runtime-corejs3/helpers/esm/toArray";
|
5
5
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, {
|
6
|
+
import React, { useEffect, useRef } from 'react';
|
7
7
|
import PropTypes from 'prop-types';
|
8
8
|
import { useGridRow } from '@react-aria/grid';
|
9
9
|
import { mergeProps } from '@react-aria/utils';
|
10
|
-
import {
|
10
|
+
import { useAccordionGridContext } from '../../context/AccordionGridContext';
|
11
11
|
import Box from '../Box';
|
12
12
|
import AccordionGridItemHeader from './AccordionGridItemHeader';
|
13
13
|
import AccordionGridItemBody from './AccordionGridItemBody';
|
14
|
+
import { useStatusClasses } from '../../hooks';
|
14
15
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
16
|
|
16
17
|
var AccordionGridItem = function AccordionGridItem(props) {
|
@@ -20,7 +21,8 @@ var AccordionGridItem = function AccordionGridItem(props) {
|
|
20
21
|
headerProps = props.headerProps,
|
21
22
|
bodyProps = props.bodyProps,
|
22
23
|
children = props.children,
|
23
|
-
|
24
|
+
className = props.className,
|
25
|
+
others = _objectWithoutProperties(props, ["item", "headerProps", "bodyProps", "children", "className"]);
|
24
26
|
|
25
27
|
var _React$Children$toArr = React.Children.toArray(children),
|
26
28
|
_React$Children$toArr2 = _toArray(_React$Children$toArr),
|
@@ -30,10 +32,18 @@ var AccordionGridItem = function AccordionGridItem(props) {
|
|
30
32
|
|
31
33
|
var cellNode = _concatInstanceProperty(_context = []).call(_context, item.childNodes)[0];
|
32
34
|
|
33
|
-
var
|
34
|
-
state =
|
35
|
+
var _useAccordionGridCont = useAccordionGridContext(),
|
36
|
+
state = _useAccordionGridCont.state; // Treat first cell as a row, fixes focus and keyboard interactions
|
35
37
|
|
36
|
-
|
38
|
+
|
39
|
+
var isDisabled = state.disabledKeys.has(cellNode.key);
|
40
|
+
var isSelected = state.selectionManager.isSelected(cellNode.key); // Sync selection between the first cell and the row
|
41
|
+
|
42
|
+
useEffect(function () {
|
43
|
+
if (isSelected !== state.selectionManager.isSelected(item.key)) {
|
44
|
+
state.selectionManager.toggleSelection(item.key);
|
45
|
+
}
|
46
|
+
}, [isSelected, state.selectionManager, item.key]);
|
37
47
|
var rowRef = useRef();
|
38
48
|
var cellRef = useRef();
|
39
49
|
var cellBodyRef = useRef();
|
@@ -43,20 +53,24 @@ var AccordionGridItem = function AccordionGridItem(props) {
|
|
43
53
|
}, state, rowRef),
|
44
54
|
rowProps = _useGridRow.rowProps;
|
45
55
|
|
46
|
-
var
|
47
|
-
|
48
|
-
as: "div",
|
56
|
+
var _useStatusClasses = useStatusClasses(className, {
|
57
|
+
isSelected: isSelected,
|
49
58
|
isDisabled: isDisabled
|
59
|
+
}),
|
60
|
+
classNames = _useStatusClasses.classNames;
|
61
|
+
|
62
|
+
return ___EmotionJSX(Box, _extends({
|
63
|
+
as: "div"
|
50
64
|
}, mergeProps(rowProps, others), {
|
51
|
-
|
52
|
-
|
65
|
+
"aria-selected": isSelected,
|
66
|
+
className: classNames,
|
67
|
+
ref: rowRef
|
53
68
|
}), ___EmotionJSX(AccordionGridItemHeader, _extends({
|
54
69
|
item: item,
|
55
|
-
|
56
|
-
|
57
|
-
}, headerProps, {
|
70
|
+
ref: cellRef,
|
71
|
+
isDisabled: isDisabled,
|
58
72
|
isSelected: isSelected
|
59
|
-
}), header), ___EmotionJSX(AccordionGridItemBody, _extends({
|
73
|
+
}, headerProps), header), ___EmotionJSX(AccordionGridItemBody, _extends({
|
60
74
|
item: item,
|
61
75
|
ref: cellBodyRef,
|
62
76
|
isSelected: isSelected
|