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.
- package/dist/add-user-b2bed3e7.js +4 -0
- package/dist/book-b11a68eb.js +4 -0
- package/dist/build/config.d.ts +3 -0
- package/dist/check-circle-74bd09c3.js +4 -0
- package/dist/check-circle-fill-dc284144.js +4 -0
- package/dist/close-20925345.js +4 -0
- package/dist/close-circle-720c18be.js +4 -0
- package/dist/close-circle-fill-238a66b1.js +4 -0
- package/dist/components/button/index.js +4 -2
- package/dist/components/icon/index.js +3 -1
- package/dist/components/image/index.js +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/message/index.d.ts +12 -6
- package/dist/components/message/index.js +1 -2
- package/dist/components/modal/index.js +4 -0
- package/dist/components/option/index.d.ts +2 -0
- package/dist/components/option/index.js +95 -0
- package/dist/components/{video → player}/index.d.ts +198 -87
- package/dist/components/player/index.js +11 -0
- package/dist/components/preview/excel/excel.d.ts +0 -9
- package/dist/components/preview/index.d.ts +4 -0
- package/dist/components/preview/index.js +5 -4
- package/dist/components/progress/index.d.ts +36 -0
- package/dist/components/progress/index.js +8 -0
- package/dist/components/radar/index.js +4 -2
- package/dist/components/select/index.d.ts +101 -0
- package/dist/components/select/index.js +11 -0
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/tab/index.js +4 -2
- package/dist/components/tabpane/index.js +1 -1
- package/dist/docx-c5d02d8c.js +21 -0
- package/dist/eye-5e742329.js +4 -0
- package/dist/eye-close-3874f1ae.js +4 -0
- package/dist/home-c4a05e8b.js +4 -0
- package/dist/index-0e7229ea.js +328 -0
- package/dist/index-183517e7.js +265 -0
- package/dist/index-48653b79.js +162 -0
- package/dist/index-4d873a42.js +195 -0
- package/dist/index-57492b9b.js +48 -0
- package/dist/index-5975bbc0.js +126 -0
- package/dist/{index-64d03ac1.js → index-7b8840f9.js} +1 -4
- package/dist/index-7f513a14.js +175 -0
- package/dist/index-8e1e2573.js +19 -0
- package/dist/index-a1a53af6.js +354 -0
- package/dist/index-a216f328.js +662 -0
- package/dist/index-a43b144f.js +232 -0
- package/dist/index-aea75a9f.js +78 -0
- package/dist/index-b2be6bef.js +10423 -0
- package/dist/index-b90299ca.js +43 -0
- package/dist/index-d2d69b06.js +225 -0
- package/dist/index-ecaed5cc.js +439 -0
- package/dist/index-f6d6982d.js +516 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -13
- package/dist/info-circle-5826decc.js +4 -0
- package/dist/info-circle-fill-90ec9aa9.js +14 -0
- package/dist/loading-09ca52df.js +4 -0
- package/dist/lock-1d2487c9.js +4 -0
- package/dist/message-b2bfdea7.js +4 -0
- package/dist/{pdf-6e38f826.js → pdf-bdb7818a.js} +1 -2
- package/dist/playwright.config.d.ts +0 -2
- package/dist/power-off-6ade5a91.js +4 -0
- package/dist/preview-b291aea8.js +4 -0
- package/dist/setting-1e5ccb6d.js +4 -0
- package/dist/style.css +1 -1
- package/dist/team-ca6a12e1.js +4 -0
- package/dist/umd/build/config.d.ts +3 -0
- package/dist/umd/components/message/index.d.ts +12 -6
- package/dist/umd/components/option/index.d.ts +2 -0
- package/dist/umd/components/{video → player}/index.d.ts +198 -87
- package/dist/umd/components/preview/excel/excel.d.ts +0 -9
- package/dist/umd/components/preview/index.d.ts +4 -0
- package/dist/umd/components/progress/index.d.ts +36 -0
- package/dist/umd/components/select/index.d.ts +101 -0
- package/dist/umd/index.d.ts +4 -0
- package/dist/umd/index.umd.cjs +26 -8
- package/dist/umd/playwright.config.d.ts +0 -2
- package/dist/umd/style.css +1 -1
- package/dist/umd/utils/image.d.ts +32 -0
- package/dist/umd/utils/index.d.ts +41 -32
- package/dist/umd/utils/math.d.ts +26 -0
- package/dist/umd/utils/tween.d.ts +21 -0
- package/dist/unlock-f56086fd.js +4 -0
- package/dist/user-5c01e665.js +4 -0
- package/dist/utils/image.d.ts +32 -0
- package/dist/utils/index.d.ts +41 -32
- package/dist/utils/math.d.ts +26 -0
- package/dist/utils/tween.d.ts +21 -0
- package/dist/{index-a55c2dff.js → vendor-f71e6f68.js} +7771 -1268
- package/dist/warning-circle-035e025c.js +4 -0
- package/dist/warning-circle-fill-d17c37c9.js +4 -0
- package/package.json +38 -6
- package/readme.md +2 -3
- package/dist/_commonjs-dynamic-modules-2ceabb0b.js +0 -12
- package/dist/add-user-d07564bd.js +0 -4
- package/dist/assets/image/failImage.d.ts +0 -2
- package/dist/base-bcc748a2.js +0 -1
- package/dist/book-2a5a596c.js +0 -4
- package/dist/check-circle-2c986969.js +0 -4
- package/dist/check-circle-fill-62eaa796.js +0 -4
- package/dist/close-circle-2afb6e94.js +0 -4
- package/dist/close-circle-fill-b6906239.js +0 -4
- package/dist/close-ee3ba1d1.js +0 -4
- package/dist/docx-5262a8f1.js +0 -2635
- package/dist/eye-bd60afe1.js +0 -4
- package/dist/eye-close-bde3c1fc.js +0 -4
- package/dist/home-f824d8f4.js +0 -4
- package/dist/index-00913cab.js +0 -43
- package/dist/index-07c8e518.js +0 -327
- package/dist/index-105ed089.js +0 -127
- package/dist/index-2243317e.js +0 -155
- package/dist/index-441da303.js +0 -196
- package/dist/index-4459fbd0.js +0 -108
- package/dist/index-57d3be68.js +0 -450
- package/dist/index-a7db1b7b.js +0 -175
- package/dist/index-b580f377.js +0 -78
- package/dist/index-b99ac79f.js +0 -353
- package/dist/index-c558bde2.js +0 -218
- package/dist/info-circle-59333e1c.js +0 -4
- package/dist/info-circle-fill-3ab7660d.js +0 -4
- package/dist/jszip.min-97cf7c6a.js +0 -2655
- package/dist/loading-407d8249.js +0 -4
- package/dist/lock-6d20715b.js +0 -4
- package/dist/message-ee4fe153.js +0 -4
- package/dist/power-off-bbec6b5f.js +0 -4
- package/dist/preview-164a4944.js +0 -4
- package/dist/setting-735a1963.js +0 -4
- package/dist/team-42573142.js +0 -4
- package/dist/umd/assets/image/failImage.d.ts +0 -2
- package/dist/unlock-ae33c6f7.js +0 -4
- package/dist/user-b7098183.js +0 -4
- package/dist/warning-circle-536d4749.js +0 -4
- package/dist/warning-circle-fill-e4be98bc.js +0 -4
|
@@ -0,0 +1,516 @@
|
|
|
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, r as removeClassToElement } from "./index-d2d69b06.js";
|
|
8
|
+
import { i as isDisabled, c as createCustomError } from "./index-57492b9b.js";
|
|
9
|
+
import "./components/option/index.js";
|
|
10
|
+
import "./index-7f513a14.js";
|
|
11
|
+
import "./index-ecaed5cc.js";
|
|
12
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc = ':host{position:relative;display:inline-block;cursor:pointer;height:32px}:host ::slotted(r-option){display:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host([type="text"])::part(selection){border:none}:host([type="text"])::part(icon){display:none}:host(:not([disabled]):hover) .select{cursor:pointer}:host(:not([disabled]):hover) .selection{border:1px solid #1890ff}:host(:not([disabled]):hover) .selection-search{cursor:pointer}:host(:not([disabled]):hover) .selection-item{cursor:pointer;color:#bfbfbf}:host(:not([disabled]):focus) .selection{border:1px solid #1890ff}:host(:not([disabled]):focus) .selection-search{cursor:pointer}:host(:not([disabled]):focus) .selection-item{cursor:pointer;color:#bfbfbf}:host .selection-search{display:none}:host([showSearch]:not([disabled])) .selection-search{cursor:text;display:block}:host([showSearch]:not([disabled])) .selection-item{cursor:pointer}:host([showSearch]:not([disabled]):focus) .selection-search{display:block;cursor:text;opacity:1}.ran-select{width:100%;height:100%;box-sizing:border-box;margin:0;padding:0;color:#000000e0;font-size:14px;line-height:1.57142857;list-style:none;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:relative;display:inline-block}.ran-select .selection{position:relative;background-color:#fff;border:1px solid #d9d9d9;transition:all .2s cubic-bezier(.645,.045,.355,1);width:100%;height:100%;padding:0 11px;box-sizing:border-box;margin:0;color:#000000e0;font-size:14px;line-height:1.57142857;list-style:none;font-family:inherit;display:flex;border-radius:6px}.ran-select .selection-search{position:absolute;top:0;left:0;height:100%;inset-inline-start:11px;inset-inline-end:11px;opacity:0;margin:0;padding:0;background:transparent;border:none;outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;font-family:inherit;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:absolute;top:0;left:12px;margin:0;padding:0;background:transparent;border:none;outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;font-family:inherit;height:100%;-webkit-user-select:none;user-select:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:pointer}.ran-select .selection-select{color:#00000040}.ran-select .selection .icon{display:flex;align-items:center;color:#00000040;font-style:normal;text-align:center;text-transform:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:absolute;top:50%;inset-inline-start:auto;inset-inline-end:8px;height:12px;margin-top:-3px;font-size:12px;pointer-events:none}\n';
|
|
13
|
+
const placementDirection = {
|
|
14
|
+
bottom: {
|
|
15
|
+
add: "ran-select-dropdown-down-in",
|
|
16
|
+
remove: "ran-select-dropdown-down-out"
|
|
17
|
+
},
|
|
18
|
+
top: {
|
|
19
|
+
add: "ran-select-dropdown-up-in",
|
|
20
|
+
remove: "ran-select-dropdown-up-out"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
class Select extends HTMLElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
__publicField(this, "removeTimeId");
|
|
27
|
+
__publicField(this, "_slot");
|
|
28
|
+
__publicField(this, "_shadowDom");
|
|
29
|
+
__publicField(this, "_select");
|
|
30
|
+
__publicField(this, "_selection");
|
|
31
|
+
__publicField(this, "_search");
|
|
32
|
+
__publicField(this, "_icon");
|
|
33
|
+
__publicField(this, "_selectDropdown");
|
|
34
|
+
__publicField(this, "_selectionDropdown");
|
|
35
|
+
__publicField(this, "_selectDropDownInTimeId");
|
|
36
|
+
__publicField(this, "_selectDropDownOutTimeId");
|
|
37
|
+
__publicField(this, "_optionList");
|
|
38
|
+
__publicField(this, "_optionLabelMapValue");
|
|
39
|
+
__publicField(this, "_optionValueMapLabel");
|
|
40
|
+
__publicField(this, "_activeOption");
|
|
41
|
+
__publicField(this, "_text");
|
|
42
|
+
__publicField(this, "_selector");
|
|
43
|
+
/**
|
|
44
|
+
* @description: 移除 select dropdown
|
|
45
|
+
* @return {*}
|
|
46
|
+
*/
|
|
47
|
+
__publicField(this, "setSelectDropdownDisplayNone", () => {
|
|
48
|
+
if (this._selectDropDownOutTimeId)
|
|
49
|
+
return;
|
|
50
|
+
if (this._selectionDropdown && this._selectionDropdown.style.display !== "none") {
|
|
51
|
+
addClassToElement(
|
|
52
|
+
this._selectionDropdown,
|
|
53
|
+
placementDirection[this.placement].remove
|
|
54
|
+
);
|
|
55
|
+
this._selectDropDownOutTimeId = setTimeout(() => {
|
|
56
|
+
var _a;
|
|
57
|
+
(_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "none");
|
|
58
|
+
this._selectionDropdown && removeClassToElement(
|
|
59
|
+
this._selectionDropdown,
|
|
60
|
+
placementDirection[this.placement].remove
|
|
61
|
+
);
|
|
62
|
+
clearTimeout(this._selectDropDownOutTimeId);
|
|
63
|
+
this._selectDropDownOutTimeId = void 0;
|
|
64
|
+
}, 300);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* @description: 添加 select dropdown
|
|
69
|
+
* @return {*}
|
|
70
|
+
*/
|
|
71
|
+
__publicField(this, "setSelectDropdownDisplayBlock", () => {
|
|
72
|
+
var _a;
|
|
73
|
+
if (this._selectDropDownInTimeId)
|
|
74
|
+
return;
|
|
75
|
+
if (this._selectionDropdown && this._selectionDropdown.style.display !== "block") {
|
|
76
|
+
addClassToElement(
|
|
77
|
+
this._selectionDropdown,
|
|
78
|
+
placementDirection[this.placement].add
|
|
79
|
+
);
|
|
80
|
+
(_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "block");
|
|
81
|
+
this._selectDropDownInTimeId = setTimeout(() => {
|
|
82
|
+
this._selectionDropdown && removeClassToElement(
|
|
83
|
+
this._selectionDropdown,
|
|
84
|
+
placementDirection[this.placement].add
|
|
85
|
+
);
|
|
86
|
+
clearTimeout(this._selectDropDownInTimeId);
|
|
87
|
+
this._selectDropDownInTimeId = void 0;
|
|
88
|
+
}, 200);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
__publicField(this, "placementPosition", () => {
|
|
92
|
+
if (!this._selectionDropdown || !this._selectDropdown)
|
|
93
|
+
return;
|
|
94
|
+
const rect = this.getBoundingClientRect();
|
|
95
|
+
const { top, left, bottom, width, height, x, y, right } = rect;
|
|
96
|
+
this._selectionDropdown.style.setProperty(
|
|
97
|
+
"-ran-x",
|
|
98
|
+
`${x + window.scrollX}`
|
|
99
|
+
);
|
|
100
|
+
this._selectionDropdown.style.setProperty(
|
|
101
|
+
"-ran-y",
|
|
102
|
+
`${y + window.scrollY}`
|
|
103
|
+
);
|
|
104
|
+
let selectTop = bottom + window.scrollY;
|
|
105
|
+
let selectLeft = left + window.scrollX;
|
|
106
|
+
this._selectionDropdown.style.setProperty("width", `${width}px`);
|
|
107
|
+
const root = document.getElementById(this.getPopupContainerId);
|
|
108
|
+
if (this.placement === "top") {
|
|
109
|
+
selectTop = top + window.scrollY - this._selectionDropdown.clientHeight;
|
|
110
|
+
if (this.getPopupContainerId && root) {
|
|
111
|
+
selectTop = top - root.getBoundingClientRect().top - this._selectionDropdown.clientHeight;
|
|
112
|
+
selectLeft = left - root.getBoundingClientRect().left;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this._selectionDropdown.style.setProperty(
|
|
116
|
+
"inset",
|
|
117
|
+
`${selectTop}px auto auto ${selectLeft}px`
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* @description: 设置下拉框
|
|
122
|
+
* @return {*}
|
|
123
|
+
*/
|
|
124
|
+
__publicField(this, "selectMouseDown", () => {
|
|
125
|
+
if (isDisabled(this))
|
|
126
|
+
return;
|
|
127
|
+
this.removeDropDownTimeId();
|
|
128
|
+
this.setSelectDropdownDisplayNone();
|
|
129
|
+
this.setSelectDropdownDisplayBlock();
|
|
130
|
+
this.placementPosition();
|
|
131
|
+
});
|
|
132
|
+
__publicField(this, "removeDropDownTimeId", () => {
|
|
133
|
+
if (this.action.includes("hover")) {
|
|
134
|
+
clearTimeout(this.removeTimeId);
|
|
135
|
+
this.removeTimeId = void 0;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* @description: 焦点移除的情况,需要移除select 下拉框
|
|
140
|
+
* @return {*}
|
|
141
|
+
*/
|
|
142
|
+
__publicField(this, "selectBlur", () => {
|
|
143
|
+
if (this.removeTimeId) {
|
|
144
|
+
this.removeDropDownTimeId();
|
|
145
|
+
}
|
|
146
|
+
this.removeTimeId = setTimeout(() => {
|
|
147
|
+
this.removeDropDownTimeId();
|
|
148
|
+
this.setSelectDropdownDisplayNone();
|
|
149
|
+
}, 300);
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* @description: 选中一个选项的情况
|
|
153
|
+
* @param {MouseEvent} e
|
|
154
|
+
* @return {*}
|
|
155
|
+
*/
|
|
156
|
+
__publicField(this, "clickOption", (e) => {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
let element = e.target;
|
|
159
|
+
if ((_a = element.classList) == null ? void 0 : _a.contains("ranui-select-dropdown-option-item")) {
|
|
160
|
+
element = element.children[0];
|
|
161
|
+
}
|
|
162
|
+
if (!((_b = element.classList) == null ? void 0 : _b.contains("ranui-select-dropdown-option-item-content")))
|
|
163
|
+
return;
|
|
164
|
+
const label = element.innerHTML;
|
|
165
|
+
const value = this._optionLabelMapValue.get(label);
|
|
166
|
+
if (value) {
|
|
167
|
+
this.setAttribute("value", value);
|
|
168
|
+
this._text.innerHTML = label;
|
|
169
|
+
this._text.setAttribute("title", label);
|
|
170
|
+
this._search.setAttribute("placeholder", label);
|
|
171
|
+
}
|
|
172
|
+
if (this._activeOption) {
|
|
173
|
+
removeClassToElement(
|
|
174
|
+
this._activeOption,
|
|
175
|
+
"ranui-select-dropdown-option-active"
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
this._activeOption = (element == null ? void 0 : element.parentElement) || void 0;
|
|
180
|
+
if (this._activeOption) {
|
|
181
|
+
addClassToElement(
|
|
182
|
+
this._activeOption,
|
|
183
|
+
"ranui-select-dropdown-option-active"
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}, 200);
|
|
187
|
+
this.setSelectDropdownDisplayNone();
|
|
188
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { value, label } }));
|
|
189
|
+
this.removeDropDownTimeId();
|
|
190
|
+
});
|
|
191
|
+
/**
|
|
192
|
+
* @description: 初始化创建选项下拉框
|
|
193
|
+
* @return {*}
|
|
194
|
+
*/
|
|
195
|
+
__publicField(this, "createOption", () => {
|
|
196
|
+
if (!this._selectDropdown) {
|
|
197
|
+
const container = document.getElementById(this.getPopupContainerId) || document.body;
|
|
198
|
+
this._selectDropdown = document.createElement("div");
|
|
199
|
+
this._selectDropdown.addEventListener("click", this.clickOption);
|
|
200
|
+
this._selectionDropdown = document.createElement("div");
|
|
201
|
+
if (this.dropdownclass) {
|
|
202
|
+
this._selectionDropdown.setAttribute(
|
|
203
|
+
"class",
|
|
204
|
+
`${this.dropdownclass} ranui-select-dropdown`
|
|
205
|
+
);
|
|
206
|
+
} else {
|
|
207
|
+
this._selectionDropdown.setAttribute("class", "ranui-select-dropdown");
|
|
208
|
+
}
|
|
209
|
+
if (this.action.includes("hover")) {
|
|
210
|
+
this._selectDropdown.addEventListener("mouseleave", this.selectBlur);
|
|
211
|
+
this._selectDropdown.addEventListener(
|
|
212
|
+
"mouseenter",
|
|
213
|
+
this.removeDropDownTimeId
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
this._selectDropdown.appendChild(this._selectionDropdown);
|
|
217
|
+
this._selectionDropdown.style.setProperty("display", "none");
|
|
218
|
+
container.appendChild(this._selectDropdown);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
/**
|
|
222
|
+
* @description: 移除选项下拉框
|
|
223
|
+
* @return {*}
|
|
224
|
+
*/
|
|
225
|
+
__publicField(this, "removeSelectDropdown", () => {
|
|
226
|
+
try {
|
|
227
|
+
if (this._selectDropdown) {
|
|
228
|
+
const container = document.getElementById(this.getPopupContainerId) || document.body;
|
|
229
|
+
container.removeChild(this._selectDropdown);
|
|
230
|
+
}
|
|
231
|
+
} catch (error) {
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* @description: 当select中有option元素的时候,给dropdown添加元素
|
|
236
|
+
* @return {*}
|
|
237
|
+
*/
|
|
238
|
+
__publicField(this, "addOptionToSlot", () => {
|
|
239
|
+
const slots = this._slot.assignedElements();
|
|
240
|
+
slots.forEach((item) => {
|
|
241
|
+
var _a;
|
|
242
|
+
if (item.tagName !== "R-OPTION")
|
|
243
|
+
return;
|
|
244
|
+
const label = item.innerHTML;
|
|
245
|
+
const value = item.getAttribute("value") || "";
|
|
246
|
+
(_a = this._optionList) == null ? void 0 : _a.push({ label, value });
|
|
247
|
+
if (this._optionLabelMapValue.get(label)) {
|
|
248
|
+
console.warn(`${label} is repeat option`);
|
|
249
|
+
}
|
|
250
|
+
if (this._optionValueMapLabel.get(value)) {
|
|
251
|
+
console.warn(`${value} is repeat option`);
|
|
252
|
+
}
|
|
253
|
+
this._optionLabelMapValue.set(label, value);
|
|
254
|
+
this._optionValueMapLabel.set(value, label);
|
|
255
|
+
});
|
|
256
|
+
this._optionList.forEach((item) => {
|
|
257
|
+
if (this._selectionDropdown) {
|
|
258
|
+
const { label, value } = item;
|
|
259
|
+
const selectOptionItem = document.createElement("div");
|
|
260
|
+
const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
|
|
261
|
+
if (defaultValue === value) {
|
|
262
|
+
selectOptionItem.setAttribute(
|
|
263
|
+
"class",
|
|
264
|
+
"ranui-select-dropdown-option-active ranui-select-dropdown-option-item"
|
|
265
|
+
);
|
|
266
|
+
this._activeOption = selectOptionItem;
|
|
267
|
+
} else {
|
|
268
|
+
selectOptionItem.setAttribute(
|
|
269
|
+
"class",
|
|
270
|
+
"ranui-select-dropdown-option-item"
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
const selectOptionItemContent = document.createElement("div");
|
|
274
|
+
selectOptionItemContent.setAttribute(
|
|
275
|
+
"class",
|
|
276
|
+
"ranui-select-dropdown-option-item-content"
|
|
277
|
+
);
|
|
278
|
+
selectOptionItemContent.innerHTML = `${label}`;
|
|
279
|
+
selectOptionItemContent.setAttribute("value", `${value}`);
|
|
280
|
+
selectOptionItemContent.setAttribute("title", `${label}`);
|
|
281
|
+
selectOptionItem.appendChild(selectOptionItemContent);
|
|
282
|
+
this._selectionDropdown.appendChild(selectOptionItem);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
this.setDefaultValue();
|
|
286
|
+
});
|
|
287
|
+
__publicField(this, "setDefaultValue", () => {
|
|
288
|
+
const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
|
|
289
|
+
if (!defaultValue)
|
|
290
|
+
return;
|
|
291
|
+
const label = this._optionValueMapLabel.get(defaultValue);
|
|
292
|
+
if (!label)
|
|
293
|
+
return;
|
|
294
|
+
this.setAttribute("value", defaultValue);
|
|
295
|
+
const rect = this.getBoundingClientRect();
|
|
296
|
+
const { height } = rect;
|
|
297
|
+
this._text.style.setProperty("line-height", `${height}px`);
|
|
298
|
+
this._text.innerHTML = label;
|
|
299
|
+
this._text.setAttribute("title", label);
|
|
300
|
+
});
|
|
301
|
+
__publicField(this, "changeSearch", (e) => {
|
|
302
|
+
});
|
|
303
|
+
__publicField(this, "setShowSearch", () => {
|
|
304
|
+
this._search.addEventListener("change", this.changeSearch);
|
|
305
|
+
});
|
|
306
|
+
__publicField(this, "listenSlotChange", () => {
|
|
307
|
+
this._slot.addEventListener("slotchange", this.addOptionToSlot);
|
|
308
|
+
});
|
|
309
|
+
__publicField(this, "removeListenSlotChange", () => {
|
|
310
|
+
this._slot.removeEventListener("slotchange", this.addOptionToSlot);
|
|
311
|
+
});
|
|
312
|
+
__publicField(this, "listenActionEvent", () => {
|
|
313
|
+
this.removeEventListener("mouseenter", this.selectMouseDown);
|
|
314
|
+
this.removeEventListener("mouseleave", this.selectBlur);
|
|
315
|
+
this.removeEventListener("mousedown", this.selectMouseDown);
|
|
316
|
+
this.removeEventListener("blur", this.selectBlur);
|
|
317
|
+
if (this.action.includes("hover")) {
|
|
318
|
+
this.addEventListener("mouseenter", this.selectMouseDown);
|
|
319
|
+
this.addEventListener("mouseleave", this.selectBlur);
|
|
320
|
+
}
|
|
321
|
+
if (this.action.includes("click")) {
|
|
322
|
+
this.addEventListener("mousedown", this.selectMouseDown);
|
|
323
|
+
this.addEventListener("blur", this.selectBlur);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
this._slot = document.createElement("slot");
|
|
327
|
+
this._select = document.createElement("div");
|
|
328
|
+
this._select.setAttribute("class", "ran-select");
|
|
329
|
+
this._select.setAttribute("part", "select");
|
|
330
|
+
this._selection = document.createElement("div");
|
|
331
|
+
this._selection.setAttribute("class", "selection");
|
|
332
|
+
this._selection.setAttribute("part", "selection");
|
|
333
|
+
this._selector = document.createElement("div");
|
|
334
|
+
this._search = document.createElement("r-input");
|
|
335
|
+
this._search.setAttribute("class", "selection-search");
|
|
336
|
+
this._search.setAttribute("part", "search");
|
|
337
|
+
this._search.setAttribute("type", "search");
|
|
338
|
+
this._search.setAttribute("autocomplete", "off");
|
|
339
|
+
this._text = document.createElement("span");
|
|
340
|
+
this._text.setAttribute("class", "selection-item");
|
|
341
|
+
this._text.setAttribute("part", "selection-item");
|
|
342
|
+
this._icon = document.createElement("r-icon");
|
|
343
|
+
this._icon.setAttribute("class", "icon");
|
|
344
|
+
this._icon.setAttribute("part", "icon");
|
|
345
|
+
this._icon.setAttribute("name", "arrow-down");
|
|
346
|
+
this._icon.setAttribute("color", "#d9d9d9");
|
|
347
|
+
this._icon.setAttribute("size", "16");
|
|
348
|
+
this._selector.appendChild(this._text);
|
|
349
|
+
this._selector.appendChild(this._search);
|
|
350
|
+
this._selection.appendChild(this._icon);
|
|
351
|
+
this._selection.appendChild(this._selector);
|
|
352
|
+
this._slot.setAttribute("class", "slot");
|
|
353
|
+
this._select.appendChild(this._selection);
|
|
354
|
+
this._select.appendChild(this._slot);
|
|
355
|
+
this._optionList = [];
|
|
356
|
+
this._optionLabelMapValue = /* @__PURE__ */ new Map();
|
|
357
|
+
this._optionValueMapLabel = /* @__PURE__ */ new Map();
|
|
358
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
359
|
+
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
360
|
+
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
|
|
361
|
+
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
362
|
+
this._shadowDom = shadowRoot;
|
|
363
|
+
shadowRoot.appendChild(this._select);
|
|
364
|
+
}
|
|
365
|
+
static get observedAttributes() {
|
|
366
|
+
return [
|
|
367
|
+
"disabled",
|
|
368
|
+
"sheet",
|
|
369
|
+
"clear",
|
|
370
|
+
"type",
|
|
371
|
+
"defaultValue",
|
|
372
|
+
"showSearch",
|
|
373
|
+
"placement",
|
|
374
|
+
// 弹窗的方向
|
|
375
|
+
"getPopupContainerId",
|
|
376
|
+
// 挂载的节点
|
|
377
|
+
"dropdownclass",
|
|
378
|
+
// 弹窗的类名
|
|
379
|
+
"action"
|
|
380
|
+
// 触发下拉框的行为,click还是hover
|
|
381
|
+
];
|
|
382
|
+
}
|
|
383
|
+
get value() {
|
|
384
|
+
return this.getAttribute("value") || "";
|
|
385
|
+
}
|
|
386
|
+
set value(value) {
|
|
387
|
+
if (!isDisabled(this) && value) {
|
|
388
|
+
this.setAttribute("value", value);
|
|
389
|
+
} else {
|
|
390
|
+
this.removeAttribute("value");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
get defaultValue() {
|
|
394
|
+
return this.getAttribute("defaultValue") || "";
|
|
395
|
+
}
|
|
396
|
+
set defaultValue(value) {
|
|
397
|
+
this.setAttribute("defaultValue", value || "");
|
|
398
|
+
}
|
|
399
|
+
get showSearch() {
|
|
400
|
+
return this.getAttribute("showSearch") || "";
|
|
401
|
+
}
|
|
402
|
+
set showSearch(value) {
|
|
403
|
+
this.setAttribute("showSearch", value || "");
|
|
404
|
+
}
|
|
405
|
+
get type() {
|
|
406
|
+
return this.getAttribute("type") || "";
|
|
407
|
+
}
|
|
408
|
+
set type(value) {
|
|
409
|
+
this.setAttribute("type", value || "");
|
|
410
|
+
}
|
|
411
|
+
get placement() {
|
|
412
|
+
return this.getAttribute("placement") || "bottom";
|
|
413
|
+
}
|
|
414
|
+
set placement(value) {
|
|
415
|
+
this.setAttribute("placement", value || "");
|
|
416
|
+
}
|
|
417
|
+
get sheet() {
|
|
418
|
+
return this.getAttribute("sheet") || "";
|
|
419
|
+
}
|
|
420
|
+
set sheet(value) {
|
|
421
|
+
this.setAttribute("sheet", value || "");
|
|
422
|
+
}
|
|
423
|
+
get getPopupContainerId() {
|
|
424
|
+
return this.getAttribute("getPopupContainerId") || "";
|
|
425
|
+
}
|
|
426
|
+
set getPopupContainerId(value) {
|
|
427
|
+
this.setAttribute("getPopupContainerId", value || "");
|
|
428
|
+
}
|
|
429
|
+
get dropdownclass() {
|
|
430
|
+
return this.getAttribute("dropdownclass") || "";
|
|
431
|
+
}
|
|
432
|
+
set dropdownclass(value) {
|
|
433
|
+
this.setAttribute("dropdownclass", value || "");
|
|
434
|
+
}
|
|
435
|
+
get action() {
|
|
436
|
+
return this.getAttribute("action") || "click";
|
|
437
|
+
}
|
|
438
|
+
set action(value) {
|
|
439
|
+
this.setAttribute("action", value || "");
|
|
440
|
+
}
|
|
441
|
+
get disabled() {
|
|
442
|
+
return isDisabled(this);
|
|
443
|
+
}
|
|
444
|
+
set disabled(value) {
|
|
445
|
+
if (!value || value === "false") {
|
|
446
|
+
this.removeAttribute("disabled");
|
|
447
|
+
this._selection.removeAttribute("disabled");
|
|
448
|
+
} else {
|
|
449
|
+
this.setAttribute("disabled", "");
|
|
450
|
+
this._selection.setAttribute("disabled", "");
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
handlerExternalCss() {
|
|
454
|
+
if (this.sheet) {
|
|
455
|
+
try {
|
|
456
|
+
const sheet = new CSSStyleSheet();
|
|
457
|
+
sheet.insertRule(this.sheet);
|
|
458
|
+
this._shadowDom.adoptedStyleSheets = [sheet];
|
|
459
|
+
} catch (error) {
|
|
460
|
+
console.error(
|
|
461
|
+
`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
connectedCallback() {
|
|
467
|
+
this.handlerExternalCss();
|
|
468
|
+
this.createOption();
|
|
469
|
+
this.listenActionEvent();
|
|
470
|
+
this.listenSlotChange();
|
|
471
|
+
this.setShowSearch();
|
|
472
|
+
}
|
|
473
|
+
disconnectCallback() {
|
|
474
|
+
var _a;
|
|
475
|
+
this.removeEventListener("mouseenter", this.selectMouseDown);
|
|
476
|
+
this.removeEventListener("mouseleave", this.selectBlur);
|
|
477
|
+
this.removeEventListener("mousedown", this.selectMouseDown);
|
|
478
|
+
this.removeEventListener("blur", this.selectBlur);
|
|
479
|
+
this.removeSelectDropdown();
|
|
480
|
+
(_a = this._selectDropdown) == null ? void 0 : _a.removeEventListener("click", this.clickOption);
|
|
481
|
+
this.removeListenSlotChange();
|
|
482
|
+
}
|
|
483
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
484
|
+
if (name === "disabled" && this._select) {
|
|
485
|
+
if (!newValue || newValue === "false") {
|
|
486
|
+
this._select.setAttribute("disabled", "");
|
|
487
|
+
this._selection.setAttribute("disabled", "");
|
|
488
|
+
} else {
|
|
489
|
+
this._select.removeAttribute("disabled");
|
|
490
|
+
this._selection.removeAttribute("disabled");
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (name === "sheet" && this._shadowDom && oldValue !== newValue) {
|
|
494
|
+
this.handlerExternalCss();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function Custom() {
|
|
499
|
+
if (typeof document !== "undefined" && !customElements.get("r-select")) {
|
|
500
|
+
customElements.define("r-select", Select);
|
|
501
|
+
return Select;
|
|
502
|
+
} else {
|
|
503
|
+
return createCustomError("document is undefined or r-select is exist");
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
const index = Custom();
|
|
507
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
508
|
+
__proto__: null,
|
|
509
|
+
Select,
|
|
510
|
+
default: index
|
|
511
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
512
|
+
export {
|
|
513
|
+
Select as S,
|
|
514
|
+
index as a,
|
|
515
|
+
index$1 as i
|
|
516
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -8,3 +8,7 @@ export * as skeleton from './components/skeleton';
|
|
|
8
8
|
export * as tabpane from './components/tabpane';
|
|
9
9
|
export * as tab from './components/tab';
|
|
10
10
|
export * as radar from './components/radar';
|
|
11
|
+
export * as player from './components/player';
|
|
12
|
+
export * as modal from './components/modal';
|
|
13
|
+
export * as select from './components/select';
|
|
14
|
+
export * as progress from './components/progress';
|