litos-ui 0.21.0 → 0.22.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 +119 -15
- package/README.zh-CN.md +153 -0
- package/lib/base.d.ts +1 -0
- package/lib/base.js +1 -1
- package/lib/button/index.js +4 -4
- package/lib/{style-gKR_qwzm.js → button/index.less_inline.js} +2 -3
- package/lib/button/style.js +6 -2
- package/lib/calendar/index.js +140 -2
- package/lib/calendar/index.less_inline.js +4 -0
- package/lib/calendar/langs.js +12 -0
- package/lib/card/index.js +64 -2
- package/lib/card/index.less_inline.js +4 -0
- package/lib/carousel/index.js +257 -2
- package/lib/carousel/index.less_inline.js +4 -0
- package/lib/carousel/item.js +15 -2
- package/lib/carousel/item.less_inline.js +4 -0
- package/lib/carousel/timer.js +19 -0
- package/lib/check/check.d.ts +1 -0
- package/lib/check/check.js +117 -0
- package/lib/check/check.less_inline.js +4 -0
- package/lib/check/checkbox.js +18 -2
- package/lib/{checkbox-DhGHJXwI.js → check/checkbox.less_inline.js} +2 -14
- package/lib/check/checkbox_group.js +1 -1
- package/lib/check/index.d.ts +1 -0
- package/lib/{check-DFlwStH9.js → check/index.js} +10 -9
- package/lib/check/index.less_inline.js +4 -0
- package/lib/check/radio.js +15 -2
- package/lib/{radio-C9NPQWGI.js → check/radio.less_inline.js} +2 -11
- package/lib/check/radio_group.js +1 -1
- package/lib/collapse/index.js +103 -2
- package/lib/collapse/index.less_inline.js +4 -0
- package/lib/collapse/item.d.ts +1 -0
- package/lib/collapse/item.js +118 -2
- package/lib/collapse/item.less_inline.js +4 -0
- package/lib/collapse/types.d.ts +1 -0
- package/lib/color_picker/index.js +42 -2
- package/lib/color_picker/index.less_inline.js +4 -0
- package/lib/date_picker/index.js +100 -3
- package/lib/date_picker/index.less_inline.js +4 -0
- package/lib/date_picker_ori/index.js +121 -2
- package/lib/date_picker_ori/index.less_inline.js +4 -0
- package/lib/description_panel/index.js +54 -2
- package/lib/description_panel/index.less_inline.js +4 -0
- package/lib/dialog/dialog_box.js +10 -10
- package/lib/{dialog_container_style-C1s0aBf7.js → dialog/dialog_container.css_inline.js} +2 -3
- package/lib/dialog/dialog_container.js +2 -2
- package/lib/dialog/dialog_container_style.js +6 -2
- package/lib/dialog/index.js +1 -1
- package/lib/entries/base.d.ts +2 -0
- package/lib/entries/base.js +2 -0
- package/lib/entries/button.d.ts +2 -0
- package/lib/entries/button.js +6 -0
- package/lib/entries/calendar.d.ts +2 -0
- package/lib/entries/calendar.js +6 -0
- package/lib/entries/card.d.ts +2 -0
- package/lib/entries/card.js +6 -0
- package/lib/entries/carousel-item.d.ts +2 -0
- package/lib/entries/carousel-item.js +6 -0
- package/lib/entries/carousel.d.ts +5 -0
- package/lib/entries/carousel.js +6 -0
- package/lib/entries/checkbox-group.d.ts +3 -0
- package/lib/entries/checkbox-group.js +6 -0
- package/lib/entries/checkbox.d.ts +2 -0
- package/lib/entries/checkbox.js +6 -0
- package/lib/entries/collapse-item.d.ts +3 -0
- package/lib/entries/collapse-item.js +6 -0
- package/lib/entries/collapse.d.ts +3 -0
- package/lib/entries/collapse.js +6 -0
- package/lib/entries/color-picker.d.ts +3 -0
- package/lib/entries/color-picker.js +6 -0
- package/lib/entries/date-picker-ori.d.ts +2 -0
- package/lib/entries/date-picker-ori.js +6 -0
- package/lib/entries/date-picker.d.ts +9 -0
- package/lib/entries/date-picker.js +6 -0
- package/lib/entries/description-panel.d.ts +4 -0
- package/lib/entries/description-panel.js +6 -0
- package/lib/entries/dialog-box.d.ts +6 -0
- package/lib/entries/dialog-box.js +2 -0
- package/lib/entries/dialog-container.d.ts +4 -0
- package/lib/entries/dialog-container.js +6 -0
- package/lib/entries/dialog.d.ts +3 -0
- package/lib/entries/dialog.js +2 -0
- package/lib/entries/form-item.d.ts +2 -0
- package/lib/entries/form-item.js +6 -0
- package/lib/entries/form.d.ts +3 -0
- package/lib/entries/form.js +6 -0
- package/lib/entries/icon-arrow-down.d.ts +2 -0
- package/lib/entries/icon-arrow-down.js +6 -0
- package/lib/entries/icon-arrow-left.d.ts +2 -0
- package/lib/entries/icon-arrow-left.js +6 -0
- package/lib/entries/icon-arrow-right.d.ts +2 -0
- package/lib/entries/icon-arrow-right.js +6 -0
- package/lib/entries/icon-arrow-up.d.ts +2 -0
- package/lib/entries/icon-arrow-up.js +6 -0
- package/lib/entries/icon-base.d.ts +2 -0
- package/lib/entries/icon-base.js +6 -0
- package/lib/entries/icon-calendar.d.ts +2 -0
- package/lib/entries/icon-calendar.js +6 -0
- package/lib/entries/icon-caret-bottom.d.ts +2 -0
- package/lib/entries/icon-caret-bottom.js +6 -0
- package/lib/entries/icon-caret-top.d.ts +2 -0
- package/lib/entries/icon-caret-top.js +6 -0
- package/lib/entries/icon-close-filled.d.ts +2 -0
- package/lib/entries/icon-close-filled.js +6 -0
- package/lib/entries/icon-close.d.ts +2 -0
- package/lib/entries/icon-close.js +6 -0
- package/lib/entries/icon-copy.d.ts +2 -0
- package/lib/entries/icon-copy.js +6 -0
- package/lib/entries/icon-d-arrow-left.d.ts +2 -0
- package/lib/entries/icon-d-arrow-left.js +6 -0
- package/lib/entries/icon-d-arrow-right.d.ts +2 -0
- package/lib/entries/icon-d-arrow-right.js +6 -0
- package/lib/entries/icon-delete.d.ts +2 -0
- package/lib/entries/icon-delete.js +6 -0
- package/lib/entries/icon-eye-outline.d.ts +2 -0
- package/lib/entries/icon-eye-outline.js +6 -0
- package/lib/entries/icon-font-icon.d.ts +2 -0
- package/lib/entries/icon-font-icon.js +6 -0
- package/lib/entries/icon-info.d.ts +2 -0
- package/lib/entries/icon-info.js +6 -0
- package/lib/entries/icon-loading.d.ts +2 -0
- package/lib/entries/icon-loading.js +6 -0
- package/lib/entries/icon-minus.d.ts +2 -0
- package/lib/entries/icon-minus.js +6 -0
- package/lib/entries/icon-moon.d.ts +2 -0
- package/lib/entries/icon-moon.js +6 -0
- package/lib/entries/icon-more.d.ts +2 -0
- package/lib/entries/icon-more.js +6 -0
- package/lib/entries/icon-picture.d.ts +2 -0
- package/lib/entries/icon-picture.js +6 -0
- package/lib/entries/icon-plus.d.ts +2 -0
- package/lib/entries/icon-plus.js +6 -0
- package/lib/entries/icon-reduction.d.ts +2 -0
- package/lib/entries/icon-reduction.js +6 -0
- package/lib/entries/icon-refresh-left.d.ts +2 -0
- package/lib/entries/icon-refresh-left.js +6 -0
- package/lib/entries/icon-refresh-right.d.ts +2 -0
- package/lib/entries/icon-refresh-right.js +6 -0
- package/lib/entries/icon-refresh.d.ts +2 -0
- package/lib/entries/icon-refresh.js +6 -0
- package/lib/entries/icon-search.d.ts +2 -0
- package/lib/entries/icon-search.js +6 -0
- package/lib/entries/icon-select.d.ts +2 -0
- package/lib/entries/icon-select.js +6 -0
- package/lib/entries/icon-sort.d.ts +2 -0
- package/lib/entries/icon-sort.js +6 -0
- package/lib/entries/icon-success.d.ts +2 -0
- package/lib/entries/icon-success.js +6 -0
- package/lib/entries/icon-sun.d.ts +2 -0
- package/lib/entries/icon-sun.js +6 -0
- package/lib/entries/icon-theme-default.d.ts +2 -0
- package/lib/entries/icon-theme-default.js +6 -0
- package/lib/entries/icon-warn.d.ts +2 -0
- package/lib/entries/icon-warn.js +6 -0
- package/lib/entries/icon-zoom-in.d.ts +2 -0
- package/lib/entries/icon-zoom-in.js +6 -0
- package/lib/entries/icon-zoom-out.d.ts +2 -0
- package/lib/entries/icon-zoom-out.js +6 -0
- package/lib/entries/image-preview.d.ts +10 -0
- package/lib/entries/image-preview.js +6 -0
- package/lib/entries/image.d.ts +2 -0
- package/lib/entries/image.js +6 -0
- package/lib/entries/input-number.d.ts +2 -0
- package/lib/entries/input-number.js +6 -0
- package/lib/entries/input.d.ts +2 -0
- package/lib/entries/input.js +6 -0
- package/lib/entries/list.d.ts +3 -0
- package/lib/entries/list.js +6 -0
- package/lib/entries/loading.d.ts +2 -0
- package/lib/entries/loading.js +2 -0
- package/lib/entries/mask.d.ts +2 -0
- package/lib/entries/mask.js +6 -0
- package/lib/entries/md-input.d.ts +2 -0
- package/lib/entries/md-input.js +6 -0
- package/lib/entries/menu.d.ts +3 -0
- package/lib/entries/menu.js +6 -0
- package/lib/entries/message.d.ts +6 -0
- package/lib/entries/message.js +2 -0
- package/lib/entries/modal-box.d.ts +6 -0
- package/lib/entries/modal-box.js +2 -0
- package/lib/entries/modal.d.ts +4 -0
- package/lib/entries/modal.js +6 -0
- package/lib/entries/notification.d.ts +7 -0
- package/lib/entries/notification.js +6 -0
- package/lib/entries/page-header.d.ts +4 -0
- package/lib/entries/page-header.js +6 -0
- package/lib/entries/pagination.d.ts +9 -0
- package/lib/entries/pagination.js +6 -0
- package/lib/entries/polygon.d.ts +2 -0
- package/lib/entries/polygon.js +6 -0
- package/lib/entries/popconfirm.d.ts +3 -0
- package/lib/entries/popconfirm.js +2 -0
- package/lib/entries/popover.d.ts +1 -0
- package/lib/entries/popover.js +2 -0
- package/lib/entries/qrcode.d.ts +2 -0
- package/lib/entries/qrcode.js +6 -0
- package/lib/entries/radio-group.d.ts +3 -0
- package/lib/entries/radio-group.js +6 -0
- package/lib/entries/radio.d.ts +2 -0
- package/lib/entries/radio.js +6 -0
- package/lib/entries/select-ori.d.ts +2 -0
- package/lib/entries/select-ori.js +6 -0
- package/lib/entries/select.d.ts +4 -0
- package/lib/entries/select.js +6 -0
- package/lib/entries/space.d.ts +2 -0
- package/lib/entries/space.js +6 -0
- package/lib/entries/switch.d.ts +2 -0
- package/lib/entries/switch.js +6 -0
- package/lib/entries/tabbar-item.d.ts +2 -0
- package/lib/entries/tabbar-item.js +6 -0
- package/lib/entries/tabbar.d.ts +3 -0
- package/lib/entries/tabbar.js +6 -0
- package/lib/entries/table.d.ts +3 -0
- package/lib/entries/table.js +6 -0
- package/lib/entries/tabs.d.ts +3 -0
- package/lib/entries/tabs.js +2 -0
- package/lib/entries/tag.d.ts +2 -0
- package/lib/entries/tag.js +6 -0
- package/lib/entries/theme-color.d.ts +3 -0
- package/lib/entries/theme-color.js +6 -0
- package/lib/entries/theme.d.ts +9 -0
- package/lib/entries/theme.js +6 -0
- package/lib/entries/transition.d.ts +1 -0
- package/lib/entries/transition.js +2 -0
- package/lib/entries/upload.d.ts +3 -0
- package/lib/entries/upload.js +6 -0
- package/lib/entries/utils.d.ts +1 -0
- package/lib/entries/utils.js +2 -0
- package/lib/form/form_inner.d.ts +1 -0
- package/lib/{form_inner-Cnwb6f_Q.js → form/form_inner.js} +9 -9
- package/lib/form/form_item.d.ts +2 -1
- package/lib/form/form_item.js +148 -2
- package/lib/form/form_item.less_inline.js +4 -0
- package/lib/form/index.d.ts +3 -2
- package/lib/form/index.js +191 -2
- package/lib/form/index.less_inline.js +4 -0
- package/lib/icon/base.js +1 -1
- package/lib/icon/delete.d.ts +5 -0
- package/lib/icon/delete.js +10 -0
- package/lib/icon/eye_outline.d.ts +6 -0
- package/lib/icon/eye_outline.js +13 -0
- package/lib/icon/icon_style.js +6 -2
- package/lib/{icon_style-J7iiDS_a.js → icon/index.less_inline.js} +2 -3
- package/lib/icon/minus.d.ts +5 -0
- package/lib/icon/minus.js +10 -0
- package/lib/icon/picture.d.ts +5 -0
- package/lib/icon/picture.js +10 -0
- package/lib/icon/plus.d.ts +5 -0
- package/lib/icon/plus.js +10 -0
- package/lib/image/image_preview.js +91 -2
- package/lib/image/image_preview.less_inline.js +4 -0
- package/lib/image/index.js +163 -2
- package/lib/image/index.less_inline.js +4 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +47 -40
- package/lib/input/index.js +4 -4
- package/lib/{input-DUBlLEXS.js → input/index.less_inline.js} +1 -1
- package/lib/{input_inner-x4GfLGjj.js → input/input_inner.less_inline.js} +1 -1
- package/lib/input_number/index.js +3 -3
- package/lib/{style-C5wUmE2b.js → input_number/index.less_inline.js} +2 -3
- package/lib/input_number/style.js +6 -2
- package/lib/list/index.js +52 -2
- package/lib/list/index.less_inline.js +4 -0
- package/lib/loading/index.js +1 -1
- package/lib/mask/index.d.ts +1 -1
- package/lib/mask/index.js +109 -2
- package/lib/mask/index.less_inline.js +4 -0
- package/lib/md_input/index.js +59 -2
- package/lib/md_input/index.less_inline.js +4 -0
- package/lib/menu/index.js +275 -2
- package/lib/menu/index.less_inline.js +4 -0
- package/lib/message/index.js +1 -1
- package/lib/modal/index.js +199 -2
- package/lib/modal/index.less_inline.js +4 -0
- package/lib/modal/modal_box.js +21 -22
- package/lib/notification/index.d.ts +212 -0
- package/lib/notification/index.js +380 -0
- package/lib/notification/index.less_inline.js +4 -0
- package/lib/notification/placement.d.ts +49 -0
- package/lib/notification/placement.js +48 -0
- package/lib/notification/style.d.ts +2 -0
- package/lib/notification/style.js +6 -0
- package/lib/page_header/index.js +100 -2
- package/lib/page_header/index.less_inline.js +4 -0
- package/lib/pagination/index.js +214 -2
- package/lib/pagination/index.less_inline.js +4 -0
- package/lib/polygon/index.js +21 -2
- package/lib/{polygon-DhhovlrG.js → polygon/index.less_inline.js} +2 -18
- package/lib/qrcode/index.js +65 -2
- package/lib/qrcode/index.less_inline.js +4 -0
- package/lib/select/index.js +355 -3
- package/lib/select/index.less_inline.js +4 -0
- package/lib/select_ori/index.js +58 -2
- package/lib/select_ori/index.less_inline.js +4 -0
- package/lib/space/index.js +40 -2
- package/lib/space/index.less_inline.js +4 -0
- package/lib/{animation-Bo4jbSGK.js → styles/animation/index.css_inline.js} +2 -3
- package/lib/styles/animation/index.js +6 -2
- package/lib/{mask-Ox6CoyFB.js → styles/mask/index.css_inline.js} +2 -3
- package/lib/styles/mask/index.js +6 -2
- package/lib/switch/index.js +51 -2
- package/lib/switch/index.less_inline.js +4 -0
- package/lib/tabbar/index.js +97 -2
- package/lib/tabbar/index.less_inline.js +4 -0
- package/lib/tabbar/item.js +61 -2
- package/lib/tabbar/item.less_inline.js +4 -0
- package/lib/table/index.js +234 -2
- package/lib/table/index.less_inline.js +4 -0
- package/lib/tabs/index.js +1 -1
- package/lib/tag/index.js +75 -2
- package/lib/tag/index.less_inline.js +4 -0
- package/lib/theme/index.js +86 -2
- package/lib/theme/index.less_inline.js +4 -0
- package/lib/theme/theme_color.js +1 -1
- package/lib/upload/index.d.ts +170 -0
- package/lib/upload/index.js +848 -0
- package/lib/upload/index.less_inline.js +4 -0
- package/lib/upload/style.d.ts +2 -0
- package/lib/upload/style.js +6 -0
- package/lib/utils/context_provide.d.ts +1 -0
- package/lib/utils/context_provide.js +1 -1
- package/lib/utils/event.d.ts +30 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +1 -1
- package/lib/utils/popover.js +1 -1
- package/lib/utils/signal_types.d.ts +5 -0
- package/lib/utils/transition.d.ts +28 -0
- package/lib/utils/transition.js +1 -1
- package/package.json +39 -18
- package/styles/animation.css +2 -2
- package/styles/container.css +8 -8
- package/styles/datepicker.css +9 -9
- package/styles/dialog.css +7 -7
- package/styles/loading.css +17 -17
- package/styles/message.css +9 -9
- package/styles/modal_box.css +3 -3
- package/styles/notification.css +17 -0
- package/styles/popover.css +11 -14
- package/styles/reset.css +13 -15
- package/styles/scrollbar.css +5 -5
- package/styles/select.css +6 -6
- package/styles/tabs.css +3 -3
- package/styles/theme-coral.css +35 -0
- package/styles/theme-jade.css +35 -0
- package/styles/theme-tangerine.css +35 -0
- package/styles/transition.css +1 -1
- package/styles/vars.css +41 -7
- package/lib/calendar-CvlUsN6w.js +0 -146
- package/lib/card-3DM-lJQV.js +0 -63
- package/lib/carousel-DvkZ1YXq.js +0 -276
- package/lib/check-doQ2ZpQj.js +0 -117
- package/lib/collapse-B6-Rn05A.js +0 -102
- package/lib/color_picker-0a-IGZY9.js +0 -41
- package/lib/date_picker-BDN2PAz5.js +0 -99
- package/lib/date_picker_ori-BXFs1eET.js +0 -120
- package/lib/description_panel--AKXBzLL.js +0 -53
- package/lib/esm-DAha108i.js +0 -270
- package/lib/form-DJxvBiLy.js +0 -190
- package/lib/form_item-BqPMRABd.js +0 -147
- package/lib/image-CVQai6NX.js +0 -162
- package/lib/image_preview-DfQAKSJH.js +0 -90
- package/lib/item-CQ2Sknbz.js +0 -14
- package/lib/item-DI6mQXtB.js +0 -117
- package/lib/item-D_ZOPXuE.js +0 -60
- package/lib/list-MG8PRzos.js +0 -51
- package/lib/mask-Bx-yNIJv.js +0 -108
- package/lib/md_input-BX3bujz8.js +0 -58
- package/lib/menu-DKscK5mw.js +0 -274
- package/lib/modal-Cwi3qlEf.js +0 -198
- package/lib/page_header-ujV3pncE.js +0 -99
- package/lib/pagination-aRbGd3Rf.js +0 -213
- package/lib/qrcode-Dip8uLSA.js +0 -64
- package/lib/select-BZMDj5VE.js +0 -354
- package/lib/select_ori-C7sUZxen.js +0 -57
- package/lib/space-CKuTk0YB.js +0 -39
- package/lib/switch-wh2-ivty.js +0 -50
- package/lib/tabbar-CBXK-_AV.js +0 -96
- package/lib/table-BQxMD2Ae.js +0 -233
- package/lib/tag-Di1z9PoZ.js +0 -74
- package/lib/theme-CLbBS-in.js +0 -85
- package/styles/dark.css +0 -13
package/lib/form/form_item.js
CHANGED
|
@@ -1,2 +1,148 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { kebabToCamel as e, parseAttrValue as t, stopSignal as n, unitNumberStr as r } from "../utils/index.js";
|
|
2
|
+
import i from "./form_item.less_inline.js";
|
|
3
|
+
import a from "../utils/context_provide.js";
|
|
4
|
+
import { $$ as o, $one as s, addClass as c, removeClass as l } from "utilane/browser";
|
|
5
|
+
import { effect as u, signal as d } from "alien-signals";
|
|
6
|
+
//#region src/components/form/form_item.ts
|
|
7
|
+
var f = class extends a {
|
|
8
|
+
static baseName = "form-item";
|
|
9
|
+
formErrors;
|
|
10
|
+
_errorSignalStop;
|
|
11
|
+
constructor() {
|
|
12
|
+
super(), this.version = 2, this.contextEventName = "form-item-context-request", this._state = {
|
|
13
|
+
labelPosition: "right",
|
|
14
|
+
required: !1
|
|
15
|
+
}, this.context = d({ innerBlock: !1 });
|
|
16
|
+
}
|
|
17
|
+
static get observedAttributes() {
|
|
18
|
+
return [
|
|
19
|
+
"error",
|
|
20
|
+
"label",
|
|
21
|
+
"required",
|
|
22
|
+
"inner-block",
|
|
23
|
+
"prop",
|
|
24
|
+
"label-position",
|
|
25
|
+
"verify",
|
|
26
|
+
"pattern",
|
|
27
|
+
"validity",
|
|
28
|
+
"label-width",
|
|
29
|
+
"label-height"
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
attributeChanged(n, i, a) {
|
|
33
|
+
switch (n) {
|
|
34
|
+
case "error":
|
|
35
|
+
case "label":
|
|
36
|
+
case "verify":
|
|
37
|
+
case "pattern":
|
|
38
|
+
case "validity":
|
|
39
|
+
this._state[n] = a;
|
|
40
|
+
break;
|
|
41
|
+
case "label-position":
|
|
42
|
+
this._state.labelPosition = a;
|
|
43
|
+
break;
|
|
44
|
+
case "inner-block":
|
|
45
|
+
let i = t(a, !1, n);
|
|
46
|
+
this.context({ innerBlock: i });
|
|
47
|
+
break;
|
|
48
|
+
case "required":
|
|
49
|
+
let o = t(a, !1, n);
|
|
50
|
+
this._state.required = o;
|
|
51
|
+
break;
|
|
52
|
+
case "prop":
|
|
53
|
+
this._state.prop = a, this.context({
|
|
54
|
+
...this.context(),
|
|
55
|
+
prop: a
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
case "label-width":
|
|
59
|
+
case "label-height": this._state[e(n)] = r(a);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
updateDOM(e) {
|
|
63
|
+
e.has("required") && this._updateRequired(), e.has("label") && this._updateLabel(), e.has("error") && this._updateError(), e.has("label-width") && (this._state.labelWidth ? this.style.setProperty("--l-form-label-width", this._state.labelWidth) : this.style.removeProperty("--l-form-label-width")), e.has("label-height") && (this._state.labelHeight ? this.style.setProperty("--l-form-label-height", this._state.labelHeight) : this.style.removeProperty("--l-form-label-height"));
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
super.connectedCallback(), this._updateRequired(), this._parseSchema(), this.emitInject("form-context-request", ((e, t) => {
|
|
67
|
+
this.formErrors = t;
|
|
68
|
+
})), this._errorSignalStop = u(() => {
|
|
69
|
+
let e = this.context().prop, t = this.formErrors ? this.formErrors() : null;
|
|
70
|
+
e && t && (this._state.error = t[e], this._updateError());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
beforeDestroy() {
|
|
74
|
+
this._errorSignalStop = n(this._errorSignalStop);
|
|
75
|
+
}
|
|
76
|
+
setRules(e) {
|
|
77
|
+
let t = this._state.prop;
|
|
78
|
+
if (t) {
|
|
79
|
+
let n = {
|
|
80
|
+
...e,
|
|
81
|
+
key: t
|
|
82
|
+
};
|
|
83
|
+
this._updateRules(n);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
render_v2() {
|
|
87
|
+
return {
|
|
88
|
+
template: this.render(),
|
|
89
|
+
style: [i]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
render() {
|
|
93
|
+
this.classList.add(`l-form-item--${this._state.labelPosition}`);
|
|
94
|
+
let e = document.createDocumentFragment();
|
|
95
|
+
this._state.label != null && e.appendChild(o("label", {
|
|
96
|
+
class: "l-form-item__label",
|
|
97
|
+
textContent: this._state.label
|
|
98
|
+
}));
|
|
99
|
+
let t = o("div", { class: "l-form-item__content" }), n = o("slot");
|
|
100
|
+
return t.appendChild(n), this._state.error && t.appendChild(o("div", {
|
|
101
|
+
class: "l-form-item__error",
|
|
102
|
+
textContent: this._state.error
|
|
103
|
+
})), e.appendChild(t), e;
|
|
104
|
+
}
|
|
105
|
+
_updateRequired() {
|
|
106
|
+
this._state.required ? c(this, "is-required") : l(this, "is-required");
|
|
107
|
+
}
|
|
108
|
+
_parseSchema() {
|
|
109
|
+
let e = this.context().prop;
|
|
110
|
+
if (e) {
|
|
111
|
+
let t = [], n = this._state.verify;
|
|
112
|
+
n && (t = n.split("|"));
|
|
113
|
+
let r = this._state.pattern;
|
|
114
|
+
r && t.push(new RegExp(r));
|
|
115
|
+
let i = {
|
|
116
|
+
key: e,
|
|
117
|
+
required: this._state.required,
|
|
118
|
+
message: this._state.validity,
|
|
119
|
+
rules: t
|
|
120
|
+
};
|
|
121
|
+
this._updateRules(i);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
_updateError() {
|
|
125
|
+
if (this._state.error ? c(this, "is-error") : l(this, "is-error"), !this.rendered) return;
|
|
126
|
+
let e = s(".l-form-item__error", this.root);
|
|
127
|
+
if (e) this._state.error ? e.textContent = this._state.error : e.remove();
|
|
128
|
+
else if (this._state.error) {
|
|
129
|
+
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this._state.error;
|
|
130
|
+
let t = s(".l-form-item__content", this.root);
|
|
131
|
+
t && t.appendChild(e);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
_updateLabel() {
|
|
135
|
+
if (!this.rendered) return;
|
|
136
|
+
let e = s(".l-form-item__label", this.root);
|
|
137
|
+
e == null ? this._state.label != null && (e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this._state.label, this.root.prepend(e)) : this._state.label == null ? e.remove() : e.textContent = this._state.label;
|
|
138
|
+
}
|
|
139
|
+
_updateRules(e) {
|
|
140
|
+
this.emit("form-rule-change", {
|
|
141
|
+
bubbles: !0,
|
|
142
|
+
composed: !0,
|
|
143
|
+
detail: e
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
export { f as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/components/form/form_item.less?inline
|
|
2
|
+
var e = ":host{display:var(--l-form-item-display,flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align,right);width:var(--l-form-label-width,auto);height:var(--l-form-label-height,var(--l-form-control-height,32px));line-height:var(--l-form-label-height,var(--l-form-control-height,32px));color:#606266;box-sizing:border-box;padding:0 10px 0 0;display:inline-block}.l-form-item__label:empty{display:var(--l-form-label-empty-display,inline-block)}:host(.is-required) .l-form-item__label:before{content:\"*\";color:var(--l-warning-color,#f56c6c);vertical-align:middle;margin-right:4px}.l-form-item__content{flex:1;align-items:center;display:flex;position:relative}.l-form-item__error{color:var(--nt-error-color,#ed3f13);padding-top:3px;font-size:12px;line-height:1;position:absolute;top:100%;left:0}:host(.l-form-item--left){--l-form-label-align:left}:host(.l-form-item--top){--l-form-item-display:grid;--l-form-label-align:left;--l-form-label-empty-display:none;grid-template-columns:1fr}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
package/lib/form/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Signal } from "../utils/signal_types";
|
|
2
|
+
import { Validator } from "utilane";
|
|
3
|
+
import type { SchemaType } from "utilane";
|
|
3
4
|
import type { FormSignal } from "./types";
|
|
4
5
|
import BaseComponent from "../base";
|
|
5
6
|
interface FormState {
|
package/lib/form/index.js
CHANGED
|
@@ -1,2 +1,191 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import e from "../base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "../utils/index.js";
|
|
3
|
+
import i from "./index.less_inline.js";
|
|
4
|
+
import { $one as a, formatClass as o, off as s, on as c } from "utilane/browser";
|
|
5
|
+
import { Validator as l } from "utilane";
|
|
6
|
+
import { signal as u } from "alien-signals";
|
|
7
|
+
//#region src/components/form/index.ts
|
|
8
|
+
var d = class extends e {
|
|
9
|
+
static baseName = "form";
|
|
10
|
+
validator;
|
|
11
|
+
_data;
|
|
12
|
+
context;
|
|
13
|
+
errors;
|
|
14
|
+
resetCtx;
|
|
15
|
+
constructor() {
|
|
16
|
+
super(), this.version = 2, this._state = {
|
|
17
|
+
inline: !1,
|
|
18
|
+
labelPosition: "right",
|
|
19
|
+
labelWidth: "80px",
|
|
20
|
+
novalidate: !1,
|
|
21
|
+
emitError: !1
|
|
22
|
+
}, this.validator = new l([]), this.context = u({ innerBlock: !1 }), this.errors = u({}), this.resetCtx = u(0);
|
|
23
|
+
}
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return [
|
|
26
|
+
"label-position",
|
|
27
|
+
"inner-block",
|
|
28
|
+
"inline",
|
|
29
|
+
"novalidate",
|
|
30
|
+
"label-width",
|
|
31
|
+
"label-height",
|
|
32
|
+
"emit-error"
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
attributeChanged(e, i, a) {
|
|
36
|
+
switch (e) {
|
|
37
|
+
case "label-position":
|
|
38
|
+
this._state.labelPosition = a;
|
|
39
|
+
break;
|
|
40
|
+
case "inner-block":
|
|
41
|
+
let i = n(a, !1, e);
|
|
42
|
+
this.context({ innerBlock: i });
|
|
43
|
+
break;
|
|
44
|
+
case "label-width":
|
|
45
|
+
case "label-height":
|
|
46
|
+
this._state[t(e)] = r(a);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
let o = n(a, !1, e);
|
|
50
|
+
this._state[t(e)] = o;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
updateDOM(e) {
|
|
54
|
+
if (e.has("label-position") || e.has("inline")) {
|
|
55
|
+
let e = a("form", this.root);
|
|
56
|
+
e && (e.className = o([
|
|
57
|
+
"l-form",
|
|
58
|
+
this._state.inline ? "l-form-inline" : void 0,
|
|
59
|
+
`l-form--${this._state.labelPosition}`
|
|
60
|
+
]));
|
|
61
|
+
}
|
|
62
|
+
e.has("label-width") && (this._state.labelWidth ? this.style.setProperty("--l-form-label-width", this._state.labelWidth) : this.style.removeProperty("--l-form-label-width")), e.has("label-height") && (this._state.labelHeight ? this.style.setProperty("--l-form-label-height", this._state.labelHeight) : this.style.removeProperty("--l-form-label-height"));
|
|
63
|
+
}
|
|
64
|
+
connectedCallback() {
|
|
65
|
+
c(this, "form-context-request", this._provide), super.connectedCallback();
|
|
66
|
+
}
|
|
67
|
+
afterInit() {
|
|
68
|
+
c(this, "form-rule-change", this.ruleChange), c(this, "form-value-change", this._valueChange), c(this, "form-action", this._formAction);
|
|
69
|
+
}
|
|
70
|
+
disconnectedCallback() {
|
|
71
|
+
this.validator = void 0, s(this, "form-rule-change", this.ruleChange), s(this, "form-value-change", this._valueChange), s(this, "form-context-request", this._provide), s(this, "form-action", this._formAction), super.disconnectedCallback();
|
|
72
|
+
}
|
|
73
|
+
render_v2() {
|
|
74
|
+
return {
|
|
75
|
+
style: [i],
|
|
76
|
+
template: this.render()
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
let e = o([
|
|
81
|
+
"l-form",
|
|
82
|
+
this._state.inline ? "l-form-inline" : void 0,
|
|
83
|
+
`l-form--${this._state.labelPosition}`
|
|
84
|
+
]);
|
|
85
|
+
return this._state.labelWidth && this.style.setProperty("--l-form-label-width", this._state.labelWidth), `<form class="${e}"><slot></slot></form>`;
|
|
86
|
+
}
|
|
87
|
+
ruleChange = (e) => {
|
|
88
|
+
e.stopPropagation(), this.validator.addSchema(e.detail);
|
|
89
|
+
};
|
|
90
|
+
addSchemas(e) {
|
|
91
|
+
this.validator.addSchemas(e);
|
|
92
|
+
}
|
|
93
|
+
setSchemas(e) {
|
|
94
|
+
this.validator.setSchemas(e);
|
|
95
|
+
}
|
|
96
|
+
setSchema(e) {
|
|
97
|
+
this.validator.setSchema(e);
|
|
98
|
+
}
|
|
99
|
+
addSchema(e) {
|
|
100
|
+
this.validator.addSchema(e);
|
|
101
|
+
}
|
|
102
|
+
_provide(e) {
|
|
103
|
+
let { context: t, callback: n } = e.detail;
|
|
104
|
+
t === "form-context-request" && n(this.context, this.errors, this.resetCtx);
|
|
105
|
+
}
|
|
106
|
+
_formAction = (e) => {
|
|
107
|
+
e.detail === "submit" ? this.submit() : this.reset();
|
|
108
|
+
};
|
|
109
|
+
_valueChange = (e) => {
|
|
110
|
+
let { name: t, value: n, valid: r } = e.detail;
|
|
111
|
+
if (!t) return;
|
|
112
|
+
this._data ??= {};
|
|
113
|
+
let i = Object.hasOwn(this._data, t);
|
|
114
|
+
if (this._data[t] = n, !this._state.novalidate && i && r) try {
|
|
115
|
+
let e = this.errors();
|
|
116
|
+
e[t] = void 0, this.setValidateErrors({ ...e });
|
|
117
|
+
} catch (e) {
|
|
118
|
+
this.setValidateErrors({
|
|
119
|
+
...this.errors(),
|
|
120
|
+
...e.detail
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
setValidateErrors(e, t = !0) {
|
|
125
|
+
this._state.emitError ? this.emit("validate-error", { detail: {
|
|
126
|
+
errors: e,
|
|
127
|
+
all: t
|
|
128
|
+
} }) : this.errors(e);
|
|
129
|
+
}
|
|
130
|
+
async validateField(e) {
|
|
131
|
+
let t = !1, n = {};
|
|
132
|
+
if (this._data != null) {
|
|
133
|
+
if (Array.isArray(e)) for (let r = 0, i = e.length; r < i; r++) {
|
|
134
|
+
let i = e[r];
|
|
135
|
+
try {
|
|
136
|
+
n[i] = void 0;
|
|
137
|
+
} catch (e) {
|
|
138
|
+
n[i] = e.detail, t = !0;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else try {
|
|
143
|
+
n[e] = void 0;
|
|
144
|
+
} catch (r) {
|
|
145
|
+
n[e] = r.detail, t = !0;
|
|
146
|
+
}
|
|
147
|
+
if (t) {
|
|
148
|
+
let e = /* @__PURE__ */ Error("validate field error");
|
|
149
|
+
return e.detail = n, Promise.reject(e);
|
|
150
|
+
}
|
|
151
|
+
return Promise.resolve();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
clearValidate() {
|
|
155
|
+
this.errors({});
|
|
156
|
+
}
|
|
157
|
+
reset() {
|
|
158
|
+
this.clearValidate();
|
|
159
|
+
let e = this.resetCtx();
|
|
160
|
+
this.resetCtx(e >= 100 ? 1 : e + 1);
|
|
161
|
+
}
|
|
162
|
+
submit() {
|
|
163
|
+
this._state.novalidate ? this.emit("submit", { detail: this.getData() }) : this.validate().then((e) => {
|
|
164
|
+
e.result ? this.emit("submit", { detail: this.getData() }) : this._state.emitError ? this.emit("validate-error", { detail: {
|
|
165
|
+
errors: e.errors,
|
|
166
|
+
all: !0
|
|
167
|
+
} }) : this.errors(e.errors);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
validate() {
|
|
171
|
+
try {
|
|
172
|
+
return this.validator.validate(this._data || {}), Promise.resolve({
|
|
173
|
+
result: !0,
|
|
174
|
+
errors: {}
|
|
175
|
+
});
|
|
176
|
+
} catch (e) {
|
|
177
|
+
return Promise.resolve({
|
|
178
|
+
result: !1,
|
|
179
|
+
errors: e.detail
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
getData() {
|
|
184
|
+
return { ...this._data };
|
|
185
|
+
}
|
|
186
|
+
setErrors(e) {
|
|
187
|
+
this.errors(e);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
export { d as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/components/form/index.less?inline
|
|
2
|
+
var e = ":host{display:block}.l-form{gap:var(--l-form-gap,20px);flex-flow:column;display:flex}.l-form-inline{gap:var(--l-form-gap,20px);flex-flow:wrap;display:flex}.l-form.l-form-inline{--l-form-item-display:flex}.l-form.l-form--left{--l-form-label-align:left}.l-form.l-form--top{--l-form-item-display:grid;--l-form-label-align:left;--l-form-label-empty-display:none;grid-template-columns:1fr}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|
package/lib/icon/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import e from "../base.js";
|
|
2
2
|
import { unitNumberStr as t } from "../utils/index.js";
|
|
3
|
-
import
|
|
3
|
+
import n from "./icon_style.js";
|
|
4
4
|
//#region src/components/icon/base.ts
|
|
5
5
|
var r = class extends e {
|
|
6
6
|
static baseName = "base-icon";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
//#region src/components/icon/delete.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "delete-icon";
|
|
5
|
+
renderChildren() {
|
|
6
|
+
return "<path fill=\"currentColor\" d=\"M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32zm448-64v-64H416v64zM224 896h576V256H224zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32m192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32\"></path>";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
//#region src/components/icon/eye_outline.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "eye-outline-icon";
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.viewBox = "0 0 24 24";
|
|
7
|
+
}
|
|
8
|
+
renderChildren() {
|
|
9
|
+
return "<path d=\"M8.25 12a3.75 3.75 0 1 1 7.5 0a3.75 3.75 0 0 1-7.5 0M12 9.75a2.25 2.25 0 1 0 0 4.5a2.25 2.25 0 0 0 0-4.5\"></path><path d=\"M4.323 10.646c-.419.604-.573 1.077-.573 1.354s.154.75.573 1.354c.406.583 1.008 1.216 1.77 1.801C7.62 16.327 9.713 17.25 12 17.25s4.38-.923 5.907-2.095c.762-.585 1.364-1.218 1.77-1.801c.419-.604.573-1.077.573-1.354s-.154-.75-.573-1.354c-.406-.583-1.008-1.216-1.77-1.801C16.38 7.673 14.287 6.75 12 6.75s-4.38.923-5.907 2.095c-.762.585-1.364 1.218-1.77 1.801m.856-2.991C6.91 6.327 9.316 5.25 12 5.25s5.09 1.077 6.82 2.405c.867.665 1.583 1.407 2.089 2.136c.492.709.841 1.486.841 2.209s-.35 1.5-.841 2.209c-.506.729-1.222 1.47-2.088 2.136c-1.73 1.328-4.137 2.405-6.821 2.405s-5.09-1.077-6.82-2.405c-.867-.665-1.583-1.407-2.089-2.136C2.6 13.5 2.25 12.723 2.25 12s.35-1.5.841-2.209c.506-.729 1.222-1.47 2.088-2.136\"></path>";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
package/lib/icon/icon_style.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/components/icon/index.less?inline
|
|
2
|
-
var e = ":host{display:inline-flex}.l-icon{fill:currentColor;vertical-align:middle;width:1em;height:1em;color:var(--l-icon-color,inherit);font-size:var(--l-icon-size,inherit);display:inline-block}.l-stroke-icon{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round}"
|
|
3
|
-
t.replaceSync(e);
|
|
2
|
+
var e = ":host{display:inline-flex}.l-icon{fill:currentColor;vertical-align:middle;width:1em;height:1em;color:var(--l-icon-color,inherit);font-size:var(--l-icon-size,inherit);display:inline-block}.l-stroke-icon{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round}";
|
|
4
3
|
//#endregion
|
|
5
|
-
export {
|
|
4
|
+
export { e as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
//#region src/components/icon/minus.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "minus-icon";
|
|
5
|
+
renderChildren() {
|
|
6
|
+
return "<path fill=\"currentColor\" d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64\"></path>";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
//#region src/components/icon/picture.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "picture-icon";
|
|
5
|
+
renderChildren() {
|
|
6
|
+
return "<path d=\"M0 914.907717c0 59.561323 48.482772 107.834457 107.834457 107.834456H914.907717c59.55326 0 107.826394-48.482772 107.826393-107.826393V107.834457C1022.742173 48.273134 974.259402 0 914.91578 0H107.834457C48.273134 0 0 48.482772 0 107.834457V914.907717z m914.907717 56.634456H107.84252c-31.139276 0-56.634457-25.495181-56.634457-56.626393V780.118677l193.931087-193.931086 165.72674 165.718677a25.479055 25.479055 0 0 0 36.146393 0L746.262173 452.656378l225.28 225.28v236.987465c0 31.131213-25.495181 56.626394-56.626393 56.626393zM107.84252 51.2H914.907717c31.131213 0 56.626394 25.495181 56.626393 56.634457v497.58337L764.242646 398.311811a25.479055 25.479055 0 0 0-36.154457 0L428.822173 697.577827 263.103496 531.851087a25.479055 25.479055 0 0 0-36.154457 0L51.2 707.608189V107.834457c0-31.139276 25.495181-56.634457 56.634457-56.634457z m209.186267 358.609638c71.889638 0 130.193134-58.513134 130.193134-130.193134 0-71.68-58.513134-130.193134-130.193134-130.193134-71.68 0-130.193134 58.513134-130.193133 130.193134 0 71.68 58.303496 130.193134 130.193133 130.193134z m0-209.186268c43.677228 0 78.993134 35.525543 78.993134 78.993134 0 43.459528-35.525543 78.993134-78.993134 78.993134-43.459528 0-78.993134-35.525543-78.993133-78.993134 0-43.467591 35.315906-78.993134 78.993133-78.993134z\" fill=\"currentColor\"></path>";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as default };
|
package/lib/icon/plus.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
//#region src/components/icon/plus.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "plus-icon";
|
|
5
|
+
renderChildren() {
|
|
6
|
+
return "<path fill=\"currentColor\" d=\"M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64z\"></path>";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as default };
|
|
@@ -1,2 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import e from "../mask/index.js";
|
|
2
|
+
import t from "./image_preview.less_inline.js";
|
|
3
|
+
import { $$ as n, $one as r, off as i, on as a } from "utilane/browser";
|
|
4
|
+
//#region src/components/image/image_preview.ts
|
|
5
|
+
var o = class extends e {
|
|
6
|
+
static baseName = "image-preview";
|
|
7
|
+
urlList = [];
|
|
8
|
+
currentIndex = 0;
|
|
9
|
+
_scale = 1;
|
|
10
|
+
_rotate = 0;
|
|
11
|
+
setImages(e) {
|
|
12
|
+
this.urlList = e;
|
|
13
|
+
}
|
|
14
|
+
setCurrentIndex(e) {
|
|
15
|
+
this.currentIndex = e;
|
|
16
|
+
}
|
|
17
|
+
static customAttributes = ["current-index"];
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
this.loadStyleText(t), super.connectedCallback();
|
|
20
|
+
}
|
|
21
|
+
contentRender() {
|
|
22
|
+
let e = [this._generateBtnString("close", "close")];
|
|
23
|
+
this.urlList.length > 1 && (e.push(this._generateBtnString("prev", "arrow-left")), e.push(this._generateBtnString("next", "arrow-right"))), e.push("<div class=\"l-image-preview-footer\">"), e.push(`<div class="l-image-preview-progress">${this._getProgress()}</div>`), e.push("<div data-action=\"operations\" class=\"l-image-preview-operations\">"), e.push(this._generateBtnString("zoom-in", "zoom-in")), e.push(this._generateBtnString("zoom-out", "zoom-out")), e.push(this._generateBtnString("reduction", "reduction")), e.push(this._generateBtnString("refresh-left", "refresh-left")), e.push(this._generateBtnString("refresh-right", "refresh-right")), e.push("</div></div>");
|
|
24
|
+
let t = this.urlList[this.currentIndex], r = this._getTransformStyleValue();
|
|
25
|
+
return e.push(`<img src="${t}" data-action="previewer" class="l-image-preview-img" style="transform: ${r};" />`), n("div", {
|
|
26
|
+
class: "l-image-preview--container",
|
|
27
|
+
innerHTML: e.join("")
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
_generateBtnString(e, t) {
|
|
31
|
+
return `<button aria-label="${e}" data-action="${e}" class="l-image-preview__btn l-image-preview__${e}"><l-${t}-icon></l-${t}-icon></button>`;
|
|
32
|
+
}
|
|
33
|
+
_getProgress() {
|
|
34
|
+
return `${this.currentIndex + 1} / ${this.urlList.length}`;
|
|
35
|
+
}
|
|
36
|
+
_getTransformStyleValue() {
|
|
37
|
+
return `scale3d(${this._scale}, ${this._scale}, 1) rotate3d(0, 0, 1, ${this._rotate}deg)`;
|
|
38
|
+
}
|
|
39
|
+
_updateImgAttr() {
|
|
40
|
+
let e = r(".l-image-preview-img", this.root);
|
|
41
|
+
e && (e.src = this.urlList[this.currentIndex], e.style.transform = this._getTransformStyleValue());
|
|
42
|
+
}
|
|
43
|
+
_updateProgress() {
|
|
44
|
+
let e = r(".l-image-preview-progress", this.root);
|
|
45
|
+
e && (e.innerHTML = this._getProgress());
|
|
46
|
+
}
|
|
47
|
+
_resetTransform() {
|
|
48
|
+
this._scale = 1, this._rotate = 0, this._updateImgAttr();
|
|
49
|
+
}
|
|
50
|
+
onAction(e) {
|
|
51
|
+
switch (e) {
|
|
52
|
+
case "close":
|
|
53
|
+
this.open = !1;
|
|
54
|
+
break;
|
|
55
|
+
case "prev":
|
|
56
|
+
this.currentIndex === 0 ? this.currentIndex = this.urlList.length - 1 : this.currentIndex--, this._resetTransform(), this._updateProgress();
|
|
57
|
+
break;
|
|
58
|
+
case "next":
|
|
59
|
+
this.currentIndex === this.urlList.length - 1 ? this.currentIndex = 0 : this.currentIndex++, this._resetTransform(), this._updateProgress();
|
|
60
|
+
break;
|
|
61
|
+
case "zoom-in":
|
|
62
|
+
this._transformScale("in");
|
|
63
|
+
break;
|
|
64
|
+
case "zoom-out":
|
|
65
|
+
this._transformScale("out");
|
|
66
|
+
break;
|
|
67
|
+
case "reduction":
|
|
68
|
+
this._resetTransform();
|
|
69
|
+
break;
|
|
70
|
+
case "refresh-left":
|
|
71
|
+
this._rotate -= 90, this._updateImgAttr();
|
|
72
|
+
break;
|
|
73
|
+
case "refresh-right": this._rotate += 90, this._updateImgAttr();
|
|
74
|
+
}
|
|
75
|
+
return !0;
|
|
76
|
+
}
|
|
77
|
+
_handleWhell = (e) => {
|
|
78
|
+
e.deltaY > 0 ? this._transformScale("out") : this._transformScale("in");
|
|
79
|
+
};
|
|
80
|
+
afterOpened() {
|
|
81
|
+
a(document, "wheel", this._handleWhell, { passive: !0 });
|
|
82
|
+
}
|
|
83
|
+
_transformScale(e) {
|
|
84
|
+
e === "in" ? this._scale < 3 && (this._scale += .25) : this._scale > .25 && (this._scale -= .25), this._updateImgAttr();
|
|
85
|
+
}
|
|
86
|
+
afterClosed() {
|
|
87
|
+
i(document, "wheel", this._handleWhell);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { o as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/components/image/image_preview.less?inline
|
|
2
|
+
var e = ".l-image-preview--container{justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative}.l-image-preview__btn,.l-image-preview-operations{background-color:#606666;justify-content:center;align-items:center;display:flex}.l-image-preview__btn{z-index:1;opacity:.8;cursor:pointer;color:#fff;background-color:#606666;border:none;border-radius:50%;outline:none;justify-content:center;align-items:center;width:40px;height:40px;font-size:20px;transition:color .3s ease-in-out;display:flex;position:absolute}.l-image-preview__btn:hover{color:var(--l-primary-color,#4998f6)}.l-image-preview__close{top:30px;right:30px}.l-image-preview__prev,.l-image-preview__next{top:50%;transform:translateY(-50%)}.l-image-preview__prev{left:30px}.l-image-preview__next{right:30px}.l-image-preview-footer{z-index:1;flex-direction:column;align-items:center;display:flex;position:absolute;bottom:30px;left:50%;transform:translate(-50%)}.l-image-preview-progress{color:#fff;margin-bottom:10px}.l-image-preview-operations{cursor:default;border-radius:20px;padding:0 25px}.l-image-preview-operations .l-image-preview__btn{width:40px;position:static}.l-image-preview-img{vertical-align:middle;transform-origin:50%;user-select:none;z-index:0;max-width:calc(100vw - 40px);max-height:calc(100vh - 200px);transition:transform .25s}";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as default };
|