@erpsquad/common 1.7.2 → 1.7.3

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 (28) hide show
  1. package/CHANGELOG.md +0 -25
  2. package/README.md +934 -946
  3. package/dist/{article-cell-editor-JDI676YI-Bgq3iI1C.esm.js → article-cell-editor-JDI676YI-Dc_C73-P.esm.js} +2 -2
  4. package/dist/{article-cell-editor-JDI676YI-Bgq3iI1C.esm.js.map → article-cell-editor-JDI676YI-Dc_C73-P.esm.js.map} +1 -1
  5. package/dist/{article-cell-editor-JDI676YI-C7s2Yz0q.js → article-cell-editor-JDI676YI-DdLmEDri.js} +2 -2
  6. package/dist/{article-cell-editor-JDI676YI-C7s2Yz0q.js.map → article-cell-editor-JDI676YI-DdLmEDri.js.map} +1 -1
  7. package/dist/components/index.d.ts +9 -0
  8. package/dist/components/index.esm.js +91 -82
  9. package/dist/components/index.js +1 -1
  10. package/dist/{index-Ctq0WMb1.js → index-Ch4YhLU3.js} +168 -152
  11. package/dist/index-Ch4YhLU3.js.map +1 -0
  12. package/dist/{index-D-LS9re6.esm.js → index-Ck1uBa0H.esm.js} +1830 -833
  13. package/dist/index-Ck1uBa0H.esm.js.map +1 -0
  14. package/dist/index.esm.js +109 -100
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/{number-overlay-editor-FPDVTUA6-C0znNQy0.esm.js → number-overlay-editor-FPDVTUA6-CIQKpJh_.esm.js} +2 -2
  18. package/dist/{number-overlay-editor-FPDVTUA6-C0znNQy0.esm.js.map → number-overlay-editor-FPDVTUA6-CIQKpJh_.esm.js.map} +1 -1
  19. package/dist/{number-overlay-editor-FPDVTUA6-BUC63sqH.js → number-overlay-editor-FPDVTUA6-CJNQkl_m.js} +2 -2
  20. package/dist/{number-overlay-editor-FPDVTUA6-BUC63sqH.js.map → number-overlay-editor-FPDVTUA6-CJNQkl_m.js.map} +1 -1
  21. package/dist/style.css +3 -3
  22. package/package.json +293 -293
  23. package/src/styles/css/reset.css +1 -7
  24. package/src/styles/index.ts +8 -7
  25. package/src/styles/sass/main.scss +4 -7
  26. package/dist/index-Ctq0WMb1.js.map +0 -1
  27. package/dist/index-D-LS9re6.esm.js.map +0 -1
  28. package/src/styles/sass/_mui-overrides.scss +0 -177
package/README.md CHANGED
@@ -1,946 +1,934 @@
1
- # @erpsquad/common
2
-
3
- A comprehensive React component library for ERP applications, built with Material-UI and TypeScript. This library provides 100+ reusable UI components, theming system, utilities, hooks, and optional Redux integration for building modern ERP applications.
4
-
5
- ## 🚀 Features
6
-
7
- - **100+ UI Components**: Comprehensive set of form controls, data display, navigation, and layout components
8
- - **Material-UI Integration**: Built on top of Material-UI with custom theming
9
- - **TypeScript Support**: Full TypeScript definitions for all components and utilities
10
- - **Flexible Redux Integration**: Optional Redux support - components work with or without Redux
11
- - **Theme System**: Light/dark themes with RTL/LTR support and customizable colors
12
- - **Internationalization**: Built-in i18n support with language switching
13
- - **Tree Shaking**: Optimized for bundle size with proper tree shaking support
14
- - **Accessibility**: WCAG compliant components with proper ARIA attributes
15
- - **Modular Architecture**: Import only what you need to minimize bundle size
16
- - **Peer Dependency Management**: Flexible dependency management for different project setups
17
-
18
- ## 📦 Installation
19
-
20
- ```bash
21
- npm install @erpsquad/common
22
- ```
23
-
24
- ### Peer Dependencies
25
-
26
- The library uses peer dependencies to avoid version conflicts and reduce bundle size. Install the dependencies you need based on your usage:
27
-
28
- #### Required (Core functionality)
29
-
30
- ```bash
31
- npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material
32
- ```
33
-
34
- #### Optional (Feature-specific)
35
-
36
- For Redux integration:
37
-
38
- ```bash
39
- npm install @reduxjs/toolkit react-redux
40
- ```
41
-
42
- For date components:
43
-
44
- ```bash
45
- npm install @mui/x-date-pickers date-fns
46
- ```
47
-
48
- For data grid components:
49
-
50
- ```bash
51
- npm install @mui/x-data-grid
52
- ```
53
-
54
- For routing utilities:
55
-
56
- ```bash
57
- npm install react-router-dom
58
- ```
59
-
60
- For internationalization:
61
-
62
- ```bash
63
- npm install react-i18next i18next
64
- ```
65
-
66
- For utility functions:
67
-
68
- ```bash
69
- npm install lodash axios
70
- ```
71
-
72
- #### Complete Installation (All features)
73
-
74
- ```bash
75
- # Install all peer dependencies for full functionality
76
- npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material @reduxjs/toolkit react-redux @mui/x-date-pickers @mui/x-data-grid date-fns react-router-dom react-i18next i18next lodash axios
77
- ```
78
-
79
- ## 🎯 Quick Start
80
-
81
- ### Core Usage (Minimal dependencies)
82
-
83
- The library provides core functionality without requiring all peer dependencies:
84
-
85
- ```tsx
86
- import React from 'react';
87
- import {
88
- configureLibrary,
89
- getLibraryConfig,
90
- images,
91
- DEFAULT_LANG,
92
- type LibraryConfig
93
- } from '@erpsquad/common';
94
-
95
- // Configure library for your application
96
- const config: LibraryConfig = {
97
- routes: {
98
- login: '/auth/login',
99
- dashboard: '/dashboard'
100
- },
101
- validation: {
102
- emailRequired: true,
103
- phoneRequired: false
104
- },
105
- dataTransforms: {
106
- dateFormat: 'dd/MM/yyyy'
107
- }
108
- };
109
-
110
- configureLibrary(config);
111
-
112
- function App() {
113
- const currentConfig = getLibraryConfig();
114
-
115
- return (
116
- <div>
117
- <img src={images.logo} alt='Logo' />
118
- <p>Default language: {DEFAULT_LANG}</p>
119
- <p>Login route: {currentConfig.routes?.login}</p>
120
- </div>
121
- );
122
- }
123
-
124
- export default App;
125
- ```
126
-
127
- ### Available Core Exports
128
-
129
- The following exports are available without peer dependencies:
130
-
131
- ```tsx
132
- // Configuration system
133
- import {
134
- configureLibrary,
135
- getLibraryConfig,
136
- getConfigFunction,
137
- type LibraryConfig
138
- } from '@erpsquad/common';
139
-
140
- // Static assets
141
- import { default as images } from '@erpsquad/common';
142
-
143
- // Constants
144
- import { DEFAULT_LANG, LANGUAGES, S3_BUCKET_URL } from '@erpsquad/common';
145
-
146
- // TypeScript types
147
- import type {
148
- BaseComponentProps,
149
- ThemeConfig,
150
- SelectOption,
151
- TableColumn,
152
- User,
153
- Permission
154
- } from '@erpsquad/common';
155
- ```
156
-
157
- ### Full Usage (With peer dependencies)
158
-
159
- After installing peer dependencies, you can use all components:
160
-
161
- ```tsx
162
- import React from 'react';
163
- // Note: Import from specific paths to avoid dependency issues
164
- import { ERPUIProvider } from '@erpsquad/common/contexts';
165
- import { Button, TextField } from '@erpsquad/common/components';
166
-
167
- function App() {
168
- return (
169
- <ERPUIProvider>
170
- <div>
171
- <TextField label='Name' variant='outlined' />
172
- <Button variant='contained' color='primary'>
173
- Submit
174
- </Button>
175
- </div>
176
- </ERPUIProvider>
177
- );
178
- }
179
-
180
- export default App;
181
- ```
182
-
183
- ### With Custom Theme
184
-
185
- ```tsx
186
- import React from 'react';
187
- import { ERPUIProvider } from '@erpsquad/common/contexts';
188
- import { Button } from '@erpsquad/common/components';
189
- import { createLightTheme } from '@erpsquad/common/theme';
190
-
191
- function App() {
192
- const { theme } = createLightTheme('#2196f3', 'ltr');
193
-
194
- return (
195
- <ERPUIProvider
196
- theme={theme}
197
- themeMode='dark'
198
- primaryColor='#2196f3'
199
- enableCssBaseline={true}>
200
- <Button variant='contained'>Dark Theme Button</Button>
201
- </ERPUIProvider>
202
- );
203
- }
204
- ```
205
-
206
- ## 🎨 Theme System
207
-
208
- The library includes a comprehensive theming system with support for light/dark modes, RTL/LTR direction, and custom colors.
209
-
210
- ### Theme Configuration
211
-
212
- ```tsx
213
- import { ERPUIProvider } from '@erpsquad/common/contexts';
214
-
215
- <ERPUIProvider
216
- themeMode='light' // 'light' | 'dark'
217
- primaryColor='#1976d2' // Any valid color
218
- direction='ltr' // 'ltr' | 'rtl'
219
- enableCssBaseline={true}>
220
- <App />
221
- </ERPUIProvider>;
222
- ```
223
-
224
- ### Custom Theme Object
225
-
226
- ```tsx
227
- import { createLightTheme, createDarkTheme } from '@erpsquad/common/theme';
228
- import { ERPUIProvider } from '@erpsquad/common/contexts';
229
-
230
- // Create custom theme
231
- const { theme } = createLightTheme('#1976d2', 'ltr');
232
-
233
- // Or create dark theme
234
- const { darkTheme } = createDarkTheme('#1976d2', 'ltr');
235
-
236
- <ERPUIProvider theme={theme}>
237
- <App />
238
- </ERPUIProvider>;
239
- ```
240
-
241
- ### Available Colors
242
-
243
- The library supports various color formats:
244
-
245
- - Hex colors: `#1976d2`
246
- - RGB: `rgb(25, 118, 210)`
247
- - Color names: `blue`, `red`, `green`
248
- - Material-UI color objects
249
-
250
- ## 🎨 Styles & SCSS
251
-
252
- The library provides a comprehensive styling system with compiled CSS, SCSS variables, mixins, utility classes, and animations.
253
-
254
- ### Import Compiled CSS (Recommended)
255
-
256
- Add this to your main application file:
257
-
258
- ```tsx
259
- // main.tsx or App.tsx
260
- import '@erpsquad/common/style.css';
261
- ```
262
-
263
- **Important for MUI users:** Wrap your app with the `erp-ui-app` class for proper style override:
264
-
265
- ```tsx
266
- function App() {
267
- return (
268
- <div className="erp-ui-app">
269
- {/* Your components */}
270
- </div>
271
- );
272
- }
273
- ```
274
-
275
- This gives you:
276
- - All component styles
277
- - Utility classes for rapid development
278
- - Responsive styles
279
- - Animations
280
-
281
- ### Using Utility Classes
282
-
283
- ```tsx
284
- <div className="d-flex justify-content-center align-items-center mb-2">
285
- <h1 className="h2 bold">Welcome</h1>
286
- <p className="s2 normal text-center">Description text</p>
287
- </div>
288
- ```
289
-
290
- Available utility classes:
291
- - **Layout**: `d-flex`, `flex-direction-column`, `justify-content-center`, `align-items-center`
292
- - **Spacing**: `mb-1`, `mt-2`, `p-0`, `pl-2` (padding/margin utilities)
293
- - **Typography**: `h1`-`h5` (headings), `s1`-`s5` (body text), `bold`, `medium`, `normal`
294
- - **Width/Height**: `w-100`, `w-50`, `h-100`, `vh-100`
295
- - **Text Alignment**: `text-center`, `text-left`, `text-right`
296
-
297
- ### Using SCSS Variables (Advanced)
298
-
299
- Import SCSS variables in your `.scss` files:
300
-
301
- ```scss
302
- // your-component.scss
303
- @import '@erpsquad/common/styles/variables';
304
-
305
- .custom-component {
306
- background-color: $primary-600;
307
- color: $neutral-100;
308
- border: 1px solid $neutral-300;
309
- }
310
- ```
311
-
312
- Available color scales (100-1000):
313
- - `$primary-*` (green), `$neutral-*` (gray), `$error-*` (red)
314
- - `$blue-*`, `$magenta-*`, `$olive-*`, `$green-*`, `$lightGreen-*`
315
-
316
- ### Using SCSS Mixins (Advanced)
317
-
318
- ```scss
319
- // your-component.scss
320
- @import '@erpsquad/common/styles/mixins';
321
-
322
- .responsive-layout {
323
- @include flex(center, space-between, row);
324
-
325
- @include media-md {
326
- flex-direction: column;
327
- }
328
- }
329
- ```
330
-
331
- Available mixins:
332
- - `@include flex($align, $justify, $direction)` - Flexbox shorthand
333
- - `@include transition($time, $motion)` - Transition shorthand
334
- - `@include center` - Absolute center positioning
335
- - Responsive breakpoints: `@include media-sm`, `@include media-md`, `@include media-l`, etc.
336
-
337
- ### Import All SCSS Features
338
-
339
- ```scss
340
- // For complete access to variables, mixins, utilities, and animations
341
- @import '@erpsquad/common/styles/all';
342
- ```
343
-
344
- **📚 For detailed styles documentation, see:**
345
- - [Complete Styles Documentation](./src/styles/README.md)
346
- - [Styles Usage Guide](./STYLES_USAGE.md)
347
- - [Migration Guide](./STYLES_MIGRATION.md)
348
-
349
- ## 📁 Modular Import System
350
-
351
- The library uses a modular import system to prevent dependency issues. Import from specific paths based on your needs:
352
-
353
- ```tsx
354
- // Core functionality (no peer dependencies required)
355
- import { configureLibrary, images } from '@erpsquad/common';
356
-
357
- // Components (requires React, MUI peer dependencies)
358
- import { Button, TextField } from '@erpsquad/common/components';
359
-
360
- // Hooks (requires React peer dependencies)
361
- import { useAuth, useLanguage } from '@erpsquad/common/hooks';
362
-
363
- // Contexts (requires React peer dependencies)
364
- import { ERPUIProvider, AuthProvider } from '@erpsquad/common/contexts';
365
-
366
- // Theme utilities (requires MUI peer dependencies)
367
- import { createLightTheme, createDarkTheme } from '@erpsquad/common/theme';
368
-
369
- // Utility functions (may require specific peer dependencies)
370
- import { formatDate, validateEmail } from '@erpsquad/common/utils';
371
-
372
- // Redux integration (requires Redux peer dependencies)
373
- import { createLibraryStore, slices } from '@erpsquad/common/redux';
374
-
375
- // API clients (requires axios peer dependency)
376
- import { AccountingAPI, InventoryAPI } from '@erpsquad/common/api-client';
377
-
378
- // Styles (CSS bundle - recommended)
379
- import '@erpsquad/common/style.css';
380
-
381
- // Styles (SCSS imports for advanced usage)
382
- // Import in .scss files only:
383
- // @import '@erpsquad/common/styles/variables';
384
- // @import '@erpsquad/common/styles/mixins';
385
- // @import '@erpsquad/common/styles/all';
386
- ```
387
-
388
- ## 🔌 API Clients
389
-
390
- The library includes pre-configured API clients for different ERP modules:
391
-
392
- ```tsx
393
- import {
394
- AccountingAPI,
395
- InventoryAPI,
396
- ManufacturingAPI,
397
- PurchaseAPI,
398
- SalesAPI,
399
- RentalAPI,
400
- RbacAPI,
401
- DriveAPI,
402
- SystemFeatureAPI
403
- } from '@erpsquad/common/api-client';
404
-
405
- // Configure base API client
406
- const baseConfig = {
407
- baseURL: 'https://api.example.com',
408
- timeout: 10000,
409
- headers: {
410
- 'Content-Type': 'application/json'
411
- }
412
- };
413
-
414
- // Use specific API clients
415
- const accountingClient = new AccountingAPI(baseConfig);
416
- const inventoryClient = new InventoryAPI(baseConfig);
417
-
418
- // Example usage
419
- const users = await accountingClient.getUsers();
420
- const products = await inventoryClient.getProducts();
421
- ```
422
-
423
- ## 🔧 Components
424
-
425
- ### Form Controls
426
-
427
- ```tsx
428
- import {
429
- TextField,
430
- Select,
431
- DatePicker,
432
- Checkbox,
433
- Radio,
434
- ToggleSwitch,
435
- Button
436
- } from '@erpsquad/common/components';
437
-
438
- // Text input
439
- <TextField
440
- label="Email"
441
- type="email"
442
- variant="outlined"
443
- required
444
- />
445
-
446
- // Select dropdown
447
- <Select
448
- label="Country"
449
- options={countries}
450
- value={selectedCountry}
451
- onChange={handleCountryChange}
452
- />
453
-
454
- // Date picker (requires @mui/x-date-pickers)
455
- <DatePicker
456
- label="Birth Date"
457
- value={birthDate}
458
- onChange={setBirthDate}
459
- />
460
- ```
461
-
462
- ### Data Display
463
-
464
- ```tsx
465
- import {
466
- MaterialTable,
467
- Grid,
468
- CardWrapper,
469
- Avatar,
470
- Chip
471
- } from '@erpsquad/common/components';
472
-
473
- // Data table (requires @mui/x-data-grid)
474
- <MaterialTable
475
- columns={columns}
476
- data={data}
477
- title="Users"
478
- options={{
479
- search: true,
480
- pagination: true,
481
- sorting: true
482
- }}
483
- />
484
-
485
- // Grid layout
486
- <Grid container spacing={2}>
487
- <Grid item xs={12} md={6}>
488
- <CardWrapper>Content</CardWrapper>
489
- </Grid>
490
- </Grid>
491
- ```
492
-
493
- ### Navigation
494
-
495
- ```tsx
496
- import {
497
- Sidebar,
498
- BreadCrumb,
499
- Pagination,
500
- Tabs
501
- } from '@erpsquad/common/components';
502
-
503
- // Sidebar navigation
504
- <Sidebar
505
- items={navigationItems}
506
- collapsed={isCollapsed}
507
- onItemClick={handleNavigation}
508
- />
509
-
510
- // Breadcrumb (requires react-router-dom for navigation)
511
- <BreadCrumb
512
- items={[
513
- { label: 'Home', href: '/' },
514
- { label: 'Users', href: '/users' },
515
- { label: 'Profile' }
516
- ]}
517
- />
518
- ```
519
-
520
- ### Feedback
521
-
522
- ```tsx
523
- import {
524
- CustomSnackbar,
525
- Toast,
526
- Loader,
527
- Alert,
528
- Modal
529
- } from '@erpsquad/common/components';
530
-
531
- // Loading indicator
532
- <Loader size="large" text="Loading data..." />
533
-
534
- // Alert message
535
- <Alert severity="success" onClose={handleClose}>
536
- Operation completed successfully!
537
- </Alert>
538
-
539
- // Snackbar notification
540
- <CustomSnackbar
541
- open={isOpen}
542
- message="Operation completed successfully!"
543
- severity="success"
544
- onClose={handleClose}
545
- />
546
-
547
- // Modal dialog
548
- <Modal
549
- open={isOpen}
550
- onClose={handleClose}
551
- title="Confirm Action"
552
- actions={[
553
- { label: 'Cancel', onClick: handleClose },
554
- { label: 'Confirm', onClick: handleConfirm, variant: 'contained' }
555
- ]}
556
- >
557
- Are you sure you want to proceed?
558
- </Modal>
559
- ```
560
-
561
- ## 🔄 Redux Integration
562
-
563
- The library provides flexible Redux integration that works with or without Redux. Requires `@reduxjs/toolkit` and `react-redux` peer dependencies.
564
-
565
- ### With Redux (Recommended for complex applications)
566
-
567
- ```tsx
568
- import { ERPUIProvider } from '@erpsquad/common/contexts';
569
- import {
570
- createLibraryStore,
571
- createConfiguredApiClient
572
- } from '@erpsquad/common/redux';
573
- import { ShareModal } from '@erpsquad/common/components';
574
-
575
- // Configure API client
576
- const apiClient = createConfiguredApiClient(baseApiClient, () => ({
577
- authorization: `Bearer ${getAuthToken()}`
578
- }));
579
-
580
- // Create store with library slices
581
- const store = createLibraryStore(
582
- {
583
- // Your app reducers
584
- app: appReducer,
585
- user: userReducer
586
- },
587
- apiClient
588
- );
589
-
590
- function App() {
591
- return (
592
- <ERPUIProvider useRedux={true} reduxStore={store} apiClient={apiClient}>
593
- <ShareModal useRedux={true} />
594
- </ERPUIProvider>
595
- );
596
- }
597
- ```
598
-
599
- ### Without Redux (Simpler applications)
600
-
601
- ```tsx
602
- import { ERPUIProvider } from '@erpsquad/common/contexts';
603
- import { ShareModal } from '@erpsquad/common/components';
604
-
605
- function App() {
606
- const [users, setUsers] = useState([]);
607
- const [loading, setLoading] = useState(false);
608
-
609
- const fetchUsers = async () => {
610
- setLoading(true);
611
- try {
612
- const response = await api.getUsers();
613
- setUsers(response.data);
614
- } finally {
615
- setLoading(false);
616
- }
617
- };
618
-
619
- return (
620
- <ERPUIProvider useRedux={false}>
621
- <ShareModal
622
- useRedux={false}
623
- users={users}
624
- loading={loading}
625
- onFetchUsersAndDepartments={fetchUsers}
626
- />
627
- </ERPUIProvider>
628
- );
629
- }
630
- ```
631
-
632
- ### Available Redux Slices
633
-
634
- - **shareSlice**: User and department data for sharing functionality
635
- - **headerSlice**: Language data and current language selection
636
- - **reportsTitleBarSlice**: Company data for reports filtering
637
- - **inventoryReportsTitleBarSlice**: Inventory-related data for reports
638
-
639
- ## 🪝 Hooks
640
-
641
- ### Custom Hooks
642
-
643
- ```tsx
644
- import {
645
- useAuth,
646
- useLanguage,
647
- usePermissions,
648
- usePages,
649
- useDeepMemo,
650
- useReduxIntegration
651
- } from '@erpsquad/common/hooks';
652
-
653
- // Authentication hook
654
- const { user, isAuthenticated, login, logout } = useAuth();
655
-
656
- // Language hook (requires react-i18next)
657
- const { currentLanguage, changeLanguage, t } = useLanguage();
658
-
659
- // Permissions hook
660
- const { hasPermission, checkPermission } = usePermissions();
661
-
662
- // Deep memoization hook
663
- const memoizedValue = useDeepMemo(() => expensiveCalculation(data), [data]);
664
- ```
665
-
666
- ### Redux Integration Hook
667
-
668
- ```tsx
669
- import { useReduxIntegration } from '@erpsquad/common/hooks';
670
-
671
- const MyComponent = ({ useRedux, ...props }) => {
672
- const { data, loading, error, actions } = useReduxIntegration({
673
- useRedux,
674
- sliceName: 'share',
675
- fallbackData: props.users,
676
- fallbackLoading: props.loading,
677
- fallbackActions: {
678
- fetchData: props.onFetchUsers
679
- }
680
- });
681
-
682
- // Component logic using unified interface
683
- };
684
- ```
685
-
686
- ## 🛠️ Utilities
687
-
688
- ### Common Utilities
689
-
690
- ```tsx
691
- import {
692
- formatDate,
693
- formatFileSize,
694
- formatText,
695
- deformatText,
696
- colorUtils
697
- } from '@erpsquad/common/utils';
698
-
699
- // Date formatting (requires date-fns)
700
- const formattedDate = formatDate(new Date(), 'dd/MM/yyyy');
701
-
702
- // File size formatting
703
- const fileSize = formatFileSize(1024000); // "1.02 MB"
704
-
705
- // Text formatting
706
- const formatted = formatText('hello world', 'title'); // "Hello World"
707
-
708
- // Color utilities
709
- const hexColor = colorUtils.rgbToHex(255, 0, 0); // "#ff0000"
710
- ```
711
-
712
- ## 🌐 Internationalization
713
-
714
- Requires `react-i18next` and `i18next` peer dependencies.
715
-
716
- ### Language Provider
717
-
718
- ```tsx
719
- import { ERPUIProvider } from '@erpsquad/common/contexts';
720
-
721
- <ERPUIProvider
722
- enableLanguage={true}
723
- // Other props
724
- >
725
- <App />
726
- </ERPUIProvider>;
727
- ```
728
-
729
- ### Using Translations
730
-
731
- ```tsx
732
- import { useLanguage } from '@erpsquad/common/hooks';
733
-
734
- const MyComponent = () => {
735
- const { t, currentLanguage, changeLanguage } = useLanguage();
736
-
737
- return (
738
- <div>
739
- <p>{t('common.welcome')}</p>
740
- <button onClick={() => changeLanguage('es')}>Switch to Spanish</button>
741
- </div>
742
- );
743
- };
744
- ```
745
-
746
- ## 🧪 Testing
747
-
748
- The library includes comprehensive testing utilities:
749
-
750
- ```tsx
751
- import { render, screen } from '@testing-library/react';
752
- import { ERPUIProvider } from '@erpsquad/common/contexts';
753
- import { Button } from '@erpsquad/common/components';
754
-
755
- test('renders button correctly', () => {
756
- render(
757
- <ERPUIProvider>
758
- <Button>Click me</Button>
759
- </ERPUIProvider>
760
- );
761
-
762
- expect(screen.getByRole('button')).toBeInTheDocument();
763
- });
764
- ```
765
-
766
- ## 📚 API Reference
767
-
768
- ### ERPUIProvider Props
769
-
770
- | Prop | Type | Default | Description |
771
- | ---------------- | ------------------- | ----------- | ------------------------ |
772
- | `useRedux` | `boolean` | `false` | Enable Redux integration |
773
- | `reduxStore` | `Store` | `undefined` | Custom Redux store |
774
- | `apiClient` | `ApiClientConfig` | `undefined` | API client configuration |
775
- | `themeMode` | `'light' \| 'dark'` | `'light'` | Theme mode |
776
- | `primaryColor` | `string` | `undefined` | Primary theme color |
777
- | `direction` | `'ltr' \| 'rtl'` | `'ltr'` | Text direction |
778
- | `enableAuth` | `boolean` | `true` | Enable auth context |
779
- | `enableLanguage` | `boolean` | `true` | Enable language context |
780
- | `enableRouter` | `boolean` | `false` | Enable router provider |
781
- | `enableSnackbar` | `boolean` | `true` | Enable snackbar provider |
782
-
783
- ### Component Props
784
-
785
- All components extend their respective Material-UI component props with additional ERP-specific functionality. Refer to individual component documentation for detailed prop information.
786
-
787
- ## 🔧 Development
788
-
789
- ### Building the Library
790
-
791
- ```bash
792
- # Production build
793
- npm run build
794
-
795
- # Build with analysis
796
- npm run build:analyze
797
-
798
- # Build with validation
799
- npm run build:validate
800
-
801
- # Clean build artifacts
802
- npm run clean
803
- ```
804
-
805
- ### Running Tests
806
-
807
- ```bash
808
- # Run all tests
809
- npm test
810
-
811
- # Run tests in CI mode
812
- npm run test:ci
813
-
814
- # Type checking
815
- npm run type-check
816
-
817
- # Linting
818
- npm run lint
819
- npm run lint:fix
820
- ```
821
-
822
- ### Package Validation
823
-
824
- ```bash
825
- # Validate package structure
826
- npm run validate:package
827
-
828
- # Check bundle size limits
829
- npm run size-check
830
-
831
- # Full validation (lint + type-check + test + build)
832
- npm run validate
833
- ```
834
-
835
- ## 📈 Bundle Analysis
836
-
837
- ```bash
838
- # Analyze bundle size and composition
839
- npm run build:analyze
840
-
841
- # Check size limits against configuration
842
- npm run size-check
843
-
844
- # Validate package contents before publishing
845
- npm run validate:package
846
- ```
847
-
848
- ## 🚨 Troubleshooting
849
-
850
- ### Common Issues
851
-
852
- #### Import Errors
853
-
854
- ```bash
855
- # Error: Cannot resolve '@erpsquad/common/components'
856
- # Solution: Install required peer dependencies
857
- npm install @mui/material @emotion/react @emotion/styled
858
-
859
- # Error: Module not found
860
- # Solution: Use correct import paths
861
- import { Button } from '@erpsquad/common/components'; // ✅ Correct
862
- import { Button } from '@erpsquad/common'; // ❌ Incorrect for components
863
- ```
864
-
865
- #### Peer Dependency Warnings
866
-
867
- ```bash
868
- # Warning: peer dependency not installed
869
- # Solution: Install the specific peer dependency
870
- npm install react-redux @reduxjs/toolkit
871
-
872
- # Or install all peer dependencies
873
- npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material
874
- ```
875
-
876
- #### TypeScript Errors
877
-
878
- ```bash
879
- # Error: Cannot find type definitions
880
- # Solution: Ensure TypeScript types are properly imported
881
- import type { LibraryConfig } from '@erpsquad/common';
882
-
883
- # Error: Module has no exported member
884
- # Solution: Check if the export requires peer dependencies
885
- import { useAuth } from '@erpsquad/common/hooks'; // Requires React
886
- ```
887
-
888
- #### Build Issues
889
-
890
- ```bash
891
- # Error: Module not found during build
892
- # Solution: Check if all peer dependencies are installed
893
- # and properly configured in your build tool
894
-
895
- # For Vite projects, add to vite.config.ts:
896
- export default defineConfig({
897
- optimizeDeps: {
898
- include: ['@erpsquad/common']
899
- }
900
- });
901
-
902
- # For Webpack projects, ensure proper externals configuration
903
- ```
904
-
905
- ### Getting Help
906
-
907
- - Check the [troubleshooting guide](./TROUBLESHOOTING.md)
908
- - Review [migration documentation](./MIGRATION.md)
909
- - Search [existing issues](https://github.com/erpforce/common/issues)
910
- - Create a [new issue](https://github.com/erpforce/common/issues/new)
911
-
912
- ## 🤝 Contributing
913
-
914
- 1. Fork the repository
915
- 2. Create a feature branch: `git checkout -b feature/new-component`
916
- 3. Make your changes and add tests
917
- 4. Run tests: `npm test`
918
- 5. Run linting: `npm run lint`
919
- 6. Commit your changes: `git commit -m 'Add new component'`
920
- 7. Push to the branch: `git push origin feature/new-component`
921
- 8. Submit a pull request
922
-
923
- ### Development Guidelines
924
-
925
- - Follow TypeScript best practices
926
- - Write comprehensive tests for new components
927
- - Update documentation for API changes
928
- - Ensure accessibility compliance
929
- - Maintain backward compatibility
930
-
931
- ## 📄 License
932
-
933
- MIT License - see the [LICENSE](LICENSE) file for details.
934
-
935
- ## 🆘 Support
936
-
937
- - **Documentation**: [Library Docs](https://github.com/erpforce/erpforce-common-hub-fe/tree/dev#readme)
938
- - **Issues**: [GitHub Issues](https://github.com/erpforce/erpforce-common-hub-fe/issues)
939
- - **NPM Package**: [@erpsquad/common](https://www.npmjs.com/package/@erpsquad/common)
940
- - **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
941
- - **Migration Guide**: [MIGRATION.md](./MIGRATION.md)
942
- - **Troubleshooting**: [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
943
-
944
- ## 📋 Changelog
945
-
946
- See [CHANGELOG.md](CHANGELOG.md) for a detailed list of changes and version history.
1
+ # @erpsquad/common
2
+
3
+ A comprehensive React component library for ERP applications, built with Material-UI and TypeScript. This library provides 100+ reusable UI components, theming system, utilities, hooks, and optional Redux integration for building modern ERP applications.
4
+
5
+ ## 🚀 Features
6
+
7
+ - **100+ UI Components**: Comprehensive set of form controls, data display, navigation, and layout components
8
+ - **Material-UI Integration**: Built on top of Material-UI with custom theming
9
+ - **TypeScript Support**: Full TypeScript definitions for all components and utilities
10
+ - **Flexible Redux Integration**: Optional Redux support - components work with or without Redux
11
+ - **Theme System**: Light/dark themes with RTL/LTR support and customizable colors
12
+ - **Internationalization**: Built-in i18n support with language switching
13
+ - **Tree Shaking**: Optimized for bundle size with proper tree shaking support
14
+ - **Accessibility**: WCAG compliant components with proper ARIA attributes
15
+ - **Modular Architecture**: Import only what you need to minimize bundle size
16
+ - **Peer Dependency Management**: Flexible dependency management for different project setups
17
+
18
+ ## 📦 Installation
19
+
20
+ ```bash
21
+ npm install @erpsquad/common
22
+ ```
23
+
24
+ ### Peer Dependencies
25
+
26
+ The library uses peer dependencies to avoid version conflicts and reduce bundle size. Install the dependencies you need based on your usage:
27
+
28
+ #### Required (Core functionality)
29
+
30
+ ```bash
31
+ npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material
32
+ ```
33
+
34
+ #### Optional (Feature-specific)
35
+
36
+ For Redux integration:
37
+
38
+ ```bash
39
+ npm install @reduxjs/toolkit react-redux
40
+ ```
41
+
42
+ For date components:
43
+
44
+ ```bash
45
+ npm install @mui/x-date-pickers date-fns
46
+ ```
47
+
48
+ For data grid components:
49
+
50
+ ```bash
51
+ npm install @mui/x-data-grid
52
+ ```
53
+
54
+ For routing utilities:
55
+
56
+ ```bash
57
+ npm install react-router-dom
58
+ ```
59
+
60
+ For internationalization:
61
+
62
+ ```bash
63
+ npm install react-i18next i18next
64
+ ```
65
+
66
+ For utility functions:
67
+
68
+ ```bash
69
+ npm install lodash axios
70
+ ```
71
+
72
+ #### Complete Installation (All features)
73
+
74
+ ```bash
75
+ # Install all peer dependencies for full functionality
76
+ npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material @reduxjs/toolkit react-redux @mui/x-date-pickers @mui/x-data-grid date-fns react-router-dom react-i18next i18next lodash axios
77
+ ```
78
+
79
+ ## 🎯 Quick Start
80
+
81
+ ### Core Usage (Minimal dependencies)
82
+
83
+ The library provides core functionality without requiring all peer dependencies:
84
+
85
+ ```tsx
86
+ import React from 'react';
87
+ import {
88
+ configureLibrary,
89
+ getLibraryConfig,
90
+ images,
91
+ DEFAULT_LANG,
92
+ type LibraryConfig
93
+ } from '@erpsquad/common';
94
+
95
+ // Configure library for your application
96
+ const config: LibraryConfig = {
97
+ routes: {
98
+ login: '/auth/login',
99
+ dashboard: '/dashboard'
100
+ },
101
+ validation: {
102
+ emailRequired: true,
103
+ phoneRequired: false
104
+ },
105
+ dataTransforms: {
106
+ dateFormat: 'dd/MM/yyyy'
107
+ }
108
+ };
109
+
110
+ configureLibrary(config);
111
+
112
+ function App() {
113
+ const currentConfig = getLibraryConfig();
114
+
115
+ return (
116
+ <div>
117
+ <img src={images.logo} alt='Logo' />
118
+ <p>Default language: {DEFAULT_LANG}</p>
119
+ <p>Login route: {currentConfig.routes?.login}</p>
120
+ </div>
121
+ );
122
+ }
123
+
124
+ export default App;
125
+ ```
126
+
127
+ ### Available Core Exports
128
+
129
+ The following exports are available without peer dependencies:
130
+
131
+ ```tsx
132
+ // Configuration system
133
+ import {
134
+ configureLibrary,
135
+ getLibraryConfig,
136
+ getConfigFunction,
137
+ type LibraryConfig
138
+ } from '@erpsquad/common';
139
+
140
+ // Static assets
141
+ import { default as images } from '@erpsquad/common';
142
+
143
+ // Constants
144
+ import { DEFAULT_LANG, LANGUAGES, S3_BUCKET_URL } from '@erpsquad/common';
145
+
146
+ // TypeScript types
147
+ import type {
148
+ BaseComponentProps,
149
+ ThemeConfig,
150
+ SelectOption,
151
+ TableColumn,
152
+ User,
153
+ Permission
154
+ } from '@erpsquad/common';
155
+ ```
156
+
157
+ ### Full Usage (With peer dependencies)
158
+
159
+ After installing peer dependencies, you can use all components:
160
+
161
+ ```tsx
162
+ import React from 'react';
163
+ // Note: Import from specific paths to avoid dependency issues
164
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
165
+ import { Button, TextField } from '@erpsquad/common/components';
166
+
167
+ function App() {
168
+ return (
169
+ <ERPUIProvider>
170
+ <div>
171
+ <TextField label='Name' variant='outlined' />
172
+ <Button variant='contained' color='primary'>
173
+ Submit
174
+ </Button>
175
+ </div>
176
+ </ERPUIProvider>
177
+ );
178
+ }
179
+
180
+ export default App;
181
+ ```
182
+
183
+ ### With Custom Theme
184
+
185
+ ```tsx
186
+ import React from 'react';
187
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
188
+ import { Button } from '@erpsquad/common/components';
189
+ import { createLightTheme } from '@erpsquad/common/theme';
190
+
191
+ function App() {
192
+ const { theme } = createLightTheme('#2196f3', 'ltr');
193
+
194
+ return (
195
+ <ERPUIProvider
196
+ theme={theme}
197
+ themeMode='dark'
198
+ primaryColor='#2196f3'
199
+ enableCssBaseline={true}>
200
+ <Button variant='contained'>Dark Theme Button</Button>
201
+ </ERPUIProvider>
202
+ );
203
+ }
204
+ ```
205
+
206
+ ## 🎨 Theme System
207
+
208
+ The library includes a comprehensive theming system with support for light/dark modes, RTL/LTR direction, and custom colors.
209
+
210
+ ### Theme Configuration
211
+
212
+ ```tsx
213
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
214
+
215
+ <ERPUIProvider
216
+ themeMode='light' // 'light' | 'dark'
217
+ primaryColor='#1976d2' // Any valid color
218
+ direction='ltr' // 'ltr' | 'rtl'
219
+ enableCssBaseline={true}>
220
+ <App />
221
+ </ERPUIProvider>;
222
+ ```
223
+
224
+ ### Custom Theme Object
225
+
226
+ ```tsx
227
+ import { createLightTheme, createDarkTheme } from '@erpsquad/common/theme';
228
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
229
+
230
+ // Create custom theme
231
+ const { theme } = createLightTheme('#1976d2', 'ltr');
232
+
233
+ // Or create dark theme
234
+ const { darkTheme } = createDarkTheme('#1976d2', 'ltr');
235
+
236
+ <ERPUIProvider theme={theme}>
237
+ <App />
238
+ </ERPUIProvider>;
239
+ ```
240
+
241
+ ### Available Colors
242
+
243
+ The library supports various color formats:
244
+
245
+ - Hex colors: `#1976d2`
246
+ - RGB: `rgb(25, 118, 210)`
247
+ - Color names: `blue`, `red`, `green`
248
+ - Material-UI color objects
249
+
250
+ ## 🎨 Styles & SCSS
251
+
252
+ The library provides a comprehensive styling system with compiled CSS, SCSS variables, mixins, utility classes, and animations.
253
+
254
+ ### Import Compiled CSS (Recommended)
255
+
256
+ Add this to your main application file:
257
+
258
+ ```tsx
259
+ // main.tsx or App.tsx
260
+ import '@erpsquad/common/style.css';
261
+ ```
262
+
263
+ This gives you:
264
+ - All component styles
265
+ - Utility classes for rapid development
266
+ - Responsive styles
267
+ - Animations
268
+
269
+ ### Using Utility Classes
270
+
271
+ ```tsx
272
+ <div className="d-flex justify-content-center align-items-center mb-2">
273
+ <h1 className="h2 bold">Welcome</h1>
274
+ <p className="s2 normal text-center">Description text</p>
275
+ </div>
276
+ ```
277
+
278
+ Available utility classes:
279
+ - **Layout**: `d-flex`, `flex-direction-column`, `justify-content-center`, `align-items-center`
280
+ - **Spacing**: `mb-1`, `mt-2`, `p-0`, `pl-2` (padding/margin utilities)
281
+ - **Typography**: `h1`-`h5` (headings), `s1`-`s5` (body text), `bold`, `medium`, `normal`
282
+ - **Width/Height**: `w-100`, `w-50`, `h-100`, `vh-100`
283
+ - **Text Alignment**: `text-center`, `text-left`, `text-right`
284
+
285
+ ### Using SCSS Variables (Advanced)
286
+
287
+ Import SCSS variables in your `.scss` files:
288
+
289
+ ```scss
290
+ // your-component.scss
291
+ @import '@erpsquad/common/styles/variables';
292
+
293
+ .custom-component {
294
+ background-color: $primary-600;
295
+ color: $neutral-100;
296
+ border: 1px solid $neutral-300;
297
+ }
298
+ ```
299
+
300
+ Available color scales (100-1000):
301
+ - `$primary-*` (green), `$neutral-*` (gray), `$error-*` (red)
302
+ - `$blue-*`, `$magenta-*`, `$olive-*`, `$green-*`, `$lightGreen-*`
303
+
304
+ ### Using SCSS Mixins (Advanced)
305
+
306
+ ```scss
307
+ // your-component.scss
308
+ @import '@erpsquad/common/styles/mixins';
309
+
310
+ .responsive-layout {
311
+ @include flex(center, space-between, row);
312
+
313
+ @include media-md {
314
+ flex-direction: column;
315
+ }
316
+ }
317
+ ```
318
+
319
+ Available mixins:
320
+ - `@include flex($align, $justify, $direction)` - Flexbox shorthand
321
+ - `@include transition($time, $motion)` - Transition shorthand
322
+ - `@include center` - Absolute center positioning
323
+ - Responsive breakpoints: `@include media-sm`, `@include media-md`, `@include media-l`, etc.
324
+
325
+ ### Import All SCSS Features
326
+
327
+ ```scss
328
+ // For complete access to variables, mixins, utilities, and animations
329
+ @import '@erpsquad/common/styles/all';
330
+ ```
331
+
332
+ **📚 For detailed styles documentation, see:**
333
+ - [Complete Styles Documentation](./src/styles/README.md)
334
+ - [Styles Usage Guide](./STYLES_USAGE.md)
335
+ - [Migration Guide](./STYLES_MIGRATION.md)
336
+
337
+ ## 📁 Modular Import System
338
+
339
+ The library uses a modular import system to prevent dependency issues. Import from specific paths based on your needs:
340
+
341
+ ```tsx
342
+ // Core functionality (no peer dependencies required)
343
+ import { configureLibrary, images } from '@erpsquad/common';
344
+
345
+ // Components (requires React, MUI peer dependencies)
346
+ import { Button, TextField } from '@erpsquad/common/components';
347
+
348
+ // Hooks (requires React peer dependencies)
349
+ import { useAuth, useLanguage } from '@erpsquad/common/hooks';
350
+
351
+ // Contexts (requires React peer dependencies)
352
+ import { ERPUIProvider, AuthProvider } from '@erpsquad/common/contexts';
353
+
354
+ // Theme utilities (requires MUI peer dependencies)
355
+ import { createLightTheme, createDarkTheme } from '@erpsquad/common/theme';
356
+
357
+ // Utility functions (may require specific peer dependencies)
358
+ import { formatDate, validateEmail } from '@erpsquad/common/utils';
359
+
360
+ // Redux integration (requires Redux peer dependencies)
361
+ import { createLibraryStore, slices } from '@erpsquad/common/redux';
362
+
363
+ // API clients (requires axios peer dependency)
364
+ import { AccountingAPI, InventoryAPI } from '@erpsquad/common/api-client';
365
+
366
+ // Styles (CSS bundle - recommended)
367
+ import '@erpsquad/common/style.css';
368
+
369
+ // Styles (SCSS imports for advanced usage)
370
+ // Import in .scss files only:
371
+ // @import '@erpsquad/common/styles/variables';
372
+ // @import '@erpsquad/common/styles/mixins';
373
+ // @import '@erpsquad/common/styles/all';
374
+ ```
375
+
376
+ ## 🔌 API Clients
377
+
378
+ The library includes pre-configured API clients for different ERP modules:
379
+
380
+ ```tsx
381
+ import {
382
+ AccountingAPI,
383
+ InventoryAPI,
384
+ ManufacturingAPI,
385
+ PurchaseAPI,
386
+ SalesAPI,
387
+ RentalAPI,
388
+ RbacAPI,
389
+ DriveAPI,
390
+ SystemFeatureAPI
391
+ } from '@erpsquad/common/api-client';
392
+
393
+ // Configure base API client
394
+ const baseConfig = {
395
+ baseURL: 'https://api.example.com',
396
+ timeout: 10000,
397
+ headers: {
398
+ 'Content-Type': 'application/json'
399
+ }
400
+ };
401
+
402
+ // Use specific API clients
403
+ const accountingClient = new AccountingAPI(baseConfig);
404
+ const inventoryClient = new InventoryAPI(baseConfig);
405
+
406
+ // Example usage
407
+ const users = await accountingClient.getUsers();
408
+ const products = await inventoryClient.getProducts();
409
+ ```
410
+
411
+ ## 🔧 Components
412
+
413
+ ### Form Controls
414
+
415
+ ```tsx
416
+ import {
417
+ TextField,
418
+ Select,
419
+ DatePicker,
420
+ Checkbox,
421
+ Radio,
422
+ ToggleSwitch,
423
+ Button
424
+ } from '@erpsquad/common/components';
425
+
426
+ // Text input
427
+ <TextField
428
+ label="Email"
429
+ type="email"
430
+ variant="outlined"
431
+ required
432
+ />
433
+
434
+ // Select dropdown
435
+ <Select
436
+ label="Country"
437
+ options={countries}
438
+ value={selectedCountry}
439
+ onChange={handleCountryChange}
440
+ />
441
+
442
+ // Date picker (requires @mui/x-date-pickers)
443
+ <DatePicker
444
+ label="Birth Date"
445
+ value={birthDate}
446
+ onChange={setBirthDate}
447
+ />
448
+ ```
449
+
450
+ ### Data Display
451
+
452
+ ```tsx
453
+ import {
454
+ MaterialTable,
455
+ Grid,
456
+ CardWrapper,
457
+ Avatar,
458
+ Chip
459
+ } from '@erpsquad/common/components';
460
+
461
+ // Data table (requires @mui/x-data-grid)
462
+ <MaterialTable
463
+ columns={columns}
464
+ data={data}
465
+ title="Users"
466
+ options={{
467
+ search: true,
468
+ pagination: true,
469
+ sorting: true
470
+ }}
471
+ />
472
+
473
+ // Grid layout
474
+ <Grid container spacing={2}>
475
+ <Grid item xs={12} md={6}>
476
+ <CardWrapper>Content</CardWrapper>
477
+ </Grid>
478
+ </Grid>
479
+ ```
480
+
481
+ ### Navigation
482
+
483
+ ```tsx
484
+ import {
485
+ Sidebar,
486
+ BreadCrumb,
487
+ Pagination,
488
+ Tabs
489
+ } from '@erpsquad/common/components';
490
+
491
+ // Sidebar navigation
492
+ <Sidebar
493
+ items={navigationItems}
494
+ collapsed={isCollapsed}
495
+ onItemClick={handleNavigation}
496
+ />
497
+
498
+ // Breadcrumb (requires react-router-dom for navigation)
499
+ <BreadCrumb
500
+ items={[
501
+ { label: 'Home', href: '/' },
502
+ { label: 'Users', href: '/users' },
503
+ { label: 'Profile' }
504
+ ]}
505
+ />
506
+ ```
507
+
508
+ ### Feedback
509
+
510
+ ```tsx
511
+ import {
512
+ CustomSnackbar,
513
+ Toast,
514
+ Loader,
515
+ Alert,
516
+ Modal
517
+ } from '@erpsquad/common/components';
518
+
519
+ // Loading indicator
520
+ <Loader size="large" text="Loading data..." />
521
+
522
+ // Alert message
523
+ <Alert severity="success" onClose={handleClose}>
524
+ Operation completed successfully!
525
+ </Alert>
526
+
527
+ // Snackbar notification
528
+ <CustomSnackbar
529
+ open={isOpen}
530
+ message="Operation completed successfully!"
531
+ severity="success"
532
+ onClose={handleClose}
533
+ />
534
+
535
+ // Modal dialog
536
+ <Modal
537
+ open={isOpen}
538
+ onClose={handleClose}
539
+ title="Confirm Action"
540
+ actions={[
541
+ { label: 'Cancel', onClick: handleClose },
542
+ { label: 'Confirm', onClick: handleConfirm, variant: 'contained' }
543
+ ]}
544
+ >
545
+ Are you sure you want to proceed?
546
+ </Modal>
547
+ ```
548
+
549
+ ## 🔄 Redux Integration
550
+
551
+ The library provides flexible Redux integration that works with or without Redux. Requires `@reduxjs/toolkit` and `react-redux` peer dependencies.
552
+
553
+ ### With Redux (Recommended for complex applications)
554
+
555
+ ```tsx
556
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
557
+ import {
558
+ createLibraryStore,
559
+ createConfiguredApiClient
560
+ } from '@erpsquad/common/redux';
561
+ import { ShareModal } from '@erpsquad/common/components';
562
+
563
+ // Configure API client
564
+ const apiClient = createConfiguredApiClient(baseApiClient, () => ({
565
+ authorization: `Bearer ${getAuthToken()}`
566
+ }));
567
+
568
+ // Create store with library slices
569
+ const store = createLibraryStore(
570
+ {
571
+ // Your app reducers
572
+ app: appReducer,
573
+ user: userReducer
574
+ },
575
+ apiClient
576
+ );
577
+
578
+ function App() {
579
+ return (
580
+ <ERPUIProvider useRedux={true} reduxStore={store} apiClient={apiClient}>
581
+ <ShareModal useRedux={true} />
582
+ </ERPUIProvider>
583
+ );
584
+ }
585
+ ```
586
+
587
+ ### Without Redux (Simpler applications)
588
+
589
+ ```tsx
590
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
591
+ import { ShareModal } from '@erpsquad/common/components';
592
+
593
+ function App() {
594
+ const [users, setUsers] = useState([]);
595
+ const [loading, setLoading] = useState(false);
596
+
597
+ const fetchUsers = async () => {
598
+ setLoading(true);
599
+ try {
600
+ const response = await api.getUsers();
601
+ setUsers(response.data);
602
+ } finally {
603
+ setLoading(false);
604
+ }
605
+ };
606
+
607
+ return (
608
+ <ERPUIProvider useRedux={false}>
609
+ <ShareModal
610
+ useRedux={false}
611
+ users={users}
612
+ loading={loading}
613
+ onFetchUsersAndDepartments={fetchUsers}
614
+ />
615
+ </ERPUIProvider>
616
+ );
617
+ }
618
+ ```
619
+
620
+ ### Available Redux Slices
621
+
622
+ - **shareSlice**: User and department data for sharing functionality
623
+ - **headerSlice**: Language data and current language selection
624
+ - **reportsTitleBarSlice**: Company data for reports filtering
625
+ - **inventoryReportsTitleBarSlice**: Inventory-related data for reports
626
+
627
+ ## 🪝 Hooks
628
+
629
+ ### Custom Hooks
630
+
631
+ ```tsx
632
+ import {
633
+ useAuth,
634
+ useLanguage,
635
+ usePermissions,
636
+ usePages,
637
+ useDeepMemo,
638
+ useReduxIntegration
639
+ } from '@erpsquad/common/hooks';
640
+
641
+ // Authentication hook
642
+ const { user, isAuthenticated, login, logout } = useAuth();
643
+
644
+ // Language hook (requires react-i18next)
645
+ const { currentLanguage, changeLanguage, t } = useLanguage();
646
+
647
+ // Permissions hook
648
+ const { hasPermission, checkPermission } = usePermissions();
649
+
650
+ // Deep memoization hook
651
+ const memoizedValue = useDeepMemo(() => expensiveCalculation(data), [data]);
652
+ ```
653
+
654
+ ### Redux Integration Hook
655
+
656
+ ```tsx
657
+ import { useReduxIntegration } from '@erpsquad/common/hooks';
658
+
659
+ const MyComponent = ({ useRedux, ...props }) => {
660
+ const { data, loading, error, actions } = useReduxIntegration({
661
+ useRedux,
662
+ sliceName: 'share',
663
+ fallbackData: props.users,
664
+ fallbackLoading: props.loading,
665
+ fallbackActions: {
666
+ fetchData: props.onFetchUsers
667
+ }
668
+ });
669
+
670
+ // Component logic using unified interface
671
+ };
672
+ ```
673
+
674
+ ## 🛠️ Utilities
675
+
676
+ ### Common Utilities
677
+
678
+ ```tsx
679
+ import {
680
+ formatDate,
681
+ formatFileSize,
682
+ formatText,
683
+ deformatText,
684
+ colorUtils
685
+ } from '@erpsquad/common/utils';
686
+
687
+ // Date formatting (requires date-fns)
688
+ const formattedDate = formatDate(new Date(), 'dd/MM/yyyy');
689
+
690
+ // File size formatting
691
+ const fileSize = formatFileSize(1024000); // "1.02 MB"
692
+
693
+ // Text formatting
694
+ const formatted = formatText('hello world', 'title'); // "Hello World"
695
+
696
+ // Color utilities
697
+ const hexColor = colorUtils.rgbToHex(255, 0, 0); // "#ff0000"
698
+ ```
699
+
700
+ ## 🌐 Internationalization
701
+
702
+ Requires `react-i18next` and `i18next` peer dependencies.
703
+
704
+ ### Language Provider
705
+
706
+ ```tsx
707
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
708
+
709
+ <ERPUIProvider
710
+ enableLanguage={true}
711
+ // Other props
712
+ >
713
+ <App />
714
+ </ERPUIProvider>;
715
+ ```
716
+
717
+ ### Using Translations
718
+
719
+ ```tsx
720
+ import { useLanguage } from '@erpsquad/common/hooks';
721
+
722
+ const MyComponent = () => {
723
+ const { t, currentLanguage, changeLanguage } = useLanguage();
724
+
725
+ return (
726
+ <div>
727
+ <p>{t('common.welcome')}</p>
728
+ <button onClick={() => changeLanguage('es')}>Switch to Spanish</button>
729
+ </div>
730
+ );
731
+ };
732
+ ```
733
+
734
+ ## 🧪 Testing
735
+
736
+ The library includes comprehensive testing utilities:
737
+
738
+ ```tsx
739
+ import { render, screen } from '@testing-library/react';
740
+ import { ERPUIProvider } from '@erpsquad/common/contexts';
741
+ import { Button } from '@erpsquad/common/components';
742
+
743
+ test('renders button correctly', () => {
744
+ render(
745
+ <ERPUIProvider>
746
+ <Button>Click me</Button>
747
+ </ERPUIProvider>
748
+ );
749
+
750
+ expect(screen.getByRole('button')).toBeInTheDocument();
751
+ });
752
+ ```
753
+
754
+ ## 📚 API Reference
755
+
756
+ ### ERPUIProvider Props
757
+
758
+ | Prop | Type | Default | Description |
759
+ | ---------------- | ------------------- | ----------- | ------------------------ |
760
+ | `useRedux` | `boolean` | `false` | Enable Redux integration |
761
+ | `reduxStore` | `Store` | `undefined` | Custom Redux store |
762
+ | `apiClient` | `ApiClientConfig` | `undefined` | API client configuration |
763
+ | `themeMode` | `'light' \| 'dark'` | `'light'` | Theme mode |
764
+ | `primaryColor` | `string` | `undefined` | Primary theme color |
765
+ | `direction` | `'ltr' \| 'rtl'` | `'ltr'` | Text direction |
766
+ | `enableAuth` | `boolean` | `true` | Enable auth context |
767
+ | `enableLanguage` | `boolean` | `true` | Enable language context |
768
+ | `enableRouter` | `boolean` | `false` | Enable router provider |
769
+ | `enableSnackbar` | `boolean` | `true` | Enable snackbar provider |
770
+
771
+ ### Component Props
772
+
773
+ All components extend their respective Material-UI component props with additional ERP-specific functionality. Refer to individual component documentation for detailed prop information.
774
+
775
+ ## 🔧 Development
776
+
777
+ ### Building the Library
778
+
779
+ ```bash
780
+ # Production build
781
+ npm run build
782
+
783
+ # Build with analysis
784
+ npm run build:analyze
785
+
786
+ # Build with validation
787
+ npm run build:validate
788
+
789
+ # Clean build artifacts
790
+ npm run clean
791
+ ```
792
+
793
+ ### Running Tests
794
+
795
+ ```bash
796
+ # Run all tests
797
+ npm test
798
+
799
+ # Run tests in CI mode
800
+ npm run test:ci
801
+
802
+ # Type checking
803
+ npm run type-check
804
+
805
+ # Linting
806
+ npm run lint
807
+ npm run lint:fix
808
+ ```
809
+
810
+ ### Package Validation
811
+
812
+ ```bash
813
+ # Validate package structure
814
+ npm run validate:package
815
+
816
+ # Check bundle size limits
817
+ npm run size-check
818
+
819
+ # Full validation (lint + type-check + test + build)
820
+ npm run validate
821
+ ```
822
+
823
+ ## 📈 Bundle Analysis
824
+
825
+ ```bash
826
+ # Analyze bundle size and composition
827
+ npm run build:analyze
828
+
829
+ # Check size limits against configuration
830
+ npm run size-check
831
+
832
+ # Validate package contents before publishing
833
+ npm run validate:package
834
+ ```
835
+
836
+ ## 🚨 Troubleshooting
837
+
838
+ ### Common Issues
839
+
840
+ #### Import Errors
841
+
842
+ ```bash
843
+ # Error: Cannot resolve '@erpsquad/common/components'
844
+ # Solution: Install required peer dependencies
845
+ npm install @mui/material @emotion/react @emotion/styled
846
+
847
+ # Error: Module not found
848
+ # Solution: Use correct import paths
849
+ import { Button } from '@erpsquad/common/components'; // ✅ Correct
850
+ import { Button } from '@erpsquad/common'; // ❌ Incorrect for components
851
+ ```
852
+
853
+ #### Peer Dependency Warnings
854
+
855
+ ```bash
856
+ # Warning: peer dependency not installed
857
+ # Solution: Install the specific peer dependency
858
+ npm install react-redux @reduxjs/toolkit
859
+
860
+ # Or install all peer dependencies
861
+ npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material
862
+ ```
863
+
864
+ #### TypeScript Errors
865
+
866
+ ```bash
867
+ # Error: Cannot find type definitions
868
+ # Solution: Ensure TypeScript types are properly imported
869
+ import type { LibraryConfig } from '@erpsquad/common';
870
+
871
+ # Error: Module has no exported member
872
+ # Solution: Check if the export requires peer dependencies
873
+ import { useAuth } from '@erpsquad/common/hooks'; // Requires React
874
+ ```
875
+
876
+ #### Build Issues
877
+
878
+ ```bash
879
+ # Error: Module not found during build
880
+ # Solution: Check if all peer dependencies are installed
881
+ # and properly configured in your build tool
882
+
883
+ # For Vite projects, add to vite.config.ts:
884
+ export default defineConfig({
885
+ optimizeDeps: {
886
+ include: ['@erpsquad/common']
887
+ }
888
+ });
889
+
890
+ # For Webpack projects, ensure proper externals configuration
891
+ ```
892
+
893
+ ### Getting Help
894
+
895
+ - Check the [troubleshooting guide](./TROUBLESHOOTING.md)
896
+ - Review [migration documentation](./MIGRATION.md)
897
+ - Search [existing issues](https://github.com/erpforce/common/issues)
898
+ - Create a [new issue](https://github.com/erpforce/common/issues/new)
899
+
900
+ ## 🤝 Contributing
901
+
902
+ 1. Fork the repository
903
+ 2. Create a feature branch: `git checkout -b feature/new-component`
904
+ 3. Make your changes and add tests
905
+ 4. Run tests: `npm test`
906
+ 5. Run linting: `npm run lint`
907
+ 6. Commit your changes: `git commit -m 'Add new component'`
908
+ 7. Push to the branch: `git push origin feature/new-component`
909
+ 8. Submit a pull request
910
+
911
+ ### Development Guidelines
912
+
913
+ - Follow TypeScript best practices
914
+ - Write comprehensive tests for new components
915
+ - Update documentation for API changes
916
+ - Ensure accessibility compliance
917
+ - Maintain backward compatibility
918
+
919
+ ## 📄 License
920
+
921
+ MIT License - see the [LICENSE](LICENSE) file for details.
922
+
923
+ ## 🆘 Support
924
+
925
+ - **Documentation**: [Library Docs](https://github.com/erpforce/erpforce-common-hub-fe/tree/dev#readme)
926
+ - **Issues**: [GitHub Issues](https://github.com/erpforce/erpforce-common-hub-fe/issues)
927
+ - **NPM Package**: [@erpsquad/common](https://www.npmjs.com/package/@erpsquad/common)
928
+ - **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
929
+ - **Migration Guide**: [MIGRATION.md](./MIGRATION.md)
930
+ - **Troubleshooting**: [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
931
+
932
+ ## 📋 Changelog
933
+
934
+ See [CHANGELOG.md](CHANGELOG.md) for a detailed list of changes and version history.