@pingux/astro 2.0.4-alpha.0 → 2.0.4-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/ListItem/ListItem.styles.js +21 -7
- package/lib/cjs/hooks/index.js +7 -0
- package/lib/cjs/hooks/useOverlappingMenuHoverState/index.js +14 -0
- package/lib/cjs/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.js +61 -0
- package/lib/cjs/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.test.js +226 -0
- package/lib/cjs/recipes/LinkedListView.stories.js +189 -139
- package/lib/cjs/recipes/ListAndPanel.stories.js +21 -46
- package/lib/components/ListItem/ListItem.styles.js +21 -7
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useOverlappingMenuHoverState/index.js +1 -0
- package/lib/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.js +53 -0
- package/lib/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.test.js +219 -0
- package/lib/recipes/LinkedListView.stories.js +191 -141
- package/lib/recipes/ListAndPanel.stories.js +21 -46
- package/package.json +1 -1
@@ -18,6 +18,7 @@ var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
18
18
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
20
20
|
var _DotsVerticalIcon = _interopRequireDefault(require("mdi-react/DotsVerticalIcon"));
|
21
|
+
var _useOverlappingMenuHoverState = _interopRequireDefault(require("../hooks/useOverlappingMenuHoverState"));
|
21
22
|
var _index = require("../index");
|
22
23
|
var _react2 = require("@emotion/react");
|
23
24
|
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); }
|
@@ -54,7 +55,6 @@ var testData = [{
|
|
54
55
|
hasSeparator: false,
|
55
56
|
hasInsetSeparator: true,
|
56
57
|
badgeText: 'default',
|
57
|
-
expirationText: 'Expiring On: 2022-12-08',
|
58
58
|
childrenObjects: [{
|
59
59
|
key: 'Staging Policy',
|
60
60
|
name: 'Staging Policy',
|
@@ -115,6 +115,93 @@ var testSort = function testSort(array) {
|
|
115
115
|
};
|
116
116
|
var unsorted = flattenArray(testData);
|
117
117
|
var sorted = testSort(unsorted);
|
118
|
+
var sx = {
|
119
|
+
badge: {
|
120
|
+
alignItems: 'center',
|
121
|
+
alignSelf: 'center',
|
122
|
+
ml: 'lg',
|
123
|
+
p: '3px 5px 2px 5px'
|
124
|
+
},
|
125
|
+
bottomBracket: {
|
126
|
+
container: {
|
127
|
+
ml: 12,
|
128
|
+
top: -2,
|
129
|
+
position: 'relative',
|
130
|
+
maxWidth: 15
|
131
|
+
},
|
132
|
+
separator: {
|
133
|
+
backgroundColor: 'decorative.7',
|
134
|
+
marginLeft: '2px !important',
|
135
|
+
maxHeight: '30px',
|
136
|
+
width: '2px !important'
|
137
|
+
},
|
138
|
+
separatorBox: {
|
139
|
+
alignItems: 'center',
|
140
|
+
flexDirection: 'row',
|
141
|
+
minWidth: 9
|
142
|
+
}
|
143
|
+
},
|
144
|
+
expirationBadge: {
|
145
|
+
alignItems: 'center',
|
146
|
+
alignSelf: 'center',
|
147
|
+
border: 'solid 1px',
|
148
|
+
borderColor: 'neutral.80',
|
149
|
+
p: '3px 5px 2px 5px'
|
150
|
+
},
|
151
|
+
listElement: {
|
152
|
+
container: {
|
153
|
+
height: 73,
|
154
|
+
pl: 24,
|
155
|
+
pr: 14
|
156
|
+
},
|
157
|
+
subText: {
|
158
|
+
color: 'text.secondary',
|
159
|
+
fontSize: 'sm',
|
160
|
+
fontWeight: 0
|
161
|
+
},
|
162
|
+
text: {
|
163
|
+
color: 'text.primary',
|
164
|
+
fontSize: 'md',
|
165
|
+
fontWeight: 1
|
166
|
+
},
|
167
|
+
textBox: {
|
168
|
+
alignItems: 'center',
|
169
|
+
justifyContent: 'center',
|
170
|
+
marginRight: 'auto'
|
171
|
+
}
|
172
|
+
},
|
173
|
+
listViewItem: {
|
174
|
+
minHeight: '75px',
|
175
|
+
padding: 1,
|
176
|
+
'&.has-inset-separator': {
|
177
|
+
'&:before': {
|
178
|
+
borderBottom: '1px solid',
|
179
|
+
borderBottomColor: 'line.light',
|
180
|
+
bottom: 0,
|
181
|
+
content: '""',
|
182
|
+
position: 'absolute',
|
183
|
+
right: 0,
|
184
|
+
width: 'calc(100% - 43px)'
|
185
|
+
}
|
186
|
+
},
|
187
|
+
'&.is-focused': {
|
188
|
+
'&:after': {
|
189
|
+
borderBottomColor: 'focus',
|
190
|
+
bottom: 0,
|
191
|
+
content: '""',
|
192
|
+
position: 'absolute',
|
193
|
+
right: 0,
|
194
|
+
width: 'calc(100% - 43px)'
|
195
|
+
}
|
196
|
+
}
|
197
|
+
},
|
198
|
+
topBracket: {
|
199
|
+
top: 50,
|
200
|
+
left: 12,
|
201
|
+
bottom: 0,
|
202
|
+
position: 'absolute'
|
203
|
+
}
|
204
|
+
};
|
118
205
|
var Default = function Default(_ref) {
|
119
206
|
var _context2;
|
120
207
|
var args = (0, _extends2["default"])({}, ((0, _objectDestructuringEmpty2["default"])(_ref), _ref));
|
@@ -126,12 +213,9 @@ var Default = function Default(_ref) {
|
|
126
213
|
var BottomBracket = function BottomBracket() {
|
127
214
|
var color = '#CACED3';
|
128
215
|
return (0, _react2.jsx)(_index.Box, {
|
129
|
-
sx:
|
130
|
-
width: '15px',
|
131
|
-
position: 'relative'
|
132
|
-
}
|
216
|
+
sx: sx.bottomBracket.container
|
133
217
|
}, (0, _react2.jsx)(_index.Box, {
|
134
|
-
flexBasis: "
|
218
|
+
flexBasis: "53%"
|
135
219
|
}, (0, _react2.jsx)("svg", {
|
136
220
|
xmlns: "http://www.w3.org/2000/svg",
|
137
221
|
version: "1.1",
|
@@ -176,17 +260,40 @@ var Default = function Default(_ref) {
|
|
176
260
|
}))))));
|
177
261
|
};
|
178
262
|
|
263
|
+
// the vector shield and key icon.
|
264
|
+
var ShieldIcon = function ShieldIcon(props) {
|
265
|
+
return (0, _react2.jsx)("svg", (0, _extends2["default"])({
|
266
|
+
width: "19",
|
267
|
+
height: "23",
|
268
|
+
viewBox: "0 0 19 23",
|
269
|
+
xmlns: "http://www.w3.org/2000/svg"
|
270
|
+
}, props), (0, _react2.jsx)("path", {
|
271
|
+
d: "M9.5 7.33342C9.77627 7.33342 10.0412 7.44316 10.2366 7.63851C10.4319 7.83386 10.5417 8.09881 10.5417 8.37508C10.5417 8.65135 10.4319 8.9163 10.2366 9.11165C10.0412 9.307 9.77627 9.41675 9.5 9.41675C9.22373 9.41675 8.95878 9.307 8.76343 9.11165C8.56808 8.9163 8.45833 8.65135 8.45833 8.37508C8.45833 8.09881 8.56808 7.83386 8.76343 7.63851C8.95878 7.44316 9.22373 7.33342 9.5 7.33342ZM18.875 10.4584C18.875 16.2397 14.875 21.6459 9.5 22.9584C4.125 21.6459 0.125 16.2397 0.125 10.4584V4.20842L9.5 0.041748L18.875 4.20842V10.4584ZM9.5 5.25008C8.6712 5.25008 7.87634 5.57932 7.29029 6.16537C6.70424 6.75142 6.375 7.54628 6.375 8.37508C6.375 9.73967 7.23958 10.8959 8.45833 11.323V17.7501H10.5417V15.6667H12.625V13.5834H10.5417V11.323C11.7604 10.8959 12.625 9.73967 12.625 8.37508C12.625 7.54628 12.2958 6.75142 11.7097 6.16537C11.1237 5.57932 10.3288 5.25008 9.5 5.25008Z"
|
272
|
+
}));
|
273
|
+
};
|
274
|
+
var Shield = function Shield(_ref2) {
|
275
|
+
var isParent = _ref2.isParent;
|
276
|
+
return (0, _react2.jsx)(_index.Box, {
|
277
|
+
alignItems: "center",
|
278
|
+
justifyContent: "center",
|
279
|
+
minWidth: 24,
|
280
|
+
sx: {
|
281
|
+
position: 'relative'
|
282
|
+
}
|
283
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
284
|
+
icon: ShieldIcon,
|
285
|
+
color: isParent ? 'decorative.7' : 'accent.40',
|
286
|
+
size: 24,
|
287
|
+
isLinked: isParent
|
288
|
+
}), isParent && (0, _react2.jsx)(TopBracket, null));
|
289
|
+
};
|
290
|
+
|
179
291
|
// the top portion of the bracket svg, this is basically just a straight vertical line.
|
180
292
|
var TopBracket = function TopBracket() {
|
181
293
|
var color = '#CACED3';
|
182
294
|
return (0, _react2.jsx)(_index.Box, {
|
183
295
|
width: 15,
|
184
|
-
sx:
|
185
|
-
position: 'absolute',
|
186
|
-
bottom: 0,
|
187
|
-
left: 12,
|
188
|
-
top: 50
|
189
|
-
}
|
296
|
+
sx: sx.topBracket
|
190
297
|
}, (0, _react2.jsx)("svg", {
|
191
298
|
xmlns: "http://www.w3.org/2000/svg",
|
192
299
|
version: "1.1",
|
@@ -208,20 +315,11 @@ var Default = function Default(_ref) {
|
|
208
315
|
}))));
|
209
316
|
};
|
210
317
|
|
211
|
-
// the vector shield and key icon.
|
212
|
-
var ShieldVector = function ShieldVector(props) {
|
213
|
-
return (0, _react2.jsx)("svg", (0, _extends2["default"])({
|
214
|
-
width: "19",
|
215
|
-
height: "23",
|
216
|
-
viewBox: "0 0 19 23",
|
217
|
-
xmlns: "http://www.w3.org/2000/svg"
|
218
|
-
}, props), (0, _react2.jsx)("path", {
|
219
|
-
d: "M9.5 7.33342C9.77627 7.33342 10.0412 7.44316 10.2366 7.63851C10.4319 7.83386 10.5417 8.09881 10.5417 8.37508C10.5417 8.65135 10.4319 8.9163 10.2366 9.11165C10.0412 9.307 9.77627 9.41675 9.5 9.41675C9.22373 9.41675 8.95878 9.307 8.76343 9.11165C8.56808 8.9163 8.45833 8.65135 8.45833 8.37508C8.45833 8.09881 8.56808 7.83386 8.76343 7.63851C8.95878 7.44316 9.22373 7.33342 9.5 7.33342ZM18.875 10.4584C18.875 16.2397 14.875 21.6459 9.5 22.9584C4.125 21.6459 0.125 16.2397 0.125 10.4584V4.20842L9.5 0.041748L18.875 4.20842V10.4584ZM9.5 5.25008C8.6712 5.25008 7.87634 5.57932 7.29029 6.16537C6.70424 6.75142 6.375 7.54628 6.375 8.37508C6.375 9.73967 7.23958 10.8959 8.45833 11.323V17.7501H10.5417V15.6667H12.625V13.5834H10.5417V11.323C11.7604 10.8959 12.625 9.73967 12.625 8.37508C12.625 7.54628 12.2958 6.75142 11.7097 6.16537C11.1237 5.57932 10.3288 5.25008 9.5 5.25008Z"
|
220
|
-
}));
|
221
|
-
};
|
222
|
-
|
223
318
|
// reusable piece of code that handles the iconbutton and popover on the right side of the rows
|
224
|
-
var IconWithPopover = function IconWithPopover() {
|
319
|
+
var IconWithPopover = function IconWithPopover(_ref3) {
|
320
|
+
var handleHoverEnd = _ref3.handleHoverEnd,
|
321
|
+
handleHoverStart = _ref3.handleHoverStart,
|
322
|
+
handleMenuHoverEnd = _ref3.handleMenuHoverEnd;
|
225
323
|
return (0, _react2.jsx)(_index.PopoverMenu, {
|
226
324
|
direction: "left"
|
227
325
|
}, (0, _react2.jsx)(_index.Box, {
|
@@ -236,6 +334,9 @@ var Default = function Default(_ref) {
|
|
236
334
|
m: "0.61px"
|
237
335
|
}))), (0, _react2.jsx)(_index.Menu, {
|
238
336
|
direction: "left",
|
337
|
+
onAction: handleHoverEnd,
|
338
|
+
onHoverEnd: handleMenuHoverEnd,
|
339
|
+
onHoverStart: handleHoverStart,
|
239
340
|
sx: {
|
240
341
|
minWidth: '155px',
|
241
342
|
minHeight: '144px'
|
@@ -259,17 +360,12 @@ var Default = function Default(_ref) {
|
|
259
360
|
return (0, _react2.jsx)(_index.Badge, {
|
260
361
|
label: "Default",
|
261
362
|
bg: "active",
|
262
|
-
sx:
|
263
|
-
marginLeft: '25px',
|
264
|
-
alignSelf: 'center',
|
265
|
-
alignItems: 'center',
|
266
|
-
padding: '3px 5px 2px 5px'
|
267
|
-
}
|
363
|
+
sx: sx.badge
|
268
364
|
});
|
269
365
|
};
|
270
|
-
var
|
271
|
-
var expirationText =
|
272
|
-
badgeText =
|
366
|
+
var ExpirationBadge = function ExpirationBadge(_ref4) {
|
367
|
+
var expirationText = _ref4.expirationText,
|
368
|
+
badgeText = _ref4.badgeText;
|
273
369
|
return (0, _react2.jsx)(_index.Box, {
|
274
370
|
sx: !badgeText && {
|
275
371
|
paddingLeft: '72px'
|
@@ -279,129 +375,83 @@ var Default = function Default(_ref) {
|
|
279
375
|
alignSelf: "center"
|
280
376
|
}, (0, _react2.jsx)(_index.Badge, {
|
281
377
|
bg: "white",
|
282
|
-
sx:
|
283
|
-
border: 'solid 1px',
|
284
|
-
borderColor: 'neutral.80',
|
285
|
-
alignSelf: 'center',
|
286
|
-
alignItems: 'center',
|
287
|
-
padding: '3px 5px 2px 5px'
|
288
|
-
},
|
378
|
+
sx: sx.expirationBadge,
|
289
379
|
textColor: "text.primary",
|
290
380
|
label: expirationText
|
291
381
|
}));
|
292
382
|
};
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
policyId = props.policyId,
|
299
|
-
name = props.name;
|
383
|
+
var ListElementContent = function ListElementContent(_ref5) {
|
384
|
+
var badgeText = _ref5.badgeText,
|
385
|
+
isChild = _ref5.isChild,
|
386
|
+
name = _ref5.name,
|
387
|
+
policyId = _ref5.policyId;
|
300
388
|
return (0, _react2.jsx)(_index.Box, {
|
301
389
|
isRow: true,
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
sx:
|
307
|
-
|
308
|
-
|
309
|
-
}, (0, _react2.jsx)(_index.Icon, {
|
310
|
-
icon: ShieldVector,
|
311
|
-
color: hasStaging ? 'decorative.7' : 'accent.40',
|
312
|
-
size: 24,
|
313
|
-
isLinked: hasStaging
|
314
|
-
}), hasStaging && (0, _react2.jsx)(TopBracket, null)), (0, _react2.jsx)(_index.Box, {
|
315
|
-
isRow: true,
|
316
|
-
mr: "auto",
|
317
|
-
alignSelf: "center",
|
318
|
-
justifyContent: "center",
|
319
|
-
ml: "18px",
|
320
|
-
alignItems: "center"
|
321
|
-
}, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
|
322
|
-
sx: {
|
323
|
-
fontWeight: 1,
|
324
|
-
color: 'text.primary',
|
325
|
-
fontSize: 'md'
|
326
|
-
}
|
390
|
+
ml: isChild ? 0 : 18,
|
391
|
+
sx: sx.listElement.textBox
|
392
|
+
}, isChild && (0, _react2.jsx)(_index.Separator, {
|
393
|
+
orientation: "vertical",
|
394
|
+
sx: sx.bottomBracket.separator
|
395
|
+
}), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
|
396
|
+
sx: sx.listElement.text
|
327
397
|
}, name), (0, _react2.jsx)(_index.Text, {
|
328
|
-
sx:
|
329
|
-
|
330
|
-
color: 'text.secondary',
|
331
|
-
fontSize: 'sm'
|
332
|
-
}
|
333
|
-
}, "Policy Id:", ' ', policyId)), badgeText && (0, _react2.jsx)(DefaultBadge, null)), (0, _react2.jsx)(IconWithPopover, null));
|
398
|
+
sx: sx.listElement.subText
|
399
|
+
}, "Policy Id:", ' ', policyId)), badgeText && (0, _react2.jsx)(DefaultBadge, null));
|
334
400
|
};
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
401
|
+
var ListElement = function ListElement(_ref6) {
|
402
|
+
var badgeText = _ref6.badgeText,
|
403
|
+
expirationText = _ref6.expirationText,
|
404
|
+
isChild = _ref6.isChild,
|
405
|
+
isParent = _ref6.isParent,
|
406
|
+
name = _ref6.name,
|
407
|
+
policyId = _ref6.policyId;
|
408
|
+
var listItemRef = (0, _react.useRef)();
|
409
|
+
var _useOverlappingMenuHo = (0, _useOverlappingMenuHoverState["default"])({
|
410
|
+
listItemRef: listItemRef
|
411
|
+
}),
|
412
|
+
handleHoverEnd = _useOverlappingMenuHo.handleHoverEnd,
|
413
|
+
handleHoverStart = _useOverlappingMenuHo.handleHoverStart,
|
414
|
+
handleMenuHoverEnd = _useOverlappingMenuHo.handleMenuHoverEnd,
|
415
|
+
handleMouseMove = _useOverlappingMenuHo.handleMouseMove,
|
416
|
+
isHovered = _useOverlappingMenuHo.isHovered;
|
417
|
+
return (0, _react2.jsx)(_index.ListItem, {
|
418
|
+
isHovered: isHovered,
|
343
419
|
isRow: true,
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
}, (0, _react2.jsx)(
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
backgroundColor: 'decorative.7',
|
360
|
-
marginLeft: '2px !important'
|
361
|
-
}
|
362
|
-
})), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
|
363
|
-
sx: {
|
364
|
-
fontWeight: 1,
|
365
|
-
color: 'text.primary',
|
366
|
-
fontSize: 'md'
|
367
|
-
}
|
368
|
-
}, name), (0, _react2.jsx)(_index.Text, {
|
369
|
-
sx: {
|
370
|
-
fontWeight: 0,
|
371
|
-
color: 'text.secondary',
|
372
|
-
fontSize: 'sm'
|
373
|
-
}
|
374
|
-
}, "Policy Id:", ' ', policyId))), badgeText && (0, _react2.jsx)(DefaultBadge, null), expirationText && (0, _react2.jsx)(ExprirationBadge, {
|
420
|
+
onHoverEnd: handleHoverEnd,
|
421
|
+
onHoverStart: handleHoverStart,
|
422
|
+
onMouseMove: handleMouseMove,
|
423
|
+
ref: listItemRef,
|
424
|
+
variant: "listItem.hover",
|
425
|
+
sx: sx.listElement.container
|
426
|
+
}, !isChild ? (0, _react2.jsx)(Shield, {
|
427
|
+
isParent: isParent
|
428
|
+
}) : (0, _react2.jsx)(BottomBracket, null), (0, _react2.jsx)(ListElementContent, {
|
429
|
+
badgeText: badgeText,
|
430
|
+
expirationText: expirationText,
|
431
|
+
isChild: isChild,
|
432
|
+
name: name,
|
433
|
+
policyId: policyId
|
434
|
+
}), expirationText && (0, _react2.jsx)(ExpirationBadge, {
|
375
435
|
expirationText: expirationText
|
376
|
-
}), (0, _react2.jsx)(IconWithPopover,
|
436
|
+
}), (0, _react2.jsx)(IconWithPopover, {
|
437
|
+
handleHoverEnd: handleHoverEnd,
|
438
|
+
handleMenuHoverEnd: handleMenuHoverEnd,
|
439
|
+
handleHoverStart: handleHoverStart
|
440
|
+
}));
|
377
441
|
};
|
378
|
-
return (0, _react2.jsx)(_index.
|
442
|
+
return (0, _react2.jsx)(_index.ListView, (0, _extends2["default"])({}, args, {
|
379
443
|
items: theseItems
|
380
444
|
}), function (item) {
|
381
445
|
return (0, _react2.jsx)(_index.Item, (0, _extends2["default"])({}, item, {
|
382
446
|
textValue: item.name,
|
383
447
|
"data-id": item.key,
|
384
448
|
listItemProps: {
|
385
|
-
|
386
|
-
sx: {
|
387
|
-
'&.has-inset-separator': {
|
388
|
-
'&:before': {
|
389
|
-
content: '""',
|
390
|
-
position: 'absolute',
|
391
|
-
width: 'calc(100% - 43px)',
|
392
|
-
right: 0,
|
393
|
-
bottom: 0,
|
394
|
-
borderBottom: '1px solid',
|
395
|
-
borderBottomColor: 'line.light'
|
396
|
-
}
|
397
|
-
}
|
398
|
-
}
|
449
|
+
sx: sx.listViewItem
|
399
450
|
}
|
400
|
-
}),
|
401
|
-
|
402
|
-
|
403
|
-
hasStaging: item.childrenObjects
|
451
|
+
}), (0, _react2.jsx)(ListElement, (0, _extends2["default"])({
|
452
|
+
isParent: item.childrenObjects,
|
453
|
+
isChild: item.parentId
|
404
454
|
}, item)));
|
405
|
-
})
|
455
|
+
});
|
406
456
|
};
|
407
457
|
exports.Default = Default;
|
@@ -20,6 +20,7 @@ var _MoreVertIcon = _interopRequireDefault(require("mdi-react/MoreVertIcon"));
|
|
20
20
|
var _PencilIcon = _interopRequireDefault(require("mdi-react/PencilIcon"));
|
21
21
|
var _PlusIcon = _interopRequireDefault(require("mdi-react/PlusIcon"));
|
22
22
|
var _hooks = require("../hooks");
|
23
|
+
var _useOverlappingMenuHoverState = _interopRequireDefault(require("../hooks/useOverlappingMenuHoverState"));
|
23
24
|
var _index = require("../index");
|
24
25
|
var _react2 = require("@emotion/react");
|
25
26
|
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); }
|
@@ -188,46 +189,20 @@ var ListElement = function ListElement(_ref) {
|
|
188
189
|
var item = _ref.item,
|
189
190
|
isHoverable = _ref.isHoverable,
|
190
191
|
onClosePanel = _ref.onClosePanel;
|
191
|
-
var _useState = (0, _react.useState)(false),
|
192
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
193
|
-
isHovered = _useState2[0],
|
194
|
-
setIsHovered = _useState2[1];
|
195
|
-
var _useState3 = (0, _react.useState)({}),
|
196
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
197
|
-
mousePosition = _useState4[0],
|
198
|
-
setMousePosition = _useState4[1];
|
199
192
|
var listItemRef = (0, _react.useRef)();
|
200
|
-
var
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
if (hasMovedBackToRow) {
|
209
|
-
setIsHovered(true);
|
210
|
-
return;
|
211
|
-
}
|
212
|
-
setIsHovered(false);
|
213
|
-
};
|
214
|
-
var handleMouseMove = function handleMouseMove(e) {
|
215
|
-
setMousePosition({
|
216
|
-
currentPositionX: e.clientX,
|
217
|
-
currentPositionY: e.clientY
|
218
|
-
});
|
219
|
-
};
|
220
|
-
var handleHoveEnd = function handleHoveEnd() {
|
221
|
-
setIsHovered(false);
|
222
|
-
};
|
223
|
-
var handleHoveStart = function handleHoveStart() {
|
224
|
-
setIsHovered(true);
|
225
|
-
};
|
193
|
+
var _useOverlappingMenuHo = (0, _useOverlappingMenuHoverState["default"])({
|
194
|
+
listItemRef: listItemRef
|
195
|
+
}),
|
196
|
+
handleHoverEnd = _useOverlappingMenuHo.handleHoverEnd,
|
197
|
+
handleHoverStart = _useOverlappingMenuHo.handleHoverStart,
|
198
|
+
handleMenuHoverEnd = _useOverlappingMenuHo.handleMenuHoverEnd,
|
199
|
+
handleMouseMove = _useOverlappingMenuHo.handleMouseMove,
|
200
|
+
isHovered = _useOverlappingMenuHo.isHovered;
|
226
201
|
return (0, _react2.jsx)(_index.ListItem, {
|
227
202
|
isHovered: isHoverable && isHovered,
|
228
203
|
isRow: true,
|
229
|
-
onHoverEnd:
|
230
|
-
onHoverStart:
|
204
|
+
onHoverEnd: handleHoverEnd,
|
205
|
+
onHoverStart: handleHoverStart,
|
231
206
|
onMouseMove: handleMouseMove,
|
232
207
|
ref: listItemRef,
|
233
208
|
sx: sx.listElement.wrapper
|
@@ -259,9 +234,9 @@ var ListElement = function ListElement(_ref) {
|
|
259
234
|
icon: _MoreVertIcon["default"],
|
260
235
|
size: "md"
|
261
236
|
})), (0, _react2.jsx)(_index.Menu, {
|
262
|
-
onAction:
|
237
|
+
onAction: handleHoverEnd,
|
263
238
|
onHoverEnd: handleMenuHoverEnd,
|
264
|
-
onHoverStart:
|
239
|
+
onHoverStart: handleHoverStart
|
265
240
|
}, (0, _react2.jsx)(_reactStately.Item, {
|
266
241
|
key: "enable"
|
267
242
|
}, "Enable user"), (0, _react2.jsx)(_reactStately.Item, {
|
@@ -277,14 +252,14 @@ var ListElement = function ListElement(_ref) {
|
|
277
252
|
}))));
|
278
253
|
};
|
279
254
|
var Default = function Default() {
|
280
|
-
var
|
281
|
-
|
282
|
-
selectedItemId =
|
283
|
-
setSelectedItemId =
|
284
|
-
var
|
285
|
-
|
286
|
-
selectedKeys =
|
287
|
-
setSelectedKeys =
|
255
|
+
var _useState = (0, _react.useState)(),
|
256
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
257
|
+
selectedItemId = _useState2[0],
|
258
|
+
setSelectedItemId = _useState2[1];
|
259
|
+
var _useState3 = (0, _react.useState)(),
|
260
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
261
|
+
selectedKeys = _useState4[0],
|
262
|
+
setSelectedKeys = _useState4[1];
|
288
263
|
var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
|
289
264
|
panelState = _useOverlayPanelState.state,
|
290
265
|
onPanelClose = _useOverlayPanelState.onClose;
|
@@ -1,4 +1,21 @@
|
|
1
|
-
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
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; }
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
12
|
+
var hover = {
|
13
|
+
bg: 'accent.99',
|
14
|
+
'&.is-hovered': {
|
15
|
+
bg: 'white'
|
16
|
+
}
|
17
|
+
};
|
18
|
+
var container = _objectSpread({
|
2
19
|
display: 'flex',
|
3
20
|
flex: '1 1 0px',
|
4
21
|
cursor: 'pointer',
|
@@ -8,14 +25,11 @@ var container = {
|
|
8
25
|
pt: 16,
|
9
26
|
pb: 16,
|
10
27
|
justifyContent: 'center',
|
11
|
-
bg: 'accent.99',
|
12
28
|
'&.is-selected': {
|
13
29
|
bg: 'white'
|
14
|
-
},
|
15
|
-
'&.is-hovered': {
|
16
|
-
bg: 'white'
|
17
30
|
}
|
18
|
-
};
|
31
|
+
}, hover);
|
19
32
|
export default {
|
20
|
-
container: container
|
33
|
+
container: container,
|
34
|
+
hover: hover
|
21
35
|
};
|
package/lib/hooks/index.js
CHANGED
@@ -9,6 +9,7 @@ export { default as useField } from './useField';
|
|
9
9
|
export { default as useLabelHeight } from './useLabelHeight';
|
10
10
|
export { default as useModalState } from './useModalState';
|
11
11
|
export { default as useNavBarPress } from './useNavBarPress';
|
12
|
+
export { default as useOverlappingMenuHoverState } from './useOverlappingMenuHoverState';
|
12
13
|
export { default as useOverlayPanelState } from './useOverlayPanelState';
|
13
14
|
export { default as useProgressiveState } from './useProgressiveState';
|
14
15
|
export { default as usePropWarning } from './usePropWarning';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useOverlappingMenuHoverState';
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import { useState } from 'react';
|
3
|
+
|
4
|
+
// Manages the hover state of a ListItem and an overlapping PopoverMenu together
|
5
|
+
var useOverlappingMenuHoverState = function useOverlappingMenuHoverState(_ref) {
|
6
|
+
var listItemRef = _ref.listItemRef;
|
7
|
+
var _useState = useState(false),
|
8
|
+
_useState2 = _slicedToArray(_useState, 2),
|
9
|
+
isHovered = _useState2[0],
|
10
|
+
setIsHovered = _useState2[1];
|
11
|
+
var _useState3 = useState({}),
|
12
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
13
|
+
mousePosition = _useState4[0],
|
14
|
+
setMousePosition = _useState4[1];
|
15
|
+
var handleMenuHoverEnd = function handleMenuHoverEnd() {
|
16
|
+
var currentPositionX = mousePosition.currentPositionX,
|
17
|
+
currentPositionY = mousePosition.currentPositionY;
|
18
|
+
var _listItemRef$current$ = listItemRef.current.getBoundingClientRect(),
|
19
|
+
height = _listItemRef$current$.height,
|
20
|
+
right = _listItemRef$current$.right,
|
21
|
+
top = _listItemRef$current$.top,
|
22
|
+
width = _listItemRef$current$.width;
|
23
|
+
|
24
|
+
// Uses the position of the mouse and list item dimensions from listItemRef
|
25
|
+
// to determine if mouse has moved back to ListItem
|
26
|
+
var hasMovedBackToRow = currentPositionY > top && currentPositionY < top + height && currentPositionX < right && currentPositionX > right - width;
|
27
|
+
if (hasMovedBackToRow) {
|
28
|
+
setIsHovered(true);
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
setIsHovered(false);
|
32
|
+
};
|
33
|
+
var handleMouseMove = function handleMouseMove(e) {
|
34
|
+
setMousePosition({
|
35
|
+
currentPositionX: e.clientX,
|
36
|
+
currentPositionY: e.clientY
|
37
|
+
});
|
38
|
+
};
|
39
|
+
var handleHoverEnd = function handleHoverEnd() {
|
40
|
+
setIsHovered(false);
|
41
|
+
};
|
42
|
+
var handleHoverStart = function handleHoverStart() {
|
43
|
+
setIsHovered(true);
|
44
|
+
};
|
45
|
+
return {
|
46
|
+
handleHoverEnd: handleHoverEnd,
|
47
|
+
handleHoverStart: handleHoverStart,
|
48
|
+
handleMenuHoverEnd: handleMenuHoverEnd,
|
49
|
+
handleMouseMove: handleMouseMove,
|
50
|
+
isHovered: isHovered
|
51
|
+
};
|
52
|
+
};
|
53
|
+
export default useOverlappingMenuHoverState;
|