litos-ui 0.8.0 → 0.9.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 (42) hide show
  1. package/lib/base.js +26 -30
  2. package/lib/button/index.js +55 -59
  3. package/lib/color_picker/index.js +17 -21
  4. package/lib/form/form_events.js +15 -17
  5. package/lib/form/form_inner.js +43 -47
  6. package/lib/form/form_item.js +49 -54
  7. package/lib/form/index.js +62 -66
  8. package/lib/icon/arrow_down.js +4 -7
  9. package/lib/icon/arrow_left.js +4 -7
  10. package/lib/icon/arrow_right.js +4 -7
  11. package/lib/icon/arrow_up.js +4 -7
  12. package/lib/icon/base.js +21 -25
  13. package/lib/icon/caret_bottom.js +4 -7
  14. package/lib/icon/caret_top.js +4 -7
  15. package/lib/icon/font_icon.js +13 -17
  16. package/lib/icon/info.js +4 -7
  17. package/lib/icon/loading.js +4 -7
  18. package/lib/icon/mask_close.js +4 -7
  19. package/lib/icon/moon.js +4 -7
  20. package/lib/icon/reduction.js +4 -7
  21. package/lib/icon/refresh_left.js +4 -7
  22. package/lib/icon/refresh_right.js +4 -7
  23. package/lib/icon/search.js +4 -7
  24. package/lib/icon/sort.js +4 -7
  25. package/lib/icon/success.js +4 -7
  26. package/lib/icon/sun.js +4 -7
  27. package/lib/icon/theme_default.js +4 -7
  28. package/lib/icon/warn.js +4 -7
  29. package/lib/input/index.js +66 -71
  30. package/lib/list/index.js +23 -27
  31. package/lib/polygon/index.js +14 -18
  32. package/lib/popconfirm/index.js +11 -14
  33. package/lib/popover/index.js +107 -113
  34. package/lib/radio/index.js +53 -57
  35. package/lib/select_ori/index.js +23 -27
  36. package/lib/switch/index.js +34 -44
  37. package/lib/tabbar/index.js +117 -126
  38. package/lib/theme/index.js +71 -74
  39. package/lib/theme/theme_color.js +17 -27
  40. package/lib/utils/event.js +16 -18
  41. package/lib/utils/transition.js +23 -27
  42. package/package.json +1 -1
@@ -1,59 +1,37 @@
1
- var I = Object.defineProperty;
2
- var T = (r) => {
3
- throw TypeError(r);
4
- };
5
- var N = (r, e, o) => e in r ? I(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o;
6
- var t = (r, e, o) => N(r, typeof e != "symbol" ? e + "" : e, o), A = (r, e, o) => e.has(r) || T("Cannot " + o);
7
- var p = (r, e, o) => (A(r, e, "read from private field"), o ? o.call(r) : e.get(r)), h = (r, e, o) => e.has(r) ? T("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, o);
8
- var d = (r, e, o) => (A(r, e, "access private method"), o);
9
- import j from "../base.js";
10
- import { initAttr as D, useId as X, getPopoverOffsetY as Y, getPopoverOffsetX as q, impactDetect as F } from "../utils/index.js";
11
- import { set as G, remove as J } from "../utils/clickoutside.js";
12
- import { $one as c, $$ as L, on as g, off as b } from "ph-utils/dom";
13
- const K = ':host{width:max-content;position:relative}.l-popover--content{--l-popover-border-color: #e4e4e4;--l-popover-color: #666666;--l-popover-box-shadow: 0 4px 8px rgba(0, 0, 0, .12);--l-popover-background: #ffffff;--l-popover-arrow-size: 8px;--l-popover-offset: 10px;position:absolute;width:max-content;box-shadow:var(--l-popover-box-shadow);background:var(--l-popover-background);border:1px solid var(--l-popover-border-color);border-radius:4px;padding:10px;z-index:30;color:var(--l-popover-color);box-sizing:border-box}.l-popover-tooltip{--l-popover-color: #fff;--l-popover-box-shadow: 4px 4px 8px rgba(0, 0, 0, .3);--l-popover-background: #383838;--l-popover-arrow-size: 6px;border-radius:5px;padding:8px;font-size:12px;line-height:1}.l-popover--arrow{position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);z-index:-1}.l-popover--arrow:before{content:"";position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);transform:rotate3d(0,0,1,45deg);background-color:var(--l-popover-background);border-width:1px;border-style:solid}.l-popover-top,.l-popover-top-start,.l-popover-top-end{bottom:calc(100% + var(--l-popover-offset, 10px))}.l-popover-bottom,.l-popover-bottom-start,.l-popover-bottom-end{top:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top-start,.l-popover-bottom-start{left:0}.l-popover-top-end,.l-popover-bottom-end{right:0}.l-popover-bottom,.l-popover-top{left:50%;transform:translate3d(-50%,0,0)}.l-popover-left-start,.l-popover-left,.l-popover-left-end{right:calc(100% + var(--l-popover-offset, 10px))}.l-popover-left-start,.l-popover-right-start{top:0}.l-popover-left-end,.l-popover-right-end{bottom:0}.l-popover-left,.l-popover-right{top:50%;transform:translate3d(0,-50%,0)}.l-popover-right-start,.l-popover-right,.l-popover-right-end{left:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top .l-popover--arrow,.l-popover-bottom .l-popover--arrow{left:50%;margin-left:-4px}.l-popover-top .l-popover--arrow:before,.l-popover-top-start .l-popover--arrow:before,.l-popover-top-end .l-popover--arrow:before{border-color:transparent var(--l-popover-border-color) var(--l-popover-border-color) transparent}.l-popover-bottom .l-popover--arrow:before,.l-popover-bottom-start .l-popover--arrow:before,.l-popover-bottom-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) transparent transparent var(--l-popover-border-color)}.l-popover-top .l-popover--arrow,.l-popover-top-start .l-popover--arrow,.l-popover-top-end .l-popover--arrow{bottom:calc((var(--l-popover-arrow-size, 8px) / -2) + 1px)}.l-popover-top-start .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow{left:10px}.l-popover-top-end .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{right:10px}.l-popover-bottom .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{top:calc((var(--l-popover-arrow-size, 8px) / -2) - 1px)}.l-popover-left .l-popover--arrow,.l-popover-left-start .l-popover--arrow,.l-popover-left-end .l-popover--arrow{margin-top:-4px;right:-4px}.l-popover-left-start .l-popover--arrow:before,.l-popover-left .l-popover--arrow:before,.l-popover-left-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) var(--l-popover-border-color) transparent transparent}.l-popover-right .l-popover--arrow,.l-popover-right-start .l-popover--arrow,.l-popover-right-end .l-popover--arrow{margin-top:-4px;left:-4px}.l-popover-right-start .l-popover--arrow:before,.l-popover-right .l-popover--arrow:before,.l-popover-right-end .l-popover--arrow:before{border-color:transparent transparent var(--l-popover-border-color) var(--l-popover-border-color)}.l-popover-left .l-popover--arrow,.l-popover-right .l-popover--arrow{top:50%}.l-popover-left-start .l-popover--arrow,.l-popover-right-start .l-popover--arrow{top:10px}.l-popover-left-end .l-popover--arrow,.l-popover-right-end .l-popover--arrow{bottom:10px}';
14
- var l, O, P, S, x, a, n, w, H, E;
15
- class Q extends j {
1
+ import x from "../base.js";
2
+ import { initAttr as k, useId as $, getPopoverOffsetY as C, getPopoverOffsetX as y, impactDetect as z } from "../utils/index.js";
3
+ import { set as T, remove as A } from "../utils/clickoutside.js";
4
+ import { $one as p, $$ as g, on as s, off as i } from "ph-utils/dom";
5
+ const P = ':host{width:max-content;position:relative}.l-popover--content{--l-popover-border-color: #e4e4e4;--l-popover-color: #666666;--l-popover-box-shadow: 0 4px 8px rgba(0, 0, 0, .12);--l-popover-background: #ffffff;--l-popover-arrow-size: 8px;--l-popover-offset: 10px;position:absolute;width:max-content;box-shadow:var(--l-popover-box-shadow);background:var(--l-popover-background);border:1px solid var(--l-popover-border-color);border-radius:4px;padding:10px;z-index:30;color:var(--l-popover-color);box-sizing:border-box}.l-popover-tooltip{--l-popover-color: #fff;--l-popover-box-shadow: 4px 4px 8px rgba(0, 0, 0, .3);--l-popover-background: #383838;--l-popover-arrow-size: 6px;border-radius:5px;padding:8px;font-size:12px;line-height:1}.l-popover--arrow{position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);z-index:-1}.l-popover--arrow:before{content:"";position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);transform:rotate3d(0,0,1,45deg);background-color:var(--l-popover-background);border-width:1px;border-style:solid}.l-popover-top,.l-popover-top-start,.l-popover-top-end{bottom:calc(100% + var(--l-popover-offset, 10px))}.l-popover-bottom,.l-popover-bottom-start,.l-popover-bottom-end{top:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top-start,.l-popover-bottom-start{left:0}.l-popover-top-end,.l-popover-bottom-end{right:0}.l-popover-bottom,.l-popover-top{left:50%;transform:translate3d(-50%,0,0)}.l-popover-left-start,.l-popover-left,.l-popover-left-end{right:calc(100% + var(--l-popover-offset, 10px))}.l-popover-left-start,.l-popover-right-start{top:0}.l-popover-left-end,.l-popover-right-end{bottom:0}.l-popover-left,.l-popover-right{top:50%;transform:translate3d(0,-50%,0)}.l-popover-right-start,.l-popover-right,.l-popover-right-end{left:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top .l-popover--arrow,.l-popover-bottom .l-popover--arrow{left:50%;margin-left:-4px}.l-popover-top .l-popover--arrow:before,.l-popover-top-start .l-popover--arrow:before,.l-popover-top-end .l-popover--arrow:before{border-color:transparent var(--l-popover-border-color) var(--l-popover-border-color) transparent}.l-popover-bottom .l-popover--arrow:before,.l-popover-bottom-start .l-popover--arrow:before,.l-popover-bottom-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) transparent transparent var(--l-popover-border-color)}.l-popover-top .l-popover--arrow,.l-popover-top-start .l-popover--arrow,.l-popover-top-end .l-popover--arrow{bottom:calc((var(--l-popover-arrow-size, 8px) / -2) + 1px)}.l-popover-top-start .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow{left:10px}.l-popover-top-end .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{right:10px}.l-popover-bottom .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{top:calc((var(--l-popover-arrow-size, 8px) / -2) - 1px)}.l-popover-left .l-popover--arrow,.l-popover-left-start .l-popover--arrow,.l-popover-left-end .l-popover--arrow{margin-top:-4px;right:-4px}.l-popover-left-start .l-popover--arrow:before,.l-popover-left .l-popover--arrow:before,.l-popover-left-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) var(--l-popover-border-color) transparent transparent}.l-popover-right .l-popover--arrow,.l-popover-right-start .l-popover--arrow,.l-popover-right-end .l-popover--arrow{margin-top:-4px;left:-4px}.l-popover-right-start .l-popover--arrow:before,.l-popover-right .l-popover--arrow:before,.l-popover-right-end .l-popover--arrow:before{border-color:transparent transparent var(--l-popover-border-color) var(--l-popover-border-color)}.l-popover-left .l-popover--arrow,.l-popover-right .l-popover--arrow{top:50%}.l-popover-left-start .l-popover--arrow,.l-popover-right-start .l-popover--arrow{top:10px}.l-popover-left-end .l-popover--arrow,.l-popover-right-end .l-popover--arrow{bottom:10px}';
6
+ class M extends x {
7
+ static baseName = "popover";
8
+ placement = "top";
9
+ content;
10
+ showArrow = !0;
11
+ trigger = "hover";
12
+ disabled = !1;
13
+ isShow = !1;
14
+ /** 宽度, 'trigger' 表示 popover 的宽度会和它的触发元素一致 */
15
+ width;
16
+ /** 隐藏时销毁 DOM 结构 */
17
+ destroyOnHide = !1;
18
+ /** 浮层偏移量 */
19
+ offset;
20
+ /** 浮层定位方式 */
21
+ position = "absolute";
22
+ theme = "default";
23
+ /**
24
+ * @property inline = false
25
+ */
26
+ _t;
16
27
  constructor() {
17
- super();
18
- h(this, l);
19
- t(this, "placement", "top");
20
- t(this, "content");
21
- t(this, "showArrow", !0);
22
- t(this, "trigger", "hover");
23
- t(this, "disabled", !1);
24
- t(this, "isShow", !1);
25
- /** 宽度, 'trigger' 表示 popover 的宽度会和它的触发元素一致 */
26
- t(this, "width");
27
- /** 隐藏时销毁 DOM 结构 */
28
- t(this, "destroyOnHide", !1);
29
- /** 浮层偏移量 */
30
- t(this, "offset");
31
- /** 浮层定位方式 */
32
- t(this, "position", "absolute");
33
- t(this, "theme", "default");
34
- /**
35
- * @property inline = false
36
- */
37
- t(this, "_t");
38
- h(this, x, (o) => {
39
- o.target.id !== this.id && this.hide();
40
- });
41
- h(this, a, (o) => {
42
- this.show(o.target);
43
- });
44
- h(this, n, () => {
45
- this.hide();
46
- });
47
- h(this, w, (o) => {
48
- this.trigger === "click" ? this.toggle(o.target) : this.trigger === "focus" && this.show(o.target);
49
- });
50
- D(this);
28
+ super(), k(this);
51
29
  }
52
30
  connectedCallback() {
53
- this.loadStyleText(K), d(this, l, O).call(this), super.connectedCallback(), this.renderContent(), d(this, l, P).call(this);
31
+ this.loadStyleText(P), this.#t(), super.connectedCallback(), this.renderContent(), this.#p();
54
32
  }
55
33
  disconnectedCallback() {
56
- super.disconnectedCallback(), d(this, l, S).call(this);
34
+ super.disconnectedCallback(), this.#l();
57
35
  }
58
36
  render() {
59
37
  const o = document.createElement("slot");
@@ -61,39 +39,63 @@ class Q extends j {
61
39
  }
62
40
  renderContent() {
63
41
  if (!this.isShow) return;
64
- let o = c(".l-popover--content", this.root);
42
+ let o = p(".l-popover--content", this.root);
65
43
  if (o) {
66
44
  o.style.removeProperty("display");
67
45
  return;
68
46
  }
69
- if (o = L("div", {
47
+ if (o = g("div", {
70
48
  class: [
71
49
  "l-popover--content",
72
50
  `l-popover-${this.placement}`,
73
51
  this.theme === "default" ? void 0 : `l-popover-${this.theme}`
74
52
  ]
75
53
  }), this.offset && (o.style.cssText = "--l-popover-offset: ${this.offset}px;"), o.part = "content", o.innerHTML = this.contentHTML(), this.showArrow) {
76
- const s = L("div", {
54
+ const r = g("div", {
77
55
  class: "l-popover--arrow"
78
56
  });
79
- o.appendChild(s);
57
+ o.appendChild(r);
80
58
  }
81
- this.trigger === "hover" && (g(o, "mouseenter", p(this, a)), g(o, "mouseleave", p(this, n))), this.root.appendChild(o);
59
+ this.trigger === "hover" && (s(o, "mouseenter", this.#o), s(o, "mouseleave", this.#r)), this.root.appendChild(o);
82
60
  }
83
61
  contentHTML() {
84
62
  return this.content ? `<span>${this.content}</span>` : "<slot></slot>";
85
63
  }
64
+ #t() {
65
+ const o = this.getAttr("inline", !1);
66
+ this.style.display = o ? "inline-block" : "block", this.id || (this.id = `${$()}-popover`);
67
+ }
86
68
  hideContent() {
87
- const o = c(".l-popover--content", this.root);
88
- o && (this.destroyOnHide ? (this.trigger === "hover" && (b(o, "mouseenter", p(this, a)), b(o, "mouseleave", p(this, n))), this.root.removeChild(o)) : o.style.display = "none");
69
+ const o = p(".l-popover--content", this.root);
70
+ o && (this.destroyOnHide ? (this.trigger === "hover" && (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)), this.root.removeChild(o)) : o.style.display = "none");
71
+ }
72
+ #p() {
73
+ const o = p('[slot="trigger"]', this);
74
+ o && (this.trigger === "hover" ? (s(o, "mouseenter", this.#o), s(o, "mouseleave", this.#r)) : (this.trigger === "click" || this.trigger === "focus") && (s(o, "click", this.#e), T(o, this.#s)));
75
+ }
76
+ #l() {
77
+ const o = p('[slot="trigger"]', this);
78
+ o && (this.trigger === "hover" ? (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)) : (this.trigger === "click" || this.trigger === "focus") && (i(o, "click", this.#e), A(o)));
89
79
  }
80
+ #s = (o) => {
81
+ o.target.id !== this.id && this.hide();
82
+ };
83
+ #o = (o) => {
84
+ this.show(o.target);
85
+ };
86
+ #r = () => {
87
+ this.hide();
88
+ };
89
+ #e = (o) => {
90
+ this.trigger === "click" ? this.toggle(o.target) : this.trigger === "focus" && this.show(o.target);
91
+ };
90
92
  show(o) {
91
93
  if (!this.disabled) {
92
94
  if (this.isShow) {
93
- d(this, l, H).call(this);
95
+ this.#i();
94
96
  return;
95
97
  }
96
- this.isShow = !0, this.renderContent(), d(this, l, E).call(this, o);
98
+ this.isShow = !0, this.renderContent(), this.#a(o);
97
99
  }
98
100
  }
99
101
  hide() {
@@ -104,59 +106,51 @@ class Q extends j {
104
106
  toggle(o) {
105
107
  this.isShow ? this.hide() : this.show(o);
106
108
  }
107
- }
108
- l = new WeakSet(), O = function() {
109
- const o = this.getAttr("inline", !1);
110
- this.style.display = o ? "inline-block" : "block", this.id || (this.id = `${X()}-popover`);
111
- }, P = function() {
112
- const o = c('[slot="trigger"]', this);
113
- o && (this.trigger === "hover" ? (g(o, "mouseenter", p(this, a)), g(o, "mouseleave", p(this, n))) : (this.trigger === "click" || this.trigger === "focus") && (g(o, "click", p(this, w)), G(o, p(this, x))));
114
- }, S = function() {
115
- const o = c('[slot="trigger"]', this);
116
- o && (this.trigger === "hover" ? (b(o, "mouseenter", p(this, a)), b(o, "mouseleave", p(this, n))) : (this.trigger === "click" || this.trigger === "focus") && (b(o, "click", p(this, w)), J(o)));
117
- }, x = new WeakMap(), a = new WeakMap(), n = new WeakMap(), w = new WeakMap(), H = function() {
118
- this._t && (clearTimeout(this._t), this._t = void 0);
119
- }, E = function(o) {
120
- let s = "bottom", i = "";
121
- const k = this.placement.split("-");
122
- k != null && (s = k[0], i = k[1] || "");
123
- let v;
124
- o == null && (o = c('[slot="trigger"]', this));
125
- const f = c(".l-popover--content", this.root);
126
- if (f) {
127
- let m = f.getBoundingClientRect();
128
- const u = o.getBoundingClientRect();
129
- let C = document.documentElement;
130
- const M = C.scrollLeft, R = C.scrollTop;
131
- this.width != null && (this.width === "trigger" ? v = u.width : v = this.width), v != null && (m.width = v);
132
- const _ = Y(
133
- u,
134
- m,
135
- s,
136
- i,
137
- this.offset
138
- ), B = q(
139
- u,
140
- m,
141
- s,
142
- i,
143
- this.offset
144
- ), y = F(
145
- u,
146
- m,
147
- s,
148
- i,
149
- M,
150
- R,
151
- B,
152
- _,
153
- this.offset
154
- );
155
- s = y.mainAlign, i = y.crossAlign, v != null && f.style.setProperty("width", `${v}px`);
156
- const z = `l-popover-${s}${i === "" ? "" : "-" + i}`, $ = f.className.split(" ");
157
- $[1] !== z && ($[1] = `${z}`, f.className = $.join(" "));
109
+ #i() {
110
+ this._t && (clearTimeout(this._t), this._t = void 0);
111
+ }
112
+ #a(o) {
113
+ let r = "bottom", e = "";
114
+ const v = this.placement.split("-");
115
+ v != null && (r = v[0], e = v[1] || "");
116
+ let t;
117
+ o == null && (o = p('[slot="trigger"]', this));
118
+ const l = p(".l-popover--content", this.root);
119
+ if (l) {
120
+ let a = l.getBoundingClientRect();
121
+ const n = o.getBoundingClientRect();
122
+ let d = document.documentElement;
123
+ const b = d.scrollLeft, w = d.scrollTop;
124
+ this.width != null && (this.width === "trigger" ? t = n.width : t = this.width), t != null && (a.width = t);
125
+ const m = C(
126
+ n,
127
+ a,
128
+ r,
129
+ e,
130
+ this.offset
131
+ ), u = y(
132
+ n,
133
+ a,
134
+ r,
135
+ e,
136
+ this.offset
137
+ ), c = z(
138
+ n,
139
+ a,
140
+ r,
141
+ e,
142
+ b,
143
+ w,
144
+ u,
145
+ m,
146
+ this.offset
147
+ );
148
+ r = c.mainAlign, e = c.crossAlign, t != null && l.style.setProperty("width", `${t}px`);
149
+ const f = `l-popover-${r}${e === "" ? "" : "-" + e}`, h = l.className.split(" ");
150
+ h[1] !== f && (h[1] = `${f}`, l.className = h.join(" "));
151
+ }
158
152
  }
159
- }, t(Q, "baseName", "popover");
153
+ }
160
154
  export {
161
- Q as default
155
+ M as default
162
156
  };
@@ -1,52 +1,41 @@
1
- var C = Object.defineProperty;
2
- var A = (n, l, e) => l in n ? C(n, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[l] = e;
3
- var s = (n, l, e) => A(n, typeof l != "symbol" ? l + "" : l, e);
4
- import { initAttr as E, tagAttr as c, parseAttrValue as I } from "../utils/index.js";
5
- import w from "../form/form_inner.js";
6
- import { $one as d, hasClass as m, addClass as b, $ as u, iterate as p, getAttr as N, removeClass as f, formatClass as V, on as j, off as z } from "ph-utils/dom";
7
- import { random as _ } from "ph-utils";
8
- const S = ':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)}';
9
- class D extends w {
10
- constructor() {
11
- super(!1);
12
- s(this, "type");
13
- s(this, "label");
14
- s(this, "checked", !1);
15
- s(this, "_ignoreInitAttrs", []);
16
- s(this, "_radioChange", (e) => {
17
- const o = e.target;
18
- let t = o.parentElement;
19
- for (; t != null && !m(t, "l-radio"); )
20
- t = t.parentElement;
21
- const i = d(".is-checked", this.root);
22
- i && f(i, "is-checked"), this.value = o.value, t && b(t, "is-checked"), this.dispatchEvent(new CustomEvent("change"));
23
- });
24
- console.log(), E(this);
25
- }
1
+ import { initAttr as $, tagAttr as s, parseAttrValue as x } 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 = [];
26
12
  setItems(e) {
27
13
  this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
28
14
  }
15
+ constructor() {
16
+ super(!1), console.log(), $(this);
17
+ }
29
18
  connectedCallback() {
30
- super.connectedCallback(), this.loadStyleText(S), this._initEvents();
19
+ super.connectedCallback(), this.loadStyleText(w), this._initEvents();
31
20
  }
32
21
  disconnectedCallback() {
33
22
  super.disconnectedCallback(), this._removeEvents();
34
23
  }
35
24
  attributeChange(e, o, t) {
36
25
  if (e === "checked") {
37
- const i = I(t, !1, e);
26
+ const i = x(t, !1, e);
38
27
  this.checked = i, this.value = i;
39
- const r = d(".l-radio", this.root);
40
- if (r && !m(r, "is-checked")) {
41
- b(r, "is-checked");
42
- const a = d("input", r);
43
- a && (a.checked = !0);
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);
44
33
  }
45
34
  }
46
35
  }
47
36
  render() {
48
- this.getName() || (this.name = `la${_(3)}_${_(6)}`);
49
- const e = [], o = d('[slot="label"]', this), t = u("[radio-value]", this);
37
+ this.getName() || (this.name = `la${p(3)}_${p(6)}`);
38
+ const e = [], o = a('[slot="label"]', this), t = c("[radio-value]", this);
50
39
  return o != null || this.label ? (this.value = this._isChecked(), o ? e.push(
51
40
  this._renderItem("slot", void 0, this._isChecked(), "label")
52
41
  ) : e.push(
@@ -56,10 +45,10 @@ class D extends w {
56
45
  this._isChecked(),
57
46
  "label"
58
47
  )
59
- )) : t.length > 0 && (p(t, (i) => {
60
- const r = i.cloneNode(!0), a = N(i, "radio-value");
48
+ )) : t.length > 0 && (h(t, (i) => {
49
+ const r = i.cloneNode(!0), l = C(i, "radio-value");
61
50
  e.push(
62
- this._renderItem(r.outerHTML, a, this.value === a)
51
+ this._renderItem(r.outerHTML, l, this.value === l)
63
52
  );
64
53
  }), this.pushValueChange()), e.join("");
65
54
  }
@@ -67,12 +56,12 @@ class D extends w {
67
56
  super.setValue(e);
68
57
  let o = "";
69
58
  typeof e != "boolean" && (o = `[l-value="${e}"]`);
70
- const t = d(".is-checked", this.root);
71
- t && f(t, "is-checked");
72
- const i = d(`label${o}`, this.root);
59
+ const t = a(".is-checked", this.root);
60
+ t && b(t, "is-checked");
61
+ const i = a(`label${o}`, this.root);
73
62
  if (i) {
74
- const r = d("input", i);
75
- typeof e == "boolean" ? (e ? b(i, "is-checked") : f(i, "is-checked"), r.checked = e) : (b(i, "is-checked"), r.checked = !0);
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);
76
65
  }
77
66
  }
78
67
  _renderItems(e) {
@@ -91,36 +80,43 @@ class D extends w {
91
80
  return o.join("");
92
81
  }
93
82
  _renderItem(e, o, t = !1, i = void 0) {
94
- const r = V({
83
+ const r = A({
95
84
  "l-radio": !0,
96
85
  "l-radio--disabled": this.isDisabled(),
97
86
  "l-radio--button": this.type === "button",
98
87
  "is-checked": t
99
- }), a = c("disabled", this.isDisabled()), v = c("checked", t), g = c("value", o), k = `${c("name", this.getName())}${g}${a}${v}`, $ = c("part", i), x = c("l-value", o), h = [
100
- `<label class="${r}"${x}>`,
101
- `<input type="radio" class="l-radio__input"${k} />`
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"${_} />`
102
91
  ];
103
- this.type !== "button" && h.push('<span class="l-radio__inner"></span>');
104
- let y = e === "slot" ? '<slot name="label"></slot>' : e;
105
- return h.push(
106
- `<div class="l-radio__label"${$}>${y}</div>`
107
- ), h.push("</label>"), h.join("");
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("");
108
97
  }
109
98
  _isChecked() {
110
99
  return this.checked;
111
100
  }
112
101
  _initEvents() {
113
- p(u("input", this.root), (e) => {
114
- j(e, "change", this._radioChange);
102
+ h(c("input", this.root), (e) => {
103
+ E(e, "change", this._radioChange);
115
104
  });
116
105
  }
117
106
  _removeEvents() {
118
- p(u("input", this.root), (e) => {
119
- z(e, "change", this._radioChange);
107
+ h(c("input", this.root), (e) => {
108
+ I(e, "change", this._radioChange);
120
109
  });
121
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
+ };
122
119
  }
123
- s(D, "baseName", "radio");
124
120
  export {
125
- D as default
121
+ T as default
126
122
  };
@@ -1,30 +1,23 @@
1
- var r = Object.defineProperty;
2
- var o = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var n = (i, t, e) => o(i, typeof t != "symbol" ? t + "" : t, e);
4
- import u from "../form/form_inner.js";
5
- import { initAttr as d, tagAttrs as p } from "../utils/index.js";
6
- import { $one as m, on as $, off as g } from "ph-utils/dom";
7
- import { i as v } from "../index-391POYEJ.js";
8
- class f extends u {
1
+ import a from "../form/form_inner.js";
2
+ import { initAttr as c, tagAttrs as h } from "../utils/index.js";
3
+ import { $one as r, on as o, off as u } from "ph-utils/dom";
4
+ import { i as d } from "../index-391POYEJ.js";
5
+ class f extends a {
6
+ static baseName = "select-ori";
7
+ $select;
8
+ changeEmit;
9
9
  constructor() {
10
- super();
11
- n(this, "$select");
12
- n(this, "changeEmit");
13
- n(this, "_handleChange", (e) => {
14
- const s = e.target.value;
15
- super.setValue(s), this.dispatchEvent(this.changeEmit);
16
- });
17
- d(this), this.changeEmit = new CustomEvent("change");
10
+ super(), c(this), this.changeEmit = new CustomEvent("change");
18
11
  }
19
12
  connectedCallback() {
20
- this.loadStyleText(v), super.connectedCallback(), this.$select = m("select", this.root), this.value && (this.$select.value = this.value), $(this.$select, "change", this._handleChange);
13
+ this.loadStyleText(d), super.connectedCallback(), this.$select = r("select", this.root), this.value && (this.$select.value = this.value), o(this.$select, "change", this._handleChange);
21
14
  }
22
15
  disconnectedCallback() {
23
- super.disconnectedCallback(), this.$select && g(this.$select, "change", this._handleChange), this.changeEmit = void 0, this.$select = void 0;
16
+ super.disconnectedCallback(), this.$select && u(this.$select, "change", this._handleChange), this.changeEmit = void 0, this.$select = void 0;
24
17
  }
25
18
  render() {
26
19
  let e = this.innerHTML.trim();
27
- return `<select class="l-input"${p([
20
+ return `<select class="l-input"${h([
28
21
  ["name", this.getName()],
29
22
  ["disabled", this.isDisabled()]
30
23
  ])}>${e}</select>`;
@@ -34,17 +27,17 @@ class f extends u {
34
27
  }
35
28
  setOptions(e) {
36
29
  if (!this.$select) return;
37
- const s = e.map((l) => `<option value="${l.value}">${l.label}</option>`);
38
- this.$select.innerHTML = s.join("");
30
+ const t = e.map((s) => `<option value="${s.value}">${s.label}</option>`);
31
+ this.$select.innerHTML = t.join("");
39
32
  }
40
33
  appendOptions(e) {
41
34
  if (!this.$select) return;
42
- const s = document.createDocumentFragment();
43
- for (let l = 0, h = e.length; l < h; l++) {
44
- const c = e[l], a = document.createElement("option");
45
- a.value = c.value, a.innerHTML = c.label, s.appendChild(a);
35
+ const t = document.createDocumentFragment();
36
+ for (let s = 0, n = e.length; s < n; s++) {
37
+ const l = e[s], i = document.createElement("option");
38
+ i.value = l.value, i.innerHTML = l.label, t.appendChild(i);
46
39
  }
47
- this.$select.appendChild(s);
40
+ this.$select.appendChild(t);
48
41
  }
49
42
  reset() {
50
43
  super.reset(), this.$select && (this.$select.value = this.value);
@@ -52,8 +45,11 @@ class f extends u {
52
45
  setValue(e) {
53
46
  super.setValue(e), this.$select && (this.$select.value = this.value);
54
47
  }
48
+ _handleChange = (e) => {
49
+ const t = e.target.value;
50
+ super.setValue(t), this.dispatchEvent(this.changeEmit);
51
+ };
55
52
  }
56
- n(f, "baseName", "select-ori");
57
53
  export {
58
54
  f as default
59
55
  };