litos-ui 0.17.5 → 0.18.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 (161) hide show
  1. package/README.md +49 -49
  2. package/lib/animation-CTt9qgA7.js +4 -0
  3. package/lib/base-Dm0WS1pK.js +62 -0
  4. package/lib/base.js +111 -147
  5. package/lib/button/index.d.ts +8 -3
  6. package/lib/button/index.js +2 -137
  7. package/lib/button-CC5PmAb1.js +146 -0
  8. package/lib/calendar/index.d.ts +10 -5
  9. package/lib/calendar/index.js +2 -123
  10. package/lib/calendar-DeP6yZB0.js +149 -0
  11. package/lib/carousel/index.js +2 -280
  12. package/lib/carousel/item.js +2 -15
  13. package/lib/carousel-D4Fe3LEx.js +272 -0
  14. package/lib/check/checkbox.js +2 -18
  15. package/lib/check/checkbox_group.js +6 -6
  16. package/lib/check/radio.js +2 -15
  17. package/lib/check/radio_group.js +9 -9
  18. package/lib/check-B0XraJvb.js +73 -0
  19. package/lib/check-CvGaONEx.js +117 -0
  20. package/lib/checkbox-DbWsmAaL.js +16 -0
  21. package/lib/collapse/index.d.ts +18 -11
  22. package/lib/collapse/index.js +2 -88
  23. package/lib/collapse/item.d.ts +28 -9
  24. package/lib/collapse/item.js +2 -115
  25. package/lib/collapse/types.d.ts +7 -0
  26. package/lib/collapse-CeKRZ-43.js +104 -0
  27. package/lib/color_picker/index.js +2 -42
  28. package/lib/color_picker-D0brKFm-.js +41 -0
  29. package/lib/date_picker/index.d.ts +23 -0
  30. package/lib/date_picker/index.js +3 -0
  31. package/lib/date_picker-DQGoiN8v.js +103 -0
  32. package/lib/date_picker_ori/index.js +2 -129
  33. package/lib/date_picker_ori-aRuSSi9D.js +122 -0
  34. package/lib/description_panel/index.js +2 -66
  35. package/lib/description_panel-Df_8rVbX.js +57 -0
  36. package/lib/dialog/dialog_container.js +2 -131
  37. package/lib/dialog/index.js +67 -85
  38. package/lib/dialog_container-DcN87wj0.js +126 -0
  39. package/lib/esm-sVEoAVPu.js +244 -0
  40. package/lib/form/form_item.d.ts +1 -0
  41. package/lib/form/form_item.js +2 -136
  42. package/lib/form/index.js +2 -147
  43. package/lib/form-DdU0yK0k.js +154 -0
  44. package/lib/form_inner-DR9tyB_r.js +117 -0
  45. package/lib/form_item-Bv-YafZK.js +137 -0
  46. package/lib/icon/arrow_down.js +12 -12
  47. package/lib/icon/arrow_left.js +9 -9
  48. package/lib/icon/arrow_right.js +9 -9
  49. package/lib/icon/arrow_up.js +12 -12
  50. package/lib/icon/base.d.ts +16 -2
  51. package/lib/icon/base.js +2 -38
  52. package/lib/icon/calendar.d.ts +5 -0
  53. package/lib/icon/calendar.js +10 -0
  54. package/lib/icon/caret_bottom.js +9 -9
  55. package/lib/icon/caret_top.js +9 -9
  56. package/lib/icon/close.js +9 -9
  57. package/lib/icon/close_filled.js +12 -12
  58. package/lib/icon/d_arrow_left.js +12 -12
  59. package/lib/icon/d_arrow_right.js +12 -12
  60. package/lib/icon/font_icon.d.ts +2 -3
  61. package/lib/icon/font_icon.js +35 -39
  62. package/lib/icon/info.js +12 -12
  63. package/lib/icon/loading.js +9 -9
  64. package/lib/icon/moon.js +12 -12
  65. package/lib/icon/more.js +12 -12
  66. package/lib/icon/reduction.js +12 -12
  67. package/lib/icon/refresh.d.ts +5 -0
  68. package/lib/icon/refresh.js +10 -0
  69. package/lib/icon/refresh_left.js +12 -12
  70. package/lib/icon/refresh_right.js +9 -9
  71. package/lib/icon/search.js +9 -9
  72. package/lib/icon/select.js +12 -12
  73. package/lib/icon/sort.js +9 -9
  74. package/lib/icon/success.js +12 -12
  75. package/lib/icon/sun.js +12 -12
  76. package/lib/icon/theme_default.js +12 -12
  77. package/lib/icon/warn.js +12 -12
  78. package/lib/icon/zoom_in.js +12 -12
  79. package/lib/icon/zoom_out.js +12 -12
  80. package/lib/image/image_preview.js +2 -104
  81. package/lib/image/index.js +2 -176
  82. package/lib/image-CeQVfS-v.js +162 -0
  83. package/lib/image_preview-PzZzwo6m.js +92 -0
  84. package/lib/index.d.ts +10 -4
  85. package/lib/index.js +80 -169
  86. package/lib/input/index.d.ts +6 -2
  87. package/lib/input/index.js +188 -203
  88. package/lib/input-DjKxcxry.js +4 -0
  89. package/lib/input_inner-BKJg9n9A.js +4 -0
  90. package/lib/item-Cuw_ZPyn.js +14 -0
  91. package/lib/item-DV842Aux.js +57 -0
  92. package/lib/item-ZXLWFzSm.js +119 -0
  93. package/lib/list/index.js +2 -58
  94. package/lib/list-CU7vHS6s.js +51 -0
  95. package/lib/loading/index.d.ts +3 -2
  96. package/lib/loading/index.js +109 -127
  97. package/lib/mask/index.js +2 -105
  98. package/lib/mask-BlV5QfTj.js +112 -0
  99. package/lib/md_input/index.js +2 -60
  100. package/lib/md_input-DSQx5TMW.js +58 -0
  101. package/lib/menu/index.js +2 -105
  102. package/lib/menu/menu_item.js +2 -21
  103. package/lib/menu/sub_menu.js +2 -83
  104. package/lib/menu-DAtplYAH.js +91 -0
  105. package/lib/menu_item-BW1Tu11Q.js +20 -0
  106. package/lib/message/index.js +67 -60
  107. package/lib/modal/index.js +2 -196
  108. package/lib/modal/modal_box.js +87 -86
  109. package/lib/modal-DWyWrN-D.js +192 -0
  110. package/lib/page_header/index.js +2 -109
  111. package/lib/page_header-DdeRDN4U.js +101 -0
  112. package/lib/pagination/index.js +2 -248
  113. package/lib/pagination-BoPzSPjT.js +210 -0
  114. package/lib/polygon/index.js +2 -27
  115. package/lib/polygon-C4Ow2lxi.js +20 -0
  116. package/lib/qrcode/index.d.ts +13 -4
  117. package/lib/qrcode/index.js +2 -57
  118. package/lib/qrcode-BFxsD_OP.js +64 -0
  119. package/lib/radio-2mNSYujz.js +13 -0
  120. package/lib/select/index.js +3 -401
  121. package/lib/select-CAgggYh7.js +326 -0
  122. package/lib/select_ori/index.js +47 -50
  123. package/lib/space/index.js +2 -35
  124. package/lib/space-CpTmBfHP.js +38 -0
  125. package/lib/sub_menu-D1s8ABNu.js +75 -0
  126. package/lib/switch/index.js +2 -50
  127. package/lib/switch-BaVBi5Ip.js +48 -0
  128. package/lib/tabbar/index.js +2 -109
  129. package/lib/tabbar/item.js +2 -58
  130. package/lib/tabbar-4_d2Fj1n.js +91 -0
  131. package/lib/table/index.js +2 -269
  132. package/lib/table-Hifj8jAX.js +234 -0
  133. package/lib/tabs/index.js +38 -42
  134. package/lib/tag/index.js +2 -72
  135. package/lib/tag-DPENZf_V.js +76 -0
  136. package/lib/theme/index.js +2 -89
  137. package/lib/theme/theme_color.js +22 -26
  138. package/lib/theme-BRTI2-Yk.js +83 -0
  139. package/lib/utils/clickoutside.js +18 -18
  140. package/lib/utils/context_provide.js +21 -21
  141. package/lib/utils/event.js +13 -18
  142. package/lib/utils/index.js +55 -58
  143. package/lib/utils/popover.d.ts +4 -1
  144. package/lib/utils/popover.js +276 -352
  145. package/lib/utils/transition.js +33 -31
  146. package/package.json +10 -11
  147. package/styles/container.css +4 -0
  148. package/styles/datepicker.css +55 -0
  149. package/styles/popover.css +14 -1
  150. package/lib/animation-DttknHkX.js +0 -4
  151. package/lib/calendar/langs.js +0 -8
  152. package/lib/carousel/timer.js +0 -19
  153. package/lib/check/check.js +0 -118
  154. package/lib/check/index.js +0 -68
  155. package/lib/check-CksURvTv.js +0 -4
  156. package/lib/form/form_inner.js +0 -125
  157. package/lib/form/types.js +0 -1
  158. package/lib/index-CrMiSe0x.js +0 -249
  159. package/lib/index-DY6m9Wbe.js +0 -4
  160. package/lib/litos-ui.css +0 -1
  161. package/lib/table/types.js +0 -1
package/README.md CHANGED
@@ -1,49 +1,49 @@
1
- # litos-ui
2
-
3
- 源自于希腊语中,表示“简洁、朴素”的形容词 "λιτός" (`litós`);所有组件均以 `l-` 为前缀,如 `l-button`、`l-input` 等。
4
-
5
- 采用原生 `Web Components` 作为技术栈,不依赖任何第三方库,可运行在现代浏览器上。跨平台、跨框架,可运行在 `React`、`Vue`、`Angular` 等框架中。
6
-
7
- ## 安装
8
-
9
- ```bash
10
- npm install litos-ui
11
- ```
12
-
13
- 如果需要自动使用一些服务组件,例如: `Message`、`ModalBox` 等且需要自动引入样式时,需要安装 `litosui-unplugin-resolver`、`unplugin-auto-import` 插件。
14
-
15
- ```js
16
- // vite.config.js
17
- import AutoImport from "unplugin-auto-import/vite";
18
- import LitosuiResolver from "litosui-unplugin-resolver";
19
-
20
- // https://vitejs.dev/config/
21
- export default defineConfig({
22
- plugins: [
23
- ...,
24
- AutoImport({
25
- resolvers: [LitosuiResolver()],
26
- dts: "src/auto-imports.d.ts",
27
- }),
28
- ],
29
- ...
30
- });
31
- ```
32
-
33
- ## 使用
34
-
35
- 引入相关组件并注册
36
-
37
- ```js
38
- import { Button, regist } from "litos-ui";
39
-
40
- regist([Button]); // <l-button></l-button>
41
- ```
42
-
43
- ## 文档
44
-
45
- [litos-ui 文档](https://dvshu.github.io/litos-ui/)
46
-
47
- ## 许可证
48
-
49
- [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
1
+ # litos-ui
2
+
3
+ 源自于希腊语中,表示“简洁、朴素”的形容词 "λιτός" (`litós`);所有组件均以 `l-` 为前缀,如 `l-button`、`l-input` 等。
4
+
5
+ 采用原生 `Web Components` 作为技术栈,不依赖任何第三方库,可运行在现代浏览器上。跨平台、跨框架,可运行在 `React`、`Vue`、`Angular` 等框架中。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install litos-ui
11
+ ```
12
+
13
+ 如果需要自动使用一些服务组件,例如: `Message`、`ModalBox` 等且需要自动引入样式时,需要安装 `litosui-unplugin-resolver`、`unplugin-auto-import` 插件。
14
+
15
+ ```js
16
+ // vite.config.js
17
+ import AutoImport from "unplugin-auto-import/vite";
18
+ import LitosuiResolver from "litosui-unplugin-resolver";
19
+
20
+ // https://vitejs.dev/config/
21
+ export default defineConfig({
22
+ plugins: [
23
+ ...,
24
+ AutoImport({
25
+ resolvers: [LitosuiResolver()],
26
+ dts: "src/auto-imports.d.ts",
27
+ }),
28
+ ],
29
+ ...
30
+ });
31
+ ```
32
+
33
+ ## 使用
34
+
35
+ 引入相关组件并注册
36
+
37
+ ```js
38
+ import { Button, regist } from "litos-ui";
39
+
40
+ regist([Button]); // <l-button></l-button>
41
+ ```
42
+
43
+ ## 文档
44
+
45
+ [litos-ui 文档](https://dvshu.github.io/litos-ui/)
46
+
47
+ ## 许可证
48
+
49
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
@@ -0,0 +1,4 @@
1
+ //#region src/components/styles/animation.css?inline
2
+ var e = "@keyframes l-rotate-frame{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.l-rotate-anim{animation:1.5s linear infinite l-rotate-frame}";
3
+ //#endregion
4
+ export { e as t };
@@ -0,0 +1,62 @@
1
+ import e from "./base.js";
2
+ import { unitNumberStr as t } from "./utils/index.js";
3
+ //#region src/components/icon/index.less?inline
4
+ var n = ":host{display:inline-flex}.l-icon{fill:currentColor;vertical-align:middle;width:1em;height:1em;color:var(--l-icon-color,inherit);font-size:var(--l-icon-size,inherit);display:inline-block}", r = class extends e {
5
+ static baseName = "base-icon";
6
+ useLink;
7
+ viewBox;
8
+ constructor() {
9
+ super(), this.useLink = !1, this.viewBox = "0 0 1024 1024", this.version = 2, this._state = {};
10
+ }
11
+ static get observedAttributes() {
12
+ return ["color", "size"];
13
+ }
14
+ attributeChanged(e, n, r) {
15
+ switch (e) {
16
+ case "color":
17
+ this._state.color = r;
18
+ break;
19
+ case "size":
20
+ this._state.size = t(r);
21
+ break;
22
+ }
23
+ }
24
+ connectedCallback() {
25
+ super.connectedCallback(), this._updateColor(), this._updateSize();
26
+ }
27
+ updateDOM(e) {
28
+ console.log("up"), e.has("color") && this._updateColor(), e.has("size") && this._updateSize();
29
+ }
30
+ _updateSize() {
31
+ this._state.size ? this.style.setProperty("--l-icon-size", this._state.size) : this.style.removeProperty("--l-icon-size");
32
+ }
33
+ _updateColor() {
34
+ this._state.color ? this.style.setProperty("--l-icon-color", this._state.color) : this.style.removeProperty("--l-icon-color");
35
+ }
36
+ render_v2() {
37
+ let e = this.createEl("svg");
38
+ e.classList.add("l-icon"), this.useLink || e.setAttribute("viewBox", this.viewBox);
39
+ let t = this.renderChildren();
40
+ if (typeof t == "string") if (t === "") {
41
+ let t = this.children, n = [];
42
+ for (let e = 0, r = t.length; e < r; e++) {
43
+ let r = t[e];
44
+ n.push(r.outerHTML);
45
+ }
46
+ e.innerHTML = n.join("");
47
+ } else e.innerHTML = t;
48
+ else e.append(t);
49
+ return {
50
+ template: e,
51
+ style: n
52
+ };
53
+ }
54
+ renderChildren() {
55
+ return "";
56
+ }
57
+ createEl(e) {
58
+ return document.createElementNS("http://www.w3.org/2000/svg", e);
59
+ }
60
+ };
61
+ //#endregion
62
+ export { r as t };
package/lib/base.js CHANGED
@@ -1,148 +1,112 @@
1
- import { getAttr as s } from "ph-utils/dom";
2
- class a extends HTMLElement {
3
- static baseName = "base-component";
4
- /** 组件是否渲染完成, 是否已经调用 connectedCallback */
5
- rendered;
6
- // state
7
- _state;
8
- // 是否正在批量更新
9
- _pendingUpdate;
10
- _pendingTask;
11
- // 延迟任务id
12
- _changedProperties;
13
- // 已改变的属性集合
14
- /** 版本, 1 - 直接调用 render, 2 - 渲染 render_v2 */
15
- version;
16
- constructor(e = !0, t = {}) {
17
- super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this.version = 1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({ mode: "open", ...t });
18
- }
19
- /**
20
- * 返回一个数组,表示观察的属性列表
21
- */
22
- static get observedAttributes() {
23
- return [];
24
- }
25
- // 当属性发生变化时调用的回调函数
26
- attributeChangedCallback(e, t, n) {
27
- t !== n && (this._changedProperties.add(e), this.attributeChanged(e, t, n), this.rendered && this.batchUpdate());
28
- }
29
- attributeChanged(e, t, n) {
30
- }
31
- cancelPending() {
32
- this._pendingTask && (cancelAnimationFrame(this._pendingTask), this._pendingTask = void 0, this._pendingUpdate = !1);
33
- }
34
- batchUpdate() {
35
- this._pendingUpdate || (this.cancelPending(), this._pendingUpdate = !0, this._pendingTask = requestAnimationFrame(() => {
36
- const e = new Set(this._changedProperties);
37
- this._changedProperties.clear(), this.updateDOM(e), this._pendingUpdate = !1;
38
- }));
39
- }
40
- updateDOM(e) {
41
- }
42
- /** @deprecated */
43
- get shadow() {
44
- return this.shadowRoot;
45
- }
46
- get root() {
47
- return this.shadowRoot || this;
48
- }
49
- createStyle(e) {
50
- const t = document.createElement("style");
51
- t.textContent = e.trim(), this.root.appendChild(t);
52
- }
53
- createLink(e) {
54
- const t = document.createElement("link");
55
- t.rel = "stylesheet", t.href = e, this.root.appendChild(t);
56
- }
57
- loadStyleText(e) {
58
- let t = e;
59
- Array.isArray(t) && (t = t.join("")), this.createStyle(t);
60
- }
61
- styleHtml(e) {
62
- let t = e;
63
- return Array.isArray(t) && (t = t.join("")), `<style>${t}</style>`;
64
- }
65
- getAttr(e, t) {
66
- return s(this, e, t);
67
- }
68
- appendToRoot(e) {
69
- if (e)
70
- if (typeof e == "string") {
71
- let t = document.createElement("div");
72
- t.innerHTML = e, this.root.append(...t.childNodes), t = void 0;
73
- } else e.length ? this.root.append(...e) : this.root.append(e);
74
- }
75
- appendToRootV2(e, t) {
76
- const n = [];
77
- if (t && n.push(this.styleHtml(t)), e)
78
- if (typeof e == "string")
79
- n.push(e);
80
- else {
81
- let i = document.createElement("div");
82
- i.appendChild(e), n.push(i.innerHTML), i = void 0;
83
- }
84
- this.root.innerHTML = n.join("");
85
- }
86
- connectedCallback() {
87
- if (this.version === 1)
88
- this.appendToRoot(this.render());
89
- else {
90
- const e = this.render_v2();
91
- this.appendToRootV2(e.template, e.style);
92
- }
93
- this.rendered = !0, this.initEvents(), this.afterInit();
94
- }
95
- disconnectedCallback() {
96
- this.cancelPending(), this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
97
- }
98
- render() {
99
- }
100
- /**
101
- * 渲染器
102
- * @returns [渲染节点,内容, 模板样式]
103
- */
104
- render_v2() {
105
- return {};
106
- }
107
- /**
108
- * 初始化事件
109
- * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
110
- */
111
- initEvents() {
112
- }
113
- afterInit() {
114
- }
115
- /** 移除事件 */
116
- /**
117
- * 移除事件
118
- * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
119
- */
120
- removeEvents() {
121
- }
122
- beforeDestroy() {
123
- }
124
- /**
125
- * 触发自定义事件
126
- * @param name 事件名称
127
- * @param eventOption 自定义事件配置选项, 默认: bubbles: true
128
- * @returns 是否成功触发事件
129
- */
130
- emit(e, t) {
131
- return this.dispatchEvent(
132
- new CustomEvent(e, { bubbles: !0, composed: !1, ...t })
133
- );
134
- }
135
- emitInject(e, t) {
136
- this.emit(e, {
137
- bubbles: !0,
138
- composed: !0,
139
- detail: {
140
- context: e,
141
- callback: t
142
- }
143
- });
144
- }
145
- }
146
- export {
147
- a as default
1
+ import { getAttr as e } from "ph-utils/dom";
2
+ //#region src/components/base.ts
3
+ var t = class extends HTMLElement {
4
+ static baseName = "base-component";
5
+ rendered;
6
+ _state;
7
+ _pendingUpdate;
8
+ _pendingTask;
9
+ _changedProperties;
10
+ version;
11
+ constructor(e = !0, t = {}) {
12
+ super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this.version = 1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({
13
+ mode: "open",
14
+ ...t
15
+ });
16
+ }
17
+ static get observedAttributes() {
18
+ return [];
19
+ }
20
+ attributeChangedCallback(e, t, n) {
21
+ t !== n && (this._changedProperties.add(e), this.attributeChanged(e, t, n), this.rendered && this.batchUpdate());
22
+ }
23
+ attributeChanged(e, t, n) {}
24
+ cancelPending() {
25
+ this._pendingTask && (cancelAnimationFrame(this._pendingTask), this._pendingTask = void 0, this._pendingUpdate = !1);
26
+ }
27
+ batchUpdate() {
28
+ this._pendingUpdate || (this.cancelPending(), this._pendingUpdate = !0, this._pendingTask = requestAnimationFrame(() => {
29
+ let e = new Set(this._changedProperties);
30
+ this._changedProperties.clear(), this.updateDOM(e), this._pendingUpdate = !1;
31
+ }));
32
+ }
33
+ updateDOM(e) {}
34
+ get shadow() {
35
+ return this.shadowRoot;
36
+ }
37
+ get root() {
38
+ return this.shadowRoot || this;
39
+ }
40
+ createStyle(e) {
41
+ let t = document.createElement("style");
42
+ t.textContent = e.trim(), this.root.appendChild(t);
43
+ }
44
+ createLink(e) {
45
+ let t = document.createElement("link");
46
+ t.rel = "stylesheet", t.href = e, this.root.appendChild(t);
47
+ }
48
+ loadStyleText(e) {
49
+ let t = e;
50
+ Array.isArray(t) && (t = t.join("")), this.createStyle(t);
51
+ }
52
+ styleHtml(e) {
53
+ let t = e;
54
+ return Array.isArray(t) && (t = t.join("")), `<style>${t}</style>`;
55
+ }
56
+ getAttr(t, n) {
57
+ return e(this, t, n);
58
+ }
59
+ appendToRoot(e) {
60
+ if (e) if (typeof e == "string") {
61
+ let t = document.createElement("div");
62
+ t.innerHTML = e, this.root.append(...t.childNodes), t = void 0;
63
+ } else e.length ? this.root.append(...e) : this.root.append(e);
64
+ }
65
+ appendToRootV2(e, t) {
66
+ let n = [];
67
+ if (t && n.push(this.styleHtml(t)), e) if (typeof e == "string") n.push(e);
68
+ else {
69
+ let t = document.createElement("div");
70
+ t.appendChild(e), n.push(t.innerHTML), t = void 0;
71
+ }
72
+ this.root.innerHTML = n.join("");
73
+ }
74
+ connectedCallback() {
75
+ if (this.version === 1) this.appendToRoot(this.render());
76
+ else {
77
+ let e = this.render_v2();
78
+ this.appendToRootV2(e.template, e.style);
79
+ }
80
+ this.rendered = !0, this.initEvents(), this.afterInit();
81
+ }
82
+ disconnectedCallback() {
83
+ this.cancelPending(), this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
84
+ }
85
+ render() {}
86
+ render_v2() {
87
+ return {};
88
+ }
89
+ initEvents() {}
90
+ afterInit() {}
91
+ removeEvents() {}
92
+ beforeDestroy() {}
93
+ emit(e, t) {
94
+ return this.dispatchEvent(new CustomEvent(e, {
95
+ bubbles: !0,
96
+ composed: !1,
97
+ ...t
98
+ }));
99
+ }
100
+ emitInject(e, t) {
101
+ this.emit(e, {
102
+ bubbles: !0,
103
+ composed: !0,
104
+ detail: {
105
+ context: e,
106
+ callback: t
107
+ }
108
+ });
109
+ }
148
110
  };
111
+ //#endregion
112
+ export { t as default };
@@ -1,7 +1,7 @@
1
1
  import BaseComponent from "../base";
2
2
  type ButtonState = {
3
3
  loading: boolean;
4
- htmlType: string;
4
+ htmlType: "submit" | "reset" | "button";
5
5
  text: boolean;
6
6
  ghost: boolean;
7
7
  color?: string;
@@ -10,10 +10,10 @@ type ButtonState = {
10
10
  type: "normal" | "primary";
11
11
  shape: "default" | "round" | "circle";
12
12
  loadingText: string;
13
+ size: "small" | "large" | "default";
13
14
  };
14
15
  export default class Button extends BaseComponent<ButtonState> {
15
16
  static baseName: string;
16
- _disabled: boolean;
17
17
  $btn?: HTMLButtonElement;
18
18
  constructor();
19
19
  get disabled(): boolean;
@@ -27,10 +27,15 @@ export default class Button extends BaseComponent<ButtonState> {
27
27
  disconnectedCallback(): void;
28
28
  isFormButton(): boolean;
29
29
  getHtmlType(): "submit" | "reset" | "button";
30
- render(): void;
30
+ render_v2(): {
31
+ template?: string | HTMLElement | DocumentFragment;
32
+ style?: string | string[];
33
+ };
34
+ render(): HTMLButtonElement;
31
35
  loadingBody(): string;
32
36
  applyColor(color: string, text?: boolean, ghost?: boolean): string;
33
37
  private _updateHeight;
38
+ private _replaceBtnClass;
34
39
  private _handleClick;
35
40
  }
36
41
  export {};
@@ -1,137 +1,2 @@
1
- import { kebabToCamel as b, parseAttrValue as d } from "../utils/index.js";
2
- import c from "../base.js";
3
- import { addClass as h, removeClass as p, on as g, off as v, formatClass as f, formatStyle as u } from "ph-utils/dom";
4
- import { adjust as s } from "ph-utils/color";
5
- import { a as m } from "../animation-DttknHkX.js";
6
- const k = ":host{--l-btn-padding: 0 15px;--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;--l-btn-height: var(--l-form-control-height, 32px);display:inline-flex;width:auto;height:var(--l-btn-height);text-indent:0;box-sizing:border-box;border-radius:var(--l-border-radius, 3px)}:host([block]){width:100%}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:var(--l-btn-padding);line-height:1;height:100%;border-radius:inherit;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:var(--l-btn-gap, 5px);font-size:inherit;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color, var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab);--l-btn-disabled-border-color: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-background: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-color: #ffffff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-padding: 5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-control-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-control-height, 32px);padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
7
- class H extends c {
8
- static baseName = "button";
9
- // public htmlType: "submit" | "reset" | "button" = "button";
10
- _disabled = !1;
11
- $btn;
12
- constructor() {
13
- super(), this._state = {
14
- loading: !1,
15
- htmlType: "button",
16
- text: !1,
17
- ghost: !1,
18
- disabled: !1,
19
- type: "normal",
20
- shape: "default",
21
- loadingText: "加载中……"
22
- };
23
- }
24
- get disabled() {
25
- return this._disabled;
26
- }
27
- set disabled(t) {
28
- this.setDisabled(t);
29
- }
30
- setLoading(t) {
31
- this.$btn && (t ? (h(this.$btn, "l-btn-loading"), this.$btn.disabled = !0, this.$btn.innerHTML = this.loadingBody()) : (p(this.$btn, "l-btn-loading"), this.$btn.disabled = this.disabled, this.$btn.innerHTML = "<slot></slot>"));
32
- }
33
- setDisabled(t) {
34
- this._disabled = t, this.$btn && (this.$btn.disabled = t);
35
- }
36
- // 初始化属性观察器
37
- static get observedAttributes() {
38
- return [
39
- "loading",
40
- "color",
41
- "text",
42
- "ghost",
43
- "disabled",
44
- "height",
45
- "html-type",
46
- "type",
47
- "shape",
48
- "loading-text"
49
- ];
50
- }
51
- attributeChanged(t, r, o) {
52
- switch (t) {
53
- case "color":
54
- case "height":
55
- case "shape":
56
- case "type":
57
- this._state[t] = o;
58
- break;
59
- case "text":
60
- case "ghost":
61
- case "disabled":
62
- case "loading":
63
- this._state[t] = d(o, !1, t);
64
- break;
65
- case "html-type":
66
- case "loading-text":
67
- this._state[b(t)] = o;
68
- break;
69
- }
70
- }
71
- updateDOM(t) {
72
- this.$btn && (t.has("loading") && this.setLoading(this._state.loading), t.has("disabled") && this.setDisabled(this.disabled), t.has("color") && this._state.color && (this.$btn.style.cssText = this.applyColor(
73
- this._state.color,
74
- this._state.text,
75
- this._state.ghost
76
- ))), t.has("height") && this._updateHeight(this._state.height);
77
- }
78
- connectedCallback() {
79
- this.loadStyleText([m, k]), super.connectedCallback(), this.isFormButton() && g(this, "click", this._handleClick), this._updateHeight(this._state.height);
80
- }
81
- disconnectedCallback() {
82
- super.disconnectedCallback(), this.isFormButton() && v(this, "click", this._handleClick), this.$btn = void 0;
83
- }
84
- isFormButton() {
85
- const t = this.getHtmlType();
86
- return t === "submit" || t === "reset";
87
- }
88
- getHtmlType() {
89
- return this._state.htmlType;
90
- }
91
- render() {
92
- const t = this._state.type, r = document.createElement("button"), o = this._state.loading, e = this._state.shape, l = this._state.text, a = this._state.ghost, i = [
93
- "l-btn",
94
- `l-btn-${t}`,
95
- e === "round" ? "l-btn-round" : "",
96
- e === "circle" ? "l-btn-circle" : "",
97
- a ? "l-btn-ghost" : "",
98
- l ? "l-btn-text" : "",
99
- o ? "l-btn-loading" : ""
100
- ];
101
- r.className = f(i), (this.disabled || o) && (r.disabled = !0), r.type = this._state.htmlType;
102
- const n = this.applyColor(this._state.color || "", l, a);
103
- n && (r.style.cssText = n), o ? r.innerHTML = this.loadingBody() : r.innerHTML = "<slot></slot>", r.setAttribute("part", "default"), this.$btn = r, this.root.appendChild(r);
104
- }
105
- loadingBody() {
106
- const t = this._state.loadingText, r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
107
- return t ? r.push(`<span>${t}</span>`) : r.push("<slot></slot>"), r.join("");
108
- }
109
- applyColor(t, r = !1, o = !1) {
110
- if (!t) return "";
111
- const e = s(t, 1, !0), l = s(t, 3, !1);
112
- return u({
113
- "--l-btn-border-color": r ? "transparent" : t,
114
- "--l-btn-text-color": o || r ? t : "#ffffff",
115
- "--l-btn-hover-text-color": o || r ? e : "#ffffff",
116
- "--l-btn-background": o || r ? "transparent" : t,
117
- "--l-btn-active-text-color": o || r ? l : "#ffffff",
118
- "--l-btn-hover-border-color": r ? "transparent" : e,
119
- "--l-btn-hover-background": o || r ? "transparent" : e,
120
- "--l-btn-active-background": o || r ? "transparent" : l,
121
- "--l-btn-active-border-color": r ? "transparent" : l
122
- });
123
- }
124
- _updateHeight(t) {
125
- t && (typeof t == "number" && (t = `${t}px`), this.style.setProperty("--l-btn-height", t));
126
- }
127
- _handleClick = () => {
128
- (this._state.htmlType === "reset" || this._state.htmlType === "submit") && this.emit("form-action", {
129
- bubbles: !0,
130
- composed: !0,
131
- detail: this._state.htmlType
132
- });
133
- };
134
- }
135
- export {
136
- H as default
137
- };
1
+ import { t as e } from "../button-CC5PmAb1.js";
2
+ export { e as default };