litos-ui 0.15.6 → 0.15.7

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 (81) hide show
  1. package/lib/button/index.d.ts +4 -0
  2. package/lib/button/index.js +84 -57
  3. package/lib/check/checkbox.js +1 -1
  4. package/lib/check/radio.js +1 -1
  5. package/lib/{check-BlDsQQo0.js → check-A86JxUfd.js} +1 -1
  6. package/lib/collapse/index.d.ts +19 -0
  7. package/lib/collapse/index.js +88 -0
  8. package/lib/collapse/item.d.ts +15 -0
  9. package/lib/collapse/item.js +115 -0
  10. package/lib/color_picker/index.js +1 -1
  11. package/lib/date_picker/index.js +1 -1
  12. package/lib/description_panel/index.d.ts +4 -4
  13. package/lib/description_panel/index.js +59 -11
  14. package/lib/dialog/dialog_container.js +1 -1
  15. package/lib/form/form_inner.d.ts +2 -1
  16. package/lib/form/form_inner.js +16 -15
  17. package/lib/form/form_item.js +9 -9
  18. package/lib/icon/d_arrow_left.d.ts +6 -0
  19. package/lib/icon/d_arrow_left.js +13 -0
  20. package/lib/icon/d_arrow_right.d.ts +6 -0
  21. package/lib/icon/d_arrow_right.js +13 -0
  22. package/lib/icon/more.d.ts +6 -0
  23. package/lib/icon/more.js +13 -0
  24. package/lib/icon/select.d.ts +6 -0
  25. package/lib/icon/select.js +13 -0
  26. package/lib/icon/zoom_in.d.ts +6 -0
  27. package/lib/icon/zoom_in.js +13 -0
  28. package/lib/icon/zoom_out.d.ts +6 -0
  29. package/lib/icon/zoom_out.js +13 -0
  30. package/lib/image/image_preview.d.ts +24 -0
  31. package/lib/image/image_preview.js +104 -0
  32. package/lib/image/index.d.ts +50 -0
  33. package/lib/image/index.js +176 -0
  34. package/lib/index-D4II9KsF.js +4 -0
  35. package/lib/index.d.ts +36 -4
  36. package/lib/index.js +157 -120
  37. package/lib/input/index.d.ts +4 -0
  38. package/lib/input/index.js +75 -64
  39. package/lib/litos-ui.css +1 -1
  40. package/lib/mask/index.d.ts +23 -0
  41. package/lib/mask/index.js +110 -0
  42. package/lib/md_input/index.js +11 -11
  43. package/lib/modal/index.d.ts +1 -1
  44. package/lib/modal/index.js +7 -7
  45. package/lib/modal/modal_box.js +10 -10
  46. package/lib/page_header/index.d.ts +20 -0
  47. package/lib/page_header/index.js +109 -0
  48. package/lib/pagination/index.d.ts +27 -0
  49. package/lib/pagination/index.js +248 -0
  50. package/lib/qrcode/index.js +4 -4
  51. package/lib/select/index.d.ts +79 -0
  52. package/lib/select/index.js +406 -0
  53. package/lib/select_ori/index.js +1 -1
  54. package/lib/switch/index.js +4 -4
  55. package/lib/tabbar/index.js +1 -1
  56. package/lib/tabbar/item.js +1 -1
  57. package/lib/table/index.d.ts +46 -0
  58. package/lib/table/index.js +200 -0
  59. package/lib/table/types.d.ts +28 -0
  60. package/lib/table/types.js +1 -0
  61. package/lib/tabs/index.d.ts +7 -0
  62. package/lib/tabs/index.js +43 -0
  63. package/lib/tag/index.d.ts +16 -0
  64. package/lib/tag/index.js +77 -0
  65. package/lib/theme/index.js +6 -6
  66. package/lib/utils/index.d.ts +6 -28
  67. package/lib/utils/index.js +61 -86
  68. package/lib/utils/popover.d.ts +137 -0
  69. package/lib/utils/popover.js +354 -0
  70. package/lib/utils/transition.js +26 -50
  71. package/package.json +13 -13
  72. package/styles/popover.css +66 -0
  73. package/styles/reset.css +1 -1
  74. package/styles/select.css +37 -0
  75. package/styles/tabs.css +13 -0
  76. package/styles/vars.css +2 -1
  77. package/lib/index-dwS1N2uN.js +0 -4
  78. package/lib/popconfirm/index.d.ts +0 -7
  79. package/lib/popconfirm/index.js +0 -30
  80. package/lib/popover/index.d.ts +0 -34
  81. package/lib/popover/index.js +0 -150
@@ -0,0 +1,248 @@
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,7 +1,7 @@
1
1
  import s from "../base.js";
2
2
  import { QRCodeRender as o, renderToCanvas as r } from "qrcode-generator-es";
3
3
  import { $one as c } from "ph-utils/dom";
4
- const n = ":host{display:inline-flex}.renderer-el{display:inline-flex}";
4
+ const d = ":host{display:inline-flex}.renderer-el{display:inline-flex}";
5
5
  class f extends s {
6
6
  static baseName = "qrcode";
7
7
  /** 二维码内容 */
@@ -16,7 +16,7 @@ class f extends s {
16
16
  icon;
17
17
  _qrcode;
18
18
  connectedCallback() {
19
- this.loadStyleText(n), super.connectedCallback();
19
+ this.loadStyleText(d), super.connectedCallback();
20
20
  }
21
21
  static get observedAttributes() {
22
22
  return ["text", "fill", "size", "level", "icon"];
@@ -28,7 +28,7 @@ class f extends s {
28
28
  this.#e();
29
29
  }
30
30
  beforeDestroy() {
31
- this._qrcode = void 0;
31
+ this._qrcode && (this._qrcode.destroy(), this._qrcode = void 0);
32
32
  }
33
33
  #t(e, t) {
34
34
  this._qrcode && (e === "icon" ? this._qrcode.option.icon = t ? { src: t } : void 0 : this._qrcode.option[e] = t);
@@ -36,7 +36,7 @@ class f extends s {
36
36
  #e() {
37
37
  if (!this._qrcode) {
38
38
  const e = c("canvas", this.root);
39
- e && (console.log(this.icon), this._qrcode = new o({
39
+ e && (this._qrcode = new o({
40
40
  renderFn: r,
41
41
  text: this.text,
42
42
  size: Number(this.size),
@@ -0,0 +1,79 @@
1
+ import FormInner from "../form/form_inner";
2
+ type SelectOption = {
3
+ class?: string;
4
+ render?: (option: SelectOption, isSelect: boolean, selectedValues?: any | any[]) => HTMLElement | DocumentFragment;
5
+ label?: string;
6
+ value?: any;
7
+ [index: string]: any;
8
+ };
9
+ export default class Select extends FormInner {
10
+ static baseName: string;
11
+ /** 选中的标签 */
12
+ selectedLabels: string[];
13
+ /** 是否启用过滤 */
14
+ filterable?: boolean;
15
+ placeholder?: string;
16
+ /** 选项 label 的字段名 */
17
+ labelField: string;
18
+ /** 选项 value 的字段名 */
19
+ valueField: string;
20
+ /** 是否支持多选 */
21
+ multiple?: boolean;
22
+ /** 多选时是否折叠标签 */
23
+ collapseTags?: boolean;
24
+ /** 是否加载中, 远程搜索时使用 */
25
+ _loading?: boolean;
26
+ /** 宽度 */
27
+ width?: string;
28
+ /** 是否可清除 */
29
+ clearable?: boolean;
30
+ /** 是否展开下拉选择 */
31
+ _expanded: boolean;
32
+ remote: boolean;
33
+ filter?: (match: string, option: SelectOption) => boolean;
34
+ options?: SelectOption[];
35
+ private _backOptions?;
36
+ inputHandler?: (match: string) => void;
37
+ private _popover?;
38
+ private _searchEl?;
39
+ constructor();
40
+ connectedCallback(): void;
41
+ setInputHandler(handler: (match: string) => void): void;
42
+ setFilter(filter: (match: string, option: SelectOption) => boolean): void;
43
+ get loading(): boolean | undefined;
44
+ set loading(loading: boolean | undefined);
45
+ setLoading(loading: boolean): void;
46
+ private get expanded();
47
+ private set expanded(value);
48
+ setExpanded(value: boolean): void;
49
+ setValue(value: string | string[] | number): void;
50
+ private _updateSelectedLabels;
51
+ static get observedAttributes(): string[];
52
+ protected attributeChange(name: string, _oldValue: string, newValue: string): void;
53
+ setOptions(options: any[]): void;
54
+ private _isOptionSelect;
55
+ private _updateOptionSelect;
56
+ private _renderOption;
57
+ private _calculateOffset;
58
+ isEmpty(): boolean;
59
+ private _toggleClearable;
60
+ private _onMouseEnter;
61
+ private _onMouseLeave;
62
+ private _togglePopover;
63
+ private _updatePopoverContent;
64
+ private _onRootTap;
65
+ private _onTap;
66
+ private _onSearchBlur;
67
+ private _onSearchInput;
68
+ private _handleFilte;
69
+ private _filteOption;
70
+ afterInit(): void;
71
+ beforeDestroy(): void;
72
+ render(): DocumentFragment;
73
+ protected disabledChange(): void;
74
+ private _renderTag;
75
+ private _reRenderLabels;
76
+ private _updateSearchValue;
77
+ private _renderSelectedLabels;
78
+ }
79
+ export {};