52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { h } from "vue";
|
|
import {
|
|
TextField,
|
|
SearchField,
|
|
type TextFieldProps,
|
|
type SearchFieldProps,
|
|
type TextFieldRenderProps,
|
|
type SearchFieldRenderProps,
|
|
type InputOTPProps,
|
|
} from "@heroui-vue/components";
|
|
const text: TextFieldProps = { autoFocus: true, validationErrors: ["server"] };
|
|
const search: SearchFieldProps = { validationErrors: "local", autoFocus: true };
|
|
const otp: InputOTPProps = {
|
|
maxLength: 4,
|
|
autoFocus: true,
|
|
textAlign: "right",
|
|
pasteTransformer: (text) => text.replaceAll("-", ""),
|
|
};
|
|
const textSlot: NonNullable<
|
|
InstanceType<typeof TextField>["$slots"]["default"]
|
|
> = (state: TextFieldRenderProps) => [
|
|
h(
|
|
"span",
|
|
`${state.value}/${state.isFocusWithin}/${state.validationDetails.valid}`,
|
|
),
|
|
];
|
|
const searchSlot: NonNullable<
|
|
InstanceType<typeof SearchField>["$slots"]["default"]
|
|
> = (state: SearchFieldRenderProps) => [
|
|
h("span", `${state.value}/${state.isEmpty}/${state.isFocusVisible}`),
|
|
];
|
|
// @ts-expect-error errors are local text/arrays, not Form name maps
|
|
const badField: TextFieldProps = { validationErrors: { email: "wrong" } };
|
|
// @ts-expect-error text alignment is a closed union
|
|
const badAlignment: InputOTPProps = { maxLength: 4, textAlign: "bottom" };
|
|
// @ts-expect-error the paste transformer returns a string
|
|
const badPaste: InputOTPProps = { maxLength: 4, pasteTransformer: () => 42 };
|
|
const badDetails: InputOTPProps = {
|
|
maxLength: 4,
|
|
// @ts-expect-error all native validity flags are required
|
|
validationDetails: { valid: false },
|
|
};
|
|
void text;
|
|
void search;
|
|
void otp;
|
|
void textSlot;
|
|
void searchSlot;
|
|
void badField;
|
|
void badAlignment;
|
|
void badPaste;
|
|
void badDetails;
|