File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed
components/content/docs/components/inputOTP Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 7
7
InputOTPInputField ,
8
8
Toast ,
9
9
} from " ~/src" ;
10
- import { defaultInputOTPCode } from " ./inputOTPCode" ;
10
+ import { inputOtpSeparatorCode } from " ./inputOTPCode" ;
11
11
12
12
const value = ref <string []>([]);
13
13
@@ -17,7 +17,7 @@ const handleComplete = (e: string[]) => {
17
17
</script >
18
18
19
19
<template >
20
- <CodeHighlightWithPreview :code =" defaultInputOTPCode " >
20
+ <CodeHighlightWithPreview :code =" inputOtpSeparatorCode " >
21
21
<div class =" flex items-center justify-center" >
22
22
<InputOTP
23
23
id =" pin-input"
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function handleComplete(e: string[]) {
11
11
</script>
12
12
13
13
<template>
14
- <InputOTP id="pin-input" :model-value ="value" @complete="handleComplete">
14
+ <InputOTP id="pin-input" v-model ="value" @complete="handleComplete">
15
15
<InputOTPGroup>
16
16
<template v-for="(id, index) in 5" :key="id">
17
17
<InputOTPInputField :index="index" />
@@ -21,4 +21,41 @@ function handleComplete(e: string[]) {
21
21
</template>` ,
22
22
} ;
23
23
24
- export { defaultInputOTPCode } ;
24
+ const inputOtpSeparatorCode = {
25
+ "DefaultInputOTP.vue" : `<script lang="ts" setup>
26
+ import {
27
+ InputOTP,
28
+ InputOTPDivider,
29
+ InputOTPGroup,
30
+ InputOTPInputField,
31
+ Toast,
32
+ } from "keep-vue";
33
+ import { defaultInputOTPCode } from "./inputOTPCode";
34
+
35
+ const value = ref<string[]>([]);
36
+
37
+ const handleComplete = (e: string[]) => {
38
+ Toast(e.join(""));
39
+ };
40
+ </script>
41
+
42
+ <template>
43
+ <InputOTP
44
+ id="pin-input"
45
+ v-model="value"
46
+ placeholder="○"
47
+ @complete="handleComplete">
48
+ <InputOTPGroup>
49
+ <template v-for="(id, index) in 5" :key="id">
50
+ <InputOTPInputField :index="index" />
51
+ <template v-if="index !== 4">
52
+ <InputOTPDivider />
53
+ </template>
54
+ </template>
55
+ </InputOTPGroup>
56
+ </InputOTP>
57
+ </template>
58
+ ` ,
59
+ } ;
60
+
61
+ export { defaultInputOTPCode , inputOtpSeparatorCode } ;
You can’t perform that action at this time.
0 commit comments