@minutemailer/kit 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ui/form.d.ts +24 -0
- package/components/ui/form.js +59 -0
- package/components/ui/typography.d.ts +26 -0
- package/components/ui/typography.js +20 -0
- package/package.json +5 -2
- package/styles.css +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { type ControllerProps, type FieldPath, type FieldValues } from 'react-hook-form';
|
|
5
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
6
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const useFormField: () => {
|
|
8
|
+
invalid: boolean;
|
|
9
|
+
isDirty: boolean;
|
|
10
|
+
isTouched: boolean;
|
|
11
|
+
isValidating: boolean;
|
|
12
|
+
error?: import("react-hook-form").FieldError;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
formItemId: string;
|
|
16
|
+
formDescriptionId: string;
|
|
17
|
+
formMessageId: string;
|
|
18
|
+
};
|
|
19
|
+
declare function FormItem({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare function FormDescription({ className, ...props }: React.ComponentProps<'p'>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare function FormMessage({ className, ...props }: React.ComponentProps<'p'>): import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
+
import { Controller, FormProvider, useFormContext, useFormState, } from 'react-hook-form';
|
|
6
|
+
import { cn } from '../../utils/utils.js';
|
|
7
|
+
import { Label } from '../../components/ui/label.js';
|
|
8
|
+
const Form = FormProvider;
|
|
9
|
+
const FormFieldContext = React.createContext({});
|
|
10
|
+
const FormField = ({ ...props }) => {
|
|
11
|
+
return (_jsx(FormFieldContext.Provider, { value: { name: props.name }, children: _jsx(Controller, { ...props }) }));
|
|
12
|
+
};
|
|
13
|
+
const useFormField = () => {
|
|
14
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
15
|
+
const itemContext = React.useContext(FormItemContext);
|
|
16
|
+
const { getFieldState } = useFormContext();
|
|
17
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
18
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
19
|
+
if (!fieldContext) {
|
|
20
|
+
throw new Error('useFormField should be used within <FormField>');
|
|
21
|
+
}
|
|
22
|
+
const { id } = itemContext;
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
name: fieldContext.name,
|
|
26
|
+
formItemId: `${id}-form-item`,
|
|
27
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
28
|
+
formMessageId: `${id}-form-item-message`,
|
|
29
|
+
...fieldState,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const FormItemContext = React.createContext({});
|
|
33
|
+
function FormItem({ className, ...props }) {
|
|
34
|
+
const id = React.useId();
|
|
35
|
+
return (_jsx(FormItemContext.Provider, { value: { id }, children: _jsx("div", { "data-slot": "form-item", className: cn('grid gap-2', className), ...props }) }));
|
|
36
|
+
}
|
|
37
|
+
function FormLabel({ className, ...props }) {
|
|
38
|
+
const { error, formItemId } = useFormField();
|
|
39
|
+
return (_jsx(Label, { "data-slot": "form-label", "data-error": !!error, className: cn('data-[error=true]:text-destructive', className), htmlFor: formItemId, ...props }));
|
|
40
|
+
}
|
|
41
|
+
function FormControl({ ...props }) {
|
|
42
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
43
|
+
return (_jsx(Slot, { "data-slot": "form-control", id: formItemId, "aria-describedby": !error
|
|
44
|
+
? `${formDescriptionId}`
|
|
45
|
+
: `${formDescriptionId} ${formMessageId}`, "aria-invalid": !!error, ...props }));
|
|
46
|
+
}
|
|
47
|
+
function FormDescription({ className, ...props }) {
|
|
48
|
+
const { formDescriptionId } = useFormField();
|
|
49
|
+
return (_jsx("p", { "data-slot": "form-description", id: formDescriptionId, className: cn('text-muted-foreground text-sm', className), ...props }));
|
|
50
|
+
}
|
|
51
|
+
function FormMessage({ className, ...props }) {
|
|
52
|
+
const { error, formMessageId } = useFormField();
|
|
53
|
+
const body = error ? String(error?.message ?? '') : props.children;
|
|
54
|
+
if (!body) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return (_jsx("p", { "data-slot": "form-message", id: formMessageId, className: cn('text-destructive text-sm', className), ...props, children: body }));
|
|
58
|
+
}
|
|
59
|
+
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export declare function TypographyH1({ children, className, ...props }: {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function TypographyH2({ children, className, }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function TypographyLead({ children, className, }: {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function TypographyMuted({ children, className, }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function TypographyP({ children, className, }: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function TypographySmall({ children, className, }: {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
className?: string;
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../utils/utils.js';
|
|
3
|
+
export function TypographyH1({ children, className = '', ...props }) {
|
|
4
|
+
return (_jsx("h1", { className: cn('scroll-m-20 text-center text-4xl font-semibold tracking-tight text-balance', className), ...props, children: children }));
|
|
5
|
+
}
|
|
6
|
+
export function TypographyH2({ children, className = '', }) {
|
|
7
|
+
return (_jsx("h2", { className: cn('scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0', className), children: children }));
|
|
8
|
+
}
|
|
9
|
+
export function TypographyLead({ children, className = '', }) {
|
|
10
|
+
return (_jsx("p", { className: cn('text-muted-foreground text-xl text-pretty', className), children: children }));
|
|
11
|
+
}
|
|
12
|
+
export function TypographyMuted({ children, className = '', }) {
|
|
13
|
+
return (_jsx("div", { className: cn('text-muted-foreground text-sm', className), children: children }));
|
|
14
|
+
}
|
|
15
|
+
export function TypographyP({ children, className = '', }) {
|
|
16
|
+
return (_jsx("p", { className: cn('leading-7 [&:not(:first-child)]:mt-6', className), children: children }));
|
|
17
|
+
}
|
|
18
|
+
export function TypographySmall({ children, className = '', }) {
|
|
19
|
+
return (_jsx("small", { className: cn('text-sm leading-none font-medium', className), children: children }));
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minutemailer/kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Minutemailer UI Kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Minutemailer",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"vitest": "^3.2.4"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"@hookform/resolvers": "^5.2.2",
|
|
44
45
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
45
46
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
46
47
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
@@ -54,9 +55,11 @@
|
|
|
54
55
|
"clsx": "^2.1.1",
|
|
55
56
|
"lucide-react": "^0.544.0",
|
|
56
57
|
"next-themes": "^0.4.6",
|
|
58
|
+
"react-hook-form": "^7.63.0",
|
|
57
59
|
"sonner": "^2.0.7",
|
|
58
60
|
"tailwind-merge": "^3.3.1",
|
|
59
61
|
"tailwindcss": "^4.1.14",
|
|
60
|
-
"tw-animate-css": "^1.4.0"
|
|
62
|
+
"tw-animate-css": "^1.4.0",
|
|
63
|
+
"zod": "^4.1.11"
|
|
61
64
|
}
|
|
62
65
|
}
|