litos-ui 0.23.1 → 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/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.js +22 -24
- package/lib/calendar/index.less_inline.js +1 -2
- package/lib/calendar/langs.js +1 -2
- 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.js +1 -2
- 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 -3
- 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 +91 -91
- package/lib/input/index.d.ts +14 -0
- package/lib/input/index.js +126 -31
- 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 +1 -0
- package/lib/input/style.js +5 -7
- 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 +2 -7
- package/lib/pagination/index.less_inline.js +1 -2
- 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 +19 -2
- package/lib/select/index.js +128 -74
- 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.js +1 -2
- 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 -6
- package/lib/utils/index.js +26 -6
- 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 +42 -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/locale.d.ts +0 -6
- package/lib/utils/locale.js +0 -34
- package/lib/utils/signal_types.d.ts +0 -5
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import e from "./index.less_inline.js";
|
|
2
|
+
import t from "../form/form_inner.js";
|
|
3
|
+
import { parseAttrValue as n, unitNumberStr as r } from "../utils/index.js";
|
|
4
|
+
import { readFormBooleanAttribute as i } from "../form/context.js";
|
|
5
|
+
import { $ as a, $$ as o, off as s, on as c } from "utilane/browser";
|
|
6
|
+
import { parse as l } from "utilane";
|
|
7
|
+
// src/components/date_picker_ori/index.ts
|
|
8
|
+
var u = class extends t {
|
|
8
9
|
static baseName = "date-picker-ori";
|
|
9
|
-
#e;
|
|
10
|
+
#e = [];
|
|
10
11
|
#t;
|
|
11
|
-
#n;
|
|
12
|
+
#n = !1;
|
|
12
13
|
#r;
|
|
14
|
+
#i = !1;
|
|
13
15
|
_state;
|
|
14
16
|
constructor() {
|
|
15
17
|
super(), this._state = {
|
|
@@ -17,16 +19,48 @@ var d = class extends r {
|
|
|
17
19
|
delay: 300,
|
|
18
20
|
type: "date",
|
|
19
21
|
allowEmpty: !0
|
|
20
|
-
}, this.#t = []
|
|
22
|
+
}, this.#t = [];
|
|
23
|
+
}
|
|
24
|
+
parseDefaultValue(e) {
|
|
25
|
+
return this.#s(this.#o(e).dates);
|
|
26
|
+
}
|
|
27
|
+
#a() {
|
|
28
|
+
let e = this.ownerDocument.createElement("input");
|
|
29
|
+
return e.type = this.getAttribute("type") || this._state.type, e;
|
|
30
|
+
}
|
|
31
|
+
#o(e) {
|
|
32
|
+
let [t, r = ""] = String(e ?? "").split(",", 2), i = this.#a();
|
|
33
|
+
i.value = t;
|
|
34
|
+
let a = i.value;
|
|
35
|
+
if (!n(this.getAttribute("range"), !1, "range")) return {
|
|
36
|
+
dates: [a],
|
|
37
|
+
reversed: !1
|
|
38
|
+
};
|
|
39
|
+
let o = i.valueAsNumber;
|
|
40
|
+
return i.value = r, {
|
|
41
|
+
dates: [a, i.value],
|
|
42
|
+
reversed: o > i.valueAsNumber
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
#s(e) {
|
|
46
|
+
return e.some(Boolean) ? e.join(",") : "";
|
|
21
47
|
}
|
|
22
48
|
setValue(e) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
let { dates: t, reversed: n } = this.#o(e);
|
|
50
|
+
this.#f(), this.#i = !1, this.#t = t, this.#n = n, this.#l(), super.setValue(this.#s(t));
|
|
51
|
+
}
|
|
52
|
+
get nativeConstraintValues() {
|
|
53
|
+
return this._state.range ? [this.#t[0] ?? "", this.#t[1] ?? ""] : [this.#t[0] ?? ""];
|
|
54
|
+
}
|
|
55
|
+
get nativeBadInput() {
|
|
56
|
+
return this.#n;
|
|
57
|
+
}
|
|
58
|
+
disabledChange() {
|
|
59
|
+
for (let e of this.#e ?? []) e.disabled = this.isDisabled();
|
|
26
60
|
}
|
|
27
61
|
static get observedAttributes() {
|
|
28
|
-
return [
|
|
29
|
-
...
|
|
62
|
+
return [.../* @__PURE__ */ new Set([
|
|
63
|
+
...t.observedAttributes,
|
|
30
64
|
"range",
|
|
31
65
|
"delay",
|
|
32
66
|
"type",
|
|
@@ -34,56 +68,85 @@ var d = class extends r {
|
|
|
34
68
|
"min",
|
|
35
69
|
"max",
|
|
36
70
|
"allow-empty"
|
|
37
|
-
];
|
|
71
|
+
])];
|
|
38
72
|
}
|
|
39
73
|
connectedCallback() {
|
|
40
|
-
this.loadStyleText(
|
|
74
|
+
this.loadStyleText(e), this._updateWidth(), super.connectedCallback();
|
|
41
75
|
}
|
|
42
76
|
afterInit() {
|
|
43
|
-
this.#e = a(".l-date-inner", this.root),
|
|
77
|
+
this.#e = a(".l-date-inner", this.root), c(this.#e, "change", this.#d), this._state.range && (c(this.#e, "focus", this.#m), c(this.#e, "blur", this.#h)), this.#l();
|
|
44
78
|
}
|
|
45
79
|
beforeDestroy() {
|
|
46
|
-
|
|
80
|
+
s(this.#e, "change", this.#d), s(this.#e, "focus", this.#m), s(this.#e, "blur", this.#h), this.#f(), this.#i = !1, this.#e = [];
|
|
47
81
|
}
|
|
48
|
-
attributeChange(
|
|
49
|
-
switch (
|
|
82
|
+
attributeChange(e, t, i) {
|
|
83
|
+
switch (e) {
|
|
50
84
|
case "type":
|
|
85
|
+
this._state.type = i || "date", this.#c();
|
|
86
|
+
break;
|
|
51
87
|
case "min":
|
|
52
88
|
case "max":
|
|
53
|
-
this._state[
|
|
89
|
+
this._state[e] = i;
|
|
54
90
|
break;
|
|
55
91
|
case "range":
|
|
92
|
+
this._state.range = n(i, !1, e), this.#c();
|
|
93
|
+
break;
|
|
56
94
|
case "allow-empty":
|
|
57
|
-
this._state
|
|
95
|
+
this._state.allowEmpty = n(i, !0, e);
|
|
58
96
|
break;
|
|
59
97
|
case "delay":
|
|
60
|
-
this._state.delay =
|
|
98
|
+
this._state.delay = n(i, 300);
|
|
61
99
|
break;
|
|
62
|
-
case "width": this._state.width =
|
|
100
|
+
case "width": this._state.width = r(i);
|
|
63
101
|
}
|
|
64
102
|
}
|
|
65
103
|
updateDOM(e) {
|
|
66
|
-
e.has("width") && this._updateWidth()
|
|
104
|
+
if (e.has("width") && this._updateWidth(), e.has("range") && this.#e.length !== (this._state.range ? 2 : 1)) {
|
|
105
|
+
this.beforeDestroy();
|
|
106
|
+
for (let e of this.root.querySelectorAll(".l-date-inner,.l-date-range-divider")) e.remove();
|
|
107
|
+
this.root.appendChild(this.render()), this.afterInit();
|
|
108
|
+
}
|
|
109
|
+
this.#l(), this.syncNativeValue();
|
|
110
|
+
}
|
|
111
|
+
#c() {
|
|
112
|
+
this.dirtyValue ? this.setValue(this.value) : this.applyDefaultValue();
|
|
113
|
+
}
|
|
114
|
+
#l() {
|
|
115
|
+
for (let [e, t] of this.#e.entries()) {
|
|
116
|
+
t.type = this._state.type || "date";
|
|
117
|
+
let n = this.#t[e] ?? "";
|
|
118
|
+
t.value !== n && (t.value = n);
|
|
119
|
+
for (let e of [
|
|
120
|
+
"min",
|
|
121
|
+
"max",
|
|
122
|
+
"step"
|
|
123
|
+
]) {
|
|
124
|
+
let n = this.getAttribute(e);
|
|
125
|
+
n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
|
|
126
|
+
}
|
|
127
|
+
t.readOnly = i(this.getAttribute("readonly")) ?? !1, t.disabled = this.isDisabled();
|
|
128
|
+
}
|
|
129
|
+
let [e, t] = this.#e;
|
|
130
|
+
e && t && (t.value && (!e.max || t.value < e.max) && (e.max = t.value), e.value && (!t.min || e.value > t.min) && (t.min = e.value));
|
|
67
131
|
}
|
|
68
132
|
_updateWidth() {
|
|
69
133
|
this._state.width ? this.style.setProperty("--l-date-picker-width", this._state.width) : this.style.removeProperty("--l-date-picker-width");
|
|
70
134
|
}
|
|
71
135
|
render() {
|
|
72
136
|
let e = document.createDocumentFragment();
|
|
73
|
-
if (e.appendChild(this.#
|
|
137
|
+
if (e.appendChild(this.#u(0)), this._state.range) {
|
|
74
138
|
let t = o("span", {
|
|
75
139
|
class: "l-date-range-divider",
|
|
76
140
|
textContent: "-"
|
|
77
141
|
});
|
|
78
|
-
e.appendChild(t), e.appendChild(this.#
|
|
142
|
+
e.appendChild(t), e.appendChild(this.#u(1));
|
|
79
143
|
}
|
|
80
144
|
return e;
|
|
81
145
|
}
|
|
82
|
-
#
|
|
146
|
+
#u(e = 0) {
|
|
83
147
|
return o("input", {
|
|
84
148
|
type: this._state.type,
|
|
85
149
|
class: `l-date-inner l-date-inner${e}`,
|
|
86
|
-
name: this.getName(),
|
|
87
150
|
value: this.#t[e],
|
|
88
151
|
"l-datepicker": `${e}`,
|
|
89
152
|
disabled: this.isDisabled() ? !0 : void 0,
|
|
@@ -91,31 +154,44 @@ var d = class extends r {
|
|
|
91
154
|
max: this._state.max
|
|
92
155
|
});
|
|
93
156
|
}
|
|
94
|
-
#
|
|
95
|
-
let t = e.target
|
|
96
|
-
|
|
157
|
+
#d = (e) => {
|
|
158
|
+
let t = e.target;
|
|
159
|
+
if (this.isDisabled() || t.readOnly) return;
|
|
160
|
+
let n = Number(t.getAttribute("l-datepicker"));
|
|
161
|
+
if (n >= this.#t.length) return;
|
|
162
|
+
let r = t.value;
|
|
163
|
+
!r && !this._state.allowEmpty && (r = this.defaultValue, r = String(r).split(",")[n] ?? "", t.value = r);
|
|
164
|
+
let i = [...this.#t];
|
|
165
|
+
i[n] = r;
|
|
166
|
+
let a = this.#s(this.#o(i.join(",")).dates);
|
|
167
|
+
a !== this.value && (this.setValue(a), this.validateInput(), this._state.range ? (this.#i = !0, this.#p()) : this.#_());
|
|
97
168
|
};
|
|
98
|
-
#
|
|
99
|
-
this.#
|
|
169
|
+
#f() {
|
|
170
|
+
this.#r !== void 0 && (clearTimeout(this.#r), this.#r = void 0);
|
|
100
171
|
}
|
|
101
|
-
#
|
|
102
|
-
this.#
|
|
103
|
-
this.#
|
|
172
|
+
#p() {
|
|
173
|
+
this.#i && (this.#f(), this.#r = setTimeout(() => {
|
|
174
|
+
this.#r = void 0, this.#i = !1, this.#_();
|
|
104
175
|
}, this._state.delay));
|
|
105
176
|
}
|
|
106
|
-
#
|
|
107
|
-
this.#
|
|
177
|
+
#m = () => {
|
|
178
|
+
this.#f();
|
|
108
179
|
};
|
|
109
|
-
#
|
|
110
|
-
this.#
|
|
180
|
+
#h = () => {
|
|
181
|
+
this.#p();
|
|
111
182
|
};
|
|
112
|
-
#
|
|
183
|
+
#g() {
|
|
184
|
+
let e = this._state.type.toLowerCase();
|
|
185
|
+
if (e !== "time" && e !== "week") return this.#t.map((e) => l(e));
|
|
186
|
+
let t = this.#a();
|
|
187
|
+
return this.#t.map((e) => (t.value = e, t.valueAsDate ?? l(e)));
|
|
188
|
+
}
|
|
189
|
+
#_() {
|
|
113
190
|
this.dispatchEvent(new CustomEvent("change", { detail: {
|
|
114
191
|
value: this.getValue(),
|
|
115
|
-
dateStr: this.#t,
|
|
116
|
-
dates: this.#
|
|
192
|
+
dateStr: [...this.#t],
|
|
193
|
+
dates: this.#g()
|
|
117
194
|
} }));
|
|
118
195
|
}
|
|
119
196
|
};
|
|
120
|
-
|
|
121
|
-
export { d as default };
|
|
197
|
+
export { u as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/date_picker_ori/index.less?inline
|
|
2
2
|
var e = ":host{width:var(--l-date-picker-width,auto);align-items:center;display:inline-flex}.l-date-inner{height:var(--l-form-control-height,32px);border:1px solid var(--l-border-color,#dedede);cursor:text;border-radius:3px;outline:none;flex-grow:1;padding:0 5px;transition:border-color .3s}.l-date-inner:hover{border-color:var(--l-primary-color-light1,#9254de)}.l-date-inner:focus{border-color:var(--l-primary-color,#722ed1)}.l-date-range-divider{margin:0 10px}";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { e as default };
|
|
@@ -2,7 +2,7 @@ import e from "../base.js";
|
|
|
2
2
|
import { kebabToCamel as t, parseAttrValue as n } from "../utils/index.js";
|
|
3
3
|
import r from "./index.less_inline.js";
|
|
4
4
|
import { $one as i, addClass as a, hasClass as o, on as s, removeClass as c, shouldEventNext as l } from "utilane/browser";
|
|
5
|
-
|
|
5
|
+
// src/components/description_panel/index.ts
|
|
6
6
|
var u = class extends e {
|
|
7
7
|
static baseName = "description-panel";
|
|
8
8
|
collapseHeight = 100;
|
|
@@ -18,14 +18,7 @@ var u = class extends e {
|
|
|
18
18
|
this.loadStyleText(r), super.connectedCallback();
|
|
19
19
|
}
|
|
20
20
|
render() {
|
|
21
|
-
return
|
|
22
|
-
"<div class=\"content\"><slot></slot></div>",
|
|
23
|
-
"<div class=\"l-desc-panel-operator\">",
|
|
24
|
-
"<l-button type=\"primary\" data-action=\"collapse\" class=\"l-desc-panel-btnmore\" text>",
|
|
25
|
-
"<span>查看更多</span>",
|
|
26
|
-
"<l-arrow-down-icon class=\"l-desc-panel-arrow\"></l-arrow-down-icon>",
|
|
27
|
-
"</l-button></div>"
|
|
28
|
-
].join("");
|
|
21
|
+
return "<div class=\"content\"><slot></slot></div><div class=\"l-desc-panel-operator\"><l-button type=\"primary\" data-action=\"collapse\" class=\"l-desc-panel-btnmore\" text><span>查看更多</span><l-arrow-down-icon class=\"l-desc-panel-arrow\"></l-arrow-down-icon></l-button></div>";
|
|
29
22
|
}
|
|
30
23
|
afterInit() {
|
|
31
24
|
this.classList.add("collapse");
|
|
@@ -50,5 +43,4 @@ var u = class extends e {
|
|
|
50
43
|
}
|
|
51
44
|
};
|
|
52
45
|
};
|
|
53
|
-
//#endregion
|
|
54
46
|
export { u as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/description_panel/index.less?inline
|
|
2
2
|
var e = ":host{--l-desc-panel-min-height:100px;--l-desc-panel-font-size:14px;--l-desc-panel-textindent:calc(var(--l-desc-panel-font-size) * 2);max-height:var(--l-desc-panel-max-height,max-content);color:#1f2937;font-size:var(--l-desc-panel-font-size);text-indent:var(--l-desc-panel-textindent);box-sizing:border-box;transition:all .15s linear;display:block;position:relative}.content{box-sizing:border-box;border:1px solid #0000}.l-desc-panel-operator{z-index:2;box-sizing:border-box;background:0 0;justify-content:center;width:100%;padding-top:0;padding-bottom:0;display:flex}.l-desc-panel-btnmore{font-size:var(--nt-desc-panel-font-size)}.l-desc-panel-btnmore:before{content:attr(data-text)}.l-desc-panel-arrow{transition:transform .3s ease-in-out;transform:rotate(180deg)}:host(.collapse){max-height:var(--l-desc-panel-min-height);overflow-y:hidden}:host(.collapse) .l-desc-panel-operator{background:linear-gradient(-180deg,#fff0 0%,#fff 80%);padding-top:65px;position:absolute;bottom:0;left:0}:host(.collapse) .l-desc-panel-arrow{transform:rotateX(0)}";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { e as default };
|
package/lib/dialog/dialog_box.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t from "../
|
|
3
|
-
import n from "./
|
|
4
|
-
import r from "
|
|
5
|
-
import i from "../
|
|
6
|
-
import a from "../icon/
|
|
1
|
+
import e from "./index.js";
|
|
2
|
+
import { regist as t } from "../utils/index.js";
|
|
3
|
+
import n from "./dialog_container.js";
|
|
4
|
+
import r from "../button/index.js";
|
|
5
|
+
import i from "../icon/close.js";
|
|
6
|
+
import a from "../icon/info.js";
|
|
7
7
|
import o from "../form/form_item.js";
|
|
8
8
|
import s from "../input/index.js";
|
|
9
9
|
import { $$ as c, $one as l } from "utilane/browser";
|
|
10
|
-
|
|
11
|
-
function u(
|
|
10
|
+
// src/components/dialog/dialog_box.ts
|
|
11
|
+
function u(t, n, r, i = "alert") {
|
|
12
12
|
return new Promise((a) => {
|
|
13
13
|
let o = [];
|
|
14
14
|
if (r.icon) {
|
|
15
15
|
let e = r.icon();
|
|
16
16
|
e.setAttribute("slot", "header"), o.push(e.outerHTML);
|
|
17
17
|
}
|
|
18
|
-
o.push(`<span slot="header">${
|
|
18
|
+
o.push(`<span slot="header">${t}</span>`), i === "prompt" ? (o.push(`<l-form-item label="${n}" label-position="top" inner-block>`), o.push(`<l-input placeholder="${r.placeholder || ""}"></l-input>`), o.push("</l-form-item>")) : o.push(`<span>${n}</span>`);
|
|
19
19
|
let s = document.createElement("dialog"), c = document.createElement("l-dialog-container");
|
|
20
|
-
c.setAttribute("header",
|
|
21
|
-
let u = new
|
|
20
|
+
c.setAttribute("header", t), c.setAttribute("close", `${r.close}`), c.setAttribute("show-cancel", `${r.showCancel}`), c.innerHTML = o.join(""), s.appendChild(c), document.body.appendChild(s);
|
|
21
|
+
let u = new e({
|
|
22
22
|
el: s,
|
|
23
23
|
maskClosable: r.maskClosable,
|
|
24
24
|
close: r.close,
|
|
@@ -39,11 +39,11 @@ function u(e, t, r, i = "alert") {
|
|
|
39
39
|
u.open();
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function d(
|
|
43
|
-
|
|
44
|
-
a,
|
|
42
|
+
function d(e, a, o) {
|
|
43
|
+
t([
|
|
45
44
|
i,
|
|
46
|
-
r
|
|
45
|
+
r,
|
|
46
|
+
n
|
|
47
47
|
]);
|
|
48
48
|
let s = {
|
|
49
49
|
showCancel: !1,
|
|
@@ -52,14 +52,14 @@ function d(t, n, o) {
|
|
|
52
52
|
icon: void 0,
|
|
53
53
|
...o
|
|
54
54
|
};
|
|
55
|
-
return u(
|
|
55
|
+
return u(a || "提示", e, s, "alert");
|
|
56
56
|
}
|
|
57
|
-
function f(
|
|
58
|
-
|
|
59
|
-
a,
|
|
60
|
-
t,
|
|
57
|
+
function f(e, o, s) {
|
|
58
|
+
t([
|
|
61
59
|
i,
|
|
62
|
-
|
|
60
|
+
a,
|
|
61
|
+
r,
|
|
62
|
+
n
|
|
63
63
|
]);
|
|
64
64
|
let l = {
|
|
65
65
|
showCancel: !0,
|
|
@@ -68,16 +68,16 @@ function f(n, o, s) {
|
|
|
68
68
|
icon: () => c("l-info-icon", { style: "color:#1890ff;" }),
|
|
69
69
|
...s
|
|
70
70
|
};
|
|
71
|
-
return u(o || "提示",
|
|
71
|
+
return u(o || "提示", e, l, "confirm");
|
|
72
72
|
}
|
|
73
|
-
function p(
|
|
74
|
-
|
|
73
|
+
function p(e, c, l) {
|
|
74
|
+
t([
|
|
75
|
+
i,
|
|
75
76
|
a,
|
|
76
|
-
t,
|
|
77
77
|
o,
|
|
78
78
|
s,
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
r,
|
|
80
|
+
n
|
|
81
81
|
]);
|
|
82
82
|
let d = {
|
|
83
83
|
showCancel: !0,
|
|
@@ -87,12 +87,11 @@ function p(n, c, l) {
|
|
|
87
87
|
icon: void 0,
|
|
88
88
|
...l
|
|
89
89
|
};
|
|
90
|
-
return u(c || "提示",
|
|
90
|
+
return u(c || "提示", e, d, "prompt");
|
|
91
91
|
}
|
|
92
92
|
var m = {
|
|
93
93
|
alert: d,
|
|
94
94
|
confirm: f,
|
|
95
95
|
prompt: p
|
|
96
96
|
};
|
|
97
|
-
//#endregion
|
|
98
97
|
export { m as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/dialog/dialog_container.css?inline
|
|
2
2
|
var e = ":host{display:block;position:relative}:host(.l-container-close-outside){padding-top:10px;padding-right:10px}.l-dialog-main{padding:var(--l-dialog-main-padding,0);background-color:#fff;border-radius:5px;box-shadow:0 0 8px #0000001a}.l-dialog-header{padding:var(--l-dialog-header-padding,10px);border-bottom:1px solid var(--l-dialog-line-color,#0000000f);align-items:center;gap:5px;font-size:16px;font-weight:600;display:flex}.l-dialog-footer{padding:var(--l-dialog-footer-padding,10px);border-top:1px solid var(--l-dialog-line-color,#0000000f);justify-content:flex-end;gap:10px;display:flex}.l-dialog-container{padding:var(--l-dialog-container-padding,15px 10px);font-size:14px}.l-btn-dialog-close{--l-form-control-height:auto;position:absolute}.l-dialog-close1{right:var(--l-dialog-close-right,5px);top:var(--l-dialog-close-top,6px)}.l-dialog-close1::part(default){border:none;width:auto;height:auto;padding:5px;font-size:16px}.l-dialog-close2{right:var(--l-dialog-close-right,0);top:var(--l-dialog-close-top,0)}.l-dialog-close2::part(default){background-color:#fff;width:20px;height:20px;padding:0}.l-dialog-main--mobile{border-radius:10px}.l-dialog-main--mobile .l-dialog-header{text-align:center;border-bottom-color:#0000;justify-content:center;padding:20px 10px 5px;display:flex}.l-dialog-main--mobile .l-dialog-container{text-align:center;padding:5px 15px 20px}.l-dialog-main--mobile .l-dialog-footer{text-align:center;justify-content:stretch;align-items:stretch;gap:0;height:50px;padding:0;display:flex}.l-dialog-main--mobile .l-dialog-footer l-button{flex-grow:1;height:100%}.l-dialog-main--mobile .l-dialog-footer l-button+l-button{border-left:1px solid var(--l-dialog-line-color,#0000000f)}";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { e as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import e from "../base.js";
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
2
|
+
import t from "./dialog_container_style.js";
|
|
3
|
+
import { parseAttrValue as n } from "../utils/index.js";
|
|
4
4
|
import { $ as r, $$ as i, $one as a, formatClass as o, iterate as s, off as c, on as l, shouldEventNext as u } from "utilane/browser";
|
|
5
|
-
|
|
5
|
+
// src/components/dialog/dialog_container.ts
|
|
6
6
|
var d = class extends e {
|
|
7
7
|
static baseName = "dialog-container";
|
|
8
8
|
constructor() {
|
|
@@ -50,42 +50,42 @@ var d = class extends e {
|
|
|
50
50
|
"confirm-loading"
|
|
51
51
|
];
|
|
52
52
|
}
|
|
53
|
-
attributeChanged(e,
|
|
53
|
+
attributeChanged(e, t, r) {
|
|
54
54
|
switch (e) {
|
|
55
55
|
case "show-header":
|
|
56
|
-
this._state.showHeader =
|
|
56
|
+
this._state.showHeader = n(r, !0, e), this.connectedCallback();
|
|
57
57
|
break;
|
|
58
58
|
case "header":
|
|
59
59
|
this._state.header = r || void 0, this.connectedCallback();
|
|
60
60
|
break;
|
|
61
61
|
case "show-footer":
|
|
62
|
-
this._state.showFooter =
|
|
62
|
+
this._state.showFooter = n(r, !0, e);
|
|
63
63
|
break;
|
|
64
64
|
case "show-cancel":
|
|
65
|
-
this._state.showCancel =
|
|
65
|
+
this._state.showCancel = n(r, !0, e), this.connectedCallback();
|
|
66
66
|
break;
|
|
67
67
|
case "cancel-text":
|
|
68
68
|
this._state.cancelText = r || "取消", this.connectedCallback();
|
|
69
69
|
break;
|
|
70
70
|
case "show-ok":
|
|
71
|
-
this._state.showOk =
|
|
71
|
+
this._state.showOk = n(r, !0, e), this.connectedCallback();
|
|
72
72
|
break;
|
|
73
73
|
case "ok-text":
|
|
74
74
|
this._state.okText = r || "确定", this.connectedCallback();
|
|
75
75
|
break;
|
|
76
76
|
case "close":
|
|
77
77
|
this._state.close = Number(r), this._state.close === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
|
|
78
|
-
let
|
|
79
|
-
this._state.close === 0 &&
|
|
78
|
+
let t = a(".l-btn-dialog-close", this.root);
|
|
79
|
+
this._state.close === 0 && t ? (c(t, "click", this.#e), t.remove()) : t ? t.className = this.#t() : (t = this.#n(), l(t, "click", this.#e), this.root.appendChild(t));
|
|
80
80
|
break;
|
|
81
81
|
case "container-class":
|
|
82
82
|
this._state.containerClass = r || void 0, this.connectedCallback();
|
|
83
83
|
break;
|
|
84
84
|
case "mobile":
|
|
85
|
-
this._state.mobile =
|
|
85
|
+
this._state.mobile = n(r, !1, e), this.connectedCallback();
|
|
86
86
|
break;
|
|
87
87
|
case "confirm-loading":
|
|
88
|
-
this._state.confirmLoading =
|
|
88
|
+
this._state.confirmLoading = n(r, !1, e);
|
|
89
89
|
let i = a("[data-action=\"ok\"]", this.root);
|
|
90
90
|
i && i.setAttribute("loading", this._state.confirmLoading.toString());
|
|
91
91
|
}
|
|
@@ -139,7 +139,7 @@ var d = class extends e {
|
|
|
139
139
|
render_v2() {
|
|
140
140
|
return {
|
|
141
141
|
template: this.render(),
|
|
142
|
-
styleSheets: [
|
|
142
|
+
styleSheets: [t]
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
render() {
|
|
@@ -163,5 +163,4 @@ var d = class extends e {
|
|
|
163
163
|
return n.appendChild(r), t.appendChild(n), this._state.showFooter && t.appendChild(this.#r()), e.appendChild(t), e;
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
//#endregion
|
|
167
166
|
export { d as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import e from "./dialog_container.css_inline.js";
|
|
2
|
-
|
|
2
|
+
// src/components/dialog/dialog_container_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 };
|
package/lib/dialog/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $one as e, addClass as t, getAttr as n, hasClass as r, off as i, on as a, removeClass as o } from "utilane/browser";
|
|
2
|
-
|
|
2
|
+
// src/components/dialog/index.ts
|
|
3
3
|
var s = class {
|
|
4
4
|
$dialog;
|
|
5
5
|
$container;
|
|
@@ -72,5 +72,4 @@ var s = class {
|
|
|
72
72
|
this.$container && (e ? this.$container.setAttribute("confirm-loading", "") : this.$container.removeAttribute("confirm-loading"));
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
//#endregion
|
|
76
75
|
export { s as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Popover } from "../utils/popover";
|
|
2
|
+
export interface DropdownItem {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
danger?: boolean;
|
|
7
|
+
divider?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type DropdownPlacement = "bottom-start" | "bottom" | "bottom-end" | "top-start" | "top" | "top-end";
|
|
10
|
+
export interface DropdownOptions {
|
|
11
|
+
reference: HTMLElement | HTMLElement[] | string;
|
|
12
|
+
items?: DropdownItem[];
|
|
13
|
+
/** Custom menu contents. Takes effect when items is omitted; the caller retains ownership. */
|
|
14
|
+
content?: HTMLElement;
|
|
15
|
+
trigger?: "click" | "hover" | "manual";
|
|
16
|
+
placement?: DropdownPlacement;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
closeOnSelect?: boolean;
|
|
19
|
+
onSelect?: (detail: {
|
|
20
|
+
key: string;
|
|
21
|
+
item: DropdownItem;
|
|
22
|
+
index: number;
|
|
23
|
+
reference: HTMLElement | undefined;
|
|
24
|
+
}) => void;
|
|
25
|
+
onOpenChange?: (open: boolean) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface DropdownInstance {
|
|
28
|
+
readonly popover: Popover;
|
|
29
|
+
readonly menu: HTMLElement;
|
|
30
|
+
show(reference?: HTMLElement): void;
|
|
31
|
+
hide(): void;
|
|
32
|
+
isOpen(): boolean;
|
|
33
|
+
setItems(items: DropdownItem[]): void;
|
|
34
|
+
setDisabled(disabled: boolean): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
/** Creates a browser-only dropdown using the existing Popover display and positioning. */
|
|
38
|
+
export declare function createDropdown(options: DropdownOptions): DropdownInstance;
|
|
39
|
+
export default createDropdown;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Popover as e } from "../utils/popover.js";
|
|
2
|
+
// src/components/dropdown/index.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = typeof t.reference == "string" ? Array.from(document.querySelectorAll(t.reference)) : Array.isArray(t.reference) ? [...t.reference] : [t.reference];
|
|
5
|
+
if (!n.length || n.some((e) => !(e instanceof HTMLElement))) throw TypeError("Dropdown requires at least one valid reference element");
|
|
6
|
+
let r = document.createElement("div");
|
|
7
|
+
r.className = "l-popover l-dropdown-menu", r.setAttribute("role", t.items === void 0 && t.content ? "group" : "menu"), r.style.display = "none";
|
|
8
|
+
let i = [], a, o = !1, s = !1, c = n.map((e) => ({
|
|
9
|
+
reference: e,
|
|
10
|
+
expanded: e.getAttribute("aria-expanded"),
|
|
11
|
+
popup: e.getAttribute("aria-haspopup")
|
|
12
|
+
})), l = t.items === void 0 ? t.content : void 0, u = l?.parentNode, d = l?.nextSibling;
|
|
13
|
+
l && r.append(l), document.body.append(r);
|
|
14
|
+
function f(e) {
|
|
15
|
+
i = Array.isArray(e) ? e.filter((e) => e && typeof e == "object").map((e) => ({
|
|
16
|
+
key: String(e.key ?? ""),
|
|
17
|
+
label: String(e.label ?? ""),
|
|
18
|
+
disabled: !!e.disabled,
|
|
19
|
+
danger: !!e.danger,
|
|
20
|
+
divider: !!e.divider
|
|
21
|
+
})) : [], r.replaceChildren(), r.setAttribute("role", "menu"), i.forEach((e, t) => {
|
|
22
|
+
if (e.divider) {
|
|
23
|
+
let e = document.createElement("div");
|
|
24
|
+
e.setAttribute("role", "separator"), r.append(e);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let n = document.createElement("button");
|
|
28
|
+
n.type = "button", n.setAttribute("role", "menuitem"), n.disabled = !!e.disabled, n.setAttribute("aria-disabled", String(!!e.disabled)), n.dataset.dropdownIndex = String(t), n.className = e.danger ? "l-dropdown-item l-dropdown-item--danger" : "l-dropdown-item", n.textContent = e.label, r.append(n);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
l || f(t.items || []);
|
|
32
|
+
let p;
|
|
33
|
+
p = new e({
|
|
34
|
+
reference: n,
|
|
35
|
+
popover: r,
|
|
36
|
+
trigger: t.trigger || "click",
|
|
37
|
+
placement: t.placement || "bottom-start",
|
|
38
|
+
arrow: !1,
|
|
39
|
+
offset: 6,
|
|
40
|
+
disabled: !!t.disabled,
|
|
41
|
+
updateContent: () => {},
|
|
42
|
+
onOpenChange: (e) => {
|
|
43
|
+
n.forEach((t) => t.setAttribute("aria-expanded", String(e && t === a))), o !== e && (o = e, t.onOpenChange?.(e));
|
|
44
|
+
},
|
|
45
|
+
onOutsideTap: (e, t, n) => {
|
|
46
|
+
!t && !n && p.hide();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
let m = (e) => {
|
|
50
|
+
a = e.currentTarget;
|
|
51
|
+
};
|
|
52
|
+
n.forEach((e) => {
|
|
53
|
+
e.setAttribute("aria-haspopup", l ? "true" : "menu"), e.setAttribute("aria-expanded", "false"), e.addEventListener("click", m, !0), e.addEventListener("mouseenter", m, !0);
|
|
54
|
+
});
|
|
55
|
+
let h = (e) => {
|
|
56
|
+
let n = e.target.closest("button[data-dropdown-index]");
|
|
57
|
+
if (!n || !r.contains(n) || n.disabled || p.options.disabled) return;
|
|
58
|
+
let o = Number(n.dataset.dropdownIndex), s = i[o];
|
|
59
|
+
if (!s) return;
|
|
60
|
+
let c = a;
|
|
61
|
+
t.closeOnSelect !== !1 && p.hide(), t.onSelect?.({
|
|
62
|
+
key: s.key,
|
|
63
|
+
item: { ...s },
|
|
64
|
+
index: o,
|
|
65
|
+
reference: c
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
return r.addEventListener("click", h), {
|
|
69
|
+
popover: p,
|
|
70
|
+
menu: r,
|
|
71
|
+
show(e = n[0]) {
|
|
72
|
+
if (!s) {
|
|
73
|
+
if (!n.includes(e)) throw TypeError("Unknown Dropdown reference");
|
|
74
|
+
a = e, p.show(e);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
hide() {
|
|
78
|
+
s || p.hide();
|
|
79
|
+
},
|
|
80
|
+
isOpen() {
|
|
81
|
+
return !s && p.isShow();
|
|
82
|
+
},
|
|
83
|
+
setItems(e) {
|
|
84
|
+
s || (l && r.contains(l) && (u ? u.insertBefore(l, d?.parentNode === u ? d : null) : l.remove()), f(e), n.forEach((e) => e.setAttribute("aria-haspopup", "menu")), o && a && (p.hide(), p.show(a)));
|
|
85
|
+
},
|
|
86
|
+
setDisabled(e) {
|
|
87
|
+
s || (p.setOption("disabled", !!e), e && p.hide());
|
|
88
|
+
},
|
|
89
|
+
destroy() {
|
|
90
|
+
s || (s = !0, r.removeEventListener("click", h), n.forEach((e) => {
|
|
91
|
+
e.removeEventListener("click", m, !0), e.removeEventListener("mouseenter", m, !0);
|
|
92
|
+
}), p.destroy(), l && r.contains(l) && (u ? u.insertBefore(l, d?.parentNode === u ? d : null) : l.remove()), c.forEach(({ reference: e, expanded: t, popup: n }) => {
|
|
93
|
+
t === null ? e.removeAttribute("aria-expanded") : e.setAttribute("aria-expanded", t), n === null ? e.removeAttribute("aria-haspopup") : e.setAttribute("aria-haspopup", n);
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export { t as createDropdown, t as default };
|
package/lib/entries/base.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e as default };
|
|
1
|
+
export { default } from "../base.js";
|