ranui 0.1.9 → 0.1.10-alpha.1
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-C9jBUUt3.js +30 -0
- package/dist/assets/image/failImage.d.ts +2 -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/components/button/index.d.ts +7 -3
- package/dist/components/checkbox/index.d.ts +27 -0
- package/dist/components/colorpicker/index.d.ts +122 -0
- package/dist/components/content/index.d.ts +15 -0
- package/dist/components/input/index.d.ts +65 -41
- package/dist/components/message/index.d.ts +2 -0
- package/dist/components/option/index.d.ts +2 -1
- package/dist/components/player/index.d.ts +31 -6
- package/dist/components/popover/index.d.ts +39 -0
- package/dist/components/preview/docx.d.ts +1 -1
- package/dist/components/preview/index.d.ts +2 -0
- package/dist/components/preview/pptx/process_pptx.d.ts +1 -1
- package/dist/components/progress/index.d.ts +11 -5
- package/dist/components/radar/index.d.ts +1 -1
- package/dist/components/scratch/index.d.ts +5 -1
- package/dist/components/select/index.d.ts +15 -7
- package/dist/content.js +6 -0
- package/dist/docx-ajDUtnbM.js +3665 -0
- package/dist/global-DOfcrQ2N.js +4 -0
- package/dist/icon.js +6 -0
- package/dist/iconShadowless.js +6 -0
- package/dist/image.js +4 -0
- package/dist/index-0fvHQjmN.js +298 -0
- package/dist/{index-1b73beee.js → index-BLepXisd.js} +55 -90
- package/dist/{index-e2e5d725.js → index-BOoNI-Al.js} +113 -305
- package/dist/{index-2d16a084.js → index-BPBRPxND.js} +8 -10
- package/dist/{index-e03d23e7.js → index-BpOERe9M.js} +1 -1
- package/dist/index-Bv6Z6rIe.js +498 -0
- package/dist/index-ByJ7zZdQ.js +65641 -0
- package/dist/{index-b7790662.js → index-C1x9Popy.js} +1 -1
- package/dist/index-CCNK5H8T.js +103 -0
- package/dist/{index-458debf7.js → index-CD09p_mF.js} +7 -31
- package/dist/{index-1048a998.js → index-CFnsLnrb.js} +68 -19
- package/dist/{index-4443363f.js → index-CJZp9lE4.js} +29 -50
- package/dist/{index-57492b9b.js → index-CSnBqUsQ.js} +48 -1
- package/dist/index-CWWI8SHO.js +206 -0
- package/dist/{index-7b8840f9.js → index-CZlEoE62.js} +220 -1010
- package/dist/index-CbyMC6Yz.js +59 -0
- package/dist/index-CiBVH-oH.js +258 -0
- package/dist/{index-3cf72afd.js → index-DUMmFdJ7.js} +9 -23
- package/dist/{index-01b17e26.js → index-Du-Biu-I.js} +1 -1
- package/dist/index-EnzWG8R0.js +521 -0
- package/dist/index-F2RO3OU4.js +501 -0
- package/dist/{index-7216d6b0.js → index-GavQwMDL.js} +11 -29
- package/dist/{index-0d5b9435.js → index-suip9eAw.js} +2 -2
- package/dist/index.d.ts +18 -14
- package/dist/index.js +23 -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-Ca6PjkYs.js +2674 -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-B2a6ll8f.js} +1 -1
- 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/{umd/components/image → shadowless/icon}/index.d.ts +1 -0
- package/dist/{umd/components → shadowless}/input/index.d.ts +33 -8
- package/dist/{umd/components → shadowless}/select/index.d.ts +16 -12
- package/dist/shadowless/shadowless/index.js +14 -0
- package/dist/shadowless.d.ts +3 -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/color.d.ts +52 -0
- package/dist/utils/index.d.ts +9 -1
- package/dist/{index-7913ec46.js → utils-BMBEcoPj.js} +279 -162
- package/dist/vite.config.d.ts +1 -0
- package/package.json +61 -36
- package/readme.md +14 -14
- package/typings.d.ts +101 -0
- package/dist/components/button/index.js +0 -8
- package/dist/components/icon/index.js +0 -6
- package/dist/components/image/index.js +0 -4
- package/dist/components/input/index.js +0 -6
- package/dist/components/message/index.js +0 -4
- package/dist/components/modal/index.js +0 -4
- package/dist/components/player/index.js +0 -12
- package/dist/components/preview/index.js +0 -8
- package/dist/components/progress/index.js +0 -8
- package/dist/components/radar/index.js +0 -7
- package/dist/components/select/index.js +0 -11
- package/dist/components/skeleton/index.js +0 -4
- package/dist/components/tab/index.js +0 -7
- 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-c14450a9.js +0 -662
- package/dist/info-circle-fill-90ec9aa9.js +0 -14
- package/dist/umd/build/config.d.ts +0 -3
- 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/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/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/vendor-f71e6f68.js +0 -92126
- /package/dist/{add-user-b2bed3e7.js → add-user-BN1JlY7e.js} +0 -0
- /package/dist/{book-b11a68eb.js → book-nTEFXU2x.js} +0 -0
- /package/dist/{umd/build/config.es.d.ts → build/config.sha.d.ts} +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
|
@@ -4,10 +4,10 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import { i as isDisabled, f as falseList, c as createCustomError } from "./index-
|
|
9
|
-
const f7170ee498e0dd32cbdcb63fba8f75cc = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:relative;display:inline-block;background-image:none;box-shadow:0 2px #00000004;cursor:pointer;-webkit-user-select:
|
|
10
|
-
class Button extends
|
|
7
|
+
import { c as currentDevice } from "./utils-BMBEcoPj.js";
|
|
8
|
+
import { H as HTMLElementSSR, i as isDisabled, f as falseList, c as createCustomError } from "./index-CSnBqUsQ.js";
|
|
9
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-btn-position, relative);display:var(--ran-btn-display, inline-block);background-image:var(--ran-btn-background-image, none);box-shadow:var(--ran-btn-box-shadow, 0 2px #00000004);cursor:var(--ran-btn-cursor, pointer);-webkit-user-select:var(--ran-btn-user-select, none);user-select:var(--ran-btn-user-select, none);touch-action:var(--ran-btn-touch-action, manipulation);overflow:var(--ran-btn-overflow, hidden);pointer-events:var(--ran-btn-pointer-events, auto)}:host .ran-btn{position:relative;display:inline-block;background-image:none;cursor:pointer;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;user-select:none;touch-action:manipulation;background:#fff}:host,:host(:active),:host(:focus){outline:0;-webkit-tap-highlight-color:transparent}:host .ran-btn,:host(:active) .ran-btn,:host(:focus) .ran-btn{outline:0}:host(:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-hover-border-color, #1890ff);color:var(--ran-btn-content-hover-color, #1890ff)}:host([type="primary"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, #1890ff);border-color:var(--ran-btn-content-border-color, #1890ff);color:var(--ran-btn-content-color, #fff)}:host([type="primary"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="primary"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, #40a9ff);color:var(--ran-btn-content-hover-color, #fff)}:host([type="warning"]) .ran-btn-content{border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="warning"]:not([disabled])) .ran-btn:after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="warning"]:not([disabled]):hover) .ran-btn-content{border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="text"]) .ran-btn-content{border:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host([disabled]) .ran-btn{cursor:not-allowed;pointer-events:all;opacity:.6}:host(:not([disabled]):active) .ran-btn:after{transform:translate(-50%,-50%) scale(0);opacity:.3;transition:0s}@media (min-width: 1024px){:host(:not([disabled],[effect])) .ran-btn:after{content:"";display:block;position:absolute;width:100%;height:100%;left:var(--ran-x, 0);top:var(--ran-y, 0);pointer-events:none;background-image:radial-gradient(circle,#1890ff 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:translate(-50%,-50%) scale(10);opacity:0;transition:transform .3s,opacity .8s}}:host .slot{display:block}.ran-btn-content{display:flex;justify-content:space-between;align-items:center;padding:4px 15px;border:1px solid transparent;border-radius:2px;border-color:#d9d9d9;color:#000000d9;line-height:22px;font-size:14px;font-weight:400;white-space:nowrap;text-align:center}.ran-btn-content .icon{margin-right:2px}';
|
|
10
|
+
class Button extends HTMLElementSSR() {
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
13
|
__publicField(this, "_btn");
|
|
@@ -17,7 +17,7 @@ class Button extends HTMLElement {
|
|
|
17
17
|
__publicField(this, "_shadowDom");
|
|
18
18
|
__publicField(this, "debounceTimeId");
|
|
19
19
|
/**
|
|
20
|
-
* @description: 设置button的icon
|
|
20
|
+
* @description: 设置 button 的 icon
|
|
21
21
|
* @return {*}
|
|
22
22
|
*/
|
|
23
23
|
__publicField(this, "setIcon", () => {
|
|
@@ -41,7 +41,7 @@ class Button extends HTMLElement {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
__publicField(this, "mousedown", (event) => {
|
|
44
|
-
if (
|
|
44
|
+
if (currentDevice() !== "pc")
|
|
45
45
|
return;
|
|
46
46
|
if (!this.disabled || this.disabled === "false") {
|
|
47
47
|
this.debounceMouseEvent();
|
|
@@ -51,7 +51,7 @@ class Button extends HTMLElement {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
__publicField(this, "mouseup", (event) => {
|
|
54
|
-
if (
|
|
54
|
+
if (currentDevice() !== "pc")
|
|
55
55
|
return;
|
|
56
56
|
if (this.debounceTimeId)
|
|
57
57
|
return;
|
|
@@ -72,9 +72,7 @@ class Button extends HTMLElement {
|
|
|
72
72
|
sheet.insertRule(this.sheet);
|
|
73
73
|
this._shadowDom.adoptedStyleSheets = [sheet];
|
|
74
74
|
} catch (error) {
|
|
75
|
-
console.error(
|
|
76
|
-
`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`
|
|
77
|
-
);
|
|
75
|
+
console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
});
|
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
const f7170ee498e0dd32cbdcb63fba8f75cc = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background
|
|
7
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:#0000000f;border-radius:4px}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,#0000000f 25%,#00000026 37%,#0000000f 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""}';
|
|
8
8
|
function Skeleton() {
|
|
9
9
|
if (typeof window !== "undefined" && !customElements.get("r-skeleton")) {
|
|
10
10
|
class CustomElement extends HTMLElement {
|
|
@@ -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-BMBEcoPj.js";
|
|
8
|
+
import { H as HTMLElementSSR, i as isDisabled, c as createCustomError } from "./index-CSnBqUsQ.js";
|
|
9
|
+
import "./option.js";
|
|
10
|
+
import "./index-GavQwMDL.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
|
+
};
|