@radix-ui/react-popper 0.1.5-rc.4 → 0.1.5-rc.42
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -35
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +16 -19
- package/dist/index.module.js.map +1 -1
- package/package.json +12 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import * as ArrowPrimitive from "@radix-ui/react-arrow";
|
|
2
3
|
import * as Radix from "@radix-ui/react-primitive";
|
|
3
4
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
-
import * as ArrowPrimitive from "@radix-ui/react-arrow";
|
|
5
5
|
import { Side, Align } from "@radix-ui/popper";
|
|
6
6
|
import { Measurable } from "@radix-ui/rect";
|
|
7
7
|
export const createPopperScope: import("@radix-ui/react-context").CreateScope;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;
|
|
1
|
+
{"mappings":";;;;;;AAsBA,OAAA,wFAAgF,CAAC;AAQjF;IACE,QAAQ,CAAC,EAAE,MAAM,SAAS,CAAC;CAC5B;AACD,OAAA,MAAM,QAAQ,MAAM,EAAE,CAAC,WAAW,CAQjC,CAAC;AAWF,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,kCAA4B,SAAQ,iBAAiB;IACnD,UAAU,CAAC,EAAE,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,OAAA,MAAM,sGAgBL,CAAC;AAoBF,mCAA6B,SAAQ,iBAAiB;IACpD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,OAAA,MAAM,wGA0EL,CAAC;AAWF,kBAAkB,MAAM,wBAAwB,CAAC,OAAO,eAAe,IAAI,CAAC,CAAC;AAC7E,iCAA2B,SAAQ,UAAU;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,OAAA,MAAM,mGAoCJ,CAAC;AAiCH,OAAA,MAAM,2BAAa,CAAC;AACpB,OAAA,MAAM,gGAAqB,CAAC;AAC5B,OAAA,MAAM,kGAAuB,CAAC;AAC9B,OAAA,MAAM,6FAAmB,CAAC","sources":["packages/react/popper/src/packages/react/popper/src/Popper.tsx","packages/react/popper/src/packages/react/popper/src/index.ts","packages/react/popper/src/index.ts"],"sourcesContent":[null,null,"export {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n} from './Popper';\nexport type {\n PopperProps,\n PopperAnchorProps,\n PopperContentProps,\n PopperArrowProps,\n} from './Popper';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
var $50Iv9$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
2
|
var $50Iv9$react = require("react");
|
|
3
|
-
var $50Iv9$
|
|
3
|
+
var $50Iv9$radixuireactarrow = require("@radix-ui/react-arrow");
|
|
4
4
|
var $50Iv9$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
|
|
5
5
|
var $50Iv9$radixuireactcontext = require("@radix-ui/react-context");
|
|
6
|
+
var $50Iv9$radixuipopper = require("@radix-ui/popper");
|
|
7
|
+
var $50Iv9$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
8
|
+
var $50Iv9$radixuireactuselayouteffect = require("@radix-ui/react-use-layout-effect");
|
|
6
9
|
var $50Iv9$radixuireactuserect = require("@radix-ui/react-use-rect");
|
|
7
10
|
var $50Iv9$radixuireactusesize = require("@radix-ui/react-use-size");
|
|
8
|
-
var $50Iv9$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
9
|
-
var $50Iv9$radixuireactarrow = require("@radix-ui/react-arrow");
|
|
10
|
-
|
|
11
|
-
function $parcel$exportWildcard(dest, source) {
|
|
12
|
-
Object.keys(source).forEach(function(key) {
|
|
13
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
Object.defineProperty(dest, key, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function get() {
|
|
20
|
-
return source[key];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
11
|
|
|
25
|
-
|
|
12
|
+
function $parcel$export(e, n, v, s) {
|
|
13
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
26
14
|
}
|
|
27
15
|
function $parcel$interopDefault(a) {
|
|
28
16
|
return a && a.__esModule ? a.default : a;
|
|
29
17
|
}
|
|
30
|
-
function $parcel$export(e, n, v, s) {
|
|
31
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
32
|
-
}
|
|
33
|
-
var $34310caa050a8d63$exports = {};
|
|
34
18
|
|
|
35
|
-
$parcel$export(
|
|
36
|
-
$parcel$export(
|
|
37
|
-
$parcel$export(
|
|
38
|
-
$parcel$export(
|
|
39
|
-
$parcel$export(
|
|
40
|
-
$parcel$export(
|
|
41
|
-
$parcel$export(
|
|
42
|
-
$parcel$export(
|
|
43
|
-
$parcel$export(
|
|
19
|
+
$parcel$export(module.exports, "createPopperScope", () => $34310caa050a8d63$export$722aac194ae923);
|
|
20
|
+
$parcel$export(module.exports, "Popper", () => $34310caa050a8d63$export$badac9ada3a0bdf9);
|
|
21
|
+
$parcel$export(module.exports, "PopperAnchor", () => $34310caa050a8d63$export$ecd4e1ccab6ed6d);
|
|
22
|
+
$parcel$export(module.exports, "PopperContent", () => $34310caa050a8d63$export$bc4ae5855d3c4fc);
|
|
23
|
+
$parcel$export(module.exports, "PopperArrow", () => $34310caa050a8d63$export$79d62cd4e10a3fd0);
|
|
24
|
+
$parcel$export(module.exports, "Root", () => $34310caa050a8d63$export$be92b6f5f03c0fe9);
|
|
25
|
+
$parcel$export(module.exports, "Anchor", () => $34310caa050a8d63$export$b688253958b8dfe7);
|
|
26
|
+
$parcel$export(module.exports, "Content", () => $34310caa050a8d63$export$7c6e2c02157bb7d2);
|
|
27
|
+
$parcel$export(module.exports, "Arrow", () => $34310caa050a8d63$export$21b07c8f274aebd5);
|
|
28
|
+
|
|
44
29
|
|
|
45
30
|
|
|
46
31
|
|
|
@@ -124,8 +109,17 @@ const $34310caa050a8d63$export$bc4ae5855d3c4fc = /*#__PURE__*/ $50Iv9$react.forw
|
|
|
124
109
|
collisionTolerance: collisionTolerance
|
|
125
110
|
});
|
|
126
111
|
const isPlaced = placedSide !== undefined;
|
|
112
|
+
const [contentZIndex, setContentZIndex] = $50Iv9$react.useState();
|
|
113
|
+
$50Iv9$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
114
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
115
|
+
}, [
|
|
116
|
+
content
|
|
117
|
+
]);
|
|
127
118
|
return /*#__PURE__*/ $50Iv9$react.createElement("div", {
|
|
128
|
-
style:
|
|
119
|
+
style: {
|
|
120
|
+
...popperStyles,
|
|
121
|
+
zIndex: contentZIndex
|
|
122
|
+
},
|
|
129
123
|
"data-radix-popper-content-wrapper": ""
|
|
130
124
|
}, /*#__PURE__*/ $50Iv9$react.createElement($34310caa050a8d63$var$PopperContentProvider, {
|
|
131
125
|
scope: __scopePopper,
|
|
@@ -136,13 +130,13 @@ const $34310caa050a8d63$export$bc4ae5855d3c4fc = /*#__PURE__*/ $50Iv9$react.forw
|
|
|
136
130
|
"data-side": placedSide,
|
|
137
131
|
"data-align": placedAlign
|
|
138
132
|
}, contentProps, {
|
|
133
|
+
ref: composedRefs,
|
|
139
134
|
style: {
|
|
140
135
|
...contentProps.style,
|
|
141
136
|
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
142
137
|
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
143
138
|
animation: !isPlaced ? 'none' : undefined
|
|
144
|
-
}
|
|
145
|
-
ref: composedRefs
|
|
139
|
+
}
|
|
146
140
|
}))));
|
|
147
141
|
});
|
|
148
142
|
/*#__PURE__*/ Object.assign($34310caa050a8d63$export$bc4ae5855d3c4fc, {
|
|
@@ -215,7 +209,6 @@ const $34310caa050a8d63$export$7c6e2c02157bb7d2 = $34310caa050a8d63$export$bc4ae
|
|
|
215
209
|
const $34310caa050a8d63$export$21b07c8f274aebd5 = $34310caa050a8d63$export$79d62cd4e10a3fd0;
|
|
216
210
|
|
|
217
211
|
|
|
218
|
-
$parcel$exportWildcard(module.exports, $34310caa050a8d63$exports);
|
|
219
212
|
|
|
220
213
|
|
|
221
214
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;ACcA;;oGAEA,CAEA,MAAMQ,iCAAW,GAAG,QAApB,AAAA;AAGA,MAAM,CAACC,yCAAD,EAAsBC,uCAAtB,CAAA,GAA2CP,6CAAkB,CAACK,iCAAD,CAAnE,AAAA;AAMA,MAAM,CAACG,oCAAD,EAAiBC,sCAAjB,CAAA,GAAqCH,yCAAmB,CAAqBD,iCAArB,CAA9D,AAAA;AAKA,MAAMK,yCAA6B,GAAIC,CAAAA,KAAD,GAAqC;IACzE,MAAM,E,eAAEC,aAAF,CAAA,E,UAAiBC,QAAAA,CAAAA,EAAjB,GAA8BF,KAApC,AAAM;IACN,MAAM,CAACG,MAAD,EAASC,SAAT,CAAA,GAAsBlB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["export * from './Popper';\n","import * as React from 'react';\nimport { getPlacementData } from '@radix-ui/popper';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as ArrowPrimitive from '@radix-ui/react-arrow';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\nimport type { Side, Align } from '@radix-ui/popper';\nimport type { Measurable } from '@radix-ui/rect';\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper';\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope };\nconst [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);\n\ntype PopperContextValue = {\n anchor: Measurable | null;\n onAnchorChange(anchor: Measurable | null): void;\n};\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME);\n\ninterface PopperProps {\n children?: React.ReactNode;\n}\nconst Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children } = props;\n const [anchor, setAnchor] = React.useState<Measurable | null>(null);\n return (\n <PopperProvider scope={__scopePopper} anchor={anchor} onAnchorChange={setAnchor}>\n {children}\n </PopperProvider>\n );\n};\n\nPopper.displayName = POPPER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor';\n\ntype PopperAnchorElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PopperAnchorProps extends PrimitiveDivProps {\n virtualRef?: React.RefObject<Measurable>;\n}\n\nconst PopperAnchor = React.forwardRef<PopperAnchorElement, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props;\n const context = usePopperContext(ANCHOR_NAME, __scopePopper);\n const ref = React.useRef<PopperAnchorElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n // Consumer can anchor the popper to something that isn't\n // a DOM node e.g. pointer position, so we override the\n // `anchorRef` with their virtual ref in this case.\n context.onAnchorChange(virtualRef?.current || ref.current);\n });\n\n return virtualRef ? null : <Primitive.div {...anchorProps} ref={composedRefs} />;\n }\n);\n\nPopperAnchor.displayName = ANCHOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent';\n\ntype PopperContentContextValue = {\n arrowStyles: React.CSSProperties;\n onArrowChange(arrow: HTMLSpanElement | null): void;\n onArrowOffsetChange(offset?: number): void;\n};\n\nconst [PopperContentProvider, useContentContext] =\n createPopperContext<PopperContentContextValue>(CONTENT_NAME);\n\ntype PopperContentElement = React.ElementRef<typeof Primitive.div>;\ninterface PopperContentProps extends PrimitiveDivProps {\n side?: Side;\n sideOffset?: number;\n align?: Align;\n alignOffset?: number;\n collisionTolerance?: number;\n avoidCollisions?: boolean;\n}\n\nconst PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const {\n __scopePopper,\n side = 'bottom',\n sideOffset,\n align = 'center',\n alignOffset,\n collisionTolerance,\n avoidCollisions = true,\n ...contentProps\n } = props;\n\n const context = usePopperContext(CONTENT_NAME, __scopePopper);\n const [arrowOffset, setArrowOffset] = React.useState<number>();\n const anchorRect = useRect(context.anchor);\n const [content, setContent] = React.useState<HTMLDivElement | null>(null);\n const contentSize = useSize(content);\n const [arrow, setArrow] = React.useState<HTMLSpanElement | null>(null);\n const arrowSize = useSize(arrow);\n\n const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));\n\n const windowSize = useWindowSize();\n const collisionBoundariesRect = windowSize\n ? DOMRect.fromRect({ ...windowSize, x: 0, y: 0 })\n : undefined;\n\n const { popperStyles, arrowStyles, placedSide, placedAlign } = getPlacementData({\n anchorRect,\n popperSize: contentSize,\n arrowSize,\n\n // config\n arrowOffset,\n side,\n sideOffset,\n align,\n alignOffset,\n shouldAvoidCollisions: avoidCollisions,\n collisionBoundariesRect,\n collisionTolerance,\n });\n const isPlaced = placedSide !== undefined;\n\n return (\n <div style={popperStyles} data-radix-popper-content-wrapper=\"\">\n <PopperContentProvider\n scope={__scopePopper}\n arrowStyles={arrowStyles}\n onArrowChange={setArrow}\n onArrowOffsetChange={setArrowOffset}\n >\n <Primitive.div\n data-side={placedSide}\n data-align={placedAlign}\n {...contentProps}\n style={{\n ...contentProps.style,\n // if the PopperContent hasn't been placed yet (not all measurements done)\n // we prevent animations so that users's animation don't kick in too early referring wrong sides\n animation: !isPlaced ? 'none' : undefined,\n }}\n ref={composedRefs}\n />\n </PopperContentProvider>\n </div>\n );\n }\n);\n\nPopperContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow';\n\ntype PopperArrowElement = React.ElementRef<typeof ArrowPrimitive.Root>;\ntype ArrowProps = Radix.ComponentPropsWithoutRef<typeof ArrowPrimitive.Root>;\ninterface PopperArrowProps extends ArrowProps {\n offset?: number;\n}\n\nconst PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(function PopperArrow(\n props: ScopedProps<PopperArrowProps>,\n forwardedRef\n) {\n const { __scopePopper, offset, ...arrowProps } = props;\n const context = useContentContext(ARROW_NAME, __scopePopper);\n const { onArrowOffsetChange } = context;\n\n // send the Arrow's offset up to Popper\n React.useEffect(() => onArrowOffsetChange(offset), [onArrowOffsetChange, offset]);\n\n return (\n <span style={{ ...context.arrowStyles, pointerEvents: 'none' }}>\n <span\n // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)\n // doesn't report size as we'd expect on SVG elements.\n // it reports their bounding box which is effectively the largest path inside the SVG.\n ref={context.onArrowChange}\n style={{\n display: 'inline-block',\n verticalAlign: 'top',\n pointerEvents: 'auto',\n }}\n >\n <ArrowPrimitive.Root\n {...arrowProps}\n ref={forwardedRef}\n style={{\n ...arrowProps.style,\n // ensures the element can be measured correctly (mostly for if SVG)\n display: 'block',\n }}\n />\n </span>\n </span>\n );\n});\n\nPopperArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS = 100;\n\nfunction useWindowSize() {\n const [windowSize, setWindowSize] = React.useState<{ width: number; height: number } | undefined>(\n undefined\n );\n\n React.useEffect(() => {\n let debounceTimerId: number;\n\n function updateWindowSize() {\n setWindowSize({ width: window.innerWidth, height: window.innerHeight });\n }\n\n function handleResize() {\n window.clearTimeout(debounceTimerId);\n debounceTimerId = window.setTimeout(updateWindowSize, WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS);\n }\n\n updateWindowSize();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowSize;\n}\n\nconst Root = Popper;\nconst Anchor = PopperAnchor;\nconst Content = PopperContent;\nconst Arrow = PopperArrow;\n\nexport {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n};\nexport type { PopperProps, PopperAnchorProps, PopperContentProps, PopperArrowProps };\n"],"names":["React","getPlacementData","useComposedRefs","createContextScope","useRect","useSize","Primitive","ArrowPrimitive","POPPER_NAME","createPopperContext","createPopperScope","PopperProvider","usePopperContext","Popper","props","__scopePopper","children","anchor","setAnchor","useState","ANCHOR_NAME","PopperAnchor","forwardRef","forwardedRef","virtualRef","anchorProps","context","ref","useRef","composedRefs","useEffect","onAnchorChange","current","CONTENT_NAME","PopperContentProvider","useContentContext","PopperContent","side","sideOffset","align","alignOffset","collisionTolerance","avoidCollisions","contentProps","arrowOffset","setArrowOffset","anchorRect","content","setContent","contentSize","arrow","setArrow","arrowSize","node","windowSize","useWindowSize","collisionBoundariesRect","DOMRect","fromRect","x","y","undefined","popperStyles","arrowStyles","placedSide","placedAlign","popperSize","shouldAvoidCollisions","isPlaced","style","animation","ARROW_NAME","PopperArrow","offset","arrowProps","onArrowOffsetChange","pointerEvents","onArrowChange","display","verticalAlign","WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS","setWindowSize","debounceTimerId","updateWindowSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","setTimeout","addEventListener","removeEventListener","Root","Anchor","Content","Arrow"],"version":3,"file":"index.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;ACeA;;oGAEA,CAEA,MAAMkB,iCAAW,GAAG,QAApB,AAAA;AAGA,MAAM,CAACC,yCAAD,EAAsBnB,uCAAtB,CAAA,GAA2CY,6CAAkB,CAACM,iCAAD,CAAnE,AAAA;AAMA,MAAM,CAACE,oCAAD,EAAiBC,sCAAjB,CAAA,GAAqCF,yCAAmB,CAAqBD,iCAArB,CAA9D,AAAA;AAKA,MAAMjB,yCAA6B,GAAIqB,CAAAA,KAAD,GAAqC;IACzE,MAAM,E,eAAEC,aAAF,CAAA,E,UAAiBC,QAAAA,CAAAA,EAAjB,GAA8BF,KAApC,AAAM;IACN,MAAM,CAACG,MAAD,EAASC,SAAT,CAAA,GAAsBjB,qBAAA,CAAkC,IAAlC,CAA5B,AAAA;IACA,OAAA,aACE,CAAA,0BAAA,CAAC,oCAAD,EADF;QACkB,KAAK,EAAEc,aAAvB;QAAsC,MAAM,EAAEE,MAA9C;QAAsD,cAAc,EAAEC,SAAhB;KAAtD,EACGF,QADH,CADF,CACE;CAJJ,AAQC;AAED,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,iCAAA;CAAA,CAAA,CAAA;A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x"],"sourcesContent":["export {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n} from './Popper';\nexport type {\n PopperProps,\n PopperAnchorProps,\n PopperContentProps,\n PopperArrowProps,\n} from './Popper';\n","import * as React from 'react';\nimport * as ArrowPrimitive from '@radix-ui/react-arrow';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { getPlacementData } from '@radix-ui/popper';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { useSize } from '@radix-ui/react-use-size';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\nimport type { Side, Align } from '@radix-ui/popper';\nimport type { Measurable } from '@radix-ui/rect';\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper';\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope };\nconst [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);\n\ntype PopperContextValue = {\n anchor: Measurable | null;\n onAnchorChange(anchor: Measurable | null): void;\n};\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME);\n\ninterface PopperProps {\n children?: React.ReactNode;\n}\nconst Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children } = props;\n const [anchor, setAnchor] = React.useState<Measurable | null>(null);\n return (\n <PopperProvider scope={__scopePopper} anchor={anchor} onAnchorChange={setAnchor}>\n {children}\n </PopperProvider>\n );\n};\n\nPopper.displayName = POPPER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor';\n\ntype PopperAnchorElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PopperAnchorProps extends PrimitiveDivProps {\n virtualRef?: React.RefObject<Measurable>;\n}\n\nconst PopperAnchor = React.forwardRef<PopperAnchorElement, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props;\n const context = usePopperContext(ANCHOR_NAME, __scopePopper);\n const ref = React.useRef<PopperAnchorElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n // Consumer can anchor the popper to something that isn't\n // a DOM node e.g. pointer position, so we override the\n // `anchorRef` with their virtual ref in this case.\n context.onAnchorChange(virtualRef?.current || ref.current);\n });\n\n return virtualRef ? null : <Primitive.div {...anchorProps} ref={composedRefs} />;\n }\n);\n\nPopperAnchor.displayName = ANCHOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent';\n\ntype PopperContentContextValue = {\n arrowStyles: React.CSSProperties;\n onArrowChange(arrow: HTMLSpanElement | null): void;\n onArrowOffsetChange(offset?: number): void;\n};\n\nconst [PopperContentProvider, useContentContext] =\n createPopperContext<PopperContentContextValue>(CONTENT_NAME);\n\ntype PopperContentElement = React.ElementRef<typeof Primitive.div>;\ninterface PopperContentProps extends PrimitiveDivProps {\n side?: Side;\n sideOffset?: number;\n align?: Align;\n alignOffset?: number;\n collisionTolerance?: number;\n avoidCollisions?: boolean;\n}\n\nconst PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const {\n __scopePopper,\n side = 'bottom',\n sideOffset,\n align = 'center',\n alignOffset,\n collisionTolerance,\n avoidCollisions = true,\n ...contentProps\n } = props;\n\n const context = usePopperContext(CONTENT_NAME, __scopePopper);\n const [arrowOffset, setArrowOffset] = React.useState<number>();\n const anchorRect = useRect(context.anchor);\n const [content, setContent] = React.useState<HTMLDivElement | null>(null);\n const contentSize = useSize(content);\n const [arrow, setArrow] = React.useState<HTMLSpanElement | null>(null);\n const arrowSize = useSize(arrow);\n\n const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));\n\n const windowSize = useWindowSize();\n const collisionBoundariesRect = windowSize\n ? DOMRect.fromRect({ ...windowSize, x: 0, y: 0 })\n : undefined;\n\n const { popperStyles, arrowStyles, placedSide, placedAlign } = getPlacementData({\n anchorRect,\n popperSize: contentSize,\n arrowSize,\n\n // config\n arrowOffset,\n side,\n sideOffset,\n align,\n alignOffset,\n shouldAvoidCollisions: avoidCollisions,\n collisionBoundariesRect,\n collisionTolerance,\n });\n const isPlaced = placedSide !== undefined;\n\n const [contentZIndex, setContentZIndex] = React.useState<string>();\n useLayoutEffect(() => {\n if (content) setContentZIndex(window.getComputedStyle(content).zIndex);\n }, [content]);\n\n return (\n <div style={{ ...popperStyles, zIndex: contentZIndex }} data-radix-popper-content-wrapper=\"\">\n <PopperContentProvider\n scope={__scopePopper}\n arrowStyles={arrowStyles}\n onArrowChange={setArrow}\n onArrowOffsetChange={setArrowOffset}\n >\n <Primitive.div\n data-side={placedSide}\n data-align={placedAlign}\n {...contentProps}\n ref={composedRefs}\n style={{\n ...contentProps.style,\n // if the PopperContent hasn't been placed yet (not all measurements done)\n // we prevent animations so that users's animation don't kick in too early referring wrong sides\n animation: !isPlaced ? 'none' : undefined,\n }}\n />\n </PopperContentProvider>\n </div>\n );\n }\n);\n\nPopperContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow';\n\ntype PopperArrowElement = React.ElementRef<typeof ArrowPrimitive.Root>;\ntype ArrowProps = Radix.ComponentPropsWithoutRef<typeof ArrowPrimitive.Root>;\ninterface PopperArrowProps extends ArrowProps {\n offset?: number;\n}\n\nconst PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(function PopperArrow(\n props: ScopedProps<PopperArrowProps>,\n forwardedRef\n) {\n const { __scopePopper, offset, ...arrowProps } = props;\n const context = useContentContext(ARROW_NAME, __scopePopper);\n const { onArrowOffsetChange } = context;\n\n // send the Arrow's offset up to Popper\n React.useEffect(() => onArrowOffsetChange(offset), [onArrowOffsetChange, offset]);\n\n return (\n <span style={{ ...context.arrowStyles, pointerEvents: 'none' }}>\n <span\n // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)\n // doesn't report size as we'd expect on SVG elements.\n // it reports their bounding box which is effectively the largest path inside the SVG.\n ref={context.onArrowChange}\n style={{\n display: 'inline-block',\n verticalAlign: 'top',\n pointerEvents: 'auto',\n }}\n >\n <ArrowPrimitive.Root\n {...arrowProps}\n ref={forwardedRef}\n style={{\n ...arrowProps.style,\n // ensures the element can be measured correctly (mostly for if SVG)\n display: 'block',\n }}\n />\n </span>\n </span>\n );\n});\n\nPopperArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS = 100;\n\nfunction useWindowSize() {\n const [windowSize, setWindowSize] = React.useState<{ width: number; height: number } | undefined>(\n undefined\n );\n\n React.useEffect(() => {\n let debounceTimerId: number;\n\n function updateWindowSize() {\n setWindowSize({ width: window.innerWidth, height: window.innerHeight });\n }\n\n function handleResize() {\n window.clearTimeout(debounceTimerId);\n debounceTimerId = window.setTimeout(updateWindowSize, WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS);\n }\n\n updateWindowSize();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowSize;\n}\n\nconst Root = Popper;\nconst Anchor = PopperAnchor;\nconst Content = PopperContent;\nconst Arrow = PopperArrow;\n\nexport {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n};\nexport type { PopperProps, PopperAnchorProps, PopperContentProps, PopperArrowProps };\n"],"names":["createPopperScope","Popper","PopperAnchor","PopperContent","PopperArrow","Root","Anchor","Content","Arrow","React","ArrowPrimitive","useComposedRefs","createContextScope","getPlacementData","Primitive","useLayoutEffect","useRect","useSize","POPPER_NAME","createPopperContext","PopperProvider","usePopperContext","props","__scopePopper","children","anchor","setAnchor","useState","ANCHOR_NAME","forwardRef","forwardedRef","virtualRef","anchorProps","context","ref","useRef","composedRefs","useEffect","onAnchorChange","current","CONTENT_NAME","PopperContentProvider","useContentContext","side","sideOffset","align","alignOffset","collisionTolerance","avoidCollisions","contentProps","arrowOffset","setArrowOffset","anchorRect","content","setContent","contentSize","arrow","setArrow","arrowSize","node","windowSize","useWindowSize","collisionBoundariesRect","DOMRect","fromRect","x","y","undefined","popperStyles","arrowStyles","placedSide","placedAlign","popperSize","shouldAvoidCollisions","isPlaced","contentZIndex","setContentZIndex","window","getComputedStyle","zIndex","style","animation","ARROW_NAME","offset","arrowProps","onArrowOffsetChange","pointerEvents","onArrowChange","display","verticalAlign","WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS","setWindowSize","debounceTimerId","updateWindowSize","width","innerWidth","height","innerHeight","handleResize","clearTimeout","setTimeout","addEventListener","removeEventListener"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import $kY93V$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import {useState as $kY93V$useState, createElement as $kY93V$createElement, forwardRef as $kY93V$forwardRef, useRef as $kY93V$useRef, useEffect as $kY93V$useEffect} from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {Root as $kY93V$Root} from "@radix-ui/react-arrow";
|
|
4
4
|
import {useComposedRefs as $kY93V$useComposedRefs} from "@radix-ui/react-compose-refs";
|
|
5
5
|
import {createContextScope as $kY93V$createContextScope} from "@radix-ui/react-context";
|
|
6
|
+
import {getPlacementData as $kY93V$getPlacementData} from "@radix-ui/popper";
|
|
7
|
+
import {Primitive as $kY93V$Primitive} from "@radix-ui/react-primitive";
|
|
8
|
+
import {useLayoutEffect as $kY93V$useLayoutEffect} from "@radix-ui/react-use-layout-effect";
|
|
6
9
|
import {useRect as $kY93V$useRect} from "@radix-ui/react-use-rect";
|
|
7
10
|
import {useSize as $kY93V$useSize} from "@radix-ui/react-use-size";
|
|
8
|
-
import {Primitive as $kY93V$Primitive} from "@radix-ui/react-primitive";
|
|
9
|
-
import {Root as $kY93V$Root} from "@radix-ui/react-arrow";
|
|
10
11
|
|
|
11
|
-
function $parcel$export(e, n, v, s) {
|
|
12
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
13
|
-
}
|
|
14
|
-
var $cf1ac5d9fe0e8206$exports = {};
|
|
15
12
|
|
|
16
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "createPopperScope", () => $cf1ac5d9fe0e8206$export$722aac194ae923);
|
|
17
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "Popper", () => $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9);
|
|
18
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "PopperAnchor", () => $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d);
|
|
19
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "PopperContent", () => $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc);
|
|
20
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "PopperArrow", () => $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0);
|
|
21
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "Root", () => $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9);
|
|
22
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "Anchor", () => $cf1ac5d9fe0e8206$export$b688253958b8dfe7);
|
|
23
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "Content", () => $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2);
|
|
24
|
-
$parcel$export($cf1ac5d9fe0e8206$exports, "Arrow", () => $cf1ac5d9fe0e8206$export$21b07c8f274aebd5);
|
|
25
13
|
|
|
26
14
|
|
|
27
15
|
|
|
@@ -105,8 +93,17 @@ const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ $kY93V$forwardRef
|
|
|
105
93
|
collisionTolerance: collisionTolerance
|
|
106
94
|
});
|
|
107
95
|
const isPlaced = placedSide !== undefined;
|
|
96
|
+
const [contentZIndex, setContentZIndex] = $kY93V$useState();
|
|
97
|
+
$kY93V$useLayoutEffect(()=>{
|
|
98
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
99
|
+
}, [
|
|
100
|
+
content
|
|
101
|
+
]);
|
|
108
102
|
return /*#__PURE__*/ $kY93V$createElement("div", {
|
|
109
|
-
style:
|
|
103
|
+
style: {
|
|
104
|
+
...popperStyles,
|
|
105
|
+
zIndex: contentZIndex
|
|
106
|
+
},
|
|
110
107
|
"data-radix-popper-content-wrapper": ""
|
|
111
108
|
}, /*#__PURE__*/ $kY93V$createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
|
|
112
109
|
scope: __scopePopper,
|
|
@@ -117,13 +114,13 @@ const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ $kY93V$forwardRef
|
|
|
117
114
|
"data-side": placedSide,
|
|
118
115
|
"data-align": placedAlign
|
|
119
116
|
}, contentProps, {
|
|
117
|
+
ref: composedRefs,
|
|
120
118
|
style: {
|
|
121
119
|
...contentProps.style,
|
|
122
120
|
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
123
121
|
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
124
122
|
animation: !isPlaced ? 'none' : undefined
|
|
125
|
-
}
|
|
126
|
-
ref: composedRefs
|
|
123
|
+
}
|
|
127
124
|
}))));
|
|
128
125
|
});
|
|
129
126
|
/*#__PURE__*/ Object.assign($c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GG,MAAM,CAACM,UAAP,CAAkBR,gBAAlB,EAAoCH,uDAApC,CAAlB,CAAAE;SACD;QAEDC,gBAAgB,EAAhBA,CAAAA;QACAE,MAAM,CAACO,gBAAP,CAAwB,QAAxB,EAAkCH,YAAlC,CAAAJ,CAAAA;QACA,OAAO,IAAMA,MAAM,CAACQ,mBAAP,CAA2B,QAA3B,EAAqCJ,YAArC,CAAb;QAAA,CAAA;KAdF,EAeG,EAfH,CAeC,CAAA;IAED,OAAOnC,UAAP,CAAA;CACD;AAED,MAAMwC,yCAAI,GAAGjF,yCAAb,AAAA;AACA,MAAMkF,yCAAM,GAAG1E,wCAAf,AAAA;AACA,MAAM2E,yCAAO,GAAG5D,wCAAhB,AAAA;AACA,MAAM6D,yCAAK,GAAGzB,yCAAd,AAAA;;ADlQA","sources":["packages/react/popper/src/index.ts","packages/react/popper/src/Popper.tsx"],"sourcesContent":["export * from './Popper';\n","import * as React from 'react';\nimport { getPlacementData } from '@radix-ui/popper';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as ArrowPrimitive from '@radix-ui/react-arrow';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\nimport type { Side, Align } from '@radix-ui/popper';\nimport type { Measurable } from '@radix-ui/rect';\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper';\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope };\nconst [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);\n\ntype PopperContextValue = {\n anchor: Measurable | null;\n onAnchorChange(anchor: Measurable | null): void;\n};\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME);\n\ninterface PopperProps {\n children?: React.ReactNode;\n}\nconst Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children } = props;\n const [anchor, setAnchor] = React.useState<Measurable | null>(null);\n return (\n <PopperProvider scope={__scopePopper} anchor={anchor} onAnchorChange={setAnchor}>\n {children}\n </PopperProvider>\n );\n};\n\nPopper.displayName = POPPER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor';\n\ntype PopperAnchorElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PopperAnchorProps extends PrimitiveDivProps {\n virtualRef?: React.RefObject<Measurable>;\n}\n\nconst PopperAnchor = React.forwardRef<PopperAnchorElement, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props;\n const context = usePopperContext(ANCHOR_NAME, __scopePopper);\n const ref = React.useRef<PopperAnchorElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n // Consumer can anchor the popper to something that isn't\n // a DOM node e.g. pointer position, so we override the\n // `anchorRef` with their virtual ref in this case.\n context.onAnchorChange(virtualRef?.current || ref.current);\n });\n\n return virtualRef ? null : <Primitive.div {...anchorProps} ref={composedRefs} />;\n }\n);\n\nPopperAnchor.displayName = ANCHOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent';\n\ntype PopperContentContextValue = {\n arrowStyles: React.CSSProperties;\n onArrowChange(arrow: HTMLSpanElement | null): void;\n onArrowOffsetChange(offset?: number): void;\n};\n\nconst [PopperContentProvider, useContentContext] =\n createPopperContext<PopperContentContextValue>(CONTENT_NAME);\n\ntype PopperContentElement = React.ElementRef<typeof Primitive.div>;\ninterface PopperContentProps extends PrimitiveDivProps {\n side?: Side;\n sideOffset?: number;\n align?: Align;\n alignOffset?: number;\n collisionTolerance?: number;\n avoidCollisions?: boolean;\n}\n\nconst PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const {\n __scopePopper,\n side = 'bottom',\n sideOffset,\n align = 'center',\n alignOffset,\n collisionTolerance,\n avoidCollisions = true,\n ...contentProps\n } = props;\n\n const context = usePopperContext(CONTENT_NAME, __scopePopper);\n const [arrowOffset, setArrowOffset] = React.useState<number>();\n const anchorRect = useRect(context.anchor);\n const [content, setContent] = React.useState<HTMLDivElement | null>(null);\n const contentSize = useSize(content);\n const [arrow, setArrow] = React.useState<HTMLSpanElement | null>(null);\n const arrowSize = useSize(arrow);\n\n const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));\n\n const windowSize = useWindowSize();\n const collisionBoundariesRect = windowSize\n ? DOMRect.fromRect({ ...windowSize, x: 0, y: 0 })\n : undefined;\n\n const { popperStyles, arrowStyles, placedSide, placedAlign } = getPlacementData({\n anchorRect,\n popperSize: contentSize,\n arrowSize,\n\n // config\n arrowOffset,\n side,\n sideOffset,\n align,\n alignOffset,\n shouldAvoidCollisions: avoidCollisions,\n collisionBoundariesRect,\n collisionTolerance,\n });\n const isPlaced = placedSide !== undefined;\n\n return (\n <div style={popperStyles} data-radix-popper-content-wrapper=\"\">\n <PopperContentProvider\n scope={__scopePopper}\n arrowStyles={arrowStyles}\n onArrowChange={setArrow}\n onArrowOffsetChange={setArrowOffset}\n >\n <Primitive.div\n data-side={placedSide}\n data-align={placedAlign}\n {...contentProps}\n style={{\n ...contentProps.style,\n // if the PopperContent hasn't been placed yet (not all measurements done)\n // we prevent animations so that users's animation don't kick in too early referring wrong sides\n animation: !isPlaced ? 'none' : undefined,\n }}\n ref={composedRefs}\n />\n </PopperContentProvider>\n </div>\n );\n }\n);\n\nPopperContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow';\n\ntype PopperArrowElement = React.ElementRef<typeof ArrowPrimitive.Root>;\ntype ArrowProps = Radix.ComponentPropsWithoutRef<typeof ArrowPrimitive.Root>;\ninterface PopperArrowProps extends ArrowProps {\n offset?: number;\n}\n\nconst PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(function PopperArrow(\n props: ScopedProps<PopperArrowProps>,\n forwardedRef\n) {\n const { __scopePopper, offset, ...arrowProps } = props;\n const context = useContentContext(ARROW_NAME, __scopePopper);\n const { onArrowOffsetChange } = context;\n\n // send the Arrow's offset up to Popper\n React.useEffect(() => onArrowOffsetChange(offset), [onArrowOffsetChange, offset]);\n\n return (\n <span style={{ ...context.arrowStyles, pointerEvents: 'none' }}>\n <span\n // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)\n // doesn't report size as we'd expect on SVG elements.\n // it reports their bounding box which is effectively the largest path inside the SVG.\n ref={context.onArrowChange}\n style={{\n display: 'inline-block',\n verticalAlign: 'top',\n pointerEvents: 'auto',\n }}\n >\n <ArrowPrimitive.Root\n {...arrowProps}\n ref={forwardedRef}\n style={{\n ...arrowProps.style,\n // ensures the element can be measured correctly (mostly for if SVG)\n display: 'block',\n }}\n />\n </span>\n </span>\n );\n});\n\nPopperArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS = 100;\n\nfunction useWindowSize() {\n const [windowSize, setWindowSize] = React.useState<{ width: number; height: number } | undefined>(\n undefined\n );\n\n React.useEffect(() => {\n let debounceTimerId: number;\n\n function updateWindowSize() {\n setWindowSize({ width: window.innerWidth, height: window.innerHeight });\n }\n\n function handleResize() {\n window.clearTimeout(debounceTimerId);\n debounceTimerId = window.setTimeout(updateWindowSize, WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS);\n }\n\n updateWindowSize();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowSize;\n}\n\nconst Root = Popper;\nconst Anchor = PopperAnchor;\nconst Content = PopperContent;\nconst Arrow = PopperArrow;\n\nexport {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n};\nexport type { PopperProps, PopperAnchorProps, PopperContentProps, PopperArrowProps };\n"],"names":["React","getPlacementData","useComposedRefs","createContextScope","useRect","useSize","Primitive","ArrowPrimitive","POPPER_NAME","createPopperContext","createPopperScope","PopperProvider","usePopperContext","Popper","props","__scopePopper","children","anchor","setAnchor","useState","ANCHOR_NAME","PopperAnchor","forwardRef","forwardedRef","virtualRef","anchorProps","context","ref","useRef","composedRefs","useEffect","onAnchorChange","current","CONTENT_NAME","PopperContentProvider","useContentContext","PopperContent","side","sideOffset","align","alignOffset","collisionTolerance","avoidCollisions","contentProps","arrowOffset","setArrowOffset","anchorRect","content","setContent","contentSize","arrow","setArrow","arrowSize","node","windowSize","useWindowSize","collisionBoundariesRect","DOMRect","fromRect","x","y","undefined","popperStyles","arrowStyles","placedSide","placedAlign","popperSize","shouldAvoidCollisions","isPlaced","style","animation","ARROW_NAME","PopperArrow","offset","arrowProps","onArrowOffsetChange","pointerEvents","onArrowChange","display","verticalAlign","WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS","setWindowSize","debounceTimerId","updateWindowSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","setTimeout","addEventListener","removeEventListener","Root","Anchor","Content","Arrow"],"version":3,"file":"index.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;A;;;;;;;;;;ACeA;;oGAEA,CAEA,MAAMkB,iCAAW,GAAG,QAApB,AAAA;AAGA,MAAM,CAACC,yCAAD,EAAsBnB,uCAAtB,CAAA,GAA2CY,yBAAkB,CAACM,iCAAD,CAAnE,AAAA;AAMA,MAAM,CAACE,oCAAD,EAAiBC,sCAAjB,CAAA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,UAAP,CAAkBP,gBAAlB,EAAoCH,uDAApC,CAAlB,CAAAE;SACD;QAEDC,gBAAgB,EAAhBA,CAAAA;QACAhB,MAAM,CAACwB,gBAAP,CAAwB,QAAxB,EAAkCH,YAAlC,CAAArB,CAAAA;QACA,OAAO,IAAMA,MAAM,CAACyB,mBAAP,CAA2B,QAA3B,EAAqCJ,YAArC,CAAb;QAAA,CAAA;KAdF,EAeG,EAfH,CAeC,CAAA;IAED,OAAOtC,UAAP,CAAA;CACD;AAED,MAAMvD,yCAAI,GAAGJ,yCAAb,AAAA;AACA,MAAMK,yCAAM,GAAGJ,wCAAf,AAAA;AACA,MAAMK,yCAAO,GAAGJ,wCAAhB,AAAA;AACA,MAAMK,yCAAK,GAAGJ,yCAAd,AAAA;;ADxQA","sources":["packages/react/popper/src/index.ts","packages/react/popper/src/Popper.tsx"],"sourcesContent":["export {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n} from './Popper';\nexport type {\n PopperProps,\n PopperAnchorProps,\n PopperContentProps,\n PopperArrowProps,\n} from './Popper';\n","import * as React from 'react';\nimport * as ArrowPrimitive from '@radix-ui/react-arrow';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { getPlacementData } from '@radix-ui/popper';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { useSize } from '@radix-ui/react-use-size';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\nimport type { Side, Align } from '@radix-ui/popper';\nimport type { Measurable } from '@radix-ui/rect';\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper';\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope };\nconst [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);\n\ntype PopperContextValue = {\n anchor: Measurable | null;\n onAnchorChange(anchor: Measurable | null): void;\n};\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME);\n\ninterface PopperProps {\n children?: React.ReactNode;\n}\nconst Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children } = props;\n const [anchor, setAnchor] = React.useState<Measurable | null>(null);\n return (\n <PopperProvider scope={__scopePopper} anchor={anchor} onAnchorChange={setAnchor}>\n {children}\n </PopperProvider>\n );\n};\n\nPopper.displayName = POPPER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor';\n\ntype PopperAnchorElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PopperAnchorProps extends PrimitiveDivProps {\n virtualRef?: React.RefObject<Measurable>;\n}\n\nconst PopperAnchor = React.forwardRef<PopperAnchorElement, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props;\n const context = usePopperContext(ANCHOR_NAME, __scopePopper);\n const ref = React.useRef<PopperAnchorElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n // Consumer can anchor the popper to something that isn't\n // a DOM node e.g. pointer position, so we override the\n // `anchorRef` with their virtual ref in this case.\n context.onAnchorChange(virtualRef?.current || ref.current);\n });\n\n return virtualRef ? null : <Primitive.div {...anchorProps} ref={composedRefs} />;\n }\n);\n\nPopperAnchor.displayName = ANCHOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent';\n\ntype PopperContentContextValue = {\n arrowStyles: React.CSSProperties;\n onArrowChange(arrow: HTMLSpanElement | null): void;\n onArrowOffsetChange(offset?: number): void;\n};\n\nconst [PopperContentProvider, useContentContext] =\n createPopperContext<PopperContentContextValue>(CONTENT_NAME);\n\ntype PopperContentElement = React.ElementRef<typeof Primitive.div>;\ninterface PopperContentProps extends PrimitiveDivProps {\n side?: Side;\n sideOffset?: number;\n align?: Align;\n alignOffset?: number;\n collisionTolerance?: number;\n avoidCollisions?: boolean;\n}\n\nconst PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const {\n __scopePopper,\n side = 'bottom',\n sideOffset,\n align = 'center',\n alignOffset,\n collisionTolerance,\n avoidCollisions = true,\n ...contentProps\n } = props;\n\n const context = usePopperContext(CONTENT_NAME, __scopePopper);\n const [arrowOffset, setArrowOffset] = React.useState<number>();\n const anchorRect = useRect(context.anchor);\n const [content, setContent] = React.useState<HTMLDivElement | null>(null);\n const contentSize = useSize(content);\n const [arrow, setArrow] = React.useState<HTMLSpanElement | null>(null);\n const arrowSize = useSize(arrow);\n\n const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));\n\n const windowSize = useWindowSize();\n const collisionBoundariesRect = windowSize\n ? DOMRect.fromRect({ ...windowSize, x: 0, y: 0 })\n : undefined;\n\n const { popperStyles, arrowStyles, placedSide, placedAlign } = getPlacementData({\n anchorRect,\n popperSize: contentSize,\n arrowSize,\n\n // config\n arrowOffset,\n side,\n sideOffset,\n align,\n alignOffset,\n shouldAvoidCollisions: avoidCollisions,\n collisionBoundariesRect,\n collisionTolerance,\n });\n const isPlaced = placedSide !== undefined;\n\n const [contentZIndex, setContentZIndex] = React.useState<string>();\n useLayoutEffect(() => {\n if (content) setContentZIndex(window.getComputedStyle(content).zIndex);\n }, [content]);\n\n return (\n <div style={{ ...popperStyles, zIndex: contentZIndex }} data-radix-popper-content-wrapper=\"\">\n <PopperContentProvider\n scope={__scopePopper}\n arrowStyles={arrowStyles}\n onArrowChange={setArrow}\n onArrowOffsetChange={setArrowOffset}\n >\n <Primitive.div\n data-side={placedSide}\n data-align={placedAlign}\n {...contentProps}\n ref={composedRefs}\n style={{\n ...contentProps.style,\n // if the PopperContent hasn't been placed yet (not all measurements done)\n // we prevent animations so that users's animation don't kick in too early referring wrong sides\n animation: !isPlaced ? 'none' : undefined,\n }}\n />\n </PopperContentProvider>\n </div>\n );\n }\n);\n\nPopperContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow';\n\ntype PopperArrowElement = React.ElementRef<typeof ArrowPrimitive.Root>;\ntype ArrowProps = Radix.ComponentPropsWithoutRef<typeof ArrowPrimitive.Root>;\ninterface PopperArrowProps extends ArrowProps {\n offset?: number;\n}\n\nconst PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(function PopperArrow(\n props: ScopedProps<PopperArrowProps>,\n forwardedRef\n) {\n const { __scopePopper, offset, ...arrowProps } = props;\n const context = useContentContext(ARROW_NAME, __scopePopper);\n const { onArrowOffsetChange } = context;\n\n // send the Arrow's offset up to Popper\n React.useEffect(() => onArrowOffsetChange(offset), [onArrowOffsetChange, offset]);\n\n return (\n <span style={{ ...context.arrowStyles, pointerEvents: 'none' }}>\n <span\n // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)\n // doesn't report size as we'd expect on SVG elements.\n // it reports their bounding box which is effectively the largest path inside the SVG.\n ref={context.onArrowChange}\n style={{\n display: 'inline-block',\n verticalAlign: 'top',\n pointerEvents: 'auto',\n }}\n >\n <ArrowPrimitive.Root\n {...arrowProps}\n ref={forwardedRef}\n style={{\n ...arrowProps.style,\n // ensures the element can be measured correctly (mostly for if SVG)\n display: 'block',\n }}\n />\n </span>\n </span>\n );\n});\n\nPopperArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS = 100;\n\nfunction useWindowSize() {\n const [windowSize, setWindowSize] = React.useState<{ width: number; height: number } | undefined>(\n undefined\n );\n\n React.useEffect(() => {\n let debounceTimerId: number;\n\n function updateWindowSize() {\n setWindowSize({ width: window.innerWidth, height: window.innerHeight });\n }\n\n function handleResize() {\n window.clearTimeout(debounceTimerId);\n debounceTimerId = window.setTimeout(updateWindowSize, WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS);\n }\n\n updateWindowSize();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowSize;\n}\n\nconst Root = Popper;\nconst Anchor = PopperAnchor;\nconst Content = PopperContent;\nconst Arrow = PopperArrow;\n\nexport {\n createPopperScope,\n //\n Popper,\n PopperAnchor,\n PopperContent,\n PopperArrow,\n //\n Root,\n Anchor,\n Content,\n Arrow,\n};\nexport type { PopperProps, PopperAnchorProps, PopperContentProps, PopperArrowProps };\n"],"names":["createPopperScope","Popper","PopperAnchor","PopperContent","PopperArrow","Root","Anchor","Content","Arrow","React","ArrowPrimitive","useComposedRefs","createContextScope","getPlacementData","Primitive","useLayoutEffect","useRect","useSize","POPPER_NAME","createPopperContext","PopperProvider","usePopperContext","props","__scopePopper","children","anchor","setAnchor","useState","ANCHOR_NAME","forwardRef","forwardedRef","virtualRef","anchorProps","context","ref","useRef","composedRefs","useEffect","onAnchorChange","current","CONTENT_NAME","PopperContentProvider","useContentContext","side","sideOffset","align","alignOffset","collisionTolerance","avoidCollisions","contentProps","arrowOffset","setArrowOffset","anchorRect","content","setContent","contentSize","arrow","setArrow","arrowSize","node","windowSize","useWindowSize","collisionBoundariesRect","DOMRect","fromRect","x","y","undefined","popperStyles","arrowStyles","placedSide","placedAlign","popperSize","shouldAvoidCollisions","isPlaced","contentZIndex","setContentZIndex","window","getComputedStyle","zIndex","style","animation","ARROW_NAME","offset","arrowProps","onArrowOffsetChange","pointerEvents","onArrowChange","display","verticalAlign","WINDOW_RESIZE_DEBOUNCE_WAIT_IN_MS","setWindowSize","debounceTimerId","updateWindowSize","width","innerWidth","height","innerHeight","handleResize","clearTimeout","setTimeout","addEventListener","removeEventListener"],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-popper",
|
|
3
|
-
"version": "0.1.5-rc.
|
|
3
|
+
"version": "0.1.5-rc.42",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,17 +17,19 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.13.10",
|
|
20
|
-
"@radix-ui/popper": "0.1.
|
|
21
|
-
"@radix-ui/react-arrow": "0.1.5-rc.
|
|
22
|
-
"@radix-ui/react-compose-refs": "0.1.1-rc.
|
|
23
|
-
"@radix-ui/react-context": "0.1.2-rc.
|
|
24
|
-
"@radix-ui/react-primitive": "0.1.5-rc.
|
|
25
|
-
"@radix-ui/react-use-
|
|
26
|
-
"@radix-ui/react-use-
|
|
27
|
-
"@radix-ui/
|
|
20
|
+
"@radix-ui/popper": "0.1.1-rc.2",
|
|
21
|
+
"@radix-ui/react-arrow": "0.1.5-rc.42",
|
|
22
|
+
"@radix-ui/react-compose-refs": "0.1.1-rc.42",
|
|
23
|
+
"@radix-ui/react-context": "0.1.2-rc.42",
|
|
24
|
+
"@radix-ui/react-primitive": "0.1.5-rc.42",
|
|
25
|
+
"@radix-ui/react-use-layout-effect": "0.1.1-rc.42",
|
|
26
|
+
"@radix-ui/react-use-rect": "0.1.2-rc.42",
|
|
27
|
+
"@radix-ui/react-use-size": "0.1.2-rc.42",
|
|
28
|
+
"@radix-ui/rect": "0.1.2-rc.2"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.8 || ^17.0 || ^18.0"
|
|
31
|
+
"react": "^16.8 || ^17.0 || ^18.0",
|
|
32
|
+
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
31
33
|
},
|
|
32
34
|
"homepage": "https://radix-ui.com/primitives",
|
|
33
35
|
"repository": {
|