@audira/carbon-react-native
Version:
Build React Native apps with component and shared patterns using Carbon
37 lines (36 loc) • 1.16 kB
JavaScript
;
import { forwardRef, useContext } from 'react';
import { StyleSheet, View } from 'react-native';
import { GlobalConfigContext } from "../../_internal/contexts/index.js";
import { CommonStyleSheet, FlexStyleSheet } from "../../_internal/style-sheets/index.js";
import { Text } from "../text/index.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export const FormLabel = /*#__PURE__*/forwardRef(function FormLabel({
label,
labelLeading,
labelTrailing,
textProps,
style,
dir,
...props
}, ref) {
const globalConfigContext = useContext(GlobalConfigContext);
return /*#__PURE__*/_jsxs(View, {
...props,
ref: ref,
dir: dir ?? globalConfigContext.rtl ? 'rtl' : undefined,
style: [FlexStyleSheet.flex_row, baseStyle.gap, globalConfigContext.rtl ? CommonStyleSheet.rtl : undefined, style],
children: [labelLeading, /*#__PURE__*/_jsx(Text, {
...textProps,
type: textProps?.type || 'label_01',
"aria-label": label,
children: label
}), labelTrailing]
});
});
const baseStyle = StyleSheet.create({
gap: {
columnGap: 8
}
});
//# sourceMappingURL=FormLabel.js.map