Files
heroui-vue/tests/package/date-field-contract.ts
2026-10-23 23:56:18 +08:00

56 lines
1.5 KiB
TypeScript

import {
DateField,
DateFieldGroup,
DateFieldInput,
DateFieldSegment,
DateInputGroup,
type DateFieldProps,
type DateFieldGroupProps,
type DateFieldSegmentProps,
type DateSegment,
} from "@heroui-vue/components";
import { parseDate } from "@internationalized/date";
const date = parseDate("2024-02-10");
const props: DateFieldProps = {
modelValue: date,
granularity: "minute",
hourCycle: 24,
placeholderValue: date,
validate: (value) => (value ? value.toString() : "Missing"),
};
const group: DateFieldGroupProps = { variant: "secondary", fullWidth: true };
// @ts-expect-error DateValue is not a date string
const wrongDate: DateFieldProps = { modelValue: "2024-02-10" };
// @ts-expect-error no milliseconds granularity
const wrongGranularity: DateFieldProps = { granularity: "millisecond" };
// @ts-expect-error no arbitrary variants
const wrongVariant: DateFieldGroupProps = { variant: "outline" };
// @ts-expect-error a DateField is not a range
const wrongRange: DateFieldProps = { modelValue: [date, date] };
const segment: DateSegment = {
part: "day",
type: "day",
text: "10",
value: "10",
isEditable: true,
isPlaceholder: false,
};
const segmentProps: DateFieldSegmentProps = { segment };
// @ts-expect-error DateSegment has real properties
const wrongSegment: DateFieldSegmentProps = { segment: "day" };
void [
DateField,
DateFieldGroup,
DateFieldInput,
DateFieldSegment,
DateInputGroup,
props,
group,
segmentProps,
wrongDate,
wrongGranularity,
wrongVariant,
wrongRange,
wrongSegment,
];