@texaryn/angular 0.0.0-stage → 0.3.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 (76) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +190 -0
  3. package/README.md +79 -2
  4. package/dist/components/document-node-renderer.d.ts +34 -0
  5. package/dist/components/document-node-renderer.d.ts.map +1 -0
  6. package/dist/components/document-node-renderer.js +190 -0
  7. package/dist/components/document-node-renderer.js.map +1 -0
  8. package/dist/components/document-root.d.ts +13 -0
  9. package/dist/components/document-root.d.ts.map +1 -0
  10. package/dist/components/document-root.js +36 -0
  11. package/dist/components/document-root.js.map +1 -0
  12. package/dist/components/error-summary.d.ts +21 -0
  13. package/dist/components/error-summary.d.ts.map +1 -0
  14. package/dist/components/error-summary.js +78 -0
  15. package/dist/components/error-summary.js.map +1 -0
  16. package/dist/components/form-root.d.ts +16 -0
  17. package/dist/components/form-root.d.ts.map +1 -0
  18. package/dist/components/form-root.js +54 -0
  19. package/dist/components/form-root.js.map +1 -0
  20. package/dist/components/node-renderer.d.ts +15 -0
  21. package/dist/components/node-renderer.d.ts.map +1 -0
  22. package/dist/components/node-renderer.js +35 -0
  23. package/dist/components/node-renderer.js.map +1 -0
  24. package/dist/context.d.ts +14 -0
  25. package/dist/context.d.ts.map +1 -0
  26. package/dist/context.js +6 -0
  27. package/dist/context.js.map +1 -0
  28. package/dist/document-context.d.ts +13 -0
  29. package/dist/document-context.d.ts.map +1 -0
  30. package/dist/document-context.js +6 -0
  31. package/dist/document-context.js.map +1 -0
  32. package/dist/field-props.d.ts +20 -0
  33. package/dist/field-props.d.ts.map +1 -0
  34. package/dist/field-props.js +32 -0
  35. package/dist/field-props.js.map +1 -0
  36. package/dist/form.d.ts +15 -0
  37. package/dist/form.d.ts.map +1 -0
  38. package/dist/form.js +26 -0
  39. package/dist/form.js.map +1 -0
  40. package/dist/index.d.ts +25 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +17 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/store.d.ts +6 -0
  45. package/dist/store.d.ts.map +1 -0
  46. package/dist/store.js +21 -0
  47. package/dist/store.js.map +1 -0
  48. package/dist/use-field-array.d.ts +17 -0
  49. package/dist/use-field-array.d.ts.map +1 -0
  50. package/dist/use-field-array.js +35 -0
  51. package/dist/use-field-array.js.map +1 -0
  52. package/dist/use-field-widget.d.ts +28 -0
  53. package/dist/use-field-widget.d.ts.map +1 -0
  54. package/dist/use-field-widget.js +81 -0
  55. package/dist/use-field-widget.js.map +1 -0
  56. package/dist/widget.d.ts +12 -0
  57. package/dist/widget.d.ts.map +1 -0
  58. package/dist/widget.js +2 -0
  59. package/dist/widget.js.map +1 -0
  60. package/dist/widgets/array-control.d.ts +26 -0
  61. package/dist/widgets/array-control.d.ts.map +1 -0
  62. package/dist/widgets/array-control.js +298 -0
  63. package/dist/widgets/array-control.js.map +1 -0
  64. package/dist/widgets/default-registry.d.ts +4 -0
  65. package/dist/widgets/default-registry.d.ts.map +1 -0
  66. package/dist/widgets/default-registry.js +12 -0
  67. package/dist/widgets/default-registry.js.map +1 -0
  68. package/dist/widgets/field.d.ts +19 -0
  69. package/dist/widgets/field.d.ts.map +1 -0
  70. package/dist/widgets/field.js +256 -0
  71. package/dist/widgets/field.js.map +1 -0
  72. package/dist/widgets/object-layout.d.ts +18 -0
  73. package/dist/widgets/object-layout.d.ts.map +1 -0
  74. package/dist/widgets/object-layout.js +115 -0
  75. package/dist/widgets/object-layout.js.map +1 -0
  76. package/package.json +65 -3
@@ -0,0 +1,78 @@
1
+ import { afterNextRender, ChangeDetectionStrategy, Component, computed, effect, ElementRef, inject, input, Injector, viewChild, } from '@angular/core';
2
+ import { createFailedSubmitTracker, englishMessages, visibleErrorLabel, visibleErrorMessages } from '@texaryn/core';
3
+ import { makeId } from '../field-props.js';
4
+ import * as i0 from "@angular/core";
5
+ export class ErrorSummary {
6
+ form = input.required(...(ngDevMode ? [{ debugName: "form" }] : []));
7
+ idPrefix = input.required(...(ngDevMode ? [{ debugName: "idPrefix" }] : []));
8
+ messages = input(undefined, ...(ngDevMode ? [{ debugName: "messages" }] : []));
9
+ focus = input(true, ...(ngDevMode ? [{ debugName: "focus" }] : []));
10
+ messageSet = computed(() => this.messages() ?? englishMessages, ...(ngDevMode ? [{ debugName: "messageSet" }] : []));
11
+ headingId = computed(() => makeId(this.idPrefix(), 'error-summary', 'heading'), ...(ngDevMode ? [{ debugName: "headingId" }] : []));
12
+ errorLabel = (entry) => visibleErrorLabel(entry, this.messageSet());
13
+ errorMessages = (entry) => visibleErrorMessages(entry, this.messageSet());
14
+ makeId = makeId;
15
+ injector = inject(Injector);
16
+ container = viewChild('container', ...(ngDevMode ? [{ debugName: "container" }] : []));
17
+ constructor() {
18
+ let tracker;
19
+ effect(() => {
20
+ const form = this.form();
21
+ const submission = form.submission();
22
+ const errors = form.visibleErrors();
23
+ if (!tracker) {
24
+ tracker = createFailedSubmitTracker(submission);
25
+ return;
26
+ }
27
+ if (!tracker.settle(submission, errors) || !this.focus())
28
+ return;
29
+ afterNextRender({
30
+ write: () => this.container()?.nativeElement.focus(),
31
+ }, { injector: this.injector });
32
+ });
33
+ }
34
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: ErrorSummary, deps: [], target: i0.ɵɵFactoryTarget.Component });
35
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.33", type: ErrorSummary, isStandalone: true, selector: "texaryn-error-summary", inputs: { form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, idPrefix: { classPropertyName: "idPrefix", publicName: "idPrefix", isSignal: true, isRequired: true, transformFunction: null }, messages: { classPropertyName: "messages", publicName: "messages", isSignal: true, isRequired: false, transformFunction: null }, focus: { classPropertyName: "focus", publicName: "focus", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: `
36
+ @if (form().visibleErrors().length > 0) {
37
+ <div
38
+ #container
39
+ role="group"
40
+ tabindex="-1"
41
+ [attr.aria-labelledby]="headingId()"
42
+ >
43
+ <h2 [id]="headingId()">{{ messageSet().errorSummaryHeading({ count: form().visibleErrors().length }) }}</h2>
44
+ <ul>
45
+ @for (entry of form().visibleErrors(); track entry.nodeId) {
46
+ <li><a [attr.href]="'#' + makeId(idPrefix(), entry.nodeId, 'input')">{{ errorLabel(entry) }}</a>{{ messageSet().errorSummaryDetail({ messages: errorMessages(entry) }) }}</li>
47
+ }
48
+ </ul>
49
+ </div>
50
+ }
51
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
52
+ }
53
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: ErrorSummary, decorators: [{
54
+ type: Component,
55
+ args: [{
56
+ selector: 'texaryn-error-summary',
57
+ standalone: true,
58
+ changeDetection: ChangeDetectionStrategy.OnPush,
59
+ template: `
60
+ @if (form().visibleErrors().length > 0) {
61
+ <div
62
+ #container
63
+ role="group"
64
+ tabindex="-1"
65
+ [attr.aria-labelledby]="headingId()"
66
+ >
67
+ <h2 [id]="headingId()">{{ messageSet().errorSummaryHeading({ count: form().visibleErrors().length }) }}</h2>
68
+ <ul>
69
+ @for (entry of form().visibleErrors(); track entry.nodeId) {
70
+ <li><a [attr.href]="'#' + makeId(idPrefix(), entry.nodeId, 'input')">{{ errorLabel(entry) }}</a>{{ messageSet().errorSummaryDetail({ messages: errorMessages(entry) }) }}</li>
71
+ }
72
+ </ul>
73
+ </div>
74
+ }
75
+ `,
76
+ }]
77
+ }], ctorParameters: () => [], propDecorators: { form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: true }] }], idPrefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "idPrefix", required: true }] }], messages: [{ type: i0.Input, args: [{ isSignal: true, alias: "messages", required: false }] }], focus: [{ type: i0.Input, args: [{ isSignal: true, alias: "focus", required: false }] }], container: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }] } });
78
+ //# sourceMappingURL=error-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-summary.js","sourceRoot":"","sources":["../../src/components/error-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAEnH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;;AAwB1C,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,KAAK,CAAC,QAAQ,+CAAe,CAAA;IACpC,QAAQ,GAAG,KAAK,CAAC,QAAQ,mDAAU,CAAA;IACnC,QAAQ,GAAG,KAAK,CAA2B,SAAS,oDAAC,CAAA;IACrD,KAAK,GAAG,KAAK,CAAC,IAAI,iDAAC,CAAA;IACnB,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,eAAe,sDAAC,CAAA;IAC/D,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,eAAe,EAAE,SAAS,CAAC,qDAAC,CAAA;IAC/E,UAAU,GAAG,CAAC,KAAmB,EAAU,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IACzF,aAAa,GAAG,CAAC,KAAmB,EAAY,EAAE,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IACjG,MAAM,GAAG,MAAM,CAAA;IACP,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC3B,SAAS,GAAG,SAAS,CAA6B,WAAW,qDAAC,CAAA;IAE/E;QACE,IAAI,OAAiE,CAAA;QACrE,MAAM,CAAC,GAAG,EAAE;YACV,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;YACxB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAA;gBAC/C,OAAM;YACR,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBAAE,OAAM;YAChE,eAAe,CAAC;gBACd,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,KAAK,EAAE;aACrD,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;IACJ,CAAC;wGA5BU,YAAY;4FAAZ,YAAY,ksBAlBb;;;;;;;;;;;;;;;;GAgBT;;4FAEU,YAAY;kBAtBxB,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,UAAU,EAAE,IAAI;oBAChB,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,QAAQ,EAAE;;;;;;;;;;;;;;;;GAgBT;iBACF;idAYoE,WAAW"}
@@ -0,0 +1,16 @@
1
+ import type { FormMessages, RendererRegistry } from '@texaryn/core';
2
+ import type { FormContext } from '../context.js';
3
+ import type { AngularForm } from '../form.js';
4
+ import type { WidgetComponent } from '../widget.js';
5
+ import * as i0 from "@angular/core";
6
+ export declare class FormRoot implements FormContext {
7
+ readonly form: import("@angular/core").InputSignal<AngularForm>;
8
+ readonly registry: import("@angular/core").InputSignal<RendererRegistry<WidgetComponent, import("@texaryn/core").UINode>>;
9
+ readonly messages: import("@angular/core").InputSignal<FormMessages | undefined>;
10
+ readonly idPrefix: import("@angular/core").InputSignal<string>;
11
+ readonly showErrorSummary: import("@angular/core").InputSignal<boolean>;
12
+ readonly summaryFocus: import("@angular/core").InputSignal<boolean>;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormRoot, never>;
14
+ static ɵcmp: i0.ɵɵComponentDeclaration<FormRoot, "texaryn-form-root", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "registry": { "alias": "registry"; "required": true; "isSignal": true; }; "messages": { "alias": "messages"; "required": false; "isSignal": true; }; "idPrefix": { "alias": "idPrefix"; "required": true; "isSignal": true; }; "showErrorSummary": { "alias": "showErrorSummary"; "required": false; "isSignal": true; }; "summaryFocus": { "alias": "summaryFocus"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
15
+ }
16
+ //# sourceMappingURL=form-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-root.d.ts","sourceRoot":"","sources":["../../src/components/form-root.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;;AAInD,qBAsBa,QAAS,YAAW,WAAW;IAC1C,QAAQ,CAAC,IAAI,mDAAgC;IAC7C,QAAQ,CAAC,QAAQ,yGAAsD;IACvE,QAAQ,CAAC,QAAQ,gEAA6C;IAC9D,QAAQ,CAAC,QAAQ,8CAA2B;IAC5C,QAAQ,CAAC,gBAAgB,+CAAe;IACxC,QAAQ,CAAC,YAAY,+CAAc;yCANxB,QAAQ;2CAAR,QAAQ;CAOpB"}
@@ -0,0 +1,54 @@
1
+ import { ChangeDetectionStrategy, Component, forwardRef, input, } from '@angular/core';
2
+ import { FORM_CONTEXT } from '../context.js';
3
+ import { ErrorSummary } from './error-summary.js';
4
+ import { NodeRenderer } from './node-renderer.js';
5
+ import * as i0 from "@angular/core";
6
+ /** Renders the UI document tree. The consumer owns any native form element and submit handler. */
7
+ export class FormRoot {
8
+ form = input.required(...(ngDevMode ? [{ debugName: "form" }] : []));
9
+ registry = input.required(...(ngDevMode ? [{ debugName: "registry" }] : []));
10
+ messages = input(undefined, ...(ngDevMode ? [{ debugName: "messages" }] : []));
11
+ idPrefix = input.required(...(ngDevMode ? [{ debugName: "idPrefix" }] : []));
12
+ showErrorSummary = input(false, ...(ngDevMode ? [{ debugName: "showErrorSummary" }] : []));
13
+ summaryFocus = input(true, ...(ngDevMode ? [{ debugName: "summaryFocus" }] : []));
14
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: FormRoot, deps: [], target: i0.ɵɵFactoryTarget.Component });
15
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.33", type: FormRoot, isStandalone: true, selector: "texaryn-form-root", inputs: { form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, registry: { classPropertyName: "registry", publicName: "registry", isSignal: true, isRequired: true, transformFunction: null }, messages: { classPropertyName: "messages", publicName: "messages", isSignal: true, isRequired: false, transformFunction: null }, idPrefix: { classPropertyName: "idPrefix", publicName: "idPrefix", isSignal: true, isRequired: true, transformFunction: null }, showErrorSummary: { classPropertyName: "showErrorSummary", publicName: "showErrorSummary", isSignal: true, isRequired: false, transformFunction: null }, summaryFocus: { classPropertyName: "summaryFocus", publicName: "summaryFocus", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: FORM_CONTEXT, useExisting: forwardRef(() => FormRoot) }], ngImport: i0, template: `
16
+ @if (showErrorSummary()) {
17
+ <texaryn-error-summary
18
+ [form]="form()"
19
+ [idPrefix]="idPrefix()"
20
+ [messages]="messages()"
21
+ [focus]="summaryFocus()"
22
+ />
23
+ }
24
+ @let document = form().document();
25
+ @if (document.nodes[document.rootId]; as root) {
26
+ <texaryn-node-renderer [node]="root" />
27
+ }
28
+ `, isInline: true, dependencies: [{ kind: "component", type: ErrorSummary, selector: "texaryn-error-summary", inputs: ["form", "idPrefix", "messages", "focus"] }, { kind: "component", type: NodeRenderer, selector: "texaryn-node-renderer", inputs: ["node"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
29
+ }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: FormRoot, decorators: [{
31
+ type: Component,
32
+ args: [{
33
+ selector: 'texaryn-form-root',
34
+ standalone: true,
35
+ imports: [ErrorSummary, NodeRenderer],
36
+ providers: [{ provide: FORM_CONTEXT, useExisting: forwardRef(() => FormRoot) }],
37
+ changeDetection: ChangeDetectionStrategy.OnPush,
38
+ template: `
39
+ @if (showErrorSummary()) {
40
+ <texaryn-error-summary
41
+ [form]="form()"
42
+ [idPrefix]="idPrefix()"
43
+ [messages]="messages()"
44
+ [focus]="summaryFocus()"
45
+ />
46
+ }
47
+ @let document = form().document();
48
+ @if (document.nodes[document.rootId]; as root) {
49
+ <texaryn-node-renderer [node]="root" />
50
+ }
51
+ `,
52
+ }]
53
+ }], propDecorators: { form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: true }] }], registry: [{ type: i0.Input, args: [{ isSignal: true, alias: "registry", required: true }] }], messages: [{ type: i0.Input, args: [{ isSignal: true, alias: "messages", required: false }] }], idPrefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "idPrefix", required: true }] }], showErrorSummary: [{ type: i0.Input, args: [{ isSignal: true, alias: "showErrorSummary", required: false }] }], summaryFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "summaryFocus", required: false }] }] } });
54
+ //# sourceMappingURL=form-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-root.js","sourceRoot":"","sources":["../../src/components/form-root.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,KAAK,GACN,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;;AAuBjD,kGAAkG;AAClG,MAAM,OAAO,QAAQ;IACV,IAAI,GAAG,KAAK,CAAC,QAAQ,+CAAe,CAAA;IACpC,QAAQ,GAAG,KAAK,CAAC,QAAQ,mDAAqC,CAAA;IAC9D,QAAQ,GAAG,KAAK,CAA2B,SAAS,oDAAC,CAAA;IACrD,QAAQ,GAAG,KAAK,CAAC,QAAQ,mDAAU,CAAA;IACnC,gBAAgB,GAAG,KAAK,CAAC,KAAK,4DAAC,CAAA;IAC/B,YAAY,GAAG,KAAK,CAAC,IAAI,wDAAC,CAAA;wGANxB,QAAQ;4FAAR,QAAQ,u2BAlBR,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,0BAErE;;;;;;;;;;;;;GAaT,4DAhBS,YAAY,qHAAE,YAAY;;4FAmBzB,QAAQ;kBAtBpB,SAAS;mBAAC;oBACT,QAAQ,EAAE,mBAAmB;oBAC7B,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC;oBAC/E,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,QAAQ,EAAE;;;;;;;;;;;;;GAaT;iBACF"}
@@ -0,0 +1,15 @@
1
+ import type { Type } from '@angular/core';
2
+ import type { UINode } from '@texaryn/core';
3
+ import type { AngularWidget } from '../widget.js';
4
+ import * as i0 from "@angular/core";
5
+ export declare class NodeRenderer {
6
+ readonly node: import("@angular/core").InputSignal<UINode>;
7
+ private readonly context;
8
+ readonly component: import("@angular/core").Signal<Type<AngularWidget> | undefined>;
9
+ readonly componentInputs: import("@angular/core").Signal<{
10
+ node: UINode;
11
+ }>;
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<NodeRenderer, never>;
13
+ static ɵcmp: i0.ɵɵComponentDeclaration<NodeRenderer, "texaryn-node-renderer", never, { "node": { "alias": "node"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
14
+ }
15
+ //# sourceMappingURL=node-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-renderer.d.ts","sourceRoot":"","sources":["../../src/components/node-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;;AAEjD,qBAaa,YAAY;IACvB,QAAQ,CAAC,IAAI,8CAA2B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,QAAQ,CAAC,SAAS,kEAEjB;IACD,QAAQ,CAAC,eAAe;;OAA0C;yCANvD,YAAY;2CAAZ,YAAY;CAOxB"}
@@ -0,0 +1,35 @@
1
+ import { NgComponentOutlet } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
3
+ import { useFormContext } from '../context.js';
4
+ import * as i0 from "@angular/core";
5
+ export class NodeRenderer {
6
+ node = input.required(...(ngDevMode ? [{ debugName: "node" }] : []));
7
+ context = useFormContext();
8
+ component = computed(() => this.context.registry().resolve(this.node()), ...(ngDevMode ? [{ debugName: "component" }] : []));
9
+ componentInputs = computed(() => ({ node: this.node() }), ...(ngDevMode ? [{ debugName: "componentInputs" }] : []));
10
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: NodeRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
11
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.33", type: NodeRenderer, isStandalone: true, selector: "texaryn-node-renderer", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
12
+ @if (node().visible) {
13
+ @if (component(); as selected) {
14
+ <ng-container *ngComponentOutlet="selected; inputs: componentInputs()" />
15
+ }
16
+ }
17
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
18
+ }
19
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: NodeRenderer, decorators: [{
20
+ type: Component,
21
+ args: [{
22
+ selector: 'texaryn-node-renderer',
23
+ standalone: true,
24
+ imports: [NgComponentOutlet],
25
+ changeDetection: ChangeDetectionStrategy.OnPush,
26
+ template: `
27
+ @if (node().visible) {
28
+ @if (component(); as selected) {
29
+ <ng-container *ngComponentOutlet="selected; inputs: componentInputs()" />
30
+ }
31
+ }
32
+ `,
33
+ }]
34
+ }], propDecorators: { node: [{ type: i0.Input, args: [{ isSignal: true, alias: "node", required: true }] }] } });
35
+ //# sourceMappingURL=node-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-renderer.js","sourceRoot":"","sources":["../../src/components/node-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAG3F,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;;AAgB9C,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,KAAK,CAAC,QAAQ,+CAAU,CAAA;IACvB,OAAO,GAAG,cAAc,EAAE,CAAA;IAClC,SAAS,GAAG,QAAQ,CAAkC,GAAG,EAAE,CAClE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,qDAC7C,CAAA;IACQ,eAAe,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,2DAAC,CAAA;wGANvD,YAAY;4FAAZ,YAAY,iNARb;;;;;;GAMT,4DARS,iBAAiB;;4FAUhB,YAAY;kBAbxB,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,CAAC,iBAAiB,CAAC;oBAC5B,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,QAAQ,EAAE;;;;;;GAMT;iBACF"}
@@ -0,0 +1,14 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import type { Signal } from '@angular/core';
3
+ import type { FormMessages, RendererRegistry } from '@texaryn/core';
4
+ import type { AngularForm } from './form.js';
5
+ import type { WidgetComponent } from './widget.js';
6
+ export interface FormContext {
7
+ readonly form: Signal<AngularForm>;
8
+ readonly registry: Signal<RendererRegistry<WidgetComponent>>;
9
+ readonly messages: Signal<FormMessages | undefined>;
10
+ readonly idPrefix: Signal<string>;
11
+ }
12
+ export declare const FORM_CONTEXT: InjectionToken<FormContext>;
13
+ export declare function useFormContext(): FormContext;
14
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAA;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC,CAAA;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CAClC;AAED,eAAO,MAAM,YAAY,6BAAkE,CAAA;AAE3F,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
@@ -0,0 +1,6 @@
1
+ import { inject, InjectionToken } from '@angular/core';
2
+ export const FORM_CONTEXT = new InjectionToken('texaryn.angular.form-context');
3
+ export function useFormContext() {
4
+ return inject(FORM_CONTEXT);
5
+ }
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAatD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,cAAc,CAAc,8BAA8B,CAAC,CAAA;AAE3F,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,YAAY,CAAC,CAAA;AAC7B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import type { Signal, Type } from '@angular/core';
3
+ import type { DocumentNode, DocumentRuntime, RendererRegistry, UIDocumentV2 } from '@texaryn/core';
4
+ import type { AngularDocumentWidget } from './widget.js';
5
+ export interface AngularDocumentContext {
6
+ readonly runtime: Signal<DocumentRuntime>;
7
+ readonly document: Signal<UIDocumentV2>;
8
+ readonly registry: Signal<RendererRegistry<Type<AngularDocumentWidget>, DocumentNode> | undefined>;
9
+ readonly onActionError: Signal<((error: unknown) => void) | undefined>;
10
+ }
11
+ export declare const DOCUMENT_CONTEXT: InjectionToken<AngularDocumentContext>;
12
+ export declare function useDocumentContext(): AngularDocumentContext;
13
+ //# sourceMappingURL=document-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-context.d.ts","sourceRoot":"","sources":["../src/document-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAClG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,eAAe,CAAC,CAAA;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,YAAY,CAAC,GAAG,SAAS,CAAC,CAAA;IAClG,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,CAAA;CACvE;AAED,eAAO,MAAM,gBAAgB,wCAAiF,CAAA;AAE9G,wBAAgB,kBAAkB,IAAI,sBAAsB,CAE3D"}
@@ -0,0 +1,6 @@
1
+ import { inject, InjectionToken } from '@angular/core';
2
+ export const DOCUMENT_CONTEXT = new InjectionToken('texaryn.angular.document-context');
3
+ export function useDocumentContext() {
4
+ return inject(DOCUMENT_CONTEXT);
5
+ }
6
+ //# sourceMappingURL=document-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-context.js","sourceRoot":"","sources":["../src/document-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAYtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,cAAc,CAAyB,kCAAkC,CAAC,CAAA;AAE9G,MAAM,UAAU,kBAAkB;IAChC,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAA;AACjC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { FieldNode, FormMessages, ValidationError } from '@texaryn/core';
2
+ export interface FieldAria {
3
+ id: string;
4
+ name: string;
5
+ disabled: boolean;
6
+ readonly?: boolean;
7
+ 'aria-readonly'?: true;
8
+ 'aria-required': boolean;
9
+ 'aria-invalid'?: boolean;
10
+ 'aria-describedby'?: string;
11
+ placeholder?: string;
12
+ }
13
+ export declare function makeId(idPrefix: string, nodeId: string, suffix: string): string;
14
+ export declare function fieldAria(node: FieldNode, state: {
15
+ disabled: boolean;
16
+ showErrors: boolean;
17
+ errors: readonly ValidationError[];
18
+ }, idPrefix: string, nativeReadOnly?: boolean): FieldAria;
19
+ export declare function fieldLabel(node: FieldNode, messages?: FormMessages): string;
20
+ //# sourceMappingURL=field-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-props.d.ts","sourceRoot":"","sources":["../src/field-props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE7E,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,CAAC,EAAE,IAAI,CAAA;IACtB,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,EACrF,QAAQ,EAAE,MAAM,EAChB,cAAc,UAAO,GACpB,SAAS,CAyBX;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,GAAE,YAA8B,GAAG,MAAM,CAE5F"}
@@ -0,0 +1,32 @@
1
+ import { englishMessages, visibleFieldLabel } from '@texaryn/core';
2
+ export function makeId(idPrefix, nodeId, suffix) {
3
+ return `${idPrefix}-${nodeId}-${suffix}`;
4
+ }
5
+ export function fieldAria(node, state, idPrefix, nativeReadOnly = true) {
6
+ const describedBy = [];
7
+ if (node.helpText ?? node.annotations.description) {
8
+ describedBy.push(makeId(idPrefix, node.id, 'description'));
9
+ }
10
+ const invalid = state.showErrors && state.errors.length > 0;
11
+ if (invalid)
12
+ describedBy.push(makeId(idPrefix, node.id, 'error'));
13
+ const readOnly = node.readOnly
14
+ ? nativeReadOnly
15
+ ? { readonly: true }
16
+ : { 'aria-readonly': true }
17
+ : {};
18
+ return {
19
+ id: makeId(idPrefix, node.id, 'input'),
20
+ name: node.dataPointer || node.id,
21
+ disabled: state.disabled,
22
+ ...readOnly,
23
+ 'aria-required': Boolean(node.constraints.required),
24
+ 'aria-invalid': invalid ? true : undefined,
25
+ 'aria-describedby': describedBy.length > 0 ? describedBy.join(' ') : undefined,
26
+ placeholder: node.placeholder ?? undefined,
27
+ };
28
+ }
29
+ export function fieldLabel(node, messages = englishMessages) {
30
+ return visibleFieldLabel(node.annotations.title, node.dataPointer, messages);
31
+ }
32
+ //# sourceMappingURL=field-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-props.js","sourceRoot":"","sources":["../src/field-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAelE,MAAM,UAAU,MAAM,CAAC,QAAgB,EAAE,MAAc,EAAE,MAAc;IACrE,OAAO,GAAG,QAAQ,IAAI,MAAM,IAAI,MAAM,EAAE,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,IAAe,EACf,KAAqF,EACrF,QAAgB,EAChB,cAAc,GAAG,IAAI;IAErB,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAClD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC,CAAA;IAC5D,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IAC3D,IAAI,OAAO;QAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAA;IAEjE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC5B,CAAC,CAAC,cAAc;YACd,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;YACpB,CAAC,CAAC,EAAE,eAAe,EAAE,IAAa,EAAE;QACtC,CAAC,CAAC,EAAE,CAAA;IAEN,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC;QACtC,IAAI,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,EAAE;QACjC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,GAAG,QAAQ;QACX,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;QACnD,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAC1C,kBAAkB,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAC9E,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;KAC3C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAe,EAAE,WAAyB,eAAe;IAClF,OAAO,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;AAC9E,CAAC"}
package/dist/form.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { DestroyRef } from '@angular/core';
2
+ import type { Signal } from '@angular/core';
3
+ import type { Command, FormRuntime, FormRuntimeOptions, NodeId, NodeState, SchemaEvaluationPort, SubmissionState, UIDocument, VisibleError } from '@texaryn/core';
4
+ export interface AngularForm {
5
+ runtime: FormRuntime;
6
+ document: Signal<UIDocument>;
7
+ data: Signal<unknown>;
8
+ submission: Signal<SubmissionState>;
9
+ visibleErrors: Signal<VisibleError[]>;
10
+ dispatch(command: Command): void;
11
+ getNodeState(nodeId: NodeId): NodeState | undefined;
12
+ }
13
+ export declare function createForm(port: SchemaEvaluationPort, options?: FormRuntimeOptions): AngularForm;
14
+ export declare function bindFormRuntime(runtime: FormRuntime, owner?: DestroyRef, destroyRuntime?: boolean): AngularForm;
15
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAU,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,YAAY,EACb,MAAM,eAAe,CAAA;AAGtB,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,WAAW,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACrB,UAAU,EAAE,MAAM,CAAC,eAAe,CAAC,CAAA;IACnC,aAAa,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IAChC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;CACpD;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,WAAW,CAIb;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EACpB,KAAK,GAAE,UAA+B,EACtC,cAAc,UAAQ,GACrB,WAAW,CAgBb"}
package/dist/form.js ADDED
@@ -0,0 +1,26 @@
1
+ import { DestroyRef, inject } from '@angular/core';
2
+ import { createFormRuntime } from '@texaryn/core';
3
+ import { useStore } from './store.js';
4
+ export function createForm(port, options) {
5
+ const destroyRef = inject(DestroyRef);
6
+ const runtime = createFormRuntime(port, options);
7
+ return bindFormRuntime(runtime, destroyRef, true);
8
+ }
9
+ export function bindFormRuntime(runtime, owner = inject(DestroyRef), destroyRuntime = false) {
10
+ const document = useStore(runtime.document, owner);
11
+ const data = useStore(runtime.data, owner);
12
+ const submission = useStore(runtime.submission, owner);
13
+ const visibleErrors = useStore(runtime.visibleErrors, owner);
14
+ if (destroyRuntime)
15
+ owner.onDestroy(() => runtime.destroy());
16
+ return {
17
+ runtime,
18
+ document,
19
+ data,
20
+ submission,
21
+ visibleErrors,
22
+ dispatch: (command) => runtime.dispatch(command),
23
+ getNodeState: (nodeId) => runtime.getNodeState(nodeId),
24
+ };
25
+ }
26
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAYjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAYrC,MAAM,UAAU,UAAU,CACxB,IAA0B,EAC1B,OAA4B;IAE5B,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;IACrC,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAChD,OAAO,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAAoB,EACpB,QAAoB,MAAM,CAAC,UAAU,CAAC,EACtC,cAAc,GAAG,KAAK;IAEtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC1C,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACtD,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;IAC5D,IAAI,cAAc;QAAE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAE5D,OAAO;QACL,OAAO;QACP,QAAQ;QACR,IAAI;QACJ,UAAU;QACV,aAAa;QACb,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAChD,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC;KACvD,CAAA;AACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ export { bindFormRuntime, createForm } from './form.js';
2
+ export type { AngularForm } from './form.js';
3
+ export { useStore, useDynamicStore } from './store.js';
4
+ export { FORM_CONTEXT, useFormContext } from './context.js';
5
+ export type { FormContext } from './context.js';
6
+ export { fieldAria, fieldLabel, makeId } from './field-props.js';
7
+ export type { FieldAria } from './field-props.js';
8
+ export { fieldKind, displayValue, coerce, useFieldWidget } from './use-field-widget.js';
9
+ export type { FieldKind, FieldWidget } from './use-field-widget.js';
10
+ export { useFieldArray } from './use-field-array.js';
11
+ export type { FieldArrayBinding, FieldArrayItem } from './use-field-array.js';
12
+ export type { AngularWidget, WidgetComponent } from './widget.js';
13
+ export { FormRoot } from './components/form-root.js';
14
+ export { DocumentRoot } from './components/document-root.js';
15
+ export { DocumentNodeRenderer, DocumentListView, DocumentTableView } from './components/document-node-renderer.js';
16
+ export { DOCUMENT_CONTEXT, useDocumentContext } from './document-context.js';
17
+ export type { AngularDocumentContext } from './document-context.js';
18
+ export type { AngularDocumentWidget, DocumentWidgetComponent } from './widget.js';
19
+ export { NodeRenderer } from './components/node-renderer.js';
20
+ export { ErrorSummary } from './components/error-summary.js';
21
+ export { FieldWidgetComponent } from './widgets/field.js';
22
+ export { ObjectLayout } from './widgets/object-layout.js';
23
+ export { ArrayControl } from './widgets/array-control.js';
24
+ export { createDefaultRegistry } from './widgets/default-registry.js';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAChE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACvF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC7E,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAClH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AACnE,YAAY,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ export { bindFormRuntime, createForm } from './form.js';
2
+ export { useStore, useDynamicStore } from './store.js';
3
+ export { FORM_CONTEXT, useFormContext } from './context.js';
4
+ export { fieldAria, fieldLabel, makeId } from './field-props.js';
5
+ export { fieldKind, displayValue, coerce, useFieldWidget } from './use-field-widget.js';
6
+ export { useFieldArray } from './use-field-array.js';
7
+ export { FormRoot } from './components/form-root.js';
8
+ export { DocumentRoot } from './components/document-root.js';
9
+ export { DocumentNodeRenderer, DocumentListView, DocumentTableView } from './components/document-node-renderer.js';
10
+ export { DOCUMENT_CONTEXT, useDocumentContext } from './document-context.js';
11
+ export { NodeRenderer } from './components/node-renderer.js';
12
+ export { ErrorSummary } from './components/error-summary.js';
13
+ export { FieldWidgetComponent } from './widgets/field.js';
14
+ export { ObjectLayout } from './widgets/object-layout.js';
15
+ export { ArrayControl } from './widgets/array-control.js';
16
+ export { createDefaultRegistry } from './widgets/default-registry.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAClH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { DestroyRef } from '@angular/core';
2
+ import type { Signal } from '@angular/core';
3
+ import type { Store } from '@texaryn/core';
4
+ export declare function useStore<T>(store: Store<T>, owner?: DestroyRef): Signal<T>;
5
+ export declare function useDynamicStore<T>(source: () => Store<T> | undefined, fallback: T): Signal<T>;
6
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,GAAE,UAA+B,GAAG,MAAM,CAAC,CAAC,CAAC,CAK9F;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAe7F"}
package/dist/store.js ADDED
@@ -0,0 +1,21 @@
1
+ import { DestroyRef, effect, inject, signal } from '@angular/core';
2
+ export function useStore(store, owner = inject(DestroyRef)) {
3
+ const value = signal(store.getSnapshot(), ...(ngDevMode ? [{ debugName: "value" }] : []));
4
+ const unsubscribe = store.subscribe(() => value.set(store.getSnapshot()));
5
+ owner.onDestroy(unsubscribe);
6
+ return value.asReadonly();
7
+ }
8
+ export function useDynamicStore(source, fallback) {
9
+ const value = signal(fallback, ...(ngDevMode ? [{ debugName: "value" }] : []));
10
+ effect((onCleanup) => {
11
+ const store = source();
12
+ if (!store) {
13
+ value.set(fallback);
14
+ return;
15
+ }
16
+ value.set(store.getSnapshot());
17
+ onCleanup(store.subscribe(() => value.set(store.getSnapshot())));
18
+ });
19
+ return value.asReadonly();
20
+ }
21
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAIlE,MAAM,UAAU,QAAQ,CAAI,KAAe,EAAE,QAAoB,MAAM,CAAC,UAAU,CAAC;IACjF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,iDAAC,CAAA;IACzC,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IACzE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAC5B,OAAO,KAAK,CAAC,UAAU,EAAE,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,eAAe,CAAI,MAAkC,EAAE,QAAW;IAChF,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,iDAAC,CAAA;IAE9B,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;QACnB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACnB,OAAM;QACR,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;QAC9B,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAC,UAAU,EAAE,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Signal } from '@angular/core';
2
+ import type { NodeId, StableItemId } from '@texaryn/core';
3
+ export interface FieldArrayItem {
4
+ id: StableItemId;
5
+ nodeId: NodeId | undefined;
6
+ }
7
+ export interface FieldArrayBinding {
8
+ items: Signal<FieldArrayItem[]>;
9
+ canAdd: Signal<boolean>;
10
+ canRemove: Signal<boolean>;
11
+ canReorder: Signal<boolean>;
12
+ add(value?: unknown): void;
13
+ remove(index: number): void;
14
+ move(from: number, to: number): void;
15
+ }
16
+ export declare function useFieldArray(nodeId: () => NodeId): FieldArrayBinding;
17
+ //# sourceMappingURL=use-field-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-array.d.ts","sourceRoot":"","sources":["../src/use-field-array.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAiB,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGxE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,YAAY,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACvB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAC3B,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CACrC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,MAAM,GAAG,iBAAiB,CA+BrE"}
@@ -0,0 +1,35 @@
1
+ import { computed } from '@angular/core';
2
+ import { useFormContext } from './context.js';
3
+ export function useFieldArray(nodeId) {
4
+ const context = useFormContext();
5
+ const form = computed(() => context.form(), ...(ngDevMode ? [{ debugName: "form" }] : []));
6
+ const container = computed(() => {
7
+ const document = form().document();
8
+ const node = document.nodes[nodeId()];
9
+ return node?.type === 'container' && node.containerType === 'array'
10
+ ? node
11
+ : undefined;
12
+ }, ...(ngDevMode ? [{ debugName: "container" }] : []));
13
+ const items = computed(() => {
14
+ const current = container();
15
+ const meta = current?.arrayMeta;
16
+ if (!meta)
17
+ return [];
18
+ return meta.itemIds.map((id, index) => ({ id, nodeId: current.children[index] }));
19
+ }, ...(ngDevMode ? [{ debugName: "items" }] : []));
20
+ return {
21
+ items,
22
+ canAdd: computed(() => container()?.arrayMeta?.canAdd ?? false),
23
+ canRemove: computed(() => container()?.arrayMeta?.canRemove ?? false),
24
+ canReorder: computed(() => container()?.arrayMeta?.canReorder ?? false),
25
+ add: (value) => form().dispatch({
26
+ type: 'InsertItem',
27
+ containerId: nodeId(),
28
+ index: items().length,
29
+ value,
30
+ }),
31
+ remove: (index) => form().dispatch({ type: 'RemoveItem', containerId: nodeId(), index }),
32
+ move: (from, to) => form().dispatch({ type: 'MoveItem', containerId: nodeId(), from, to }),
33
+ };
34
+ }
35
+ //# sourceMappingURL=use-field-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-array.js","sourceRoot":"","sources":["../src/use-field-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAiB7C,MAAM,UAAU,aAAa,CAAC,MAAoB;IAChD,MAAM,OAAO,GAAG,cAAc,EAAE,CAAA;IAChC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,gDAAC,CAAA;IAC3C,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC9B,MAAM,QAAQ,GAAG,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAA;QAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;QACrC,OAAO,IAAI,EAAE,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO;YACjE,CAAC,CAAC,IAAqB;YACvB,CAAC,CAAC,SAAS,CAAA;IACf,CAAC,qDAAC,CAAA;IACF,MAAM,KAAK,GAAG,QAAQ,CAAmB,GAAG,EAAE;QAC5C,MAAM,OAAO,GAAG,SAAS,EAAE,CAAA;QAC3B,MAAM,IAAI,GAAG,OAAO,EAAE,SAAS,CAAA;QAC/B,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAA;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IACnF,CAAC,iDAAC,CAAA;IAEF,OAAO;QACL,KAAK;QACL,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,IAAI,KAAK,CAAC;QAC/D,SAAS,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,SAAS,IAAI,KAAK,CAAC;QACrE,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,UAAU,IAAI,KAAK,CAAC;QACvE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC;YAC9B,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,MAAM,EAAE;YACrB,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM;YACrB,KAAK;SACN,CAAC;QACF,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC;QACxF,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KAC3F,CAAA;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Signal } from '@angular/core';
2
+ import type { FieldNode, FormMessages, ValidationError } from '@texaryn/core';
3
+ import type { FieldAria } from './field-props.js';
4
+ import type { AngularWidget } from './widget.js';
5
+ export type FieldKind = 'enum' | 'boolean' | 'number' | 'string';
6
+ export declare function fieldKind(node: FieldNode): FieldKind;
7
+ export declare function displayValue(kind: FieldKind, value: unknown): string | number;
8
+ export declare function coerce(kind: FieldKind, node: FieldNode, raw: string): unknown;
9
+ export interface FieldWidget {
10
+ node: Signal<FieldNode>;
11
+ kind: Signal<FieldKind>;
12
+ value: Signal<unknown>;
13
+ display: Signal<string | number>;
14
+ label: Signal<string>;
15
+ description: Signal<string | undefined>;
16
+ descriptionId: Signal<string>;
17
+ errorId: Signal<string>;
18
+ labelFor: Signal<string>;
19
+ aria: Signal<FieldAria>;
20
+ messages: Signal<FormMessages>;
21
+ errors: Signal<readonly ValidationError[]>;
22
+ invalid: Signal<boolean>;
23
+ setRaw(raw: string): void;
24
+ setValue(value: unknown): void;
25
+ onBlur(): void;
26
+ }
27
+ export declare function useFieldWidget(nodeSource: AngularWidget['node']): FieldWidget;
28
+ //# sourceMappingURL=use-field-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-widget.d.ts","sourceRoot":"","sources":["../src/use-field-widget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAI7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEhE,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAKpD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAI7E;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAO7E;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;IACvB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACvC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACxB,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAC,SAAS,eAAe,EAAE,CAAC,CAAA;IAC1C,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;IAC9B,MAAM,IAAI,IAAI,CAAA;CACf;AAID,wBAAgB,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,WAAW,CAoD7E"}