@tamagui/popover 1.0.1-beta.71 → 1.0.1-beta.74
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/Popover.js +2 -4
- package/dist/cjs/Popover.js.map +1 -1
- package/dist/esm/Popover.js +2 -5
- package/dist/esm/Popover.js.map +1 -1
- package/dist/jsx/Popover.js +2 -5
- package/package.json +11 -11
package/dist/cjs/Popover.js
CHANGED
|
@@ -21,7 +21,6 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
24
|
var __objRest = (source, exclude) => {
|
|
26
25
|
var target = {};
|
|
27
26
|
for (var prop in source)
|
|
@@ -260,7 +259,7 @@ const Popover = (0, import_core.withStaticProperties)((props) => {
|
|
|
260
259
|
defaultProp: defaultOpen || false,
|
|
261
260
|
onChange: onOpenChange
|
|
262
261
|
});
|
|
263
|
-
const useFloatingFn =
|
|
262
|
+
const useFloatingFn = (props2) => {
|
|
264
263
|
const floating = (0, import_react_dom_interactions.useFloating)(__spreadProps(__spreadValues({}, props2), {
|
|
265
264
|
open,
|
|
266
265
|
onOpenChange: setOpen
|
|
@@ -274,7 +273,7 @@ const Popover = (0, import_core.withStaticProperties)((props) => {
|
|
|
274
273
|
getReferenceProps,
|
|
275
274
|
getFloatingProps
|
|
276
275
|
});
|
|
277
|
-
}
|
|
276
|
+
};
|
|
278
277
|
const useFloatingContext = React.useCallback(useFloatingFn, [open]);
|
|
279
278
|
return /* @__PURE__ */ React.createElement(import_popper.FloatingOverrideContext.Provider, {
|
|
280
279
|
value: useFloatingContext
|
|
@@ -301,7 +300,6 @@ Popover.displayName = POPOVER_NAME;
|
|
|
301
300
|
function getState(open) {
|
|
302
301
|
return open ? "open" : "closed";
|
|
303
302
|
}
|
|
304
|
-
__name(getState, "getState");
|
|
305
303
|
// Annotate the CommonJS export names for ESM import in node:
|
|
306
304
|
0 && (module.exports = {
|
|
307
305
|
Popover,
|
package/dist/cjs/Popover.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Popover.tsx"],
|
|
4
4
|
"sourcesContent": ["// adapted from radix-ui popover\n\nimport '@tamagui/polyfill-dev'\n\nimport {\n useDismiss,\n useFloating,\n useFocus,\n useInteractions,\n useRole,\n} from '@floating-ui/react-dom-interactions'\nimport { AnimatePresence } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n Theme,\n composeEventHandlers,\n useId,\n useThemeName,\n withStaticProperties,\n} from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\n// import { DismissableLayer } from '@tamagui/react-dismissable-layer'\n// import { useFocusGuards } from '@tamagui/react-focus-guards'\n// import { FocusScope } from '@tamagui/react-focus-scope'\nimport {\n FloatingOverrideContext,\n Popper,\n PopperAnchor,\n PopperArrow,\n PopperContent,\n PopperContentProps,\n PopperProps,\n UseFloatingFn,\n createPopperScope,\n} from '@tamagui/popper'\nimport { Portal } from '@tamagui/portal'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\n// import { hideOthers } from 'aria-hidden'\nimport * as React from 'react'\nimport { GestureResponderEvent, View } from 'react-native'\n\n// import { RemoveScroll } from 'react-remove-scroll'\n\nconst POPOVER_NAME = 'Popover'\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope }\nconst [createPopoverContext, createPopoverScopeInternal] = createContextScope(POPOVER_NAME, [\n createPopperScope,\n])\nexport const usePopoverScope = createPopperScope()\nexport const createPopoverScope = createPopoverScopeInternal\n\ntype PopoverContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>\n contentId?: string\n open: boolean\n onOpenChange(open: boolean): void\n onOpenToggle(): void\n hasCustomAnchor: boolean\n onCustomAnchorAdd(): void\n onCustomAnchorRemove(): void\n modal: boolean\n}\n\nconst [PopoverProviderInternal, usePopoverInternalContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME)\n\nexport const __PopoverProviderInternal = PopoverProviderInternal\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor'\n\ntype PopoverAnchorElement = HTMLElement | View\nexport type PopoverAnchorProps = YStackProps\n\nexport const PopoverAnchor = React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n (props: ScopedProps<PopoverAnchorProps>, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props\n const context = usePopoverInternalContext(ANCHOR_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context\n\n React.useEffect(() => {\n onCustomAnchorAdd()\n return () => onCustomAnchorRemove()\n }, [onCustomAnchorAdd, onCustomAnchorRemove])\n\n return <PopperAnchor {...popperScope} {...anchorProps} ref={forwardedRef} />\n }\n)\n\nPopoverAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger'\n\ntype PopoverTriggerElement = HTMLElement | View\nexport type PopoverTriggerProps = YStackProps\n\nexport const PopoverTrigger = React.forwardRef<PopoverTriggerElement, PopoverTriggerProps>(\n (props: ScopedProps<PopoverTriggerProps>, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props\n const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef)\n\n const trigger = (\n <YStack\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}\n />\n )\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperAnchor asChild {...popperScope}>\n {trigger}\n </PopperAnchor>\n )\n }\n)\n\nPopoverTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent'\n\nexport interface PopoverContentTypeProps\n extends Omit<PopoverContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom']\n}\n\nexport type PopoverContentProps = PopoverContentTypeProps\n\nexport const PopoverContent = React.forwardRef<PopoverContentTypeElement, PopoverContentProps>(\n (props: ScopedProps<PopoverContentProps>, forwardedRef) => {\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n return context.modal ? (\n <PopoverContentModal {...props} ref={forwardedRef} />\n ) : (\n <PopoverContentNonModal {...props} ref={forwardedRef} />\n )\n }\n)\n\nPopoverContent.displayName = CONTENT_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype RemoveScrollProps = any //React.ComponentProps<typeof RemoveScroll>\ntype PopoverContentTypeElement = PopoverContentImplElement\n\nconst PopoverContentModal = React.forwardRef<PopoverContentTypeElement, PopoverContentTypeProps>(\n (props: ScopedProps<PopoverContentTypeProps>, forwardedRef) => {\n const { allowPinchZoom, ...contentModalProps } = props\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n const contentRef = React.useRef<HTMLDivElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, contentRef)\n const isRightClickOutsideRef = React.useRef(false)\n const themeName = useThemeName()\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n // React.useEffect(() => {\n // const content = contentRef.current\n // if (content) return hideOthers(content)\n // }, [])\n\n const PortalWrapper = context.modal ? Portal : React.Fragment\n\n return (\n <PortalWrapper>\n <Theme name={themeName}>\n {/* <RemoveScroll allowPinchZoom={allowPinchZoom}> */}\n <PopoverContentImpl\n {...contentModalProps}\n ref={composedRefs}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault()\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus()\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n // @ts-expect-error\n const originalEvent = event.detail.originalEvent\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick\n isRightClickOutsideRef.current = isRightClick\n },\n { checkDefaultPrevented: false }\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkDefaultPrevented: false }\n )}\n />\n </Theme>\n {/* </RemoveScroll> */}\n </PortalWrapper>\n )\n }\n)\n\nconst PopoverContentNonModal = React.forwardRef<PopoverContentTypeElement, PopoverContentTypeProps>(\n (props: ScopedProps<PopoverContentTypeProps>, forwardedRef) => {\n const { ...contentNonModalProps } = props\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n const hasInteractedOutsideRef = React.useRef(false)\n const PortalWrapper = context.modal ? Portal : React.Fragment\n\n return (\n <PortalWrapper>\n <PopoverContentImpl\n {...contentNonModalProps}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event)\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus()\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault()\n }\n\n hasInteractedOutsideRef.current = false\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event)\n\n if (!event.defaultPrevented) hasInteractedOutsideRef.current = true\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n //\n // We use `onInteractOutside` as some browsers also\n // focus on pointer down, creating the same issue.\n // @ts-ignore\n const target = event.target as HTMLElement\n const targetIsTrigger = context.triggerRef.current?.contains(target)\n if (targetIsTrigger) event.preventDefault()\n }}\n />\n </PortalWrapper>\n )\n }\n)\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ElementRef<typeof PopperContent>\n\n// TODO\ntype FocusScopeProps = {\n /**\n * Whether focus should be trapped within the FocusScope\n * (default: false)\n */\n trapped?: boolean\n\n /**\n * Event handler called when auto-focusing on mount.\n * Can be prevented.\n */\n onMountAutoFocus?: (event: GestureResponderEvent) => void\n\n /**\n * Event handler called when auto-focusing on unmount.\n * Can be prevented.\n */\n onUnmountAutoFocus?: (event: GestureResponderEvent) => void\n}\n\ntype DismissableLayerProps = {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside the `DismissableLayer`.\n * Users will need to click twice on outside elements to interact with them:\n * Once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean\n\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n\n /**\n * Event handler called when the a pointer event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: GestureResponderEvent) => void\n // onPointerDownOutside?: (event: MouseEvent | TouchEvent) => void\n\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: React.FocusEvent) => void\n\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a pointer event happens outside of the `DismissableLayer` or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: GestureResponderEvent) => void\n // onInteractOutside?: (event: MouseEvent | TouchEvent | React.FocusEvent) => void\n\n /** Callback called when the `DismissableLayer` should be dismissed */\n onDismiss?: () => void\n}\n\nexport interface PopoverContentImplProps\n extends PopperContentProps,\n Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped']\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus']\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus']\n}\n\nconst PopoverContentImpl = React.forwardRef<PopoverContentImplElement, PopoverContentImplProps>(\n (props: ScopedProps<PopoverContentImplProps>, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props\n const context = usePopoverInternalContext(CONTENT_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n\n // Make sure the whole tree has focus guards as our `Popover` may be\n // the last element in the DOM (beacuse of the `Portal`)\n // useFocusGuards()\n\n // <FocusScope\n // asChild\n // loop\n // trapped={trapFocus}\n // onMountAutoFocus={onOpenAutoFocus}\n // onUnmountAutoFocus={onCloseAutoFocus}\n // >\n // <DismissableLayer\n // asChild\n // disableOutsidePointerEvents={disableOutsidePointerEvents}\n // onInteractOutside={onInteractOutside}\n // onEscapeKeyDown={onEscapeKeyDown}\n // onPointerDownOutside={onPointerDownOutside}\n // onFocusOutside={onFocusOutside}\n // onDismiss={() => context.onOpenChange(false)}\n // >\n return (\n <AnimatePresence>\n {!!context.open && (\n <PopperContent\n data-state={getState(context.open)}\n // role=\"dialog\"\n id={context.contentId}\n pointerEvents=\"auto\"\n {...popperScope}\n {...contentProps}\n ref={forwardedRef}\n />\n )}\n </AnimatePresence>\n )\n // </DismissableLayer>\n // </FocusScope>\n }\n)\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose'\n\ntype PopoverCloseElement = HTMLElement | View\nexport type PopoverCloseProps = YStackProps\n\nexport const PopoverClose = React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n (props: ScopedProps<PopoverCloseProps>, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props\n const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover)\n return (\n <YStack\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress, () => context.onOpenChange(false))}\n />\n )\n }\n)\n\nPopoverClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopoverArrow'\n\ntype PopoverArrowElement = HTMLElement | View\nexport type PopoverArrowProps = YStackProps\n\nexport const PopoverArrow = React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n (props: ScopedProps<PopoverArrowProps>, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props\n const popperScope = usePopoverScope(__scopePopover)\n return <PopperArrow {...popperScope} {...arrowProps} ref={forwardedRef} />\n }\n)\n\nPopoverArrow.displayName = ARROW_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nexport type PopoverProps = PopperProps & {\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n modal?: boolean\n}\n\nexport const Popover = withStaticProperties(\n ((props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n ...restProps\n } = props\n const popperScope = usePopoverScope(__scopePopover)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen || false,\n onChange: onOpenChange,\n })\n\n const useFloatingFn: UseFloatingFn = (props) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange: setOpen,\n })\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useFocus(floating.context),\n useRole(floating.context, { role: 'dialog' }),\n useDismiss(floating.context),\n ])\n return {\n ...floating,\n getReferenceProps,\n getFloatingProps,\n } as any\n }\n\n const useFloatingContext = React.useCallback(useFloatingFn, [open])\n\n return (\n <FloatingOverrideContext.Provider value={useFloatingContext}>\n <Popper {...popperScope} {...restProps}>\n <PopoverProviderInternal\n scope={__scopePopover}\n contentId={useId()}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal={modal}\n >\n {children}\n </PopoverProviderInternal>\n </Popper>\n </FloatingOverrideContext.Provider>\n )\n }) as React.FC<PopoverProps>,\n {\n Anchor: PopoverAnchor,\n Arrow: PopoverArrow,\n Trigger: PopoverTrigger,\n Content: PopoverContent,\n Close: PopoverClose,\n }\n)\n\nPopover.displayName = POPOVER_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed'\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAO;AAEP,oCAMO;AACP,8BAAgC;AAChC,0BAAgC;AAChC,kBAMO;AAEP,4BAAmC;AAInC,oBAUO;AACP,oBAAuB;AACvB,oBAAo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Popover.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import "@tamagui/polyfill-dev";
|
|
4
2
|
import {
|
|
5
3
|
useDismiss,
|
|
@@ -214,7 +212,7 @@ const Popover = withStaticProperties((props) => {
|
|
|
214
212
|
defaultProp: defaultOpen || false,
|
|
215
213
|
onChange: onOpenChange
|
|
216
214
|
});
|
|
217
|
-
const useFloatingFn =
|
|
215
|
+
const useFloatingFn = (props2) => {
|
|
218
216
|
const floating = useFloating({
|
|
219
217
|
...props2,
|
|
220
218
|
open,
|
|
@@ -230,7 +228,7 @@ const Popover = withStaticProperties((props) => {
|
|
|
230
228
|
getReferenceProps,
|
|
231
229
|
getFloatingProps
|
|
232
230
|
};
|
|
233
|
-
}
|
|
231
|
+
};
|
|
234
232
|
const useFloatingContext = React.useCallback(useFloatingFn, [open]);
|
|
235
233
|
return /* @__PURE__ */ React.createElement(FloatingOverrideContext.Provider, {
|
|
236
234
|
value: useFloatingContext
|
|
@@ -260,7 +258,6 @@ Popover.displayName = POPOVER_NAME;
|
|
|
260
258
|
function getState(open) {
|
|
261
259
|
return open ? "open" : "closed";
|
|
262
260
|
}
|
|
263
|
-
__name(getState, "getState");
|
|
264
261
|
export {
|
|
265
262
|
Popover,
|
|
266
263
|
PopoverAnchor,
|
package/dist/esm/Popover.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Popover.tsx"],
|
|
4
4
|
"sourcesContent": ["// adapted from radix-ui popover\n\nimport '@tamagui/polyfill-dev'\n\nimport {\n useDismiss,\n useFloating,\n useFocus,\n useInteractions,\n useRole,\n} from '@floating-ui/react-dom-interactions'\nimport { AnimatePresence } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n Theme,\n composeEventHandlers,\n useId,\n useThemeName,\n withStaticProperties,\n} from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\n// import { DismissableLayer } from '@tamagui/react-dismissable-layer'\n// import { useFocusGuards } from '@tamagui/react-focus-guards'\n// import { FocusScope } from '@tamagui/react-focus-scope'\nimport {\n FloatingOverrideContext,\n Popper,\n PopperAnchor,\n PopperArrow,\n PopperContent,\n PopperContentProps,\n PopperProps,\n UseFloatingFn,\n createPopperScope,\n} from '@tamagui/popper'\nimport { Portal } from '@tamagui/portal'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\n// import { hideOthers } from 'aria-hidden'\nimport * as React from 'react'\nimport { GestureResponderEvent, View } from 'react-native'\n\n// import { RemoveScroll } from 'react-remove-scroll'\n\nconst POPOVER_NAME = 'Popover'\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope }\nconst [createPopoverContext, createPopoverScopeInternal] = createContextScope(POPOVER_NAME, [\n createPopperScope,\n])\nexport const usePopoverScope = createPopperScope()\nexport const createPopoverScope = createPopoverScopeInternal\n\ntype PopoverContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>\n contentId?: string\n open: boolean\n onOpenChange(open: boolean): void\n onOpenToggle(): void\n hasCustomAnchor: boolean\n onCustomAnchorAdd(): void\n onCustomAnchorRemove(): void\n modal: boolean\n}\n\nconst [PopoverProviderInternal, usePopoverInternalContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME)\n\nexport const __PopoverProviderInternal = PopoverProviderInternal\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor'\n\ntype PopoverAnchorElement = HTMLElement | View\nexport type PopoverAnchorProps = YStackProps\n\nexport const PopoverAnchor = React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n (props: ScopedProps<PopoverAnchorProps>, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props\n const context = usePopoverInternalContext(ANCHOR_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context\n\n React.useEffect(() => {\n onCustomAnchorAdd()\n return () => onCustomAnchorRemove()\n }, [onCustomAnchorAdd, onCustomAnchorRemove])\n\n return <PopperAnchor {...popperScope} {...anchorProps} ref={forwardedRef} />\n }\n)\n\nPopoverAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger'\n\ntype PopoverTriggerElement = HTMLElement | View\nexport type PopoverTriggerProps = YStackProps\n\nexport const PopoverTrigger = React.forwardRef<PopoverTriggerElement, PopoverTriggerProps>(\n (props: ScopedProps<PopoverTriggerProps>, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props\n const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef)\n\n const trigger = (\n <YStack\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}\n />\n )\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperAnchor asChild {...popperScope}>\n {trigger}\n </PopperAnchor>\n )\n }\n)\n\nPopoverTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent'\n\nexport interface PopoverContentTypeProps\n extends Omit<PopoverContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom']\n}\n\nexport type PopoverContentProps = PopoverContentTypeProps\n\nexport const PopoverContent = React.forwardRef<PopoverContentTypeElement, PopoverContentProps>(\n (props: ScopedProps<PopoverContentProps>, forwardedRef) => {\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n return context.modal ? (\n <PopoverContentModal {...props} ref={forwardedRef} />\n ) : (\n <PopoverContentNonModal {...props} ref={forwardedRef} />\n )\n }\n)\n\nPopoverContent.displayName = CONTENT_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype RemoveScrollProps = any //React.ComponentProps<typeof RemoveScroll>\ntype PopoverContentTypeElement = PopoverContentImplElement\n\nconst PopoverContentModal = React.forwardRef<PopoverContentTypeElement, PopoverContentTypeProps>(\n (props: ScopedProps<PopoverContentTypeProps>, forwardedRef) => {\n const { allowPinchZoom, ...contentModalProps } = props\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n const contentRef = React.useRef<HTMLDivElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, contentRef)\n const isRightClickOutsideRef = React.useRef(false)\n const themeName = useThemeName()\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n // React.useEffect(() => {\n // const content = contentRef.current\n // if (content) return hideOthers(content)\n // }, [])\n\n const PortalWrapper = context.modal ? Portal : React.Fragment\n\n return (\n <PortalWrapper>\n <Theme name={themeName}>\n {/* <RemoveScroll allowPinchZoom={allowPinchZoom}> */}\n <PopoverContentImpl\n {...contentModalProps}\n ref={composedRefs}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault()\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus()\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n // @ts-expect-error\n const originalEvent = event.detail.originalEvent\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick\n isRightClickOutsideRef.current = isRightClick\n },\n { checkDefaultPrevented: false }\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkDefaultPrevented: false }\n )}\n />\n </Theme>\n {/* </RemoveScroll> */}\n </PortalWrapper>\n )\n }\n)\n\nconst PopoverContentNonModal = React.forwardRef<PopoverContentTypeElement, PopoverContentTypeProps>(\n (props: ScopedProps<PopoverContentTypeProps>, forwardedRef) => {\n const { ...contentNonModalProps } = props\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n const hasInteractedOutsideRef = React.useRef(false)\n const PortalWrapper = context.modal ? Portal : React.Fragment\n\n return (\n <PortalWrapper>\n <PopoverContentImpl\n {...contentNonModalProps}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event)\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus()\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault()\n }\n\n hasInteractedOutsideRef.current = false\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event)\n\n if (!event.defaultPrevented) hasInteractedOutsideRef.current = true\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n //\n // We use `onInteractOutside` as some browsers also\n // focus on pointer down, creating the same issue.\n // @ts-ignore\n const target = event.target as HTMLElement\n const targetIsTrigger = context.triggerRef.current?.contains(target)\n if (targetIsTrigger) event.preventDefault()\n }}\n />\n </PortalWrapper>\n )\n }\n)\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ElementRef<typeof PopperContent>\n\n// TODO\ntype FocusScopeProps = {\n /**\n * Whether focus should be trapped within the FocusScope\n * (default: false)\n */\n trapped?: boolean\n\n /**\n * Event handler called when auto-focusing on mount.\n * Can be prevented.\n */\n onMountAutoFocus?: (event: GestureResponderEvent) => void\n\n /**\n * Event handler called when auto-focusing on unmount.\n * Can be prevented.\n */\n onUnmountAutoFocus?: (event: GestureResponderEvent) => void\n}\n\ntype DismissableLayerProps = {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside the `DismissableLayer`.\n * Users will need to click twice on outside elements to interact with them:\n * Once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean\n\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n\n /**\n * Event handler called when the a pointer event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: GestureResponderEvent) => void\n // onPointerDownOutside?: (event: MouseEvent | TouchEvent) => void\n\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: React.FocusEvent) => void\n\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a pointer event happens outside of the `DismissableLayer` or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: GestureResponderEvent) => void\n // onInteractOutside?: (event: MouseEvent | TouchEvent | React.FocusEvent) => void\n\n /** Callback called when the `DismissableLayer` should be dismissed */\n onDismiss?: () => void\n}\n\nexport interface PopoverContentImplProps\n extends PopperContentProps,\n Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped']\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus']\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus']\n}\n\nconst PopoverContentImpl = React.forwardRef<PopoverContentImplElement, PopoverContentImplProps>(\n (props: ScopedProps<PopoverContentImplProps>, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props\n const context = usePopoverInternalContext(CONTENT_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n\n // Make sure the whole tree has focus guards as our `Popover` may be\n // the last element in the DOM (beacuse of the `Portal`)\n // useFocusGuards()\n\n // <FocusScope\n // asChild\n // loop\n // trapped={trapFocus}\n // onMountAutoFocus={onOpenAutoFocus}\n // onUnmountAutoFocus={onCloseAutoFocus}\n // >\n // <DismissableLayer\n // asChild\n // disableOutsidePointerEvents={disableOutsidePointerEvents}\n // onInteractOutside={onInteractOutside}\n // onEscapeKeyDown={onEscapeKeyDown}\n // onPointerDownOutside={onPointerDownOutside}\n // onFocusOutside={onFocusOutside}\n // onDismiss={() => context.onOpenChange(false)}\n // >\n return (\n <AnimatePresence>\n {!!context.open && (\n <PopperContent\n data-state={getState(context.open)}\n // role=\"dialog\"\n id={context.contentId}\n pointerEvents=\"auto\"\n {...popperScope}\n {...contentProps}\n ref={forwardedRef}\n />\n )}\n </AnimatePresence>\n )\n // </DismissableLayer>\n // </FocusScope>\n }\n)\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose'\n\ntype PopoverCloseElement = HTMLElement | View\nexport type PopoverCloseProps = YStackProps\n\nexport const PopoverClose = React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n (props: ScopedProps<PopoverCloseProps>, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props\n const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover)\n return (\n <YStack\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress, () => context.onOpenChange(false))}\n />\n )\n }\n)\n\nPopoverClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopoverArrow'\n\ntype PopoverArrowElement = HTMLElement | View\nexport type PopoverArrowProps = YStackProps\n\nexport const PopoverArrow = React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n (props: ScopedProps<PopoverArrowProps>, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props\n const popperScope = usePopoverScope(__scopePopover)\n return <PopperArrow {...popperScope} {...arrowProps} ref={forwardedRef} />\n }\n)\n\nPopoverArrow.displayName = ARROW_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nexport type PopoverProps = PopperProps & {\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n modal?: boolean\n}\n\nexport const Popover = withStaticProperties(\n ((props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n ...restProps\n } = props\n const popperScope = usePopoverScope(__scopePopover)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen || false,\n onChange: onOpenChange,\n })\n\n const useFloatingFn: UseFloatingFn = (props) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange: setOpen,\n })\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useFocus(floating.context),\n useRole(floating.context, { role: 'dialog' }),\n useDismiss(floating.context),\n ])\n return {\n ...floating,\n getReferenceProps,\n getFloatingProps,\n } as any\n }\n\n const useFloatingContext = React.useCallback(useFloatingFn, [open])\n\n return (\n <FloatingOverrideContext.Provider value={useFloatingContext}>\n <Popper {...popperScope} {...restProps}>\n <PopoverProviderInternal\n scope={__scopePopover}\n contentId={useId()}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal={modal}\n >\n {children}\n </PopoverProviderInternal>\n </Popper>\n </FloatingOverrideContext.Provider>\n )\n }) as React.FC<PopoverProps>,\n {\n Anchor: PopoverAnchor,\n Arrow: PopoverArrow,\n Trigger: PopoverTrigger,\n Content: PopoverContent,\n Close: PopoverClose,\n }\n)\n\nPopover.displayName = POPOVER_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed'\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AACA;AACA;AAEA;AAKA,MAAM,eAAe;AAGrB,MAAM,CAAC,sBAAsB,8BAA8B,mBAAmB,cAAc;AAAA,EAC1F;AACF,CAAC;AACM,MAAM,kBAAkB,kBAAkB;AAC1C,MAAM,qBAAqB;AAclC,MAAM,CAAC,yBAAyB,6BAC9B,qBAA0C,YAAY;AAEjD,MAAM,4BAA4B;AAMzC,MAAM,cAAc;AAKb,MAAM,gBAAgB,MAAM,WACjC,CAAC,OAAwC,iBAAiB;AACxD,QAAM,EAAE,mBAAmB,gBAAgB;AAC3C,QAAM,UAAU,0BAA0B,aAAa,cAAc;AACrE,QAAM,cAAc,gBAAgB,cAAc;AAClD,QAAM,EAAE,mBAAmB,yBAAyB;AAEpD,QAAM,UAAU,MAAM;AACpB,sBAAkB;AAClB,WAAO,MAAM,qBAAqB;AAAA,EACpC,GAAG,CAAC,mBAAmB,oBAAoB,CA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,CAAC,aAAa,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC;AAAA,IACjF;AAAA,IACA,mBAAmB,MAAM,YAAY,MAAM,mBAAmB,IAAI,GAAG,CAAC,CAAC;AAAA,IACvE,sBAAsB,MAAM,YAAY,MAAM,mBAAmB,KAAK,GAAG,CAAC,CAAC;AAAA,IAC3E;AAAA,KAEC,QACH,CACF,CACF;AAEJ,GACA;AAAA,EACE,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,CACF;AAEA,QAAQ,cAAc;AAItB,kBAAkB,MAAe;AAC/B,SAAO,OAAO,SAAS;AACzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Popover.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import "@tamagui/polyfill-dev";
|
|
4
2
|
import {
|
|
5
3
|
useDismiss,
|
|
@@ -161,7 +159,7 @@ const Popover = withStaticProperties((props) => {
|
|
|
161
159
|
defaultProp: defaultOpen || false,
|
|
162
160
|
onChange: onOpenChange
|
|
163
161
|
});
|
|
164
|
-
const useFloatingFn =
|
|
162
|
+
const useFloatingFn = (props2) => {
|
|
165
163
|
const floating = useFloating({
|
|
166
164
|
...props2,
|
|
167
165
|
open,
|
|
@@ -177,7 +175,7 @@ const Popover = withStaticProperties((props) => {
|
|
|
177
175
|
getReferenceProps,
|
|
178
176
|
getFloatingProps
|
|
179
177
|
};
|
|
180
|
-
}
|
|
178
|
+
};
|
|
181
179
|
const useFloatingContext = React.useCallback(useFloatingFn, [open]);
|
|
182
180
|
return <FloatingOverrideContext.Provider value={useFloatingContext}><Popper {...popperScope} {...restProps}><PopoverProviderInternal scope={__scopePopover} contentId={useId()} triggerRef={triggerRef} open={open} onOpenChange={setOpen} onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])} hasCustomAnchor={hasCustomAnchor} onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])} onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])} modal={modal}>{children}</PopoverProviderInternal></Popper></FloatingOverrideContext.Provider>;
|
|
183
181
|
}, {
|
|
@@ -191,7 +189,6 @@ Popover.displayName = POPOVER_NAME;
|
|
|
191
189
|
function getState(open) {
|
|
192
190
|
return open ? "open" : "closed";
|
|
193
191
|
}
|
|
194
|
-
__name(getState, "getState");
|
|
195
192
|
export {
|
|
196
193
|
Popover,
|
|
197
194
|
PopoverAnchor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/popover",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.74",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@floating-ui/react-dom-interactions": "^0.5.0",
|
|
25
|
-
"@tamagui/animate-presence": "^1.0.1-beta.
|
|
26
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
27
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
28
|
-
"@tamagui/create-context": "^1.0.1-beta.
|
|
29
|
-
"@tamagui/polyfill-dev": "^1.0.1-beta.
|
|
30
|
-
"@tamagui/popper": "^1.0.1-beta.
|
|
31
|
-
"@tamagui/portal": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/stacks": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/use-controllable-state": "^1.0.1-beta.
|
|
25
|
+
"@tamagui/animate-presence": "^1.0.1-beta.74",
|
|
26
|
+
"@tamagui/compose-refs": "^1.0.1-beta.74",
|
|
27
|
+
"@tamagui/core": "^1.0.1-beta.74",
|
|
28
|
+
"@tamagui/create-context": "^1.0.1-beta.74",
|
|
29
|
+
"@tamagui/polyfill-dev": "^1.0.1-beta.74",
|
|
30
|
+
"@tamagui/popper": "^1.0.1-beta.74",
|
|
31
|
+
"@tamagui/portal": "^1.0.1-beta.74",
|
|
32
|
+
"@tamagui/stacks": "^1.0.1-beta.74",
|
|
33
|
+
"@tamagui/use-controllable-state": "^1.0.1-beta.74"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "*",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-native": "*"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
41
|
+
"@tamagui/build": "^1.0.1-beta.74",
|
|
42
42
|
"@types/react-dom": "^18.0.3",
|
|
43
43
|
"@types/react-native": "^0.67.3",
|
|
44
44
|
"react": "*",
|