litos-ui 0.17.0 → 0.17.1
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.
|
@@ -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-DY6m9Wbe.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/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $one as
|
|
2
|
-
import { parseAttrValue as
|
|
1
|
+
import { $one as c, formatClass as d, on as r, off as o } from "ph-utils/dom";
|
|
2
|
+
import { unitNumberStr as m, parseAttrValue as f } from "../utils/index.js";
|
|
3
3
|
import u from "ph-utils/validator";
|
|
4
|
-
import { s as
|
|
4
|
+
import { s as n } from "../index-CrMiSe0x.js";
|
|
5
5
|
import v from "../base.js";
|
|
6
|
-
const
|
|
6
|
+
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}";
|
|
7
7
|
class k extends v {
|
|
8
8
|
static baseName = "form";
|
|
9
9
|
validator;
|
|
@@ -19,38 +19,42 @@ class k extends v {
|
|
|
19
19
|
labelPosition: "right",
|
|
20
20
|
labelWidth: "80px",
|
|
21
21
|
novalidate: !1
|
|
22
|
-
}, this.validator = new u([]), this.context =
|
|
22
|
+
}, this.validator = new u([]), this.context = n({ innerBlock: !1 }), this.errors = n({}), this.resetCtx = n(0);
|
|
23
23
|
}
|
|
24
24
|
static get observedAttributes() {
|
|
25
|
-
return ["label-position", "inner-block", "inline", "novalidate"];
|
|
25
|
+
return ["label-position", "inner-block", "inline", "novalidate", "label-width"];
|
|
26
26
|
}
|
|
27
|
-
attributeChanged(t,
|
|
27
|
+
attributeChanged(t, i, e) {
|
|
28
28
|
switch (t) {
|
|
29
29
|
case "label-position":
|
|
30
|
-
this._state.labelPosition =
|
|
30
|
+
this._state.labelPosition = e;
|
|
31
31
|
break;
|
|
32
32
|
case "inner-block":
|
|
33
|
-
const s =
|
|
33
|
+
const s = f(e, !1, t);
|
|
34
34
|
this.context({ innerBlock: s });
|
|
35
35
|
break;
|
|
36
|
+
case "label-width":
|
|
37
|
+
this._state.labelWidth = m(e);
|
|
38
|
+
break;
|
|
36
39
|
default:
|
|
37
|
-
const a =
|
|
40
|
+
const a = f(e, !1, t);
|
|
38
41
|
this._state[t] = a;
|
|
39
42
|
break;
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
updateDOM(t) {
|
|
43
46
|
if (t.has("label-position") || t.has("inline")) {
|
|
44
|
-
const
|
|
45
|
-
|
|
47
|
+
const i = c("form", this.root);
|
|
48
|
+
i && (i.className = d([
|
|
46
49
|
"l-form",
|
|
47
50
|
this._state.inline ? "l-form-inline" : void 0,
|
|
48
51
|
`l-form--${this._state.labelPosition}`
|
|
49
52
|
]));
|
|
50
53
|
}
|
|
54
|
+
t.has("label-width") && (this._state.labelWidth ? this.style.setProperty("--l-form-label-width", this._state.labelWidth) : this.style.removeProperty("--l-form-label-width"));
|
|
51
55
|
}
|
|
52
56
|
connectedCallback() {
|
|
53
|
-
r(this, "form-context-request", this._provide), this.loadStyleText([
|
|
57
|
+
r(this, "form-context-request", this._provide), this.loadStyleText([b]), super.connectedCallback();
|
|
54
58
|
}
|
|
55
59
|
afterInit() {
|
|
56
60
|
r(this, "form-rule-change", this.ruleChange), r(this, "form-value-change", this._valueChange), r(this, "form-action", this._formAction);
|
|
@@ -63,48 +67,46 @@ class k extends v {
|
|
|
63
67
|
"l-form",
|
|
64
68
|
this._state.inline ? "l-form-inline" : void 0,
|
|
65
69
|
`l-form--${this._state.labelPosition}`
|
|
66
|
-
])
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
return `<form class="${t}" style="${e}"><slot></slot></form>`;
|
|
70
|
+
]);
|
|
71
|
+
return this._state.labelWidth && this.style.setProperty("--l-form-label-width", this._state.labelWidth), `<form class="${t}"><slot></slot></form>`;
|
|
70
72
|
}
|
|
71
73
|
ruleChange = (t) => {
|
|
72
74
|
t.stopPropagation(), this.validator.addSchema(t.detail);
|
|
73
75
|
};
|
|
74
76
|
_provide(t) {
|
|
75
|
-
const { context:
|
|
76
|
-
|
|
77
|
+
const { context: i, callback: e } = t.detail;
|
|
78
|
+
i === "form-context-request" && e(this.context, this.errors, this.resetCtx);
|
|
77
79
|
}
|
|
78
80
|
_formAction = (t) => {
|
|
79
81
|
t.detail === "submit" ? this.submit() : this.reset();
|
|
80
82
|
};
|
|
81
83
|
_valueChange = (t) => {
|
|
82
|
-
const { name:
|
|
83
|
-
if (!
|
|
84
|
+
const { name: i, value: e, valid: s } = t.detail;
|
|
85
|
+
if (!i) return;
|
|
84
86
|
this._data == null && (this._data = {});
|
|
85
|
-
const a = Object.hasOwn(this._data,
|
|
86
|
-
this._data[
|
|
87
|
+
const a = Object.hasOwn(this._data, i);
|
|
88
|
+
this._data[i] = e, !this._state.novalidate && a && s && this.validator.validateKey(i, e, this._data).then(() => {
|
|
87
89
|
const l = this.errors();
|
|
88
|
-
l[
|
|
90
|
+
l[i] = void 0, this.errors({ ...l });
|
|
89
91
|
}).catch((l) => {
|
|
90
92
|
this.errors({ ...this.errors(), ...l.detail });
|
|
91
93
|
});
|
|
92
94
|
};
|
|
93
95
|
validateField(t) {
|
|
94
|
-
const
|
|
96
|
+
const i = [];
|
|
95
97
|
if (this._data != null) {
|
|
96
98
|
if (Array.isArray(t))
|
|
97
|
-
for (let
|
|
98
|
-
const a = t[
|
|
99
|
-
|
|
99
|
+
for (let e = 0, s = t.length; e < s; e++) {
|
|
100
|
+
const a = t[e];
|
|
101
|
+
i.push(this.validator.validateKey(a, this._data[a], this._data));
|
|
100
102
|
}
|
|
101
103
|
else
|
|
102
|
-
|
|
103
|
-
Promise.allSettled(
|
|
104
|
+
i.push(this.validator.validateKey(t, this._data[t], this._data));
|
|
105
|
+
Promise.allSettled(i).then((e) => {
|
|
104
106
|
let s = {};
|
|
105
|
-
for (let a = 0, l =
|
|
106
|
-
const
|
|
107
|
-
|
|
107
|
+
for (let a = 0, l = e.length; a < l; a++) {
|
|
108
|
+
const h = e[a];
|
|
109
|
+
h.status === "rejected" ? s = { ...s, ...h.reason.detail } : s[h.value.key] = void 0;
|
|
108
110
|
}
|
|
109
111
|
this.errors({ ...this.errors(), ...s });
|
|
110
112
|
});
|
|
@@ -1,4 +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}";
|
|
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;background-color:transparent}.l-input__inner:disabled{background-color:transparent}";
|
|
2
2
|
export {
|
|
3
3
|
r as i
|
|
4
4
|
};
|
package/lib/input/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $one as c, on as h, formatStyle as f, off as p, addClass as o, removeClass as u, $ as d, $$ as n } from "ph-utils/dom";
|
|
2
2
|
import { unitNumberStr as b, parseAttrValue as m } from "../utils/index.js";
|
|
3
3
|
import g from "../form/form_inner.js";
|
|
4
|
-
import { i as _ } from "../index-
|
|
4
|
+
import { i as _ } from "../index-DY6m9Wbe.js";
|
|
5
5
|
class I extends g {
|
|
6
6
|
static baseName = "input";
|
|
7
7
|
/** 自定义输入解析器 */
|
|
@@ -35,6 +35,7 @@ class I extends g {
|
|
|
35
35
|
"minlength",
|
|
36
36
|
"inputmode",
|
|
37
37
|
"type",
|
|
38
|
+
"placeholder",
|
|
38
39
|
"width",
|
|
39
40
|
"block"
|
|
40
41
|
];
|
|
@@ -51,6 +52,7 @@ class I extends g {
|
|
|
51
52
|
case "maxlength":
|
|
52
53
|
case "minlength":
|
|
53
54
|
case "inputmode":
|
|
55
|
+
case "placeholder":
|
|
54
56
|
case "type":
|
|
55
57
|
this._state[t] = e;
|
|
56
58
|
break;
|
package/lib/select_ori/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import a from "../form/form_inner.js";
|
|
2
2
|
import { tagAttrs as c } from "../utils/index.js";
|
|
3
3
|
import { $one as r, on as h, off as o } from "ph-utils/dom";
|
|
4
|
-
import { i as d } from "../index-
|
|
4
|
+
import { i as d } from "../index-DY6m9Wbe.js";
|
|
5
5
|
class v extends a {
|
|
6
6
|
static baseName = "select-ori";
|
|
7
7
|
$select;
|