litos-ui 0.11.1 → 0.12.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 (50) hide show
  1. package/README.md +48 -0
  2. package/lib/base.d.ts +11 -2
  3. package/lib/base.js +18 -7
  4. package/lib/button/index.d.ts +3 -2
  5. package/lib/button/index.js +18 -19
  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.js +1 -1
  9. package/lib/form/form_inner.d.ts +7 -2
  10. package/lib/form/form_inner.js +26 -20
  11. package/lib/form/form_item.d.ts +0 -2
  12. package/lib/form/form_item.js +5 -9
  13. package/lib/form/index.d.ts +0 -2
  14. package/lib/form/index.js +23 -25
  15. package/lib/icon/base.d.ts +0 -1
  16. package/lib/icon/base.js +15 -17
  17. package/lib/index.d.ts +10 -0
  18. package/lib/index.js +92 -82
  19. package/lib/input/index.d.ts +1 -3
  20. package/lib/input/index.js +4 -8
  21. package/lib/loading/index.d.ts +9 -4
  22. package/lib/loading/index.js +70 -64
  23. package/lib/menu/base.js +1 -0
  24. package/lib/menu/index.d.ts +29 -0
  25. package/lib/menu/index.js +90 -0
  26. package/lib/menu/menu_item.d.ts +6 -0
  27. package/lib/menu/menu_item.js +21 -0
  28. package/lib/menu/sub_menu.d.ts +13 -0
  29. package/lib/menu/sub_menu.js +64 -0
  30. package/lib/modal/index.d.ts +40 -0
  31. package/lib/modal/index.js +153 -0
  32. package/lib/modal/modal_box.js +95 -0
  33. package/lib/popover/index.d.ts +1 -4
  34. package/lib/popover/index.js +6 -12
  35. package/lib/radio/index.js +2 -2
  36. package/lib/select_ori/index.d.ts +0 -2
  37. package/lib/select_ori/index.js +11 -15
  38. package/lib/switch/index.d.ts +0 -1
  39. package/lib/switch/index.js +8 -13
  40. package/lib/tabbar/index.d.ts +0 -1
  41. package/lib/tabbar/index.js +55 -63
  42. package/lib/theme/index.d.ts +1 -2
  43. package/lib/theme/index.js +9 -12
  44. package/lib/utils/index.js +29 -29
  45. package/lib/utils/transition.js +3 -2
  46. package/package.json +12 -13
  47. package/styles/loading.css +58 -14
  48. package/styles/message.css +1 -1
  49. package/styles/modal_box.css +7 -0
  50. package/styles/vars.css +1 -0
package/README.md CHANGED
@@ -1 +1,49 @@
1
1
  # litos-ui
2
+
3
+ 源自于希腊语中,表示“简洁、朴素”的形容词 "λιτός" (`litós`);所有组件均以 `l-` 为前缀,如 `l-button`、`l-input` 等。
4
+
5
+ 采用原生 `Web Components` 作为技术栈,不依赖任何第三方库,可运行在现代浏览器上。跨平台、跨框架,可运行在 `React`、`Vue`、`Angular` 等框架中。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install litos-ui
11
+ ```
12
+
13
+ 如果需要自动使用一些服务组件,例如: `Message`、`ModalBox` 等且需要自动引入样式时,需要安装 `litosui-unplugin-resolver`、`unplugin-auto-import` 插件。
14
+
15
+ ```js
16
+ // vite.config.js
17
+ import AutoImport from "unplugin-auto-import/vite";
18
+ import LitosuiResolver from "litosui-unplugin-resolver";
19
+
20
+ // https://vitejs.dev/config/
21
+ export default defineConfig({
22
+ plugins: [
23
+ ...,
24
+ AutoImport({
25
+ resolvers: [LitosuiResolver()],
26
+ dts: "src/auto-imports.d.ts",
27
+ }),
28
+ ],
29
+ ...
30
+ });
31
+ ```
32
+
33
+ ## 使用
34
+
35
+ 引入相关组件并注册
36
+
37
+ ```js
38
+ import { Button, regist } from "litos-ui";
39
+
40
+ regist([Button]); // <l-button></l-button>
41
+ ```
42
+
43
+ ## 文档
44
+
45
+ [litos-ui 文档](https://dvshu.github.io/litos-ui/)
46
+
47
+ ## 许可证
48
+
49
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
package/lib/base.d.ts CHANGED
@@ -7,7 +7,7 @@ export default class BaseComponent extends HTMLElement {
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
11
  get shadow(): ShadowRoot;
12
12
  get root(): ShadowRoot | HTMLElement;
13
13
  createStyle(text: string): void;
@@ -31,8 +31,17 @@ export default class BaseComponent extends HTMLElement {
31
31
  connectedCallback(): void;
32
32
  disconnectedCallback(): void;
33
33
  render(): void | string | HTMLElement | HTMLElement[] | DocumentFragment;
34
- /** 初始化事件 */
34
+ /**
35
+ * 初始化事件
36
+ * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
37
+ */
35
38
  initEvents(): void;
39
+ afterInit(): void;
36
40
  /** 移除事件 */
41
+ /**
42
+ * 移除事件
43
+ * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
44
+ */
37
45
  removeEvents(): void;
46
+ beforeDestroy(): void;
38
47
  }
package/lib/base.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getAttr as n } from "ph-utils/dom";
1
+ import { getAttr as r } from "ph-utils/dom";
2
2
  class i extends HTMLElement {
3
3
  static baseName = "base-component";
4
4
  /** 组件是否渲染完成, 是否已经调用 connectedCallback */
@@ -13,7 +13,7 @@ class i extends HTMLElement {
13
13
  return [];
14
14
  }
15
15
  // 当属性发生变化时调用的回调函数
16
- attributeChangedCallback(t, e, o) {
16
+ attributeChangedCallback(t, e, n) {
17
17
  }
18
18
  get shadow() {
19
19
  return this.shadowRoot;
@@ -34,29 +34,40 @@ class i extends HTMLElement {
34
34
  Array.isArray(e) && (e = e.join("")), this.createStyle(e);
35
35
  }
36
36
  getAttr(t, e) {
37
- return n(this, t, e);
37
+ return r(this, t, e);
38
38
  }
39
39
  appendToRoot(t) {
40
40
  if (t)
41
41
  if (typeof t == "string") {
42
42
  let e = document.createElement("div");
43
- e.innerHTML = t, this.root.append(...e.children), e = void 0;
43
+ e.innerHTML = t, this.root.append(...e.childNodes), e = void 0;
44
44
  } else t.length ? this.root.append(...t) : this.root.append(t);
45
45
  }
46
46
  connectedCallback() {
47
- this.appendToRoot(this.render()), this.initEvents(), this.rendered = !0;
47
+ this.appendToRoot(this.render()), this.initEvents(), this.afterInit(), this.rendered = !0;
48
48
  }
49
49
  disconnectedCallback() {
50
- this.removeEvents(), this.root.innerHTML = "", this.rendered = !1;
50
+ this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
51
51
  }
52
52
  render() {
53
53
  }
54
- /** 初始化事件 */
54
+ /**
55
+ * 初始化事件
56
+ * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
57
+ */
55
58
  initEvents() {
56
59
  }
60
+ afterInit() {
61
+ }
57
62
  /** 移除事件 */
63
+ /**
64
+ * 移除事件
65
+ * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
66
+ */
58
67
  removeEvents() {
59
68
  }
69
+ beforeDestroy() {
70
+ }
60
71
  }
61
72
  export {
62
73
  i as default
@@ -1,9 +1,10 @@
1
1
  import BaseComponent from "../base";
2
2
  export default class Button extends BaseComponent {
3
3
  static baseName: string;
4
- static tagName: string;
5
4
  htmlType: "submit" | "reset" | "button";
6
- constructor();
5
+ /** 加载中文本 */
6
+ loadingText: string;
7
+ disabled: boolean;
7
8
  static get observedAttributes(): string[];
8
9
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
9
10
  connectedCallback(): void;
@@ -1,16 +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;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: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: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
- static tagName = "l-button";
10
9
  htmlType = "button";
11
- constructor() {
12
- super(), s(this);
13
- }
10
+ /** 加载中文本 */
11
+ loadingText = "";
12
+ disabled = !1;
14
13
  // 初始化属性观察器
15
14
  static get observedAttributes() {
16
15
  return ["loading", "color", "disabled"];
@@ -20,20 +19,20 @@ class w extends d {
20
19
  const l = h(".l-btn", this.root);
21
20
  if (l)
22
21
  if (r === "loading")
23
- 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>");
24
23
  else if (r === "color") {
25
24
  const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
26
25
  l.style.cssText = this.applyColor(o, e, n);
27
- } else r === "disabled" && (l.disabled = this.getAttr("disabled", !1));
26
+ } else r === "disabled" && (l.disabled = b(o, !1, "disabled"));
28
27
  }
29
28
  connectedCallback() {
30
- 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);
31
30
  }
32
31
  disconnectedCallback() {
33
- 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);
34
33
  }
35
34
  render() {
36
- 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 = [
37
36
  "l-btn",
38
37
  `l-btn-${r}`,
39
38
  l === "round" ? "l-btn-round" : "",
@@ -42,17 +41,17 @@ class w extends d {
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
  };
@@ -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
+ };
@@ -1,7 +1,7 @@
1
1
  import p from "../base.js";
2
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
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{--nt-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}";
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
5
  class k extends p {
6
6
  static baseName = "dialog-container";
7
7
  /** 是否显示标题栏 */
@@ -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;
@@ -1,7 +1,7 @@
1
- import d from "../base.js";
1
+ import n from "../base.js";
2
2
  import { parseAttrValue as u } from "../utils/index.js";
3
- import { add as l, remove as n, emit as o } from "../utils/event.js";
4
- class b extends d {
3
+ import { add as l, remove as d, emit as o } from "../utils/event.js";
4
+ class A extends n {
5
5
  disabled = !1;
6
6
  name = void 0;
7
7
  formAttrs = {};
@@ -32,15 +32,15 @@ class b extends d {
32
32
  static get observedAttributes() {
33
33
  return ["disabled"];
34
34
  }
35
- attributeChangedCallback(t, e, r) {
35
+ attributeChangedCallback(t, e, s) {
36
36
  if (this.rendered)
37
37
  if (t === "disabled") {
38
- const i = u(r, !1, t);
39
- i !== this.disabled && (this._changeDisabled(), this.disabled = i);
38
+ const i = u(s, !1, t);
39
+ i !== this.disabled && (this._changeDisabled(), this.disabledChange(), this.disabled = i);
40
40
  } else
41
- this.attributeChange(t, e, r);
41
+ this.attributeChange(t, e, s);
42
42
  }
43
- attributeChange(t, e, r) {
43
+ attributeChange(t, e, s) {
44
44
  }
45
45
  connectedCallback() {
46
46
  const t = this._getForm();
@@ -51,7 +51,7 @@ class b extends d {
51
51
  ), super.connectedCallback();
52
52
  }
53
53
  disconnectedCallback() {
54
- this.formAttrs.id && (n(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), n(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && n(
54
+ this.formAttrs.id && (d(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), d(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && d(
55
55
  this.formItemAttrs.id,
56
56
  "attributeChanged",
57
57
  this._formAttributeChanged
@@ -64,13 +64,13 @@ class b extends d {
64
64
  return this.name ? this.name : this.formItemAttrs.name;
65
65
  }
66
66
  _getForm() {
67
- let t = this.parentElement, e = {}, r = {};
67
+ let t = this.parentElement, e = {}, s = {};
68
68
  for (; t != null; ) {
69
69
  const i = t.tagName;
70
70
  if (i === "L-FORM") {
71
71
  const a = t.sharedAttrs;
72
- for (let s = 0; s < a.length; s++) {
73
- const h = a[s];
72
+ for (let r = 0; r < a.length; r++) {
73
+ const h = a[r];
74
74
  e[h] = t[h];
75
75
  }
76
76
  break;
@@ -78,24 +78,30 @@ class b extends d {
78
78
  if (i === "BODY") break;
79
79
  if (i === "L-FORM-ITEM") {
80
80
  const a = t.sharedAttrs;
81
- for (let s = 0; s < a.length; s++) {
82
- const h = a[s];
83
- r[h] = t[h];
81
+ for (let r = 0; r < a.length; r++) {
82
+ const h = a[r];
83
+ s[h] = t[h];
84
84
  }
85
85
  }
86
86
  t = t.parentElement;
87
87
  }
88
88
  return t = null, {
89
89
  formAttr: e,
90
- formItemAttr: r
90
+ formItemAttr: s
91
91
  };
92
92
  }
93
- _formAttributeChanged = (t, e, r) => {
94
- r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this._changeDisabled();
93
+ _formAttributeChanged = (t, e, s) => {
94
+ s === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && (this._changeDisabled(), this.disabledChange());
95
95
  };
96
- /** disable 属性改变时回调 */
96
+ /** */
97
+ /**
98
+ * disable 属性改变时回调
99
+ * @deprecated 使用 disabledChange 代替
100
+ */
97
101
  _changeDisabled() {
98
102
  }
103
+ disabledChange() {
104
+ }
99
105
  pushValueChange() {
100
106
  const t = this.getName();
101
107
  this.formAttrs.id && t && o(
@@ -114,5 +120,5 @@ class b extends d {
114
120
  }
115
121
  }
116
122
  export {
117
- b as default
123
+ A as default
118
124
  };
@@ -9,7 +9,6 @@ export default class FormItem extends BaseComponent {
9
9
  error?: string;
10
10
  /** 标签文本 */
11
11
  label?: string;
12
- id: string;
13
12
  /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
14
13
  verify?: string;
15
14
  /** 验证失败错误信息 */
@@ -20,7 +19,6 @@ export default class FormItem extends BaseComponent {
20
19
  innerBlock: boolean;
21
20
  labelPosition?: "left" | "right" | "top";
22
21
  private formId?;
23
- constructor();
24
22
  static get observedAttributes(): string[];
25
23
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
26
24
  connectedCallback(): void;
@@ -1,5 +1,5 @@
1
- import { formatClass as a, $one as i, addClass as n, removeClass as m } from "ph-utils/dom";
2
- import { initAttr as d, parseAttrValue as f } from "../utils/index.js";
1
+ import { formatClass as a, $one as i, addClass as m, removeClass as n } from "ph-utils/dom";
2
+ import { parseAttrValue as d, initAttr as f } from "../utils/index.js";
3
3
  import h from "../base.js";
4
4
  import { emit as o, add as c, clear as p, remove as b } from "../utils/event.js";
5
5
  import { random as s } from "ph-utils";
@@ -13,7 +13,6 @@ class $ extends h {
13
13
  error;
14
14
  /** 标签文本 */
15
15
  label;
16
- id;
17
16
  /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
18
17
  verify;
19
18
  /** 验证失败错误信息 */
@@ -24,9 +23,6 @@ class $ extends h {
24
23
  innerBlock = !1;
25
24
  labelPosition = "right";
26
25
  formId;
27
- constructor() {
28
- super(), d(this), this.id == null && (this.id = `l-fi${s(3)}-${s(6)}`);
29
- }
30
26
  static get observedAttributes() {
31
27
  return ["error", "label", "disabled"];
32
28
  }
@@ -36,12 +32,12 @@ class $ extends h {
36
32
  else if (e === "label")
37
33
  this.label = r, this._updateLabel();
38
34
  else if (e === "disabled") {
39
- const l = f(r, !1, e);
35
+ const l = d(r, !1, e);
40
36
  l !== this.disabled && (o(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
41
37
  }
42
38
  }
43
39
  connectedCallback() {
44
- if (super.connectedCallback(), this.loadStyleText([u]), this.formId = this._getFormId(), this.name && this.formId) {
40
+ if (f(this), this.id == null && (this.id = `l-fi${s(3)}-${s(6)}`), this.loadStyleText([u]), super.connectedCallback(), this.formId = this._getFormId(), this.name && this.formId) {
45
41
  let e = this.verify?.split("|") || [];
46
42
  this.pattern && e.push(new RegExp(this.pattern));
47
43
  const t = {
@@ -91,7 +87,7 @@ class $ extends h {
91
87
  r && r.appendChild(e);
92
88
  }
93
89
  const t = i(".l-form-item", this.root);
94
- t && (this.error ? n(t, "is-error") : m(t, "is-error"));
90
+ t && (this.error ? m(t, "is-error") : n(t, "is-error"));
95
91
  }
96
92
  _updateLabel() {
97
93
  if (!this.rendered) return;
@@ -7,14 +7,12 @@ export default class Form extends BaseComponent {
7
7
  inline: boolean;
8
8
  labelPosition?: "left" | "right" | "top";
9
9
  labelWidth?: string;
10
- id: string;
11
10
  disabled: boolean;
12
11
  sharedAttrs: string[];
13
12
  validator: Validator;
14
13
  innerBlock: boolean;
15
14
  novalidate: boolean;
16
15
  private _data?;
17
- private emit;
18
16
  constructor();
19
17
  static get observedAttributes(): string[];
20
18
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;