ranui 0.1.8 → 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 +38 -1
- 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 +208 -1
- 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 +207 -493
- 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 +23 -0
- package/dist/components/select/index.d.ts +18 -6
- package/dist/components/tab/index.d.ts +5 -0
- package/dist/components/tabpane/index.d.ts +5 -0
- 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-f6d6982d.js → index-BLepXisd.js} +101 -84
- package/dist/{index-b2be6bef.js → index-BOoNI-Al.js} +904 -1078
- package/dist/index-BPBRPxND.js +195 -0
- package/dist/{index-b90299ca.js → index-BpOERe9M.js} +1 -1
- package/dist/index-Bv6Z6rIe.js +498 -0
- package/dist/index-ByJ7zZdQ.js +65641 -0
- package/dist/{index-5975bbc0.js → index-C1x9Popy.js} +1 -1
- package/dist/index-CCNK5H8T.js +103 -0
- package/dist/{index-a1a53af6.js → index-CD09p_mF.js} +7 -31
- package/dist/index-CFnsLnrb.js +496 -0
- package/dist/{index-a43b144f.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-0e7229ea.js → index-DUMmFdJ7.js} +9 -21
- package/dist/{index-aea75a9f.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-7f513a14.js → index-GavQwMDL.js} +11 -29
- package/dist/{index-48653b79.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/shadowless/input/index.d.ts +210 -0
- package/dist/{umd/components → shadowless}/select/index.d.ts +19 -11
- 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/utils-BMBEcoPj.js +356 -0
- package/dist/vite.config.d.ts +1 -0
- package/package.json +61 -39
- package/readme.md +14 -14
- package/typings.d.ts +101 -0
- package/dist/components/button/index.js +0 -7
- package/dist/components/icon/index.js +0 -6
- package/dist/components/image/index.js +0 -4
- package/dist/components/input/index.js +0 -5
- package/dist/components/message/index.js +0 -4
- package/dist/components/modal/index.js +0 -4
- package/dist/components/player/index.js +0 -11
- 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-183517e7.js +0 -265
- package/dist/index-4d873a42.js +0 -195
- package/dist/index-a216f328.js +0 -662
- package/dist/index-d2d69b06.js +0 -225
- package/dist/index-ecaed5cc.js +0 -439
- 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 -2
- package/dist/umd/components/form/index.d.ts +0 -2
- package/dist/umd/components/icon/index.d.ts +0 -2
- package/dist/umd/components/input/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 -524
- 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/skeleton/index.d.ts +0 -2
- package/dist/umd/components/tab/index.d.ts +0 -403
- package/dist/umd/components/tabpane/index.d.ts +0 -347
- 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,11 +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 { p as perToNum } from "./
|
|
8
|
-
import { c as createCustomError } from "./index-
|
|
9
|
-
const index$2 = "";
|
|
7
|
+
import { p as perToNum } from "./utils-BMBEcoPj.js";
|
|
8
|
+
import { H as HTMLElementSSR, c as createCustomError } from "./index-CSnBqUsQ.js";
|
|
10
9
|
const attributes = ["percent", "type", "total", "dot"];
|
|
11
|
-
class Progress extends
|
|
10
|
+
class Progress extends HTMLElementSSR() {
|
|
12
11
|
constructor() {
|
|
13
12
|
super();
|
|
14
13
|
__publicField(this, "_progress");
|
|
@@ -19,19 +18,10 @@ class Progress extends HTMLElement {
|
|
|
19
18
|
__publicField(this, "progressClick", (e) => {
|
|
20
19
|
const rect = this._progress.getBoundingClientRect();
|
|
21
20
|
const offsetX = e.clientX - rect.left;
|
|
22
|
-
const percentage = Math.min(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
this.percent = percentage * this.total;
|
|
27
|
-
this._progressWrapValue.style.setProperty(
|
|
28
|
-
"transform",
|
|
29
|
-
`scaleX(${percentage})`
|
|
30
|
-
);
|
|
31
|
-
this._progressDot.style.setProperty(
|
|
32
|
-
"transform",
|
|
33
|
-
`translateX(${percentage * this._progress.offsetWidth}px)`
|
|
34
|
-
);
|
|
21
|
+
const percentage = Math.min(1, Math.max(0, offsetX / this._progress.offsetWidth));
|
|
22
|
+
this.percent = `${percentage * Number(this.total)}`;
|
|
23
|
+
this._progressWrapValue.style.setProperty("transform", `scaleX(${percentage})`);
|
|
24
|
+
this._progressDot.style.setProperty("transform", `translateX(${percentage * this._progress.offsetWidth}px)`);
|
|
35
25
|
this.change();
|
|
36
26
|
});
|
|
37
27
|
__publicField(this, "progressDotMouseDown", () => {
|
|
@@ -42,19 +32,10 @@ class Progress extends HTMLElement {
|
|
|
42
32
|
return;
|
|
43
33
|
const rect = this._progress.getBoundingClientRect();
|
|
44
34
|
const offsetX = e.clientX - rect.left;
|
|
45
|
-
const percentage = Math.min(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
this.percent = percentage * this.total;
|
|
50
|
-
this._progressWrapValue.style.setProperty(
|
|
51
|
-
"transform",
|
|
52
|
-
`scaleX(${percentage})`
|
|
53
|
-
);
|
|
54
|
-
this._progressDot.style.setProperty(
|
|
55
|
-
"transform",
|
|
56
|
-
`translateX(${percentage * this._progress.offsetWidth}px)`
|
|
57
|
-
);
|
|
35
|
+
const percentage = Math.min(1, Math.max(0, offsetX / this._progress.offsetWidth));
|
|
36
|
+
this.percent = `${percentage * Number(this.total)}`;
|
|
37
|
+
this._progressWrapValue.style.setProperty("transform", `scaleX(${percentage})`);
|
|
38
|
+
this._progressDot.style.setProperty("transform", `translateX(${percentage * this._progress.offsetWidth}px)`);
|
|
58
39
|
this.change();
|
|
59
40
|
});
|
|
60
41
|
__publicField(this, "progressDotMouseUp", (e) => {
|
|
@@ -82,15 +63,9 @@ class Progress extends HTMLElement {
|
|
|
82
63
|
}
|
|
83
64
|
});
|
|
84
65
|
__publicField(this, "updateCurrentProgress", () => {
|
|
85
|
-
const percent = this.percent / this.total;
|
|
86
|
-
this._progressWrapValue.style.setProperty(
|
|
87
|
-
|
|
88
|
-
`scaleX(${percent})`
|
|
89
|
-
);
|
|
90
|
-
this._progressDot.style.setProperty(
|
|
91
|
-
"transform",
|
|
92
|
-
`translateX(${percent * this._progress.offsetWidth}px)`
|
|
93
|
-
);
|
|
66
|
+
const percent = Number(this.percent) / Number(this.total);
|
|
67
|
+
this._progressWrapValue.style.setProperty("transform", `scaleX(${percent})`);
|
|
68
|
+
this._progressDot.style.setProperty("transform", `translateX(${percent * this._progress.offsetWidth}px)`);
|
|
94
69
|
});
|
|
95
70
|
__publicField(this, "dragEvent", () => {
|
|
96
71
|
if (this.type !== "drag")
|
|
@@ -101,9 +76,9 @@ class Progress extends HTMLElement {
|
|
|
101
76
|
document.addEventListener("mouseup", this.progressDotMouseUp);
|
|
102
77
|
});
|
|
103
78
|
__publicField(this, "createProgress", () => {
|
|
104
|
-
if (!this.
|
|
105
|
-
this.appendChild(this._progress);
|
|
79
|
+
if (!(this.children.length > 0 && [...this.children].some((item) => item.className === "ran-progress"))) {
|
|
106
80
|
this._progress.appendChild(this._progressDot);
|
|
81
|
+
this.appendChild(this._progress);
|
|
107
82
|
}
|
|
108
83
|
});
|
|
109
84
|
__publicField(this, "resize", () => {
|
|
@@ -111,6 +86,7 @@ class Progress extends HTMLElement {
|
|
|
111
86
|
});
|
|
112
87
|
this._progress = document.createElement("div");
|
|
113
88
|
this._progress.setAttribute("class", "ran-progress");
|
|
89
|
+
this._progress.setAttribute("role", "progressbar");
|
|
114
90
|
this._progressWrap = document.createElement("div");
|
|
115
91
|
this._progressWrap.setAttribute("class", "ran-progress-wrap");
|
|
116
92
|
this._progress.appendChild(this._progressWrap);
|
|
@@ -129,20 +105,21 @@ class Progress extends HTMLElement {
|
|
|
129
105
|
get percent() {
|
|
130
106
|
const percent = this.getAttribute("percent") || "";
|
|
131
107
|
const num = perToNum(percent);
|
|
132
|
-
if (num > this.total) {
|
|
108
|
+
if (Number(num) > Number(this.total)) {
|
|
133
109
|
console.error("percent must be < total");
|
|
134
110
|
return this.total;
|
|
135
111
|
}
|
|
136
|
-
return perToNum(percent)
|
|
112
|
+
return `${perToNum(percent)}`;
|
|
137
113
|
}
|
|
138
114
|
set percent(value) {
|
|
139
115
|
this.setAttribute("percent", `${value || 0}`);
|
|
116
|
+
this.setAttribute("aria-valuenow", `${value || 0}`);
|
|
140
117
|
}
|
|
141
118
|
get total() {
|
|
142
119
|
const total = this.getAttribute("total");
|
|
143
120
|
if (!total)
|
|
144
|
-
return 1;
|
|
145
|
-
return perToNum(total)
|
|
121
|
+
return "1";
|
|
122
|
+
return `${perToNum(total)}`;
|
|
146
123
|
}
|
|
147
124
|
set total(value) {
|
|
148
125
|
this.setAttribute("total", value || "");
|
|
@@ -184,16 +161,17 @@ class Progress extends HTMLElement {
|
|
|
184
161
|
this.setAttribute("dot", value || "true");
|
|
185
162
|
}
|
|
186
163
|
connectedCallback() {
|
|
164
|
+
const type = this.getAttribute("type");
|
|
165
|
+
if (!type) {
|
|
166
|
+
this.setAttribute("type", "primary");
|
|
167
|
+
}
|
|
187
168
|
this.dragEvent();
|
|
188
169
|
this.updateCurrentProgress();
|
|
189
170
|
window.addEventListener("resize", this.resize);
|
|
190
171
|
}
|
|
191
172
|
disconnectCallback() {
|
|
192
173
|
this._progress.removeEventListener("click", this.progressClick);
|
|
193
|
-
this._progressDot.removeEventListener(
|
|
194
|
-
"mousedown",
|
|
195
|
-
this.progressDotMouseDown
|
|
196
|
-
);
|
|
174
|
+
this._progressDot.removeEventListener("mousedown", this.progressDotMouseDown);
|
|
197
175
|
document.removeEventListener("mousemove", this.progressDotMouseMove);
|
|
198
176
|
document.removeEventListener("mouseup", this.progressDotMouseUp);
|
|
199
177
|
window.removeEventListener("resize", this.resize);
|
|
@@ -214,7 +192,8 @@ class Progress extends HTMLElement {
|
|
|
214
192
|
}
|
|
215
193
|
function Custom() {
|
|
216
194
|
if (typeof document !== "undefined" && !customElements.get("r-progress")) {
|
|
217
|
-
customElements.define("r-progress", Progress);
|
|
195
|
+
Progress && customElements.define("r-progress", Progress);
|
|
196
|
+
return Progress;
|
|
218
197
|
} else {
|
|
219
198
|
return createCustomError("document is undefined or r-progress is exist");
|
|
220
199
|
}
|
|
@@ -31,7 +31,7 @@ const loadScript = (src) => {
|
|
|
31
31
|
document.body.append(script);
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
function createCustomError(msg) {
|
|
34
|
+
function createCustomError(msg = "") {
|
|
35
35
|
return class CustomError {
|
|
36
36
|
constructor(message = msg) {
|
|
37
37
|
__publicField(this, "message");
|
|
@@ -39,7 +39,54 @@ function createCustomError(msg) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
+
const HTMLElementSSR = () => {
|
|
43
|
+
if (typeof document !== "undefined") {
|
|
44
|
+
return HTMLElement;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
const createSignal = (value, options) => {
|
|
49
|
+
const signal = {
|
|
50
|
+
value,
|
|
51
|
+
// 订阅者
|
|
52
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
53
|
+
comparator: options == null ? void 0 : options.equals
|
|
54
|
+
};
|
|
55
|
+
const { subscriber } = options || {};
|
|
56
|
+
if (subscriber && Array.isArray(subscriber)) {
|
|
57
|
+
subscriber.forEach((item) => {
|
|
58
|
+
if (typeof item === "function" && !signal.subscribers.has(item)) {
|
|
59
|
+
signal.subscribers.add(item);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const getter = () => {
|
|
64
|
+
return signal.value;
|
|
65
|
+
};
|
|
66
|
+
const updateSignal = (newValue) => {
|
|
67
|
+
if (signal.value !== newValue) {
|
|
68
|
+
signal.value = newValue;
|
|
69
|
+
signal.subscribers.forEach((subscriber2) => subscriber2(newValue));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const setter = (newValue) => {
|
|
73
|
+
const { comparator } = signal;
|
|
74
|
+
if (comparator instanceof Function) {
|
|
75
|
+
return !comparator(signal.value, newValue) && updateSignal(newValue);
|
|
76
|
+
}
|
|
77
|
+
if (comparator === void 0) {
|
|
78
|
+
if (signal.value !== newValue) {
|
|
79
|
+
updateSignal(newValue);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
!comparator && updateSignal(newValue);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return [getter, setter];
|
|
86
|
+
};
|
|
42
87
|
export {
|
|
88
|
+
HTMLElementSSR as H,
|
|
89
|
+
createSignal as a,
|
|
43
90
|
createCustomError as c,
|
|
44
91
|
falseList as f,
|
|
45
92
|
isDisabled as i,
|
|
@@ -0,0 +1,206 @@
|
|
|
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 Popover extends HTMLElementSSR() {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
__publicField(this, "_slot");
|
|
12
|
+
__publicField(this, "popoverBlock");
|
|
13
|
+
__publicField(this, "popoverContent");
|
|
14
|
+
__publicField(this, "popoverArrow");
|
|
15
|
+
__publicField(this, "popoverInner");
|
|
16
|
+
__publicField(this, "popoverInnerBlock");
|
|
17
|
+
__publicField(this, "removePopoverTimeId");
|
|
18
|
+
__publicField(this, "createContent", (content) => {
|
|
19
|
+
if (!content)
|
|
20
|
+
return;
|
|
21
|
+
if (!this.popoverContent) {
|
|
22
|
+
const div = document.createElement("div");
|
|
23
|
+
this.popoverContent = document.createElement("div");
|
|
24
|
+
this.popoverContent.setAttribute("class", "ran-popover-content");
|
|
25
|
+
this.popoverContent.addEventListener("click", this.clickContent);
|
|
26
|
+
this.popoverArrow = document.createElement("div");
|
|
27
|
+
this.popoverArrow.setAttribute("class", "ran-popover-content-arrow");
|
|
28
|
+
this.popoverInner = document.createElement("div");
|
|
29
|
+
this.popoverInner.setAttribute("class", "ran-popover-content-inner");
|
|
30
|
+
this.popoverInnerBlock = document.createElement("div");
|
|
31
|
+
this.popoverInnerBlock.setAttribute("class", "ran-popover-content-inner-block");
|
|
32
|
+
this.popoverContent.appendChild(this.popoverArrow);
|
|
33
|
+
this.popoverContent.appendChild(this.popoverInner);
|
|
34
|
+
this.popoverInner.appendChild(this.popoverInnerBlock);
|
|
35
|
+
div.appendChild(this.popoverContent);
|
|
36
|
+
document.body.appendChild(div);
|
|
37
|
+
}
|
|
38
|
+
if (this.popoverInnerBlock && content.length > 0) {
|
|
39
|
+
this.popoverInnerBlock.innerHTML = "";
|
|
40
|
+
const Fragment = document.createDocumentFragment();
|
|
41
|
+
for (const child of content) {
|
|
42
|
+
Fragment.appendChild(child);
|
|
43
|
+
}
|
|
44
|
+
this.popoverInnerBlock.appendChild(Fragment);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
__publicField(this, "watchContent", (e) => {
|
|
48
|
+
const { value } = e.detail;
|
|
49
|
+
this.createContent(value.content);
|
|
50
|
+
this.placementPosition();
|
|
51
|
+
});
|
|
52
|
+
__publicField(this, "placementPosition", () => {
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
|
+
if (!this.popoverInnerBlock || !this.popoverContent)
|
|
55
|
+
return;
|
|
56
|
+
(_a = this.popoverContent) == null ? void 0 : _a.style.setProperty("display", "block");
|
|
57
|
+
(_b = this.popoverContent) == null ? void 0 : _b.style.setProperty("opacity", "1");
|
|
58
|
+
const rect = this.getBoundingClientRect();
|
|
59
|
+
const { top, left, bottom, width } = rect;
|
|
60
|
+
this.popoverContent.style.setProperty("--ran-x", `${(left + window.scrollX).toFixed(2)}px`);
|
|
61
|
+
this.popoverContent.style.setProperty("--ran-y", `${(top + window.scrollY).toFixed(2)}px`);
|
|
62
|
+
let popoverTop = bottom + window.scrollY;
|
|
63
|
+
let popoverLeft = left + window.scrollX;
|
|
64
|
+
const root = document.getElementById(this.getPopupContainerId);
|
|
65
|
+
const arrowHeight = 8;
|
|
66
|
+
let popoverArrowTransform = `translateX(-50%) translateY(-40%) rotate(0deg)`;
|
|
67
|
+
let popoverArrowTop = -arrowHeight;
|
|
68
|
+
let popoverArrowLeft = left + this.popoverContent.clientWidth / 2 - arrowHeight / 2;
|
|
69
|
+
if (this.placement === "top") {
|
|
70
|
+
popoverTop = top + window.scrollY - this.popoverContent.clientHeight - arrowHeight;
|
|
71
|
+
if (this.getPopupContainerId && root) {
|
|
72
|
+
popoverTop = top - root.getBoundingClientRect().top - this.popoverContent.clientHeight;
|
|
73
|
+
popoverLeft = left - root.getBoundingClientRect().left;
|
|
74
|
+
}
|
|
75
|
+
popoverArrowTransform = "translateX(-50%) translateY(40%) rotate(180deg)";
|
|
76
|
+
popoverArrowTop = this.popoverContent.clientHeight - arrowHeight;
|
|
77
|
+
popoverArrowLeft = width / 2;
|
|
78
|
+
}
|
|
79
|
+
(_c = this.popoverArrow) == null ? void 0 : _c.style.setProperty("inset", `${popoverArrowTop}px auto auto ${popoverArrowLeft}px`);
|
|
80
|
+
(_d = this.popoverArrow) == null ? void 0 : _d.style.setProperty("transform", popoverArrowTransform);
|
|
81
|
+
this.popoverContent.style.setProperty("inset", `${popoverTop}px auto auto ${popoverLeft}px`);
|
|
82
|
+
});
|
|
83
|
+
__publicField(this, "hoverPopover", () => {
|
|
84
|
+
if (this.removePopoverTimeId) {
|
|
85
|
+
clearTimeout(this.removePopoverTimeId);
|
|
86
|
+
this.removePopoverTimeId = void 0;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
__publicField(this, "clickContent", (e) => {
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
});
|
|
92
|
+
__publicField(this, "clickPopover", (e) => {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
this.placementPosition();
|
|
95
|
+
});
|
|
96
|
+
__publicField(this, "clickRemovePopover", () => {
|
|
97
|
+
this.hoverRemovePopover();
|
|
98
|
+
});
|
|
99
|
+
__publicField(this, "popoverTrigger", () => {
|
|
100
|
+
this.removeEventListener("mouseenter", this.hoverPopover);
|
|
101
|
+
this.removeEventListener("click", this.hoverPopover);
|
|
102
|
+
this.removeEventListener("mouseleave", this.hoverRemovePopover);
|
|
103
|
+
this.removeEventListener("click", this.clickPopover);
|
|
104
|
+
document.removeEventListener("click", this.clickRemovePopover);
|
|
105
|
+
if (this.trigger === "hover") {
|
|
106
|
+
this.addEventListener("mouseenter", this.placementPosition);
|
|
107
|
+
this.addEventListener("mouseleave", this.hoverRemovePopover);
|
|
108
|
+
} else {
|
|
109
|
+
this.addEventListener("click", this.clickPopover);
|
|
110
|
+
document.addEventListener("click", this.clickRemovePopover);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
__publicField(this, "hoverRemovePopover", () => {
|
|
114
|
+
if (this.removePopoverTimeId) {
|
|
115
|
+
clearTimeout(this.removePopoverTimeId);
|
|
116
|
+
this.removePopoverTimeId = void 0;
|
|
117
|
+
}
|
|
118
|
+
this.removePopoverTimeId = setTimeout(() => {
|
|
119
|
+
var _a;
|
|
120
|
+
(_a = this.popoverContent) == null ? void 0 : _a.style.setProperty("opacity", "0");
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
var _a2;
|
|
123
|
+
(_a2 = this.popoverContent) == null ? void 0 : _a2.style.setProperty("display", "none");
|
|
124
|
+
}, 300);
|
|
125
|
+
}, 100);
|
|
126
|
+
});
|
|
127
|
+
this._slot = document.createElement("slot");
|
|
128
|
+
this.popoverBlock = document.createElement("div");
|
|
129
|
+
this.popoverBlock.setAttribute("class", "ran-popover-block");
|
|
130
|
+
this.popoverBlock.setAttribute("role", "tooltip");
|
|
131
|
+
this.popoverBlock.appendChild(this._slot);
|
|
132
|
+
}
|
|
133
|
+
static get observedAttributes() {
|
|
134
|
+
return ["placement", "arrow", "trigger"];
|
|
135
|
+
}
|
|
136
|
+
get placement() {
|
|
137
|
+
return this.getAttribute("placement") || "top";
|
|
138
|
+
}
|
|
139
|
+
set placement(value) {
|
|
140
|
+
this.setAttribute("placement", value);
|
|
141
|
+
}
|
|
142
|
+
get arrow() {
|
|
143
|
+
return this.getAttribute("arrow") || "";
|
|
144
|
+
}
|
|
145
|
+
set arrow(value) {
|
|
146
|
+
this.setAttribute("arrow", value);
|
|
147
|
+
}
|
|
148
|
+
get trigger() {
|
|
149
|
+
return this.getAttribute("trigger") || "";
|
|
150
|
+
}
|
|
151
|
+
set trigger(value) {
|
|
152
|
+
this.setAttribute("trigger", value);
|
|
153
|
+
}
|
|
154
|
+
get getPopupContainerId() {
|
|
155
|
+
return this.getAttribute("getPopupContainerId") || "";
|
|
156
|
+
}
|
|
157
|
+
set getPopupContainerId(value) {
|
|
158
|
+
this.setAttribute("getPopupContainerId", value);
|
|
159
|
+
}
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
this.setAttribute("class", "ran-popover");
|
|
162
|
+
this.appendChild(this.popoverBlock);
|
|
163
|
+
for (const element of this.children) {
|
|
164
|
+
if (element.tagName === "R-CONTENT") {
|
|
165
|
+
element.addEventListener("change", this.watchContent);
|
|
166
|
+
this.createContent(element.children);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
this.popoverTrigger();
|
|
170
|
+
}
|
|
171
|
+
disconnectCallback() {
|
|
172
|
+
var _a;
|
|
173
|
+
this.removeEventListener("mouseenter", this.hoverPopover);
|
|
174
|
+
this.removeEventListener("mouseleave", this.hoverRemovePopover);
|
|
175
|
+
this.removeEventListener("click", this.hoverPopover);
|
|
176
|
+
this.removeEventListener("click", this.placementPosition);
|
|
177
|
+
document.removeEventListener("click", this.clickRemovePopover);
|
|
178
|
+
(_a = this.popoverContent) == null ? void 0 : _a.removeEventListener("click", this.clickContent);
|
|
179
|
+
}
|
|
180
|
+
attributeChangedCallback(n, o, v) {
|
|
181
|
+
if (o !== v) {
|
|
182
|
+
if (n === "trigger") {
|
|
183
|
+
this.popoverTrigger();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function Custom() {
|
|
189
|
+
if (typeof document !== "undefined" && !customElements.get("r-popover")) {
|
|
190
|
+
customElements.define("r-popover", Popover);
|
|
191
|
+
return Popover;
|
|
192
|
+
} else {
|
|
193
|
+
return createCustomError("document is undefined or r-popover is exist");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const index = Custom();
|
|
197
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
198
|
+
__proto__: null,
|
|
199
|
+
Popover,
|
|
200
|
+
default: index
|
|
201
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
202
|
+
export {
|
|
203
|
+
Popover as P,
|
|
204
|
+
index as a,
|
|
205
|
+
index$1 as i
|
|
206
|
+
};
|