litos-ui 0.12.2 → 0.14.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 (86) 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/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 +6 -6
  26. package/lib/date_picker/index.d.ts +22 -0
  27. package/lib/date_picker/index.js +99 -0
  28. package/lib/dialog/dialog_container.d.ts +28 -0
  29. package/lib/dialog/dialog_container.js +100 -0
  30. package/lib/dialog/index.d.ts +30 -0
  31. package/lib/dialog/index.js +86 -0
  32. package/lib/form/form_inner.d.ts +3 -5
  33. package/lib/form/form_inner.js +29 -31
  34. package/lib/form/form_item.d.ts +1 -3
  35. package/lib/form/form_item.js +30 -41
  36. package/lib/form/index.d.ts +0 -2
  37. package/lib/form/index.js +23 -25
  38. package/lib/icon/base.d.ts +0 -1
  39. package/lib/icon/base.js +15 -17
  40. package/lib/icon/close.d.ts +5 -0
  41. package/lib/icon/close.js +10 -0
  42. package/lib/icon/{mask_close.d.ts → close_filled.d.ts} +1 -1
  43. package/lib/icon/{mask_close.js → close_filled.js} +1 -1
  44. package/lib/index-dwS1N2uN.js +4 -0
  45. package/lib/index.d.ts +40 -6
  46. package/lib/index.js +120 -87
  47. package/lib/input/index.d.ts +6 -5
  48. package/lib/input/index.js +105 -57
  49. package/lib/list/index.d.ts +2 -3
  50. package/lib/list/index.js +17 -17
  51. package/lib/litos-ui.css +1 -1
  52. package/lib/loading/index.d.ts +45 -0
  53. package/lib/loading/index.js +141 -0
  54. package/lib/md_input/index.js +9 -9
  55. package/lib/menu/base.js +1 -0
  56. package/lib/menu/index.d.ts +31 -0
  57. package/lib/menu/index.js +95 -0
  58. package/lib/menu/menu_item.d.ts +6 -0
  59. package/lib/menu/menu_item.js +21 -0
  60. package/lib/menu/sub_menu.d.ts +15 -0
  61. package/lib/menu/sub_menu.js +82 -0
  62. package/lib/message/index.js +1 -1
  63. package/lib/modal/index.d.ts +40 -0
  64. package/lib/modal/index.js +153 -0
  65. package/lib/modal/modal_box.js +95 -0
  66. package/lib/popover/index.d.ts +1 -4
  67. package/lib/popover/index.js +6 -12
  68. package/lib/select_ori/index.d.ts +1 -3
  69. package/lib/select_ori/index.js +12 -16
  70. package/lib/switch/index.d.ts +0 -1
  71. package/lib/switch/index.js +8 -13
  72. package/lib/tabbar/index.d.ts +0 -1
  73. package/lib/tabbar/index.js +55 -63
  74. package/lib/theme/index.d.ts +1 -2
  75. package/lib/theme/index.js +9 -12
  76. package/lib/utils/index.d.ts +1 -6
  77. package/lib/utils/index.js +47 -54
  78. package/lib/utils/transition.js +4 -2
  79. package/package.json +8 -8
  80. package/styles/vars.css +1 -1
  81. package/lib/checkbox/index.d.ts +0 -17
  82. package/lib/checkbox/index.js +0 -135
  83. package/lib/index-391POYEJ.js +0 -4
  84. package/lib/litos-ui.min.js +0 -1
  85. package/lib/radio/index.d.ts +0 -28
  86. package/lib/radio/index.js +0 -122
@@ -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
+ };
@@ -0,0 +1,12 @@
1
+ import FormInner from "../form/form_inner";
2
+ export default class CheckGroup extends FormInner {
3
+ #private;
4
+ button: boolean;
5
+ checkedValues: string[];
6
+ constructor();
7
+ connectedCallback(): void;
8
+ afterInit(): void;
9
+ beforeDestroy(): void;
10
+ render(): HTMLElement;
11
+ valueChange(_value: string): void;
12
+ }
@@ -0,0 +1,35 @@
1
+ import t from "../form/form_inner.js";
2
+ import { on as s, off as a, $$ as o } from "ph-utils/dom";
3
+ import { initAttr as r } from "../utils/index.js";
4
+ const l = ":host{display:flex;align-items:center}";
5
+ class u extends t {
6
+ button = !1;
7
+ // 是否为按钮样式
8
+ checkedValues;
9
+ constructor() {
10
+ super(!1), this.checkedValues = [];
11
+ }
12
+ connectedCallback() {
13
+ r(this), this.loadStyleText([l]), super.connectedCallback();
14
+ }
15
+ afterInit() {
16
+ s(this.root, "change", this.#e);
17
+ }
18
+ beforeDestroy() {
19
+ a(this.root, "change", this.#e), this.checkedValues = [];
20
+ }
21
+ render() {
22
+ return o("slot");
23
+ }
24
+ #e = (e) => {
25
+ this.valueChange(e.detail.value), e.stopPropagation(), this.emit("change", {
26
+ detail: { value: [...this.checkedValues] },
27
+ composed: !0
28
+ });
29
+ };
30
+ valueChange(e) {
31
+ }
32
+ }
33
+ export {
34
+ u as default
35
+ };
@@ -0,0 +1,6 @@
1
+ import Check from "./check";
2
+ export default class Raido extends Check {
3
+ static baseName: string;
4
+ connectedCallback(): void;
5
+ _doChangeAction(): void;
6
+ }
@@ -0,0 +1,19 @@
1
+ import e from "./check.js";
2
+ import { c as o } from "../check-BlDsQQo0.js";
3
+ import { $one as r } from "ph-utils/dom";
4
+ const t = '.l-check__inner{border-radius:50%}.l-check__inner:after{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color, #722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color, #e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color, #e6e6e6)}';
5
+ class d extends e {
6
+ static baseName = "radio";
7
+ connectedCallback() {
8
+ this.loadStyleText([o, t]), super.connectedCallback();
9
+ }
10
+ _doChangeAction() {
11
+ r("input", this.root).checked || (this.setAttribute("checked", ""), this.emit("change", {
12
+ detail: { value: this.value, name: this.getName() },
13
+ composed: !0
14
+ }));
15
+ }
16
+ }
17
+ export {
18
+ d as default
19
+ };
@@ -0,0 +1,6 @@
1
+ import CheckGroup from ".";
2
+ export default class RadioGroup extends CheckGroup {
3
+ static baseName: string;
4
+ afterInit(): void;
5
+ valueChange(value: string): void;
6
+ }
@@ -0,0 +1,24 @@
1
+ import a from "./index.js";
2
+ import { $one as i } from "ph-utils/dom";
3
+ class u extends a {
4
+ static baseName = "radio-group";
5
+ afterInit() {
6
+ if (super.afterInit(), this.value) {
7
+ const e = i(`l-radio[value="${this.value}"]`, this);
8
+ e && e.setAttribute("checked", "");
9
+ }
10
+ }
11
+ valueChange(e) {
12
+ if (this.value) {
13
+ const t = i(
14
+ `l-radio[value="${this.value}"]`,
15
+ this
16
+ );
17
+ t && t.removeAttribute("checked");
18
+ }
19
+ this.value = e;
20
+ }
21
+ }
22
+ export {
23
+ u as default
24
+ };
@@ -0,0 +1,4 @@
1
+ const r = ":host{--l-check-size: 16px;display:inline-flex;align-items:center;position:relative;cursor:pointer;width:auto;transition:color .3s,border-color .3s,background-color .3s}:host(:not(:first-child)){margin-left:15px}.l-check__input{margin:0;position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-check__inner{width:var(--l-check-size);height:var(--l-check-size);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:border-color .3s ease-in-out;position:relative;margin-right:5px}.l-check__label{transition:color .3s;cursor:inherit;line-height:1}:host(.is-checked){color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner{border-color:var(--l-primary-color, #722ed1)}:host(.is-disabled){cursor:not-allowed}:host(.is-disabled) .l-check__label{color:var(--l-disabled-color, #e6e6e6)}:host([button]){height:var(--l-form-edit-height, 32px);justify-content:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0;border-radius:inherit}:host([button]:first-child){border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}:host([button]:last-child){border-top-right-radius:3px;border-bottom-right-radius:3px}:host([button].is-checked){background-color:var(--l-primary-color, #722ed1);color:#fff;border-color:var(--l-primary-color, #722ed1);border-right-color:#fff}:host([button].is-checked:last-child){border-right-color:var(--l-primary-color, #722ed1)}";
2
+ export {
3
+ r as c
4
+ };
@@ -8,6 +8,6 @@ export default class ColorPicker extends FormInner {
8
8
  connectedCallback(): void;
9
9
  disconnectedCallback(): void;
10
10
  render(): HTMLInputElement;
11
- protected _changeDisabled(): void;
11
+ protected disabledChange(): void;
12
12
  private _handleChange;
13
13
  }
@@ -1,14 +1,14 @@
1
1
  import { $one as i, on as s, off as a } from "ph-utils/dom";
2
- import c from "../form/form_inner.js";
3
- import { initAttr as r, setAttrs as n } from "../utils/index.js";
4
- import { i as l } from "../index-391POYEJ.js";
2
+ import r from "../form/form_inner.js";
3
+ import { initAttr as c, setAttrs as n } from "../utils/index.js";
4
+ import { i as l } from "../index-dwS1N2uN.js";
5
5
  const o = ":host{--l-input-width: 60px}";
6
- class m extends c {
6
+ class m extends r {
7
7
  static baseName = "color-picker";
8
8
  $picker;
9
9
  _value = "#000000";
10
10
  constructor() {
11
- super(), r(this);
11
+ super(), c(this);
12
12
  }
13
13
  setValue(e) {
14
14
  super.setValue(e), this.$picker && (this.$picker.value = e);
@@ -29,7 +29,7 @@ class m extends c {
29
29
  ["class", "l-input l-color-picker"]
30
30
  ]), e;
31
31
  }
32
- _changeDisabled() {
32
+ disabledChange() {
33
33
  this.$picker && (this.$picker.disabled = this.isDisabled());
34
34
  }
35
35
  _handleChange = (e) => {
@@ -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;