create-du-app 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -36
- package/package.json +6 -5
- package/src/generate.js +246 -15
- package/src/index.js +8 -8
- package/src/prompts.js +1 -1
- package/src/registry.js +3 -1
- package/templates/mobile/expo/.env.example +5 -0
- package/templates/mobile/expo/.eslintrc.js +7 -0
- package/templates/mobile/expo/.prettierrc.js +7 -0
- package/templates/mobile/expo/.svgrrc.js +9 -0
- package/templates/mobile/expo/README.md +42 -7
- package/templates/mobile/expo/_gitignore +20 -0
- package/templates/mobile/expo/_package.json +62 -1
- package/templates/mobile/expo/app.json +18 -0
- package/templates/mobile/expo/babel.config.js +21 -0
- package/templates/mobile/expo/index.js +5 -0
- package/templates/mobile/expo/metro.config.js +31 -0
- package/templates/mobile/expo/src/app/App.tsx +24 -0
- package/templates/mobile/expo/src/app/app-provider.tsx +36 -0
- package/templates/mobile/expo/src/app/config/translation.ts +26 -0
- package/templates/mobile/expo/src/app/index.ts +1 -0
- package/templates/mobile/expo/src/app/navigation/app-route-type.ts +27 -0
- package/templates/mobile/expo/src/app/navigation/bottom-tabs.tsx +34 -0
- package/templates/mobile/expo/src/app/navigation/index.tsx +14 -0
- package/templates/mobile/expo/src/app/stores/auth.store.ts +33 -0
- package/templates/mobile/expo/src/app/stores/common.store.ts +19 -0
- package/templates/mobile/expo/src/app/stores/index.ts +3 -0
- package/templates/mobile/expo/src/app/stores/loading.store.ts +22 -0
- package/templates/mobile/expo/src/assets/Images/empty-list.png +0 -0
- package/templates/mobile/expo/src/assets/Images/index.ts +5 -0
- package/templates/mobile/expo/src/assets/Images/screen-bg-gradian.png +0 -0
- package/templates/mobile/expo/src/assets/i18n/en.json +12 -0
- package/templates/mobile/expo/src/assets/i18n/fr.json +12 -0
- package/templates/mobile/expo/src/assets/lotties/index.ts +3 -0
- package/templates/mobile/expo/src/assets/lotties/loading.json +1 -0
- package/templates/mobile/expo/src/assets/svgs/arrow-left.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/arrow-right.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/calendar.svg +12 -0
- package/templates/mobile/expo/src/assets/svgs/check.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/close.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/eye-hide.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/eye.svg +4 -0
- package/templates/mobile/expo/src/assets/svgs/index.ts +29 -0
- package/templates/mobile/expo/src/assets/svgs/minus.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/plus.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/search.svg +3 -0
- package/templates/mobile/expo/src/assets/svgs/toast-error.svg +5 -0
- package/templates/mobile/expo/src/assets/svgs/toast-success.svg +4 -0
- package/templates/mobile/expo/src/core/api/endpoints.ts +8 -0
- package/templates/mobile/expo/src/core/api/example.api.ts +53 -0
- package/templates/mobile/expo/src/core/api/index.ts +4 -0
- package/templates/mobile/expo/src/core/components/common/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/common/list-empty/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/common/list-empty/list-empty.tsx +30 -0
- package/templates/mobile/expo/src/core/components/common/list-empty/list-empty.type.ts +5 -0
- package/templates/mobile/expo/src/core/components/forms/hf-date-time.tsx +301 -0
- package/templates/mobile/expo/src/core/components/forms/hf-password-input.tsx +153 -0
- package/templates/mobile/expo/src/core/components/forms/hf-text-input.tsx +59 -0
- package/templates/mobile/expo/src/core/components/forms/hf-time-picker.tsx +117 -0
- package/templates/mobile/expo/src/core/components/forms/index.ts +4 -0
- package/templates/mobile/expo/src/core/components/index.ts +5 -0
- package/templates/mobile/expo/src/core/components/loading/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/loading/loading-app/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/loading/loading-app/loading-app.tsx +50 -0
- package/templates/mobile/expo/src/core/components/offline/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/offline/offline-banner.tsx +186 -0
- package/templates/mobile/expo/src/core/components/screen/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/screen/screen-container/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/screen/screen-container/screen-container.tsx +252 -0
- package/templates/mobile/expo/src/core/components/splash/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/splash/splash-overlay/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/splash/splash-overlay/splash-overlay.tsx +93 -0
- package/templates/mobile/expo/src/core/components/ui/animated-list-item/animated-list-item.tsx +48 -0
- package/templates/mobile/expo/src/core/components/ui/animated-list-item/animated-list-item.type.ts +10 -0
- package/templates/mobile/expo/src/core/components/ui/animated-list-item/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/app-image/app-image.tsx +104 -0
- package/templates/mobile/expo/src/core/components/ui/app-image/app-image.type.ts +19 -0
- package/templates/mobile/expo/src/core/components/ui/app-image/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/asset-placeholder/asset-placeholder.tsx +76 -0
- package/templates/mobile/expo/src/core/components/ui/asset-placeholder/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/ui/avatar-image/avatar-image.tsx +90 -0
- package/templates/mobile/expo/src/core/components/ui/avatar-image/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/ui/bottom-sheet/bottom-sheet.tsx +145 -0
- package/templates/mobile/expo/src/core/components/ui/bottom-sheet/bottom-sheet.type.ts +10 -0
- package/templates/mobile/expo/src/core/components/ui/bottom-sheet/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/button/button.style.ts +146 -0
- package/templates/mobile/expo/src/core/components/ui/button/button.tsx +97 -0
- package/templates/mobile/expo/src/core/components/ui/button/button.type.ts +47 -0
- package/templates/mobile/expo/src/core/components/ui/button/index.ts +4 -0
- package/templates/mobile/expo/src/core/components/ui/checkbox/checkbox.tsx +127 -0
- package/templates/mobile/expo/src/core/components/ui/checkbox/checkbox.type.ts +24 -0
- package/templates/mobile/expo/src/core/components/ui/checkbox/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/collapsible-section/collapsible-section.tsx +141 -0
- package/templates/mobile/expo/src/core/components/ui/collapsible-section/collapsible-section.type.ts +10 -0
- package/templates/mobile/expo/src/core/components/ui/collapsible-section/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/components.registry.json +313 -0
- package/templates/mobile/expo/src/core/components/ui/field/field-frame.tsx +62 -0
- package/templates/mobile/expo/src/core/components/ui/field/field.shared.ts +31 -0
- package/templates/mobile/expo/src/core/components/ui/header/header.tsx +196 -0
- package/templates/mobile/expo/src/core/components/ui/header/header.type.ts +30 -0
- package/templates/mobile/expo/src/core/components/ui/header/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/icon-button/icon-button.style.ts +23 -0
- package/templates/mobile/expo/src/core/components/ui/icon-button/icon-button.tsx +66 -0
- package/templates/mobile/expo/src/core/components/ui/icon-button/icon-button.type.ts +25 -0
- package/templates/mobile/expo/src/core/components/ui/icon-button/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/image-slider/image-slider.tsx +107 -0
- package/templates/mobile/expo/src/core/components/ui/image-slider/image-slider.type.ts +10 -0
- package/templates/mobile/expo/src/core/components/ui/image-slider/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/index.ts +25 -0
- package/templates/mobile/expo/src/core/components/ui/label/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/label/label.tsx +36 -0
- package/templates/mobile/expo/src/core/components/ui/label/label.type.ts +12 -0
- package/templates/mobile/expo/src/core/components/ui/modal/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/modal/modal.tsx +62 -0
- package/templates/mobile/expo/src/core/components/ui/modal/modal.type.ts +11 -0
- package/templates/mobile/expo/src/core/components/ui/otp-input/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/otp-input/otp-input.tsx +129 -0
- package/templates/mobile/expo/src/core/components/ui/otp-input/otp-input.type.ts +20 -0
- package/templates/mobile/expo/src/core/components/ui/page-dots/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/ui/page-dots/page-dots.tsx +60 -0
- package/templates/mobile/expo/src/core/components/ui/radio/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/radio/radio.tsx +121 -0
- package/templates/mobile/expo/src/core/components/ui/radio/radio.type.ts +20 -0
- package/templates/mobile/expo/src/core/components/ui/screen/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/ui/screen/screen-gradient.tsx +33 -0
- package/templates/mobile/expo/src/core/components/ui/search-box/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/search-box/search-box.tsx +162 -0
- package/templates/mobile/expo/src/core/components/ui/search-box/search-box.type.ts +26 -0
- package/templates/mobile/expo/src/core/components/ui/segmented-control/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/segmented-control/segmented-control.tsx +86 -0
- package/templates/mobile/expo/src/core/components/ui/segmented-control/segmented-control.type.ts +22 -0
- package/templates/mobile/expo/src/core/components/ui/skeleton/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/skeleton/skeleton.tsx +106 -0
- package/templates/mobile/expo/src/core/components/ui/skeleton/skeleton.type.ts +8 -0
- package/templates/mobile/expo/src/core/components/ui/success-state/index.ts +1 -0
- package/templates/mobile/expo/src/core/components/ui/success-state/success-state.tsx +68 -0
- package/templates/mobile/expo/src/core/components/ui/tabs/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/tabs/tabs.tsx +273 -0
- package/templates/mobile/expo/src/core/components/ui/tabs/tabs.type.ts +21 -0
- package/templates/mobile/expo/src/core/components/ui/tag-input/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/tag-input/tag-input.tsx +146 -0
- package/templates/mobile/expo/src/core/components/ui/tag-input/tag-input.type.ts +22 -0
- package/templates/mobile/expo/src/core/components/ui/text-area/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/text-area/text-area.tsx +90 -0
- package/templates/mobile/expo/src/core/components/ui/text-area/text-area.type.ts +20 -0
- package/templates/mobile/expo/src/core/components/ui/text-field/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/text-field/text-field.tsx +116 -0
- package/templates/mobile/expo/src/core/components/ui/text-field/text-field.type.ts +21 -0
- package/templates/mobile/expo/src/core/components/ui/toggle/index.ts +2 -0
- package/templates/mobile/expo/src/core/components/ui/toggle/toggle.tsx +110 -0
- package/templates/mobile/expo/src/core/components/ui/toggle/toggle.type.ts +19 -0
- package/templates/mobile/expo/src/core/constants/external-urls.constant.ts +5 -0
- package/templates/mobile/expo/src/core/constants/hard-data.constant.ts +0 -0
- package/templates/mobile/expo/src/core/constants/index.ts +2 -0
- package/templates/mobile/expo/src/core/constants/type.constant.ts +3 -0
- package/templates/mobile/expo/src/core/context/index.ts +1 -0
- package/templates/mobile/expo/src/core/context/shared-transition-context.tsx +35 -0
- package/templates/mobile/expo/src/core/hook/index.ts +8 -0
- package/templates/mobile/expo/src/core/hook/useActiveRouteName.ts +63 -0
- package/templates/mobile/expo/src/core/hook/useAppNavigation.tsx +7 -0
- package/templates/mobile/expo/src/core/hook/useBottomInset.tsx +26 -0
- package/templates/mobile/expo/src/core/hook/useDebounce.tsx +16 -0
- package/templates/mobile/expo/src/core/hook/useEndReached.tsx +46 -0
- package/templates/mobile/expo/src/core/hook/useManualRefetch.ts +56 -0
- package/templates/mobile/expo/src/core/hook/useNetworkStatus.ts +68 -0
- package/templates/mobile/expo/src/core/hook/useTimeout.tsx +30 -0
- package/templates/mobile/expo/src/core/index.ts +7 -0
- package/templates/mobile/expo/src/core/services/api.service.ts +230 -0
- package/templates/mobile/expo/src/core/services/device-id.service.ts +23 -0
- package/templates/mobile/expo/src/core/services/index.ts +3 -0
- package/templates/mobile/expo/src/core/services/session-end.bridge.ts +26 -0
- package/templates/mobile/expo/src/core/theme/dark.theme.ts +10 -0
- package/templates/mobile/expo/src/core/theme/index.ts +5 -0
- package/templates/mobile/expo/src/core/theme/light.theme.ts +44 -0
- package/templates/mobile/expo/src/core/theme/theme-context.tsx +82 -0
- package/templates/mobile/expo/src/core/theme/theme.types.ts +26 -0
- package/templates/mobile/expo/src/core/theme/use-themed-styles.ts +25 -0
- package/templates/mobile/expo/src/core/utils/color.util.tsx +198 -0
- package/templates/mobile/expo/src/core/utils/date.util.ts +97 -0
- package/templates/mobile/expo/src/core/utils/device-locale.util.ts +22 -0
- package/templates/mobile/expo/src/core/utils/emitter/index.ts +161 -0
- package/templates/mobile/expo/src/core/utils/emitter/type.ts +40 -0
- package/templates/mobile/expo/src/core/utils/enum.util.tsx +15 -0
- package/templates/mobile/expo/src/core/utils/font.util.tsx +42 -0
- package/templates/mobile/expo/src/core/utils/func.util.ts +48 -0
- package/templates/mobile/expo/src/core/utils/greeting.util.ts +20 -0
- package/templates/mobile/expo/src/core/utils/image-format.util.ts +117 -0
- package/templates/mobile/expo/src/core/utils/image-picker.util.ts +84 -0
- package/templates/mobile/expo/src/core/utils/index.ts +18 -0
- package/templates/mobile/expo/src/core/utils/linking.util.ts +16 -0
- package/templates/mobile/expo/src/core/utils/navigation.util.tsx +100 -0
- package/templates/mobile/expo/src/core/utils/number-format.ts +28 -0
- package/templates/mobile/expo/src/core/utils/query-client.util.ts +35 -0
- package/templates/mobile/expo/src/core/utils/query-persister.util.ts +36 -0
- package/templates/mobile/expo/src/core/utils/schema.util.tsx +2713 -0
- package/templates/mobile/expo/src/core/utils/size.util.tsx +74 -0
- package/templates/mobile/expo/src/core/utils/storage.util.tsx +53 -0
- package/templates/mobile/expo/src/core/utils/toast.util.tsx +151 -0
- package/templates/mobile/expo/src/core/utils/translator.util.tsx +23 -0
- package/templates/mobile/expo/src/core/utils/typography.util.tsx +69 -0
- package/templates/mobile/expo/src/core/utils/validate.util.tsx +13 -0
- package/templates/mobile/expo/src/declarations.d.ts +54 -0
- package/templates/mobile/expo/src/modules/home/home.screen.tsx +33 -0
- package/templates/mobile/expo/src/modules/profile/profile.screen.tsx +29 -0
- package/templates/mobile/expo/src/scripts/link-fonts.js +60 -0
- package/templates/mobile/expo/src/scripts/sync-images.js +56 -0
- package/templates/mobile/expo/src/scripts/sync-svgs.js +50 -0
- package/templates/mobile/expo/src/types/models.d.ts +24 -0
- package/templates/mobile/expo/tsconfig.json +19 -0
- package/templates/mobile/rn/.env.example +5 -0
- package/templates/mobile/rn/.eslintrc.js +7 -0
- package/templates/mobile/rn/.prettierrc.js +7 -0
- package/templates/mobile/rn/.svgrrc.js +9 -0
- package/templates/mobile/rn/README.md +40 -7
- package/templates/mobile/rn/_gitignore +24 -0
- package/templates/mobile/rn/_package.json +67 -1
- package/templates/mobile/rn/app.json +4 -0
- package/templates/mobile/rn/babel.config.js +18 -0
- package/templates/mobile/rn/index.js +8 -0
- package/templates/mobile/rn/metro.config.js +33 -0
- package/templates/mobile/rn/src/app/App.tsx +24 -0
- package/templates/mobile/rn/src/app/app-provider.tsx +36 -0
- package/templates/mobile/rn/src/app/config/translation.ts +26 -0
- package/templates/mobile/rn/src/app/index.ts +1 -0
- package/templates/mobile/rn/src/app/navigation/app-route-type.ts +27 -0
- package/templates/mobile/rn/src/app/navigation/bottom-tabs.tsx +34 -0
- package/templates/mobile/rn/src/app/navigation/index.tsx +14 -0
- package/templates/mobile/rn/src/app/stores/auth.store.ts +33 -0
- package/templates/mobile/rn/src/app/stores/common.store.ts +19 -0
- package/templates/mobile/rn/src/app/stores/index.ts +3 -0
- package/templates/mobile/rn/src/app/stores/loading.store.ts +22 -0
- package/templates/mobile/rn/src/assets/Images/empty-list.png +0 -0
- package/templates/mobile/rn/src/assets/Images/index.ts +5 -0
- package/templates/mobile/rn/src/assets/Images/screen-bg-gradian.png +0 -0
- package/templates/mobile/rn/src/assets/i18n/en.json +12 -0
- package/templates/mobile/rn/src/assets/i18n/fr.json +12 -0
- package/templates/mobile/rn/src/assets/lotties/index.ts +3 -0
- package/templates/mobile/rn/src/assets/lotties/loading.json +1 -0
- package/templates/mobile/rn/src/assets/svgs/arrow-left.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/arrow-right.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/calendar.svg +12 -0
- package/templates/mobile/rn/src/assets/svgs/check.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/close.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/eye-hide.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/eye.svg +4 -0
- package/templates/mobile/rn/src/assets/svgs/index.ts +29 -0
- package/templates/mobile/rn/src/assets/svgs/minus.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/plus.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/search.svg +3 -0
- package/templates/mobile/rn/src/assets/svgs/toast-error.svg +5 -0
- package/templates/mobile/rn/src/assets/svgs/toast-success.svg +4 -0
- package/templates/mobile/rn/src/core/api/endpoints.ts +8 -0
- package/templates/mobile/rn/src/core/api/example.api.ts +53 -0
- package/templates/mobile/rn/src/core/api/index.ts +4 -0
- package/templates/mobile/rn/src/core/components/common/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/common/list-empty/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/common/list-empty/list-empty.tsx +30 -0
- package/templates/mobile/rn/src/core/components/common/list-empty/list-empty.type.ts +5 -0
- package/templates/mobile/rn/src/core/components/forms/hf-date-time.tsx +301 -0
- package/templates/mobile/rn/src/core/components/forms/hf-password-input.tsx +153 -0
- package/templates/mobile/rn/src/core/components/forms/hf-text-input.tsx +59 -0
- package/templates/mobile/rn/src/core/components/forms/hf-time-picker.tsx +117 -0
- package/templates/mobile/rn/src/core/components/forms/index.ts +4 -0
- package/templates/mobile/rn/src/core/components/index.ts +5 -0
- package/templates/mobile/rn/src/core/components/loading/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/loading/loading-app/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/loading/loading-app/loading-app.tsx +50 -0
- package/templates/mobile/rn/src/core/components/offline/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/offline/offline-banner.tsx +186 -0
- package/templates/mobile/rn/src/core/components/screen/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/screen/screen-container/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/screen/screen-container/screen-container.tsx +252 -0
- package/templates/mobile/rn/src/core/components/splash/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/splash/splash-overlay/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/splash/splash-overlay/splash-overlay.tsx +93 -0
- package/templates/mobile/rn/src/core/components/ui/animated-list-item/animated-list-item.tsx +48 -0
- package/templates/mobile/rn/src/core/components/ui/animated-list-item/animated-list-item.type.ts +10 -0
- package/templates/mobile/rn/src/core/components/ui/animated-list-item/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/app-image/app-image.tsx +104 -0
- package/templates/mobile/rn/src/core/components/ui/app-image/app-image.type.ts +19 -0
- package/templates/mobile/rn/src/core/components/ui/app-image/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/asset-placeholder/asset-placeholder.tsx +76 -0
- package/templates/mobile/rn/src/core/components/ui/asset-placeholder/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/ui/avatar-image/avatar-image.tsx +90 -0
- package/templates/mobile/rn/src/core/components/ui/avatar-image/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/ui/bottom-sheet/bottom-sheet.tsx +145 -0
- package/templates/mobile/rn/src/core/components/ui/bottom-sheet/bottom-sheet.type.ts +10 -0
- package/templates/mobile/rn/src/core/components/ui/bottom-sheet/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/button/button.style.ts +146 -0
- package/templates/mobile/rn/src/core/components/ui/button/button.tsx +97 -0
- package/templates/mobile/rn/src/core/components/ui/button/button.type.ts +47 -0
- package/templates/mobile/rn/src/core/components/ui/button/index.ts +4 -0
- package/templates/mobile/rn/src/core/components/ui/checkbox/checkbox.tsx +127 -0
- package/templates/mobile/rn/src/core/components/ui/checkbox/checkbox.type.ts +24 -0
- package/templates/mobile/rn/src/core/components/ui/checkbox/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/collapsible-section/collapsible-section.tsx +141 -0
- package/templates/mobile/rn/src/core/components/ui/collapsible-section/collapsible-section.type.ts +10 -0
- package/templates/mobile/rn/src/core/components/ui/collapsible-section/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/components.registry.json +313 -0
- package/templates/mobile/rn/src/core/components/ui/field/field-frame.tsx +62 -0
- package/templates/mobile/rn/src/core/components/ui/field/field.shared.ts +31 -0
- package/templates/mobile/rn/src/core/components/ui/header/header.tsx +196 -0
- package/templates/mobile/rn/src/core/components/ui/header/header.type.ts +30 -0
- package/templates/mobile/rn/src/core/components/ui/header/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/icon-button/icon-button.style.ts +23 -0
- package/templates/mobile/rn/src/core/components/ui/icon-button/icon-button.tsx +66 -0
- package/templates/mobile/rn/src/core/components/ui/icon-button/icon-button.type.ts +25 -0
- package/templates/mobile/rn/src/core/components/ui/icon-button/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/image-slider/image-slider.tsx +107 -0
- package/templates/mobile/rn/src/core/components/ui/image-slider/image-slider.type.ts +10 -0
- package/templates/mobile/rn/src/core/components/ui/image-slider/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/index.ts +25 -0
- package/templates/mobile/rn/src/core/components/ui/label/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/label/label.tsx +36 -0
- package/templates/mobile/rn/src/core/components/ui/label/label.type.ts +12 -0
- package/templates/mobile/rn/src/core/components/ui/modal/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/modal/modal.tsx +62 -0
- package/templates/mobile/rn/src/core/components/ui/modal/modal.type.ts +11 -0
- package/templates/mobile/rn/src/core/components/ui/otp-input/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/otp-input/otp-input.tsx +129 -0
- package/templates/mobile/rn/src/core/components/ui/otp-input/otp-input.type.ts +20 -0
- package/templates/mobile/rn/src/core/components/ui/page-dots/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/ui/page-dots/page-dots.tsx +60 -0
- package/templates/mobile/rn/src/core/components/ui/radio/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/radio/radio.tsx +121 -0
- package/templates/mobile/rn/src/core/components/ui/radio/radio.type.ts +20 -0
- package/templates/mobile/rn/src/core/components/ui/screen/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/ui/screen/screen-gradient.tsx +33 -0
- package/templates/mobile/rn/src/core/components/ui/search-box/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/search-box/search-box.tsx +162 -0
- package/templates/mobile/rn/src/core/components/ui/search-box/search-box.type.ts +26 -0
- package/templates/mobile/rn/src/core/components/ui/segmented-control/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/segmented-control/segmented-control.tsx +86 -0
- package/templates/mobile/rn/src/core/components/ui/segmented-control/segmented-control.type.ts +22 -0
- package/templates/mobile/rn/src/core/components/ui/skeleton/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/skeleton/skeleton.tsx +106 -0
- package/templates/mobile/rn/src/core/components/ui/skeleton/skeleton.type.ts +8 -0
- package/templates/mobile/rn/src/core/components/ui/success-state/index.ts +1 -0
- package/templates/mobile/rn/src/core/components/ui/success-state/success-state.tsx +68 -0
- package/templates/mobile/rn/src/core/components/ui/tabs/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/tabs/tabs.tsx +273 -0
- package/templates/mobile/rn/src/core/components/ui/tabs/tabs.type.ts +21 -0
- package/templates/mobile/rn/src/core/components/ui/tag-input/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/tag-input/tag-input.tsx +146 -0
- package/templates/mobile/rn/src/core/components/ui/tag-input/tag-input.type.ts +22 -0
- package/templates/mobile/rn/src/core/components/ui/text-area/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/text-area/text-area.tsx +90 -0
- package/templates/mobile/rn/src/core/components/ui/text-area/text-area.type.ts +20 -0
- package/templates/mobile/rn/src/core/components/ui/text-field/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/text-field/text-field.tsx +116 -0
- package/templates/mobile/rn/src/core/components/ui/text-field/text-field.type.ts +21 -0
- package/templates/mobile/rn/src/core/components/ui/toggle/index.ts +2 -0
- package/templates/mobile/rn/src/core/components/ui/toggle/toggle.tsx +110 -0
- package/templates/mobile/rn/src/core/components/ui/toggle/toggle.type.ts +19 -0
- package/templates/mobile/rn/src/core/constants/external-urls.constant.ts +5 -0
- package/templates/mobile/rn/src/core/constants/hard-data.constant.ts +0 -0
- package/templates/mobile/rn/src/core/constants/index.ts +2 -0
- package/templates/mobile/rn/src/core/constants/type.constant.ts +3 -0
- package/templates/mobile/rn/src/core/context/index.ts +1 -0
- package/templates/mobile/rn/src/core/context/shared-transition-context.tsx +35 -0
- package/templates/mobile/rn/src/core/hook/index.ts +8 -0
- package/templates/mobile/rn/src/core/hook/useActiveRouteName.ts +63 -0
- package/templates/mobile/rn/src/core/hook/useAppNavigation.tsx +7 -0
- package/templates/mobile/rn/src/core/hook/useBottomInset.tsx +26 -0
- package/templates/mobile/rn/src/core/hook/useDebounce.tsx +16 -0
- package/templates/mobile/rn/src/core/hook/useEndReached.tsx +46 -0
- package/templates/mobile/rn/src/core/hook/useManualRefetch.ts +56 -0
- package/templates/mobile/rn/src/core/hook/useNetworkStatus.ts +68 -0
- package/templates/mobile/rn/src/core/hook/useTimeout.tsx +30 -0
- package/templates/mobile/rn/src/core/index.ts +7 -0
- package/templates/mobile/rn/src/core/services/api.service.ts +230 -0
- package/templates/mobile/rn/src/core/services/device-id.service.ts +23 -0
- package/templates/mobile/rn/src/core/services/index.ts +3 -0
- package/templates/mobile/rn/src/core/services/session-end.bridge.ts +26 -0
- package/templates/mobile/rn/src/core/theme/dark.theme.ts +10 -0
- package/templates/mobile/rn/src/core/theme/index.ts +5 -0
- package/templates/mobile/rn/src/core/theme/light.theme.ts +44 -0
- package/templates/mobile/rn/src/core/theme/theme-context.tsx +82 -0
- package/templates/mobile/rn/src/core/theme/theme.types.ts +26 -0
- package/templates/mobile/rn/src/core/theme/use-themed-styles.ts +25 -0
- package/templates/mobile/rn/src/core/utils/color.util.tsx +198 -0
- package/templates/mobile/rn/src/core/utils/date.util.ts +97 -0
- package/templates/mobile/rn/src/core/utils/device-locale.util.ts +22 -0
- package/templates/mobile/rn/src/core/utils/emitter/index.ts +161 -0
- package/templates/mobile/rn/src/core/utils/emitter/type.ts +40 -0
- package/templates/mobile/rn/src/core/utils/enum.util.tsx +15 -0
- package/templates/mobile/rn/src/core/utils/font.util.tsx +42 -0
- package/templates/mobile/rn/src/core/utils/func.util.ts +48 -0
- package/templates/mobile/rn/src/core/utils/greeting.util.ts +20 -0
- package/templates/mobile/rn/src/core/utils/image-format.util.ts +117 -0
- package/templates/mobile/rn/src/core/utils/image-picker.util.ts +84 -0
- package/templates/mobile/rn/src/core/utils/index.ts +18 -0
- package/templates/mobile/rn/src/core/utils/linking.util.ts +16 -0
- package/templates/mobile/rn/src/core/utils/navigation.util.tsx +100 -0
- package/templates/mobile/rn/src/core/utils/number-format.ts +28 -0
- package/templates/mobile/rn/src/core/utils/query-client.util.ts +35 -0
- package/templates/mobile/rn/src/core/utils/query-persister.util.ts +36 -0
- package/templates/mobile/rn/src/core/utils/schema.util.tsx +2713 -0
- package/templates/mobile/rn/src/core/utils/size.util.tsx +74 -0
- package/templates/mobile/rn/src/core/utils/storage.util.tsx +53 -0
- package/templates/mobile/rn/src/core/utils/toast.util.tsx +151 -0
- package/templates/mobile/rn/src/core/utils/translator.util.tsx +23 -0
- package/templates/mobile/rn/src/core/utils/typography.util.tsx +69 -0
- package/templates/mobile/rn/src/core/utils/validate.util.tsx +13 -0
- package/templates/mobile/rn/src/declarations.d.ts +54 -0
- package/templates/mobile/rn/src/modules/home/home.screen.tsx +33 -0
- package/templates/mobile/rn/src/modules/profile/profile.screen.tsx +29 -0
- package/templates/mobile/rn/src/scripts/link-fonts.js +60 -0
- package/templates/mobile/rn/src/scripts/sync-images.js +56 -0
- package/templates/mobile/rn/src/scripts/sync-svgs.js +50 -0
- package/templates/mobile/rn/src/types/models.d.ts +24 -0
- package/templates/mobile/rn/tsconfig.json +21 -0
- package/templates/shared/README.md +21 -6
- package/templates/shared/_package.json +26 -4
- package/templates/shared/src/api-endpoints.ts +8 -0
- package/templates/shared/src/enums.ts +34 -0
- package/templates/shared/src/external-urls.ts +5 -0
- package/templates/shared/src/index.ts +15 -0
- package/templates/shared/tsconfig.json +8 -0
- package/templates/shared/tsup.config.ts +9 -0
- package/templates/shared/index.js +0 -4
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { Font, fontSize, Radius, Spacing, Stroke } from '@src/core/utils';
|
|
2
|
+
import { ThemeColors, useTheme, useThemedStyles } from '@src/core/theme';
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
LayoutChangeEvent,
|
|
6
|
+
ScrollView,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import Animated, {
|
|
12
|
+
useAnimatedStyle,
|
|
13
|
+
useSharedValue,
|
|
14
|
+
withTiming,
|
|
15
|
+
} from 'react-native-reanimated';
|
|
16
|
+
import { TabItem, TabsProps } from './tabs.type';
|
|
17
|
+
|
|
18
|
+
// One timing for both the underline slide and the label scale, so the
|
|
19
|
+
// indicator and the text settle together.
|
|
20
|
+
const SLIDE_DURATION = 240;
|
|
21
|
+
// Active label nudges up a touch — subtle; the row height stays put because the
|
|
22
|
+
// inactive label already reserves the line-height.
|
|
23
|
+
const LABEL_SCALE_ACTIVE = 1.06;
|
|
24
|
+
|
|
25
|
+
/** Per-tab measured geometry, used to place the sliding underline. */
|
|
26
|
+
type TabLayout = { x: number; width: number };
|
|
27
|
+
|
|
28
|
+
type Styles = ReturnType<typeof makeStyles>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One tab cell. Measures itself (`onLayout`) so the parent can drive the
|
|
32
|
+
* sliding underline, and scales its label up while active. Memoized so a tab
|
|
33
|
+
* switch only re-renders the two tabs whose active state actually flips.
|
|
34
|
+
*/
|
|
35
|
+
const Tab = React.memo(function Tab({
|
|
36
|
+
item,
|
|
37
|
+
isActive,
|
|
38
|
+
onPress,
|
|
39
|
+
onMeasure,
|
|
40
|
+
styles,
|
|
41
|
+
}: {
|
|
42
|
+
item: TabItem;
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
onPress: (key: string) => void;
|
|
45
|
+
onMeasure: (key: string, layout: TabLayout) => void;
|
|
46
|
+
styles: Styles;
|
|
47
|
+
}) {
|
|
48
|
+
const scale = useSharedValue(isActive ? LABEL_SCALE_ACTIVE : 1);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
scale.value = withTiming(isActive ? LABEL_SCALE_ACTIVE : 1, {
|
|
52
|
+
duration: SLIDE_DURATION,
|
|
53
|
+
});
|
|
54
|
+
}, [isActive, scale]);
|
|
55
|
+
|
|
56
|
+
const labelStyle = useAnimatedStyle(() => ({
|
|
57
|
+
transform: [{ scale: scale.value }],
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
const handleLayout = useCallback(
|
|
61
|
+
(e: LayoutChangeEvent) => {
|
|
62
|
+
const { x, width } = e.nativeEvent.layout;
|
|
63
|
+
onMeasure(item.key, { x, width });
|
|
64
|
+
},
|
|
65
|
+
[item.key, onMeasure],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const handlePress = useCallback(() => onPress(item.key), [item.key, onPress]);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<TouchableOpacity
|
|
72
|
+
accessibilityRole="tab"
|
|
73
|
+
accessibilityState={{ selected: isActive }}
|
|
74
|
+
activeOpacity={0.7}
|
|
75
|
+
onPress={handlePress}
|
|
76
|
+
onLayout={handleLayout}
|
|
77
|
+
style={styles.tab}
|
|
78
|
+
>
|
|
79
|
+
<Animated.Text
|
|
80
|
+
style={[styles.label, isActive && styles.labelActive, labelStyle]}
|
|
81
|
+
>
|
|
82
|
+
{item.label}
|
|
83
|
+
</Animated.Text>
|
|
84
|
+
</TouchableOpacity>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Design-system underline tabs (Life-Master-Design "Horizontal tabs").
|
|
90
|
+
*
|
|
91
|
+
* The active tab keeps the same look as before — a 2px primary underline + a
|
|
92
|
+
* highlighted label — but the underline now *slides* between tabs (reanimated)
|
|
93
|
+
* and the active label scales up a touch, so switching reads as continuous
|
|
94
|
+
* motion instead of a hard swap. The whole bar keeps its 1px bottom divider.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* <Tabs items={[{key:'all',label:'Tout'}]} activeKey={key} onChange={setKey} />
|
|
98
|
+
*/
|
|
99
|
+
const Tabs = ({ items, activeKey, onChange, scrollable = true, style }: TabsProps) => {
|
|
100
|
+
const styles = useThemedStyles(makeStyles);
|
|
101
|
+
const { colors } = useTheme();
|
|
102
|
+
|
|
103
|
+
// Measured geometry per tab key — the underline reads from here. A ref, so a
|
|
104
|
+
// measurement never triggers a render; the underline is repositioned
|
|
105
|
+
// imperatively on the UI thread instead.
|
|
106
|
+
const layouts = useRef<Record<string, TabLayout>>({});
|
|
107
|
+
|
|
108
|
+
const underlineX = useSharedValue(0);
|
|
109
|
+
const underlineW = useSharedValue(0);
|
|
110
|
+
// Skip the first animation so the underline appears already under the active
|
|
111
|
+
// tab instead of flying in from x=0 on mount.
|
|
112
|
+
const placed = useRef(false);
|
|
113
|
+
|
|
114
|
+
// The horizontal scroller + its measured viewport width, so a tap on a tab
|
|
115
|
+
// near either edge can recenter that tab. Width is needed to compute the
|
|
116
|
+
// centering offset; the ref drives the imperative scroll.
|
|
117
|
+
const scrollRef = useRef<ScrollView>(null);
|
|
118
|
+
const viewportW = useRef(0);
|
|
119
|
+
|
|
120
|
+
// Scroll so the tapped tab sits centered in the viewport, clamped at both
|
|
121
|
+
// ends so we never overscroll past the content edges.
|
|
122
|
+
const centerTab = useCallback((key: string) => {
|
|
123
|
+
const l = layouts.current[key];
|
|
124
|
+
const vw = viewportW.current;
|
|
125
|
+
if (!l || !vw) return;
|
|
126
|
+
const target = l.x + l.width / 2 - vw / 2;
|
|
127
|
+
scrollRef.current?.scrollTo({ x: Math.max(0, target), animated: true });
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
const placeUnderline = useCallback(
|
|
131
|
+
(key: string, animated: boolean) => {
|
|
132
|
+
const l = layouts.current[key];
|
|
133
|
+
if (!l) return;
|
|
134
|
+
if (animated) {
|
|
135
|
+
underlineX.value = withTiming(l.x, { duration: SLIDE_DURATION });
|
|
136
|
+
underlineW.value = withTiming(l.width, { duration: SLIDE_DURATION });
|
|
137
|
+
} else {
|
|
138
|
+
underlineX.value = l.x;
|
|
139
|
+
underlineW.value = l.width;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
[underlineX, underlineW],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const onMeasure = useCallback(
|
|
146
|
+
(key: string, layout: TabLayout) => {
|
|
147
|
+
const prev = layouts.current[key];
|
|
148
|
+
if (prev && prev.x === layout.x && prev.width === layout.width) return;
|
|
149
|
+
layouts.current[key] = layout;
|
|
150
|
+
// First time the active tab reports its box, snap the underline under it.
|
|
151
|
+
if (key === activeKey && !placed.current) {
|
|
152
|
+
placeUnderline(key, false);
|
|
153
|
+
placed.current = true;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
[activeKey, placeUnderline],
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// Slide whenever the active tab changes. If the active tab has already been
|
|
160
|
+
// measured, `placed` is true → animate; otherwise the measure callback snaps.
|
|
161
|
+
// Also recenter the now-active tab so edge tabs (and external swipes that
|
|
162
|
+
// move the active key) pull themselves into the middle of the scroller.
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
placeUnderline(activeKey, placed.current);
|
|
165
|
+
centerTab(activeKey);
|
|
166
|
+
}, [activeKey, placeUnderline, centerTab]);
|
|
167
|
+
|
|
168
|
+
const underlineStyle = useAnimatedStyle(() => ({
|
|
169
|
+
transform: [{ translateX: underlineX.value }],
|
|
170
|
+
width: underlineW.value,
|
|
171
|
+
}));
|
|
172
|
+
|
|
173
|
+
const row = items.map((item) => (
|
|
174
|
+
<Tab
|
|
175
|
+
key={item.key}
|
|
176
|
+
item={item}
|
|
177
|
+
isActive={item.key === activeKey}
|
|
178
|
+
onPress={onChange}
|
|
179
|
+
onMeasure={onMeasure}
|
|
180
|
+
styles={styles}
|
|
181
|
+
/>
|
|
182
|
+
));
|
|
183
|
+
|
|
184
|
+
// Absolutely positioned over the bar; left + width animate to the active tab.
|
|
185
|
+
const underline = (
|
|
186
|
+
<Animated.View
|
|
187
|
+
pointerEvents="none"
|
|
188
|
+
style={[
|
|
189
|
+
styles.underline,
|
|
190
|
+
{ backgroundColor: colors.bd_primary_normal },
|
|
191
|
+
underlineStyle,
|
|
192
|
+
]}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
if (scrollable) {
|
|
197
|
+
return (
|
|
198
|
+
<View style={styles.content}>
|
|
199
|
+
<ScrollView
|
|
200
|
+
ref={scrollRef}
|
|
201
|
+
horizontal
|
|
202
|
+
showsHorizontalScrollIndicator={false}
|
|
203
|
+
onLayout={(e) => {
|
|
204
|
+
viewportW.current = e.nativeEvent.layout.width;
|
|
205
|
+
}}
|
|
206
|
+
style={style}
|
|
207
|
+
contentContainerStyle={styles.bar}
|
|
208
|
+
>
|
|
209
|
+
{row}
|
|
210
|
+
{underline}
|
|
211
|
+
</ScrollView>
|
|
212
|
+
</View>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<View style={[styles.bar, styles.barStatic, style]}>
|
|
218
|
+
{row}
|
|
219
|
+
{underline}
|
|
220
|
+
</View>
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export default Tabs;
|
|
225
|
+
|
|
226
|
+
const makeStyles = (c: ThemeColors) =>
|
|
227
|
+
StyleSheet.create({
|
|
228
|
+
bar: {
|
|
229
|
+
flexDirection: 'row',
|
|
230
|
+
alignItems: 'center',
|
|
231
|
+
gap: Spacing.spacing_sm, // 8
|
|
232
|
+
// Anchor the absolute sliding underline to the bar's bottom edge.
|
|
233
|
+
position: 'relative',
|
|
234
|
+
paddingBottom: Stroke.stroke_m, // 2 — room for the underline
|
|
235
|
+
},
|
|
236
|
+
barStatic: {
|
|
237
|
+
alignSelf: 'stretch',
|
|
238
|
+
},
|
|
239
|
+
content: {
|
|
240
|
+
borderBottomWidth: Stroke.stroke_m, // 1
|
|
241
|
+
borderBottomColor: c.bd_neutral_faded, // #525252
|
|
242
|
+
},
|
|
243
|
+
tab: {
|
|
244
|
+
minHeight: 46,
|
|
245
|
+
alignItems: 'center',
|
|
246
|
+
justifyContent: 'center',
|
|
247
|
+
paddingHorizontal: Spacing.spacing_base, // 16
|
|
248
|
+
paddingTop: Spacing.spacing_sm, // 8
|
|
249
|
+
paddingBottom: Spacing.spacing_m_nudge, // 10
|
|
250
|
+
borderTopLeftRadius: Radius.radius_md, // 8
|
|
251
|
+
borderTopRightRadius: Radius.radius_md,
|
|
252
|
+
},
|
|
253
|
+
// Slides between tabs; left (translateX) + width are animated inline.
|
|
254
|
+
underline: {
|
|
255
|
+
position: 'absolute',
|
|
256
|
+
left: 0,
|
|
257
|
+
bottom: 0,
|
|
258
|
+
height: Stroke.stroke_m, // 2
|
|
259
|
+
borderRadius: Stroke.stroke_m,
|
|
260
|
+
},
|
|
261
|
+
label: {
|
|
262
|
+
fontFamily: Font.dmSansMedium,
|
|
263
|
+
fontSize: fontSize(14),
|
|
264
|
+
lineHeight: 20,
|
|
265
|
+
letterSpacing: 0.25,
|
|
266
|
+
color: c.fg_neutral_faded, // #a8a8a8
|
|
267
|
+
paddingHorizontal: Spacing.spacing_s_nudge, // 6
|
|
268
|
+
paddingVertical: Spacing.spacing_2xs, // 2
|
|
269
|
+
},
|
|
270
|
+
labelActive: {
|
|
271
|
+
color: c.fg_primary_faded, // #ece9fe
|
|
272
|
+
},
|
|
273
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface TabItem {
|
|
4
|
+
/** Unique key. */
|
|
5
|
+
key: string;
|
|
6
|
+
/** Visible label. */
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TabsProps {
|
|
11
|
+
/** Tab items. */
|
|
12
|
+
items: TabItem[];
|
|
13
|
+
/** Currently active tab key. */
|
|
14
|
+
activeKey: string;
|
|
15
|
+
/** Fired with the next key when a tab is pressed. */
|
|
16
|
+
onChange: (key: string) => void;
|
|
17
|
+
/** Scroll horizontally when tabs overflow. @default true */
|
|
18
|
+
scrollable?: boolean;
|
|
19
|
+
/** Override the container style. */
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { IconClose } from '@src/assets/svgs';
|
|
2
|
+
import { ThemeColors, useTheme, useThemedStyles } from '@src/core/theme';
|
|
3
|
+
import { Font, fontSize, horizontalScale, Radius, Spacing, Stroke } from '@src/core/utils';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
6
|
+
import FieldFrame from '../field/field-frame';
|
|
7
|
+
import { FIELD_BORDER_WIDTH, resolveFieldBorderColor } from '../field/field.shared';
|
|
8
|
+
import { TagInputProps } from './tag-input.type';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Design-system tag / badge input (Life-Master-Design "Badge" input field).
|
|
12
|
+
*
|
|
13
|
+
* Removable chips + a free-text input. Submitting the input adds a tag;
|
|
14
|
+
* backspace on an empty input removes the last tag. Shares the field frame
|
|
15
|
+
* + border-state logic with {@link TextField}.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <TagInput label="People" tags={tags} onChangeTags={setTags} placeholder="Add…" />
|
|
19
|
+
*/
|
|
20
|
+
const TagInput = (props: TagInputProps) => {
|
|
21
|
+
const {
|
|
22
|
+
label,
|
|
23
|
+
message,
|
|
24
|
+
tags,
|
|
25
|
+
onChangeTags,
|
|
26
|
+
placeholder,
|
|
27
|
+
error = false,
|
|
28
|
+
disabled = false,
|
|
29
|
+
containerStyle,
|
|
30
|
+
inputStyle,
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const { colors } = useTheme();
|
|
34
|
+
const styles = useThemedStyles(makeStyles);
|
|
35
|
+
|
|
36
|
+
const [text, setText] = useState('');
|
|
37
|
+
const [focused, setFocused] = useState(false);
|
|
38
|
+
const borderColor = resolveFieldBorderColor(colors, { focused, error, disabled });
|
|
39
|
+
|
|
40
|
+
const addTag = () => {
|
|
41
|
+
const value = text.trim();
|
|
42
|
+
if (value) {
|
|
43
|
+
onChangeTags([...tags, value]);
|
|
44
|
+
setText('');
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const removeTag = (index: number) => {
|
|
49
|
+
onChangeTags(tags.filter((_, i) => i !== index));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleKeyPress = (key: string) => {
|
|
53
|
+
if (key === 'Backspace' && text.length === 0 && tags.length > 0) {
|
|
54
|
+
removeTag(tags.length - 1);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<FieldFrame label={label} message={message} error={error} disabled={disabled} style={containerStyle}>
|
|
60
|
+
<View
|
|
61
|
+
style={[
|
|
62
|
+
styles.box,
|
|
63
|
+
{ borderColor, backgroundColor: disabled ? colors.bg_disable : colors.bg_input },
|
|
64
|
+
]}
|
|
65
|
+
>
|
|
66
|
+
{tags.map((tag, i) => (
|
|
67
|
+
<View key={`${tag}-${i}`} style={styles.chip}>
|
|
68
|
+
<Text style={styles.chipText}>{tag}</Text>
|
|
69
|
+
<TouchableOpacity disabled={disabled} onPress={() => removeTag(i)} hitSlop={6}>
|
|
70
|
+
<IconClose
|
|
71
|
+
width={horizontalScale(12)}
|
|
72
|
+
height={horizontalScale(12)}
|
|
73
|
+
color={colors.fg_neutral_faded}
|
|
74
|
+
/>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
</View>
|
|
77
|
+
))}
|
|
78
|
+
|
|
79
|
+
<TextInput
|
|
80
|
+
value={text}
|
|
81
|
+
editable={!disabled}
|
|
82
|
+
placeholder={tags.length === 0 ? placeholder : undefined}
|
|
83
|
+
placeholderTextColor={colors.fg_neutral_faded}
|
|
84
|
+
onChangeText={setText}
|
|
85
|
+
onSubmitEditing={addTag}
|
|
86
|
+
onKeyPress={(e) => {
|
|
87
|
+
// Android may report a null/undefined key — guard before handling.
|
|
88
|
+
if (e.nativeEvent?.key) {
|
|
89
|
+
handleKeyPress(e.nativeEvent.key);
|
|
90
|
+
}
|
|
91
|
+
}}
|
|
92
|
+
onFocus={() => setFocused(true)}
|
|
93
|
+
onBlur={() => {
|
|
94
|
+
setFocused(false);
|
|
95
|
+
addTag();
|
|
96
|
+
}}
|
|
97
|
+
blurOnSubmit={false}
|
|
98
|
+
style={[styles.input, inputStyle]}
|
|
99
|
+
/>
|
|
100
|
+
</View>
|
|
101
|
+
</FieldFrame>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default TagInput;
|
|
106
|
+
|
|
107
|
+
const makeStyles = (c: ThemeColors) =>
|
|
108
|
+
StyleSheet.create({
|
|
109
|
+
box: {
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
flexWrap: 'wrap',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
alignSelf: 'stretch',
|
|
114
|
+
gap: Spacing.spacing_xs, // 4
|
|
115
|
+
borderRadius: Radius.radius_lg, // 12
|
|
116
|
+
borderWidth: FIELD_BORDER_WIDTH, // 1
|
|
117
|
+
paddingHorizontal: Spacing.spacing_md, // 12
|
|
118
|
+
paddingVertical: Spacing.spacing_s_nudge, // 6
|
|
119
|
+
},
|
|
120
|
+
chip: {
|
|
121
|
+
flexDirection: 'row',
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
gap: Spacing.spacing_xs, // 4
|
|
124
|
+
paddingHorizontal: Spacing.spacing_sm, // 8
|
|
125
|
+
paddingVertical: Spacing.spacing_2xs, // 2
|
|
126
|
+
borderRadius: Radius.radius_sm, // 4
|
|
127
|
+
borderWidth: Stroke.stroke_xs, // 0.5
|
|
128
|
+
borderColor: c.bd_neutral_faded,
|
|
129
|
+
backgroundColor: c.bg_elevation_level_2_normal, // #292929
|
|
130
|
+
},
|
|
131
|
+
chipText: {
|
|
132
|
+
fontFamily: Font.dmSansMedium,
|
|
133
|
+
fontSize: fontSize(12),
|
|
134
|
+
lineHeight: 18,
|
|
135
|
+
color: c.fg_neutral_normal,
|
|
136
|
+
},
|
|
137
|
+
input: {
|
|
138
|
+
flexGrow: 1,
|
|
139
|
+
minWidth: horizontalScale(60),
|
|
140
|
+
paddingVertical: Spacing.spacing_xs, // 4
|
|
141
|
+
fontFamily: Font.dmSansRegular,
|
|
142
|
+
fontSize: fontSize(16),
|
|
143
|
+
lineHeight: 24,
|
|
144
|
+
color: c.fg_neutral_normal,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface TagInputProps {
|
|
4
|
+
/** Top label. */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Bottom helper / error message. */
|
|
7
|
+
message?: string;
|
|
8
|
+
/** Current list of tags (controlled). */
|
|
9
|
+
tags: string[];
|
|
10
|
+
/** Fired with the next list when a tag is added or removed. */
|
|
11
|
+
onChangeTags: (tags: string[]) => void;
|
|
12
|
+
/** Placeholder for the text input. */
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** Error (validation) visual + red message. */
|
|
15
|
+
error?: boolean;
|
|
16
|
+
/** Disable input. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Override the outer container style. */
|
|
19
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
20
|
+
/** Override the text input style. */
|
|
21
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Font, fontSize, Radius, Spacing } from '@src/core/utils';
|
|
2
|
+
import { ThemeColors, useTheme, useThemedStyles } from '@src/core/theme';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { StyleSheet, TextInput } from 'react-native';
|
|
5
|
+
import FieldFrame from '../field/field-frame';
|
|
6
|
+
import { FIELD_BORDER_WIDTH, resolveFieldBorderColor } from '../field/field.shared';
|
|
7
|
+
import { TextAreaProps } from './text-area.type';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Design-system multiline text area (Life-Master-Design "Textarea input field").
|
|
11
|
+
*
|
|
12
|
+
* Shares the field frame + border-state logic with {@link TextField}.
|
|
13
|
+
* States: default / focus / filled / error / disabled.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <TextArea label="Description" placeholder="Text" value={v} onChangeText={setV} />
|
|
17
|
+
*/
|
|
18
|
+
const TextArea = (props: TextAreaProps) => {
|
|
19
|
+
const {
|
|
20
|
+
label,
|
|
21
|
+
message,
|
|
22
|
+
error = false,
|
|
23
|
+
disabled = false,
|
|
24
|
+
minHeight = 140,
|
|
25
|
+
maxHeight = 240,
|
|
26
|
+
containerStyle,
|
|
27
|
+
inputStyle,
|
|
28
|
+
onFocus,
|
|
29
|
+
onBlur,
|
|
30
|
+
...inputProps
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const { colors } = useTheme();
|
|
34
|
+
const styles = useThemedStyles(makeStyles);
|
|
35
|
+
|
|
36
|
+
const [focused, setFocused] = useState(false);
|
|
37
|
+
const borderColor = resolveFieldBorderColor(colors, { focused, error, disabled });
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FieldFrame label={label} message={message} error={error} disabled={disabled} style={containerStyle}>
|
|
41
|
+
<TextInput
|
|
42
|
+
{...inputProps}
|
|
43
|
+
multiline
|
|
44
|
+
editable={!disabled}
|
|
45
|
+
textAlignVertical="top"
|
|
46
|
+
placeholderTextColor={colors.fg_neutral_faded}
|
|
47
|
+
onFocus={(e) => {
|
|
48
|
+
setFocused(true);
|
|
49
|
+
onFocus?.(e);
|
|
50
|
+
}}
|
|
51
|
+
onBlur={(e) => {
|
|
52
|
+
setFocused(false);
|
|
53
|
+
onBlur?.(e);
|
|
54
|
+
}}
|
|
55
|
+
scrollEnabled
|
|
56
|
+
style={[
|
|
57
|
+
styles.box,
|
|
58
|
+
{
|
|
59
|
+
minHeight,
|
|
60
|
+
maxHeight,
|
|
61
|
+
borderColor,
|
|
62
|
+
backgroundColor: disabled ? colors.bg_disable : colors.bg_input,
|
|
63
|
+
},
|
|
64
|
+
disabled && styles.inputDisabled,
|
|
65
|
+
inputStyle,
|
|
66
|
+
]}
|
|
67
|
+
/>
|
|
68
|
+
</FieldFrame>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default TextArea;
|
|
73
|
+
|
|
74
|
+
const makeStyles = (c: ThemeColors) =>
|
|
75
|
+
StyleSheet.create({
|
|
76
|
+
box: {
|
|
77
|
+
alignSelf: 'stretch',
|
|
78
|
+
borderRadius: Radius.radius_lg, // 12
|
|
79
|
+
borderWidth: FIELD_BORDER_WIDTH, // 1
|
|
80
|
+
paddingHorizontal: Spacing.spacing_md, // 12
|
|
81
|
+
paddingVertical: Spacing.spacing_m_nudge, // 10
|
|
82
|
+
fontFamily: Font.dmSansRegular,
|
|
83
|
+
fontSize: fontSize(16),
|
|
84
|
+
lineHeight: 24,
|
|
85
|
+
color: c.fg_neutral_normal,
|
|
86
|
+
},
|
|
87
|
+
inputDisabled: {
|
|
88
|
+
color: c.fg_neutral_faded,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StyleProp, TextInputProps, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type TextAreaProps = Omit<TextInputProps, 'style' | 'editable' | 'multiline'> & {
|
|
4
|
+
/** Top label / description. */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Bottom helper / error message. */
|
|
7
|
+
message?: string;
|
|
8
|
+
/** Error (validation) visual + red message. */
|
|
9
|
+
error?: boolean;
|
|
10
|
+
/** Disable input. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Minimum height of the box. @default 140 */
|
|
13
|
+
minHeight?: number;
|
|
14
|
+
/** Maximum height; beyond this the field scrolls instead of growing. @default 240 */
|
|
15
|
+
maxHeight?: number;
|
|
16
|
+
/** Override the outer container style. */
|
|
17
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
18
|
+
/** Override the text input style. */
|
|
19
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
20
|
+
};
|