@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,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utils module entry point.
|
|
3
|
+
* Exports all utility functions from the design system.
|
|
4
|
+
*/
|
|
5
|
+
export { camelCase } from './utils/camelCase';
|
|
6
|
+
export { camelCaseJSONKeys } from './utils/camelCaseJSONKeys';
|
|
7
|
+
export { capitalizeWord } from './utils/capitalizeWord';
|
|
8
|
+
export { createLinkingPhoneNumberString } from './utils/createLinkingPhoneNumberString';
|
|
9
|
+
export * from './utils/dateFormatters';
|
|
10
|
+
export { debounce } from './utils/debounce';
|
|
11
|
+
export { deepLinkParser } from './utils/deepLinkParser';
|
|
12
|
+
export { getAge } from './utils/getAge';
|
|
13
|
+
export { getOnlyNumbers } from './utils/getOnlyNumbers';
|
|
14
|
+
export { isArray } from './utils/isArray';
|
|
15
|
+
export { isObject } from './utils/isObject';
|
|
16
|
+
export { Masks } from './utils/masks';
|
|
17
|
+
export { priceFormatter } from './utils/priceFormatter';
|
|
18
|
+
export { removeTextAccents } from './utils/removeTextAccents';
|
|
19
|
+
export { shadowStyledIos } from './utils/shadowStyledIos';
|
|
20
|
+
export { sortBy } from './utils/sortBy';
|
|
21
|
+
export { uniqBy } from './utils/uniqBy';
|
|
22
|
+
export { userFullnameInitialsExtractor } from './utils/userFullnameInitialsExtractor';
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@navegarti/rn-design-system",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Components and functions to help navegar projects",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.tsx",
|
|
11
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./components": {
|
|
15
|
+
"source": "./src/components.tsx",
|
|
16
|
+
"types": "./lib/typescript/src/components.d.ts",
|
|
17
|
+
"default": "./lib/module/components.js"
|
|
18
|
+
},
|
|
19
|
+
"./utils": {
|
|
20
|
+
"source": "./src/utils.tsx",
|
|
21
|
+
"types": "./lib/typescript/src/utils.d.ts",
|
|
22
|
+
"default": "./lib/module/utils.js"
|
|
23
|
+
},
|
|
24
|
+
"./form": {
|
|
25
|
+
"source": "./src/form.tsx",
|
|
26
|
+
"types": "./lib/typescript/src/form.d.ts",
|
|
27
|
+
"default": "./lib/module/form.js"
|
|
28
|
+
},
|
|
29
|
+
"./hooks": {
|
|
30
|
+
"source": "./src/hooks.tsx",
|
|
31
|
+
"types": "./lib/typescript/src/hooks.d.ts",
|
|
32
|
+
"default": "./lib/module/hooks.js"
|
|
33
|
+
},
|
|
34
|
+
"./api": {
|
|
35
|
+
"source": "./src/api.tsx",
|
|
36
|
+
"types": "./lib/typescript/src/api.d.ts",
|
|
37
|
+
"default": "./lib/module/api.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"src",
|
|
43
|
+
"lib",
|
|
44
|
+
"android",
|
|
45
|
+
"ios",
|
|
46
|
+
"cpp",
|
|
47
|
+
"*.podspec",
|
|
48
|
+
"react-native.config.js",
|
|
49
|
+
"!ios/build",
|
|
50
|
+
"!android/build",
|
|
51
|
+
"!android/gradle",
|
|
52
|
+
"!android/gradlew",
|
|
53
|
+
"!android/gradlew.bat",
|
|
54
|
+
"!android/local.properties",
|
|
55
|
+
"!**/__tests__",
|
|
56
|
+
"!**/__fixtures__",
|
|
57
|
+
"!**/__mocks__",
|
|
58
|
+
"!**/.*"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"example": "yarn workspace @navegarti/rn-design-system-example",
|
|
62
|
+
"clean": "del-cli lib",
|
|
63
|
+
"prepare": "bob build",
|
|
64
|
+
"typecheck": "tsc",
|
|
65
|
+
"lint": "biome check --write --unsafe; biome format --write",
|
|
66
|
+
"test": "jest",
|
|
67
|
+
"release": "release-it --only-version"
|
|
68
|
+
},
|
|
69
|
+
"keywords": [
|
|
70
|
+
"react-native",
|
|
71
|
+
"ios",
|
|
72
|
+
"android"
|
|
73
|
+
],
|
|
74
|
+
"repository": {
|
|
75
|
+
"type": "git",
|
|
76
|
+
"url": "git+https://bitbucket.org/navegar/navegar-design-system/.git"
|
|
77
|
+
},
|
|
78
|
+
"author": "Lucas Rodrigues Paixão <lucas.paixao@navegarti.com.br> (https://bitbucket.org/navegar/navegar-design-system/)",
|
|
79
|
+
"license": "MIT",
|
|
80
|
+
"bugs": {
|
|
81
|
+
"url": "https://bitbucket.org/navegar/navegar-design-system//issues"
|
|
82
|
+
},
|
|
83
|
+
"homepage": "https://bitbucket.org/navegar/navegar-design-system/#readme",
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"registry": "https://registry.npmjs.org/",
|
|
86
|
+
"access": "public"
|
|
87
|
+
},
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@biomejs/biome": "^2.3.14",
|
|
90
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
91
|
+
"@react-native-community/netinfo": "^11.5.2",
|
|
92
|
+
"@react-native-picker/picker": "^2.11.4",
|
|
93
|
+
"@react-native/babel-preset": "0.83.1",
|
|
94
|
+
"@release-it/conventional-changelog": "^10.0.5",
|
|
95
|
+
"@types/jest": "^30.0.0",
|
|
96
|
+
"@types/prop-types": "^15",
|
|
97
|
+
"@types/react": "^19.2.13",
|
|
98
|
+
"commitlint": "^20.4.1",
|
|
99
|
+
"del-cli": "^7.0.0",
|
|
100
|
+
"expo-checkbox": "^5.0.8",
|
|
101
|
+
"jail-monkey": "^2.8.4",
|
|
102
|
+
"jest": "^30.2.0",
|
|
103
|
+
"lefthook": "^2.1.0",
|
|
104
|
+
"prettier": "^3.8.1",
|
|
105
|
+
"prop-types": "^15.8.1",
|
|
106
|
+
"react": "19.2.4",
|
|
107
|
+
"react-native": "0.83.1",
|
|
108
|
+
"react-native-builder-bob": "^0.40.17",
|
|
109
|
+
"react-native-nitro-modules": "^0.33.7",
|
|
110
|
+
"react-native-permissions": "^5.4.4",
|
|
111
|
+
"release-it": "^19.2.4",
|
|
112
|
+
"typescript": "^5.9.3"
|
|
113
|
+
},
|
|
114
|
+
"peerDependencies": {
|
|
115
|
+
"@react-native-community/netinfo": ">=11.0.0",
|
|
116
|
+
"@react-native-picker/picker": ">=2.0.0",
|
|
117
|
+
"expo-checkbox": ">=3.0.0",
|
|
118
|
+
"jail-monkey": ">=2.0.0",
|
|
119
|
+
"react": "*",
|
|
120
|
+
"react-native": "*",
|
|
121
|
+
"react-native-nitro-modules": "^0.33.7",
|
|
122
|
+
"react-native-permissions": ">=4.0.0",
|
|
123
|
+
"react-native-svg": ">=15.0.0"
|
|
124
|
+
},
|
|
125
|
+
"peerDependenciesMeta": {
|
|
126
|
+
"@react-native-community/netinfo": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
129
|
+
"@react-native-picker/picker": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"expo-checkbox": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"jail-monkey": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"react-native-permissions": {
|
|
139
|
+
"optional": true
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"workspaces": [
|
|
143
|
+
"example"
|
|
144
|
+
],
|
|
145
|
+
"packageManager": "yarn@4.11.0",
|
|
146
|
+
"react-native-builder-bob": {
|
|
147
|
+
"source": "src",
|
|
148
|
+
"output": "lib",
|
|
149
|
+
"targets": [
|
|
150
|
+
[
|
|
151
|
+
"module",
|
|
152
|
+
{
|
|
153
|
+
"esm": true
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
[
|
|
157
|
+
"typescript",
|
|
158
|
+
{
|
|
159
|
+
"project": "tsconfig.build.json"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
"prettier": {
|
|
165
|
+
"quoteProps": "consistent",
|
|
166
|
+
"singleQuote": true,
|
|
167
|
+
"tabWidth": 2,
|
|
168
|
+
"trailingComma": "es5",
|
|
169
|
+
"useTabs": false
|
|
170
|
+
},
|
|
171
|
+
"jest": {
|
|
172
|
+
"preset": "react-native",
|
|
173
|
+
"modulePathIgnorePatterns": [
|
|
174
|
+
"<rootDir>/example/node_modules",
|
|
175
|
+
"<rootDir>/lib/"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"commitlint": {
|
|
179
|
+
"extends": [
|
|
180
|
+
"@commitlint/config-conventional"
|
|
181
|
+
],
|
|
182
|
+
"rules": {
|
|
183
|
+
"body-max-line-length": [
|
|
184
|
+
0,
|
|
185
|
+
"always"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"release-it": {
|
|
190
|
+
"git": {
|
|
191
|
+
"commitMessage": "chore: release ${version}",
|
|
192
|
+
"tagName": "v${version}"
|
|
193
|
+
},
|
|
194
|
+
"npm": {
|
|
195
|
+
"publish": true
|
|
196
|
+
},
|
|
197
|
+
"github": {
|
|
198
|
+
"release": true
|
|
199
|
+
},
|
|
200
|
+
"plugins": {
|
|
201
|
+
"@release-it/conventional-changelog": {
|
|
202
|
+
"preset": {
|
|
203
|
+
"name": "angular"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"create-react-native-library": {
|
|
209
|
+
"type": "library",
|
|
210
|
+
"languages": "js",
|
|
211
|
+
"tools": [
|
|
212
|
+
"jest",
|
|
213
|
+
"lefthook",
|
|
214
|
+
"release-it"
|
|
215
|
+
],
|
|
216
|
+
"version": "0.57.0"
|
|
217
|
+
},
|
|
218
|
+
"dependencies": {
|
|
219
|
+
"@emotion/native": "^11.11.0",
|
|
220
|
+
"@emotion/react": "^11.14.0",
|
|
221
|
+
"@fnando/cnpj": "^2.0.0",
|
|
222
|
+
"@fnando/cpf": "^1.0.2",
|
|
223
|
+
"@tanstack/react-form": "^1.28.0",
|
|
224
|
+
"@tanstack/react-query": "^5.90.20",
|
|
225
|
+
"axios": "^1.13.5",
|
|
226
|
+
"date-fns": "^4.1.0",
|
|
227
|
+
"libphonenumber-js": "^1.12.36",
|
|
228
|
+
"lucide-react-native": "^0.563.0",
|
|
229
|
+
"react-native-mask-input": "^1.2.3",
|
|
230
|
+
"react-native-picker-select": "^9.3.1",
|
|
231
|
+
"zod": "^4.3.6",
|
|
232
|
+
"zustand": "^5.0.11"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import axios, {
|
|
2
|
+
type AxiosError,
|
|
3
|
+
type AxiosInstance,
|
|
4
|
+
type AxiosRequestConfig,
|
|
5
|
+
type AxiosResponse,
|
|
6
|
+
} from 'axios';
|
|
7
|
+
import {
|
|
8
|
+
AuthError,
|
|
9
|
+
NetworkError,
|
|
10
|
+
NotFoundError,
|
|
11
|
+
RateLimitError,
|
|
12
|
+
ServerError,
|
|
13
|
+
TimeoutError,
|
|
14
|
+
ValidationError,
|
|
15
|
+
} from './errors';
|
|
16
|
+
import { executeWithRetry } from './retry-strategy';
|
|
17
|
+
import { useAuthStore } from './stores/auth-store';
|
|
18
|
+
import type {
|
|
19
|
+
ApiConfig,
|
|
20
|
+
ApiResponse,
|
|
21
|
+
IHttpAdapter,
|
|
22
|
+
RetryConfig,
|
|
23
|
+
} from './types';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Axios-based HTTP adapter implementation
|
|
27
|
+
* Implements retry logic, error handling, and token management
|
|
28
|
+
*/
|
|
29
|
+
export class AxiosAdapter implements IHttpAdapter {
|
|
30
|
+
private readonly axiosInstance: AxiosInstance;
|
|
31
|
+
private readonly retryConfig: RetryConfig;
|
|
32
|
+
|
|
33
|
+
constructor(config: ApiConfig) {
|
|
34
|
+
// Initialize axios instance with configuration
|
|
35
|
+
this.axiosInstance = axios.create({
|
|
36
|
+
baseURL: config.baseURL,
|
|
37
|
+
timeout: config.timeout ?? 30000, // 30 seconds default
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
...config.headers,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Configure retry behavior
|
|
45
|
+
this.retryConfig = {
|
|
46
|
+
maxAttempts: config.retryAttempts ?? 3,
|
|
47
|
+
baseDelay: 1000, // 1 second
|
|
48
|
+
maxDelay: 10000, // 10 seconds
|
|
49
|
+
retryableStatusCodes: [408, 429, 500, 502, 503, 504],
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Setup request interceptor to inject auth token
|
|
53
|
+
this.setupRequestInterceptor();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Sets up request interceptor to automatically add auth token
|
|
58
|
+
*/
|
|
59
|
+
private setupRequestInterceptor(): void {
|
|
60
|
+
this.axiosInstance.interceptors.request.use(
|
|
61
|
+
(config) => {
|
|
62
|
+
const token = useAuthStore.getState().token;
|
|
63
|
+
|
|
64
|
+
if (token && config.headers) {
|
|
65
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return config;
|
|
69
|
+
},
|
|
70
|
+
(error) => Promise.reject(error),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Maps axios error to appropriate custom error type
|
|
76
|
+
*/
|
|
77
|
+
private mapError(error: AxiosError, url?: string, method?: string): Error {
|
|
78
|
+
// Network errors (no response received)
|
|
79
|
+
if (!error.response) {
|
|
80
|
+
if (error.code === 'ECONNABORTED' || error.message.includes('timeout')) {
|
|
81
|
+
return new TimeoutError(
|
|
82
|
+
'Request timeout - server took too long to respond',
|
|
83
|
+
url,
|
|
84
|
+
method,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return new NetworkError(
|
|
88
|
+
error.message || 'Network error - please check your connection',
|
|
89
|
+
url,
|
|
90
|
+
method,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const statusCode = error.response.status;
|
|
95
|
+
const responseData = error.response.data as {
|
|
96
|
+
message?: string;
|
|
97
|
+
errors?: Record<string, string[]>;
|
|
98
|
+
};
|
|
99
|
+
const message =
|
|
100
|
+
responseData?.message || error.message || 'An error occurred';
|
|
101
|
+
|
|
102
|
+
// Map status codes to error types
|
|
103
|
+
switch (true) {
|
|
104
|
+
case statusCode === 401 || statusCode === 403:
|
|
105
|
+
return new AuthError(message, statusCode, url, method);
|
|
106
|
+
|
|
107
|
+
case statusCode === 404:
|
|
108
|
+
return new NotFoundError(message, url, method);
|
|
109
|
+
|
|
110
|
+
case statusCode === 429:
|
|
111
|
+
return new RateLimitError(
|
|
112
|
+
message,
|
|
113
|
+
url,
|
|
114
|
+
method,
|
|
115
|
+
Number(error.response.headers['retry-after']),
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
case statusCode === 400 || statusCode === 422:
|
|
119
|
+
return new ValidationError(
|
|
120
|
+
message,
|
|
121
|
+
statusCode,
|
|
122
|
+
url,
|
|
123
|
+
method,
|
|
124
|
+
responseData?.errors,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
case statusCode >= 500:
|
|
128
|
+
return new ServerError(message, statusCode, url, method);
|
|
129
|
+
|
|
130
|
+
default:
|
|
131
|
+
return new NetworkError(message, url, method);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Transforms axios response to standardized ApiResponse format
|
|
137
|
+
*/
|
|
138
|
+
private transformResponse<T>(response: AxiosResponse<T>): ApiResponse<T> {
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
data: response.data,
|
|
142
|
+
statusCode: response.status,
|
|
143
|
+
error: '',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Transforms error to standardized ApiResponse format
|
|
149
|
+
*/
|
|
150
|
+
private transformError<T>(error: Error, statusCode = 0): ApiResponse<T> {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
data: null,
|
|
154
|
+
statusCode,
|
|
155
|
+
error: error.message,
|
|
156
|
+
} as ApiResponse<T>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Executes HTTP request with retry logic and error handling
|
|
161
|
+
*/
|
|
162
|
+
private async executeRequest<T>(
|
|
163
|
+
requestFn: () => Promise<AxiosResponse<T>>,
|
|
164
|
+
url?: string,
|
|
165
|
+
method?: string,
|
|
166
|
+
): Promise<ApiResponse<T>> {
|
|
167
|
+
try {
|
|
168
|
+
const response = await executeWithRetry(
|
|
169
|
+
requestFn,
|
|
170
|
+
this.retryConfig,
|
|
171
|
+
(attempt, delay, error) => {
|
|
172
|
+
console.log(
|
|
173
|
+
`[API Retry] Attempt ${attempt} failed, retrying in ${delay}ms...`,
|
|
174
|
+
error.message,
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return this.transformResponse(response);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
const mappedError = this.mapError(error as AxiosError, url, method);
|
|
182
|
+
const statusCode =
|
|
183
|
+
mappedError instanceof NetworkError
|
|
184
|
+
? 0
|
|
185
|
+
: ((mappedError as { statusCode?: number }).statusCode ?? 0);
|
|
186
|
+
|
|
187
|
+
console.error('[API Error]', mappedError);
|
|
188
|
+
|
|
189
|
+
return this.transformError(mappedError, statusCode);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Performs GET request
|
|
195
|
+
*/
|
|
196
|
+
async get<T = unknown>(
|
|
197
|
+
url: string,
|
|
198
|
+
config?: AxiosRequestConfig,
|
|
199
|
+
): Promise<ApiResponse<T>> {
|
|
200
|
+
return this.executeRequest(
|
|
201
|
+
() => this.axiosInstance.get<T>(url, config),
|
|
202
|
+
url,
|
|
203
|
+
'GET',
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Performs POST request
|
|
209
|
+
*/
|
|
210
|
+
async post<T = unknown>(
|
|
211
|
+
url: string,
|
|
212
|
+
data?: unknown,
|
|
213
|
+
config?: AxiosRequestConfig,
|
|
214
|
+
): Promise<ApiResponse<T>> {
|
|
215
|
+
return this.executeRequest(
|
|
216
|
+
() => this.axiosInstance.post<T>(url, data, config),
|
|
217
|
+
url,
|
|
218
|
+
'POST',
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Performs PUT request
|
|
224
|
+
*/
|
|
225
|
+
async put<T = unknown>(
|
|
226
|
+
url: string,
|
|
227
|
+
data?: unknown,
|
|
228
|
+
config?: AxiosRequestConfig,
|
|
229
|
+
): Promise<ApiResponse<T>> {
|
|
230
|
+
return this.executeRequest(
|
|
231
|
+
() => this.axiosInstance.put<T>(url, data, config),
|
|
232
|
+
url,
|
|
233
|
+
'PUT',
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Performs DELETE request
|
|
239
|
+
*/
|
|
240
|
+
async delete<T = unknown>(
|
|
241
|
+
url: string,
|
|
242
|
+
config?: AxiosRequestConfig,
|
|
243
|
+
): Promise<ApiResponse<T>> {
|
|
244
|
+
return this.executeRequest(
|
|
245
|
+
() => this.axiosInstance.delete<T>(url, config),
|
|
246
|
+
url,
|
|
247
|
+
'DELETE',
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Adds authentication token to store
|
|
253
|
+
* Token will be automatically included in all subsequent requests
|
|
254
|
+
*/
|
|
255
|
+
addToken(token: string): void {
|
|
256
|
+
useAuthStore.getState().setToken(token);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Removes authentication token from store
|
|
261
|
+
*/
|
|
262
|
+
removeToken(): void {
|
|
263
|
+
useAuthStore.getState().clearToken();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Get token from store
|
|
268
|
+
*/
|
|
269
|
+
getToken(): string | null {
|
|
270
|
+
return useAuthStore.getState().token;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all API errors
|
|
3
|
+
* Provides common structure and debugging information
|
|
4
|
+
*/
|
|
5
|
+
export class ApiError extends Error {
|
|
6
|
+
public readonly statusCode: number;
|
|
7
|
+
public readonly url?: string;
|
|
8
|
+
public readonly method?: string;
|
|
9
|
+
public readonly timestamp: Date;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
message: string,
|
|
13
|
+
statusCode: number,
|
|
14
|
+
url?: string,
|
|
15
|
+
method?: string,
|
|
16
|
+
) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = this.constructor.name;
|
|
19
|
+
this.statusCode = statusCode;
|
|
20
|
+
this.url = url;
|
|
21
|
+
this.method = method;
|
|
22
|
+
this.timestamp = new Date();
|
|
23
|
+
|
|
24
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
25
|
+
if (Error.captureStackTrace) {
|
|
26
|
+
Error.captureStackTrace(this, this.constructor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns a formatted error message for debugging
|
|
32
|
+
*/
|
|
33
|
+
toDebugString(): string {
|
|
34
|
+
return `[${this.name}] ${this.message}\nStatus: ${this.statusCode}\nURL: ${this.url}\nMethod: ${this.method}\nTime: ${this.timestamp.toISOString()}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Network-related errors (no internet, DNS failure, timeout)
|
|
40
|
+
* HTTP Status: N/A (network layer)
|
|
41
|
+
*/
|
|
42
|
+
export class NetworkError extends ApiError {
|
|
43
|
+
constructor(message: string, url?: string, method?: string) {
|
|
44
|
+
super(message, 0, url, method);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Authentication errors (401, 403)
|
|
50
|
+
* Client lacks valid credentials or permissions
|
|
51
|
+
*/
|
|
52
|
+
export class AuthError extends ApiError {}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Client validation errors (400, 422)
|
|
56
|
+
* Request malformed or validation failed
|
|
57
|
+
*/
|
|
58
|
+
export class ValidationError extends ApiError {
|
|
59
|
+
public readonly validationErrors?: Record<string, string[]>;
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
message: string,
|
|
63
|
+
statusCode: number,
|
|
64
|
+
url?: string,
|
|
65
|
+
method?: string,
|
|
66
|
+
validationErrors?: Record<string, string[]>,
|
|
67
|
+
) {
|
|
68
|
+
super(message, statusCode, url, method);
|
|
69
|
+
this.validationErrors = validationErrors;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Server errors (500, 502, 503, 504)
|
|
75
|
+
* Something went wrong on the server
|
|
76
|
+
*/
|
|
77
|
+
export class ServerError extends ApiError {}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Request timeout errors
|
|
81
|
+
* Request took too long to complete
|
|
82
|
+
*/
|
|
83
|
+
export class TimeoutError extends ApiError {
|
|
84
|
+
constructor(message: string, url?: string, method?: string) {
|
|
85
|
+
super(message, 408, url, method);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Resource not found errors (404)
|
|
91
|
+
*/
|
|
92
|
+
export class NotFoundError extends ApiError {
|
|
93
|
+
constructor(message: string, url?: string, method?: string) {
|
|
94
|
+
super(message, 404, url, method);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Rate limit errors (429)
|
|
100
|
+
*/
|
|
101
|
+
export class RateLimitError extends ApiError {
|
|
102
|
+
public readonly retryAfter?: number;
|
|
103
|
+
|
|
104
|
+
constructor(
|
|
105
|
+
message: string,
|
|
106
|
+
url?: string,
|
|
107
|
+
method?: string,
|
|
108
|
+
retryAfter?: number,
|
|
109
|
+
) {
|
|
110
|
+
super(message, 429, url, method);
|
|
111
|
+
this.retryAfter = retryAfter;
|
|
112
|
+
}
|
|
113
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AxiosAdapter } from './axios-adapter';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default API request instance
|
|
5
|
+
* Pre-configured with default settings
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { apiRequest } from '@navegarti/rn-design-system/api';
|
|
10
|
+
*
|
|
11
|
+
* const response = await apiRequest.get<User>('/users/123');
|
|
12
|
+
* if (response.success) {
|
|
13
|
+
* console.log(response.data);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const apiRequest = new AxiosAdapter({
|
|
18
|
+
baseURL: 'https://api.example.com', // Will be overridden by consumers
|
|
19
|
+
timeout: 30000,
|
|
20
|
+
retryAttempts: 3,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { AxiosAdapter } from './axios-adapter';
|
|
24
|
+
export * from './errors';
|
|
25
|
+
export { useAuthStore } from './stores/auth-store';
|
|
26
|
+
// Re-export types and classes for consumer use
|
|
27
|
+
export * from './types';
|