@audira/carbon-react-native 1.0.0-beta.7 → 1.0.0-beta.8
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/lib/commonjs/components/modal/Modal.js +19 -15
- package/lib/commonjs/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/Modal.js +19 -15
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/typescript/commonjs/components/modal/Modal.d.ts.map +1 -1
- package/lib/typescript/module/components/modal/Modal.d.ts.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/_internal/contexts/button-group/ButtonGroupContext.ts +25 -0
- package/src/_internal/contexts/button-group/index.tsx +1 -0
- package/src/_internal/contexts/global-config/GlobalConfigContext.ts +30 -0
- package/src/_internal/contexts/global-config/index.ts +1 -0
- package/src/_internal/contexts/index.ts +3 -0
- package/src/_internal/contexts/modal/ModalContext.ts +15 -0
- package/src/_internal/contexts/modal/index.ts +1 -0
- package/src/_internal/globals/breakpoint/index.ts +13 -0
- package/src/_internal/globals/color-scheme/index.ts +13 -0
- package/src/_internal/globals/index.ts +7 -0
- package/src/_internal/helpers/index.ts +5 -0
- package/src/_internal/helpers/math/clamp.ts +3 -0
- package/src/_internal/helpers/math/index.ts +1 -0
- package/src/_internal/providers/breakpoint/BreakpointProvider.tsx +42 -0
- package/src/_internal/providers/breakpoint/BreakpointProviderProps.ts +3 -0
- package/src/_internal/providers/breakpoint/index.tsx +2 -0
- package/src/_internal/providers/global-config/GlobalConfigProvider.tsx +30 -0
- package/src/_internal/providers/global-config/GlobalConfigProviderProps.ts +7 -0
- package/src/_internal/providers/global-config/index.tsx +2 -0
- package/src/_internal/providers/index.ts +3 -0
- package/src/_internal/providers/theme/ThemeProvider.tsx +45 -0
- package/src/_internal/providers/theme/ThemeProviderProps.ts +8 -0
- package/src/_internal/providers/theme/index.tsx +2 -0
- package/src/_internal/style-sheets/common-style-sheet.ts +24 -0
- package/src/_internal/style-sheets/flex-style-sheet.ts +84 -0
- package/src/_internal/style-sheets/index.ts +3 -0
- package/src/_internal/style-sheets/text-style-sheet.ts +62 -0
- package/src/carbon-react-native/CarbonReactNative.tsx +41 -0
- package/src/carbon-react-native/CarbonReactNativeProps.ts +7 -0
- package/src/carbon-react-native/index.tsx +2 -0
- package/src/carbon-style-sheet/breakpoint.ts +16 -0
- package/src/carbon-style-sheet/color.ts +13 -0
- package/src/carbon-style-sheet/create.ts +232 -0
- package/src/carbon-style-sheet/index.tsx +51 -0
- package/src/carbon-style-sheet/use.tsx +16 -0
- package/src/components/accordion/Accordion.tsx +132 -0
- package/src/components/accordion/AccordionHeaderProps.ts +17 -0
- package/src/components/accordion/AccordionItemProps.ts +24 -0
- package/src/components/accordion/AccordionItemRef.ts +10 -0
- package/src/components/accordion/AccordionProps.ts +19 -0
- package/src/components/accordion/AccordionRef.ts +6 -0
- package/src/components/accordion/AccordionSize.ts +4 -0
- package/src/components/accordion/_Header.tsx +201 -0
- package/src/components/accordion/_HeaderBorder.tsx +75 -0
- package/src/components/accordion/_Item.tsx +175 -0
- package/src/components/accordion/_ItemRefBase.ts +7 -0
- package/src/components/accordion/_chevron/Chevron.tsx +97 -0
- package/src/components/accordion/_chevron/ChevronProps.ts +10 -0
- package/src/components/accordion/_chevron/index.ts +2 -0
- package/src/components/accordion/_context.ts +20 -0
- package/src/components/accordion/_motion.ts +27 -0
- package/src/components/accordion/_styles.ts +24 -0
- package/src/components/accordion/index.tsx +7 -0
- package/src/components/button/Size.ts +7 -0
- package/src/components/button/base/Base.tsx +328 -0
- package/src/components/button/base/BaseProps.ts +60 -0
- package/src/components/button/base/BaseRef.ts +6 -0
- package/src/components/button/base/index.tsx +3 -0
- package/src/components/button/base-color/BaseColor.tsx +289 -0
- package/src/components/button/base-color/BaseColorProps.ts +32 -0
- package/src/components/button/base-color/BaseColorRef.ts +6 -0
- package/src/components/button/base-color/BaseColorState.ts +6 -0
- package/src/components/button/base-color/index.tsx +4 -0
- package/src/components/button/ghost/Ghost.tsx +165 -0
- package/src/components/button/ghost/GhostProps.ts +10 -0
- package/src/components/button/ghost/GhostRef.ts +6 -0
- package/src/components/button/ghost/index.tsx +3 -0
- package/src/components/button/ghost-danger/GhostDanger.tsx +165 -0
- package/src/components/button/ghost-danger/GhostDangerProps.ts +10 -0
- package/src/components/button/ghost-danger/GhostDangerRef.ts +6 -0
- package/src/components/button/ghost-danger/index.tsx +3 -0
- package/src/components/button/ghost-icon/GhostIcon.tsx +127 -0
- package/src/components/button/ghost-icon/GhostIconProps.ts +17 -0
- package/src/components/button/ghost-icon/GhostIconRef.ts +6 -0
- package/src/components/button/ghost-icon/index.tsx +3 -0
- package/src/components/button/index.tsx +11 -0
- package/src/components/button/primary/Primary.tsx +140 -0
- package/src/components/button/primary/PrimaryProps.ts +11 -0
- package/src/components/button/primary/PrimaryRef.ts +6 -0
- package/src/components/button/primary/index.tsx +3 -0
- package/src/components/button/primary-danger/PrimaryDanger.tsx +140 -0
- package/src/components/button/primary-danger/PrimaryDangerProps.ts +12 -0
- package/src/components/button/primary-danger/PrimaryDangerRef.ts +6 -0
- package/src/components/button/primary-danger/index.tsx +3 -0
- package/src/components/button/secondary/Secondary.tsx +140 -0
- package/src/components/button/secondary/SecondaryProps.ts +12 -0
- package/src/components/button/secondary/SecondaryRef.ts +6 -0
- package/src/components/button/secondary/index.tsx +3 -0
- package/src/components/button/tertiary/Tertiary.tsx +157 -0
- package/src/components/button/tertiary/TertiaryProps.ts +12 -0
- package/src/components/button/tertiary/TertiaryRef.ts +6 -0
- package/src/components/button/tertiary/index.tsx +3 -0
- package/src/components/button/tertiary-danger/TertiaryDanger.tsx +157 -0
- package/src/components/button/tertiary-danger/TertiaryDangerProps.ts +12 -0
- package/src/components/button/tertiary-danger/TertiaryDangerRef.ts +6 -0
- package/src/components/button/tertiary-danger/index.tsx +3 -0
- package/src/components/button-group/ButtonGroup.tsx +145 -0
- package/src/components/button-group/ButtonGroupProps.ts +37 -0
- package/src/components/button-group/ButtonGroupRef.ts +6 -0
- package/src/components/button-group/index.tsx +3 -0
- package/src/components/checkbox/Checkbox.tsx +221 -0
- package/src/components/checkbox/CheckboxProps.ts +39 -0
- package/src/components/checkbox/CheckboxRef.ts +10 -0
- package/src/components/checkbox/_RefBase.ts +11 -0
- package/src/components/checkbox/index.tsx +3 -0
- package/src/components/checkbox-group/CheckboxGroup.tsx +227 -0
- package/src/components/checkbox-group/CheckboxGroupHelperTextMode.ts +4 -0
- package/src/components/checkbox-group/CheckboxGroupProps.ts +28 -0
- package/src/components/checkbox-group/CheckboxGroupRef.ts +6 -0
- package/src/components/checkbox-group/index.tsx +4 -0
- package/src/components/checkbox-input/CheckboxInput.tsx +340 -0
- package/src/components/checkbox-input/CheckboxInputInteractiveState.ts +6 -0
- package/src/components/checkbox-input/CheckboxInputProps.ts +25 -0
- package/src/components/checkbox-input/CheckboxInputRef.ts +11 -0
- package/src/components/checkbox-input/CheckboxInputValue.ts +6 -0
- package/src/components/checkbox-input/_RefBase.ts +11 -0
- package/src/components/checkbox-input/index.tsx +5 -0
- package/src/components/collapsible/Collapsible.tsx +274 -0
- package/src/components/collapsible/CollapsibleProps.ts +17 -0
- package/src/components/collapsible/CollapsibleRef.ts +11 -0
- package/src/components/collapsible/_RefBase.ts +6 -0
- package/src/components/collapsible/index.ts +3 -0
- package/src/components/form-helper-text/FormHelperText.tsx +109 -0
- package/src/components/form-helper-text/FormHelperTextProps.ts +15 -0
- package/src/components/form-helper-text/FormHelperTextRef.ts +6 -0
- package/src/components/form-helper-text/index.tsx +3 -0
- package/src/components/form-label/FormLabel.tsx +85 -0
- package/src/components/form-label/FormLabelProps.ts +17 -0
- package/src/components/form-label/FormLabelRef.ts +6 -0
- package/src/components/form-label/index.tsx +3 -0
- package/src/components/icon/Icon.tsx +48 -0
- package/src/components/icon/IconProps.ts +11 -0
- package/src/components/icon/index.tsx +2 -0
- package/src/components/index.tsx +35 -0
- package/src/components/inline-loading/InlineLoading.tsx +144 -0
- package/src/components/inline-loading/InlineLoadingProps.ts +24 -0
- package/src/components/inline-loading/InlineLoadingRef.ts +6 -0
- package/src/components/inline-loading/InlineLoadingState.ts +5 -0
- package/src/components/inline-loading/index.tsx +4 -0
- package/src/components/layer/Layer.tsx +87 -0
- package/src/components/layer/LayerContext.ts +9 -0
- package/src/components/layer/LayerProps.ts +16 -0
- package/src/components/layer/LayerRef.ts +6 -0
- package/src/components/layer/index.tsx +4 -0
- package/src/components/loading/Loading.tsx +116 -0
- package/src/components/loading/LoadingProps.ts +14 -0
- package/src/components/loading/LoadingRef.ts +4 -0
- package/src/components/loading/LoadingType.ts +3 -0
- package/src/components/loading/_circular-progress/CircularProgress.tsx +113 -0
- package/src/components/loading/_circular-progress/CircularProgressProps.ts +18 -0
- package/src/components/loading/_circular-progress/index.ts +2 -0
- package/src/components/loading/_map-circle-background-color.ts +26 -0
- package/src/components/loading/_map-circle-stroke-color.ts +13 -0
- package/src/components/loading/index.ts +4 -0
- package/src/components/modal/Modal.tsx +397 -0
- package/src/components/modal/ModalProps.ts +24 -0
- package/src/components/modal/ModalRef.ts +6 -0
- package/src/components/modal/ModalSize.ts +5 -0
- package/src/components/modal/index.tsx +4 -0
- package/src/components/modal-content/ModalContent.tsx +182 -0
- package/src/components/modal-content/ModalContentProps.ts +7 -0
- package/src/components/modal-content/ModalContentRef.ts +6 -0
- package/src/components/modal-content/index.tsx +3 -0
- package/src/components/notification/NotificationColor.ts +3 -0
- package/src/components/notification/_VariantContextProvider.tsx +39 -0
- package/src/components/notification/_status-hooks/_base/UseBaseData.ts +11 -0
- package/src/components/notification/_status-hooks/_base/UseBaseProps.ts +21 -0
- package/src/components/notification/_status-hooks/_base/index.tsx +3 -0
- package/src/components/notification/_status-hooks/_base/useBase.tsx +77 -0
- package/src/components/notification/_status-hooks/error/UseErrorData.ts +11 -0
- package/src/components/notification/_status-hooks/error/UseErrorProps.ts +8 -0
- package/src/components/notification/_status-hooks/error/index.tsx +3 -0
- package/src/components/notification/_status-hooks/error/useError.tsx +122 -0
- package/src/components/notification/_status-hooks/index.tsx +4 -0
- package/src/components/notification/_status-hooks/informational/UseInformationalData.ts +11 -0
- package/src/components/notification/_status-hooks/informational/UseInformationalProps.ts +8 -0
- package/src/components/notification/_status-hooks/informational/index.tsx +3 -0
- package/src/components/notification/_status-hooks/informational/useInformational.tsx +122 -0
- package/src/components/notification/_status-hooks/success/UseSuccessData.ts +11 -0
- package/src/components/notification/_status-hooks/success/UseSuccessProps.ts +8 -0
- package/src/components/notification/_status-hooks/success/index.tsx +3 -0
- package/src/components/notification/_status-hooks/success/useSuccess.tsx +122 -0
- package/src/components/notification/_status-hooks/warning/UseWarningData.ts +11 -0
- package/src/components/notification/_status-hooks/warning/UseWarningProps.ts +8 -0
- package/src/components/notification/_status-hooks/warning/index.tsx +3 -0
- package/src/components/notification/_status-hooks/warning/useWarning.tsx +122 -0
- package/src/components/notification/_variant-context.ts +15 -0
- package/src/components/notification/_variants/_ButtonGhost.tsx +73 -0
- package/src/components/notification/_variants/_ButtonTertiary.tsx +73 -0
- package/src/components/notification/_variants/actionable/ActionableVariant.tsx +70 -0
- package/src/components/notification/_variants/actionable/ActionableVariantProps.ts +46 -0
- package/src/components/notification/_variants/actionable/ActionableVariantRef.ts +6 -0
- package/src/components/notification/_variants/actionable/index.tsx +3 -0
- package/src/components/notification/_variants/actionable-inline/ActionableInlineVariant.tsx +70 -0
- package/src/components/notification/_variants/actionable-inline/ActionableInlineVariantProps.ts +46 -0
- package/src/components/notification/_variants/actionable-inline/ActionableInlineVariantRef.ts +6 -0
- package/src/components/notification/_variants/actionable-inline/index.tsx +3 -0
- package/src/components/notification/_variants/callout/CalloutVariant.tsx +59 -0
- package/src/components/notification/_variants/callout/CalloutVariantProps.ts +26 -0
- package/src/components/notification/_variants/callout/CalloutVariantRef.ts +6 -0
- package/src/components/notification/_variants/callout/index.tsx +3 -0
- package/src/components/notification/_variants/callout-inline/CalloutInlineVariant.tsx +59 -0
- package/src/components/notification/_variants/callout-inline/CalloutInlineVariantProps.ts +26 -0
- package/src/components/notification/_variants/callout-inline/CalloutInlineVariantRef.ts +6 -0
- package/src/components/notification/_variants/callout-inline/index.tsx +3 -0
- package/src/components/notification/_variants/index.tsx +5 -0
- package/src/components/notification/_variants/toast/ToastVariant.tsx +115 -0
- package/src/components/notification/_variants/toast/ToastVariantProps.ts +30 -0
- package/src/components/notification/_variants/toast/ToastVariantRef.ts +6 -0
- package/src/components/notification/_variants/toast/index.tsx +3 -0
- package/src/components/notification/actionable/error/Error.tsx +78 -0
- package/src/components/notification/actionable/error/ErrorProps.ts +14 -0
- package/src/components/notification/actionable/error/ErrorRef.ts +6 -0
- package/src/components/notification/actionable/error/index.tsx +3 -0
- package/src/components/notification/actionable/index.tsx +4 -0
- package/src/components/notification/actionable/informational/Informational.tsx +78 -0
- package/src/components/notification/actionable/informational/InformationalProps.ts +14 -0
- package/src/components/notification/actionable/informational/InformationalRef.ts +6 -0
- package/src/components/notification/actionable/informational/index.tsx +3 -0
- package/src/components/notification/actionable/success/Success.tsx +78 -0
- package/src/components/notification/actionable/success/SuccessProps.ts +14 -0
- package/src/components/notification/actionable/success/SuccessRef.ts +6 -0
- package/src/components/notification/actionable/success/index.tsx +3 -0
- package/src/components/notification/actionable/warning/Warning.tsx +78 -0
- package/src/components/notification/actionable/warning/WarningProps.ts +14 -0
- package/src/components/notification/actionable/warning/WarningRef.ts +6 -0
- package/src/components/notification/actionable/warning/index.tsx +3 -0
- package/src/components/notification/actionable-inline/error/Error.tsx +77 -0
- package/src/components/notification/actionable-inline/error/ErrorProps.ts +14 -0
- package/src/components/notification/actionable-inline/error/ErrorRef.ts +6 -0
- package/src/components/notification/actionable-inline/error/index.tsx +3 -0
- package/src/components/notification/actionable-inline/index.tsx +4 -0
- package/src/components/notification/actionable-inline/informational/Informational.tsx +77 -0
- package/src/components/notification/actionable-inline/informational/InformationalProps.ts +14 -0
- package/src/components/notification/actionable-inline/informational/InformationalRef.ts +6 -0
- package/src/components/notification/actionable-inline/informational/index.tsx +3 -0
- package/src/components/notification/actionable-inline/success/Success.tsx +77 -0
- package/src/components/notification/actionable-inline/success/SuccessProps.ts +14 -0
- package/src/components/notification/actionable-inline/success/SuccessRef.ts +6 -0
- package/src/components/notification/actionable-inline/success/index.tsx +3 -0
- package/src/components/notification/actionable-inline/warning/Warning.tsx +77 -0
- package/src/components/notification/actionable-inline/warning/WarningProps.ts +14 -0
- package/src/components/notification/actionable-inline/warning/WarningRef.ts +6 -0
- package/src/components/notification/actionable-inline/warning/index.tsx +3 -0
- package/src/components/notification/base/Base.tsx +292 -0
- package/src/components/notification/base/BaseProps.ts +59 -0
- package/src/components/notification/base/BaseRef.ts +6 -0
- package/src/components/notification/base/index.tsx +3 -0
- package/src/components/notification/callout/error/Error.tsx +78 -0
- package/src/components/notification/callout/error/ErrorProps.ts +14 -0
- package/src/components/notification/callout/error/ErrorRef.ts +6 -0
- package/src/components/notification/callout/error/index.tsx +3 -0
- package/src/components/notification/callout/index.tsx +4 -0
- package/src/components/notification/callout/informational/Informational.tsx +78 -0
- package/src/components/notification/callout/informational/InformationalProps.ts +14 -0
- package/src/components/notification/callout/informational/InformationalRef.ts +6 -0
- package/src/components/notification/callout/informational/index.tsx +3 -0
- package/src/components/notification/callout/success/Success.tsx +78 -0
- package/src/components/notification/callout/success/SuccessProps.ts +14 -0
- package/src/components/notification/callout/success/SuccessRef.ts +6 -0
- package/src/components/notification/callout/success/index.tsx +3 -0
- package/src/components/notification/callout/warning/Warning.tsx +78 -0
- package/src/components/notification/callout/warning/WarningProps.ts +14 -0
- package/src/components/notification/callout/warning/WarningRef.ts +6 -0
- package/src/components/notification/callout/warning/index.tsx +3 -0
- package/src/components/notification/callout-inline/error/Error.tsx +77 -0
- package/src/components/notification/callout-inline/error/ErrorProps.ts +14 -0
- package/src/components/notification/callout-inline/error/ErrorRef.ts +6 -0
- package/src/components/notification/callout-inline/error/index.tsx +3 -0
- package/src/components/notification/callout-inline/index.tsx +4 -0
- package/src/components/notification/callout-inline/informational/Informational.tsx +77 -0
- package/src/components/notification/callout-inline/informational/InformationalProps.ts +14 -0
- package/src/components/notification/callout-inline/informational/InformationalRef.ts +6 -0
- package/src/components/notification/callout-inline/informational/index.tsx +3 -0
- package/src/components/notification/callout-inline/success/Success.tsx +77 -0
- package/src/components/notification/callout-inline/success/SuccessProps.ts +14 -0
- package/src/components/notification/callout-inline/success/SuccessRef.ts +6 -0
- package/src/components/notification/callout-inline/success/index.tsx +3 -0
- package/src/components/notification/callout-inline/warning/Warning.tsx +77 -0
- package/src/components/notification/callout-inline/warning/WarningProps.ts +14 -0
- package/src/components/notification/callout-inline/warning/WarningRef.ts +6 -0
- package/src/components/notification/callout-inline/warning/index.tsx +3 -0
- package/src/components/notification/index.tsx +18 -0
- package/src/components/notification/subtitle/Subtitle.tsx +75 -0
- package/src/components/notification/subtitle/SubtitleProps.ts +6 -0
- package/src/components/notification/subtitle/SubtitleRef.ts +6 -0
- package/src/components/notification/subtitle/index.tsx +3 -0
- package/src/components/notification/subtitle-link/SubtitleLink.tsx +74 -0
- package/src/components/notification/subtitle-link/SubtitleLinkProps.ts +6 -0
- package/src/components/notification/subtitle-link/SubtitleLinkRef.ts +6 -0
- package/src/components/notification/subtitle-link/index.tsx +3 -0
- package/src/components/notification/toast/error/Error.tsx +78 -0
- package/src/components/notification/toast/error/ErrorProps.ts +14 -0
- package/src/components/notification/toast/error/ErrorRef.ts +6 -0
- package/src/components/notification/toast/error/index.tsx +3 -0
- package/src/components/notification/toast/index.tsx +4 -0
- package/src/components/notification/toast/informational/Informational.tsx +78 -0
- package/src/components/notification/toast/informational/InformationalProps.ts +14 -0
- package/src/components/notification/toast/informational/InformationalRef.ts +6 -0
- package/src/components/notification/toast/informational/index.tsx +3 -0
- package/src/components/notification/toast/success/Success.tsx +78 -0
- package/src/components/notification/toast/success/SuccessProps.ts +14 -0
- package/src/components/notification/toast/success/SuccessRef.ts +6 -0
- package/src/components/notification/toast/success/index.tsx +3 -0
- package/src/components/notification/toast/warning/Warning.tsx +78 -0
- package/src/components/notification/toast/warning/WarningProps.ts +14 -0
- package/src/components/notification/toast/warning/WarningRef.ts +6 -0
- package/src/components/notification/toast/warning/index.tsx +3 -0
- package/src/components/radio-button/RadioButton.tsx +216 -0
- package/src/components/radio-button/RadioButtonProps.ts +44 -0
- package/src/components/radio-button/RadioButtonRef.ts +10 -0
- package/src/components/radio-button/_RefBase.ts +11 -0
- package/src/components/radio-button/index.tsx +3 -0
- package/src/components/radio-button-group/RadioButtonGroup.tsx +246 -0
- package/src/components/radio-button-group/RadioButtonGroupHelperTextMode.ts +4 -0
- package/src/components/radio-button-group/RadioButtonGroupItemProps.ts +10 -0
- package/src/components/radio-button-group/RadioButtonGroupItemRef.ts +6 -0
- package/src/components/radio-button-group/RadioButtonGroupProps.ts +35 -0
- package/src/components/radio-button-group/RadioButtonGroupRef.ts +10 -0
- package/src/components/radio-button-group/_Item.tsx +101 -0
- package/src/components/radio-button-group/_RefBase.ts +11 -0
- package/src/components/radio-button-group/_item-context.tsx +18 -0
- package/src/components/radio-button-group/index.tsx +6 -0
- package/src/components/radio-button-input/RadioButtonInput.tsx +295 -0
- package/src/components/radio-button-input/RadioButtonInputInteractiveState.ts +6 -0
- package/src/components/radio-button-input/RadioButtonInputProps.ts +25 -0
- package/src/components/radio-button-input/RadioButtonInputRef.ts +10 -0
- package/src/components/radio-button-input/_RefBase.ts +7 -0
- package/src/components/radio-button-input/index.tsx +4 -0
- package/src/components/switch/Switch.tsx +487 -0
- package/src/components/switch/SwitchProps.ts +38 -0
- package/src/components/switch/SwitchRef.ts +10 -0
- package/src/components/switch/SwitchSize.ts +4 -0
- package/src/components/switch/SwitchState.ts +4 -0
- package/src/components/switch/_RefBase.ts +7 -0
- package/src/components/switch/index.ts +5 -0
- package/src/components/text/Text.tsx +171 -0
- package/src/components/text/TextProps.ts +20 -0
- package/src/components/text/TextRef.ts +6 -0
- package/src/components/text/index.ts +3 -0
- package/src/components/text-area/TextArea.tsx +266 -0
- package/src/components/text-area/TextAreaProps.ts +13 -0
- package/src/components/text-area/TextAreaRef.ts +10 -0
- package/src/components/text-area/_TextAreaRefBase.ts +7 -0
- package/src/components/text-area/index.tsx +3 -0
- package/src/components/text-area-field/TextAreaField.tsx +75 -0
- package/src/components/text-area-field/TextAreaFieldInteractiveState.ts +5 -0
- package/src/components/text-area-field/TextAreaFieldProps.ts +6 -0
- package/src/components/text-area-field/TextAreaFieldRef.ts +6 -0
- package/src/components/text-area-field/index.tsx +4 -0
- package/src/components/text-area-fluid/TextAreaFluid.tsx +157 -0
- package/src/components/text-area-fluid/TextAreaFluidProps.ts +13 -0
- package/src/components/text-area-fluid/TextAreaFluidRef.ts +6 -0
- package/src/components/text-area-fluid/index.tsx +3 -0
- package/src/components/text-input/TextInput.tsx +270 -0
- package/src/components/text-input/TextInputProps.ts +13 -0
- package/src/components/text-input/TextInputRef.ts +10 -0
- package/src/components/text-input/TextInputSize.ts +5 -0
- package/src/components/text-input/_TextInputRefBase.ts +7 -0
- package/src/components/text-input/index.ts +4 -0
- package/src/components/text-input-field/TextInputField.tsx +435 -0
- package/src/components/text-input-field/TextInputFieldInteractiveState.ts +6 -0
- package/src/components/text-input-field/TextInputFieldProps.ts +31 -0
- package/src/components/text-input-field/TextInputFieldRef.ts +8 -0
- package/src/components/text-input-field/TextInputFieldSize.ts +4 -0
- package/src/components/text-input-field/_rn-text-input/RNTextInput.tsx +161 -0
- package/src/components/text-input-field/_rn-text-input/RNTextInputProps.ts +11 -0
- package/src/components/text-input-field/_rn-text-input/RNTextInputRef.ts +6 -0
- package/src/components/text-input-field/_rn-text-input/index.ts +3 -0
- package/src/components/text-input-field/index.tsx +5 -0
- package/src/components/text-input-fluid/TextInputFluid.tsx +166 -0
- package/src/components/text-input-fluid/TextInputFluidProps.ts +14 -0
- package/src/components/text-input-fluid/TextInputFluidRef.ts +6 -0
- package/src/components/text-input-fluid/index.tsx +3 -0
- package/src/components/toggle/State.ts +5 -0
- package/src/components/toggle/base/Base.tsx +302 -0
- package/src/components/toggle/base/BaseProps.ts +54 -0
- package/src/components/toggle/base/BaseRef.ts +10 -0
- package/src/components/toggle/base/_RefBase.ts +11 -0
- package/src/components/toggle/base/index.tsx +3 -0
- package/src/components/toggle/default/Default.tsx +38 -0
- package/src/components/toggle/default/DefaultProps.ts +9 -0
- package/src/components/toggle/default/DefaultRef.ts +6 -0
- package/src/components/toggle/default/index.tsx +3 -0
- package/src/components/toggle/index.tsx +4 -0
- package/src/components/toggle/small/Small.tsx +38 -0
- package/src/components/toggle/small/SmallProps.ts +7 -0
- package/src/components/toggle/small/SmallRef.ts +6 -0
- package/src/components/toggle/small/index.tsx +3 -0
- package/src/const/dialog-animation-configs/carbon-react.ts +53 -0
- package/src/const/dialog-animation-configs/fade-bottom-up-2.ts +36 -0
- package/src/const/dialog-animation-configs/fade-bottom-up.ts +36 -0
- package/src/const/dialog-animation-configs/index.ts +3 -0
- package/src/const/index.ts +5 -0
- package/src/contexts/breakpoint/BreakpointContext.ts +19 -0
- package/src/contexts/breakpoint/index.ts +1 -0
- package/src/contexts/dialog/DialogContext.ts +27 -0
- package/src/contexts/dialog/DialogData.ts +27 -0
- package/src/contexts/dialog/DialogType.ts +7 -0
- package/src/contexts/dialog/index.ts +2 -0
- package/src/contexts/index.ts +4 -0
- package/src/contexts/theme/ThemeContext.ts +24 -0
- package/src/contexts/theme/index.ts +1 -0
- package/src/contexts/toast/ToastContext.ts +24 -0
- package/src/contexts/toast/ToastContextShowConfig.ts +6 -0
- package/src/contexts/toast/index.ts +2 -0
- package/src/helpers/breakpoint/get-token.ts +20 -0
- package/src/helpers/breakpoint/index.ts +1 -0
- package/src/helpers/color/get-color-scheme.ts +19 -0
- package/src/helpers/color/get-color-token.ts +23 -0
- package/src/helpers/color/hex-to-rgba.ts +11 -0
- package/src/helpers/color/index.ts +3 -0
- package/src/helpers/index.ts +7 -0
- package/src/hooks/breakpoint/index.tsx +1 -0
- package/src/hooks/breakpoint/use.tsx +30 -0
- package/src/hooks/index.tsx +9 -0
- package/src/index.ts +9 -0
- package/src/providers/dialog/DialogProvider.tsx +122 -0
- package/src/providers/dialog/DialogProviderAnimationConfig.ts +49 -0
- package/src/providers/dialog/DialogProviderProps.ts +28 -0
- package/src/providers/dialog/DialogProviderRef.ts +6 -0
- package/src/providers/dialog/_controller/Controller.tsx +223 -0
- package/src/providers/dialog/_controller/ControllerProps.ts +11 -0
- package/src/providers/dialog/_controller/ControllerRef.ts +6 -0
- package/src/providers/dialog/_controller/_modal/Modal.tsx +148 -0
- package/src/providers/dialog/_controller/_modal/ModalProps.ts +11 -0
- package/src/providers/dialog/_controller/_modal/ModalRef.ts +8 -0
- package/src/providers/dialog/_controller/_modal/_Interpolation.ts +9 -0
- package/src/providers/dialog/_controller/_modal/index.ts +3 -0
- package/src/providers/dialog/_controller/_overlay/Overlay.tsx +132 -0
- package/src/providers/dialog/_controller/_overlay/OverlayProps.ts +9 -0
- package/src/providers/dialog/_controller/_overlay/OverlayRef.ts +10 -0
- package/src/providers/dialog/_controller/_overlay/_OverlayRefBase.ts +3 -0
- package/src/providers/dialog/_controller/_overlay/index.ts +3 -0
- package/src/providers/dialog/_controller/index.ts +3 -0
- package/src/providers/dialog/index.ts +4 -0
- package/src/providers/index.ts +2 -0
- package/src/providers/toast/ToastProvider.tsx +73 -0
- package/src/providers/toast/ToastProviderProps.ts +3 -0
- package/src/providers/toast/ToastRef.ts +6 -0
- package/src/providers/toast/_overlay/Overlay.tsx +208 -0
- package/src/providers/toast/_overlay/OverlayRef.ts +6 -0
- package/src/providers/toast/_overlay/_component-wrapper/ComponentWrapper.tsx +168 -0
- package/src/providers/toast/_overlay/_component-wrapper/ComponentWrapperProps.ts +8 -0
- package/src/providers/toast/_overlay/_component-wrapper/ComponentWrapperRef.ts +6 -0
- package/src/providers/toast/_overlay/_component-wrapper/index.ts +3 -0
- package/src/providers/toast/_overlay/index.ts +2 -0
- package/src/providers/toast/index.tsx +3 -0
- package/src/types/index.ts +7 -0
- package/src/types/shared.ts +1 -0
- package/src/types/theme/ColorScheme.ts +1 -0
- package/src/types/theme/index.ts +1 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react"
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
Pressable,
|
|
12
|
+
StyleSheet,
|
|
13
|
+
} from "react-native"
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
DialogAnimationConfigs,
|
|
17
|
+
} from "../../../const"
|
|
18
|
+
|
|
19
|
+
import type {
|
|
20
|
+
DialogData,
|
|
21
|
+
} from "../../../contexts/dialog/DialogData"
|
|
22
|
+
|
|
23
|
+
import type {
|
|
24
|
+
DialogProviderAnimationConfig,
|
|
25
|
+
} from "../DialogProviderAnimationConfig"
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
ControllerProps,
|
|
29
|
+
} from "./ControllerProps"
|
|
30
|
+
|
|
31
|
+
import type {
|
|
32
|
+
ControllerRef,
|
|
33
|
+
} from "./ControllerRef"
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
Modal,
|
|
37
|
+
type ModalRef,
|
|
38
|
+
} from "./_modal"
|
|
39
|
+
|
|
40
|
+
import {
|
|
41
|
+
Overlay,
|
|
42
|
+
type OverlayRef,
|
|
43
|
+
} from "./_overlay"
|
|
44
|
+
|
|
45
|
+
export const Controller = forwardRef<ControllerRef, ControllerProps>(
|
|
46
|
+
function Controller(
|
|
47
|
+
{
|
|
48
|
+
animationConfig,
|
|
49
|
+
modalProps,
|
|
50
|
+
overlayProps,
|
|
51
|
+
overlayTouchDismiss,
|
|
52
|
+
onEmpty,
|
|
53
|
+
},
|
|
54
|
+
ref,
|
|
55
|
+
) {
|
|
56
|
+
|
|
57
|
+
const
|
|
58
|
+
[data, setData] =
|
|
59
|
+
useState<DialogDataState[]>([]),
|
|
60
|
+
|
|
61
|
+
modalRefs =
|
|
62
|
+
useRef<ModalRef[]>([]),
|
|
63
|
+
|
|
64
|
+
overlayRef =
|
|
65
|
+
useRef<OverlayRef>(null),
|
|
66
|
+
|
|
67
|
+
initialRender =
|
|
68
|
+
useRef(false),
|
|
69
|
+
|
|
70
|
+
setModalRef =
|
|
71
|
+
useCallback((
|
|
72
|
+
modalRef: ModalRef | null,
|
|
73
|
+
index: number,
|
|
74
|
+
) => {
|
|
75
|
+
if(modalRef && !modalRefs.current[index]) {
|
|
76
|
+
modalRefs.current[index] = modalRef
|
|
77
|
+
}
|
|
78
|
+
}, []),
|
|
79
|
+
|
|
80
|
+
dismissAllHandler: ControllerRef["dismissAll"] =
|
|
81
|
+
useCallback(() => {
|
|
82
|
+
if(modalRefs.current.length) {
|
|
83
|
+
return new Promise(resolve => {
|
|
84
|
+
Promise
|
|
85
|
+
.all([
|
|
86
|
+
overlayRef.current?.animateUnmount() ?? Promise.resolve(),
|
|
87
|
+
modalRefs.current[modalRefs.current.length - 1]?.toState(2) ?? Promise.resolve(),
|
|
88
|
+
])
|
|
89
|
+
.then(() => {
|
|
90
|
+
setData([])
|
|
91
|
+
// modalRefs.current = []
|
|
92
|
+
resolve()
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
return Promise.resolve()
|
|
97
|
+
}, []),
|
|
98
|
+
|
|
99
|
+
dismissHandler: ControllerRef["dismiss"] =
|
|
100
|
+
useCallback(() => {
|
|
101
|
+
if(modalRefs.current.length) {
|
|
102
|
+
return new Promise(resolve => {
|
|
103
|
+
if(modalRefs.current.length == 1) {
|
|
104
|
+
dismissAllHandler()
|
|
105
|
+
} else {
|
|
106
|
+
modalRefs.current[modalRefs.current.length - 1]?.toState(2).then(() => {
|
|
107
|
+
modalRefs.current.splice(modalRefs.current.length - 1, 1)
|
|
108
|
+
modalRefs.current[modalRefs.current.length - 1]?.fromToState(0, 1).then(() => {
|
|
109
|
+
setData(curr => {
|
|
110
|
+
const nextData = curr.slice()
|
|
111
|
+
nextData.splice(nextData.length - 1, 1)
|
|
112
|
+
return nextData
|
|
113
|
+
})
|
|
114
|
+
resolve()
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return Promise.resolve()
|
|
122
|
+
}, [
|
|
123
|
+
dismissAllHandler,
|
|
124
|
+
])
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if(!initialRender.current) {
|
|
128
|
+
initialRender.current = true
|
|
129
|
+
} else {
|
|
130
|
+
if(!data.length) {
|
|
131
|
+
onEmpty()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, [
|
|
135
|
+
onEmpty,
|
|
136
|
+
data.length,
|
|
137
|
+
])
|
|
138
|
+
|
|
139
|
+
useImperativeHandle(ref, () => {
|
|
140
|
+
return {
|
|
141
|
+
show({
|
|
142
|
+
stack,
|
|
143
|
+
...restData
|
|
144
|
+
}) {
|
|
145
|
+
if(!modalRefs.current.length) {
|
|
146
|
+
setData([{ ...restData }])
|
|
147
|
+
} else {
|
|
148
|
+
modalRefs.current[modalRefs.current.length - 1]?.toState(2).then(() => {
|
|
149
|
+
if(stack) {
|
|
150
|
+
setData(curr => {
|
|
151
|
+
return [
|
|
152
|
+
...curr,
|
|
153
|
+
{ ...restData },
|
|
154
|
+
]
|
|
155
|
+
})
|
|
156
|
+
} else {
|
|
157
|
+
modalRefs.current.splice(modalRefs.current.length - 1, 1)
|
|
158
|
+
setData([{ ...restData }])
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
dismiss: dismissHandler,
|
|
164
|
+
dismissAll: dismissAllHandler,
|
|
165
|
+
}
|
|
166
|
+
}, [
|
|
167
|
+
dismissHandler,
|
|
168
|
+
dismissAllHandler,
|
|
169
|
+
])
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Overlay
|
|
173
|
+
ref={ overlayRef }
|
|
174
|
+
{ ...overlayProps }
|
|
175
|
+
animationConfig={{
|
|
176
|
+
duration:
|
|
177
|
+
getSingleAnimationConfigDuration(animationConfig?.duration) ??
|
|
178
|
+
DialogAnimationConfigs.CarbonReact.duration,
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
{ data.map((item, index) => {
|
|
182
|
+
return (
|
|
183
|
+
<Modal
|
|
184
|
+
{ ...modalProps }
|
|
185
|
+
key={ index }
|
|
186
|
+
animationConfig={ animationConfig }
|
|
187
|
+
ref={ modalRef => setModalRef(modalRef, index) }
|
|
188
|
+
>
|
|
189
|
+
{ (item.overlayTouchDismiss ?? overlayTouchDismiss) && (
|
|
190
|
+
<Pressable
|
|
191
|
+
onPress={ dismissHandler as () => void }
|
|
192
|
+
style={ StyleSheet.absoluteFill }
|
|
193
|
+
/>
|
|
194
|
+
) }
|
|
195
|
+
|
|
196
|
+
{ item.component }
|
|
197
|
+
</Modal>
|
|
198
|
+
)
|
|
199
|
+
}) }
|
|
200
|
+
</Overlay>
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
},
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
type DialogDataState =
|
|
207
|
+
Omit<
|
|
208
|
+
DialogData,
|
|
209
|
+
// | 'type'
|
|
210
|
+
| "stack"
|
|
211
|
+
>
|
|
212
|
+
|
|
213
|
+
function getSingleAnimationConfigDuration(duration: DialogProviderAnimationConfig["duration"]) {
|
|
214
|
+
if(typeof duration === "number") {
|
|
215
|
+
return duration
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if(duration) {
|
|
219
|
+
return duration[0]
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return undefined
|
|
223
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useEffect,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
} from "react"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Animated,
|
|
10
|
+
StyleSheet,
|
|
11
|
+
} from "react-native"
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
FlexStyleSheet,
|
|
15
|
+
} from "../../../../_internal/style-sheets"
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
DialogAnimationConfigs,
|
|
19
|
+
} from "../../../../const"
|
|
20
|
+
|
|
21
|
+
import type {
|
|
22
|
+
ModalProps,
|
|
23
|
+
} from "./ModalProps"
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
ModalRef,
|
|
27
|
+
} from "./ModalRef"
|
|
28
|
+
|
|
29
|
+
export const Modal = forwardRef<ModalRef, ModalProps>(
|
|
30
|
+
function(
|
|
31
|
+
{
|
|
32
|
+
animationConfig = DialogAnimationConfigs.CarbonReact,
|
|
33
|
+
style,
|
|
34
|
+
...props
|
|
35
|
+
},
|
|
36
|
+
ref,
|
|
37
|
+
) {
|
|
38
|
+
|
|
39
|
+
const
|
|
40
|
+
initialAnimation =
|
|
41
|
+
useRef(false),
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* - 0 = unmounted
|
|
45
|
+
* - 1 = mounted
|
|
46
|
+
* - 2 = hidden behind of next dialog
|
|
47
|
+
*/
|
|
48
|
+
interpolation =
|
|
49
|
+
useRef(new Animated.Value(0))
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if(!initialAnimation.current) {
|
|
53
|
+
initialAnimation.current = true
|
|
54
|
+
Animated.timing(
|
|
55
|
+
interpolation.current,
|
|
56
|
+
{
|
|
57
|
+
toValue: 1,
|
|
58
|
+
duration: Array.isArray(animationConfig.duration)
|
|
59
|
+
? animationConfig.duration[1]
|
|
60
|
+
: animationConfig.duration,
|
|
61
|
+
easing: Array.isArray(animationConfig.modalEasing)
|
|
62
|
+
? animationConfig.modalEasing[1]
|
|
63
|
+
: animationConfig.modalEasing,
|
|
64
|
+
useNativeDriver: true,
|
|
65
|
+
},
|
|
66
|
+
).start()
|
|
67
|
+
}
|
|
68
|
+
}, [
|
|
69
|
+
animationConfig,
|
|
70
|
+
interpolation,
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
useImperativeHandle(ref, () => {
|
|
74
|
+
return {
|
|
75
|
+
toState(value) {
|
|
76
|
+
return new Promise(resolve => {
|
|
77
|
+
Animated
|
|
78
|
+
.timing(
|
|
79
|
+
interpolation.current,
|
|
80
|
+
{
|
|
81
|
+
toValue: value,
|
|
82
|
+
duration: Array.isArray(animationConfig.duration)
|
|
83
|
+
? animationConfig.duration[value]
|
|
84
|
+
: animationConfig.duration,
|
|
85
|
+
easing: Array.isArray(animationConfig.modalEasing)
|
|
86
|
+
? animationConfig.modalEasing[value]
|
|
87
|
+
: animationConfig.modalEasing,
|
|
88
|
+
useNativeDriver: true,
|
|
89
|
+
},
|
|
90
|
+
)
|
|
91
|
+
.start(({ finished }) => {
|
|
92
|
+
if(finished) {
|
|
93
|
+
resolve()
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
},
|
|
98
|
+
fromToState(from, to) {
|
|
99
|
+
return new Promise(resolve => {
|
|
100
|
+
Animated
|
|
101
|
+
.sequence([
|
|
102
|
+
Animated.timing(interpolation.current, { toValue: from, duration: 0, useNativeDriver: true }),
|
|
103
|
+
Animated.timing(
|
|
104
|
+
interpolation.current,
|
|
105
|
+
{
|
|
106
|
+
toValue: to,
|
|
107
|
+
duration: Array.isArray(animationConfig.duration)
|
|
108
|
+
? animationConfig.duration[to]
|
|
109
|
+
: animationConfig.duration,
|
|
110
|
+
easing: Array.isArray(animationConfig.modalEasing)
|
|
111
|
+
? animationConfig.modalEasing[to]
|
|
112
|
+
: animationConfig.modalEasing,
|
|
113
|
+
useNativeDriver: true,
|
|
114
|
+
},
|
|
115
|
+
),
|
|
116
|
+
])
|
|
117
|
+
.start(({ finished }) => {
|
|
118
|
+
if(finished) {
|
|
119
|
+
resolve()
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
}, [
|
|
126
|
+
animationConfig,
|
|
127
|
+
interpolation,
|
|
128
|
+
])
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Animated.View
|
|
132
|
+
{ ...props }
|
|
133
|
+
style={ [
|
|
134
|
+
StyleSheet.absoluteFill,
|
|
135
|
+
FlexStyleSheet.items_center,
|
|
136
|
+
FlexStyleSheet.justify_center,
|
|
137
|
+
animationConfig.modalStyleFactory(interpolation.current, interpolationInputRange),
|
|
138
|
+
style,
|
|
139
|
+
] }
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
},
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
const
|
|
147
|
+
interpolationInputRange =
|
|
148
|
+
[0, 1, 2]
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useEffect,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
} from "react"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Animated,
|
|
10
|
+
type View,
|
|
11
|
+
} from "react-native"
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
CarbonStyleSheet,
|
|
15
|
+
} from "../../../../carbon-style-sheet"
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
OverlayProps,
|
|
19
|
+
} from "./OverlayProps"
|
|
20
|
+
|
|
21
|
+
import type {
|
|
22
|
+
OverlayRef,
|
|
23
|
+
} from "./OverlayRef"
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
OverlayRefBase,
|
|
27
|
+
} from "./_OverlayRefBase"
|
|
28
|
+
|
|
29
|
+
export const Overlay = forwardRef<OverlayRef, OverlayProps>(
|
|
30
|
+
function(
|
|
31
|
+
{
|
|
32
|
+
// type,
|
|
33
|
+
animationConfig,
|
|
34
|
+
style,
|
|
35
|
+
...props
|
|
36
|
+
},
|
|
37
|
+
ref,
|
|
38
|
+
) {
|
|
39
|
+
|
|
40
|
+
const
|
|
41
|
+
viewRef =
|
|
42
|
+
useRef<View>(null),
|
|
43
|
+
|
|
44
|
+
opacityRef =
|
|
45
|
+
useRef(0),
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 0 = unmounted
|
|
49
|
+
* 1 = mounted
|
|
50
|
+
*/
|
|
51
|
+
opacity =
|
|
52
|
+
useRef(new Animated.Value(0))
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if(opacityRef.current == 0) {
|
|
56
|
+
opacityRef.current = 1
|
|
57
|
+
Animated
|
|
58
|
+
.timing(
|
|
59
|
+
opacity.current,
|
|
60
|
+
{
|
|
61
|
+
toValue: 1,
|
|
62
|
+
duration: animationConfig.duration,
|
|
63
|
+
useNativeDriver: true,
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
.start()
|
|
67
|
+
}
|
|
68
|
+
}, [
|
|
69
|
+
animationConfig,
|
|
70
|
+
opacity,
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
useImperativeHandle(ref, () => {
|
|
74
|
+
return Object.assign<View, OverlayRefBase>(
|
|
75
|
+
viewRef.current ?? {} as View,
|
|
76
|
+
{
|
|
77
|
+
animateUnmount() {
|
|
78
|
+
return new Promise(resolve => {
|
|
79
|
+
opacityRef.current = 0
|
|
80
|
+
Animated
|
|
81
|
+
.timing(
|
|
82
|
+
opacity.current,
|
|
83
|
+
{
|
|
84
|
+
toValue: 0,
|
|
85
|
+
duration: animationConfig.duration,
|
|
86
|
+
useNativeDriver: true,
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
.start(({ finished }) => {
|
|
90
|
+
if(finished) {
|
|
91
|
+
resolve()
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
)
|
|
98
|
+
}, [
|
|
99
|
+
animationConfig,
|
|
100
|
+
opacity,
|
|
101
|
+
])
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Animated.View
|
|
105
|
+
ref={ viewRef }
|
|
106
|
+
{ ...props }
|
|
107
|
+
style={ [
|
|
108
|
+
styleSheet.overlay,
|
|
109
|
+
{
|
|
110
|
+
opacity: opacity.current,
|
|
111
|
+
},
|
|
112
|
+
style,
|
|
113
|
+
] }
|
|
114
|
+
/>
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
const
|
|
121
|
+
styleSheet =
|
|
122
|
+
CarbonStyleSheet.create({
|
|
123
|
+
overlay: {
|
|
124
|
+
backgroundColor: CarbonStyleSheet.color.overlay,
|
|
125
|
+
position: "absolute",
|
|
126
|
+
top: 0,
|
|
127
|
+
right: 0,
|
|
128
|
+
bottom: 0,
|
|
129
|
+
left: 0,
|
|
130
|
+
overflow: "hidden",
|
|
131
|
+
},
|
|
132
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
} from "react"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ToastContext,
|
|
10
|
+
} from "../../contexts"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
ToastProviderProps,
|
|
15
|
+
} from "./ToastProviderProps"
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
ToastRef,
|
|
19
|
+
} from "./ToastRef"
|
|
20
|
+
import {
|
|
21
|
+
Overlay,
|
|
22
|
+
type OverlayRef,
|
|
23
|
+
} from "./_overlay"
|
|
24
|
+
|
|
25
|
+
export const ToastProvider = forwardRef<ToastRef, ToastProviderProps>(
|
|
26
|
+
function ToastProvider(
|
|
27
|
+
{
|
|
28
|
+
children,
|
|
29
|
+
},
|
|
30
|
+
ref,
|
|
31
|
+
) {
|
|
32
|
+
|
|
33
|
+
const
|
|
34
|
+
overlayRef =
|
|
35
|
+
useRef<OverlayRef>(null),
|
|
36
|
+
|
|
37
|
+
show: ToastContext["show"] =
|
|
38
|
+
useCallback((...args) => {
|
|
39
|
+
overlayRef.current?.show(...args)
|
|
40
|
+
}, []),
|
|
41
|
+
|
|
42
|
+
dismiss: ToastContext["dismiss"] =
|
|
43
|
+
useCallback((...args) => {
|
|
44
|
+
overlayRef.current?.dismiss(...args)
|
|
45
|
+
}, [])
|
|
46
|
+
|
|
47
|
+
useImperativeHandle(ref, () => {
|
|
48
|
+
return {
|
|
49
|
+
show,
|
|
50
|
+
dismiss,
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
show,
|
|
54
|
+
dismiss,
|
|
55
|
+
])
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<ToastContext.Provider
|
|
59
|
+
value={{
|
|
60
|
+
show,
|
|
61
|
+
dismiss,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{ children }
|
|
65
|
+
|
|
66
|
+
<Overlay
|
|
67
|
+
ref={ overlayRef }
|
|
68
|
+
/>
|
|
69
|
+
</ToastContext.Provider>
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
},
|
|
73
|
+
)
|