litos-ui 0.18.2 → 0.18.3
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/button/index.d.ts +2 -1
- package/lib/button/index.js +1 -1
- package/lib/{button-CBoYJ9Tt.js → button-DEm6CutF.js} +22 -22
- package/lib/form/form_item.d.ts +6 -0
- package/lib/form/form_item.js +1 -1
- package/lib/form/index.d.ts +5 -0
- package/lib/form/index.js +1 -1
- package/lib/{form-DdU0yK0k.js → form-CNWykMNM.js} +32 -24
- package/lib/form_item-Clu9QKRa.js +149 -0
- package/lib/index.js +3 -3
- package/lib/input/index.js +8 -2
- package/lib/modal/modal_box.js +2 -2
- package/package.json +1 -1
- package/lib/form_item-Bv-YafZK.js +0 -137
package/lib/button/index.d.ts
CHANGED
|
@@ -32,11 +32,12 @@ export default class Button extends BaseComponent<ButtonState> {
|
|
|
32
32
|
template?: string | HTMLElement | DocumentFragment;
|
|
33
33
|
style?: string | string[];
|
|
34
34
|
};
|
|
35
|
+
afterInit(): void;
|
|
35
36
|
render(): HTMLButtonElement;
|
|
36
37
|
loadingBody(): string;
|
|
37
38
|
applyColor(color: string, text?: boolean, ghost?: boolean): string;
|
|
38
39
|
private _updateHeight;
|
|
39
|
-
private
|
|
40
|
+
private _resetBtnClass;
|
|
40
41
|
private _handleClick;
|
|
41
42
|
}
|
|
42
43
|
export {};
|
package/lib/button/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../button-
|
|
1
|
+
import { t as e } from "../button-DEm6CutF.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "./base.js";
|
|
2
2
|
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "./utils/index.js";
|
|
3
3
|
import { t as i } from "./animation-CTt9qgA7.js";
|
|
4
|
-
import {
|
|
4
|
+
import { $one as a, addClass as o, formatClass as s, formatStyle as c, off as l, on as u, removeClass as d } from "ph-utils/dom";
|
|
5
5
|
import { adjust as f } from "ph-utils/color";
|
|
6
6
|
//#region src/components/button/index.less?inline
|
|
7
7
|
var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text-color:var(--l-btn-text-color);--l-btn-active-text-color:var(--l-btn-text-color);--l-btn-border-color:var(--l-primary-color,#722ed1);--l-btn-background:var(--l-btn-border-color);--l-btn-hover-border-color:var(--l-primary-color-light1,#9254de);--l-btn-hover-background:var(--l-btn-hover-border-color);--l-btn-active-border-color:var(--l-primary-color-dark1,#531dab);--l-btn-active-background:var(--l-btn-active-border-color);--l-btn-disabled-color:#c9c9c9;--l-btn-disabled-background:#fbfbfb;--l-btn-disabled-border-color:#e6e6e6;--l-btn-height:var(--l-form-control-height,32px);width:auto;height:var(--l-btn-height);text-indent:0;box-sizing:border-box;border-radius:var(--l-border-radius,3px);display:inline-flex}:host([block]){width:100%}:host(.l-btn-small){--l-btn-height:24px;--l-btn-padding:0 7px}:host(.l-btn-large){--l-border-radius:6px;--l-btn-height:40px;--l-btn-padding:0 15px;font-size:16px}.l-btn{cursor:pointer;box-sizing:border-box;vertical-align:middle;width:100%;padding:var(--l-btn-padding);border-radius:inherit;height:100%;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);justify-content:center;align-items:center;gap:var(--l-btn-gap,5px);line-height:1;font-size:inherit;outline:none;transition:border-color .3s,background-color .3s,color .3s;display:inline-flex;position:relative}.l-btn:hover{border-color:var(--l-btn-hover-border-color,var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn-box-shadow:hover{box-shadow:0 4px 12px var(--l-primary-color-light4)}.l-btn:active{border-color:var(--l-btn-active-border-color,var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal,.l-btn-normal-v2{--l-btn-text-color:auto;--l-btn-background:transparent;--l-btn-border-color:#d9d9d9;--l-btn-hover-text-color:var(--l-primary-color-light1,#9254de);--l-btn-active-text-color:var(--l-primary-color-dark1,#531dab);--l-btn-hover-background:transparent;--l-btn-active-background:transparent;--l-btn-hover-border-color:var(--l-btn-hover-text-color);--l-btn-active-border-color:var(--l-btn-active-text-color)}.l-btn-normal-v2{--l-btn-hover-background:var(--l-primary-color-light5);--l-btn-active-background:var(--l-primary-color-light4)}.l-btn-primary{--l-btn-background:var(--l-primary-color,#722ed1);--l-btn-hover-background:var(--l-primary-color-light1,#9254de);--l-btn-active-background:var(--l-primary-color-dark1,#531dab);--l-btn-disabled-border-color:var(--l-primary-color-light2,#b37feb);--l-btn-disabled-background:var(--l-primary-color-light2,#b37feb);--l-btn-disabled-color:#fff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background:transparent;--l-btn-border-color:transparent;--l-btn-hover-border-color:transparent;--l-btn-active-border-color:transparent;--l-btn-disabled-background:transparent;--l-btn-disabled-border-color:transparent;--l-btn-hover-background:transparent;--l-btn-active-background:transparent;--l-btn-padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color:var(--l-primary-color,#722ed1);--l-btn-hover-text-color:var(--l-primary-color-light1,#9254de);--l-btn-active-text-color:var(--l-primary-color-dark1,#531dab)}.l-btn-ghost{--l-btn-text-color:var(--l-btn-border-color);--l-btn-background:transparent;--l-btn-hover-background:transparent;--l-btn-active-background:transparent;--l-btn-hover-text-color:var(--l-btn-hover-border-color);--l-btn-active-text-color:var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-control-height,32px) / 2)}.l-btn-circle{width:var(--l-form-control-height,32px);border-radius:50%;padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background:#ffffff14;--l-btn-disabled-color:#ffffff4d;--l-btn-disabled-border-color:#ffffff4d}", m = class extends e {
|
|
@@ -28,7 +28,7 @@ var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text
|
|
|
28
28
|
this.setDisabled(e);
|
|
29
29
|
}
|
|
30
30
|
setLoading(e) {
|
|
31
|
-
this.$btn && (e ? (
|
|
31
|
+
this.$btn && (e ? (o(this.$btn, "l-btn-loading"), this.$btn.disabled = !0, this.$btn.innerHTML = this.loadingBody()) : (d(this.$btn, "l-btn-loading"), this.$btn.disabled = this.disabled, this.$btn.innerHTML = "<slot></slot>"));
|
|
32
32
|
}
|
|
33
33
|
setDisabled(e) {
|
|
34
34
|
this._state.disabled = e, this.$btn && (this.$btn.disabled = e);
|
|
@@ -72,18 +72,18 @@ var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text
|
|
|
72
72
|
break;
|
|
73
73
|
case "box-shadow":
|
|
74
74
|
let i = n(a, !1, "box-shadow");
|
|
75
|
-
|
|
75
|
+
this._state.boxShadow = `box-shadow${i ? "" : "-none"}`;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
updateDOM(e) {
|
|
80
|
-
this.$btn && (e.has("loading") && this.setLoading(this._state.loading), e.has("disabled") && this.setDisabled(this.disabled), e.has("color") && this._state.color && (this.$btn.style.cssText = this.applyColor(this._state.color, this._state.text, this._state.ghost)), e.has("type")
|
|
80
|
+
this.$btn && (e.has("loading") && this.setLoading(this._state.loading), e.has("disabled") && this.setDisabled(this.disabled), e.has("color") && this._state.color && (this.$btn.style.cssText = this.applyColor(this._state.color, this._state.text, this._state.ghost)), (e.has("type") || e.has("shape") || e.has("box-shadow")) && (this.$btn.className = this._resetBtnClass())), e.has("height") && this._updateHeight();
|
|
81
81
|
}
|
|
82
82
|
connectedCallback() {
|
|
83
|
-
this.className = `l-btn-${this._state.size || "default"} ${this.className}`, super.connectedCallback(), this.isFormButton() &&
|
|
83
|
+
this.className = `l-btn-${this._state.size || "default"} ${this.className}`, super.connectedCallback(), this.isFormButton() && u(this, "click", this._handleClick), this._updateHeight();
|
|
84
84
|
}
|
|
85
85
|
disconnectedCallback() {
|
|
86
|
-
super.disconnectedCallback(), this.isFormButton() &&
|
|
86
|
+
super.disconnectedCallback(), this.isFormButton() && l(this, "click", this._handleClick), this.$btn = void 0;
|
|
87
87
|
}
|
|
88
88
|
isFormButton() {
|
|
89
89
|
let e = this.getHtmlType();
|
|
@@ -98,19 +98,14 @@ var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text
|
|
|
98
98
|
template: this.render()
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
+
afterInit() {
|
|
102
|
+
this.$btn ||= a(".l-btn", this.root);
|
|
103
|
+
}
|
|
101
104
|
render() {
|
|
102
105
|
let e = document.createElement("button"), t = this._state.loading, n = this._state.text, r = this._state.ghost;
|
|
103
|
-
e.className =
|
|
104
|
-
"l-btn",
|
|
105
|
-
`l-btn-${this._state.type}`,
|
|
106
|
-
`l-btn-${this._state.shape}`,
|
|
107
|
-
`l-btn-${this._state.boxShadow}`,
|
|
108
|
-
r ? "l-btn-ghost" : "",
|
|
109
|
-
n ? "l-btn-text" : "",
|
|
110
|
-
t ? "l-btn-loading" : ""
|
|
111
|
-
]), (this.disabled || t) && (e.disabled = !0), e.type = this._state.htmlType;
|
|
106
|
+
e.className = this._resetBtnClass(), (this.disabled || t) && (e.disabled = !0), e.type = this._state.htmlType;
|
|
112
107
|
let i = this.applyColor(this._state.color || "", n, r);
|
|
113
|
-
return i && (e.style.cssText = i), t ? e.innerHTML = this.loadingBody() : e.innerHTML = "<slot></slot>", e.setAttribute("part", "default"),
|
|
108
|
+
return i && (e.style.cssText = i), t ? e.innerHTML = this.loadingBody() : e.innerHTML = "<slot></slot>", e.setAttribute("part", "default"), e;
|
|
114
109
|
}
|
|
115
110
|
loadingBody() {
|
|
116
111
|
let e = this._state.loadingText, t = ["<l-loading-icon class=\"l-rotate-anim\"></l-loading-icon>"];
|
|
@@ -119,7 +114,7 @@ var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text
|
|
|
119
114
|
applyColor(e, t = !1, n = !1) {
|
|
120
115
|
if (!e) return "";
|
|
121
116
|
let r = f(e, 1, !0), i = f(e, 3, !1);
|
|
122
|
-
return
|
|
117
|
+
return c({
|
|
123
118
|
"--l-btn-border-color": t ? "transparent" : e,
|
|
124
119
|
"--l-btn-text-color": n || t ? e : "#ffffff",
|
|
125
120
|
"--l-btn-hover-text-color": n || t ? r : "#ffffff",
|
|
@@ -134,11 +129,16 @@ var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text
|
|
|
134
129
|
_updateHeight() {
|
|
135
130
|
this._state.height ? this.style.setProperty("--l-btn-height", this._state.height) : this.style.removeProperty("--l-btn-height");
|
|
136
131
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
_resetBtnClass() {
|
|
133
|
+
return s([
|
|
134
|
+
"l-btn",
|
|
135
|
+
`l-btn-${this._state.type}`,
|
|
136
|
+
`l-btn-${this._state.shape}`,
|
|
137
|
+
`l-btn-${this._state.boxShadow}`,
|
|
138
|
+
this._state.ghost ? "l-btn-ghost" : "",
|
|
139
|
+
this._state.text ? "l-btn-text" : "",
|
|
140
|
+
this._state.loading ? "l-btn-loading" : ""
|
|
141
|
+
]);
|
|
142
142
|
}
|
|
143
143
|
_handleClick = () => {
|
|
144
144
|
(this._state.htmlType === "reset" || this._state.htmlType === "submit") && this.emit("form-action", {
|
package/lib/form/form_item.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ type FormItemState = {
|
|
|
14
14
|
/** 验证消息 */
|
|
15
15
|
validity?: string;
|
|
16
16
|
prop?: string;
|
|
17
|
+
labelWidth?: string;
|
|
18
|
+
labelHeight?: string;
|
|
17
19
|
};
|
|
18
20
|
export default class FormItem extends ContextProvide<FormItemSignal, FormItemState> {
|
|
19
21
|
static baseName: string;
|
|
@@ -30,6 +32,10 @@ export default class FormItem extends ContextProvide<FormItemSignal, FormItemSta
|
|
|
30
32
|
rules?: RuleType[];
|
|
31
33
|
message?: string;
|
|
32
34
|
}): void;
|
|
35
|
+
render_v2(): {
|
|
36
|
+
template?: string | HTMLElement | DocumentFragment;
|
|
37
|
+
style?: string | string[];
|
|
38
|
+
};
|
|
33
39
|
render(): DocumentFragment;
|
|
34
40
|
private _updateRequired;
|
|
35
41
|
private _parseSchema;
|
package/lib/form/form_item.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../form_item-
|
|
1
|
+
import { t as e } from "../form_item-Clu9QKRa.js";
|
|
2
2
|
export { e as default };
|
package/lib/form/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface FormState {
|
|
|
5
5
|
inline: boolean;
|
|
6
6
|
labelPosition: "left" | "right" | "top";
|
|
7
7
|
labelWidth: string;
|
|
8
|
+
labelHeight?: string;
|
|
8
9
|
novalidate: boolean;
|
|
9
10
|
}
|
|
10
11
|
export default class Form extends BaseComponent<FormState> {
|
|
@@ -21,6 +22,10 @@ export default class Form extends BaseComponent<FormState> {
|
|
|
21
22
|
connectedCallback(): void;
|
|
22
23
|
afterInit(): void;
|
|
23
24
|
disconnectedCallback(): void;
|
|
25
|
+
protected render_v2(): {
|
|
26
|
+
style: string[];
|
|
27
|
+
template: string;
|
|
28
|
+
};
|
|
24
29
|
render(): string;
|
|
25
30
|
ruleChange: (e: CustomEvent) => void;
|
|
26
31
|
private _provide;
|
package/lib/form/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../form-
|
|
1
|
+
import { t as e } from "../form-CNWykMNM.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import e from "./base.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import { $one as
|
|
5
|
-
import
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "./utils/index.js";
|
|
3
|
+
import { n as i } from "./esm-sVEoAVPu.js";
|
|
4
|
+
import { $one as a, formatClass as o, off as s, on as c } from "ph-utils/dom";
|
|
5
|
+
import l from "ph-utils/validator";
|
|
6
6
|
//#region src/components/form/index.less?inline
|
|
7
|
-
var
|
|
7
|
+
var u = ":host{display:block}.l-form{gap:var(--l-form-gap,20px);flex-flow:column;display:flex}.l-form-inline{gap:var(--l-form-gap,20px);flex-flow:wrap;display:flex}.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}", d = class extends e {
|
|
8
8
|
static baseName = "form";
|
|
9
9
|
validator;
|
|
10
10
|
_data;
|
|
@@ -12,12 +12,12 @@ var l = ":host{display:block}.l-form{gap:var(--l-form-gap,20px);flex-flow:column
|
|
|
12
12
|
errors;
|
|
13
13
|
resetCtx;
|
|
14
14
|
constructor() {
|
|
15
|
-
super(), this._state = {
|
|
15
|
+
super(), this.version = 2, this._state = {
|
|
16
16
|
inline: !1,
|
|
17
17
|
labelPosition: "right",
|
|
18
18
|
labelWidth: "80px",
|
|
19
19
|
novalidate: !1
|
|
20
|
-
}, this.validator = new
|
|
20
|
+
}, this.validator = new l([]), this.context = i({ innerBlock: !1 }), this.errors = i({}), this.resetCtx = i(0);
|
|
21
21
|
}
|
|
22
22
|
static get observedAttributes() {
|
|
23
23
|
return [
|
|
@@ -25,49 +25,57 @@ var l = ":host{display:block}.l-form{gap:var(--l-form-gap,20px);flex-flow:column
|
|
|
25
25
|
"inner-block",
|
|
26
26
|
"inline",
|
|
27
27
|
"novalidate",
|
|
28
|
-
"label-width"
|
|
28
|
+
"label-width",
|
|
29
|
+
"label-height"
|
|
29
30
|
];
|
|
30
31
|
}
|
|
31
|
-
attributeChanged(e,
|
|
32
|
+
attributeChanged(e, i, a) {
|
|
32
33
|
switch (e) {
|
|
33
34
|
case "label-position":
|
|
34
|
-
this._state.labelPosition =
|
|
35
|
+
this._state.labelPosition = a;
|
|
35
36
|
break;
|
|
36
37
|
case "inner-block":
|
|
37
|
-
let
|
|
38
|
-
this.context({ innerBlock:
|
|
38
|
+
let i = n(a, !1, e);
|
|
39
|
+
this.context({ innerBlock: i });
|
|
39
40
|
break;
|
|
40
41
|
case "label-width":
|
|
41
|
-
|
|
42
|
+
case "label-height":
|
|
43
|
+
this._state[t(e)] = r(a);
|
|
42
44
|
break;
|
|
43
45
|
default:
|
|
44
|
-
let
|
|
45
|
-
this._state[e] =
|
|
46
|
+
let o = n(a, !1, e);
|
|
47
|
+
this._state[e] = o;
|
|
46
48
|
break;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
updateDOM(e) {
|
|
50
52
|
if (e.has("label-position") || e.has("inline")) {
|
|
51
|
-
let e =
|
|
52
|
-
e && (e.className =
|
|
53
|
+
let e = a("form", this.root);
|
|
54
|
+
e && (e.className = o([
|
|
53
55
|
"l-form",
|
|
54
56
|
this._state.inline ? "l-form-inline" : void 0,
|
|
55
57
|
`l-form--${this._state.labelPosition}`
|
|
56
58
|
]));
|
|
57
59
|
}
|
|
58
|
-
e.has("label-width") && (this._state.labelWidth ? this.style.setProperty("--l-form-label-width", this._state.labelWidth) : this.style.removeProperty("--l-form-label-width"));
|
|
60
|
+
e.has("label-width") && (this._state.labelWidth ? this.style.setProperty("--l-form-label-width", this._state.labelWidth) : this.style.removeProperty("--l-form-label-width")), e.has("label-height") && (this._state.labelHeight ? this.style.setProperty("--l-form-label-height", this._state.labelHeight) : this.style.removeProperty("--l-form-label-height"));
|
|
59
61
|
}
|
|
60
62
|
connectedCallback() {
|
|
61
|
-
|
|
63
|
+
c(this, "form-context-request", this._provide), super.connectedCallback();
|
|
62
64
|
}
|
|
63
65
|
afterInit() {
|
|
64
|
-
|
|
66
|
+
c(this, "form-rule-change", this.ruleChange), c(this, "form-value-change", this._valueChange), c(this, "form-action", this._formAction);
|
|
65
67
|
}
|
|
66
68
|
disconnectedCallback() {
|
|
67
|
-
this.validator = void 0,
|
|
69
|
+
this.validator = void 0, s(this, "form-rule-change", this.ruleChange), s(this, "form-value-change", this._valueChange), s(this, "form-context-request", this._provide), s(this, "form-action", this._formAction), super.disconnectedCallback();
|
|
70
|
+
}
|
|
71
|
+
render_v2() {
|
|
72
|
+
return {
|
|
73
|
+
style: [u],
|
|
74
|
+
template: this.render()
|
|
75
|
+
};
|
|
68
76
|
}
|
|
69
77
|
render() {
|
|
70
|
-
let e =
|
|
78
|
+
let e = o([
|
|
71
79
|
"l-form",
|
|
72
80
|
this._state.inline ? "l-form-inline" : void 0,
|
|
73
81
|
`l-form--${this._state.labelPosition}`
|
|
@@ -138,7 +146,7 @@ var l = ":host{display:block}.l-form{gap:var(--l-form-gap,20px);flex-flow:column
|
|
|
138
146
|
}
|
|
139
147
|
async validate() {
|
|
140
148
|
try {
|
|
141
|
-
return await this.validator.validate(this._data), this.errors({}), Promise.resolve(!0);
|
|
149
|
+
return await this.validator.validate(this._data || {}), this.errors({}), Promise.resolve(!0);
|
|
142
150
|
} catch (e) {
|
|
143
151
|
return this.errors(e.detail), Promise.resolve(!1);
|
|
144
152
|
}
|
|
@@ -151,4 +159,4 @@ var l = ":host{display:block}.l-form{gap:var(--l-form-gap,20px);flex-flow:column
|
|
|
151
159
|
}
|
|
152
160
|
};
|
|
153
161
|
//#endregion
|
|
154
|
-
export {
|
|
162
|
+
export { d as t };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { kebabToCamel as e, parseAttrValue as t, stopSignal as n, unitNumberStr as r } from "./utils/index.js";
|
|
2
|
+
import { n as i, t as a } from "./esm-sVEoAVPu.js";
|
|
3
|
+
import o from "./utils/context_provide.js";
|
|
4
|
+
import { $$ as s, $one as c, addClass as l, removeClass as u } from "ph-utils/dom";
|
|
5
|
+
//#region src/components/form/form_item.less?inline
|
|
6
|
+
var d = ":host{display:var(--l-form-item-display,flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align,right);width:var(--l-form-label-width,auto);height:var(--l-form-label-height,var(--l-form-control-height,32px));line-height:var(--l-form-label-height,var(--l-form-control-height,32px));color:#606266;box-sizing:border-box;padding:0 10px 0 0;display:inline-block}.l-form-item__label:empty{display:var(--l-form-label-empty-display,inline-block)}:host(.is-required) .l-form-item__label:before{content:\"*\";color:var(--l-warn-color,#f56c6c);vertical-align:middle;margin-right:4px}.l-form-item__content{flex:1;align-items:center;display:flex;position:relative}.l-form-item__error{color:var(--nt-error-color,#ed3f13);padding-top:3px;font-size:12px;line-height:1;position:absolute;top:100%;left:0}: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}", f = class extends o {
|
|
7
|
+
static baseName = "form-item";
|
|
8
|
+
formErrors;
|
|
9
|
+
_errorSignalStop;
|
|
10
|
+
constructor() {
|
|
11
|
+
super(), this.version = 2, this.contextEventName = "form-item-context-request", this._state = {
|
|
12
|
+
labelPosition: "right",
|
|
13
|
+
required: !1
|
|
14
|
+
}, this.context = i({ innerBlock: !1 });
|
|
15
|
+
}
|
|
16
|
+
static get observedAttributes() {
|
|
17
|
+
return [
|
|
18
|
+
"error",
|
|
19
|
+
"label",
|
|
20
|
+
"required",
|
|
21
|
+
"inner-block",
|
|
22
|
+
"prop",
|
|
23
|
+
"label-position",
|
|
24
|
+
"verify",
|
|
25
|
+
"pattern",
|
|
26
|
+
"validity",
|
|
27
|
+
"label-width",
|
|
28
|
+
"label-height"
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
attributeChanged(n, i, a) {
|
|
32
|
+
switch (n) {
|
|
33
|
+
case "error":
|
|
34
|
+
case "label":
|
|
35
|
+
case "verify":
|
|
36
|
+
case "pattern":
|
|
37
|
+
case "validity":
|
|
38
|
+
this._state[n] = a;
|
|
39
|
+
break;
|
|
40
|
+
case "label-position":
|
|
41
|
+
this._state.labelPosition = a;
|
|
42
|
+
break;
|
|
43
|
+
case "inner-block":
|
|
44
|
+
let i = t(a, !1, n);
|
|
45
|
+
this.context({ innerBlock: i });
|
|
46
|
+
break;
|
|
47
|
+
case "required":
|
|
48
|
+
let o = t(a, !1, n);
|
|
49
|
+
this._state.required = o;
|
|
50
|
+
break;
|
|
51
|
+
case "prop":
|
|
52
|
+
this._state.prop = a, this.context({
|
|
53
|
+
...this.context(),
|
|
54
|
+
prop: a
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
case "label-width":
|
|
58
|
+
case "label-height":
|
|
59
|
+
this._state[e(n)] = r(a);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
updateDOM(e) {
|
|
64
|
+
e.has("required") && this._updateRequired(), e.has("label") && this._updateLabel(), e.has("error") && this._updateError(), e.has("label-width") && (this._state.labelWidth ? this.style.setProperty("--l-form-label-width", this._state.labelWidth) : this.style.removeProperty("--l-form-label-width")), e.has("label-height") && (this._state.labelHeight ? this.style.setProperty("--l-form-label-height", this._state.labelHeight) : this.style.removeProperty("--l-form-label-height"));
|
|
65
|
+
}
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
super.connectedCallback(), this._updateRequired(), this._parseSchema(), this.emitInject("form-context-request", ((e, t) => {
|
|
68
|
+
this.formErrors = t;
|
|
69
|
+
})), this._errorSignalStop = a(() => {
|
|
70
|
+
let e = this.context().prop, t = this.formErrors ? this.formErrors() : null;
|
|
71
|
+
e && t && (this._state.error = t[e], this._updateError());
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
beforeDestroy() {
|
|
75
|
+
this._errorSignalStop = n(this._errorSignalStop);
|
|
76
|
+
}
|
|
77
|
+
setRules(e) {
|
|
78
|
+
let t = this._state.prop;
|
|
79
|
+
if (t) {
|
|
80
|
+
let n = {
|
|
81
|
+
...e,
|
|
82
|
+
key: t
|
|
83
|
+
};
|
|
84
|
+
this._updateRules(n);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
render_v2() {
|
|
88
|
+
return {
|
|
89
|
+
template: this.render(),
|
|
90
|
+
style: [d]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
this.classList.add(`l-form-item--${this._state.labelPosition}`);
|
|
95
|
+
let e = document.createDocumentFragment();
|
|
96
|
+
this._state.label != null && e.appendChild(s("label", {
|
|
97
|
+
class: "l-form-item__label",
|
|
98
|
+
textContent: this._state.label
|
|
99
|
+
}));
|
|
100
|
+
let t = s("div", { class: "l-form-item__content" }), n = s("slot");
|
|
101
|
+
return t.appendChild(n), this._state.error && t.appendChild(s("div", {
|
|
102
|
+
class: "l-form-item__error",
|
|
103
|
+
textContent: this._state.error
|
|
104
|
+
})), e.appendChild(t), e;
|
|
105
|
+
}
|
|
106
|
+
_updateRequired() {
|
|
107
|
+
this._state.required ? l(this, "is-required") : u(this, "is-required");
|
|
108
|
+
}
|
|
109
|
+
_parseSchema() {
|
|
110
|
+
let e = this.context().prop;
|
|
111
|
+
if (e) {
|
|
112
|
+
let t = [], n = this._state.verify;
|
|
113
|
+
n && (t = n.split("|"));
|
|
114
|
+
let r = this._state.pattern;
|
|
115
|
+
r && t.push(new RegExp(r));
|
|
116
|
+
let i = {
|
|
117
|
+
key: e,
|
|
118
|
+
required: this._state.required,
|
|
119
|
+
message: this._state.validity,
|
|
120
|
+
rules: t
|
|
121
|
+
};
|
|
122
|
+
this._updateRules(i);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_updateError() {
|
|
126
|
+
if (this._state.error ? l(this, "is-error") : u(this, "is-error"), !this.rendered) return;
|
|
127
|
+
let e = c(".l-form-item__error", this.root);
|
|
128
|
+
if (e) this._state.error ? e.textContent = this._state.error : e.remove();
|
|
129
|
+
else if (this._state.error) {
|
|
130
|
+
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this._state.error;
|
|
131
|
+
let t = c(".l-form-item__content", this.root);
|
|
132
|
+
t && t.appendChild(e);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
_updateLabel() {
|
|
136
|
+
if (!this.rendered) return;
|
|
137
|
+
let e = c(".l-form-item__label", this.root);
|
|
138
|
+
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.remove() : e.textContent = this._state.label;
|
|
139
|
+
}
|
|
140
|
+
_updateRules(e) {
|
|
141
|
+
this.emit("form-rule-change", {
|
|
142
|
+
bubbles: !0,
|
|
143
|
+
composed: !0,
|
|
144
|
+
detail: e
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
export { f as t };
|
package/lib/index.js
CHANGED
|
@@ -37,13 +37,13 @@ import G from "./icon/zoom_out.js";
|
|
|
37
37
|
import K from "./icon/select.js";
|
|
38
38
|
import q from "./icon/calendar.js";
|
|
39
39
|
import J from "./icon/refresh.js";
|
|
40
|
-
import { t as Y } from "./form-
|
|
41
|
-
import { t as X } from "./form_item-
|
|
40
|
+
import { t as Y } from "./form-CNWykMNM.js";
|
|
41
|
+
import { t as X } from "./form_item-Clu9QKRa.js";
|
|
42
42
|
import Z from "./check/radio_group.js";
|
|
43
43
|
import { t as Q } from "./radio-2mNSYujz.js";
|
|
44
44
|
import { t as $ } from "./checkbox-DbWsmAaL.js";
|
|
45
45
|
import ee from "./check/checkbox_group.js";
|
|
46
|
-
import { t as te } from "./button-
|
|
46
|
+
import { t as te } from "./button-DEm6CutF.js";
|
|
47
47
|
import ne from "./input/index.js";
|
|
48
48
|
import re from "./select_ori/index.js";
|
|
49
49
|
import { t as ie } from "./switch-BaVBi5Ip.js";
|
package/lib/input/index.js
CHANGED
|
@@ -68,7 +68,7 @@ var p = class extends n {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
updateDOM(e) {
|
|
71
|
-
e.has("clearable") && (this._state.clearable ? c(this, "l-input--clearable") : f(this, "l-input--clearable")), e.has("error") && this._updateError(this._state.error != null), e.has("maxlength") && this._updateAttr("maxlength", this._state.maxlength), e.has("minlength") && this._updateAttr("minlength", this._state.minlength), e.has("inputmode") && this._updateAttr("inputmode", this._state.inputmode), e.has("block") && this.innerBlockChange(this._state.block);
|
|
71
|
+
e.has("clearable") && (this._state.clearable ? c(this, "l-input--clearable") : f(this, "l-input--clearable")), e.has("error") && this._updateError(this._state.error != null), e.has("maxlength") && this._updateAttr("maxlength", this._state.maxlength), e.has("minlength") && this._updateAttr("minlength", this._state.minlength), e.has("inputmode") && this._updateAttr("inputmode", this._state.inputmode), e.has("block") && this.innerBlockChange(this._state.block), e.has("placeholder") && this.$inner && (this.$inner.placeholder = this._state.placeholder);
|
|
72
72
|
}
|
|
73
73
|
_updateAttr(e, t) {
|
|
74
74
|
this.$inner && (t ? this.$inner.setAttribute(e, t) : this.$inner.removeAttribute(e));
|
|
@@ -126,7 +126,13 @@ var p = class extends n {
|
|
|
126
126
|
precision: t
|
|
127
127
|
}), r = String(r);
|
|
128
128
|
}
|
|
129
|
-
this.parser != null && (r = this.parser(r))
|
|
129
|
+
this.parser != null && (r = this.parser(r));
|
|
130
|
+
try {
|
|
131
|
+
this._calcCurosorPosition(t, r);
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.warn(e);
|
|
134
|
+
}
|
|
135
|
+
this.setValue(r), this.#e();
|
|
130
136
|
};
|
|
131
137
|
#e() {
|
|
132
138
|
if (this._state.clearable) {
|
package/lib/modal/modal_box.js
CHANGED
|
@@ -2,8 +2,8 @@ import { regist as e } from "../utils/index.js";
|
|
|
2
2
|
import t from "../icon/info.js";
|
|
3
3
|
import { t as n } from "../modal-DWyWrN-D.js";
|
|
4
4
|
import r from "../icon/close.js";
|
|
5
|
-
import { t as i } from "../form_item-
|
|
6
|
-
import { t as a } from "../button-
|
|
5
|
+
import { t as i } from "../form_item-Clu9QKRa.js";
|
|
6
|
+
import { t as a } from "../button-DEm6CutF.js";
|
|
7
7
|
import o from "../input/index.js";
|
|
8
8
|
import { $$ as s, $one as c, on as l } from "ph-utils/dom";
|
|
9
9
|
//#region src/components/modal/modal_box.ts
|
package/package.json
CHANGED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { parseAttrValue as e, stopSignal as t } from "./utils/index.js";
|
|
2
|
-
import { n, t as r } from "./esm-sVEoAVPu.js";
|
|
3
|
-
import i from "./utils/context_provide.js";
|
|
4
|
-
import { $$ as a, $one as o, addClass as s, removeClass as c } from "ph-utils/dom";
|
|
5
|
-
//#region src/components/form/form_item.less?inline
|
|
6
|
-
var l = ":host{display:var(--l-form-item-display,flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align,right);width:var(--l-form-label-width,auto);height:var(--l-form-control-height,32px);line-height:var(--l-form-control-height,32px);color:#606266;box-sizing:border-box;padding:0 10px 0 0;display:inline-block}.l-form-item__label:empty{display:var(--l-form-label-empty-display,inline-block)}:host(.is-required) .l-form-item__label:before{content:\"*\";color:var(--l-warn-color,#f56c6c);vertical-align:middle;margin-right:4px}.l-form-item__content{flex:1;align-items:center;display:flex;position:relative}.l-form-item__error{color:var(--nt-error-color,#ed3f13);padding-top:3px;font-size:12px;line-height:1;position:absolute;top:100%;left:0}: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}", u = class extends i {
|
|
7
|
-
static baseName = "form-item";
|
|
8
|
-
formErrors;
|
|
9
|
-
_errorSignalStop;
|
|
10
|
-
constructor() {
|
|
11
|
-
super(), this.contextEventName = "form-item-context-request", this._state = {
|
|
12
|
-
labelPosition: "right",
|
|
13
|
-
required: !1
|
|
14
|
-
}, this.context = n({ innerBlock: !1 });
|
|
15
|
-
}
|
|
16
|
-
static get observedAttributes() {
|
|
17
|
-
return [
|
|
18
|
-
"error",
|
|
19
|
-
"label",
|
|
20
|
-
"required",
|
|
21
|
-
"inner-block",
|
|
22
|
-
"prop",
|
|
23
|
-
"label-position",
|
|
24
|
-
"verify",
|
|
25
|
-
"pattern",
|
|
26
|
-
"validity"
|
|
27
|
-
];
|
|
28
|
-
}
|
|
29
|
-
attributeChanged(t, n, r) {
|
|
30
|
-
switch (t) {
|
|
31
|
-
case "error":
|
|
32
|
-
case "label":
|
|
33
|
-
case "verify":
|
|
34
|
-
case "pattern":
|
|
35
|
-
case "validity":
|
|
36
|
-
this._state[t] = r;
|
|
37
|
-
break;
|
|
38
|
-
case "label-position":
|
|
39
|
-
this._state.labelPosition = r;
|
|
40
|
-
break;
|
|
41
|
-
case "inner-block":
|
|
42
|
-
let n = e(r, !1, t);
|
|
43
|
-
this.context({ innerBlock: n });
|
|
44
|
-
break;
|
|
45
|
-
case "required":
|
|
46
|
-
let i = e(r, !1, t);
|
|
47
|
-
this._state.required = i;
|
|
48
|
-
break;
|
|
49
|
-
case "prop":
|
|
50
|
-
this._state.prop = r, this.context({
|
|
51
|
-
...this.context(),
|
|
52
|
-
prop: r
|
|
53
|
-
});
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
updateDOM(e) {
|
|
58
|
-
e.has("required") && this._updateRequired(), e.has("label") && this._updateLabel(), e.has("error") && this._updateError();
|
|
59
|
-
}
|
|
60
|
-
connectedCallback() {
|
|
61
|
-
this.loadStyleText([l]), super.connectedCallback(), this._updateRequired(), this._parseSchema(), this.emitInject("form-context-request", ((e, t) => {
|
|
62
|
-
this.formErrors = t;
|
|
63
|
-
})), this._errorSignalStop = r(() => {
|
|
64
|
-
let e = this.context().prop, t = this.formErrors ? this.formErrors() : null;
|
|
65
|
-
e && t && (this._state.error = t[e], this._updateError());
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
beforeDestroy() {
|
|
69
|
-
this._errorSignalStop = t(this._errorSignalStop);
|
|
70
|
-
}
|
|
71
|
-
setRules(e) {
|
|
72
|
-
let t = this._state.prop;
|
|
73
|
-
if (t) {
|
|
74
|
-
let n = {
|
|
75
|
-
...e,
|
|
76
|
-
key: t
|
|
77
|
-
};
|
|
78
|
-
this._updateRules(n);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
render() {
|
|
82
|
-
this.classList.add(`l-form-item--${this._state.labelPosition}`);
|
|
83
|
-
let e = document.createDocumentFragment();
|
|
84
|
-
this._state.label != null && e.appendChild(a("label", {
|
|
85
|
-
class: "l-form-item__label",
|
|
86
|
-
textContent: this._state.label
|
|
87
|
-
}));
|
|
88
|
-
let t = a("div", { class: "l-form-item__content" }), n = a("slot");
|
|
89
|
-
return t.appendChild(n), this._state.error && t.appendChild(a("div", {
|
|
90
|
-
class: "l-form-item__error",
|
|
91
|
-
textContent: this._state.error
|
|
92
|
-
})), e.appendChild(t), e;
|
|
93
|
-
}
|
|
94
|
-
_updateRequired() {
|
|
95
|
-
this._state.required ? s(this, "is-required") : c(this, "is-required");
|
|
96
|
-
}
|
|
97
|
-
_parseSchema() {
|
|
98
|
-
let e = this.context().prop;
|
|
99
|
-
if (e) {
|
|
100
|
-
let t = [], n = this._state.verify;
|
|
101
|
-
n && (t = n.split("|"));
|
|
102
|
-
let r = this._state.pattern;
|
|
103
|
-
r && t.push(new RegExp(r));
|
|
104
|
-
let i = {
|
|
105
|
-
key: e,
|
|
106
|
-
required: this._state.required,
|
|
107
|
-
message: this._state.validity,
|
|
108
|
-
rules: t
|
|
109
|
-
};
|
|
110
|
-
this._updateRules(i);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
_updateError() {
|
|
114
|
-
if (this._state.error ? s(this, "is-error") : c(this, "is-error"), !this.rendered) return;
|
|
115
|
-
let e = o(".l-form-item__error", this.root);
|
|
116
|
-
if (e) this._state.error ? e.textContent = this._state.error : e.remove();
|
|
117
|
-
else if (this._state.error) {
|
|
118
|
-
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this._state.error;
|
|
119
|
-
let t = o(".l-form-item__content", this.root);
|
|
120
|
-
t && t.appendChild(e);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
_updateLabel() {
|
|
124
|
-
if (!this.rendered) return;
|
|
125
|
-
let e = o(".l-form-item__label", this.root);
|
|
126
|
-
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.remove() : e.textContent = this._state.label;
|
|
127
|
-
}
|
|
128
|
-
_updateRules(e) {
|
|
129
|
-
this.emit("form-rule-change", {
|
|
130
|
-
bubbles: !0,
|
|
131
|
-
composed: !0,
|
|
132
|
-
detail: e
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
//#endregion
|
|
137
|
-
export { u as t };
|