@unifylib/ui-lib 1.2.16 → 1.2.18

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 (84) hide show
  1. package/cli/client-app-component-guide.md +166 -166
  2. package/cli/generators/dashboard.js +147 -147
  3. package/cli/generators/form-screen.js +95 -95
  4. package/cli/generators/line-editor.js +110 -110
  5. package/cli/generators/permission-matrix.js +115 -115
  6. package/cli/generators/section-form.js +103 -103
  7. package/cli/generators/table-screen.js +181 -181
  8. package/cli/index.js +185 -185
  9. package/cli/utils.js +228 -228
  10. package/esm2022/iq-ui-lib.mjs +5 -0
  11. package/esm2022/lib/base-model/SearchStrConfig.mjs +1 -1
  12. package/esm2022/lib/base-model/api-response.mjs +1 -1
  13. package/esm2022/lib/base-model/audit-log-entry.mjs +1 -1
  14. package/esm2022/lib/base-model/button-action-settings.mjs +1 -1
  15. package/esm2022/lib/base-model/column-def.model.mjs +1 -1
  16. package/esm2022/lib/base-model/do-action-request.mjs +1 -1
  17. package/esm2022/lib/base-model/field-action.mjs +1 -1
  18. package/esm2022/lib/base-model/field-filter.model.mjs +1 -1
  19. package/esm2022/lib/base-model/field-info.mjs +1 -1
  20. package/esm2022/lib/base-model/field-predicate.model.mjs +1 -1
  21. package/esm2022/lib/base-model/filter-request.mjs +1 -1
  22. package/esm2022/lib/base-model/filter.model.mjs +1 -1
  23. package/esm2022/lib/base-model/get-items-list.mjs +1 -1
  24. package/esm2022/lib/base-model/index.mjs +1 -1
  25. package/esm2022/lib/base-model/items-total.model.mjs +1 -1
  26. package/esm2022/lib/base-model/line-item.model.mjs +1 -1
  27. package/esm2022/lib/base-model/lookupItem.mjs +1 -1
  28. package/esm2022/lib/base-model/page-info.mjs +1 -1
  29. package/esm2022/lib/base-model/permission-matrix.model.mjs +1 -1
  30. package/esm2022/lib/base-model/report-request.model.mjs +1 -1
  31. package/esm2022/lib/base-model/response-envelop.model.mjs +1 -1
  32. package/esm2022/lib/base-model/snack-message.model.mjs +1 -1
  33. package/esm2022/lib/base-model/table-column.interface.mjs +1 -1
  34. package/esm2022/lib/base-model/table-page-user-action.interface.mjs +1 -1
  35. package/esm2022/lib/base-model/workflow/workflow-steps.model.mjs +1 -1
  36. package/esm2022/lib/base-model/workflow/workflow.model.mjs +1 -1
  37. package/esm2022/lib/components/action-comment/action-comment.component.mjs +3 -3
  38. package/esm2022/lib/components/action-confirmation/action-confirmation.component.mjs +3 -3
  39. package/esm2022/lib/components/activity-report-form/activity-report-form.component.mjs +3 -3
  40. package/esm2022/lib/components/advanced-filter/field-filter/field-filter.component.mjs +3 -3
  41. package/esm2022/lib/components/advanced-filter/filter-builder/filter-builder.component.mjs +3 -3
  42. package/esm2022/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.mjs +3 -3
  43. package/esm2022/lib/components/auto-complete/auto-complete.component.mjs +3 -3
  44. package/esm2022/lib/components/base-form/base-form.component.mjs +3 -3
  45. package/esm2022/lib/components/base-form-canvas/MaxDigitsDirective.mjs +1 -1
  46. package/esm2022/lib/components/base-form-canvas/NumbersOnlyDirective.mjs +1 -1
  47. package/esm2022/lib/components/base-form-canvas/base-form-canvas.component.mjs +5 -5
  48. package/esm2022/lib/components/base-input-dialog/base-input-dialog.component.mjs +3 -3
  49. package/esm2022/lib/components/base-table/base-table.component.mjs +3 -3
  50. package/esm2022/lib/components/button-actions/button-actions.component.mjs +3 -3
  51. package/esm2022/lib/components/editable-base-table/editable-base-table.component.mjs +3 -3
  52. package/esm2022/lib/components/equation-builder/equation-builder.component.mjs +3 -3
  53. package/esm2022/lib/components/item-line-editor/item-line-editor.component.mjs +3 -3
  54. package/esm2022/lib/components/multi-auto-complete/multi-auto-complete.component.mjs +11 -10
  55. package/esm2022/lib/components/paginator/paginator.component.mjs +3 -3
  56. package/esm2022/lib/components/permission-matrix/permission-matrix.component.mjs +3 -3
  57. package/esm2022/lib/components/report-details-dialog/report-details-dialog.component.mjs +3 -3
  58. package/esm2022/lib/components/report-form/report-form.component.mjs +3 -3
  59. package/esm2022/lib/components/search-bar/search-bar.component.mjs +3 -3
  60. package/esm2022/lib/components/section-form-canvas/section-form-canvas.component.mjs +3 -3
  61. package/esm2022/lib/components/shared/action-button/action-button.component.mjs +3 -3
  62. package/esm2022/lib/components/shared/action-card/action-card.component.mjs +3 -3
  63. package/esm2022/lib/components/shared/attachment-uploader/attachment-uploader.component.mjs +3 -3
  64. package/esm2022/lib/components/shared-list/shared-list.component.mjs +3 -3
  65. package/esm2022/lib/components/snackbar-static/snackbar-static.component.mjs +3 -3
  66. package/esm2022/lib/components/title-bar/title-bar.component.mjs +3 -3
  67. package/esm2022/lib/directives/phone-number-only.directive.mjs +1 -1
  68. package/esm2022/lib/services/backend-service.mjs +1 -1
  69. package/esm2022/lib/services/index.mjs +1 -1
  70. package/esm2022/lib/services/top-panel.mjs +1 -1
  71. package/esm2022/lib/services/trigger-form.service.mjs +1 -1
  72. package/esm2022/lib/utils/base-utils.mjs +1 -1
  73. package/esm2022/lib/validators/date-range-validator.mjs +1 -1
  74. package/esm2022/lib/validators/index.mjs +1 -1
  75. package/esm2022/lib/validators/match-list.validator.mjs +1 -1
  76. package/esm2022/lib/validators/multi-email-validator.mjs +1 -1
  77. package/esm2022/public-api.mjs +1 -1
  78. package/fesm2022/iq-ui-lib.mjs +7060 -0
  79. package/fesm2022/iq-ui-lib.mjs.map +1 -0
  80. package/index.d.ts +1 -1
  81. package/package.json +14 -6
  82. package/esm2022/unifylib-ui-lib.mjs +0 -5
  83. package/fesm2022/unifylib-ui-lib.mjs +0 -7059
  84. package/fesm2022/unifylib-ui-lib.mjs.map +0 -1
@@ -1,166 +1,166 @@
1
- # Create ui-lib Components in Client Apps
2
-
3
- This guide explains how feature teams create new screens in client applications using `ui-lib` components and the `iq-ui` generator.
4
-
5
- ## Prerequisites
6
-
7
- - `ui-lib` workspace built locally (for local development flow), or package installed from registry.
8
- - Client app is an Angular app (for example `lynx-entities-shell-fe`).
9
- - `@iq/ui-lib` or `@unifylib/ui-lib` import path is decided in your app.
10
-
11
- ---
12
-
13
- ## 1) Local development setup (`@iq/ui-lib`)
14
-
15
- Use this when you develop `ui-lib` and the client app side-by-side.
16
-
17
- From `ui-lib/library-package-workspace`:
18
-
19
- ```bash
20
- ng build iq-ui-lib --watch
21
- npm link dist/iq/ui-lib
22
- ```
23
-
24
- From the client app root:
25
-
26
- ```bash
27
- npm link @iq/ui-lib
28
- ```
29
-
30
- Verify the package link:
31
-
32
- ```bash
33
- npm ls -g --depth=0
34
- ```
35
-
36
- ---
37
-
38
- ## 2) Generate a screen scaffold
39
-
40
- From the client app root, generate a new feature screen:
41
-
42
- ```bash
43
- npx iq-ui -g form-screen src/app/registration --import-path @iq/ui-lib
44
- ```
45
-
46
- This creates:
47
-
48
- - `registration.settings.ts`
49
- - `registration.component.ts`
50
- - `registration.component.html`
51
- - `registration.component.scss`
52
-
53
- Useful options:
54
-
55
- - `-g <type>`: `form-screen`, `table-screen`, `section-form`, `line-editor`, `dashboard`, `permission-matrix`
56
- - `--import-path <p>`: usually `@iq/ui-lib` (local) or `@unifylib/ui-lib` (published)
57
- - `--name <n>`: override generated base name
58
- - `--labels-section <s>`: override `PageInfo.labelsSection`
59
- - `--api-uri <u>`: override `PageInfo.apiUri`
60
- - `--fields-count <n>`: placeholder fields count (form/section/line)
61
- - `--dry-run`: preview generated files without writing
62
- - `--i18n-path <p>`: update translation JSON with template keys used by generated files.
63
- - file mode: `src/assets/en.json`
64
- - folder mode: `src/assets` (updates translation-like files only, such as `en.json` / `ar.json`; skips config JSON files)
65
-
66
- Example table screen:
67
-
68
- ```bash
69
- npx iq-ui -g table-screen src/app/device-list --import-path @iq/ui-lib
70
- ```
71
-
72
- Example with translation template update:
73
-
74
- ```bash
75
- npx iq-ui -g table-screen src/app/device-list --import-path @iq/ui-lib --i18n-path src/assets/en.json
76
- ```
77
-
78
- Example updating both `en.json` and `ar.json` in assets:
79
-
80
- ```bash
81
- npx iq-ui -g table-screen src/app/device-list --import-path @iq/ui-lib --i18n-path src/assets
82
- ```
83
-
84
- ---
85
-
86
- ## 3) What to add in the client app (required setup)
87
-
88
- To use `iq-ui` comfortably in a client app, add/confirm the following:
89
-
90
- 1. **Library availability** (choose one):
91
- - local link flow: `npm link @iq/ui-lib`
92
- - installed dependency flow: `npm install @unifylib/ui-lib`
93
-
94
- 2. **Optional package script** (recommended) in client app `package.json`:
95
-
96
- ```json
97
- {
98
- "scripts": {
99
- "gen:ui": "iq-ui"
100
- }
101
- }
102
- ```
103
-
104
- Then run:
105
-
106
- ```bash
107
- npm run gen:ui -- -g form-screen src/app/registration --import-path @iq/ui-lib
108
- ```
109
-
110
- 3. **Optional shared barrel** if your app centralizes imports:
111
-
112
- ```ts
113
- // src/app/shared/ui-lib-imports.ts
114
- export * from "@iq/ui-lib";
115
- ```
116
-
117
- Then generate using:
118
-
119
- ```bash
120
- npx iq-ui -g form-screen src/app/registration --import-path src/app/shared/ui-lib-imports
121
- ```
122
-
123
- 4. **Route registration** for each generated screen so it is reachable in the client app.
124
-
125
- ---
126
-
127
- ## 4) Wire the generated component into the client app
128
-
129
- 1. Add route (or include component in a parent standalone component).
130
- 2. Add i18n labels for generated keys.
131
- 3. Replace placeholder fields/columns with business fields.
132
- 4. Update API values (`apiUri`, list actions, filters, validators).
133
-
134
- Generated files are intentionally starter templates; treat them as scaffolding.
135
-
136
- ---
137
-
138
- ## 5) If `npx iq-ui` fails with 404
139
-
140
- Error:
141
-
142
- `404 Not Found - GET https://registry.npmjs.org/iq-ui`
143
-
144
- Means `iq-ui` binary is not available in the current app context. Fix by ensuring one of:
145
-
146
- - linked package exists (`npm link @iq/ui-lib` after building/linking library), or
147
- - dependency is installed in the app (`npm install @unifylib/ui-lib` / local file install).
148
-
149
- Then run `npx iq-ui ...` again.
150
-
151
- ---
152
-
153
- ## 6) Published package flow (`@unifylib/ui-lib`)
154
-
155
- If you are not using local links:
156
-
157
- ```bash
158
- npm install @unifylib/ui-lib
159
- npx iq-ui -g form-screen src/app/registration --import-path @unifylib/ui-lib
160
- ```
161
-
162
- If your app re-exports symbols from `src/app/shared/ui-lib-imports`, you can generate against that barrel:
163
-
164
- ```bash
165
- npx iq-ui -g form-screen src/app/registration --import-path src/app/shared/ui-lib-imports
166
- ```
1
+ # Create ui-lib Components in Client Apps
2
+
3
+ This guide explains how feature teams create new screens in client applications using `ui-lib` components and the `iq-ui` generator.
4
+
5
+ ## Prerequisites
6
+
7
+ - `ui-lib` workspace built locally (for local development flow), or package installed from registry.
8
+ - Client app is an Angular app (for example `lynx-entities-shell-fe`).
9
+ - `@iq/ui-lib` or `@unifylib/ui-lib` import path is decided in your app.
10
+
11
+ ---
12
+
13
+ ## 1) Local development setup (`@iq/ui-lib`)
14
+
15
+ Use this when you develop `ui-lib` and the client app side-by-side.
16
+
17
+ From `ui-lib/library-package-workspace`:
18
+
19
+ ```bash
20
+ ng build iq-ui-lib --watch
21
+ npm link dist/iq/ui-lib
22
+ ```
23
+
24
+ From the client app root:
25
+
26
+ ```bash
27
+ npm link @iq/ui-lib
28
+ ```
29
+
30
+ Verify the package link:
31
+
32
+ ```bash
33
+ npm ls -g --depth=0
34
+ ```
35
+
36
+ ---
37
+
38
+ ## 2) Generate a screen scaffold
39
+
40
+ From the client app root, generate a new feature screen:
41
+
42
+ ```bash
43
+ npx iq-ui -g form-screen src/app/registration --import-path @iq/ui-lib
44
+ ```
45
+
46
+ This creates:
47
+
48
+ - `registration.settings.ts`
49
+ - `registration.component.ts`
50
+ - `registration.component.html`
51
+ - `registration.component.scss`
52
+
53
+ Useful options:
54
+
55
+ - `-g <type>`: `form-screen`, `table-screen`, `section-form`, `line-editor`, `dashboard`, `permission-matrix`
56
+ - `--import-path <p>`: usually `@iq/ui-lib` (local) or `@unifylib/ui-lib` (published)
57
+ - `--name <n>`: override generated base name
58
+ - `--labels-section <s>`: override `PageInfo.labelsSection`
59
+ - `--api-uri <u>`: override `PageInfo.apiUri`
60
+ - `--fields-count <n>`: placeholder fields count (form/section/line)
61
+ - `--dry-run`: preview generated files without writing
62
+ - `--i18n-path <p>`: update translation JSON with template keys used by generated files.
63
+ - file mode: `src/assets/en.json`
64
+ - folder mode: `src/assets` (updates translation-like files only, such as `en.json` / `ar.json`; skips config JSON files)
65
+
66
+ Example table screen:
67
+
68
+ ```bash
69
+ npx iq-ui -g table-screen src/app/device-list --import-path @iq/ui-lib
70
+ ```
71
+
72
+ Example with translation template update:
73
+
74
+ ```bash
75
+ npx iq-ui -g table-screen src/app/device-list --import-path @iq/ui-lib --i18n-path src/assets/en.json
76
+ ```
77
+
78
+ Example updating both `en.json` and `ar.json` in assets:
79
+
80
+ ```bash
81
+ npx iq-ui -g table-screen src/app/device-list --import-path @iq/ui-lib --i18n-path src/assets
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 3) What to add in the client app (required setup)
87
+
88
+ To use `iq-ui` comfortably in a client app, add/confirm the following:
89
+
90
+ 1. **Library availability** (choose one):
91
+ - local link flow: `npm link @iq/ui-lib`
92
+ - installed dependency flow: `npm install @unifylib/ui-lib`
93
+
94
+ 2. **Optional package script** (recommended) in client app `package.json`:
95
+
96
+ ```json
97
+ {
98
+ "scripts": {
99
+ "gen:ui": "iq-ui"
100
+ }
101
+ }
102
+ ```
103
+
104
+ Then run:
105
+
106
+ ```bash
107
+ npm run gen:ui -- -g form-screen src/app/registration --import-path @iq/ui-lib
108
+ ```
109
+
110
+ 3. **Optional shared barrel** if your app centralizes imports:
111
+
112
+ ```ts
113
+ // src/app/shared/ui-lib-imports.ts
114
+ export * from "@iq/ui-lib";
115
+ ```
116
+
117
+ Then generate using:
118
+
119
+ ```bash
120
+ npx iq-ui -g form-screen src/app/registration --import-path src/app/shared/ui-lib-imports
121
+ ```
122
+
123
+ 4. **Route registration** for each generated screen so it is reachable in the client app.
124
+
125
+ ---
126
+
127
+ ## 4) Wire the generated component into the client app
128
+
129
+ 1. Add route (or include component in a parent standalone component).
130
+ 2. Add i18n labels for generated keys.
131
+ 3. Replace placeholder fields/columns with business fields.
132
+ 4. Update API values (`apiUri`, list actions, filters, validators).
133
+
134
+ Generated files are intentionally starter templates; treat them as scaffolding.
135
+
136
+ ---
137
+
138
+ ## 5) If `npx iq-ui` fails with 404
139
+
140
+ Error:
141
+
142
+ `404 Not Found - GET https://registry.npmjs.org/iq-ui`
143
+
144
+ Means `iq-ui` binary is not available in the current app context. Fix by ensuring one of:
145
+
146
+ - linked package exists (`npm link @iq/ui-lib` after building/linking library), or
147
+ - dependency is installed in the app (`npm install @unifylib/ui-lib` / local file install).
148
+
149
+ Then run `npx iq-ui ...` again.
150
+
151
+ ---
152
+
153
+ ## 6) Published package flow (`@unifylib/ui-lib`)
154
+
155
+ If you are not using local links:
156
+
157
+ ```bash
158
+ npm install @unifylib/ui-lib
159
+ npx iq-ui -g form-screen src/app/registration --import-path @unifylib/ui-lib
160
+ ```
161
+
162
+ If your app re-exports symbols from `src/app/shared/ui-lib-imports`, you can generate against that barrel:
163
+
164
+ ```bash
165
+ npx iq-ui -g form-screen src/app/registration --import-path src/app/shared/ui-lib-imports
166
+ ```
@@ -1,147 +1,147 @@
1
- "use strict";
2
-
3
- /**
4
- * @param {{
5
- * kebab: string,
6
- * pascal: string,
7
- * labelsSection: string,
8
- * importPath: string,
9
- * }} ctx
10
- */
11
- function generate(ctx) {
12
- const fileBase = ctx.kebab;
13
-
14
- const componentTs = `import { ChangeDetectionStrategy, Component, inject } from "@angular/core";
15
- import { Router } from "@angular/router";
16
- import { TranslateModule } from "@ngx-translate/core";
17
- import { ActionCardComponent, FeatureItem } from "${ctx.importPath}";
18
-
19
- @Component({
20
- selector: "app-${fileBase}",
21
- standalone: true,
22
- imports: [ActionCardComponent, TranslateModule],
23
- templateUrl: "./${fileBase}.component.html",
24
- styleUrls: ["./${fileBase}.component.scss"],
25
- changeDetection: ChangeDetectionStrategy.OnPush,
26
- })
27
- export class ${ctx.pascal}Component {
28
- private readonly router = inject(Router);
29
-
30
- readonly cardAFeatures: FeatureItem[] = [
31
- { textKey: "${ctx.labelsSection}.FEATURE_1" },
32
- { textKey: "${ctx.labelsSection}.FEATURE_2" },
33
- ];
34
-
35
- readonly cardBFeatures: FeatureItem[] = [
36
- { textKey: "${ctx.labelsSection}.FEATURE_3" },
37
- { textKey: "${ctx.labelsSection}.FEATURE_4" },
38
- ];
39
-
40
- navigateA(): void {
41
- void this.router.navigate(["/${ctx.kebab}", "feature-a"]);
42
- }
43
-
44
- navigateB(): void {
45
- void this.router.navigate(["/${ctx.kebab}", "feature-b"]);
46
- }
47
- }
48
- `;
49
-
50
- const componentHtml = `<div class="dashboard-container">
51
- <div class="welcome-section">
52
- <h1 class="welcome-title">{{ '${ctx.labelsSection}.TITLE' | translate }}</h1>
53
- <p class="welcome-subtitle">{{ '${ctx.labelsSection}.SUBTITLE' | translate }}</p>
54
- </div>
55
-
56
- <div class="cards-grid">
57
- <lib-action-card
58
- class="action-card-item"
59
- icon="dashboard"
60
- [titleKey]="'${ctx.labelsSection}.CARD_A_TITLE'"
61
- [descriptionKey]="'${ctx.labelsSection}.CARD_A_DESC'"
62
- [buttonTextKey]="'${ctx.labelsSection}.CARD_A_CTA'"
63
- iconColor="#0d4261"
64
- borderColor="#bcd4e6"
65
- [buttonGradient]="'linear-gradient(90deg, #e3f0ff 0%, #0d4261 100%)'"
66
- [topBorderHeight]="14"
67
- variant="extended"
68
- [features]="cardAFeatures"
69
- [featuresHeadingKey]="'${ctx.labelsSection}.FEATURES'"
70
- [showDivider]="true"
71
- (buttonClick)="navigateA()">
72
- </lib-action-card>
73
-
74
- <lib-action-card
75
- class="action-card-item"
76
- icon="add_to_queue"
77
- [titleKey]="'${ctx.labelsSection}.CARD_B_TITLE'"
78
- [descriptionKey]="'${ctx.labelsSection}.CARD_B_DESC'"
79
- [buttonTextKey]="'${ctx.labelsSection}.CARD_B_CTA'"
80
- iconColor="#8067A4"
81
- borderColor="#BDB3CA"
82
- [buttonGradient]="'linear-gradient(90deg, #D1CBD8 0%, #8168A5 100%)'"
83
- [topBorderHeight]="14"
84
- variant="extended"
85
- [features]="cardBFeatures"
86
- [featuresHeadingKey]="'${ctx.labelsSection}.FEATURES'"
87
- [showDivider]="true"
88
- (buttonClick)="navigateB()">
89
- </lib-action-card>
90
- </div>
91
- </div>
92
- `;
93
-
94
- const componentScss = `.dashboard-container {
95
- padding: 1.5rem;
96
- }
97
-
98
- .welcome-section {
99
- margin-bottom: 2rem;
100
- }
101
-
102
- .welcome-title {
103
- margin: 0 0 0.5rem;
104
- }
105
-
106
- .welcome-subtitle {
107
- margin: 0;
108
- opacity: 0.85;
109
- }
110
-
111
- .cards-grid {
112
- display: grid;
113
- gap: 1.5rem;
114
- grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
115
- }
116
-
117
- .action-card-item {
118
- min-height: 100%;
119
- }
120
- `;
121
-
122
- return [
123
- { relative: `${fileBase}.component.ts`, content: componentTs },
124
- { relative: `${fileBase}.component.html`, content: componentHtml },
125
- { relative: `${fileBase}.component.scss`, content: componentScss },
126
- ];
127
- }
128
-
129
- function getTranslations(ctx) {
130
- return {
131
- [`${ctx.labelsSection}.TITLE`]: `${ctx.pascal} Dashboard`,
132
- [`${ctx.labelsSection}.SUBTITLE`]: "Choose an option to continue",
133
- [`${ctx.labelsSection}.FEATURES`]: "Features",
134
- [`${ctx.labelsSection}.CARD_A_TITLE`]: "Card A",
135
- [`${ctx.labelsSection}.CARD_A_DESC`]: "Description for card A",
136
- [`${ctx.labelsSection}.CARD_A_CTA`]: "Open",
137
- [`${ctx.labelsSection}.CARD_B_TITLE`]: "Card B",
138
- [`${ctx.labelsSection}.CARD_B_DESC`]: "Description for card B",
139
- [`${ctx.labelsSection}.CARD_B_CTA`]: "Open",
140
- [`${ctx.labelsSection}.FEATURE_1`]: "Feature 1",
141
- [`${ctx.labelsSection}.FEATURE_2`]: "Feature 2",
142
- [`${ctx.labelsSection}.FEATURE_3`]: "Feature 3",
143
- [`${ctx.labelsSection}.FEATURE_4`]: "Feature 4",
144
- };
145
- }
146
-
147
- module.exports = { generate, getTranslations };
1
+ "use strict";
2
+
3
+ /**
4
+ * @param {{
5
+ * kebab: string,
6
+ * pascal: string,
7
+ * labelsSection: string,
8
+ * importPath: string,
9
+ * }} ctx
10
+ */
11
+ function generate(ctx) {
12
+ const fileBase = ctx.kebab;
13
+
14
+ const componentTs = `import { ChangeDetectionStrategy, Component, inject } from "@angular/core";
15
+ import { Router } from "@angular/router";
16
+ import { TranslateModule } from "@ngx-translate/core";
17
+ import { ActionCardComponent, FeatureItem } from "${ctx.importPath}";
18
+
19
+ @Component({
20
+ selector: "app-${fileBase}",
21
+ standalone: true,
22
+ imports: [ActionCardComponent, TranslateModule],
23
+ templateUrl: "./${fileBase}.component.html",
24
+ styleUrls: ["./${fileBase}.component.scss"],
25
+ changeDetection: ChangeDetectionStrategy.OnPush,
26
+ })
27
+ export class ${ctx.pascal}Component {
28
+ private readonly router = inject(Router);
29
+
30
+ readonly cardAFeatures: FeatureItem[] = [
31
+ { textKey: "${ctx.labelsSection}.FEATURE_1" },
32
+ { textKey: "${ctx.labelsSection}.FEATURE_2" },
33
+ ];
34
+
35
+ readonly cardBFeatures: FeatureItem[] = [
36
+ { textKey: "${ctx.labelsSection}.FEATURE_3" },
37
+ { textKey: "${ctx.labelsSection}.FEATURE_4" },
38
+ ];
39
+
40
+ navigateA(): void {
41
+ void this.router.navigate(["/${ctx.kebab}", "feature-a"]);
42
+ }
43
+
44
+ navigateB(): void {
45
+ void this.router.navigate(["/${ctx.kebab}", "feature-b"]);
46
+ }
47
+ }
48
+ `;
49
+
50
+ const componentHtml = `<div class="dashboard-container">
51
+ <div class="welcome-section">
52
+ <h1 class="welcome-title">{{ '${ctx.labelsSection}.TITLE' | translate }}</h1>
53
+ <p class="welcome-subtitle">{{ '${ctx.labelsSection}.SUBTITLE' | translate }}</p>
54
+ </div>
55
+
56
+ <div class="cards-grid">
57
+ <lib-action-card
58
+ class="action-card-item"
59
+ icon="dashboard"
60
+ [titleKey]="'${ctx.labelsSection}.CARD_A_TITLE'"
61
+ [descriptionKey]="'${ctx.labelsSection}.CARD_A_DESC'"
62
+ [buttonTextKey]="'${ctx.labelsSection}.CARD_A_CTA'"
63
+ iconColor="#0d4261"
64
+ borderColor="#bcd4e6"
65
+ [buttonGradient]="'linear-gradient(90deg, #e3f0ff 0%, #0d4261 100%)'"
66
+ [topBorderHeight]="14"
67
+ variant="extended"
68
+ [features]="cardAFeatures"
69
+ [featuresHeadingKey]="'${ctx.labelsSection}.FEATURES'"
70
+ [showDivider]="true"
71
+ (buttonClick)="navigateA()">
72
+ </lib-action-card>
73
+
74
+ <lib-action-card
75
+ class="action-card-item"
76
+ icon="add_to_queue"
77
+ [titleKey]="'${ctx.labelsSection}.CARD_B_TITLE'"
78
+ [descriptionKey]="'${ctx.labelsSection}.CARD_B_DESC'"
79
+ [buttonTextKey]="'${ctx.labelsSection}.CARD_B_CTA'"
80
+ iconColor="#8067A4"
81
+ borderColor="#BDB3CA"
82
+ [buttonGradient]="'linear-gradient(90deg, #D1CBD8 0%, #8168A5 100%)'"
83
+ [topBorderHeight]="14"
84
+ variant="extended"
85
+ [features]="cardBFeatures"
86
+ [featuresHeadingKey]="'${ctx.labelsSection}.FEATURES'"
87
+ [showDivider]="true"
88
+ (buttonClick)="navigateB()">
89
+ </lib-action-card>
90
+ </div>
91
+ </div>
92
+ `;
93
+
94
+ const componentScss = `.dashboard-container {
95
+ padding: 1.5rem;
96
+ }
97
+
98
+ .welcome-section {
99
+ margin-bottom: 2rem;
100
+ }
101
+
102
+ .welcome-title {
103
+ margin: 0 0 0.5rem;
104
+ }
105
+
106
+ .welcome-subtitle {
107
+ margin: 0;
108
+ opacity: 0.85;
109
+ }
110
+
111
+ .cards-grid {
112
+ display: grid;
113
+ gap: 1.5rem;
114
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
115
+ }
116
+
117
+ .action-card-item {
118
+ min-height: 100%;
119
+ }
120
+ `;
121
+
122
+ return [
123
+ { relative: `${fileBase}.component.ts`, content: componentTs },
124
+ { relative: `${fileBase}.component.html`, content: componentHtml },
125
+ { relative: `${fileBase}.component.scss`, content: componentScss },
126
+ ];
127
+ }
128
+
129
+ function getTranslations(ctx) {
130
+ return {
131
+ [`${ctx.labelsSection}.TITLE`]: `${ctx.pascal} Dashboard`,
132
+ [`${ctx.labelsSection}.SUBTITLE`]: "Choose an option to continue",
133
+ [`${ctx.labelsSection}.FEATURES`]: "Features",
134
+ [`${ctx.labelsSection}.CARD_A_TITLE`]: "Card A",
135
+ [`${ctx.labelsSection}.CARD_A_DESC`]: "Description for card A",
136
+ [`${ctx.labelsSection}.CARD_A_CTA`]: "Open",
137
+ [`${ctx.labelsSection}.CARD_B_TITLE`]: "Card B",
138
+ [`${ctx.labelsSection}.CARD_B_DESC`]: "Description for card B",
139
+ [`${ctx.labelsSection}.CARD_B_CTA`]: "Open",
140
+ [`${ctx.labelsSection}.FEATURE_1`]: "Feature 1",
141
+ [`${ctx.labelsSection}.FEATURE_2`]: "Feature 2",
142
+ [`${ctx.labelsSection}.FEATURE_3`]: "Feature 3",
143
+ [`${ctx.labelsSection}.FEATURE_4`]: "Feature 4",
144
+ };
145
+ }
146
+
147
+ module.exports = { generate, getTranslations };