litos-ui 0.12.2 → 0.13.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 (61) hide show
  1. package/lib/base.d.ts +23 -2
  2. package/lib/base.js +37 -8
  3. package/lib/button/index.d.ts +3 -1
  4. package/lib/button/index.js +18 -19
  5. package/lib/color_picker/index.js +1 -1
  6. package/lib/date_picker/index.d.ts +22 -0
  7. package/lib/date_picker/index.js +99 -0
  8. package/lib/dialog/dialog_container.d.ts +28 -0
  9. package/lib/dialog/dialog_container.js +100 -0
  10. package/lib/dialog/index.d.ts +30 -0
  11. package/lib/dialog/index.js +86 -0
  12. package/lib/form/form_inner.d.ts +7 -2
  13. package/lib/form/form_inner.js +27 -21
  14. package/lib/form/form_item.d.ts +0 -2
  15. package/lib/form/form_item.js +5 -9
  16. package/lib/form/index.d.ts +0 -2
  17. package/lib/form/index.js +23 -25
  18. package/lib/icon/base.d.ts +0 -1
  19. package/lib/icon/base.js +15 -17
  20. package/lib/icon/close.d.ts +5 -0
  21. package/lib/icon/close.js +10 -0
  22. package/lib/icon/{mask_close.js → close_filled.js} +1 -1
  23. package/lib/index-dwS1N2uN.js +4 -0
  24. package/lib/index.d.ts +28 -2
  25. package/lib/index.js +112 -87
  26. package/lib/input/index.d.ts +6 -5
  27. package/lib/input/index.js +105 -57
  28. package/lib/list/index.d.ts +1 -1
  29. package/lib/litos-ui.css +1 -1
  30. package/lib/loading/index.d.ts +45 -0
  31. package/lib/loading/index.js +141 -0
  32. package/lib/menu/base.js +1 -0
  33. package/lib/menu/index.d.ts +29 -0
  34. package/lib/menu/index.js +90 -0
  35. package/lib/menu/menu_item.d.ts +6 -0
  36. package/lib/menu/menu_item.js +21 -0
  37. package/lib/menu/sub_menu.d.ts +13 -0
  38. package/lib/menu/sub_menu.js +64 -0
  39. package/lib/message/index.js +1 -1
  40. package/lib/modal/index.d.ts +40 -0
  41. package/lib/modal/index.js +153 -0
  42. package/lib/modal/modal_box.js +95 -0
  43. package/lib/popover/index.d.ts +1 -4
  44. package/lib/popover/index.js +6 -12
  45. package/lib/radio/index.js +3 -3
  46. package/lib/select_ori/index.d.ts +0 -2
  47. package/lib/select_ori/index.js +11 -15
  48. package/lib/switch/index.d.ts +0 -1
  49. package/lib/switch/index.js +8 -13
  50. package/lib/tabbar/index.d.ts +0 -1
  51. package/lib/tabbar/index.js +55 -63
  52. package/lib/theme/index.d.ts +1 -2
  53. package/lib/theme/index.js +9 -12
  54. package/lib/utils/index.d.ts +0 -5
  55. package/lib/utils/index.js +45 -52
  56. package/lib/utils/transition.js +3 -2
  57. package/package.json +8 -8
  58. package/styles/vars.css +1 -1
  59. package/lib/index-391POYEJ.js +0 -4
  60. package/lib/litos-ui.min.js +0 -1
  61. /package/lib/icon/{mask_close.d.ts → close_filled.d.ts} +0 -0
package/lib/base.d.ts CHANGED
@@ -2,12 +2,13 @@ export default class BaseComponent extends HTMLElement {
2
2
  static baseName: string;
3
3
  /** 组件是否渲染完成, 是否已经调用 connectedCallback */
4
4
  rendered: boolean;
5
- constructor(shadow?: boolean);
5
+ constructor(shadow?: boolean, init?: Partial<ShadowRootInit>);
6
6
  /**
7
7
  * 返回一个数组,表示观察的属性列表
8
8
  */
9
9
  static get observedAttributes(): string[] | undefined | null;
10
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
10
+ attributeChangedCallback(_name: string, _oldValue: string, _newValue: string): void;
11
+ /** @deprecated */
11
12
  get shadow(): ShadowRoot;
12
13
  get root(): ShadowRoot | HTMLElement;
13
14
  createStyle(text: string): void;
@@ -31,4 +32,24 @@ export default class BaseComponent extends HTMLElement {
31
32
  connectedCallback(): void;
32
33
  disconnectedCallback(): void;
33
34
  render(): void | string | HTMLElement | HTMLElement[] | DocumentFragment;
35
+ /**
36
+ * 初始化事件
37
+ * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
38
+ */
39
+ initEvents(): void;
40
+ afterInit(): void;
41
+ /** 移除事件 */
42
+ /**
43
+ * 移除事件
44
+ * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
45
+ */
46
+ removeEvents(): void;
47
+ beforeDestroy(): void;
48
+ /**
49
+ * 触发自定义事件
50
+ * @param name 事件名称
51
+ * @param eventOption 自定义事件配置选项, 默认: bubbles: true
52
+ * @returns 是否成功触发事件
53
+ */
54
+ emit(name: string, eventOption: Partial<CustomEventInit>): boolean;
34
55
  }
package/lib/base.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { getAttr as r } from "ph-utils/dom";
2
- class a extends HTMLElement {
2
+ class i extends HTMLElement {
3
3
  static baseName = "base-component";
4
4
  /** 组件是否渲染完成, 是否已经调用 connectedCallback */
5
5
  rendered = !1;
6
- constructor(t = !0) {
7
- super(), t && this.attachShadow({ mode: "open" });
6
+ constructor(t = !0, e = {}) {
7
+ super(), t && this.attachShadow({ mode: "open", ...e });
8
8
  }
9
9
  /**
10
10
  * 返回一个数组,表示观察的属性列表
@@ -13,8 +13,9 @@ class a extends HTMLElement {
13
13
  return [];
14
14
  }
15
15
  // 当属性发生变化时调用的回调函数
16
- attributeChangedCallback(t, e, n) {
16
+ attributeChangedCallback(t, e, o) {
17
17
  }
18
+ /** @deprecated */
18
19
  get shadow() {
19
20
  return this.shadowRoot;
20
21
  }
@@ -40,18 +41,46 @@ class a extends HTMLElement {
40
41
  if (t)
41
42
  if (typeof t == "string") {
42
43
  let e = document.createElement("div");
43
- e.innerHTML = t, this.root.append(...e.children), e = void 0;
44
+ e.innerHTML = t, this.root.append(...e.childNodes), e = void 0;
44
45
  } else t.length ? this.root.append(...t) : this.root.append(t);
45
46
  }
46
47
  connectedCallback() {
47
- this.appendToRoot(this.render()), this.rendered = !0;
48
+ this.appendToRoot(this.render()), this.initEvents(), this.afterInit(), this.rendered = !0;
48
49
  }
49
50
  disconnectedCallback() {
50
- this.root.innerHTML = "", this.rendered = !1;
51
+ this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
51
52
  }
52
53
  render() {
53
54
  }
55
+ /**
56
+ * 初始化事件
57
+ * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
58
+ */
59
+ initEvents() {
60
+ }
61
+ afterInit() {
62
+ }
63
+ /** 移除事件 */
64
+ /**
65
+ * 移除事件
66
+ * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
67
+ */
68
+ removeEvents() {
69
+ }
70
+ beforeDestroy() {
71
+ }
72
+ /**
73
+ * 触发自定义事件
74
+ * @param name 事件名称
75
+ * @param eventOption 自定义事件配置选项, 默认: bubbles: true
76
+ * @returns 是否成功触发事件
77
+ */
78
+ emit(t, e) {
79
+ return this.dispatchEvent(
80
+ new CustomEvent(t, { bubbles: !0, composed: !1, ...e })
81
+ );
82
+ }
54
83
  }
55
84
  export {
56
- a as default
85
+ i as default
57
86
  };
@@ -2,7 +2,9 @@ import BaseComponent from "../base";
2
2
  export default class Button extends BaseComponent {
3
3
  static baseName: string;
4
4
  htmlType: "submit" | "reset" | "button";
5
- constructor();
5
+ /** 加载中文本 */
6
+ loadingText: string;
7
+ disabled: boolean;
6
8
  static get observedAttributes(): string[];
7
9
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
8
10
  connectedCallback(): void;
@@ -1,15 +1,15 @@
1
- import { initAttr as s, parseAttrValue as c } from "../utils/index.js";
2
- import d from "../base.js";
3
- import { $one as h, addClass as g, removeClass as p, on as v, off as f, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
4
- import { adjust as b } from "ph-utils/color";
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";
5
5
  import { a as x } from "../animation-DttknHkX.js";
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}.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:var(--l-form-edit-height, 32px);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:not(.l-btn-loading):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-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;height:auto;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-block{width:100%}.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 w extends d {
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 {
8
8
  static baseName = "button";
9
9
  htmlType = "button";
10
- constructor() {
11
- super(), s(this);
12
- }
10
+ /** 加载中文本 */
11
+ loadingText = "";
12
+ disabled = !1;
13
13
  // 初始化属性观察器
14
14
  static get observedAttributes() {
15
15
  return ["loading", "color", "disabled"];
@@ -19,40 +19,39 @@ class w extends d {
19
19
  const l = h(".l-btn", this.root);
20
20
  if (l)
21
21
  if (r === "loading")
22
- c(o, !1, r) ? (g(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (p(l, "l-btn-loading"), l.disabled = this.getAttr("disabled", !1), l.innerHTML = "<slot></slot>");
22
+ 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
23
  else if (r === "color") {
24
24
  const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
25
25
  l.style.cssText = this.applyColor(o, e, n);
26
- } else r === "disabled" && (l.disabled = this.getAttr("disabled", !1));
26
+ } else r === "disabled" && (l.disabled = b(o, !1, "disabled"));
27
27
  }
28
28
  connectedCallback() {
29
- this.loadStyleText([y, x]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
29
+ s(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
30
30
  }
31
31
  disconnectedCallback() {
32
- super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && f(this, "click", this._handleClick);
32
+ super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
33
33
  }
34
34
  render() {
35
- const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1), i = [
35
+ const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1), d = [
36
36
  "l-btn",
37
37
  `l-btn-${r}`,
38
- this.getAttr("block", !1) ? "l-btn-block" : "",
39
38
  l === "round" ? "l-btn-round" : "",
40
39
  l === "circle" ? "l-btn-circle" : "",
41
40
  n ? "l-btn-ghost" : "",
42
41
  e ? "l-btn-text" : "",
43
42
  o ? "l-btn-loading" : ""
44
43
  ];
45
- t.className = u(i), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
44
+ t.className = u(d), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
46
45
  const a = this.applyColor(this.getAttr("color"), e, n);
47
46
  a && (t.style.cssText = a), o ? t.innerHTML = this.loadingBody() : t.innerHTML = "<slot></slot>", t.setAttribute("part", "default"), this.root.appendChild(t);
48
47
  }
49
48
  loadingBody() {
50
49
  const r = this.getAttr("loading-text", ""), t = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
51
- return r === "" ? t.push("<slot></slot>") : t.push(`<span>${r}</span>`), t.join("");
50
+ return r ? t.push(`<span>${r}</span>`) : t.push("<slot></slot>"), t.join("");
52
51
  }
53
52
  applyColor(r, t = !1, o = !1) {
54
53
  if (!r) return "";
55
- const l = b(r, 1, !0), e = b(r, 3, !1);
54
+ const l = i(r, 1, !0), e = i(r, 3, !1);
56
55
  return m({
57
56
  "--l-btn-border-color": t ? "transparent" : r,
58
57
  "--l-btn-text-color": o || t ? r : "#ffffff",
@@ -87,5 +86,5 @@ class w extends d {
87
86
  }
88
87
  }
89
88
  export {
90
- w as default
89
+ M as default
91
90
  };
@@ -1,7 +1,7 @@
1
1
  import { $one as i, on as s, off as a } from "ph-utils/dom";
2
2
  import c from "../form/form_inner.js";
3
3
  import { initAttr as r, setAttrs as n } from "../utils/index.js";
4
- import { i as l } from "../index-391POYEJ.js";
4
+ import { i as l } from "../index-dwS1N2uN.js";
5
5
  const o = ":host{--l-input-width: 60px}";
6
6
  class m extends c {
7
7
  static baseName = "color-picker";
@@ -0,0 +1,22 @@
1
+ import FormInner from "../form/form_inner";
2
+ export default class DatePicker extends FormInner {
3
+ #private;
4
+ static baseName: string;
5
+ /** 是否显示日期范围选择 */
6
+ range: boolean;
7
+ /** 范围选择器时,为了性能考虑, 立即改变一个日期后,会延迟 300ms 通知, 以响应其它选择器, 0 - 立即触发 */
8
+ emitTimeout: number;
9
+ /** 原生 type 属性 */
10
+ type: "date" | "datetime-local" | "time" | "month" | "week";
11
+ width?: string;
12
+ /** 日期范围 */
13
+ min?: string;
14
+ max?: string;
15
+ allowEmpty: boolean;
16
+ set value(value: string);
17
+ connectedCallback(): void;
18
+ afterInit(): void;
19
+ beforeDestroy(): void;
20
+ protected attributeChange(name: string, oldValue: string, newValue: string): void;
21
+ render(): DocumentFragment;
22
+ }
@@ -0,0 +1,99 @@
1
+ import { initAttr as l } from "../utils/index.js";
2
+ import n from "../form/form_inner.js";
3
+ import { iterate as o, formatStyle as d, $ as c, on as a, off as r, $$ as h } from "ph-utils/dom";
4
+ import { parse as m } from "ph-utils/date";
5
+ const u = ":host{display:inline-flex;align-items:center;width:var(--l-date-picker-width, auto)}.l-date-inner{height:var(--l-form-edit-height, 32px);border-radius:3px;outline:none;border:1px solid var(--l-border-color, #dedede);cursor:text;padding:0 5px;flex-grow:1;transition:border-color .3s}.l-date-inner:hover{border-color:var(--l-primary-color-light1, #9254de)}.l-date-inner:focus{border-color:var(--l-primary-color, #722ed1)}.l-date-range-divider{margin:0 10px}";
6
+ class y extends n {
7
+ static baseName = "date-picker";
8
+ /** 是否显示日期范围选择 */
9
+ range = !1;
10
+ /** 范围选择器时,为了性能考虑, 立即改变一个日期后,会延迟 300ms 通知, 以响应其它选择器, 0 - 立即触发 */
11
+ emitTimeout = 300;
12
+ /** 原生 type 属性 */
13
+ type = "date";
14
+ width;
15
+ /** 日期范围 */
16
+ min;
17
+ max;
18
+ allowEmpty = !0;
19
+ #t = [];
20
+ #e = [];
21
+ #i = -1;
22
+ // 至上一次触发change后,是否有更改
23
+ #s = !1;
24
+ set value(t) {
25
+ this.setValue(t), this.#e = t.split(","), o(this.#t, (i, e) => {
26
+ i.value = this.#e[e];
27
+ });
28
+ }
29
+ connectedCallback() {
30
+ l(this), this.loadStyleText(u);
31
+ const t = {};
32
+ this.width && (t["--l-date-picker-width"] = this.width), this.style.cssText = d(t), super.connectedCallback();
33
+ }
34
+ afterInit() {
35
+ this.#t = c(".l-date-inner", this.root), a(this.#t, "change", this.#h), this.range && (a(this.#t, "focus", this.#n), a(this.#t, "blur", this.#o));
36
+ }
37
+ beforeDestroy() {
38
+ r(this.#t, "change", this.#h), this.range && (r(this.#t, "focus", this.#n), r(this.#t, "blur", this.#o)), this.#a();
39
+ }
40
+ attributeChange(t, i, e) {
41
+ t === "value" && e !== this._value && (this.value = e);
42
+ }
43
+ render() {
44
+ const t = document.createDocumentFragment();
45
+ if (t.appendChild(this.#r(0)), this.range) {
46
+ const i = h("span", {
47
+ class: "l-date-range-divider",
48
+ textContent: "-"
49
+ });
50
+ t.appendChild(i), t.appendChild(this.#r(1));
51
+ }
52
+ return t;
53
+ }
54
+ #r(t = 0) {
55
+ return h("input", {
56
+ type: this.type,
57
+ class: `l-date-inner l-date-inner${t}`,
58
+ name: this.getName(),
59
+ value: this.#e[t],
60
+ "l-datepicker": `${t}`,
61
+ disabled: this.isDisabled(),
62
+ min: this.min,
63
+ max: this.max
64
+ });
65
+ }
66
+ #h = (t) => {
67
+ const i = t.target, e = Number(i.getAttribute("l-datepicker"));
68
+ let s = i.value;
69
+ !s && !this.allowEmpty && (s = this._resetValue || "", s = s.split(",")[e], i.value = s), this.#e[e] = s, this.#e.join(",") !== this._value && (this.setValue(this.#e.join(",")), this.#s = !0), e === 0 && this.#t.length > 1 ? this.#t[1].min = s : e === 1 && (this.#t[0].max = s), this.range ? this.#l() : this.#d();
70
+ };
71
+ #a() {
72
+ this.#i !== -1 && (clearTimeout(this.#i), this.#i = -1);
73
+ }
74
+ #l() {
75
+ this.#s && (this.#a(), this.#i = setTimeout(() => {
76
+ this.#d(), this.#s = !1;
77
+ }, this.emitTimeout));
78
+ }
79
+ #n = () => {
80
+ this.#a();
81
+ };
82
+ #o = () => {
83
+ this.#l();
84
+ };
85
+ #d() {
86
+ this.dispatchEvent(
87
+ new CustomEvent("change", {
88
+ detail: {
89
+ value: this.getValue(),
90
+ dateStr: this.#e,
91
+ dates: this.#e.map((t) => m(t))
92
+ }
93
+ })
94
+ );
95
+ }
96
+ }
97
+ export {
98
+ y as default
99
+ };
@@ -0,0 +1,28 @@
1
+ import BaseComponent from "../base";
2
+ export default class DialogContainer extends BaseComponent {
3
+ #private;
4
+ static baseName: string;
5
+ /** 是否显示标题栏 */
6
+ showHeader: boolean;
7
+ /** 头部内容 */
8
+ header?: string;
9
+ /** 是否显示底部 */
10
+ showFooter: boolean;
11
+ /** 是否显示取消按钮 */
12
+ showCancel: boolean;
13
+ /** 取消按钮文本 */
14
+ cancelText: string;
15
+ /** 是否显示确定按钮 */
16
+ showOk: boolean;
17
+ /** 确定按钮文本 */
18
+ okText: string;
19
+ /** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
20
+ showClose: number;
21
+ containerClass?: string;
22
+ connectedCallback(): void;
23
+ initEvents(): void;
24
+ removeEvents(): void;
25
+ static get observedAttributes(): string[] | null | undefined;
26
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
27
+ render(): HTMLElement[];
28
+ }
@@ -0,0 +1,100 @@
1
+ import p from "../base.js";
2
+ import { $ as d, iterate as c, on as r, off as h, shouldEventNext as g, $one as f, $$ as e, formatClass as u } from "ph-utils/dom";
3
+ import { initAttr as x } from "../utils/index.js";
4
+ const C = ":host{display:block;position:relative}:host(.l-container-close-outside){padding-top:10px;padding-right:10px}.l-dialog-main{box-shadow:0 0 8px #0000001a;border-radius:5px;background-color:#fff}.l-dialog-header{padding:10px;font-size:16px;border-bottom:1px solid var(--l-dialog-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-dialog-footer{padding:10px;border-top:1px solid var(--l-dialog-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-dialog-container{padding:15px 10px;font-size:14px}.l-btn-dialog-close{--l-form-edit-height: auto;position:absolute}.l-dialog-close1{right:5px;top:6px}.l-dialog-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-dialog-close2{right:0;top:0}.l-dialog-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}";
5
+ class k extends p {
6
+ static baseName = "dialog-container";
7
+ /** 是否显示标题栏 */
8
+ showHeader = !0;
9
+ /** 头部内容 */
10
+ header;
11
+ /** 是否显示底部 */
12
+ showFooter = !0;
13
+ /** 是否显示取消按钮 */
14
+ showCancel = !0;
15
+ /** 取消按钮文本 */
16
+ cancelText = "取消";
17
+ /** 是否显示确定按钮 */
18
+ showOk = !0;
19
+ /** 确定按钮文本 */
20
+ okText = "确定";
21
+ /** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
22
+ showClose = 1;
23
+ containerClass;
24
+ connectedCallback() {
25
+ this.loadStyleText(C), x(this), this.showClose === 2 && this.classList.add("l-container-close-outside"), super.connectedCallback();
26
+ }
27
+ initEvents() {
28
+ const t = d("[data-action]", this.root);
29
+ c(t, (o) => {
30
+ r(o, "click", this.#t);
31
+ });
32
+ }
33
+ removeEvents() {
34
+ const t = d("[data-action]", this.root);
35
+ c(t, (o) => {
36
+ h(o, "click", this.#t);
37
+ });
38
+ }
39
+ #t(t) {
40
+ const [o, i] = g(t, "data-action");
41
+ o && this.dispatchEvent(
42
+ new CustomEvent("dialogAction", {
43
+ detail: { action: i },
44
+ composed: !0
45
+ })
46
+ );
47
+ }
48
+ static get observedAttributes() {
49
+ return ["show-close"];
50
+ }
51
+ attributeChangedCallback(t, o, i) {
52
+ switch (t) {
53
+ case "show-close":
54
+ this.showClose = Number(i), this.showClose === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
55
+ let s = f(".l-btn-dialog-close", this.root);
56
+ this.showClose === 0 && s ? (h(s, "click", this.#t), s.remove()) : s ? s.className = this.#o() : (s = this.#e(), r(s, "click", this.#t), this.root.appendChild(s));
57
+ break;
58
+ }
59
+ }
60
+ #o() {
61
+ return `l-btn-dialog-close l-dialog-close${this.showClose}`;
62
+ }
63
+ #e() {
64
+ const t = e("l-button", {
65
+ shape: "circle",
66
+ type: "normal",
67
+ class: this.#o(),
68
+ "data-action": "close"
69
+ }), o = e("l-close-icon");
70
+ return t.appendChild(o), t;
71
+ }
72
+ render() {
73
+ const t = [];
74
+ this.showClose !== 0 && t.push(this.#e());
75
+ const o = e("div", { class: "l-dialog-main" });
76
+ if (this.showHeader) {
77
+ const l = e("header", { class: "l-dialog-header" }), a = e("slot", { name: "header" });
78
+ a.textContent = this.header || "", l.appendChild(a), o.appendChild(l);
79
+ }
80
+ const i = e("div", {
81
+ class: u(["l-dialog-container", this.containerClass])
82
+ }), s = e("slot");
83
+ if (i.appendChild(s), o.appendChild(i), this.showFooter) {
84
+ const l = e("div", { class: "l-dialog-footer" }), a = e("slot", { name: "footer" });
85
+ if (this.showCancel) {
86
+ const n = e("l-button", { "data-action": "cancel" });
87
+ n.textContent = this.cancelText, a.appendChild(n);
88
+ }
89
+ if (this.showOk) {
90
+ const n = e("l-button", { type: "primary", "data-action": "ok" });
91
+ n.textContent = this.okText, a.appendChild(n);
92
+ }
93
+ l.appendChild(a), o.appendChild(l);
94
+ }
95
+ return t.push(o), t;
96
+ }
97
+ }
98
+ export {
99
+ k as default
100
+ };
@@ -0,0 +1,30 @@
1
+ type DialogProps = {
2
+ /** 对话框在垂直方向位置 */
3
+ verticalAlign?: "top" | "bottom" | "middle";
4
+ /** css translate, 例如: 0,0,0 -> translate3d(0,0,0) */
5
+ translate?: string;
6
+ /** 对话框宽度 */
7
+ width?: string;
8
+ /** 是否在点击 esc 时关闭弹窗 */
9
+ escClose?: boolean;
10
+ /** 是否可以通过点击 mask 关闭对话框 */
11
+ maskClosable?: boolean;
12
+ /** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
13
+ showClose?: number;
14
+ };
15
+ /** 初始化对话框配置 */
16
+ type DialogInitialParams = DialogProps & {
17
+ /** dialog 节点 */
18
+ el: HTMLDialogElement | string;
19
+ /** 返回 true 表明手动调用 done 关闭 */
20
+ onAction?: (action: string, done: () => void) => boolean;
21
+ };
22
+ declare const Dialog: (option?: DialogInitialParams) => {
23
+ init: (option: DialogInitialParams) => void;
24
+ open: () => void;
25
+ close: () => void;
26
+ destroy: () => void;
27
+ setProp: (key: keyof DialogProps, value: DialogProps[keyof DialogProps]) => void;
28
+ setProps: (props: DialogProps) => void;
29
+ };
30
+ export default Dialog;
@@ -0,0 +1,86 @@
1
+ import { $one as C, hasClass as v, addClass as s, getAttr as a, on as c, off as f, removeClass as $ } from "ph-utils/dom";
2
+ const D = (g) => {
3
+ let t, l, i;
4
+ function w(e) {
5
+ e.code === "Escape" && (e.preventDefault(), n());
6
+ }
7
+ function h(e) {
8
+ t.isSameNode(e.target) && i && i.maskClosable && n();
9
+ }
10
+ function p(e) {
11
+ const o = e.detail.action;
12
+ i.onAction != null && i.onAction(o, n);
13
+ }
14
+ function u(e) {
15
+ if (!i) {
16
+ let o = {
17
+ escClose: !0,
18
+ verticalAlign: "top",
19
+ maskClosable: !0,
20
+ showClose: 1,
21
+ ...e
22
+ };
23
+ if (t = C(e.el), t) {
24
+ v(t, "l-dialog") || s(t, "l-dialog"), l = C("l-dialog-container", t);
25
+ const r = a(t, "vertical-align");
26
+ o.verticalAlign = r || "top", s(t, `l-dialog--vertical-${o.verticalAlign}`);
27
+ const m = a(t, "translate") || o.translate;
28
+ m && t.style.setProperty(
29
+ "--l-dialog-translate",
30
+ `translate3d(${m})`
31
+ );
32
+ const A = a(t, "width") || o.width;
33
+ A && t.style.setProperty("--l-dialog-width", A);
34
+ const d = a(t, "show-close", 1);
35
+ d === 2 && s(t, "l-dialog-close-outside"), l && l.setAttribute("show-close", `${d}`), o.showClose = d, c(t, "keydown", w), c(t, "click", h), l && c(l, "dialogAction", p);
36
+ }
37
+ i = o;
38
+ }
39
+ }
40
+ function b() {
41
+ t && (t.showModal(), s(t, "l-dialog--open"), s(document.body, "l-body--dialog-open"));
42
+ }
43
+ function n() {
44
+ t && v(t, "l-dialog--open") && (c(
45
+ t,
46
+ "transitionend",
47
+ () => {
48
+ t.close(), $(document.body, "l-body--dialog-open");
49
+ },
50
+ { once: !0 }
51
+ ), $(t, "l-dialog--open"));
52
+ }
53
+ function P() {
54
+ t && (n(), f(t, "keydown", w), f(t, "click", h), l && f(l, "dialogAction", p), l = void 0, t = void 0);
55
+ }
56
+ function y(e, o) {
57
+ if (i && (i[e] = o, t))
58
+ if (e === "verticalAlign") {
59
+ const r = t.className.replace(
60
+ /l-dialog--vertical-\w+/g,
61
+ function() {
62
+ return `l-dialog--vertical-${o || "top"}`;
63
+ }
64
+ );
65
+ t.className = r;
66
+ } else e === "translate" ? o ? t.style.setProperty(
67
+ "--l-dialog-translate",
68
+ `translate3d(${o})`
69
+ ) : t.style.removeProperty("--l-dialog-translate") : e === "width" ? o ? t.style.setProperty("--l-dialog-width", o) : t.style.removeProperty("--l-dialog-width") : e === "showClose" && l && l.setAttribute("show-close", `${o}`);
70
+ }
71
+ function k(e) {
72
+ for (const o in e)
73
+ y(o, e[o]);
74
+ }
75
+ return g != null && u(g), {
76
+ init: u,
77
+ open: b,
78
+ close: n,
79
+ destroy: P,
80
+ setProp: y,
81
+ setProps: k
82
+ };
83
+ };
84
+ export {
85
+ D as default
86
+ };
@@ -19,15 +19,20 @@ export default class FormInner extends BaseComponent {
19
19
  getValue(): any;
20
20
  static get observedAttributes(): string[];
21
21
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
22
- protected attributeChange(name: string, oldValue: string, newValue: string): void;
22
+ protected attributeChange(_name: string, _oldValue: string, _newValue: string): void;
23
23
  connectedCallback(): void;
24
24
  disconnectedCallback(): void;
25
25
  isDisabled(): any;
26
26
  getName(): any;
27
27
  private _getForm;
28
28
  private _formAttributeChanged;
29
- /** disable 属性改变时回调 */
29
+ /** */
30
+ /**
31
+ * disable 属性改变时回调
32
+ * @deprecated 使用 disabledChange 代替
33
+ */
30
34
  protected _changeDisabled(): void;
35
+ protected disabledChange(): void;
31
36
  protected pushValueChange(): void;
32
37
  private _resetFieldValue;
33
38
  reset(): void;