yc-pro-components 0.0.4 → 0.0.6

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