@flipova/foundation 1.14.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 (268) hide show
  1. package/CHANGELOG.md +175 -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 -10
  173. package/dist/index.d.ts +40 -10
  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 -149
  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/createTheme-DQeX3s0I.d.mts +0 -78
  236. package/dist/createTheme-Y4jfz4-u.d.ts +0 -78
  237. package/dist/index-CuaJA3gM.d.mts +0 -78
  238. package/dist/index-CuaJA3gM.d.ts +0 -78
  239. package/dist/registry/index.d.mts +0 -10160
  240. package/dist/registry/index.d.ts +0 -10160
  241. package/dist/registry/index.js +0 -392
  242. package/dist/registry/index.js.map +0 -1
  243. package/dist/registry/index.mjs +0 -3
  244. package/dist/registry/index.mjs.map +0 -1
  245. package/dist/theme/index.d.mts +0 -35
  246. package/dist/theme/index.d.ts +0 -35
  247. package/dist/theme/index.js +0 -28
  248. package/dist/theme/index.js.map +0 -1
  249. package/dist/theme/index.mjs +0 -3
  250. package/dist/theme/index.mjs.map +0 -1
  251. package/dist/tokens/index.d.mts +0 -423
  252. package/dist/tokens/index.d.ts +0 -423
  253. package/dist/tokens/index.js +0 -44
  254. package/dist/tokens/index.js.map +0 -1
  255. package/dist/tokens/index.mjs +0 -3
  256. package/dist/tokens/index.mjs.map +0 -1
  257. package/dist/types/index.d.mts +0 -202
  258. package/dist/types/index.d.ts +0 -202
  259. package/dist/types/index.js +0 -4
  260. package/dist/types/index.js.map +0 -1
  261. package/dist/types/index.mjs +0 -3
  262. package/dist/types/index.mjs.map +0 -1
  263. package/dist/web/index.d.mts +0 -316
  264. package/dist/web/index.d.ts +0 -316
  265. package/dist/web/index.js +0 -1500
  266. package/dist/web/index.js.map +0 -1
  267. package/dist/web/index.mjs +0 -1396
  268. package/dist/web/index.mjs.map +0 -1
@@ -0,0 +1,96 @@
1
+ 'use client';
2
+ import React, { useEffect, useLayoutEffect } from 'react';
3
+ import { config } from './config';
4
+ import { OverlayProvider } from '@gluestack-ui/core/overlay/creator';
5
+ import { ToastProvider } from '@gluestack-ui/core/toast/creator';
6
+ import { setFlushStyles } from '@gluestack-ui/utils/nativewind-utils';
7
+ import { script } from './script';
8
+
9
+ export type ModeType = 'light' | 'dark' | 'system';
10
+
11
+ const variableStyleTagId = 'nativewind-style';
12
+ const createStyle = (styleTagId: string) => {
13
+ const style = document.createElement('style');
14
+ style.id = styleTagId;
15
+ style.appendChild(document.createTextNode(''));
16
+ return style;
17
+ };
18
+
19
+ export const useSafeLayoutEffect =
20
+ typeof window !== 'undefined' ? useLayoutEffect : useEffect;
21
+
22
+ export function GluestackUIProvider({
23
+ mode = 'light',
24
+ ...props
25
+ }: {
26
+ mode?: ModeType;
27
+ children?: React.ReactNode;
28
+ }) {
29
+ let cssVariablesWithMode = ``;
30
+ Object.keys(config).forEach((configKey) => {
31
+ cssVariablesWithMode +=
32
+ configKey === 'dark' ? `\n .dark {\n ` : `\n:root {\n`;
33
+ const cssVariables = Object.keys(
34
+ config[configKey as keyof typeof config]
35
+ ).reduce((acc: string, curr: string) => {
36
+ acc += `${curr}:${config[configKey as keyof typeof config][curr]}; `;
37
+ return acc;
38
+ }, '');
39
+ cssVariablesWithMode += `${cssVariables} \n}`;
40
+ });
41
+
42
+ setFlushStyles(cssVariablesWithMode);
43
+
44
+ const handleMediaQuery = React.useCallback((e: MediaQueryListEvent) => {
45
+ script(e.matches ? 'dark' : 'light');
46
+ }, []);
47
+
48
+ useSafeLayoutEffect(() => {
49
+ if (mode !== 'system') {
50
+ const documentElement = document.documentElement;
51
+ if (documentElement) {
52
+ documentElement.classList.add(mode);
53
+ documentElement.classList.remove(mode === 'light' ? 'dark' : 'light');
54
+ documentElement.style.colorScheme = mode;
55
+ }
56
+ }
57
+ }, [mode]);
58
+
59
+ useSafeLayoutEffect(() => {
60
+ if (mode !== 'system') return;
61
+ const media = window.matchMedia('(prefers-color-scheme: dark)');
62
+
63
+ media.addListener(handleMediaQuery);
64
+
65
+ return () => media.removeListener(handleMediaQuery);
66
+ }, [handleMediaQuery]);
67
+
68
+ useSafeLayoutEffect(() => {
69
+ if (typeof window !== 'undefined') {
70
+ const documentElement = document.documentElement;
71
+ if (documentElement) {
72
+ const head = documentElement.querySelector('head');
73
+ let style = head?.querySelector(`[id='${variableStyleTagId}']`);
74
+ if (!style) {
75
+ style = createStyle(variableStyleTagId);
76
+ style.innerHTML = cssVariablesWithMode;
77
+ if (head) head.appendChild(style);
78
+ }
79
+ }
80
+ }
81
+ }, []);
82
+
83
+ return (
84
+ <>
85
+ <script
86
+ suppressHydrationWarning
87
+ dangerouslySetInnerHTML={{
88
+ __html: `(${script.toString()})('${mode}')`,
89
+ }}
90
+ />
91
+ <OverlayProvider>
92
+ <ToastProvider>{props.children}</ToastProvider>
93
+ </OverlayProvider>
94
+ </>
95
+ );
96
+ }
@@ -0,0 +1,19 @@
1
+ export const script = (mode: string) => {
2
+ const documentElement = document.documentElement;
3
+
4
+ function getSystemColorMode() {
5
+ return window.matchMedia('(prefers-color-scheme: dark)').matches
6
+ ? 'dark'
7
+ : 'light';
8
+ }
9
+
10
+ try {
11
+ const isSystem = mode === 'system';
12
+ const theme = isSystem ? getSystemColorMode() : mode;
13
+ documentElement.classList.remove(theme === 'light' ? 'dark' : 'light');
14
+ documentElement.classList.add(theme);
15
+ documentElement.style.colorScheme = theme;
16
+ } catch (e) {
17
+ console.error(e);
18
+ }
19
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Type surface of the generated Tailwind theme.
3
+ *
4
+ * The runtime value is `tokens.js`, GENERATED from `design/tokens.xml` +
5
+ * `design/themes.xml` by `npm run design:gen` -- do not edit that file.
6
+ * This stub only types it, so `tailwind.config.ts` also works.
7
+ *
8
+ * Consume it from your Tailwind config:
9
+ *
10
+ * const tokens = require('@flipova/foundation/tokens');
11
+ * module.exports = { theme: { extend: tokens.theme } };
12
+ */
13
+ declare const tokens: {
14
+ theme: Record<string, Record<string, string | string[]>>;
15
+ };
16
+
17
+ export = tokens;
@@ -0,0 +1,188 @@
1
+ // Generated by design/tools/sources/generate.py -- do not edit by hand.
2
+ // Source of truth: design/tokens.xml + design/themes.xml
3
+ // Tailwind/nativewind theme, consumed by tailwind.config.js.
4
+ // Regenerate with: npm run design:gen
5
+ module.exports = {
6
+ theme: {
7
+ colors: {
8
+ 'background': 'rgb(var(--background)/<alpha-value>)',
9
+ 'foreground': 'rgb(var(--foreground)/<alpha-value>)',
10
+ 'card': 'rgb(var(--card)/<alpha-value>)',
11
+ 'card-foreground': 'rgb(var(--card-foreground)/<alpha-value>)',
12
+ 'popover': 'rgb(var(--popover)/<alpha-value>)',
13
+ 'popover-foreground': 'rgb(var(--popover-foreground)/<alpha-value>)',
14
+ 'primary': 'rgb(var(--primary)/<alpha-value>)',
15
+ 'primary-foreground': 'rgb(var(--primary-foreground)/<alpha-value>)',
16
+ 'secondary': 'rgb(var(--secondary)/<alpha-value>)',
17
+ 'secondary-foreground': 'rgb(var(--secondary-foreground)/<alpha-value>)',
18
+ 'muted': 'rgb(var(--muted)/<alpha-value>)',
19
+ 'muted-foreground': 'rgb(var(--muted-foreground)/<alpha-value>)',
20
+ 'accent': 'rgb(var(--accent)/<alpha-value>)',
21
+ 'accent-foreground': 'rgb(var(--accent-foreground)/<alpha-value>)',
22
+ 'destructive': 'rgb(var(--destructive)/<alpha-value>)',
23
+ 'destructive-foreground': 'rgb(var(--destructive-foreground)/<alpha-value>)',
24
+ 'border': 'rgb(var(--border)/<alpha-value>)',
25
+ 'input': 'rgb(var(--input)/<alpha-value>)',
26
+ 'ring': 'rgb(var(--ring)/<alpha-value>)',
27
+ 'success': 'rgb(var(--success)/<alpha-value>)',
28
+ 'success-foreground': 'rgb(var(--success-foreground)/<alpha-value>)',
29
+ 'warning': 'rgb(var(--warning)/<alpha-value>)',
30
+ 'warning-foreground': 'rgb(var(--warning-foreground)/<alpha-value>)',
31
+ 'error': 'rgb(var(--error)/<alpha-value>)',
32
+ 'error-foreground': 'rgb(var(--error-foreground)/<alpha-value>)',
33
+ 'info': 'rgb(var(--info)/<alpha-value>)',
34
+ 'info-foreground': 'rgb(var(--info-foreground)/<alpha-value>)',
35
+ },
36
+ spacing: {
37
+ '0': '0px',
38
+ '0.5': '2px',
39
+ '1': '4px',
40
+ '1.5': '6px',
41
+ '2': '8px',
42
+ '2.5': '10px',
43
+ '3': '12px',
44
+ '3.5': '14px',
45
+ '4': '16px',
46
+ '5': '20px',
47
+ '6': '24px',
48
+ '7': '28px',
49
+ '8': '32px',
50
+ '9': '36px',
51
+ '10': '40px',
52
+ '11': '44px',
53
+ '12': '48px',
54
+ '14': '56px',
55
+ '16': '64px',
56
+ '20': '80px',
57
+ '24': '96px',
58
+ '32': '128px',
59
+ '40': '160px',
60
+ '48': '192px',
61
+ },
62
+ borderRadius: {
63
+ 'none': '0px',
64
+ 'xs': '2px',
65
+ 'sm': '4px',
66
+ 'md': '8px',
67
+ 'lg': '12px',
68
+ 'xl': '16px',
69
+ '2xl': '24px',
70
+ '3xl': '32px',
71
+ 'full': '9999px',
72
+ },
73
+ screens: {
74
+ 'base': '0px',
75
+ 'xs': '480px',
76
+ 'sm': '640px',
77
+ 'md': '768px',
78
+ 'lg': '1024px',
79
+ 'xl': '1280px',
80
+ '2xl': '1536px',
81
+ },
82
+ fontFamily: {
83
+ 'system': ['system-ui', '-apple-system', 'Segoe UI', 'Roboto', 'sans-serif'],
84
+ 'mono': ['ui-monospace', 'SFMono-Regular', 'Menlo', 'monospace'],
85
+ 'serif': ['Georgia', 'Cambria', 'Times New Roman', 'serif'],
86
+ 'sans': ['var(--font-sans)'],
87
+ 'body': ['var(--font-sans)'],
88
+ 'heading': ['var(--font-heading)'],
89
+ 'roboto': ['Roboto', 'sans-serif'],
90
+ },
91
+ fontSize: {
92
+ '2xs': '10px',
93
+ 'xs': '12px',
94
+ 'sm': '14px',
95
+ 'md': '16px',
96
+ 'lg': '18px',
97
+ 'xl': '20px',
98
+ '2xl': '24px',
99
+ '3xl': '30px',
100
+ '4xl': '36px',
101
+ '5xl': '48px',
102
+ '6xl': '60px',
103
+ '7xl': '72px',
104
+ '8xl': '96px',
105
+ '9xl': '128px',
106
+ },
107
+ fontWeight: {
108
+ 'thin': '100',
109
+ 'extralight': '200',
110
+ 'light': '300',
111
+ 'normal': '400',
112
+ 'medium': '500',
113
+ 'semibold': '600',
114
+ 'bold': '700',
115
+ 'extrabold': '800',
116
+ 'black': '900',
117
+ },
118
+ lineHeight: {
119
+ 'xs': '16px',
120
+ 'sm': '20px',
121
+ 'md': '24px',
122
+ 'lg': '28px',
123
+ 'xl': '28px',
124
+ '2xl': '32px',
125
+ '3xl': '36px',
126
+ '4xl': '40px',
127
+ '5xl': '1',
128
+ '6xl': '1',
129
+ '7xl': '1',
130
+ '8xl': '1',
131
+ '9xl': '1',
132
+ },
133
+ letterSpacing: {
134
+ 'tighter': '-0.05em',
135
+ 'tight': '-0.025em',
136
+ 'normal': '0em',
137
+ 'wide': '0.025em',
138
+ 'wider': '0.05em',
139
+ 'widest': '0.1em',
140
+ },
141
+ boxShadow: {
142
+ 'sm': '0px 1px 2px rgb(0 0 0 / 0.05)',
143
+ 'md': '0px 3px 4px rgb(0 0 0 / 0.1)',
144
+ 'lg': '0px 6px 12px rgb(0 0 0 / 0.1)',
145
+ 'xl': '0px 12px 24px rgb(0 0 0 / 0.14)',
146
+ 'hard-1': '-2px 2px 8px rgb(38 38 38 / 0.2)',
147
+ 'hard-2': '0px 3px 10px rgb(38 38 38 / 0.2)',
148
+ 'hard-3': '2px 2px 8px rgb(38 38 38 / 0.2)',
149
+ 'hard-4': '0px -3px 10px rgb(38 38 38 / 0.2)',
150
+ 'hard-5': '0px 2px 10px rgb(38 38 38 / 0.1)',
151
+ 'soft-1': '0px 0px 10px rgb(38 38 38 / 0.1)',
152
+ 'soft-2': '0px 0px 20px rgb(38 38 38 / 0.2)',
153
+ 'soft-3': '0px 0px 30px rgb(38 38 38 / 0.1)',
154
+ 'soft-4': '0px 0px 40px rgb(38 38 38 / 0.1)',
155
+ },
156
+ zIndex: {
157
+ 'base': '0',
158
+ 'sticky': '100',
159
+ 'dropdown': '1000',
160
+ 'popover': '1500',
161
+ 'overlay': '1300',
162
+ 'drawer': '1400',
163
+ 'modal': '2000',
164
+ 'toast': '3000',
165
+ 'tooltip': '3100',
166
+ },
167
+ opacity: {
168
+ 'faint': '0.08',
169
+ 'muted': '0.4',
170
+ 'dim': '0.6',
171
+ 'solid': '1',
172
+ },
173
+ transitionDuration: {
174
+ 'instant': '0ms',
175
+ 'fastest': '80ms',
176
+ 'fast': '120ms',
177
+ 'normal': '200ms',
178
+ 'slow': '350ms',
179
+ 'slower': '500ms',
180
+ 'slowest': '700ms',
181
+ },
182
+ transitionTimingFunction: {
183
+ 'standard': 'cubic-bezier(0.4, 0, 0.2, 1)',
184
+ 'enter': 'cubic-bezier(0, 0, 0.2, 1)',
185
+ 'exit': 'cubic-bezier(0.4, 0, 1, 1)',
186
+ },
187
+ },
188
+ };
@@ -0,0 +1,82 @@
1
+ import { useColorScheme } from 'nativewind';
2
+ import { colors } from './config';
3
+
4
+ /**
5
+ * Convert CSS variable name to camelCase
6
+ * Example: '--primary-foreground' -> 'primaryForeground'
7
+ */
8
+ function toCamelCase(str: string): string {
9
+ return str
10
+ .replace(/^--/, '') // Remove leading --
11
+ .replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()); // Convert -x to X
12
+ }
13
+
14
+ /**
15
+ * Convert RGB string "23 23 23" to hex "#171717"
16
+ */
17
+ function rgbToHex(rgbString: string): string {
18
+ const parts = rgbString.trim().split(/\s+/);
19
+ if (parts.length !== 3) return '#000000';
20
+
21
+ const [r, g, b] = parts.map((s) => {
22
+ const num = parseInt(s, 10);
23
+ return isNaN(num) ? 0 : num;
24
+ });
25
+
26
+ const toHex = (n: number) =>
27
+ Math.max(0, Math.min(255, n)).toString(16).padStart(2, '0');
28
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
29
+ }
30
+
31
+ /**
32
+ * Hook to get all gluestack colors as hex values
33
+ * Automatically converts all CSS variables to camelCase
34
+ * Returns a dynamic object with all colors
35
+ *
36
+ * Usage: const colors = useGluestackColors();
37
+ * colors.primary -> '#171717'
38
+ * colors.primaryForeground -> '#fafafa'
39
+ * colors.forest -> '#228b22' (if you add --forest to config)
40
+ */
41
+ export function useGluestackColors(): Record<string, string> {
42
+ const { colorScheme } = useColorScheme();
43
+ const theme = colors[colorScheme || 'light'];
44
+
45
+ // Dynamically convert all CSS variables to camelCase hex colors
46
+ const result: Record<string, string> = {};
47
+
48
+ Object.entries(theme).forEach(([key, value]) => {
49
+ const camelKey = toCamelCase(key);
50
+ result[camelKey] = rgbToHex(value as string);
51
+ });
52
+
53
+ return result;
54
+ }
55
+
56
+ /**
57
+ * Hook to get calendar theme object for react-native-calendars
58
+ * Automatically maps all available colors
59
+ */
60
+ export function useCalendarTheme(): Record<string, string> {
61
+ const palette = useGluestackColors();
62
+
63
+ return {
64
+ backgroundColor: palette.background || '#ffffff',
65
+ calendarBackground: palette.background || '#ffffff',
66
+ textSectionTitleColor: palette.mutedForeground || '#737373',
67
+ selectedDayBackgroundColor: palette.primary || '#171717',
68
+ selectedDayTextColor: palette.primaryForeground || '#fafafa',
69
+ todayTextColor: palette.primary || '#171717',
70
+ todayBackgroundColor: palette.accent || '#f7f7f7',
71
+ dayTextColor: palette.foreground || '#0a0a0a',
72
+ textDisabledColor: palette.mutedForeground || '#737373',
73
+ dotColor: palette.primary || '#171717',
74
+ selectedDotColor: palette.primaryForeground || '#fafafa',
75
+ arrowColor: palette.foreground || '#0a0a0a',
76
+ monthTextColor: palette.foreground || '#0a0a0a',
77
+ indicatorColor: palette.primary || '#171717',
78
+ };
79
+ }
80
+
81
+ // Type helper - you can use this to get typed colors if needed
82
+ export type GluestackColors = ReturnType<typeof useGluestackColors>;
@@ -0,0 +1,283 @@
1
+ import React, {
2
+ useState,
3
+ createContext,
4
+ useContext,
5
+ useMemo,
6
+ forwardRef,
7
+ } from 'react';
8
+ import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
9
+ import { View, Dimensions, Platform, ViewProps } from 'react-native';
10
+ import { gridStyle, gridItemStyle } from './styles';
11
+ import { cssInterop } from 'nativewind';
12
+ import {
13
+ useBreakpointValue,
14
+ getBreakPointValue,
15
+ } from '@gluestack-ui/utils/hooks';
16
+ const { width: DEVICE_WIDTH } = Dimensions.get('window');
17
+ const GridContext = createContext<any>({});
18
+ function arrangeChildrenIntoRows({
19
+ childrenArray,
20
+ colSpanArr,
21
+ numColumns,
22
+ }: {
23
+ childrenArray: React.ReactNode[];
24
+ colSpanArr: number[];
25
+ numColumns: number;
26
+ }) {
27
+ let currentRow = 1;
28
+ let currentRowTotalColSpan = 0;
29
+ // store how many items in each row
30
+ const rowItemsCount: {
31
+ [key: number]: number[];
32
+ } = {};
33
+ for (let i = 0; i < childrenArray.length; i++) {
34
+ const colSpan = colSpanArr[i];
35
+ // if current row is full, go to next row
36
+ if (currentRowTotalColSpan + colSpan > numColumns) {
37
+ currentRow++;
38
+ currentRowTotalColSpan = colSpan;
39
+ } else {
40
+ // if current row is not full, add colSpan to current row
41
+ currentRowTotalColSpan += colSpan;
42
+ }
43
+ rowItemsCount[currentRow] = rowItemsCount[currentRow]
44
+ ? [...rowItemsCount[currentRow], i]
45
+ : [i];
46
+ }
47
+ return rowItemsCount;
48
+ }
49
+ function generateResponsiveNumColumns({ gridClass }: { gridClass: string }) {
50
+ const gridClassNamePattern = /\b(?:\w+:)?grid-cols-?\d+\b/g;
51
+ const numColumns = gridClass?.match(gridClassNamePattern);
52
+ if (!numColumns) {
53
+ return 12;
54
+ }
55
+ const regex = /^(?:(\w+):)?grid-cols-?(\d+)$/;
56
+ const result: any = {};
57
+ numColumns.forEach((classname) => {
58
+ const match = classname.match(regex);
59
+ if (match) {
60
+ const prefix = match[1] || 'default';
61
+ const value = parseInt(match[2], 10);
62
+ result[prefix] = value;
63
+ }
64
+ });
65
+ return result;
66
+ }
67
+ function generateResponsiveColSpans({
68
+ gridItemClassName,
69
+ }: {
70
+ gridItemClassName: string;
71
+ }) {
72
+ const gridClassNamePattern = /\b(?:\w+:)?col-span-?\d+\b/g;
73
+ const colSpan: any = gridItemClassName?.match(gridClassNamePattern);
74
+ if (!colSpan) {
75
+ return 1;
76
+ }
77
+ const regex = /^(?:(\w+):)?col-span-?(\d+)$/;
78
+ const result: any = {};
79
+ colSpan.forEach((classname: any) => {
80
+ const match = classname.match(regex);
81
+ if (match) {
82
+ const prefix = match[1] || 'default';
83
+ const value = parseInt(match[2], 10);
84
+ result[prefix] = value;
85
+ }
86
+ });
87
+ return result;
88
+ }
89
+ type IGridProps = ViewProps &
90
+ VariantProps<typeof gridStyle> & {
91
+ gap?: number;
92
+ rowGap?: number;
93
+ columnGap?: number;
94
+ flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
95
+ padding?: number;
96
+ paddingLeft?: number;
97
+ paddingRight?: number;
98
+ paddingStart?: number;
99
+ paddingEnd?: number;
100
+ borderWidth?: number;
101
+ borderLeftWidth?: number;
102
+ borderRightWidth?: number;
103
+ _extra: {
104
+ className: string;
105
+ };
106
+ };
107
+ const Grid = forwardRef<React.ComponentRef<typeof View>, IGridProps>(
108
+ function Grid({ className, _extra, children, ...props }, ref) {
109
+ const [calculatedWidth, setCalculatedWidth] = useState<number | null>(null);
110
+ const gridClass = _extra?.className;
111
+ const obj = generateResponsiveNumColumns({ gridClass });
112
+ const responsiveNumColumns: any = useBreakpointValue(obj);
113
+ const itemsPerRow = useMemo(() => {
114
+ // get the colSpan of each child
115
+ const colSpanArr = React.Children.map(children, (child: any) => {
116
+ const gridItemClassName = child?.props?._extra?.className;
117
+ const colSpan2 = getBreakPointValue(
118
+ generateResponsiveColSpans({ gridItemClassName }),
119
+ DEVICE_WIDTH
120
+ );
121
+ const colSpan = colSpan2 ? colSpan2 : 1;
122
+ if (colSpan > responsiveNumColumns) {
123
+ return responsiveNumColumns;
124
+ }
125
+ return colSpan;
126
+ });
127
+ const childrenArray = React.Children.toArray(children);
128
+ const rowItemsCount = arrangeChildrenIntoRows({
129
+ childrenArray,
130
+ colSpanArr,
131
+ numColumns: responsiveNumColumns,
132
+ });
133
+ return rowItemsCount;
134
+ }, [responsiveNumColumns, children]);
135
+ const childrenWithProps = React.Children.map(children, (child, index) => {
136
+ if (React.isValidElement(child)) {
137
+ return React.cloneElement(child, { key: index, index: index } as any);
138
+ }
139
+ return child;
140
+ });
141
+ const gridClassMerged = `${Platform.select({
142
+ web: gridClass ?? '',
143
+ })}`;
144
+ const contextValue = useMemo(() => {
145
+ return {
146
+ calculatedWidth,
147
+ numColumns: responsiveNumColumns,
148
+ itemsPerRow,
149
+ flexDirection: props?.flexDirection || 'row',
150
+ gap: props?.gap || 0,
151
+ columnGap: props?.columnGap || 0,
152
+ };
153
+ }, [calculatedWidth, itemsPerRow, responsiveNumColumns, props]);
154
+ const borderLeftWidth = props?.borderLeftWidth || props?.borderWidth || 0;
155
+ const borderRightWidth = props?.borderRightWidth || props?.borderWidth || 0;
156
+ const borderWidthToSubtract = borderLeftWidth + borderRightWidth;
157
+ return (
158
+ <GridContext.Provider value={contextValue}>
159
+ <View
160
+ ref={ref}
161
+ className={gridStyle({
162
+ class: className + ' ' + gridClassMerged,
163
+ })}
164
+ onLayout={(event) => {
165
+ const paddingLeftToSubtract =
166
+ props?.paddingStart || props?.paddingLeft || props?.padding || 0;
167
+ const paddingRightToSubtract =
168
+ props?.paddingEnd || props?.paddingRight || props?.padding || 0;
169
+ const gridWidth =
170
+ Math.floor(event.nativeEvent.layout.width) -
171
+ paddingLeftToSubtract -
172
+ paddingRightToSubtract -
173
+ borderWidthToSubtract;
174
+ setCalculatedWidth(gridWidth);
175
+ }}
176
+ {...props}
177
+ >
178
+ {calculatedWidth && childrenWithProps}
179
+ </View>
180
+ </GridContext.Provider>
181
+ );
182
+ }
183
+ );
184
+ cssInterop(Grid, {
185
+ className: {
186
+ target: 'style',
187
+ nativeStyleToProp: {
188
+ gap: 'gap',
189
+ rowGap: 'rowGap',
190
+ columnGap: 'columnGap',
191
+ flexDirection: 'flexDirection',
192
+ padding: 'padding',
193
+ paddingLeft: 'paddingLeft',
194
+ paddingRight: 'paddingRight',
195
+ paddingStart: 'paddingStart',
196
+ paddingEnd: 'paddingEnd',
197
+ borderWidth: 'borderWidth',
198
+ borderLeftWidth: 'borderLeftWidth',
199
+ borderRightWidth: 'borderRightWidth',
200
+ },
201
+ },
202
+ });
203
+ type IGridItemProps = ViewProps &
204
+ VariantProps<typeof gridItemStyle> & {
205
+ index?: number;
206
+ _extra: {
207
+ className: string;
208
+ };
209
+ };
210
+ const GridItem = forwardRef<React.ComponentRef<typeof View>, IGridItemProps>(
211
+ function GridItem({ className, _extra, ...props }, ref) {
212
+ const {
213
+ calculatedWidth,
214
+ numColumns,
215
+ itemsPerRow,
216
+ flexDirection,
217
+ gap,
218
+ columnGap,
219
+ } = useContext(GridContext);
220
+ const gridItemClass = _extra?.className;
221
+ const responsiveColSpan = (useBreakpointValue(
222
+ generateResponsiveColSpans({ gridItemClassName: gridItemClass })
223
+ ) ?? 1) as number;
224
+ const flexBasisValue = useMemo(() => {
225
+ if (!calculatedWidth || !numColumns || responsiveColSpan <= 0) {
226
+ return 'auto';
227
+ }
228
+ if (flexDirection?.includes('column')) {
229
+ return 'auto';
230
+ }
231
+ // Find which row this item is in
232
+ const row = Object.keys(itemsPerRow).find((key) => {
233
+ return itemsPerRow[key].includes(props?.index);
234
+ });
235
+ if (!row) {
236
+ return 'auto';
237
+ }
238
+ const rowColsCount = itemsPerRow[row]?.length || 1;
239
+ const space = columnGap || gap || 0;
240
+ // Calculate available width accounting for gaps
241
+ const totalGapWidth = space * (rowColsCount - 1);
242
+ const availableWidth = calculatedWidth - totalGapWidth;
243
+ // Calculate the width for this item based on its column span
244
+ const itemWidth = (availableWidth * responsiveColSpan) / numColumns;
245
+ // Return the width directly instead of percentage for better native compatibility
246
+ return Math.max(0, Math.floor(itemWidth));
247
+ }, [
248
+ calculatedWidth,
249
+ responsiveColSpan,
250
+ numColumns,
251
+ columnGap,
252
+ gap,
253
+ flexDirection,
254
+ itemsPerRow,
255
+ props?.index,
256
+ ]);
257
+ return (
258
+ <View
259
+ ref={ref}
260
+ // @ts-expect-error : internal implementation for r-19/react-native-web
261
+ gridItemClass={gridItemClass}
262
+ className={gridItemStyle({
263
+ class: className,
264
+ })}
265
+ {...props}
266
+ style={[
267
+ {
268
+ width:
269
+ typeof flexBasisValue === 'number' ? flexBasisValue : undefined,
270
+ flexBasis:
271
+ typeof flexBasisValue === 'string' ? flexBasisValue : undefined,
272
+ flexShrink: 0,
273
+ flexGrow: 0,
274
+ },
275
+ props.style,
276
+ ]}
277
+ />
278
+ );
279
+ }
280
+ );
281
+ Grid.displayName = 'Grid';
282
+ GridItem.displayName = 'GridItem';
283
+ export { Grid, GridItem };