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.
Files changed (51) hide show
  1. package/lib/base.d.ts +1 -1
  2. package/lib/base.js +3 -3
  3. package/lib/button/index.d.ts +4 -1
  4. package/lib/button/index.js +28 -13
  5. package/lib/carousel/index.d.ts +20 -0
  6. package/lib/carousel/index.js +280 -0
  7. package/lib/carousel/item.d.ts +6 -0
  8. package/lib/carousel/item.js +15 -0
  9. package/lib/carousel/timer.d.ts +5 -0
  10. package/lib/carousel/timer.js +19 -0
  11. package/lib/check/check.d.ts +22 -0
  12. package/lib/check/check.js +81 -0
  13. package/lib/check/checkbox.d.ts +7 -0
  14. package/lib/check/checkbox.js +25 -0
  15. package/lib/check/checkbox_group.d.ts +9 -0
  16. package/lib/check/checkbox_group.js +33 -0
  17. package/lib/check/index.d.ts +12 -0
  18. package/lib/check/index.js +35 -0
  19. package/lib/check/radio.d.ts +6 -0
  20. package/lib/check/radio.js +19 -0
  21. package/lib/check/radio_group.d.ts +6 -0
  22. package/lib/check/radio_group.js +24 -0
  23. package/lib/check-BlDsQQo0.js +4 -0
  24. package/lib/color_picker/index.d.ts +1 -1
  25. package/lib/color_picker/index.js +5 -5
  26. package/lib/form/form_inner.d.ts +1 -8
  27. package/lib/form/form_inner.js +31 -39
  28. package/lib/form/form_item.d.ts +1 -1
  29. package/lib/form/form_item.js +30 -37
  30. package/lib/form/index.js +5 -5
  31. package/lib/icon/close_filled.d.ts +1 -1
  32. package/lib/index.d.ts +12 -4
  33. package/lib/index.js +80 -72
  34. package/lib/input/index.js +10 -10
  35. package/lib/list/index.d.ts +1 -2
  36. package/lib/list/index.js +17 -17
  37. package/lib/md_input/index.js +9 -9
  38. package/lib/menu/index.d.ts +2 -0
  39. package/lib/menu/index.js +47 -42
  40. package/lib/menu/sub_menu.d.ts +4 -2
  41. package/lib/menu/sub_menu.js +59 -41
  42. package/lib/select_ori/index.d.ts +1 -1
  43. package/lib/select_ori/index.js +1 -1
  44. package/lib/utils/index.d.ts +1 -1
  45. package/lib/utils/index.js +49 -49
  46. package/lib/utils/transition.js +3 -2
  47. package/package.json +1 -1
  48. package/lib/checkbox/index.d.ts +0 -17
  49. package/lib/checkbox/index.js +0 -135
  50. package/lib/radio/index.d.ts +0 -28
  51. package/lib/radio/index.js +0 -122
@@ -1,64 +1,82 @@
1
- import { addClass as r, removeClass as a, $one as i, on as p, off as d, queryHideNodeSize as h, $$ as l } from "ph-utils/dom";
2
- import u from "../base.js";
3
- import { initAttr as m, parseAttrValue as b } from "../utils/index.js";
4
- const g = ":host{display:block;width:100%;overflow:hidden}.l-submenu-title{display:flex;align-items:center;padding:0 10px 0 calc(10px + var(--l-menu-level) * 15px);height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;position:relative;overflow:hidden;text-overflow:ellipsis;border-right:2px solid transparent;transition:color .3s,background-color .3s,border-color .3s}.l-submenu-title:hover{background-color:var(--l-primary-color-light5)}.l-menu{--l-menu-level: 1;display:block;width:var(--l-menu-width);height:var(--l-menu-height);font-size:14px;position:relative;color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;transition:height .3s,width .3s;overflow:hidden;border-right:1px solid var(--l-border-color, #dedede)}.l-menu-icon-wrap{display:inline-flex;font-size:14px;margin-right:5px}.l-submenu-arrow-icon{position:absolute;top:50%;right:10px;transition:transform .3s;transform:translate3d(0,-50%,0) rotate(90deg);color:var(--l-info-color)}:host(.collapse) .l-submenu-arrow-icon{transform:translate3d(0,-50%,0) rotate(0)}.l-menu--collapse{display:none}";
5
- class y extends u {
1
+ import { addClass as r, $one as a, on as h, off as p, removeClass as d, queryHideNodeSize as u, toggleClass as m, $$ as n } from "ph-utils/dom";
2
+ import g from "../base.js";
3
+ import { initAttr as f, parseAttrValue as c } from "../utils/index.js";
4
+ const v = ":host{display:block;width:100%;overflow:hidden}.l-submenu-title{display:flex;align-items:center;padding:0 10px 0 calc(10px + var(--l-menu-level) * 15px);height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;position:relative;overflow:hidden;text-overflow:ellipsis;border-right:2px solid transparent;transition:color .3s,background-color .3s,border-color .3s}.l-submenu-title:hover{background-color:var(--l-primary-color-light5)}.l-menu{--l-menu-level: 1;display:block;width:var(--l-menu-width);height:var(--l-menu-height);font-size:14px;position:relative;color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;transition:height .3s,width .3s;overflow:hidden;border-right:1px solid var(--l-border-color, #dedede)}.l-menu-icon-wrap{display:inline-flex;font-size:14px;margin-right:5px}.l-submenu-arrow-icon{position:absolute;top:50%;right:10px;transition:transform .3s;transform:translate3d(0,-50%,0) rotate(90deg);color:var(--l-info-color)}:host(.collapsed) .l-submenu-arrow-icon{transform:translate3d(0,-50%,0) rotate(0)}.l-menu--collapsed{display:none}:host(.is-active) .l-submenu-title{color:var(--l-primary-color)}";
5
+ class C extends g {
6
6
  static baseName = "sub-menu";
7
7
  /** 默认折叠子菜单 */
8
- collapse = !0;
8
+ expanded = !1;
9
+ /** 是否激活状态, 通常是下面的子菜单项被选中 */
10
+ active = !1;
11
+ #e;
9
12
  connectedCallback() {
10
- this.loadStyleText(g), m(this), this.collapse ? r(this, "collapse") : a(this, "collapse"), super.connectedCallback();
13
+ this.loadStyleText(v), f(this), this.expanded || r(this, "collapsed"), this.active && r(this, "is-active"), super.connectedCallback();
11
14
  }
12
15
  afterInit() {
13
- const e = i(".l-menu", this.root);
14
- p(e, "transitionend", this.#e);
16
+ const e = a(".l-menu", this.root);
17
+ h(e, "transitionend", this.#t);
15
18
  }
16
19
  beforeDestroy() {
17
- const e = i(".l-menu", this.root);
18
- d(e, "transitionend", this.#e);
20
+ const e = a(".l-menu", this.root);
21
+ p(e, "transitionend", this.#t), this.#e && clearTimeout(this.#e);
19
22
  }
20
23
  static get observedAttributes() {
21
- return ["collapse"];
24
+ return ["expanded", "active"];
22
25
  }
23
- attributeChangedCallback(e, t, c) {
24
- if (this.rendered && e === "collapse") {
25
- const s = b(c, !0, "collapse");
26
- if (this.collapse !== s) {
27
- this.collapse = s;
28
- const o = i(".l-menu", this.root);
29
- if (this.collapse)
30
- r(this, "collapse"), o.style.height = "0";
31
- else {
32
- a(this, "collapse");
33
- const n = h(o, null);
34
- o.style.height = "0", a(o, "l-menu--collapse"), requestAnimationFrame(() => {
35
- o.style.height = `${n.height}px`;
36
- });
26
+ attributeChangedCallback(e, i, l) {
27
+ if (this.rendered) {
28
+ if (e === "expanded") {
29
+ const o = c(l, !1, "expanded");
30
+ if (this.expanded !== o) {
31
+ this.expanded = o;
32
+ const t = a(".l-menu", this.root);
33
+ if (this.expanded) {
34
+ d(this, "collapsed");
35
+ const s = u(t, null);
36
+ t.style.height = "0", d(t, "l-menu--collapsed"), requestAnimationFrame(() => {
37
+ t.style.height = `${s.height}px`;
38
+ });
39
+ } else {
40
+ const s = t.getBoundingClientRect();
41
+ t.style.height = `${s.height}px`, r(this, "collapsed"), requestAnimationFrame(() => {
42
+ t.style.height = "0";
43
+ });
44
+ }
45
+ this.#e = setTimeout(() => {
46
+ this.#t({
47
+ target: t,
48
+ propertyName: "height"
49
+ });
50
+ }, 350);
37
51
  }
52
+ } else if (e === "active") {
53
+ const o = c(l, !1, "active");
54
+ o !== this.active && (this.active = o, m(this, "is-active"));
38
55
  }
39
56
  }
40
57
  }
41
58
  render() {
42
- const e = document.createDocumentFragment(), t = l("div", { class: "l-submenu-title" });
43
- if (i('[slot="icon"]', this)) {
44
- const n = l("span", { class: "l-menu-icon-wrap" });
45
- n.appendChild(l("slot", { name: "icon" })), t.appendChild(n);
59
+ const e = document.createDocumentFragment(), i = n("div", { class: "l-submenu-title" });
60
+ if (a('[slot="icon"]', this)) {
61
+ const s = n("span", { class: "l-menu-icon-wrap" });
62
+ s.appendChild(n("slot", { name: "icon" })), i.appendChild(s);
46
63
  }
47
- t.appendChild(l("slot", { name: "title" }));
48
- const s = l("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
49
- t.appendChild(s), e.appendChild(t);
50
- const o = l("div", {
51
- class: ["l-menu", this.collapse ? "l-menu--collapse" : void 0]
64
+ i.appendChild(n("slot", { name: "title" }));
65
+ const o = n("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
66
+ i.appendChild(o), e.appendChild(i);
67
+ const t = n("div", {
68
+ class: ["l-menu", this.expanded ? void 0 : "l-menu--collapsed"]
52
69
  });
53
- return o.appendChild(l("slot")), e.appendChild(o), e;
70
+ return t.appendChild(n("slot")), e.appendChild(t), e;
54
71
  }
55
- #e = (e) => {
56
- if (this.collapse) {
57
- const t = e.target;
58
- t.style.removeProperty("height"), r(t, "l-menu--collapse");
72
+ #t = (e) => {
73
+ if (!this.expanded && e.propertyName === "height") {
74
+ this.#e && clearTimeout(this.#e);
75
+ const i = e.target;
76
+ i.style.removeProperty("height"), r(i, "l-menu--collapsed");
59
77
  }
60
78
  };
61
79
  }
62
80
  export {
63
- y as default
81
+ C as default
64
82
  };
@@ -9,7 +9,7 @@ export default class SelectOri extends FormInner {
9
9
  connectedCallback(): void;
10
10
  disconnectedCallback(): void;
11
11
  render(): string;
12
- protected _changeDisabled(): void;
12
+ protected disabledChange(): void;
13
13
  setOptions(options: Option[]): void;
14
14
  appendOptions(options: Option[]): void;
15
15
  reset(): void;
@@ -18,7 +18,7 @@ class g extends n {
18
18
  ["disabled", this.isDisabled()]
19
19
  ])}>${e}</select>`;
20
20
  }
21
- _changeDisabled() {
21
+ disabledChange() {
22
22
  this.$select && (this.$select.disabled = this.isDisabled());
23
23
  }
24
24
  setOptions(e) {
@@ -12,7 +12,7 @@ export declare function regist(component: any | any[], name?: string): void;
12
12
  export declare function useId(): string;
13
13
  export declare function parseAttrValue(value: string, defaultValue?: string): string;
14
14
  export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
15
- export declare function parseAttrValue(value: string, defaultValue?: number, key?: string): number;
15
+ export declare function parseAttrValue(value: string, defaultValue?: number): number;
16
16
  /**
17
17
  * 初始化元素的属性值。
18
18
  * 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。
@@ -1,14 +1,14 @@
1
1
  import { isBlank as N } from "ph-utils";
2
- import { $ as x, iterate as $, transition as y } from "ph-utils/dom";
2
+ import { $, iterate as x, transition as y } from "ph-utils/dom";
3
3
  let E = -1;
4
- function H(t, r) {
4
+ function j(t, r) {
5
5
  const e = Array.isArray(t) ? t : [t];
6
6
  for (const i of e) {
7
- const n = r || `l-${i.baseName}`;
8
- customElements.get(n) || customElements.define(n, i);
7
+ const s = r || `l-${i.baseName}`;
8
+ customElements.get(s) || customElements.define(s, i);
9
9
  }
10
10
  }
11
- function _() {
11
+ function H() {
12
12
  return `l-${++E}`;
13
13
  }
14
14
  function I(t, r, e) {
@@ -25,92 +25,92 @@ function I(t, r, e) {
25
25
  function k(t) {
26
26
  const r = t.attributes;
27
27
  for (const e of r) {
28
- const { name: i, value: n } = e;
28
+ const { name: i, value: s } = e;
29
29
  if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$") || ["id", "class", "style"].includes(i))
30
30
  continue;
31
- const s = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), u = I(n, t[s], i), f = Object.getOwnPropertyNames(t);
32
- (t._ignoreInitAttrs || []).includes(s) || (i === "value" ? (t[s] = u, t._resetValue = u) : f.includes(s) && (t[s] = u));
31
+ const n = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), f = I(s, t[n], i), u = Object.getOwnPropertyNames(t);
32
+ (t._ignoreInitAttrs || []).includes(n) || (i === "value" ? (t[n] = f, t._resetValue = f) : (u.includes(n) || u.includes(`_${n}`)) && (t[n] = f));
33
33
  }
34
34
  }
35
35
  function W(t, r) {
36
36
  let e = " ";
37
37
  return r === !0 ? e = ` ${t}` : typeof r == "string" && !N(r) && (e = ` ${t}="${r}"`), e;
38
38
  }
39
- function C(t) {
39
+ function l(t) {
40
40
  return t.map((e) => W(e[0], e[1])).join("");
41
41
  }
42
- function V(t, r) {
42
+ function C(t, r) {
43
43
  for (const e of r) {
44
- const i = e[1], n = e[0];
45
- i === !0 ? t.setAttribute(n, "") : typeof i == "string" && !N(i) && t.setAttribute(n, i);
44
+ const i = e[1], s = e[0];
45
+ i === !0 ? t.setAttribute(s, "") : typeof i == "string" && !N(i) && t.setAttribute(s, i);
46
46
  }
47
47
  }
48
- function l() {
48
+ function V() {
49
49
  let t;
50
50
  const r = {
51
51
  attributes: !0,
52
52
  attributeFilter: ["l-transition-emit"]
53
- }, e = (s) => {
54
- for (let u of s)
55
- if (u.type === "attributes" && u.attributeName) {
56
- const f = u.target, c = f.getAttribute(u.attributeName) || "show", d = f.getAttribute("l-transition") || "l", h = f.getAttribute("l-transition-method") || "hide";
57
- c === "show" ? (f.style.removeProperty("display"), y(f, d, "enter")) : y(f, d, "leave", () => {
58
- h === "remove" ? f.remove() : f.style.display = "none";
53
+ }, e = (n) => {
54
+ for (let f of n)
55
+ if (f.type === "attributes" && f.attributeName) {
56
+ const u = f.target, c = u.getAttribute(f.attributeName) || "show", d = u.getAttribute("l-transition") || "l", h = u.getAttribute("l-transition-method") || "hide";
57
+ c === "show" ? (u.style.removeProperty("display"), y(u, d, "enter")) : y(u, d, "leave", () => {
58
+ h === "remove" ? u.remove() : u.style.display = "none";
59
59
  });
60
60
  }
61
61
  };
62
- function i(s) {
63
- s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (u) => {
64
- const f = u.getAttribute("l-transition");
65
- f && (y(u, f, "enter"), t.observe(u, r));
62
+ function i(n) {
63
+ n && n.length > 0 && (t == null && (t = new MutationObserver(e)), x(n, (f) => {
64
+ const u = f.getAttribute("l-transition");
65
+ u && (y(f, u, "enter"), t.observe(f, r));
66
66
  }));
67
67
  }
68
- function n(s) {
69
- s == null && (s = x("[l-transition]"), i(s));
68
+ function s(n) {
69
+ n == null && (n = $("[l-transition]"), i(n));
70
70
  }
71
71
  function o() {
72
72
  t && (t.disconnect(), t = void 0);
73
73
  }
74
- return { destroy: o, add: i, init: n };
74
+ return { destroy: o, add: i, init: s };
75
75
  }
76
- function m(t, r, e, i, n = 10) {
76
+ function m(t, r, e, i, s = 10) {
77
77
  let o = 0;
78
- return e === "top" ? o = r.height + n : e === "bottom" ? o = -(t.height + n) : (e === "left" || e === "right") && (i === "" ? o = r.height / 2 - t.height / 2 : i === "end" && (o = r.height - t.height)), o;
78
+ return e === "top" ? o = r.height + s : e === "bottom" ? o = -(t.height + s) : (e === "left" || e === "right") && (i === "" ? o = r.height / 2 - t.height / 2 : i === "end" && (o = r.height - t.height)), o;
79
79
  }
80
- function w(t, r, e, i, n = 10) {
80
+ function w(t, r, e, i, s = 10) {
81
81
  let o = 0;
82
- return e === "left" ? o = r.width + n : e === "right" ? o = -(t.width + n) : (e === "top" || e === "bottom") && (i === "" ? o = r.width / 2 - t.width / 2 : i === "end" && (o = r.width - t.width)), o;
82
+ return e === "left" ? o = r.width + s : e === "right" ? o = -(t.width + s) : (e === "top" || e === "bottom") && (i === "" ? o = r.width / 2 - t.width / 2 : i === "end" && (o = r.width - t.width)), o;
83
83
  }
84
- function v(t, r, e, i, n, o, s, u, f = 10, c = "absolute") {
85
- const d = window.innerHeight + o - 10, h = window.innerWidth + n - 10;
86
- let a = t.top + o - u;
87
- a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", u = m(
84
+ function v(t, r, e, i, s, o, n, f, u = 10, c = "absolute") {
85
+ const d = window.innerHeight + o - 10, h = window.innerWidth + s - 10;
86
+ let a = t.top + o - f;
87
+ a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", f = m(
88
88
  t,
89
89
  r,
90
90
  e,
91
91
  i,
92
- f
93
- ), a = t.top + o - u), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
94
- let b = t.left + n - s;
95
- return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = w(
92
+ u
93
+ ), a = t.top + o - f), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
94
+ let b = t.left + s - n;
95
+ return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", n = w(
96
96
  t,
97
97
  r,
98
98
  e,
99
99
  i,
100
- f
101
- ), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (u = m(
100
+ u
101
+ ), b = t.left + s - n), b < s && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (f = m(
102
102
  t,
103
103
  r,
104
104
  e,
105
105
  i,
106
- f
107
- ), s = w(
106
+ u
107
+ ), n = w(
108
108
  t,
109
109
  r,
110
110
  e,
111
111
  i,
112
- f
113
- ), b = t.left + n - s, a = t.top + o - u), {
112
+ u
113
+ ), b = t.left + s - n, a = t.top + o - f), {
114
114
  x: b,
115
115
  y: a,
116
116
  mainAlign: e,
@@ -118,15 +118,15 @@ function v(t, r, e, i, n, o, s, u, f = 10, c = "absolute") {
118
118
  };
119
119
  }
120
120
  export {
121
- l as createTransition,
121
+ V as createTransition,
122
122
  w as getPopoverOffsetX,
123
123
  m as getPopoverOffsetY,
124
124
  v as impactDetect,
125
125
  k as initAttr,
126
126
  I as parseAttrValue,
127
- H as regist,
128
- V as setAttrs,
127
+ j as regist,
128
+ C as setAttrs,
129
129
  W as tagAttr,
130
- C as tagAttrs,
131
- _ as useId
130
+ l as tagAttrs,
131
+ H as useId
132
132
  };
@@ -7,7 +7,8 @@ import "ph-utils/validator";
7
7
  import "ph-utils/color";
8
8
  import "ph-utils/theme";
9
9
  import "ph-utils/date";
10
- class S extends a {
10
+ import "ph-utils/web";
11
+ class _ extends a {
11
12
  static baseName = "transition";
12
13
  /** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
13
14
  sheetRec;
@@ -50,5 +51,5 @@ class S extends a {
50
51
  }
51
52
  }
52
53
  export {
53
- S as Transition
54
+ _ as Transition
54
55
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.13.0",
4
+ "version": "0.14.1",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
7
  "@eslint/js": "^9.25.0",
@@ -1,17 +0,0 @@
1
- import FormInner from "../form/form_inner";
2
- export default class Checkbox extends FormInner {
3
- #private;
4
- static baseName: string;
5
- type?: "button";
6
- checked: boolean;
7
- label?: string;
8
- indeterminate: boolean;
9
- _ignoreInitAttrs: string[];
10
- constructor();
11
- connectedCallback(): void;
12
- disconnectedCallback(): void;
13
- static get observedAttributes(): string[];
14
- protected attributeChange(name: string, oldValue: string, newValue: string): void;
15
- render(): DocumentFragment;
16
- setValue(value: boolean | string[]): void;
17
- }
@@ -1,135 +0,0 @@
1
- import { initAttr as f, parseAttrValue as m } from "../utils/index.js";
2
- import v from "../form/form_inner.js";
3
- import { random as x, isBlank as _ } from "ph-utils";
4
- import { $one as i, addClass as a, removeClass as s, $ as n, iterate as h, getAttr as d, $$ as b, on as g, off as C } from "ph-utils/dom";
5
- const $ = ':host{--l-checkbox-size: 16px;--l-checkbox-label-color: #333;--l-checkbox-checked-color: var(--l-primary-color, #722ed1);--l-checkbox-disabled-color: #e6e6e6;--l-checkbox-disabled-label-color: #c0c4cc;--l-checkbox-item-margin: 10px;display:inline-flex;align-items:center}.l-checkbox{display:inline-flex;align-items:center;cursor:pointer}.l-checkbox__input{opacity:0;width:0;height:0;position:absolute;z-index:-1}.l-checkbox__label{color:var(--l-checkbox-label-color);transition:color .3s ease-in-out;margin-left:5px;line-height:1}.l-checkbox__inner{width:var(--l-checkbox-size);height:var(--l-checkbox-size);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:all .3s ease-in-out;position:relative}.l-checkbox__inner:after{content:"";width:calc(var(--l-checkbox-size) * .6);height:calc(var(--l-checkbox-size) * .3);display:block;border:solid 1px transparent;border-right:none;border-top:none;transform:rotate(-45deg);transition:border-color .2s ease-in-out;margin-top:-3px}.l-checkbox--indeterminate .l-checkbox__inner{background-color:var(--l-checkbox-checked-color)}.l-checkbox--indeterminate .l-checkbox__inner:before{content:"";width:calc(var(--l-checkbox-size) * .4);height:1px;display:block;border:solid 1px #fff;border-right:none;border-top:none;border-left:none;position:absolute}.l-checkbox:hover .l-checkbox__inner{border-color:var(--l-checkbox-checked-color)}.l-checkbox__input:checked+.l-checkbox__inner{background-color:var(--l-checkbox-checked-color)}.l-checkbox__input:checked+.l-checkbox__inner:after{border-color:#fff}.l-checkbox__input:checked~.l-checkbox__label{color:var(--l-checkbox-checked-color)}.l-checkbox--disabled{--l-checkbox-checked-color: var(--l-checkbox-disabled-color);cursor:not-allowed}.l-checkbox--disabled .l-checkbox__inner{border-color:var(--l-checkbox-disabled-color)}.l-checkbox--disabled .l-checkbox__inner:after{border-color:transparent}.l-checkbox--disabled .l-checkbox__label{color:var(--l-checkbox-disabled-label-color)}.l-checkbox+.l-checkbox{margin-left:var(--l-checkbox-item-margin)}.l-checkbox--button .l-checkbox__label{display:inline-flex;height:var(--l-form-edit-height, 32px);justify-content:center;align-items:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0}.l-checkbox--button:first-child .l-checkbox__label{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.l-checkbox--button:last-child .l-checkbox__label{border-top-right-radius:3px;border-bottom-right-radius:3px}.l-checkbox--button .l-checkbox__input:checked~.l-checkbox__label{background-color:var(--l-checkbox-checked-color);color:#fff;border-top-color:var(--l-checkbox-checked-color);border-bottom-color:var(--l-checkbox-checked-color);border-right-color:#fff}';
6
- class N extends v {
7
- static baseName = "checkbox";
8
- type;
9
- checked = !1;
10
- label;
11
- indeterminate = !1;
12
- _ignoreInitAttrs = ["value"];
13
- constructor() {
14
- super(!1);
15
- }
16
- connectedCallback() {
17
- f(this), this.loadStyleText($), this.getName() || (this.name = `la${x(3)}_${x(6)}`), super.connectedCallback(), this.#o();
18
- }
19
- disconnectedCallback() {
20
- super.disconnectedCallback(), this.#t();
21
- }
22
- static get observedAttributes() {
23
- return ["disabled", "value", "indeterminate"];
24
- }
25
- attributeChange(e, c, l) {
26
- if (e === "indeterminate") {
27
- this.indeterminate = m(l, !1);
28
- const o = i("label[l-value]", this.root);
29
- o && (this.indeterminate ? a(o, "l-checkbox--indeterminate") : s(o, "l-checkbox--indeterminate"));
30
- } else if (e === "value") {
31
- const o = l.split("&").map((t) => decodeURIComponent(t));
32
- this.setValue(o);
33
- }
34
- }
35
- render() {
36
- const e = document.createDocumentFragment(), c = i('[slot="label"]', this), l = n("[check-value]", this);
37
- return c || this.label ? (this.value = this.checked, c ? e.appendChild(
38
- this.#e("slot", void 0, this.checked, "label")
39
- ) : e.appendChild(
40
- this.#e(
41
- this.label,
42
- void 0,
43
- this.checked,
44
- "label"
45
- )
46
- )) : l.length > 0 && (this.#l(), h(l, (o) => {
47
- const t = o.cloneNode(!0), r = d(o, "check-value");
48
- e.appendChild(
49
- this.#e(
50
- t.outerHTML,
51
- r,
52
- this.value.includes(r)
53
- )
54
- );
55
- })), e;
56
- }
57
- #e(e, c, l = !1, o = void 0) {
58
- const t = b("label", {
59
- class: {
60
- "l-checkbox": !0,
61
- "l-checkbox--button": this.type === "button",
62
- "is-checked": l,
63
- "l-checkbox--disabled": this.isDisabled(),
64
- "l-checkbox--indeterminate": this.indeterminate
65
- },
66
- "l-value": c
67
- }), r = b("input", {
68
- class: "l-checkbox__input",
69
- type: "checkbox",
70
- name: this.getName(),
71
- value: c,
72
- checked: l,
73
- disabled: this.isDisabled()
74
- });
75
- if (t.appendChild(r), this.type !== "button") {
76
- const u = b("span", {
77
- class: "l-checkbox__inner"
78
- });
79
- t.appendChild(u);
80
- }
81
- let p = e === "slot" ? '<slot name="label"></slot>' : e;
82
- const k = b("div", {
83
- class: "l-checkbox__label",
84
- part: o
85
- });
86
- return k.innerHTML = p, t.appendChild(k), t;
87
- }
88
- setValue(e) {
89
- if (super.setValue(e), typeof e == "boolean") {
90
- const c = i("label", this.root);
91
- c && (this.checked ? a(c, "is-checked") : s(c, "is-checked"));
92
- } else {
93
- const c = n("label[l-value]", this.root);
94
- h(c, (l) => {
95
- const o = d(l, "l-value");
96
- e.includes(o) ? a(l, "is-checked") : s(l, "is-checked");
97
- });
98
- }
99
- }
100
- #l() {
101
- const e = d(this, "value");
102
- let c = [];
103
- this.hasAttribute("checked") && (c = this.checked), _(e) || (c = e.split("&").map((l) => decodeURIComponent(l))), this._resetValue = c, this.value = c;
104
- }
105
- #c = (e) => {
106
- const c = e.target;
107
- let l;
108
- if (typeof this.value == "boolean")
109
- this.value = c.checked, l = i("label", this.root);
110
- else {
111
- const o = c.value;
112
- if (c.checked)
113
- this.value.push(o);
114
- else {
115
- const t = this.value.indexOf(o);
116
- t > -1 && this.value.splice(t, t);
117
- }
118
- this.pushValueChange(), l = i(`label[l-value="${o}"]`, this.root);
119
- }
120
- l && (c.checked ? a(l, "is-checked") : s(l, "is-checked"));
121
- };
122
- #o() {
123
- h(n("input", this.root), (e) => {
124
- g(e, "change", this.#c);
125
- });
126
- }
127
- #t() {
128
- h(n("input", this.root), (e) => {
129
- C(e, "change", this.#c);
130
- });
131
- }
132
- }
133
- export {
134
- N as default
135
- };
@@ -1,28 +0,0 @@
1
- import FormInner from "../form/form_inner";
2
- type RadioItem = {
3
- value: string;
4
- label: string;
5
- /** 允许通过 part 修改样式 */
6
- labelPart?: string;
7
- };
8
- export default class Radio extends FormInner {
9
- static baseName: string;
10
- type?: "button";
11
- label?: string;
12
- checked: boolean;
13
- private _ignoreInitAttrs;
14
- setItems(items: RadioItem[]): void;
15
- constructor();
16
- connectedCallback(): void;
17
- disconnectedCallback(): void;
18
- protected attributeChange(name: string, oldValue: string, newValue: string): void;
19
- render(): string;
20
- setValue(value: any): void;
21
- private _renderItems;
22
- private _renderItem;
23
- private _isChecked;
24
- private _initEvents;
25
- private _removeEvents;
26
- private _radioChange;
27
- }
28
- export {};