Merge pull request #164 from hongquan/feature/required-prop
feat(input): Allow to set "required" attribute
This commit is contained in:
@@ -5,6 +5,7 @@ import InputDisabledExample from './input/examples/InputDisabledExample.vue';
|
|||||||
import InputHelperExample from './input/examples/InputHelperExample.vue';
|
import InputHelperExample from './input/examples/InputHelperExample.vue';
|
||||||
import InputPrefixExample from './input/examples/InputPrefixExample.vue';
|
import InputPrefixExample from './input/examples/InputPrefixExample.vue';
|
||||||
import InputSuffixExample from './input/examples/InputSuffixExample.vue'
|
import InputSuffixExample from './input/examples/InputSuffixExample.vue'
|
||||||
|
import InputRequiredExample from './input/examples/InputRequiredExample.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# Vue Input - Flowbite
|
# Vue Input - Flowbite
|
||||||
@@ -30,7 +31,7 @@ import { ref } from 'vue'
|
|||||||
const name = ref('')
|
const name = ref('')
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Input v-modal="name" placeholder="enter your first name" label="First name" />
|
<Input v-model="name" placeholder="enter your first name" label="First name" />
|
||||||
</template>
|
</template>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -60,7 +61,18 @@ import { Input } from 'flowbite-vue'
|
|||||||
</template>
|
</template>
|
||||||
```
|
```
|
||||||
|
|
||||||
<InputDisabledExample />
|
## Required
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
import { Input } from 'flowbite-vue'
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<Input required placeholder="enter your first name" label="First name" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
<InputRequiredExample />
|
||||||
|
|
||||||
## Slot - Helper
|
## Slot - Helper
|
||||||
```vue
|
```vue
|
||||||
@@ -112,4 +124,3 @@ import { Input, Button } from 'flowbite-vue'
|
|||||||
```
|
```
|
||||||
|
|
||||||
<InputSuffixExample />
|
<InputSuffixExample />
|
||||||
|
|
||||||
|
|||||||
12
docs/components/input/examples/InputRequiredExample.vue
Normal file
12
docs/components/input/examples/InputRequiredExample.vue
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<div class="vp-raw">
|
||||||
|
<Input v-model='name' required placeholder="enter your first name" label="First name">
|
||||||
|
</Input>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { Input } from '../../../../src/index'
|
||||||
|
|
||||||
|
const name = ref('')
|
||||||
|
</script>
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
v-model="model"
|
v-model="model"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:type="type"
|
:type="type"
|
||||||
|
:required='required'
|
||||||
|
|
||||||
:class="[inputClasses, $slots.prefix ? 'pl-10' : '']"
|
:class="[inputClasses, $slots.prefix ? 'pl-10' : '']"
|
||||||
/>
|
/>
|
||||||
@@ -33,6 +34,7 @@ interface InputProps {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
type?: 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
type?: 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
||||||
size?: InputSize;
|
size?: InputSize;
|
||||||
|
required?: boolean;
|
||||||
modelValue: string;
|
modelValue: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ const props = withDefaults(defineProps<InputProps>(), {
|
|||||||
disabled: false,
|
disabled: false,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
size: 'md',
|
size: 'md',
|
||||||
|
required: false,
|
||||||
modelValue: '',
|
modelValue: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user