SInputYMD
<SInputYMD> is a input component to fill in "Year", "Month", and "Date".
Usage
Import <SInputYMD> component and pass in :value props. The value should be an object with year, month, and date properties.
<script setup lang="ts">
import { ref } from 'vue'
import SInputYMD from '@globalbrain/sefirot/lib/components/SInputYMD.vue'
const input = ref({
year: null,
month: null,
date: null
})
</script>
<template>
<SInputYMD v-model="input" />
</template>Props
Here are the list of props you may pass to the component.
:size
Defines the size of the input. The default is small.
interface Props {
size?: 'mini' | 'small' | 'medium'
}<SInputYMD size="small" v-model="..." />:label
Defines the label text of the input.
interface Props {
label?: string
}<SInputYMD label="Date" v-model="..." />:info
Shows help icon after the label and shows info in a tooltip when the user hovers the label.
interface Props {
info?: string
}<SInputYMD
label="Date"
info="Some helpful information."
v-model="..."
/>:note
Adds small help text after the label. Best used along with label prop.
interface Props {
note?: string
}<SInputYMD
label="Date"
note="Optional"
v-model="..."
/>:placeholder
Defines the placeholder to show when the value is empty. The default is 1998/01/14, which is the founded date of Global Brain.
interface Props {
placeholder?: Placeholder
}
interface Placeholder {
year: number
month: number
date: number
}<SInputYMD
:placeholder="{
year: 1985,
month: 10,
date: 10
}"
v-model="..."
/>:check-icon
Icon to display at corner right of label. Useful to show the status of a particular input.
import { IconifyIcon } from '@iconify/vue/dist/offline'
interface Props {
checkIcon?: IconifyIcon
}<SInputYMD :check-icon="IconCheckCircle" v-model="..." />:check-text
Text to display alongside check-icon.
interface Props {
checkText?: string
}<SInputYMD :check-text="Saved" v-model="..." />:check-color
Defines the color of check-icon and check-text. The default is neutral.
interface Props {
checkColor?: Color
}
type Color =
| 'neutral'
| 'mute'
| 'info'
| 'success'
| 'warning'
| 'danger'<SInputYMD
:check-icon="IconCheckCircle"
check-text="Uploaded"
check-color="success"
v-model="..."
/>:no-year
Hide the "year" input.
interface Props {
noYear?: boolean
}<SInputYMD no-year v-model="..." />:no-month
Hide the "month" input.
interface Props {
noMonth?: boolean
}<SInputYMD no-month v-model="..." />:no-date
Hide the "date" input.
interface Props {
noDate?: boolean
}<SInputYMD no-date v-model="..." />:block
Make the input full width to fit the parent container.
interface Props {
block?: boolean
}<SInputYMD block v-model="..." />:disabled
Mark input as disabled. When this prop is set, users may not be able to focus the element nor trigger any events.
interface Props {
disabled?: boolean
}<SInputYMD disabled v-model="..." />:value
Sets the input value. When model-value prop is set (e.g. via v-model directive), this prop gets ignored.
interface Props {
value?: Value
}
interface Value {
year: number | null
month: number | null
date: number | null
}<SInputYMD :value="value" />:model-value
The v-model binding for the input.
interface Props {
value?: Value
}
interface Value {
year: number | null
month: number | null
date: number | null
}<SInputYMD v-model="value" />:validation
The validation object for the input. It accepts Vuelidate like validation object and displays error if there're any.
import { Ref } from 'vue'
interface Props {
validation?: Validatable
}
interface Validatable {
readonly $dirty: boolean
readonly $invalid: boolean
readonly $errors: ValidatableError[]
readonly $touch: () => void
}
interface ValidatableError {
readonly $message: string | Ref<string>
}<SInputYMD v-model="..." :validation="validation" />:hide-error
Stop showing validation error message even when there are errors. This prop will not prevent the error color from appearing.
interface Props {
hideError?: boolean
}<SInputYMD
v-model="1"
:validation="validation"
hide-error
/>Slots
Here are the list of slots you may define within the component.
#info
Same as info prop. When info prop and this slot are defined at the same time, this slot will take precedence.
<SInputYMD label="Date" v-model="...">
<template #info>
Learn more about this field <SLink href="...">here</SLink>.
</template>
</SInputSelect>Events
Here are the list of events the component may emit.
@update:model-value
Emits when the user selects the item. This event is always emitted together with change event.
interface Emits {
(e: 'update:model-value', value: Value): void
}
interface Value {
year: number | null
month: number | null
date: number | null
}@change
Emits when the user selects the item. This event is always emitted together with update:model-value event.
interface Emits {
(e: 'change', value: Value): void
}
interface Value {
year: number | null
month: number | null
date: number | null
}Styles
You may customize the styles by overriding --input prefixed CSS variables.
Global input styles
You may customize the various styles of the component via global input related CSS variables. Please refer to Styles: Input Styles page.