@tamagui/linear-gradient 1.0.4
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/BubbleSelect.js +44 -0
- package/dist/cjs/BubbleSelect.js.map +7 -0
- package/dist/cjs/LinearGradient.js +74 -0
- package/dist/cjs/LinearGradient.js.map +7 -0
- package/dist/cjs/Select.js +480 -0
- package/dist/cjs/Select.js.map +7 -0
- package/dist/cjs/SelectContent.js +76 -0
- package/dist/cjs/SelectContent.js.map +7 -0
- package/dist/cjs/SelectContent.native.js +31 -0
- package/dist/cjs/SelectContent.native.js.map +7 -0
- package/dist/cjs/SelectImpl.js +301 -0
- package/dist/cjs/SelectImpl.js.map +7 -0
- package/dist/cjs/SelectImpl.native.js +37 -0
- package/dist/cjs/SelectImpl.native.js.map +7 -0
- package/dist/cjs/SelectScrollButton.js +161 -0
- package/dist/cjs/SelectScrollButton.js.map +7 -0
- package/dist/cjs/SelectScrollButton.native.js +32 -0
- package/dist/cjs/SelectScrollButton.native.js.map +7 -0
- package/dist/cjs/SelectViewport.js +126 -0
- package/dist/cjs/SelectViewport.js.map +7 -0
- package/dist/cjs/SelectViewport.native.js +62 -0
- package/dist/cjs/SelectViewport.native.js.map +7 -0
- package/dist/cjs/constants.js +47 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/context.js +49 -0
- package/dist/cjs/context.js.map +7 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/linear-gradient.js +29 -0
- package/dist/cjs/linear-gradient.js.map +7 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/useSelectBreakpointActive.js +39 -0
- package/dist/cjs/useSelectBreakpointActive.js.map +7 -0
- package/dist/esm/BubbleSelect.js +25 -0
- package/dist/esm/BubbleSelect.js.map +7 -0
- package/dist/esm/LinearGradient.js +51 -0
- package/dist/esm/LinearGradient.js.map +7 -0
- package/dist/esm/Select.js +452 -0
- package/dist/esm/Select.js.map +7 -0
- package/dist/esm/SelectContent.js +52 -0
- package/dist/esm/SelectContent.js.map +7 -0
- package/dist/esm/SelectContent.native.js +7 -0
- package/dist/esm/SelectContent.native.js.map +7 -0
- package/dist/esm/SelectImpl.js +286 -0
- package/dist/esm/SelectImpl.js.map +7 -0
- package/dist/esm/SelectImpl.native.js +13 -0
- package/dist/esm/SelectImpl.native.js.map +7 -0
- package/dist/esm/SelectScrollButton.js +130 -0
- package/dist/esm/SelectScrollButton.js.map +7 -0
- package/dist/esm/SelectScrollButton.native.js +7 -0
- package/dist/esm/SelectScrollButton.native.js.map +7 -0
- package/dist/esm/SelectViewport.js +95 -0
- package/dist/esm/SelectViewport.js.map +7 -0
- package/dist/esm/SelectViewport.native.js +32 -0
- package/dist/esm/SelectViewport.native.js.map +7 -0
- package/dist/esm/constants.js +17 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/context.js +21 -0
- package/dist/esm/context.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/linear-gradient.js +5 -0
- package/dist/esm/linear-gradient.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/useSelectBreakpointActive.js +14 -0
- package/dist/esm/useSelectBreakpointActive.js.map +7 -0
- package/dist/jsx/BubbleSelect.js +25 -0
- package/dist/jsx/BubbleSelect.js.map +7 -0
- package/dist/jsx/LinearGradient.js +39 -0
- package/dist/jsx/LinearGradient.js.map +7 -0
- package/dist/jsx/Select.js +326 -0
- package/dist/jsx/Select.js.map +7 -0
- package/dist/jsx/SelectContent.js +30 -0
- package/dist/jsx/SelectContent.js.map +7 -0
- package/dist/jsx/SelectContent.native.js +7 -0
- package/dist/jsx/SelectContent.native.js.map +7 -0
- package/dist/jsx/SelectImpl.js +259 -0
- package/dist/jsx/SelectImpl.js.map +7 -0
- package/dist/jsx/SelectImpl.native.js +10 -0
- package/dist/jsx/SelectImpl.native.js.map +7 -0
- package/dist/jsx/SelectScrollButton.js +103 -0
- package/dist/jsx/SelectScrollButton.js.map +7 -0
- package/dist/jsx/SelectScrollButton.native.js +7 -0
- package/dist/jsx/SelectScrollButton.native.js.map +7 -0
- package/dist/jsx/SelectViewport.js +73 -0
- package/dist/jsx/SelectViewport.js.map +7 -0
- package/dist/jsx/SelectViewport.native.js +18 -0
- package/dist/jsx/SelectViewport.native.js.map +7 -0
- package/dist/jsx/constants.js +17 -0
- package/dist/jsx/constants.js.map +7 -0
- package/dist/jsx/context.js +15 -0
- package/dist/jsx/context.js.map +7 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/linear-gradient.js +5 -0
- package/dist/jsx/linear-gradient.js.map +7 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/types.js.map +7 -0
- package/dist/jsx/useSelectBreakpointActive.js +14 -0
- package/dist/jsx/useSelectBreakpointActive.js.map +7 -0
- package/package.json +43 -0
- package/src/LinearGradient.tsx +64 -0
- package/src/index.ts +1 -0
- package/src/linear-gradient.d.ts +3 -0
- package/src/linear-gradient.d.ts.map +1 -0
- package/src/linear-gradient.ts +2 -0
- package/types/LinearGradient.d.ts +10 -0
- package/types/index.d.ts +2 -0
- package/types/linear-gradient.d.ts +3 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectScrollButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import { autoUpdate, offset, useFloating } from '@floating-ui/react-dom-interactions'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { TamaguiElement, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { useSelectContext } from './context'\nimport {\n ScopedProps,\n SelectScrollButtonImplProps,\n SelectScrollButtonProps,\n} from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollUpButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton'\n\nexport const SelectScrollUpButton = React.forwardRef<\n TamaguiElement,\n SelectScrollButtonProps\n>((props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_UP_BUTTON_NAME}\n {...props}\n dir=\"up\"\n ref={forwardedRef}\n />\n )\n})\n\nSelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollDownButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton'\n\nexport const SelectScrollDownButton = React.forwardRef<\n TamaguiElement,\n SelectScrollButtonProps\n>((props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_DOWN_BUTTON_NAME}\n {...props}\n dir=\"down\"\n ref={forwardedRef}\n />\n )\n})\n\nSelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME\n\ntype SelectScrollButtonImplElement = TamaguiElement\n\nconst SelectScrollButtonImpl = React.memo(\n React.forwardRef<SelectScrollButtonImplElement, SelectScrollButtonImplProps>(\n (props: ScopedProps<SelectScrollButtonImplProps>, forwardedRef) => {\n const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props\n const {\n floatingRef,\n forceUpdate,\n open,\n fallback,\n setScrollTop,\n setInnerOffset,\n ...context\n } = useSelectContext(componentName, __scopeSelect)\n\n const [element, setElement] = React.useState<HTMLElement | null>(null)\n const statusRef = React.useRef<'idle' | 'active'>('idle')\n const isVisible = context[dir === 'down' ? 'canScrollDown' : 'canScrollUp']\n const frameRef = React.useRef<any>()\n\n const { x, y, reference, floating, strategy, update, refs } = useFloating({\n strategy: 'fixed',\n placement: dir === 'up' ? 'top' : 'bottom',\n middleware: [offset(({ rects }) => -rects.floating.height)],\n whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true }),\n })\n\n const composedRef = useComposedRefs(forwardedRef, floating)\n\n if (floatingRef) {\n if (open) {\n if (element !== floatingRef.current) {\n setElement(floatingRef.current)\n reference(floatingRef.current)\n requestAnimationFrame(update)\n }\n } else {\n cancelAnimationFrame(frameRef.current)\n }\n }\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n cancelAnimationFrame(frameRef.current)\n }\n }, [])\n\n if (!(isVisible && floatingRef)) {\n return null\n }\n\n const onScroll = (amount: number) => {\n if (fallback) {\n if (refs.floating.current) {\n refs.floating.current.scrollTop -= amount\n flushSync(() => setScrollTop!(refs.floating.current?.scrollTop ?? 0))\n }\n } else {\n flushSync(() => setInnerOffset!((value) => value - amount))\n }\n }\n\n return (\n <YStack\n ref={composedRef}\n componentName={componentName}\n aria-hidden\n {...scrollIndicatorProps}\n zIndex={1000}\n // @ts-expect-error\n position={strategy}\n left={x || 0}\n top={y || 0}\n width={`calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`}\n onPointerEnter={() => {\n statusRef.current = 'active'\n let prevNow = Date.now()\n\n function frame() {\n if (element) {\n const currentNow = Date.now()\n const msElapsed = currentNow - prevNow\n prevNow = currentNow\n\n const pixelsToScroll = msElapsed / 2\n\n const remainingPixels =\n dir === 'up'\n ? element.scrollTop\n : element.scrollHeight - element.clientHeight - element.scrollTop\n\n const scrollRemaining =\n dir === 'up'\n ? element.scrollTop - pixelsToScroll > 0\n : element.scrollTop + pixelsToScroll <\n element.scrollHeight - element.clientHeight\n\n onScroll(\n dir === 'up'\n ? Math.min(pixelsToScroll, remainingPixels)\n : Math.max(-pixelsToScroll, -remainingPixels)\n )\n\n if (scrollRemaining) {\n frameRef.current = requestAnimationFrame(frame)\n }\n }\n }\n\n cancelAnimationFrame(frameRef.current)\n frameRef.current = requestAnimationFrame(frame)\n }}\n onPointerLeave={() => {\n statusRef.current = 'idle'\n cancelAnimationFrame(frameRef.current)\n }}\n />\n )\n }\n )\n)\n"],
|
|
5
|
+
"mappings": "AAyBI;AAzBJ,SAAS,YAAY,QAAQ,mBAAmB;AAChD,SAAS,uBAAuB;AAChC,SAAyB,iCAAiC;AAC1D,SAAS,cAAc;AACvB,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAE1B,SAAS,wBAAwB;AAWjC,MAAM,wBAAwB;AAEvB,MAAM,uBAAuB,MAAM,WAGxC,CAAC,OAA6C,iBAAiB;AAC/D,SACE,oBAAC;AAAA,IACC,eAAe;AAAA,IACd,GAAG;AAAA,IACJ,KAAI;AAAA,IACJ,KAAK;AAAA,GACP;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAMnC,MAAM,0BAA0B;AAEzB,MAAM,yBAAyB,MAAM,WAG1C,CAAC,OAA6C,iBAAiB;AAC/D,SACE,oBAAC;AAAA,IACC,eAAe;AAAA,IACd,GAAG;AAAA,IACJ,KAAI;AAAA,IACJ,KAAK;AAAA,GACP;AAEJ,CAAC;AAED,uBAAuB,cAAc;AAIrC,MAAM,yBAAyB,MAAM;AAAA,EACnC,MAAM;AAAA,IACJ,CAAC,OAAiD,iBAAiB;AA9DvE;AA+DM,YAAM,EAAE,eAAe,KAAK,kBAAkB,qBAAqB,IAAI;AACvE,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,WACG;AAAA,MACL,IAAI,iBAAiB,eAAe,aAAa;AAEjD,YAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAA6B,IAAI;AACrE,YAAM,YAAY,MAAM,OAA0B,MAAM;AACxD,YAAM,YAAY,QAAQ,QAAQ,SAAS,kBAAkB;AAC7D,YAAM,WAAW,MAAM,OAAY;AAEnC,YAAM,EAAE,GAAG,GAAG,WAAW,UAAU,UAAU,QAAQ,KAAK,IAAI,YAAY;AAAA,QACxE,UAAU;AAAA,QACV,WAAW,QAAQ,OAAO,QAAQ;AAAA,QAClC,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC;AAAA,QAC1D,sBAAsB,IAAI,SAAS,WAAW,GAAG,MAAM,EAAE,gBAAgB,KAAK,CAAC;AAAA,MACjF,CAAC;AAED,YAAM,cAAc,gBAAgB,cAAc,QAAQ;AAE1D,UAAI,aAAa;AACf,YAAI,MAAM;AACR,cAAI,YAAY,YAAY,SAAS;AACnC,uBAAW,YAAY,OAAO;AAC9B,sBAAU,YAAY,OAAO;AAC7B,kCAAsB,MAAM;AAAA,UAC9B;AAAA,QACF,OAAO;AACL,+BAAqB,SAAS,OAAO;AAAA,QACvC;AAAA,MACF;AAEA,gCAA0B,MAAM;AAC9B,eAAO,MAAM;AAEX,+BAAqB,SAAS,OAAO;AAAA,QACvC;AAAA,MACF,GAAG,CAAC,CAAC;AAEL,UAAI,EAAE,aAAa,cAAc;AAC/B,eAAO;AAAA,MACT;AAEA,YAAM,WAAW,CAAC,WAAmB;AACnC,YAAI,UAAU;AACZ,cAAI,KAAK,SAAS,SAAS;AACzB,iBAAK,SAAS,QAAQ,aAAa;AACnC,sBAAU,MAAG;AAnHzB,kBAAAA;AAmH4B,oCAAcA,MAAA,KAAK,SAAS,YAAd,gBAAAA,IAAuB,cAAa,CAAC;AAAA,aAAC;AAAA,UACtE;AAAA,QACF,OAAO;AACL,oBAAU,MAAM,eAAgB,CAAC,UAAU,QAAQ,MAAM,CAAC;AAAA,QAC5D;AAAA,MACF;AAEA,aACE,oBAAC;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA,eAAW;AAAA,QACV,GAAG;AAAA,QACJ,QAAQ;AAAA,QAER,UAAU;AAAA,QACV,MAAM,KAAK;AAAA,QACX,KAAK,KAAK;AAAA,QACV,OAAO,WAAS,gDAAa,YAAb,mBAAsB,gBAAe,KAAK;AAAA,QAC1D,gBAAgB,MAAM;AACpB,oBAAU,UAAU;AACpB,cAAI,UAAU,KAAK,IAAI;AAEvB,mBAAS,QAAQ;AACf,gBAAI,SAAS;AACX,oBAAM,aAAa,KAAK,IAAI;AAC5B,oBAAM,YAAY,aAAa;AAC/B,wBAAU;AAEV,oBAAM,iBAAiB,YAAY;AAEnC,oBAAM,kBACJ,QAAQ,OACJ,QAAQ,YACR,QAAQ,eAAe,QAAQ,eAAe,QAAQ;AAE5D,oBAAM,kBACJ,QAAQ,OACJ,QAAQ,YAAY,iBAAiB,IACrC,QAAQ,YAAY,iBACpB,QAAQ,eAAe,QAAQ;AAErC;AAAA,gBACE,QAAQ,OACJ,KAAK,IAAI,gBAAgB,eAAe,IACxC,KAAK,IAAI,CAAC,gBAAgB,CAAC,eAAe;AAAA,cAChD;AAEA,kBAAI,iBAAiB;AACnB,yBAAS,UAAU,sBAAsB,KAAK;AAAA,cAChD;AAAA,YACF;AAAA,UACF;AAEA,+BAAqB,SAAS,OAAO;AACrC,mBAAS,UAAU,sBAAsB,KAAK;AAAA,QAChD;AAAA,QACA,gBAAgB,MAAM;AACpB,oBAAU,UAAU;AACpB,+BAAqB,SAAS,OAAO;AAAA,QACvC;AAAA,OACF;AAAA,IAEJ;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["_a"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectScrollButton.native.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ScopedProps, SelectScrollButtonProps } from './types'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollUpButton = (_: ScopedProps<SelectScrollButtonProps>) => null\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollDownButton = (_: ScopedProps<SelectScrollButtonProps>) =>\n null\n"],
|
|
5
|
+
"mappings": "AAGO,MAAM,uBAAuB,CAAC,MAA4C;AAG1E,MAAM,yBAAyB,CAAC,MACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FloatingFocusManager } from "@floating-ui/react-dom-interactions";
|
|
3
|
+
import { isWeb } from "@tamagui/core";
|
|
4
|
+
import { styled } from "@tamagui/core";
|
|
5
|
+
import { PortalItem } from "@tamagui/portal";
|
|
6
|
+
import { ThemeableStack } from "@tamagui/stacks";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { VIEWPORT_NAME } from "./constants";
|
|
9
|
+
import { ForwardSelectContext, useSelectContext } from "./context";
|
|
10
|
+
import { useSelectBreakpointActive } from "./useSelectBreakpointActive";
|
|
11
|
+
const SelectViewportFrame = styled(ThemeableStack, {
|
|
12
|
+
name: VIEWPORT_NAME,
|
|
13
|
+
backgroundColor: "$background",
|
|
14
|
+
elevate: true,
|
|
15
|
+
bordered: true,
|
|
16
|
+
overflow: "scroll",
|
|
17
|
+
userSelect: "none",
|
|
18
|
+
outlineWidth: 0,
|
|
19
|
+
variants: {
|
|
20
|
+
size: {
|
|
21
|
+
"...size": (val, { tokens }) => {
|
|
22
|
+
return {
|
|
23
|
+
borderRadius: tokens.radius[val] ?? val
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
size: "$2"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const SelectViewport = React.forwardRef(
|
|
33
|
+
(props, forwardedRef) => {
|
|
34
|
+
const { __scopeSelect, children, ...viewportProps } = props;
|
|
35
|
+
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
36
|
+
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
37
|
+
if (breakpointActive || !isWeb) {
|
|
38
|
+
return /* @__PURE__ */ jsx(PortalItem, {
|
|
39
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
40
|
+
children: /* @__PURE__ */ jsx(ForwardSelectContext, {
|
|
41
|
+
context,
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (!context.floatingContext) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (!context.open) {
|
|
50
|
+
return children;
|
|
51
|
+
}
|
|
52
|
+
const {
|
|
53
|
+
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
54
|
+
...floatingProps
|
|
55
|
+
} = context.interactions.getFloatingProps();
|
|
56
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx("style", {
|
|
59
|
+
dangerouslySetInnerHTML: {
|
|
60
|
+
__html: selectViewportCSS
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ jsx(FloatingFocusManager, {
|
|
64
|
+
context: context.floatingContext,
|
|
65
|
+
children: /* @__PURE__ */ jsx(SelectViewportFrame, {
|
|
66
|
+
size: context.size,
|
|
67
|
+
role: "presentation",
|
|
68
|
+
...viewportProps,
|
|
69
|
+
ref: forwardedRef,
|
|
70
|
+
...floatingProps,
|
|
71
|
+
...restStyle,
|
|
72
|
+
children
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
80
|
+
const selectViewportCSS = `
|
|
81
|
+
.is_SelectViewport {
|
|
82
|
+
scrollbar-width: none;
|
|
83
|
+
-webkit-overflow-scrolling: touch;
|
|
84
|
+
overscroll-behavior: contain;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.is_SelectViewport::-webkit-scrollbar{
|
|
88
|
+
display:none
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
export {
|
|
92
|
+
SelectViewport,
|
|
93
|
+
SelectViewportFrame
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=SelectViewport.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectViewport.tsx"],
|
|
4
|
+
"sourcesContent": ["import { FloatingFocusManager } from '@floating-ui/react-dom-interactions'\nimport { TamaguiElement, isWeb } from '@tamagui/core'\nimport { styled } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { ForwardSelectContext, useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\nimport { useSelectBreakpointActive } from './useSelectBreakpointActive'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectViewport\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SelectViewportFrame = styled(ThemeableStack, {\n name: VIEWPORT_NAME,\n backgroundColor: '$background',\n elevate: true,\n bordered: true,\n overflow: 'scroll',\n userSelect: 'none',\n outlineWidth: 0,\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n borderRadius: tokens.radius[val] ?? val,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$2',\n },\n})\n\nexport const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportProps>(\n (props: ScopedProps<SelectViewportProps>, forwardedRef) => {\n const { __scopeSelect, children, ...viewportProps } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n\n if (breakpointActive || !isWeb) {\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <ForwardSelectContext context={context}>{children}</ForwardSelectContext>\n </PortalItem>\n )\n }\n\n if (!context.floatingContext) {\n return null\n }\n\n if (!context.open) {\n return children\n }\n\n const {\n style: { scrollbarWidth, listStyleType, ...restStyle },\n ...floatingProps\n } = context.interactions!.getFloatingProps()\n\n return (\n <>\n <style\n dangerouslySetInnerHTML={{\n __html: selectViewportCSS,\n }}\n />\n <FloatingFocusManager context={context.floatingContext}>\n <SelectViewportFrame\n size={context.size}\n // @ts-ignore\n role=\"presentation\"\n {...viewportProps}\n ref={forwardedRef}\n {...floatingProps}\n {...restStyle}\n >\n {children}\n </SelectViewportFrame>\n </FloatingFocusManager>\n </>\n )\n }\n)\n\nSelectViewport.displayName = VIEWPORT_NAME\n\nconst selectViewportCSS = `\n.is_SelectViewport {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n.is_SelectViewport::-webkit-scrollbar{\n display:none\n}\n`\n"],
|
|
5
|
+
"mappings": "AAiDU,SAmBJ,UAnBI,KAmBJ,YAnBI;AAjDV,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB,wBAAwB;AAEvD,SAAS,iCAAiC;AAMnC,MAAM,sBAAsB,OAAO,gBAAgB;AAAA,EACxD,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,cAAc;AAAA,EAEd,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,EAAE,OAAO,MAAM;AAC9B,eAAO;AAAA,UACL,cAAc,OAAO,OAAO,QAAQ;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAEM,MAAM,iBAAiB,MAAM;AAAA,EAClC,CAAC,OAAyC,iBAAiB;AACzD,UAAM,EAAE,eAAe,aAAa,cAAc,IAAI;AACtD,UAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,UAAM,mBAAmB,0BAA0B,QAAQ,eAAe;AAE1E,QAAI,oBAAoB,CAAC,OAAO;AAC9B,aACE,oBAAC;AAAA,QAAW,UAAU,GAAG,QAAQ;AAAA,QAC/B,8BAAC;AAAA,UAAqB;AAAA,UAAmB;AAAA,SAAS;AAAA,OACpD;AAAA,IAEJ;AAEA,QAAI,CAAC,QAAQ,iBAAiB;AAC5B,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,QAAQ,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,gBAAgB,kBAAkB,UAAU;AAAA,SAClD;AAAA,IACL,IAAI,QAAQ,aAAc,iBAAiB;AAE3C,WACE;AAAA,MACE;AAAA,4BAAC;AAAA,UACC,yBAAyB;AAAA,YACvB,QAAQ;AAAA,UACV;AAAA,SACF;AAAA,QACA,oBAAC;AAAA,UAAqB,SAAS,QAAQ;AAAA,UACrC,8BAAC;AAAA,YACC,MAAM,QAAQ;AAAA,YAEd,MAAK;AAAA,YACJ,GAAG;AAAA,YACJ,KAAK;AAAA,YACJ,GAAG;AAAA,YACH,GAAG;AAAA,YAEH;AAAA,WACH;AAAA,SACF;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAE7B,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AdaptParentContext } from "@tamagui/adapt";
|
|
3
|
+
import { Theme, useThemeName } from "@tamagui/core";
|
|
4
|
+
import { PortalItem } from "@tamagui/portal";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { VIEWPORT_NAME } from "./constants";
|
|
7
|
+
import { SelectProvider, useSelectContext } from "./context";
|
|
8
|
+
const SelectViewport = (props) => {
|
|
9
|
+
const { __scopeSelect, children } = props;
|
|
10
|
+
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
11
|
+
const themeName = useThemeName();
|
|
12
|
+
const adaptContext = React.useContext(AdaptParentContext);
|
|
13
|
+
return /* @__PURE__ */ jsx(PortalItem, {
|
|
14
|
+
hostName: `${context.scopeKey}SheetContents`,
|
|
15
|
+
children: /* @__PURE__ */ jsx(Theme, {
|
|
16
|
+
name: themeName,
|
|
17
|
+
children: /* @__PURE__ */ jsx(SelectProvider, {
|
|
18
|
+
scope: __scopeSelect,
|
|
19
|
+
...context,
|
|
20
|
+
children: /* @__PURE__ */ jsx(AdaptParentContext.Provider, {
|
|
21
|
+
value: adaptContext,
|
|
22
|
+
children
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
29
|
+
export {
|
|
30
|
+
SelectViewport
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=SelectViewport.native.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectViewport.native.tsx"],
|
|
4
|
+
"sourcesContent": ["import { AdaptParentContext } from '@tamagui/adapt'\nimport { Stack, Theme, useThemeName } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { SelectProvider, useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\n\nexport const SelectViewport = (props: ScopedProps<SelectViewportProps>) => {\n const { __scopeSelect, children } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n const themeName = useThemeName()\n const adaptContext = React.useContext(AdaptParentContext)\n\n // need to forward context...\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <Theme name={themeName}>\n <SelectProvider scope={__scopeSelect} {...context}>\n <AdaptParentContext.Provider value={adaptContext}>\n {children}\n </AdaptParentContext.Provider>\n </SelectProvider>\n </Theme>\n </PortalItem>\n )\n}\n\nSelectViewport.displayName = VIEWPORT_NAME\n"],
|
|
5
|
+
"mappings": "AAoBU;AApBV,SAAS,0BAA0B;AACnC,SAAgB,OAAO,oBAAoB;AAC3C,SAAS,kBAAkB;AAC3B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,wBAAwB;AAG1C,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,MAAM,WAAW,kBAAkB;AAGxD,SACE,oBAAC;AAAA,IAAW,UAAU,GAAG,QAAQ;AAAA,IAC/B,8BAAC;AAAA,MAAM,MAAM;AAAA,MACX,8BAAC;AAAA,QAAe,OAAO;AAAA,QAAgB,GAAG;AAAA,QACxC,8BAAC,mBAAmB,UAAnB;AAAA,UAA4B,OAAO;AAAA,UACjC;AAAA,SACH;AAAA,OACF;AAAA,KACF;AAAA,GACF;AAEJ;AAEA,eAAe,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const SELECT_NAME = "Select";
|
|
2
|
+
const WINDOW_PADDING = 8;
|
|
3
|
+
const SCROLL_ARROW_VELOCITY = 8;
|
|
4
|
+
const SCROLL_ARROW_THRESHOLD = 8;
|
|
5
|
+
const MIN_HEIGHT = 80;
|
|
6
|
+
const FALLBACK_THRESHOLD = 16;
|
|
7
|
+
const VIEWPORT_NAME = "SelectViewport";
|
|
8
|
+
export {
|
|
9
|
+
FALLBACK_THRESHOLD,
|
|
10
|
+
MIN_HEIGHT,
|
|
11
|
+
SCROLL_ARROW_THRESHOLD,
|
|
12
|
+
SCROLL_ARROW_VELOCITY,
|
|
13
|
+
SELECT_NAME,
|
|
14
|
+
VIEWPORT_NAME,
|
|
15
|
+
WINDOW_PADDING
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/constants.tsx"],
|
|
4
|
+
"sourcesContent": ["export const SELECT_NAME = 'Select'\nexport const WINDOW_PADDING = 8\nexport const SCROLL_ARROW_VELOCITY = 8\nexport const SCROLL_ARROW_THRESHOLD = 8\nexport const MIN_HEIGHT = 80\nexport const FALLBACK_THRESHOLD = 16\nexport const VIEWPORT_NAME = 'SelectViewport'\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB;AAC/B,MAAM,aAAa;AACnB,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContextScope } from "@tamagui/create-context";
|
|
3
|
+
import { SELECT_NAME } from "./constants";
|
|
4
|
+
const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME);
|
|
5
|
+
const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
6
|
+
const ForwardSelectContext = (props) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(SelectProvider, {
|
|
8
|
+
isInSheet: true,
|
|
9
|
+
scope: props.__scopeSelect,
|
|
10
|
+
...props.context,
|
|
11
|
+
children: props.children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
ForwardSelectContext,
|
|
16
|
+
SelectProvider,
|
|
17
|
+
createSelectContext,
|
|
18
|
+
createSelectScope,
|
|
19
|
+
useSelectContext
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/context.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContextScope } from '@tamagui/create-context'\n\nimport { SELECT_NAME } from './constants'\nimport { ScopedProps, SelectContextValue } from './types'\n\nexport const [createSelectContext, createSelectScope] =\n createContextScope(SELECT_NAME)\n\nexport const [SelectProvider, useSelectContext] =\n createSelectContext<SelectContextValue>(SELECT_NAME)\n\nexport const ForwardSelectContext = (\n props: ScopedProps<{ children?: any; context: SelectContextValue }>,\n) => {\n return (\n <SelectProvider isInSheet scope={props.__scopeSelect} {...props.context}>\n {props.children}\n </SelectProvider>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAeI;AAfJ,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,IAClD,mBAAmB,WAAW;AAEzB,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAE9C,MAAM,uBAAuB,CAClC,UACG;AACH,SACE,oBAAC;AAAA,IAAe,WAAS;AAAA,IAAC,OAAO,MAAM;AAAA,IAAgB,GAAG,MAAM;AAAA,IAC7D,gBAAM;AAAA,GACT;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMedia } from "@tamagui/core";
|
|
2
|
+
const useSelectBreakpointActive = (sheetBreakpoint) => {
|
|
3
|
+
const media = useMedia();
|
|
4
|
+
return sheetBreakpoint ? media[sheetBreakpoint] : false;
|
|
5
|
+
};
|
|
6
|
+
const useShowSelectSheet = (context) => {
|
|
7
|
+
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
8
|
+
return context.open === false ? false : breakpointActive;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
useSelectBreakpointActive,
|
|
12
|
+
useShowSelectSheet
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useSelectBreakpointActive.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useSelectBreakpointActive.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useMedia } from '@tamagui/core'\n\nimport { SelectContextValue } from './types'\n\nexport const useSelectBreakpointActive = (\n sheetBreakpoint: SelectContextValue['sheetBreakpoint'],\n) => {\n const media = useMedia()\n return sheetBreakpoint ? media[sheetBreakpoint] : false\n}\n\nexport const useShowSelectSheet = (context: SelectContextValue) => {\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n return context.open === false ? false : breakpointActive\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAIlB,MAAM,4BAA4B,CACvC,oBACG;AACH,QAAM,QAAQ,SAAS;AACvB,SAAO,kBAAkB,MAAM,mBAAmB;AACpD;AAEO,MAAM,qBAAqB,CAAC,YAAgC;AACjE,QAAM,mBAAmB,0BAA0B,QAAQ,eAAe;AAC1E,SAAO,QAAQ,SAAS,QAAQ,QAAQ;AAC1C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { usePrevious } from "@radix-ui/react-use-previous";
|
|
2
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
const BubbleSelect = React.forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { value, ...selectProps } = props;
|
|
6
|
+
const ref = React.useRef(null);
|
|
7
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
8
|
+
const prevValue = usePrevious(value);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
const select = ref.current;
|
|
11
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
|
12
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
13
|
+
selectProto,
|
|
14
|
+
"value"
|
|
15
|
+
);
|
|
16
|
+
const setValue = descriptor.set;
|
|
17
|
+
if (prevValue !== value && setValue) {
|
|
18
|
+
const event = new Event("change", { bubbles: true });
|
|
19
|
+
setValue.call(select, value);
|
|
20
|
+
select.dispatchEvent(event);
|
|
21
|
+
}
|
|
22
|
+
}, [prevValue, value]);
|
|
23
|
+
return null;
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=BubbleSelect.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/BubbleSelect.tsx"],
|
|
4
|
+
"sourcesContent": ["import { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\n/* -----------------------------------------------------------------------------------------------*/\nconst BubbleSelect = React.forwardRef<\n HTMLSelectElement,\n React.ComponentPropsWithoutRef<'select'>\n>((props, forwardedRef) => {\n const { value, ...selectProps } = props\n const ref = React.useRef<HTMLSelectElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const prevValue = usePrevious(value)\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!\n const selectProto = window.HTMLSelectElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(\n selectProto,\n 'value',\n ) as PropertyDescriptor\n const setValue = descriptor.set\n if (prevValue !== value && setValue) {\n const event = new Event('change', { bubbles: true })\n setValue.call(select, value)\n select.dispatchEvent(event)\n }\n }, [prevValue, value])\n\n /**\n * We purposefully use a `select` here to support form autofill as much\n * as possible.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n *\n * We use `VisuallyHidden` rather than `display: \"none\"` because Safari autofill\n * won't work otherwise.\n */\n // TODO\n return null\n // return (\n // <VisuallyHidden asChild>\n // <select {...selectProps} ref={composedRefs} defaultValue={value} />\n // </VisuallyHidden>\n // )\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAGvB,MAAM,eAAe,MAAM,WAGzB,CAAC,OAAO,iBAAiB;AACzB,QAAM,EAAE,UAAU,YAAY,IAAI;AAClC,QAAM,MAAM,MAAM,OAA0B,IAAI;AAChD,QAAM,eAAe,gBAAgB,cAAc,GAAG;AACtD,QAAM,YAAY,YAAY,KAAK;AAGnC,QAAM,UAAU,MAAM;AACpB,UAAM,SAAS,IAAI;AACnB,UAAM,cAAc,OAAO,kBAAkB;AAC7C,UAAM,aAAa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AACA,UAAM,WAAW,WAAW;AAC5B,QAAI,cAAc,SAAS,UAAU;AACnC,YAAM,QAAQ,IAAI,MAAM,UAAU,EAAE,SAAS,KAAK,CAAC;AACnD,eAAS,KAAK,QAAQ,KAAK;AAC3B,aAAO,cAAc,KAAK;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAerB,SAAO;AAMT,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getVariable,
|
|
3
|
+
styled,
|
|
4
|
+
themeable,
|
|
5
|
+
useTheme
|
|
6
|
+
} from "@tamagui/core";
|
|
7
|
+
import { YStack } from "@tamagui/stacks";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { StyleSheet } from "react-native";
|
|
10
|
+
import {
|
|
11
|
+
LinearGradient as ExpoLinearGradient
|
|
12
|
+
} from "./linear-gradient";
|
|
13
|
+
const LinearGradient = YStack.extractable(
|
|
14
|
+
themeable(
|
|
15
|
+
React.forwardRef((props, ref) => {
|
|
16
|
+
const { start, end, colors: colorsProp, locations, children, ...stackProps } = props;
|
|
17
|
+
const colors = useThemeColors(colorsProp || []);
|
|
18
|
+
return <LinearGradientFrame ref={ref} {...stackProps}><ExpoLinearGradient start={start} end={end} colors={colors} locations={locations} style={StyleSheet.absoluteFill}>{children}</ExpoLinearGradient></LinearGradientFrame>;
|
|
19
|
+
})
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
const LinearGradientFrame = styled(YStack, {
|
|
23
|
+
name: "LinearGradient",
|
|
24
|
+
overflow: "hidden",
|
|
25
|
+
position: "relative"
|
|
26
|
+
});
|
|
27
|
+
const useThemeColors = (colors) => {
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
return colors.map((color) => {
|
|
30
|
+
if (color[0] === "$") {
|
|
31
|
+
return getVariable(theme[color] || color);
|
|
32
|
+
}
|
|
33
|
+
return color;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
LinearGradient
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=LinearGradient.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/LinearGradient.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n ColorTokens,\n ThemeTokens,\n getVariable,\n styled,\n themeable,\n useTheme,\n} from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { StyleSheet, View } from 'react-native'\n\nimport {\n LinearGradient as ExpoLinearGradient,\n LinearGradientProps as ExpoLinearGradientProps,\n} from './linear-gradient'\n\n//\nexport type LinearGradientProps = Omit<ExpoLinearGradientProps, 'colors'> &\n Omit<YStackProps, 'children' | keyof ExpoLinearGradientProps> & {\n colors?: (ColorTokens | ThemeTokens | (string & {}))[]\n }\n\nexport const LinearGradient: React.ForwardRefExoticComponent<\n LinearGradientProps & React.RefAttributes<HTMLElement | View>\n> = YStack.extractable(\n themeable(\n React.forwardRef((props: LinearGradientProps, ref) => {\n const { start, end, colors: colorsProp, locations, children, ...stackProps } = props\n const colors = useThemeColors(colorsProp || [])\n return (\n // @ts-ignore\n <LinearGradientFrame ref={ref} {...stackProps}>\n <ExpoLinearGradient\n start={start}\n end={end}\n colors={colors}\n locations={locations}\n style={StyleSheet.absoluteFill}\n >\n {children}\n </ExpoLinearGradient>\n </LinearGradientFrame>\n )\n })\n )\n) as any\n\nconst LinearGradientFrame = styled(YStack, {\n name: 'LinearGradient',\n overflow: 'hidden',\n position: 'relative',\n})\n\n// resolve tamagui theme values\nconst useThemeColors = (colors: string[]) => {\n const theme = useTheme()\n return colors.map((color) => {\n if (color[0] === '$') {\n return getVariable(theme[color] || color)\n }\n return color\n })\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAA2B;AACpC,YAAY,WAAW;AACvB,SAAS,kBAAwB;AAEjC;AAAA,EACE,kBAAkB;AAAA,OAEb;AAQA,MAAM,iBAET,OAAO;AAAA,EACT;AAAA,IACE,MAAM,WAAW,CAAC,OAA4B,QAAQ;AACpD,YAAM,EAAE,OAAO,KAAK,QAAQ,YAAY,WAAW,aAAa,WAAW,IAAI;AAC/E,YAAM,SAAS,eAAe,cAAc,CAAC,CAAC;AAC9C,aAEE,CAAC,oBAAoB,KAAK,SAAS,YACjC,CAAC,mBACC,OAAO,OACP,KAAK,KACL,QAAQ,QACR,WAAW,WACX,OAAO,WAAW,eAEjB,SACH,EARC,mBASH,EAVC;AAAA,IAYL,CAAC;AAAA,EACH;AACF;AAEA,MAAM,sBAAsB,OAAO,QAAQ;AAAA,EACzC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AACZ,CAAC;AAGD,MAAM,iBAAiB,CAAC,WAAqB;AAC3C,QAAM,QAAQ,SAAS;AACvB,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,QAAI,MAAM,OAAO,KAAK;AACpB,aAAO,YAAY,MAAM,UAAU,KAAK;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|