@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.
- package/CONTRIBUTING.md +27 -0
- package/LICENSE +22 -0
- package/README.md +32 -2
- package/ai/SETUP.md +5 -0
- package/docs/catalog.md +85 -0
- package/forge.manifest.js +75 -0
- package/lib/compat.js +40 -0
- package/lib/docs/build.js +146 -0
- package/lib/install.js +51 -0
- package/lib/journal.js +40 -0
- package/lib/jsonConfig.js +33 -0
- package/lib/migration.js +35 -0
- package/lib/names.js +42 -0
- package/lib/patch.js +62 -0
- package/lib/paths.js +12 -0
- package/lib/project.js +48 -0
- package/lib/registry.js +99 -0
- package/package.json +46 -4
- package/platforms/react-native/CATALOG.md +391 -0
- package/platforms/react-native/ORIGIN.md +42 -0
- package/platforms/react-native/README.md +78 -0
- package/platforms/react-native/ai/AGENTS.md.hbs +36 -0
- package/platforms/react-native/ai/SETUP.md +89 -0
- package/platforms/react-native/compat/matrix.js +150 -0
- package/platforms/react-native/configs/babel.js +63 -0
- package/platforms/react-native/configs/forgeConfig.js +35 -0
- package/platforms/react-native/configs/jsConfigs.js +96 -0
- package/platforms/react-native/configs/metro.js +86 -0
- package/platforms/react-native/generators/add/generator.js +12 -0
- package/platforms/react-native/generators/add/run.js +64 -0
- package/platforms/react-native/generators/component/generator.js +75 -0
- package/platforms/react-native/generators/component/render.js +69 -0
- package/platforms/react-native/generators/component/templates/Common.tsx.hbs +13 -0
- package/platforms/react-native/generators/component/templates/index.ts.hbs +13 -0
- package/platforms/react-native/generators/component/templates/pm.ts.hbs +7 -0
- package/platforms/react-native/generators/component/templates/types.ts.hbs +3 -0
- package/platforms/react-native/generators/demo/files/api/app.http +8 -0
- package/platforms/react-native/generators/demo/files/api/environment/http-client.env.json +5 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.api.ts +18 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.dto.ts +15 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.service.ts +42 -0
- package/platforms/react-native/generators/demo/files/entity/category/category.store.ts +26 -0
- package/platforms/react-native/generators/demo/files/entity/category/index.ts +2 -0
- package/platforms/react-native/generators/demo/files/entity/product/index.ts +2 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.api.ts +49 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.dto.ts +120 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.service.ts +139 -0
- package/platforms/react-native/generators/demo/files/entity/product/product.store.ts +37 -0
- package/platforms/react-native/generators/demo/files/feature/product/components/Product.CategorySelect.tsx +36 -0
- package/platforms/react-native/generators/demo/files/feature/product/detail/Product.Detail.Screen.tsx +100 -0
- package/platforms/react-native/generators/demo/files/feature/product/detail/product.detail.service.ts +33 -0
- package/platforms/react-native/generators/demo/files/feature/product/filter/Product.Filter.Screen.tsx +59 -0
- package/platforms/react-native/generators/demo/files/feature/product/filter/product.filter.service.ts +78 -0
- package/platforms/react-native/generators/demo/files/feature/product/form/Product.Form.Screen.tsx +71 -0
- package/platforms/react-native/generators/demo/files/feature/product/form/product.form.service.ts +142 -0
- package/platforms/react-native/generators/demo/files/feature/product/index.ts +7 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Item.tsx +34 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/Product.List.Screen.tsx +106 -0
- package/platforms/react-native/generators/demo/files/feature/product/list/product.list.service.ts +47 -0
- package/platforms/react-native/generators/demo/files/feature/product/product.feature.ts +29 -0
- package/platforms/react-native/generators/demo/files/feature/product/product.hooks.ts +7 -0
- package/platforms/react-native/generators/demo/files/feature/product/search/Product.Search.Screen.tsx +82 -0
- package/platforms/react-native/generators/demo/files/feature/product/search/product.search.service.ts +97 -0
- package/platforms/react-native/generators/demo/files/navigation/navigation.product.ts +46 -0
- package/platforms/react-native/generators/demo/generator.js +93 -0
- package/platforms/react-native/generators/entity/generator.js +68 -0
- package/platforms/react-native/generators/feature/generator.js +224 -0
- package/platforms/react-native/generators/feature/render.js +163 -0
- package/platforms/react-native/generators/feature/templates/detail.screen.tsx.hbs +25 -0
- package/platforms/react-native/generators/feature/templates/detail.service.ts.hbs +14 -0
- package/platforms/react-native/generators/feature/templates/feature.ts.hbs +18 -0
- package/platforms/react-native/generators/feature/templates/filter.screen.tsx.hbs +17 -0
- package/platforms/react-native/generators/feature/templates/filter.service.ts.hbs +14 -0
- package/platforms/react-native/generators/feature/templates/form.screen.tsx.hbs +21 -0
- package/platforms/react-native/generators/feature/templates/form.service.ts.hbs +37 -0
- package/platforms/react-native/generators/feature/templates/hooks.ts.hbs +7 -0
- package/platforms/react-native/generators/feature/templates/index.ts.hbs +2 -0
- package/platforms/react-native/generators/feature/templates/list.item.tsx.hbs +16 -0
- package/platforms/react-native/generators/feature/templates/list.screen.tsx.hbs +34 -0
- package/platforms/react-native/generators/feature/templates/list.service.ts.hbs +15 -0
- package/platforms/react-native/generators/feature/templates/navigation.ts.hbs +12 -0
- package/platforms/react-native/generators/feature/templates/search.screen.tsx.hbs +24 -0
- package/platforms/react-native/generators/feature/templates/search.service.ts.hbs +13 -0
- package/platforms/react-native/generators/feature/templates/tab.tsx.hbs +8 -0
- package/platforms/react-native/generators/init/files/app/app.controller.ts +41 -0
- package/platforms/react-native/generators/init/files/app/app.error.ts +1 -0
- package/platforms/react-native/generators/init/files/app/app.store.ts +12 -0
- package/platforms/react-native/generators/init/files/app/index.ts +19 -0
- package/platforms/react-native/generators/init/files/app/splash/Onboarding.Screen.tsx +31 -0
- package/platforms/react-native/generators/init/files/app/splash/Splash.Screen.tsx +14 -0
- package/platforms/react-native/generators/init/files/app/tabs/home/Home.tab.tsx +24 -0
- package/platforms/react-native/generators/init/files/app/tabs/profile/Profile.tab.tsx +1 -0
- package/platforms/react-native/generators/init/files/configs/dev.ts.hbs +5 -0
- package/platforms/react-native/generators/init/files/configs/index.ts +4 -0
- package/platforms/react-native/generators/init/files/configs/prod.ts.hbs +5 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.api.ts +36 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.dto.ts +26 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.service.ts +94 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.session.store.ts +14 -0
- package/platforms/react-native/generators/init/files/entity/auth/auth.store.ts +20 -0
- package/platforms/react-native/generators/init/files/entity/auth/index.ts +2 -0
- package/platforms/react-native/generators/init/files/entity/index.ts +2 -0
- package/platforms/react-native/generators/init/files/feature/auth/auth.feature.ts +10 -0
- package/platforms/react-native/generators/init/files/feature/auth/auth.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/feature/auth/index.ts +1 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-in/SignIn.Screen.tsx +39 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-in/signIn.service.ts +54 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-up/SignUp.Screen.tsx +64 -0
- package/platforms/react-native/generators/init/files/feature/auth/sign-up/signUp.service.ts +73 -0
- package/platforms/react-native/generators/init/files/feature/feature.hooks.ts +15 -0
- package/platforms/react-native/generators/init/files/feature/index.ts +3 -0
- package/platforms/react-native/generators/init/files/feature/profile/Profile.Screen.tsx +52 -0
- package/platforms/react-native/generators/init/files/feature/profile/index.ts +1 -0
- package/platforms/react-native/generators/init/files/feature/profile/profile.feature.ts +18 -0
- package/platforms/react-native/generators/init/files/feature/profile/profile.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/index.ts +16 -0
- package/platforms/react-native/generators/init/files/navigation/index.ts +18 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.app.ts +58 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.tabs.ts +55 -0
- package/platforms/react-native/generators/init/files/navigation/navigation.widgets.ts +23 -0
- package/platforms/react-native/generators/init/files/services/http/http.base.ts +69 -0
- package/platforms/react-native/generators/init/files/services/http/http.error.ts +10 -0
- package/platforms/react-native/generators/init/files/services/http/http.service.ts +24 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/index.ts +12 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.error.ts +36 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.registry.ts +3 -0
- package/platforms/react-native/generators/init/files/services/http/middleware/middleware.token.ts +97 -0
- package/platforms/react-native/generators/init/files/services/index.ts +15 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/box.pm.ts +111 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/box.types.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/components/Box/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/Common.tsx +50 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/Touchable.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.pm.ts +197 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.types.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/button.utils.ts +16 -0
- package/platforms/react-native/generators/init/files/ui/components/Button/index.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Colours.tsx +50 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Common.tsx +38 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/ErrorText.tsx +11 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Input.tsx +115 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/InputArea.tsx +70 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Label.tsx +18 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/Select.tsx +86 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/components/SecureTextEntry.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.error.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.pm.ts +134 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/form.types.ts +59 -0
- package/platforms/react-native/generators/init/files/ui/components/Form/index.ts +67 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/Common.tsx +11 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/grid.pm.ts +93 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/grid.types.ts +79 -0
- package/platforms/react-native/generators/init/files/ui/components/Grid/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/icons.pm.ts +74 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/icons.types.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/Icon/index.ts +3 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/Loading.tsx +10 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.hook.ts +5 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.service.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Loading/loading.store.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Common.tsx +87 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Content.tsx +77 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/Header.tsx +80 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/HeaderTab.tsx +17 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/SafeAreaHOC.tsx +9 -0
- package/platforms/react-native/generators/init/files/ui/components/Screen/index.ts +22 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/Common.tsx +20 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/index.ts +13 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/text.pm.ts +55 -0
- package/platforms/react-native/generators/init/files/ui/components/Text/text.types.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/Common.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/index.ts +15 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.pm.ts +65 -0
- package/platforms/react-native/generators/init/files/ui/components/TextInput/textInput.types.ts +16 -0
- package/platforms/react-native/generators/init/files/ui/components/ThemePicker/ThemePicker.tsx +92 -0
- package/platforms/react-native/generators/init/files/ui/components/ThemePicker/index.ts +1 -0
- package/platforms/react-native/generators/init/files/ui/components/index.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/color.ts +19 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/index.ts +3 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.spec.tsx +202 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useLoading.hook.ts +172 -0
- package/platforms/react-native/generators/init/files/ui/components/utils/useStore.ts +34 -0
- package/platforms/react-native/generators/init/files/ui/fonts/font-icons.ttf +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/font-icons.json +53 -0
- package/platforms/react-native/generators/init/files/ui/icons/logo.png +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/logo.svg +304 -0
- package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-1.png +0 -0
- package/platforms/react-native/generators/init/files/ui/icons/tabs/icon-2.png +0 -0
- package/platforms/react-native/generators/init/files/ui/theme/black/black.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/black/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/blue/blue.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/blue/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/green/green.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/green/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/index.ts +11 -0
- package/platforms/react-native/generators/init/files/ui/theme/pink/index.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/pink/pink.color.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/index.ts +23 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.color.ts +139 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.radius.ts +21 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.spacing.ts +24 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.ts +25 -0
- package/platforms/react-native/generators/init/files/ui/theme/scheme/theme.scheme.typography.ts +98 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/index.ts +4 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.color.base.ts +79 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.radius.ts +8 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.spacing.ts +9 -0
- package/platforms/react-native/generators/init/files/ui/theme/shared/shared.typography.ts +105 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.hooks.ts +7 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.meta.ts +10 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.provider.tsx +19 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.service.ts +36 -0
- package/platforms/react-native/generators/init/files/ui/theme/theme.ts +27 -0
- package/platforms/react-native/generators/init/files/ui/widgets/index.ts +1 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Item.tsx +175 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Overlay.tsx +46 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/Toast.Stack.tsx +75 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/index.ts +7 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.hooks.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.service.ts +39 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.store.ts +59 -0
- package/platforms/react-native/generators/init/files/ui/widgets/toast/toast.types.ts +18 -0
- package/platforms/react-native/generators/init/files/ui/widgets/widgets.feature.ts +14 -0
- package/platforms/react-native/generators/init/files/utils/date.ts +11 -0
- package/platforms/react-native/generators/init/files/utils/index.ts +12 -0
- package/platforms/react-native/generators/init/files/utils/store.persistent.ts +103 -0
- package/platforms/react-native/generators/init/files/utils/store.registry.ts +14 -0
- package/platforms/react-native/generators/init/files/utils/string.ts +100 -0
- package/platforms/react-native/generators/init/generator.js +86 -0
- package/platforms/react-native/generators/init/kit.js +23 -0
- package/platforms/react-native/generators/init/navigators/expo-router/index.ts +18 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.app.ts +8 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.tabs.ts +7 -0
- package/platforms/react-native/generators/init/navigators/expo-router/navigation.widgets.ts +5 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/index.ts +18 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.app.ts +8 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.features.ts +9 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.hooks.ts +5 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.tabs.ts +7 -0
- package/platforms/react-native/generators/init/navigators/react-navigation/navigation.widgets.ts +5 -0
- package/platforms/react-native/generators/setup/generator.js +225 -0
- package/platforms/react-native/generators/util/generator.js +12 -0
- package/platforms/react-native/platform.js +32 -0
- package/platforms/react-native/runtime.js +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/README.md +29 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Common.tsx +120 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Content.tsx +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Context.tsx +22 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/FlatList.tsx +50 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Header.tsx +57 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/Search.tsx +24 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.constants.ts +13 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/bottomSheet.types.ts +31 -0
- package/platforms/react-native/solutions/components/BottomSheet/files/index.ts +33 -0
- package/platforms/react-native/solutions/components/BottomSheet/solution.js +38 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/README.md +29 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/SelectPicker.tsx +47 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/Content.BottomSheet.tsx +22 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/DateTimePicker.BottomSheet.tsx +74 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/files/bottomSheet/List.BottomSheet.tsx +62 -0
- package/platforms/react-native/solutions/components/BottomSheetWidgets/solution.js +49 -0
- package/platforms/react-native/solutions/components/Calendar/README.md +29 -0
- package/platforms/react-native/solutions/components/Calendar/files/Common.tsx +16 -0
- package/platforms/react-native/solutions/components/Calendar/files/Context.tsx +466 -0
- package/platforms/react-native/solutions/components/Calendar/files/DayCell.tsx +89 -0
- package/platforms/react-native/solutions/components/Calendar/files/MonthView.tsx +41 -0
- package/platforms/react-native/solutions/components/Calendar/files/MonthYearOverlay.tsx +51 -0
- package/platforms/react-native/solutions/components/Calendar/files/SwipeablePeriod.tsx +44 -0
- package/platforms/react-native/solutions/components/Calendar/files/WeekDayTitles.tsx +31 -0
- package/platforms/react-native/solutions/components/Calendar/files/WeekView.tsx +40 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.styles.ts +142 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.types.ts +126 -0
- package/platforms/react-native/solutions/components/Calendar/files/calendar.utils.ts +143 -0
- package/platforms/react-native/solutions/components/Calendar/files/index.ts +40 -0
- package/platforms/react-native/solutions/components/Calendar/solution.js +38 -0
- package/platforms/react-native/solutions/components/Chart/README.md +29 -0
- package/platforms/react-native/solutions/components/Chart/files/Cilcular.tsx +140 -0
- package/platforms/react-native/solutions/components/Chart/files/index.ts +3 -0
- package/platforms/react-native/solutions/components/Chart/solution.js +38 -0
- package/platforms/react-native/solutions/components/CheckBox/README.md +29 -0
- package/platforms/react-native/solutions/components/CheckBox/files/Common.tsx +55 -0
- package/platforms/react-native/solutions/components/CheckBox/files/checkbox.pm.ts +71 -0
- package/platforms/react-native/solutions/components/CheckBox/files/index.ts +9 -0
- package/platforms/react-native/solutions/components/CheckBox/form/Checkbox.tsx +22 -0
- package/platforms/react-native/solutions/components/CheckBox/solution.js +57 -0
- package/platforms/react-native/solutions/components/DateTimePicker/README.md +29 -0
- package/platforms/react-native/solutions/components/DateTimePicker/files/DateTimePicker.tsx +44 -0
- package/platforms/react-native/solutions/components/DateTimePicker/solution.js +45 -0
- package/platforms/react-native/solutions/components/Image/README.md +29 -0
- package/platforms/react-native/solutions/components/Image/files/SVG.tsx +74 -0
- package/platforms/react-native/solutions/components/Image/files/image.pm.ts +25 -0
- package/platforms/react-native/solutions/components/Image/files/image.utils.ts +35 -0
- package/platforms/react-native/solutions/components/Image/files/index.ts +5 -0
- package/platforms/react-native/solutions/components/Image/solution.js +40 -0
- package/platforms/react-native/solutions/components/InputSecurity/README.md +29 -0
- package/platforms/react-native/solutions/components/InputSecurity/files/InputSecurity.ts +142 -0
- package/platforms/react-native/solutions/components/InputSecurity/solution.js +28 -0
- package/platforms/react-native/solutions/components/OTP/README.md +29 -0
- package/platforms/react-native/solutions/components/OTP/files/Item.tsx +16 -0
- package/platforms/react-native/solutions/components/OTP/files/Items.tsx +33 -0
- package/platforms/react-native/solutions/components/OTP/files/index.tsx +120 -0
- package/platforms/react-native/solutions/components/OTP/files/otp.pm.ts +30 -0
- package/platforms/react-native/solutions/components/OTP/solution.js +38 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/README.md +29 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/Circular.tsx +154 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/Linear.tsx +133 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/circular.pm.ts +34 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/files/index.ts +16 -0
- package/platforms/react-native/solutions/components/ProgressIndicator/solution.js +39 -0
- package/platforms/react-native/solutions/components/Ruler/README.md +29 -0
- package/platforms/react-native/solutions/components/Ruler/files/Common.tsx +44 -0
- package/platforms/react-native/solutions/components/Ruler/files/Context.tsx +210 -0
- package/platforms/react-native/solutions/components/Ruler/files/Track.tsx +686 -0
- package/platforms/react-native/solutions/components/Ruler/files/Value.tsx +60 -0
- package/platforms/react-native/solutions/components/Ruler/files/index.ts +23 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.constants.ts +70 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.types.ts +98 -0
- package/platforms/react-native/solutions/components/Ruler/files/ruler.utils.ts +332 -0
- package/platforms/react-native/solutions/components/Ruler/solution.js +38 -0
- package/platforms/react-native/solutions/components/Section/README.md +29 -0
- package/platforms/react-native/solutions/components/Section/files/Common.tsx +144 -0
- package/platforms/react-native/solutions/components/Section/solution.js +37 -0
- package/platforms/react-native/solutions/components/Slider/README.md +29 -0
- package/platforms/react-native/solutions/components/Slider/files/Container.tsx +5 -0
- package/platforms/react-native/solutions/components/Slider/files/Content.tsx +44 -0
- package/platforms/react-native/solutions/components/Slider/files/Context.tsx +30 -0
- package/platforms/react-native/solutions/components/Slider/files/Pagination.Dot.tsx +61 -0
- package/platforms/react-native/solutions/components/Slider/files/index.ts +22 -0
- package/platforms/react-native/solutions/components/Slider/solution.js +38 -0
- package/platforms/react-native/solutions/components/Switch/README.md +29 -0
- package/platforms/react-native/solutions/components/Switch/files/Common.tsx +38 -0
- package/platforms/react-native/solutions/components/Switch/files/index.ts +9 -0
- package/platforms/react-native/solutions/components/Switch/files/switch.pm.ts +53 -0
- package/platforms/react-native/solutions/components/Switch/solution.js +38 -0
- package/platforms/react-native/solutions/install.js +97 -0
- package/platforms/react-native/solutions/services/firebase-core/README.md +31 -0
- package/platforms/react-native/solutions/services/firebase-core/files/index.ts +5 -0
- package/platforms/react-native/solutions/services/firebase-core/solution.js +39 -0
- package/platforms/react-native/solutions/services/firebase-messaging/README.md +31 -0
- package/platforms/react-native/solutions/services/firebase-messaging/files/index.ts +20 -0
- package/platforms/react-native/solutions/services/firebase-messaging/solution.js +42 -0
- package/platforms/react-native/solutions/utils/permissions/README.md +29 -0
- package/platforms/react-native/solutions/utils/permissions/files/permissions.ts +10 -0
- package/platforms/react-native/solutions/utils/permissions/solution.js +32 -0
- package/presets/react-native-fsd/index.js +25 -0
- package/shared/generators/entity/render.js +88 -0
- package/shared/generators/entity/templates/crud/api.ts.hbs +36 -0
- package/shared/generators/entity/templates/crud/dto.ts.hbs +36 -0
- package/shared/generators/entity/templates/crud/service.ts.hbs +73 -0
- package/shared/generators/entity/templates/crud/store.ts.hbs +27 -0
- package/shared/generators/entity/templates/index.ts.hbs +2 -0
- package/shared/generators/entity/templates/simple/api.ts.hbs +16 -0
- package/shared/generators/entity/templates/simple/dto.ts.hbs +5 -0
- package/shared/generators/entity/templates/simple/service.ts.hbs +26 -0
- package/shared/generators/entity/templates/simple/store.ts.hbs +18 -0
- package/shared/solutions/utils/date/README.md +29 -0
- package/shared/solutions/utils/date/files/date.ts +11 -0
- package/shared/solutions/utils/date/solution.js +27 -0
- package/shared/solutions/utils/string/README.md +29 -0
- package/shared/solutions/utils/string/files/string.ts +100 -0
- package/shared/solutions/utils/string/solution.js +27 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useNavigation } from '@effijs/navigation-react-native';
|
|
2
|
+
import { createContext, JSX, useContext, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import BottomSheet from '@components/BottomSheet';
|
|
5
|
+
|
|
6
|
+
export interface IListBottomSheetProps {
|
|
7
|
+
value?: any;
|
|
8
|
+
data: any[];
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
onSearch?: (query: string, item: any) => boolean;
|
|
12
|
+
renderItem: (item: any, close: () => void) => JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ListContext = createContext<{ value: any; setValue: (value?: any) => void }>({
|
|
16
|
+
value: undefined,
|
|
17
|
+
setValue: () => {},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export function useListContext() {
|
|
21
|
+
return useContext(ListContext);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default function ListBottomSheet({
|
|
25
|
+
value: initial,
|
|
26
|
+
title,
|
|
27
|
+
description,
|
|
28
|
+
data: allData,
|
|
29
|
+
onSearch,
|
|
30
|
+
renderItem,
|
|
31
|
+
}: IListBottomSheetProps) {
|
|
32
|
+
const { close } = useNavigation();
|
|
33
|
+
const [value, setValue] = useState(initial);
|
|
34
|
+
const [data, setData] = useState(allData);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<BottomSheet onClose={close} maxHeight={500}>
|
|
38
|
+
<BottomSheet.Header title={title} description={description} trailingActions={['close']} />
|
|
39
|
+
{onSearch ? (
|
|
40
|
+
<BottomSheet.Search
|
|
41
|
+
placeholder="Search"
|
|
42
|
+
onSearch={query => {
|
|
43
|
+
if (!query) {
|
|
44
|
+
setData(allData);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const filtered = allData.filter(item => onSearch?.(query, item));
|
|
48
|
+
setData(filtered);
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
) : null}
|
|
52
|
+
<ListContext.Provider value={{ value, setValue }}>
|
|
53
|
+
<BottomSheet.FlatList
|
|
54
|
+
data={data}
|
|
55
|
+
renderItem={props => renderItem?.(props, close)}
|
|
56
|
+
contentContainerStyle={{ paddingBottom: 20 }}
|
|
57
|
+
showsVerticalScrollIndicator={true}
|
|
58
|
+
/>
|
|
59
|
+
</ListContext.Provider>
|
|
60
|
+
</BottomSheet>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"id": "component:BottomSheetWidgets",
|
|
3
|
+
"type": "component",
|
|
4
|
+
"platforms": [
|
|
5
|
+
"react-native"
|
|
6
|
+
],
|
|
7
|
+
"title": "Bottom sheet widgets",
|
|
8
|
+
"description": "List and date-time sheets, plus Form.Element.SelectPicker.",
|
|
9
|
+
"status": "stable",
|
|
10
|
+
"since": "1.0.0",
|
|
11
|
+
"tags": [
|
|
12
|
+
"ui",
|
|
13
|
+
"widget"
|
|
14
|
+
],
|
|
15
|
+
"requires": [
|
|
16
|
+
"component:BottomSheet"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": [],
|
|
19
|
+
"files": [
|
|
20
|
+
{
|
|
21
|
+
"from": "files/bottomSheet",
|
|
22
|
+
"to": "ui/widgets/bottomSheet"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"from": "files/SelectPicker.tsx",
|
|
26
|
+
"to": "ui/components/Form/SelectPicker.tsx"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"register": [
|
|
30
|
+
{
|
|
31
|
+
"file": "ui/components/Form/index.ts",
|
|
32
|
+
"marker": "form-imports",
|
|
33
|
+
"code": "import SelectPicker from './SelectPicker';\n"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"file": "ui/components/Form/index.ts",
|
|
37
|
+
"marker": "form-types",
|
|
38
|
+
"code": " SelectPicker: typeof SelectPicker;\n"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"file": "ui/components/Form/index.ts",
|
|
42
|
+
"marker": "form-elements",
|
|
43
|
+
"code": " SelectPicker,\n"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"manual": [],
|
|
47
|
+
"api": "List bottom sheet and SelectPicker. DateTimePicker widget is used by component:DateTimePicker.",
|
|
48
|
+
"example": "<Form.Element.SelectPicker data={items} />"
|
|
49
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Calendar
|
|
2
|
+
|
|
3
|
+
Calendar from the previous template kit. Treat the API as experimental until it is wired into a screen.
|
|
4
|
+
|
|
5
|
+
## API
|
|
6
|
+
|
|
7
|
+
Default export from ui/components/Calendar.
|
|
8
|
+
|
|
9
|
+
## Example
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import Calendar from '@components/Calendar';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Dependencies
|
|
16
|
+
|
|
17
|
+
None beyond the setup baseline.
|
|
18
|
+
|
|
19
|
+
No other solutions are required.
|
|
20
|
+
|
|
21
|
+
## Manual steps
|
|
22
|
+
|
|
23
|
+
None.
|
|
24
|
+
|
|
25
|
+
## Added in
|
|
26
|
+
|
|
27
|
+
1.0.0 (`experimental`).
|
|
28
|
+
|
|
29
|
+
Install with `forge g add --id component:Calendar`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { calendarStyles } from './calendar.styles';
|
|
5
|
+
import type { ICalendarProps } from './calendar.types';
|
|
6
|
+
import { CalendarProvider } from './Context';
|
|
7
|
+
|
|
8
|
+
export default function CalendarCommon({ children, type = 'day', ...providerProps }: ICalendarProps) {
|
|
9
|
+
const resolvedChildren = typeof children === 'function' ? children() : children;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<CalendarProvider type={type} {...providerProps}>
|
|
13
|
+
<View style={calendarStyles.container}>{resolvedChildren}</View>
|
|
14
|
+
</CalendarProvider>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ICalendarContext,
|
|
5
|
+
ICalendarProps,
|
|
6
|
+
TCalendarActivePeriod,
|
|
7
|
+
TCalendarDayItem,
|
|
8
|
+
TCalendarDayRenderState,
|
|
9
|
+
TCalendarSelectType,
|
|
10
|
+
} from './calendar.types';
|
|
11
|
+
import {
|
|
12
|
+
addDays,
|
|
13
|
+
DEFAULT_MONTH_NAMES,
|
|
14
|
+
formatDate,
|
|
15
|
+
generateCalendarDays,
|
|
16
|
+
generateWeekDays,
|
|
17
|
+
getDayName,
|
|
18
|
+
getWeekDayLabels,
|
|
19
|
+
getWeekStart,
|
|
20
|
+
resolveInitialDate,
|
|
21
|
+
} from './calendar.utils';
|
|
22
|
+
|
|
23
|
+
const CalendarContext = createContext<ICalendarContext | null>(null);
|
|
24
|
+
|
|
25
|
+
const resolveMarker = (markedDates: ICalendarProps['markedDates'], dateKey: string) => {
|
|
26
|
+
const marker = markedDates?.[dateKey];
|
|
27
|
+
if (!marker) {
|
|
28
|
+
return { hasMarker: false, markerColor: undefined };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (typeof marker === 'boolean') {
|
|
32
|
+
return { hasMarker: marker, markerColor: undefined };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { hasMarker: true, markerColor: marker.dotColor };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function CalendarProvider({
|
|
39
|
+
children,
|
|
40
|
+
type = 'day',
|
|
41
|
+
minDate,
|
|
42
|
+
maxDate,
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
startWeekDay,
|
|
46
|
+
daysNames,
|
|
47
|
+
monthNames: customMonthNames,
|
|
48
|
+
defaultViewDate,
|
|
49
|
+
swipeable = true,
|
|
50
|
+
markedDates,
|
|
51
|
+
renderDayItem,
|
|
52
|
+
renderDayTitleItem,
|
|
53
|
+
}: ICalendarProps & { children: ReactNode }) {
|
|
54
|
+
const today = useMemo(() => new Date(), []);
|
|
55
|
+
const initialDate = useMemo(
|
|
56
|
+
() => defaultViewDate ?? resolveInitialDate(type, value, today),
|
|
57
|
+
[defaultViewDate, type, value, today],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const [selectType, setSelectType] = useState<TCalendarSelectType>();
|
|
61
|
+
const [currentMonth, setCurrentMonth] = useState(() => initialDate.getMonth());
|
|
62
|
+
const [currentYear, setCurrentYear] = useState(() => initialDate.getFullYear());
|
|
63
|
+
const [currentWeekStart, setCurrentWeekStart] = useState(() => {
|
|
64
|
+
const firstDayOfWeek = startWeekDay === 'monday' ? 1 : 0;
|
|
65
|
+
return getWeekStart(initialDate, firstDayOfWeek);
|
|
66
|
+
});
|
|
67
|
+
const [activePeriod, setActivePeriod] = useState<TCalendarActivePeriod>('month');
|
|
68
|
+
|
|
69
|
+
const [selectedStartDate, setSelectedStartDate] = useState<Date | null>(() =>
|
|
70
|
+
type === 'day' && value instanceof Date
|
|
71
|
+
? value
|
|
72
|
+
: type === 'period' &&
|
|
73
|
+
value &&
|
|
74
|
+
typeof value === 'object' &&
|
|
75
|
+
!(value instanceof Date) &&
|
|
76
|
+
value.startPeriod instanceof Date
|
|
77
|
+
? value.startPeriod
|
|
78
|
+
: null,
|
|
79
|
+
);
|
|
80
|
+
const [selectedEndDate, setSelectedEndDate] = useState<Date | null>(() =>
|
|
81
|
+
type === 'period' &&
|
|
82
|
+
value &&
|
|
83
|
+
typeof value === 'object' &&
|
|
84
|
+
!(value instanceof Date) &&
|
|
85
|
+
value.endPeriod instanceof Date
|
|
86
|
+
? value.endPeriod
|
|
87
|
+
: null,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const firstDayOfWeek = useMemo(() => (startWeekDay === 'monday' ? 1 : 0), [startWeekDay]);
|
|
91
|
+
|
|
92
|
+
const monthNames = useMemo(() => customMonthNames || DEFAULT_MONTH_NAMES, [customMonthNames]);
|
|
93
|
+
const weekDays = useMemo(() => getWeekDayLabels(daysNames, firstDayOfWeek), [daysNames, firstDayOfWeek]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (type === 'day' && value instanceof Date) {
|
|
97
|
+
setSelectedStartDate(value);
|
|
98
|
+
setSelectedEndDate(null);
|
|
99
|
+
setCurrentMonth(value.getMonth());
|
|
100
|
+
setCurrentYear(value.getFullYear());
|
|
101
|
+
setCurrentWeekStart(getWeekStart(value, firstDayOfWeek));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (type === 'period' && value && typeof value === 'object' && !(value instanceof Date)) {
|
|
106
|
+
const start = value.startPeriod instanceof Date ? value.startPeriod : null;
|
|
107
|
+
const end = value.endPeriod instanceof Date ? value.endPeriod : null;
|
|
108
|
+
setSelectedStartDate(start);
|
|
109
|
+
setSelectedEndDate(end);
|
|
110
|
+
|
|
111
|
+
if (start) {
|
|
112
|
+
setCurrentMonth(start.getMonth());
|
|
113
|
+
setCurrentYear(start.getFullYear());
|
|
114
|
+
setCurrentWeekStart(getWeekStart(start, firstDayOfWeek));
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (value === null) {
|
|
120
|
+
setSelectedStartDate(null);
|
|
121
|
+
setSelectedEndDate(null);
|
|
122
|
+
}
|
|
123
|
+
}, [value, type, firstDayOfWeek]);
|
|
124
|
+
|
|
125
|
+
const isToday = useCallback(
|
|
126
|
+
(year: number, month: number, day: number) =>
|
|
127
|
+
today.getDate() === day && today.getMonth() === month && today.getFullYear() === year,
|
|
128
|
+
[today],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const handleDateSelect = useCallback(
|
|
132
|
+
(year: number, month: number, day: number) => {
|
|
133
|
+
let selectedDate: Date | null = new Date(year, month, day);
|
|
134
|
+
|
|
135
|
+
if (minDate && selectedDate < minDate) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (maxDate && selectedDate > maxDate) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (type === 'day') {
|
|
144
|
+
if (selectedStartDate && formatDate(selectedDate) === formatDate(selectedStartDate)) {
|
|
145
|
+
selectedDate = null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setSelectedStartDate(selectedDate);
|
|
149
|
+
setSelectedEndDate(null);
|
|
150
|
+
onChange?.(selectedDate);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (type === 'period') {
|
|
155
|
+
if (
|
|
156
|
+
selectedStartDate &&
|
|
157
|
+
selectedEndDate &&
|
|
158
|
+
(formatDate(selectedDate) === formatDate(selectedStartDate) ||
|
|
159
|
+
formatDate(selectedDate) === formatDate(selectedEndDate))
|
|
160
|
+
) {
|
|
161
|
+
setSelectedStartDate(null);
|
|
162
|
+
setSelectedEndDate(null);
|
|
163
|
+
onChange?.(null);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!selectedStartDate || (selectedStartDate && selectedEndDate)) {
|
|
168
|
+
setSelectedStartDate(selectedDate);
|
|
169
|
+
setSelectedEndDate(null);
|
|
170
|
+
onChange?.(null);
|
|
171
|
+
} else {
|
|
172
|
+
const period = {
|
|
173
|
+
startPeriod: selectedStartDate,
|
|
174
|
+
endPeriod: selectedDate,
|
|
175
|
+
};
|
|
176
|
+
if (selectedDate < selectedStartDate) {
|
|
177
|
+
period.startPeriod = selectedDate;
|
|
178
|
+
period.endPeriod = selectedStartDate;
|
|
179
|
+
|
|
180
|
+
setSelectedStartDate(selectedDate);
|
|
181
|
+
setSelectedEndDate(selectedStartDate);
|
|
182
|
+
} else {
|
|
183
|
+
setSelectedEndDate(selectedDate);
|
|
184
|
+
}
|
|
185
|
+
onChange?.(period);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
[minDate, maxDate, selectedStartDate, selectedEndDate, type, onChange],
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const isInRange = useCallback(
|
|
193
|
+
(year: number, month: number, day: number) => {
|
|
194
|
+
if (!selectedStartDate || !selectedEndDate) return false;
|
|
195
|
+
|
|
196
|
+
const date = new Date(year, month, day);
|
|
197
|
+
return date >= selectedStartDate && date <= selectedEndDate;
|
|
198
|
+
},
|
|
199
|
+
[selectedStartDate, selectedEndDate],
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const isOutMinMax = useCallback(
|
|
203
|
+
(year: number, month: number, day: number) => {
|
|
204
|
+
if (!minDate && !maxDate) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const date = new Date(year, month, day);
|
|
209
|
+
|
|
210
|
+
return Boolean((minDate && minDate > date) || (maxDate && maxDate < date));
|
|
211
|
+
},
|
|
212
|
+
[minDate, maxDate],
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const isStartDate = useCallback(
|
|
216
|
+
(year: number, month: number, day: number) => {
|
|
217
|
+
if (!selectedStartDate) return false;
|
|
218
|
+
|
|
219
|
+
const date = new Date(year, month, day);
|
|
220
|
+
return formatDate(date) === formatDate(selectedStartDate);
|
|
221
|
+
},
|
|
222
|
+
[selectedStartDate],
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const isEndDate = useCallback(
|
|
226
|
+
(year: number, month: number, day: number) => {
|
|
227
|
+
if (!selectedEndDate) return false;
|
|
228
|
+
|
|
229
|
+
const date = new Date(year, month, day);
|
|
230
|
+
return formatDate(date) === formatDate(selectedEndDate);
|
|
231
|
+
},
|
|
232
|
+
[selectedEndDate],
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const isStartWeekDay = useCallback(
|
|
236
|
+
(year: number, month: number, day: number) => {
|
|
237
|
+
const date = new Date(year, month, day);
|
|
238
|
+
return date.getDay() === firstDayOfWeek;
|
|
239
|
+
},
|
|
240
|
+
[firstDayOfWeek],
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const isEndWeekDay = useCallback(
|
|
244
|
+
(year: number, month: number, day: number) => {
|
|
245
|
+
const date = new Date(year, month, day);
|
|
246
|
+
return date.getDay() === (firstDayOfWeek === 1 ? 0 : 6);
|
|
247
|
+
},
|
|
248
|
+
[firstDayOfWeek],
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const goToPreviousMonth = useCallback(() => {
|
|
252
|
+
if (currentMonth === 0) {
|
|
253
|
+
setCurrentMonth(11);
|
|
254
|
+
setCurrentYear(prev => prev - 1);
|
|
255
|
+
} else {
|
|
256
|
+
setCurrentMonth(prev => prev - 1);
|
|
257
|
+
}
|
|
258
|
+
}, [currentMonth]);
|
|
259
|
+
|
|
260
|
+
const goToNextMonth = useCallback(() => {
|
|
261
|
+
if (currentMonth === 11) {
|
|
262
|
+
setCurrentMonth(0);
|
|
263
|
+
setCurrentYear(prev => prev + 1);
|
|
264
|
+
} else {
|
|
265
|
+
setCurrentMonth(prev => prev + 1);
|
|
266
|
+
}
|
|
267
|
+
}, [currentMonth]);
|
|
268
|
+
|
|
269
|
+
const goToPreviousWeek = useCallback(() => {
|
|
270
|
+
setCurrentWeekStart(prev => {
|
|
271
|
+
const next = addDays(prev, -7);
|
|
272
|
+
setCurrentMonth(next.getMonth());
|
|
273
|
+
setCurrentYear(next.getFullYear());
|
|
274
|
+
return next;
|
|
275
|
+
});
|
|
276
|
+
}, []);
|
|
277
|
+
|
|
278
|
+
const goToNextWeek = useCallback(() => {
|
|
279
|
+
setCurrentWeekStart(prev => {
|
|
280
|
+
const next = addDays(prev, 7);
|
|
281
|
+
setCurrentMonth(next.getMonth());
|
|
282
|
+
setCurrentYear(next.getFullYear());
|
|
283
|
+
return next;
|
|
284
|
+
});
|
|
285
|
+
}, []);
|
|
286
|
+
|
|
287
|
+
const handlePrevPeriod = useCallback(
|
|
288
|
+
(period?: TCalendarActivePeriod) => {
|
|
289
|
+
const target = period ?? activePeriod;
|
|
290
|
+
if (target === 'week') {
|
|
291
|
+
goToPreviousWeek();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
goToPreviousMonth();
|
|
295
|
+
},
|
|
296
|
+
[activePeriod, goToPreviousMonth, goToPreviousWeek],
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
const handleNextPeriod = useCallback(
|
|
300
|
+
(period?: TCalendarActivePeriod) => {
|
|
301
|
+
const target = period ?? activePeriod;
|
|
302
|
+
if (target === 'week') {
|
|
303
|
+
goToNextWeek();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
goToNextMonth();
|
|
307
|
+
},
|
|
308
|
+
[activePeriod, goToNextMonth, goToNextWeek],
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const handleToday = useCallback(() => {
|
|
312
|
+
setCurrentMonth(today.getMonth());
|
|
313
|
+
setCurrentYear(today.getFullYear());
|
|
314
|
+
setCurrentWeekStart(getWeekStart(today, firstDayOfWeek));
|
|
315
|
+
}, [today, firstDayOfWeek]);
|
|
316
|
+
|
|
317
|
+
const setViewDate = useCallback(
|
|
318
|
+
(date: Date) => {
|
|
319
|
+
setCurrentMonth(date.getMonth());
|
|
320
|
+
setCurrentYear(date.getFullYear());
|
|
321
|
+
setCurrentWeekStart(getWeekStart(date, firstDayOfWeek));
|
|
322
|
+
},
|
|
323
|
+
[firstDayOfWeek],
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
const onMonthSelect = useCallback(() => {
|
|
327
|
+
setSelectType(prev => (prev === 'month' ? undefined : 'month'));
|
|
328
|
+
}, []);
|
|
329
|
+
|
|
330
|
+
const onYearSelect = useCallback(() => {
|
|
331
|
+
setSelectType(prev => (prev === 'year' ? undefined : 'year'));
|
|
332
|
+
}, []);
|
|
333
|
+
|
|
334
|
+
const calendarDays = useMemo(
|
|
335
|
+
() => generateCalendarDays(currentYear, currentMonth, firstDayOfWeek),
|
|
336
|
+
[currentYear, currentMonth, firstDayOfWeek],
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const weekDaysItems = useMemo(
|
|
340
|
+
() => generateWeekDays(currentWeekStart, currentMonth, currentYear),
|
|
341
|
+
[currentWeekStart, currentMonth, currentYear],
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
const getDayNameForDate = useCallback((date: Date) => getDayName(date, daysNames), [daysNames]);
|
|
345
|
+
|
|
346
|
+
const getDayRenderState = useCallback(
|
|
347
|
+
(item: TCalendarDayItem): TCalendarDayRenderState => {
|
|
348
|
+
const markerInfo = resolveMarker(markedDates, formatDate(item.date));
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
isToday: isToday(item.year, item.month, item.day),
|
|
352
|
+
isStart: isStartDate(item.year, item.month, item.day),
|
|
353
|
+
isEnd: isEndDate(item.year, item.month, item.day),
|
|
354
|
+
isInRange: isInRange(item.year, item.month, item.day),
|
|
355
|
+
isOutMinMax: isOutMinMax(item.year, item.month, item.day),
|
|
356
|
+
isStartWeekDay: isStartWeekDay(item.year, item.month, item.day),
|
|
357
|
+
isEndWeekDay: isEndWeekDay(item.year, item.month, item.day),
|
|
358
|
+
hasMarker: markerInfo.hasMarker,
|
|
359
|
+
markerColor: markerInfo.markerColor,
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
[markedDates, isToday, isStartDate, isEndDate, isInRange, isOutMinMax, isStartWeekDay, isEndWeekDay],
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
const contextValue = useMemo<ICalendarContext>(
|
|
366
|
+
() => ({
|
|
367
|
+
type,
|
|
368
|
+
value,
|
|
369
|
+
today,
|
|
370
|
+
minDate,
|
|
371
|
+
maxDate,
|
|
372
|
+
currentMonth,
|
|
373
|
+
currentYear,
|
|
374
|
+
currentWeekStart,
|
|
375
|
+
selectType,
|
|
376
|
+
selectedStartDate,
|
|
377
|
+
selectedEndDate,
|
|
378
|
+
firstDayOfWeek,
|
|
379
|
+
monthNames,
|
|
380
|
+
weekDays,
|
|
381
|
+
activePeriod,
|
|
382
|
+
swipeable,
|
|
383
|
+
markedDates,
|
|
384
|
+
renderDayItem,
|
|
385
|
+
renderDayTitleItem,
|
|
386
|
+
handleDateSelect,
|
|
387
|
+
handlePrevPeriod,
|
|
388
|
+
handleNextPeriod,
|
|
389
|
+
handleToday,
|
|
390
|
+
setViewDate,
|
|
391
|
+
setActivePeriod,
|
|
392
|
+
onMonthSelect,
|
|
393
|
+
onYearSelect,
|
|
394
|
+
setCurrentMonth,
|
|
395
|
+
setCurrentYear,
|
|
396
|
+
setSelectType,
|
|
397
|
+
isToday,
|
|
398
|
+
isInRange,
|
|
399
|
+
isOutMinMax,
|
|
400
|
+
isStartDate,
|
|
401
|
+
isEndDate,
|
|
402
|
+
isStartWeekDay,
|
|
403
|
+
isEndWeekDay,
|
|
404
|
+
formatDate,
|
|
405
|
+
getDayName: getDayNameForDate,
|
|
406
|
+
getDayRenderState,
|
|
407
|
+
generateCalendarDays: calendarDays,
|
|
408
|
+
generateWeekDays: weekDaysItems,
|
|
409
|
+
}),
|
|
410
|
+
[
|
|
411
|
+
type,
|
|
412
|
+
value,
|
|
413
|
+
today,
|
|
414
|
+
minDate,
|
|
415
|
+
maxDate,
|
|
416
|
+
currentMonth,
|
|
417
|
+
currentYear,
|
|
418
|
+
currentWeekStart,
|
|
419
|
+
selectType,
|
|
420
|
+
selectedStartDate,
|
|
421
|
+
selectedEndDate,
|
|
422
|
+
firstDayOfWeek,
|
|
423
|
+
monthNames,
|
|
424
|
+
weekDays,
|
|
425
|
+
activePeriod,
|
|
426
|
+
swipeable,
|
|
427
|
+
markedDates,
|
|
428
|
+
renderDayItem,
|
|
429
|
+
renderDayTitleItem,
|
|
430
|
+
handleDateSelect,
|
|
431
|
+
handlePrevPeriod,
|
|
432
|
+
handleNextPeriod,
|
|
433
|
+
handleToday,
|
|
434
|
+
setViewDate,
|
|
435
|
+
onMonthSelect,
|
|
436
|
+
onYearSelect,
|
|
437
|
+
isToday,
|
|
438
|
+
isInRange,
|
|
439
|
+
isOutMinMax,
|
|
440
|
+
isStartDate,
|
|
441
|
+
isEndDate,
|
|
442
|
+
isStartWeekDay,
|
|
443
|
+
isEndWeekDay,
|
|
444
|
+
getDayRenderState,
|
|
445
|
+
getDayNameForDate,
|
|
446
|
+
calendarDays,
|
|
447
|
+
weekDaysItems,
|
|
448
|
+
],
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
return <CalendarContext.Provider value={contextValue}>{children}</CalendarContext.Provider>;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export function useCalendar(): ICalendarContext {
|
|
455
|
+
const context = useContext(CalendarContext);
|
|
456
|
+
|
|
457
|
+
if (!context) {
|
|
458
|
+
throw new Error('useCalendar must be used within a Calendar component');
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return context;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export function useOptionalCalendar() {
|
|
465
|
+
return useContext(CalendarContext);
|
|
466
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, TouchableOpacity, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { calendarStyles } from './calendar.styles';
|
|
5
|
+
import type { TCalendarDayItem, TCalendarDayRender } from './calendar.types';
|
|
6
|
+
import { useCalendar } from './Context';
|
|
7
|
+
|
|
8
|
+
interface IDayCellProps {
|
|
9
|
+
item: TCalendarDayItem;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
renderDayItem?: TCalendarDayRender;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function DayCell({ item, style, renderDayItem: renderDayItemProp }: IDayCellProps) {
|
|
15
|
+
const {
|
|
16
|
+
handleDateSelect,
|
|
17
|
+
getDayRenderState,
|
|
18
|
+
selectedStartDate,
|
|
19
|
+
selectedEndDate,
|
|
20
|
+
formatDate,
|
|
21
|
+
getDayName,
|
|
22
|
+
renderDayItem: renderDayItemContext,
|
|
23
|
+
} = useCalendar();
|
|
24
|
+
|
|
25
|
+
const state = getDayRenderState(item);
|
|
26
|
+
const renderDayItem = renderDayItemProp ?? renderDayItemContext;
|
|
27
|
+
const onPress = () => handleDateSelect(item.year, item.month, item.day);
|
|
28
|
+
const dayName = getDayName(item.date);
|
|
29
|
+
|
|
30
|
+
if (renderDayItem) {
|
|
31
|
+
return renderDayItem({ item, state, onPress, dayName });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isStart = state.isStart;
|
|
35
|
+
const isEnd = state.isEnd;
|
|
36
|
+
const isRange = state.isInRange;
|
|
37
|
+
const isOutMinMaxRange = state.isOutMinMax;
|
|
38
|
+
const isTodayDate = state.isToday;
|
|
39
|
+
const isStartWeekDate = state.isStartWeekDay;
|
|
40
|
+
const isEndWeekDate = state.isEndWeekDay;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<TouchableOpacity style={[calendarStyles.dayButton, style]} onPress={onPress}>
|
|
44
|
+
{selectedStartDate &&
|
|
45
|
+
selectedEndDate &&
|
|
46
|
+
formatDate(selectedStartDate) !== formatDate(selectedEndDate) &&
|
|
47
|
+
(isStart || isEnd) ? (
|
|
48
|
+
<View
|
|
49
|
+
style={[
|
|
50
|
+
calendarStyles.startEndRange,
|
|
51
|
+
{
|
|
52
|
+
backgroundColor: isStart || isEnd ? '#FE00001A' : 'transparent',
|
|
53
|
+
right: isStart ? 0 : undefined,
|
|
54
|
+
left: isEnd ? 0 : undefined,
|
|
55
|
+
},
|
|
56
|
+
]}
|
|
57
|
+
/>
|
|
58
|
+
) : null}
|
|
59
|
+
<View
|
|
60
|
+
style={[
|
|
61
|
+
StyleSheet.absoluteFill,
|
|
62
|
+
!isStart && !isEnd && !isRange && !item.isCurrentMonth && calendarStyles.otherMonthDay,
|
|
63
|
+
isStart && calendarStyles.startDate,
|
|
64
|
+
isEnd && calendarStyles.endDate,
|
|
65
|
+
isRange && !isStart && !isEnd && calendarStyles.inRange,
|
|
66
|
+
isRange && !isStart && !isEnd && isStartWeekDate && calendarStyles.inRangeStartWeek,
|
|
67
|
+
isRange && !isStart && !isEnd && isEndWeekDate && calendarStyles.inRangeEndWeek,
|
|
68
|
+
]}
|
|
69
|
+
/>
|
|
70
|
+
<Text
|
|
71
|
+
style={[
|
|
72
|
+
calendarStyles.dayText,
|
|
73
|
+
!item.isCurrentMonth && calendarStyles.otherMonthDayText,
|
|
74
|
+
item.isCurrentMonth && isOutMinMaxRange && calendarStyles.outMinMaxRangeText,
|
|
75
|
+
isTodayDate && calendarStyles.todayText,
|
|
76
|
+
(isStart || isEnd) && calendarStyles.selectedDayText,
|
|
77
|
+
isRange && !isStart && !isEnd && calendarStyles.inRangeText,
|
|
78
|
+
]}>
|
|
79
|
+
{item.day}
|
|
80
|
+
</Text>
|
|
81
|
+
{isTodayDate ? <View style={calendarStyles.today} /> : null}
|
|
82
|
+
{state.hasMarker ? (
|
|
83
|
+
<View
|
|
84
|
+
style={[calendarStyles.markerDot, state.markerColor ? { backgroundColor: state.markerColor } : undefined]}
|
|
85
|
+
/>
|
|
86
|
+
) : null}
|
|
87
|
+
</TouchableOpacity>
|
|
88
|
+
);
|
|
89
|
+
}
|