@navegarti/rn-design-system 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +37 -0
- package/lib/module/api/axios-adapter.js +174 -0
- package/lib/module/api/axios-adapter.js.map +1 -0
- package/lib/module/api/errors.js +91 -0
- package/lib/module/api/errors.js.map +1 -0
- package/lib/module/api/index.js +30 -0
- package/lib/module/api/index.js.map +1 -0
- package/lib/module/api/retry-strategy.js +68 -0
- package/lib/module/api/retry-strategy.js.map +1 -0
- package/lib/module/api/stores/auth-store.js +26 -0
- package/lib/module/api/stores/auth-store.js.map +1 -0
- package/lib/module/api/types.js +4 -0
- package/lib/module/api/types.js.map +1 -0
- package/lib/module/api.js +10 -0
- package/lib/module/api.js.map +1 -0
- package/lib/module/components/Button/index.js +32 -0
- package/lib/module/components/Button/index.js.map +1 -0
- package/lib/module/components/Button/styles.js +27 -0
- package/lib/module/components/Button/styles.js.map +1 -0
- package/lib/module/components/Carousel/components/dot.js +42 -0
- package/lib/module/components/Carousel/components/dot.js.map +1 -0
- package/lib/module/components/Carousel/components/footer.js +22 -0
- package/lib/module/components/Carousel/components/footer.js.map +1 -0
- package/lib/module/components/Carousel/components/list.js +55 -0
- package/lib/module/components/Carousel/components/list.js.map +1 -0
- package/lib/module/components/Carousel/components/pagination.js +29 -0
- package/lib/module/components/Carousel/components/pagination.js.map +1 -0
- package/lib/module/components/Carousel/components/see-all-button.js +24 -0
- package/lib/module/components/Carousel/components/see-all-button.js.map +1 -0
- package/lib/module/components/Carousel/context.js +15 -0
- package/lib/module/components/Carousel/context.js.map +1 -0
- package/lib/module/components/Carousel/index.js +142 -0
- package/lib/module/components/Carousel/index.js.map +1 -0
- package/lib/module/components/Carousel/styles.js +10 -0
- package/lib/module/components/Carousel/styles.js.map +1 -0
- package/lib/module/components/Carousel/types.js +4 -0
- package/lib/module/components/Carousel/types.js.map +1 -0
- package/lib/module/components/Checkbox/index.js +34 -0
- package/lib/module/components/Checkbox/index.js.map +1 -0
- package/lib/module/components/Checkbox/styles.js +9 -0
- package/lib/module/components/Checkbox/styles.js.map +1 -0
- package/lib/module/components/FAB/components/extended-fab.js +17 -0
- package/lib/module/components/FAB/components/extended-fab.js.map +1 -0
- package/lib/module/components/FAB/index.js +24 -0
- package/lib/module/components/FAB/index.js.map +1 -0
- package/lib/module/components/FAB/styles.js +40 -0
- package/lib/module/components/FAB/styles.js.map +1 -0
- package/lib/module/components/FAB/utils.js +49 -0
- package/lib/module/components/FAB/utils.js.map +1 -0
- package/lib/module/components/Flex/index.js +4 -0
- package/lib/module/components/Flex/index.js.map +1 -0
- package/lib/module/components/Flex/styles.js +31 -0
- package/lib/module/components/Flex/styles.js.map +1 -0
- package/lib/module/components/FormLabel/index.js +10 -0
- package/lib/module/components/FormLabel/index.js.map +1 -0
- package/lib/module/components/FormLabel/styles.js +10 -0
- package/lib/module/components/FormLabel/styles.js.map +1 -0
- package/lib/module/components/Input/components/input-control.js +25 -0
- package/lib/module/components/Input/components/input-control.js.map +1 -0
- package/lib/module/components/Input/components/input-error.js +17 -0
- package/lib/module/components/Input/components/input-error.js.map +1 -0
- package/lib/module/components/Input/components/input-field.js +48 -0
- package/lib/module/components/Input/components/input-field.js.map +1 -0
- package/lib/module/components/Input/components/input-icon.js +10 -0
- package/lib/module/components/Input/components/input-icon.js.map +1 -0
- package/lib/module/components/Input/components/input-password-toggle.js +30 -0
- package/lib/module/components/Input/components/input-password-toggle.js.map +1 -0
- package/lib/module/components/Input/components/input-root.js +45 -0
- package/lib/module/components/Input/components/input-root.js.map +1 -0
- package/lib/module/components/Input/context.js +12 -0
- package/lib/module/components/Input/context.js.map +1 -0
- package/lib/module/components/Input/index.js +18 -0
- package/lib/module/components/Input/index.js.map +1 -0
- package/lib/module/components/Input/styles.js +40 -0
- package/lib/module/components/Input/styles.js.map +1 -0
- package/lib/module/components/Input/utils.js +24 -0
- package/lib/module/components/Input/utils.js.map +1 -0
- package/lib/module/components/Margin/index.js +4 -0
- package/lib/module/components/Margin/index.js.map +1 -0
- package/lib/module/components/Margin/styles.js +15 -0
- package/lib/module/components/Margin/styles.js.map +1 -0
- package/lib/module/components/OTPInput/index.js +85 -0
- package/lib/module/components/OTPInput/index.js.map +1 -0
- package/lib/module/components/OTPInput/styles.js +23 -0
- package/lib/module/components/OTPInput/styles.js.map +1 -0
- package/lib/module/components/OTPInput/utils.js +24 -0
- package/lib/module/components/OTPInput/utils.js.map +1 -0
- package/lib/module/components/Padding/index.js +4 -0
- package/lib/module/components/Padding/index.js.map +1 -0
- package/lib/module/components/Padding/styles.js +15 -0
- package/lib/module/components/Padding/styles.js.map +1 -0
- package/lib/module/components/Radio/components/radio-item.js +52 -0
- package/lib/module/components/Radio/components/radio-item.js.map +1 -0
- package/lib/module/components/Radio/context.js +5 -0
- package/lib/module/components/Radio/context.js.map +1 -0
- package/lib/module/components/Radio/index.js +30 -0
- package/lib/module/components/Radio/index.js.map +1 -0
- package/lib/module/components/Radio/styles.js +33 -0
- package/lib/module/components/Radio/styles.js.map +1 -0
- package/lib/module/components/Radio/utils.js +15 -0
- package/lib/module/components/Radio/utils.js.map +1 -0
- package/lib/module/components/Select/components/error-icon.js +8 -0
- package/lib/module/components/Select/components/error-icon.js.map +1 -0
- package/lib/module/components/Select/components/select-error.js +17 -0
- package/lib/module/components/Select/components/select-error.js.map +1 -0
- package/lib/module/components/Select/components/select-field.js +67 -0
- package/lib/module/components/Select/components/select-field.js.map +1 -0
- package/lib/module/components/Select/context.js +12 -0
- package/lib/module/components/Select/context.js.map +1 -0
- package/lib/module/components/Select/index.js +26 -0
- package/lib/module/components/Select/index.js.map +1 -0
- package/lib/module/components/Select/styles.js +15 -0
- package/lib/module/components/Select/styles.js.map +1 -0
- package/lib/module/components/Skeleton/index.js +44 -0
- package/lib/module/components/Skeleton/index.js.map +1 -0
- package/lib/module/components/Switch/index.js +55 -0
- package/lib/module/components/Switch/index.js.map +1 -0
- package/lib/module/components/Switch/styles.js +31 -0
- package/lib/module/components/Switch/styles.js.map +1 -0
- package/lib/module/components/Switch/utils.js +12 -0
- package/lib/module/components/Switch/utils.js.map +1 -0
- package/lib/module/components/Text/index.js +4 -0
- package/lib/module/components/Text/index.js.map +1 -0
- package/lib/module/components/Text/styles.js +25 -0
- package/lib/module/components/Text/styles.js.map +1 -0
- package/lib/module/components.js +23 -0
- package/lib/module/components.js.map +1 -0
- package/lib/module/form.js +10 -0
- package/lib/module/form.js.map +1 -0
- package/lib/module/formValidators/ZodTypeValidator.js +38 -0
- package/lib/module/formValidators/ZodTypeValidator.js.map +1 -0
- package/lib/module/formValidators/index.js +8 -0
- package/lib/module/formValidators/index.js.map +1 -0
- package/lib/module/formValidators/types.js +4 -0
- package/lib/module/formValidators/types.js.map +1 -0
- package/lib/module/hooks/useAppIsActive.js +20 -0
- package/lib/module/hooks/useAppIsActive.js.map +1 -0
- package/lib/module/hooks/useAppSecurity.js +26 -0
- package/lib/module/hooks/useAppSecurity.js.map +1 -0
- package/lib/module/hooks/useNetworkStatus.js +55 -0
- package/lib/module/hooks/useNetworkStatus.js.map +1 -0
- package/lib/module/hooks/useStatusBar.js +26 -0
- package/lib/module/hooks/useStatusBar.js.map +1 -0
- package/lib/module/hooks.js +12 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +53 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/libs/tanstack-form.js +5 -0
- package/lib/module/libs/tanstack-form.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/utils/camelCase.js +7 -0
- package/lib/module/utils/camelCase.js.map +1 -0
- package/lib/module/utils/camelCaseJSONKeys.js +29 -0
- package/lib/module/utils/camelCaseJSONKeys.js.map +1 -0
- package/lib/module/utils/capitalizeWord.js +5 -0
- package/lib/module/utils/capitalizeWord.js.map +1 -0
- package/lib/module/utils/createLinkingPhoneNumberString.js +10 -0
- package/lib/module/utils/createLinkingPhoneNumberString.js.map +1 -0
- package/lib/module/utils/dateFormatters.js +34 -0
- package/lib/module/utils/dateFormatters.js.map +1 -0
- package/lib/module/utils/debounce.js +12 -0
- package/lib/module/utils/debounce.js.map +1 -0
- package/lib/module/utils/deepLinkParser.js +117 -0
- package/lib/module/utils/deepLinkParser.js.map +1 -0
- package/lib/module/utils/getAge.js +13 -0
- package/lib/module/utils/getAge.js.map +1 -0
- package/lib/module/utils/getOnlyNumbers.js +4 -0
- package/lib/module/utils/getOnlyNumbers.js.map +1 -0
- package/lib/module/utils/isArray.js +7 -0
- package/lib/module/utils/isArray.js.map +1 -0
- package/lib/module/utils/isObject.js +7 -0
- package/lib/module/utils/isObject.js.map +1 -0
- package/lib/module/utils/masks.js +5 -0
- package/lib/module/utils/masks.js.map +1 -0
- package/lib/module/utils/priceFormatter.js +9 -0
- package/lib/module/utils/priceFormatter.js.map +1 -0
- package/lib/module/utils/removeTextAccents.js +5 -0
- package/lib/module/utils/removeTextAccents.js.map +1 -0
- package/lib/module/utils/shadowStyledIos.js +8 -0
- package/lib/module/utils/shadowStyledIos.js.map +1 -0
- package/lib/module/utils/sortBy.js +18 -0
- package/lib/module/utils/sortBy.js.map +1 -0
- package/lib/module/utils/uniqBy.js +15 -0
- package/lib/module/utils/uniqBy.js.map +1 -0
- package/lib/module/utils/userFullnameInitialsExtractor.js +19 -0
- package/lib/module/utils/userFullnameInitialsExtractor.js.map +1 -0
- package/lib/module/utils.js +26 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/api/axios-adapter.d.ts +61 -0
- package/lib/typescript/src/api/axios-adapter.d.ts.map +1 -0
- package/lib/typescript/src/api/errors.d.ts +63 -0
- package/lib/typescript/src/api/errors.d.ts.map +1 -0
- package/lib/typescript/src/api/index.d.ts +21 -0
- package/lib/typescript/src/api/index.d.ts.map +1 -0
- package/lib/typescript/src/api/retry-strategy.d.ts +21 -0
- package/lib/typescript/src/api/retry-strategy.d.ts.map +1 -0
- package/lib/typescript/src/api/stores/auth-store.d.ts +15 -0
- package/lib/typescript/src/api/stores/auth-store.d.ts.map +1 -0
- package/lib/typescript/src/api/types.d.ts +68 -0
- package/lib/typescript/src/api/types.d.ts.map +1 -0
- package/lib/typescript/src/api.d.ts +8 -0
- package/lib/typescript/src/api.d.ts.map +1 -0
- package/lib/typescript/src/components/Button/index.d.ts +478 -0
- package/lib/typescript/src/components/Button/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Button/styles.d.ts +318 -0
- package/lib/typescript/src/components/Button/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/components/dot.d.ts +7 -0
- package/lib/typescript/src/components/Carousel/components/dot.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/components/footer.d.ts +6 -0
- package/lib/typescript/src/components/Carousel/components/footer.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/components/list.d.ts +8 -0
- package/lib/typescript/src/components/Carousel/components/list.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/components/pagination.d.ts +2 -0
- package/lib/typescript/src/components/Carousel/components/pagination.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/components/see-all-button.d.ts +7 -0
- package/lib/typescript/src/components/Carousel/components/see-all-button.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/context.d.ts +4 -0
- package/lib/typescript/src/components/Carousel/context.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/index.d.ts +394 -0
- package/lib/typescript/src/components/Carousel/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/styles.d.ts +79 -0
- package/lib/typescript/src/components/Carousel/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Carousel/types.d.ts +40 -0
- package/lib/typescript/src/components/Carousel/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Checkbox/index.d.ts +10 -0
- package/lib/typescript/src/components/Checkbox/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Checkbox/styles.d.ts +154 -0
- package/lib/typescript/src/components/Checkbox/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/FAB/components/extended-fab.d.ts +3 -0
- package/lib/typescript/src/components/FAB/components/extended-fab.d.ts.map +1 -0
- package/lib/typescript/src/components/FAB/index.d.ts +8 -0
- package/lib/typescript/src/components/FAB/index.d.ts.map +1 -0
- package/lib/typescript/src/components/FAB/styles.d.ts +807 -0
- package/lib/typescript/src/components/FAB/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/FAB/utils.d.ts +19 -0
- package/lib/typescript/src/components/FAB/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/Flex/index.d.ts +2 -0
- package/lib/typescript/src/components/Flex/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Flex/styles.d.ts +135 -0
- package/lib/typescript/src/components/Flex/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/FormLabel/index.d.ts +3 -0
- package/lib/typescript/src/components/FormLabel/index.d.ts.map +1 -0
- package/lib/typescript/src/components/FormLabel/styles.d.ts +158 -0
- package/lib/typescript/src/components/FormLabel/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/components/input-control.d.ts +3 -0
- package/lib/typescript/src/components/Input/components/input-control.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/components/input-error.d.ts +3 -0
- package/lib/typescript/src/components/Input/components/input-error.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/components/input-field.d.ts +7 -0
- package/lib/typescript/src/components/Input/components/input-field.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/components/input-icon.d.ts +3 -0
- package/lib/typescript/src/components/Input/components/input-icon.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/components/input-password-toggle.d.ts +2 -0
- package/lib/typescript/src/components/Input/components/input-password-toggle.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/components/input-root.d.ts +9 -0
- package/lib/typescript/src/components/Input/components/input-root.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/context.d.ts +15 -0
- package/lib/typescript/src/components/Input/context.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/index.d.ts +17 -0
- package/lib/typescript/src/components/Input/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/styles.d.ts +738 -0
- package/lib/typescript/src/components/Input/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Input/utils.d.ts +3 -0
- package/lib/typescript/src/components/Input/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/Margin/index.d.ts +2 -0
- package/lib/typescript/src/components/Margin/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Margin/styles.d.ts +144 -0
- package/lib/typescript/src/components/Margin/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/OTPInput/index.d.ts +18 -0
- package/lib/typescript/src/components/OTPInput/index.d.ts.map +1 -0
- package/lib/typescript/src/components/OTPInput/styles.d.ts +214 -0
- package/lib/typescript/src/components/OTPInput/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/OTPInput/utils.d.ts +3 -0
- package/lib/typescript/src/components/OTPInput/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/Padding/index.d.ts +2 -0
- package/lib/typescript/src/components/Padding/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Padding/styles.d.ts +144 -0
- package/lib/typescript/src/components/Padding/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Radio/components/radio-item.d.ts +8 -0
- package/lib/typescript/src/components/Radio/components/radio-item.d.ts.map +1 -0
- package/lib/typescript/src/components/Radio/context.d.ts +8 -0
- package/lib/typescript/src/components/Radio/context.d.ts.map +1 -0
- package/lib/typescript/src/components/Radio/index.d.ts +86 -0
- package/lib/typescript/src/components/Radio/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Radio/styles.d.ts +348 -0
- package/lib/typescript/src/components/Radio/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Radio/utils.d.ts +2 -0
- package/lib/typescript/src/components/Radio/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/Select/components/error-icon.d.ts +2 -0
- package/lib/typescript/src/components/Select/components/error-icon.d.ts.map +1 -0
- package/lib/typescript/src/components/Select/components/select-error.d.ts +3 -0
- package/lib/typescript/src/components/Select/components/select-error.d.ts.map +1 -0
- package/lib/typescript/src/components/Select/components/select-field.d.ts +5 -0
- package/lib/typescript/src/components/Select/components/select-field.d.ts.map +1 -0
- package/lib/typescript/src/components/Select/context.d.ts +7 -0
- package/lib/typescript/src/components/Select/context.d.ts.map +1 -0
- package/lib/typescript/src/components/Select/index.d.ts +11 -0
- package/lib/typescript/src/components/Select/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Select/styles.d.ts +315 -0
- package/lib/typescript/src/components/Select/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Skeleton/index.d.ts +11 -0
- package/lib/typescript/src/components/Skeleton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Switch/index.d.ts +11 -0
- package/lib/typescript/src/components/Switch/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Switch/styles.d.ts +344 -0
- package/lib/typescript/src/components/Switch/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Switch/utils.d.ts +2 -0
- package/lib/typescript/src/components/Switch/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/Text/index.d.ts +3 -0
- package/lib/typescript/src/components/Text/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Text/styles.d.ts +169 -0
- package/lib/typescript/src/components/Text/styles.d.ts.map +1 -0
- package/lib/typescript/src/components.d.ts +20 -0
- package/lib/typescript/src/components.d.ts.map +1 -0
- package/lib/typescript/src/form.d.ts +7 -0
- package/lib/typescript/src/form.d.ts.map +1 -0
- package/lib/typescript/src/formValidators/ZodTypeValidator.d.ts +11 -0
- package/lib/typescript/src/formValidators/ZodTypeValidator.d.ts.map +1 -0
- package/lib/typescript/src/formValidators/index.d.ts +4 -0
- package/lib/typescript/src/formValidators/index.d.ts.map +1 -0
- package/lib/typescript/src/formValidators/types.d.ts +16 -0
- package/lib/typescript/src/formValidators/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAppIsActive.d.ts +2 -0
- package/lib/typescript/src/hooks/useAppIsActive.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAppSecurity.d.ts +8 -0
- package/lib/typescript/src/hooks/useAppSecurity.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useNetworkStatus.d.ts +7 -0
- package/lib/typescript/src/hooks/useNetworkStatus.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStatusBar.d.ts +7 -0
- package/lib/typescript/src/hooks/useStatusBar.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +9 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +45 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/libs/tanstack-form.d.ts +3 -0
- package/lib/typescript/src/libs/tanstack-form.d.ts.map +1 -0
- package/lib/typescript/src/utils/camelCase.d.ts +2 -0
- package/lib/typescript/src/utils/camelCase.d.ts.map +1 -0
- package/lib/typescript/src/utils/camelCaseJSONKeys.d.ts +3 -0
- package/lib/typescript/src/utils/camelCaseJSONKeys.d.ts.map +1 -0
- package/lib/typescript/src/utils/capitalizeWord.d.ts +3 -0
- package/lib/typescript/src/utils/capitalizeWord.d.ts.map +1 -0
- package/lib/typescript/src/utils/createLinkingPhoneNumberString.d.ts +3 -0
- package/lib/typescript/src/utils/createLinkingPhoneNumberString.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateFormatters.d.ts +7 -0
- package/lib/typescript/src/utils/dateFormatters.d.ts.map +1 -0
- package/lib/typescript/src/utils/debounce.d.ts +2 -0
- package/lib/typescript/src/utils/debounce.d.ts.map +1 -0
- package/lib/typescript/src/utils/deepLinkParser.d.ts +7 -0
- package/lib/typescript/src/utils/deepLinkParser.d.ts.map +1 -0
- package/lib/typescript/src/utils/getAge.d.ts +2 -0
- package/lib/typescript/src/utils/getAge.d.ts.map +1 -0
- package/lib/typescript/src/utils/getOnlyNumbers.d.ts +2 -0
- package/lib/typescript/src/utils/getOnlyNumbers.d.ts.map +1 -0
- package/lib/typescript/src/utils/isArray.d.ts +2 -0
- package/lib/typescript/src/utils/isArray.d.ts.map +1 -0
- package/lib/typescript/src/utils/isObject.d.ts +2 -0
- package/lib/typescript/src/utils/isObject.d.ts.map +1 -0
- package/lib/typescript/src/utils/masks.d.ts +3 -0
- package/lib/typescript/src/utils/masks.d.ts.map +1 -0
- package/lib/typescript/src/utils/priceFormatter.d.ts +2 -0
- package/lib/typescript/src/utils/priceFormatter.d.ts.map +1 -0
- package/lib/typescript/src/utils/removeTextAccents.d.ts +3 -0
- package/lib/typescript/src/utils/removeTextAccents.d.ts.map +1 -0
- package/lib/typescript/src/utils/shadowStyledIos.d.ts +3 -0
- package/lib/typescript/src/utils/shadowStyledIos.d.ts.map +1 -0
- package/lib/typescript/src/utils/sortBy.d.ts +2 -0
- package/lib/typescript/src/utils/sortBy.d.ts.map +1 -0
- package/lib/typescript/src/utils/uniqBy.d.ts +2 -0
- package/lib/typescript/src/utils/uniqBy.d.ts.map +1 -0
- package/lib/typescript/src/utils/userFullnameInitialsExtractor.d.ts +3 -0
- package/lib/typescript/src/utils/userFullnameInitialsExtractor.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +23 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/package.json +234 -0
- package/src/api/axios-adapter.ts +272 -0
- package/src/api/errors.ts +113 -0
- package/src/api/index.ts +27 -0
- package/src/api/retry-strategy.ts +86 -0
- package/src/api/stores/auth-store.ts +26 -0
- package/src/api/types.ts +91 -0
- package/src/api.tsx +17 -0
- package/src/components/Button/index.tsx +35 -0
- package/src/components/Button/styles.ts +28 -0
- package/src/components/Carousel/components/dot.tsx +43 -0
- package/src/components/Carousel/components/footer.tsx +21 -0
- package/src/components/Carousel/components/list.tsx +81 -0
- package/src/components/Carousel/components/pagination.tsx +16 -0
- package/src/components/Carousel/components/see-all-button.tsx +25 -0
- package/src/components/Carousel/context.tsx +19 -0
- package/src/components/Carousel/index.tsx +191 -0
- package/src/components/Carousel/styles.ts +8 -0
- package/src/components/Carousel/types.ts +45 -0
- package/src/components/Checkbox/index.tsx +42 -0
- package/src/components/Checkbox/styles.ts +7 -0
- package/src/components/FAB/components/extended-fab.tsx +17 -0
- package/src/components/FAB/index.tsx +22 -0
- package/src/components/FAB/styles.ts +61 -0
- package/src/components/FAB/utils.ts +45 -0
- package/src/components/Flex/index.tsx +1 -0
- package/src/components/Flex/styles.ts +47 -0
- package/src/components/FormLabel/index.tsx +6 -0
- package/src/components/FormLabel/styles.ts +8 -0
- package/src/components/Input/components/input-control.tsx +20 -0
- package/src/components/Input/components/input-error.tsx +14 -0
- package/src/components/Input/components/input-field.tsx +55 -0
- package/src/components/Input/components/input-icon.tsx +7 -0
- package/src/components/Input/components/input-password-toggle.tsx +19 -0
- package/src/components/Input/components/input-root.tsx +55 -0
- package/src/components/Input/context.tsx +26 -0
- package/src/components/Input/index.tsx +17 -0
- package/src/components/Input/styles.ts +45 -0
- package/src/components/Input/utils.ts +27 -0
- package/src/components/Margin/index.tsx +1 -0
- package/src/components/Margin/styles.ts +23 -0
- package/src/components/OTPInput/index.tsx +116 -0
- package/src/components/OTPInput/styles.ts +23 -0
- package/src/components/OTPInput/utils.ts +31 -0
- package/src/components/Padding/index.tsx +1 -0
- package/src/components/Padding/styles.ts +23 -0
- package/src/components/Radio/components/radio-item.tsx +53 -0
- package/src/components/Radio/context.tsx +10 -0
- package/src/components/Radio/index.tsx +32 -0
- package/src/components/Radio/styles.ts +38 -0
- package/src/components/Radio/utils.ts +19 -0
- package/src/components/Select/components/error-icon.tsx +3 -0
- package/src/components/Select/components/select-error.tsx +14 -0
- package/src/components/Select/components/select-field.tsx +72 -0
- package/src/components/Select/context.tsx +17 -0
- package/src/components/Select/index.tsx +24 -0
- package/src/components/Select/styles.ts +15 -0
- package/src/components/Skeleton/index.tsx +60 -0
- package/src/components/Switch/index.tsx +61 -0
- package/src/components/Switch/styles.ts +32 -0
- package/src/components/Switch/utils.ts +15 -0
- package/src/components/Text/index.tsx +2 -0
- package/src/components/Text/styles.ts +44 -0
- package/src/components.tsx +20 -0
- package/src/form.tsx +7 -0
- package/src/formValidators/ZodTypeValidator.ts +58 -0
- package/src/formValidators/index.ts +8 -0
- package/src/formValidators/types.ts +21 -0
- package/src/hooks/useAppIsActive.ts +28 -0
- package/src/hooks/useAppSecurity.tsx +35 -0
- package/src/hooks/useNetworkStatus.ts +75 -0
- package/src/hooks/useStatusBar.ts +34 -0
- package/src/hooks.tsx +9 -0
- package/src/index.tsx +50 -0
- package/src/libs/tanstack-form.tsx +3 -0
- package/src/utils/camelCase.ts +6 -0
- package/src/utils/camelCaseJSONKeys.ts +31 -0
- package/src/utils/capitalizeWord.ts +4 -0
- package/src/utils/createLinkingPhoneNumberString.ts +13 -0
- package/src/utils/dateFormatters.ts +48 -0
- package/src/utils/debounce.ts +15 -0
- package/src/utils/deepLinkParser.ts +88 -0
- package/src/utils/getAge.ts +12 -0
- package/src/utils/getOnlyNumbers.ts +1 -0
- package/src/utils/isArray.ts +4 -0
- package/src/utils/isObject.ts +4 -0
- package/src/utils/masks.ts +3 -0
- package/src/utils/priceFormatter.ts +11 -0
- package/src/utils/removeTextAccents.ts +4 -0
- package/src/utils/shadowStyledIos.ts +6 -0
- package/src/utils/sortBy.ts +21 -0
- package/src/utils/uniqBy.ts +20 -0
- package/src/utils/userFullnameInitialsExtractor.ts +23 -0
- package/src/utils.tsx +23 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AxiosError } from 'axios';
|
|
2
|
+
import type { RetryConfig } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Calculates exponential backoff delay
|
|
6
|
+
* Formula: min(baseDelay * (2 ^ attempt), maxDelay)
|
|
7
|
+
*/
|
|
8
|
+
export function calculateBackoffDelay(
|
|
9
|
+
attempt: number,
|
|
10
|
+
baseDelay: number,
|
|
11
|
+
maxDelay: number,
|
|
12
|
+
): number {
|
|
13
|
+
const exponentialDelay = baseDelay * 2 ** attempt;
|
|
14
|
+
return Math.min(exponentialDelay, maxDelay);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Determines if an error is retryable based on configuration
|
|
19
|
+
*/
|
|
20
|
+
export function isRetryableError(
|
|
21
|
+
error: AxiosError,
|
|
22
|
+
retryConfig: RetryConfig,
|
|
23
|
+
): boolean {
|
|
24
|
+
// Network errors (no response) are always retryable
|
|
25
|
+
if (!error.response) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const statusCode = error.response.status;
|
|
30
|
+
|
|
31
|
+
// Check if status code is in retryable list
|
|
32
|
+
return retryConfig.retryableStatusCodes.includes(statusCode);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sleep utility for retry delays
|
|
37
|
+
*/
|
|
38
|
+
export function sleep(ms: number): Promise<void> {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
setTimeout(resolve, ms);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Executes a request with retry logic
|
|
46
|
+
* @template T - The expected response type
|
|
47
|
+
*/
|
|
48
|
+
export async function executeWithRetry<T>(
|
|
49
|
+
requestFn: () => Promise<T>,
|
|
50
|
+
retryConfig: RetryConfig,
|
|
51
|
+
onRetry?: (attempt: number, delay: number, error: AxiosError) => void,
|
|
52
|
+
): Promise<T> {
|
|
53
|
+
let lastError: AxiosError | undefined;
|
|
54
|
+
|
|
55
|
+
for (let attempt = 0; attempt < retryConfig.maxAttempts; attempt++) {
|
|
56
|
+
try {
|
|
57
|
+
return await requestFn();
|
|
58
|
+
} catch (error) {
|
|
59
|
+
const axiosError = error as AxiosError;
|
|
60
|
+
lastError = axiosError;
|
|
61
|
+
|
|
62
|
+
// Don't retry if not retryable or if this was the last attempt
|
|
63
|
+
const isLastAttempt = attempt === retryConfig.maxAttempts - 1;
|
|
64
|
+
if (!isRetryableError(axiosError, retryConfig) || isLastAttempt) {
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Calculate delay and wait before retrying
|
|
69
|
+
const delay = calculateBackoffDelay(
|
|
70
|
+
attempt,
|
|
71
|
+
retryConfig.baseDelay,
|
|
72
|
+
retryConfig.maxDelay,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Notify callback if provided
|
|
76
|
+
if (onRetry) {
|
|
77
|
+
onRetry(attempt + 1, delay, axiosError);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await sleep(delay);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// This should never be reached, but TypeScript needs it
|
|
85
|
+
throw lastError;
|
|
86
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Authentication store state
|
|
5
|
+
*/
|
|
6
|
+
interface AuthState {
|
|
7
|
+
token: string | null;
|
|
8
|
+
setToken: (token: string) => void;
|
|
9
|
+
clearToken: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Zustand store for managing authentication token
|
|
14
|
+
* Token is stored in memory and used for Authorization header
|
|
15
|
+
*/
|
|
16
|
+
export const useAuthStore = create<AuthState>((set) => ({
|
|
17
|
+
token: null,
|
|
18
|
+
|
|
19
|
+
setToken: (token: string) => {
|
|
20
|
+
set({ token });
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
clearToken: () => {
|
|
24
|
+
set({ token: null });
|
|
25
|
+
},
|
|
26
|
+
}));
|
package/src/api/types.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Standardized API response format
|
|
5
|
+
* @template T - The type of data returned on success
|
|
6
|
+
*/
|
|
7
|
+
export interface ApiResponse<T = unknown> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data: T | null;
|
|
10
|
+
statusCode: number;
|
|
11
|
+
error: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Configuration options for API adapter
|
|
16
|
+
*/
|
|
17
|
+
export interface ApiConfig {
|
|
18
|
+
baseURL: string;
|
|
19
|
+
timeout?: number;
|
|
20
|
+
retryAttempts?: number;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Interface for HTTP client adapter
|
|
26
|
+
* Defines the contract all HTTP adapters must implement
|
|
27
|
+
*/
|
|
28
|
+
export interface IHttpAdapter {
|
|
29
|
+
/**
|
|
30
|
+
* Performs a GET request
|
|
31
|
+
* @template T - Expected response data type
|
|
32
|
+
*/
|
|
33
|
+
get<T = unknown>(
|
|
34
|
+
url: string,
|
|
35
|
+
config?: AxiosRequestConfig,
|
|
36
|
+
): Promise<ApiResponse<T>>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Performs a POST request
|
|
40
|
+
* @template T - Expected response data type
|
|
41
|
+
*/
|
|
42
|
+
post<T = unknown>(
|
|
43
|
+
url: string,
|
|
44
|
+
data?: unknown,
|
|
45
|
+
config?: AxiosRequestConfig,
|
|
46
|
+
): Promise<ApiResponse<T>>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Performs a PUT request
|
|
50
|
+
* @template T - Expected response data type
|
|
51
|
+
*/
|
|
52
|
+
put<T = unknown>(
|
|
53
|
+
url: string,
|
|
54
|
+
data?: unknown,
|
|
55
|
+
config?: AxiosRequestConfig,
|
|
56
|
+
): Promise<ApiResponse<T>>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Performs a DELETE request
|
|
60
|
+
* @template T - Expected response data type
|
|
61
|
+
*/
|
|
62
|
+
delete<T = unknown>(
|
|
63
|
+
url: string,
|
|
64
|
+
config?: AxiosRequestConfig,
|
|
65
|
+
): Promise<ApiResponse<T>>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Adds authentication token to all subsequent requests
|
|
69
|
+
*/
|
|
70
|
+
addToken(token: string): void;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Removes authentication token from requests
|
|
74
|
+
*/
|
|
75
|
+
removeToken(): void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get token from store
|
|
79
|
+
*/
|
|
80
|
+
getToken(): string | null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Retry configuration
|
|
85
|
+
*/
|
|
86
|
+
export interface RetryConfig {
|
|
87
|
+
maxAttempts: number;
|
|
88
|
+
baseDelay: number;
|
|
89
|
+
maxDelay: number;
|
|
90
|
+
retryableStatusCodes: number[];
|
|
91
|
+
}
|
package/src/api.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API module entry point.
|
|
3
|
+
* Exports HTTP client, types, errors, and stores.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
ApiError,
|
|
8
|
+
AuthError,
|
|
9
|
+
NetworkError,
|
|
10
|
+
NotFoundError,
|
|
11
|
+
RateLimitError,
|
|
12
|
+
ServerError,
|
|
13
|
+
TimeoutError,
|
|
14
|
+
ValidationError,
|
|
15
|
+
} from './api/errors';
|
|
16
|
+
export { AxiosAdapter, apiRequest, useAuthStore } from './api/index';
|
|
17
|
+
export type { ApiConfig, ApiResponse, IHttpAdapter } from './api/types';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
|
+
|
|
3
|
+
import { type ButtonProps, ButtonText, DefaultButtonStyle } from './styles';
|
|
4
|
+
|
|
5
|
+
const DefaultButton = (props: ButtonProps) => (
|
|
6
|
+
<DefaultButtonStyle activeOpacity={0.5} {...props} />
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
const SquareButton = styled(DefaultButton)(() => ({
|
|
10
|
+
borderRadius: 0,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const OutlineButton = styled(DefaultButton)(() => ({
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderColor: '#333',
|
|
16
|
+
backgroundColor: 'transparent',
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const RoundedButton = styled(DefaultButton)(() => ({
|
|
20
|
+
borderRadius: 8,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const PillButton = styled(DefaultButton)(() => ({
|
|
24
|
+
borderRadius: 999,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const Button = Object.assign(DefaultButton, {
|
|
28
|
+
Square: SquareButton,
|
|
29
|
+
Outline: OutlineButton,
|
|
30
|
+
Rounded: RoundedButton,
|
|
31
|
+
Pill: PillButton,
|
|
32
|
+
Text: ButtonText,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export { Button };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
|
+
import type { DimensionValue, TouchableOpacityProps } from 'react-native';
|
|
3
|
+
import { Text } from '../Text';
|
|
4
|
+
|
|
5
|
+
export type ButtonProps = {
|
|
6
|
+
color?: string;
|
|
7
|
+
paddingVertical?: number;
|
|
8
|
+
paddingHorizontal?: number;
|
|
9
|
+
margin?: DimensionValue;
|
|
10
|
+
} & TouchableOpacityProps;
|
|
11
|
+
|
|
12
|
+
export const DefaultButtonStyle = styled.TouchableOpacity<ButtonProps>(
|
|
13
|
+
({ paddingVertical, paddingHorizontal, color, margin }) => ({
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
paddingHorizontal: paddingHorizontal ?? 20,
|
|
18
|
+
paddingVertical: paddingVertical ?? 14,
|
|
19
|
+
gap: 8,
|
|
20
|
+
backgroundColor: color ?? '#333',
|
|
21
|
+
margin,
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const ButtonText = styled(Text)(({ color, size }) => ({
|
|
26
|
+
color: color ?? '#fff',
|
|
27
|
+
fontSize: size ?? 16,
|
|
28
|
+
}));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Animated, Pressable } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type DotProps = {
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
onPress: () => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function Dot({ isActive, onPress }: DotProps) {
|
|
10
|
+
const progress = React.useRef(new Animated.Value(isActive ? 1 : 0)).current;
|
|
11
|
+
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
Animated.timing(progress, {
|
|
14
|
+
toValue: isActive ? 1 : 0,
|
|
15
|
+
duration: 150,
|
|
16
|
+
useNativeDriver: false, // color animation needs native driver off
|
|
17
|
+
}).start();
|
|
18
|
+
}, [isActive, progress]);
|
|
19
|
+
|
|
20
|
+
const backgroundColor = progress.interpolate({
|
|
21
|
+
inputRange: [0, 1],
|
|
22
|
+
outputRange: ['#00000055', '#000000'],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const scale = progress.interpolate({
|
|
26
|
+
inputRange: [0, 1],
|
|
27
|
+
outputRange: [1, 1.2],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Pressable onPress={onPress} hitSlop={10}>
|
|
32
|
+
<Animated.View
|
|
33
|
+
style={{
|
|
34
|
+
height: 8,
|
|
35
|
+
width: 8,
|
|
36
|
+
borderRadius: 999,
|
|
37
|
+
backgroundColor,
|
|
38
|
+
transform: [{ scale }],
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
</Pressable>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentProps, PropsWithChildren } from 'react';
|
|
2
|
+
import { Flex } from '../../Flex';
|
|
3
|
+
import { Padding } from '../../Padding';
|
|
4
|
+
|
|
5
|
+
type CarouselFooterProps = PropsWithChildren<ComponentProps<typeof Flex>>;
|
|
6
|
+
|
|
7
|
+
export const CarouselFooter = ({
|
|
8
|
+
children,
|
|
9
|
+
gap = 8,
|
|
10
|
+
...flexProps
|
|
11
|
+
}: CarouselFooterProps) => (
|
|
12
|
+
<Padding
|
|
13
|
+
insets={{
|
|
14
|
+
all: 20,
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<Flex flexDirection="row" alignItems="center" gap={gap} {...flexProps}>
|
|
18
|
+
{children}
|
|
19
|
+
</Flex>
|
|
20
|
+
</Padding>
|
|
21
|
+
);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
type FlatListProps,
|
|
5
|
+
type StyleProp,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { useCarouselContext } from '../context';
|
|
10
|
+
|
|
11
|
+
type CarouselListProps<T> = {
|
|
12
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
13
|
+
snapEnabled?: boolean;
|
|
14
|
+
} & Omit<
|
|
15
|
+
FlatListProps<T>,
|
|
16
|
+
| 'CellRendererComponent'
|
|
17
|
+
| 'data'
|
|
18
|
+
| 'horizontal'
|
|
19
|
+
| 'renderItem'
|
|
20
|
+
| 'onScroll'
|
|
21
|
+
| 'onMomentumScrollEnd'
|
|
22
|
+
| 'snapToInterval'
|
|
23
|
+
| 'keyExtractor'
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
const CarouselList = <T,>({
|
|
27
|
+
contentContainerStyle,
|
|
28
|
+
snapEnabled = true,
|
|
29
|
+
...props
|
|
30
|
+
}: CarouselListProps<T>) => {
|
|
31
|
+
const {
|
|
32
|
+
data,
|
|
33
|
+
gapBetweenItems,
|
|
34
|
+
pageWidth,
|
|
35
|
+
onMomentumScrollEnd,
|
|
36
|
+
listRef,
|
|
37
|
+
renderItem,
|
|
38
|
+
handleScrollBeginDrag,
|
|
39
|
+
calculateSnapOffset,
|
|
40
|
+
centerItems,
|
|
41
|
+
} = useCarouselContext<T>();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Calculate snap offsets to center items (except first and last).
|
|
45
|
+
* Only used when centerItems is true.
|
|
46
|
+
*/
|
|
47
|
+
const snapToOffsets = React.useMemo(() => {
|
|
48
|
+
if (data.length === 0 || !snapEnabled || !centerItems) return undefined;
|
|
49
|
+
|
|
50
|
+
return data.map((_, index) => calculateSnapOffset(index));
|
|
51
|
+
}, [data, snapEnabled, calculateSnapOffset, centerItems]);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<FlatList
|
|
55
|
+
ref={listRef}
|
|
56
|
+
data={data}
|
|
57
|
+
renderItem={renderItem}
|
|
58
|
+
keyExtractor={(_, index) => `carousel-item-${index}`}
|
|
59
|
+
horizontal
|
|
60
|
+
showsHorizontalScrollIndicator={false}
|
|
61
|
+
contentContainerStyle={[
|
|
62
|
+
{
|
|
63
|
+
paddingHorizontal: 20,
|
|
64
|
+
columnGap: gapBetweenItems,
|
|
65
|
+
},
|
|
66
|
+
contentContainerStyle,
|
|
67
|
+
]}
|
|
68
|
+
snapToOffsets={centerItems ? snapToOffsets : undefined}
|
|
69
|
+
snapToInterval={!centerItems && snapEnabled ? pageWidth : undefined}
|
|
70
|
+
snapToAlignment="start"
|
|
71
|
+
decelerationRate={snapEnabled ? 'fast' : 'normal'}
|
|
72
|
+
bounces={false}
|
|
73
|
+
scrollEventThrottle={16}
|
|
74
|
+
onMomentumScrollEnd={onMomentumScrollEnd}
|
|
75
|
+
onScrollBeginDrag={handleScrollBeginDrag}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { CarouselList };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Flex } from '../../Flex';
|
|
2
|
+
import { useCarouselContext } from '../context';
|
|
3
|
+
import { Dot } from './dot';
|
|
4
|
+
|
|
5
|
+
export const CarouselPagination = () => {
|
|
6
|
+
const { data, activeIndex, goTo } = useCarouselContext();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Flex flexDirection="row" gap={8} alignItems="center" flexWrap="wrap">
|
|
10
|
+
{Array.from({ length: data.length }).map((_, i) => (
|
|
11
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: No need to use another key instead of index here
|
|
12
|
+
<Dot key={i} isActive={activeIndex === i} onPress={() => goTo(i)} />
|
|
13
|
+
))}
|
|
14
|
+
</Flex>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChevronRightIcon } from 'lucide-react-native';
|
|
2
|
+
import type { TouchableOpacityProps } from 'react-native';
|
|
3
|
+
import { Text } from '../../Text';
|
|
4
|
+
import { SeeAllButton } from '../styles';
|
|
5
|
+
|
|
6
|
+
type CarouselSeeAllButtonProps = {
|
|
7
|
+
color?: string;
|
|
8
|
+
} & TouchableOpacityProps;
|
|
9
|
+
|
|
10
|
+
const CarouselSeeAllButton = ({
|
|
11
|
+
color,
|
|
12
|
+
...props
|
|
13
|
+
}: CarouselSeeAllButtonProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<SeeAllButton {...props}>
|
|
16
|
+
<Text weight="bold" color={color ?? '#014661'}>
|
|
17
|
+
Ver todos
|
|
18
|
+
</Text>
|
|
19
|
+
{/* @ts-expect-error - lucide-react-native types issue */}
|
|
20
|
+
<ChevronRightIcon size={12} color={color ?? '#014661'} />
|
|
21
|
+
</SeeAllButton>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { CarouselSeeAllButton };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { CarouselContextValue } from './types';
|
|
4
|
+
|
|
5
|
+
export const CarouselContext =
|
|
6
|
+
// biome-ignore lint/suspicious/noExplicitAny: No need to specify generic type here
|
|
7
|
+
createContext<CarouselContextValue<any> | null>(null);
|
|
8
|
+
|
|
9
|
+
export const useCarouselContext = <T,>() => {
|
|
10
|
+
const context = useContext(CarouselContext);
|
|
11
|
+
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
'Carousel compound components must be used inside Carousel.',
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return context as CarouselContextValue<T>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
FlatList,
|
|
4
|
+
NativeScrollEvent,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import { Dimensions } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { CarouselFooter } from './components/footer';
|
|
10
|
+
import { CarouselList } from './components/list';
|
|
11
|
+
import { CarouselPagination } from './components/pagination';
|
|
12
|
+
import { CarouselSeeAllButton } from './components/see-all-button';
|
|
13
|
+
import { CarouselContext } from './context';
|
|
14
|
+
import type { CarouselRootProps } from './types';
|
|
15
|
+
|
|
16
|
+
const CarouselRoot = <T,>({
|
|
17
|
+
children,
|
|
18
|
+
data,
|
|
19
|
+
itemWidth = Dimensions.get('screen').width * 0.8,
|
|
20
|
+
gapBetweenItems = 10,
|
|
21
|
+
renderItem,
|
|
22
|
+
onSnapToItem,
|
|
23
|
+
defaultIndex,
|
|
24
|
+
autoPlay = false,
|
|
25
|
+
autoPlaySeconds = 3,
|
|
26
|
+
centerItems = false,
|
|
27
|
+
}: CarouselRootProps<T>) => {
|
|
28
|
+
const pageWidth = useMemo(
|
|
29
|
+
() => itemWidth + gapBetweenItems,
|
|
30
|
+
[gapBetweenItems, itemWidth],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const listRef = useRef<FlatList<T> | null>(null);
|
|
34
|
+
const activeIndexRef = useRef(defaultIndex ?? 0);
|
|
35
|
+
const autoPlayTimerRef = useRef<NodeJS.Timeout | null>(null);
|
|
36
|
+
const isUserInteracting = useRef(false);
|
|
37
|
+
|
|
38
|
+
const [activeIndex, setActiveIndex] = useState(() => defaultIndex ?? 0);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Calculate the scroll offset for a given index with proper centering.
|
|
42
|
+
* First and last items are not centered, middle items are centered.
|
|
43
|
+
*/
|
|
44
|
+
const calculateSnapOffset = useCallback(
|
|
45
|
+
(index: number) => {
|
|
46
|
+
const basePosition = index * pageWidth;
|
|
47
|
+
|
|
48
|
+
// If centerItems is disabled, use default behavior
|
|
49
|
+
if (!centerItems) {
|
|
50
|
+
return basePosition;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const screenWidth = Dimensions.get('window').width;
|
|
54
|
+
const centerOfScreen = screenWidth / 2;
|
|
55
|
+
const centerOfItem = itemWidth / 2;
|
|
56
|
+
const offsetToCenter = centerOfScreen - centerOfItem - 20;
|
|
57
|
+
|
|
58
|
+
// First item: keep default alignment (left edge with padding)
|
|
59
|
+
if (index === 0) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Last item: keep default alignment
|
|
64
|
+
if (index === data.length - 1) {
|
|
65
|
+
return basePosition;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Middle items: center them
|
|
69
|
+
return basePosition - offsetToCenter;
|
|
70
|
+
},
|
|
71
|
+
[itemWidth, pageWidth, data.length, centerItems],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const goTo = useCallback(
|
|
75
|
+
(index: number) => {
|
|
76
|
+
const targetIndex = Math.max(0, Math.min(index, data.length - 1));
|
|
77
|
+
|
|
78
|
+
if (activeIndexRef.current !== targetIndex) {
|
|
79
|
+
activeIndexRef.current = targetIndex;
|
|
80
|
+
setActiveIndex(targetIndex);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
listRef.current?.scrollToOffset({
|
|
84
|
+
offset: calculateSnapOffset(targetIndex),
|
|
85
|
+
animated: true,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
[data.length, calculateSnapOffset],
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const startAutoPlay = useCallback(() => {
|
|
92
|
+
if (autoPlayTimerRef.current) {
|
|
93
|
+
clearInterval(autoPlayTimerRef.current);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
autoPlayTimerRef.current = setInterval(() => {
|
|
97
|
+
if (!isUserInteracting.current) {
|
|
98
|
+
const nextIndex = (activeIndexRef.current + 1) % data.length;
|
|
99
|
+
goTo(nextIndex);
|
|
100
|
+
}
|
|
101
|
+
}, autoPlaySeconds * 1000);
|
|
102
|
+
}, [autoPlaySeconds, data.length, goTo]);
|
|
103
|
+
|
|
104
|
+
const onMomentumScrollEnd = useCallback(
|
|
105
|
+
(e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
106
|
+
const { x } = e.nativeEvent.contentOffset;
|
|
107
|
+
const currentIndex = Math.round(x / pageWidth);
|
|
108
|
+
|
|
109
|
+
// Update active index if changed
|
|
110
|
+
if (activeIndexRef.current !== currentIndex) {
|
|
111
|
+
activeIndexRef.current = currentIndex;
|
|
112
|
+
setActiveIndex(currentIndex);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
isUserInteracting.current = false;
|
|
116
|
+
|
|
117
|
+
// Restart autoPlay after user interaction ends
|
|
118
|
+
if (autoPlay && autoPlayTimerRef.current) {
|
|
119
|
+
startAutoPlay();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (onSnapToItem) {
|
|
123
|
+
onSnapToItem(activeIndexRef.current);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[pageWidth, autoPlay, startAutoPlay, onSnapToItem],
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (!autoPlay) return;
|
|
131
|
+
|
|
132
|
+
startAutoPlay();
|
|
133
|
+
|
|
134
|
+
return () => {
|
|
135
|
+
if (autoPlayTimerRef.current) {
|
|
136
|
+
clearInterval(autoPlayTimerRef.current);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}, [autoPlay, startAutoPlay]);
|
|
140
|
+
|
|
141
|
+
const handleScrollBeginDrag = useCallback(() => {
|
|
142
|
+
isUserInteracting.current = true;
|
|
143
|
+
|
|
144
|
+
if (autoPlayTimerRef.current) {
|
|
145
|
+
clearInterval(autoPlayTimerRef.current);
|
|
146
|
+
}
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
const value = useMemo(
|
|
150
|
+
() => ({
|
|
151
|
+
data,
|
|
152
|
+
pageWidth,
|
|
153
|
+
gapBetweenItems,
|
|
154
|
+
activeIndex,
|
|
155
|
+
goTo,
|
|
156
|
+
onMomentumScrollEnd,
|
|
157
|
+
listRef,
|
|
158
|
+
renderItem,
|
|
159
|
+
itemWidth,
|
|
160
|
+
handleScrollBeginDrag,
|
|
161
|
+
calculateSnapOffset,
|
|
162
|
+
centerItems,
|
|
163
|
+
}),
|
|
164
|
+
[
|
|
165
|
+
data,
|
|
166
|
+
pageWidth,
|
|
167
|
+
gapBetweenItems,
|
|
168
|
+
activeIndex,
|
|
169
|
+
goTo,
|
|
170
|
+
onMomentumScrollEnd,
|
|
171
|
+
renderItem,
|
|
172
|
+
itemWidth,
|
|
173
|
+
handleScrollBeginDrag,
|
|
174
|
+
calculateSnapOffset,
|
|
175
|
+
centerItems,
|
|
176
|
+
],
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<CarouselContext.Provider value={value}>
|
|
181
|
+
{children}
|
|
182
|
+
</CarouselContext.Provider>
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const Carousel = Object.assign(CarouselRoot, {
|
|
187
|
+
List: CarouselList,
|
|
188
|
+
Footer: CarouselFooter,
|
|
189
|
+
Pagination: CarouselPagination,
|
|
190
|
+
SeeAllButton: CarouselSeeAllButton,
|
|
191
|
+
});
|