You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
11 KiB

{"ast":null,"code":"import _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nimport * as Font from \"expo-font\";\nimport React from \"react\";\nimport Text from \"react-native-web/dist/exports/Text\";\nimport createIconSet from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\nimport createIconButtonComponent from \"./vendor/react-native-vector-icons/lib/icon-button\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\nexport default function (glyphMap, fontName, expoAssetId, fontStyle) {\n var _a;\n var font = _defineProperty({}, fontName, expoAssetId);\n var RNVIconComponent = createIconSet(glyphMap, fontName, null, fontStyle);\n return _a = function (_React$Component) {\n _inherits(Icon, _React$Component);\n var _super = _createSuper(Icon);\n function Icon() {\n var _this;\n _classCallCheck(this, Icon);\n _this = _super.apply(this, arguments);\n _this._mounted = false;\n _this.state = {\n fontIsLoaded: Font.isLoaded(fontName)\n };\n return _this;\n }\n _createClass(Icon, [{\n key: \"componentDidMount\",\n value: function () {\n var _componentDidMount = _asyncToGenerator(function* () {\n this._mounted = true;\n if (!this.state.fontIsLoaded) {\n yield Font.loadAsync(font);\n this._mounted && this.setState({\n fontIsLoaded: true\n });\n }\n });\n function componentDidMount() {\n return _componentDidMount.apply(this, arguments);\n }\n return componentDidMount;\n }()\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n this._mounted = false;\n }\n }, {\n key: \"setNativeProps\",\n value: function setNativeProps(props) {\n if (this._icon) {\n this._icon.setNativeProps(props);\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n if (__DEV__ && this.props.name && !(this.props.name in glyphMap)) {\n console.warn(\"\\\"\" + this.props.name + \"\\\" is not a valid icon name for family \\\"\" + fontName + \"\\\"\");\n }\n if (!this.state.fontIsLoaded) {\n return _jsx(Text, {});\n }\n return _jsx(RNVIconComponent, _objectSpread({\n ref: function ref(view) {\n _this2._icon = view;\n }\n }, this.props));\n }\n }]);\n return Icon;\n }(React.Component), _a.defaultProps = RNVIconComponent.defaultProps, _a.Button = createIconButtonComponent(_a), _a.glyphMap = glyphMap, _a.getRawGlyphMap = function () {\n return glyphMap;\n }, _a.getFontFamily = function () {\n return fontName;\n }, _a.loadFont = function () {\n return Font.loadAsync(font);\n }, _a.font = font, _a;\n}","map":{"version":3,"sources":["../src/createIconSet.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,WAAW;AACjC,OAAO,KAAyB,MAAM,OAAO;AAAC;AAW9C,OAAO,aAAa;AACpB,OAAO,yBAAyB;AAA2D;AAE3F,SACE,kBAAkB,EAClB,iBAAiB;AAqFnB,eAAc,UACZ,QAAqB,EACrB,QAAY,EACZ,WAAW,EACX,SAAe,EAAA;;EAEf,IAAM,IAAI,uBAAM,QAAQ,EAAG,WAAW,CAAE;EACxC,IAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC;EAE3E,OAAA,EAAA;IAAA;IAAA;IAAO,gBAAA;MAAA;MAAA;;MASL,MAAA,QAAQ,GAAG,KAAK;MAGhB,MAAA,KAAK,GAAG;QACN,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;OACrC;MAAC;IAwCJ;IAAC;MAAA;MAAA;QAAA,2CAtCC,aAAuB;UACrB,IAAI,CAAC,QAAQ,GAAG,IAAI;UACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;YAC5B,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;cAAE,YAAY,EAAE;YAAI,CAAE,CAAC;UACvD;QACH,CAAC;QAAA;UAAA;QAAA;QAAA;MAAA;IAAA;MAAA;MAAA,OAED,gCAAoB;QAClB,IAAI,CAAC,QAAQ,GAAG,KAAK;MACvB;IAAC;MAAA;MAAA,OAED,wBAAe,KAAK,EAAA;QAClB,IAAI,IAAI,CAAC,KAAK,EAAE;UACd,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;QACjC;MACH;IAAC;MAAA;MAAA,OAED,kBAAM;QAAA;QACJ,IAAI,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,EAAE;UAChE,OAAO,CAAC,IAAI,QACN,IAAI,CAAC,KAAK,CAAC,IAAI,iDAA0C,QAAQ,QACtE;QACF;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;UAC5B,OAAO,KAAC,IAAI,KAAG;QAChB;QAED,OACE,KAAC,gBAAgB;UACf,GAAG,EAAE,aAAC,IAAI,EAAI;YACZ,MAAI,CAAC,KAAK,GAAG,IAAI;UACnB;QAAE,GACE,IAAI,CAAC,KAAK,EACd;MAEN;IAAC;IAAA;EAAA,EArDuB,KAAK,CAAC,SAAuB,CAsDtD,EArDQ,EAAA,CAAA,YAAY,GAAG,gBAAgB,CAAC,YAAa,EAC7C,EAAA,CAAA,MAAM,GAAG,yBAAyB,CAAC,EAAI,CAAE,EACzC,EAAA,CAAA,QAAQ,GAAG,QAAS,EACpB,EAAA,CAAA,cAAc,GAAG;IAAA,OAAM,QAAS;EAAA,GAChC,EAAA,CAAA,aAAa,GAAG;IAAA,OAAM,QAAS;EAAA,GAC/B,EAAA,CAAA,QAAQ,GAAG;IAAA,OAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE;EAAA,GACtC,EAAA,CAAA,IAAI,GAAG,IAAK,E,EA+CnB;AACJ","sourcesContent":["import * as Font from \"expo-font\";\nimport React, { ComponentClass } from \"react\";\nimport {\n Text,\n TextProps,\n TouchableHighlightProps,\n ViewProps,\n OpaqueColorValue,\n TextStyle,\n ViewStyle,\n} from \"react-native\";\n\nimport createIconSet from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\nimport createIconButtonComponent from \"./vendor/react-native-vector-icons/lib/icon-button\";\n\nexport {\n DEFAULT_ICON_COLOR,\n DEFAULT_ICON_SIZE,\n} from \"./vendor/react-native-vector-icons/lib/create-icon-set\";\n\nexport interface IconProps<GLYPHS extends string> extends TextProps {\n /**\n * Size of the icon, can also be passed as fontSize in the style object.\n *\n * @default 12\n */\n size?: number;\n\n /**\n * Name of the icon to show\n *\n * See Icon Explorer app\n * {@link https://expo.github.io/vector-icons/}\n */\n name: GLYPHS;\n\n /**\n * Color of the icon. Can be a string or OpaqueColorValue (returned from\n * PlatformColor(..))\n *\n */\n color?: string | OpaqueColorValue;\n}\n\nexport interface IconButtonProps<GLYPHS extends string>\n extends IconProps<GLYPHS>,\n ViewProps,\n TouchableHighlightProps {\n /**\n * Text and icon color\n * Use iconStyle or nest a Text component if you need different colors.\n * Can be a string or OpaqueColorValue (returned from PlatformColor(..))\n *\n * @default 'white'\n */\n color?: string | OpaqueColorValue;\n\n /**\n * Border radius of the button\n * Set to 0 to disable.\n *\n * @default 5\n */\n borderRadius?: number;\n\n /**\n * Styles applied to the icon only\n * Good for setting margins or a different color.\n *\n * @default {marginRight: 10}\n */\n iconStyle?: TextStyle;\n\n /**\n * Style prop inherited from TextProps and TouchableWithoutFeedbackProperties\n * Only exist here so we can have ViewStyle or TextStyle\n *\n */\n style?: ViewStyle | TextStyle;\n\n /**\n * Background color of the button. Can be a string or OpaqueColorValue (returned from\n * PlatformColor(..))\n *\n * @default '#007AFF'\n */\n backgroundColor?: string | OpaqueColorValue;\n}\n\nexport type GlyphMap<G extends string> = { [K in G]: number | string };\n\nexport interface Icon<G extends string, FN extends string> {\n defaultProps: any;\n Button: ComponentClass<IconButtonProps<G>>;\n glyphMap: GlyphMap<G>;\n getRawGlyphMap: () => GlyphMap<G>;\n getFontFamily: () => FN;\n loadFont: () => Promise<void>;\n font: { [x: string]: any };\n new (props: IconProps<G>): React.Component<IconProps<G>>;\n}\n\nexport default function <G extends string, FN extends string>(\n glyphMap: GlyphMap<G>,\n fontName: FN,\n expoAssetId,\n fontStyle?: any\n): Icon<G, FN> {\n const font = { [fontName]: expoAssetId };\n const RNVIconComponent = createIconSet(glyphMap, fontName, null, fontStyle);\n\n return class Icon extends React.Component<IconProps<G>> {\n static defaultProps = RNVIconComponent.defaultProps;\n static Button = createIconButtonComponent(Icon);\n static glyphMap = glyphMap;\n static getRawGlyphMap = () => glyphMap;\n static getFontFamily = () => fontName;\n static loadFont = () => Font.loadAsync(font);\n static font = font;\n\n _mounted = false;\n _icon?: any;\n\n state = {\n fontIsLoaded: Font.isLoaded(fontName),\n };\n\n async componentDidMount() {\n this._mounted = true;\n if (!this.state.fontIsLoaded) {\n await Font.loadAsync(font);\n this._mounted && this.setState({ fontIsLoaded: true });\n }\n }\n\n componentWillUnmount() {\n this._mounted = false;\n }\n\n setNativeProps(props) {\n if (this._icon) {\n this._icon.setNativeProps(props);\n }\n }\n\n render() {\n if (__DEV__ && this.props.name && !(this.props.name in glyphMap)) {\n console.warn(\n `\"${this.props.name}\" is not a valid icon name for family \"${fontName}\"`\n );\n }\n\n if (!this.state.fontIsLoaded) {\n return <Text />;\n }\n\n return (\n <RNVIconComponent\n ref={(view) => {\n this._icon = view;\n }}\n {...this.props}\n />\n );\n }\n };\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}