@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,487 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react"
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
Animated,
|
|
14
|
+
Easing,
|
|
15
|
+
Pressable,
|
|
16
|
+
StyleSheet,
|
|
17
|
+
View,
|
|
18
|
+
type EasingFunction,
|
|
19
|
+
type PressableProps,
|
|
20
|
+
} from "react-native"
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
Color,
|
|
24
|
+
Motion,
|
|
25
|
+
} from "@audira/carbon-react-native-elements"
|
|
26
|
+
|
|
27
|
+
import IconCheckmark from "@carbon/icons/svg/32/checkmark.svg"
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
GlobalConfigContext,
|
|
31
|
+
} from "../../_internal/contexts"
|
|
32
|
+
|
|
33
|
+
import {
|
|
34
|
+
CommonStyleSheet,
|
|
35
|
+
FlexStyleSheet,
|
|
36
|
+
} from "../../_internal/style-sheets"
|
|
37
|
+
|
|
38
|
+
import {
|
|
39
|
+
CarbonStyleSheet,
|
|
40
|
+
} from "../../carbon-style-sheet"
|
|
41
|
+
|
|
42
|
+
import {
|
|
43
|
+
ThemeContext,
|
|
44
|
+
} from "../../contexts"
|
|
45
|
+
|
|
46
|
+
import type {
|
|
47
|
+
SwitchProps,
|
|
48
|
+
} from "./SwitchProps"
|
|
49
|
+
|
|
50
|
+
import type {
|
|
51
|
+
SwitchRef,
|
|
52
|
+
} from "./SwitchRef"
|
|
53
|
+
|
|
54
|
+
import type {
|
|
55
|
+
SwitchSize,
|
|
56
|
+
} from "./SwitchSize"
|
|
57
|
+
|
|
58
|
+
import type {
|
|
59
|
+
SwitchState,
|
|
60
|
+
} from "./SwitchState"
|
|
61
|
+
|
|
62
|
+
import type {
|
|
63
|
+
RefBase,
|
|
64
|
+
} from "./_RefBase"
|
|
65
|
+
|
|
66
|
+
export const Switch = forwardRef<SwitchRef, SwitchProps>(
|
|
67
|
+
function(
|
|
68
|
+
{
|
|
69
|
+
|
|
70
|
+
size = "default",
|
|
71
|
+
state = "normal",
|
|
72
|
+
defaultValue,
|
|
73
|
+
value: valueProp,
|
|
74
|
+
trackColor: trackColorProp,
|
|
75
|
+
thumbColor: thumbColorProp,
|
|
76
|
+
motion = {
|
|
77
|
+
false: motionDefault,
|
|
78
|
+
true: motionDefault,
|
|
79
|
+
},
|
|
80
|
+
style,
|
|
81
|
+
role = "switch",
|
|
82
|
+
"aria-checked": ariaChecked,
|
|
83
|
+
onChange,
|
|
84
|
+
onBlur,
|
|
85
|
+
onFocus,
|
|
86
|
+
onPress,
|
|
87
|
+
...props
|
|
88
|
+
},
|
|
89
|
+
forwardedRef,
|
|
90
|
+
) {
|
|
91
|
+
|
|
92
|
+
const
|
|
93
|
+
viewRef =
|
|
94
|
+
useRef<View>(null),
|
|
95
|
+
|
|
96
|
+
ref =
|
|
97
|
+
useRef({
|
|
98
|
+
onChangeEffect: false,
|
|
99
|
+
value: defaultValue ?? false,
|
|
100
|
+
}),
|
|
101
|
+
|
|
102
|
+
globalConfigContext =
|
|
103
|
+
useContext(GlobalConfigContext),
|
|
104
|
+
|
|
105
|
+
themeContext =
|
|
106
|
+
useContext(ThemeContext),
|
|
107
|
+
|
|
108
|
+
[isFocused, setIsFocused] =
|
|
109
|
+
useState(false),
|
|
110
|
+
|
|
111
|
+
[valueSelf, setValueSelf] =
|
|
112
|
+
useState(ref.current.value),
|
|
113
|
+
|
|
114
|
+
controlled =
|
|
115
|
+
typeof valueProp === "boolean",
|
|
116
|
+
|
|
117
|
+
value =
|
|
118
|
+
controlled ? !!valueProp : valueSelf,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 0 -> false/inactive
|
|
122
|
+
* 1 -> true/active
|
|
123
|
+
*/
|
|
124
|
+
sharedValue =
|
|
125
|
+
useRef(new Animated.Value(value ? 1 : 0)),
|
|
126
|
+
|
|
127
|
+
{ trackColor, thumbColor } =
|
|
128
|
+
useMemo<{
|
|
129
|
+
trackColor: NonNullable<SwitchProps["trackColor"]>,
|
|
130
|
+
thumbColor: NonNullable<SwitchProps["thumbColor"]>,
|
|
131
|
+
}>(() => {
|
|
132
|
+
const
|
|
133
|
+
trackColor_ =
|
|
134
|
+
mapSwitchTrackColorToken[state],
|
|
135
|
+
|
|
136
|
+
thumbColor_ =
|
|
137
|
+
mapSwitchThumbColorToken[state]
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
trackColor: trackColorProp ?? {
|
|
141
|
+
false: trackColor_.false?.[themeContext.colorScheme] ?? "transparent",
|
|
142
|
+
true: trackColor_.true?.[themeContext.colorScheme] ?? "transparent",
|
|
143
|
+
},
|
|
144
|
+
thumbColor: thumbColorProp ?? {
|
|
145
|
+
false: thumbColor_[themeContext.colorScheme],
|
|
146
|
+
true: thumbColor_[themeContext.colorScheme],
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
}, [
|
|
150
|
+
state,
|
|
151
|
+
trackColorProp,
|
|
152
|
+
thumbColorProp,
|
|
153
|
+
themeContext.colorScheme,
|
|
154
|
+
]),
|
|
155
|
+
|
|
156
|
+
blurHandler: NonNullable<PressableProps["onBlur"]> =
|
|
157
|
+
useCallback(event => {
|
|
158
|
+
onBlur?.(event)
|
|
159
|
+
setIsFocused(false)
|
|
160
|
+
}, [
|
|
161
|
+
onBlur,
|
|
162
|
+
]),
|
|
163
|
+
|
|
164
|
+
focusHandler: NonNullable<PressableProps["onFocus"]> =
|
|
165
|
+
useCallback(event => {
|
|
166
|
+
onFocus?.(event)
|
|
167
|
+
setIsFocused(true)
|
|
168
|
+
}, [
|
|
169
|
+
onFocus,
|
|
170
|
+
]),
|
|
171
|
+
|
|
172
|
+
pressHandler: NonNullable<PressableProps["onPress"]> =
|
|
173
|
+
useCallback(event => {
|
|
174
|
+
onPress?.(event)
|
|
175
|
+
if(!controlled) {
|
|
176
|
+
ref.current.onChangeEffect = true
|
|
177
|
+
setValueSelf(self => !self)
|
|
178
|
+
} else {
|
|
179
|
+
onChange?.(!ref.current.value)
|
|
180
|
+
}
|
|
181
|
+
}, [
|
|
182
|
+
controlled,
|
|
183
|
+
onPress,
|
|
184
|
+
onChange,
|
|
185
|
+
]),
|
|
186
|
+
|
|
187
|
+
transformInterpolationOutputRange =
|
|
188
|
+
useMemo(() => {
|
|
189
|
+
const ltr = [
|
|
190
|
+
/**
|
|
191
|
+
* i can't find how IBM tell this gap between the container and the thumb/handle
|
|
192
|
+
* i have to look at the Carbon React just to find this padding (they are using inset-inline-start there)
|
|
193
|
+
*/
|
|
194
|
+
3,
|
|
195
|
+
sizeStyle[size].width - thumbSizeStyle[size].width - 3,
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
if(globalConfigContext.rtl) {
|
|
199
|
+
return ltr.reverse()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return ltr
|
|
203
|
+
}, [
|
|
204
|
+
size,
|
|
205
|
+
globalConfigContext.rtl,
|
|
206
|
+
])
|
|
207
|
+
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if(value) {
|
|
210
|
+
Animated.timing(
|
|
211
|
+
sharedValue.current,
|
|
212
|
+
{
|
|
213
|
+
toValue: 1,
|
|
214
|
+
duration: motion.true.duration,
|
|
215
|
+
easing: motion.true.easing as EasingFunction,
|
|
216
|
+
useNativeDriver: true,
|
|
217
|
+
},
|
|
218
|
+
).start()
|
|
219
|
+
} else {
|
|
220
|
+
Animated.timing(
|
|
221
|
+
sharedValue.current,
|
|
222
|
+
{
|
|
223
|
+
toValue: 0,
|
|
224
|
+
duration: motion.false.duration,
|
|
225
|
+
easing: motion.false.easing as EasingFunction,
|
|
226
|
+
useNativeDriver: true,
|
|
227
|
+
},
|
|
228
|
+
).start()
|
|
229
|
+
}
|
|
230
|
+
}, [
|
|
231
|
+
motion,
|
|
232
|
+
sharedValue,
|
|
233
|
+
value,
|
|
234
|
+
])
|
|
235
|
+
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
ref.current.value = value
|
|
238
|
+
if(ref.current.onChangeEffect) {
|
|
239
|
+
ref.current.onChangeEffect = false
|
|
240
|
+
onChange?.(value)
|
|
241
|
+
}
|
|
242
|
+
}, [
|
|
243
|
+
value,
|
|
244
|
+
onChange,
|
|
245
|
+
])
|
|
246
|
+
|
|
247
|
+
useImperativeHandle(forwardedRef, () => {
|
|
248
|
+
return Object.assign<View, RefBase>(
|
|
249
|
+
(viewRef.current ?? {
|
|
250
|
+
}) as View,
|
|
251
|
+
{
|
|
252
|
+
get value() {
|
|
253
|
+
return value
|
|
254
|
+
},
|
|
255
|
+
setValue(valueParam) {
|
|
256
|
+
if(!controlled) {
|
|
257
|
+
ref.current.onChangeEffect = true
|
|
258
|
+
if(typeof valueParam === "boolean") {
|
|
259
|
+
setValueSelf(valueParam)
|
|
260
|
+
} else {
|
|
261
|
+
setValueSelf(valueParam(ref.current.value))
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
)
|
|
267
|
+
}, [
|
|
268
|
+
controlled,
|
|
269
|
+
value,
|
|
270
|
+
])
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<PressableAnimated
|
|
274
|
+
{ ...props }
|
|
275
|
+
role={ role }
|
|
276
|
+
aria-checked={ ariaChecked ?? value }
|
|
277
|
+
style={ [
|
|
278
|
+
FlexStyleSheet.justify_center,
|
|
279
|
+
baseStyle.container,
|
|
280
|
+
sizeStyle[size],
|
|
281
|
+
{
|
|
282
|
+
backgroundColor: sharedValue.current.interpolate({
|
|
283
|
+
inputRange: interpolationRange,
|
|
284
|
+
outputRange: [trackColor.false, trackColor.true],
|
|
285
|
+
}),
|
|
286
|
+
},
|
|
287
|
+
state === "read_only" ? baseStyleCarbon.containerReadonly : null,
|
|
288
|
+
style,
|
|
289
|
+
] }
|
|
290
|
+
onBlur={ blurHandler }
|
|
291
|
+
onFocus={ focusHandler }
|
|
292
|
+
onPress={ pressHandler }
|
|
293
|
+
ref={ viewRef }
|
|
294
|
+
>
|
|
295
|
+
<Animated.View
|
|
296
|
+
style={ [
|
|
297
|
+
FlexStyleSheet.items_center,
|
|
298
|
+
FlexStyleSheet.justify_center,
|
|
299
|
+
baseStyle.thumb,
|
|
300
|
+
thumbSizeStyle[size],
|
|
301
|
+
// thumbAnimatedStyle,
|
|
302
|
+
{
|
|
303
|
+
transform: [{
|
|
304
|
+
translateX: sharedValue.current.interpolate({
|
|
305
|
+
inputRange: interpolationRange,
|
|
306
|
+
outputRange: transformInterpolationOutputRange,
|
|
307
|
+
}),
|
|
308
|
+
}],
|
|
309
|
+
backgroundColor: sharedValue.current.interpolate({
|
|
310
|
+
inputRange: interpolationRange,
|
|
311
|
+
outputRange: [thumbColor.false, thumbColor.true],
|
|
312
|
+
}),
|
|
313
|
+
},
|
|
314
|
+
] }
|
|
315
|
+
>
|
|
316
|
+
{ size === "small" && (
|
|
317
|
+
<IconCheckmarkAnimated
|
|
318
|
+
fill={ mapIconAnimatedFillColor[themeContext.colorScheme] }
|
|
319
|
+
style={{
|
|
320
|
+
opacity: sharedValue.current,
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
) }
|
|
324
|
+
</Animated.View>
|
|
325
|
+
|
|
326
|
+
{ isFocused && (
|
|
327
|
+
<View
|
|
328
|
+
style={ [
|
|
329
|
+
CommonStyleSheet.absolute,
|
|
330
|
+
focusBoxSizeStyle[size],
|
|
331
|
+
baseStyle.focusBox,
|
|
332
|
+
baseStyleCarbon.focusBoxBorderColor,
|
|
333
|
+
] }
|
|
334
|
+
/>
|
|
335
|
+
) }
|
|
336
|
+
</PressableAnimated>
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
},
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
const
|
|
343
|
+
baseStyle =
|
|
344
|
+
StyleSheet.create({
|
|
345
|
+
container: {
|
|
346
|
+
borderRadius: 24,
|
|
347
|
+
},
|
|
348
|
+
thumb: {
|
|
349
|
+
borderRadius: 18,
|
|
350
|
+
},
|
|
351
|
+
focusBox: {
|
|
352
|
+
borderWidth: 2,
|
|
353
|
+
borderRadius: 24,
|
|
354
|
+
transform: [{
|
|
355
|
+
translateX: -3,
|
|
356
|
+
}],
|
|
357
|
+
},
|
|
358
|
+
}),
|
|
359
|
+
|
|
360
|
+
baseStyleCarbon =
|
|
361
|
+
CarbonStyleSheet.create({
|
|
362
|
+
containerReadonly: {
|
|
363
|
+
borderWidth: 1,
|
|
364
|
+
borderColor: CarbonStyleSheet.color.border_subtle_00,
|
|
365
|
+
},
|
|
366
|
+
focusBoxBorderColor: {
|
|
367
|
+
borderColor: CarbonStyleSheet.color.focus,
|
|
368
|
+
},
|
|
369
|
+
}),
|
|
370
|
+
|
|
371
|
+
sizeStyle =
|
|
372
|
+
StyleSheet.create<Record<SwitchSize, Record<"width" | "height", number>>>({
|
|
373
|
+
default: {
|
|
374
|
+
width: 48,
|
|
375
|
+
height: 24,
|
|
376
|
+
},
|
|
377
|
+
small: {
|
|
378
|
+
width: 32,
|
|
379
|
+
height: 16,
|
|
380
|
+
},
|
|
381
|
+
}),
|
|
382
|
+
|
|
383
|
+
thumbSizeStyle =
|
|
384
|
+
StyleSheet.create<typeof sizeStyle>({
|
|
385
|
+
default: {
|
|
386
|
+
width: 18,
|
|
387
|
+
height: 18,
|
|
388
|
+
},
|
|
389
|
+
small: {
|
|
390
|
+
width: 10,
|
|
391
|
+
height: 10,
|
|
392
|
+
},
|
|
393
|
+
}),
|
|
394
|
+
|
|
395
|
+
focusBoxSizeStyle =
|
|
396
|
+
StyleSheet.create<typeof sizeStyle>({
|
|
397
|
+
default: {
|
|
398
|
+
width: sizeStyle.default.width + 6,
|
|
399
|
+
height: sizeStyle.default.height + 6,
|
|
400
|
+
},
|
|
401
|
+
small: {
|
|
402
|
+
width: sizeStyle.small.width + 6,
|
|
403
|
+
height: sizeStyle.small.height + 6,
|
|
404
|
+
},
|
|
405
|
+
}),
|
|
406
|
+
|
|
407
|
+
mapSwitchTrackColorToken: Record<SwitchState | "focused", Partial<Record<"false" | "true", Record<ThemeContext["colorScheme"], string>>>> =
|
|
408
|
+
{
|
|
409
|
+
normal: {
|
|
410
|
+
false: {
|
|
411
|
+
gray_10: Color.Token.gray_10.toggle_off,
|
|
412
|
+
gray_100: Color.Token.gray_100.toggle_off,
|
|
413
|
+
},
|
|
414
|
+
true: {
|
|
415
|
+
gray_10: Color.Token.gray_10.support_success,
|
|
416
|
+
gray_100: Color.Token.gray_100.support_success,
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
disabled: {
|
|
420
|
+
false: {
|
|
421
|
+
gray_10: Color.Token.gray_10.button_disabled,
|
|
422
|
+
gray_100: Color.Token.gray_100.button_disabled,
|
|
423
|
+
},
|
|
424
|
+
true: {
|
|
425
|
+
gray_10: Color.Token.gray_10.button_disabled,
|
|
426
|
+
gray_100: Color.Token.gray_100.button_disabled,
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
read_only: {
|
|
430
|
+
},
|
|
431
|
+
focused: {
|
|
432
|
+
false: {
|
|
433
|
+
gray_10: Color.Token.gray_10.toggle_off,
|
|
434
|
+
gray_100: Color.Token.gray_100.toggle_off,
|
|
435
|
+
},
|
|
436
|
+
true: {
|
|
437
|
+
gray_10: Color.Token.gray_10.support_success,
|
|
438
|
+
gray_100: Color.Token.gray_100.support_success,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
|
|
443
|
+
mapSwitchThumbColorToken: Record<SwitchState | "focused", Record<ThemeContext["colorScheme"], string>> =
|
|
444
|
+
{
|
|
445
|
+
normal: {
|
|
446
|
+
gray_10: Color.Token.gray_10.icon_on_color,
|
|
447
|
+
gray_100: Color.Token.gray_100.icon_on_color,
|
|
448
|
+
},
|
|
449
|
+
disabled: {
|
|
450
|
+
gray_10: Color.Token.gray_10.icon_on_color_disabled,
|
|
451
|
+
gray_100: Color.Token.gray_100.icon_on_color_disabled,
|
|
452
|
+
},
|
|
453
|
+
read_only: {
|
|
454
|
+
gray_10: Color.Token.gray_10.icon_primary,
|
|
455
|
+
gray_100: Color.Token.gray_100.icon_primary,
|
|
456
|
+
},
|
|
457
|
+
focused: {
|
|
458
|
+
gray_10: Color.Token.gray_10.icon_on_color,
|
|
459
|
+
gray_100: Color.Token.gray_100.icon_on_color,
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
interpolationRange =
|
|
464
|
+
[0, 1],
|
|
465
|
+
|
|
466
|
+
motionDefault =
|
|
467
|
+
{
|
|
468
|
+
duration: Motion.Duration.fast_01,
|
|
469
|
+
easing: Easing.bezier(
|
|
470
|
+
Motion.Easing.exit.productive.x1,
|
|
471
|
+
Motion.Easing.exit.productive.y1,
|
|
472
|
+
Motion.Easing.exit.productive.x2,
|
|
473
|
+
Motion.Easing.exit.productive.y2,
|
|
474
|
+
),
|
|
475
|
+
} as const satisfies NonNullable<SwitchProps["motion"]>["false"],
|
|
476
|
+
|
|
477
|
+
PressableAnimated =
|
|
478
|
+
Animated.createAnimatedComponent(Pressable),
|
|
479
|
+
|
|
480
|
+
IconCheckmarkAnimated =
|
|
481
|
+
Animated.createAnimatedComponent(IconCheckmark),
|
|
482
|
+
|
|
483
|
+
mapIconAnimatedFillColor: Record<ThemeContext["colorScheme"], string> =
|
|
484
|
+
{
|
|
485
|
+
gray_10: Color.Token.gray_10.support_success,
|
|
486
|
+
gray_100: Color.Token.gray_100.support_success,
|
|
487
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EasingFunction,
|
|
3
|
+
PressableProps,
|
|
4
|
+
StyleProp,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
} from "react-native"
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
SwitchSize,
|
|
10
|
+
} from "./SwitchSize"
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
SwitchState,
|
|
14
|
+
} from "./SwitchState"
|
|
15
|
+
|
|
16
|
+
export interface SwitchProps extends Omit<PressableProps, "children"> {
|
|
17
|
+
/**
|
|
18
|
+
* @default 'default'
|
|
19
|
+
*/
|
|
20
|
+
size?: SwitchSize,
|
|
21
|
+
/**
|
|
22
|
+
* @default 'normal'
|
|
23
|
+
*/
|
|
24
|
+
state?: SwitchState,
|
|
25
|
+
/**
|
|
26
|
+
* Control `value` prop
|
|
27
|
+
*/
|
|
28
|
+
defaultValue?: boolean,
|
|
29
|
+
value?: boolean,
|
|
30
|
+
trackColor?: Record<"false" | "true", string>,
|
|
31
|
+
thumbColor?: Record<"false" | "true", string>,
|
|
32
|
+
motion?: Record<"false" | "true", {
|
|
33
|
+
duration: number,
|
|
34
|
+
easing?: EasingFunction,
|
|
35
|
+
}>,
|
|
36
|
+
onChange?: (value: boolean) => void,
|
|
37
|
+
style?: StyleProp<ViewStyle>,
|
|
38
|
+
}
|