@nauticana/sail 0.8.1 → 0.8.3
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
CHANGED
|
@@ -1051,6 +1051,25 @@ protected onActionSuccess(action: TableAction, record?: Record<string, unknown>)
|
|
|
1051
1051
|
|
|
1052
1052
|
If your downstream component extends `BaseTable` / `BaseView` and uses the alias-input pattern from v0.8.0 (`input + effect`), you can optionally migrate to `linkedSignal` — but the old pattern still compiles.
|
|
1053
1053
|
|
|
1054
|
+
```typescript
|
|
1055
|
+
import { input, linkedSignal } from '@angular/core';
|
|
1056
|
+
|
|
1057
|
+
export class MyView extends BaseView {
|
|
1058
|
+
// Aliased input MUST be public — Angular's strict template type-checker
|
|
1059
|
+
// resolves `[tableName]="x"` from a parent template back to this field
|
|
1060
|
+
// by name, and a `private` / `protected` modifier rejects the binding
|
|
1061
|
+
// with TS2445. The override signal can be any visibility.
|
|
1062
|
+
readonly tableNameInput = input('', { alias: 'tableName' });
|
|
1063
|
+
|
|
1064
|
+
override readonly tableName = linkedSignal<string, string>({
|
|
1065
|
+
source: () => this.tableNameInput(),
|
|
1066
|
+
computation: (v, prev) => v || prev?.value || '', // preserve .set() when input goes empty
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
The `computation` callback runs whenever the source changes. Returning `v || prev?.value` gives "use the bound value if provided, else keep the last non-empty value we had locally" — same semantics the v0.8.0 `effect()` carried.
|
|
1072
|
+
|
|
1054
1073
|
### 5. Internal: `BaseTable.caption` is no longer memoised; `Navigation.allMenuItems` via `toSignal`
|
|
1055
1074
|
|
|
1056
1075
|
`getCaption()` and `colCaption()` previously cached on first read, so `tableName` updates after first render returned stale captions. They now recompute each call (cost is negligible). `Navigation` reads `allMenuItems` via `toSignal(getMenus(), { initialValue: [] })` instead of a manual `subscribe` in `ngOnInit`.
|
|
@@ -1077,6 +1096,7 @@ Expected errors after the upgrade:
|
|
|
1077
1096
|
- **`'app-*' is not a known element`** — selector rename, see step 1.
|
|
1078
1097
|
- **`'@Output' is deprecated`** — leftover from the v0.8.0 migration; finish it.
|
|
1079
1098
|
- **`peerinvalid` / `--legacy-peer-deps` prompts on `npm install`** — your project still has TS 6.x. Downgrade per step 6.
|
|
1099
|
+
- **`TS2445: Property 'xInput' is protected and only accessible within class …`** during `ng build` from a downstream project, pointing at sail's own `*.html` files (e.g. `[tableName]="..."` in `table_edit.html`) — upgrade to sail `v0.8.1` patch (published after the initial v0.8.1 cut) where the aliased input fields are public. The cause: Angular's strict template type-checker resolves the alias back to the declared field, so `input('', { alias: 'tableName' })` declared as `protected readonly tableNameInput` is unreachable from the parent template that binds `[tableName]=…`. The fix in your own subclasses, if you copied the v0.8.1 pattern: drop the `protected` / `private` modifier on any aliased `input()` field, leave it `readonly`.
|
|
1080
1100
|
|
|
1081
1101
|
### 8. Backend alignment
|
|
1082
1102
|
|
|
@@ -1097,7 +1117,7 @@ When you extend sail in your own app, apply the same patterns sail itself follow
|
|
|
1097
1117
|
|
|
1098
1118
|
### Components and directives
|
|
1099
1119
|
|
|
1100
|
-
- **Signal-based inputs/outputs.** `input()` / `output()` instead of `@Input()` / `@Output()`. Read as `this.x()` / `{{ x() }}`.
|
|
1120
|
+
- **Signal-based inputs/outputs.** `input()` / `output()` instead of `@Input()` / `@Output()`. Read as `this.x()` / `{{ x() }}`. **Keep `input()` / `output()` fields publicly accessible** (`readonly` without `private`/`protected`). Angular's strict template type-checker resolves an `{ alias: 'foo' }` back to the declared field name and rejects parent bindings against a non-public field with TS2445.
|
|
1101
1121
|
- **`model()` for two-way bindings.** When the parent needs `[(value)]` binding semantics, declare `value = model('')` rather than rolling your own `@Output() valueChange`.
|
|
1102
1122
|
- **`inject()` for dependencies.** No constructor parameter injection. Field-level `inject(Token)` keeps the constructor zero-arg and lets the class be subclassed without parameter forwarding.
|
|
1103
1123
|
- **`ChangeDetectionStrategy.OnPush` on every component.** Signal-based code is fully compatible with OnPush; without it, change detection still runs needlessly.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauticana/sail",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Metadata-driven Angular component library for CRUD admin frontends backed by the keel Go backend. Tables, forms, navigation, OTP/2FA/social auth, billing, payout onboarding.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,7 @@ import { TableLookup } from "../table/table_lookup";
|
|
|
31
31
|
]
|
|
32
32
|
})
|
|
33
33
|
export class DynamicField extends BaseTable {
|
|
34
|
-
|
|
34
|
+
readonly tableNameInput = input('', { alias: 'tableName' });
|
|
35
35
|
readonly value = input<any>(undefined);
|
|
36
36
|
readonly valueChange = output<any>();
|
|
37
37
|
readonly recordUpdate = output<{[key: string]: any}>();
|
|
@@ -20,8 +20,8 @@ import { OpCode } from "../../model/common";
|
|
|
20
20
|
],
|
|
21
21
|
})
|
|
22
22
|
export class TableDetail extends BaseForm implements OnInit {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
readonly tableNameInput = input('', { alias: 'tableName' });
|
|
24
|
+
readonly recordsInput = input<any[]>([], { alias: 'records' });
|
|
25
25
|
readonly parentTableName = input('');
|
|
26
26
|
readonly parentRecord = input<any>({});
|
|
27
27
|
/** When true, the parent view is in read-only mode — disable all child row editing. */
|
|
@@ -22,9 +22,9 @@ import { OpCode } from "../../model/common";
|
|
|
22
22
|
]
|
|
23
23
|
})
|
|
24
24
|
export class TableEdit extends BaseForm implements OnInit {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
readonly recordInput = input<any>({}, { alias: 'record' });
|
|
26
|
+
readonly tableNameInput = input('', { alias: 'tableName' });
|
|
27
|
+
readonly apiNameInput = input('', { alias: 'apiName' });
|
|
28
28
|
|
|
29
29
|
readonly record = linkedSignal<any, any>({ source: () => this.recordInput(), computation: (v, p) => v ?? p?.value ?? {} });
|
|
30
30
|
override readonly tableName = linkedSignal<string, string>({ source: () => this.tableNameInput(), computation: (v, p) => v || p?.value || '' });
|
|
@@ -16,9 +16,9 @@ import { MatIconModule } from "@angular/material/icon";
|
|
|
16
16
|
})
|
|
17
17
|
export class TableList extends BaseView implements OnInit {
|
|
18
18
|
override dialogWidth = '400px';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
readonly tableNameInput = input('', { alias: 'tableName' });
|
|
20
|
+
readonly apiNameInput = input('', { alias: 'apiName' });
|
|
21
|
+
readonly dialogComponentInput = input<any>(undefined, { alias: 'dialogComponent' });
|
|
22
22
|
|
|
23
23
|
// linkedSignal: defaults to the consumer's input, but ngOnInit / route data
|
|
24
24
|
// can override with `.set()`. The `computation` preserves the last
|
|
@@ -18,9 +18,9 @@ import { ApplicationMenu } from "../../model/common";
|
|
|
18
18
|
],
|
|
19
19
|
})
|
|
20
20
|
export class TableSearch extends BaseForm implements OnInit {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
readonly tableNameInput = input('', { alias: 'tableName' });
|
|
22
|
+
readonly apiNameInput = input('', { alias: 'apiName' });
|
|
23
|
+
readonly targetRouteInput = input('', { alias: 'targetRoute' });
|
|
24
24
|
|
|
25
25
|
override readonly tableName = linkedSignal<string, string>({ source: () => this.tableNameInput(), computation: (v, p) => v || p?.value || '' });
|
|
26
26
|
readonly apiName = linkedSignal<string, string>({ source: () => this.apiNameInput(), computation: (v, p) => v || p?.value || '' });
|