litos-ui 0.17.5 → 0.18.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 (163) hide show
  1. package/lib/animation-CTt9qgA7.js +4 -0
  2. package/lib/base-Dm0WS1pK.js +62 -0
  3. package/lib/base.js +111 -147
  4. package/lib/button/index.d.ts +8 -3
  5. package/lib/button/index.js +2 -137
  6. package/lib/button-CC5PmAb1.js +146 -0
  7. package/lib/calendar/index.d.ts +10 -5
  8. package/lib/calendar/index.js +2 -123
  9. package/lib/calendar-GpYHNmXG.js +149 -0
  10. package/lib/carousel/index.js +2 -280
  11. package/lib/carousel/item.js +2 -15
  12. package/lib/carousel-dT3FJPQo.js +272 -0
  13. package/lib/check/checkbox.js +2 -18
  14. package/lib/check/checkbox_group.js +6 -6
  15. package/lib/check/radio.js +2 -15
  16. package/lib/check/radio_group.js +9 -9
  17. package/lib/check-B0XraJvb.js +73 -0
  18. package/lib/check-CvGaONEx.js +117 -0
  19. package/lib/checkbox-DbWsmAaL.js +16 -0
  20. package/lib/collapse/index.d.ts +18 -11
  21. package/lib/collapse/index.js +2 -88
  22. package/lib/collapse/item.d.ts +28 -9
  23. package/lib/collapse/item.js +2 -115
  24. package/lib/collapse/types.d.ts +7 -0
  25. package/lib/collapse-C3IRHLeg.js +104 -0
  26. package/lib/color_picker/index.js +2 -42
  27. package/lib/color_picker-D0brKFm-.js +41 -0
  28. package/lib/date_picker/index.d.ts +23 -0
  29. package/lib/date_picker/index.js +3 -0
  30. package/lib/date_picker-DQGoiN8v.js +103 -0
  31. package/lib/date_picker_ori/index.js +2 -129
  32. package/lib/date_picker_ori-aRuSSi9D.js +122 -0
  33. package/lib/description_panel/index.js +2 -66
  34. package/lib/description_panel-BY2yljeC.js +57 -0
  35. package/lib/dialog/dialog_container.js +2 -131
  36. package/lib/dialog/index.js +67 -85
  37. package/lib/dialog_container-DcN87wj0.js +126 -0
  38. package/lib/esm-sVEoAVPu.js +244 -0
  39. package/lib/form/form_item.d.ts +1 -0
  40. package/lib/form/form_item.js +2 -136
  41. package/lib/form/index.js +2 -147
  42. package/lib/form-DdU0yK0k.js +154 -0
  43. package/lib/form_inner-DR9tyB_r.js +117 -0
  44. package/lib/form_item-Bv-YafZK.js +137 -0
  45. package/lib/icon/arrow_down.js +12 -12
  46. package/lib/icon/arrow_left.js +9 -9
  47. package/lib/icon/arrow_right.js +9 -9
  48. package/lib/icon/arrow_up.js +12 -12
  49. package/lib/icon/base.d.ts +16 -2
  50. package/lib/icon/base.js +2 -38
  51. package/lib/icon/calendar.d.ts +5 -0
  52. package/lib/icon/calendar.js +10 -0
  53. package/lib/icon/caret_bottom.js +9 -9
  54. package/lib/icon/caret_top.js +9 -9
  55. package/lib/icon/close.js +9 -9
  56. package/lib/icon/close_filled.js +12 -12
  57. package/lib/icon/d_arrow_left.js +12 -12
  58. package/lib/icon/d_arrow_right.js +12 -12
  59. package/lib/icon/font_icon.d.ts +2 -3
  60. package/lib/icon/font_icon.js +35 -39
  61. package/lib/icon/info.js +12 -12
  62. package/lib/icon/loading.js +9 -9
  63. package/lib/icon/moon.js +12 -12
  64. package/lib/icon/more.js +12 -12
  65. package/lib/icon/reduction.js +12 -12
  66. package/lib/icon/refresh.d.ts +5 -0
  67. package/lib/icon/refresh.js +10 -0
  68. package/lib/icon/refresh_left.js +12 -12
  69. package/lib/icon/refresh_right.js +9 -9
  70. package/lib/icon/search.js +9 -9
  71. package/lib/icon/select.js +12 -12
  72. package/lib/icon/sort.js +9 -9
  73. package/lib/icon/success.js +12 -12
  74. package/lib/icon/sun.js +12 -12
  75. package/lib/icon/theme_default.js +12 -12
  76. package/lib/icon/warn.js +12 -12
  77. package/lib/icon/zoom_in.js +12 -12
  78. package/lib/icon/zoom_out.js +12 -12
  79. package/lib/image/image_preview.js +2 -104
  80. package/lib/image/index.js +2 -176
  81. package/lib/image-COPKk8Jm.js +162 -0
  82. package/lib/image_preview-CYEup07F.js +92 -0
  83. package/lib/index.d.ts +5 -81
  84. package/lib/index.js +78 -169
  85. package/lib/input/index.d.ts +6 -2
  86. package/lib/input/index.js +188 -203
  87. package/lib/input-DjKxcxry.js +4 -0
  88. package/lib/input_inner-BKJg9n9A.js +4 -0
  89. package/lib/item-B7Elh5xE.js +14 -0
  90. package/lib/item-CvoJt3wp.js +60 -0
  91. package/lib/item-DRsOV_Tc.js +119 -0
  92. package/lib/list/index.js +2 -58
  93. package/lib/list-CU7vHS6s.js +51 -0
  94. package/lib/loading/index.d.ts +3 -2
  95. package/lib/loading/index.js +109 -127
  96. package/lib/mask/index.js +2 -105
  97. package/lib/mask-CEznzwji.js +112 -0
  98. package/lib/md_input/index.js +2 -60
  99. package/lib/md_input-DSQx5TMW.js +58 -0
  100. package/lib/menu/index.d.ts +30 -13
  101. package/lib/menu/index.js +2 -105
  102. package/lib/menu/types.d.ts +6 -0
  103. package/lib/menu/types.js +0 -0
  104. package/lib/menu-CzV6lOlw.js +224 -0
  105. package/lib/message/index.js +67 -60
  106. package/lib/modal/index.js +2 -196
  107. package/lib/modal/modal_box.js +87 -86
  108. package/lib/modal-DWyWrN-D.js +192 -0
  109. package/lib/page_header/index.js +2 -109
  110. package/lib/page_header-BJkEstRw.js +101 -0
  111. package/lib/pagination/index.js +2 -248
  112. package/lib/pagination-5t7AOeFV.js +210 -0
  113. package/lib/polygon/index.js +2 -27
  114. package/lib/polygon-C4Ow2lxi.js +20 -0
  115. package/lib/qrcode/index.d.ts +13 -4
  116. package/lib/qrcode/index.js +2 -57
  117. package/lib/qrcode-BKG2MibP.js +64 -0
  118. package/lib/radio-2mNSYujz.js +13 -0
  119. package/lib/select/index.js +3 -401
  120. package/lib/select-CAgggYh7.js +326 -0
  121. package/lib/select_ori/index.js +47 -50
  122. package/lib/space/index.js +2 -35
  123. package/lib/space-Bv-p0DL8.js +38 -0
  124. package/lib/switch/index.js +2 -50
  125. package/lib/switch-BaVBi5Ip.js +48 -0
  126. package/lib/tabbar/index.js +2 -109
  127. package/lib/tabbar/item.js +2 -58
  128. package/lib/tabbar-CI1xSj1G.js +96 -0
  129. package/lib/table/index.js +2 -269
  130. package/lib/table-DfL2hFqA.js +234 -0
  131. package/lib/tabs/index.js +38 -42
  132. package/lib/tag/index.js +2 -72
  133. package/lib/tag-72DwCkvq.js +76 -0
  134. package/lib/theme/index.js +2 -89
  135. package/lib/theme/theme_color.js +22 -26
  136. package/lib/theme-BRTI2-Yk.js +83 -0
  137. package/lib/utils/clickoutside.js +18 -18
  138. package/lib/utils/context_provide.js +21 -21
  139. package/lib/utils/event.js +13 -18
  140. package/lib/utils/index.js +55 -58
  141. package/lib/utils/popover.d.ts +4 -1
  142. package/lib/utils/popover.js +276 -352
  143. package/lib/utils/transition.js +33 -31
  144. package/package.json +14 -14
  145. package/styles/container.css +4 -0
  146. package/styles/datepicker.css +55 -0
  147. package/styles/popover.css +14 -1
  148. package/lib/animation-DttknHkX.js +0 -4
  149. package/lib/calendar/langs.js +0 -8
  150. package/lib/carousel/timer.js +0 -19
  151. package/lib/check/check.js +0 -118
  152. package/lib/check/index.js +0 -68
  153. package/lib/check-CksURvTv.js +0 -4
  154. package/lib/form/form_inner.js +0 -125
  155. package/lib/form/types.js +0 -1
  156. package/lib/index-CrMiSe0x.js +0 -249
  157. package/lib/index-DY6m9Wbe.js +0 -4
  158. package/lib/litos-ui.css +0 -1
  159. package/lib/menu/menu_item.d.ts +0 -6
  160. package/lib/menu/menu_item.js +0 -21
  161. package/lib/menu/sub_menu.d.ts +0 -15
  162. package/lib/menu/sub_menu.js +0 -83
  163. package/lib/table/types.js +0 -1
@@ -1,361 +1,285 @@
1
- import { $one as T, $ as y, iterate as $, on as d, off as a, shouldEventNext as P, $$ as w } from "ph-utils/dom";
2
- function E(s, t, e, o, n = 10, r = "x") {
3
- const i = r === "x" ? "width" : "height";
4
- let p = ["left", "right", "top", "bottom"];
5
- r === "y" && (p = ["top", "bottom", "left", "right"]);
6
- let h = 0;
7
- return e === p[0] ? h = t[i] + n : e === p[1] ? h = -(s[i] + n) : (e === p[2] || e === p[3]) && (o === "" ? h = t[i] / 2 - s[i] / 2 : o === "end" && (h = t[i] - s[i])), h;
1
+ import { $ as e, $$ as t, $one as n, iterate as r, off as i, on as a, shouldEventNext as o } from "ph-utils/dom";
2
+ //#region src/components/utils/popover.ts
3
+ function s(e, t, n, r, i = 10, a = "x") {
4
+ let o = a === "x" ? "width" : "height", s = [
5
+ "left",
6
+ "right",
7
+ "top",
8
+ "bottom"
9
+ ];
10
+ a === "y" && (s = [
11
+ "top",
12
+ "bottom",
13
+ "left",
14
+ "right"
15
+ ]);
16
+ let c = 0;
17
+ return n === s[0] ? c = t[o] + i : n === s[1] ? c = -(e[o] + i) : (n === s[2] || n === s[3]) && (r === "" ? c = t[o] / 2 - e[o] / 2 : r === "end" && (c = t[o] - e[o])), c;
8
18
  }
9
- function C(s) {
10
- const t = [];
11
- let e = s;
12
- for (; e && e !== document.body && e !== document.documentElement; ) {
13
- const o = window.getComputedStyle(e), n = o.overflow + o.overflowX + o.overflowY;
14
- /(scroll|auto)/i.test(n) && t.push(e), e = e.parentElement;
15
- }
16
- return t;
19
+ function c(e) {
20
+ let t = [], n = e;
21
+ for (; n && n !== document.body && n !== document.documentElement;) {
22
+ let e = window.getComputedStyle(n), r = e.overflow + e.overflowX + e.overflowY;
23
+ /(scroll|auto)/i.test(r) && t.push(n), n = n.parentElement;
24
+ }
25
+ return t;
17
26
  }
18
- function O(s, t, e, o, n = 10) {
19
- let r = document.documentElement;
20
- const i = r.scrollLeft, p = r.scrollTop, h = window.innerHeight + p - 10, l = window.innerWidth + i - 10;
21
- let c = E(
22
- s,
23
- t,
24
- e,
25
- o,
26
- n,
27
- "y"
28
- ), f = s.top + p - c;
29
- f + t.height > h && (e === "left" || e === "right" ? o = "end" : e = "top"), f < p && (e === "left" || e === "right" ? o = "start" : e = "bottom");
30
- let u = E(
31
- s,
32
- t,
33
- e,
34
- o,
35
- n,
36
- "x"
37
- ), m = s.left + i - u;
38
- m + t.width > l && (e === "top" || e === "bottom" ? o = "end" : e = "left"), m < i && (e === "top" || e === "bottom" ? o = "start" : e = "right"), c = E(
39
- s,
40
- t,
41
- e,
42
- o,
43
- n,
44
- "y"
45
- ), u = E(
46
- s,
47
- t,
48
- e,
49
- o,
50
- n,
51
- "x"
52
- ), m = s.left + i - u, f = s.top + p - c;
53
- const g = `${e}${o === "" ? "" : "-" + o}`;
54
- return {
55
- x: m,
56
- y: f,
57
- mainAlign: e,
58
- crossAlign: o,
59
- placement: g
60
- };
27
+ function l(e, t, n, r, i = 10) {
28
+ let a = document.documentElement, o = a.scrollLeft, c = a.scrollTop, l = window.innerHeight + c - 10, u = window.innerWidth + o - 10, d = s(e, t, n, r, i, "y"), f = e.top + c - d;
29
+ f + t.height > l && (n === "left" || n === "right" ? r = "end" : n = "top"), f < c && (n === "left" || n === "right" ? r = "start" : n = "bottom");
30
+ let p = s(e, t, n, r, i, "x"), m = e.left + o - p;
31
+ m + t.width > u && (n === "top" || n === "bottom" ? r = "end" : n = "left"), m < o && (n === "top" || n === "bottom" ? r = "start" : n = "right"), d = s(e, t, n, r, i, "y"), p = s(e, t, n, r, i, "x"), m = e.left + o - p, f = e.top + c - d;
32
+ let h = `${n}${r === "" ? "" : "-" + r}`;
33
+ return {
34
+ x: m,
35
+ y: f,
36
+ mainAlign: n,
37
+ crossAlign: r,
38
+ placement: h
39
+ };
61
40
  }
62
- function M(s, t, e, o) {
63
- const n = s.getBoundingClientRect(), r = t.getBoundingClientRect();
64
- let i = "height";
65
- (e === "top" || e === "bottom") && (i = "width");
66
- const p = Math.min(n[i], r[i]);
67
- let h = 0;
68
- return o === "start" ? h = p / 2 - 4 : o === "end" ? h = r[i] - p / 2 - 4 : h = r[i] / 2 - 4, {
69
- x: i === "width" ? h : void 0,
70
- y: i === "height" ? h : void 0
71
- };
41
+ function u(e, t, n, r) {
42
+ let i = e.getBoundingClientRect(), a = t.getBoundingClientRect(), o = "height";
43
+ (n === "top" || n === "bottom") && (o = "width");
44
+ let s = Math.min(i[o], a[o]), c = 0;
45
+ return c = r === "start" ? s / 2 - 4 : r === "end" ? a[o] - s / 2 - 4 : a[o] / 2 - 4, {
46
+ x: o === "width" ? c : void 0,
47
+ y: o === "height" ? c : void 0
48
+ };
72
49
  }
73
- function b(s, t, e = { placement: "top", offset: 10, arrowSize: 8 }) {
74
- let o = "bottom", n = "";
75
- const r = (e.placement || "top").split("-");
76
- r != null && (o = r[0], n = r[1] || "");
77
- let i, p = t.getBoundingClientRect();
78
- const h = s.getBoundingClientRect();
79
- e.popoverWidth && (e.popoverWidth === "trigger" ? i = h.width : i = e.popoverWidth), i != null && (p.width = i, t.style.width = `${i}px`);
80
- const l = O(
81
- h,
82
- p,
83
- o,
84
- n,
85
- e.offset || 10
86
- );
87
- t.style.setProperty("left", `${l.x}px`), t.style.setProperty("top", `${l.y}px`);
88
- let c = T(".l-popover-arrow", t);
89
- if (c) {
90
- const f = M(
91
- s,
92
- t,
93
- l.mainAlign,
94
- l.crossAlign
95
- );
96
- let v = "";
97
- e.arrowSize !== 8 && (v += `--l-popover-arrow-size: ${e.arrowSize}px;`), f.x && (v += `left: ${f.x}px;`), f.y && (v += `top: ${f.y}px;`);
98
- const u = {
99
- top: "bottom",
100
- right: "left",
101
- bottom: "top",
102
- left: "right"
103
- }[l.mainAlign], m = {
104
- top: "right",
105
- bottom: "left",
106
- left: "top",
107
- right: "bottom"
108
- }[l.mainAlign], _ = Math.ceil((e.arrowSize || 8) / 2);
109
- v += `${u}: -${_}px;border-${u}: 1px solid var(--l-popover-border-color);border-${m}:1px solid var(--l-popover-border-color);`, c.style.cssText = v;
110
- }
50
+ function d(e, t, r = {
51
+ placement: "top",
52
+ offset: 10,
53
+ arrowSize: 8
54
+ }) {
55
+ let i = "bottom", a = "", o = (r.placement || "top").split("-");
56
+ o != null && (i = o[0], a = o[1] || "");
57
+ let s, c = t.getBoundingClientRect(), d = e.getBoundingClientRect();
58
+ r.popoverWidth && (s = r.popoverWidth === "trigger" ? d.width : r.popoverWidth), s != null && (c.width = s, t.style.width = `${s}px`);
59
+ let f = l(d, c, i, a, r.offset || 10);
60
+ t.style.setProperty("left", `${f.x}px`), t.style.setProperty("top", `${f.y}px`);
61
+ let p = n(".l-popover-arrow", t);
62
+ if (p) {
63
+ let n = u(e, t, f.mainAlign, f.crossAlign), i = "";
64
+ r.arrowSize !== 8 && (i += `--l-popover-arrow-size: ${r.arrowSize}px;`), n.x && (i += `left: ${n.x}px;`), n.y && (i += `top: ${n.y}px;`);
65
+ let a = {
66
+ top: "bottom",
67
+ right: "left",
68
+ bottom: "top",
69
+ left: "right"
70
+ }[f.mainAlign], o = {
71
+ top: "right",
72
+ bottom: "left",
73
+ left: "top",
74
+ right: "bottom"
75
+ }[f.mainAlign], s = Math.ceil((r.arrowSize || 8) / 2);
76
+ i += `${a}: -${s}px;border-${a}: 1px solid var(--l-popover-border-color);border-${o}:1px solid var(--l-popover-border-color);`, p.style.cssText = i;
77
+ }
111
78
  }
112
- function L(s, t, e) {
113
- let o = s, n = t, r = e;
114
- b(o, n, r);
115
- function i() {
116
- b(o, n, r);
117
- }
118
- let p = C(o);
119
- p.forEach((f) => {
120
- d(f, "scroll", i);
121
- });
122
- function h() {
123
- b(o, n, r);
124
- }
125
- let l = new ResizeObserver(h);
126
- l.observe(o), l.observe(window.document.body);
127
- function c() {
128
- p.forEach((f) => {
129
- a(f, "scroll", i);
130
- }), p = void 0, o = void 0, n = void 0, r = void 0, l.disconnect(), l = void 0;
131
- }
132
- return { destroy: c };
79
+ function f(e, t, n) {
80
+ let r = e, o = t, s = n;
81
+ d(r, o, s);
82
+ function l() {
83
+ d(r, o, s);
84
+ }
85
+ let u = c(r);
86
+ u.forEach((e) => {
87
+ a(e, "scroll", l);
88
+ });
89
+ function f() {
90
+ d(r, o, s);
91
+ }
92
+ let p = new ResizeObserver(f);
93
+ p.observe(r), p.observe(window.document.body);
94
+ function m() {
95
+ u.forEach((e) => {
96
+ i(e, "scroll", l);
97
+ }), u = void 0, r = void 0, o = void 0, s = void 0, p.disconnect(), p = void 0;
98
+ }
99
+ return { destroy: m };
133
100
  }
134
- class z {
135
- options;
136
- $refs = [];
137
- /** 激活的触发节点 */
138
- $reference;
139
- popoverElement;
140
- updater;
141
- _hideTimer;
142
- constructor(t) {
143
- this.options = {
144
- trigger: "hover",
145
- arrow: !0,
146
- offset: 10,
147
- arrowSize: 8,
148
- disabled: !1,
149
- updateContent: (o, n) => {
150
- if (n && n.title) {
151
- const r = T(".l-popover-content", o);
152
- r && (r.textContent = n.title);
153
- }
154
- },
155
- ...t
156
- };
157
- let e = [];
158
- this.options.reference ? typeof this.options.reference == "string" ? e = [...y(this.options.reference)] : Array.isArray(this.options.reference) ? e.push(...this.options.reference) : e.push(this.options.reference) : e = [...y(".l-popover-reference")], this.$refs = e, this.popoverElement = this.options.popover, this._bindPopoverEvents(), this._init();
159
- }
160
- /**
161
- * 向实例中添加一个引用元素
162
- *
163
- * @param reference 需要添加的引用元素
164
- */
165
- addReference(t) {
166
- this.$refs && (this._bindReferenceEvents(t), this.$refs.push(t));
167
- }
168
- /**
169
- * 从引用列表中移除指定的引用
170
- *
171
- * @param referecnce 要移除的引用元素
172
- */
173
- removeReference(t) {
174
- if (this.$refs) {
175
- let e = this.$refs.indexOf(t);
176
- e !== -1 && (t == this.$reference && this.hide(), this._removeReferenceEvents(t), this.$refs.splice(e, 1));
177
- }
178
- }
179
- _init() {
180
- this.options.trigger && this.$refs && $(this.$refs, (t) => {
181
- this._bindReferenceEvents(t);
182
- }), d(document, "click", this._onOuterTap, { capture: !0 });
183
- }
184
- _bindReferenceEvents(t) {
185
- const e = this.options.trigger;
186
- ["click", "focus"].includes(e) ? d(t, "click", this._onRefTap) : e === "hover" && (d(t, "mouseenter", this._onMouseEnter), d(t, "mouseleave", this._onMouseLeave));
187
- }
188
- _removeReferenceEvents(t) {
189
- a(t, "click", this._onRefTap), a(t, "mouseenter", this._onMouseEnter), a(t, "mouseleave", this._onMouseLeave);
190
- }
191
- _bindPopoverEvents() {
192
- this.popoverElement && this.options.trigger === "hover" && (d(this.popoverElement, "mouseenter", this._onPopoverEnter), d(this.popoverElement, "mouseleave", this._onMouseLeave));
193
- }
194
- _onPopoverEnter = () => {
195
- this._clearHideTimer();
196
- };
197
- _clearHideTimer() {
198
- this._hideTimer && (clearTimeout(this._hideTimer), this._hideTimer = void 0);
199
- }
200
- _onMouseEnter = (t) => {
201
- const e = t.target;
202
- this._clearHideTimer(), this.$reference != e && this.show(e);
203
- };
204
- _onMouseLeave = () => {
205
- this._clearHideTimer(), this.options.trigger === "hover" && (this._hideTimer = setTimeout(() => {
206
- this.hide();
207
- }, 50));
208
- };
209
- _onRefTap = (t) => {
210
- this._destroyUpdater();
211
- const e = t.target;
212
- if (this.$reference) {
213
- if (this.options.trigger === "focus") return;
214
- this.hide();
215
- return;
216
- }
217
- this.show(e);
218
- };
219
- /**
220
- * 显示浮层。
221
- *
222
- * @param reference 浮层所对齐的 HTML 元素。
223
- */
224
- show(t) {
225
- const e = t.dataset;
226
- let o = e.disabled;
227
- if (o == null && (o = this.options.disabled), !o) {
228
- if (this.$reference) {
229
- if (this.$reference === t)
230
- return;
231
- this.hide();
232
- }
233
- if (this.$reference = t, this.popoverElement || (this._renderPopover(), this._bindPopoverEvents()), this.popoverElement) {
234
- this.options.updateContent && this.options.updateContent(this.popoverElement, e), this._destroyUpdater();
235
- const n = e.placement || this.options.placement || "top", r = Number(e.offset || this.options.offset || 10), i = e.popoverWidth || this.options.popoverWidth;
236
- this.popoverElement.style.display = "block";
237
- let p;
238
- i && (i !== "trigger" ? p = Number(i) : p = i), this.updater = L(this.$reference, this.popoverElement, {
239
- placement: n,
240
- popoverWidth: p,
241
- offset: r,
242
- arrowSize: this.options.arrowSize
243
- }), this.options.onOpenChange && this.options.onOpenChange(!0);
244
- }
245
- }
246
- }
247
- isShow() {
248
- return this.$reference != null;
249
- }
250
- /**
251
- * 隐藏 Popover
252
- */
253
- hide() {
254
- this._destroyUpdater(), this.popoverElement && (this.popoverElement.style.display = "none"), this.$reference = void 0, this.options.onOpenChange && this.options.onOpenChange(!1);
255
- }
256
- /** 重新设置选项 */
257
- setOption(t, e) {
258
- this.options[t] = e;
259
- }
260
- updatePopoverContent() {
261
- this.popoverElement && this.options.updateContent && this.options.updateContent(this.popoverElement, {});
262
- }
263
- _onOuterTap = (t) => {
264
- const e = t.target;
265
- if (this.$reference && !this.$reference.contains(e) && this.$reference != e) {
266
- if (this.options.trigger === "focus") {
267
- this.hide();
268
- return;
269
- }
270
- if (this.popoverElement && (this.popoverElement.contains(e) || this.popoverElement == e)) {
271
- const [o, n, r] = P(
272
- t,
273
- "data-action",
274
- this.popoverElement
275
- );
276
- if (o) {
277
- let i = "";
278
- n === "popconfirm-cancel" ? i = "cancel" : n === "popconfirm-ok" && (i = "ok"), i && this.hide(), this.options.onPopoverAction && this.options.onPopoverAction(i || n, r);
279
- }
280
- return;
281
- }
282
- this.hide();
283
- }
284
- };
285
- _renderPopover() {
286
- let e = `l-popover l-popover--${this.options.theme || "default"}`;
287
- this.options.popoverClass && (e += ` ${this.options.popoverClass}`);
288
- const o = w("div", {
289
- class: e
290
- }), n = this.options.contentRender;
291
- if (n) {
292
- const r = n();
293
- typeof r == "string" ? o.innerHTML = r : o.appendChild(r);
294
- } else {
295
- const r = w("div", { class: "l-popover-content" });
296
- o.appendChild(r);
297
- }
298
- this.options.arrow && o.appendChild(w("div", { class: "l-popover-arrow" })), document.body.appendChild(o), this.popoverElement = o;
299
- }
300
- _destroyUpdater() {
301
- this.updater && (this.updater.destroy(), this.updater = void 0);
302
- }
303
- /**
304
- * 销毁组件
305
- *
306
- * 销毁组件并移除相关事件监听器和 DOM 元素。
307
- */
308
- destroy() {
309
- this.hide(), this.$refs && $(this.$refs, (t) => {
310
- this._removeReferenceEvents(t);
311
- }), a(document, "click", this._onOuterTap, { capture: !0 }), this.options = void 0, this.$refs = void 0, this._clearHideTimer(), this.popoverElement && (a(this.popoverElement, "mouseenter", this._onPopoverEnter), a(this.popoverElement, "mouseleave", this._onMouseLeave), this.popoverElement.remove()), this.popoverElement = void 0;
312
- }
313
- }
314
- const S = {
315
- theme: "popconfirm",
316
- trigger: "click",
317
- contentRender: () => {
318
- const s = [];
319
- return s.push('<div class="l-popconfirm-container">'), s.push('<div class="l-popconfirm-icon-wrapper">'), s.push("<l-warn-icon></l-warn-icon>"), s.push('</div><div class="l-popconfirm-content"></div></div>'), s.push('<div class="l-popconfirm-footer">'), s.push(
320
- '<l-button class="l-popconfirm-btn" data-action="popconfirm-cancel">取消</l-button>'
321
- ), s.push(
322
- '<l-button class="l-popconfirm-btn" type="primary" data-action="popconfirm-ok">确定</l-button>'
323
- ), s.push("</div>"), s.join("");
324
- },
325
- updateContent: (s, t) => {
326
- const e = s.querySelector(".l-popconfirm-content");
327
- e && t && (e.innerHTML = t.content || "");
328
- }
101
+ var p = class {
102
+ options;
103
+ $refs = [];
104
+ $reference;
105
+ popoverElement;
106
+ updater;
107
+ _hideTimer;
108
+ constructor(t) {
109
+ this.options = {
110
+ trigger: "hover",
111
+ arrow: !0,
112
+ offset: 10,
113
+ arrowSize: 8,
114
+ disabled: !1,
115
+ updateContent: (e, t) => {
116
+ if (t && t.title) {
117
+ let r = n(".l-popover-content", e);
118
+ r && (r.textContent = t.title);
119
+ }
120
+ },
121
+ ...t
122
+ };
123
+ let r = [];
124
+ this.options.reference ? typeof this.options.reference == "string" ? r = [...e(this.options.reference)] : Array.isArray(this.options.reference) ? r.push(...this.options.reference) : r.push(this.options.reference) : r = [...e(".l-popover-reference")], this.$refs = r, this.popoverElement = this.options.popover, this._bindPopoverEvents(), this._init();
125
+ }
126
+ addReference(e) {
127
+ this.$refs && (this._bindReferenceEvents(e), this.$refs.push(e));
128
+ }
129
+ removeReference(e) {
130
+ if (this.$refs) {
131
+ let t = this.$refs.indexOf(e);
132
+ t !== -1 && (e == this.$reference && this.hide(), this._removeReferenceEvents(e), this.$refs.splice(t, 1));
133
+ }
134
+ }
135
+ _init() {
136
+ this.options.trigger && this.$refs && r(this.$refs, (e) => {
137
+ this._bindReferenceEvents(e);
138
+ }), a(document, "click", this._onOuterTap, { capture: !0 });
139
+ }
140
+ _bindReferenceEvents(e) {
141
+ let t = this.options.trigger;
142
+ ["click", "focus"].includes(t) ? a(e, "click", this._onRefTap) : t === "hover" && (a(e, "mouseenter", this._onMouseEnter), a(e, "mouseleave", this._onMouseLeave));
143
+ }
144
+ _removeReferenceEvents(e) {
145
+ i(e, "click", this._onRefTap), i(e, "mouseenter", this._onMouseEnter), i(e, "mouseleave", this._onMouseLeave);
146
+ }
147
+ _bindPopoverEvents() {
148
+ this.popoverElement && this.options.trigger === "hover" && (a(this.popoverElement, "mouseenter", this._onPopoverEnter), a(this.popoverElement, "mouseleave", this._onMouseLeave));
149
+ }
150
+ _onPopoverEnter = () => {
151
+ this._clearHideTimer();
152
+ };
153
+ _clearHideTimer() {
154
+ this._hideTimer &&= (clearTimeout(this._hideTimer), void 0);
155
+ }
156
+ _onMouseEnter = (e) => {
157
+ let t = e.target;
158
+ this._clearHideTimer(), this.$reference != t && this.show(t);
159
+ };
160
+ _onMouseLeave = () => {
161
+ this._clearHideTimer(), this.options.trigger === "hover" && (this._hideTimer = setTimeout(() => {
162
+ this.hide();
163
+ }, 50));
164
+ };
165
+ _onRefTap = (e) => {
166
+ this._destroyUpdater();
167
+ let t = e.target;
168
+ if (this.$reference) {
169
+ if (this.options.trigger === "focus") return;
170
+ this.hide();
171
+ return;
172
+ }
173
+ this.show(t);
174
+ };
175
+ show(e) {
176
+ let t = e.dataset, n = t.disabled;
177
+ if (n ??= this.options.disabled, !n) {
178
+ if (this.$reference) {
179
+ if (this.$reference === e) return;
180
+ this.hide();
181
+ }
182
+ if (this.$reference = e, this.popoverElement || (this._renderPopover(), this._bindPopoverEvents()), this.popoverElement) {
183
+ this.options.updateContent && this.options.updateContent(this.popoverElement, t), this._destroyUpdater();
184
+ let e = t.placement || this.options.placement || "top", n = Number(t.offset || this.options.offset || 10), r = t.popoverWidth || this.options.popoverWidth;
185
+ this.popoverElement.style.display = "block";
186
+ let i;
187
+ r && (i = r === "trigger" ? r : Number(r)), this.updater = f(this.$reference, this.popoverElement, {
188
+ placement: e,
189
+ popoverWidth: i,
190
+ offset: n,
191
+ arrowSize: this.options.arrowSize
192
+ }), this.options.onOpenChange && this.options.onOpenChange(!0);
193
+ }
194
+ }
195
+ }
196
+ isShow() {
197
+ return this.$reference != null;
198
+ }
199
+ hide() {
200
+ this._destroyUpdater(), this.popoverElement && (this.popoverElement.style.display = "none"), this.$reference = void 0, this.options.onOpenChange && this.options.onOpenChange(!1, this.popoverElement);
201
+ }
202
+ setOption(e, t) {
203
+ this.options[e] = t;
204
+ }
205
+ updatePopoverContent() {
206
+ this.popoverElement && this.options.updateContent && this.options.updateContent(this.popoverElement, {});
207
+ }
208
+ _onOuterTap = (e) => {
209
+ let t = e.target, n = !!(this.$reference && !this.$reference.contains(t) && this.$reference != t), r = !!(this.popoverElement && (this.popoverElement.contains(t) || this.popoverElement == t));
210
+ if (this.options.trigger !== "manual" && !n) {
211
+ if (this.options.trigger === "focus") {
212
+ this.hide();
213
+ return;
214
+ }
215
+ if (r) {
216
+ let [t, n, r] = o(e, "data-action", this.popoverElement);
217
+ if (t) {
218
+ let e = "";
219
+ n === "popconfirm-cancel" ? e = "cancel" : n === "popconfirm-ok" && (e = "ok"), e && this.hide(), this.options.onPopoverAction && this.options.onPopoverAction(e || n, r);
220
+ }
221
+ return;
222
+ }
223
+ this.hide();
224
+ }
225
+ this.options.onOutsideTap && this.options.onOutsideTap(e, !n, r);
226
+ };
227
+ _renderPopover() {
228
+ let e = `l-popover l-popover--${this.options.theme || "default"}`;
229
+ this.options.popoverClass && (e += ` ${this.options.popoverClass}`);
230
+ let n = t("div", { class: e }), r = this.options.contentRender;
231
+ if (r) {
232
+ let e = r();
233
+ typeof e == "string" ? n.innerHTML = e : n.appendChild(e);
234
+ } else {
235
+ let e = t("div", { class: "l-popover-content" });
236
+ n.appendChild(e);
237
+ }
238
+ this.options.arrow && n.appendChild(t("div", { class: "l-popover-arrow" })), document.body.appendChild(n), this.popoverElement = n;
239
+ }
240
+ _destroyUpdater() {
241
+ this.updater &&= (this.updater.destroy(), void 0);
242
+ }
243
+ destroy() {
244
+ this.hide(), this.$refs && r(this.$refs, (e) => {
245
+ this._removeReferenceEvents(e);
246
+ }), i(document, "click", this._onOuterTap, { capture: !0 }), this.options = void 0, this.$refs = void 0, this._clearHideTimer(), this.popoverElement && (i(this.popoverElement, "mouseenter", this._onPopoverEnter), i(this.popoverElement, "mouseleave", this._onMouseLeave), this.popoverElement.remove()), this.popoverElement = void 0;
247
+ }
248
+ }, m = {
249
+ theme: "popconfirm",
250
+ trigger: "click",
251
+ contentRender: () => {
252
+ let e = [];
253
+ return e.push("<div class=\"l-popconfirm-container\">"), e.push("<div class=\"l-popconfirm-icon-wrapper\">"), e.push("<l-warn-icon></l-warn-icon>"), e.push("</div><div class=\"l-popconfirm-content\"></div></div>"), e.push("<div class=\"l-popconfirm-footer\">"), e.push("<l-button class=\"l-popconfirm-btn\" data-action=\"popconfirm-cancel\">取消</l-button>"), e.push("<l-button class=\"l-popconfirm-btn\" type=\"primary\" data-action=\"popconfirm-ok\">确定</l-button>"), e.push("</div>"), e.join("");
254
+ },
255
+ updateContent: (e, t) => {
256
+ let n = e.querySelector(".l-popconfirm-content");
257
+ n && t && (n.innerHTML = t.content || "");
258
+ }
329
259
  };
330
- function x(s, t) {
331
- return s.classList.contains(t) ? s : y(`.${t}`, s);
260
+ function h(t, n) {
261
+ return t.classList.contains(n) ? t : e(`.${n}`, t);
332
262
  }
333
- function H(s, t, e) {
334
- let o = new MutationObserver((n) => {
335
- n.forEach((r) => {
336
- r.type === "childList" && ($(r.addedNodes, (i) => {
337
- let p = x(i, t);
338
- p && (p instanceof HTMLElement ? e.addReference(p) : $(p, (h) => {
339
- e.addReference(h);
340
- }));
341
- }), $(r.removedNodes, (i) => {
342
- let p = x(i, t);
343
- p && (p instanceof HTMLElement ? e.removeReference(p) : $(p, (h) => {
344
- e.removeReference(h);
345
- }));
346
- }));
347
- });
348
- });
349
- return o.observe(s, {
350
- childList: !0,
351
- subtree: !0
352
- }), o;
263
+ function g(e, t, n) {
264
+ let i = new MutationObserver((e) => {
265
+ e.forEach((e) => {
266
+ e.type === "childList" && (r(e.addedNodes, (e) => {
267
+ let i = h(e, t);
268
+ i && (i instanceof HTMLElement ? n.addReference(i) : r(i, (e) => {
269
+ n.addReference(e);
270
+ }));
271
+ }), r(e.removedNodes, (e) => {
272
+ let i = h(e, t);
273
+ i && (i instanceof HTMLElement ? n.removeReference(i) : r(i, (e) => {
274
+ n.removeReference(e);
275
+ }));
276
+ }));
277
+ });
278
+ });
279
+ return i.observe(e, {
280
+ childList: !0,
281
+ subtree: !0
282
+ }), i;
353
283
  }
354
- export {
355
- z as Popover,
356
- L as autoUpdate,
357
- H as createPopoverObserver,
358
- C as getOverflowAncestors,
359
- S as popconfirmProps,
360
- b as updatePosition
361
- };
284
+ //#endregion
285
+ export { p as Popover, f as autoUpdate, g as createPopoverObserver, c as getOverflowAncestors, m as popconfirmProps, d as updatePosition };