litos-ui 0.11.1 → 0.12.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 (50) hide show
  1. package/README.md +48 -0
  2. package/lib/base.d.ts +11 -2
  3. package/lib/base.js +18 -7
  4. package/lib/button/index.d.ts +3 -2
  5. package/lib/button/index.js +18 -19
  6. package/lib/date_picker/index.d.ts +22 -0
  7. package/lib/date_picker/index.js +99 -0
  8. package/lib/dialog/dialog_container.js +1 -1
  9. package/lib/form/form_inner.d.ts +7 -2
  10. package/lib/form/form_inner.js +26 -20
  11. package/lib/form/form_item.d.ts +0 -2
  12. package/lib/form/form_item.js +5 -9
  13. package/lib/form/index.d.ts +0 -2
  14. package/lib/form/index.js +23 -25
  15. package/lib/icon/base.d.ts +0 -1
  16. package/lib/icon/base.js +15 -17
  17. package/lib/index.d.ts +10 -0
  18. package/lib/index.js +92 -82
  19. package/lib/input/index.d.ts +1 -3
  20. package/lib/input/index.js +4 -8
  21. package/lib/loading/index.d.ts +9 -4
  22. package/lib/loading/index.js +70 -64
  23. package/lib/menu/base.js +1 -0
  24. package/lib/menu/index.d.ts +29 -0
  25. package/lib/menu/index.js +90 -0
  26. package/lib/menu/menu_item.d.ts +6 -0
  27. package/lib/menu/menu_item.js +21 -0
  28. package/lib/menu/sub_menu.d.ts +13 -0
  29. package/lib/menu/sub_menu.js +64 -0
  30. package/lib/modal/index.d.ts +40 -0
  31. package/lib/modal/index.js +153 -0
  32. package/lib/modal/modal_box.js +95 -0
  33. package/lib/popover/index.d.ts +1 -4
  34. package/lib/popover/index.js +6 -12
  35. package/lib/radio/index.js +2 -2
  36. package/lib/select_ori/index.d.ts +0 -2
  37. package/lib/select_ori/index.js +11 -15
  38. package/lib/switch/index.d.ts +0 -1
  39. package/lib/switch/index.js +8 -13
  40. package/lib/tabbar/index.d.ts +0 -1
  41. package/lib/tabbar/index.js +55 -63
  42. package/lib/theme/index.d.ts +1 -2
  43. package/lib/theme/index.js +9 -12
  44. package/lib/utils/index.js +29 -29
  45. package/lib/utils/transition.js +3 -2
  46. package/package.json +12 -13
  47. package/styles/loading.css +58 -14
  48. package/styles/message.css +1 -1
  49. package/styles/modal_box.css +7 -0
  50. package/styles/vars.css +1 -0
@@ -4,8 +4,8 @@ let E = -1;
4
4
  function H(t, r) {
5
5
  const e = Array.isArray(t) ? t : [t];
6
6
  for (const i of e) {
7
- const s = r || i.tabName || `l-${i.baseName}`;
8
- customElements.get(s) || customElements.define(s, i);
7
+ const n = r || `l-${i.baseName}`;
8
+ customElements.get(n) || customElements.define(n, i);
9
9
  }
10
10
  }
11
11
  function _() {
@@ -15,7 +15,7 @@ function I(t, r, e) {
15
15
  if (t == null) return r;
16
16
  switch (typeof r) {
17
17
  case "boolean":
18
- return t === "" || t === "true" || t === "1" || t === e;
18
+ return ["", "true", "1", "on", e].includes(t);
19
19
  case "number":
20
20
  return Number(t);
21
21
  default:
@@ -25,11 +25,11 @@ function I(t, r, e) {
25
25
  function k(t) {
26
26
  const r = t.attributes;
27
27
  for (const e of r) {
28
- const { name: i, value: s } = e;
28
+ const { name: i, value: n } = e;
29
29
  if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$") || ["id", "class", "style"].includes(i))
30
30
  continue;
31
- const n = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), u = I(s, t[n], i), f = Object.getOwnPropertyNames(t);
32
- (t._ignoreInitAttrs || []).includes(n) || (i === "value" ? (t[n] = u, t._resetValue = u) : f.includes(n) && (t[n] = u));
31
+ const s = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), u = I(n, t[s], i), f = Object.getOwnPropertyNames(t);
32
+ (t._ignoreInitAttrs || []).includes(s) || (i === "value" ? (t[s] = u, t._resetValue = u) : f.includes(s) && (t[s] = u));
33
33
  }
34
34
  }
35
35
  function W(t, r) {
@@ -41,17 +41,17 @@ function C(t) {
41
41
  }
42
42
  function V(t, r) {
43
43
  for (const e of r) {
44
- const i = e[1], s = e[0];
45
- i === !0 ? t.setAttribute(s, "") : typeof i == "string" && !N(i) && t.setAttribute(s, i);
44
+ const i = e[1], n = e[0];
45
+ i === !0 ? t.setAttribute(n, "") : typeof i == "string" && !N(i) && t.setAttribute(n, i);
46
46
  }
47
47
  }
48
- function B() {
48
+ function l() {
49
49
  let t;
50
50
  const r = {
51
51
  attributes: !0,
52
52
  attributeFilter: ["l-transition-emit"]
53
- }, e = (n) => {
54
- for (let u of n)
53
+ }, e = (s) => {
54
+ for (let u of s)
55
55
  if (u.type === "attributes" && u.attributeName) {
56
56
  const f = u.target, c = f.getAttribute(u.attributeName) || "show", d = f.getAttribute("l-transition") || "l", h = f.getAttribute("l-transition-method") || "hide";
57
57
  c === "show" ? (f.style.removeProperty("display"), y(f, d, "enter")) : y(f, d, "leave", () => {
@@ -59,30 +59,30 @@ function B() {
59
59
  });
60
60
  }
61
61
  };
62
- function i(n) {
63
- n && n.length > 0 && (t == null && (t = new MutationObserver(e)), $(n, (u) => {
62
+ function i(s) {
63
+ s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (u) => {
64
64
  const f = u.getAttribute("l-transition");
65
65
  f && (y(u, f, "enter"), t.observe(u, r));
66
66
  }));
67
67
  }
68
- function s(n) {
69
- n == null && (n = x("[l-transition]"), i(n));
68
+ function n(s) {
69
+ s == null && (s = x("[l-transition]"), i(s));
70
70
  }
71
71
  function o() {
72
72
  t && (t.disconnect(), t = void 0);
73
73
  }
74
- return { destroy: o, add: i, init: s };
74
+ return { destroy: o, add: i, init: n };
75
75
  }
76
- function m(t, r, e, i, s = 10) {
76
+ function m(t, r, e, i, n = 10) {
77
77
  let o = 0;
78
- return e === "top" ? o = r.height + s : e === "bottom" ? o = -(t.height + s) : (e === "left" || e === "right") && (i === "" ? o = r.height / 2 - t.height / 2 : i === "end" && (o = r.height - t.height)), o;
78
+ return e === "top" ? o = r.height + n : e === "bottom" ? o = -(t.height + n) : (e === "left" || e === "right") && (i === "" ? o = r.height / 2 - t.height / 2 : i === "end" && (o = r.height - t.height)), o;
79
79
  }
80
- function w(t, r, e, i, s = 10) {
80
+ function w(t, r, e, i, n = 10) {
81
81
  let o = 0;
82
- return e === "left" ? o = r.width + s : e === "right" ? o = -(t.width + s) : (e === "top" || e === "bottom") && (i === "" ? o = r.width / 2 - t.width / 2 : i === "end" && (o = r.width - t.width)), o;
82
+ return e === "left" ? o = r.width + n : e === "right" ? o = -(t.width + n) : (e === "top" || e === "bottom") && (i === "" ? o = r.width / 2 - t.width / 2 : i === "end" && (o = r.width - t.width)), o;
83
83
  }
84
- function F(t, r, e, i, s, o, n, u, f = 10, c = "absolute") {
85
- const d = window.innerHeight + o - 10, h = window.innerWidth + s - 10;
84
+ function v(t, r, e, i, n, o, s, u, f = 10, c = "absolute") {
85
+ const d = window.innerHeight + o - 10, h = window.innerWidth + n - 10;
86
86
  let a = t.top + o - u;
87
87
  a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", u = m(
88
88
  t,
@@ -91,26 +91,26 @@ function F(t, r, e, i, s, o, n, u, f = 10, c = "absolute") {
91
91
  i,
92
92
  f
93
93
  ), a = t.top + o - u), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
94
- let b = t.left + s - n;
95
- return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", n = w(
94
+ let b = t.left + n - s;
95
+ return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = w(
96
96
  t,
97
97
  r,
98
98
  e,
99
99
  i,
100
100
  f
101
- ), b = t.left + s - n), b < s && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (u = m(
101
+ ), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (u = m(
102
102
  t,
103
103
  r,
104
104
  e,
105
105
  i,
106
106
  f
107
- ), n = w(
107
+ ), s = w(
108
108
  t,
109
109
  r,
110
110
  e,
111
111
  i,
112
112
  f
113
- ), b = t.left + s - n, a = t.top + o - u), {
113
+ ), b = t.left + n - s, a = t.top + o - u), {
114
114
  x: b,
115
115
  y: a,
116
116
  mainAlign: e,
@@ -118,10 +118,10 @@ function F(t, r, e, i, s, o, n, u, f = 10, c = "absolute") {
118
118
  };
119
119
  }
120
120
  export {
121
- B as createTransition,
121
+ l as createTransition,
122
122
  w as getPopoverOffsetX,
123
123
  m as getPopoverOffsetY,
124
- F as impactDetect,
124
+ v as impactDetect,
125
125
  k as initAttr,
126
126
  I as parseAttrValue,
127
127
  H as regist,
@@ -6,7 +6,8 @@ import "ph-utils";
6
6
  import "ph-utils/validator";
7
7
  import "ph-utils/color";
8
8
  import "ph-utils/theme";
9
- class C extends a {
9
+ import "ph-utils/date";
10
+ class S extends a {
10
11
  static baseName = "transition";
11
12
  /** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
12
13
  sheetRec;
@@ -49,5 +50,5 @@ class C extends a {
49
50
  }
50
51
  }
51
52
  export {
52
- C as Transition
53
+ S as Transition
53
54
  };
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.11.1",
4
+ "version": "0.12.1",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
- "@eslint/js": "^9.22.0",
7
+ "@eslint/js": "^9.24.0",
8
8
  "@eslint/markdown": "^6.3.0",
9
- "@types/node": "^22.13.10",
10
- "eslint": "^9.22.0",
9
+ "@types/node": "^22.14.0",
10
+ "eslint": "^9.24.0",
11
11
  "globals": "^16.0.0",
12
- "less": "^4.2.2",
12
+ "less": "^4.3.0",
13
13
  "lightningcss": "^1.29.3",
14
14
  "prettier": "^3.5.3",
15
- "typescript": "^5.8.2",
16
- "typescript-eslint": "^8.26.1",
17
- "vite": "^6.2.2",
15
+ "typescript": "^5.8.3",
16
+ "typescript-eslint": "^8.29.1",
17
+ "vite": "^6.2.5",
18
18
  "vite-plugin-dts": "^4.5.3",
19
19
  "vitepress": "^1.6.3"
20
20
  },
@@ -52,20 +52,19 @@
52
52
  },
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
- "ph-utils": "^0.15.0",
55
+ "iconify-icon": "^2.3.0",
56
+ "ph-utils": "^0.15.4",
56
57
  "shiki": "^3.2.1"
57
58
  },
58
59
  "scripts": {
59
60
  "dev": "vite dev",
60
61
  "build": "vite build",
61
- "docs:dev": "vitepress dev docs",
62
+ "docs:dev": "vitepress dev docs --force",
62
63
  "docs:build": "vitepress build docs",
63
64
  "docs:preview": "vitepress preview docs",
64
65
  "inspect:eslint": "eslint --inspect-config",
65
- "new_version": "node scripts/version.js",
66
66
  "create": "node scripts/index.js create",
67
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"
68
+ "lib:build": "pnpm build && pnpm dts:build"
70
69
  }
71
70
  }
@@ -7,18 +7,28 @@
7
7
  right: 0;
8
8
  bottom: 0;
9
9
  left: 0;
10
- background: rgba(0, 0, 0, 0.6);
10
+ z-index: var(--l-loading-zindex, 10);
11
+ background: rgba(0, 0, 0, 0.4);
11
12
  border-radius: inherit;
12
- display: flex;
13
- justify-content: center;
14
- align-items: center;
15
- transition: opacity 0.3s ease-in-out;
13
+ transition: opacity 0.3s;
16
14
  opacity: 0;
17
15
  }
18
16
 
19
17
  .l-loading-spinner {
18
+ --l-loading-color: var(--l-primary-color, #722ed1);
20
19
  text-align: center;
20
+ position: absolute;
21
+ z-index: calc(var(--l-loading-zindex, 10) + 1);
22
+ opacity: 0;
23
+ transition: opacity 0.3s;
24
+ display: block;
25
+ }
26
+ .l-loading-spinner.l-loading--circle {
27
+ top: 50%;
28
+ left: 50%;
29
+ transform: translate3d(-50%, -50%, 0);
21
30
  }
31
+
22
32
  .l-loading-spinner .circle {
23
33
  display: inline;
24
34
  width: 40px;
@@ -27,7 +37,7 @@
27
37
  }
28
38
 
29
39
  .l-loading-spinner .path {
30
- stroke: var(--l-primary-color, #722ed1);
40
+ stroke: var(--l-loading-color);
31
41
  stroke-width: 2px;
32
42
  stroke-linecap: round;
33
43
  stroke-linejoin: round;
@@ -36,7 +46,7 @@
36
46
  }
37
47
 
38
48
  .l-loading-spinner .l-loading-text {
39
- color: var(--l-primary-color, #722ed1);
49
+ color: var(--l-loading-color);
40
50
  margin: 0;
41
51
  font-size: 14px;
42
52
  }
@@ -44,37 +54,55 @@
44
54
  /* 全屏组件 */
45
55
  .l-loading-fullscreen.l-loading-lock {
46
56
  overflow: hidden;
57
+ --l-loading-zindex: 50;
47
58
  }
48
59
  .l-loading-fullscreen > .l-loading-mask {
49
60
  position: fixed;
50
- z-index: 100;
61
+ }
62
+ .l-loading-fullscreen > .l-loading-spinner {
63
+ position: fixed;
64
+ }
65
+
66
+ /* 边框风格 */
67
+ .l-loading-spinner.l-loading--border {
68
+ top: 0;
69
+ left: 0;
70
+ right: 0;
71
+ bottom: 0;
72
+ border: 2px solid var(--l-loading-color);
73
+ border-radius: inherit;
74
+ clip-path: inset(0 0 calc(100% - 2px) 0);
75
+ animation: borderLoadingAnim 5s linear infinite;
51
76
  }
52
77
 
53
78
  /* 进度条样式 */
54
- .l-loading-bar.l-loading-mask {
55
- bottom: auto;
79
+ .l-loading--bar.l-loading-spinner {
80
+ top: 0;
81
+ left: 0;
82
+ width: 100%;
56
83
  height: 2px;
57
84
  border-radius: inherit;
85
+ display: flex;
58
86
  background-color: transparent;
59
87
  justify-content: flex-start;
60
- opacity: 1;
61
88
  }
62
- .l-loading-bar > .l-loading-spinner {
89
+ .l-loading--bar > .l-loading-progress {
63
90
  width: 100%;
64
91
  height: 100%;
65
92
  max-width: 0;
66
93
  opacity: 1;
94
+ border-radius: 1px;
67
95
  transition:
68
96
  max-width 4s linear,
69
97
  background-color 0.2s linear,
70
98
  opacity 0.2s linear;
71
99
  background-color: var(--l-primary-color, #722ed1);
72
100
  }
73
- .l-loading-bar--start .l-loading-spinner {
101
+ .l-loading-bar--start .l-loading-progress {
74
102
  max-width: 90%;
75
103
  }
76
104
 
77
- .l-loading-bar--finish .l-loading-spinner {
105
+ .l-loading-bar--finish .l-loading-progress {
78
106
  transition:
79
107
  max-width 0.2s linear,
80
108
  background-color 0.2s linear,
@@ -98,3 +126,19 @@
98
126
  transform: rotate3d(0, 0, 1, 360deg);
99
127
  }
100
128
  }
129
+
130
+ @keyframes borderLoadingAnim {
131
+ 0%,
132
+ 100% {
133
+ clip-path: inset(0 0 calc(100% - 2px) 0);
134
+ }
135
+ 25% {
136
+ clip-path: inset(0 0 0 calc(100% - 2px));
137
+ }
138
+ 50% {
139
+ clip-path: inset(calc(100% - 2px) 0 0 0);
140
+ }
141
+ 75% {
142
+ clip-path: inset(0 calc(100% - 2px) 0 0);
143
+ }
144
+ }
@@ -15,7 +15,7 @@
15
15
  background: #f0faff;
16
16
  color: var(--l-primary-color, #722ed1);
17
17
  border: 1px solid #d4eeff;
18
- z-index: 1000;
18
+ z-index: 500;
19
19
  }
20
20
  .l-message .l-message-icon {
21
21
  margin-right: 5px;
@@ -0,0 +1,7 @@
1
+ .l-modal-box {
2
+ --l-modal-width: 340px;
3
+ }
4
+
5
+ .l-modal-box.l-modal-box--prompt {
6
+ --l-modal-container-padding: 5px 10px 15px 10px;
7
+ }
package/styles/vars.css CHANGED
@@ -11,6 +11,7 @@
11
11
  --l-primary-color-light4: #efdbff;
12
12
  --l-primary-color-light5: #f9f0ff;
13
13
  --l-primary-color-dark1: #531dab;
14
+ --l-primary-color-dark2: #391085;
14
15
  /* 表示错误(error)的颜色 */
15
16
  --l-error-color: #f5222d;
16
17
  --l-error-color-light3: #ffa39e;