@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,328 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useContext,
|
|
4
|
+
} from "react"
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Pressable,
|
|
8
|
+
StyleSheet,
|
|
9
|
+
View,
|
|
10
|
+
type ViewProps,
|
|
11
|
+
} from "react-native"
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
Spacing,
|
|
15
|
+
} from "@audira/carbon-react-native-elements"
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
ButtonGroupContext,
|
|
19
|
+
GlobalConfigContext,
|
|
20
|
+
} from "../../../_internal/contexts"
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
FlexStyleSheet,
|
|
24
|
+
} from "../../../_internal/style-sheets"
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
Text,
|
|
28
|
+
type TextProps,
|
|
29
|
+
} from "../../text"
|
|
30
|
+
|
|
31
|
+
import type {
|
|
32
|
+
Size,
|
|
33
|
+
} from "../Size"
|
|
34
|
+
|
|
35
|
+
import type {
|
|
36
|
+
BaseProps,
|
|
37
|
+
} from "./BaseProps"
|
|
38
|
+
|
|
39
|
+
import type {
|
|
40
|
+
BaseRef,
|
|
41
|
+
} from "./BaseRef"
|
|
42
|
+
|
|
43
|
+
export const Base = forwardRef<BaseRef, BaseProps>(
|
|
44
|
+
function Base(
|
|
45
|
+
{
|
|
46
|
+
size: sizeProp,
|
|
47
|
+
text,
|
|
48
|
+
textProps,
|
|
49
|
+
Icon,
|
|
50
|
+
iconProps,
|
|
51
|
+
iconNode,
|
|
52
|
+
backgroundNode,
|
|
53
|
+
InlineLoading,
|
|
54
|
+
inlineLoadingProps,
|
|
55
|
+
style,
|
|
56
|
+
role = "button",
|
|
57
|
+
"aria-label": ariaLabel,
|
|
58
|
+
dir,
|
|
59
|
+
...props
|
|
60
|
+
},
|
|
61
|
+
ref,
|
|
62
|
+
) {
|
|
63
|
+
|
|
64
|
+
const
|
|
65
|
+
globalConfigContext =
|
|
66
|
+
useContext(GlobalConfigContext),
|
|
67
|
+
|
|
68
|
+
buttonGroupContext =
|
|
69
|
+
useContext(ButtonGroupContext),
|
|
70
|
+
|
|
71
|
+
size =
|
|
72
|
+
sizeProp ?? buttonGroupContext.size ?? "large_productive",
|
|
73
|
+
|
|
74
|
+
iconSize =
|
|
75
|
+
getIconSize(size),
|
|
76
|
+
|
|
77
|
+
iconMarginStyle =
|
|
78
|
+
mapIconMarginStyle[`${!!globalConfigContext.rtl}`][`${!!text}`]
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Pressable
|
|
82
|
+
{ ...props }
|
|
83
|
+
role={ role }
|
|
84
|
+
aria-label={ ariaLabel ?? text }
|
|
85
|
+
dir={ dir ?? globalConfigContext.rtl ? "rtl" : undefined }
|
|
86
|
+
style={ [
|
|
87
|
+
FlexStyleSheet.flex_row,
|
|
88
|
+
FlexStyleSheet.justify_between,
|
|
89
|
+
baseStyle.container,
|
|
90
|
+
globalConfigContext.rtl ? baseStyle.containerRtl : undefined,
|
|
91
|
+
mapContainerStyle[`${!!text}`][`${!!Icon || !!iconNode}`],
|
|
92
|
+
sizeStyle[size],
|
|
93
|
+
mapStyleInButtonGroup[`${!!buttonGroupContext.vertical}`][`${!!buttonGroupContext.fluid}`],
|
|
94
|
+
style,
|
|
95
|
+
] }
|
|
96
|
+
ref={ ref }
|
|
97
|
+
>
|
|
98
|
+
{ backgroundNode }{/* only for base-color button, and this is not valid HTML per se (?) */}
|
|
99
|
+
|
|
100
|
+
{ !InlineLoading || inlineLoadingProps?.state === "inactive" ? (<>
|
|
101
|
+
{ !!text && (
|
|
102
|
+
<View
|
|
103
|
+
style={ baseStyle.textContainer }
|
|
104
|
+
>
|
|
105
|
+
<Text
|
|
106
|
+
{ ...textProps }
|
|
107
|
+
type={ getTextType(size) }
|
|
108
|
+
>
|
|
109
|
+
{ text }
|
|
110
|
+
</Text>
|
|
111
|
+
</View>
|
|
112
|
+
) }
|
|
113
|
+
|
|
114
|
+
{ (!!Icon && !iconNode) ? (
|
|
115
|
+
<Icon
|
|
116
|
+
{ ...iconProps }
|
|
117
|
+
width={ iconProps?.width ?? iconSize }
|
|
118
|
+
height={ iconProps?.height ?? iconSize }
|
|
119
|
+
dir={ globalConfigContext.rtl ? "rtl" : undefined }
|
|
120
|
+
style={ [
|
|
121
|
+
getIconMarginTopStyle(size),
|
|
122
|
+
iconMarginStyle,
|
|
123
|
+
iconProps?.style,
|
|
124
|
+
] }
|
|
125
|
+
/>
|
|
126
|
+
) : iconNode?.(
|
|
127
|
+
iconSize,
|
|
128
|
+
[
|
|
129
|
+
getIconMarginTopStyle(size),
|
|
130
|
+
iconMarginStyle,
|
|
131
|
+
],
|
|
132
|
+
) }
|
|
133
|
+
</>) : (
|
|
134
|
+
<InlineLoading
|
|
135
|
+
{ ...inlineLoadingProps }
|
|
136
|
+
text={ inlineLoadingProps?.text || text || "" }
|
|
137
|
+
style={ [
|
|
138
|
+
baseStyle.inlineLoading,
|
|
139
|
+
inlineLoadingProps?.style,
|
|
140
|
+
] }
|
|
141
|
+
/>
|
|
142
|
+
) }
|
|
143
|
+
</Pressable>
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
},
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
const
|
|
150
|
+
baseStyle =
|
|
151
|
+
StyleSheet.create({
|
|
152
|
+
container: {
|
|
153
|
+
overflow: "hidden",
|
|
154
|
+
},
|
|
155
|
+
containerRtl: {
|
|
156
|
+
direction: "rtl",
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Start Padding
|
|
161
|
+
*/
|
|
162
|
+
containerPaddingStart: {
|
|
163
|
+
paddingStart: Spacing.spacing_05,
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* End Padding with icon
|
|
167
|
+
*/
|
|
168
|
+
containerPaddingEnd05: {
|
|
169
|
+
paddingEnd: Spacing.spacing_05,
|
|
170
|
+
},
|
|
171
|
+
/**
|
|
172
|
+
* End Padding without icon
|
|
173
|
+
*/
|
|
174
|
+
containerPaddingEnd10: {
|
|
175
|
+
paddingEnd: Spacing.spacing_10,
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
textContainer: {
|
|
179
|
+
justifyContent: "center",
|
|
180
|
+
height: "100%",
|
|
181
|
+
maxHeight: 48,
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
iconMarginLTR: {
|
|
185
|
+
marginLeft: Spacing.spacing_07,
|
|
186
|
+
},
|
|
187
|
+
iconMarginRTL: {
|
|
188
|
+
marginRight: Spacing.spacing_07,
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
inlineLoading: {
|
|
192
|
+
height: "100%",
|
|
193
|
+
maxHeight: 48,
|
|
194
|
+
},
|
|
195
|
+
}),
|
|
196
|
+
|
|
197
|
+
sizeStyle =
|
|
198
|
+
StyleSheet.create<Record<Size, {
|
|
199
|
+
height: number
|
|
200
|
+
}>>({
|
|
201
|
+
small: {
|
|
202
|
+
height: 32,
|
|
203
|
+
},
|
|
204
|
+
medium: {
|
|
205
|
+
height: 40,
|
|
206
|
+
},
|
|
207
|
+
large_productive: {
|
|
208
|
+
height: 48,
|
|
209
|
+
},
|
|
210
|
+
large_expressive: {
|
|
211
|
+
height: 48,
|
|
212
|
+
},
|
|
213
|
+
extra_large: {
|
|
214
|
+
height: 64,
|
|
215
|
+
},
|
|
216
|
+
"2xl": {
|
|
217
|
+
height: 80,
|
|
218
|
+
},
|
|
219
|
+
}),
|
|
220
|
+
|
|
221
|
+
mapContainerStyle: {
|
|
222
|
+
[HasText in `${boolean}`]: {
|
|
223
|
+
[HasIcon in `${boolean}`]: BaseProps["style"]
|
|
224
|
+
}
|
|
225
|
+
} =
|
|
226
|
+
{
|
|
227
|
+
false: {
|
|
228
|
+
false: [baseStyle.containerPaddingEnd05, baseStyle.containerPaddingStart],
|
|
229
|
+
true: [baseStyle.containerPaddingEnd05, baseStyle.containerPaddingStart],
|
|
230
|
+
},
|
|
231
|
+
true: {
|
|
232
|
+
false: [baseStyle.containerPaddingEnd10, baseStyle.containerPaddingStart],
|
|
233
|
+
true: [baseStyle.containerPaddingEnd05, baseStyle.containerPaddingStart],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* https://carbondesignsystem.com/components/button/style/#typography
|
|
239
|
+
*/
|
|
240
|
+
mapTextTypeByExpressive: Record<"true" | "false", NonNullable<TextProps["type"]>> =
|
|
241
|
+
{
|
|
242
|
+
false: "body_compact_01",
|
|
243
|
+
true: "body_compact_02",
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
mapIconSizeByExpressive: Record<"true" | "false", number> =
|
|
247
|
+
{
|
|
248
|
+
false: 16,
|
|
249
|
+
true: 20,
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
mapIconMarginStyle: {
|
|
253
|
+
[RTL in `${boolean}`]: {
|
|
254
|
+
[HasText in `${boolean}`]: ViewProps["style"]
|
|
255
|
+
}
|
|
256
|
+
} =
|
|
257
|
+
{
|
|
258
|
+
false: {
|
|
259
|
+
false: null,
|
|
260
|
+
true: baseStyle.iconMarginLTR,
|
|
261
|
+
},
|
|
262
|
+
true: {
|
|
263
|
+
false: null,
|
|
264
|
+
true: baseStyle.iconMarginRTL,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
mapStyleInButtonGroup: {
|
|
269
|
+
[IsVertical in `${boolean}`]: {
|
|
270
|
+
[IsFluid in `${boolean}`]: ViewProps["style"]
|
|
271
|
+
}
|
|
272
|
+
} =
|
|
273
|
+
{
|
|
274
|
+
false: {
|
|
275
|
+
false: FlexStyleSheet.self_start,
|
|
276
|
+
true: FlexStyleSheet.flex_1,
|
|
277
|
+
},
|
|
278
|
+
true: {
|
|
279
|
+
false: FlexStyleSheet.self_stretch,
|
|
280
|
+
true: FlexStyleSheet.self_stretch,
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Expressive only when button size is LARGE_EXPRESSIVE. You can see this link
|
|
286
|
+
* https://carbondesignsystem.com/components/button/style/#sizes
|
|
287
|
+
*/
|
|
288
|
+
function isExpressiveStr(
|
|
289
|
+
Size: BaseProps["size"],
|
|
290
|
+
): "true" | "false" {
|
|
291
|
+
return `${Size === "large_expressive"}`
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// function getContainerPaddingRight(
|
|
295
|
+
// text: boolean,
|
|
296
|
+
// icon: boolean,
|
|
297
|
+
// ) {
|
|
298
|
+
// return mapContainerEndPR[`${text}`][`${icon}`]
|
|
299
|
+
// }
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Expressive only when button size is LARGE_EXPRESSIVE. You can see this link
|
|
303
|
+
* https://carbondesignsystem.com/components/button/style/#sizes
|
|
304
|
+
*/
|
|
305
|
+
function getTextType(size: BaseProps["size"]) {
|
|
306
|
+
return mapTextTypeByExpressive[isExpressiveStr(size)]
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Expressive only when button size is LARGE_EXPRESSIVE. You can see this link
|
|
311
|
+
* https://carbondesignsystem.com/components/button/style/#sizes
|
|
312
|
+
*/
|
|
313
|
+
function getIconSize(size: BaseProps["size"]) {
|
|
314
|
+
return mapIconSizeByExpressive[isExpressiveStr(size)]
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function getIconMarginTopStyle(size: NonNullable<BaseProps["size"]>) {
|
|
318
|
+
const
|
|
319
|
+
iconSize =
|
|
320
|
+
mapIconSizeByExpressive[isExpressiveStr(size)],
|
|
321
|
+
|
|
322
|
+
height =
|
|
323
|
+
Math.min(sizeStyle[size].height, sizeStyle.large_productive.height) // 48 at max
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
marginTop: (height / 2) - (iconSize / 2),
|
|
327
|
+
}
|
|
328
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PressableProps,
|
|
3
|
+
ViewProps,
|
|
4
|
+
} from "react-native"
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
SvgProps,
|
|
8
|
+
} from "react-native-svg"
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
InlineLoadingProps,
|
|
12
|
+
} from "../../inline-loading/InlineLoadingProps"
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
TextProps,
|
|
16
|
+
} from "../../text/TextProps"
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
Size,
|
|
20
|
+
} from "../Size"
|
|
21
|
+
|
|
22
|
+
export interface BaseProps extends Omit<PressableProps, "children" | "style"> {
|
|
23
|
+
/**
|
|
24
|
+
* Refer to https://carbondesignsystem.com/components/button/style/#sizes
|
|
25
|
+
* Default is `large_productive`
|
|
26
|
+
*/
|
|
27
|
+
size?: Size,
|
|
28
|
+
text?: string,
|
|
29
|
+
textProps?: Omit<TextProps, "type" | "children">,
|
|
30
|
+
Icon?: React.FunctionComponent<SvgProps>,
|
|
31
|
+
iconProps?: Omit<SvgProps, "children">,
|
|
32
|
+
/**
|
|
33
|
+
* This prop is useful to custom render at the icon position.
|
|
34
|
+
* `iconNode` takes precedence even if {@linkcode icon} prop is present.
|
|
35
|
+
*/
|
|
36
|
+
iconNode?: (
|
|
37
|
+
/**
|
|
38
|
+
* Use this param to resize icon view correctly according to each size of button
|
|
39
|
+
*/
|
|
40
|
+
iconSize: number,
|
|
41
|
+
/**
|
|
42
|
+
* Use this style to keep icon style nicely center aligned vertically with text
|
|
43
|
+
*/
|
|
44
|
+
iconStyle: SvgProps["style"],
|
|
45
|
+
) => React.ReactNode,
|
|
46
|
+
/**
|
|
47
|
+
* Only for base-color button for Focus state UI purposes
|
|
48
|
+
*/
|
|
49
|
+
backgroundNode?: React.ReactNode,
|
|
50
|
+
/**
|
|
51
|
+
* Pass this `InlineLoading` component to render the loading inside of button.
|
|
52
|
+
* The Text of Button will be used if `inlineLoadingProps.text` is empty.
|
|
53
|
+
* If you pass `inlineLoadingProps.state` with `inactive` value, the `InlineLoading` component will not be rendered.
|
|
54
|
+
*/
|
|
55
|
+
InlineLoading?: React.FunctionComponent<InlineLoadingProps>,
|
|
56
|
+
inlineLoadingProps?: Omit<InlineLoadingProps, "text"> & {
|
|
57
|
+
text?: string,
|
|
58
|
+
},
|
|
59
|
+
style?: ViewProps["style"],
|
|
60
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useState,
|
|
6
|
+
} from "react"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Platform,
|
|
10
|
+
StyleSheet,
|
|
11
|
+
View,
|
|
12
|
+
type StyleProp,
|
|
13
|
+
type TextStyle,
|
|
14
|
+
type ViewStyle,
|
|
15
|
+
} from "react-native"
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Color,
|
|
19
|
+
} from "@audira/carbon-react-native-elements"
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
GlobalConfigContext,
|
|
23
|
+
} from "../../../_internal/contexts"
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
ThemeContext,
|
|
27
|
+
} from "../../../contexts"
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
type ThemeType,
|
|
31
|
+
} from "../../../types"
|
|
32
|
+
|
|
33
|
+
import {
|
|
34
|
+
Base,
|
|
35
|
+
type BaseProps,
|
|
36
|
+
} from "../base"
|
|
37
|
+
|
|
38
|
+
import type {
|
|
39
|
+
BaseColorProps,
|
|
40
|
+
} from "./BaseColorProps"
|
|
41
|
+
|
|
42
|
+
import type {
|
|
43
|
+
BaseColorRef,
|
|
44
|
+
} from "./BaseColorRef"
|
|
45
|
+
|
|
46
|
+
import type {
|
|
47
|
+
BaseColorState,
|
|
48
|
+
} from "./BaseColorState"
|
|
49
|
+
|
|
50
|
+
export const BaseColor = forwardRef<BaseColorRef, BaseColorProps>(
|
|
51
|
+
function BaseColor(
|
|
52
|
+
{
|
|
53
|
+
disabled,
|
|
54
|
+
style,
|
|
55
|
+
textProps,
|
|
56
|
+
android_rippleEffectColor,
|
|
57
|
+
colorStateStyle,
|
|
58
|
+
Icon,
|
|
59
|
+
iconProps,
|
|
60
|
+
iconNode,
|
|
61
|
+
InlineLoading,
|
|
62
|
+
inlineLoadingProps,
|
|
63
|
+
onBlur,
|
|
64
|
+
onFocus,
|
|
65
|
+
onHoverIn,
|
|
66
|
+
onHoverOut,
|
|
67
|
+
onPressIn,
|
|
68
|
+
onPressOut,
|
|
69
|
+
android_ripple,
|
|
70
|
+
...props
|
|
71
|
+
},
|
|
72
|
+
ref,
|
|
73
|
+
) {
|
|
74
|
+
|
|
75
|
+
const
|
|
76
|
+
globalConfigContext =
|
|
77
|
+
useContext(GlobalConfigContext),
|
|
78
|
+
|
|
79
|
+
themeContext =
|
|
80
|
+
useContext(ThemeContext),
|
|
81
|
+
|
|
82
|
+
[state, setState] =
|
|
83
|
+
useState({
|
|
84
|
+
focused: false,
|
|
85
|
+
hovered: false,
|
|
86
|
+
pressed: false,
|
|
87
|
+
}),
|
|
88
|
+
|
|
89
|
+
blurHandler: NonNullable<BaseProps["onBlur"]> =
|
|
90
|
+
useCallback(event => {
|
|
91
|
+
onBlur?.(event)
|
|
92
|
+
setState(state_ => ({
|
|
93
|
+
...state_,
|
|
94
|
+
focused: false,
|
|
95
|
+
}))
|
|
96
|
+
}, [
|
|
97
|
+
onBlur,
|
|
98
|
+
]),
|
|
99
|
+
|
|
100
|
+
focusHandler: NonNullable<BaseProps["onFocus"]> =
|
|
101
|
+
useCallback(event => {
|
|
102
|
+
onFocus?.(event)
|
|
103
|
+
setState(state_ => ({
|
|
104
|
+
...state_,
|
|
105
|
+
focused: true,
|
|
106
|
+
}))
|
|
107
|
+
}, [
|
|
108
|
+
onFocus,
|
|
109
|
+
]),
|
|
110
|
+
|
|
111
|
+
hoverInHandler: NonNullable<BaseProps["onHoverIn"]> =
|
|
112
|
+
useCallback(event => {
|
|
113
|
+
onHoverIn?.(event)
|
|
114
|
+
setState(state_ => ({
|
|
115
|
+
...state_,
|
|
116
|
+
hovered: true,
|
|
117
|
+
}))
|
|
118
|
+
}, [
|
|
119
|
+
onHoverIn,
|
|
120
|
+
]),
|
|
121
|
+
|
|
122
|
+
hoverOutHandler: NonNullable<BaseProps["onHoverIn"]> =
|
|
123
|
+
useCallback(event => {
|
|
124
|
+
onHoverOut?.(event)
|
|
125
|
+
setState(state_ => ({
|
|
126
|
+
...state_,
|
|
127
|
+
hovered: false,
|
|
128
|
+
}))
|
|
129
|
+
}, [
|
|
130
|
+
onHoverOut,
|
|
131
|
+
]),
|
|
132
|
+
|
|
133
|
+
pressInHandler: NonNullable<BaseProps["onPressIn"]> =
|
|
134
|
+
useCallback(event => {
|
|
135
|
+
onPressIn?.(event)
|
|
136
|
+
setState(state_ => ({
|
|
137
|
+
...state_,
|
|
138
|
+
pressed: true,
|
|
139
|
+
}))
|
|
140
|
+
}, [
|
|
141
|
+
onPressIn,
|
|
142
|
+
]),
|
|
143
|
+
|
|
144
|
+
pressOutHandler: NonNullable<BaseProps["onPressOut"]> =
|
|
145
|
+
useCallback(event => {
|
|
146
|
+
onPressOut?.(event)
|
|
147
|
+
setState(state_ => ({
|
|
148
|
+
...state_,
|
|
149
|
+
pressed: false,
|
|
150
|
+
}))
|
|
151
|
+
}, [
|
|
152
|
+
onPressOut,
|
|
153
|
+
]),
|
|
154
|
+
|
|
155
|
+
stateStyle =
|
|
156
|
+
getStateStyle(
|
|
157
|
+
colorStateStyle,
|
|
158
|
+
{
|
|
159
|
+
...state,
|
|
160
|
+
disabled: !!disabled,
|
|
161
|
+
},
|
|
162
|
+
android_ripple
|
|
163
|
+
? true
|
|
164
|
+
: android_ripple === null ? false : globalConfigContext.android_buttonRippleEffect,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<Base
|
|
169
|
+
{ ...props }
|
|
170
|
+
ref={ ref }
|
|
171
|
+
android_ripple={ android_ripple ?? globalConfigContext.android_buttonRippleEffect ? {
|
|
172
|
+
// color: colorStateStyle.background.pressed.backgroundColor,
|
|
173
|
+
color: android_rippleEffectColor,
|
|
174
|
+
} : undefined }
|
|
175
|
+
backgroundNode={
|
|
176
|
+
<View
|
|
177
|
+
style={ [
|
|
178
|
+
styleSheet.innerFocusBox,
|
|
179
|
+
state.focused
|
|
180
|
+
? mapInnerFocusBoxActiveStyle[themeContext.colorScheme]
|
|
181
|
+
: null,
|
|
182
|
+
] }
|
|
183
|
+
/>
|
|
184
|
+
}
|
|
185
|
+
disabled={ disabled }
|
|
186
|
+
onBlur={ blurHandler }
|
|
187
|
+
onFocus={ focusHandler }
|
|
188
|
+
onHoverIn={ hoverInHandler }
|
|
189
|
+
onHoverOut={ hoverOutHandler }
|
|
190
|
+
onPressIn={ pressInHandler }
|
|
191
|
+
onPressOut={ pressOutHandler }
|
|
192
|
+
textProps={{
|
|
193
|
+
...textProps,
|
|
194
|
+
style: [stateStyle.text, textProps?.style],
|
|
195
|
+
}}
|
|
196
|
+
Icon={ !iconNode ? Icon : undefined }
|
|
197
|
+
iconProps={{
|
|
198
|
+
...iconProps,
|
|
199
|
+
fill: iconProps?.fill ?? stateStyle.icon,
|
|
200
|
+
}}
|
|
201
|
+
iconNode={
|
|
202
|
+
iconNode
|
|
203
|
+
? (...params) => iconNode(stateStyle.icon, ...params)
|
|
204
|
+
: undefined
|
|
205
|
+
}
|
|
206
|
+
InlineLoading={ InlineLoading }
|
|
207
|
+
inlineLoadingProps={ inlineLoadingProps }
|
|
208
|
+
style={ [
|
|
209
|
+
!InlineLoading || inlineLoadingProps?.state === "inactive"
|
|
210
|
+
? stateStyle.background
|
|
211
|
+
: styleSheet.withInlineLoading,
|
|
212
|
+
style,
|
|
213
|
+
] }
|
|
214
|
+
/>
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
},
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
const
|
|
221
|
+
styleSheet =
|
|
222
|
+
StyleSheet.create({
|
|
223
|
+
withInlineLoading: {
|
|
224
|
+
borderColor: "transparent",
|
|
225
|
+
},
|
|
226
|
+
innerFocusBox: {
|
|
227
|
+
position: "absolute",
|
|
228
|
+
top: 2,
|
|
229
|
+
right: 2,
|
|
230
|
+
bottom: 2,
|
|
231
|
+
left: 2,
|
|
232
|
+
borderWidth: 1,
|
|
233
|
+
borderColor: "transparent",
|
|
234
|
+
},
|
|
235
|
+
innerFocusBoxActive_GRAY_10: {
|
|
236
|
+
borderColor: Color.Token.gray_10.focus_inset,
|
|
237
|
+
},
|
|
238
|
+
innerFocusBoxActive_GRAY_100: {
|
|
239
|
+
borderColor: Color.Token.gray_100.focus_inset,
|
|
240
|
+
},
|
|
241
|
+
}),
|
|
242
|
+
|
|
243
|
+
mapInnerFocusBoxActiveStyle: Record<ThemeType.ColorScheme, typeof styleSheet["innerFocusBoxActive_GRAY_10"]> =
|
|
244
|
+
{
|
|
245
|
+
gray_10: styleSheet.innerFocusBoxActive_GRAY_10,
|
|
246
|
+
gray_100: styleSheet.innerFocusBoxActive_GRAY_100,
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function getStateStyle(
|
|
250
|
+
colorStateStyle: BaseColorProps["colorStateStyle"],
|
|
251
|
+
states: Record<Exclude<BaseColorState, "default">, boolean>,
|
|
252
|
+
androidRipple?: boolean,
|
|
253
|
+
): {
|
|
254
|
+
background: StyleProp<ViewStyle>, text: StyleProp<TextStyle>, icon: string
|
|
255
|
+
} {
|
|
256
|
+
|
|
257
|
+
if(!states.hovered && !states.pressed && !states.disabled) {
|
|
258
|
+
return {
|
|
259
|
+
background: colorStateStyle.background.default,
|
|
260
|
+
text: colorStateStyle.text.default,
|
|
261
|
+
icon: colorStateStyle.icon.default,
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if(states.disabled) {
|
|
266
|
+
return {
|
|
267
|
+
background: colorStateStyle.background.disabled,
|
|
268
|
+
text: colorStateStyle.text.disabled,
|
|
269
|
+
icon: colorStateStyle.icon.disabled,
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if(states.pressed) {
|
|
274
|
+
return {
|
|
275
|
+
background: androidRipple && Platform.OS == "android"
|
|
276
|
+
? colorStateStyle.background.default
|
|
277
|
+
: colorStateStyle.background.pressed,
|
|
278
|
+
text: colorStateStyle.text.pressed,
|
|
279
|
+
icon: colorStateStyle.icon.pressed,
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
background: colorStateStyle.background.hovered,
|
|
285
|
+
text: colorStateStyle.text.hovered,
|
|
286
|
+
icon: colorStateStyle.icon.hovered,
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
StyleProp,
|
|
3
|
+
TextStyle,
|
|
4
|
+
ViewStyle,
|
|
5
|
+
} from "react-native"
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
BaseProps,
|
|
9
|
+
} from "../base/BaseProps"
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
BaseColorState,
|
|
13
|
+
} from "./BaseColorState"
|
|
14
|
+
|
|
15
|
+
export interface BaseColorProps extends Omit<BaseProps, "backgroundNode" | "iconNode"> {
|
|
16
|
+
android_rippleEffectColor: string,
|
|
17
|
+
colorStateStyle: {
|
|
18
|
+
background: Record<BaseColorState, StyleProp<ViewStyle>>,
|
|
19
|
+
text: Record<BaseColorState, StyleProp<TextStyle>>,
|
|
20
|
+
icon: Record<BaseColorState, string>,
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* It extends `iconNode` prop from `BaseProps` to add one argument at start for icon coloring
|
|
24
|
+
*/
|
|
25
|
+
iconNode?: (
|
|
26
|
+
/**
|
|
27
|
+
* Use this param to coloring an icon correctly according each variant of button and its state, like focused, disabled, etc.
|
|
28
|
+
*/
|
|
29
|
+
iconColorState: string,
|
|
30
|
+
...params: Parameters<NonNullable<BaseProps["iconNode"]>>
|
|
31
|
+
) => React.ReactNode,
|
|
32
|
+
}
|