litos-ui 0.17.2 → 0.17.3

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.
package/lib/base.d.ts CHANGED
@@ -6,6 +6,8 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
6
6
  protected _pendingUpdate: boolean;
7
7
  protected _pendingTask?: number;
8
8
  protected _changedProperties: Set<string>;
9
+ /** 版本, 1 - 直接调用 render, 2 - 渲染 render_v2 */
10
+ protected version: number;
9
11
  constructor(shadow?: boolean, init?: Partial<ShadowRootInit>);
10
12
  /**
11
13
  * 返回一个数组,表示观察的属性列表
@@ -22,6 +24,7 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
22
24
  createStyle(text: string): void;
23
25
  createLink(href: string): void;
24
26
  loadStyleText(styleText: string | string[]): void;
27
+ styleHtml(styleText: string | string[]): string;
25
28
  /**
26
29
  * 获取属性值
27
30
  * @param key 属性名称
@@ -37,9 +40,18 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
37
40
  getAttr(key: string, defaultValue: boolean): boolean;
38
41
  getAttr<T extends Record<string, string | number | boolean>>(filepath: string, defaultValue: T): T;
39
42
  appendToRoot(el?: HTMLElement | HTMLElement[] | string | DocumentFragment): void;
43
+ appendToRootV2(template?: HTMLElement | string | DocumentFragment, style?: string | string[]): void;
40
44
  connectedCallback(): void;
41
45
  disconnectedCallback(): void;
42
- render(): void | string | HTMLElement | HTMLElement[] | DocumentFragment;
46
+ render(): void | string | HTMLElement | DocumentFragment;
47
+ /**
48
+ * 渲染器
49
+ * @returns [渲染节点,内容, 模板样式]
50
+ */
51
+ render_v2(): {
52
+ template?: string | HTMLElement | DocumentFragment;
53
+ style?: string | string[];
54
+ };
43
55
  /**
44
56
  * 初始化事件
45
57
  * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
package/lib/base.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getAttr as i } from "ph-utils/dom";
1
+ import { getAttr as s } from "ph-utils/dom";
2
2
  class a extends HTMLElement {
3
3
  static baseName = "base-component";
4
4
  /** 组件是否渲染完成, 是否已经调用 connectedCallback */
@@ -11,8 +11,10 @@ class a extends HTMLElement {
11
11
  // 延迟任务id
12
12
  _changedProperties;
13
13
  // 已改变的属性集合
14
+ /** 版本, 1 - 直接调用 render, 2 - 渲染 render_v2 */
15
+ version;
14
16
  constructor(e = !0, t = {}) {
15
- super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({ mode: "open", ...t });
17
+ super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this.version = 1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({ mode: "open", ...t });
16
18
  }
17
19
  /**
18
20
  * 返回一个数组,表示观察的属性列表
@@ -22,7 +24,7 @@ class a extends HTMLElement {
22
24
  }
23
25
  // 当属性发生变化时调用的回调函数
24
26
  attributeChangedCallback(e, t, n) {
25
- t !== n && (this.attributeChanged(e, t, n), this._changedProperties.add(e), this.rendered && this.batchUpdate());
27
+ t !== n && (this._changedProperties.add(e), this.attributeChanged(e, t, n), this.rendered && this.batchUpdate());
26
28
  }
27
29
  attributeChanged(e, t, n) {
28
30
  }
@@ -56,8 +58,12 @@ class a extends HTMLElement {
56
58
  let t = e;
57
59
  Array.isArray(t) && (t = t.join("")), this.createStyle(t);
58
60
  }
61
+ styleHtml(e) {
62
+ let t = e;
63
+ return Array.isArray(t) && (t = t.join("")), `<style>${t}</style>`;
64
+ }
59
65
  getAttr(e, t) {
60
- return i(this, e, t);
66
+ return s(this, e, t);
61
67
  }
62
68
  appendToRoot(e) {
63
69
  if (e)
@@ -66,14 +72,38 @@ class a extends HTMLElement {
66
72
  t.innerHTML = e, this.root.append(...t.childNodes), t = void 0;
67
73
  } else e.length ? this.root.append(...e) : this.root.append(e);
68
74
  }
75
+ appendToRootV2(e, t) {
76
+ const n = [];
77
+ if (t && n.push(this.styleHtml(t)), e)
78
+ if (typeof e == "string")
79
+ n.push(e);
80
+ else {
81
+ let i = document.createElement("div");
82
+ i.appendChild(e), n.push(i.innerHTML), i = void 0;
83
+ }
84
+ this.root.innerHTML = n.join("");
85
+ }
69
86
  connectedCallback() {
70
- this.appendToRoot(this.render()), this.rendered = !0, this.initEvents(), this.afterInit();
87
+ if (this.version === 1)
88
+ this.appendToRoot(this.render());
89
+ else {
90
+ const e = this.render_v2();
91
+ this.appendToRootV2(e.template, e.style);
92
+ }
93
+ this.rendered = !0, this.initEvents(), this.afterInit();
71
94
  }
72
95
  disconnectedCallback() {
73
96
  this.cancelPending(), this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
74
97
  }
75
98
  render() {
76
99
  }
100
+ /**
101
+ * 渲染器
102
+ * @returns [渲染节点,内容, 模板样式]
103
+ */
104
+ render_v2() {
105
+ return {};
106
+ }
77
107
  /**
78
108
  * 初始化事件
79
109
  * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
@@ -0,0 +1,30 @@
1
+ import FormInner from "../form/form_inner";
2
+ type CalendarState = {
3
+ locale: string;
4
+ minDate?: string;
5
+ maxDate?: string;
6
+ };
7
+ export default class Calendar extends FormInner<CalendarState> {
8
+ static baseName: string;
9
+ private _currentDate;
10
+ private _langData;
11
+ private $container?;
12
+ constructor();
13
+ setValue(v: string): void;
14
+ connectedCallback(): void;
15
+ afterInit(): void;
16
+ beforeDestroy(): void;
17
+ static get observedAttributes(): string[];
18
+ protected attributeChanged(name: string, oldValue: string, newValue: string): void;
19
+ protected updateDOM(changedProps: Set<string>): void;
20
+ private _renderHeader;
21
+ private _renderBody;
22
+ rerenderHeader(): void;
23
+ rerenderBody(): void;
24
+ rerender(): string;
25
+ render_v2(): {
26
+ template?: string | HTMLElement | DocumentFragment;
27
+ style?: string | string[];
28
+ };
29
+ }
30
+ export {};
@@ -0,0 +1,91 @@
1
+ import u from "../form/form_inner.js";
2
+ import { kebabToCamel as v } from "../utils/index.js";
3
+ import { parse as x, format as c } from "ph-utils/date";
4
+ import { $one as h } from "ph-utils/dom";
5
+ import { langs as y } from "./langs.js";
6
+ import { get as k } from "ph-utils/storage";
7
+ const w = ":host{display:block;box-sizing:border-box;width:100%;height:100%}.calendar-table{width:100%;height:100%;border-collapse:collapse}.calendar-table thead{height:var(--calendar-header-height, auto)}.calendar-table th{font-weight:400;cursor:default}.calendar-table .prev-month,.calendar-table .next-month{color:var(--l-calendar-off-text-color, #a8abb2)}.calendar-table .today{color:var(--l-primary-color, #007bff)}.day{text-align:center;cursor:pointer;transition:background-color .2s;font-size:13px}.day:hover{background-color:#0000000a}.day.disabled{background-color:#0000000a;cursor:not-allowed}.day.active{background-color:var(--l-primary-color, #007bff);color:#fff;font-weight:700}";
8
+ class A extends u {
9
+ static baseName = "calendar";
10
+ _currentDate;
11
+ _langData;
12
+ $container;
13
+ constructor() {
14
+ super(), this.version = 2, this._currentDate = /* @__PURE__ */ new Date();
15
+ const e = k("l_app_locale", "zh-CN", { storage: "session" });
16
+ this._state = {
17
+ locale: e
18
+ }, this._langData = y[e];
19
+ }
20
+ setValue(e) {
21
+ e != this.value && (super.setValue(e), this._currentDate = x(e), this.rerenderBody());
22
+ }
23
+ connectedCallback() {
24
+ super.connectedCallback();
25
+ }
26
+ afterInit() {
27
+ this.$container = h(".calendar-table", this.root);
28
+ }
29
+ beforeDestroy() {
30
+ this.$container = void 0;
31
+ }
32
+ static get observedAttributes() {
33
+ return [...u.observedAttributes, "locale"];
34
+ }
35
+ attributeChanged(e, r, o) {
36
+ switch (e) {
37
+ case "locale":
38
+ y.hasOwnProperty(o) && (this._state.locale = o, this._langData = y[o]);
39
+ break;
40
+ case "min-date":
41
+ case "max-date":
42
+ this._state[v(e)] = o;
43
+ break;
44
+ }
45
+ }
46
+ updateDOM(e) {
47
+ e.has("locale") && this.rerenderHeader(), this.$container && (this.$container.innerHTML = this.rerender());
48
+ }
49
+ _renderHeader() {
50
+ return `<tr>${this._langData.weekdays.map((r) => `<th>${r}</th>`).join("")}</tr>`;
51
+ }
52
+ _renderBody() {
53
+ const e = this._currentDate.getFullYear(), r = this._currentDate.getMonth(), o = c(null, "yyyy-mm-dd");
54
+ let a = new Date(e, r, 1).getDay() - 1;
55
+ a < 0 && (a = 6);
56
+ const b = new Date(e, r + 1, 0), f = b.getDate(), p = c(b, "yyyy-mm"), m = new Date(e, r, 0), g = m.getDate(), D = c(m, "yyyy-mm"), $ = new Date(e, r + 1, 1), _ = c($, "yyyy-mm");
57
+ let i = "";
58
+ for (let t = 0; t < 42; t++) {
59
+ t % 7 === 0 && (i += "<tr>");
60
+ let n, s = "day", l = "";
61
+ t < a ? (n = `${g - a + t + 1}`, s += " prev-month", l = D) : t < a + f ? (n = `${t - a + 1}`, l = p) : (n = `${t - a - f + 1}`, s += " next-month disabled", l = _);
62
+ const d = `${l}-${n.padStart(2, "0")}`;
63
+ d === o && (s += " today"), d === this.value && (s += " active"), i += `<td class="${s}" title="${d}">${n}</td>`, t % 7 === 6 && (i += "</tr>");
64
+ }
65
+ return i;
66
+ }
67
+ rerenderHeader() {
68
+ if (this.$container) {
69
+ const e = h("thead", this.$container);
70
+ e.innerHTML = this._renderHeader();
71
+ }
72
+ }
73
+ rerenderBody() {
74
+ if (this.$container) {
75
+ const e = h("tbody", this.$container);
76
+ e.innerHTML = this._renderBody();
77
+ }
78
+ }
79
+ rerender() {
80
+ return `<thead>${this._renderHeader()}</thead><tbody>${this._renderBody()}</tbody>`;
81
+ }
82
+ render_v2() {
83
+ return {
84
+ template: `<table class="calendar-table">${this.rerender()}</table>`,
85
+ style: [w]
86
+ };
87
+ }
88
+ }
89
+ export {
90
+ A as default
91
+ };
@@ -0,0 +1,4 @@
1
+ export type LangItem = {
2
+ weekdays: string[];
3
+ };
4
+ export declare const langs: Record<string, LangItem>;
@@ -0,0 +1,8 @@
1
+ const e = {
2
+ "zh-CN": {
3
+ weekdays: ["一", "二", "三", "四", "五", "六", "七"]
4
+ }
5
+ };
6
+ export {
7
+ e as langs
8
+ };
@@ -1,22 +1,30 @@
1
1
  import FormInner from "../form/form_inner";
2
- export default class DatePicker extends FormInner {
3
- #private;
4
- static baseName: string;
2
+ type DateInputType = "date" | "datetime-local" | "time" | "month" | "week";
3
+ type DatePickerOriState = {
5
4
  /** 是否显示日期范围选择 */
6
5
  range: boolean;
7
6
  /** 范围选择器时,为了性能考虑, 立即改变一个日期后,会延迟 300ms 通知, 以响应其它选择器, 0 - 立即触发 */
8
- emitTimeout: number;
9
- /** 原生 type 属性 */
10
- type: "date" | "datetime-local" | "time" | "month" | "week";
7
+ delay: number;
8
+ type: DateInputType;
11
9
  width?: string;
12
10
  /** 日期范围 */
13
11
  min?: string;
14
12
  max?: string;
15
13
  allowEmpty: boolean;
16
- set value(value: string);
14
+ };
15
+ export default class DatePicker extends FormInner {
16
+ #private;
17
+ static baseName: string;
18
+ _state: DatePickerOriState;
19
+ constructor();
20
+ setValue(v: string): void;
21
+ static get observedAttributes(): string[];
17
22
  connectedCallback(): void;
18
23
  afterInit(): void;
19
24
  beforeDestroy(): void;
20
25
  protected attributeChange(name: string, oldValue: string, newValue: string): void;
26
+ protected updateDOM(changedProps: Set<string>): void;
27
+ private _updateWidth;
21
28
  render(): DocumentFragment;
22
29
  }
30
+ export {};
@@ -0,0 +1,129 @@
1
+ import h from "../form/form_inner.js";
2
+ import { iterate as n, $ as o, on as a, off as r, $$ as l } from "ph-utils/dom";
3
+ import { parse as c } from "ph-utils/date";
4
+ import { unitNumberStr as p, parseAttrValue as d, kebabToCamel as u } from "../utils/index.js";
5
+ const m = ":host{display:inline-flex;align-items:center;width:var(--l-date-picker-width, auto)}.l-date-inner{height:var(--l-form-control-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 w extends h {
7
+ static baseName = "date-picker-ori";
8
+ #t;
9
+ #e;
10
+ #i;
11
+ // 至上一次触发change后,是否有更改
12
+ #s;
13
+ _state;
14
+ constructor() {
15
+ super(), this._state = {
16
+ range: !1,
17
+ delay: 300,
18
+ type: "date",
19
+ allowEmpty: !0
20
+ }, this.#e = [], this.#s = !1;
21
+ }
22
+ setValue(t) {
23
+ super.setValue(t), this.#e = t.split(","), this.rendered && n(this.#t, (i, e) => {
24
+ i.value = this.#e[e];
25
+ });
26
+ }
27
+ static get observedAttributes() {
28
+ return [
29
+ ...h.observedAttributes,
30
+ "range",
31
+ "delay",
32
+ "type",
33
+ "width",
34
+ "min",
35
+ "max",
36
+ "allow-empty"
37
+ ];
38
+ }
39
+ connectedCallback() {
40
+ this.loadStyleText(m), this._updateWidth(), super.connectedCallback();
41
+ }
42
+ afterInit() {
43
+ this.#t = o(".l-date-inner", this.root), a(this.#t, "change", this.#h), this._state.range && (a(this.#t, "focus", this.#d), a(this.#t, "blur", this.#n));
44
+ }
45
+ beforeDestroy() {
46
+ r(this.#t, "change", this.#h), this._state.range && (r(this.#t, "focus", this.#d), r(this.#t, "blur", this.#n)), this.#a();
47
+ }
48
+ attributeChange(t, i, e) {
49
+ switch (t) {
50
+ case "type":
51
+ case "min":
52
+ case "max":
53
+ this._state[t] = e;
54
+ break;
55
+ case "range":
56
+ case "allow-empty":
57
+ this._state[u(t)] = d(e, !1, t);
58
+ break;
59
+ case "delay":
60
+ this._state.delay = d(e, 300);
61
+ break;
62
+ case "width":
63
+ this._state.width = p(e);
64
+ break;
65
+ }
66
+ }
67
+ updateDOM(t) {
68
+ t.has("width") && this._updateWidth();
69
+ }
70
+ _updateWidth() {
71
+ this._state.width ? this.style.setProperty("--l-date-picker-width", this._state.width) : this.style.removeProperty("--l-date-picker-width");
72
+ }
73
+ render() {
74
+ const t = document.createDocumentFragment();
75
+ if (t.appendChild(this.#r(0)), this._state.range) {
76
+ const i = l("span", {
77
+ class: "l-date-range-divider",
78
+ textContent: "-"
79
+ });
80
+ t.appendChild(i), t.appendChild(this.#r(1));
81
+ }
82
+ return t;
83
+ }
84
+ #r(t = 0) {
85
+ return l("input", {
86
+ type: this._state.type,
87
+ class: `l-date-inner l-date-inner${t}`,
88
+ name: this.getName(),
89
+ value: this.#e[t],
90
+ "l-datepicker": `${t}`,
91
+ disabled: this.isDisabled() ? !0 : void 0,
92
+ min: this._state.min,
93
+ max: this._state.max
94
+ });
95
+ }
96
+ #h = (t) => {
97
+ const i = t.target, e = Number(i.getAttribute("l-datepicker"));
98
+ let s = i.value;
99
+ !s && !this._state.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._state.range ? this.#l() : this.#o();
100
+ };
101
+ #a() {
102
+ this.#i !== -1 && (clearTimeout(this.#i), this.#i = -1);
103
+ }
104
+ #l() {
105
+ this.#s && (this.#a(), this.#i = setTimeout(() => {
106
+ this.#o(), this.#s = !1;
107
+ }, this._state.delay));
108
+ }
109
+ #d = () => {
110
+ this.#a();
111
+ };
112
+ #n = () => {
113
+ this.#l();
114
+ };
115
+ #o() {
116
+ this.dispatchEvent(
117
+ new CustomEvent("change", {
118
+ detail: {
119
+ value: this.getValue(),
120
+ dateStr: this.#e,
121
+ dates: this.#e.map((t) => c(t))
122
+ }
123
+ })
124
+ );
125
+ }
126
+ }
127
+ export {
128
+ w as default
129
+ };
@@ -1,7 +1,5 @@
1
1
  import BaseComponent from "../base";
2
- export default class DialogContainer extends BaseComponent {
3
- #private;
4
- static baseName: string;
2
+ type DialogContainerState = {
5
3
  /** 是否显示标题栏 */
6
4
  showHeader: boolean;
7
5
  /** 头部内容 */
@@ -18,11 +16,21 @@ export default class DialogContainer extends BaseComponent {
18
16
  okText: string;
19
17
  /** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
20
18
  showClose: number;
19
+ /** 容器类名 */
21
20
  containerClass?: string;
22
- connectedCallback(): void;
23
- initEvents(): void;
24
- removeEvents(): void;
21
+ };
22
+ export default class DialogContainer extends BaseComponent<DialogContainerState> {
23
+ #private;
24
+ static baseName: string;
25
+ constructor();
26
+ afterInit(): void;
27
+ beforeDestroy(): void;
25
28
  static get observedAttributes(): string[] | null | undefined;
26
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
27
- render(): HTMLElement[];
29
+ protected attributeChanged(name: string, oldValue: string, newValue: string): void;
30
+ render_v2(): {
31
+ template?: string | HTMLElement | DocumentFragment;
32
+ style?: string | string[];
33
+ };
34
+ render(): DocumentFragment;
28
35
  }
36
+ export {};
@@ -1,98 +1,131 @@
1
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";
2
+ import { $ as c, iterate as d, on as r, off as h, shouldEventNext as g, $one as b, $$ as s, formatClass as f } from "ph-utils/dom";
4
3
  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-control-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 {
4
+ class m extends p {
6
5
  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();
6
+ constructor() {
7
+ super(), this.version = 2, this._state = {
8
+ showHeader: !0,
9
+ showFooter: !0,
10
+ showCancel: !0,
11
+ cancelText: "取消",
12
+ showOk: !0,
13
+ okText: "确定",
14
+ showClose: 1
15
+ };
26
16
  }
27
- initEvents() {
28
- const t = d("[data-action]", this.root);
29
- c(t, (o) => {
17
+ afterInit() {
18
+ this._state.showClose === 2 && this.classList.add("l-container-close-outside");
19
+ const t = c("[data-action]", this.root);
20
+ d(t, (o) => {
30
21
  r(o, "click", this.#t);
31
22
  });
32
23
  }
33
- removeEvents() {
34
- const t = d("[data-action]", this.root);
35
- c(t, (o) => {
24
+ beforeDestroy() {
25
+ const t = c("[data-action]", this.root);
26
+ d(t, (o) => {
36
27
  h(o, "click", this.#t);
37
28
  });
38
29
  }
39
30
  #t(t) {
40
- const [o, i] = g(t, "data-action");
31
+ const [o, e] = g(t, "data-action");
41
32
  o && this.dispatchEvent(
42
33
  new CustomEvent("dialogAction", {
43
- detail: { action: i },
34
+ detail: { action: e },
44
35
  composed: !0
45
36
  })
46
37
  );
47
38
  }
48
39
  static get observedAttributes() {
49
- return ["show-close"];
40
+ return [
41
+ "show-header",
42
+ "header",
43
+ "show-footer",
44
+ "show-cancel",
45
+ "cancel-text",
46
+ "show-ok",
47
+ "ok-text",
48
+ "show-close",
49
+ "container-class"
50
+ ];
50
51
  }
51
- attributeChangedCallback(t, o, i) {
52
- if (t === "show-close") {
53
- this.showClose = Number(i), this.showClose === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
54
- let s = f(".l-btn-dialog-close", this.root);
55
- 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));
52
+ attributeChanged(t, o, e) {
53
+ switch (t) {
54
+ case "show-header":
55
+ this._state.showHeader = e !== null, this.connectedCallback();
56
+ break;
57
+ case "header":
58
+ this._state.header = e || void 0, this.connectedCallback();
59
+ break;
60
+ case "show-footer":
61
+ this._state.showFooter = e !== null, this.connectedCallback();
62
+ break;
63
+ case "show-cancel":
64
+ this._state.showCancel = e !== null, this.connectedCallback();
65
+ break;
66
+ case "cancel-text":
67
+ this._state.cancelText = e || "取消", this.connectedCallback();
68
+ break;
69
+ case "show-ok":
70
+ this._state.showOk = e !== null, this.connectedCallback();
71
+ break;
72
+ case "ok-text":
73
+ this._state.okText = e || "确定", this.connectedCallback();
74
+ break;
75
+ case "show-close":
76
+ this._state.showClose = Number(e), this._state.showClose === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
77
+ let a = b(".l-btn-dialog-close", this.root);
78
+ this._state.showClose === 0 && a ? (h(a, "click", this.#t), a.remove()) : a ? a.className = this.#e() : (a = this.#o(), r(a, "click", this.#t), this.root.appendChild(a));
79
+ break;
80
+ case "container-class":
81
+ this._state.containerClass = e || void 0, this.connectedCallback();
82
+ break;
56
83
  }
57
84
  }
58
- #o() {
59
- return `l-btn-dialog-close l-dialog-close${this.showClose}`;
60
- }
61
85
  #e() {
62
- const t = e("l-button", {
86
+ return `l-btn-dialog-close l-dialog-close${this._state.showClose}`;
87
+ }
88
+ #o() {
89
+ const t = s("l-button", {
63
90
  shape: "circle",
64
91
  type: "normal",
65
- class: this.#o(),
92
+ class: this.#e(),
66
93
  "data-action": "close"
67
- }), o = e("l-close-icon");
94
+ }), o = s("l-close-icon");
68
95
  return t.appendChild(o), t;
69
96
  }
97
+ render_v2() {
98
+ return {
99
+ style: C,
100
+ template: this.render()
101
+ };
102
+ }
70
103
  render() {
71
- const t = [];
72
- this.showClose !== 0 && t.push(this.#e());
73
- const o = e("div", { class: "l-dialog-main" });
74
- if (this.showHeader) {
75
- const l = e("header", { class: "l-dialog-header" }), a = e("slot", { name: "header" });
76
- a.textContent = this.header || "", l.appendChild(a), o.appendChild(l);
104
+ const t = document.createDocumentFragment();
105
+ this._state.showClose !== 0 && t.appendChild(this.#o());
106
+ const o = s("div", { class: "l-dialog-main" });
107
+ if (this._state.showHeader) {
108
+ const l = s("header", { class: "l-dialog-header" }), i = s("slot", { name: "header" });
109
+ i.textContent = this._state.header || "", l.appendChild(i), o.appendChild(l);
77
110
  }
78
- const i = e("div", {
79
- class: u(["l-dialog-container", this.containerClass])
80
- }), s = e("slot");
81
- if (i.appendChild(s), o.appendChild(i), this.showFooter) {
82
- const l = e("div", { class: "l-dialog-footer" }), a = e("slot", { name: "footer" });
83
- if (this.showCancel) {
84
- const n = e("l-button", { "data-action": "cancel" });
85
- n.textContent = this.cancelText, a.appendChild(n);
111
+ const e = s("div", {
112
+ class: f(["l-dialog-container", this._state.containerClass])
113
+ }), a = s("slot");
114
+ if (e.appendChild(a), o.appendChild(e), this._state.showFooter) {
115
+ const l = s("div", { class: "l-dialog-footer" }), i = s("slot", { name: "footer" });
116
+ if (this._state.showCancel) {
117
+ const n = s("l-button", { "data-action": "cancel" });
118
+ n.textContent = this._state.cancelText, i.appendChild(n);
86
119
  }
87
- if (this.showOk) {
88
- const n = e("l-button", { type: "primary", "data-action": "ok" });
89
- n.textContent = this.okText, a.appendChild(n);
120
+ if (this._state.showOk) {
121
+ const n = s("l-button", { type: "primary", "data-action": "ok" });
122
+ n.textContent = this._state.okText, i.appendChild(n);
90
123
  }
91
- l.appendChild(a), o.appendChild(l);
124
+ l.appendChild(i), o.appendChild(l);
92
125
  }
93
- return t.push(o), t;
126
+ return t.appendChild(o), t;
94
127
  }
95
128
  }
96
129
  export {
97
- k as default
130
+ m as default
98
131
  };