PromoCursed/node_modules/.cache/babel-loader/1f9d8a6037154928511ef44683f868db003ed1ca3a0561c3065eb9a8ec6a4f4b.json

1 line
8.2 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport raf from \"rc-util/es/raf\";\nimport Input from '../Input';\nconst OTPInput = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n value,\n onChange,\n onActiveChange,\n index,\n mask\n } = props,\n restProps = __rest(props, [\"value\", \"onChange\", \"onActiveChange\", \"index\", \"mask\"]);\n const internalValue = value && typeof mask === 'string' ? mask : value;\n const onInternalChange = e => {\n onChange(index, e.target.value);\n };\n // ========================== Ref ===========================\n const inputRef = React.useRef(null);\n React.useImperativeHandle(ref, () => inputRef.current);\n // ========================= Focus ==========================\n const syncSelection = () => {\n raf(() => {\n var _a;\n const inputEle = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;\n if (document.activeElement === inputEle && inputEle) {\n inputEle.select();\n }\n });\n };\n // ======================== Keyboard ========================\n const onInternalKeyDown = _ref => {\n let {\n key\n } = _ref;\n if (key === 'ArrowLeft') {\n onActiveChange(index - 1);\n } else if (key === 'ArrowRight') {\n onActiveChange(index + 1);\n }\n syncSelection();\n };\n const onInternalKeyUp = e => {\n if (e.key === 'Backspace' && !value) {\n onActiveChange(index - 1);\n }\n syncSelection();\n };\n // ========================= Render =========================\n return /*#__PURE__*/React.createElement(Input, Object.assign({}, restProps, {\n ref: inputRef,\n value: internalValue,\n onInput: onInternalChange,\n onFocus: syncSelection,\n onKeyDown: onInternalKeyDown,\n onKeyUp: onInternalKeyUp,\n onMouseDown: syncSelection,\n onMouseUp: syncSelection,\n type: mask === true ? 'password' : 'text'\n }));\n});\nexport default OTPInput;","map":{"version":3,"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","raf","Input","OTPInput","forwardRef","props","ref","value","onChange","onActiveChange","index","mask","restProps","internalValue","onInternalChange","target","inputRef","useRef","useImperativeHandle","current","syncSelection","_a","inputEle","input","document","activeElement","select","onInternalKeyDown","_ref","key","onInternalKeyUp","createElement","assign","onInput","onFocus","onKeyDown","onKeyUp","onMouseDown","onMouseUp","type"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/input/OTP/OTPInput.js"],"sourcesContent":["\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport raf from \"rc-util/es/raf\";\nimport Input from '../Input';\nconst OTPInput = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n value,\n onChange,\n onActiveChange,\n index,\n mask\n } = props,\n restProps = __rest(props, [\"value\", \"onChange\", \"onActiveChange\", \"index\", \"mask\"]);\n const internalValue = value && typeof mask === 'string' ? mask : v