@flusys/ng-auth 4.0.0-rc → 4.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 +172 -3
- package/fesm2022/flusys-ng-auth.mjs +82 -54
- package/fesm2022/flusys-ng-auth.mjs.map +1 -1
- package/package.json +6 -5
- package/types/flusys-ng-auth.d.ts +31 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
`@flusys/ng-auth` provides complete authentication functionality including login, registration, token management, company/branch selection, user administration, and permission handling.
|
|
6
6
|
|
|
7
7
|
**Package:** `@flusys/ng-auth`
|
|
8
|
-
**Version:** 4.0.
|
|
8
|
+
**Version:** 4.0.2
|
|
9
9
|
**Dependencies:** ng-core, ng-shared, ng-layout
|
|
10
10
|
**Build:** `npm run build:ng-auth`
|
|
11
11
|
|
|
@@ -1436,6 +1436,167 @@ When using extensions, registration data flows as:
|
|
|
1436
1436
|
|
|
1437
1437
|
---
|
|
1438
1438
|
|
|
1439
|
+
## Translation System (v4.0.0+)
|
|
1440
|
+
|
|
1441
|
+
### Smart Translation Pattern with Fallback
|
|
1442
|
+
|
|
1443
|
+
All text fields (labels, placeholders, headers, titles) now support intelligent translation fallback:
|
|
1444
|
+
|
|
1445
|
+
```typescript
|
|
1446
|
+
// Interface Pattern
|
|
1447
|
+
interface IField {
|
|
1448
|
+
label: string; // Fallback text (always required)
|
|
1449
|
+
labelKey?: string; // Translation key (optional)
|
|
1450
|
+
placeholder?: string; // Fallback text (optional)
|
|
1451
|
+
placeholderKey?: string; // Translation key (optional)
|
|
1452
|
+
}
|
|
1453
|
+
```
|
|
1454
|
+
|
|
1455
|
+
### Message/Validation Parameter Support
|
|
1456
|
+
|
|
1457
|
+
Validation messages and custom messages now support parameter interpolation:
|
|
1458
|
+
|
|
1459
|
+
```typescript
|
|
1460
|
+
// Interface Pattern
|
|
1461
|
+
interface IValidationConfig {
|
|
1462
|
+
message?: string; // Fallback message
|
|
1463
|
+
messageKey?: string; // Translation key
|
|
1464
|
+
messageParam?: Record<string, string | number>; // Interpolation params
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
interface IField {
|
|
1468
|
+
validationMessage?: string;
|
|
1469
|
+
validationMessageKey?: string;
|
|
1470
|
+
validationMessageParam?: Record<string, string | number>;
|
|
1471
|
+
}
|
|
1472
|
+
```
|
|
1473
|
+
|
|
1474
|
+
**Usage Example:**
|
|
1475
|
+
```typescript
|
|
1476
|
+
// Provider configuration
|
|
1477
|
+
validationConfig: {
|
|
1478
|
+
message: "Password must be at least {{min}} characters",
|
|
1479
|
+
messageKey: "auth.validation.password.min.length",
|
|
1480
|
+
messageParam: { min: 8 }
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
// Field configuration
|
|
1484
|
+
{
|
|
1485
|
+
label: "Company Name",
|
|
1486
|
+
labelKey: "admin.company.name",
|
|
1487
|
+
placeholder: "Enter company name",
|
|
1488
|
+
placeholderKey: "admin.company.name.placeholder",
|
|
1489
|
+
validationMessage: "Company name is required",
|
|
1490
|
+
validationMessageKey: "admin.company.name.required",
|
|
1491
|
+
validationMessageParam: {}
|
|
1492
|
+
}
|
|
1493
|
+
```
|
|
1494
|
+
|
|
1495
|
+
### safeTranslate() Method
|
|
1496
|
+
|
|
1497
|
+
All form components have a protected `safeTranslate()` helper method that intelligently falls back when translations are missing:
|
|
1498
|
+
|
|
1499
|
+
```typescript
|
|
1500
|
+
/** Translate with fallback: if key returns unchanged, use fallback instead */
|
|
1501
|
+
safeTranslate(key: string | undefined, fallback: string): string {
|
|
1502
|
+
if (!key) return fallback;
|
|
1503
|
+
const translated = this.translate(key);
|
|
1504
|
+
return translated === key ? fallback : translated; // Smart fallback!
|
|
1505
|
+
}
|
|
1506
|
+
```
|
|
1507
|
+
|
|
1508
|
+
**Behavior:**
|
|
1509
|
+
```
|
|
1510
|
+
safeTranslate(undefined, "Name")
|
|
1511
|
+
→ Returns: "Name" (no key, use fallback)
|
|
1512
|
+
|
|
1513
|
+
safeTranslate("auth.profile.name", "Name")
|
|
1514
|
+
→ Returns: "Nome" (translated)
|
|
1515
|
+
|
|
1516
|
+
safeTranslate("auth.new.feature", "Name")
|
|
1517
|
+
→ Returns: "Name" (no translation, use fallback)
|
|
1518
|
+
```
|
|
1519
|
+
|
|
1520
|
+
### Template Usage Patterns
|
|
1521
|
+
|
|
1522
|
+
**Pattern 1: Simple Label**
|
|
1523
|
+
```html
|
|
1524
|
+
{{ safeTranslate(field.labelKey, field.label) }}
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
**Pattern 2: Placeholder with Default**
|
|
1528
|
+
```html
|
|
1529
|
+
{{ safeTranslate(field.placeholderKey, field.placeholder ?? '') }}
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
**Pattern 3: Fallback Translation Chain**
|
|
1533
|
+
```html
|
|
1534
|
+
{{ safeTranslate(field.placeholderKey, field.placeholder ?? ('shared.select' | translate)) }}
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
**Pattern 4: Complex Nested Fallback**
|
|
1538
|
+
```html
|
|
1539
|
+
{{ safeTranslate(
|
|
1540
|
+
field.placeholderKey,
|
|
1541
|
+
field.placeholder ?? safeTranslate(field.labelKey, field.label)
|
|
1542
|
+
) }}
|
|
1543
|
+
```
|
|
1544
|
+
|
|
1545
|
+
### Components Using safeTranslate()
|
|
1546
|
+
|
|
1547
|
+
- **RegisterPageComponent** - Registration extra fields
|
|
1548
|
+
- **ProfilePageComponent** - User editable + admin view-only fields
|
|
1549
|
+
- **UserFormComponent** - Admin user form fields
|
|
1550
|
+
- **UserListComponent** - Custom columns and action labels
|
|
1551
|
+
|
|
1552
|
+
### Translation File Integration
|
|
1553
|
+
|
|
1554
|
+
When translations exist, they are automatically used:
|
|
1555
|
+
|
|
1556
|
+
**Translation file (en.json):**
|
|
1557
|
+
```json
|
|
1558
|
+
{
|
|
1559
|
+
"auth.profile.name": "User Name",
|
|
1560
|
+
"auth.phone.placeholder": "Enter phone number",
|
|
1561
|
+
"admin.company.name": "Company",
|
|
1562
|
+
"shared.select": "Select an option"
|
|
1563
|
+
}
|
|
1564
|
+
```
|
|
1565
|
+
|
|
1566
|
+
**When key exists in translations:** Shows translated value
|
|
1567
|
+
**When key missing from translations:** Shows fallback text (label/placeholder/message)
|
|
1568
|
+
**When key undefined:** Shows fallback text directly
|
|
1569
|
+
|
|
1570
|
+
### Corner Cases Handled
|
|
1571
|
+
|
|
1572
|
+
| Scenario | Result |
|
|
1573
|
+
|----------|--------|
|
|
1574
|
+
| Key undefined | Returns fallback ✅ |
|
|
1575
|
+
| Translation missing | Returns fallback ✅ |
|
|
1576
|
+
| No TRANSLATE_ADAPTER | Returns fallback ✅ |
|
|
1577
|
+
| Fallback is empty string | Displays empty string (valid) ✅ |
|
|
1578
|
+
| Parameter interpolation | Supported via messageParam ✅ |
|
|
1579
|
+
| Nested safeTranslate calls | Works correctly ✅ |
|
|
1580
|
+
|
|
1581
|
+
### Migration from v3.0.x
|
|
1582
|
+
|
|
1583
|
+
**Removed fields** (no longer needed):
|
|
1584
|
+
```typescript
|
|
1585
|
+
❌ labelFallback → Use label directly
|
|
1586
|
+
❌ placeholderFallback → Use placeholder directly
|
|
1587
|
+
❌ titleFallback → Use title directly
|
|
1588
|
+
❌ headerFallback → Use header directly
|
|
1589
|
+
❌ messageFallback → Use message directly
|
|
1590
|
+
```
|
|
1591
|
+
|
|
1592
|
+
**Removed:** `labelFallback`, `placeholderFallback`, `titleFallback`, `headerFallback`, `messageFallback`
|
|
1593
|
+
|
|
1594
|
+
**Added:** `messageParam`, `validationMessageParam` for parameter interpolation
|
|
1595
|
+
|
|
1596
|
+
**No breaking changes:** Existing implementations still work due to smart fallback logic.
|
|
1597
|
+
|
|
1598
|
+
---
|
|
1599
|
+
|
|
1439
1600
|
## See Also
|
|
1440
1601
|
|
|
1441
1602
|
- [CORE-GUIDE.md](./CORE-GUIDE.md) - APP_CONFIG configuration
|
|
@@ -1446,8 +1607,16 @@ When using extensions, registration data flows as:
|
|
|
1446
1607
|
|
|
1447
1608
|
---
|
|
1448
1609
|
|
|
1449
|
-
**Last Updated:** 2026-03-
|
|
1450
|
-
**Version:**
|
|
1610
|
+
**Last Updated:** 2026-03-03
|
|
1611
|
+
**Version:** 4.0.0-rc
|
|
1451
1612
|
**Angular Version:** 21
|
|
1452
1613
|
|
|
1614
|
+
## Key Changes in v4.0.0-rc
|
|
1615
|
+
|
|
1616
|
+
- ✅ Smart translation fallback system with `safeTranslate()` helper
|
|
1617
|
+
- ✅ Message parameter support (`messageParam`, `validationMessageParam`)
|
|
1618
|
+
- ✅ Removed redundant `*Fallback` interface fields
|
|
1619
|
+
- ✅ All 4 form pages use safe translation pattern
|
|
1620
|
+
- ✅ Type-safe, TypeScript enforced
|
|
1621
|
+
|
|
1453
1622
|
All 15 components use responsive design and dark mode support. Form components use Signal Forms.
|