litos-ui 0.3.0 → 0.6.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 (80) hide show
  1. package/lib/base.d.ts +3 -3
  2. package/lib/base.js +29 -27
  3. package/lib/browser.d.ts +7 -0
  4. package/lib/button/index.js +10 -11
  5. package/lib/color_picker/index.d.ts +13 -0
  6. package/lib/color_picker/index.js +44 -0
  7. package/lib/form/form_inner.js +26 -26
  8. package/lib/form/form_item.js +1 -1
  9. package/lib/form/index.js +1 -1
  10. package/lib/icon/arrow_left.d.ts +5 -0
  11. package/lib/icon/arrow_left.js +13 -0
  12. package/lib/icon/arrow_right.d.ts +5 -0
  13. package/lib/icon/arrow_right.js +13 -0
  14. package/lib/icon/arrow_up.d.ts +6 -0
  15. package/lib/icon/arrow_up.js +16 -0
  16. package/lib/icon/base.js +13 -13
  17. package/lib/icon/moon.d.ts +6 -0
  18. package/lib/icon/moon.js +16 -0
  19. package/lib/icon/reduction.d.ts +6 -0
  20. package/lib/icon/reduction.js +16 -0
  21. package/lib/icon/refresh_left.d.ts +6 -0
  22. package/lib/icon/refresh_left.js +16 -0
  23. package/lib/icon/refresh_right.d.ts +5 -0
  24. package/lib/icon/refresh_right.js +13 -0
  25. package/lib/icon/sort.d.ts +5 -0
  26. package/lib/icon/sort.js +13 -0
  27. package/lib/icon/sun.d.ts +6 -0
  28. package/lib/icon/sun.js +16 -0
  29. package/lib/icon/theme_default.d.ts +6 -0
  30. package/lib/icon/theme_default.js +16 -0
  31. package/lib/index-116dRdDj.js +4 -0
  32. package/lib/index-BUyxD_nH.js +4 -0
  33. package/lib/index-BeOxuMd4.js +4 -0
  34. package/lib/index-Bl8lRTJd.js +4 -0
  35. package/lib/index-BxlGVrX3.js +4 -0
  36. package/lib/index-C98Kx857.js +4 -0
  37. package/lib/index-CMz7GCCH.js +4 -0
  38. package/lib/index-DJ70Xyma.js +4 -0
  39. package/lib/index-DKvzJmsR.js +4 -0
  40. package/lib/index.d.ts +40 -1
  41. package/lib/index.js +82 -36
  42. package/lib/input/index.d.ts +1 -1
  43. package/lib/input/index.js +14 -14
  44. package/lib/list/index.js +1 -1
  45. package/lib/litos-ui.css +1 -1
  46. package/lib/litos-ui.min.js +1 -1
  47. package/lib/message/index.js +32 -32
  48. package/lib/polygon/index.d.ts +9 -0
  49. package/lib/polygon/index.js +30 -0
  50. package/lib/popover/index.d.ts +34 -0
  51. package/lib/popover/index.js +153 -0
  52. package/lib/radio/index.d.ts +1 -0
  53. package/lib/radio/index.js +61 -49
  54. package/lib/select_ori/index.d.ts +21 -0
  55. package/lib/select_ori/index.js +59 -0
  56. package/lib/switch/index.d.ts +18 -0
  57. package/lib/switch/index.js +64 -0
  58. package/lib/tabbar/index.d.ts +50 -0
  59. package/lib/tabbar/index.js +186 -0
  60. package/lib/theme/index.d.ts +12 -0
  61. package/lib/theme/index.js +95 -0
  62. package/lib/theme/theme_color.d.ts +9 -0
  63. package/lib/theme/theme_color.js +40 -0
  64. package/lib/utils/clickoutside.d.ts +5 -0
  65. package/lib/utils/clickoutside.js +22 -0
  66. package/lib/utils/event.js +24 -0
  67. package/lib/utils/index.d.ts +88 -0
  68. package/lib/utils/index.js +139 -0
  69. package/lib/utils/transition.js +58 -0
  70. package/package.json +69 -68
  71. package/styles/animation.css +13 -0
  72. package/styles/container.css +51 -0
  73. package/styles/scrollbar.css +23 -0
  74. package/styles/transition.css +33 -0
  75. package/lib/index-Boq1Q7q9.js +0 -4
  76. package/lib/index-ColsUDnt.js +0 -4
  77. package/lib/transition.d.ts +0 -15
  78. package/lib/transition.js +0 -52
  79. package/lib/util.d.ts +0 -40
  80. package/lib/util.js +0 -56
@@ -0,0 +1,95 @@
1
+ var C = Object.defineProperty;
2
+ var b = (e) => {
3
+ throw TypeError(e);
4
+ };
5
+ var E = (e, n, t) => n in e ? C(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
6
+ var r = (e, n, t) => E(e, typeof n != "symbol" ? n + "" : n, t), m = (e, n, t) => n.has(e) || b("Cannot " + t);
7
+ var o = (e, n, t) => (m(e, n, "read from private field"), t ? t.call(e) : n.get(e)), u = (e, n, t) => n.has(e) ? b("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), p = (e, n, t, s) => (m(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), h = (e, n, t) => (m(e, n, "access private method"), t);
8
+ import M from "../base.js";
9
+ import { initAttr as R } from "../utils/index.js";
10
+ import { create as d, $one as H, on as f, off as k } from "ph-utils/dom";
11
+ import { getTheme as L, applyTheme as j } from "ph-utils/theme";
12
+ const A = [
13
+ { value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
14
+ { value: "light", text: "浅色模式", icon: "l-sun-icon" },
15
+ { value: "dark", text: "深色模式", icon: "l-moon-icon" }
16
+ ];
17
+ var l, i, $, v, y, g, w, c, T, x;
18
+ class B extends M {
19
+ constructor() {
20
+ super();
21
+ u(this, i);
22
+ r(this, "type", "button");
23
+ r(this, "label", "text");
24
+ r(this, "theme");
25
+ u(this, l);
26
+ u(this, c, async (t) => {
27
+ let s;
28
+ if (this.type === "button")
29
+ s = this.theme === "dark" ? "auto" : "dark";
30
+ else {
31
+ const a = t.target.value;
32
+ this.type !== "switch" ? s = a : s = a ? "dark" : "light";
33
+ }
34
+ await j(s), this.theme = s, this.type === "button" && h(this, i, v).call(this, o(this, l)), this.dispatchEvent(new CustomEvent("change", { detail: s }));
35
+ });
36
+ R(this), this.theme = L();
37
+ }
38
+ connectedCallback() {
39
+ this.loadStyle(["theme"]), super.connectedCallback(), h(this, i, T).call(this);
40
+ }
41
+ disconnectedCallback() {
42
+ super.disconnectedCallback(), h(this, i, x).call(this);
43
+ }
44
+ render() {
45
+ switch (this.type) {
46
+ case "select":
47
+ return h(this, i, y).call(this);
48
+ case "radio":
49
+ return h(this, i, w).call(this);
50
+ case "switch":
51
+ return h(this, i, g).call(this);
52
+ default:
53
+ return h(this, i, $).call(this);
54
+ }
55
+ }
56
+ }
57
+ l = new WeakMap(), i = new WeakSet(), $ = function() {
58
+ const t = d("l-button", {
59
+ class: "l-theme-btn l-theme-inner"
60
+ });
61
+ return h(this, i, v).call(this, t), t;
62
+ }, v = function(t) {
63
+ const s = this.theme === "auto" ? "sun" : "moon";
64
+ t.innerHTML = `<l-${s}-icon></l-${s}-icon>`;
65
+ }, y = function() {
66
+ const t = d("l-select-ori", {
67
+ class: "l-theme-inner"
68
+ });
69
+ t.value = this.theme;
70
+ const s = [
71
+ '<option value="auto">跟随系统</option>',
72
+ '<option value="light">浅色模式</option>',
73
+ '<option value="dark">深色模式</option>'
74
+ ];
75
+ return t.innerHTML = s.join(""), t;
76
+ }, g = function() {
77
+ const t = d("l-switch", {
78
+ class: "l-theme-switch l-theme-inner"
79
+ });
80
+ return t.value = this.theme === "dark", t.innerHTML = '<l-sun-icon slot="unchecked-action"></l-sun-icon><l-moon-icon slot="checked-action"></l-moon-icon>', t;
81
+ }, w = function() {
82
+ const t = d("l-radio", {
83
+ class: "l-theme-inner"
84
+ });
85
+ t.value = this.theme, t.type = "button";
86
+ const s = A.map((a) => this.label === "icon" ? `<${a.icon} radio-value="${a.value}"></${a.icon}>` : `<span radio-value="${a.value}">${a.text}</span>`);
87
+ return t.innerHTML = s.join(""), t;
88
+ }, c = new WeakMap(), T = function() {
89
+ p(this, l, H(".l-theme-inner", this.root)), this.type === "button" ? f(o(this, l), "click", o(this, c)) : f(o(this, l), "change", o(this, c));
90
+ }, x = function() {
91
+ o(this, l) && (this.type === "button" ? k(o(this, l), "click", o(this, c)) : k(o(this, l), "change", o(this, c)), p(this, l, void 0));
92
+ }, r(B, "baseName", "theme");
93
+ export {
94
+ B as default
95
+ };
@@ -0,0 +1,9 @@
1
+ import BaseComponent from "../base";
2
+ export default class ThemeColor extends BaseComponent {
3
+ #private;
4
+ static baseName: string;
5
+ color: string;
6
+ constructor();
7
+ connectedCallback(): void;
8
+ render(): string | void | HTMLElement | HTMLElement[];
9
+ }
@@ -0,0 +1,40 @@
1
+ var d = Object.defineProperty;
2
+ var s = (o) => {
3
+ throw TypeError(o);
4
+ };
5
+ var u = (o, t, e) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
6
+ var a = (o, t, e) => u(o, typeof t != "symbol" ? t + "" : t, e), i = (o, t, e) => t.has(o) || s("Cannot " + e);
7
+ var h = (o, t, e) => (i(o, t, "read from private field"), e ? e.call(o) : t.get(o)), l = (o, t, e) => t.has(o) ? s("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e);
8
+ var m = (o, t, e) => (i(o, t, "access private method"), e);
9
+ import { $one as C, on as k } from "ph-utils/dom";
10
+ import f from "../base.js";
11
+ import { getColorTheme as g, applyColorTheme as v } from "ph-utils/theme";
12
+ var c, p, r;
13
+ class E extends f {
14
+ constructor() {
15
+ super();
16
+ l(this, c);
17
+ a(this, "color");
18
+ l(this, r, async (e) => {
19
+ const n = e.detail;
20
+ this.color = n, await v(n), this.dispatchEvent(new CustomEvent("change", { detail: n }));
21
+ });
22
+ this.color = g() || "#722ed1";
23
+ }
24
+ connectedCallback() {
25
+ super.connectedCallback(), m(this, c, p).call(this);
26
+ }
27
+ render() {
28
+ const e = document.createElement(
29
+ "l-color-picker"
30
+ );
31
+ return e.value = this.color, e;
32
+ }
33
+ }
34
+ c = new WeakSet(), p = function() {
35
+ const e = C("l-color-picker", this.root);
36
+ e && k(e, "change", h(this, r));
37
+ }, r = new WeakMap(), a(E, "baseName", "theme-color");
38
+ export {
39
+ E as default
40
+ };
@@ -0,0 +1,5 @@
1
+ /** 事件处理函数 */
2
+ type ClickHandler = (e: Event) => void;
3
+ export declare function set(el: HTMLElement, handler: ClickHandler): void;
4
+ export declare function remove(el: HTMLElement): void;
5
+ export {};
@@ -0,0 +1,22 @@
1
+ const s = /* @__PURE__ */ new Map();
2
+ function o(t) {
3
+ for (const n of s.values())
4
+ for (const e of n)
5
+ f(t, e);
6
+ }
7
+ function f(t, n) {
8
+ const e = t.target, i = !e, c = n.el.contains(e), r = n.el === e;
9
+ i || c || r || n.handler(t);
10
+ }
11
+ function u(t, n) {
12
+ s.has(t) || s.set(t, []);
13
+ const e = s.get(t);
14
+ e && e.push({ el: t, handler: n }), s.size === 1 && document.addEventListener("click", o, !0);
15
+ }
16
+ function a(t) {
17
+ s.delete(t), s.size === 0 && document.removeEventListener("click", o, !0);
18
+ }
19
+ export {
20
+ a as remove,
21
+ u as set
22
+ };
@@ -0,0 +1,24 @@
1
+ let i;
2
+ function w(f, t, o) {
3
+ i == null && (i = /* @__PURE__ */ new Map()), i.has(f) || i.set(f, /* @__PURE__ */ new Map([[t, /* @__PURE__ */ new Set()]])), i.get(f).has(t) || i.get(f).set(t, /* @__PURE__ */ new Set()), i.get(f).get(t).add(o);
4
+ }
5
+ function z(f, t, o) {
6
+ var g, d, e, l, u, r;
7
+ (d = (g = i == null ? void 0 : i.get(f)) == null ? void 0 : g.get(t)) == null || d.delete(o), ((l = (e = i == null ? void 0 : i.get(f)) == null ? void 0 : e.get(t)) == null ? void 0 : l.size) == 0 && ((u = i.get(f)) == null || u.delete(t)), ((r = i == null ? void 0 : i.get(f)) == null ? void 0 : r.size) == 0 && i.delete(f), (i == null ? void 0 : i.size) == 0 && (i = void 0);
8
+ }
9
+ function p(f) {
10
+ f == null ? i != null && (i.clear(), i = void 0) : i != null && (i.delete(f), i.size === 0 && (i = void 0));
11
+ }
12
+ function m(f, t, ...o) {
13
+ var d;
14
+ const g = (d = i == null ? void 0 : i.get(f)) == null ? void 0 : d.get(t);
15
+ if (g != null)
16
+ for (const e of g)
17
+ e(...o);
18
+ }
19
+ export {
20
+ w as add,
21
+ p as clear,
22
+ m as emit,
23
+ z as remove
24
+ };
@@ -0,0 +1,88 @@
1
+ type UIConfig = {
2
+ /** 注册应用的前缀, 默认: lt */
3
+ prefix: string;
4
+ };
5
+ export declare function config(cfg: Partial<UIConfig>): void;
6
+ /**
7
+ * 注册 Web Components 组件
8
+ * @param component Web Components 组件
9
+ * @param name 组件名称, 如果不填, 则根据组件的 baseName 生成
10
+ */
11
+ export declare function regist(component: any | any[], name?: string): void;
12
+ /**
13
+ * 生成一个唯一标识符,格式为:`uiConfig.prefix-递增的seed值`。
14
+ * 此函数用于在组件或应用中生成唯一的ID。
15
+ * @returns 唯一标识符字符串
16
+ */
17
+ export declare function useId(): string;
18
+ export declare function parseAttrValue(value: string, defaultValue?: string): string;
19
+ export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
20
+ export declare function parseAttrValue(value: string, defaultValue?: number, key?: string): number;
21
+ /**
22
+ * 初始化元素的属性值。
23
+ * 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。
24
+ * @param el - 要初始化属性的 HTML 元素。
25
+ */
26
+ export declare function initAttr(el: HTMLElement): void;
27
+ /**
28
+ * 生成 HTML 标签属性字符串。
29
+ * @param attr - 属性名。
30
+ * @param value - 属性值,可以是字符串、undefined 或布尔值。
31
+ * @returns 返回拼接好的属性字符串。
32
+ */
33
+ export declare function tagAttr(attr: string, value: string | undefined | boolean): string;
34
+ export declare function tagAttrs(attr: [string, string | undefined | boolean][]): string;
35
+ export declare function setAttrs(el: HTMLElement, attrs: [string, string | undefined | boolean][]): void;
36
+ /**
37
+ * 初始化元素过渡, 同时会监听 l-transition-emit 变化自动执行隐藏动画, show - 显示元素, hide - 隐藏元素
38
+ *
39
+ * 注意需要在页面结束后调用 destroy 销毁监听
40
+ *
41
+ * @param els 需要初始化的元素列表, 如果不传则会自动查找页面中带有 l-transition 属性的元素
42
+ * @returns
43
+ *
44
+ * @example
45
+ * // html
46
+ * <div
47
+ * l-transition="l-opacity"
48
+ * l-transition-emit="show"
49
+ * l-transition-method="hide"
50
+ * >
51
+ * Hello World
52
+ * </div>
53
+ * // js
54
+ * const trans = createTransition();
55
+ *
56
+ * // 销毁监听
57
+ * transition.destroy();
58
+ */
59
+ export declare function createTransition(): {
60
+ destroy: () => void;
61
+ add: (elems: HTMLElement[]) => void;
62
+ init: (els?: HTMLElement[]) => void;
63
+ };
64
+ /**
65
+ * 获取悬浮窗 y 偏移
66
+ * @param targetRect
67
+ * @param popoverRect
68
+ * @param mainAlign
69
+ * @param crossAlign
70
+ * @returns
71
+ */
72
+ export declare function getPopoverOffsetY(targetRect: DOMRect, popoverRect: DomRectPos, mainAlign: string, crossAlign: string, offset?: number): number;
73
+ type DomRectPos = {
74
+ x: number;
75
+ y: number;
76
+ width: number;
77
+ height: number;
78
+ left: number;
79
+ top: number;
80
+ };
81
+ export declare function getPopoverOffsetX(targetRect: DOMRect, popoverRect: DomRectPos, mainAlign: string, crossAlign: string, offset?: number): number;
82
+ export declare function impactDetect(targetRect: DOMRect, popoverRect: DomRectPos, mainAlign: string, crossAlign: string, scrollLeft: number, scrollTop: number, leftDiff: number, topDiff: number, offset?: number, position?: string): {
83
+ x: number;
84
+ y: number;
85
+ mainAlign: string;
86
+ crossAlign: string;
87
+ };
88
+ export {};
@@ -0,0 +1,139 @@
1
+ import { isBlank as $ } from "ph-utils";
2
+ import { iterate as N, transition as w, $ as p } from "ph-utils/dom";
3
+ let E = -1, y = {
4
+ /** 注册应用的前缀 */
5
+ prefix: "l"
6
+ };
7
+ function j(t) {
8
+ y = { ...y, ...t };
9
+ }
10
+ function k(t, r) {
11
+ const e = Array.isArray(t) ? t : [t];
12
+ for (const i of e) {
13
+ const n = r || `${y.prefix}-${i.baseName}`;
14
+ customElements.get(n) || customElements.define(n, i);
15
+ }
16
+ }
17
+ function V() {
18
+ return `${y.prefix}-${++E}`;
19
+ }
20
+ function W(t, r, e) {
21
+ if (t == null) return r;
22
+ switch (typeof r) {
23
+ case "boolean":
24
+ return t === "" || t === "true" || t === "1" || t === e;
25
+ case "number":
26
+ return Number(t);
27
+ default:
28
+ return t;
29
+ }
30
+ }
31
+ function _(t) {
32
+ const r = t.attributes;
33
+ for (const e of r) {
34
+ const { name: i, value: n } = e;
35
+ if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$"))
36
+ continue;
37
+ const f = i.split("-").map((o, h) => h === 0 ? o : o[0].toUpperCase() + o.slice(1)).join(""), u = W(n, t[f], i);
38
+ t[f] = u, i === "value" && (t._resetValue = u);
39
+ }
40
+ }
41
+ function C(t, r) {
42
+ let e = " ";
43
+ return r === !0 ? e = ` ${t}` : typeof r == "string" && !$(r) && (e = ` ${t}="${r}"`), e;
44
+ }
45
+ function B(t) {
46
+ return t.map((e) => C(e[0], e[1])).join("");
47
+ }
48
+ function F(t, r) {
49
+ for (const e of r) {
50
+ const i = e[1], n = e[0];
51
+ i === !0 ? t.setAttribute(n, "") : typeof i == "string" && !$(i) && t.setAttribute(n, i);
52
+ }
53
+ }
54
+ function M() {
55
+ let t;
56
+ const r = {
57
+ attributes: !0,
58
+ attributeFilter: ["l-transition-emit"]
59
+ }, e = (f) => {
60
+ for (let u of f)
61
+ if (u.type === "attributes" && u.attributeName) {
62
+ const o = u.target, h = o.getAttribute(u.attributeName) || "show", b = o.getAttribute("l-transition") || "l", m = o.getAttribute("l-transition-method") || "hide";
63
+ h === "show" ? (o.style.removeProperty("display"), w(o, b, "enter")) : w(o, b, "leave", () => {
64
+ m === "remove" ? o.remove() : o.style.display = "none";
65
+ });
66
+ }
67
+ };
68
+ function i(f) {
69
+ f && f.length > 0 && (t == null && (t = new MutationObserver(e)), N(f, (u) => {
70
+ const o = u.getAttribute("l-transition");
71
+ o && (w(u, o, "enter"), t.observe(u, r));
72
+ }));
73
+ }
74
+ function n(f) {
75
+ f == null && (f = p("[l-transition]"), i(f));
76
+ }
77
+ function s() {
78
+ t && (t.disconnect(), t = void 0);
79
+ }
80
+ return { destroy: s, add: i, init: n };
81
+ }
82
+ function c(t, r, e, i, n = 10) {
83
+ let s = 0;
84
+ return e === "top" ? s = r.height + n : e === "bottom" ? s = -(t.height + n) : (e === "left" || e === "right") && (i === "" ? s = r.height / 2 - t.height / 2 : i === "end" && (s = r.height - t.height)), s;
85
+ }
86
+ function x(t, r, e, i, n = 10) {
87
+ let s = 0;
88
+ return e === "left" ? s = r.width + n : e === "right" ? s = -(t.width + n) : (e === "top" || e === "bottom") && (i === "" ? s = r.width / 2 - t.width / 2 : i === "end" && (s = r.width - t.width)), s;
89
+ }
90
+ function U(t, r, e, i, n, s, f, u, o = 10, h = "absolute") {
91
+ const b = window.innerHeight + s - 10, m = window.innerWidth + n - 10;
92
+ let d = t.top + s - u;
93
+ d + r.height > b && (e === "left" || e === "right" ? i = "end" : e = "top", u = c(
94
+ t,
95
+ r,
96
+ e,
97
+ i,
98
+ o
99
+ ), d = t.top + s - u), d < s && (e === "left" || e === "right" ? i = "start" : e = "bottom");
100
+ let a = t.left + n - f;
101
+ return a + r.width > m && (e === "top" || e === "bottom" ? i = "end" : e = "left", f = x(
102
+ t,
103
+ r,
104
+ e,
105
+ i,
106
+ o
107
+ ), a = t.left + n - f), a < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), h === "fixed" && (u = c(
108
+ t,
109
+ r,
110
+ e,
111
+ i,
112
+ o
113
+ ), f = x(
114
+ t,
115
+ r,
116
+ e,
117
+ i,
118
+ o
119
+ ), a = t.left + n - f, d = t.top + s - u), {
120
+ x: a,
121
+ y: d,
122
+ mainAlign: e,
123
+ crossAlign: i
124
+ };
125
+ }
126
+ export {
127
+ j as config,
128
+ M as createTransition,
129
+ x as getPopoverOffsetX,
130
+ c as getPopoverOffsetY,
131
+ U as impactDetect,
132
+ _ as initAttr,
133
+ W as parseAttrValue,
134
+ k as regist,
135
+ F as setAttrs,
136
+ C as tagAttr,
137
+ B as tagAttrs,
138
+ V as useId
139
+ };
@@ -0,0 +1,58 @@
1
+ var c = Object.defineProperty;
2
+ var p = (s, e, t) => e in s ? c(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var o = (s, e, t) => p(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { initAttr as d } from "./index.js";
5
+ import u from "../base.js";
6
+ import "../message/index.js";
7
+ import { transition as n } from "ph-utils/dom";
8
+ import "ph-utils";
9
+ import "ph-utils/validator";
10
+ import "../button/index.js";
11
+ import "../list/index.js";
12
+ import "ph-utils/theme";
13
+ class m extends u {
14
+ constructor() {
15
+ super();
16
+ /** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
17
+ o(this, "sheetRec");
18
+ o(this, "duration", "0.3s");
19
+ d(this), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
20
+ }
21
+ static get observedAttributes() {
22
+ return ["sheets"];
23
+ }
24
+ connectedCallback() {
25
+ super.connectedCallback(), this.show();
26
+ }
27
+ render() {
28
+ this.shadow.innerHTML = "<slot></slot>";
29
+ }
30
+ attributeChangedCallback(t, r, i) {
31
+ t === "sheets" && (this.sheetRec = this._parseSheets(i));
32
+ }
33
+ show() {
34
+ const t = this._getSlotFirstChild();
35
+ t && n(t, this.sheetRec, "enter");
36
+ }
37
+ hide(t) {
38
+ const r = this._getSlotFirstChild();
39
+ r && n(r, this.sheetRec, "leave", t);
40
+ }
41
+ _parseSheets(t) {
42
+ const r = t.split(";"), i = [];
43
+ return r.forEach((h) => {
44
+ if (h) {
45
+ const [a, l] = h.split(":");
46
+ i.push([a.trim(), l.trim(), this.duration]);
47
+ }
48
+ }), i;
49
+ }
50
+ _getSlotFirstChild() {
51
+ const t = this.shadow.querySelector("slot");
52
+ return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
53
+ }
54
+ }
55
+ o(m, "baseName", "transition");
56
+ export {
57
+ m as Transition
58
+ };
package/package.json CHANGED
@@ -1,68 +1,69 @@
1
- {
2
- "name": "litos-ui",
3
- "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.3.0",
5
- "type": "module",
6
- "devDependencies": {
7
- "@eslint/js": "^9.16.0",
8
- "@types/node": "^22.10.1",
9
- "eslint": "^9.16.0",
10
- "globals": "^15.13.0",
11
- "less": "^4.2.1",
12
- "lightningcss": "^1.28.2",
13
- "prettier": "^3.4.2",
14
- "typescript": "^5.7.2",
15
- "typescript-eslint": "^8.18.0",
16
- "vite": "^6.0.3",
17
- "vitepress": "^1.5.0"
18
- },
19
- "files": [
20
- "lib",
21
- "styles"
22
- ],
23
- "main": "./lib/index.js",
24
- "module": "./lib/index.js",
25
- "types": "./lib/index.d.ts",
26
- "jsdelivr": "./lib/litos-ui.min.js",
27
- "unpkg": "./lib/litos-ui.min.js",
28
- "exports": {
29
- "./styles/*": "./styles/*",
30
- "./lib/*": "./lib/*",
31
- ".": {
32
- "import": "./lib/index.js",
33
- "types": "./lib/index.d.ts",
34
- "require": "./lib/index.js"
35
- }
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/DvShu/litos-ui.git"
40
- },
41
- "keywords": [
42
- "litos-ui",
43
- "web component",
44
- "ui framework",
45
- "component library"
46
- ],
47
- "homepage": "https://dvshu.github.io/litos-ui/",
48
- "bugs": {
49
- "url": "https://github.com/DvShu/litos-ui/issues"
50
- },
51
- "license": "MIT",
52
- "dependencies": {
53
- "ph-utils": "^0.11.4",
54
- "shiki": "^1.24.1"
55
- },
56
- "scripts": {
57
- "docs:dev": "vitepress dev docs",
58
- "docs:build": "vitepress build docs",
59
- "docs:preview": "vitepress preview docs",
60
- "inspect:eslint": "eslint --inspect-config",
61
- "new_version": "node scripts/version.js",
62
- "create": "node scripts/index.js create",
63
- "source:build": "vite build",
64
- "iife:build": "vite build -c vite_iife.config.ts --mode browser",
65
- "dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
66
- "lib:build": "pnpm source:build && pnpm dts:build && pnpm iife:build"
67
- }
68
- }
1
+ {
2
+ "name": "litos-ui",
3
+ "description": "基于 Web Component 的 UI 组件库",
4
+ "version": "0.6.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "docs:dev": "vitepress dev docs",
8
+ "docs:build": "vitepress build docs",
9
+ "docs:preview": "vitepress preview docs",
10
+ "inspect:eslint": "eslint --inspect-config",
11
+ "new_version": "node scripts/version.js",
12
+ "create": "node scripts/index.js create",
13
+ "source:build": "vite build",
14
+ "iife:build": "vite build -c vite_iife.config.ts --mode browser",
15
+ "dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
16
+ "lib:build": "pnpm source:build && pnpm dts:build && pnpm iife:build",
17
+ "vp": "scripts/publish.sh"
18
+ },
19
+ "devDependencies": {
20
+ "@eslint/js": "^9.17.0",
21
+ "@types/node": "^22.10.3",
22
+ "eslint": "^9.17.0",
23
+ "globals": "^15.14.0",
24
+ "less": "^4.2.1",
25
+ "lightningcss": "^1.28.2",
26
+ "prettier": "^3.4.2",
27
+ "typescript": "^5.7.2",
28
+ "typescript-eslint": "^8.19.0",
29
+ "vite": "^6.0.6",
30
+ "vitepress": "^1.5.0"
31
+ },
32
+ "files": [
33
+ "lib",
34
+ "styles"
35
+ ],
36
+ "main": "./lib/index.js",
37
+ "module": "./lib/index.js",
38
+ "types": "./lib/index.d.ts",
39
+ "jsdelivr": "./lib/litos-ui.min.js",
40
+ "unpkg": "./lib/litos-ui.min.js",
41
+ "exports": {
42
+ "./styles/*": "./styles/*",
43
+ "./lib/*": "./lib/*",
44
+ ".": {
45
+ "import": "./lib/index.js",
46
+ "types": "./lib/index.d.ts",
47
+ "require": "./lib/index.js"
48
+ }
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/DvShu/litos-ui.git"
53
+ },
54
+ "keywords": [
55
+ "litos-ui",
56
+ "web component",
57
+ "ui framework",
58
+ "component library"
59
+ ],
60
+ "homepage": "https://dvshu.github.io/litos-ui/",
61
+ "bugs": {
62
+ "url": "https://github.com/DvShu/litos-ui/issues"
63
+ },
64
+ "license": "MIT",
65
+ "dependencies": {
66
+ "ph-utils": "^0.13.1",
67
+ "shiki": "^1.24.4"
68
+ }
69
+ }
@@ -0,0 +1,13 @@
1
+ /* 旋转动画 */
2
+ @keyframes l-rotate-frame {
3
+ from {
4
+ transform: rotate3d(0, 0, 1, 0);
5
+ }
6
+ to {
7
+ transform: rotate3d(0, 0, 1, 360deg);
8
+ }
9
+ }
10
+ /** 应用旋转动画 */
11
+ .l-rotate-anim {
12
+ animation: l-rotate-frame var(--l-animation-duration, 1.5s) infinite linear;
13
+ }