@qualtrics/ui-react 2.74.0 → 2.76.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/CHANGELOG.md +18 -0
- package/dist/__node_modules/@radix-ui/primitive/dist/index.js +54 -0
- package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +28 -0
- package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +605 -0
- package/dist/__node_modules/@radix-ui/react-compose-refs/dist/index.js +45 -0
- package/dist/__node_modules/@radix-ui/react-context/dist/index.js +108 -0
- package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +21 -0
- package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +223 -0
- package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +350 -0
- package/dist/__node_modules/@radix-ui/react-focus-guards/dist/index.js +35 -0
- package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +248 -0
- package/dist/__node_modules/@radix-ui/react-id/dist/index.js +15 -0
- package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +911 -0
- package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +325 -0
- package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +25 -0
- package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +141 -0
- package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +34 -0
- package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +216 -0
- package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +127 -0
- package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +18 -0
- package/dist/__node_modules/@radix-ui/react-use-controllable-state/dist/index.js +141 -0
- package/dist/__node_modules/@radix-ui/react-use-effect-event/dist/index.js +32 -0
- package/dist/__node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +23 -0
- package/dist/__node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
- package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +48 -0
- package/dist/__node_modules/aria-hidden/dist/es2015/index.js +169 -0
- package/dist/__node_modules/detect-node-es/esm/node.js +4 -0
- package/dist/__node_modules/get-nonce/dist/es2015/index.js +15 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/SideEffect.js +169 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/UI.js +39 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/index.js +1 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/component.js +57 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/index.js +3 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/component.js +19 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/index.js +3 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
- package/dist/__node_modules/tslib/tslib.es6.js +403 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/createRef.js +25 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/index.js +8 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/mergeRef.js +21 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/refToCallback.js +50 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/transformRef.js +17 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useTransformRef.js +21 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/config.js +8 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/env.js +8 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/exports.js +21 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/hoc.js +18 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/hook.js +44 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/index.js +6 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/medium.js +81 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/renderProp.js +38 -0
- package/dist/__shared/cjs/{index-be619849.js → index-87207072.js} +422 -371
- package/dist/__shared/cjs/{index-97d7b02b.js → index-b569963c.js} +3 -3
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/BreakpointSwitch/BreakpointSwitch.js +3 -2
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/ButtonGroup/ButtonGroup.js +3 -2
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker.js +7 -8
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/Combobox/Combobox.js +9 -8
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxList.js +5 -6
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +10 -9
- package/dist/components/Dropdown/DropdownList.js +6 -7
- 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/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/ConditionSet.js +2 -2
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal.js +4 -2
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +31 -25
- package/dist/components/NewMenu/Menu/Menu.js +1 -0
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +3 -1
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +10 -4
- package/dist/components/NewMenu/parts/MenuItem.js +1 -1
- 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/Popover/Popover.js +8 -14
- package/dist/components/Popover/Popover2.js +3 -3
- 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/TabList.js +3 -2
- package/dist/components/Tabs/TabPanels.js +2 -1
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +6 -12
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +5 -6
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs.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/usePrevious/usePrevious.js +1 -1
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +2 -2
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.es.js +1 -1
- package/dist/index.js +4 -5
- package/dist/next/AdvancedTable/AdvancedTable.js +2 -0
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTablePagination.js +3 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxFlyout.js +6 -6
- package/dist/next/Combobox/ComboboxGroup.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +1 -1
- 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/usePaneSearch.js +1 -1
- package/dist/next/Menu/Menu.js +2 -2
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +1 -1
- package/dist/next/Menu/MenuItem.js +2 -2
- package/dist/next/Menu/MenuPane.js +4 -3
- package/dist/next/Menu/SubMenu.js +8 -6
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +90 -41
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimeDropdown.js +5 -6
- package/dist/next/TimePicker/TimeInput.js +104 -37
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +27 -20
- package/dist/next/index.js +5605 -325
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/GridChildrenWrapper/GridChildrenWrapper.js +2 -1
- package/dist/utils/Popper/Popper.js +162 -114
- package/dist/utils/Portal/Portal.js +3 -2
- package/dist/utils/Text/Text.js +3 -2
- package/dist/utils/filterChildren/filterChildren.js +3 -2
- package/dist/utils/index.js +1 -0
- package/icons/package.json +3 -4
- package/next/package.json +4 -5
- package/package.json +17 -18
- package/dist/__shared/cjs/index-55082bc8.js +0 -13425
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useFloating, autoUpdate, offset, shift, limitShift, flip, size, arrow, hide } from '@floating-ui/react-dom';
|
|
3
|
+
import { Root } from '../../react-arrow/dist/index.js';
|
|
4
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
5
|
+
import { createContextScope } from '../../react-context/dist/index.js';
|
|
6
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
7
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
|
|
8
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
9
|
+
import { useSize } from '../../react-use-size/dist/index.js';
|
|
10
|
+
|
|
11
|
+
"use client";
|
|
12
|
+
var SIDE_OPTIONS = ["top", "right", "bottom", "left"];
|
|
13
|
+
var ALIGN_OPTIONS = ["start", "center", "end"];
|
|
14
|
+
var POPPER_NAME = "Popper";
|
|
15
|
+
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
|
16
|
+
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
17
|
+
var Popper = props => {
|
|
18
|
+
const {
|
|
19
|
+
__scopePopper,
|
|
20
|
+
children
|
|
21
|
+
} = props;
|
|
22
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
23
|
+
return /* @__PURE__ */React.createElement(PopperProvider, {
|
|
24
|
+
scope: __scopePopper,
|
|
25
|
+
anchor,
|
|
26
|
+
onAnchorChange: setAnchor,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Popper.displayName = POPPER_NAME;
|
|
31
|
+
var ANCHOR_NAME = "PopperAnchor";
|
|
32
|
+
var PopperAnchor = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
33
|
+
const {
|
|
34
|
+
__scopePopper,
|
|
35
|
+
virtualRef,
|
|
36
|
+
...anchorProps
|
|
37
|
+
} = props;
|
|
38
|
+
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
39
|
+
const ref = React.useRef(null);
|
|
40
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
41
|
+
const anchorRef = React.useRef(null);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
const previousAnchor = anchorRef.current;
|
|
44
|
+
anchorRef.current = (virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current;
|
|
45
|
+
if (previousAnchor !== anchorRef.current) {
|
|
46
|
+
context.onAnchorChange(anchorRef.current);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return virtualRef ? null : /* @__PURE__ */React.createElement(Primitive.div, {
|
|
50
|
+
...anchorProps,
|
|
51
|
+
ref: composedRefs
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
55
|
+
var CONTENT_NAME = "PopperContent";
|
|
56
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
|
|
57
|
+
var PopperContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
58
|
+
var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
|
|
59
|
+
const {
|
|
60
|
+
__scopePopper,
|
|
61
|
+
side = "bottom",
|
|
62
|
+
sideOffset = 0,
|
|
63
|
+
align = "center",
|
|
64
|
+
alignOffset = 0,
|
|
65
|
+
arrowPadding = 0,
|
|
66
|
+
avoidCollisions = true,
|
|
67
|
+
collisionBoundary = [],
|
|
68
|
+
collisionPadding: collisionPaddingProp = 0,
|
|
69
|
+
sticky = "partial",
|
|
70
|
+
hideWhenDetached = false,
|
|
71
|
+
updatePositionStrategy = "optimized",
|
|
72
|
+
onPlaced,
|
|
73
|
+
...contentProps
|
|
74
|
+
} = props;
|
|
75
|
+
const context = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
76
|
+
const [content, setContent] = React.useState(null);
|
|
77
|
+
const composedRefs = useComposedRefs(forwardedRef, node => setContent(node));
|
|
78
|
+
const [arrow$1, setArrow] = React.useState(null);
|
|
79
|
+
const arrowSize = useSize(arrow$1);
|
|
80
|
+
const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
|
|
81
|
+
const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
|
|
82
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
83
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : {
|
|
84
|
+
top: 0,
|
|
85
|
+
right: 0,
|
|
86
|
+
bottom: 0,
|
|
87
|
+
left: 0,
|
|
88
|
+
...collisionPaddingProp
|
|
89
|
+
};
|
|
90
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
|
91
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
|
92
|
+
const detectOverflowOptions = {
|
|
93
|
+
padding: collisionPadding,
|
|
94
|
+
boundary: boundary.filter(isNotNull),
|
|
95
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
96
|
+
altBoundary: hasExplicitBoundaries
|
|
97
|
+
};
|
|
98
|
+
const {
|
|
99
|
+
refs,
|
|
100
|
+
floatingStyles,
|
|
101
|
+
placement,
|
|
102
|
+
isPositioned,
|
|
103
|
+
middlewareData
|
|
104
|
+
} = useFloating({
|
|
105
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
106
|
+
strategy: "fixed",
|
|
107
|
+
placement: desiredPlacement,
|
|
108
|
+
whileElementsMounted: function () {
|
|
109
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
110
|
+
args[_key] = arguments[_key];
|
|
111
|
+
}
|
|
112
|
+
const cleanup = autoUpdate(...args, {
|
|
113
|
+
animationFrame: updatePositionStrategy === "always"
|
|
114
|
+
});
|
|
115
|
+
return cleanup;
|
|
116
|
+
},
|
|
117
|
+
elements: {
|
|
118
|
+
reference: context.anchor
|
|
119
|
+
},
|
|
120
|
+
middleware: [offset({
|
|
121
|
+
mainAxis: sideOffset + arrowHeight,
|
|
122
|
+
alignmentAxis: alignOffset
|
|
123
|
+
}), avoidCollisions && shift({
|
|
124
|
+
mainAxis: true,
|
|
125
|
+
crossAxis: false,
|
|
126
|
+
limiter: sticky === "partial" ? limitShift() : void 0,
|
|
127
|
+
...detectOverflowOptions
|
|
128
|
+
}), avoidCollisions && flip({
|
|
129
|
+
...detectOverflowOptions
|
|
130
|
+
}), size({
|
|
131
|
+
...detectOverflowOptions,
|
|
132
|
+
apply: _ref => {
|
|
133
|
+
let {
|
|
134
|
+
elements,
|
|
135
|
+
rects,
|
|
136
|
+
availableWidth,
|
|
137
|
+
availableHeight
|
|
138
|
+
} = _ref;
|
|
139
|
+
const {
|
|
140
|
+
width: anchorWidth,
|
|
141
|
+
height: anchorHeight
|
|
142
|
+
} = rects.reference;
|
|
143
|
+
const contentStyle = elements.floating.style;
|
|
144
|
+
contentStyle.setProperty("--radix-popper-available-width", "".concat(availableWidth, "px"));
|
|
145
|
+
contentStyle.setProperty("--radix-popper-available-height", "".concat(availableHeight, "px"));
|
|
146
|
+
contentStyle.setProperty("--radix-popper-anchor-width", "".concat(anchorWidth, "px"));
|
|
147
|
+
contentStyle.setProperty("--radix-popper-anchor-height", "".concat(anchorHeight, "px"));
|
|
148
|
+
}
|
|
149
|
+
}), arrow$1 && arrow({
|
|
150
|
+
element: arrow$1,
|
|
151
|
+
padding: arrowPadding
|
|
152
|
+
}), transformOrigin({
|
|
153
|
+
arrowWidth,
|
|
154
|
+
arrowHeight
|
|
155
|
+
}), hideWhenDetached && hide({
|
|
156
|
+
strategy: "referenceHidden",
|
|
157
|
+
...detectOverflowOptions
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
161
|
+
const handlePlaced = useCallbackRef(onPlaced);
|
|
162
|
+
useLayoutEffect2(() => {
|
|
163
|
+
if (isPositioned) {
|
|
164
|
+
handlePlaced === null || handlePlaced === void 0 || handlePlaced();
|
|
165
|
+
}
|
|
166
|
+
}, [isPositioned, handlePlaced]);
|
|
167
|
+
const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
|
|
168
|
+
const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
|
|
169
|
+
const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
|
|
170
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
|
171
|
+
useLayoutEffect2(() => {
|
|
172
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
173
|
+
}, [content]);
|
|
174
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
175
|
+
ref: refs.setFloating,
|
|
176
|
+
"data-radix-popper-content-wrapper": "",
|
|
177
|
+
style: {
|
|
178
|
+
...floatingStyles,
|
|
179
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
180
|
+
// keep off the page when measuring
|
|
181
|
+
minWidth: "max-content",
|
|
182
|
+
zIndex: contentZIndex,
|
|
183
|
+
["--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(" "),
|
|
184
|
+
// hide the content if using the hide middleware and should be hidden
|
|
185
|
+
// set visibility to hidden and disable pointer events so the UI behaves
|
|
186
|
+
// as if the PopperContent isn't there at all
|
|
187
|
+
...(((_middlewareData$hide = middlewareData.hide) === null || _middlewareData$hide === void 0 ? void 0 : _middlewareData$hide.referenceHidden) && {
|
|
188
|
+
visibility: "hidden",
|
|
189
|
+
pointerEvents: "none"
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
dir: props.dir,
|
|
193
|
+
children: /* @__PURE__ */React.createElement(PopperContentProvider, {
|
|
194
|
+
scope: __scopePopper,
|
|
195
|
+
placedSide,
|
|
196
|
+
onArrowChange: setArrow,
|
|
197
|
+
arrowX,
|
|
198
|
+
arrowY,
|
|
199
|
+
shouldHideArrow: cannotCenterArrow,
|
|
200
|
+
children: /* @__PURE__ */React.createElement(Primitive.div, {
|
|
201
|
+
"data-side": placedSide,
|
|
202
|
+
"data-align": placedAlign,
|
|
203
|
+
...contentProps,
|
|
204
|
+
ref: composedRefs,
|
|
205
|
+
style: {
|
|
206
|
+
...contentProps.style,
|
|
207
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
208
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
209
|
+
animation: !isPositioned ? "none" : void 0
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
PopperContent.displayName = CONTENT_NAME;
|
|
216
|
+
var ARROW_NAME = "PopperArrow";
|
|
217
|
+
var OPPOSITE_SIDE = {
|
|
218
|
+
top: "bottom",
|
|
219
|
+
right: "left",
|
|
220
|
+
bottom: "top",
|
|
221
|
+
left: "right"
|
|
222
|
+
};
|
|
223
|
+
var PopperArrow = /*#__PURE__*/React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
224
|
+
const {
|
|
225
|
+
__scopePopper,
|
|
226
|
+
...arrowProps
|
|
227
|
+
} = props;
|
|
228
|
+
const contentContext = useContentContext(ARROW_NAME, __scopePopper);
|
|
229
|
+
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
|
230
|
+
return (// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
231
|
+
// doesn't report size as we'd expect on SVG elements.
|
|
232
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
233
|
+
/* @__PURE__ */
|
|
234
|
+
React.createElement("span", {
|
|
235
|
+
ref: contentContext.onArrowChange,
|
|
236
|
+
style: {
|
|
237
|
+
position: "absolute",
|
|
238
|
+
left: contentContext.arrowX,
|
|
239
|
+
top: contentContext.arrowY,
|
|
240
|
+
[baseSide]: 0,
|
|
241
|
+
transformOrigin: {
|
|
242
|
+
top: "",
|
|
243
|
+
right: "0 0",
|
|
244
|
+
bottom: "center 0",
|
|
245
|
+
left: "100% 0"
|
|
246
|
+
}[contentContext.placedSide],
|
|
247
|
+
transform: {
|
|
248
|
+
top: "translateY(100%)",
|
|
249
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
250
|
+
bottom: "rotate(180deg)",
|
|
251
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
252
|
+
}[contentContext.placedSide],
|
|
253
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
254
|
+
},
|
|
255
|
+
children: /* @__PURE__ */React.createElement(Root, {
|
|
256
|
+
...arrowProps,
|
|
257
|
+
ref: forwardedRef,
|
|
258
|
+
style: {
|
|
259
|
+
...arrowProps.style,
|
|
260
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
|
261
|
+
display: "block"
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
PopperArrow.displayName = ARROW_NAME;
|
|
268
|
+
function isNotNull(value) {
|
|
269
|
+
return value !== null;
|
|
270
|
+
}
|
|
271
|
+
var transformOrigin = options => ({
|
|
272
|
+
name: "transformOrigin",
|
|
273
|
+
options,
|
|
274
|
+
fn(data) {
|
|
275
|
+
var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
|
|
276
|
+
const {
|
|
277
|
+
placement,
|
|
278
|
+
rects,
|
|
279
|
+
middlewareData
|
|
280
|
+
} = data;
|
|
281
|
+
const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
|
|
282
|
+
const isArrowHidden = cannotCenterArrow;
|
|
283
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
|
284
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
285
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
286
|
+
const noArrowAlign = {
|
|
287
|
+
start: "0%",
|
|
288
|
+
center: "50%",
|
|
289
|
+
end: "100%"
|
|
290
|
+
}[placedAlign];
|
|
291
|
+
const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
|
|
292
|
+
const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
|
|
293
|
+
let x = "";
|
|
294
|
+
let y = "";
|
|
295
|
+
if (placedSide === "bottom") {
|
|
296
|
+
x = isArrowHidden ? noArrowAlign : "".concat(arrowXCenter, "px");
|
|
297
|
+
y = "".concat(-arrowHeight, "px");
|
|
298
|
+
} else if (placedSide === "top") {
|
|
299
|
+
x = isArrowHidden ? noArrowAlign : "".concat(arrowXCenter, "px");
|
|
300
|
+
y = "".concat(rects.floating.height + arrowHeight, "px");
|
|
301
|
+
} else if (placedSide === "right") {
|
|
302
|
+
x = "".concat(-arrowHeight, "px");
|
|
303
|
+
y = isArrowHidden ? noArrowAlign : "".concat(arrowYCenter, "px");
|
|
304
|
+
} else if (placedSide === "left") {
|
|
305
|
+
x = "".concat(rects.floating.width + arrowHeight, "px");
|
|
306
|
+
y = isArrowHidden ? noArrowAlign : "".concat(arrowYCenter, "px");
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
data: {
|
|
310
|
+
x,
|
|
311
|
+
y
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
function getSideAndAlignFromPlacement(placement) {
|
|
317
|
+
const [side, align = "center"] = placement.split("-");
|
|
318
|
+
return [side, align];
|
|
319
|
+
}
|
|
320
|
+
var Root2 = Popper;
|
|
321
|
+
var Anchor = PopperAnchor;
|
|
322
|
+
var Content = PopperContent;
|
|
323
|
+
var Arrow = PopperArrow;
|
|
324
|
+
|
|
325
|
+
export { ALIGN_OPTIONS, Anchor, Arrow, Content, Popper, PopperAnchor, PopperArrow, PopperContent, Root2 as Root, SIDE_OPTIONS, createPopperScope };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ReactDOM__default from 'react-dom';
|
|
3
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
4
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
5
|
+
|
|
6
|
+
"use client";
|
|
7
|
+
var PORTAL_NAME = "Portal";
|
|
8
|
+
var Portal = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
9
|
+
var _globalThis$document;
|
|
10
|
+
const {
|
|
11
|
+
container: containerProp,
|
|
12
|
+
...portalProps
|
|
13
|
+
} = props;
|
|
14
|
+
const [mounted, setMounted] = React.useState(false);
|
|
15
|
+
useLayoutEffect2(() => setMounted(true), []);
|
|
16
|
+
const container = containerProp || mounted && (globalThis === null || globalThis === void 0 || (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body);
|
|
17
|
+
return container ? /*#__PURE__*/ReactDOM__default.createPortal(/* @__PURE__ */React.createElement(Primitive.div, {
|
|
18
|
+
...portalProps,
|
|
19
|
+
ref: forwardedRef
|
|
20
|
+
}), container) : null;
|
|
21
|
+
});
|
|
22
|
+
Portal.displayName = PORTAL_NAME;
|
|
23
|
+
var Root = Portal;
|
|
24
|
+
|
|
25
|
+
export { Portal, Root };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
3
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
4
|
+
|
|
5
|
+
"use client";
|
|
6
|
+
function useStateMachine(initialState, machine) {
|
|
7
|
+
return React.useReducer((state, event) => {
|
|
8
|
+
const nextState = machine[state][event];
|
|
9
|
+
return nextState !== null && nextState !== void 0 ? nextState : state;
|
|
10
|
+
}, initialState);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/presence.tsx
|
|
14
|
+
var Presence = props => {
|
|
15
|
+
const {
|
|
16
|
+
present,
|
|
17
|
+
children
|
|
18
|
+
} = props;
|
|
19
|
+
const presence = usePresence(present);
|
|
20
|
+
const child = typeof children === "function" ? children({
|
|
21
|
+
present: presence.isPresent
|
|
22
|
+
}) : React.Children.only(children);
|
|
23
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
24
|
+
const forceMount = typeof children === "function";
|
|
25
|
+
return forceMount || presence.isPresent ? /*#__PURE__*/React.cloneElement(child, {
|
|
26
|
+
ref
|
|
27
|
+
}) : null;
|
|
28
|
+
};
|
|
29
|
+
Presence.displayName = "Presence";
|
|
30
|
+
function usePresence(present) {
|
|
31
|
+
const [node, setNode] = React.useState();
|
|
32
|
+
const stylesRef = React.useRef(null);
|
|
33
|
+
const prevPresentRef = React.useRef(present);
|
|
34
|
+
const prevAnimationNameRef = React.useRef("none");
|
|
35
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
36
|
+
const [state, send] = useStateMachine(initialState, {
|
|
37
|
+
mounted: {
|
|
38
|
+
UNMOUNT: "unmounted",
|
|
39
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
40
|
+
},
|
|
41
|
+
unmountSuspended: {
|
|
42
|
+
MOUNT: "mounted",
|
|
43
|
+
ANIMATION_END: "unmounted"
|
|
44
|
+
},
|
|
45
|
+
unmounted: {
|
|
46
|
+
MOUNT: "mounted"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
51
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
52
|
+
}, [state]);
|
|
53
|
+
useLayoutEffect2(() => {
|
|
54
|
+
const styles = stylesRef.current;
|
|
55
|
+
const wasPresent = prevPresentRef.current;
|
|
56
|
+
const hasPresentChanged = wasPresent !== present;
|
|
57
|
+
if (hasPresentChanged) {
|
|
58
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
59
|
+
const currentAnimationName = getAnimationName(styles);
|
|
60
|
+
if (present) {
|
|
61
|
+
send("MOUNT");
|
|
62
|
+
} else if (currentAnimationName === "none" || (styles === null || styles === void 0 ? void 0 : styles.display) === "none") {
|
|
63
|
+
send("UNMOUNT");
|
|
64
|
+
} else {
|
|
65
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
66
|
+
if (wasPresent && isAnimating) {
|
|
67
|
+
send("ANIMATION_OUT");
|
|
68
|
+
} else {
|
|
69
|
+
send("UNMOUNT");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
prevPresentRef.current = present;
|
|
73
|
+
}
|
|
74
|
+
}, [present, send]);
|
|
75
|
+
useLayoutEffect2(() => {
|
|
76
|
+
if (node) {
|
|
77
|
+
var _node$ownerDocument$d;
|
|
78
|
+
let timeoutId;
|
|
79
|
+
const ownerWindow = (_node$ownerDocument$d = node.ownerDocument.defaultView) !== null && _node$ownerDocument$d !== void 0 ? _node$ownerDocument$d : window;
|
|
80
|
+
const handleAnimationEnd = event => {
|
|
81
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
82
|
+
const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
|
|
83
|
+
if (event.target === node && isCurrentAnimation) {
|
|
84
|
+
send("ANIMATION_END");
|
|
85
|
+
if (!prevPresentRef.current) {
|
|
86
|
+
const currentFillMode = node.style.animationFillMode;
|
|
87
|
+
node.style.animationFillMode = "forwards";
|
|
88
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
89
|
+
if (node.style.animationFillMode === "forwards") {
|
|
90
|
+
node.style.animationFillMode = currentFillMode;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const handleAnimationStart = event => {
|
|
97
|
+
if (event.target === node) {
|
|
98
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
102
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
103
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
104
|
+
return () => {
|
|
105
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
106
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
107
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
108
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
send("ANIMATION_END");
|
|
112
|
+
}
|
|
113
|
+
}, [node, send]);
|
|
114
|
+
return {
|
|
115
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
116
|
+
ref: React.useCallback(node2 => {
|
|
117
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
118
|
+
setNode(node2);
|
|
119
|
+
}, [])
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function getAnimationName(styles) {
|
|
123
|
+
return (styles === null || styles === void 0 ? void 0 : styles.animationName) || "none";
|
|
124
|
+
}
|
|
125
|
+
function getElementRef(element) {
|
|
126
|
+
var _Object$getOwnPropert, _Object$getOwnPropert2;
|
|
127
|
+
let getter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(element.props, "ref")) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.get;
|
|
128
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
129
|
+
if (mayWarn) {
|
|
130
|
+
return element.ref;
|
|
131
|
+
}
|
|
132
|
+
getter = (_Object$getOwnPropert2 = Object.getOwnPropertyDescriptor(element, "ref")) === null || _Object$getOwnPropert2 === void 0 ? void 0 : _Object$getOwnPropert2.get;
|
|
133
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
134
|
+
if (mayWarn) {
|
|
135
|
+
return element.props.ref;
|
|
136
|
+
}
|
|
137
|
+
return element.props.ref || element.ref;
|
|
138
|
+
}
|
|
139
|
+
var Root = Presence;
|
|
140
|
+
|
|
141
|
+
export { Presence, Root };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { createSlot } from '../../react-slot/dist/index.js';
|
|
4
|
+
|
|
5
|
+
// src/primitive.tsx
|
|
6
|
+
var NODES = ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "select", "span", "svg", "ul"];
|
|
7
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
8
|
+
const Slot = createSlot("Primitive.".concat(node));
|
|
9
|
+
const Node = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
10
|
+
const {
|
|
11
|
+
asChild,
|
|
12
|
+
...primitiveProps
|
|
13
|
+
} = props;
|
|
14
|
+
const Comp = asChild ? Slot : node;
|
|
15
|
+
if (typeof window !== "undefined") {
|
|
16
|
+
window[Symbol.for("radix-ui")] = true;
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */React.createElement(Comp, {
|
|
19
|
+
...primitiveProps,
|
|
20
|
+
ref: forwardedRef
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
Node.displayName = "Primitive.".concat(node);
|
|
24
|
+
return {
|
|
25
|
+
...primitive,
|
|
26
|
+
[node]: Node
|
|
27
|
+
};
|
|
28
|
+
}, {});
|
|
29
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
30
|
+
if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
31
|
+
}
|
|
32
|
+
var Root = Primitive;
|
|
33
|
+
|
|
34
|
+
export { Primitive, Root, dispatchDiscreteCustomEvent };
|