litos-ui 0.23.0 → 0.24.0
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.md +2 -2
- package/README.zh-CN.md +2 -2
- package/lib/base.d.ts +3 -2
- package/lib/base.js +11 -8
- package/lib/button/index.d.ts +21 -5
- package/lib/button/index.js +115 -62
- package/lib/button/index.less_inline.js +2 -3
- package/lib/button/style.js +1 -2
- package/lib/calendar/index.d.ts +1 -0
- package/lib/calendar/index.js +19 -17
- package/lib/calendar/index.less_inline.js +1 -2
- package/lib/calendar/langs.js +21 -11
- package/lib/card/index.js +8 -9
- package/lib/card/index.less_inline.js +1 -2
- package/lib/carousel/index.js +10 -11
- package/lib/carousel/index.less_inline.js +1 -2
- package/lib/carousel/item.js +1 -2
- package/lib/carousel/item.less_inline.js +1 -2
- package/lib/carousel/timer.js +1 -2
- package/lib/check/check.d.ts +40 -8
- package/lib/check/check.js +200 -65
- package/lib/check/check.less_inline.js +2 -3
- package/lib/check/checkbox.js +2 -3
- package/lib/check/checkbox.less_inline.js +2 -3
- package/lib/check/checkbox_group.js +1 -2
- package/lib/check/index.d.ts +28 -8
- package/lib/check/index.js +151 -46
- package/lib/check/index.less_inline.js +1 -2
- package/lib/check/radio.js +2 -3
- package/lib/check/radio.less_inline.js +1 -2
- package/lib/check/radio_group.js +2 -3
- package/lib/collapse/index.d.ts +12 -4
- package/lib/collapse/index.js +80 -46
- package/lib/collapse/index.less_inline.js +2 -3
- package/lib/collapse/item.d.ts +35 -9
- package/lib/collapse/item.js +219 -57
- package/lib/collapse/item.less_inline.js +2 -3
- package/lib/collapse/types.d.ts +17 -3
- package/lib/color_picker/index.d.ts +4 -2
- package/lib/color_picker/index.js +26 -17
- package/lib/color_picker/index.less_inline.js +1 -2
- package/lib/date_picker/index.d.ts +5 -1
- package/lib/date_picker/index.js +39 -23
- package/lib/date_picker/index.less_inline.js +1 -2
- package/lib/date_picker_ori/index.d.ts +7 -2
- package/lib/date_picker_ori/index.js +123 -47
- package/lib/date_picker_ori/index.less_inline.js +1 -2
- package/lib/description_panel/index.js +2 -10
- package/lib/description_panel/index.less_inline.js +1 -2
- package/lib/dialog/dialog_box.js +28 -29
- package/lib/dialog/dialog_container.css_inline.js +1 -2
- package/lib/dialog/dialog_container.js +13 -14
- package/lib/dialog/dialog_container_style.js +1 -2
- package/lib/dialog/index.d.ts +2 -0
- package/lib/dialog/index.js +11 -9
- package/lib/dropdown/index.d.ts +39 -0
- package/lib/dropdown/index.js +98 -0
- package/lib/entries/base.js +1 -2
- package/lib/entries/button.js +5 -6
- package/lib/entries/calendar.js +5 -6
- package/lib/entries/card.js +5 -6
- package/lib/entries/carousel-item.js +5 -6
- package/lib/entries/carousel.js +5 -6
- package/lib/entries/checkbox-group.js +5 -6
- package/lib/entries/checkbox.js +5 -6
- package/lib/entries/collapse-item.d.ts +0 -1
- package/lib/entries/collapse-item.js +6 -6
- package/lib/entries/collapse.d.ts +0 -1
- package/lib/entries/collapse.js +11 -6
- package/lib/entries/color-picker.js +5 -6
- package/lib/entries/date-picker-ori.js +5 -6
- package/lib/entries/date-picker.js +5 -6
- package/lib/entries/description-panel.js +5 -6
- package/lib/entries/dialog-box.js +1 -2
- package/lib/entries/dialog-container.js +5 -6
- package/lib/entries/dialog.js +1 -2
- package/lib/entries/dropdown.d.ts +2 -0
- package/lib/entries/dropdown.js +1 -0
- package/lib/entries/form-item.js +5 -6
- package/lib/entries/form.js +5 -6
- package/lib/entries/icon-arrow-down.js +5 -6
- package/lib/entries/icon-arrow-left.js +5 -6
- package/lib/entries/icon-arrow-right.js +5 -6
- package/lib/entries/icon-arrow-up.js +5 -6
- package/lib/entries/icon-base.js +5 -6
- package/lib/entries/icon-calendar.js +5 -6
- package/lib/entries/icon-caret-bottom.js +5 -6
- package/lib/entries/icon-caret-top.js +5 -6
- package/lib/entries/icon-close-filled.js +5 -6
- package/lib/entries/icon-close.js +5 -6
- package/lib/entries/icon-copy.js +5 -6
- package/lib/entries/icon-d-arrow-left.js +5 -6
- package/lib/entries/icon-d-arrow-right.js +5 -6
- package/lib/entries/icon-delete.js +5 -6
- package/lib/entries/icon-eye-outline.js +5 -6
- package/lib/entries/icon-font-icon.js +5 -6
- package/lib/entries/icon-info.js +5 -6
- package/lib/entries/icon-loading.js +5 -6
- package/lib/entries/icon-minus.js +5 -6
- package/lib/entries/icon-moon.js +5 -6
- package/lib/entries/icon-more.js +5 -6
- package/lib/entries/icon-picture.js +5 -6
- package/lib/entries/icon-plus.js +5 -6
- package/lib/entries/icon-reduction.js +5 -6
- package/lib/entries/icon-refresh-left.js +5 -6
- package/lib/entries/icon-refresh-right.js +5 -6
- package/lib/entries/icon-refresh.js +5 -6
- package/lib/entries/icon-search.js +5 -6
- package/lib/entries/icon-select.js +5 -6
- package/lib/entries/icon-sort.js +5 -6
- package/lib/entries/icon-success.js +5 -6
- package/lib/entries/icon-sun.js +5 -6
- package/lib/entries/icon-theme-default.js +5 -6
- package/lib/entries/icon-warn.js +5 -6
- package/lib/entries/icon-zoom-in.js +5 -6
- package/lib/entries/icon-zoom-out.js +5 -6
- package/lib/entries/image-preview.js +5 -6
- package/lib/entries/image.js +5 -6
- package/lib/entries/input-number.js +5 -6
- package/lib/entries/input.js +5 -6
- package/lib/entries/list.js +5 -6
- package/lib/entries/loading.js +1 -2
- package/lib/entries/mask.js +5 -6
- package/lib/entries/md-input.js +5 -6
- package/lib/entries/menu.js +5 -6
- package/lib/entries/message.js +1 -2
- package/lib/entries/modal-box.js +1 -2
- package/lib/entries/modal.js +5 -6
- package/lib/entries/notification-box.js +1 -2
- package/lib/entries/notification.js +1 -2
- package/lib/entries/page-header.js +5 -6
- package/lib/entries/pagination.js +5 -6
- package/lib/entries/polygon.js +5 -6
- package/lib/entries/popconfirm.js +1 -2
- package/lib/entries/popover.js +1 -2
- package/lib/entries/qrcode.js +5 -6
- package/lib/entries/radio-group.js +5 -6
- package/lib/entries/radio.js +5 -6
- package/lib/entries/select-ori.js +5 -6
- package/lib/entries/select.js +5 -6
- package/lib/entries/space.js +5 -6
- package/lib/entries/switch.js +5 -6
- package/lib/entries/tabbar-item.js +5 -6
- package/lib/entries/tabbar.js +5 -6
- package/lib/entries/table.js +5 -6
- package/lib/entries/tabs.js +1 -2
- package/lib/entries/tag.js +5 -6
- package/lib/entries/theme-color.js +5 -6
- package/lib/entries/theme.js +5 -6
- package/lib/entries/transition.js +1 -2
- package/lib/entries/upload.js +5 -6
- package/lib/entries/utils.js +1 -2
- package/lib/form/accessibility.d.ts +15 -0
- package/lib/form/accessibility.js +56 -0
- package/lib/form/autocomplete.d.ts +21 -0
- package/lib/form/autocomplete.js +59 -0
- package/lib/form/context.d.ts +157 -0
- package/lib/form/context.js +88 -0
- package/lib/form/form_inner.d.ts +99 -24
- package/lib/form/form_inner.js +424 -72
- package/lib/form/form_item.d.ts +35 -11
- package/lib/form/form_item.js +210 -78
- package/lib/form/form_item.less_inline.js +2 -3
- package/lib/form/form_item_style.d.ts +3 -0
- package/lib/form/form_item_style.js +7 -0
- package/lib/form/index.d.ts +69 -15
- package/lib/form/index.js +501 -101
- package/lib/form/index.less_inline.js +1 -2
- package/lib/form/owner.d.ts +78 -0
- package/lib/form/owner.js +138 -0
- package/lib/form/style.d.ts +3 -0
- package/lib/form/style.js +7 -0
- package/lib/icon/arrow_down.js +1 -2
- package/lib/icon/arrow_left.js +1 -2
- package/lib/icon/arrow_right.js +1 -2
- package/lib/icon/arrow_up.js +1 -2
- package/lib/icon/base.js +1 -2
- package/lib/icon/calendar.js +1 -2
- package/lib/icon/caret_bottom.js +1 -2
- package/lib/icon/caret_top.js +1 -2
- package/lib/icon/close.js +1 -2
- package/lib/icon/close_filled.js +1 -2
- package/lib/icon/copy.js +1 -2
- package/lib/icon/d_arrow_left.js +1 -2
- package/lib/icon/d_arrow_right.js +1 -2
- package/lib/icon/delete.js +1 -2
- package/lib/icon/eye_outline.js +1 -2
- package/lib/icon/font_icon.js +1 -2
- package/lib/icon/icon_style.js +1 -2
- package/lib/icon/index.less_inline.js +1 -2
- package/lib/icon/info.js +1 -2
- package/lib/icon/loading.js +1 -2
- package/lib/icon/minus.js +1 -2
- package/lib/icon/moon.js +1 -2
- package/lib/icon/more.js +1 -2
- package/lib/icon/picture.js +1 -2
- package/lib/icon/plus.js +1 -2
- package/lib/icon/reduction.js +1 -2
- package/lib/icon/refresh.js +1 -2
- package/lib/icon/refresh_left.js +1 -2
- package/lib/icon/refresh_right.js +1 -2
- package/lib/icon/search.js +1 -2
- package/lib/icon/select.js +1 -2
- package/lib/icon/sort.js +1 -2
- package/lib/icon/success.js +1 -2
- package/lib/icon/sun.js +1 -2
- package/lib/icon/theme_default.js +1 -2
- package/lib/icon/warn.js +1 -2
- package/lib/icon/zoom_in.js +1 -2
- package/lib/icon/zoom_out.js +1 -2
- package/lib/image/image_preview.js +1 -2
- package/lib/image/image_preview.less_inline.js +1 -2
- package/lib/image/index.js +1 -2
- package/lib/image/index.less_inline.js +1 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +88 -87
- package/lib/input/index.d.ts +18 -1
- package/lib/input/index.js +151 -48
- package/lib/input/index.less_inline.js +2 -3
- package/lib/input/input_inner.less_inline.js +1 -2
- package/lib/input/style.d.ts +3 -0
- package/lib/input/style.js +7 -0
- package/lib/input_number/index.d.ts +7 -0
- package/lib/input_number/index.js +70 -48
- package/lib/input_number/index.less_inline.js +1 -2
- package/lib/input_number/style.js +1 -2
- package/lib/list/index.js +4 -5
- package/lib/list/index.less_inline.js +1 -2
- package/lib/loading/index.js +1 -2
- package/lib/mask/index.js +2 -7
- package/lib/mask/index.less_inline.js +1 -2
- package/lib/md_input/index.d.ts +11 -2
- package/lib/md_input/index.js +63 -27
- package/lib/md_input/index.less_inline.js +2 -3
- package/lib/menu/index.js +2 -7
- package/lib/menu/index.less_inline.js +1 -2
- package/lib/message/index.js +1 -2
- package/lib/modal/index.js +15 -16
- package/lib/modal/index.less_inline.js +1 -2
- package/lib/modal/modal_box.js +24 -25
- package/lib/notification/index.js +15 -29
- package/lib/notification/index.less_inline.js +1 -2
- package/lib/notification/notification_box.js +2 -3
- package/lib/notification/placement.js +1 -2
- package/lib/notification/style.js +1 -2
- package/lib/page_header/index.js +1 -2
- package/lib/page_header/index.less_inline.js +1 -2
- package/lib/pagination/index.js +26 -25
- package/lib/pagination/index.less_inline.js +2 -3
- package/lib/polygon/index.js +1 -2
- package/lib/polygon/index.less_inline.js +1 -2
- package/lib/qrcode/index.js +1 -2
- package/lib/qrcode/index.less_inline.js +1 -2
- package/lib/select/index.d.ts +21 -2
- package/lib/select/index.js +138 -77
- package/lib/select/index.less_inline.js +1 -2
- package/lib/select_ori/index.d.ts +9 -1
- package/lib/select_ori/index.js +36 -24
- package/lib/select_ori/index.less_inline.js +1 -2
- package/lib/space/index.js +1 -2
- package/lib/space/index.less_inline.js +1 -2
- package/lib/styles/animation/index.css_inline.js +1 -2
- package/lib/styles/animation/index.js +1 -2
- package/lib/styles/mask/index.css_inline.js +1 -2
- package/lib/styles/mask/index.js +1 -2
- package/lib/switch/index.d.ts +6 -0
- package/lib/switch/index.js +31 -16
- package/lib/switch/index.less_inline.js +1 -2
- package/lib/tabbar/index.js +1 -2
- package/lib/tabbar/index.less_inline.js +1 -2
- package/lib/tabbar/item.js +1 -2
- package/lib/tabbar/item.less_inline.js +1 -2
- package/lib/table/index.d.ts +2 -0
- package/lib/table/index.js +12 -4
- package/lib/table/index.less_inline.js +1 -2
- package/lib/tabs/index.js +1 -2
- package/lib/tag/index.d.ts +11 -3
- package/lib/tag/index.js +25 -24
- package/lib/tag/index.less_inline.js +2 -3
- package/lib/theme/appearance.d.ts +5 -0
- package/lib/theme/appearance.js +34 -0
- package/lib/theme/index.js +83 -39
- package/lib/theme/index.less_inline.js +1 -2
- package/lib/theme/theme_color.js +1 -2
- package/lib/upload/index.js +28 -41
- package/lib/upload/index.less_inline.js +2 -3
- package/lib/upload/style.js +1 -2
- package/lib/utils/clickoutside.js +1 -2
- package/lib/utils/event.js +1 -2
- package/lib/utils/index.d.ts +27 -5
- package/lib/utils/index.js +43 -22
- package/lib/utils/popover.js +7 -16
- package/lib/utils/transition.js +1 -2
- package/package.json +16 -13
- package/styles/dark.css +10 -2
- package/styles/dropdown.css +46 -0
- package/styles/reset.css +0 -1
- package/styles/select.css +5 -0
- package/styles/themes/apple.css +47 -0
- package/styles/{theme-coral.css → themes/coral.css} +5 -3
- package/styles/themes/deep-sea-blue.css +12 -0
- package/styles/themes/gamboge.css +15 -0
- package/styles/{theme-jade.css → themes/jade.css} +5 -3
- package/styles/themes/lotus-seed.css +12 -0
- package/styles/{theme-tangerine.css → themes/tangerine.css} +5 -3
- package/styles/themes.css +8 -0
- package/styles/vars.css +8 -2
- package/types/preact.d.ts +43 -0
- package/lib/form/types.d.ts +0 -7
- package/lib/utils/context_provide.d.ts +0 -10
- package/lib/utils/context_provide.js +0 -22
- package/lib/utils/signal_types.d.ts +0 -5
package/lib/theme/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import e from "../base.js";
|
|
2
2
|
import { initAttr as t } from "../utils/index.js";
|
|
3
|
-
import n from "./
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { applyThemeMode as n, observeTheme as r } from "./appearance.js";
|
|
4
|
+
import i from "./index.less_inline.js";
|
|
5
|
+
import { $one as a, create as o, getTheme as s, off as c, on as l } from "utilane/browser";
|
|
6
|
+
// src/components/theme/index.ts
|
|
7
|
+
var u = [
|
|
7
8
|
{
|
|
8
9
|
value: "auto",
|
|
9
10
|
text: "跟随系统",
|
|
@@ -19,68 +20,111 @@ var l = [
|
|
|
19
20
|
text: "深色模式",
|
|
20
21
|
icon: "l-moon-icon"
|
|
21
22
|
}
|
|
22
|
-
],
|
|
23
|
+
], d = /* @__PURE__ */ new WeakMap();
|
|
24
|
+
function f(e, t) {
|
|
25
|
+
let n = d.get(e);
|
|
26
|
+
if (n?.pending) {
|
|
27
|
+
n.pending = t;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (n || !e.startViewTransition) {
|
|
31
|
+
t.apply().catch(console.error);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let r = { pending: t };
|
|
35
|
+
d.set(e, r);
|
|
36
|
+
let i = e.startViewTransition(() => {
|
|
37
|
+
let e = r.pending;
|
|
38
|
+
return r.pending = void 0, e?.apply();
|
|
39
|
+
});
|
|
40
|
+
i.ready.catch(() => {}), i.finished.then(() => d.delete(e), (t) => {
|
|
41
|
+
d.delete(e), console.error(t);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
var p = class extends e {
|
|
23
45
|
static baseName = "theme";
|
|
24
46
|
type = "button";
|
|
25
47
|
label = "text";
|
|
26
48
|
theme;
|
|
27
49
|
#e;
|
|
50
|
+
#t;
|
|
28
51
|
connectedCallback() {
|
|
29
|
-
t(this), this.theme =
|
|
52
|
+
t(this), this.theme = s(), this.loadStyleText(i), super.connectedCallback(), this.#l(), this.#t = r(this.ownerDocument, this.#s);
|
|
30
53
|
}
|
|
31
54
|
disconnectedCallback() {
|
|
32
|
-
super.disconnectedCallback(), this.#
|
|
55
|
+
this.#t?.(), this.#t = void 0, super.disconnectedCallback(), this.#u();
|
|
33
56
|
}
|
|
34
57
|
render() {
|
|
35
58
|
switch (this.type) {
|
|
36
|
-
case "select": return this.#
|
|
37
|
-
case "radio": return this.#
|
|
38
|
-
case "switch": return this.#
|
|
39
|
-
default: return this.#
|
|
59
|
+
case "select": return this.#i();
|
|
60
|
+
case "radio": return this.#o();
|
|
61
|
+
case "switch": return this.#a();
|
|
62
|
+
default: return this.#n();
|
|
40
63
|
}
|
|
41
64
|
}
|
|
42
|
-
#
|
|
43
|
-
let e =
|
|
44
|
-
return this.#
|
|
65
|
+
#n() {
|
|
66
|
+
let e = o("l-button", { class: "l-theme-btn l-theme-inner" });
|
|
67
|
+
return this.#r(e), e;
|
|
45
68
|
}
|
|
46
|
-
#
|
|
69
|
+
#r(e) {
|
|
47
70
|
let t = this.theme === "auto" ? "sun" : "moon";
|
|
48
71
|
e.innerHTML = `<l-${t}-icon></l-${t}-icon>`;
|
|
49
72
|
}
|
|
50
|
-
#r() {
|
|
51
|
-
let e = a("l-select-ori", { class: "l-theme-inner" });
|
|
52
|
-
return e.value = this.theme, e.innerHTML = [
|
|
53
|
-
"<option value=\"auto\">跟随系统</option>",
|
|
54
|
-
"<option value=\"light\">浅色模式</option>",
|
|
55
|
-
"<option value=\"dark\">深色模式</option>"
|
|
56
|
-
].join(""), e;
|
|
57
|
-
}
|
|
58
73
|
#i() {
|
|
59
|
-
let e =
|
|
60
|
-
return e.value = this.theme
|
|
74
|
+
let e = o("l-select-ori", { class: "l-theme-inner" });
|
|
75
|
+
return e.value = this.theme, e.innerHTML = "<option value=\"auto\">跟随系统</option><option value=\"light\">浅色模式</option><option value=\"dark\">深色模式</option>", e;
|
|
61
76
|
}
|
|
62
77
|
#a() {
|
|
63
|
-
let e =
|
|
64
|
-
return e.value = this.theme, e.innerHTML = l
|
|
78
|
+
let e = o("l-switch", { class: "l-theme-switch l-theme-inner" });
|
|
79
|
+
return e.value = this.theme === "dark", e.innerHTML = "<l-sun-icon slot=\"unchecked-action\"></l-sun-icon><l-moon-icon slot=\"checked-action\"></l-moon-icon>", e;
|
|
80
|
+
}
|
|
81
|
+
#o() {
|
|
82
|
+
let e = o("l-radio-group", { class: "l-theme-inner" });
|
|
83
|
+
return e.value = this.theme, e.innerHTML = u.map((e) => {
|
|
65
84
|
let t = "";
|
|
66
85
|
return t = this.label === "icon" ? `<${e.icon}></${e.icon}>` : e.text, `<l-radio value="${e.value}" button>${t}</l-radio>`;
|
|
67
86
|
}).join(""), e;
|
|
68
87
|
}
|
|
69
|
-
#
|
|
70
|
-
let t;
|
|
71
|
-
if (
|
|
88
|
+
#s = (e) => {
|
|
89
|
+
let t = this.#e;
|
|
90
|
+
if (t) {
|
|
91
|
+
if (this.theme = e, this.type === "button") this.#r(t);
|
|
92
|
+
else {
|
|
93
|
+
let n = this.type === "switch" ? e === "dark" : e;
|
|
94
|
+
t.value !== n && (t.value = n);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
#c = (e) => {
|
|
99
|
+
e.type === "change" && e.stopPropagation();
|
|
100
|
+
let t = this.#e;
|
|
101
|
+
if (!t) return;
|
|
102
|
+
let r = this.ownerDocument, i = d.get(r)?.pending?.value ?? s(), a;
|
|
103
|
+
if (this.type === "button") a = i === "dark" ? "auto" : "dark";
|
|
72
104
|
else {
|
|
73
|
-
let
|
|
74
|
-
|
|
105
|
+
let e = t.value;
|
|
106
|
+
a = this.type === "switch" ? e ? "dark" : "light" : e;
|
|
75
107
|
}
|
|
76
|
-
|
|
108
|
+
if (a !== "auto" && a !== "light" && a !== "dark") return;
|
|
109
|
+
let o = a;
|
|
110
|
+
o !== i && f(r, {
|
|
111
|
+
value: o,
|
|
112
|
+
apply: async () => {
|
|
113
|
+
let e = s() !== o;
|
|
114
|
+
e && await n(r, o), this.isConnected && this.#e === t && e && this.emit("change", { detail: o });
|
|
115
|
+
}
|
|
116
|
+
});
|
|
77
117
|
};
|
|
78
|
-
#
|
|
79
|
-
this.#e =
|
|
118
|
+
#l() {
|
|
119
|
+
if (this.#e = a(".l-theme-inner", this.root), this.type === "button") l(this.#e, "click", this.#c);
|
|
120
|
+
else {
|
|
121
|
+
this.keepChangeLocal(this.#e);
|
|
122
|
+
for (let e of this.#e.querySelectorAll("l-radio")) this.keepChangeLocal(e);
|
|
123
|
+
l(this.#e, "change", this.#c);
|
|
124
|
+
}
|
|
80
125
|
}
|
|
81
|
-
#
|
|
82
|
-
this.#e &&= (this.type === "button" ?
|
|
126
|
+
#u() {
|
|
127
|
+
this.#e &&= (this.type === "button" ? c(this.#e, "click", this.#c) : c(this.#e, "change", this.#c), void 0);
|
|
83
128
|
}
|
|
84
129
|
};
|
|
85
|
-
|
|
86
|
-
export { u as default };
|
|
130
|
+
export { p as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/theme/index.less?inline
|
|
2
2
|
var e = ":host{box-sizing:border-box;width:auto;display:inline-flex}.l-theme-btn::part(default){--l-btn-background:transparent;--l-btn-hover-background:transparent;--l-btn-text-color:#9ca3af;--l-btn-hover-text-color:#666;width:var(--l-form-control-height,32px);padding:0;font-size:18px}.l-theme-switch.l-switch--checked{background-color:#65757129;border-color:#3c3f44}.l-theme-switch.l-switch--checked::part(action){color:#fff;background-color:#000}html.dark .l-theme-btn{--l-btn-hover-text-color:#fff}";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { e as default };
|
package/lib/theme/theme_color.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import e from "../base.js";
|
|
2
2
|
import { $one as t, applyColorTheme as n, getColorTheme as r, on as i } from "utilane/browser";
|
|
3
|
-
|
|
3
|
+
// src/components/theme/theme_color.ts
|
|
4
4
|
var a = class extends e {
|
|
5
5
|
static baseName = "theme-color";
|
|
6
6
|
constructor() {
|
|
@@ -18,5 +18,4 @@ var a = class extends e {
|
|
|
18
18
|
this._state.color = t, await n(t), this.emit("change", { detail: t });
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { a as default };
|
package/lib/upload/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import e from "../
|
|
2
|
-
import
|
|
1
|
+
import { kebabToCamel as e, parseAttrValue as t } from "../utils/index.js";
|
|
2
|
+
import n from "../base.js";
|
|
3
3
|
import r from "../styles/animation/index.js";
|
|
4
4
|
import i from "./style.js";
|
|
5
5
|
import { $$ as a, $one as o, addClass as s, formatClass as c, off as l, on as u, removeClass as d } from "utilane/browser";
|
|
6
|
-
|
|
6
|
+
// src/components/upload/index.ts
|
|
7
7
|
var f = (e) => {
|
|
8
8
|
if (!e || typeof e != "object") return;
|
|
9
9
|
let t = e;
|
|
@@ -48,7 +48,7 @@ function p(e, t, n) {
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
var m = 0, h = class h extends
|
|
51
|
+
var m = 0, h = class h extends n {
|
|
52
52
|
static baseName = "upload";
|
|
53
53
|
$input;
|
|
54
54
|
$trigger;
|
|
@@ -218,11 +218,11 @@ var m = 0, h = class h extends e {
|
|
|
218
218
|
"with-credentials"
|
|
219
219
|
];
|
|
220
220
|
}
|
|
221
|
-
attributeChanged(
|
|
222
|
-
switch (
|
|
221
|
+
attributeChanged(n, r, i) {
|
|
222
|
+
switch (n) {
|
|
223
223
|
case "accept":
|
|
224
224
|
case "action":
|
|
225
|
-
this._state[
|
|
225
|
+
this._state[e(n)] = i ?? "";
|
|
226
226
|
break;
|
|
227
227
|
case "list-type":
|
|
228
228
|
this._state.listType = i === "picture" || i === "picture-card" ? i : "text";
|
|
@@ -233,20 +233,20 @@ var m = 0, h = class h extends e {
|
|
|
233
233
|
case "auto-upload":
|
|
234
234
|
case "show-file-list":
|
|
235
235
|
case "with-credentials":
|
|
236
|
-
this._state[
|
|
236
|
+
this._state[e(n)] = t(i, n === "auto-upload" || n === "show-file-list", n);
|
|
237
237
|
break;
|
|
238
238
|
case "max-size":
|
|
239
239
|
case "max-count":
|
|
240
240
|
case "timeout": {
|
|
241
|
-
let
|
|
242
|
-
this._state[
|
|
241
|
+
let t = i == null ? 0 : Number(i);
|
|
242
|
+
this._state[e(n)] = this._validLimit(t, n) ? t : 0;
|
|
243
243
|
break;
|
|
244
244
|
}
|
|
245
245
|
case "headers":
|
|
246
246
|
case "data": try {
|
|
247
|
-
this._state[
|
|
247
|
+
this._state[n] = this._validateRecord(i == null ? void 0 : JSON.parse(i), n);
|
|
248
248
|
} catch {
|
|
249
|
-
this._state[
|
|
249
|
+
this._state[e(n)] = {};
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
}
|
|
@@ -331,11 +331,8 @@ var m = 0, h = class h extends e {
|
|
|
331
331
|
raw: e.raw
|
|
332
332
|
} : void 0;
|
|
333
333
|
let t = o("slot", this.$trigger), n = o(".l-upload-trigger-image", this.$trigger), r = o(".l-upload-trigger-status", this.$trigger);
|
|
334
|
-
if (t && (t.hidden = !!e), !e)
|
|
335
|
-
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
if (e.status === "fail") {
|
|
334
|
+
if (t && (t.hidden = !!e), !e) n?.remove(), r?.remove();
|
|
335
|
+
else if (e.status === "fail") {
|
|
339
336
|
if (n?.remove(), !r || !o("l-picture-icon", r)) {
|
|
340
337
|
r?.remove();
|
|
341
338
|
let e = a("div", {
|
|
@@ -346,9 +343,7 @@ var m = 0, h = class h extends e {
|
|
|
346
343
|
});
|
|
347
344
|
e.appendChild(a("l-picture-icon", { "aria-hidden": "true" })), this.$trigger.appendChild(e);
|
|
348
345
|
}
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
n || (n = a("img", {
|
|
346
|
+
} else n || (n = a("img", {
|
|
352
347
|
class: "l-upload-trigger-image",
|
|
353
348
|
part: "image"
|
|
354
349
|
}), this.$trigger.appendChild(n)), this._updateImage(n, e), this._appendPictureProgress(this.$trigger, e);
|
|
@@ -368,14 +363,14 @@ var m = 0, h = class h extends e {
|
|
|
368
363
|
r.textContent !== i && (r.textContent = i), this._updateProgressBar(o(".l-upload-trigger-progress", n), t, "l-upload-trigger-progress");
|
|
369
364
|
}
|
|
370
365
|
_handleTriggerKeydown = (e) => {
|
|
371
|
-
e.target
|
|
366
|
+
e.target === this.$trigger && ["Enter", " "].includes(e.key) && (e.preventDefault(), this._handleClick());
|
|
372
367
|
};
|
|
373
368
|
_handleClick = () => {
|
|
374
|
-
this._state.disabled
|
|
369
|
+
!this._state.disabled && this.$input && (this._state.listType === "picture-card" && this._state.maxCount > 0 && this._state.fileList.length >= this._state.maxCount || this.$input.click());
|
|
375
370
|
};
|
|
376
371
|
_handleInputChange = (e) => {
|
|
377
372
|
let t = e.target, n = t.files;
|
|
378
|
-
|
|
373
|
+
n && n.length !== 0 && (this._handleFiles(n), t.value = "");
|
|
379
374
|
};
|
|
380
375
|
_acceptsFile(e) {
|
|
381
376
|
let t = this._state.accept.split(",").map((e) => e.trim().toLowerCase()).filter((e) => /^\.[^\s,/.]+(?:\.[^\s,/.]+)*$/.test(e) || /^[a-z0-9!#$&^_.+-]+\/(?:[a-z0-9!#$&^_.+-]+|\*)$/.test(e));
|
|
@@ -451,7 +446,7 @@ var m = 0, h = class h extends e {
|
|
|
451
446
|
o(".l-upload-list", this.root)?.remove(), this._fileNodes.clear(), this._listElement = void 0, this._listMode = void 0;
|
|
452
447
|
return;
|
|
453
448
|
}
|
|
454
|
-
|
|
449
|
+
this._listElement && this._listMode === this._state.listType || (o(".l-upload-list", this.root)?.remove(), this._fileNodes.clear(), this._listElement = a("div", {
|
|
455
450
|
class: this._state.listType === "picture-card" ? "l-upload-list l-upload-list-picture-card" : "l-upload-list l-upload-list-text",
|
|
456
451
|
part: "list"
|
|
457
452
|
}), this._listMode = this._state.listType, this._state.listType === "picture-card" && this.$trigger?.parentElement ? this.$trigger.parentElement.insertBefore(this._listElement, this.$trigger) : (o(".l-upload", this.root) || this.root).appendChild(this._listElement));
|
|
@@ -486,11 +481,7 @@ var m = 0, h = class h extends e {
|
|
|
486
481
|
}
|
|
487
482
|
_updateTextProgress(e, t) {
|
|
488
483
|
let n = o(".l-upload-list-item-progress", e);
|
|
489
|
-
|
|
490
|
-
n?.remove();
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
n || (n = a("div", { class: "l-upload-list-item-progress" }), n.appendChild(this._createProgressBar(t, "l-upload-list-item-progress-bar")), e.appendChild(n)), this._updateProgressBar(o(".l-upload-list-item-progress-bar", n), t, "l-upload-list-item-progress-bar");
|
|
484
|
+
t.status === "uploading" ? (n || (n = a("div", { class: "l-upload-list-item-progress" }), n.appendChild(this._createProgressBar(t, "l-upload-list-item-progress-bar")), e.appendChild(n)), this._updateProgressBar(o(".l-upload-list-item-progress-bar", n), t, "l-upload-list-item-progress-bar")) : n?.remove();
|
|
494
485
|
}
|
|
495
486
|
_renderFileItem(e) {
|
|
496
487
|
if (this._state.listType === "picture-card") return this._renderPictureCard(e);
|
|
@@ -604,10 +595,10 @@ var m = 0, h = class h extends e {
|
|
|
604
595
|
e && !this._dragBound ? (u(this, "dragenter", this._onDragEnter), u(this, "dragover", this._onDragOver), u(this, "dragleave", this._onDragLeave), u(this, "drop", this._onDrop), this._dragBound = !0) : !e && this._dragBound && (l(this, "dragenter", this._onDragEnter), l(this, "dragover", this._onDragOver), l(this, "dragleave", this._onDragLeave), l(this, "drop", this._onDrop), this._dragBound = !1);
|
|
605
596
|
}
|
|
606
597
|
_onDragEnter = (e) => {
|
|
607
|
-
e.preventDefault(),
|
|
598
|
+
e.preventDefault(), this._state.disabled || s(this, "l-upload-dragover");
|
|
608
599
|
};
|
|
609
600
|
_onDragOver = (e) => {
|
|
610
|
-
e.preventDefault(),
|
|
601
|
+
e.preventDefault(), this._state.disabled || s(this, "l-upload-dragover");
|
|
611
602
|
};
|
|
612
603
|
_onDragLeave = (e) => {
|
|
613
604
|
e.preventDefault(), d(this, "l-upload-dragover");
|
|
@@ -619,7 +610,7 @@ var m = 0, h = class h extends e {
|
|
|
619
610
|
};
|
|
620
611
|
handlePreview(e) {
|
|
621
612
|
let t = this._state.fileList.find((t) => t.id === e.id);
|
|
622
|
-
if (
|
|
613
|
+
if (t && t.status === "success" && !this._state.disabled) {
|
|
623
614
|
if (this._state.listType === "picture-card") {
|
|
624
615
|
let e = this._state.fileList.filter((e) => e.status === "success").map((e) => ({
|
|
625
616
|
id: e.id,
|
|
@@ -647,7 +638,7 @@ var m = 0, h = class h extends e {
|
|
|
647
638
|
}
|
|
648
639
|
upload(e) {
|
|
649
640
|
let t = e || this._state.fileList.filter((e) => e.status === "ready");
|
|
650
|
-
if (
|
|
641
|
+
if ((this._state.action || this._customRequest) && t.length !== 0) for (let e of t) {
|
|
651
642
|
let t = this._state.fileList.find((t) => t.id === e.id);
|
|
652
643
|
t && this._uploadFile(t);
|
|
653
644
|
}
|
|
@@ -662,11 +653,8 @@ var m = 0, h = class h extends e {
|
|
|
662
653
|
_currentRequest(e, t) {
|
|
663
654
|
let n = this._requests.get(e);
|
|
664
655
|
if (n?.token === t) {
|
|
665
|
-
if (this._destroyed || !this._state.fileList.includes(n.file))
|
|
666
|
-
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
return n;
|
|
656
|
+
if (this._destroyed || !this._state.fileList.includes(n.file)) this._disposeRequest(e);
|
|
657
|
+
else return n;
|
|
670
658
|
}
|
|
671
659
|
}
|
|
672
660
|
_clearRequestTimeout(e) {
|
|
@@ -689,7 +677,7 @@ var m = 0, h = class h extends e {
|
|
|
689
677
|
let i = this._currentRequest(e, t);
|
|
690
678
|
if (!i) return;
|
|
691
679
|
let { file: a, status: o } = i;
|
|
692
|
-
this._disposeRequest(e), !
|
|
680
|
+
this._disposeRequest(e), !this._destroyed && this._state.fileList.includes(a) && (a.status = "fail", this._syncPreview(this._state.fileList), this._renderFileList(), this.emit("error", { detail: {
|
|
693
681
|
file: a,
|
|
694
682
|
status: o,
|
|
695
683
|
phase: n,
|
|
@@ -721,7 +709,7 @@ var m = 0, h = class h extends e {
|
|
|
721
709
|
}
|
|
722
710
|
_reportProgress(e, t, n) {
|
|
723
711
|
let r = this._currentRequest(e, t);
|
|
724
|
-
|
|
712
|
+
r && r.phase === "upload" && Number.isFinite(n) && (r.file.percentage = Math.max(0, Math.min(100, n)), this._updateFileProgress(r.file), this.emit("progress", { detail: {
|
|
725
713
|
file: r.file,
|
|
726
714
|
percent: r.file.percentage
|
|
727
715
|
} }));
|
|
@@ -844,5 +832,4 @@ var m = 0, h = class h extends e {
|
|
|
844
832
|
}
|
|
845
833
|
}
|
|
846
834
|
};
|
|
847
|
-
//#endregion
|
|
848
835
|
export { h as default, f as defaultUploadResponseParser };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
var e = ":host{width:var(--l-upload-width,100%);height:var(--l-upload-height,auto);box-sizing:border-box;font-size:var(--l-upload-font-size,14px);color:var(--l-upload-text-color,var(--l-text-color,#000000e0));display:block}.l-upload-trigger--picture,.l-upload-trigger--picture-card{box-sizing:border-box;cursor:pointer;width:var(--l-upload-picture-size,90px);height:var(--l-upload-picture-size,90px);border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));border:1px dashed var(--l-upload-border-color,var(--l-border-color,#d9d9d9));color:var(--l-upload-border-color,var(--l-border-color,#d9d9d9));justify-content:center;align-items:center;font-size:20px;transition:color .3s,border-color .3s;display:flex;position:relative;overflow:hidden}.l-upload-trigger--picture:not(.l-upload-trigger--disabled):hover,.l-upload-trigger--picture-card:not(.l-upload-trigger--disabled):hover{color:var(--l-upload-border-hover-color,var(--l-primary-color,#007bff));border-color:var(--l-upload-border-hover-color,var(--l-primary-color,#007bff))}.l-upload-trigger-image{object-fit:contain;width:100%;height:100%;display:block}.l-upload-trigger-status{color:#fff;text-align:center;pointer-events:none;background:#00000073;flex-direction:column;justify-content:center;align-items:center;gap:6px;padding:4px;font-size:12px;display:flex;position:absolute;inset:0}.l-upload-trigger-status l-picture-icon{font-size:24px}.l-upload-trigger-progress{background:var(--l-upload-progress-color,var(--l-primary-color,#007bff));height:3px;transition:width .3s;position:absolute;bottom:0;left:0}.l-upload-progress--indeterminate{animation:1.2s ease-in-out infinite l-upload-indeterminate}.l-upload-list-item-progress{overflow:hidden}@keyframes l-upload-indeterminate{0%{transform:translate(-100%)}to{transform:translate(300%)}}@media (prefers-reduced-motion:reduce){.l-upload-progress--indeterminate{animation:none}}.l-upload-trigger--fail,.l-upload-trigger--fail:hover{color:var(--l-upload-error-color,var(--l-error-color,#f5222d));border-color:var(--l-upload-error-color,var(--l-error-color,#f5222d))}.l-upload-trigger--fail .l-upload-trigger-status,.l-upload-trigger--fail:hover .l-upload-trigger-status{color:inherit;background:var(--l-upload-background,#fff)}.l-upload-tip{color:var(--l-upload-text-secondary-color,var(--l-text-secondary-color,#
|
|
3
|
-
//#endregion
|
|
1
|
+
// src/components/upload/index.less?inline
|
|
2
|
+
var e = ":host{width:var(--l-upload-width,100%);height:var(--l-upload-height,auto);box-sizing:border-box;font-size:var(--l-upload-font-size,14px);color:var(--l-upload-text-color,var(--l-text-color,#000000e0));display:block}.l-upload-trigger--picture,.l-upload-trigger--picture-card{box-sizing:border-box;cursor:pointer;width:var(--l-upload-picture-size,90px);height:var(--l-upload-picture-size,90px);border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));border:1px dashed var(--l-upload-border-color,var(--l-border-color,#d9d9d9));color:var(--l-upload-border-color,var(--l-border-color,#d9d9d9));justify-content:center;align-items:center;font-size:20px;transition:color .3s,border-color .3s;display:flex;position:relative;overflow:hidden}.l-upload-trigger--picture:not(.l-upload-trigger--disabled):hover,.l-upload-trigger--picture-card:not(.l-upload-trigger--disabled):hover{color:var(--l-upload-border-hover-color,var(--l-primary-color,#007bff));border-color:var(--l-upload-border-hover-color,var(--l-primary-color,#007bff))}.l-upload-trigger-image{object-fit:contain;width:100%;height:100%;display:block}.l-upload-trigger-status{color:#fff;text-align:center;pointer-events:none;background:#00000073;flex-direction:column;justify-content:center;align-items:center;gap:6px;padding:4px;font-size:12px;display:flex;position:absolute;inset:0}.l-upload-trigger-status l-picture-icon{font-size:24px}.l-upload-trigger-progress{background:var(--l-upload-progress-color,var(--l-primary-color,#007bff));height:3px;transition:width .3s;position:absolute;bottom:0;left:0}.l-upload-progress--indeterminate{animation:1.2s ease-in-out infinite l-upload-indeterminate}.l-upload-list-item-progress{overflow:hidden}@keyframes l-upload-indeterminate{0%{transform:translate(-100%)}to{transform:translate(300%)}}@media (prefers-reduced-motion:reduce){.l-upload-progress--indeterminate{animation:none}}.l-upload-trigger--fail,.l-upload-trigger--fail:hover{color:var(--l-upload-error-color,var(--l-error-color,#f5222d));border-color:var(--l-upload-error-color,var(--l-error-color,#f5222d))}.l-upload-trigger--fail .l-upload-trigger-status,.l-upload-trigger--fail:hover .l-upload-trigger-status{color:inherit;background:var(--l-upload-background,#fff)}.l-upload-tip{color:var(--l-upload-text-secondary-color,var(--l-text-secondary-color,#000000a6));margin-top:5px;font-size:12px}.l-upload-trigger--drag.l-upload-trigger--text{border:1px dashed var(--l-upload-border-color,var(--l-border-color,#d9d9d9));border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));background-color:var(--l-upload-background,#fff);padding:12px 8px;transition:border-color .3s,background-color .3s}:host(.l-upload-dragover) .l-upload-trigger:not(.l-upload-trigger--disabled){border-color:var(--l-upload-border-hover-color,var(--l-primary-color,#007bff));background-color:var(--l-upload-dragover-background,var(--l-primary-color-light5,#e6f2ff))}.l-upload-trigger.l-upload-trigger--disabled,.l-upload-trigger.l-upload-trigger--disabled:hover{cursor:not-allowed;color:var(--l-upload-disabled-color,var(--l-disabled-color,#c9c9c9));background-color:var(--l-upload-disabled-background,#fbfbfb);border-color:var(--l-upload-disabled-border-color,var(--l-disabled-color,#e6e6e6));opacity:.6}.l-upload-input{display:none}.l-upload-list{margin-top:5px}.l-upload-list-item{position:relative}.l-upload-list-text .l-upload-list-item{min-height:var(--l-upload-list-item-height,32px);box-sizing:border-box;border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));justify-content:space-between;align-items:center;padding:4px 7px;transition:background-color .3s;display:flex}.l-upload-list-text .l-upload-list-item:hover{background-color:var(--l-upload-list-hover-background,#0000000a)}.l-upload-list-text .l-upload-list-item-info{flex:1;align-items:center;gap:8px;min-width:0;margin-right:10px;display:flex}.l-upload-list-text .l-upload-list-item-name{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.l-upload-list-text .l-upload-list-item-size{color:var(--l-upload-text-secondary-color,var(--l-text-secondary-color,#000000a6));flex-shrink:0;font-size:12px}.l-upload-list-item--uploading .l-upload-list-item-progress{background:#0000001a;height:2px;position:absolute;bottom:0;left:0;right:0}.l-upload-list-item--uploading .l-upload-list-item-progress-bar{background:var(--l-upload-progress-color,var(--l-primary-color,#007bff));height:100%;transition:width .3s}.l-upload-list-item--success .l-upload-list-item-name{color:var(--l-upload-success-color,var(--l-success-color,#52c41a))}.l-upload-list-item--fail .l-upload-list-item-name{color:var(--l-upload-error-color,var(--l-error-color,#f5222d))}.l-upload--close{border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));width:24px;height:24px;color:var(--l-upload-text-color,var(--l-text-color,#000000e0));font-size:inherit;cursor:pointer;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;transition:color .3s;display:inline-flex}.l-upload--close:not(:disabled):hover{color:var(--l-upload-border-hover-color,var(--l-primary-color,#007bff))}.l-upload--close:focus-visible{outline:2px solid var(--l-primary-color,#007bff);outline-offset:1px}.l-upload--close:disabled{cursor:not-allowed;color:var(--l-upload-disabled-color,var(--l-disabled-color,#c9c9c9));opacity:.6}.l-upload-items{display:contents}.l-upload-items--picture-card{flex-wrap:wrap;align-items:flex-start;gap:10px;display:flex}.l-upload-items--picture-card .l-upload-list-picture-card{display:contents}.l-upload-items--picture-card .l-upload-trigger{flex:none}.l-upload-card{box-sizing:border-box;width:var(--l-upload-picture-size,90px);height:var(--l-upload-picture-size,90px);border:1px solid var(--l-upload-border-color,var(--l-border-color,#d9d9d9));border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));color:var(--l-upload-text-secondary-color,var(--l-text-secondary-color,#000000a6));flex:none;justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.l-upload-card--fail{border-color:var(--l-upload-error-color,var(--l-error-color,#f5222d));color:var(--l-upload-error-color,var(--l-error-color,#f5222d))}.l-upload-card .l-upload-card-error{font-size:24px}.l-upload-card-actions{opacity:0;pointer-events:none;background:#00000080;justify-content:center;align-items:center;gap:5px;transition:opacity .2s;display:flex;position:absolute;inset:0}.l-upload-card:hover .l-upload-card-actions,.l-upload-card:focus-within .l-upload-card-actions{opacity:1;pointer-events:auto}.l-upload-card-action{border-radius:var(--l-upload-border-radius,var(--l-border-radius,3px));color:#fff;cursor:pointer;background:0 0;border:0;justify-content:center;align-items:center;width:30px;height:30px;font-size:20px;display:inline-flex}.l-upload-card-action:not(:disabled):hover{color:var(--l-primary-color,#007bff)}.l-upload-card-action:focus-visible{outline:2px solid var(--l-primary-color,#007bff);outline-offset:-2px}.l-upload-card-action:disabled{cursor:not-allowed;opacity:.5}.l-upload-trigger:focus-visible{outline:2px solid var(--l-primary-color,#007bff);outline-offset:2px}@media (hover:none){.l-upload-card-actions{opacity:1;pointer-events:auto}}";
|
|
4
3
|
export { e as default };
|
package/lib/upload/style.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import e from "./index.less_inline.js";
|
|
2
|
-
|
|
2
|
+
// src/components/upload/style.ts
|
|
3
3
|
var t = /* @__PURE__ */ (() => {
|
|
4
4
|
let t = new CSSStyleSheet();
|
|
5
5
|
return t.replaceSync(e), t;
|
|
6
6
|
})();
|
|
7
|
-
//#endregion
|
|
8
7
|
export { t as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/utils/clickoutside.ts
|
|
2
2
|
var e = /* @__PURE__ */ new Map();
|
|
3
3
|
function t(t) {
|
|
4
4
|
for (let r of e.values()) for (let e of r) n(t, e);
|
|
@@ -18,5 +18,4 @@ function r(n, r) {
|
|
|
18
18
|
function i(n) {
|
|
19
19
|
e.delete(n), e.size === 0 && document.removeEventListener("click", t, !0);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { i as remove, r as set };
|
package/lib/utils/event.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/utils/event.ts
|
|
2
2
|
var e;
|
|
3
3
|
function t(t, n, r) {
|
|
4
4
|
e ??= /* @__PURE__ */ new Map(), e.has(t) || e.set(t, /* @__PURE__ */ new Map([[n, /* @__PURE__ */ new Set()]])), e.get(t).has(n) || e.get(t).set(n, /* @__PURE__ */ new Set()), e.get(t).get(n).add(r);
|
|
@@ -13,5 +13,4 @@ function i(t, n, ...r) {
|
|
|
13
13
|
let i = e?.get(t)?.get(n);
|
|
14
14
|
if (i != null) for (let e of i) e(...r);
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { t as add, r as clear, i as emit, n as remove };
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SignalStop } from "./signal_types";
|
|
2
1
|
/**
|
|
3
2
|
* 注册 Web Components 组件
|
|
4
3
|
* @param component Web Components 组件
|
|
@@ -13,9 +12,9 @@ export declare function regist(component: any | any[], name?: string): void;
|
|
|
13
12
|
* @returns 唯一标识符字符串
|
|
14
13
|
*/
|
|
15
14
|
export declare function useId(): string;
|
|
16
|
-
export declare function parseAttrValue(value: string, defaultValue?: string): string;
|
|
17
|
-
export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
|
|
18
|
-
export declare function parseAttrValue(value: string, defaultValue?: number): number;
|
|
15
|
+
export declare function parseAttrValue(value: string | null | undefined, defaultValue?: string): string;
|
|
16
|
+
export declare function parseAttrValue(value: string | null | undefined, defaultValue?: boolean, key?: string): boolean;
|
|
17
|
+
export declare function parseAttrValue(value: string | null | undefined, defaultValue?: number): number;
|
|
19
18
|
/**
|
|
20
19
|
* 初始化元素的属性值。
|
|
21
20
|
* 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。
|
|
@@ -37,5 +36,28 @@ export declare function setAttrs(el: HTMLElement, attrs: [string, string | undef
|
|
|
37
36
|
* @returns
|
|
38
37
|
*/
|
|
39
38
|
export declare function kebabToCamel(attr: string): string;
|
|
40
|
-
|
|
39
|
+
/** 兼容非表单组件的旧清理入口;仅调用清理函数,不依赖 signal 类型或运行时。 */
|
|
40
|
+
export declare function stopSignal(fn?: () => void): undefined;
|
|
41
41
|
export declare function unitNumberStr(value?: string | null | undefined, unit?: string): string | null | undefined;
|
|
42
|
+
/** Button 支持的自定义颜色变量,可只覆盖其中一部分。 */
|
|
43
|
+
export type ButtonColor = Partial<Record<"--l-btn-border-color" | "--l-btn-text-color" | "--l-btn-hover-text-color" | "--l-btn-background" | "--l-btn-active-text-color" | "--l-btn-hover-border-color" | "--l-btn-hover-background" | "--l-btn-active-background" | "--l-btn-active-border-color", string>>;
|
|
44
|
+
/**
|
|
45
|
+
* 按需生成普通、文本或幽灵按钮的颜色变量,不修改按钮或 DOM。
|
|
46
|
+
* 仅调用此函数时进行颜色调整;普通按钮无需引入颜色计算。
|
|
47
|
+
*
|
|
48
|
+
* @param {string} color 基础颜色,使用 adjust 支持的颜色字符串,例如 "#00AA7E";空字符串返回空对象。
|
|
49
|
+
* @param {boolean} [text=false] 是否生成文本按钮配色;为 true 时背景和边框透明,文字随交互状态变色。
|
|
50
|
+
* @param {boolean} [ghost=false] 是否生成幽灵按钮配色;为 true 时背景透明,文字和边框随交互状态变色。
|
|
51
|
+
* text 与 ghost 同为 true 时,按文本按钮处理(边框透明)。
|
|
52
|
+
* @returns {ButtonColor} 包含默认、hover 和 active 状态的九个 CSS 变量的全新对象;
|
|
53
|
+
* 可赋给 Button.color 或传入 Button.setColor(),不会随按钮属性变化自动重新计算。
|
|
54
|
+
*/
|
|
55
|
+
export declare function generateButtonColor(color: string, text?: boolean, ghost?: boolean): ButtonColor;
|
|
56
|
+
/** Tag 支持的自定义颜色变量,可只覆盖其中一部分。 */
|
|
57
|
+
export type TagColor = Partial<Record<"--l-tag-color" | "--l-tag-border-color" | "--l-tag-background", string>>;
|
|
58
|
+
/**
|
|
59
|
+
* 生成标签的文字、边框和浅色背景配色,不修改标签或 DOM。
|
|
60
|
+
* @param {string} color 基础颜色,使用 adjust 支持的颜色字符串,例如 "#00AA7E";空白字符串返回空对象。
|
|
61
|
+
* @returns {TagColor} 包含三个 CSS 变量的全新对象,可赋给 Tag.color 或传入 Tag.setColor()。
|
|
62
|
+
*/
|
|
63
|
+
export declare function generateTagColor(color: string): TagColor;
|
package/lib/utils/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
import { adjust as e, isBlank as t, isNumeric as n } from "utilane";
|
|
2
|
+
// src/components/utils/index.ts
|
|
3
|
+
var r = -1;
|
|
4
|
+
function i(e, t) {
|
|
5
5
|
let n = Array.isArray(e) ? e : [e];
|
|
6
6
|
for (let e of n) {
|
|
7
7
|
let n = t || `l-${e.baseName}`;
|
|
8
8
|
customElements.get(n) || customElements.define(n, e);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return `l-${++
|
|
11
|
+
function a() {
|
|
12
|
+
return `l-${++r}`;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function o(e, t, n) {
|
|
15
15
|
if (e == null) return t;
|
|
16
16
|
switch (typeof t) {
|
|
17
17
|
case "boolean": return [
|
|
@@ -25,7 +25,7 @@ function a(e, t, n) {
|
|
|
25
25
|
default: return e;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function s(e) {
|
|
29
29
|
let t = e.attributes;
|
|
30
30
|
for (let n of t) {
|
|
31
31
|
let { name: t, value: r } = n;
|
|
@@ -34,32 +34,53 @@ function o(e) {
|
|
|
34
34
|
"class",
|
|
35
35
|
"style"
|
|
36
36
|
].includes(t)) continue;
|
|
37
|
-
let i = t.split("-").map((e, t) => t === 0 ? e : e[0].toUpperCase() + e.slice(1)).join(""),
|
|
38
|
-
(e._ignoreInitAttrs || []).includes(i) || (t === "value"
|
|
37
|
+
let i = t.split("-").map((e, t) => t === 0 ? e : e[0].toUpperCase() + e.slice(1)).join(""), a = o(r, e[i], t), s = Object.getOwnPropertyNames(e);
|
|
38
|
+
(e._ignoreInitAttrs || []).includes(i) || (t === "value" || s.includes(i) || s.includes(`_${i}`)) && (e[i] = a);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function c(e, n) {
|
|
42
42
|
let r = "";
|
|
43
|
-
return n === !0 ? r = ` ${
|
|
43
|
+
return n === !0 ? r = ` ${e}` : typeof n == "string" && !t(n) && (r = ` ${e}="${n}"`), r;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
let t = e.map((e) =>
|
|
45
|
+
function l(e) {
|
|
46
|
+
let t = e.map((e) => c(e[0], e[1]));
|
|
47
47
|
return t.length > 0 ? ` ${t.join("")}` : "";
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function u(e, n) {
|
|
50
50
|
for (let r of n) {
|
|
51
51
|
let n = r[1], i = r[0];
|
|
52
|
-
n === !0 ?
|
|
52
|
+
n === !0 ? e.setAttribute(i, "") : typeof n == "string" && !t(n) && e.setAttribute(i, n);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function d(e) {
|
|
56
56
|
return e.replace(/-(\w)/g, (e, t) => t.toUpperCase());
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function f(e) {
|
|
59
59
|
e && e();
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
return e && (
|
|
61
|
+
function p(e, t = "px") {
|
|
62
|
+
return e && (n(e) ? `${e}${t}` : e);
|
|
63
|
+
}
|
|
64
|
+
function m(t, n = !1, r = !1) {
|
|
65
|
+
if (!t) return {};
|
|
66
|
+
let i = e(t, 1, !0), a = e(t, 3, !1);
|
|
67
|
+
return {
|
|
68
|
+
"--l-btn-border-color": n ? "transparent" : t,
|
|
69
|
+
"--l-btn-text-color": r || n ? t : "#ffffff",
|
|
70
|
+
"--l-btn-hover-text-color": r || n ? i : "#ffffff",
|
|
71
|
+
"--l-btn-background": r || n ? "transparent" : t,
|
|
72
|
+
"--l-btn-active-text-color": r || n ? a : "#ffffff",
|
|
73
|
+
"--l-btn-hover-border-color": n ? "transparent" : i,
|
|
74
|
+
"--l-btn-hover-background": r || n ? "transparent" : i,
|
|
75
|
+
"--l-btn-active-background": r || n ? "transparent" : a,
|
|
76
|
+
"--l-btn-active-border-color": n ? "transparent" : a
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function h(n) {
|
|
80
|
+
return t(n) ? {} : {
|
|
81
|
+
"--l-tag-color": n,
|
|
82
|
+
"--l-tag-border-color": n,
|
|
83
|
+
"--l-tag-background": e(n, 5, !0)
|
|
84
|
+
};
|
|
63
85
|
}
|
|
64
|
-
|
|
65
|
-
export { o as initAttr, u as kebabToCamel, a as parseAttrValue, r as regist, l as setAttrs, d as stopSignal, s as tagAttr, c as tagAttrs, f as unitNumberStr, i as useId };
|
|
86
|
+
export { m as generateButtonColor, h as generateTagColor, s as initAttr, d as kebabToCamel, o as parseAttrValue, i as regist, u as setAttrs, f as stopSignal, c as tagAttr, l as tagAttrs, p as unitNumberStr, a as useId };
|