@ringcentral/spring-ui 1.11.2 → 1.13.0
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/Accordion.js +90 -34
- package/AccordionHeader.js +72 -20
- package/Alert.js +120 -28
- package/Animation.js +2 -45
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -580
- package/Avatar.js +134 -73
- package/AvatarGroup.js +50 -7
- package/Backdrop.js +45 -7
- package/Badge.js +77 -15
- package/Block.js +34 -12
- package/BlockHeader.js +55 -11
- package/BottomNavigation.js +181 -65
- package/BottomNavigationItem.js +93 -30
- package/Button.js +160 -24
- package/CallButton.js +53 -31
- package/Checkbox.js +88 -26
- package/Chip.js +126 -26
- package/CircularProgressIndicator.js +80 -8
- package/ClickAwayListener.js +4 -1
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +611 -190
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +576 -250
- package/Dialog.js +100 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -74
- package/EmptyState.js +63 -11
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +106 -8
- package/FormLabel.js +81 -7
- package/Icon.js +1 -8
- package/IconButton.js +142 -26
- package/IconButtonGroup.js +35 -12
- package/InlineEditable.js +98 -44
- package/LinearProgressIndicator.js +73 -24
- package/Link.js +40 -11
- package/List.js +54 -9
- package/ListItem.js +152 -23
- package/ListItemText.js +44 -16
- package/ListNavigation.js +272 -20
- package/Menu.js +139 -23
- package/MenuActions.js +37 -12
- package/MenuDivider.js +34 -8
- package/MenuFooter.js +36 -12
- package/MenuHeader.js +54 -15
- package/MenuItem.js +402 -33
- package/MenuItemText.js +51 -8
- package/MenuList.js +87 -34
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -34
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -33
- package/Popover.js +262 -21
- package/Popper.js +130 -77
- package/PopperPaper.js +54 -8
- package/Portal.js +6 -1
- package/Radio.js +65 -21
- package/RadioGroup.js +56 -17
- package/Rating.js +223 -87
- package/Select.js +387 -41
- package/SingleFilter.js +148 -77
- package/Skeleton.js +68 -17
- package/Slider.js +168 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +52 -28
- package/SplitButton.js +124 -86
- package/Squircle.js +4 -7
- package/StatusIndicator.js +51 -9
- package/Step.js +63 -38
- package/StepButton.js +51 -23
- package/StepConnector.js +48 -8
- package/StepContent.js +68 -25
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -99
- package/SwipeableDrawer.js +439 -194
- package/Switch.js +70 -23
- package/Tab.js +120 -57
- package/TabContext.js +59 -15
- package/TabPanel.js +40 -13
- package/Table.js +60 -17
- package/TableBody.js +42 -12
- package/TableCell.js +84 -50
- package/TableContainer.js +32 -10
- package/TableFooter.js +38 -10
- package/TableHead.js +49 -15
- package/TablePagination.js +153 -77
- package/TableRow.js +60 -21
- package/Tabs.js +593 -268
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -29
- package/Textarea.js +51 -40
- package/TimePicker.js +490 -230
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -41
- package/VirtualizedList.js +208 -109
- package/VirtualizedMenu.js +359 -29
- package/VisuallyHidden.js +29 -6
- package/chunks/1250.js +98 -0
- package/chunks/1294.js +126 -0
- package/chunks/2956.js +18 -0
- package/chunks/4476.js +460 -0
- package/chunks/4491.js +10 -0
- package/chunks/4535.js +364 -0
- package/chunks/5047.js +3 -0
- package/chunks/6335.js +24 -0
- package/chunks/7279.js +10 -0
- package/chunks/8011.js +8 -0
- package/chunks/8307.js +56 -0
- package/chunks/8467.js +8 -0
- package/chunks/8809.js +8 -0
- package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
- package/chunks/987.js +8 -0
- package/index.css +2624 -2416
- package/index.js +245 -193
- package/internal/utils/index.d.ts +1 -0
- package/internal/utils/setRef.d.ts +2 -0
- package/package.json +8 -8
- package/src/Alert/Alert.type.d.ts +2 -1
- package/src/Animation/components/Fade/Fade.d.ts +4 -2
- package/src/Animation/components/Grow/Grow.d.ts +4 -2
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
- package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
- package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Autocomplete/useAutocomplete.d.ts +18 -18
- package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
- package/src/Badge/Badge.d.ts +2 -1
- package/src/Button/Button.classes.d.ts +1 -1
- package/src/ComponentsProps.d.ts +111 -110
- package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
- package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
- package/src/Dialer/DialPad/DialPad.d.ts +2 -2
- package/src/Dialer/Dialer.d.ts +4 -2
- package/src/Dropdown/Dropdown.type.d.ts +2 -2
- package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
- package/src/ListNavigation/useListNavigation.d.ts +3 -3
- package/src/MenuActions/MenuActions.d.ts +2 -2
- package/src/MenuItem/MenuItem.type.d.ts +1 -0
- package/src/MenuItem/useMenuItem.d.ts +1 -1
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
- package/src/MenuList/MenuList.type.d.ts +1 -1
- package/src/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Popover/Popover.classes.d.ts +1 -1
- package/src/Popover/Popover.internal.d.ts +8 -0
- package/src/Popover/Popover.type.d.ts +1 -0
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/Rating/utils.d.ts +3 -2
- package/src/Select/Select.type.d.ts +7 -5
- package/src/Slider/Slider.d.ts +2 -2
- package/src/Slider/SliderThumb.d.ts +2 -1
- package/src/Squircle/Squircle.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
- package/src/SubMenu/PopperMenu.type.d.ts +4 -1
- package/src/Table/Table.type.d.ts +3 -0
- package/src/Table/TableContext.d.ts +3 -0
- package/src/Table/TableRowContext.d.ts +7 -0
- package/src/Table/index.d.ts +1 -0
- package/src/TableCell/TableCell.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.type.d.ts +1 -0
- package/src/TableHead/TableHead.classes.d.ts +1 -1
- package/src/TableHead/TableHead.type.d.ts +1 -0
- package/src/TableRow/TableRow.type.d.ts +2 -0
- package/chunks/AccordionContext.js +0 -6
- package/chunks/Alert.js +0 -48
- package/chunks/AvatarGroup.js +0 -22
- package/chunks/Backdrop.js +0 -18
- package/chunks/Badge.js +0 -32
- package/chunks/BottomNavigationItem.js +0 -36
- package/chunks/Button.js +0 -88
- package/chunks/Chip.js +0 -73
- package/chunks/CircularProgressIndicator.js +0 -36
- package/chunks/Divider.js +0 -19
- package/chunks/DragHandle.js +0 -11
- package/chunks/Drawer.js +0 -32
- package/chunks/ExpandCollapseCaret.js +0 -24
- package/chunks/FormLabel.js +0 -27
- package/chunks/Icon.js +0 -25
- package/chunks/IconButtonLabel.js +0 -68
- package/chunks/List.js +0 -22
- package/chunks/ListItem.js +0 -83
- package/chunks/Menu.js +0 -61
- package/chunks/MenuDivider.js +0 -14
- package/chunks/MenuItemText.js +0 -17
- package/chunks/MenuList.js +0 -46
- package/chunks/Modal.js +0 -212
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -53
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -220
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -19
- package/chunks/SortableArrow.js +0 -73
- package/chunks/Squircle.js +0 -31
- package/chunks/StatusIndicator.js +0 -20
- package/chunks/StepConnector.js +0 -21
- package/chunks/StepIcon.js +0 -43
- package/chunks/StepLabel.js +0 -29
- package/chunks/StepperContext.js +0 -9
- package/chunks/TableContext.js +0 -6
- package/chunks/Tablelvl2Context.js +0 -6
- package/chunks/TabsContext.js +0 -6
- package/chunks/TextField.js +0 -110
- package/chunks/Tooltip.js +0 -217
- package/chunks/VirtualizedMenu.js +0 -164
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/getFade.js +0 -27
- package/chunks/getGrow.js +0 -70
- package/chunks/getSlideIn.js +0 -30
- package/chunks/hasContent.js +0 -3
- package/chunks/useAnimationFrame.js +0 -15
- package/chunks/useFocusTrapStack.js +0 -36
- package/chunks/useHelperTextId.js +0 -22
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -273
- package/chunks/useMotionSafeTransition.js +0 -9
- package/chunks/useNestedMenuItem.js +0 -27
- package/chunks/useNestedParentMenu.js +0 -113
- package/chunks/usePrefersReducedMotion.js +0 -36
- package/chunks/useTooltipForceHide.js +0 -27
- package/chunks/useTrayNavigate.js +0 -150
- package/chunks/withTooltip.js +0 -15
package/Popover.js
CHANGED
|
@@ -1,21 +1,262 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef } from "react";
|
|
3
|
+
import { shift, size } from "@floating-ui/react-dom";
|
|
4
|
+
import { combineProps, logInDev, useClasses, useForkRef } from "@ringcentral/spring-base";
|
|
5
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
6
|
+
import { getTransformOriginStringForPlacement, getGrow, getFade } from "./chunks/4476.js";
|
|
7
|
+
import { Modal as Modal_Modal } from "./Modal.js";
|
|
8
|
+
import { Popper } from "./Popper.js";
|
|
9
|
+
import { PopperPaper as PopperPaper_PopperPaper } from "./PopperPaper.js";
|
|
10
|
+
import { usePrefersReducedMotion } from "./chunks/1294.js";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// extracted by css-extract-rspack-plugin
|
|
18
|
+
/* export default */ var Popover = ({"sui-popover-popper":"sui-popover-popper","sui-popover-paper":"sui-popover-paper","sui-popover-widget":"sui-popover-widget","sui-popover-bordered":"sui-popover-bordered","sui-popover-shadow":"sui-popover-shadow","sui-popover-paper-content-no-vertical-scroll":"sui-popover-paper-content-no-vertical-scroll"});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/** Middleware name and its `middlewareData` key, which have to stay in sync. */ const DESIRED_CONTENT_HEIGHT = 'desiredContentHeight';
|
|
30
|
+
const Popover_Popover = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
31
|
+
/** Internal-only extras; see `Popover.internal.ts`. */ const props = useThemeProps({
|
|
32
|
+
props: inProps,
|
|
33
|
+
name: 'Popover'
|
|
34
|
+
});
|
|
35
|
+
const { classes, className, children, PopperProps, variant = 'standard', bordered = false, shadow = true, transformOrigin, motionProps: motionPropsProp, popperRef, placement, open, disableBackdropAnimation, anchorEl, actions, maxHeight, onAvailableHeightChange, measureDesiredHeight, disableContentVerticalScroll = false, deferEnterAnimation = false, PopperPaperProps: popperPaperPropsProp, ...rest } = props;
|
|
36
|
+
const cls = useClasses('popover', classes, className);
|
|
37
|
+
const paperContentRef = useRef(null);
|
|
38
|
+
const handlePaperContentRef = useForkRef(popperPaperPropsProp?.contentRef, paperContentRef);
|
|
39
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
40
|
+
return /*#__PURE__*/ jsx(Modal_Modal, {
|
|
41
|
+
...rest,
|
|
42
|
+
open: open,
|
|
43
|
+
className: cls('root', 'popper'),
|
|
44
|
+
ref: ref,
|
|
45
|
+
/**
|
|
46
|
+
* Pin the fade to `hidden` only while the consumer is still sizing itself,
|
|
47
|
+
* which is the one state Modal's own `toggle: open` cannot express. Handing
|
|
48
|
+
* back `null` afterwards restores Modal's default fade, so the animation
|
|
49
|
+
* plays from the settled size and nothing changes for other consumers.
|
|
50
|
+
*/ motionProps: deferEnterAnimation ? getFade({
|
|
51
|
+
prefersReducedMotion,
|
|
52
|
+
toggle: false
|
|
53
|
+
}) : null,
|
|
54
|
+
/**
|
|
55
|
+
* A close that lands while the fade is still pinned has nothing to play:
|
|
56
|
+
* the popover was never shown, and the pinned state leaves framer-motion
|
|
57
|
+
* with no change to report, so waiting for the exit would keep the content
|
|
58
|
+
* in the DOM for good. Leave through Modal's no-animation path instead.
|
|
59
|
+
*/ disableBackdropAnimation: disableBackdropAnimation || deferEnterAnimation && !open,
|
|
60
|
+
hideBackdrop: true,
|
|
61
|
+
children: /*#__PURE__*/ jsx(Popper, {
|
|
62
|
+
arrowHeight: variant === 'standard' ? 0 : 10,
|
|
63
|
+
arrowPadding: 12,
|
|
64
|
+
offset: variant === 'standard' ? 2 : 4,
|
|
65
|
+
...combineProps({
|
|
66
|
+
tether: false,
|
|
67
|
+
middlewares: (presetMiddlewares)=>{
|
|
68
|
+
/**
|
|
69
|
+
* Popper presets: offset, flip, shift, arrow, optional match-anchor-width size.
|
|
70
|
+
* Popover reorders them so alignment shift runs before its own `size`, and the
|
|
71
|
+
* preset tether shift runs after `size` so cross-axis movement does not inflate
|
|
72
|
+
* the clipping dimension `size` reports.
|
|
73
|
+
*
|
|
74
|
+
* Popper's match-anchor `size` stays in the trailing presets. When
|
|
75
|
+
* `matchAnchorWidth` is on, Popover skips content `maxWidth`: floating
|
|
76
|
+
* width already matches the anchor, and content should flow inside it
|
|
77
|
+
* without a separate viewport-based width cap.
|
|
78
|
+
*/ const restMiddlewares = [
|
|
79
|
+
...presetMiddlewares
|
|
80
|
+
];
|
|
81
|
+
const matchAnchorWidth = Boolean(PopperProps?.matchAnchorWidth);
|
|
82
|
+
/** Pull named presets out; anything Popper adds later stays in `restMiddlewares`. */ const takePreset = (name)=>{
|
|
83
|
+
const index = restMiddlewares.findIndex((middleware)=>middleware.name === name);
|
|
84
|
+
if (index === -1) {
|
|
85
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
86
|
+
logInDev({
|
|
87
|
+
scope: 'Popover',
|
|
88
|
+
message: `Popper preset middleware "${name}" was not found, so Popover cannot order it around its own \`size\` middleware.`
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
return restMiddlewares.splice(index, 1);
|
|
94
|
+
};
|
|
95
|
+
const offsetMiddleware = takePreset('offset');
|
|
96
|
+
const flipMiddleware = takePreset('flip');
|
|
97
|
+
const tetherShiftMiddleware = takePreset('shift');
|
|
98
|
+
const arrowMiddleware = takePreset('arrow');
|
|
99
|
+
/**
|
|
100
|
+
* Establish the height the content wants, ignoring the space the current
|
|
101
|
+
* side happens to have, and publish it for `flip` and `size` to share.
|
|
102
|
+
* `maxHeight` caps that demand: it is a height the consumer asked for,
|
|
103
|
+
* unlike the viewport clamp, which only reflects the current side.
|
|
104
|
+
*
|
|
105
|
+
* `flip` decides from the rendered box, so the clamp `size` left behind on
|
|
106
|
+
* the previous update would otherwise prove the current side still fits and
|
|
107
|
+
* `bestFit` would never move the popper to the roomier side.
|
|
108
|
+
*
|
|
109
|
+
* One value, two sources: a consumer whose height lives outside the DOM
|
|
110
|
+
* (virtualized list sized from state) restores and reports it through
|
|
111
|
+
* `measureDesiredHeight`; anything else is measured from the DOM once the
|
|
112
|
+
* viewport clamp is gone.
|
|
113
|
+
*
|
|
114
|
+
* Runs once per positioning pass. The guard lives in `middlewareData`, not a
|
|
115
|
+
* ref: `size` may reset the chain after it clamps, and a ref would keep
|
|
116
|
+
* clearing that clamp on every reset until Floating UI hits its reset limit
|
|
117
|
+
* and stops with `y` out of sync with the final height.
|
|
118
|
+
*/ const desiredContentHeight = {
|
|
119
|
+
name: DESIRED_CONTENT_HEIGHT,
|
|
120
|
+
fn ({ middlewareData }) {
|
|
121
|
+
if (middlewareData[DESIRED_CONTENT_HEIGHT]) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
const content = paperContentRef.current;
|
|
125
|
+
if (!content) {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
/** Drop the viewport clamp, but keep the cap the consumer asked for. */ const previousClamp = content.style.maxHeight;
|
|
129
|
+
const consumerClamp = maxHeight !== undefined ? `${maxHeight}px` : '';
|
|
130
|
+
content.style.maxHeight = consumerClamp;
|
|
131
|
+
const reportedHeight = measureDesiredHeight?.();
|
|
132
|
+
const measuredHeight = typeof reportedHeight === 'number' ? reportedHeight : content.scrollHeight;
|
|
133
|
+
const height = maxHeight !== undefined ? Math.min(maxHeight, measuredHeight) : measuredHeight;
|
|
134
|
+
const data = {
|
|
135
|
+
height
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
data,
|
|
139
|
+
/** Remeasure so `flip` sees the box at its desired size. */ ...previousClamp !== consumerClamp || reportedHeight !== undefined ? {
|
|
140
|
+
reset: {
|
|
141
|
+
rects: true
|
|
142
|
+
}
|
|
143
|
+
} : undefined
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return [
|
|
148
|
+
...offsetMiddleware,
|
|
149
|
+
desiredContentHeight,
|
|
150
|
+
...flipMiddleware,
|
|
151
|
+
shift({
|
|
152
|
+
padding: PopperProps?.padding
|
|
153
|
+
}),
|
|
154
|
+
size({
|
|
155
|
+
padding: PopperProps?.padding,
|
|
156
|
+
apply ({ availableHeight, availableWidth, elements, middlewareData }) {
|
|
157
|
+
const content = paperContentRef.current;
|
|
158
|
+
if (!content) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Available size is for the popper. Max size is applied to paper
|
|
163
|
+
* content, so subtract the paper's extra size (border, etc.).
|
|
164
|
+
*/ const decorationHeight = elements.floating.offsetHeight - content.offsetHeight;
|
|
165
|
+
const viewportMaxHeight = Math.max(0, availableHeight - decorationHeight);
|
|
166
|
+
/**
|
|
167
|
+
* Both caps guard the same box; use the smaller one so paper
|
|
168
|
+
* content stays the only scroller.
|
|
169
|
+
*/ const contentMaxHeight = maxHeight !== undefined ? Math.min(viewportMaxHeight, maxHeight) : viewportMaxHeight;
|
|
170
|
+
if (matchAnchorWidth) {
|
|
171
|
+
/**
|
|
172
|
+
* Floating width already matches the anchor (Popper `size`).
|
|
173
|
+
* Clear content `maxWidth` so paper content is not capped by a
|
|
174
|
+
* separate viewport-based width; it flows inside the floating box.
|
|
175
|
+
*/ content.style.maxWidth = '';
|
|
176
|
+
} else {
|
|
177
|
+
/**
|
|
178
|
+
* Always set maxWidth. If we cleared it when content "fits", wrapping
|
|
179
|
+
* would shrink `scrollWidth` to the cap, we would clear it, text would
|
|
180
|
+
* unwrap, and it would flicker.
|
|
181
|
+
*/ const decorationWidth = elements.floating.offsetWidth - content.offsetWidth;
|
|
182
|
+
content.style.maxWidth = `${Math.max(0, availableWidth - decorationWidth)}px`;
|
|
183
|
+
}
|
|
184
|
+
/** Clamp against the height already resolved before `flip`. */ const desiredHeight = middlewareData[DESIRED_CONTENT_HEIGHT]?.height ?? content.scrollHeight;
|
|
185
|
+
/** The consumer cap stays applied even where the viewport is roomier. */ content.style.maxHeight = maxHeight !== undefined || contentMaxHeight < desiredHeight ? `${contentMaxHeight}px` : '';
|
|
186
|
+
/**
|
|
187
|
+
* Height of a horizontal scrollbar, if any. Measured after the
|
|
188
|
+
* width/height caps above so it matches this pass.
|
|
189
|
+
* `offsetHeight - clientHeight` also includes vertical borders,
|
|
190
|
+
* so subtract those (consumers can border this element via
|
|
191
|
+
* `PopperPaperProps`).
|
|
192
|
+
*/ const { borderTopWidth, borderBottomWidth } = getComputedStyle(content);
|
|
193
|
+
const borderY = (Number.parseFloat(borderTopWidth) || 0) + (Number.parseFloat(borderBottomWidth) || 0);
|
|
194
|
+
const inlineScrollbarHeight = Math.max(0, content.offsetHeight - content.clientHeight - borderY);
|
|
195
|
+
/**
|
|
196
|
+
* Height left for content after decoration and that scrollbar.
|
|
197
|
+
* Filling the full `maxHeight` would hide the last rows behind it.
|
|
198
|
+
*/ onAvailableHeightChange?.(Math.max(0, contentMaxHeight - inlineScrollbarHeight));
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
...tetherShiftMiddleware,
|
|
202
|
+
...arrowMiddleware,
|
|
203
|
+
...restMiddlewares
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
}, PopperProps ?? {}, [
|
|
207
|
+
'middlewares'
|
|
208
|
+
]),
|
|
209
|
+
className: cls('popper'),
|
|
210
|
+
disablePortal: true,
|
|
211
|
+
tabIndex: -1,
|
|
212
|
+
ref: popperRef,
|
|
213
|
+
placement: placement,
|
|
214
|
+
anchorEl: anchorEl,
|
|
215
|
+
actions: actions,
|
|
216
|
+
children: ({ arrowStyle, arrowRef, placement: computedPlacement })=>{
|
|
217
|
+
const motionProps = motionPropsProp ?? getGrow({
|
|
218
|
+
transformOrigin,
|
|
219
|
+
prefersReducedMotion
|
|
220
|
+
});
|
|
221
|
+
const popperPaperProps = {
|
|
222
|
+
className: cls('paper', {
|
|
223
|
+
bordered,
|
|
224
|
+
shadow
|
|
225
|
+
}),
|
|
226
|
+
...disableContentVerticalScroll ? {
|
|
227
|
+
classes: {
|
|
228
|
+
content: cls('paper-content-no-vertical-scroll')
|
|
229
|
+
}
|
|
230
|
+
} : {}
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* If no transform origin is set, determine the transform origin using
|
|
234
|
+
* the computed placement. This ensures the transition used for the
|
|
235
|
+
* grow animation is always faithful to where the Popover is positioned.
|
|
236
|
+
*/ if (!transformOrigin) {
|
|
237
|
+
popperPaperProps.style = {
|
|
238
|
+
...popperPaperProps.style,
|
|
239
|
+
transformOrigin: getTransformOriginStringForPlacement({
|
|
240
|
+
placement: computedPlacement
|
|
241
|
+
})
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return /*#__PURE__*/ jsx(PopperPaper_PopperPaper, {
|
|
245
|
+
arrowRef: arrowRef,
|
|
246
|
+
arrowStyle: arrowStyle,
|
|
247
|
+
...combineProps(combineProps(motionProps, popperPaperProps), popperPaperPropsProp),
|
|
248
|
+
contentRef: handlePaperContentRef,
|
|
249
|
+
children: children
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
Popover_Popover.displayName = 'SuiPopover';
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
export { Popover as popoverStyle, Popover_Popover as Popover };
|
package/Popper.js
CHANGED
|
@@ -1,100 +1,127 @@
|
|
|
1
|
-
import { jsx } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { forwardRef,
|
|
6
|
-
import {
|
|
7
|
-
import { Portal } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { arrow, autoUpdate as react_dom_autoUpdate, flip, limitShift, offset as react_dom_offset, shift, size, useFloating } from "@floating-ui/react-dom";
|
|
3
|
+
import { useForkRef, useWindowContext } from "@ringcentral/spring-base";
|
|
4
|
+
import { useTheme, useThemeProps } from "@ringcentral/spring-theme";
|
|
5
|
+
import { forwardRef, useImperativeHandle, useLayoutEffect, useRef } from "react";
|
|
6
|
+
import { useModalContext, useOverlayBranch } from "./Modal.js";
|
|
7
|
+
import { Portal } from "./Portal.js";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const getArrowSide = (placement)=>({
|
|
23
|
+
top: 'bottom',
|
|
24
|
+
right: 'left',
|
|
25
|
+
bottom: 'top',
|
|
26
|
+
left: 'right'
|
|
27
|
+
})[placement.split('-')[0]];
|
|
28
|
+
const Popper = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
29
|
+
const props = useThemeProps({
|
|
30
|
+
props: inProps,
|
|
31
|
+
name: 'Popper'
|
|
32
|
+
});
|
|
33
|
+
const { children: childrenProp, middlewares: middlewaresProp = [], placement: placementProp, anchorEl, arrowHeight = 0, offset = 0, padding = 0, arrowPadding = 0, style, actions, autoUpdate = true, whileElementsMounted, matchAnchorWidth, tether = true, container: containerProp, disablePortal, ...rest } = props;
|
|
24
34
|
const { externalWindow, document } = useWindowContext();
|
|
25
35
|
const container = containerProp ?? document?.body;
|
|
26
36
|
const { scopeProps } = useTheme();
|
|
27
37
|
const modalContext = useModalContext();
|
|
38
|
+
const overlayBranchRegistry = modalContext?.overlayBranchRegistry;
|
|
28
39
|
const finalDisablePortal = disablePortal ?? (modalContext?.ariaHideEnabled ? true : false);
|
|
40
|
+
const overlayBranchRef = useOverlayBranch({
|
|
41
|
+
active: !finalDisablePortal,
|
|
42
|
+
registry: overlayBranchRegistry
|
|
43
|
+
});
|
|
29
44
|
const arrowRef = useRef(null);
|
|
30
45
|
const presetMiddlewares = [
|
|
31
|
-
|
|
46
|
+
react_dom_offset(offset + arrowHeight),
|
|
47
|
+
flip({
|
|
48
|
+
padding
|
|
49
|
+
}),
|
|
32
50
|
shift({
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
// tether: limitShift on alignment axis. Untethered: also shift crossAxis.
|
|
52
|
+
...tether ? {
|
|
53
|
+
limiter: limitShift()
|
|
54
|
+
} : {
|
|
55
|
+
crossAxis: true
|
|
56
|
+
},
|
|
57
|
+
padding
|
|
35
58
|
}),
|
|
36
59
|
arrow({
|
|
37
60
|
element: arrowRef,
|
|
38
|
-
padding: arrowPadding
|
|
39
|
-
})
|
|
40
|
-
offset(offset$1 + arrowHeight),
|
|
61
|
+
padding: arrowPadding
|
|
62
|
+
})
|
|
41
63
|
];
|
|
42
64
|
if (matchAnchorWidth) {
|
|
43
65
|
presetMiddlewares.push(size({
|
|
44
|
-
apply({ rects, elements
|
|
66
|
+
apply ({ rects, elements }) {
|
|
45
67
|
Object.assign(elements.floating.style, {
|
|
46
|
-
|
|
68
|
+
boxSizing: 'border-box',
|
|
69
|
+
width: `${rects.reference.width}px`
|
|
47
70
|
});
|
|
48
|
-
}
|
|
71
|
+
}
|
|
49
72
|
}));
|
|
50
73
|
}
|
|
51
|
-
const middlewares = typeof middlewaresProp === 'function'
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
74
|
+
const middlewares = typeof middlewaresProp === 'function' ? middlewaresProp(presetMiddlewares) : [
|
|
75
|
+
...presetMiddlewares,
|
|
76
|
+
...middlewaresProp
|
|
77
|
+
];
|
|
78
|
+
const { x, y, refs: { setReference, setFloating }, strategy, placement, update, middlewareData: { arrow: { x: arrowX, y: arrowY } = {} } } = useFloating({
|
|
55
79
|
placement: placementProp,
|
|
56
80
|
middleware: middlewares,
|
|
57
|
-
whileElementsMounted: (reference, floating, update)
|
|
81
|
+
whileElementsMounted: (reference, floating, update)=>{
|
|
58
82
|
const dispose = whileElementsMounted?.(reference, floating, update);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return autoUpdate(reference, floating, update, {
|
|
65
|
-
ancestorResize: true,
|
|
66
|
-
ancestorScroll: true,
|
|
67
|
-
animationFrame: false,
|
|
68
|
-
elementResize: Boolean(matchAnchorWidth),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return autoUpdate(reference, floating, update, autoUpdate$1);
|
|
72
|
-
})();
|
|
73
|
-
return () => {
|
|
83
|
+
/**
|
|
84
|
+
* `true` passes no options so floating-ui keeps its defaults, including
|
|
85
|
+
* skipping ResizeObserver / IntersectionObserver when they are missing (jsdom).
|
|
86
|
+
*/ const disposeAutoUpdate = autoUpdate === false ? undefined : react_dom_autoUpdate(reference, floating, update, autoUpdate === true ? undefined : autoUpdate);
|
|
87
|
+
return ()=>{
|
|
74
88
|
disposeAutoUpdate?.();
|
|
75
89
|
dispose?.();
|
|
76
90
|
};
|
|
77
|
-
}
|
|
91
|
+
}
|
|
78
92
|
});
|
|
79
|
-
useImperativeHandle(actions, ()
|
|
93
|
+
useImperativeHandle(actions, ()=>({
|
|
94
|
+
update
|
|
95
|
+
}), [
|
|
96
|
+
update
|
|
97
|
+
]);
|
|
80
98
|
const handleRootRef = useForkRef(ref, setFloating);
|
|
81
|
-
useLayoutEffect(()
|
|
82
|
-
if (anchorEl) {
|
|
83
|
-
const anchor = typeof anchorEl === 'function' ? anchorEl() : anchorEl;
|
|
84
|
-
setReference(anchor);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
99
|
+
useLayoutEffect(()=>{
|
|
100
|
+
if (!anchorEl) {
|
|
87
101
|
setReference(null);
|
|
102
|
+
return undefined;
|
|
88
103
|
}
|
|
89
|
-
|
|
104
|
+
const anchor = typeof anchorEl === 'function' ? anchorEl() : anchorEl;
|
|
105
|
+
setReference(anchor);
|
|
106
|
+
return ()=>{
|
|
107
|
+
setReference(null);
|
|
108
|
+
};
|
|
109
|
+
}, [
|
|
110
|
+
setReference,
|
|
111
|
+
anchorEl
|
|
112
|
+
]);
|
|
90
113
|
const arrowSide = getArrowSide(placement);
|
|
91
|
-
const
|
|
92
|
-
if (typeof childrenProp !== 'function')
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
const renderChildren = ()=>{
|
|
115
|
+
if (typeof childrenProp !== 'function') return childrenProp;
|
|
116
|
+
if (!arrowHeight) {
|
|
117
|
+
return childrenProp({
|
|
118
|
+
placement,
|
|
119
|
+
arrowRef,
|
|
120
|
+
arrowStyle: {}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
96
123
|
const squareSideLength = Math.round(((arrowHeight * 2) ** 2 / 2) ** (1 / 2));
|
|
97
|
-
|
|
124
|
+
const childrenRenderProps = {
|
|
98
125
|
placement,
|
|
99
126
|
arrowRef,
|
|
100
127
|
arrowStyle: {
|
|
@@ -102,25 +129,51 @@ const Popper = forwardRef((inProps, ref) => {
|
|
|
102
129
|
height: squareSideLength,
|
|
103
130
|
top: arrowY,
|
|
104
131
|
left: arrowX,
|
|
105
|
-
[arrowSide]: -squareSideLength / 2
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
132
|
+
[arrowSide]: -squareSideLength / 2
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
return childrenProp(childrenRenderProps);
|
|
136
|
+
};
|
|
137
|
+
const children = renderChildren();
|
|
109
138
|
const dpr = externalWindow?.devicePixelRatio ?? 1;
|
|
110
139
|
const fixedX = Math.round(Number(x ?? 0) * dpr) / dpr;
|
|
111
140
|
const fixedY = Math.round(Number(y ?? 0) * dpr) / dpr;
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
141
|
+
return /*#__PURE__*/ jsx(Portal, {
|
|
142
|
+
container: container,
|
|
143
|
+
disablePortal: finalDisablePortal,
|
|
144
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
145
|
+
ref: overlayBranchRef,
|
|
146
|
+
...scopeProps,
|
|
147
|
+
style: {
|
|
148
|
+
display: 'contents'
|
|
149
|
+
},
|
|
150
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
151
|
+
...rest,
|
|
152
|
+
"data-sui-popper-placement": placement,
|
|
153
|
+
ref: handleRootRef,
|
|
154
|
+
style: {
|
|
155
|
+
/* prevent arrow overflow when content too small */ ...arrowHeight ? {
|
|
156
|
+
minWidth: (arrowHeight + arrowPadding) * 2
|
|
157
|
+
} : undefined,
|
|
116
158
|
...style,
|
|
117
159
|
position: strategy,
|
|
118
160
|
top: '0',
|
|
119
161
|
left: '0',
|
|
120
162
|
transform: `translate3d(${fixedX}px,${fixedY}px,0)`,
|
|
121
|
-
|
|
122
|
-
|
|
163
|
+
// matchAnchorWidth: width is set by size middleware, not inline style.
|
|
164
|
+
...matchAnchorWidth ? undefined : {
|
|
165
|
+
width: 'max-content'
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
children: children
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
});
|
|
123
172
|
});
|
|
124
173
|
Popper.displayName = 'SuiPopper';
|
|
125
174
|
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
126
179
|
export { Popper };
|
package/PopperPaper.js
CHANGED
|
@@ -1,10 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import '@ringcentral/spring-theme';
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import { useClasses } from "@ringcentral/spring-base";
|
|
5
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
7
6
|
|
|
8
|
-
var PopperPaper = {"sui-popper-paper-root":"sui-popper-paper-root","sui-popper-paper-arrow":"sui-popper-paper-arrow","sui-popper":"sui-popper","sui-popper-paper-content":"sui-popper-paper-content"};
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// extracted by css-extract-rspack-plugin
|
|
13
|
+
/* export default */ var PopperPaper = ({"sui-popper-paper-root":"sui-popper-paper-root","sui-popper-paper-arrow":"sui-popper-paper-arrow","sui-popper":"sui-popper","sui-popper-paper-content":"sui-popper-paper-content"});
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const PopperPaper_PopperPaper = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
21
|
+
const props = useThemeProps({
|
|
22
|
+
props: inProps,
|
|
23
|
+
name: 'PopperPaper'
|
|
24
|
+
});
|
|
25
|
+
const { classes, className, children, arrowRef, arrowStyle, contentRef, ...rest } = props;
|
|
26
|
+
const cls = useClasses('popper-paper', classes, className);
|
|
27
|
+
/**
|
|
28
|
+
* Popper passes `{}` when `arrowHeight` is 0 ("not show arrow"). Rendering the
|
|
29
|
+
* empty arrow node still inherits paper border and can show a 1px corner dot.
|
|
30
|
+
*/ const showArrow = Object.keys(arrowStyle).length > 0;
|
|
31
|
+
return /*#__PURE__*/ jsxs(motion.div, {
|
|
32
|
+
className: cls('root'),
|
|
33
|
+
...rest,
|
|
34
|
+
ref: ref,
|
|
35
|
+
children: [
|
|
36
|
+
/*#__PURE__*/ jsx("div", {
|
|
37
|
+
ref: contentRef,
|
|
38
|
+
className: cls('content'),
|
|
39
|
+
children: children
|
|
40
|
+
}),
|
|
41
|
+
showArrow ? /*#__PURE__*/ jsx("div", {
|
|
42
|
+
className: cls('arrow'),
|
|
43
|
+
ref: arrowRef,
|
|
44
|
+
style: arrowStyle
|
|
45
|
+
}) : null
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
PopperPaper_PopperPaper.displayName = 'SuiPopperPaper';
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export { PopperPaper as popperPaperStyle, PopperPaper_PopperPaper as PopperPaper };
|