litos-ui 0.16.2 → 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 -67
- package/lib/check/check.d.ts +13 -5
- package/lib/check/check.js +61 -33
- package/lib/check/checkbox.js +3 -3
- package/lib/check/checkbox_group.d.ts +0 -1
- package/lib/check/checkbox_group.js +3 -7
- package/lib/check/index.d.ts +12 -8
- package/lib/check/index.js +40 -47
- package/lib/check/radio.js +6 -6
- package/lib/check/radio_group.d.ts +0 -2
- package/lib/check/radio_group.js +3 -10
- 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 +82 -65
- package/lib/form/form_item.d.ts +23 -23
- package/lib/form/form_item.js +108 -89
- 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 +113 -99
- package/lib/modal/index.js +1 -1
- 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/lib/check-D-KVLA1z.js +0 -4
- package/lib/index-DvcllHRh.js +0 -4
- package/lib/utils/event.d.ts +0 -30
package/lib/check/index.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import FormInner from "../form/form_inner";
|
|
2
|
-
|
|
2
|
+
type CheckGroupState = {
|
|
3
|
+
gap?: string;
|
|
4
|
+
};
|
|
5
|
+
export default class CheckGroup extends FormInner<CheckGroupState> {
|
|
3
6
|
#private;
|
|
4
|
-
|
|
7
|
+
values: Signal<string[]>;
|
|
5
8
|
multiple: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
_state: CheckGroupState;
|
|
10
|
+
setValue(value: string): void;
|
|
8
11
|
constructor();
|
|
9
12
|
static get observedAttributes(): string[];
|
|
10
|
-
attributeChange(name: string,
|
|
13
|
+
attributeChange(name: string, _oldValue: any, newValue: any): void;
|
|
14
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
11
15
|
connectedCallback(): void;
|
|
12
16
|
afterInit(): void;
|
|
13
17
|
beforeDestroy(): void;
|
|
14
18
|
render(): HTMLElement;
|
|
15
|
-
|
|
19
|
+
_privide: (e: CustomEvent) => void;
|
|
20
|
+
_updateGap: () => void;
|
|
16
21
|
protected updateChecked(): void;
|
|
17
|
-
protected updateChangedStatus(): void;
|
|
18
|
-
protected updateChildren(): void;
|
|
19
22
|
}
|
|
23
|
+
export {};
|
package/lib/check/index.js
CHANGED
|
@@ -1,75 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { on as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
class
|
|
7
|
-
|
|
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
8
|
multiple;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get value() {
|
|
13
|
-
return this._value;
|
|
9
|
+
_state;
|
|
10
|
+
setValue(e) {
|
|
11
|
+
super.setValue(e), this.rendered && this.updateChecked();
|
|
14
12
|
}
|
|
15
13
|
constructor() {
|
|
16
|
-
super(!1), this.multiple = !0, this.
|
|
14
|
+
super(!1), this.multiple = !0, this.values = c([]), this._state = {};
|
|
17
15
|
}
|
|
18
16
|
static get observedAttributes() {
|
|
19
|
-
return ["
|
|
17
|
+
return ["disabled", "value", "name", "inner-block", "gap"];
|
|
20
18
|
}
|
|
21
|
-
attributeChange(e,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.style.setProperty("--l-check-gap", i);
|
|
27
|
-
} else
|
|
28
|
-
this.style.removeProperty("--l-check-gap");
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
19
|
+
attributeChange(e, s, t) {
|
|
20
|
+
e === "gap" && (this._state.gap = u(t));
|
|
21
|
+
}
|
|
22
|
+
updateDOM(e) {
|
|
23
|
+
e.has("gap") && this._updateGap();
|
|
31
24
|
}
|
|
32
25
|
connectedCallback() {
|
|
33
|
-
|
|
26
|
+
this.loadStyleText([o]), this.updateChecked(), super.connectedCallback(), this._updateGap();
|
|
34
27
|
}
|
|
35
28
|
afterInit() {
|
|
36
|
-
|
|
29
|
+
a(this.root, "change", this.#e), a(this, "check-context-request", this._privide);
|
|
37
30
|
}
|
|
38
31
|
beforeDestroy() {
|
|
39
|
-
|
|
32
|
+
l(this.root, "change", this.#e), l(this, "check-context-request", this._privide), this.values([]);
|
|
40
33
|
}
|
|
41
34
|
render() {
|
|
42
|
-
return
|
|
35
|
+
return r("slot");
|
|
43
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
|
+
};
|
|
44
44
|
#e = (e) => {
|
|
45
|
-
e.stopPropagation()
|
|
46
|
-
|
|
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 },
|
|
47
50
|
composed: !0
|
|
48
51
|
});
|
|
49
52
|
};
|
|
50
|
-
updatePartChild(e) {
|
|
51
|
-
}
|
|
52
53
|
updateChecked() {
|
|
54
|
+
let e = [];
|
|
53
55
|
if (this.value)
|
|
54
56
|
if (this.multiple) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
+
const s = this.value.split("&");
|
|
58
|
+
e.push(...s.map((t) => decodeURIComponent(t)));
|
|
57
59
|
} else
|
|
58
|
-
|
|
60
|
+
e = [this.value];
|
|
59
61
|
else
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
updateChangedStatus() {
|
|
63
|
-
this.updateChecked(), this.updateChildren();
|
|
64
|
-
}
|
|
65
|
-
updateChildren() {
|
|
66
|
-
const e = this.children;
|
|
67
|
-
d(e, (t) => {
|
|
68
|
-
let s = t.value || t.getAttribute("value");
|
|
69
|
-
s && (this.checkedValues.includes(s) ? t.setAttribute("checked", "") : t.removeAttribute("checked"));
|
|
70
|
-
});
|
|
62
|
+
e = [];
|
|
63
|
+
this.values(e);
|
|
71
64
|
}
|
|
72
65
|
}
|
|
73
66
|
export {
|
|
74
|
-
|
|
67
|
+
f as default
|
|
75
68
|
};
|
package/lib/check/radio.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import e from "./check.js";
|
|
2
|
-
import { c as r } from "../check-
|
|
3
|
-
const
|
|
4
|
-
class
|
|
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 {
|
|
5
5
|
static baseName = "radio";
|
|
6
6
|
connectedCallback() {
|
|
7
|
-
this.loadStyleText([r,
|
|
7
|
+
this.loadStyleText([r, o]), super.connectedCallback();
|
|
8
8
|
}
|
|
9
9
|
_doChangeAction() {
|
|
10
|
-
this.
|
|
10
|
+
this.setChecked(!0), this.emitChange();
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
t as default
|
|
15
15
|
};
|
package/lib/check/radio_group.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
class u extends t {
|
|
1
|
+
import e from "./index.js";
|
|
2
|
+
class s extends e {
|
|
4
3
|
static baseName = "radio-group";
|
|
5
4
|
constructor() {
|
|
6
5
|
super(), this.multiple = !1;
|
|
7
6
|
}
|
|
8
|
-
setValue(e) {
|
|
9
|
-
this.checkedValues = [e], super.setValue(e);
|
|
10
|
-
}
|
|
11
|
-
updatePartChild() {
|
|
12
|
-
s(`[value="${this.value}"]`, this)?.removeAttribute("checked");
|
|
13
|
-
}
|
|
14
7
|
}
|
|
15
8
|
export {
|
|
16
|
-
|
|
9
|
+
s as default
|
|
17
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-
|
|
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";
|
package/lib/form/form_inner.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
|
|
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
|
|
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
|
-
|
|
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():
|
|
29
|
-
getName():
|
|
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
|
}
|
package/lib/form/form_inner.js
CHANGED
|
@@ -1,108 +1,125 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { parseAttrValue as
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
formItemAttrs = {};
|
|
8
|
-
_value = "";
|
|
7
|
+
_value = void 0;
|
|
9
8
|
_resetValue;
|
|
9
|
+
// 重置值(即初始化值)
|
|
10
10
|
_firstPushValue = !0;
|
|
11
|
-
|
|
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(
|
|
19
|
-
super(!0, { delegatesFocus:
|
|
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(
|
|
25
|
-
this._name =
|
|
34
|
+
set name(e) {
|
|
35
|
+
this._name = e;
|
|
26
36
|
}
|
|
27
37
|
get value() {
|
|
28
38
|
return this._value;
|
|
29
39
|
}
|
|
30
|
-
set value(
|
|
31
|
-
this.setValue(
|
|
40
|
+
set value(e) {
|
|
41
|
+
this.setValue(e);
|
|
32
42
|
}
|
|
33
|
-
setValue(
|
|
34
|
-
this._value =
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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(
|
|
70
|
+
attributeChange(e, t, s) {
|
|
49
71
|
}
|
|
50
72
|
connectedCallback() {
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
});
|
|
53
86
|
}
|
|
54
87
|
disconnectedCallback() {
|
|
55
|
-
|
|
88
|
+
super.disconnectedCallback(), this._signalStop = i(this._signalStop), this._errorSignalStop = i(this._errorSignalStop), this._resetSignalStop = i(this._resetSignalStop);
|
|
56
89
|
}
|
|
57
90
|
isDisabled() {
|
|
58
|
-
return this.disabled
|
|
91
|
+
return this.disabled;
|
|
59
92
|
}
|
|
60
93
|
getName() {
|
|
61
|
-
return this.name
|
|
62
|
-
}
|
|
63
|
-
_getForm() {
|
|
64
|
-
let t = this.parentElement, e = {}, s = {};
|
|
65
|
-
for (; t != null; ) {
|
|
66
|
-
const i = t.tagName;
|
|
67
|
-
if (i === "L-FORM") {
|
|
68
|
-
const a = t.sharedAttrs;
|
|
69
|
-
for (let r = 0; r < a.length; r++) {
|
|
70
|
-
const h = a[r];
|
|
71
|
-
e[h] = t[h];
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
if (i === "BODY") break;
|
|
76
|
-
if (i === "L-FORM-ITEM") {
|
|
77
|
-
const a = t.sharedAttrs;
|
|
78
|
-
for (let r = 0; r < a.length; r++) {
|
|
79
|
-
const h = a[r];
|
|
80
|
-
s[h] = t[h];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
t = t.parentElement;
|
|
84
|
-
}
|
|
85
|
-
return t = null, {
|
|
86
|
-
formAttr: e,
|
|
87
|
-
formItemAttr: s
|
|
88
|
-
};
|
|
94
|
+
return this.name;
|
|
89
95
|
}
|
|
90
|
-
_formAttributeChanged = (t, e, s) => {
|
|
91
|
-
s === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this.disabledChange();
|
|
92
|
-
};
|
|
93
96
|
disabledChange() {
|
|
94
97
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
innerBlockChange(e) {
|
|
99
|
+
}
|
|
100
|
+
validResult(e) {
|
|
98
101
|
}
|
|
99
|
-
|
|
100
|
-
this.
|
|
102
|
+
formInject = (e, t, s) => {
|
|
103
|
+
this.formContext = e, this.formErrors = t, this.resetCtx = s;
|
|
101
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
|
+
}
|
|
102
119
|
reset() {
|
|
103
|
-
this.value = this._resetValue || "";
|
|
120
|
+
this._isReset = !0, this.value = this._resetValue || "", console.log("reset");
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
123
|
export {
|
|
107
|
-
|
|
124
|
+
_ as default
|
|
108
125
|
};
|
package/lib/form/form_item.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import BaseComponent from "../base";
|
|
2
1
|
import type { RuleType } from "ph-utils/validator";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
|
33
|
+
private _updateRequired;
|
|
34
|
+
private _parseSchema;
|
|
36
35
|
private _updateError;
|
|
37
36
|
private _updateLabel;
|
|
38
|
-
private
|
|
37
|
+
private _updateRules;
|
|
39
38
|
}
|
|
39
|
+
export {};
|