@texaryn/angular 0.0.0-stage → 0.2.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 +18 -0
  2. package/LICENSE +190 -0
  3. package/README.md +75 -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 +22 -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 +53 -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 +31 -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,81 @@
1
+ import { computed } from '@angular/core';
2
+ import { englishMessages } from '@texaryn/core';
3
+ import { useFormContext } from './context.js';
4
+ import { fieldAria, fieldLabel, makeId } from './field-props.js';
5
+ import { useDynamicStore } from './store.js';
6
+ export function fieldKind(node) {
7
+ if (node.enumValues != null && node.enumValues.length > 0)
8
+ return 'enum';
9
+ if (node.fieldType === 'boolean')
10
+ return 'boolean';
11
+ if (node.fieldType === 'number' || node.fieldType === 'integer')
12
+ return 'number';
13
+ return 'string';
14
+ }
15
+ export function displayValue(kind, value) {
16
+ if (kind === 'number' && typeof value === 'number')
17
+ return value;
18
+ if (kind === 'string' && typeof value === 'string')
19
+ return value;
20
+ return value == null ? '' : String(value);
21
+ }
22
+ export function coerce(kind, node, raw) {
23
+ if (kind === 'number')
24
+ return raw === '' ? undefined : Number(raw);
25
+ if (kind === 'enum') {
26
+ const option = (node.enumValues ?? []).find((entry) => String(entry.value) === raw);
27
+ return option ? option.value : raw;
28
+ }
29
+ return raw;
30
+ }
31
+ const NO_ERRORS = [];
32
+ export function useFieldWidget(nodeSource) {
33
+ const context = useFormContext();
34
+ const node = computed(() => nodeSource(), ...(ngDevMode ? [{ debugName: "node" }] : []));
35
+ const kind = computed(() => fieldKind(node()), ...(ngDevMode ? [{ debugName: "kind" }] : []));
36
+ const nodeState = computed(() => {
37
+ const form = context.form();
38
+ form.document();
39
+ return form.getNodeState(node().id);
40
+ }, ...(ngDevMode ? [{ debugName: "nodeState" }] : []));
41
+ const value = useDynamicStore(() => nodeState()?.value, undefined);
42
+ const errors = useDynamicStore(() => nodeState()?.errors, NO_ERRORS);
43
+ const disabled = useDynamicStore(() => nodeState()?.disabled, false);
44
+ const showErrors = useDynamicStore(() => nodeState()?.showErrors, false);
45
+ const idPrefix = computed(() => context.idPrefix(), ...(ngDevMode ? [{ debugName: "idPrefix" }] : []));
46
+ const messages = computed(() => context.messages() ?? englishMessages, ...(ngDevMode ? [{ debugName: "messages" }] : []));
47
+ const visibleErrors = computed(() => showErrors() ? errors() : NO_ERRORS, ...(ngDevMode ? [{ debugName: "visibleErrors" }] : []));
48
+ return {
49
+ node,
50
+ kind,
51
+ value,
52
+ display: computed(() => displayValue(kind(), value())),
53
+ label: computed(() => fieldLabel(node())),
54
+ description: computed(() => node().helpText ?? node().annotations.description),
55
+ descriptionId: computed(() => makeId(idPrefix(), node().id, 'description')),
56
+ errorId: computed(() => makeId(idPrefix(), node().id, 'error')),
57
+ labelFor: computed(() => makeId(idPrefix(), node().id, 'input')),
58
+ aria: computed(() => fieldAria(node(), { disabled: disabled(), showErrors: showErrors(), errors: errors() }, idPrefix(), kind() !== 'enum' && kind() !== 'boolean')),
59
+ messages,
60
+ errors: visibleErrors,
61
+ invalid: computed(() => visibleErrors().length > 0),
62
+ setRaw: (raw) => {
63
+ const current = node();
64
+ if (current.readOnly)
65
+ return;
66
+ context.form().dispatch({
67
+ type: 'SetValue',
68
+ nodeId: current.id,
69
+ value: coerce(kind(), current, raw),
70
+ });
71
+ },
72
+ setValue: (next) => {
73
+ const current = node();
74
+ if (current.readOnly)
75
+ return;
76
+ context.form().dispatch({ type: 'SetValue', nodeId: current.id, value: next });
77
+ },
78
+ onBlur: () => context.form().dispatch({ type: 'SetTouched', nodeId: node().id }),
79
+ };
80
+ }
81
+ //# sourceMappingURL=use-field-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-widget.js","sourceRoot":"","sources":["../src/use-field-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK5C,MAAM,UAAU,SAAS,CAAC,IAAe;IACvC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAA;IACxE,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAClD,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;QAA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AAA;QACJ,CAAC;QACD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YACjB,MAAM,OAAO,GAAG,IAAI,EAAE,CAAA;YACtB,IAAI,OAAO,CAAC,QAAQ;gBAAE,OAAM;YAC5B,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAChF,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;KACjF,CAAA;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { InputSignal, Type } from '@angular/core';
2
+ import type { DocumentNode, DocumentRuntime, UINode } from '@texaryn/core';
3
+ export interface AngularWidget {
4
+ readonly node: InputSignal<UINode>;
5
+ }
6
+ export type WidgetComponent = Type<AngularWidget>;
7
+ export interface AngularDocumentWidget {
8
+ readonly node: InputSignal<DocumentNode>;
9
+ readonly runtime: InputSignal<DocumentRuntime>;
10
+ }
11
+ export type DocumentWidgetComponent = Type<AngularDocumentWidget>;
12
+ //# sourceMappingURL=widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACnC;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,CAAA;AAEjD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;CAC/C;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAA"}
package/dist/widget.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.js","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import type { ContainerNode, StableItemId, UINode } from '@texaryn/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ArrayControl {
4
+ readonly node: import("@angular/core").InputSignal<UINode>;
5
+ readonly context: import("../context.js").FormContext;
6
+ readonly array: import("../use-field-array.js").FieldArrayBinding;
7
+ readonly currentArray: import("@angular/core").Signal<ContainerNode>;
8
+ readonly messages: import("@angular/core").Signal<import("@texaryn/core").FormMessages>;
9
+ readonly canDrag: import("@angular/core").Signal<boolean>;
10
+ private readonly dragSession;
11
+ private readonly dragCleanup;
12
+ private readonly injector;
13
+ private readonly dragType;
14
+ private ownsTarget;
15
+ private clearDrag;
16
+ startDrag(event: DragEvent, itemId: StableItemId): void;
17
+ endDrag(event: DragEvent): void;
18
+ dragOver(event: DragEvent, itemId: StableItemId): void;
19
+ dragLeave(event: DragEvent): void;
20
+ drop(event: DragEvent, itemId: StableItemId): void;
21
+ itemTitle(nodeId: string | undefined): string | undefined;
22
+ move(event: MouseEvent, from: number, to: number, nextDirection: 'up' | 'down', restoreAtBoundary: boolean): void;
23
+ static ɵfac: i0.ɵɵFactoryDeclaration<ArrayControl, never>;
24
+ static ɵcmp: i0.ɵɵComponentDeclaration<ArrayControl, "texaryn-array-control", never, { "node": { "alias": "node"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
25
+ }
26
+ //# sourceMappingURL=array-control.d.ts.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,298 @@
1
+ import { afterNextRender, ChangeDetectionStrategy, Component, computed, effect, inject, Injector, input, signal, untracked, } from '@angular/core';
2
+ import { englishMessages } from '@texaryn/core';
3
+ import { NodeRenderer } from '../components/node-renderer.js';
4
+ import { useFormContext } from '../context.js';
5
+ import { useFieldArray } from '../use-field-array.js';
6
+ import * as i0 from "@angular/core";
7
+ export class ArrayControl {
8
+ node = input.required(...(ngDevMode ? [{ debugName: "node" }] : []));
9
+ context = useFormContext();
10
+ array = useFieldArray(() => this.node().id);
11
+ currentArray = computed(() => {
12
+ const node = this.node();
13
+ return (this.context.form().document().nodes[node.id] ?? node);
14
+ }, ...(ngDevMode ? [{ debugName: "currentArray" }] : []));
15
+ messages = computed(() => this.context.messages() ?? englishMessages, ...(ngDevMode ? [{ debugName: "messages" }] : []));
16
+ canDrag = computed(() => this.currentArray().arrayMeta?.canReorder === true &&
17
+ !this.currentArray().readOnly && !this.currentArray().disabled, ...(ngDevMode ? [{ debugName: "canDrag" }] : []));
18
+ dragSession = signal(null, ...(ngDevMode ? [{ debugName: "dragSession" }] : []));
19
+ dragCleanup = effect(() => {
20
+ const session = this.dragSession();
21
+ if (!session)
22
+ return;
23
+ const runtime = this.context.form().runtime;
24
+ const array = this.currentArray();
25
+ if (session.runtime !== runtime || session.identityKey !== array.arrayMeta?.identityKey ||
26
+ !this.canDrag() || !array.arrayMeta?.itemIds.includes(session.itemId))
27
+ untracked(() => this.clearDrag());
28
+ }, ...(ngDevMode ? [{ debugName: "dragCleanup" }] : []));
29
+ injector = inject(Injector);
30
+ dragType = 'application/x-texaryn-array-item';
31
+ ownsTarget(event, root) {
32
+ return event.target instanceof Element && event.target.closest('[data-array-container]') === root;
33
+ }
34
+ clearDrag() {
35
+ const root = this.dragSession()?.root;
36
+ root?.removeAttribute('data-array-drag-active');
37
+ root?.querySelectorAll('[data-dragging], [data-drop-target]').forEach((row) => {
38
+ row.removeAttribute('data-dragging');
39
+ row.removeAttribute('data-drop-target');
40
+ });
41
+ this.dragSession.set(null);
42
+ }
43
+ startDrag(event, itemId) {
44
+ const current = this.currentArray();
45
+ const root = event.currentTarget.closest('[data-array-container]');
46
+ const identityKey = current.arrayMeta?.identityKey;
47
+ if (!this.canDrag() || !root || identityKey === undefined || !current.arrayMeta?.itemIds.includes(itemId) || !event.dataTransfer) {
48
+ event.preventDefault();
49
+ return;
50
+ }
51
+ event.stopPropagation();
52
+ event.dataTransfer.setData(this.dragType, itemId);
53
+ event.dataTransfer.effectAllowed = 'move';
54
+ this.dragSession.set({ runtime: this.context.form().runtime, identityKey, root, itemId });
55
+ root.setAttribute('data-array-drag-active', '');
56
+ event.currentTarget.closest('[data-array-row]')?.setAttribute('data-dragging', '');
57
+ }
58
+ endDrag(event) {
59
+ event.dataTransfer?.clearData(this.dragType);
60
+ this.clearDrag();
61
+ }
62
+ dragOver(event, itemId) {
63
+ if (!Array.from(event.dataTransfer?.types ?? []).includes(this.dragType))
64
+ return;
65
+ const currentTarget = event.currentTarget;
66
+ const root = currentTarget.closest('[data-array-container]');
67
+ if (!root || !this.ownsTarget(event, root)) {
68
+ event.stopPropagation();
69
+ return;
70
+ }
71
+ const session = this.dragSession();
72
+ const current = this.currentArray();
73
+ const ids = current.arrayMeta?.itemIds ?? [];
74
+ if (!session || session.runtime !== this.context.form().runtime || session.root !== root ||
75
+ session.identityKey !== current.arrayMeta?.identityKey || !this.canDrag() ||
76
+ !ids.includes(session.itemId) || !ids.includes(itemId)) {
77
+ event.stopPropagation();
78
+ return;
79
+ }
80
+ event.preventDefault();
81
+ event.stopPropagation();
82
+ if (event.dataTransfer)
83
+ event.dataTransfer.dropEffect = 'move';
84
+ currentTarget.setAttribute('data-drop-target', '');
85
+ }
86
+ dragLeave(event) {
87
+ if (Array.from(event.dataTransfer?.types ?? []).includes(this.dragType)) {
88
+ event.currentTarget.removeAttribute('data-drop-target');
89
+ }
90
+ }
91
+ drop(event, itemId) {
92
+ if (!Array.from(event.dataTransfer?.types ?? []).includes(this.dragType))
93
+ return;
94
+ event.stopPropagation();
95
+ const currentTarget = event.currentTarget;
96
+ const root = currentTarget.closest('[data-array-container]');
97
+ const session = this.dragSession();
98
+ const current = this.currentArray();
99
+ const ids = current.arrayMeta?.itemIds ?? [];
100
+ if (!root || !this.ownsTarget(event, root) || !session) {
101
+ this.clearDrag();
102
+ return;
103
+ }
104
+ const sourceIndex = ids.indexOf(session.itemId);
105
+ const targetIndex = ids.indexOf(itemId);
106
+ if (session.runtime !== this.context.form().runtime || session.root !== root ||
107
+ session.identityKey !== current.arrayMeta?.identityKey || !this.canDrag() ||
108
+ sourceIndex < 0 || targetIndex < 0) {
109
+ this.clearDrag();
110
+ return;
111
+ }
112
+ event.preventDefault();
113
+ const bounds = currentTarget.getBoundingClientRect();
114
+ const after = event.clientY >= bounds.top + bounds.height / 2;
115
+ const boundary = targetIndex + (after ? 1 : 0);
116
+ const destination = boundary > sourceIndex ? boundary - 1 : boundary;
117
+ this.clearDrag();
118
+ if (destination !== sourceIndex)
119
+ this.array.move(sourceIndex, destination);
120
+ }
121
+ itemTitle(nodeId) {
122
+ if (!nodeId)
123
+ return undefined;
124
+ return this.context.form().document().nodes[nodeId]?.annotations.title;
125
+ }
126
+ move(event, from, to, nextDirection, restoreAtBoundary) {
127
+ const button = event.currentTarget;
128
+ const wasFocused = button.ownerDocument.activeElement === button;
129
+ const row = button.closest('[data-array-row]');
130
+ this.array.move(from, to);
131
+ if (wasFocused && restoreAtBoundary) {
132
+ afterNextRender({
133
+ mixedReadWrite: () => row?.querySelector(`[data-reorder-direction="${nextDirection}"]`)?.focus(),
134
+ }, { injector: this.injector });
135
+ }
136
+ }
137
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: ArrayControl, deps: [], target: i0.ɵɵFactoryTarget.Component });
138
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.33", type: ArrayControl, isStandalone: true, selector: "texaryn-array-control", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
139
+ <div data-array-container="array">
140
+ @for (item of array.items(); track item.id; let index = $index) {
141
+ <div
142
+ data-array-row
143
+ [attr.data-array-item-id]="item.id"
144
+ (dragover)="dragOver($event, item.id)"
145
+ (dragleave)="dragLeave($event)"
146
+ (drop)="drop($event, item.id)"
147
+ >
148
+ @if (canDrag()) {
149
+ <span
150
+ aria-hidden="true"
151
+ class="texaryn-array-drag-handle"
152
+ tabindex="-1"
153
+ draggable="true"
154
+ (dragstart)="startDrag($event, item.id)"
155
+ (dragend)="endDrag($event)"
156
+ >⠿</span>
157
+ }
158
+ @if (item.nodeId; as childId) {
159
+ @let child = context.form().document().nodes[childId];
160
+ @if (child) {
161
+ <texaryn-node-renderer [node]="child" />
162
+ }
163
+ }
164
+ @if (array.canReorder() && index > 0) {
165
+ @let action = messages().moveItemUp({
166
+ position: index + 1,
167
+ itemTitle: itemTitle(item.nodeId),
168
+ containerTitle: currentArray().annotations.title,
169
+ });
170
+ <button
171
+ type="button"
172
+ data-reorder-direction="up"
173
+ [attr.aria-label]="action.accessibleName"
174
+ (click)="move($event, index, index - 1, 'down', index === 1)"
175
+ >{{ action.label }}</button>
176
+ }
177
+ @if (array.canReorder() && index < array.items().length - 1) {
178
+ @let action = messages().moveItemDown({
179
+ position: index + 1,
180
+ itemTitle: itemTitle(item.nodeId),
181
+ containerTitle: currentArray().annotations.title,
182
+ });
183
+ <button
184
+ type="button"
185
+ data-reorder-direction="down"
186
+ [attr.aria-label]="action.accessibleName"
187
+ (click)="move($event, index, index + 1, 'up', index === array.items().length - 2)"
188
+ >{{ action.label }}</button>
189
+ }
190
+ @if (array.canRemove()) {
191
+ @let action = messages().removeItem({
192
+ position: index + 1,
193
+ itemTitle: itemTitle(item.nodeId),
194
+ containerTitle: currentArray().annotations.title,
195
+ });
196
+ <button type="button" [attr.aria-label]="action.accessibleName" (click)="array.remove(index)">
197
+ {{ action.label }}
198
+ </button>
199
+ }
200
+ </div>
201
+ }
202
+ @if (array.canAdd()) {
203
+ @let action = messages().addItem({
204
+ itemTemplateTitle: currentArray().arrayMeta?.itemTitle,
205
+ containerTitle: currentArray().annotations.title,
206
+ });
207
+ <button type="button" [attr.aria-label]="action.accessibleName" (click)="array.add()">
208
+ {{ action.label }}
209
+ </button>
210
+ }
211
+ </div>
212
+ `, isInline: true, dependencies: [{ kind: "component", type: NodeRenderer, selector: "texaryn-node-renderer", inputs: ["node"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
213
+ }
214
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: ArrayControl, decorators: [{
215
+ type: Component,
216
+ args: [{
217
+ selector: 'texaryn-array-control',
218
+ standalone: true,
219
+ imports: [NodeRenderer],
220
+ changeDetection: ChangeDetectionStrategy.OnPush,
221
+ template: `
222
+ <div data-array-container="array">
223
+ @for (item of array.items(); track item.id; let index = $index) {
224
+ <div
225
+ data-array-row
226
+ [attr.data-array-item-id]="item.id"
227
+ (dragover)="dragOver($event, item.id)"
228
+ (dragleave)="dragLeave($event)"
229
+ (drop)="drop($event, item.id)"
230
+ >
231
+ @if (canDrag()) {
232
+ <span
233
+ aria-hidden="true"
234
+ class="texaryn-array-drag-handle"
235
+ tabindex="-1"
236
+ draggable="true"
237
+ (dragstart)="startDrag($event, item.id)"
238
+ (dragend)="endDrag($event)"
239
+ >⠿</span>
240
+ }
241
+ @if (item.nodeId; as childId) {
242
+ @let child = context.form().document().nodes[childId];
243
+ @if (child) {
244
+ <texaryn-node-renderer [node]="child" />
245
+ }
246
+ }
247
+ @if (array.canReorder() && index > 0) {
248
+ @let action = messages().moveItemUp({
249
+ position: index + 1,
250
+ itemTitle: itemTitle(item.nodeId),
251
+ containerTitle: currentArray().annotations.title,
252
+ });
253
+ <button
254
+ type="button"
255
+ data-reorder-direction="up"
256
+ [attr.aria-label]="action.accessibleName"
257
+ (click)="move($event, index, index - 1, 'down', index === 1)"
258
+ >{{ action.label }}</button>
259
+ }
260
+ @if (array.canReorder() && index < array.items().length - 1) {
261
+ @let action = messages().moveItemDown({
262
+ position: index + 1,
263
+ itemTitle: itemTitle(item.nodeId),
264
+ containerTitle: currentArray().annotations.title,
265
+ });
266
+ <button
267
+ type="button"
268
+ data-reorder-direction="down"
269
+ [attr.aria-label]="action.accessibleName"
270
+ (click)="move($event, index, index + 1, 'up', index === array.items().length - 2)"
271
+ >{{ action.label }}</button>
272
+ }
273
+ @if (array.canRemove()) {
274
+ @let action = messages().removeItem({
275
+ position: index + 1,
276
+ itemTitle: itemTitle(item.nodeId),
277
+ containerTitle: currentArray().annotations.title,
278
+ });
279
+ <button type="button" [attr.aria-label]="action.accessibleName" (click)="array.remove(index)">
280
+ {{ action.label }}
281
+ </button>
282
+ }
283
+ </div>
284
+ }
285
+ @if (array.canAdd()) {
286
+ @let action = messages().addItem({
287
+ itemTemplateTitle: currentArray().arrayMeta?.itemTitle,
288
+ containerTitle: currentArray().annotations.title,
289
+ });
290
+ <button type="button" [attr.aria-label]="action.accessibleName" (click)="array.add()">
291
+ {{ action.label }}
292
+ </button>
293
+ }
294
+ </div>
295
+ `,
296
+ }]
297
+ }], propDecorators: { node: [{ type: i0.Input, args: [{ isSignal: true, alias: "node", required: true }] }] } });
298
+ //# sourceMappingURL=array-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-control.js","sourceRoot":"","sources":["../../src/widgets/array-control.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,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ACjC,CAAC;IACH,CAAC;wGAxJU,YAAY;4FAAZ,YAAY,iNA5Eb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0ET,4DA5ES,YAAY;;4FA8EX,YAAY;kBAjFxB,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0ET;iBACF"}
@@ -0,0 +1,4 @@
1
+ import type { RendererRegistry } from '@texaryn/core';
2
+ import type { WidgetComponent } from '../widget.js';
3
+ export declare function createDefaultRegistry(): RendererRegistry<WidgetComponent>;
4
+ //# sourceMappingURL=default-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-registry.d.ts","sourceRoot":"","sources":["../../src/widgets/default-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAKnD,wBAAgB,qBAAqB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAYzE"}
@@ -0,0 +1,12 @@
1
+ import { createRendererRegistry } from '@texaryn/core';
2
+ import { ArrayControl } from './array-control.js';
3
+ import { FieldWidgetComponent } from './field.js';
4
+ import { ObjectLayout } from './object-layout.js';
5
+ export function createDefaultRegistry() {
6
+ const registry = createRendererRegistry();
7
+ registry.register({ test: (node) => node.type === 'field', rank: 1 }, FieldWidgetComponent);
8
+ registry.register({ test: (node) => node.type === 'container' && node.containerType === 'object', rank: 1 }, ObjectLayout);
9
+ registry.register({ test: (node) => node.type === 'container' && node.containerType === 'array', rank: 1 }, ArrayControl);
10
+ return registry;
11
+ }
12
+ //# sourceMappingURL=default-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-registry.js","sourceRoot":"","sources":["../../src/widgets/default-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,UAAU,qBAAqB;IACnC,MAAM,QAAQ,GAAG,sBAAsB,EAAmB,CAAA;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAA;IAC3F,QAAQ,CAAC,QAAQ,CACf,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,EACzF,YAAY,CACb,CAAA;IACD,QAAQ,CAAC,QAAQ,CACf,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EACxF,YAAY,CACb,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { UINode } from '@texaryn/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class FieldWidgetComponent {
4
+ readonly node: import("@angular/core").InputSignal<UINode>;
5
+ readonly field: import("../use-field-widget.js").FieldWidget;
6
+ readonly requiredIndicator: import("@angular/core").Signal<import("@texaryn/core").IndicatorMessage>;
7
+ readonly enumOptions: import("@angular/core").Signal<{
8
+ token: string;
9
+ value: unknown;
10
+ label: string;
11
+ }[]>;
12
+ readonly enumValueToken: import("@angular/core").Signal<string>;
13
+ readonly stringify: (value: unknown) => string;
14
+ onSelectChange(event: Event): void;
15
+ onCheckboxChange(event: Event): void;
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<FieldWidgetComponent, never>;
17
+ static ɵcmp: i0.ɵɵComponentDeclaration<FieldWidgetComponent, "texaryn-field-widget", never, { "node": { "alias": "node"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
18
+ }
19
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/widgets/field.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;;AAG3C,qBAuGa,oBAAoB;IAC/B,QAAQ,CAAC,IAAI,8CAA2B;IACxC,QAAQ,CAAC,KAAK,+CAA4B;IAC1C,QAAQ,CAAC,iBAAiB,2EAA4D;IACtF,QAAQ,CAAC,WAAW;;;;SAMnB;IACD,QAAQ,CAAC,cAAc,yCAEtB;IACD,QAAQ,CAAC,SAAS,GAAI,OAAO,OAAO,KAAG,MAAM,CAG5C;IAED,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAOlC,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;yCA1BzB,oBAAoB;2CAApB,oBAAoB;CA+BhC"}