@aegov/designsystem-angular 0.2.25 → 4.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/README.md +61 -42
- package/fesm2022/aegov-designsystem-angular-provider.mjs +36 -0
- package/fesm2022/aegov-designsystem-angular-provider.mjs.map +1 -0
- package/fesm2022/aegov-designsystem-angular.mjs +4519 -5439
- package/fesm2022/aegov-designsystem-angular.mjs.map +1 -1
- package/package.json +6 -2
- package/types/aegov-designsystem-angular-provider.d.ts +23 -0
- package/types/aegov-designsystem-angular.d.ts +3224 -2988
package/README.md
CHANGED
|
@@ -1,64 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AEGOV Design System for Angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular wrappers for the UAE Government Design System web components ([`@aegov/designsystem`](https://www.npmjs.com/package/@aegov/designsystem)): one standalone component per element, with typed inputs and outputs. Supports Angular 18 and later.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
5
|
+
## Installation
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
|
|
8
|
+
npm install @aegov/designsystem @aegov/designsystem-angular
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
**Tailwind CSS v4 is required in your project.** Add three imports to `src/styles.css`, in this order:
|
|
14
12
|
|
|
15
|
-
```
|
|
16
|
-
|
|
13
|
+
```css
|
|
14
|
+
@import "tailwindcss";
|
|
15
|
+
@import "@aegov/designsystem/base";
|
|
16
|
+
@import "@aegov/designsystem/theme";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Import the wrappers a component uses. Each wrapper registers its own element, so there is nothing else to set up:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Component } from '@angular/core';
|
|
25
|
+
import { AegovButton, AegovInput } from '@aegov/designsystem-angular';
|
|
26
|
+
|
|
27
|
+
@Component({
|
|
28
|
+
selector: 'app-signup',
|
|
29
|
+
imports: [AegovButton, AegovInput],
|
|
30
|
+
template: `
|
|
31
|
+
<aegov-input fieldId="email" type="email" name="email" isRequired />
|
|
32
|
+
<aegov-button variant="primary" size="lg" (aegovButtonClick)="submit()">
|
|
33
|
+
Submit application
|
|
34
|
+
</aegov-button>
|
|
35
|
+
`,
|
|
36
|
+
})
|
|
37
|
+
export class SignupComponent {
|
|
38
|
+
submit() {}
|
|
39
|
+
}
|
|
25
40
|
```
|
|
26
41
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Publishing the Library
|
|
30
|
-
|
|
31
|
-
Once the project is built, you can publish your library by following these steps:
|
|
42
|
+
Inputs use the camelCase property names and are type-checked under `strictTemplates`. Boolean and number inputs also accept static attributes: `isRequired`, `isDisabled="false"`, `pages="5"`. Events are outputs named after the DOM event, such as `(aegovButtonClick)`.
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
### Global setup
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
cd dist/component-library
|
|
37
|
-
```
|
|
46
|
+
Add `provideDesignSystem()` to the application's providers to run the design system's global script, which creates the toast live region and `window.aegovToast`. It also registers every `aegov-*` element, including ones you render without importing their wrapper. It loads the design system's lazy loader when the application starts. It is exported only from the `@aegov/designsystem-angular/provider` entry point, so an application that doesn't use it ships none of the loader's files.
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
```ts
|
|
49
|
+
// app.config.ts
|
|
50
|
+
import { ApplicationConfig } from '@angular/core';
|
|
51
|
+
import { provideDesignSystem } from '@aegov/designsystem-angular/provider';
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
export const appConfig: ApplicationConfig = {
|
|
54
|
+
providers: [
|
|
55
|
+
// ...your existing providers
|
|
56
|
+
provideDesignSystem(),
|
|
57
|
+
],
|
|
58
|
+
};
|
|
50
59
|
```
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
### NgModule applications
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
`DesignSystemModule` re-exports every wrapper and has no providers. Add `provideDesignSystem()` to the root module for the global setup:
|
|
55
64
|
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
```ts
|
|
66
|
+
import { NgModule } from '@angular/core';
|
|
67
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
68
|
+
import { DesignSystemModule } from '@aegov/designsystem-angular';
|
|
69
|
+
import { provideDesignSystem } from '@aegov/designsystem-angular/provider';
|
|
70
|
+
import { AppComponent } from './app.component';
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
@NgModule({
|
|
73
|
+
declarations: [AppComponent],
|
|
74
|
+
imports: [BrowserModule, DesignSystemModule],
|
|
75
|
+
providers: [provideDesignSystem()],
|
|
76
|
+
bootstrap: [AppComponent],
|
|
77
|
+
})
|
|
78
|
+
export class AppModule {}
|
|
79
|
+
```
|
|
61
80
|
|
|
62
|
-
##
|
|
81
|
+
## Documentation
|
|
63
82
|
|
|
64
|
-
|
|
83
|
+
The full guide, including server-side rendering and every component's API, is *Using with Angular* on the documentation site: [designsystem.gov.ae](https://designsystem.gov.ae).
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { makeEnvironmentProviders, APP_INITIALIZER } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Registers every `aegov-*` element through the lazy loader and runs the design
|
|
5
|
+
* system's global script (toast live region, `window.aegovToast`).
|
|
6
|
+
*
|
|
7
|
+
* Add it to the application's providers (`bootstrapApplication`, or the root
|
|
8
|
+
* NgModule's `providers`). It must be an application-level provider: Angular only
|
|
9
|
+
* runs `APP_INITIALIZER` from the root environment injector.
|
|
10
|
+
*
|
|
11
|
+
* The loader is imported dynamically so apps that never call this function don't
|
|
12
|
+
* bundle it (the loader is a side-effect module). It lives in this secondary entry
|
|
13
|
+
* point because a bundler emits the loader's lazy chunks for any `import()` in a
|
|
14
|
+
* module it includes, even inside a function the app never calls: an app that
|
|
15
|
+
* imports only wrappers from `@aegov/designsystem-angular` would otherwise ship
|
|
16
|
+
* ~70 unused chunk files.
|
|
17
|
+
*
|
|
18
|
+
* This is what `provideAppInitializer()` expands to; the token form is used so the
|
|
19
|
+
* package keeps working on Angular 18, which has no `provideAppInitializer()`.
|
|
20
|
+
*/
|
|
21
|
+
function provideDesignSystem() {
|
|
22
|
+
return makeEnvironmentProviders([
|
|
23
|
+
{
|
|
24
|
+
provide: APP_INITIALIZER,
|
|
25
|
+
multi: true,
|
|
26
|
+
useValue: () => import('@aegov/designsystem/loader').then((loader) => loader.defineCustomElements()),
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generated bundle index. Do not edit.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export { provideDesignSystem };
|
|
36
|
+
//# sourceMappingURL=aegov-designsystem-angular-provider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aegov-designsystem-angular-provider.mjs","sources":["../../../projects/component-library/provider/public-api.ts","../../../projects/component-library/provider/aegov-designsystem-angular-provider.ts"],"sourcesContent":["import { APP_INITIALIZER, EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\n/**\n * Registers every `aegov-*` element through the lazy loader and runs the design\n * system's global script (toast live region, `window.aegovToast`).\n *\n * Add it to the application's providers (`bootstrapApplication`, or the root\n * NgModule's `providers`). It must be an application-level provider: Angular only\n * runs `APP_INITIALIZER` from the root environment injector.\n *\n * The loader is imported dynamically so apps that never call this function don't\n * bundle it (the loader is a side-effect module). It lives in this secondary entry\n * point because a bundler emits the loader's lazy chunks for any `import()` in a\n * module it includes, even inside a function the app never calls: an app that\n * imports only wrappers from `@aegov/designsystem-angular` would otherwise ship\n * ~70 unused chunk files.\n *\n * This is what `provideAppInitializer()` expands to; the token form is used so the\n * package keeps working on Angular 18, which has no `provideAppInitializer()`.\n */\nexport function provideDesignSystem(): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: APP_INITIALIZER,\n multi: true,\n useValue: () => import('@aegov/designsystem/loader').then((loader) => loader.defineCustomElements()),\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;AAiBG;SACa,mBAAmB,GAAA;AACjC,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA;AACE,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,MAAM,OAAO,4BAA4B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,oBAAoB,EAAE,CAAC;AACrG,SAAA;AACF,KAAA,CAAC;AACJ;;AC5BA;;AAEG;;;;"}
|