hcui-package 1.9.31 → 1.9.32

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.
@@ -78077,7 +78077,25 @@ const OJ = {
78077
78077
  };
78078
78078
  class zJ extends HTMLElement {
78079
78079
  constructor() {
78080
- super(), this.inputTimestamps = [], this.timer = null, Object.assign(this, OJ), this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
78080
+ super(), this.inputTimestamps = [], this.timer = null, Object.assign(this, OJ), this.attachShadow({ mode: "open" });
78081
+ }
78082
+ static get observedAttributes() {
78083
+ return ["placeholder", "value", "style", "params"];
78084
+ }
78085
+ isScanInput() {
78086
+ const t = this.inputTimestamps, n = t.length, o = 100;
78087
+ if (n < 4)
78088
+ return !1;
78089
+ const i = t[0];
78090
+ return t[t.length - 1] - i <= o;
78091
+ }
78092
+ // 处理配置
78093
+ attributeChangedCallback(t, n, o) {
78094
+ if (n && !n.includes("{{") && (this[t] = n), o && !o.includes("{{") && (this[t] = o), t === "params" && o) {
78095
+ const i = JSON.parse(o);
78096
+ Object.assign(this, i);
78097
+ }
78098
+ this.shadowRoot.innerHTML = `
78081
78099
  <style>
78082
78100
  * {margin:0;padding:0;box-sizing: border-box;}
78083
78101
  @keyframes blink {
@@ -78086,11 +78104,11 @@ class zJ extends HTMLElement {
78086
78104
  100% { opacity: 1; }
78087
78105
  }
78088
78106
  .input-box { position: relative;width:${this.width};height:${this.height};display: grid;grid-template-columns: 1fr 20px;align-items: center;cursor: text; overflow: hidden;}
78089
- .input-box .before { color: #999;position: absolute;padding-left: 12px; display: none;top: 50%;transform: translateY(-50%); font-size: ${this.fontSize}; }
78107
+ .input-box .before { color: rgba(194,194,194,1);position: absolute;padding-left: 12px; display: none;top: 50%;transform: translateY(-50%); font-size: ${this.fontSize}; }
78090
78108
  .input-box.empty .before { display: block; }
78091
78109
  .displayInput { position:relative;display:flex;align-items: center;height:100%;padding:${this.padding};font-size:${this.fontSize};width: fit-content;white-space: nowrap; }
78092
78110
  .displayInput.focus::after {content: '';position: absolute; right:-4px;top:50%;transform: translateY(-50%);width: 1px;height: 1em;background-color: #666;opacity: 1;animation: blink 1.2s infinite;}
78093
- .close-like { position: relative; display: inline-block; width: 12px; height: 12px; cursor: pointer; border-radius: 50%; border:1px solid #ccc; color: #fff; padding: 2px; display: none; }
78111
+ .close-like { position: absolute; display: inline-block; width: 12px; height: 12px; cursor: pointer; border-radius: 50%; border:1px solid #ccc; color: #fff; padding: 2px; display: none; right: 4px; }
78094
78112
  .close-like::before,
78095
78113
  .close-like::after {content: '';position: absolute;top: 50%;left: 50%;width: 7px;height: 1px;background-color: #ccc;transform-origin: center;}
78096
78114
  .close-like::before {transform: translate(-50%, -50%) rotate(45deg);}
@@ -78107,40 +78125,26 @@ class zJ extends HTMLElement {
78107
78125
  <span class="displayInput"></span>
78108
78126
  <span class="close-like"></span>
78109
78127
  </div>
78110
- `, this.inputBox = this.shadowRoot.querySelector(".input-box"), this.realInput = this.shadowRoot.querySelector(".realInput"), this.displayInput = this.shadowRoot.querySelector(".displayInput"), this.closeDom = this.shadowRoot.querySelector(".close-like");
78111
- let t = !1;
78128
+ `, this.inputBox = this.shadowRoot.querySelector(".input-box"), this.realInput = this.shadowRoot.querySelector(".realInput"), this.displayInput = this.shadowRoot.querySelector(".displayInput"), this.closeDom = this.shadowRoot.querySelector(".close-like"), this.placeholder && (this.shadowRoot.querySelector(".input-box .before").innerText = this.placeholder, this.inputBox.classList.add("empty")), this.value && (this.displayInput.innerText = this.value, this.realInput.value = this.value, this.inputBox.classList.remove("empty"));
78129
+ let r = !1;
78112
78130
  this.inputBox.addEventListener("click", () => {
78113
78131
  this.displayInput.classList.add("focus"), this.realInput.focus({ preventScroll: !0 });
78114
78132
  }), this.realInput.addEventListener("blur", () => {
78115
78133
  this.displayInput.classList.remove("focus"), this.emitBlur();
78116
78134
  }), this.realInput.addEventListener("compositionstart", () => {
78117
- t = !0, this.realInput.value = "";
78135
+ r = !0, this.realInput.value = "";
78118
78136
  }), this.realInput.addEventListener("compositionend", () => {
78119
- t = !1, this.realInput.value = "";
78120
- }), this.realInput.addEventListener("input", (n) => {
78121
- if (t) return;
78122
- const o = Date.now(), r = n.target.value;
78123
- r ? this.inputTimestamps.push(o) : this.inputTimestamps = [], r ? this.inputBox.classList.remove("empty") : this.inputBox.classList.add("empty"), this.displayInput.innerText = r, this.emitChange(r), this.isScanInput() && !this.timer && (this.timer = setTimeout(() => {
78137
+ r = !1, this.realInput.value = "";
78138
+ }), this.realInput.addEventListener("input", (i) => {
78139
+ if (r) return;
78140
+ const l = Date.now(), s = i.target.value;
78141
+ s ? this.inputTimestamps.push(l) : this.inputTimestamps = [], s ? this.inputBox.classList.remove("empty") : this.inputBox.classList.add("empty"), this.displayInput.innerText = s, this.emitChange(s), this.isScanInput() && !this.timer && (this.timer = setTimeout(() => {
78124
78142
  console.log("扫码完毕"), this.emitScanend();
78125
78143
  }, 600));
78126
- }), this.realInput.addEventListener("paste", (n) => n.preventDefault()), this.closeDom.addEventListener("click", (n) => {
78127
- n.preventDefault(), t = !1, this.displayInput.innerText = "", this.realInput.value = "", this.inputBox.classList.add("empty"), this.emitChange("");
78144
+ }), this.realInput.addEventListener("paste", (i) => i.preventDefault()), this.closeDom.addEventListener("click", (i) => {
78145
+ i.preventDefault(), r = !1, this.displayInput.innerText = "", this.realInput.value = "", this.inputBox.classList.add("empty"), this.inputTimestamps = [], this.emitChange("");
78128
78146
  });
78129
78147
  }
78130
- static get observedAttributes() {
78131
- return ["placeholder", "value", "style"];
78132
- }
78133
- isScanInput() {
78134
- const t = this.inputTimestamps, n = t.length, o = 100;
78135
- if (n < 4)
78136
- return !1;
78137
- const i = t[0];
78138
- return t[t.length - 1] - i <= o;
78139
- }
78140
- // 处理配置
78141
- attributeChangedCallback(t, n, o) {
78142
- n && !n.includes("{{") && (this[t] = n), o && !o.includes("{{") && (this[t] = o), t === "placeholder" && this.placeholder && (this.shadowRoot.querySelector(".input-box .before").innerText = this.placeholder, this.inputBox.classList.add("empty")), t === "value" && this.value && (this.displayInput.innerText = this.value, this.realInput.value = this.value, this.inputBox.classList.remove("empty"));
78143
- }
78144
78148
  emitChange(t) {
78145
78149
  this.dispatchEvent(new CustomEvent("change", {
78146
78150
  bubbles: !1,