3ed96a3acd653fa758dd2d37ca4eea82.json 8.51 KB
{"ast":null,"code":"import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport Icon from './Icon';\nvar customCache = new Set();\n\nfunction isValidCustomScriptUrl(scriptUrl) {\n  return Boolean(typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl));\n}\n\nfunction createScriptUrlElements(scriptUrls) {\n  var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n  var currentScriptUrl = scriptUrls[index];\n\n  if (isValidCustomScriptUrl(currentScriptUrl)) {\n    var script = document.createElement('script');\n    script.setAttribute('src', currentScriptUrl);\n    script.setAttribute('data-namespace', currentScriptUrl);\n\n    if (scriptUrls.length > index + 1) {\n      script.onload = function () {\n        createScriptUrlElements(scriptUrls, index + 1);\n      };\n\n      script.onerror = function () {\n        createScriptUrlElements(scriptUrls, index + 1);\n      };\n    }\n\n    customCache.add(currentScriptUrl);\n    document.body.appendChild(script);\n  }\n}\n\nexport default function create() {\n  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  var scriptUrl = options.scriptUrl,\n      _options$extraCommonP = options.extraCommonProps,\n      extraCommonProps = _options$extraCommonP === void 0 ? {} : _options$extraCommonP;\n  /**\n   * DOM API required.\n   * Make sure in browser environment.\n   * The Custom Icon will create a <script/>\n   * that loads SVG symbols and insert the SVG Element into the document body.\n   */\n\n  if (scriptUrl && typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function') {\n    if (Array.isArray(scriptUrl)) {\n      // 因为iconfont资源会把svg插入before,所以前加载相同type会覆盖后加载,为了数组覆盖顺序,倒叙插入\n      createScriptUrlElements(scriptUrl.reverse());\n    } else {\n      createScriptUrlElements([scriptUrl]);\n    }\n  }\n\n  var Iconfont = /*#__PURE__*/React.forwardRef(function (props, ref) {\n    var type = props.type,\n        children = props.children,\n        restProps = _objectWithoutProperties(props, [\"type\", \"children\"]); // children > type\n\n\n    var content = null;\n\n    if (props.type) {\n      content = /*#__PURE__*/React.createElement(\"use\", {\n        xlinkHref: \"#\".concat(type)\n      });\n    }\n\n    if (children) {\n      content = children;\n    }\n\n    return /*#__PURE__*/React.createElement(Icon, Object.assign({}, extraCommonProps, restProps, {\n      ref: ref\n    }), content);\n  });\n  Iconfont.displayName = 'Iconfont';\n  return Iconfont;\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/@ant-design/icons/es/components/IconFont.js"],"names":["_objectWithoutProperties","React","Icon","customCache","Set","isValidCustomScriptUrl","scriptUrl","Boolean","length","has","createScriptUrlElements","scriptUrls","index","arguments","undefined","currentScriptUrl","script","document","createElement","setAttribute","onload","onerror","add","body","appendChild","create","options","_options$extraCommonP","extraCommonProps","window","Array","isArray","reverse","Iconfont","forwardRef","props","ref","type","children","restProps","content","xlinkHref","concat","Object","assign","displayName"],"mappings":"AAAA,OAAOA,wBAAP,MAAqC,oDAArC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,IAAIC,WAAW,GAAG,IAAIC,GAAJ,EAAlB;;AAEA,SAASC,sBAAT,CAAgCC,SAAhC,EAA2C;AACzC,SAAOC,OAAO,CAAC,OAAOD,SAAP,KAAqB,QAArB,IAAiCA,SAAS,CAACE,MAA3C,IAAqD,CAACL,WAAW,CAACM,GAAZ,CAAgBH,SAAhB,CAAvD,CAAd;AACD;;AAED,SAASI,uBAAT,CAAiCC,UAAjC,EAA6C;AAC3C,MAAIC,KAAK,GAAGC,SAAS,CAACL,MAAV,GAAmB,CAAnB,IAAwBK,SAAS,CAAC,CAAD,CAAT,KAAiBC,SAAzC,GAAqDD,SAAS,CAAC,CAAD,CAA9D,GAAoE,CAAhF;AACA,MAAIE,gBAAgB,GAAGJ,UAAU,CAACC,KAAD,CAAjC;;AAEA,MAAIP,sBAAsB,CAACU,gBAAD,CAA1B,EAA8C;AAC5C,QAA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,EAA8B;AAC5B;AACAI,MAAAA,uBAAuB,CAACJ,SAAS,CAAC0B,OAAV,EAAD,CAAvB;AACD,KAHD,MAGO;AACLtB,MAAAA,uBAAuB,CAAC,CAACJ,SAAD,CAAD,CAAvB;AACD;AACF;;AAED,MAAI2B,QAAQ,GAAG,aAAahC,KAAK,CAACiC,UAAN,CAAiB,UAAUC,KAAV,EAAiBC,GAAjB,EAAsB;AACjE,QAAIC,IAAI,GAAGF,KAAK,CAACE,IAAjB;AAAA,QACIC,QAAQ,GAAGH,KAAK,CAACG,QADrB;AAAA,QAEIC,SAAS,GAAGvC,wBAAwB,CAACmC,KAAD,EAAQ,CAAC,MAAD,EAAS,UAAT,CAAR,CAFxC,CADiE,CAGM;;;AAGvE,QAAIK,OAAO,GAAG,IAAd;;AAEA,QAAIL,KAAK,CAACE,IAAV,EAAgB;AACdG,MAAAA,OAAO,GAAG,aAAavC,KAAK,CAACiB,aAAN,CAAoB,KAApB,EAA2B;AAChDuB,QAAAA,SAAS,EAAE,IAAIC,MAAJ,CAAWL,IAAX;AADqC,OAA3B,CAAvB;AAGD;;AAED,QAAIC,QAAJ,EAAc;AACZE,MAAAA,OAAO,GAAGF,QAAV;AACD;;AAED,WAAO,aAAarC,KAAK,CAACiB,aAAN,CAAoBhB,IAApB,EAA0ByC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBhB,gBAAlB,EAAoCW,SAApC,EAA+C;AAC3FH,MAAAA,GAAG,EAAEA;AADsF,KAA/C,CAA1B,EAEhBI,OAFgB,CAApB;AAGD,GArB2B,CAA5B;AAsBAP,EAAAA,QAAQ,CAACY,WAAT,GAAuB,UAAvB;AACA,SAAOZ,QAAP;AACD","sourcesContent":["import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport Icon from './Icon';\nvar customCache = new Set();\n\nfunction isValidCustomScriptUrl(scriptUrl) {\n  return Boolean(typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl));\n}\n\nfunction createScriptUrlElements(scriptUrls) {\n  var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n  var currentScriptUrl = scriptUrls[index];\n\n  if (isValidCustomScriptUrl(currentScriptUrl)) {\n    var script = document.createElement('script');\n    script.setAttribute('src', currentScriptUrl);\n    script.setAttribute('data-namespace', currentScriptUrl);\n\n    if (scriptUrls.length > index + 1) {\n      script.onload = function () {\n        createScriptUrlElements(scriptUrls, index + 1);\n      };\n\n      script.onerror = function () {\n        createScriptUrlElements(scriptUrls, index + 1);\n      };\n    }\n\n    customCache.add(currentScriptUrl);\n    document.body.appendChild(script);\n  }\n}\n\nexport default function create() {\n  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  var scriptUrl = options.scriptUrl,\n      _options$extraCommonP = options.extraCommonProps,\n      extraCommonProps = _options$extraCommonP === void 0 ? {} : _options$extraCommonP;\n  /**\n   * DOM API required.\n   * Make sure in browser environment.\n   * The Custom Icon will create a <script/>\n   * that loads SVG symbols and insert the SVG Element into the document body.\n   */\n\n  if (scriptUrl && typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function') {\n    if (Array.isArray(scriptUrl)) {\n      // 因为iconfont资源会把svg插入before,所以前加载相同type会覆盖后加载,为了数组覆盖顺序,倒叙插入\n      createScriptUrlElements(scriptUrl.reverse());\n    } else {\n      createScriptUrlElements([scriptUrl]);\n    }\n  }\n\n  var Iconfont = /*#__PURE__*/React.forwardRef(function (props, ref) {\n    var type = props.type,\n        children = props.children,\n        restProps = _objectWithoutProperties(props, [\"type\", \"children\"]); // children > type\n\n\n    var content = null;\n\n    if (props.type) {\n      content = /*#__PURE__*/React.createElement(\"use\", {\n        xlinkHref: \"#\".concat(type)\n      });\n    }\n\n    if (children) {\n      content = children;\n    }\n\n    return /*#__PURE__*/React.createElement(Icon, Object.assign({}, extraCommonProps, restProps, {\n      ref: ref\n    }), content);\n  });\n  Iconfont.displayName = 'Iconfont';\n  return Iconfont;\n}"]},"metadata":{},"sourceType":"module"}