UNPKG

@audira/carbon-react-native

Version:

Build React Native apps with component and shared patterns using Carbon

68 lines (67 loc) 2.49 kB
"use strict"; import { forwardRef, useContext } from 'react'; import { StyleSheet, View } from 'react-native'; import { Color } from '@audira/carbon-react-native-elements'; import IconCheckmarkFilled from '@carbon/icons/svg/32/checkmark--filled.svg'; import IconErrorFilled from '@carbon/icons/svg/32/error--filled.svg'; import { GlobalConfigContext } from "../../_internal/contexts/index.js"; import { CommonStyleSheet, FlexStyleSheet } from "../../_internal/style-sheets/index.js"; import { CarbonStyleSheet } from "../../carbon-style-sheet/index.js"; import { ThemeContext } from "../../contexts/index.js"; import { Loading } from "../loading/index.js"; import { Text } from "../text/index.js"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export const InlineLoading = /*#__PURE__*/forwardRef(function InlineLoading({ state = 'active', text, style, 'aria-label': ariaLabel, textProps, dir, ...props }, ref) { const themeContext = useContext(ThemeContext), globalConfigContext = useContext(GlobalConfigContext); return /*#__PURE__*/_jsxs(View, { ref: ref, ...props, "aria-label": ariaLabel ?? text, dir: dir ?? globalConfigContext.rtl ? 'rtl' : undefined, style: [FlexStyleSheet.flex_row, FlexStyleSheet.items_center, styleSheet.inlineLoading, globalConfigContext.rtl ? CommonStyleSheet.rtl : undefined, style], children: [state == 'active' ? /*#__PURE__*/_jsx(Loading, { type: "small" }) : state == 'error' ? /*#__PURE__*/_jsx(IconErrorFilled, { width: 16, height: 16, fill: mapIconErrorColor[themeContext.colorScheme] }) : state == 'finished' ? /*#__PURE__*/_jsx(IconCheckmarkFilled, { width: 16, height: 16, fill: mapIconCheckmarkColor[themeContext.colorScheme] }) : null, !!text && /*#__PURE__*/_jsx(Text, { ...textProps, type: "body_compact_01", style: [carbonStyleSheet.text, textProps?.style], children: text })] }); }); const styleSheet = StyleSheet.create({ inlineLoading: { columnGap: 8 } }), carbonStyleSheet = CarbonStyleSheet.create({ text: { color: CarbonStyleSheet.color.text_secondary } }), mapIconErrorColor = { gray_10: Color.Token.gray_10.support_error, gray_100: Color.Token.gray_100.support_error }, mapIconCheckmarkColor = { gray_10: Color.Token.gray_10.support_success, gray_100: Color.Token.gray_100.support_success }; //# sourceMappingURL=InlineLoading.js.map