litos-ui 0.12.2 → 0.14.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 +23 -2
- package/lib/base.js +37 -8
- package/lib/button/index.d.ts +3 -1
- package/lib/button/index.js +18 -19
- package/lib/carousel/index.d.ts +20 -0
- package/lib/carousel/index.js +280 -0
- package/lib/carousel/item.d.ts +6 -0
- package/lib/carousel/item.js +15 -0
- package/lib/carousel/timer.d.ts +5 -0
- package/lib/carousel/timer.js +19 -0
- package/lib/check/check.d.ts +22 -0
- package/lib/check/check.js +81 -0
- package/lib/check/checkbox.d.ts +7 -0
- package/lib/check/checkbox.js +25 -0
- package/lib/check/checkbox_group.d.ts +9 -0
- package/lib/check/checkbox_group.js +33 -0
- package/lib/check/index.d.ts +12 -0
- package/lib/check/index.js +35 -0
- package/lib/check/radio.d.ts +6 -0
- package/lib/check/radio.js +19 -0
- package/lib/check/radio_group.d.ts +6 -0
- package/lib/check/radio_group.js +24 -0
- package/lib/check-BlDsQQo0.js +4 -0
- package/lib/color_picker/index.d.ts +1 -1
- package/lib/color_picker/index.js +6 -6
- package/lib/date_picker/index.d.ts +22 -0
- package/lib/date_picker/index.js +99 -0
- package/lib/dialog/dialog_container.d.ts +28 -0
- package/lib/dialog/dialog_container.js +100 -0
- package/lib/dialog/index.d.ts +30 -0
- package/lib/dialog/index.js +86 -0
- package/lib/form/form_inner.d.ts +3 -5
- package/lib/form/form_inner.js +29 -31
- package/lib/form/form_item.d.ts +1 -3
- package/lib/form/form_item.js +30 -41
- package/lib/form/index.d.ts +0 -2
- package/lib/form/index.js +23 -25
- package/lib/icon/base.d.ts +0 -1
- package/lib/icon/base.js +15 -17
- package/lib/icon/close.d.ts +5 -0
- package/lib/icon/close.js +10 -0
- package/lib/icon/{mask_close.d.ts → close_filled.d.ts} +1 -1
- package/lib/icon/{mask_close.js → close_filled.js} +1 -1
- package/lib/index-dwS1N2uN.js +4 -0
- package/lib/index.d.ts +40 -6
- package/lib/index.js +120 -87
- package/lib/input/index.d.ts +6 -5
- package/lib/input/index.js +105 -57
- package/lib/list/index.d.ts +2 -3
- package/lib/list/index.js +17 -17
- package/lib/litos-ui.css +1 -1
- package/lib/loading/index.d.ts +45 -0
- package/lib/loading/index.js +141 -0
- package/lib/md_input/index.js +9 -9
- package/lib/menu/base.js +1 -0
- package/lib/menu/index.d.ts +31 -0
- package/lib/menu/index.js +95 -0
- package/lib/menu/menu_item.d.ts +6 -0
- package/lib/menu/menu_item.js +21 -0
- package/lib/menu/sub_menu.d.ts +15 -0
- package/lib/menu/sub_menu.js +82 -0
- package/lib/message/index.js +1 -1
- package/lib/modal/index.d.ts +40 -0
- package/lib/modal/index.js +153 -0
- package/lib/modal/modal_box.js +95 -0
- package/lib/popover/index.d.ts +1 -4
- package/lib/popover/index.js +6 -12
- package/lib/select_ori/index.d.ts +1 -3
- package/lib/select_ori/index.js +12 -16
- package/lib/switch/index.d.ts +0 -1
- package/lib/switch/index.js +8 -13
- package/lib/tabbar/index.d.ts +0 -1
- package/lib/tabbar/index.js +55 -63
- package/lib/theme/index.d.ts +1 -2
- package/lib/theme/index.js +9 -12
- package/lib/utils/index.d.ts +1 -6
- package/lib/utils/index.js +47 -54
- package/lib/utils/transition.js +4 -2
- package/package.json +8 -8
- package/styles/vars.css +1 -1
- package/lib/checkbox/index.d.ts +0 -17
- package/lib/checkbox/index.js +0 -135
- package/lib/index-391POYEJ.js +0 -4
- package/lib/litos-ui.min.js +0 -1
- package/lib/radio/index.d.ts +0 -28
- package/lib/radio/index.js +0 -122
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { $one as C, hasClass as v, addClass as s, getAttr as a, on as c, off as f, removeClass as $ } from "ph-utils/dom";
|
|
2
|
+
const D = (g) => {
|
|
3
|
+
let t, l, i;
|
|
4
|
+
function w(e) {
|
|
5
|
+
e.code === "Escape" && (e.preventDefault(), n());
|
|
6
|
+
}
|
|
7
|
+
function h(e) {
|
|
8
|
+
t.isSameNode(e.target) && i && i.maskClosable && n();
|
|
9
|
+
}
|
|
10
|
+
function p(e) {
|
|
11
|
+
const o = e.detail.action;
|
|
12
|
+
i.onAction != null && i.onAction(o, n);
|
|
13
|
+
}
|
|
14
|
+
function u(e) {
|
|
15
|
+
if (!i) {
|
|
16
|
+
let o = {
|
|
17
|
+
escClose: !0,
|
|
18
|
+
verticalAlign: "top",
|
|
19
|
+
maskClosable: !0,
|
|
20
|
+
showClose: 1,
|
|
21
|
+
...e
|
|
22
|
+
};
|
|
23
|
+
if (t = C(e.el), t) {
|
|
24
|
+
v(t, "l-dialog") || s(t, "l-dialog"), l = C("l-dialog-container", t);
|
|
25
|
+
const r = a(t, "vertical-align");
|
|
26
|
+
o.verticalAlign = r || "top", s(t, `l-dialog--vertical-${o.verticalAlign}`);
|
|
27
|
+
const m = a(t, "translate") || o.translate;
|
|
28
|
+
m && t.style.setProperty(
|
|
29
|
+
"--l-dialog-translate",
|
|
30
|
+
`translate3d(${m})`
|
|
31
|
+
);
|
|
32
|
+
const A = a(t, "width") || o.width;
|
|
33
|
+
A && t.style.setProperty("--l-dialog-width", A);
|
|
34
|
+
const d = a(t, "show-close", 1);
|
|
35
|
+
d === 2 && s(t, "l-dialog-close-outside"), l && l.setAttribute("show-close", `${d}`), o.showClose = d, c(t, "keydown", w), c(t, "click", h), l && c(l, "dialogAction", p);
|
|
36
|
+
}
|
|
37
|
+
i = o;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function b() {
|
|
41
|
+
t && (t.showModal(), s(t, "l-dialog--open"), s(document.body, "l-body--dialog-open"));
|
|
42
|
+
}
|
|
43
|
+
function n() {
|
|
44
|
+
t && v(t, "l-dialog--open") && (c(
|
|
45
|
+
t,
|
|
46
|
+
"transitionend",
|
|
47
|
+
() => {
|
|
48
|
+
t.close(), $(document.body, "l-body--dialog-open");
|
|
49
|
+
},
|
|
50
|
+
{ once: !0 }
|
|
51
|
+
), $(t, "l-dialog--open"));
|
|
52
|
+
}
|
|
53
|
+
function P() {
|
|
54
|
+
t && (n(), f(t, "keydown", w), f(t, "click", h), l && f(l, "dialogAction", p), l = void 0, t = void 0);
|
|
55
|
+
}
|
|
56
|
+
function y(e, o) {
|
|
57
|
+
if (i && (i[e] = o, t))
|
|
58
|
+
if (e === "verticalAlign") {
|
|
59
|
+
const r = t.className.replace(
|
|
60
|
+
/l-dialog--vertical-\w+/g,
|
|
61
|
+
function() {
|
|
62
|
+
return `l-dialog--vertical-${o || "top"}`;
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
t.className = r;
|
|
66
|
+
} else e === "translate" ? o ? t.style.setProperty(
|
|
67
|
+
"--l-dialog-translate",
|
|
68
|
+
`translate3d(${o})`
|
|
69
|
+
) : t.style.removeProperty("--l-dialog-translate") : e === "width" ? o ? t.style.setProperty("--l-dialog-width", o) : t.style.removeProperty("--l-dialog-width") : e === "showClose" && l && l.setAttribute("show-close", `${o}`);
|
|
70
|
+
}
|
|
71
|
+
function k(e) {
|
|
72
|
+
for (const o in e)
|
|
73
|
+
y(o, e[o]);
|
|
74
|
+
}
|
|
75
|
+
return g != null && u(g), {
|
|
76
|
+
init: u,
|
|
77
|
+
open: b,
|
|
78
|
+
close: n,
|
|
79
|
+
destroy: P,
|
|
80
|
+
setProp: y,
|
|
81
|
+
setProps: k
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
D as default
|
|
86
|
+
};
|
package/lib/form/form_inner.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
2
|
export default class FormInner extends BaseComponent {
|
|
3
3
|
disabled: boolean;
|
|
4
|
-
name?: string;
|
|
5
4
|
protected formAttrs: Record<string, any>;
|
|
6
5
|
protected formItemAttrs: Record<string, any>;
|
|
7
6
|
_value: any;
|
|
@@ -13,21 +12,20 @@ export default class FormInner extends BaseComponent {
|
|
|
13
12
|
* @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
|
|
14
13
|
*/
|
|
15
14
|
constructor(firstPushValue?: boolean);
|
|
16
|
-
set value(value: any);
|
|
17
15
|
get value(): any;
|
|
16
|
+
set value(value: any);
|
|
18
17
|
setValue(value: any): void;
|
|
19
18
|
getValue(): any;
|
|
20
19
|
static get observedAttributes(): string[];
|
|
21
20
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
22
|
-
protected attributeChange(
|
|
21
|
+
protected attributeChange(_name: string, _oldValue: string, _newValue: string): void;
|
|
23
22
|
connectedCallback(): void;
|
|
24
23
|
disconnectedCallback(): void;
|
|
25
24
|
isDisabled(): any;
|
|
26
25
|
getName(): any;
|
|
27
26
|
private _getForm;
|
|
28
27
|
private _formAttributeChanged;
|
|
29
|
-
|
|
30
|
-
protected _changeDisabled(): void;
|
|
28
|
+
protected disabledChange(): void;
|
|
31
29
|
protected pushValueChange(): void;
|
|
32
30
|
private _resetFieldValue;
|
|
33
31
|
reset(): void;
|
package/lib/form/form_inner.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { parseAttrValue as
|
|
3
|
-
import { add as l, remove as
|
|
4
|
-
|
|
1
|
+
import o from "../base.js";
|
|
2
|
+
import { parseAttrValue as d } from "../utils/index.js";
|
|
3
|
+
import { add as l, remove as u, emit as f } from "../utils/event.js";
|
|
4
|
+
import { getAttr as m } from "ph-utils/dom";
|
|
5
|
+
class _ extends o {
|
|
5
6
|
disabled = !1;
|
|
6
|
-
name = void 0;
|
|
7
7
|
formAttrs = {};
|
|
8
8
|
formItemAttrs = {};
|
|
9
9
|
_value = "";
|
|
@@ -15,14 +15,14 @@ class b extends d {
|
|
|
15
15
|
* @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
|
|
16
16
|
*/
|
|
17
17
|
constructor(t = !0) {
|
|
18
|
-
super(), this._firstPushValue = t;
|
|
18
|
+
super(!0, { delegatesFocus: !0 }), this._firstPushValue = t;
|
|
19
|
+
}
|
|
20
|
+
get value() {
|
|
21
|
+
return this._value;
|
|
19
22
|
}
|
|
20
23
|
set value(t) {
|
|
21
24
|
this.setValue(t);
|
|
22
25
|
}
|
|
23
|
-
get value() {
|
|
24
|
-
return this.getValue();
|
|
25
|
-
}
|
|
26
26
|
setValue(t) {
|
|
27
27
|
this._value = t, this.pushValueChange();
|
|
28
28
|
}
|
|
@@ -30,17 +30,15 @@ class b extends d {
|
|
|
30
30
|
return this._value;
|
|
31
31
|
}
|
|
32
32
|
static get observedAttributes() {
|
|
33
|
-
return ["disabled"];
|
|
33
|
+
return ["disabled", "value"];
|
|
34
34
|
}
|
|
35
|
-
attributeChangedCallback(t,
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} else
|
|
41
|
-
this.attributeChange(t, e, r);
|
|
35
|
+
attributeChangedCallback(t, r, e) {
|
|
36
|
+
if (t === "disabled") {
|
|
37
|
+
const i = d(e, !1, t);
|
|
38
|
+
i !== this.disabled && (this.disabled = i, this.disabledChange());
|
|
39
|
+
} else t === "value" ? this.value = e : this.attributeChange(t, r, e);
|
|
42
40
|
}
|
|
43
|
-
attributeChange(t,
|
|
41
|
+
attributeChange(t, r, e) {
|
|
44
42
|
}
|
|
45
43
|
connectedCallback() {
|
|
46
44
|
const t = this._getForm();
|
|
@@ -51,7 +49,7 @@ class b extends d {
|
|
|
51
49
|
), super.connectedCallback();
|
|
52
50
|
}
|
|
53
51
|
disconnectedCallback() {
|
|
54
|
-
this.formAttrs.id && (
|
|
52
|
+
this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(
|
|
55
53
|
this.formItemAttrs.id,
|
|
56
54
|
"attributeChanged",
|
|
57
55
|
this._formAttributeChanged
|
|
@@ -61,17 +59,18 @@ class b extends d {
|
|
|
61
59
|
return this.disabled === !0 || this.formItemAttrs.disabled === !0 ? !0 : this.formAttrs.disabled || !1;
|
|
62
60
|
}
|
|
63
61
|
getName() {
|
|
64
|
-
|
|
62
|
+
const t = m(this, "name");
|
|
63
|
+
return t || this.formItemAttrs.name;
|
|
65
64
|
}
|
|
66
65
|
_getForm() {
|
|
67
|
-
let t = this.parentElement,
|
|
66
|
+
let t = this.parentElement, r = {}, e = {};
|
|
68
67
|
for (; t != null; ) {
|
|
69
68
|
const i = t.tagName;
|
|
70
69
|
if (i === "L-FORM") {
|
|
71
70
|
const a = t.sharedAttrs;
|
|
72
71
|
for (let s = 0; s < a.length; s++) {
|
|
73
72
|
const h = a[s];
|
|
74
|
-
|
|
73
|
+
r[h] = t[h];
|
|
75
74
|
}
|
|
76
75
|
break;
|
|
77
76
|
}
|
|
@@ -80,25 +79,24 @@ class b extends d {
|
|
|
80
79
|
const a = t.sharedAttrs;
|
|
81
80
|
for (let s = 0; s < a.length; s++) {
|
|
82
81
|
const h = a[s];
|
|
83
|
-
|
|
82
|
+
e[h] = t[h];
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
t = t.parentElement;
|
|
87
86
|
}
|
|
88
87
|
return t = null, {
|
|
89
|
-
formAttr:
|
|
90
|
-
formItemAttr:
|
|
88
|
+
formAttr: r,
|
|
89
|
+
formItemAttr: e
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
|
-
_formAttributeChanged = (t,
|
|
94
|
-
|
|
92
|
+
_formAttributeChanged = (t, r, e) => {
|
|
93
|
+
e === this.formAttrs.formId ? this.formAttrs[t] = r : this.formItemAttrs[t] = r, t === "disabled" && this.disabledChange();
|
|
95
94
|
};
|
|
96
|
-
|
|
97
|
-
_changeDisabled() {
|
|
95
|
+
disabledChange() {
|
|
98
96
|
}
|
|
99
97
|
pushValueChange() {
|
|
100
98
|
const t = this.getName();
|
|
101
|
-
this.formAttrs.id && t &&
|
|
99
|
+
this.formAttrs.id && t && f(
|
|
102
100
|
this.formAttrs.id,
|
|
103
101
|
"valueChange",
|
|
104
102
|
t,
|
|
@@ -114,5 +112,5 @@ class b extends d {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
export {
|
|
117
|
-
|
|
115
|
+
_ as default
|
|
118
116
|
};
|
package/lib/form/form_item.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export default class FormItem extends BaseComponent {
|
|
|
9
9
|
error?: string;
|
|
10
10
|
/** 标签文本 */
|
|
11
11
|
label?: string;
|
|
12
|
-
id: string;
|
|
13
12
|
/** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
|
|
14
13
|
verify?: string;
|
|
15
14
|
/** 验证失败错误信息 */
|
|
@@ -20,7 +19,6 @@ export default class FormItem extends BaseComponent {
|
|
|
20
19
|
innerBlock: boolean;
|
|
21
20
|
labelPosition?: "left" | "right" | "top";
|
|
22
21
|
private formId?;
|
|
23
|
-
constructor();
|
|
24
22
|
static get observedAttributes(): string[];
|
|
25
23
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
26
24
|
connectedCallback(): void;
|
|
@@ -31,7 +29,7 @@ export default class FormItem extends BaseComponent {
|
|
|
31
29
|
message?: string;
|
|
32
30
|
}): void;
|
|
33
31
|
setError(error: string): void;
|
|
34
|
-
render():
|
|
32
|
+
render(): DocumentFragment;
|
|
35
33
|
private _validateChange;
|
|
36
34
|
private _updateError;
|
|
37
35
|
private _updateLabel;
|
package/lib/form/form_item.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { emit as o, add as
|
|
5
|
-
import { random as
|
|
6
|
-
const u = ':host{display:
|
|
7
|
-
class
|
|
1
|
+
import { $$ as i, $one as s, addClass as n, removeClass as d } from "ph-utils/dom";
|
|
2
|
+
import { parseAttrValue as h, initAttr as m } from "../utils/index.js";
|
|
3
|
+
import f from "../base.js";
|
|
4
|
+
import { emit as o, add as p, clear as c, remove as b } from "../utils/event.js";
|
|
5
|
+
import { random as a } from "ph-utils";
|
|
6
|
+
const u = ':host{display:var(--l-form-item-display, flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-edit-height, 32px);line-height:var(--l-form-edit-height, 32px);color:#606266;padding:0 10px 0 0;box-sizing:border-box}.l-form-item__label:empty{display:var(--l-form-label-empty-display, inline-block)}:host(.is-required) .l-form-item__label:before{content:"*";margin-right:4px;color:var(--l-warn-color, #f56c6c);vertical-align:middle}.l-form-item__content{flex:1;position:relative;display:flex;align-items:center}.l-form-item__error{font-size:12px;line-height:1;position:absolute;top:100%;left:0;color:var(--nt-error-color, #ed3f13);padding-top:3px}: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}';
|
|
7
|
+
class I extends f {
|
|
8
8
|
static baseName = "form-item";
|
|
9
9
|
disabled = !1;
|
|
10
10
|
sharedAttrs = ["disabled", "id", "name", "innerBlock"];
|
|
@@ -13,7 +13,6 @@ class $ extends h {
|
|
|
13
13
|
error;
|
|
14
14
|
/** 标签文本 */
|
|
15
15
|
label;
|
|
16
|
-
id;
|
|
17
16
|
/** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
|
|
18
17
|
verify;
|
|
19
18
|
/** 验证失败错误信息 */
|
|
@@ -24,9 +23,6 @@ class $ extends h {
|
|
|
24
23
|
innerBlock = !1;
|
|
25
24
|
labelPosition = "right";
|
|
26
25
|
formId;
|
|
27
|
-
constructor() {
|
|
28
|
-
super(), d(this), this.id == null && (this.id = `l-fi${s(3)}-${s(6)}`);
|
|
29
|
-
}
|
|
30
26
|
static get observedAttributes() {
|
|
31
27
|
return ["error", "label", "disabled"];
|
|
32
28
|
}
|
|
@@ -36,12 +32,12 @@ class $ extends h {
|
|
|
36
32
|
else if (e === "label")
|
|
37
33
|
this.label = r, this._updateLabel();
|
|
38
34
|
else if (e === "disabled") {
|
|
39
|
-
const l =
|
|
35
|
+
const l = h(r, !1, e);
|
|
40
36
|
l !== this.disabled && (o(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
connectedCallback() {
|
|
44
|
-
if (
|
|
40
|
+
if (m(this), this.id == null && (this.id = `l-fi${a(3)}-${a(6)}`), this.loadStyleText([u]), super.connectedCallback(), this.formId = this._getFormId(), this.name && this.formId) {
|
|
45
41
|
let e = this.verify?.split("|") || [];
|
|
46
42
|
this.pattern && e.push(new RegExp(this.pattern));
|
|
47
43
|
const t = {
|
|
@@ -50,11 +46,11 @@ class $ extends h {
|
|
|
50
46
|
message: this.validity,
|
|
51
47
|
rules: e
|
|
52
48
|
};
|
|
53
|
-
o(this.formId, "ruleChange", t),
|
|
49
|
+
o(this.formId, "ruleChange", t), p(this.formId, "validateChange", this._validateChange);
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
disconnectedCallback() {
|
|
57
|
-
|
|
53
|
+
c(this.id), this.formId && b(this.formId, "validateChange", this._validateChange);
|
|
58
54
|
}
|
|
59
55
|
setRules(e) {
|
|
60
56
|
const t = { ...e, key: this.name };
|
|
@@ -64,17 +60,18 @@ class $ extends h {
|
|
|
64
60
|
this.error = e;
|
|
65
61
|
}
|
|
66
62
|
render() {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
this.required && this.classList.add("is-required"), this.error && this.classList.add("is-error"), this.classList.add(`l-form-item--${this.labelPosition}`);
|
|
64
|
+
const e = document.createDocumentFragment();
|
|
65
|
+
this.label != null && e.appendChild(
|
|
66
|
+
i("label", {
|
|
67
|
+
class: "l-form-item__label",
|
|
68
|
+
textContent: this.label
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
const t = i("div", { class: "l-form-item__content" }), r = i("slot");
|
|
72
|
+
return t.appendChild(r), this.error && t.appendChild(
|
|
73
|
+
i("div", { class: "l-form-item__error", textContent: this.error })
|
|
74
|
+
), e.appendChild(t), e;
|
|
78
75
|
}
|
|
79
76
|
_validateChange = (e, t) => {
|
|
80
77
|
const r = e === !0 ? void 0 : e[this.name];
|
|
@@ -82,28 +79,20 @@ class $ extends h {
|
|
|
82
79
|
};
|
|
83
80
|
_updateError() {
|
|
84
81
|
if (!this.rendered) return;
|
|
85
|
-
let e =
|
|
82
|
+
let e = s(".l-form-item__error", this.root);
|
|
86
83
|
if (e)
|
|
87
84
|
this.error ? e.textContent = this.error : e.remove();
|
|
88
85
|
else if (this.error) {
|
|
89
86
|
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this.error;
|
|
90
|
-
const
|
|
91
|
-
|
|
87
|
+
const t = s(".l-form-item__content", this.root);
|
|
88
|
+
t && t.appendChild(e);
|
|
92
89
|
}
|
|
93
|
-
|
|
94
|
-
t && (this.error ? n(t, "is-error") : m(t, "is-error"));
|
|
90
|
+
this.error ? n(this, "is-error") : d(this, "is-error");
|
|
95
91
|
}
|
|
96
92
|
_updateLabel() {
|
|
97
93
|
if (!this.rendered) return;
|
|
98
|
-
let e =
|
|
99
|
-
|
|
100
|
-
if (this.label != null) {
|
|
101
|
-
e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this.label;
|
|
102
|
-
const t = i(".l-form-item", this.root);
|
|
103
|
-
t && t.appendChild(e);
|
|
104
|
-
}
|
|
105
|
-
} else
|
|
106
|
-
this.label != null ? e.textContent = this.label : e.remove();
|
|
94
|
+
let e = s(".l-form-item__label", this.root);
|
|
95
|
+
e == null ? this.label != null && (e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this.label, this.root.prepend(e)) : this.label != null ? e.textContent = this.label : e.remove();
|
|
107
96
|
}
|
|
108
97
|
_getFormId() {
|
|
109
98
|
let e = this.parentElement, t;
|
|
@@ -120,5 +109,5 @@ class $ extends h {
|
|
|
120
109
|
}
|
|
121
110
|
}
|
|
122
111
|
export {
|
|
123
|
-
|
|
112
|
+
I as default
|
|
124
113
|
};
|
package/lib/form/index.d.ts
CHANGED
|
@@ -7,14 +7,12 @@ export default class Form extends BaseComponent {
|
|
|
7
7
|
inline: boolean;
|
|
8
8
|
labelPosition?: "left" | "right" | "top";
|
|
9
9
|
labelWidth?: string;
|
|
10
|
-
id: string;
|
|
11
10
|
disabled: boolean;
|
|
12
11
|
sharedAttrs: string[];
|
|
13
12
|
validator: Validator;
|
|
14
13
|
innerBlock: boolean;
|
|
15
14
|
novalidate: boolean;
|
|
16
15
|
private _data?;
|
|
17
|
-
private emit;
|
|
18
16
|
constructor();
|
|
19
17
|
static get observedAttributes(): string[];
|
|
20
18
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
package/lib/form/index.js
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
import { $one as
|
|
1
|
+
import { $one as h, formatClass as o, formatStyle as f } from "ph-utils/dom";
|
|
2
2
|
import m from "../base.js";
|
|
3
|
-
import {
|
|
3
|
+
import { parseAttrValue as c, initAttr as u } from "../utils/index.js";
|
|
4
4
|
import { random as d } from "ph-utils";
|
|
5
|
-
import { emit as l, add as
|
|
5
|
+
import { emit as l, add as n, clear as v } from "../utils/event.js";
|
|
6
6
|
import p from "ph-utils/validator";
|
|
7
|
-
const b = ":host{display:block}.l-form{display:
|
|
7
|
+
const b = ":host{display:block}.l-form{display:flex;gap:20px;flex-flow:column nowrap}.l-form-inline{display:flex;gap:20px;flex-flow:row wrap}.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}";
|
|
8
8
|
class $ extends m {
|
|
9
9
|
static baseName = "form";
|
|
10
10
|
/** 是否行内表单 */
|
|
11
11
|
inline = !1;
|
|
12
12
|
labelPosition = "right";
|
|
13
|
-
labelWidth;
|
|
14
|
-
id;
|
|
13
|
+
labelWidth = "80px";
|
|
15
14
|
disabled = !1;
|
|
16
15
|
sharedAttrs = ["disabled", "id", "innerBlock"];
|
|
17
16
|
validator;
|
|
18
17
|
innerBlock = !1;
|
|
19
18
|
novalidate = !1;
|
|
20
19
|
_data;
|
|
21
|
-
emit;
|
|
22
20
|
constructor() {
|
|
23
|
-
super(),
|
|
21
|
+
super(), this.validator = new p([]);
|
|
24
22
|
}
|
|
25
23
|
static get observedAttributes() {
|
|
26
24
|
return ["disabled", "label-position"];
|
|
27
25
|
}
|
|
28
|
-
attributeChangedCallback(t, e,
|
|
26
|
+
attributeChangedCallback(t, e, i) {
|
|
29
27
|
if (t === "disabled") {
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
const a = c(i, !1, t);
|
|
29
|
+
a !== this.disabled && (l(this.id, "attributeChanged", t, a, this.id), this.disabled = a);
|
|
32
30
|
} else if (t === "label-position") {
|
|
33
|
-
const
|
|
34
|
-
|
|
31
|
+
const a = h("form", this.root);
|
|
32
|
+
a && (a.className = o([
|
|
35
33
|
"l-form",
|
|
36
34
|
this.inline ? "l-form-inline" : void 0,
|
|
37
|
-
`l-form--${
|
|
35
|
+
`l-form--${i}`
|
|
38
36
|
]));
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
connectedCallback() {
|
|
42
|
-
this.loadStyleText([b]), super.connectedCallback(),
|
|
40
|
+
u(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(), n(this.id, "ruleChange", this.ruleChange), n(this.id, "valueChange", this._valueChange);
|
|
43
41
|
}
|
|
44
42
|
disconnectedCallback() {
|
|
45
43
|
v(this.id), this.validator = void 0;
|
|
@@ -57,10 +55,10 @@ class $ extends m {
|
|
|
57
55
|
ruleChange = (t) => {
|
|
58
56
|
this.validator.addSchema(t);
|
|
59
57
|
};
|
|
60
|
-
_valueChange = (t, e,
|
|
58
|
+
_valueChange = (t, e, i = !0) => {
|
|
61
59
|
this._data == null && (this._data = {});
|
|
62
|
-
const
|
|
63
|
-
this._data[t] = e, !this.novalidate &&
|
|
60
|
+
const a = Object.hasOwn(this._data, t);
|
|
61
|
+
this._data[t] = e, !this.novalidate && a && i && this.validator.validateKey(t, e, this._data).then(() => {
|
|
64
62
|
l(this.id, "validateChange", !0, t);
|
|
65
63
|
}).catch((s) => {
|
|
66
64
|
l(this.id, "validateChange", s.detail, t);
|
|
@@ -70,17 +68,17 @@ class $ extends m {
|
|
|
70
68
|
const e = [];
|
|
71
69
|
if (this._data != null) {
|
|
72
70
|
if (Array.isArray(t))
|
|
73
|
-
for (let
|
|
74
|
-
const s = t[
|
|
71
|
+
for (let i = 0, a = t.length; i < a; i++) {
|
|
72
|
+
const s = t[i];
|
|
75
73
|
e.push(this.validator.validateKey(s, this._data[s], this._data));
|
|
76
74
|
}
|
|
77
75
|
else
|
|
78
76
|
e.push(
|
|
79
77
|
this.validator.validateKey(t, this._data[t], this._data)
|
|
80
78
|
);
|
|
81
|
-
Promise.allSettled(e).then((
|
|
82
|
-
for (let
|
|
83
|
-
const r = a
|
|
79
|
+
Promise.allSettled(e).then((i) => {
|
|
80
|
+
for (let a = 0, s = i.length; a < s; a++) {
|
|
81
|
+
const r = i[a];
|
|
84
82
|
r.status === "rejected" ? l(
|
|
85
83
|
this.id,
|
|
86
84
|
"validateChange",
|
|
@@ -98,8 +96,8 @@ class $ extends m {
|
|
|
98
96
|
this.clearValidate(), l(this.id, "reset");
|
|
99
97
|
}
|
|
100
98
|
submit() {
|
|
101
|
-
this.novalidate ? this.dispatchEvent(
|
|
102
|
-
t && this.dispatchEvent(
|
|
99
|
+
this.novalidate ? this.dispatchEvent(new CustomEvent("submit")) : this.validate().then((t) => {
|
|
100
|
+
t && this.dispatchEvent(new CustomEvent("submit"));
|
|
103
101
|
});
|
|
104
102
|
}
|
|
105
103
|
/**
|
package/lib/icon/base.d.ts
CHANGED
package/lib/icon/base.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import o from "../base.js";
|
|
2
|
+
import { initAttr as c } from "../utils/index.js";
|
|
3
|
+
const d = ":host{display:inline-flex}.l-icon{width:1em;height:1em;fill:currentColor;vertical-align:middle;display:inline-block}";
|
|
4
|
+
class f extends o {
|
|
4
5
|
static baseName = "base-icon";
|
|
5
|
-
useLink;
|
|
6
|
-
viewBox;
|
|
7
|
-
constructor() {
|
|
8
|
-
super(), this.useLink = !1, this.viewBox = "0 0 1024 1024";
|
|
9
|
-
}
|
|
6
|
+
useLink = !1;
|
|
7
|
+
viewBox = "0 0 1024 1024";
|
|
10
8
|
connectedCallback() {
|
|
11
|
-
this.loadStyleText([
|
|
9
|
+
c(this), this.loadStyleText([d]), this.render(), this.rendered = !0;
|
|
12
10
|
}
|
|
13
11
|
render() {
|
|
14
|
-
const e = this.createEl("svg")
|
|
15
|
-
e.classList.add("l-icon"),
|
|
12
|
+
const e = this.createEl("svg");
|
|
13
|
+
e.classList.add("l-icon"), this.useLink || e.setAttribute("viewBox", this.viewBox);
|
|
16
14
|
const t = this.renderChildren();
|
|
17
15
|
if (typeof t == "string")
|
|
18
16
|
if (t === "") {
|
|
19
|
-
const
|
|
20
|
-
for (let i = 0,
|
|
21
|
-
const
|
|
22
|
-
|
|
17
|
+
const n = this.children, s = [];
|
|
18
|
+
for (let i = 0, r = n.length; i < r; i++) {
|
|
19
|
+
const l = n[i];
|
|
20
|
+
s.push(l.outerHTML);
|
|
23
21
|
}
|
|
24
|
-
e.innerHTML =
|
|
22
|
+
e.innerHTML = s.join("");
|
|
25
23
|
} else
|
|
26
24
|
e.innerHTML = t;
|
|
27
25
|
else
|
|
@@ -36,5 +34,5 @@ class p extends d {
|
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
export {
|
|
39
|
-
|
|
37
|
+
f as default
|
|
40
38
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
class l extends e {
|
|
3
|
+
static baseName = "close-icon";
|
|
4
|
+
renderChildren() {
|
|
5
|
+
return '<path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path>';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
l as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const r = ":host{--l-input-border-color: var(--l-border-color, #dedede);display:inline-flex;width:var(--l-input-width, 170px);height:var(--l-form-edit-height, 32px);align-items:center;padding:0 7px;border:1px solid var(--l-input-border-color, #dedede);transition:border-color .3s;border-radius:4px;vertical-align:middle}:host(:focus){--l-input-border-color: var(--l-primary-color, #722ed1)}:host(.is-disabled){background-color:var(--l-disabled-color, #f5f7fa)}:host(.is-error){--l-input-border-color: #ed3f13}.l-input__prefix,.l-input__suffix{color:#a8abb2;font-size:14px;display:inline-flex;flex-shrink:0}.l-input__prefix{margin-right:5px}.l-input__suffix{margin-left:5px}.l-clearable{cursor:pointer}.l-clearable:hover{color:#999}.l-input__inner{outline:none;border:none;box-sizing:border-box;width:100%;max-width:100%;height:100%;flex-grow:1;text-align:inherit}.l-input__inner:disabled{background-color:transparent}";
|
|
2
|
+
export {
|
|
3
|
+
r as i
|
|
4
|
+
};
|