@wc-bindable/angular 0.7.0 → 0.7.1
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 +64 -60
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
# @wc-bindable/angular
|
|
2
|
-
|
|
3
|
-
Angular adapter for the **wc-bindable** protocol.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @wc-bindable/angular @angular/core
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { Component } from "@angular/core";
|
|
15
|
-
import { WcBindableDirective } from "@wc-bindable/angular";
|
|
16
|
-
|
|
17
|
-
@Component({
|
|
18
|
-
selector: "app-root",
|
|
19
|
-
standalone: true,
|
|
20
|
-
imports: [WcBindableDirective],
|
|
21
|
-
template: `
|
|
22
|
-
<my-input wcBindable (wcBindableChange)="onUpdate($event)" />
|
|
23
|
-
<p>Current value: {{ currentValue }}</p>
|
|
24
|
-
`,
|
|
25
|
-
})
|
|
26
|
-
export class AppComponent {
|
|
27
|
-
currentValue = "";
|
|
28
|
-
|
|
29
|
-
onUpdate(event: { name: string; value: unknown }) {
|
|
30
|
-
if (event.name === "value") {
|
|
31
|
-
this.currentValue = event.value as string;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## API
|
|
38
|
-
|
|
39
|
-
### `WcBindableDirective`
|
|
40
|
-
|
|
41
|
-
A standalone directive applied via the `wcBindable` attribute selector.
|
|
42
|
-
|
|
43
|
-
| Output | Type | Description |
|
|
44
|
-
|---|---|---|
|
|
45
|
-
| `wcBindableChange` | `{ name: string; value: unknown }` | Emitted whenever a bindable property changes |
|
|
46
|
-
|
|
47
|
-
- Binds on `ngOnInit` and cleans up on `ngOnDestroy`.
|
|
48
|
-
- If the element does not implement `wc-bindable`, the directive is a no-op.
|
|
49
|
-
|
|
50
|
-
## Design Notes
|
|
51
|
-
|
|
52
|
-
This directive uses `@Output()` with `EventEmitter` rather than the newer `output()` function API (Angular 17.3+). Reasons:
|
|
53
|
-
|
|
54
|
-
- **Broader compatibility** — works with Angular 17+ (matching the `peerDependencies` requirement).
|
|
55
|
-
- **Testability** — `@Output()` does not require an injection context, so the directive can be instantiated directly in unit tests.
|
|
56
|
-
- **Stability** — `EventEmitter` is a long-established, stable Angular API with no deprecation planned.
|
|
57
|
-
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
# @wc-bindable/angular
|
|
2
|
+
|
|
3
|
+
Angular adapter for the **wc-bindable** protocol.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wc-bindable/angular @angular/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component } from "@angular/core";
|
|
15
|
+
import { WcBindableDirective } from "@wc-bindable/angular";
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: "app-root",
|
|
19
|
+
standalone: true,
|
|
20
|
+
imports: [WcBindableDirective],
|
|
21
|
+
template: `
|
|
22
|
+
<my-input wcBindable (wcBindableChange)="onUpdate($event)" />
|
|
23
|
+
<p>Current value: {{ currentValue }}</p>
|
|
24
|
+
`,
|
|
25
|
+
})
|
|
26
|
+
export class AppComponent {
|
|
27
|
+
currentValue = "";
|
|
28
|
+
|
|
29
|
+
onUpdate(event: { name: string; value: unknown }) {
|
|
30
|
+
if (event.name === "value") {
|
|
31
|
+
this.currentValue = event.value as string;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### `WcBindableDirective`
|
|
40
|
+
|
|
41
|
+
A standalone directive applied via the `wcBindable` attribute selector.
|
|
42
|
+
|
|
43
|
+
| Output | Type | Description |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `wcBindableChange` | `{ name: string; value: unknown }` | Emitted whenever a bindable property changes |
|
|
46
|
+
|
|
47
|
+
- Binds on `ngOnInit` and cleans up on `ngOnDestroy`.
|
|
48
|
+
- If the element does not implement `wc-bindable`, the directive is a no-op.
|
|
49
|
+
|
|
50
|
+
## Design Notes
|
|
51
|
+
|
|
52
|
+
This directive uses `@Output()` with `EventEmitter` rather than the newer `output()` function API (Angular 17.3+). Reasons:
|
|
53
|
+
|
|
54
|
+
- **Broader compatibility** — works with Angular 17+ (matching the `peerDependencies` requirement).
|
|
55
|
+
- **Testability** — `@Output()` does not require an injection context, so the directive can be instantiated directly in unit tests.
|
|
56
|
+
- **Stability** — `EventEmitter` is a long-established, stable Angular API with no deprecation planned.
|
|
57
|
+
|
|
58
|
+
## Specification
|
|
59
|
+
|
|
60
|
+
The protocol contract this adapter implements lives in [SPEC.md](../../SPEC.md); the optional input/command invocation surface and the remote wire format live in [SPEC-extensions.md](../../SPEC-extensions.md). Runnable conformance vectors are in [CONFORMANCE.md](../../CONFORMANCE.md).
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wc-bindable/angular",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Angular adapter for wc-bindable protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dev": "tsc --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@wc-bindable/core": "^0.
|
|
24
|
+
"@wc-bindable/core": "^0.7.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@angular/core": ">=17"
|