@open-ui-kit/core 2.1.0 → 2.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/index.cjs.js +814 -44
- package/index.cjs.js.map +1 -1
- package/index.d.ts +1217 -1199
- package/index.esm.js +815 -46
- package/index.esm.js.map +1 -1
- package/index.umd.js +814 -44
- package/index.umd.js.map +1 -1
- package/package.json +12 -13
package/index.umd.js
CHANGED
|
@@ -6265,6 +6265,13 @@
|
|
|
6265
6265
|
textTransform: "none",
|
|
6266
6266
|
transition: "none",
|
|
6267
6267
|
borderRadius: "4px",
|
|
6268
|
+
width: "max-content",
|
|
6269
|
+
maxWidth: "100%",
|
|
6270
|
+
whiteSpace: "normal",
|
|
6271
|
+
overflowWrap: "break-word",
|
|
6272
|
+
textAlign: "center",
|
|
6273
|
+
alignItems: "center",
|
|
6274
|
+
height: "auto",
|
|
6268
6275
|
"& .MuiButton-startIcon": {
|
|
6269
6276
|
marginLeft: "0px",
|
|
6270
6277
|
},
|
|
@@ -6276,16 +6283,22 @@
|
|
|
6276
6283
|
padding: "8px",
|
|
6277
6284
|
minWidth: "40px",
|
|
6278
6285
|
width: "40px",
|
|
6286
|
+
height: "40px",
|
|
6287
|
+
minHeight: "40px",
|
|
6279
6288
|
},
|
|
6280
6289
|
"&.MuiButton-sizeMedium": {
|
|
6281
6290
|
padding: "6px",
|
|
6282
6291
|
minWidth: "32px",
|
|
6283
6292
|
width: "32px",
|
|
6293
|
+
height: "32px",
|
|
6294
|
+
minHeight: "32px",
|
|
6284
6295
|
},
|
|
6285
6296
|
"&.MuiButton-sizeSmall": {
|
|
6286
6297
|
padding: "2px",
|
|
6287
6298
|
minWidth: "24px",
|
|
6288
6299
|
width: "24px",
|
|
6300
|
+
height: "24px",
|
|
6301
|
+
minHeight: "24px",
|
|
6289
6302
|
},
|
|
6290
6303
|
},
|
|
6291
6304
|
"&.MuiButton-sizeLarge": {
|
|
@@ -6293,7 +6306,8 @@
|
|
|
6293
6306
|
fontWeight: 600,
|
|
6294
6307
|
fontSize: "16px",
|
|
6295
6308
|
lineHeight: "125%",
|
|
6296
|
-
|
|
6309
|
+
minHeight: "40px",
|
|
6310
|
+
height: "auto",
|
|
6297
6311
|
padding: "10px 16px",
|
|
6298
6312
|
},
|
|
6299
6313
|
"&.OuiButton-hasIcon.MuiButton-sizeLarge": {
|
|
@@ -6304,7 +6318,8 @@
|
|
|
6304
6318
|
fontWeight: 600,
|
|
6305
6319
|
fontSize: "14px",
|
|
6306
6320
|
lineHeight: "125%",
|
|
6307
|
-
|
|
6321
|
+
minHeight: "32px",
|
|
6322
|
+
height: "auto",
|
|
6308
6323
|
padding: "7px 16px",
|
|
6309
6324
|
},
|
|
6310
6325
|
"&.MuiButton-sizeSmall": {
|
|
@@ -6312,7 +6327,8 @@
|
|
|
6312
6327
|
fontWeight: 600,
|
|
6313
6328
|
fontSize: "14px",
|
|
6314
6329
|
lineHeight: "125%",
|
|
6315
|
-
|
|
6330
|
+
minHeight: "24px",
|
|
6331
|
+
height: "auto",
|
|
6316
6332
|
padding: "3px 12px",
|
|
6317
6333
|
},
|
|
6318
6334
|
"&.MuiButton-sizeLarge svg": {
|
|
@@ -6531,7 +6547,7 @@
|
|
|
6531
6547
|
}
|
|
6532
6548
|
return child.props.children == null;
|
|
6533
6549
|
};
|
|
6534
|
-
const Button = (_a) => {
|
|
6550
|
+
const Button = React.forwardRef((_a, ref) => {
|
|
6535
6551
|
var { children, className, disableRipple = true, endIcon, startIcon } = _a, props = __rest(_a, ["children", "className", "disableRipple", "endIcon", "startIcon"]);
|
|
6536
6552
|
const hasIcon = Boolean(startIcon || endIcon);
|
|
6537
6553
|
const isIconOnly = !hasIcon && isIconOnlyChild(children);
|
|
@@ -6542,8 +6558,9 @@
|
|
|
6542
6558
|
]
|
|
6543
6559
|
.filter(Boolean)
|
|
6544
6560
|
.join(" ");
|
|
6545
|
-
return (jsxRuntime.jsx(StyledButton$1, Object.assign({ className: buttonClassName || undefined, disableRipple: disableRipple, endIcon: endIcon, startIcon: startIcon }, props, { children: children })));
|
|
6546
|
-
};
|
|
6561
|
+
return (jsxRuntime.jsx(StyledButton$1, Object.assign({ ref: ref, className: buttonClassName || undefined, disableRipple: disableRipple, endIcon: endIcon, startIcon: startIcon }, props, { children: children })));
|
|
6562
|
+
});
|
|
6563
|
+
Button.displayName = "Button";
|
|
6547
6564
|
|
|
6548
6565
|
const getSpinnerWrapperStyles = (size) => ({
|
|
6549
6566
|
position: "relative",
|
|
@@ -7562,18 +7579,48 @@
|
|
|
7562
7579
|
}, children: [selectNodeElement, selectableLeavesCount && (jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { cursor: "pointer", color: theme.palette.vars.baseTextWeak }, children: selectableLeavesCount }))] })));
|
|
7563
7580
|
};
|
|
7564
7581
|
|
|
7582
|
+
const TOOLTIP_ARROW_WIDTH = 10;
|
|
7583
|
+
const TOOLTIP_ARROW_HEIGHT = 6;
|
|
7565
7584
|
const baseTooltipStyles = (theme) => (Object.assign(Object.assign({}, theme.typography.captionMedium), { backgroundColor: theme.palette.vars.inactiveBackgroundActive, borderRadius: "4px", boxSizing: "border-box", color: theme.palette.vars.baseTextInverse, maxWidth: "none" }));
|
|
7566
7585
|
const tooltipArrowStyles = (theme) => ({
|
|
7567
7586
|
color: theme.palette.vars.inactiveBackgroundActive,
|
|
7568
|
-
height:
|
|
7569
|
-
width:
|
|
7587
|
+
height: `${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7588
|
+
width: `${TOOLTIP_ARROW_WIDTH}px`,
|
|
7570
7589
|
"&::before": {
|
|
7571
7590
|
backgroundColor: "currentColor",
|
|
7572
|
-
|
|
7573
|
-
height: "
|
|
7574
|
-
width: "
|
|
7591
|
+
display: "block",
|
|
7592
|
+
height: "100%",
|
|
7593
|
+
width: "100%",
|
|
7575
7594
|
},
|
|
7576
7595
|
});
|
|
7596
|
+
const tooltipPopperSx = {
|
|
7597
|
+
[`&[data-popper-placement*="bottom"] .MuiTooltip-arrow`]: {
|
|
7598
|
+
marginTop: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7599
|
+
},
|
|
7600
|
+
[`&[data-popper-placement*="top"] .MuiTooltip-arrow`]: {
|
|
7601
|
+
marginBottom: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7602
|
+
},
|
|
7603
|
+
[`&[data-popper-placement*="left"] .MuiTooltip-arrow, &[data-popper-placement*="right"] .MuiTooltip-arrow`]: {
|
|
7604
|
+
height: `${TOOLTIP_ARROW_WIDTH}px`,
|
|
7605
|
+
width: `${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7606
|
+
},
|
|
7607
|
+
[`&[data-popper-placement*="right"] .MuiTooltip-arrow`]: {
|
|
7608
|
+
marginLeft: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7609
|
+
marginRight: 0,
|
|
7610
|
+
},
|
|
7611
|
+
[`&[data-popper-placement*="left"] .MuiTooltip-arrow`]: {
|
|
7612
|
+
marginRight: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7613
|
+
marginLeft: 0,
|
|
7614
|
+
},
|
|
7615
|
+
'[dir="rtl"] &[data-popper-placement*="right"] .MuiTooltip-arrow': {
|
|
7616
|
+
marginLeft: 0,
|
|
7617
|
+
marginRight: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7618
|
+
},
|
|
7619
|
+
'[dir="rtl"] &[data-popper-placement*="left"] .MuiTooltip-arrow': {
|
|
7620
|
+
marginRight: 0,
|
|
7621
|
+
marginLeft: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7622
|
+
},
|
|
7623
|
+
};
|
|
7577
7624
|
const largeTooltipStyles = {
|
|
7578
7625
|
height: "32px",
|
|
7579
7626
|
padding: "8px 12px",
|
|
@@ -7598,12 +7645,7 @@
|
|
|
7598
7645
|
},
|
|
7599
7646
|
},
|
|
7600
7647
|
],
|
|
7601
|
-
sx:
|
|
7602
|
-
'&[data-popper-placement*="left"] .MuiTooltip-arrow, &[data-popper-placement*="right"] .MuiTooltip-arrow': {
|
|
7603
|
-
height: "10px",
|
|
7604
|
-
width: "6px",
|
|
7605
|
-
},
|
|
7606
|
-
},
|
|
7648
|
+
sx: tooltipPopperSx,
|
|
7607
7649
|
};
|
|
7608
7650
|
const tooltipSlotProps = {
|
|
7609
7651
|
[exports.TooltipSize.Medium]: {
|
|
@@ -13069,44 +13111,604 @@
|
|
|
13069
13111
|
], children: [jsxRuntime.jsx(material.Box, { className: "picker-icon", "aria-hidden": true, children: icon }), jsxRuntime.jsx(material.Box, { component: "span", className: "picker-label", children: label })] })));
|
|
13070
13112
|
};
|
|
13071
13113
|
|
|
13114
|
+
exports.PopoverPlacementSide = void 0;
|
|
13115
|
+
(function (PopoverPlacementSide) {
|
|
13116
|
+
PopoverPlacementSide["Top"] = "top";
|
|
13117
|
+
PopoverPlacementSide["Bottom"] = "bottom";
|
|
13118
|
+
PopoverPlacementSide["Left"] = "left";
|
|
13119
|
+
PopoverPlacementSide["Right"] = "right";
|
|
13120
|
+
})(exports.PopoverPlacementSide || (exports.PopoverPlacementSide = {}));
|
|
13121
|
+
exports.PopoverPlacementAlign = void 0;
|
|
13122
|
+
(function (PopoverPlacementAlign) {
|
|
13123
|
+
PopoverPlacementAlign["Start"] = "start";
|
|
13124
|
+
PopoverPlacementAlign["End"] = "end";
|
|
13125
|
+
PopoverPlacementAlign["Center"] = "center";
|
|
13126
|
+
})(exports.PopoverPlacementAlign || (exports.PopoverPlacementAlign = {}));
|
|
13127
|
+
exports.PopoverPlacement = void 0;
|
|
13128
|
+
(function (PopoverPlacement) {
|
|
13129
|
+
PopoverPlacement["Top"] = "top";
|
|
13130
|
+
PopoverPlacement["TopStart"] = "top-start";
|
|
13131
|
+
PopoverPlacement["TopEnd"] = "top-end";
|
|
13132
|
+
PopoverPlacement["Bottom"] = "bottom";
|
|
13133
|
+
PopoverPlacement["BottomStart"] = "bottom-start";
|
|
13134
|
+
PopoverPlacement["BottomEnd"] = "bottom-end";
|
|
13135
|
+
PopoverPlacement["Left"] = "left";
|
|
13136
|
+
PopoverPlacement["LeftStart"] = "left-start";
|
|
13137
|
+
PopoverPlacement["LeftEnd"] = "left-end";
|
|
13138
|
+
PopoverPlacement["Right"] = "right";
|
|
13139
|
+
PopoverPlacement["RightStart"] = "right-start";
|
|
13140
|
+
PopoverPlacement["RightEnd"] = "right-end";
|
|
13141
|
+
})(exports.PopoverPlacement || (exports.PopoverPlacement = {}));
|
|
13142
|
+
const POPOVER_PLACEMENTS = [
|
|
13143
|
+
exports.PopoverPlacement.BottomStart,
|
|
13144
|
+
exports.PopoverPlacement.Bottom,
|
|
13145
|
+
exports.PopoverPlacement.BottomEnd,
|
|
13146
|
+
exports.PopoverPlacement.TopStart,
|
|
13147
|
+
exports.PopoverPlacement.Top,
|
|
13148
|
+
exports.PopoverPlacement.TopEnd,
|
|
13149
|
+
exports.PopoverPlacement.LeftStart,
|
|
13150
|
+
exports.PopoverPlacement.Left,
|
|
13151
|
+
exports.PopoverPlacement.LeftEnd,
|
|
13152
|
+
exports.PopoverPlacement.RightStart,
|
|
13153
|
+
exports.PopoverPlacement.Right,
|
|
13154
|
+
exports.PopoverPlacement.RightEnd,
|
|
13155
|
+
];
|
|
13156
|
+
var PopoverVerticalPlacement;
|
|
13157
|
+
(function (PopoverVerticalPlacement) {
|
|
13158
|
+
PopoverVerticalPlacement["Above"] = "above";
|
|
13159
|
+
PopoverVerticalPlacement["Below"] = "below";
|
|
13160
|
+
})(PopoverVerticalPlacement || (PopoverVerticalPlacement = {}));
|
|
13161
|
+
var PopoverHorizontalPlacement;
|
|
13162
|
+
(function (PopoverHorizontalPlacement) {
|
|
13163
|
+
PopoverHorizontalPlacement["Left"] = "left";
|
|
13164
|
+
PopoverHorizontalPlacement["Center"] = "center";
|
|
13165
|
+
PopoverHorizontalPlacement["Right"] = "right";
|
|
13166
|
+
})(PopoverHorizontalPlacement || (PopoverHorizontalPlacement = {}));
|
|
13167
|
+
var PopoverSidePlacement;
|
|
13168
|
+
(function (PopoverSidePlacement) {
|
|
13169
|
+
PopoverSidePlacement["Left"] = "left";
|
|
13170
|
+
PopoverSidePlacement["Right"] = "right";
|
|
13171
|
+
})(PopoverSidePlacement || (PopoverSidePlacement = {}));
|
|
13172
|
+
var PopoverEdgeAlignment;
|
|
13173
|
+
(function (PopoverEdgeAlignment) {
|
|
13174
|
+
PopoverEdgeAlignment["Top"] = "top";
|
|
13175
|
+
PopoverEdgeAlignment["Center"] = "center";
|
|
13176
|
+
PopoverEdgeAlignment["Bottom"] = "bottom";
|
|
13177
|
+
})(PopoverEdgeAlignment || (PopoverEdgeAlignment = {}));
|
|
13178
|
+
var PopoverArrowAxisAlign;
|
|
13179
|
+
(function (PopoverArrowAxisAlign) {
|
|
13180
|
+
PopoverArrowAxisAlign["Left"] = "left";
|
|
13181
|
+
PopoverArrowAxisAlign["Right"] = "right";
|
|
13182
|
+
PopoverArrowAxisAlign["Top"] = "top";
|
|
13183
|
+
PopoverArrowAxisAlign["Bottom"] = "bottom";
|
|
13184
|
+
PopoverArrowAxisAlign["Center"] = "center";
|
|
13185
|
+
})(PopoverArrowAxisAlign || (PopoverArrowAxisAlign = {}));
|
|
13186
|
+
|
|
13187
|
+
const VIEWPORT_MARGIN = 16;
|
|
13188
|
+
const POPOVER_ARROW_HEIGHT = 8;
|
|
13189
|
+
const POPOVER_ARROW_WIDTH = POPOVER_ARROW_HEIGHT;
|
|
13190
|
+
const CENTER_PLACEMENTS = new Set([
|
|
13191
|
+
exports.PopoverPlacement.Top,
|
|
13192
|
+
exports.PopoverPlacement.Bottom,
|
|
13193
|
+
exports.PopoverPlacement.Left,
|
|
13194
|
+
exports.PopoverPlacement.Right,
|
|
13195
|
+
]);
|
|
13196
|
+
const OPPOSITE_PLACEMENT_SIDE = {
|
|
13197
|
+
[exports.PopoverPlacementSide.Top]: exports.PopoverPlacementSide.Bottom,
|
|
13198
|
+
[exports.PopoverPlacementSide.Bottom]: exports.PopoverPlacementSide.Top,
|
|
13199
|
+
[exports.PopoverPlacementSide.Left]: exports.PopoverPlacementSide.Right,
|
|
13200
|
+
[exports.PopoverPlacementSide.Right]: exports.PopoverPlacementSide.Left,
|
|
13201
|
+
};
|
|
13202
|
+
const VERTICAL_CENTER_PLACEMENT = {
|
|
13203
|
+
[exports.PopoverPlacementSide.Top]: exports.PopoverPlacement.Top,
|
|
13204
|
+
[exports.PopoverPlacementSide.Bottom]: exports.PopoverPlacement.Bottom,
|
|
13205
|
+
};
|
|
13206
|
+
const SIDE_CENTER_PLACEMENT = {
|
|
13207
|
+
[PopoverSidePlacement.Left]: exports.PopoverPlacement.Left,
|
|
13208
|
+
[PopoverSidePlacement.Right]: exports.PopoverPlacement.Right,
|
|
13209
|
+
};
|
|
13210
|
+
|
|
13211
|
+
const getOppositePlacementSide = (side) => OPPOSITE_PLACEMENT_SIDE[side];
|
|
13212
|
+
const getPlacementSide = (placement) => placement.split("-")[0];
|
|
13213
|
+
const getPlacementAlign = (placement) => {
|
|
13214
|
+
if (CENTER_PLACEMENTS.has(placement)) {
|
|
13215
|
+
return exports.PopoverPlacementAlign.Center;
|
|
13216
|
+
}
|
|
13217
|
+
if (placement.endsWith(`-${exports.PopoverPlacementAlign.Start}`)) {
|
|
13218
|
+
return exports.PopoverPlacementAlign.Start;
|
|
13219
|
+
}
|
|
13220
|
+
return exports.PopoverPlacementAlign.End;
|
|
13221
|
+
};
|
|
13222
|
+
const getArrowAxisAlign = (placement) => {
|
|
13223
|
+
const side = getPlacementSide(placement);
|
|
13224
|
+
const align = getPlacementAlign(placement);
|
|
13225
|
+
if (side === exports.PopoverPlacementSide.Top ||
|
|
13226
|
+
side === exports.PopoverPlacementSide.Bottom) {
|
|
13227
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13228
|
+
return PopoverArrowAxisAlign.Left;
|
|
13229
|
+
}
|
|
13230
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13231
|
+
return PopoverArrowAxisAlign.Right;
|
|
13232
|
+
}
|
|
13233
|
+
return PopoverArrowAxisAlign.Center;
|
|
13234
|
+
}
|
|
13235
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13236
|
+
return PopoverArrowAxisAlign.Top;
|
|
13237
|
+
}
|
|
13238
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13239
|
+
return PopoverArrowAxisAlign.Bottom;
|
|
13240
|
+
}
|
|
13241
|
+
return PopoverArrowAxisAlign.Center;
|
|
13242
|
+
};
|
|
13243
|
+
|
|
13244
|
+
const toHorizontalOrigin = (align) => {
|
|
13245
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13246
|
+
return PopoverHorizontalPlacement.Left;
|
|
13247
|
+
}
|
|
13248
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13249
|
+
return PopoverHorizontalPlacement.Right;
|
|
13250
|
+
}
|
|
13251
|
+
return PopoverHorizontalPlacement.Center;
|
|
13252
|
+
};
|
|
13253
|
+
const toVerticalOrigin = (align) => {
|
|
13254
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13255
|
+
return PopoverEdgeAlignment.Top;
|
|
13256
|
+
}
|
|
13257
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13258
|
+
return PopoverEdgeAlignment.Bottom;
|
|
13259
|
+
}
|
|
13260
|
+
return PopoverEdgeAlignment.Center;
|
|
13261
|
+
};
|
|
13262
|
+
const getOriginsForPlacement = (placement) => {
|
|
13263
|
+
const side = getPlacementSide(placement);
|
|
13264
|
+
const align = getPlacementAlign(placement);
|
|
13265
|
+
if (side === exports.PopoverPlacementSide.Top) {
|
|
13266
|
+
const horizontal = toHorizontalOrigin(align);
|
|
13267
|
+
return {
|
|
13268
|
+
anchorOrigin: {
|
|
13269
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13270
|
+
horizontal,
|
|
13271
|
+
},
|
|
13272
|
+
transformOrigin: {
|
|
13273
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13274
|
+
horizontal,
|
|
13275
|
+
},
|
|
13276
|
+
};
|
|
13277
|
+
}
|
|
13278
|
+
if (side === exports.PopoverPlacementSide.Bottom) {
|
|
13279
|
+
const horizontal = toHorizontalOrigin(align);
|
|
13280
|
+
return {
|
|
13281
|
+
anchorOrigin: {
|
|
13282
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13283
|
+
horizontal,
|
|
13284
|
+
},
|
|
13285
|
+
transformOrigin: {
|
|
13286
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13287
|
+
horizontal,
|
|
13288
|
+
},
|
|
13289
|
+
};
|
|
13290
|
+
}
|
|
13291
|
+
if (side === exports.PopoverPlacementSide.Left) {
|
|
13292
|
+
const vertical = toVerticalOrigin(align);
|
|
13293
|
+
return {
|
|
13294
|
+
anchorOrigin: {
|
|
13295
|
+
vertical,
|
|
13296
|
+
horizontal: exports.PopoverPlacementSide.Left,
|
|
13297
|
+
},
|
|
13298
|
+
transformOrigin: {
|
|
13299
|
+
vertical,
|
|
13300
|
+
horizontal: exports.PopoverPlacementSide.Right,
|
|
13301
|
+
},
|
|
13302
|
+
};
|
|
13303
|
+
}
|
|
13304
|
+
const vertical = toVerticalOrigin(align);
|
|
13305
|
+
return {
|
|
13306
|
+
anchorOrigin: {
|
|
13307
|
+
vertical,
|
|
13308
|
+
horizontal: exports.PopoverPlacementSide.Right,
|
|
13309
|
+
},
|
|
13310
|
+
transformOrigin: {
|
|
13311
|
+
vertical,
|
|
13312
|
+
horizontal: exports.PopoverPlacementSide.Left,
|
|
13313
|
+
},
|
|
13314
|
+
};
|
|
13315
|
+
};
|
|
13316
|
+
const getOriginsForVerticalPlacement = (placement, horizontal = PopoverHorizontalPlacement.Center) => {
|
|
13317
|
+
if (placement === PopoverVerticalPlacement.Above) {
|
|
13318
|
+
return {
|
|
13319
|
+
anchorOrigin: {
|
|
13320
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13321
|
+
horizontal,
|
|
13322
|
+
},
|
|
13323
|
+
transformOrigin: {
|
|
13324
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13325
|
+
horizontal,
|
|
13326
|
+
},
|
|
13327
|
+
};
|
|
13328
|
+
}
|
|
13329
|
+
return {
|
|
13330
|
+
anchorOrigin: {
|
|
13331
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13332
|
+
horizontal,
|
|
13333
|
+
},
|
|
13334
|
+
transformOrigin: {
|
|
13335
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13336
|
+
horizontal,
|
|
13337
|
+
},
|
|
13338
|
+
};
|
|
13339
|
+
};
|
|
13340
|
+
const getVerticalPreference = (anchorOrigin, transformOrigin) => {
|
|
13341
|
+
if (transformOrigin.vertical === exports.PopoverPlacementSide.Bottom &&
|
|
13342
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Top) {
|
|
13343
|
+
return PopoverVerticalPlacement.Above;
|
|
13344
|
+
}
|
|
13345
|
+
if (transformOrigin.vertical === exports.PopoverPlacementSide.Top &&
|
|
13346
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Bottom) {
|
|
13347
|
+
return PopoverVerticalPlacement.Below;
|
|
13348
|
+
}
|
|
13349
|
+
return PopoverVerticalPlacement.Above;
|
|
13350
|
+
};
|
|
13351
|
+
const getHorizontalPreference = (anchorOrigin, transformOrigin) => {
|
|
13352
|
+
var _a, _b;
|
|
13353
|
+
const anchor = (_a = anchorOrigin.horizontal) !== null && _a !== void 0 ? _a : PopoverHorizontalPlacement.Center;
|
|
13354
|
+
const transform = (_b = transformOrigin.horizontal) !== null && _b !== void 0 ? _b : PopoverHorizontalPlacement.Center;
|
|
13355
|
+
if (anchor === PopoverHorizontalPlacement.Left &&
|
|
13356
|
+
transform === PopoverHorizontalPlacement.Left) {
|
|
13357
|
+
return PopoverHorizontalPlacement.Left;
|
|
13358
|
+
}
|
|
13359
|
+
if (anchor === PopoverHorizontalPlacement.Right &&
|
|
13360
|
+
transform === PopoverHorizontalPlacement.Right) {
|
|
13361
|
+
return PopoverHorizontalPlacement.Right;
|
|
13362
|
+
}
|
|
13363
|
+
return PopoverHorizontalPlacement.Center;
|
|
13364
|
+
};
|
|
13365
|
+
const getSidePreference = (placement) => getPlacementSide(placement) === exports.PopoverPlacementSide.Right
|
|
13366
|
+
? PopoverSidePlacement.Right
|
|
13367
|
+
: PopoverSidePlacement.Left;
|
|
13368
|
+
const getEdgeAlignmentPreference = (placement) => {
|
|
13369
|
+
const align = getPlacementAlign(placement);
|
|
13370
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13371
|
+
return PopoverEdgeAlignment.Top;
|
|
13372
|
+
}
|
|
13373
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13374
|
+
return PopoverEdgeAlignment.Bottom;
|
|
13375
|
+
}
|
|
13376
|
+
return PopoverEdgeAlignment.Center;
|
|
13377
|
+
};
|
|
13378
|
+
|
|
13379
|
+
const getPopoverHorizontalBounds = ({ anchorLeft, anchorRight, anchorWidth, popoverWidth, horizontal, }) => {
|
|
13380
|
+
switch (horizontal) {
|
|
13381
|
+
case PopoverHorizontalPlacement.Left:
|
|
13382
|
+
return { left: anchorLeft, right: anchorLeft + popoverWidth };
|
|
13383
|
+
case PopoverHorizontalPlacement.Right:
|
|
13384
|
+
return { left: anchorRight - popoverWidth, right: anchorRight };
|
|
13385
|
+
default: {
|
|
13386
|
+
const center = anchorLeft + anchorWidth / 2;
|
|
13387
|
+
return {
|
|
13388
|
+
left: center - popoverWidth / 2,
|
|
13389
|
+
right: center + popoverWidth / 2,
|
|
13390
|
+
};
|
|
13391
|
+
}
|
|
13392
|
+
}
|
|
13393
|
+
};
|
|
13394
|
+
const getPopoverVerticalBounds = ({ anchorTop, anchorBottom, anchorHeight, popoverHeight, vertical, }) => {
|
|
13395
|
+
switch (vertical) {
|
|
13396
|
+
case PopoverEdgeAlignment.Top:
|
|
13397
|
+
return { top: anchorTop, bottom: anchorTop + popoverHeight };
|
|
13398
|
+
case PopoverEdgeAlignment.Bottom:
|
|
13399
|
+
return { top: anchorBottom - popoverHeight, bottom: anchorBottom };
|
|
13400
|
+
default: {
|
|
13401
|
+
const center = anchorTop + anchorHeight / 2;
|
|
13402
|
+
return {
|
|
13403
|
+
top: center - popoverHeight / 2,
|
|
13404
|
+
bottom: center + popoverHeight / 2,
|
|
13405
|
+
};
|
|
13406
|
+
}
|
|
13407
|
+
}
|
|
13408
|
+
};
|
|
13409
|
+
|
|
13410
|
+
const resolveVerticalPlacement = ({ preferAbove, spaceAbove, spaceBelow, popoverHeight, hasArrow, margin = VIEWPORT_MARGIN, }) => {
|
|
13411
|
+
const clearance = hasArrow ? POPOVER_ARROW_HEIGHT : 0;
|
|
13412
|
+
const required = popoverHeight + clearance;
|
|
13413
|
+
const aboveRoom = spaceAbove - margin;
|
|
13414
|
+
const belowRoom = spaceBelow - margin;
|
|
13415
|
+
const fitsAbove = aboveRoom >= required;
|
|
13416
|
+
const fitsBelow = belowRoom >= required;
|
|
13417
|
+
if (preferAbove && fitsAbove)
|
|
13418
|
+
return PopoverVerticalPlacement.Above;
|
|
13419
|
+
if (!preferAbove && fitsBelow)
|
|
13420
|
+
return PopoverVerticalPlacement.Below;
|
|
13421
|
+
if (fitsAbove && !fitsBelow)
|
|
13422
|
+
return PopoverVerticalPlacement.Above;
|
|
13423
|
+
if (fitsBelow && !fitsAbove)
|
|
13424
|
+
return PopoverVerticalPlacement.Below;
|
|
13425
|
+
return aboveRoom >= belowRoom
|
|
13426
|
+
? PopoverVerticalPlacement.Above
|
|
13427
|
+
: PopoverVerticalPlacement.Below;
|
|
13428
|
+
};
|
|
13429
|
+
const resolveHorizontalPlacement = ({ preferHorizontal, anchorLeft, anchorRight, anchorWidth, popoverWidth, margin = VIEWPORT_MARGIN, viewportWidth, }) => {
|
|
13430
|
+
const fits = (horizontal) => {
|
|
13431
|
+
const { left, right } = getPopoverHorizontalBounds({
|
|
13432
|
+
anchorLeft,
|
|
13433
|
+
anchorRight,
|
|
13434
|
+
anchorWidth,
|
|
13435
|
+
popoverWidth,
|
|
13436
|
+
horizontal,
|
|
13437
|
+
});
|
|
13438
|
+
return left >= margin && right <= viewportWidth - margin;
|
|
13439
|
+
};
|
|
13440
|
+
if (fits(preferHorizontal))
|
|
13441
|
+
return preferHorizontal;
|
|
13442
|
+
const alternatives = (() => {
|
|
13443
|
+
if (preferHorizontal === PopoverHorizontalPlacement.Center) {
|
|
13444
|
+
const { left } = getPopoverHorizontalBounds({
|
|
13445
|
+
anchorLeft,
|
|
13446
|
+
anchorRight,
|
|
13447
|
+
anchorWidth,
|
|
13448
|
+
popoverWidth,
|
|
13449
|
+
horizontal: PopoverHorizontalPlacement.Center,
|
|
13450
|
+
});
|
|
13451
|
+
return left < margin
|
|
13452
|
+
? [PopoverHorizontalPlacement.Left, PopoverHorizontalPlacement.Right]
|
|
13453
|
+
: [PopoverHorizontalPlacement.Right, PopoverHorizontalPlacement.Left];
|
|
13454
|
+
}
|
|
13455
|
+
if (preferHorizontal === PopoverHorizontalPlacement.Left) {
|
|
13456
|
+
return [
|
|
13457
|
+
PopoverHorizontalPlacement.Right,
|
|
13458
|
+
PopoverHorizontalPlacement.Center,
|
|
13459
|
+
];
|
|
13460
|
+
}
|
|
13461
|
+
return [PopoverHorizontalPlacement.Left, PopoverHorizontalPlacement.Center];
|
|
13462
|
+
})();
|
|
13463
|
+
for (const horizontal of alternatives) {
|
|
13464
|
+
if (fits(horizontal))
|
|
13465
|
+
return horizontal;
|
|
13466
|
+
}
|
|
13467
|
+
const overflow = (horizontal) => {
|
|
13468
|
+
const { left, right } = getPopoverHorizontalBounds({
|
|
13469
|
+
anchorLeft,
|
|
13470
|
+
anchorRight,
|
|
13471
|
+
anchorWidth,
|
|
13472
|
+
popoverWidth,
|
|
13473
|
+
horizontal,
|
|
13474
|
+
});
|
|
13475
|
+
const leftOverflow = Math.max(0, margin - left);
|
|
13476
|
+
const rightOverflow = Math.max(0, right - (viewportWidth - margin));
|
|
13477
|
+
return leftOverflow + rightOverflow;
|
|
13478
|
+
};
|
|
13479
|
+
const all = [
|
|
13480
|
+
PopoverHorizontalPlacement.Left,
|
|
13481
|
+
PopoverHorizontalPlacement.Center,
|
|
13482
|
+
PopoverHorizontalPlacement.Right,
|
|
13483
|
+
];
|
|
13484
|
+
return all.reduce((best, current) => overflow(current) < overflow(best) ? current : best);
|
|
13485
|
+
};
|
|
13486
|
+
const resolveSidePlacement = ({ preferSide, spaceLeft, spaceRight, popoverWidth, hasArrow, margin = VIEWPORT_MARGIN, }) => {
|
|
13487
|
+
const clearance = POPOVER_ARROW_WIDTH ;
|
|
13488
|
+
const required = popoverWidth + clearance;
|
|
13489
|
+
const leftRoom = spaceLeft - margin;
|
|
13490
|
+
const rightRoom = spaceRight - margin;
|
|
13491
|
+
const fitsLeft = leftRoom >= required;
|
|
13492
|
+
const fitsRight = rightRoom >= required;
|
|
13493
|
+
if (preferSide === PopoverSidePlacement.Left && fitsLeft) {
|
|
13494
|
+
return PopoverSidePlacement.Left;
|
|
13495
|
+
}
|
|
13496
|
+
if (preferSide === PopoverSidePlacement.Right && fitsRight) {
|
|
13497
|
+
return PopoverSidePlacement.Right;
|
|
13498
|
+
}
|
|
13499
|
+
if (fitsLeft && !fitsRight)
|
|
13500
|
+
return PopoverSidePlacement.Left;
|
|
13501
|
+
if (fitsRight && !fitsLeft)
|
|
13502
|
+
return PopoverSidePlacement.Right;
|
|
13503
|
+
return leftRoom >= rightRoom
|
|
13504
|
+
? PopoverSidePlacement.Left
|
|
13505
|
+
: PopoverSidePlacement.Right;
|
|
13506
|
+
};
|
|
13507
|
+
const resolveEdgeAlignment = ({ preferAlignment, anchorTop, anchorBottom, anchorHeight, popoverHeight, margin = VIEWPORT_MARGIN, viewportHeight, }) => {
|
|
13508
|
+
const fits = (vertical) => {
|
|
13509
|
+
const { top, bottom } = getPopoverVerticalBounds({
|
|
13510
|
+
anchorTop,
|
|
13511
|
+
anchorBottom,
|
|
13512
|
+
anchorHeight,
|
|
13513
|
+
popoverHeight,
|
|
13514
|
+
vertical,
|
|
13515
|
+
});
|
|
13516
|
+
return top >= margin && bottom <= viewportHeight - margin;
|
|
13517
|
+
};
|
|
13518
|
+
if (fits(preferAlignment))
|
|
13519
|
+
return preferAlignment;
|
|
13520
|
+
const alternatives = (() => {
|
|
13521
|
+
if (preferAlignment === PopoverEdgeAlignment.Center) {
|
|
13522
|
+
const { top } = getPopoverVerticalBounds({
|
|
13523
|
+
anchorTop,
|
|
13524
|
+
anchorBottom,
|
|
13525
|
+
anchorHeight,
|
|
13526
|
+
popoverHeight,
|
|
13527
|
+
vertical: PopoverEdgeAlignment.Center,
|
|
13528
|
+
});
|
|
13529
|
+
return top < margin
|
|
13530
|
+
? [PopoverEdgeAlignment.Top, PopoverEdgeAlignment.Bottom]
|
|
13531
|
+
: [PopoverEdgeAlignment.Bottom, PopoverEdgeAlignment.Top];
|
|
13532
|
+
}
|
|
13533
|
+
if (preferAlignment === PopoverEdgeAlignment.Top) {
|
|
13534
|
+
return [PopoverEdgeAlignment.Bottom, PopoverEdgeAlignment.Center];
|
|
13535
|
+
}
|
|
13536
|
+
return [PopoverEdgeAlignment.Top, PopoverEdgeAlignment.Center];
|
|
13537
|
+
})();
|
|
13538
|
+
for (const vertical of alternatives) {
|
|
13539
|
+
if (fits(vertical))
|
|
13540
|
+
return vertical;
|
|
13541
|
+
}
|
|
13542
|
+
const overflow = (vertical) => {
|
|
13543
|
+
const { top, bottom } = getPopoverVerticalBounds({
|
|
13544
|
+
anchorTop,
|
|
13545
|
+
anchorBottom,
|
|
13546
|
+
anchorHeight,
|
|
13547
|
+
popoverHeight,
|
|
13548
|
+
vertical,
|
|
13549
|
+
});
|
|
13550
|
+
const topOverflow = Math.max(0, margin - top);
|
|
13551
|
+
const bottomOverflow = Math.max(0, bottom - (viewportHeight - margin));
|
|
13552
|
+
return topOverflow + bottomOverflow;
|
|
13553
|
+
};
|
|
13554
|
+
const all = [
|
|
13555
|
+
PopoverEdgeAlignment.Top,
|
|
13556
|
+
PopoverEdgeAlignment.Center,
|
|
13557
|
+
PopoverEdgeAlignment.Bottom,
|
|
13558
|
+
];
|
|
13559
|
+
return all.reduce((best, current) => overflow(current) < overflow(best) ? current : best);
|
|
13560
|
+
};
|
|
13561
|
+
|
|
13562
|
+
const placementSideToSidePlacement = (side) => side === exports.PopoverPlacementSide.Right
|
|
13563
|
+
? PopoverSidePlacement.Right
|
|
13564
|
+
: PopoverSidePlacement.Left;
|
|
13565
|
+
const formatVerticalPlacement = (side, align) => {
|
|
13566
|
+
if (align === exports.PopoverPlacementAlign.Center) {
|
|
13567
|
+
return VERTICAL_CENTER_PLACEMENT[side];
|
|
13568
|
+
}
|
|
13569
|
+
return `${side}-${align}`;
|
|
13570
|
+
};
|
|
13571
|
+
const formatSidePlacement = (side, align) => {
|
|
13572
|
+
if (align === exports.PopoverPlacementAlign.Center) {
|
|
13573
|
+
return SIDE_CENTER_PLACEMENT[side];
|
|
13574
|
+
}
|
|
13575
|
+
return `${side}-${align}`;
|
|
13576
|
+
};
|
|
13577
|
+
const horizontalToPlacementAlign = (horizontal) => {
|
|
13578
|
+
if (horizontal === PopoverHorizontalPlacement.Left) {
|
|
13579
|
+
return exports.PopoverPlacementAlign.Start;
|
|
13580
|
+
}
|
|
13581
|
+
if (horizontal === PopoverHorizontalPlacement.Right) {
|
|
13582
|
+
return exports.PopoverPlacementAlign.End;
|
|
13583
|
+
}
|
|
13584
|
+
return exports.PopoverPlacementAlign.Center;
|
|
13585
|
+
};
|
|
13586
|
+
const edgeToPlacementAlign = (edge) => {
|
|
13587
|
+
if (edge === PopoverEdgeAlignment.Top) {
|
|
13588
|
+
return exports.PopoverPlacementAlign.Start;
|
|
13589
|
+
}
|
|
13590
|
+
if (edge === PopoverEdgeAlignment.Bottom) {
|
|
13591
|
+
return exports.PopoverPlacementAlign.End;
|
|
13592
|
+
}
|
|
13593
|
+
return exports.PopoverPlacementAlign.Center;
|
|
13594
|
+
};
|
|
13595
|
+
const placementForVerticalPlacement = (placement, verticalPlacement) => {
|
|
13596
|
+
const side = getPlacementSide(placement);
|
|
13597
|
+
if (side !== exports.PopoverPlacementSide.Top &&
|
|
13598
|
+
side !== exports.PopoverPlacementSide.Bottom) {
|
|
13599
|
+
return placement;
|
|
13600
|
+
}
|
|
13601
|
+
const align = getPlacementAlign(placement);
|
|
13602
|
+
return verticalPlacement === PopoverVerticalPlacement.Above
|
|
13603
|
+
? formatVerticalPlacement(exports.PopoverPlacementSide.Top, align)
|
|
13604
|
+
: formatVerticalPlacement(exports.PopoverPlacementSide.Bottom, align);
|
|
13605
|
+
};
|
|
13606
|
+
const placementForHorizontalPlacement = (placement, horizontal) => {
|
|
13607
|
+
const side = getPlacementSide(placement);
|
|
13608
|
+
if (side !== exports.PopoverPlacementSide.Top &&
|
|
13609
|
+
side !== exports.PopoverPlacementSide.Bottom) {
|
|
13610
|
+
return placement;
|
|
13611
|
+
}
|
|
13612
|
+
return formatVerticalPlacement(side, horizontalToPlacementAlign(horizontal));
|
|
13613
|
+
};
|
|
13614
|
+
const placementForSidePlacement = (placement, side) => {
|
|
13615
|
+
const placementSide = getPlacementSide(placement);
|
|
13616
|
+
if (placementSide !== exports.PopoverPlacementSide.Left &&
|
|
13617
|
+
placementSide !== exports.PopoverPlacementSide.Right) {
|
|
13618
|
+
return placement;
|
|
13619
|
+
}
|
|
13620
|
+
return formatSidePlacement(side, getPlacementAlign(placement));
|
|
13621
|
+
};
|
|
13622
|
+
const placementForEdgeAlignment = (placement, align) => {
|
|
13623
|
+
const side = getPlacementSide(placement);
|
|
13624
|
+
if (side !== exports.PopoverPlacementSide.Left &&
|
|
13625
|
+
side !== exports.PopoverPlacementSide.Right) {
|
|
13626
|
+
return placement;
|
|
13627
|
+
}
|
|
13628
|
+
return formatSidePlacement(placementSideToSidePlacement(side), edgeToPlacementAlign(align));
|
|
13629
|
+
};
|
|
13630
|
+
|
|
13631
|
+
const getArrowEdgeSide = (placement) => getOppositePlacementSide(getPlacementSide(placement));
|
|
13072
13632
|
const ARROW_SIZE = 16;
|
|
13073
13633
|
const ARROW_HALF = ARROW_SIZE / 2;
|
|
13074
|
-
const ARROW_HEIGHT =
|
|
13634
|
+
const ARROW_HEIGHT = POPOVER_ARROW_HEIGHT;
|
|
13075
13635
|
const ARROW_OFFSET = 12;
|
|
13076
13636
|
const popoverWidthBySize = {
|
|
13077
13637
|
medium: "228px",
|
|
13078
13638
|
large: "360px",
|
|
13079
13639
|
};
|
|
13080
|
-
const
|
|
13081
|
-
|
|
13640
|
+
const popoverContentLayoutBySize = {
|
|
13641
|
+
medium: { padding: "12px 16px", gap: "16px" },
|
|
13642
|
+
large: { padding: "16px 20px", gap: "20px" },
|
|
13643
|
+
};
|
|
13644
|
+
const getPaperArrowOffset = (placement, anchorOrigin = {
|
|
13645
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13646
|
+
}, transformOrigin = {
|
|
13647
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13648
|
+
}) => {
|
|
13649
|
+
if (!placement)
|
|
13082
13650
|
return {};
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13651
|
+
const side = getPlacementSide(placement);
|
|
13652
|
+
if (side === exports.PopoverPlacementSide.Top &&
|
|
13653
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Top &&
|
|
13654
|
+
transformOrigin.vertical === exports.PopoverPlacementSide.Bottom) {
|
|
13655
|
+
return { marginTop: `-${ARROW_HEIGHT}px` };
|
|
13656
|
+
}
|
|
13657
|
+
if (side === exports.PopoverPlacementSide.Bottom &&
|
|
13658
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Bottom &&
|
|
13659
|
+
transformOrigin.vertical === exports.PopoverPlacementSide.Top) {
|
|
13660
|
+
return { marginTop: `${ARROW_HEIGHT}px` };
|
|
13661
|
+
}
|
|
13662
|
+
if (side === exports.PopoverPlacementSide.Left &&
|
|
13663
|
+
anchorOrigin.horizontal === exports.PopoverPlacementSide.Left &&
|
|
13664
|
+
transformOrigin.horizontal === exports.PopoverPlacementSide.Right) {
|
|
13665
|
+
return { marginLeft: `-${ARROW_HEIGHT}px` };
|
|
13666
|
+
}
|
|
13667
|
+
if (side === exports.PopoverPlacementSide.Right &&
|
|
13668
|
+
anchorOrigin.horizontal === exports.PopoverPlacementSide.Right &&
|
|
13669
|
+
transformOrigin.horizontal === exports.PopoverPlacementSide.Left) {
|
|
13670
|
+
return { marginLeft: `${ARROW_HEIGHT}px` };
|
|
13671
|
+
}
|
|
13672
|
+
return {};
|
|
13086
13673
|
};
|
|
13087
|
-
const getArrowStyles = (
|
|
13674
|
+
const getArrowStyles = (placement, bg) => {
|
|
13675
|
+
const edgeSide = getArrowEdgeSide(placement);
|
|
13676
|
+
const align = getArrowAxisAlign(placement);
|
|
13088
13677
|
const base = {
|
|
13089
13678
|
position: "absolute",
|
|
13090
|
-
width: `${ARROW_SIZE}px`,
|
|
13091
|
-
height: `${ARROW_HEIGHT}px`,
|
|
13092
13679
|
background: bg,
|
|
13093
|
-
zIndex:
|
|
13680
|
+
zIndex: 2,
|
|
13681
|
+
pointerEvents: "none",
|
|
13094
13682
|
};
|
|
13095
|
-
const horizontal =
|
|
13683
|
+
const horizontal = align === PopoverArrowAxisAlign.Center
|
|
13096
13684
|
? { left: `calc(50% - ${ARROW_HALF}px)` }
|
|
13097
|
-
:
|
|
13685
|
+
: align === PopoverArrowAxisAlign.Left
|
|
13098
13686
|
? { left: `${ARROW_OFFSET}px` }
|
|
13099
13687
|
: { right: `${ARROW_OFFSET}px` };
|
|
13100
|
-
|
|
13101
|
-
|
|
13688
|
+
const vertical = align === PopoverArrowAxisAlign.Center
|
|
13689
|
+
? { top: `calc(50% - ${ARROW_HALF}px)` }
|
|
13690
|
+
: align === PopoverArrowAxisAlign.Top
|
|
13691
|
+
? { top: `${ARROW_OFFSET}px` }
|
|
13692
|
+
: { bottom: `${ARROW_OFFSET}px` };
|
|
13693
|
+
if (edgeSide === exports.PopoverPlacementSide.Bottom) {
|
|
13694
|
+
return Object.assign(Object.assign(Object.assign({}, base), horizontal), { width: `${ARROW_SIZE}px`, height: `${ARROW_HEIGHT}px`, bottom: `-${ARROW_HEIGHT}px`, clipPath: `polygon(50% 100%, 0 0, 100% 0)` });
|
|
13102
13695
|
}
|
|
13103
|
-
|
|
13696
|
+
if (edgeSide === exports.PopoverPlacementSide.Top) {
|
|
13697
|
+
return Object.assign(Object.assign(Object.assign({}, base), horizontal), { width: `${ARROW_SIZE}px`, height: `${ARROW_HEIGHT}px`, top: `-${ARROW_HEIGHT}px`, clipPath: `polygon(0 100%, 50% 0, 100% 100%)` });
|
|
13698
|
+
}
|
|
13699
|
+
if (edgeSide === exports.PopoverPlacementSide.Left) {
|
|
13700
|
+
return Object.assign(Object.assign(Object.assign({}, base), vertical), { width: `${ARROW_HEIGHT}px`, height: `${ARROW_SIZE}px`, left: `-${ARROW_HEIGHT}px`, clipPath: `polygon(0 50%, 100% 0, 100% 100%)` });
|
|
13701
|
+
}
|
|
13702
|
+
return Object.assign(Object.assign(Object.assign({}, base), vertical), { width: `${ARROW_HEIGHT}px`, height: `${ARROW_SIZE}px`, right: `-${ARROW_HEIGHT}px`, clipPath: `polygon(100% 50%, 0 0, 0 100%)` });
|
|
13104
13703
|
};
|
|
13105
13704
|
const getPopoverPaperStyles = (theme, size = "medium") => {
|
|
13106
13705
|
var _a;
|
|
13107
|
-
|
|
13706
|
+
const width = popoverWidthBySize[size];
|
|
13707
|
+
return {
|
|
13108
13708
|
boxSizing: "border-box",
|
|
13109
|
-
width
|
|
13709
|
+
width,
|
|
13710
|
+
minWidth: width,
|
|
13711
|
+
maxWidth: width,
|
|
13110
13712
|
background: (_a = theme.palette.vars) === null || _a === void 0 ? void 0 : _a.controlBackgroundDefault,
|
|
13111
13713
|
borderRadius: "6px",
|
|
13112
13714
|
boxShadow: "none",
|
|
@@ -13114,25 +13716,34 @@
|
|
|
13114
13716
|
? `drop-shadow(${darkModeCardFloating})`
|
|
13115
13717
|
: `drop-shadow(${lightModeCardFloating})`,
|
|
13116
13718
|
overflow: "visible",
|
|
13117
|
-
|
|
13719
|
+
overflowX: "visible",
|
|
13720
|
+
overflowY: "visible",
|
|
13721
|
+
};
|
|
13722
|
+
};
|
|
13723
|
+
const popoverSurfaceStyles = {
|
|
13724
|
+
position: "relative",
|
|
13725
|
+
boxSizing: "border-box",
|
|
13726
|
+
width: "100%",
|
|
13727
|
+
overflow: "visible",
|
|
13118
13728
|
};
|
|
13119
|
-
const getPopoverContentStyles = (theme, featureHighlight = false) => {
|
|
13729
|
+
const getPopoverContentStyles = (theme, featureHighlight = false, size = "medium") => {
|
|
13120
13730
|
var _a, _b;
|
|
13121
|
-
|
|
13731
|
+
const layout = popoverContentLayoutBySize[size];
|
|
13732
|
+
return {
|
|
13122
13733
|
boxSizing: "border-box",
|
|
13123
13734
|
display: "flex",
|
|
13124
13735
|
flexDirection: "row",
|
|
13125
13736
|
justifyContent: "flex-end",
|
|
13126
13737
|
alignItems: "flex-start",
|
|
13127
|
-
gap:
|
|
13128
|
-
padding:
|
|
13738
|
+
gap: layout.gap,
|
|
13739
|
+
padding: layout.padding,
|
|
13129
13740
|
width: "100%",
|
|
13130
13741
|
background: (_a = theme.palette.vars) === null || _a === void 0 ? void 0 : _a.controlBackgroundDefault,
|
|
13131
13742
|
border: featureHighlight
|
|
13132
13743
|
? `2px solid ${(_b = theme.palette.vars) === null || _b === void 0 ? void 0 : _b.controlBorderActive}`
|
|
13133
13744
|
: "0px solid transparent",
|
|
13134
13745
|
borderRadius: "6px",
|
|
13135
|
-
}
|
|
13746
|
+
};
|
|
13136
13747
|
};
|
|
13137
13748
|
const popoverColumnStyles = {
|
|
13138
13749
|
display: "flex",
|
|
@@ -13184,10 +13795,15 @@
|
|
|
13184
13795
|
const popoverActionsStyles = {
|
|
13185
13796
|
display: "flex",
|
|
13186
13797
|
flexDirection: "row",
|
|
13798
|
+
flexWrap: "wrap",
|
|
13187
13799
|
justifyContent: "flex-end",
|
|
13188
13800
|
alignItems: "center",
|
|
13189
13801
|
gap: "12px",
|
|
13190
13802
|
width: "100%",
|
|
13803
|
+
"& .MuiButton-root": {
|
|
13804
|
+
flexShrink: 0,
|
|
13805
|
+
whiteSpace: "nowrap",
|
|
13806
|
+
},
|
|
13191
13807
|
};
|
|
13192
13808
|
const closeButtonStyles = {
|
|
13193
13809
|
padding: "2px",
|
|
@@ -13195,21 +13811,174 @@
|
|
|
13195
13811
|
flexShrink: 0,
|
|
13196
13812
|
};
|
|
13197
13813
|
|
|
13814
|
+
const resolveAnchorRect = (anchorEl) => {
|
|
13815
|
+
var _a, _b;
|
|
13816
|
+
if (!anchorEl)
|
|
13817
|
+
return null;
|
|
13818
|
+
const resolved = typeof anchorEl === "function" ? anchorEl() : anchorEl;
|
|
13819
|
+
return (_b = (_a = resolved === null || resolved === void 0 ? void 0 : resolved.getBoundingClientRect) === null || _a === void 0 ? void 0 : _a.call(resolved)) !== null && _b !== void 0 ? _b : null;
|
|
13820
|
+
};
|
|
13821
|
+
const resolvePlacementState = ({ anchorOrigin, transformOrigin, placement, }) => {
|
|
13822
|
+
if (placement) {
|
|
13823
|
+
const origins = getOriginsForPlacement(placement);
|
|
13824
|
+
return {
|
|
13825
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13826
|
+
transformOrigin: origins.transformOrigin,
|
|
13827
|
+
placement,
|
|
13828
|
+
};
|
|
13829
|
+
}
|
|
13830
|
+
return { anchorOrigin, transformOrigin, placement };
|
|
13831
|
+
};
|
|
13832
|
+
const isSameResolvedState = (current, next) => current.placement === next.placement &&
|
|
13833
|
+
current.anchorOrigin.vertical === next.anchorOrigin.vertical &&
|
|
13834
|
+
current.anchorOrigin.horizontal === next.anchorOrigin.horizontal &&
|
|
13835
|
+
current.transformOrigin.vertical === next.transformOrigin.vertical &&
|
|
13836
|
+
current.transformOrigin.horizontal === next.transformOrigin.horizontal;
|
|
13837
|
+
const getPreferenceOrigins = ({ anchorOrigin, transformOrigin, placement, }) => placement
|
|
13838
|
+
? getOriginsForPlacement(placement)
|
|
13839
|
+
: { anchorOrigin, transformOrigin };
|
|
13840
|
+
const useResolvedPopoverPlacement = ({ open, anchorEl, anchorOrigin, transformOrigin, placement, }) => {
|
|
13841
|
+
const paperRef = React.useRef(null);
|
|
13842
|
+
const [resolved, setResolved] = React.useState(() => resolvePlacementState({ anchorOrigin, transformOrigin, placement }));
|
|
13843
|
+
const updateResolved = (next) => {
|
|
13844
|
+
setResolved((current) => isSameResolvedState(current, next) ? current : next);
|
|
13845
|
+
};
|
|
13846
|
+
React.useLayoutEffect(() => {
|
|
13847
|
+
if (!open) {
|
|
13848
|
+
updateResolved(resolvePlacementState({ anchorOrigin, transformOrigin, placement }));
|
|
13849
|
+
return;
|
|
13850
|
+
}
|
|
13851
|
+
const anchorRect = resolveAnchorRect(anchorEl);
|
|
13852
|
+
if (!anchorRect)
|
|
13853
|
+
return;
|
|
13854
|
+
const { anchorOrigin: preferenceAnchorOrigin, transformOrigin: preferenceTransformOrigin, } = getPreferenceOrigins({ anchorOrigin, transformOrigin, placement });
|
|
13855
|
+
const measure = () => {
|
|
13856
|
+
const paper = paperRef.current;
|
|
13857
|
+
if (!paper)
|
|
13858
|
+
return;
|
|
13859
|
+
if (placement) {
|
|
13860
|
+
const placementSide = getPlacementSide(placement);
|
|
13861
|
+
if (placementSide === exports.PopoverPlacementSide.Top ||
|
|
13862
|
+
placementSide === exports.PopoverPlacementSide.Bottom) {
|
|
13863
|
+
const preferAbove = getVerticalPreference(preferenceAnchorOrigin, preferenceTransformOrigin) === "above";
|
|
13864
|
+
const preferHorizontal = getHorizontalPreference(preferenceAnchorOrigin, preferenceTransformOrigin);
|
|
13865
|
+
const verticalPlacement = resolveVerticalPlacement({
|
|
13866
|
+
preferAbove,
|
|
13867
|
+
spaceAbove: anchorRect.top,
|
|
13868
|
+
spaceBelow: window.innerHeight - anchorRect.bottom,
|
|
13869
|
+
popoverHeight: paper.offsetHeight,
|
|
13870
|
+
hasArrow: true,
|
|
13871
|
+
});
|
|
13872
|
+
const horizontalPlacement = resolveHorizontalPlacement({
|
|
13873
|
+
preferHorizontal,
|
|
13874
|
+
anchorLeft: anchorRect.left,
|
|
13875
|
+
anchorRight: anchorRect.right,
|
|
13876
|
+
anchorWidth: anchorRect.width,
|
|
13877
|
+
popoverWidth: paper.offsetWidth,
|
|
13878
|
+
viewportWidth: window.innerWidth,
|
|
13879
|
+
});
|
|
13880
|
+
const nextPlacement = placementForHorizontalPlacement(placementForVerticalPlacement(placement, verticalPlacement), horizontalPlacement);
|
|
13881
|
+
const origins = getOriginsForPlacement(nextPlacement);
|
|
13882
|
+
updateResolved({
|
|
13883
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13884
|
+
transformOrigin: origins.transformOrigin,
|
|
13885
|
+
placement: nextPlacement,
|
|
13886
|
+
});
|
|
13887
|
+
return;
|
|
13888
|
+
}
|
|
13889
|
+
const preferSide = getSidePreference(placement);
|
|
13890
|
+
const preferAlignment = getEdgeAlignmentPreference(placement);
|
|
13891
|
+
const sidePlacement = resolveSidePlacement({
|
|
13892
|
+
preferSide,
|
|
13893
|
+
spaceLeft: anchorRect.left,
|
|
13894
|
+
spaceRight: window.innerWidth - anchorRect.right,
|
|
13895
|
+
popoverWidth: paper.offsetWidth,
|
|
13896
|
+
hasArrow: true,
|
|
13897
|
+
});
|
|
13898
|
+
const edgeAlignment = resolveEdgeAlignment({
|
|
13899
|
+
preferAlignment,
|
|
13900
|
+
anchorTop: anchorRect.top,
|
|
13901
|
+
anchorBottom: anchorRect.bottom,
|
|
13902
|
+
anchorHeight: anchorRect.height,
|
|
13903
|
+
popoverHeight: paper.offsetHeight,
|
|
13904
|
+
viewportHeight: window.innerHeight,
|
|
13905
|
+
});
|
|
13906
|
+
const nextPlacement = placementForEdgeAlignment(placementForSidePlacement(placement, sidePlacement), edgeAlignment);
|
|
13907
|
+
const origins = getOriginsForPlacement(nextPlacement);
|
|
13908
|
+
updateResolved({
|
|
13909
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13910
|
+
transformOrigin: origins.transformOrigin,
|
|
13911
|
+
placement: nextPlacement,
|
|
13912
|
+
});
|
|
13913
|
+
return;
|
|
13914
|
+
}
|
|
13915
|
+
const preferAbove = getVerticalPreference(preferenceAnchorOrigin, preferenceTransformOrigin) === "above";
|
|
13916
|
+
const verticalPlacement = resolveVerticalPlacement({
|
|
13917
|
+
preferAbove,
|
|
13918
|
+
spaceAbove: anchorRect.top,
|
|
13919
|
+
spaceBelow: window.innerHeight - anchorRect.bottom,
|
|
13920
|
+
popoverHeight: paper.offsetHeight,
|
|
13921
|
+
hasArrow: false,
|
|
13922
|
+
});
|
|
13923
|
+
const horizontalPlacement = resolveHorizontalPlacement({
|
|
13924
|
+
preferHorizontal: getHorizontalPreference(preferenceAnchorOrigin, preferenceTransformOrigin),
|
|
13925
|
+
anchorLeft: anchorRect.left,
|
|
13926
|
+
anchorRight: anchorRect.right,
|
|
13927
|
+
anchorWidth: anchorRect.width,
|
|
13928
|
+
popoverWidth: paper.offsetWidth,
|
|
13929
|
+
viewportWidth: window.innerWidth,
|
|
13930
|
+
});
|
|
13931
|
+
const origins = getOriginsForVerticalPlacement(verticalPlacement, horizontalPlacement);
|
|
13932
|
+
updateResolved({
|
|
13933
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13934
|
+
transformOrigin: origins.transformOrigin,
|
|
13935
|
+
placement,
|
|
13936
|
+
});
|
|
13937
|
+
};
|
|
13938
|
+
const frame = requestAnimationFrame(measure);
|
|
13939
|
+
return () => cancelAnimationFrame(frame);
|
|
13940
|
+
}, [open, anchorEl, anchorOrigin, transformOrigin, placement]);
|
|
13941
|
+
const paperOffsetSx = getPaperArrowOffset(resolved.placement, resolved.anchorOrigin, resolved.transformOrigin);
|
|
13942
|
+
return {
|
|
13943
|
+
paperRef,
|
|
13944
|
+
anchorOrigin: resolved.anchorOrigin,
|
|
13945
|
+
transformOrigin: resolved.transformOrigin,
|
|
13946
|
+
placement: resolved.placement,
|
|
13947
|
+
paperOffsetSx,
|
|
13948
|
+
};
|
|
13949
|
+
};
|
|
13950
|
+
|
|
13951
|
+
const DEFAULT_POPOVER_ANCHOR_ORIGIN = {
|
|
13952
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13953
|
+
horizontal: PopoverHorizontalPlacement.Left,
|
|
13954
|
+
};
|
|
13955
|
+
const DEFAULT_POPOVER_TRANSFORM_ORIGIN = {
|
|
13956
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13957
|
+
horizontal: PopoverHorizontalPlacement.Left,
|
|
13958
|
+
};
|
|
13198
13959
|
const Popover = (_a) => {
|
|
13199
|
-
var { title, body, actions, icon, showCloseButton = false, featureHighlight = false, size = "medium",
|
|
13960
|
+
var { title, body, actions, icon, showCloseButton = false, featureHighlight = false, size = "medium", placement, paperSx, onClose, children, anchorOrigin = DEFAULT_POPOVER_ANCHOR_ORIGIN, transformOrigin = DEFAULT_POPOVER_TRANSFORM_ORIGIN, open = false, disableScrollLock = true } = _a, props = __rest(_a, ["title", "body", "actions", "icon", "showCloseButton", "featureHighlight", "size", "placement", "paperSx", "onClose", "children", "anchorOrigin", "transformOrigin", "open", "disableScrollLock"]);
|
|
13200
13961
|
const theme = material.useTheme();
|
|
13962
|
+
const { paperRef, anchorOrigin: resolvedAnchorOrigin, transformOrigin: resolvedTransformOrigin, placement: resolvedPlacement, paperOffsetSx, } = useResolvedPopoverPlacement({
|
|
13963
|
+
open,
|
|
13964
|
+
anchorEl: props.anchorEl,
|
|
13965
|
+
anchorOrigin,
|
|
13966
|
+
transformOrigin,
|
|
13967
|
+
placement,
|
|
13968
|
+
});
|
|
13201
13969
|
const bg = featureHighlight
|
|
13202
13970
|
? theme.palette.vars.controlBorderActive
|
|
13203
13971
|
: theme.palette.vars.controlBackgroundDefault;
|
|
13204
|
-
return (jsxRuntime.
|
|
13972
|
+
return (jsxRuntime.jsx(material.Popover, Object.assign({}, props, { open: open, disableScrollLock: disableScrollLock, marginThreshold: null, anchorOrigin: resolvedAnchorOrigin, transformOrigin: resolvedTransformOrigin, onClose: onClose, slotProps: {
|
|
13205
13973
|
paper: {
|
|
13974
|
+
ref: paperRef,
|
|
13206
13975
|
sx: [
|
|
13207
13976
|
getPopoverPaperStyles(theme, size),
|
|
13208
|
-
|
|
13977
|
+
paperOffsetSx,
|
|
13209
13978
|
...(Array.isArray(paperSx) ? paperSx : paperSx ? [paperSx] : []),
|
|
13210
13979
|
],
|
|
13211
13980
|
},
|
|
13212
|
-
}, children: [
|
|
13981
|
+
}, children: jsxRuntime.jsxs(material.Box, { sx: popoverSurfaceStyles, children: [resolvedPlacement && (jsxRuntime.jsx(material.Box, { "aria-hidden": true, "data-slot": "popover-arrow", sx: getArrowStyles(resolvedPlacement, bg) })), children !== null && children !== void 0 ? children : (jsxRuntime.jsxs(material.Box, { sx: getPopoverContentStyles(theme, featureHighlight, size), children: [icon && jsxRuntime.jsx(material.Box, { sx: popoverIconStyles, children: icon }), jsxRuntime.jsxs(material.Box, { sx: popoverColumnStyles, children: [(title || body || showCloseButton) && (jsxRuntime.jsxs(material.Box, { sx: popoverTextStyles, children: [(title || showCloseButton) && (jsxRuntime.jsxs(material.Box, { sx: popoverHeaderStyles, children: [title && (jsxRuntime.jsx(material.Typography, { component: "div", sx: popoverTitleStyles(theme), children: title })), showCloseButton && (jsxRuntime.jsx(material.IconButton, { "aria-label": "Close popover", size: "small", onClick: () => onClose === null || onClose === void 0 ? void 0 : onClose({}, "escapeKeyDown"), sx: closeButtonStyles, children: jsxRuntime.jsx(CloseIcon, { fontSize: "small" }) }))] })), body && (jsxRuntime.jsx(material.Typography, { component: "div", sx: popoverBodyStyles(theme), children: body }))] })), actions && jsxRuntime.jsx(material.Box, { sx: popoverActionsStyles, children: actions })] })] }))] }) })));
|
|
13213
13982
|
};
|
|
13214
13983
|
|
|
13215
13984
|
const getRadioButtonStyles = (theme) => ({
|
|
@@ -16558,6 +17327,7 @@
|
|
|
16558
17327
|
exports.NoData = NoData;
|
|
16559
17328
|
exports.OS_LIGHT_COLORS = OS_LIGHT_COLORS;
|
|
16560
17329
|
exports.OverflowTooltip = OverflowTooltip;
|
|
17330
|
+
exports.POPOVER_PLACEMENTS = POPOVER_PLACEMENTS;
|
|
16561
17331
|
exports.PageTitle = PageTitle;
|
|
16562
17332
|
exports.Pagination = Pagination;
|
|
16563
17333
|
exports.PathDisplay = PathDisplay;
|