bank20baht-ui-angular 0.0.0-stage → 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 Nattapong Promthong
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 CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # bank20baht-ui-angular
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Angular adapter for [bank20baht-ui](https://www.npmjs.com/package/bank20baht-ui). One directive per `<baht-*>`
4
+ element, sitting on the real element (no wrapper, no extra DOM), so templates get:
5
+
6
+ - **typed inputs**: `[field]`, `[form]`, `[items]` are checked against the element's own property types, and a
7
+ misspelled property fails the build (`Can't bind to 'varient'`);
8
+ - **typed outputs** that emit the event `detail`: `(bahtChange)="save($event.data)"`, no `$any($event).detail`;
9
+ - **`[(value)]`** on every element that edits a value (fields, tabs, rating, range, otp, …), with signals;
10
+ - **the binding gotchas handled**: `readonly` reaches the element (Angular maps a plain `[readonly]` to the
11
+ native `readOnly`), and boolean/number attributes (`<baht-form readonly>`, `debounce="300"`) are coerced;
12
+ - **no `CUSTOM_ELEMENTS_SCHEMA`**: the directives make the tags known to the compiler.
13
+
14
+ The directives are generated from the elements' `custom-elements.json`, so every element, property and event
15
+ in the matching bank20baht-ui minor is covered.
16
+
17
+ ```bash
18
+ npm i bank20baht-ui bank20baht-ui-angular
19
+ ```
20
+
21
+ ## Use
22
+
23
+ ```ts
24
+ // main.ts: register the elements once, as before
25
+ import 'bank20baht-ui';
26
+ ```
27
+
28
+ ```ts
29
+ import { Component, signal } from '@angular/core';
30
+ import type { FormDefinition } from 'bank20baht-ui';
31
+ import { BAHT_UI } from 'bank20baht-ui-angular';
32
+
33
+ @Component({
34
+ selector: 'app-request',
35
+ imports: [BAHT_UI],
36
+ template: `
37
+ <baht-tabs [tabs]="tabs" [(value)]="tab" />
38
+ <baht-form #f="bahtForm" [form]="form" [readonly]="locked()" (bahtChange)="draft = $event.data" />
39
+ <baht-button (click)="f.element.validate().valid && save()">Save</baht-button>
40
+ `,
41
+ })
42
+ export class RequestComponent {
43
+ readonly tab = signal('details');
44
+ readonly locked = signal(false);
45
+ form!: FormDefinition;
46
+ draft: Record<string, unknown> = {};
47
+ }
48
+ ```
49
+
50
+ - `BAHT_UI` is every directive; import single ones (`BahtFormDirective`, `BahtSelectDirective`, …) if you prefer.
51
+ - Outputs are the event name in camelCase: `baht-row-click` → `(bahtRowClick)`, emitting the detail. The DOM
52
+ event still fires, so existing `(baht-row-click)="…$event.detail…"` bindings keep working while you migrate.
53
+ - `#ref="bahtForm"` (the tag in camelCase) gives the directive; `.element` is the element, typed, for its methods
54
+ (`validate()`, `getData()`, `reset()`, `replay()`, …). `viewChild(BahtFormDirective)` works the same way.
55
+ - Outputs only fire for the element's own events; the same event bubbling from an element inside it is ignored.
56
+ - `<baht-form>` and `<baht-workflow>` have no `[(value)]`: their `value` is the starting data. Listen to
57
+ `(bahtChange)` / `(bahtDataChange)`, or bind a store (below).
58
+
59
+ ## bank20baht-store as signals
60
+
61
+ ```ts
62
+ import { createBahtStore } from 'bank20baht-store';
63
+ import { bahtSignal, bahtStore } from 'bank20baht-ui-angular/store';
64
+
65
+ readonly store = createBahtStore();
66
+ readonly days = bahtSignal<number>(this.store, 'Request.days'); // WritableSignal: set() writes through
67
+ readonly all = bahtStore(this.store); // the whole tree, read-only
68
+ ```
69
+
70
+ Call them in an injection context; they unsubscribe on destroy. `bank20baht-store` is an optional peer.
71
+
72
+ ## Versions and federation
73
+
74
+ - Peer `bank20baht-ui` is pinned to one minor (`>=0.18.0 <0.19.0`): the directives are generated from that
75
+ minor's elements. Angular `>=20`.
76
+ - The package ships partial-compiled (Ivy) code and imports only types from bank20baht-ui at runtime, so it adds
77
+ no second copy of the elements. With Native Federation, share it like any other library.
78
+
79
+ MIT.