PasswordInput.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. default: () => stdin_default
  21. });
  22. module.exports = __toCommonJS(stdin_exports);
  23. var import_vue = require("vue");
  24. var import_vue2 = require("vue");
  25. var import_utils = require("../utils");
  26. const [name, bem] = (0, import_utils.createNamespace)("password-input");
  27. const passwordInputProps = {
  28. info: String,
  29. mask: import_utils.truthProp,
  30. value: (0, import_utils.makeStringProp)(""),
  31. gutter: import_utils.numericProp,
  32. length: (0, import_utils.makeNumericProp)(6),
  33. focused: Boolean,
  34. errorInfo: String
  35. };
  36. var stdin_default = (0, import_vue2.defineComponent)({
  37. name,
  38. props: passwordInputProps,
  39. emits: ["focus"],
  40. setup(props, {
  41. emit
  42. }) {
  43. const onTouchStart = (event) => {
  44. event.stopPropagation();
  45. emit("focus", event);
  46. };
  47. const renderPoints = () => {
  48. const Points = [];
  49. const {
  50. mask,
  51. value,
  52. length,
  53. gutter,
  54. focused
  55. } = props;
  56. for (let i = 0; i < length; i++) {
  57. const char = value[i];
  58. const showBorder = i !== 0 && !gutter;
  59. const showCursor = focused && i === value.length;
  60. let style;
  61. if (i !== 0 && gutter) {
  62. style = {
  63. marginLeft: (0, import_utils.addUnit)(gutter)
  64. };
  65. }
  66. Points.push((0, import_vue.createVNode)("li", {
  67. "class": [{
  68. [import_utils.BORDER_LEFT]: showBorder
  69. }, bem("item", {
  70. focus: showCursor
  71. })],
  72. "style": style
  73. }, [mask ? (0, import_vue.createVNode)("i", {
  74. "style": {
  75. visibility: char ? "visible" : "hidden"
  76. }
  77. }, null) : char, showCursor && (0, import_vue.createVNode)("div", {
  78. "class": bem("cursor")
  79. }, null)]));
  80. }
  81. return Points;
  82. };
  83. return () => {
  84. const info = props.errorInfo || props.info;
  85. return (0, import_vue.createVNode)("div", {
  86. "class": bem()
  87. }, [(0, import_vue.createVNode)("ul", {
  88. "class": [bem("security"), {
  89. [import_utils.BORDER_SURROUND]: !props.gutter
  90. }],
  91. "onTouchstartPassive": onTouchStart
  92. }, [renderPoints()]), info && (0, import_vue.createVNode)("div", {
  93. "class": bem(props.errorInfo ? "error-info" : "info")
  94. }, [info])]);
  95. };
  96. }
  97. });