@qualtrics/ui-react 2.85.2 → 2.85.5
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/CHANGELOG.md +25 -0
- package/dist/__node_modules/@radix-ui/primitive/dist/index.js +14 -3
- package/dist/__node_modules/@radix-ui/primitive/dist/internal/is-development.false.js +4 -0
- package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +9 -6
- package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +263 -153
- package/dist/__node_modules/@radix-ui/react-compose-refs/dist/index.js +8 -1
- package/dist/__node_modules/@radix-ui/react-context/dist/index.js +35 -12
- package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +16 -6
- package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +172 -43
- package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +76 -95
- package/dist/__node_modules/@radix-ui/react-focus-guards/dist/index.js +30 -6
- package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +111 -30
- package/dist/__node_modules/@radix-ui/react-id/dist/index.js +6 -0
- package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +232 -197
- package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +104 -49
- package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +10 -8
- package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +72 -14
- package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +8 -2
- package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +52 -18
- package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +106 -54
- package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +17 -4
- package/dist/__node_modules/@radix-ui/react-use-controllable-state/dist/index.js +14 -4
- package/dist/__node_modules/@radix-ui/react-use-effect-event/dist/index.js +6 -1
- package/dist/__node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +37 -0
- package/dist/__node_modules/@radix-ui/react-use-layout-effect/dist/index.js +1 -1
- package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +28 -15
- package/dist/__shared/cjs/{index-e03dac36.js → index-bd03241f.js} +213 -208
- package/dist/__shared/cjs/{index-507024ee.js → index-ccb5282a.js} +12 -3
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Button/Button.js +52 -6
- package/dist/components/Button/Button2.js +6 -52
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/ColorPickerFlyout.js +1 -1
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/ConfigPane/ConfigPane.js +6 -2
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +1 -1
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/FilePicker/FilePicker.js +1 -1
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/Icon/IconTypes.js +1 -0
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +1 -1
- package/dist/components/Pagination/PaginationPreviousButton.js +1 -1
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +1 -1
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +1 -1
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/design-tokens/less/typography.js +3 -3
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/components/PulseIcon.js +11 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.es.js +1 -0
- package/dist/icons/index.js +2 -1
- package/dist/index.d.ts +72 -71
- package/dist/index.es.js +2 -2
- package/dist/index.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/Chat/Loader.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Form/FormFields/InputField.js +3 -3
- package/dist/next/Indicator/Indicator2.js +3 -3
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/next/Menu/Hooks/useFlyoutNode.js +48 -0
- package/dist/next/Menu/Menu.js +2 -2
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +6 -5
- package/dist/next/Menu/MenuItem.js +5 -4
- package/dist/next/Menu/MenuPane.js +20 -19
- package/dist/next/Menu/PaneChildren.js +15 -10
- package/dist/next/Menu/SubMenu.js +22 -21
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/SplitButton/SplitButton.js +1 -1
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/ToggleButton.js +1 -1
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.js +1581 -850
- package/dist/translations-en.js +71 -71
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/icons/package.json +4 -4
- package/next/package.json +5 -5
- package/package.json +16 -16
- package/dist/__node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -23
|
@@ -2,7 +2,7 @@ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWitho
|
|
|
2
2
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useFloating, autoUpdate, offset, shift, limitShift, flip, size, arrow, hide } from '@floating-ui/react-dom';
|
|
5
|
-
import {
|
|
5
|
+
import { Arrow } from '../../react-arrow/dist/index.js';
|
|
6
6
|
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
7
7
|
import { createContextScope } from '../../react-context/dist/index.js';
|
|
8
8
|
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
@@ -14,8 +14,21 @@ import { useSize } from '../../react-use-size/dist/index.js';
|
|
|
14
14
|
const _excluded = ["__scopePopper", "virtualRef"],
|
|
15
15
|
_excluded2 = ["__scopePopper", "side", "sideOffset", "align", "alignOffset", "arrowPadding", "avoidCollisions", "collisionBoundary", "collisionPadding", "sticky", "hideWhenDetached", "updatePositionStrategy", "onPlaced"],
|
|
16
16
|
_excluded3 = ["__scopePopper"];
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
19
|
+
value,
|
|
20
|
+
configurable: true
|
|
21
|
+
});
|
|
17
22
|
var SIDE_OPTIONS = ["top", "right", "bottom", "left"];
|
|
18
23
|
var ALIGN_OPTIONS = ["start", "center", "end"];
|
|
24
|
+
var Sticky = {
|
|
25
|
+
Partial: "partial",
|
|
26
|
+
Always: "always"
|
|
27
|
+
};
|
|
28
|
+
var UpdatePositionStrategy = {
|
|
29
|
+
Optimized: "optimized",
|
|
30
|
+
Always: "always"
|
|
31
|
+
};
|
|
19
32
|
var POPPER_NAME = "Popper";
|
|
20
33
|
var _createContextScope = createContextScope(POPPER_NAME),
|
|
21
34
|
_createContextScope2 = _slicedToArray(_createContextScope, 2),
|
|
@@ -25,50 +38,69 @@ var _createPopperContext = createPopperContext(POPPER_NAME),
|
|
|
25
38
|
_createPopperContext2 = _slicedToArray(_createPopperContext, 2),
|
|
26
39
|
PopperProvider = _createPopperContext2[0],
|
|
27
40
|
usePopperContext = _createPopperContext2[1];
|
|
28
|
-
var Popper = props => {
|
|
41
|
+
var Popper = /* @__PURE__ */__name(props => {
|
|
29
42
|
const __scopePopper = props.__scopePopper,
|
|
30
43
|
children = props.children;
|
|
31
44
|
const _React$useState = React.useState(null),
|
|
32
45
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
33
46
|
anchor = _React$useState2[0],
|
|
34
47
|
setAnchor = _React$useState2[1];
|
|
48
|
+
const _React$useState3 = React.useState(void 0),
|
|
49
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
50
|
+
placementState = _React$useState4[0],
|
|
51
|
+
setPlacementState = _React$useState4[1];
|
|
35
52
|
return /* @__PURE__ */React.createElement(PopperProvider, {
|
|
36
53
|
scope: __scopePopper,
|
|
37
54
|
anchor,
|
|
38
55
|
onAnchorChange: setAnchor,
|
|
56
|
+
placementState,
|
|
57
|
+
setPlacementState,
|
|
39
58
|
children
|
|
40
59
|
});
|
|
41
|
-
};
|
|
42
|
-
Popper.displayName = POPPER_NAME;
|
|
60
|
+
}, "Popper");
|
|
43
61
|
var ANCHOR_NAME = "PopperAnchor";
|
|
44
|
-
var PopperAnchor =
|
|
62
|
+
var PopperAnchor = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function PopperAnchor2(props, forwardedRef) {
|
|
45
63
|
const __scopePopper = props.__scopePopper,
|
|
46
64
|
virtualRef = props.virtualRef,
|
|
47
65
|
anchorProps = _objectWithoutProperties(props, _excluded);
|
|
48
66
|
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
49
67
|
const ref = React.useRef(null);
|
|
50
|
-
const
|
|
68
|
+
const onAnchorChange = context.onAnchorChange;
|
|
69
|
+
const callbackRef = React.useCallback(node => {
|
|
70
|
+
ref.current = node;
|
|
71
|
+
if (node) {
|
|
72
|
+
onAnchorChange(node);
|
|
73
|
+
}
|
|
74
|
+
}, [onAnchorChange]);
|
|
75
|
+
const composedRefs = useComposedRefs(forwardedRef, callbackRef);
|
|
51
76
|
const anchorRef = React.useRef(null);
|
|
52
77
|
React.useEffect(() => {
|
|
78
|
+
if (!virtualRef) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
53
81
|
const previousAnchor = anchorRef.current;
|
|
54
|
-
anchorRef.current =
|
|
82
|
+
anchorRef.current = virtualRef.current;
|
|
55
83
|
if (previousAnchor !== anchorRef.current) {
|
|
56
|
-
|
|
84
|
+
onAnchorChange(anchorRef.current);
|
|
57
85
|
}
|
|
58
86
|
});
|
|
87
|
+
const sideAndAlign = context.placementState && getSideAndAlignFromPlacement(context.placementState);
|
|
88
|
+
const placedSide = sideAndAlign === null || sideAndAlign === void 0 ? void 0 : sideAndAlign[0];
|
|
89
|
+
const placedAlign = sideAndAlign === null || sideAndAlign === void 0 ? void 0 : sideAndAlign[1];
|
|
59
90
|
return virtualRef ? null : /* @__PURE__ */React.createElement(Primitive.div, {
|
|
91
|
+
"data-radix-popper-side": placedSide,
|
|
92
|
+
"data-radix-popper-align": placedAlign,
|
|
60
93
|
...anchorProps,
|
|
61
94
|
ref: composedRefs
|
|
62
95
|
});
|
|
63
|
-
});
|
|
64
|
-
PopperAnchor.displayName = ANCHOR_NAME;
|
|
96
|
+
}, "PopperAnchor"));
|
|
65
97
|
var CONTENT_NAME = "PopperContent";
|
|
66
98
|
var _createPopperContext3 = createPopperContext(CONTENT_NAME),
|
|
67
99
|
_createPopperContext4 = _slicedToArray(_createPopperContext3, 2),
|
|
68
100
|
PopperContentProvider = _createPopperContext4[0],
|
|
69
101
|
useContentContext = _createPopperContext4[1];
|
|
70
|
-
var PopperContent =
|
|
71
|
-
var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
|
|
102
|
+
var PopperContent = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function PopperContent2(props, forwardedRef) {
|
|
103
|
+
var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide, _contentProps$style;
|
|
72
104
|
const __scopePopper = props.__scopePopper,
|
|
73
105
|
_props$side = props.side,
|
|
74
106
|
side = _props$side === void 0 ? "bottom" : _props$side,
|
|
@@ -87,23 +119,23 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
87
119
|
_props$collisionPaddi = props.collisionPadding,
|
|
88
120
|
collisionPaddingProp = _props$collisionPaddi === void 0 ? 0 : _props$collisionPaddi,
|
|
89
121
|
_props$sticky = props.sticky,
|
|
90
|
-
sticky = _props$sticky === void 0 ?
|
|
122
|
+
sticky = _props$sticky === void 0 ? Sticky.Partial : _props$sticky,
|
|
91
123
|
_props$hideWhenDetach = props.hideWhenDetached,
|
|
92
124
|
hideWhenDetached = _props$hideWhenDetach === void 0 ? false : _props$hideWhenDetach,
|
|
93
125
|
_props$updatePosition = props.updatePositionStrategy,
|
|
94
|
-
updatePositionStrategy = _props$updatePosition === void 0 ?
|
|
126
|
+
updatePositionStrategy = _props$updatePosition === void 0 ? UpdatePositionStrategy.Optimized : _props$updatePosition,
|
|
95
127
|
onPlaced = props.onPlaced,
|
|
96
128
|
contentProps = _objectWithoutProperties(props, _excluded2);
|
|
97
129
|
const context = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
98
|
-
const _React$useState3 = React.useState(null),
|
|
99
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
100
|
-
content = _React$useState4[0],
|
|
101
|
-
setContent = _React$useState4[1];
|
|
102
|
-
const composedRefs = useComposedRefs(forwardedRef, node => setContent(node));
|
|
103
130
|
const _React$useState5 = React.useState(null),
|
|
104
131
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
content = _React$useState6[0],
|
|
133
|
+
setContent = _React$useState6[1];
|
|
134
|
+
const composedRefs = useComposedRefs(forwardedRef, setContent);
|
|
135
|
+
const _React$useState7 = React.useState(null),
|
|
136
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
137
|
+
arrow$1 = _React$useState8[0],
|
|
138
|
+
setArrow = _React$useState8[1];
|
|
107
139
|
const arrowSize = useSize(arrow$1);
|
|
108
140
|
const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
|
|
109
141
|
const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
|
|
@@ -127,15 +159,15 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
127
159
|
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
128
160
|
strategy: "fixed",
|
|
129
161
|
placement: desiredPlacement,
|
|
130
|
-
whileElementsMounted: function () {
|
|
162
|
+
whileElementsMounted: /* @__PURE__ */__name(function () {
|
|
131
163
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
132
164
|
args[_key] = arguments[_key];
|
|
133
165
|
}
|
|
134
166
|
const cleanup = autoUpdate(...args, {
|
|
135
|
-
animationFrame: updatePositionStrategy ===
|
|
167
|
+
animationFrame: updatePositionStrategy === UpdatePositionStrategy.Always
|
|
136
168
|
});
|
|
137
169
|
return cleanup;
|
|
138
|
-
},
|
|
170
|
+
}, "whileElementsMounted"),
|
|
139
171
|
elements: {
|
|
140
172
|
reference: context.anchor
|
|
141
173
|
},
|
|
@@ -145,13 +177,17 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
145
177
|
}), avoidCollisions && shift({
|
|
146
178
|
mainAxis: true,
|
|
147
179
|
crossAxis: false,
|
|
148
|
-
|
|
180
|
+
// Spread rather than passing `limiter: undefined`, which
|
|
181
|
+
// `exactOptionalPropertyTypes` rejects for Floating UI's optional option.
|
|
182
|
+
...(sticky === Sticky.Partial ? {
|
|
183
|
+
limiter: limitShift()
|
|
184
|
+
} : {}),
|
|
149
185
|
...detectOverflowOptions
|
|
150
186
|
}), avoidCollisions && flip({
|
|
151
187
|
...detectOverflowOptions
|
|
152
188
|
}), size({
|
|
153
189
|
...detectOverflowOptions,
|
|
154
|
-
apply: _ref => {
|
|
190
|
+
apply: /* @__PURE__ */__name(_ref => {
|
|
155
191
|
let elements = _ref.elements,
|
|
156
192
|
rects = _ref.rects,
|
|
157
193
|
availableWidth = _ref.availableWidth,
|
|
@@ -164,16 +200,30 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
164
200
|
contentStyle.setProperty("--radix-popper-available-height", "".concat(availableHeight, "px"));
|
|
165
201
|
contentStyle.setProperty("--radix-popper-anchor-width", "".concat(anchorWidth, "px"));
|
|
166
202
|
contentStyle.setProperty("--radix-popper-anchor-height", "".concat(anchorHeight, "px"));
|
|
167
|
-
}
|
|
203
|
+
}, "apply")
|
|
168
204
|
}), arrow$1 && arrow({
|
|
169
205
|
element: arrow$1,
|
|
170
206
|
padding: arrowPadding
|
|
171
207
|
}), transformOrigin({
|
|
172
208
|
arrowWidth,
|
|
173
209
|
arrowHeight
|
|
174
|
-
}), hideWhenDetached &&
|
|
210
|
+
}), hideWhenDetached &&
|
|
211
|
+
// `hide` detects whether the anchor (reference) is clipped, so when
|
|
212
|
+
// no explicit `collisionBoundary` is set we omit `boundary` entirely
|
|
213
|
+
// and fall back to Floating UI's default clipping ancestors (e.g. a
|
|
214
|
+
// scrollable menu). This lets an occluded submenu hide once its anchor
|
|
215
|
+
// scrolls out of view (#3237). The collision/size middlewares
|
|
216
|
+
// deliberately keep the viewport-based default to avoid clamping
|
|
217
|
+
// content rendered inside transformed or overflow-clipping portal
|
|
218
|
+
// containers. The key is omitted rather than set to `undefined`
|
|
219
|
+
// because `exactOptionalPropertyTypes` rejects the explicit value.
|
|
220
|
+
hide(hasExplicitBoundaries ? {
|
|
175
221
|
strategy: "referenceHidden",
|
|
176
222
|
...detectOverflowOptions
|
|
223
|
+
} : {
|
|
224
|
+
strategy: "referenceHidden",
|
|
225
|
+
padding: detectOverflowOptions.padding,
|
|
226
|
+
altBoundary: detectOverflowOptions.altBoundary
|
|
177
227
|
})]
|
|
178
228
|
}),
|
|
179
229
|
refs = _useFloating.refs,
|
|
@@ -181,6 +231,13 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
181
231
|
placement = _useFloating.placement,
|
|
182
232
|
isPositioned = _useFloating.isPositioned,
|
|
183
233
|
middlewareData = _useFloating.middlewareData;
|
|
234
|
+
const setPlacementState = context.setPlacementState;
|
|
235
|
+
useLayoutEffect2(() => {
|
|
236
|
+
setPlacementState(placement);
|
|
237
|
+
return () => {
|
|
238
|
+
setPlacementState(void 0);
|
|
239
|
+
};
|
|
240
|
+
}, [placement, setPlacementState]);
|
|
184
241
|
const _getSideAndAlignFromP = getSideAndAlignFromPlacement(placement),
|
|
185
242
|
_getSideAndAlignFromP2 = _slicedToArray(_getSideAndAlignFromP, 2),
|
|
186
243
|
placedSide = _getSideAndAlignFromP2[0],
|
|
@@ -194,10 +251,10 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
194
251
|
const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
|
|
195
252
|
const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
|
|
196
253
|
const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
|
|
197
|
-
const _React$
|
|
198
|
-
_React$
|
|
199
|
-
contentZIndex = _React$
|
|
200
|
-
setContentZIndex = _React$
|
|
254
|
+
const _React$useState9 = React.useState(),
|
|
255
|
+
_React$useState0 = _slicedToArray(_React$useState9, 2),
|
|
256
|
+
contentZIndex = _React$useState0[0],
|
|
257
|
+
setContentZIndex = _React$useState0[1];
|
|
201
258
|
useLayoutEffect2(() => {
|
|
202
259
|
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
203
260
|
}, [content]);
|
|
@@ -210,7 +267,7 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
210
267
|
// keep off the page when measuring
|
|
211
268
|
minWidth: "max-content",
|
|
212
269
|
zIndex: contentZIndex,
|
|
213
|
-
|
|
270
|
+
"--radix-popper-transform-origin": [(_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x, (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y].join(" "),
|
|
214
271
|
// hide the content if using the hide middleware and should be hidden
|
|
215
272
|
// set visibility to hidden and disable pointer events so the UI behaves
|
|
216
273
|
// as if the PopperContent isn't there at all
|
|
@@ -223,6 +280,7 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
223
280
|
children: /* @__PURE__ */React.createElement(PopperContentProvider, {
|
|
224
281
|
scope: __scopePopper,
|
|
225
282
|
placedSide,
|
|
283
|
+
placedAlign,
|
|
226
284
|
onArrowChange: setArrow,
|
|
227
285
|
arrowX,
|
|
228
286
|
arrowY,
|
|
@@ -234,15 +292,15 @@ var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
234
292
|
ref: composedRefs,
|
|
235
293
|
style: {
|
|
236
294
|
...contentProps.style,
|
|
237
|
-
// if the PopperContent hasn't been placed yet (not all
|
|
238
|
-
// we prevent animations so that users'
|
|
239
|
-
|
|
295
|
+
// if the PopperContent hasn't been placed yet (not all
|
|
296
|
+
// measurements done) we prevent animations so that users'
|
|
297
|
+
// animations don't kick in too early from the wrong sides.
|
|
298
|
+
animation: !isPositioned ? "none" : (_contentProps$style = contentProps.style) === null || _contentProps$style === void 0 ? void 0 : _contentProps$style.animation
|
|
240
299
|
}
|
|
241
300
|
})
|
|
242
301
|
})
|
|
243
302
|
});
|
|
244
|
-
});
|
|
245
|
-
PopperContent.displayName = CONTENT_NAME;
|
|
303
|
+
}, "PopperContent"));
|
|
246
304
|
var ARROW_NAME = "PopperArrow";
|
|
247
305
|
var OPPOSITE_SIDE = {
|
|
248
306
|
top: "bottom",
|
|
@@ -250,7 +308,7 @@ var OPPOSITE_SIDE = {
|
|
|
250
308
|
bottom: "top",
|
|
251
309
|
left: "right"
|
|
252
310
|
};
|
|
253
|
-
var PopperArrow =
|
|
311
|
+
var PopperArrow = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function PopperArrow2(props, forwardedRef) {
|
|
254
312
|
const __scopePopper = props.__scopePopper,
|
|
255
313
|
arrowProps = _objectWithoutProperties(props, _excluded3);
|
|
256
314
|
const contentContext = useContentContext(ARROW_NAME, __scopePopper);
|
|
@@ -280,7 +338,7 @@ var PopperArrow = /*#__PURE__*/React.forwardRef(function PopperArrow2(props, for
|
|
|
280
338
|
}[contentContext.placedSide],
|
|
281
339
|
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
282
340
|
},
|
|
283
|
-
children: /* @__PURE__ */React.createElement(
|
|
341
|
+
children: /* @__PURE__ */React.createElement(Arrow, {
|
|
284
342
|
...arrowProps,
|
|
285
343
|
ref: forwardedRef,
|
|
286
344
|
style: {
|
|
@@ -291,12 +349,12 @@ var PopperArrow = /*#__PURE__*/React.forwardRef(function PopperArrow2(props, for
|
|
|
291
349
|
})
|
|
292
350
|
})
|
|
293
351
|
);
|
|
294
|
-
});
|
|
295
|
-
PopperArrow.displayName = ARROW_NAME;
|
|
352
|
+
}, "PopperArrow"));
|
|
296
353
|
function isNotNull(value) {
|
|
297
354
|
return value !== null;
|
|
298
355
|
}
|
|
299
|
-
|
|
356
|
+
__name(isNotNull, "isNotNull");
|
|
357
|
+
var transformOrigin = /* @__PURE__ */__name(options => ({
|
|
300
358
|
name: "transformOrigin",
|
|
301
359
|
options,
|
|
302
360
|
fn(data) {
|
|
@@ -341,7 +399,7 @@ var transformOrigin = options => ({
|
|
|
341
399
|
}
|
|
342
400
|
};
|
|
343
401
|
}
|
|
344
|
-
});
|
|
402
|
+
}), "transformOrigin");
|
|
345
403
|
function getSideAndAlignFromPlacement(placement) {
|
|
346
404
|
const _placement$split = placement.split("-"),
|
|
347
405
|
_placement$split2 = _slicedToArray(_placement$split, 2),
|
|
@@ -350,9 +408,6 @@ function getSideAndAlignFromPlacement(placement) {
|
|
|
350
408
|
align = _placement$split2$ === void 0 ? "center" : _placement$split2$;
|
|
351
409
|
return [side, align];
|
|
352
410
|
}
|
|
353
|
-
|
|
354
|
-
var Anchor = PopperAnchor;
|
|
355
|
-
var Content = PopperContent;
|
|
356
|
-
var Arrow = PopperArrow;
|
|
411
|
+
__name(getSideAndAlignFromPlacement, "getSideAndAlignFromPlacement");
|
|
357
412
|
|
|
358
|
-
export { ALIGN_OPTIONS, Anchor, Arrow, Content, Popper, PopperAnchor, PopperArrow, PopperContent,
|
|
413
|
+
export { ALIGN_OPTIONS, PopperAnchor as Anchor, PopperArrow as Arrow, PopperContent as Content, Popper, PopperAnchor, PopperArrow, PopperContent, Popper as Root, SIDE_OPTIONS, createPopperScope };
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import
|
|
4
|
+
import * as ReactDOM from 'react-dom';
|
|
5
5
|
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
6
6
|
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
7
7
|
|
|
8
8
|
"use client";
|
|
9
9
|
const _excluded = ["container"];
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
12
|
+
value,
|
|
13
|
+
configurable: true
|
|
14
|
+
});
|
|
15
|
+
var Portal = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function Portal2(props, forwardedRef) {
|
|
12
16
|
var _globalThis$document;
|
|
13
17
|
const containerProp = props.container,
|
|
14
18
|
portalProps = _objectWithoutProperties(props, _excluded);
|
|
@@ -18,12 +22,10 @@ var Portal = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
18
22
|
setMounted = _React$useState2[1];
|
|
19
23
|
useLayoutEffect2(() => setMounted(true), []);
|
|
20
24
|
const container = containerProp || mounted && (globalThis === null || globalThis === void 0 || (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body);
|
|
21
|
-
return container ? /*#__PURE__*/
|
|
25
|
+
return container ? /*#__PURE__*/ReactDOM.createPortal(/* @__PURE__ */React.createElement(Primitive.div, {
|
|
22
26
|
...portalProps,
|
|
23
27
|
ref: forwardedRef
|
|
24
28
|
}), container) : null;
|
|
25
|
-
});
|
|
26
|
-
Portal.displayName = PORTAL_NAME;
|
|
27
|
-
var Root = Portal;
|
|
29
|
+
}, "Portal"));
|
|
28
30
|
|
|
29
|
-
export { Portal, Root };
|
|
31
|
+
export { Portal, Portal as Root };
|
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
2
2
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
5
4
|
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
6
5
|
|
|
7
6
|
"use client";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
9
|
+
value,
|
|
10
|
+
configurable: true
|
|
11
|
+
});
|
|
8
12
|
function useStateMachine(initialState, machine) {
|
|
9
13
|
return React.useReducer((state, event) => {
|
|
10
14
|
const nextState = machine[state][event];
|
|
11
15
|
return nextState !== null && nextState !== void 0 ? nextState : state;
|
|
12
16
|
}, initialState);
|
|
13
17
|
}
|
|
18
|
+
__name(useStateMachine, "useStateMachine");
|
|
14
19
|
|
|
15
20
|
// src/presence.tsx
|
|
16
|
-
var Presence = props => {
|
|
21
|
+
var Presence = /* @__PURE__ */__name(props => {
|
|
17
22
|
const present = props.present,
|
|
18
23
|
children = props.children;
|
|
19
24
|
const presence = usePresence(present);
|
|
20
25
|
const child = typeof children === "function" ? children({
|
|
21
26
|
present: presence.isPresent
|
|
22
27
|
}) : React.Children.only(children);
|
|
23
|
-
const ref =
|
|
28
|
+
const ref = useStableComposedRefs(presence.ref, getElementRef(child));
|
|
24
29
|
const forceMount = typeof children === "function";
|
|
25
30
|
return forceMount || presence.isPresent ? /*#__PURE__*/React.cloneElement(child, {
|
|
26
31
|
ref
|
|
27
32
|
}) : null;
|
|
28
|
-
};
|
|
29
|
-
Presence.displayName = "Presence";
|
|
33
|
+
}, "Presence");
|
|
30
34
|
function usePresence(present) {
|
|
31
35
|
var _context;
|
|
32
36
|
const _React2$useState = React.useState(),
|
|
@@ -36,6 +40,7 @@ function usePresence(present) {
|
|
|
36
40
|
const stylesRef = React.useRef(null);
|
|
37
41
|
const prevPresentRef = React.useRef(present);
|
|
38
42
|
const prevAnimationNameRef = React.useRef("none");
|
|
43
|
+
const mountAnimationNameRef = React.useRef(void 0);
|
|
39
44
|
const initialState = present ? "mounted" : "unmounted";
|
|
40
45
|
const _useStateMachine = useStateMachine(initialState, {
|
|
41
46
|
mounted: {
|
|
@@ -54,8 +59,13 @@ function usePresence(present) {
|
|
|
54
59
|
state = _useStateMachine2[0],
|
|
55
60
|
send = _useStateMachine2[1];
|
|
56
61
|
React.useEffect(() => {
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
if (state === "mounted") {
|
|
63
|
+
var _mountAnimationNameRe;
|
|
64
|
+
prevAnimationNameRef.current = (_mountAnimationNameRe = mountAnimationNameRef.current) !== null && _mountAnimationNameRe !== void 0 ? _mountAnimationNameRe : getAnimationName(stylesRef.current);
|
|
65
|
+
mountAnimationNameRef.current = void 0;
|
|
66
|
+
} else {
|
|
67
|
+
prevAnimationNameRef.current = "none";
|
|
68
|
+
}
|
|
59
69
|
}, [state]);
|
|
60
70
|
useLayoutEffect2(() => {
|
|
61
71
|
const styles = stylesRef.current;
|
|
@@ -65,6 +75,7 @@ function usePresence(present) {
|
|
|
65
75
|
const prevAnimationName = prevAnimationNameRef.current;
|
|
66
76
|
const currentAnimationName = getAnimationName(styles);
|
|
67
77
|
if (present) {
|
|
78
|
+
mountAnimationNameRef.current = currentAnimationName;
|
|
68
79
|
send("MOUNT");
|
|
69
80
|
} else if (currentAnimationName === "none" || (styles === null || styles === void 0 ? void 0 : styles.display) === "none") {
|
|
70
81
|
send("UNMOUNT");
|
|
@@ -84,7 +95,7 @@ function usePresence(present) {
|
|
|
84
95
|
var _node$ownerDocument$d;
|
|
85
96
|
let timeoutId;
|
|
86
97
|
const ownerWindow = (_node$ownerDocument$d = node.ownerDocument.defaultView) !== null && _node$ownerDocument$d !== void 0 ? _node$ownerDocument$d : window;
|
|
87
|
-
const handleAnimationEnd = event => {
|
|
98
|
+
const handleAnimationEnd = /* @__PURE__ */__name(event => {
|
|
88
99
|
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
89
100
|
const isCurrentAnimation = _includesInstanceProperty(currentAnimationName).call(currentAnimationName, CSS.escape(event.animationName));
|
|
90
101
|
if (event.target === node && isCurrentAnimation) {
|
|
@@ -99,12 +110,12 @@ function usePresence(present) {
|
|
|
99
110
|
});
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
|
-
};
|
|
103
|
-
const handleAnimationStart = event => {
|
|
113
|
+
}, "handleAnimationEnd");
|
|
114
|
+
const handleAnimationStart = /* @__PURE__ */__name(event => {
|
|
104
115
|
if (event.target === node) {
|
|
105
116
|
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
106
117
|
}
|
|
107
|
-
};
|
|
118
|
+
}, "handleAnimationStart");
|
|
108
119
|
node.addEventListener("animationstart", handleAnimationStart);
|
|
109
120
|
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
110
121
|
node.addEventListener("animationend", handleAnimationEnd);
|
|
@@ -121,14 +132,61 @@ function usePresence(present) {
|
|
|
121
132
|
return {
|
|
122
133
|
isPresent: _includesInstanceProperty(_context = ["mounted", "unmountSuspended"]).call(_context, state),
|
|
123
134
|
ref: React.useCallback(node2 => {
|
|
124
|
-
|
|
135
|
+
if (node2) {
|
|
136
|
+
const styles = getComputedStyle(node2);
|
|
137
|
+
stylesRef.current = styles;
|
|
138
|
+
mountAnimationNameRef.current = getAnimationName(styles);
|
|
139
|
+
} else {
|
|
140
|
+
stylesRef.current = null;
|
|
141
|
+
}
|
|
125
142
|
setNode(node2);
|
|
126
143
|
}, [])
|
|
127
144
|
};
|
|
128
145
|
}
|
|
146
|
+
__name(usePresence, "usePresence");
|
|
147
|
+
function setRef(ref, value) {
|
|
148
|
+
if (typeof ref === "function") {
|
|
149
|
+
return ref(value);
|
|
150
|
+
} else if (ref !== null && ref !== void 0) {
|
|
151
|
+
ref.current = value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
__name(setRef, "setRef");
|
|
155
|
+
function useStableComposedRefs() {
|
|
156
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
157
|
+
refs[_key] = arguments[_key];
|
|
158
|
+
}
|
|
159
|
+
const refsRef = React.useRef(refs);
|
|
160
|
+
refsRef.current = refs;
|
|
161
|
+
return React.useCallback(node => {
|
|
162
|
+
const currentRefs = refsRef.current;
|
|
163
|
+
let hasCleanup = false;
|
|
164
|
+
const cleanups = currentRefs.map(ref => {
|
|
165
|
+
const cleanup = setRef(ref, node);
|
|
166
|
+
if (!hasCleanup && typeof cleanup === "function") {
|
|
167
|
+
hasCleanup = true;
|
|
168
|
+
}
|
|
169
|
+
return cleanup;
|
|
170
|
+
});
|
|
171
|
+
if (hasCleanup) {
|
|
172
|
+
return () => {
|
|
173
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
174
|
+
const cleanup = cleanups[i];
|
|
175
|
+
if (typeof cleanup === "function") {
|
|
176
|
+
cleanup();
|
|
177
|
+
} else {
|
|
178
|
+
setRef(currentRefs[i], null);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}, []);
|
|
184
|
+
}
|
|
185
|
+
__name(useStableComposedRefs, "useStableComposedRefs");
|
|
129
186
|
function getAnimationName(styles) {
|
|
130
187
|
return (styles === null || styles === void 0 ? void 0 : styles.animationName) || "none";
|
|
131
188
|
}
|
|
189
|
+
__name(getAnimationName, "getAnimationName");
|
|
132
190
|
function getElementRef(element) {
|
|
133
191
|
var _Object$getOwnPropert, _Object$getOwnPropert2;
|
|
134
192
|
let getter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(element.props, "ref")) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.get;
|
|
@@ -143,6 +201,6 @@ function getElementRef(element) {
|
|
|
143
201
|
}
|
|
144
202
|
return element.props.ref || element.ref;
|
|
145
203
|
}
|
|
146
|
-
|
|
204
|
+
__name(getElementRef, "getElementRef");
|
|
147
205
|
|
|
148
|
-
export { Presence, Root };
|
|
206
|
+
export { Presence, Presence as Root };
|
|
@@ -3,7 +3,13 @@ import * as React from 'react';
|
|
|
3
3
|
import * as ReactDOM from 'react-dom';
|
|
4
4
|
import { createSlot } from '../../react-slot/dist/index.js';
|
|
5
5
|
|
|
6
|
+
"use client";
|
|
6
7
|
const _excluded = ["asChild"];
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
10
|
+
value,
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
7
13
|
var NODES = ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "select", "span", "svg", "ul"];
|
|
8
14
|
var Primitive = NODES.reduce((primitive, node) => {
|
|
9
15
|
const Slot = createSlot("Primitive.".concat(node));
|
|
@@ -28,6 +34,6 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
28
34
|
function dispatchDiscreteCustomEvent(target, event) {
|
|
29
35
|
if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
__name(dispatchDiscreteCustomEvent, "dispatchDiscreteCustomEvent");
|
|
32
38
|
|
|
33
|
-
export { Primitive, Root, dispatchDiscreteCustomEvent };
|
|
39
|
+
export { Primitive, Primitive as Root, dispatchDiscreteCustomEvent };
|