@tamagui/popper 1.0.0-beta.10
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/cjs/Popper.js +233 -0
- package/dist/cjs/Popper.js.map +7 -0
- package/dist/cjs/floating.js +18 -0
- package/dist/cjs/floating.js.map +7 -0
- package/dist/cjs/floating.native.js +18 -0
- package/dist/cjs/floating.native.js.map +7 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/useFloating.js +41 -0
- package/dist/cjs/useFloating.js.map +7 -0
- package/dist/esm/Popper.js +193 -0
- package/dist/esm/Popper.js.map +7 -0
- package/dist/esm/floating.js +2 -0
- package/dist/esm/floating.js.map +7 -0
- package/dist/esm/floating.native.js +2 -0
- package/dist/esm/floating.native.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/useFloating.js +15 -0
- package/dist/esm/useFloating.js.map +7 -0
- package/dist/jsx/Popper.js +164 -0
- package/dist/jsx/floating.js +1 -0
- package/dist/jsx/floating.native.js +1 -0
- package/dist/jsx/index.js +6 -0
- package/dist/jsx/useFloating.js +14 -0
- package/package.json +44 -0
- package/types/Popper.d.ts +94 -0
- package/types/Popper.d.ts.map +1 -0
- package/types/floating.d.ts +2 -0
- package/types/floating.d.ts.map +1 -0
- package/types/floating.native.d.ts +2 -0
- package/types/floating.native.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/useFloating.d.ts +18 -0
- package/types/useFloating.d.ts.map +1 -0
- package/types/useFloating.native.d.ts +2 -0
- package/types/useFloating.native.d.ts.map +1 -0
- package/types/useFloating.web.d.ts +2 -0
- package/types/useFloating.web.d.ts.map +1 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
50
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
51
|
+
var Popper_exports = {};
|
|
52
|
+
__export(Popper_exports, {
|
|
53
|
+
Popper: () => Popper,
|
|
54
|
+
PopperAnchor: () => PopperAnchor,
|
|
55
|
+
PopperArrow: () => PopperArrow,
|
|
56
|
+
PopperContent: () => PopperContent,
|
|
57
|
+
createPopperScope: () => createPopperScope
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(Popper_exports);
|
|
60
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
61
|
+
var import_core = require("@tamagui/core");
|
|
62
|
+
var import_create_context = require("@tamagui/create-context");
|
|
63
|
+
var import_stacks = require("@tamagui/stacks");
|
|
64
|
+
var React = __toESM(require("react"));
|
|
65
|
+
var import_floating = require("./floating");
|
|
66
|
+
var import_useFloating = require("./useFloating");
|
|
67
|
+
const POPPER_NAME = "Popper";
|
|
68
|
+
const [createPopperContext, createScope] = (0, import_create_context.createContextScope)(POPPER_NAME);
|
|
69
|
+
const createPopperScope = createScope;
|
|
70
|
+
const [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
71
|
+
const Popper = /* @__PURE__ */ __name((props) => {
|
|
72
|
+
const { __scopePopper, children, size, placement = "bottom", stayInFrame, allowFlip } = props;
|
|
73
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
74
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
75
|
+
setIsMounted(true);
|
|
76
|
+
}, []);
|
|
77
|
+
const anchorRef = React.useRef();
|
|
78
|
+
const [arrowEl, setArrow] = React.useState(null);
|
|
79
|
+
const [arrowSize, setArrowSize] = React.useState(0);
|
|
80
|
+
const arrowRef = React.useRef();
|
|
81
|
+
const floating = (0, import_useFloating.useFloating)({
|
|
82
|
+
placement,
|
|
83
|
+
middleware: [
|
|
84
|
+
stayInFrame ? (0, import_floating.shift)(stayInFrame) : null,
|
|
85
|
+
allowFlip ? (0, import_floating.flip)(allowFlip) : null,
|
|
86
|
+
arrowEl ? (0, import_floating.arrow)({ element: arrowEl }) : null,
|
|
87
|
+
arrowSize ? (0, import_floating.offset)(arrowSize) : null
|
|
88
|
+
].filter(Boolean)
|
|
89
|
+
});
|
|
90
|
+
const { refs, middlewareData } = floating;
|
|
91
|
+
const composedArrowRefs = (0, import_compose_refs.useComposedRefs)(arrowRef, setArrow);
|
|
92
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
93
|
+
floating.reference(anchorRef.current);
|
|
94
|
+
}, [anchorRef]);
|
|
95
|
+
React.useEffect(() => {
|
|
96
|
+
if (!refs.reference.current || !refs.floating.current) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
return (0, import_floating.autoUpdate)(refs.reference.current, refs.floating.current, floating.update);
|
|
100
|
+
}, [refs.floating.current, refs.reference.current]);
|
|
101
|
+
const arrowStyle = React.useMemo(() => {
|
|
102
|
+
return middlewareData.arrow;
|
|
103
|
+
}, [JSON.stringify(middlewareData.arrow || {})]);
|
|
104
|
+
return /* @__PURE__ */ React.createElement(PopperProvider, __spreadValues({
|
|
105
|
+
scope: __scopePopper,
|
|
106
|
+
anchorRef,
|
|
107
|
+
size,
|
|
108
|
+
arrowRef: composedArrowRefs,
|
|
109
|
+
arrowStyle,
|
|
110
|
+
onArrowSize: setArrowSize,
|
|
111
|
+
isMounted
|
|
112
|
+
}, floating), children);
|
|
113
|
+
}, "Popper");
|
|
114
|
+
Popper.displayName = POPPER_NAME;
|
|
115
|
+
const ANCHOR_NAME = "PopperAnchor";
|
|
116
|
+
const PopperAnchor = React.forwardRef((props, forwardedRef) => {
|
|
117
|
+
const _a = props, { __scopePopper, virtualRef } = _a, anchorProps = __objRest(_a, ["__scopePopper", "virtualRef"]);
|
|
118
|
+
const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
119
|
+
const ref = React.useRef(null);
|
|
120
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, anchorRef);
|
|
121
|
+
if (virtualRef) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const stackProps = __spreadValues({
|
|
125
|
+
ref: composedRefs
|
|
126
|
+
}, anchorProps);
|
|
127
|
+
return /* @__PURE__ */ React.createElement(import_stacks.YStack, __spreadValues({}, getReferenceProps ? getReferenceProps(stackProps) : stackProps));
|
|
128
|
+
});
|
|
129
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
130
|
+
const CONTENT_NAME = "PopperContent";
|
|
131
|
+
const PopperContentFrame = (0, import_core.styled)(import_stacks.SizableStack, {
|
|
132
|
+
name: "PopperContent",
|
|
133
|
+
backgroundColor: "$background",
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
defaultVariants: {
|
|
136
|
+
size: "$4"
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const PopperContent = React.forwardRef((props, forwardedRef) => {
|
|
140
|
+
const _a = props, { __scopePopper } = _a, contentProps = __objRest(_a, ["__scopePopper"]);
|
|
141
|
+
const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
142
|
+
const contentRefs = (0, import_compose_refs.useComposedRefs)(floating, forwardedRef);
|
|
143
|
+
const contents = React.useMemo(() => {
|
|
144
|
+
return /* @__PURE__ */ React.createElement(PopperContentFrame, __spreadProps(__spreadValues({
|
|
145
|
+
key: "popper-content-frame",
|
|
146
|
+
"data-placement": placement,
|
|
147
|
+
"data-strategy": strategy
|
|
148
|
+
}, contentProps), {
|
|
149
|
+
size: contentProps.size ?? size
|
|
150
|
+
}));
|
|
151
|
+
}, [placement, strategy, props]);
|
|
152
|
+
if (!isMounted) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const frameProps = {
|
|
156
|
+
ref: contentRefs,
|
|
157
|
+
x: x || 0,
|
|
158
|
+
y: y || 0,
|
|
159
|
+
position: "absolute"
|
|
160
|
+
};
|
|
161
|
+
return /* @__PURE__ */ React.createElement(import_stacks.YStack, __spreadValues({}, getFloatingProps ? getFloatingProps(frameProps) : frameProps), contents);
|
|
162
|
+
});
|
|
163
|
+
PopperContent.displayName = CONTENT_NAME;
|
|
164
|
+
const ARROW_NAME = "PopperArrow";
|
|
165
|
+
const PopperArrowFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
166
|
+
name: "PopperArrow",
|
|
167
|
+
borderColor: "$borderColor",
|
|
168
|
+
backgroundColor: "$background",
|
|
169
|
+
position: "absolute",
|
|
170
|
+
zIndex: 1
|
|
171
|
+
});
|
|
172
|
+
const opposites = {
|
|
173
|
+
top: "bottom",
|
|
174
|
+
right: "left",
|
|
175
|
+
bottom: "top",
|
|
176
|
+
left: "right"
|
|
177
|
+
};
|
|
178
|
+
const PopperArrow = React.forwardRef(/* @__PURE__ */ __name(function PopperArrow2(props, forwardedRef) {
|
|
179
|
+
const _a = props, { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0 } = _a, arrowProps = __objRest(_a, ["__scopePopper", "offset", "size", "borderWidth"]);
|
|
180
|
+
const context = usePopperContext(ARROW_NAME, __scopePopper);
|
|
181
|
+
const tokens = (0, import_core.getTokens)();
|
|
182
|
+
const sizeVal = sizeProp ?? context.size;
|
|
183
|
+
const sizeValResolved = (0, import_core.getVariableValue)(tokens.size[sizeVal] ?? sizeVal ?? 12);
|
|
184
|
+
const size = +sizeValResolved;
|
|
185
|
+
const { placement } = context;
|
|
186
|
+
const { x, y } = context.arrowStyle || { x: 0, y: 0 };
|
|
187
|
+
const refs = (0, import_compose_refs.useComposedRefs)(context.arrowRef, forwardedRef);
|
|
188
|
+
const primaryPlacement = placement ? placement.split("-")[0] : "top";
|
|
189
|
+
let arrowStyle = { x, y, width: size, height: size };
|
|
190
|
+
if (primaryPlacement) {
|
|
191
|
+
const oppSide = opposites[primaryPlacement];
|
|
192
|
+
if (oppSide) {
|
|
193
|
+
arrowStyle[oppSide] = -size / 2;
|
|
194
|
+
}
|
|
195
|
+
if (oppSide === "top" || oppSide === "bottom") {
|
|
196
|
+
arrowStyle.left = 0;
|
|
197
|
+
}
|
|
198
|
+
if (oppSide === "left" || oppSide === "right") {
|
|
199
|
+
arrowStyle.top = 0;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
203
|
+
var _a2;
|
|
204
|
+
(_a2 = context.onArrowSize) == null ? void 0 : _a2.call(context, size);
|
|
205
|
+
}, [size, context.onArrowSize]);
|
|
206
|
+
return /* @__PURE__ */ React.createElement(PopperArrowFrame, __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, arrowProps), {
|
|
207
|
+
ref: refs
|
|
208
|
+
}), arrowStyle), {
|
|
209
|
+
rotate: "45deg"
|
|
210
|
+
}), primaryPlacement === "top" && {
|
|
211
|
+
borderBottomWidth: borderWidth,
|
|
212
|
+
borderRightWidth: borderWidth
|
|
213
|
+
}), primaryPlacement === "bottom" && {
|
|
214
|
+
borderTopWidth: borderWidth,
|
|
215
|
+
borderLeftWidth: borderWidth
|
|
216
|
+
}), primaryPlacement === "left" && {
|
|
217
|
+
borderTopWidth: borderWidth,
|
|
218
|
+
borderRightWidth: borderWidth
|
|
219
|
+
}), primaryPlacement === "right" && {
|
|
220
|
+
borderBottomWidth: borderWidth,
|
|
221
|
+
borderLeftWidth: borderWidth
|
|
222
|
+
}));
|
|
223
|
+
}, "PopperArrow"));
|
|
224
|
+
PopperArrow.displayName = ARROW_NAME;
|
|
225
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
226
|
+
0 && (module.exports = {
|
|
227
|
+
Popper,
|
|
228
|
+
PopperAnchor,
|
|
229
|
+
PopperArrow,
|
|
230
|
+
PopperContent,
|
|
231
|
+
createPopperScope
|
|
232
|
+
});
|
|
233
|
+
//# sourceMappingURL=Popper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Popper.tsx"],
|
|
4
|
+
"sourcesContent": ["// adapted from radix-ui popper\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n SizeTokens,\n StackProps,\n getTokens,\n getVariableValue,\n styled,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { SizableStack, SizableStackProps, YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nimport { Coords, Placement, arrow, autoUpdate, flip, offset, shift } from './floating'\nimport { UseFloatingResult, useFloating } from './useFloating'\n\ntype ShiftProps = typeof shift extends (options: infer Opts) => void ? Opts : never\ntype FlipProps = typeof flip extends (options: infer Opts) => void ? Opts : never\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper'\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope }\nconst [createPopperContext, createScope] = createContextScope(POPPER_NAME)\n\nexport const createPopperScope = createScope\n\ntype PopperContextValue = UseFloatingResult & {\n isMounted: boolean\n anchorRef: any\n size?: SizeTokens\n placement?: Placement\n arrowRef: any\n onArrowSize?: (val: number) => void\n arrowStyle?: Partial<Coords> & {\n centerOffset: number\n }\n}\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME)\n\nexport type PopperProps = {\n size?: SizeTokens\n children?: React.ReactNode\n placement?: Placement\n stayInFrame?: ShiftProps\n allowFlip?: FlipProps\n}\n\nexport const Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children, size, placement = 'bottom', stayInFrame, allowFlip } = props\n\n const [isMounted, setIsMounted] = React.useState(false)\n useIsomorphicLayoutEffect(() => {\n setIsMounted(true)\n }, [])\n\n const anchorRef = React.useRef<any>()\n const [arrowEl, setArrow] = React.useState<HTMLSpanElement | null>(null)\n const [arrowSize, setArrowSize] = React.useState(0)\n const arrowRef = React.useRef()\n\n const floating = useFloating({\n placement,\n middleware: [\n stayInFrame ? shift(stayInFrame) : (null as any),\n allowFlip ? flip(allowFlip) : (null as any),\n arrowEl ? arrow({ element: arrowEl }) : (null as any),\n arrowSize ? offset(arrowSize) : (null as any),\n ].filter(Boolean),\n })\n\n const { refs, middlewareData } = floating\n\n const composedArrowRefs = useComposedRefs<any>(arrowRef, setArrow)\n\n useIsomorphicLayoutEffect(() => {\n floating.reference(anchorRef.current)\n }, [anchorRef])\n\n React.useEffect(() => {\n if (!refs.reference.current || !refs.floating.current) {\n return\n }\n // Only call this when the floating element is rendered\n return autoUpdate(refs.reference.current, refs.floating.current, floating.update)\n }, [refs.floating.current, refs.reference.current])\n\n const arrowStyle = React.useMemo(() => {\n return middlewareData.arrow\n }, [JSON.stringify(middlewareData.arrow || {})])\n\n return (\n <PopperProvider\n scope={__scopePopper}\n anchorRef={anchorRef}\n size={size}\n arrowRef={composedArrowRefs}\n arrowStyle={arrowStyle}\n onArrowSize={setArrowSize}\n isMounted={isMounted}\n {...floating}\n >\n {children}\n </PopperProvider>\n )\n}\n\nPopper.displayName = POPPER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor'\n\ntype PopperAnchorRef = HTMLElement | View\n\nexport type PopperAnchorProps = YStackProps & {\n virtualRef?: React.RefObject<any>\n}\n\nexport const PopperAnchor = React.forwardRef<PopperAnchorRef, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props\n const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper)\n const ref = React.useRef<PopperAnchorRef>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef)\n if (virtualRef) {\n return null\n }\n const stackProps = {\n ref: composedRefs,\n ...anchorProps,\n }\n return <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />\n }\n)\n\nPopperAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent'\n\ntype PopperContentElement = HTMLElement | View\n\nexport type PopperContentProps = SizableStackProps\n\nconst PopperContentFrame = styled(SizableStack, {\n name: 'PopperContent',\n backgroundColor: '$background',\n alignItems: 'center',\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const { __scopePopper, ...contentProps } = props\n const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } =\n usePopperContext(CONTENT_NAME, __scopePopper)\n const contentRefs = useComposedRefs<any>(floating, forwardedRef)\n\n const contents = React.useMemo(() => {\n return (\n <PopperContentFrame\n key=\"popper-content-frame\"\n data-placement={placement}\n data-strategy={strategy}\n {...contentProps}\n size={contentProps.size ?? size}\n />\n )\n }, [placement, strategy, props])\n\n // all poppers hidden on ssr by default\n if (!isMounted) {\n return null\n }\n\n const frameProps = {\n ref: contentRefs,\n x: (x as any) || 0,\n y: (y as any) || 0,\n position: 'absolute',\n }\n\n // outer frame because we explicitly dont want animation to apply to this\n return (\n <YStack {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}>\n {contents}\n </YStack>\n )\n }\n)\n\nPopperContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow'\n\ntype PopperArrowElement = HTMLElement | View\n\nexport type PopperArrowProps = YStackProps & {\n offset?: number\n size?: SizeTokens\n}\n\nconst PopperArrowFrame = styled(YStack, {\n name: 'PopperArrow',\n borderColor: '$borderColor',\n backgroundColor: '$background',\n position: 'absolute',\n zIndex: 1,\n // TODO bug not applying\n // rotate: '45deg',\n})\n\nconst opposites = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n}\n\nexport const PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(\n function PopperArrow(props: ScopedProps<PopperArrowProps>, forwardedRef) {\n const { __scopePopper, offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props\n const context = usePopperContext(ARROW_NAME, __scopePopper)\n const tokens = getTokens()\n const sizeVal = sizeProp ?? context.size\n const sizeValResolved = getVariableValue(tokens.size[sizeVal as any] ?? sizeVal ?? 12)\n const size = +sizeValResolved\n const { placement } = context\n const { x, y } = context.arrowStyle || { x: 0, y: 0 }\n const refs = useComposedRefs(context.arrowRef, forwardedRef)\n\n const primaryPlacement = placement ? placement.split('-')[0] : 'top'\n\n let arrowStyle: StackProps = { x, y, width: size, height: size }\n if (primaryPlacement) {\n const oppSide = opposites[primaryPlacement]\n if (oppSide) {\n arrowStyle[oppSide] = -size / 2\n }\n if (oppSide === 'top' || oppSide === 'bottom') {\n arrowStyle.left = 0\n }\n if (oppSide === 'left' || oppSide === 'right') {\n arrowStyle.top = 0\n }\n }\n\n // send the Arrow's offset up to Popper\n useIsomorphicLayoutEffect(() => {\n context.onArrowSize?.(size)\n }, [size, context.onArrowSize])\n\n return (\n <PopperArrowFrame\n {...arrowProps}\n ref={refs}\n {...arrowStyle}\n rotate=\"45deg\"\n // left={0}\n // top={0}\n {...(primaryPlacement === 'top' && {\n borderBottomWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'bottom' && {\n borderTopWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n {...(primaryPlacement === 'left' && {\n borderTopWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'right' && {\n borderBottomWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n />\n )\n }\n)\n\nPopperArrow.displayName = ARROW_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAgC;AAChC,kBAOO;AACP,4BAA0C;AAC1C,oBAAqE;AACrE,YAAuB;AAGvB,sBAA0E;AAC1E,yBAA+C;AAS/C,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,eAAe,8CAAmB,WAAW;AAElE,MAAM,oBAAoB;AAajC,MAAM,CAAC,gBAAgB,oBAAoB,oBAAwC,WAAW;AAUvF,MAAM,SAAgC,wBAAC,UAAoC;AAChF,QAAM,EAAE,eAAe,UAAU,MAAM,YAAY,UAAU,aAAa,cAAc;AAExF,QAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,KAAK;AACtD,6CAA0B,MAAM;AAC9B,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY,MAAM,OAAY;AACpC,QAAM,CAAC,SAAS,YAAY,MAAM,SAAiC,IAAI;AACvE,QAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,CAAC;AAClD,QAAM,WAAW,MAAM,OAAO;AAE9B,QAAM,WAAW,oCAAY;AAAA,IAC3B;AAAA,IACA,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ChB,iBAAiB;AAAA,EACnB,IACK,qBAAqB,UAAU;AAAA,IAClC,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,EACpB,IACK,qBAAqB,WAAW;AAAA,IACnC,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,EACnB,EACF;AAEJ,GA1DA,cA2DF;AAEA,YAAY,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var floating_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(floating_exports);
|
|
17
|
+
__reExport(floating_exports, require("@floating-ui/react-dom"), module.exports);
|
|
18
|
+
//# sourceMappingURL=floating.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var floating_native_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(floating_native_exports);
|
|
17
|
+
__reExport(floating_native_exports, require("@floating-ui/react-native"), module.exports);
|
|
18
|
+
//# sourceMappingURL=floating.native.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
FloatingOverrideContext: () => import_useFloating.FloatingOverrideContext,
|
|
22
|
+
UseFloatingFn: () => import_useFloating.UseFloatingFn
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(src_exports);
|
|
25
|
+
var import_useFloating = require("./useFloating");
|
|
26
|
+
__reExport(src_exports, require("./Popper"), module.exports);
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
FloatingOverrideContext,
|
|
30
|
+
UseFloatingFn
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["export { FloatingOverrideContext, UseFloatingFn } from './useFloating'\nexport * from './Popper'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuD;AACvD,wBAAc,qBADd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var useFloating_exports = {};
|
|
23
|
+
__export(useFloating_exports, {
|
|
24
|
+
FloatingOverrideContext: () => FloatingOverrideContext,
|
|
25
|
+
useFloating: () => useFloating
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useFloating_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var Floating = __toESM(require("./floating"));
|
|
30
|
+
const FloatingOverrideContext = (0, import_react.createContext)(null);
|
|
31
|
+
const useFloating = /* @__PURE__ */ __name((props) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const context = (0, import_react.useContext)(FloatingOverrideContext);
|
|
34
|
+
return (_a = context || Floating.useFloating) == null ? void 0 : _a(props);
|
|
35
|
+
}, "useFloating");
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
FloatingOverrideContext,
|
|
39
|
+
useFloating
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=useFloating.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useFloating.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContext, useContext } from 'react'\n\nimport * as Floating from './floating'\n\nexport type UseFloatingFn = typeof Floating.useFloating\n\ntype UseFloatingProps = UseFloatingFn extends (props: infer Props) => any ? Props : never\n\nexport type UseFloatingResult = ReturnType<UseFloatingFn> & {\n getFloatingProps?: (props: { ref: any; [key: string]: any }) => any\n getReferenceProps?: (props: { ref: any; [key: string]: any }) => any\n}\n\nexport const FloatingOverrideContext = createContext<UseFloatingFn | null>(null)\n\nexport const useFloating = (props: UseFloatingProps): UseFloatingResult => {\n const context = useContext(FloatingOverrideContext)\n return (context || Floating.useFloating)?.(props)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAE1C,eAA0B;AAWnB,MAAM,0BAA0B,gCAAoC,IAAI;AAExE,MAAM,cAAc,wBAAC,UAA+C;AAf3E;AAgBE,QAAM,UAAU,6BAAW,uBAAuB;AAClD,SAAQ,iBAAW,SAAS,gBAApB,mBAAmC;AAC7C,GAH2B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
4
|
+
import {
|
|
5
|
+
getTokens,
|
|
6
|
+
getVariableValue,
|
|
7
|
+
styled,
|
|
8
|
+
useIsomorphicLayoutEffect
|
|
9
|
+
} from "@tamagui/core";
|
|
10
|
+
import { createContextScope } from "@tamagui/create-context";
|
|
11
|
+
import { SizableStack, YStack } from "@tamagui/stacks";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { arrow, autoUpdate, flip, offset, shift } from "./floating";
|
|
14
|
+
import { useFloating } from "./useFloating";
|
|
15
|
+
const POPPER_NAME = "Popper";
|
|
16
|
+
const [createPopperContext, createScope] = createContextScope(POPPER_NAME);
|
|
17
|
+
const createPopperScope = createScope;
|
|
18
|
+
const [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
19
|
+
const Popper = /* @__PURE__ */ __name((props) => {
|
|
20
|
+
const { __scopePopper, children, size, placement = "bottom", stayInFrame, allowFlip } = props;
|
|
21
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
22
|
+
useIsomorphicLayoutEffect(() => {
|
|
23
|
+
setIsMounted(true);
|
|
24
|
+
}, []);
|
|
25
|
+
const anchorRef = React.useRef();
|
|
26
|
+
const [arrowEl, setArrow] = React.useState(null);
|
|
27
|
+
const [arrowSize, setArrowSize] = React.useState(0);
|
|
28
|
+
const arrowRef = React.useRef();
|
|
29
|
+
const floating = useFloating({
|
|
30
|
+
placement,
|
|
31
|
+
middleware: [
|
|
32
|
+
stayInFrame ? shift(stayInFrame) : null,
|
|
33
|
+
allowFlip ? flip(allowFlip) : null,
|
|
34
|
+
arrowEl ? arrow({ element: arrowEl }) : null,
|
|
35
|
+
arrowSize ? offset(arrowSize) : null
|
|
36
|
+
].filter(Boolean)
|
|
37
|
+
});
|
|
38
|
+
const { refs, middlewareData } = floating;
|
|
39
|
+
const composedArrowRefs = useComposedRefs(arrowRef, setArrow);
|
|
40
|
+
useIsomorphicLayoutEffect(() => {
|
|
41
|
+
floating.reference(anchorRef.current);
|
|
42
|
+
}, [anchorRef]);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (!refs.reference.current || !refs.floating.current) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
|
|
48
|
+
}, [refs.floating.current, refs.reference.current]);
|
|
49
|
+
const arrowStyle = React.useMemo(() => {
|
|
50
|
+
return middlewareData.arrow;
|
|
51
|
+
}, [JSON.stringify(middlewareData.arrow || {})]);
|
|
52
|
+
return /* @__PURE__ */ React.createElement(PopperProvider, {
|
|
53
|
+
scope: __scopePopper,
|
|
54
|
+
anchorRef,
|
|
55
|
+
size,
|
|
56
|
+
arrowRef: composedArrowRefs,
|
|
57
|
+
arrowStyle,
|
|
58
|
+
onArrowSize: setArrowSize,
|
|
59
|
+
isMounted,
|
|
60
|
+
...floating
|
|
61
|
+
}, children);
|
|
62
|
+
}, "Popper");
|
|
63
|
+
Popper.displayName = POPPER_NAME;
|
|
64
|
+
const ANCHOR_NAME = "PopperAnchor";
|
|
65
|
+
const PopperAnchor = React.forwardRef((props, forwardedRef) => {
|
|
66
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
67
|
+
const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
68
|
+
const ref = React.useRef(null);
|
|
69
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
|
|
70
|
+
if (virtualRef) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const stackProps = {
|
|
74
|
+
ref: composedRefs,
|
|
75
|
+
...anchorProps
|
|
76
|
+
};
|
|
77
|
+
return /* @__PURE__ */ React.createElement(YStack, {
|
|
78
|
+
...getReferenceProps ? getReferenceProps(stackProps) : stackProps
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
82
|
+
const CONTENT_NAME = "PopperContent";
|
|
83
|
+
const PopperContentFrame = styled(SizableStack, {
|
|
84
|
+
name: "PopperContent",
|
|
85
|
+
backgroundColor: "$background",
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
defaultVariants: {
|
|
88
|
+
size: "$4"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const PopperContent = React.forwardRef((props, forwardedRef) => {
|
|
92
|
+
const { __scopePopper, ...contentProps } = props;
|
|
93
|
+
const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
94
|
+
const contentRefs = useComposedRefs(floating, forwardedRef);
|
|
95
|
+
const contents = React.useMemo(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
return /* @__PURE__ */ React.createElement(PopperContentFrame, {
|
|
98
|
+
key: "popper-content-frame",
|
|
99
|
+
"data-placement": placement,
|
|
100
|
+
"data-strategy": strategy,
|
|
101
|
+
...contentProps,
|
|
102
|
+
size: (_a = contentProps.size) != null ? _a : size
|
|
103
|
+
});
|
|
104
|
+
}, [placement, strategy, props]);
|
|
105
|
+
if (!isMounted) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const frameProps = {
|
|
109
|
+
ref: contentRefs,
|
|
110
|
+
x: x || 0,
|
|
111
|
+
y: y || 0,
|
|
112
|
+
position: "absolute"
|
|
113
|
+
};
|
|
114
|
+
return /* @__PURE__ */ React.createElement(YStack, {
|
|
115
|
+
...getFloatingProps ? getFloatingProps(frameProps) : frameProps
|
|
116
|
+
}, contents);
|
|
117
|
+
});
|
|
118
|
+
PopperContent.displayName = CONTENT_NAME;
|
|
119
|
+
const ARROW_NAME = "PopperArrow";
|
|
120
|
+
const PopperArrowFrame = styled(YStack, {
|
|
121
|
+
name: "PopperArrow",
|
|
122
|
+
borderColor: "$borderColor",
|
|
123
|
+
backgroundColor: "$background",
|
|
124
|
+
position: "absolute",
|
|
125
|
+
zIndex: 1
|
|
126
|
+
});
|
|
127
|
+
const opposites = {
|
|
128
|
+
top: "bottom",
|
|
129
|
+
right: "left",
|
|
130
|
+
bottom: "top",
|
|
131
|
+
left: "right"
|
|
132
|
+
};
|
|
133
|
+
const PopperArrow = React.forwardRef(/* @__PURE__ */ __name(function PopperArrow2(props, forwardedRef) {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
const { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
|
|
136
|
+
const context = usePopperContext(ARROW_NAME, __scopePopper);
|
|
137
|
+
const tokens = getTokens();
|
|
138
|
+
const sizeVal = sizeProp != null ? sizeProp : context.size;
|
|
139
|
+
const sizeValResolved = getVariableValue((_b = (_a = tokens.size[sizeVal]) != null ? _a : sizeVal) != null ? _b : 12);
|
|
140
|
+
const size = +sizeValResolved;
|
|
141
|
+
const { placement } = context;
|
|
142
|
+
const { x, y } = context.arrowStyle || { x: 0, y: 0 };
|
|
143
|
+
const refs = useComposedRefs(context.arrowRef, forwardedRef);
|
|
144
|
+
const primaryPlacement = placement ? placement.split("-")[0] : "top";
|
|
145
|
+
let arrowStyle = { x, y, width: size, height: size };
|
|
146
|
+
if (primaryPlacement) {
|
|
147
|
+
const oppSide = opposites[primaryPlacement];
|
|
148
|
+
if (oppSide) {
|
|
149
|
+
arrowStyle[oppSide] = -size / 2;
|
|
150
|
+
}
|
|
151
|
+
if (oppSide === "top" || oppSide === "bottom") {
|
|
152
|
+
arrowStyle.left = 0;
|
|
153
|
+
}
|
|
154
|
+
if (oppSide === "left" || oppSide === "right") {
|
|
155
|
+
arrowStyle.top = 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
useIsomorphicLayoutEffect(() => {
|
|
159
|
+
var _a2;
|
|
160
|
+
(_a2 = context.onArrowSize) == null ? void 0 : _a2.call(context, size);
|
|
161
|
+
}, [size, context.onArrowSize]);
|
|
162
|
+
return /* @__PURE__ */ React.createElement(PopperArrowFrame, {
|
|
163
|
+
...arrowProps,
|
|
164
|
+
ref: refs,
|
|
165
|
+
...arrowStyle,
|
|
166
|
+
rotate: "45deg",
|
|
167
|
+
...primaryPlacement === "top" && {
|
|
168
|
+
borderBottomWidth: borderWidth,
|
|
169
|
+
borderRightWidth: borderWidth
|
|
170
|
+
},
|
|
171
|
+
...primaryPlacement === "bottom" && {
|
|
172
|
+
borderTopWidth: borderWidth,
|
|
173
|
+
borderLeftWidth: borderWidth
|
|
174
|
+
},
|
|
175
|
+
...primaryPlacement === "left" && {
|
|
176
|
+
borderTopWidth: borderWidth,
|
|
177
|
+
borderRightWidth: borderWidth
|
|
178
|
+
},
|
|
179
|
+
...primaryPlacement === "right" && {
|
|
180
|
+
borderBottomWidth: borderWidth,
|
|
181
|
+
borderLeftWidth: borderWidth
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}, "PopperArrow"));
|
|
185
|
+
PopperArrow.displayName = ARROW_NAME;
|
|
186
|
+
export {
|
|
187
|
+
Popper,
|
|
188
|
+
PopperAnchor,
|
|
189
|
+
PopperArrow,
|
|
190
|
+
PopperContent,
|
|
191
|
+
createPopperScope
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=Popper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Popper.tsx"],
|
|
4
|
+
"sourcesContent": ["// adapted from radix-ui popper\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n SizeTokens,\n StackProps,\n getTokens,\n getVariableValue,\n styled,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { SizableStack, SizableStackProps, YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nimport { Coords, Placement, arrow, autoUpdate, flip, offset, shift } from './floating'\nimport { UseFloatingResult, useFloating } from './useFloating'\n\ntype ShiftProps = typeof shift extends (options: infer Opts) => void ? Opts : never\ntype FlipProps = typeof flip extends (options: infer Opts) => void ? Opts : never\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper'\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope }\nconst [createPopperContext, createScope] = createContextScope(POPPER_NAME)\n\nexport const createPopperScope = createScope\n\ntype PopperContextValue = UseFloatingResult & {\n isMounted: boolean\n anchorRef: any\n size?: SizeTokens\n placement?: Placement\n arrowRef: any\n onArrowSize?: (val: number) => void\n arrowStyle?: Partial<Coords> & {\n centerOffset: number\n }\n}\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME)\n\nexport type PopperProps = {\n size?: SizeTokens\n children?: React.ReactNode\n placement?: Placement\n stayInFrame?: ShiftProps\n allowFlip?: FlipProps\n}\n\nexport const Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children, size, placement = 'bottom', stayInFrame, allowFlip } = props\n\n const [isMounted, setIsMounted] = React.useState(false)\n useIsomorphicLayoutEffect(() => {\n setIsMounted(true)\n }, [])\n\n const anchorRef = React.useRef<any>()\n const [arrowEl, setArrow] = React.useState<HTMLSpanElement | null>(null)\n const [arrowSize, setArrowSize] = React.useState(0)\n const arrowRef = React.useRef()\n\n const floating = useFloating({\n placement,\n middleware: [\n stayInFrame ? shift(stayInFrame) : (null as any),\n allowFlip ? flip(allowFlip) : (null as any),\n arrowEl ? arrow({ element: arrowEl }) : (null as any),\n arrowSize ? offset(arrowSize) : (null as any),\n ].filter(Boolean),\n })\n\n const { refs, middlewareData } = floating\n\n const composedArrowRefs = useComposedRefs<any>(arrowRef, setArrow)\n\n useIsomorphicLayoutEffect(() => {\n floating.reference(anchorRef.current)\n }, [anchorRef])\n\n React.useEffect(() => {\n if (!refs.reference.current || !refs.floating.current) {\n return\n }\n // Only call this when the floating element is rendered\n return autoUpdate(refs.reference.current, refs.floating.current, floating.update)\n }, [refs.floating.current, refs.reference.current])\n\n const arrowStyle = React.useMemo(() => {\n return middlewareData.arrow\n }, [JSON.stringify(middlewareData.arrow || {})])\n\n return (\n <PopperProvider\n scope={__scopePopper}\n anchorRef={anchorRef}\n size={size}\n arrowRef={composedArrowRefs}\n arrowStyle={arrowStyle}\n onArrowSize={setArrowSize}\n isMounted={isMounted}\n {...floating}\n >\n {children}\n </PopperProvider>\n )\n}\n\nPopper.displayName = POPPER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor'\n\ntype PopperAnchorRef = HTMLElement | View\n\nexport type PopperAnchorProps = YStackProps & {\n virtualRef?: React.RefObject<any>\n}\n\nexport const PopperAnchor = React.forwardRef<PopperAnchorRef, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props\n const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper)\n const ref = React.useRef<PopperAnchorRef>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef)\n if (virtualRef) {\n return null\n }\n const stackProps = {\n ref: composedRefs,\n ...anchorProps,\n }\n return <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />\n }\n)\n\nPopperAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent'\n\ntype PopperContentElement = HTMLElement | View\n\nexport type PopperContentProps = SizableStackProps\n\nconst PopperContentFrame = styled(SizableStack, {\n name: 'PopperContent',\n backgroundColor: '$background',\n alignItems: 'center',\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const { __scopePopper, ...contentProps } = props\n const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } =\n usePopperContext(CONTENT_NAME, __scopePopper)\n const contentRefs = useComposedRefs<any>(floating, forwardedRef)\n\n const contents = React.useMemo(() => {\n return (\n <PopperContentFrame\n key=\"popper-content-frame\"\n data-placement={placement}\n data-strategy={strategy}\n {...contentProps}\n size={contentProps.size ?? size}\n />\n )\n }, [placement, strategy, props])\n\n // all poppers hidden on ssr by default\n if (!isMounted) {\n return null\n }\n\n const frameProps = {\n ref: contentRefs,\n x: (x as any) || 0,\n y: (y as any) || 0,\n position: 'absolute',\n }\n\n // outer frame because we explicitly dont want animation to apply to this\n return (\n <YStack {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}>\n {contents}\n </YStack>\n )\n }\n)\n\nPopperContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow'\n\ntype PopperArrowElement = HTMLElement | View\n\nexport type PopperArrowProps = YStackProps & {\n offset?: number\n size?: SizeTokens\n}\n\nconst PopperArrowFrame = styled(YStack, {\n name: 'PopperArrow',\n borderColor: '$borderColor',\n backgroundColor: '$background',\n position: 'absolute',\n zIndex: 1,\n // TODO bug not applying\n // rotate: '45deg',\n})\n\nconst opposites = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n}\n\nexport const PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(\n function PopperArrow(props: ScopedProps<PopperArrowProps>, forwardedRef) {\n const { __scopePopper, offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props\n const context = usePopperContext(ARROW_NAME, __scopePopper)\n const tokens = getTokens()\n const sizeVal = sizeProp ?? context.size\n const sizeValResolved = getVariableValue(tokens.size[sizeVal as any] ?? sizeVal ?? 12)\n const size = +sizeValResolved\n const { placement } = context\n const { x, y } = context.arrowStyle || { x: 0, y: 0 }\n const refs = useComposedRefs(context.arrowRef, forwardedRef)\n\n const primaryPlacement = placement ? placement.split('-')[0] : 'top'\n\n let arrowStyle: StackProps = { x, y, width: size, height: size }\n if (primaryPlacement) {\n const oppSide = opposites[primaryPlacement]\n if (oppSide) {\n arrowStyle[oppSide] = -size / 2\n }\n if (oppSide === 'top' || oppSide === 'bottom') {\n arrowStyle.left = 0\n }\n if (oppSide === 'left' || oppSide === 'right') {\n arrowStyle.top = 0\n }\n }\n\n // send the Arrow's offset up to Popper\n useIsomorphicLayoutEffect(() => {\n context.onArrowSize?.(size)\n }, [size, context.onArrowSize])\n\n return (\n <PopperArrowFrame\n {...arrowProps}\n ref={refs}\n {...arrowStyle}\n rotate=\"45deg\"\n // left={0}\n // top={0}\n {...(primaryPlacement === 'top' && {\n borderBottomWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'bottom' && {\n borderTopWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n {...(primaryPlacement === 'left' && {\n borderTopWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'right' && {\n borderBottomWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n />\n )\n }\n)\n\nPopperArrow.displayName = ARROW_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n"],
|
|
5
|
+
"mappings": ";;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AACA;AACA;AAGA;AACA;AASA,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,eAAe,mBAAmB,WAAW;AAElE,MAAM,oBAAoB;AAajC,MAAM,CAAC,gBAAgB,oBAAoB,oBAAwC,WAAW;AAUvF,MAAM,SAAgC,wBAAC,UAAoC;AAChF,QAAM,EAAE,eAAe,UAAU,MAAM,YAAY,UAAU,aAAa,cAAc;AAExF,QAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,KAAK;AACtD,4BAA0B,MAAM;AAC9B,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY,MAAM,OAAY;AACpC,QAAM,CAAC,SAAS,YAAY,MAAM,SAAiC,IAAI;AACvE,QAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,CAAC;AAClD,QAAM,WAAW,MAAM,OAAO;AAE9B,QAAM,WAAW,YAAY;AAAA,IAC3B;AAAA,IACA,YAAY;AAAA,MACV,cAAc,MAAM,WAAW,IAAK;AAAA,MACpC,YAAY,KAAK,SAAS,IAAK;AAAA,MAC/B,UAAU,MAAM,EAAE,SAAS,QAAQ,CAAC,IAAK;AAAA,MACzC,YAAY,OAAO,SAAS,IAAK;AAAA,IACnC,EAAE,OAAO,OAAO;AAAA,EAClB,CAAC;AAED,QAAM,EAAE,MAAM,mBAAmB;AAEjC,QAAM,oBAAoB,gBAAqB,UAAU,QAAQ;AAEjE,4BAA0B,MAAM;AAC9B,aAAS,UAAU,UAAU,OAAO;AAAA,EACtC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AACd,QAAM,EAAE,cAAc;AACtB,QAAM,EAAE,GAAG,MAAM,QAAQ,cAAc,EAAE,GAAG,GAAG,GAAG,EAAE;AACpD,QAAM,OAAO,gBAAgB,QAAQ,UAAU,YAAY;AAE3D,QAAM,mBAAmB,YAAY,UAAU,MAAM,GAAG,EAAE,KAAK;AAE/D,MAAI,aAAyB,EAAE,GAAG,GAAG,OAAO,MAAM,QAAQ,KAAK;AAC/D,MAAI,kBAAkB;AACpB,UAAM,UAAU,UAAU;AAC1B,QAAI,SAAS;AACX,iBAAW,WAAW,CAAC,OAAO;AAAA,IAChC;AACA,QAAI,YAAY,SAAS,YAAY,UAAU;AAC7C,iBAAW,OAAO;AAAA,IACpB;AACA,QAAI,YAAY,UAAU,YAAY,SAAS;AAC7C,iBAAW,MAAM;AAAA,IACnB;AAAA,EACF;AAGA,4BAA0B,MAAM;AA3QpC;AA4QM,mBAAQ,gBAAR,kCAAsB;AAAA,EACxB,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAE9B,SACE,oCAAC;AAAA,OACK;AAAA,IACJ,KAAK;AAAA,OACD;AAAA,IACJ,QAAO;AAAA,OAGF,qBAAqB,SAAS;AAAA,MACjC,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,IACpB;AAAA,OACK,qBAAqB,YAAY;AAAA,MACpC,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACnB;AAAA,OACK,qBAAqB,UAAU;AAAA,MAClC,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,IACpB;AAAA,OACK,qBAAqB,WAAW;AAAA,MACnC,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,IACnB;AAAA,GACF;AAEJ,GA1DA,cA2DF;AAEA,YAAY,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import * as Floating from "./floating";
|
|
5
|
+
const FloatingOverrideContext = createContext(null);
|
|
6
|
+
const useFloating = /* @__PURE__ */ __name((props) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const context = useContext(FloatingOverrideContext);
|
|
9
|
+
return (_a = context || Floating.useFloating) == null ? void 0 : _a(props);
|
|
10
|
+
}, "useFloating");
|
|
11
|
+
export {
|
|
12
|
+
FloatingOverrideContext,
|
|
13
|
+
useFloating
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useFloating.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useFloating.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContext, useContext } from 'react'\n\nimport * as Floating from './floating'\n\nexport type UseFloatingFn = typeof Floating.useFloating\n\ntype UseFloatingProps = UseFloatingFn extends (props: infer Props) => any ? Props : never\n\nexport type UseFloatingResult = ReturnType<UseFloatingFn> & {\n getFloatingProps?: (props: { ref: any; [key: string]: any }) => any\n getReferenceProps?: (props: { ref: any; [key: string]: any }) => any\n}\n\nexport const FloatingOverrideContext = createContext<UseFloatingFn | null>(null)\n\nexport const useFloating = (props: UseFloatingProps): UseFloatingResult => {\n const context = useContext(FloatingOverrideContext)\n return (context || Floating.useFloating)?.(props)\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AAWO,MAAM,0BAA0B,cAAoC,IAAI;AAExE,MAAM,cAAc,wBAAC,UAA+C;AAf3E;AAgBE,QAAM,UAAU,WAAW,uBAAuB;AAClD,SAAQ,iBAAW,SAAS,gBAApB,mBAAmC;AAC7C,GAH2B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
4
|
+
import {
|
|
5
|
+
getTokens,
|
|
6
|
+
getVariableValue,
|
|
7
|
+
styled,
|
|
8
|
+
useIsomorphicLayoutEffect
|
|
9
|
+
} from "@tamagui/core";
|
|
10
|
+
import { createContextScope } from "@tamagui/create-context";
|
|
11
|
+
import { SizableStack, YStack } from "@tamagui/stacks";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { arrow, autoUpdate, flip, offset, shift } from "./floating";
|
|
14
|
+
import { useFloating } from "./useFloating";
|
|
15
|
+
const POPPER_NAME = "Popper";
|
|
16
|
+
const [createPopperContext, createScope] = createContextScope(POPPER_NAME);
|
|
17
|
+
const createPopperScope = createScope;
|
|
18
|
+
const [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
19
|
+
const Popper = /* @__PURE__ */ __name((props) => {
|
|
20
|
+
const { __scopePopper, children, size, placement = "bottom", stayInFrame, allowFlip } = props;
|
|
21
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
22
|
+
useIsomorphicLayoutEffect(() => {
|
|
23
|
+
setIsMounted(true);
|
|
24
|
+
}, []);
|
|
25
|
+
const anchorRef = React.useRef();
|
|
26
|
+
const [arrowEl, setArrow] = React.useState(null);
|
|
27
|
+
const [arrowSize, setArrowSize] = React.useState(0);
|
|
28
|
+
const arrowRef = React.useRef();
|
|
29
|
+
const floating = useFloating({
|
|
30
|
+
placement,
|
|
31
|
+
middleware: [
|
|
32
|
+
stayInFrame ? shift(stayInFrame) : null,
|
|
33
|
+
allowFlip ? flip(allowFlip) : null,
|
|
34
|
+
arrowEl ? arrow({ element: arrowEl }) : null,
|
|
35
|
+
arrowSize ? offset(arrowSize) : null
|
|
36
|
+
].filter(Boolean)
|
|
37
|
+
});
|
|
38
|
+
const { refs, middlewareData } = floating;
|
|
39
|
+
const composedArrowRefs = useComposedRefs(arrowRef, setArrow);
|
|
40
|
+
useIsomorphicLayoutEffect(() => {
|
|
41
|
+
floating.reference(anchorRef.current);
|
|
42
|
+
}, [anchorRef]);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (!refs.reference.current || !refs.floating.current) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
|
|
48
|
+
}, [refs.floating.current, refs.reference.current]);
|
|
49
|
+
const arrowStyle = React.useMemo(() => {
|
|
50
|
+
return middlewareData.arrow;
|
|
51
|
+
}, [JSON.stringify(middlewareData.arrow || {})]);
|
|
52
|
+
return <PopperProvider scope={__scopePopper} anchorRef={anchorRef} size={size} arrowRef={composedArrowRefs} arrowStyle={arrowStyle} onArrowSize={setArrowSize} isMounted={isMounted} {...floating}>{children}</PopperProvider>;
|
|
53
|
+
}, "Popper");
|
|
54
|
+
Popper.displayName = POPPER_NAME;
|
|
55
|
+
const ANCHOR_NAME = "PopperAnchor";
|
|
56
|
+
const PopperAnchor = React.forwardRef((props, forwardedRef) => {
|
|
57
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
58
|
+
const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
59
|
+
const ref = React.useRef(null);
|
|
60
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
|
|
61
|
+
if (virtualRef) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const stackProps = {
|
|
65
|
+
ref: composedRefs,
|
|
66
|
+
...anchorProps
|
|
67
|
+
};
|
|
68
|
+
return <YStack {...getReferenceProps ? getReferenceProps(stackProps) : stackProps} />;
|
|
69
|
+
});
|
|
70
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
71
|
+
const CONTENT_NAME = "PopperContent";
|
|
72
|
+
const PopperContentFrame = styled(SizableStack, {
|
|
73
|
+
name: "PopperContent",
|
|
74
|
+
backgroundColor: "$background",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
defaultVariants: {
|
|
77
|
+
size: "$4"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const PopperContent = React.forwardRef((props, forwardedRef) => {
|
|
81
|
+
const { __scopePopper, ...contentProps } = props;
|
|
82
|
+
const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
83
|
+
const contentRefs = useComposedRefs(floating, forwardedRef);
|
|
84
|
+
const contents = React.useMemo(() => {
|
|
85
|
+
var _a;
|
|
86
|
+
return <PopperContentFrame key="popper-content-frame" data-placement={placement} data-strategy={strategy} {...contentProps} size={(_a = contentProps.size) != null ? _a : size} />;
|
|
87
|
+
}, [placement, strategy, props]);
|
|
88
|
+
if (!isMounted) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const frameProps = {
|
|
92
|
+
ref: contentRefs,
|
|
93
|
+
x: x || 0,
|
|
94
|
+
y: y || 0,
|
|
95
|
+
position: "absolute"
|
|
96
|
+
};
|
|
97
|
+
return <YStack {...getFloatingProps ? getFloatingProps(frameProps) : frameProps}>{contents}</YStack>;
|
|
98
|
+
});
|
|
99
|
+
PopperContent.displayName = CONTENT_NAME;
|
|
100
|
+
const ARROW_NAME = "PopperArrow";
|
|
101
|
+
const PopperArrowFrame = styled(YStack, {
|
|
102
|
+
name: "PopperArrow",
|
|
103
|
+
borderColor: "$borderColor",
|
|
104
|
+
backgroundColor: "$background",
|
|
105
|
+
position: "absolute",
|
|
106
|
+
zIndex: 1
|
|
107
|
+
});
|
|
108
|
+
const opposites = {
|
|
109
|
+
top: "bottom",
|
|
110
|
+
right: "left",
|
|
111
|
+
bottom: "top",
|
|
112
|
+
left: "right"
|
|
113
|
+
};
|
|
114
|
+
const PopperArrow = React.forwardRef(/* @__PURE__ */ __name(function PopperArrow2(props, forwardedRef) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
|
|
117
|
+
const context = usePopperContext(ARROW_NAME, __scopePopper);
|
|
118
|
+
const tokens = getTokens();
|
|
119
|
+
const sizeVal = sizeProp != null ? sizeProp : context.size;
|
|
120
|
+
const sizeValResolved = getVariableValue((_b = (_a = tokens.size[sizeVal]) != null ? _a : sizeVal) != null ? _b : 12);
|
|
121
|
+
const size = +sizeValResolved;
|
|
122
|
+
const { placement } = context;
|
|
123
|
+
const { x, y } = context.arrowStyle || { x: 0, y: 0 };
|
|
124
|
+
const refs = useComposedRefs(context.arrowRef, forwardedRef);
|
|
125
|
+
const primaryPlacement = placement ? placement.split("-")[0] : "top";
|
|
126
|
+
let arrowStyle = { x, y, width: size, height: size };
|
|
127
|
+
if (primaryPlacement) {
|
|
128
|
+
const oppSide = opposites[primaryPlacement];
|
|
129
|
+
if (oppSide) {
|
|
130
|
+
arrowStyle[oppSide] = -size / 2;
|
|
131
|
+
}
|
|
132
|
+
if (oppSide === "top" || oppSide === "bottom") {
|
|
133
|
+
arrowStyle.left = 0;
|
|
134
|
+
}
|
|
135
|
+
if (oppSide === "left" || oppSide === "right") {
|
|
136
|
+
arrowStyle.top = 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
useIsomorphicLayoutEffect(() => {
|
|
140
|
+
var _a2;
|
|
141
|
+
(_a2 = context.onArrowSize) == null ? void 0 : _a2.call(context, size);
|
|
142
|
+
}, [size, context.onArrowSize]);
|
|
143
|
+
return <PopperArrowFrame {...arrowProps} ref={refs} {...arrowStyle} rotate="45deg" {...primaryPlacement === "top" && {
|
|
144
|
+
borderBottomWidth: borderWidth,
|
|
145
|
+
borderRightWidth: borderWidth
|
|
146
|
+
}} {...primaryPlacement === "bottom" && {
|
|
147
|
+
borderTopWidth: borderWidth,
|
|
148
|
+
borderLeftWidth: borderWidth
|
|
149
|
+
}} {...primaryPlacement === "left" && {
|
|
150
|
+
borderTopWidth: borderWidth,
|
|
151
|
+
borderRightWidth: borderWidth
|
|
152
|
+
}} {...primaryPlacement === "right" && {
|
|
153
|
+
borderBottomWidth: borderWidth,
|
|
154
|
+
borderLeftWidth: borderWidth
|
|
155
|
+
}} />;
|
|
156
|
+
}, "PopperArrow"));
|
|
157
|
+
PopperArrow.displayName = ARROW_NAME;
|
|
158
|
+
export {
|
|
159
|
+
Popper,
|
|
160
|
+
PopperAnchor,
|
|
161
|
+
PopperArrow,
|
|
162
|
+
PopperContent,
|
|
163
|
+
createPopperScope
|
|
164
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@floating-ui/react-dom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@floating-ui/react-native";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import * as Floating from "./floating";
|
|
5
|
+
const FloatingOverrideContext = createContext(null);
|
|
6
|
+
const useFloating = /* @__PURE__ */ __name((props) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const context = useContext(FloatingOverrideContext);
|
|
9
|
+
return (_a = context || Floating.useFloating) == null ? void 0 : _a(props);
|
|
10
|
+
}, "useFloating");
|
|
11
|
+
export {
|
|
12
|
+
FloatingOverrideContext,
|
|
13
|
+
useFloating
|
|
14
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/popper",
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
|
+
"sideEffects": true,
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"typings": "types",
|
|
7
|
+
"main": "dist/cjs",
|
|
8
|
+
"module": "dist/esm",
|
|
9
|
+
"module:jsx": "dist/jsx",
|
|
10
|
+
"files": [
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tamagui-build",
|
|
16
|
+
"watch": "tamagui-build --watch",
|
|
17
|
+
"clean": "tamagui-build clean",
|
|
18
|
+
"clean:build": "tamagui-build clean:build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@floating-ui/react-dom": "0.7.0",
|
|
22
|
+
"@floating-ui/react-native": "^0.7.0",
|
|
23
|
+
"@tamagui/compose-refs": "^1.0.0-beta.10",
|
|
24
|
+
"@tamagui/core": "^1.0.0-beta.10",
|
|
25
|
+
"@tamagui/create-context": "^1.0.0-beta.10",
|
|
26
|
+
"@tamagui/stacks": "^1.0.0-beta.10",
|
|
27
|
+
"@tamagui/use-controllable-state": "^1.0.0-beta.10"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "*",
|
|
31
|
+
"react-dom": "*",
|
|
32
|
+
"react-native": "*"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tamagui/build": "^1.0.0-beta.10",
|
|
36
|
+
"@types/react-native": "^0.67.3",
|
|
37
|
+
"react": "*",
|
|
38
|
+
"react-dom": "*",
|
|
39
|
+
"react-native": "*"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SizeTokens } from '@tamagui/core';
|
|
2
|
+
import { SizableStackProps, YStackProps } from '@tamagui/stacks';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { Placement, flip, shift } from './floating';
|
|
6
|
+
declare type ShiftProps = typeof shift extends (options: infer Opts) => void ? Opts : never;
|
|
7
|
+
declare type FlipProps = typeof flip extends (options: infer Opts) => void ? Opts : never;
|
|
8
|
+
export declare const createPopperScope: import("@tamagui/create-context").CreateScope;
|
|
9
|
+
export declare type PopperProps = {
|
|
10
|
+
size?: SizeTokens;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
placement?: Placement;
|
|
13
|
+
stayInFrame?: ShiftProps;
|
|
14
|
+
allowFlip?: FlipProps;
|
|
15
|
+
};
|
|
16
|
+
export declare const Popper: React.FC<PopperProps>;
|
|
17
|
+
declare type PopperAnchorRef = HTMLElement | View;
|
|
18
|
+
export declare type PopperAnchorProps = YStackProps & {
|
|
19
|
+
virtualRef?: React.RefObject<any>;
|
|
20
|
+
};
|
|
21
|
+
export declare const PopperAnchor: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
22
|
+
fullscreen?: boolean | undefined;
|
|
23
|
+
elevation?: SizeTokens | undefined;
|
|
24
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
25
|
+
fullscreen?: boolean | undefined;
|
|
26
|
+
elevation?: SizeTokens | undefined;
|
|
27
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
28
|
+
fullscreen?: boolean | undefined;
|
|
29
|
+
elevation?: SizeTokens | undefined;
|
|
30
|
+
}>> & {
|
|
31
|
+
virtualRef?: React.RefObject<any> | undefined;
|
|
32
|
+
} & React.RefAttributes<PopperAnchorRef>>;
|
|
33
|
+
declare type PopperContentElement = HTMLElement | View;
|
|
34
|
+
export declare type PopperContentProps = SizableStackProps;
|
|
35
|
+
export declare const PopperContent: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
36
|
+
fullscreen?: boolean | undefined;
|
|
37
|
+
elevation?: SizeTokens | undefined;
|
|
38
|
+
}, "size" | "focusable" | "fontFamily" | "disabled" | "transparent" | "hoverable" | "pressable" | "bordered" | "chromeless"> & {
|
|
39
|
+
fontFamily?: unknown;
|
|
40
|
+
hoverable?: boolean | undefined;
|
|
41
|
+
pressable?: boolean | undefined;
|
|
42
|
+
focusable?: boolean | undefined;
|
|
43
|
+
bordered?: boolean | undefined;
|
|
44
|
+
size?: SizeTokens | undefined;
|
|
45
|
+
disabled?: boolean | undefined;
|
|
46
|
+
transparent?: boolean | undefined;
|
|
47
|
+
chromeless?: boolean | undefined;
|
|
48
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
49
|
+
fullscreen?: boolean | undefined;
|
|
50
|
+
elevation?: SizeTokens | undefined;
|
|
51
|
+
}, "size" | "focusable" | "fontFamily" | "disabled" | "transparent" | "hoverable" | "pressable" | "bordered" | "chromeless"> & {
|
|
52
|
+
fontFamily?: unknown;
|
|
53
|
+
hoverable?: boolean | undefined;
|
|
54
|
+
pressable?: boolean | undefined;
|
|
55
|
+
focusable?: boolean | undefined;
|
|
56
|
+
bordered?: boolean | undefined;
|
|
57
|
+
size?: SizeTokens | undefined;
|
|
58
|
+
disabled?: boolean | undefined;
|
|
59
|
+
transparent?: boolean | undefined;
|
|
60
|
+
chromeless?: boolean | undefined;
|
|
61
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
62
|
+
fullscreen?: boolean | undefined;
|
|
63
|
+
elevation?: SizeTokens | undefined;
|
|
64
|
+
}, "size" | "focusable" | "fontFamily" | "disabled" | "transparent" | "hoverable" | "pressable" | "bordered" | "chromeless"> & {
|
|
65
|
+
fontFamily?: unknown;
|
|
66
|
+
hoverable?: boolean | undefined;
|
|
67
|
+
pressable?: boolean | undefined;
|
|
68
|
+
focusable?: boolean | undefined;
|
|
69
|
+
bordered?: boolean | undefined;
|
|
70
|
+
size?: SizeTokens | undefined;
|
|
71
|
+
disabled?: boolean | undefined;
|
|
72
|
+
transparent?: boolean | undefined;
|
|
73
|
+
chromeless?: boolean | undefined;
|
|
74
|
+
}>> & React.RefAttributes<PopperContentElement>>;
|
|
75
|
+
declare type PopperArrowElement = HTMLElement | View;
|
|
76
|
+
export declare type PopperArrowProps = YStackProps & {
|
|
77
|
+
offset?: number;
|
|
78
|
+
size?: SizeTokens;
|
|
79
|
+
};
|
|
80
|
+
export declare const PopperArrow: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
81
|
+
fullscreen?: boolean | undefined;
|
|
82
|
+
elevation?: SizeTokens | undefined;
|
|
83
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
84
|
+
fullscreen?: boolean | undefined;
|
|
85
|
+
elevation?: SizeTokens | undefined;
|
|
86
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "children" | "display"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
87
|
+
fullscreen?: boolean | undefined;
|
|
88
|
+
elevation?: SizeTokens | undefined;
|
|
89
|
+
}>> & {
|
|
90
|
+
offset?: number | undefined;
|
|
91
|
+
size?: SizeTokens | undefined;
|
|
92
|
+
} & React.RefAttributes<PopperArrowElement>>;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=Popper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../src/Popper.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EAMX,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAgB,iBAAiB,EAAU,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACtF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,c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AA;AAmBD,eAAO,MAAM,WAAW;;;;;;;;;;;;4CA4DvB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating.d.ts","sourceRoot":"","sources":["../src/floating.tsx"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating.native.d.ts","sourceRoot":"","sources":["../src/floating.native.tsx"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACtE,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as Floating from './floating';
|
|
3
|
+
export declare type UseFloatingFn = typeof Floating.useFloating;
|
|
4
|
+
declare type UseFloatingProps = UseFloatingFn extends (props: infer Props) => any ? Props : never;
|
|
5
|
+
export declare type UseFloatingResult = ReturnType<UseFloatingFn> & {
|
|
6
|
+
getFloatingProps?: (props: {
|
|
7
|
+
ref: any;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}) => any;
|
|
10
|
+
getReferenceProps?: (props: {
|
|
11
|
+
ref: any;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}) => any;
|
|
14
|
+
};
|
|
15
|
+
export declare const FloatingOverrideContext: import("react").Context<typeof Floating.useFloating | null>;
|
|
16
|
+
export declare const useFloating: (props: UseFloatingProps) => UseFloatingResult;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=useFloating.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFloating.d.ts","sourceRoot":"","sources":["../src/useFloating.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,oBAAY,aAAa,GAAG,OAAO,QAAQ,CAAC,WAAW,CAAA;AAEvD,aAAK,gBAAgB,GAAG,aAAa,SAAS,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,CAAA;AAEzF,oBAAY,iBAAiB,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG;IAC1D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,GAAG,CAAA;IACnE,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,GAAG,CAAA;CACrE,CAAA;AAED,eAAO,MAAM,uBAAuB,6DAA4C,CAAA;AAEhF,eAAO,MAAM,WAAW,UAAW,gBAAgB,KAAG,iBAGrD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFloating.native.d.ts","sourceRoot":"","sources":["../src/useFloating.native.tsx"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFloating.web.d.ts","sourceRoot":"","sources":["../src/useFloating.web.tsx"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|