PasswordInput.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. passwordInputProps: () => passwordInputProps
  22. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = require("vue");
  25. var import_vue2 = require("vue");
  26. var import_utils = require("../utils");
  27. const [name, bem] = (0, import_utils.createNamespace)("password-input");
  28. const passwordInputProps = {
  29. info: String,
  30. mask: import_utils.truthProp,
  31. value: (0, import_utils.makeStringProp)(""),
  32. gutter: import_utils.numericProp,
  33. length: (0, import_utils.makeNumericProp)(6),
  34. focused: Boolean,
  35. errorInfo: String
  36. };
  37. var stdin_default = (0, import_vue2.defineComponent)({
  38. name,
  39. props: passwordInputProps,
  40. emits: ["focus"],
  41. setup(props, {
  42. emit
  43. }) {
  44. const onTouchStart = (event) => {
  45. event.stopPropagation();
  46. emit("focus", event);
  47. };
  48. const renderPoints = () => {
  49. const Points = [];
  50. const {
  51. mask,
  52. value,
  53. length,
  54. gutter,
  55. focused
  56. } = props;
  57. for (let i = 0; i < length; i++) {
  58. const char = value[i];
  59. const showBorder = i !== 0 && !gutter;
  60. const showCursor = focused && i === value.length;
  61. let style;
  62. if (i !== 0 && gutter) {
  63. style = {
  64. marginLeft: (0, import_utils.addUnit)(gutter)
  65. };
  66. }
  67. Points.push((0, import_vue.createVNode)("li", {
  68. "class": [{
  69. [import_utils.BORDER_LEFT]: showBorder
  70. }, bem("item", {
  71. focus: showCursor
  72. })],
  73. "style": style
  74. }, [mask ? (0, import_vue.createVNode)("i", {
  75. "style": {
  76. visibility: char ? "visible" : "hidden"
  77. }
  78. }, null) : char, showCursor && (0, import_vue.createVNode)("div", {
  79. "class": bem("cursor")
  80. }, null)]));
  81. }
  82. return Points;
  83. };
  84. return () => {
  85. const info = props.errorInfo || props.info;
  86. return (0, import_vue.createVNode)("div", {
  87. "class": bem()
  88. }, [(0, import_vue.createVNode)("ul", {
  89. "class": [bem("security"), {
  90. [import_utils.BORDER_SURROUND]: !props.gutter
  91. }],
  92. "onTouchstartPassive": onTouchStart
  93. }, [renderPoints()]), info && (0, import_vue.createVNode)("div", {
  94. "class": bem(props.errorInfo ? "error-info" : "info")
  95. }, [info])]);
  96. };
  97. }
  98. });