litos-ui 0.17.4 → 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 +15 -4
  9. package/lib/calendar/index.js +2 -95
  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 +4 -2
  96. package/lib/loading/index.js +109 -123
  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
@@ -0,0 +1,48 @@
1
+ import { initAttr as e } from "./utils/index.js";
2
+ import { t } from "./form_inner-DR9tyB_r.js";
3
+ import { $one as n, addClass as r, off as i, on as a, removeClass as o } from "ph-utils/dom";
4
+ //#region src/components/switch/index.less?inline
5
+ var s = ":host{box-sizing:border-box;--l-switch-height:22px;--l-switch-width:40px;width:auto;width:var(--l-switch-width);height:var(--l-switch-height);border-radius:calc(var(--l-switch-height) / 2);cursor:pointer;vertical-align:middle;background-color:#dcdfe6;border:1px solid #c2c2c2;justify-content:flex-start;align-items:center;padding:2px;transition:all .3s ease-in-out;display:inline-flex;position:relative}:host(:hover),:host(.l-switch--checked):hover{border-color:var(--l-primary-color,#722ed1)}:host(.l-switch--checked){background-color:var(--l-primary-color,#722ed1);border-color:var(--l-primary-color,#722ed1)}.l-switch-action{width:calc(var(--l-switch-height) - 6px);box-sizing:border-box;background-color:#fff;border-radius:50%;justify-content:center;align-items:center;padding:2px;font-size:12px;transition:all .3s ease-in-out;display:flex;position:absolute;top:2px;bottom:2px;left:2px}.l-switch-text{color:#fff;padding-left:calc(var(--l-switch-width) - 20px);transition:padding-left .3s ease-in-out}:host(.l-switch--checked) .l-switch-action{left:calc(var(--l-switch-width) - var(--l-switch-height) + 3px)}:host(.l-switch--checked) .l-switch-text{padding-left:5px}", c = class extends t {
6
+ static baseName = "switch";
7
+ actionRender;
8
+ checkedText;
9
+ uncheckedText;
10
+ connectedCallback() {
11
+ e(this), this.loadStyleText(s), super.connectedCallback(), this.pushValueChange(), this.#t(), a(this, "click", this.#e);
12
+ }
13
+ disconnectedCallback() {
14
+ super.disconnectedCallback(), i(this, "click", this.#e), this.actionRender = void 0;
15
+ }
16
+ render() {
17
+ this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
18
+ let e = ["<div class=\"l-switch-action\" part=\"action\"></div>"];
19
+ if (this.checkedText || this.uncheckedText) {
20
+ let t = this.value ? this.checkedText || "" : this.uncheckedText || "";
21
+ e.push(`<span class="l-switch-text">${t}</span>`);
22
+ }
23
+ return e.join("");
24
+ }
25
+ #e = (e) => {
26
+ this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
27
+ };
28
+ setValue(e) {
29
+ super.setValue(e), e ? r(this, "l-switch--checked") : o(this, "l-switch--checked");
30
+ let t = n(".l-switch-text", this.root);
31
+ t && (t.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
32
+ }
33
+ setActionRender(e) {
34
+ this.actionRender = e, this.#t();
35
+ }
36
+ #t() {
37
+ let e = n(".l-switch-action", this.root);
38
+ if (e) if (this.actionRender) {
39
+ let t = this.actionRender({ checked: this.value });
40
+ typeof t == "string" ? e.innerHTML = t : e.innerHTML = t.outerHTML;
41
+ } else {
42
+ let t = n("[slot=\"checked-action\"]", this), r = n("[slot=\"unchecked-action\"]", this);
43
+ this.value && t ? e.innerHTML = "<slot name=\"checked-action\"></slot>" : !this.value && r && (e.innerHTML = "<slot name=\"unchecked-action\"></slot>");
44
+ }
45
+ }
46
+ };
47
+ //#endregion
48
+ export { c as t };
@@ -1,109 +1,2 @@
1
- import { isBlank as h, isNumeric as c } from "ph-utils";
2
- import d from "../base.js";
3
- import { parseAttrValue as l } from "../utils/index.js";
4
- import { addClass as b, removeClass as s, $one as r, create as n, $$ as p, on as f, off as m, shouldEventNext as u, isVisible as v } from "ph-utils/dom";
5
- const g = ":host{--l-tabbar-hover-color: var(--l-primary-color-light1, #9254de);--l-tabbar-active-color: var(--l-primary-color, #722ed1);--l-tabbar-item-gap: 0;--l-tabbar-height: 38px;position:relative;overflow:hidden;height:var(--l-tabbar-height);background-color:#fff;display:flex;flex-wrap:nowrap;align-items:stretch;gap:var(--l-tabbar-item-gap);box-sizing:border-box}:host(.l-tabbar--nav){--l-tabbar-height: 50px;--l-tabbar-item-grow: 1;width:100%}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding: 10px;--l-tabbar-item-gap: 30px;--l-tabbar-line-color: var(--l-primary-color, #722ed1);overflow:auto;white-space:nowrap}.l-tabbar--bar-line{position:absolute;width:32px;left:0;bottom:0;border-radius:1px;height:2px;background-color:var(--l-tabbar-line-color);transition:all .3s ease-in-out}:host(.l-tabbar--card){--l-tabbar-card-border-color: #f5f7fa;--l-tabbar-line-color: #fff;--l-tabbar-item-gap: 0;--l-tabbar-card-border-radius: 5px}.l-tabbar-card-border{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--l-tabbar-card-border-color)}";
6
- class _ extends d {
7
- static baseName = "tabbar";
8
- /**
9
- * 标签类型:
10
- * 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
11
- * 2. bar - 选项卡
12
- * 3. card - 卡片
13
- */
14
- type = "nav";
15
- _name = "";
16
- gap;
17
- $line;
18
- get name() {
19
- return this._name;
20
- }
21
- set name(t) {
22
- this._name = t;
23
- }
24
- connectedCallback() {
25
- this.loadStyleText(g), b(this, `l-tabbar--${this.type}`), this.#t(), super.connectedCallback();
26
- }
27
- static get observedAttributes() {
28
- return ["name", "type", "justify-content", "gap"];
29
- }
30
- attributeChangedCallback(t, e, a) {
31
- if (t === "name") {
32
- const i = l(a, void 0);
33
- this.name = i, this._updateActive(), this._updateLine();
34
- } else if (t === "type") {
35
- const i = l(a, "nav");
36
- if (i !== this.type && (s(this, `l-tabbar--${this.type}`), this.type = i, s(this, `l-tabbar--${i}`), i === "card")) {
37
- let o = r(".l-tabbar-card-border", this.root);
38
- o || (o = n("div", { class: "l-tabbar-card-border" }), this.root.appendChild(o));
39
- }
40
- } else {
41
- const i = l(a, void 0);
42
- this[t] = i, this.#t();
43
- }
44
- }
45
- render() {
46
- const t = document.createDocumentFragment();
47
- if (t.appendChild(p("slot")), this.type === "card") {
48
- const e = n("div", { class: "l-tabbar-card-border" });
49
- t.appendChild(e);
50
- }
51
- return t;
52
- }
53
- afterInit() {
54
- f(this.root, "click", this._handleClick), setTimeout(() => {
55
- this._updateLine();
56
- }, 300);
57
- }
58
- beforeDestroy() {
59
- m(this.root, "click", this._handleClick), this.$line = void 0;
60
- }
61
- _handleClick = (t) => {
62
- const [e, a] = u(t, "name", this);
63
- e && a !== this.name && (this.name = a, this.dispatchEvent(
64
- new CustomEvent("change", {
65
- detail: {
66
- name: a
67
- }
68
- })
69
- ), this._updateActive(), this._updateLine());
70
- };
71
- _updateActive() {
72
- const t = r(".active", this);
73
- t && s(t, "active");
74
- const e = r(`[name="${this.name}"]`, this);
75
- e && b(e, "active");
76
- }
77
- /**
78
- * 初始化线条的方法,在微任务队列中执行。
79
- * 该方法用于设置或更新标签栏中的线条位置或样式。
80
- */
81
- _updateLine() {
82
- queueMicrotask(() => {
83
- if (!this.name || this.type === "nav" || !this.rendered) return;
84
- const t = r(".active", this);
85
- if (!t) return;
86
- const e = t.offsetLeft;
87
- if (!this.$line) {
88
- const a = n("div", { class: "l-tabbar--bar-line" });
89
- a.part = "line", this.root.appendChild(a), this.$line = r(".l-tabbar--bar-line", this.root);
90
- }
91
- this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, v(t, this) || this.scrollTo({
92
- left: e,
93
- behavior: "smooth"
94
- });
95
- });
96
- }
97
- #t() {
98
- const t = this.getAttr("justify-content");
99
- if (h(t) ? this.style.removeProperty("justify-content") : this.style.setProperty("justify-content", t), h(this.gap))
100
- this.style.removeProperty("--l-tabbar-item-gap"), s(this, "l-tabbar-gap");
101
- else {
102
- let e = this.gap;
103
- c(e, { isPositive: !0 }) && (e = `${e}px`), b(this, "l-tabbar-gap"), this.style.setProperty("--l-tabbar-item-gap", e);
104
- }
105
- }
106
- }
107
- export {
108
- _ as default
109
- };
1
+ import { t as e } from "../tabbar-4_d2Fj1n.js";
2
+ export { e as default };
@@ -1,58 +1,2 @@
1
- import l from "../base.js";
2
- import { parseAttrValue as s } from "../utils/index.js";
3
- import { addClass as i, $one as a, $$ as r, removeClass as c } from "ph-utils/dom";
4
- const d = ":host{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;line-height:1;flex-direction:column;flex-grow:var(--l-tabbar-item-grow, 0);box-sizing:border-box}:host(:hover){color:var(--l-tabbar-hover-color)}:host(.active){color:var(--l-tabbar-active-color)}.icon-wrapper{font-size:18px;margin-bottom:3px;display:flex;justify-content:center;align-items:center}.icon-wrapper.only{font-size:24px;margin-bottom:0}:host(.l-item--card){padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-item--card:first-child){border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-item--card:last-child){border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-item--card.active){background:#fff}:host(.l-item--gap){border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}";
5
- class m extends l {
6
- static baseName = "tabbar-item";
7
- name;
8
- icon;
9
- onlyIcon;
10
- static get observedAttributes() {
11
- return ["name", "label", "icon", "only-icon"];
12
- }
13
- connectedCallback() {
14
- this.loadStyleText(d);
15
- const t = this.parentElement;
16
- t.gap && i(this, "l-item--gap"), t.type === "card" && i(this, "l-item--card"), super.connectedCallback();
17
- }
18
- attributeChangedCallback(t, o, e) {
19
- if (t === "icon" || t === "only-icon") {
20
- const n = s(e, !1, "icon");
21
- this[t] = n, this.#t();
22
- } else
23
- this[t] = e;
24
- }
25
- #t() {
26
- if (!this.rendered) return;
27
- let t = a(".icon-wrapper", this.root);
28
- this.icon ? t ? this.onlyIcon ? i(t, "only") : c(t, "only") : (t = r("div", {
29
- class: ["icon-wrapper", this.onlyIcon ? "only" : ""],
30
- innerHTML: "<slot name='icon'></slot>"
31
- }), this.root.prepend(t)) : t && t.remove();
32
- let o = a("slot:not([name])", this.root);
33
- if (this.onlyIcon)
34
- o && o.remove();
35
- else if (!o) {
36
- const e = r("slot");
37
- this.root.appendChild(e);
38
- }
39
- }
40
- render() {
41
- const t = document.createDocumentFragment();
42
- if (this.icon) {
43
- const o = r("div", {
44
- class: ["icon-wrapper", this.onlyIcon ? "only" : ""],
45
- innerHTML: "<slot name='icon'></slot>"
46
- });
47
- t.appendChild(o);
48
- }
49
- if (!this.onlyIcon) {
50
- const o = r("slot");
51
- t.appendChild(o);
52
- }
53
- return t;
54
- }
55
- }
56
- export {
57
- m as default
58
- };
1
+ import { t as e } from "../item-DV842Aux.js";
2
+ export { e as default };
@@ -0,0 +1,91 @@
1
+ import e from "./base.js";
2
+ import { parseAttrValue as t } from "./utils/index.js";
3
+ import { $$ as n, $one as r, addClass as i, create as a, isVisible as o, off as s, on as c, removeClass as l, shouldEventNext as u } from "ph-utils/dom";
4
+ import { isBlank as d, isNumeric as f } from "ph-utils";
5
+ //#region src/components/tabbar/index.less?inline
6
+ var p = ":host{--l-tabbar-hover-color:var(--l-primary-color-light1,#9254de);--l-tabbar-active-color:var(--l-primary-color,#722ed1);--l-tabbar-item-gap:0;--l-tabbar-height:38px;height:var(--l-tabbar-height);align-items:stretch;gap:var(--l-tabbar-item-gap);box-sizing:border-box;background-color:#fff;flex-wrap:nowrap;display:flex;position:relative;overflow:hidden}:host(.l-tabbar--nav){--l-tabbar-height:50px;--l-tabbar-item-grow:1;width:100%}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding:10px;--l-tabbar-item-gap:30px;--l-tabbar-line-color:var(--l-primary-color,#722ed1);white-space:nowrap;overflow:auto}.l-tabbar--bar-line{background-color:var(--l-tabbar-line-color);border-radius:1px;width:32px;height:2px;transition:all .3s ease-in-out;position:absolute;bottom:0;left:0}:host(.l-tabbar--card){--l-tabbar-card-border-color:#f5f7fa;--l-tabbar-line-color:#fff;--l-tabbar-item-gap:0;--l-tabbar-card-border-radius:5px}.l-tabbar-card-border{background-color:var(--l-tabbar-card-border-color);height:1px;position:absolute;bottom:0;left:0;right:0}", m = class extends e {
7
+ static baseName = "tabbar";
8
+ type = "nav";
9
+ _name = "";
10
+ gap;
11
+ $line;
12
+ get name() {
13
+ return this._name;
14
+ }
15
+ set name(e) {
16
+ this._name = e;
17
+ }
18
+ connectedCallback() {
19
+ this.loadStyleText(p), i(this, `l-tabbar--${this.type}`), this.#e(), super.connectedCallback();
20
+ }
21
+ static get observedAttributes() {
22
+ return [
23
+ "name",
24
+ "type",
25
+ "justify-content",
26
+ "gap"
27
+ ];
28
+ }
29
+ attributeChangedCallback(e, n, i) {
30
+ if (e === "name") this.name = t(i, void 0), this._updateActive(), this._updateLine();
31
+ else if (e === "type") {
32
+ let e = t(i, "nav");
33
+ if (e !== this.type && (l(this, `l-tabbar--${this.type}`), this.type = e, l(this, `l-tabbar--${e}`), e === "card")) {
34
+ let e = r(".l-tabbar-card-border", this.root);
35
+ e || (e = a("div", { class: "l-tabbar-card-border" }), this.root.appendChild(e));
36
+ }
37
+ } else this[e] = t(i, void 0), this.#e();
38
+ }
39
+ render() {
40
+ let e = document.createDocumentFragment();
41
+ if (e.appendChild(n("slot")), this.type === "card") {
42
+ let t = a("div", { class: "l-tabbar-card-border" });
43
+ e.appendChild(t);
44
+ }
45
+ return e;
46
+ }
47
+ afterInit() {
48
+ c(this.root, "click", this._handleClick), setTimeout(() => {
49
+ this._updateLine();
50
+ }, 300);
51
+ }
52
+ beforeDestroy() {
53
+ s(this.root, "click", this._handleClick), this.$line = void 0;
54
+ }
55
+ _handleClick = (e) => {
56
+ let [t, n] = u(e, "name", this);
57
+ t && n !== this.name && (this.name = n, this.dispatchEvent(new CustomEvent("change", { detail: { name: n } })), this._updateActive(), this._updateLine());
58
+ };
59
+ _updateActive() {
60
+ let e = r(".active", this);
61
+ e && l(e, "active");
62
+ let t = r(`[name="${this.name}"]`, this);
63
+ t && i(t, "active");
64
+ }
65
+ _updateLine() {
66
+ queueMicrotask(() => {
67
+ if (!this.name || this.type === "nav" || !this.rendered) return;
68
+ let e = r(".active", this);
69
+ if (!e) return;
70
+ let t = e.offsetLeft;
71
+ if (!this.$line) {
72
+ let e = a("div", { class: "l-tabbar--bar-line" });
73
+ e.part = "line", this.root.appendChild(e), this.$line = r(".l-tabbar--bar-line", this.root);
74
+ }
75
+ this.$line.style.cssText = `width:${e.offsetWidth}px;left:${t}px`, o(e, this) || this.scrollTo({
76
+ left: t,
77
+ behavior: "smooth"
78
+ });
79
+ });
80
+ }
81
+ #e() {
82
+ let e = this.getAttr("justify-content");
83
+ if (d(e) ? this.style.removeProperty("justify-content") : this.style.setProperty("justify-content", e), d(this.gap)) this.style.removeProperty("--l-tabbar-item-gap"), l(this, "l-tabbar-gap");
84
+ else {
85
+ let e = this.gap;
86
+ f(e, { isPositive: !0 }) && (e = `${e}px`), i(this, "l-tabbar-gap"), this.style.setProperty("--l-tabbar-item-gap", e);
87
+ }
88
+ }
89
+ };
90
+ //#endregion
91
+ export { m as t };
@@ -1,269 +1,2 @@
1
- import p from "../base.js";
2
- import { kebabToCamel as b, parseAttrValue as x } from "../utils/index.js";
3
- import { $one as h, $$ as d, iterate as g, formatStyle as f, shouldEventNext as y, on as u, off as C } from "ph-utils/dom";
4
- import { random as _ } from "ph-utils";
5
- const m = ":host{display:inline-block;width:100%;max-height:var(--l-table-max-height, 100%);overflow:auto;font-size:var(--l-table-font-size, 14px)}.l-table{width:100%;border-collapse:collapse;border-spacing:0;table-layout:var(--l-table-layout, auto)}.l-table th,.l-table td{border-bottom:1px solid var(--l-table-border-color, #e6e6e6)}.l-table th{padding:var(--l-table-th-padding, 10px);text-align:left;background-color:var(--l-table-th-bg, #f2f2f2);color:var(--l-table-th-color, #000000)}.l-table td{background-color:var(--l-table-td-bg, #ffffff);color:var(--l-table-td-color, #000000);padding:var(--l-table-td-padding, 10px);transition:background-color .3s}.l-table tr:hover td{background-color:var(--l-table-row-hover-bg, #f2f2f2)}.l-table .l-table__empty-col{color:var(--l-table-empty-color, #999999);text-align:center}.l-table-stripe tr:nth-child(2n) td{background-color:var(--l-table-stripe-bg, #fafafa)}.l-table-stripe tr:nth-child(2n):hover td{background-color:var(--l-table-row-hover-bg, #f2f2f2)}.l-table-border th,.l-table-border td{border:1px solid var(--l-table-border-color, #e6e6e6)}.l-table-fixed{--l-table-layout: fixed}.l-table-fixed .l-fixed{position:-webkit-sticky;position:sticky;z-index:1;box-sizing:border-box}.l-table-fixed thead.l-fixed,.l-table-fixed tfoot.l-fixed{z-index:2}.l-table .caret-wrapper{display:inline-flex;justify-content:center;align-items:center;vertical-align:middle;height:14px;width:20px;position:relative}.l-table .caret-wrapper .ascending{border-bottom-color:var(--l-table-sort-inactive-color, #c0c4cc);top:-5px}.l-table .caret-wrapper .descending{border-top-color:var(--l-table-sort-inactive-color, #c0c4cc);bottom:-3px}.l-table .sort-caret{display:inline-block;width:0;height:0;border:5px solid transparent;position:absolute;border-radius:3px}.l-table .sort-column{cursor:pointer}.l-table .sort-asc .ascending{border-bottom-color:var(--l-primary-color, #52c41a)}.l-table .sort-desc .descending{border-top-color:var(--l-primary-color, #52c41a)}";
6
- class H extends p {
7
- static baseName = "table";
8
- /** 斑马纹 */
9
- stripe = !0;
10
- /** 是否显示四周边框 */
11
- border = !1;
12
- /** 是否固定表头 */
13
- fixedHead = !1;
14
- /** 是否固定列,在进行列解析时,会自动确认该属性 */
15
- fixedColumn = !1;
16
- /** 最大高度 */
17
- maxHeight;
18
- /** 表格布局 */
19
- tableLayout;
20
- columns = [];
21
- data = [];
22
- sortInfo;
23
- /** 缓存列通用样式, 避免渲染数据时,重复计算 */
24
- _globalColStyles;
25
- connectedCallback() {
26
- this.loadStyleText(m), super.connectedCallback();
27
- }
28
- setColumns(t) {
29
- let i = 0, e = 0;
30
- this.columns = this._parseColumns(t, i, e), this.rerender("all");
31
- }
32
- setData(t, i) {
33
- this.data = t, this.sortInfo = i, this.columns && this.columns.length > 0 && this.rerender(i ? "all" : "body");
34
- }
35
- changeFixed(t) {
36
- const i = {
37
- fixedHead: this.fixedHead,
38
- fixedColumn: this.fixedColumn,
39
- ...t
40
- };
41
- if (this.fixedHead = i.fixedHead, this.fixedColumn = i.fixedColumn, this.rendered) {
42
- const e = h(".l-table", this.root);
43
- e && (this.fixedHead || this.fixedColumn ? e.classList.add("l-table-fixed") : e.classList.remove("l-table-fixed"));
44
- }
45
- }
46
- static get observedAttributes() {
47
- return ["stripe", "border", "fixed-head", "max-height", "table-layout"];
48
- }
49
- attributeChangedCallback(t, i, e) {
50
- t = b(t);
51
- const s = x(
52
- e,
53
- this[t],
54
- t
55
- );
56
- if (s !== this[t])
57
- switch (this[t] = s, t) {
58
- case "stripe":
59
- this._classAttrChannge("stripe", s);
60
- break;
61
- case "border":
62
- this._classAttrChannge("border", s);
63
- break;
64
- case "fixedHead":
65
- this._updateFixedHead(), this.changeFixed();
66
- break;
67
- case "maxHeight":
68
- this._changeMaxHeight();
69
- break;
70
- case "tableLayout":
71
- this._changeCssVar("table-layout", s);
72
- break;
73
- }
74
- }
75
- render() {
76
- const t = d("table", {
77
- class: [
78
- "l-table",
79
- this.stripe ? "l-table-stripe" : "",
80
- this.border ? "l-table-border" : "",
81
- this.fixedHead || this.fixedColumn ? "l-table-fixed" : ""
82
- ]
83
- });
84
- return t.appendChild(this._headRender()), t.appendChild(this._bodyRender()), t;
85
- }
86
- rerender(t) {
87
- if (this.rendered) {
88
- if (t === "all" || t === "head") {
89
- const i = h("thead", this.root);
90
- i && i.replaceWith(this._headRender());
91
- }
92
- if (t === "all" || t === "body") {
93
- const i = h("tbody", this.root);
94
- i && i.replaceWith(this._bodyRender());
95
- }
96
- }
97
- }
98
- _changeCssVar(t, i) {
99
- if (!this.rendered) return;
100
- const e = `--l-table-${t}`;
101
- i ? this.style.setProperty(e, i) : this.style.removeProperty(e);
102
- }
103
- _changeMaxHeight() {
104
- let t = this.maxHeight;
105
- t && typeof t == "number" && (t = `${t}px`), this._changeCssVar("max-height", t);
106
- }
107
- _classAttrChannge(t, i) {
108
- if (this.rendered) {
109
- const e = h("table", this.root);
110
- e && e.classList.toggle(`l-table-${t}`, i);
111
- }
112
- }
113
- _updateFixedHead() {
114
- if (this.rendered) {
115
- const t = h("thead", this.root);
116
- t && (t.classList.toggle("l-fixed", this.fixedHead), t.style.top = this.fixedHead ? "0" : "");
117
- }
118
- }
119
- _headRender() {
120
- const t = d("thead", {
121
- class: {
122
- "l-fixed": this.fixedHead
123
- },
124
- style: {
125
- top: this.fixedHead ? "0" : void 0
126
- }
127
- });
128
- return this.columns && this._rendHeadRow(t, this.columns), t;
129
- }
130
- _rendHeadRow(t, i) {
131
- const e = d("tr");
132
- for (let s = 0, a = i.length; s < a; s++) {
133
- const r = i[s];
134
- e.appendChild(this._headColRender(r, s)), r.children && this._rendHeadRow(t, r.children);
135
- }
136
- t.appendChild(e);
137
- }
138
- _headColRender(t, i) {
139
- const e = d("th");
140
- if (t.titleColspan && t.titleColspan > 1 && (e.colSpan = t.titleColspan), t.titleRowspan && t.titleRowspan > 1 && (e.rowSpan = t.titleRowspan), e.style.cssText = this._getColumnStyle(t, "th"), t.fixed && e.classList.add("l-fixed"), e.appendChild(
141
- d("span", {
142
- textContent: t.title
143
- })
144
- ), t.sorter) {
145
- const s = d("span", { class: "caret-wrapper" });
146
- s.appendChild(d("span", { class: "sort-caret ascending" })), s.appendChild(d("span", { class: "sort-caret descending" })), e.classList.add("sort-column"), e.setAttribute("data-action", "sort"), e.setAttribute("data-col", `${i}`), e.appendChild(s);
147
- }
148
- return this.sortInfo && this.sortInfo.key === t.key && e.classList.add(this.sortInfo.order === "asc" ? "sort-asc" : "sort-desc"), e;
149
- }
150
- _bodyRender() {
151
- const t = d("tbody");
152
- if (this.data && this.data.length > 0)
153
- for (let i = 0, e = this.data.length; i < e; i++) {
154
- const s = this.data[i];
155
- if (this.columns) {
156
- const a = d("tr");
157
- this._bodyRowRender(this.columns, i, s, a), t.appendChild(a);
158
- }
159
- }
160
- else {
161
- const i = d("tr"), e = d("td", {
162
- class: "l-table__empty-col",
163
- textContent: "暂无数据"
164
- });
165
- this.columns && (e.colSpan = this.columns.length), i.appendChild(e), t.appendChild(i);
166
- }
167
- return t;
168
- }
169
- _bodyRowRender(t, i, e, s) {
170
- for (let a = 0, r = t.length; a < r; a++) {
171
- const l = t[a];
172
- if (l.children && l.children.length > 0)
173
- this._bodyRowRender(l.children, i, e, s);
174
- else {
175
- const o = d("td");
176
- if (typeof l.rowspan == "number" && (o.rowSpan = l.rowspan), typeof l.rowspan == "function" && (o.rowSpan = l.rowspan(e, i)), typeof l.colspan == "number" && (o.colSpan = l.colspan), typeof l.colspan == "function" && (o.colSpan = l.colspan(e, i)), l.fixed && (o.className = "l-fixed"), o.style.cssText = this._getColumnStyle(l), l.render) {
177
- const n = l.render(e, i);
178
- typeof n == "string" ? o.innerHTML = n : Array.isArray(n) ? g(n, (c) => {
179
- o.appendChild(c);
180
- }) : o.appendChild(n);
181
- } else
182
- o.textContent = l.key ? e[l.key] : "";
183
- s.appendChild(o);
184
- }
185
- }
186
- }
187
- /**
188
- * 解析列配置,表头跨行跨列、固定列
189
- * @param columns 列配置
190
- * @param leftOffset 左边固定列偏移
191
- * @param rightOffset 右边固定列偏移
192
- * @returns
193
- */
194
- _parseColumns(t, i, e) {
195
- const s = [];
196
- for (let a = 0, r = t.length; a < r; a++) {
197
- const l = t[a];
198
- if (l.id || (l.id = l.key || l.title), l.id || (l.id = `${a}_${_(6)}`), l.fixed) {
199
- const o = Number.parseFloat(`${l.width || 0}`);
200
- l.fixed === "left" ? (l.left = i, i += o) : l.fixed === "right" && (l.right = e, e += o);
201
- }
202
- if (l.children) {
203
- const o = this._parseColumns(
204
- l.children,
205
- i,
206
- e
207
- );
208
- l.titleRowspan = l.titleRowspan || 1, l.titleColspan || (l.titleColspan = o.reduce((n, c) => n + (c.titleColspan || 1), 0)), s.push({ ...l, children: o });
209
- } else
210
- l.titleRowspan = l.titleRowspan || this._getMaxDepth(t), l.titleColspan = l.titleColspan || 1, s.push({ ...l });
211
- }
212
- return s;
213
- }
214
- /**
215
- * 获取多级表头的最大深度
216
- * @param headers 表头配置
217
- * @returns 最大深度, 最大跨行数
218
- */
219
- _getMaxDepth(t) {
220
- let i = 1;
221
- for (const e of t)
222
- e.children && (i = Math.max(i, this._getMaxDepth(e.children) + 1));
223
- return i;
224
- }
225
- _getColumnStyle(t, i = "td") {
226
- const e = t.id;
227
- if (this._globalColStyles && e in this._globalColStyles)
228
- return this._globalColStyles[e][i];
229
- const s = {};
230
- t.width && (typeof t.width == "number" ? s.width = `${t.width}px` : s.width = t.width), t.fixed && (t.fixed === "left" ? (s.left = `${t.left}px`, s["box-shadow"] = "-4px 0 4px -4px #d9d9d9 inset") : t.fixed === "right" && (s.right = `${t.right}px`, s["box-shadow"] = "4px 0 4px -4px #d9d9d9 inset")), this._globalColStyles || (this._globalColStyles = {});
231
- const a = f(s), r = {
232
- th: a,
233
- td: a + f(t.style || "")
234
- };
235
- return this._globalColStyles[e] = r, r[i];
236
- }
237
- _handleTap = (t) => {
238
- const [i, e, s] = y(
239
- t,
240
- "data-action",
241
- t.currentTarget
242
- );
243
- if (i) {
244
- const a = s.dataset;
245
- if (e === "sort") {
246
- const r = parseInt(a.col), l = this.columns[r], o = this.sortInfo && this.sortInfo.order === "desc" ? "asc" : "desc";
247
- this.sortInfo = { key: l.key, order: o }, l.sorter === "custom" ? this.emit("sort", { detail: { index: r, key: l.key, dir: o } }) : (this.data = this._dataSort(), this.rerender("all"));
248
- } else
249
- this.emit(e, { detail: a });
250
- }
251
- };
252
- afterInit() {
253
- this._changeMaxHeight(), u(this.root, "click", this._handleTap);
254
- }
255
- beforeDestroy() {
256
- C(this.root, "click", this._handleTap);
257
- }
258
- _dataSort() {
259
- if (!this.sortInfo || !this.data) return;
260
- const { key: t, order: i } = this.sortInfo;
261
- return this.data.sort((e, s) => {
262
- const a = e[t], r = s[t];
263
- return i === "asc" ? a - r : r - a;
264
- });
265
- }
266
- }
267
- export {
268
- H as default
269
- };
1
+ import { t as e } from "../table-Hifj8jAX.js";
2
+ export { e as default };