Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the use of v-model possible #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions kitchen-sink/vue/pages/FormInputs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<demo-icon />
</template>
</k-list-input>

<k-list-input
label="Password"
type="password"
Expand Down Expand Up @@ -325,20 +324,20 @@
<k-block-title>Clear Button</k-block-title>
<k-list inset-ios strong-ios>
<k-list-input
v-model="demoValue"
label="TV Show"
type="text"
placeholder="Your favorite TV show"
info="Type something to see clear button"
:value="demoValue"
:clear-button="demoValue.length > 0"
@input="onDemoValueChange"
@clear="onDemoValueClear"
>
<template #media>
<demo-icon />
</template>
</k-list-input>
</k-list>
<p>Favorite TV Show: {{demoValue}}</p>

<k-block-title>Icon + Input</k-block-title>
<k-list inset-ios strong-ios>
Expand Down Expand Up @@ -442,7 +441,7 @@
},
setup() {
const name = ref({ value: '', changed: false });
const demoValue = ref('');
const demoValue = ref('test');

const onNameChange = (e) => {
name.value = { value: e.target.value, changed: true };
Expand Down
11 changes: 6 additions & 5 deletions src/vue/components/ListInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
:pattern="pattern"
:tabindex="tabindex"
v-bind="inputProps"
:value="modelValue"
@input="onInput"
@change="onChange"
@focus="onFocusInternal"
Expand Down Expand Up @@ -143,7 +144,7 @@
inputClass: { type: String, default: '' },

name: String,
value: [String, Number],
modelValue: [String, Number],
type: { type: String, default: 'text' },
inputmode: String,
readonly: Boolean,
Expand All @@ -167,7 +168,7 @@
pattern: String,
tabindex: [String, Number],
},
emits: ['change', 'input', 'focus', 'blur', 'clear'],
emits: ['update:modelValue', 'change', 'input', 'focus', 'blur', 'clear'],
setup(props, ctx) {
const inputElRef = ref(null);
const isFocused = ref(false);
Expand Down Expand Up @@ -199,9 +200,9 @@

const isInputHasValue = () => {
const domValue = getDomValue();
return typeof props.value === 'undefined'
return typeof props.modelValue === 'undefined'
? domValue || domValue === 0
: props.value || props.value === 0;
: props.modelValue || props.modelValue === 0;
};
const isFloatingTransformed = computed(() => {
return (
Expand Down Expand Up @@ -234,6 +235,7 @@

const onInput = (e) => {
ctx.emit('input', e);
ctx.emit('update:modelValue', e.target.value);
};

const onClear = (e) => {
Expand Down Expand Up @@ -271,7 +273,6 @@
return {
...(typeof props.size === 'undefined' ? {} : { size: props.size }),
...(needsType.value ? { type: props.type } : {}),
...(typeof props.value === 'undefined' ? {} : { value: props.value }),
};
});

Expand Down