litos-ui 0.13.0 → 0.14.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.
- package/lib/base.d.ts +1 -1
- package/lib/base.js +3 -3
- package/lib/button/index.d.ts +4 -1
- package/lib/button/index.js +28 -13
- package/lib/carousel/index.d.ts +20 -0
- package/lib/carousel/index.js +280 -0
- package/lib/carousel/item.d.ts +6 -0
- package/lib/carousel/item.js +15 -0
- package/lib/carousel/timer.d.ts +5 -0
- package/lib/carousel/timer.js +19 -0
- package/lib/check/check.d.ts +22 -0
- package/lib/check/check.js +81 -0
- package/lib/check/checkbox.d.ts +7 -0
- package/lib/check/checkbox.js +25 -0
- package/lib/check/checkbox_group.d.ts +9 -0
- package/lib/check/checkbox_group.js +33 -0
- package/lib/check/index.d.ts +12 -0
- package/lib/check/index.js +35 -0
- package/lib/check/radio.d.ts +6 -0
- package/lib/check/radio.js +19 -0
- package/lib/check/radio_group.d.ts +6 -0
- package/lib/check/radio_group.js +24 -0
- package/lib/check-BlDsQQo0.js +4 -0
- package/lib/color_picker/index.d.ts +1 -1
- package/lib/color_picker/index.js +5 -5
- package/lib/form/form_inner.d.ts +1 -8
- package/lib/form/form_inner.js +31 -39
- package/lib/form/form_item.d.ts +1 -1
- package/lib/form/form_item.js +30 -37
- package/lib/form/index.js +5 -5
- package/lib/icon/close_filled.d.ts +1 -1
- package/lib/index.d.ts +12 -4
- package/lib/index.js +80 -72
- package/lib/input/index.js +10 -10
- package/lib/list/index.d.ts +1 -2
- package/lib/list/index.js +17 -17
- package/lib/md_input/index.js +9 -9
- package/lib/menu/index.d.ts +2 -0
- package/lib/menu/index.js +47 -42
- package/lib/menu/sub_menu.d.ts +4 -2
- package/lib/menu/sub_menu.js +59 -41
- package/lib/select_ori/index.d.ts +1 -1
- package/lib/select_ori/index.js +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +49 -49
- package/lib/utils/transition.js +3 -2
- package/package.json +1 -1
- package/lib/checkbox/index.d.ts +0 -17
- package/lib/checkbox/index.js +0 -135
- package/lib/radio/index.d.ts +0 -28
- package/lib/radio/index.js +0 -122
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
export default class CheckGroup extends FormInner {
|
|
3
|
+
#private;
|
|
4
|
+
button: boolean;
|
|
5
|
+
checkedValues: string[];
|
|
6
|
+
constructor();
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
afterInit(): void;
|
|
9
|
+
beforeDestroy(): void;
|
|
10
|
+
render(): HTMLElement;
|
|
11
|
+
valueChange(_value: string): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import t from "../form/form_inner.js";
|
|
2
|
+
import { on as s, off as a, $$ as o } from "ph-utils/dom";
|
|
3
|
+
import { initAttr as r } from "../utils/index.js";
|
|
4
|
+
const l = ":host{display:flex;align-items:center}";
|
|
5
|
+
class u extends t {
|
|
6
|
+
button = !1;
|
|
7
|
+
// 是否为按钮样式
|
|
8
|
+
checkedValues;
|
|
9
|
+
constructor() {
|
|
10
|
+
super(!1), this.checkedValues = [];
|
|
11
|
+
}
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
r(this), this.loadStyleText([l]), super.connectedCallback();
|
|
14
|
+
}
|
|
15
|
+
afterInit() {
|
|
16
|
+
s(this.root, "change", this.#e);
|
|
17
|
+
}
|
|
18
|
+
beforeDestroy() {
|
|
19
|
+
a(this.root, "change", this.#e), this.checkedValues = [];
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return o("slot");
|
|
23
|
+
}
|
|
24
|
+
#e = (e) => {
|
|
25
|
+
this.valueChange(e.detail.value), e.stopPropagation(), this.emit("change", {
|
|
26
|
+
detail: { value: [...this.checkedValues] },
|
|
27
|
+
composed: !0
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
valueChange(e) {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
u as default
|
|
35
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import e from "./check.js";
|
|
2
|
+
import { c as o } from "../check-BlDsQQo0.js";
|
|
3
|
+
import { $one as r } 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 d extends e {
|
|
6
|
+
static baseName = "radio";
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
this.loadStyleText([o, t]), super.connectedCallback();
|
|
9
|
+
}
|
|
10
|
+
_doChangeAction() {
|
|
11
|
+
r("input", this.root).checked || (this.setAttribute("checked", ""), this.emit("change", {
|
|
12
|
+
detail: { value: this.value, name: this.getName() },
|
|
13
|
+
composed: !0
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
d as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import a from "./index.js";
|
|
2
|
+
import { $one as i } from "ph-utils/dom";
|
|
3
|
+
class u extends a {
|
|
4
|
+
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;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
u as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const r = ":host{--l-check-size: 16px;display:inline-flex;align-items:center;position:relative;cursor:pointer;width:auto;transition:color .3s,border-color .3s,background-color .3s}:host(:not(:first-child)){margin-left:15px}.l-check__input{margin:0;position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-check__inner{width:var(--l-check-size);height:var(--l-check-size);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}.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-edit-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,14 +1,14 @@
|
|
|
1
1
|
import { $one as i, on as s, off as a } from "ph-utils/dom";
|
|
2
|
-
import
|
|
3
|
-
import { initAttr as
|
|
2
|
+
import r from "../form/form_inner.js";
|
|
3
|
+
import { initAttr as c, setAttrs as n } from "../utils/index.js";
|
|
4
4
|
import { i as l } from "../index-dwS1N2uN.js";
|
|
5
5
|
const o = ":host{--l-input-width: 60px}";
|
|
6
|
-
class m extends
|
|
6
|
+
class m extends r {
|
|
7
7
|
static baseName = "color-picker";
|
|
8
8
|
$picker;
|
|
9
9
|
_value = "#000000";
|
|
10
10
|
constructor() {
|
|
11
|
-
super(),
|
|
11
|
+
super(), c(this);
|
|
12
12
|
}
|
|
13
13
|
setValue(e) {
|
|
14
14
|
super.setValue(e), this.$picker && (this.$picker.value = e);
|
|
@@ -29,7 +29,7 @@ class m extends c {
|
|
|
29
29
|
["class", "l-input l-color-picker"]
|
|
30
30
|
]), e;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
disabledChange() {
|
|
33
33
|
this.$picker && (this.$picker.disabled = this.isDisabled());
|
|
34
34
|
}
|
|
35
35
|
_handleChange = (e) => {
|
package/lib/form/form_inner.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
2
|
export default class FormInner extends BaseComponent {
|
|
3
3
|
disabled: boolean;
|
|
4
|
-
name?: string;
|
|
5
4
|
protected formAttrs: Record<string, any>;
|
|
6
5
|
protected formItemAttrs: Record<string, any>;
|
|
7
6
|
_value: any;
|
|
@@ -13,8 +12,8 @@ export default class FormInner extends BaseComponent {
|
|
|
13
12
|
* @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
|
|
14
13
|
*/
|
|
15
14
|
constructor(firstPushValue?: boolean);
|
|
16
|
-
set value(value: any);
|
|
17
15
|
get value(): any;
|
|
16
|
+
set value(value: any);
|
|
18
17
|
setValue(value: any): void;
|
|
19
18
|
getValue(): any;
|
|
20
19
|
static get observedAttributes(): string[];
|
|
@@ -26,12 +25,6 @@ export default class FormInner extends BaseComponent {
|
|
|
26
25
|
getName(): any;
|
|
27
26
|
private _getForm;
|
|
28
27
|
private _formAttributeChanged;
|
|
29
|
-
/** */
|
|
30
|
-
/**
|
|
31
|
-
* disable 属性改变时回调
|
|
32
|
-
* @deprecated 使用 disabledChange 代替
|
|
33
|
-
*/
|
|
34
|
-
protected _changeDisabled(): void;
|
|
35
28
|
protected disabledChange(): void;
|
|
36
29
|
protected pushValueChange(): void;
|
|
37
30
|
private _resetFieldValue;
|
package/lib/form/form_inner.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { parseAttrValue as
|
|
3
|
-
import { add as l, remove as
|
|
4
|
-
|
|
1
|
+
import o from "../base.js";
|
|
2
|
+
import { parseAttrValue as d } from "../utils/index.js";
|
|
3
|
+
import { add as l, remove as u, emit as f } from "../utils/event.js";
|
|
4
|
+
import { getAttr as m } from "ph-utils/dom";
|
|
5
|
+
class _ extends o {
|
|
5
6
|
disabled = !1;
|
|
6
|
-
name = void 0;
|
|
7
7
|
formAttrs = {};
|
|
8
8
|
formItemAttrs = {};
|
|
9
9
|
_value = "";
|
|
@@ -17,12 +17,12 @@ class A extends n {
|
|
|
17
17
|
constructor(t = !0) {
|
|
18
18
|
super(!0, { delegatesFocus: !0 }), this._firstPushValue = t;
|
|
19
19
|
}
|
|
20
|
+
get value() {
|
|
21
|
+
return this._value;
|
|
22
|
+
}
|
|
20
23
|
set value(t) {
|
|
21
24
|
this.setValue(t);
|
|
22
25
|
}
|
|
23
|
-
get value() {
|
|
24
|
-
return this.getValue();
|
|
25
|
-
}
|
|
26
26
|
setValue(t) {
|
|
27
27
|
this._value = t, this.pushValueChange();
|
|
28
28
|
}
|
|
@@ -30,17 +30,15 @@ class A extends n {
|
|
|
30
30
|
return this._value;
|
|
31
31
|
}
|
|
32
32
|
static get observedAttributes() {
|
|
33
|
-
return ["disabled"];
|
|
33
|
+
return ["disabled", "value"];
|
|
34
34
|
}
|
|
35
|
-
attributeChangedCallback(t,
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} else
|
|
41
|
-
this.attributeChange(t, e, s);
|
|
35
|
+
attributeChangedCallback(t, r, e) {
|
|
36
|
+
if (t === "disabled") {
|
|
37
|
+
const i = d(e, !1, t);
|
|
38
|
+
i !== this.disabled && (this.disabled = i, this.disabledChange());
|
|
39
|
+
} else t === "value" ? this.value = e : this.attributeChange(t, r, e);
|
|
42
40
|
}
|
|
43
|
-
attributeChange(t,
|
|
41
|
+
attributeChange(t, r, e) {
|
|
44
42
|
}
|
|
45
43
|
connectedCallback() {
|
|
46
44
|
const t = this._getForm();
|
|
@@ -51,7 +49,7 @@ class A extends n {
|
|
|
51
49
|
), super.connectedCallback();
|
|
52
50
|
}
|
|
53
51
|
disconnectedCallback() {
|
|
54
|
-
this.formAttrs.id && (
|
|
52
|
+
this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(
|
|
55
53
|
this.formItemAttrs.id,
|
|
56
54
|
"attributeChanged",
|
|
57
55
|
this._formAttributeChanged
|
|
@@ -61,50 +59,44 @@ class A extends n {
|
|
|
61
59
|
return this.disabled === !0 || this.formItemAttrs.disabled === !0 ? !0 : this.formAttrs.disabled || !1;
|
|
62
60
|
}
|
|
63
61
|
getName() {
|
|
64
|
-
|
|
62
|
+
const t = m(this, "name");
|
|
63
|
+
return t || this.formItemAttrs.name;
|
|
65
64
|
}
|
|
66
65
|
_getForm() {
|
|
67
|
-
let t = this.parentElement,
|
|
66
|
+
let t = this.parentElement, r = {}, e = {};
|
|
68
67
|
for (; t != null; ) {
|
|
69
68
|
const i = t.tagName;
|
|
70
69
|
if (i === "L-FORM") {
|
|
71
70
|
const a = t.sharedAttrs;
|
|
72
|
-
for (let
|
|
73
|
-
const h = a[
|
|
74
|
-
|
|
71
|
+
for (let s = 0; s < a.length; s++) {
|
|
72
|
+
const h = a[s];
|
|
73
|
+
r[h] = t[h];
|
|
75
74
|
}
|
|
76
75
|
break;
|
|
77
76
|
}
|
|
78
77
|
if (i === "BODY") break;
|
|
79
78
|
if (i === "L-FORM-ITEM") {
|
|
80
79
|
const a = t.sharedAttrs;
|
|
81
|
-
for (let
|
|
82
|
-
const h = a[
|
|
83
|
-
|
|
80
|
+
for (let s = 0; s < a.length; s++) {
|
|
81
|
+
const h = a[s];
|
|
82
|
+
e[h] = t[h];
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
t = t.parentElement;
|
|
87
86
|
}
|
|
88
87
|
return t = null, {
|
|
89
|
-
formAttr:
|
|
90
|
-
formItemAttr:
|
|
88
|
+
formAttr: r,
|
|
89
|
+
formItemAttr: e
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
|
-
_formAttributeChanged = (t,
|
|
94
|
-
|
|
92
|
+
_formAttributeChanged = (t, r, e) => {
|
|
93
|
+
e === this.formAttrs.formId ? this.formAttrs[t] = r : this.formItemAttrs[t] = r, t === "disabled" && this.disabledChange();
|
|
95
94
|
};
|
|
96
|
-
/** */
|
|
97
|
-
/**
|
|
98
|
-
* disable 属性改变时回调
|
|
99
|
-
* @deprecated 使用 disabledChange 代替
|
|
100
|
-
*/
|
|
101
|
-
_changeDisabled() {
|
|
102
|
-
}
|
|
103
95
|
disabledChange() {
|
|
104
96
|
}
|
|
105
97
|
pushValueChange() {
|
|
106
98
|
const t = this.getName();
|
|
107
|
-
this.formAttrs.id && t &&
|
|
99
|
+
this.formAttrs.id && t && f(
|
|
108
100
|
this.formAttrs.id,
|
|
109
101
|
"valueChange",
|
|
110
102
|
t,
|
|
@@ -120,5 +112,5 @@ class A extends n {
|
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
114
|
export {
|
|
123
|
-
|
|
115
|
+
_ as default
|
|
124
116
|
};
|
package/lib/form/form_item.d.ts
CHANGED
package/lib/form/form_item.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseAttrValue as
|
|
3
|
-
import
|
|
4
|
-
import { emit as o, add as
|
|
5
|
-
import { random as
|
|
6
|
-
const u = ':host{display:
|
|
7
|
-
class
|
|
1
|
+
import { $$ as i, $one as s, addClass as n, removeClass as d } from "ph-utils/dom";
|
|
2
|
+
import { parseAttrValue as h, initAttr as m } from "../utils/index.js";
|
|
3
|
+
import f from "../base.js";
|
|
4
|
+
import { emit as o, add as p, clear as c, 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-edit-height, 32px);line-height:var(--l-form-edit-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 {
|
|
8
8
|
static baseName = "form-item";
|
|
9
9
|
disabled = !1;
|
|
10
10
|
sharedAttrs = ["disabled", "id", "name", "innerBlock"];
|
|
@@ -32,12 +32,12 @@ class $ extends h {
|
|
|
32
32
|
else if (e === "label")
|
|
33
33
|
this.label = r, this._updateLabel();
|
|
34
34
|
else if (e === "disabled") {
|
|
35
|
-
const l =
|
|
35
|
+
const l = h(r, !1, e);
|
|
36
36
|
l !== this.disabled && (o(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
connectedCallback() {
|
|
40
|
-
if (
|
|
40
|
+
if (m(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) {
|
|
41
41
|
let e = this.verify?.split("|") || [];
|
|
42
42
|
this.pattern && e.push(new RegExp(this.pattern));
|
|
43
43
|
const t = {
|
|
@@ -46,11 +46,11 @@ class $ extends h {
|
|
|
46
46
|
message: this.validity,
|
|
47
47
|
rules: e
|
|
48
48
|
};
|
|
49
|
-
o(this.formId, "ruleChange", t),
|
|
49
|
+
o(this.formId, "ruleChange", t), p(this.formId, "validateChange", this._validateChange);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
disconnectedCallback() {
|
|
53
|
-
|
|
53
|
+
c(this.id), this.formId && b(this.formId, "validateChange", this._validateChange);
|
|
54
54
|
}
|
|
55
55
|
setRules(e) {
|
|
56
56
|
const t = { ...e, key: this.name };
|
|
@@ -60,17 +60,18 @@ class $ extends h {
|
|
|
60
60
|
this.error = e;
|
|
61
61
|
}
|
|
62
62
|
render() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
this.required && this.classList.add("is-required"), this.error && this.classList.add("is-error"), this.classList.add(`l-form-item--${this.labelPosition}`);
|
|
64
|
+
const e = document.createDocumentFragment();
|
|
65
|
+
this.label != null && e.appendChild(
|
|
66
|
+
i("label", {
|
|
67
|
+
class: "l-form-item__label",
|
|
68
|
+
textContent: this.label
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
const t = i("div", { class: "l-form-item__content" }), r = i("slot");
|
|
72
|
+
return t.appendChild(r), this.error && t.appendChild(
|
|
73
|
+
i("div", { class: "l-form-item__error", textContent: this.error })
|
|
74
|
+
), e.appendChild(t), e;
|
|
74
75
|
}
|
|
75
76
|
_validateChange = (e, t) => {
|
|
76
77
|
const r = e === !0 ? void 0 : e[this.name];
|
|
@@ -78,28 +79,20 @@ class $ extends h {
|
|
|
78
79
|
};
|
|
79
80
|
_updateError() {
|
|
80
81
|
if (!this.rendered) return;
|
|
81
|
-
let e =
|
|
82
|
+
let e = s(".l-form-item__error", this.root);
|
|
82
83
|
if (e)
|
|
83
84
|
this.error ? e.textContent = this.error : e.remove();
|
|
84
85
|
else if (this.error) {
|
|
85
86
|
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this.error;
|
|
86
|
-
const
|
|
87
|
-
|
|
87
|
+
const t = s(".l-form-item__content", this.root);
|
|
88
|
+
t && t.appendChild(e);
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
-
t && (this.error ? m(t, "is-error") : n(t, "is-error"));
|
|
90
|
+
this.error ? n(this, "is-error") : d(this, "is-error");
|
|
91
91
|
}
|
|
92
92
|
_updateLabel() {
|
|
93
93
|
if (!this.rendered) return;
|
|
94
|
-
let e =
|
|
95
|
-
|
|
96
|
-
if (this.label != null) {
|
|
97
|
-
e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this.label;
|
|
98
|
-
const t = i(".l-form-item", this.root);
|
|
99
|
-
t && t.appendChild(e);
|
|
100
|
-
}
|
|
101
|
-
} else
|
|
102
|
-
this.label != null ? e.textContent = this.label : e.remove();
|
|
94
|
+
let e = s(".l-form-item__label", this.root);
|
|
95
|
+
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();
|
|
103
96
|
}
|
|
104
97
|
_getFormId() {
|
|
105
98
|
let e = this.parentElement, t;
|
|
@@ -116,5 +109,5 @@ class $ extends h {
|
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
111
|
export {
|
|
119
|
-
|
|
112
|
+
I as default
|
|
120
113
|
};
|
package/lib/form/index.js
CHANGED
|
@@ -3,14 +3,14 @@ import m from "../base.js";
|
|
|
3
3
|
import { parseAttrValue as c, initAttr as u } from "../utils/index.js";
|
|
4
4
|
import { random as d } from "ph-utils";
|
|
5
5
|
import { emit as l, add as n, clear as v } from "../utils/event.js";
|
|
6
|
-
import
|
|
7
|
-
const
|
|
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
8
|
class $ extends m {
|
|
9
9
|
static baseName = "form";
|
|
10
10
|
/** 是否行内表单 */
|
|
11
11
|
inline = !1;
|
|
12
12
|
labelPosition = "right";
|
|
13
|
-
labelWidth;
|
|
13
|
+
labelWidth = "80px";
|
|
14
14
|
disabled = !1;
|
|
15
15
|
sharedAttrs = ["disabled", "id", "innerBlock"];
|
|
16
16
|
validator;
|
|
@@ -18,7 +18,7 @@ class $ extends m {
|
|
|
18
18
|
novalidate = !1;
|
|
19
19
|
_data;
|
|
20
20
|
constructor() {
|
|
21
|
-
super(), this.validator = new
|
|
21
|
+
super(), this.validator = new p([]);
|
|
22
22
|
}
|
|
23
23
|
static get observedAttributes() {
|
|
24
24
|
return ["disabled", "label-position"];
|
|
@@ -37,7 +37,7 @@ class $ extends m {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
connectedCallback() {
|
|
40
|
-
u(this), this.id
|
|
40
|
+
u(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(), n(this.id, "ruleChange", this.ruleChange), n(this.id, "valueChange", this._valueChange);
|
|
41
41
|
}
|
|
42
42
|
disconnectedCallback() {
|
|
43
43
|
v(this.id), this.validator = void 0;
|
package/lib/index.d.ts
CHANGED
|
@@ -32,8 +32,10 @@ export { default as WarnIcon } from "./icon/warn";
|
|
|
32
32
|
export { default as CloseFilledIcon } from "./icon/close_filled";
|
|
33
33
|
export { default as Form } from "./form";
|
|
34
34
|
export { default as FormItem } from "./form/form_item";
|
|
35
|
-
export { default as
|
|
36
|
-
export { default as
|
|
35
|
+
export { default as RadioGroup } from "./check/radio_group";
|
|
36
|
+
export { default as Radio } from "./check/radio";
|
|
37
|
+
export { default as Checkbox } from "./check/checkbox";
|
|
38
|
+
export { default as CheckboxGroup } from "./check/checkbox_group";
|
|
37
39
|
export { default as Button } from "./button";
|
|
38
40
|
export { default as Input } from "./input";
|
|
39
41
|
export { default as SelectOri } from "./select_ori";
|
|
@@ -49,6 +51,8 @@ export { default as DatePicker } from "./date_picker";
|
|
|
49
51
|
export { default as Menu } from "./menu";
|
|
50
52
|
export { default as MenuItem } from "./menu/menu_item";
|
|
51
53
|
export { default as SubMenu } from "./menu/sub_menu";
|
|
54
|
+
export { default as Carousel } from "./carousel";
|
|
55
|
+
export { default as CarouselItem } from "./carousel/item";
|
|
52
56
|
|
|
53
57
|
declare global {
|
|
54
58
|
interface HTMLElementTagNameMap {
|
|
@@ -83,8 +87,10 @@ declare global {
|
|
|
83
87
|
"l-close-filled-icon": import("./icon/close_filled").default
|
|
84
88
|
"l-form": import("./form").default
|
|
85
89
|
"l-form-item": import("./form/form_item").default
|
|
86
|
-
"l-radio": import("./
|
|
87
|
-
"l-
|
|
90
|
+
"l-radio-group": import("./check/radio_group").default
|
|
91
|
+
"l-radio": import("./check/radio").default
|
|
92
|
+
"l-checkbox": import("./check/checkbox").default
|
|
93
|
+
"l-checkbox-group": import("./check/checkbox_group").default
|
|
88
94
|
"l-button": import("./button").default
|
|
89
95
|
"l-input": import("./input").default
|
|
90
96
|
"l-select-ori": import("./select_ori").default
|
|
@@ -100,5 +106,7 @@ declare global {
|
|
|
100
106
|
"l-menu": import("./menu").default
|
|
101
107
|
"l-menu-item": import("./menu/menu_item").default
|
|
102
108
|
"l-sub-menu": import("./menu/sub_menu").default
|
|
109
|
+
"l-carousel": import("./carousel").default
|
|
110
|
+
"l-carousel-item": import("./carousel/item").default
|
|
103
111
|
}
|
|
104
112
|
}
|