ranui 0.1.6 → 0.1.8

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 (133) hide show
  1. package/dist/add-user-b2bed3e7.js +4 -0
  2. package/dist/book-b11a68eb.js +4 -0
  3. package/dist/build/config.d.ts +3 -0
  4. package/dist/check-circle-74bd09c3.js +4 -0
  5. package/dist/check-circle-fill-dc284144.js +4 -0
  6. package/dist/close-20925345.js +4 -0
  7. package/dist/close-circle-720c18be.js +4 -0
  8. package/dist/close-circle-fill-238a66b1.js +4 -0
  9. package/dist/components/button/index.js +4 -2
  10. package/dist/components/icon/index.js +3 -1
  11. package/dist/components/image/index.js +1 -1
  12. package/dist/components/input/index.js +2 -2
  13. package/dist/components/message/index.d.ts +12 -6
  14. package/dist/components/message/index.js +1 -2
  15. package/dist/components/modal/index.js +4 -0
  16. package/dist/components/option/index.d.ts +2 -0
  17. package/dist/components/option/index.js +95 -0
  18. package/dist/components/{video → player}/index.d.ts +198 -87
  19. package/dist/components/player/index.js +11 -0
  20. package/dist/components/preview/excel/excel.d.ts +0 -9
  21. package/dist/components/preview/index.d.ts +4 -0
  22. package/dist/components/preview/index.js +5 -4
  23. package/dist/components/progress/index.d.ts +36 -0
  24. package/dist/components/progress/index.js +8 -0
  25. package/dist/components/radar/index.js +4 -2
  26. package/dist/components/select/index.d.ts +101 -0
  27. package/dist/components/select/index.js +11 -0
  28. package/dist/components/skeleton/index.js +1 -1
  29. package/dist/components/tab/index.js +4 -2
  30. package/dist/components/tabpane/index.js +1 -1
  31. package/dist/docx-c5d02d8c.js +21 -0
  32. package/dist/eye-5e742329.js +4 -0
  33. package/dist/eye-close-3874f1ae.js +4 -0
  34. package/dist/home-c4a05e8b.js +4 -0
  35. package/dist/index-0e7229ea.js +328 -0
  36. package/dist/index-183517e7.js +265 -0
  37. package/dist/index-48653b79.js +162 -0
  38. package/dist/index-4d873a42.js +195 -0
  39. package/dist/index-57492b9b.js +48 -0
  40. package/dist/index-5975bbc0.js +126 -0
  41. package/dist/{index-64d03ac1.js → index-7b8840f9.js} +1 -4
  42. package/dist/index-7f513a14.js +175 -0
  43. package/dist/index-8e1e2573.js +19 -0
  44. package/dist/index-a1a53af6.js +354 -0
  45. package/dist/index-a216f328.js +662 -0
  46. package/dist/index-a43b144f.js +232 -0
  47. package/dist/index-aea75a9f.js +78 -0
  48. package/dist/index-b2be6bef.js +10423 -0
  49. package/dist/index-b90299ca.js +43 -0
  50. package/dist/index-d2d69b06.js +225 -0
  51. package/dist/index-ecaed5cc.js +439 -0
  52. package/dist/index-f6d6982d.js +516 -0
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.js +23 -13
  55. package/dist/info-circle-5826decc.js +4 -0
  56. package/dist/info-circle-fill-90ec9aa9.js +14 -0
  57. package/dist/loading-09ca52df.js +4 -0
  58. package/dist/lock-1d2487c9.js +4 -0
  59. package/dist/message-b2bfdea7.js +4 -0
  60. package/dist/{pdf-6e38f826.js → pdf-bdb7818a.js} +1 -2
  61. package/dist/playwright.config.d.ts +0 -2
  62. package/dist/power-off-6ade5a91.js +4 -0
  63. package/dist/preview-b291aea8.js +4 -0
  64. package/dist/setting-1e5ccb6d.js +4 -0
  65. package/dist/style.css +1 -1
  66. package/dist/team-ca6a12e1.js +4 -0
  67. package/dist/umd/build/config.d.ts +3 -0
  68. package/dist/umd/components/message/index.d.ts +12 -6
  69. package/dist/umd/components/option/index.d.ts +2 -0
  70. package/dist/umd/components/{video → player}/index.d.ts +198 -87
  71. package/dist/umd/components/preview/excel/excel.d.ts +0 -9
  72. package/dist/umd/components/preview/index.d.ts +4 -0
  73. package/dist/umd/components/progress/index.d.ts +36 -0
  74. package/dist/umd/components/select/index.d.ts +101 -0
  75. package/dist/umd/index.d.ts +4 -0
  76. package/dist/umd/index.umd.cjs +26 -8
  77. package/dist/umd/playwright.config.d.ts +0 -2
  78. package/dist/umd/style.css +1 -1
  79. package/dist/umd/utils/image.d.ts +32 -0
  80. package/dist/umd/utils/index.d.ts +41 -32
  81. package/dist/umd/utils/math.d.ts +26 -0
  82. package/dist/umd/utils/tween.d.ts +21 -0
  83. package/dist/unlock-f56086fd.js +4 -0
  84. package/dist/user-5c01e665.js +4 -0
  85. package/dist/utils/image.d.ts +32 -0
  86. package/dist/utils/index.d.ts +41 -32
  87. package/dist/utils/math.d.ts +26 -0
  88. package/dist/utils/tween.d.ts +21 -0
  89. package/dist/{index-a55c2dff.js → vendor-f71e6f68.js} +7771 -1268
  90. package/dist/warning-circle-035e025c.js +4 -0
  91. package/dist/warning-circle-fill-d17c37c9.js +4 -0
  92. package/package.json +38 -6
  93. package/readme.md +2 -3
  94. package/dist/_commonjs-dynamic-modules-2ceabb0b.js +0 -12
  95. package/dist/add-user-d07564bd.js +0 -4
  96. package/dist/assets/image/failImage.d.ts +0 -2
  97. package/dist/base-bcc748a2.js +0 -1
  98. package/dist/book-2a5a596c.js +0 -4
  99. package/dist/check-circle-2c986969.js +0 -4
  100. package/dist/check-circle-fill-62eaa796.js +0 -4
  101. package/dist/close-circle-2afb6e94.js +0 -4
  102. package/dist/close-circle-fill-b6906239.js +0 -4
  103. package/dist/close-ee3ba1d1.js +0 -4
  104. package/dist/docx-5262a8f1.js +0 -2635
  105. package/dist/eye-bd60afe1.js +0 -4
  106. package/dist/eye-close-bde3c1fc.js +0 -4
  107. package/dist/home-f824d8f4.js +0 -4
  108. package/dist/index-00913cab.js +0 -43
  109. package/dist/index-07c8e518.js +0 -327
  110. package/dist/index-105ed089.js +0 -127
  111. package/dist/index-2243317e.js +0 -155
  112. package/dist/index-441da303.js +0 -196
  113. package/dist/index-4459fbd0.js +0 -108
  114. package/dist/index-57d3be68.js +0 -450
  115. package/dist/index-a7db1b7b.js +0 -175
  116. package/dist/index-b580f377.js +0 -78
  117. package/dist/index-b99ac79f.js +0 -353
  118. package/dist/index-c558bde2.js +0 -218
  119. package/dist/info-circle-59333e1c.js +0 -4
  120. package/dist/info-circle-fill-3ab7660d.js +0 -4
  121. package/dist/jszip.min-97cf7c6a.js +0 -2655
  122. package/dist/loading-407d8249.js +0 -4
  123. package/dist/lock-6d20715b.js +0 -4
  124. package/dist/message-ee4fe153.js +0 -4
  125. package/dist/power-off-bbec6b5f.js +0 -4
  126. package/dist/preview-164a4944.js +0 -4
  127. package/dist/setting-735a1963.js +0 -4
  128. package/dist/team-42573142.js +0 -4
  129. package/dist/umd/assets/image/failImage.d.ts +0 -2
  130. package/dist/unlock-ae33c6f7.js +0 -4
  131. package/dist/user-b7098183.js +0 -4
  132. package/dist/warning-circle-536d4749.js +0 -4
  133. package/dist/warning-circle-fill-e4be98bc.js +0 -4
@@ -0,0 +1,101 @@
1
+ /// <reference types="node" />
2
+ interface Option {
3
+ label: string | number;
4
+ value: string | number;
5
+ }
6
+ export declare class Select extends HTMLElement {
7
+ removeTimeId?: NodeJS.Timeout;
8
+ _slot: HTMLSlotElement;
9
+ _shadowDom: ShadowRoot;
10
+ _select: HTMLDivElement;
11
+ _selection: HTMLDivElement;
12
+ _search: HTMLElement;
13
+ _icon: HTMLElement;
14
+ _selectDropdown?: HTMLDivElement;
15
+ _selectionDropdown?: HTMLDivElement;
16
+ _selectDropDownInTimeId?: NodeJS.Timeout;
17
+ _selectDropDownOutTimeId?: NodeJS.Timeout;
18
+ _optionList: Option[];
19
+ _optionLabelMapValue: Map<string, string>;
20
+ _optionValueMapLabel: Map<string, string>;
21
+ _activeOption?: HTMLElement;
22
+ _text: HTMLSpanElement;
23
+ _selector: HTMLDivElement;
24
+ static get observedAttributes(): string[];
25
+ constructor();
26
+ get value(): string;
27
+ set value(value: string);
28
+ get defaultValue(): string;
29
+ set defaultValue(value: string);
30
+ get showSearch(): string;
31
+ set showSearch(value: string);
32
+ get type(): string;
33
+ set type(value: string);
34
+ get placement(): string;
35
+ set placement(value: string);
36
+ get sheet(): string;
37
+ set sheet(value: string);
38
+ get getPopupContainerId(): string;
39
+ set getPopupContainerId(value: string);
40
+ get dropdownclass(): string;
41
+ set dropdownclass(value: string);
42
+ get action(): string;
43
+ set action(value: string);
44
+ get disabled(): boolean;
45
+ set disabled(value: boolean | string | undefined | null);
46
+ handlerExternalCss(): void;
47
+ /**
48
+ * @description: 移除 select dropdown
49
+ * @return {*}
50
+ */
51
+ setSelectDropdownDisplayNone: () => void;
52
+ /**
53
+ * @description: 添加 select dropdown
54
+ * @return {*}
55
+ */
56
+ setSelectDropdownDisplayBlock: () => void;
57
+ placementPosition: () => void;
58
+ /**
59
+ * @description: 设置下拉框
60
+ * @return {*}
61
+ */
62
+ selectMouseDown: () => void;
63
+ removeDropDownTimeId: () => void;
64
+ /**
65
+ * @description: 焦点移除的情况,需要移除select 下拉框
66
+ * @return {*}
67
+ */
68
+ selectBlur: () => void;
69
+ /**
70
+ * @description: 选中一个选项的情况
71
+ * @param {MouseEvent} e
72
+ * @return {*}
73
+ */
74
+ clickOption: (e: MouseEvent) => void;
75
+ /**
76
+ * @description: 初始化创建选项下拉框
77
+ * @return {*}
78
+ */
79
+ createOption: () => void;
80
+ /**
81
+ * @description: 移除选项下拉框
82
+ * @return {*}
83
+ */
84
+ removeSelectDropdown: () => void;
85
+ /**
86
+ * @description: 当select中有option元素的时候,给dropdown添加元素
87
+ * @return {*}
88
+ */
89
+ addOptionToSlot: () => void;
90
+ setDefaultValue: () => void;
91
+ changeSearch: (e: Event) => void;
92
+ setShowSearch: () => void;
93
+ listenSlotChange: () => void;
94
+ removeListenSlotChange: () => void;
95
+ listenActionEvent: () => void;
96
+ connectedCallback(): void;
97
+ disconnectCallback(): void;
98
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
99
+ }
100
+ declare const _default: import('../../utils/index').CustomErrorType;
101
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { S, a } from "../../index-f6d6982d.js";
2
+ import "../../index-d2d69b06.js";
3
+ import "../../index-57492b9b.js";
4
+ import "../option/index.js";
5
+ import "../../index-7f513a14.js";
6
+ import "../../index-ecaed5cc.js";
7
+ import "../../vendor-f71e6f68.js";
8
+ export {
9
+ S as Select,
10
+ a as default
11
+ };
@@ -1,4 +1,4 @@
1
- import { a } from "../../index-00913cab.js";
1
+ import { a } from "../../index-b90299ca.js";
2
2
  export {
3
3
  a as default
4
4
  };
@@ -1,5 +1,7 @@
1
- import { a } from "../../index-07c8e518.js";
2
- import "../../index-4459fbd0.js";
1
+ import { a } from "../../index-0e7229ea.js";
2
+ import "../../index-d2d69b06.js";
3
+ import "../../index-57492b9b.js";
4
+ import "../../vendor-f71e6f68.js";
3
5
  export {
4
6
  a as default
5
7
  };
@@ -1,4 +1,4 @@
1
- import { a } from "../../index-105ed089.js";
1
+ import { a } from "../../index-5975bbc0.js";
2
2
  export {
3
3
  a as default
4
4
  };
@@ -0,0 +1,21 @@
1
+ import { d as docxPreview_minExports } from "./vendor-f71e6f68.js";
2
+ const renderDocx = (options) => {
3
+ if (typeof window !== "undefined") {
4
+ const { bodyContainer, styleContainer, buffer, docxOptions = {} } = options;
5
+ const defaultOptions = {
6
+ className: "docx"
7
+ // ignoreLastRenderedPageBreak: false,
8
+ };
9
+ const configuration = Object.assign({}, defaultOptions, docxOptions);
10
+ if (bodyContainer) {
11
+ return docxPreview_minExports.renderAsync(buffer, bodyContainer, styleContainer, configuration);
12
+ } else {
13
+ const contain = document.createElement("div");
14
+ document.body.appendChild(contain);
15
+ return docxPreview_minExports.renderAsync(buffer, contain, styleContainer, configuration);
16
+ }
17
+ }
18
+ };
19
+ export {
20
+ renderDocx
21
+ };
@@ -0,0 +1,4 @@
1
+ const eye = { "success": true, "_identification": true, "data": '<svg t="1665473580103" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7625" width="200" height="200">\n <path d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3-7.7 16.2-7.7 35.2 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766z" p-id="7626"></path>\n <path d="M508 336c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176z m0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z" p-id="7627"></path>\n</svg>' };
2
+ export {
3
+ eye as default
4
+ };
@@ -0,0 +1,4 @@
1
+ const eyeClose = { "success": true, "_identification": true, "data": '<svg t="1665473540543" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7485" width="200" height="200">\n <path d="M942.3 486.4l-0.1-0.1-0.1-0.1c-36.4-76.7-80-138.7-130.7-186L760.7 351c43.7 40.2 81.5 93.7 114.1 160.9C791.5 684.2 673.4 766 512 766c-51.3 0-98.3-8.3-141.2-25.1l-54.7 54.7C374.6 823.8 439.8 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0.1-51.3zM878.3 154.2l-42.4-42.4c-3.1-3.1-8.2-3.1-11.3 0L707.8 228.5C649.4 200.2 584.2 186 512 186c-192.2 0-335.4 100.5-430.2 300.3v0.1c-7.7 16.2-7.7 35.2 0 51.5 36.4 76.7 80 138.7 130.7 186.1L111.8 824.5c-3.1 3.1-3.1 8.2 0 11.3l42.4 42.4c3.1 3.1 8.2 3.1 11.3 0l712.8-712.8c3.1-3 3.1-8.1 0-11.2zM398.9 537.4c-1.9-8.2-2.9-16.7-2.9-25.4 0-61.9 50.1-112 112-112 8.7 0 17.3 1 25.4 2.9L398.9 537.4z m184.5-184.5C560.5 342.1 535 336 508 336c-97.2 0-176 78.8-176 176 0 27 6.1 52.5 16.9 75.4L263.3 673c-43.7-40.2-81.5-93.7-114.1-160.9C232.6 339.8 350.7 258 512 258c51.3 0 98.3 8.3 141.2 25.1l-69.8 69.8z" p-id="7486"></path>\n <path d="M508 624c-6.4 0-12.7-0.5-18.8-1.6l-51.1 51.1c21.4 9.3 45.1 14.4 69.9 14.4 97.2 0 176-78.8 176-176 0-24.8-5.1-48.5-14.4-69.9l-51.1 51.1c1 6.1 1.6 12.4 1.6 18.8C620 573.9 569.9 624 508 624z" p-id="7487"></path>\n</svg>' };
2
+ export {
3
+ eyeClose as default
4
+ };
@@ -0,0 +1,4 @@
1
+ const home = { "success": true, "_identification": true, "data": '<svg t="1667486325771" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8988" width="200" height="200"><path d="M946.5 505L560.1 118.8l-25.9-25.9c-12.3-12.2-32.1-12.2-44.4 0L77.5 505c-12.3 12.3-18.9 28.6-18.8 46 0.4 35.2 29.7 63.3 64.9 63.3h42.5V940h691.8V614.3h43.4c17.1 0 33.2-6.7 45.3-18.8 12.1-12.1 18.7-28.2 18.7-45.3 0-17-6.7-33.1-18.8-45.2zM568 868H456V664h112v204z m217.9-325.7V868H632V640c0-22.1-17.9-40-40-40H432c-22.1 0-40 17.9-40 40v228H238.1V542.3h-96l370-369.7 23.1 23.1L882 542.3h-96.1z" p-id="8989"></path></svg>' };
2
+ export {
3
+ home as default
4
+ };
@@ -0,0 +1,328 @@
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) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { a as addClassToElement } from "./index-d2d69b06.js";
8
+ import { i as isDisabled, r as removeClassToElementChild } from "./index-57492b9b.js";
9
+ const f7170ee498e0dd32cbdcb63fba8f75cc = '.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--active-color, #1890ff)}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--line-color, #1890ff);border:solid 1px transparent;border-color:var(--border-color, rgba(0, 0, 0, .2)) var(--border-color, rgba(0, 0, 0, .2)) transparent;border-radius:var(--border-radius, .25em) var(--border-radius, .25em) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--border-color, rgba(0, 0, 0, .2))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}\n';
10
+ function CustomElement() {
11
+ if (typeof window !== "undefined" && !customElements.get("r-tabs")) {
12
+ class Tabs extends HTMLElement {
13
+ constructor() {
14
+ super();
15
+ __publicField(this, "_container");
16
+ __publicField(this, "_header");
17
+ __publicField(this, "_nav");
18
+ __publicField(this, "_line");
19
+ __publicField(this, "_content");
20
+ __publicField(this, "_wrap");
21
+ __publicField(this, "_slot");
22
+ __publicField(this, "tabHeaderKeyMapIndex");
23
+ /**
24
+ * @description: 构建tabPane组件key值和index的映射,同时判断一个tabs下的tabPane key值不能重复
25
+ * @param {string} key
26
+ * @param {number} index
27
+ */
28
+ __publicField(this, "initTabHeaderKeyMapIndex", (key, index2) => {
29
+ const value = this.tabHeaderKeyMapIndex[key];
30
+ if (value) {
31
+ throw new Error(
32
+ "tab 组件的 key 值存在重复, 或者某个 tab 组件缺少 key 属性"
33
+ );
34
+ } else {
35
+ this.tabHeaderKeyMapIndex[key] = index2;
36
+ }
37
+ });
38
+ /**
39
+ * @description: 初始化tabLine的位置,主要是当tabs的align属性为center时需要处理
40
+ */
41
+ __publicField(this, "initTabLineAlignCenter", () => {
42
+ const { length } = this._nav.children;
43
+ let left = 0;
44
+ for (let i = 0; i < length; i++) {
45
+ const { width = 0 } = this._nav.children[i].getBoundingClientRect();
46
+ left += width;
47
+ }
48
+ this._line.style.setProperty("left", `calc(50% - ${left / 2}px)`);
49
+ });
50
+ /**
51
+ * @description: 初始化tabLine的位置,主要是当tabs的align属性为end时需要处理
52
+ */
53
+ __publicField(this, "initTabLineAlignEnd", () => {
54
+ const { length } = this._nav.children;
55
+ let left = 0;
56
+ for (let i = 0; i < length; i++) {
57
+ const { width = 0 } = this._nav.children[i].getBoundingClientRect();
58
+ left += width;
59
+ }
60
+ this._line.style.setProperty("left", `calc(100% - ${left}px)`);
61
+ });
62
+ /**
63
+ * @description: 通过key值设置tabLine的位置
64
+ * @param {string} key
65
+ */
66
+ __publicField(this, "setTabLine", (key) => {
67
+ if (key) {
68
+ const index2 = this.tabHeaderKeyMapIndex[key];
69
+ const TabHeader = this._nav.children[index2];
70
+ const { width = 0 } = TabHeader.getBoundingClientRect();
71
+ this._line.style.setProperty("width", `${width}px`);
72
+ let distance = 0;
73
+ for (let i = 0; i < index2; i++) {
74
+ const item = this._nav.children[i];
75
+ const { width: width2 = 0 } = item.getBoundingClientRect();
76
+ distance += width2;
77
+ }
78
+ this._line.style.setProperty(
79
+ "transform",
80
+ `translateX(${distance}px)`
81
+ );
82
+ }
83
+ });
84
+ /**
85
+ * @description: 通过传入的key值设置tabContent
86
+ */
87
+ __publicField(this, "setTabContent", (key) => {
88
+ if (key) {
89
+ const index2 = this.tabHeaderKeyMapIndex[key];
90
+ this._wrap.style.setProperty(
91
+ "transform",
92
+ `translateX(${index2 * -100}%)`
93
+ );
94
+ }
95
+ });
96
+ /**
97
+ * @description: 根据点击设置tabLine的位置
98
+ * @param {Event} e
99
+ * @param {number} index
100
+ * @param {number} width
101
+ */
102
+ __publicField(this, "clickTabHead", (e) => {
103
+ const tabHeader = e.target;
104
+ const key = tabHeader.getAttribute("r-key");
105
+ const disabled = isDisabled(tabHeader);
106
+ if (!disabled && key) {
107
+ this.setAttribute("active", key);
108
+ this.setTabLine(key);
109
+ this.setTabContent(key);
110
+ removeClassToElementChild(this._nav, "active");
111
+ addClassToElement(tabHeader, "active");
112
+ }
113
+ });
114
+ /**
115
+ * @description: tabPane 设置属性,需要在 tabs 上展示时触发
116
+ * @param {string} key
117
+ * @param {string} value
118
+ */
119
+ __publicField(this, "updateAttribute", (key, attribute, value = "") => {
120
+ var _a, _b;
121
+ const index2 = this.tabHeaderKeyMapIndex[key];
122
+ if (key && value && this._nav.children[index2]) {
123
+ (_a = this._nav.children[index2]) == null ? void 0 : _a.setAttribute(attribute, value);
124
+ } else {
125
+ (_b = this._nav.children[index2]) == null ? void 0 : _b.removeAttribute(attribute);
126
+ }
127
+ });
128
+ /**
129
+ * @description: 初始化tabs的active属性和tabLine,tabContent
130
+ */
131
+ __publicField(this, "initActive", () => {
132
+ const tabHeaderList = [...this._nav.children];
133
+ const initTabList = tabHeaderList.filter((item) => !isDisabled(item));
134
+ let initTabHeader;
135
+ if (this.active != null) {
136
+ initTabHeader = initTabList.find(
137
+ (item) => item.getAttribute("r-key") === this.active
138
+ );
139
+ initTabHeader == null ? void 0 : initTabHeader.setAttribute("r-key", this.active);
140
+ }
141
+ if (!initTabHeader) {
142
+ initTabHeader = initTabList.shift();
143
+ }
144
+ if (!initTabHeader)
145
+ return;
146
+ const index2 = tabHeaderList.findIndex((item) => item === initTabHeader);
147
+ const key = (initTabHeader == null ? void 0 : initTabHeader.getAttribute("r-key")) || `${index2}`;
148
+ if (key != null) {
149
+ this.setAttribute("active", `${key}`);
150
+ addClassToElement(initTabHeader, "active");
151
+ this.setTabContent(key);
152
+ setTimeout(() => {
153
+ this.setTabLine(key);
154
+ }, 200);
155
+ }
156
+ });
157
+ /**
158
+ * @description: 监听slot组件的添加/删除/替换操作,进行tabs初始化
159
+ * @return {*}
160
+ */
161
+ __publicField(this, "listenSlotChange", () => {
162
+ const slots = this._slot.assignedElements();
163
+ slots.forEach((item, index2) => {
164
+ const tabPane = this.createTabHeader(item, index2);
165
+ this._nav.appendChild(tabPane);
166
+ tabPane.addEventListener("click", this.clickTabHead);
167
+ });
168
+ this.initActive();
169
+ if (this.align) {
170
+ if (this.align === "center")
171
+ this.initTabLineAlignCenter();
172
+ if (this.align === "end")
173
+ this.initTabLineAlignEnd();
174
+ }
175
+ });
176
+ /**
177
+ * @description: 初始化tab
178
+ */
179
+ __publicField(this, "initTab", () => {
180
+ this._slot.addEventListener("slotchange", this.listenSlotChange);
181
+ });
182
+ /**
183
+ * @description: 卸载tab
184
+ */
185
+ __publicField(this, "unloadTab", () => {
186
+ this._slot.removeEventListener("slotchange", this.listenSlotChange);
187
+ });
188
+ this._container = document.createElement("div");
189
+ this._container.setAttribute("class", "ran-tab");
190
+ this._header = document.createElement("div");
191
+ this._header.setAttribute("class", "ran-tab-header");
192
+ this._nav = document.createElement("div");
193
+ this._nav.setAttribute("class", "ran-tab-header-nav");
194
+ this._line = document.createElement("div");
195
+ this._line.setAttribute("class", "ran-tab-header-line");
196
+ this._content = document.createElement("div");
197
+ this._content.setAttribute("class", "ran-tab-content");
198
+ this._wrap = document.createElement("div");
199
+ this._wrap.setAttribute("class", "ran-tab-content-wrap");
200
+ this._slot = document.createElement("slot");
201
+ this._wrap.appendChild(this._slot);
202
+ this._content.appendChild(this._wrap);
203
+ this._header.appendChild(this._nav);
204
+ this._header.appendChild(this._line);
205
+ this._container.appendChild(this._header);
206
+ this._container.appendChild(this._content);
207
+ this.tabHeaderKeyMapIndex = {};
208
+ const shadowRoot = this.attachShadow({ mode: "closed" });
209
+ const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
210
+ F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
211
+ shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
212
+ shadowRoot.appendChild(this._container);
213
+ }
214
+ static get observedAttributes() {
215
+ return ["active", "forceRender", "type", "align", "effect"];
216
+ }
217
+ get align() {
218
+ return this.getAttribute("align") || "start";
219
+ }
220
+ set align(value) {
221
+ this.setAttribute("align", value);
222
+ }
223
+ set type(value) {
224
+ this.setAttribute("type", value);
225
+ }
226
+ get type() {
227
+ return this.getAttribute("type") || "flat";
228
+ }
229
+ get active() {
230
+ return this.getAttribute("active");
231
+ }
232
+ set active(value) {
233
+ if (value) {
234
+ this.setAttribute("active", value);
235
+ this.setTabLine(value);
236
+ this.setTabContent(value);
237
+ } else {
238
+ this.removeAttribute("active");
239
+ }
240
+ }
241
+ get effect() {
242
+ return this.getAttribute("effect");
243
+ }
244
+ set effect(value) {
245
+ if (!value || value === "false") {
246
+ this.removeAttribute("effect");
247
+ } else {
248
+ this.setAttribute("effect", value);
249
+ }
250
+ }
251
+ /**
252
+ * @description: 根据传入的tabPane生成tabs的头部
253
+ * @param {Element} tabPane
254
+ * @param {number} index
255
+ * @return {Element}
256
+ */
257
+ createTabHeader(tabPane, index2) {
258
+ const label = tabPane.getAttribute("label") || "";
259
+ const icon = tabPane.getAttribute("icon") || "";
260
+ const iconSize = tabPane.getAttribute("iconSize") || "";
261
+ const key = tabPane.getAttribute("r-key") || `${index2}`;
262
+ const type = tabPane.getAttribute("type") || "text";
263
+ this.initTabHeaderKeyMapIndex(key, index2);
264
+ const tabHeader = document.createElement("r-button");
265
+ tabHeader.setAttribute("class", "tab-header-nav-item");
266
+ tabHeader.setAttribute("type", type);
267
+ icon && tabHeader.setAttribute("icon", icon);
268
+ iconSize && tabHeader.setAttribute("iconSize", iconSize);
269
+ isDisabled(tabPane) && tabHeader.setAttribute("disabled", "");
270
+ tabHeader.setAttribute("r-key", key);
271
+ if (this.effect) {
272
+ tabPane.setAttribute("effect", this.effect);
273
+ this._line.style.setProperty("display", "none");
274
+ }
275
+ tabPane.setAttribute("r-key", key);
276
+ tabHeader.innerHTML = label;
277
+ return tabHeader;
278
+ }
279
+ connectedCallback() {
280
+ this.initTab();
281
+ }
282
+ disconnectCallback() {
283
+ this.unloadTab();
284
+ }
285
+ attributeChangedCallback(name, oldValue, newValue) {
286
+ if (oldValue !== newValue) {
287
+ this.dispatchEvent(
288
+ new CustomEvent("change", {
289
+ detail: {
290
+ active: this.active
291
+ }
292
+ })
293
+ );
294
+ if (name === "align") {
295
+ if (newValue === "center")
296
+ this.initTabLineAlignCenter();
297
+ if (newValue === "end")
298
+ this.initTabLineAlignEnd();
299
+ }
300
+ if (name === "effect") {
301
+ const tabHeaderList = [...this._nav.children];
302
+ tabHeaderList.forEach((item) => {
303
+ if (!this.effect || this.effect === "false") {
304
+ item.removeAttribute("effect");
305
+ } else {
306
+ item.setAttribute("effect", newValue);
307
+ }
308
+ });
309
+ }
310
+ if (name === "active") {
311
+ this.setAttribute(name, newValue);
312
+ }
313
+ }
314
+ }
315
+ }
316
+ customElements.define("r-tabs", Tabs);
317
+ return Tabs;
318
+ }
319
+ }
320
+ const index = CustomElement();
321
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
322
+ __proto__: null,
323
+ default: index
324
+ }, Symbol.toStringTag, { value: "Module" }));
325
+ export {
326
+ index as a,
327
+ index$1 as i
328
+ };