@wc-bindable/angular 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wc-bindable-protocol
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,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 @wc-bindable/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
+ ## License
59
+
60
+ MIT
@@ -0,0 +1,13 @@
1
+ import { ElementRef, EventEmitter, OnInit, OnDestroy } from "@angular/core";
2
+ export declare class WcBindableDirective implements OnInit, OnDestroy {
3
+ private el;
4
+ wcBindableChange: EventEmitter<{
5
+ name: string;
6
+ value: unknown;
7
+ }>;
8
+ private unbind?;
9
+ constructor(el: ElementRef<HTMLElement>);
10
+ ngOnInit(): void;
11
+ ngOnDestroy(): void;
12
+ }
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,MAAM,EACN,SAAS,EAEV,MAAM,eAAe,CAAC;AAGvB,qBAIa,mBAAoB,YAAW,MAAM,EAAE,SAAS;IAK/C,OAAO,CAAC,EAAE;IAJZ,gBAAgB;cAA4B,MAAM;eAAS,OAAO;OAAM;IAElF,OAAO,CAAC,MAAM,CAAC,CAAa;gBAER,EAAE,EAAE,UAAU,CAAC,WAAW,CAAC;IAE/C,QAAQ;IASR,WAAW;CAGZ"}
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Directive, ElementRef, EventEmitter, Output, } from "@angular/core";
11
+ import { bind, isWcBindable } from "@wc-bindable/core";
12
+ let WcBindableDirective = class WcBindableDirective {
13
+ constructor(el) {
14
+ this.el = el;
15
+ this.wcBindableChange = new EventEmitter();
16
+ }
17
+ ngOnInit() {
18
+ const element = this.el.nativeElement;
19
+ if (!isWcBindable(element))
20
+ return;
21
+ this.unbind = bind(element, (name, value) => {
22
+ this.wcBindableChange.emit({ name, value });
23
+ });
24
+ }
25
+ ngOnDestroy() {
26
+ this.unbind?.();
27
+ }
28
+ };
29
+ __decorate([
30
+ Output(),
31
+ __metadata("design:type", Object)
32
+ ], WcBindableDirective.prototype, "wcBindableChange", void 0);
33
+ WcBindableDirective = __decorate([
34
+ Directive({
35
+ selector: "[wcBindable]",
36
+ standalone: true,
37
+ }),
38
+ __metadata("design:paramtypes", [ElementRef])
39
+ ], WcBindableDirective);
40
+ export { WcBindableDirective };
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EAGZ,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMhD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAK9B,YAAoB,EAA2B;QAA3B,OAAE,GAAF,EAAE,CAAyB;QAJrC,qBAAgB,GAAG,IAAI,YAAY,EAAoC,CAAC;IAIhC,CAAC;IAEnD,QAAQ;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;QACtC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAAE,OAAO;QAEnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC1C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,WAAW;QACT,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAClB,CAAC;CACF,CAAA;AAlBW;IAAT,MAAM,EAAE;;6DAAyE;AADvE,mBAAmB;IAJ/B,SAAS,CAAC;QACT,QAAQ,EAAE,cAAc;QACxB,UAAU,EAAE,IAAI;KACjB,CAAC;qCAMwB,UAAU;GALvB,mBAAmB,CAmB/B"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@wc-bindable/angular",
3
+ "version": "0.1.0",
4
+ "description": "Angular adapter for wc-bindable protocol",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsc --watch"
22
+ },
23
+ "dependencies": {
24
+ "@wc-bindable/core": "^0.1.0"
25
+ },
26
+ "peerDependencies": {
27
+ "@angular/core": ">=17"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/wc-bindable-protocol/wc-bindable-protocol.git",
32
+ "directory": "packages/angular"
33
+ },
34
+ "license": "MIT"
35
+ }