Skip to content

Commit

Permalink
feat(NcSettingsInputText): v9 model compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Oct 31, 2024
1 parent 33623b2 commit f30f126
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions src/components/NcSettingsInputText/NcSettingsInputText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<template>
<div>
<NcSettingsInputText v-model="value" label="Label" hint="Hint" />
<NcSettingsInputText label="Label" value="Value" hint="Hint" disabled />
<NcSettingsInputText label="Label" model-value="Value" hint="Hint" disabled />
</div>
</template>

Expand All @@ -34,7 +34,7 @@ export default {
<label :for="id" class="action-input__label">{{ label }}</label>
<input :id="id"
type="text"
:value="value"
:value="model"
:disabled="disabled"
@input="onInput"
@change="onChange">
Expand All @@ -52,6 +52,7 @@ export default {
<script>
import { t } from '../../l10n.js'
import GenRandomId from '../../utils/GenRandomId.js'
import { useModelMigration } from '../../composables/useModelMigration.ts'
export default {
name: 'NcSettingsInputText',
Expand Down Expand Up @@ -79,9 +80,18 @@ export default {
},
/**
* value of the select group input
* Removed in v9 - use `modelValue` (`v-model`) instead
* @deprecated
*/
value: {
type: String,
default: undefined,
},
/**
* value of the select group input
*/
modelValue: {
type: String,
default: '',
},
Expand All @@ -105,12 +115,31 @@ export default {
},
emits: [
/**
* Removed in v9 - use `update:modelValue` (`v-model`) instead
* @deprecated
*/
'update:value',
/**
* Emitted when the inputs value changes
*
* @type {string}
*/
'update:modelValue',
/* Same as update:modelValue for Vue 2 compatibility */
'update:model-value',
'input',
'submit',
'change',
],
setup() {
const model = useModelMigration('value', 'update:value')
return {
model,
}
},
data() {
return {
submitTranslated: t('Submit'),
Expand All @@ -128,12 +157,7 @@ export default {
methods: {
onInput(event) {
this.$emit('input', event)
/**
* Emitted when the inputs value changes
*
* @type {string}
*/
this.$emit('update:value', event.target.value)
this.model = event.target.value
},
onSubmit(event) {
if (!this.disabled) {
Expand Down

0 comments on commit f30f126

Please sign in to comment.