@flipova/foundation 1.13.0 → 2.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.
Files changed (260) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/README.md +53 -178
  3. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +162 -0
  4. package/components/ui/accordion/AccordionAnimatedHeight.tsx +56 -0
  5. package/components/ui/accordion/AccordionAnimatedIcon.tsx +41 -0
  6. package/components/ui/accordion/AnimatedHeight.tsx +56 -0
  7. package/components/ui/accordion/AnimatedIcon.tsx +41 -0
  8. package/components/ui/accordion/MIGRATION_SUMMARY.md +250 -0
  9. package/components/ui/accordion/USAGE_EXAMPLE.tsx +179 -0
  10. package/components/ui/accordion/animation-config.ts +32 -0
  11. package/components/ui/accordion/index.tsx +253 -0
  12. package/components/ui/actionsheet/index.tsx +511 -0
  13. package/components/ui/alert/index.tsx +158 -0
  14. package/components/ui/alert-dialog/index.tsx +254 -0
  15. package/components/ui/avatar/index.tsx +139 -0
  16. package/components/ui/badge/index.tsx +163 -0
  17. package/components/ui/bottomsheet/index.tsx +477 -0
  18. package/components/ui/box/index.tsx +19 -0
  19. package/components/ui/box/index.web.tsx +19 -0
  20. package/components/ui/box/styles.tsx +10 -0
  21. package/components/ui/button/index.tsx +264 -0
  22. package/components/ui/calendar/creator.tsx +366 -0
  23. package/components/ui/calendar/index.tsx +462 -0
  24. package/components/ui/calendar/styles.tsx +140 -0
  25. package/components/ui/card/index.tsx +23 -0
  26. package/components/ui/card/index.web.tsx +26 -0
  27. package/components/ui/card/styles.tsx +16 -0
  28. package/components/ui/center/index.tsx +22 -0
  29. package/components/ui/center/index.web.tsx +20 -0
  30. package/components/ui/center/styles.tsx +8 -0
  31. package/components/ui/checkbox/index.tsx +184 -0
  32. package/components/ui/date-time-picker/creator.tsx +109 -0
  33. package/components/ui/date-time-picker/index.tsx +585 -0
  34. package/components/ui/date-time-picker/index.web.tsx +217 -0
  35. package/components/ui/date-time-picker/styles.tsx +56 -0
  36. package/components/ui/divider/index.tsx +40 -0
  37. package/components/ui/drawer/index.tsx +362 -0
  38. package/components/ui/fab/index.tsx +215 -0
  39. package/components/ui/flat-list/index.tsx +21 -0
  40. package/components/ui/form-control/index.tsx +352 -0
  41. package/components/ui/gluestack-ui-provider/config.ts +72 -0
  42. package/components/ui/gluestack-ui-provider/index.tsx +47 -0
  43. package/components/ui/gluestack-ui-provider/index.web.tsx +96 -0
  44. package/components/ui/gluestack-ui-provider/script.ts +19 -0
  45. package/components/ui/gluestack-ui-provider/tokens.d.ts +17 -0
  46. package/components/ui/gluestack-ui-provider/tokens.js +188 -0
  47. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +82 -0
  48. package/components/ui/grid/index.tsx +283 -0
  49. package/components/ui/grid/index.web.tsx +66 -0
  50. package/components/ui/grid/styles.tsx +15 -0
  51. package/components/ui/heading/index.tsx +220 -0
  52. package/components/ui/heading/index.web.tsx +202 -0
  53. package/components/ui/heading/styles.tsx +43 -0
  54. package/components/ui/hstack/index.tsx +27 -0
  55. package/components/ui/hstack/index.web.tsx +26 -0
  56. package/components/ui/hstack/styles.tsx +25 -0
  57. package/components/ui/icon/index.tsx +1588 -0
  58. package/components/ui/icon/index.web.tsx +1573 -0
  59. package/components/ui/image/index.tsx +48 -0
  60. package/components/ui/image-background/index.tsx +25 -0
  61. package/components/ui/image-viewer/index.tsx +743 -0
  62. package/components/ui/image-viewer/index.web.tsx +302 -0
  63. package/components/ui/index.ts +58 -0
  64. package/components/ui/input/index.tsx +125 -0
  65. package/components/ui/input-accessory-view/index.tsx +2 -0
  66. package/components/ui/keyboard-avoiding-view/index.tsx +2 -0
  67. package/components/ui/link/index.tsx +102 -0
  68. package/components/ui/liquid-glass/index.tsx +74 -0
  69. package/components/ui/menu/index.tsx +186 -0
  70. package/components/ui/modal/index.tsx +237 -0
  71. package/components/ui/popover/index.tsx +272 -0
  72. package/components/ui/portal/index.tsx +17 -0
  73. package/components/ui/pressable/index.tsx +39 -0
  74. package/components/ui/progress/index.tsx +83 -0
  75. package/components/ui/radio/index.tsx +217 -0
  76. package/components/ui/refresh-control/index.tsx +2 -0
  77. package/components/ui/safe-area-view/index.tsx +2 -0
  78. package/components/ui/scroll-view/index.tsx +2 -0
  79. package/components/ui/section-list/index.tsx +2 -0
  80. package/components/ui/select/index.tsx +277 -0
  81. package/components/ui/select/select-actionsheet.tsx +562 -0
  82. package/components/ui/skeleton/index.tsx +105 -0
  83. package/components/ui/skeleton/index.web.tsx +103 -0
  84. package/components/ui/skeleton/styles.tsx +35 -0
  85. package/components/ui/slider/index.tsx +181 -0
  86. package/components/ui/spinner/index.tsx +40 -0
  87. package/components/ui/status-bar/index.tsx +2 -0
  88. package/components/ui/switch/index.tsx +41 -0
  89. package/components/ui/table/index.tsx +210 -0
  90. package/components/ui/table/index.web.tsx +157 -0
  91. package/components/ui/table/styles.tsx +44 -0
  92. package/components/ui/tabs/TabsAnimatedIndicator.tsx +160 -0
  93. package/components/ui/tabs/animation-config.ts +3 -0
  94. package/components/ui/tabs/creator.tsx +206 -0
  95. package/components/ui/tabs/index.tsx +484 -0
  96. package/components/ui/text/index.tsx +48 -0
  97. package/components/ui/text/index.web.tsx +45 -0
  98. package/components/ui/text/styles.tsx +47 -0
  99. package/components/ui/textarea/index.tsx +94 -0
  100. package/components/ui/toast/index.tsx +252 -0
  101. package/components/ui/tooltip/index.tsx +131 -0
  102. package/components/ui/view/index.tsx +2 -0
  103. package/components/ui/virtualized-list/index.tsx +2 -0
  104. package/components/ui/vstack/index.tsx +28 -0
  105. package/components/ui/vstack/index.web.tsx +27 -0
  106. package/components/ui/vstack/styles.tsx +25 -0
  107. package/design/canonical.index.txt +53 -0
  108. package/design/documentation.xml +519 -0
  109. package/design/manifest.xml +90 -0
  110. package/design/schema.xsd +639 -0
  111. package/design/themes.xml +204 -0
  112. package/design/tokens.xml +510 -0
  113. package/design/tools/design.js +165 -0
  114. package/design/tools/npm.js +65 -0
  115. package/design/tools/requirements.txt +35 -0
  116. package/design/tools/sources/.checker/__init__.py +81 -0
  117. package/design/tools/sources/.checker/checks.py +198 -0
  118. package/design/tools/sources/.checker/cli.py +154 -0
  119. package/design/tools/sources/.checker/io.py +242 -0
  120. package/design/tools/sources/.checker/model.py +144 -0
  121. package/design/tools/sources/.checker/registry.py +115 -0
  122. package/design/tools/sources/.checker/report.py +21 -0
  123. package/design/tools/sources/.docgen/__init__.py +45 -0
  124. package/design/tools/sources/.docgen/cli.py +101 -0
  125. package/design/tools/sources/.docgen/model.py +147 -0
  126. package/design/tools/sources/.docgen/reference.py +97 -0
  127. package/design/tools/sources/.docgen/site.py +145 -0
  128. package/design/tools/sources/.docgen/xsddoc.py +329 -0
  129. package/design/tools/sources/.generate/__init__.py +35 -0
  130. package/design/tools/sources/.generate/cli.py +76 -0
  131. package/design/tools/sources/.generate/common.py +33 -0
  132. package/design/tools/sources/.generate/config.py +119 -0
  133. package/design/tools/sources/.generate/model.py +51 -0
  134. package/design/tools/sources/.generate/tokens.py +141 -0
  135. package/design/tools/sources/.linter/__init__.py +9 -0
  136. package/design/tools/sources/.linter/cli.py +44 -0
  137. package/design/tools/sources/.linter/discovery.py +30 -0
  138. package/design/tools/sources/.linter/errors.py +45 -0
  139. package/design/tools/sources/.linter/linter.py +68 -0
  140. package/design/tools/sources/.xmleditor/__init__.py +74 -0
  141. package/design/tools/sources/.xmleditor/blocks.py +185 -0
  142. package/design/tools/sources/.xmleditor/cli.py +141 -0
  143. package/design/tools/sources/.xmleditor/editor.py +906 -0
  144. package/design/tools/sources/.xmleditor/model.py +708 -0
  145. package/design/tools/sources/.xmleditor/widgets.py +1832 -0
  146. package/design/tools/sources/.xmleditor/xsdmodel.py +753 -0
  147. package/design/tools/sources/checker.py +55 -0
  148. package/design/tools/sources/docgen.py +66 -0
  149. package/design/tools/sources/generate.py +48 -0
  150. package/design/tools/sources/linter.py +54 -0
  151. package/design/tools/sources/ruff.toml +12 -0
  152. package/design/tools/sources/xmleditor.py +62 -0
  153. package/design/tools/unix/_venv_python.sh +16 -0
  154. package/design/tools/unix/check.sh +13 -0
  155. package/design/tools/unix/doc.sh +14 -0
  156. package/design/tools/unix/gen.sh +14 -0
  157. package/design/tools/unix/lint.sh +10 -0
  158. package/design/tools/unix/run.sh +20 -0
  159. package/design/tools/unix/verify.sh +12 -0
  160. package/design/tools/unix/xmledit.sh +12 -0
  161. package/design/tools/windows/check.cmd +12 -0
  162. package/design/tools/windows/doc.cmd +12 -0
  163. package/design/tools/windows/gen.cmd +11 -0
  164. package/design/tools/windows/lint.cmd +9 -0
  165. package/design/tools/windows/run.cmd +26 -0
  166. package/design/tools/windows/verify.cmd +10 -0
  167. package/design/tools/windows/xmledit.cmd +10 -0
  168. package/dist/chunk-LV4UIEQN.js +9730 -0
  169. package/dist/chunk-LV4UIEQN.js.map +1 -0
  170. package/dist/chunk-WNVU3BM2.mjs +9401 -0
  171. package/dist/chunk-WNVU3BM2.mjs.map +1 -0
  172. package/dist/index.d.mts +40 -9
  173. package/dist/index.d.ts +40 -9
  174. package/dist/index.js +726 -414
  175. package/dist/index.mjs +1 -5
  176. package/dist/ui/index.d.mts +6931 -3070
  177. package/dist/ui/index.d.ts +6931 -3070
  178. package/dist/ui/index.js +779 -352
  179. package/dist/ui/index.mjs +1 -2
  180. package/package.json +66 -142
  181. package/dist/chunk-2XORADW6.js +0 -24552
  182. package/dist/chunk-2XORADW6.js.map +0 -1
  183. package/dist/chunk-52BHHF5M.js +0 -46
  184. package/dist/chunk-52BHHF5M.js.map +0 -1
  185. package/dist/chunk-5647JY7Z.mjs +0 -100
  186. package/dist/chunk-5647JY7Z.mjs.map +0 -1
  187. package/dist/chunk-5N5HC4ZA.mjs +0 -3
  188. package/dist/chunk-5N5HC4ZA.mjs.map +0 -1
  189. package/dist/chunk-7QFZMGL6.js +0 -8583
  190. package/dist/chunk-7QFZMGL6.js.map +0 -1
  191. package/dist/chunk-ASZEP37D.js +0 -423
  192. package/dist/chunk-ASZEP37D.js.map +0 -1
  193. package/dist/chunk-BH5SU2JQ.mjs +0 -8282
  194. package/dist/chunk-BH5SU2JQ.mjs.map +0 -1
  195. package/dist/chunk-BO65GO53.mjs +0 -422
  196. package/dist/chunk-BO65GO53.mjs.map +0 -1
  197. package/dist/chunk-BSVXX52E.mjs +0 -413
  198. package/dist/chunk-BSVXX52E.mjs.map +0 -1
  199. package/dist/chunk-DNV5UBNF.mjs +0 -3
  200. package/dist/chunk-DNV5UBNF.mjs.map +0 -1
  201. package/dist/chunk-EDTAMUO2.js +0 -8310
  202. package/dist/chunk-EDTAMUO2.js.map +0 -1
  203. package/dist/chunk-IJTI6EX4.js +0 -4
  204. package/dist/chunk-IJTI6EX4.js.map +0 -1
  205. package/dist/chunk-M3YLASM2.js +0 -428
  206. package/dist/chunk-M3YLASM2.js.map +0 -1
  207. package/dist/chunk-OXKOGLXE.js +0 -4
  208. package/dist/chunk-OXKOGLXE.js.map +0 -1
  209. package/dist/chunk-RQXQK3ZO.mjs +0 -8486
  210. package/dist/chunk-RQXQK3ZO.mjs.map +0 -1
  211. package/dist/chunk-SR25V4EA.mjs +0 -40
  212. package/dist/chunk-SR25V4EA.mjs.map +0 -1
  213. package/dist/chunk-UB34WFEQ.js +0 -106
  214. package/dist/chunk-UB34WFEQ.js.map +0 -1
  215. package/dist/chunk-ZBRWXKDF.mjs +0 -24431
  216. package/dist/chunk-ZBRWXKDF.mjs.map +0 -1
  217. package/dist/cli/ds.d.mts +0 -1
  218. package/dist/cli/ds.d.ts +0 -1
  219. package/dist/cli/ds.js +0 -602
  220. package/dist/cli/ds.js.map +0 -1
  221. package/dist/cli/ds.mjs +0 -579
  222. package/dist/cli/ds.mjs.map +0 -1
  223. package/dist/cli/flipova.d.mts +0 -1
  224. package/dist/cli/flipova.d.ts +0 -1
  225. package/dist/cli/flipova.js +0 -161
  226. package/dist/cli/flipova.js.map +0 -1
  227. package/dist/cli/flipova.mjs +0 -154
  228. package/dist/cli/flipova.mjs.map +0 -1
  229. package/dist/config/index.d.mts +0 -123
  230. package/dist/config/index.d.ts +0 -123
  231. package/dist/config/index.js +0 -28
  232. package/dist/config/index.js.map +0 -1
  233. package/dist/config/index.mjs +0 -3
  234. package/dist/config/index.mjs.map +0 -1
  235. package/dist/index-CuaJA3gM.d.mts +0 -78
  236. package/dist/index-CuaJA3gM.d.ts +0 -78
  237. package/dist/registry/index.d.mts +0 -10160
  238. package/dist/registry/index.d.ts +0 -10160
  239. package/dist/registry/index.js +0 -392
  240. package/dist/registry/index.js.map +0 -1
  241. package/dist/registry/index.mjs +0 -3
  242. package/dist/registry/index.mjs.map +0 -1
  243. package/dist/theme/index.d.mts +0 -109
  244. package/dist/theme/index.d.ts +0 -109
  245. package/dist/theme/index.js +0 -28
  246. package/dist/theme/index.js.map +0 -1
  247. package/dist/theme/index.mjs +0 -3
  248. package/dist/theme/index.mjs.map +0 -1
  249. package/dist/tokens/index.d.mts +0 -423
  250. package/dist/tokens/index.d.ts +0 -423
  251. package/dist/tokens/index.js +0 -44
  252. package/dist/tokens/index.js.map +0 -1
  253. package/dist/tokens/index.mjs +0 -3
  254. package/dist/tokens/index.mjs.map +0 -1
  255. package/dist/types/index.d.mts +0 -202
  256. package/dist/types/index.d.ts +0 -202
  257. package/dist/types/index.js +0 -4
  258. package/dist/types/index.js.map +0 -1
  259. package/dist/types/index.mjs +0 -3
  260. package/dist/types/index.mjs.map +0 -1
@@ -0,0 +1,157 @@
1
+ import React, { createContext, useMemo, useContext } from 'react';
2
+ import {
3
+ tableStyle,
4
+ tableHeaderStyle,
5
+ tableBodyStyle,
6
+ tableFooterStyle,
7
+ tableHeadStyle,
8
+ tableRowStyleStyle,
9
+ tableDataStyle,
10
+ tableCaptionStyle,
11
+ } from './styles';
12
+
13
+ const TableHeaderContext = createContext<{
14
+ isHeaderRow: boolean;
15
+ }>({
16
+ isHeaderRow: false,
17
+ });
18
+ const TableFooterContext = createContext<{
19
+ isFooterRow: boolean;
20
+ }>({
21
+ isFooterRow: false,
22
+ });
23
+
24
+ const Table = React.forwardRef<HTMLTableElement, React.ComponentProps<'table'>>(
25
+ function Table({ className, ...props }, ref) {
26
+ return (
27
+ <table
28
+ ref={ref}
29
+ className={tableStyle({ class: className })}
30
+ {...props}
31
+ />
32
+ );
33
+ }
34
+ );
35
+
36
+ const TableHeader = React.forwardRef<
37
+ HTMLTableSectionElement,
38
+ React.ComponentProps<'thead'>
39
+ >(function TableHeader({ className, ...props }, ref) {
40
+ const contextValue = useMemo(() => {
41
+ return {
42
+ isHeaderRow: true,
43
+ };
44
+ }, []);
45
+ return (
46
+ <TableHeaderContext.Provider value={contextValue}>
47
+ <thead
48
+ ref={ref}
49
+ className={tableHeaderStyle({ class: className })}
50
+ {...props}
51
+ />
52
+ </TableHeaderContext.Provider>
53
+ );
54
+ });
55
+
56
+ const TableBody = React.forwardRef<
57
+ HTMLTableSectionElement,
58
+ React.ComponentProps<'tbody'>
59
+ >(function TableBody({ className, ...props }, ref) {
60
+ return (
61
+ <tbody
62
+ ref={ref}
63
+ className={tableBodyStyle({ class: className })}
64
+ {...props}
65
+ />
66
+ );
67
+ });
68
+
69
+ const TableFooter = React.forwardRef<
70
+ HTMLTableSectionElement,
71
+ React.ComponentProps<'tfoot'>
72
+ >(function TableFooter({ className, ...props }, ref) {
73
+ const contextValue = useMemo(() => {
74
+ return {
75
+ isFooterRow: true,
76
+ };
77
+ }, []);
78
+ return (
79
+ <TableFooterContext.Provider value={contextValue}>
80
+ <tfoot
81
+ ref={ref}
82
+ className={tableFooterStyle({ class: className })}
83
+ {...props}
84
+ />
85
+ </TableFooterContext.Provider>
86
+ );
87
+ });
88
+
89
+ const TableHead = React.forwardRef<
90
+ HTMLTableCellElement,
91
+ React.ComponentProps<'th'>
92
+ >(function TableHead({ className, ...props }, ref) {
93
+ return (
94
+ <th ref={ref} className={tableHeadStyle({ class: className })} {...props} />
95
+ );
96
+ });
97
+
98
+ const TableRow = React.forwardRef<
99
+ HTMLTableRowElement,
100
+ React.ComponentProps<'tr'>
101
+ >(function TableRow({ className, ...props }, ref) {
102
+ const { isHeaderRow } = useContext(TableHeaderContext);
103
+ const { isFooterRow } = useContext(TableFooterContext);
104
+ return (
105
+ <tr
106
+ ref={ref}
107
+ className={tableRowStyleStyle({
108
+ isHeaderRow,
109
+ isFooterRow,
110
+ class: className,
111
+ })}
112
+ {...props}
113
+ />
114
+ );
115
+ });
116
+
117
+ const TableData = React.forwardRef<
118
+ HTMLTableCellElement,
119
+ React.ComponentProps<'td'>
120
+ >(function TableData({ className, ...props }, ref) {
121
+ return (
122
+ <td ref={ref} className={tableDataStyle({ class: className })} {...props} />
123
+ );
124
+ });
125
+
126
+ const TableCaption = React.forwardRef<
127
+ HTMLTableCaptionElement,
128
+ React.ComponentProps<'caption'>
129
+ >(function TableCaption({ className, ...props }, ref) {
130
+ return (
131
+ <caption
132
+ ref={ref}
133
+ className={tableCaptionStyle({ class: className })}
134
+ {...props}
135
+ />
136
+ );
137
+ });
138
+
139
+ Table.displayName = 'Table';
140
+ TableHeader.displayName = 'TableHeader';
141
+ TableBody.displayName = 'TableBody';
142
+ TableFooter.displayName = 'TableFooter';
143
+ TableHead.displayName = 'TableHead';
144
+ TableRow.displayName = 'TableRow';
145
+ TableData.displayName = 'TableData';
146
+ TableCaption.displayName = 'TableCaption';
147
+
148
+ export {
149
+ Table,
150
+ TableHeader,
151
+ TableBody,
152
+ TableFooter,
153
+ TableHead,
154
+ TableRow,
155
+ TableData,
156
+ TableCaption,
157
+ };
@@ -0,0 +1,44 @@
1
+ import { tva } from '@gluestack-ui/utils/nativewind-utils';
2
+ import { isWeb } from '@gluestack-ui/utils/nativewind-utils';
3
+
4
+ const captionTableStyle = isWeb ? 'caption-bottom' : '';
5
+
6
+ export const tableStyle = tva({
7
+ base: `table border-collapse w-[800px]`,
8
+ });
9
+
10
+ export const tableHeaderStyle = tva({
11
+ base: '',
12
+ });
13
+
14
+ export const tableBodyStyle = tva({
15
+ base: '',
16
+ });
17
+
18
+ export const tableFooterStyle = tva({
19
+ base: '',
20
+ });
21
+
22
+ export const tableHeadStyle = tva({
23
+ base: 'flex-1 px-6 py-[14px] text-left font-bold text-[16px] leading-[22px] text-foreground/80 font-roboto',
24
+ });
25
+
26
+ export const tableRowStyleStyle = tva({
27
+ base: 'border-0 border-b border-solid border-border/80 bg-background',
28
+ variants: {
29
+ isHeaderRow: {
30
+ true: '',
31
+ },
32
+ isFooterRow: {
33
+ true: 'border-b-0 ',
34
+ },
35
+ },
36
+ });
37
+
38
+ export const tableDataStyle = tva({
39
+ base: 'flex-1 px-6 py-[14px] text-left text-[16px] font-medium leading-[22px] text-foreground/80 font-roboto',
40
+ });
41
+
42
+ export const tableCaptionStyle = tva({
43
+ base: `${captionTableStyle} px-6 py-[14px] text-[16px] font-normal leading-[22px] text-foreground/90 bg-background/90 font-roboto`,
44
+ });
@@ -0,0 +1,160 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Animated, {
3
+ useSharedValue,
4
+ useAnimatedStyle,
5
+ withTiming,
6
+ withDelay,
7
+ Easing,
8
+ SharedValue,
9
+ } from 'react-native-reanimated';
10
+ import type { LayoutData } from './creator';
11
+ import { tabsAnimationConfig } from './animation-config';
12
+ import { Platform } from 'react-native';
13
+ import { cssInterop } from 'nativewind';
14
+
15
+ interface TabsAnimatedIndicatorProps {
16
+ selectedKey: any;
17
+ orientation: 'horizontal' | 'vertical';
18
+ triggerLayouts: Map<any, LayoutData>;
19
+ scrollOffset?: number;
20
+ animatedScrollOffset?: SharedValue<number>;
21
+ className?: string;
22
+ style?: any;
23
+ }
24
+ Platform.OS === 'web' ? cssInterop(Animated.View,{className:{target:'style'}}) : Animated.View
25
+ const isWeb = Platform.OS === 'web';
26
+
27
+ export const TabsAnimatedIndicator = React.forwardRef<
28
+ any,
29
+ TabsAnimatedIndicatorProps
30
+ >(
31
+ (
32
+ {
33
+ selectedKey,
34
+ orientation,
35
+ triggerLayouts,
36
+ scrollOffset = 0,
37
+ animatedScrollOffset,
38
+ className,
39
+ style,
40
+ },
41
+ ref
42
+ ) => {
43
+ const animatedX = useSharedValue(0);
44
+ const animatedY = useSharedValue(0);
45
+ const animatedWidth = useSharedValue(0);
46
+ const animatedHeight = useSharedValue(0);
47
+ const [hasLayout, setHasLayout] = useState(false);
48
+ // Create a shared value for scroll offset to use in worklet
49
+ const scrollOffsetShared = useSharedValue(scrollOffset);
50
+
51
+ // Update scroll offset shared value when scrollOffset changes
52
+ useEffect(() => {
53
+ if (!animatedScrollOffset) {
54
+ scrollOffsetShared.value = scrollOffset;
55
+ }
56
+ }, [scrollOffset, scrollOffsetShared, animatedScrollOffset]);
57
+
58
+ useEffect(() => {
59
+ if (selectedKey && triggerLayouts.has(selectedKey)) {
60
+ const layout = triggerLayouts.get(selectedKey);
61
+
62
+ if (layout && layout.width > 0) {
63
+ // Determine if this is the first time we're setting values
64
+ const isFirstRender = !hasLayout;
65
+ const duration = isFirstRender
66
+ ? 0
67
+ : tabsAnimationConfig.indicatorDuration;
68
+
69
+ // Store the absolute x position (not adjusted for scroll)
70
+ animatedX.value = withDelay(
71
+ 20,
72
+ withTiming(layout.x, {
73
+ duration: duration,
74
+ easing: Easing.ease,
75
+ })
76
+ );
77
+ animatedY.value = withTiming(layout.y, {
78
+ duration: duration,
79
+ easing: Easing.ease,
80
+ });
81
+ animatedWidth.value = withTiming(layout.width, {
82
+ duration: duration,
83
+ easing: Easing.ease,
84
+ });
85
+ animatedHeight.value = withTiming(layout.height, {
86
+ duration: duration,
87
+ easing: Easing.ease,
88
+ });
89
+
90
+ if (!hasLayout) {
91
+ setHasLayout(true);
92
+ }
93
+ }
94
+ }
95
+ }, [
96
+ selectedKey,
97
+ triggerLayouts,
98
+ hasLayout,
99
+ animatedX,
100
+ animatedY,
101
+ animatedWidth,
102
+ animatedHeight,
103
+ ]);
104
+
105
+ const animatedStyle = useAnimatedStyle(() => {
106
+ 'worklet';
107
+
108
+ const scrollOffsetValue = animatedScrollOffset
109
+ ? animatedScrollOffset.value
110
+ : scrollOffsetShared.value;
111
+
112
+ const xPos = orientation === 'horizontal'
113
+ ? animatedX.value - scrollOffsetValue
114
+ : animatedX.value;
115
+
116
+ // Web: react-native-reanimated does not reliably flush the transform
117
+ // array to a CSS transform string, so use left/top instead.
118
+ // Native: keep transform for GPU-accelerated UI-thread animation.
119
+ if (isWeb) {
120
+ return {
121
+ left: xPos,
122
+ top: animatedY.value,
123
+ width: animatedWidth.value,
124
+ height: animatedHeight.value,
125
+ };
126
+ }
127
+
128
+ return {
129
+ transform: [
130
+ { translateX: xPos } as { translateX: number },
131
+ { translateY: animatedY.value } as { translateY: number },
132
+ ],
133
+ width: animatedWidth.value,
134
+ height: animatedHeight.value,
135
+ };
136
+ }, [orientation, animatedX, animatedY, animatedWidth, animatedHeight]);
137
+
138
+ // Don't render indicator until we have valid layout data
139
+ if (!hasLayout) {
140
+ return null;
141
+ }
142
+
143
+ return (
144
+ <Animated.View
145
+ ref={ref}
146
+ className={className}
147
+ style={[
148
+ animatedStyle,
149
+ style,
150
+ {
151
+ position: 'absolute',
152
+ zIndex:1,
153
+ },
154
+ ]}
155
+ />
156
+ );
157
+ }
158
+ );
159
+
160
+ TabsAnimatedIndicator.displayName = 'TabsAnimatedIndicator';
@@ -0,0 +1,3 @@
1
+ export const tabsAnimationConfig = {
2
+ indicatorDuration: 200,
3
+ };
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Local replacement for the (unpublished) `@gluestack-ui/core/tabs/creator`
3
+ * module. Implements the minimal state machine the `Tabs` components in
4
+ * `./index.tsx` rely on: selection, orientation, scroll-offset tracking, and
5
+ * layout measurement for the animated indicator.
6
+ */
7
+ import React from 'react';
8
+
9
+ export interface LayoutData {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ }
15
+
16
+ export interface TabsContextValue {
17
+ orientation: 'horizontal' | 'vertical';
18
+ selectedKey: string | undefined;
19
+ setSelectedKey: (key: string) => void;
20
+ scrollOffset: number;
21
+ setScrollOffset: (x: number) => void;
22
+ listRef: React.RefObject<any>;
23
+ triggerLayouts: Map<string, LayoutData>;
24
+ contentLayouts: Map<string, LayoutData>;
25
+ registerTriggerLayout: (key: string, layout: LayoutData) => void;
26
+ registerContentLayout: (key: string, layout: LayoutData) => void;
27
+ // Attached ad-hoc by TabsList so the indicator can read a Reanimated
28
+ // SharedValue for the scroll offset instead of the plain number above.
29
+ animatedScrollOffset?: import('react-native-reanimated').SharedValue<number>;
30
+ }
31
+
32
+ export const TabsContext = React.createContext<TabsContextValue | null>(null);
33
+
34
+ export interface CreateTabsConfig {
35
+ Root: React.ComponentType<any>;
36
+ List: React.ComponentType<any>;
37
+ Trigger: React.ComponentType<any>;
38
+ Content: React.ComponentType<any>;
39
+ ContentWrapper: React.ComponentType<any>;
40
+ TriggerText: React.ComponentType<any>;
41
+ TriggerIcon: React.ComponentType<any>;
42
+ Indicator: React.ComponentType<any>;
43
+ }
44
+
45
+ export function createTabs({
46
+ Root,
47
+ List,
48
+ Trigger,
49
+ Content,
50
+ ContentWrapper,
51
+ TriggerText,
52
+ TriggerIcon,
53
+ Indicator,
54
+ }: CreateTabsConfig) {
55
+ const Tabs = React.forwardRef<any, any>(function Tabs(
56
+ { value, defaultValue, onValueChange, orientation = 'horizontal', children, ...props },
57
+ ref
58
+ ) {
59
+ const [uncontrolledKey, setUncontrolledKey] = React.useState<string | undefined>(defaultValue);
60
+ const selectedKey = value !== undefined ? value : uncontrolledKey;
61
+ const [scrollOffset, setScrollOffsetState] = React.useState(0);
62
+ const listRef = React.useRef(null);
63
+ const triggerLayouts = React.useRef(new Map<string, LayoutData>()).current;
64
+ const contentLayouts = React.useRef(new Map<string, LayoutData>()).current;
65
+ const [, forceRender] = React.useReducer((c) => c + 1, 0);
66
+
67
+ const setSelectedKey = React.useCallback(
68
+ (key: string) => {
69
+ if (value === undefined) setUncontrolledKey(key);
70
+ onValueChange?.(key);
71
+ },
72
+ [value, onValueChange]
73
+ );
74
+
75
+ const registerTriggerLayout = React.useCallback((key: string, layout: LayoutData) => {
76
+ triggerLayouts.set(key, layout);
77
+ forceRender();
78
+ }, [triggerLayouts]);
79
+
80
+ const registerContentLayout = React.useCallback((key: string, layout: LayoutData) => {
81
+ contentLayouts.set(key, layout);
82
+ forceRender();
83
+ }, [contentLayouts]);
84
+
85
+ const contextValue = React.useMemo<TabsContextValue>(
86
+ () => ({
87
+ orientation,
88
+ selectedKey,
89
+ setSelectedKey,
90
+ scrollOffset,
91
+ setScrollOffset: setScrollOffsetState,
92
+ listRef,
93
+ triggerLayouts,
94
+ contentLayouts,
95
+ registerTriggerLayout,
96
+ registerContentLayout,
97
+ }),
98
+ [orientation, selectedKey, setSelectedKey, scrollOffset, triggerLayouts, contentLayouts, registerTriggerLayout, registerContentLayout]
99
+ );
100
+
101
+ return (
102
+ <TabsContext.Provider value={contextValue}>
103
+ <Root ref={ref} {...props}>
104
+ {children}
105
+ </Root>
106
+ </TabsContext.Provider>
107
+ );
108
+ });
109
+
110
+ const TabsListBase = React.forwardRef<any, any>(function TabsListBase({ children, ...props }, ref) {
111
+ return (
112
+ <List ref={ref} {...props}>
113
+ {children}
114
+ </List>
115
+ );
116
+ });
117
+
118
+ const TabsTriggerBase = React.forwardRef<any, any>(function TabsTriggerBase(
119
+ { value, disabled, onPress, onLayout, ...props },
120
+ ref
121
+ ) {
122
+ const context = React.useContext(TabsContext);
123
+ const isSelected = context?.selectedKey === value;
124
+
125
+ const handleLayout = React.useCallback(
126
+ (event: any) => {
127
+ const { x, y, width, height } = event.nativeEvent.layout;
128
+ context?.registerTriggerLayout(value, { x, y, width, height });
129
+ onLayout?.(event);
130
+ },
131
+ [context, value, onLayout]
132
+ );
133
+
134
+ const handlePress = React.useCallback(
135
+ (event: any) => {
136
+ if (!disabled) context?.setSelectedKey(value);
137
+ onPress?.(event);
138
+ },
139
+ [context, disabled, value, onPress]
140
+ );
141
+
142
+ return (
143
+ <Trigger
144
+ ref={ref}
145
+ onPress={handlePress}
146
+ onLayout={handleLayout}
147
+ disabled={disabled}
148
+ dataSet={{ selected: isSelected ? 'true' : 'false', disabled: disabled ? 'true' : 'false' }}
149
+ {...props}
150
+ />
151
+ );
152
+ });
153
+
154
+ const TabsContentBase = React.forwardRef<any, any>(function TabsContentBase(
155
+ { value, style, onLayout, ...props },
156
+ ref
157
+ ) {
158
+ const context = React.useContext(TabsContext);
159
+ const isSelected = context?.selectedKey === value;
160
+
161
+ const handleLayout = React.useCallback(
162
+ (event: any) => {
163
+ const { x, y, width, height } = event.nativeEvent.layout;
164
+ context?.registerContentLayout(value, { x, y, width, height });
165
+ onLayout?.(event);
166
+ },
167
+ [context, value, onLayout]
168
+ );
169
+
170
+ return (
171
+ <Content
172
+ ref={ref}
173
+ onLayout={handleLayout}
174
+ style={[style, !isSelected && { display: 'none' }]}
175
+ {...props}
176
+ />
177
+ );
178
+ });
179
+
180
+ const TabsContentWrapperBase = React.forwardRef<any, any>(function TabsContentWrapperBase(props, ref) {
181
+ return <ContentWrapper ref={ref} {...props} />;
182
+ });
183
+
184
+ const TabsIndicatorBase = React.forwardRef<any, any>(function TabsIndicatorBase(props, ref) {
185
+ return <Indicator ref={ref} {...props} />;
186
+ });
187
+
188
+ const Compound = Tabs as typeof Tabs & {
189
+ List: typeof TabsListBase;
190
+ Trigger: typeof TabsTriggerBase;
191
+ Content: typeof TabsContentBase;
192
+ ContentWrapper: typeof TabsContentWrapperBase;
193
+ TriggerText: typeof TriggerText;
194
+ TriggerIcon: typeof TriggerIcon;
195
+ Indicator: typeof TabsIndicatorBase;
196
+ };
197
+ Compound.List = TabsListBase;
198
+ Compound.Trigger = TabsTriggerBase;
199
+ Compound.Content = TabsContentBase;
200
+ Compound.ContentWrapper = TabsContentWrapperBase;
201
+ Compound.TriggerText = TriggerText;
202
+ Compound.TriggerIcon = TriggerIcon;
203
+ Compound.Indicator = TabsIndicatorBase;
204
+
205
+ return Compound;
206
+ }