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
@@ -2,7 +2,7 @@ import o from "../base.js";
2
2
  import { parseAttrValue as d } from "../utils/index.js";
3
3
  import { add as l, remove as u, emit as f } from "../utils/event.js";
4
4
  import { getAttr as m } from "ph-utils/dom";
5
- class _ extends o {
5
+ class c extends o {
6
6
  disabled = !1;
7
7
  formAttrs = {};
8
8
  formItemAttrs = {};
@@ -13,9 +13,10 @@ class _ extends o {
13
13
  /**
14
14
  *
15
15
  * @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
16
+ * @param delegatesFocus 是否委托焦点, 默认: true
16
17
  */
17
- constructor(t = !0) {
18
- super(!0, { delegatesFocus: !0 }), this._firstPushValue = t;
18
+ constructor(t = !0, e = !0) {
19
+ super(!0, { delegatesFocus: e }), this._firstPushValue = t;
19
20
  }
20
21
  get value() {
21
22
  return this._value;
@@ -32,13 +33,13 @@ class _ extends o {
32
33
  static get observedAttributes() {
33
34
  return ["disabled", "value"];
34
35
  }
35
- attributeChangedCallback(t, r, e) {
36
+ attributeChangedCallback(t, e, r) {
36
37
  if (t === "disabled") {
37
- const i = d(e, !1, t);
38
+ const i = d(r, !1, t);
38
39
  i !== this.disabled && (this.disabled = i, this.disabledChange());
39
- } else t === "value" ? this.value = e : this.attributeChange(t, r, e);
40
+ } else t === "value" ? this.value = r : this.attributeChange(t, e, r);
40
41
  }
41
- attributeChange(t, r, e) {
42
+ attributeChange(t, e, r) {
42
43
  }
43
44
  connectedCallback() {
44
45
  const t = this._getForm();
@@ -63,14 +64,14 @@ class _ extends o {
63
64
  return t || this.formItemAttrs.name;
64
65
  }
65
66
  _getForm() {
66
- let t = this.parentElement, r = {}, e = {};
67
+ let t = this.parentElement, e = {}, r = {};
67
68
  for (; t != null; ) {
68
69
  const i = t.tagName;
69
70
  if (i === "L-FORM") {
70
71
  const a = t.sharedAttrs;
71
72
  for (let s = 0; s < a.length; s++) {
72
73
  const h = a[s];
73
- r[h] = t[h];
74
+ e[h] = t[h];
74
75
  }
75
76
  break;
76
77
  }
@@ -79,18 +80,18 @@ class _ extends o {
79
80
  const a = t.sharedAttrs;
80
81
  for (let s = 0; s < a.length; s++) {
81
82
  const h = a[s];
82
- e[h] = t[h];
83
+ r[h] = t[h];
83
84
  }
84
85
  }
85
86
  t = t.parentElement;
86
87
  }
87
88
  return t = null, {
88
- formAttr: r,
89
- formItemAttr: e
89
+ formAttr: e,
90
+ formItemAttr: r
90
91
  };
91
92
  }
92
- _formAttributeChanged = (t, r, e) => {
93
- e === this.formAttrs.formId ? this.formAttrs[t] = r : this.formItemAttrs[t] = r, t === "disabled" && this.disabledChange();
93
+ _formAttributeChanged = (t, e, r) => {
94
+ r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this.disabledChange();
94
95
  };
95
96
  disabledChange() {
96
97
  }
@@ -112,5 +113,5 @@ class _ extends o {
112
113
  }
113
114
  }
114
115
  export {
115
- _ as default
116
+ c as default
116
117
  };
@@ -1,9 +1,9 @@
1
- import { $$ as i, $one as s, addClass as n, removeClass as d } from "ph-utils/dom";
1
+ import { $$ as i, $one as o, addClass as n, removeClass as d } from "ph-utils/dom";
2
2
  import { parseAttrValue as h, initAttr as m } from "../utils/index.js";
3
3
  import f from "../base.js";
4
- import { emit as o, add as c, clear as p, remove as b } from "../utils/event.js";
4
+ import { emit as s, add as c, clear as p, remove as b } from "../utils/event.js";
5
5
  import { random as a } from "ph-utils";
6
- const u = ':host{display:var(--l-form-item-display, flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-edit-height, 32px);line-height:var(--l-form-edit-height, 32px);color:#606266;padding:0 10px 0 0;box-sizing:border-box}.l-form-item__label:empty{display:var(--l-form-label-empty-display, inline-block)}:host(.is-required) .l-form-item__label:before{content:"*";margin-right:4px;color:var(--l-warn-color, #f56c6c);vertical-align:middle}.l-form-item__content{flex:1;position:relative;display:flex;align-items:center}.l-form-item__error{font-size:12px;line-height:1;position:absolute;top:100%;left:0;color:var(--nt-error-color, #ed3f13);padding-top:3px}:host(.l-form-item--left){--l-form-label-align: left}:host(.l-form-item--top){--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}';
6
+ const u = ':host{display:var(--l-form-item-display, flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-control-height, 32px);line-height:var(--l-form-control-height, 32px);color:#606266;padding:0 10px 0 0;box-sizing:border-box}.l-form-item__label:empty{display:var(--l-form-label-empty-display, inline-block)}:host(.is-required) .l-form-item__label:before{content:"*";margin-right:4px;color:var(--l-warn-color, #f56c6c);vertical-align:middle}.l-form-item__content{flex:1;position:relative;display:flex;align-items:center}.l-form-item__error{font-size:12px;line-height:1;position:absolute;top:100%;left:0;color:var(--nt-error-color, #ed3f13);padding-top:3px}:host(.l-form-item--left){--l-form-label-align: left}:host(.l-form-item--top){--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}';
7
7
  class I extends f {
8
8
  static baseName = "form-item";
9
9
  disabled = !1;
@@ -39,7 +39,7 @@ class I extends f {
39
39
  this.label = r, this._updateLabel();
40
40
  else if (e === "disabled") {
41
41
  const l = h(r, !1, e);
42
- l !== this.disabled && (o(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
42
+ l !== this.disabled && (s(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
43
43
  }
44
44
  }
45
45
  connectedCallback() {
@@ -52,7 +52,7 @@ class I extends f {
52
52
  message: this.validity,
53
53
  rules: e
54
54
  };
55
- o(this.formId, "ruleChange", t), c(this.formId, "validateChange", this._validateChange);
55
+ s(this.formId, "ruleChange", t), c(this.formId, "validateChange", this._validateChange);
56
56
  }
57
57
  }
58
58
  disconnectedCallback() {
@@ -60,7 +60,7 @@ class I extends f {
60
60
  }
61
61
  setRules(e) {
62
62
  const t = { ...e, key: this.name };
63
- t.required != null && this.required && (t.required = !0), this.formId && o(this.formId, "ruleChange", t);
63
+ t.required != null && this.required && (t.required = !0), this.formId && s(this.formId, "ruleChange", t);
64
64
  }
65
65
  setError(e) {
66
66
  this.error = e;
@@ -85,19 +85,19 @@ class I extends f {
85
85
  };
86
86
  _updateError() {
87
87
  if (!this.rendered) return;
88
- let e = s(".l-form-item__error", this.root);
88
+ let e = o(".l-form-item__error", this.root);
89
89
  if (e)
90
90
  this.error ? e.textContent = this.error : e.remove();
91
91
  else if (this.error) {
92
92
  e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this.error;
93
- const t = s(".l-form-item__content", this.root);
93
+ const t = o(".l-form-item__content", this.root);
94
94
  t && t.appendChild(e);
95
95
  }
96
96
  this.error ? n(this, "is-error") : d(this, "is-error");
97
97
  }
98
98
  _updateLabel() {
99
99
  if (!this.rendered) return;
100
- let e = s(".l-form-item__label", this.root);
100
+ let e = o(".l-form-item__label", this.root);
101
101
  e == null ? this.label != null && (e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this.label, this.root.prepend(e)) : this.label != null ? e.textContent = this.label : e.remove();
102
102
  }
103
103
  _getFormId() {
@@ -0,0 +1,6 @@
1
+ import BaseIcon from "./base";
2
+ export default class Moon extends BaseIcon {
3
+ static baseName: string;
4
+ constructor();
5
+ renderChildren(): string;
6
+ }
@@ -0,0 +1,13 @@
1
+ import a from "./base.js";
2
+ class t extends a {
3
+ static baseName = "d-arrow-left-icon";
4
+ constructor() {
5
+ super(), this.viewBox = "0 0 1024 1024";
6
+ }
7
+ renderChildren() {
8
+ return '<path d="M529.408 149.376a29.12 29.12 0 0 1 41.728 0 30.592 30.592 0 0 1 0 42.688L259.264 511.936l311.872 319.936a30.592 30.592 0 0 1-.512 43.264 29.12 29.12 0 0 1-41.216-.512L197.76 534.272a32 32 0 0 1 0-44.672l331.648-340.224zm256 0a29.12 29.12 0 0 1 41.728 0 30.592 30.592 0 0 1 0 42.688L515.264 511.936l311.872 319.936a30.592 30.592 0 0 1-.512 43.264 29.12 29.12 0 0 1-41.216-.512L453.76 534.272a32 32 0 0 1 0-44.672l331.648-340.224z"></path>';
9
+ }
10
+ }
11
+ export {
12
+ t as default
13
+ };
@@ -0,0 +1,6 @@
1
+ import BaseIcon from "./base";
2
+ export default class Moon extends BaseIcon {
3
+ static baseName: string;
4
+ constructor();
5
+ renderChildren(): string;
6
+ }
@@ -0,0 +1,13 @@
1
+ import a from "./base.js";
2
+ class t extends a {
3
+ static baseName = "d-arrow-right-icon";
4
+ constructor() {
5
+ super(), this.viewBox = "0 0 1024 1024";
6
+ }
7
+ renderChildren() {
8
+ return '<path d="M452.864 149.312a29.12 29.12 0 0 1 41.728.064L826.24 489.664a32 32 0 0 1 0 44.672L494.592 874.624a29.12 29.12 0 0 1-41.728 0 30.592 30.592 0 0 1 0-42.752L764.736 512 452.864 192a30.592 30.592 0 0 1 0-42.688m-256 0a29.12 29.12 0 0 1 41.728.064L570.24 489.664a32 32 0 0 1 0 44.672L238.592 874.624a29.12 29.12 0 0 1-41.728 0 30.592 30.592 0 0 1 0-42.752L508.736 512 196.864 192a30.592 30.592 0 0 1 0-42.688z"></path>';
9
+ }
10
+ }
11
+ export {
12
+ t as default
13
+ };
@@ -0,0 +1,6 @@
1
+ import BaseIcon from "./base";
2
+ export default class Moon extends BaseIcon {
3
+ static baseName: string;
4
+ constructor();
5
+ renderChildren(): string;
6
+ }
@@ -0,0 +1,13 @@
1
+ import e from "./base.js";
2
+ class t extends e {
3
+ static baseName = "more-icon";
4
+ constructor() {
5
+ super(), this.viewBox = "0 0 1024 1024";
6
+ }
7
+ renderChildren() {
8
+ return '<path d="M176 416a112 112 0 1 1 0 224 112 112 0 0 1 0-224m336 0a112 112 0 1 1 0 224 112 112 0 0 1 0-224m336 0a112 112 0 1 1 0 224 112 112 0 0 1 0-224"></path>';
9
+ }
10
+ }
11
+ export {
12
+ t as default
13
+ };
@@ -0,0 +1,6 @@
1
+ import BaseIcon from "./base";
2
+ export default class Select extends BaseIcon {
3
+ static baseName: string;
4
+ connectedCallback(): void;
5
+ renderChildren(): string;
6
+ }
@@ -0,0 +1,13 @@
1
+ import e from "./base.js";
2
+ class t extends e {
3
+ static baseName = "select-icon";
4
+ connectedCallback() {
5
+ super.connectedCallback();
6
+ }
7
+ renderChildren() {
8
+ return '<path fill="currentColor" d="M77.248 415.04a64 64 0 0 1 90.496 0l226.304 226.304L846.528 188.8a64 64 0 1 1 90.56 90.496l-543.04 543.04-316.8-316.8a64 64 0 0 1 0-90.496z"></path>';
9
+ }
10
+ }
11
+ export {
12
+ t as default
13
+ };
@@ -0,0 +1,6 @@
1
+ import BaseIcon from "./base";
2
+ export default class ZoomIn extends BaseIcon {
3
+ static baseName: string;
4
+ connectedCallback(): void;
5
+ renderChildren(): string;
6
+ }
@@ -0,0 +1,13 @@
1
+ import a from "./base.js";
2
+ class o extends a {
3
+ static baseName = "zoom-in-icon";
4
+ connectedCallback() {
5
+ super.connectedCallback();
6
+ }
7
+ renderChildren() {
8
+ return '<path fill="currentColor" d="m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704m-32-384v-96a32 32 0 0 1 64 0v96h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64z"></path>';
9
+ }
10
+ }
11
+ export {
12
+ o as default
13
+ };
@@ -0,0 +1,6 @@
1
+ import BaseIcon from "./base";
2
+ export default class ZoomOut extends BaseIcon {
3
+ static baseName: string;
4
+ connectedCallback(): void;
5
+ renderChildren(): string;
6
+ }
@@ -0,0 +1,13 @@
1
+ import a from "./base.js";
2
+ class t extends a {
3
+ static baseName = "zoom-out-icon";
4
+ connectedCallback() {
5
+ super.connectedCallback();
6
+ }
7
+ renderChildren() {
8
+ return '<path fill="currentColor" d="m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704M352 448h256a32 32 0 0 1 0 64H352a32 32 0 0 1 0-64"></path>';
9
+ }
10
+ }
11
+ export {
12
+ t as default
13
+ };
@@ -0,0 +1,24 @@
1
+ import Mask from "../mask";
2
+ export default class ImagePreview extends Mask {
3
+ static baseName: string;
4
+ urlList: string[];
5
+ currentIndex: number;
6
+ private _scale;
7
+ private _rotate;
8
+ setImages(urlList: string[]): void;
9
+ setCurrentIndex(index: number): void;
10
+ static customAttributes: string[];
11
+ connectedCallback(): void;
12
+ contentRender(): string | HTMLElement | DocumentFragment;
13
+ _generateBtnString(name: string, iconName: string): string;
14
+ _getProgress(): string;
15
+ _getTransformStyleValue(): string;
16
+ private _updateImgAttr;
17
+ private _updateProgress;
18
+ private _resetTransform;
19
+ onAction(action: string): boolean;
20
+ private _handleWhell;
21
+ afterOpened(): void;
22
+ private _transformScale;
23
+ afterClosed(): void;
24
+ }
@@ -0,0 +1,104 @@
1
+ import s from "../mask/index.js";
2
+ import { $$ as n, $one as r, on as a, off as o } from "ph-utils/dom";
3
+ const l = ".l-image-preview--container{position:relative;width:100%;height:100%;display:flex;justify-content:center;align-items:center}.l-image-preview__btn,.l-image-preview-operations{display:flex;justify-content:center;align-items:center;background-color:#606666}.l-image-preview__btn{z-index:1;position:absolute;border-radius:50%;opacity:.8;cursor:pointer;background-color:#606666;color:#fff;width:40px;height:40px;font-size:20px;display:flex;justify-content:center;align-items:center;transition:color .3s ease-in-out;outline:none;border:none}.l-image-preview__btn:hover{color:var(--l-primary-color, #4998f6)}.l-image-preview__close{right:30px;top:30px}.l-image-preview__prev,.l-image-preview__next{top:50%;transform:translateY(-50%)}.l-image-preview__prev{left:30px}.l-image-preview__next{right:30px}.l-image-preview-footer{position:absolute;bottom:30px;left:50%;transform:translate(-50%);display:flex;align-items:center;flex-direction:column;z-index:1}.l-image-preview-progress{color:#fff;margin-bottom:10px}.l-image-preview-operations{cursor:default;padding:0 25px;border-radius:20px}.l-image-preview-operations .l-image-preview__btn{position:static;width:40px}.l-image-preview-img{max-width:calc(100vw - 40px);max-height:calc(100vh - 200px);vertical-align:middle;transform-origin:center center;transition:transform .25s;user-select:none;z-index:0}";
4
+ class g extends s {
5
+ static baseName = "image-preview";
6
+ urlList = [];
7
+ currentIndex = 0;
8
+ // 缩放
9
+ _scale = 1;
10
+ // 旋转
11
+ _rotate = 0;
12
+ setImages(e) {
13
+ this.urlList = e;
14
+ }
15
+ setCurrentIndex(e) {
16
+ this.currentIndex = e;
17
+ }
18
+ static customAttributes = ["current-index"];
19
+ connectedCallback() {
20
+ this.loadStyleText(l), super.connectedCallback();
21
+ }
22
+ contentRender() {
23
+ const e = [this._generateBtnString("close", "close")];
24
+ this.urlList.length > 1 && (e.push(this._generateBtnString("prev", "arrow-left")), e.push(this._generateBtnString("next", "arrow-right"))), e.push('<div class="l-image-preview-footer">'), e.push(
25
+ `<div class="l-image-preview-progress">${this._getProgress()}</div>`
26
+ ), e.push(
27
+ '<div data-action="operations" class="l-image-preview-operations">'
28
+ ), e.push(this._generateBtnString("zoom-in", "zoom-in")), e.push(this._generateBtnString("zoom-out", "zoom-out")), e.push(this._generateBtnString("reduction", "reduction")), e.push(this._generateBtnString("refresh-left", "refresh-left")), e.push(this._generateBtnString("refresh-right", "refresh-right")), e.push("</div></div>");
29
+ const t = this.urlList[this.currentIndex], i = this._getTransformStyleValue();
30
+ return e.push(
31
+ `<img src="${t}" data-action="previewer" class="l-image-preview-img" style="transform: ${i};" />`
32
+ ), n("div", {
33
+ class: "l-image-preview--container",
34
+ innerHTML: e.join("")
35
+ });
36
+ }
37
+ _generateBtnString(e, t) {
38
+ return `<button aria-label="${e}" data-action="${e}" class="l-image-preview__btn l-image-preview__${e}"><l-${t}-icon></l-${t}-icon></button>`;
39
+ }
40
+ _getProgress() {
41
+ return `${this.currentIndex + 1}&nbsp;/&nbsp;${this.urlList.length}`;
42
+ }
43
+ _getTransformStyleValue() {
44
+ return `scale3d(${this._scale}, ${this._scale}, 1) rotate3d(0, 0, 1, ${this._rotate}deg)`;
45
+ }
46
+ _updateImgAttr() {
47
+ const e = r(".l-image-preview-img", this.root);
48
+ e && (e.src = this.urlList[this.currentIndex], e.style.transform = this._getTransformStyleValue());
49
+ }
50
+ _updateProgress() {
51
+ const e = r(
52
+ ".l-image-preview-progress",
53
+ this.root
54
+ );
55
+ e && (e.innerHTML = this._getProgress());
56
+ }
57
+ _resetTransform() {
58
+ this._scale = 1, this._rotate = 0, this._updateImgAttr();
59
+ }
60
+ onAction(e) {
61
+ switch (e) {
62
+ case "close":
63
+ this.open = !1;
64
+ break;
65
+ case "prev":
66
+ this.currentIndex === 0 ? this.currentIndex = this.urlList.length - 1 : this.currentIndex--, this._resetTransform(), this._updateProgress();
67
+ break;
68
+ case "next":
69
+ this.currentIndex === this.urlList.length - 1 ? this.currentIndex = 0 : this.currentIndex++, this._resetTransform(), this._updateProgress();
70
+ break;
71
+ case "zoom-in":
72
+ this._transformScale("in");
73
+ break;
74
+ case "zoom-out":
75
+ this._transformScale("out");
76
+ break;
77
+ case "reduction":
78
+ this._resetTransform();
79
+ break;
80
+ case "refresh-left":
81
+ this._rotate -= 90, this._updateImgAttr();
82
+ break;
83
+ case "refresh-right":
84
+ this._rotate += 90, this._updateImgAttr();
85
+ break;
86
+ }
87
+ return !0;
88
+ }
89
+ _handleWhell = (e) => {
90
+ e.preventDefault(), e.deltaY > 0 ? this._transformScale("out") : this._transformScale("in");
91
+ };
92
+ afterOpened() {
93
+ a(document, "wheel", this._handleWhell, { passive: !0 });
94
+ }
95
+ _transformScale(e) {
96
+ e === "in" ? this._scale < 3 && (this._scale += 0.25) : this._scale > 0.25 && (this._scale -= 0.25), this._updateImgAttr();
97
+ }
98
+ afterClosed() {
99
+ o(document, "wheel", this._handleWhell);
100
+ }
101
+ }
102
+ export {
103
+ g as default
104
+ };
@@ -0,0 +1,50 @@
1
+ import BaseComponent from "../base";
2
+ export default class ImageHTML extends BaseComponent {
3
+ static baseName: string;
4
+ alt?: string;
5
+ private _src;
6
+ /** eager - 立即加载图像, lazy - 懒加载 */
7
+ private _loading;
8
+ fit?: "fill" | "contain" | "cover" | "none" | "scale-down";
9
+ width?: string;
10
+ height?: string;
11
+ fallback?: string;
12
+ customFallback?: boolean;
13
+ /** 是否加载错误 */
14
+ isError?: boolean;
15
+ /** 是否禁用图片预览 */
16
+ previewDisabled?: boolean;
17
+ private _previewEl?;
18
+ private _previewImageList?;
19
+ private _previewIndex?;
20
+ private _placeholder?;
21
+ private _imageInner?;
22
+ get src(): string;
23
+ set src(value: string);
24
+ get loading(): "lazy" | "eager";
25
+ set loading(value: "lazy" | "eager");
26
+ get placeholder(): string | undefined;
27
+ set placeholder(value: string);
28
+ get previewImageList(): string[] | undefined;
29
+ set previewImageList(value: string[]);
30
+ get previewIndex(): number | undefined;
31
+ set previewIndex(value: number);
32
+ setPreviewImageList(imageList: string[] | undefined): void;
33
+ setPreviewIndex(index: number): void;
34
+ connectedCallback(): void;
35
+ static get observedAttributes(): string[];
36
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
37
+ render(): HTMLElement;
38
+ private _updateSize;
39
+ afterInit(): void;
40
+ beforeDestroy(): void;
41
+ setIsError(isError?: boolean): void;
42
+ openPreview(): void;
43
+ closePreview(): void;
44
+ private _onError;
45
+ private _onLoad;
46
+ private _onPreviewClosed;
47
+ private _onTap;
48
+ private _clearTmpImg;
49
+ private _loadActualImage;
50
+ }
@@ -0,0 +1,176 @@
1
+ import o from "../base.js";
2
+ import { kebabToCamel as n, parseAttrValue as d } from "../utils/index.js";
3
+ import { $$ as l, formatClass as c, $one as h, on as s, off as r, addClass as g, removeClass as p, shouldEventNext as m } from "ph-utils/dom";
4
+ const f = ":host{vertical-align:middle;display:inline-flex;box-sizing:border-box;width:auto;height:auto}.l-image-inner{vertical-align:middle;width:100%;height:100%;object-fit:var(--l-image-fit, fill)}.l-image-inner--preview{cursor:pointer}.l-image-hide{display:none}.l-image-fallback{width:100%;height:100%;display:inline-flex;justify-content:center;align-items:center;background-color:#0000001a}";
5
+ class b extends o {
6
+ static baseName = "image";
7
+ alt;
8
+ _src = "";
9
+ /** eager - 立即加载图像, lazy - 懒加载 */
10
+ _loading = "eager";
11
+ fit;
12
+ width;
13
+ height;
14
+ fallback;
15
+ customFallback = !1;
16
+ /** 是否加载错误 */
17
+ isError = !1;
18
+ /** 是否禁用图片预览 */
19
+ previewDisabled = !1;
20
+ _previewEl;
21
+ _previewImageList;
22
+ _previewIndex = 0;
23
+ _placeholder;
24
+ _imageInner;
25
+ get src() {
26
+ return this._src;
27
+ }
28
+ set src(e) {
29
+ this._src = e, this._loadActualImage();
30
+ }
31
+ get loading() {
32
+ return this._loading;
33
+ }
34
+ set loading(e) {
35
+ this._loading = e;
36
+ }
37
+ get placeholder() {
38
+ return this._placeholder;
39
+ }
40
+ set placeholder(e) {
41
+ this._placeholder = e;
42
+ }
43
+ get previewImageList() {
44
+ return this._previewImageList;
45
+ }
46
+ set previewImageList(e) {
47
+ this.setPreviewImageList(e);
48
+ }
49
+ get previewIndex() {
50
+ return this._previewIndex;
51
+ }
52
+ set previewIndex(e) {
53
+ this.setPreviewIndex(e);
54
+ }
55
+ setPreviewImageList(e) {
56
+ this._previewImageList = e;
57
+ }
58
+ setPreviewIndex(e) {
59
+ this._previewIndex = e;
60
+ }
61
+ connectedCallback() {
62
+ this.loadStyleText(f), super.connectedCallback();
63
+ }
64
+ static get observedAttributes() {
65
+ return [
66
+ "src",
67
+ "loading",
68
+ "fit",
69
+ "width",
70
+ "height",
71
+ "placeholder",
72
+ "preview-disabled",
73
+ "preview-image-list",
74
+ "preview-index",
75
+ "fallback",
76
+ "custom-fallback"
77
+ ];
78
+ }
79
+ attributeChangedCallback(e, i, a) {
80
+ e = n(e);
81
+ const t = d(
82
+ a,
83
+ this[e],
84
+ e
85
+ );
86
+ switch (t !== this[e] && (e === "previewImageList" ? this.setPreviewImageList(
87
+ t ? t.split(",") : void 0
88
+ ) : this[e] = t), e) {
89
+ case "width":
90
+ case "height":
91
+ this.rendered && this._updateSize();
92
+ break;
93
+ }
94
+ }
95
+ render() {
96
+ const e = this.alt || this.getAttribute("alt"), i = this.placeholder || this.src;
97
+ return l("img", {
98
+ class: c([
99
+ "l-image-inner",
100
+ this.previewDisabled ? void 0 : "l-image-inner--preview"
101
+ ]),
102
+ alt: e,
103
+ loading: this.loading,
104
+ src: i,
105
+ part: "inner",
106
+ "l-action": "inner"
107
+ });
108
+ }
109
+ _updateSize() {
110
+ this.width ? this.style.setProperty("width", this.width) : this.style.removeProperty("width"), this.height ? this.style.setProperty("height", this.height) : this.style.removeProperty("height");
111
+ }
112
+ afterInit() {
113
+ this.fit && this.fit !== "fill" && this.style.setProperty("--l-image-fit", this.fit), this._updateSize(), this._imageInner = h(".l-image-inner", this.root), s(this._imageInner, "click", this._onTap), s(this._imageInner, "error", this._onError), s(this._imageInner, "load", this._onLoad), this._loadActualImage();
114
+ }
115
+ beforeDestroy() {
116
+ this._imageInner && (r(this._imageInner, "click", this._onTap), r(this._imageInner, "error", this._onError), r(this._imageInner, "load", this._onLoad));
117
+ }
118
+ setIsError(e = !1) {
119
+ if (this.isError !== e)
120
+ if (this.isError = e, e) {
121
+ if (!this.customFallback) {
122
+ this.fallback && this._imageInner && (this._imageInner.src = this.fallback);
123
+ return;
124
+ }
125
+ this._imageInner && g(this._imageInner, "l-image-hide");
126
+ let i = h(".l-image-fallback", this.root);
127
+ this.fallback || (i = l("div", {
128
+ class: "l-image-fallback",
129
+ part: "fallback",
130
+ innerHTML: "<slot name='fallback'></slot>"
131
+ }), this.root.appendChild(i));
132
+ } else {
133
+ this._imageInner && p(this._imageInner, "l-image-hide");
134
+ const i = h(".l-image-fallback", this.root);
135
+ i && i.remove();
136
+ }
137
+ }
138
+ openPreview() {
139
+ if (!this._previewEl) {
140
+ const e = l("l-image-preview");
141
+ e.setImages(this.previewImageList || [this.src]), e.setCurrentIndex(this.previewIndex || 0), e.setAttribute("open", "on"), this._previewEl = e, document.body.appendChild(e), s(this._previewEl, "closed", this._onPreviewClosed);
142
+ }
143
+ }
144
+ closePreview() {
145
+ this._previewEl && (r(this._previewEl, "closed", this._onPreviewClosed), this._previewEl.remove(), this._previewEl = void 0);
146
+ }
147
+ _onError = () => {
148
+ this.setIsError(!0);
149
+ };
150
+ _onLoad = () => {
151
+ this.setIsError(!1);
152
+ };
153
+ _onPreviewClosed = () => {
154
+ this.closePreview();
155
+ };
156
+ _onTap = (e) => {
157
+ const [i, a] = m(e, "l-action", this.root);
158
+ i && a === "inner" && !this.previewDisabled && !this.isError && this.openPreview();
159
+ };
160
+ _clearTmpImg(e) {
161
+ e && (e.onload = null, e.onerror = null, e = void 0);
162
+ }
163
+ _loadActualImage() {
164
+ if (this.placeholder && this.rendered) {
165
+ let e = new Image();
166
+ e.src = this.src, e.onload = () => {
167
+ this._imageInner && (this._imageInner.src = this.src), this._clearTmpImg(e);
168
+ }, e.onerror = () => {
169
+ this.setIsError(!0), this._clearTmpImg(e);
170
+ };
171
+ }
172
+ }
173
+ }
174
+ export {
175
+ b as default
176
+ };
@@ -0,0 +1,4 @@
1
+ const r = ":host{--l-input-border-color: var(--l-border-color, #dedede);display:inline-flex;width:var(--l-input-width, 170px);height:var(--l-form-control-height, 32px);align-items:center;padding:0 7px;border:1px solid var(--l-input-border-color, #dedede);transition:border-color .3s;border-radius:var(--l-border-radius, 3px);vertical-align:middle;box-sizing:border-box}:host(:focus){--l-input-border-color: var(--l-primary-color, #722ed1)}:host(.is-disabled){background-color:var(--l-disabled-color, #f5f7fa)}:host(.is-error){--l-input-border-color: #ed3f13}.l-input__prefix,.l-input__suffix{color:#a8abb2;font-size:14px;display:inline-flex;flex-shrink:0}.l-input__prefix{margin-right:5px}.l-input__suffix{margin-left:5px}.l-clearable{cursor:pointer}.l-clearable:hover{color:#999}.l-input__inner{outline:none;border:none;box-sizing:border-box;width:100%;max-width:100%;height:100%;flex-grow:1;text-align:inherit;font-size:inherit}.l-input__inner:disabled{background-color:transparent}";
2
+ export {
3
+ r as i
4
+ };