feat: migrate DateField and shared date input group
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
computed,
|
||||
defineComponent,
|
||||
h,
|
||||
inject,
|
||||
mergeProps,
|
||||
provide,
|
||||
type PropType,
|
||||
} from "vue";
|
||||
import { dateInputGroupVariants } from "@heroui-vue/styles";
|
||||
import { dateFieldKey, dateGroupKey } from "./context";
|
||||
export default defineComponent({
|
||||
name: "DateInputGroup",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
variant: {
|
||||
type: String as PropType<"primary" | "secondary">,
|
||||
default: "primary",
|
||||
},
|
||||
fullWidth: Boolean,
|
||||
as: { type: String, default: "div" },
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
const field = inject(dateFieldKey, undefined);
|
||||
const styles = computed(() =>
|
||||
dateInputGroupVariants({
|
||||
variant: props.variant,
|
||||
fullWidth: props.fullWidth,
|
||||
}),
|
||||
);
|
||||
provide(dateGroupKey, styles);
|
||||
return () =>
|
||||
h(
|
||||
props.as,
|
||||
mergeProps(attrs, {
|
||||
class: styles.value.base(),
|
||||
"data-slot": "date-input-group",
|
||||
"data-invalid": field?.invalid.value || undefined,
|
||||
"aria-invalid": field?.invalid.value || undefined,
|
||||
"data-disabled": field?.disabled.value || undefined,
|
||||
"aria-disabled": field?.disabled.value || undefined,
|
||||
}),
|
||||
slots.default?.({
|
||||
isDisabled: !!field?.disabled.value,
|
||||
isInvalid: !!field?.invalid.value,
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user