@effijs/templates 0.0.0-stage → 1.0.0-alpha.0

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 (367) hide show
  1. package/CONTRIBUTING.md +27 -0
  2. package/LICENSE +22 -0
  3. package/README.md +32 -2
  4. package/ai/SETUP.md +5 -0
  5. package/docs/catalog.md +85 -0
  6. package/forge.manifest.js +75 -0
  7. package/lib/compat.js +40 -0
  8. package/lib/docs/build.js +146 -0
  9. package/lib/install.js +51 -0
  10. package/lib/journal.js +40 -0
  11. package/lib/jsonConfig.js +33 -0
  12. package/lib/migration.js +35 -0
  13. package/lib/names.js +42 -0
  14. package/lib/patch.js +62 -0
  15. package/lib/paths.js +12 -0
  16. package/lib/project.js +48 -0
  17. package/lib/registry.js +99 -0
  18. package/package.json +46 -4
  19. package/platforms/react-native/CATALOG.md +391 -0
  20. package/platforms/react-native/ORIGIN.md +42 -0
  21. package/platforms/react-native/README.md +78 -0
  22. package/platforms/react-native/ai/AGENTS.md.hbs +36 -0
  23. package/platforms/react-native/ai/SETUP.md +89 -0
  24. package/platforms/react-native/compat/matrix.js +150 -0
  25. package/platforms/react-native/configs/babel.js +63 -0
  26. package/platforms/react-native/configs/forgeConfig.js +35 -0
  27. package/platforms/react-native/configs/jsConfigs.js +96 -0
  28. package/platforms/react-native/configs/metro.js +86 -0
  29. package/platforms/react-native/generators/add/generator.js +12 -0
  30. package/platforms/react-native/generators/add/run.js +64 -0
  31. package/platforms/react-native/generators/component/generator.js +75 -0
  32. package/platforms/react-native/generators/component/render.js +69 -0
  33. package/platforms/react-native/generators/component/templates/Common.tsx.hbs +13 -0
  34. package/platforms/react-native/generators/component/templates/index.ts.hbs +13 -0
  35. package/platforms/react-native/generators/component/templates/pm.ts.hbs +7 -0
  36. package/platforms/react-native/generators/component/templates/types.ts.hbs +3 -0
  37. package/platforms/react-native/generators/demo/files/api/app.http +8 -0
  38. package/platforms/react-native/generators/demo/files/api/environment/http-client.env.json +5 -0
  39. package/platforms/react-native/generators/demo/files/entity/category/category.api.ts +18 -0
  40. package/platforms/react-native/generators/demo/files/entity/category/category.dto.ts +15 -0
  41. package/platforms/react-native/generators/demo/files/entity/category/category.service.ts +42 -0
  42. package/platforms/react-native/generators/demo/files/entity/category/category.store.ts +26 -0
  43. package/platforms/react-native/generators/demo/files/entity/category/index.ts +2 -0
  44. package/platforms/react-native/generators/demo/files/entity/product/index.ts +2 -0
  45. package/platforms/react-native/generators/demo/files/entity/product/product.api.ts +49 -0
  46. package/platforms/react-native/generators/demo/files/entity/product/product.dto.ts +120 -0
  47. package/platforms/react-native/generators/demo/files/entity/product/product.service.ts +139 -0
  48. package/platforms/react-native/generators/demo/files/entity/product/product.store.ts +37 -0
  49. package/platforms/react-native/generators/demo/files/feature/product/components/Product.CategorySelect.tsx +36 -0
  50. package/platforms/react-native/generators/demo/files/feature/product/detail/Product.Detail.Screen.tsx +100 -0
  51. package/platforms/react-native/generators/demo/files/feature/product/detail/product.detail.service.ts +33 -0
  52. package/platforms/react-native/generators/demo/files/feature/product/filter/Product.Filter.Screen.tsx +59 -0
  53. package/platforms/react-native/generators/demo/files/feature/product/filter/product.filter.service.ts +78 -0
  54. package/platforms/react-native/generators/demo/files/feature/product/form/Product.Form.Screen.tsx +71 -0
  55. package/platforms/react-native/generators/demo/files/feature/product/form/product.form.service.ts +142 -0
  56. package/platforms/react-native/generators/demo/files/feature/product/index.ts +7 -0
  57. package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Item.tsx +34 -0
  58. package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Screen.tsx +106 -0
  59. package/platforms/react-native/generators/demo/files/feature/product/list/product.list.service.ts +47 -0
  60. package/platforms/react-native/generators/demo/files/feature/product/product.feature.ts +29 -0
  61. package/platforms/react-native/generators/demo/files/feature/product/product.hooks.ts +7 -0
  62. package/platforms/react-native/generators/demo/files/feature/product/search/Product.Search.Screen.tsx +82 -0
  63. package/platforms/react-native/generators/demo/files/feature/product/search/product.search.service.ts +97 -0
  64. package/platforms/react-native/generators/demo/files/navigation/navigation.product.ts +46 -0
  65. package/platforms/react-native/generators/demo/generator.js +93 -0
  66. package/platforms/react-native/generators/entity/generator.js +68 -0
  67. package/platforms/react-native/generators/feature/generator.js +224 -0
  68. package/platforms/react-native/generators/feature/render.js +163 -0
  69. package/platforms/react-native/generators/feature/templates/detail.screen.tsx.hbs +25 -0
  70. package/platforms/react-native/generators/feature/templates/detail.service.ts.hbs +14 -0
  71. package/platforms/react-native/generators/feature/templates/feature.ts.hbs +18 -0
  72. package/platforms/react-native/generators/feature/templates/filter.screen.tsx.hbs +17 -0
  73. package/platforms/react-native/generators/feature/templates/filter.service.ts.hbs +14 -0
  74. package/platforms/react-native/generators/feature/templates/form.screen.tsx.hbs +21 -0
  75. package/platforms/react-native/generators/feature/templates/form.service.ts.hbs +37 -0
  76. package/platforms/react-native/generators/feature/templates/hooks.ts.hbs +7 -0
  77. package/platforms/react-native/generators/feature/templates/index.ts.hbs +2 -0
  78. package/platforms/react-native/generators/feature/templates/list.item.tsx.hbs +16 -0
  79. package/platforms/react-native/generators/feature/templates/list.screen.tsx.hbs +34 -0
  80. package/platforms/react-native/generators/feature/templates/list.service.ts.hbs +15 -0
  81. package/platforms/react-native/generators/feature/templates/navigation.ts.hbs +12 -0
  82. package/platforms/react-native/generators/feature/templates/search.screen.tsx.hbs +24 -0
  83. package/platforms/react-native/generators/feature/templates/search.service.ts.hbs +13 -0
  84. package/platforms/react-native/generators/feature/templates/tab.tsx.hbs +8 -0
  85. package/platforms/react-native/generators/init/files/app/app.controller.ts +41 -0
  86. package/platforms/react-native/generators/init/files/app/app.error.ts +1 -0
  87. package/platforms/react-native/generators/init/files/app/app.store.ts +12 -0
  88. package/platforms/react-native/generators/init/files/app/index.ts +19 -0
  89. package/platforms/react-native/generators/init/files/app/splash/Onboarding.Screen.tsx +31 -0
  90. package/platforms/react-native/generators/init/files/app/splash/Splash.Screen.tsx +14 -0
  91. package/platforms/react-native/generators/init/files/app/tabs/home/Home.tab.tsx +24 -0
  92. package/platforms/react-native/generators/init/files/app/tabs/profile/Profile.tab.tsx +1 -0
  93. package/platforms/react-native/generators/init/files/configs/dev.ts.hbs +5 -0
  94. package/platforms/react-native/generators/init/files/configs/index.ts +4 -0
  95. package/platforms/react-native/generators/init/files/configs/prod.ts.hbs +5 -0
  96. package/platforms/react-native/generators/init/files/entity/auth/auth.api.ts +36 -0
  97. package/platforms/react-native/generators/init/files/entity/auth/auth.dto.ts +26 -0
  98. package/platforms/react-native/generators/init/files/entity/auth/auth.service.ts +94 -0
  99. package/platforms/react-native/generators/init/files/entity/auth/auth.session.store.ts +14 -0
  100. package/platforms/react-native/generators/init/files/entity/auth/auth.store.ts +20 -0
  101. package/platforms/react-native/generators/init/files/entity/auth/index.ts +2 -0
  102. package/platforms/react-native/generators/init/files/entity/index.ts +2 -0
  103. package/platforms/react-native/generators/init/files/feature/auth/auth.feature.ts +10 -0
  104. package/platforms/react-native/generators/init/files/feature/auth/auth.hooks.ts +7 -0
  105. package/platforms/react-native/generators/init/files/feature/auth/index.ts +1 -0
  106. package/platforms/react-native/generators/init/files/feature/auth/sign-in/SignIn.Screen.tsx +39 -0
  107. package/platforms/react-native/generators/init/files/feature/auth/sign-in/signIn.service.ts +54 -0
  108. package/platforms/react-native/generators/init/files/feature/auth/sign-up/SignUp.Screen.tsx +64 -0
  109. package/platforms/react-native/generators/init/files/feature/auth/sign-up/signUp.service.ts +73 -0
  110. package/platforms/react-native/generators/init/files/feature/feature.hooks.ts +15 -0
  111. package/platforms/react-native/generators/init/files/feature/index.ts +3 -0
  112. package/platforms/react-native/generators/init/files/feature/profile/Profile.Screen.tsx +52 -0
  113. package/platforms/react-native/generators/init/files/feature/profile/index.ts +1 -0
  114. package/platforms/react-native/generators/init/files/feature/profile/profile.feature.ts +18 -0
  115. package/platforms/react-native/generators/init/files/feature/profile/profile.hooks.ts +7 -0
  116. package/platforms/react-native/generators/init/files/index.ts +16 -0
  117. package/platforms/react-native/generators/init/files/navigation/index.ts +18 -0
  118. package/platforms/react-native/generators/init/files/navigation/navigation.app.ts +58 -0
  119. package/platforms/react-native/generators/init/files/navigation/navigation.features.ts +9 -0
  120. package/platforms/react-native/generators/init/files/navigation/navigation.hooks.ts +5 -0
  121. package/platforms/react-native/generators/init/files/navigation/navigation.tabs.ts +55 -0
  122. package/platforms/react-native/generators/init/files/navigation/navigation.widgets.ts +23 -0
  123. package/platforms/react-native/generators/init/files/services/http/http.base.ts +69 -0
  124. package/platforms/react-native/generators/init/files/services/http/http.error.ts +10 -0
  125. package/platforms/react-native/generators/init/files/services/http/http.service.ts +24 -0
  126. package/platforms/react-native/generators/init/files/services/http/middleware/index.ts +12 -0
  127. package/platforms/react-native/generators/init/files/services/http/middleware/middleware.error.ts +36 -0
  128. package/platforms/react-native/generators/init/files/services/http/middleware/middleware.registry.ts +3 -0
  129. package/platforms/react-native/generators/init/files/services/http/middleware/middleware.token.ts +97 -0
  130. package/platforms/react-native/generators/init/files/services/index.ts +15 -0
  131. package/platforms/react-native/generators/init/files/ui/components/Box/Common.tsx +19 -0
  132. package/platforms/react-native/generators/init/files/ui/components/Box/box.pm.ts +111 -0
  133. package/platforms/react-native/generators/init/files/ui/components/Box/box.types.ts +8 -0
  134. package/platforms/react-native/generators/init/files/ui/components/Box/index.ts +13 -0
  135. package/platforms/react-native/generators/init/files/ui/components/Button/Common.tsx +50 -0
  136. package/platforms/react-native/generators/init/files/ui/components/Button/Touchable.tsx +19 -0
  137. package/platforms/react-native/generators/init/files/ui/components/Button/button.pm.ts +197 -0
  138. package/platforms/react-native/generators/init/files/ui/components/Button/button.types.ts +22 -0
  139. package/platforms/react-native/generators/init/files/ui/components/Button/button.utils.ts +16 -0
  140. package/platforms/react-native/generators/init/files/ui/components/Button/index.ts +19 -0
  141. package/platforms/react-native/generators/init/files/ui/components/Form/Colours.tsx +50 -0
  142. package/platforms/react-native/generators/init/files/ui/components/Form/Common.tsx +38 -0
  143. package/platforms/react-native/generators/init/files/ui/components/Form/ErrorText.tsx +11 -0
  144. package/platforms/react-native/generators/init/files/ui/components/Form/Input.tsx +115 -0
  145. package/platforms/react-native/generators/init/files/ui/components/Form/InputArea.tsx +70 -0
  146. package/platforms/react-native/generators/init/files/ui/components/Form/Label.tsx +18 -0
  147. package/platforms/react-native/generators/init/files/ui/components/Form/Select.tsx +86 -0
  148. package/platforms/react-native/generators/init/files/ui/components/Form/components/SecureTextEntry.tsx +19 -0
  149. package/platforms/react-native/generators/init/files/ui/components/Form/form.error.ts +18 -0
  150. package/platforms/react-native/generators/init/files/ui/components/Form/form.pm.ts +134 -0
  151. package/platforms/react-native/generators/init/files/ui/components/Form/form.types.ts +59 -0
  152. package/platforms/react-native/generators/init/files/ui/components/Form/index.ts +67 -0
  153. package/platforms/react-native/generators/init/files/ui/components/Grid/Common.tsx +11 -0
  154. package/platforms/react-native/generators/init/files/ui/components/Grid/grid.pm.ts +93 -0
  155. package/platforms/react-native/generators/init/files/ui/components/Grid/grid.types.ts +79 -0
  156. package/platforms/react-native/generators/init/files/ui/components/Grid/index.ts +13 -0
  157. package/platforms/react-native/generators/init/files/ui/components/Icon/Common.tsx +19 -0
  158. package/platforms/react-native/generators/init/files/ui/components/Icon/icons.pm.ts +74 -0
  159. package/platforms/react-native/generators/init/files/ui/components/Icon/icons.types.ts +19 -0
  160. package/platforms/react-native/generators/init/files/ui/components/Icon/index.ts +3 -0
  161. package/platforms/react-native/generators/init/files/ui/components/Loading/Loading.tsx +10 -0
  162. package/platforms/react-native/generators/init/files/ui/components/Loading/loading.hook.ts +5 -0
  163. package/platforms/react-native/generators/init/files/ui/components/Loading/loading.service.ts +22 -0
  164. package/platforms/react-native/generators/init/files/ui/components/Loading/loading.store.ts +8 -0
  165. package/platforms/react-native/generators/init/files/ui/components/Screen/Common.tsx +87 -0
  166. package/platforms/react-native/generators/init/files/ui/components/Screen/Content.tsx +77 -0
  167. package/platforms/react-native/generators/init/files/ui/components/Screen/Header.tsx +80 -0
  168. package/platforms/react-native/generators/init/files/ui/components/Screen/HeaderTab.tsx +17 -0
  169. package/platforms/react-native/generators/init/files/ui/components/Screen/SafeAreaHOC.tsx +9 -0
  170. package/platforms/react-native/generators/init/files/ui/components/Screen/index.ts +22 -0
  171. package/platforms/react-native/generators/init/files/ui/components/Text/Common.tsx +20 -0
  172. package/platforms/react-native/generators/init/files/ui/components/Text/index.ts +13 -0
  173. package/platforms/react-native/generators/init/files/ui/components/Text/text.pm.ts +55 -0
  174. package/platforms/react-native/generators/init/files/ui/components/Text/text.types.ts +27 -0
  175. package/platforms/react-native/generators/init/files/ui/components/TextInput/Common.tsx +19 -0
  176. package/platforms/react-native/generators/init/files/ui/components/TextInput/index.ts +15 -0
  177. package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.pm.ts +65 -0
  178. package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.types.ts +16 -0
  179. package/platforms/react-native/generators/init/files/ui/components/ThemePicker/ThemePicker.tsx +92 -0
  180. package/platforms/react-native/generators/init/files/ui/components/ThemePicker/index.ts +1 -0
  181. package/platforms/react-native/generators/init/files/ui/components/index.ts +27 -0
  182. package/platforms/react-native/generators/init/files/ui/components/utils/color.ts +19 -0
  183. package/platforms/react-native/generators/init/files/ui/components/utils/index.ts +3 -0
  184. package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.spec.tsx +202 -0
  185. package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.ts +172 -0
  186. package/platforms/react-native/generators/init/files/ui/components/utils/useStore.ts +34 -0
  187. package/platforms/react-native/generators/init/files/ui/fonts/font-icons.ttf +0 -0
  188. package/platforms/react-native/generators/init/files/ui/icons/font-icons.json +53 -0
  189. package/platforms/react-native/generators/init/files/ui/icons/logo.png +0 -0
  190. package/platforms/react-native/generators/init/files/ui/icons/logo.svg +304 -0
  191. package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-1.png +0 -0
  192. package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-2.png +0 -0
  193. package/platforms/react-native/generators/init/files/ui/theme/black/black.color.ts +8 -0
  194. package/platforms/react-native/generators/init/files/ui/theme/black/index.ts +10 -0
  195. package/platforms/react-native/generators/init/files/ui/theme/blue/blue.color.ts +8 -0
  196. package/platforms/react-native/generators/init/files/ui/theme/blue/index.ts +10 -0
  197. package/platforms/react-native/generators/init/files/ui/theme/green/green.color.ts +8 -0
  198. package/platforms/react-native/generators/init/files/ui/theme/green/index.ts +10 -0
  199. package/platforms/react-native/generators/init/files/ui/theme/index.ts +11 -0
  200. package/platforms/react-native/generators/init/files/ui/theme/pink/index.ts +10 -0
  201. package/platforms/react-native/generators/init/files/ui/theme/pink/pink.color.ts +8 -0
  202. package/platforms/react-native/generators/init/files/ui/theme/scheme/index.ts +23 -0
  203. package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.color.ts +139 -0
  204. package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.radius.ts +21 -0
  205. package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.spacing.ts +24 -0
  206. package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.ts +25 -0
  207. package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.typography.ts +98 -0
  208. package/platforms/react-native/generators/init/files/ui/theme/shared/index.ts +4 -0
  209. package/platforms/react-native/generators/init/files/ui/theme/shared/shared.color.base.ts +79 -0
  210. package/platforms/react-native/generators/init/files/ui/theme/shared/shared.radius.ts +8 -0
  211. package/platforms/react-native/generators/init/files/ui/theme/shared/shared.spacing.ts +9 -0
  212. package/platforms/react-native/generators/init/files/ui/theme/shared/shared.typography.ts +105 -0
  213. package/platforms/react-native/generators/init/files/ui/theme/theme.hooks.ts +7 -0
  214. package/platforms/react-native/generators/init/files/ui/theme/theme.meta.ts +10 -0
  215. package/platforms/react-native/generators/init/files/ui/theme/theme.provider.tsx +19 -0
  216. package/platforms/react-native/generators/init/files/ui/theme/theme.service.ts +36 -0
  217. package/platforms/react-native/generators/init/files/ui/theme/theme.ts +27 -0
  218. package/platforms/react-native/generators/init/files/ui/widgets/index.ts +1 -0
  219. package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Item.tsx +175 -0
  220. package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Overlay.tsx +46 -0
  221. package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Stack.tsx +75 -0
  222. package/platforms/react-native/generators/init/files/ui/widgets/toast/index.ts +7 -0
  223. package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.hooks.ts +18 -0
  224. package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.service.ts +39 -0
  225. package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.store.ts +59 -0
  226. package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.types.ts +18 -0
  227. package/platforms/react-native/generators/init/files/ui/widgets/widgets.feature.ts +14 -0
  228. package/platforms/react-native/generators/init/files/utils/date.ts +11 -0
  229. package/platforms/react-native/generators/init/files/utils/index.ts +12 -0
  230. package/platforms/react-native/generators/init/files/utils/store.persistent.ts +103 -0
  231. package/platforms/react-native/generators/init/files/utils/store.registry.ts +14 -0
  232. package/platforms/react-native/generators/init/files/utils/string.ts +100 -0
  233. package/platforms/react-native/generators/init/generator.js +86 -0
  234. package/platforms/react-native/generators/init/kit.js +23 -0
  235. package/platforms/react-native/generators/init/navigators/expo-router/index.ts +18 -0
  236. package/platforms/react-native/generators/init/navigators/expo-router/navigation.app.ts +8 -0
  237. package/platforms/react-native/generators/init/navigators/expo-router/navigation.features.ts +9 -0
  238. package/platforms/react-native/generators/init/navigators/expo-router/navigation.hooks.ts +5 -0
  239. package/platforms/react-native/generators/init/navigators/expo-router/navigation.tabs.ts +7 -0
  240. package/platforms/react-native/generators/init/navigators/expo-router/navigation.widgets.ts +5 -0
  241. package/platforms/react-native/generators/init/navigators/react-navigation/index.ts +18 -0
  242. package/platforms/react-native/generators/init/navigators/react-navigation/navigation.app.ts +8 -0
  243. package/platforms/react-native/generators/init/navigators/react-navigation/navigation.features.ts +9 -0
  244. package/platforms/react-native/generators/init/navigators/react-navigation/navigation.hooks.ts +5 -0
  245. package/platforms/react-native/generators/init/navigators/react-navigation/navigation.tabs.ts +7 -0
  246. package/platforms/react-native/generators/init/navigators/react-navigation/navigation.widgets.ts +5 -0
  247. package/platforms/react-native/generators/setup/generator.js +225 -0
  248. package/platforms/react-native/generators/util/generator.js +12 -0
  249. package/platforms/react-native/platform.js +32 -0
  250. package/platforms/react-native/runtime.js +57 -0
  251. package/platforms/react-native/solutions/components/BottomSheet/README.md +29 -0
  252. package/platforms/react-native/solutions/components/BottomSheet/files/Common.tsx +120 -0
  253. package/platforms/react-native/solutions/components/BottomSheet/files/Content.tsx +57 -0
  254. package/platforms/react-native/solutions/components/BottomSheet/files/Context.tsx +22 -0
  255. package/platforms/react-native/solutions/components/BottomSheet/files/FlatList.tsx +50 -0
  256. package/platforms/react-native/solutions/components/BottomSheet/files/Header.tsx +57 -0
  257. package/platforms/react-native/solutions/components/BottomSheet/files/Search.tsx +24 -0
  258. package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.constants.ts +13 -0
  259. package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.types.ts +31 -0
  260. package/platforms/react-native/solutions/components/BottomSheet/files/index.ts +33 -0
  261. package/platforms/react-native/solutions/components/BottomSheet/solution.js +38 -0
  262. package/platforms/react-native/solutions/components/BottomSheetWidgets/README.md +29 -0
  263. package/platforms/react-native/solutions/components/BottomSheetWidgets/files/SelectPicker.tsx +47 -0
  264. package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/Content.BottomSheet.tsx +22 -0
  265. package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/DateTimePicker.BottomSheet.tsx +74 -0
  266. package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/List.BottomSheet.tsx +62 -0
  267. package/platforms/react-native/solutions/components/BottomSheetWidgets/solution.js +49 -0
  268. package/platforms/react-native/solutions/components/Calendar/README.md +29 -0
  269. package/platforms/react-native/solutions/components/Calendar/files/Common.tsx +16 -0
  270. package/platforms/react-native/solutions/components/Calendar/files/Context.tsx +466 -0
  271. package/platforms/react-native/solutions/components/Calendar/files/DayCell.tsx +89 -0
  272. package/platforms/react-native/solutions/components/Calendar/files/MonthView.tsx +41 -0
  273. package/platforms/react-native/solutions/components/Calendar/files/MonthYearOverlay.tsx +51 -0
  274. package/platforms/react-native/solutions/components/Calendar/files/SwipeablePeriod.tsx +44 -0
  275. package/platforms/react-native/solutions/components/Calendar/files/WeekDayTitles.tsx +31 -0
  276. package/platforms/react-native/solutions/components/Calendar/files/WeekView.tsx +40 -0
  277. package/platforms/react-native/solutions/components/Calendar/files/calendar.styles.ts +142 -0
  278. package/platforms/react-native/solutions/components/Calendar/files/calendar.types.ts +126 -0
  279. package/platforms/react-native/solutions/components/Calendar/files/calendar.utils.ts +143 -0
  280. package/platforms/react-native/solutions/components/Calendar/files/index.ts +40 -0
  281. package/platforms/react-native/solutions/components/Calendar/solution.js +38 -0
  282. package/platforms/react-native/solutions/components/Chart/README.md +29 -0
  283. package/platforms/react-native/solutions/components/Chart/files/Cilcular.tsx +140 -0
  284. package/platforms/react-native/solutions/components/Chart/files/index.ts +3 -0
  285. package/platforms/react-native/solutions/components/Chart/solution.js +38 -0
  286. package/platforms/react-native/solutions/components/CheckBox/README.md +29 -0
  287. package/platforms/react-native/solutions/components/CheckBox/files/Common.tsx +55 -0
  288. package/platforms/react-native/solutions/components/CheckBox/files/checkbox.pm.ts +71 -0
  289. package/platforms/react-native/solutions/components/CheckBox/files/index.ts +9 -0
  290. package/platforms/react-native/solutions/components/CheckBox/form/Checkbox.tsx +22 -0
  291. package/platforms/react-native/solutions/components/CheckBox/solution.js +57 -0
  292. package/platforms/react-native/solutions/components/DateTimePicker/README.md +29 -0
  293. package/platforms/react-native/solutions/components/DateTimePicker/files/DateTimePicker.tsx +44 -0
  294. package/platforms/react-native/solutions/components/DateTimePicker/solution.js +45 -0
  295. package/platforms/react-native/solutions/components/Image/README.md +29 -0
  296. package/platforms/react-native/solutions/components/Image/files/SVG.tsx +74 -0
  297. package/platforms/react-native/solutions/components/Image/files/image.pm.ts +25 -0
  298. package/platforms/react-native/solutions/components/Image/files/image.utils.ts +35 -0
  299. package/platforms/react-native/solutions/components/Image/files/index.ts +5 -0
  300. package/platforms/react-native/solutions/components/Image/solution.js +40 -0
  301. package/platforms/react-native/solutions/components/InputSecurity/README.md +29 -0
  302. package/platforms/react-native/solutions/components/InputSecurity/files/InputSecurity.ts +142 -0
  303. package/platforms/react-native/solutions/components/InputSecurity/solution.js +28 -0
  304. package/platforms/react-native/solutions/components/OTP/README.md +29 -0
  305. package/platforms/react-native/solutions/components/OTP/files/Item.tsx +16 -0
  306. package/platforms/react-native/solutions/components/OTP/files/Items.tsx +33 -0
  307. package/platforms/react-native/solutions/components/OTP/files/index.tsx +120 -0
  308. package/platforms/react-native/solutions/components/OTP/files/otp.pm.ts +30 -0
  309. package/platforms/react-native/solutions/components/OTP/solution.js +38 -0
  310. package/platforms/react-native/solutions/components/ProgressIndicator/README.md +29 -0
  311. package/platforms/react-native/solutions/components/ProgressIndicator/files/Circular.tsx +154 -0
  312. package/platforms/react-native/solutions/components/ProgressIndicator/files/Linear.tsx +133 -0
  313. package/platforms/react-native/solutions/components/ProgressIndicator/files/circular.pm.ts +34 -0
  314. package/platforms/react-native/solutions/components/ProgressIndicator/files/index.ts +16 -0
  315. package/platforms/react-native/solutions/components/ProgressIndicator/solution.js +39 -0
  316. package/platforms/react-native/solutions/components/Ruler/README.md +29 -0
  317. package/platforms/react-native/solutions/components/Ruler/files/Common.tsx +44 -0
  318. package/platforms/react-native/solutions/components/Ruler/files/Context.tsx +210 -0
  319. package/platforms/react-native/solutions/components/Ruler/files/Track.tsx +686 -0
  320. package/platforms/react-native/solutions/components/Ruler/files/Value.tsx +60 -0
  321. package/platforms/react-native/solutions/components/Ruler/files/index.ts +23 -0
  322. package/platforms/react-native/solutions/components/Ruler/files/ruler.constants.ts +70 -0
  323. package/platforms/react-native/solutions/components/Ruler/files/ruler.types.ts +98 -0
  324. package/platforms/react-native/solutions/components/Ruler/files/ruler.utils.ts +332 -0
  325. package/platforms/react-native/solutions/components/Ruler/solution.js +38 -0
  326. package/platforms/react-native/solutions/components/Section/README.md +29 -0
  327. package/platforms/react-native/solutions/components/Section/files/Common.tsx +144 -0
  328. package/platforms/react-native/solutions/components/Section/solution.js +37 -0
  329. package/platforms/react-native/solutions/components/Slider/README.md +29 -0
  330. package/platforms/react-native/solutions/components/Slider/files/Container.tsx +5 -0
  331. package/platforms/react-native/solutions/components/Slider/files/Content.tsx +44 -0
  332. package/platforms/react-native/solutions/components/Slider/files/Context.tsx +30 -0
  333. package/platforms/react-native/solutions/components/Slider/files/Pagination.Dot.tsx +61 -0
  334. package/platforms/react-native/solutions/components/Slider/files/index.ts +22 -0
  335. package/platforms/react-native/solutions/components/Slider/solution.js +38 -0
  336. package/platforms/react-native/solutions/components/Switch/README.md +29 -0
  337. package/platforms/react-native/solutions/components/Switch/files/Common.tsx +38 -0
  338. package/platforms/react-native/solutions/components/Switch/files/index.ts +9 -0
  339. package/platforms/react-native/solutions/components/Switch/files/switch.pm.ts +53 -0
  340. package/platforms/react-native/solutions/components/Switch/solution.js +38 -0
  341. package/platforms/react-native/solutions/install.js +97 -0
  342. package/platforms/react-native/solutions/services/firebase-core/README.md +31 -0
  343. package/platforms/react-native/solutions/services/firebase-core/files/index.ts +5 -0
  344. package/platforms/react-native/solutions/services/firebase-core/solution.js +39 -0
  345. package/platforms/react-native/solutions/services/firebase-messaging/README.md +31 -0
  346. package/platforms/react-native/solutions/services/firebase-messaging/files/index.ts +20 -0
  347. package/platforms/react-native/solutions/services/firebase-messaging/solution.js +42 -0
  348. package/platforms/react-native/solutions/utils/permissions/README.md +29 -0
  349. package/platforms/react-native/solutions/utils/permissions/files/permissions.ts +10 -0
  350. package/platforms/react-native/solutions/utils/permissions/solution.js +32 -0
  351. package/presets/react-native-fsd/index.js +25 -0
  352. package/shared/generators/entity/render.js +88 -0
  353. package/shared/generators/entity/templates/crud/api.ts.hbs +36 -0
  354. package/shared/generators/entity/templates/crud/dto.ts.hbs +36 -0
  355. package/shared/generators/entity/templates/crud/service.ts.hbs +73 -0
  356. package/shared/generators/entity/templates/crud/store.ts.hbs +27 -0
  357. package/shared/generators/entity/templates/index.ts.hbs +2 -0
  358. package/shared/generators/entity/templates/simple/api.ts.hbs +16 -0
  359. package/shared/generators/entity/templates/simple/dto.ts.hbs +5 -0
  360. package/shared/generators/entity/templates/simple/service.ts.hbs +26 -0
  361. package/shared/generators/entity/templates/simple/store.ts.hbs +18 -0
  362. package/shared/solutions/utils/date/README.md +29 -0
  363. package/shared/solutions/utils/date/files/date.ts +11 -0
  364. package/shared/solutions/utils/date/solution.js +27 -0
  365. package/shared/solutions/utils/string/README.md +29 -0
  366. package/shared/solutions/utils/string/files/string.ts +100 -0
  367. package/shared/solutions/utils/string/solution.js +27 -0
@@ -0,0 +1,16 @@
1
+ type TextSizes = 's' | 'm' | 'l';
2
+
3
+ type SpacingProps<Prefix extends string> = {
4
+ [Size in TextSizes as `${Prefix}-${Size}`]?: boolean;
5
+ };
6
+
7
+ export interface TTextProps<TThemeColor>
8
+ extends SpacingProps<'title'>,
9
+ SpacingProps<'label'>,
10
+ SpacingProps<'body'>,
11
+ SpacingProps<'display'>,
12
+ SpacingProps<'headline'> {
13
+ color?: TThemeColor | string;
14
+ disabled?: boolean;
15
+ flex?: number;
16
+ }
@@ -0,0 +1,92 @@
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import { Pressable, StyleSheet, View } from 'react-native';
3
+ import { useSharedValue, withTiming } from 'react-native-reanimated';
4
+
5
+ import { SchemaName, themeMeta, themeOrder, useThemeService } from '@theme';
6
+
7
+ const SWATCH_SIZE = 40;
8
+ const SWATCH_GAP = 16;
9
+ const INDICATOR_HEIGHT = 40;
10
+ const INDICATOR_WIDTH = 70;
11
+ const STEP = SWATCH_SIZE + SWATCH_GAP;
12
+
13
+ type ThemePickerProps = {
14
+ value?: SchemaName;
15
+ onChange?: (name: SchemaName) => void;
16
+ previewOnSelect?: boolean;
17
+ };
18
+
19
+ export default function ThemePicker({ value, onChange, previewOnSelect = true }: ThemePickerProps) {
20
+ const themeService = useThemeService();
21
+ const [selected, setSelected] = useState<SchemaName>(value ?? SchemaName.Blue);
22
+ const indicatorOffset = useSharedValue(themeOrder.indexOf(selected) * STEP);
23
+
24
+ useEffect(() => {
25
+ if (value) {
26
+ setSelected(value);
27
+ indicatorOffset.value = withTiming(themeOrder.indexOf(value) * STEP, { duration: 300 });
28
+ }
29
+ }, [indicatorOffset, value]);
30
+
31
+ const handleSelect = useCallback(
32
+ (name: SchemaName, index: number) => {
33
+ setSelected(name);
34
+ indicatorOffset.value = withTiming(index * STEP, { duration: 300 });
35
+ onChange?.(name);
36
+
37
+ if (previewOnSelect) {
38
+ themeService.setActive(name);
39
+ }
40
+ },
41
+ [indicatorOffset, onChange, previewOnSelect, themeService],
42
+ );
43
+
44
+ return (
45
+ <View style={styles.container}>
46
+ {themeOrder.map((name, index) => {
47
+ const isActive = selected === name;
48
+ return (
49
+ <Pressable
50
+ key={name}
51
+ onPress={() => handleSelect(name, index)}
52
+ style={[styles.swatch, { backgroundColor: themeMeta[name].previewColor }, isActive && styles.swatchActive]}
53
+ />
54
+ );
55
+ })}
56
+ </View>
57
+ );
58
+ }
59
+
60
+ const styles = StyleSheet.create({
61
+ container: {
62
+ flexDirection: 'row',
63
+ gap: SWATCH_GAP,
64
+ alignItems: 'center',
65
+ },
66
+ indicator: {
67
+ position: 'absolute',
68
+ top: 16,
69
+ width: INDICATOR_WIDTH,
70
+ height: INDICATOR_HEIGHT,
71
+ borderRadius: 30,
72
+ borderWidth: 1,
73
+ borderColor: '#d9cdb9',
74
+ },
75
+ swatch: {
76
+ width: SWATCH_SIZE,
77
+ height: SWATCH_SIZE,
78
+ borderWidth: 0,
79
+ borderRadius: SWATCH_SIZE / 2,
80
+ shadowColor: '#757575',
81
+ shadowOffset: { width: 0, height: 2 },
82
+ shadowOpacity: 0.32,
83
+ shadowRadius: 10,
84
+ elevation: 4,
85
+ },
86
+ swatchActive: {
87
+ width: INDICATOR_WIDTH,
88
+ borderRadius: 30,
89
+ borderWidth: 4,
90
+ borderColor: '#fffdf8',
91
+ },
92
+ });
@@ -0,0 +1 @@
1
+ export { default } from '@components/ThemePicker/ThemePicker.tsx';
@@ -0,0 +1,27 @@
1
+ import Box from './Box';
2
+ import Button from './Button';
3
+ import Form from './Form';
4
+ import Grid from './Grid';
5
+ import Icon from './Icon';
6
+ import Loading from './Loading';
7
+ import Screen from './Screen';
8
+ import Text from './Text';
9
+ import TextInput from './TextInput';
10
+ import ThemePicker from './ThemePicker';
11
+ import { useStore } from './utils/useStore';
12
+ // forge:components-import
13
+
14
+ export {
15
+ Grid,
16
+ Box,
17
+ Text,
18
+ TextInput,
19
+ Button,
20
+ Icon,
21
+ Screen,
22
+ Form,
23
+ Loading,
24
+ ThemePicker,
25
+ useStore,
26
+ // forge:components-export
27
+ };
@@ -0,0 +1,19 @@
1
+ function opacityToHex(opacity: number | undefined) {
2
+ if (opacity === undefined) return '';
3
+
4
+ let value = opacity;
5
+ if (opacity < 0) value = 0;
6
+ if (opacity > 1) value = 1;
7
+
8
+ return Math.round(value * 255)
9
+ .toString(16)
10
+ .padStart(2, '0');
11
+ }
12
+
13
+ export function colorOpacity(color: string, opacity: number | undefined) {
14
+ if (opacity !== undefined && color.startsWith('#')) {
15
+ return `${color}${opacityToHex(opacity)}`;
16
+ }
17
+
18
+ return color;
19
+ }
@@ -0,0 +1,3 @@
1
+ import * as color from './color';
2
+
3
+ export default { color };
@@ -0,0 +1,202 @@
1
+ import TestRenderer, { act } from 'react-test-renderer';
2
+
3
+ import { useLoading } from './useLoading.hook';
4
+
5
+ /**
6
+ * Мінімальний renderHook на react-test-renderer — у проєкті немає
7
+ * @testing-library/react(-native), тож рендеримо хук через "порожній"
8
+ * компонент і читаємо результат з мутабельного об'єкта.
9
+ */
10
+ function renderHook<TResult>(callback: () => TResult) {
11
+ const result = { current: undefined as unknown as TResult };
12
+
13
+ function TestComponent() {
14
+ result.current = callback();
15
+ return null;
16
+ }
17
+
18
+ let renderer!: ReturnType<typeof TestRenderer.create>;
19
+ act(() => {
20
+ renderer = TestRenderer.create(<TestComponent />);
21
+ });
22
+
23
+ return {
24
+ result,
25
+ unmount: () => act(() => renderer.unmount()),
26
+ };
27
+ }
28
+
29
+ // @react-native/jest-preset зазвичай виставляє це сам; дублюємо явно,
30
+ // щоб тести не залежали від конкретного preset-налаштування середовища.
31
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
32
+
33
+ beforeEach(() => {
34
+ jest.useFakeTimers();
35
+ });
36
+
37
+ afterEach(() => {
38
+ jest.useRealTimers();
39
+ });
40
+
41
+ describe('useLoading', () => {
42
+ describe('useLoading — debounce', () => {
43
+ test('виконує лише останній виклик, попередні резолвляться undefined', async () => {
44
+ const fn = jest.fn().mockResolvedValue('done');
45
+ const { result } = renderHook(() => useLoading(fn, { debounce: 100 }));
46
+
47
+ let p1!: Promise<unknown>;
48
+ let p2!: Promise<unknown>;
49
+ let p3!: Promise<unknown>;
50
+
51
+ act(() => {
52
+ p1 = result.current.handle('a');
53
+ p2 = result.current.handle('b');
54
+ p3 = result.current.handle('c');
55
+ });
56
+
57
+ await act(async () => {
58
+ await jest.advanceTimersByTimeAsync(100);
59
+ });
60
+
61
+ expect(fn).toHaveBeenCalledTimes(1);
62
+ expect(fn).toHaveBeenCalledWith('c', expect.any(AbortSignal));
63
+ await expect(p1).resolves.toBeUndefined();
64
+ await expect(p2).resolves.toBeUndefined();
65
+ await expect(p3).resolves.toBe('done');
66
+ });
67
+ });
68
+
69
+ describe('useLoading — lock', () => {
70
+ test('ігнорує повторний виклик, поки попередній ще виконується', async () => {
71
+ let resolveFirst!: (value: unknown) => void;
72
+ const fn = jest.fn(
73
+ () =>
74
+ new Promise(resolve => {
75
+ resolveFirst = resolve;
76
+ }),
77
+ );
78
+ const { result } = renderHook(() => useLoading(fn));
79
+
80
+ let p1!: Promise<unknown>;
81
+ let p2!: Promise<unknown>;
82
+ act(() => {
83
+ p1 = result.current.handle();
84
+ p2 = result.current.handle();
85
+ });
86
+
87
+ expect(fn).toHaveBeenCalledTimes(1);
88
+ await expect(p2).resolves.toBeUndefined();
89
+
90
+ await act(async () => {
91
+ resolveFirst('ok');
92
+ await p1;
93
+ });
94
+ });
95
+ });
96
+
97
+ describe('useLoading — throttle', () => {
98
+ test('пропускає виклики в межах вікна throttle', async () => {
99
+ const fn = jest.fn().mockResolvedValue('ok');
100
+ const { result } = renderHook(() => useLoading(fn, { throttle: 200, lock: false }));
101
+
102
+ await act(async () => {
103
+ await result.current.handle();
104
+ });
105
+ expect(fn).toHaveBeenCalledTimes(1);
106
+
107
+ await act(async () => {
108
+ await result.current.handle();
109
+ });
110
+ expect(fn).toHaveBeenCalledTimes(1); // ще в межах вікна
111
+
112
+ await act(async () => {
113
+ await jest.advanceTimersByTimeAsync(200);
114
+ await result.current.handle();
115
+ });
116
+ expect(fn).toHaveBeenCalledTimes(2);
117
+ });
118
+ });
119
+
120
+ describe('useLoading — minDuration', () => {
121
+ test('тримає loading=true щонайменше minDuration, навіть якщо fn швидка', async () => {
122
+ const fn = jest.fn().mockResolvedValue('ok');
123
+ const { result } = renderHook(() => useLoading(fn, { minDuration: 300 }));
124
+
125
+ let promise!: Promise<unknown>;
126
+ act(() => {
127
+ promise = result.current.handle();
128
+ });
129
+ expect(result.current.loading).toBe(true);
130
+
131
+ await act(async () => {
132
+ await jest.advanceTimersByTimeAsync(0);
133
+ });
134
+ expect(result.current.loading).toBe(true);
135
+
136
+ await act(async () => {
137
+ await jest.advanceTimersByTimeAsync(299);
138
+ });
139
+ expect(result.current.loading).toBe(true);
140
+
141
+ await act(async () => {
142
+ await jest.advanceTimersByTimeAsync(1);
143
+ });
144
+ expect(result.current.loading).toBe(false);
145
+ await expect(promise).resolves.toBe('ok');
146
+ });
147
+ });
148
+
149
+ describe('useLoading — unmount', () => {
150
+ test('скасовує відкладений (debounce) виклик при unmount', async () => {
151
+ const fn = jest.fn().mockResolvedValue('ok');
152
+ const { result, unmount } = renderHook(() => useLoading(fn, { debounce: 100 }));
153
+
154
+ let promise!: Promise<unknown>;
155
+ act(() => {
156
+ promise = result.current.handle();
157
+ });
158
+
159
+ unmount();
160
+
161
+ await expect(promise).resolves.toBeUndefined();
162
+ expect(fn).not.toHaveBeenCalled();
163
+ });
164
+
165
+ test('абортить активний виклик через AbortSignal при unmount', async () => {
166
+ const fn = jest.fn(
167
+ (signal: AbortSignal) =>
168
+ new Promise((_resolve, reject) => {
169
+ signal.addEventListener('abort', () => reject(new DOMException('Aborted', 'AbortError')));
170
+ }),
171
+ );
172
+ const { result, unmount } = renderHook(() => useLoading(fn));
173
+
174
+ let promise!: Promise<unknown>;
175
+ act(() => {
176
+ promise = result.current.handle();
177
+ });
178
+
179
+ unmount();
180
+
181
+ await expect(promise).rejects.toThrow('Aborted');
182
+ });
183
+
184
+ test('очищує активний таймер minDuration при unmount, а не залишає його висіти', async () => {
185
+ const fn = jest.fn().mockResolvedValue('ok');
186
+ const { result, unmount } = renderHook(() => useLoading(fn, { minDuration: 1000 }));
187
+
188
+ act(() => {
189
+ result.current.handle();
190
+ });
191
+
192
+ await act(async () => {
193
+ await jest.advanceTimersByTimeAsync(0);
194
+ });
195
+ expect(jest.getTimerCount()).toBeGreaterThan(0);
196
+
197
+ unmount();
198
+
199
+ expect(jest.getTimerCount()).toBe(0);
200
+ });
201
+ });
202
+ });
@@ -0,0 +1,172 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+
3
+ export type UseLoadingOptions = {
4
+ debounce?: number;
5
+ throttle?: number;
6
+ minDuration?: number;
7
+ lock?: boolean;
8
+ /**
9
+ * Зовнішній сигнал скасування. Коли він абортиться — абортиться і
10
+ * внутрішній AbortController поточного виклику fn (якщо він у польоті),
11
+ * а вже розпочаті/заплановані виклики, що ще не стартували, просто
12
+ * ігноруються (як throttle/lock).
13
+ */
14
+ signal?: AbortSignal;
15
+ };
16
+
17
+ function isThenable(value: unknown): value is PromiseLike<unknown> {
18
+ return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function';
19
+ }
20
+
21
+ type PendingDebounce = {
22
+ timer: ReturnType<typeof setTimeout>;
23
+ resolve: (value: unknown) => void;
24
+ };
25
+
26
+ type LatestInputs<TArgs extends unknown[]> = {
27
+ fn?: (...args: [...TArgs, AbortSignal?]) => unknown;
28
+ options: UseLoadingOptions;
29
+ };
30
+
31
+ function createLoadingController<TArgs extends unknown[]>(
32
+ latest: { current: LatestInputs<TArgs> },
33
+ notify: (loading: boolean) => void,
34
+ ) {
35
+ let inFlight = 0;
36
+ let lastCall = 0;
37
+ let mounted = true;
38
+ let pending: PendingDebounce | undefined;
39
+
40
+ // Активні таймери minDuration — щоб можна було форсовано "розбудити" їх при unmount,
41
+ // а не просто чекати призначений час у нікуди.
42
+ const minDurationCancels = new Set<() => void>();
43
+ // Активні AbortController-и запущених fn — щоб при unmount дати їм шанс перерватись.
44
+ const activeControllers = new Set<AbortController>();
45
+
46
+ const cancelPending = () => {
47
+ if (!pending) return;
48
+ clearTimeout(pending.timer);
49
+ pending.resolve(undefined);
50
+ pending = undefined;
51
+ };
52
+
53
+ function waitMinDuration(ms: number): Promise<void> {
54
+ return new Promise<void>(resolve => {
55
+ const finish = () => {
56
+ minDurationCancels.delete(finish);
57
+ clearTimeout(timer);
58
+ resolve();
59
+ };
60
+ const timer = setTimeout(finish, ms);
61
+ minDurationCancels.add(finish);
62
+ });
63
+ }
64
+
65
+ async function run(...args: TArgs) {
66
+ const { throttle = 0, minDuration = 0, lock = true, signal: externalSignal } = latest.current.options;
67
+
68
+ if (externalSignal?.aborted) return;
69
+ if (lock && inFlight > 0) return;
70
+
71
+ if (throttle > 0) {
72
+ const now = Date.now();
73
+ if (now - lastCall < throttle) return;
74
+ lastCall = now;
75
+ }
76
+
77
+ const controller = new AbortController();
78
+ const forwardAbort = () => controller.abort();
79
+ externalSignal?.addEventListener('abort', forwardAbort);
80
+ activeControllers.add(controller);
81
+
82
+ const detach = () => {
83
+ activeControllers.delete(controller);
84
+ externalSignal?.removeEventListener('abort', forwardAbort);
85
+ };
86
+
87
+ const result = latest.current.fn?.(...args, controller.signal);
88
+ if (!isThenable(result)) {
89
+ detach();
90
+ return result;
91
+ }
92
+
93
+ inFlight += 1;
94
+ const started = Date.now();
95
+ if (mounted) notify(true);
96
+
97
+ try {
98
+ return await result;
99
+ } finally {
100
+ inFlight -= 1;
101
+ detach();
102
+
103
+ // Якщо вже unmounted — не чекаємо штучно minDuration, нікому це вже не покаже UI.
104
+ const wait = minDuration - (Date.now() - started);
105
+ if (wait > 0 && mounted) await waitMinDuration(wait);
106
+
107
+ if (mounted && inFlight === 0) notify(false);
108
+ }
109
+ }
110
+
111
+ function handle(...args: TArgs): Promise<unknown> {
112
+ const { debounce = 0 } = latest.current.options;
113
+ if (debounce <= 0) return run(...args);
114
+
115
+ return new Promise<unknown>((resolve, reject) => {
116
+ cancelPending();
117
+ const timer = setTimeout(() => {
118
+ pending = undefined;
119
+ run(...args).then(resolve, reject);
120
+ }, debounce);
121
+ pending = { timer, resolve };
122
+ });
123
+ }
124
+
125
+ return {
126
+ handle,
127
+ onMount() {
128
+ mounted = true;
129
+ },
130
+ onUnmount() {
131
+ mounted = false;
132
+ cancelPending();
133
+ for (const finish of [...minDurationCancels]) finish();
134
+ for (const controller of [...activeControllers]) controller.abort();
135
+ },
136
+ };
137
+ }
138
+
139
+ /**
140
+ * Хук для керування `loading`-станом довкола (можливо асинхронної) функції.
141
+ *
142
+ * Debounce: якщо виклик `handle()` скасовано новим викликом (спрацював
143
+ * дебаунс) або unmount-ом компонента — повернутий Promise резолвиться
144
+ * значенням `undefined`, а НЕ відхиляється. Це свідоме скасування, а не
145
+ * помилка виконання: перевіряйте результат на `undefined`, а не покладайтесь
146
+ * на try/catch, щоб відрізнити "скасовано" від "виконано".
147
+ *
148
+ * `fn` опціонально може прийняти останнім аргументом `AbortSignal` — він
149
+ * абортиться автоматично при unmount, а також коли абортиться переданий
150
+ * ззовні `options.signal`.
151
+ */
152
+ export function useLoading<TArgs extends any[]>(
153
+ fn?: (...args: [...TArgs, AbortSignal?]) => unknown,
154
+ options: UseLoadingOptions = {},
155
+ ): { loading: boolean; handle: (...args: TArgs) => Promise<unknown> } {
156
+ const [loading, setLoading] = useState(false);
157
+
158
+ const latestRef = useRef<LatestInputs<TArgs>>({ fn, options });
159
+ latestRef.current = { fn, options };
160
+
161
+ const controllerRef = useRef<ReturnType<typeof createLoadingController<TArgs>> | undefined>(undefined);
162
+ if (!controllerRef.current) {
163
+ controllerRef.current = createLoadingController<TArgs>(latestRef, setLoading);
164
+ }
165
+
166
+ useEffect(() => {
167
+ controllerRef.current!.onMount();
168
+ return () => controllerRef.current!.onUnmount();
169
+ }, []);
170
+
171
+ return { loading, handle: controllerRef.current.handle };
172
+ }
@@ -0,0 +1,34 @@
1
+ import { Store } from '@effijs/common';
2
+ import { useEffect, useMemo, useState } from 'react';
3
+
4
+ export function useStore<TSchema extends Store.TData, P extends Store.TPathOf<TSchema>>(
5
+ store: Store.Common<TSchema>,
6
+ key: P,
7
+ ): Store.PathValue<TSchema, P>;
8
+ export function useStore<TSchema extends Store.TData, P extends Store.TPathOf<TSchema>, T>(
9
+ store: Store.Common<TSchema>,
10
+ key: P,
11
+ handle: (data: Store.PathValue<TSchema, P>) => T,
12
+ ): T;
13
+ export function useStore<TSchema extends Store.TData, P extends Store.TPathOf<TSchema>, T>(
14
+ store: Store.Common<TSchema>,
15
+ key: P,
16
+ handle?: (data: Store.PathValue<TSchema, P>) => T,
17
+ ): Store.PathValue<TSchema, P> | T {
18
+ const [data, setData] = useState(handle ? handle(store.getByPath(key)) : store.getByPath(key));
19
+
20
+ const hash = useMemo(() => JSON.stringify(key), [key]);
21
+
22
+ useEffect(() => {
23
+ const removeDataSubscription = store.subscribe({ value: key }, subscriptionData =>
24
+ setData(handle ? handle(subscriptionData.value) : subscriptionData.value),
25
+ );
26
+ return () => {
27
+ removeDataSubscription();
28
+ // setData({});
29
+ };
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ }, [hash]);
32
+
33
+ return data;
34
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "water": 61697,
3
+ "user": 61698,
4
+ "upload": 61699,
5
+ "star": 61700,
6
+ "sleep": 61701,
7
+ "settings": 61702,
8
+ "setting": 61703,
9
+ "search": 61704,
10
+ "running": 61705,
11
+ "rerecord": 61706,
12
+ "repeat": 61707,
13
+ "reload": 61708,
14
+ "preset-day": 61709,
15
+ "plus": 61710,
16
+ "plus-circle": 61711,
17
+ "plus-cicle": 61712,
18
+ "plus-cicle-border": 61713,
19
+ "pin": 61714,
20
+ "paint-brush": 61715,
21
+ "new-event": 61716,
22
+ "msg": 61717,
23
+ "low-smile": 61718,
24
+ "low-sad": 61719,
25
+ "log-out": 61720,
26
+ "lock": 61721,
27
+ "list": 61722,
28
+ "icon-5": 61723,
29
+ "icon-4": 61724,
30
+ "icon-3": 61725,
31
+ "icon-2": 61726,
32
+ "icon-1": 61727,
33
+ "high-smile": 61728,
34
+ "high-sad": 61729,
35
+ "heart": 61730,
36
+ "heart-filled": 61731,
37
+ "grid": 61732,
38
+ "flat": 61733,
39
+ "favourite-event": 61734,
40
+ "eye": 61735,
41
+ "ellipsis-horizontal": 61736,
42
+ "dollar": 61737,
43
+ "close": 61738,
44
+ "close-circle": 61739,
45
+ "clock": 61740,
46
+ "check": 61741,
47
+ "calendar": 61742,
48
+ "bookmark": 61743,
49
+ "bell": 61744,
50
+ "back": 61745,
51
+ "arrow-right": 61746,
52
+ "arrow-down": 61747
53
+ }