litos-ui 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/lib/base.d.ts +1 -1
  2. package/lib/base.js +3 -3
  3. package/lib/carousel/index.d.ts +20 -0
  4. package/lib/carousel/index.js +280 -0
  5. package/lib/carousel/item.d.ts +6 -0
  6. package/lib/carousel/item.js +15 -0
  7. package/lib/carousel/timer.d.ts +5 -0
  8. package/lib/carousel/timer.js +19 -0
  9. package/lib/check/check.d.ts +22 -0
  10. package/lib/check/check.js +81 -0
  11. package/lib/check/checkbox.d.ts +7 -0
  12. package/lib/check/checkbox.js +25 -0
  13. package/lib/check/checkbox_group.d.ts +9 -0
  14. package/lib/check/checkbox_group.js +33 -0
  15. package/lib/check/index.d.ts +12 -0
  16. package/lib/check/index.js +35 -0
  17. package/lib/check/radio.d.ts +6 -0
  18. package/lib/check/radio.js +19 -0
  19. package/lib/check/radio_group.d.ts +6 -0
  20. package/lib/check/radio_group.js +24 -0
  21. package/lib/check-BlDsQQo0.js +4 -0
  22. package/lib/color_picker/index.d.ts +1 -1
  23. package/lib/color_picker/index.js +5 -5
  24. package/lib/form/form_inner.d.ts +1 -8
  25. package/lib/form/form_inner.js +31 -39
  26. package/lib/form/form_item.d.ts +1 -1
  27. package/lib/form/form_item.js +30 -37
  28. package/lib/form/index.js +5 -5
  29. package/lib/icon/close_filled.d.ts +1 -1
  30. package/lib/index.d.ts +12 -4
  31. package/lib/index.js +80 -72
  32. package/lib/input/index.js +10 -10
  33. package/lib/list/index.d.ts +1 -2
  34. package/lib/list/index.js +17 -17
  35. package/lib/md_input/index.js +9 -9
  36. package/lib/menu/index.d.ts +2 -0
  37. package/lib/menu/index.js +47 -42
  38. package/lib/menu/sub_menu.d.ts +4 -2
  39. package/lib/menu/sub_menu.js +59 -41
  40. package/lib/select_ori/index.d.ts +1 -1
  41. package/lib/select_ori/index.js +1 -1
  42. package/lib/utils/index.d.ts +1 -1
  43. package/lib/utils/index.js +49 -49
  44. package/lib/utils/transition.js +3 -2
  45. package/package.json +1 -1
  46. package/lib/checkbox/index.d.ts +0 -17
  47. package/lib/checkbox/index.js +0 -135
  48. package/lib/radio/index.d.ts +0 -28
  49. package/lib/radio/index.js +0 -122
@@ -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.0",
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 {};
@@ -1,122 +0,0 @@
1
- import { initAttr as $, parseAttrValue as x, tagAttr as s } from "../utils/index.js";
2
- import y from "../form/form_inner.js";
3
- import { $one as a, hasClass as u, addClass as n, $ as c, iterate as h, getAttr as C, removeClass as b, formatClass as A, on as E, off as I } from "ph-utils/dom";
4
- import { random as p } from "ph-utils";
5
- const w = ':host{display:flex;align-items:center}.l-radio{--l-radio-size: 16px;--l-radio-label-color: #333;--l-radio-disabled-color: #e6e6e6;--l-radio-disabled-label-color: var(--l-disabled-color, #c0c4cc);--l-radio-checked-color: var(--l-primary-color, #722ed1);--l-radio-item-margin: 10px;display:inline-flex;align-items:center;position:relative;cursor:pointer}.l-radio__label{transition:color .3s ease-in-out;margin-left:5px}.l-radio__input{position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-radio__inner{display:flex;justify-content:center;align-items:center;width:var(--l-radio-size);height:var(--l-radio-size);border:1px solid #dcddd9;border-radius:50%;box-sizing:border-box;transition:border-color .3s ease-in-out}.l-radio__inner:before{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}.l-radio.is-checked .l-radio__inner{border-color:var(--l-primary-color, #722ed1)}.l-radio.is-checked .l-radio__inner:before{background-color:var(--l-primary-color, #722ed1)}.l-radio.is-checked .l-radio__label{color:var(--l-primary-color, #722ed1)}.l-radio--disabled{cursor:not-allowed}.l-radio--disabledd .l-radio__inner{border-color:var(--l-radio-disabled-color)}.l-radio--disabled .l-radio__label{color:var(--l-radio-disabled-label-color)}.l-radio:not(:first-child){margin-left:var(--l-radio-item-margin)}.l-radio--button .l-radio__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-radio--button:not(:first-of-type){margin-left:0}.l-radio--button:first-of-type .l-radio__label{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.l-radio--button:last-of-type .l-radio__label{border-top-right-radius:3px;border-bottom-right-radius:3px}.is-checked.l-radio--button .l-radio__label{background-color:var(--l-radio-checked-color);color:#fff;border-color:var(--l-radio-checked-color)}';
6
- class T extends y {
7
- static baseName = "radio";
8
- type;
9
- label;
10
- checked = !1;
11
- _ignoreInitAttrs = [];
12
- setItems(e) {
13
- this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
14
- }
15
- constructor() {
16
- super(!1);
17
- }
18
- connectedCallback() {
19
- $(this), this.loadStyleText(w), super.connectedCallback(), this._initEvents();
20
- }
21
- disconnectedCallback() {
22
- super.disconnectedCallback(), this._removeEvents();
23
- }
24
- attributeChange(e, o, t) {
25
- if (e === "checked") {
26
- const i = x(t, !1, e);
27
- this.checked = i, this.value = i;
28
- const r = a(".l-radio", this.root);
29
- if (r && !u(r, "is-checked")) {
30
- n(r, "is-checked");
31
- const l = a("input", r);
32
- l && (l.checked = !0);
33
- }
34
- }
35
- }
36
- render() {
37
- this.getName() || (this.name = `la${p(3)}_${p(6)}`);
38
- const e = [], o = a('[slot="label"]', this), t = c("[radio-value]", this);
39
- return o != null || this.label ? (this.value = this._isChecked(), o ? e.push(
40
- this._renderItem("slot", void 0, this._isChecked(), "label")
41
- ) : e.push(
42
- this._renderItem(
43
- this.label,
44
- void 0,
45
- this._isChecked(),
46
- "label"
47
- )
48
- )) : t.length > 0 && (h(t, (i) => {
49
- const r = i.cloneNode(!0), l = C(i, "radio-value");
50
- e.push(
51
- this._renderItem(r.outerHTML, l, this.value === l)
52
- );
53
- }), this.pushValueChange()), e.join("");
54
- }
55
- setValue(e) {
56
- super.setValue(e);
57
- let o = "";
58
- typeof e != "boolean" && (o = `[l-value="${e}"]`);
59
- const t = a(".is-checked", this.root);
60
- t && b(t, "is-checked");
61
- const i = a(`label${o}`, this.root);
62
- if (i) {
63
- const r = a("input", i);
64
- typeof e == "boolean" ? (e ? n(i, "is-checked") : b(i, "is-checked"), r.checked = e) : (n(i, "is-checked"), r.checked = !0);
65
- }
66
- }
67
- _renderItems(e) {
68
- const o = [];
69
- for (let t = 0, i = e.length; t < i; t++) {
70
- const r = e[t];
71
- o.push(
72
- this._renderItem(
73
- r.label,
74
- r.value,
75
- this.value === r.value,
76
- r.labelPart
77
- )
78
- );
79
- }
80
- return o.join("");
81
- }
82
- _renderItem(e, o, t = !1, i = void 0) {
83
- const r = A({
84
- "l-radio": !0,
85
- "l-radio--disabled": this.isDisabled(),
86
- "l-radio--button": this.type === "button",
87
- "is-checked": t
88
- }), l = s("disabled", this.isDisabled()), f = s("checked", t), m = s("value", o), _ = `${s("name", this.getName())}${m}${l}${f}`, v = s("part", i), g = s("l-value", o), d = [
89
- `<label class="${r}"${g}>`,
90
- `<input type="radio" class="l-radio__input"${_} />`
91
- ];
92
- this.type !== "button" && d.push('<span class="l-radio__inner"></span>');
93
- let k = e === "slot" ? '<slot name="label"></slot>' : e;
94
- return d.push(
95
- `<div class="l-radio__label"${v}>${k}</div>`
96
- ), d.push("</label>"), d.join("");
97
- }
98
- _isChecked() {
99
- return this.checked;
100
- }
101
- _initEvents() {
102
- h(c("input", this.root), (e) => {
103
- E(e, "change", this._radioChange);
104
- });
105
- }
106
- _removeEvents() {
107
- h(c("input", this.root), (e) => {
108
- I(e, "change", this._radioChange);
109
- });
110
- }
111
- _radioChange = (e) => {
112
- const o = e.target;
113
- let t = o.parentElement;
114
- for (; t != null && !u(t, "l-radio"); )
115
- t = t.parentElement;
116
- const i = a(".is-checked", this.root);
117
- i && b(i, "is-checked"), this.value = o.value, t && n(t, "is-checked"), this.dispatchEvent(new CustomEvent("change"));
118
- };
119
- }
120
- export {
121
- T as default
122
- };