litos-ui 0.12.1 → 0.12.2

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 (54) hide show
  1. package/lib/base.d.ts +1 -14
  2. package/lib/base.js +5 -22
  3. package/lib/button/index.d.ts +1 -3
  4. package/lib/button/index.js +19 -18
  5. package/lib/form/form_inner.d.ts +2 -7
  6. package/lib/form/form_inner.js +20 -26
  7. package/lib/form/form_item.d.ts +2 -0
  8. package/lib/form/form_item.js +9 -5
  9. package/lib/form/index.d.ts +2 -0
  10. package/lib/form/index.js +25 -23
  11. package/lib/icon/base.d.ts +1 -0
  12. package/lib/icon/base.js +17 -15
  13. package/lib/index.d.ts +2 -26
  14. package/lib/index.js +83 -106
  15. package/lib/input/index.d.ts +2 -1
  16. package/lib/input/index.js +8 -5
  17. package/lib/list/index.d.ts +1 -1
  18. package/lib/litos-ui.css +1 -1
  19. package/lib/litos-ui.min.js +1 -0
  20. package/lib/popover/index.d.ts +4 -1
  21. package/lib/popover/index.js +12 -6
  22. package/lib/radio/index.js +3 -3
  23. package/lib/select_ori/index.d.ts +2 -0
  24. package/lib/select_ori/index.js +15 -11
  25. package/lib/switch/index.d.ts +1 -0
  26. package/lib/switch/index.js +13 -8
  27. package/lib/tabbar/index.d.ts +1 -0
  28. package/lib/tabbar/index.js +63 -55
  29. package/lib/theme/index.d.ts +2 -1
  30. package/lib/theme/index.js +12 -9
  31. package/lib/utils/index.d.ts +5 -0
  32. package/lib/utils/index.js +52 -45
  33. package/lib/utils/transition.js +2 -3
  34. package/package.json +1 -1
  35. package/lib/date_picker/index.d.ts +0 -22
  36. package/lib/date_picker/index.js +0 -99
  37. package/lib/dialog/dialog_container.d.ts +0 -28
  38. package/lib/dialog/dialog_container.js +0 -100
  39. package/lib/dialog/index.d.ts +0 -30
  40. package/lib/dialog/index.js +0 -86
  41. package/lib/icon/close.d.ts +0 -5
  42. package/lib/icon/close.js +0 -10
  43. package/lib/loading/index.d.ts +0 -45
  44. package/lib/loading/index.js +0 -141
  45. package/lib/menu/base.js +0 -1
  46. package/lib/menu/index.d.ts +0 -29
  47. package/lib/menu/index.js +0 -90
  48. package/lib/menu/menu_item.d.ts +0 -6
  49. package/lib/menu/menu_item.js +0 -21
  50. package/lib/menu/sub_menu.d.ts +0 -13
  51. package/lib/menu/sub_menu.js +0 -64
  52. package/lib/modal/index.d.ts +0 -40
  53. package/lib/modal/index.js +0 -153
  54. package/lib/modal/modal_box.js +0 -95
@@ -1,116 +1,122 @@
1
1
  import { isBlank as N } from "ph-utils";
2
- import { $ as x, iterate as $, transition as y } from "ph-utils/dom";
3
- let E = -1;
4
- function H(t, r) {
2
+ import { iterate as $, transition as m, $ as p } from "ph-utils/dom";
3
+ let E = -1, y = {
4
+ /** 注册应用的前缀 */
5
+ prefix: "l"
6
+ };
7
+ function H(t) {
8
+ y = { ...y, ...t };
9
+ }
10
+ function _(t, r) {
5
11
  const e = Array.isArray(t) ? t : [t];
6
12
  for (const i of e) {
7
- const n = r || `l-${i.baseName}`;
13
+ const n = r || `${y.prefix}-${i.baseName}`;
8
14
  customElements.get(n) || customElements.define(n, i);
9
15
  }
10
16
  }
11
- function _() {
12
- return `l-${++E}`;
17
+ function k() {
18
+ return `${y.prefix}-${++E}`;
13
19
  }
14
20
  function I(t, r, e) {
15
21
  if (t == null) return r;
16
22
  switch (typeof r) {
17
23
  case "boolean":
18
- return ["", "true", "1", "on", e].includes(t);
24
+ return t === "" || t === "true" || t === "1" || t === e;
19
25
  case "number":
20
26
  return Number(t);
21
27
  default:
22
28
  return t;
23
29
  }
24
30
  }
25
- function k(t) {
31
+ function V(t) {
26
32
  const r = t.attributes;
27
33
  for (const e of r) {
28
34
  const { name: i, value: n } = e;
29
35
  if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$") || ["id", "class", "style"].includes(i))
30
36
  continue;
31
- const s = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), u = I(n, t[s], i), f = Object.getOwnPropertyNames(t);
32
- (t._ignoreInitAttrs || []).includes(s) || (i === "value" ? (t[s] = u, t._resetValue = u) : f.includes(s) && (t[s] = u));
37
+ const s = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), f = I(n, t[s], i), u = Object.getOwnPropertyNames(t);
38
+ (t._ignoreInitAttrs || []).includes(s) || (i === "value" ? (t[s] = f, t._resetValue = f) : u.includes(s) && (t[s] = f));
33
39
  }
34
40
  }
35
41
  function W(t, r) {
36
42
  let e = " ";
37
43
  return r === !0 ? e = ` ${t}` : typeof r == "string" && !N(r) && (e = ` ${t}="${r}"`), e;
38
44
  }
39
- function C(t) {
45
+ function B(t) {
40
46
  return t.map((e) => W(e[0], e[1])).join("");
41
47
  }
42
- function V(t, r) {
48
+ function F(t, r) {
43
49
  for (const e of r) {
44
50
  const i = e[1], n = e[0];
45
51
  i === !0 ? t.setAttribute(n, "") : typeof i == "string" && !N(i) && t.setAttribute(n, i);
46
52
  }
47
53
  }
48
- function l() {
54
+ function M() {
49
55
  let t;
50
56
  const r = {
51
57
  attributes: !0,
52
58
  attributeFilter: ["l-transition-emit"]
53
59
  }, e = (s) => {
54
- for (let u of s)
55
- if (u.type === "attributes" && u.attributeName) {
56
- const f = u.target, c = f.getAttribute(u.attributeName) || "show", d = f.getAttribute("l-transition") || "l", h = f.getAttribute("l-transition-method") || "hide";
57
- c === "show" ? (f.style.removeProperty("display"), y(f, d, "enter")) : y(f, d, "leave", () => {
58
- h === "remove" ? f.remove() : f.style.display = "none";
60
+ for (let f of s)
61
+ if (f.type === "attributes" && f.attributeName) {
62
+ const u = f.target, c = u.getAttribute(f.attributeName) || "show", d = u.getAttribute("l-transition") || "l", h = u.getAttribute("l-transition-method") || "hide";
63
+ c === "show" ? (u.style.removeProperty("display"), m(u, d, "enter")) : m(u, d, "leave", () => {
64
+ h === "remove" ? u.remove() : u.style.display = "none";
59
65
  });
60
66
  }
61
67
  };
62
68
  function i(s) {
63
- s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (u) => {
64
- const f = u.getAttribute("l-transition");
65
- f && (y(u, f, "enter"), t.observe(u, r));
69
+ s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (f) => {
70
+ const u = f.getAttribute("l-transition");
71
+ u && (m(f, u, "enter"), t.observe(f, r));
66
72
  }));
67
73
  }
68
74
  function n(s) {
69
- s == null && (s = x("[l-transition]"), i(s));
75
+ s == null && (s = p("[l-transition]"), i(s));
70
76
  }
71
77
  function o() {
72
78
  t && (t.disconnect(), t = void 0);
73
79
  }
74
80
  return { destroy: o, add: i, init: n };
75
81
  }
76
- function m(t, r, e, i, n = 10) {
82
+ function w(t, r, e, i, n = 10) {
77
83
  let o = 0;
78
84
  return e === "top" ? o = r.height + n : e === "bottom" ? o = -(t.height + n) : (e === "left" || e === "right") && (i === "" ? o = r.height / 2 - t.height / 2 : i === "end" && (o = r.height - t.height)), o;
79
85
  }
80
- function w(t, r, e, i, n = 10) {
86
+ function x(t, r, e, i, n = 10) {
81
87
  let o = 0;
82
88
  return e === "left" ? o = r.width + n : e === "right" ? o = -(t.width + n) : (e === "top" || e === "bottom") && (i === "" ? o = r.width / 2 - t.width / 2 : i === "end" && (o = r.width - t.width)), o;
83
89
  }
84
- function v(t, r, e, i, n, o, s, u, f = 10, c = "absolute") {
90
+ function U(t, r, e, i, n, o, s, f, u = 10, c = "absolute") {
85
91
  const d = window.innerHeight + o - 10, h = window.innerWidth + n - 10;
86
- let a = t.top + o - u;
87
- a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", u = m(
92
+ let a = t.top + o - f;
93
+ a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", f = w(
88
94
  t,
89
95
  r,
90
96
  e,
91
97
  i,
92
- f
93
- ), a = t.top + o - u), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
98
+ u
99
+ ), a = t.top + o - f), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
94
100
  let b = t.left + n - s;
95
- return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = w(
101
+ return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = x(
96
102
  t,
97
103
  r,
98
104
  e,
99
105
  i,
100
- f
101
- ), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (u = m(
106
+ u
107
+ ), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (f = w(
102
108
  t,
103
109
  r,
104
110
  e,
105
111
  i,
106
- f
107
- ), s = w(
112
+ u
113
+ ), s = x(
108
114
  t,
109
115
  r,
110
116
  e,
111
117
  i,
112
- f
113
- ), b = t.left + n - s, a = t.top + o - u), {
118
+ u
119
+ ), b = t.left + n - s, a = t.top + o - f), {
114
120
  x: b,
115
121
  y: a,
116
122
  mainAlign: e,
@@ -118,15 +124,16 @@ function v(t, r, e, i, n, o, s, u, f = 10, c = "absolute") {
118
124
  };
119
125
  }
120
126
  export {
121
- l as createTransition,
122
- w as getPopoverOffsetX,
123
- m as getPopoverOffsetY,
124
- v as impactDetect,
125
- k as initAttr,
127
+ H as config,
128
+ M as createTransition,
129
+ x as getPopoverOffsetX,
130
+ w as getPopoverOffsetY,
131
+ U as impactDetect,
132
+ V as initAttr,
126
133
  I as parseAttrValue,
127
- H as regist,
128
- V as setAttrs,
134
+ _ as regist,
135
+ F as setAttrs,
129
136
  W as tagAttr,
130
- C as tagAttrs,
131
- _ as useId
137
+ B as tagAttrs,
138
+ k as useId
132
139
  };
@@ -6,8 +6,7 @@ import "ph-utils";
6
6
  import "ph-utils/validator";
7
7
  import "ph-utils/color";
8
8
  import "ph-utils/theme";
9
- import "ph-utils/date";
10
- class S extends a {
9
+ class C extends a {
11
10
  static baseName = "transition";
12
11
  /** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
13
12
  sheetRec;
@@ -50,5 +49,5 @@ class S extends a {
50
49
  }
51
50
  }
52
51
  export {
53
- S as Transition
52
+ C as Transition
54
53
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.12.1",
4
+ "version": "0.12.2",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
7
  "@eslint/js": "^9.24.0",
@@ -1,22 +0,0 @@
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
- }
@@ -1,99 +0,0 @@
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,28 +0,0 @@
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
- }
@@ -1,100 +0,0 @@
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
- };
@@ -1,30 +0,0 @@
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;
@@ -1,86 +0,0 @@
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
- };
@@ -1,5 +0,0 @@
1
- import BaseIcon from "./base";
2
- export default class Close extends BaseIcon {
3
- static baseName: string;
4
- renderChildren(): string;
5
- }
package/lib/icon/close.js DELETED
@@ -1,10 +0,0 @@
1
- import e from "./base.js";
2
- class l extends e {
3
- static baseName = "close-icon";
4
- renderChildren() {
5
- return '<path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path>';
6
- }
7
- }
8
- export {
9
- l as default
10
- };
@@ -1,45 +0,0 @@
1
- type LoadingInstanceParams = {
2
- /** 是否全屏显示, 默认: true */
3
- fullscreen?: boolean;
4
- /** 全屏显示时,是否隐藏滚动条; 默认: true */
5
- lock?: boolean;
6
- /** 进度条形状, bar - 进度条, circle - 圆形, border - 边框进度 */
7
- shape?: "circle" | "bar" | "border";
8
- /** 进度条挂载容器 */
9
- to?: string | HTMLElement | null;
10
- /** 显示的文本; 默认: 加载中…… */
11
- text?: string;
12
- /** 阴影背景色 */
13
- background?: string;
14
- /** 是否显示阴影, 0 - 不显示, 1 - 显示, 2 - 自动[circle-显示,bar-不显示], 默认: 2 */
15
- mask?: number;
16
- zindex?: number;
17
- /** 前景文字颜色 */
18
- color?: string;
19
- };
20
- declare class LoadingInstance {
21
- /** 加载容器 */
22
- el: HTMLElement;
23
- option: Required<Omit<LoadingInstanceParams, "to" | "zindex">>;
24
- constructor(option?: LoadingInstanceParams);
25
- /** 显示进度条 */
26
- show(): void;
27
- /** 隐藏进度条 */
28
- hide(): void;
29
- }
30
- declare const _default: {
31
- /** 创建并显示进度条 */
32
- create(option?: LoadingInstanceParams): LoadingInstance;
33
- /** 根据指令参数初始化进度条 */
34
- init(id?: string): void;
35
- /**
36
- * 关闭加载中的元素
37
- *
38
- * 此函数用于关闭页面上带有特定 l-loading 属性的元素,只关闭与该 id 匹配的元素
39
- * 否则,将关闭所有带有 l-loading 属性的元素
40
- *
41
- * @param id 可选参数,指定特定的加载元素 l-loading 对应的值,如果提供,则只关闭匹配该 id 的元素
42
- */
43
- close(id?: string): void;
44
- };
45
- export default _default;