litos-ui 0.15.5 → 0.15.7

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 (84) hide show
  1. package/lib/button/index.d.ts +4 -0
  2. package/lib/button/index.js +84 -57
  3. package/lib/check/checkbox.js +1 -1
  4. package/lib/check/radio.js +1 -1
  5. package/lib/{check-BlDsQQo0.js → check-A86JxUfd.js} +1 -1
  6. package/lib/collapse/index.d.ts +19 -0
  7. package/lib/collapse/index.js +88 -0
  8. package/lib/collapse/item.d.ts +15 -0
  9. package/lib/collapse/item.js +115 -0
  10. package/lib/color_picker/index.js +1 -1
  11. package/lib/date_picker/index.js +1 -1
  12. package/lib/description_panel/index.d.ts +4 -4
  13. package/lib/description_panel/index.js +59 -11
  14. package/lib/dialog/dialog_container.js +1 -1
  15. package/lib/form/form_inner.d.ts +2 -1
  16. package/lib/form/form_inner.js +16 -15
  17. package/lib/form/form_item.d.ts +3 -1
  18. package/lib/form/form_item.js +19 -13
  19. package/lib/form/index.js +8 -6
  20. package/lib/icon/d_arrow_left.d.ts +6 -0
  21. package/lib/icon/d_arrow_left.js +13 -0
  22. package/lib/icon/d_arrow_right.d.ts +6 -0
  23. package/lib/icon/d_arrow_right.js +13 -0
  24. package/lib/icon/more.d.ts +6 -0
  25. package/lib/icon/more.js +13 -0
  26. package/lib/icon/select.d.ts +6 -0
  27. package/lib/icon/select.js +13 -0
  28. package/lib/icon/zoom_in.d.ts +6 -0
  29. package/lib/icon/zoom_in.js +13 -0
  30. package/lib/icon/zoom_out.d.ts +6 -0
  31. package/lib/icon/zoom_out.js +13 -0
  32. package/lib/image/image_preview.d.ts +24 -0
  33. package/lib/image/image_preview.js +104 -0
  34. package/lib/image/index.d.ts +50 -0
  35. package/lib/image/index.js +176 -0
  36. package/lib/index-D4II9KsF.js +4 -0
  37. package/lib/index.d.ts +36 -4
  38. package/lib/index.js +157 -120
  39. package/lib/input/index.d.ts +6 -2
  40. package/lib/input/index.js +70 -51
  41. package/lib/litos-ui.css +1 -1
  42. package/lib/mask/index.d.ts +23 -0
  43. package/lib/mask/index.js +110 -0
  44. package/lib/md_input/index.js +11 -11
  45. package/lib/menu/index.js +46 -42
  46. package/lib/modal/index.d.ts +1 -1
  47. package/lib/modal/index.js +7 -7
  48. package/lib/modal/modal_box.js +10 -10
  49. package/lib/page_header/index.d.ts +20 -0
  50. package/lib/page_header/index.js +109 -0
  51. package/lib/pagination/index.d.ts +27 -0
  52. package/lib/pagination/index.js +248 -0
  53. package/lib/qrcode/index.js +4 -4
  54. package/lib/select/index.d.ts +79 -0
  55. package/lib/select/index.js +406 -0
  56. package/lib/select_ori/index.js +10 -10
  57. package/lib/switch/index.js +4 -4
  58. package/lib/tabbar/index.js +1 -1
  59. package/lib/tabbar/item.js +1 -1
  60. package/lib/table/index.d.ts +46 -0
  61. package/lib/table/index.js +200 -0
  62. package/lib/table/types.d.ts +28 -0
  63. package/lib/table/types.js +1 -0
  64. package/lib/tabs/index.d.ts +7 -0
  65. package/lib/tabs/index.js +43 -0
  66. package/lib/tag/index.d.ts +16 -0
  67. package/lib/tag/index.js +77 -0
  68. package/lib/theme/index.js +6 -6
  69. package/lib/utils/index.d.ts +6 -28
  70. package/lib/utils/index.js +61 -86
  71. package/lib/utils/popover.d.ts +137 -0
  72. package/lib/utils/popover.js +354 -0
  73. package/lib/utils/transition.js +26 -50
  74. package/package.json +13 -13
  75. package/styles/popover.css +66 -0
  76. package/styles/reset.css +1 -1
  77. package/styles/select.css +37 -0
  78. package/styles/tabs.css +13 -0
  79. package/styles/vars.css +2 -1
  80. package/lib/index-dwS1N2uN.js +0 -4
  81. package/lib/popconfirm/index.d.ts +0 -7
  82. package/lib/popconfirm/index.js +0 -30
  83. package/lib/popover/index.d.ts +0 -34
  84. package/lib/popover/index.js +0 -150
@@ -0,0 +1,137 @@
1
+ /**
2
+ * 获取给定元素的所有可滚动祖先元素
3
+ *
4
+ * @param element 给定的HTML元素
5
+ * @returns 返回包含所有可滚动祖先元素的数组
6
+ */
7
+ export declare function getOverflowAncestors(element: HTMLElement): HTMLElement[];
8
+ type PopoverPlacement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
9
+ type UpdatePositionProps = {
10
+ /** 浮动元素宽度 */
11
+ popoverWidth?: number | "trigger";
12
+ /** 弹出位置, 默认: top */
13
+ placement?: PopoverPlacement;
14
+ /** 偏移量, 默认: 10 */
15
+ offset?: number;
16
+ /** 指示箭头大小 */
17
+ arrowSize?: number;
18
+ };
19
+ /**
20
+ * 更新浮动元素的位置
21
+ *
22
+ * @param reference 参照元素
23
+ * @param floating 浮动元素
24
+ * @param options 配置项,默认值为 { placement: "top" }
25
+ *
26
+ * options 参数:
27
+ * - placement: 浮动元素的定位方式,可选值包括 top, right, bottom, left,支持带横轴对齐方式(如 "top-start", "right-end" 等)
28
+ * - popoverWidth: 浮动元素的宽度,可选值为具体数值或 "trigger"(表示与参照元素同宽)
29
+ */
30
+ export declare function updatePosition(reference: HTMLElement, floating: HTMLElement, options?: UpdatePositionProps): void;
31
+ export declare function autoUpdate(reference: HTMLElement, floating: HTMLElement, options: UpdatePositionProps): {
32
+ destroy: () => void;
33
+ };
34
+ type PopoverInitProps = {
35
+ /** 触发元素, 如果不传, 则默认查询所有的 .l-popover-reference 类节点 */
36
+ reference?: HTMLElement | HTMLElement[] | string;
37
+ /** Popover节点, 如果不传则会自动创建 */
38
+ popover?: HTMLElement;
39
+ popoverClass?: string;
40
+ /** Popover 内容渲染 */
41
+ contentRender?: () => HTMLElement | string | DocumentFragment;
42
+ /**
43
+ * Popover显示内容修改函数
44
+ * @param popoverElement Popover节点
45
+ * @param datas referecnce 节点上的 data 属性集
46
+ * @returns
47
+ */
48
+ updateContent?: (popoverElement: HTMLElement, datas?: Record<string, any>) => void;
49
+ /** 触发方式, 默认: hover */
50
+ trigger?: "click" | "hover" | "focus" | "manual";
51
+ /** 主题, default - 白底, tooltip - 黑底 */
52
+ theme?: "default" | "tooltip" | string;
53
+ /** 浮动元素宽度 */
54
+ popoverWidth?: number | "trigger";
55
+ /** 弹出位置, 默认: top */
56
+ placement?: PopoverPlacement;
57
+ /** 是否显示指示箭头 */
58
+ arrow?: boolean;
59
+ /** 指示箭头大小 */
60
+ arrowSize?: number;
61
+ /** 偏移量, 默认: 10 */
62
+ offset?: number;
63
+ /** 点击 Popover 内具有 data-action 的元素时触发 */
64
+ onPopoverAction?: (action: string, target: HTMLElement) => void;
65
+ onOpenChange?: (isOpen: boolean) => void;
66
+ disabled?: boolean;
67
+ };
68
+ export declare class Popover {
69
+ options: PopoverInitProps;
70
+ private $refs;
71
+ /** 激活的触发节点 */
72
+ private $reference?;
73
+ popoverElement?: HTMLElement;
74
+ private updater?;
75
+ private _hideTimer?;
76
+ constructor(props?: PopoverInitProps);
77
+ /**
78
+ * 向实例中添加一个引用元素
79
+ *
80
+ * @param reference 需要添加的引用元素
81
+ */
82
+ addReference(reference: HTMLElement): void;
83
+ /**
84
+ * 从引用列表中移除指定的引用
85
+ *
86
+ * @param referecnce 要移除的引用元素
87
+ */
88
+ removeReference(referecnce: HTMLElement): void;
89
+ _init(): void;
90
+ _bindReferenceEvents(ref: HTMLElement): void;
91
+ _removeReferenceEvents(ref: HTMLElement): void;
92
+ _bindPopoverEvents(): void;
93
+ _onPopoverEnter: () => void;
94
+ _clearHideTimer(): void;
95
+ _onMouseEnter: (e: Event) => void;
96
+ _onMouseLeave: () => void;
97
+ _onRefTap: (e: Event) => void;
98
+ /**
99
+ * 显示浮层。
100
+ *
101
+ * @param reference 浮层所对齐的 HTML 元素。
102
+ */
103
+ show(reference: HTMLElement): void;
104
+ isShow(): boolean;
105
+ /**
106
+ * 隐藏 Popover
107
+ */
108
+ hide(): void;
109
+ /** 重新设置选项 */
110
+ setOption(key: string, value: any): void;
111
+ updatePopoverContent(): void;
112
+ _onOuterTap: (e: Event) => void;
113
+ _renderPopover(): void;
114
+ _destroyUpdater(): void;
115
+ /**
116
+ * 销毁组件
117
+ *
118
+ * 销毁组件并移除相关事件监听器和 DOM 元素。
119
+ */
120
+ destroy(): void;
121
+ }
122
+ type PopconfirmInitProps = PopoverInitProps;
123
+ export declare const popconfirmProps: PopconfirmInitProps;
124
+ /**
125
+ * 创建 Popover 观察者
126
+ *
127
+ * 当指定元素的子节点发生变化时,会自动添加或移除 Popover 实例的引用元素。
128
+ *
129
+ * 通常用于列表子元素的 Popover, 列表又能增加和删除, 比如: List、Table
130
+ *
131
+ * @param observeElement - 要观察的元素
132
+ * @param refereceClass - 引用元素的类名
133
+ * @param popover - Popover 实例
134
+ * @returns 一个对象,包含一个 `disconnect` 方法,用于断开观察
135
+ */
136
+ export declare function createPopoverObserver(observeElement: HTMLElement, refereceClass: string, popover: Popover): MutationObserver;
137
+ export {};
@@ -0,0 +1,354 @@
1
+ import { $one as T, $ as y, iterate as $, on as d, off as a, shouldEventNext as g, $$ 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;
8
+ }
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;
17
+ }
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 P = `${e}${o === "" ? "" : "-" + o}`;
54
+ return {
55
+ x: m,
56
+ y: f,
57
+ mainAlign: e,
58
+ crossAlign: o,
59
+ placement: P
60
+ };
61
+ }
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
+ };
72
+ }
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
+ }
111
+ }
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 };
133
+ }
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._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 && !this.$reference && (this.$reference = t, this.popoverElement || (this._renderPopover(), this._bindPopoverEvents()), this.popoverElement)) {
228
+ this.options.updateContent && this.options.updateContent(this.popoverElement, e), this._destroyUpdater();
229
+ const n = e.placement || this.options.placement || "top", r = Number(e.offset || this.options.offset || 10), i = e.popoverWidth || this.options.popoverWidth;
230
+ this.popoverElement.style.display = "block";
231
+ let p;
232
+ i && (i !== "trigger" ? p = Number(i) : p = i), this.updater = L(this.$reference, this.popoverElement, {
233
+ placement: n,
234
+ popoverWidth: p,
235
+ offset: r,
236
+ arrowSize: this.options.arrowSize
237
+ }), this.options.onOpenChange && this.options.onOpenChange(!0);
238
+ }
239
+ }
240
+ isShow() {
241
+ return this.$reference != null;
242
+ }
243
+ /**
244
+ * 隐藏 Popover
245
+ */
246
+ hide() {
247
+ this._destroyUpdater(), this.popoverElement && (this.popoverElement.style.display = "none"), this.$reference = void 0, this.options.onOpenChange && this.options.onOpenChange(!1);
248
+ }
249
+ /** 重新设置选项 */
250
+ setOption(t, e) {
251
+ this.options[t] = e;
252
+ }
253
+ updatePopoverContent() {
254
+ this.popoverElement && this.options.updateContent && this.options.updateContent(this.popoverElement, {});
255
+ }
256
+ _onOuterTap = (t) => {
257
+ const e = t.target;
258
+ if (this.$reference && !this.$reference.contains(e) && this.$reference != e) {
259
+ if (this.options.trigger === "focus") {
260
+ this.hide();
261
+ return;
262
+ }
263
+ if (this.popoverElement && (this.popoverElement.contains(e) || this.popoverElement == e)) {
264
+ const [o, n, r] = g(
265
+ t,
266
+ "data-action",
267
+ this.popoverElement
268
+ );
269
+ if (o) {
270
+ let i = "";
271
+ n === "popconfirm-cancel" ? i = "cancel" : n === "popconfirm-ok" && (i = "ok"), i && this.hide(), this.options.onPopoverAction && this.options.onPopoverAction(i || n, r);
272
+ }
273
+ return;
274
+ }
275
+ this.hide();
276
+ }
277
+ };
278
+ _renderPopover() {
279
+ let e = `l-popover l-popover--${this.options.theme || "default"}`;
280
+ this.options.popoverClass && (e += ` ${this.options.popoverClass}`);
281
+ const o = w("div", {
282
+ class: e
283
+ }), n = this.options.contentRender;
284
+ if (n) {
285
+ const r = n();
286
+ typeof r == "string" ? o.innerHTML = r : o.appendChild(r);
287
+ } else {
288
+ const r = w("div", { class: "l-popover-content" });
289
+ o.appendChild(r);
290
+ }
291
+ this.options.arrow && o.appendChild(w("div", { class: "l-popover-arrow" })), document.body.appendChild(o), this.popoverElement = o;
292
+ }
293
+ _destroyUpdater() {
294
+ this.updater && (this.updater.destroy(), this.updater = void 0);
295
+ }
296
+ /**
297
+ * 销毁组件
298
+ *
299
+ * 销毁组件并移除相关事件监听器和 DOM 元素。
300
+ */
301
+ destroy() {
302
+ this.hide(), this.$refs && $(this.$refs, (t) => {
303
+ this._removeReferenceEvents(t);
304
+ }), 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;
305
+ }
306
+ }
307
+ const S = {
308
+ theme: "popconfirm",
309
+ trigger: "click",
310
+ contentRender: () => {
311
+ const s = [];
312
+ 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(
313
+ '<l-button class="l-popconfirm-btn" data-action="popconfirm-cancel">取消</l-button>'
314
+ ), s.push(
315
+ '<l-button class="l-popconfirm-btn" type="primary" data-action="popconfirm-ok">确定</l-button>'
316
+ ), s.push("</div>"), s.join("");
317
+ },
318
+ updateContent: (s, t) => {
319
+ const e = s.querySelector(".l-popconfirm-content");
320
+ e && t && (e.innerHTML = t.content || "");
321
+ }
322
+ };
323
+ function x(s, t) {
324
+ return s.classList.contains(t) ? s : y(`.${t}`, s);
325
+ }
326
+ function H(s, t, e) {
327
+ let o = new MutationObserver((n) => {
328
+ n.forEach((r) => {
329
+ r.type === "childList" && ($(r.addedNodes, (i) => {
330
+ let p = x(i, t);
331
+ p && (p instanceof HTMLElement ? e.addReference(p) : $(p, (h) => {
332
+ e.addReference(h);
333
+ }));
334
+ }), $(r.removedNodes, (i) => {
335
+ let p = x(i, t);
336
+ p && (p instanceof HTMLElement ? e.removeReference(p) : $(p, (h) => {
337
+ e.removeReference(h);
338
+ }));
339
+ }));
340
+ });
341
+ });
342
+ return o.observe(s, {
343
+ childList: !0,
344
+ subtree: !0
345
+ }), o;
346
+ }
347
+ export {
348
+ z as Popover,
349
+ L as autoUpdate,
350
+ H as createPopoverObserver,
351
+ C as getOverflowAncestors,
352
+ S as popconfirmProps,
353
+ b as updatePosition
354
+ };
@@ -1,56 +1,32 @@
1
- import { initAttr as h } from "./index.js";
2
- import a from "../base.js";
3
- import "../message/index.js";
4
- import { transition as i } from "ph-utils/dom";
5
- import "ph-utils";
6
- import "ph-utils/validator";
7
- import "ph-utils/color";
8
- import "ph-utils/theme";
9
- import "ph-utils/date";
10
- import "ph-utils/web";
11
- import "qrcode-generator-es";
12
- class R extends a {
13
- static baseName = "transition";
14
- /** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
15
- sheetRec;
16
- duration = "0.3s";
17
- static get observedAttributes() {
18
- return ["sheets"];
19
- }
20
- constructor() {
21
- super(), h(this), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
22
- }
23
- connectedCallback() {
24
- super.connectedCallback(), this.show();
25
- }
26
- render() {
27
- this.shadow.innerHTML = "<slot></slot>";
28
- }
29
- attributeChangedCallback(t, e, s) {
30
- t === "sheets" && (this.sheetRec = this._parseSheets(s));
31
- }
32
- show() {
33
- const t = this._getSlotFirstChild();
34
- t && i(t, this.sheetRec, "enter");
35
- }
36
- hide(t) {
37
- const e = this._getSlotFirstChild();
38
- e && i(e, this.sheetRec, "leave", t);
39
- }
40
- _parseSheets(t) {
41
- const e = t.split(";"), s = [];
42
- return e.forEach((r) => {
43
- if (r) {
44
- const [o, n] = r.split(":");
45
- s.push([o.trim(), n.trim(), this.duration]);
1
+ import { $ as d, iterate as m, transition as r } from "ph-utils/dom";
2
+ function g() {
3
+ let n;
4
+ const s = {
5
+ attributes: !0,
6
+ attributeFilter: ["l-transition-emit"]
7
+ }, u = (e) => {
8
+ for (let i of e)
9
+ if (i.type === "attributes" && i.attributeName) {
10
+ const t = i.target, b = t.getAttribute(i.attributeName) || "show", a = t.getAttribute("l-transition") || "l", c = t.getAttribute("l-transition-method") || "hide";
11
+ b === "show" ? (t.style.removeProperty("display"), r(t, a, "enter")) : r(t, a, "leave", () => {
12
+ c === "remove" ? t.remove() : t.style.display = "none";
13
+ });
46
14
  }
47
- }), s;
15
+ };
16
+ function o(e) {
17
+ e && e.length > 0 && (n == null && (n = new MutationObserver(u)), m(e, (i) => {
18
+ const t = i.getAttribute("l-transition");
19
+ t && (r(i, t, "enter"), n.observe(i, s));
20
+ }));
21
+ }
22
+ function f(e) {
23
+ e == null && (e = d("[l-transition]"), o(e));
48
24
  }
49
- _getSlotFirstChild() {
50
- const t = this.shadow.querySelector("slot");
51
- return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
25
+ function l() {
26
+ n && (n.disconnect(), n = void 0);
52
27
  }
28
+ return { destroy: l, add: o, init: f };
53
29
  }
54
30
  export {
55
- R as Transition
31
+ g as createTransition
56
32
  };
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.15.5",
4
+ "version": "0.15.7",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
- "@eslint/js": "^9.30.1",
8
- "@eslint/markdown": "^6.6.0",
9
- "@types/node": "^24.0.10",
10
- "eslint": "^9.30.1",
7
+ "@eslint/js": "^9.34.0",
8
+ "@eslint/markdown": "^7.2.0",
9
+ "@types/node": "^24.3.0",
10
+ "eslint": "^9.34.0",
11
11
  "globals": "^16.3.0",
12
- "less": "^4.3.0",
12
+ "less": "^4.4.1",
13
13
  "lightningcss": "^1.30.1",
14
14
  "prettier": "^3.6.2",
15
- "typescript": "^5.8.3",
16
- "typescript-eslint": "^8.35.1",
17
- "vite": "^7.0.2",
15
+ "typescript": "^5.9.2",
16
+ "typescript-eslint": "^8.41.0",
17
+ "vite": "^7.1.3",
18
18
  "vite-plugin-dts": "^4.5.4",
19
- "vitepress": "^1.6.3"
19
+ "vitepress": "^1.6.4"
20
20
  },
21
21
  "files": [
22
22
  "lib",
@@ -53,14 +53,14 @@
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
55
  "iconify-icon": "^3.0.0",
56
- "ph-utils": "^0.15.4",
56
+ "ph-utils": "^0.16.2",
57
57
  "qrcode-generator-es": "^1.1.4",
58
- "shiki": "^3.7.0"
58
+ "shiki": "^3.12.0"
59
59
  },
60
60
  "scripts": {
61
61
  "dev": "vite dev",
62
62
  "build": "vite build",
63
- "docs:dev": "vitepress dev docs --force",
63
+ "docs:dev": "vitepress dev docs --force --host 0.0.0.0",
64
64
  "docs:build": "vitepress build docs",
65
65
  "docs:preview": "vitepress preview docs",
66
66
  "inspect:eslint": "eslint --inspect-config",
@@ -0,0 +1,66 @@
1
+ .l-popover {
2
+ --l-popover-background: #ffffff;
3
+ --l-popover-border-color: #e4e4e4;
4
+ --l-popover-color: #666666;
5
+ --l-popover-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
6
+ width: max-content;
7
+ position: absolute;
8
+ top: 0;
9
+ left: 0;
10
+ background: var(--l-popover-background);
11
+ box-shadow: var(--l-popover-box-shadow);
12
+ border: 1px solid var(--l-popover-border-color);
13
+ color: var(--l-popover-color);
14
+ border-radius: 4px;
15
+ font-size: 90%;
16
+ box-sizing: border-box;
17
+ display: none;
18
+ z-index: 300;
19
+ line-height: 1;
20
+ padding: 10px;
21
+ }
22
+ .l-popover-arrow {
23
+ position: absolute;
24
+ background: var(--l-popover-background);
25
+ width: var(--l-popover-arrow-size, 8px);
26
+ height: var(--l-popover-arrow-size, 8px);
27
+ transform: rotate(45deg);
28
+ box-sizing: border-box;
29
+ }
30
+ /* tooltip */
31
+ .l-popover.l-popover--tooltip {
32
+ --l-popover-color: #fff;
33
+ --l-popover-box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
34
+ --l-popover-background: #383838;
35
+ --l-popover-border-color: #383838;
36
+ font-size: 12px;
37
+ padding: 8px;
38
+ }
39
+
40
+ /* popconfirm */
41
+ .l-popover--popconfirm {
42
+ min-width: 150px;
43
+ }
44
+ .l-popover--popconfirm .l-popconfirm-container {
45
+ display: flex;
46
+ align-items: center;
47
+ }
48
+ .l-popover--popconfirm .l-popconfirm-icon-wrapper {
49
+ margin-right: 10px;
50
+ display: inline-flex;
51
+ color: var(--l-warn-color, #f90);
52
+ }
53
+ .l-popover--popconfirm .l-popconfirm-footer {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: flex-end;
57
+ margin-top: 7px;
58
+ gap: 7px;
59
+ }
60
+ .l-popover--popconfirm .l-popconfirm-btn {
61
+ height: 24px;
62
+ }
63
+ .l-popover--popconfirm .l-popconfirm-btn::part(default) {
64
+ padding: 0 6px;
65
+ font-size: 13px;
66
+ }