@ghentcdh/json-forms-vue 0.6.7 → 0.6.8

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/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { useApi } from "@ghentcdh/tools-vue";
2
- import { NotificationService, Checkbox, InputNumber, Markdown, Input, Textarea, Autocomplete, IconEnum, Btn, BtnBadge, TextCell, Table, hasCustomEventListener, Card, ModalService, myStyles, Color, Modal } from "@ghentcdh/ui";
3
- import { uiTypeIs, rankWith, isNumberControl, isIntegerControl, isBooleanControl, createDefaultValue, composePaths, getArrayTranslations, defaultJsonFormsI18nState, arrayDefaultTranslations } from "@jsonforms/core";
4
- import { ref, computed, defineComponent, openBlock, createBlock, unref, mergeProps, inject, resolveComponent, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, Fragment, renderList, createVNode, withCtx, createTextVNode, watch, useModel, provide, mergeModels, renderSlot } from "vue";
5
- import { useJsonFormsControl, rendererProps, DispatchRenderer, useJsonFormsArrayControl, JsonForms } from "@jsonforms/vue";
1
+ import { useApi, Debugger } from "@ghentcdh/tools-vue";
2
+ import { NotificationService, Checkbox, InputNumber, Markdown, Input, Textarea, Autocomplete, IconEnum, Btn, Collapse, BtnBadge, TextCell, Table, hasCustomEventListener, Card, ModalService, myStyles, Alert, Color, Modal } from "@ghentcdh/ui";
3
+ import { uiTypeIs, rankWith, isNumberControl, isIntegerControl, isBooleanControl, createDefaultValue, composePaths } from "@jsonforms/core";
4
+ import { ref, computed, defineComponent, openBlock, createBlock, unref, mergeProps, createElementBlock, createElementVNode, normalizeClass, Fragment, renderList, createVNode, createCommentVNode, withCtx, createTextVNode, watch, toDisplayString, useModel, provide, mergeModels, renderSlot } from "vue";
5
+ import { useJsonFormsControl, rendererProps, useJsonFormsArrayControl, DispatchRenderer, useJsonFormsLayout, JsonForms } from "@jsonforms/vue";
6
6
  import { useVanillaControl, useVanillaArrayControl, vanillaRenderers } from "@jsonforms/vue-vanilla";
7
+ import { omit, isArray } from "lodash-es";
7
8
  import { and, optionIs, or, schemaTypeIs } from "@jsonforms/core/src/testers/testers";
8
- import { ControlType, RequestSchema, extractFilters, findColumnDef } from "@ghentcdh/json-forms-core";
9
+ import { ControlType, LayoutTypes, RequestSchema, extractFilters, findColumnDef } from "@ghentcdh/json-forms-core";
9
10
  import { useRouter, useRoute } from "vue-router";
10
- import { isArray } from "lodash-es";
11
11
  import { computedAsync } from "@vueuse/core";
12
12
  class FormStore {
13
13
  constructor(schema) {
@@ -49,6 +49,7 @@ const useVanillaControlCustom = (input, adaptTarget = (v) => v.value) => {
49
49
  const controlWrapper = computed(() => {
50
50
  return {
51
51
  ...vanillaControl.controlWrapper.value,
52
+ ...omit(vanillaControl.appliedOptions.value, "styles"),
52
53
  isFocused: isFocused.value,
53
54
  isTouched: isTouched.value
54
55
  };
@@ -63,7 +64,7 @@ const useVanillaControlCustom = (input, adaptTarget = (v) => v.value) => {
63
64
  // handleChange,
64
65
  };
65
66
  };
66
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
67
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
67
68
  __name: "BooleanControlRenderer",
68
69
  props: { ...rendererProps() },
69
70
  setup(__props) {
@@ -84,7 +85,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
84
85
  };
85
86
  }
86
87
  });
87
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
88
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
88
89
  __name: "IntegerControlRenderer",
89
90
  props: { ...rendererProps() },
90
91
  setup(__props) {
@@ -108,28 +109,36 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
108
109
  };
109
110
  }
110
111
  });
111
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
112
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
112
113
  __name: "MarkdownControlRenderer",
113
114
  props: { ...rendererProps() },
114
115
  setup(__props) {
115
116
  const props = __props;
116
- const { control, onChange, appliedOptions, onFocus, onBlur, controlWrapper } = useVanillaControlCustom(useJsonFormsControl(props), (target) => {
117
- return Boolean(target.value) ?? false;
118
- });
117
+ const {
118
+ control,
119
+ handleChange,
120
+ appliedOptions,
121
+ onFocus,
122
+ onBlur,
123
+ controlWrapper
124
+ } = useVanillaControlCustom(useJsonFormsControl(props));
125
+ const changeValue = (value) => {
126
+ handleChange(control.value.path, value);
127
+ };
119
128
  return (_ctx, _cache) => {
120
129
  return openBlock(), createBlock(unref(Markdown), mergeProps(unref(controlWrapper), {
121
130
  modelValue: unref(control).data,
122
131
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
123
132
  enabled: unref(control).enabled,
124
133
  config: unref(appliedOptions),
125
- onChange: unref(onChange),
134
+ onChange: changeValue,
126
135
  onFocus: unref(onFocus),
127
136
  onBlur: unref(onBlur)
128
- }), null, 16, ["modelValue", "enabled", "config", "onChange", "onFocus", "onBlur"]);
137
+ }), null, 16, ["modelValue", "enabled", "config", "onFocus", "onBlur"]);
129
138
  };
130
139
  }
131
140
  });
132
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
141
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
133
142
  __name: "NumberControlRenderer",
134
143
  props: { ...rendererProps() },
135
144
  setup(__props) {
@@ -153,26 +162,35 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
153
162
  };
154
163
  }
155
164
  });
156
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
165
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
157
166
  __name: "StringControlRenderer",
158
167
  props: { ...rendererProps() },
159
168
  setup(__props) {
160
169
  const props = __props;
161
- const { control, onChange, appliedOptions, onFocus, onBlur, controlWrapper } = useVanillaControlCustom(useJsonFormsControl(props));
170
+ const {
171
+ control,
172
+ onChange,
173
+ appliedOptions,
174
+ onFocus,
175
+ onBlur,
176
+ controlWrapper,
177
+ styles
178
+ } = useVanillaControlCustom(useJsonFormsControl(props));
162
179
  return (_ctx, _cache) => {
163
180
  return openBlock(), createBlock(unref(Input), mergeProps(unref(controlWrapper), {
164
181
  modelValue: unref(control).data,
165
182
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
166
183
  enabled: unref(control).enabled,
167
184
  config: unref(appliedOptions),
185
+ styles: unref(styles),
168
186
  onChange: unref(onChange),
169
187
  onFocus: unref(onFocus),
170
188
  onBlur: unref(onBlur)
171
- }), null, 16, ["modelValue", "enabled", "config", "onChange", "onFocus", "onBlur"]);
189
+ }), null, 16, ["modelValue", "enabled", "config", "styles", "onChange", "onFocus", "onBlur"]);
172
190
  };
173
191
  }
174
192
  });
175
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
193
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
176
194
  __name: "TextAreaControlRenderer",
177
195
  props: { ...rendererProps() },
178
196
  setup(__props) {
@@ -207,10 +225,6 @@ const isMarkdownControl = and(
207
225
  uiTypeIs("Control"),
208
226
  optionIs("format", ControlType.markdown)
209
227
  );
210
- const isFixedArray = and(
211
- schemaTypeIs("array"),
212
- optionIs("format", ControlType.fixedArray)
213
- );
214
228
  const isArrayRenderer = and(
215
229
  schemaTypeIs("array")
216
230
  // optionIs('format', ControlType.array),
@@ -221,15 +235,24 @@ const isCustomControl = (customType) => {
221
235
  optionIs("type", customType)
222
236
  );
223
237
  };
224
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
238
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
225
239
  __name: "AutocompleteControlRenderer",
226
240
  props: { ...rendererProps() },
227
241
  setup(__props) {
228
242
  const props = __props;
229
- const { control, onChange, appliedOptions, onFocus, onBlur, controlWrapper } = useVanillaControlCustom(useJsonFormsControl(props), (target) => {
230
- return target?.value ?? void 0;
231
- });
243
+ const {
244
+ control,
245
+ handleChange: _handleChange,
246
+ appliedOptions,
247
+ onFocus,
248
+ onBlur,
249
+ controlWrapper
250
+ } = useVanillaControlCustom(useJsonFormsControl(props));
232
251
  const field = computed(() => appliedOptions.value.field);
252
+ const handleChange = (result) => {
253
+ const { path } = control.value;
254
+ _handleChange(path, result);
255
+ };
233
256
  return (_ctx, _cache) => {
234
257
  return openBlock(), createBlock(unref(Autocomplete), mergeProps(unref(controlWrapper), {
235
258
  modelValue: unref(control).data,
@@ -238,10 +261,10 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
238
261
  config: unref(appliedOptions),
239
262
  "label-key": field.value?.label,
240
263
  "value-key": field.value?.id,
241
- onChange: unref(onChange),
264
+ onChange: handleChange,
242
265
  onFocus: unref(onFocus),
243
266
  onBlur: unref(onBlur)
244
- }), null, 16, ["modelValue", "enabled", "config", "label-key", "value-key", "onChange", "onFocus", "onBlur"]);
267
+ }), null, 16, ["modelValue", "enabled", "config", "label-key", "value-key", "onFocus", "onBlur"]);
245
268
  };
246
269
  }
247
270
  });
@@ -249,24 +272,24 @@ const controlRenderers = [
249
272
  // First custom renderers on format
250
273
  {
251
274
  tester: rankWith(10, isMarkdownControl),
252
- renderer: _sfc_main$a
275
+ renderer: _sfc_main$e
253
276
  },
254
277
  {
255
278
  tester: rankWith(10, isAutoCompleteControl),
256
- renderer: _sfc_main$6
279
+ renderer: _sfc_main$a
257
280
  },
258
281
  {
259
282
  tester: rankWith(10, isTextAreaControl),
260
- renderer: _sfc_main$7
283
+ renderer: _sfc_main$b
261
284
  },
262
285
  // Renderers based on type if no format is provided
263
- { tester: rankWith(10, isStringFormat), renderer: _sfc_main$8 },
264
- { tester: rankWith(10, isNumberControl), renderer: _sfc_main$9 },
286
+ { tester: rankWith(10, isStringFormat), renderer: _sfc_main$c },
287
+ { tester: rankWith(10, isNumberControl), renderer: _sfc_main$d },
265
288
  {
266
289
  tester: rankWith(10, isIntegerControl),
267
- renderer: _sfc_main$b
290
+ renderer: _sfc_main$f
268
291
  },
269
- { tester: rankWith(10, isBooleanControl), renderer: _sfc_main$c }
292
+ { tester: rankWith(10, isBooleanControl), renderer: _sfc_main$g }
270
293
  ];
271
294
  const actionMap = {
272
295
  edit: (router, action) => ({
@@ -301,262 +324,233 @@ class FormState {
301
324
  const useFormState = (form) => {
302
325
  return FormState.getInstance();
303
326
  };
304
- const controlRenderer$1 = defineComponent({
305
- name: "ArrayListRenderer",
306
- components: {
307
- DispatchRenderer,
308
- Btn
309
- },
310
- props: {
311
- ...rendererProps()
312
- },
313
- setup(props) {
327
+ const _hoisted_1$8 = ["title"];
328
+ const _hoisted_2$2 = { key: 0 };
329
+ const _hoisted_3$1 = {
330
+ key: 1,
331
+ class: "list-row"
332
+ };
333
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
334
+ __name: "ArrayRenderer",
335
+ props: { ...rendererProps() },
336
+ setup(__props) {
337
+ const props = __props;
314
338
  const vanillaArrayControl = useVanillaArrayControl(
315
339
  useJsonFormsArrayControl(props)
316
340
  );
317
- const control = vanillaArrayControl.control.value;
318
- if (!control.data || control.data.length < 1) {
341
+ const { styles, childUiSchema, control, appliedOptions } = vanillaArrayControl;
342
+ if (!control.value.data || control.value.data.length < 1) {
319
343
  vanillaArrayControl.addItem(
320
- control.path,
321
- createDefaultValue(control.schema, control.rootSchema)
344
+ control.value.path,
345
+ createDefaultValue(control.value.schema, control.value.rootSchema)
322
346
  )();
323
347
  }
324
- return vanillaArrayControl;
325
- },
326
- computed: {
327
- IconEnum() {
328
- return IconEnum;
329
- },
330
- noData() {
331
- return !this.control.data || this.control.data.length === 0;
332
- },
333
- actions() {
334
- const actions = this.uischema.options?.actions ?? [];
335
- return mapArrayActions(useRouter(), actions);
336
- },
337
- showDelete() {
338
- return this.control.data?.length > 1;
339
- },
340
- translations() {
341
- const jsonforms = inject("jsonforms");
342
- return getArrayTranslations(
343
- jsonforms?.i18n?.translate ?? defaultJsonFormsI18nState.translate,
344
- arrayDefaultTranslations,
345
- this.control.i18nKeyPrefix,
346
- this.control.label
347
- );
348
- },
349
- labelKey() {
350
- const key = this.uischema?.options?.labelKey;
348
+ const noData = computed(
349
+ () => !control.value.data || control.value.data.length === 0
350
+ );
351
+ const actions = computed(() => {
352
+ const actions2 = props.uischema.options?.actions ?? [];
353
+ return mapArrayActions(useRouter(), actions2);
354
+ });
355
+ const showDelete = computed(() => control.value.data?.length > 1);
356
+ computed(() => {
357
+ const key = control.value.uischema?.options?.labelKey;
351
358
  if (!key) return null;
352
359
  return key;
353
- }
354
- },
355
- methods: {
356
- composePaths,
357
- createDefaultValue,
358
- deleteButtonClick(index) {
359
- this.removeItems(this.control.path, [index])();
360
- },
361
- dispatchEvent: (event, data) => {
360
+ });
361
+ const deleteButtonClick = (index) => {
362
+ vanillaArrayControl.removeItems(control.value.path, [index])();
363
+ };
364
+ const dispatchEvent = (event, data) => {
362
365
  const form_id = "";
363
366
  useFormState().dispatchEvent(form_id, event, data);
364
- },
365
- addButtonClick() {
366
- this.addItem(
367
- this.control.path,
368
- createDefaultValue(this.control.schema, this.control.rootSchema)
367
+ };
368
+ const addButtonClick = () => {
369
+ vanillaArrayControl.addItem(
370
+ control.value.path,
371
+ createDefaultValue(control.value.schema, control.value.rootSchema)
369
372
  )();
370
- }
373
+ };
374
+ const showActions = computed(() => {
375
+ return !appliedOptions.value.hideActions;
376
+ });
377
+ return (_ctx, _cache) => {
378
+ return openBlock(), createElementBlock("div", {
379
+ title: unref(control).label
380
+ }, [
381
+ createElementVNode("div", {
382
+ class: normalizeClass([
383
+ "flex gap-2",
384
+ unref(appliedOptions)?.layout === "row" ? "flex-row items-center" : "flex-col"
385
+ ])
386
+ }, [
387
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(control).data, (element, index) => {
388
+ return openBlock(), createElementBlock("div", {
389
+ key: `${unref(control).path}-${index}`,
390
+ class: "flex-1"
391
+ }, [
392
+ createElementVNode("div", {
393
+ class: normalizeClass([
394
+ "flex gap-2",
395
+ unref(appliedOptions)?.layout === "row" ? "flex-col" : "flex-row items-center"
396
+ ])
397
+ }, [
398
+ createElementVNode("div", null, [
399
+ createVNode(unref(DispatchRenderer), {
400
+ schema: unref(control).schema,
401
+ uischema: unref(childUiSchema),
402
+ path: unref(composePaths)(unref(control).path, `${index}`),
403
+ enabled: unref(control).enabled,
404
+ renderers: unref(control).renderers,
405
+ cells: unref(control).cells
406
+ }, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"])
407
+ ]),
408
+ showActions.value ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
409
+ (openBlock(true), createElementBlock(Fragment, null, renderList(actions.value, (action) => {
410
+ return openBlock(), createElementBlock(Fragment, null, [
411
+ action.show(element) ? (openBlock(), createBlock(unref(Btn), {
412
+ key: action.label,
413
+ icon: action.icon,
414
+ outline: true,
415
+ onClick: ($event) => dispatchEvent(action.label, element)
416
+ }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
417
+ ], 64);
418
+ }), 256)),
419
+ showDelete.value ? (openBlock(), createBlock(unref(Btn), {
420
+ key: 0,
421
+ icon: unref(IconEnum).Delete,
422
+ outline: true,
423
+ onClick: ($event) => deleteButtonClick(index)
424
+ }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
425
+ ])) : createCommentVNode("", true)
426
+ ], 2)
427
+ ]);
428
+ }), 128)),
429
+ noData.value ? (openBlock(), createElementBlock("div", {
430
+ key: 0,
431
+ class: normalizeClass(["list-row", unref(styles).arrayList.noData])
432
+ }, " No data ", 2)) : createCommentVNode("", true),
433
+ showActions.value ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
434
+ createVNode(unref(Btn), {
435
+ icon: unref(IconEnum).Plus,
436
+ outline: true,
437
+ onClick: addButtonClick
438
+ }, {
439
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
440
+ createTextVNode(" Add ", -1)
441
+ ])]),
442
+ _: 1
443
+ }, 8, ["icon"])
444
+ ])) : createCommentVNode("", true)
445
+ ], 2)
446
+ ], 8, _hoisted_1$8);
447
+ };
371
448
  }
372
449
  });
373
- const entry$1 = {
374
- renderer: controlRenderer$1,
375
- tester: rankWith(2, isArrayRenderer)
376
- };
377
- const _export_sfc = (sfc, props) => {
378
- const target = sfc.__vccOpts || sfc;
379
- for (const [key, val] of props) {
380
- target[key] = val;
450
+ const arrayRenderers = [
451
+ {
452
+ tester: rankWith(12, isArrayRenderer),
453
+ renderer: _sfc_main$9
381
454
  }
382
- return target;
383
- };
384
- const _hoisted_1$6 = { class: "fieldset" };
385
- const _hoisted_2$2 = { class: "flex gap-2 items-center" };
386
- const _hoisted_3$2 = { class: "mt-3 flex gap-2" };
387
- const _hoisted_4$1 = { class: "py-2" };
388
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
389
- const _component_dispatch_renderer = resolveComponent("dispatch-renderer");
390
- const _component_Btn = resolveComponent("Btn");
391
- return _ctx.control.visible ? (openBlock(), createElementBlock("fieldset", {
392
- key: 0,
393
- class: normalizeClass(_ctx.styles.arrayList.root)
394
- }, [
395
- !_ctx.labelKey ? (openBlock(), createElementBlock("legend", {
396
- key: 0,
397
- class: normalizeClass(_ctx.styles.arrayList.legend)
398
- }, [
399
- createElementVNode("label", {
400
- class: normalizeClass(_ctx.styles.arrayList.label)
401
- }, toDisplayString(_ctx.control.label), 3)
402
- ], 2)) : createCommentVNode("", true),
403
- createElementVNode("div", null, [
404
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.control.data, (element, index) => {
405
- return openBlock(), createElementBlock("div", {
406
- key: `${_ctx.control.path}-${index}`
407
- }, [
408
- createElementVNode("fieldset", _hoisted_1$6, [
409
- _ctx.labelKey ? (openBlock(), createElementBlock("legend", {
410
- key: 0,
411
- class: normalizeClass(_ctx.styles.arrayList.legend)
412
- }, toDisplayString(element[_ctx.labelKey]?.toLowerCase()), 3)) : createCommentVNode("", true),
413
- createElementVNode("div", _hoisted_2$2, [
414
- createVNode(_component_dispatch_renderer, {
415
- schema: _ctx.control.schema,
416
- uischema: _ctx.childUiSchema,
417
- path: _ctx.composePaths(_ctx.control.path, `${index}`),
418
- enabled: _ctx.control.enabled,
419
- renderers: _ctx.control.renderers,
420
- cells: _ctx.control.cells
421
- }, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"]),
422
- createElementVNode("div", _hoisted_3$2, [
423
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.actions, (action) => {
424
- return openBlock(), createElementBlock(Fragment, null, [
425
- action.show(element) ? (openBlock(), createBlock(_component_Btn, {
426
- key: action.label,
427
- icon: action.icon,
428
- outline: true,
429
- onClick: ($event) => _ctx.dispatchEvent(action.label, element)
430
- }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
431
- ], 64);
432
- }), 256)),
433
- _ctx.showDelete ? (openBlock(), createBlock(_component_Btn, {
434
- key: 0,
435
- icon: _ctx.IconEnum.Delete,
436
- outline: true,
437
- onClick: ($event) => _ctx.deleteButtonClick(index)
438
- }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
439
- ])
440
- ])
455
+ ];
456
+ const _hoisted_1$7 = { class: "flex flex-col gap-4" };
457
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
458
+ __name: "CollapseLayout",
459
+ props: { ...rendererProps() },
460
+ setup(__props) {
461
+ const props = __props;
462
+ const jsonLayout = useJsonFormsLayout(props);
463
+ const { layout, renderers, cells } = jsonLayout;
464
+ const title = computed(() => {
465
+ const { titleKey, title: title2 } = layout?.value.uischema?.options ?? {};
466
+ if (title2) return title2;
467
+ if (titleKey) return layout?.value.data[titleKey];
468
+ return layout?.value.uischema?.options?.titleKey;
469
+ });
470
+ return (_ctx, _cache) => {
471
+ return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
472
+ default: withCtx(() => [
473
+ createElementVNode("div", _hoisted_1$7, [
474
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
475
+ return openBlock(), createBlock(unref(DispatchRenderer), {
476
+ key: index,
477
+ schema: unref(layout).schema,
478
+ uischema: element,
479
+ path: unref(layout).path,
480
+ renderers: unref(renderers),
481
+ cells: unref(cells)
482
+ }, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
483
+ }), 128))
441
484
  ])
442
- ]);
443
- }), 128))
444
- ]),
445
- createElementVNode("div", _hoisted_4$1, [
446
- createVNode(_component_Btn, {
447
- icon: _ctx.IconEnum.Plus,
448
- outline: true,
449
- onClick: _ctx.addButtonClick
450
- }, {
451
- default: withCtx(() => [..._cache[0] || (_cache[0] = [
452
- createTextVNode(" Add ", -1)
453
- ])]),
485
+ ]),
454
486
  _: 1
455
- }, 8, ["icon", "onClick"])
456
- ]),
457
- _ctx.noData ? (openBlock(), createElementBlock("div", {
458
- key: 1,
459
- class: normalizeClass(_ctx.styles.arrayList.noData)
460
- }, toDisplayString(_ctx.translations.noDataMessage), 3)) : createCommentVNode("", true)
461
- ], 2)) : createCommentVNode("", true);
462
- }
463
- const ArrayRenderer = /* @__PURE__ */ _export_sfc(controlRenderer$1, [["render", _sfc_render$1]]);
464
- const controlRenderer = defineComponent({
465
- name: "FixedArrayListRenderer",
466
- components: {
467
- DispatchRenderer
468
- },
469
- props: {
470
- ...rendererProps()
471
- },
472
- setup(props) {
473
- return useVanillaArrayControl(useJsonFormsArrayControl(props));
474
- },
475
- computed: {
476
- noData() {
477
- return !this.control.data || this.control.data.length === 0;
478
- },
479
- translations() {
480
- const jsonforms = inject("jsonforms");
481
- return getArrayTranslations(
482
- jsonforms?.i18n?.translate ?? defaultJsonFormsI18nState.translate,
483
- arrayDefaultTranslations,
484
- this.control.i18nKeyPrefix,
485
- this.control.label
486
- );
487
- },
488
- labelKey() {
489
- const key = this.uischema?.options?.labelKey;
490
- if (!key) return null;
491
- return key;
492
- }
493
- },
494
- methods: {
495
- composePaths,
496
- createDefaultValue
487
+ }, 8, ["title"]);
488
+ };
489
+ }
490
+ });
491
+ const _hoisted_1$6 = { class: "flex flex-row gap-4 items-center" };
492
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
493
+ __name: "HorizontalLayout",
494
+ props: { ...rendererProps() },
495
+ setup(__props) {
496
+ const props = __props;
497
+ const { layout, renderers, cells } = useJsonFormsLayout(props);
498
+ return (_ctx, _cache) => {
499
+ return openBlock(), createElementBlock("div", _hoisted_1$6, [
500
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
501
+ return openBlock(), createBlock(unref(DispatchRenderer), {
502
+ key: index,
503
+ schema: unref(layout).schema,
504
+ uischema: element,
505
+ path: unref(layout).path,
506
+ renderers: unref(renderers),
507
+ cells: unref(cells)
508
+ }, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
509
+ }), 128))
510
+ ]);
511
+ };
512
+ }
513
+ });
514
+ const _hoisted_1$5 = { class: "flex flex-col gap-4" };
515
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
516
+ __name: "VerticalLayout",
517
+ props: { ...rendererProps() },
518
+ setup(__props) {
519
+ const props = __props;
520
+ const { layout, renderers, cells } = useJsonFormsLayout(props);
521
+ return (_ctx, _cache) => {
522
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
523
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
524
+ return openBlock(), createBlock(unref(DispatchRenderer), {
525
+ key: index,
526
+ schema: unref(layout).schema,
527
+ uischema: element,
528
+ path: unref(layout).path,
529
+ renderers: unref(renderers),
530
+ cells: unref(cells)
531
+ }, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
532
+ }), 128))
533
+ ]);
534
+ };
497
535
  }
498
536
  });
499
- const entry = {
500
- renderer: controlRenderer,
501
- tester: rankWith(2, isFixedArray)
502
- };
503
- const _hoisted_1$5 = { class: "fieldset" };
504
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
505
- const _component_dispatch_renderer = resolveComponent("dispatch-renderer");
506
- return _ctx.control.visible ? (openBlock(), createElementBlock("fieldset", {
507
- key: 0,
508
- class: normalizeClass(_ctx.styles.arrayList.root)
509
- }, [
510
- !_ctx.labelKey ? (openBlock(), createElementBlock("legend", {
511
- key: 0,
512
- class: normalizeClass(_ctx.styles.arrayList.legend)
513
- }, [
514
- createElementVNode("label", {
515
- class: normalizeClass(_ctx.styles.arrayList.label)
516
- }, toDisplayString(_ctx.control.label), 3)
517
- ], 2)) : createCommentVNode("", true),
518
- createElementVNode("div", {
519
- class: normalizeClass(_ctx.styles.fixedArrayList.root)
520
- }, [
521
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.control.data, (element, index) => {
522
- return openBlock(), createElementBlock("div", {
523
- key: `${_ctx.control.path}-${index}`,
524
- class: normalizeClass(_ctx.styles.fixedArrayList.item)
525
- }, [
526
- createElementVNode("fieldset", _hoisted_1$5, [
527
- _ctx.labelKey ? (openBlock(), createElementBlock("legend", {
528
- key: 0,
529
- class: normalizeClass(_ctx.styles.arrayList.legend)
530
- }, toDisplayString(element[_ctx.labelKey]?.toLowerCase()), 3)) : createCommentVNode("", true),
531
- createVNode(_component_dispatch_renderer, {
532
- schema: _ctx.control.schema,
533
- uischema: _ctx.childUiSchema,
534
- path: _ctx.composePaths(_ctx.control.path, `${index}`),
535
- enabled: _ctx.control.enabled,
536
- renderers: _ctx.control.renderers,
537
- cells: _ctx.control.cells
538
- }, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"])
539
- ])
540
- ], 2);
541
- }), 128))
542
- ], 2),
543
- _ctx.noData ? (openBlock(), createElementBlock("div", {
544
- key: 1,
545
- class: normalizeClass(_ctx.styles.arrayList.noData)
546
- }, toDisplayString(_ctx.translations.noDataMessage), 3)) : createCommentVNode("", true)
547
- ], 2)) : createCommentVNode("", true);
548
- }
549
- const FixedArrayRenderer = /* @__PURE__ */ _export_sfc(controlRenderer, [["render", _sfc_render]]);
550
- const arrayRenderers = [
551
- entry,
552
- entry$1
553
- ];
554
537
  const layoutRenderers = [
555
- // LayoutRenderer
538
+ {
539
+ tester: rankWith(10, uiTypeIs(LayoutTypes.VerticalLayout)),
540
+ renderer: _sfc_main$6
541
+ },
542
+ {
543
+ tester: rankWith(10, uiTypeIs(LayoutTypes.HorizontalLayout)),
544
+ renderer: _sfc_main$7
545
+ },
546
+ {
547
+ tester: rankWith(10, uiTypeIs(LayoutTypes.CollapseLayout)),
548
+ renderer: _sfc_main$8
549
+ }
556
550
  ];
557
551
  const _hoisted_1$4 = { class: "" };
558
552
  const _hoisted_2$1 = { class: "flex gap-2 items-center mb-2" };
559
- const _hoisted_3$1 = { class: "flex gap-2" };
553
+ const _hoisted_3 = { class: "flex gap-2" };
560
554
  const _sfc_main$5 = /* @__PURE__ */ defineComponent({
561
555
  __name: "table-filter",
562
556
  props: {
@@ -600,7 +594,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
600
594
  _: 1
601
595
  })) : createCommentVNode("", true)
602
596
  ]),
603
- createElementVNode("div", _hoisted_3$1, [
597
+ createElementVNode("div", _hoisted_3, [
604
598
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.filters, (filter) => {
605
599
  return openBlock(), createBlock(unref(BtnBadge), {
606
600
  key: filter.key,
@@ -930,12 +924,12 @@ const customRenderers = [
930
924
  const customRenderesName = customRenderers.map((c) => {
931
925
  return c.renderer.name;
932
926
  });
933
- const useVanillaRenderers = vanillaRenderers.filter(
927
+ vanillaRenderers.filter(
934
928
  (v) => !customRenderesName.includes(v.renderer.name)
935
929
  );
936
930
  const tailwindRenderers = [
937
- ...customRenderers,
938
- ...useVanillaRenderers
931
+ ...vanillaRenderers,
932
+ ...customRenderers
939
933
  ];
940
934
  const _hoisted_1$1 = ["id"];
941
935
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
@@ -951,7 +945,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
951
945
  "modelValue": {},
952
946
  "modelModifiers": {}
953
947
  }),
954
- emits: /* @__PURE__ */ mergeModels(["valid", "change", "submit"], ["update:modelValue"]),
948
+ emits: /* @__PURE__ */ mergeModels(["valid", "change", "submit", "errors"], ["update:modelValue"]),
955
949
  setup(__props, { emit: __emit }) {
956
950
  const properties = __props;
957
951
  const _JSON_FORM_ID = `json-form-${Date.now()}`;
@@ -964,6 +958,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
964
958
  valid.value = event.errors.length === 0;
965
959
  emits("valid", valid.value);
966
960
  emits("change", event.data);
961
+ emits("errors", event.errors);
962
+ Debugger.debug(event.errors);
967
963
  };
968
964
  const onSubmit = (event) => {
969
965
  event.preventDefault();
@@ -1004,10 +1000,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1004
1000
  };
1005
1001
  }
1006
1002
  });
1007
- const _hoisted_1 = { class: "card w-full shadow border-2" };
1008
- const _hoisted_2 = { class: "card-body" };
1009
- const _hoisted_3 = { class: "card-title" };
1010
- const _hoisted_4 = { class: "card-actions flex justify-end" };
1003
+ const _hoisted_1 = { class: "card-actions flex justify-between" };
1004
+ const _hoisted_2 = { class: "flex justify-end gap-2" };
1011
1005
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1012
1006
  __name: "form-with-actions.component",
1013
1007
  props: /* @__PURE__ */ mergeModels({
@@ -1024,23 +1018,33 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1024
1018
  const properties = __props;
1025
1019
  const valid = ref(false);
1026
1020
  const formData = useModel(__props, "modelValue");
1021
+ const submitted = ref(false);
1027
1022
  const store = new FormStore(properties.formSchema);
1028
1023
  const emits = __emit;
1029
1024
  const save = () => {
1025
+ submitted.value = true;
1026
+ if (!valid.value) {
1027
+ return;
1028
+ }
1030
1029
  store.save(formData.value.id, formData.value).then(() => {
1031
1030
  emits("success");
1032
1031
  });
1033
1032
  };
1034
1033
  const clear = () => {
1035
1034
  formData.value = { id: null };
1035
+ submitted.value = false;
1036
1036
  };
1037
1037
  const onValid = (v) => {
1038
+ submitted.value = false;
1038
1039
  valid.value = v;
1039
1040
  };
1041
+ const title = computed(() => {
1042
+ if (!properties.updateTitle) return properties.createTitle;
1043
+ return formData.value?.id ? properties.updateTitle : properties.createTitle;
1044
+ });
1040
1045
  return (_ctx, _cache) => {
1041
- return openBlock(), createElementBlock("div", _hoisted_1, [
1042
- createElementVNode("div", _hoisted_2, [
1043
- createElementVNode("h1", _hoisted_3, toDisplayString(formData.value?.id ? __props.updateTitle : __props.createTitle), 1),
1046
+ return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
1047
+ default: withCtx(() => [
1044
1048
  createVNode(_sfc_main$2, {
1045
1049
  id: `form_${properties.id}`,
1046
1050
  modelValue: formData.value,
@@ -1050,29 +1054,41 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1050
1054
  onValid: _cache[1] || (_cache[1] = ($event) => onValid($event)),
1051
1055
  onSubmit: save
1052
1056
  }, null, 8, ["id", "modelValue", "schema", "uischema"]),
1053
- createElementVNode("div", _hoisted_4, [
1054
- createVNode(unref(Btn), {
1055
- outline: true,
1056
- onClick: clear
1057
- }, {
1058
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
1059
- createTextVNode(" Clear ", -1)
1060
- ])]),
1061
- _: 1
1062
- }),
1063
- createVNode(unref(Btn), {
1064
- color: unref(Color).primary,
1065
- disabled: !valid.value,
1066
- onClick: save
1067
- }, {
1068
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
1069
- createTextVNode(" Save ", -1)
1070
- ])]),
1071
- _: 1
1072
- }, 8, ["color", "disabled"])
1057
+ createElementVNode("div", _hoisted_1, [
1058
+ createElementVNode("div", null, [
1059
+ !valid.value && submitted.value ? (openBlock(), createBlock(unref(Alert), {
1060
+ key: 0,
1061
+ message: "The form is not valid",
1062
+ type: "error"
1063
+ })) : createCommentVNode("", true)
1064
+ ]),
1065
+ createElementVNode("div", _hoisted_2, [
1066
+ renderSlot(_ctx.$slots, "actions"),
1067
+ !formData.value.id ? (openBlock(), createBlock(unref(Btn), {
1068
+ key: 0,
1069
+ outline: true,
1070
+ onClick: clear
1071
+ }, {
1072
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
1073
+ createTextVNode(" Clear ", -1)
1074
+ ])]),
1075
+ _: 1
1076
+ })) : createCommentVNode("", true),
1077
+ createVNode(unref(Btn), {
1078
+ color: unref(Color).primary,
1079
+ disabled: submitted.value,
1080
+ onClick: save
1081
+ }, {
1082
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
1083
+ createTextVNode(" Save ", -1)
1084
+ ])]),
1085
+ _: 1
1086
+ }, 8, ["color", "disabled"])
1087
+ ])
1073
1088
  ])
1074
- ])
1075
- ]);
1089
+ ]),
1090
+ _: 3
1091
+ }, 8, ["title"]);
1076
1092
  };
1077
1093
  }
1078
1094
  });
@@ -1197,7 +1213,7 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
1197
1213
  const create = (object, options2) => {
1198
1214
  return httpRequest.post(getDataUri(), object, options2).then((response) => {
1199
1215
  handleSuccess(`Created ${notificationEntity}`);
1200
- return response;
1216
+ return response.data;
1201
1217
  }).catch((response) => {
1202
1218
  handleError(response, `Failed to create ${notificationEntity}`);
1203
1219
  });
@@ -1205,13 +1221,17 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
1205
1221
  const patch = (id, object, options2) => {
1206
1222
  return httpRequest.patch(getDataUri(id), object, options2).then((response) => {
1207
1223
  handleSuccess(`Saved ${notificationEntity}`);
1208
- return response;
1224
+ return response.data;
1209
1225
  }).catch((response) => {
1210
1226
  handleError(response, `Failed to save ${notificationEntity}`);
1211
1227
  });
1212
1228
  };
1213
1229
  const get = (id, options2) => {
1214
- return httpRequest.get(getDataUri(id), options2);
1230
+ return httpRequest.get(getDataUri(id), options2).then((response) => {
1231
+ return response.data;
1232
+ }).catch((response) => {
1233
+ handleError(response, `Failed to load data`);
1234
+ });
1215
1235
  };
1216
1236
  const _delete = (id, options2) => {
1217
1237
  return httpRequest.delete(getDataUri(id), options2).then((response) => {
@@ -1226,7 +1246,7 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
1226
1246
  objects.map((object) => httpRequest.post(getDataUri(), object, options2))
1227
1247
  ).then((response) => {
1228
1248
  handleSuccess(`Created ${notificationEntity}`);
1229
- return response;
1249
+ return response.data;
1230
1250
  }).catch((response) => {
1231
1251
  handleError(response, `Failed to save ${notificationEntity}`);
1232
1252
  });
@@ -1234,19 +1254,18 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
1234
1254
  return { create, patch, createMulti, delete: _delete, get };
1235
1255
  };
1236
1256
  export {
1237
- ArrayRenderer,
1238
- _sfc_main$6 as AutocompleteControlRenderer,
1239
- _sfc_main$c as BooleanControlRenderer,
1240
- FixedArrayRenderer,
1257
+ _sfc_main$9 as ArrayRenderer,
1258
+ _sfc_main$a as AutocompleteControlRenderer,
1259
+ _sfc_main$g as BooleanControlRenderer,
1241
1260
  _sfc_main$2 as FormComponent,
1242
1261
  _sfc_main as FormModal,
1243
1262
  FormModalService,
1244
1263
  FormStore,
1245
1264
  _sfc_main$1 as FormWithActions,
1246
1265
  _sfc_main$3 as FormWithTableComponent,
1247
- _sfc_main$b as IntegerControlRenderer,
1248
- _sfc_main$9 as NumberControlRenderer,
1249
- _sfc_main$8 as StringControlRenderer,
1266
+ _sfc_main$f as IntegerControlRenderer,
1267
+ _sfc_main$d as NumberControlRenderer,
1268
+ _sfc_main$c as StringControlRenderer,
1250
1269
  _sfc_main$4 as TableComponent,
1251
1270
  arrayRenderers,
1252
1271
  controlRenderers,
@@ -1254,11 +1273,10 @@ export {
1254
1273
  isArrayRenderer,
1255
1274
  isAutoCompleteControl,
1256
1275
  isCustomControl,
1257
- isFixedArray,
1258
1276
  isMarkdownControl,
1259
1277
  isStringFormat,
1260
1278
  isTextAreaControl,
1261
1279
  layoutRenderers,
1262
- _sfc_main$a as markdownControlRenderer,
1280
+ _sfc_main$e as markdownControlRenderer,
1263
1281
  useFormState
1264
1282
  };