yc-pro-components 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/es/components/check-card/index.d.ts +57 -57
  2. package/es/components/check-card/src/index.vue.d.ts +14 -14
  3. package/es/components/check-card-group/index.d.ts +22 -22
  4. package/es/components/check-card-group/src/index.vue.d.ts +19 -19
  5. package/es/components/date-picker/index.d.ts +1 -1
  6. package/es/components/date-picker/src/index.vue.d.ts +1 -1
  7. package/es/components/descriptions/index.d.ts +39 -39
  8. package/es/components/descriptions/src/index.vue.d.ts +2 -2
  9. package/es/components/dialog/index.d.ts +19 -19
  10. package/es/components/dialog/src/index.vue.d.ts +1 -1
  11. package/es/components/dialog-form/index.d.ts +47 -47
  12. package/es/components/dialog-form/src/index.vue.d.ts +7 -7
  13. package/es/components/display-item/index.d.ts +12 -12
  14. package/es/components/display-item/src/index.vue.d.ts +12 -12
  15. package/es/components/drawer-form/index.d.ts +28 -28
  16. package/es/components/drawer-form/src/index.vue.d.ts +6 -6
  17. package/es/components/form/index.d.ts +107 -107
  18. package/es/components/form/src/form-content.vue.d.ts +17 -17
  19. package/es/components/form/src/index.vue.d.ts +16 -16
  20. package/es/components/form-item/index.d.ts +106 -106
  21. package/es/components/form-item/src/index.vue.d.ts +14 -14
  22. package/es/components/header/index.d.ts +19 -19
  23. package/es/components/header/src/index.vue.d.ts +1 -1
  24. package/es/components/index.d.ts +0 -1
  25. package/es/components/index.mjs +0 -2
  26. package/es/components/input-tag/index.d.ts +11 -11
  27. package/es/components/input-tag/src/index.vue.d.ts +3 -3
  28. package/es/components/page/index.d.ts +900 -900
  29. package/es/components/page/src/index.vue.d.ts +289 -289
  30. package/es/components/pagination/index.d.ts +4 -4
  31. package/es/components/pagination/src/index.vue.d.ts +1 -1
  32. package/es/components/radio/index.d.ts +26 -26
  33. package/es/components/radio/src/index.vue.d.ts +26 -26
  34. package/es/components/render/index.d.ts +17 -17
  35. package/es/components/render/src/index.vue.d.ts +2 -2
  36. package/es/components/search/index.d.ts +328 -328
  37. package/es/components/search/src/index.vue.d.ts +95 -95
  38. package/es/components/steps-form/index.d.ts +23 -23
  39. package/es/components/steps-form/src/index.vue.d.ts +2 -2
  40. package/es/components/table/index.d.ts +74 -74
  41. package/es/components/table/src/index.vue.d.ts +19 -19
  42. package/es/components/table/src/table-action-bar.vue.d.ts +3 -3
  43. package/es/components/table/src/table-column-drag-sort.vue.d.ts +18 -18
  44. package/es/components/table/src/table-column.vue.d.ts +12 -12
  45. package/es/components/utils/index.d.ts +15 -15
  46. package/es/components/yc-count-to/index.d.ts +1 -1
  47. package/es/components/yc-count-to/src/normal/index.d.ts +1 -1
  48. package/es/components/yc-download-dialog/index.d.ts +19 -19
  49. package/es/components/yc-download-dialog/src/index.vue.d.ts +1 -1
  50. package/es/components/yc-drawer/store.d.ts +6 -6
  51. package/es/components/yc-form-container-header/index.d.ts +12 -12
  52. package/es/components/yc-more-actions/index.d.ts +46 -46
  53. package/es/components/yc-more-actions/src/index.vue.d.ts +3 -3
  54. package/es/components/yc-plus-page/src/index.vue.d.ts +677 -677
  55. package/es/components/yc-plus-tree/src/index.vue.d.ts +1 -1
  56. package/es/components/yc-segmented/index.d.ts +1 -1
  57. package/es/components/yc-segmented/src/index.d.ts +1 -1
  58. package/es/components/yc-select-v2/src/index.vue.d.ts +3 -3
  59. package/es/components/yc-status-dialog/src/index.vue.d.ts +2 -2
  60. package/es/components/yc-status-dialog/src/index.vue.mjs +1 -1
  61. package/es/components/yc-text/src/index.vue.d.ts +2 -2
  62. package/es/hooks/usePlusFormReset.d.ts +193 -193
  63. package/es/index.css +2 -2
  64. package/es/index.mjs +0 -2
  65. package/index.css +19 -14
  66. package/index.js +10 -2049
  67. package/index.min.css +2 -2
  68. package/index.min.js +7 -7
  69. package/index.min.mjs +7 -7
  70. package/index.mjs +11 -2043
  71. package/lib/components/check-card/index.d.ts +57 -57
  72. package/lib/components/check-card/src/index.vue.d.ts +14 -14
  73. package/lib/components/check-card-group/index.d.ts +22 -22
  74. package/lib/components/check-card-group/src/index.vue.d.ts +19 -19
  75. package/lib/components/date-picker/index.d.ts +1 -1
  76. package/lib/components/date-picker/src/index.vue.d.ts +1 -1
  77. package/lib/components/descriptions/index.d.ts +39 -39
  78. package/lib/components/descriptions/src/index.vue.d.ts +2 -2
  79. package/lib/components/dialog/index.d.ts +19 -19
  80. package/lib/components/dialog/src/index.vue.d.ts +1 -1
  81. package/lib/components/dialog-form/index.d.ts +47 -47
  82. package/lib/components/dialog-form/src/index.vue.d.ts +7 -7
  83. package/lib/components/display-item/index.d.ts +12 -12
  84. package/lib/components/display-item/src/index.vue.d.ts +12 -12
  85. package/lib/components/drawer-form/index.d.ts +28 -28
  86. package/lib/components/drawer-form/src/index.vue.d.ts +6 -6
  87. package/lib/components/form/index.d.ts +107 -107
  88. package/lib/components/form/src/form-content.vue.d.ts +17 -17
  89. package/lib/components/form/src/index.vue.d.ts +16 -16
  90. package/lib/components/form-item/index.d.ts +106 -106
  91. package/lib/components/form-item/src/index.vue.d.ts +14 -14
  92. package/lib/components/header/index.d.ts +19 -19
  93. package/lib/components/header/src/index.vue.d.ts +1 -1
  94. package/lib/components/index.d.ts +0 -1
  95. package/lib/components/index.js +10 -19
  96. package/lib/components/input-tag/index.d.ts +11 -11
  97. package/lib/components/input-tag/src/index.vue.d.ts +3 -3
  98. package/lib/components/page/index.d.ts +900 -900
  99. package/lib/components/page/src/index.vue.d.ts +289 -289
  100. package/lib/components/pagination/index.d.ts +4 -4
  101. package/lib/components/pagination/src/index.vue.d.ts +1 -1
  102. package/lib/components/radio/index.d.ts +26 -26
  103. package/lib/components/radio/src/index.vue.d.ts +26 -26
  104. package/lib/components/render/index.d.ts +17 -17
  105. package/lib/components/render/src/index.vue.d.ts +2 -2
  106. package/lib/components/search/index.d.ts +328 -328
  107. package/lib/components/search/src/index.vue.d.ts +95 -95
  108. package/lib/components/steps-form/index.d.ts +23 -23
  109. package/lib/components/steps-form/src/index.vue.d.ts +2 -2
  110. package/lib/components/table/index.d.ts +74 -74
  111. package/lib/components/table/src/index.vue.d.ts +19 -19
  112. package/lib/components/table/src/table-action-bar.vue.d.ts +3 -3
  113. package/lib/components/table/src/table-column-drag-sort.vue.d.ts +18 -18
  114. package/lib/components/table/src/table-column.vue.d.ts +12 -12
  115. package/lib/components/utils/index.d.ts +15 -15
  116. package/lib/components/yc-count-to/index.d.ts +1 -1
  117. package/lib/components/yc-count-to/src/normal/index.d.ts +1 -1
  118. package/lib/components/yc-download-dialog/index.d.ts +19 -19
  119. package/lib/components/yc-download-dialog/src/index.vue.d.ts +1 -1
  120. package/lib/components/yc-drawer/store.d.ts +6 -6
  121. package/lib/components/yc-form-container-header/index.d.ts +12 -12
  122. package/lib/components/yc-more-actions/index.d.ts +46 -46
  123. package/lib/components/yc-more-actions/src/index.vue.d.ts +3 -3
  124. package/lib/components/yc-plus-page/src/index.vue.d.ts +677 -677
  125. package/lib/components/yc-plus-tree/src/index.vue.d.ts +1 -1
  126. package/lib/components/yc-segmented/index.d.ts +1 -1
  127. package/lib/components/yc-segmented/src/index.d.ts +1 -1
  128. package/lib/components/yc-select-v2/src/index.vue.d.ts +3 -3
  129. package/lib/components/yc-status-dialog/src/index.vue.d.ts +2 -2
  130. package/lib/components/yc-status-dialog/src/index.vue.js +1 -1
  131. package/lib/components/yc-text/src/index.vue.d.ts +2 -2
  132. package/lib/hooks/usePlusFormReset.d.ts +193 -193
  133. package/lib/index.css +2 -2
  134. package/lib/index.js +10 -19
  135. package/locale/en.js +1 -1
  136. package/locale/en.min.js +1 -1
  137. package/locale/en.min.mjs +1 -1
  138. package/locale/en.mjs +1 -1
  139. package/locale/ja.js +1 -1
  140. package/locale/ja.min.js +1 -1
  141. package/locale/ja.min.mjs +1 -1
  142. package/locale/ja.mjs +1 -1
  143. package/locale/ko.js +1 -1
  144. package/locale/ko.min.js +1 -1
  145. package/locale/ko.min.mjs +1 -1
  146. package/locale/ko.mjs +1 -1
  147. package/locale/zh-cn.js +1 -1
  148. package/locale/zh-cn.min.js +1 -1
  149. package/locale/zh-cn.min.mjs +1 -1
  150. package/locale/zh-cn.mjs +1 -1
  151. package/locale/zh-tw.js +1 -1
  152. package/locale/zh-tw.min.js +1 -1
  153. package/locale/zh-tw.min.mjs +1 -1
  154. package/locale/zh-tw.mjs +1 -1
  155. package/package.json +1 -2
  156. package/theme-chalk/index.css +1 -1
  157. package/theme-chalk/plus-yc-line-tree.css +1 -0
  158. package/theme-chalk/plus-yc-plus-tree.css +1 -1
  159. package/theme-chalk/plus-yc-status-dialog.css +1 -1
  160. package/theme-chalk/src/index.scss +1 -0
  161. package/theme-chalk/src/yc-line-tree.scss +64 -0
  162. package/theme-chalk/src/yc-plus-tree.scss +102 -0
  163. package/theme-chalk/src/yc-status-dialog.scss +7 -4
  164. package/es/components/yc-icon/index.d.ts +0 -49
  165. package/es/components/yc-icon/index.mjs +0 -10
  166. package/es/components/yc-icon/src/hooks.d.ts +0 -11
  167. package/es/components/yc-icon/src/hooks.mjs +0 -80
  168. package/es/components/yc-icon/src/iconfont.d.ts +0 -21
  169. package/es/components/yc-icon/src/iconfont.mjs +0 -45
  170. package/es/components/yc-icon/src/iconifyIconOffline.d.ts +0 -34
  171. package/es/components/yc-icon/src/iconifyIconOffline.mjs +0 -51
  172. package/es/components/yc-icon/src/iconifyIconOnline.d.ts +0 -19
  173. package/es/components/yc-icon/src/iconifyIconOnline.mjs +0 -30
  174. package/es/components/yc-icon/src/types.d.ts +0 -35
  175. package/es/components/yc-icon/src/types.mjs +0 -1
  176. package/lib/components/yc-icon/index.d.ts +0 -49
  177. package/lib/components/yc-icon/index.js +0 -18
  178. package/lib/components/yc-icon/src/hooks.d.ts +0 -11
  179. package/lib/components/yc-icon/src/hooks.js +0 -82
  180. package/lib/components/yc-icon/src/iconfont.d.ts +0 -21
  181. package/lib/components/yc-icon/src/iconfont.js +0 -49
  182. package/lib/components/yc-icon/src/iconifyIconOffline.d.ts +0 -34
  183. package/lib/components/yc-icon/src/iconifyIconOffline.js +0 -55
  184. package/lib/components/yc-icon/src/iconifyIconOnline.d.ts +0 -19
  185. package/lib/components/yc-icon/src/iconifyIconOnline.js +0 -34
  186. package/lib/components/yc-icon/src/types.d.ts +0 -35
  187. package/lib/components/yc-icon/src/types.js +0 -2
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! yc-pro-components v0.0.5 */
1
+ /*! yc-pro-components v0.0.7 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('element-plus')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'vue', 'element-plus'], factory) :
@@ -1169,7 +1169,7 @@
1169
1169
  objectTag$4 = '[object Object]',
1170
1170
  regexpTag$3 = '[object RegExp]',
1171
1171
  setTag$5 = '[object Set]',
1172
- stringTag$4 = '[object String]',
1172
+ stringTag$3 = '[object String]',
1173
1173
  weakMapTag$2 = '[object WeakMap]';
1174
1174
 
1175
1175
  var arrayBufferTag$3 = '[object ArrayBuffer]',
@@ -1197,7 +1197,7 @@
1197
1197
  typedArrayTags[errorTag$2] = typedArrayTags[funcTag$1] =
1198
1198
  typedArrayTags[mapTag$5] = typedArrayTags[numberTag$4] =
1199
1199
  typedArrayTags[objectTag$4] = typedArrayTags[regexpTag$3] =
1200
- typedArrayTags[setTag$5] = typedArrayTags[stringTag$4] =
1200
+ typedArrayTags[setTag$5] = typedArrayTags[stringTag$3] =
1201
1201
  typedArrayTags[weakMapTag$2] = false;
1202
1202
 
1203
1203
  /**
@@ -2668,7 +2668,7 @@
2668
2668
  numberTag$3 = '[object Number]',
2669
2669
  regexpTag$2 = '[object RegExp]',
2670
2670
  setTag$3 = '[object Set]',
2671
- stringTag$3 = '[object String]',
2671
+ stringTag$2 = '[object String]',
2672
2672
  symbolTag$2 = '[object Symbol]';
2673
2673
 
2674
2674
  var arrayBufferTag$2 = '[object ArrayBuffer]',
@@ -2717,7 +2717,7 @@
2717
2717
  return new Ctor;
2718
2718
 
2719
2719
  case numberTag$3:
2720
- case stringTag$3:
2720
+ case stringTag$2:
2721
2721
  return new Ctor(object);
2722
2722
 
2723
2723
  case regexpTag$2:
@@ -2834,7 +2834,7 @@
2834
2834
  objectTag$1 = '[object Object]',
2835
2835
  regexpTag$1 = '[object RegExp]',
2836
2836
  setTag$1 = '[object Set]',
2837
- stringTag$2 = '[object String]',
2837
+ stringTag$1 = '[object String]',
2838
2838
  symbolTag$1 = '[object Symbol]',
2839
2839
  weakMapTag = '[object WeakMap]';
2840
2840
 
@@ -2860,7 +2860,7 @@
2860
2860
  cloneableTags[int32Tag] = cloneableTags[mapTag$1] =
2861
2861
  cloneableTags[numberTag$2] = cloneableTags[objectTag$1] =
2862
2862
  cloneableTags[regexpTag$1] = cloneableTags[setTag$1] =
2863
- cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
2863
+ cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] =
2864
2864
  cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
2865
2865
  cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
2866
2866
  cloneableTags[errorTag$1] = cloneableTags[funcTag] =
@@ -3196,7 +3196,7 @@
3196
3196
  numberTag$1 = '[object Number]',
3197
3197
  regexpTag = '[object RegExp]',
3198
3198
  setTag = '[object Set]',
3199
- stringTag$1 = '[object String]',
3199
+ stringTag = '[object String]',
3200
3200
  symbolTag = '[object Symbol]';
3201
3201
 
3202
3202
  var arrayBufferTag = '[object ArrayBuffer]',
@@ -3251,7 +3251,7 @@
3251
3251
  return object.name == other.name && object.message == other.message;
3252
3252
 
3253
3253
  case regexpTag:
3254
- case stringTag$1:
3254
+ case stringTag:
3255
3255
  // Coerce regexes to strings and treat strings, primitives and objects,
3256
3256
  // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
3257
3257
  // for more details.
@@ -4286,31 +4286,6 @@
4286
4286
  return result;
4287
4287
  }
4288
4288
 
4289
- /** `Object#toString` result references. */
4290
- var stringTag = '[object String]';
4291
-
4292
- /**
4293
- * Checks if `value` is classified as a `String` primitive or object.
4294
- *
4295
- * @static
4296
- * @since 0.1.0
4297
- * @memberOf _
4298
- * @category Lang
4299
- * @param {*} value The value to check.
4300
- * @returns {boolean} Returns `true` if `value` is a string, else `false`.
4301
- * @example
4302
- *
4303
- * _.isString('abc');
4304
- * // => true
4305
- *
4306
- * _.isString(1);
4307
- * // => false
4308
- */
4309
- function isString$1(value) {
4310
- return typeof value == 'string' ||
4311
- (!isArray$1(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
4312
- }
4313
-
4314
4289
  /**
4315
4290
  * Performs a deep comparison between two values to determine if they are
4316
4291
  * equivalent.
@@ -57972,7 +57947,7 @@
57972
57947
  }
57973
57948
  });
57974
57949
 
57975
- var YcStatusDialog = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-41a50537"], ["__file", "index.vue"]]);
57950
+ var YcStatusDialog = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-2757be57"], ["__file", "index.vue"]]);
57976
57951
 
57977
57952
  var _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
57978
57953
  ...{
@@ -59621,2013 +59596,6 @@
59621
59596
 
59622
59597
  var installer = makeInstaller([...plugins]);
59623
59598
 
59624
- const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
59625
- const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
59626
- const colonSeparated = value.split(":");
59627
- if (value.slice(0, 1) === "@") {
59628
- if (colonSeparated.length < 2 || colonSeparated.length > 3) {
59629
- return null;
59630
- }
59631
- provider = colonSeparated.shift().slice(1);
59632
- }
59633
- if (colonSeparated.length > 3 || !colonSeparated.length) {
59634
- return null;
59635
- }
59636
- if (colonSeparated.length > 1) {
59637
- const name2 = colonSeparated.pop();
59638
- const prefix = colonSeparated.pop();
59639
- const result = {
59640
- // Allow provider without '@': "provider:prefix:name"
59641
- provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
59642
- prefix,
59643
- name: name2
59644
- };
59645
- return validate && !validateIconName(result) ? null : result;
59646
- }
59647
- const name = colonSeparated[0];
59648
- const dashSeparated = name.split("-");
59649
- if (dashSeparated.length > 1) {
59650
- const result = {
59651
- provider,
59652
- prefix: dashSeparated.shift(),
59653
- name: dashSeparated.join("-")
59654
- };
59655
- return validate && !validateIconName(result) ? null : result;
59656
- }
59657
- if (allowSimpleName && provider === "") {
59658
- const result = {
59659
- provider,
59660
- prefix: "",
59661
- name
59662
- };
59663
- return validate && !validateIconName(result, allowSimpleName) ? null : result;
59664
- }
59665
- return null;
59666
- };
59667
- const validateIconName = (icon, allowSimpleName) => {
59668
- if (!icon) {
59669
- return false;
59670
- }
59671
- return !!// Check prefix: cannot be empty, unless allowSimpleName is enabled
59672
- // Check name: cannot be empty
59673
- ((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
59674
- };
59675
-
59676
- const defaultIconDimensions = Object.freeze(
59677
- {
59678
- left: 0,
59679
- top: 0,
59680
- width: 16,
59681
- height: 16
59682
- }
59683
- );
59684
- const defaultIconTransformations = Object.freeze({
59685
- rotate: 0,
59686
- vFlip: false,
59687
- hFlip: false
59688
- });
59689
- const defaultIconProps = Object.freeze({
59690
- ...defaultIconDimensions,
59691
- ...defaultIconTransformations
59692
- });
59693
- const defaultExtendedIconProps = Object.freeze({
59694
- ...defaultIconProps,
59695
- body: "",
59696
- hidden: false
59697
- });
59698
-
59699
- function mergeIconTransformations(obj1, obj2) {
59700
- const result = {};
59701
- if (!obj1.hFlip !== !obj2.hFlip) {
59702
- result.hFlip = true;
59703
- }
59704
- if (!obj1.vFlip !== !obj2.vFlip) {
59705
- result.vFlip = true;
59706
- }
59707
- const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
59708
- if (rotate) {
59709
- result.rotate = rotate;
59710
- }
59711
- return result;
59712
- }
59713
-
59714
- function mergeIconData(parent, child) {
59715
- const result = mergeIconTransformations(parent, child);
59716
- for (const key in defaultExtendedIconProps) {
59717
- if (key in defaultIconTransformations) {
59718
- if (key in parent && !(key in result)) {
59719
- result[key] = defaultIconTransformations[key];
59720
- }
59721
- } else if (key in child) {
59722
- result[key] = child[key];
59723
- } else if (key in parent) {
59724
- result[key] = parent[key];
59725
- }
59726
- }
59727
- return result;
59728
- }
59729
-
59730
- function getIconsTree(data, names) {
59731
- const icons = data.icons;
59732
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
59733
- const resolved = /* @__PURE__ */ Object.create(null);
59734
- function resolve(name) {
59735
- if (icons[name]) {
59736
- return resolved[name] = [];
59737
- }
59738
- if (!(name in resolved)) {
59739
- resolved[name] = null;
59740
- const parent = aliases[name] && aliases[name].parent;
59741
- const value = parent && resolve(parent);
59742
- if (value) {
59743
- resolved[name] = [parent].concat(value);
59744
- }
59745
- }
59746
- return resolved[name];
59747
- }
59748
- (Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
59749
- return resolved;
59750
- }
59751
-
59752
- function internalGetIconData(data, name, tree) {
59753
- const icons = data.icons;
59754
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
59755
- let currentProps = {};
59756
- function parse(name2) {
59757
- currentProps = mergeIconData(
59758
- icons[name2] || aliases[name2],
59759
- currentProps
59760
- );
59761
- }
59762
- parse(name);
59763
- tree.forEach(parse);
59764
- return mergeIconData(data, currentProps);
59765
- }
59766
-
59767
- function parseIconSet(data, callback) {
59768
- const names = [];
59769
- if (typeof data !== "object" || typeof data.icons !== "object") {
59770
- return names;
59771
- }
59772
- if (data.not_found instanceof Array) {
59773
- data.not_found.forEach((name) => {
59774
- callback(name, null);
59775
- names.push(name);
59776
- });
59777
- }
59778
- const tree = getIconsTree(data);
59779
- for (const name in tree) {
59780
- const item = tree[name];
59781
- if (item) {
59782
- callback(name, internalGetIconData(data, name, item));
59783
- names.push(name);
59784
- }
59785
- }
59786
- return names;
59787
- }
59788
-
59789
- const optionalPropertyDefaults = {
59790
- provider: "",
59791
- aliases: {},
59792
- not_found: {},
59793
- ...defaultIconDimensions
59794
- };
59795
- function checkOptionalProps(item, defaults) {
59796
- for (const prop in defaults) {
59797
- if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
59798
- return false;
59799
- }
59800
- }
59801
- return true;
59802
- }
59803
- function quicklyValidateIconSet(obj) {
59804
- if (typeof obj !== "object" || obj === null) {
59805
- return null;
59806
- }
59807
- const data = obj;
59808
- if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
59809
- return null;
59810
- }
59811
- if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
59812
- return null;
59813
- }
59814
- const icons = data.icons;
59815
- for (const name in icons) {
59816
- const icon = icons[name];
59817
- if (
59818
- // Name cannot be empty
59819
- !name || // Must have body
59820
- typeof icon.body !== "string" || // Check other props
59821
- !checkOptionalProps(
59822
- icon,
59823
- defaultExtendedIconProps
59824
- )
59825
- ) {
59826
- return null;
59827
- }
59828
- }
59829
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
59830
- for (const name in aliases) {
59831
- const icon = aliases[name];
59832
- const parent = icon.parent;
59833
- if (
59834
- // Name cannot be empty
59835
- !name || // Parent must be set and point to existing icon
59836
- typeof parent !== "string" || !icons[parent] && !aliases[parent] || // Check other props
59837
- !checkOptionalProps(
59838
- icon,
59839
- defaultExtendedIconProps
59840
- )
59841
- ) {
59842
- return null;
59843
- }
59844
- }
59845
- return data;
59846
- }
59847
-
59848
- const dataStorage = /* @__PURE__ */ Object.create(null);
59849
- function newStorage(provider, prefix) {
59850
- return {
59851
- provider,
59852
- prefix,
59853
- icons: /* @__PURE__ */ Object.create(null),
59854
- missing: /* @__PURE__ */ new Set()
59855
- };
59856
- }
59857
- function getStorage(provider, prefix) {
59858
- const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
59859
- return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
59860
- }
59861
- function addIconSet(storage, data) {
59862
- if (!quicklyValidateIconSet(data)) {
59863
- return [];
59864
- }
59865
- return parseIconSet(data, (name, icon) => {
59866
- if (icon) {
59867
- storage.icons[name] = icon;
59868
- } else {
59869
- storage.missing.add(name);
59870
- }
59871
- });
59872
- }
59873
- function addIconToStorage(storage, name, icon) {
59874
- try {
59875
- if (typeof icon.body === "string") {
59876
- storage.icons[name] = { ...icon };
59877
- return true;
59878
- }
59879
- } catch (err) {
59880
- }
59881
- return false;
59882
- }
59883
-
59884
- let simpleNames = false;
59885
- function allowSimpleNames(allow) {
59886
- if (typeof allow === "boolean") {
59887
- simpleNames = allow;
59888
- }
59889
- return simpleNames;
59890
- }
59891
- function getIconData(name) {
59892
- const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
59893
- if (icon) {
59894
- const storage = getStorage(icon.provider, icon.prefix);
59895
- const iconName = icon.name;
59896
- return storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);
59897
- }
59898
- }
59899
- function addIcon(name, data) {
59900
- const icon = stringToIcon(name, true, simpleNames);
59901
- if (!icon) {
59902
- return false;
59903
- }
59904
- const storage = getStorage(icon.provider, icon.prefix);
59905
- if (data) {
59906
- return addIconToStorage(storage, icon.name, data);
59907
- } else {
59908
- storage.missing.add(icon.name);
59909
- return true;
59910
- }
59911
- }
59912
- function addCollection(data, provider) {
59913
- if (typeof data !== "object") {
59914
- return false;
59915
- }
59916
- if (typeof provider !== "string") {
59917
- provider = data.provider || "";
59918
- }
59919
- if (simpleNames && !provider && !data.prefix) {
59920
- let added = false;
59921
- if (quicklyValidateIconSet(data)) {
59922
- data.prefix = "";
59923
- parseIconSet(data, (name, icon) => {
59924
- if (addIcon(name, icon)) {
59925
- added = true;
59926
- }
59927
- });
59928
- }
59929
- return added;
59930
- }
59931
- const prefix = data.prefix;
59932
- if (!validateIconName({
59933
- prefix,
59934
- name: "a"
59935
- })) {
59936
- return false;
59937
- }
59938
- const storage = getStorage(provider, prefix);
59939
- return !!addIconSet(storage, data);
59940
- }
59941
-
59942
- const defaultIconSizeCustomisations = Object.freeze({
59943
- width: null,
59944
- height: null
59945
- });
59946
- const defaultIconCustomisations = Object.freeze({
59947
- // Dimensions
59948
- ...defaultIconSizeCustomisations,
59949
- // Transformations
59950
- ...defaultIconTransformations
59951
- });
59952
-
59953
- const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
59954
- const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
59955
- function calculateSize(size, ratio, precision) {
59956
- if (ratio === 1) {
59957
- return size;
59958
- }
59959
- precision = precision || 100;
59960
- if (typeof size === "number") {
59961
- return Math.ceil(size * ratio * precision) / precision;
59962
- }
59963
- if (typeof size !== "string") {
59964
- return size;
59965
- }
59966
- const oldParts = size.split(unitsSplit);
59967
- if (oldParts === null || !oldParts.length) {
59968
- return size;
59969
- }
59970
- const newParts = [];
59971
- let code = oldParts.shift();
59972
- let isNumber = unitsTest.test(code);
59973
- while (true) {
59974
- if (isNumber) {
59975
- const num = parseFloat(code);
59976
- if (isNaN(num)) {
59977
- newParts.push(code);
59978
- } else {
59979
- newParts.push(Math.ceil(num * ratio * precision) / precision);
59980
- }
59981
- } else {
59982
- newParts.push(code);
59983
- }
59984
- code = oldParts.shift();
59985
- if (code === void 0) {
59986
- return newParts.join("");
59987
- }
59988
- isNumber = !isNumber;
59989
- }
59990
- }
59991
-
59992
- function splitSVGDefs(content, tag = "defs") {
59993
- let defs = "";
59994
- const index = content.indexOf("<" + tag);
59995
- while (index >= 0) {
59996
- const start = content.indexOf(">", index);
59997
- const end = content.indexOf("</" + tag);
59998
- if (start === -1 || end === -1) {
59999
- break;
60000
- }
60001
- const endEnd = content.indexOf(">", end);
60002
- if (endEnd === -1) {
60003
- break;
60004
- }
60005
- defs += content.slice(start + 1, end).trim();
60006
- content = content.slice(0, index).trim() + content.slice(endEnd + 1);
60007
- }
60008
- return {
60009
- defs,
60010
- content
60011
- };
60012
- }
60013
- function mergeDefsAndContent(defs, content) {
60014
- return defs ? "<defs>" + defs + "</defs>" + content : content;
60015
- }
60016
- function wrapSVGContent(body, start, end) {
60017
- const split = splitSVGDefs(body);
60018
- return mergeDefsAndContent(split.defs, start + split.content + end);
60019
- }
60020
-
60021
- const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
60022
- function iconToSVG(icon, customisations) {
60023
- const fullIcon = {
60024
- ...defaultIconProps,
60025
- ...icon
60026
- };
60027
- const fullCustomisations = {
60028
- ...defaultIconCustomisations,
60029
- ...customisations
60030
- };
60031
- const box = {
60032
- left: fullIcon.left,
60033
- top: fullIcon.top,
60034
- width: fullIcon.width,
60035
- height: fullIcon.height
60036
- };
60037
- let body = fullIcon.body;
60038
- [fullIcon, fullCustomisations].forEach((props) => {
60039
- const transformations = [];
60040
- const hFlip = props.hFlip;
60041
- const vFlip = props.vFlip;
60042
- let rotation = props.rotate;
60043
- if (hFlip) {
60044
- if (vFlip) {
60045
- rotation += 2;
60046
- } else {
60047
- transformations.push(
60048
- "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
60049
- );
60050
- transformations.push("scale(-1 1)");
60051
- box.top = box.left = 0;
60052
- }
60053
- } else if (vFlip) {
60054
- transformations.push(
60055
- "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
60056
- );
60057
- transformations.push("scale(1 -1)");
60058
- box.top = box.left = 0;
60059
- }
60060
- let tempValue;
60061
- if (rotation < 0) {
60062
- rotation -= Math.floor(rotation / 4) * 4;
60063
- }
60064
- rotation = rotation % 4;
60065
- switch (rotation) {
60066
- case 1:
60067
- tempValue = box.height / 2 + box.top;
60068
- transformations.unshift(
60069
- "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
60070
- );
60071
- break;
60072
- case 2:
60073
- transformations.unshift(
60074
- "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
60075
- );
60076
- break;
60077
- case 3:
60078
- tempValue = box.width / 2 + box.left;
60079
- transformations.unshift(
60080
- "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
60081
- );
60082
- break;
60083
- }
60084
- if (rotation % 2 === 1) {
60085
- if (box.left !== box.top) {
60086
- tempValue = box.left;
60087
- box.left = box.top;
60088
- box.top = tempValue;
60089
- }
60090
- if (box.width !== box.height) {
60091
- tempValue = box.width;
60092
- box.width = box.height;
60093
- box.height = tempValue;
60094
- }
60095
- }
60096
- if (transformations.length) {
60097
- body = wrapSVGContent(
60098
- body,
60099
- '<g transform="' + transformations.join(" ") + '">',
60100
- "</g>"
60101
- );
60102
- }
60103
- });
60104
- const customisationsWidth = fullCustomisations.width;
60105
- const customisationsHeight = fullCustomisations.height;
60106
- const boxWidth = box.width;
60107
- const boxHeight = box.height;
60108
- let width;
60109
- let height;
60110
- if (customisationsWidth === null) {
60111
- height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
60112
- width = calculateSize(height, boxWidth / boxHeight);
60113
- } else {
60114
- width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
60115
- height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
60116
- }
60117
- const attributes = {};
60118
- const setAttr = (prop, value) => {
60119
- if (!isUnsetKeyword(value)) {
60120
- attributes[prop] = value.toString();
60121
- }
60122
- };
60123
- setAttr("width", width);
60124
- setAttr("height", height);
60125
- const viewBox = [box.left, box.top, boxWidth, boxHeight];
60126
- attributes.viewBox = viewBox.join(" ");
60127
- return {
60128
- attributes,
60129
- viewBox,
60130
- body
60131
- };
60132
- }
60133
-
60134
- const regex = /\sid="(\S+)"/g;
60135
- const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
60136
- let counter = 0;
60137
- function replaceIDs(body, prefix = randomPrefix) {
60138
- const ids = [];
60139
- let match;
60140
- while (match = regex.exec(body)) {
60141
- ids.push(match[1]);
60142
- }
60143
- if (!ids.length) {
60144
- return body;
60145
- }
60146
- const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
60147
- ids.forEach((id) => {
60148
- const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
60149
- const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
60150
- body = body.replace(
60151
- // Allowed characters before id: [#;"]
60152
- // Allowed characters after id: [)"], .[a-z]
60153
- new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
60154
- "$1" + newID + suffix + "$3"
60155
- );
60156
- });
60157
- body = body.replace(new RegExp(suffix, "g"), "");
60158
- return body;
60159
- }
60160
-
60161
- const storage = /* @__PURE__ */ Object.create(null);
60162
- function setAPIModule(provider, item) {
60163
- storage[provider] = item;
60164
- }
60165
- function getAPIModule(provider) {
60166
- return storage[provider] || storage[""];
60167
- }
60168
-
60169
- function createAPIConfig(source) {
60170
- let resources;
60171
- if (typeof source.resources === "string") {
60172
- resources = [source.resources];
60173
- } else {
60174
- resources = source.resources;
60175
- if (!(resources instanceof Array) || !resources.length) {
60176
- return null;
60177
- }
60178
- }
60179
- const result = {
60180
- // API hosts
60181
- resources,
60182
- // Root path
60183
- path: source.path || "/",
60184
- // URL length limit
60185
- maxURL: source.maxURL || 500,
60186
- // Timeout before next host is used.
60187
- rotate: source.rotate || 750,
60188
- // Timeout before failing query.
60189
- timeout: source.timeout || 5e3,
60190
- // Randomise default API end point.
60191
- random: source.random === true,
60192
- // Start index
60193
- index: source.index || 0,
60194
- // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
60195
- dataAfterTimeout: source.dataAfterTimeout !== false
60196
- };
60197
- return result;
60198
- }
60199
- const configStorage = /* @__PURE__ */ Object.create(null);
60200
- const fallBackAPISources = [
60201
- "https://api.simplesvg.com",
60202
- "https://api.unisvg.com"
60203
- ];
60204
- const fallBackAPI = [];
60205
- while (fallBackAPISources.length > 0) {
60206
- if (fallBackAPISources.length === 1) {
60207
- fallBackAPI.push(fallBackAPISources.shift());
60208
- } else {
60209
- if (Math.random() > 0.5) {
60210
- fallBackAPI.push(fallBackAPISources.shift());
60211
- } else {
60212
- fallBackAPI.push(fallBackAPISources.pop());
60213
- }
60214
- }
60215
- }
60216
- configStorage[""] = createAPIConfig({
60217
- resources: ["https://api.iconify.design"].concat(fallBackAPI)
60218
- });
60219
- function addAPIProvider(provider, customConfig) {
60220
- const config = createAPIConfig(customConfig);
60221
- if (config === null) {
60222
- return false;
60223
- }
60224
- configStorage[provider] = config;
60225
- return true;
60226
- }
60227
- function getAPIConfig(provider) {
60228
- return configStorage[provider];
60229
- }
60230
-
60231
- const detectFetch = () => {
60232
- let callback;
60233
- try {
60234
- callback = fetch;
60235
- if (typeof callback === "function") {
60236
- return callback;
60237
- }
60238
- } catch (err) {
60239
- }
60240
- };
60241
- let fetchModule = detectFetch();
60242
- function calculateMaxLength(provider, prefix) {
60243
- const config = getAPIConfig(provider);
60244
- if (!config) {
60245
- return 0;
60246
- }
60247
- let result;
60248
- if (!config.maxURL) {
60249
- result = 0;
60250
- } else {
60251
- let maxHostLength = 0;
60252
- config.resources.forEach((item) => {
60253
- const host = item;
60254
- maxHostLength = Math.max(maxHostLength, host.length);
60255
- });
60256
- const url = prefix + ".json?icons=";
60257
- result = config.maxURL - maxHostLength - config.path.length - url.length;
60258
- }
60259
- return result;
60260
- }
60261
- function shouldAbort(status) {
60262
- return status === 404;
60263
- }
60264
- const prepare = (provider, prefix, icons) => {
60265
- const results = [];
60266
- const maxLength = calculateMaxLength(provider, prefix);
60267
- const type = "icons";
60268
- let item = {
60269
- type,
60270
- provider,
60271
- prefix,
60272
- icons: []
60273
- };
60274
- let length = 0;
60275
- icons.forEach((name, index) => {
60276
- length += name.length + 1;
60277
- if (length >= maxLength && index > 0) {
60278
- results.push(item);
60279
- item = {
60280
- type,
60281
- provider,
60282
- prefix,
60283
- icons: []
60284
- };
60285
- length = name.length;
60286
- }
60287
- item.icons.push(name);
60288
- });
60289
- results.push(item);
60290
- return results;
60291
- };
60292
- function getPath(provider) {
60293
- if (typeof provider === "string") {
60294
- const config = getAPIConfig(provider);
60295
- if (config) {
60296
- return config.path;
60297
- }
60298
- }
60299
- return "/";
60300
- }
60301
- const send = (host, params, callback) => {
60302
- if (!fetchModule) {
60303
- callback("abort", 424);
60304
- return;
60305
- }
60306
- let path = getPath(params.provider);
60307
- switch (params.type) {
60308
- case "icons": {
60309
- const prefix = params.prefix;
60310
- const icons = params.icons;
60311
- const iconsList = icons.join(",");
60312
- const urlParams = new URLSearchParams({
60313
- icons: iconsList
60314
- });
60315
- path += prefix + ".json?" + urlParams.toString();
60316
- break;
60317
- }
60318
- case "custom": {
60319
- const uri = params.uri;
60320
- path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
60321
- break;
60322
- }
60323
- default:
60324
- callback("abort", 400);
60325
- return;
60326
- }
60327
- let defaultError = 503;
60328
- fetchModule(host + path).then((response) => {
60329
- const status = response.status;
60330
- if (status !== 200) {
60331
- setTimeout(() => {
60332
- callback(shouldAbort(status) ? "abort" : "next", status);
60333
- });
60334
- return;
60335
- }
60336
- defaultError = 501;
60337
- return response.json();
60338
- }).then((data) => {
60339
- if (typeof data !== "object" || data === null) {
60340
- setTimeout(() => {
60341
- if (data === 404) {
60342
- callback("abort", data);
60343
- } else {
60344
- callback("next", defaultError);
60345
- }
60346
- });
60347
- return;
60348
- }
60349
- setTimeout(() => {
60350
- callback("success", data);
60351
- });
60352
- }).catch(() => {
60353
- callback("next", defaultError);
60354
- });
60355
- };
60356
- const fetchAPIModule = {
60357
- prepare,
60358
- send
60359
- };
60360
-
60361
- function sortIcons(icons) {
60362
- const result = {
60363
- loaded: [],
60364
- missing: [],
60365
- pending: []
60366
- };
60367
- const storage = /* @__PURE__ */ Object.create(null);
60368
- icons.sort((a, b) => {
60369
- if (a.provider !== b.provider) {
60370
- return a.provider.localeCompare(b.provider);
60371
- }
60372
- if (a.prefix !== b.prefix) {
60373
- return a.prefix.localeCompare(b.prefix);
60374
- }
60375
- return a.name.localeCompare(b.name);
60376
- });
60377
- let lastIcon = {
60378
- provider: "",
60379
- prefix: "",
60380
- name: ""
60381
- };
60382
- icons.forEach((icon) => {
60383
- if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
60384
- return;
60385
- }
60386
- lastIcon = icon;
60387
- const provider = icon.provider;
60388
- const prefix = icon.prefix;
60389
- const name = icon.name;
60390
- const providerStorage = storage[provider] || (storage[provider] = /* @__PURE__ */ Object.create(null));
60391
- const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
60392
- let list;
60393
- if (name in localStorage.icons) {
60394
- list = result.loaded;
60395
- } else if (prefix === "" || localStorage.missing.has(name)) {
60396
- list = result.missing;
60397
- } else {
60398
- list = result.pending;
60399
- }
60400
- const item = {
60401
- provider,
60402
- prefix,
60403
- name
60404
- };
60405
- list.push(item);
60406
- });
60407
- return result;
60408
- }
60409
-
60410
- function removeCallback(storages, id) {
60411
- storages.forEach((storage) => {
60412
- const items = storage.loaderCallbacks;
60413
- if (items) {
60414
- storage.loaderCallbacks = items.filter((row) => row.id !== id);
60415
- }
60416
- });
60417
- }
60418
- function updateCallbacks(storage) {
60419
- if (!storage.pendingCallbacksFlag) {
60420
- storage.pendingCallbacksFlag = true;
60421
- setTimeout(() => {
60422
- storage.pendingCallbacksFlag = false;
60423
- const items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];
60424
- if (!items.length) {
60425
- return;
60426
- }
60427
- let hasPending = false;
60428
- const provider = storage.provider;
60429
- const prefix = storage.prefix;
60430
- items.forEach((item) => {
60431
- const icons = item.icons;
60432
- const oldLength = icons.pending.length;
60433
- icons.pending = icons.pending.filter((icon) => {
60434
- if (icon.prefix !== prefix) {
60435
- return true;
60436
- }
60437
- const name = icon.name;
60438
- if (storage.icons[name]) {
60439
- icons.loaded.push({
60440
- provider,
60441
- prefix,
60442
- name
60443
- });
60444
- } else if (storage.missing.has(name)) {
60445
- icons.missing.push({
60446
- provider,
60447
- prefix,
60448
- name
60449
- });
60450
- } else {
60451
- hasPending = true;
60452
- return true;
60453
- }
60454
- return false;
60455
- });
60456
- if (icons.pending.length !== oldLength) {
60457
- if (!hasPending) {
60458
- removeCallback([storage], item.id);
60459
- }
60460
- item.callback(
60461
- icons.loaded.slice(0),
60462
- icons.missing.slice(0),
60463
- icons.pending.slice(0),
60464
- item.abort
60465
- );
60466
- }
60467
- });
60468
- });
60469
- }
60470
- }
60471
- let idCounter = 0;
60472
- function storeCallback(callback, icons, pendingSources) {
60473
- const id = idCounter++;
60474
- const abort = removeCallback.bind(null, pendingSources, id);
60475
- if (!icons.pending.length) {
60476
- return abort;
60477
- }
60478
- const item = {
60479
- id,
60480
- icons,
60481
- callback,
60482
- abort
60483
- };
60484
- pendingSources.forEach((storage) => {
60485
- (storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);
60486
- });
60487
- return abort;
60488
- }
60489
-
60490
- function listToIcons(list, validate = true, simpleNames = false) {
60491
- const result = [];
60492
- list.forEach((item) => {
60493
- const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : item;
60494
- if (icon) {
60495
- result.push(icon);
60496
- }
60497
- });
60498
- return result;
60499
- }
60500
-
60501
- // src/config.ts
60502
- var defaultConfig = {
60503
- resources: [],
60504
- index: 0,
60505
- timeout: 2e3,
60506
- rotate: 750,
60507
- random: false,
60508
- dataAfterTimeout: false
60509
- };
60510
-
60511
- // src/query.ts
60512
- function sendQuery(config, payload, query, done) {
60513
- const resourcesCount = config.resources.length;
60514
- const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
60515
- let resources;
60516
- if (config.random) {
60517
- let list = config.resources.slice(0);
60518
- resources = [];
60519
- while (list.length > 1) {
60520
- const nextIndex = Math.floor(Math.random() * list.length);
60521
- resources.push(list[nextIndex]);
60522
- list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
60523
- }
60524
- resources = resources.concat(list);
60525
- } else {
60526
- resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
60527
- }
60528
- const startTime = Date.now();
60529
- let status = "pending";
60530
- let queriesSent = 0;
60531
- let lastError;
60532
- let timer = null;
60533
- let queue = [];
60534
- let doneCallbacks = [];
60535
- if (typeof done === "function") {
60536
- doneCallbacks.push(done);
60537
- }
60538
- function resetTimer() {
60539
- if (timer) {
60540
- clearTimeout(timer);
60541
- timer = null;
60542
- }
60543
- }
60544
- function abort() {
60545
- if (status === "pending") {
60546
- status = "aborted";
60547
- }
60548
- resetTimer();
60549
- queue.forEach((item) => {
60550
- if (item.status === "pending") {
60551
- item.status = "aborted";
60552
- }
60553
- });
60554
- queue = [];
60555
- }
60556
- function subscribe(callback, overwrite) {
60557
- if (overwrite) {
60558
- doneCallbacks = [];
60559
- }
60560
- if (typeof callback === "function") {
60561
- doneCallbacks.push(callback);
60562
- }
60563
- }
60564
- function getQueryStatus() {
60565
- return {
60566
- startTime,
60567
- payload,
60568
- status,
60569
- queriesSent,
60570
- queriesPending: queue.length,
60571
- subscribe,
60572
- abort
60573
- };
60574
- }
60575
- function failQuery() {
60576
- status = "failed";
60577
- doneCallbacks.forEach((callback) => {
60578
- callback(void 0, lastError);
60579
- });
60580
- }
60581
- function clearQueue() {
60582
- queue.forEach((item) => {
60583
- if (item.status === "pending") {
60584
- item.status = "aborted";
60585
- }
60586
- });
60587
- queue = [];
60588
- }
60589
- function moduleResponse(item, response, data) {
60590
- const isError = response !== "success";
60591
- queue = queue.filter((queued) => queued !== item);
60592
- switch (status) {
60593
- case "pending":
60594
- break;
60595
- case "failed":
60596
- if (isError || !config.dataAfterTimeout) {
60597
- return;
60598
- }
60599
- break;
60600
- default:
60601
- return;
60602
- }
60603
- if (response === "abort") {
60604
- lastError = data;
60605
- failQuery();
60606
- return;
60607
- }
60608
- if (isError) {
60609
- lastError = data;
60610
- if (!queue.length) {
60611
- if (!resources.length) {
60612
- failQuery();
60613
- } else {
60614
- execNext();
60615
- }
60616
- }
60617
- return;
60618
- }
60619
- resetTimer();
60620
- clearQueue();
60621
- if (!config.random) {
60622
- const index = config.resources.indexOf(item.resource);
60623
- if (index !== -1 && index !== config.index) {
60624
- config.index = index;
60625
- }
60626
- }
60627
- status = "completed";
60628
- doneCallbacks.forEach((callback) => {
60629
- callback(data);
60630
- });
60631
- }
60632
- function execNext() {
60633
- if (status !== "pending") {
60634
- return;
60635
- }
60636
- resetTimer();
60637
- const resource = resources.shift();
60638
- if (resource === void 0) {
60639
- if (queue.length) {
60640
- timer = setTimeout(() => {
60641
- resetTimer();
60642
- if (status === "pending") {
60643
- clearQueue();
60644
- failQuery();
60645
- }
60646
- }, config.timeout);
60647
- return;
60648
- }
60649
- failQuery();
60650
- return;
60651
- }
60652
- const item = {
60653
- status: "pending",
60654
- resource,
60655
- callback: (status2, data) => {
60656
- moduleResponse(item, status2, data);
60657
- }
60658
- };
60659
- queue.push(item);
60660
- queriesSent++;
60661
- timer = setTimeout(execNext, config.rotate);
60662
- query(resource, payload, item.callback);
60663
- }
60664
- setTimeout(execNext);
60665
- return getQueryStatus;
60666
- }
60667
-
60668
- // src/index.ts
60669
- function initRedundancy(cfg) {
60670
- const config = {
60671
- ...defaultConfig,
60672
- ...cfg
60673
- };
60674
- let queries = [];
60675
- function cleanup() {
60676
- queries = queries.filter((item) => item().status === "pending");
60677
- }
60678
- function query(payload, queryCallback, doneCallback) {
60679
- const query2 = sendQuery(
60680
- config,
60681
- payload,
60682
- queryCallback,
60683
- (data, error) => {
60684
- cleanup();
60685
- if (doneCallback) {
60686
- doneCallback(data, error);
60687
- }
60688
- }
60689
- );
60690
- queries.push(query2);
60691
- return query2;
60692
- }
60693
- function find(callback) {
60694
- return queries.find((value) => {
60695
- return callback(value);
60696
- }) || null;
60697
- }
60698
- const instance = {
60699
- query,
60700
- find,
60701
- setIndex: (index) => {
60702
- config.index = index;
60703
- },
60704
- getIndex: () => config.index,
60705
- cleanup
60706
- };
60707
- return instance;
60708
- }
60709
-
60710
- function emptyCallback$1() {
60711
- }
60712
- const redundancyCache = /* @__PURE__ */ Object.create(null);
60713
- function getRedundancyCache(provider) {
60714
- if (!redundancyCache[provider]) {
60715
- const config = getAPIConfig(provider);
60716
- if (!config) {
60717
- return;
60718
- }
60719
- const redundancy = initRedundancy(config);
60720
- const cachedReundancy = {
60721
- config,
60722
- redundancy
60723
- };
60724
- redundancyCache[provider] = cachedReundancy;
60725
- }
60726
- return redundancyCache[provider];
60727
- }
60728
- function sendAPIQuery(target, query, callback) {
60729
- let redundancy;
60730
- let send;
60731
- if (typeof target === "string") {
60732
- const api = getAPIModule(target);
60733
- if (!api) {
60734
- callback(void 0, 424);
60735
- return emptyCallback$1;
60736
- }
60737
- send = api.send;
60738
- const cached = getRedundancyCache(target);
60739
- if (cached) {
60740
- redundancy = cached.redundancy;
60741
- }
60742
- } else {
60743
- const config = createAPIConfig(target);
60744
- if (config) {
60745
- redundancy = initRedundancy(config);
60746
- const moduleKey = target.resources ? target.resources[0] : "";
60747
- const api = getAPIModule(moduleKey);
60748
- if (api) {
60749
- send = api.send;
60750
- }
60751
- }
60752
- }
60753
- if (!redundancy || !send) {
60754
- callback(void 0, 424);
60755
- return emptyCallback$1;
60756
- }
60757
- return redundancy.query(query, send, callback)().abort;
60758
- }
60759
-
60760
- function emptyCallback() {
60761
- }
60762
- function loadedNewIcons(storage) {
60763
- if (!storage.iconsLoaderFlag) {
60764
- storage.iconsLoaderFlag = true;
60765
- setTimeout(() => {
60766
- storage.iconsLoaderFlag = false;
60767
- updateCallbacks(storage);
60768
- });
60769
- }
60770
- }
60771
- function checkIconNamesForAPI(icons) {
60772
- const valid = [];
60773
- const invalid = [];
60774
- icons.forEach((name) => {
60775
- (name.match(matchIconName) ? valid : invalid).push(name);
60776
- });
60777
- return {
60778
- valid,
60779
- invalid
60780
- };
60781
- }
60782
- function parseLoaderResponse(storage, icons, data) {
60783
- function checkMissing() {
60784
- const pending = storage.pendingIcons;
60785
- icons.forEach((name) => {
60786
- if (pending) {
60787
- pending.delete(name);
60788
- }
60789
- if (!storage.icons[name]) {
60790
- storage.missing.add(name);
60791
- }
60792
- });
60793
- }
60794
- if (data && typeof data === "object") {
60795
- try {
60796
- const parsed = addIconSet(storage, data);
60797
- if (!parsed.length) {
60798
- checkMissing();
60799
- return;
60800
- }
60801
- } catch (err) {
60802
- console.error(err);
60803
- }
60804
- }
60805
- checkMissing();
60806
- loadedNewIcons(storage);
60807
- }
60808
- function parsePossiblyAsyncResponse(response, callback) {
60809
- if (response instanceof Promise) {
60810
- response.then((data) => {
60811
- callback(data);
60812
- }).catch(() => {
60813
- callback(null);
60814
- });
60815
- } else {
60816
- callback(response);
60817
- }
60818
- }
60819
- function loadNewIcons(storage, icons) {
60820
- if (!storage.iconsToLoad) {
60821
- storage.iconsToLoad = icons;
60822
- } else {
60823
- storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();
60824
- }
60825
- if (!storage.iconsQueueFlag) {
60826
- storage.iconsQueueFlag = true;
60827
- setTimeout(() => {
60828
- storage.iconsQueueFlag = false;
60829
- const { provider, prefix } = storage;
60830
- const icons2 = storage.iconsToLoad;
60831
- delete storage.iconsToLoad;
60832
- if (!icons2 || !icons2.length) {
60833
- return;
60834
- }
60835
- const customIconLoader = storage.loadIcon;
60836
- if (storage.loadIcons && (icons2.length > 1 || !customIconLoader)) {
60837
- parsePossiblyAsyncResponse(
60838
- storage.loadIcons(icons2, prefix, provider),
60839
- (data) => {
60840
- parseLoaderResponse(storage, icons2, data);
60841
- }
60842
- );
60843
- return;
60844
- }
60845
- if (customIconLoader) {
60846
- icons2.forEach((name) => {
60847
- const response = customIconLoader(name, prefix, provider);
60848
- parsePossiblyAsyncResponse(response, (data) => {
60849
- const iconSet = data ? {
60850
- prefix,
60851
- icons: {
60852
- [name]: data
60853
- }
60854
- } : null;
60855
- parseLoaderResponse(storage, [name], iconSet);
60856
- });
60857
- });
60858
- return;
60859
- }
60860
- const { valid, invalid } = checkIconNamesForAPI(icons2);
60861
- if (invalid.length) {
60862
- parseLoaderResponse(storage, invalid, null);
60863
- }
60864
- if (!valid.length) {
60865
- return;
60866
- }
60867
- const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
60868
- if (!api) {
60869
- parseLoaderResponse(storage, valid, null);
60870
- return;
60871
- }
60872
- const params = api.prepare(provider, prefix, valid);
60873
- params.forEach((item) => {
60874
- sendAPIQuery(provider, item, (data) => {
60875
- parseLoaderResponse(storage, item.icons, data);
60876
- });
60877
- });
60878
- });
60879
- }
60880
- }
60881
- const loadIcons = (icons, callback) => {
60882
- const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
60883
- const sortedIcons = sortIcons(cleanedIcons);
60884
- if (!sortedIcons.pending.length) {
60885
- let callCallback = true;
60886
- if (callback) {
60887
- setTimeout(() => {
60888
- if (callCallback) {
60889
- callback(
60890
- sortedIcons.loaded,
60891
- sortedIcons.missing,
60892
- sortedIcons.pending,
60893
- emptyCallback
60894
- );
60895
- }
60896
- });
60897
- }
60898
- return () => {
60899
- callCallback = false;
60900
- };
60901
- }
60902
- const newIcons = /* @__PURE__ */ Object.create(null);
60903
- const sources = [];
60904
- let lastProvider, lastPrefix;
60905
- sortedIcons.pending.forEach((icon) => {
60906
- const { provider, prefix } = icon;
60907
- if (prefix === lastPrefix && provider === lastProvider) {
60908
- return;
60909
- }
60910
- lastProvider = provider;
60911
- lastPrefix = prefix;
60912
- sources.push(getStorage(provider, prefix));
60913
- const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
60914
- if (!providerNewIcons[prefix]) {
60915
- providerNewIcons[prefix] = [];
60916
- }
60917
- });
60918
- sortedIcons.pending.forEach((icon) => {
60919
- const { provider, prefix, name } = icon;
60920
- const storage = getStorage(provider, prefix);
60921
- const pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());
60922
- if (!pendingQueue.has(name)) {
60923
- pendingQueue.add(name);
60924
- newIcons[provider][prefix].push(name);
60925
- }
60926
- });
60927
- sources.forEach((storage) => {
60928
- const list = newIcons[storage.provider][storage.prefix];
60929
- if (list.length) {
60930
- loadNewIcons(storage, list);
60931
- }
60932
- });
60933
- return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
60934
- };
60935
-
60936
- function mergeCustomisations(defaults, item) {
60937
- const result = {
60938
- ...defaults
60939
- };
60940
- for (const key in item) {
60941
- const value = item[key];
60942
- const valueType = typeof value;
60943
- if (key in defaultIconSizeCustomisations) {
60944
- if (value === null || value && (valueType === "string" || valueType === "number")) {
60945
- result[key] = value;
60946
- }
60947
- } else if (valueType === typeof result[key]) {
60948
- result[key] = key === "rotate" ? value % 4 : value;
60949
- }
60950
- }
60951
- return result;
60952
- }
60953
-
60954
- const separator = /[\s,]+/;
60955
- function flipFromString(custom, flip) {
60956
- flip.split(separator).forEach((str) => {
60957
- const value = str.trim();
60958
- switch (value) {
60959
- case "horizontal":
60960
- custom.hFlip = true;
60961
- break;
60962
- case "vertical":
60963
- custom.vFlip = true;
60964
- break;
60965
- }
60966
- });
60967
- }
60968
-
60969
- function rotateFromString(value, defaultValue = 0) {
60970
- const units = value.replace(/^-?[0-9.]*/, "");
60971
- function cleanup(value2) {
60972
- while (value2 < 0) {
60973
- value2 += 4;
60974
- }
60975
- return value2 % 4;
60976
- }
60977
- if (units === "") {
60978
- const num = parseInt(value);
60979
- return isNaN(num) ? 0 : cleanup(num);
60980
- } else if (units !== value) {
60981
- let split = 0;
60982
- switch (units) {
60983
- case "%":
60984
- split = 25;
60985
- break;
60986
- case "deg":
60987
- split = 90;
60988
- }
60989
- if (split) {
60990
- let num = parseFloat(value.slice(0, value.length - units.length));
60991
- if (isNaN(num)) {
60992
- return 0;
60993
- }
60994
- num = num / split;
60995
- return num % 1 === 0 ? cleanup(num) : 0;
60996
- }
60997
- }
60998
- return defaultValue;
60999
- }
61000
-
61001
- function iconToHTML(body, attributes) {
61002
- let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
61003
- for (const attr in attributes) {
61004
- renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
61005
- }
61006
- return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
61007
- }
61008
-
61009
- function encodeSVGforURL(svg) {
61010
- return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
61011
- }
61012
- function svgToData(svg) {
61013
- return "data:image/svg+xml," + encodeSVGforURL(svg);
61014
- }
61015
- function svgToURL(svg) {
61016
- return 'url("' + svgToData(svg) + '")';
61017
- }
61018
-
61019
- const defaultExtendedIconCustomisations = {
61020
- ...defaultIconCustomisations,
61021
- inline: false,
61022
- };
61023
-
61024
- /**
61025
- * Default SVG attributes
61026
- */
61027
- const svgDefaults = {
61028
- 'xmlns': 'http://www.w3.org/2000/svg',
61029
- 'xmlns:xlink': 'http://www.w3.org/1999/xlink',
61030
- 'aria-hidden': true,
61031
- 'role': 'img',
61032
- };
61033
- /**
61034
- * Style modes
61035
- */
61036
- const commonProps = {
61037
- display: 'inline-block',
61038
- };
61039
- const monotoneProps = {
61040
- backgroundColor: 'currentColor',
61041
- };
61042
- const coloredProps = {
61043
- backgroundColor: 'transparent',
61044
- };
61045
- // Dynamically add common props to variables above
61046
- const propsToAdd = {
61047
- Image: 'var(--svg)',
61048
- Repeat: 'no-repeat',
61049
- Size: '100% 100%',
61050
- };
61051
- const propsToAddTo = {
61052
- webkitMask: monotoneProps,
61053
- mask: monotoneProps,
61054
- background: coloredProps,
61055
- };
61056
- for (const prefix in propsToAddTo) {
61057
- const list = propsToAddTo[prefix];
61058
- for (const prop in propsToAdd) {
61059
- list[prefix + prop] = propsToAdd[prop];
61060
- }
61061
- }
61062
- /**
61063
- * Aliases for customisations.
61064
- * In Vue 'v-' properties are reserved, so v-flip must be renamed
61065
- */
61066
- const customisationAliases = {};
61067
- ['horizontal', 'vertical'].forEach((prefix) => {
61068
- const attr = prefix.slice(0, 1) + 'Flip';
61069
- // vertical-flip
61070
- customisationAliases[prefix + '-flip'] = attr;
61071
- // v-flip
61072
- customisationAliases[prefix.slice(0, 1) + '-flip'] = attr;
61073
- // verticalFlip
61074
- customisationAliases[prefix + 'Flip'] = attr;
61075
- });
61076
- /**
61077
- * Fix size: add 'px' to numbers
61078
- */
61079
- function fixSize(value) {
61080
- return value + (value.match(/^[-0-9.]+$/) ? 'px' : '');
61081
- }
61082
- /**
61083
- * Render icon
61084
- */
61085
- const render = (
61086
- // Icon must be validated before calling this function
61087
- icon,
61088
- // Partial properties
61089
- props) => {
61090
- // Split properties
61091
- const customisations = mergeCustomisations(defaultExtendedIconCustomisations, props);
61092
- const componentProps = { ...svgDefaults };
61093
- // Check mode
61094
- const mode = props.mode || 'svg';
61095
- // Copy style
61096
- const style = {};
61097
- const propsStyle = props.style;
61098
- const customStyle = typeof propsStyle === 'object' && !(propsStyle instanceof Array)
61099
- ? propsStyle
61100
- : {};
61101
- // Get element properties
61102
- for (let key in props) {
61103
- const value = props[key];
61104
- if (value === void 0) {
61105
- continue;
61106
- }
61107
- switch (key) {
61108
- // Properties to ignore
61109
- case 'icon':
61110
- case 'style':
61111
- case 'onLoad':
61112
- case 'mode':
61113
- case 'ssr':
61114
- break;
61115
- // Boolean attributes
61116
- case 'inline':
61117
- case 'hFlip':
61118
- case 'vFlip':
61119
- customisations[key] =
61120
- value === true || value === 'true' || value === 1;
61121
- break;
61122
- // Flip as string: 'horizontal,vertical'
61123
- case 'flip':
61124
- if (typeof value === 'string') {
61125
- flipFromString(customisations, value);
61126
- }
61127
- break;
61128
- // Color: override style
61129
- case 'color':
61130
- style.color = value;
61131
- break;
61132
- // Rotation as string
61133
- case 'rotate':
61134
- if (typeof value === 'string') {
61135
- customisations[key] = rotateFromString(value);
61136
- }
61137
- else if (typeof value === 'number') {
61138
- customisations[key] = value;
61139
- }
61140
- break;
61141
- // Remove aria-hidden
61142
- case 'ariaHidden':
61143
- case 'aria-hidden':
61144
- // Vue transforms 'aria-hidden' property to 'ariaHidden'
61145
- if (value !== true && value !== 'true') {
61146
- delete componentProps['aria-hidden'];
61147
- }
61148
- break;
61149
- default: {
61150
- const alias = customisationAliases[key];
61151
- if (alias) {
61152
- // Aliases for boolean customisations
61153
- if (value === true || value === 'true' || value === 1) {
61154
- customisations[alias] = true;
61155
- }
61156
- }
61157
- else if (defaultExtendedIconCustomisations[key] === void 0) {
61158
- // Copy missing property if it does not exist in customisations
61159
- componentProps[key] = value;
61160
- }
61161
- }
61162
- }
61163
- }
61164
- // Generate icon
61165
- const item = iconToSVG(icon, customisations);
61166
- const renderAttribs = item.attributes;
61167
- // Inline display
61168
- if (customisations.inline) {
61169
- style.verticalAlign = '-0.125em';
61170
- }
61171
- if (mode === 'svg') {
61172
- // Add style
61173
- componentProps.style = {
61174
- ...style,
61175
- ...customStyle,
61176
- };
61177
- // Add icon stuff
61178
- Object.assign(componentProps, renderAttribs);
61179
- // Counter for ids based on "id" property to render icons consistently on server and client
61180
- let localCounter = 0;
61181
- let id = props.id;
61182
- if (typeof id === 'string') {
61183
- // Convert '-' to '_' to avoid errors in animations
61184
- id = id.replace(/-/g, '_');
61185
- }
61186
- // Add innerHTML and style to props
61187
- componentProps['innerHTML'] = replaceIDs(item.body, id ? () => id + 'ID' + localCounter++ : 'iconifyVue');
61188
- // Render icon
61189
- return vue.h('svg', componentProps);
61190
- }
61191
- // Render <span> with style
61192
- const { body, width, height } = icon;
61193
- const useMask = mode === 'mask' ||
61194
- (mode === 'bg' ? false : body.indexOf('currentColor') !== -1);
61195
- // Generate SVG
61196
- const html = iconToHTML(body, {
61197
- ...renderAttribs,
61198
- width: width + '',
61199
- height: height + '',
61200
- });
61201
- // Generate style
61202
- componentProps.style = {
61203
- ...style,
61204
- '--svg': svgToURL(html),
61205
- 'width': fixSize(renderAttribs.width),
61206
- 'height': fixSize(renderAttribs.height),
61207
- ...commonProps,
61208
- ...(useMask ? monotoneProps : coloredProps),
61209
- ...customStyle,
61210
- };
61211
- return vue.h('span', componentProps);
61212
- };
61213
-
61214
- /**
61215
- * Initialise stuff
61216
- */
61217
- // Enable short names
61218
- allowSimpleNames(true);
61219
- // Set API module
61220
- setAPIModule('', fetchAPIModule);
61221
- /**
61222
- * Browser stuff
61223
- */
61224
- if (typeof document !== 'undefined' && typeof window !== 'undefined') {
61225
- const _window = window;
61226
- // Load icons from global "IconifyPreload"
61227
- if (_window.IconifyPreload !== void 0) {
61228
- const preload = _window.IconifyPreload;
61229
- const err = 'Invalid IconifyPreload syntax.';
61230
- if (typeof preload === 'object' && preload !== null) {
61231
- (preload instanceof Array ? preload : [preload]).forEach((item) => {
61232
- try {
61233
- if (
61234
- // Check if item is an object and not null/array
61235
- typeof item !== 'object' ||
61236
- item === null ||
61237
- item instanceof Array ||
61238
- // Check for 'icons' and 'prefix'
61239
- typeof item.icons !== 'object' ||
61240
- typeof item.prefix !== 'string' ||
61241
- // Add icon set
61242
- !addCollection(item)) {
61243
- console.error(err);
61244
- }
61245
- }
61246
- catch (e) {
61247
- console.error(err);
61248
- }
61249
- });
61250
- }
61251
- }
61252
- // Set API from global "IconifyProviders"
61253
- if (_window.IconifyProviders !== void 0) {
61254
- const providers = _window.IconifyProviders;
61255
- if (typeof providers === 'object' && providers !== null) {
61256
- for (let key in providers) {
61257
- const err = 'IconifyProviders[' + key + '] is invalid.';
61258
- try {
61259
- const value = providers[key];
61260
- if (typeof value !== 'object' ||
61261
- !value ||
61262
- value.resources === void 0) {
61263
- continue;
61264
- }
61265
- if (!addAPIProvider(key, value)) {
61266
- console.error(err);
61267
- }
61268
- }
61269
- catch (e) {
61270
- console.error(err);
61271
- }
61272
- }
61273
- }
61274
- }
61275
- }
61276
- /**
61277
- * Empty icon data, rendered when icon is not available
61278
- */
61279
- const emptyIcon = {
61280
- ...defaultIconProps,
61281
- body: '',
61282
- };
61283
- /**
61284
- * Component
61285
- */
61286
- const Icon = vue.defineComponent((props, { emit }) => {
61287
- const loader = vue.ref(null);
61288
- function abortLoading() {
61289
- if (loader.value) {
61290
- loader.value.abort?.();
61291
- loader.value = null;
61292
- }
61293
- }
61294
- // Render state
61295
- const rendering = vue.ref(!!props.ssr);
61296
- const lastRenderedIconName = vue.ref('');
61297
- const iconData = vue.shallowRef(null);
61298
- // Update icon data
61299
- function getIcon() {
61300
- const icon = props.icon;
61301
- // Icon is an object
61302
- if (typeof icon === 'object' &&
61303
- icon !== null &&
61304
- typeof icon.body === 'string') {
61305
- lastRenderedIconName.value = '';
61306
- return {
61307
- data: icon,
61308
- };
61309
- }
61310
- // Check for valid icon name
61311
- let iconName;
61312
- if (typeof icon !== 'string' ||
61313
- (iconName = stringToIcon(icon, false, true)) === null) {
61314
- return null;
61315
- }
61316
- // Load icon
61317
- let data = getIconData(iconName);
61318
- if (!data) {
61319
- // Icon data is not available
61320
- const oldState = loader.value;
61321
- if (!oldState || oldState.name !== icon) {
61322
- // Icon name does not match old loader state
61323
- if (data === null) {
61324
- // Failed to load
61325
- loader.value = {
61326
- name: icon,
61327
- };
61328
- }
61329
- else {
61330
- loader.value = {
61331
- name: icon,
61332
- abort: loadIcons([iconName], updateIconData),
61333
- };
61334
- }
61335
- }
61336
- return null;
61337
- }
61338
- // Icon data is available
61339
- abortLoading();
61340
- if (lastRenderedIconName.value !== icon) {
61341
- lastRenderedIconName.value = icon;
61342
- // Emit on next tick because render will be called on next tick
61343
- vue.nextTick(() => {
61344
- emit('load', icon);
61345
- });
61346
- }
61347
- // Customise icon
61348
- const customise = props.customise;
61349
- if (customise) {
61350
- // Clone data and customise it
61351
- data = Object.assign({}, data);
61352
- const customised = customise(data.body, iconName.name, iconName.prefix, iconName.provider);
61353
- if (typeof customised === 'string') {
61354
- data.body = customised;
61355
- }
61356
- }
61357
- // Add classes
61358
- const classes = ['iconify'];
61359
- if (iconName.prefix !== '') {
61360
- classes.push('iconify--' + iconName.prefix);
61361
- }
61362
- if (iconName.provider !== '') {
61363
- classes.push('iconify--' + iconName.provider);
61364
- }
61365
- return { data, classes };
61366
- }
61367
- function updateIconData() {
61368
- const icon = getIcon();
61369
- if (!icon) {
61370
- iconData.value = null;
61371
- }
61372
- else if (icon.data !== iconData.value?.data) {
61373
- iconData.value = icon;
61374
- }
61375
- }
61376
- // Set icon data
61377
- if (rendering.value) {
61378
- updateIconData();
61379
- }
61380
- else {
61381
- vue.onMounted(() => {
61382
- rendering.value = true;
61383
- updateIconData();
61384
- });
61385
- }
61386
- vue.watch(() => props.icon, updateIconData);
61387
- // Abort loading on unmount
61388
- vue.onUnmounted(abortLoading);
61389
- // Render function
61390
- return () => {
61391
- // Get icon data
61392
- const icon = iconData.value;
61393
- if (!icon) {
61394
- // Icon is not available
61395
- return render(emptyIcon, props);
61396
- }
61397
- // Add classes
61398
- let newProps = props;
61399
- if (icon.classes) {
61400
- newProps = {
61401
- ...props,
61402
- class: icon.classes.join(' '),
61403
- };
61404
- }
61405
- // Render icon
61406
- return render({
61407
- ...defaultIconProps,
61408
- ...icon.data,
61409
- }, newProps);
61410
- };
61411
- }, {
61412
- props: [
61413
- // Icon and render mode
61414
- 'icon',
61415
- 'mode',
61416
- 'ssr',
61417
- // Layout and style
61418
- 'width',
61419
- 'height',
61420
- 'style',
61421
- 'color',
61422
- 'inline',
61423
- // Transformations
61424
- 'rotate',
61425
- 'hFlip',
61426
- 'horizontalFlip',
61427
- 'vFlip',
61428
- 'verticalFlip',
61429
- 'flip',
61430
- // Misc
61431
- 'id',
61432
- 'ariaHidden',
61433
- 'customise',
61434
- 'title',
61435
- ],
61436
- emits: ['load'],
61437
- });
61438
-
61439
- function isIconifyIconData(icon) {
61440
- return typeof icon === "object" && icon !== null && "body" in icon && typeof icon.body === "string";
61441
- }
61442
- var IconifyIconOffline = vue.defineComponent({
61443
- name: "YcIconifyIconOffline",
61444
- components: { IconifyIcon: Icon },
61445
- props: {
61446
- icon: {
61447
- type: [String, Object, Function],
61448
- default: null
61449
- }
61450
- },
61451
- render() {
61452
- if (isIconifyIconData(this.icon)) {
61453
- const iconName = this.icon.name || "custom-icon";
61454
- addIcon(iconName, this.icon);
61455
- }
61456
- const attrs = this.$attrs;
61457
- if (typeof this.icon === "string") {
61458
- return vue.h(
61459
- Icon,
61460
- {
61461
- icon: this.icon,
61462
- "aria-hidden": false,
61463
- style: (attrs == null ? void 0 : attrs.style) ? Object.assign(attrs.style, { outline: "none" }) : { outline: "none" },
61464
- ...attrs
61465
- },
61466
- {
61467
- default: () => []
61468
- }
61469
- );
61470
- } else {
61471
- return vue.h(
61472
- this.icon,
61473
- {
61474
- "aria-hidden": false,
61475
- style: (attrs == null ? void 0 : attrs.style) ? Object.assign(attrs.style, { outline: "none" }) : { outline: "none" },
61476
- ...attrs
61477
- },
61478
- {
61479
- default: () => []
61480
- }
61481
- );
61482
- }
61483
- }
61484
- });
61485
-
61486
- var IconifyIconOnline = vue.defineComponent({
61487
- name: "YcIconifyIconOnline",
61488
- components: { IconifyIcon: Icon },
61489
- props: {
61490
- icon: {
61491
- type: String,
61492
- default: ""
61493
- }
61494
- },
61495
- render() {
61496
- const attrs = this.$attrs;
61497
- return vue.h(
61498
- Icon,
61499
- {
61500
- icon: `${this.icon}`,
61501
- "aria-hidden": false,
61502
- style: (attrs == null ? void 0 : attrs.style) ? Object.assign(attrs.style, { outline: "none" }) : { outline: "none" },
61503
- ...attrs
61504
- },
61505
- {
61506
- default: () => []
61507
- }
61508
- );
61509
- }
61510
- });
61511
-
61512
- var FontIcon = vue.defineComponent({
61513
- name: "YcFontIcon",
61514
- props: {
61515
- icon: {
61516
- type: String,
61517
- default: ""
61518
- }
61519
- },
61520
- render() {
61521
- const attrs = this.$attrs;
61522
- if (Object.keys(attrs).includes("uni") || (attrs == null ? void 0 : attrs.iconType) === "uni") {
61523
- return vue.h(
61524
- "i",
61525
- {
61526
- class: "iconfont",
61527
- ...attrs
61528
- },
61529
- this.icon
61530
- );
61531
- } else if (Object.keys(attrs).includes("svg") || (attrs == null ? void 0 : attrs.iconType) === "svg") {
61532
- return vue.h(
61533
- "svg",
61534
- {
61535
- class: "icon-svg"
61536
- },
61537
- {
61538
- default: () => [
61539
- vue.h("use", {
61540
- "xlink:href": `#${this.icon}`
61541
- })
61542
- ]
61543
- }
61544
- );
61545
- } else {
61546
- return vue.h("i", {
61547
- class: `iconfont ${this.icon}`,
61548
- ...attrs
61549
- });
61550
- }
61551
- }
61552
- });
61553
-
61554
- function isUrlIcon(icon) {
61555
- return /^https?:\/\//i.test(icon);
61556
- }
61557
- const UrlIconComponent = vue.defineComponent({
61558
- name: "YcUrlIcon",
61559
- props: {
61560
- src: { type: String, required: true },
61561
- size: { type: Number, default: 20 }
61562
- },
61563
- render() {
61564
- return vue.h("img", {
61565
- src: this.src,
61566
- class: "yc-url-icon",
61567
- style: {
61568
- width: `${this.size}px`,
61569
- height: `${this.size}px`,
61570
- objectFit: "contain"
61571
- },
61572
- alt: "icon"
61573
- });
61574
- }
61575
- });
61576
- function useRenderIcon(icon, attrs) {
61577
- const ifReg = /^IF-/;
61578
- if (isString$1(icon) && isUrlIcon(icon)) {
61579
- const attrSize = (attrs == null ? void 0 : attrs.width) || (attrs == null ? void 0 : attrs.height);
61580
- const size = typeof attrSize === "number" ? attrSize : 20;
61581
- return vue.h(UrlIconComponent, { src: icon, size });
61582
- }
61583
- if (isString$1(icon) && ifReg.test(icon)) {
61584
- const name = icon.split(ifReg)[1];
61585
- const iconName = name.slice(
61586
- 0,
61587
- name.indexOf(" ") == -1 ? name.length : name.indexOf(" ")
61588
- );
61589
- const iconType = name.slice(name.indexOf(" ") + 1, name.length);
61590
- return vue.defineComponent({
61591
- name: "YcFontIconWrapper",
61592
- render() {
61593
- return vue.h(FontIcon, {
61594
- icon: iconName,
61595
- iconType,
61596
- ...attrs
61597
- });
61598
- }
61599
- });
61600
- } else if (typeof icon === "function" || typeof (icon == null ? void 0 : icon.render) === "function") {
61601
- return attrs ? vue.h(icon, { ...attrs }) : icon;
61602
- } else if (typeof icon === "object") {
61603
- return vue.defineComponent({
61604
- name: "YcOfflineIconWrapper",
61605
- render() {
61606
- return vue.h(IconifyIconOffline, {
61607
- icon,
61608
- ...attrs
61609
- });
61610
- }
61611
- });
61612
- } else {
61613
- return vue.defineComponent({
61614
- name: "YcIconWrapper",
61615
- render() {
61616
- if (!icon) return;
61617
- const IconComponent = icon.includes(":") ? IconifyIconOnline : IconifyIconOffline;
61618
- return vue.h(IconComponent, {
61619
- icon,
61620
- ...attrs
61621
- });
61622
- }
61623
- });
61624
- }
61625
- }
61626
-
61627
- const YcIconifyIconOffline = IconifyIconOffline;
61628
- const YcIconifyIconOnline = IconifyIconOnline;
61629
- const YcFontIcon = FontIcon;
61630
-
61631
59599
  const version = "0.1.30";
61632
59600
 
61633
59601
  const install = installer.install;
@@ -61637,9 +59605,6 @@
61637
59605
  exports.DatePickerValueIsArrayList = DatePickerValueIsArrayList;
61638
59606
  exports.DefaultPageInfo = DefaultPageInfo;
61639
59607
  exports.DefaultPageSizeList = DefaultPageSizeList;
61640
- exports.FontIcon = YcFontIcon;
61641
- exports.IconifyIconOffline = YcIconifyIconOffline;
61642
- exports.IconifyIconOnline = YcIconifyIconOnline;
61643
59608
  exports.PlusBreadcrumb = PlusBreadcrumb;
61644
59609
  exports.PlusCheckCard = PlusCheckCard;
61645
59610
  exports.PlusCheckCardGroup = PlusCheckCardGroup;
@@ -61708,10 +59673,7 @@
61708
59673
  exports.YcDownloadDialogWithInstall = YcDownloadDialogWithInstall;
61709
59674
  exports.YcDrawer = YcDrawer;
61710
59675
  exports.YcFlicker = YcFlicker;
61711
- exports.YcFontIcon = YcFontIcon;
61712
59676
  exports.YcFormContainerHeader = YcFormContainerHeader;
61713
- exports.YcIconifyIconOffline = YcIconifyIconOffline;
61714
- exports.YcIconifyIconOnline = YcIconifyIconOnline;
61715
59677
  exports.YcLineTree = YcLineTree;
61716
59678
  exports.YcLineTreeWithInstall = YcLineTreeWithInstall;
61717
59679
  exports.YcMoreActions = YcMoreActions;
@@ -61756,7 +59718,6 @@
61756
59718
  exports.usePlusFormReset = usePlusFormReset;
61757
59719
  exports.usePlusProConfig = usePlusProConfig;
61758
59720
  exports.useRenderFlicker = useRenderFlicker;
61759
- exports.useRenderIcon = useRenderIcon;
61760
59721
  exports.useRenderReFlicker = useRenderFlicker;
61761
59722
  exports.useSelectWithMapping = useSelectWithMapping;
61762
59723
  exports.useSelectWithPagination = useSelectWithPagination;