@saptanshuwanjari/react-component-library 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Saptanshu Wanjari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # React Component Library
2
+
3
+ A modern, lightweight React component library featuring robust DataTable and Form components built with the Compound Component pattern.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **DataTable**: Powerful data table with sorting, filtering, and pagination
8
+ - 📝 **Form**: Flexible form system with validation using react-hook-form and Zod
9
+ - 🎨 **Styled with Tailwind CSS**: Fully customizable with Tailwind
10
+ - 📦 **Tree-shakeable**: Only import what you need
11
+ - 🔷 **TypeScript**: Full type safety
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @your-org/react-component-library
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```tsx
22
+ import { Form, DataTable } from '@your-org/react-component-library';
23
+
24
+ // Form example
25
+ <Form.Root schema={mySchema} onSubmit={handleSubmit}>
26
+ <Form.InputField name="email" label="Email" />
27
+ <Form.Submit>Submit</Form.Submit>
28
+ </Form.Root>
29
+
30
+ // DataTable example
31
+ <DataTable.Root data={data}>
32
+ <DataTable.Header>
33
+ <DataTable.Column>Name</DataTable.Column>
34
+ </DataTable.Header>
35
+ <DataTable.Body />
36
+ </DataTable.Root>
37
+ ```
38
+
39
+ ## Development
40
+
41
+ This library is built with `tsup` for fast bundling. The `example/` folder contains a Next.js app for testing components locally.
42
+
43
+ ```bash
44
+ # Install dependencies
45
+ npm install
46
+
47
+ # Start development mode
48
+ npm run dev
49
+
50
+ # Build for production
51
+ npm run build
52
+ ```
53
+
54
+ ## License
55
+
56
+ MIT
@@ -0,0 +1,171 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import * as react_hook_form from 'react-hook-form';
4
+ import { FieldValues, Path, ControllerRenderProps } from 'react-hook-form';
5
+ import * as z from 'zod';
6
+ import { ColumnDef } from '@tanstack/react-table';
7
+ import { ClassValue } from 'clsx';
8
+
9
+ type ZodSchema = z.ZodTypeAny;
10
+
11
+ type RootProps$1<T extends FieldValues> = {
12
+ schema?: ZodSchema;
13
+ defaultValues?: Partial<T>;
14
+ onSubmit: (values: any) => void | Promise<void>;
15
+ children: React.ReactNode;
16
+ enableOptimistic?: boolean;
17
+ title?: string;
18
+ description?: string;
19
+ enableEditMode?: boolean;
20
+ formId?: string;
21
+ };
22
+ declare function Root$1<T extends FieldValues = FieldValues>({ schema, defaultValues, onSubmit, children, enableOptimistic, title, description, enableEditMode, formId, }: RootProps$1<T>): react_jsx_runtime.JSX.Element;
23
+
24
+ type FieldProps<TFieldValues extends FieldValues> = {
25
+ name: Path<TFieldValues>;
26
+ label?: string;
27
+ children: (field: ControllerRenderProps<TFieldValues, Path<TFieldValues>>) => React.ReactNode;
28
+ };
29
+ declare function Field<TFieldValues extends FieldValues>({ name, label, children, }: FieldProps<TFieldValues>): react_jsx_runtime.JSX.Element;
30
+
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
+ declare const Button$1: ({ children, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
35
+ type EditButtonProps = React.ComponentProps<typeof Button$1> & {
36
+ formId?: string;
37
+ };
38
+ declare function EditButton({ children, formId, ...props }: EditButtonProps): react_jsx_runtime.JSX.Element | null;
39
+
40
+ declare const Button: ({ children, className, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
41
+ declare function CancelButton({ children, ...props }: React.ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element | null;
42
+
43
+ type LinkFieldProps = {
44
+ label?: string;
45
+ link: string;
46
+ LinkComponent?: React.ComponentType<{
47
+ href: string;
48
+ className?: string;
49
+ children: React.ReactNode;
50
+ }>;
51
+ };
52
+ declare function LinkField({ label, link, LinkComponent }: LinkFieldProps): react_jsx_runtime.JSX.Element;
53
+
54
+ declare const Form: typeof Root$1 & {
55
+ Field: typeof Field;
56
+ InputField: <TFieldValues extends react_hook_form.FieldValues>(props: {
57
+ name: react_hook_form.Path<TFieldValues>;
58
+ label?: string;
59
+ placeholder?: string;
60
+ type?: React.HTMLInputTypeAttribute;
61
+ icon?: React.ReactNode;
62
+ iconAlign?: "inline-start" | "inline-end" | "block-start" | "block-end";
63
+ startAddon?: React.ReactNode;
64
+ endAddon?: React.ReactNode;
65
+ useGroup?: boolean;
66
+ }) => react.ReactNode;
67
+ PasswordField: react.MemoExoticComponent<(<TFieldValues extends react_hook_form.FieldValues>({ name, label, placeholder, }: {
68
+ name: react_hook_form.Path<TFieldValues>;
69
+ label?: string;
70
+ placeholder?: string;
71
+ }) => react_jsx_runtime.JSX.Element)>;
72
+ TextareaField: <TFieldValues extends react_hook_form.FieldValues>(props: {
73
+ name: react_hook_form.Path<TFieldValues>;
74
+ label?: string;
75
+ placeholder?: string;
76
+ rows?: number;
77
+ }) => react.ReactNode;
78
+ SelectField: <TFieldValues extends react_hook_form.FieldValues>(props: {
79
+ name: react_hook_form.Path<TFieldValues>;
80
+ label?: string;
81
+ placeholder?: string;
82
+ options: Array<{
83
+ label: string;
84
+ value: string;
85
+ }>;
86
+ }) => react.ReactNode;
87
+ CheckboxField: <TFieldValues extends react_hook_form.FieldValues>(props: {
88
+ name: react_hook_form.Path<TFieldValues>;
89
+ label?: string;
90
+ description?: string;
91
+ }) => react.ReactNode;
92
+ DateField: <TFieldValues extends react_hook_form.FieldValues>(props: {
93
+ name: react_hook_form.Path<TFieldValues>;
94
+ label?: string;
95
+ placeholder?: string;
96
+ }) => react.ReactNode;
97
+ FileField: <TFieldValues extends react_hook_form.FieldValues>(props: {
98
+ name: react_hook_form.Path<TFieldValues>;
99
+ label?: string;
100
+ accept?: string;
101
+ multiple?: boolean;
102
+ }) => react.ReactNode;
103
+ ProfilePictureField: <TFieldValues extends react_hook_form.FieldValues>(props: {
104
+ name: react_hook_form.Path<TFieldValues>;
105
+ label?: string;
106
+ className?: string;
107
+ avatarClassName?: string;
108
+ fallback?: string;
109
+ }) => react.ReactNode;
110
+ Submit: typeof Submit;
111
+ EditButton: typeof EditButton;
112
+ CancelButton: typeof CancelButton;
113
+ Group: ({ children }: {
114
+ children: React.ReactNode;
115
+ }) => react_jsx_runtime.JSX.Element;
116
+ LinkField: typeof LinkField;
117
+ };
118
+
119
+ type ViewMode = 'table' | 'grid';
120
+ interface FilterOption {
121
+ id: string;
122
+ label: string;
123
+ options: {
124
+ value: string;
125
+ label: string;
126
+ }[];
127
+ placeholder?: string;
128
+ multiSelect?: boolean;
129
+ }
130
+
131
+ interface RootProps<TData, TValue> {
132
+ columns: ColumnDef<TData, TValue>[];
133
+ data: TData[];
134
+ filters?: FilterOption[];
135
+ defaultViewMode?: ViewMode;
136
+ defaultPageSize?: number;
137
+ children: React.ReactNode;
138
+ }
139
+ declare function Root<TData, TValue>({ columns, data, filters, defaultViewMode, defaultPageSize, children, }: RootProps<TData, TValue>): react_jsx_runtime.JSX.Element;
140
+
141
+ declare function Toolbar(): react_jsx_runtime.JSX.Element;
142
+
143
+ interface ContentProps {
144
+ renderCard?: (item: any, index: number) => React.ReactNode;
145
+ gridColumns?: number;
146
+ gridGap?: number;
147
+ }
148
+ declare function Content({ renderCard, gridColumns, gridGap }: ContentProps): react_jsx_runtime.JSX.Element;
149
+
150
+ declare function TableView(): react_jsx_runtime.JSX.Element;
151
+
152
+ interface GridViewProps<TData = any> {
153
+ renderCard?: (item: TData, index: number) => React.ReactNode;
154
+ columns?: number;
155
+ gap?: number;
156
+ }
157
+ declare function GridView<TData = any>({ renderCard, columns, gap }: GridViewProps<TData>): react_jsx_runtime.JSX.Element;
158
+
159
+ declare function Pagination(): react_jsx_runtime.JSX.Element;
160
+
161
+ declare const DataTable: typeof Root & {
162
+ Toolbar: typeof Toolbar;
163
+ Content: typeof Content;
164
+ TableView: typeof TableView;
165
+ GridView: typeof GridView;
166
+ Pagination: typeof Pagination;
167
+ };
168
+
169
+ declare function cn(...inputs: ClassValue[]): string;
170
+
171
+ export { DataTable, Form, cn };
@@ -0,0 +1,171 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import * as react_hook_form from 'react-hook-form';
4
+ import { FieldValues, Path, ControllerRenderProps } from 'react-hook-form';
5
+ import * as z from 'zod';
6
+ import { ColumnDef } from '@tanstack/react-table';
7
+ import { ClassValue } from 'clsx';
8
+
9
+ type ZodSchema = z.ZodTypeAny;
10
+
11
+ type RootProps$1<T extends FieldValues> = {
12
+ schema?: ZodSchema;
13
+ defaultValues?: Partial<T>;
14
+ onSubmit: (values: any) => void | Promise<void>;
15
+ children: React.ReactNode;
16
+ enableOptimistic?: boolean;
17
+ title?: string;
18
+ description?: string;
19
+ enableEditMode?: boolean;
20
+ formId?: string;
21
+ };
22
+ declare function Root$1<T extends FieldValues = FieldValues>({ schema, defaultValues, onSubmit, children, enableOptimistic, title, description, enableEditMode, formId, }: RootProps$1<T>): react_jsx_runtime.JSX.Element;
23
+
24
+ type FieldProps<TFieldValues extends FieldValues> = {
25
+ name: Path<TFieldValues>;
26
+ label?: string;
27
+ children: (field: ControllerRenderProps<TFieldValues, Path<TFieldValues>>) => React.ReactNode;
28
+ };
29
+ declare function Field<TFieldValues extends FieldValues>({ name, label, children, }: FieldProps<TFieldValues>): react_jsx_runtime.JSX.Element;
30
+
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
+ declare const Button$1: ({ children, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
35
+ type EditButtonProps = React.ComponentProps<typeof Button$1> & {
36
+ formId?: string;
37
+ };
38
+ declare function EditButton({ children, formId, ...props }: EditButtonProps): react_jsx_runtime.JSX.Element | null;
39
+
40
+ declare const Button: ({ children, className, ...props }: React.ComponentProps<"button">) => react_jsx_runtime.JSX.Element;
41
+ declare function CancelButton({ children, ...props }: React.ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element | null;
42
+
43
+ type LinkFieldProps = {
44
+ label?: string;
45
+ link: string;
46
+ LinkComponent?: React.ComponentType<{
47
+ href: string;
48
+ className?: string;
49
+ children: React.ReactNode;
50
+ }>;
51
+ };
52
+ declare function LinkField({ label, link, LinkComponent }: LinkFieldProps): react_jsx_runtime.JSX.Element;
53
+
54
+ declare const Form: typeof Root$1 & {
55
+ Field: typeof Field;
56
+ InputField: <TFieldValues extends react_hook_form.FieldValues>(props: {
57
+ name: react_hook_form.Path<TFieldValues>;
58
+ label?: string;
59
+ placeholder?: string;
60
+ type?: React.HTMLInputTypeAttribute;
61
+ icon?: React.ReactNode;
62
+ iconAlign?: "inline-start" | "inline-end" | "block-start" | "block-end";
63
+ startAddon?: React.ReactNode;
64
+ endAddon?: React.ReactNode;
65
+ useGroup?: boolean;
66
+ }) => react.ReactNode;
67
+ PasswordField: react.MemoExoticComponent<(<TFieldValues extends react_hook_form.FieldValues>({ name, label, placeholder, }: {
68
+ name: react_hook_form.Path<TFieldValues>;
69
+ label?: string;
70
+ placeholder?: string;
71
+ }) => react_jsx_runtime.JSX.Element)>;
72
+ TextareaField: <TFieldValues extends react_hook_form.FieldValues>(props: {
73
+ name: react_hook_form.Path<TFieldValues>;
74
+ label?: string;
75
+ placeholder?: string;
76
+ rows?: number;
77
+ }) => react.ReactNode;
78
+ SelectField: <TFieldValues extends react_hook_form.FieldValues>(props: {
79
+ name: react_hook_form.Path<TFieldValues>;
80
+ label?: string;
81
+ placeholder?: string;
82
+ options: Array<{
83
+ label: string;
84
+ value: string;
85
+ }>;
86
+ }) => react.ReactNode;
87
+ CheckboxField: <TFieldValues extends react_hook_form.FieldValues>(props: {
88
+ name: react_hook_form.Path<TFieldValues>;
89
+ label?: string;
90
+ description?: string;
91
+ }) => react.ReactNode;
92
+ DateField: <TFieldValues extends react_hook_form.FieldValues>(props: {
93
+ name: react_hook_form.Path<TFieldValues>;
94
+ label?: string;
95
+ placeholder?: string;
96
+ }) => react.ReactNode;
97
+ FileField: <TFieldValues extends react_hook_form.FieldValues>(props: {
98
+ name: react_hook_form.Path<TFieldValues>;
99
+ label?: string;
100
+ accept?: string;
101
+ multiple?: boolean;
102
+ }) => react.ReactNode;
103
+ ProfilePictureField: <TFieldValues extends react_hook_form.FieldValues>(props: {
104
+ name: react_hook_form.Path<TFieldValues>;
105
+ label?: string;
106
+ className?: string;
107
+ avatarClassName?: string;
108
+ fallback?: string;
109
+ }) => react.ReactNode;
110
+ Submit: typeof Submit;
111
+ EditButton: typeof EditButton;
112
+ CancelButton: typeof CancelButton;
113
+ Group: ({ children }: {
114
+ children: React.ReactNode;
115
+ }) => react_jsx_runtime.JSX.Element;
116
+ LinkField: typeof LinkField;
117
+ };
118
+
119
+ type ViewMode = 'table' | 'grid';
120
+ interface FilterOption {
121
+ id: string;
122
+ label: string;
123
+ options: {
124
+ value: string;
125
+ label: string;
126
+ }[];
127
+ placeholder?: string;
128
+ multiSelect?: boolean;
129
+ }
130
+
131
+ interface RootProps<TData, TValue> {
132
+ columns: ColumnDef<TData, TValue>[];
133
+ data: TData[];
134
+ filters?: FilterOption[];
135
+ defaultViewMode?: ViewMode;
136
+ defaultPageSize?: number;
137
+ children: React.ReactNode;
138
+ }
139
+ declare function Root<TData, TValue>({ columns, data, filters, defaultViewMode, defaultPageSize, children, }: RootProps<TData, TValue>): react_jsx_runtime.JSX.Element;
140
+
141
+ declare function Toolbar(): react_jsx_runtime.JSX.Element;
142
+
143
+ interface ContentProps {
144
+ renderCard?: (item: any, index: number) => React.ReactNode;
145
+ gridColumns?: number;
146
+ gridGap?: number;
147
+ }
148
+ declare function Content({ renderCard, gridColumns, gridGap }: ContentProps): react_jsx_runtime.JSX.Element;
149
+
150
+ declare function TableView(): react_jsx_runtime.JSX.Element;
151
+
152
+ interface GridViewProps<TData = any> {
153
+ renderCard?: (item: TData, index: number) => React.ReactNode;
154
+ columns?: number;
155
+ gap?: number;
156
+ }
157
+ declare function GridView<TData = any>({ renderCard, columns, gap }: GridViewProps<TData>): react_jsx_runtime.JSX.Element;
158
+
159
+ declare function Pagination(): react_jsx_runtime.JSX.Element;
160
+
161
+ declare const DataTable: typeof Root & {
162
+ Toolbar: typeof Toolbar;
163
+ Content: typeof Content;
164
+ TableView: typeof TableView;
165
+ GridView: typeof GridView;
166
+ Pagination: typeof Pagination;
167
+ };
168
+
169
+ declare function cn(...inputs: ClassValue[]): string;
170
+
171
+ export { DataTable, Form, cn };