litos-ui 0.17.5 → 0.18.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 (163) hide show
  1. package/lib/animation-CTt9qgA7.js +4 -0
  2. package/lib/base-Dm0WS1pK.js +62 -0
  3. package/lib/base.js +111 -147
  4. package/lib/button/index.d.ts +8 -3
  5. package/lib/button/index.js +2 -137
  6. package/lib/button-CC5PmAb1.js +146 -0
  7. package/lib/calendar/index.d.ts +10 -5
  8. package/lib/calendar/index.js +2 -123
  9. package/lib/calendar-GpYHNmXG.js +149 -0
  10. package/lib/carousel/index.js +2 -280
  11. package/lib/carousel/item.js +2 -15
  12. package/lib/carousel-dT3FJPQo.js +272 -0
  13. package/lib/check/checkbox.js +2 -18
  14. package/lib/check/checkbox_group.js +6 -6
  15. package/lib/check/radio.js +2 -15
  16. package/lib/check/radio_group.js +9 -9
  17. package/lib/check-B0XraJvb.js +73 -0
  18. package/lib/check-CvGaONEx.js +117 -0
  19. package/lib/checkbox-DbWsmAaL.js +16 -0
  20. package/lib/collapse/index.d.ts +18 -11
  21. package/lib/collapse/index.js +2 -88
  22. package/lib/collapse/item.d.ts +28 -9
  23. package/lib/collapse/item.js +2 -115
  24. package/lib/collapse/types.d.ts +7 -0
  25. package/lib/collapse-C3IRHLeg.js +104 -0
  26. package/lib/color_picker/index.js +2 -42
  27. package/lib/color_picker-D0brKFm-.js +41 -0
  28. package/lib/date_picker/index.d.ts +23 -0
  29. package/lib/date_picker/index.js +3 -0
  30. package/lib/date_picker-DQGoiN8v.js +103 -0
  31. package/lib/date_picker_ori/index.js +2 -129
  32. package/lib/date_picker_ori-aRuSSi9D.js +122 -0
  33. package/lib/description_panel/index.js +2 -66
  34. package/lib/description_panel-BY2yljeC.js +57 -0
  35. package/lib/dialog/dialog_container.js +2 -131
  36. package/lib/dialog/index.js +67 -85
  37. package/lib/dialog_container-DcN87wj0.js +126 -0
  38. package/lib/esm-sVEoAVPu.js +244 -0
  39. package/lib/form/form_item.d.ts +1 -0
  40. package/lib/form/form_item.js +2 -136
  41. package/lib/form/index.js +2 -147
  42. package/lib/form-DdU0yK0k.js +154 -0
  43. package/lib/form_inner-DR9tyB_r.js +117 -0
  44. package/lib/form_item-Bv-YafZK.js +137 -0
  45. package/lib/icon/arrow_down.js +12 -12
  46. package/lib/icon/arrow_left.js +9 -9
  47. package/lib/icon/arrow_right.js +9 -9
  48. package/lib/icon/arrow_up.js +12 -12
  49. package/lib/icon/base.d.ts +16 -2
  50. package/lib/icon/base.js +2 -38
  51. package/lib/icon/calendar.d.ts +5 -0
  52. package/lib/icon/calendar.js +10 -0
  53. package/lib/icon/caret_bottom.js +9 -9
  54. package/lib/icon/caret_top.js +9 -9
  55. package/lib/icon/close.js +9 -9
  56. package/lib/icon/close_filled.js +12 -12
  57. package/lib/icon/d_arrow_left.js +12 -12
  58. package/lib/icon/d_arrow_right.js +12 -12
  59. package/lib/icon/font_icon.d.ts +2 -3
  60. package/lib/icon/font_icon.js +35 -39
  61. package/lib/icon/info.js +12 -12
  62. package/lib/icon/loading.js +9 -9
  63. package/lib/icon/moon.js +12 -12
  64. package/lib/icon/more.js +12 -12
  65. package/lib/icon/reduction.js +12 -12
  66. package/lib/icon/refresh.d.ts +5 -0
  67. package/lib/icon/refresh.js +10 -0
  68. package/lib/icon/refresh_left.js +12 -12
  69. package/lib/icon/refresh_right.js +9 -9
  70. package/lib/icon/search.js +9 -9
  71. package/lib/icon/select.js +12 -12
  72. package/lib/icon/sort.js +9 -9
  73. package/lib/icon/success.js +12 -12
  74. package/lib/icon/sun.js +12 -12
  75. package/lib/icon/theme_default.js +12 -12
  76. package/lib/icon/warn.js +12 -12
  77. package/lib/icon/zoom_in.js +12 -12
  78. package/lib/icon/zoom_out.js +12 -12
  79. package/lib/image/image_preview.js +2 -104
  80. package/lib/image/index.js +2 -176
  81. package/lib/image-COPKk8Jm.js +162 -0
  82. package/lib/image_preview-CYEup07F.js +92 -0
  83. package/lib/index.d.ts +5 -81
  84. package/lib/index.js +78 -169
  85. package/lib/input/index.d.ts +6 -2
  86. package/lib/input/index.js +188 -203
  87. package/lib/input-DjKxcxry.js +4 -0
  88. package/lib/input_inner-BKJg9n9A.js +4 -0
  89. package/lib/item-B7Elh5xE.js +14 -0
  90. package/lib/item-CvoJt3wp.js +60 -0
  91. package/lib/item-DRsOV_Tc.js +119 -0
  92. package/lib/list/index.js +2 -58
  93. package/lib/list-CU7vHS6s.js +51 -0
  94. package/lib/loading/index.d.ts +3 -2
  95. package/lib/loading/index.js +109 -127
  96. package/lib/mask/index.js +2 -105
  97. package/lib/mask-CEznzwji.js +112 -0
  98. package/lib/md_input/index.js +2 -60
  99. package/lib/md_input-DSQx5TMW.js +58 -0
  100. package/lib/menu/index.d.ts +30 -13
  101. package/lib/menu/index.js +2 -105
  102. package/lib/menu/types.d.ts +6 -0
  103. package/lib/menu/types.js +0 -0
  104. package/lib/menu-CzV6lOlw.js +224 -0
  105. package/lib/message/index.js +67 -60
  106. package/lib/modal/index.js +2 -196
  107. package/lib/modal/modal_box.js +87 -86
  108. package/lib/modal-DWyWrN-D.js +192 -0
  109. package/lib/page_header/index.js +2 -109
  110. package/lib/page_header-BJkEstRw.js +101 -0
  111. package/lib/pagination/index.js +2 -248
  112. package/lib/pagination-5t7AOeFV.js +210 -0
  113. package/lib/polygon/index.js +2 -27
  114. package/lib/polygon-C4Ow2lxi.js +20 -0
  115. package/lib/qrcode/index.d.ts +13 -4
  116. package/lib/qrcode/index.js +2 -57
  117. package/lib/qrcode-BKG2MibP.js +64 -0
  118. package/lib/radio-2mNSYujz.js +13 -0
  119. package/lib/select/index.js +3 -401
  120. package/lib/select-CAgggYh7.js +326 -0
  121. package/lib/select_ori/index.js +47 -50
  122. package/lib/space/index.js +2 -35
  123. package/lib/space-Bv-p0DL8.js +38 -0
  124. package/lib/switch/index.js +2 -50
  125. package/lib/switch-BaVBi5Ip.js +48 -0
  126. package/lib/tabbar/index.js +2 -109
  127. package/lib/tabbar/item.js +2 -58
  128. package/lib/tabbar-CI1xSj1G.js +96 -0
  129. package/lib/table/index.js +2 -269
  130. package/lib/table-DfL2hFqA.js +234 -0
  131. package/lib/tabs/index.js +38 -42
  132. package/lib/tag/index.js +2 -72
  133. package/lib/tag-72DwCkvq.js +76 -0
  134. package/lib/theme/index.js +2 -89
  135. package/lib/theme/theme_color.js +22 -26
  136. package/lib/theme-BRTI2-Yk.js +83 -0
  137. package/lib/utils/clickoutside.js +18 -18
  138. package/lib/utils/context_provide.js +21 -21
  139. package/lib/utils/event.js +13 -18
  140. package/lib/utils/index.js +55 -58
  141. package/lib/utils/popover.d.ts +4 -1
  142. package/lib/utils/popover.js +276 -352
  143. package/lib/utils/transition.js +33 -31
  144. package/package.json +14 -14
  145. package/styles/container.css +4 -0
  146. package/styles/datepicker.css +55 -0
  147. package/styles/popover.css +14 -1
  148. package/lib/animation-DttknHkX.js +0 -4
  149. package/lib/calendar/langs.js +0 -8
  150. package/lib/carousel/timer.js +0 -19
  151. package/lib/check/check.js +0 -118
  152. package/lib/check/index.js +0 -68
  153. package/lib/check-CksURvTv.js +0 -4
  154. package/lib/form/form_inner.js +0 -125
  155. package/lib/form/types.js +0 -1
  156. package/lib/index-CrMiSe0x.js +0 -249
  157. package/lib/index-DY6m9Wbe.js +0 -4
  158. package/lib/litos-ui.css +0 -1
  159. package/lib/menu/menu_item.d.ts +0 -6
  160. package/lib/menu/menu_item.js +0 -21
  161. package/lib/menu/sub_menu.d.ts +0 -15
  162. package/lib/menu/sub_menu.js +0 -83
  163. package/lib/table/types.js +0 -1
@@ -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-CI1xSj1G.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-CvoJt3wp.js";
2
+ export { e as default };
@@ -0,0 +1,96 @@
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") {
31
+ let e = t(i, void 0);
32
+ this.name = e, this._updateActive(), this._updateLine();
33
+ } else if (e === "type") {
34
+ let e = t(i, "nav");
35
+ if (e !== this.type && (l(this, `l-tabbar--${this.type}`), this.type = e, l(this, `l-tabbar--${e}`), e === "card")) {
36
+ let e = r(".l-tabbar-card-border", this.root);
37
+ e || (e = a("div", { class: "l-tabbar-card-border" }), this.root.appendChild(e));
38
+ }
39
+ } else {
40
+ let n = t(i, void 0);
41
+ this[e] = n, this.#e();
42
+ }
43
+ }
44
+ render() {
45
+ let e = document.createDocumentFragment();
46
+ if (e.appendChild(n("slot")), this.type === "card") {
47
+ let t = a("div", { class: "l-tabbar-card-border" });
48
+ e.appendChild(t);
49
+ }
50
+ return e;
51
+ }
52
+ afterInit() {
53
+ c(this.root, "click", this._handleClick), setTimeout(() => {
54
+ this._updateLine();
55
+ }, 300);
56
+ }
57
+ beforeDestroy() {
58
+ s(this.root, "click", this._handleClick), this.$line = void 0;
59
+ }
60
+ _handleClick = (e) => {
61
+ let [t, n] = u(e, "name", this);
62
+ t && n !== this.name && (this.name = n, this.dispatchEvent(new CustomEvent("change", { detail: { name: n } })), this._updateActive(), this._updateLine());
63
+ };
64
+ _updateActive() {
65
+ let e = r(".active", this);
66
+ e && l(e, "active");
67
+ let t = r(`[name="${this.name}"]`, this);
68
+ t && i(t, "active");
69
+ }
70
+ _updateLine() {
71
+ queueMicrotask(() => {
72
+ if (!this.name || this.type === "nav" || !this.rendered) return;
73
+ let e = r(".active", this);
74
+ if (!e) return;
75
+ let t = e.offsetLeft;
76
+ if (!this.$line) {
77
+ let e = a("div", { class: "l-tabbar--bar-line" });
78
+ e.part = "line", this.root.appendChild(e), this.$line = r(".l-tabbar--bar-line", this.root);
79
+ }
80
+ this.$line.style.cssText = `width:${e.offsetWidth}px;left:${t}px`, o(e, this) || this.scrollTo({
81
+ left: t,
82
+ behavior: "smooth"
83
+ });
84
+ });
85
+ }
86
+ #e() {
87
+ let e = this.getAttr("justify-content");
88
+ 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");
89
+ else {
90
+ let e = this.gap;
91
+ f(e, { isPositive: !0 }) && (e = `${e}px`), i(this, "l-tabbar-gap"), this.style.setProperty("--l-tabbar-item-gap", e);
92
+ }
93
+ }
94
+ };
95
+ //#endregion
96
+ 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-DfL2hFqA.js";
2
+ export { e as default };