@tamagui/collapsible 1.0.1-beta.78 → 1.0.1-beta.79
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/jsx/Collapsible.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Collapsible.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n Stack,\n StackProps,\n TamaguiElement,\n composeEventHandlers,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { useId } from '@tamagui/core'\nimport { createContextScope } from '@tamagui/create-context'\nimport type { Scope } from '@tamagui/create-context'\n// import { Presence } from '@tamagui/react-presence'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\n/* -------------------------------------------------------------------------------------------------\n * Collapsible\n * -----------------------------------------------------------------------------------------------*/\n\nconst COLLAPSIBLE_NAME = 'Collapsible'\n\ntype ScopedProps<P> = P & { __scopeCollapsible?: Scope }\nconst [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME)\n\ntype CollapsibleContextValue = {\n contentId: string\n disabled?: boolean\n open: boolean\n onOpenToggle(): void\n}\n\nconst [CollapsibleProvider, useCollapsibleContext] =\n createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME)\n\ntype CollapsibleElement = TamaguiElement\ninterface CollapsibleProps extends StackProps {\n defaultOpen?: boolean\n open?: boolean\n disabled?: boolean\n onOpenChange?(open: boolean): void\n}\n\nconst Collapsible = React.forwardRef<CollapsibleElement, CollapsibleProps>(\n (props: ScopedProps<CollapsibleProps>, forwardedRef) => {\n const {\n __scopeCollapsible,\n open: openProp,\n defaultOpen,\n disabled,\n onOpenChange,\n ...collapsibleProps\n } = props\n\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen || false,\n onChange: onOpenChange,\n })\n\n return (\n <CollapsibleProvider\n scope={__scopeCollapsible}\n disabled={disabled}\n contentId={useId() || ''}\n open={open}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n >\n <Stack\n data-state={getState(open)}\n data-disabled={disabled ? '' : undefined}\n {...collapsibleProps}\n // @ts-expect-error\n ref={forwardedRef}\n />\n </CollapsibleProvider>\n )\n }\n)\n\nCollapsible.displayName = COLLAPSIBLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * CollapsibleTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'CollapsibleTrigger'\n\ntype CollapsibleTriggerElement = TamaguiElement\ninterface CollapsibleTriggerProps extends StackProps {}\n\nconst CollapsibleTrigger = React.forwardRef<CollapsibleTriggerElement, CollapsibleTriggerProps>(\n (props: ScopedProps<CollapsibleTriggerProps>, forwardedRef) => {\n const { __scopeCollapsible, ...triggerProps } = props\n const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible)\n return (\n <Stack\n type=\"button\"\n aria-controls={context.contentId}\n aria-expanded={context.open || false}\n data-state={getState(context.open)}\n data-disabled={context.disabled ? '' : undefined}\n disabled={context.disabled}\n {...triggerProps}\n // @ts-expect-error\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}\n />\n )\n }\n)\n\nCollapsibleTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * CollapsibleContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'CollapsibleContent'\n\ntype CollapsibleContentElement = CollapsibleContentImplElement\ninterface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true\n}\n\nconst CollapsibleContent = React.forwardRef<CollapsibleContentElement, CollapsibleContentProps>(\n (props: ScopedProps<CollapsibleContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props\n const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible)\n return (\n // <Presence present={forceMount || context.open}>\n <>\n {({ present }) => (\n <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />\n )}\n </>\n // </Presence>\n )\n }\n)\n\nCollapsibleContent.displayName = CONTENT_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype CollapsibleContentImplElement = TamaguiElement\ninterface CollapsibleContentImplProps extends StackProps {\n present: boolean\n}\n\nconst CollapsibleContentImpl = React.forwardRef<\n CollapsibleContentImplElement,\n CollapsibleContentImplProps\n>((props: ScopedProps<CollapsibleContentImplProps>, forwardedRef) => {\n const { __scopeCollapsible, present, children, ...contentProps } = props\n const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible)\n const [isPresent, setIsPresent] = React.useState(present)\n const ref = React.useRef<CollapsibleContentImplElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const heightRef = React.useRef<number | undefined>(0)\n const height = heightRef.current\n const widthRef = React.useRef<number | undefined>(0)\n const width = widthRef.current\n // when opening we want it to immediately open to retrieve dimensions\n // when closing we delay `present` to retrieve dimensions before closing\n const isOpen = context.open || isPresent\n const isMountAnimationPreventedRef = React.useRef(isOpen)\n const originalStylesRef = React.useRef<Record<string, string>>()\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false))\n return () => cancelAnimationFrame(rAF)\n }, [])\n\n // useIsomorphicLayoutEffect(() => {\n // const node = ref.current\n // if (node) {\n // originalStylesRef.current = originalStylesRef.current || {\n // transitionDuration: node.style.transitionDuration,\n // animationDuration: node.style.animationDuration,\n // animationFillMode: node.style.animationFillMode,\n // }\n // // block any animations/transitions so the element renders at its full dimensions\n // node.style.transitionDuration = '0s'\n // node.style.animationDuration = '0s'\n // node.style.animationFillMode = 'none'\n\n // // get width and height from full dimensions\n // const rect = node.getBoundingClientRect()\n // heightRef.current = rect.height\n // widthRef.current = rect.width\n\n // // kick off any animations/transitions that were originally set up if it isn't the initial mount\n // if (!isMountAnimationPreventedRef.current) {\n // node.style.transitionDuration = originalStylesRef.current.transitionDuration\n // node.style.animationDuration = originalStylesRef.current.animationDuration\n // node.style.animationFillMode = originalStylesRef.current.animationFillMode\n // }\n\n // setIsPresent(present)\n // }\n // /**\n // * depends on `context.open` because it will change to `false`\n // * when a close is triggered but `present` will be `false` on\n // * animation end (so when close finishes). This allows us to\n // * retrieve the dimensions *before* closing.\n // */\n // }, [context.open, present])\n\n return (\n <Stack\n data-state={getState(context.open)}\n data-disabled={context.disabled ? '' : undefined}\n id={context.contentId}\n hidden={!isOpen}\n {...contentProps}\n // @ts-expect-error\n ref={composedRefs}\n // style={{\n // [`--radix-collapsible-content-height` as any]: height ? `${height}px` : undefined,\n // [`--radix-collapsible-content-width` as any]: width ? `${width}px` : undefined,\n // ...props.style,\n // }}\n >\n {isOpen && children}\n </Stack>\n )\n})\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed'\n}\n\nconst Root = Collapsible\nconst Trigger = CollapsibleTrigger\nconst Content = CollapsibleContent\n\nexport {\n createCollapsibleScope,\n //\n Collapsible,\n CollapsibleTrigger,\n CollapsibleContent,\n //\n Root,\n Trigger,\n Content,\n}\nexport type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps }\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AAAA;AAAA;AAAA;AAOA;AACA;AAGA;AACA;AAMA,MAAM,mBAAmB;AAGzB,MAAM,CAAC,0BAA0B,0BAA0B,mBAAmB,gBAAgB;AAS9F,MAAM,CAAC,qBAAqB,yBAC1B,yBAAkD,gBAAgB;AAUpE,MAAM,cAAc,MAAM,WACxB,CAAC,OAAsC,iBAAiB;AACtD,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,MACD;AAEJ,QAAM,CAAC,MAAM,WAAW,qBAAqB;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,SAAS,OAAO;AACxD,QAAM,MAAM,MAAM,OAAsC,IAAI;AAC5D,QAAM,eAAe,gBAAgB,cAAc,GAAG;AACtD,QAAM,YAAY,MAAM,OAA2B,CAAC;AACpD,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,MAAM,OAA2B,CAAC;AACnD,QAAM,QAAQ,SAAS;AAGvB,QAAM,SAAS,QAAQ,QAAQ;AAC/B,QAAM,+BAA+B,MAAM,OAAO,MAAM;AACxD,QAAM,oBAAoB,MAAM,OAA+B;AAE/D,QAAM,UAAU,MAAM;AACpB,UAAM,MAAM,sBAAsB,MAAO,6BAA6B,UAAU,KAAM;AACtF,WAAO,MAAM,qBAAqB,GAAG;AAAA,EACvC,GAAG,CAAC,CAAC;AAqCL,SACE,CAAC,MACC,YAAY,SAAS,QAAQ,IAAI,GACjC,eAAe,QAAQ,WAAW,KAAK,QACvC,IAAI,QAAQ,WACZ,QAAQ,CAAC,YACL,cAEJ,KAAK,eAOJ,UAAU,SACb,EAfC;AAiBL,CAAC;AAID,kBAAkB,MAAgB;AAChC,SAAO,OAAO,SAAS;AACzB;AAEA,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/jsx/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/collapsible",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.79",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@gorhom/bottom-sheet": "^4.3.1",
|
|
21
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
22
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
23
|
-
"@tamagui/create-context": "^1.0.1-beta.
|
|
24
|
-
"@tamagui/polyfill-dev": "^1.0.1-beta.
|
|
25
|
-
"@tamagui/stacks": "^1.0.1-beta.
|
|
26
|
-
"@tamagui/use-controllable-state": "^1.0.1-beta.
|
|
21
|
+
"@tamagui/compose-refs": "^1.0.1-beta.79",
|
|
22
|
+
"@tamagui/core": "^1.0.1-beta.79",
|
|
23
|
+
"@tamagui/create-context": "^1.0.1-beta.79",
|
|
24
|
+
"@tamagui/polyfill-dev": "^1.0.1-beta.79",
|
|
25
|
+
"@tamagui/stacks": "^1.0.1-beta.79",
|
|
26
|
+
"@tamagui/use-controllable-state": "^1.0.1-beta.79",
|
|
27
27
|
"react-native-reanimated": "~2.8.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-native-gesture-handler": "*"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
35
|
+
"@tamagui/build": "^1.0.1-beta.79",
|
|
36
36
|
"react": "*",
|
|
37
37
|
"react-dom": "*",
|
|
38
38
|
"react-native-gesture-handler": "*"
|