2
0
mirror of https://github.com/tenrok/maska.git synced 2026-05-15 11:59:38 +03:00

fix(vue): use defineExpose to set argument value

This commit is contained in:
Alexander Shabunevich
2024-06-11 10:17:10 +03:00
parent 0285532bfc
commit e6b2799880
9 changed files with 54 additions and 38 deletions
+5 -3
View File
@@ -2,11 +2,13 @@
import { ref } from 'vue'
import { vMaska } from '../../src/vue'
const bound = ref(false)
const boundCompleted = ref(false)
defineExpose({ boundCompleted })
</script>
<template>
<input v-maska:bound.completed data-maska="#-#-#" />
<div v-if="bound === true">Completed</div>
<input v-maska:boundCompleted.completed data-maska="#-#-#" />
<div v-if="boundCompleted === true">Completed</div>
<div v-else>Uncompleted</div>
</template>
+5 -3
View File
@@ -2,10 +2,12 @@
import { ref } from 'vue'
import { vMaska } from '../../src/vue'
const bound = ref('')
const boundMasked = ref('')
defineExpose({ boundMasked })
</script>
<template>
<input v-maska:bound.masked data-maska="#-#" />
<div>{{ bound }}</div>
<input v-maska:boundMasked.masked data-maska="#-#" />
<div>{{ boundMasked }}</div>
</template>
+7 -5
View File
@@ -2,12 +2,14 @@
import { ref } from 'vue'
import { vMaska } from '../../src/vue'
const value = ref('123')
const bound = ref('')
const valueMasked = ref('123')
const boundUnmasked = ref('')
defineExpose({ boundUnmasked })
</script>
<template>
<input v-maska:bound.unmasked data-maska="#-#" data-maska-eager v-model="value" />
<div id="value1">{{ value }}</div>
<div id="value2">{{ bound }}</div>
<input v-maska:boundUnmasked.unmasked data-maska="#-#" data-maska-eager v-model="valueMasked" />
<div id="value1">{{ valueMasked }}</div>
<div id="value2">{{ boundUnmasked }}</div>
</template>
+5 -3
View File
@@ -2,10 +2,12 @@
import { ref } from 'vue'
import { vMaska } from '../../src/vue'
const bound = ref('')
const boundUnmasked = ref('')
defineExpose({ boundUnmasked })
</script>
<template>
<input v-maska:bound.unmasked data-maska="#-#" />
<div>{{ bound }}</div>
<input v-maska:boundUnmasked.unmasked data-maska="#-#" />
<div>{{ boundUnmasked }}</div>
</template>
+2
View File
@@ -17,6 +17,8 @@ const options2 = <MaskInputOptions>{
(detail) => emit('mask3', detail),
]
}
defineExpose({ bound1, bound2 })
</script>
<template>
+5 -3
View File
@@ -3,7 +3,7 @@ import { ref } from 'vue'
import { MaskInputOptions } from '../../src'
import { vMaska } from '../../src/vue'
const bound = ref('')
const boundMasked = ref('')
const config = <MaskInputOptions>{
mask: 'A A',
tokens: {
@@ -14,9 +14,11 @@ const config = <MaskInputOptions>{
}
}
}
defineExpose({ boundMasked })
</script>
<template>
<input v-maska:bound="config" />
<div>{{ bound }}</div>
<input v-maska:boundMasked="config" />
<div>{{ boundMasked }}</div>
</template>
+5 -3
View File
@@ -6,7 +6,7 @@ const mask = ref('+1 (###) ###-####')
const show = ref(true)
const eager = ref(true)
const valueMasked = ref('1234567')
const valueunmasked = ref('1')
const valueUnmasked = ref('1')
const onMaska = (e) => console.log(e.detail)
@@ -29,6 +29,8 @@ const options2 = {
.slice(0, sub ? -sub : undefined)
}
}
defineExpose({ valueUnmasked })
</script>
<template>
@@ -40,9 +42,9 @@ const options2 = {
<div><input v-model="mask"></div>
<div v-if="show">
<input v-maska:valueunmasked.unmasked="options" v-model="valueMasked" @maska="onMaska">
<input v-maska:valueUnmasked.unmasked="options" v-model="valueMasked" @maska="onMaska">
<div>Masked: {{ valueMasked }}</div>
<div>Unmasked: {{ valueunmasked }}</div>
<div>Unmasked: {{ valueUnmasked }}</div>
</div>
</div>