完全跑通1.0版本
This commit is contained in:
6
frontend/node_modules/element-plus/es/hooks/use-cursor/index.d.ts
generated
vendored
Normal file
6
frontend/node_modules/element-plus/es/hooks/use-cursor/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ShallowRef } from "vue";
|
||||
|
||||
//#region ../../packages/hooks/use-cursor/index.d.ts
|
||||
declare function useCursor(input: ShallowRef<HTMLInputElement | undefined>): [() => void, () => void];
|
||||
//#endregion
|
||||
export { useCursor };
|
||||
36
frontend/node_modules/element-plus/es/hooks/use-cursor/index.mjs
generated
vendored
Normal file
36
frontend/node_modules/element-plus/es/hooks/use-cursor/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
//#region ../../packages/hooks/use-cursor/index.ts
|
||||
function useCursor(input) {
|
||||
let selectionInfo;
|
||||
function recordCursor() {
|
||||
if (input.value == void 0) return;
|
||||
const { selectionStart, selectionEnd, value } = input.value;
|
||||
if (selectionStart == null || selectionEnd == null) return;
|
||||
selectionInfo = {
|
||||
selectionStart,
|
||||
selectionEnd,
|
||||
value,
|
||||
beforeTxt: value.slice(0, Math.max(0, selectionStart)),
|
||||
afterTxt: value.slice(Math.max(0, selectionEnd))
|
||||
};
|
||||
}
|
||||
function setCursor() {
|
||||
if (input.value == void 0 || selectionInfo == void 0) return;
|
||||
const { value } = input.value;
|
||||
const { beforeTxt, afterTxt, selectionStart } = selectionInfo;
|
||||
if (beforeTxt == void 0 || afterTxt == void 0 || selectionStart == void 0) return;
|
||||
let startPos = value.length;
|
||||
if (value.endsWith(afterTxt)) startPos = value.length - afterTxt.length;
|
||||
else if (value.startsWith(beforeTxt)) startPos = beforeTxt.length;
|
||||
else {
|
||||
const beforeLastChar = beforeTxt[selectionStart - 1];
|
||||
const newIndex = value.indexOf(beforeLastChar, selectionStart - 1);
|
||||
if (newIndex !== -1) startPos = newIndex + 1;
|
||||
}
|
||||
input.value.setSelectionRange(startPos, startPos);
|
||||
}
|
||||
return [recordCursor, setCursor];
|
||||
}
|
||||
//#endregion
|
||||
export { useCursor };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/hooks/use-cursor/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/hooks/use-cursor/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/hooks/use-cursor/index.ts"],"sourcesContent":["import type { ShallowRef } from 'vue'\n\ninterface SelectionInfo {\n selectionStart?: number\n selectionEnd?: number\n value?: string\n beforeTxt?: string\n afterTxt?: string\n}\n\n// Keep input cursor in the correct position when we use formatter.\nexport function useCursor(\n input: ShallowRef<HTMLInputElement | undefined>\n): [() => void, () => void] {\n let selectionInfo: SelectionInfo\n function recordCursor() {\n if (input.value == undefined) return\n\n const { selectionStart, selectionEnd, value } = input.value\n\n if (selectionStart == null || selectionEnd == null) return\n\n const beforeTxt = value.slice(0, Math.max(0, selectionStart))\n const afterTxt = value.slice(Math.max(0, selectionEnd))\n\n selectionInfo = {\n selectionStart,\n selectionEnd,\n value,\n beforeTxt,\n afterTxt,\n }\n }\n function setCursor() {\n if (input.value == undefined || selectionInfo == undefined) return\n\n const { value } = input.value\n const { beforeTxt, afterTxt, selectionStart } = selectionInfo\n\n if (\n beforeTxt == undefined ||\n afterTxt == undefined ||\n selectionStart == undefined\n )\n return\n\n let startPos = value.length\n\n if (value.endsWith(afterTxt)) {\n startPos = value.length - afterTxt.length\n } else if (value.startsWith(beforeTxt)) {\n startPos = beforeTxt.length\n } else {\n const beforeLastChar = beforeTxt[selectionStart - 1]\n const newIndex = value.indexOf(beforeLastChar, selectionStart - 1)\n if (newIndex !== -1) {\n startPos = newIndex + 1\n }\n }\n\n input.value.setSelectionRange(startPos, startPos)\n }\n\n return [recordCursor, setCursor]\n}\n"],"mappings":";AAWA,SAAgB,UACd,OAC0B;CAC1B,IAAI;CACJ,SAAS,eAAe;EACtB,IAAI,MAAM,SAAS,KAAA,GAAW;EAE9B,MAAM,EAAE,gBAAgB,cAAc,UAAU,MAAM;EAEtD,IAAI,kBAAkB,QAAQ,gBAAgB,MAAM;EAKpD,gBAAgB;GACd;GACA;GACA;GACA,WAPgB,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,eAAe,CAOjD;GACT,UAPe,MAAM,MAAM,KAAK,IAAI,GAAG,aAAa,CAO5C;GACT;;CAEH,SAAS,YAAY;EACnB,IAAI,MAAM,SAAS,KAAA,KAAa,iBAAiB,KAAA,GAAW;EAE5D,MAAM,EAAE,UAAU,MAAM;EACxB,MAAM,EAAE,WAAW,UAAU,mBAAmB;EAEhD,IACE,aAAa,KAAA,KACb,YAAY,KAAA,KACZ,kBAAkB,KAAA,GAElB;EAEF,IAAI,WAAW,MAAM;EAErB,IAAI,MAAM,SAAS,SAAS,EAC1B,WAAW,MAAM,SAAS,SAAS;OAC9B,IAAI,MAAM,WAAW,UAAU,EACpC,WAAW,UAAU;OAChB;GACL,MAAM,iBAAiB,UAAU,iBAAiB;GAClD,MAAM,WAAW,MAAM,QAAQ,gBAAgB,iBAAiB,EAAE;GAClE,IAAI,aAAa,IACf,WAAW,WAAW;;EAI1B,MAAM,MAAM,kBAAkB,UAAU,SAAS;;CAGnD,OAAO,CAAC,cAAc,UAAU"}
|
||||
Reference in New Issue
Block a user