@mndw/ui-angular 0.1.2 → 0.1.4

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 ADDED
@@ -0,0 +1,62 @@
1
+ # @mndw/ui-angular
2
+
3
+ Angular table cell adapters for mndw UI.
4
+
5
+ ## Part of mndw
6
+
7
+ mndw is a modular web dashboard for Keenetic/Netcraze routers. Everything in it is a plugin: a dashboard widget or a full page. See [the plugin author site](https://eralde.github.io/mndw/).
8
+
9
+ ## Install
10
+
11
+ `mndw create` adds this adapter to `dependencies` for Angular plugins. To add it by hand, install it in the plugin project; peer dependency: `@angular/core >=21.0.0`.
12
+
13
+ ```sh
14
+ npm i @mndw/ui-angular
15
+ ```
16
+
17
+ ## Use
18
+
19
+ `@mndw/ui-angular` exports `MndwTableDirective`, `MndwCellDirective`, and `angularCell` for adapting Angular components or templates to the table cell lifecycle:
20
+
21
+ ```ts
22
+ import {MndwCellDirective, MndwTableDirective} from '@mndw/ui-angular';
23
+ import {CUSTOM_ELEMENTS_SCHEMA, Component} from '@angular/core';
24
+ import {type Column, column} from '@mndw/ui';
25
+
26
+ interface TableRow {
27
+ id: string;
28
+ name: string;
29
+ }
30
+
31
+ function isTableRow(value: unknown): value is TableRow {
32
+ return typeof value === 'object' && value !== null && 'id' in value && 'name' in value
33
+ && typeof value.id === 'string' && typeof value.name === 'string';
34
+ }
35
+
36
+ @Component({
37
+ standalone: true,
38
+ imports: [MndwTableDirective, MndwCellDirective],
39
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
40
+ template: `
41
+ <mndw-table [columns]="columns" [rows]="rows">
42
+ <ng-template mndwCell="name" let-row>
43
+ <span>{{ $any(row).name }}</span>
44
+ </ng-template>
45
+ </mndw-table>
46
+ `,
47
+ })
48
+ export class TableComponent {
49
+ protected readonly rows: readonly TableRow[] = [{id: 'first', name: 'Alpha'}];
50
+ protected readonly columns: Column<unknown>[] = [
51
+ column<unknown>()({
52
+ id: 'name',
53
+ label: 'Name',
54
+ accessor: (row) => isTableRow(row) ? row.name : '',
55
+ }),
56
+ ];
57
+ }
58
+ ```
59
+
60
+ ## Read on
61
+
62
+ See the [table adapter guide](https://eralde.github.io/mndw/guides/ui-components#angular) and [UI components overview](https://eralde.github.io/mndw/ui/).
package/dist/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @mndw/ui-angular
2
+
3
+ Angular table cell adapters for mndw UI.
4
+
5
+ ## Part of mndw
6
+
7
+ mndw is a modular web dashboard for Keenetic/Netcraze routers. Everything in it is a plugin: a dashboard widget or a full page. See [the plugin author site](https://eralde.github.io/mndw/).
8
+
9
+ ## Install
10
+
11
+ `mndw create` adds this adapter to `dependencies` for Angular plugins. To add it by hand, install it in the plugin project; peer dependency: `@angular/core >=21.0.0`.
12
+
13
+ ```sh
14
+ npm i @mndw/ui-angular
15
+ ```
16
+
17
+ ## Use
18
+
19
+ `@mndw/ui-angular` exports `MndwTableDirective`, `MndwCellDirective`, and `angularCell` for adapting Angular components or templates to the table cell lifecycle:
20
+
21
+ ```ts
22
+ import {MndwCellDirective, MndwTableDirective} from '@mndw/ui-angular';
23
+ import {CUSTOM_ELEMENTS_SCHEMA, Component} from '@angular/core';
24
+ import {type Column, column} from '@mndw/ui';
25
+
26
+ interface TableRow {
27
+ id: string;
28
+ name: string;
29
+ }
30
+
31
+ function isTableRow(value: unknown): value is TableRow {
32
+ return typeof value === 'object' && value !== null && 'id' in value && 'name' in value
33
+ && typeof value.id === 'string' && typeof value.name === 'string';
34
+ }
35
+
36
+ @Component({
37
+ standalone: true,
38
+ imports: [MndwTableDirective, MndwCellDirective],
39
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
40
+ template: `
41
+ <mndw-table [columns]="columns" [rows]="rows">
42
+ <ng-template mndwCell="name" let-row>
43
+ <span>{{ $any(row).name }}</span>
44
+ </ng-template>
45
+ </mndw-table>
46
+ `,
47
+ })
48
+ export class TableComponent {
49
+ protected readonly rows: readonly TableRow[] = [{id: 'first', name: 'Alpha'}];
50
+ protected readonly columns: Column<unknown>[] = [
51
+ column<unknown>()({
52
+ id: 'name',
53
+ label: 'Name',
54
+ accessor: (row) => isTableRow(row) ? row.name : '',
55
+ }),
56
+ ];
57
+ }
58
+ ```
59
+
60
+ ## Read on
61
+
62
+ See the [table adapter guide](https://eralde.github.io/mndw/guides/ui-components#angular) and [UI components overview](https://eralde.github.io/mndw/ui/).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mndw/ui-angular",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "homepage": "https://eralde.github.io/mndw/",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@mndw/ui": "^0.1.2"
26
+ "@mndw/ui": "^0.1.4"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@angular/core": ">=21.0.0"
@@ -41,6 +41,7 @@
41
41
  "vitest": "^3.2.7",
42
42
  "zone.js": "^0.15.1"
43
43
  },
44
+ "description": "Angular table cell adapters for mndw UI.",
44
45
  "scripts": {
45
46
  "build": "ng-packagr -p ng-package.json -c tsconfig.lib.json",
46
47
  "test": "vitest run",