@flipova/foundation 2.4.3 → 3.0.0-alpha.1

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 (402) hide show
  1. package/CHANGES.md +66 -0
  2. package/COMPONENTS.md +102 -0
  3. package/DOCS.md +261 -0
  4. package/LICENSE +1 -1
  5. package/README.md +169 -118
  6. package/components/contract/index.ts +3 -0
  7. package/components/contract/recipes/accordion.ts +42 -0
  8. package/components/contract/recipes/avatar.ts +41 -0
  9. package/components/contract/recipes/badge.ts +46 -0
  10. package/components/contract/recipes/button.ts +58 -0
  11. package/components/contract/recipes/calendar.ts +118 -0
  12. package/components/contract/recipes/card.ts +21 -0
  13. package/components/contract/recipes/checkbox.ts +33 -0
  14. package/components/contract/recipes/divider.ts +9 -0
  15. package/components/contract/recipes/fab.ts +31 -0
  16. package/components/contract/recipes/feedback.ts +66 -0
  17. package/components/contract/recipes/formcontrol.ts +16 -0
  18. package/components/contract/recipes/heading.ts +16 -0
  19. package/components/contract/recipes/icon.ts +40 -0
  20. package/components/contract/recipes/index.ts +30 -0
  21. package/components/contract/recipes/input.ts +39 -0
  22. package/components/contract/recipes/layout.ts +44 -0
  23. package/components/contract/recipes/link.ts +6 -0
  24. package/components/contract/recipes/modal.ts +40 -0
  25. package/components/contract/recipes/overlay.ts +250 -0
  26. package/components/contract/recipes/progress.ts +27 -0
  27. package/components/contract/recipes/radio.ts +39 -0
  28. package/components/contract/recipes/select.ts +63 -0
  29. package/components/contract/recipes/skeleton.ts +25 -0
  30. package/components/contract/recipes/slider.ts +50 -0
  31. package/components/contract/recipes/spinner.ts +12 -0
  32. package/components/contract/recipes/switch.ts +26 -0
  33. package/components/contract/recipes/table.ts +37 -0
  34. package/components/contract/recipes/tabs.ts +31 -0
  35. package/components/contract/recipes/text.ts +12 -0
  36. package/components/contract/recipes/textarea.ts +37 -0
  37. package/components/contract/recipes/util.ts +15 -0
  38. package/components/contract/theme.ts +116 -0
  39. package/components/contract/types.ts +598 -0
  40. package/components/providers/css-vars.ts +43 -0
  41. package/components/providers/flipova/components/Accordion.tsx +41 -0
  42. package/components/providers/flipova/components/ActionSheet.tsx +34 -0
  43. package/components/providers/flipova/components/Alert.tsx +15 -0
  44. package/components/providers/flipova/components/AlertDialog.tsx +31 -0
  45. package/components/providers/flipova/components/Avatar.tsx +30 -0
  46. package/components/providers/flipova/components/Badge.tsx +14 -0
  47. package/components/providers/flipova/components/BottomSheet.tsx +24 -0
  48. package/components/providers/flipova/components/Box.tsx +1 -0
  49. package/components/providers/flipova/components/Button.tsx +31 -0
  50. package/components/providers/flipova/components/Calendar.tsx +85 -0
  51. package/components/providers/flipova/components/Card.tsx +13 -0
  52. package/components/providers/flipova/components/Center.tsx +11 -0
  53. package/components/providers/flipova/components/Checkbox.tsx +24 -0
  54. package/components/providers/flipova/components/DateTimePicker.tsx +45 -0
  55. package/components/providers/flipova/components/Divider.tsx +9 -0
  56. package/components/providers/flipova/components/Drawer.tsx +18 -0
  57. package/components/providers/flipova/components/Fab.tsx +22 -0
  58. package/components/providers/flipova/components/FlatList.tsx +1 -0
  59. package/components/providers/flipova/components/FormControl.tsx +27 -0
  60. package/components/providers/flipova/components/Grid.tsx +18 -0
  61. package/components/providers/flipova/components/HStack.tsx +13 -0
  62. package/components/providers/flipova/components/Heading.tsx +19 -0
  63. package/components/providers/flipova/components/Icon.tsx +20 -0
  64. package/components/providers/flipova/components/Image.tsx +1 -0
  65. package/components/providers/flipova/components/ImageBackground.tsx +1 -0
  66. package/components/providers/flipova/components/ImageViewer.tsx +25 -0
  67. package/components/providers/flipova/components/Input.tsx +29 -0
  68. package/components/providers/flipova/components/InputAccessoryView.tsx +1 -0
  69. package/components/providers/flipova/components/KeyboardAvoidingView.tsx +1 -0
  70. package/components/providers/flipova/components/Link.tsx +21 -0
  71. package/components/providers/flipova/components/LiquidGlass.tsx +13 -0
  72. package/components/providers/flipova/components/Menu.tsx +43 -0
  73. package/components/providers/flipova/components/Modal.tsx +24 -0
  74. package/components/providers/flipova/components/Popover.tsx +23 -0
  75. package/components/providers/flipova/components/Portal.tsx +42 -0
  76. package/components/providers/flipova/components/Pressable.tsx +1 -0
  77. package/components/providers/flipova/components/Progress.tsx +22 -0
  78. package/components/providers/flipova/components/RadioGroup.tsx +36 -0
  79. package/components/providers/flipova/components/RefreshControl.tsx +1 -0
  80. package/components/providers/flipova/components/SafeAreaView.tsx +1 -0
  81. package/components/providers/flipova/components/ScrollView.tsx +1 -0
  82. package/components/providers/flipova/components/SectionList.tsx +1 -0
  83. package/components/providers/flipova/components/Select.tsx +61 -0
  84. package/components/providers/flipova/components/Skeleton.tsx +25 -0
  85. package/components/providers/flipova/components/Slider.tsx +52 -0
  86. package/components/providers/flipova/components/Spinner.tsx +19 -0
  87. package/components/providers/flipova/components/StatusBar.tsx +1 -0
  88. package/components/providers/flipova/components/Switch.tsx +21 -0
  89. package/components/providers/flipova/components/Table.tsx +33 -0
  90. package/components/providers/flipova/components/Tabs.tsx +39 -0
  91. package/components/providers/flipova/components/Text.tsx +13 -0
  92. package/components/providers/flipova/components/Textarea.tsx +28 -0
  93. package/components/providers/flipova/components/Toast.tsx +28 -0
  94. package/components/providers/flipova/components/Tooltip.tsx +34 -0
  95. package/components/providers/flipova/components/VStack.tsx +13 -0
  96. package/components/providers/flipova/components/View.tsx +1 -0
  97. package/components/providers/flipova/components/VirtualizedList.tsx +1 -0
  98. package/components/providers/flipova/index.tsx +189 -0
  99. package/components/providers/gluestack/index.tsx +226 -0
  100. package/components/providers/gluestack/more.tsx +151 -0
  101. package/components/{ui → providers/gluestack/ui}/accordion/index.tsx +2 -2
  102. package/components/{ui → providers/gluestack/ui}/actionsheet/index.tsx +15 -15
  103. package/components/{ui → providers/gluestack/ui}/alert/index.tsx +1 -1
  104. package/components/{ui → providers/gluestack/ui}/alert-dialog/index.tsx +3 -3
  105. package/components/{ui → providers/gluestack/ui}/badge/index.tsx +2 -2
  106. package/components/{ui → providers/gluestack/ui}/bottomsheet/index.tsx +11 -10
  107. package/components/{ui → providers/gluestack/ui}/box/index.tsx +4 -1
  108. package/components/{ui → providers/gluestack/ui}/button/index.tsx +1 -1
  109. package/components/{ui → providers/gluestack/ui}/calendar/index.tsx +4 -4
  110. package/components/{ui → providers/gluestack/ui}/card/index.tsx +1 -1
  111. package/components/{ui → providers/gluestack/ui}/center/index.tsx +1 -1
  112. package/components/{ui → providers/gluestack/ui}/checkbox/index.tsx +9 -8
  113. package/components/{ui → providers/gluestack/ui}/date-time-picker/index.tsx +4 -4
  114. package/components/providers/gluestack/ui/date-time-picker/index.web.tsx +197 -0
  115. package/components/{ui → providers/gluestack/ui}/divider/index.tsx +1 -1
  116. package/components/{ui → providers/gluestack/ui}/drawer/index.tsx +2 -2
  117. package/components/{ui → providers/gluestack/ui}/fab/index.tsx +1 -1
  118. package/components/{ui → providers/gluestack/ui}/form-control/index.tsx +3 -3
  119. package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/config.ts +1 -62
  120. package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/tokens.js +1 -1
  121. package/components/{ui → providers/gluestack/ui}/grid/index.tsx +3 -3
  122. package/components/{ui → providers/gluestack/ui}/heading/index.tsx +7 -7
  123. package/components/{ui → providers/gluestack/ui}/hstack/index.tsx +1 -1
  124. package/components/{ui → providers/gluestack/ui}/icon/index.tsx +1 -1
  125. package/components/{ui → providers/gluestack/ui}/image/index.tsx +0 -1
  126. package/components/{ui → providers/gluestack/ui}/image-viewer/index.tsx +96 -99
  127. package/components/providers/gluestack/ui/index.ts +58 -0
  128. package/components/{ui → providers/gluestack/ui}/input/index.tsx +1 -1
  129. package/components/{ui → providers/gluestack/ui}/link/index.tsx +2 -2
  130. package/components/{ui → providers/gluestack/ui}/liquid-glass/index.tsx +2 -2
  131. package/components/{ui → providers/gluestack/ui}/menu/index.tsx +5 -4
  132. package/components/{ui → providers/gluestack/ui}/modal/index.tsx +19 -17
  133. package/components/{ui → providers/gluestack/ui}/popover/index.tsx +4 -4
  134. package/components/{ui → providers/gluestack/ui}/portal/index.tsx +1 -1
  135. package/components/{ui → providers/gluestack/ui}/progress/index.tsx +2 -2
  136. package/components/{ui → providers/gluestack/ui}/radio/index.tsx +1 -1
  137. package/components/{ui → providers/gluestack/ui}/select/index.tsx +8 -12
  138. package/components/{ui → providers/gluestack/ui}/select/select-actionsheet.tsx +13 -13
  139. package/components/{ui → providers/gluestack/ui}/skeleton/index.tsx +2 -2
  140. package/components/{ui → providers/gluestack/ui}/slider/index.tsx +1 -1
  141. package/components/{ui → providers/gluestack/ui}/spinner/index.tsx +2 -2
  142. package/components/{ui → providers/gluestack/ui}/table/index.tsx +33 -33
  143. package/components/{ui → providers/gluestack/ui}/tabs/TabsAnimatedIndicator.tsx +1 -1
  144. package/components/{ui → providers/gluestack/ui}/tabs/index.tsx +2 -2
  145. package/components/{ui → providers/gluestack/ui}/text/index.tsx +1 -1
  146. package/components/{ui → providers/gluestack/ui}/toast/index.tsx +4 -4
  147. package/components/{ui → providers/gluestack/ui}/tooltip/index.tsx +1 -1
  148. package/components/{ui → providers/gluestack/ui}/vstack/index.tsx +1 -1
  149. package/components/providers/index.ts +2 -0
  150. package/components/providers/paper/index.tsx +449 -0
  151. package/components/providers/provider.tsx +80 -0
  152. package/components/providers/reusables/classes.ts +163 -0
  153. package/components/providers/reusables/index.tsx +289 -0
  154. package/components/providers/rn-base/Box.tsx +7 -0
  155. package/components/providers/rn-base/FlatList.tsx +16 -0
  156. package/components/providers/rn-base/Image.tsx +18 -0
  157. package/components/providers/rn-base/ImageBackground.tsx +11 -0
  158. package/components/providers/rn-base/InputAccessoryView.tsx +9 -0
  159. package/components/providers/rn-base/KeyboardAvoidingView.tsx +15 -0
  160. package/components/providers/rn-base/Pressable.tsx +19 -0
  161. package/components/providers/rn-base/RefreshControl.tsx +16 -0
  162. package/components/providers/rn-base/SafeAreaView.tsx +11 -0
  163. package/components/providers/rn-base/ScrollView.tsx +11 -0
  164. package/components/providers/rn-base/SectionList.tsx +22 -0
  165. package/components/providers/rn-base/StatusBar.tsx +17 -0
  166. package/components/providers/rn-base/View.tsx +7 -0
  167. package/components/providers/rn-base/VirtualizedList.tsx +18 -0
  168. package/components/providers/rn-base/index.tsx +64 -0
  169. package/components/providers/tamagui/index.tsx +375 -0
  170. package/components/providers/types.ts +17 -0
  171. package/components/theme/design-theme.ts +230 -0
  172. package/components/ui/create.tsx +14 -0
  173. package/components/ui/index.ts +68 -58
  174. package/components/ui/resolve.ts +40 -0
  175. package/design/canonical.index.txt +2 -16
  176. package/design/manifest.xml +4 -3
  177. package/design/schema.xsd +44 -434
  178. package/design/themes.xml +7 -177
  179. package/design/tools/{npm.js → cli.js} +173 -73
  180. package/design/tools/gui/index.html +998 -0
  181. package/design/tools/lib/check.js +533 -0
  182. package/design/tools/lib/contract.js +23 -0
  183. package/design/tools/lib/edit.js +166 -0
  184. package/design/tools/lib/generate.js +465 -0
  185. package/design/tools/lib/gui.js +614 -0
  186. package/design/tools/lib/lint.js +139 -0
  187. package/design/tools/lib/registry.js +135 -0
  188. package/design/tools/lib/util.js +53 -0
  189. package/design/tools/lib/xml.js +257 -0
  190. package/design/tools/lib/xsd.js +408 -0
  191. package/dist/chunk-2QM2ZUDS.mjs +1308 -0
  192. package/dist/chunk-2QM2ZUDS.mjs.map +1 -0
  193. package/dist/chunk-2T2TCUYF.js +1371 -0
  194. package/dist/chunk-2T2TCUYF.js.map +1 -0
  195. package/dist/chunk-6UKTC4KF.js +43 -0
  196. package/dist/chunk-6UKTC4KF.js.map +1 -0
  197. package/dist/chunk-6Z4WRTI4.mjs +37 -0
  198. package/dist/chunk-6Z4WRTI4.mjs.map +1 -0
  199. package/dist/chunk-G3K6J5KY.js +157 -0
  200. package/dist/chunk-G3K6J5KY.js.map +1 -0
  201. package/dist/chunk-GM45RCSI.mjs +96 -0
  202. package/dist/chunk-GM45RCSI.mjs.map +1 -0
  203. package/dist/chunk-GQJLHH2P.mjs +3 -0
  204. package/dist/chunk-GQJLHH2P.mjs.map +1 -0
  205. package/dist/chunk-ICNR56VP.js +1653 -0
  206. package/dist/chunk-ICNR56VP.js.map +1 -0
  207. package/dist/chunk-J5LGTIGS.mjs +9 -0
  208. package/dist/chunk-J5LGTIGS.mjs.map +1 -0
  209. package/dist/chunk-LRPZLF2K.mjs +30 -0
  210. package/dist/chunk-LRPZLF2K.mjs.map +1 -0
  211. package/dist/chunk-OC4MXNXU.js +32 -0
  212. package/dist/chunk-OC4MXNXU.js.map +1 -0
  213. package/dist/chunk-PZ5AY32C.js +11 -0
  214. package/dist/chunk-PZ5AY32C.js.map +1 -0
  215. package/dist/chunk-RWVTZUEG.js +161 -0
  216. package/dist/chunk-RWVTZUEG.js.map +1 -0
  217. package/dist/chunk-V473I5XQ.js +4 -0
  218. package/dist/chunk-V473I5XQ.js.map +1 -0
  219. package/dist/chunk-V4ULAISZ.js +915 -0
  220. package/dist/chunk-V4ULAISZ.js.map +1 -0
  221. package/dist/chunk-WRJERTJS.mjs +145 -0
  222. package/dist/chunk-WRJERTJS.mjs.map +1 -0
  223. package/dist/chunk-YIBPE3KQ.mjs +864 -0
  224. package/dist/chunk-YIBPE3KQ.mjs.map +1 -0
  225. package/dist/chunk-YUAQIZPN.mjs +1556 -0
  226. package/dist/chunk-YUAQIZPN.mjs.map +1 -0
  227. package/dist/contract/index.d.mts +304 -0
  228. package/dist/contract/index.d.ts +304 -0
  229. package/dist/contract/index.js +256 -0
  230. package/dist/contract/index.js.map +1 -0
  231. package/dist/contract/index.mjs +3 -0
  232. package/dist/contract/index.mjs.map +1 -0
  233. package/dist/index.d.mts +4 -40
  234. package/dist/index.d.ts +4 -40
  235. package/dist/index.js +73 -992
  236. package/dist/index.mjs +2 -1
  237. package/dist/providers/flipova/index.d.mts +133 -0
  238. package/dist/providers/flipova/index.d.ts +133 -0
  239. package/dist/providers/flipova/index.js +249 -0
  240. package/dist/providers/flipova/index.js.map +1 -0
  241. package/dist/providers/flipova/index.mjs +4 -0
  242. package/dist/providers/flipova/index.mjs.map +1 -0
  243. package/dist/providers/gluestack/index.d.mts +7 -0
  244. package/dist/providers/gluestack/index.d.ts +7 -0
  245. package/dist/providers/gluestack/index.js +240 -0
  246. package/dist/providers/gluestack/index.js.map +1 -0
  247. package/dist/providers/gluestack/index.mjs +238 -0
  248. package/dist/providers/gluestack/index.mjs.map +1 -0
  249. package/dist/providers/gluestack/ui/index.d.mts +3472 -0
  250. package/dist/providers/gluestack/ui/index.d.ts +3472 -0
  251. package/dist/{chunk-LCTFQJZM.js → providers/gluestack/ui/index.js} +860 -2297
  252. package/dist/providers/gluestack/ui/index.js.map +1 -0
  253. package/dist/{chunk-2R66P5X5.mjs → providers/gluestack/ui/index.mjs} +468 -2062
  254. package/dist/providers/gluestack/ui/index.mjs.map +1 -0
  255. package/dist/providers/index.d.mts +37 -0
  256. package/dist/providers/index.d.ts +37 -0
  257. package/dist/providers/index.js +28 -0
  258. package/dist/providers/index.js.map +1 -0
  259. package/dist/providers/index.mjs +3 -0
  260. package/dist/providers/index.mjs.map +1 -0
  261. package/dist/providers/paper/index.d.mts +30 -0
  262. package/dist/providers/paper/index.d.ts +30 -0
  263. package/dist/providers/paper/index.js +362 -0
  264. package/dist/providers/paper/index.js.map +1 -0
  265. package/dist/providers/paper/index.mjs +353 -0
  266. package/dist/providers/paper/index.mjs.map +1 -0
  267. package/dist/providers/reusables/index.d.mts +60 -0
  268. package/dist/providers/reusables/index.d.ts +60 -0
  269. package/dist/providers/reusables/index.js +348 -0
  270. package/dist/providers/reusables/index.js.map +1 -0
  271. package/dist/providers/reusables/index.mjs +311 -0
  272. package/dist/providers/reusables/index.mjs.map +1 -0
  273. package/dist/providers/tamagui/index.d.mts +15 -0
  274. package/dist/providers/tamagui/index.d.ts +15 -0
  275. package/dist/providers/tamagui/index.js +275 -0
  276. package/dist/providers/tamagui/index.js.map +1 -0
  277. package/dist/providers/tamagui/index.mjs +270 -0
  278. package/dist/providers/tamagui/index.mjs.map +1 -0
  279. package/dist/theme-BznFrVT1.d.mts +566 -0
  280. package/dist/theme-BznFrVT1.d.ts +566 -0
  281. package/dist/types-C7P80VKR.d.ts +22 -0
  282. package/dist/types-Tspvmask.d.mts +22 -0
  283. package/dist/ui/index.d.mts +190 -7017
  284. package/dist/ui/index.d.ts +190 -7017
  285. package/dist/ui/index.js +73 -992
  286. package/dist/ui/index.mjs +2 -1
  287. package/package.json +142 -38
  288. package/components/ui/date-time-picker/index.web.tsx +0 -195
  289. package/design/documentation.xml +0 -607
  290. package/design/tools/design.js +0 -188
  291. package/design/tools/requirements.txt +0 -35
  292. package/design/tools/sources/.checker/__init__.py +0 -81
  293. package/design/tools/sources/.checker/checks.py +0 -198
  294. package/design/tools/sources/.checker/cli.py +0 -154
  295. package/design/tools/sources/.checker/io.py +0 -242
  296. package/design/tools/sources/.checker/model.py +0 -144
  297. package/design/tools/sources/.checker/registry.py +0 -115
  298. package/design/tools/sources/.checker/report.py +0 -21
  299. package/design/tools/sources/.docgen/__init__.py +0 -45
  300. package/design/tools/sources/.docgen/cli.py +0 -101
  301. package/design/tools/sources/.docgen/model.py +0 -147
  302. package/design/tools/sources/.docgen/reference.py +0 -97
  303. package/design/tools/sources/.docgen/site.py +0 -145
  304. package/design/tools/sources/.docgen/xsddoc.py +0 -329
  305. package/design/tools/sources/.generate/__init__.py +0 -35
  306. package/design/tools/sources/.generate/cli.py +0 -76
  307. package/design/tools/sources/.generate/common.py +0 -33
  308. package/design/tools/sources/.generate/config.py +0 -177
  309. package/design/tools/sources/.generate/model.py +0 -51
  310. package/design/tools/sources/.generate/tokens.py +0 -141
  311. package/design/tools/sources/.linter/__init__.py +0 -9
  312. package/design/tools/sources/.linter/cli.py +0 -44
  313. package/design/tools/sources/.linter/discovery.py +0 -30
  314. package/design/tools/sources/.linter/errors.py +0 -45
  315. package/design/tools/sources/.linter/linter.py +0 -68
  316. package/design/tools/sources/.xmleditor/__init__.py +0 -74
  317. package/design/tools/sources/.xmleditor/blocks.py +0 -185
  318. package/design/tools/sources/.xmleditor/cli.py +0 -141
  319. package/design/tools/sources/.xmleditor/editor.py +0 -906
  320. package/design/tools/sources/.xmleditor/model.py +0 -708
  321. package/design/tools/sources/.xmleditor/widgets.py +0 -1832
  322. package/design/tools/sources/.xmleditor/xsdmodel.py +0 -753
  323. package/design/tools/sources/checker.py +0 -55
  324. package/design/tools/sources/docgen.py +0 -66
  325. package/design/tools/sources/generate.py +0 -48
  326. package/design/tools/sources/linter.py +0 -54
  327. package/design/tools/sources/ruff.toml +0 -12
  328. package/design/tools/sources/xmleditor.py +0 -62
  329. package/design/tools/unix/_venv_python.sh +0 -16
  330. package/design/tools/unix/check.sh +0 -13
  331. package/design/tools/unix/doc.sh +0 -14
  332. package/design/tools/unix/gen.sh +0 -14
  333. package/design/tools/unix/lint.sh +0 -10
  334. package/design/tools/unix/run.sh +0 -20
  335. package/design/tools/unix/verify.sh +0 -12
  336. package/design/tools/unix/xmledit.sh +0 -12
  337. package/design/tools/windows/check.cmd +0 -12
  338. package/design/tools/windows/doc.cmd +0 -12
  339. package/design/tools/windows/gen.cmd +0 -11
  340. package/design/tools/windows/lint.cmd +0 -9
  341. package/design/tools/windows/run.cmd +0 -26
  342. package/design/tools/windows/verify.cmd +0 -10
  343. package/design/tools/windows/xmledit.cmd +0 -10
  344. package/dist/chunk-2R66P5X5.mjs.map +0 -1
  345. package/dist/chunk-LCTFQJZM.js.map +0 -1
  346. /package/components/{ui → providers/gluestack/ui}/accordion/ANIMATION_CUSTOMIZATION.md +0 -0
  347. /package/components/{ui → providers/gluestack/ui}/accordion/AccordionAnimatedHeight.tsx +0 -0
  348. /package/components/{ui → providers/gluestack/ui}/accordion/AccordionAnimatedIcon.tsx +0 -0
  349. /package/components/{ui → providers/gluestack/ui}/accordion/AnimatedHeight.tsx +0 -0
  350. /package/components/{ui → providers/gluestack/ui}/accordion/AnimatedIcon.tsx +0 -0
  351. /package/components/{ui → providers/gluestack/ui}/accordion/MIGRATION_SUMMARY.md +0 -0
  352. /package/components/{ui → providers/gluestack/ui}/accordion/USAGE_EXAMPLE.tsx +0 -0
  353. /package/components/{ui → providers/gluestack/ui}/accordion/animation-config.ts +0 -0
  354. /package/components/{ui → providers/gluestack/ui}/avatar/index.tsx +0 -0
  355. /package/components/{ui → providers/gluestack/ui}/box/index.web.tsx +0 -0
  356. /package/components/{ui → providers/gluestack/ui}/box/styles.tsx +0 -0
  357. /package/components/{ui → providers/gluestack/ui}/calendar/creator.tsx +0 -0
  358. /package/components/{ui → providers/gluestack/ui}/calendar/styles.tsx +0 -0
  359. /package/components/{ui → providers/gluestack/ui}/card/index.web.tsx +0 -0
  360. /package/components/{ui → providers/gluestack/ui}/card/styles.tsx +0 -0
  361. /package/components/{ui → providers/gluestack/ui}/center/index.web.tsx +0 -0
  362. /package/components/{ui → providers/gluestack/ui}/center/styles.tsx +0 -0
  363. /package/components/{ui → providers/gluestack/ui}/date-time-picker/creator.tsx +0 -0
  364. /package/components/{ui → providers/gluestack/ui}/date-time-picker/styles.tsx +0 -0
  365. /package/components/{ui → providers/gluestack/ui}/flat-list/index.tsx +0 -0
  366. /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/index.tsx +0 -0
  367. /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/index.web.tsx +0 -0
  368. /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/script.ts +0 -0
  369. /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/theme-context.ts +0 -0
  370. /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/tokens.d.ts +0 -0
  371. /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/useGluestackColors.ts +0 -0
  372. /package/components/{ui → providers/gluestack/ui}/grid/index.web.tsx +0 -0
  373. /package/components/{ui → providers/gluestack/ui}/grid/styles.tsx +0 -0
  374. /package/components/{ui → providers/gluestack/ui}/heading/index.web.tsx +0 -0
  375. /package/components/{ui → providers/gluestack/ui}/heading/styles.tsx +0 -0
  376. /package/components/{ui → providers/gluestack/ui}/hstack/index.web.tsx +0 -0
  377. /package/components/{ui → providers/gluestack/ui}/hstack/styles.tsx +0 -0
  378. /package/components/{ui → providers/gluestack/ui}/icon/index.web.tsx +0 -0
  379. /package/components/{ui → providers/gluestack/ui}/image-background/index.tsx +0 -0
  380. /package/components/{ui → providers/gluestack/ui}/image-viewer/index.web.tsx +0 -0
  381. /package/components/{ui → providers/gluestack/ui}/input-accessory-view/index.tsx +0 -0
  382. /package/components/{ui → providers/gluestack/ui}/keyboard-avoiding-view/index.tsx +0 -0
  383. /package/components/{ui → providers/gluestack/ui}/pressable/index.tsx +0 -0
  384. /package/components/{ui → providers/gluestack/ui}/refresh-control/index.tsx +0 -0
  385. /package/components/{ui → providers/gluestack/ui}/safe-area-view/index.tsx +0 -0
  386. /package/components/{ui → providers/gluestack/ui}/scroll-view/index.tsx +0 -0
  387. /package/components/{ui → providers/gluestack/ui}/section-list/index.tsx +0 -0
  388. /package/components/{ui → providers/gluestack/ui}/skeleton/index.web.tsx +0 -0
  389. /package/components/{ui → providers/gluestack/ui}/skeleton/styles.tsx +0 -0
  390. /package/components/{ui → providers/gluestack/ui}/status-bar/index.tsx +0 -0
  391. /package/components/{ui → providers/gluestack/ui}/switch/index.tsx +0 -0
  392. /package/components/{ui → providers/gluestack/ui}/table/index.web.tsx +0 -0
  393. /package/components/{ui → providers/gluestack/ui}/table/styles.tsx +0 -0
  394. /package/components/{ui → providers/gluestack/ui}/tabs/animation-config.ts +0 -0
  395. /package/components/{ui → providers/gluestack/ui}/tabs/creator.tsx +0 -0
  396. /package/components/{ui → providers/gluestack/ui}/text/index.web.tsx +0 -0
  397. /package/components/{ui → providers/gluestack/ui}/text/styles.tsx +0 -0
  398. /package/components/{ui → providers/gluestack/ui}/textarea/index.tsx +0 -0
  399. /package/components/{ui → providers/gluestack/ui}/view/index.tsx +0 -0
  400. /package/components/{ui → providers/gluestack/ui}/virtualized-list/index.tsx +0 -0
  401. /package/components/{ui → providers/gluestack/ui}/vstack/index.web.tsx +0 -0
  402. /package/components/{ui → providers/gluestack/ui}/vstack/styles.tsx +0 -0
@@ -0,0 +1,614 @@
1
+ 'use strict';
2
+ /**
3
+ * `flipova-design gui` -- a local, dependency-free editor for the design registries.
4
+ *
5
+ * The server listens on 127.0.0.1 only, on a random port, and every request must carry the token printed at start
6
+ * (the page itself is served at /?t=<token>); the Host header must be the loopback address, so another page in the
7
+ * browser, or a DNS-rebinding trick, cannot drive it. It never takes a path from the browser: the only files it
8
+ * writes are the registry files and the generated artifacts, in the project it was started in.
9
+ *
10
+ * Edits go to a working copy in the OS temp folder. Nothing in the project changes until Save, and Save validates
11
+ * first (generation, determinism rules, XSD) and writes only if all of it passes.
12
+ */
13
+ const crypto = require('node:crypto');
14
+ const fs = require('node:fs');
15
+ const http = require('node:http');
16
+ const os = require('node:os');
17
+ const path = require('node:path');
18
+ const { spawnSync } = require('node:child_process');
19
+ const edit = require('./edit');
20
+ const { REQUIRED_ROLES } = require('./contract');
21
+ const { loadManifest, renderDesignTheme } = require('./generate');
22
+
23
+ const CLI = path.resolve(__dirname, '..', 'cli.js');
24
+ const PAGE = path.resolve(__dirname, '..', 'gui', 'index.html');
25
+ const PACKAGE_ROOT = path.resolve(__dirname, '..', '..', '..');
26
+
27
+ const SCALES = [
28
+ 'spacing',
29
+ 'radii',
30
+ 'fontSizes',
31
+ 'fontWeights',
32
+ 'lineHeights',
33
+ 'letterSpacings',
34
+ 'opacity',
35
+ 'duration',
36
+ 'zIndex',
37
+ 'breakpoints',
38
+ ];
39
+ const camel = (s) => s.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
40
+
41
+ // --- colour helpers ----------------------------------------------------------------------------------------------------
42
+
43
+ function parseHex(hex) {
44
+ let d = hex.replace('#', '');
45
+ if (d.length === 3) d = [...d].map((c) => c + c).join('');
46
+ const n = parseInt(d, 16);
47
+ return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
48
+ }
49
+ const toHex = (rgb) =>
50
+ '#' +
51
+ rgb
52
+ .map((v) =>
53
+ Math.round(Math.max(0, Math.min(255, v)))
54
+ .toString(16)
55
+ .padStart(2, '0'),
56
+ )
57
+ .join('');
58
+ const mix = (a, b, t) => a.map((v, i) => v + (b[i] - v) * t);
59
+
60
+ /** shade id -> how far the base colour (the 500) is mixed towards white (<0.5) or black (>0.5) */
61
+ const SHADE_MIX = {
62
+ 50: 0.95,
63
+ 100: 0.9,
64
+ 200: 0.75,
65
+ 300: 0.58,
66
+ 400: 0.3,
67
+ 500: 0,
68
+ 600: 0.15,
69
+ 700: 0.3,
70
+ 800: 0.45,
71
+ 900: 0.6,
72
+ 950: 0.75,
73
+ };
74
+
75
+ /** A palette from one base colour: the base is the 500, lighter shades towards white, darker towards black. */
76
+ function paletteFrom(base) {
77
+ if (!edit.HEX.test(base)) throw new Error(`"${base}" is not a colour (#RGB or #RRGGBB)`);
78
+ const b = parseHex(base);
79
+ return Object.fromEntries(
80
+ Object.entries(SHADE_MIX).map(([shade, t]) => [
81
+ shade,
82
+ toHex(Number(shade) < 500 ? mix(b, [255, 255, 255], t) : mix(b, [0, 0, 0], t)),
83
+ ]),
84
+ );
85
+ }
86
+
87
+ // --- the working copy --------------------------------------------------------------------------------------------------
88
+
89
+ class Workspace {
90
+ /** @param {{designDir: string, outputRoot: string}} where */
91
+ constructor({ designDir, outputRoot }) {
92
+ this.designDir = designDir;
93
+ this.outputRoot = outputRoot;
94
+ this.tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'flipova-gui-')));
95
+ this.work = path.join(this.tmp, 'design');
96
+ fs.mkdirSync(this.work);
97
+ for (const f of ['manifest.xml', 'schema.xsd', 'canonical.index.txt', 'tokens.xml', 'themes.xml'])
98
+ if (fs.existsSync(path.join(designDir, f))) fs.copyFileSync(path.join(designDir, f), path.join(this.work, f));
99
+ fs.writeFileSync(
100
+ path.join(this.tmp, 'package.json'),
101
+ fs.existsSync(path.join(outputRoot, 'package.json'))
102
+ ? fs.readFileSync(path.join(outputRoot, 'package.json'))
103
+ : '{"name":"app","version":"0.0.0"}',
104
+ );
105
+ this.saved = { tokens: this.read('tokens.xml'), themes: this.read('themes.xml') };
106
+ this.log = [];
107
+ }
108
+
109
+ read(f) {
110
+ return fs.readFileSync(path.join(this.work, f), 'utf8');
111
+ }
112
+
113
+ write(f, text) {
114
+ fs.writeFileSync(path.join(this.work, f), text, 'utf8');
115
+ }
116
+
117
+ get dirty() {
118
+ return this.read('tokens.xml') !== this.saved.tokens || this.read('themes.xml') !== this.saved.themes;
119
+ }
120
+
121
+ dispose() {
122
+ fs.rmSync(this.tmp, { recursive: true, force: true });
123
+ }
124
+
125
+ /** the registry as the components read it (design-theme.ts evaluated), or the error that prevents it */
126
+ registry() {
127
+ try {
128
+ const man = loadManifest(this.tmp, path.join(this.work, 'manifest.xml'));
129
+ const src = renderDesignTheme(man);
130
+ const body = src.slice(
131
+ src.indexOf('export const designTheme = ') + 'export const designTheme = '.length,
132
+ src.indexOf('} as const;') + 1,
133
+ );
134
+ return { registry: new Function(`return (${body})`)(), error: null };
135
+ } catch (e) {
136
+ return { registry: null, error: String(e.message || e) };
137
+ }
138
+ }
139
+
140
+ /** every colour / scale / theme of the working copy, for the page */
141
+ state() {
142
+ const { registry, error } = this.registry();
143
+ const tokens = this.read('tokens.xml');
144
+ const themesXml = this.read('themes.xml');
145
+ const values = (token) => {
146
+ try {
147
+ const b = tokenBlock(tokens, token);
148
+ return [...b.matchAll(/<value\s[^>]*\bid="([^"]+)"[^>]*>([^<]*)<\/value>/g)].map((m) => ({
149
+ id: m[1],
150
+ value: m[2].trim(),
151
+ }));
152
+ } catch {
153
+ return [];
154
+ }
155
+ };
156
+ const colors = values('color');
157
+ const themes = [...themesXml.matchAll(/<theme\s([^>]*)>([\s\S]*?)<\/theme>/g)].map((m) => {
158
+ const attr = (n) => new RegExp(`\\b${n}="([^"]*)"`).exec(m[1])?.[1] ?? '';
159
+ const id = attr('id');
160
+ const resolved = registry?.themes?.[id]?.colors ?? {};
161
+ const roles = [...m[2].matchAll(/<role\s[^>]*\bid="([^"]+)"[^>]*>([\s\S]*?)<\/role>/g)].map((r) => {
162
+ const ref = /<ref>([^<]*)<\/ref>/.exec(r[2])?.[1]?.trim();
163
+ const value = /<value>([^<]*)<\/value>/.exec(r[2])?.[1]?.trim();
164
+ return {
165
+ id: r[1],
166
+ ref: ref ?? null,
167
+ value: value ?? null,
168
+ color: resolved[camel(r[1])] ?? null,
169
+ required: REQUIRED_ROLES.includes(r[1]),
170
+ };
171
+ });
172
+ const have = new Set(roles.map((r) => r.id));
173
+ return {
174
+ id,
175
+ mode: attr('mode'),
176
+ variant: attr('variant') || 'default',
177
+ roles,
178
+ missing: REQUIRED_ROLES.filter((r) => !have.has(r)),
179
+ };
180
+ });
181
+ return {
182
+ dirty: this.dirty,
183
+ designDir: this.designDir,
184
+ error,
185
+ requiredRoles: REQUIRED_ROLES,
186
+ colors,
187
+ scales: Object.fromEntries(SCALES.map((s) => [s, values(s)])),
188
+ themes,
189
+ default: /<themes\b[^>]*\bdefault="([^"]*)"/.exec(themesXml)?.[1] ?? null,
190
+ registry,
191
+ log: this.log.slice(-40),
192
+ };
193
+ }
194
+
195
+ /** One edit. Returns nothing; throws an Error with a user-facing message when the edit is refused. */
196
+ apply(op) {
197
+ const need = (k) => {
198
+ if (op[k] === undefined || op[k] === null || op[k] === '') throw new Error(`missing "${k}"`);
199
+ return op[k];
200
+ };
201
+ const tokens = () => this.read('tokens.xml');
202
+ const themes = () => this.read('themes.xml');
203
+ switch (op.type) {
204
+ case 'setColor':
205
+ return this.write('tokens.xml', edit.setValue(tokens(), 'color', need('id'), need('value'), 'color'));
206
+ case 'addColor':
207
+ return this.write('tokens.xml', edit.addValue(tokens(), 'color', need('id'), need('value'), 'color'));
208
+ case 'removeColor': {
209
+ const ref = `$ref.tokens.color.${need('id')}`;
210
+ if (themes().includes(`<ref>${ref}</ref>`))
211
+ throw new Error(`${op.id} is used by a theme; point those roles elsewhere first`);
212
+ return this.write('tokens.xml', edit.removeValue(tokens(), 'color', op.id));
213
+ }
214
+ case 'palette': {
215
+ const name = need('name');
216
+ if (!/^[A-Za-z][A-Za-z0-9-]*$/.test(name)) throw new Error(`"${name}" is not a valid palette name`);
217
+ let xml = tokens();
218
+ const have = new Set([...xml.matchAll(/<value\s[^>]*\bid="([^"]+)"/g)].map((m) => m[1]));
219
+ for (const [shade, hex] of Object.entries(paletteFrom(need('base')))) {
220
+ const id = `${name}.${shade}`;
221
+ xml = have.has(id)
222
+ ? edit.setValue(xml, 'color', id, hex, 'color')
223
+ : edit.addValue(xml, 'color', id, hex, 'color');
224
+ }
225
+ return this.write('tokens.xml', xml);
226
+ }
227
+ case 'setScale':
228
+ if (!SCALES.includes(need('scale'))) throw new Error(`unknown scale "${op.scale}"`);
229
+ return this.write('tokens.xml', edit.setValue(tokens(), op.scale, need('id'), need('value'), 'scale'));
230
+ case 'addScale':
231
+ if (!SCALES.includes(need('scale'))) throw new Error(`unknown scale "${op.scale}"`);
232
+ return this.write('tokens.xml', edit.addValue(tokens(), op.scale, need('id'), need('value'), 'scale'));
233
+ case 'removeScale':
234
+ if (!SCALES.includes(need('scale'))) throw new Error(`unknown scale "${op.scale}"`);
235
+ return this.write('tokens.xml', edit.removeValue(tokens(), op.scale, need('id')));
236
+ case 'setRole':
237
+ return this.write(
238
+ 'themes.xml',
239
+ edit.setRole(themes(), need('theme'), need('role'), op.ref ? { ref: op.ref } : { value: op.value }),
240
+ );
241
+ case 'addTheme':
242
+ return this.write(
243
+ 'themes.xml',
244
+ edit.addTheme(themes(), { id: need('id'), mode: need('mode'), variant: need('variant'), from: need('from') }),
245
+ );
246
+ case 'removeTheme':
247
+ return this.write('themes.xml', edit.removeTheme(themes(), need('id')));
248
+ case 'setTheme':
249
+ return this.write(
250
+ 'themes.xml',
251
+ edit.setThemeAttrs(themes(), need('id'), { newId: op.newId, mode: op.mode, variant: op.variant }),
252
+ );
253
+ case 'revert':
254
+ this.write('tokens.xml', this.saved.tokens);
255
+ return this.write('themes.xml', this.saved.themes);
256
+ default:
257
+ throw new Error(`unknown operation "${op.type}"`);
258
+ }
259
+ }
260
+
261
+ /** CLI on the working copy: gen is skipped (outputs are the project's), the rules and the schema are checked. */
262
+ validate() {
263
+ const env = { ...process.env, FOUNDATION_DESIGN_DIR: this.work, FOUNDATION_PROJECT_ROOT: this.tmp };
264
+ const steps = [];
265
+ const run = (name, args) => {
266
+ const r = spawnSync(process.execPath, [CLI, ...args], { env, encoding: 'utf8' });
267
+ steps.push({ name, ok: r.status === 0, output: `${r.stdout || ''}${r.stderr || ''}`.trim() });
268
+ return r.status === 0;
269
+ };
270
+ const { error } = this.registry();
271
+ if (error) {
272
+ steps.push({ name: 'registry', ok: false, output: error });
273
+ return { ok: false, steps };
274
+ }
275
+ const state = this.state();
276
+ for (const t of state.themes)
277
+ if (t.missing.length)
278
+ steps.push({
279
+ name: `theme ${t.id}`,
280
+ ok: false,
281
+ output: `lacks the role(s) the components read: ${t.missing.join(', ')}`,
282
+ });
283
+ const roles = steps.length === 0;
284
+ // the canonical index follows the registries; it is part of what Save writes
285
+ const ok = run('canonical', ['canonical']) && run('check', ['check']) && run('lint', ['lint']);
286
+ return { ok: ok && roles, steps };
287
+ }
288
+
289
+ /** Validate, then write the registries + canonical index to the project and regenerate the artifacts. */
290
+ save() {
291
+ const v = this.validate();
292
+ if (!v.ok) return { ok: false, steps: v.steps };
293
+ for (const f of ['tokens.xml', 'themes.xml', 'canonical.index.txt'])
294
+ fs.copyFileSync(path.join(this.work, f), path.join(this.designDir, f));
295
+ const env = { ...process.env };
296
+ const gen = spawnSync(process.execPath, [CLI, 'gen'], { cwd: this.outputRoot, env, encoding: 'utf8' });
297
+ const steps = [
298
+ ...v.steps,
299
+ { name: 'gen', ok: gen.status === 0, output: `${gen.stdout || ''}${gen.stderr || ''}`.trim() },
300
+ ];
301
+ if (gen.status === 0) this.saved = { tokens: this.read('tokens.xml'), themes: this.read('themes.xml') };
302
+ return { ok: gen.status === 0, steps };
303
+ }
304
+ }
305
+
306
+ function tokenBlock(xml, id) {
307
+ const open = new RegExp(`<token\\s[^>]*\\bid="${id}"[^>]*>`).exec(xml);
308
+ if (!open) throw new Error(`token ${id} not found`);
309
+ return xml.slice(open.index, xml.indexOf('</token>', open.index));
310
+ }
311
+
312
+ // --- the preview -------------------------------------------------------------------------------------------------------
313
+
314
+ /** The contract the components are built from, as published (dist) -- the preview shows the real recipes. */
315
+ function loadContract() {
316
+ const file = path.join(PACKAGE_ROOT, 'dist', 'contract', 'index.js');
317
+ if (!fs.existsSync(file)) return null;
318
+ return require(file);
319
+ }
320
+
321
+ const view = (style, children = []) => ({ k: 'view', style, children });
322
+ const text = (style, value) => ({ k: 'text', style, text: value });
323
+
324
+ /** Specimens of every component for one theme, as plain view/text trees the page draws. */
325
+ function specimens(contract, registry, themeId) {
326
+ const c = contract;
327
+ const t = c.resolveTheme(themeId, registry);
328
+ const R = c;
329
+ const groups = [];
330
+ const add = (title, items) => groups.push({ title, items });
331
+
332
+ add(
333
+ 'Button',
334
+ ['default', 'secondary', 'outline', 'destructive', 'ghost', 'link']
335
+ .map((variant) => {
336
+ const r = R.buttonRecipe({ variant }, t);
337
+ return { label: variant, node: view(r.container, [text(r.label, 'Button')]) };
338
+ })
339
+ .concat(
340
+ (() => {
341
+ const r = R.buttonRecipe({ disabled: true }, t);
342
+ return [{ label: 'disabled', node: view(r.container, [text(r.label, 'Button')]) }];
343
+ })(),
344
+ ),
345
+ );
346
+ add('Heading & Text', [
347
+ ...[1, 2, 3, 5].map((level) => ({
348
+ label: `heading ${level}`,
349
+ node: text(R.headingRecipe({ level }, t), 'The quick brown fox'),
350
+ })),
351
+ { label: 'text md', node: text(R.textRecipe({ size: 'md' }, t), 'Body text uses the foreground colour.') },
352
+ { label: 'text bold', node: text(R.textRecipe({ size: 'sm', bold: true }, t), 'Small and bold') },
353
+ ]);
354
+ const input = R.inputRecipe({}, t);
355
+ const area = R.textareaRecipe({}, t);
356
+ const select = R.selectRecipe({ options: [] }, t);
357
+ add('Fields', [
358
+ {
359
+ label: 'input',
360
+ node: view(input.container, [text({ ...input.field, color: input.placeholderTextColor }, 'Placeholder')]),
361
+ },
362
+ {
363
+ label: 'invalid',
364
+ node: view(R.inputRecipe({ invalid: true }, t).container, [
365
+ text({ ...input.field, color: input.placeholderTextColor }, 'Placeholder'),
366
+ ]),
367
+ },
368
+ {
369
+ label: 'textarea',
370
+ node: view({ ...area.field, justifyContent: 'flex-start' }, [
371
+ text({ color: area.placeholderTextColor, fontSize: area.field.fontSize }, 'Write something…'),
372
+ ]),
373
+ },
374
+ {
375
+ label: 'select (open)',
376
+ node: view({ width: '100%' }, [
377
+ view(select.trigger, [text(select.triggerLabel, 'Alpha'), text({ color: select.placeholderColor }, '▾')]),
378
+ view(select.menu, [
379
+ view({ ...select.option, ...select.optionSelected }, [
380
+ text({ ...select.optionLabel, ...select.optionLabelSelected }, 'Alpha'),
381
+ ]),
382
+ view(select.option, [text(select.optionLabel, 'Beta')]),
383
+ ]),
384
+ ]),
385
+ },
386
+ ]);
387
+ const cb = (checked) => R.checkboxRecipe({ checked }, t);
388
+ const rd = R.radioRecipe({ options: [] }, t);
389
+ const sw = R.switchRecipe({}, t);
390
+ const knob = sw.height - 4;
391
+ add('Choices', [
392
+ ...[true, false].map((checked) => ({
393
+ label: checked ? 'checked' : 'unchecked',
394
+ node: view(cb(checked).row, [
395
+ view(cb(checked).box, checked ? [text(cb(checked).mark, '✓')] : []),
396
+ text(cb(checked).label, 'Label'),
397
+ ]),
398
+ })),
399
+ {
400
+ label: 'radio',
401
+ node: view(
402
+ rd.group,
403
+ [true, false].map((sel) =>
404
+ view(rd.row, [view(rd.circle(sel), sel ? [view(rd.dot)] : []), text(rd.label, sel ? 'Selected' : 'Other')]),
405
+ ),
406
+ ),
407
+ },
408
+ ...[true, false].map((on) => ({
409
+ label: on ? 'switch on' : 'switch off',
410
+ node: view(
411
+ {
412
+ width: sw.width,
413
+ height: sw.height,
414
+ borderRadius: 9999,
415
+ backgroundColor: on ? sw.trackOn : sw.trackOff,
416
+ justifyContent: 'center',
417
+ paddingHorizontal: 2,
418
+ alignItems: on ? 'flex-end' : 'flex-start',
419
+ },
420
+ [view({ width: knob, height: knob, borderRadius: 9999, backgroundColor: sw.thumb })],
421
+ ),
422
+ })),
423
+ ]);
424
+ const card = R.cardRecipe({}, t);
425
+ add('Card & Badge', [
426
+ {
427
+ label: 'card',
428
+ node: view(card, [
429
+ text(R.headingRecipe({ level: 4 }, t), 'Card title'),
430
+ text(R.textRecipe({ size: 'sm' }, t), 'Cards sit on the card colour with a border and a soft shadow.'),
431
+ ]),
432
+ },
433
+ ...['default', 'secondary', 'destructive', 'outline'].map((variant) => {
434
+ const r = R.badgeRecipe({ variant }, t);
435
+ return { label: `badge ${variant}`, node: view(r.container, [text(r.label, 'New')]) };
436
+ }),
437
+ ]);
438
+ add('Avatar & Divider', [
439
+ ...['sm', 'md', 'lg', 'xl'].map((size) => {
440
+ const r = R.avatarRecipe({ size }, t);
441
+ return { label: size, node: view(r.container, [text(r.initials, 'AL')]) };
442
+ }),
443
+ { label: 'divider', node: view(R.dividerRecipe({}, t)) },
444
+ ]);
445
+ const tabs = R.tabsRecipe({ tabs: [] }, t);
446
+ add('Tabs', [
447
+ {
448
+ label: 'tabs',
449
+ node: view({ width: '100%' }, [
450
+ view(tabs.list, [
451
+ view(tabs.tab(true, false), [text(tabs.label(true), 'Overview')]),
452
+ view(tabs.tab(false, false), [text(tabs.label(false), 'Settings')]),
453
+ ]),
454
+ view(tabs.panel, [text(R.textRecipe({ size: 'sm' }, t), 'Panel content')]),
455
+ ]),
456
+ },
457
+ ]);
458
+ add('Feedback', [
459
+ ...['info', 'success', 'warning', 'error'].map((variant) => {
460
+ const r = R.alertRecipe({ variant }, t);
461
+ return {
462
+ label: `alert ${variant}`,
463
+ node: view(r.container, [
464
+ text(r.title, variant[0].toUpperCase() + variant.slice(1)),
465
+ text(r.body, 'Something worth knowing.'),
466
+ ]),
467
+ };
468
+ }),
469
+ (() => {
470
+ const r = R.toastRecipe({ variant: 'success' }, t);
471
+ return {
472
+ label: 'toast',
473
+ node: view(r.container, [view({ flex: 1 }, [text(r.title, 'Saved'), text(r.body, 'All changes are stored.')])]),
474
+ };
475
+ })(),
476
+ ]);
477
+ const pr = R.progressRecipe({ value: 60 }, t);
478
+ const sk = R.skeletonRecipe({ width: 160 }, t);
479
+ const sp = R.spinnerRecipe({ size: 'md' }, t);
480
+ add('Progress & Loading', [
481
+ { label: 'progress 60%', node: view(pr.track, [view(pr.bar)]) },
482
+ { label: 'skeleton', node: view(sk.block) },
483
+ {
484
+ label: 'spinner',
485
+ node: view({
486
+ width: 24,
487
+ height: 24,
488
+ borderRadius: 9999,
489
+ borderWidth: 3,
490
+ borderColor: sp.color,
491
+ borderTopColor: 'transparent',
492
+ }),
493
+ },
494
+ ]);
495
+ const md = R.modalRecipe({ visible: true }, t);
496
+ add('Modal', [
497
+ {
498
+ label: 'panel',
499
+ node: view(md.panel, [
500
+ text(md.title, 'Delete this item?'),
501
+ text(R.textRecipe({ size: 'sm' }, t), 'This cannot be undone.'),
502
+ ]),
503
+ },
504
+ ]);
505
+ return { background: t.colors.background, foreground: t.colors.foreground, groups };
506
+ }
507
+
508
+ // --- the server --------------------------------------------------------------------------------------------------------
509
+
510
+ const MAX_BODY = 1024 * 1024;
511
+
512
+ function start({ designDir, outputRoot, port = 0, out = (s) => process.stdout.write(s + '\n') }) {
513
+ const token = crypto.randomBytes(24).toString('hex');
514
+ const ws = new Workspace({ designDir, outputRoot });
515
+ const contract = loadContract();
516
+ const page = fs.readFileSync(PAGE, 'utf8');
517
+ const stateOf = () => ({ ...ws.state(), previewAvailable: !!contract });
518
+
519
+ const json = (res, code, body) => {
520
+ const s = JSON.stringify(body);
521
+ res.writeHead(code, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
522
+ res.end(s);
523
+ };
524
+
525
+ const server = http.createServer((req, res) => {
526
+ const addr = server.address();
527
+ const host = String(req.headers.host || '');
528
+ if (host !== `127.0.0.1:${addr.port}` && host !== `localhost:${addr.port}`)
529
+ return json(res, 403, { error: 'forbidden host' });
530
+ const url = new URL(req.url, `http://${host}`);
531
+ if (req.method === 'GET' && url.pathname === '/') {
532
+ if (url.searchParams.get('t') !== token) return json(res, 403, { error: 'missing or wrong token' });
533
+ res.writeHead(200, {
534
+ 'content-type': 'text/html; charset=utf-8',
535
+ 'cache-control': 'no-store',
536
+ 'content-security-policy':
537
+ "default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'none'",
538
+ 'x-content-type-options': 'nosniff',
539
+ 'referrer-policy': 'no-referrer',
540
+ });
541
+ return res.end(page.replace('__TOKEN__', token));
542
+ }
543
+ if (req.headers['x-flipova-token'] !== token) return json(res, 403, { error: 'missing or wrong token' });
544
+ const body = () =>
545
+ new Promise((resolve, reject) => {
546
+ let size = 0;
547
+ const parts = [];
548
+ req.on('data', (c) => {
549
+ size += c.length;
550
+ if (size > MAX_BODY) {
551
+ reject(new Error('request too large'));
552
+ req.destroy();
553
+ } else parts.push(c);
554
+ });
555
+ req.on('end', () => {
556
+ try {
557
+ resolve(parts.length ? JSON.parse(Buffer.concat(parts).toString('utf8')) : {});
558
+ } catch {
559
+ reject(new Error('invalid JSON'));
560
+ }
561
+ });
562
+ });
563
+ (async () => {
564
+ if (req.method === 'GET' && url.pathname === '/api/state') return json(res, 200, stateOf());
565
+ if (req.method === 'GET' && url.pathname === '/api/preview') {
566
+ if (!contract)
567
+ return json(res, 200, {
568
+ available: false,
569
+ reason:
570
+ 'The preview uses the published components (dist/). Run `npm run build` in the package, or install the published package.',
571
+ });
572
+ const { registry, error } = ws.registry();
573
+ if (error) return json(res, 200, { available: false, reason: error });
574
+ const id = url.searchParams.get('theme');
575
+ if (!registry.themes[id]) return json(res, 404, { error: `unknown theme "${id}"` });
576
+ return json(res, 200, { available: true, ...specimens(contract, registry, id) });
577
+ }
578
+ if (req.method === 'POST' && url.pathname === '/api/edit') {
579
+ if (!String(req.headers['content-type'] || '').startsWith('application/json'))
580
+ return json(res, 415, { error: 'JSON only' });
581
+ const op = await body();
582
+ try {
583
+ ws.apply(op);
584
+ } catch (e) {
585
+ return json(res, 400, { error: String(e.message || e) });
586
+ }
587
+ return json(res, 200, stateOf());
588
+ }
589
+ if (req.method === 'POST' && url.pathname === '/api/validate') return json(res, 200, ws.validate());
590
+ if (req.method === 'POST' && url.pathname === '/api/save') return json(res, 200, ws.save());
591
+ return json(res, 404, { error: 'not found' });
592
+ })().catch((e) => json(res, 400, { error: String(e.message || e) }));
593
+ });
594
+
595
+ return new Promise((resolve, reject) => {
596
+ server.once('error', reject);
597
+ server.listen(port, '127.0.0.1', () => {
598
+ const p = server.address().port;
599
+ const link = `http://127.0.0.1:${p}/?t=${token}`;
600
+ out(`flipova-design gui ${link}`);
601
+ out(`editing ${designDir} (changes stay in a working copy until you press Save)`);
602
+ resolve({
603
+ url: link,
604
+ port: p,
605
+ token,
606
+ server,
607
+ workspace: ws,
608
+ close: () => new Promise((r) => server.close(() => (ws.dispose(), r()))),
609
+ });
610
+ });
611
+ });
612
+ }
613
+
614
+ module.exports = { start, Workspace, paletteFrom, specimens, SCALES };