You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
2.9 KiB
1 line
2.9 KiB
2 months ago
|
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-composition/index.ts"],"sourcesContent":["import { nextTick, ref } from 'vue'\nimport { isKorean } from '@element-plus/utils'\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 const text = (event.target as HTMLInputElement)?.value\n const lastCharacter = text[text.length - 1] || ''\n isComposing.value = !isKorean(lastCharacter)\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"],"names":["ref","isKorean","nextTick"],"mappings":";;;;;;;;AAEO,SAAS,cAAc,CAAC;AAC/B,EAAE,gBAAgB;AAClB,EAAE,IAAI;AACN,CAAC,EAAE;AACH,EAAE,MAAM,WAAW,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AACjC,EAAE,MAAM,sBAAsB,GAAG,CAAC,KAAK,KAAK;AAC5C,IAAI,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAC5D,I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