@pingux/astro 1.2.0-alpha.12 → 1.2.0-alpha.16
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/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 +9 -0
- package/lib/cjs/components/Button/Button.stories.js +1 -14
- 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/TextAreaField/TextAreaField.js +53 -8
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +33 -1
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
- package/lib/cjs/context/AccordionGridContext/index.js +20 -0
- 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 +2 -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 +10 -1
- package/lib/components/Button/Button.stories.js +0 -10
- 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/TextAreaField/TextAreaField.js +53 -9
- package/lib/components/TextAreaField/TextAreaField.stories.js +27 -0
- package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
- package/lib/context/AccordionGridContext/index.js +5 -0
- 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 +2 -0
- package/package.json +1 -1
- package/lib/cjs/components/AccordionGridGroup/AccordionGridContext.js +0 -17
- package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
@@ -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
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
|
-
import React, {
|
3
|
+
import React, { forwardRef } from 'react';
|
4
4
|
import { mergeProps } from '@react-aria/utils';
|
5
5
|
import PropTypes from 'prop-types';
|
6
6
|
import { useGridCell } from '@react-aria/grid';
|
7
7
|
import { useHover } from '@react-aria/interactions';
|
8
|
-
import {
|
8
|
+
import { useAccordionGridContext } from '../../context/AccordionGridContext';
|
9
9
|
import Box from '../Box';
|
10
10
|
import { useStatusClasses } from '../../hooks';
|
11
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -17,8 +17,8 @@ var AccordionGridItemBody = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
17
17
|
children = props.children,
|
18
18
|
isSelected = props.isSelected;
|
19
19
|
|
20
|
-
var
|
21
|
-
state =
|
20
|
+
var _useAccordionGridCont = useAccordionGridContext(),
|
21
|
+
state = _useAccordionGridCont.state;
|
22
22
|
|
23
23
|
var cellNode = _concatInstanceProperty(_context = []).call(_context, item.childNodes)[1];
|
24
24
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
4
|
-
import React, {
|
4
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
5
5
|
import { mergeProps } from '@react-aria/utils';
|
6
6
|
import { useFocusRing } from '@react-aria/focus';
|
7
7
|
import PropTypes from 'prop-types';
|
8
8
|
import { useGridCell } from '@react-aria/grid';
|
9
|
-
import { useHover
|
9
|
+
import { useHover } from '@react-aria/interactions';
|
10
10
|
import MenuDown from 'mdi-react/MenuDownIcon';
|
11
11
|
import MenuUp from 'mdi-react/MenuUpIcon';
|
12
|
-
import {
|
12
|
+
import { useAccordionGridContext } from '../../context/AccordionGridContext';
|
13
13
|
import Box from '../Box';
|
14
14
|
import Icon from '../Icon';
|
15
15
|
import { useStatusClasses } from '../../hooks';
|
@@ -20,20 +20,27 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
20
20
|
var item = props.item,
|
21
21
|
className = props.className,
|
22
22
|
children = props.children,
|
23
|
-
key = props.key,
|
24
23
|
isSelected = props.isSelected,
|
25
|
-
others = _objectWithoutProperties(props, ["item", "className", "children", "
|
24
|
+
others = _objectWithoutProperties(props, ["item", "className", "children", "isSelected"]);
|
26
25
|
|
27
|
-
var
|
28
|
-
state =
|
26
|
+
var _useAccordionGridCont = useAccordionGridContext(),
|
27
|
+
state = _useAccordionGridCont.state;
|
28
|
+
|
29
|
+
var cellRef = useRef();
|
30
|
+
/* istanbul ignore next */
|
31
|
+
|
32
|
+
useImperativeHandle(ref, function () {
|
33
|
+
return cellRef.current;
|
34
|
+
});
|
29
35
|
|
30
36
|
var cellNode = _concatInstanceProperty(_context = []).call(_context, item.childNodes)[0];
|
31
37
|
|
32
38
|
var _useGridCell = useGridCell({
|
33
39
|
node: cellNode,
|
34
40
|
focusMode: 'cell'
|
35
|
-
}, state,
|
36
|
-
gridCellProps = _useGridCell.gridCellProps
|
41
|
+
}, state, cellRef),
|
42
|
+
gridCellProps = _useGridCell.gridCellProps,
|
43
|
+
isPressed = _useGridCell.isPressed;
|
37
44
|
|
38
45
|
var _useHover = useHover({}),
|
39
46
|
hoverProps = _useHover.hoverProps,
|
@@ -48,14 +55,7 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
48
55
|
focusProps = _useFocusRing2.focusProps,
|
49
56
|
isFocusVisible = _useFocusRing2.isFocusVisible;
|
50
57
|
|
51
|
-
var
|
52
|
-
ref: ref,
|
53
|
-
isPressed: item.props.isPressed
|
54
|
-
}),
|
55
|
-
pressProps = _usePress.pressProps,
|
56
|
-
isPressed = _usePress.isPressed;
|
57
|
-
|
58
|
-
var mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps, pressProps);
|
58
|
+
var mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps);
|
59
59
|
|
60
60
|
var _useStatusClasses = useStatusClasses(className, {
|
61
61
|
isPressed: isPressed,
|
@@ -68,9 +68,8 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
68
68
|
var ariaLabel = props['aria-label'];
|
69
69
|
return ___EmotionJSX(Box, _extends({
|
70
70
|
as: "div",
|
71
|
-
ref:
|
71
|
+
ref: cellRef
|
72
72
|
}, mergedProps, {
|
73
|
-
role: "gridcell",
|
74
73
|
variant: "accordion.accordionGridHeader",
|
75
74
|
isFocused: isFocusVisible,
|
76
75
|
isSelected: isSelected,
|
@@ -93,8 +92,8 @@ var AccordionGridItemHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
93
92
|
AccordionGridItemHeader.propTypes = {
|
94
93
|
'aria-label': PropTypes.string,
|
95
94
|
isSelected: PropTypes.bool,
|
96
|
-
key: PropTypes.string,
|
97
95
|
item: PropTypes.shape({
|
96
|
+
key: PropTypes.string,
|
98
97
|
childNodes: PropTypes.arrayOf(PropTypes.shape({})),
|
99
98
|
props: PropTypes.shape({
|
100
99
|
isPressed: PropTypes.bool
|
@@ -32,8 +32,9 @@ var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
32
32
|
|
33
33
|
var _useAccordion = useAccordion(props, state, accordionRef),
|
34
34
|
accordionProps = _useAccordion.accordionProps;
|
35
|
-
/* istanbul ignore next */
|
36
35
|
|
36
|
+
delete accordionProps.onMouseDown;
|
37
|
+
/* istanbul ignore next */
|
37
38
|
|
38
39
|
useImperativeHandle(ref, function () {
|
39
40
|
return accordionRef.current;
|
@@ -7,7 +7,7 @@ import axeTest from '../../utils/testUtils/testAxe';
|
|
7
7
|
import { act, fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
8
8
|
import Text from '../Text';
|
9
9
|
import AccordionGroup from '../AccordionGroup';
|
10
|
-
import { OverlayPanel } from '../../index';
|
10
|
+
import { OverlayPanel, TextField } from '../../index';
|
11
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
12
|
var testId = 'test-accordion';
|
13
13
|
var defaultProps = {
|
@@ -31,7 +31,11 @@ var getComponent = function getComponent() {
|
|
31
31
|
textValue: "Duplicate",
|
32
32
|
"data-id": "third",
|
33
33
|
label: "Accordion item"
|
34
|
-
}, ___EmotionJSX(
|
34
|
+
}, ___EmotionJSX(TextField, {
|
35
|
+
role: "form",
|
36
|
+
label: "Example Label",
|
37
|
+
"data-testid": "testField"
|
38
|
+
}))));
|
35
39
|
};
|
36
40
|
|
37
41
|
var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
|
@@ -214,6 +218,16 @@ test('expanded keys expands an accordion item', function () {
|
|
214
218
|
var selectedItem = buttons[0];
|
215
219
|
expect(selectedItem).toHaveAttribute('aria-expanded', 'true');
|
216
220
|
});
|
221
|
+
test('able to click a textfield that is the rendered child of an accordion', function () {
|
222
|
+
getComponent({
|
223
|
+
expandedKeys: ['third']
|
224
|
+
});
|
225
|
+
var field = screen.getByTestId('testField');
|
226
|
+
var input = screen.getByRole('form');
|
227
|
+
userEvent.click(input);
|
228
|
+
userEvent.type(input, 'banana');
|
229
|
+
expect(field).toHaveClass('has-focus-within');
|
230
|
+
});
|
217
231
|
test('Item accepts a data-id and the data-id can be found in the DOM', function () {
|
218
232
|
getComponent();
|
219
233
|
var buttons = screen.getAllByRole('button');
|