ranui 0.1.0-alpha
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/.vitepress/config.ts +26 -0
- package/.vitepress/theme/index.ts +9 -0
- package/assets/image/failImage.ts +4 -0
- package/assets/svgs/check-circle.svg +4 -0
- package/assets/svgs/close-circle.svg +4 -0
- package/assets/svgs/eye-close.svg +4 -0
- package/assets/svgs/eye.svg +4 -0
- package/assets/svgs/info-circle.svg +5 -0
- package/assets/svgs/lock.svg +4 -0
- package/assets/svgs/unlock.svg +4 -0
- package/assets/svgs/user.svg +3 -0
- package/components/button/index.less +95 -0
- package/components/button/index.ts +64 -0
- package/components/form/index.less +0 -0
- package/components/form/index.ts +36 -0
- package/components/image/index.less +0 -0
- package/components/image/index.ts +62 -0
- package/components/input/index.less +114 -0
- package/components/input/index.ts +367 -0
- package/components/modal/index.less +0 -0
- package/components/modal/index.ts +118 -0
- package/components/tabPane/index.less +0 -0
- package/components/tabPane/index.ts +71 -0
- package/components/tabs/index.less +47 -0
- package/components/tabs/index.ts +207 -0
- package/dist/assets/image/failImage.d.ts +2 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/modal/index.d.ts +2 -0
- package/dist/components/tabPane/index.d.ts +2 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +677 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.cjs +2 -0
- package/dist/index.umd.cjs.map +1 -0
- package/dist/style.css +1 -0
- package/dist/typings.d.ts +4 -0
- package/dist/utils/index.d.ts +7 -0
- package/docs/button/index.md +25 -0
- package/docs/image/index.md +9 -0
- package/docs/input/index.md +146 -0
- package/docs/tabs/index.md +121 -0
- package/index.html +67 -0
- package/index.md +1 -0
- package/index.ts +6 -0
- package/package.json +33 -0
- package/plugins/auto-import-file.ts +59 -0
- package/plugins/load-style.ts +31 -0
- package/tsconfig.json +31 -0
- package/typings.d.ts +4 -0
- package/utils/index.ts +12 -0
- package/vite.config.ts +58 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc$4 = ':host{position:relative;display:inline-block;font-weight:400;white-space:nowrap;text-align:center;background-image:none;border:1px solid transparent;box-shadow:0 2px #00000004;cursor:pointer;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;touch-action:manipulation;line-height:22px;font-size:14px;border-radius:2px;color:#000000d9;border-color:#d9d9d9;background:#fff;overflow:hidden;pointer-events:auto}:host,:host(:active),:host(:focus){outline:0}:host(:not([disabled]):hover){border-color:#1890ff;color:#1890ff}:host([type="primary"]){border-color:#1890ff;background-color:#1890ff;color:#fff}:host([type="primary"]:not([disabled])):after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="primary"]:not([disabled]):hover){background-color:#40a9ff;color:#fff}:host([type="warning"]){border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="warning"]:not([disabled])):after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="warning"]:not([disabled]):hover){border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="text"]){border:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host(:not([disabled]):active):after{transform:translate(-50%,-50%) scale(0);opacity:.3;transition:0s}:host(:active) .btn:before{opacity:.2}:host(:not([disabled])):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;margin:4px 15px}\n';
|
|
2
|
+
const falseList = [false, "false", null, void 0];
|
|
3
|
+
const isDisabled = (element) => {
|
|
4
|
+
const status = element.hasAttribute("disabled");
|
|
5
|
+
const value = element.getAttribute("disabled");
|
|
6
|
+
if (status && !falseList.includes(value))
|
|
7
|
+
return true;
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
class CustomElement$4 extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.mousedown = (event) => {
|
|
14
|
+
if (!this.disabled || this.disabled === "false") {
|
|
15
|
+
const { left, top } = this.getBoundingClientRect();
|
|
16
|
+
this.style.setProperty("--ran-x", event.clientX - left + "px");
|
|
17
|
+
this.style.setProperty("--ran-y", event.clientY - top + "px");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
this.mouseLeave = () => {
|
|
21
|
+
this.style.removeProperty("--ran-x");
|
|
22
|
+
this.style.removeProperty("--ran-y");
|
|
23
|
+
};
|
|
24
|
+
const slot = document.createElement("slot");
|
|
25
|
+
this._btn = document.createElement("div");
|
|
26
|
+
this._btn.appendChild(slot);
|
|
27
|
+
slot.setAttribute("class", "slot");
|
|
28
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
29
|
+
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
30
|
+
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc$4;
|
|
31
|
+
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
32
|
+
shadowRoot.appendChild(this._btn);
|
|
33
|
+
}
|
|
34
|
+
static get observedAttributes() {
|
|
35
|
+
return ["disabled", "type"];
|
|
36
|
+
}
|
|
37
|
+
get disabled() {
|
|
38
|
+
return isDisabled(this);
|
|
39
|
+
}
|
|
40
|
+
set disabled(value) {
|
|
41
|
+
if (!value || value === "false") {
|
|
42
|
+
this.removeAttribute("disabled");
|
|
43
|
+
} else {
|
|
44
|
+
this.setAttribute("disabled", "");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
connectedCallback() {
|
|
48
|
+
this._btn.addEventListener("mousedown", this.mousedown);
|
|
49
|
+
this._btn.addEventListener("mouseleave", this.mouseLeave);
|
|
50
|
+
}
|
|
51
|
+
disconnectCallback() {
|
|
52
|
+
this._btn.removeEventListener("mousedown", this.mousedown);
|
|
53
|
+
this._btn.removeEventListener("mouseleave", this.mouseLeave);
|
|
54
|
+
}
|
|
55
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
56
|
+
if (name == "disabled" && this._btn) {
|
|
57
|
+
if (!newValue || newValue === "false") {
|
|
58
|
+
this._btn.setAttribute("disabled", "");
|
|
59
|
+
} else {
|
|
60
|
+
this._btn.removeAttribute("disabled");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function Custom$2() {
|
|
66
|
+
if (!customElements.get("r-button")) {
|
|
67
|
+
customElements.define("r-button", CustomElement$4);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
Custom$2();
|
|
71
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc$3 = "";
|
|
72
|
+
class CustomElement$3 extends HTMLElement {
|
|
73
|
+
constructor() {
|
|
74
|
+
super();
|
|
75
|
+
this._container = document.createElement("div");
|
|
76
|
+
this._container.setAttribute("class", "r-image");
|
|
77
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
78
|
+
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
79
|
+
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc$3;
|
|
80
|
+
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
81
|
+
shadowRoot.appendChild(this._container);
|
|
82
|
+
}
|
|
83
|
+
static get observedAttributes() {
|
|
84
|
+
return ["fallback"];
|
|
85
|
+
}
|
|
86
|
+
get fallback() {
|
|
87
|
+
return this.getAttribute("fallback");
|
|
88
|
+
}
|
|
89
|
+
set fallback(value) {
|
|
90
|
+
if (value) {
|
|
91
|
+
this.setAttribute("fallback", value);
|
|
92
|
+
} else {
|
|
93
|
+
this.removeAttribute("fallback");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
listenFallback(name, value) {
|
|
97
|
+
if (name === "fallback" && this._image) {
|
|
98
|
+
if (value) {
|
|
99
|
+
this._image.setAttribute("fallback", value);
|
|
100
|
+
} else {
|
|
101
|
+
this._image.removeAttribute("fallback");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
connectedCallback() {
|
|
106
|
+
const src = this.getAttribute("src") || "";
|
|
107
|
+
this._image = new Image();
|
|
108
|
+
this._image.src = src;
|
|
109
|
+
this._image.addEventListener("error", () => {
|
|
110
|
+
if (this._image && this.fallback) {
|
|
111
|
+
this._image.src = this.fallback;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
this._image.addEventListener("load", () => {
|
|
115
|
+
if (this._image) {
|
|
116
|
+
this._container.appendChild(this._image);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
121
|
+
this.listenFallback(name, newValue);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function Custom$1() {
|
|
125
|
+
if (!customElements.get("r-img")) {
|
|
126
|
+
customElements.define("r-img", CustomElement$3);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
Custom$1();
|
|
130
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc$2 = '.input{position:relative;display:inline-block;width:100%;min-width:0;padding:2px 8px;color:#000000d9;font-size:12px;line-height:1.5715;background-color:#fff;background-image:none;border:1px solid #d9d9d9;border-radius:2px;transition:all .3s}.input:active{border-color:#40a9ff;box-shadow:0 0 0 2px #1890ff33;border-right-width:1px;outline:0}.input:hover{border-color:#40a9ff;border-right-width:1px}.input>.input-main:hover~.input-label{color:#40a9ff}.input[value]>.input-label{transform:translateY(calc(-50% - .43em)) scale(.8);color:#00000040}.input[disabled]{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.input[disabled]>.input-main{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.input[disabled]>.input-main:hover~.input-label{color:#999}.input[disabled]>.input-label{color:#999;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed}.input-main{writing-mode:horizontal-tb;text-rendering:auto;letter-spacing:normal;word-spacing:normal;text-transform:none;text-indent:0px;text-shadow:none;text-align:start;-webkit-rtl-ordering:logical;cursor:text;touch-action:manipulation;-webkit-appearance:none;text-overflow:ellipsis;box-sizing:border-box;margin:0;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";position:relative;border:none;width:100%;min-width:0;color:#000000d9;font-size:14px;line-height:1.5715;background-color:#fff;background-image:none;transition:all .3s}.input-main:focus,.input-main:hover{border:none;outline:0}.input-main::placeholder{color:#999}.input-main:placeholder-shown~.input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.input-main:focus~.input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.input-label{pointer-events:none;position:absolute;font-size:14px;left:8px;transition:transform .3s,color .3s,background-color .3s;transform-origin:left;padding:0 .2em;color:#999;backdrop-filter:blur(10px);opacity:.9}\n';
|
|
131
|
+
class CustomElement$2 extends HTMLElement {
|
|
132
|
+
constructor() {
|
|
133
|
+
super();
|
|
134
|
+
this.inputValue = (event) => {
|
|
135
|
+
event.stopPropagation();
|
|
136
|
+
const target = event.target;
|
|
137
|
+
this.value = target ? target.value : "";
|
|
138
|
+
this.dispatchEvent(
|
|
139
|
+
new CustomEvent("input", {
|
|
140
|
+
detail: {
|
|
141
|
+
value: this.value
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
this.change = () => {
|
|
147
|
+
this.dispatchEvent(
|
|
148
|
+
new CustomEvent("change", {
|
|
149
|
+
detail: {
|
|
150
|
+
value: this.value
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
this.focus = () => {
|
|
156
|
+
this.dispatchEvent(
|
|
157
|
+
new CustomEvent("focus", {
|
|
158
|
+
detail: {
|
|
159
|
+
value: this.value
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
this.checkout = () => {
|
|
165
|
+
};
|
|
166
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
167
|
+
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
168
|
+
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc$2;
|
|
169
|
+
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
170
|
+
this._container = document.createElement("div");
|
|
171
|
+
this._container.setAttribute("class", "input");
|
|
172
|
+
this._input = document.createElement("input");
|
|
173
|
+
this._input.setAttribute("class", "input-main");
|
|
174
|
+
this._container.appendChild(this._input);
|
|
175
|
+
shadowRoot.appendChild(this._container);
|
|
176
|
+
}
|
|
177
|
+
static get observedAttributes() {
|
|
178
|
+
return [
|
|
179
|
+
"label",
|
|
180
|
+
"disabled",
|
|
181
|
+
"name",
|
|
182
|
+
"pattern",
|
|
183
|
+
"required",
|
|
184
|
+
"placeholder",
|
|
185
|
+
"type"
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
get value() {
|
|
189
|
+
return this.getAttribute("value");
|
|
190
|
+
}
|
|
191
|
+
set value(value) {
|
|
192
|
+
if (!isDisabled(this) && value) {
|
|
193
|
+
this.setAttribute("value", value);
|
|
194
|
+
this._container.setAttribute("value", value);
|
|
195
|
+
} else {
|
|
196
|
+
this.removeAttribute("value");
|
|
197
|
+
this._container.removeAttribute("value");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
get placeholder() {
|
|
201
|
+
return this.getAttribute("placeholder");
|
|
202
|
+
}
|
|
203
|
+
set placeholder(value) {
|
|
204
|
+
if (value) {
|
|
205
|
+
this.setAttribute("placeholder", value);
|
|
206
|
+
} else {
|
|
207
|
+
this.removeAttribute("placeholder");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
get required() {
|
|
211
|
+
return this.getAttribute("required");
|
|
212
|
+
}
|
|
213
|
+
set required(value) {
|
|
214
|
+
if (!value || value === "false") {
|
|
215
|
+
this.removeAttribute("required");
|
|
216
|
+
} else {
|
|
217
|
+
this.setAttribute("required", "");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
get warning() {
|
|
221
|
+
return this.getAttribute("warning");
|
|
222
|
+
}
|
|
223
|
+
set warning(value) {
|
|
224
|
+
if (!value) {
|
|
225
|
+
this.removeAttribute("warning");
|
|
226
|
+
} else {
|
|
227
|
+
this.setAttribute("warning", value);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
get pattern() {
|
|
231
|
+
return this.getAttribute("pattern");
|
|
232
|
+
}
|
|
233
|
+
set pattern(value) {
|
|
234
|
+
if (!value || value === "false") {
|
|
235
|
+
this.removeAttribute("pattern");
|
|
236
|
+
} else {
|
|
237
|
+
this.setAttribute("pattern", value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
get disabled() {
|
|
241
|
+
return isDisabled(this);
|
|
242
|
+
}
|
|
243
|
+
set disabled(value) {
|
|
244
|
+
if (falseList.includes(value)) {
|
|
245
|
+
this.removeAttribute("disabled");
|
|
246
|
+
this._container.removeAttribute("disabled");
|
|
247
|
+
this._input.removeAttribute("disabled");
|
|
248
|
+
} else {
|
|
249
|
+
this.setAttribute("disabled", "");
|
|
250
|
+
this._container.setAttribute("disabled", "");
|
|
251
|
+
this._input.setAttribute("disabled", "");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
get label() {
|
|
255
|
+
return this.getAttribute("label") || "";
|
|
256
|
+
}
|
|
257
|
+
set label(value) {
|
|
258
|
+
this.setAttribute("label", value);
|
|
259
|
+
}
|
|
260
|
+
get name() {
|
|
261
|
+
return this.getAttribute("name") || "";
|
|
262
|
+
}
|
|
263
|
+
set name(value) {
|
|
264
|
+
this.setAttribute("name", value);
|
|
265
|
+
}
|
|
266
|
+
get icon() {
|
|
267
|
+
return this.getAttribute("icon");
|
|
268
|
+
}
|
|
269
|
+
set icon(value) {
|
|
270
|
+
if (value) {
|
|
271
|
+
this.setAttribute("icon", value);
|
|
272
|
+
} else {
|
|
273
|
+
this.removeAttribute("icon");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
get type() {
|
|
277
|
+
return this.getAttribute("type");
|
|
278
|
+
}
|
|
279
|
+
set type(value) {
|
|
280
|
+
if (value) {
|
|
281
|
+
this.setAttribute("type", value);
|
|
282
|
+
} else {
|
|
283
|
+
this.removeAttribute("type");
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
listenPlaceholder(name, value) {
|
|
287
|
+
if (name === "placeholder" && this._input) {
|
|
288
|
+
if (value !== null) {
|
|
289
|
+
this._input.setAttribute("placeholder", value);
|
|
290
|
+
} else {
|
|
291
|
+
this._input.removeAttribute("placeholder");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
listenRequired(name, value) {
|
|
296
|
+
if (name === "required" && this._input) {
|
|
297
|
+
if (value && value !== "false") {
|
|
298
|
+
this._input.setAttribute("required", "");
|
|
299
|
+
} else {
|
|
300
|
+
this._input.removeAttribute("required");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
listenPattern(name, value) {
|
|
305
|
+
if (name === "pattern" && this._input) {
|
|
306
|
+
if (value && value !== "false") {
|
|
307
|
+
this._input.setAttribute("pattern", value);
|
|
308
|
+
} else {
|
|
309
|
+
this._input.removeAttribute("pattern");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
listenLabel(name, value) {
|
|
314
|
+
if (name === "label" && this._input) {
|
|
315
|
+
if (value !== null) {
|
|
316
|
+
if (this._label) {
|
|
317
|
+
this._label.innerHTML = value;
|
|
318
|
+
} else {
|
|
319
|
+
this._label = document.createElement("label");
|
|
320
|
+
this._label.innerHTML = value;
|
|
321
|
+
this._label.setAttribute("class", "input-label");
|
|
322
|
+
this._container.appendChild(this._label);
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
this._container.removeAttribute("label");
|
|
326
|
+
if (this._label) {
|
|
327
|
+
this._container.removeChild(this._label);
|
|
328
|
+
this._label = void 0;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
listenType(name, value) {
|
|
334
|
+
if (name === "type" && this._input) {
|
|
335
|
+
if (value) {
|
|
336
|
+
this._input.setAttribute("type", value);
|
|
337
|
+
} else {
|
|
338
|
+
this._input.removeAttribute("type");
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
connectedCallback() {
|
|
343
|
+
if (this.value) {
|
|
344
|
+
this._input.value = this.value;
|
|
345
|
+
this._container.setAttribute("value", this.value);
|
|
346
|
+
}
|
|
347
|
+
if (isDisabled(this)) {
|
|
348
|
+
this._container.setAttribute("disabled", "");
|
|
349
|
+
this._input.setAttribute("disabled", "");
|
|
350
|
+
}
|
|
351
|
+
if (this.type) {
|
|
352
|
+
this._input.setAttribute("type", this.type);
|
|
353
|
+
}
|
|
354
|
+
this._input.addEventListener("input", this.inputValue);
|
|
355
|
+
this._input.addEventListener("change", this.change);
|
|
356
|
+
this._input.addEventListener("focus", this.focus);
|
|
357
|
+
}
|
|
358
|
+
disconnectCallback() {
|
|
359
|
+
this._input.removeEventListener("input", this.inputValue);
|
|
360
|
+
this._input.removeEventListener("change", this.change);
|
|
361
|
+
}
|
|
362
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
363
|
+
this.listenPlaceholder(name, newValue);
|
|
364
|
+
this.listenRequired(name, newValue);
|
|
365
|
+
this.listenPattern(name, newValue);
|
|
366
|
+
this.listenLabel(name, newValue);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function Custom() {
|
|
370
|
+
if (!customElements.get("r-input")) {
|
|
371
|
+
customElements.define("r-input", CustomElement$2);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
Custom();
|
|
375
|
+
function Modal() {
|
|
376
|
+
const template = document.createElement("template");
|
|
377
|
+
const div = document.createElement("div");
|
|
378
|
+
div.setAttribute("class", "modal-content");
|
|
379
|
+
const slot = document.createElement("slot");
|
|
380
|
+
slot.setAttribute("name", "modal-content");
|
|
381
|
+
div.appendChild(slot);
|
|
382
|
+
template == null ? void 0 : template.appendChild(div);
|
|
383
|
+
class Modal2 extends HTMLElement {
|
|
384
|
+
constructor() {
|
|
385
|
+
super();
|
|
386
|
+
const templateContent = template.content;
|
|
387
|
+
const shadowRoot = this.attachShadow({ mode: "open" });
|
|
388
|
+
const wrap = document.createElement("div");
|
|
389
|
+
const modal = document.createElement("div");
|
|
390
|
+
const header = document.createElement("header");
|
|
391
|
+
const btnClose = document.createElement("span");
|
|
392
|
+
const mask = document.createElement("div");
|
|
393
|
+
const footer = document.createElement("footer");
|
|
394
|
+
const btnCancel = document.createElement("xu-button");
|
|
395
|
+
const btnOk = document.createElement("xu-button");
|
|
396
|
+
wrap.setAttribute("class", "wrap");
|
|
397
|
+
modal.setAttribute("class", "xu-modal");
|
|
398
|
+
let title = this.getAttribute("title");
|
|
399
|
+
header.textContent = title;
|
|
400
|
+
btnClose.setAttribute("class", "xu-close");
|
|
401
|
+
btnClose.textContent = "x";
|
|
402
|
+
header.appendChild(btnClose);
|
|
403
|
+
modal.appendChild(header);
|
|
404
|
+
btnClose.addEventListener("click", () => {
|
|
405
|
+
wrap.style.display = "none";
|
|
406
|
+
});
|
|
407
|
+
modal.appendChild(templateContent.cloneNode(true));
|
|
408
|
+
btnOk.setAttribute("type", "primary");
|
|
409
|
+
const slot1 = document.createElement("span");
|
|
410
|
+
slot1.setAttribute("slot", "btn-content");
|
|
411
|
+
slot1.textContent = "\u786E\u8BA4";
|
|
412
|
+
btnOk.appendChild(slot1);
|
|
413
|
+
const slot2 = document.createElement("span");
|
|
414
|
+
slot2.setAttribute("slot", "btn-content");
|
|
415
|
+
slot2.textContent = "\u53D6\u6D88";
|
|
416
|
+
btnCancel.appendChild(slot2);
|
|
417
|
+
footer.appendChild(btnCancel);
|
|
418
|
+
footer.appendChild(btnOk);
|
|
419
|
+
modal.appendChild(footer);
|
|
420
|
+
mask.setAttribute("class", "mask");
|
|
421
|
+
wrap.appendChild(mask);
|
|
422
|
+
wrap.appendChild(modal);
|
|
423
|
+
const style = document.createElement("style");
|
|
424
|
+
this.getAttribute("width");
|
|
425
|
+
const isVisible = this.getAttribute("visible");
|
|
426
|
+
style.textContent = `
|
|
427
|
+
.wrap {
|
|
428
|
+
position: fixed;
|
|
429
|
+
left: 0;
|
|
430
|
+
right: 0;
|
|
431
|
+
bottom: 0;
|
|
432
|
+
top: 0;
|
|
433
|
+
display: ${isVisible === "true" ? "block" : "none"}
|
|
434
|
+
}
|
|
435
|
+
// \u5FFD\u7565\u90E8\u5206\u6837\u5F0F
|
|
436
|
+
`;
|
|
437
|
+
shadowRoot.appendChild(style);
|
|
438
|
+
shadowRoot.appendChild(wrap);
|
|
439
|
+
}
|
|
440
|
+
connectedCallback(el) {
|
|
441
|
+
console.log("insert dom", el);
|
|
442
|
+
}
|
|
443
|
+
disconnectedCallback() {
|
|
444
|
+
console.log("Custom square element removed from page.");
|
|
445
|
+
}
|
|
446
|
+
adoptedCallback() {
|
|
447
|
+
console.log("Custom square element moved to new page.");
|
|
448
|
+
}
|
|
449
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
450
|
+
var _a;
|
|
451
|
+
if (oldValue && this.shadowRoot) {
|
|
452
|
+
const children = [...this.shadowRoot.children];
|
|
453
|
+
for (let i = 0; i < children.length; i++) {
|
|
454
|
+
if (children[i].nodeName === "DIV" && ((_a = children[i]) == null ? void 0 : _a.className) === "wrap") {
|
|
455
|
+
if (newValue === "true") {
|
|
456
|
+
children[i].style.display = "block";
|
|
457
|
+
} else {
|
|
458
|
+
children[i].style.display = "none";
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
static get observedAttributes() {
|
|
465
|
+
return ["visible"];
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
window.customElements.define("xu-modal", Modal2);
|
|
469
|
+
}
|
|
470
|
+
Modal();
|
|
471
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc$1 = "";
|
|
472
|
+
class TabPane extends HTMLElement {
|
|
473
|
+
constructor() {
|
|
474
|
+
super();
|
|
475
|
+
this._div = document.createElement("slot");
|
|
476
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
477
|
+
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
478
|
+
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc$1;
|
|
479
|
+
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
480
|
+
shadowRoot.appendChild(this._div);
|
|
481
|
+
}
|
|
482
|
+
static get observedAttributes() {
|
|
483
|
+
return ["label", "key", "disabled", "icon"];
|
|
484
|
+
}
|
|
485
|
+
get label() {
|
|
486
|
+
return this.getAttribute("label") || "";
|
|
487
|
+
}
|
|
488
|
+
set label(value) {
|
|
489
|
+
this.setAttribute("label", value);
|
|
490
|
+
}
|
|
491
|
+
get icon() {
|
|
492
|
+
return this.getAttribute("icon");
|
|
493
|
+
}
|
|
494
|
+
get key() {
|
|
495
|
+
return this.getAttribute("key");
|
|
496
|
+
}
|
|
497
|
+
set key(value) {
|
|
498
|
+
if (value) {
|
|
499
|
+
this.setAttribute("key", value);
|
|
500
|
+
} else {
|
|
501
|
+
this.removeAttribute("key");
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
get disabled() {
|
|
505
|
+
return this.getAttribute("disabled");
|
|
506
|
+
}
|
|
507
|
+
set disabled(value) {
|
|
508
|
+
if (!value || value === "false") {
|
|
509
|
+
this.removeAttribute("disabled");
|
|
510
|
+
} else {
|
|
511
|
+
this.setAttribute("disabled", value);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
onClick(e) {
|
|
515
|
+
console.log("e", e);
|
|
516
|
+
}
|
|
517
|
+
connectedCallback() {
|
|
518
|
+
this._div.addEventListener("click", this.onClick);
|
|
519
|
+
}
|
|
520
|
+
disconnectCallback() {
|
|
521
|
+
}
|
|
522
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function CustomElement$1() {
|
|
526
|
+
if (!customElements.get("r-tab")) {
|
|
527
|
+
customElements.define("r-tab", TabPane);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
CustomElement$1();
|
|
531
|
+
const f7170ee498e0dd32cbdcb63fba8f75cc = ".tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto}.tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.tab-header_nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.tab-header_line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--themeColor, #1890ff);transition:.2s}.tab-content{overflow:hidden}.tab-content_wrap{display:flex;width:100%;height:100%;transition:.2s}\n";
|
|
532
|
+
class Tabs extends HTMLElement {
|
|
533
|
+
constructor() {
|
|
534
|
+
super();
|
|
535
|
+
this.initTabHeaderKeyMapIndex = (key, index) => {
|
|
536
|
+
const value = this.tabHeaderKeyMapIndex[key];
|
|
537
|
+
if (value) {
|
|
538
|
+
throw new Error("tab \u7EC4\u4EF6\u7684 key \u503C\u5B58\u5728\u91CD\u590D, \u6216\u8005\u67D0\u4E2A tab \u7EC4\u4EF6\u7F3A\u5C11 key \u5C5E\u6027");
|
|
539
|
+
} else {
|
|
540
|
+
this.tabHeaderKeyMapIndex[key] = index;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
this.setTabLine = (key) => {
|
|
544
|
+
if (key) {
|
|
545
|
+
const index = this.tabHeaderKeyMapIndex[key];
|
|
546
|
+
this._line.style.setProperty("transform", `translateX(${100 * index}%)`);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
this.setTabContent = (key) => {
|
|
550
|
+
if (key) {
|
|
551
|
+
const index = this.tabHeaderKeyMapIndex[key];
|
|
552
|
+
this._wrap.style.setProperty("transform", `translateX(${index * -100}%)`);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
this.clickTabHead = (e) => {
|
|
556
|
+
const tabHeader = e.target;
|
|
557
|
+
const key = tabHeader.getAttribute("ran-key");
|
|
558
|
+
const disabled = isDisabled(tabHeader);
|
|
559
|
+
if (!disabled && key) {
|
|
560
|
+
this.setAttribute("active", key);
|
|
561
|
+
this.setTabLine(key);
|
|
562
|
+
this.setTabContent(key);
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
this.initActive = () => {
|
|
566
|
+
const tabHeaderList = [...this._nav.children];
|
|
567
|
+
const initTabHeader = tabHeaderList.filter((item) => !isDisabled(item)).shift();
|
|
568
|
+
if (!initTabHeader)
|
|
569
|
+
return;
|
|
570
|
+
const index = tabHeaderList.findIndex((item) => item === initTabHeader);
|
|
571
|
+
const key = (initTabHeader == null ? void 0 : initTabHeader.getAttribute("ran-key")) || `${index}`;
|
|
572
|
+
if (this.active === null && key !== null) {
|
|
573
|
+
this.setAttribute("active", `${key}`);
|
|
574
|
+
const { width = 0 } = initTabHeader.getBoundingClientRect();
|
|
575
|
+
this._line.style.setProperty("width", `${width}px`);
|
|
576
|
+
this.setTabLine(key);
|
|
577
|
+
this.setTabContent(key);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
this.listenSlotChange = () => {
|
|
581
|
+
const slots = this._slot.assignedElements();
|
|
582
|
+
slots.forEach((item, index) => {
|
|
583
|
+
const tabPane = this.createTabHeader(item, index);
|
|
584
|
+
this._nav.appendChild(tabPane);
|
|
585
|
+
tabPane.addEventListener("click", this.clickTabHead);
|
|
586
|
+
});
|
|
587
|
+
this.initActive();
|
|
588
|
+
};
|
|
589
|
+
this._container = document.createElement("div");
|
|
590
|
+
this._container.setAttribute("class", "tab");
|
|
591
|
+
this._header = document.createElement("div");
|
|
592
|
+
this._header.setAttribute("class", "tab-header");
|
|
593
|
+
this._nav = document.createElement("div");
|
|
594
|
+
this._nav.setAttribute("class", "tab-header_nav");
|
|
595
|
+
this._line = document.createElement("div");
|
|
596
|
+
this._line.setAttribute("class", "tab-header_line");
|
|
597
|
+
this._content = document.createElement("div");
|
|
598
|
+
this._content.setAttribute("class", "tab-content");
|
|
599
|
+
this._wrap = document.createElement("div");
|
|
600
|
+
this._wrap.setAttribute("class", "tab-content_wrap");
|
|
601
|
+
this._slot = document.createElement("slot");
|
|
602
|
+
this._wrap.appendChild(this._slot);
|
|
603
|
+
this._content.appendChild(this._wrap);
|
|
604
|
+
this._header.appendChild(this._nav);
|
|
605
|
+
this._header.appendChild(this._line);
|
|
606
|
+
this._container.appendChild(this._header);
|
|
607
|
+
this._container.appendChild(this._content);
|
|
608
|
+
this.tabHeaderKeyMapIndex = {};
|
|
609
|
+
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
610
|
+
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
611
|
+
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
|
|
612
|
+
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
613
|
+
shadowRoot.appendChild(this._container);
|
|
614
|
+
}
|
|
615
|
+
static get observedAttributes() {
|
|
616
|
+
return ["active", "forceRender"];
|
|
617
|
+
}
|
|
618
|
+
get align() {
|
|
619
|
+
return this.getAttribute("align") || "start";
|
|
620
|
+
}
|
|
621
|
+
set align(value) {
|
|
622
|
+
this.setAttribute("align", value);
|
|
623
|
+
}
|
|
624
|
+
get type() {
|
|
625
|
+
return this.getAttribute("type") || "flat";
|
|
626
|
+
}
|
|
627
|
+
get active() {
|
|
628
|
+
return this.getAttribute("active");
|
|
629
|
+
}
|
|
630
|
+
set active(value) {
|
|
631
|
+
if (value) {
|
|
632
|
+
this.setAttribute("active", value);
|
|
633
|
+
this.setTabLine(value);
|
|
634
|
+
this.setTabContent(value);
|
|
635
|
+
} else {
|
|
636
|
+
this.removeAttribute("active");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
set type(value) {
|
|
640
|
+
this.setAttribute("type", value);
|
|
641
|
+
}
|
|
642
|
+
createTabHeader(tabPane, index) {
|
|
643
|
+
const label = tabPane.getAttribute("label") || "";
|
|
644
|
+
const key = tabPane.getAttribute("key") || `${index}`;
|
|
645
|
+
const type = tabPane.getAttribute("type") || "text";
|
|
646
|
+
this.initTabHeaderKeyMapIndex(key, index);
|
|
647
|
+
const tabHeader = document.createElement("r-button");
|
|
648
|
+
tabHeader.setAttribute("class", "tab-header_nav__item");
|
|
649
|
+
tabHeader.setAttribute("type", type);
|
|
650
|
+
isDisabled(tabPane) && tabHeader.setAttribute("disabled", "");
|
|
651
|
+
tabHeader.setAttribute("ran-key", key);
|
|
652
|
+
tabHeader.innerHTML = label;
|
|
653
|
+
return tabHeader;
|
|
654
|
+
}
|
|
655
|
+
connectedCallback() {
|
|
656
|
+
this._slot.addEventListener("slotchange", this.listenSlotChange);
|
|
657
|
+
}
|
|
658
|
+
disconnectCallback() {
|
|
659
|
+
this._slot.removeEventListener("slotchange", this.listenSlotChange);
|
|
660
|
+
}
|
|
661
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
662
|
+
if (oldValue !== newValue) {
|
|
663
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
664
|
+
detail: {
|
|
665
|
+
active: this.active
|
|
666
|
+
}
|
|
667
|
+
}));
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function CustomElement() {
|
|
672
|
+
if (!customElements.get("r-tabs")) {
|
|
673
|
+
customElements.define("r-tabs", Tabs);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
CustomElement();
|
|
677
|
+
//# sourceMappingURL=index.js.map
|