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
@@ -1,109 +1,2 @@
1
- import h from "../base.js";
2
- import { kebabToCamel as n, parseAttrValue as d } from "../utils/index.js";
3
- import { $$ as a, shouldEventNext as p, on as g, off as c } from "ph-utils/dom";
4
- import { isBlank as r } from "ph-utils";
5
- const f = ":host{display:block;box-sizing:border-box;display:flex;position:relative;align-items:center;height:var(--l-page-header-height, auto)}.l-page-header-left,.l-page-header-right{display:flex;align-items:center;flex:0 0 auto;z-index:1}.l-page-header-back{height:auto}.l-page-header-back::part(default){--l-btn-padding: 5px 0}.l-page-header-content{display:flex;align-items:center;line-height:1}.l-page-header-title{font-size:16px;font-weight:600}.l-page-header-sub-title{font-size:14px;font-weight:500;color:#999;margin-left:10px}:host(.l-page-header-align-left) .l-page-header-left{margin-right:15px}:host(.l-page-header-align-left) .l-page-header-content{flex:1 0 auto}:host(.l-page-header-align-left) .l-page-header-right{margin-left:15px}:host(.l-page-header-align-center){justify-content:space-between}:host(.l-page-header-align-center) .l-page-header-content{position:absolute;inset:0;justify-content:center}:host(.l-page-header-align-center) .l-page-header-back::part(default){--l-btn-padding: 8px 0;--l-btn-gap: 0}:host(.l-page-header-border){border-bottom:1px solid var(--l-border-color, #dedede)}";
6
- class w extends h {
7
- static baseName = "page-header";
8
- showLeft = !0;
9
- showBack = !0;
10
- backText = "返回";
11
- pageTitle;
12
- pageSubTitle;
13
- align = "left";
14
- showRight = !0;
15
- border = !1;
16
- height;
17
- connectedCallback() {
18
- this.loadStyleText(f), this.classList.add(`l-page-header-align-${this.align}`), super.connectedCallback();
19
- }
20
- static get observedAttributes() {
21
- return [
22
- "show-left",
23
- "show-back",
24
- "back-text",
25
- "page-title",
26
- "page-sub-title",
27
- "align",
28
- "show-right",
29
- "border",
30
- "height"
31
- ];
32
- }
33
- attributeChangedCallback(t, i, l) {
34
- t = n(t);
35
- const e = d(
36
- l,
37
- this[t],
38
- t
39
- );
40
- switch (e !== this[t] && (this[t] = e), t) {
41
- case "border":
42
- e ? this.classList.add("l-page-header-border") : this.classList.remove("l-page-header-border");
43
- break;
44
- case "height":
45
- e && this.style.setProperty("--l-page-header-height", e);
46
- break;
47
- }
48
- }
49
- render() {
50
- const t = document.createDocumentFragment();
51
- if (this.showLeft) {
52
- const e = a("div", { class: "l-page-header-left" });
53
- if (this.showBack) {
54
- const o = a("l-button", {
55
- text: !0,
56
- class: "l-page-header-back",
57
- "l-action": "back",
58
- innerHTML: `<l-arrow-left-icon></l-arrow-left-icon><span>${this.backText}</span>`
59
- });
60
- e.appendChild(o);
61
- }
62
- const s = a("slot", { name: "left" });
63
- e.appendChild(s), t.appendChild(e);
64
- }
65
- const i = a("div", {
66
- class: "l-page-header-content"
67
- });
68
- if (!r(this.pageTitle)) {
69
- const e = a("div", {
70
- class: "l-page-header-title",
71
- innerHTML: this.pageTitle
72
- });
73
- i.appendChild(e);
74
- }
75
- if (!r(this.pageSubTitle)) {
76
- const e = a("div", {
77
- class: "l-page-header-sub-title",
78
- innerHTML: this.pageSubTitle
79
- });
80
- i.appendChild(e);
81
- }
82
- const l = a("slot");
83
- if (i.appendChild(l), t.appendChild(i), this.showRight) {
84
- const e = a("div", { class: "l-page-header-right" }), s = a("slot", { name: "right" });
85
- e.appendChild(s), t.appendChild(e);
86
- }
87
- return t;
88
- }
89
- #e = (t) => {
90
- const [i, l, e] = p(
91
- t,
92
- "l-action",
93
- this.root
94
- );
95
- if (i) {
96
- const s = e.dataset;
97
- this.emit("action", { detail: { action: l, ...s } });
98
- }
99
- };
100
- afterInit() {
101
- g(this.root, "click", this.#e);
102
- }
103
- beforeDestroy() {
104
- c(this.root, "click", this.#e);
105
- }
106
- }
107
- export {
108
- w as default
109
- };
1
+ import { t as e } from "../page_header-DdeRDN4U.js";
2
+ export { e as default };
@@ -0,0 +1,101 @@
1
+ import e from "./base.js";
2
+ import { kebabToCamel as t, parseAttrValue as n } from "./utils/index.js";
3
+ import { $$ as r, off as i, on as a, shouldEventNext as o } from "ph-utils/dom";
4
+ import { isBlank as s } from "ph-utils";
5
+ //#region src/components/page_header/index.less?inline
6
+ var c = ":host{box-sizing:border-box;height:var(--l-page-header-height,auto);align-items:center;display:flex;position:relative}.l-page-header-left,.l-page-header-right{z-index:1;flex:none;align-items:center;display:flex}.l-page-header-back{height:auto}.l-page-header-back::part(default){--l-btn-padding:5px 0}.l-page-header-content{align-items:center;line-height:1;display:flex}.l-page-header-title{font-size:16px;font-weight:600}.l-page-header-sub-title{color:#999;margin-left:10px;font-size:14px;font-weight:500}:host(.l-page-header-align-left) .l-page-header-left{margin-right:15px}:host(.l-page-header-align-left) .l-page-header-content{flex:1 0 auto}:host(.l-page-header-align-left) .l-page-header-right{margin-left:15px}:host(.l-page-header-align-center){justify-content:space-between}:host(.l-page-header-align-center) .l-page-header-content{justify-content:center;position:absolute;inset:0}:host(.l-page-header-align-center) .l-page-header-back::part(default){--l-btn-padding:8px 0;--l-btn-gap:0}:host(.l-page-header-border){border-bottom:1px solid var(--l-border-color,#dedede)}", l = class extends e {
7
+ static baseName = "page-header";
8
+ showLeft = !0;
9
+ showBack = !0;
10
+ backText = "返回";
11
+ pageTitle;
12
+ pageSubTitle;
13
+ align = "left";
14
+ showRight = !0;
15
+ border = !1;
16
+ height;
17
+ connectedCallback() {
18
+ this.loadStyleText(c), this.classList.add(`l-page-header-align-${this.align}`), super.connectedCallback();
19
+ }
20
+ static get observedAttributes() {
21
+ return [
22
+ "show-left",
23
+ "show-back",
24
+ "back-text",
25
+ "page-title",
26
+ "page-sub-title",
27
+ "align",
28
+ "show-right",
29
+ "border",
30
+ "height"
31
+ ];
32
+ }
33
+ attributeChangedCallback(e, r, i) {
34
+ e = t(e);
35
+ let a = n(i, this[e], e);
36
+ switch (a !== this[e] && (this[e] = a), e) {
37
+ case "border":
38
+ a ? this.classList.add("l-page-header-border") : this.classList.remove("l-page-header-border");
39
+ break;
40
+ case "height":
41
+ a && this.style.setProperty("--l-page-header-height", a);
42
+ break;
43
+ }
44
+ }
45
+ render() {
46
+ let e = document.createDocumentFragment();
47
+ if (this.showLeft) {
48
+ let t = r("div", { class: "l-page-header-left" });
49
+ if (this.showBack) {
50
+ let e = r("l-button", {
51
+ text: !0,
52
+ class: "l-page-header-back",
53
+ "l-action": "back",
54
+ innerHTML: `<l-arrow-left-icon></l-arrow-left-icon><span>${this.backText}</span>`
55
+ });
56
+ t.appendChild(e);
57
+ }
58
+ let n = r("slot", { name: "left" });
59
+ t.appendChild(n), e.appendChild(t);
60
+ }
61
+ let t = r("div", { class: "l-page-header-content" });
62
+ if (!s(this.pageTitle)) {
63
+ let e = r("div", {
64
+ class: "l-page-header-title",
65
+ innerHTML: this.pageTitle
66
+ });
67
+ t.appendChild(e);
68
+ }
69
+ if (!s(this.pageSubTitle)) {
70
+ let e = r("div", {
71
+ class: "l-page-header-sub-title",
72
+ innerHTML: this.pageSubTitle
73
+ });
74
+ t.appendChild(e);
75
+ }
76
+ let n = r("slot");
77
+ if (t.appendChild(n), e.appendChild(t), this.showRight) {
78
+ let t = r("div", { class: "l-page-header-right" }), n = r("slot", { name: "right" });
79
+ t.appendChild(n), e.appendChild(t);
80
+ }
81
+ return e;
82
+ }
83
+ #e = (e) => {
84
+ let [t, n, r] = o(e, "l-action", this.root);
85
+ if (t) {
86
+ let e = r.dataset;
87
+ this.emit("action", { detail: {
88
+ action: n,
89
+ ...e
90
+ } });
91
+ }
92
+ };
93
+ afterInit() {
94
+ a(this.root, "click", this.#e);
95
+ }
96
+ beforeDestroy() {
97
+ i(this.root, "click", this.#e);
98
+ }
99
+ };
100
+ //#endregion
101
+ export { l as t };
@@ -1,248 +1,2 @@
1
- import c from "../base.js";
2
- import { kebabToCamel as p, parseAttrValue as h, tagAttr as g } from "../utils/index.js";
3
- import { $one as r, on as s, off as l, shouldEventNext as u, formatClass as d } from "ph-utils/dom";
4
- const m = ":host{white-space:nowrap;font-size:14px;line-height:1;color:#333}.l-pagination{display:flex;align-items:center;justify-content:var(--l-pagination-justify-content, flex-start)}.l-pagination-item{width:30px;height:30px;box-sizing:border-box}.l-pagination-item+.l-pagination-item{margin-left:5px}.l-pagination--btn{--l-btn-padding: 0}.l-pagination--link{display:inline-flex;justify-content:center;align-items:center;text-decoration:none;transition:color .3s,border-color .3s;border:1px solid transparent;border-radius:3px;color:#666;cursor:pointer}.l-pagination--link.active{color:var(--l-primary-color, #722ed1);border-color:var(--l-primary-color, #722ed1)}.darrow-icon{display:none}.more-icon{display:inline-block}.l-pagination--link:hover{color:var(--l-primary-color-light1, #9254de)}.l-pagination--link:hover .darrow-icon{display:inline-block}.l-pagination--link:hover .more-icon{display:none}.l-pagination--link:active{color:var(--l-primary-color-light1, #9254de)}.l-pagination-simple-layout{display:inline-flex;align-items:center;width:auto}.l-pagination-simple-input{--l-form-control-height: 30px;box-sizing:border-box;width:60px;text-align:center}.l-pagination-simple-divide{margin:0 5px}";
5
- class k extends c {
6
- static baseName = "pagination";
7
- /** 数据总数 */
8
- total;
9
- /** 总页数 */
10
- pageCount;
11
- /** 每页显示条目个数 */
12
- pageSize = 10;
13
- /** 对齐方式 */
14
- align;
15
- /** 是否为简单分页 */
16
- simple = !1;
17
- /** 单页隐藏 */
18
- hideOnSinglePage = !1;
19
- /** 当前页码 */
20
- #e = 1;
21
- /** 总页数 */
22
- #t = 0;
23
- get current() {
24
- return this.#e;
25
- }
26
- set current(t) {
27
- this.setCurrent(t);
28
- }
29
- setCurrent(t) {
30
- t !== this.#e && (this.#e = t, this.rerender());
31
- }
32
- connectedCallback() {
33
- this.loadStyleText(m), super.connectedCallback();
34
- }
35
- static get observedAttributes() {
36
- return [
37
- "align",
38
- "current",
39
- "page-count",
40
- "total",
41
- "hide-on-single-page",
42
- "simple"
43
- ];
44
- }
45
- attributeChangedCallback(t, e, n) {
46
- t = p(t);
47
- const i = h(
48
- n,
49
- this[t],
50
- t
51
- );
52
- if (i !== this[t])
53
- switch (this[t] = i, t) {
54
- case "align":
55
- this.style.setProperty(
56
- "--l-pagination-justify-content",
57
- i === "center" ? i : `flex-${i}`
58
- );
59
- break;
60
- case "total":
61
- case "page-count":
62
- this.#t = this.#c();
63
- break;
64
- case "simple":
65
- case "hide-on-single-page":
66
- this.rendered && this.rerender();
67
- break;
68
- }
69
- }
70
- rerender() {
71
- const t = r(".l-pagination", this.root);
72
- t && (this.#s(), t.innerHTML = this.#a(), this.#r());
73
- }
74
- render() {
75
- return `<div class="l-pagination">${this.#a()}</div>`;
76
- }
77
- afterInit() {
78
- s(this.root, "click", this.#n), this.#r();
79
- }
80
- beforeDestroy() {
81
- l(this.root, "click", this.#n), this.#s();
82
- }
83
- #n = (t) => {
84
- const [e, n] = u(t, "data-page", this.root);
85
- if (e) {
86
- let i = Number(n);
87
- i = Math.min(this.#t, Math.max(1, i)), i !== this.current && (this.setCurrent(i), this.emit("change", {
88
- detail: {
89
- current: i,
90
- pageSize: this.pageSize || 10,
91
- totalPage: this.#t
92
- }
93
- }));
94
- }
95
- };
96
- #c() {
97
- let t = this.pageCount;
98
- return t == null && this.total != null && (t = Math.ceil(this.total / (this.pageSize || 10))), (t == null || t <= 0) && (t = 1), t;
99
- }
100
- #a() {
101
- if (this.#t <= 1) return "";
102
- const t = [];
103
- if (t.push(
104
- this.#i("l-button", {
105
- title: "上一页",
106
- disabled: this.current === 1,
107
- "data-page": this.current - 1,
108
- innerHTML: "<l-arrow-left-icon></l-arrow-left-icon>",
109
- class: ["l-pagination-item", "l-pagination--btn", "prev-btn"]
110
- })
111
- ), this.simple)
112
- t.push(
113
- this.#i("div", {
114
- class: ["l-pagination-item", "l-pagination-simple-layout"],
115
- innerHTML: [
116
- this.#i("l-input", {
117
- inputmode: "numeric",
118
- value: `${this.current}`,
119
- class: ["l-pagination-simple-input"],
120
- "allow-input": "integer"
121
- }),
122
- '<span class="l-pagination-simple-divide">/</span>',
123
- `<span>${this.#t}</span>`
124
- ]
125
- })
126
- );
127
- else {
128
- t.push(
129
- this.#i("a", {
130
- title: "1",
131
- innerHTML: "1",
132
- class: [
133
- "l-pagination-item",
134
- "l-pagination--link",
135
- this.current === 1 ? "active" : ""
136
- ],
137
- "data-page": "1"
138
- })
139
- ), this.current > 4 && t.push(
140
- this.#i("a", {
141
- title: "上5页",
142
- innerHTML: [
143
- "<l-d-arrow-left-icon class='darrow-icon'></l-d-arrow-left-icon>",
144
- "<l-more-icon class='more-icon'></l-more-icon>"
145
- ],
146
- class: ["l-pagination-item", "l-pagination--link"],
147
- "data-page": `${this.current - 5}`
148
- })
149
- );
150
- let e = Math.max(this.current - 2, 1), n = Math.min(this.current + 2, this.#t), i = n - e;
151
- i < 4 && (n = Math.min(this.#t, n + i)), i = n - e, i < 4 && (e = Math.max(1, e - i));
152
- for (let a = e; a <= n; a++)
153
- if (!(a <= 1)) {
154
- if (a >= this.#t) break;
155
- t.push(
156
- this.#i("a", {
157
- title: `${a}`,
158
- innerHTML: `${a}`,
159
- class: [
160
- "l-pagination-item",
161
- "l-pagination--link",
162
- this.current === a ? "active" : ""
163
- ],
164
- "data-page": `${a}`
165
- })
166
- );
167
- }
168
- this.current < this.#t - 3 && t.push(
169
- this.#i("a", {
170
- title: "下5页",
171
- innerHTML: [
172
- "<l-d-arrow-right-icon class='darrow-icon'></l-d-arrow-right-icon>",
173
- "<l-more-icon class='more-icon'></l-more-icon>"
174
- ],
175
- class: ["l-pagination-item", "l-pagination--link"],
176
- "data-page": `${this.current + 5}`
177
- })
178
- ), this.#t > 1 && t.push(
179
- this.#i("a", {
180
- title: `${this.#t}`,
181
- innerHTML: `${this.#t}`,
182
- class: [
183
- "l-pagination-item",
184
- "l-pagination--link",
185
- this.current === this.#t ? "active" : ""
186
- ],
187
- "data-page": `${this.#t}`
188
- })
189
- );
190
- }
191
- return t.push(
192
- this.#i("l-button", {
193
- title: `${this.current + 1}`,
194
- innerHTML: "<l-arrow-right-icon></l-arrow-right-icon>",
195
- class: ["l-pagination-item", "l-pagination--btn", "next-btn"],
196
- disabled: this.current === this.#t,
197
- "data-page": `${this.current + 1}`
198
- })
199
- ), t.join("");
200
- }
201
- #r() {
202
- const t = r(".l-pagination-simple-input", this.root);
203
- t && (t.setParser(this.#p), s(t, "keyup", this.#o), s(t, "blur", this.#l));
204
- }
205
- #s() {
206
- const t = r(".l-pagination-simple-input", this.root);
207
- t && (t.setParser(void 0), l(t, "keyup", this.#o), l(t, "blur", this.#l));
208
- }
209
- #l = (t) => {
210
- const e = t.target, n = e.value;
211
- if (!n) {
212
- e.value = `${this.current}`;
213
- return;
214
- }
215
- this.setCurrent(Number(n));
216
- };
217
- #o = (t) => {
218
- if (t.key === "Enter") {
219
- const n = t.target.value;
220
- if (n) {
221
- const i = Number(n);
222
- this.setCurrent(i);
223
- }
224
- }
225
- };
226
- #p = (t) => {
227
- if (t) {
228
- let e = Number(t);
229
- e = Math.max(1, Math.min(this.#t, e)), t = String(e);
230
- }
231
- return t;
232
- };
233
- #i(t = "a", e) {
234
- let n = [], i = "";
235
- for (const a in e)
236
- if (a === "innerHTML")
237
- i = e[a], Array.isArray(i) && (i = i.join(""));
238
- else if (a === "class") {
239
- const o = e.class;
240
- n.push(` class="${d(o)}"`);
241
- } else
242
- n.push(g(a, e[a]));
243
- return `<${t}${n.join("")}>${i}</${t}>`;
244
- }
245
- }
246
- export {
247
- k as default
248
- };
1
+ import { t as e } from "../pagination-BoPzSPjT.js";
2
+ export { e as default };
@@ -0,0 +1,210 @@
1
+ import e from "./base.js";
2
+ import { kebabToCamel as t, parseAttrValue as n, tagAttr as r } from "./utils/index.js";
3
+ import { $one as i, formatClass as a, off as o, on as s, shouldEventNext as c } from "ph-utils/dom";
4
+ //#region src/components/pagination/index.less?inline
5
+ var l = ":host{white-space:nowrap;color:#333;font-size:14px;line-height:1}.l-pagination{align-items:center;justify-content:var(--l-pagination-justify-content,flex-start);display:flex}.l-pagination-item{box-sizing:border-box;width:30px;height:30px}.l-pagination-item+.l-pagination-item{margin-left:5px}.l-pagination--btn{--l-btn-padding:0}.l-pagination--link{color:#666;cursor:pointer;border:1px solid #0000;border-radius:3px;justify-content:center;align-items:center;text-decoration:none;transition:color .3s,border-color .3s;display:inline-flex}.l-pagination--link.active{color:var(--l-primary-color,#722ed1);border-color:var(--l-primary-color,#722ed1)}.darrow-icon{display:none}.more-icon{display:inline-block}.l-pagination--link:hover{color:var(--l-primary-color-light1,#9254de)}.l-pagination--link:hover .darrow-icon{display:inline-block}.l-pagination--link:hover .more-icon{display:none}.l-pagination--link:active{color:var(--l-primary-color-light1,#9254de)}.l-pagination-simple-layout{align-items:center;width:auto;display:inline-flex}.l-pagination-simple-input{--l-form-control-height:30px;box-sizing:border-box;text-align:center;width:60px}.l-pagination-simple-divide{margin:0 5px}", u = class extends e {
6
+ static baseName = "pagination";
7
+ total;
8
+ pageCount;
9
+ pageSize = 10;
10
+ align;
11
+ simple = !1;
12
+ hideOnSinglePage = !1;
13
+ #e = 1;
14
+ #t = 0;
15
+ get current() {
16
+ return this.#e;
17
+ }
18
+ set current(e) {
19
+ this.setCurrent(e);
20
+ }
21
+ setCurrent(e) {
22
+ e !== this.#e && (this.#e = e, this.rerender());
23
+ }
24
+ connectedCallback() {
25
+ this.loadStyleText(l), super.connectedCallback();
26
+ }
27
+ static get observedAttributes() {
28
+ return [
29
+ "align",
30
+ "current",
31
+ "page-count",
32
+ "total",
33
+ "hide-on-single-page",
34
+ "simple"
35
+ ];
36
+ }
37
+ attributeChangedCallback(e, r, i) {
38
+ e = t(e);
39
+ let a = n(i, this[e], e);
40
+ if (a !== this[e]) switch (this[e] = a, e) {
41
+ case "align":
42
+ this.style.setProperty("--l-pagination-justify-content", a === "center" ? a : `flex-${a}`);
43
+ break;
44
+ case "total":
45
+ case "page-count":
46
+ this.#t = this.#r();
47
+ break;
48
+ case "simple":
49
+ case "hide-on-single-page":
50
+ this.rendered && this.rerender();
51
+ break;
52
+ }
53
+ }
54
+ rerender() {
55
+ let e = i(".l-pagination", this.root);
56
+ e && (this.#o(), e.innerHTML = this.#i(), this.#a());
57
+ }
58
+ render() {
59
+ return `<div class="l-pagination">${this.#i()}</div>`;
60
+ }
61
+ afterInit() {
62
+ s(this.root, "click", this.#n), this.#a();
63
+ }
64
+ beforeDestroy() {
65
+ o(this.root, "click", this.#n), this.#o();
66
+ }
67
+ #n = (e) => {
68
+ let [t, n] = c(e, "data-page", this.root);
69
+ if (t) {
70
+ let e = Number(n);
71
+ e = Math.min(this.#t, Math.max(1, e)), e !== this.current && (this.setCurrent(e), this.emit("change", { detail: {
72
+ current: e,
73
+ pageSize: this.pageSize || 10,
74
+ totalPage: this.#t
75
+ } }));
76
+ }
77
+ };
78
+ #r() {
79
+ let e = this.pageCount;
80
+ return e == null && this.total != null && (e = Math.ceil(this.total / (this.pageSize || 10))), (e == null || e <= 0) && (e = 1), e;
81
+ }
82
+ #i() {
83
+ if (this.#t <= 1) return "";
84
+ let e = [];
85
+ if (e.push(this.#u("l-button", {
86
+ title: "上一页",
87
+ disabled: this.current === 1,
88
+ "data-page": this.current - 1,
89
+ innerHTML: "<l-arrow-left-icon></l-arrow-left-icon>",
90
+ class: [
91
+ "l-pagination-item",
92
+ "l-pagination--btn",
93
+ "prev-btn"
94
+ ]
95
+ })), this.simple) e.push(this.#u("div", {
96
+ class: ["l-pagination-item", "l-pagination-simple-layout"],
97
+ innerHTML: [
98
+ this.#u("l-input", {
99
+ inputmode: "numeric",
100
+ value: `${this.current}`,
101
+ class: ["l-pagination-simple-input"],
102
+ "allow-input": "integer"
103
+ }),
104
+ "<span class=\"l-pagination-simple-divide\">/</span>",
105
+ `<span>${this.#t}</span>`
106
+ ]
107
+ }));
108
+ else {
109
+ e.push(this.#u("a", {
110
+ title: "1",
111
+ innerHTML: "1",
112
+ class: [
113
+ "l-pagination-item",
114
+ "l-pagination--link",
115
+ this.current === 1 ? "active" : ""
116
+ ],
117
+ "data-page": "1"
118
+ })), this.current > 4 && e.push(this.#u("a", {
119
+ title: "上5页",
120
+ innerHTML: ["<l-d-arrow-left-icon class='darrow-icon'></l-d-arrow-left-icon>", "<l-more-icon class='more-icon'></l-more-icon>"],
121
+ class: ["l-pagination-item", "l-pagination--link"],
122
+ "data-page": `${this.current - 5}`
123
+ }));
124
+ let t = Math.max(this.current - 2, 1), n = Math.min(this.current + 2, this.#t), r = n - t;
125
+ r < 4 && (n = Math.min(this.#t, n + r)), r = n - t, r < 4 && (t = Math.max(1, t - r));
126
+ for (let r = t; r <= n; r++) if (!(r <= 1)) {
127
+ if (r >= this.#t) break;
128
+ e.push(this.#u("a", {
129
+ title: `${r}`,
130
+ innerHTML: `${r}`,
131
+ class: [
132
+ "l-pagination-item",
133
+ "l-pagination--link",
134
+ this.current === r ? "active" : ""
135
+ ],
136
+ "data-page": `${r}`
137
+ }));
138
+ }
139
+ this.current < this.#t - 3 && e.push(this.#u("a", {
140
+ title: "下5页",
141
+ innerHTML: ["<l-d-arrow-right-icon class='darrow-icon'></l-d-arrow-right-icon>", "<l-more-icon class='more-icon'></l-more-icon>"],
142
+ class: ["l-pagination-item", "l-pagination--link"],
143
+ "data-page": `${this.current + 5}`
144
+ })), this.#t > 1 && e.push(this.#u("a", {
145
+ title: `${this.#t}`,
146
+ innerHTML: `${this.#t}`,
147
+ class: [
148
+ "l-pagination-item",
149
+ "l-pagination--link",
150
+ this.current === this.#t ? "active" : ""
151
+ ],
152
+ "data-page": `${this.#t}`
153
+ }));
154
+ }
155
+ return e.push(this.#u("l-button", {
156
+ title: `${this.current + 1}`,
157
+ innerHTML: "<l-arrow-right-icon></l-arrow-right-icon>",
158
+ class: [
159
+ "l-pagination-item",
160
+ "l-pagination--btn",
161
+ "next-btn"
162
+ ],
163
+ disabled: this.current === this.#t,
164
+ "data-page": `${this.current + 1}`
165
+ })), e.join("");
166
+ }
167
+ #a() {
168
+ let e = i(".l-pagination-simple-input", this.root);
169
+ e && (e.setParser(this.#l), s(e, "keyup", this.#c), s(e, "blur", this.#s));
170
+ }
171
+ #o() {
172
+ let e = i(".l-pagination-simple-input", this.root);
173
+ e && (e.setParser(void 0), o(e, "keyup", this.#c), o(e, "blur", this.#s));
174
+ }
175
+ #s = (e) => {
176
+ let t = e.target, n = t.value;
177
+ if (!n) {
178
+ t.value = `${this.current}`;
179
+ return;
180
+ }
181
+ this.setCurrent(Number(n));
182
+ };
183
+ #c = (e) => {
184
+ if (e.key === "Enter") {
185
+ let t = e.target.value;
186
+ if (t) {
187
+ let e = Number(t);
188
+ this.setCurrent(e);
189
+ }
190
+ }
191
+ };
192
+ #l = (e) => {
193
+ if (e) {
194
+ let t = Number(e);
195
+ t = Math.max(1, Math.min(this.#t, t)), e = String(t);
196
+ }
197
+ return e;
198
+ };
199
+ #u(e = "a", t) {
200
+ let n = [], i = "";
201
+ for (let e in t) if (e === "innerHTML") i = t[e], Array.isArray(i) && (i = i.join(""));
202
+ else if (e === "class") {
203
+ let e = t.class;
204
+ n.push(` class="${a(e)}"`);
205
+ } else n.push(r(e, t[e]));
206
+ return `<${e}${n.join("")}>${i}</${e}>`;
207
+ }
208
+ };
209
+ //#endregion
210
+ export { u as t };