litos-ui 0.9.0 → 0.11.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.
@@ -1,5 +1,5 @@
1
1
  import { isBlank as N } from "ph-utils";
2
- import { iterate as $, transition as m, $ as p } from "ph-utils/dom";
2
+ import { $, iterate as p, transition as m } from "ph-utils/dom";
3
3
  let E = -1, y = {
4
4
  /** 注册应用的前缀 */
5
5
  prefix: "l"
@@ -17,7 +17,7 @@ function _(t, r) {
17
17
  function k() {
18
18
  return `${y.prefix}-${++E}`;
19
19
  }
20
- function W(t, r, e) {
20
+ function I(t, r, e) {
21
21
  if (t == null) return r;
22
22
  switch (typeof r) {
23
23
  case "boolean":
@@ -34,16 +34,16 @@ function V(t) {
34
34
  const { name: i, value: n } = e;
35
35
  if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$") || ["id", "class", "style"].includes(i))
36
36
  continue;
37
- const s = i.split("-").map((d, a) => a === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), f = W(n, t[s], i), u = Object.getOwnPropertyNames(t), h = t._ignoreInitAttrs || [];
38
- i === "value" ? (t[s] = f, t._resetValue = f) : u.includes(s) && !h.includes(s) && (t[s] = f);
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));
39
39
  }
40
40
  }
41
- function I(t, r) {
41
+ function W(t, r) {
42
42
  let e = " ";
43
43
  return r === !0 ? e = ` ${t}` : typeof r == "string" && !N(r) && (e = ` ${t}="${r}"`), e;
44
44
  }
45
45
  function B(t) {
46
- return t.map((e) => I(e[0], e[1])).join("");
46
+ return t.map((e) => W(e[0], e[1])).join("");
47
47
  }
48
48
  function F(t, r) {
49
49
  for (const e of r) {
@@ -59,20 +59,20 @@ function M() {
59
59
  }, e = (s) => {
60
60
  for (let f of s)
61
61
  if (f.type === "attributes" && f.attributeName) {
62
- const u = f.target, h = u.getAttribute(f.attributeName) || "show", d = u.getAttribute("l-transition") || "l", a = u.getAttribute("l-transition-method") || "hide";
63
- h === "show" ? (u.style.removeProperty("display"), m(u, d, "enter")) : m(u, d, "leave", () => {
64
- a === "remove" ? u.remove() : u.style.display = "none";
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";
65
65
  });
66
66
  }
67
67
  };
68
68
  function i(s) {
69
- s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (f) => {
69
+ s && s.length > 0 && (t == null && (t = new MutationObserver(e)), p(s, (f) => {
70
70
  const u = f.getAttribute("l-transition");
71
71
  u && (m(f, u, "enter"), t.observe(f, r));
72
72
  }));
73
73
  }
74
74
  function n(s) {
75
- s == null && (s = p("[l-transition]"), i(s));
75
+ s == null && (s = $("[l-transition]"), i(s));
76
76
  }
77
77
  function o() {
78
78
  t && (t.disconnect(), t = void 0);
@@ -87,24 +87,24 @@ function x(t, r, e, i, n = 10) {
87
87
  let o = 0;
88
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;
89
89
  }
90
- function U(t, r, e, i, n, o, s, f, u = 10, h = "absolute") {
91
- const d = window.innerHeight + o - 10, a = window.innerWidth + n - 10;
92
- let b = t.top + o - f;
93
- b + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", f = w(
90
+ function U(t, r, e, i, n, o, s, f, u = 10, c = "absolute") {
91
+ const d = window.innerHeight + o - 10, h = window.innerWidth + n - 10;
92
+ let a = t.top + o - f;
93
+ a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", f = w(
94
94
  t,
95
95
  r,
96
96
  e,
97
97
  i,
98
98
  u
99
- ), b = t.top + o - f), b < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
100
- let c = t.left + n - s;
101
- return c + r.width > a && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = x(
99
+ ), a = t.top + o - f), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
100
+ let b = t.left + n - s;
101
+ return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = x(
102
102
  t,
103
103
  r,
104
104
  e,
105
105
  i,
106
106
  u
107
- ), c = t.left + n - s), c < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), h === "fixed" && (f = w(
107
+ ), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (f = w(
108
108
  t,
109
109
  r,
110
110
  e,
@@ -116,9 +116,9 @@ function U(t, r, e, i, n, o, s, f, u = 10, h = "absolute") {
116
116
  e,
117
117
  i,
118
118
  u
119
- ), c = t.left + n - s, b = t.top + o - f), {
120
- x: c,
121
- y: b,
119
+ ), b = t.left + n - s, a = t.top + o - f), {
120
+ x: b,
121
+ y: a,
122
122
  mainAlign: e,
123
123
  crossAlign: i
124
124
  };
@@ -130,10 +130,10 @@ export {
130
130
  w as getPopoverOffsetY,
131
131
  U as impactDetect,
132
132
  V as initAttr,
133
- W as parseAttrValue,
133
+ I as parseAttrValue,
134
134
  _ as regist,
135
135
  F as setAttrs,
136
- I as tagAttr,
136
+ W as tagAttr,
137
137
  B as tagAttrs,
138
138
  k as useId
139
139
  };
package/package.json CHANGED
@@ -1,72 +1,71 @@
1
- {
2
- "name": "litos-ui",
3
- "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.9.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite dev",
8
- "build": "vite build",
9
- "docs:dev": "vitepress dev docs",
10
- "docs:build": "vitepress build docs",
11
- "docs:preview": "vitepress preview docs",
12
- "inspect:eslint": "eslint --inspect-config",
13
- "new_version": "node scripts/version.js",
14
- "create": "node scripts/index.js create",
15
- "source:build": "vite build",
16
- "iife:build": "vite build -c vite_iife.config.ts --mode browser",
17
- "dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
18
- "lib:build": "pnpm source:build && pnpm dts:build && pnpm iife:build",
19
- "vp": "scripts/publish.sh"
20
- },
21
- "devDependencies": {
22
- "@eslint/js": "^9.17.0",
23
- "@types/node": "^22.10.3",
24
- "eslint": "^9.17.0",
25
- "globals": "^15.14.0",
26
- "less": "^4.2.1",
27
- "lightningcss": "^1.28.2",
28
- "prettier": "^3.4.2",
29
- "typescript": "^5.7.2",
30
- "typescript-eslint": "^8.19.0",
31
- "vite": "^6.0.6",
32
- "vite-plugin-dts": "^4.5.0",
33
- "vitepress": "^1.5.0"
34
- },
35
- "files": [
36
- "lib",
37
- "styles"
38
- ],
39
- "main": "./lib/index.js",
40
- "module": "./lib/index.js",
41
- "types": "./lib/index.d.ts",
42
- "jsdelivr": "./lib/litos-ui.min.js",
43
- "unpkg": "./lib/litos-ui.min.js",
44
- "exports": {
45
- "./styles/*": "./styles/*",
46
- "./lib/*": "./lib/*",
47
- ".": {
48
- "import": "./lib/index.js",
49
- "types": "./lib/index.d.ts",
50
- "require": "./lib/index.js"
51
- }
52
- },
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/DvShu/litos-ui.git"
56
- },
57
- "keywords": [
58
- "litos-ui",
59
- "web component",
60
- "ui framework",
61
- "component library"
62
- ],
63
- "homepage": "https://dvshu.github.io/litos-ui/",
64
- "bugs": {
65
- "url": "https://github.com/DvShu/litos-ui/issues"
66
- },
67
- "license": "MIT",
68
- "dependencies": {
69
- "ph-utils": "^0.13.1",
70
- "shiki": "^1.24.4"
71
- }
72
- }
1
+ {
2
+ "name": "litos-ui",
3
+ "description": "基于 Web Component 的 UI 组件库",
4
+ "version": "0.11.0",
5
+ "type": "module",
6
+ "devDependencies": {
7
+ "@eslint/js": "^9.21.0",
8
+ "@eslint/markdown": "^6.2.2",
9
+ "@types/node": "^22.13.5",
10
+ "eslint": "^9.21.0",
11
+ "globals": "^16.0.0",
12
+ "less": "^4.2.2",
13
+ "lightningcss": "^1.29.1",
14
+ "prettier": "^3.5.2",
15
+ "typescript": "^5.7.3",
16
+ "typescript-eslint": "^8.24.1",
17
+ "vite": "^6.1.1",
18
+ "vite-plugin-dts": "^4.5.0",
19
+ "vitepress": "^1.6.3"
20
+ },
21
+ "files": [
22
+ "lib",
23
+ "styles"
24
+ ],
25
+ "main": "./lib/index.js",
26
+ "module": "./lib/index.js",
27
+ "types": "./lib/index.d.ts",
28
+ "jsdelivr": "./lib/litos-ui.min.js",
29
+ "unpkg": "./lib/litos-ui.min.js",
30
+ "exports": {
31
+ "./styles/*": "./styles/*",
32
+ "./lib/*": "./lib/*",
33
+ ".": {
34
+ "import": "./lib/index.js",
35
+ "types": "./lib/index.d.ts",
36
+ "require": "./lib/index.js"
37
+ }
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/DvShu/litos-ui.git"
42
+ },
43
+ "keywords": [
44
+ "litos-ui",
45
+ "web component",
46
+ "ui framework",
47
+ "component library"
48
+ ],
49
+ "homepage": "https://dvshu.github.io/litos-ui/",
50
+ "bugs": {
51
+ "url": "https://github.com/DvShu/litos-ui/issues"
52
+ },
53
+ "license": "MIT",
54
+ "dependencies": {
55
+ "ph-utils": "^0.13.1",
56
+ "shiki": "^3.0.0"
57
+ },
58
+ "scripts": {
59
+ "dev": "vite dev",
60
+ "build": "vite build",
61
+ "docs:dev": "vitepress dev docs",
62
+ "docs:build": "vitepress build docs",
63
+ "docs:preview": "vitepress preview docs",
64
+ "inspect:eslint": "eslint --inspect-config",
65
+ "new_version": "node scripts/version.js",
66
+ "create": "node scripts/index.js create",
67
+ "dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
68
+ "lib:build": "pnpm build && pnpm dts:build",
69
+ "vp": "scripts/publish.sh"
70
+ }
71
+ }
@@ -0,0 +1,56 @@
1
+ .l-dialog {
2
+ --l-dialog-translate: translate3d(0, 80px, 0);
3
+ --l-dialog-width: 30%;
4
+ transform: scale3d(0, 0, 0);
5
+ border: none;
6
+ outline: none;
7
+ opacity: 0;
8
+ width: var(--l-dialog-width);
9
+ margin: 0 auto;
10
+ transition:
11
+ transform 0.3s,
12
+ opacity 0.3s;
13
+ max-width: 100%;
14
+ background-color: transparent;
15
+ }
16
+ .l-dialog-close-outside {
17
+ --l-dialog-translate: translate3d(5px, 90px, 0);
18
+ }
19
+ .l-dialog--vertical-middle {
20
+ --l-dialog-translate: translate3d(0, 0, 0);
21
+ margin: auto;
22
+ }
23
+ .l-dialog-close-outside.l-dialog--vertical-middle {
24
+ --l-dialog-translate: translate3d(5px, 0, 0);
25
+ }
26
+ .l-dialog--vertical-bottom {
27
+ --l-dialog-translate: translate3d(0, -100%, 0);
28
+ top: 100%;
29
+ border-bottom-left-radius: 0;
30
+ border-bottom-right-radius: 0;
31
+ }
32
+ .l-dialog-close-outside.l-dialog--vertical-bottom {
33
+ --l-dialog-translate: translate3d(5px, -100%, 0);
34
+ }
35
+ .l-dialog::backdrop {
36
+ background-color: rgba(0, 0, 0, 0.7);
37
+ opacity: 0;
38
+ transition: opacity 0.3s;
39
+ }
40
+ .l-dialog--open {
41
+ transform: scale3d(1, 1, 1) var(--l-dialog-translate);
42
+ opacity: 1;
43
+ }
44
+ .l-dialog--open::backdrop {
45
+ opacity: 1;
46
+ }
47
+ .l-body--dialog-open {
48
+ overflow: hidden;
49
+ }
50
+
51
+ @media screen and (max-width: 768px) {
52
+ .l-dialog {
53
+ width: 80%;
54
+ max-width: 300px;
55
+ }
56
+ }
@@ -0,0 +1,100 @@
1
+ .l-loading:not(.l-loading-fullscreen) {
2
+ position: relative;
3
+ }
4
+ .l-loading-mask {
5
+ position: absolute;
6
+ top: 0;
7
+ right: 0;
8
+ bottom: 0;
9
+ left: 0;
10
+ background: rgba(0, 0, 0, 0.6);
11
+ border-radius: inherit;
12
+ display: flex;
13
+ justify-content: center;
14
+ align-items: center;
15
+ transition: opacity 0.3s ease-in-out;
16
+ opacity: 0;
17
+ }
18
+
19
+ .l-loading-spinner {
20
+ text-align: center;
21
+ }
22
+ .l-loading-spinner .circle {
23
+ display: inline;
24
+ width: 40px;
25
+ height: 40px;
26
+ animation: loading-rotate 1.5s linear infinite;
27
+ }
28
+
29
+ .l-loading-spinner .path {
30
+ stroke: var(--l-primary-color, #722ed1);
31
+ stroke-width: 2px;
32
+ stroke-linecap: round;
33
+ stroke-linejoin: round;
34
+ stroke-dasharray: 90, 150;
35
+ stroke-dashoffset: 0px;
36
+ }
37
+
38
+ .l-loading-spinner .l-loading-text {
39
+ color: var(--l-primary-color, #722ed1);
40
+ margin: 0;
41
+ font-size: 14px;
42
+ }
43
+
44
+ /* 全屏组件 */
45
+ .l-loading-fullscreen.l-loading-lock {
46
+ overflow: hidden;
47
+ }
48
+ .l-loading-fullscreen > .l-loading-mask {
49
+ position: fixed;
50
+ z-index: 100;
51
+ }
52
+
53
+ /* 进度条样式 */
54
+ .l-loading-bar.l-loading-mask {
55
+ bottom: auto;
56
+ height: 2px;
57
+ border-radius: inherit;
58
+ background-color: transparent;
59
+ justify-content: flex-start;
60
+ opacity: 1;
61
+ }
62
+ .l-loading-bar > .l-loading-spinner {
63
+ width: 100%;
64
+ height: 100%;
65
+ max-width: 0;
66
+ opacity: 1;
67
+ transition:
68
+ max-width 4s linear,
69
+ background-color 0.2s linear,
70
+ opacity 0.2s linear;
71
+ background-color: var(--l-primary-color, #722ed1);
72
+ }
73
+ .l-loading-bar--start .l-loading-spinner {
74
+ max-width: 90%;
75
+ }
76
+
77
+ .l-loading-bar--finish .l-loading-spinner {
78
+ transition:
79
+ max-width 0.2s linear,
80
+ background-color 0.2s linear,
81
+ opacity 0.2s linear;
82
+ max-width: 100%;
83
+ opacity: 0;
84
+ }
85
+
86
+ .l-loading-bar--error .l-loading-spinner {
87
+ transition:
88
+ max-width 0.2s linear,
89
+ background-color 0.2s linear,
90
+ opacity 0.2s linear;
91
+ max-width: 100%;
92
+ background-color: var(--l-error-color, #d03050);
93
+ opacity: 0;
94
+ }
95
+
96
+ @keyframes loading-rotate {
97
+ 100% {
98
+ transform: rotate3d(0, 0, 1, 360deg);
99
+ }
100
+ }
package/styles/reset.css CHANGED
@@ -21,6 +21,16 @@ ol {
21
21
  margin: 0;
22
22
  padding: 0;
23
23
  }
24
+ dialog {
25
+ border: none;
26
+ outline: none;
27
+ padding: 0;
28
+ opacity: 0;
29
+ transition: opacity 3s;
30
+ }
31
+ dialog[open] {
32
+ opacity: 1;
33
+ }
24
34
  /* 统一采用盒子模式 */
25
35
  div {
26
36
  box-sizing: border-box;
@@ -1,22 +0,0 @@
1
- let e;
2
- function o(t, l, f) {
3
- e == null && (e = /* @__PURE__ */ new Map()), e.has(t) || e.set(t, /* @__PURE__ */ new Map([[l, /* @__PURE__ */ new Set()]])), e.get(t).has(l) || e.get(t).set(l, /* @__PURE__ */ new Set()), e.get(t).get(l).add(f);
4
- }
5
- function g(t, l, f) {
6
- e?.get(t)?.get(l)?.delete(f), e?.get(t)?.get(l)?.size == 0 && e.get(t)?.delete(l), e?.get(t)?.size == 0 && e.delete(t), e?.size == 0 && (e = void 0);
7
- }
8
- function s(t) {
9
- t == null ? e != null && (e.clear(), e = void 0) : e != null && (e.delete(t), e.size === 0 && (e = void 0));
10
- }
11
- function u(t, l, ...f) {
12
- const n = e?.get(t)?.get(l);
13
- if (n != null)
14
- for (const i of n)
15
- i(...f);
16
- }
17
- export {
18
- o as add,
19
- s as clear,
20
- u as emit,
21
- g as remove
22
- };