flysoft-react-ui 1.0.0 → 1.0.2

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.
Files changed (3) hide show
  1. package/AI_CONTEXT.md +218 -0
  2. package/README.md +4 -3
  3. package/package.json +3 -2
package/AI_CONTEXT.md ADDED
@@ -0,0 +1,218 @@
1
+ # Flysoft React UI - AI Context & Documentation
2
+
3
+ This document serves as the source of truth for AI models (Gemini, Claude, GPT, etc.) when generating code that consumes the `flysoft-react-ui` library.
4
+
5
+ ## Library Philosophy
6
+ `flysoft-react-ui` is a React component library built with TypeScript. It emphasizes a consistent look and feel, ease of use, and "premium" aesthetics out of the box.
7
+
8
+ ## 🚨 Critical Rules for AI
9
+ 1. **Top-Level Imports Only**: Always import components from the root package `flysoft-react-ui`.
10
+ - **CORRECT**: `import { Button, Card } from 'flysoft-react-ui';`
11
+ - **INCORRECT**: `import { Button } from 'flysoft-react-ui/components/Button';`
12
+ 2. **TypeScript First**: Use the exported types (e.g., `ButtonProps`, `DataTableColumn`) to ensure type safety.
13
+ 3. **No Direct Style Imports**: Do not import CSS files from the library (like `flysoft-react-ui/dist/index.css`) in components. This is handled at the app root.
14
+
15
+ ## Component Categorization
16
+
17
+ ### 1. Layouts & Structure
18
+ - **AppLayout**: The main wrapper for applications.
19
+ - **Props**: `navbar` (NavbarInterface), `leftDrawer` (LeftDrawerInterface), `children`.
20
+ - **Card**: Generic container with shadow and rounded corners.
21
+ - **Accordion**: Collapsible content sections.
22
+ - **Collection**: Renders a list of items using a render prop or component.
23
+ - **TabsGroup / TabPanel**: Tabbed interfaces.
24
+ - **Menu**: Menu component.
25
+ - **DropdownMenu / DropdownPanel**: Components for building drop-down menus.
26
+ - **DashboardLayout**: Specialized layout for dashboard views with statistics.
27
+ - **SidebarLayout**: Layout with a persistent sidebar.
28
+
29
+ ### 2. Form Controls
30
+ - **Button / LinkButton**: Standard buttons. Supports `variant` ('primary' | 'secondary' | 'danger' | 'ghost') and `icon`.
31
+ - **Input**: Text inputs.
32
+ - **AutocompleteInput**: Searchable dropdown.
33
+ - **SearchSelectInput**: Specialized input for selecting from search results.
34
+ - **DatePicker / DateInput**: Date picking and input.
35
+ - **Checkbox**: Boolean selection.
36
+ - **RadioButtonGroup**: Single selection from a group.
37
+ - **ThemeSwitcher**: Component to toggle theme (light/dark).
38
+ - **FormPattern**: Template pattern for building forms.
39
+
40
+ ### 3. Data Display
41
+ - **DataTable<T>**: High-performance table.
42
+ - **Props**: `columns` (array of definitions), `rows` (data), `isLoading`.
43
+ - **DataField**: Displays a Label + Value pair, useful for detail views.
44
+ - **Pagination**: Pagination controls.
45
+
46
+ ### 4. Utilities & Feedback
47
+ - **Dialog**: Modal windows for confirmation or complex forms.
48
+ - **Filter / FiltersDialog**: Components for filtering lists/tables.
49
+ - **Snackbar**: Toast notifications. Requires `SnackbarContainer` at the app root.
50
+ - **Loader**: Visual loading indicator.
51
+ - **Badge**: Status indicators.
52
+ - **Avatar**: User profile images.
53
+ - **RoadMap**: Progress or stage visualization.
54
+
55
+ ### 5. Ready-to-use Templates
56
+ - **LoginForm**
57
+ - **RegistrationForm**
58
+ - **ContactForm**
59
+
60
+ ## Common Patterns
61
+
62
+ ### Basic Page Usage (Simple Card)
63
+ Use this pattern for simple pages that do not require the full `AppLayout` wrapper or when inserting into an existing structure.
64
+ ```tsx
65
+ import { Card, Button } from 'flysoft-react-ui';
66
+
67
+ export default function SimplePage() {
68
+ return (
69
+ <div className="p-4">
70
+ <Card>
71
+ <h2 className="text-xl font-bold mb-4">Content Title</h2>
72
+ <p className="mb-4">This is the content within a basic card.</p>
73
+ <Button variant="primary" onClick={() => console.log('Clicked')}>
74
+ Action
75
+ </Button>
76
+ </Card>
77
+ </div>
78
+ );
79
+ }
80
+ ```
81
+
82
+ ### Full Page Layout
83
+ ```tsx
84
+ import { AppLayout } from 'flysoft-react-ui';
85
+
86
+ export default function Page() {
87
+ return (
88
+ <AppLayout
89
+ navbar={{ title: "My Page" }}
90
+ >
91
+ {/* Children content goes here */}
92
+ </AppLayout>
93
+ );
94
+ }
95
+ ```
96
+
97
+ ### Data Table Usage
98
+ ```tsx
99
+ import { DataTable, DataTableColumn } from 'flysoft-react-ui';
100
+
101
+ interface User { id: number; name: string; }
102
+
103
+ const columns: DataTableColumn<User>[] = [
104
+ { header: 'ID', accessorKey: 'id' },
105
+ { header: 'Name', accessorKey: 'name' },
106
+ ];
107
+
108
+ <DataTable columns={columns} rows={users} />
109
+ ```
110
+
111
+ ## Contexts & State Management
112
+
113
+ ### 1. AuthContext
114
+ Manages user authentication state.
115
+ - **Provider**: `AuthProvider`
116
+ - **Hook**: `useContext(AuthContext)`
117
+ - **Key Features**: `user`, `login`, `logout`, `isAuthenticated`.
118
+ ```tsx
119
+ import { AuthProvider, AuthContext } from 'flysoft-react-ui';
120
+
121
+ // Wrap app
122
+ <AuthProvider
123
+ getToken={async (user, pass) => ({ token: '...' })}
124
+ getUserData={async (token) => ({ id: 1, name: 'User' })}
125
+ >
126
+ <App />
127
+ </AuthProvider>
128
+
129
+ // Use
130
+ const { login, user } = useContext(AuthContext);
131
+ ```
132
+
133
+ ### 2. CrudContext<T>
134
+ Powerful context for managing standard CRUD operations with pagination, filtering, and loading states.
135
+ - **Provider**: `CrudProvider<T>`
136
+ - **Hook**: `useCrud<T>()`
137
+ - **Key Features**: Auto-fetching, `list`, `item`, `pagination` node, `isLoading`, CRUD actions (`createItem`, `updateItem`, `deleteItem`).
138
+
139
+ **Usage:**
140
+ ```tsx
141
+ import { CrudProvider, useCrud, DataTable } from 'flysoft-react-ui';
142
+
143
+ function UserList() {
144
+ const { list, isLoading, pagination } = useCrud<User>();
145
+ return (
146
+ <div>
147
+ <DataTable rows={list} isLoading={isLoading} ... />
148
+ {pagination}
149
+ </div>
150
+ );
151
+ }
152
+
153
+ // Wrapper
154
+ <CrudProvider
155
+ getPromise={userApi.getAll}
156
+ postPromise={userApi.create}
157
+ putPromise={userApi.update}
158
+ deletePromise={userApi.delete}
159
+ >
160
+ <UserList />
161
+ </CrudProvider>
162
+ ```
163
+
164
+ ### 3. AppLayoutContext
165
+ Controls the global layout state (navbar, visual settings). usually handled internally by `AppLayout` but accessible if needed.
166
+ - **Provider**: `AppLayoutProvider`
167
+ - **Hook**: `useAppLayout()`
168
+
169
+ ### 4. ThemeContext
170
+ Manages the visual theme of the application.
171
+ - **Provider**: `ThemeProvider`
172
+ - **Hook**: `useTheme()`
173
+ - **Features**: Switch between `light`, `dark`, `blue`, `green` themes or custom themes.
174
+
175
+ ```tsx
176
+ ## Hooks & Services
177
+
178
+ ### 1. apiClient (Service)
179
+ A singleton wrapper around Axios with built-in token management and simplified methods.
180
+ - **Methods**: `get`, `post`, `put`, `del`, `getFile`, `downloadFile`, `uploadFile`.
181
+ - **Configuration**: Use `setApiClientTokenProvider(() => token)` to handle auth globally.
182
+
183
+ ```tsx
184
+ import { apiClient } from 'flysoft-react-ui';
185
+
186
+ // GET request
187
+ const users = await apiClient.get<User[]>({ url: '/api/users' });
188
+
189
+ // POST request with body
190
+ const result = await apiClient.post({ url: '/api/users', body: newUser });
191
+
192
+ // Download file (handles blob and filename automatically)
193
+ await apiClient.downloadFile({ url: '/api/report/pdf' });
194
+ ```
195
+
196
+ ### 2. useAsyncRequest (Hook)
197
+ Simplifies handling async operations (loading states, success/error messages via Snackbar).
198
+ - **Props**: `successMessage`, `errorMessage`, `onSuccess`, `onError`.
199
+ - **Returns**: `execute(promiseFn)`, `isLoading`.
200
+
201
+ ```tsx
202
+ import { useAsyncRequest, apiClient } from 'flysoft-react-ui';
203
+
204
+ function UserForm() {
205
+ const { execute, isLoading } = useAsyncRequest({
206
+ successMessage: "User created successfully!",
207
+ errorMessage: "Failed to create user."
208
+ });
209
+
210
+ const handleSubmit = async (data) => {
211
+ await execute(async () => {
212
+ await apiClient.post({ url: '/api/users', body: data });
213
+ });
214
+ };
215
+
216
+ return <Button loading={isLoading} onClick={handleSubmit}>Save</Button>;
217
+ }
218
+ ```
package/README.md CHANGED
@@ -91,9 +91,10 @@ SIEMPRE usa los componentes de flysoft-react-ui antes de crear nuevos:
91
91
 
92
92
  ## Componentes Disponibles:
93
93
 
94
- - Button, Input, Card, Badge, ThemeSwitcher
95
- - LoginForm, RegistrationForm, ContactForm
96
- - DashboardLayout, SidebarLayout, FormPattern
94
+ - Layouts: AppLayout, DashboardLayout, SidebarLayout, Card, Menu, TabsGroup
95
+ - Forms: Button, Input, AutocompleteInput, DatePicker, Checkbox
96
+ - Data: DataTable, DataField, Pagination
97
+ - Templates: LoginForm, RegistrationForm, ContactForm
97
98
 
98
99
  ## Para formularios:
99
100
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flysoft-react-ui",
3
3
  "private": false,
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "type": "module",
6
6
  "description": "A modern React UI component library with Tailwind CSS, TypeScript, and FontAwesome 5. Includes forms, layouts, themes, and templates for rapid development.",
7
7
  "keywords": [
@@ -45,7 +45,8 @@
45
45
  "files": [
46
46
  "dist",
47
47
  "styles.d.ts",
48
- "README.md"
48
+ "README.md",
49
+ "AI_CONTEXT.md"
49
50
  ],
50
51
  "scripts": {
51
52
  "dev": "vite --port 5189 --strictPort",