orcs-design-system 3.3.33 → 3.3.35
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.
|
@@ -386,7 +386,8 @@ export const headerAvatarVariants = () => {
|
|
|
386
386
|
headerAvatar: true,
|
|
387
387
|
sizing: "small",
|
|
388
388
|
image: "https://randomuser.me/api/portraits/men/32.jpg",
|
|
389
|
-
imageAlt: "Avatar for John Doe"
|
|
389
|
+
imageAlt: "Avatar for John Doe",
|
|
390
|
+
onClick: handleClick
|
|
390
391
|
}), /*#__PURE__*/_jsx(Avatar, {
|
|
391
392
|
headerAvatar: true,
|
|
392
393
|
sizing: "large",
|
|
@@ -399,7 +400,8 @@ export const headerAvatarVariants = () => {
|
|
|
399
400
|
sizing: "small",
|
|
400
401
|
shape: "square",
|
|
401
402
|
image: "https://images.unsplash.com/photo-1464802686167-b939a6910659?q=80&w=3500&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
|
402
|
-
imageAlt: "Avatar for Nebula UI"
|
|
403
|
+
imageAlt: "Avatar for Nebula UI",
|
|
404
|
+
onClick: handleClick
|
|
403
405
|
})]
|
|
404
406
|
});
|
|
405
407
|
};
|
|
@@ -360,47 +360,54 @@ const HeaderAvatarShape = styled("div").withConfig({
|
|
|
360
360
|
})
|
|
361
361
|
};
|
|
362
362
|
});
|
|
363
|
-
const
|
|
364
|
-
displayName: "
|
|
363
|
+
const HeaderAvatarAction = styled("button").withConfig({
|
|
364
|
+
displayName: "Avatar__HeaderAvatarAction",
|
|
365
365
|
componentId: "sc-1wtet2j-11"
|
|
366
|
+
})(() => ({
|
|
367
|
+
cursor: "pointer",
|
|
368
|
+
padding: "0",
|
|
369
|
+
background: "none",
|
|
370
|
+
border: "none",
|
|
371
|
+
outline: "none",
|
|
372
|
+
appearance: "none",
|
|
373
|
+
position: "relative",
|
|
374
|
+
"&:hover": {
|
|
375
|
+
"& > .icon-container": {
|
|
376
|
+
opacity: "1"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}));
|
|
380
|
+
const IconContainer = styled("div").withConfig({
|
|
381
|
+
displayName: "Avatar__IconContainer",
|
|
382
|
+
componentId: "sc-1wtet2j-12"
|
|
366
383
|
})(_ref6 => {
|
|
367
384
|
let {
|
|
368
|
-
$shape
|
|
385
|
+
$shape,
|
|
386
|
+
$sizing
|
|
369
387
|
} = _ref6;
|
|
370
388
|
return {
|
|
389
|
+
opacity: "0",
|
|
390
|
+
transition: "opacity 0.2s ease-in-out",
|
|
371
391
|
position: "absolute",
|
|
372
|
-
top:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
});
|
|
377
|
-
const HeaderAvatarAction = styled("button").withConfig({
|
|
378
|
-
displayName: "Avatar__HeaderAvatarAction",
|
|
379
|
-
componentId: "sc-1wtet2j-12"
|
|
380
|
-
})(_ref7 => {
|
|
381
|
-
let {
|
|
382
|
-
...props
|
|
383
|
-
} = _ref7;
|
|
384
|
-
return {
|
|
385
|
-
width: "36px",
|
|
386
|
-
height: "36px",
|
|
387
|
-
borderRadius: "50%",
|
|
388
|
-
background: "#e6e6e6",
|
|
389
|
-
border: "solid 2px #fff",
|
|
390
|
-
boxShadow: "0 2px 8px 0 rgba(0,0,0,0.10)",
|
|
392
|
+
top: $sizing === "large" ? "6px" : "4px",
|
|
393
|
+
left: $sizing === "large" ? "6px" : "4px",
|
|
394
|
+
width: $sizing === "large" ? "calc(100% - 12px)" : "calc(100% - 8px)",
|
|
395
|
+
height: $sizing === "large" ? "calc(100% - 18px)" : "calc(100% - 12px)",
|
|
391
396
|
display: "flex",
|
|
392
397
|
alignItems: "center",
|
|
393
398
|
justifyContent: "center",
|
|
394
|
-
|
|
395
|
-
zIndex: 2,
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
400
|
+
zIndex: "2",
|
|
401
|
+
borderRadius: $shape === "circle" || !$shape ? "50%" : "0",
|
|
402
|
+
...($shape === "hexagon" && {
|
|
403
|
+
clipPath: "polygon(50% 0, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%)"
|
|
404
|
+
}),
|
|
405
|
+
...($shape === "tag" && {
|
|
406
|
+
clipPath: "polygon(6% 0, 95% 0, 95% 65%, 50% 100%, 6% 65%)"
|
|
407
|
+
})
|
|
401
408
|
};
|
|
402
409
|
});
|
|
403
|
-
const Avatar =
|
|
410
|
+
const Avatar = _ref7 => {
|
|
404
411
|
let {
|
|
405
412
|
sizing,
|
|
406
413
|
image,
|
|
@@ -419,7 +426,7 @@ const Avatar = _ref8 => {
|
|
|
419
426
|
headerAvatar = false,
|
|
420
427
|
onClick,
|
|
421
428
|
...props
|
|
422
|
-
} =
|
|
429
|
+
} = _ref7;
|
|
423
430
|
const hasTitle = !!title;
|
|
424
431
|
const hasSubtitle = !!subtitle;
|
|
425
432
|
const hasSubtitleContent = !!subtitleContent;
|
|
@@ -443,11 +450,11 @@ const Avatar = _ref8 => {
|
|
|
443
450
|
theme
|
|
444
451
|
}) || customSize;
|
|
445
452
|
}
|
|
446
|
-
|
|
453
|
+
const avatarContent = /*#__PURE__*/_jsx(HeaderAvatarWrapper, {
|
|
447
454
|
...props,
|
|
448
455
|
$size: size,
|
|
449
456
|
$shape: shape,
|
|
450
|
-
children:
|
|
457
|
+
children: /*#__PURE__*/_jsx(HeaderAvatarBorder, {
|
|
451
458
|
$size: size,
|
|
452
459
|
$shape: shape,
|
|
453
460
|
$sizing: sizing,
|
|
@@ -469,27 +476,36 @@ const Avatar = _ref8 => {
|
|
|
469
476
|
icon: ["fas", "user"]
|
|
470
477
|
})
|
|
471
478
|
})
|
|
472
|
-
})
|
|
479
|
+
})
|
|
480
|
+
});
|
|
481
|
+
if (onClick) {
|
|
482
|
+
return /*#__PURE__*/_jsx(Popover, {
|
|
473
483
|
direction: "right",
|
|
474
484
|
width: "fit-content",
|
|
475
485
|
$shape: shape,
|
|
476
486
|
text: shape === "circle" ? "Upload profile picture" : "Change image",
|
|
477
|
-
|
|
487
|
+
headerAvatarSizing: sizing,
|
|
488
|
+
children: /*#__PURE__*/_jsxs(HeaderAvatarAction, {
|
|
478
489
|
onClick: onClick,
|
|
479
490
|
"aria-label": "Edit avatar",
|
|
480
|
-
children:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
491
|
+
children: [/*#__PURE__*/_jsx(IconContainer, {
|
|
492
|
+
$shape: shape,
|
|
493
|
+
$sizing: sizing,
|
|
494
|
+
className: "icon-container",
|
|
495
|
+
children: shape === "circle" ? /*#__PURE__*/_jsx(Icon, {
|
|
496
|
+
icon: ["fas", "camera"],
|
|
497
|
+
size: sizing === "large" ? "lg" : "1x",
|
|
498
|
+
color: "white"
|
|
499
|
+
}) : /*#__PURE__*/_jsx(Icon, {
|
|
500
|
+
icon: ["fas", "image"],
|
|
501
|
+
size: sizing === "large" ? "lg" : "1x",
|
|
502
|
+
color: "white"
|
|
503
|
+
})
|
|
504
|
+
}), avatarContent]
|
|
490
505
|
})
|
|
491
|
-
})
|
|
492
|
-
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
return avatarContent;
|
|
493
509
|
}
|
|
494
510
|
const component = /*#__PURE__*/_jsxs(AvatarWrapper, {
|
|
495
511
|
...props,
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, useMemo } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import Box from "../Box";
|
|
4
4
|
import ColorPickerLib from "react-best-gradient-color-picker";
|
|
5
|
+
import { FloatingPortal } from "@floating-ui/react";
|
|
6
|
+
import { getFloatingUiRootElement } from "../../utils/floatingUiHelpers";
|
|
7
|
+
import useActionMenu from "../ActionsMenu/useActionMenu";
|
|
5
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
9
|
const ColorPicker = _ref => {
|
|
7
10
|
let {
|
|
8
11
|
value,
|
|
9
12
|
onChange,
|
|
10
13
|
children,
|
|
11
|
-
position = "bottom-
|
|
14
|
+
position = "bottom-end",
|
|
12
15
|
zIndex = 20,
|
|
13
16
|
bg = "#202020",
|
|
14
17
|
p = "s",
|
|
@@ -33,131 +36,52 @@ const ColorPicker = _ref => {
|
|
|
33
36
|
...colorPickerProps
|
|
34
37
|
} = _ref;
|
|
35
38
|
const [isOpen, setIsOpen] = useState(false);
|
|
36
|
-
const colorPickerRef = useRef(null);
|
|
37
|
-
const triggerRef = useRef(null);
|
|
38
|
-
|
|
39
|
-
// Handle clicks outside to close
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
function handleClickOutside(event) {
|
|
42
|
-
if (colorPickerRef.current && !colorPickerRef.current.contains(event.target) && triggerRef.current && !triggerRef.current.contains(event.target)) {
|
|
43
|
-
setIsOpen(false);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (isOpen) {
|
|
47
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
48
|
-
return () => {
|
|
49
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
}, [isOpen]);
|
|
54
39
|
const toggleColorPicker = () => setIsOpen(!isOpen);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
case "top-start":
|
|
67
|
-
return {
|
|
68
|
-
...baseStyles,
|
|
69
|
-
bottom: "100%",
|
|
70
|
-
right: "0",
|
|
71
|
-
mb: "s"
|
|
72
|
-
};
|
|
73
|
-
case "top-end":
|
|
74
|
-
return {
|
|
75
|
-
...baseStyles,
|
|
76
|
-
bottom: "100%",
|
|
77
|
-
left: "0",
|
|
78
|
-
mb: "s"
|
|
79
|
-
};
|
|
80
|
-
case "bottom-start":
|
|
81
|
-
return {
|
|
82
|
-
...baseStyles,
|
|
83
|
-
top: "100%",
|
|
84
|
-
right: "0",
|
|
85
|
-
mt: "s"
|
|
86
|
-
};
|
|
87
|
-
case "bottom-end":
|
|
88
|
-
return {
|
|
89
|
-
...baseStyles,
|
|
90
|
-
top: "100%",
|
|
91
|
-
left: "0",
|
|
92
|
-
mt: "s"
|
|
93
|
-
};
|
|
94
|
-
case "left-start":
|
|
95
|
-
return {
|
|
96
|
-
...baseStyles,
|
|
97
|
-
right: "100%",
|
|
98
|
-
top: "0",
|
|
99
|
-
mr: "s"
|
|
100
|
-
};
|
|
101
|
-
case "left-end":
|
|
102
|
-
return {
|
|
103
|
-
...baseStyles,
|
|
104
|
-
right: "100%",
|
|
105
|
-
bottom: "0",
|
|
106
|
-
mr: "s"
|
|
107
|
-
};
|
|
108
|
-
case "right-start":
|
|
109
|
-
return {
|
|
110
|
-
...baseStyles,
|
|
111
|
-
left: "100%",
|
|
112
|
-
top: "0",
|
|
113
|
-
ml: "s"
|
|
114
|
-
};
|
|
115
|
-
case "right-end":
|
|
116
|
-
return {
|
|
117
|
-
...baseStyles,
|
|
118
|
-
left: "100%",
|
|
119
|
-
bottom: "0",
|
|
120
|
-
ml: "s"
|
|
121
|
-
};
|
|
122
|
-
default:
|
|
123
|
-
return {
|
|
124
|
-
...baseStyles,
|
|
125
|
-
top: "100%",
|
|
126
|
-
right: "0",
|
|
127
|
-
mt: "s"
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
};
|
|
40
|
+
const baseStyles = useMemo(() => ({
|
|
41
|
+
zIndex,
|
|
42
|
+
bg,
|
|
43
|
+
p,
|
|
44
|
+
borderRadius
|
|
45
|
+
}), [zIndex, bg, p, borderRadius]);
|
|
46
|
+
const actionMenu = useActionMenu({
|
|
47
|
+
placement: position,
|
|
48
|
+
open: isOpen,
|
|
49
|
+
onOpenChange: setIsOpen
|
|
50
|
+
});
|
|
131
51
|
return /*#__PURE__*/_jsxs(Box, {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
52
|
+
ref: actionMenu.refs.setReference,
|
|
53
|
+
...actionMenu.getReferenceProps(),
|
|
54
|
+
children: [typeof children === "function" ? children({
|
|
55
|
+
isOpen,
|
|
56
|
+
toggleColorPicker
|
|
57
|
+
}) : children, isOpen && /*#__PURE__*/_jsx(FloatingPortal, {
|
|
58
|
+
root: getFloatingUiRootElement(actionMenu.refs.reference),
|
|
59
|
+
preserveTabOrder: true,
|
|
60
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
61
|
+
ref: actionMenu.refs.setFloating,
|
|
62
|
+
style: actionMenu.floatingStyles,
|
|
63
|
+
...baseStyles,
|
|
64
|
+
...actionMenu.getFloatingProps(),
|
|
65
|
+
children: /*#__PURE__*/_jsx(ColorPickerLib, {
|
|
66
|
+
value: value,
|
|
67
|
+
onChange: onChange,
|
|
68
|
+
width: width,
|
|
69
|
+
height: height,
|
|
70
|
+
hidePresets: hidePresets,
|
|
71
|
+
hideInputs: hideInputs,
|
|
72
|
+
hideControls: hideControls,
|
|
73
|
+
hideOpacity: hideOpacity,
|
|
74
|
+
hideEyeDrop: hideEyeDrop,
|
|
75
|
+
hideAdvancedSliders: hideAdvancedSliders,
|
|
76
|
+
hideColorGuide: hideColorGuide,
|
|
77
|
+
hideInputType: hideInputType,
|
|
78
|
+
hideColorTypeBtns: hideColorTypeBtns,
|
|
79
|
+
hideGradientType: hideGradientType,
|
|
80
|
+
hideGradientAngle: hideGradientAngle,
|
|
81
|
+
hideGradientStop: hideGradientStop,
|
|
82
|
+
hideGradientControls: hideGradientControls,
|
|
83
|
+
...colorPickerProps
|
|
84
|
+
})
|
|
161
85
|
})
|
|
162
86
|
})]
|
|
163
87
|
});
|
|
@@ -197,7 +121,7 @@ ColorPicker.__docgenInfo = {
|
|
|
197
121
|
"props": {
|
|
198
122
|
"position": {
|
|
199
123
|
"defaultValue": {
|
|
200
|
-
"value": "\"bottom-
|
|
124
|
+
"value": "\"bottom-end\"",
|
|
201
125
|
"computed": false
|
|
202
126
|
},
|
|
203
127
|
"description": "",
|
|
@@ -21,6 +21,7 @@ export default {
|
|
|
21
21
|
};
|
|
22
22
|
export const defaultPopover = () => /*#__PURE__*/_jsx(Popover, {
|
|
23
23
|
text: "Description that explains child element",
|
|
24
|
+
width: "fit-content",
|
|
24
25
|
children: /*#__PURE__*/_jsx(Button, {
|
|
25
26
|
onClick: () => alert("Maintains original click"),
|
|
26
27
|
children: "Hover Me!"
|
|
@@ -38,6 +39,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
38
39
|
children: [/*#__PURE__*/_jsx(Popover, {
|
|
39
40
|
direction: "topLeft",
|
|
40
41
|
text: "Description that explains child element",
|
|
42
|
+
width: "fit-content",
|
|
41
43
|
children: /*#__PURE__*/_jsx(Button, {
|
|
42
44
|
width: "125px",
|
|
43
45
|
children: "Top left"
|
|
@@ -45,6 +47,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
45
47
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
46
48
|
direction: "top",
|
|
47
49
|
text: "Description that explains child element",
|
|
50
|
+
width: "fit-content",
|
|
48
51
|
children: /*#__PURE__*/_jsx(Button, {
|
|
49
52
|
width: "125px",
|
|
50
53
|
children: "Top"
|
|
@@ -52,6 +55,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
52
55
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
53
56
|
direction: "topRight",
|
|
54
57
|
text: "Description that explains child element",
|
|
58
|
+
width: "fit-content",
|
|
55
59
|
children: /*#__PURE__*/_jsx(Button, {
|
|
56
60
|
width: "125px",
|
|
57
61
|
children: "Top right"
|
|
@@ -59,6 +63,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
59
63
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
60
64
|
direction: "left",
|
|
61
65
|
text: "Description that explains child element",
|
|
66
|
+
width: "fit-content",
|
|
62
67
|
children: /*#__PURE__*/_jsx(Button, {
|
|
63
68
|
width: "125px",
|
|
64
69
|
children: "Left"
|
|
@@ -70,6 +75,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
70
75
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
71
76
|
direction: "right",
|
|
72
77
|
text: "Description that explains child element",
|
|
78
|
+
width: "fit-content",
|
|
73
79
|
children: /*#__PURE__*/_jsx(Button, {
|
|
74
80
|
width: "125px",
|
|
75
81
|
children: "Right"
|
|
@@ -77,6 +83,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
77
83
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
78
84
|
direction: "bottomLeft",
|
|
79
85
|
text: "Description that explains child element",
|
|
86
|
+
width: "fit-content",
|
|
80
87
|
children: /*#__PURE__*/_jsx(Button, {
|
|
81
88
|
width: "125px",
|
|
82
89
|
children: "Bottom left"
|
|
@@ -84,6 +91,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
84
91
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
85
92
|
direction: "bottom",
|
|
86
93
|
text: "Description that explains child element",
|
|
94
|
+
width: "fit-content",
|
|
87
95
|
children: /*#__PURE__*/_jsx(Button, {
|
|
88
96
|
width: "125px",
|
|
89
97
|
children: "Bottom"
|
|
@@ -91,6 +99,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
91
99
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
92
100
|
direction: "bottomRight",
|
|
93
101
|
text: "Description that explains child element",
|
|
102
|
+
width: "fit-content",
|
|
94
103
|
children: /*#__PURE__*/_jsx(Button, {
|
|
95
104
|
width: "125px",
|
|
96
105
|
children: "Bottom right"
|
|
@@ -100,8 +109,8 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
|
|
|
100
109
|
});
|
|
101
110
|
direction.storyName = "Direction";
|
|
102
111
|
export const specifiedWidth = () => /*#__PURE__*/_jsx(Popover, {
|
|
103
|
-
text: "
|
|
104
|
-
width: "
|
|
112
|
+
text: "Long description that you might not want to show on one line, and instead would like it to wrap",
|
|
113
|
+
width: "200px",
|
|
105
114
|
children: /*#__PURE__*/_jsx(Button, {
|
|
106
115
|
children: "Hover Me"
|
|
107
116
|
})
|
|
@@ -109,6 +118,7 @@ export const specifiedWidth = () => /*#__PURE__*/_jsx(Popover, {
|
|
|
109
118
|
export const textAlignment = () => /*#__PURE__*/_jsx(Popover, {
|
|
110
119
|
textAlign: "center",
|
|
111
120
|
text: "Centered description that explains child element",
|
|
121
|
+
width: "fit-content",
|
|
112
122
|
children: /*#__PURE__*/_jsx(Button, {
|
|
113
123
|
children: "Hover Me"
|
|
114
124
|
})
|
|
@@ -120,23 +130,27 @@ export const DisplayInlineBlock = () => /*#__PURE__*/_jsx(Flex, {
|
|
|
120
130
|
children: [/*#__PURE__*/_jsx(Popover, {
|
|
121
131
|
text: "Description that explains child element",
|
|
122
132
|
inlineBlock: true,
|
|
133
|
+
width: "fit-content",
|
|
123
134
|
children: /*#__PURE__*/_jsx(Button, {
|
|
124
135
|
children: "Inline Block Set"
|
|
125
136
|
})
|
|
126
137
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
127
138
|
text: "Description that explains child element",
|
|
128
139
|
inlineBlock: true,
|
|
140
|
+
width: "fit-content",
|
|
129
141
|
children: /*#__PURE__*/_jsx(Button, {
|
|
130
142
|
children: "Inline Block Set"
|
|
131
143
|
})
|
|
132
144
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
133
145
|
text: "Because it is display: block, the triggering container is wider than the button",
|
|
146
|
+
width: "fit-content",
|
|
134
147
|
children: /*#__PURE__*/_jsx(Button, {
|
|
135
148
|
children: "Not Inline"
|
|
136
149
|
})
|
|
137
150
|
}), /*#__PURE__*/_jsx(Popover, {
|
|
138
151
|
direction: "top",
|
|
139
152
|
text: "Description that explains child element",
|
|
153
|
+
width: "fit-content",
|
|
140
154
|
children: /*#__PURE__*/_jsx(Button, {
|
|
141
155
|
children: "Not Inline"
|
|
142
156
|
})
|
|
@@ -146,7 +160,8 @@ export const DisplayInlineBlock = () => /*#__PURE__*/_jsx(Flex, {
|
|
|
146
160
|
export const tooltipExample = () => /*#__PURE__*/_jsx(Popover, {
|
|
147
161
|
text: "This tooltip helps explain stuff",
|
|
148
162
|
direction: "top",
|
|
149
|
-
variant: "tooltip"
|
|
163
|
+
variant: "tooltip",
|
|
164
|
+
width: "fit-content"
|
|
150
165
|
});
|
|
151
166
|
tooltipExample.storyName = "Tooltip Example";
|
|
152
167
|
export const tooltipWithLinkExample = () => /*#__PURE__*/_jsx(Popover, {
|
|
@@ -160,7 +175,8 @@ export const tooltipWithLinkExample = () => /*#__PURE__*/_jsx(Popover, {
|
|
|
160
175
|
arialLabel: "Link to TeamForm",
|
|
161
176
|
direction: "right",
|
|
162
177
|
variant: "tooltip",
|
|
163
|
-
enableSelectAll: false
|
|
178
|
+
enableSelectAll: false,
|
|
179
|
+
width: "fit-content"
|
|
164
180
|
});
|
|
165
181
|
tooltipWithLinkExample.storyName = "Tooltip with link Example";
|
|
166
182
|
export const iconExample = () => /*#__PURE__*/_jsx(Popover, {
|
|
@@ -179,12 +195,90 @@ export const keepInViewExample = () => /*#__PURE__*/_jsx(Flex, {
|
|
|
179
195
|
width: "100%",
|
|
180
196
|
children: /*#__PURE__*/_jsx(Popover, {
|
|
181
197
|
text: "Description that explains child element",
|
|
198
|
+
width: "fit-content",
|
|
182
199
|
children: /*#__PURE__*/_jsx(Button, {
|
|
183
200
|
children: "Hover Me!"
|
|
184
201
|
})
|
|
185
202
|
})
|
|
186
203
|
});
|
|
187
204
|
keepInViewExample.storyName = "Keep In View Example";
|
|
205
|
+
export const customOffset = () => /*#__PURE__*/_jsx("div", {
|
|
206
|
+
children: /*#__PURE__*/_jsxs(Spacer, {
|
|
207
|
+
mb: "r",
|
|
208
|
+
children: [/*#__PURE__*/_jsx(Popover, {
|
|
209
|
+
text: "Default offset (10px mainAxis)",
|
|
210
|
+
direction: "right",
|
|
211
|
+
width: "fit-content",
|
|
212
|
+
inlineBlock: true,
|
|
213
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
214
|
+
height: "130px",
|
|
215
|
+
children: "Default Offset"
|
|
216
|
+
})
|
|
217
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
218
|
+
text: "Custom offset: 30px mainAxis (moved further away)",
|
|
219
|
+
direction: "right",
|
|
220
|
+
offset: {
|
|
221
|
+
mainAxis: 30
|
|
222
|
+
},
|
|
223
|
+
width: "fit-content",
|
|
224
|
+
inlineBlock: true,
|
|
225
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
226
|
+
height: "130px",
|
|
227
|
+
children: "30px Main Axis (Right)"
|
|
228
|
+
})
|
|
229
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
230
|
+
text: "Custom offset: -10px mainAxis (moved closer)",
|
|
231
|
+
direction: "right",
|
|
232
|
+
offset: {
|
|
233
|
+
mainAxis: -10
|
|
234
|
+
},
|
|
235
|
+
width: "fit-content",
|
|
236
|
+
inlineBlock: true,
|
|
237
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
238
|
+
height: "130px",
|
|
239
|
+
children: "-10px Main Axis (Left)"
|
|
240
|
+
})
|
|
241
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
242
|
+
text: "Custom offset: 20px alignmentAxis (moved down)",
|
|
243
|
+
direction: "right",
|
|
244
|
+
offset: {
|
|
245
|
+
alignmentAxis: 20
|
|
246
|
+
},
|
|
247
|
+
width: "fit-content",
|
|
248
|
+
inlineBlock: true,
|
|
249
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
250
|
+
height: "130px",
|
|
251
|
+
children: "20px Alignment Axis (Down)"
|
|
252
|
+
})
|
|
253
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
254
|
+
text: "Custom offset: -20px alignmentAxis (moved up)",
|
|
255
|
+
direction: "right",
|
|
256
|
+
offset: {
|
|
257
|
+
alignmentAxis: -20
|
|
258
|
+
},
|
|
259
|
+
width: "fit-content",
|
|
260
|
+
inlineBlock: true,
|
|
261
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
262
|
+
height: "130px",
|
|
263
|
+
children: "-20px Alignment Axis (Up)"
|
|
264
|
+
})
|
|
265
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
266
|
+
text: "Custom offset: both axes combined",
|
|
267
|
+
direction: "right",
|
|
268
|
+
offset: {
|
|
269
|
+
mainAxis: 25,
|
|
270
|
+
alignmentAxis: -25
|
|
271
|
+
},
|
|
272
|
+
width: "fit-content",
|
|
273
|
+
inlineBlock: true,
|
|
274
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
275
|
+
height: "130px",
|
|
276
|
+
children: "Combined Axes (right and up)"
|
|
277
|
+
})
|
|
278
|
+
})]
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
customOffset.storyName = "Custom Offset";
|
|
188
282
|
defaultPopover.__docgenInfo = {
|
|
189
283
|
"description": "",
|
|
190
284
|
"methods": [],
|
|
@@ -229,4 +323,9 @@ keepInViewExample.__docgenInfo = {
|
|
|
229
323
|
"description": "",
|
|
230
324
|
"methods": [],
|
|
231
325
|
"displayName": "keepInViewExample"
|
|
326
|
+
};
|
|
327
|
+
customOffset.__docgenInfo = {
|
|
328
|
+
"description": "",
|
|
329
|
+
"methods": [],
|
|
330
|
+
"displayName": "customOffset"
|
|
232
331
|
};
|
|
@@ -84,9 +84,39 @@ export default function Popover(_ref) {
|
|
|
84
84
|
ariaLabel,
|
|
85
85
|
inlineBlock,
|
|
86
86
|
withFocusControl = true,
|
|
87
|
+
offset: customOffset,
|
|
88
|
+
headerAvatarSizing,
|
|
87
89
|
...props
|
|
88
90
|
} = _ref;
|
|
89
91
|
const [visible, setVisible] = useState(false);
|
|
92
|
+
const middleware = useMemo(() => [offset(_ref2 => {
|
|
93
|
+
let {
|
|
94
|
+
rects
|
|
95
|
+
} = _ref2;
|
|
96
|
+
const defaultOffset = {
|
|
97
|
+
mainAxis: 10,
|
|
98
|
+
alignmentAxis: -rects.floating.width
|
|
99
|
+
};
|
|
100
|
+
if (customOffset) {
|
|
101
|
+
// For simple placements (right, left, top, bottom), use crossAxis instead of alignmentAxis
|
|
102
|
+
const placement = DIRECTIONS_MAP[direction] || direction || "right";
|
|
103
|
+
const isSimplePlacement = !placement.includes("-");
|
|
104
|
+
if (isSimplePlacement && customOffset.alignmentAxis !== undefined) {
|
|
105
|
+
return {
|
|
106
|
+
...defaultOffset,
|
|
107
|
+
mainAxis: customOffset.mainAxis !== undefined ? customOffset.mainAxis : defaultOffset.mainAxis,
|
|
108
|
+
crossAxis: customOffset.alignmentAxis
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
...defaultOffset,
|
|
113
|
+
...customOffset
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return defaultOffset;
|
|
117
|
+
}), flip({
|
|
118
|
+
fallbackAxisSideDirection: "start"
|
|
119
|
+
}), shift()], [direction, customOffset]);
|
|
90
120
|
const {
|
|
91
121
|
refs,
|
|
92
122
|
floatingStyles,
|
|
@@ -96,17 +126,7 @@ export default function Popover(_ref) {
|
|
|
96
126
|
onOpenChange: setVisible,
|
|
97
127
|
placement: DIRECTIONS_MAP[direction] || direction || "right",
|
|
98
128
|
whileElementsMounted: autoUpdate,
|
|
99
|
-
middleware
|
|
100
|
-
let {
|
|
101
|
-
rects
|
|
102
|
-
} = _ref2;
|
|
103
|
-
return {
|
|
104
|
-
mainAxis: 10,
|
|
105
|
-
alignmentAxis: -rects.floating.width
|
|
106
|
-
};
|
|
107
|
-
}), flip({
|
|
108
|
-
fallbackAxisSideDirection: "start"
|
|
109
|
-
}), shift()]
|
|
129
|
+
middleware
|
|
110
130
|
});
|
|
111
131
|
const hover = useHover(context, {
|
|
112
132
|
move: false,
|
|
@@ -132,10 +152,19 @@ export default function Popover(_ref) {
|
|
|
132
152
|
tabIndex: "0"
|
|
133
153
|
}), [getReferenceProps, refs.setReference]);
|
|
134
154
|
const directionClass = useMemo(() => context.placement === DIRECTIONS_MAP[direction] ? direction : context.placement, [context.placement, direction]);
|
|
135
|
-
const style = useMemo(() =>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
155
|
+
const style = useMemo(() => {
|
|
156
|
+
const baseStyle = {
|
|
157
|
+
...floatingStyles,
|
|
158
|
+
zIndex: getFloatingUiZIndex(context.refs.reference)
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Add CSS-based positioning for Header Avatar sizing changes
|
|
162
|
+
if (headerAvatarSizing) {
|
|
163
|
+
const translateY = headerAvatarSizing === "large" ? -56 : -3;
|
|
164
|
+
baseStyle.transform = `${baseStyle.transform || ""} translateY(${translateY}px)`;
|
|
165
|
+
}
|
|
166
|
+
return baseStyle;
|
|
167
|
+
}, [floatingStyles, context.refs.reference, headerAvatarSizing]);
|
|
139
168
|
const containsLinks = withFocusControl && refs.floating?.current?.querySelectorAll("a").length;
|
|
140
169
|
const visiblePopoverClassName = useMemo(() => `Tooltip popover visible ${directionClass}`, [directionClass]);
|
|
141
170
|
const floatingProps = useMemo(() => getFloatingProps({
|
|
@@ -230,7 +259,11 @@ Popover.propTypes = {
|
|
|
230
259
|
tabIndex: PropTypes.number,
|
|
231
260
|
className: PropTypes.string,
|
|
232
261
|
/** Render tooltip with focus control when there is link inside, defaults to true */
|
|
233
|
-
withFocusControl: PropTypes.bool
|
|
262
|
+
withFocusControl: PropTypes.bool,
|
|
263
|
+
/** Custom offset configuration for the popover positioning. Can be an object with mainAxis and/or alignmentAxis properties, or a function that returns an offset object. */
|
|
264
|
+
offset: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
265
|
+
/** Special prop for Header Avatar to apply CSS-based positioning adjustments when sizing changes dynamically */
|
|
266
|
+
headerAvatarSizing: PropTypes.oneOf(["large", "default", "small"])
|
|
234
267
|
};
|
|
235
268
|
Popover.__docgenInfo = {
|
|
236
269
|
"description": "",
|
|
@@ -356,6 +389,35 @@ Popover.__docgenInfo = {
|
|
|
356
389
|
"name": "string"
|
|
357
390
|
},
|
|
358
391
|
"required": false
|
|
392
|
+
},
|
|
393
|
+
"offset": {
|
|
394
|
+
"description": "Custom offset configuration for the popover positioning. Can be an object with mainAxis and/or alignmentAxis properties, or a function that returns an offset object.",
|
|
395
|
+
"type": {
|
|
396
|
+
"name": "union",
|
|
397
|
+
"value": [{
|
|
398
|
+
"name": "object"
|
|
399
|
+
}, {
|
|
400
|
+
"name": "func"
|
|
401
|
+
}]
|
|
402
|
+
},
|
|
403
|
+
"required": false
|
|
404
|
+
},
|
|
405
|
+
"headerAvatarSizing": {
|
|
406
|
+
"description": "Special prop for Header Avatar to apply CSS-based positioning adjustments when sizing changes dynamically",
|
|
407
|
+
"type": {
|
|
408
|
+
"name": "enum",
|
|
409
|
+
"value": [{
|
|
410
|
+
"value": "\"large\"",
|
|
411
|
+
"computed": false
|
|
412
|
+
}, {
|
|
413
|
+
"value": "\"default\"",
|
|
414
|
+
"computed": false
|
|
415
|
+
}, {
|
|
416
|
+
"value": "\"small\"",
|
|
417
|
+
"computed": false
|
|
418
|
+
}]
|
|
419
|
+
},
|
|
420
|
+
"required": false
|
|
359
421
|
}
|
|
360
422
|
}
|
|
361
423
|
};
|