@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.
- package/CHANGELOG.md +18 -0
- package/LICENSE +190 -0
- package/README.md +75 -2
- package/dist/components/document-node-renderer.d.ts +34 -0
- package/dist/components/document-node-renderer.d.ts.map +1 -0
- package/dist/components/document-node-renderer.js +190 -0
- package/dist/components/document-node-renderer.js.map +1 -0
- package/dist/components/document-root.d.ts +13 -0
- package/dist/components/document-root.d.ts.map +1 -0
- package/dist/components/document-root.js +36 -0
- package/dist/components/document-root.js.map +1 -0
- package/dist/components/error-summary.d.ts +22 -0
- package/dist/components/error-summary.d.ts.map +1 -0
- package/dist/components/error-summary.js +78 -0
- package/dist/components/error-summary.js.map +1 -0
- package/dist/components/form-root.d.ts +16 -0
- package/dist/components/form-root.d.ts.map +1 -0
- package/dist/components/form-root.js +53 -0
- package/dist/components/form-root.js.map +1 -0
- package/dist/components/node-renderer.d.ts +15 -0
- package/dist/components/node-renderer.d.ts.map +1 -0
- package/dist/components/node-renderer.js +35 -0
- package/dist/components/node-renderer.js.map +1 -0
- package/dist/context.d.ts +14 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +6 -0
- package/dist/context.js.map +1 -0
- package/dist/document-context.d.ts +13 -0
- package/dist/document-context.d.ts.map +1 -0
- package/dist/document-context.js +6 -0
- package/dist/document-context.js.map +1 -0
- package/dist/field-props.d.ts +20 -0
- package/dist/field-props.d.ts.map +1 -0
- package/dist/field-props.js +31 -0
- package/dist/field-props.js.map +1 -0
- package/dist/form.d.ts +15 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +26 -0
- package/dist/form.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/store.d.ts +6 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +21 -0
- package/dist/store.js.map +1 -0
- package/dist/use-field-array.d.ts +17 -0
- package/dist/use-field-array.d.ts.map +1 -0
- package/dist/use-field-array.js +35 -0
- package/dist/use-field-array.js.map +1 -0
- package/dist/use-field-widget.d.ts +28 -0
- package/dist/use-field-widget.d.ts.map +1 -0
- package/dist/use-field-widget.js +81 -0
- package/dist/use-field-widget.js.map +1 -0
- package/dist/widget.d.ts +12 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widget.js +2 -0
- package/dist/widget.js.map +1 -0
- package/dist/widgets/array-control.d.ts +26 -0
- package/dist/widgets/array-control.d.ts.map +1 -0
- package/dist/widgets/array-control.js +298 -0
- package/dist/widgets/array-control.js.map +1 -0
- package/dist/widgets/default-registry.d.ts +4 -0
- package/dist/widgets/default-registry.d.ts.map +1 -0
- package/dist/widgets/default-registry.js +12 -0
- package/dist/widgets/default-registry.js.map +1 -0
- package/dist/widgets/field.d.ts +19 -0
- package/dist/widgets/field.d.ts.map +1 -0
- package/dist/widgets/field.js +256 -0
- package/dist/widgets/field.js.map +1 -0
- package/dist/widgets/object-layout.d.ts +18 -0
- package/dist/widgets/object-layout.d.ts.map +1 -0
- package/dist/widgets/object-layout.js +115 -0
- package/dist/widgets/object-layout.js.map +1 -0
- package/package.json +65 -3
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core';
|
|
2
|
+
import { useFieldWidget } from '../use-field-widget.js';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export class FieldWidgetComponent {
|
|
5
|
+
node = input.required(...(ngDevMode ? [{ debugName: "node" }] : []));
|
|
6
|
+
field = useFieldWidget(this.node);
|
|
7
|
+
requiredIndicator = computed(() => this.field.messages().requiredIndicator(), ...(ngDevMode ? [{ debugName: "requiredIndicator" }] : []));
|
|
8
|
+
enumOptions = computed(() => (this.field.node().enumValues ?? []).map((option, index) => ({
|
|
9
|
+
token: `texaryn-enum-${index}`,
|
|
10
|
+
value: option.value,
|
|
11
|
+
label: option.title ?? this.stringify(option.value),
|
|
12
|
+
})), ...(ngDevMode ? [{ debugName: "enumOptions" }] : []));
|
|
13
|
+
enumValueToken = computed(() => this.enumOptions().find((option) => sameJsonValue(option.value, this.field.value()))?.token ?? '', ...(ngDevMode ? [{ debugName: "enumValueToken" }] : []));
|
|
14
|
+
stringify = (value) => {
|
|
15
|
+
if (typeof value === 'string')
|
|
16
|
+
return value;
|
|
17
|
+
return JSON.stringify(value) ?? String(value);
|
|
18
|
+
};
|
|
19
|
+
onSelectChange(event) {
|
|
20
|
+
const control = event.target;
|
|
21
|
+
const option = this.enumOptions().find((candidate) => candidate.token === control.value);
|
|
22
|
+
this.field.setValue(option ? option.value : '');
|
|
23
|
+
if (this.field.node().readOnly)
|
|
24
|
+
control.value = this.enumValueToken();
|
|
25
|
+
}
|
|
26
|
+
onCheckboxChange(event) {
|
|
27
|
+
const control = event.target;
|
|
28
|
+
this.field.setValue(control.checked);
|
|
29
|
+
if (this.field.node().readOnly)
|
|
30
|
+
control.checked = Boolean(this.field.value());
|
|
31
|
+
}
|
|
32
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: FieldWidgetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
33
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.33", type: FieldWidgetComponent, isStandalone: true, selector: "texaryn-field-widget", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
34
|
+
<div>
|
|
35
|
+
<label [id]="field.labelFor() + '-label'" [attr.for]="field.labelFor()">@if (field.aria()['aria-required'] && requiredIndicator().placement === 'before') {<span aria-hidden="true">{{ requiredIndicator().text }} </span>}<span>{{ field.label() }}</span>@if (field.aria()['aria-required'] && requiredIndicator().placement === 'after') {<span aria-hidden="true"> {{ requiredIndicator().text }}</span>}</label>
|
|
36
|
+
@switch (field.kind()) {
|
|
37
|
+
@case ('enum') {
|
|
38
|
+
<select
|
|
39
|
+
[id]="field.aria().id"
|
|
40
|
+
[name]="field.aria().name"
|
|
41
|
+
[disabled]="field.aria().disabled"
|
|
42
|
+
[attr.aria-readonly]="field.aria()['aria-readonly'] ? 'true' : null"
|
|
43
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
44
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
45
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
46
|
+
(change)="onSelectChange($event)"
|
|
47
|
+
(blur)="field.onBlur()"
|
|
48
|
+
>
|
|
49
|
+
<option value="" [selected]="enumValueToken() === ''"></option>
|
|
50
|
+
@for (option of enumOptions(); track option.token) {
|
|
51
|
+
<option [value]="option.token" [selected]="enumValueToken() === option.token">
|
|
52
|
+
{{ option.label }}
|
|
53
|
+
</option>
|
|
54
|
+
}
|
|
55
|
+
</select>
|
|
56
|
+
}
|
|
57
|
+
@case ('boolean') {
|
|
58
|
+
<input
|
|
59
|
+
[id]="field.aria().id"
|
|
60
|
+
[name]="field.aria().name"
|
|
61
|
+
type="checkbox"
|
|
62
|
+
[checked]="!!field.value()"
|
|
63
|
+
[disabled]="field.aria().disabled"
|
|
64
|
+
[attr.aria-readonly]="field.aria()['aria-readonly'] ? 'true' : null"
|
|
65
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
66
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
67
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
68
|
+
(change)="onCheckboxChange($event)"
|
|
69
|
+
(blur)="field.onBlur()"
|
|
70
|
+
/>
|
|
71
|
+
}
|
|
72
|
+
@case ('number') {
|
|
73
|
+
<input
|
|
74
|
+
[id]="field.aria().id"
|
|
75
|
+
[name]="field.aria().name"
|
|
76
|
+
type="number"
|
|
77
|
+
[value]="field.display()"
|
|
78
|
+
[disabled]="field.aria().disabled"
|
|
79
|
+
[readOnly]="field.node().readOnly"
|
|
80
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
81
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
82
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
83
|
+
[attr.placeholder]="field.aria().placeholder ?? null"
|
|
84
|
+
(input)="field.setRaw($any($event.target).value)"
|
|
85
|
+
(blur)="field.onBlur()"
|
|
86
|
+
/>
|
|
87
|
+
}
|
|
88
|
+
@default {
|
|
89
|
+
@if (field.node().widget === 'textarea') {
|
|
90
|
+
<textarea
|
|
91
|
+
[id]="field.aria().id"
|
|
92
|
+
[name]="field.aria().name"
|
|
93
|
+
[value]="field.display()"
|
|
94
|
+
[disabled]="field.aria().disabled"
|
|
95
|
+
[readOnly]="field.node().readOnly"
|
|
96
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
97
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
98
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
99
|
+
[attr.placeholder]="field.aria().placeholder ?? null"
|
|
100
|
+
(input)="field.setRaw($any($event.target).value)"
|
|
101
|
+
(blur)="field.onBlur()"
|
|
102
|
+
></textarea>
|
|
103
|
+
} @else {
|
|
104
|
+
<input
|
|
105
|
+
[id]="field.aria().id"
|
|
106
|
+
[name]="field.aria().name"
|
|
107
|
+
type="text"
|
|
108
|
+
[value]="field.display()"
|
|
109
|
+
[disabled]="field.aria().disabled"
|
|
110
|
+
[readOnly]="field.node().readOnly"
|
|
111
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
112
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
113
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
114
|
+
[attr.placeholder]="field.aria().placeholder ?? null"
|
|
115
|
+
(input)="field.setRaw($any($event.target).value)"
|
|
116
|
+
(blur)="field.onBlur()"
|
|
117
|
+
/>
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
@if (field.description(); as description) {
|
|
122
|
+
<div [id]="field.descriptionId()">{{ description }}</div>
|
|
123
|
+
}
|
|
124
|
+
<div [id]="field.errorId()" aria-live="polite" aria-atomic="true">
|
|
125
|
+
@for (error of field.errors(); track $index) {
|
|
126
|
+
<div>{{ error.message ?? error.keyword }}</div>
|
|
127
|
+
}
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
131
|
+
}
|
|
132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: FieldWidgetComponent, decorators: [{
|
|
133
|
+
type: Component,
|
|
134
|
+
args: [{
|
|
135
|
+
selector: 'texaryn-field-widget',
|
|
136
|
+
standalone: true,
|
|
137
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
138
|
+
template: `
|
|
139
|
+
<div>
|
|
140
|
+
<label [id]="field.labelFor() + '-label'" [attr.for]="field.labelFor()">@if (field.aria()['aria-required'] && requiredIndicator().placement === 'before') {<span aria-hidden="true">{{ requiredIndicator().text }} </span>}<span>{{ field.label() }}</span>@if (field.aria()['aria-required'] && requiredIndicator().placement === 'after') {<span aria-hidden="true"> {{ requiredIndicator().text }}</span>}</label>
|
|
141
|
+
@switch (field.kind()) {
|
|
142
|
+
@case ('enum') {
|
|
143
|
+
<select
|
|
144
|
+
[id]="field.aria().id"
|
|
145
|
+
[name]="field.aria().name"
|
|
146
|
+
[disabled]="field.aria().disabled"
|
|
147
|
+
[attr.aria-readonly]="field.aria()['aria-readonly'] ? 'true' : null"
|
|
148
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
149
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
150
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
151
|
+
(change)="onSelectChange($event)"
|
|
152
|
+
(blur)="field.onBlur()"
|
|
153
|
+
>
|
|
154
|
+
<option value="" [selected]="enumValueToken() === ''"></option>
|
|
155
|
+
@for (option of enumOptions(); track option.token) {
|
|
156
|
+
<option [value]="option.token" [selected]="enumValueToken() === option.token">
|
|
157
|
+
{{ option.label }}
|
|
158
|
+
</option>
|
|
159
|
+
}
|
|
160
|
+
</select>
|
|
161
|
+
}
|
|
162
|
+
@case ('boolean') {
|
|
163
|
+
<input
|
|
164
|
+
[id]="field.aria().id"
|
|
165
|
+
[name]="field.aria().name"
|
|
166
|
+
type="checkbox"
|
|
167
|
+
[checked]="!!field.value()"
|
|
168
|
+
[disabled]="field.aria().disabled"
|
|
169
|
+
[attr.aria-readonly]="field.aria()['aria-readonly'] ? 'true' : null"
|
|
170
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
171
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
172
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
173
|
+
(change)="onCheckboxChange($event)"
|
|
174
|
+
(blur)="field.onBlur()"
|
|
175
|
+
/>
|
|
176
|
+
}
|
|
177
|
+
@case ('number') {
|
|
178
|
+
<input
|
|
179
|
+
[id]="field.aria().id"
|
|
180
|
+
[name]="field.aria().name"
|
|
181
|
+
type="number"
|
|
182
|
+
[value]="field.display()"
|
|
183
|
+
[disabled]="field.aria().disabled"
|
|
184
|
+
[readOnly]="field.node().readOnly"
|
|
185
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
186
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
187
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
188
|
+
[attr.placeholder]="field.aria().placeholder ?? null"
|
|
189
|
+
(input)="field.setRaw($any($event.target).value)"
|
|
190
|
+
(blur)="field.onBlur()"
|
|
191
|
+
/>
|
|
192
|
+
}
|
|
193
|
+
@default {
|
|
194
|
+
@if (field.node().widget === 'textarea') {
|
|
195
|
+
<textarea
|
|
196
|
+
[id]="field.aria().id"
|
|
197
|
+
[name]="field.aria().name"
|
|
198
|
+
[value]="field.display()"
|
|
199
|
+
[disabled]="field.aria().disabled"
|
|
200
|
+
[readOnly]="field.node().readOnly"
|
|
201
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
202
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
203
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
204
|
+
[attr.placeholder]="field.aria().placeholder ?? null"
|
|
205
|
+
(input)="field.setRaw($any($event.target).value)"
|
|
206
|
+
(blur)="field.onBlur()"
|
|
207
|
+
></textarea>
|
|
208
|
+
} @else {
|
|
209
|
+
<input
|
|
210
|
+
[id]="field.aria().id"
|
|
211
|
+
[name]="field.aria().name"
|
|
212
|
+
type="text"
|
|
213
|
+
[value]="field.display()"
|
|
214
|
+
[disabled]="field.aria().disabled"
|
|
215
|
+
[readOnly]="field.node().readOnly"
|
|
216
|
+
[attr.aria-required]="field.aria()['aria-required'] ? 'true' : null"
|
|
217
|
+
[attr.aria-invalid]="field.aria()['aria-invalid'] ? 'true' : null"
|
|
218
|
+
[attr.aria-describedby]="field.aria()['aria-describedby'] ?? null"
|
|
219
|
+
[attr.placeholder]="field.aria().placeholder ?? null"
|
|
220
|
+
(input)="field.setRaw($any($event.target).value)"
|
|
221
|
+
(blur)="field.onBlur()"
|
|
222
|
+
/>
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
@if (field.description(); as description) {
|
|
227
|
+
<div [id]="field.descriptionId()">{{ description }}</div>
|
|
228
|
+
}
|
|
229
|
+
<div [id]="field.errorId()" aria-live="polite" aria-atomic="true">
|
|
230
|
+
@for (error of field.errors(); track $index) {
|
|
231
|
+
<div>{{ error.message ?? error.keyword }}</div>
|
|
232
|
+
}
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
`,
|
|
236
|
+
}]
|
|
237
|
+
}], propDecorators: { node: [{ type: i0.Input, args: [{ isSignal: true, alias: "node", required: true }] }] } });
|
|
238
|
+
function sameJsonValue(left, right) {
|
|
239
|
+
if (left === right)
|
|
240
|
+
return true;
|
|
241
|
+
if (left === null || right === null || typeof left !== 'object' || typeof right !== 'object') {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
if (Array.isArray(left) !== Array.isArray(right))
|
|
245
|
+
return false;
|
|
246
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
247
|
+
return left.length === right.length && left.every((value, index) => sameJsonValue(value, right[index]));
|
|
248
|
+
}
|
|
249
|
+
const leftRecord = left;
|
|
250
|
+
const rightRecord = right;
|
|
251
|
+
const leftKeys = Object.keys(leftRecord);
|
|
252
|
+
const rightKeys = Object.keys(rightRecord);
|
|
253
|
+
return leftKeys.length === rightKeys.length
|
|
254
|
+
&& leftKeys.every((key) => Object.hasOwn(rightRecord, key) && sameJsonValue(leftRecord[key], rightRecord[key]));
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/widgets/field.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,KAAK,GACN,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;;AAyGvD,MAAM,OAAO,oBAAoB;IACtB,IAAI,GAAG,KAAK,CAAC,QAAQ,+CAAU,CAAA;IAC/B,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjC,iBAAiB,GAAG,QAAQ,CAAC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CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC9D,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACzG,CAAC;IACD,MAAM,UAAU,GAAG,IAA+B,CAAA;IAClD,MAAM,WAAW,GAAG,KAAgC,CAAA;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACxC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC1C,OAAO,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM;WACtC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACnH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { objectChildKey } from '@texaryn/core';
|
|
2
|
+
import type { ContainerNode, UINode } from '@texaryn/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class ObjectLayout {
|
|
5
|
+
readonly node: import("@angular/core").InputSignal<UINode>;
|
|
6
|
+
private readonly context;
|
|
7
|
+
readonly currentNode: import("@angular/core").Signal<ContainerNode>;
|
|
8
|
+
readonly children: import("@angular/core").Signal<UINode[]>;
|
|
9
|
+
readonly expandActions: import("@angular/core").Signal<{
|
|
10
|
+
target: import("@texaryn/core").ProjectionBoundaryTarget;
|
|
11
|
+
message: import("@texaryn/core").ActionMessage;
|
|
12
|
+
}[]>;
|
|
13
|
+
readonly childKey: typeof objectChildKey;
|
|
14
|
+
expand(targetToken: string): void;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ObjectLayout, never>;
|
|
16
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ObjectLayout, "texaryn-object-layout", never, { "node": { "alias": "node"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=object-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-layout.d.ts","sourceRoot":"","sources":["../../src/widgets/object-layout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,cAAc,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;;AAI1D,qBAmCa,YAAY;IACvB,QAAQ,CAAC,IAAI,8CAA2B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,QAAQ,CAAC,WAAW,gDAGlB;IACF,QAAQ,CAAC,QAAQ,2CAKf;IACF,QAAQ,CAAC,aAAa;;;SAgBpB;IACF,QAAQ,CAAC,QAAQ,wBAAiB;IAElC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;yCAhCtB,YAAY;2CAAZ,YAAY;CAuCxB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
3
|
+
import { englishMessages, objectChildKey } from '@texaryn/core';
|
|
4
|
+
import { useFormContext } from '../context.js';
|
|
5
|
+
import { NodeRenderer } from '../components/node-renderer.js';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export class ObjectLayout {
|
|
8
|
+
node = input.required(...(ngDevMode ? [{ debugName: "node" }] : []));
|
|
9
|
+
context = useFormContext();
|
|
10
|
+
currentNode = computed(() => {
|
|
11
|
+
const node = this.node();
|
|
12
|
+
return (this.context.form().document().nodes[node.id] ?? node);
|
|
13
|
+
}, ...(ngDevMode ? [{ debugName: "currentNode" }] : []));
|
|
14
|
+
children = computed(() => {
|
|
15
|
+
const document = this.context.form().document();
|
|
16
|
+
return this.currentNode().children
|
|
17
|
+
.map((id) => document.nodes[id])
|
|
18
|
+
.filter((child) => child !== undefined);
|
|
19
|
+
}, ...(ngDevMode ? [{ debugName: "children" }] : []));
|
|
20
|
+
expandActions = computed(() => {
|
|
21
|
+
const current = this.currentNode();
|
|
22
|
+
const messages = this.context.messages() ?? englishMessages;
|
|
23
|
+
const firstByReason = new Map();
|
|
24
|
+
for (const target of current.boundaryTargets ?? []) {
|
|
25
|
+
if (!firstByReason.has(target.reason))
|
|
26
|
+
firstByReason.set(target.reason, target);
|
|
27
|
+
}
|
|
28
|
+
return [...firstByReason.values()].map((target) => ({
|
|
29
|
+
target,
|
|
30
|
+
message: (messages.expandBoundary ?? englishMessages.expandBoundary)({
|
|
31
|
+
boundary: target.reason,
|
|
32
|
+
containerTitle: current.annotations.title,
|
|
33
|
+
position: 1,
|
|
34
|
+
count: 1,
|
|
35
|
+
}),
|
|
36
|
+
}));
|
|
37
|
+
}, ...(ngDevMode ? [{ debugName: "expandActions" }] : []));
|
|
38
|
+
childKey = objectChildKey;
|
|
39
|
+
expand(targetToken) {
|
|
40
|
+
this.context.form().dispatch({
|
|
41
|
+
type: 'ExpandBoundary',
|
|
42
|
+
containerId: this.currentNode().id,
|
|
43
|
+
targetToken,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: ObjectLayout, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
47
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.33", type: ObjectLayout, isStandalone: true, selector: "texaryn-object-layout", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
48
|
+
@let current = currentNode();
|
|
49
|
+
@if (current.parentId === null) {
|
|
50
|
+
<div>
|
|
51
|
+
<ng-container *ngTemplateOutlet="content" />
|
|
52
|
+
</div>
|
|
53
|
+
} @else {
|
|
54
|
+
<fieldset [attr.role]="current.annotations.title === undefined ? 'none' : null">
|
|
55
|
+
@if (current.annotations.title !== undefined) {
|
|
56
|
+
<legend>{{ current.annotations.title }}</legend>
|
|
57
|
+
}
|
|
58
|
+
<div>
|
|
59
|
+
<ng-container *ngTemplateOutlet="content" />
|
|
60
|
+
</div>
|
|
61
|
+
</fieldset>
|
|
62
|
+
}
|
|
63
|
+
<ng-template #content>
|
|
64
|
+
@for (child of children(); track childKey(child)) {
|
|
65
|
+
<texaryn-node-renderer [node]="child" />
|
|
66
|
+
}
|
|
67
|
+
@for (action of expandActions(); track action.target.reason) {
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
[attr.aria-label]="action.message.accessibleName"
|
|
71
|
+
(click)="expand(action.target.token)"
|
|
72
|
+
>{{ action.message.label }}</button>
|
|
73
|
+
}
|
|
74
|
+
</ng-template>
|
|
75
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NodeRenderer, selector: "texaryn-node-renderer", inputs: ["node"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
76
|
+
}
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.33", ngImport: i0, type: ObjectLayout, decorators: [{
|
|
78
|
+
type: Component,
|
|
79
|
+
args: [{
|
|
80
|
+
selector: 'texaryn-object-layout',
|
|
81
|
+
standalone: true,
|
|
82
|
+
imports: [NgTemplateOutlet, NodeRenderer],
|
|
83
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
84
|
+
template: `
|
|
85
|
+
@let current = currentNode();
|
|
86
|
+
@if (current.parentId === null) {
|
|
87
|
+
<div>
|
|
88
|
+
<ng-container *ngTemplateOutlet="content" />
|
|
89
|
+
</div>
|
|
90
|
+
} @else {
|
|
91
|
+
<fieldset [attr.role]="current.annotations.title === undefined ? 'none' : null">
|
|
92
|
+
@if (current.annotations.title !== undefined) {
|
|
93
|
+
<legend>{{ current.annotations.title }}</legend>
|
|
94
|
+
}
|
|
95
|
+
<div>
|
|
96
|
+
<ng-container *ngTemplateOutlet="content" />
|
|
97
|
+
</div>
|
|
98
|
+
</fieldset>
|
|
99
|
+
}
|
|
100
|
+
<ng-template #content>
|
|
101
|
+
@for (child of children(); track childKey(child)) {
|
|
102
|
+
<texaryn-node-renderer [node]="child" />
|
|
103
|
+
}
|
|
104
|
+
@for (action of expandActions(); track action.target.reason) {
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
[attr.aria-label]="action.message.accessibleName"
|
|
108
|
+
(click)="expand(action.target.token)"
|
|
109
|
+
>{{ action.message.label }}</button>
|
|
110
|
+
}
|
|
111
|
+
</ng-template>
|
|
112
|
+
`,
|
|
113
|
+
}]
|
|
114
|
+
}], propDecorators: { node: [{ type: i0.Input, args: [{ isSignal: true, alias: "node", required: true }] }] } });
|
|
115
|
+
//# sourceMappingURL=object-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-layout.js","sourceRoot":"","sources":["../../src/widgets/object-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACnF,OAAO,EAAE,eAAe,EAAE,cAAc,EA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
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Angular signal bindings and default widgets for Texaryn",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"json-schema",
|
|
8
|
+
"forms",
|
|
9
|
+
"form-builder",
|
|
10
|
+
"schema-driven",
|
|
11
|
+
"headless",
|
|
12
|
+
"angular-forms",
|
|
13
|
+
"dynamic-forms",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"funding": {
|
|
19
|
+
"type": "github",
|
|
20
|
+
"url": "https://github.com/sponsors/hamzahamidi"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/texaryn/texaryn.git",
|
|
25
|
+
"directory": "packages/angular"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://texaryn.github.io/texaryn/",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/texaryn/texaryn/issues"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@texaryn/core": "^0.15.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@angular/common": ">=20.0.0",
|
|
51
|
+
"@angular/core": ">=20.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@angular/common": "20.3.33",
|
|
55
|
+
"@angular/compiler": "20.3.33",
|
|
56
|
+
"@angular/compiler-cli": "20.3.33",
|
|
57
|
+
"@angular/core": "20.3.33",
|
|
58
|
+
"@angular/platform-browser": "20.3.33",
|
|
59
|
+
"jsdom": "^25.0.0",
|
|
60
|
+
"rxjs": "^7.8.2",
|
|
61
|
+
"typescript": "~5.8.0",
|
|
62
|
+
"@texaryn/schema-json": "0.8.3"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "pnpm --filter @texaryn/core build && ngc -p tsconfig.json",
|
|
66
|
+
"typecheck": "pnpm --filter @texaryn/core build && ngc --noEmit -p tsconfig.typecheck.json"
|
|
67
|
+
}
|
|
6
68
|
}
|