@scania-nl/tegel-angular-extensions 0.0.6 → 0.0.8
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 +438 -46
- package/esm2022/index.mjs +8 -1
- package/esm2022/lib/directives/barcode-scanner.directive.mjs +94 -0
- package/esm2022/lib/env/angular/provide-runtime-config.mjs +7 -5
- package/esm2022/lib/modal/components/modal/modal.component.mjs +121 -0
- package/esm2022/lib/modal/components/modal-host/modal-host.component.mjs +32 -0
- package/esm2022/lib/modal/directives/dynamic-component.directive.mjs +135 -0
- package/esm2022/lib/modal/modal.service.mjs +156 -0
- package/esm2022/lib/modal/provide-modal.mjs +25 -0
- package/esm2022/lib/modal/schema/modal-ref.mjs +2 -0
- package/esm2022/lib/modal/schema/modal.config.mjs +15 -0
- package/esm2022/lib/modal/schema/modal.model.mjs +2 -0
- package/esm2022/lib/modal/schema/modal.types.mjs +3 -0
- package/esm2022/lib/toast/provide-toast.mjs +7 -1
- package/esm2022/lib/utils/angular-component-io.mjs +2 -0
- package/index.d.ts +296 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,23 +5,30 @@
|
|
|
5
5
|
|
|
6
6
|
# @scania-nl/tegel-angular-extensions
|
|
7
7
|
|
|
8
|
-
Angular services for working with the [Tegel Angular 17](https://www.npmjs.com/package/@scania/tegel-angular-17) component library.
|
|
9
|
-
Provides simple wrappers for toast and modal
|
|
8
|
+
Angular components, services, and directives for working with the [Tegel Angular 17](https://www.npmjs.com/package/@scania/tegel-angular-17) component library.
|
|
9
|
+
Provides simple wrappers for toast and modal functionality using Angular 19+ **standalone components** and **dependency injection configuration**.
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Features
|
|
14
16
|
|
|
15
17
|
1. **Runtime environment configuration**
|
|
16
18
|
- Schema-driven configuration and validation using Zod
|
|
17
19
|
- Deep-partial runtime overrides
|
|
18
20
|
- Runtime-required key enforcements
|
|
19
21
|
- Strong TypeScript inference
|
|
20
|
-
2. **
|
|
21
|
-
- Drop-in UI integrations for Tegel Angular
|
|
22
|
+
2. **Toast management**
|
|
22
23
|
- Signal-based `ToastService` for displaying toasts
|
|
23
24
|
- Customizable toast appearance and behavior
|
|
24
|
-
3. **
|
|
25
|
+
3. **Modal management**
|
|
26
|
+
- Strongly typed modal API
|
|
27
|
+
- Dynamic body content (string, template, or component)
|
|
28
|
+
- Configurable actions and lifecycle callbacks
|
|
29
|
+
4. **Standalone components and directives**
|
|
30
|
+
- Drop-in UI integrations for Tegel Angular
|
|
31
|
+
5. **Default Nginx config**
|
|
25
32
|
|
|
26
33
|
- Zero boilerplate - no Angular modules required
|
|
27
34
|
- Fully typed and configurable via DI
|
|
@@ -29,10 +36,12 @@ Provides simple wrappers for toast and modal (TBC) functionality using Angular 1
|
|
|
29
36
|
|
|
30
37
|
---
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# Table of Contents
|
|
33
42
|
|
|
34
|
-
1. [Installation](
|
|
35
|
-
2. [Environment Configuration Overview](
|
|
43
|
+
1. [Installation](#installation)
|
|
44
|
+
2. [Environment Configuration Overview](#environment-configuration-overview)
|
|
36
45
|
1. [Defining your schema with createEnvKit](#defining-your-schema-with-createenvkit)
|
|
37
46
|
2. [Defining Static Environments (Dev/Prod)](#defining-static-environments-devprod)
|
|
38
47
|
3. [Providing Runtime Configuration](#providing-runtime-configuration)
|
|
@@ -42,27 +51,39 @@ Provides simple wrappers for toast and modal (TBC) functionality using Angular 1
|
|
|
42
51
|
2. [`extract-env-vars.sh`](#extract-env-varssh)
|
|
43
52
|
3. [`nginx.conf`](#nginxconf)
|
|
44
53
|
4. [Example Docker Commands](#example-docker-commands)
|
|
45
|
-
3. [Toasts](
|
|
46
|
-
1. [Quick Start](
|
|
54
|
+
3. [Toasts](#toasts)
|
|
55
|
+
1. [Quick Start](#quick-start)
|
|
47
56
|
1. [Add Providers](#add-providers)
|
|
48
57
|
2. [Use in components](#use-in-components)
|
|
49
|
-
2. [Configuration Options](
|
|
50
|
-
3. [ToastService API](
|
|
51
|
-
1. [ToastService Properties](
|
|
52
|
-
2. [ToastService Methods](
|
|
53
|
-
3. [Toast Lifecycle Hooks](
|
|
54
|
-
4. [
|
|
55
|
-
1. [
|
|
58
|
+
2. [Toast Configuration Options](#toast-configuration-options)
|
|
59
|
+
3. [ToastService API](#toastservice-api)
|
|
60
|
+
1. [ToastService Properties](#toastservice-properties)
|
|
61
|
+
2. [ToastService Methods](#toastservice-methods)
|
|
62
|
+
3. [Toast Lifecycle Hooks](#toast-lifecycle-hooks)
|
|
63
|
+
4. [Modals](#modals)
|
|
64
|
+
1. [Quick Start](#quick-start-1)
|
|
65
|
+
1. [Add Providers](#add-providers-1)
|
|
66
|
+
2. [Use in components](#use-in-components-1)
|
|
67
|
+
2. [Modal Configuration Options](#modal-configuration-options)
|
|
68
|
+
3. [ModalService API](#modalservice-api)
|
|
69
|
+
1. [ModalService Properties](#modalservice-properties)
|
|
70
|
+
2. [ModalService Methods](#modalservice-methods)
|
|
71
|
+
3. [Modal Lifecycle Hooks](#modal-lifecycle-hooks)
|
|
72
|
+
5. [Components & Directives](#components--directives)
|
|
73
|
+
1. [Components](#components)
|
|
56
74
|
1. [Footer](#footer-component-tae-footer)
|
|
57
|
-
2. [Directives](
|
|
75
|
+
2. [Directives](#directives)
|
|
58
76
|
1. [Hard Refresh](#hard-refresh-directive-taehardrefresh)
|
|
59
|
-
|
|
77
|
+
2. [Barcode Scanner](#barcode-scanner-directive-taebarcodescanner)
|
|
78
|
+
6. [Appendix](#appendix)
|
|
60
79
|
1. [Dockerfile Example](#runtime-config-dockerfile-example)
|
|
61
|
-
|
|
80
|
+
7. [License](#license)
|
|
62
81
|
|
|
63
82
|
---
|
|
64
83
|
|
|
65
|
-
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Installation
|
|
66
87
|
|
|
67
88
|
```bash
|
|
68
89
|
npm install @scania-nl/tegel-angular-extensions @scania/tegel-angular-17 @traversable/zod zod
|
|
@@ -74,16 +95,18 @@ When creating an Angular project, the following dependencies already should have
|
|
|
74
95
|
|
|
75
96
|
```json
|
|
76
97
|
{
|
|
77
|
-
"@angular/common": "
|
|
78
|
-
"@angular/core": "
|
|
79
|
-
"@angular/router": "
|
|
98
|
+
"@angular/common": ">=19",
|
|
99
|
+
"@angular/core": ">=19",
|
|
100
|
+
"@angular/router": ">=19",
|
|
80
101
|
"rxjs": ">=7.8.0"
|
|
81
102
|
}
|
|
82
103
|
```
|
|
83
104
|
|
|
84
105
|
---
|
|
85
106
|
|
|
86
|
-
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# Environment Configuration Overview
|
|
87
110
|
|
|
88
111
|
The runtime-config system provides:
|
|
89
112
|
|
|
@@ -92,6 +115,8 @@ The runtime-config system provides:
|
|
|
92
115
|
- Runtime overrides via .env files (shell scripts included)
|
|
93
116
|
- Guaranteed config availability before app bootstrap
|
|
94
117
|
|
|
118
|
+
|
|
119
|
+
|
|
95
120
|
## Defining your schema with createEnvKit
|
|
96
121
|
|
|
97
122
|
Create a local file: `src/environments/environment-config.ts`
|
|
@@ -205,7 +230,7 @@ This setup involves several key steps:
|
|
|
205
230
|
- At application startup, the code loads `/env/runtime.env`, parses any overrides using Zod (via a deep-partial schema), and merges them with the static configuration.
|
|
206
231
|
- Required configuration keys are enforced **only** in production.
|
|
207
232
|
- The validated configuration is exposed through Angular DI using the `ENV_CONFIG` InjectionToken.
|
|
208
|
-
- The `environment` file is referenced directly here. Angular
|
|
233
|
+
- The `environment` file is referenced directly here. Angular's build process replaces the `development` environment with the `production` environment via file replacement based on the selected build configuration.
|
|
209
234
|
|
|
210
235
|
> The `/env/runtime.env` file must be generated by the container during startup.
|
|
211
236
|
> Shell script binaries to support this are included the package.
|
|
@@ -216,12 +241,16 @@ This setup involves several key steps:
|
|
|
216
241
|
|
|
217
242
|
This package ships with two lightweight shell scripts used to generate a runtime configuration file inside the container. They enable true runtime configurability without rebuilding the Angular image. Additionally, the package contains a default `nginx.conf` optimized for Angular application. The files are located in the `/docker` directory.
|
|
218
243
|
|
|
244
|
+
|
|
245
|
+
|
|
219
246
|
### `docker-entrypoint.sh`
|
|
220
247
|
|
|
221
248
|
- Entry point executed every time the container starts
|
|
222
249
|
- Calls the `extract-env-vars.sh` to generate a fresh `runtime.env`
|
|
223
250
|
- Lastly, executes the provided Dockerfile `CMD`
|
|
224
251
|
|
|
252
|
+
|
|
253
|
+
|
|
225
254
|
### `extract-env-vars.sh`
|
|
226
255
|
|
|
227
256
|
- Reads all container environment variables matching a prefix (default: `NG__`)
|
|
@@ -229,6 +258,8 @@ This package ships with two lightweight shell scripts used to generate a runtime
|
|
|
229
258
|
- Supports nested keys via ** (e.g., `NG**myFeature\_\_myThreshold`)
|
|
230
259
|
- Defaults output to `/usr/share/nginx/html/env/runtime.env`
|
|
231
260
|
|
|
261
|
+
|
|
262
|
+
|
|
232
263
|
### `nginx.conf`
|
|
233
264
|
|
|
234
265
|
A default Nginx configuration optimized for Angular applications. It provides:
|
|
@@ -238,6 +269,8 @@ A default Nginx configuration optimized for Angular applications. It provides:
|
|
|
238
269
|
- Gzip compression where supported
|
|
239
270
|
- Automatic fallback to `index.html` for client-side routing
|
|
240
271
|
|
|
272
|
+
|
|
273
|
+
|
|
241
274
|
### **Example Docker Commands**
|
|
242
275
|
|
|
243
276
|
```Dockerfile
|
|
@@ -253,21 +286,24 @@ CMD ["nginx", "-g", "daemon off;"]
|
|
|
253
286
|
|
|
254
287
|
For a complete Dockerfile example with the shipped `nginx.conf` config, refer to [Runtime Config Dockerfile Example](#runtime-config-dockerfile-example)
|
|
255
288
|
|
|
256
|
-
|
|
257
|
-
|
|
258
289
|
---
|
|
259
290
|
|
|
260
|
-
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
# Toasts
|
|
261
294
|
|
|
262
295
|
A lightweight, standalone toast system that integrates seamlessly with Tegel Angular. Provides configurable, signal-driven notifications for success, error, warning, and information messages.
|
|
263
296
|
|
|
264
|
-
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
## Quick Start
|
|
265
300
|
|
|
266
301
|
### Add Providers
|
|
267
302
|
|
|
268
303
|
In your `app.config.ts`, specify the provider with `provideToast()`:
|
|
269
304
|
|
|
270
305
|
```ts
|
|
306
|
+
// app.config.ts
|
|
271
307
|
import { provideToast } from '@scania-nl/tegel-angular-extensions';
|
|
272
308
|
|
|
273
309
|
export const appConfig: ApplicationConfig = {
|
|
@@ -286,6 +322,8 @@ export const appConfig: ApplicationConfig = {
|
|
|
286
322
|
|
|
287
323
|
> Note: The configuration is optional, all values shown above are the default settings.
|
|
288
324
|
|
|
325
|
+
|
|
326
|
+
|
|
289
327
|
### Use in components
|
|
290
328
|
|
|
291
329
|
In any standalone component:
|
|
@@ -313,7 +351,7 @@ export class MyToastDemoComponent {
|
|
|
313
351
|
|
|
314
352
|
|
|
315
353
|
|
|
316
|
-
##
|
|
354
|
+
## Toast Configuration Options
|
|
317
355
|
|
|
318
356
|
You can configure the default appearance and behavior of toasts by passing a `ToastConfig` object to `provideToast()` in your `app.config.ts`.
|
|
319
357
|
|
|
@@ -334,22 +372,22 @@ All options are optional. Defaults will be applied if values are not provided.
|
|
|
334
372
|
|
|
335
373
|
|
|
336
374
|
|
|
337
|
-
##
|
|
375
|
+
## ToastService API
|
|
338
376
|
|
|
339
377
|
The `ToastService` provides a signal-based API to create, manage, and dismiss toast notifications in Angular standalone apps. It is automatically available after registering `provideToast()` in your `app.config.ts`.
|
|
340
378
|
|
|
341
|
-
|
|
379
|
+
|
|
342
380
|
|
|
343
|
-
###
|
|
381
|
+
### ToastService Properties
|
|
344
382
|
|
|
345
383
|
| Property | Type | Description |
|
|
346
384
|
| -------------- | ----------------- | ----------------------------------------------------- |
|
|
347
385
|
| `toasts` | `Signal<Toast[]>` | Read-only list of all toasts (including closed) |
|
|
348
386
|
| `activeToasts` | `Signal<Toast[]>` | List of currently active toasts (`Open` or `Closing`) |
|
|
349
387
|
|
|
350
|
-
|
|
388
|
+
|
|
351
389
|
|
|
352
|
-
###
|
|
390
|
+
### ToastService Methods
|
|
353
391
|
|
|
354
392
|
#### `create(toastOptions: Partial<ToastOptions>): number`
|
|
355
393
|
|
|
@@ -423,7 +461,9 @@ Force-removes all toasts instantly (no animations).
|
|
|
423
461
|
|
|
424
462
|
---
|
|
425
463
|
|
|
426
|
-
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
### Toast Lifecycle Hooks
|
|
427
467
|
|
|
428
468
|
Each toast supports optional lifecycle callbacks:
|
|
429
469
|
|
|
@@ -447,12 +487,328 @@ toastService.success({
|
|
|
447
487
|
|
|
448
488
|
|
|
449
489
|
|
|
450
|
-
#
|
|
490
|
+
# Modals
|
|
491
|
+
|
|
492
|
+
Standalone modal service + host for Tegel's `tds-modal`, with strongly‑typed options and dynamic body support.
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
## Quick Start
|
|
497
|
+
|
|
498
|
+
### Add Providers
|
|
499
|
+
|
|
500
|
+
In your `app.config.ts`, specify the provider with `provideModal()`:
|
|
501
|
+
|
|
502
|
+
```ts
|
|
503
|
+
// app.config.ts
|
|
504
|
+
import { provideModal } from '@scania-nl/tegel-angular-extensions';
|
|
505
|
+
|
|
506
|
+
export const appConfig: ApplicationConfig = {
|
|
507
|
+
providers: [
|
|
508
|
+
provideModal({
|
|
509
|
+
size: 'md', // Modal size
|
|
510
|
+
actionsPosition: 'static', // Actions slot behavior
|
|
511
|
+
prevent: false, // Prevent overlay click from closing the modal
|
|
512
|
+
closable: true, // Show or hide the close [X] button
|
|
513
|
+
alertDialog: 'dialog', // ARIA role of the modal component
|
|
514
|
+
lazy: false, // Render body only while open
|
|
515
|
+
startOpen: true, // Open modal on creation
|
|
516
|
+
removeOnClose: true, // Remove modal from DOM when closed
|
|
517
|
+
}),
|
|
518
|
+
],
|
|
519
|
+
};
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
Most of these options are inherited from `tds-modal`.
|
|
523
|
+
|
|
524
|
+
> Note: The configuration is optional, all values shown above are the default settings.
|
|
525
|
+
|
|
526
|
+
### Use in components
|
|
527
|
+
|
|
528
|
+
`create()` returns a `ModalRef` that can control the modal instance.
|
|
529
|
+
|
|
530
|
+
```ts
|
|
531
|
+
import { inject } from '@angular/core';
|
|
532
|
+
import { ModalService } from '@scania-nl/tegel-angular-extensions';
|
|
533
|
+
|
|
534
|
+
export class MyComponent {
|
|
535
|
+
private readonly modalService = inject(ModalService);
|
|
536
|
+
|
|
537
|
+
openModal() {
|
|
538
|
+
const ref = this.modalService.create({
|
|
539
|
+
header: 'Demo Modal',
|
|
540
|
+
body: 'Hello from modal',
|
|
541
|
+
startOpen: false,
|
|
542
|
+
removeOnClose: false,
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
ref.open(); // Opens the modal
|
|
546
|
+
ref.close(); // Closes (hides) the modal
|
|
547
|
+
ref.remove(); // Removes the modal from the DOM
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
You get a `ModalRef` back from `create()`, which you can use to control that specific modal instance (`open()`, `close()`, `remove()`).
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
## Modal Configuration Options
|
|
559
|
+
|
|
560
|
+
| Option | Type | Default | Description |
|
|
561
|
+
| ----------------- | ------------------------------ | -------- | --------------------------- |
|
|
562
|
+
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | `md` | Modal size |
|
|
563
|
+
| `actionsPosition` | `'static' \| 'sticky'` | `static` | Actions slot behavior |
|
|
564
|
+
| `prevent` | `boolean` | `false` | Prevent overlay close |
|
|
565
|
+
| `closable` | `boolean` | `true` | Show/hide close button |
|
|
566
|
+
| `alertDialog` | `'dialog' \| 'alertdialog'` | `dialog` | ARIA role |
|
|
567
|
+
| `lazy` | `boolean` | `false` | Render body only while open |
|
|
568
|
+
| `startOpen` | `boolean` | `true` | Open immediately on create |
|
|
569
|
+
| `removeOnClose` | `boolean` | `true` | Remove modal after close |
|
|
570
|
+
|
|
571
|
+
> Be aware that when `removeOnClose` is set to `false`, the modal content is hidden but **not destroyed**. If your body uses a component with active subscriptions, timers, or sockets, they will continue to run while the modal is hidden. Consider `removeOnClose: true` for component bodies if you want their resources to be disposed on close.
|
|
572
|
+
|
|
573
|
+
---
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
### Per-modal options (create)
|
|
578
|
+
|
|
579
|
+
These options are passed to `modalService.create()` and override defaults from `provideModal()` on a per‑modal basis. For shared defaults like `size`, `actionsPosition`, `prevent`, `closable`, `alertDialog`, `lazy`, `startOpen`, and `removeOnClose`, see [Modal Configuration Options](#modal-configuration-options) above.
|
|
580
|
+
|
|
581
|
+
| Option | Type | Description |
|
|
582
|
+
| ------------- | ------------------------------------------------------------------ | ---------------------------------------------------- |
|
|
583
|
+
| `header` | `string \| TemplateRef<unknown>` | Modal header text or template |
|
|
584
|
+
| `body` | `string \| TemplateRef<unknown> \| { component, inputs, outputs }` | Modal body content (string, template, or component) |
|
|
585
|
+
| `buttons` | `ModalButton[]` | Action buttons to render in the actions slot |
|
|
586
|
+
| `selector` | `string` | CSS selector for focus return element |
|
|
587
|
+
| `referenceEl` | `HTMLElement` | Element to return focus to (preferred over selector) |
|
|
588
|
+
| `onClosed` | `() => void \| Promise<void>` | Called when the modal is closed |
|
|
589
|
+
| `onRemoved` | `() => void \| Promise<void>` | Called after the modal is removed |
|
|
590
|
+
|
|
591
|
+
> Note: If you want focus to return to the element that opened the modal, pass either `selector` or `referenceEl` when creating the modal. This avoids Tegel's "Missing focus origin" warning.
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
### Body content options
|
|
598
|
+
|
|
599
|
+
The modal body can be provided as a simple string, a `TemplateRef`, or a component descriptor.
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
#### 1) String body
|
|
604
|
+
|
|
605
|
+
```ts
|
|
606
|
+
this.modalService.create({
|
|
607
|
+
header: 'Simple',
|
|
608
|
+
body: 'This is a simple modal body',
|
|
609
|
+
});
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
#### 2) TemplateRef body
|
|
615
|
+
|
|
616
|
+
```html
|
|
617
|
+
<ng-template #bodyTpl>
|
|
618
|
+
<strong>Template body</strong>
|
|
619
|
+
</ng-template>
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
```ts
|
|
623
|
+
const bodyTpl = viewChild<TemplateRef<unknown>>('bodyTpl');
|
|
624
|
+
this.modalService.create({
|
|
625
|
+
header: 'Template',
|
|
626
|
+
body: bodyTpl(),
|
|
627
|
+
});
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
#### 3) Component body (with inputs/outputs)
|
|
633
|
+
|
|
634
|
+
When you pass a component as the modal body, the `inputs` and `outputs` objects are fully typed. This means you get IntelliSense for signal inputs/outputs, and any `input.required(...)` fields are enforced at compile time (missing required inputs will fail the build).
|
|
635
|
+
|
|
636
|
+
```ts
|
|
637
|
+
export class ExampleComponent {
|
|
638
|
+
readonly requiredField = input.required<string>();
|
|
639
|
+
readonly optionalField = input<string>();
|
|
640
|
+
readonly outputField = output<string>();
|
|
641
|
+
}
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
const ref = this.modalService.create({
|
|
646
|
+
header: 'Example',
|
|
647
|
+
body: {
|
|
648
|
+
component: ExampleComponent,
|
|
649
|
+
inputs: {
|
|
650
|
+
requiredField: 'Required',
|
|
651
|
+
// optionalField: 'Optional'
|
|
652
|
+
},
|
|
653
|
+
outputs: {
|
|
654
|
+
outputField: (value: string) => {
|
|
655
|
+
console.log('Value:', value);
|
|
656
|
+
ref.close();
|
|
657
|
+
}
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
});
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
### Action buttons
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
this.modalService.create({
|
|
669
|
+
header: 'Confirm',
|
|
670
|
+
body: 'Are you sure?',
|
|
671
|
+
buttons: [
|
|
672
|
+
{ text: 'OK', variant: 'primary', onClick: async () => console.log('OK') },
|
|
673
|
+
{ text: 'Cancel', variant: 'secondary', dismiss: true },
|
|
674
|
+
],
|
|
675
|
+
startOpen: true,
|
|
676
|
+
});
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
- `dismiss`: true adds `data-dismiss-modal` for Tegel's built‑in close behavior.
|
|
680
|
+
- `onClick` supports sync or async handlers.
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
#### ModalButton options
|
|
685
|
+
|
|
686
|
+
Modal action buttons map directly to Tegel's `tds-button` configuration. The following options are supported:
|
|
687
|
+
|
|
688
|
+
| Option | Type | Description |
|
|
689
|
+
| ---------- | ------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
690
|
+
| `text` | `string` | Button label text |
|
|
691
|
+
| `variant` | `'primary' \| 'secondary' \| 'success' \| 'danger'` | Visual variant |
|
|
692
|
+
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | Button size |
|
|
693
|
+
| `disabled` | `boolean` | Disable the button |
|
|
694
|
+
| `dismiss` | `boolean` | Adds `data-dismiss-modal` to trigger Tegel's close behavior |
|
|
695
|
+
| `onClick` | `() => void \| Promise<void>` | Optional click handler (sync or async) |
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
## ModalService API
|
|
702
|
+
|
|
703
|
+
The `ModalService` provides a signal-based API to create, manage, and dismiss modal instances. It is available after registering `provideModal()` in your `app.config.ts`.
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
### ModalService Properties
|
|
708
|
+
|
|
709
|
+
| Property | Type | Description |
|
|
710
|
+
| -------- | ---------------------------- | -------------------------------------------------- |
|
|
711
|
+
| `modals` | `Signal<Map<string, Modal>>` | Read-only map of all registered modals keyed by id |
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
### ModalService Methods
|
|
716
|
+
|
|
717
|
+
#### `create<T>(options?: ModalOptions<T>): ModalRef`
|
|
718
|
+
|
|
719
|
+
Creates and registers a new modal. Returns a `ModalRef` for controlling that instance.
|
|
720
|
+
|
|
721
|
+
```ts
|
|
722
|
+
const ref = modalService.create({
|
|
723
|
+
header: 'Hello',
|
|
724
|
+
body: 'Modal content',
|
|
725
|
+
startOpen: false,
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
ref.open();
|
|
729
|
+
ref.close();
|
|
730
|
+
ref.remove();
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
#### ModalRef
|
|
736
|
+
|
|
737
|
+
`create()` returns a `ModalRef` with `open()`, `close()`, and `remove()` methods to control that specific modal instance.
|
|
738
|
+
|
|
739
|
+
#### `open(id: string): void`
|
|
740
|
+
|
|
741
|
+
Opens an existing modal by id.
|
|
742
|
+
|
|
743
|
+
Example:
|
|
744
|
+
|
|
745
|
+
```ts
|
|
746
|
+
const ref = modalService.create({
|
|
747
|
+
header: 'Example',
|
|
748
|
+
body: 'Hello',
|
|
749
|
+
startOpen: false,
|
|
750
|
+
});
|
|
751
|
+
modalService.open(ref.id); // Equivalent to ref.open()
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
#### `close(id: string): void`
|
|
757
|
+
|
|
758
|
+
Closes (hides) a modal by id. If `removeOnClose` is `true`, it is removed from the DOM after closing.
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
#### `remove(id: string): void`
|
|
763
|
+
|
|
764
|
+
Removes a modal from the registry/DOM. If the modal is open, it is closed first.
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
#### `closeAll(): void`
|
|
769
|
+
|
|
770
|
+
Closes all registered modals.
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
#### `removeAll(): void`
|
|
775
|
+
|
|
776
|
+
Removes all registered modals.
|
|
777
|
+
|
|
778
|
+
---
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
### Modal Lifecycle Hooks
|
|
783
|
+
|
|
784
|
+
Each modal supports optional lifecycle callbacks:
|
|
785
|
+
|
|
786
|
+
| Callback | Description |
|
|
787
|
+
| ------------- | ------------------------------------------------------- |
|
|
788
|
+
| `onClosed()` | Called when the modal is closed |
|
|
789
|
+
| `onRemoved()` | Called after the modal is removed from the registry/DOM |
|
|
790
|
+
|
|
791
|
+
Example:
|
|
792
|
+
|
|
793
|
+
```ts
|
|
794
|
+
modalService.create({
|
|
795
|
+
header: 'Example',
|
|
796
|
+
body: 'Hello',
|
|
797
|
+
onClosed: () => console.log('Modal closed'),
|
|
798
|
+
onRemoved: () => console.log('Modal removed'),
|
|
799
|
+
});
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
---
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
# Components & Directives
|
|
451
807
|
|
|
452
808
|
This library includes a set of standalone UI components and utility directives, all prefixed with **`tae`**, designed to extend and complement the Tegel Angular ecosystem. Each piece is lightweight, fully typed, and easy to import into any Angular 19+ application.
|
|
453
809
|
|
|
454
810
|
|
|
455
|
-
##
|
|
811
|
+
## Components
|
|
456
812
|
|
|
457
813
|
### Footer Component (`tae-footer`)
|
|
458
814
|
|
|
@@ -478,7 +834,7 @@ This makes it ideal for full-viewport layouts that benefit from space efficiency
|
|
|
478
834
|
|
|
479
835
|
|
|
480
836
|
|
|
481
|
-
##
|
|
837
|
+
## Directives
|
|
482
838
|
|
|
483
839
|
### Hard Refresh Directive (`taeHardRefresh`)
|
|
484
840
|
|
|
@@ -488,10 +844,10 @@ This is especially useful for hard-reloading tablet or mobile applications which
|
|
|
488
844
|
|
|
489
845
|
**Inputs:**
|
|
490
846
|
|
|
491
|
-
|
|
|
492
|
-
|
|
|
493
|
-
| clicksRequired | number | 3
|
|
494
|
-
| clickWindowMs | number | 500
|
|
847
|
+
| Property | Type | Default | Description |
|
|
848
|
+
| ---------------- | -------- | ------- | ---------------------------------------------------------------------- |
|
|
849
|
+
| `clicksRequired` | `number` | `3` | Number of clicks required within the window to trigger a hard refresh. |
|
|
850
|
+
| `clickWindowMs` | `number` | `500` | Time window in milliseconds between two subsequent clicks. |
|
|
495
851
|
|
|
496
852
|
**Example:**
|
|
497
853
|
|
|
@@ -505,6 +861,40 @@ This is especially useful for hard-reloading tablet or mobile applications which
|
|
|
505
861
|
</tds-header-brand-symbol>
|
|
506
862
|
```
|
|
507
863
|
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
### Barcode Scanner Directive (`taeBarcodeScanner`)
|
|
867
|
+
|
|
868
|
+
The `BarcodeScannerDirective` enables global barcode scanning by listening for rapid character input sequences (typically from a hardware scanner) that terminate with a specific key (default is `Enter`).
|
|
869
|
+
|
|
870
|
+
It operates outside of Angular's zone to prevent unnecessary change detection cycles on every keypress and includes built-in filtering to ignore modifier keys like `Shift`, `Ctrl`, or `Alt`, ensuring only the actual barcode data is captured.
|
|
871
|
+
|
|
872
|
+
**Inputs:**
|
|
873
|
+
|
|
874
|
+
| Input | Type | Default | Description |
|
|
875
|
+
| --------------- | -------- | --------- | ------------------------------------------------------------------ |
|
|
876
|
+
| `inputWindowMs` | `number` | `100` | Max time allowed between consecutive keypresses before discarding. |
|
|
877
|
+
| `terminatorKey` | `string` | `'Enter'` | The key that signals the end of a barcode sequence. |
|
|
878
|
+
|
|
879
|
+
**Outputs:**
|
|
880
|
+
|
|
881
|
+
| Output | Type | Description |
|
|
882
|
+
| ---------------- | -------- | ----------------------------------------------------------- |
|
|
883
|
+
| `barcodeScanned` | `string` | **Required**. Emits the full barcode string once completed. |
|
|
884
|
+
|
|
885
|
+
**Example:**
|
|
886
|
+
|
|
887
|
+
```html
|
|
888
|
+
<ng-container
|
|
889
|
+
taeBarcodeScanner
|
|
890
|
+
(barcodeScanned)="handleScan($event)"
|
|
891
|
+
[inputWindowMs]="100"
|
|
892
|
+
terminatorKey="Enter"
|
|
893
|
+
>
|
|
894
|
+
<p>Scanner is active. Please scan a barcode...</p>
|
|
895
|
+
</ng-container>
|
|
896
|
+
```
|
|
897
|
+
|
|
508
898
|
---
|
|
509
899
|
|
|
510
900
|
|
|
@@ -561,7 +951,9 @@ CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]
|
|
|
561
951
|
|
|
562
952
|
---
|
|
563
953
|
|
|
564
|
-
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
# License
|
|
565
957
|
|
|
566
958
|
Copyright 2025 Scania CV AB.
|
|
567
959
|
|