litos-ui 0.16.1 → 0.17.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 +11 -2
- package/lib/base.js +59 -27
- package/lib/button/index.d.ts +18 -3
- package/lib/button/index.js +65 -68
- package/lib/check/check.d.ts +14 -5
- package/lib/check/check.js +67 -29
- package/lib/check/checkbox.js +5 -12
- package/lib/check/checkbox_group.d.ts +0 -5
- package/lib/check/checkbox_group.js +3 -29
- package/lib/check/index.d.ts +14 -4
- package/lib/check/index.js +48 -28
- package/lib/check/radio.js +6 -14
- package/lib/check/radio_group.d.ts +1 -2
- package/lib/check/radio_group.js +5 -19
- package/lib/check-CksURvTv.js +4 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/form/form_inner.d.ts +17 -10
- package/lib/form/form_inner.js +83 -80
- package/lib/form/form_item.d.ts +23 -23
- package/lib/form/form_item.js +107 -90
- package/lib/form/index.d.ts +21 -14
- package/lib/form/index.js +92 -70
- package/lib/form/types.d.ts +7 -0
- package/lib/form/types.js +1 -0
- package/lib/index-Blf4-a2-.js +4 -0
- package/lib/index-CrMiSe0x.js +249 -0
- package/lib/index.js +162 -160
- package/lib/input/index.d.ts +24 -25
- package/lib/input/index.js +99 -89
- package/lib/loading/index.d.ts +2 -0
- package/lib/loading/index.js +50 -64
- package/lib/message/index.js +9 -9
- package/lib/modal/index.d.ts +1 -6
- package/lib/modal/index.js +40 -46
- package/lib/select_ori/index.js +1 -1
- package/lib/utils/context_provide.d.ts +9 -0
- package/lib/utils/context_provide.js +22 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +41 -33
- package/package.json +8 -8
- package/styles/loading.css +5 -3
- package/lib/check-C7YSuH60.js +0 -4
- package/lib/index-DvcllHRh.js +0 -4
- package/lib/utils/event.d.ts +0 -30
package/lib/form/form_item.js
CHANGED
|
@@ -1,119 +1,136 @@
|
|
|
1
|
-
import { $$ as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class I extends f {
|
|
1
|
+
import { $$ as s, addClass as a, removeClass as n, $one as l } from "ph-utils/dom";
|
|
2
|
+
import { stopSignal as m, parseAttrValue as h } from "../utils/index.js";
|
|
3
|
+
import c from "../utils/context_provide.js";
|
|
4
|
+
import { s as p, e as d } from "../index-CrMiSe0x.js";
|
|
5
|
+
const f = ':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-control-height, 32px);line-height:var(--l-form-control-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}';
|
|
6
|
+
class v extends c {
|
|
8
7
|
static baseName = "form-item";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** 验证失败错误信息 */
|
|
18
|
-
validity;
|
|
19
|
-
/** 自定义验证的正则 */
|
|
20
|
-
pattern;
|
|
21
|
-
name;
|
|
22
|
-
innerBlock = !1;
|
|
23
|
-
labelPosition = "right";
|
|
24
|
-
formId;
|
|
25
|
-
#e;
|
|
26
|
-
static get observedAttributes() {
|
|
27
|
-
return ["error", "label", "disabled"];
|
|
28
|
-
}
|
|
29
|
-
get error() {
|
|
30
|
-
return this.#e;
|
|
8
|
+
formErrors;
|
|
9
|
+
// 表单验证错误
|
|
10
|
+
_errorSignalStop;
|
|
11
|
+
constructor() {
|
|
12
|
+
super(), this.contextEventName = "form-item-context-request", this._state = {
|
|
13
|
+
labelPosition: "right",
|
|
14
|
+
required: !1
|
|
15
|
+
}, this.context = p({ innerBlock: !1 });
|
|
31
16
|
}
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
];
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
attributeChanged(e, t, r) {
|
|
31
|
+
switch (e) {
|
|
32
|
+
case "error":
|
|
33
|
+
case "label":
|
|
34
|
+
case "verify":
|
|
35
|
+
case "pattern":
|
|
36
|
+
case "validity":
|
|
37
|
+
this._state[e] = r;
|
|
38
|
+
break;
|
|
39
|
+
case "label-position":
|
|
40
|
+
this._state.labelPosition = r;
|
|
41
|
+
break;
|
|
42
|
+
case "inner-block":
|
|
43
|
+
const i = h(r, !1, e);
|
|
44
|
+
this.context({ innerBlock: i });
|
|
45
|
+
break;
|
|
46
|
+
case "required":
|
|
47
|
+
const o = h(r, !1, e);
|
|
48
|
+
this._state.required = o;
|
|
49
|
+
break;
|
|
50
|
+
case "prop":
|
|
51
|
+
this.context({ ...this.context(), prop: r });
|
|
52
|
+
break;
|
|
43
53
|
}
|
|
44
54
|
}
|
|
55
|
+
updateDOM(e) {
|
|
56
|
+
e.has("required") && this._updateRequired(), e.has("label") && this._updateLabel(), e.has("error") && this._updateError();
|
|
57
|
+
}
|
|
45
58
|
connectedCallback() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const t =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
message: this.validity,
|
|
53
|
-
rules: e
|
|
54
|
-
};
|
|
55
|
-
s(this.formId, "ruleChange", t), c(this.formId, "validateChange", this._validateChange);
|
|
56
|
-
}
|
|
59
|
+
this.loadStyleText([f]), super.connectedCallback(), this._updateRequired(), this._parseSchema(), this.emitInject("form-context-request", ((e, t) => {
|
|
60
|
+
this.formErrors = t;
|
|
61
|
+
})), this._errorSignalStop = d(() => {
|
|
62
|
+
const e = this.context().prop, t = this.formErrors ? this.formErrors() : null;
|
|
63
|
+
e && t && (this._state.error = t[e], this._updateError());
|
|
64
|
+
});
|
|
57
65
|
}
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
beforeDestroy() {
|
|
67
|
+
this._errorSignalStop = m(this._errorSignalStop);
|
|
60
68
|
}
|
|
61
69
|
setRules(e) {
|
|
62
|
-
const t =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
const t = this.getAttr("prop");
|
|
71
|
+
if (t) {
|
|
72
|
+
const r = { ...e, key: t };
|
|
73
|
+
this._updateRules(r);
|
|
74
|
+
}
|
|
67
75
|
}
|
|
68
76
|
render() {
|
|
69
|
-
this.
|
|
77
|
+
this.classList.add(`l-form-item--${this._state.labelPosition}`);
|
|
70
78
|
const e = document.createDocumentFragment();
|
|
71
|
-
this.label != null && e.appendChild(
|
|
72
|
-
|
|
79
|
+
this._state.label != null && e.appendChild(
|
|
80
|
+
s("label", {
|
|
73
81
|
class: "l-form-item__label",
|
|
74
|
-
textContent: this.label
|
|
82
|
+
textContent: this._state.label
|
|
75
83
|
})
|
|
76
84
|
);
|
|
77
|
-
const t =
|
|
78
|
-
return t.appendChild(r), this.error && t.appendChild(
|
|
79
|
-
|
|
85
|
+
const t = s("div", { class: "l-form-item__content" }), r = s("slot");
|
|
86
|
+
return t.appendChild(r), this._state.error && t.appendChild(
|
|
87
|
+
s("div", { class: "l-form-item__error", textContent: this._state.error })
|
|
80
88
|
), e.appendChild(t), e;
|
|
81
89
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
_updateRequired() {
|
|
91
|
+
this._state.required ? a(this, "is-required") : n(this, "is-required");
|
|
92
|
+
}
|
|
93
|
+
_parseSchema() {
|
|
94
|
+
const e = this.context().prop;
|
|
95
|
+
if (e) {
|
|
96
|
+
let t = [];
|
|
97
|
+
const r = this._state.verify;
|
|
98
|
+
r && (t = r.split("|"));
|
|
99
|
+
const i = this._state.pattern;
|
|
100
|
+
i && t.push(new RegExp(i));
|
|
101
|
+
const o = {
|
|
102
|
+
key: e,
|
|
103
|
+
required: this._state.required,
|
|
104
|
+
message: this._state.validity,
|
|
105
|
+
rules: t
|
|
106
|
+
};
|
|
107
|
+
this._updateRules(o);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
86
110
|
_updateError() {
|
|
87
|
-
if (!this.rendered) return;
|
|
88
|
-
let e =
|
|
111
|
+
if (this._state.error ? a(this, "is-error") : n(this, "is-error"), !this.rendered) return;
|
|
112
|
+
let e = l(".l-form-item__error", this.root);
|
|
89
113
|
if (e)
|
|
90
|
-
this.error ? e.textContent = this.error : e.remove();
|
|
91
|
-
else if (this.error) {
|
|
92
|
-
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this.error;
|
|
93
|
-
const t =
|
|
114
|
+
this._state.error ? e.textContent = this._state.error : e.remove();
|
|
115
|
+
else if (this._state.error) {
|
|
116
|
+
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this._state.error;
|
|
117
|
+
const t = l(".l-form-item__content", this.root);
|
|
94
118
|
t && t.appendChild(e);
|
|
95
119
|
}
|
|
96
|
-
this.error ? n(this, "is-error") : d(this, "is-error");
|
|
97
120
|
}
|
|
98
121
|
_updateLabel() {
|
|
99
122
|
if (!this.rendered) return;
|
|
100
|
-
let e =
|
|
101
|
-
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();
|
|
123
|
+
let e = l(".l-form-item__label", this.root);
|
|
124
|
+
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.textContent = this._state.label : e.remove();
|
|
102
125
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
if (r === "BODY") break;
|
|
112
|
-
e = e.parentElement;
|
|
113
|
-
}
|
|
114
|
-
return e = null, t;
|
|
126
|
+
_updateRules(e) {
|
|
127
|
+
this.emit("form-rule-change", {
|
|
128
|
+
bubbles: !0,
|
|
129
|
+
composed: !0,
|
|
130
|
+
detail: e
|
|
131
|
+
});
|
|
115
132
|
}
|
|
116
133
|
}
|
|
117
134
|
export {
|
|
118
|
-
|
|
135
|
+
v as default
|
|
119
136
|
};
|
package/lib/form/index.d.ts
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import BaseComponent from "../base";
|
|
2
|
-
import type { SchemaType } from "ph-utils/validator";
|
|
3
1
|
import Validator from "ph-utils/validator";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type { FormSignal } from "./types";
|
|
3
|
+
import BaseComponent from "../base";
|
|
4
|
+
interface FormState {
|
|
7
5
|
inline: boolean;
|
|
8
|
-
labelPosition
|
|
9
|
-
labelWidth
|
|
10
|
-
disabled: boolean;
|
|
11
|
-
sharedAttrs: string[];
|
|
12
|
-
validator: Validator;
|
|
13
|
-
innerBlock: boolean;
|
|
6
|
+
labelPosition: "left" | "right" | "top";
|
|
7
|
+
labelWidth: string;
|
|
14
8
|
novalidate: boolean;
|
|
9
|
+
}
|
|
10
|
+
export default class Form extends BaseComponent<FormState> {
|
|
11
|
+
static baseName: string;
|
|
12
|
+
validator: Validator;
|
|
15
13
|
private _data?;
|
|
14
|
+
context: Signal<FormSignal>;
|
|
15
|
+
errors: Signal<Record<string, string | undefined>>;
|
|
16
|
+
resetCtx: Signal<number>;
|
|
16
17
|
constructor();
|
|
17
18
|
static get observedAttributes(): string[];
|
|
18
|
-
|
|
19
|
+
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
20
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
19
21
|
connectedCallback(): void;
|
|
22
|
+
afterInit(): void;
|
|
20
23
|
disconnectedCallback(): void;
|
|
21
24
|
render(): string;
|
|
22
|
-
ruleChange: (
|
|
23
|
-
|
|
25
|
+
ruleChange: (e: CustomEvent) => void;
|
|
26
|
+
private _provide;
|
|
27
|
+
_formAction: (e: CustomEvent) => void;
|
|
28
|
+
_valueChange: (e: CustomEvent) => void;
|
|
24
29
|
validateField(field: string | string[]): void;
|
|
25
30
|
clearValidate(): void;
|
|
26
31
|
reset(): void;
|
|
@@ -32,4 +37,6 @@ export default class Form extends BaseComponent {
|
|
|
32
37
|
getData(): {
|
|
33
38
|
[x: string]: any;
|
|
34
39
|
};
|
|
40
|
+
setErrors(errorObj: Record<string, any>): void;
|
|
35
41
|
}
|
|
42
|
+
export {};
|
package/lib/form/index.js
CHANGED
|
@@ -1,123 +1,145 @@
|
|
|
1
|
-
import { $one as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class $ extends m {
|
|
1
|
+
import { $one as f, formatClass as d, on as r, off as o, formatStyle as m } from "ph-utils/dom";
|
|
2
|
+
import { parseAttrValue as c } from "../utils/index.js";
|
|
3
|
+
import u from "ph-utils/validator";
|
|
4
|
+
import { s as h } from "../index-CrMiSe0x.js";
|
|
5
|
+
import v from "../base.js";
|
|
6
|
+
const p = ":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}";
|
|
7
|
+
class k extends v {
|
|
9
8
|
static baseName = "form";
|
|
10
|
-
/** 是否行内表单 */
|
|
11
|
-
inline = !1;
|
|
12
|
-
labelPosition = "right";
|
|
13
|
-
labelWidth = "80px";
|
|
14
|
-
disabled = !1;
|
|
15
|
-
sharedAttrs = ["disabled", "id", "innerBlock"];
|
|
16
9
|
validator;
|
|
17
|
-
innerBlock = !1;
|
|
18
|
-
novalidate = !1;
|
|
19
10
|
_data;
|
|
11
|
+
context;
|
|
12
|
+
errors;
|
|
13
|
+
// 验证错误
|
|
14
|
+
resetCtx;
|
|
20
15
|
constructor() {
|
|
21
|
-
super(), this.
|
|
16
|
+
super(), this._state = {
|
|
17
|
+
/** 是否行内表单 */
|
|
18
|
+
inline: !1,
|
|
19
|
+
labelPosition: "right",
|
|
20
|
+
labelWidth: "80px",
|
|
21
|
+
novalidate: !1
|
|
22
|
+
}, this.validator = new u([]), this.context = h({ innerBlock: !1 }), this.errors = h({}), this.resetCtx = h(0);
|
|
22
23
|
}
|
|
23
24
|
static get observedAttributes() {
|
|
24
|
-
return ["
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
return ["label-position", "inner-block", "inline", "novalidate"];
|
|
26
|
+
}
|
|
27
|
+
attributeChanged(t, e, i) {
|
|
28
|
+
switch (t) {
|
|
29
|
+
case "label-position":
|
|
30
|
+
this._state.labelPosition = i;
|
|
31
|
+
break;
|
|
32
|
+
case "inner-block":
|
|
33
|
+
const s = c(i, !1, t);
|
|
34
|
+
this.context({ innerBlock: s });
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
const a = c(i, !1, t);
|
|
38
|
+
this._state[t] = a;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
updateDOM(t) {
|
|
43
|
+
if (t.has("label-position") || t.has("inline")) {
|
|
44
|
+
const e = f("form", this.root);
|
|
45
|
+
e && (e.className = d([
|
|
33
46
|
"l-form",
|
|
34
|
-
this.inline ? "l-form-inline" : void 0,
|
|
35
|
-
`l-form--${
|
|
47
|
+
this._state.inline ? "l-form-inline" : void 0,
|
|
48
|
+
`l-form--${this._state.labelPosition}`
|
|
36
49
|
]));
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
connectedCallback() {
|
|
40
|
-
|
|
53
|
+
r(this, "form-context-request", this._provide), this.loadStyleText([p]), super.connectedCallback();
|
|
54
|
+
}
|
|
55
|
+
afterInit() {
|
|
56
|
+
r(this, "form-rule-change", this.ruleChange), r(this, "form-value-change", this._valueChange), r(this, "form-action", this._formAction);
|
|
41
57
|
}
|
|
42
58
|
disconnectedCallback() {
|
|
43
|
-
|
|
59
|
+
this.validator = void 0, o(this, "form-rule-change", this.ruleChange), o(this, "form-value-change", this._valueChange), o(this, "form-context-request", this._provide), o(this, "form-action", this._formAction), super.disconnectedCallback();
|
|
44
60
|
}
|
|
45
61
|
render() {
|
|
46
|
-
const t =
|
|
62
|
+
const t = d([
|
|
47
63
|
"l-form",
|
|
48
|
-
this.inline ? "l-form-inline" : void 0,
|
|
49
|
-
`l-form--${this.labelPosition}`
|
|
50
|
-
]), e =
|
|
51
|
-
"--l-form-label-width": this.labelWidth ? this.labelWidth : ""
|
|
64
|
+
this._state.inline ? "l-form-inline" : void 0,
|
|
65
|
+
`l-form--${this._state.labelPosition}`
|
|
66
|
+
]), e = m({
|
|
67
|
+
"--l-form-label-width": this._state.labelWidth ? this._state.labelWidth : ""
|
|
52
68
|
});
|
|
53
69
|
return `<form class="${t}" style="${e}"><slot></slot></form>`;
|
|
54
70
|
}
|
|
55
71
|
ruleChange = (t) => {
|
|
56
|
-
this.validator.addSchema(t);
|
|
72
|
+
t.stopPropagation(), this.validator.addSchema(t.detail);
|
|
57
73
|
};
|
|
58
|
-
|
|
74
|
+
_provide(t) {
|
|
75
|
+
const { context: e, callback: i } = t.detail;
|
|
76
|
+
e === "form-context-request" && i(this.context, this.errors, this.resetCtx);
|
|
77
|
+
}
|
|
78
|
+
_formAction = (t) => {
|
|
79
|
+
t.detail === "submit" ? this.submit() : this.reset();
|
|
80
|
+
};
|
|
81
|
+
_valueChange = (t) => {
|
|
82
|
+
const { name: e, value: i, valid: s } = t.detail;
|
|
83
|
+
if (!e) return;
|
|
59
84
|
this._data == null && (this._data = {});
|
|
60
|
-
const a = Object.hasOwn(this._data,
|
|
61
|
-
this._data[
|
|
62
|
-
l
|
|
63
|
-
|
|
64
|
-
|
|
85
|
+
const a = Object.hasOwn(this._data, e);
|
|
86
|
+
this._data[e] = i, !this._state.novalidate && a && s && this.validator.validateKey(e, i, this._data).then(() => {
|
|
87
|
+
const l = this.errors();
|
|
88
|
+
l[e] = void 0, this.errors({ ...l });
|
|
89
|
+
}).catch((l) => {
|
|
90
|
+
this.errors({ ...this.errors(), ...l.detail });
|
|
65
91
|
});
|
|
66
92
|
};
|
|
67
93
|
validateField(t) {
|
|
68
94
|
const e = [];
|
|
69
95
|
if (this._data != null) {
|
|
70
96
|
if (Array.isArray(t))
|
|
71
|
-
for (let i = 0,
|
|
72
|
-
const
|
|
73
|
-
e.push(this.validator.validateKey(
|
|
97
|
+
for (let i = 0, s = t.length; i < s; i++) {
|
|
98
|
+
const a = t[i];
|
|
99
|
+
e.push(this.validator.validateKey(a, this._data[a], this._data));
|
|
74
100
|
}
|
|
75
101
|
else
|
|
76
|
-
e.push(
|
|
77
|
-
this.validator.validateKey(t, this._data[t], this._data)
|
|
78
|
-
);
|
|
102
|
+
e.push(this.validator.validateKey(t, this._data[t], this._data));
|
|
79
103
|
Promise.allSettled(e).then((i) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"validateChange",
|
|
85
|
-
r.reason.detail,
|
|
86
|
-
r.reason.key
|
|
87
|
-
) : l(this.id, "validateChange", !0, r.value.key);
|
|
104
|
+
let s = {};
|
|
105
|
+
for (let a = 0, l = i.length; a < l; a++) {
|
|
106
|
+
const n = i[a];
|
|
107
|
+
n.status === "rejected" ? s = { ...s, ...n.reason.detail } : s[n.value.key] = void 0;
|
|
88
108
|
}
|
|
109
|
+
this.errors({ ...this.errors(), ...s });
|
|
89
110
|
});
|
|
90
111
|
}
|
|
91
112
|
}
|
|
92
113
|
clearValidate() {
|
|
93
|
-
|
|
114
|
+
this.errors({});
|
|
94
115
|
}
|
|
95
116
|
reset() {
|
|
96
|
-
this.clearValidate()
|
|
117
|
+
this.clearValidate();
|
|
118
|
+
const t = this.resetCtx();
|
|
119
|
+
this.resetCtx(t >= 100 ? 1 : t + 1);
|
|
97
120
|
}
|
|
98
121
|
submit() {
|
|
99
|
-
this.novalidate ? this.dispatchEvent(new CustomEvent("submit", { detail: this.getData() })) : this.validate().then((t) => {
|
|
100
|
-
t && this.dispatchEvent(
|
|
101
|
-
new CustomEvent("submit", { detail: this.getData() })
|
|
102
|
-
);
|
|
122
|
+
console.log(this._state.novalidate), this._state.novalidate ? this.dispatchEvent(new CustomEvent("submit", { detail: this.getData() })) : this.validate().then((t) => {
|
|
123
|
+
t && this.dispatchEvent(new CustomEvent("submit", { detail: this.getData() }));
|
|
103
124
|
});
|
|
104
125
|
}
|
|
105
126
|
/**
|
|
106
127
|
* 校验全部表单数据
|
|
107
128
|
*/
|
|
108
129
|
async validate() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
return Promise.resolve(!0);
|
|
130
|
+
try {
|
|
131
|
+
return await this.validator.validate(this._data), this.errors({}), Promise.resolve(!0);
|
|
132
|
+
} catch (t) {
|
|
133
|
+
return this.errors(t.detail), Promise.resolve(!1);
|
|
134
|
+
}
|
|
116
135
|
}
|
|
117
136
|
getData() {
|
|
118
137
|
return { ...this._data };
|
|
119
138
|
}
|
|
139
|
+
setErrors(t) {
|
|
140
|
+
this.errors(t);
|
|
141
|
+
}
|
|
120
142
|
}
|
|
121
143
|
export {
|
|
122
|
-
|
|
144
|
+
k as default
|
|
123
145
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -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-control-height, 32px);align-items:center;padding:0 7px;border:1px solid var(--l-input-border-color, #dedede);transition:border-color .3s;border-radius:var(--l-border-radius, 3px);vertical-align:middle;box-sizing:border-box;background-color:transparent}:host(:focus){--l-input-border-color: var(--l-primary-color, #722ed1)}:host(.is-block){width:100%}: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;font-size:inherit}.l-input__inner:disabled{background-color:transparent}";
|
|
2
|
+
export {
|
|
3
|
+
r as i
|
|
4
|
+
};
|