@effijs/templates 0.0.0-stage → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { calendarStyles } from './calendar.styles';
|
|
5
|
+
import type { ICalendarMonthViewProps } from './calendar.types';
|
|
6
|
+
import { useCalendar } from './Context';
|
|
7
|
+
import DayCell from './DayCell';
|
|
8
|
+
import MonthYearOverlay from './MonthYearOverlay';
|
|
9
|
+
import SwipeablePeriod from './SwipeablePeriod';
|
|
10
|
+
import WeekDayTitles from './WeekDayTitles';
|
|
11
|
+
|
|
12
|
+
export default function MonthView({
|
|
13
|
+
showWeekDays = true,
|
|
14
|
+
swipeable,
|
|
15
|
+
renderDayItem,
|
|
16
|
+
renderDayTitleItem,
|
|
17
|
+
}: ICalendarMonthViewProps) {
|
|
18
|
+
const { generateCalendarDays, setActivePeriod } = useCalendar();
|
|
19
|
+
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
setActivePeriod('month');
|
|
22
|
+
}, [setActivePeriod]);
|
|
23
|
+
|
|
24
|
+
const content = (
|
|
25
|
+
<View>
|
|
26
|
+
{showWeekDays ? <WeekDayTitles renderDayTitleItem={renderDayTitleItem} /> : null}
|
|
27
|
+
<View style={calendarStyles.daysContainer}>
|
|
28
|
+
{generateCalendarDays.map((item, index) => (
|
|
29
|
+
<DayCell key={`${item.year}-${item.month}-${item.day}-${index}`} item={item} renderDayItem={renderDayItem} />
|
|
30
|
+
))}
|
|
31
|
+
</View>
|
|
32
|
+
<MonthYearOverlay />
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<SwipeablePeriod enabled={swipeable} period="month">
|
|
38
|
+
{content}
|
|
39
|
+
</SwipeablePeriod>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { calendarStyles } from './calendar.styles';
|
|
5
|
+
import { useCalendar } from './Context';
|
|
6
|
+
|
|
7
|
+
export default function MonthYearOverlay() {
|
|
8
|
+
const { selectType, monthNames, today, setCurrentMonth, setCurrentYear, setSelectType } = useCalendar();
|
|
9
|
+
|
|
10
|
+
if (!selectType) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<View style={calendarStyles.monthContainer}>
|
|
16
|
+
{selectType === 'month' ? (
|
|
17
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(index => (
|
|
18
|
+
<TouchableOpacity
|
|
19
|
+
key={index}
|
|
20
|
+
style={calendarStyles.monthItem}
|
|
21
|
+
onPress={() => {
|
|
22
|
+
setCurrentMonth(index);
|
|
23
|
+
setSelectType(undefined);
|
|
24
|
+
}}>
|
|
25
|
+
<Text style={calendarStyles.monthText}>{monthNames[index]}</Text>
|
|
26
|
+
</TouchableOpacity>
|
|
27
|
+
))
|
|
28
|
+
) : (
|
|
29
|
+
<ScrollView
|
|
30
|
+
style={calendarStyles.yearScrollContainer}
|
|
31
|
+
contentContainerStyle={calendarStyles.yearScrollContent}
|
|
32
|
+
showsVerticalScrollIndicator={true}>
|
|
33
|
+
{Array.from({ length: 101 }, (_, index) => {
|
|
34
|
+
const year = today.getFullYear() - index;
|
|
35
|
+
return (
|
|
36
|
+
<TouchableOpacity
|
|
37
|
+
key={year}
|
|
38
|
+
style={calendarStyles.yearItem}
|
|
39
|
+
onPress={() => {
|
|
40
|
+
setCurrentYear(year);
|
|
41
|
+
setSelectType(undefined);
|
|
42
|
+
}}>
|
|
43
|
+
<Text style={calendarStyles.monthText}>{year}</Text>
|
|
44
|
+
</TouchableOpacity>
|
|
45
|
+
);
|
|
46
|
+
})}
|
|
47
|
+
</ScrollView>
|
|
48
|
+
)}
|
|
49
|
+
</View>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { GestureDetector, usePanGesture } from 'react-native-gesture-handler';
|
|
3
|
+
import { runOnJS } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
import type { TCalendarActivePeriod } from './calendar.types';
|
|
6
|
+
import { useCalendar } from './Context';
|
|
7
|
+
|
|
8
|
+
const SWIPE_THRESHOLD = 50;
|
|
9
|
+
|
|
10
|
+
interface ISwipeablePeriodProps {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
period?: TCalendarActivePeriod;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function SwipeablePeriod({ children, enabled = true, period = 'month' }: ISwipeablePeriodProps) {
|
|
17
|
+
const { handlePrevPeriod, handleNextPeriod, selectType, swipeable } = useCalendar();
|
|
18
|
+
|
|
19
|
+
const isEnabled = enabled && swipeable && !selectType;
|
|
20
|
+
|
|
21
|
+
const onSwipePrev = useCallback(() => handlePrevPeriod(period), [handlePrevPeriod, period]);
|
|
22
|
+
const onSwipeNext = useCallback(() => handleNextPeriod(period), [handleNextPeriod, period]);
|
|
23
|
+
|
|
24
|
+
const gesture = usePanGesture({
|
|
25
|
+
activeOffsetX: [-10, 10],
|
|
26
|
+
onDeactivate: event => {
|
|
27
|
+
if (!isEnabled) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (event.translationX < -SWIPE_THRESHOLD) {
|
|
32
|
+
runOnJS(onSwipeNext)();
|
|
33
|
+
} else if (event.translationX > SWIPE_THRESHOLD) {
|
|
34
|
+
runOnJS(onSwipePrev)();
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!isEnabled) {
|
|
40
|
+
return <>{children}</>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <GestureDetector gesture={gesture}>{children}</GestureDetector>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { calendarStyles } from './calendar.styles';
|
|
5
|
+
import type { TCalendarDayTitleRender } from './calendar.types';
|
|
6
|
+
import { useCalendar } from './Context';
|
|
7
|
+
|
|
8
|
+
interface IWeekDayTitlesProps {
|
|
9
|
+
renderDayTitleItem?: TCalendarDayTitleRender;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function WeekDayTitles({ renderDayTitleItem: renderDayTitleItemProp }: IWeekDayTitlesProps) {
|
|
13
|
+
const { weekDays, renderDayTitleItem: renderDayTitleItemContext } = useCalendar();
|
|
14
|
+
const renderDayTitleItem = renderDayTitleItemProp ?? renderDayTitleItemContext;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View style={calendarStyles.weekDaysContainer}>
|
|
18
|
+
{weekDays.map((day, index) =>
|
|
19
|
+
renderDayTitleItem ? (
|
|
20
|
+
<View key={index} style={calendarStyles.weekDayTitleCell}>
|
|
21
|
+
{renderDayTitleItem({ dayName: day, index })}
|
|
22
|
+
</View>
|
|
23
|
+
) : (
|
|
24
|
+
<Text key={index} style={calendarStyles.weekDayText}>
|
|
25
|
+
{day}
|
|
26
|
+
</Text>
|
|
27
|
+
),
|
|
28
|
+
)}
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { calendarStyles } from './calendar.styles';
|
|
5
|
+
import type { ICalendarWeekViewProps } from './calendar.types';
|
|
6
|
+
import { useCalendar } from './Context';
|
|
7
|
+
import DayCell from './DayCell';
|
|
8
|
+
import SwipeablePeriod from './SwipeablePeriod';
|
|
9
|
+
import WeekDayTitles from './WeekDayTitles';
|
|
10
|
+
|
|
11
|
+
export default function WeekView({ swipeable, renderDayItem, renderDayTitleItem }: ICalendarWeekViewProps) {
|
|
12
|
+
const { generateWeekDays, setActivePeriod } = useCalendar();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setActivePeriod('week');
|
|
16
|
+
return () => setActivePeriod('month');
|
|
17
|
+
}, [setActivePeriod]);
|
|
18
|
+
|
|
19
|
+
const content = (
|
|
20
|
+
<View>
|
|
21
|
+
<WeekDayTitles renderDayTitleItem={renderDayTitleItem} />
|
|
22
|
+
<View style={calendarStyles.weekRowContainer}>
|
|
23
|
+
{generateWeekDays.map((item, index) => (
|
|
24
|
+
<DayCell
|
|
25
|
+
key={`${item.year}-${item.month}-${item.day}-${index}`}
|
|
26
|
+
item={item}
|
|
27
|
+
style={calendarStyles.weekDayButton}
|
|
28
|
+
renderDayItem={renderDayItem}
|
|
29
|
+
/>
|
|
30
|
+
))}
|
|
31
|
+
</View>
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<SwipeablePeriod enabled={swipeable} period="week">
|
|
37
|
+
{content}
|
|
38
|
+
</SwipeablePeriod>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const calendarStyles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
// backgroundColor: '#fff',
|
|
6
|
+
padding: 1,
|
|
7
|
+
},
|
|
8
|
+
weekDaysContainer: {
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
marginVertical: 12,
|
|
11
|
+
},
|
|
12
|
+
weekDayText: {
|
|
13
|
+
flex: 1,
|
|
14
|
+
textAlign: 'center',
|
|
15
|
+
fontWeight: '500',
|
|
16
|
+
},
|
|
17
|
+
weekDayTitleCell: {
|
|
18
|
+
flex: 1,
|
|
19
|
+
},
|
|
20
|
+
daysContainer: {
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
flexWrap: 'wrap',
|
|
23
|
+
},
|
|
24
|
+
weekRowContainer: {
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
},
|
|
27
|
+
dayButton: {
|
|
28
|
+
width: '14.28%',
|
|
29
|
+
height: '14.28%',
|
|
30
|
+
aspectRatio: 1,
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
marginTop: 4,
|
|
34
|
+
},
|
|
35
|
+
weekDayButton: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
aspectRatio: 1,
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
marginTop: 4,
|
|
41
|
+
},
|
|
42
|
+
dayText: {
|
|
43
|
+
fontSize: 14,
|
|
44
|
+
fontWeight: '400',
|
|
45
|
+
},
|
|
46
|
+
today: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
top: 0,
|
|
49
|
+
bottom: 0,
|
|
50
|
+
left: 0,
|
|
51
|
+
right: 0,
|
|
52
|
+
borderRadius: 8,
|
|
53
|
+
borderWidth: 1,
|
|
54
|
+
borderColor: '#FF9999',
|
|
55
|
+
},
|
|
56
|
+
todayText: {},
|
|
57
|
+
otherMonthDay: {
|
|
58
|
+
opacity: 0.5,
|
|
59
|
+
},
|
|
60
|
+
otherMonthDayText: {
|
|
61
|
+
color: '#999',
|
|
62
|
+
},
|
|
63
|
+
outMinMaxRangeText: {
|
|
64
|
+
color: '#999',
|
|
65
|
+
},
|
|
66
|
+
startDate: {
|
|
67
|
+
backgroundColor: '#fe0000',
|
|
68
|
+
borderRadius: 8,
|
|
69
|
+
},
|
|
70
|
+
endDate: {
|
|
71
|
+
backgroundColor: '#fe0000',
|
|
72
|
+
borderRadius: 8,
|
|
73
|
+
},
|
|
74
|
+
inRange: {
|
|
75
|
+
backgroundColor: '#FFE5E5',
|
|
76
|
+
},
|
|
77
|
+
startEndRange: {
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
top: 0,
|
|
80
|
+
bottom: 0,
|
|
81
|
+
width: '50%',
|
|
82
|
+
},
|
|
83
|
+
inRangeStartWeek: {
|
|
84
|
+
borderTopLeftRadius: 8,
|
|
85
|
+
borderBottomLeftRadius: 8,
|
|
86
|
+
},
|
|
87
|
+
inRangeEndWeek: {
|
|
88
|
+
borderTopRightRadius: 8,
|
|
89
|
+
borderBottomRightRadius: 8,
|
|
90
|
+
},
|
|
91
|
+
selectedDayText: {
|
|
92
|
+
color: '#fff',
|
|
93
|
+
fontWeight: 'bold',
|
|
94
|
+
},
|
|
95
|
+
inRangeText: {},
|
|
96
|
+
markerDot: {
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
bottom: 4,
|
|
99
|
+
width: 4,
|
|
100
|
+
height: 4,
|
|
101
|
+
borderRadius: 2,
|
|
102
|
+
backgroundColor: '#fe0000',
|
|
103
|
+
},
|
|
104
|
+
monthContainer: {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
top: 0,
|
|
107
|
+
bottom: 0,
|
|
108
|
+
left: 0,
|
|
109
|
+
right: 0,
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
flexWrap: 'wrap',
|
|
112
|
+
backgroundColor: '#fff',
|
|
113
|
+
},
|
|
114
|
+
monthItem: {
|
|
115
|
+
width: '33.33%',
|
|
116
|
+
height: '25%',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
justifyContent: 'center',
|
|
119
|
+
},
|
|
120
|
+
yearScrollContainer: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
maxHeight: '90%',
|
|
123
|
+
},
|
|
124
|
+
yearScrollContent: {
|
|
125
|
+
flexDirection: 'row',
|
|
126
|
+
flexWrap: 'wrap',
|
|
127
|
+
paddingBottom: 10,
|
|
128
|
+
},
|
|
129
|
+
yearItem: {
|
|
130
|
+
width: '33.33%',
|
|
131
|
+
height: 75,
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
},
|
|
135
|
+
monthText: {
|
|
136
|
+
fontFamily: 'Roboto',
|
|
137
|
+
fontSize: 14,
|
|
138
|
+
},
|
|
139
|
+
hidden: {
|
|
140
|
+
opacity: 0,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type TCalendarPeriodValue = { startPeriod: Date; endPeriod: Date };
|
|
4
|
+
|
|
5
|
+
export type TCalendarValue = null | Date | TCalendarPeriodValue;
|
|
6
|
+
|
|
7
|
+
export type TCalendarSelectType = 'month' | 'year' | undefined;
|
|
8
|
+
|
|
9
|
+
export type TCalendarActivePeriod = 'month' | 'week';
|
|
10
|
+
|
|
11
|
+
export type TCalendarMarkedDate = boolean | { dotColor?: string };
|
|
12
|
+
|
|
13
|
+
export type TCalendarMarkedDates = Record<string, TCalendarMarkedDate>;
|
|
14
|
+
|
|
15
|
+
/** @deprecated Use TCalendarMarkedDate */
|
|
16
|
+
export type TMarkedDate = TCalendarMarkedDate;
|
|
17
|
+
|
|
18
|
+
/** @deprecated Use TCalendarMarkedDates */
|
|
19
|
+
export type TMarkedDates = TCalendarMarkedDates;
|
|
20
|
+
|
|
21
|
+
export type TCalendarDayItem = {
|
|
22
|
+
day: number;
|
|
23
|
+
month: number;
|
|
24
|
+
year: number;
|
|
25
|
+
date: Date;
|
|
26
|
+
isCurrentMonth: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type TCalendarDayRenderState = {
|
|
30
|
+
isToday: boolean;
|
|
31
|
+
isStart: boolean;
|
|
32
|
+
isEnd: boolean;
|
|
33
|
+
isInRange: boolean;
|
|
34
|
+
isOutMinMax: boolean;
|
|
35
|
+
isStartWeekDay: boolean;
|
|
36
|
+
isEndWeekDay: boolean;
|
|
37
|
+
hasMarker: boolean;
|
|
38
|
+
markerColor?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type TCalendarDayRenderProps = {
|
|
42
|
+
item: TCalendarDayItem;
|
|
43
|
+
state: TCalendarDayRenderState;
|
|
44
|
+
onPress: () => void;
|
|
45
|
+
dayName: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type TCalendarDayRender = (props: TCalendarDayRenderProps) => ReactNode;
|
|
49
|
+
|
|
50
|
+
export type TCalendarDayTitleRender = (props: { dayName: string; index: number }) => ReactNode;
|
|
51
|
+
|
|
52
|
+
export interface ICalendarProps {
|
|
53
|
+
type: 'day' | 'period';
|
|
54
|
+
startWeekDay?: 'monday' | 'sunday';
|
|
55
|
+
minDate?: Date;
|
|
56
|
+
maxDate?: Date;
|
|
57
|
+
monthNames?: string[];
|
|
58
|
+
daysNames?: string[];
|
|
59
|
+
value?: TCalendarValue;
|
|
60
|
+
onChange?: (value: TCalendarValue) => void;
|
|
61
|
+
defaultViewDate?: Date;
|
|
62
|
+
swipeable?: boolean;
|
|
63
|
+
markedDates?: TCalendarMarkedDates;
|
|
64
|
+
renderDayItem?: TCalendarDayRender;
|
|
65
|
+
renderDayTitleItem?: TCalendarDayTitleRender;
|
|
66
|
+
children?: ReactNode | (() => ReactNode);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ICalendarViewProps {
|
|
70
|
+
swipeable?: boolean;
|
|
71
|
+
renderDayItem?: TCalendarDayRender;
|
|
72
|
+
renderDayTitleItem?: TCalendarDayTitleRender;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ICalendarMonthViewProps extends ICalendarViewProps {
|
|
76
|
+
showWeekDays?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ICalendarWeekViewProps extends ICalendarViewProps {}
|
|
80
|
+
|
|
81
|
+
export interface ICalendarContext {
|
|
82
|
+
type: 'day' | 'period';
|
|
83
|
+
value: TCalendarValue | undefined;
|
|
84
|
+
today: Date;
|
|
85
|
+
minDate?: Date;
|
|
86
|
+
maxDate?: Date;
|
|
87
|
+
currentMonth: number;
|
|
88
|
+
currentYear: number;
|
|
89
|
+
currentWeekStart: Date;
|
|
90
|
+
selectType: TCalendarSelectType;
|
|
91
|
+
selectedStartDate: Date | null;
|
|
92
|
+
selectedEndDate: Date | null;
|
|
93
|
+
firstDayOfWeek: number;
|
|
94
|
+
monthNames: string[];
|
|
95
|
+
weekDays: string[];
|
|
96
|
+
activePeriod: TCalendarActivePeriod;
|
|
97
|
+
swipeable: boolean;
|
|
98
|
+
markedDates?: TCalendarMarkedDates;
|
|
99
|
+
renderDayItem?: TCalendarDayRender;
|
|
100
|
+
renderDayTitleItem?: TCalendarDayTitleRender;
|
|
101
|
+
|
|
102
|
+
handleDateSelect: (year: number, month: number, day: number) => void;
|
|
103
|
+
handlePrevPeriod: (period?: TCalendarActivePeriod) => void;
|
|
104
|
+
handleNextPeriod: (period?: TCalendarActivePeriod) => void;
|
|
105
|
+
handleToday: () => void;
|
|
106
|
+
setViewDate: (date: Date) => void;
|
|
107
|
+
setActivePeriod: (period: TCalendarActivePeriod) => void;
|
|
108
|
+
onMonthSelect: () => void;
|
|
109
|
+
onYearSelect: () => void;
|
|
110
|
+
setCurrentMonth: (month: number) => void;
|
|
111
|
+
setCurrentYear: (year: number) => void;
|
|
112
|
+
setSelectType: (type: TCalendarSelectType) => void;
|
|
113
|
+
|
|
114
|
+
isToday: (year: number, month: number, day: number) => boolean;
|
|
115
|
+
isInRange: (year: number, month: number, day: number) => boolean;
|
|
116
|
+
isOutMinMax: (year: number, month: number, day: number) => boolean;
|
|
117
|
+
isStartDate: (year: number, month: number, day: number) => boolean;
|
|
118
|
+
isEndDate: (year: number, month: number, day: number) => boolean;
|
|
119
|
+
isStartWeekDay: (year: number, month: number, day: number) => boolean;
|
|
120
|
+
isEndWeekDay: (year: number, month: number, day: number) => boolean;
|
|
121
|
+
formatDate: (date: Date) => string;
|
|
122
|
+
getDayName: (date: Date) => string;
|
|
123
|
+
getDayRenderState: (item: TCalendarDayItem) => TCalendarDayRenderState;
|
|
124
|
+
generateCalendarDays: TCalendarDayItem[];
|
|
125
|
+
generateWeekDays: TCalendarDayItem[];
|
|
126
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { TCalendarDayItem, TCalendarPeriodValue, TCalendarValue } from './calendar.types';
|
|
2
|
+
|
|
3
|
+
export const getDaysInMonth = (year: number, month: number) => new Date(year, month + 1, 0).getDate();
|
|
4
|
+
|
|
5
|
+
export const getFirstDayOfMonth = (year: number, month: number) => new Date(year, month, 1).getDay();
|
|
6
|
+
|
|
7
|
+
export const formatDate = (date: Date) => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
|
|
8
|
+
|
|
9
|
+
export const addDays = (date: Date, days: number) => {
|
|
10
|
+
const result = new Date(date);
|
|
11
|
+
result.setDate(result.getDate() + days);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const getWeekStart = (date: Date, firstDayOfWeek: number) => {
|
|
16
|
+
const result = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
17
|
+
const day = result.getDay();
|
|
18
|
+
const diff = firstDayOfWeek === 1 ? (day === 0 ? -6 : 1 - day) : -day;
|
|
19
|
+
result.setDate(result.getDate() + diff);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const resolveInitialDate = (
|
|
24
|
+
type: 'day' | 'period',
|
|
25
|
+
value: TCalendarValue | undefined,
|
|
26
|
+
fallback: Date,
|
|
27
|
+
) => {
|
|
28
|
+
if (type === 'day' && value instanceof Date) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (type === 'period' && value && typeof value === 'object' && !(value instanceof Date)) {
|
|
33
|
+
const period = value as TCalendarPeriodValue;
|
|
34
|
+
if (period.startPeriod instanceof Date) {
|
|
35
|
+
return period.startPeriod;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return fallback;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const generateCalendarDays = (
|
|
43
|
+
currentYear: number,
|
|
44
|
+
currentMonth: number,
|
|
45
|
+
firstDayOfWeek: number,
|
|
46
|
+
): TCalendarDayItem[] => {
|
|
47
|
+
const days: TCalendarDayItem[] = [];
|
|
48
|
+
const daysInMonth = getDaysInMonth(currentYear, currentMonth);
|
|
49
|
+
let firstDayOfMonth = getFirstDayOfMonth(currentYear, currentMonth);
|
|
50
|
+
|
|
51
|
+
if (firstDayOfWeek === 1) {
|
|
52
|
+
firstDayOfMonth = firstDayOfMonth === 0 ? 6 : firstDayOfMonth - 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const prevMonth = currentMonth === 0 ? 11 : currentMonth - 1;
|
|
56
|
+
const prevYear = currentMonth === 0 ? currentYear - 1 : currentYear;
|
|
57
|
+
const daysInPrevMonth = getDaysInMonth(prevYear, prevMonth);
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < firstDayOfMonth; i++) {
|
|
60
|
+
const day = daysInPrevMonth - firstDayOfMonth + i + 1;
|
|
61
|
+
days.push({
|
|
62
|
+
day,
|
|
63
|
+
month: prevMonth,
|
|
64
|
+
year: prevYear,
|
|
65
|
+
date: new Date(prevYear, prevMonth, day),
|
|
66
|
+
isCurrentMonth: false,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (let i = 1; i <= daysInMonth; i++) {
|
|
71
|
+
days.push({
|
|
72
|
+
day: i,
|
|
73
|
+
month: currentMonth,
|
|
74
|
+
year: currentYear,
|
|
75
|
+
date: new Date(currentYear, currentMonth, i),
|
|
76
|
+
isCurrentMonth: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const totalDaysDisplayed = Math.ceil((firstDayOfMonth + daysInMonth) / 7) * 7;
|
|
81
|
+
const daysFromNextMonth = totalDaysDisplayed - days.length;
|
|
82
|
+
const nextMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
|
83
|
+
const nextYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
|
84
|
+
|
|
85
|
+
for (let i = 1; i <= daysFromNextMonth; i++) {
|
|
86
|
+
days.push({
|
|
87
|
+
day: i,
|
|
88
|
+
month: nextMonth,
|
|
89
|
+
year: nextYear,
|
|
90
|
+
date: new Date(nextYear, nextMonth, i),
|
|
91
|
+
isCurrentMonth: false,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return days;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const generateWeekDays = (
|
|
99
|
+
currentWeekStart: Date,
|
|
100
|
+
currentMonth: number,
|
|
101
|
+
currentYear: number,
|
|
102
|
+
): TCalendarDayItem[] => {
|
|
103
|
+
return Array.from({ length: 7 }, (_, index) => {
|
|
104
|
+
const date = addDays(currentWeekStart, index);
|
|
105
|
+
return {
|
|
106
|
+
day: date.getDate(),
|
|
107
|
+
month: date.getMonth(),
|
|
108
|
+
year: date.getFullYear(),
|
|
109
|
+
date,
|
|
110
|
+
isCurrentMonth: date.getMonth() === currentMonth && date.getFullYear() === currentYear,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const DEFAULT_MONTH_NAMES = [
|
|
116
|
+
'January',
|
|
117
|
+
'February',
|
|
118
|
+
'March',
|
|
119
|
+
'April',
|
|
120
|
+
'May',
|
|
121
|
+
'June',
|
|
122
|
+
'July',
|
|
123
|
+
'August',
|
|
124
|
+
'September',
|
|
125
|
+
'October',
|
|
126
|
+
'November',
|
|
127
|
+
'December',
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
export const DEFAULT_DAY_NAMES = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
131
|
+
|
|
132
|
+
export const getWeekDayLabels = (daysNames?: string[], firstDayOfWeek: number = 0) => {
|
|
133
|
+
const days = daysNames || DEFAULT_DAY_NAMES;
|
|
134
|
+
if (firstDayOfWeek === 1) {
|
|
135
|
+
return [...days.slice(1), days[0]];
|
|
136
|
+
}
|
|
137
|
+
return days;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const getDayName = (date: Date, daysNames?: string[]) => {
|
|
141
|
+
const days = daysNames || DEFAULT_DAY_NAMES;
|
|
142
|
+
return days[date.getDay()];
|
|
143
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Common from './Common';
|
|
2
|
+
import { useCalendar } from './Context';
|
|
3
|
+
import MonthView from './MonthView';
|
|
4
|
+
import WeekView from './WeekView';
|
|
5
|
+
|
|
6
|
+
type TCommon = typeof Common;
|
|
7
|
+
type TMonthView = typeof MonthView;
|
|
8
|
+
type TWeekView = typeof WeekView;
|
|
9
|
+
type TUseCalendar = typeof useCalendar;
|
|
10
|
+
|
|
11
|
+
interface ICalendar extends TCommon {
|
|
12
|
+
MonthView: TMonthView;
|
|
13
|
+
WeekView: TWeekView;
|
|
14
|
+
useCalendar: TUseCalendar;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Calendar = Common as ICalendar;
|
|
18
|
+
Calendar.MonthView = MonthView;
|
|
19
|
+
Calendar.WeekView = WeekView;
|
|
20
|
+
Calendar.useCalendar = useCalendar;
|
|
21
|
+
|
|
22
|
+
export type {
|
|
23
|
+
ICalendarContext,
|
|
24
|
+
ICalendarMonthViewProps,
|
|
25
|
+
ICalendarProps,
|
|
26
|
+
ICalendarWeekViewProps,
|
|
27
|
+
TCalendarActivePeriod,
|
|
28
|
+
TCalendarDayItem,
|
|
29
|
+
TCalendarDayRender,
|
|
30
|
+
TCalendarDayRenderProps,
|
|
31
|
+
TCalendarDayRenderState,
|
|
32
|
+
TCalendarDayTitleRender,
|
|
33
|
+
TCalendarMarkedDate,
|
|
34
|
+
TCalendarMarkedDates,
|
|
35
|
+
TCalendarPeriodValue,
|
|
36
|
+
TCalendarSelectType,
|
|
37
|
+
TCalendarValue,
|
|
38
|
+
} from './calendar.types';
|
|
39
|
+
|
|
40
|
+
export default Calendar;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"id": "component:Calendar",
|
|
3
|
+
"type": "component",
|
|
4
|
+
"platforms": [
|
|
5
|
+
"react-native"
|
|
6
|
+
],
|
|
7
|
+
"title": "Calendar",
|
|
8
|
+
"description": "Calendar from the previous template kit. Treat the API as experimental until it is wired into a screen.",
|
|
9
|
+
"status": "experimental",
|
|
10
|
+
"since": "1.0.0",
|
|
11
|
+
"tags": [
|
|
12
|
+
"ui",
|
|
13
|
+
"kit"
|
|
14
|
+
],
|
|
15
|
+
"requires": [],
|
|
16
|
+
"dependencies": [],
|
|
17
|
+
"files": [
|
|
18
|
+
{
|
|
19
|
+
"from": "files",
|
|
20
|
+
"to": "ui/components/Calendar"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"register": [
|
|
24
|
+
{
|
|
25
|
+
"file": "ui/components/index.ts",
|
|
26
|
+
"marker": "components-import",
|
|
27
|
+
"code": "import Calendar from './Calendar';\n"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"file": "ui/components/index.ts",
|
|
31
|
+
"marker": "components-export",
|
|
32
|
+
"code": " Calendar,\n"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"manual": [],
|
|
36
|
+
"api": "Default export from ui/components/Calendar.",
|
|
37
|
+
"example": "import Calendar from '@components/Calendar';"
|
|
38
|
+
};
|