@oniratec/onira-react-ui 1.0.2 → 1.0.4
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/dist/index.cjs +41 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +103 -0
- package/dist/index.js +6551 -4347
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
3
|
import { FC } from 'react';
|
|
4
|
+
import { FieldPath } from 'react-hook-form';
|
|
5
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
6
|
import { ForwardRefExoticComponent } from 'react';
|
|
5
7
|
import { ImgHTMLAttributes } from 'react';
|
|
6
8
|
import { InputHTMLAttributes } from 'react';
|
|
@@ -12,6 +14,40 @@ import { RefAttributes } from 'react';
|
|
|
12
14
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
13
15
|
import { SlotProps } from '@radix-ui/react-slot';
|
|
14
16
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
17
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
|
|
20
|
+
declare type BaseField<T extends FieldValues> = {
|
|
21
|
+
name: FieldPath<T>;
|
|
22
|
+
label: string;
|
|
23
|
+
kind: FieldKind;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
options?: Option_2[];
|
|
27
|
+
/**
|
|
28
|
+
* Zod schema for this field.
|
|
29
|
+
* If not provided, it will default to optional.
|
|
30
|
+
*/
|
|
31
|
+
schema?: z.ZodTypeAny;
|
|
32
|
+
/**
|
|
33
|
+
* Default value for this field.
|
|
34
|
+
*/
|
|
35
|
+
defaultValue?: unknown;
|
|
36
|
+
/**
|
|
37
|
+
* Normalize value before storing it in form state.
|
|
38
|
+
*/
|
|
39
|
+
normalize?: (value: unknown) => unknown;
|
|
40
|
+
/**
|
|
41
|
+
* Cross-field dependencies.
|
|
42
|
+
*/
|
|
43
|
+
deps?: FieldDependency<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Conditional visibility.
|
|
46
|
+
*/
|
|
47
|
+
hidden?: (values: Partial<T>) => boolean;
|
|
48
|
+
/** Grid layout helpers */
|
|
49
|
+
colSpan?: 1 | 2 | 3 | 4;
|
|
50
|
+
};
|
|
15
51
|
|
|
16
52
|
declare type BaseProps = {
|
|
17
53
|
children: ReactNode;
|
|
@@ -22,6 +58,10 @@ export declare const Box: ({ children, }: Readonly<{
|
|
|
22
58
|
children: ReactNode;
|
|
23
59
|
}>) => JSX.Element;
|
|
24
60
|
|
|
61
|
+
export declare function buildDefaultValues<TFormModel extends FieldValues, TEntity>(config: FormFactoryConfig<TFormModel, TEntity>, ctx: DefaultValuesContext<TEntity>): Partial<TFormModel>;
|
|
62
|
+
|
|
63
|
+
export declare function buildZodSchema<TFormModel extends FieldValues, TEntity>(config: FormFactoryConfig<TFormModel, TEntity>): z.ZodTypeAny;
|
|
64
|
+
|
|
25
65
|
export declare const Button: React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
|
|
26
66
|
|
|
27
67
|
export declare interface ButtonProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -48,12 +88,18 @@ declare type Column<T> = {
|
|
|
48
88
|
className?: string;
|
|
49
89
|
};
|
|
50
90
|
|
|
91
|
+
declare type CrossRule<T extends FieldValues> = (values: T, ctx: z.RefinementCtx) => void;
|
|
92
|
+
|
|
51
93
|
export declare const darkTheme: Theme;
|
|
52
94
|
|
|
53
95
|
export declare function DataTable<T>({ columns, data }: Props<T>): JSX.Element;
|
|
54
96
|
|
|
55
97
|
export declare const defaultTheme: Theme;
|
|
56
98
|
|
|
99
|
+
declare interface DefaultValuesContext<TEntity> {
|
|
100
|
+
entity?: TEntity;
|
|
101
|
+
}
|
|
102
|
+
|
|
57
103
|
export declare const DropdownMenu: React_2.FC<DropdownMenuPrimitive.DropdownMenuProps>;
|
|
58
104
|
|
|
59
105
|
export declare const DropdownMenuCheckboxItem: React_2.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuCheckboxItemProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
@@ -95,6 +141,16 @@ declare interface FieldContextValue {
|
|
|
95
141
|
|
|
96
142
|
export declare const FieldControl: ForwardRefExoticComponent<Omit<SlotProps & RefAttributes<HTMLElement>, "ref"> & RefAttributes<HTMLElement>>;
|
|
97
143
|
|
|
144
|
+
declare type FieldDependency<T extends FieldValues> = {
|
|
145
|
+
/**
|
|
146
|
+
* Fields to revalidate when this field changes.
|
|
147
|
+
* Required for cross-field validation (superRefine).
|
|
148
|
+
*/
|
|
149
|
+
onChangeTrigger?: FieldPath<T>[];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
declare type FieldKind = 'input' | 'password' | 'textarea' | 'select' | 'toggle' | 'checkbox';
|
|
153
|
+
|
|
98
154
|
export declare const FieldLabel: React_2.ForwardRefExoticComponent<React_2.LabelHTMLAttributes<HTMLLabelElement> & React_2.RefAttributes<HTMLLabelElement>>;
|
|
99
155
|
|
|
100
156
|
export declare const FieldMessage: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLParagraphElement> & React_2.RefAttributes<HTMLParagraphElement>>;
|
|
@@ -104,6 +160,14 @@ declare interface FieldProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
|
104
160
|
required?: boolean;
|
|
105
161
|
}
|
|
106
162
|
|
|
163
|
+
export declare interface FormFactoryConfig<TFormModel extends FieldValues, TEntity = unknown> {
|
|
164
|
+
defaultValues?: (ctx: DefaultValuesContext<TEntity>) => Partial<TFormModel>;
|
|
165
|
+
sections: Section<TFormModel>[];
|
|
166
|
+
crossRules?: CrossRule<TFormModel>[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export declare function FormFactoryRenderer<TFormModel extends FieldValues, TEntity>({ config, form, onSubmitAction, submitLabel, maxWidthClass, }: Props_4<TFormModel, TEntity>): JSX.Element;
|
|
170
|
+
|
|
107
171
|
export declare const Input: React_2.ForwardRefExoticComponent<InputProps & React_2.RefAttributes<HTMLInputElement>>;
|
|
108
172
|
|
|
109
173
|
declare interface InputProps extends Omit<React_2.InputHTMLAttributes<HTMLInputElement>, 'crossOrigin' | 'dangerouslySetInnerHTML'> {
|
|
@@ -114,6 +178,15 @@ declare interface InputProps extends Omit<React_2.InputHTMLAttributes<HTMLInputE
|
|
|
114
178
|
isInvalid?: boolean;
|
|
115
179
|
}
|
|
116
180
|
|
|
181
|
+
declare type Layout = {
|
|
182
|
+
kind: 'single';
|
|
183
|
+
} | {
|
|
184
|
+
kind: 'grid';
|
|
185
|
+
cols?: 1 | 2 | 3 | 4;
|
|
186
|
+
mdCols?: 1 | 2 | 3 | 4;
|
|
187
|
+
gap?: string;
|
|
188
|
+
};
|
|
189
|
+
|
|
117
190
|
export declare const lightTheme: Theme;
|
|
118
191
|
|
|
119
192
|
export declare const Logo: ({ src, alt, width, height, className, ImageComponent, ...props }: LogoProps) => JSX.Element;
|
|
@@ -138,6 +211,11 @@ declare type NotFoundStateProps = {
|
|
|
138
211
|
fallbackIcon?: ReactNode;
|
|
139
212
|
};
|
|
140
213
|
|
|
214
|
+
declare type Option_2<T extends string | number = string> = {
|
|
215
|
+
value: T;
|
|
216
|
+
label: string;
|
|
217
|
+
};
|
|
218
|
+
|
|
141
219
|
export declare const PageSizeSelector: ({ value, onChange, options }: Props_2) => JSX.Element;
|
|
142
220
|
|
|
143
221
|
export declare const Pagination: ({ page, pageSize, total, onPageChange, onPageSizeChange }: Props_3) => JSX.Element;
|
|
@@ -181,8 +259,33 @@ declare interface Props_3 {
|
|
|
181
259
|
onPageSizeChange: (size: number) => void;
|
|
182
260
|
}
|
|
183
261
|
|
|
262
|
+
declare interface Props_4<TFormModel extends FieldValues, TEntity> {
|
|
263
|
+
config: FormFactoryConfig<TFormModel, TEntity>;
|
|
264
|
+
form: UseFormReturn<TFormModel>;
|
|
265
|
+
onSubmitAction: (data: TFormModel) => void | Promise<void>;
|
|
266
|
+
submitLabel: string;
|
|
267
|
+
maxWidthClass?: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
declare type Section<T extends FieldValues> = {
|
|
271
|
+
title: string;
|
|
272
|
+
description?: string;
|
|
273
|
+
layout?: Layout;
|
|
274
|
+
fields: Array<BaseField<T> | BaseField<T>[]>;
|
|
275
|
+
};
|
|
276
|
+
|
|
184
277
|
export declare const Select: React_2.FC<SelectPrimitive.SelectProps>;
|
|
185
278
|
|
|
279
|
+
export declare const SelectContent: React_2.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
280
|
+
|
|
281
|
+
export declare const SelectItem: React_2.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
282
|
+
|
|
283
|
+
export declare const SelectTrigger: React_2.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React_2.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
284
|
+
hasError?: boolean;
|
|
285
|
+
} & React_2.RefAttributes<HTMLButtonElement>>;
|
|
286
|
+
|
|
287
|
+
export declare const SelectValue: React_2.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React_2.RefAttributes<HTMLSpanElement>>;
|
|
288
|
+
|
|
186
289
|
export declare function Skeleton({ className }: SkeletonProps): JSX.Element;
|
|
187
290
|
|
|
188
291
|
declare type SkeletonProps = {
|