NumberKeyboardKey.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. var import_use_touch = require("../composables/use-touch");
  27. var import_loading = require("../loading");
  28. const [name, bem] = (0, import_utils.createNamespace)("key");
  29. const CollapseIcon = (0, import_vue.createVNode)("svg", {
  30. "class": bem("collapse-icon"),
  31. "viewBox": "0 0 30 24"
  32. }, [(0, import_vue.createVNode)("path", {
  33. "d": "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
  34. "fill": "currentColor"
  35. }, null)]);
  36. const DeleteIcon = (0, import_vue.createVNode)("svg", {
  37. "class": bem("delete-icon"),
  38. "viewBox": "0 0 32 22"
  39. }, [(0, import_vue.createVNode)("path", {
  40. "d": "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
  41. "fill": "currentColor"
  42. }, null)]);
  43. var stdin_default = (0, import_vue2.defineComponent)({
  44. name,
  45. props: {
  46. type: String,
  47. text: import_utils.numericProp,
  48. color: String,
  49. wider: Boolean,
  50. large: Boolean,
  51. loading: Boolean
  52. },
  53. emits: ["press"],
  54. setup(props, {
  55. emit,
  56. slots
  57. }) {
  58. const active = (0, import_vue2.ref)(false);
  59. const touch = (0, import_use_touch.useTouch)();
  60. const onTouchStart = (event) => {
  61. touch.start(event);
  62. active.value = true;
  63. };
  64. const onTouchMove = (event) => {
  65. touch.move(event);
  66. if (touch.direction.value) {
  67. active.value = false;
  68. }
  69. };
  70. const onTouchEnd = (event) => {
  71. if (active.value) {
  72. if (!slots.default) {
  73. (0, import_utils.preventDefault)(event);
  74. }
  75. active.value = false;
  76. emit("press", props.text, props.type);
  77. }
  78. };
  79. const renderContent = () => {
  80. if (props.loading) {
  81. return (0, import_vue.createVNode)(import_loading.Loading, {
  82. "class": bem("loading-icon")
  83. }, null);
  84. }
  85. const text = slots.default ? slots.default() : props.text;
  86. switch (props.type) {
  87. case "delete":
  88. return text || DeleteIcon;
  89. case "extra":
  90. return text || CollapseIcon;
  91. default:
  92. return text;
  93. }
  94. };
  95. return () => (0, import_vue.createVNode)("div", {
  96. "class": bem("wrapper", {
  97. wider: props.wider
  98. }),
  99. "onTouchstartPassive": onTouchStart,
  100. "onTouchmovePassive": onTouchMove,
  101. "onTouchend": onTouchEnd,
  102. "onTouchcancel": onTouchEnd
  103. }, [(0, import_vue.createVNode)("div", {
  104. "role": "button",
  105. "tabindex": 0,
  106. "class": bem([props.color, {
  107. large: props.large,
  108. active: active.value,
  109. delete: props.type === "delete"
  110. }])
  111. }, [renderContent()])]);
  112. }
  113. });