Skip to content

Commit 6eaaef4

Browse files
committed
1,655th Commit
1 parent 29b46ba commit 6eaaef4

1 file changed

Lines changed: 82 additions & 7 deletions

File tree

  • app/src/routes/(backstage)/(library)/data-entry/input-mask

app/src/routes/(backstage)/(library)/data-entry/input-mask/+page.vue

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
2-
import { XBreadcrumb, XCard, XCode, XInputMask } from '@x/ui';
3-
import { reactive } from 'vue';
2+
import { XBreadcrumb, XCard, XCode, XDivider, XInputMask, XSelect } from '@x/ui';
3+
import { onMounted, reactive } from 'vue';
44
55
const flux = reactive({
66
numberMasked: '',
@@ -10,14 +10,49 @@ const flux = reactive({
1010
percentUnmasked: undefined,
1111
1212
phoneMasked: '',
13-
phoneUnmasked: '',
13+
phoneUnmasked: undefined as string | null | undefined,
14+
15+
phone2: '',
16+
phone2Options: [
17+
{
18+
label: 'United States (+1)',
19+
value: '{+1} (000) 000-0000',
20+
placeholder: '+1 (___) ___-____',
21+
},
22+
{
23+
label: 'Japan (+81)',
24+
value: '{+81} 00-0000-0000',
25+
placeholder: '+81 __-____-____',
26+
},
27+
{
28+
label: 'South Korea (+82)',
29+
value: '{+82} 00-0000-0000',
30+
placeholder: '+82 __-____-____',
31+
},
32+
{
33+
label: 'Taiwan (+886)',
34+
value: '{+886} 000-000-000',
35+
placeholder: '+886 ___-___-___',
36+
},
37+
],
38+
phone2Key: 1,
39+
phone2Masked: '',
40+
phone2Unmasked: undefined,
41+
phone2Placeholder: '',
1442
1543
usdMasked: '',
16-
usdUnmasked: '',
44+
usdUnmasked: undefined,
1745
1846
verificationCodeMasked: '',
1947
verificationCodeUnmasked: undefined,
2048
});
49+
50+
onMounted(() => {
51+
// mock data from the response
52+
const phoneUnmasked = '+12123456789';
53+
flux.phoneMasked = phoneUnmasked;
54+
flux.phoneUnmasked = phoneUnmasked;
55+
});
2156
</script>
2257

2358
<template>
@@ -92,14 +127,51 @@ const flux = reactive({
92127
<XInputMask
93128
v-model:masked="flux.phoneMasked"
94129
v-model:unmasked="flux.phoneUnmasked"
95-
:mask="{ mask: '+{1} (000) 000-0000' }"
130+
:mask="{ mask: '{+1} (000) 000-0000' }"
96131
label="Phone Label"
97132
placeholder="+1 (___) ___-____"
98133
/>
99134

100135
<div class="mt-1">
101136
<div>Masked: {{ flux.phoneMasked }}</div>
102-
<div>Unmasked: {{ flux.phoneUnmasked }}</div>
137+
<div>
138+
Unmasked: {{ flux.phoneUnmasked }}
139+
<XCode>{{ typeof flux.phoneUnmasked }}</XCode>
140+
</div>
141+
</div>
142+
143+
<XDivider />
144+
145+
<div class="flex flex-col md:flex-row gap-2">
146+
<XSelect
147+
v-model:value="flux.phone2"
148+
label="Phone 2 Label"
149+
:options="flux.phone2Options"
150+
@change="
151+
(_val, opt) => {
152+
flux.phone2Placeholder = opt.placeholder;
153+
flux.phone2Key += 1;
154+
flux.phone2Masked = '';
155+
flux.phone2Unmasked = undefined;
156+
}
157+
"
158+
/>
159+
<XInputMask
160+
:key="flux.phone2Key"
161+
v-model:masked="flux.phone2Masked"
162+
v-model:unmasked="flux.phone2Unmasked"
163+
:mask="{ mask: flux.phone2 }"
164+
sub
165+
:placeholder="flux.phone2Placeholder"
166+
/>
167+
</div>
168+
169+
<div class="mt-1">
170+
<div>Masked: {{ flux.phone2Masked }}</div>
171+
<div>
172+
Unmasked: {{ flux.phone2Unmasked }}
173+
<XCode>{{ typeof flux.phone2Unmasked }}</XCode>
174+
</div>
103175
</div>
104176
</XCard>
105177
</section>
@@ -127,7 +199,10 @@ const flux = reactive({
127199

128200
<div class="mt-1">
129201
<div>Masked: {{ flux.usdMasked }}</div>
130-
<div>Unmasked: {{ flux.usdUnmasked }}</div>
202+
<div>
203+
Unmasked: {{ flux.usdUnmasked }}
204+
<XCode>{{ typeof flux.usdUnmasked }}</XCode>
205+
</div>
131206
</div>
132207
</XCard>
133208
</section>

0 commit comments

Comments
 (0)