ranui 0.1.9 → 0.1.10-alpha.2
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/_commonjs-dynamic-modules-DLbDWi6a.js +12 -0
- package/dist/arrow-down-D4qr4m33.js +30 -0
- package/dist/button.js +7 -0
- package/dist/checkbox.js +7 -0
- package/dist/colorpicker.js +13 -0
- package/dist/{colz-746223ab.js → colz-CRDozfZA.js} +1 -5
- package/dist/content.js +6 -0
- package/dist/docx-CChZ5Ycr.js +3665 -0
- package/dist/global-DOOKQmNv.js +4 -0
- package/dist/icon.js +6 -0
- package/dist/iconShadowless.js +6 -0
- package/dist/image.js +4 -0
- package/dist/index-01Qfd9QI.js +207 -0
- package/dist/{index-2d16a084.js → index-B2yRe66F.js} +8 -10
- package/dist/{index-3cf72afd.js → index-B4bfIbdI.js} +9 -23
- package/dist/{index-458debf7.js → index-BF8tJ6rR.js} +7 -31
- package/dist/{index-7b8840f9.js → index-BHmWrPCW.js} +223 -1011
- package/dist/{index-e03d23e7.js → index-BpOERe9M.js} +1 -1
- package/dist/{index-e2e5d725.js → index-ByBbFhvo.js} +123 -323
- package/dist/index-C-p_Wpit.js +103 -0
- package/dist/{index-b7790662.js → index-C1x9Popy.js} +1 -1
- package/dist/index-C6wPL-2Y.js +298 -0
- package/dist/{index-1048a998.js → index-CFnsLnrb.js} +68 -19
- package/dist/{index-57492b9b.js → index-CSnBqUsQ.js} +48 -1
- package/dist/index-CWWI8SHO.js +206 -0
- package/dist/index-Cbp6LrE5.js +501 -0
- package/dist/index-CbyMC6Yz.js +59 -0
- package/dist/index-Cr9AYoGT.js +498 -0
- package/dist/index-DLB8VOy7.js +281 -0
- package/dist/index-DRWOSfdF.js +521 -0
- package/dist/{index-4443363f.js → index-DRi1ylHx.js} +29 -50
- package/dist/index-Dapt713u.js +65624 -0
- package/dist/{index-7216d6b0.js → index-DqtzBqPN.js} +11 -29
- package/dist/{index-1b73beee.js → index-DsIUhdNt.js} +55 -90
- package/dist/{index-01b17e26.js → index-Du-Biu-I.js} +1 -1
- package/dist/{index-0d5b9435.js → index-DytfjwBV.js} +2 -2
- package/dist/index.js +25 -19
- package/dist/info-circle-fill-CFeVMdci.js +4 -0
- package/dist/input.js +6 -0
- package/dist/inputShadowless.js +6 -0
- package/dist/jszip.min-DD9Dc6z4.js +2674 -0
- package/dist/loading.js +6 -0
- package/dist/message.js +5 -0
- package/dist/modal.js +4 -0
- package/dist/{components/option/index.js → option.js} +3 -6
- package/dist/{pdf-bdb7818a.js → pdf-DpNqCylD.js} +12 -4
- package/dist/player.js +8 -0
- package/dist/popover.js +6 -0
- package/dist/preview.js +7 -0
- package/dist/progress.js +7 -0
- package/dist/radar.js +6 -0
- package/dist/select.js +10 -0
- package/dist/selectShadowless.js +10 -0
- package/dist/shadowless/shadowless/index.js +14 -0
- package/dist/skeleton.js +4 -0
- package/dist/sprite-CH2zLtZy.js +141 -0
- package/dist/style.css +1 -1
- package/dist/tab.js +6 -0
- package/dist/tabpane.js +4 -0
- package/dist/tsconfig.json +29 -0
- package/dist/umd/index.umd.cjs +21 -32
- package/dist/umd/shadowless/shadowless.umd.cjs +1 -0
- package/dist/umd/shadowless/style.css +1 -0
- package/dist/umd/style.css +1 -1
- package/dist/utils-74Icp-PI.js +541 -0
- package/package.json +54 -24
- package/readme.md +18 -14
- package/typings.d.ts +101 -0
- package/dist/build/config.d.ts +0 -3
- package/dist/build/config.es.d.ts +0 -2
- package/dist/build/config.umd.d.ts +0 -2
- package/dist/components/button/index.d.ts +0 -35
- package/dist/components/button/index.js +0 -8
- package/dist/components/form/index.d.ts +0 -2
- package/dist/components/icon/index.d.ts +0 -2
- package/dist/components/icon/index.js +0 -6
- package/dist/components/image/index.d.ts +0 -2
- package/dist/components/image/index.js +0 -4
- package/dist/components/input/index.d.ts +0 -185
- package/dist/components/input/index.js +0 -6
- package/dist/components/message/index.d.ts +0 -14
- package/dist/components/message/index.js +0 -4
- package/dist/components/modal/index.d.ts +0 -2
- package/dist/components/modal/index.js +0 -4
- package/dist/components/option/index.d.ts +0 -2
- package/dist/components/player/index.d.ts +0 -213
- package/dist/components/player/index.js +0 -12
- package/dist/components/preview/colz.d.ts +0 -72
- package/dist/components/preview/docx.d.ts +0 -8
- package/dist/components/preview/excel/excel.d.ts +0 -2
- package/dist/components/preview/excel/index.d.ts +0 -1
- package/dist/components/preview/excel/media.d.ts +0 -37
- package/dist/components/preview/index.d.ts +0 -6
- package/dist/components/preview/index.js +0 -8
- package/dist/components/preview/pdf.d.ts +0 -1
- package/dist/components/preview/pptx/index.d.ts +0 -16
- package/dist/components/preview/pptx/process_pptx.d.ts +0 -23
- package/dist/components/preview/pptx/t_xml.d.ts +0 -1
- package/dist/components/preview/pptx/worker.d.ts +0 -1
- package/dist/components/progress/index.d.ts +0 -36
- package/dist/components/progress/index.js +0 -8
- package/dist/components/radar/index.d.ts +0 -2
- package/dist/components/radar/index.js +0 -7
- package/dist/components/scratch/index.d.ts +0 -19
- package/dist/components/select/index.d.ts +0 -105
- package/dist/components/select/index.js +0 -11
- package/dist/components/skeleton/index.d.ts +0 -2
- package/dist/components/skeleton/index.js +0 -4
- package/dist/components/tab/index.d.ts +0 -408
- package/dist/components/tab/index.js +0 -7
- package/dist/components/tabpane/index.d.ts +0 -352
- package/dist/components/tabpane/index.js +0 -4
- package/dist/docx-c5d02d8c.js +0 -21
- package/dist/index-73ce455b.js +0 -264
- package/dist/index-7913ec46.js +0 -239
- package/dist/index-c14450a9.js +0 -662
- package/dist/index.d.ts +0 -14
- package/dist/info-circle-fill-90ec9aa9.js +0 -14
- package/dist/playwright.config.d.ts +0 -9
- package/dist/plugins/auto-import-file.d.ts +0 -0
- package/dist/plugins/load-style.d.ts +0 -6
- package/dist/plugins/load-svg.d.ts +0 -9
- package/dist/tests/button.spec.d.ts +0 -1
- package/dist/umd/build/config.d.ts +0 -3
- package/dist/umd/build/config.es.d.ts +0 -2
- package/dist/umd/build/config.umd.d.ts +0 -2
- package/dist/umd/components/button/index.d.ts +0 -35
- package/dist/umd/components/form/index.d.ts +0 -2
- package/dist/umd/components/icon/index.d.ts +0 -2
- package/dist/umd/components/image/index.d.ts +0 -2
- package/dist/umd/components/input/index.d.ts +0 -185
- package/dist/umd/components/message/index.d.ts +0 -14
- package/dist/umd/components/modal/index.d.ts +0 -2
- package/dist/umd/components/option/index.d.ts +0 -2
- package/dist/umd/components/player/index.d.ts +0 -213
- package/dist/umd/components/preview/colz.d.ts +0 -72
- package/dist/umd/components/preview/docx.d.ts +0 -8
- package/dist/umd/components/preview/excel/excel.d.ts +0 -2
- package/dist/umd/components/preview/excel/index.d.ts +0 -1
- package/dist/umd/components/preview/excel/media.d.ts +0 -37
- package/dist/umd/components/preview/index.d.ts +0 -6
- package/dist/umd/components/preview/pdf.d.ts +0 -1
- package/dist/umd/components/preview/pptx/index.d.ts +0 -16
- package/dist/umd/components/preview/pptx/process_pptx.d.ts +0 -23
- package/dist/umd/components/preview/pptx/t_xml.d.ts +0 -1
- package/dist/umd/components/preview/pptx/worker.d.ts +0 -1
- package/dist/umd/components/progress/index.d.ts +0 -36
- package/dist/umd/components/radar/index.d.ts +0 -2
- package/dist/umd/components/scratch/index.d.ts +0 -19
- package/dist/umd/components/select/index.d.ts +0 -105
- package/dist/umd/components/skeleton/index.d.ts +0 -2
- package/dist/umd/components/tab/index.d.ts +0 -408
- package/dist/umd/components/tabpane/index.d.ts +0 -352
- package/dist/umd/index.d.ts +0 -14
- package/dist/umd/playwright.config.d.ts +0 -9
- package/dist/umd/plugins/auto-import-file.d.ts +0 -0
- package/dist/umd/plugins/load-style.d.ts +0 -6
- package/dist/umd/plugins/load-svg.d.ts +0 -9
- package/dist/umd/tests/button.spec.d.ts +0 -1
- package/dist/umd/utils/image.d.ts +0 -32
- package/dist/umd/utils/index.d.ts +0 -64
- package/dist/umd/utils/math.d.ts +0 -26
- package/dist/umd/utils/tween.d.ts +0 -21
- package/dist/umd/vite.config.d.ts +0 -6
- package/dist/utils/image.d.ts +0 -32
- package/dist/utils/index.d.ts +0 -64
- package/dist/utils/math.d.ts +0 -26
- package/dist/utils/tween.d.ts +0 -21
- package/dist/vendor-f71e6f68.js +0 -92126
- package/dist/vite.config.d.ts +0 -6
- /package/dist/{add-user-b2bed3e7.js → add-user-BN1JlY7e.js} +0 -0
- /package/dist/{book-b11a68eb.js → book-nTEFXU2x.js} +0 -0
- /package/dist/{check-circle-fill-dc284144.js → check-circle-fill-B_pd8ZSs.js} +0 -0
- /package/dist/{check-circle-74bd09c3.js → check-circle-szyAJiap.js} +0 -0
- /package/dist/{close-20925345.js → close-CFnkhudp.js} +0 -0
- /package/dist/{close-circle-720c18be.js → close-circle-CwmuN2C6.js} +0 -0
- /package/dist/{close-circle-fill-238a66b1.js → close-circle-fill-jSqPPw9i.js} +0 -0
- /package/dist/{eye-5e742329.js → eye-D_mEt17f.js} +0 -0
- /package/dist/{eye-close-3874f1ae.js → eye-close-BVr3NJtg.js} +0 -0
- /package/dist/{home-c4a05e8b.js → home-BUQ4USMk.js} +0 -0
- /package/dist/{index-8e1e2573.js → index-CQTJoWhb.js} +0 -0
- /package/dist/{info-circle-5826decc.js → info-circle-COnL5bTJ.js} +0 -0
- /package/dist/{loading-09ca52df.js → loading-Dcc5RApI.js} +0 -0
- /package/dist/{lock-1d2487c9.js → lock-Cr7BnmWN.js} +0 -0
- /package/dist/{message-b2bfdea7.js → message-D36_Zo2l.js} +0 -0
- /package/dist/{power-off-6ade5a91.js → power-off-lQRbiBak.js} +0 -0
- /package/dist/{preview-b291aea8.js → preview-CJbz9GjO.js} +0 -0
- /package/dist/{setting-1e5ccb6d.js → setting-DemlgzVC.js} +0 -0
- /package/dist/{team-ca6a12e1.js → team-tl4NJXPC.js} +0 -0
- /package/dist/{unlock-f56086fd.js → unlock-CeU74z9n.js} +0 -0
- /package/dist/{user-5c01e665.js → user-B-eVXwuk.js} +0 -0
- /package/dist/{warning-circle-035e025c.js → warning-circle-DDUgEDIv.js} +0 -0
- /package/dist/{warning-circle-fill-d17c37c9.js → warning-circle-fill-lODUKz0i.js} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
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 { H as HTMLElementSSR, c as createCustomError } from "./index-CSnBqUsQ.js";
|
|
8
|
+
class Content extends HTMLElementSSR() {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
__publicField(this, "observer");
|
|
12
|
+
__publicField(this, "callback", (mutations, observer) => {
|
|
13
|
+
for (const mutation of mutations) {
|
|
14
|
+
if (mutation.type === "childList") {
|
|
15
|
+
this.onChange(mutation);
|
|
16
|
+
} else if (mutation.type === "attributes") {
|
|
17
|
+
this.onChange(mutation);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
__publicField(this, "onChange", (mutation) => {
|
|
22
|
+
this.dispatchEvent(
|
|
23
|
+
new CustomEvent("change", {
|
|
24
|
+
detail: {
|
|
25
|
+
type: mutation.type,
|
|
26
|
+
value: { content: this.children, mutation }
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
this.observer = new MutationObserver(this.callback);
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
this.setAttribute("class", "ran-content");
|
|
35
|
+
this.observer.observe(this, { attributes: true, childList: true, subtree: true });
|
|
36
|
+
}
|
|
37
|
+
disconnectCallback() {
|
|
38
|
+
this.observer.disconnect();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function Custom() {
|
|
42
|
+
if (typeof document !== "undefined" && !customElements.get("r-content")) {
|
|
43
|
+
customElements.define("r-content", Content);
|
|
44
|
+
return Content;
|
|
45
|
+
} else {
|
|
46
|
+
return createCustomError("document is undefined or r-content is exist");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const index = Custom();
|
|
50
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
51
|
+
__proto__: null,
|
|
52
|
+
Content,
|
|
53
|
+
default: index
|
|
54
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
55
|
+
export {
|
|
56
|
+
Content as C,
|
|
57
|
+
index as a,
|
|
58
|
+
index$1 as i
|
|
59
|
+
};
|
|
@@ -0,0 +1,498 @@
|
|
|
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, i as isMobile, d as generateThrottle } from "./utils-74Icp-PI.js";
|
|
8
|
+
import { H as HTMLElementSSR, i as isDisabled, c as createCustomError } from "./index-CSnBqUsQ.js";
|
|
9
|
+
import "./option.js";
|
|
10
|
+
import "./index-DqtzBqPN.js";
|
|
11
|
+
import "./index-CFnsLnrb.js";
|
|
12
|
+
const placementDirection = {
|
|
13
|
+
bottom: {
|
|
14
|
+
add: "ran-select-dropdown-down-in",
|
|
15
|
+
remove: "ran-select-dropdown-down-out"
|
|
16
|
+
},
|
|
17
|
+
top: {
|
|
18
|
+
add: "ran-select-dropdown-up-in",
|
|
19
|
+
remove: "ran-select-dropdown-up-out"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const searchThrottle = generateThrottle();
|
|
23
|
+
class Select extends HTMLElementSSR() {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
__publicField(this, "removeTimeId");
|
|
27
|
+
__publicField(this, "_select");
|
|
28
|
+
__publicField(this, "_selection");
|
|
29
|
+
__publicField(this, "_search");
|
|
30
|
+
__publicField(this, "_icon");
|
|
31
|
+
__publicField(this, "_selectDropdown");
|
|
32
|
+
__publicField(this, "_selectionDropdown");
|
|
33
|
+
__publicField(this, "_selectDropDownInTimeId");
|
|
34
|
+
__publicField(this, "_selectDropDownOutTimeId");
|
|
35
|
+
__publicField(this, "_optionList");
|
|
36
|
+
__publicField(this, "_optionLabelMapValue");
|
|
37
|
+
__publicField(this, "_optionValueMapLabel");
|
|
38
|
+
__publicField(this, "_activeOption");
|
|
39
|
+
__publicField(this, "_text");
|
|
40
|
+
__publicField(this, "_selector");
|
|
41
|
+
__publicField(this, "onSearch");
|
|
42
|
+
/**
|
|
43
|
+
* @description: 移除 select dropdown
|
|
44
|
+
* @return {*}
|
|
45
|
+
*/
|
|
46
|
+
__publicField(this, "setSelectDropdownDisplayNone", () => {
|
|
47
|
+
if (this._selectDropDownOutTimeId)
|
|
48
|
+
return;
|
|
49
|
+
if (this._selectionDropdown && this._selectionDropdown.style.display !== "none") {
|
|
50
|
+
addClassToElement(this._selectionDropdown, placementDirection[this.placement].remove);
|
|
51
|
+
this._selectDropDownOutTimeId = setTimeout(() => {
|
|
52
|
+
var _a;
|
|
53
|
+
(_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "none");
|
|
54
|
+
this._selectionDropdown && removeClassToElement(this._selectionDropdown, placementDirection[this.placement].remove);
|
|
55
|
+
clearTimeout(this._selectDropDownOutTimeId);
|
|
56
|
+
this._selectDropDownOutTimeId = void 0;
|
|
57
|
+
}, 300);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* @description: 添加 select dropdown
|
|
62
|
+
* @return {*}
|
|
63
|
+
*/
|
|
64
|
+
__publicField(this, "setSelectDropdownDisplayBlock", () => {
|
|
65
|
+
var _a;
|
|
66
|
+
if (this._selectDropDownInTimeId)
|
|
67
|
+
return;
|
|
68
|
+
if (this._selectionDropdown && this._selectionDropdown.style.display !== "block") {
|
|
69
|
+
addClassToElement(this._selectionDropdown, placementDirection[this.placement].add);
|
|
70
|
+
(_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "block");
|
|
71
|
+
this._selectDropDownInTimeId = setTimeout(() => {
|
|
72
|
+
this._selectionDropdown && removeClassToElement(this._selectionDropdown, placementDirection[this.placement].add);
|
|
73
|
+
clearTimeout(this._selectDropDownInTimeId);
|
|
74
|
+
this._selectDropDownInTimeId = void 0;
|
|
75
|
+
}, 200);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
__publicField(this, "placementPosition", () => {
|
|
79
|
+
if (!this._selectionDropdown || !this._selectDropdown)
|
|
80
|
+
return;
|
|
81
|
+
const rect = this.getBoundingClientRect();
|
|
82
|
+
const { top, left, bottom, width, height, x, y, right } = rect;
|
|
83
|
+
const root = document.getElementById(this.getPopupContainerId);
|
|
84
|
+
this._selectionDropdown.style.setProperty("--ran-x", `${top + window.scrollX}`);
|
|
85
|
+
this._selectionDropdown.style.setProperty("--ran-y", `${left + window.scrollY}`);
|
|
86
|
+
let selectTop = bottom + window.scrollY;
|
|
87
|
+
let selectLeft = left + window.scrollX;
|
|
88
|
+
this._selectionDropdown.style.setProperty("width", `${width}px`);
|
|
89
|
+
if (this.placement === "top") {
|
|
90
|
+
selectTop = top + window.scrollY - this._selectionDropdown.clientHeight;
|
|
91
|
+
}
|
|
92
|
+
if (this.getPopupContainerId && root) {
|
|
93
|
+
if (this.placement === "top") {
|
|
94
|
+
selectTop = top - root.getBoundingClientRect().top - this._selectionDropdown.clientHeight;
|
|
95
|
+
} else {
|
|
96
|
+
selectTop = root.getBoundingClientRect().height;
|
|
97
|
+
}
|
|
98
|
+
selectLeft = 0;
|
|
99
|
+
}
|
|
100
|
+
this._selectionDropdown.style.setProperty("inset", `${selectTop}px auto auto ${selectLeft}px`);
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* @description: 设置下拉框
|
|
104
|
+
* @return {*}
|
|
105
|
+
*/
|
|
106
|
+
__publicField(this, "selectMouseDown", (e) => {
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
if (isDisabled(this))
|
|
109
|
+
return;
|
|
110
|
+
this.removeDropDownTimeId();
|
|
111
|
+
this.setSelectDropdownDisplayNone();
|
|
112
|
+
this.setSelectDropdownDisplayBlock();
|
|
113
|
+
this.placementPosition();
|
|
114
|
+
});
|
|
115
|
+
__publicField(this, "removeDropDownTimeId", () => {
|
|
116
|
+
this._search.setAttribute("value", "");
|
|
117
|
+
if (this.trigger.includes("hover") && !isMobile()) {
|
|
118
|
+
clearTimeout(this.removeTimeId);
|
|
119
|
+
this.removeTimeId = void 0;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
/**
|
|
123
|
+
* @description: 焦点移除的情况,需要移除select 下拉框
|
|
124
|
+
* @return {*}
|
|
125
|
+
*/
|
|
126
|
+
__publicField(this, "selectBlur", () => {
|
|
127
|
+
if (this.removeTimeId) {
|
|
128
|
+
this.removeDropDownTimeId();
|
|
129
|
+
}
|
|
130
|
+
this.removeTimeId = setTimeout(() => {
|
|
131
|
+
this.removeDropDownTimeId();
|
|
132
|
+
this.setSelectDropdownDisplayNone();
|
|
133
|
+
}, 100);
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* @description: 选中一个选项的情况
|
|
137
|
+
* @param {MouseEvent} e
|
|
138
|
+
* @return {*}
|
|
139
|
+
*/
|
|
140
|
+
__publicField(this, "clickOption", (e) => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
let element = e.target;
|
|
144
|
+
if ((_a = element.classList) == null ? void 0 : _a.contains("ranui-select-dropdown-option-item")) {
|
|
145
|
+
element = element.children[0];
|
|
146
|
+
}
|
|
147
|
+
if (!((_b = element.classList) == null ? void 0 : _b.contains("ranui-select-dropdown-option-item-content")))
|
|
148
|
+
return;
|
|
149
|
+
const label = element.innerHTML;
|
|
150
|
+
const value = this._optionLabelMapValue.get(label);
|
|
151
|
+
if (value) {
|
|
152
|
+
this.setAttribute("value", value);
|
|
153
|
+
this._text.innerHTML = label;
|
|
154
|
+
this._text.setAttribute("title", label);
|
|
155
|
+
this._search.setAttribute("placeholder", label);
|
|
156
|
+
}
|
|
157
|
+
const rect = this.getBoundingClientRect();
|
|
158
|
+
const { height } = rect;
|
|
159
|
+
this._text.style.setProperty("line-height", `${height}px`);
|
|
160
|
+
if (this._activeOption) {
|
|
161
|
+
removeClassToElement(this._activeOption, "ranui-select-dropdown-option-active");
|
|
162
|
+
}
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
this._activeOption = (element == null ? void 0 : element.parentElement) || void 0;
|
|
165
|
+
if (this._activeOption) {
|
|
166
|
+
addClassToElement(this._activeOption, "ranui-select-dropdown-option-active");
|
|
167
|
+
}
|
|
168
|
+
}, 200);
|
|
169
|
+
this.setSelectDropdownDisplayNone();
|
|
170
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { value, label } }));
|
|
171
|
+
this.removeDropDownTimeId();
|
|
172
|
+
});
|
|
173
|
+
/**
|
|
174
|
+
* @description: 初始化创建选项下拉框
|
|
175
|
+
* @return {*}
|
|
176
|
+
*/
|
|
177
|
+
__publicField(this, "createOption", () => {
|
|
178
|
+
if (!this._selectDropdown) {
|
|
179
|
+
this.appendChild(this._select);
|
|
180
|
+
const container = document.getElementById(this.getPopupContainerId) || document.body;
|
|
181
|
+
this._selectDropdown = document.createElement("div");
|
|
182
|
+
this._selectDropdown.style.setProperty("-webkit-tap-highlight-color", "transparent");
|
|
183
|
+
this._selectDropdown.style.setProperty("outline", "0");
|
|
184
|
+
this._selectDropdown.addEventListener("click", this.clickOption);
|
|
185
|
+
this._selectionDropdown = document.createElement("div");
|
|
186
|
+
this._selectionDropdown.style.setProperty("-webkit-tap-highlight-color", "transparent");
|
|
187
|
+
this._selectionDropdown.style.setProperty("outline", "0");
|
|
188
|
+
if (this.dropdownclass) {
|
|
189
|
+
this._selectionDropdown.setAttribute("class", `${this.dropdownclass} ranui-select-dropdown`);
|
|
190
|
+
} else {
|
|
191
|
+
this._selectionDropdown.setAttribute("class", "ranui-select-dropdown");
|
|
192
|
+
}
|
|
193
|
+
if (this.trigger.includes("hover") && !isMobile()) {
|
|
194
|
+
this._selectDropdown.addEventListener("mouseleave", this.selectBlur);
|
|
195
|
+
this._selectDropdown.addEventListener("mouseenter", this.removeDropDownTimeId);
|
|
196
|
+
}
|
|
197
|
+
this._selectDropdown.appendChild(this._selectionDropdown);
|
|
198
|
+
this._selectionDropdown.style.setProperty("display", "none");
|
|
199
|
+
container.appendChild(this._selectDropdown);
|
|
200
|
+
}
|
|
201
|
+
this.addOptionToSlot();
|
|
202
|
+
});
|
|
203
|
+
/**
|
|
204
|
+
* @description: 移除选项下拉框
|
|
205
|
+
* @return {*}
|
|
206
|
+
*/
|
|
207
|
+
__publicField(this, "removeSelectDropdown", () => {
|
|
208
|
+
try {
|
|
209
|
+
if (this._selectDropdown) {
|
|
210
|
+
const container = document.getElementById(this.getPopupContainerId) || document.body;
|
|
211
|
+
container.removeChild(this._selectDropdown);
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* @description: 当select中有option元素的时候,给dropdown添加元素
|
|
218
|
+
* @return {*}
|
|
219
|
+
*/
|
|
220
|
+
__publicField(this, "addOptionToSlot", () => {
|
|
221
|
+
var _a;
|
|
222
|
+
const child = this.children || [];
|
|
223
|
+
this._optionList = [];
|
|
224
|
+
for (const item of child) {
|
|
225
|
+
if (item.tagName === "R-OPTION") {
|
|
226
|
+
const label = item.innerHTML;
|
|
227
|
+
const value = item.getAttribute("value") || "";
|
|
228
|
+
(_a = this._optionList) == null ? void 0 : _a.push({ label, value });
|
|
229
|
+
this._optionLabelMapValue.set(label, value);
|
|
230
|
+
this._optionValueMapLabel.set(value, label);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
this.createSelectDropdownContent(this._optionList);
|
|
234
|
+
});
|
|
235
|
+
__publicField(this, "createSelectDropdownContent", (options = []) => {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
if (options.length === 0) {
|
|
238
|
+
(_a = this._selectDropdown) == null ? void 0 : _a.style.setProperty("display", "none");
|
|
239
|
+
} else {
|
|
240
|
+
(_b = this._selectDropdown) == null ? void 0 : _b.style.setProperty("display", "block");
|
|
241
|
+
}
|
|
242
|
+
if (this._selectionDropdown) {
|
|
243
|
+
this._selectionDropdown.innerHTML = "";
|
|
244
|
+
}
|
|
245
|
+
options.forEach((item) => {
|
|
246
|
+
if (this._selectionDropdown) {
|
|
247
|
+
const { label, value } = item;
|
|
248
|
+
const selectOptionItem = document.createElement("div");
|
|
249
|
+
const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
|
|
250
|
+
if (defaultValue === value) {
|
|
251
|
+
selectOptionItem.setAttribute(
|
|
252
|
+
"class",
|
|
253
|
+
"ranui-select-dropdown-option-active ranui-select-dropdown-option-item"
|
|
254
|
+
);
|
|
255
|
+
this._activeOption = selectOptionItem;
|
|
256
|
+
} else {
|
|
257
|
+
selectOptionItem.setAttribute("class", "ranui-select-dropdown-option-item");
|
|
258
|
+
}
|
|
259
|
+
const selectOptionItemContent = document.createElement("div");
|
|
260
|
+
selectOptionItemContent.setAttribute("class", "ranui-select-dropdown-option-item-content");
|
|
261
|
+
selectOptionItemContent.innerHTML = `${label}`;
|
|
262
|
+
selectOptionItemContent.setAttribute("value", `${value}`);
|
|
263
|
+
selectOptionItemContent.setAttribute("title", `${label}`);
|
|
264
|
+
selectOptionItem.appendChild(selectOptionItemContent);
|
|
265
|
+
this._selectionDropdown.appendChild(selectOptionItem);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
this.setDefaultValue();
|
|
269
|
+
});
|
|
270
|
+
__publicField(this, "setDefaultValue", () => {
|
|
271
|
+
const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
|
|
272
|
+
if (!defaultValue)
|
|
273
|
+
return;
|
|
274
|
+
const label = this._optionValueMapLabel.get(defaultValue);
|
|
275
|
+
if (!label)
|
|
276
|
+
return;
|
|
277
|
+
this.setAttribute("value", defaultValue);
|
|
278
|
+
const rect = this.getBoundingClientRect();
|
|
279
|
+
const { height } = rect;
|
|
280
|
+
this._text.style.setProperty("line-height", `${height}px`);
|
|
281
|
+
this._text.innerHTML = label;
|
|
282
|
+
this._text.setAttribute("title", label);
|
|
283
|
+
});
|
|
284
|
+
__publicField(this, "changeSearch", (e) => {
|
|
285
|
+
const value = e.detail.value || "";
|
|
286
|
+
this.dispatchEvent(
|
|
287
|
+
new CustomEvent("search", {
|
|
288
|
+
detail: { value }
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
if (this._selectionDropdown) {
|
|
292
|
+
this._selectionDropdown.innerHTML = "";
|
|
293
|
+
}
|
|
294
|
+
if (value.length > 0) {
|
|
295
|
+
const options = this._optionList.map((item) => {
|
|
296
|
+
const { label } = item;
|
|
297
|
+
if (`${label}`.toLowerCase().includes(value)) {
|
|
298
|
+
return { label, value: item.value };
|
|
299
|
+
}
|
|
300
|
+
return void 0;
|
|
301
|
+
}).filter((item) => item);
|
|
302
|
+
this.createSelectDropdownContent(options);
|
|
303
|
+
} else {
|
|
304
|
+
this.createSelectDropdownContent(this._optionList);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
__publicField(this, "setShowSearch", () => {
|
|
308
|
+
this.onSearch = searchThrottle(this.changeSearch);
|
|
309
|
+
this.onSearch && this._search.addEventListener("change", this.onSearch);
|
|
310
|
+
this.onSearch && this._search.addEventListener("click", this.onSearch);
|
|
311
|
+
});
|
|
312
|
+
__publicField(this, "removeShowSearch", () => {
|
|
313
|
+
this.onSearch && this._search.removeEventListener("change", this.onSearch);
|
|
314
|
+
this.onSearch && this._search.removeEventListener("click", this.onSearch);
|
|
315
|
+
});
|
|
316
|
+
__publicField(this, "listenActionEvent", () => {
|
|
317
|
+
this.removeEventListener("mouseenter", this.selectMouseDown);
|
|
318
|
+
this.removeEventListener("mouseleave", this.selectBlur);
|
|
319
|
+
this.removeEventListener("click", this.selectMouseDown);
|
|
320
|
+
this.removeEventListener("blur", this.selectBlur);
|
|
321
|
+
if (this.trigger.includes("hover") && !isMobile()) {
|
|
322
|
+
this.addEventListener("mouseenter", this.selectMouseDown);
|
|
323
|
+
this.addEventListener("mouseleave", this.selectBlur);
|
|
324
|
+
}
|
|
325
|
+
if (this.trigger.includes("click")) {
|
|
326
|
+
this.addEventListener("click", this.selectMouseDown);
|
|
327
|
+
this.addEventListener("blur", this.selectBlur);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
__publicField(this, "clickRemoveSelect", (e) => {
|
|
331
|
+
e.stopPropagation();
|
|
332
|
+
this.setSelectDropdownDisplayNone();
|
|
333
|
+
});
|
|
334
|
+
this._select = document.createElement("div");
|
|
335
|
+
this._select.setAttribute("class", "ran-select");
|
|
336
|
+
this._select.setAttribute("part", "select");
|
|
337
|
+
this._selection = document.createElement("div");
|
|
338
|
+
this._selection.setAttribute("class", "selection");
|
|
339
|
+
this._selection.setAttribute("part", "selection");
|
|
340
|
+
this._selector = document.createElement("div");
|
|
341
|
+
this._search = document.createElement("ra-input");
|
|
342
|
+
this._search.setAttribute("class", "selection-search");
|
|
343
|
+
this._search.setAttribute("part", "search");
|
|
344
|
+
this._search.setAttribute("type", "search");
|
|
345
|
+
this._search.setAttribute("autocomplete", "off");
|
|
346
|
+
this._text = document.createElement("span");
|
|
347
|
+
this._text.setAttribute("class", "selection-item");
|
|
348
|
+
this._text.setAttribute("part", "selection-item");
|
|
349
|
+
this._icon = document.createElement("ra-icon");
|
|
350
|
+
this._icon.setAttribute("class", "icon");
|
|
351
|
+
this._icon.setAttribute("part", "icon");
|
|
352
|
+
this._icon.setAttribute("name", "arrow-down");
|
|
353
|
+
this._icon.setAttribute("color", "#d9d9d9");
|
|
354
|
+
this._icon.setAttribute("size", "16");
|
|
355
|
+
this._selector.appendChild(this._text);
|
|
356
|
+
this._selector.appendChild(this._search);
|
|
357
|
+
this._selection.appendChild(this._icon);
|
|
358
|
+
this._selection.appendChild(this._selector);
|
|
359
|
+
this._select.appendChild(this._selection);
|
|
360
|
+
this._optionList = [];
|
|
361
|
+
this._optionLabelMapValue = /* @__PURE__ */ new Map();
|
|
362
|
+
this._optionValueMapLabel = /* @__PURE__ */ new Map();
|
|
363
|
+
}
|
|
364
|
+
static get observedAttributes() {
|
|
365
|
+
return [
|
|
366
|
+
"disabled",
|
|
367
|
+
"sheet",
|
|
368
|
+
"clear",
|
|
369
|
+
"type",
|
|
370
|
+
"defaultValue",
|
|
371
|
+
"showSearch",
|
|
372
|
+
"placement",
|
|
373
|
+
// 弹窗的方向
|
|
374
|
+
"getPopupContainerId",
|
|
375
|
+
// 挂载的节点
|
|
376
|
+
"dropdownclass",
|
|
377
|
+
// 弹窗的类名
|
|
378
|
+
"trigger"
|
|
379
|
+
// 触发下拉框的行为, click 还是 hover ,hover 在 isMobile 移动端无效
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
get value() {
|
|
383
|
+
return this.getAttribute("value") || "";
|
|
384
|
+
}
|
|
385
|
+
set value(value) {
|
|
386
|
+
if (!isDisabled(this) && value) {
|
|
387
|
+
this.setAttribute("value", value);
|
|
388
|
+
} else {
|
|
389
|
+
this.removeAttribute("value");
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
get defaultValue() {
|
|
393
|
+
return this.getAttribute("defaultValue") || "";
|
|
394
|
+
}
|
|
395
|
+
set defaultValue(value) {
|
|
396
|
+
this.setAttribute("defaultValue", value || "");
|
|
397
|
+
}
|
|
398
|
+
get showSearch() {
|
|
399
|
+
return this.getAttribute("showSearch") || "";
|
|
400
|
+
}
|
|
401
|
+
set showSearch(value) {
|
|
402
|
+
this.setAttribute("showSearch", value || "");
|
|
403
|
+
}
|
|
404
|
+
get type() {
|
|
405
|
+
return this.getAttribute("type") || "";
|
|
406
|
+
}
|
|
407
|
+
set type(value) {
|
|
408
|
+
this.setAttribute("type", value || "");
|
|
409
|
+
}
|
|
410
|
+
get placement() {
|
|
411
|
+
return this.getAttribute("placement") || "bottom";
|
|
412
|
+
}
|
|
413
|
+
set placement(value) {
|
|
414
|
+
this.setAttribute("placement", value || "");
|
|
415
|
+
}
|
|
416
|
+
get sheet() {
|
|
417
|
+
return this.getAttribute("sheet") || "";
|
|
418
|
+
}
|
|
419
|
+
set sheet(value) {
|
|
420
|
+
this.setAttribute("sheet", value || "");
|
|
421
|
+
}
|
|
422
|
+
get getPopupContainerId() {
|
|
423
|
+
return this.getAttribute("getPopupContainerId") || "";
|
|
424
|
+
}
|
|
425
|
+
set getPopupContainerId(value) {
|
|
426
|
+
this.setAttribute("getPopupContainerId", value || "");
|
|
427
|
+
}
|
|
428
|
+
get dropdownclass() {
|
|
429
|
+
return this.getAttribute("dropdownclass") || "";
|
|
430
|
+
}
|
|
431
|
+
set dropdownclass(value) {
|
|
432
|
+
this.setAttribute("dropdownclass", value || "");
|
|
433
|
+
}
|
|
434
|
+
get trigger() {
|
|
435
|
+
return this.getAttribute("trigger") || "click";
|
|
436
|
+
}
|
|
437
|
+
set trigger(value) {
|
|
438
|
+
this.setAttribute("trigger", value || "");
|
|
439
|
+
}
|
|
440
|
+
get disabled() {
|
|
441
|
+
return isDisabled(this);
|
|
442
|
+
}
|
|
443
|
+
set disabled(value) {
|
|
444
|
+
if (!value || value === "false") {
|
|
445
|
+
this.removeAttribute("disabled");
|
|
446
|
+
this._selection.removeAttribute("disabled");
|
|
447
|
+
} else {
|
|
448
|
+
this.setAttribute("disabled", "");
|
|
449
|
+
this._selection.setAttribute("disabled", "");
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
connectedCallback() {
|
|
453
|
+
this.createOption();
|
|
454
|
+
this.listenActionEvent();
|
|
455
|
+
this.setShowSearch();
|
|
456
|
+
document.addEventListener("click", this.clickRemoveSelect);
|
|
457
|
+
}
|
|
458
|
+
disconnectCallback() {
|
|
459
|
+
var _a;
|
|
460
|
+
this.removeEventListener("mouseenter", this.selectMouseDown);
|
|
461
|
+
this.removeEventListener("mouseleave", this.selectBlur);
|
|
462
|
+
this.removeEventListener("click", this.selectMouseDown);
|
|
463
|
+
this.removeEventListener("blur", this.selectBlur);
|
|
464
|
+
this.removeSelectDropdown();
|
|
465
|
+
(_a = this._selectDropdown) == null ? void 0 : _a.removeEventListener("click", this.clickOption);
|
|
466
|
+
document.removeEventListener("click", this.clickRemoveSelect);
|
|
467
|
+
}
|
|
468
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
469
|
+
if (name === "disabled" && this._select) {
|
|
470
|
+
if (!newValue || newValue === "false") {
|
|
471
|
+
this._select.setAttribute("disabled", "");
|
|
472
|
+
this._selection.setAttribute("disabled", "");
|
|
473
|
+
} else {
|
|
474
|
+
this._select.removeAttribute("disabled");
|
|
475
|
+
this._selection.removeAttribute("disabled");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function Custom() {
|
|
481
|
+
if (typeof document !== "undefined" && !customElements.get("ra-select")) {
|
|
482
|
+
customElements.define("ra-select", Select);
|
|
483
|
+
return Select;
|
|
484
|
+
} else {
|
|
485
|
+
return createCustomError("document is undefined or ra-select is exist");
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const index = Custom();
|
|
489
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
490
|
+
__proto__: null,
|
|
491
|
+
Select,
|
|
492
|
+
default: index
|
|
493
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
494
|
+
export {
|
|
495
|
+
Select as S,
|
|
496
|
+
index as a,
|
|
497
|
+
index$1 as i
|
|
498
|
+
};
|