@ghentcdh/json-forms-vue 1.1.0 → 1.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.
Files changed (49) hide show
  1. package/composables/useFormEvents.d.ts +32 -0
  2. package/forms/Dispatch.vue.d.ts +10 -0
  3. package/forms/FormComponent.properties.d.ts +48 -0
  4. package/forms/FormComponent.vue.d.ts +68 -0
  5. package/forms/FormWithActions.properties.d.ts +52 -0
  6. package/forms/FormWithActions.vue.d.ts +258 -0
  7. package/forms/FormWithTable.properties.d.ts +65 -0
  8. package/forms/FormWithTable.vue.d.ts +90 -0
  9. package/forms/errorMessages.d.ts +10 -0
  10. package/forms/errorMode.d.ts +4 -0
  11. package/forms/modal/FormModal.properties.d.ts +64 -0
  12. package/forms/modal/FormModal.vue.d.ts +275 -0
  13. package/forms/modal/FormModalService.d.ts +14 -0
  14. package/forms/renderer-registry.d.ts +7 -0
  15. package/forms/renderers/array/ArrayRenderer.vue.d.ts +7 -0
  16. package/forms/renderers/array/ArrayRenderers.d.ts +10 -0
  17. package/forms/renderers/controls/AutocompleteControlRenderer.vue.d.ts +7 -0
  18. package/forms/renderers/controls/BooleanControlRenderer.vue.d.ts +7 -0
  19. package/forms/renderers/controls/MarkdownControlRenderer.vue.d.ts +7 -0
  20. package/forms/renderers/controls/MultiSelectControlRenderer.vue.d.ts +7 -0
  21. package/forms/renderers/controls/NumberControlRenderer.vue.d.ts +7 -0
  22. package/forms/renderers/controls/SelectControlRenderer.vue.d.ts +7 -0
  23. package/forms/renderers/controls/StringControlRenderer.vue.d.ts +7 -0
  24. package/forms/renderers/controls/TextAreaControlRenderer.vue.d.ts +7 -0
  25. package/forms/renderers/controls/composable/UseControlBinding.d.ts +29 -0
  26. package/forms/renderers/controls/composable/UseFetchOption.d.ts +16 -0
  27. package/forms/renderers/controls/composable/UseInput.d.ts +24 -0
  28. package/forms/renderers/controls/composable/UseSelectBinding.d.ts +23 -0
  29. package/forms/renderers/controls/composable/resource.d.ts +187 -0
  30. package/forms/renderers/controls/index.d.ts +10 -0
  31. package/forms/renderers/index.d.ts +3 -0
  32. package/forms/renderers/layout/CollapseLayoutRenderer.vue.d.ts +7 -0
  33. package/forms/renderers/layout/LayoutRenderer.vue.d.ts +7 -0
  34. package/forms/renderers/layout/LayoutRenders.d.ts +10 -0
  35. package/forms/renderers/layout/colspan.d.ts +1 -0
  36. package/forms/renderes.d.ts +19 -0
  37. package/forms/scope.d.ts +4 -0
  38. package/forms/types.d.ts +36 -0
  39. package/package.json +9 -9
  40. package/renderes/tester.d.ts +11 -0
  41. package/repository/crud.repository.d.ts +32 -0
  42. package/repository/index.d.ts +1 -0
  43. package/table/filter/table-filter.vue.d.ts +13 -0
  44. package/table/index.d.ts +2 -0
  45. package/table/table.component.properties.d.ts +34 -0
  46. package/table/table.component.vue.d.ts +60 -0
  47. package/table/table.store.d.ts +29 -0
  48. package/index.mjs +0 -1892
  49. package/testing.mjs +0 -1
package/index.mjs DELETED
@@ -1,1892 +0,0 @@
1
- import { defineComponent, ref, watch, openBlock, createElementBlock, createElementVNode, createBlock, unref, withCtx, createTextVNode, createCommentVNode, Fragment, renderList, toDisplayString, computed, createVNode, inject, provide, resolveDynamicComponent, normalizeClass, useModel, mergeProps, renderSlot, mergeModels, isRef, toRef, onMounted, toRaw, nextTick, withModifiers } from "vue";
2
- import { isArray, isUndefined, pick, isEmpty } from "lodash-es";
3
- import { RequestSchema, extractFilters, findColumnDef, ControlType, uiFromJsonSchema, enforceRequiredStringMinLength } from "@ghentcdh/json-forms-core";
4
- import { Btn, BtnBadge, IconEnum, BooleanCell, TextCell, Table, mergeStyles, Modal, Color, ModalService, Autocomplete, Checkbox, Markdown, MultiSelect, InputNumber, SelectComponent, Input, Textarea, Collapse, myStyles, NotificationService, hasCustomEventListener, Card } from "@ghentcdh/ui";
5
- import { computedAsync } from "@vueuse/core";
6
- import { useRoute, useRouter } from "vue-router";
7
- import { useApi } from "@ghentcdh/tools-vue";
8
- import { z, fromJSONSchema } from "zod";
9
- import { useFieldArray, useField, useFieldValue, useForm } from "vee-validate";
10
- import { uiTypeIs, rankWith, or as or$1 } from "@jsonforms/core";
11
- import { and, optionIs, or, schemaTypeIs, isBooleanControl as isBooleanControl$1 } from "@jsonforms/core/src/testers/testers";
12
- import axios from "axios";
13
- const FormModalProperties = {
14
- /** Title displayed in the modal header. */
15
- modalTitle: { type: String, required: true },
16
- /** Label for the save button. */
17
- saveLabel: { type: String, default: "save" },
18
- /** Label for the cancel button. */
19
- cancelLabel: { type: String, default: "cancel" },
20
- /** JSON schema describing the shape of the form data. */
21
- schema: { type: Object, required: true },
22
- /** UI schema describing the layout and controls. */
23
- uiSchema: { type: Object, required: true },
24
- /** Modal width (`'xs'`, `'sm'`, `'md'`, `'lg'`, `'xl'`). */
25
- modalSize: { type: String, default: "md" },
26
- /** Callback invoked when the modal closes (with result or `null` on cancel). */
27
- onClose: {
28
- type: Function,
29
- required: true
30
- },
31
- /** Callback for form events dispatched by custom renderers. */
32
- onEvents: {
33
- type: Function
34
- },
35
- /** Initial form data to populate the form with. */
36
- data: { type: Object, required: true },
37
- /** When validation errors are shown. */
38
- errorMode: {
39
- type: String,
40
- default: "onBlur"
41
- }
42
- };
43
- const FormModalEmits = [
44
- /** Emitted when the modal is closed (submit or cancel). */
45
- "closeModal",
46
- /** Emitted when a custom renderer dispatches a form event. */
47
- "events",
48
- /** Emitted when validation errors change. */
49
- "errors",
50
- /** Emitted when form validity changes. */
51
- "valid"
52
- ];
53
- const _hoisted_1$8 = { class: "" };
54
- const _hoisted_2$2 = { class: "flex gap-2 items-center mb-2" };
55
- const _hoisted_3$1 = { class: "flex gap-2" };
56
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
57
- __name: "table-filter",
58
- props: {
59
- layout: {},
60
- filters: {}
61
- },
62
- emits: ["changeFilters", "removeFilter"],
63
- setup(__props, { emit: __emit }) {
64
- const formData = ref();
65
- const properties = __props;
66
- const emits = __emit;
67
- watch(
68
- () => properties.filters,
69
- () => {
70
- formData.value = {};
71
- properties.filters.forEach((filter) => {
72
- formData.value[filter.key] = filter.value;
73
- });
74
- },
75
- { immediate: true }
76
- );
77
- const onResetFilters = () => {
78
- emits("changeFilters", {});
79
- };
80
- const removeFilter = (filter) => {
81
- formData.value[filter.key] = void 0;
82
- emits("changeFilters", formData.value);
83
- };
84
- return (_ctx, _cache) => {
85
- return openBlock(), createElementBlock("div", _hoisted_1$8, [
86
- createElementVNode("div", _hoisted_2$2, [
87
- __props.filters.length ? (openBlock(), createBlock(unref(Btn), {
88
- key: 0,
89
- size: "xs",
90
- outline: true,
91
- onClick: onResetFilters
92
- }, {
93
- default: withCtx(() => [..._cache[0] || (_cache[0] = [
94
- createTextVNode(" Reset all filters ", -1)
95
- ])]),
96
- _: 1
97
- })) : createCommentVNode("", true)
98
- ]),
99
- createElementVNode("div", _hoisted_3$1, [
100
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.filters, (filter) => {
101
- return openBlock(), createBlock(unref(BtnBadge), {
102
- key: filter.key,
103
- icon: unref(IconEnum).Close,
104
- onClick: ($event) => removeFilter(filter)
105
- }, {
106
- default: withCtx(() => [
107
- createTextVNode(toDisplayString(filter.label) + ": " + toDisplayString(filter.value), 1)
108
- ]),
109
- _: 2
110
- }, 1032, ["icon", "onClick"]);
111
- }), 128))
112
- ])
113
- ]);
114
- };
115
- }
116
- });
117
- const TableComponentProperties = {
118
- id: { type: String, required: true },
119
- uiSchema: { type: Object, required: true },
120
- schema: { type: Object, required: true },
121
- filterUiSchema: { type: Object },
122
- filterSchema: { type: Object },
123
- uri: { type: String, required: true },
124
- reload: { type: Number },
125
- actions: { type: Array }
126
- };
127
- const TableComponentEmits = ["delete", "edit"];
128
- class TableStore {
129
- constructor() {
130
- this.route = useRoute();
131
- this.router = useRouter();
132
- this.requestData = ref(RequestSchema.parse(this.route.query));
133
- this._reload = ref(Date.now());
134
- this.loading = ref(true);
135
- this.uri = ref("");
136
- this.data = computedAsync(async () => {
137
- this._reload.value;
138
- if (!this.uri.value) return null;
139
- this.loading.value = true;
140
- if (this.requestData.value.page < 1) {
141
- this.requestData.value.page = 1;
142
- }
143
- const response = await useApi().get(this.uri.value, {
144
- params: this.requestData.value
145
- }).catch((error) => {
146
- console.error(error);
147
- return { data: [], request: { totalPages: 1, page: 1 } };
148
- }).finally(() => this.loading.value = false);
149
- const data = response.data;
150
- if (data.request.totalPages < data.request.page) {
151
- this.updateRequest({ page: data.request.totalPages });
152
- }
153
- return data;
154
- });
155
- this.pageData = computed(() => {
156
- const request = this.data.value?.request ?? {
157
- count: 0,
158
- pageSize: 1,
159
- page: 1
160
- };
161
- return {
162
- count: request.count,
163
- pageSize: request.pageSize,
164
- page: request.page
165
- };
166
- });
167
- this.tableData = computed(() => {
168
- const d = this.data.value;
169
- if (!d) return [];
170
- if (this.loading.value) return [];
171
- return d.data ?? [];
172
- });
173
- this.init = (url) => {
174
- this.uri.value = url;
175
- };
176
- this.updateRequest = (data) => {
177
- this.requestData.value = { ...this.requestData.value, ...data };
178
- this.router.replace({
179
- query: {
180
- ...this.route.query,
181
- ...this.requestData.value
182
- }
183
- });
184
- };
185
- this.sort = (id) => {
186
- const sortDir = this.requestData.value.sort === id && this.requestData.value.sortDir === "asc" ? "desc" : "asc";
187
- this.updateRequest({ sort: id, sortDir });
188
- };
189
- this.updateFilters = (filters) => {
190
- const filter = [];
191
- Object.entries(filters).forEach(([key, value]) => {
192
- if (!value) return;
193
- const operator = value?.operator || "contains";
194
- filter.push(`${key}:${value}:${operator}`);
195
- });
196
- this.updateRequest({ filter });
197
- };
198
- this.sorting = computed(() => {
199
- const requestData = this.requestData.value;
200
- return {
201
- sortColumn: requestData.sort,
202
- sortDirection: requestData.sortDir ?? "asc"
203
- };
204
- });
205
- this.filters = computed(
206
- () => extractFilters(this.requestData.value.filter)
207
- );
208
- }
209
- get httpRequest() {
210
- return useApi();
211
- }
212
- reload() {
213
- this._reload.value = Date.now();
214
- }
215
- updatePage(page) {
216
- this.updateRequest({ page });
217
- }
218
- }
219
- const tableCache = /* @__PURE__ */ new Map();
220
- const useTableStore = (name) => {
221
- const tableStore = tableCache.get(name);
222
- if (tableStore) {
223
- return tableStore;
224
- }
225
- const newTableStore = new TableStore();
226
- tableCache.set(name, newTableStore);
227
- return newTableStore;
228
- };
229
- const _hoisted_1$7 = {
230
- key: 0,
231
- class: "mb-2"
232
- };
233
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
234
- __name: "table.component",
235
- props: TableComponentProperties,
236
- emits: TableComponentEmits,
237
- setup(__props, { emit: __emit }) {
238
- const properties = __props;
239
- const emit = __emit;
240
- watch(
241
- () => properties.reload,
242
- () => {
243
- store.reload();
244
- }
245
- );
246
- let store = useTableStore(properties.id);
247
- watch(
248
- () => properties.uri,
249
- () => {
250
- store.init(properties.uri);
251
- },
252
- { immediate: true }
253
- );
254
- const edit = (data) => {
255
- emit("edit", data);
256
- };
257
- const deleteFn = (data) => {
258
- emit("delete", data);
259
- };
260
- const components = {
261
- TextCell,
262
- BooleanCell
263
- };
264
- const displayColumns = computed(() => {
265
- return properties.uiSchema.elements.map((e) => {
266
- const element = e;
267
- const def = findColumnDef(element, properties.schema);
268
- const type = isArray(def.type) ? def.type[0] : def.type;
269
- let component;
270
- if (element.options?.format && element.options.format in components) {
271
- component = components[element.options.format];
272
- } else {
273
- component = components[element.type];
274
- }
275
- if (!component) console.warn("No component found for type", element.type);
276
- return {
277
- ...def,
278
- type,
279
- component
280
- };
281
- });
282
- });
283
- const onChangeFilters = (filters) => {
284
- store.updateFilters(filters);
285
- };
286
- const onUpdatePage = (page) => {
287
- store.updatePage(page);
288
- };
289
- const onSort = (id) => {
290
- store.sort(id);
291
- };
292
- const sort = computed(() => {
293
- return store.sorting.value ?? { orderBy: "", ascending: 1 };
294
- });
295
- return (_ctx, _cache) => {
296
- return openBlock(), createElementBlock("div", null, [
297
- _ctx.filterUiSchema && _ctx.filterSchema ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
298
- createVNode(_sfc_main$h, {
299
- layout: { uiSchema: _ctx.filterUiSchema, schema: _ctx.filterSchema },
300
- filters: unref(store).filters.value,
301
- onChangeFilters
302
- }, null, 8, ["layout", "filters"])
303
- ])) : createCommentVNode("", true),
304
- createElementVNode("div", null, [
305
- createVNode(unref(Table), {
306
- "display-columns": displayColumns.value,
307
- sort: sort.value,
308
- page: unref(store).pageData.value,
309
- loading: unref(store).loading.value,
310
- data: unref(store).tableData.value,
311
- actions: _ctx.actions,
312
- onUpdatePage,
313
- onDelete: deleteFn,
314
- onEdit: edit,
315
- onSort
316
- }, null, 8, ["display-columns", "sort", "page", "loading", "data", "actions"])
317
- ])
318
- ]);
319
- };
320
- }
321
- });
322
- const createRepository = (formSchemaModel, httpRequest, options = {}) => {
323
- const notificationEntity = options.notification?.entityType || "entity";
324
- const notificationStore = options.notification?.notification ?? null;
325
- const getDataUri = (...suffix) => {
326
- return [formSchemaModel.uri, ...suffix].join("/");
327
- };
328
- const handleSuccess = (message) => {
329
- notificationStore?.success(message);
330
- };
331
- const handleError = (error, message) => {
332
- console.error(error);
333
- notificationStore?.error(message);
334
- throw new Error(error);
335
- };
336
- const create = (object, options2) => {
337
- return httpRequest.post(getDataUri(), object, options2).then((response) => {
338
- handleSuccess(`Created ${notificationEntity}`);
339
- return response.data;
340
- }).catch((response) => {
341
- handleError(response, `Failed to create ${notificationEntity}`);
342
- });
343
- };
344
- const patch = (id, object, options2) => {
345
- return httpRequest.patch(getDataUri(id), object, options2).then((response) => {
346
- handleSuccess(`Saved ${notificationEntity}`);
347
- return response.data;
348
- }).catch((response) => {
349
- handleError(response, `Failed to save ${notificationEntity}`);
350
- });
351
- };
352
- const get = (id, options2) => {
353
- return httpRequest.get(getDataUri(id), options2).then((response) => {
354
- return response.data;
355
- }).catch((response) => {
356
- handleError(response, "Failed to load data");
357
- });
358
- };
359
- const _delete = (id, options2) => {
360
- return httpRequest.delete(getDataUri(id), options2).then((response) => {
361
- handleSuccess(`${notificationEntity} deleted`);
362
- return response;
363
- }).catch((response) => {
364
- handleError(response, `Failed to delete ${notificationEntity}`);
365
- });
366
- };
367
- const createMulti = (objects, options2) => {
368
- return Promise.all(
369
- objects.map((object) => httpRequest.post(getDataUri(), object, options2))
370
- ).then((response) => {
371
- handleSuccess(`Created ${notificationEntity}`);
372
- return response.data;
373
- }).catch((response) => {
374
- handleError(response, `Failed to save ${notificationEntity}`);
375
- });
376
- };
377
- return { create, patch, createMulti, delete: _delete, get };
378
- };
379
- const createFormEvents = (dispatch) => ({
380
- dispatch
381
- });
382
- const FORM_EVENTS_KEY = /* @__PURE__ */ Symbol("json-forms:events");
383
- const provideFormEvents = (dispatch) => {
384
- const events = createFormEvents(dispatch);
385
- provide(FORM_EVENTS_KEY, events);
386
- return events;
387
- };
388
- const useFormEvents = () => {
389
- return inject(
390
- FORM_EVENTS_KEY,
391
- createFormEvents(() => {
392
- })
393
- );
394
- };
395
- const errorPatterns = [
396
- [/^Invalid input: expected \w+, received undefined$/, "This field is required"],
397
- [/^Invalid input: expected \w+, received null$/, "This field is required"],
398
- [/^Expected string, received/, "Invalid value"],
399
- [/^String must contain at least (\d+)/, "Must be at least $1 characters"],
400
- [/^Number must be greater than or equal to (\d+)/, "Minimum value is $1"],
401
- [/^Number must be less than or equal to (\d+)/, "Maximum value is $1"]
402
- ];
403
- const formatError = (message) => {
404
- if (!message) return void 0;
405
- for (const [pattern, replacement] of errorPatterns) {
406
- if (pattern.test(message)) {
407
- return message.replace(pattern, replacement);
408
- }
409
- }
410
- return message;
411
- };
412
- const registerZodErrorMap = () => {
413
- z.config({
414
- customError: (issue) => {
415
- if (issue.code === "invalid_type" && issue.received === "undefined") {
416
- return { message: "This field is required" };
417
- }
418
- if (issue.code === "invalid_type" && issue.received === "null") {
419
- return { message: "This field is required" };
420
- }
421
- if (issue.code === "too_small") {
422
- const i = issue;
423
- if (i.type === "string" && i.minimum === 1) {
424
- return { message: "This field is required" };
425
- }
426
- if (i.type === "string") {
427
- return { message: `Must be at least ${i.minimum} characters` };
428
- }
429
- }
430
- if (issue.code === "too_big") {
431
- const i = issue;
432
- if (i.type === "string") {
433
- return { message: `Must be at most ${i.maximum} characters` };
434
- }
435
- }
436
- return { message: issue.message };
437
- }
438
- });
439
- };
440
- function findRenderer(registry, uischema, schema) {
441
- let best = null;
442
- for (const entry of registry) {
443
- const rank = entry.tester(uischema, schema);
444
- if (rank > -1 && (!best || rank > best.rank)) {
445
- best = { rank, renderer: entry.renderer };
446
- }
447
- }
448
- return best?.renderer ?? null;
449
- }
450
- const scopeToPath = (scope) => {
451
- if (!scope) return "";
452
- return scope.replace(/^#\//, "").split("/").filter((s) => s !== "properties").join(".");
453
- };
454
- const resolveSchema = (root, scope) => {
455
- const segments = scope.replace(/^#\//, "").split("/").filter(Boolean);
456
- return segments.reduce((acc, key) => acc?.[key], root);
457
- };
458
- const _hoisted_1$6 = {
459
- key: 1,
460
- class: "text-error text-xs"
461
- };
462
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
463
- __name: "Dispatch",
464
- props: {
465
- uischema: {},
466
- schema: {},
467
- pathPrefix: { default: void 0 }
468
- },
469
- setup(__props) {
470
- const props = __props;
471
- const registry = inject("renderers");
472
- const rootSchema = inject("rootSchema");
473
- const parentPrefix = inject("pathPrefix", "");
474
- const effectivePrefix = props.pathPrefix ?? parentPrefix;
475
- if (props.pathPrefix !== void 0) {
476
- provide("pathPrefix", effectivePrefix);
477
- }
478
- const resolved = computed(() => {
479
- const u = props.uischema;
480
- if (!u.scope) return props.schema;
481
- const fromRoot = resolveSchema(rootSchema, u.scope);
482
- if (fromRoot) return fromRoot;
483
- return resolveSchema(props.schema, u.scope) ?? props.schema;
484
- });
485
- const renderer = computed(
486
- () => findRenderer(registry, props.uischema, resolved.value)
487
- );
488
- return (_ctx, _cache) => {
489
- return renderer.value ? (openBlock(), createBlock(resolveDynamicComponent(renderer.value), {
490
- key: 0,
491
- uischema: __props.uischema,
492
- schema: resolved.value
493
- }, null, 8, ["uischema", "schema"])) : (openBlock(), createElementBlock("div", _hoisted_1$6, " No renderer for " + toDisplayString(__props.uischema.scope ?? __props.uischema.type), 1));
494
- };
495
- }
496
- });
497
- const JsonFormComponentProperties = {
498
- /** Unique identifier used to namespace the form element. */
499
- id: { type: String, required: true },
500
- /** HTML name attribute for the form. */
501
- name: { type: String, default: "form" },
502
- /** JSON schema describing the shape of the form data. */
503
- schema: { type: Object, required: true },
504
- /** UI schema describing the layout and controls. */
505
- uiSchema: { type: Object, required: true },
506
- /** Disable all form controls. */
507
- disabled: { type: Boolean, default: false },
508
- /** Current form data object. */
509
- formData: { type: Object, default: () => ({}) },
510
- /** When validation errors are shown (`'onBlur'`, `'onChange'`, `'onSubmit'`, `'always'`). */
511
- errorMode: {
512
- type: String,
513
- default: "onChanges"
514
- }
515
- };
516
- const JsonFormComponentEmits = [
517
- /** Emitted when form data changes. */
518
- "change",
519
- /** Emitted on form submission. */
520
- "submit",
521
- /** Emitted when validation errors change. */
522
- "errors",
523
- /** Emitted when form validity changes. */
524
- "valid",
525
- /** Emitted when a custom renderer dispatches a form event. */
526
- "events"
527
- ];
528
- const ERROR_MODE_KEY = /* @__PURE__ */ Symbol("errorMode");
529
- const FORM_SUBMITTED_KEY = /* @__PURE__ */ Symbol("formSubmitted");
530
- const _hoisted_1$5 = { class: "flex-1" };
531
- const _hoisted_2$1 = { key: 0 };
532
- const _hoisted_3 = {
533
- key: 0,
534
- class: "text-sm text-base-content/50"
535
- };
536
- const _hoisted_4 = { key: 1 };
537
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
538
- __name: "ArrayRenderer",
539
- props: {
540
- uischema: {},
541
- schema: {}
542
- },
543
- setup(__props) {
544
- const props = __props;
545
- const parentPrefix = inject("pathPrefix", "");
546
- const scope = props.uischema.scope;
547
- const scopePath = scopeToPath(scope);
548
- const path = parentPrefix ? `${parentPrefix}.${scopePath}` : scopePath;
549
- const rootSchema = inject("rootSchema");
550
- const arraySchema = resolveSchema(rootSchema, scope);
551
- const itemSchema = arraySchema?.items ?? {};
552
- const { fields, push, remove } = useFieldArray(path);
553
- if (fields.value.length === 0) {
554
- push({});
555
- }
556
- const opts = props.uischema.options ?? {};
557
- const layout = opts.layout ?? "column";
558
- const showActions = computed(() => !opts.hideActions);
559
- const detail = computed(
560
- () => props.uischema._detail ?? opts.detail
561
- );
562
- const childElements = computed(() => {
563
- if (!detail.value) {
564
- return props.uischema.elements ?? [];
565
- }
566
- const type = detail.value.type;
567
- if (type && type !== "Control") {
568
- return [detail.value];
569
- }
570
- return detail.value.elements ?? [detail.value];
571
- });
572
- return (_ctx, _cache) => {
573
- return openBlock(), createElementBlock("div", null, [
574
- createElementVNode("div", {
575
- class: normalizeClass([
576
- "flex gap-2",
577
- unref(layout) === "row" ? "flex-row items-center" : "flex-col"
578
- ])
579
- }, [
580
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fields), (entry, index2) => {
581
- return openBlock(), createElementBlock("div", {
582
- key: entry.key,
583
- class: "flex-1"
584
- }, [
585
- createElementVNode("div", {
586
- class: normalizeClass([
587
- "flex gap-2",
588
- unref(layout) === "row" ? "flex-col" : "flex-row items-center"
589
- ])
590
- }, [
591
- createElementVNode("div", _hoisted_1$5, [
592
- (openBlock(true), createElementBlock(Fragment, null, renderList(childElements.value, (child, ci) => {
593
- return openBlock(), createBlock(_sfc_main$f, {
594
- key: ci,
595
- uischema: child,
596
- schema: unref(itemSchema),
597
- "path-prefix": `${unref(path)}[${index2}]`
598
- }, null, 8, ["uischema", "schema", "path-prefix"]);
599
- }), 128))
600
- ]),
601
- showActions.value ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
602
- unref(fields).length > 1 ? (openBlock(), createBlock(unref(Btn), {
603
- key: 0,
604
- icon: unref(IconEnum).Delete,
605
- outline: true,
606
- onClick: ($event) => unref(remove)(index2)
607
- }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
608
- ])) : createCommentVNode("", true)
609
- ], 2)
610
- ]);
611
- }), 128)),
612
- unref(fields).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_3, " No data ")) : createCommentVNode("", true),
613
- showActions.value ? (openBlock(), createElementBlock("div", _hoisted_4, [
614
- createVNode(unref(Btn), {
615
- icon: unref(IconEnum).Plus,
616
- outline: true,
617
- onClick: _cache[0] || (_cache[0] = ($event) => unref(push)({}))
618
- }, {
619
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
620
- createTextVNode(" Add ", -1)
621
- ])]),
622
- _: 1
623
- }, 8, ["icon"])
624
- ])) : createCommentVNode("", true)
625
- ], 2)
626
- ]);
627
- };
628
- }
629
- });
630
- const isAutoCompleteControl = and(
631
- // uiTypeIs('Control'),
632
- optionIs("format", ControlType.autocomplete)
633
- );
634
- const isTextAreaControl = and(
635
- uiTypeIs("Control"),
636
- optionIs("format", ControlType.textArea)
637
- );
638
- const isStringFormat = and(
639
- uiTypeIs("Control"),
640
- or(optionIs("format", ControlType.string), schemaTypeIs("string"))
641
- );
642
- const isMarkdownControl = and(
643
- uiTypeIs("Control"),
644
- optionIs("format", ControlType.markdown)
645
- );
646
- const isArrayRenderer = and(
647
- schemaTypeIs("array")
648
- // optionIs('format', ControlType.array),
649
- );
650
- const isMultiselectControl = and(
651
- uiTypeIs("Control"),
652
- optionIs("format", ControlType.mutliSelect)
653
- );
654
- const isSelectControl = and(
655
- uiTypeIs("Control"),
656
- optionIs("format", ControlType.select)
657
- );
658
- const isBooleanControl = or(
659
- isBooleanControl$1,
660
- and(uiTypeIs("Control"), optionIs("format", ControlType.boolean))
661
- );
662
- const isNumberFormat = and(
663
- uiTypeIs("Control"),
664
- or(optionIs("format", ControlType.number), schemaTypeIs("number"))
665
- );
666
- const isIntegerFormat = and(
667
- uiTypeIs("Control"),
668
- or(optionIs("format", ControlType.integer), schemaTypeIs("integer"))
669
- );
670
- const arrayRenderers = [
671
- { tester: rankWith(12, isArrayRenderer), renderer: _sfc_main$e }
672
- ];
673
- const MethodSchema = z.enum(["get", "post", "delete", "put", "patch"]);
674
- const OperationSchema = z.object({
675
- uri: z.string(),
676
- method: MethodSchema
677
- });
678
- const OperationsSchema = z.string().or(OperationSchema);
679
- const BooleanOperationSchema = z.boolean().or(OperationSchema).optional().default(false);
680
- const Operations = z.object({
681
- findAll: BooleanOperationSchema,
682
- findOne: BooleanOperationSchema,
683
- create: BooleanOperationSchema,
684
- update: BooleanOperationSchema,
685
- delete: BooleanOperationSchema,
686
- lookup: OperationsSchema.optional()
687
- });
688
- const OperationMap = {
689
- create: "post",
690
- delete: "delete",
691
- findAll: "get",
692
- findOne: "get",
693
- lookup: "get",
694
- update: "get"
695
- };
696
- const ResourceSchema = z.object({
697
- id: z.string(),
698
- uri: z.string(),
699
- operations: Operations,
700
- schema: z.object({
701
- ui: z.any().optional(),
702
- data: z.any()
703
- }).optional()
704
- }).transform((data) => {
705
- const schema = data.schema;
706
- if (schema) {
707
- if (!schema.ui) {
708
- schema.ui = uiFromJsonSchema(schema.data);
709
- }
710
- }
711
- const operations = {};
712
- for (const k in OperationMap) {
713
- const key = k;
714
- const defaultOperation = OperationMap[key];
715
- const operation = data.operations[key];
716
- const mapResourceSchema = () => {
717
- if (isUndefined(operation) || operation === false) return null;
718
- if (operation === true)
719
- return { uri: data.uri, method: defaultOperation };
720
- if (typeof operation === "string")
721
- return { uri: operation, method: "get" };
722
- return {
723
- uri: operation.uri,
724
- method: operation.method ?? defaultOperation
725
- };
726
- };
727
- operations[key] = mapResourceSchema();
728
- }
729
- return {
730
- ...data,
731
- schema,
732
- operations
733
- };
734
- });
735
- const getResourceSchema = async (resourceUri, skipAuth) => {
736
- const fetch = skipAuth ? axios : useApi();
737
- return fetch.get(resourceUri).then((response) => {
738
- const resource = ResourceSchema.safeParse(response.data);
739
- if (!resource.success)
740
- throw new Error(`Invalid resource schema: ${resource.error}`);
741
- return resource.data;
742
- });
743
- };
744
- const useRemoteOption = (options) => {
745
- return {
746
- fetchOptions: (searchTerm, signal) => {
747
- const fetch = options.skipAuth ? axios : useApi();
748
- return fetch.get(`${options.uri}${searchTerm}`, { signal }).then((data) => data.data[options.dataField ?? "data"]);
749
- }
750
- };
751
- };
752
- const useResourceOptions = async (options) => {
753
- const resource = await getResourceSchema(
754
- options.resource,
755
- options.skipAuth ?? false
756
- );
757
- const fetch = options.skipAuth ? axios : useApi();
758
- const lookup = resource.operations.lookup;
759
- return {
760
- fetchOptions: (searchTerm, signal) => {
761
- const uri = lookup.uri.replace("{text}", searchTerm);
762
- const method = lookup.method;
763
- return fetch[method](uri, { signal }).then(
764
- (data) => data.data[options.dataField ?? "data"]
765
- );
766
- },
767
- enableCreate: !!resource.operations.create,
768
- form: resource.operations.create ? {
769
- ui_schema: resource.schema.ui,
770
- json_schema: resource.schema.data,
771
- title: `Create new ${resource.id}`,
772
- create: async (data) => {
773
- const create = resource.operations.create;
774
- return fetch[create.method](create.uri, data).then(
775
- (result) => result.data
776
- );
777
- }
778
- } : null
779
- };
780
- };
781
- const useFetchOptions = async (options) => {
782
- let config = {};
783
- if (options.uri)
784
- config = useRemoteOption(options);
785
- if (options.resource)
786
- config = await useResourceOptions(options);
787
- return {
788
- fetchOptions: null,
789
- labelKey: options.labelKey,
790
- valueKey: options.valueKey,
791
- enableCreate: options.enableCreate ?? false,
792
- form: null,
793
- ...config
794
- };
795
- };
796
- const checkRequired = (rootSchema, scope, fieldName) => {
797
- const segments = scope.replace(/^#\//, "").split("/");
798
- const parentSegments = segments.slice(0, -2);
799
- if (parentSegments.length === 0) {
800
- const req2 = rootSchema?.required;
801
- return Array.isArray(req2) && req2.includes(fieldName);
802
- }
803
- const parentScope = `#/${parentSegments.join("/")}`;
804
- const parentSchema = resolveSchema(rootSchema, parentScope);
805
- const req = parentSchema?.required;
806
- return Array.isArray(req) && req.includes(fieldName);
807
- };
808
- const useInputProps = (uischema, schema, field, options = {}) => {
809
- const rootSchema = inject("rootSchema");
810
- const path = scopeToPath(uischema.scope);
811
- const { errorMessage, meta } = field;
812
- const opts = uischema.options ?? {};
813
- const labelFromScope = path.split(".").pop() ?? "";
814
- const isRequired = rootSchema ? checkRequired(rootSchema, uischema.scope, labelFromScope) : false;
815
- const s = schema ?? {};
816
- const inferredType = (() => {
817
- if (opts.format === "text") return "text";
818
- if (s.format === "email") return "email";
819
- if (s.format === "uri") return "url";
820
- if (s.type === "number" || s.type === "integer") return "number";
821
- return options.defaultType ?? "text";
822
- })();
823
- const styles = mergeStyles(opts.styles);
824
- const errorMode = inject(ERROR_MODE_KEY, ref("onBlur"));
825
- const submitted = inject(FORM_SUBMITTED_KEY, ref(false));
826
- const shouldShowError = computed(() => {
827
- if (!errorMessage.value) return false;
828
- switch (errorMode.value) {
829
- case "always":
830
- return true;
831
- case "onChange":
832
- return meta.dirty;
833
- case "onSubmit":
834
- return submitted.value;
835
- case "onBlur":
836
- default:
837
- return meta.touched;
838
- }
839
- });
840
- const width = opts.colspan || styles?.width === "full" ? "w-full" : opts.width ?? "min-w-input";
841
- return computed(() => ({
842
- id: path,
843
- placeholder: opts.placeholder,
844
- description: s.description,
845
- errors: shouldShowError.value ? opts.errorMessage ?? formatError(errorMessage.value) : void 0,
846
- label: opts.label ?? labelFromScope.charAt(0).toUpperCase() + labelFromScope.slice(1),
847
- visible: opts.visible ?? true,
848
- required: isRequired,
849
- enabled: opts.readonly !== true,
850
- isFocused: false,
851
- isTouched: shouldShowError.value,
852
- hideLabel: opts.hideLabel ?? false,
853
- styles,
854
- width,
855
- type: inferredType,
856
- ...options.overrides
857
- }));
858
- };
859
- const useCustomControlBinding = ({
860
- useProps,
861
- setDefaultValue
862
- } = {}) => {
863
- return (uischema, schema, options = {}) => {
864
- const pathPrefix = inject("pathPrefix", "");
865
- const scopePath = scopeToPath(uischema.scope);
866
- const path = pathPrefix ? `${pathPrefix}.${scopePath}` : scopePath;
867
- const field = useField(() => path);
868
- setDefaultValue?.(field);
869
- const wrapper = useInputProps(uischema, schema, field, options);
870
- const customWrapper = useProps?.(uischema, schema, field, options) ?? {
871
- value: {}
872
- };
873
- const onBlur = () => field.handleBlur(new Event("blur"));
874
- const onChange = () => field.handleChange(field.value.value);
875
- let initialized = false;
876
- watch(field.value, (val) => {
877
- if (!initialized) {
878
- initialized = true;
879
- return;
880
- }
881
- field.handleChange(val);
882
- });
883
- return {
884
- wrapper: computed(() => ({ ...wrapper.value, ...customWrapper.value })),
885
- value: field.value,
886
- field,
887
- onBlur,
888
- onChange,
889
- appliedOptions: computed(
890
- () => uischema.options ?? {}
891
- )
892
- };
893
- };
894
- };
895
- const useControlBinding = (uischema, schema, options = {}) => {
896
- return useCustomControlBinding()(uischema, schema, options);
897
- };
898
- const useSelectInput = (...fields) => (uischema, schema, field) => {
899
- const opts = uischema.options ?? {};
900
- return computed(() => {
901
- return pick(opts, fields);
902
- });
903
- };
904
- const useSelectBinding = useCustomControlBinding({
905
- useProps: useSelectInput("options", "labelKey", "valueKey")
906
- });
907
- const useAutocompleteBinding = useCustomControlBinding({
908
- useProps: useSelectInput(
909
- "options",
910
- "labelKey",
911
- "valueKey",
912
- "uri",
913
- "freeText",
914
- "enableCreate",
915
- "dataField",
916
- "skipAuth"
917
- )
918
- });
919
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
920
- __name: "FormModal",
921
- props: /* @__PURE__ */ mergeModels(FormModalProperties, {
922
- "modelValue": {},
923
- "modelModifiers": {}
924
- }),
925
- emits: /* @__PURE__ */ mergeModels(FormModalEmits, ["update:modelValue"]),
926
- setup(__props, { emit: __emit }) {
927
- const properties = __props;
928
- const id = `modal_${Math.floor(Math.random() * 1e3)}`;
929
- const formRef = ref();
930
- const valid = ref(false);
931
- const formData = useModel(__props, "modelValue");
932
- const emits = __emit;
933
- if (properties.data) {
934
- formData.value = properties.data;
935
- }
936
- const onCancel = () => {
937
- formData.value = {};
938
- emits("closeModal", null);
939
- };
940
- const onChange = (data) => {
941
- formData.value = data;
942
- };
943
- const onSubmit = () => {
944
- formRef.value?.markSubmitted();
945
- if (!valid.value) return;
946
- emits("closeModal", { data: formData.value, valid: valid.value });
947
- };
948
- const onErrors = (errors) => {
949
- emits("errors", errors);
950
- valid.value = isEmpty(errors);
951
- };
952
- watch(valid, (newValid, oldValid) => {
953
- if (newValid !== oldValid) {
954
- emits("valid", newValid);
955
- }
956
- });
957
- return (_ctx, _cache) => {
958
- return openBlock(), createBlock(unref(Modal), mergeProps(properties, {
959
- open: true,
960
- "disable-close": false,
961
- width: _ctx.modalSize,
962
- onCloseModal: onCancel
963
- }), {
964
- content: withCtx(() => [
965
- renderSlot(_ctx.$slots, "content-before"),
966
- createVNode(_sfc_main$2, {
967
- id: `modal-${id}`,
968
- ref_key: "formRef",
969
- ref: formRef,
970
- "form-data": formData.value,
971
- schema: _ctx.schema,
972
- "ui-schema": _ctx.uiSchema,
973
- "error-mode": _ctx.errorMode,
974
- onErrors,
975
- onChange,
976
- onEvents: _cache[0] || (_cache[0] = ($event) => emits("events", $event))
977
- }, null, 8, ["id", "form-data", "schema", "ui-schema", "error-mode"]),
978
- renderSlot(_ctx.$slots, "content-after")
979
- ]),
980
- actions: withCtx(() => [
981
- createVNode(unref(Btn), {
982
- color: unref(Color).secondary,
983
- outline: true,
984
- "aria-label": "Cancel",
985
- onClick: onCancel
986
- }, {
987
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
988
- createTextVNode(" Cancel ", -1)
989
- ])]),
990
- _: 1
991
- }, 8, ["color"]),
992
- createVNode(unref(Btn), {
993
- disabled: !valid.value,
994
- "aria-label": "Save",
995
- onClick: onSubmit
996
- }, {
997
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
998
- createTextVNode(" Save ", -1)
999
- ])]),
1000
- _: 1
1001
- }, 8, ["disabled"])
1002
- ]),
1003
- _: 3
1004
- }, 16, ["width"]);
1005
- };
1006
- }
1007
- });
1008
- class JsonFormModalService {
1009
- static openModal({
1010
- initialData,
1011
- modalTitle,
1012
- schema,
1013
- uiSchema,
1014
- modalSize,
1015
- onClose,
1016
- onEvents
1017
- }) {
1018
- ModalService.openModal({
1019
- component: _sfc_main$d,
1020
- props: {
1021
- schema,
1022
- uiSchema,
1023
- modalSize,
1024
- data: initialData ?? {},
1025
- modalTitle,
1026
- onClose,
1027
- onEvents
1028
- }
1029
- });
1030
- }
1031
- }
1032
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
1033
- __name: "AutocompleteControlRenderer",
1034
- props: {
1035
- uischema: {},
1036
- schema: {}
1037
- },
1038
- setup(__props) {
1039
- const props = __props;
1040
- const {
1041
- wrapper,
1042
- value,
1043
- field,
1044
- onBlur,
1045
- onChange: onFieldChange,
1046
- appliedOptions
1047
- } = useAutocompleteBinding(props.uischema, props.schema);
1048
- const fetchOptions = computedAsync(async () => {
1049
- const config = await useFetchOptions(
1050
- appliedOptions.value
1051
- );
1052
- return config;
1053
- });
1054
- const onChange = (val) => {
1055
- setValue(val);
1056
- onFieldChange();
1057
- };
1058
- const formEvents = useFormEvents();
1059
- const path = scopeToPath(props.uischema.scope);
1060
- const setValue = (result) => {
1061
- if (!result || !fetchOptions.value) {
1062
- field.setValue(result);
1063
- return;
1064
- }
1065
- const { valueKey, labelKey } = fetchOptions.value;
1066
- const keys = [valueKey, labelKey].filter(Boolean);
1067
- if (keys.length === 0) {
1068
- field.setValue(result);
1069
- return;
1070
- }
1071
- const stripped = pick(result, keys);
1072
- field.setValue(stripped);
1073
- };
1074
- const onCreate = () => {
1075
- if (fetchOptions.value?.enableCreate === false) return;
1076
- const form = fetchOptions.value.form;
1077
- if (form) {
1078
- JsonFormModalService.openModal({
1079
- schema: form.json_schema,
1080
- uiSchema: form.ui_schema,
1081
- modalTitle: `Create new ${wrapper.value.label}`,
1082
- onClose: (result) => {
1083
- if (!result || !result.valid) return;
1084
- form.create(result.data).then((res) => {
1085
- setValue(res);
1086
- });
1087
- }
1088
- });
1089
- return;
1090
- }
1091
- formEvents.dispatch({
1092
- event: "create",
1093
- type: path,
1094
- data: value.value,
1095
- onSuccess: setValue
1096
- });
1097
- };
1098
- return (_ctx, _cache) => {
1099
- return unref(fetchOptions) ? (openBlock(), createBlock(unref(Autocomplete), mergeProps({ key: 0 }, unref(wrapper), {
1100
- "model-value": unref(value),
1101
- "fetch-options": unref(fetchOptions).fetchOptions,
1102
- "label-key": unref(fetchOptions).labelKey,
1103
- "value-key": unref(fetchOptions).valueKey,
1104
- "enable-create": unref(fetchOptions).enableCreate,
1105
- onChange,
1106
- onBlur: unref(onBlur),
1107
- onCreate
1108
- }), null, 16, ["model-value", "fetch-options", "label-key", "value-key", "enable-create", "onBlur"])) : createCommentVNode("", true);
1109
- };
1110
- }
1111
- });
1112
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
1113
- __name: "BooleanControlRenderer",
1114
- props: {
1115
- uischema: {},
1116
- schema: {}
1117
- },
1118
- setup(__props) {
1119
- const props = __props;
1120
- const useBooleanBinding = useCustomControlBinding({
1121
- setDefaultValue: (field2) => {
1122
- if (field2.value.value === void 0) field2.setValue(false);
1123
- }
1124
- });
1125
- const { wrapper, value, field, onBlur, onChange: onFieldChange } = useBooleanBinding(props.uischema, props.schema);
1126
- const onChange = (val) => {
1127
- field.setValue(Boolean(val) ?? false);
1128
- onFieldChange();
1129
- };
1130
- return (_ctx, _cache) => {
1131
- return openBlock(), createBlock(unref(Checkbox), mergeProps(unref(wrapper), {
1132
- "model-value": unref(value),
1133
- onChange,
1134
- onBlur: unref(onBlur)
1135
- }), null, 16, ["model-value", "onBlur"]);
1136
- };
1137
- }
1138
- });
1139
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
1140
- __name: "MarkdownControlRenderer",
1141
- props: {
1142
- uischema: {},
1143
- schema: {}
1144
- },
1145
- setup(__props) {
1146
- const props = __props;
1147
- const {
1148
- wrapper,
1149
- value,
1150
- field,
1151
- onBlur,
1152
- onChange: onFieldChange
1153
- } = useControlBinding(props.uischema, props.schema);
1154
- const onChange = (val) => {
1155
- field.setValue(val);
1156
- onFieldChange();
1157
- };
1158
- return (_ctx, _cache) => {
1159
- return openBlock(), createBlock(unref(Markdown), mergeProps(unref(wrapper), {
1160
- "model-value": unref(value),
1161
- onChange,
1162
- onBlur: unref(onBlur)
1163
- }), null, 16, ["model-value", "onBlur"]);
1164
- };
1165
- }
1166
- });
1167
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
1168
- __name: "MultiSelectControlRenderer",
1169
- props: {
1170
- uischema: {},
1171
- schema: {}
1172
- },
1173
- setup(__props) {
1174
- const props = __props;
1175
- const {
1176
- wrapper,
1177
- value,
1178
- field,
1179
- onBlur,
1180
- onChange: onFieldChange
1181
- } = useSelectBinding(props.uischema, props.schema);
1182
- const onChange = (val) => {
1183
- field.setValue(val);
1184
- onFieldChange();
1185
- };
1186
- return (_ctx, _cache) => {
1187
- return openBlock(), createBlock(unref(MultiSelect), mergeProps(unref(wrapper), {
1188
- "model-value": unref(value),
1189
- onChange,
1190
- onBlur: unref(onBlur)
1191
- }), null, 16, ["model-value", "onBlur"]);
1192
- };
1193
- }
1194
- });
1195
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
1196
- __name: "NumberControlRenderer",
1197
- props: {
1198
- uischema: {},
1199
- schema: {}
1200
- },
1201
- setup(__props) {
1202
- const props = __props;
1203
- const { wrapper, value, onBlur, onChange } = useControlBinding(
1204
- props.uischema,
1205
- props.schema,
1206
- { defaultType: "number" }
1207
- );
1208
- return (_ctx, _cache) => {
1209
- return openBlock(), createBlock(unref(InputNumber), mergeProps(unref(wrapper), {
1210
- modelValue: unref(value),
1211
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(value) ? value.value = $event : null),
1212
- steps: 0.01,
1213
- onBlur: unref(onBlur),
1214
- onChange: unref(onChange)
1215
- }), null, 16, ["modelValue", "onBlur", "onChange"]);
1216
- };
1217
- }
1218
- });
1219
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1220
- __name: "SelectControlRenderer",
1221
- props: {
1222
- uischema: {},
1223
- schema: {}
1224
- },
1225
- setup(__props) {
1226
- const props = __props;
1227
- const {
1228
- wrapper,
1229
- value,
1230
- field,
1231
- onBlur,
1232
- onChange: onFieldChange,
1233
- appliedOptions
1234
- } = useSelectBinding(props.uischema, props.schema);
1235
- const selectOptions = computed(() => {
1236
- return appliedOptions.options ?? [];
1237
- });
1238
- const onChange = (val) => {
1239
- field.setValue(val);
1240
- onFieldChange();
1241
- };
1242
- return (_ctx, _cache) => {
1243
- return openBlock(), createBlock(unref(SelectComponent), mergeProps(unref(wrapper), {
1244
- "model-value": unref(value),
1245
- options: selectOptions.value,
1246
- onChange,
1247
- onBlur: unref(onBlur)
1248
- }), null, 16, ["model-value", "options", "onBlur"]);
1249
- };
1250
- }
1251
- });
1252
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1253
- __name: "StringControlRenderer",
1254
- props: {
1255
- uischema: {},
1256
- schema: {}
1257
- },
1258
- setup(__props) {
1259
- const props = __props;
1260
- const { wrapper, value, onBlur, onChange } = useControlBinding(
1261
- props.uischema,
1262
- props.schema
1263
- );
1264
- return (_ctx, _cache) => {
1265
- return openBlock(), createBlock(unref(Input), mergeProps(unref(wrapper), {
1266
- modelValue: unref(value),
1267
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(value) ? value.value = $event : null),
1268
- onBlur: unref(onBlur),
1269
- onChange: unref(onChange)
1270
- }), null, 16, ["modelValue", "onBlur", "onChange"]);
1271
- };
1272
- }
1273
- });
1274
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1275
- __name: "TextAreaControlRenderer",
1276
- props: {
1277
- uischema: {},
1278
- schema: {}
1279
- },
1280
- setup(__props) {
1281
- const props = __props;
1282
- const { wrapper, value, onBlur, onChange } = useControlBinding(
1283
- props.uischema,
1284
- props.schema
1285
- );
1286
- return (_ctx, _cache) => {
1287
- return openBlock(), createBlock(unref(Textarea), mergeProps(unref(wrapper), {
1288
- modelValue: unref(value),
1289
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(value) ? value.value = $event : null),
1290
- onBlur: unref(onBlur),
1291
- onChange: unref(onChange)
1292
- }), null, 16, ["modelValue", "onBlur", "onChange"]);
1293
- };
1294
- }
1295
- });
1296
- const index = [
1297
- { tester: rankWith(10, isStringFormat), renderer: _sfc_main$6 },
1298
- {
1299
- tester: rankWith(11, isTextAreaControl),
1300
- renderer: _sfc_main$5
1301
- },
1302
- {
1303
- tester: rankWith(11, isMarkdownControl),
1304
- renderer: _sfc_main$a
1305
- },
1306
- { tester: rankWith(11, isBooleanControl), renderer: _sfc_main$b },
1307
- { tester: rankWith(11, isSelectControl), renderer: _sfc_main$7 },
1308
- {
1309
- tester: rankWith(11, isMultiselectControl),
1310
- renderer: _sfc_main$9
1311
- },
1312
- {
1313
- tester: rankWith(12, isAutoCompleteControl),
1314
- renderer: _sfc_main$c
1315
- },
1316
- {
1317
- tester: rankWith(12, isNumberFormat),
1318
- renderer: _sfc_main$8
1319
- },
1320
- {
1321
- tester: rankWith(12, isIntegerFormat),
1322
- renderer: _sfc_main$8
1323
- }
1324
- ];
1325
- const COLSPAN = {
1326
- 1: "col-span-1",
1327
- 2: "col-span-2",
1328
- 3: "col-span-3",
1329
- 4: "col-span-4",
1330
- 5: "col-span-5",
1331
- 6: "col-span-6",
1332
- 7: "col-span-7",
1333
- 8: "col-span-8",
1334
- 9: "col-span-9",
1335
- 10: "col-span-10",
1336
- 11: "col-span-11",
1337
- 12: "col-span-12"
1338
- };
1339
- const _hoisted_1$4 = { class: "flex flex-col gap-4" };
1340
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1341
- __name: "CollapseLayoutRenderer",
1342
- props: {
1343
- uischema: {},
1344
- schema: {}
1345
- },
1346
- setup(__props) {
1347
- const props = __props;
1348
- const pathPrefix = inject("pathPrefix", "");
1349
- const opts = props.uischema.options ?? {};
1350
- const titleKeyField = opts.titleKey ? useFieldValue(
1351
- () => pathPrefix ? `${pathPrefix}.${opts.titleKey}` : opts.titleKey
1352
- ) : void 0;
1353
- const title = computed(() => {
1354
- if (titleKeyField?.value) return titleKeyField.value;
1355
- return props.uischema.label ?? opts.title ?? "Details";
1356
- });
1357
- return (_ctx, _cache) => {
1358
- return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
1359
- default: withCtx(() => [
1360
- createElementVNode("div", _hoisted_1$4, [
1361
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.uischema.elements, (child, i) => {
1362
- return openBlock(), createElementBlock("div", {
1363
- key: i,
1364
- class: normalizeClass(unref(COLSPAN)[child.options?.colspan ?? 12])
1365
- }, [
1366
- createVNode(_sfc_main$f, {
1367
- uischema: child,
1368
- schema: __props.schema
1369
- }, null, 8, ["uischema", "schema"])
1370
- ], 2);
1371
- }), 128))
1372
- ])
1373
- ]),
1374
- _: 1
1375
- }, 8, ["title"]);
1376
- };
1377
- }
1378
- });
1379
- const _hoisted_1$3 = {
1380
- key: 1,
1381
- class: "flex flex-col gap-3"
1382
- };
1383
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1384
- __name: "LayoutRenderer",
1385
- props: {
1386
- uischema: {},
1387
- schema: {}
1388
- },
1389
- setup(__props) {
1390
- const props = __props;
1391
- const LAYOUT = {
1392
- GridLayout: "grid grid-cols-12 gap-3",
1393
- HorizontalLayout: "flex flex-row gap-3",
1394
- VerticalLayout: "flex flex-col gap-3"
1395
- };
1396
- const getLayout = computed(() => LAYOUT[props.uischema.type]);
1397
- const isLayout = computed(() => props.uischema.type in LAYOUT);
1398
- return (_ctx, _cache) => {
1399
- return isLayout.value ? (openBlock(), createElementBlock("div", {
1400
- key: 0,
1401
- class: normalizeClass(getLayout.value)
1402
- }, [
1403
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.uischema.elements, (child, i) => {
1404
- return openBlock(), createElementBlock("div", {
1405
- key: i,
1406
- class: normalizeClass(unref(COLSPAN)[child.options?.colspan ?? 12])
1407
- }, [
1408
- createVNode(_sfc_main$f, {
1409
- uischema: child,
1410
- schema: __props.schema
1411
- }, null, 8, ["uischema", "schema"])
1412
- ], 2);
1413
- }), 128))
1414
- ], 2)) : (openBlock(), createElementBlock("div", _hoisted_1$3, " No Applicable Layout found "));
1415
- };
1416
- }
1417
- });
1418
- const isLayoutType = or$1(
1419
- uiTypeIs("GridLayout"),
1420
- uiTypeIs("HorizontalLayout"),
1421
- uiTypeIs("VerticalLayout")
1422
- );
1423
- const layoutRenderes = [
1424
- { tester: rankWith(10, isLayoutType), renderer: _sfc_main$3 },
1425
- {
1426
- tester: rankWith(10, uiTypeIs("CollapseLayout")),
1427
- renderer: _sfc_main$4
1428
- }
1429
- ];
1430
- const customRenderes = [layoutRenderes, index, arrayRenderers].flat();
1431
- const _hoisted_1$2 = ["id"];
1432
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1433
- __name: "FormComponent",
1434
- props: JsonFormComponentProperties,
1435
- emits: JsonFormComponentEmits,
1436
- setup(__props, { expose: __expose, emit: __emit }) {
1437
- registerZodErrorMap();
1438
- const properties = __props;
1439
- const emits = __emit;
1440
- const zodSchema = computed(() => {
1441
- if (!properties.schema) return void 0;
1442
- try {
1443
- const patched = enforceRequiredStringMinLength(properties.schema);
1444
- return fromJSONSchema(patched);
1445
- } catch {
1446
- return void 0;
1447
- }
1448
- });
1449
- const { values, errors, meta, setValues, validate } = useForm({
1450
- validationSchema: zodSchema,
1451
- initialValues: properties.formData
1452
- });
1453
- provide("renderers", customRenderes);
1454
- provide("rootSchema", properties.schema);
1455
- provide("styles", myStyles);
1456
- const submitted = ref(false);
1457
- provide(ERROR_MODE_KEY, toRef(properties, "errorMode"));
1458
- provide(FORM_SUBMITTED_KEY, submitted);
1459
- onMounted(async () => {
1460
- const result = await validate();
1461
- emits("valid", result.valid);
1462
- });
1463
- provideFormEvents((payload) => {
1464
- emits("events", payload);
1465
- });
1466
- let syncing = false;
1467
- watch(
1468
- () => properties.formData,
1469
- (newData) => {
1470
- if (!newData) return;
1471
- if (JSON.stringify(newData) === JSON.stringify(toRaw(values))) return;
1472
- syncing = true;
1473
- setValues(newData);
1474
- nextTick(() => {
1475
- syncing = false;
1476
- });
1477
- },
1478
- { deep: true }
1479
- );
1480
- watch(
1481
- values,
1482
- (newValues) => {
1483
- if (syncing) return;
1484
- const isValid = meta.value.valid;
1485
- emits("valid", isValid);
1486
- emits("change", toRaw(newValues));
1487
- },
1488
- { deep: true }
1489
- );
1490
- watch(
1491
- errors,
1492
- (newErrors) => {
1493
- const errorList = Object.entries(newErrors).filter(([, msg]) => !!msg).map(([path, message]) => ({ path, message }));
1494
- emits("errors", errorList);
1495
- },
1496
- { deep: true }
1497
- );
1498
- const onSubmit = () => {
1499
- submitted.value = true;
1500
- emits("submit", {
1501
- data: toRaw(values),
1502
- valid: meta.value.valid
1503
- });
1504
- };
1505
- const markSubmitted = () => {
1506
- submitted.value = true;
1507
- };
1508
- __expose({ markSubmitted });
1509
- return (_ctx, _cache) => {
1510
- return openBlock(), createElementBlock("form", {
1511
- id: _ctx.id,
1512
- onSubmit: withModifiers(onSubmit, ["prevent"])
1513
- }, [
1514
- createVNode(_sfc_main$f, {
1515
- uischema: _ctx.uiSchema,
1516
- schema: _ctx.schema
1517
- }, null, 8, ["uischema", "schema"])
1518
- ], 40, _hoisted_1$2);
1519
- };
1520
- }
1521
- });
1522
- const FormWithActionsProperties = {
1523
- /** Unique identifier used to namespace the inner form element. */
1524
- id: { type: String, required: true },
1525
- /** Title shown when creating a new record. */
1526
- createTitle: { type: String, required: true },
1527
- /** Title shown when editing an existing record. Falls back to `createTitle` when omitted. */
1528
- updateTitle: { type: String },
1529
- /** JSON schema describing the shape of the form data. */
1530
- schema: { type: Object },
1531
- /** UI schema describing the layout and controls. */
1532
- uiSchema: { type: Object },
1533
- /** REST endpoint used by `FormStore` to persist data. When omitted the form emits `submit` instead. */
1534
- uri: { type: String },
1535
- /** Enable vertical scrolling inside the form area. */
1536
- scrollable: { type: Boolean, default: false },
1537
- /** Stretch the collapse wrapper to full height. */
1538
- fullHeight: { type: Boolean, default: false },
1539
- /** Two-way bound form data object. */
1540
- modelValue: { type: Object, default: () => ({}) },
1541
- /** When validation errors are shown (`'onBlur'`, `'onChange'`, `'onSubmit'`, `'always'`). */
1542
- errorMode: {
1543
- type: String,
1544
- default: "onBlur"
1545
- }
1546
- };
1547
- const FormWithActionsEmits = [
1548
- /** Emitted when `modelValue` changes. */
1549
- "update:modelValue",
1550
- /** Emitted after a successful `FormStore.save()`. */
1551
- "success",
1552
- /** Emitted on submit when no `uri` is provided. */
1553
- "submit",
1554
- /** Emitted whenever form validity changes. */
1555
- "valid",
1556
- /** Emitted when a custom renderer dispatches a form event. */
1557
- "events",
1558
- /** Emitted when validation errors change. */
1559
- "errors",
1560
- /** Emitted when the user cancels editing an existing record. */
1561
- "cancel"
1562
- ];
1563
- class FormStore {
1564
- constructor(uri) {
1565
- this.uri = uri;
1566
- }
1567
- async delete(data) {
1568
- return useApi().delete(`${this.uri}/${data.id}`).then(() => {
1569
- NotificationService.success("Data deleted");
1570
- }).catch((error) => {
1571
- console.error(error);
1572
- NotificationService.error("Error deleting data");
1573
- });
1574
- }
1575
- async save(id, data) {
1576
- if (!this.uri) return;
1577
- const promise = id ? useApi().patch(`${this.uri}/${id}`, data) : useApi().post(this.uri, data);
1578
- return promise.then((response) => {
1579
- NotificationService.success("Data saved");
1580
- return response.data;
1581
- }).catch((error) => {
1582
- console.error(error);
1583
- NotificationService.error("Error saving data");
1584
- });
1585
- }
1586
- }
1587
- const _hoisted_1$1 = { class: "flex justify-end gap-2 p-2 mt-2 border-t border-gray-300 z-[30] shrink-0" };
1588
- const _hoisted_2 = { class: "flex justify-end gap-2" };
1589
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1590
- __name: "FormWithActions",
1591
- props: FormWithActionsProperties,
1592
- emits: FormWithActionsEmits,
1593
- setup(__props, { emit: __emit }) {
1594
- const properties = __props;
1595
- const emits = __emit;
1596
- const formRef = ref();
1597
- const formData = ref(properties.modelValue);
1598
- const initialFormData = ref(structuredClone(toRaw(properties.modelValue)));
1599
- const recordId = ref(properties.modelValue?.id ?? null);
1600
- const valid = ref(false);
1601
- watch(
1602
- () => properties.modelValue,
1603
- (newValue) => {
1604
- if (JSON.stringify(toRaw(newValue)) === JSON.stringify(toRaw(formData.value))) return;
1605
- recordId.value = newValue?.id ?? null;
1606
- initialFormData.value = structuredClone(toRaw(newValue));
1607
- formData.value = newValue;
1608
- }
1609
- );
1610
- const store = computed(
1611
- () => properties.uri ? new FormStore(properties.uri) : null
1612
- );
1613
- const updateValue = (data) => {
1614
- formData.value = data;
1615
- emits("update:modelValue", data);
1616
- };
1617
- const save = () => {
1618
- formRef.value?.markSubmitted();
1619
- if (!valid.value) return;
1620
- if (store.value) {
1621
- store.value.save(recordId.value, formData.value).then((response) => {
1622
- emits("success", response);
1623
- });
1624
- } else {
1625
- emits("submit", formData.value);
1626
- }
1627
- };
1628
- const clear = () => {
1629
- formData.value = { id: null };
1630
- emits("update:modelValue", formData.value);
1631
- };
1632
- const cancel = () => {
1633
- formData.value = structuredClone(toRaw(initialFormData.value));
1634
- emits("update:modelValue", formData.value);
1635
- emits("cancel");
1636
- };
1637
- const title = computed(() => {
1638
- if (!properties.updateTitle) return properties.createTitle;
1639
- return recordId.value ? properties.updateTitle : properties.createTitle;
1640
- });
1641
- const onErrors = (errors) => {
1642
- emits("errors", errors);
1643
- valid.value = isEmpty(errors);
1644
- };
1645
- watch(valid, (newValid, oldValid) => {
1646
- if (newValid !== oldValid) {
1647
- emits("valid", newValid);
1648
- }
1649
- });
1650
- return (_ctx, _cache) => {
1651
- return openBlock(), createBlock(unref(Collapse), {
1652
- title: title.value,
1653
- "height-full": _ctx.fullHeight,
1654
- scrollable: true
1655
- }, {
1656
- default: withCtx(() => [
1657
- createElementVNode("div", {
1658
- class: normalizeClass(["flex flex-col", { "overflow-hidden h-full": _ctx.scrollable }])
1659
- }, [
1660
- createElementVNode("div", {
1661
- class: normalizeClass(["flex-1", { "overflow-y-auto overflow-x-hidden": _ctx.scrollable }])
1662
- }, [
1663
- createVNode(_sfc_main$2, {
1664
- id: `form_${_ctx.id}`,
1665
- ref_key: "formRef",
1666
- ref: formRef,
1667
- "form-data": formData.value,
1668
- schema: _ctx.schema,
1669
- "ui-schema": _ctx.uiSchema,
1670
- "error-mode": _ctx.errorMode,
1671
- onChange: updateValue,
1672
- onSubmit: save,
1673
- onErrors,
1674
- onEvents: _cache[0] || (_cache[0] = ($event) => emits("events", $event))
1675
- }, null, 8, ["id", "form-data", "schema", "ui-schema", "error-mode"])
1676
- ], 2),
1677
- createElementVNode("div", _hoisted_1$1, [
1678
- createElementVNode("div", _hoisted_2, [
1679
- renderSlot(_ctx.$slots, "actions"),
1680
- recordId.value ? (openBlock(), createBlock(unref(Btn), {
1681
- key: 0,
1682
- "aria-label": "Cancel",
1683
- outline: true,
1684
- onClick: cancel
1685
- }, {
1686
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
1687
- createTextVNode(" Cancel ", -1)
1688
- ])]),
1689
- _: 1
1690
- })) : (openBlock(), createBlock(unref(Btn), {
1691
- key: 1,
1692
- "aria-label": "Clear",
1693
- outline: true,
1694
- onClick: clear
1695
- }, {
1696
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
1697
- createTextVNode(" Clear ", -1)
1698
- ])]),
1699
- _: 1
1700
- })),
1701
- createVNode(unref(Btn), {
1702
- "aria-label": "Save",
1703
- color: unref(Color).primary,
1704
- disabled: !valid.value,
1705
- onClick: save
1706
- }, {
1707
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
1708
- createTextVNode(" Save ", -1)
1709
- ])]),
1710
- _: 1
1711
- }, 8, ["color", "disabled"])
1712
- ])
1713
- ])
1714
- ], 2)
1715
- ]),
1716
- _: 3
1717
- }, 8, ["title", "height-full"]);
1718
- };
1719
- }
1720
- });
1721
- const FormWithTableProperties = {
1722
- /** Unique identifier used to namespace the inner table element. */
1723
- id: { type: String, required: true },
1724
- /** Heading displayed above the table. */
1725
- tableTitle: { type: String, required: true },
1726
- /** Title shown in the modal when creating a new record. */
1727
- createTitle: { type: String, required: true },
1728
- /** Title shown in the modal when editing a record. Falls back to `createTitle` when omitted. */
1729
- updateTitle: { type: String },
1730
- /** Override URI used to fetch table data. Defaults to `uri` when omitted. */
1731
- dataUri: { type: String },
1732
- /** Custom row actions rendered in the table. */
1733
- tableActions: { type: Array },
1734
- /** JSON Forms layout for the create/edit modal form. */
1735
- form: { type: Object },
1736
- /** JSON Forms layout for the table. */
1737
- table: { type: Object },
1738
- /** JSON Forms layout for the table filter. */
1739
- filter: { type: Object },
1740
- /** REST endpoint used by `FormStore` for CRUD operations. */
1741
- uri: { type: String },
1742
- /** Default data pre-filled when creating a new record. */
1743
- initialData: { type: Object, default: () => ({}) },
1744
- /** When validation errors are shown in the modal form. */
1745
- errorMode: {
1746
- type: String,
1747
- default: "onBlur"
1748
- }
1749
- };
1750
- const FormWithTableEmits = [
1751
- /** Emitted when a row is selected for editing (listener-based routing). */
1752
- "editData",
1753
- /** Emitted after a record is saved through the modal. */
1754
- "save",
1755
- /** Emitted after a record is deleted. */
1756
- "delete",
1757
- /** Emitted when a custom renderer dispatches a form event. */
1758
- "events",
1759
- /** Emitted when a custom edit handler is registered. */
1760
- "custom:edit",
1761
- /** Emitted when a custom create handler is registered. */
1762
- "custom:create"
1763
- ];
1764
- const _hoisted_1 = { class: "flex justify-between items-center mb-2" };
1765
- const _sfc_main = /* @__PURE__ */ defineComponent({
1766
- __name: "FormWithTable",
1767
- props: FormWithTableProperties,
1768
- emits: FormWithTableEmits,
1769
- setup(__props, { emit: __emit }) {
1770
- const properties = __props;
1771
- const emit = __emit;
1772
- const reload = ref(0);
1773
- const resolvedForm = computed(() => properties.form);
1774
- const resolvedTable = computed(() => properties.table);
1775
- const resolvedFilter = computed(() => properties.filter);
1776
- const resolvedUri = computed(() => properties.uri);
1777
- let store = new FormStore(resolvedUri.value ?? "");
1778
- watch(resolvedUri, (uri) => {
1779
- store = new FormStore(uri ?? "");
1780
- });
1781
- const hasEdit = hasCustomEventListener("editData");
1782
- const customEdit = hasCustomEventListener("custom:edit");
1783
- const customCreate = hasCustomEventListener("custom:create");
1784
- const edit = (data) => {
1785
- if (customEdit) {
1786
- emit("custom:edit", data);
1787
- return;
1788
- }
1789
- if (hasEdit) {
1790
- emit("editData", data);
1791
- return;
1792
- }
1793
- openModal(data);
1794
- };
1795
- const create = () => {
1796
- if (customCreate) {
1797
- emit("custom:create");
1798
- return;
1799
- }
1800
- openModal();
1801
- };
1802
- const deleteFn = (data) => {
1803
- ModalService.showConfirm({
1804
- title: "Delete record",
1805
- message: "Are you sure to delete, the data will be lost?",
1806
- onClose: (result) => {
1807
- if (result.confirmed) {
1808
- store.delete(data).then(() => {
1809
- reload.value = Date.now();
1810
- emit("delete", data);
1811
- });
1812
- }
1813
- }
1814
- });
1815
- };
1816
- const openModal = (formData) => {
1817
- if (!resolvedForm.value) return;
1818
- const isUpdate = !!formData?.id;
1819
- JsonFormModalService.openModal({
1820
- schema: resolvedForm.value.schema,
1821
- uiSchema: resolvedForm.value.uiSchema,
1822
- modalSize: resolvedForm.value.modalSize,
1823
- initialData: formData ?? properties.initialData,
1824
- modalTitle: (isUpdate ? properties.updateTitle ?? properties.createTitle : properties.createTitle) ?? "",
1825
- onClose: (result) => {
1826
- if (result && result.valid) {
1827
- store.save(formData?.id, result.data).then(() => {
1828
- reload.value = Date.now();
1829
- emit("save", { id: formData?.id, data: result.data });
1830
- });
1831
- }
1832
- },
1833
- onEvents: (payload) => emit("events", payload)
1834
- });
1835
- };
1836
- return (_ctx, _cache) => {
1837
- return openBlock(), createElementBlock(Fragment, null, [
1838
- createElementVNode("div", _hoisted_1, [
1839
- createElementVNode("h1", null, toDisplayString(_ctx.tableTitle), 1),
1840
- createElementVNode("div", null, [
1841
- createVNode(unref(Btn), {
1842
- icon: unref(IconEnum).Plus,
1843
- outline: true,
1844
- onClick: create
1845
- }, {
1846
- default: withCtx(() => [..._cache[0] || (_cache[0] = [
1847
- createTextVNode(" Add new record ", -1)
1848
- ])]),
1849
- _: 1
1850
- }, 8, ["icon"])
1851
- ])
1852
- ]),
1853
- resolvedTable.value ? (openBlock(), createBlock(unref(Card), { key: 0 }, {
1854
- default: withCtx(() => [
1855
- resolvedUri.value ? (openBlock(), createBlock(unref(_sfc_main$g), {
1856
- key: 0,
1857
- id: `form_table_${_ctx.id}`,
1858
- "ui-schema": resolvedTable.value.uiSchema,
1859
- schema: resolvedTable.value.schema,
1860
- "filter-ui-schema": resolvedFilter.value?.uiSchema,
1861
- "filter-schema": resolvedFilter.value?.schema,
1862
- uri: _ctx.dataUri ?? resolvedUri.value,
1863
- reload: reload.value,
1864
- actions: _ctx.tableActions,
1865
- onEdit: edit,
1866
- onDelete: deleteFn
1867
- }, null, 8, ["id", "ui-schema", "schema", "filter-ui-schema", "filter-schema", "uri", "reload", "actions"])) : createCommentVNode("", true)
1868
- ]),
1869
- _: 1
1870
- })) : createCommentVNode("", true)
1871
- ], 64);
1872
- };
1873
- }
1874
- });
1875
- export {
1876
- FormModalEmits,
1877
- FormModalProperties,
1878
- _sfc_main$2 as JsonForm,
1879
- _sfc_main$d as JsonFormModal,
1880
- JsonFormModalService,
1881
- _sfc_main$1 as JsonFormWithActions,
1882
- _sfc_main as JsonFormWithTable,
1883
- _sfc_main$g as TableComponent,
1884
- TableComponentEmits,
1885
- TableComponentProperties,
1886
- createRepository,
1887
- formatError,
1888
- provideFormEvents,
1889
- registerZodErrorMap,
1890
- useFormEvents,
1891
- customRenderes as veeRenderers
1892
- };