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,33 +1,7 @@
1
- import a from "./index.js";
2
- import { $ as u, iterate as i } from "ph-utils/dom";
3
- class d extends a {
1
+ import e from "./index.js";
2
+ class c extends e {
4
3
  static baseName = "checkbox-group";
5
- set value(t) {
6
- super.setValue(t), this.rendered && this.updateChangedStatus();
7
- }
8
- get value() {
9
- return this._value;
10
- }
11
- afterInit() {
12
- super.afterInit(), this.updateChangedStatus();
13
- }
14
- updateChangedStatus() {
15
- if (this.value) {
16
- const e = this.value.split("&");
17
- this.checkedValues.push(...e.map((s) => decodeURIComponent(s)));
18
- } else
19
- this.checkedValues = [];
20
- const t = u("l-checkbox[value]", this);
21
- i(t, (e) => {
22
- let s = e.value;
23
- s || (s = e.getAttribute("value")), s && (this.checkedValues.includes(s) ? e.setAttribute("checked", "") : e.removeAttribute("checked"));
24
- });
25
- }
26
- valueChange(t) {
27
- let e = this.checkedValues.indexOf(t);
28
- e >= 0 ? this.checkedValues.splice(e, 1) : this.checkedValues.push(t), this.setValue(this.checkedValues.join("&"));
29
- }
30
4
  }
31
5
  export {
32
- d as default
6
+ c as default
33
7
  };
@@ -1,13 +1,23 @@
1
1
  import FormInner from "../form/form_inner";
2
- export default class CheckGroup extends FormInner {
2
+ type CheckGroupState = {
3
+ gap?: string;
4
+ };
5
+ export default class CheckGroup extends FormInner<CheckGroupState> {
3
6
  #private;
4
- checkedValues: string[];
7
+ values: Signal<string[]>;
8
+ multiple: boolean;
9
+ _state: CheckGroupState;
10
+ setValue(value: string): void;
5
11
  constructor();
6
12
  static get observedAttributes(): string[];
7
- attributeChange(name: string, oldValue: any, newValue: any): void;
13
+ attributeChange(name: string, _oldValue: any, newValue: any): void;
14
+ protected updateDOM(changedProps: Set<string>): void;
8
15
  connectedCallback(): void;
9
16
  afterInit(): void;
10
17
  beforeDestroy(): void;
11
18
  render(): HTMLElement;
12
- valueChange(_value: string): void;
19
+ _privide: (e: CustomEvent) => void;
20
+ _updateGap: () => void;
21
+ protected updateChecked(): void;
13
22
  }
23
+ export {};
@@ -1,48 +1,68 @@
1
- import r from "../form/form_inner.js";
2
- import { on as o, off as l, $$ as c } from "ph-utils/dom";
3
- import { initAttr as i, parseAttrValue as h } from "../utils/index.js";
4
- import { isNumeric as n } from "ph-utils";
5
- const p = ":host{display:flex;align-items:center;gap:var(--l-check-gap, 0px)}";
6
- class v extends r {
7
- checkedValues;
1
+ import h from "../form/form_inner.js";
2
+ import { on as a, off as l, $$ as r } from "ph-utils/dom";
3
+ import { unitNumberStr as u } from "../utils/index.js";
4
+ import { s as c } from "../index-CrMiSe0x.js";
5
+ const o = ":host{display:flex;align-items:center;gap:var(--l-check-gap, 0px)}";
6
+ class f extends h {
7
+ values;
8
+ multiple;
9
+ _state;
10
+ setValue(e) {
11
+ super.setValue(e), this.rendered && this.updateChecked();
12
+ }
8
13
  constructor() {
9
- super(!1), this.checkedValues = [];
14
+ super(!1), this.multiple = !0, this.values = c([]), this._state = {};
10
15
  }
11
16
  static get observedAttributes() {
12
- return ["gap", "value"];
13
- }
14
- attributeChange(e, g, a) {
15
- if (console.log(e), e === "gap") {
16
- const t = h(a, void 0);
17
- if (t) {
18
- const s = n(t) ? `${t}px` : t;
19
- this.style.setProperty("--l-check-gap", s);
20
- } else
21
- this.style.removeProperty("--l-check-gap");
22
- return;
23
- }
17
+ return ["disabled", "value", "name", "inner-block", "gap"];
18
+ }
19
+ attributeChange(e, s, t) {
20
+ e === "gap" && (this._state.gap = u(t));
21
+ }
22
+ updateDOM(e) {
23
+ e.has("gap") && this._updateGap();
24
24
  }
25
25
  connectedCallback() {
26
- i(this), this.loadStyleText([p]), super.connectedCallback();
26
+ this.loadStyleText([o]), this.updateChecked(), super.connectedCallback(), this._updateGap();
27
27
  }
28
28
  afterInit() {
29
- o(this.root, "change", this.#e);
29
+ a(this.root, "change", this.#e), a(this, "check-context-request", this._privide);
30
30
  }
31
31
  beforeDestroy() {
32
- l(this.root, "change", this.#e), this.checkedValues = [];
32
+ l(this.root, "change", this.#e), l(this, "check-context-request", this._privide), this.values([]);
33
33
  }
34
34
  render() {
35
- return c("slot");
35
+ return r("slot");
36
36
  }
37
+ _privide = (e) => {
38
+ const { context: s, callback: t } = e.detail;
39
+ s === "check-context-request" && t(this.values);
40
+ };
41
+ _updateGap = () => {
42
+ this._state.gap ? this.style.setProperty("--l-check-gap", this._state.gap) : this.style.removeProperty("--l-check-gap");
43
+ };
37
44
  #e = (e) => {
38
- this.valueChange(e.detail.value), e.stopPropagation(), this.emit("change", {
39
- detail: { value: [...this.checkedValues] },
45
+ e.stopPropagation();
46
+ const s = e.detail.value, t = this.values();
47
+ let i = t.indexOf(s);
48
+ this.multiple ? (i !== -1 ? t.splice(i, 1) : t.push(s), this.setAttribute("value", t.join("&"))) : i === -1 && this.setAttribute("value", s), this.emit("change", {
49
+ detail: { value: this.multiple ? t : s },
40
50
  composed: !0
41
51
  });
42
52
  };
43
- valueChange(e) {
53
+ updateChecked() {
54
+ let e = [];
55
+ if (this.value)
56
+ if (this.multiple) {
57
+ const s = this.value.split("&");
58
+ e.push(...s.map((t) => decodeURIComponent(t)));
59
+ } else
60
+ e = [this.value];
61
+ else
62
+ e = [];
63
+ this.values(e);
44
64
  }
45
65
  }
46
66
  export {
47
- v as default
67
+ f as default
48
68
  };
@@ -1,23 +1,15 @@
1
1
  import e from "./check.js";
2
- import { c as o } from "../check-C7YSuH60.js";
3
- import { $one as c } from "ph-utils/dom";
4
- const t = '.l-check__inner{border-radius:50%}.l-check__inner:after{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color, #722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color, #e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color, #e6e6e6)}';
5
- class n extends e {
2
+ import { c as r } from "../check-CksURvTv.js";
3
+ const o = '.l-check__inner{border-radius:50%}.l-check__inner:after{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color, #722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color, #e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color, #e6e6e6)}';
4
+ class t extends e {
6
5
  static baseName = "radio";
7
6
  connectedCallback() {
8
- this.loadStyleText([o, t]), super.connectedCallback();
7
+ this.loadStyleText([r, o]), super.connectedCallback();
9
8
  }
10
9
  _doChangeAction() {
11
- c("input", this.root).checked || (this.setAttribute("checked", ""), this.emit("change", {
12
- detail: {
13
- value: this.value,
14
- name: this.getName(),
15
- checked: this.getChecked()
16
- },
17
- composed: !0
18
- }));
10
+ this.setChecked(!0), this.emitChange();
19
11
  }
20
12
  }
21
13
  export {
22
- n as default
14
+ t as default
23
15
  };
@@ -1,6 +1,5 @@
1
1
  import CheckGroup from ".";
2
2
  export default class RadioGroup extends CheckGroup {
3
3
  static baseName: string;
4
- afterInit(): void;
5
- valueChange(value: string): void;
4
+ constructor();
6
5
  }
@@ -1,24 +1,10 @@
1
- import a from "./index.js";
2
- import { $one as i } from "ph-utils/dom";
3
- class u extends a {
1
+ import e from "./index.js";
2
+ class s extends e {
4
3
  static baseName = "radio-group";
5
- afterInit() {
6
- if (super.afterInit(), this.value) {
7
- const e = i(`l-radio[value="${this.value}"]`, this);
8
- e && e.setAttribute("checked", "");
9
- }
10
- }
11
- valueChange(e) {
12
- if (this.value) {
13
- const t = i(
14
- `l-radio[value="${this.value}"]`,
15
- this
16
- );
17
- t && t.removeAttribute("checked");
18
- }
19
- this.value = e;
4
+ constructor() {
5
+ super(), this.multiple = !1;
20
6
  }
21
7
  }
22
8
  export {
23
- u as default
9
+ s as default
24
10
  };
@@ -0,0 +1,4 @@
1
+ const r = ":host{--l-check-size: 14px;display:inline-flex;align-items:center;position:relative;cursor:pointer;width:auto;outline:none;transition:color .3s,border-color .3s,background-color .3s}.l-check__input{margin:0;position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-check__inner{width:var(--l-check-size, 14px);height:var(--l-check-size, 14px);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:border-color .3s ease-in-out;position:relative;margin-right:5px;flex-shrink:0}.l-check__label{transition:color .3s;cursor:inherit;line-height:1}:host(.is-checked){color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner{border-color:var(--l-primary-color, #722ed1)}:host(.is-disabled){cursor:not-allowed}:host(.is-disabled) .l-check__label{color:var(--l-disabled-color, #e6e6e6)}:host([button]){height:var(--l-form-control-height, 32px);justify-content:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0;border-radius:inherit}:host([button]:first-child){border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}:host([button]:last-child){border-top-right-radius:3px;border-bottom-right-radius:3px}:host([button].is-checked){background-color:var(--l-primary-color, #722ed1);color:#fff;border-color:var(--l-primary-color, #722ed1);border-right-color:#fff}:host([button].is-checked:last-child){border-right-color:var(--l-primary-color, #722ed1)}";
2
+ export {
3
+ r as c
4
+ };
@@ -1,7 +1,7 @@
1
1
  import { $one as i, on as s, off as a } from "ph-utils/dom";
2
2
  import r from "../form/form_inner.js";
3
3
  import { initAttr as c, setAttrs as n } from "../utils/index.js";
4
- import { i as l } from "../index-DvcllHRh.js";
4
+ import { i as l } from "../index-Blf4-a2-.js";
5
5
  const o = ":host{--l-input-width: 60px}";
6
6
  class m extends r {
7
7
  static baseName = "color-picker";
@@ -1,13 +1,19 @@
1
1
  import BaseComponent from "../base";
2
- export default class FormInner extends BaseComponent {
2
+ import type { FormItemSignal, FormSignal } from "./types";
3
+ export default class FormInner<T = Record<string, any>> extends BaseComponent<T> {
3
4
  disabled: boolean;
4
- protected formAttrs: Record<string, any>;
5
- protected formItemAttrs: Record<string, any>;
6
5
  _value: any;
7
6
  _resetValue?: any;
8
7
  protected _firstPushValue: boolean;
9
- private _reseting;
8
+ private _isReset;
10
9
  private _name?;
10
+ formContext?: Signal<FormSignal>;
11
+ formItemContext?: Signal<FormItemSignal>;
12
+ formErrors?: Signal<Record<string, string>>;
13
+ resetCtx?: Signal<number>;
14
+ private _signalStop?;
15
+ private _errorSignalStop?;
16
+ private _resetSignalStop?;
11
17
  /**
12
18
  *
13
19
  * @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
@@ -21,16 +27,17 @@ export default class FormInner extends BaseComponent {
21
27
  setValue(value: any): void;
22
28
  getValue(): any;
23
29
  static get observedAttributes(): string[];
24
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
30
+ protected attributeChanged(name: string, oldValue: string, newValue: string): void;
25
31
  protected attributeChange(_name: string, _oldValue: string, _newValue: string): void;
26
32
  connectedCallback(): void;
27
33
  disconnectedCallback(): void;
28
- isDisabled(): any;
29
- getName(): any;
30
- private _getForm;
31
- private _formAttributeChanged;
34
+ isDisabled(): boolean;
35
+ getName(): string | undefined;
32
36
  protected disabledChange(): void;
37
+ protected innerBlockChange(_innerBlock: boolean): void;
38
+ protected validResult(_msg?: string): void;
39
+ formInject: (context: Signal<FormSignal>, errors: Signal<Record<string, string>>, reset: Signal<number>) => void;
40
+ formItemInject: (context: Signal<FormItemSignal>) => void;
33
41
  protected pushValueChange(): void;
34
- private _resetFieldValue;
35
42
  reset(): void;
36
43
  }
@@ -1,122 +1,125 @@
1
- import n from "../base.js";
2
- import { parseAttrValue as m } from "../utils/index.js";
3
- import { add as l, remove as u, emit as d } from "../utils/event.js";
4
- class b extends n {
1
+ import o from "../base.js";
2
+ import { parseAttrValue as a, stopSignal as i } from "../utils/index.js";
3
+ import { getAttr as l } from "ph-utils/dom";
4
+ import { e as n } from "../index-CrMiSe0x.js";
5
+ class _ extends o {
5
6
  disabled = !1;
6
- formAttrs = {};
7
- formItemAttrs = {};
8
- _value = "";
7
+ _value = void 0;
9
8
  _resetValue;
9
+ // 重置值(即初始化值)
10
10
  _firstPushValue = !0;
11
- _reseting = !1;
11
+ // 初始化时是否推送数据到 Form
12
+ _isReset = !1;
13
+ // 是否是重置, 重置时不触发数据校验
12
14
  _name;
15
+ formContext;
16
+ formItemContext;
17
+ formErrors;
18
+ // 表单验证错误
19
+ resetCtx;
20
+ _signalStop;
21
+ _errorSignalStop;
22
+ _resetSignalStop;
13
23
  /**
14
24
  *
15
25
  * @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
16
26
  * @param delegatesFocus 是否委托焦点, 默认: true
17
27
  */
18
- constructor(t = !0, e = !0) {
19
- super(!0, { delegatesFocus: e }), this._firstPushValue = t;
28
+ constructor(e = !0, t = !0) {
29
+ super(!0, { delegatesFocus: t }), this._firstPushValue = e;
20
30
  }
21
31
  get name() {
22
32
  return this._name;
23
33
  }
24
- set name(t) {
25
- this._name = t;
34
+ set name(e) {
35
+ this._name = e;
26
36
  }
27
37
  get value() {
28
38
  return this._value;
29
39
  }
30
- set value(t) {
31
- this.setValue(t);
40
+ set value(e) {
41
+ this.setValue(e);
32
42
  }
33
- setValue(t) {
34
- this._value = t, this.pushValueChange();
43
+ setValue(e) {
44
+ this._value = e, this._resetValue == null && (this._resetValue = e), this.pushValueChange();
35
45
  }
36
46
  getValue() {
37
47
  return this._value;
38
48
  }
39
49
  static get observedAttributes() {
40
- return ["disabled", "value", "name"];
50
+ return ["disabled", "value", "name", "inner-block"];
41
51
  }
42
- attributeChangedCallback(t, e, s) {
43
- if (t === "disabled") {
44
- const i = m(s, !1, t);
45
- i !== this.disabled && (this.disabled = i, this.disabledChange());
46
- } else t === "value" || t === "name" ? this.value = s : this.attributeChange(t, e, s);
52
+ attributeChanged(e, t, s) {
53
+ switch (e) {
54
+ case "value":
55
+ case "name":
56
+ this[e] = s;
57
+ break;
58
+ case "disabled":
59
+ this.disabled = a(s, !1, e);
60
+ break;
61
+ case "inner-block":
62
+ const r = a(s, !1, e);
63
+ this.innerBlockChange(r);
64
+ break;
65
+ default:
66
+ this.attributeChange(e, t, s);
67
+ break;
68
+ }
47
69
  }
48
- attributeChange(t, e, s) {
70
+ attributeChange(e, t, s) {
49
71
  }
50
72
  connectedCallback() {
51
- const t = this._getForm();
52
- this.formAttrs = t.formAttr, this.formItemAttrs = t.formItemAttr, this.formAttrs.id && (l(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), l(this.formAttrs.id, "reset", this._resetFieldValue), this._firstPushValue && this.pushValueChange()), this.formItemAttrs.id && l(
53
- this.formItemAttrs.id,
54
- "attributeChanged",
55
- this._formAttributeChanged
56
- ), super.connectedCallback();
73
+ this.emitInject("form-context-request", this.formInject), this.emitInject("form-item-context-request", this.formItemInject), super.connectedCallback(), this._signalStop = n(() => {
74
+ const e = this.formItemContext ? this.formItemContext() : null, t = this.formContext ? this.formContext() : null;
75
+ if (!this.name && e && e.prop && this.setAttribute("name", e.prop), !l(this, "inner-block")) {
76
+ const r = e?.innerBlock || t?.innerBlock;
77
+ r != null && this.innerBlockChange(r);
78
+ }
79
+ }), this._value == null && (this._resetValue = "", this._firstPushValue && this.pushValueChange()), this._errorSignalStop = n(() => {
80
+ if (!this.name) return;
81
+ const t = (this.formErrors ? this.formErrors() : {})[this.name];
82
+ this.validResult(t);
83
+ }), this._resetSignalStop = n(() => {
84
+ (this.resetCtx ? this.resetCtx() : 0) > 0 && this.reset();
85
+ });
57
86
  }
58
87
  disconnectedCallback() {
59
- this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(
60
- this.formItemAttrs.id,
61
- "attributeChanged",
62
- this._formAttributeChanged
63
- ), super.disconnectedCallback();
88
+ super.disconnectedCallback(), this._signalStop = i(this._signalStop), this._errorSignalStop = i(this._errorSignalStop), this._resetSignalStop = i(this._resetSignalStop);
64
89
  }
65
90
  isDisabled() {
66
- return this.disabled === !0 || this.formItemAttrs.disabled === !0 ? !0 : this.formAttrs.disabled || !1;
91
+ return this.disabled;
67
92
  }
68
93
  getName() {
69
- return this.name ? this.name : this.formItemAttrs.name;
70
- }
71
- _getForm() {
72
- let t = this.parentElement, e = {}, s = {};
73
- for (; t != null; ) {
74
- const i = t.tagName;
75
- if (i === "L-FORM") {
76
- const a = t.sharedAttrs;
77
- for (let r = 0; r < a.length; r++) {
78
- const h = a[r];
79
- e[h] = t[h];
80
- }
81
- break;
82
- }
83
- if (i === "BODY") break;
84
- if (i === "L-FORM-ITEM") {
85
- const a = t.sharedAttrs;
86
- for (let r = 0; r < a.length; r++) {
87
- const h = a[r];
88
- s[h] = t[h];
89
- }
90
- }
91
- t = t.parentElement;
92
- }
93
- return t = null, {
94
- formAttr: e,
95
- formItemAttr: s
96
- };
94
+ return this.name;
97
95
  }
98
- _formAttributeChanged = (t, e, s) => {
99
- s === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this.disabledChange();
100
- };
101
96
  disabledChange() {
102
97
  }
103
- pushValueChange() {
104
- const t = this.getName();
105
- this.formAttrs.id && t && d(
106
- this.formAttrs.id,
107
- "valueChange",
108
- t,
109
- this._value,
110
- !this._reseting
111
- ), this._reseting = !1;
112
- }
113
- _resetFieldValue = () => {
114
- this._reseting = !0, this.reset();
98
+ innerBlockChange(e) {
99
+ }
100
+ validResult(e) {
101
+ }
102
+ formInject = (e, t, s) => {
103
+ this.formContext = e, this.formErrors = t, this.resetCtx = s;
115
104
  };
105
+ formItemInject = (e) => {
106
+ this.formItemContext = e;
107
+ };
108
+ pushValueChange() {
109
+ this.name && this.emit("form-value-change", {
110
+ bubbles: !0,
111
+ composed: !0,
112
+ detail: {
113
+ name: this.name,
114
+ value: this._value,
115
+ valid: !this._isReset
116
+ }
117
+ }), this._isReset = !1;
118
+ }
116
119
  reset() {
117
- this.value = this._resetValue || "";
120
+ this._isReset = !0, this.value = this._resetValue || "", console.log("reset");
118
121
  }
119
122
  }
120
123
  export {
121
- b as default
124
+ _ as default
122
125
  };
@@ -1,39 +1,39 @@
1
- import BaseComponent from "../base";
2
1
  import type { RuleType } from "ph-utils/validator";
3
- export default class FormItem extends BaseComponent {
4
- #private;
5
- static baseName: string;
6
- disabled: boolean;
7
- sharedAttrs: string[];
8
- /** 是否必须 */
9
- required: boolean;
2
+ import ContextProvide from "../utils/context_provide";
3
+ import type { FormItemSignal } from "./types";
4
+ type FormItemState = {
10
5
  /** 标签文本 */
11
6
  label?: string;
12
- /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
7
+ labelPosition?: "left" | "right" | "top";
8
+ error?: string;
9
+ required: boolean;
10
+ /** 内置验证规则 */
13
11
  verify?: string;
14
- /** 验证失败错误信息 */
15
- validity?: string;
16
- /** 自定义验证的正则 */
12
+ /** 正则表达式 */
17
13
  pattern?: string;
18
- name?: string;
19
- innerBlock: boolean;
20
- labelPosition?: "left" | "right" | "top";
21
- private formId?;
14
+ /** 验证消息 */
15
+ validity?: string;
16
+ };
17
+ export default class FormItem extends ContextProvide<FormItemSignal, FormItemState> {
18
+ static baseName: string;
19
+ formErrors?: Signal<Record<string, string>>;
20
+ private _errorSignalStop?;
21
+ constructor();
22
22
  static get observedAttributes(): string[];
23
- get error(): string | undefined;
24
- set error(error: string | undefined);
25
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
23
+ protected attributeChanged(name: string, oldValue: string, newValue: string): void;
24
+ protected updateDOM(changedProps: Set<string>): void;
26
25
  connectedCallback(): void;
27
- disconnectedCallback(): void;
26
+ beforeDestroy(): void;
28
27
  setRules(rules: {
29
28
  required?: boolean;
30
29
  rules?: RuleType[];
31
30
  message?: string;
32
31
  }): void;
33
- setError(error: string): void;
34
32
  render(): DocumentFragment;
35
- private _validateChange;
33
+ private _updateRequired;
34
+ private _parseSchema;
36
35
  private _updateError;
37
36
  private _updateLabel;
38
- private _getFormId;
37
+ private _updateRules;
39
38
  }
39
+ export {};