UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

31 lines (28 loc) • 2.09 kB
import { cloneElement, isValidElement } from "react"; import { StyleSheet } from "react-native"; import { Image } from "../generated/Controls.native.js"; function Icon(param) { var { icons, colorRole, color } = param; var _ref, _ref1, _ref2; var _icons_ios_props_swiftStyle, _icons_ios_props_swiftStyle1, _icons_ios_props_swiftStyle2, _icons_ios_props_swiftStyle3, _icons_ios_props_swiftStyle4; if (!/* @__PURE__ */ isValidElement(icons.ios) || icons.ios.type !== Image) throw new Error("One.UI.Icon icons.ios must be a One.iOS.Image element"); var fallbackSize = (_ref = (_icons_ios_props_swiftStyle = icons.ios.props.swiftStyle) === null || _icons_ios_props_swiftStyle === void 0 ? void 0 : _icons_ios_props_swiftStyle.fontSize) !== null && _ref !== void 0 ? _ref : 24; var style = [{ width: (_ref1 = (_icons_ios_props_swiftStyle1 = icons.ios.props.swiftStyle) === null || _icons_ios_props_swiftStyle1 === void 0 ? void 0 : _icons_ios_props_swiftStyle1.width) !== null && _ref1 !== void 0 ? _ref1 : fallbackSize, height: (_ref2 = (_icons_ios_props_swiftStyle2 = icons.ios.props.swiftStyle) === null || _icons_ios_props_swiftStyle2 === void 0 ? void 0 : _icons_ios_props_swiftStyle2.height) !== null && _ref2 !== void 0 ? _ref2 : fallbackSize }, icons.ios.props.style]; var { width, height } = StyleSheet.flatten(style); return /* @__PURE__ */ cloneElement(icons.ios, { colorRole: color === void 0 ? colorRole !== null && colorRole !== void 0 ? colorRole : "primary" : void 0, style, swiftStyle: { ...icons.ios.props.swiftStyle, fontSize: fallbackSize, width: typeof width === "number" ? width : (_icons_ios_props_swiftStyle3 = icons.ios.props.swiftStyle) === null || _icons_ios_props_swiftStyle3 === void 0 ? void 0 : _icons_ios_props_swiftStyle3.width, height: typeof height === "number" ? height : (_icons_ios_props_swiftStyle4 = icons.ios.props.swiftStyle) === null || _icons_ios_props_swiftStyle4 === void 0 ? void 0 : _icons_ios_props_swiftStyle4.height, foregroundStyle: color } }); } export { Icon }; //# sourceMappingURL=Icon.ios.js.map