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.
Files changed (44) hide show
  1. package/lib/base.d.ts +11 -2
  2. package/lib/base.js +59 -27
  3. package/lib/button/index.d.ts +18 -3
  4. package/lib/button/index.js +65 -68
  5. package/lib/check/check.d.ts +14 -5
  6. package/lib/check/check.js +67 -29
  7. package/lib/check/checkbox.js +5 -12
  8. package/lib/check/checkbox_group.d.ts +0 -5
  9. package/lib/check/checkbox_group.js +3 -29
  10. package/lib/check/index.d.ts +14 -4
  11. package/lib/check/index.js +48 -28
  12. package/lib/check/radio.js +6 -14
  13. package/lib/check/radio_group.d.ts +1 -2
  14. package/lib/check/radio_group.js +5 -19
  15. package/lib/check-CksURvTv.js +4 -0
  16. package/lib/color_picker/index.js +1 -1
  17. package/lib/form/form_inner.d.ts +17 -10
  18. package/lib/form/form_inner.js +83 -80
  19. package/lib/form/form_item.d.ts +23 -23
  20. package/lib/form/form_item.js +107 -90
  21. package/lib/form/index.d.ts +21 -14
  22. package/lib/form/index.js +92 -70
  23. package/lib/form/types.d.ts +7 -0
  24. package/lib/form/types.js +1 -0
  25. package/lib/index-Blf4-a2-.js +4 -0
  26. package/lib/index-CrMiSe0x.js +249 -0
  27. package/lib/index.js +162 -160
  28. package/lib/input/index.d.ts +24 -25
  29. package/lib/input/index.js +99 -89
  30. package/lib/loading/index.d.ts +2 -0
  31. package/lib/loading/index.js +50 -64
  32. package/lib/message/index.js +9 -9
  33. package/lib/modal/index.d.ts +1 -6
  34. package/lib/modal/index.js +40 -46
  35. package/lib/select_ori/index.js +1 -1
  36. package/lib/utils/context_provide.d.ts +9 -0
  37. package/lib/utils/context_provide.js +22 -0
  38. package/lib/utils/index.d.ts +2 -0
  39. package/lib/utils/index.js +41 -33
  40. package/package.json +8 -8
  41. package/styles/loading.css +5 -3
  42. package/lib/check-C7YSuH60.js +0 -4
  43. package/lib/index-DvcllHRh.js +0 -4
  44. package/lib/utils/event.d.ts +0 -30
@@ -1,119 +1,136 @@
1
- import { $$ as i, $one as o, addClass as n, removeClass as d } from "ph-utils/dom";
2
- import { initAttr as h, parseAttrValue as m } from "../utils/index.js";
3
- import f from "../base.js";
4
- import { emit as s, add as c, clear as p, 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-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}';
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
- disabled = !1;
10
- sharedAttrs = ["disabled", "id", "name", "innerBlock"];
11
- /** 是否必须 */
12
- required = !1;
13
- /** 标签文本 */
14
- label;
15
- /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
16
- verify;
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
- set error(e) {
33
- this.#e = e, this._updateError();
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
- attributeChangedCallback(e, t, r) {
36
- if (e === "error")
37
- r != this.#e && (this.error = r);
38
- else if (e === "label")
39
- this.label = r, this._updateLabel();
40
- else if (e === "disabled") {
41
- const l = m(r, !1, e);
42
- l !== this.disabled && (s(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
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
- if (h(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) {
47
- let e = this.verify?.split("|") || [];
48
- this.pattern && e.push(new RegExp(this.pattern));
49
- const t = {
50
- key: this.name,
51
- required: this.required,
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
- disconnectedCallback() {
59
- p(this.id), this.formId && b(this.formId, "validateChange", this._validateChange);
66
+ beforeDestroy() {
67
+ this._errorSignalStop = m(this._errorSignalStop);
60
68
  }
61
69
  setRules(e) {
62
- const t = { ...e, key: this.name };
63
- t.required != null && this.required && (t.required = !0), this.formId && s(this.formId, "ruleChange", t);
64
- }
65
- setError(e) {
66
- this.error = e;
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.required && this.classList.add("is-required"), this.error && this.classList.add("is-error"), this.classList.add(`l-form-item--${this.labelPosition}`);
77
+ this.classList.add(`l-form-item--${this._state.labelPosition}`);
70
78
  const e = document.createDocumentFragment();
71
- this.label != null && e.appendChild(
72
- i("label", {
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 = i("div", { class: "l-form-item__content" }), r = i("slot");
78
- return t.appendChild(r), this.error && t.appendChild(
79
- i("div", { class: "l-form-item__error", textContent: this.error })
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
- _validateChange = (e, t) => {
83
- const r = e === !0 ? void 0 : e[this.name];
84
- (t == null || t === this.name && this.error != r) && (this.error = r);
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 = o(".l-form-item__error", this.root);
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 = o(".l-form-item__content", this.root);
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 = o(".l-form-item__label", this.root);
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
- _getFormId() {
104
- let e = this.parentElement, t;
105
- for (; e != null; ) {
106
- const r = e.tagName;
107
- if (r === "L-FORM") {
108
- t = e.id;
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
- I as default
135
+ v as default
119
136
  };
@@ -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
- export default class Form extends BaseComponent {
5
- static baseName: string;
6
- /** 是否行内表单 */
2
+ import type { FormSignal } from "./types";
3
+ import BaseComponent from "../base";
4
+ interface FormState {
7
5
  inline: boolean;
8
- labelPosition?: "left" | "right" | "top";
9
- labelWidth?: string;
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
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
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: (schema: SchemaType) => void;
23
- _valueChange: (name: string, value: any, valid?: boolean) => void;
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 n, formatClass as o, formatStyle as f } from "ph-utils/dom";
2
- import m from "../base.js";
3
- import { initAttr as c, parseAttrValue as u } from "../utils/index.js";
4
- import { random as d } from "ph-utils";
5
- import { emit as l, add as h, clear as v } from "../utils/event.js";
6
- import p from "ph-utils/validator";
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
- 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.validator = new p([]);
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 ["disabled", "label-position"];
25
- }
26
- attributeChangedCallback(t, e, i) {
27
- if (t === "disabled") {
28
- const a = u(i, !1, t);
29
- a !== this.disabled && (l(this.id, "attributeChanged", t, a, this.id), this.disabled = a);
30
- } else if (t === "label-position") {
31
- const a = n("form", this.root);
32
- a && (a.className = o([
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--${i}`
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
- c(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(), h(this.id, "ruleChange", this.ruleChange), h(this.id, "valueChange", this._valueChange);
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
- v(this.id), this.validator = void 0;
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 = o([
62
+ const t = d([
47
63
  "l-form",
48
- this.inline ? "l-form-inline" : void 0,
49
- `l-form--${this.labelPosition}`
50
- ]), e = f({
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
- _valueChange = (t, e, i = !0) => {
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, t);
61
- this._data[t] = e, !this.novalidate && a && i && this.validator.validateKey(t, e, this._data).then(() => {
62
- l(this.id, "validateChange", !0, t);
63
- }).catch((s) => {
64
- l(this.id, "validateChange", s.detail, t);
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, a = t.length; i < a; i++) {
72
- const s = t[i];
73
- e.push(this.validator.validateKey(s, this._data[s], this._data));
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
- for (let a = 0, s = i.length; a < s; a++) {
81
- const r = i[a];
82
- r.status === "rejected" ? l(
83
- this.id,
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
- l(this.id, "validateChange", !0);
114
+ this.errors({});
94
115
  }
95
116
  reset() {
96
- this.clearValidate(), l(this.id, "reset");
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
- if (this._data != null)
110
- try {
111
- return await this.validator.validate(this._data), l(this.id, "validateChange", !0), Promise.resolve(!0);
112
- } catch (t) {
113
- return l(this.id, "validateChange", t.detail), Promise.resolve(!1);
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
- $ as default
144
+ k as default
123
145
  };
@@ -0,0 +1,7 @@
1
+ export type FormSignal = {
2
+ innerBlock: boolean;
3
+ };
4
+ export type FormItemSignal = {
5
+ innerBlock: boolean;
6
+ prop?: string;
7
+ };
@@ -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
+ };