| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- import { P as i, _ as f } from "./index2.js";
- import { defineComponent as O, shallowRef as w, createVNode as h, ref as b, watch as k, computed as S } from "vue";
- var z = function(n, u) {
- var o = {};
- for (var t in n) Object.prototype.hasOwnProperty.call(n, t) && u.indexOf(t) < 0 && (o[t] = n[t]);
- if (n != null && typeof Object.getOwnPropertySymbols == "function") for (var r = 0, t = Object.getOwnPropertySymbols(n); r < t.length; r++)
- u.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, t[r]) && (o[t[r]] = n[t[r]]);
- return o;
- };
- const K = O({
- compatConfig: {
- MODE: 3
- },
- // inheritAttrs: false,
- props: {
- disabled: i.looseBool,
- type: i.string,
- value: i.any,
- tag: {
- type: String,
- default: "input"
- },
- size: i.string,
- onChange: Function,
- onInput: Function,
- onBlur: Function,
- onFocus: Function,
- onKeydown: Function,
- onCompositionstart: Function,
- onCompositionend: Function,
- onKeyup: Function,
- onPaste: Function,
- onMousedown: Function
- },
- emits: ["change", "input", "blur", "keydown", "focus", "compositionstart", "compositionend", "keyup", "paste", "mousedown"],
- setup(n, u) {
- let {
- expose: o
- } = u;
- const t = w(null);
- return o({
- focus: () => {
- t.value && t.value.focus();
- },
- blur: () => {
- t.value && t.value.blur();
- },
- input: t,
- setSelectionRange: (l, c, d) => {
- var v;
- (v = t.value) === null || v === void 0 || v.setSelectionRange(l, c, d);
- },
- select: () => {
- var l;
- (l = t.value) === null || l === void 0 || l.select();
- },
- getSelectionStart: () => {
- var l;
- return (l = t.value) === null || l === void 0 ? void 0 : l.selectionStart;
- },
- getSelectionEnd: () => {
- var l;
- return (l = t.value) === null || l === void 0 ? void 0 : l.selectionEnd;
- },
- getScrollTop: () => {
- var l;
- return (l = t.value) === null || l === void 0 ? void 0 : l.scrollTop;
- }
- }), () => {
- const {
- tag: l,
- value: c
- } = n, d = z(n, ["tag", "value"]);
- return h(l, f(f({}, d), {}, {
- ref: t,
- value: c
- }), null);
- };
- }
- });
- function $(n) {
- const u = n.getBoundingClientRect(), o = document.documentElement;
- return {
- left: u.left + (window.scrollX || o.scrollLeft) - (o.clientLeft || document.body.clientLeft || 0),
- top: u.top + (window.scrollY || o.scrollTop) - (o.clientTop || document.body.clientTop || 0)
- };
- }
- function M(n) {
- return Object.keys(n).reduce((u, o) => {
- const t = n[o];
- return typeof t == "undefined" || t === null || (u += `${o}: ${n[o]};`), u;
- }, "");
- }
- var L = function(n, u) {
- var o = {};
- for (var t in n) Object.prototype.hasOwnProperty.call(n, t) && u.indexOf(t) < 0 && (o[t] = n[t]);
- if (n != null && typeof Object.getOwnPropertySymbols == "function") for (var r = 0, t = Object.getOwnPropertySymbols(n); r < t.length; r++)
- u.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, t[r]) && (o[t[r]] = n[t[r]]);
- return o;
- };
- const A = O({
- compatConfig: {
- MODE: 3
- },
- inheritAttrs: !1,
- props: {
- disabled: i.looseBool,
- type: i.string,
- value: i.any,
- lazy: i.bool.def(!0),
- tag: {
- type: String,
- default: "input"
- },
- size: i.string,
- style: i.oneOfType([String, Object]),
- class: i.string
- },
- emits: ["change", "input", "blur", "keydown", "focus", "compositionstart", "compositionend", "keyup", "paste", "mousedown"],
- setup(n, u) {
- let {
- emit: o,
- attrs: t,
- expose: r
- } = u;
- const a = w(null), y = b(), s = b(!1);
- k([() => n.value, s], () => {
- s.value || (y.value = n.value);
- }, {
- immediate: !0
- });
- const l = (e) => {
- o("change", e);
- }, c = (e) => {
- s.value = !0, e.target.composing = !0, o("compositionstart", e);
- }, d = (e) => {
- s.value = !1, e.target.composing = !1, o("compositionend", e);
- const p = document.createEvent("HTMLEvents");
- p.initEvent("input", !0, !0), e.target.dispatchEvent(p), l(e);
- }, v = (e) => {
- if (s.value && n.lazy) {
- y.value = e.target.value;
- return;
- }
- o("input", e);
- }, _ = (e) => {
- o("blur", e);
- }, C = (e) => {
- o("focus", e);
- }, E = () => {
- a.value && a.value.focus();
- }, F = () => {
- a.value && a.value.blur();
- }, P = (e) => {
- o("keydown", e);
- }, j = (e) => {
- o("keyup", e);
- }, T = (e, p, g) => {
- var m;
- (m = a.value) === null || m === void 0 || m.setSelectionRange(e, p, g);
- }, B = () => {
- var e;
- (e = a.value) === null || e === void 0 || e.select();
- };
- r({
- focus: E,
- blur: F,
- input: S(() => {
- var e;
- return (e = a.value) === null || e === void 0 ? void 0 : e.input;
- }),
- setSelectionRange: T,
- select: B,
- getSelectionStart: () => {
- var e;
- return (e = a.value) === null || e === void 0 ? void 0 : e.getSelectionStart();
- },
- getSelectionEnd: () => {
- var e;
- return (e = a.value) === null || e === void 0 ? void 0 : e.getSelectionEnd();
- },
- getScrollTop: () => {
- var e;
- return (e = a.value) === null || e === void 0 ? void 0 : e.getScrollTop();
- }
- });
- const R = (e) => {
- o("mousedown", e);
- }, x = (e) => {
- o("paste", e);
- }, I = S(() => n.style && typeof n.style != "string" ? M(n.style) : n.style);
- return () => {
- const {
- style: e,
- lazy: p
- } = n, g = L(n, ["style", "lazy"]);
- return h(K, f(f(f({}, g), t), {}, {
- style: I.value,
- onInput: v,
- onChange: l,
- onBlur: _,
- onFocus: C,
- ref: a,
- value: y.value,
- onCompositionstart: c,
- onCompositionend: d,
- onKeyup: j,
- onKeydown: P,
- onPaste: x,
- onMousedown: R
- }), null);
- };
- }
- });
- export {
- A as B,
- $ as g
- };
|