ranui 0.1.9 → 0.1.10-alpha.10
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/README.zh-CN.md +190 -0
- package/dist/_commonjs-dynamic-modules-DLbDWi6a.js +12 -0
- package/dist/arrow-down-B_hCY3Wt.js +662 -0
- package/dist/button.js +7 -0
- package/dist/checkbox.js +7 -0
- package/dist/colorpicker.js +11 -0
- package/dist/{colz-746223ab.js → colz-DJZvo_8B.js} +4 -13
- package/dist/docx-CHkPTdGU.js +3665 -0
- package/dist/drop-4j4abxje.js +36 -0
- package/dist/icon.js +6 -0
- package/dist/iconShadowless.js +6 -0
- package/dist/image.js +4 -0
- package/dist/{index-4443363f.js → index-15M0olqa.js} +40 -68
- package/dist/index-1v568_nq.js +140 -0
- package/dist/index-B897keW5.js +279 -0
- package/dist/{index-e03d23e7.js → index-BZR0HaP2.js} +2 -5
- package/dist/{index-e2e5d725.js → index-B_GuEcTd.js} +1280 -2146
- package/dist/index-Bc2Bcl8D.js +63701 -0
- package/dist/index-C4Sv0T51.js +495 -0
- package/dist/{index-2d16a084.js → index-C6RcMHoH.js} +12 -22
- package/dist/index-C9z10IgG.js +103 -0
- package/dist/{index-3cf72afd.js → index-CFjEuvBW.js} +23 -45
- package/dist/{index-7b8840f9.js → index-CGEx9VOA.js} +1086 -2670
- package/dist/index-CGYfjKUV.js +72 -0
- package/dist/index-CVtBLEpV.js +712 -0
- package/dist/index-CiWwvEMM.js +511 -0
- package/dist/index-CtVOgBDk.js +659 -0
- package/dist/index-D4qUro5V.js +279 -0
- package/dist/index-D4y9c1Dj.js +310 -0
- package/dist/{index-b7790662.js → index-DAxs7Dd2.js} +6 -13
- package/dist/index-DC5EA657.js +91 -0
- package/dist/index-DJZmDHz-.js +146 -0
- package/dist/{index-0d5b9435.js → index-D_CA5VDZ.js} +11 -15
- package/dist/{index-01b17e26.js → index-KS2nvVcO.js} +2 -5
- package/dist/{index-1048a998.js → index-WfFw4LJT.js} +105 -62
- package/dist/{index-458debf7.js → index-mhFL9MJp.js} +15 -49
- package/dist/index.d.ts +211 -14
- package/dist/index.js +24 -24
- 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-Dhs3nUkD.js +2346 -0
- package/dist/katex-es-B5r5vt3m.js +14628 -0
- package/dist/loading-scene-BMc2wqKm.js +4 -0
- package/dist/loading.js +8 -0
- package/dist/math.js +7 -0
- package/dist/message.js +6 -0
- package/dist/modal.js +4 -0
- package/dist/{pdf-bdb7818a.js → pdf-Cx0VWKFo.js} +13 -8
- package/dist/player.js +8 -0
- package/dist/popover.js +8 -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/{index-1b73beee.js → selectShadowless.js} +161 -165
- package/dist/shadowless.js +8 -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 +31 -0
- package/dist/typings.d.ts +211 -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/package.json +113 -69
- package/readme.md +38 -56
- package/typings.d.ts +211 -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/option/index.js +0 -95
- 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-57492b9b.js +0 -48
- package/dist/index-7216d6b0.js +0 -175
- package/dist/index-73ce455b.js +0 -264
- package/dist/index-7913ec46.js +0 -239
- package/dist/index-c14450a9.js +0 -662
- 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
package/dist/player.js
ADDED
package/dist/popover.js
ADDED
package/dist/preview.js
ADDED
package/dist/progress.js
ADDED
package/dist/radar.js
ADDED
package/dist/select.js
ADDED
|
@@ -1,15 +1,87 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
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
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import "./index-DJZmDHz-.js";
|
|
5
|
+
import "./index-WfFw4LJT.js";
|
|
6
|
+
import { a as addClassToElement, r as removeClassToElement, i as isMobile, f as generateThrottle } from "./arrow-down-B_hCY3Wt.js";
|
|
7
|
+
import { c as createCustomError, i as isDisabled, H as HTMLElementSSR } from "./index-DC5EA657.js";
|
|
8
|
+
function Custom$1() {
|
|
9
|
+
if (typeof document !== "undefined" && !customElements.get("ra-option")) {
|
|
10
|
+
class Option extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
__publicField(this, "_option");
|
|
14
|
+
__publicField(this, "_optionContent");
|
|
15
|
+
__publicField(this, "_shadowDom");
|
|
16
|
+
__publicField(this, "_slot");
|
|
17
|
+
this._slot = document.createElement("slot");
|
|
18
|
+
this._option = document.createElement("div");
|
|
19
|
+
this._option.setAttribute("class", "ran-option");
|
|
20
|
+
this._optionContent = document.createElement("div");
|
|
21
|
+
this._optionContent.setAttribute("class", "ran-option-content");
|
|
22
|
+
this._optionContent.appendChild(this._slot);
|
|
23
|
+
this._option.appendChild(this._optionContent);
|
|
24
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
25
|
+
this._shadowDom = shadowRoot;
|
|
26
|
+
shadowRoot.appendChild(this._option);
|
|
27
|
+
}
|
|
28
|
+
static get observedAttributes() {
|
|
29
|
+
return ["disabled", "sheet", "value"];
|
|
30
|
+
}
|
|
31
|
+
get value() {
|
|
32
|
+
return this.getAttribute("value");
|
|
33
|
+
}
|
|
34
|
+
set value(value) {
|
|
35
|
+
this.setAttribute("value", value || "");
|
|
36
|
+
}
|
|
37
|
+
get sheet() {
|
|
38
|
+
return this.getAttribute("sheet");
|
|
39
|
+
}
|
|
40
|
+
set sheet(value) {
|
|
41
|
+
this.setAttribute("sheet", value || "");
|
|
42
|
+
}
|
|
43
|
+
get disabled() {
|
|
44
|
+
return isDisabled(this);
|
|
45
|
+
}
|
|
46
|
+
set disabled(value) {
|
|
47
|
+
if (!value || value === "false") {
|
|
48
|
+
this.removeAttribute("disabled");
|
|
49
|
+
} else {
|
|
50
|
+
this.setAttribute("disabled", "");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
handlerExternalCss() {
|
|
54
|
+
if (this.sheet) {
|
|
55
|
+
try {
|
|
56
|
+
const sheet = new CSSStyleSheet();
|
|
57
|
+
sheet.insertRule(this.sheet);
|
|
58
|
+
this._shadowDom.adoptedStyleSheets = [sheet];
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
connectedCallback() {
|
|
65
|
+
}
|
|
66
|
+
disconnectCallback() {
|
|
67
|
+
}
|
|
68
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
69
|
+
if (name === "disabled" && this._option) {
|
|
70
|
+
if (!newValue || newValue === "false") {
|
|
71
|
+
this._option.setAttribute("disabled", "");
|
|
72
|
+
} else {
|
|
73
|
+
this._option.removeAttribute("disabled");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (name === "sheet" && this._shadowDom && oldValue !== newValue) this.handlerExternalCss();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return Option;
|
|
80
|
+
} else {
|
|
81
|
+
return createCustomError("document is undefined or ra-option is exist");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
Custom$1();
|
|
13
85
|
const placementDirection = {
|
|
14
86
|
bottom: {
|
|
15
87
|
add: "ran-select-dropdown-down-in",
|
|
@@ -21,12 +93,10 @@ const placementDirection = {
|
|
|
21
93
|
}
|
|
22
94
|
};
|
|
23
95
|
const searchThrottle = generateThrottle();
|
|
24
|
-
class Select extends
|
|
96
|
+
class Select extends HTMLElementSSR() {
|
|
25
97
|
constructor() {
|
|
26
98
|
super();
|
|
27
99
|
__publicField(this, "removeTimeId");
|
|
28
|
-
__publicField(this, "_slot");
|
|
29
|
-
__publicField(this, "_shadowDom");
|
|
30
100
|
__publicField(this, "_select");
|
|
31
101
|
__publicField(this, "_selection");
|
|
32
102
|
__publicField(this, "_search");
|
|
@@ -47,20 +117,13 @@ class Select extends HTMLElement {
|
|
|
47
117
|
* @return {*}
|
|
48
118
|
*/
|
|
49
119
|
__publicField(this, "setSelectDropdownDisplayNone", () => {
|
|
50
|
-
if (this._selectDropDownOutTimeId)
|
|
51
|
-
return;
|
|
120
|
+
if (this._selectDropDownOutTimeId) return;
|
|
52
121
|
if (this._selectionDropdown && this._selectionDropdown.style.display !== "none") {
|
|
53
|
-
addClassToElement(
|
|
54
|
-
this._selectionDropdown,
|
|
55
|
-
placementDirection[this.placement].remove
|
|
56
|
-
);
|
|
122
|
+
addClassToElement(this._selectionDropdown, placementDirection[this.placement].remove);
|
|
57
123
|
this._selectDropDownOutTimeId = setTimeout(() => {
|
|
58
124
|
var _a;
|
|
59
125
|
(_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "none");
|
|
60
|
-
this._selectionDropdown && removeClassToElement(
|
|
61
|
-
this._selectionDropdown,
|
|
62
|
-
placementDirection[this.placement].remove
|
|
63
|
-
);
|
|
126
|
+
this._selectionDropdown && removeClassToElement(this._selectionDropdown, placementDirection[this.placement].remove);
|
|
64
127
|
clearTimeout(this._selectDropDownOutTimeId);
|
|
65
128
|
this._selectDropDownOutTimeId = void 0;
|
|
66
129
|
}, 300);
|
|
@@ -72,60 +135,47 @@ class Select extends HTMLElement {
|
|
|
72
135
|
*/
|
|
73
136
|
__publicField(this, "setSelectDropdownDisplayBlock", () => {
|
|
74
137
|
var _a;
|
|
75
|
-
if (this._selectDropDownInTimeId)
|
|
76
|
-
return;
|
|
138
|
+
if (this._selectDropDownInTimeId) return;
|
|
77
139
|
if (this._selectionDropdown && this._selectionDropdown.style.display !== "block") {
|
|
78
|
-
addClassToElement(
|
|
79
|
-
this._selectionDropdown,
|
|
80
|
-
placementDirection[this.placement].add
|
|
81
|
-
);
|
|
140
|
+
addClassToElement(this._selectionDropdown, placementDirection[this.placement].add);
|
|
82
141
|
(_a = this._selectionDropdown) == null ? void 0 : _a.style.setProperty("display", "block");
|
|
83
142
|
this._selectDropDownInTimeId = setTimeout(() => {
|
|
84
|
-
this._selectionDropdown && removeClassToElement(
|
|
85
|
-
this._selectionDropdown,
|
|
86
|
-
placementDirection[this.placement].add
|
|
87
|
-
);
|
|
143
|
+
this._selectionDropdown && removeClassToElement(this._selectionDropdown, placementDirection[this.placement].add);
|
|
88
144
|
clearTimeout(this._selectDropDownInTimeId);
|
|
89
145
|
this._selectDropDownInTimeId = void 0;
|
|
90
146
|
}, 200);
|
|
91
147
|
}
|
|
92
148
|
});
|
|
93
149
|
__publicField(this, "placementPosition", () => {
|
|
94
|
-
if (!this._selectionDropdown || !this._selectDropdown)
|
|
95
|
-
return;
|
|
150
|
+
if (!this._selectionDropdown || !this._selectDropdown) return;
|
|
96
151
|
const rect = this.getBoundingClientRect();
|
|
97
152
|
const { top, left, bottom, width, height, x, y, right } = rect;
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
this._selectionDropdown.style.setProperty(
|
|
103
|
-
"-ran-y",
|
|
104
|
-
`${y + window.scrollY}`
|
|
105
|
-
);
|
|
153
|
+
const root = document.getElementById(this.getPopupContainerId);
|
|
154
|
+
this._selectionDropdown.style.setProperty("--ran-x", `${top + window.scrollX}`);
|
|
155
|
+
this._selectionDropdown.style.setProperty("--ran-y", `${left + window.scrollY}`);
|
|
106
156
|
let selectTop = bottom + window.scrollY;
|
|
107
157
|
let selectLeft = left + window.scrollX;
|
|
108
158
|
this._selectionDropdown.style.setProperty("width", `${width}px`);
|
|
109
|
-
const root = document.getElementById(this.getPopupContainerId);
|
|
110
159
|
if (this.placement === "top") {
|
|
111
160
|
selectTop = top + window.scrollY - this._selectionDropdown.clientHeight;
|
|
112
|
-
|
|
161
|
+
}
|
|
162
|
+
if (this.getPopupContainerId && root) {
|
|
163
|
+
if (this.placement === "top") {
|
|
113
164
|
selectTop = top - root.getBoundingClientRect().top - this._selectionDropdown.clientHeight;
|
|
114
|
-
|
|
165
|
+
} else {
|
|
166
|
+
selectTop = root.getBoundingClientRect().height;
|
|
115
167
|
}
|
|
168
|
+
selectLeft = 0;
|
|
116
169
|
}
|
|
117
|
-
this._selectionDropdown.style.setProperty(
|
|
118
|
-
"inset",
|
|
119
|
-
`${selectTop}px auto auto ${selectLeft}px`
|
|
120
|
-
);
|
|
170
|
+
this._selectionDropdown.style.setProperty("inset", `${selectTop}px auto auto ${selectLeft}px`);
|
|
121
171
|
});
|
|
122
172
|
/**
|
|
123
173
|
* @description: 设置下拉框
|
|
124
174
|
* @return {*}
|
|
125
175
|
*/
|
|
126
|
-
__publicField(this, "selectMouseDown", () => {
|
|
127
|
-
|
|
128
|
-
|
|
176
|
+
__publicField(this, "selectMouseDown", (e) => {
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
if (isDisabled(this)) return;
|
|
129
179
|
this.removeDropDownTimeId();
|
|
130
180
|
this.setSelectDropdownDisplayNone();
|
|
131
181
|
this.setSelectDropdownDisplayBlock();
|
|
@@ -133,13 +183,13 @@ class Select extends HTMLElement {
|
|
|
133
183
|
});
|
|
134
184
|
__publicField(this, "removeDropDownTimeId", () => {
|
|
135
185
|
this._search.setAttribute("value", "");
|
|
136
|
-
if (this.
|
|
186
|
+
if (this.trigger.includes("hover") && !isMobile()) {
|
|
137
187
|
clearTimeout(this.removeTimeId);
|
|
138
188
|
this.removeTimeId = void 0;
|
|
139
189
|
}
|
|
140
190
|
});
|
|
141
191
|
/**
|
|
142
|
-
* @description: 焦点移除的情况,需要移除select 下拉框
|
|
192
|
+
* @description: 焦点移除的情况,需要移除 select 下拉框
|
|
143
193
|
* @return {*}
|
|
144
194
|
*/
|
|
145
195
|
__publicField(this, "selectBlur", () => {
|
|
@@ -149,7 +199,7 @@ class Select extends HTMLElement {
|
|
|
149
199
|
this.removeTimeId = setTimeout(() => {
|
|
150
200
|
this.removeDropDownTimeId();
|
|
151
201
|
this.setSelectDropdownDisplayNone();
|
|
152
|
-
},
|
|
202
|
+
}, 100);
|
|
153
203
|
});
|
|
154
204
|
/**
|
|
155
205
|
* @description: 选中一个选项的情况
|
|
@@ -158,12 +208,12 @@ class Select extends HTMLElement {
|
|
|
158
208
|
*/
|
|
159
209
|
__publicField(this, "clickOption", (e) => {
|
|
160
210
|
var _a, _b;
|
|
211
|
+
e.stopPropagation();
|
|
161
212
|
let element = e.target;
|
|
162
213
|
if ((_a = element.classList) == null ? void 0 : _a.contains("ranui-select-dropdown-option-item")) {
|
|
163
214
|
element = element.children[0];
|
|
164
215
|
}
|
|
165
|
-
if (!((_b = element.classList) == null ? void 0 : _b.contains("ranui-select-dropdown-option-item-content")))
|
|
166
|
-
return;
|
|
216
|
+
if (!((_b = element.classList) == null ? void 0 : _b.contains("ranui-select-dropdown-option-item-content"))) return;
|
|
167
217
|
const label = element.innerHTML;
|
|
168
218
|
const value = this._optionLabelMapValue.get(label);
|
|
169
219
|
if (value) {
|
|
@@ -176,18 +226,12 @@ class Select extends HTMLElement {
|
|
|
176
226
|
const { height } = rect;
|
|
177
227
|
this._text.style.setProperty("line-height", `${height}px`);
|
|
178
228
|
if (this._activeOption) {
|
|
179
|
-
removeClassToElement(
|
|
180
|
-
this._activeOption,
|
|
181
|
-
"ranui-select-dropdown-option-active"
|
|
182
|
-
);
|
|
229
|
+
removeClassToElement(this._activeOption, "ranui-select-dropdown-option-active");
|
|
183
230
|
}
|
|
184
231
|
setTimeout(() => {
|
|
185
232
|
this._activeOption = (element == null ? void 0 : element.parentElement) || void 0;
|
|
186
233
|
if (this._activeOption) {
|
|
187
|
-
addClassToElement(
|
|
188
|
-
this._activeOption,
|
|
189
|
-
"ranui-select-dropdown-option-active"
|
|
190
|
-
);
|
|
234
|
+
addClassToElement(this._activeOption, "ranui-select-dropdown-option-active");
|
|
191
235
|
}
|
|
192
236
|
}, 200);
|
|
193
237
|
this.setSelectDropdownDisplayNone();
|
|
@@ -200,39 +244,29 @@ class Select extends HTMLElement {
|
|
|
200
244
|
*/
|
|
201
245
|
__publicField(this, "createOption", () => {
|
|
202
246
|
if (!this._selectDropdown) {
|
|
247
|
+
this.appendChild(this._select);
|
|
203
248
|
const container = document.getElementById(this.getPopupContainerId) || document.body;
|
|
204
249
|
this._selectDropdown = document.createElement("div");
|
|
205
|
-
this._selectDropdown.style.setProperty(
|
|
206
|
-
"-webkit-tap-highlight-color",
|
|
207
|
-
"transparent"
|
|
208
|
-
);
|
|
250
|
+
this._selectDropdown.style.setProperty("-webkit-tap-highlight-color", "transparent");
|
|
209
251
|
this._selectDropdown.style.setProperty("outline", "0");
|
|
210
252
|
this._selectDropdown.addEventListener("click", this.clickOption);
|
|
211
253
|
this._selectionDropdown = document.createElement("div");
|
|
212
|
-
this._selectionDropdown.style.setProperty(
|
|
213
|
-
"-webkit-tap-highlight-color",
|
|
214
|
-
"transparent"
|
|
215
|
-
);
|
|
254
|
+
this._selectionDropdown.style.setProperty("-webkit-tap-highlight-color", "transparent");
|
|
216
255
|
this._selectionDropdown.style.setProperty("outline", "0");
|
|
217
256
|
if (this.dropdownclass) {
|
|
218
|
-
this._selectionDropdown.setAttribute(
|
|
219
|
-
"class",
|
|
220
|
-
`${this.dropdownclass} ranui-select-dropdown`
|
|
221
|
-
);
|
|
257
|
+
this._selectionDropdown.setAttribute("class", `${this.dropdownclass} ranui-select-dropdown`);
|
|
222
258
|
} else {
|
|
223
259
|
this._selectionDropdown.setAttribute("class", "ranui-select-dropdown");
|
|
224
260
|
}
|
|
225
|
-
if (this.
|
|
261
|
+
if (this.trigger.includes("hover") && !isMobile()) {
|
|
226
262
|
this._selectDropdown.addEventListener("mouseleave", this.selectBlur);
|
|
227
|
-
this._selectDropdown.addEventListener(
|
|
228
|
-
"mouseenter",
|
|
229
|
-
this.removeDropDownTimeId
|
|
230
|
-
);
|
|
263
|
+
this._selectDropdown.addEventListener("mouseenter", this.removeDropDownTimeId);
|
|
231
264
|
}
|
|
232
265
|
this._selectDropdown.appendChild(this._selectionDropdown);
|
|
233
266
|
this._selectionDropdown.style.setProperty("display", "none");
|
|
234
267
|
container.appendChild(this._selectDropdown);
|
|
235
268
|
}
|
|
269
|
+
this.addOptionToSlot();
|
|
236
270
|
});
|
|
237
271
|
/**
|
|
238
272
|
* @description: 移除选项下拉框
|
|
@@ -248,27 +282,22 @@ class Select extends HTMLElement {
|
|
|
248
282
|
}
|
|
249
283
|
});
|
|
250
284
|
/**
|
|
251
|
-
* @description: 当select中有option元素的时候,给dropdown添加元素
|
|
285
|
+
* @description: 当 select 中有 option 元素的时候,给 dropdown 添加元素
|
|
252
286
|
* @return {*}
|
|
253
287
|
*/
|
|
254
288
|
__publicField(this, "addOptionToSlot", () => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
if (this._optionValueMapLabel.get(value)) {
|
|
267
|
-
console.warn(`${value} is repeat option`);
|
|
289
|
+
var _a;
|
|
290
|
+
const child = this.children || [];
|
|
291
|
+
this._optionList = [];
|
|
292
|
+
for (const item of child) {
|
|
293
|
+
if (item.tagName === "R-OPTION") {
|
|
294
|
+
const label = item.innerHTML;
|
|
295
|
+
const value = item.getAttribute("value") || "";
|
|
296
|
+
(_a = this._optionList) == null ? void 0 : _a.push({ label, value });
|
|
297
|
+
this._optionLabelMapValue.set(label, value);
|
|
298
|
+
this._optionValueMapLabel.set(value, label);
|
|
268
299
|
}
|
|
269
|
-
|
|
270
|
-
this._optionValueMapLabel.set(value, label);
|
|
271
|
-
});
|
|
300
|
+
}
|
|
272
301
|
this.createSelectDropdownContent(this._optionList);
|
|
273
302
|
});
|
|
274
303
|
__publicField(this, "createSelectDropdownContent", (options = []) => {
|
|
@@ -278,6 +307,9 @@ class Select extends HTMLElement {
|
|
|
278
307
|
} else {
|
|
279
308
|
(_b = this._selectDropdown) == null ? void 0 : _b.style.setProperty("display", "block");
|
|
280
309
|
}
|
|
310
|
+
if (this._selectionDropdown) {
|
|
311
|
+
this._selectionDropdown.innerHTML = "";
|
|
312
|
+
}
|
|
281
313
|
options.forEach((item) => {
|
|
282
314
|
if (this._selectionDropdown) {
|
|
283
315
|
const { label, value } = item;
|
|
@@ -290,16 +322,10 @@ class Select extends HTMLElement {
|
|
|
290
322
|
);
|
|
291
323
|
this._activeOption = selectOptionItem;
|
|
292
324
|
} else {
|
|
293
|
-
selectOptionItem.setAttribute(
|
|
294
|
-
"class",
|
|
295
|
-
"ranui-select-dropdown-option-item"
|
|
296
|
-
);
|
|
325
|
+
selectOptionItem.setAttribute("class", "ranui-select-dropdown-option-item");
|
|
297
326
|
}
|
|
298
327
|
const selectOptionItemContent = document.createElement("div");
|
|
299
|
-
selectOptionItemContent.setAttribute(
|
|
300
|
-
"class",
|
|
301
|
-
"ranui-select-dropdown-option-item-content"
|
|
302
|
-
);
|
|
328
|
+
selectOptionItemContent.setAttribute("class", "ranui-select-dropdown-option-item-content");
|
|
303
329
|
selectOptionItemContent.innerHTML = `${label}`;
|
|
304
330
|
selectOptionItemContent.setAttribute("value", `${value}`);
|
|
305
331
|
selectOptionItemContent.setAttribute("title", `${label}`);
|
|
@@ -311,11 +337,9 @@ class Select extends HTMLElement {
|
|
|
311
337
|
});
|
|
312
338
|
__publicField(this, "setDefaultValue", () => {
|
|
313
339
|
const defaultValue = this.getAttribute("defaultValue") || this.getAttribute("value");
|
|
314
|
-
if (!defaultValue)
|
|
315
|
-
return;
|
|
340
|
+
if (!defaultValue) return;
|
|
316
341
|
const label = this._optionValueMapLabel.get(defaultValue);
|
|
317
|
-
if (!label)
|
|
318
|
-
return;
|
|
342
|
+
if (!label) return;
|
|
319
343
|
this.setAttribute("value", defaultValue);
|
|
320
344
|
const rect = this.getBoundingClientRect();
|
|
321
345
|
const { height } = rect;
|
|
@@ -348,34 +372,31 @@ class Select extends HTMLElement {
|
|
|
348
372
|
});
|
|
349
373
|
__publicField(this, "setShowSearch", () => {
|
|
350
374
|
this.onSearch = searchThrottle(this.changeSearch);
|
|
351
|
-
this._search.addEventListener("change", this.onSearch);
|
|
352
|
-
this._search.addEventListener("click", this.onSearch);
|
|
375
|
+
this.onSearch && this._search.addEventListener("change", this.onSearch);
|
|
376
|
+
this.onSearch && this._search.addEventListener("click", this.onSearch);
|
|
353
377
|
});
|
|
354
378
|
__publicField(this, "removeShowSearch", () => {
|
|
355
|
-
this._search.removeEventListener("change", this.onSearch);
|
|
356
|
-
this._search.removeEventListener("click", this.onSearch);
|
|
357
|
-
});
|
|
358
|
-
__publicField(this, "listenSlotChange", () => {
|
|
359
|
-
this._slot.addEventListener("slotchange", this.addOptionToSlot);
|
|
360
|
-
});
|
|
361
|
-
__publicField(this, "removeListenSlotChange", () => {
|
|
362
|
-
this._slot.removeEventListener("slotchange", this.addOptionToSlot);
|
|
379
|
+
this.onSearch && this._search.removeEventListener("change", this.onSearch);
|
|
380
|
+
this.onSearch && this._search.removeEventListener("click", this.onSearch);
|
|
363
381
|
});
|
|
364
382
|
__publicField(this, "listenActionEvent", () => {
|
|
365
383
|
this.removeEventListener("mouseenter", this.selectMouseDown);
|
|
366
384
|
this.removeEventListener("mouseleave", this.selectBlur);
|
|
367
385
|
this.removeEventListener("click", this.selectMouseDown);
|
|
368
386
|
this.removeEventListener("blur", this.selectBlur);
|
|
369
|
-
if (this.
|
|
387
|
+
if (this.trigger.includes("hover") && !isMobile()) {
|
|
370
388
|
this.addEventListener("mouseenter", this.selectMouseDown);
|
|
371
389
|
this.addEventListener("mouseleave", this.selectBlur);
|
|
372
390
|
}
|
|
373
|
-
if (this.
|
|
391
|
+
if (this.trigger.includes("click")) {
|
|
374
392
|
this.addEventListener("click", this.selectMouseDown);
|
|
375
393
|
this.addEventListener("blur", this.selectBlur);
|
|
376
394
|
}
|
|
377
395
|
});
|
|
378
|
-
this
|
|
396
|
+
__publicField(this, "clickRemoveSelect", (e) => {
|
|
397
|
+
e.stopPropagation();
|
|
398
|
+
this.setSelectDropdownDisplayNone();
|
|
399
|
+
});
|
|
379
400
|
this._select = document.createElement("div");
|
|
380
401
|
this._select.setAttribute("class", "ran-select");
|
|
381
402
|
this._select.setAttribute("part", "select");
|
|
@@ -383,7 +404,7 @@ class Select extends HTMLElement {
|
|
|
383
404
|
this._selection.setAttribute("class", "selection");
|
|
384
405
|
this._selection.setAttribute("part", "selection");
|
|
385
406
|
this._selector = document.createElement("div");
|
|
386
|
-
this._search = document.createElement("
|
|
407
|
+
this._search = document.createElement("ra-input");
|
|
387
408
|
this._search.setAttribute("class", "selection-search");
|
|
388
409
|
this._search.setAttribute("part", "search");
|
|
389
410
|
this._search.setAttribute("type", "search");
|
|
@@ -391,7 +412,7 @@ class Select extends HTMLElement {
|
|
|
391
412
|
this._text = document.createElement("span");
|
|
392
413
|
this._text.setAttribute("class", "selection-item");
|
|
393
414
|
this._text.setAttribute("part", "selection-item");
|
|
394
|
-
this._icon = document.createElement("
|
|
415
|
+
this._icon = document.createElement("ra-icon");
|
|
395
416
|
this._icon.setAttribute("class", "icon");
|
|
396
417
|
this._icon.setAttribute("part", "icon");
|
|
397
418
|
this._icon.setAttribute("name", "arrow-down");
|
|
@@ -401,18 +422,10 @@ class Select extends HTMLElement {
|
|
|
401
422
|
this._selector.appendChild(this._search);
|
|
402
423
|
this._selection.appendChild(this._icon);
|
|
403
424
|
this._selection.appendChild(this._selector);
|
|
404
|
-
this._slot.setAttribute("class", "slot");
|
|
405
425
|
this._select.appendChild(this._selection);
|
|
406
|
-
this._select.appendChild(this._slot);
|
|
407
426
|
this._optionList = [];
|
|
408
427
|
this._optionLabelMapValue = /* @__PURE__ */ new Map();
|
|
409
428
|
this._optionValueMapLabel = /* @__PURE__ */ new Map();
|
|
410
|
-
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
411
|
-
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
412
|
-
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
|
|
413
|
-
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
414
|
-
this._shadowDom = shadowRoot;
|
|
415
|
-
shadowRoot.appendChild(this._select);
|
|
416
429
|
}
|
|
417
430
|
static get observedAttributes() {
|
|
418
431
|
return [
|
|
@@ -428,8 +441,8 @@ class Select extends HTMLElement {
|
|
|
428
441
|
// 挂载的节点
|
|
429
442
|
"dropdownclass",
|
|
430
443
|
// 弹窗的类名
|
|
431
|
-
"
|
|
432
|
-
// 触发下拉框的行为,
|
|
444
|
+
"trigger"
|
|
445
|
+
// 触发下拉框的行为,click 还是 hover,hover 在 isMobile 移动端无效
|
|
433
446
|
];
|
|
434
447
|
}
|
|
435
448
|
get value() {
|
|
@@ -484,11 +497,11 @@ class Select extends HTMLElement {
|
|
|
484
497
|
set dropdownclass(value) {
|
|
485
498
|
this.setAttribute("dropdownclass", value || "");
|
|
486
499
|
}
|
|
487
|
-
get
|
|
488
|
-
return this.getAttribute("
|
|
500
|
+
get trigger() {
|
|
501
|
+
return this.getAttribute("trigger") || "click";
|
|
489
502
|
}
|
|
490
|
-
set
|
|
491
|
-
this.setAttribute("
|
|
503
|
+
set trigger(value) {
|
|
504
|
+
this.setAttribute("trigger", value || "");
|
|
492
505
|
}
|
|
493
506
|
get disabled() {
|
|
494
507
|
return isDisabled(this);
|
|
@@ -502,25 +515,11 @@ class Select extends HTMLElement {
|
|
|
502
515
|
this._selection.setAttribute("disabled", "");
|
|
503
516
|
}
|
|
504
517
|
}
|
|
505
|
-
handlerExternalCss() {
|
|
506
|
-
if (this.sheet) {
|
|
507
|
-
try {
|
|
508
|
-
const sheet = new CSSStyleSheet();
|
|
509
|
-
sheet.insertRule(this.sheet);
|
|
510
|
-
this._shadowDom.adoptedStyleSheets = [sheet];
|
|
511
|
-
} catch (error) {
|
|
512
|
-
console.error(
|
|
513
|
-
`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
518
|
connectedCallback() {
|
|
519
|
-
this.handlerExternalCss();
|
|
520
519
|
this.createOption();
|
|
521
520
|
this.listenActionEvent();
|
|
522
|
-
this.listenSlotChange();
|
|
523
521
|
this.setShowSearch();
|
|
522
|
+
document.addEventListener("click", this.clickRemoveSelect);
|
|
524
523
|
}
|
|
525
524
|
disconnectCallback() {
|
|
526
525
|
var _a;
|
|
@@ -530,7 +529,7 @@ class Select extends HTMLElement {
|
|
|
530
529
|
this.removeEventListener("blur", this.selectBlur);
|
|
531
530
|
this.removeSelectDropdown();
|
|
532
531
|
(_a = this._selectDropdown) == null ? void 0 : _a.removeEventListener("click", this.clickOption);
|
|
533
|
-
this.
|
|
532
|
+
document.removeEventListener("click", this.clickRemoveSelect);
|
|
534
533
|
}
|
|
535
534
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
536
535
|
if (name === "disabled" && this._select) {
|
|
@@ -542,17 +541,14 @@ class Select extends HTMLElement {
|
|
|
542
541
|
this._selection.removeAttribute("disabled");
|
|
543
542
|
}
|
|
544
543
|
}
|
|
545
|
-
if (name === "sheet" && this._shadowDom && oldValue !== newValue) {
|
|
546
|
-
this.handlerExternalCss();
|
|
547
|
-
}
|
|
548
544
|
}
|
|
549
545
|
}
|
|
550
546
|
function Custom() {
|
|
551
|
-
if (typeof document !== "undefined" && !customElements.get("
|
|
552
|
-
customElements.define("
|
|
547
|
+
if (typeof document !== "undefined" && !customElements.get("ra-select")) {
|
|
548
|
+
customElements.define("ra-select", Select);
|
|
553
549
|
return Select;
|
|
554
550
|
} else {
|
|
555
|
-
return createCustomError("document is undefined or
|
|
551
|
+
return createCustomError("document is undefined or ra-select is exist");
|
|
556
552
|
}
|
|
557
553
|
}
|
|
558
554
|
const index = Custom();
|
|
@@ -562,7 +558,7 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
562
558
|
default: index
|
|
563
559
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
564
560
|
export {
|
|
565
|
-
Select
|
|
566
|
-
index as
|
|
561
|
+
Select,
|
|
562
|
+
index as default,
|
|
567
563
|
index$1 as i
|
|
568
564
|
};
|
package/dist/skeleton.js
ADDED