UNPKG

@audira/carbon-react-native

Version:

Build React Native apps with component and shared patterns using Carbon

63 lines (62 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ToastVariant = void 0; var _react = require("react"); var _reactNative = require("react-native"); var _carbonReactNativeElements = require("@audira/carbon-react-native-elements"); var _VariantContextProvider = require("../../_VariantContextProvider.js"); var _index = require("../../base/index.js"); var _index2 = require("../../subtitle/index.js"); var _jsxRuntime = require("react/jsx-runtime"); const ToastVariant = exports.ToastVariant = /*#__PURE__*/(0, _react.forwardRef)(function ToastVariant({ color, Icon, timestamp, subtitle, subtitleStyle, ...props }, ref) { return /*#__PURE__*/(0, _jsxRuntime.jsx)(_VariantContextProvider.VariantContextProvider, { color: color, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Base, { ...props, inline: false, Icon: Icon, iconClose: true, body: subtitle && (typeof subtitle === 'string' || typeof subtitle === 'number') ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Subtitle, { style: subtitleStyle, children: subtitle }) : subtitle, nodes: { beforeContentContainerEnd: timestamp ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Subtitle, { style: baseStyle.timestamp, children: timestamp }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(Timestamp, {}) }, ref: ref }) }); }); const baseStyle = _reactNative.StyleSheet.create({ timestamp: { marginTop: _carbonReactNativeElements.Spacing.spacing_06 } }); function Timestamp({ style, ...props }) { return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Subtitle, { ...props, style: [baseStyle.timestamp, style], children: new Date().toLocaleString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true }) }); } //# sourceMappingURL=ToastVariant.js.map