@erpsquad/common 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.
- package/README.md +65 -57
- package/dist/common-BRx8CJLZ.js.map +1 -1
- package/dist/common-DjkB08j1.esm.js.map +1 -1
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/navigation-utils-93uihT3j.esm.js.map +1 -1
- package/dist/navigation-utils-DJjak6jv.js.map +1 -1
- package/dist/translations-A_1jDwOn.esm.js.map +1 -1
- package/dist/translations-DAx8u6R5.js.map +1 -1
- package/dist/utils/common-utility.d.ts +4 -5
- package/dist/utils/common.d.ts +6 -7
- package/dist/utils/date-range.d.ts +2 -3
- package/dist/utils/dateValidation.d.ts +1 -1
- package/dist/utils/form-builder-deconversion.d.ts +42 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.esm.js +2 -0
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @erpsquad/common
|
|
2
2
|
|
|
3
|
-
A comprehensive React component library for ERP applications, built with Material-UI and TypeScript. This library provides
|
|
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
4
|
|
|
5
5
|
## 🚀 Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
7
|
+
- **100+ UI Components**: Comprehensive set of form controls, data display, navigation, and layout components
|
|
8
8
|
- **Material-UI Integration**: Built on top of Material-UI with custom theming
|
|
9
9
|
- **TypeScript Support**: Full TypeScript definitions for all components and utilities
|
|
10
10
|
- **Flexible Redux Integration**: Optional Redux support - components work with or without Redux
|
|
@@ -18,7 +18,7 @@ A comprehensive React component library for ERP applications, built with Materia
|
|
|
18
18
|
## 📦 Installation
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
npm install
|
|
21
|
+
npm install @erpsquad/common
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
### Peer Dependencies
|
|
@@ -90,7 +90,7 @@ import {
|
|
|
90
90
|
images,
|
|
91
91
|
DEFAULT_LANG,
|
|
92
92
|
type LibraryConfig
|
|
93
|
-
} from '
|
|
93
|
+
} from '@erpsquad/common';
|
|
94
94
|
|
|
95
95
|
// Configure library for your application
|
|
96
96
|
const config: LibraryConfig = {
|
|
@@ -135,13 +135,13 @@ import {
|
|
|
135
135
|
getLibraryConfig,
|
|
136
136
|
getConfigFunction,
|
|
137
137
|
type LibraryConfig
|
|
138
|
-
} from '
|
|
138
|
+
} from '@erpsquad/common';
|
|
139
139
|
|
|
140
140
|
// Static assets
|
|
141
|
-
import { default as images } from '
|
|
141
|
+
import { default as images } from '@erpsquad/common';
|
|
142
142
|
|
|
143
143
|
// Constants
|
|
144
|
-
import { DEFAULT_LANG, LANGUAGES, S3_BUCKET_URL } from '
|
|
144
|
+
import { DEFAULT_LANG, LANGUAGES, S3_BUCKET_URL } from '@erpsquad/common';
|
|
145
145
|
|
|
146
146
|
// TypeScript types
|
|
147
147
|
import type {
|
|
@@ -151,7 +151,7 @@ import type {
|
|
|
151
151
|
TableColumn,
|
|
152
152
|
User,
|
|
153
153
|
Permission
|
|
154
|
-
} from '
|
|
154
|
+
} from '@erpsquad/common';
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
### Full Usage (With peer dependencies)
|
|
@@ -161,8 +161,8 @@ After installing peer dependencies, you can use all components:
|
|
|
161
161
|
```tsx
|
|
162
162
|
import React from 'react';
|
|
163
163
|
// Note: Import from specific paths to avoid dependency issues
|
|
164
|
-
import { ERPUIProvider } from '
|
|
165
|
-
import { Button, TextField } from '
|
|
164
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
165
|
+
import { Button, TextField } from '@erpsquad/common/components';
|
|
166
166
|
|
|
167
167
|
function App() {
|
|
168
168
|
return (
|
|
@@ -184,9 +184,9 @@ export default App;
|
|
|
184
184
|
|
|
185
185
|
```tsx
|
|
186
186
|
import React from 'react';
|
|
187
|
-
import { ERPUIProvider } from '
|
|
188
|
-
import { Button } from '
|
|
189
|
-
import { createLightTheme } from '
|
|
187
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
188
|
+
import { Button } from '@erpsquad/common/components';
|
|
189
|
+
import { createLightTheme } from '@erpsquad/common/theme';
|
|
190
190
|
|
|
191
191
|
function App() {
|
|
192
192
|
const { theme } = createLightTheme('#2196f3', 'ltr');
|
|
@@ -210,7 +210,7 @@ The library includes a comprehensive theming system with support for light/dark
|
|
|
210
210
|
### Theme Configuration
|
|
211
211
|
|
|
212
212
|
```tsx
|
|
213
|
-
import { ERPUIProvider } from '@
|
|
213
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
214
214
|
|
|
215
215
|
<ERPUIProvider
|
|
216
216
|
themeMode='light' // 'light' | 'dark'
|
|
@@ -224,8 +224,8 @@ import { ERPUIProvider } from '@erpforce/common/contexts';
|
|
|
224
224
|
### Custom Theme Object
|
|
225
225
|
|
|
226
226
|
```tsx
|
|
227
|
-
import { createLightTheme, createDarkTheme } from '
|
|
228
|
-
import { ERPUIProvider } from '
|
|
227
|
+
import { createLightTheme, createDarkTheme } from '@erpsquad/common/theme';
|
|
228
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
229
229
|
|
|
230
230
|
// Create custom theme
|
|
231
231
|
const { theme } = createLightTheme('#1976d2', 'ltr');
|
|
@@ -253,28 +253,28 @@ The library uses a modular import system to prevent dependency issues. Import fr
|
|
|
253
253
|
|
|
254
254
|
```tsx
|
|
255
255
|
// Core functionality (no peer dependencies required)
|
|
256
|
-
import { configureLibrary, images } from '
|
|
256
|
+
import { configureLibrary, images } from '@erpsquad/common';
|
|
257
257
|
|
|
258
258
|
// Components (requires React, MUI peer dependencies)
|
|
259
|
-
import { Button, TextField } from '
|
|
259
|
+
import { Button, TextField } from '@erpsquad/common/components';
|
|
260
260
|
|
|
261
261
|
// Hooks (requires React peer dependencies)
|
|
262
|
-
import { useAuth, useLanguage } from '
|
|
262
|
+
import { useAuth, useLanguage } from '@erpsquad/common/hooks';
|
|
263
263
|
|
|
264
264
|
// Contexts (requires React peer dependencies)
|
|
265
|
-
import { ERPUIProvider, AuthProvider } from '
|
|
265
|
+
import { ERPUIProvider, AuthProvider } from '@erpsquad/common/contexts';
|
|
266
266
|
|
|
267
267
|
// Theme utilities (requires MUI peer dependencies)
|
|
268
|
-
import { createLightTheme, createDarkTheme } from '
|
|
268
|
+
import { createLightTheme, createDarkTheme } from '@erpsquad/common/theme';
|
|
269
269
|
|
|
270
270
|
// Utility functions (may require specific peer dependencies)
|
|
271
|
-
import { formatDate, validateEmail } from '
|
|
271
|
+
import { formatDate, validateEmail } from '@erpsquad/common/utils';
|
|
272
272
|
|
|
273
273
|
// Redux integration (requires Redux peer dependencies)
|
|
274
|
-
import { createLibraryStore, slices } from '
|
|
274
|
+
import { createLibraryStore, slices } from '@erpsquad/common/redux';
|
|
275
275
|
|
|
276
276
|
// API clients (requires axios peer dependency)
|
|
277
|
-
import { AccountingAPI, InventoryAPI } from '
|
|
277
|
+
import { AccountingAPI, InventoryAPI } from '@erpsquad/common/api-client';
|
|
278
278
|
```
|
|
279
279
|
|
|
280
280
|
## 🔌 API Clients
|
|
@@ -292,7 +292,7 @@ import {
|
|
|
292
292
|
RbacAPI,
|
|
293
293
|
DriveAPI,
|
|
294
294
|
SystemFeatureAPI
|
|
295
|
-
} from '
|
|
295
|
+
} from '@erpsquad/common/api-client';
|
|
296
296
|
|
|
297
297
|
// Configure base API client
|
|
298
298
|
const baseConfig = {
|
|
@@ -323,9 +323,9 @@ import {
|
|
|
323
323
|
DatePicker,
|
|
324
324
|
Checkbox,
|
|
325
325
|
Radio,
|
|
326
|
-
|
|
326
|
+
ToggleSwitch,
|
|
327
327
|
Button
|
|
328
|
-
} from '
|
|
328
|
+
} from '@erpsquad/common/components';
|
|
329
329
|
|
|
330
330
|
// Text input
|
|
331
331
|
<TextField
|
|
@@ -357,10 +357,10 @@ import {
|
|
|
357
357
|
import {
|
|
358
358
|
MaterialTable,
|
|
359
359
|
Grid,
|
|
360
|
-
|
|
360
|
+
CardWrapper,
|
|
361
361
|
Avatar,
|
|
362
362
|
Chip
|
|
363
|
-
} from '
|
|
363
|
+
} from '@erpsquad/common/components';
|
|
364
364
|
|
|
365
365
|
// Data table (requires @mui/x-data-grid)
|
|
366
366
|
<MaterialTable
|
|
@@ -377,7 +377,7 @@ import {
|
|
|
377
377
|
// Grid layout
|
|
378
378
|
<Grid container spacing={2}>
|
|
379
379
|
<Grid item xs={12} md={6}>
|
|
380
|
-
<
|
|
380
|
+
<CardWrapper>Content</CardWrapper>
|
|
381
381
|
</Grid>
|
|
382
382
|
</Grid>
|
|
383
383
|
```
|
|
@@ -387,10 +387,10 @@ import {
|
|
|
387
387
|
```tsx
|
|
388
388
|
import {
|
|
389
389
|
Sidebar,
|
|
390
|
-
|
|
390
|
+
BreadCrumb,
|
|
391
391
|
Pagination,
|
|
392
392
|
Tabs
|
|
393
|
-
} from '
|
|
393
|
+
} from '@erpsquad/common/components';
|
|
394
394
|
|
|
395
395
|
// Sidebar navigation
|
|
396
396
|
<Sidebar
|
|
@@ -400,7 +400,7 @@ import {
|
|
|
400
400
|
/>
|
|
401
401
|
|
|
402
402
|
// Breadcrumb (requires react-router-dom for navigation)
|
|
403
|
-
<
|
|
403
|
+
<BreadCrumb
|
|
404
404
|
items={[
|
|
405
405
|
{ label: 'Home', href: '/' },
|
|
406
406
|
{ label: 'Users', href: '/users' },
|
|
@@ -413,12 +413,12 @@ import {
|
|
|
413
413
|
|
|
414
414
|
```tsx
|
|
415
415
|
import {
|
|
416
|
-
|
|
416
|
+
CustomSnackbar,
|
|
417
417
|
Toast,
|
|
418
418
|
Loader,
|
|
419
419
|
Alert,
|
|
420
420
|
Modal
|
|
421
|
-
} from '
|
|
421
|
+
} from '@erpsquad/common/components';
|
|
422
422
|
|
|
423
423
|
// Loading indicator
|
|
424
424
|
<Loader size="large" text="Loading data..." />
|
|
@@ -428,6 +428,14 @@ import {
|
|
|
428
428
|
Operation completed successfully!
|
|
429
429
|
</Alert>
|
|
430
430
|
|
|
431
|
+
// Snackbar notification
|
|
432
|
+
<CustomSnackbar
|
|
433
|
+
open={isOpen}
|
|
434
|
+
message="Operation completed successfully!"
|
|
435
|
+
severity="success"
|
|
436
|
+
onClose={handleClose}
|
|
437
|
+
/>
|
|
438
|
+
|
|
431
439
|
// Modal dialog
|
|
432
440
|
<Modal
|
|
433
441
|
open={isOpen}
|
|
@@ -449,12 +457,12 @@ The library provides flexible Redux integration that works with or without Redux
|
|
|
449
457
|
### With Redux (Recommended for complex applications)
|
|
450
458
|
|
|
451
459
|
```tsx
|
|
452
|
-
import { ERPUIProvider } from '
|
|
460
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
453
461
|
import {
|
|
454
462
|
createLibraryStore,
|
|
455
|
-
ShareModalEnhanced,
|
|
456
463
|
createConfiguredApiClient
|
|
457
|
-
} from '
|
|
464
|
+
} from '@erpsquad/common/redux';
|
|
465
|
+
import { ShareModal } from '@erpsquad/common/components';
|
|
458
466
|
|
|
459
467
|
// Configure API client
|
|
460
468
|
const apiClient = createConfiguredApiClient(baseApiClient, () => ({
|
|
@@ -474,7 +482,7 @@ const store = createLibraryStore(
|
|
|
474
482
|
function App() {
|
|
475
483
|
return (
|
|
476
484
|
<ERPUIProvider useRedux={true} reduxStore={store} apiClient={apiClient}>
|
|
477
|
-
<
|
|
485
|
+
<ShareModal useRedux={true} />
|
|
478
486
|
</ERPUIProvider>
|
|
479
487
|
);
|
|
480
488
|
}
|
|
@@ -483,8 +491,8 @@ function App() {
|
|
|
483
491
|
### Without Redux (Simpler applications)
|
|
484
492
|
|
|
485
493
|
```tsx
|
|
486
|
-
import { ERPUIProvider } from '
|
|
487
|
-
import {
|
|
494
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
495
|
+
import { ShareModal } from '@erpsquad/common/components';
|
|
488
496
|
|
|
489
497
|
function App() {
|
|
490
498
|
const [users, setUsers] = useState([]);
|
|
@@ -502,7 +510,7 @@ function App() {
|
|
|
502
510
|
|
|
503
511
|
return (
|
|
504
512
|
<ERPUIProvider useRedux={false}>
|
|
505
|
-
<
|
|
513
|
+
<ShareModal
|
|
506
514
|
useRedux={false}
|
|
507
515
|
users={users}
|
|
508
516
|
loading={loading}
|
|
@@ -532,7 +540,7 @@ import {
|
|
|
532
540
|
usePages,
|
|
533
541
|
useDeepMemo,
|
|
534
542
|
useReduxIntegration
|
|
535
|
-
} from '
|
|
543
|
+
} from '@erpsquad/common/hooks';
|
|
536
544
|
|
|
537
545
|
// Authentication hook
|
|
538
546
|
const { user, isAuthenticated, login, logout } = useAuth();
|
|
@@ -550,7 +558,7 @@ const memoizedValue = useDeepMemo(() => expensiveCalculation(data), [data]);
|
|
|
550
558
|
### Redux Integration Hook
|
|
551
559
|
|
|
552
560
|
```tsx
|
|
553
|
-
import { useReduxIntegration } from '
|
|
561
|
+
import { useReduxIntegration } from '@erpsquad/common/hooks';
|
|
554
562
|
|
|
555
563
|
const MyComponent = ({ useRedux, ...props }) => {
|
|
556
564
|
const { data, loading, error, actions } = useReduxIntegration({
|
|
@@ -578,7 +586,7 @@ import {
|
|
|
578
586
|
formatText,
|
|
579
587
|
deformatText,
|
|
580
588
|
colorUtils
|
|
581
|
-
} from '
|
|
589
|
+
} from '@erpsquad/common/utils';
|
|
582
590
|
|
|
583
591
|
// Date formatting (requires date-fns)
|
|
584
592
|
const formattedDate = formatDate(new Date(), 'dd/MM/yyyy');
|
|
@@ -600,7 +608,7 @@ Requires `react-i18next` and `i18next` peer dependencies.
|
|
|
600
608
|
### Language Provider
|
|
601
609
|
|
|
602
610
|
```tsx
|
|
603
|
-
import { ERPUIProvider } from '@
|
|
611
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
604
612
|
|
|
605
613
|
<ERPUIProvider
|
|
606
614
|
enableLanguage={true}
|
|
@@ -613,7 +621,7 @@ import { ERPUIProvider } from '@erpforce/common/contexts';
|
|
|
613
621
|
### Using Translations
|
|
614
622
|
|
|
615
623
|
```tsx
|
|
616
|
-
import { useLanguage } from '
|
|
624
|
+
import { useLanguage } from '@erpsquad/common/hooks';
|
|
617
625
|
|
|
618
626
|
const MyComponent = () => {
|
|
619
627
|
const { t, currentLanguage, changeLanguage } = useLanguage();
|
|
@@ -633,8 +641,8 @@ The library includes comprehensive testing utilities:
|
|
|
633
641
|
|
|
634
642
|
```tsx
|
|
635
643
|
import { render, screen } from '@testing-library/react';
|
|
636
|
-
import { ERPUIProvider } from '
|
|
637
|
-
import { Button } from '
|
|
644
|
+
import { ERPUIProvider } from '@erpsquad/common/contexts';
|
|
645
|
+
import { Button } from '@erpsquad/common/components';
|
|
638
646
|
|
|
639
647
|
test('renders button correctly', () => {
|
|
640
648
|
render(
|
|
@@ -736,14 +744,14 @@ npm run validate:package
|
|
|
736
744
|
#### Import Errors
|
|
737
745
|
|
|
738
746
|
```bash
|
|
739
|
-
# Error: Cannot resolve '@
|
|
747
|
+
# Error: Cannot resolve '@erpsquad/common/components'
|
|
740
748
|
# Solution: Install required peer dependencies
|
|
741
749
|
npm install @mui/material @emotion/react @emotion/styled
|
|
742
750
|
|
|
743
751
|
# Error: Module not found
|
|
744
752
|
# Solution: Use correct import paths
|
|
745
|
-
import { Button } from '
|
|
746
|
-
import { Button } from '
|
|
753
|
+
import { Button } from '@erpsquad/common/components'; // ✅ Correct
|
|
754
|
+
import { Button } from '@erpsquad/common'; // ❌ Incorrect for components
|
|
747
755
|
```
|
|
748
756
|
|
|
749
757
|
#### Peer Dependency Warnings
|
|
@@ -762,11 +770,11 @@ npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/ic
|
|
|
762
770
|
```bash
|
|
763
771
|
# Error: Cannot find type definitions
|
|
764
772
|
# Solution: Ensure TypeScript types are properly imported
|
|
765
|
-
import type { LibraryConfig } from '
|
|
773
|
+
import type { LibraryConfig } from '@erpsquad/common';
|
|
766
774
|
|
|
767
775
|
# Error: Module has no exported member
|
|
768
776
|
# Solution: Check if the export requires peer dependencies
|
|
769
|
-
import { useAuth } from '
|
|
777
|
+
import { useAuth } from '@erpsquad/common/hooks'; // Requires React
|
|
770
778
|
```
|
|
771
779
|
|
|
772
780
|
#### Build Issues
|
|
@@ -779,7 +787,7 @@ import { useAuth } from 'erpforce-common-ui/hooks'; // Requires React
|
|
|
779
787
|
# For Vite projects, add to vite.config.ts:
|
|
780
788
|
export default defineConfig({
|
|
781
789
|
optimizeDeps: {
|
|
782
|
-
include: ['
|
|
790
|
+
include: ['@erpsquad/common']
|
|
783
791
|
}
|
|
784
792
|
});
|
|
785
793
|
|
|
@@ -821,7 +829,7 @@ MIT License - see the [LICENSE](LICENSE) file for details.
|
|
|
821
829
|
- **Documentation**: [Library Docs](https://github.com/erpforce/common#readme)
|
|
822
830
|
- **Issues**: [GitHub Issues](https://github.com/erpforce/common/issues)
|
|
823
831
|
- **Discussions**: [GitHub Discussions](https://github.com/erpforce/common/discussions)
|
|
824
|
-
- **NPM Package**: [
|
|
832
|
+
- **NPM Package**: [@erpsquad/common](https://www.npmjs.com/package/@erpsquad/common)
|
|
825
833
|
- **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
|
|
826
834
|
- **Migration Guide**: [MIGRATION.md](./MIGRATION.md)
|
|
827
835
|
- **Troubleshooting**: [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
|