jsonforms-nuxt-ui-renderers 0.1.1
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/LICENSE +22 -0
- package/README.md +66 -0
- package/dist/index.cjs +896 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +895 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
// src/nuxtUiRenderers.ts
|
|
2
|
+
import {
|
|
3
|
+
isBooleanControl,
|
|
4
|
+
isEnumControl,
|
|
5
|
+
isIntegerControl,
|
|
6
|
+
isMultiLineControl,
|
|
7
|
+
isNumberControl,
|
|
8
|
+
isObjectControl,
|
|
9
|
+
isStringControl,
|
|
10
|
+
rankWith,
|
|
11
|
+
schemaTypeIs,
|
|
12
|
+
uiTypeIs
|
|
13
|
+
} from "@jsonforms/core";
|
|
14
|
+
import { markRaw } from "vue";
|
|
15
|
+
|
|
16
|
+
// src/renderers/complex/NuxtUiArrayListRenderer.ts
|
|
17
|
+
import {
|
|
18
|
+
Resolve,
|
|
19
|
+
composePaths,
|
|
20
|
+
createDefaultValue,
|
|
21
|
+
findUISchema,
|
|
22
|
+
getFirstPrimitiveProp
|
|
23
|
+
} from "@jsonforms/core";
|
|
24
|
+
import { DispatchRenderer, rendererProps, useJsonFormsArrayControl } from "@jsonforms/vue";
|
|
25
|
+
import { computed as computed2, defineComponent, h, resolveComponent } from "vue";
|
|
26
|
+
|
|
27
|
+
// src/renderers/util.ts
|
|
28
|
+
import { computed } from "vue";
|
|
29
|
+
function trimmedOrUndefined(input) {
|
|
30
|
+
const v = input?.trim();
|
|
31
|
+
return v ? v : void 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/renderers/complex/NuxtUiArrayListRenderer.ts
|
|
35
|
+
var NuxtUiArrayListRenderer = defineComponent({
|
|
36
|
+
name: "NuxtUiArrayListRenderer",
|
|
37
|
+
components: { DispatchRenderer },
|
|
38
|
+
props: rendererProps(),
|
|
39
|
+
setup(props) {
|
|
40
|
+
const { control, addItem, removeItems, moveUp, moveDown } = useJsonFormsArrayControl(
|
|
41
|
+
props
|
|
42
|
+
);
|
|
43
|
+
const errorMessage = computed2(() => trimmedOrUndefined(control.value.errors));
|
|
44
|
+
const items = computed2(
|
|
45
|
+
() => Array.isArray(control.value.data) ? control.value.data : []
|
|
46
|
+
);
|
|
47
|
+
const arraySchema = computed2(() => {
|
|
48
|
+
try {
|
|
49
|
+
return Resolve.schema(
|
|
50
|
+
props.schema,
|
|
51
|
+
control.value.uischema.scope,
|
|
52
|
+
control.value.rootSchema
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const maxItemsReached = computed2(() => {
|
|
59
|
+
const max = arraySchema.value?.maxItems;
|
|
60
|
+
return typeof max === "number" ? items.value.length >= max : false;
|
|
61
|
+
});
|
|
62
|
+
const minItemsReached = computed2(() => {
|
|
63
|
+
const min = arraySchema.value?.minItems;
|
|
64
|
+
return typeof min === "number" ? items.value.length <= min : false;
|
|
65
|
+
});
|
|
66
|
+
const childUiSchema = computed2(
|
|
67
|
+
() => findUISchema(
|
|
68
|
+
control.value.uischemas,
|
|
69
|
+
control.value.schema,
|
|
70
|
+
control.value.uischema.scope,
|
|
71
|
+
control.value.path,
|
|
72
|
+
void 0,
|
|
73
|
+
control.value.uischema,
|
|
74
|
+
control.value.rootSchema
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
function childLabelForIndex(index) {
|
|
78
|
+
const childLabelProp = getChildLabelPropFromUiSchemaOptions(control.value.uischema.options) ?? getFirstPrimitiveProp(control.value.schema);
|
|
79
|
+
if (!childLabelProp) return `${index}`;
|
|
80
|
+
const labelValue = Resolve.data(
|
|
81
|
+
control.value.data,
|
|
82
|
+
composePaths(`${index}`, childLabelProp)
|
|
83
|
+
);
|
|
84
|
+
if (labelValue === void 0 || labelValue === null || Number.isNaN(labelValue)) {
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
return String(labelValue);
|
|
88
|
+
}
|
|
89
|
+
function getChildLabelPropFromUiSchemaOptions(options) {
|
|
90
|
+
if (!options || typeof options !== "object") return void 0;
|
|
91
|
+
const value = options.childLabelProp;
|
|
92
|
+
return typeof value === "string" ? value : void 0;
|
|
93
|
+
}
|
|
94
|
+
function addButtonClick() {
|
|
95
|
+
addItem(
|
|
96
|
+
control.value.path,
|
|
97
|
+
createDefaultValue(control.value.schema, control.value.rootSchema)
|
|
98
|
+
)();
|
|
99
|
+
}
|
|
100
|
+
return () => {
|
|
101
|
+
if (!control.value.visible) return null;
|
|
102
|
+
const UFormField = resolveComponent("UFormField");
|
|
103
|
+
const UButton = resolveComponent("UButton");
|
|
104
|
+
return h(
|
|
105
|
+
"div",
|
|
106
|
+
{},
|
|
107
|
+
h(
|
|
108
|
+
UFormField,
|
|
109
|
+
{
|
|
110
|
+
label: control.value.label,
|
|
111
|
+
description: control.value.description,
|
|
112
|
+
required: control.value.required,
|
|
113
|
+
error: errorMessage.value
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
default: () => h("div", { class: "flex flex-col gap-3" }, [
|
|
117
|
+
h("div", { class: "flex items-center justify-between gap-3" }, [
|
|
118
|
+
h(
|
|
119
|
+
"div",
|
|
120
|
+
{ class: "text-xs text-gray-500" },
|
|
121
|
+
`${items.value.length} items`
|
|
122
|
+
),
|
|
123
|
+
h(
|
|
124
|
+
UButton,
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
size: "xs",
|
|
128
|
+
variant: "soft",
|
|
129
|
+
color: "neutral",
|
|
130
|
+
disabled: !control.value.enabled || maxItemsReached.value,
|
|
131
|
+
onClick: addButtonClick
|
|
132
|
+
},
|
|
133
|
+
{ default: () => "Add" }
|
|
134
|
+
)
|
|
135
|
+
]),
|
|
136
|
+
items.value.length === 0 ? h(
|
|
137
|
+
"div",
|
|
138
|
+
{ class: "text-sm text-gray-500" },
|
|
139
|
+
"No items."
|
|
140
|
+
) : null,
|
|
141
|
+
...items.value.map(
|
|
142
|
+
(_item, index) => h(
|
|
143
|
+
"div",
|
|
144
|
+
{ key: `${control.value.path}-${index}`, class: "rounded border p-3" },
|
|
145
|
+
[
|
|
146
|
+
h(
|
|
147
|
+
"div",
|
|
148
|
+
{ class: "mb-3 flex items-start justify-between gap-3" },
|
|
149
|
+
[
|
|
150
|
+
h("div", { class: "min-w-0" }, [
|
|
151
|
+
h(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
class: "text-xs font-semibold text-gray-700 dark:text-gray-200"
|
|
155
|
+
},
|
|
156
|
+
[
|
|
157
|
+
`Item ${index + 1}`,
|
|
158
|
+
childLabelForIndex(index) ? h(
|
|
159
|
+
"span",
|
|
160
|
+
{
|
|
161
|
+
class: "font-normal text-gray-500"
|
|
162
|
+
},
|
|
163
|
+
` \u2014 ${childLabelForIndex(index)}`
|
|
164
|
+
) : null
|
|
165
|
+
]
|
|
166
|
+
)
|
|
167
|
+
]),
|
|
168
|
+
h("div", { class: "flex flex-none items-center gap-1" }, [
|
|
169
|
+
h(
|
|
170
|
+
UButton,
|
|
171
|
+
{
|
|
172
|
+
type: "button",
|
|
173
|
+
size: "xs",
|
|
174
|
+
variant: "ghost",
|
|
175
|
+
color: "neutral",
|
|
176
|
+
disabled: !control.value.enabled || index === 0,
|
|
177
|
+
onClick: () => moveUp?.(control.value.path, index)()
|
|
178
|
+
},
|
|
179
|
+
{ default: () => "Up" }
|
|
180
|
+
),
|
|
181
|
+
h(
|
|
182
|
+
UButton,
|
|
183
|
+
{
|
|
184
|
+
type: "button",
|
|
185
|
+
size: "xs",
|
|
186
|
+
variant: "ghost",
|
|
187
|
+
color: "neutral",
|
|
188
|
+
disabled: !control.value.enabled || index >= items.value.length - 1,
|
|
189
|
+
onClick: () => moveDown?.(control.value.path, index)()
|
|
190
|
+
},
|
|
191
|
+
{ default: () => "Down" }
|
|
192
|
+
),
|
|
193
|
+
h(
|
|
194
|
+
UButton,
|
|
195
|
+
{
|
|
196
|
+
type: "button",
|
|
197
|
+
size: "xs",
|
|
198
|
+
variant: "ghost",
|
|
199
|
+
color: "error",
|
|
200
|
+
disabled: !control.value.enabled || minItemsReached.value,
|
|
201
|
+
onClick: () => removeItems?.(control.value.path, [index])()
|
|
202
|
+
},
|
|
203
|
+
{ default: () => "Remove" }
|
|
204
|
+
)
|
|
205
|
+
])
|
|
206
|
+
]
|
|
207
|
+
),
|
|
208
|
+
h(DispatchRenderer, {
|
|
209
|
+
schema: control.value.schema,
|
|
210
|
+
uischema: childUiSchema.value,
|
|
211
|
+
path: composePaths(control.value.path, `${index}`),
|
|
212
|
+
enabled: control.value.enabled,
|
|
213
|
+
renderers: control.value.renderers,
|
|
214
|
+
cells: control.value.cells
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
])
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// src/renderers/complex/NuxtUiObjectRenderer.ts
|
|
228
|
+
import { Generate, findUISchema as findUISchema2 } from "@jsonforms/core";
|
|
229
|
+
import {
|
|
230
|
+
DispatchRenderer as DispatchRenderer2,
|
|
231
|
+
rendererProps as rendererProps2,
|
|
232
|
+
useJsonFormsControlWithDetail
|
|
233
|
+
} from "@jsonforms/vue";
|
|
234
|
+
import { computed as computed3, defineComponent as defineComponent2, h as h2 } from "vue";
|
|
235
|
+
var NuxtUiObjectRenderer = defineComponent2({
|
|
236
|
+
name: "NuxtUiObjectRenderer",
|
|
237
|
+
components: { DispatchRenderer: DispatchRenderer2 },
|
|
238
|
+
props: rendererProps2(),
|
|
239
|
+
setup(props) {
|
|
240
|
+
const { control } = useJsonFormsControlWithDetail(
|
|
241
|
+
props
|
|
242
|
+
);
|
|
243
|
+
const detailUiSchema = computed3(() => {
|
|
244
|
+
const uiSchemaGenerator = () => {
|
|
245
|
+
const uiSchema = Generate.uiSchema(
|
|
246
|
+
control.value.schema,
|
|
247
|
+
"Group",
|
|
248
|
+
void 0,
|
|
249
|
+
control.value.rootSchema
|
|
250
|
+
);
|
|
251
|
+
if (!control.value.path) {
|
|
252
|
+
uiSchema.type = "VerticalLayout";
|
|
253
|
+
} else {
|
|
254
|
+
;
|
|
255
|
+
uiSchema.label = control.value.label;
|
|
256
|
+
}
|
|
257
|
+
return uiSchema;
|
|
258
|
+
};
|
|
259
|
+
return findUISchema2(
|
|
260
|
+
control.value.uischemas,
|
|
261
|
+
control.value.schema,
|
|
262
|
+
control.value.uischema.scope,
|
|
263
|
+
control.value.path,
|
|
264
|
+
uiSchemaGenerator,
|
|
265
|
+
control.value.uischema,
|
|
266
|
+
control.value.rootSchema
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
return () => {
|
|
270
|
+
if (!control.value.visible) return null;
|
|
271
|
+
return h2(DispatchRenderer2, {
|
|
272
|
+
visible: control.value.visible,
|
|
273
|
+
enabled: control.value.enabled,
|
|
274
|
+
schema: control.value.schema,
|
|
275
|
+
uischema: detailUiSchema.value,
|
|
276
|
+
path: control.value.path,
|
|
277
|
+
renderers: control.value.renderers,
|
|
278
|
+
cells: control.value.cells
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// src/renderers/controls/NuxtUiBooleanControl.ts
|
|
285
|
+
import { rendererProps as rendererProps3, useJsonFormsControl } from "@jsonforms/vue";
|
|
286
|
+
import { computed as computed4, defineComponent as defineComponent3, h as h3, resolveComponent as resolveComponent2 } from "vue";
|
|
287
|
+
var NuxtUiBooleanControl = defineComponent3({
|
|
288
|
+
name: "NuxtUiBooleanControl",
|
|
289
|
+
props: rendererProps3(),
|
|
290
|
+
setup(props) {
|
|
291
|
+
const { control, handleChange } = useJsonFormsControl(
|
|
292
|
+
props
|
|
293
|
+
);
|
|
294
|
+
const errorMessage = computed4(() => trimmedOrUndefined(control.value.errors));
|
|
295
|
+
const modelValue = computed4({
|
|
296
|
+
get: () => Boolean(control.value.data),
|
|
297
|
+
set: (v) => handleChange(control.value.path, v)
|
|
298
|
+
});
|
|
299
|
+
return () => {
|
|
300
|
+
if (!control.value.visible) return null;
|
|
301
|
+
const UFormField = resolveComponent2("UFormField");
|
|
302
|
+
const USwitch = resolveComponent2("USwitch");
|
|
303
|
+
return h3(
|
|
304
|
+
"div",
|
|
305
|
+
{},
|
|
306
|
+
h3(
|
|
307
|
+
UFormField,
|
|
308
|
+
{
|
|
309
|
+
label: control.value.label,
|
|
310
|
+
description: control.value.description,
|
|
311
|
+
required: control.value.required,
|
|
312
|
+
error: errorMessage.value
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
default: () => h3(
|
|
316
|
+
"div",
|
|
317
|
+
{ class: "flex items-center justify-between gap-3" },
|
|
318
|
+
h3(USwitch, {
|
|
319
|
+
modelValue: modelValue.value,
|
|
320
|
+
disabled: !control.value.enabled,
|
|
321
|
+
"aria-invalid": Boolean(errorMessage.value),
|
|
322
|
+
"onUpdate:modelValue": (v) => {
|
|
323
|
+
modelValue.value = v;
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
)
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// src/renderers/controls/NuxtUiEnumControl.ts
|
|
335
|
+
import { rendererProps as rendererProps4, useJsonFormsControl as useJsonFormsControl2 } from "@jsonforms/vue";
|
|
336
|
+
import { computed as computed5, defineComponent as defineComponent4, h as h4, resolveComponent as resolveComponent3 } from "vue";
|
|
337
|
+
function schemaEnumOptions(schema) {
|
|
338
|
+
if (!schema) return [];
|
|
339
|
+
if (Array.isArray(schema.enum)) {
|
|
340
|
+
return schema.enum.map((v) => ({ label: String(v), value: v }));
|
|
341
|
+
}
|
|
342
|
+
const oneOf = schema.oneOf;
|
|
343
|
+
if (!Array.isArray(oneOf)) return [];
|
|
344
|
+
const out = [];
|
|
345
|
+
for (const entry of oneOf) {
|
|
346
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
347
|
+
const maybe = entry;
|
|
348
|
+
if (!("const" in maybe)) continue;
|
|
349
|
+
out.push({
|
|
350
|
+
value: maybe.const,
|
|
351
|
+
label: typeof maybe.title === "string" && maybe.title.trim() ? maybe.title : String(maybe.const)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return out;
|
|
355
|
+
}
|
|
356
|
+
var NuxtUiEnumControl = defineComponent4({
|
|
357
|
+
name: "NuxtUiEnumControl",
|
|
358
|
+
props: rendererProps4(),
|
|
359
|
+
setup(props) {
|
|
360
|
+
const { control, handleChange } = useJsonFormsControl2(
|
|
361
|
+
props
|
|
362
|
+
);
|
|
363
|
+
const errorMessage = computed5(() => trimmedOrUndefined(control.value.errors));
|
|
364
|
+
const options = computed5(() => schemaEnumOptions(control.value.schema));
|
|
365
|
+
const selectedValue = computed5({
|
|
366
|
+
get: () => control.value.data,
|
|
367
|
+
set: (v) => handleChange(control.value.path, v)
|
|
368
|
+
});
|
|
369
|
+
return () => {
|
|
370
|
+
if (!control.value.visible) return null;
|
|
371
|
+
const UFormField = resolveComponent3("UFormField");
|
|
372
|
+
const USelectMenu = resolveComponent3("USelectMenu");
|
|
373
|
+
return h4(
|
|
374
|
+
"div",
|
|
375
|
+
{},
|
|
376
|
+
h4(
|
|
377
|
+
UFormField,
|
|
378
|
+
{
|
|
379
|
+
label: control.value.label,
|
|
380
|
+
description: control.value.description,
|
|
381
|
+
required: control.value.required,
|
|
382
|
+
error: errorMessage.value
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
default: () => h4(USelectMenu, {
|
|
386
|
+
modelValue: selectedValue.value,
|
|
387
|
+
items: options.value,
|
|
388
|
+
valueKey: "value",
|
|
389
|
+
labelKey: "label",
|
|
390
|
+
disabled: !control.value.enabled,
|
|
391
|
+
color: errorMessage.value ? "error" : void 0,
|
|
392
|
+
"aria-invalid": Boolean(errorMessage.value),
|
|
393
|
+
placeholder: "Select...",
|
|
394
|
+
"onUpdate:modelValue": (v) => {
|
|
395
|
+
selectedValue.value = v;
|
|
396
|
+
}
|
|
397
|
+
})
|
|
398
|
+
}
|
|
399
|
+
)
|
|
400
|
+
);
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// src/renderers/controls/NuxtUiIntegerControl.ts
|
|
406
|
+
import { rendererProps as rendererProps5, useJsonFormsControl as useJsonFormsControl3 } from "@jsonforms/vue";
|
|
407
|
+
import { computed as computed6, defineComponent as defineComponent5, h as h5, resolveComponent as resolveComponent4 } from "vue";
|
|
408
|
+
var NuxtUiIntegerControl = defineComponent5({
|
|
409
|
+
name: "NuxtUiIntegerControl",
|
|
410
|
+
props: rendererProps5(),
|
|
411
|
+
setup(props) {
|
|
412
|
+
const { control, handleChange } = useJsonFormsControl3(
|
|
413
|
+
props
|
|
414
|
+
);
|
|
415
|
+
const errorMessage = computed6(() => trimmedOrUndefined(control.value.errors));
|
|
416
|
+
const modelValue = computed6(() => {
|
|
417
|
+
const v = control.value.data;
|
|
418
|
+
return v === null || v === void 0 ? "" : String(v);
|
|
419
|
+
});
|
|
420
|
+
function onUpdate(raw) {
|
|
421
|
+
const trimmed = raw.trim();
|
|
422
|
+
if (trimmed === "") {
|
|
423
|
+
handleChange(control.value.path, void 0);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
427
|
+
handleChange(control.value.path, Number.isFinite(parsed) ? parsed : void 0);
|
|
428
|
+
}
|
|
429
|
+
return () => {
|
|
430
|
+
if (!control.value.visible) return null;
|
|
431
|
+
const UFormField = resolveComponent4("UFormField");
|
|
432
|
+
const UInput = resolveComponent4("UInput");
|
|
433
|
+
return h5(
|
|
434
|
+
"div",
|
|
435
|
+
{},
|
|
436
|
+
h5(
|
|
437
|
+
UFormField,
|
|
438
|
+
{
|
|
439
|
+
label: control.value.label,
|
|
440
|
+
description: control.value.description,
|
|
441
|
+
required: control.value.required,
|
|
442
|
+
error: errorMessage.value
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
default: () => h5(UInput, {
|
|
446
|
+
type: "number",
|
|
447
|
+
inputmode: "numeric",
|
|
448
|
+
step: "1",
|
|
449
|
+
modelValue: modelValue.value,
|
|
450
|
+
disabled: !control.value.enabled,
|
|
451
|
+
color: errorMessage.value ? "error" : void 0,
|
|
452
|
+
"aria-invalid": Boolean(errorMessage.value),
|
|
453
|
+
"onUpdate:modelValue": onUpdate
|
|
454
|
+
})
|
|
455
|
+
}
|
|
456
|
+
)
|
|
457
|
+
);
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// src/renderers/controls/NuxtUiNumberControl.ts
|
|
463
|
+
import { rendererProps as rendererProps6, useJsonFormsControl as useJsonFormsControl4 } from "@jsonforms/vue";
|
|
464
|
+
import { computed as computed7, defineComponent as defineComponent6, h as h6, resolveComponent as resolveComponent5 } from "vue";
|
|
465
|
+
var NuxtUiNumberControl = defineComponent6({
|
|
466
|
+
name: "NuxtUiNumberControl",
|
|
467
|
+
props: rendererProps6(),
|
|
468
|
+
setup(props) {
|
|
469
|
+
const { control, handleChange } = useJsonFormsControl4(
|
|
470
|
+
props
|
|
471
|
+
);
|
|
472
|
+
const errorMessage = computed7(() => trimmedOrUndefined(control.value.errors));
|
|
473
|
+
const modelValue = computed7(() => {
|
|
474
|
+
const v = control.value.data;
|
|
475
|
+
return v === null || v === void 0 ? "" : String(v);
|
|
476
|
+
});
|
|
477
|
+
function onUpdate(raw) {
|
|
478
|
+
const trimmed = raw.trim();
|
|
479
|
+
if (trimmed === "") {
|
|
480
|
+
handleChange(control.value.path, void 0);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const parsed = Number(trimmed);
|
|
484
|
+
handleChange(control.value.path, Number.isFinite(parsed) ? parsed : void 0);
|
|
485
|
+
}
|
|
486
|
+
return () => {
|
|
487
|
+
if (!control.value.visible) return null;
|
|
488
|
+
const UFormField = resolveComponent5("UFormField");
|
|
489
|
+
const UInput = resolveComponent5("UInput");
|
|
490
|
+
return h6(
|
|
491
|
+
"div",
|
|
492
|
+
{},
|
|
493
|
+
h6(
|
|
494
|
+
UFormField,
|
|
495
|
+
{
|
|
496
|
+
label: control.value.label,
|
|
497
|
+
description: control.value.description,
|
|
498
|
+
required: control.value.required,
|
|
499
|
+
error: errorMessage.value
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
default: () => h6(UInput, {
|
|
503
|
+
type: "number",
|
|
504
|
+
inputmode: "decimal",
|
|
505
|
+
modelValue: modelValue.value,
|
|
506
|
+
disabled: !control.value.enabled,
|
|
507
|
+
color: errorMessage.value ? "error" : void 0,
|
|
508
|
+
"aria-invalid": Boolean(errorMessage.value),
|
|
509
|
+
"onUpdate:modelValue": onUpdate
|
|
510
|
+
})
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// src/renderers/controls/NuxtUiStringControl.ts
|
|
519
|
+
import { rendererProps as rendererProps7, useJsonFormsControl as useJsonFormsControl5 } from "@jsonforms/vue";
|
|
520
|
+
import {
|
|
521
|
+
computed as computed8,
|
|
522
|
+
defineComponent as defineComponent7,
|
|
523
|
+
h as h7,
|
|
524
|
+
resolveComponent as resolveComponent6
|
|
525
|
+
} from "vue";
|
|
526
|
+
var NuxtUiStringControl = defineComponent7({
|
|
527
|
+
name: "NuxtUiStringControl",
|
|
528
|
+
props: rendererProps7(),
|
|
529
|
+
setup(props) {
|
|
530
|
+
const { control, handleChange } = useJsonFormsControl5(
|
|
531
|
+
props
|
|
532
|
+
);
|
|
533
|
+
const errorMessage = computed8(() => trimmedOrUndefined(control.value.errors));
|
|
534
|
+
return () => {
|
|
535
|
+
if (!control.value.visible) return null;
|
|
536
|
+
const UFormField = resolveComponent6("UFormField");
|
|
537
|
+
const UInput = resolveComponent6("UInput");
|
|
538
|
+
return h7(
|
|
539
|
+
"div",
|
|
540
|
+
{},
|
|
541
|
+
h7(
|
|
542
|
+
UFormField,
|
|
543
|
+
{
|
|
544
|
+
label: control.value.label,
|
|
545
|
+
description: control.value.description,
|
|
546
|
+
required: control.value.required,
|
|
547
|
+
error: errorMessage.value
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
default: () => h7(UInput, {
|
|
551
|
+
modelValue: control.value.data ?? "",
|
|
552
|
+
class: "w-full",
|
|
553
|
+
disabled: !control.value.enabled,
|
|
554
|
+
color: errorMessage.value ? "error" : void 0,
|
|
555
|
+
"aria-invalid": Boolean(errorMessage.value),
|
|
556
|
+
"onUpdate:modelValue": (v) => handleChange(control.value.path, v)
|
|
557
|
+
})
|
|
558
|
+
}
|
|
559
|
+
)
|
|
560
|
+
);
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
// src/renderers/controls/NuxtUiTextareaControl.ts
|
|
566
|
+
import { rendererProps as rendererProps8, useJsonFormsControl as useJsonFormsControl6 } from "@jsonforms/vue";
|
|
567
|
+
import { computed as computed9, defineComponent as defineComponent8, h as h8, resolveComponent as resolveComponent7 } from "vue";
|
|
568
|
+
var NuxtUiTextareaControl = defineComponent8({
|
|
569
|
+
name: "NuxtUiTextareaControl",
|
|
570
|
+
props: rendererProps8(),
|
|
571
|
+
setup(props) {
|
|
572
|
+
const { control, handleChange } = useJsonFormsControl6(
|
|
573
|
+
props
|
|
574
|
+
);
|
|
575
|
+
const errorMessage = computed9(() => trimmedOrUndefined(control.value.errors));
|
|
576
|
+
return () => {
|
|
577
|
+
if (!control.value.visible) return null;
|
|
578
|
+
const UFormField = resolveComponent7("UFormField");
|
|
579
|
+
const UTextarea = resolveComponent7("UTextarea");
|
|
580
|
+
return h8(
|
|
581
|
+
"div",
|
|
582
|
+
{},
|
|
583
|
+
h8(
|
|
584
|
+
UFormField,
|
|
585
|
+
{
|
|
586
|
+
label: control.value.label,
|
|
587
|
+
description: control.value.description,
|
|
588
|
+
required: control.value.required,
|
|
589
|
+
error: errorMessage.value
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
default: () => h8(UTextarea, {
|
|
593
|
+
modelValue: control.value.data ?? "",
|
|
594
|
+
class: "w-full",
|
|
595
|
+
disabled: !control.value.enabled,
|
|
596
|
+
color: errorMessage.value ? "error" : void 0,
|
|
597
|
+
"aria-invalid": Boolean(errorMessage.value),
|
|
598
|
+
rows: 5,
|
|
599
|
+
"onUpdate:modelValue": (v) => handleChange(control.value.path, v)
|
|
600
|
+
})
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
);
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// src/renderers/layouts/NuxtUiCategorizationRenderer.ts
|
|
609
|
+
import { DispatchRenderer as DispatchRenderer3, rendererProps as rendererProps9, useJsonFormsCategorization } from "@jsonforms/vue";
|
|
610
|
+
import { defineComponent as defineComponent9, h as h9 } from "vue";
|
|
611
|
+
var NuxtUiCategorizationRenderer = defineComponent9({
|
|
612
|
+
name: "NuxtUiCategorizationRenderer",
|
|
613
|
+
components: { DispatchRenderer: DispatchRenderer3 },
|
|
614
|
+
props: rendererProps9(),
|
|
615
|
+
setup(props) {
|
|
616
|
+
const { layout, categories } = useJsonFormsCategorization(
|
|
617
|
+
props
|
|
618
|
+
);
|
|
619
|
+
return () => {
|
|
620
|
+
if (!layout.value.visible) return null;
|
|
621
|
+
return h9(
|
|
622
|
+
"div",
|
|
623
|
+
{ class: "flex flex-col gap-6" },
|
|
624
|
+
categories.map((categoryRef, catIndex) => {
|
|
625
|
+
const category = categoryRef.value;
|
|
626
|
+
const elements = category.uischema.elements ?? [];
|
|
627
|
+
return h9(
|
|
628
|
+
"div",
|
|
629
|
+
{ key: `${layout.value.path}-cat-${catIndex}`, class: "flex flex-col gap-3" },
|
|
630
|
+
[
|
|
631
|
+
category.label ? h9("div", { class: "text-sm font-semibold" }, category.label) : null,
|
|
632
|
+
h9(
|
|
633
|
+
"div",
|
|
634
|
+
{ class: "flex flex-col gap-3" },
|
|
635
|
+
elements.map(
|
|
636
|
+
(element, index) => h9(
|
|
637
|
+
"div",
|
|
638
|
+
{ key: `${category.path}-${index}` },
|
|
639
|
+
h9(DispatchRenderer3, {
|
|
640
|
+
schema: category.schema,
|
|
641
|
+
uischema: element,
|
|
642
|
+
path: category.path,
|
|
643
|
+
enabled: category.enabled,
|
|
644
|
+
renderers: category.renderers,
|
|
645
|
+
cells: category.cells
|
|
646
|
+
})
|
|
647
|
+
)
|
|
648
|
+
)
|
|
649
|
+
)
|
|
650
|
+
]
|
|
651
|
+
);
|
|
652
|
+
})
|
|
653
|
+
);
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
// src/renderers/layouts/NuxtUiCategoryRenderer.ts
|
|
659
|
+
import { DispatchRenderer as DispatchRenderer4, rendererProps as rendererProps10, useJsonFormsLayout } from "@jsonforms/vue";
|
|
660
|
+
import { defineComponent as defineComponent10, h as h10 } from "vue";
|
|
661
|
+
var NuxtUiCategoryRenderer = defineComponent10({
|
|
662
|
+
name: "NuxtUiCategoryRenderer",
|
|
663
|
+
components: { DispatchRenderer: DispatchRenderer4 },
|
|
664
|
+
props: rendererProps10(),
|
|
665
|
+
setup(props) {
|
|
666
|
+
const { layout } = useJsonFormsLayout(
|
|
667
|
+
props
|
|
668
|
+
);
|
|
669
|
+
return () => {
|
|
670
|
+
if (!layout.value.visible) return null;
|
|
671
|
+
const elements = layout.value.uischema.elements ?? [];
|
|
672
|
+
return h10("div", { class: "flex flex-col gap-3" }, [
|
|
673
|
+
layout.value.label ? h10("div", { class: "text-sm font-semibold" }, layout.value.label) : null,
|
|
674
|
+
h10(
|
|
675
|
+
"div",
|
|
676
|
+
{ class: "flex flex-col gap-3" },
|
|
677
|
+
elements.map(
|
|
678
|
+
(element, index) => h10(
|
|
679
|
+
"div",
|
|
680
|
+
{ key: `${layout.value.path}-${index}` },
|
|
681
|
+
h10(DispatchRenderer4, {
|
|
682
|
+
schema: layout.value.schema,
|
|
683
|
+
uischema: element,
|
|
684
|
+
path: layout.value.path,
|
|
685
|
+
enabled: layout.value.enabled,
|
|
686
|
+
renderers: layout.value.renderers,
|
|
687
|
+
cells: layout.value.cells
|
|
688
|
+
})
|
|
689
|
+
)
|
|
690
|
+
)
|
|
691
|
+
)
|
|
692
|
+
]);
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
// src/renderers/layouts/NuxtUiGroupRenderer.ts
|
|
698
|
+
import { DispatchRenderer as DispatchRenderer5, rendererProps as rendererProps11, useJsonFormsLayout as useJsonFormsLayout2 } from "@jsonforms/vue";
|
|
699
|
+
import { defineComponent as defineComponent11, h as h11 } from "vue";
|
|
700
|
+
var NuxtUiGroupRenderer = defineComponent11({
|
|
701
|
+
name: "NuxtUiGroupRenderer",
|
|
702
|
+
components: { DispatchRenderer: DispatchRenderer5 },
|
|
703
|
+
props: rendererProps11(),
|
|
704
|
+
setup(props) {
|
|
705
|
+
const { layout } = useJsonFormsLayout2(
|
|
706
|
+
props
|
|
707
|
+
);
|
|
708
|
+
return () => {
|
|
709
|
+
if (!layout.value.visible) return null;
|
|
710
|
+
const elements = layout.value.uischema.elements ?? [];
|
|
711
|
+
return h11("div", { class: "rounded border p-3" }, [
|
|
712
|
+
layout.value.label ? h11("div", { class: "mb-3 text-sm font-semibold" }, layout.value.label) : null,
|
|
713
|
+
h11(
|
|
714
|
+
"div",
|
|
715
|
+
{ class: "flex flex-col gap-3" },
|
|
716
|
+
elements.map(
|
|
717
|
+
(element, index) => h11(
|
|
718
|
+
"div",
|
|
719
|
+
{ key: `${layout.value.path}-${index}` },
|
|
720
|
+
h11(DispatchRenderer5, {
|
|
721
|
+
schema: layout.value.schema,
|
|
722
|
+
uischema: element,
|
|
723
|
+
path: layout.value.path,
|
|
724
|
+
enabled: layout.value.enabled,
|
|
725
|
+
renderers: layout.value.renderers,
|
|
726
|
+
cells: layout.value.cells
|
|
727
|
+
})
|
|
728
|
+
)
|
|
729
|
+
)
|
|
730
|
+
)
|
|
731
|
+
]);
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
// src/renderers/layouts/NuxtUiHorizontalLayoutRenderer.ts
|
|
737
|
+
import { DispatchRenderer as DispatchRenderer6, rendererProps as rendererProps12, useJsonFormsLayout as useJsonFormsLayout3 } from "@jsonforms/vue";
|
|
738
|
+
import { defineComponent as defineComponent12, h as h12 } from "vue";
|
|
739
|
+
var NuxtUiHorizontalLayoutRenderer = defineComponent12({
|
|
740
|
+
name: "NuxtUiHorizontalLayoutRenderer",
|
|
741
|
+
components: { DispatchRenderer: DispatchRenderer6 },
|
|
742
|
+
props: rendererProps12(),
|
|
743
|
+
setup(props) {
|
|
744
|
+
const { layout } = useJsonFormsLayout3(
|
|
745
|
+
props
|
|
746
|
+
);
|
|
747
|
+
return () => {
|
|
748
|
+
if (!layout.value.visible) return null;
|
|
749
|
+
const elements = layout.value.uischema.elements ?? [];
|
|
750
|
+
return h12(
|
|
751
|
+
"div",
|
|
752
|
+
{ class: "flex flex-col gap-3 md:flex-row md:flex-wrap" },
|
|
753
|
+
elements.map(
|
|
754
|
+
(element, index) => h12(
|
|
755
|
+
"div",
|
|
756
|
+
{ key: `${layout.value.path}-${index}`, class: "min-w-0 flex-1" },
|
|
757
|
+
h12(DispatchRenderer6, {
|
|
758
|
+
schema: layout.value.schema,
|
|
759
|
+
uischema: element,
|
|
760
|
+
path: layout.value.path,
|
|
761
|
+
enabled: layout.value.enabled,
|
|
762
|
+
renderers: layout.value.renderers,
|
|
763
|
+
cells: layout.value.cells
|
|
764
|
+
})
|
|
765
|
+
)
|
|
766
|
+
)
|
|
767
|
+
);
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
// src/renderers/layouts/NuxtUiLabelRenderer.ts
|
|
773
|
+
import { rendererProps as rendererProps13, useJsonFormsLabel } from "@jsonforms/vue";
|
|
774
|
+
import { defineComponent as defineComponent13, h as h13 } from "vue";
|
|
775
|
+
var NuxtUiLabelRenderer = defineComponent13({
|
|
776
|
+
name: "NuxtUiLabelRenderer",
|
|
777
|
+
props: rendererProps13(),
|
|
778
|
+
setup(props) {
|
|
779
|
+
const { label } = useJsonFormsLabel(
|
|
780
|
+
props
|
|
781
|
+
);
|
|
782
|
+
return () => {
|
|
783
|
+
if (!label.value.visible) return null;
|
|
784
|
+
return h13(
|
|
785
|
+
"div",
|
|
786
|
+
{ class: "text-sm text-gray-600 dark:text-gray-300" },
|
|
787
|
+
label.value.text
|
|
788
|
+
);
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
// src/renderers/layouts/NuxtUiVerticalLayoutRenderer.ts
|
|
794
|
+
import { DispatchRenderer as DispatchRenderer7, rendererProps as rendererProps14, useJsonFormsLayout as useJsonFormsLayout4 } from "@jsonforms/vue";
|
|
795
|
+
import { defineComponent as defineComponent14, h as h14 } from "vue";
|
|
796
|
+
var NuxtUiVerticalLayoutRenderer = defineComponent14({
|
|
797
|
+
name: "NuxtUiVerticalLayoutRenderer",
|
|
798
|
+
components: { DispatchRenderer: DispatchRenderer7 },
|
|
799
|
+
props: rendererProps14(),
|
|
800
|
+
setup(props) {
|
|
801
|
+
const { layout } = useJsonFormsLayout4(
|
|
802
|
+
props
|
|
803
|
+
);
|
|
804
|
+
return () => {
|
|
805
|
+
if (!layout.value.visible) return null;
|
|
806
|
+
const elements = layout.value.uischema.elements ?? [];
|
|
807
|
+
return h14(
|
|
808
|
+
"div",
|
|
809
|
+
{ class: "flex flex-col gap-3" },
|
|
810
|
+
elements.map(
|
|
811
|
+
(element, index) => h14(
|
|
812
|
+
"div",
|
|
813
|
+
{ key: `${layout.value.path}-${index}` },
|
|
814
|
+
h14(DispatchRenderer7, {
|
|
815
|
+
schema: layout.value.schema,
|
|
816
|
+
uischema: element,
|
|
817
|
+
path: layout.value.path,
|
|
818
|
+
enabled: layout.value.enabled,
|
|
819
|
+
renderers: layout.value.renderers,
|
|
820
|
+
cells: layout.value.cells
|
|
821
|
+
})
|
|
822
|
+
)
|
|
823
|
+
)
|
|
824
|
+
);
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
// src/nuxtUiRenderers.ts
|
|
830
|
+
var RANK = 10;
|
|
831
|
+
var nuxtUiRenderers = [
|
|
832
|
+
// Layouts
|
|
833
|
+
{
|
|
834
|
+
tester: rankWith(RANK, uiTypeIs("VerticalLayout")),
|
|
835
|
+
renderer: markRaw(NuxtUiVerticalLayoutRenderer)
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
tester: rankWith(RANK, uiTypeIs("HorizontalLayout")),
|
|
839
|
+
renderer: markRaw(NuxtUiHorizontalLayoutRenderer)
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
tester: rankWith(RANK, uiTypeIs("Group")),
|
|
843
|
+
renderer: markRaw(NuxtUiGroupRenderer)
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
tester: rankWith(RANK, uiTypeIs("Categorization")),
|
|
847
|
+
renderer: markRaw(NuxtUiCategorizationRenderer)
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
tester: rankWith(RANK, uiTypeIs("Category")),
|
|
851
|
+
renderer: markRaw(NuxtUiCategoryRenderer)
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
tester: rankWith(RANK, uiTypeIs("Label")),
|
|
855
|
+
renderer: markRaw(NuxtUiLabelRenderer)
|
|
856
|
+
},
|
|
857
|
+
// Complex schemas
|
|
858
|
+
{
|
|
859
|
+
tester: rankWith(RANK, schemaTypeIs("array")),
|
|
860
|
+
renderer: markRaw(NuxtUiArrayListRenderer)
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
tester: rankWith(RANK, isObjectControl),
|
|
864
|
+
renderer: markRaw(NuxtUiObjectRenderer)
|
|
865
|
+
},
|
|
866
|
+
// Primitive controls
|
|
867
|
+
{
|
|
868
|
+
tester: rankWith(RANK, isMultiLineControl),
|
|
869
|
+
renderer: markRaw(NuxtUiTextareaControl)
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
tester: rankWith(RANK, isStringControl),
|
|
873
|
+
renderer: markRaw(NuxtUiStringControl)
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
tester: rankWith(RANK, isNumberControl),
|
|
877
|
+
renderer: markRaw(NuxtUiNumberControl)
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
tester: rankWith(RANK, isIntegerControl),
|
|
881
|
+
renderer: markRaw(NuxtUiIntegerControl)
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
tester: rankWith(RANK, isBooleanControl),
|
|
885
|
+
renderer: markRaw(NuxtUiBooleanControl)
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
tester: rankWith(RANK, isEnumControl),
|
|
889
|
+
renderer: markRaw(NuxtUiEnumControl)
|
|
890
|
+
}
|
|
891
|
+
];
|
|
892
|
+
export {
|
|
893
|
+
nuxtUiRenderers
|
|
894
|
+
};
|
|
895
|
+
//# sourceMappingURL=index.js.map
|