ranui 0.1.10-alpha.2 → 0.1.10-alpha.4

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 (134) hide show
  1. package/dist/{utils-74Icp-PI.js → arrow-down-Beig7FXI.js} +139 -28
  2. package/dist/assets/image/failImage.d.ts +2 -0
  3. package/dist/build/config.d.ts +3 -0
  4. package/dist/build/config.es.d.ts +2 -0
  5. package/dist/build/config.sha.d.ts +2 -0
  6. package/dist/build/config.umd.d.ts +2 -0
  7. package/dist/button.js +3 -3
  8. package/dist/checkbox.js +3 -3
  9. package/dist/colorpicker.js +7 -9
  10. package/dist/{colz-CRDozfZA.js → colz-DJZvo_8B.js} +3 -8
  11. package/dist/components/button/index.d.ts +39 -0
  12. package/dist/components/checkbox/index.d.ts +27 -0
  13. package/dist/components/colorpicker/index.d.ts +120 -0
  14. package/dist/components/dropdown/index.d.ts +28 -0
  15. package/dist/components/form/index.d.ts +2 -0
  16. package/dist/components/icon/index.d.ts +2 -0
  17. package/dist/components/image/index.d.ts +2 -0
  18. package/dist/components/input/index.d.ts +209 -0
  19. package/dist/components/loading/index.d.ts +77 -0
  20. package/dist/components/math/index.d.ts +17 -0
  21. package/dist/components/message/index.d.ts +16 -0
  22. package/dist/components/modal/index.d.ts +2 -0
  23. package/dist/components/player/index.d.ts +238 -0
  24. package/dist/components/popover/content/index.d.ts +16 -0
  25. package/dist/components/popover/index.d.ts +59 -0
  26. package/dist/components/preview/colz.d.ts +72 -0
  27. package/dist/components/preview/constant.d.ts +5 -0
  28. package/dist/components/preview/docx.d.ts +8 -0
  29. package/dist/components/preview/excel/excel.d.ts +2 -0
  30. package/dist/components/preview/excel/index.d.ts +2 -0
  31. package/dist/components/preview/excel/media.d.ts +37 -0
  32. package/dist/components/preview/index.d.ts +3 -0
  33. package/dist/components/preview/pdf.d.ts +2 -0
  34. package/dist/components/preview/pptx/index.d.ts +19 -0
  35. package/dist/components/preview/pptx/process_pptx.d.ts +23 -0
  36. package/dist/components/preview/pptx/t_xml.d.ts +1 -0
  37. package/dist/components/preview/pptx/worker.d.ts +1 -0
  38. package/dist/components/preview/types.d.ts +10 -0
  39. package/dist/components/progress/index.d.ts +41 -0
  40. package/dist/components/radar/index.d.ts +2 -0
  41. package/dist/components/scratch/index.d.ts +23 -0
  42. package/dist/components/select/dropdown-item/index.d.ts +23 -0
  43. package/dist/components/select/index.d.ts +115 -0
  44. package/dist/components/select/option/index.d.ts +2 -0
  45. package/dist/components/skeleton/index.d.ts +2 -0
  46. package/dist/components/tab/index.d.ts +410 -0
  47. package/dist/components/tabpane/index.d.ts +354 -0
  48. package/dist/{docx-CChZ5Ycr.js → docx-CHkPTdGU.js} +1 -1
  49. package/dist/drop-4j4abxje.js +36 -0
  50. package/dist/icon.js +3 -3
  51. package/dist/iconShadowless.js +3 -3
  52. package/dist/image.js +1 -1
  53. package/dist/{index-BpOERe9M.js → index-BZR0HaP2.js} +1 -4
  54. package/dist/{index-B2yRe66F.js → index-BafnazTJ.js} +9 -17
  55. package/dist/{index-Dapt713u.js → index-Bl6-5Hp8.js} +2438 -4361
  56. package/dist/{index-ByBbFhvo.js → index-BqWbyjm2.js} +1165 -1831
  57. package/dist/{index-DqtzBqPN.js → index-C0Xh8vJ3.js} +12 -23
  58. package/dist/{index-DRi1ylHx.js → index-C1rSQlmc.js} +16 -23
  59. package/dist/{index-Cbp6LrE5.js → index-C4Sv0T51.js} +6 -12
  60. package/dist/index-CCxIoCAT.js +657 -0
  61. package/dist/{index-BHmWrPCW.js → index-CGEx9VOA.js} +866 -1662
  62. package/dist/{index-C-p_Wpit.js → index-CILRcFIV.js} +3 -6
  63. package/dist/index-COa4RzeW.js +105 -0
  64. package/dist/{index-B4bfIbdI.js → index-CWNtaUwu.js} +17 -25
  65. package/dist/{index-DytfjwBV.js → index-CjSKJE6S.js} +11 -15
  66. package/dist/{index-C6wPL-2Y.js → index-Ck9TOxFh.js} +22 -41
  67. package/dist/{index-BF8tJ6rR.js → index-CryFK9u4.js} +11 -21
  68. package/dist/{index-C1x9Popy.js → index-DAxs7Dd2.js} +5 -12
  69. package/dist/index-DBecKjmY.js +279 -0
  70. package/dist/{index-CSnBqUsQ.js → index-DC5EA657.js} +2 -6
  71. package/dist/index-DEcHDJ1m.js +306 -0
  72. package/dist/index-DL-1C2RQ.js +496 -0
  73. package/dist/index-DN-kAx-A.js +72 -0
  74. package/dist/{index-DRWOSfdF.js → index-DUF6lQQS.js} +15 -28
  75. package/dist/{index-Du-Biu-I.js → index-KS2nvVcO.js} +1 -4
  76. package/dist/{index-CFnsLnrb.js → index-WfFw4LJT.js} +42 -48
  77. package/dist/index.d.ts +231 -0
  78. package/dist/index.js +20 -26
  79. package/dist/input.js +2 -2
  80. package/dist/inputShadowless.js +2 -2
  81. package/dist/{jszip.min-DD9Dc6z4.js → jszip.min-Dhs3nUkD.js} +699 -1027
  82. package/dist/katex-es-B5r5vt3m.js +14628 -0
  83. package/dist/loading-scene-BMc2wqKm.js +4 -0
  84. package/dist/loading.js +4 -2
  85. package/dist/math.js +7 -0
  86. package/dist/message.js +3 -2
  87. package/dist/{pdf-DpNqCylD.js → pdf-Cx0VWKFo.js} +2 -5
  88. package/dist/player.js +4 -4
  89. package/dist/playwright.config.d.ts +9 -0
  90. package/dist/plugins/auto-import-file.d.ts +0 -0
  91. package/dist/plugins/load-style.d.ts +6 -0
  92. package/dist/plugins/load-svg.d.ts +9 -0
  93. package/dist/popover.js +4 -2
  94. package/dist/preview.js +4 -4
  95. package/dist/progress.js +3 -3
  96. package/dist/radar.js +3 -3
  97. package/dist/select.js +6 -6
  98. package/dist/selectShadowless.js +562 -8
  99. package/dist/shadowless/icon/index.d.ts +3 -0
  100. package/dist/shadowless/input/index.d.ts +210 -0
  101. package/dist/shadowless/select/index.d.ts +109 -0
  102. package/dist/shadowless/select/option/index.d.ts +2 -0
  103. package/dist/shadowless/shadowless/index.js +3 -9
  104. package/dist/shadowless.d.ts +3 -0
  105. package/dist/skeleton.js +1 -1
  106. package/dist/style.css +1 -1
  107. package/dist/tab.js +3 -3
  108. package/dist/tabpane.js +1 -1
  109. package/dist/tests/button.spec.d.ts +1 -0
  110. package/dist/tsconfig.json +3 -2
  111. package/dist/typings.d.ts +211 -0
  112. package/dist/umd/index.umd.cjs +9 -9
  113. package/dist/umd/shadowless/shadowless.umd.cjs +1 -1
  114. package/dist/umd/shadowless/style.css +1 -1
  115. package/dist/umd/style.css +1 -1
  116. package/dist/utils/color.d.ts +52 -0
  117. package/dist/utils/image.d.ts +32 -0
  118. package/dist/utils/index.d.ts +72 -0
  119. package/dist/utils/math.d.ts +26 -0
  120. package/dist/utils/tween.d.ts +21 -0
  121. package/dist/vite.config.d.ts +7 -0
  122. package/package.json +47 -38
  123. package/readme.md +7 -48
  124. package/typings.d.ts +113 -2
  125. package/dist/arrow-down-D4qr4m33.js +0 -30
  126. package/dist/content.js +0 -6
  127. package/dist/global-DOOKQmNv.js +0 -4
  128. package/dist/index-01Qfd9QI.js +0 -207
  129. package/dist/index-CWWI8SHO.js +0 -206
  130. package/dist/index-CbyMC6Yz.js +0 -59
  131. package/dist/index-Cr9AYoGT.js +0 -498
  132. package/dist/index-DLB8VOy7.js +0 -281
  133. package/dist/index-DsIUhdNt.js +0 -533
  134. package/dist/option.js +0 -92
@@ -0,0 +1,657 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { c as create, a as addClassToElement, r as removeClassToElement, i as isMobile, f as generateThrottle } from "./arrow-down-Beig7FXI.js";
5
+ import { c as createCustomError, i as isDisabled, H as HTMLElementSSR } from "./index-DC5EA657.js";
6
+ import "./index-COa4RzeW.js";
7
+ import "./index-Ck9TOxFh.js";
8
+ import "./index-C4Sv0T51.js";
9
+ const f7170ee498e0dd32cbdcb63fba8f75cc = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}r-select{position:var(--ran-select, relative);width:var(--ran-select, 120px);height:var(--ran-select, 40px)}:host{position:var(--ran-select-host, relative);display:var(--ran-select-host, inline-block);cursor:var(--ran-select-host, pointer);height:var(--ran-select-host, 32px);outline:var(--ran-select-host, 0);-webkit-tap-highlight-color:var(--ran-select-host-highlight-color, transparent)}:host,:host(:focus),:host(:active){outline:var(--ran-select-host-focus-outline, 0);-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:none}:host([disabled]){cursor:var(--ran-select-host-disabled-cursor, not-allowed);pointer-events:var(--ran-select-host-disabled-pointer-events, all);opacity:var(--ran-select-host-disabled-opacity, .6)}:host([type="text"])::part(selection){border:none}:host([type="text"])::part(icon){display:none}:host(:not([disabled]):hover) .select{cursor:var(--ran-select-host-hover-cursor, pointer)}:host(:not([disabled]):hover) .selection{border:var(--ran-select-host-selection-border, 1px solid #1890ff)}:host(:not([disabled]):hover) .selection-search{cursor:var(--ran-select-host-selection-search-cursor, pointer)}:host(:not([disabled]):hover) .selection-item{cursor:var(--ran-select-host-selection-item-cursor, pointer);color:var(--ran-select-host-selection-item-color, #bfbfbf)}:host(:not([disabled]):focus) .selection{border:var(--ran-select-host-selection-focus-border, 1px solid #1890ff)}:host(:not([disabled]):focus) .selection-search{cursor:var(--ran-select-host-selection-focus-search-cursor, pointer)}:host(:not([disabled]):focus) .selection-item{cursor:var(--ran-select-host-selection-focus-item-cursor, pointer);color:var(--ran-select-host-selection-focus-item-color, #bfbfbf)}:host .selection-search{display:var(--ran-select-host-selection-search-display, none)}:host([showSearch]:not([disabled])) .selection-search{cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);display:var(--ran-select-host-showSearch-selection-search-display, block)}:host([showSearch]:not([disabled])) .selection-item{cursor:var(--ran-select-host-showSearch-selection-item-cursor, pointer)}:host([showSearch]:not([disabled]):focus) .selection-search{display:var(--ran-select-host-showSearch-selection-search-display, block);cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);opacity:var(--ran-select-host-showSearch-selection-search-opacity, 1)}.ran-select{width:var(--ran-select-width, 100%);height:var(--ran-select-width, 100%);font-size:var(--ran-select-font-size, 14px);box-sizing:var(--ran-select-box-sizing, border-box);margin:var(--ran-select-margin, 0);padding:var(--ran-select-padding, 0);color:var(--ran-select-color, rgba(0, 0, 0, .88));line-height:var(--ran-select-line-height, 1.57142857);list-style:var(--ran-select-list-style, none);font-family:var(--ran-select-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");position:var(--ran-select-position, relative);display:var(--ran-select-display, inline-block)}.ran-select .selection{position:var(--ran-select-selection-position, relative);background-color:var(--ran-select-selection-background-color, #ffffff);border:var(--ran-select-selection-border, 1px solid #d9d9d9);transition:var(--ran-select-selection-transition, all .2s cubic-bezier(.645, .045, .355, 1));width:var(--ran-select-selection-width, 100%);height:var(--ran-select-selection-height, 100%);padding:var(--ran-select-selection-padding, 0 11px);box-sizing:var(--ran-select-selection-box-sizing, border-box);margin:var(--ran-select-selection-margin, 0);color:var(--ran-select-selection-color, rgba(0, 0, 0, .88));font-size:var(--ran-select-selection-font-size, 14px);line-height:var(--ran-select-selection-line-height, 1.57142857);list-style:var(--ran-select-selection-list-style, none);font-family:var(--ran-select-selection-font-family, inherit);display:var(--ran-select-selection-display, flex);border-radius:var(--ran-select-selection-border-radius, 6px)}.ran-select .selection-search{position:var(--ran-select-selection-search-position, absolute);opacity:var(--ran-select-selection-search-opacity, 0);top:var(--ran-select-selection-search-top, 0);left:var(--ran-select-selection-search-left, 0);height:var(--ran-select-selection-search-height, 100%);inset-inline-start:var(--ran-select-selection-search-inset-inline-start, 11px);inset-inline-end:var(--ran-select-selection-search-inset-inline-end, 11px);margin:var(--ran-select-selection-search-margin, 0);padding:var(--ran-select-selection-search-padding, 0);background:var(--ran-select-selection-search-background, transparent);border:var(--ran-select-selection-search-border, none);outline:var(--ran-select-selection-search-outline, none);-webkit-appearance:var(--ran-select-selection-search-appearance, none);-moz-appearance:var(--ran-select-selection-search-appearance, none);appearance:var(--ran-select-selection-search-appearance, none);font-family:var(--ran-select-selection-search-font-family, inherit);cursor:var(--ran-select-selection-search-cursor, not-allowed)}.ran-select .selection-search::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-select .selection-search::part(ran-input){border:none;padding:0;height:100%;outline:none}.ran-select .selection-search::part(ran-input):active{border:none;padding:0;height:100%;outline:none;border-color:transparent;box-shadow:none;border-right-width:0px}.ran-select .selection-item{position:var(--ran-select-selection-item-position, absolute);top:var(--ran-select-selection-item-top, 0);left:var(--ran-select-selection-item-left, 12px);margin:var(--ran-select-selection-item-margin, 0);padding:var(--ran-select-selection-item-padding, 0);background:var(--ran-select-selection-item-background, transparent);border:var(--ran-select-selection-item-border, none);outline:var(--ran-select-selection-item-outline, none);-webkit-appearance:var(--ran-select-selection-item-appearance, none);-moz-appearance:var(--ran-select-selection-item-appearance, none);appearance:var(--ran-select-selection-item-appearance, none);font-family:var(--ran-select-selection-item-font-family, inherit);height:var(--ran-select-selection-item-height, 100%);-webkit-user-select:var(--ran-select-selection-item-user-select, none);user-select:var(--ran-select-selection-item-user-select, none);overflow:var(--ran-select-selection-item-overflow, hidden);white-space:var(--ran-select-selection-item-white-space, nowrap);text-overflow:var(--ran-select-selection-item-text-overflow, ellipsis);cursor:var(--ran-select-selection-item-cursor, pointer)}.ran-select .selection-select{color:var(--ran-select-selection-select-color, rgba(0, 0, 0, .25))}.ran-select .selection .icon{display:var(--ran-select-selection-icon-display, flex);align-items:var(--ran-select-selection-icon-align-items, center);color:var(--ran-select-selection-icon-color, rgba(0, 0, 0, .25));font-style:var(--ran-select-selection-icon-font-style, normal);text-align:var(--ran-select-selection-icon-text-align, center);text-transform:var(--ran-select-selection-icon-text-transform, none);text-rendering:var(--ran-select-selection-icon-text-rendering, optimizeLegibility);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:var(--ran-select-selection-icon-position, absolute);top:var(--ran-select-selection-icon-top, 50%);inset-inline-start:var(--ran-select-selection-icon-inset-inline-start, auto);inset-inline-end:var(--ran-select-selection-icon-inset-inline-end, 8px);height:var(--ran-select-selection-icon-height, 12px);margin-top:var(--ran-select-selection-icon-margin-top, -3px);font-size:var(--ran-select-selection-icon-font-size, 12px);pointer-events:var(--ran-select-selection-icon-color, pointer-events)}';
10
+ function Custom$2() {
11
+ if (typeof document !== "undefined" && !customElements.get("r-option")) {
12
+ class Option extends HTMLElement {
13
+ constructor() {
14
+ super();
15
+ __publicField(this, "_option");
16
+ __publicField(this, "_optionContent");
17
+ __publicField(this, "_shadowDom");
18
+ __publicField(this, "_slot");
19
+ this._slot = document.createElement("slot");
20
+ this._option = document.createElement("div");
21
+ this._option.setAttribute("class", "ran-option");
22
+ this._optionContent = document.createElement("div");
23
+ this._optionContent.setAttribute("class", "ran-option-content");
24
+ this._optionContent.appendChild(this._slot);
25
+ this._option.appendChild(this._optionContent);
26
+ const shadowRoot = this.attachShadow({ mode: "closed" });
27
+ this._shadowDom = shadowRoot;
28
+ shadowRoot.appendChild(this._option);
29
+ }
30
+ static get observedAttributes() {
31
+ return ["disabled", "sheet", "value"];
32
+ }
33
+ get value() {
34
+ return this.getAttribute("value");
35
+ }
36
+ set value(value) {
37
+ this.setAttribute("value", value || "");
38
+ }
39
+ get sheet() {
40
+ return this.getAttribute("sheet");
41
+ }
42
+ set sheet(value) {
43
+ this.setAttribute("sheet", value || "");
44
+ }
45
+ get disabled() {
46
+ return isDisabled(this);
47
+ }
48
+ set disabled(value) {
49
+ if (!value || value === "false") {
50
+ this.removeAttribute("disabled");
51
+ } else {
52
+ this.setAttribute("disabled", "");
53
+ }
54
+ }
55
+ handlerExternalCss() {
56
+ if (this.sheet) {
57
+ try {
58
+ const sheet = new CSSStyleSheet();
59
+ sheet.insertRule(this.sheet);
60
+ this._shadowDom.adoptedStyleSheets = [sheet];
61
+ } catch (error) {
62
+ console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`);
63
+ }
64
+ }
65
+ }
66
+ connectedCallback() {
67
+ }
68
+ disconnectCallback() {
69
+ }
70
+ attributeChangedCallback(name, oldValue, newValue) {
71
+ if (name === "disabled" && this._option) {
72
+ if (!newValue || newValue === "false") {
73
+ this._option.setAttribute("disabled", "");
74
+ } else {
75
+ this._option.removeAttribute("disabled");
76
+ }
77
+ }
78
+ if (name === "sheet" && this._shadowDom && oldValue !== newValue) this.handlerExternalCss();
79
+ }
80
+ }
81
+ return Option;
82
+ } else {
83
+ return createCustomError("document is undefined or r-option is exist");
84
+ }
85
+ }
86
+ Custom$2();
87
+ const less = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ranui-dropdown-option-item{position:var(--ranui-dropdown-option-item-position, relative);display:var(--ranui-dropdown-option-item-display, block);padding:var(--ranui-dropdown-option-item-padding, 5px 12px);color:var(--ranui-dropdown-option-item-color, rgba(0, 0, 0, .88));font-weight:var(--ranui-dropdown-option-item-font-weight, normal);font-size:var(--ranui-dropdown-option-item-font-size, 14px);transition:var(--ranui-dropdown-option-item-transition, background .3s ease);border-radius:var(--ranui-dropdown-option-item-border-radius, 4px)}.ranui-dropdown-option-item:hover{background-color:var(--ranui-dropdown-option-item-hover-background-color, rgba(0, 0, 0, .04))}.ranui-dropdown-option-item-content{text-align:var(--ranui-dropdown-content-text-align, left);overflow:var(--ranui-dropdown-content-overflow, hidden);white-space:var(--ranui-dropdown-content-white-space, nowrap);text-overflow:var(--ranui-dropdown-content-text-overflow, ellipsis);color:var(--ranui-dropdown-content-color, rgba(0, 0, 0, .88));font-size:var(--ranui-dropdown-content-font-size, 14px);line-height:var(--ranui-dropdown-content-line-height, 1.57142857);box-sizing:var(--ranui-dropdown-content-box-sizing, border-box);list-style:var(--ranui-dropdown-content-list-style, none);font-family:var(--ranui-dropdown-content-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-variant:var(--ranui-dropdown-content-font-variant, initial)}.ranui-dropdown-option-active{background-color:var(--ranui-dropdown-option-active-background-color, #e6f7ff);font-weight:var(--ranui-dropdown-option-active-font-weight, bold)}.ranui-dropdown-option-active:hover{background-color:var(--ranui-dropdown-option-active-hover-background-color, #e6f7ff)}';
88
+ class DropdownItem extends HTMLElementSSR() {
89
+ constructor() {
90
+ super();
91
+ __publicField(this, "ionDropdownItem");
92
+ __publicField(this, "_slot");
93
+ __publicField(this, "_shadowDom");
94
+ __publicField(this, "ionDropdownItemContent");
95
+ this._slot = create("slot").setAttribute("class", "slot");
96
+ this.ionDropdownItemContent = create("div").setAttribute("class", "ranui-dropdown-option-item-content").setAttribute("part", "ranui-dropdown-option-item-content").addChild(this._slot);
97
+ this.ionDropdownItem = create("div").setAttribute("class", "ranui-dropdown-option-item").setAttribute("part", "ranui-dropdown-option-item").addChild([this.ionDropdownItemContent]);
98
+ const shadowRoot = this.attachShadow({ mode: "closed" });
99
+ this._shadowDom = shadowRoot;
100
+ const style = create("style").setTextContent(less);
101
+ shadowRoot.appendChild(style.element);
102
+ shadowRoot.appendChild(this.ionDropdownItem.element);
103
+ }
104
+ static get observedAttributes() {
105
+ return ["active", "value", "title"];
106
+ }
107
+ get value() {
108
+ return this.getAttribute("value") || "";
109
+ }
110
+ set value(value) {
111
+ if (!isDisabled(this) && value) {
112
+ this.setAttribute("value", value);
113
+ } else {
114
+ this.removeAttribute("value");
115
+ }
116
+ }
117
+ get active() {
118
+ return this.getAttribute("active") || "";
119
+ }
120
+ set active(value) {
121
+ if (value) {
122
+ this.setAttribute("active", value);
123
+ } else {
124
+ this.removeAttribute("active");
125
+ }
126
+ }
127
+ get title() {
128
+ return this.getAttribute("title") || "";
129
+ }
130
+ set title(value) {
131
+ if (value) {
132
+ this.setAttribute("title", value);
133
+ } else {
134
+ this.removeAttribute("title");
135
+ }
136
+ }
137
+ connectedCallback() {
138
+ if (this.active) {
139
+ addClassToElement(this.ionDropdownItem.element, "ranui-dropdown-option-active");
140
+ }
141
+ }
142
+ attributeChangedCallback(name, oldValue, newValue) {
143
+ if (name === "active" && newValue) {
144
+ addClassToElement(this.ionDropdownItem.element, "ranui-dropdown-option-active");
145
+ } else {
146
+ removeClassToElement(this.ionDropdownItem.element, "ranui-dropdown-option-active");
147
+ }
148
+ }
149
+ }
150
+ function Custom$1() {
151
+ if (typeof document !== "undefined" && !customElements.get("r-dropdown-item")) {
152
+ customElements.define("r-dropdown-item", DropdownItem);
153
+ return DropdownItem;
154
+ } else {
155
+ return createCustomError("document is undefined or r-dropdown-item is exist");
156
+ }
157
+ }
158
+ Custom$1();
159
+ const placementDirection = {
160
+ bottom: {
161
+ add: "ran-dropdown-down-in",
162
+ remove: "ran-dropdown-down-out"
163
+ },
164
+ top: {
165
+ add: "ran-dropdown-up-in",
166
+ remove: "ran-dropdown-up-out"
167
+ }
168
+ };
169
+ const searchThrottle = generateThrottle();
170
+ const animationTime = 300;
171
+ class Select extends HTMLElementSSR() {
172
+ constructor() {
173
+ super();
174
+ __publicField(this, "removeTimeId");
175
+ __publicField(this, "_slot");
176
+ __publicField(this, "_shadowDom");
177
+ __publicField(this, "_select");
178
+ __publicField(this, "_selection");
179
+ __publicField(this, "_search");
180
+ __publicField(this, "_icon");
181
+ __publicField(this, "_selectDropdown");
182
+ __publicField(this, "_selectionDropdown");
183
+ __publicField(this, "_selectDropDownInTimeId");
184
+ __publicField(this, "_selectDropDownOutTimeId");
185
+ __publicField(this, "_optionList");
186
+ __publicField(this, "_optionLabelMapValue");
187
+ __publicField(this, "_optionValueMapLabel");
188
+ __publicField(this, "_activeOption");
189
+ __publicField(this, "_text");
190
+ __publicField(this, "_selector");
191
+ __publicField(this, "onSearch");
192
+ /**
193
+ * @description: 移除 select dropdown
194
+ * @return {*}
195
+ */
196
+ __publicField(this, "setSelectDropdownDisplayNone", () => {
197
+ if (this._selectDropDownOutTimeId) return;
198
+ if (this._selectionDropdown && this._selectionDropdown.style.display !== "none") {
199
+ this._selectionDropdown.setAttribute("transit", placementDirection[this.placement].remove);
200
+ this._selectDropDownOutTimeId = setTimeout(() => {
201
+ var _a;
202
+ (_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "none");
203
+ this._selectionDropdown && this._selectionDropdown.removeAttribute("transit");
204
+ clearTimeout(this._selectDropDownOutTimeId);
205
+ this._selectDropDownOutTimeId = void 0;
206
+ }, animationTime);
207
+ }
208
+ });
209
+ /**
210
+ * @description: 添加 select dropdown
211
+ * @return {*}
212
+ */
213
+ __publicField(this, "setSelectDropdownDisplayBlock", () => {
214
+ var _a;
215
+ if (this._selectDropDownInTimeId) return;
216
+ if (this._selectionDropdown && this._selectionDropdown.style.display !== "block") {
217
+ this._selectionDropdown.setAttribute("transit", placementDirection[this.placement].add);
218
+ (_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "block");
219
+ this._selectDropDownInTimeId = setTimeout(() => {
220
+ this._selectionDropdown && this._selectionDropdown.removeAttribute("transit");
221
+ clearTimeout(this._selectDropDownInTimeId);
222
+ this._selectDropDownInTimeId = void 0;
223
+ }, animationTime);
224
+ }
225
+ });
226
+ __publicField(this, "placementPosition", () => {
227
+ if (!this._selectionDropdown || !this._selectDropdown) return;
228
+ const rect = this.getBoundingClientRect();
229
+ const { top, left, bottom, width, height, x, y, right } = rect;
230
+ const root = document.getElementById(this.getPopupContainerId);
231
+ this._selectionDropdown.style.setProperty("position", `absolute`);
232
+ this._selectionDropdown.style.setProperty("--ran-x", `${top + window.scrollX}`);
233
+ this._selectionDropdown.style.setProperty("--ran-y", `${left + window.scrollY}`);
234
+ let selectTop = bottom + window.scrollY;
235
+ let selectLeft = left + window.scrollX;
236
+ this._selectionDropdown.style.setProperty("width", `${width}px`);
237
+ if (this.placement === "top") {
238
+ selectTop = top + window.scrollY - this._selectionDropdown.clientHeight;
239
+ }
240
+ if (this.getPopupContainerId && root) {
241
+ const rootRect = root.getBoundingClientRect();
242
+ selectLeft = left - rootRect.left;
243
+ if (this.placement === "top") {
244
+ selectTop = top - root.getBoundingClientRect().top - this._selectionDropdown.clientHeight;
245
+ } else {
246
+ selectTop = root.getBoundingClientRect().height;
247
+ }
248
+ }
249
+ this._selectionDropdown.style.setProperty("inset", `${selectTop}px auto auto ${selectLeft}px`);
250
+ });
251
+ /**
252
+ * @description: 设置下拉框
253
+ * @return {*}
254
+ */
255
+ __publicField(this, "selectMouseDown", (e) => {
256
+ e.stopPropagation();
257
+ if (isDisabled(this)) return;
258
+ this.removeDropDownTimeId();
259
+ this.setSelectDropdownDisplayNone();
260
+ this.setSelectDropdownDisplayBlock();
261
+ this.placementPosition();
262
+ });
263
+ __publicField(this, "removeDropDownTimeId", () => {
264
+ this._search.setAttribute("value", "");
265
+ if (this.trigger.includes("hover") && !isMobile()) {
266
+ clearTimeout(this.removeTimeId);
267
+ this.removeTimeId = void 0;
268
+ }
269
+ });
270
+ /**
271
+ * @description: 焦点移除的情况,需要移除 select 下拉框
272
+ * @return {*}
273
+ */
274
+ __publicField(this, "selectBlur", () => {
275
+ if (this.removeTimeId) {
276
+ this.removeDropDownTimeId();
277
+ }
278
+ this.removeTimeId = setTimeout(() => {
279
+ this.removeDropDownTimeId();
280
+ this.setSelectDropdownDisplayNone();
281
+ }, 100);
282
+ });
283
+ /**
284
+ * @description: 选中一个选项的情况
285
+ * @param {MouseEvent} e
286
+ * @return {*}
287
+ */
288
+ __publicField(this, "clickOption", (e) => {
289
+ e.stopPropagation();
290
+ const element = e.target;
291
+ const label = element.innerHTML;
292
+ const value = this._optionLabelMapValue.get(label);
293
+ if (value) {
294
+ this.setAttribute("value", value);
295
+ this._text.innerHTML = label;
296
+ this._text.setAttribute("title", label);
297
+ this._search.setAttribute("placeholder", label);
298
+ }
299
+ const rect = this.getBoundingClientRect();
300
+ const { height } = rect;
301
+ this._text.style.setProperty("line-height", `${height}px`);
302
+ if (this._activeOption) {
303
+ this._activeOption.removeAttribute("active");
304
+ }
305
+ this._activeOption = element;
306
+ if (this._activeOption) {
307
+ this._activeOption.setAttribute("active", value || "");
308
+ }
309
+ this.setSelectDropdownDisplayNone();
310
+ this.dispatchEvent(new CustomEvent("change", { detail: { value, label } }));
311
+ this.removeDropDownTimeId();
312
+ });
313
+ /**
314
+ * @description: 初始化创建选项下拉框
315
+ * @return {*}
316
+ */
317
+ __publicField(this, "createOption", () => {
318
+ if (!this._selectDropdown) {
319
+ const container = document.getElementById(this.getPopupContainerId) || document.body;
320
+ this._selectDropdown = document.createElement("div");
321
+ this._selectDropdown.style.setProperty("-webkit-tap-highlight-color", "transparent");
322
+ this._selectDropdown.style.setProperty("outline", "0");
323
+ this._selectDropdown.addEventListener("click", this.clickOption);
324
+ this._selectionDropdown = document.createElement("r-dropdown");
325
+ if (this.dropdownclass) {
326
+ this._selectionDropdown.setAttribute("class", this.dropdownclass);
327
+ }
328
+ if (this.trigger.includes("hover") && !isMobile()) {
329
+ this._selectDropdown.addEventListener("mouseleave", this.selectBlur);
330
+ this._selectDropdown.addEventListener("mouseenter", this.removeDropDownTimeId);
331
+ }
332
+ this._selectDropdown.appendChild(this._selectionDropdown);
333
+ this._selectionDropdown.style.setProperty("display", "none");
334
+ container.appendChild(this._selectDropdown);
335
+ }
336
+ });
337
+ /**
338
+ * @description: 移除选项下拉框
339
+ * @return {*}
340
+ */
341
+ __publicField(this, "removeSelectDropdown", () => {
342
+ try {
343
+ if (this._selectDropdown) {
344
+ const container = document.getElementById(this.getPopupContainerId) || document.body;
345
+ container.removeChild(this._selectDropdown);
346
+ }
347
+ } catch (error) {
348
+ }
349
+ });
350
+ /**
351
+ * @description: 当 select 中有 option 元素的时候,给 dropdown 添加元素
352
+ * @return {*}
353
+ */
354
+ __publicField(this, "addOptionToSlot", () => {
355
+ const slots = this._slot.assignedElements();
356
+ slots.forEach((item) => {
357
+ var _a;
358
+ if (item.tagName !== "R-OPTION") return;
359
+ const label = item.innerHTML;
360
+ const value = item.getAttribute("value") || "";
361
+ (_a = this._optionList) == null ? void 0 : _a.push({ label, value });
362
+ if (this._optionLabelMapValue.get(label)) {
363
+ console.warn(`${label} is repeat option`);
364
+ }
365
+ if (this._optionValueMapLabel.get(value)) {
366
+ console.warn(`${value} is repeat option`);
367
+ }
368
+ this._optionLabelMapValue.set(label, value);
369
+ this._optionValueMapLabel.set(value, label);
370
+ });
371
+ this.createSelectDropdownContent(this._optionList);
372
+ });
373
+ __publicField(this, "createSelectDropdownContent", (options = []) => {
374
+ var _a, _b;
375
+ if (options.length === 0) {
376
+ (_a = this._selectDropdown) == null ? void 0 : _a.style.setProperty("display", "none");
377
+ } else {
378
+ (_b = this._selectDropdown) == null ? void 0 : _b.style.setProperty("display", "block");
379
+ }
380
+ options.forEach((item) => {
381
+ if (this._selectionDropdown) {
382
+ const { label, value } = item;
383
+ const selectOptionItem = document.createElement("r-dropdown-item");
384
+ const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
385
+ if (defaultValue === value) {
386
+ selectOptionItem.setAttribute("active", value);
387
+ this._activeOption = selectOptionItem;
388
+ } else {
389
+ selectOptionItem.removeAttribute("active");
390
+ }
391
+ selectOptionItem.innerHTML = `${label}`;
392
+ selectOptionItem.setAttribute("value", `${value}`);
393
+ selectOptionItem.setAttribute("title", `${label}`);
394
+ this._selectionDropdown.appendChild(selectOptionItem);
395
+ }
396
+ });
397
+ this.setDefaultValue();
398
+ });
399
+ __publicField(this, "setDefaultValue", () => {
400
+ const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
401
+ if (!defaultValue) return;
402
+ const label = this._optionValueMapLabel.get(defaultValue);
403
+ if (!label) return;
404
+ this.setAttribute("value", defaultValue);
405
+ const rect = this.getBoundingClientRect();
406
+ const { height } = rect;
407
+ this._text.style.setProperty("line-height", `${height}px`);
408
+ this._text.innerHTML = label;
409
+ this._text.setAttribute("title", label);
410
+ });
411
+ __publicField(this, "changeSearch", (e) => {
412
+ const value = e.detail.value || "";
413
+ this.dispatchEvent(
414
+ new CustomEvent("search", {
415
+ detail: { value }
416
+ })
417
+ );
418
+ if (this._selectionDropdown) {
419
+ this._selectionDropdown.innerHTML = "";
420
+ }
421
+ if (value.length > 0) {
422
+ const options = this._optionList.map((item) => {
423
+ const { label } = item;
424
+ if (`${label}`.toLowerCase().includes(value)) {
425
+ return { label, value: item.value };
426
+ }
427
+ return void 0;
428
+ }).filter((item) => item);
429
+ this.createSelectDropdownContent(options);
430
+ } else {
431
+ this.createSelectDropdownContent(this._optionList);
432
+ }
433
+ });
434
+ __publicField(this, "setShowSearch", () => {
435
+ this.onSearch = searchThrottle(this.changeSearch);
436
+ this.onSearch && this._search.addEventListener("change", this.onSearch);
437
+ this.onSearch && this._search.addEventListener("click", this.onSearch);
438
+ });
439
+ __publicField(this, "removeShowSearch", () => {
440
+ this.onSearch && this._search.removeEventListener("change", this.onSearch);
441
+ this.onSearch && this._search.removeEventListener("click", this.onSearch);
442
+ });
443
+ __publicField(this, "listenSlotChange", () => {
444
+ this._slot.addEventListener("slotchange", this.addOptionToSlot);
445
+ });
446
+ __publicField(this, "removeListenSlotChange", () => {
447
+ this._slot.removeEventListener("slotchange", this.addOptionToSlot);
448
+ });
449
+ __publicField(this, "listenActionEvent", () => {
450
+ this.removeEventListener("mouseenter", this.selectMouseDown);
451
+ this.removeEventListener("mouseleave", this.selectBlur);
452
+ this.removeEventListener("click", this.selectMouseDown);
453
+ this.removeEventListener("blur", this.selectBlur);
454
+ if (this.trigger.includes("hover") && !isMobile()) {
455
+ this.addEventListener("mouseenter", this.selectMouseDown);
456
+ this.addEventListener("mouseleave", this.selectBlur);
457
+ }
458
+ if (this.trigger.includes("click")) {
459
+ this.addEventListener("click", this.selectMouseDown);
460
+ this.addEventListener("blur", this.selectBlur);
461
+ }
462
+ });
463
+ __publicField(this, "clickRemoveSelect", (e) => {
464
+ e.stopPropagation();
465
+ this.setSelectDropdownDisplayNone();
466
+ });
467
+ this._slot = document.createElement("slot");
468
+ this._select = document.createElement("div");
469
+ this._select.setAttribute("class", "ran-select");
470
+ this._select.setAttribute("part", "select");
471
+ this._selection = document.createElement("div");
472
+ this._selection.setAttribute("class", "selection");
473
+ this._selection.setAttribute("part", "selection");
474
+ this._selector = document.createElement("div");
475
+ this._search = document.createElement("r-input");
476
+ this._search.setAttribute("class", "selection-search");
477
+ this._search.setAttribute("part", "search");
478
+ this._search.setAttribute("type", "search");
479
+ this._search.setAttribute("autocomplete", "off");
480
+ this._text = document.createElement("span");
481
+ this._text.setAttribute("class", "selection-item");
482
+ this._text.setAttribute("part", "selection-item");
483
+ this._icon = document.createElement("ra-icon");
484
+ this._icon.setAttribute("class", "icon");
485
+ this._icon.setAttribute("part", "icon");
486
+ this._icon.setAttribute("name", "arrow-down");
487
+ this._icon.setAttribute("color", "#d9d9d9");
488
+ this._icon.setAttribute("size", "16");
489
+ this._selector.appendChild(this._text);
490
+ this._selector.appendChild(this._search);
491
+ this._selection.appendChild(this._icon);
492
+ this._selection.appendChild(this._selector);
493
+ this._slot.setAttribute("class", "slot");
494
+ this._select.appendChild(this._selection);
495
+ this._select.appendChild(this._slot);
496
+ this._optionList = [];
497
+ this._optionLabelMapValue = /* @__PURE__ */ new Map();
498
+ this._optionValueMapLabel = /* @__PURE__ */ new Map();
499
+ const shadowRoot = this.attachShadow({ mode: "closed" });
500
+ const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
501
+ F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
502
+ shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
503
+ this._shadowDom = shadowRoot;
504
+ this._shadowDom.appendChild(this._select);
505
+ }
506
+ static get observedAttributes() {
507
+ return [
508
+ "disabled",
509
+ "sheet",
510
+ "clear",
511
+ "type",
512
+ "defaultValue",
513
+ "showSearch",
514
+ "placement",
515
+ // 弹窗的方向
516
+ "getPopupContainerId",
517
+ // 挂载的节点
518
+ "dropdownclass",
519
+ // 弹窗的类名
520
+ "trigger"
521
+ // 触发下拉框的行为,click 还是 hover,hover 在 isMobile 移动端无效
522
+ ];
523
+ }
524
+ get value() {
525
+ return this.getAttribute("value") || "";
526
+ }
527
+ set value(value) {
528
+ if (!isDisabled(this) && value) {
529
+ this.setAttribute("value", value);
530
+ } else {
531
+ this.removeAttribute("value");
532
+ }
533
+ }
534
+ get defaultValue() {
535
+ return this.getAttribute("defaultValue") || "";
536
+ }
537
+ set defaultValue(value) {
538
+ this.setAttribute("defaultValue", value || "");
539
+ }
540
+ get showSearch() {
541
+ return this.getAttribute("showSearch") || "";
542
+ }
543
+ set showSearch(value) {
544
+ this.setAttribute("showSearch", value || "");
545
+ }
546
+ get type() {
547
+ return this.getAttribute("type") || "";
548
+ }
549
+ set type(value) {
550
+ this.setAttribute("type", value || "");
551
+ }
552
+ get placement() {
553
+ return this.getAttribute("placement") || "bottom";
554
+ }
555
+ set placement(value) {
556
+ this.setAttribute("placement", value || "");
557
+ }
558
+ get sheet() {
559
+ return this.getAttribute("sheet") || "";
560
+ }
561
+ set sheet(value) {
562
+ this.setAttribute("sheet", value || "");
563
+ }
564
+ get getPopupContainerId() {
565
+ return this.getAttribute("getPopupContainerId") || "";
566
+ }
567
+ set getPopupContainerId(value) {
568
+ this.setAttribute("getPopupContainerId", value || "");
569
+ }
570
+ get dropdownclass() {
571
+ return this.getAttribute("dropdownclass") || "";
572
+ }
573
+ set dropdownclass(value) {
574
+ this.setAttribute("dropdownclass", value || "");
575
+ }
576
+ get trigger() {
577
+ return this.getAttribute("trigger") || "click";
578
+ }
579
+ set trigger(value) {
580
+ this.setAttribute("trigger", value || "");
581
+ }
582
+ get disabled() {
583
+ return isDisabled(this);
584
+ }
585
+ set disabled(value) {
586
+ if (!value || value === "false") {
587
+ this.removeAttribute("disabled");
588
+ this._selection.removeAttribute("disabled");
589
+ } else {
590
+ this.setAttribute("disabled", "");
591
+ this._selection.setAttribute("disabled", "");
592
+ }
593
+ }
594
+ handlerExternalCss() {
595
+ if (this.sheet) {
596
+ try {
597
+ const sheet = new CSSStyleSheet();
598
+ sheet.insertRule(this.sheet);
599
+ this._shadowDom.adoptedStyleSheets = [sheet];
600
+ } catch (error) {
601
+ console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`);
602
+ }
603
+ }
604
+ }
605
+ connectedCallback() {
606
+ this.handlerExternalCss();
607
+ this.createOption();
608
+ this.listenActionEvent();
609
+ this.listenSlotChange();
610
+ this.setShowSearch();
611
+ document.addEventListener("click", this.clickRemoveSelect);
612
+ }
613
+ disconnectCallback() {
614
+ var _a;
615
+ this.removeEventListener("mouseenter", this.selectMouseDown);
616
+ this.removeEventListener("mouseleave", this.selectBlur);
617
+ this.removeEventListener("click", this.selectMouseDown);
618
+ this.removeEventListener("blur", this.selectBlur);
619
+ this.removeSelectDropdown();
620
+ (_a = this._selectDropdown) == null ? void 0 : _a.removeEventListener("click", this.clickOption);
621
+ this.removeListenSlotChange();
622
+ document.removeEventListener("click", this.clickRemoveSelect);
623
+ }
624
+ attributeChangedCallback(name, oldValue, newValue) {
625
+ if (name === "disabled" && this._select) {
626
+ if (!newValue || newValue === "false") {
627
+ this._select.setAttribute("disabled", "");
628
+ this._selection.setAttribute("disabled", "");
629
+ } else {
630
+ this._select.removeAttribute("disabled");
631
+ this._selection.removeAttribute("disabled");
632
+ }
633
+ }
634
+ if (name === "sheet" && this._shadowDom && oldValue !== newValue) {
635
+ this.handlerExternalCss();
636
+ }
637
+ }
638
+ }
639
+ function Custom() {
640
+ if (typeof document !== "undefined" && !customElements.get("r-select")) {
641
+ customElements.define("r-select", Select);
642
+ return Select;
643
+ } else {
644
+ return createCustomError("document is undefined or r-select is exist");
645
+ }
646
+ }
647
+ const index = Custom();
648
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
649
+ __proto__: null,
650
+ Select,
651
+ default: index
652
+ }, Symbol.toStringTag, { value: "Module" }));
653
+ export {
654
+ Select as S,
655
+ index as a,
656
+ index$1 as i
657
+ };