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
package/lib/base.d.ts CHANGED
@@ -51,5 +51,5 @@ export default class BaseComponent extends HTMLElement {
51
51
  * @param eventOption 自定义事件配置选项, 默认: bubbles: true
52
52
  * @returns 是否成功触发事件
53
53
  */
54
- emit(name: string, eventOption: Partial<CustomEventInit>): boolean;
54
+ emit(name: string, eventOption?: Partial<CustomEventInit>): boolean;
55
55
  }
package/lib/base.js CHANGED
@@ -4,7 +4,7 @@ class i extends HTMLElement {
4
4
  /** 组件是否渲染完成, 是否已经调用 connectedCallback */
5
5
  rendered = !1;
6
6
  constructor(t = !0, e = {}) {
7
- super(), t && this.attachShadow({ mode: "open", ...e });
7
+ super(), this.rendered = !1, t && this.attachShadow({ mode: "open", ...e });
8
8
  }
9
9
  /**
10
10
  * 返回一个数组,表示观察的属性列表
@@ -13,7 +13,7 @@ class i extends HTMLElement {
13
13
  return [];
14
14
  }
15
15
  // 当属性发生变化时调用的回调函数
16
- attributeChangedCallback(t, e, o) {
16
+ attributeChangedCallback(t, e, s) {
17
17
  }
18
18
  /** @deprecated */
19
19
  get shadow() {
@@ -45,7 +45,7 @@ class i extends HTMLElement {
45
45
  } else t.length ? this.root.append(...t) : this.root.append(t);
46
46
  }
47
47
  connectedCallback() {
48
- this.appendToRoot(this.render()), this.initEvents(), this.afterInit(), this.rendered = !0;
48
+ this.appendToRoot(this.render()), this.rendered = !0, this.initEvents(), this.afterInit();
49
49
  }
50
50
  disconnectedCallback() {
51
51
  this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
@@ -4,7 +4,10 @@ export default class Button extends BaseComponent {
4
4
  htmlType: "submit" | "reset" | "button";
5
5
  /** 加载中文本 */
6
6
  loadingText: string;
7
- disabled: boolean;
7
+ _disabled: boolean;
8
+ get disabled(): boolean;
9
+ set disabled(value: boolean);
10
+ setDisabled(value: boolean): void;
8
11
  static get observedAttributes(): string[];
9
12
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
10
13
  connectedCallback(): void;
@@ -1,32 +1,47 @@
1
- import { parseAttrValue as b, initAttr as s } from "../utils/index.js";
2
- import c from "../base.js";
3
- import { $one as h, addClass as g, removeClass as f, on as p, off as v, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
4
- import { adjust as i } from "ph-utils/color";
1
+ import { parseAttrValue as b, initAttr as c } from "../utils/index.js";
2
+ import h from "../base.js";
3
+ import { $one as i, addClass as g, removeClass as f, on as p, off as v, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
4
+ import { adjust as s } from "ph-utils/color";
5
5
  import { a as x } from "../animation-DttknHkX.js";
6
6
  const y = ":host{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-block;width:auto;height:var(--l-form-edit-height, 32px);font-size:0}:host([block]){width:100%}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:100%;border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color, var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab);--l-btn-disabled-border-color: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-background: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-color: #ffffff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height, 32px);padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
7
- class M extends c {
7
+ class L extends h {
8
8
  static baseName = "button";
9
9
  htmlType = "button";
10
10
  /** 加载中文本 */
11
11
  loadingText = "";
12
- disabled = !1;
12
+ _disabled = !1;
13
+ get disabled() {
14
+ return this._disabled;
15
+ }
16
+ set disabled(r) {
17
+ this.setDisabled(r);
18
+ }
19
+ setDisabled(r) {
20
+ this._disabled = r;
21
+ const t = i(".l-btn", this.root);
22
+ t && (t.disabled = r);
23
+ }
13
24
  // 初始化属性观察器
14
25
  static get observedAttributes() {
15
26
  return ["loading", "color", "disabled"];
16
27
  }
17
28
  // 当属性发生变化时调用的回调函数
18
29
  attributeChangedCallback(r, t, o) {
19
- const l = h(".l-btn", this.root);
20
- if (l)
30
+ const l = i(".l-btn", this.root);
31
+ if (l) {
21
32
  if (r === "loading")
22
33
  b(o, !1, r) ? (g(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (f(l, "l-btn-loading"), l.disabled = this.disabled, l.innerHTML = "<slot></slot>");
23
34
  else if (r === "color") {
24
35
  const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
25
36
  l.style.cssText = this.applyColor(o, e, n);
26
- } else r === "disabled" && (l.disabled = b(o, !1, "disabled"));
37
+ } else if (r === "disabled") {
38
+ const e = b(o, !1, "disabled");
39
+ this.setDisabled(e);
40
+ }
41
+ }
27
42
  }
28
43
  connectedCallback() {
29
- s(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
44
+ c(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
30
45
  }
31
46
  disconnectedCallback() {
32
47
  super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
@@ -41,7 +56,7 @@ class M extends c {
41
56
  e ? "l-btn-text" : "",
42
57
  o ? "l-btn-loading" : ""
43
58
  ];
44
- t.className = u(d), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
59
+ t.className = u(d), t.disabled = this.disabled || o, t.type = this.getAttr("html-type", "button");
45
60
  const a = this.applyColor(this.getAttr("color"), e, n);
46
61
  a && (t.style.cssText = a), o ? t.innerHTML = this.loadingBody() : t.innerHTML = "<slot></slot>", t.setAttribute("part", "default"), this.root.appendChild(t);
47
62
  }
@@ -51,7 +66,7 @@ class M extends c {
51
66
  }
52
67
  applyColor(r, t = !1, o = !1) {
53
68
  if (!r) return "";
54
- const l = i(r, 1, !0), e = i(r, 3, !1);
69
+ const l = s(r, 1, !0), e = s(r, 3, !1);
55
70
  return m({
56
71
  "--l-btn-border-color": t ? "transparent" : r,
57
72
  "--l-btn-text-color": o || t ? r : "#ffffff",
@@ -86,5 +101,5 @@ class M extends c {
86
101
  }
87
102
  }
88
103
  export {
89
- M as default
104
+ L as default
90
105
  };
@@ -0,0 +1,20 @@
1
+ import BaseComponent from "../base";
2
+ export default class Carousel extends BaseComponent {
3
+ #private;
4
+ static baseName: string;
5
+ /** 是否显示箭头 */
6
+ arrows: "hover" | "always" | "never";
7
+ currentIndex: number;
8
+ allIndex: number;
9
+ loop: boolean;
10
+ observer?: MutationObserver;
11
+ autoplay: boolean;
12
+ static get observedAttributes(): string[];
13
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
14
+ connectedCallback(): void;
15
+ afterInit(): void;
16
+ beforeDestroy(): void;
17
+ render(): DocumentFragment;
18
+ renderArrows(fragment: DocumentFragment): void;
19
+ renderNavigationButton(dir: "prev" | "next" | undefined, fragment: DocumentFragment): void;
20
+ }
@@ -0,0 +1,280 @@
1
+ import u from "../base.js";
2
+ import { getAttr as m, on as l, $one as h, off as r, $$ as c, $ as p, iterate as f, shouldEventNext as v } from "ph-utils/dom";
3
+ import { debounce as x } from "ph-utils/web";
4
+ import { parseAttrValue as d } from "../utils/index.js";
5
+ import b from "./timer.js";
6
+ const g = ":host{display:block;width:100%;height:180px;margin:0 auto;box-sizing:border-box;position:relative;overflow:hidden}.container{min-width:900%;height:100%;box-sizing:border-box;position:relative;display:flex}.nav-button{position:absolute;top:50%;transform:translateY(-50%);width:30px;height:30px;border:none;outline:none;border-radius:50%;cursor:pointer;display:flex;justify-content:center;align-items:center;z-index:20;font-size:16px;background-color:#292d3d4d;margin:0;padding:0;color:#fff;transition:background-color .3s}.nav-button:hover{background-color:#292d3d66}.nav-button:active{background-color:#292d3d80}.nav-prev{left:20px}.nav-next{right:20px}.pagination{position:absolute;bottom:10px;left:0;width:100%;z-index:2;display:flex;align-items:center;gap:8px;justify-content:center}.bullet{display:inline-block;width:8px;height:8px;border-radius:50%;background-color:#0000004d;cursor:pointer;transition:background-color .3s}.bullet.active{background-color:var(--l-primary-color, #722ed1)}";
7
+ class A extends u {
8
+ static baseName = "carousel";
9
+ /** 是否显示箭头 */
10
+ arrows = "hover";
11
+ currentIndex = 0;
12
+ allIndex = -1;
13
+ #s = 0;
14
+ // 当前偏移量
15
+ loop = !0;
16
+ observer;
17
+ autoplay = !1;
18
+ #e = void 0;
19
+ /* 手势 */
20
+ #o = 0;
21
+ #i = !1;
22
+ #d = 0;
23
+ #r = 0;
24
+ // 节点引用
25
+ #t;
26
+ static get observedAttributes() {
27
+ return ["arrows", "loop", "current-index", "autoplay"];
28
+ }
29
+ attributeChangedCallback(t, e, i) {
30
+ switch (t) {
31
+ case "arrows":
32
+ const s = d(i, "hover");
33
+ if (s !== this.arrows) {
34
+ this.arrows = s;
35
+ const a = document.createDocumentFragment();
36
+ this.renderArrows(a), this.root.appendChild(a);
37
+ }
38
+ break;
39
+ case "loop":
40
+ this.loop = d(i, !1, "loop");
41
+ break;
42
+ case "current-index":
43
+ const n = d(i, 0);
44
+ n !== this.currentIndex && this.#x(this.loop ? n + 1 : n);
45
+ break;
46
+ case "autoplay":
47
+ const o = d(i, !1, "autoplay");
48
+ o !== this.autoplay && (this.autoplay = o, this.#e && (o ? this.#e.start() : this.#e.stop()));
49
+ break;
50
+ }
51
+ }
52
+ connectedCallback() {
53
+ this.loadStyleText(g), this.style.setProperty(
54
+ "--carousel-width",
55
+ `${Math.floor(this.clientWidth)}px`
56
+ );
57
+ const t = m(this, "height");
58
+ t && this.style.setProperty("height", `${t}px`), this.#m(), super.connectedCallback();
59
+ }
60
+ afterInit() {
61
+ this.setAttribute("data-page", "__stop__"), l(this.root, "click", this.#v), this.#f(), this.#e = b(() => {
62
+ this.#a("next");
63
+ }), this.autoplay && this.#e.start(), this.#t = h(".container", this.root), l(this.#t, "pointerdown", this.#y), l(this.#t, "pointerup", this.#I), l(this.#t, "pointermove", this.#$), l(this.#t, "pointercancel", this.#n), l(this.#t, "pointerleave", this.#n);
64
+ }
65
+ beforeDestroy() {
66
+ r(this, "mouseenter", this.#l), r(this, "mouseleave", this.#h), r(this.root, "click", this.#v), r(this.#t, "pointerdown", this.#y), r(this.#t, "pointerup", this.#I), r(this.#t, "pointermove", this.#$), r(this.#t, "pointercancel", this.#n), r(this.#t, "pointerleave", this.#n), this.#t = void 0, this.#u(!0), this.#e.stop(), this.#e = void 0;
67
+ }
68
+ render() {
69
+ const t = document.createDocumentFragment();
70
+ let e = "";
71
+ if (this.allIndex > 0) {
72
+ const n = this.loop ? this.currentIndex + 1 : this.currentIndex, o = Math.floor(n * this.clientWidth * -1);
73
+ e = `transform:translateX(${o}px);`;
74
+ const a = Math.floor(this.clientWidth * (this.allIndex + 3));
75
+ e += `min-width:${a}px;`, this.#s = o;
76
+ }
77
+ const i = c("div", {
78
+ class: "container",
79
+ style: e,
80
+ "data-container": "1"
81
+ });
82
+ i.appendChild(c("slot")), t.appendChild(i), this.renderArrows(t);
83
+ const s = c("div", { class: "pagination", part: "pagination" });
84
+ return this.allIndex >= 0 && s.replaceChildren(this.#p()), t.appendChild(s), t;
85
+ }
86
+ renderArrows(t) {
87
+ if (this.arrows !== "never")
88
+ this.renderNavigationButton("prev", t), this.renderNavigationButton("next", t), this.arrows === "hover" && (l(this, "mouseenter", this.#l), l(this, "mouseleave", this.#h));
89
+ else {
90
+ r(this, "mouseenter", this.#l), r(this, "mouseleave", this.#h);
91
+ const e = p(".nav-button", this.root);
92
+ e.length && f(e, (i) => {
93
+ i.remove();
94
+ });
95
+ }
96
+ }
97
+ #p() {
98
+ const t = document.createDocumentFragment();
99
+ for (let e = 0; e <= this.allIndex; e++)
100
+ t.appendChild(
101
+ c("div", {
102
+ class: ["bullet", e === this.currentIndex ? "active" : ""],
103
+ "aria-label": `第 ${e + 1} 页`,
104
+ "data-page": `${e}`,
105
+ id: `bullet-${e}`
106
+ })
107
+ );
108
+ return t;
109
+ }
110
+ renderNavigationButton(t = "prev", e) {
111
+ let i = h(`.nav-${t}`, this.root);
112
+ if (i == null) {
113
+ const s = t === "prev" ? "left" : "right";
114
+ i = c("button", {
115
+ class: `nav-button nav-${t}`,
116
+ type: "button",
117
+ innerHTML: `<l-arrow-${s}-icon></l-arrow-${s}-icon>`,
118
+ "aria-label": t,
119
+ "data-page": t
120
+ }), e.appendChild(i);
121
+ }
122
+ this.arrows === "always" ? i.style.display = "flex" : i.style.display = "none";
123
+ }
124
+ #f() {
125
+ this.observer == null && (this.observer = new MutationObserver(this.#C)), this.observer.observe(this, { childList: !0 });
126
+ }
127
+ #u(t = !1) {
128
+ this.observer && (this.observer.disconnect(), t && (this.observer = void 0));
129
+ }
130
+ #w = x(() => {
131
+ const t = h("#cloneFirst", this);
132
+ t && t.remove();
133
+ const e = h("#cloneLast", this);
134
+ if (e && e.remove(), this.#m(), this.#t) {
135
+ if (this.allIndex > 0) {
136
+ const o = Math.floor(
137
+ this.clientWidth * (this.allIndex + 3)
138
+ );
139
+ this.#t.style.minWidth = `${o}px`;
140
+ } else
141
+ this.#t.style.minWidth = "900%";
142
+ const s = this.loop ? this.currentIndex + 1 : this.currentIndex, n = Math.floor(s * this.clientWidth * -1);
143
+ this.#t.style.transform = `translateX(${n}px)`, this.#s = n;
144
+ }
145
+ const i = h(".pagination", this.root);
146
+ i && i.replaceChildren(this.#p()), this.#f();
147
+ }, 300);
148
+ #m() {
149
+ const t = this.children, e = t.length;
150
+ if (e > 0 && this.loop) {
151
+ const i = t[0].cloneNode(!0);
152
+ i.id = "cloneFirst";
153
+ const s = t[e - 1].cloneNode(!0);
154
+ s.id = "cloneLast", this.children[e - 1].insertAdjacentElement("afterend", i), this.children[0].insertAdjacentElement("beforebegin", s);
155
+ }
156
+ this.allIndex = this.children.length - (this.loop ? 3 : 1);
157
+ }
158
+ #C = (t) => {
159
+ for (const e of t)
160
+ e.type === "childList" && (this.#u(), this.#w());
161
+ };
162
+ #v = (t) => {
163
+ const [e, i] = v(t, "data-page", this.root);
164
+ e && this.#a(i);
165
+ };
166
+ #a(t) {
167
+ this.#e.stop();
168
+ const e = this.loop ? this.currentIndex + 1 : this.currentIndex;
169
+ let i = e;
170
+ if (t === "prev")
171
+ this.loop && this.currentIndex === 0 ? i = 0 : i = e - 1, i < 0 && (i = 0);
172
+ else if (t === "next")
173
+ this.loop && this.currentIndex === this.allIndex ? i = this.allIndex + 2 : i = e + 1, !this.loop && i > this.allIndex && (i = this.allIndex);
174
+ else {
175
+ const s = Number(t);
176
+ s !== this.currentIndex && (i = this.loop ? s + 1 : s);
177
+ }
178
+ i !== e && this.#x(i), requestAnimationFrame(() => {
179
+ this.#c();
180
+ });
181
+ }
182
+ #x(t) {
183
+ if (this.#t) {
184
+ const s = Math.floor(t * this.clientWidth * -1), n = this.#t.style.transform;
185
+ this.#t.animate(
186
+ [{ transform: n }, { transform: `translateX(${s}px)` }],
187
+ { duration: 300 }
188
+ ).addEventListener(
189
+ "finish",
190
+ () => {
191
+ let a = s;
192
+ this.loop && t === this.allIndex + 2 ? a = Math.floor(this.clientWidth * -1) : this.loop && t === 0 && (a = Math.floor(this.clientWidth * (this.allIndex + 1) * -1)), this.#t.style.transform = `translateX(${a}px)`, this.#s = a;
193
+ },
194
+ { once: !0 }
195
+ );
196
+ }
197
+ this.loop && this.allIndex > 0 && t === this.allIndex + 2 ? this.currentIndex = 0 : this.loop && this.allIndex > 0 && t === 0 ? this.currentIndex = this.allIndex : this.currentIndex = this.loop ? t - 1 : t;
198
+ const e = h(".bullet.active", this.root);
199
+ e && e.classList.remove("active");
200
+ const i = h(`#bullet-${this.currentIndex}`, this.root);
201
+ i && i.classList.add("active");
202
+ }
203
+ #l = () => {
204
+ if (this.arrows === "hover") {
205
+ const t = p(".nav-button", this.root);
206
+ f(t, (e) => {
207
+ e.style.display = "flex", this.#b(e, !0);
208
+ });
209
+ }
210
+ };
211
+ #h = () => {
212
+ if (this.arrows === "hover") {
213
+ const t = p(".nav-button", this.root);
214
+ f(t, (e) => {
215
+ this.#b(e, !1);
216
+ });
217
+ }
218
+ };
219
+ #b(t, e = !0) {
220
+ const s = t.getAttribute("data-page") === "prev" ? -10 : 10, n = [];
221
+ e ? n.push(
222
+ { opacity: 0, transform: `translate3d(${s}px, -50%, 0)` },
223
+ { opacity: 1, transform: "translate3d(0px, -50%, 0)" }
224
+ ) : n.push(
225
+ { opacity: 1, transform: "translate3d(0px, -50%, 0)" },
226
+ { opacity: 0, transform: `translate3d(${s}px, -50%, 0)` }
227
+ );
228
+ const o = t.animate(n, {
229
+ duration: 300,
230
+ fill: "both"
231
+ });
232
+ e || o.addEventListener(
233
+ "finish",
234
+ () => {
235
+ t.style.display = "none";
236
+ },
237
+ { once: !0 }
238
+ );
239
+ }
240
+ #g = () => {
241
+ const t = h(".container", this.root);
242
+ t.style.transition = "transform 0.3s", requestAnimationFrame(() => {
243
+ t.style.transform = `translateX(${this.#s}px)`;
244
+ }), t.addEventListener(
245
+ "transitionend",
246
+ () => {
247
+ t.style.transition = "";
248
+ },
249
+ { once: !0 }
250
+ );
251
+ };
252
+ #y = (t) => {
253
+ this.#o = t.clientX, this.#i = !0, this.#d = Date.now(), this.#e.stop();
254
+ };
255
+ #$ = (t) => {
256
+ this.#i && (this.#r && cancelAnimationFrame(this.#r), this.#r = requestAnimationFrame(() => {
257
+ const e = Math.floor(t.clientX - this.#o);
258
+ if (!this.loop && (e < 0 && this.currentIndex === this.allIndex || e > 0 && this.currentIndex === 0))
259
+ return;
260
+ const i = this.#s + e;
261
+ this.#t.style.transform = `translateX(${i}px)`;
262
+ }), t.preventDefault());
263
+ };
264
+ #I = (t) => {
265
+ if (!this.#i) return;
266
+ const e = Date.now() - this.#d, i = t.clientX - this.#o;
267
+ if (this.#i = !1, i === 0) return;
268
+ let s = "cancel";
269
+ e <= 200 ? i >= 20 ? s = "prev" : i <= -20 && (s = "next") : i >= this.clientWidth / 2 ? s = "prev" : i <= -this.clientWidth / 2 && (s = "next"), s === "cancel" ? this.#g() : this.#a(s), this.#c();
270
+ };
271
+ #c = () => {
272
+ this.autoplay && this.#e.start();
273
+ };
274
+ #n = () => {
275
+ this.#i && (this.#i = !1, this.#g(), this.#c());
276
+ };
277
+ }
278
+ export {
279
+ A as default
280
+ };
@@ -0,0 +1,6 @@
1
+ import BaseComponent from "../base";
2
+ export default class Carousel extends BaseComponent {
3
+ static baseName: string;
4
+ connectedCallback(): void;
5
+ render(): HTMLElement;
6
+ }
@@ -0,0 +1,15 @@
1
+ import e from "../base.js";
2
+ import { $$ as t } from "ph-utils/dom";
3
+ const o = ":host{width:var(--carousel-width, 100%);height:100%;box-sizing:border-box;display:block}:host(.active){display:block}";
4
+ class r extends e {
5
+ static baseName = "carousel-item";
6
+ connectedCallback() {
7
+ this.loadStyleText(o), super.connectedCallback();
8
+ }
9
+ render() {
10
+ return t("slot");
11
+ }
12
+ }
13
+ export {
14
+ r as default
15
+ };
@@ -0,0 +1,5 @@
1
+ export type AutoPlayTimerT = {
2
+ start: () => void;
3
+ stop: () => void;
4
+ };
5
+ export default function autoPlayTimer(callback: () => void, duration?: number): AutoPlayTimerT;
@@ -0,0 +1,19 @@
1
+ function o(a, l = 3e3) {
2
+ let n = 0, t = !1, e = null;
3
+ function u() {
4
+ t || (t = !0, n = 0, e = requestAnimationFrame(r));
5
+ }
6
+ function f() {
7
+ t = !1, e && (cancelAnimationFrame(e), e = null);
8
+ }
9
+ function r(i) {
10
+ t && (n || (n = i), i - n >= l && (a(), n = i), e = requestAnimationFrame(r));
11
+ }
12
+ return {
13
+ start: u,
14
+ stop: f
15
+ };
16
+ }
17
+ export {
18
+ o as default
19
+ };
@@ -0,0 +1,22 @@
1
+ import FormInner from "../form/form_inner";
2
+ export default class Check extends FormInner {
3
+ #private;
4
+ /** 是否选中 */
5
+ private _checked;
6
+ label?: string;
7
+ /** 是否为按钮样式 */
8
+ button: boolean;
9
+ _inputType: string;
10
+ setChecked(isChecked: boolean): void;
11
+ getChecked(): boolean;
12
+ constructor();
13
+ static get observedAttributes(): string[];
14
+ connectedCallback(): void;
15
+ afterInit(): void;
16
+ beforeDestroy(): void;
17
+ render(): DocumentFragment;
18
+ protected attributeChange(name: string, _oldValue: string, newValue: string): void;
19
+ protected checkedChange(): void;
20
+ protected disabledChange(): void;
21
+ _doChangeAction(): void;
22
+ }
@@ -0,0 +1,81 @@
1
+ import d from "../form/form_inner.js";
2
+ import { initAttr as n, parseAttrValue as l } from "../utils/index.js";
3
+ import { addClass as c, on as r, off as o, $$ as i, removeClass as k, $one as u, toggleClass as p } from "ph-utils/dom";
4
+ class m extends d {
5
+ /** 是否选中 */
6
+ _checked = !1;
7
+ label;
8
+ /** 是否为按钮样式 */
9
+ button = !1;
10
+ _inputType = "radio";
11
+ // input类型
12
+ setChecked(e) {
13
+ this._checked = e, this.checkedChange();
14
+ }
15
+ getChecked() {
16
+ return this._checked;
17
+ }
18
+ constructor() {
19
+ super(), Object.defineProperty(this, "checked", {
20
+ configurable: !0,
21
+ enumerable: !0,
22
+ get: this.getChecked,
23
+ set: this.setChecked
24
+ });
25
+ }
26
+ static get observedAttributes() {
27
+ return ["disabled", "checked"];
28
+ }
29
+ connectedCallback() {
30
+ n(this), super.connectedCallback(), this.getChecked() && c(this, "is-checked"), this.isDisabled() && c(this, "is-disabled");
31
+ }
32
+ afterInit() {
33
+ r(this, "click", this.#e);
34
+ }
35
+ beforeDestroy() {
36
+ o(this, "click", this.#e);
37
+ }
38
+ render() {
39
+ const e = document.createDocumentFragment(), h = i("input", {
40
+ type: this._inputType,
41
+ class: "l-check__input",
42
+ name: this.getName(),
43
+ value: this.value,
44
+ disabled: this.isDisabled(),
45
+ checked: this.getChecked()
46
+ });
47
+ if (e.appendChild(h), !this.button) {
48
+ const a = i("span", { class: "l-check__inner" });
49
+ e.appendChild(a);
50
+ }
51
+ const t = i("label", {
52
+ class: "l-check__label",
53
+ part: "label"
54
+ }), s = i("slot", {
55
+ textContent: this.label
56
+ });
57
+ return t.appendChild(s), e.appendChild(t), e;
58
+ }
59
+ attributeChange(e, h, t) {
60
+ if (e === "checked") {
61
+ const s = l(t, !1, "checked");
62
+ s !== this.getChecked() && this.setChecked(s);
63
+ }
64
+ }
65
+ checkedChange() {
66
+ this.getChecked() ? c(this, "is-checked") : k(this, "is-checked");
67
+ const e = u("input", this.root);
68
+ e && (e.checked = this._checked);
69
+ }
70
+ disabledChange() {
71
+ p(this, "is-disabled");
72
+ }
73
+ #e = () => {
74
+ this.isDisabled() || this._doChangeAction();
75
+ };
76
+ _doChangeAction() {
77
+ }
78
+ }
79
+ export {
80
+ m as default
81
+ };
@@ -0,0 +1,7 @@
1
+ import Check from "./check";
2
+ export default class Checkbox extends Check {
3
+ static baseName: string;
4
+ constructor();
5
+ connectedCallback(): void;
6
+ _doChangeAction(): void;
7
+ }
@@ -0,0 +1,25 @@
1
+ import e from "./check.js";
2
+ import { c as r } from "../check-BlDsQQo0.js";
3
+ const o = '.l-check__inner:after{content:"";width:calc(var(--l-check-size) * .6);height:calc(var(--l-check-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}:host([indeterminate]) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host([indeterminate]) .l-check__inner:after{content:"";width:calc(var(--l-check-size) * .4);height:1px;display:block;border:1px solid #fff;border-right:none;border-top:none;border-left:none;transform:rotate(0);margin-top:0}:host(.is-checked) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner:after{border-color:#fff}:host(.is-disabled) .l-check__inner{background-color:var(--l-disabled-color, #e6e6e6);border-color:var(--l-disabled-color, #e6e6e6)}';
4
+ class a extends e {
5
+ static baseName = "checkbox";
6
+ constructor() {
7
+ super(), this._inputType = "checkbox";
8
+ }
9
+ connectedCallback() {
10
+ this.loadStyleText([r, o]), super.connectedCallback();
11
+ }
12
+ _doChangeAction() {
13
+ this.getChecked() ? this.removeAttribute("checked") : this.setAttribute("checked", ""), this.emit("change", {
14
+ detail: {
15
+ value: this.value,
16
+ name: this.getName(),
17
+ checked: this.getChecked()
18
+ },
19
+ composed: !0
20
+ });
21
+ }
22
+ }
23
+ export {
24
+ a as default
25
+ };
@@ -0,0 +1,9 @@
1
+ import CheckGroup from ".";
2
+ export default class CheckboxGroup extends CheckGroup {
3
+ static baseName: string;
4
+ set value(value: string);
5
+ get value(): string;
6
+ afterInit(): void;
7
+ protected updateChangedStatus(): void;
8
+ valueChange(value: string): void;
9
+ }
@@ -0,0 +1,33 @@
1
+ import a from "./index.js";
2
+ import { $ as u, iterate as i } from "ph-utils/dom";
3
+ class d extends a {
4
+ static baseName = "checkbox-group";
5
+ set value(t) {
6
+ super.setValue(t), this.rendered && this.updateChangedStatus();
7
+ }
8
+ get value() {
9
+ return this._value;
10
+ }
11
+ afterInit() {
12
+ super.afterInit(), this.updateChangedStatus();
13
+ }
14
+ updateChangedStatus() {
15
+ if (this.value) {
16
+ const e = this.value.split("&");
17
+ this.checkedValues.push(...e.map((s) => decodeURIComponent(s)));
18
+ } else
19
+ this.checkedValues = [];
20
+ const t = u("l-checkbox[value]", this);
21
+ i(t, (e) => {
22
+ let s = e.value;
23
+ s || (s = e.getAttribute("value")), s && (this.checkedValues.includes(s) ? e.setAttribute("checked", "") : e.removeAttribute("checked"));
24
+ });
25
+ }
26
+ valueChange(t) {
27
+ let e = this.checkedValues.indexOf(t);
28
+ e >= 0 ? this.checkedValues.splice(e, 1) : this.checkedValues.push(t), this.setValue(this.checkedValues.join("&"));
29
+ }
30
+ }
31
+ export {
32
+ d as default
33
+ };