statusUtils.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import { P as s, a as p, m as $ } from "./index2.js";
  2. import { defineComponent as S, shallowRef as O, createVNode as h, ref as m, watch as M, computed as b } from "vue";
  3. var K = function(t, a) {
  4. var o = {};
  5. for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && a.indexOf(n) < 0 && (o[n] = t[n]);
  6. if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, n = Object.getOwnPropertySymbols(t); l < n.length; l++)
  7. a.indexOf(n[l]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[l]) && (o[n[l]] = t[n[l]]);
  8. return o;
  9. };
  10. const z = S({
  11. compatConfig: {
  12. MODE: 3
  13. },
  14. // inheritAttrs: false,
  15. props: {
  16. disabled: s.looseBool,
  17. type: s.string,
  18. value: s.any,
  19. tag: {
  20. type: String,
  21. default: "input"
  22. },
  23. size: s.string,
  24. onChange: Function,
  25. onInput: Function,
  26. onBlur: Function,
  27. onFocus: Function,
  28. onKeydown: Function,
  29. onCompositionstart: Function,
  30. onCompositionend: Function,
  31. onKeyup: Function,
  32. onPaste: Function,
  33. onMousedown: Function
  34. },
  35. emits: ["change", "input", "blur", "keydown", "focus", "compositionstart", "compositionend", "keyup", "paste", "mousedown"],
  36. setup(t, a) {
  37. let {
  38. expose: o
  39. } = a;
  40. const n = O(null);
  41. return o({
  42. focus: () => {
  43. n.value && n.value.focus();
  44. },
  45. blur: () => {
  46. n.value && n.value.blur();
  47. },
  48. input: n,
  49. setSelectionRange: (u, c, d) => {
  50. var v;
  51. (v = n.value) === null || v === void 0 || v.setSelectionRange(u, c, d);
  52. },
  53. select: () => {
  54. var u;
  55. (u = n.value) === null || u === void 0 || u.select();
  56. },
  57. getSelectionStart: () => {
  58. var u;
  59. return (u = n.value) === null || u === void 0 ? void 0 : u.selectionStart;
  60. },
  61. getSelectionEnd: () => {
  62. var u;
  63. return (u = n.value) === null || u === void 0 ? void 0 : u.selectionEnd;
  64. },
  65. getScrollTop: () => {
  66. var u;
  67. return (u = n.value) === null || u === void 0 ? void 0 : u.scrollTop;
  68. }
  69. }), () => {
  70. const {
  71. tag: u,
  72. value: c
  73. } = t, d = K(t, ["tag", "value"]);
  74. return h(u, p(p({}, d), {}, {
  75. ref: n,
  76. value: c
  77. }), null);
  78. };
  79. }
  80. });
  81. function x(t) {
  82. return Object.keys(t).reduce((a, o) => {
  83. const n = t[o];
  84. return typeof n == "undefined" || n === null || (a += `${o}: ${t[o]};`), a;
  85. }, "");
  86. }
  87. var D = function(t, a) {
  88. var o = {};
  89. for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && a.indexOf(n) < 0 && (o[n] = t[n]);
  90. if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, n = Object.getOwnPropertySymbols(t); l < n.length; l++)
  91. a.indexOf(n[l]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[l]) && (o[n[l]] = t[n[l]]);
  92. return o;
  93. };
  94. const A = S({
  95. compatConfig: {
  96. MODE: 3
  97. },
  98. inheritAttrs: !1,
  99. props: {
  100. disabled: s.looseBool,
  101. type: s.string,
  102. value: s.any,
  103. lazy: s.bool.def(!0),
  104. tag: {
  105. type: String,
  106. default: "input"
  107. },
  108. size: s.string,
  109. style: s.oneOfType([String, Object]),
  110. class: s.string
  111. },
  112. emits: ["change", "input", "blur", "keydown", "focus", "compositionstart", "compositionend", "keyup", "paste", "mousedown"],
  113. setup(t, a) {
  114. let {
  115. emit: o,
  116. attrs: n,
  117. expose: l
  118. } = a;
  119. const r = O(null), f = m(), i = m(!1);
  120. M([() => t.value, i], () => {
  121. i.value || (f.value = t.value);
  122. }, {
  123. immediate: !0
  124. });
  125. const u = (e) => {
  126. o("change", e);
  127. }, c = (e) => {
  128. i.value = !0, e.target.composing = !0, o("compositionstart", e);
  129. }, d = (e) => {
  130. i.value = !1, e.target.composing = !1, o("compositionend", e);
  131. const g = document.createEvent("HTMLEvents");
  132. g.initEvent("input", !0, !0), e.target.dispatchEvent(g), u(e);
  133. }, v = (e) => {
  134. if (i.value && t.lazy) {
  135. f.value = e.target.value;
  136. return;
  137. }
  138. o("input", e);
  139. }, w = (e) => {
  140. o("blur", e);
  141. }, _ = (e) => {
  142. o("focus", e);
  143. }, F = () => {
  144. r.value && r.value.focus();
  145. }, P = () => {
  146. r.value && r.value.blur();
  147. }, j = (e) => {
  148. o("keydown", e);
  149. }, E = (e) => {
  150. o("keyup", e);
  151. }, C = (e, g, R) => {
  152. var y;
  153. (y = r.value) === null || y === void 0 || y.setSelectionRange(e, g, R);
  154. }, T = () => {
  155. var e;
  156. (e = r.value) === null || e === void 0 || e.select();
  157. };
  158. l({
  159. focus: F,
  160. blur: P,
  161. input: b(() => {
  162. var e;
  163. return (e = r.value) === null || e === void 0 ? void 0 : e.input;
  164. }),
  165. setSelectionRange: C,
  166. select: T,
  167. getSelectionStart: () => {
  168. var e;
  169. return (e = r.value) === null || e === void 0 ? void 0 : e.getSelectionStart();
  170. },
  171. getSelectionEnd: () => {
  172. var e;
  173. return (e = r.value) === null || e === void 0 ? void 0 : e.getSelectionEnd();
  174. },
  175. getScrollTop: () => {
  176. var e;
  177. return (e = r.value) === null || e === void 0 ? void 0 : e.getScrollTop();
  178. }
  179. });
  180. const k = (e) => {
  181. o("mousedown", e);
  182. }, B = (e) => {
  183. o("paste", e);
  184. }, I = b(() => t.style && typeof t.style != "string" ? x(t.style) : t.style);
  185. return () => {
  186. const e = D(t, ["style", "lazy"]);
  187. return h(z, p(p(p({}, e), n), {}, {
  188. style: I.value,
  189. onInput: v,
  190. onChange: u,
  191. onBlur: w,
  192. onFocus: _,
  193. ref: r,
  194. value: f.value,
  195. onCompositionstart: c,
  196. onCompositionend: d,
  197. onKeyup: E,
  198. onKeydown: j,
  199. onPaste: B,
  200. onMousedown: k
  201. }), null);
  202. };
  203. }
  204. });
  205. function H(t, a, o) {
  206. return $({
  207. [`${t}-status-success`]: a === "success",
  208. [`${t}-status-warning`]: a === "warning",
  209. [`${t}-status-error`]: a === "error",
  210. [`${t}-status-validating`]: a === "validating",
  211. [`${t}-has-feedback`]: o
  212. });
  213. }
  214. const L = (t, a) => a || t;
  215. export {
  216. A as B,
  217. H as a,
  218. L as g
  219. };