@saptanshuwanjari/react-component-library 0.1.6 → 0.1.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/dist/index.d.mts CHANGED
@@ -1,8 +1,11 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as react from 'react';
2
+ import { ComponentType, ReactNode } from 'react';
3
3
  import * as react_hook_form from 'react-hook-form';
4
4
  import { FieldValues, Path, ControllerRenderProps } from 'react-hook-form';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
  import * as z from 'zod';
7
+ import * as class_variance_authority_types from 'class-variance-authority/types';
8
+ import { VariantProps } from 'class-variance-authority';
6
9
  import { ColumnDef } from '@tanstack/react-table';
7
10
  import { ClassValue } from 'clsx';
8
11
 
@@ -11,7 +14,7 @@ type ZodSchema = z.ZodTypeAny;
11
14
  type RootProps$1<T extends FieldValues> = {
12
15
  schema?: ZodSchema;
13
16
  defaultValues?: Partial<T>;
14
- onSubmit: (values: any) => void | Promise<void>;
17
+ onSubmit: (values: T) => void | Promise<void>;
15
18
  children: React.ReactNode;
16
19
  enableOptimistic?: boolean;
17
20
  title?: string;
@@ -28,30 +31,45 @@ type FieldProps<TFieldValues extends FieldValues> = {
28
31
  };
29
32
  declare function Field<TFieldValues extends FieldValues>({ name, label, children, }: FieldProps<TFieldValues>): react_jsx_runtime.JSX.Element;
30
33
 
31
- declare const Button$2: ({ children, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
32
- declare function Submit({ children, ...props }: React.ComponentProps<typeof Button$2>): react_jsx_runtime.JSX.Element | null;
33
-
34
34
  declare const Button$1: ({ children, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
35
- type EditButtonProps = React.ComponentProps<typeof Button$1> & {
35
+ declare function Submit({ children, ...props }: React.ComponentProps<typeof Button$1>): react_jsx_runtime.JSX.Element | null;
36
+
37
+ declare const buttonVariants: (props?: ({
38
+ variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
39
+ size?: "icon" | "default" | "sm" | "lg" | "icon-sm" | "icon-lg" | null | undefined;
40
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
41
+ declare function Button({ className, variant, size, asChild, ...props }: react.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
42
+ asChild?: boolean;
43
+ }): react_jsx_runtime.JSX.Element;
44
+
45
+ type EditButtonProps = React.ComponentProps<typeof Button> & {
36
46
  formId?: string;
37
47
  };
38
48
  declare function EditButton({ children, formId, ...props }: EditButtonProps): react_jsx_runtime.JSX.Element | null;
39
49
 
40
- declare const Button: ({ children, className, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
41
50
  declare function CancelButton({ children, ...props }: React.ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element | null;
42
51
 
43
52
  type LinkFieldProps = {
44
53
  label?: string;
45
54
  link: string;
46
- LinkComponent?: React.ComponentType<{
55
+ LinkComponent?: ComponentType<{
47
56
  href: string;
48
57
  className?: string;
49
- children: React.ReactNode;
58
+ children: ReactNode;
50
59
  }>;
60
+ className?: string;
51
61
  };
52
- declare function LinkField({ label, link, LinkComponent }: LinkFieldProps): react_jsx_runtime.JSX.Element;
62
+ declare function LinkField({ label, link, LinkComponent, className }: LinkFieldProps): react_jsx_runtime.JSX.Element;
63
+
64
+ type FieldGroupProps = {
65
+ children: ReactNode;
66
+ className?: string;
67
+ title?: string;
68
+ };
69
+ declare function FieldGroup({ children, className, title }: FieldGroupProps): react_jsx_runtime.JSX.Element;
53
70
 
54
71
  declare const Form: typeof Root$1 & {
72
+ Root: typeof Root$1;
55
73
  Field: typeof Field;
56
74
  InputField: <TFieldValues extends react_hook_form.FieldValues>(props: {
57
75
  name: react_hook_form.Path<TFieldValues>;
@@ -64,11 +82,11 @@ declare const Form: typeof Root$1 & {
64
82
  endAddon?: React.ReactNode;
65
83
  useGroup?: boolean;
66
84
  }) => react.ReactNode;
67
- PasswordField: react.MemoExoticComponent<(<TFieldValues extends react_hook_form.FieldValues>({ name, label, placeholder, }: {
85
+ PasswordField: <TFieldValues extends react_hook_form.FieldValues>(props: {
68
86
  name: react_hook_form.Path<TFieldValues>;
69
87
  label?: string;
70
88
  placeholder?: string;
71
- }) => react_jsx_runtime.JSX.Element)>;
89
+ }) => react.ReactNode;
72
90
  TextareaField: <TFieldValues extends react_hook_form.FieldValues>(props: {
73
91
  name: react_hook_form.Path<TFieldValues>;
74
92
  label?: string;
@@ -110,9 +128,7 @@ declare const Form: typeof Root$1 & {
110
128
  Submit: typeof Submit;
111
129
  EditButton: typeof EditButton;
112
130
  CancelButton: typeof CancelButton;
113
- Group: ({ children }: {
114
- children: React.ReactNode;
115
- }) => react_jsx_runtime.JSX.Element;
131
+ Group: typeof FieldGroup;
116
132
  LinkField: typeof LinkField;
117
133
  };
118
134
 
@@ -133,37 +149,50 @@ interface RootProps<TData, TValue> {
133
149
  data: TData[];
134
150
  filters?: FilterOption[];
135
151
  defaultViewMode?: ViewMode;
152
+ viewMode?: ViewMode;
153
+ onViewModeChange?: (mode: ViewMode) => void;
136
154
  defaultPageSize?: number;
137
155
  children: React.ReactNode;
138
156
  }
139
- declare function Root<TData, TValue>({ columns, data, filters, defaultViewMode, defaultPageSize, children, }: RootProps<TData, TValue>): react_jsx_runtime.JSX.Element;
157
+ declare function Root<TData, TValue>({ columns, data, filters, defaultViewMode, viewMode: controlledViewMode, onViewModeChange: controlledOnViewModeChange, defaultPageSize, children, }: RootProps<TData, TValue>): react_jsx_runtime.JSX.Element;
140
158
 
141
- declare function Toolbar(): react_jsx_runtime.JSX.Element;
159
+ interface ToolbarProps {
160
+ viewOptions?: React.ReactNode;
161
+ }
162
+ declare function Toolbar({ viewOptions }?: ToolbarProps): react_jsx_runtime.JSX.Element;
142
163
 
143
- interface ContentProps {
144
- renderCard?: (item: any, index: number) => React.ReactNode;
164
+ interface ContentProps<TData> {
165
+ renderCard?: (item: TData, index: number) => React.ReactNode;
145
166
  gridColumns?: number;
146
167
  gridGap?: number;
147
168
  }
148
- declare function Content({ renderCard, gridColumns, gridGap }: ContentProps): react_jsx_runtime.JSX.Element;
169
+ declare function Content<TData>({ renderCard, gridColumns, gridGap }: ContentProps<TData>): react_jsx_runtime.JSX.Element;
149
170
 
150
171
  declare function TableView(): react_jsx_runtime.JSX.Element;
151
172
 
152
- interface GridViewProps<TData = any> {
173
+ interface GridViewProps<TData> {
153
174
  renderCard?: (item: TData, index: number) => React.ReactNode;
154
175
  columns?: number;
155
176
  gap?: number;
156
177
  }
157
- declare function GridView<TData = any>({ renderCard, columns, gap }: GridViewProps<TData>): react_jsx_runtime.JSX.Element;
178
+ declare function GridView<TData>({ renderCard, columns, gap }: GridViewProps<TData>): react_jsx_runtime.JSX.Element;
158
179
 
159
180
  declare function Pagination(): react_jsx_runtime.JSX.Element;
160
181
 
182
+ interface ViewOptionsProps {
183
+ viewMode?: ViewMode;
184
+ onViewModeChange?: (mode: ViewMode) => void;
185
+ }
186
+ declare function ViewOptions({ viewMode: propViewMode, onViewModeChange: propOnViewModeChange }: ViewOptionsProps): react_jsx_runtime.JSX.Element;
187
+
161
188
  declare const DataTable: typeof Root & {
189
+ Root: typeof Root;
162
190
  Toolbar: typeof Toolbar;
163
191
  Content: typeof Content;
164
192
  TableView: typeof TableView;
165
193
  GridView: typeof GridView;
166
194
  Pagination: typeof Pagination;
195
+ ViewOptions: typeof ViewOptions;
167
196
  };
168
197
 
169
198
  declare function cn(...inputs: ClassValue[]): string;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as react from 'react';
2
+ import { ComponentType, ReactNode } from 'react';
3
3
  import * as react_hook_form from 'react-hook-form';
4
4
  import { FieldValues, Path, ControllerRenderProps } from 'react-hook-form';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
  import * as z from 'zod';
7
+ import * as class_variance_authority_types from 'class-variance-authority/types';
8
+ import { VariantProps } from 'class-variance-authority';
6
9
  import { ColumnDef } from '@tanstack/react-table';
7
10
  import { ClassValue } from 'clsx';
8
11
 
@@ -11,7 +14,7 @@ type ZodSchema = z.ZodTypeAny;
11
14
  type RootProps$1<T extends FieldValues> = {
12
15
  schema?: ZodSchema;
13
16
  defaultValues?: Partial<T>;
14
- onSubmit: (values: any) => void | Promise<void>;
17
+ onSubmit: (values: T) => void | Promise<void>;
15
18
  children: React.ReactNode;
16
19
  enableOptimistic?: boolean;
17
20
  title?: string;
@@ -28,30 +31,45 @@ type FieldProps<TFieldValues extends FieldValues> = {
28
31
  };
29
32
  declare function Field<TFieldValues extends FieldValues>({ name, label, children, }: FieldProps<TFieldValues>): react_jsx_runtime.JSX.Element;
30
33
 
31
- declare const Button$2: ({ children, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
32
- declare function Submit({ children, ...props }: React.ComponentProps<typeof Button$2>): react_jsx_runtime.JSX.Element | null;
33
-
34
34
  declare const Button$1: ({ children, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
35
- type EditButtonProps = React.ComponentProps<typeof Button$1> & {
35
+ declare function Submit({ children, ...props }: React.ComponentProps<typeof Button$1>): react_jsx_runtime.JSX.Element | null;
36
+
37
+ declare const buttonVariants: (props?: ({
38
+ variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
39
+ size?: "icon" | "default" | "sm" | "lg" | "icon-sm" | "icon-lg" | null | undefined;
40
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
41
+ declare function Button({ className, variant, size, asChild, ...props }: react.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
42
+ asChild?: boolean;
43
+ }): react_jsx_runtime.JSX.Element;
44
+
45
+ type EditButtonProps = React.ComponentProps<typeof Button> & {
36
46
  formId?: string;
37
47
  };
38
48
  declare function EditButton({ children, formId, ...props }: EditButtonProps): react_jsx_runtime.JSX.Element | null;
39
49
 
40
- declare const Button: ({ children, className, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
41
50
  declare function CancelButton({ children, ...props }: React.ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element | null;
42
51
 
43
52
  type LinkFieldProps = {
44
53
  label?: string;
45
54
  link: string;
46
- LinkComponent?: React.ComponentType<{
55
+ LinkComponent?: ComponentType<{
47
56
  href: string;
48
57
  className?: string;
49
- children: React.ReactNode;
58
+ children: ReactNode;
50
59
  }>;
60
+ className?: string;
51
61
  };
52
- declare function LinkField({ label, link, LinkComponent }: LinkFieldProps): react_jsx_runtime.JSX.Element;
62
+ declare function LinkField({ label, link, LinkComponent, className }: LinkFieldProps): react_jsx_runtime.JSX.Element;
63
+
64
+ type FieldGroupProps = {
65
+ children: ReactNode;
66
+ className?: string;
67
+ title?: string;
68
+ };
69
+ declare function FieldGroup({ children, className, title }: FieldGroupProps): react_jsx_runtime.JSX.Element;
53
70
 
54
71
  declare const Form: typeof Root$1 & {
72
+ Root: typeof Root$1;
55
73
  Field: typeof Field;
56
74
  InputField: <TFieldValues extends react_hook_form.FieldValues>(props: {
57
75
  name: react_hook_form.Path<TFieldValues>;
@@ -64,11 +82,11 @@ declare const Form: typeof Root$1 & {
64
82
  endAddon?: React.ReactNode;
65
83
  useGroup?: boolean;
66
84
  }) => react.ReactNode;
67
- PasswordField: react.MemoExoticComponent<(<TFieldValues extends react_hook_form.FieldValues>({ name, label, placeholder, }: {
85
+ PasswordField: <TFieldValues extends react_hook_form.FieldValues>(props: {
68
86
  name: react_hook_form.Path<TFieldValues>;
69
87
  label?: string;
70
88
  placeholder?: string;
71
- }) => react_jsx_runtime.JSX.Element)>;
89
+ }) => react.ReactNode;
72
90
  TextareaField: <TFieldValues extends react_hook_form.FieldValues>(props: {
73
91
  name: react_hook_form.Path<TFieldValues>;
74
92
  label?: string;
@@ -110,9 +128,7 @@ declare const Form: typeof Root$1 & {
110
128
  Submit: typeof Submit;
111
129
  EditButton: typeof EditButton;
112
130
  CancelButton: typeof CancelButton;
113
- Group: ({ children }: {
114
- children: React.ReactNode;
115
- }) => react_jsx_runtime.JSX.Element;
131
+ Group: typeof FieldGroup;
116
132
  LinkField: typeof LinkField;
117
133
  };
118
134
 
@@ -133,37 +149,50 @@ interface RootProps<TData, TValue> {
133
149
  data: TData[];
134
150
  filters?: FilterOption[];
135
151
  defaultViewMode?: ViewMode;
152
+ viewMode?: ViewMode;
153
+ onViewModeChange?: (mode: ViewMode) => void;
136
154
  defaultPageSize?: number;
137
155
  children: React.ReactNode;
138
156
  }
139
- declare function Root<TData, TValue>({ columns, data, filters, defaultViewMode, defaultPageSize, children, }: RootProps<TData, TValue>): react_jsx_runtime.JSX.Element;
157
+ declare function Root<TData, TValue>({ columns, data, filters, defaultViewMode, viewMode: controlledViewMode, onViewModeChange: controlledOnViewModeChange, defaultPageSize, children, }: RootProps<TData, TValue>): react_jsx_runtime.JSX.Element;
140
158
 
141
- declare function Toolbar(): react_jsx_runtime.JSX.Element;
159
+ interface ToolbarProps {
160
+ viewOptions?: React.ReactNode;
161
+ }
162
+ declare function Toolbar({ viewOptions }?: ToolbarProps): react_jsx_runtime.JSX.Element;
142
163
 
143
- interface ContentProps {
144
- renderCard?: (item: any, index: number) => React.ReactNode;
164
+ interface ContentProps<TData> {
165
+ renderCard?: (item: TData, index: number) => React.ReactNode;
145
166
  gridColumns?: number;
146
167
  gridGap?: number;
147
168
  }
148
- declare function Content({ renderCard, gridColumns, gridGap }: ContentProps): react_jsx_runtime.JSX.Element;
169
+ declare function Content<TData>({ renderCard, gridColumns, gridGap }: ContentProps<TData>): react_jsx_runtime.JSX.Element;
149
170
 
150
171
  declare function TableView(): react_jsx_runtime.JSX.Element;
151
172
 
152
- interface GridViewProps<TData = any> {
173
+ interface GridViewProps<TData> {
153
174
  renderCard?: (item: TData, index: number) => React.ReactNode;
154
175
  columns?: number;
155
176
  gap?: number;
156
177
  }
157
- declare function GridView<TData = any>({ renderCard, columns, gap }: GridViewProps<TData>): react_jsx_runtime.JSX.Element;
178
+ declare function GridView<TData>({ renderCard, columns, gap }: GridViewProps<TData>): react_jsx_runtime.JSX.Element;
158
179
 
159
180
  declare function Pagination(): react_jsx_runtime.JSX.Element;
160
181
 
182
+ interface ViewOptionsProps {
183
+ viewMode?: ViewMode;
184
+ onViewModeChange?: (mode: ViewMode) => void;
185
+ }
186
+ declare function ViewOptions({ viewMode: propViewMode, onViewModeChange: propOnViewModeChange }: ViewOptionsProps): react_jsx_runtime.JSX.Element;
187
+
161
188
  declare const DataTable: typeof Root & {
189
+ Root: typeof Root;
162
190
  Toolbar: typeof Toolbar;
163
191
  Content: typeof Content;
164
192
  TableView: typeof TableView;
165
193
  GridView: typeof GridView;
166
194
  Pagination: typeof Pagination;
195
+ ViewOptions: typeof ViewOptions;
167
196
  };
168
197
 
169
198
  declare function cn(...inputs: ClassValue[]): string;