@firedesktop/react-base 2.1.24 → 3.0.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 +162 -0
- package/README.md +174 -94
- package/dist/components/AppIcon.d.ts +20 -20
- package/dist/components/AppIcon.js +64 -53
- package/dist/components/AppIcon.js.map +1 -1
- package/dist/components/AppInput.d.ts +20 -20
- package/dist/components/AppInput.js +18 -7
- package/dist/components/AppInput.js.map +1 -1
- package/dist/components/AppPagination.d.ts +11 -11
- package/dist/components/AppPagination.js +74 -63
- package/dist/components/AppPagination.js.map +1 -1
- package/dist/components/Spin.d.ts +6 -6
- package/dist/components/Spin.js +21 -17
- package/dist/components/Spin.js.map +1 -1
- package/dist/components/Toaster/Toaster.d.ts +7 -7
- package/dist/components/Toaster/Toaster.js +41 -29
- package/dist/components/Toaster/Toaster.js.map +1 -1
- package/dist/components/Toaster/Types.d.ts +6 -6
- package/dist/components/Toaster/Types.js +1 -1
- package/dist/components/index.d.ts +7 -7
- package/dist/components/index.js +7 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/CurrencyUtiles.d.ts +4 -4
- package/dist/utils/CurrencyUtiles.js +35 -30
- package/dist/utils/CurrencyUtiles.js.map +1 -1
- package/dist/utils/DateUtils.d.ts +7 -7
- package/dist/utils/DateUtils.js +111 -100
- package/dist/utils/DateUtils.js.map +1 -1
- package/dist/utils/FileUtils.d.ts +5 -5
- package/dist/utils/FileUtils.js +73 -73
- package/dist/utils/FileUtils.js.map +1 -1
- package/dist/utils/Logger.d.ts +13 -0
- package/dist/utils/Logger.js +44 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/RegExValidation.d.ts +4 -4
- package/dist/utils/RegExValidation.js +19 -19
- package/dist/utils/UrlUtils.d.ts +4 -4
- package/dist/utils/UrlUtils.js +15 -15
- package/dist/utils/UrlUtils.js.map +1 -1
- package/dist/utils/configuration/ConfigurationLoader.d.ts +6 -6
- package/dist/utils/configuration/ConfigurationLoader.js +76 -75
- package/dist/utils/configuration/ConfigurationLoader.js.map +1 -1
- package/dist/utils/configuration/ConfigurationManager.d.ts +5 -5
- package/dist/utils/configuration/ConfigurationManager.js +96 -89
- package/dist/utils/configuration/ConfigurationManager.js.map +1 -1
- package/dist/utils/configuration/ConfigurationReturner.d.ts +9 -9
- package/dist/utils/configuration/ConfigurationReturner.js +70 -69
- package/dist/utils/configuration/ConfigurationReturner.js.map +1 -1
- package/dist/utils/configuration/index.d.ts +4 -4
- package/dist/utils/configuration/index.js +4 -4
- package/dist/utils/fetch/Types.d.ts +10 -10
- package/dist/utils/fetch/Types.js +1 -1
- package/dist/utils/fetch/fetchWrapper.d.ts +14 -14
- package/dist/utils/fetch/fetchWrapper.js +239 -262
- package/dist/utils/fetch/fetchWrapper.js.map +1 -1
- package/dist/utils/fetch/index.d.ts +3 -3
- package/dist/utils/fetch/index.js +3 -3
- package/dist/utils/index.d.ts +10 -9
- package/dist/utils/index.js +10 -9
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/labels/LanguageLoader.d.ts +7 -7
- package/dist/utils/labels/LanguageLoader.js +130 -100
- package/dist/utils/labels/LanguageLoader.js.map +1 -1
- package/dist/utils/labels/LanguageManager.d.ts +6 -6
- package/dist/utils/labels/LanguageManager.js +118 -110
- package/dist/utils/labels/LanguageManager.js.map +1 -1
- package/dist/utils/labels/LanguageReturner.d.ts +10 -10
- package/dist/utils/labels/LanguageReturner.js +70 -69
- package/dist/utils/labels/LanguageReturner.js.map +1 -1
- package/dist/utils/labels/index.d.ts +4 -4
- package/dist/utils/labels/index.js +4 -4
- package/docs/APP_ICON.md +82 -0
- package/docs/APP_INPUT.md +81 -0
- package/docs/APP_PAGINATION.md +61 -0
- package/docs/CONFIGURATION.md +105 -0
- package/docs/FETCH_WRAPPER.md +163 -0
- package/docs/LABELS.md +148 -0
- package/docs/LOGGER.md +112 -0
- package/docs/SECURITY_AUDIT_2026-02-05.md +468 -0
- package/docs/SPIN.md +45 -0
- package/docs/TOASTER.md +75 -0
- package/docs/UTILITIES.md +177 -0
- package/package.json +25 -35
- package/src/App.css +0 -12
- package/src/lib/components/AppIcon.tsx +0 -784
- package/src/lib/components/AppInput.tsx +0 -66
- package/src/lib/components/AppPagination.tsx +0 -124
- package/src/lib/components/Spin.tsx +0 -31
- package/src/lib/components/Toaster/Toaster.tsx +0 -50
- package/src/lib/components/Toaster/Types.ts +0 -11
- package/src/lib/components/index.ts +0 -8
- package/src/lib/index.ts +0 -15
- package/src/lib/styles/base.css +0 -392
- package/src/lib/styles/syncfusion_bootstrap4.css +0 -10
- package/src/lib/styles/toaster.css +0 -50
- package/src/lib/utils/CurrencyUtiles.ts +0 -48
- package/src/lib/utils/DateUtils.ts +0 -135
- package/src/lib/utils/FileUtils.ts +0 -40
- package/src/lib/utils/RegExValidation.ts +0 -49
- package/src/lib/utils/UrlUtils.ts +0 -17
- package/src/lib/utils/configuration/ConfigurationLoader.tsx +0 -43
- package/src/lib/utils/configuration/ConfigurationManager.ts +0 -38
- package/src/lib/utils/configuration/ConfigurationReturner.tsx +0 -39
- package/src/lib/utils/configuration/index.ts +0 -9
- package/src/lib/utils/fetch/Types.ts +0 -11
- package/src/lib/utils/fetch/fetchWrapper.ts +0 -174
- package/src/lib/utils/fetch/index.ts +0 -4
- package/src/lib/utils/index.ts +0 -11
- package/src/lib/utils/labels/LanguageLoader.tsx +0 -69
- package/src/lib/utils/labels/LanguageManager.ts +0 -61
- package/src/lib/utils/labels/LanguageReturner.tsx +0 -41
- package/src/lib/utils/labels/index.ts +0 -9
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Utilities
|
|
2
|
+
|
|
3
|
+
Standalone utility functions for dates, currency, files, URLs, and input validation.
|
|
4
|
+
|
|
5
|
+
All utilities use the factory pattern: import the function, call it to get an object of methods.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import { Utils } from '@firedesktop/react-base';
|
|
11
|
+
|
|
12
|
+
const { dateToString, dateToString_Italian, isoStringToDate, removeTime, zuluTimeUTC_to_yourTimeZone } = Utils.DateUtils();
|
|
13
|
+
const { numberToCurrencyString, numberToCurrencyStringNoSymbol } = Utils.CurrencyUtiles();
|
|
14
|
+
const { b64toBlob, fileReadAsync } = Utils.FileUtils();
|
|
15
|
+
const { validate: validateUrl } = Utils.UrlUtils();
|
|
16
|
+
const { isAValid_CSharpName, isAValid_EmailAddress } = Utils.RegExValidation();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## DateUtils
|
|
22
|
+
|
|
23
|
+
### `dateToString(date, locale?)`
|
|
24
|
+
|
|
25
|
+
Format a date using `Intl.DateTimeFormat`.
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Default | Description |
|
|
28
|
+
|-----------|------|---------|-------------|
|
|
29
|
+
| `date` | `string \| Date` | -- | Date to format |
|
|
30
|
+
| `locale` | `string` | `'IT'` | Locale code for formatting |
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
dateToString(new Date()); // "05/02/2026"
|
|
34
|
+
dateToString('2026-02-05', 'en-US'); // "2/5/2026"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### `dateToString_Italian(date, separator, time?)`
|
|
38
|
+
|
|
39
|
+
Format as Italian-style string with configurable separator and optional time.
|
|
40
|
+
|
|
41
|
+
| Parameter | Type | Description |
|
|
42
|
+
|-----------|------|-------------|
|
|
43
|
+
| `date` | `string \| Date \| undefined` | Date to format |
|
|
44
|
+
| `separator` | `string` | Date separator (e.g., `'/'`, `'-'`, `'.'`) |
|
|
45
|
+
| `time` | `'HH:mm' \| 'HH:mm:ss' \| undefined` | Optional time format |
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
dateToString_Italian(new Date(), '/', 'HH:mm'); // "05/02/2026 14:30"
|
|
49
|
+
dateToString_Italian(new Date(), '-', 'HH:mm:ss'); // "05-02-2026 14:30:45"
|
|
50
|
+
dateToString_Italian(new Date(), '/'); // "05/02/2026"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### `isoStringToDate(value)`
|
|
54
|
+
|
|
55
|
+
Parse an ISO date string to a `Date` object. Returns `undefined` if invalid.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
isoStringToDate('2026-02-05T14:00:00.000Z'); // Date object
|
|
59
|
+
isoStringToDate(undefined); // undefined
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### `removeTime(date)`
|
|
63
|
+
|
|
64
|
+
Return a new `Date` at midnight (00:00:00) on the same day.
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
removeTime(new Date('2026-02-05T14:30:00')); // Date at 2026-02-05T00:00:00
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### `zuluTimeUTC_to_yourTimeZone(isoString)`
|
|
71
|
+
|
|
72
|
+
Convert a Z-formatted UTC string to local timezone in `YYYY-MM-DDTHH:mm:ss` format (no `Z` suffix). Returns the input unchanged if it doesn't end with `Z`.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
zuluTimeUTC_to_yourTimeZone('2026-02-05T14:00:00.000Z'); // "2026-02-05T15:00:00" (CET)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## CurrencyUtiles
|
|
81
|
+
|
|
82
|
+
### `numberToCurrencyString(value, locale?, currency?)`
|
|
83
|
+
|
|
84
|
+
Format a number as a currency string using `Intl.NumberFormat`.
|
|
85
|
+
|
|
86
|
+
| Parameter | Type | Default | Description |
|
|
87
|
+
|-----------|------|---------|-------------|
|
|
88
|
+
| `value` | `string \| number \| undefined` | -- | Value to format |
|
|
89
|
+
| `locale` | `string` | `'IT'` | Locale for formatting |
|
|
90
|
+
| `currency` | `string` | `'EUR'` | ISO 4217 currency code |
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
numberToCurrencyString(1234.5); // "1.234,50 €"
|
|
94
|
+
numberToCurrencyString(1234.5, 'en-US', 'USD'); // "$1,234.50"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `numberToCurrencyStringNoSymbol(value, locale?, minimumFractionDigits?)`
|
|
98
|
+
|
|
99
|
+
Format a number without a currency symbol.
|
|
100
|
+
|
|
101
|
+
| Parameter | Type | Default | Description |
|
|
102
|
+
|-----------|------|---------|-------------|
|
|
103
|
+
| `value` | `string \| number \| undefined` | -- | Value to format |
|
|
104
|
+
| `locale` | `string` | `'IT'` | Locale for formatting |
|
|
105
|
+
| `minimumFractionDigits` | `number` | `2` | Minimum decimal places |
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
numberToCurrencyStringNoSymbol(1234.5); // "1.234,50"
|
|
109
|
+
numberToCurrencyStringNoSymbol(1234.5, 'en-US'); // "1,234.50"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## FileUtils
|
|
115
|
+
|
|
116
|
+
### `b64toBlob(b64Data, contentType?, sliceSize?)`
|
|
117
|
+
|
|
118
|
+
Convert a base64 string to a `Blob`.
|
|
119
|
+
|
|
120
|
+
| Parameter | Type | Default | Description |
|
|
121
|
+
|-----------|------|---------|-------------|
|
|
122
|
+
| `b64Data` | `string` | -- | Base64-encoded data |
|
|
123
|
+
| `contentType` | `string` | `''` | MIME type |
|
|
124
|
+
| `sliceSize` | `number` | `512` | Byte processing chunk size |
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const blob = b64toBlob(pdfBase64, 'application/pdf');
|
|
128
|
+
const url = URL.createObjectURL(blob);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `fileReadAsync(file)`
|
|
132
|
+
|
|
133
|
+
Read a `File` object as text asynchronously.
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
const text = await fileReadAsync(inputElement.files[0]);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## UrlUtils
|
|
142
|
+
|
|
143
|
+
### `validate(url?)`
|
|
144
|
+
|
|
145
|
+
Validate a URL string (supports HTTP/HTTPS, domain names, IPs, ports, paths, query strings, fragments).
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
validateUrl('https://example.com'); // true
|
|
149
|
+
validateUrl('http://192.168.1.1:8080'); // true
|
|
150
|
+
validateUrl('not a url'); // false
|
|
151
|
+
validateUrl(undefined); // false
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## RegExValidation
|
|
157
|
+
|
|
158
|
+
### `isAValid_CSharpName(value?)`
|
|
159
|
+
|
|
160
|
+
Validate that a string is a valid C# identifier: starts with a letter, contains only letters, digits, and underscores.
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
isAValid_CSharpName('MyClass'); // true
|
|
164
|
+
isAValid_CSharpName('my_var_1'); // true
|
|
165
|
+
isAValid_CSharpName('1invalid'); // false
|
|
166
|
+
isAValid_CSharpName('has space'); // false
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `isAValid_EmailAddress(value?)`
|
|
170
|
+
|
|
171
|
+
Validate email format.
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
isAValid_EmailAddress('user@example.com'); // true
|
|
175
|
+
isAValid_EmailAddress('invalid'); // false
|
|
176
|
+
isAValid_EmailAddress(undefined); // false
|
|
177
|
+
```
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firedesktop/react-base",
|
|
3
|
-
"version": "
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/",
|
|
9
|
+
"docs/",
|
|
10
|
+
"LICENSE",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
6
13
|
"description": "This is the FireDesktop base package used to support every React Project in this Company.",
|
|
7
14
|
"author": "Firedesktop",
|
|
8
15
|
"repository": "https://firedesktopDevOps@dev.azure.com/firedesktopDevOps/baseFEComponents/_git/baseFEComponents",
|
|
@@ -11,30 +18,30 @@
|
|
|
11
18
|
"@syncfusion/ej2-react-notifications": "32.1.24"
|
|
12
19
|
},
|
|
13
20
|
"devDependencies": {
|
|
14
|
-
"@babel/cli": "7.28.6",
|
|
15
|
-
"@babel/core": "7.28.6",
|
|
16
|
-
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
17
|
-
"@babel/plugin-transform-arrow-functions": "7.27.1",
|
|
18
|
-
"@babel/preset-typescript": "7.28.5",
|
|
19
21
|
"@testing-library/jest-dom": "6.9.1",
|
|
20
22
|
"@testing-library/react": "16.3.2",
|
|
21
23
|
"@testing-library/user-event": "14.6.1",
|
|
22
|
-
"@types/jest": "30.0.0",
|
|
23
24
|
"@types/node": "25.0.9",
|
|
24
25
|
"@types/react": "19.2.9",
|
|
25
26
|
"@types/react-dom": "19.2.3",
|
|
26
27
|
"@types/react-redux": "7.1.34",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
29
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
30
|
+
"@vitejs/plugin-react": "^5.1.3",
|
|
29
31
|
"bootstrap": "5.3.8",
|
|
30
32
|
"copyfiles": "2.4.1",
|
|
31
|
-
"
|
|
33
|
+
"eslint": "^9.39.2",
|
|
34
|
+
"eslint-plugin-react": "^7.37.5",
|
|
35
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
36
|
+
"jsdom": "^28.0.0",
|
|
37
|
+
"lodash": "4.17.23",
|
|
32
38
|
"react": "18.3.1",
|
|
33
|
-
"react-dom": "18.3.1",
|
|
39
|
+
"react-dom": "18.3.1",
|
|
34
40
|
"react-redux": "9.2.0",
|
|
35
|
-
"
|
|
36
|
-
"typescript": "
|
|
37
|
-
"
|
|
41
|
+
"redux": "^5.0.1",
|
|
42
|
+
"typescript": "4.9.5",
|
|
43
|
+
"vite": "^7.3.1",
|
|
44
|
+
"vitest": "^4.0.18"
|
|
38
45
|
},
|
|
39
46
|
"peerDependencies": {
|
|
40
47
|
"bootstrap": ">=4.5.3",
|
|
@@ -44,25 +51,8 @@
|
|
|
44
51
|
},
|
|
45
52
|
"scripts": {
|
|
46
53
|
"distribute": "rmdir /s /q dist & mkdir dist\\styles && tsc && copyfiles -f src/lib/styles/* dist/styles",
|
|
47
|
-
"start": "
|
|
48
|
-
"test": "
|
|
49
|
-
|
|
50
|
-
"eslintConfig": {
|
|
51
|
-
"extends": [
|
|
52
|
-
"react-app",
|
|
53
|
-
"react-app/jest"
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
"browserslist": {
|
|
57
|
-
"production": [
|
|
58
|
-
">0.2%",
|
|
59
|
-
"not dead",
|
|
60
|
-
"not op_mini all"
|
|
61
|
-
],
|
|
62
|
-
"development": [
|
|
63
|
-
"last 1 chrome version",
|
|
64
|
-
"last 1 firefox version",
|
|
65
|
-
"last 1 safari version"
|
|
66
|
-
]
|
|
54
|
+
"start": "vite",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest"
|
|
67
57
|
}
|
|
68
58
|
}
|