@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.cjs.js
CHANGED
|
@@ -6336,6 +6336,13 @@ const StyledButton$1 = material.styled(material.Button)(({ theme }) => ({
|
|
|
6336
6336
|
textTransform: "none",
|
|
6337
6337
|
transition: "none",
|
|
6338
6338
|
borderRadius: "4px",
|
|
6339
|
+
width: "max-content",
|
|
6340
|
+
maxWidth: "100%",
|
|
6341
|
+
whiteSpace: "normal",
|
|
6342
|
+
overflowWrap: "break-word",
|
|
6343
|
+
textAlign: "center",
|
|
6344
|
+
alignItems: "center",
|
|
6345
|
+
height: "auto",
|
|
6339
6346
|
"& .MuiButton-startIcon": {
|
|
6340
6347
|
marginLeft: "0px",
|
|
6341
6348
|
},
|
|
@@ -6347,16 +6354,22 @@ const StyledButton$1 = material.styled(material.Button)(({ theme }) => ({
|
|
|
6347
6354
|
padding: "8px",
|
|
6348
6355
|
minWidth: "40px",
|
|
6349
6356
|
width: "40px",
|
|
6357
|
+
height: "40px",
|
|
6358
|
+
minHeight: "40px",
|
|
6350
6359
|
},
|
|
6351
6360
|
"&.MuiButton-sizeMedium": {
|
|
6352
6361
|
padding: "6px",
|
|
6353
6362
|
minWidth: "32px",
|
|
6354
6363
|
width: "32px",
|
|
6364
|
+
height: "32px",
|
|
6365
|
+
minHeight: "32px",
|
|
6355
6366
|
},
|
|
6356
6367
|
"&.MuiButton-sizeSmall": {
|
|
6357
6368
|
padding: "2px",
|
|
6358
6369
|
minWidth: "24px",
|
|
6359
6370
|
width: "24px",
|
|
6371
|
+
height: "24px",
|
|
6372
|
+
minHeight: "24px",
|
|
6360
6373
|
},
|
|
6361
6374
|
},
|
|
6362
6375
|
"&.MuiButton-sizeLarge": {
|
|
@@ -6364,7 +6377,8 @@ const StyledButton$1 = material.styled(material.Button)(({ theme }) => ({
|
|
|
6364
6377
|
fontWeight: 600,
|
|
6365
6378
|
fontSize: "16px",
|
|
6366
6379
|
lineHeight: "125%",
|
|
6367
|
-
|
|
6380
|
+
minHeight: "40px",
|
|
6381
|
+
height: "auto",
|
|
6368
6382
|
padding: "10px 16px",
|
|
6369
6383
|
},
|
|
6370
6384
|
"&.OuiButton-hasIcon.MuiButton-sizeLarge": {
|
|
@@ -6375,7 +6389,8 @@ const StyledButton$1 = material.styled(material.Button)(({ theme }) => ({
|
|
|
6375
6389
|
fontWeight: 600,
|
|
6376
6390
|
fontSize: "14px",
|
|
6377
6391
|
lineHeight: "125%",
|
|
6378
|
-
|
|
6392
|
+
minHeight: "32px",
|
|
6393
|
+
height: "auto",
|
|
6379
6394
|
padding: "7px 16px",
|
|
6380
6395
|
},
|
|
6381
6396
|
"&.MuiButton-sizeSmall": {
|
|
@@ -6383,7 +6398,8 @@ const StyledButton$1 = material.styled(material.Button)(({ theme }) => ({
|
|
|
6383
6398
|
fontWeight: 600,
|
|
6384
6399
|
fontSize: "14px",
|
|
6385
6400
|
lineHeight: "125%",
|
|
6386
|
-
|
|
6401
|
+
minHeight: "24px",
|
|
6402
|
+
height: "auto",
|
|
6387
6403
|
padding: "3px 12px",
|
|
6388
6404
|
},
|
|
6389
6405
|
"&.MuiButton-sizeLarge svg": {
|
|
@@ -6602,7 +6618,7 @@ const isIconOnlyChild = (children) => {
|
|
|
6602
6618
|
}
|
|
6603
6619
|
return child.props.children == null;
|
|
6604
6620
|
};
|
|
6605
|
-
const Button = (_a) => {
|
|
6621
|
+
const Button = React.forwardRef((_a, ref) => {
|
|
6606
6622
|
var { children, className, disableRipple = true, endIcon, startIcon } = _a, props = __rest(_a, ["children", "className", "disableRipple", "endIcon", "startIcon"]);
|
|
6607
6623
|
const hasIcon = Boolean(startIcon || endIcon);
|
|
6608
6624
|
const isIconOnly = !hasIcon && isIconOnlyChild(children);
|
|
@@ -6613,8 +6629,9 @@ const Button = (_a) => {
|
|
|
6613
6629
|
]
|
|
6614
6630
|
.filter(Boolean)
|
|
6615
6631
|
.join(" ");
|
|
6616
|
-
return (jsxRuntime.jsx(StyledButton$1, Object.assign({ className: buttonClassName || undefined, disableRipple: disableRipple, endIcon: endIcon, startIcon: startIcon }, props, { children: children })));
|
|
6617
|
-
};
|
|
6632
|
+
return (jsxRuntime.jsx(StyledButton$1, Object.assign({ ref: ref, className: buttonClassName || undefined, disableRipple: disableRipple, endIcon: endIcon, startIcon: startIcon }, props, { children: children })));
|
|
6633
|
+
});
|
|
6634
|
+
Button.displayName = "Button";
|
|
6618
6635
|
|
|
6619
6636
|
const getSpinnerWrapperStyles = (size) => ({
|
|
6620
6637
|
position: "relative",
|
|
@@ -7633,18 +7650,48 @@ const SelectNodeListItem = ({ isLeaf, isSelectable = true, listItemProps = {}, o
|
|
|
7633
7650
|
}, children: [selectNodeElement, selectableLeavesCount && (jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { cursor: "pointer", color: theme.palette.vars.baseTextWeak }, children: selectableLeavesCount }))] })));
|
|
7634
7651
|
};
|
|
7635
7652
|
|
|
7653
|
+
const TOOLTIP_ARROW_WIDTH = 10;
|
|
7654
|
+
const TOOLTIP_ARROW_HEIGHT = 6;
|
|
7636
7655
|
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" }));
|
|
7637
7656
|
const tooltipArrowStyles = (theme) => ({
|
|
7638
7657
|
color: theme.palette.vars.inactiveBackgroundActive,
|
|
7639
|
-
height:
|
|
7640
|
-
width:
|
|
7658
|
+
height: `${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7659
|
+
width: `${TOOLTIP_ARROW_WIDTH}px`,
|
|
7641
7660
|
"&::before": {
|
|
7642
7661
|
backgroundColor: "currentColor",
|
|
7643
|
-
|
|
7644
|
-
height: "
|
|
7645
|
-
width: "
|
|
7662
|
+
display: "block",
|
|
7663
|
+
height: "100%",
|
|
7664
|
+
width: "100%",
|
|
7646
7665
|
},
|
|
7647
7666
|
});
|
|
7667
|
+
const tooltipPopperSx = {
|
|
7668
|
+
[`&[data-popper-placement*="bottom"] .MuiTooltip-arrow`]: {
|
|
7669
|
+
marginTop: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7670
|
+
},
|
|
7671
|
+
[`&[data-popper-placement*="top"] .MuiTooltip-arrow`]: {
|
|
7672
|
+
marginBottom: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7673
|
+
},
|
|
7674
|
+
[`&[data-popper-placement*="left"] .MuiTooltip-arrow, &[data-popper-placement*="right"] .MuiTooltip-arrow`]: {
|
|
7675
|
+
height: `${TOOLTIP_ARROW_WIDTH}px`,
|
|
7676
|
+
width: `${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7677
|
+
},
|
|
7678
|
+
[`&[data-popper-placement*="right"] .MuiTooltip-arrow`]: {
|
|
7679
|
+
marginLeft: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7680
|
+
marginRight: 0,
|
|
7681
|
+
},
|
|
7682
|
+
[`&[data-popper-placement*="left"] .MuiTooltip-arrow`]: {
|
|
7683
|
+
marginRight: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7684
|
+
marginLeft: 0,
|
|
7685
|
+
},
|
|
7686
|
+
'[dir="rtl"] &[data-popper-placement*="right"] .MuiTooltip-arrow': {
|
|
7687
|
+
marginLeft: 0,
|
|
7688
|
+
marginRight: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7689
|
+
},
|
|
7690
|
+
'[dir="rtl"] &[data-popper-placement*="left"] .MuiTooltip-arrow': {
|
|
7691
|
+
marginRight: 0,
|
|
7692
|
+
marginLeft: `-${TOOLTIP_ARROW_HEIGHT}px`,
|
|
7693
|
+
},
|
|
7694
|
+
};
|
|
7648
7695
|
const largeTooltipStyles = {
|
|
7649
7696
|
height: "32px",
|
|
7650
7697
|
padding: "8px 12px",
|
|
@@ -7669,12 +7716,7 @@ const tooltipPopper = {
|
|
|
7669
7716
|
},
|
|
7670
7717
|
},
|
|
7671
7718
|
],
|
|
7672
|
-
sx:
|
|
7673
|
-
'&[data-popper-placement*="left"] .MuiTooltip-arrow, &[data-popper-placement*="right"] .MuiTooltip-arrow': {
|
|
7674
|
-
height: "10px",
|
|
7675
|
-
width: "6px",
|
|
7676
|
-
},
|
|
7677
|
-
},
|
|
7719
|
+
sx: tooltipPopperSx,
|
|
7678
7720
|
};
|
|
7679
7721
|
const tooltipSlotProps = {
|
|
7680
7722
|
[exports.TooltipSize.Medium]: {
|
|
@@ -13140,44 +13182,604 @@ const PickerItem = (_a) => {
|
|
|
13140
13182
|
], children: [jsxRuntime.jsx(material.Box, { className: "picker-icon", "aria-hidden": true, children: icon }), jsxRuntime.jsx(material.Box, { component: "span", className: "picker-label", children: label })] })));
|
|
13141
13183
|
};
|
|
13142
13184
|
|
|
13185
|
+
exports.PopoverPlacementSide = void 0;
|
|
13186
|
+
(function (PopoverPlacementSide) {
|
|
13187
|
+
PopoverPlacementSide["Top"] = "top";
|
|
13188
|
+
PopoverPlacementSide["Bottom"] = "bottom";
|
|
13189
|
+
PopoverPlacementSide["Left"] = "left";
|
|
13190
|
+
PopoverPlacementSide["Right"] = "right";
|
|
13191
|
+
})(exports.PopoverPlacementSide || (exports.PopoverPlacementSide = {}));
|
|
13192
|
+
exports.PopoverPlacementAlign = void 0;
|
|
13193
|
+
(function (PopoverPlacementAlign) {
|
|
13194
|
+
PopoverPlacementAlign["Start"] = "start";
|
|
13195
|
+
PopoverPlacementAlign["End"] = "end";
|
|
13196
|
+
PopoverPlacementAlign["Center"] = "center";
|
|
13197
|
+
})(exports.PopoverPlacementAlign || (exports.PopoverPlacementAlign = {}));
|
|
13198
|
+
exports.PopoverPlacement = void 0;
|
|
13199
|
+
(function (PopoverPlacement) {
|
|
13200
|
+
PopoverPlacement["Top"] = "top";
|
|
13201
|
+
PopoverPlacement["TopStart"] = "top-start";
|
|
13202
|
+
PopoverPlacement["TopEnd"] = "top-end";
|
|
13203
|
+
PopoverPlacement["Bottom"] = "bottom";
|
|
13204
|
+
PopoverPlacement["BottomStart"] = "bottom-start";
|
|
13205
|
+
PopoverPlacement["BottomEnd"] = "bottom-end";
|
|
13206
|
+
PopoverPlacement["Left"] = "left";
|
|
13207
|
+
PopoverPlacement["LeftStart"] = "left-start";
|
|
13208
|
+
PopoverPlacement["LeftEnd"] = "left-end";
|
|
13209
|
+
PopoverPlacement["Right"] = "right";
|
|
13210
|
+
PopoverPlacement["RightStart"] = "right-start";
|
|
13211
|
+
PopoverPlacement["RightEnd"] = "right-end";
|
|
13212
|
+
})(exports.PopoverPlacement || (exports.PopoverPlacement = {}));
|
|
13213
|
+
const POPOVER_PLACEMENTS = [
|
|
13214
|
+
exports.PopoverPlacement.BottomStart,
|
|
13215
|
+
exports.PopoverPlacement.Bottom,
|
|
13216
|
+
exports.PopoverPlacement.BottomEnd,
|
|
13217
|
+
exports.PopoverPlacement.TopStart,
|
|
13218
|
+
exports.PopoverPlacement.Top,
|
|
13219
|
+
exports.PopoverPlacement.TopEnd,
|
|
13220
|
+
exports.PopoverPlacement.LeftStart,
|
|
13221
|
+
exports.PopoverPlacement.Left,
|
|
13222
|
+
exports.PopoverPlacement.LeftEnd,
|
|
13223
|
+
exports.PopoverPlacement.RightStart,
|
|
13224
|
+
exports.PopoverPlacement.Right,
|
|
13225
|
+
exports.PopoverPlacement.RightEnd,
|
|
13226
|
+
];
|
|
13227
|
+
var PopoverVerticalPlacement;
|
|
13228
|
+
(function (PopoverVerticalPlacement) {
|
|
13229
|
+
PopoverVerticalPlacement["Above"] = "above";
|
|
13230
|
+
PopoverVerticalPlacement["Below"] = "below";
|
|
13231
|
+
})(PopoverVerticalPlacement || (PopoverVerticalPlacement = {}));
|
|
13232
|
+
var PopoverHorizontalPlacement;
|
|
13233
|
+
(function (PopoverHorizontalPlacement) {
|
|
13234
|
+
PopoverHorizontalPlacement["Left"] = "left";
|
|
13235
|
+
PopoverHorizontalPlacement["Center"] = "center";
|
|
13236
|
+
PopoverHorizontalPlacement["Right"] = "right";
|
|
13237
|
+
})(PopoverHorizontalPlacement || (PopoverHorizontalPlacement = {}));
|
|
13238
|
+
var PopoverSidePlacement;
|
|
13239
|
+
(function (PopoverSidePlacement) {
|
|
13240
|
+
PopoverSidePlacement["Left"] = "left";
|
|
13241
|
+
PopoverSidePlacement["Right"] = "right";
|
|
13242
|
+
})(PopoverSidePlacement || (PopoverSidePlacement = {}));
|
|
13243
|
+
var PopoverEdgeAlignment;
|
|
13244
|
+
(function (PopoverEdgeAlignment) {
|
|
13245
|
+
PopoverEdgeAlignment["Top"] = "top";
|
|
13246
|
+
PopoverEdgeAlignment["Center"] = "center";
|
|
13247
|
+
PopoverEdgeAlignment["Bottom"] = "bottom";
|
|
13248
|
+
})(PopoverEdgeAlignment || (PopoverEdgeAlignment = {}));
|
|
13249
|
+
var PopoverArrowAxisAlign;
|
|
13250
|
+
(function (PopoverArrowAxisAlign) {
|
|
13251
|
+
PopoverArrowAxisAlign["Left"] = "left";
|
|
13252
|
+
PopoverArrowAxisAlign["Right"] = "right";
|
|
13253
|
+
PopoverArrowAxisAlign["Top"] = "top";
|
|
13254
|
+
PopoverArrowAxisAlign["Bottom"] = "bottom";
|
|
13255
|
+
PopoverArrowAxisAlign["Center"] = "center";
|
|
13256
|
+
})(PopoverArrowAxisAlign || (PopoverArrowAxisAlign = {}));
|
|
13257
|
+
|
|
13258
|
+
const VIEWPORT_MARGIN = 16;
|
|
13259
|
+
const POPOVER_ARROW_HEIGHT = 8;
|
|
13260
|
+
const POPOVER_ARROW_WIDTH = POPOVER_ARROW_HEIGHT;
|
|
13261
|
+
const CENTER_PLACEMENTS = new Set([
|
|
13262
|
+
exports.PopoverPlacement.Top,
|
|
13263
|
+
exports.PopoverPlacement.Bottom,
|
|
13264
|
+
exports.PopoverPlacement.Left,
|
|
13265
|
+
exports.PopoverPlacement.Right,
|
|
13266
|
+
]);
|
|
13267
|
+
const OPPOSITE_PLACEMENT_SIDE = {
|
|
13268
|
+
[exports.PopoverPlacementSide.Top]: exports.PopoverPlacementSide.Bottom,
|
|
13269
|
+
[exports.PopoverPlacementSide.Bottom]: exports.PopoverPlacementSide.Top,
|
|
13270
|
+
[exports.PopoverPlacementSide.Left]: exports.PopoverPlacementSide.Right,
|
|
13271
|
+
[exports.PopoverPlacementSide.Right]: exports.PopoverPlacementSide.Left,
|
|
13272
|
+
};
|
|
13273
|
+
const VERTICAL_CENTER_PLACEMENT = {
|
|
13274
|
+
[exports.PopoverPlacementSide.Top]: exports.PopoverPlacement.Top,
|
|
13275
|
+
[exports.PopoverPlacementSide.Bottom]: exports.PopoverPlacement.Bottom,
|
|
13276
|
+
};
|
|
13277
|
+
const SIDE_CENTER_PLACEMENT = {
|
|
13278
|
+
[PopoverSidePlacement.Left]: exports.PopoverPlacement.Left,
|
|
13279
|
+
[PopoverSidePlacement.Right]: exports.PopoverPlacement.Right,
|
|
13280
|
+
};
|
|
13281
|
+
|
|
13282
|
+
const getOppositePlacementSide = (side) => OPPOSITE_PLACEMENT_SIDE[side];
|
|
13283
|
+
const getPlacementSide = (placement) => placement.split("-")[0];
|
|
13284
|
+
const getPlacementAlign = (placement) => {
|
|
13285
|
+
if (CENTER_PLACEMENTS.has(placement)) {
|
|
13286
|
+
return exports.PopoverPlacementAlign.Center;
|
|
13287
|
+
}
|
|
13288
|
+
if (placement.endsWith(`-${exports.PopoverPlacementAlign.Start}`)) {
|
|
13289
|
+
return exports.PopoverPlacementAlign.Start;
|
|
13290
|
+
}
|
|
13291
|
+
return exports.PopoverPlacementAlign.End;
|
|
13292
|
+
};
|
|
13293
|
+
const getArrowAxisAlign = (placement) => {
|
|
13294
|
+
const side = getPlacementSide(placement);
|
|
13295
|
+
const align = getPlacementAlign(placement);
|
|
13296
|
+
if (side === exports.PopoverPlacementSide.Top ||
|
|
13297
|
+
side === exports.PopoverPlacementSide.Bottom) {
|
|
13298
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13299
|
+
return PopoverArrowAxisAlign.Left;
|
|
13300
|
+
}
|
|
13301
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13302
|
+
return PopoverArrowAxisAlign.Right;
|
|
13303
|
+
}
|
|
13304
|
+
return PopoverArrowAxisAlign.Center;
|
|
13305
|
+
}
|
|
13306
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13307
|
+
return PopoverArrowAxisAlign.Top;
|
|
13308
|
+
}
|
|
13309
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13310
|
+
return PopoverArrowAxisAlign.Bottom;
|
|
13311
|
+
}
|
|
13312
|
+
return PopoverArrowAxisAlign.Center;
|
|
13313
|
+
};
|
|
13314
|
+
|
|
13315
|
+
const toHorizontalOrigin = (align) => {
|
|
13316
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13317
|
+
return PopoverHorizontalPlacement.Left;
|
|
13318
|
+
}
|
|
13319
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13320
|
+
return PopoverHorizontalPlacement.Right;
|
|
13321
|
+
}
|
|
13322
|
+
return PopoverHorizontalPlacement.Center;
|
|
13323
|
+
};
|
|
13324
|
+
const toVerticalOrigin = (align) => {
|
|
13325
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13326
|
+
return PopoverEdgeAlignment.Top;
|
|
13327
|
+
}
|
|
13328
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13329
|
+
return PopoverEdgeAlignment.Bottom;
|
|
13330
|
+
}
|
|
13331
|
+
return PopoverEdgeAlignment.Center;
|
|
13332
|
+
};
|
|
13333
|
+
const getOriginsForPlacement = (placement) => {
|
|
13334
|
+
const side = getPlacementSide(placement);
|
|
13335
|
+
const align = getPlacementAlign(placement);
|
|
13336
|
+
if (side === exports.PopoverPlacementSide.Top) {
|
|
13337
|
+
const horizontal = toHorizontalOrigin(align);
|
|
13338
|
+
return {
|
|
13339
|
+
anchorOrigin: {
|
|
13340
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13341
|
+
horizontal,
|
|
13342
|
+
},
|
|
13343
|
+
transformOrigin: {
|
|
13344
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13345
|
+
horizontal,
|
|
13346
|
+
},
|
|
13347
|
+
};
|
|
13348
|
+
}
|
|
13349
|
+
if (side === exports.PopoverPlacementSide.Bottom) {
|
|
13350
|
+
const horizontal = toHorizontalOrigin(align);
|
|
13351
|
+
return {
|
|
13352
|
+
anchorOrigin: {
|
|
13353
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13354
|
+
horizontal,
|
|
13355
|
+
},
|
|
13356
|
+
transformOrigin: {
|
|
13357
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13358
|
+
horizontal,
|
|
13359
|
+
},
|
|
13360
|
+
};
|
|
13361
|
+
}
|
|
13362
|
+
if (side === exports.PopoverPlacementSide.Left) {
|
|
13363
|
+
const vertical = toVerticalOrigin(align);
|
|
13364
|
+
return {
|
|
13365
|
+
anchorOrigin: {
|
|
13366
|
+
vertical,
|
|
13367
|
+
horizontal: exports.PopoverPlacementSide.Left,
|
|
13368
|
+
},
|
|
13369
|
+
transformOrigin: {
|
|
13370
|
+
vertical,
|
|
13371
|
+
horizontal: exports.PopoverPlacementSide.Right,
|
|
13372
|
+
},
|
|
13373
|
+
};
|
|
13374
|
+
}
|
|
13375
|
+
const vertical = toVerticalOrigin(align);
|
|
13376
|
+
return {
|
|
13377
|
+
anchorOrigin: {
|
|
13378
|
+
vertical,
|
|
13379
|
+
horizontal: exports.PopoverPlacementSide.Right,
|
|
13380
|
+
},
|
|
13381
|
+
transformOrigin: {
|
|
13382
|
+
vertical,
|
|
13383
|
+
horizontal: exports.PopoverPlacementSide.Left,
|
|
13384
|
+
},
|
|
13385
|
+
};
|
|
13386
|
+
};
|
|
13387
|
+
const getOriginsForVerticalPlacement = (placement, horizontal = PopoverHorizontalPlacement.Center) => {
|
|
13388
|
+
if (placement === PopoverVerticalPlacement.Above) {
|
|
13389
|
+
return {
|
|
13390
|
+
anchorOrigin: {
|
|
13391
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13392
|
+
horizontal,
|
|
13393
|
+
},
|
|
13394
|
+
transformOrigin: {
|
|
13395
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13396
|
+
horizontal,
|
|
13397
|
+
},
|
|
13398
|
+
};
|
|
13399
|
+
}
|
|
13400
|
+
return {
|
|
13401
|
+
anchorOrigin: {
|
|
13402
|
+
vertical: exports.PopoverPlacementSide.Bottom,
|
|
13403
|
+
horizontal,
|
|
13404
|
+
},
|
|
13405
|
+
transformOrigin: {
|
|
13406
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13407
|
+
horizontal,
|
|
13408
|
+
},
|
|
13409
|
+
};
|
|
13410
|
+
};
|
|
13411
|
+
const getVerticalPreference = (anchorOrigin, transformOrigin) => {
|
|
13412
|
+
if (transformOrigin.vertical === exports.PopoverPlacementSide.Bottom &&
|
|
13413
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Top) {
|
|
13414
|
+
return PopoverVerticalPlacement.Above;
|
|
13415
|
+
}
|
|
13416
|
+
if (transformOrigin.vertical === exports.PopoverPlacementSide.Top &&
|
|
13417
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Bottom) {
|
|
13418
|
+
return PopoverVerticalPlacement.Below;
|
|
13419
|
+
}
|
|
13420
|
+
return PopoverVerticalPlacement.Above;
|
|
13421
|
+
};
|
|
13422
|
+
const getHorizontalPreference = (anchorOrigin, transformOrigin) => {
|
|
13423
|
+
var _a, _b;
|
|
13424
|
+
const anchor = (_a = anchorOrigin.horizontal) !== null && _a !== void 0 ? _a : PopoverHorizontalPlacement.Center;
|
|
13425
|
+
const transform = (_b = transformOrigin.horizontal) !== null && _b !== void 0 ? _b : PopoverHorizontalPlacement.Center;
|
|
13426
|
+
if (anchor === PopoverHorizontalPlacement.Left &&
|
|
13427
|
+
transform === PopoverHorizontalPlacement.Left) {
|
|
13428
|
+
return PopoverHorizontalPlacement.Left;
|
|
13429
|
+
}
|
|
13430
|
+
if (anchor === PopoverHorizontalPlacement.Right &&
|
|
13431
|
+
transform === PopoverHorizontalPlacement.Right) {
|
|
13432
|
+
return PopoverHorizontalPlacement.Right;
|
|
13433
|
+
}
|
|
13434
|
+
return PopoverHorizontalPlacement.Center;
|
|
13435
|
+
};
|
|
13436
|
+
const getSidePreference = (placement) => getPlacementSide(placement) === exports.PopoverPlacementSide.Right
|
|
13437
|
+
? PopoverSidePlacement.Right
|
|
13438
|
+
: PopoverSidePlacement.Left;
|
|
13439
|
+
const getEdgeAlignmentPreference = (placement) => {
|
|
13440
|
+
const align = getPlacementAlign(placement);
|
|
13441
|
+
if (align === exports.PopoverPlacementAlign.Start) {
|
|
13442
|
+
return PopoverEdgeAlignment.Top;
|
|
13443
|
+
}
|
|
13444
|
+
if (align === exports.PopoverPlacementAlign.End) {
|
|
13445
|
+
return PopoverEdgeAlignment.Bottom;
|
|
13446
|
+
}
|
|
13447
|
+
return PopoverEdgeAlignment.Center;
|
|
13448
|
+
};
|
|
13449
|
+
|
|
13450
|
+
const getPopoverHorizontalBounds = ({ anchorLeft, anchorRight, anchorWidth, popoverWidth, horizontal, }) => {
|
|
13451
|
+
switch (horizontal) {
|
|
13452
|
+
case PopoverHorizontalPlacement.Left:
|
|
13453
|
+
return { left: anchorLeft, right: anchorLeft + popoverWidth };
|
|
13454
|
+
case PopoverHorizontalPlacement.Right:
|
|
13455
|
+
return { left: anchorRight - popoverWidth, right: anchorRight };
|
|
13456
|
+
default: {
|
|
13457
|
+
const center = anchorLeft + anchorWidth / 2;
|
|
13458
|
+
return {
|
|
13459
|
+
left: center - popoverWidth / 2,
|
|
13460
|
+
right: center + popoverWidth / 2,
|
|
13461
|
+
};
|
|
13462
|
+
}
|
|
13463
|
+
}
|
|
13464
|
+
};
|
|
13465
|
+
const getPopoverVerticalBounds = ({ anchorTop, anchorBottom, anchorHeight, popoverHeight, vertical, }) => {
|
|
13466
|
+
switch (vertical) {
|
|
13467
|
+
case PopoverEdgeAlignment.Top:
|
|
13468
|
+
return { top: anchorTop, bottom: anchorTop + popoverHeight };
|
|
13469
|
+
case PopoverEdgeAlignment.Bottom:
|
|
13470
|
+
return { top: anchorBottom - popoverHeight, bottom: anchorBottom };
|
|
13471
|
+
default: {
|
|
13472
|
+
const center = anchorTop + anchorHeight / 2;
|
|
13473
|
+
return {
|
|
13474
|
+
top: center - popoverHeight / 2,
|
|
13475
|
+
bottom: center + popoverHeight / 2,
|
|
13476
|
+
};
|
|
13477
|
+
}
|
|
13478
|
+
}
|
|
13479
|
+
};
|
|
13480
|
+
|
|
13481
|
+
const resolveVerticalPlacement = ({ preferAbove, spaceAbove, spaceBelow, popoverHeight, hasArrow, margin = VIEWPORT_MARGIN, }) => {
|
|
13482
|
+
const clearance = hasArrow ? POPOVER_ARROW_HEIGHT : 0;
|
|
13483
|
+
const required = popoverHeight + clearance;
|
|
13484
|
+
const aboveRoom = spaceAbove - margin;
|
|
13485
|
+
const belowRoom = spaceBelow - margin;
|
|
13486
|
+
const fitsAbove = aboveRoom >= required;
|
|
13487
|
+
const fitsBelow = belowRoom >= required;
|
|
13488
|
+
if (preferAbove && fitsAbove)
|
|
13489
|
+
return PopoverVerticalPlacement.Above;
|
|
13490
|
+
if (!preferAbove && fitsBelow)
|
|
13491
|
+
return PopoverVerticalPlacement.Below;
|
|
13492
|
+
if (fitsAbove && !fitsBelow)
|
|
13493
|
+
return PopoverVerticalPlacement.Above;
|
|
13494
|
+
if (fitsBelow && !fitsAbove)
|
|
13495
|
+
return PopoverVerticalPlacement.Below;
|
|
13496
|
+
return aboveRoom >= belowRoom
|
|
13497
|
+
? PopoverVerticalPlacement.Above
|
|
13498
|
+
: PopoverVerticalPlacement.Below;
|
|
13499
|
+
};
|
|
13500
|
+
const resolveHorizontalPlacement = ({ preferHorizontal, anchorLeft, anchorRight, anchorWidth, popoverWidth, margin = VIEWPORT_MARGIN, viewportWidth, }) => {
|
|
13501
|
+
const fits = (horizontal) => {
|
|
13502
|
+
const { left, right } = getPopoverHorizontalBounds({
|
|
13503
|
+
anchorLeft,
|
|
13504
|
+
anchorRight,
|
|
13505
|
+
anchorWidth,
|
|
13506
|
+
popoverWidth,
|
|
13507
|
+
horizontal,
|
|
13508
|
+
});
|
|
13509
|
+
return left >= margin && right <= viewportWidth - margin;
|
|
13510
|
+
};
|
|
13511
|
+
if (fits(preferHorizontal))
|
|
13512
|
+
return preferHorizontal;
|
|
13513
|
+
const alternatives = (() => {
|
|
13514
|
+
if (preferHorizontal === PopoverHorizontalPlacement.Center) {
|
|
13515
|
+
const { left } = getPopoverHorizontalBounds({
|
|
13516
|
+
anchorLeft,
|
|
13517
|
+
anchorRight,
|
|
13518
|
+
anchorWidth,
|
|
13519
|
+
popoverWidth,
|
|
13520
|
+
horizontal: PopoverHorizontalPlacement.Center,
|
|
13521
|
+
});
|
|
13522
|
+
return left < margin
|
|
13523
|
+
? [PopoverHorizontalPlacement.Left, PopoverHorizontalPlacement.Right]
|
|
13524
|
+
: [PopoverHorizontalPlacement.Right, PopoverHorizontalPlacement.Left];
|
|
13525
|
+
}
|
|
13526
|
+
if (preferHorizontal === PopoverHorizontalPlacement.Left) {
|
|
13527
|
+
return [
|
|
13528
|
+
PopoverHorizontalPlacement.Right,
|
|
13529
|
+
PopoverHorizontalPlacement.Center,
|
|
13530
|
+
];
|
|
13531
|
+
}
|
|
13532
|
+
return [PopoverHorizontalPlacement.Left, PopoverHorizontalPlacement.Center];
|
|
13533
|
+
})();
|
|
13534
|
+
for (const horizontal of alternatives) {
|
|
13535
|
+
if (fits(horizontal))
|
|
13536
|
+
return horizontal;
|
|
13537
|
+
}
|
|
13538
|
+
const overflow = (horizontal) => {
|
|
13539
|
+
const { left, right } = getPopoverHorizontalBounds({
|
|
13540
|
+
anchorLeft,
|
|
13541
|
+
anchorRight,
|
|
13542
|
+
anchorWidth,
|
|
13543
|
+
popoverWidth,
|
|
13544
|
+
horizontal,
|
|
13545
|
+
});
|
|
13546
|
+
const leftOverflow = Math.max(0, margin - left);
|
|
13547
|
+
const rightOverflow = Math.max(0, right - (viewportWidth - margin));
|
|
13548
|
+
return leftOverflow + rightOverflow;
|
|
13549
|
+
};
|
|
13550
|
+
const all = [
|
|
13551
|
+
PopoverHorizontalPlacement.Left,
|
|
13552
|
+
PopoverHorizontalPlacement.Center,
|
|
13553
|
+
PopoverHorizontalPlacement.Right,
|
|
13554
|
+
];
|
|
13555
|
+
return all.reduce((best, current) => overflow(current) < overflow(best) ? current : best);
|
|
13556
|
+
};
|
|
13557
|
+
const resolveSidePlacement = ({ preferSide, spaceLeft, spaceRight, popoverWidth, hasArrow, margin = VIEWPORT_MARGIN, }) => {
|
|
13558
|
+
const clearance = POPOVER_ARROW_WIDTH ;
|
|
13559
|
+
const required = popoverWidth + clearance;
|
|
13560
|
+
const leftRoom = spaceLeft - margin;
|
|
13561
|
+
const rightRoom = spaceRight - margin;
|
|
13562
|
+
const fitsLeft = leftRoom >= required;
|
|
13563
|
+
const fitsRight = rightRoom >= required;
|
|
13564
|
+
if (preferSide === PopoverSidePlacement.Left && fitsLeft) {
|
|
13565
|
+
return PopoverSidePlacement.Left;
|
|
13566
|
+
}
|
|
13567
|
+
if (preferSide === PopoverSidePlacement.Right && fitsRight) {
|
|
13568
|
+
return PopoverSidePlacement.Right;
|
|
13569
|
+
}
|
|
13570
|
+
if (fitsLeft && !fitsRight)
|
|
13571
|
+
return PopoverSidePlacement.Left;
|
|
13572
|
+
if (fitsRight && !fitsLeft)
|
|
13573
|
+
return PopoverSidePlacement.Right;
|
|
13574
|
+
return leftRoom >= rightRoom
|
|
13575
|
+
? PopoverSidePlacement.Left
|
|
13576
|
+
: PopoverSidePlacement.Right;
|
|
13577
|
+
};
|
|
13578
|
+
const resolveEdgeAlignment = ({ preferAlignment, anchorTop, anchorBottom, anchorHeight, popoverHeight, margin = VIEWPORT_MARGIN, viewportHeight, }) => {
|
|
13579
|
+
const fits = (vertical) => {
|
|
13580
|
+
const { top, bottom } = getPopoverVerticalBounds({
|
|
13581
|
+
anchorTop,
|
|
13582
|
+
anchorBottom,
|
|
13583
|
+
anchorHeight,
|
|
13584
|
+
popoverHeight,
|
|
13585
|
+
vertical,
|
|
13586
|
+
});
|
|
13587
|
+
return top >= margin && bottom <= viewportHeight - margin;
|
|
13588
|
+
};
|
|
13589
|
+
if (fits(preferAlignment))
|
|
13590
|
+
return preferAlignment;
|
|
13591
|
+
const alternatives = (() => {
|
|
13592
|
+
if (preferAlignment === PopoverEdgeAlignment.Center) {
|
|
13593
|
+
const { top } = getPopoverVerticalBounds({
|
|
13594
|
+
anchorTop,
|
|
13595
|
+
anchorBottom,
|
|
13596
|
+
anchorHeight,
|
|
13597
|
+
popoverHeight,
|
|
13598
|
+
vertical: PopoverEdgeAlignment.Center,
|
|
13599
|
+
});
|
|
13600
|
+
return top < margin
|
|
13601
|
+
? [PopoverEdgeAlignment.Top, PopoverEdgeAlignment.Bottom]
|
|
13602
|
+
: [PopoverEdgeAlignment.Bottom, PopoverEdgeAlignment.Top];
|
|
13603
|
+
}
|
|
13604
|
+
if (preferAlignment === PopoverEdgeAlignment.Top) {
|
|
13605
|
+
return [PopoverEdgeAlignment.Bottom, PopoverEdgeAlignment.Center];
|
|
13606
|
+
}
|
|
13607
|
+
return [PopoverEdgeAlignment.Top, PopoverEdgeAlignment.Center];
|
|
13608
|
+
})();
|
|
13609
|
+
for (const vertical of alternatives) {
|
|
13610
|
+
if (fits(vertical))
|
|
13611
|
+
return vertical;
|
|
13612
|
+
}
|
|
13613
|
+
const overflow = (vertical) => {
|
|
13614
|
+
const { top, bottom } = getPopoverVerticalBounds({
|
|
13615
|
+
anchorTop,
|
|
13616
|
+
anchorBottom,
|
|
13617
|
+
anchorHeight,
|
|
13618
|
+
popoverHeight,
|
|
13619
|
+
vertical,
|
|
13620
|
+
});
|
|
13621
|
+
const topOverflow = Math.max(0, margin - top);
|
|
13622
|
+
const bottomOverflow = Math.max(0, bottom - (viewportHeight - margin));
|
|
13623
|
+
return topOverflow + bottomOverflow;
|
|
13624
|
+
};
|
|
13625
|
+
const all = [
|
|
13626
|
+
PopoverEdgeAlignment.Top,
|
|
13627
|
+
PopoverEdgeAlignment.Center,
|
|
13628
|
+
PopoverEdgeAlignment.Bottom,
|
|
13629
|
+
];
|
|
13630
|
+
return all.reduce((best, current) => overflow(current) < overflow(best) ? current : best);
|
|
13631
|
+
};
|
|
13632
|
+
|
|
13633
|
+
const placementSideToSidePlacement = (side) => side === exports.PopoverPlacementSide.Right
|
|
13634
|
+
? PopoverSidePlacement.Right
|
|
13635
|
+
: PopoverSidePlacement.Left;
|
|
13636
|
+
const formatVerticalPlacement = (side, align) => {
|
|
13637
|
+
if (align === exports.PopoverPlacementAlign.Center) {
|
|
13638
|
+
return VERTICAL_CENTER_PLACEMENT[side];
|
|
13639
|
+
}
|
|
13640
|
+
return `${side}-${align}`;
|
|
13641
|
+
};
|
|
13642
|
+
const formatSidePlacement = (side, align) => {
|
|
13643
|
+
if (align === exports.PopoverPlacementAlign.Center) {
|
|
13644
|
+
return SIDE_CENTER_PLACEMENT[side];
|
|
13645
|
+
}
|
|
13646
|
+
return `${side}-${align}`;
|
|
13647
|
+
};
|
|
13648
|
+
const horizontalToPlacementAlign = (horizontal) => {
|
|
13649
|
+
if (horizontal === PopoverHorizontalPlacement.Left) {
|
|
13650
|
+
return exports.PopoverPlacementAlign.Start;
|
|
13651
|
+
}
|
|
13652
|
+
if (horizontal === PopoverHorizontalPlacement.Right) {
|
|
13653
|
+
return exports.PopoverPlacementAlign.End;
|
|
13654
|
+
}
|
|
13655
|
+
return exports.PopoverPlacementAlign.Center;
|
|
13656
|
+
};
|
|
13657
|
+
const edgeToPlacementAlign = (edge) => {
|
|
13658
|
+
if (edge === PopoverEdgeAlignment.Top) {
|
|
13659
|
+
return exports.PopoverPlacementAlign.Start;
|
|
13660
|
+
}
|
|
13661
|
+
if (edge === PopoverEdgeAlignment.Bottom) {
|
|
13662
|
+
return exports.PopoverPlacementAlign.End;
|
|
13663
|
+
}
|
|
13664
|
+
return exports.PopoverPlacementAlign.Center;
|
|
13665
|
+
};
|
|
13666
|
+
const placementForVerticalPlacement = (placement, verticalPlacement) => {
|
|
13667
|
+
const side = getPlacementSide(placement);
|
|
13668
|
+
if (side !== exports.PopoverPlacementSide.Top &&
|
|
13669
|
+
side !== exports.PopoverPlacementSide.Bottom) {
|
|
13670
|
+
return placement;
|
|
13671
|
+
}
|
|
13672
|
+
const align = getPlacementAlign(placement);
|
|
13673
|
+
return verticalPlacement === PopoverVerticalPlacement.Above
|
|
13674
|
+
? formatVerticalPlacement(exports.PopoverPlacementSide.Top, align)
|
|
13675
|
+
: formatVerticalPlacement(exports.PopoverPlacementSide.Bottom, align);
|
|
13676
|
+
};
|
|
13677
|
+
const placementForHorizontalPlacement = (placement, horizontal) => {
|
|
13678
|
+
const side = getPlacementSide(placement);
|
|
13679
|
+
if (side !== exports.PopoverPlacementSide.Top &&
|
|
13680
|
+
side !== exports.PopoverPlacementSide.Bottom) {
|
|
13681
|
+
return placement;
|
|
13682
|
+
}
|
|
13683
|
+
return formatVerticalPlacement(side, horizontalToPlacementAlign(horizontal));
|
|
13684
|
+
};
|
|
13685
|
+
const placementForSidePlacement = (placement, side) => {
|
|
13686
|
+
const placementSide = getPlacementSide(placement);
|
|
13687
|
+
if (placementSide !== exports.PopoverPlacementSide.Left &&
|
|
13688
|
+
placementSide !== exports.PopoverPlacementSide.Right) {
|
|
13689
|
+
return placement;
|
|
13690
|
+
}
|
|
13691
|
+
return formatSidePlacement(side, getPlacementAlign(placement));
|
|
13692
|
+
};
|
|
13693
|
+
const placementForEdgeAlignment = (placement, align) => {
|
|
13694
|
+
const side = getPlacementSide(placement);
|
|
13695
|
+
if (side !== exports.PopoverPlacementSide.Left &&
|
|
13696
|
+
side !== exports.PopoverPlacementSide.Right) {
|
|
13697
|
+
return placement;
|
|
13698
|
+
}
|
|
13699
|
+
return formatSidePlacement(placementSideToSidePlacement(side), edgeToPlacementAlign(align));
|
|
13700
|
+
};
|
|
13701
|
+
|
|
13702
|
+
const getArrowEdgeSide = (placement) => getOppositePlacementSide(getPlacementSide(placement));
|
|
13143
13703
|
const ARROW_SIZE = 16;
|
|
13144
13704
|
const ARROW_HALF = ARROW_SIZE / 2;
|
|
13145
|
-
const ARROW_HEIGHT =
|
|
13705
|
+
const ARROW_HEIGHT = POPOVER_ARROW_HEIGHT;
|
|
13146
13706
|
const ARROW_OFFSET = 12;
|
|
13147
13707
|
const popoverWidthBySize = {
|
|
13148
13708
|
medium: "228px",
|
|
13149
13709
|
large: "360px",
|
|
13150
13710
|
};
|
|
13151
|
-
const
|
|
13152
|
-
|
|
13711
|
+
const popoverContentLayoutBySize = {
|
|
13712
|
+
medium: { padding: "12px 16px", gap: "16px" },
|
|
13713
|
+
large: { padding: "16px 20px", gap: "20px" },
|
|
13714
|
+
};
|
|
13715
|
+
const getPaperArrowOffset = (placement, anchorOrigin = {
|
|
13716
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13717
|
+
}, transformOrigin = {
|
|
13718
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
13719
|
+
}) => {
|
|
13720
|
+
if (!placement)
|
|
13153
13721
|
return {};
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13722
|
+
const side = getPlacementSide(placement);
|
|
13723
|
+
if (side === exports.PopoverPlacementSide.Top &&
|
|
13724
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Top &&
|
|
13725
|
+
transformOrigin.vertical === exports.PopoverPlacementSide.Bottom) {
|
|
13726
|
+
return { marginTop: `-${ARROW_HEIGHT}px` };
|
|
13727
|
+
}
|
|
13728
|
+
if (side === exports.PopoverPlacementSide.Bottom &&
|
|
13729
|
+
anchorOrigin.vertical === exports.PopoverPlacementSide.Bottom &&
|
|
13730
|
+
transformOrigin.vertical === exports.PopoverPlacementSide.Top) {
|
|
13731
|
+
return { marginTop: `${ARROW_HEIGHT}px` };
|
|
13732
|
+
}
|
|
13733
|
+
if (side === exports.PopoverPlacementSide.Left &&
|
|
13734
|
+
anchorOrigin.horizontal === exports.PopoverPlacementSide.Left &&
|
|
13735
|
+
transformOrigin.horizontal === exports.PopoverPlacementSide.Right) {
|
|
13736
|
+
return { marginLeft: `-${ARROW_HEIGHT}px` };
|
|
13737
|
+
}
|
|
13738
|
+
if (side === exports.PopoverPlacementSide.Right &&
|
|
13739
|
+
anchorOrigin.horizontal === exports.PopoverPlacementSide.Right &&
|
|
13740
|
+
transformOrigin.horizontal === exports.PopoverPlacementSide.Left) {
|
|
13741
|
+
return { marginLeft: `${ARROW_HEIGHT}px` };
|
|
13742
|
+
}
|
|
13743
|
+
return {};
|
|
13157
13744
|
};
|
|
13158
|
-
const getArrowStyles = (
|
|
13745
|
+
const getArrowStyles = (placement, bg) => {
|
|
13746
|
+
const edgeSide = getArrowEdgeSide(placement);
|
|
13747
|
+
const align = getArrowAxisAlign(placement);
|
|
13159
13748
|
const base = {
|
|
13160
13749
|
position: "absolute",
|
|
13161
|
-
width: `${ARROW_SIZE}px`,
|
|
13162
|
-
height: `${ARROW_HEIGHT}px`,
|
|
13163
13750
|
background: bg,
|
|
13164
|
-
zIndex:
|
|
13751
|
+
zIndex: 2,
|
|
13752
|
+
pointerEvents: "none",
|
|
13165
13753
|
};
|
|
13166
|
-
const horizontal =
|
|
13754
|
+
const horizontal = align === PopoverArrowAxisAlign.Center
|
|
13167
13755
|
? { left: `calc(50% - ${ARROW_HALF}px)` }
|
|
13168
|
-
:
|
|
13756
|
+
: align === PopoverArrowAxisAlign.Left
|
|
13169
13757
|
? { left: `${ARROW_OFFSET}px` }
|
|
13170
13758
|
: { right: `${ARROW_OFFSET}px` };
|
|
13171
|
-
|
|
13172
|
-
|
|
13759
|
+
const vertical = align === PopoverArrowAxisAlign.Center
|
|
13760
|
+
? { top: `calc(50% - ${ARROW_HALF}px)` }
|
|
13761
|
+
: align === PopoverArrowAxisAlign.Top
|
|
13762
|
+
? { top: `${ARROW_OFFSET}px` }
|
|
13763
|
+
: { bottom: `${ARROW_OFFSET}px` };
|
|
13764
|
+
if (edgeSide === exports.PopoverPlacementSide.Bottom) {
|
|
13765
|
+
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)` });
|
|
13173
13766
|
}
|
|
13174
|
-
|
|
13767
|
+
if (edgeSide === exports.PopoverPlacementSide.Top) {
|
|
13768
|
+
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%)` });
|
|
13769
|
+
}
|
|
13770
|
+
if (edgeSide === exports.PopoverPlacementSide.Left) {
|
|
13771
|
+
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%)` });
|
|
13772
|
+
}
|
|
13773
|
+
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%)` });
|
|
13175
13774
|
};
|
|
13176
13775
|
const getPopoverPaperStyles = (theme, size = "medium") => {
|
|
13177
13776
|
var _a;
|
|
13178
|
-
|
|
13777
|
+
const width = popoverWidthBySize[size];
|
|
13778
|
+
return {
|
|
13179
13779
|
boxSizing: "border-box",
|
|
13180
|
-
width
|
|
13780
|
+
width,
|
|
13781
|
+
minWidth: width,
|
|
13782
|
+
maxWidth: width,
|
|
13181
13783
|
background: (_a = theme.palette.vars) === null || _a === void 0 ? void 0 : _a.controlBackgroundDefault,
|
|
13182
13784
|
borderRadius: "6px",
|
|
13183
13785
|
boxShadow: "none",
|
|
@@ -13185,25 +13787,34 @@ const getPopoverPaperStyles = (theme, size = "medium") => {
|
|
|
13185
13787
|
? `drop-shadow(${darkModeCardFloating})`
|
|
13186
13788
|
: `drop-shadow(${lightModeCardFloating})`,
|
|
13187
13789
|
overflow: "visible",
|
|
13188
|
-
|
|
13790
|
+
overflowX: "visible",
|
|
13791
|
+
overflowY: "visible",
|
|
13792
|
+
};
|
|
13793
|
+
};
|
|
13794
|
+
const popoverSurfaceStyles = {
|
|
13795
|
+
position: "relative",
|
|
13796
|
+
boxSizing: "border-box",
|
|
13797
|
+
width: "100%",
|
|
13798
|
+
overflow: "visible",
|
|
13189
13799
|
};
|
|
13190
|
-
const getPopoverContentStyles = (theme, featureHighlight = false) => {
|
|
13800
|
+
const getPopoverContentStyles = (theme, featureHighlight = false, size = "medium") => {
|
|
13191
13801
|
var _a, _b;
|
|
13192
|
-
|
|
13802
|
+
const layout = popoverContentLayoutBySize[size];
|
|
13803
|
+
return {
|
|
13193
13804
|
boxSizing: "border-box",
|
|
13194
13805
|
display: "flex",
|
|
13195
13806
|
flexDirection: "row",
|
|
13196
13807
|
justifyContent: "flex-end",
|
|
13197
13808
|
alignItems: "flex-start",
|
|
13198
|
-
gap:
|
|
13199
|
-
padding:
|
|
13809
|
+
gap: layout.gap,
|
|
13810
|
+
padding: layout.padding,
|
|
13200
13811
|
width: "100%",
|
|
13201
13812
|
background: (_a = theme.palette.vars) === null || _a === void 0 ? void 0 : _a.controlBackgroundDefault,
|
|
13202
13813
|
border: featureHighlight
|
|
13203
13814
|
? `2px solid ${(_b = theme.palette.vars) === null || _b === void 0 ? void 0 : _b.controlBorderActive}`
|
|
13204
13815
|
: "0px solid transparent",
|
|
13205
13816
|
borderRadius: "6px",
|
|
13206
|
-
}
|
|
13817
|
+
};
|
|
13207
13818
|
};
|
|
13208
13819
|
const popoverColumnStyles = {
|
|
13209
13820
|
display: "flex",
|
|
@@ -13255,10 +13866,15 @@ const popoverBodyStyles = (theme) => {
|
|
|
13255
13866
|
const popoverActionsStyles = {
|
|
13256
13867
|
display: "flex",
|
|
13257
13868
|
flexDirection: "row",
|
|
13869
|
+
flexWrap: "wrap",
|
|
13258
13870
|
justifyContent: "flex-end",
|
|
13259
13871
|
alignItems: "center",
|
|
13260
13872
|
gap: "12px",
|
|
13261
13873
|
width: "100%",
|
|
13874
|
+
"& .MuiButton-root": {
|
|
13875
|
+
flexShrink: 0,
|
|
13876
|
+
whiteSpace: "nowrap",
|
|
13877
|
+
},
|
|
13262
13878
|
};
|
|
13263
13879
|
const closeButtonStyles = {
|
|
13264
13880
|
padding: "2px",
|
|
@@ -13266,21 +13882,174 @@ const closeButtonStyles = {
|
|
|
13266
13882
|
flexShrink: 0,
|
|
13267
13883
|
};
|
|
13268
13884
|
|
|
13885
|
+
const resolveAnchorRect = (anchorEl) => {
|
|
13886
|
+
var _a, _b;
|
|
13887
|
+
if (!anchorEl)
|
|
13888
|
+
return null;
|
|
13889
|
+
const resolved = typeof anchorEl === "function" ? anchorEl() : anchorEl;
|
|
13890
|
+
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;
|
|
13891
|
+
};
|
|
13892
|
+
const resolvePlacementState = ({ anchorOrigin, transformOrigin, placement, }) => {
|
|
13893
|
+
if (placement) {
|
|
13894
|
+
const origins = getOriginsForPlacement(placement);
|
|
13895
|
+
return {
|
|
13896
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13897
|
+
transformOrigin: origins.transformOrigin,
|
|
13898
|
+
placement,
|
|
13899
|
+
};
|
|
13900
|
+
}
|
|
13901
|
+
return { anchorOrigin, transformOrigin, placement };
|
|
13902
|
+
};
|
|
13903
|
+
const isSameResolvedState = (current, next) => current.placement === next.placement &&
|
|
13904
|
+
current.anchorOrigin.vertical === next.anchorOrigin.vertical &&
|
|
13905
|
+
current.anchorOrigin.horizontal === next.anchorOrigin.horizontal &&
|
|
13906
|
+
current.transformOrigin.vertical === next.transformOrigin.vertical &&
|
|
13907
|
+
current.transformOrigin.horizontal === next.transformOrigin.horizontal;
|
|
13908
|
+
const getPreferenceOrigins = ({ anchorOrigin, transformOrigin, placement, }) => placement
|
|
13909
|
+
? getOriginsForPlacement(placement)
|
|
13910
|
+
: { anchorOrigin, transformOrigin };
|
|
13911
|
+
const useResolvedPopoverPlacement = ({ open, anchorEl, anchorOrigin, transformOrigin, placement, }) => {
|
|
13912
|
+
const paperRef = React.useRef(null);
|
|
13913
|
+
const [resolved, setResolved] = React.useState(() => resolvePlacementState({ anchorOrigin, transformOrigin, placement }));
|
|
13914
|
+
const updateResolved = (next) => {
|
|
13915
|
+
setResolved((current) => isSameResolvedState(current, next) ? current : next);
|
|
13916
|
+
};
|
|
13917
|
+
React.useLayoutEffect(() => {
|
|
13918
|
+
if (!open) {
|
|
13919
|
+
updateResolved(resolvePlacementState({ anchorOrigin, transformOrigin, placement }));
|
|
13920
|
+
return;
|
|
13921
|
+
}
|
|
13922
|
+
const anchorRect = resolveAnchorRect(anchorEl);
|
|
13923
|
+
if (!anchorRect)
|
|
13924
|
+
return;
|
|
13925
|
+
const { anchorOrigin: preferenceAnchorOrigin, transformOrigin: preferenceTransformOrigin, } = getPreferenceOrigins({ anchorOrigin, transformOrigin, placement });
|
|
13926
|
+
const measure = () => {
|
|
13927
|
+
const paper = paperRef.current;
|
|
13928
|
+
if (!paper)
|
|
13929
|
+
return;
|
|
13930
|
+
if (placement) {
|
|
13931
|
+
const placementSide = getPlacementSide(placement);
|
|
13932
|
+
if (placementSide === exports.PopoverPlacementSide.Top ||
|
|
13933
|
+
placementSide === exports.PopoverPlacementSide.Bottom) {
|
|
13934
|
+
const preferAbove = getVerticalPreference(preferenceAnchorOrigin, preferenceTransformOrigin) === "above";
|
|
13935
|
+
const preferHorizontal = getHorizontalPreference(preferenceAnchorOrigin, preferenceTransformOrigin);
|
|
13936
|
+
const verticalPlacement = resolveVerticalPlacement({
|
|
13937
|
+
preferAbove,
|
|
13938
|
+
spaceAbove: anchorRect.top,
|
|
13939
|
+
spaceBelow: window.innerHeight - anchorRect.bottom,
|
|
13940
|
+
popoverHeight: paper.offsetHeight,
|
|
13941
|
+
hasArrow: true,
|
|
13942
|
+
});
|
|
13943
|
+
const horizontalPlacement = resolveHorizontalPlacement({
|
|
13944
|
+
preferHorizontal,
|
|
13945
|
+
anchorLeft: anchorRect.left,
|
|
13946
|
+
anchorRight: anchorRect.right,
|
|
13947
|
+
anchorWidth: anchorRect.width,
|
|
13948
|
+
popoverWidth: paper.offsetWidth,
|
|
13949
|
+
viewportWidth: window.innerWidth,
|
|
13950
|
+
});
|
|
13951
|
+
const nextPlacement = placementForHorizontalPlacement(placementForVerticalPlacement(placement, verticalPlacement), horizontalPlacement);
|
|
13952
|
+
const origins = getOriginsForPlacement(nextPlacement);
|
|
13953
|
+
updateResolved({
|
|
13954
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13955
|
+
transformOrigin: origins.transformOrigin,
|
|
13956
|
+
placement: nextPlacement,
|
|
13957
|
+
});
|
|
13958
|
+
return;
|
|
13959
|
+
}
|
|
13960
|
+
const preferSide = getSidePreference(placement);
|
|
13961
|
+
const preferAlignment = getEdgeAlignmentPreference(placement);
|
|
13962
|
+
const sidePlacement = resolveSidePlacement({
|
|
13963
|
+
preferSide,
|
|
13964
|
+
spaceLeft: anchorRect.left,
|
|
13965
|
+
spaceRight: window.innerWidth - anchorRect.right,
|
|
13966
|
+
popoverWidth: paper.offsetWidth,
|
|
13967
|
+
hasArrow: true,
|
|
13968
|
+
});
|
|
13969
|
+
const edgeAlignment = resolveEdgeAlignment({
|
|
13970
|
+
preferAlignment,
|
|
13971
|
+
anchorTop: anchorRect.top,
|
|
13972
|
+
anchorBottom: anchorRect.bottom,
|
|
13973
|
+
anchorHeight: anchorRect.height,
|
|
13974
|
+
popoverHeight: paper.offsetHeight,
|
|
13975
|
+
viewportHeight: window.innerHeight,
|
|
13976
|
+
});
|
|
13977
|
+
const nextPlacement = placementForEdgeAlignment(placementForSidePlacement(placement, sidePlacement), edgeAlignment);
|
|
13978
|
+
const origins = getOriginsForPlacement(nextPlacement);
|
|
13979
|
+
updateResolved({
|
|
13980
|
+
anchorOrigin: origins.anchorOrigin,
|
|
13981
|
+
transformOrigin: origins.transformOrigin,
|
|
13982
|
+
placement: nextPlacement,
|
|
13983
|
+
});
|
|
13984
|
+
return;
|
|
13985
|
+
}
|
|
13986
|
+
const preferAbove = getVerticalPreference(preferenceAnchorOrigin, preferenceTransformOrigin) === "above";
|
|
13987
|
+
const verticalPlacement = resolveVerticalPlacement({
|
|
13988
|
+
preferAbove,
|
|
13989
|
+
spaceAbove: anchorRect.top,
|
|
13990
|
+
spaceBelow: window.innerHeight - anchorRect.bottom,
|
|
13991
|
+
popoverHeight: paper.offsetHeight,
|
|
13992
|
+
hasArrow: false,
|
|
13993
|
+
});
|
|
13994
|
+
const horizontalPlacement = resolveHorizontalPlacement({
|
|
13995
|
+
preferHorizontal: getHorizontalPreference(preferenceAnchorOrigin, preferenceTransformOrigin),
|
|
13996
|
+
anchorLeft: anchorRect.left,
|
|
13997
|
+
anchorRight: anchorRect.right,
|
|
13998
|
+
anchorWidth: anchorRect.width,
|
|
13999
|
+
popoverWidth: paper.offsetWidth,
|
|
14000
|
+
viewportWidth: window.innerWidth,
|
|
14001
|
+
});
|
|
14002
|
+
const origins = getOriginsForVerticalPlacement(verticalPlacement, horizontalPlacement);
|
|
14003
|
+
updateResolved({
|
|
14004
|
+
anchorOrigin: origins.anchorOrigin,
|
|
14005
|
+
transformOrigin: origins.transformOrigin,
|
|
14006
|
+
placement,
|
|
14007
|
+
});
|
|
14008
|
+
};
|
|
14009
|
+
const frame = requestAnimationFrame(measure);
|
|
14010
|
+
return () => cancelAnimationFrame(frame);
|
|
14011
|
+
}, [open, anchorEl, anchorOrigin, transformOrigin, placement]);
|
|
14012
|
+
const paperOffsetSx = getPaperArrowOffset(resolved.placement, resolved.anchorOrigin, resolved.transformOrigin);
|
|
14013
|
+
return {
|
|
14014
|
+
paperRef,
|
|
14015
|
+
anchorOrigin: resolved.anchorOrigin,
|
|
14016
|
+
transformOrigin: resolved.transformOrigin,
|
|
14017
|
+
placement: resolved.placement,
|
|
14018
|
+
paperOffsetSx,
|
|
14019
|
+
};
|
|
14020
|
+
};
|
|
14021
|
+
|
|
14022
|
+
const DEFAULT_POPOVER_ANCHOR_ORIGIN = {
|
|
14023
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
14024
|
+
horizontal: PopoverHorizontalPlacement.Left,
|
|
14025
|
+
};
|
|
14026
|
+
const DEFAULT_POPOVER_TRANSFORM_ORIGIN = {
|
|
14027
|
+
vertical: exports.PopoverPlacementSide.Top,
|
|
14028
|
+
horizontal: PopoverHorizontalPlacement.Left,
|
|
14029
|
+
};
|
|
13269
14030
|
const Popover = (_a) => {
|
|
13270
|
-
var { title, body, actions, icon, showCloseButton = false, featureHighlight = false, size = "medium",
|
|
14031
|
+
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"]);
|
|
13271
14032
|
const theme = material.useTheme();
|
|
14033
|
+
const { paperRef, anchorOrigin: resolvedAnchorOrigin, transformOrigin: resolvedTransformOrigin, placement: resolvedPlacement, paperOffsetSx, } = useResolvedPopoverPlacement({
|
|
14034
|
+
open,
|
|
14035
|
+
anchorEl: props.anchorEl,
|
|
14036
|
+
anchorOrigin,
|
|
14037
|
+
transformOrigin,
|
|
14038
|
+
placement,
|
|
14039
|
+
});
|
|
13272
14040
|
const bg = featureHighlight
|
|
13273
14041
|
? theme.palette.vars.controlBorderActive
|
|
13274
14042
|
: theme.palette.vars.controlBackgroundDefault;
|
|
13275
|
-
return (jsxRuntime.
|
|
14043
|
+
return (jsxRuntime.jsx(material.Popover, Object.assign({}, props, { open: open, disableScrollLock: disableScrollLock, marginThreshold: null, anchorOrigin: resolvedAnchorOrigin, transformOrigin: resolvedTransformOrigin, onClose: onClose, slotProps: {
|
|
13276
14044
|
paper: {
|
|
14045
|
+
ref: paperRef,
|
|
13277
14046
|
sx: [
|
|
13278
14047
|
getPopoverPaperStyles(theme, size),
|
|
13279
|
-
|
|
14048
|
+
paperOffsetSx,
|
|
13280
14049
|
...(Array.isArray(paperSx) ? paperSx : paperSx ? [paperSx] : []),
|
|
13281
14050
|
],
|
|
13282
14051
|
},
|
|
13283
|
-
}, children: [
|
|
14052
|
+
}, 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__default.default, { fontSize: "small" }) }))] })), body && (jsxRuntime.jsx(material.Typography, { component: "div", sx: popoverBodyStyles(theme), children: body }))] })), actions && jsxRuntime.jsx(material.Box, { sx: popoverActionsStyles, children: actions })] })] }))] }) })));
|
|
13284
14053
|
};
|
|
13285
14054
|
|
|
13286
14055
|
const getRadioButtonStyles = (theme) => ({
|
|
@@ -16629,6 +17398,7 @@ exports.NestedMenuListbox = NestedMenuListbox;
|
|
|
16629
17398
|
exports.NoData = NoData;
|
|
16630
17399
|
exports.OS_LIGHT_COLORS = OS_LIGHT_COLORS;
|
|
16631
17400
|
exports.OverflowTooltip = OverflowTooltip;
|
|
17401
|
+
exports.POPOVER_PLACEMENTS = POPOVER_PLACEMENTS;
|
|
16632
17402
|
exports.PageTitle = PageTitle;
|
|
16633
17403
|
exports.Pagination = Pagination;
|
|
16634
17404
|
exports.PathDisplay = PathDisplay;
|