@runic-artifex/angular 0.19.0 → 0.20.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.
Files changed (53) hide show
  1. package/README.md +130 -23
  2. package/dist/fesm2022/runic-artifex-angular-experimental.mjs +285 -0
  3. package/dist/fesm2022/runic-artifex-angular-experimental.mjs.map +1 -0
  4. package/dist/fesm2022/runic-artifex-angular-forms.mjs +246 -0
  5. package/dist/fesm2022/runic-artifex-angular-forms.mjs.map +1 -0
  6. package/dist/fesm2022/runic-artifex-angular.mjs +975 -0
  7. package/dist/fesm2022/runic-artifex-angular.mjs.map +1 -0
  8. package/dist/types/runic-artifex-angular-experimental.d.ts +85 -0
  9. package/dist/types/runic-artifex-angular-forms.d.ts +72 -0
  10. package/dist/types/runic-artifex-angular.d.ts +626 -0
  11. package/package.json +20 -17
  12. package/dist/esm/experimental.d.ts +0 -39
  13. package/dist/esm/experimental.js +0 -64
  14. package/dist/esm/forms/index.d.ts +0 -2
  15. package/dist/esm/forms/index.js +0 -2
  16. package/dist/esm/forms/runic-field.directive.d.ts +0 -48
  17. package/dist/esm/forms/runic-field.directive.js +0 -195
  18. package/dist/esm/forms/signal-forms.d.ts +0 -19
  19. package/dist/esm/forms/signal-forms.js +0 -29
  20. package/dist/esm/index.d.ts +0 -24
  21. package/dist/esm/index.js +0 -25
  22. package/dist/esm/inject-appearance.d.ts +0 -19
  23. package/dist/esm/inject-appearance.js +0 -28
  24. package/dist/esm/inject-bridge-connection.d.ts +0 -22
  25. package/dist/esm/inject-bridge-connection.js +0 -26
  26. package/dist/esm/inject-collection-viewport.d.ts +0 -13
  27. package/dist/esm/inject-collection-viewport.js +0 -31
  28. package/dist/esm/inject-command.d.ts +0 -35
  29. package/dist/esm/inject-command.js +0 -33
  30. package/dist/esm/inject-field.d.ts +0 -66
  31. package/dist/esm/inject-field.js +0 -58
  32. package/dist/esm/inject-form.d.ts +0 -40
  33. package/dist/esm/inject-form.js +0 -48
  34. package/dist/esm/inject-latest-operation.d.ts +0 -25
  35. package/dist/esm/inject-latest-operation.js +0 -35
  36. package/dist/esm/inject-menu-bar.d.ts +0 -32
  37. package/dist/esm/inject-menu-bar.js +0 -39
  38. package/dist/esm/inject-operation.d.ts +0 -23
  39. package/dist/esm/inject-operation.js +0 -33
  40. package/dist/esm/inject-query-collection.d.ts +0 -29
  41. package/dist/esm/inject-query-collection.js +0 -64
  42. package/dist/esm/inject-text-field.d.ts +0 -55
  43. package/dist/esm/inject-text-field.js +0 -51
  44. package/dist/esm/inject-text.d.ts +0 -57
  45. package/dist/esm/inject-text.js +0 -107
  46. package/dist/esm/inject-view-resource.d.ts +0 -39
  47. package/dist/esm/inject-view-resource.js +0 -98
  48. package/dist/esm/inject-view.d.ts +0 -41
  49. package/dist/esm/inject-view.js +0 -67
  50. package/dist/esm/instance.d.ts +0 -34
  51. package/dist/esm/instance.js +0 -48
  52. package/dist/esm/view-outlet.d.ts +0 -101
  53. package/dist/esm/view-outlet.js +0 -177
package/package.json CHANGED
@@ -1,33 +1,34 @@
1
1
  {
2
2
  "name": "@runic-artifex/angular",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
7
- "types": "./dist/esm/index.d.ts",
8
- "import": "./dist/esm/index.js",
9
- "default": "./dist/esm/index.js"
7
+ "types": "./dist/types/runic-artifex-angular.d.ts",
8
+ "default": "./dist/fesm2022/runic-artifex-angular.mjs"
10
9
  },
11
10
  "./forms": {
12
- "types": "./dist/esm/forms/index.d.ts",
13
- "import": "./dist/esm/forms/index.js",
14
- "default": "./dist/esm/forms/index.js"
11
+ "types": "./dist/types/runic-artifex-angular-forms.d.ts",
12
+ "default": "./dist/fesm2022/runic-artifex-angular-forms.mjs"
15
13
  },
16
14
  "./experimental": {
17
- "types": "./dist/esm/experimental.d.ts",
18
- "import": "./dist/esm/experimental.js",
19
- "default": "./dist/esm/experimental.js"
15
+ "types": "./dist/types/runic-artifex-angular-experimental.d.ts",
16
+ "default": "./dist/fesm2022/runic-artifex-angular-experimental.mjs"
20
17
  },
21
18
  "./package.json": "./package.json"
22
19
  },
23
20
  "peerDependencies": {
24
21
  "@angular/core": ">=22.0.0 <23",
25
22
  "@angular/forms": ">=22.0.0 <23",
26
- "@runic-artifex/views": "0.19.0"
23
+ "@angular/platform-browser": ">=22.0.0 <23",
24
+ "@runic-artifex/views": "0.20.0"
27
25
  },
28
26
  "peerDependenciesMeta": {
29
27
  "@angular/forms": {
30
28
  "optional": true
29
+ },
30
+ "@angular/platform-browser": {
31
+ "optional": true
31
32
  }
32
33
  },
33
34
  "description": "Angular outlet and signals for Runic Views",
@@ -37,7 +38,7 @@
37
38
  "url": "git+https://github.com/Runic-Artifex/runic-sdk.git",
38
39
  "directory": "packages/web/angular"
39
40
  },
40
- "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.19.0/packages/web/angular#readme",
41
+ "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/v0.20.0/packages/web/angular#readme",
41
42
  "bugs": {
42
43
  "url": "https://github.com/Runic-Artifex/runic-sdk/issues"
43
44
  },
@@ -52,16 +53,16 @@
52
53
  ],
53
54
  "packageManager": "bun@1.4.4",
54
55
  "sideEffects": false,
55
- "main": "./dist/esm/index.js",
56
- "types": "./dist/esm/index.d.ts",
56
+ "main": "./dist/fesm2022/runic-artifex-angular.mjs",
57
+ "types": "./dist/types/runic-artifex-angular.d.ts",
57
58
  "scripts": {
58
- "build": "ngc -p tsconfig.json",
59
+ "build": "ng-packagr -p ng-package.json -c tsconfig.json && bun scripts/finish-apf.mjs",
59
60
  "check": "ngc -p tsconfig.json --noEmit",
60
61
  "test": "bun run --bun build && tsc -p tsconfig.test.json && vitest run",
61
62
  "pack:check": "bun pm pack --dry-run"
62
63
  },
63
64
  "devDependencies": {
64
- "@runic-artifex/views": "0.19.0",
65
+ "@runic-artifex/views": "0.20.0",
65
66
  "@angular/common": "22.2.3",
66
67
  "@angular/compiler": "22.2.3",
67
68
  "@angular/compiler-cli": "22.2.3",
@@ -70,9 +71,11 @@
70
71
  "@angular/platform-browser": "22.2.3",
71
72
  "esbuild": "0.28.2",
72
73
  "happy-dom": "21.0.4",
74
+ "ng-packagr": "22.2.6",
73
75
  "playwright-core": "1.63.0",
76
+ "tslib": "2.8.1",
74
77
  "typescript": "6.0.3",
75
78
  "vitest": "5.0.3"
76
79
  },
77
- "gitHead": "9a09c23055f09f7505552d236c8acf69bdeeb02e"
80
+ "gitHead": "8288005e35e9cc377ca280db1ab44b91582cd705"
78
81
  }
@@ -1,39 +0,0 @@
1
- import { type HostedRegionSizing, type HostedRegionState } from "@runic-artifex/views/experimental";
2
- import * as i0 from "@angular/core";
3
- export type { HostedRegionSizing, HostedRegionState, RunicHostedRegionElement } from "@runic-artifex/views/experimental";
4
- /** The `stateChange` output of {@link RunicHostedRegion}. */
5
- export interface HostedRegionStateChange {
6
- readonly state: HostedRegionState;
7
- readonly previous: HostedRegionState;
8
- }
9
- /**
10
- * A region where the host application shows a hosted guest's Window: the component's element is
11
- * `<runic-hosted-region>` itself, and the page never gets a reference to its frame. Projected content shows while no
12
- * guest page shows in the region; `state()` tells which state it is in:
13
- *
14
- * ```html
15
- * <runic-hosted-region #check name="check" style="height: 420px" (stateChange)="onState($event)">
16
- * @if (check.state() === "ended") { <button (click)="runAgain()">Run the check again</button> }
17
- * @else { <p>Starting the check…</p> }
18
- * </runic-hosted-region>
19
- * ```
20
- */
21
- export declare class RunicHostedRegion {
22
- #private;
23
- /** The region's name, which the host application's policy embeds a guest's Window in. */
24
- readonly name: import("@angular/core").InputSignal<string>;
25
- /** `fill` (the default): the page's layout sets the height. `content-height`: the guest's page does. */
26
- readonly sizing: import("@angular/core").InputSignal<HostedRegionSizing | undefined>;
27
- /** The region's accessible name; without it, the guest page's title. */
28
- readonly label: import("@angular/core").InputSignal<string | undefined>;
29
- readonly stateChange: import("@angular/core").OutputEmitterRef<HostedRegionStateChange>;
30
- /** The guest page's title as the host passed it on, or `null`. */
31
- readonly titleChange: import("@angular/core").OutputEmitterRef<string | null>;
32
- /** What the region shows now. */
33
- readonly state: import("@angular/core").Signal<HostedRegionState>;
34
- constructor();
35
- protected stateChanged(event: Event): void;
36
- protected titleChanged(event: Event): void;
37
- static ɵfac: i0.ɵɵFactoryDeclaration<RunicHostedRegion, never>;
38
- static ɵcmp: i0.ɵɵComponentDeclaration<RunicHostedRegion, "runic-hosted-region", ["runicHostedRegion"], { "name": { "alias": "name"; "required": true; "isSignal": true; }; "sizing": { "alias": "sizing"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; }, { "stateChange": "stateChange"; "titleChange": "titleChange"; }, never, ["*"], true, never>;
39
- }
@@ -1,64 +0,0 @@
1
- // The experimental entry (docs/experimental.md, "npm packages"): importing it is the opt-in. Hosted regions (0.18): the
2
- // .NET side is the experimental family RUNICDESK103.
3
- import { Component, input, output, signal } from "@angular/core";
4
- import { defineHostedRegion, } from "@runic-artifex/views/experimental";
5
- import * as i0 from "@angular/core";
6
- /**
7
- * A region where the host application shows a hosted guest's Window: the component's element is
8
- * `<runic-hosted-region>` itself, and the page never gets a reference to its frame. Projected content shows while no
9
- * guest page shows in the region; `state()` tells which state it is in:
10
- *
11
- * ```html
12
- * <runic-hosted-region #check name="check" style="height: 420px" (stateChange)="onState($event)">
13
- * @if (check.state() === "ended") { <button (click)="runAgain()">Run the check again</button> }
14
- * @else { <p>Starting the check…</p> }
15
- * </runic-hosted-region>
16
- * ```
17
- */
18
- export class RunicHostedRegion {
19
- /** The region's name, which the host application's policy embeds a guest's Window in. */
20
- name = input.required(/* @ts-ignore */
21
- ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
22
- /** `fill` (the default): the page's layout sets the height. `content-height`: the guest's page does. */
23
- sizing = input(/* @ts-ignore */
24
- ...(ngDevMode ? [undefined, { debugName: "sizing" }] : /* istanbul ignore next */ []));
25
- /** The region's accessible name; without it, the guest page's title. */
26
- label = input(/* @ts-ignore */
27
- ...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
28
- stateChange = output();
29
- /** The guest page's title as the host passed it on, or `null`. */
30
- titleChange = output();
31
- #state = signal("waiting", /* @ts-ignore */
32
- ...(ngDevMode ? [{ debugName: "#state" }] : /* istanbul ignore next */ []));
33
- /** What the region shows now. */
34
- state = this.#state.asReadonly();
35
- constructor() {
36
- defineHostedRegion();
37
- }
38
- stateChanged(event) {
39
- const detail = event.detail;
40
- this.#state.set(detail.state);
41
- this.stateChange.emit({ state: detail.state, previous: detail.previous });
42
- }
43
- titleChanged(event) {
44
- this.titleChange.emit(event.detail.title);
45
- }
46
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: RunicHostedRegion, deps: [], target: i0.ɵɵFactoryTarget.Component });
47
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.3", type: RunicHostedRegion, isStandalone: true, selector: "runic-hosted-region", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, sizing: { classPropertyName: "sizing", publicName: "sizing", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stateChange: "stateChange", titleChange: "titleChange" }, host: { listeners: { "runicregionstatechange": "stateChanged($event)", "runicregiontitlechange": "titleChanged($event)" }, properties: { "attr.name": "name()", "attr.sizing": "sizing() ?? null", "attr.label": "label() ?? null" } }, exportAs: ["runicHostedRegion"], ngImport: i0, template: `<div slot="fallback" style="display: contents"><ng-content /></div>`, isInline: true });
48
- }
49
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: RunicHostedRegion, decorators: [{
50
- type: Component,
51
- args: [{
52
- selector: "runic-hosted-region",
53
- standalone: true,
54
- exportAs: "runicHostedRegion",
55
- host: {
56
- "[attr.name]": "name()",
57
- "[attr.sizing]": "sizing() ?? null",
58
- "[attr.label]": "label() ?? null",
59
- "(runicregionstatechange)": "stateChanged($event)",
60
- "(runicregiontitlechange)": "titleChanged($event)",
61
- },
62
- template: `<div slot="fallback" style="display: contents"><ng-content /></div>`,
63
- }]
64
- }], ctorParameters: () => [], propDecorators: { name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: true }] }], sizing: [{ type: i0.Input, args: [{ isSignal: true, alias: "sizing", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], stateChange: [{ type: i0.Output, args: ["stateChange"] }], titleChange: [{ type: i0.Output, args: ["titleChange"] }] } });
@@ -1,2 +0,0 @@
1
- export { RunicFieldDirective } from "./runic-field.directive.js";
2
- export { runicFieldModel, validateRunicField } from "./signal-forms.js";
@@ -1,2 +0,0 @@
1
- export { RunicFieldDirective } from "./runic-field.directive.js";
2
- export { runicFieldModel, validateRunicField } from "./signal-forms.js";
@@ -1,48 +0,0 @@
1
- import { type AbstractControl, type ControlValueAccessor, type ValidationErrors, type Validator } from "@angular/forms";
2
- import type { FieldHandle } from "../inject-field.js";
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Wires an `<input>`, `<textarea>` or `<select>` to an {@link injectField} handle: `<input [runicField]="title">`.
6
- *
7
- * Alone, it writes what the user types (`input`; `change` for checkboxes, radios and selects), holds writes during IME
8
- * composition, commits on blur, keeps the element's `value` (or `checked`) equal to the field without moving the
9
- * caret, and sets `aria-invalid` while the field has an `error` or `errors`.
10
- *
11
- * It is also the `ControlValueAccessor` and `Validator` of a `formControl` or `formControlName` on the same element:
12
- * the View's value flows into the control without marking it dirty or emitting `valueChanges`, the user's input
13
- * reaches it as usual, `patchValue` and `reset` write through to the View when they change the value, `disable()`
14
- * disables the element, and the control is invalid with `{ runic: errors }` while the View reports `errors`.
15
- */
16
- export declare class RunicFieldDirective implements ControlValueAccessor, Validator {
17
- /** The field to wire, from {@link injectField}. */
18
- readonly runicField: import("@angular/core").InputSignal<FieldHandle<unknown>>;
19
- protected readonly invalid: import("@angular/core").Signal<boolean>;
20
- private readonly element;
21
- private readonly injector;
22
- private composing;
23
- private changed;
24
- private touched;
25
- private validatorChanged;
26
- private validated;
27
- private synced;
28
- constructor();
29
- private wiring;
30
- private control;
31
- private syncControl;
32
- private changedByUser;
33
- protected onInput(): void;
34
- protected onChange(): void;
35
- protected onCompositionStart(): void;
36
- protected onCompositionEnd(): void;
37
- protected onBlur(): void;
38
- /** A value set by the form (`setValue`, `patchValue`, `reset`): written to the View when it differs from the field's. */
39
- writeValue(value: unknown): void;
40
- registerOnChange(fn: (value: unknown) => void): void;
41
- registerOnTouched(fn: () => void): void;
42
- setDisabledState(disabled: boolean): void;
43
- /** `{ runic: errors }` while the View reports validation messages for the field. */
44
- validate(_control?: AbstractControl): ValidationErrors | null;
45
- registerOnValidatorChange(fn: () => void): void;
46
- static ɵfac: i0.ɵɵFactoryDeclaration<RunicFieldDirective, never>;
47
- static ɵdir: i0.ɵɵDirectiveDeclaration<RunicFieldDirective, "[runicField]", never, { "runicField": { "alias": "runicField"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
48
- }
@@ -1,195 +0,0 @@
1
- import { afterRenderEffect, computed, Directive, effect, ElementRef, forwardRef, inject, Injector, input, untracked } from "@angular/core";
2
- import { NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, } from "@angular/forms";
3
- import * as i0 from "@angular/core";
4
- // No control synced yet: the first `writeValue` of a control is its setup, not a change by the form.
5
- const unsynced = Symbol("unsynced");
6
- /**
7
- * Wires an `<input>`, `<textarea>` or `<select>` to an {@link injectField} handle: `<input [runicField]="title">`.
8
- *
9
- * Alone, it writes what the user types (`input`; `change` for checkboxes, radios and selects), holds writes during IME
10
- * composition, commits on blur, keeps the element's `value` (or `checked`) equal to the field without moving the
11
- * caret, and sets `aria-invalid` while the field has an `error` or `errors`.
12
- *
13
- * It is also the `ControlValueAccessor` and `Validator` of a `formControl` or `formControlName` on the same element:
14
- * the View's value flows into the control without marking it dirty or emitting `valueChanges`, the user's input
15
- * reaches it as usual, `patchValue` and `reset` write through to the View when they change the value, `disable()`
16
- * disables the element, and the control is invalid with `{ runic: errors }` while the View reports `errors`.
17
- */
18
- export class RunicFieldDirective {
19
- /** The field to wire, from {@link injectField}. */
20
- runicField = input.required(/* @ts-ignore */
21
- ...(ngDevMode ? [{ debugName: "runicField" }] : /* istanbul ignore next */ []));
22
- invalid = computed(() => {
23
- const field = this.runicField();
24
- return field.error() !== undefined || field.errors().length !== 0;
25
- }, /* @ts-ignore */
26
- ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
27
- element = inject(ElementRef).nativeElement;
28
- // NgControl injects this directive as its accessor, so it is looked up when needed rather than injected.
29
- injector = inject(Injector);
30
- composing = false;
31
- changed;
32
- touched;
33
- validatorChanged;
34
- validated;
35
- synced = unsynced;
36
- constructor() {
37
- afterRenderEffect({
38
- write: () => {
39
- const field = this.runicField();
40
- const value = field.value();
41
- const text = field.text();
42
- if (this.composing)
43
- return;
44
- const element = this.element;
45
- switch (this.wiring()) {
46
- case "checkbox": {
47
- const checkbox = element;
48
- if (checkbox.checked !== (value === true))
49
- checkbox.checked = value === true;
50
- checkbox.indeterminate = value === null || value === undefined;
51
- break;
52
- }
53
- case "radio": {
54
- const radio = element;
55
- if (radio.checked !== (radio.value === text))
56
- radio.checked = radio.value === text;
57
- break;
58
- }
59
- default:
60
- // Only a changed value is assigned, which keeps the caret where it is.
61
- if (element.value !== text)
62
- element.value = text;
63
- }
64
- },
65
- });
66
- // The View's value, and the user's while a draft exists, flows into the control without dirtying it.
67
- effect(() => {
68
- this.runicField().value();
69
- untracked(() => this.syncControl());
70
- });
71
- effect(() => {
72
- const errors = this.runicField().errors();
73
- untracked(() => {
74
- if (this.validated !== undefined && errors !== this.validated)
75
- this.validatorChanged?.();
76
- });
77
- });
78
- }
79
- wiring() {
80
- const element = this.element;
81
- if (element.tagName === "SELECT")
82
- return "select";
83
- if (element.tagName === "INPUT") {
84
- const type = element.type;
85
- if (type === "checkbox" || type === "radio")
86
- return type;
87
- }
88
- return "text";
89
- }
90
- control() {
91
- return this.injector.get(NgControl, null, { self: true, optional: true })?.control ?? undefined;
92
- }
93
- syncControl() {
94
- const control = this.control();
95
- if (control === undefined)
96
- return;
97
- this.synced = control;
98
- const value = this.runicField().value();
99
- if (!Object.is(control.value, value))
100
- control.setValue(value, { emitEvent: false, emitModelToViewChange: false });
101
- }
102
- changedByUser() {
103
- this.changed?.(this.runicField().value());
104
- }
105
- onInput() {
106
- if (this.wiring() !== "text")
107
- return;
108
- this.runicField().inputText(this.element.value);
109
- if (!this.composing)
110
- this.changedByUser();
111
- }
112
- onChange() {
113
- const field = this.runicField();
114
- switch (this.wiring()) {
115
- case "checkbox":
116
- field.input(this.element.checked);
117
- break;
118
- case "radio":
119
- if (!this.element.checked)
120
- return;
121
- field.inputText(this.element.value);
122
- break;
123
- case "select":
124
- field.inputText(this.element.value);
125
- break;
126
- default: return;
127
- }
128
- this.changedByUser();
129
- }
130
- onCompositionStart() {
131
- this.composing = true;
132
- this.runicField().compositionStart();
133
- }
134
- onCompositionEnd() {
135
- this.composing = false;
136
- this.runicField().compositionEnd(this.element.value);
137
- this.changedByUser();
138
- }
139
- onBlur() {
140
- void this.runicField().commit();
141
- this.touched?.();
142
- }
143
- /** A value set by the form (`setValue`, `patchValue`, `reset`): written to the View when it differs from the field's. */
144
- writeValue(value) {
145
- const control = this.control();
146
- // Setting up a control writes its value first: the View's value is the one to keep.
147
- if (this.changed === undefined || control !== this.synced) {
148
- queueMicrotask(() => this.syncControl());
149
- return;
150
- }
151
- const field = this.runicField();
152
- if (Object.is(value, untracked(field.value)))
153
- return;
154
- if ((value === null || value === undefined) && !field.field.nullable) {
155
- // `reset()` of a nullable control: a non-nullable field keeps its value, and the control shows it again.
156
- queueMicrotask(() => this.syncControl());
157
- return;
158
- }
159
- field.input(value);
160
- }
161
- registerOnChange(fn) { this.changed = fn; }
162
- registerOnTouched(fn) { this.touched = fn; }
163
- setDisabledState(disabled) { this.element.disabled = disabled; }
164
- /** `{ runic: errors }` while the View reports validation messages for the field. */
165
- validate(_control) {
166
- const errors = untracked(this.runicField().errors);
167
- this.validated = errors;
168
- return errors.length === 0 ? null : { runic: errors };
169
- }
170
- registerOnValidatorChange(fn) { this.validatorChanged = fn; }
171
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: RunicFieldDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
172
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.3", type: RunicFieldDirective, isStandalone: true, selector: "[runicField]", inputs: { runicField: { classPropertyName: "runicField", publicName: "runicField", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "input": "onInput()", "change": "onChange()", "compositionstart": "onCompositionStart()", "compositionend": "onCompositionEnd()", "blur": "onBlur()" }, properties: { "attr.aria-invalid": "invalid() ? 'true' : null" } }, providers: [
173
- { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => RunicFieldDirective), multi: true },
174
- { provide: NG_VALIDATORS, useExisting: forwardRef(() => RunicFieldDirective), multi: true },
175
- ], ngImport: i0 });
176
- }
177
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: RunicFieldDirective, decorators: [{
178
- type: Directive,
179
- args: [{
180
- selector: "[runicField]",
181
- standalone: true,
182
- providers: [
183
- { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => RunicFieldDirective), multi: true },
184
- { provide: NG_VALIDATORS, useExisting: forwardRef(() => RunicFieldDirective), multi: true },
185
- ],
186
- host: {
187
- "(input)": "onInput()",
188
- "(change)": "onChange()",
189
- "(compositionstart)": "onCompositionStart()",
190
- "(compositionend)": "onCompositionEnd()",
191
- "(blur)": "onBlur()",
192
- "[attr.aria-invalid]": "invalid() ? 'true' : null",
193
- },
194
- }]
195
- }], ctorParameters: () => [], propDecorators: { runicField: [{ type: i0.Input, args: [{ isSignal: true, alias: "runicField", required: true }] }] } });
@@ -1,19 +0,0 @@
1
- import { type WritableSignal } from "@angular/core";
2
- import { type PathKind, type SchemaPath, type SchemaPathRules } from "@angular/forms/signals";
3
- import type { FieldHandle } from "../inject-field.js";
4
- /**
5
- * A `WritableSignal` over an {@link injectField} handle, for a Signal Forms `form()`: it reads the field's `value`,
6
- * and `set` and `update` write through the field (`input`), so the form's `[formField]` edits the View.
7
- *
8
- * ```ts
9
- * readonly title = injectField(this.editor, EditorFields.title);
10
- * readonly titleForm = form(runicFieldModel(this.title), path => validateRunicField(path, this.title));
11
- * // <input [formField]="titleForm" (blur)="title.commit()">
12
- * ```
13
- */
14
- export declare function runicFieldModel<TValue>(handle: FieldHandle<TValue>): WritableSignal<TValue>;
15
- /**
16
- * Adds the field's validation messages (`errors()`) to a Signal Forms schema path as errors of kind `runic`, each
17
- * with its message.
18
- */
19
- export declare function validateRunicField<TValue, TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, handle: Pick<FieldHandle<unknown>, "errors">): void;
@@ -1,29 +0,0 @@
1
- import { linkedSignal, untracked } from "@angular/core";
2
- import { validate } from "@angular/forms/signals";
3
- /**
4
- * A `WritableSignal` over an {@link injectField} handle, for a Signal Forms `form()`: it reads the field's `value`,
5
- * and `set` and `update` write through the field (`input`), so the form's `[formField]` edits the View.
6
- *
7
- * ```ts
8
- * readonly title = injectField(this.editor, EditorFields.title);
9
- * readonly titleForm = form(runicFieldModel(this.title), path => validateRunicField(path, this.title));
10
- * // <input [formField]="titleForm" (blur)="title.commit()">
11
- * ```
12
- */
13
- export function runicFieldModel(handle) {
14
- const model = linkedSignal(() => handle.value(), /* @ts-ignore */
15
- ...(ngDevMode ? [{ debugName: "model" }] : /* istanbul ignore next */ []));
16
- model.set = value => handle.input(value);
17
- model.update = update => handle.input(update(untracked(handle.value)));
18
- return model;
19
- }
20
- /**
21
- * Adds the field's validation messages (`errors()`) to a Signal Forms schema path as errors of kind `runic`, each
22
- * with its message.
23
- */
24
- export function validateRunicField(path, handle) {
25
- validate(path, () => {
26
- const errors = handle.errors();
27
- return errors.length === 0 ? undefined : errors.map((message) => ({ kind: "runic", message }));
28
- });
29
- }
@@ -1,24 +0,0 @@
1
- export { ViewOutlet, RegionOutlets, RunicViewOutlet, type RegionOutletsMode, type RegionPanelAttributes, type ViewOutletMissingContext, type ViewRegistry, } from "./view-outlet.js";
2
- export { injectView, type InjectViewOptions, type ViewHandle } from "./inject-view.js";
3
- export { injectViewResource, type InjectViewResourceOptions, type ViewResource } from "./inject-view-resource.js";
4
- export { injectCommand, type CommandHandle, type InjectCommandOptions } from "./inject-command.js";
5
- export { injectOperation, type InjectOperationOptions, type OperationHandle } from "./inject-operation.js";
6
- export { injectField, type FieldHandle, type FieldView, type InjectFieldOptions } from "./inject-field.js";
7
- export { injectForm, type FormFieldHandle, type FormHandle, type InjectFormOptions } from "./inject-form.js";
8
- export { commitAllFields, type FormState, type FormSubmitOptions, type FormSubmitResult } from "@runic-artifex/views";
9
- export { injectTextField, type InjectTextFieldOptions, type TextFieldHandle, type TextFieldView } from "./inject-text-field.js";
10
- export { injectLatestOperation, type InjectLatestOperationOptions, type LatestOperationHandle, } from "./inject-latest-operation.js";
11
- export { injectCollectionViewport, type InjectCollectionViewportOptions } from "./inject-collection-viewport.js";
12
- export { injectQueryCollection, type InjectQueryCollectionOptions, type QueryCollectionHandle } from "./inject-query-collection.js";
13
- export { injectBridgeConnection, type BridgeConnectionHandle, type InjectBridgeConnectionOptions } from "./inject-bridge-connection.js";
14
- export { injectText, injectWindowLocale, RunicTextPipe, textLocaleSignal, type InjectTextOptions } from "./inject-text.js";
15
- export { injectAppearance, type InjectAppearanceOptions } from "./inject-appearance.js";
16
- export { injectRunicInstance, provideRunicInstance, RUNIC_INSTANCE, type InjectRunicInstanceOptions, } from "./instance.js";
17
- export { createRunicInstance, pageInstance, type RunicInstance, type RunicInstanceOptions } from "@runic-artifex/views";
18
- export { configureFieldErrorText, configureTranslatedText, fieldErrorText, resolveText, syncDocumentLocale, textDirection, windowLocale, type DocumentLocaleOptions, type FieldErrorArguments, type FieldErrorReason, type FieldErrorText, type TextReference, type TextTranslations, } from "@runic-artifex/views";
19
- export { appearance, onAppearance, type Appearance, type AppearanceColorScheme, type AppearanceContrast, type AppearanceSystemColors, type HostAppearance, } from "@runic-artifex/views";
20
- export { onBridgeConnection, type BridgeConnectionOptions, type BridgeConnectionState } from "@runic-artifex/views";
21
- export { upload, type BlobRef, type RunicBlob, type UploadOptions, type UploadProgress } from "@runic-artifex/views";
22
- export { regionEntries, selectedRegion, type RegionCollection, type RegionEntry, type RegionOutcome, type RegionSlot, } from "@runic-artifex/views";
23
- export { installBackNavigation, installNavigationPath, navigateBack, onNavigationPath, openNavigationPath, type NavigationPathChange, type NavigationPathOptions, type NavigationReply, } from "@runic-artifex/views";
24
- export { injectMenuBar, type InjectMenuBarOptions, type MenuBarEntry, type MenuBarHandle, type MenuBarInvokeResult, type MenuBarItem, type MenuBarMenu, type MenuBarRequest, type MenuBarSeparator, type MenuBarState, } from "./inject-menu-bar.js";
package/dist/esm/index.js DELETED
@@ -1,25 +0,0 @@
1
- export { ViewOutlet, RegionOutlets, RunicViewOutlet, } from "./view-outlet.js";
2
- export { injectView } from "./inject-view.js";
3
- export { injectViewResource } from "./inject-view-resource.js";
4
- export { injectCommand } from "./inject-command.js";
5
- export { injectOperation } from "./inject-operation.js";
6
- export { injectField } from "./inject-field.js";
7
- export { injectForm } from "./inject-form.js";
8
- export { commitAllFields } from "@runic-artifex/views";
9
- export { injectTextField } from "./inject-text-field.js";
10
- export { injectLatestOperation, } from "./inject-latest-operation.js";
11
- export { injectCollectionViewport } from "./inject-collection-viewport.js";
12
- export { injectQueryCollection } from "./inject-query-collection.js";
13
- export { injectBridgeConnection } from "./inject-bridge-connection.js";
14
- export { injectText, injectWindowLocale, RunicTextPipe, textLocaleSignal } from "./inject-text.js";
15
- export { injectAppearance } from "./inject-appearance.js";
16
- export { injectRunicInstance, provideRunicInstance, RUNIC_INSTANCE, } from "./instance.js";
17
- export { createRunicInstance, pageInstance } from "@runic-artifex/views";
18
- export { configureFieldErrorText, configureTranslatedText, fieldErrorText, resolveText, syncDocumentLocale, textDirection, windowLocale, } from "@runic-artifex/views";
19
- export { appearance, onAppearance, } from "@runic-artifex/views";
20
- export { onBridgeConnection } from "@runic-artifex/views";
21
- // blobs/1: uploads from the page and the blob values of state.
22
- export { upload } from "@runic-artifex/views";
23
- export { regionEntries, selectedRegion, } from "@runic-artifex/views";
24
- export { installBackNavigation, installNavigationPath, navigateBack, onNavigationPath, openNavigationPath, } from "@runic-artifex/views";
25
- export { injectMenuBar, } from "./inject-menu-bar.js";
@@ -1,19 +0,0 @@
1
- import { Injector, type Signal } from "@angular/core";
2
- import { type Appearance } from "@runic-artifex/views";
3
- /** Options of {@link injectAppearance}. */
4
- export interface InjectAppearanceOptions {
5
- /** The injector to use outside an injection context. */
6
- readonly injector?: Injector;
7
- }
8
- /**
9
- * The appearance of the injection context's Runic instance (`appearance` from `@runic-artifex/views`) as a signal for the lifetime of the injection
10
- * context: the colour scheme, contrast and reduced motion of the page's engine combined with the desktop's values that a
11
- * Runic host pushes (`appearance/1`), which also carry the text scale, the accent colour and the forced-colours palette.
12
- * Every member is `null` under server rendering.
13
- *
14
- * ```ts
15
- * readonly appearance = injectAppearance();
16
- * readonly animate = computed(() => this.appearance().reducedMotion !== true);
17
- * ```
18
- */
19
- export declare function injectAppearance({ injector: provided }?: InjectAppearanceOptions): Signal<Appearance>;
@@ -1,28 +0,0 @@
1
- import { assertInInjectionContext, DestroyRef, inject, Injector, PLATFORM_ID, signal } from "@angular/core";
2
- import { appearance, onAppearance, unknownAppearance } from "@runic-artifex/views";
3
- import { instanceOf } from "./instance.js";
4
- /**
5
- * The appearance of the injection context's Runic instance (`appearance` from `@runic-artifex/views`) as a signal for the lifetime of the injection
6
- * context: the colour scheme, contrast and reduced motion of the page's engine combined with the desktop's values that a
7
- * Runic host pushes (`appearance/1`), which also carry the text scale, the accent colour and the forced-colours palette.
8
- * Every member is `null` under server rendering.
9
- *
10
- * ```ts
11
- * readonly appearance = injectAppearance();
12
- * readonly animate = computed(() => this.appearance().reducedMotion !== true);
13
- * ```
14
- */
15
- export function injectAppearance({ injector: provided } = {}) {
16
- if (!provided)
17
- assertInInjectionContext(injectAppearance);
18
- const injector = provided ?? inject(Injector);
19
- if (injector.get(PLATFORM_ID, null) === "server")
20
- return signal(unknownAppearance).asReadonly();
21
- const instance = instanceOf(injector);
22
- const current = signal(instance.run(appearance), /* @ts-ignore */
23
- ...(ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []));
24
- const stop = instance.run(() => onAppearance(next => current.set(next)));
25
- injector.get(DestroyRef).onDestroy(stop);
26
- current.set(instance.run(appearance));
27
- return current.asReadonly();
28
- }
@@ -1,22 +0,0 @@
1
- import { Injector, type Signal } from "@angular/core";
2
- import { type BridgeConnectionOptions, type BridgeConnectionState } from "@runic-artifex/views";
3
- export interface BridgeConnectionHandle {
4
- /** The connection to the .NET host, as `onBridgeConnection` reports it. */
5
- readonly state: Signal<BridgeConnectionState>;
6
- }
7
- export interface InjectBridgeConnectionOptions extends BridgeConnectionOptions {
8
- /** Required outside an injection context. */
9
- readonly injector?: Injector;
10
- }
11
- /**
12
- * Follows the connection of the injection context's Runic instance to its .NET host (`connecting`, `connected`, `reconnecting`,
13
- * `lost` or `closed`) as a signal through `onBridgeConnection`, for the lifetime of the injection context.
14
- * Destruction unsubscribes. Under server rendering (`PLATFORM_ID` `"server"`) it does not
15
- * observe and stays `connecting`.
16
- *
17
- * ```ts
18
- * readonly connection = injectBridgeConnection();
19
- * // @if (connection.state() === "lost") { <p role="alert">The application stopped responding.</p> }
20
- * ```
21
- */
22
- export declare function injectBridgeConnection({ injector: provided, ...options }?: InjectBridgeConnectionOptions): BridgeConnectionHandle;