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