first commit
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
import * as vue from "vue";
|
||||
|
||||
//#region ../../packages/hooks/use-composition/index.d.ts
|
||||
interface UseCompositionOptions {
|
||||
afterComposition: (event: CompositionEvent) => void;
|
||||
emit?: ((event: 'compositionstart', evt: CompositionEvent) => void) & ((event: 'compositionupdate', evt: CompositionEvent) => void) & ((event: 'compositionend', evt: CompositionEvent) => void);
|
||||
}
|
||||
declare function useComposition({
|
||||
afterComposition,
|
||||
emit
|
||||
}: UseCompositionOptions): {
|
||||
isComposing: vue.Ref<boolean, boolean>;
|
||||
handleComposition: (event: CompositionEvent) => void;
|
||||
handleCompositionStart: (event: CompositionEvent) => void;
|
||||
handleCompositionUpdate: (event: CompositionEvent) => void;
|
||||
handleCompositionEnd: (event: CompositionEvent) => void;
|
||||
};
|
||||
//#endregion
|
||||
export { useComposition };
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
||||
let vue = require("vue");
|
||||
|
||||
//#region ../../packages/hooks/use-composition/index.ts
|
||||
function useComposition({ afterComposition, emit }) {
|
||||
const isComposing = (0, vue.ref)(false);
|
||||
const handleCompositionStart = (event) => {
|
||||
emit?.("compositionstart", event);
|
||||
isComposing.value = true;
|
||||
};
|
||||
const handleCompositionUpdate = (event) => {
|
||||
emit?.("compositionupdate", event);
|
||||
isComposing.value = true;
|
||||
};
|
||||
const handleCompositionEnd = (event) => {
|
||||
emit?.("compositionend", event);
|
||||
if (isComposing.value) {
|
||||
isComposing.value = false;
|
||||
(0, vue.nextTick)(() => afterComposition(event));
|
||||
}
|
||||
};
|
||||
const handleComposition = (event) => {
|
||||
event.type === "compositionend" ? handleCompositionEnd(event) : handleCompositionUpdate(event);
|
||||
};
|
||||
return {
|
||||
isComposing,
|
||||
handleComposition,
|
||||
handleCompositionStart,
|
||||
handleCompositionUpdate,
|
||||
handleCompositionEnd
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.useComposition = useComposition;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":[],"sources":["../../../../../packages/hooks/use-composition/index.ts"],"sourcesContent":["import { nextTick, ref } from 'vue'\n\ninterface UseCompositionOptions {\n afterComposition: (event: CompositionEvent) => void\n emit?: ((event: 'compositionstart', evt: CompositionEvent) => void) &\n ((event: 'compositionupdate', evt: CompositionEvent) => void) &\n ((event: 'compositionend', evt: CompositionEvent) => void)\n}\n\nexport function useComposition({\n afterComposition,\n emit,\n}: UseCompositionOptions) {\n const isComposing = ref(false)\n\n const handleCompositionStart = (event: CompositionEvent) => {\n emit?.('compositionstart', event)\n isComposing.value = true\n }\n\n const handleCompositionUpdate = (event: CompositionEvent) => {\n emit?.('compositionupdate', event)\n isComposing.value = true\n }\n\n const handleCompositionEnd = (event: CompositionEvent) => {\n emit?.('compositionend', event)\n if (isComposing.value) {\n isComposing.value = false\n nextTick(() => afterComposition(event))\n }\n }\n\n const handleComposition = (event: CompositionEvent) => {\n event.type === 'compositionend'\n ? handleCompositionEnd(event)\n : handleCompositionUpdate(event)\n }\n\n return {\n isComposing,\n handleComposition,\n handleCompositionStart,\n handleCompositionUpdate,\n handleCompositionEnd,\n }\n}\n"],"mappings":";;;;;AASA,SAAgB,eAAe,EAC7B,kBACA,QACwB;CACxB,MAAM,2BAAkB,MAAM;CAE9B,MAAM,0BAA0B,UAA4B;AAC1D,SAAO,oBAAoB,MAAM;AACjC,cAAY,QAAQ;;CAGtB,MAAM,2BAA2B,UAA4B;AAC3D,SAAO,qBAAqB,MAAM;AAClC,cAAY,QAAQ;;CAGtB,MAAM,wBAAwB,UAA4B;AACxD,SAAO,kBAAkB,MAAM;AAC/B,MAAI,YAAY,OAAO;AACrB,eAAY,QAAQ;AACpB,2BAAe,iBAAiB,MAAM,CAAC;;;CAI3C,MAAM,qBAAqB,UAA4B;AACrD,QAAM,SAAS,mBACX,qBAAqB,MAAM,GAC3B,wBAAwB,MAAM;;AAGpC,QAAO;EACL;EACA;EACA;EACA;EACA;EACD"}
|
||||
Reference in New Issue
Block a user