litos-ui 0.15.0 → 0.15.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.
@@ -0,0 +1,12 @@
1
+ import BaseComponent from "../base";
2
+ export default class DescriptionPanel extends BaseComponent {
3
+ static baseName: string;
4
+ /** 内容折叠后的高度, 默认: 100px */
5
+ collapseHeight: string;
6
+ /** 字体大小, 默认: 12px */
7
+ fontSize: string;
8
+ static get observedAttributes(): string[] | null | undefined;
9
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
10
+ connectedCallback(): void;
11
+ render(): void;
12
+ }
@@ -0,0 +1,23 @@
1
+ import a from "../base.js";
2
+ const l = ":host{--l-desc-panel-min-height: 100px;--l-desc-panel-font-size: 12px;--l-desc-panel-textindent: calc(var(--l-desc-panel-font-size) * 2);display:block;max-height:var(--l-desc-panel-max-height, max-content);color:#1f2937;font-size:var(--l-desc-panel-font-size);position:relative;transition:all .15s linear}";
3
+ class o extends a {
4
+ static baseName = "description-panel";
5
+ /** 内容折叠后的高度, 默认: 100px */
6
+ collapseHeight = "100px";
7
+ /** 字体大小, 默认: 12px */
8
+ fontSize = "12px";
9
+ static get observedAttributes() {
10
+ return ["collapse-height", "font-size"];
11
+ }
12
+ attributeChangedCallback(e, s, t) {
13
+ this[e] = t;
14
+ }
15
+ connectedCallback() {
16
+ this.loadStyleText(l), super.connectedCallback();
17
+ }
18
+ render() {
19
+ }
20
+ }
21
+ export {
22
+ o as default
23
+ };
package/lib/index.d.ts CHANGED
@@ -54,6 +54,8 @@ export { default as MenuItem } from "./menu/menu_item";
54
54
  export { default as SubMenu } from "./menu/sub_menu";
55
55
  export { default as Carousel } from "./carousel";
56
56
  export { default as CarouselItem } from "./carousel/item";
57
+ export { default as Qrcode } from "./qrcode";
58
+ export { default as DescriptionPanel } from "./description_panel";
57
59
 
58
60
  declare global {
59
61
  interface HTMLElementTagNameMap {
@@ -110,5 +112,7 @@ declare global {
110
112
  "l-sub-menu": import("./menu/sub_menu").default
111
113
  "l-carousel": import("./carousel").default
112
114
  "l-carousel-item": import("./carousel/item").default
115
+ "l-qrcode": import("./qrcode").default
116
+ "l-description-panel": import("./description_panel").default
113
117
  }
114
118
  }
package/lib/index.js CHANGED
@@ -2,21 +2,21 @@ import { createTransition as t, getPopoverOffsetX as r, getPopoverOffsetY as a,
2
2
  import { set as c, remove as I } from "./utils/clickoutside.js";
3
3
  import { default as C } from "./base.js";
4
4
  import { default as h } from "./message/index.js";
5
- import { default as b } from "./popover/index.js";
6
- import { default as P } from "./popconfirm/index.js";
7
- import { default as S } from "./dialog/index.js";
8
- import { default as k } from "./dialog/dialog_container.js";
9
- import { default as D } from "./loading/index.js";
5
+ import { default as P } from "./popover/index.js";
6
+ import { default as D } from "./popconfirm/index.js";
7
+ import { default as R } from "./dialog/index.js";
8
+ import { default as T } from "./dialog/dialog_container.js";
9
+ import { default as w } from "./loading/index.js";
10
10
  import { default as L } from "./modal/index.js";
11
11
  import { default as B } from "./icon/base.js";
12
12
  import { default as G } from "./icon/arrow_down.js";
13
- import { default as U } from "./icon/arrow_left.js";
14
- import { default as W } from "./icon/arrow_right.js";
15
- import { default as Y } from "./icon/arrow_up.js";
16
- import { default as q } from "./icon/caret_top.js";
17
- import { default as E } from "./icon/caret_bottom.js";
18
- import { default as J } from "./icon/font_icon.js";
19
- import { default as N } from "./icon/loading.js";
13
+ import { default as Q } from "./icon/arrow_left.js";
14
+ import { default as V } from "./icon/arrow_right.js";
15
+ import { default as X } from "./icon/arrow_up.js";
16
+ import { default as j } from "./icon/caret_top.js";
17
+ import { default as z } from "./icon/caret_bottom.js";
18
+ import { default as H } from "./icon/font_icon.js";
19
+ import { default as K } from "./icon/loading.js";
20
20
  import { default as Z } from "./icon/search.js";
21
21
  import { default as $ } from "./icon/sun.js";
22
22
  import { default as eo } from "./icon/moon.js";
@@ -29,21 +29,21 @@ import { default as co } from "./icon/close.js";
29
29
  import { default as io } from "./icon/info.js";
30
30
  import { default as go } from "./icon/success.js";
31
31
  import { default as Ao } from "./icon/warn.js";
32
- import { default as Mo } from "./icon/close_filled.js";
33
- import { default as Ro } from "./form/index.js";
34
- import { default as To } from "./form/form_item.js";
35
- import { default as wo } from "./check/radio_group.js";
32
+ import { default as bo } from "./icon/close_filled.js";
33
+ import { default as Mo } from "./form/index.js";
34
+ import { default as So } from "./form/form_item.js";
35
+ import { default as ko } from "./check/radio_group.js";
36
36
  import { default as vo } from "./check/radio.js";
37
37
  import { default as Oo } from "./check/checkbox.js";
38
38
  import { default as Fo } from "./check/checkbox_group.js";
39
39
  import { default as yo } from "./button/index.js";
40
- import { default as Vo } from "./input/index.js";
41
- import { default as Xo } from "./select_ori/index.js";
42
- import { default as jo } from "./switch/index.js";
43
- import { default as zo } from "./md_input/index.js";
44
- import { default as Ho } from "./list/index.js";
45
- import { default as Ko } from "./polygon/index.js";
46
- import { default as Qo } from "./color_picker/index.js";
40
+ import { default as Uo } from "./input/index.js";
41
+ import { default as Wo } from "./select_ori/index.js";
42
+ import { default as Yo } from "./switch/index.js";
43
+ import { default as qo } from "./md_input/index.js";
44
+ import { default as Eo } from "./list/index.js";
45
+ import { default as Jo } from "./polygon/index.js";
46
+ import { default as No } from "./color_picker/index.js";
47
47
  import { default as _o } from "./tabbar/index.js";
48
48
  import { default as oe } from "./tabbar/item.js";
49
49
  import { default as te } from "./theme/index.js";
@@ -54,55 +54,59 @@ import { default as pe } from "./menu/menu_item.js";
54
54
  import { default as xe } from "./menu/sub_menu.js";
55
55
  import { default as ce } from "./carousel/index.js";
56
56
  import { default as ie } from "./carousel/item.js";
57
+ import { default as ge } from "./qrcode/index.js";
58
+ import { default as Ae } from "./description_panel/index.js";
57
59
  export {
58
60
  G as ArrowDownIcon,
59
- U as ArrowLeftIcon,
60
- W as ArrowRightIcon,
61
- Y as ArrowUpIcon,
61
+ Q as ArrowLeftIcon,
62
+ V as ArrowRightIcon,
63
+ X as ArrowUpIcon,
62
64
  C as BaseComponent,
63
65
  B as BaseIcon,
64
66
  yo as Button,
65
- E as CaretBottomIcon,
66
- q as CaretTopIcon,
67
+ z as CaretBottomIcon,
68
+ j as CaretTopIcon,
67
69
  ce as Carousel,
68
70
  ie as CarouselItem,
69
71
  Oo as Checkbox,
70
72
  Fo as CheckboxGroup,
71
- Mo as CloseFilledIcon,
73
+ bo as CloseFilledIcon,
72
74
  co as CloseIcon,
73
- Qo as ColorPicker,
75
+ No as ColorPicker,
74
76
  se as DatePicker,
75
- S as Dialog,
76
- k as DialogContainer,
77
- J as FontIcon,
78
- Ro as Form,
79
- To as FormItem,
77
+ Ae as DescriptionPanel,
78
+ R as Dialog,
79
+ T as DialogContainer,
80
+ H as FontIcon,
81
+ Mo as Form,
82
+ So as FormItem,
80
83
  io as InfoIcon,
81
- Vo as Input,
82
- Ho as List,
83
- D as Loading,
84
- N as LoadingIcon,
85
- zo as MdInput,
84
+ Uo as Input,
85
+ Eo as List,
86
+ w as Loading,
87
+ K as LoadingIcon,
88
+ qo as MdInput,
86
89
  le as Menu,
87
90
  pe as MenuItem,
88
91
  h as Message,
89
92
  L as Modal,
90
93
  eo as MoonIcon,
91
- Ko as Polygon,
92
- P as Popconfirm,
93
- b as Popover,
94
+ Jo as Polygon,
95
+ D as Popconfirm,
96
+ P as Popover,
97
+ ge as Qrcode,
94
98
  vo as Radio,
95
- wo as RadioGroup,
99
+ ko as RadioGroup,
96
100
  ro as ReductionIcon,
97
101
  fo as RefreshLeftIcon,
98
102
  uo as RefreshRightIcon,
99
103
  Z as SearchIcon,
100
- Xo as SelectOri,
104
+ Wo as SelectOri,
101
105
  mo as SortIcon,
102
106
  xe as SubMenu,
103
107
  go as SuccessIcon,
104
108
  $ as SunIcon,
105
- jo as Switch,
109
+ Yo as Switch,
106
110
  _o as Tabbar,
107
111
  oe as TabbarItem,
108
112
  te as Theme,
package/lib/menu/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { on as d, off as c, $$ as u, $ as h, iterate as f, $one as a } from "ph-utils/dom";
1
+ import { on as c, off as u, $$ as h, $ as a, iterate as d, $one as f } from "ph-utils/dom";
2
2
  import m from "../base.js";
3
3
  import { initAttr as b } from "../utils/index.js";
4
4
  const p = ":host{--l-menu-width: 240px;--l-menu-height: auto;--l-menu-color: #333333;--l-menu-background: #ffffff;--l-menu-level: 0;--l-menu-item-height: 40px;--l-menu-active-color: var(--l-primary-color, #722ed1);--l-menu-active-background: var(--l-primary-color-light5, #f9f0ff);display:block;width:var(--l-menu-width);height:var(--l-menu-height);font-size:14px;position:relative;color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;transition:height .3s,width .3s;overflow:hidden;border-right:1px solid var(--l-border-color, #dedede)}";
@@ -20,44 +20,44 @@ class x extends m {
20
20
  ), this.loadStyleText(p), super.connectedCallback();
21
21
  }
22
22
  static get observedAttributes() {
23
- return ["selectedKeys", "orientation"];
23
+ return ["selected-key", "orientation"];
24
24
  }
25
- attributeChangedCallback(t, i, e) {
25
+ attributeChangedCallback(e, s, t) {
26
26
  if (this.rendered) {
27
- if (t === "selectedKeys")
28
- this.selectedKey !== e && (this.selectedKey = e, this.updateSelectedKeys(e));
29
- else if (t === "orientation") {
30
- const s = this.classList;
31
- s.remove(`l-menu--${i}`), s.add(`l-menu--${e}`);
27
+ if (e === "selected-key")
28
+ this.selectedKey !== t && this.updateSelectedKeys(t);
29
+ else if (e === "orientation") {
30
+ const i = this.classList;
31
+ i.remove(`l-menu--${s}`), i.add(`l-menu--${t}`);
32
32
  }
33
33
  }
34
34
  }
35
35
  afterInit() {
36
- d(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
36
+ c(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
37
37
  }
38
38
  beforeDestroy() {
39
- c(this, "click", this.#t);
39
+ u(this, "click", this.#t);
40
40
  }
41
41
  render() {
42
- return u("slot");
42
+ return h("slot");
43
43
  }
44
- #t = (t) => {
45
- const { type: i, key: e, keyPaths: s, target: l } = this.#e(
46
- t.target
44
+ #t = (e) => {
45
+ const { type: s, key: t, keyPaths: i, target: n } = this.#e(
46
+ e.target
47
47
  );
48
- l && (i === 2 ? l.hasAttribute("expanded") ? l.removeAttribute("expanded") : (l.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(s, !0)) : i === 1 && (this.#i(s), this.updateSelectedKeys(e), this.emit("select", { detail: { key: e, keyPaths: s } })));
48
+ n && (s === 2 ? n.hasAttribute("expanded") ? n.removeAttribute("expanded") : (n.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(i, !0)) : s === 1 && (this.#i(i), this.updateSelectedKeys(t), this.emit("select", { detail: { key: t, keyPaths: i } })));
49
49
  };
50
- #e(t, i) {
51
- let e = 0, s = "", l;
52
- const o = [];
50
+ #e(e, s) {
51
+ let t = 0, i = "", n;
52
+ const l = [];
53
53
  do {
54
- const r = t.tagName;
55
- if (["L-MENU", "BODY"].includes(r))
54
+ const o = e.tagName;
55
+ if (["L-MENU", "BODY"].includes(o))
56
56
  break;
57
- const n = t.getAttribute("key");
58
- n && (s || (s = n), o.unshift(n), i && i(t, n)), e === 0 && (r === "L-MENU-ITEM" ? (e = 1, l = t) : r === "L-SUB-MENU" && (l = t, e = 2)), t = t.parentElement;
59
- } while (e >= 0);
60
- return { type: e, key: s, keyPaths: o, target: l };
57
+ const r = e.getAttribute("key");
58
+ r && (i || (i = r), l.unshift(r), s && s(e, r)), t === 0 && (o === "L-MENU-ITEM" ? (t = 1, n = e) : o === "L-SUB-MENU" && (n = e, t = 2)), e = e.parentElement;
59
+ } while (t >= 0);
60
+ return { type: t, key: i, keyPaths: l, target: n };
61
61
  }
62
62
  /**
63
63
  * 展开与提供的 keys 对应的子菜单。
@@ -69,24 +69,30 @@ class x extends m {
69
69
  * @param keys - 表示要展开的子菜单的 key 的字符串数组。
70
70
  * @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
71
71
  */
72
- expandSubmenus(t, i = !1) {
73
- const e = h("l-sub-menu[key]", this);
74
- f(e, (s) => {
75
- const l = s.getAttribute("key") || "";
76
- t.includes(l) ? s.setAttribute("expanded", "") : i && s.removeAttribute("expanded");
72
+ expandSubmenus(e, s = !1) {
73
+ const t = a("l-sub-menu[key]", this);
74
+ d(t, (i) => {
75
+ const n = i.getAttribute("key") || "";
76
+ e.includes(n) ? i.setAttribute("expanded", "") : s && i.removeAttribute("expanded");
77
77
  });
78
78
  }
79
- updateSelectedKeys(t) {
80
- this.selectedKey = t;
81
- const i = a(`l-menu-item[key="${t}"]`, this);
82
- i && (i.setAttribute("active", ""), this.#e(i, (e) => {
83
- e.setAttribute("active", ""), e.setAttribute("expanded", "");
84
- }));
79
+ updateSelectedKeys(e) {
80
+ this.selectedKey = e;
81
+ const s = f(`l-menu-item[key="${e}"]`, this);
82
+ if (s) {
83
+ const t = this.#e(s, (i) => {
84
+ i.setAttribute("active", ""), i.setAttribute("expanded", "");
85
+ });
86
+ this.#i(t.keyPaths);
87
+ }
85
88
  }
86
- #i(t) {
87
- const i = a("l-menu-item[active]", this);
88
- i && this.#e(i, (e, s) => {
89
- t.includes(s) || e.removeAttribute("active");
89
+ #i(e) {
90
+ const s = a("l-menu-item[active]", this);
91
+ d(s, (t) => {
92
+ const i = t.getAttribute("key") || "";
93
+ e.includes(i) || this.#e(t, (n, l) => {
94
+ e.includes(l) || (n.removeAttribute("expanded"), n.removeAttribute("active"));
95
+ });
90
96
  });
91
97
  }
92
98
  }
@@ -0,0 +1,22 @@
1
+ import BaseComponent from "../base";
2
+ export default class Qrcode extends BaseComponent {
3
+ #private;
4
+ static baseName: string;
5
+ /** 二维码内容 */
6
+ text?: string;
7
+ /** 二维码颜色 */
8
+ fill: string;
9
+ /** 二维码大小 */
10
+ size?: string | number;
11
+ /** 二维码等级 */
12
+ level?: "L" | "M" | "Q" | "H";
13
+ /** 插入二维码中间的图标 */
14
+ icon?: string;
15
+ private _qrcode?;
16
+ connectedCallback(): void;
17
+ static get observedAttributes(): string[] | null | undefined;
18
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
19
+ afterInit(): void;
20
+ beforeDestroy(): void;
21
+ render(): string;
22
+ }
@@ -0,0 +1,57 @@
1
+ import s from "../base.js";
2
+ import { QRCodeRender as o, renderToCanvas as r } from "qrcode-generator-es";
3
+ import { $one as c } from "ph-utils/dom";
4
+ const n = ":host{display:inline-flex}.renderer-el{display:inline-flex}";
5
+ class f extends s {
6
+ static baseName = "qrcode";
7
+ /** 二维码内容 */
8
+ text;
9
+ /** 二维码颜色 */
10
+ fill = "#000000";
11
+ /** 二维码大小 */
12
+ size = "100";
13
+ /** 二维码等级 */
14
+ level = "M";
15
+ /** 插入二维码中间的图标 */
16
+ icon;
17
+ _qrcode;
18
+ connectedCallback() {
19
+ this.loadStyleText(n), super.connectedCallback();
20
+ }
21
+ static get observedAttributes() {
22
+ return ["text", "fill", "size", "level", "icon"];
23
+ }
24
+ attributeChangedCallback(e, t, i) {
25
+ t !== i && (this[e] = i, this.#t(e, i), this.#e());
26
+ }
27
+ afterInit() {
28
+ this.#e();
29
+ }
30
+ beforeDestroy() {
31
+ this._qrcode = void 0;
32
+ }
33
+ #t(e, t) {
34
+ this._qrcode && (e === "icon" ? this._qrcode.option.icon = t ? { src: t } : void 0 : this._qrcode.option[e] = t);
35
+ }
36
+ #e() {
37
+ if (!this._qrcode) {
38
+ const e = c("canvas", this.root);
39
+ e && (console.log(this.icon), this._qrcode = new o({
40
+ renderFn: r,
41
+ text: this.text,
42
+ size: Number(this.size),
43
+ level: this.level,
44
+ fill: this.fill,
45
+ icon: this.icon ? { src: this.icon } : void 0,
46
+ el: e
47
+ }));
48
+ }
49
+ this._qrcode != null && this.text && this._qrcode.render();
50
+ }
51
+ render() {
52
+ return "<canvas class='renderer-el' width='100' height='100'></canvas>";
53
+ }
54
+ }
55
+ export {
56
+ f as default
57
+ };
@@ -8,7 +8,8 @@ import "ph-utils/color";
8
8
  import "ph-utils/theme";
9
9
  import "ph-utils/date";
10
10
  import "ph-utils/web";
11
- class _ extends a {
11
+ import "qrcode-generator-es";
12
+ class R extends a {
12
13
  static baseName = "transition";
13
14
  /** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
14
15
  sheetRec;
@@ -51,5 +52,5 @@ class _ extends a {
51
52
  }
52
53
  }
53
54
  export {
54
- _ as Transition
55
+ R as Transition
55
56
  };
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.15.0",
4
+ "version": "0.15.1",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
- "@eslint/js": "^9.25.0",
8
- "@eslint/markdown": "^6.4.0",
9
- "@types/node": "^22.14.1",
10
- "eslint": "^9.25.0",
11
- "globals": "^16.0.0",
7
+ "@eslint/js": "^9.30.1",
8
+ "@eslint/markdown": "^6.6.0",
9
+ "@types/node": "^24.0.10",
10
+ "eslint": "^9.30.1",
11
+ "globals": "^16.3.0",
12
12
  "less": "^4.3.0",
13
- "lightningcss": "^1.29.3",
14
- "prettier": "^3.5.3",
13
+ "lightningcss": "^1.30.1",
14
+ "prettier": "^3.6.2",
15
15
  "typescript": "^5.8.3",
16
- "typescript-eslint": "^8.30.1",
17
- "vite": "^6.3.2",
18
- "vite-plugin-dts": "^4.5.3",
16
+ "typescript-eslint": "^8.35.1",
17
+ "vite": "^7.0.2",
18
+ "vite-plugin-dts": "^4.5.4",
19
19
  "vitepress": "^1.6.3"
20
20
  },
21
21
  "files": [
@@ -52,9 +52,10 @@
52
52
  },
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
- "iconify-icon": "^2.3.0",
55
+ "iconify-icon": "^3.0.0",
56
56
  "ph-utils": "^0.15.4",
57
- "shiki": "^3.2.2"
57
+ "qrcode-generator-es": "^1.1.4",
58
+ "shiki": "^3.7.0"
58
59
  },
59
60
  "scripts": {
60
61
  "dev": "vite dev",