@ghentcdh/json-forms-vue 0.8.6 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/form.store.d.ts +1 -1
- package/forms/Dispatch.vue.d.ts +10 -0
- package/forms/FormComponent.properties.d.ts +48 -0
- package/{form.component.vue.d.ts → forms/FormComponent.vue.d.ts} +19 -17
- package/forms/FormWithActions.properties.d.ts +52 -0
- package/forms/FormWithActions.vue.d.ts +258 -0
- package/forms/FormWithTable.properties.d.ts +65 -0
- package/{form-with-table.component.vue.d.ts → forms/FormWithTable.vue.d.ts} +24 -15
- package/forms/errorMessages.d.ts +10 -0
- package/forms/errorMode.d.ts +4 -0
- package/forms/modal/FormModal.properties.d.ts +64 -0
- package/forms/modal/FormModal.vue.d.ts +275 -0
- package/{modal/form-modal.service.d.ts → forms/modal/FormModalService.d.ts} +4 -5
- package/forms/renderer-registry.d.ts +7 -0
- package/forms/renderers/array/ArrayRenderer.vue.d.ts +7 -0
- package/forms/renderers/array/ArrayRenderers.d.ts +10 -0
- package/forms/renderers/controls/AutocompleteControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/BooleanControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/MarkdownControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/MultiSelectControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/NumberControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/SelectControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/StringControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/TextAreaControlRenderer.vue.d.ts +7 -0
- package/forms/renderers/controls/composable/UseControlBinding.d.ts +29 -0
- package/forms/renderers/controls/composable/UseFetchOption.d.ts +16 -0
- package/forms/renderers/controls/composable/UseInput.d.ts +24 -0
- package/forms/renderers/controls/composable/UseSelectBinding.d.ts +23 -0
- package/forms/renderers/controls/composable/resource.d.ts +187 -0
- package/forms/renderers/controls/index.d.ts +10 -0
- package/forms/renderers/index.d.ts +3 -0
- package/forms/renderers/layout/CollapseLayoutRenderer.vue.d.ts +7 -0
- package/forms/renderers/layout/LayoutRenderer.vue.d.ts +7 -0
- package/forms/renderers/layout/LayoutRenders.d.ts +10 -0
- package/forms/renderers/layout/colspan.d.ts +1 -0
- package/forms/renderes.d.ts +19 -0
- package/forms/scope.d.ts +4 -0
- package/forms/types.d.ts +36 -0
- package/index.d.ts +9 -12
- package/index.js +1826 -1503
- package/index.mjs +1877 -1554
- package/package.json +4 -5
- package/renderes/tester.d.ts +2 -0
- package/form-with-actions.component.properties.d.ts +0 -40
- package/form-with-actions.component.vue.d.ts +0 -88
- package/form-with-table.component.properties.d.ts +0 -58
- package/form.component.properties.d.ts +0 -49
- package/modal/form-modal.props.d.ts +0 -30
- package/modal/form-modal.vue.d.ts +0 -35
- package/modal/index.d.ts +0 -3
- package/renderes/array/ArrayRenderer.vue.d.ts +0 -74
- package/renderes/array/index.d.ts +0 -76
- package/renderes/controls/AutocompleteControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/BooleanControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/IntegerControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/MarkdownControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/MultiSelectControlRender.vue.d.ts +0 -74
- package/renderes/controls/NumberControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/SelectControlRender.vue.d.ts +0 -74
- package/renderes/controls/StringControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/TextAreaControlRenderer.vue.d.ts +0 -74
- package/renderes/controls/index.d.ts +0 -675
- package/renderes/index.d.ts +0 -817
- package/renderes/layouts/CollapseLayout.vue.d.ts +0 -73
- package/renderes/layouts/GridLayout.vue.d.ts +0 -73
- package/renderes/layouts/HorizontalLayout.vue.d.ts +0 -73
- package/renderes/layouts/VerticalLayout.vue.d.ts +0 -73
- package/renderes/layouts/index.d.ts +0 -75
- package/standalone/emits.d.ts +0 -5
- package/standalone/properties.d.ts +0 -2
- package/utils/style.d.ts +0 -6
- package/utils/vanillaControl.d.ts +0 -15
package/index.mjs
CHANGED
|
@@ -1,1128 +1,396 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useJsonFormsControl, rendererProps, useJsonFormsArrayControl, DispatchRenderer, useJsonFormsLayout, JsonForms } from "@jsonforms/vue";
|
|
6
|
-
import axios from "axios";
|
|
7
|
-
import { useVanillaControl, useVanillaArrayControl, vanillaRenderers } from "@jsonforms/vue-vanilla";
|
|
8
|
-
import { pick as pick$1, omit as omit$1, isArray } from "lodash-es";
|
|
9
|
-
import { and, optionIs, or, schemaTypeIs, isBooleanControl as isBooleanControl$1 } from "@jsonforms/core/src/testers/testers";
|
|
10
|
-
import { ControlType, LayoutTypes, RequestSchema, extractFilters, findColumnDef } from "@ghentcdh/json-forms-core";
|
|
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 as pick$1, 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";
|
|
11
5
|
import { computedAsync } from "@vueuse/core";
|
|
12
6
|
import { useRoute, useRouter } from "vue-router";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
async save(id, data) {
|
|
26
|
-
if (!this.uri) return;
|
|
27
|
-
const promise2 = id ? useApi().patch(`${this.uri}/${id}`, data) : useApi().post(this.uri, data);
|
|
28
|
-
return promise2.then(() => {
|
|
29
|
-
NotificationService.success("Data saved");
|
|
30
|
-
}).catch((error2) => {
|
|
31
|
-
console.error(error2);
|
|
32
|
-
NotificationService.error("Error saving data");
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const FormComponentProperties = {
|
|
37
|
-
/** Unique id applied to the `<form>` element and used as `<json-forms>` key. */
|
|
38
|
-
id: { type: String, required: true },
|
|
39
|
-
name: { type: String, default: "form" },
|
|
7
|
+
import { useApi } from "@ghentcdh/tools-vue";
|
|
8
|
+
import { useFieldArray, useField, useFieldValue, useForm } from "vee-validate";
|
|
9
|
+
import { uiTypeIs, rankWith, or as or$1 } from "@jsonforms/core";
|
|
10
|
+
import { and, optionIs, or, schemaTypeIs, isBooleanControl as isBooleanControl$1 } from "@jsonforms/core/src/testers/testers";
|
|
11
|
+
import axios from "axios";
|
|
12
|
+
const FormModalProperties = {
|
|
13
|
+
/** Title displayed in the modal header. */
|
|
14
|
+
modalTitle: { type: String, required: true },
|
|
15
|
+
/** Label for the save button. */
|
|
16
|
+
saveLabel: { type: String, default: "save" },
|
|
17
|
+
/** Label for the cancel button. */
|
|
18
|
+
cancelLabel: { type: String, default: "cancel" },
|
|
40
19
|
/** JSON schema describing the shape of the form data. */
|
|
41
20
|
schema: { type: Object, required: true },
|
|
42
21
|
/** UI schema describing the layout and controls. */
|
|
43
22
|
uiSchema: { type: Object, required: true },
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
/** Modal width (`'xs'`, `'sm'`, `'md'`, `'lg'`, `'xl'`). */
|
|
24
|
+
modalSize: { type: String, default: "md" },
|
|
25
|
+
/** Callback invoked when the modal closes (with result or `null` on cancel). */
|
|
26
|
+
onClose: {
|
|
27
|
+
type: Function,
|
|
28
|
+
required: true
|
|
48
29
|
},
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/** Emitted with the raw Ajv validation errors array. */
|
|
61
|
-
"errors",
|
|
62
|
-
/** Generic event channel for custom renderer dispatches (`FormEventPayload`). */
|
|
63
|
-
"events"
|
|
64
|
-
];
|
|
65
|
-
const FormWithActionsProperties = {
|
|
66
|
-
/** Unique identifier; the inner form receives `form_${id}` as its id. */
|
|
67
|
-
id: { type: String, required: true },
|
|
68
|
-
/** Title shown when creating a new record (`formData.id` is falsy). */
|
|
69
|
-
createTitle: { type: String, required: true },
|
|
70
|
-
/** Title shown when editing an existing record. Falls back to `createTitle`. */
|
|
71
|
-
updateTitle: { type: String },
|
|
72
|
-
/** JSON schema describing the shape of the form data. */
|
|
73
|
-
schema: { type: Object },
|
|
74
|
-
/** UI schema describing the layout and controls. */
|
|
75
|
-
uiSchema: { type: Object },
|
|
76
|
-
/** When provided, the component submits the form to this URI via `FormStore`. */
|
|
77
|
-
uri: { type: String },
|
|
78
|
-
/** When true, the form content scrolls and the action bar stays pinned. */
|
|
79
|
-
scrollable: { type: Boolean, default: false },
|
|
80
|
-
/** When true, the component takes the full height of its parent. */
|
|
81
|
-
fullHeight: { type: Boolean, default: false }
|
|
30
|
+
/** Callback for form events dispatched by custom renderers. */
|
|
31
|
+
onEvents: {
|
|
32
|
+
type: Function
|
|
33
|
+
},
|
|
34
|
+
/** Initial form data to populate the form with. */
|
|
35
|
+
data: { type: Object, required: true },
|
|
36
|
+
/** When validation errors are shown. */
|
|
37
|
+
errorMode: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "onBlur"
|
|
40
|
+
}
|
|
82
41
|
};
|
|
83
|
-
const
|
|
84
|
-
/**
|
|
85
|
-
"
|
|
86
|
-
/** Emitted
|
|
87
|
-
"success",
|
|
88
|
-
/** Emitted with form data when saving without a `uri`. */
|
|
89
|
-
"submit",
|
|
90
|
-
/** Emitted whenever the form validity changes. */
|
|
91
|
-
"valid",
|
|
92
|
-
/** Forwards custom renderer events (`FormEventPayload`). */
|
|
42
|
+
const FormModalEmits = [
|
|
43
|
+
/** Emitted when the modal is closed (submit or cancel). */
|
|
44
|
+
"closeModal",
|
|
45
|
+
/** Emitted when a custom renderer dispatches a form event. */
|
|
93
46
|
"events",
|
|
47
|
+
/** Emitted when validation errors change. */
|
|
94
48
|
"errors",
|
|
95
|
-
/** Emitted when
|
|
96
|
-
"
|
|
97
|
-
];
|
|
98
|
-
const FormWithTableProperties = {
|
|
99
|
-
/** Unique identifier used to generate the table form id (`form_table_${id}`). */
|
|
100
|
-
id: { type: String, required: true },
|
|
101
|
-
/** Heading displayed above the table. */
|
|
102
|
-
tableTitle: { type: String, required: true },
|
|
103
|
-
/** Title shown in the create modal. */
|
|
104
|
-
createTitle: { type: String, required: true },
|
|
105
|
-
/** Title shown in the edit modal. Falls back to `createTitle`. */
|
|
106
|
-
updateTitle: { type: String },
|
|
107
|
-
/** Overrides `uri` as the data source for the table. */
|
|
108
|
-
dataUri: { type: String },
|
|
109
|
-
/** Custom action buttons rendered in each table row. */
|
|
110
|
-
tableActions: { type: Array },
|
|
111
|
-
/** Layout for the create/edit modal form. */
|
|
112
|
-
form: { type: Object },
|
|
113
|
-
/** Layout for the table columns. */
|
|
114
|
-
table: { type: Object },
|
|
115
|
-
/** Layout for the table filter controls. */
|
|
116
|
-
filter: { type: Object },
|
|
117
|
-
/** Base URI used by `FormStore` for CRUD operations and as the default table data source. */
|
|
118
|
-
uri: { type: String },
|
|
119
|
-
/** Default data used when opening the create modal. */
|
|
120
|
-
initialData: { type: Object, default: () => ({}) }
|
|
121
|
-
};
|
|
122
|
-
const FormWithTableEmits = [
|
|
123
|
-
/** Emitted when a table row is edited and a custom listener is bound. */
|
|
124
|
-
"editData",
|
|
125
|
-
/** Emitted after a record is successfully saved (created or updated). Payload: `{ id?: string, data: Data }`. */
|
|
126
|
-
"save",
|
|
127
|
-
/** Emitted after a record is successfully deleted. Payload: the deleted record. */
|
|
128
|
-
"delete",
|
|
129
|
-
/** Forwarded form events dispatched by custom renderers inside the modal (e.g. "create"). Payload: `FormEventPayload`. */
|
|
130
|
-
"events",
|
|
131
|
-
"custom:edit",
|
|
132
|
-
"custom:create"
|
|
49
|
+
/** Emitted when form validity changes. */
|
|
50
|
+
"valid"
|
|
133
51
|
];
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
};
|
|
161
|
-
const controlWrapper = computed(() => {
|
|
162
|
-
return {
|
|
163
|
-
...vanillaControl.controlWrapper.value,
|
|
164
|
-
...omit$1(vanillaControl.appliedOptions.value, "styles"),
|
|
165
|
-
...pick$1(vanillaControl.appliedOptions.value.styles, ["width"]),
|
|
166
|
-
isFocused: isFocused.value,
|
|
167
|
-
isTouched: isTouched.value
|
|
168
|
-
};
|
|
169
|
-
});
|
|
170
|
-
return {
|
|
171
|
-
...vanillaControl,
|
|
172
|
-
appliedOptions: vanillaControl.appliedOptions,
|
|
173
|
-
controlWrapper,
|
|
174
|
-
isFocused,
|
|
175
|
-
isTouched,
|
|
176
|
-
onFocus,
|
|
177
|
-
onBlur
|
|
178
|
-
// handleChange,
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
182
|
-
__name: "AutocompleteControlRenderer",
|
|
183
|
-
props: { ...rendererProps() },
|
|
184
|
-
setup(__props) {
|
|
185
|
-
const props = __props;
|
|
186
|
-
const {
|
|
187
|
-
control,
|
|
188
|
-
handleChange: _handleChange,
|
|
189
|
-
appliedOptions,
|
|
190
|
-
onFocus,
|
|
191
|
-
onBlur,
|
|
192
|
-
controlWrapper
|
|
193
|
-
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
194
|
-
const bindProperties = computed(() => ({
|
|
195
|
-
...controlWrapper.value,
|
|
196
|
-
...appliedOptions.value,
|
|
197
|
-
enableCreate: !!appliedOptions.value.enableCreate
|
|
198
|
-
}));
|
|
199
|
-
const fetchOptions = computed(() => {
|
|
200
|
-
const options = appliedOptions.value;
|
|
201
|
-
if (!options.uri) return null;
|
|
202
|
-
return (searchTerm, signal) => {
|
|
203
|
-
const fetch = options.skipAuth ? axios : useApi();
|
|
204
|
-
return fetch.get(`${options.uri}${searchTerm}`, { signal }).then((data) => data.data[options.dataField ?? "data"]);
|
|
205
|
-
};
|
|
206
|
-
});
|
|
207
|
-
const handleChange = (result) => {
|
|
208
|
-
const { path } = control.value;
|
|
209
|
-
_handleChange(path, result);
|
|
52
|
+
const _hoisted_1$8 = { class: "" };
|
|
53
|
+
const _hoisted_2$2 = { class: "flex gap-2 items-center mb-2" };
|
|
54
|
+
const _hoisted_3$1 = { class: "flex gap-2" };
|
|
55
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
56
|
+
__name: "table-filter",
|
|
57
|
+
props: {
|
|
58
|
+
layout: {},
|
|
59
|
+
filters: {}
|
|
60
|
+
},
|
|
61
|
+
emits: ["changeFilters", "removeFilter"],
|
|
62
|
+
setup(__props, { emit: __emit }) {
|
|
63
|
+
const formData = ref();
|
|
64
|
+
const properties = __props;
|
|
65
|
+
const emits = __emit;
|
|
66
|
+
watch(
|
|
67
|
+
() => properties.filters,
|
|
68
|
+
() => {
|
|
69
|
+
formData.value = {};
|
|
70
|
+
properties.filters.forEach((filter) => {
|
|
71
|
+
formData.value[filter.key] = filter.value;
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
{ immediate: true }
|
|
75
|
+
);
|
|
76
|
+
const onResetFilters = () => {
|
|
77
|
+
emits("changeFilters", {});
|
|
210
78
|
};
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
event: "create",
|
|
215
|
-
type: control.value.path,
|
|
216
|
-
data: control.value.data,
|
|
217
|
-
onSuccess: (result) => {
|
|
218
|
-
handleChange(result);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
79
|
+
const removeFilter = (filter) => {
|
|
80
|
+
formData.value[filter.key] = void 0;
|
|
81
|
+
emits("changeFilters", formData.value);
|
|
221
82
|
};
|
|
222
83
|
return (_ctx, _cache) => {
|
|
223
|
-
return openBlock(),
|
|
224
|
-
"
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
84
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
85
|
+
createElementVNode("div", _hoisted_2$2, [
|
|
86
|
+
__props.filters.length ? (openBlock(), createBlock(unref(Btn), {
|
|
87
|
+
key: 0,
|
|
88
|
+
size: "xs",
|
|
89
|
+
outline: true,
|
|
90
|
+
onClick: onResetFilters
|
|
91
|
+
}, {
|
|
92
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
93
|
+
createTextVNode(" Reset all filters ", -1)
|
|
94
|
+
])]),
|
|
95
|
+
_: 1
|
|
96
|
+
})) : createCommentVNode("", true)
|
|
97
|
+
]),
|
|
98
|
+
createElementVNode("div", _hoisted_3$1, [
|
|
99
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.filters, (filter) => {
|
|
100
|
+
return openBlock(), createBlock(unref(BtnBadge), {
|
|
101
|
+
key: filter.key,
|
|
102
|
+
icon: unref(IconEnum).Close,
|
|
103
|
+
onClick: ($event) => removeFilter(filter)
|
|
104
|
+
}, {
|
|
105
|
+
default: withCtx(() => [
|
|
106
|
+
createTextVNode(toDisplayString(filter.label) + ": " + toDisplayString(filter.value), 1)
|
|
107
|
+
]),
|
|
108
|
+
_: 2
|
|
109
|
+
}, 1032, ["icon", "onClick"]);
|
|
110
|
+
}), 128))
|
|
111
|
+
])
|
|
112
|
+
]);
|
|
232
113
|
};
|
|
233
114
|
}
|
|
234
115
|
});
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
116
|
+
const TableComponentProperties = {
|
|
117
|
+
id: { type: String, required: true },
|
|
118
|
+
uiSchema: { type: Object, required: true },
|
|
119
|
+
schema: { type: Object, required: true },
|
|
120
|
+
filterUiSchema: { type: Object },
|
|
121
|
+
filterSchema: { type: Object },
|
|
122
|
+
uri: { type: String, required: true },
|
|
123
|
+
reload: { type: Number },
|
|
124
|
+
actions: { type: Array }
|
|
125
|
+
};
|
|
126
|
+
const TableComponentEmits = ["delete", "edit"];
|
|
127
|
+
class TableStore {
|
|
128
|
+
constructor() {
|
|
129
|
+
this.route = useRoute();
|
|
130
|
+
this.router = useRouter();
|
|
131
|
+
this.requestData = ref(RequestSchema.parse(this.route.query));
|
|
132
|
+
this._reload = ref(Date.now());
|
|
133
|
+
this.loading = ref(true);
|
|
134
|
+
this.uri = ref("");
|
|
135
|
+
this.data = computedAsync(async () => {
|
|
136
|
+
this._reload.value;
|
|
137
|
+
if (!this.uri.value) return null;
|
|
138
|
+
this.loading.value = true;
|
|
139
|
+
if (this.requestData.value.page < 1) {
|
|
140
|
+
this.requestData.value.page = 1;
|
|
141
|
+
}
|
|
142
|
+
const response = await useApi().get(this.uri.value, {
|
|
143
|
+
params: this.requestData.value
|
|
144
|
+
}).catch((error2) => {
|
|
145
|
+
console.error(error2);
|
|
146
|
+
return { data: [], request: { totalPages: 1, page: 1 } };
|
|
147
|
+
}).finally(() => this.loading.value = false);
|
|
148
|
+
const data = response.data;
|
|
149
|
+
if (data.request.totalPages < data.request.page) {
|
|
150
|
+
this.updateRequest({ page: data.request.totalPages });
|
|
250
151
|
}
|
|
251
|
-
return
|
|
152
|
+
return data;
|
|
153
|
+
});
|
|
154
|
+
this.pageData = computed(() => {
|
|
155
|
+
const request = this.data.value?.request ?? {
|
|
156
|
+
count: 0,
|
|
157
|
+
pageSize: 1,
|
|
158
|
+
page: 1
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
count: request.count,
|
|
162
|
+
pageSize: request.pageSize,
|
|
163
|
+
page: request.page
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
this.tableData = computed(() => {
|
|
167
|
+
const d = this.data.value;
|
|
168
|
+
if (!d) return [];
|
|
169
|
+
if (this.loading.value) return [];
|
|
170
|
+
return d.data ?? [];
|
|
252
171
|
});
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
_handleChange(path, result);
|
|
172
|
+
this.init = (url2) => {
|
|
173
|
+
this.uri.value = url2;
|
|
256
174
|
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}), null, 16, ["model-value", "enabled", "config", "onFocus", "onBlur"]);
|
|
175
|
+
this.updateRequest = (data) => {
|
|
176
|
+
this.requestData.value = { ...this.requestData.value, ...data };
|
|
177
|
+
this.router.replace({
|
|
178
|
+
query: {
|
|
179
|
+
...this.route.query,
|
|
180
|
+
...this.requestData.value
|
|
181
|
+
}
|
|
182
|
+
});
|
|
266
183
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
__name: "IntegerControlRenderer",
|
|
271
|
-
props: { ...rendererProps() },
|
|
272
|
-
setup(__props) {
|
|
273
|
-
const props = __props;
|
|
274
|
-
const { control, onChange, appliedOptions, onFocus, onBlur, controlWrapper } = useVanillaControlCustom(
|
|
275
|
-
useJsonFormsControl(props),
|
|
276
|
-
(target) => target.value === "" ? void 0 : Number(target.value)
|
|
277
|
-
);
|
|
278
|
-
const steps = computed(() => appliedOptions.value.steps ?? 1);
|
|
279
|
-
return (_ctx, _cache) => {
|
|
280
|
-
return openBlock(), createBlock(unref(InputNumber), mergeProps(unref(controlWrapper), {
|
|
281
|
-
"model-value": unref(control).data,
|
|
282
|
-
enabled: unref(control).enabled,
|
|
283
|
-
config: unref(appliedOptions),
|
|
284
|
-
steps: steps.value,
|
|
285
|
-
onChange: unref(onChange),
|
|
286
|
-
onFocus: unref(onFocus),
|
|
287
|
-
onBlur: unref(onBlur)
|
|
288
|
-
}), null, 16, ["model-value", "enabled", "config", "steps", "onChange", "onFocus", "onBlur"]);
|
|
184
|
+
this.sort = (id) => {
|
|
185
|
+
const sortDir = this.requestData.value.sort === id && this.requestData.value.sortDir === "asc" ? "desc" : "asc";
|
|
186
|
+
this.updateRequest({ sort: id, sortDir });
|
|
289
187
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
control,
|
|
299
|
-
handleChange,
|
|
300
|
-
appliedOptions,
|
|
301
|
-
onFocus,
|
|
302
|
-
onBlur,
|
|
303
|
-
controlWrapper
|
|
304
|
-
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
305
|
-
const changeValue = (value) => {
|
|
306
|
-
handleChange(control.value.path, value);
|
|
307
|
-
};
|
|
308
|
-
return (_ctx, _cache) => {
|
|
309
|
-
return openBlock(), createBlock(unref(Markdown), mergeProps(unref(controlWrapper), {
|
|
310
|
-
"model-value": unref(control).data,
|
|
311
|
-
enabled: unref(control).enabled,
|
|
312
|
-
config: unref(appliedOptions),
|
|
313
|
-
onChange: changeValue,
|
|
314
|
-
onFocus: unref(onFocus),
|
|
315
|
-
onBlur: unref(onBlur)
|
|
316
|
-
}), null, 16, ["model-value", "enabled", "config", "onFocus", "onBlur"]);
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
321
|
-
__name: "MultiSelectControlRender",
|
|
322
|
-
props: { ...rendererProps() },
|
|
323
|
-
setup(__props) {
|
|
324
|
-
const props = __props;
|
|
325
|
-
const {
|
|
326
|
-
control,
|
|
327
|
-
handleChange: _handleChange,
|
|
328
|
-
onFocus,
|
|
329
|
-
onBlur,
|
|
330
|
-
controlWrapper
|
|
331
|
-
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
332
|
-
const handleChange = (result) => {
|
|
333
|
-
const { path } = control.value;
|
|
334
|
-
_handleChange(path, result);
|
|
335
|
-
};
|
|
336
|
-
return (_ctx, _cache) => {
|
|
337
|
-
return openBlock(), createBlock(unref(MultiSelect), mergeProps(unref(controlWrapper), {
|
|
338
|
-
"model-value": unref(control).data,
|
|
339
|
-
enabled: unref(control).enabled,
|
|
340
|
-
onChange: handleChange,
|
|
341
|
-
onFocus: unref(onFocus),
|
|
342
|
-
onBlur: unref(onBlur)
|
|
343
|
-
}), null, 16, ["model-value", "enabled", "onFocus", "onBlur"]);
|
|
188
|
+
this.updateFilters = (filters) => {
|
|
189
|
+
const filter = [];
|
|
190
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
191
|
+
if (!value) return;
|
|
192
|
+
const operator = value?.operator || "contains";
|
|
193
|
+
filter.push(`${key}:${value}:${operator}`);
|
|
194
|
+
});
|
|
195
|
+
this.updateRequest({ filter });
|
|
344
196
|
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
(target) => target.value === "" ? void 0 : Number(target.value)
|
|
197
|
+
this.sorting = computed(() => {
|
|
198
|
+
const requestData = this.requestData.value;
|
|
199
|
+
return {
|
|
200
|
+
sortColumn: requestData.sort,
|
|
201
|
+
sortDirection: requestData.sortDir ?? "asc"
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
this.filters = computed(
|
|
205
|
+
() => extractFilters(this.requestData.value.filter)
|
|
355
206
|
);
|
|
356
|
-
const steps = computed(() => appliedOptions.value.steps ?? 0.01);
|
|
357
|
-
return (_ctx, _cache) => {
|
|
358
|
-
return openBlock(), createBlock(unref(InputNumber), mergeProps(unref(controlWrapper), {
|
|
359
|
-
"model-value": unref(control).data,
|
|
360
|
-
enabled: unref(control).enabled,
|
|
361
|
-
config: unref(appliedOptions),
|
|
362
|
-
steps: steps.value,
|
|
363
|
-
onChange: unref(onChange),
|
|
364
|
-
onFocus: unref(onFocus),
|
|
365
|
-
onBlur: unref(onBlur)
|
|
366
|
-
}), null, 16, ["model-value", "enabled", "config", "steps", "onChange", "onFocus", "onBlur"]);
|
|
367
|
-
};
|
|
368
207
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
__name: "SelectControlRender",
|
|
372
|
-
props: { ...rendererProps() },
|
|
373
|
-
setup(__props) {
|
|
374
|
-
const props = __props;
|
|
375
|
-
const {
|
|
376
|
-
control,
|
|
377
|
-
handleChange: _handleChange,
|
|
378
|
-
appliedOptions,
|
|
379
|
-
onFocus,
|
|
380
|
-
onBlur,
|
|
381
|
-
controlWrapper
|
|
382
|
-
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
383
|
-
const handleChange = (result) => {
|
|
384
|
-
const { path } = control.value;
|
|
385
|
-
_handleChange(path, result);
|
|
386
|
-
};
|
|
387
|
-
return (_ctx, _cache) => {
|
|
388
|
-
return openBlock(), createBlock(unref(SelectComponent), mergeProps(unref(controlWrapper), {
|
|
389
|
-
"model-value": unref(control).data,
|
|
390
|
-
enabled: unref(control).enabled,
|
|
391
|
-
options: unref(appliedOptions)?.options,
|
|
392
|
-
onChange: handleChange,
|
|
393
|
-
onFocus: unref(onFocus),
|
|
394
|
-
onBlur: unref(onBlur)
|
|
395
|
-
}), null, 16, ["model-value", "enabled", "options", "onFocus", "onBlur"]);
|
|
396
|
-
};
|
|
208
|
+
get httpRequest() {
|
|
209
|
+
return useApi();
|
|
397
210
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
__name: "StringControlRenderer",
|
|
401
|
-
props: { ...rendererProps() },
|
|
402
|
-
setup(__props) {
|
|
403
|
-
const props = __props;
|
|
404
|
-
const {
|
|
405
|
-
control,
|
|
406
|
-
onChange,
|
|
407
|
-
appliedOptions,
|
|
408
|
-
onFocus,
|
|
409
|
-
onBlur,
|
|
410
|
-
controlWrapper,
|
|
411
|
-
styles
|
|
412
|
-
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
413
|
-
return (_ctx, _cache) => {
|
|
414
|
-
return openBlock(), createBlock(unref(Input), mergeProps(unref(controlWrapper), {
|
|
415
|
-
"model-value": unref(control).data,
|
|
416
|
-
enabled: unref(control).enabled,
|
|
417
|
-
config: unref(appliedOptions),
|
|
418
|
-
styles: unref(styles),
|
|
419
|
-
onChange: unref(onChange),
|
|
420
|
-
onFocus: unref(onFocus),
|
|
421
|
-
onBlur: unref(onBlur)
|
|
422
|
-
}), null, 16, ["model-value", "enabled", "config", "styles", "onChange", "onFocus", "onBlur"]);
|
|
423
|
-
};
|
|
211
|
+
reload() {
|
|
212
|
+
this._reload.value = Date.now();
|
|
424
213
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
__name: "TextAreaControlRenderer",
|
|
428
|
-
props: { ...rendererProps() },
|
|
429
|
-
setup(__props) {
|
|
430
|
-
const props = __props;
|
|
431
|
-
const { control, onChange, appliedOptions, onFocus, onBlur, controlWrapper } = useVanillaControlCustom(useJsonFormsControl(props));
|
|
432
|
-
return (_ctx, _cache) => {
|
|
433
|
-
return openBlock(), createBlock(unref(Textarea), mergeProps(unref(controlWrapper), {
|
|
434
|
-
"model-value": unref(control).data,
|
|
435
|
-
enabled: unref(control).enabled,
|
|
436
|
-
config: unref(appliedOptions),
|
|
437
|
-
onChange: unref(onChange),
|
|
438
|
-
onFocus: unref(onFocus),
|
|
439
|
-
onBlur: unref(onBlur)
|
|
440
|
-
}), null, 16, ["model-value", "enabled", "config", "onChange", "onFocus", "onBlur"]);
|
|
441
|
-
};
|
|
214
|
+
updatePage(page) {
|
|
215
|
+
this.updateRequest({ page });
|
|
442
216
|
}
|
|
443
|
-
}
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
);
|
|
452
|
-
|
|
453
|
-
uiTypeIs("Control"),
|
|
454
|
-
or(optionIs("format", ControlType.string), schemaTypeIs("string"))
|
|
455
|
-
);
|
|
456
|
-
const isMarkdownControl = and(
|
|
457
|
-
uiTypeIs("Control"),
|
|
458
|
-
optionIs("format", ControlType.markdown)
|
|
459
|
-
);
|
|
460
|
-
const isArrayRenderer = and(
|
|
461
|
-
schemaTypeIs("array")
|
|
462
|
-
// optionIs('format', ControlType.array),
|
|
463
|
-
);
|
|
464
|
-
const isCustomControl = (customType) => {
|
|
465
|
-
return and(
|
|
466
|
-
optionIs("format", ControlType.custom),
|
|
467
|
-
optionIs("type", customType)
|
|
468
|
-
);
|
|
217
|
+
}
|
|
218
|
+
const tableCache = /* @__PURE__ */ new Map();
|
|
219
|
+
const useTableStore = (name) => {
|
|
220
|
+
const tableStore = tableCache.get(name);
|
|
221
|
+
if (tableStore) {
|
|
222
|
+
return tableStore;
|
|
223
|
+
}
|
|
224
|
+
const newTableStore = new TableStore();
|
|
225
|
+
tableCache.set(name, newTableStore);
|
|
226
|
+
return newTableStore;
|
|
469
227
|
};
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
);
|
|
474
|
-
const isSelectControl = and(
|
|
475
|
-
uiTypeIs("Control"),
|
|
476
|
-
optionIs("format", ControlType.select)
|
|
477
|
-
);
|
|
478
|
-
const isBooleanControl = or(
|
|
479
|
-
isBooleanControl$1,
|
|
480
|
-
and(uiTypeIs("Control"), optionIs("format", ControlType.boolean))
|
|
481
|
-
);
|
|
482
|
-
const controlRenderers = [
|
|
483
|
-
// First custom renderers on format
|
|
484
|
-
{
|
|
485
|
-
tester: rankWith(10, isMarkdownControl),
|
|
486
|
-
renderer: _sfc_main$g
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
tester: rankWith(10, isAutoCompleteControl),
|
|
490
|
-
renderer: _sfc_main$j
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
tester: rankWith(10, isTextAreaControl),
|
|
494
|
-
renderer: _sfc_main$b
|
|
495
|
-
},
|
|
496
|
-
// Renderers based on type if no format is provided
|
|
497
|
-
{ tester: rankWith(10, isStringFormat), renderer: _sfc_main$c },
|
|
498
|
-
{ tester: rankWith(10, isSelectControl), renderer: _sfc_main$d },
|
|
499
|
-
{
|
|
500
|
-
tester: rankWith(10, isMultiselectControl),
|
|
501
|
-
renderer: _sfc_main$f
|
|
502
|
-
},
|
|
503
|
-
{ tester: rankWith(10, isNumberControl), renderer: _sfc_main$e },
|
|
504
|
-
{
|
|
505
|
-
tester: rankWith(10, isIntegerControl),
|
|
506
|
-
renderer: _sfc_main$h
|
|
507
|
-
},
|
|
508
|
-
{ tester: rankWith(10, isBooleanControl), renderer: _sfc_main$i }
|
|
509
|
-
];
|
|
510
|
-
const _hoisted_1$9 = ["title"];
|
|
511
|
-
const _hoisted_2$2 = { key: 0 };
|
|
512
|
-
const _hoisted_3$1 = {
|
|
513
|
-
key: 1,
|
|
514
|
-
class: "list-row"
|
|
228
|
+
const _hoisted_1$7 = {
|
|
229
|
+
key: 0,
|
|
230
|
+
class: "mb-2"
|
|
515
231
|
};
|
|
516
|
-
const _sfc_main$
|
|
517
|
-
__name: "
|
|
518
|
-
props:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
232
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
233
|
+
__name: "table.component",
|
|
234
|
+
props: TableComponentProperties,
|
|
235
|
+
emits: TableComponentEmits,
|
|
236
|
+
setup(__props, { emit: __emit }) {
|
|
237
|
+
const properties = __props;
|
|
238
|
+
const emit = __emit;
|
|
239
|
+
watch(
|
|
240
|
+
() => properties.reload,
|
|
241
|
+
() => {
|
|
242
|
+
store.reload();
|
|
243
|
+
}
|
|
523
244
|
);
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const noData = computed(
|
|
532
|
-
() => !control.value.data || control.value.data.length === 0
|
|
245
|
+
let store = useTableStore(properties.id);
|
|
246
|
+
watch(
|
|
247
|
+
() => properties.uri,
|
|
248
|
+
() => {
|
|
249
|
+
store.init(properties.uri);
|
|
250
|
+
},
|
|
251
|
+
{ immediate: true }
|
|
533
252
|
);
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
253
|
+
const edit = (data) => {
|
|
254
|
+
emit("edit", data);
|
|
255
|
+
};
|
|
256
|
+
const deleteFn = (data) => {
|
|
257
|
+
emit("delete", data);
|
|
258
|
+
};
|
|
259
|
+
const components = {
|
|
260
|
+
TextCell,
|
|
261
|
+
BooleanCell
|
|
262
|
+
};
|
|
263
|
+
const displayColumns = computed(() => {
|
|
264
|
+
return properties.uiSchema.elements.map((e) => {
|
|
265
|
+
const element = e;
|
|
266
|
+
const def = findColumnDef(element, properties.schema);
|
|
267
|
+
const type = isArray(def.type) ? def.type[0] : def.type;
|
|
268
|
+
let component;
|
|
269
|
+
if (element.options?.format && element.options.format in components) {
|
|
270
|
+
component = components[element.options.format];
|
|
271
|
+
} else {
|
|
272
|
+
component = components[element.type];
|
|
273
|
+
}
|
|
274
|
+
if (!component) console.warn("No component found for type", element.type);
|
|
275
|
+
return {
|
|
276
|
+
...def,
|
|
277
|
+
type,
|
|
278
|
+
component
|
|
279
|
+
};
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
const onChangeFilters = (filters) => {
|
|
283
|
+
store.updateFilters(filters);
|
|
284
|
+
};
|
|
285
|
+
const onUpdatePage = (page) => {
|
|
286
|
+
store.updatePage(page);
|
|
537
287
|
};
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
control.value.path,
|
|
541
|
-
createDefaultValue(control.value.schema, control.value.rootSchema)
|
|
542
|
-
)();
|
|
288
|
+
const onSort = (id) => {
|
|
289
|
+
store.sort(id);
|
|
543
290
|
};
|
|
544
|
-
const
|
|
545
|
-
return
|
|
291
|
+
const sort = computed(() => {
|
|
292
|
+
return store.sorting.value ?? { orderBy: "", ascending: 1 };
|
|
546
293
|
});
|
|
547
294
|
return (_ctx, _cache) => {
|
|
548
|
-
return openBlock(), createElementBlock("div",
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
uischema: unref(childUiSchema),
|
|
572
|
-
path: unref(composePaths)(unref(control).path, `${index}`),
|
|
573
|
-
enabled: unref(control).enabled,
|
|
574
|
-
renderers: unref(control).renderers,
|
|
575
|
-
cells: unref(control).cells
|
|
576
|
-
}, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"])
|
|
577
|
-
]),
|
|
578
|
-
showActions.value ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
|
|
579
|
-
showDelete.value ? (openBlock(), createBlock(unref(Btn), {
|
|
580
|
-
key: 0,
|
|
581
|
-
icon: unref(IconEnum).Delete,
|
|
582
|
-
outline: true,
|
|
583
|
-
onClick: ($event) => deleteButtonClick(index)
|
|
584
|
-
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
585
|
-
])) : createCommentVNode("", true)
|
|
586
|
-
], 2)
|
|
587
|
-
]);
|
|
588
|
-
}), 128)),
|
|
589
|
-
noData.value ? (openBlock(), createElementBlock("div", {
|
|
590
|
-
key: 0,
|
|
591
|
-
class: normalizeClass(["list-row", unref(styles).arrayList.noData])
|
|
592
|
-
}, " No data ", 2)) : createCommentVNode("", true),
|
|
593
|
-
showActions.value ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
594
|
-
createVNode(unref(Btn), {
|
|
595
|
-
icon: unref(IconEnum).Plus,
|
|
596
|
-
outline: true,
|
|
597
|
-
onClick: addButtonClick
|
|
598
|
-
}, {
|
|
599
|
-
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
600
|
-
createTextVNode(" Add ", -1)
|
|
601
|
-
])]),
|
|
602
|
-
_: 1
|
|
603
|
-
}, 8, ["icon"])
|
|
604
|
-
])) : createCommentVNode("", true)
|
|
605
|
-
], 2)
|
|
606
|
-
], 8, _hoisted_1$9);
|
|
295
|
+
return openBlock(), createElementBlock("div", null, [
|
|
296
|
+
_ctx.filterUiSchema && _ctx.filterSchema ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
297
|
+
createVNode(_sfc_main$h, {
|
|
298
|
+
layout: { uiSchema: _ctx.filterUiSchema, schema: _ctx.filterSchema },
|
|
299
|
+
filters: unref(store).filters.value,
|
|
300
|
+
onChangeFilters
|
|
301
|
+
}, null, 8, ["layout", "filters"])
|
|
302
|
+
])) : createCommentVNode("", true),
|
|
303
|
+
createElementVNode("div", null, [
|
|
304
|
+
createVNode(unref(Table), {
|
|
305
|
+
"display-columns": displayColumns.value,
|
|
306
|
+
sort: sort.value,
|
|
307
|
+
page: unref(store).pageData.value,
|
|
308
|
+
loading: unref(store).loading.value,
|
|
309
|
+
data: unref(store).tableData.value,
|
|
310
|
+
actions: _ctx.actions,
|
|
311
|
+
onUpdatePage,
|
|
312
|
+
onDelete: deleteFn,
|
|
313
|
+
onEdit: edit,
|
|
314
|
+
onSort
|
|
315
|
+
}, null, 8, ["display-columns", "sort", "page", "loading", "data", "actions"])
|
|
316
|
+
])
|
|
317
|
+
]);
|
|
607
318
|
};
|
|
608
319
|
}
|
|
609
320
|
});
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
return (_ctx, _cache) => {
|
|
631
|
-
return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
|
|
632
|
-
default: withCtx(() => [
|
|
633
|
-
createElementVNode("div", _hoisted_1$8, [
|
|
634
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
635
|
-
return openBlock(), createBlock(unref(DispatchRenderer), {
|
|
636
|
-
key: index,
|
|
637
|
-
schema: unref(layout).schema,
|
|
638
|
-
uischema: element,
|
|
639
|
-
path: unref(layout).path,
|
|
640
|
-
renderers: unref(renderers),
|
|
641
|
-
cells: unref(cells)
|
|
642
|
-
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
|
|
643
|
-
}), 128))
|
|
644
|
-
])
|
|
645
|
-
]),
|
|
646
|
-
_: 1
|
|
647
|
-
}, 8, ["title"]);
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
const _hoisted_1$7 = {
|
|
652
|
-
class: "grid gap-4 items-center",
|
|
653
|
-
style: { "grid-template-columns": "repeat(12, 1fr)" }
|
|
654
|
-
};
|
|
655
|
-
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
656
|
-
__name: "GridLayout",
|
|
657
|
-
props: { ...rendererProps() },
|
|
658
|
-
setup(__props) {
|
|
659
|
-
const props = __props;
|
|
660
|
-
const { layout, renderers, cells } = useJsonFormsLayout(props);
|
|
661
|
-
return (_ctx, _cache) => {
|
|
662
|
-
return openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
663
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
664
|
-
return openBlock(), createElementBlock("div", {
|
|
665
|
-
key: index,
|
|
666
|
-
style: normalizeStyle({
|
|
667
|
-
"grid-column": `span ${element.options?.colspan ?? 12}`
|
|
668
|
-
})
|
|
669
|
-
}, [
|
|
670
|
-
createVNode(unref(DispatchRenderer), {
|
|
671
|
-
schema: unref(layout).schema,
|
|
672
|
-
uischema: element,
|
|
673
|
-
path: unref(layout).path,
|
|
674
|
-
renderers: unref(renderers),
|
|
675
|
-
cells: unref(cells)
|
|
676
|
-
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"])
|
|
677
|
-
], 4);
|
|
678
|
-
}), 128))
|
|
679
|
-
]);
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
const _hoisted_1$6 = { class: "flex flex-row gap-4 items-center" };
|
|
684
|
-
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
685
|
-
__name: "HorizontalLayout",
|
|
686
|
-
props: { ...rendererProps() },
|
|
687
|
-
setup(__props) {
|
|
688
|
-
const props = __props;
|
|
689
|
-
const { layout, renderers, cells } = useJsonFormsLayout(props);
|
|
690
|
-
return (_ctx, _cache) => {
|
|
691
|
-
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
692
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
693
|
-
return openBlock(), createBlock(unref(DispatchRenderer), {
|
|
694
|
-
key: index,
|
|
695
|
-
schema: unref(layout).schema,
|
|
696
|
-
uischema: element,
|
|
697
|
-
path: unref(layout).path,
|
|
698
|
-
renderers: unref(renderers),
|
|
699
|
-
cells: unref(cells)
|
|
700
|
-
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
|
|
701
|
-
}), 128))
|
|
702
|
-
]);
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
const _hoisted_1$5 = { class: "flex flex-col gap-4" };
|
|
707
|
-
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
708
|
-
__name: "VerticalLayout",
|
|
709
|
-
props: { ...rendererProps() },
|
|
710
|
-
setup(__props) {
|
|
711
|
-
const props = __props;
|
|
712
|
-
const { layout, renderers, cells } = useJsonFormsLayout(props);
|
|
713
|
-
return (_ctx, _cache) => {
|
|
714
|
-
return openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
715
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
716
|
-
return openBlock(), createBlock(unref(DispatchRenderer), {
|
|
717
|
-
key: index,
|
|
718
|
-
schema: unref(layout).schema,
|
|
719
|
-
uischema: element,
|
|
720
|
-
path: unref(layout).path,
|
|
721
|
-
renderers: unref(renderers),
|
|
722
|
-
cells: unref(cells)
|
|
723
|
-
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
|
|
724
|
-
}), 128))
|
|
725
|
-
]);
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
const layoutRenderers = [
|
|
730
|
-
{
|
|
731
|
-
tester: rankWith(10, uiTypeIs(LayoutTypes.VerticalLayout)),
|
|
732
|
-
renderer: _sfc_main$6
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
tester: rankWith(10, uiTypeIs(LayoutTypes.HorizontalLayout)),
|
|
736
|
-
renderer: _sfc_main$7
|
|
737
|
-
},
|
|
738
|
-
{
|
|
739
|
-
tester: rankWith(10, uiTypeIs(LayoutTypes.CollapseLayout)),
|
|
740
|
-
renderer: _sfc_main$9
|
|
741
|
-
},
|
|
742
|
-
{
|
|
743
|
-
tester: rankWith(10, uiTypeIs(LayoutTypes.GridLayout)),
|
|
744
|
-
renderer: _sfc_main$8
|
|
745
|
-
}
|
|
746
|
-
];
|
|
747
|
-
const _hoisted_1$4 = { class: "" };
|
|
748
|
-
const _hoisted_2$1 = { class: "flex gap-2 items-center mb-2" };
|
|
749
|
-
const _hoisted_3 = { class: "flex gap-2" };
|
|
750
|
-
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
751
|
-
__name: "table-filter",
|
|
752
|
-
props: {
|
|
753
|
-
layout: {},
|
|
754
|
-
filters: {}
|
|
755
|
-
},
|
|
756
|
-
emits: ["changeFilters", "removeFilter"],
|
|
757
|
-
setup(__props, { emit: __emit }) {
|
|
758
|
-
const formData = ref();
|
|
759
|
-
const properties = __props;
|
|
760
|
-
const emits = __emit;
|
|
761
|
-
watch(
|
|
762
|
-
() => properties.filters,
|
|
763
|
-
() => {
|
|
764
|
-
formData.value = {};
|
|
765
|
-
properties.filters.forEach((filter) => {
|
|
766
|
-
formData.value[filter.key] = filter.value;
|
|
767
|
-
});
|
|
768
|
-
},
|
|
769
|
-
{ immediate: true }
|
|
770
|
-
);
|
|
771
|
-
const onResetFilters = () => {
|
|
772
|
-
emits("changeFilters", {});
|
|
773
|
-
};
|
|
774
|
-
const removeFilter = (filter) => {
|
|
775
|
-
formData.value[filter.key] = void 0;
|
|
776
|
-
emits("changeFilters", formData.value);
|
|
777
|
-
};
|
|
778
|
-
return (_ctx, _cache) => {
|
|
779
|
-
return openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
780
|
-
createElementVNode("div", _hoisted_2$1, [
|
|
781
|
-
__props.filters.length ? (openBlock(), createBlock(unref(Btn), {
|
|
782
|
-
key: 0,
|
|
783
|
-
size: "xs",
|
|
784
|
-
outline: true,
|
|
785
|
-
onClick: onResetFilters
|
|
786
|
-
}, {
|
|
787
|
-
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
788
|
-
createTextVNode(" Reset all filters ", -1)
|
|
789
|
-
])]),
|
|
790
|
-
_: 1
|
|
791
|
-
})) : createCommentVNode("", true)
|
|
792
|
-
]),
|
|
793
|
-
createElementVNode("div", _hoisted_3, [
|
|
794
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.filters, (filter) => {
|
|
795
|
-
return openBlock(), createBlock(unref(BtnBadge), {
|
|
796
|
-
key: filter.key,
|
|
797
|
-
icon: unref(IconEnum).Close,
|
|
798
|
-
onClick: ($event) => removeFilter(filter)
|
|
799
|
-
}, {
|
|
800
|
-
default: withCtx(() => [
|
|
801
|
-
createTextVNode(toDisplayString(filter.label) + ": " + toDisplayString(filter.value), 1)
|
|
802
|
-
]),
|
|
803
|
-
_: 2
|
|
804
|
-
}, 1032, ["icon", "onClick"]);
|
|
805
|
-
}), 128))
|
|
806
|
-
])
|
|
807
|
-
]);
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
const TableComponentProperties = {
|
|
812
|
-
id: { type: String, required: true },
|
|
813
|
-
uiSchema: { type: Object, required: true },
|
|
814
|
-
schema: { type: Object, required: true },
|
|
815
|
-
filterUiSchema: { type: Object },
|
|
816
|
-
filterSchema: { type: Object },
|
|
817
|
-
uri: { type: String, required: true },
|
|
818
|
-
reload: { type: Number },
|
|
819
|
-
actions: { type: Array }
|
|
820
|
-
};
|
|
821
|
-
const TableComponentEmits = ["delete", "edit"];
|
|
822
|
-
class TableStore {
|
|
823
|
-
constructor() {
|
|
824
|
-
this.route = useRoute();
|
|
825
|
-
this.router = useRouter();
|
|
826
|
-
this.requestData = ref(RequestSchema.parse(this.route.query));
|
|
827
|
-
this._reload = ref(Date.now());
|
|
828
|
-
this.loading = ref(true);
|
|
829
|
-
this.uri = ref("");
|
|
830
|
-
this.data = computedAsync(async () => {
|
|
831
|
-
this._reload.value;
|
|
832
|
-
if (!this.uri.value) return null;
|
|
833
|
-
this.loading.value = true;
|
|
834
|
-
if (this.requestData.value.page < 1) {
|
|
835
|
-
this.requestData.value.page = 1;
|
|
836
|
-
}
|
|
837
|
-
const response = await useApi().get(this.uri.value, {
|
|
838
|
-
params: this.requestData.value
|
|
839
|
-
}).catch((error2) => {
|
|
840
|
-
console.error(error2);
|
|
841
|
-
return { data: [], request: { totalPages: 1, page: 1 } };
|
|
842
|
-
}).finally(() => this.loading.value = false);
|
|
843
|
-
const data = response.data;
|
|
844
|
-
if (data.request.totalPages < data.request.page) {
|
|
845
|
-
this.updateRequest({ page: data.request.totalPages });
|
|
846
|
-
}
|
|
847
|
-
return data;
|
|
848
|
-
});
|
|
849
|
-
this.pageData = computed(() => {
|
|
850
|
-
const request = this.data.value?.request ?? {
|
|
851
|
-
count: 0,
|
|
852
|
-
pageSize: 1,
|
|
853
|
-
page: 1
|
|
854
|
-
};
|
|
855
|
-
return {
|
|
856
|
-
count: request.count,
|
|
857
|
-
pageSize: request.pageSize,
|
|
858
|
-
page: request.page
|
|
859
|
-
};
|
|
860
|
-
});
|
|
861
|
-
this.tableData = computed(() => {
|
|
862
|
-
const d = this.data.value;
|
|
863
|
-
if (!d) return [];
|
|
864
|
-
if (this.loading.value) return [];
|
|
865
|
-
return d.data ?? [];
|
|
321
|
+
const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
322
|
+
const notificationEntity = options.notification?.entityType || "entity";
|
|
323
|
+
const notificationStore = options.notification?.notification ?? null;
|
|
324
|
+
const getDataUri = (...suffix) => {
|
|
325
|
+
return [formSchemaModel.uri, ...suffix].join("/");
|
|
326
|
+
};
|
|
327
|
+
const handleSuccess = (message) => {
|
|
328
|
+
notificationStore?.success(message);
|
|
329
|
+
};
|
|
330
|
+
const handleError = (error2, message) => {
|
|
331
|
+
console.error(error2);
|
|
332
|
+
notificationStore?.error(message);
|
|
333
|
+
throw new Error(error2);
|
|
334
|
+
};
|
|
335
|
+
const create = (object2, options2) => {
|
|
336
|
+
return httpRequest.post(getDataUri(), object2, options2).then((response) => {
|
|
337
|
+
handleSuccess(`Created ${notificationEntity}`);
|
|
338
|
+
return response.data;
|
|
339
|
+
}).catch((response) => {
|
|
340
|
+
handleError(response, `Failed to create ${notificationEntity}`);
|
|
866
341
|
});
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
...this.route.query,
|
|
875
|
-
...this.requestData.value
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
};
|
|
879
|
-
this.sort = (id) => {
|
|
880
|
-
const sortDir = this.requestData.value.sort === id && this.requestData.value.sortDir === "asc" ? "desc" : "asc";
|
|
881
|
-
this.updateRequest({ sort: id, sortDir });
|
|
882
|
-
};
|
|
883
|
-
this.updateFilters = (filters) => {
|
|
884
|
-
const filter = [];
|
|
885
|
-
Object.entries(filters).forEach(([key, value]) => {
|
|
886
|
-
if (!value) return;
|
|
887
|
-
const operator = value?.operator || "contains";
|
|
888
|
-
filter.push(`${key}:${value}:${operator}`);
|
|
889
|
-
});
|
|
890
|
-
this.updateRequest({ filter });
|
|
891
|
-
};
|
|
892
|
-
this.sorting = computed(() => {
|
|
893
|
-
const requestData = this.requestData.value;
|
|
894
|
-
return {
|
|
895
|
-
sortColumn: requestData.sort,
|
|
896
|
-
sortDirection: requestData.sortDir ?? "asc"
|
|
897
|
-
};
|
|
342
|
+
};
|
|
343
|
+
const patch = (id, object2, options2) => {
|
|
344
|
+
return httpRequest.patch(getDataUri(id), object2, options2).then((response) => {
|
|
345
|
+
handleSuccess(`Saved ${notificationEntity}`);
|
|
346
|
+
return response.data;
|
|
347
|
+
}).catch((response) => {
|
|
348
|
+
handleError(response, `Failed to save ${notificationEntity}`);
|
|
898
349
|
});
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
)
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
reload() {
|
|
907
|
-
this._reload.value = Date.now();
|
|
908
|
-
}
|
|
909
|
-
updatePage(page) {
|
|
910
|
-
this.updateRequest({ page });
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
const tableCache = /* @__PURE__ */ new Map();
|
|
914
|
-
const useTableStore = (name) => {
|
|
915
|
-
const tableStore = tableCache.get(name);
|
|
916
|
-
if (tableStore) {
|
|
917
|
-
return tableStore;
|
|
918
|
-
}
|
|
919
|
-
const newTableStore = new TableStore();
|
|
920
|
-
tableCache.set(name, newTableStore);
|
|
921
|
-
return newTableStore;
|
|
922
|
-
};
|
|
923
|
-
const _hoisted_1$3 = {
|
|
924
|
-
key: 0,
|
|
925
|
-
class: "mb-2"
|
|
926
|
-
};
|
|
927
|
-
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
928
|
-
__name: "table.component",
|
|
929
|
-
props: TableComponentProperties,
|
|
930
|
-
emits: TableComponentEmits,
|
|
931
|
-
setup(__props, { emit: __emit }) {
|
|
932
|
-
const properties = __props;
|
|
933
|
-
const emit = __emit;
|
|
934
|
-
watch(
|
|
935
|
-
() => properties.reload,
|
|
936
|
-
() => {
|
|
937
|
-
store.reload();
|
|
938
|
-
}
|
|
939
|
-
);
|
|
940
|
-
let store = useTableStore(properties.id);
|
|
941
|
-
watch(
|
|
942
|
-
() => properties.uri,
|
|
943
|
-
() => {
|
|
944
|
-
store.init(properties.uri);
|
|
945
|
-
},
|
|
946
|
-
{ immediate: true }
|
|
947
|
-
);
|
|
948
|
-
const edit = (data) => {
|
|
949
|
-
emit("edit", data);
|
|
950
|
-
};
|
|
951
|
-
const deleteFn = (data) => {
|
|
952
|
-
emit("delete", data);
|
|
953
|
-
};
|
|
954
|
-
const components = {
|
|
955
|
-
TextCell
|
|
956
|
-
};
|
|
957
|
-
const displayColumns = computed(() => {
|
|
958
|
-
return properties.uiSchema.elements.map((e) => {
|
|
959
|
-
const element = e;
|
|
960
|
-
const def = findColumnDef(element, properties.schema);
|
|
961
|
-
const type = isArray(def.type) ? def.type[0] : def.type;
|
|
962
|
-
let component;
|
|
963
|
-
if (element.options?.format && element.options.format in components) {
|
|
964
|
-
component = components[element.options.format];
|
|
965
|
-
} else {
|
|
966
|
-
component = components[element.type];
|
|
967
|
-
}
|
|
968
|
-
if (!component) console.warn("No component found for type", element.type);
|
|
969
|
-
return {
|
|
970
|
-
...def,
|
|
971
|
-
type,
|
|
972
|
-
component
|
|
973
|
-
};
|
|
974
|
-
});
|
|
350
|
+
};
|
|
351
|
+
const get = (id, options2) => {
|
|
352
|
+
return httpRequest.get(getDataUri(id), options2).then((response) => {
|
|
353
|
+
return response.data;
|
|
354
|
+
}).catch((response) => {
|
|
355
|
+
handleError(response, `Failed to load data`);
|
|
975
356
|
});
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
store.sort(id);
|
|
984
|
-
};
|
|
985
|
-
const sort = computed(() => {
|
|
986
|
-
return store.sorting.value ?? { orderBy: "", ascending: 1 };
|
|
357
|
+
};
|
|
358
|
+
const _delete = (id, options2) => {
|
|
359
|
+
return httpRequest.delete(getDataUri(id), options2).then((response) => {
|
|
360
|
+
handleSuccess(`${notificationEntity} deleted`);
|
|
361
|
+
return response;
|
|
362
|
+
}).catch((response) => {
|
|
363
|
+
handleError(response, `Failed to delete ${notificationEntity}`);
|
|
987
364
|
});
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
createElementVNode("div", null, [
|
|
998
|
-
createVNode(unref(Table), {
|
|
999
|
-
"display-columns": displayColumns.value,
|
|
1000
|
-
sort: sort.value,
|
|
1001
|
-
page: unref(store).pageData.value,
|
|
1002
|
-
loading: unref(store).loading.value,
|
|
1003
|
-
data: unref(store).tableData.value,
|
|
1004
|
-
actions: _ctx.actions,
|
|
1005
|
-
onUpdatePage,
|
|
1006
|
-
onDelete: deleteFn,
|
|
1007
|
-
onEdit: edit,
|
|
1008
|
-
onSort
|
|
1009
|
-
}, null, 8, ["display-columns", "sort", "page", "loading", "data", "actions"])
|
|
1010
|
-
])
|
|
1011
|
-
]);
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
const _hoisted_1$2 = { class: "flex justify-between items-center mb-2" };
|
|
1016
|
-
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1017
|
-
__name: "form-with-table.component",
|
|
1018
|
-
props: FormWithTableProperties,
|
|
1019
|
-
emits: FormWithTableEmits,
|
|
1020
|
-
setup(__props, { emit: __emit }) {
|
|
1021
|
-
const properties = __props;
|
|
1022
|
-
const emit = __emit;
|
|
1023
|
-
const reload = ref(0);
|
|
1024
|
-
const resolvedForm = computed(() => properties.form);
|
|
1025
|
-
const resolvedTable = computed(() => properties.table);
|
|
1026
|
-
const resolvedFilter = computed(() => properties.filter);
|
|
1027
|
-
const resolvedUri = computed(() => properties.uri);
|
|
1028
|
-
let store = new FormStore(resolvedUri.value ?? "");
|
|
1029
|
-
watch(resolvedUri, (uri) => {
|
|
1030
|
-
store = new FormStore(uri ?? "");
|
|
365
|
+
};
|
|
366
|
+
const createMulti = (objects, options2) => {
|
|
367
|
+
return Promise.all(
|
|
368
|
+
objects.map((object2) => httpRequest.post(getDataUri(), object2, options2))
|
|
369
|
+
).then((response) => {
|
|
370
|
+
handleSuccess(`Created ${notificationEntity}`);
|
|
371
|
+
return response.data;
|
|
372
|
+
}).catch((response) => {
|
|
373
|
+
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1031
374
|
});
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
emit("custom:edit", data);
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
if (hasEdit) {
|
|
1041
|
-
emit("editData", data);
|
|
1042
|
-
return;
|
|
1043
|
-
}
|
|
1044
|
-
openModal(data);
|
|
1045
|
-
};
|
|
1046
|
-
const create = () => {
|
|
1047
|
-
if (customCreate) {
|
|
1048
|
-
emit("custom:create");
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
openModal();
|
|
1052
|
-
};
|
|
1053
|
-
const deleteFn = (data) => {
|
|
1054
|
-
ModalService.showConfirm({
|
|
1055
|
-
title: "Delete record",
|
|
1056
|
-
message: "Are you sure to delete, the data will be lost?",
|
|
1057
|
-
onClose: (result) => {
|
|
1058
|
-
if (result.confirmed) {
|
|
1059
|
-
store.delete(data).then(() => {
|
|
1060
|
-
reload.value = Date.now();
|
|
1061
|
-
emit("delete", data);
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
};
|
|
1067
|
-
const openModal = (formData) => {
|
|
1068
|
-
if (!resolvedForm.value) return;
|
|
1069
|
-
const isUpdate = !!formData?.id;
|
|
1070
|
-
FormModalService.openModal({
|
|
1071
|
-
schema: resolvedForm.value.schema,
|
|
1072
|
-
uiSchema: resolvedForm.value.uiSchema,
|
|
1073
|
-
modalSize: resolvedForm.value.modalSize,
|
|
1074
|
-
initialData: formData ?? properties.initialData,
|
|
1075
|
-
modalTitle: (isUpdate ? properties.updateTitle ?? properties.createTitle : properties.createTitle) ?? "",
|
|
1076
|
-
onClose: (result) => {
|
|
1077
|
-
if (result && result.valid) {
|
|
1078
|
-
store.save(formData?.id, result.data).then(() => {
|
|
1079
|
-
reload.value = Date.now();
|
|
1080
|
-
emit("save", { id: formData?.id, data: result.data });
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
},
|
|
1084
|
-
onEvents: (payload) => emit("events", payload)
|
|
1085
|
-
});
|
|
1086
|
-
};
|
|
1087
|
-
return (_ctx, _cache) => {
|
|
1088
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
1089
|
-
createElementVNode("div", _hoisted_1$2, [
|
|
1090
|
-
createElementVNode("h1", null, toDisplayString(_ctx.tableTitle), 1),
|
|
1091
|
-
createElementVNode("div", null, [
|
|
1092
|
-
createVNode(unref(Btn), {
|
|
1093
|
-
icon: unref(IconEnum).Plus,
|
|
1094
|
-
outline: true,
|
|
1095
|
-
onClick: create
|
|
1096
|
-
}, {
|
|
1097
|
-
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
1098
|
-
createTextVNode(" Add new record ", -1)
|
|
1099
|
-
])]),
|
|
1100
|
-
_: 1
|
|
1101
|
-
}, 8, ["icon"])
|
|
1102
|
-
])
|
|
1103
|
-
]),
|
|
1104
|
-
resolvedTable.value ? (openBlock(), createBlock(unref(Card), { key: 0 }, {
|
|
1105
|
-
default: withCtx(() => [
|
|
1106
|
-
resolvedUri.value ? (openBlock(), createBlock(unref(_sfc_main$4), {
|
|
1107
|
-
key: 0,
|
|
1108
|
-
id: `form_table_${_ctx.id}`,
|
|
1109
|
-
"ui-schema": resolvedTable.value.uiSchema,
|
|
1110
|
-
schema: resolvedTable.value.schema,
|
|
1111
|
-
"filter-ui-schema": resolvedFilter.value?.uiSchema,
|
|
1112
|
-
"filter-schema": resolvedFilter.value?.schema,
|
|
1113
|
-
uri: _ctx.dataUri ?? resolvedUri.value,
|
|
1114
|
-
reload: reload.value,
|
|
1115
|
-
actions: _ctx.tableActions,
|
|
1116
|
-
onEdit: edit,
|
|
1117
|
-
onDelete: deleteFn
|
|
1118
|
-
}, null, 8, ["id", "ui-schema", "schema", "filter-ui-schema", "filter-schema", "uri", "reload", "actions"])) : createCommentVNode("", true)
|
|
1119
|
-
]),
|
|
1120
|
-
_: 1
|
|
1121
|
-
})) : createCommentVNode("", true)
|
|
1122
|
-
], 64);
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
375
|
+
};
|
|
376
|
+
return { create, patch, createMulti, delete: _delete, get };
|
|
377
|
+
};
|
|
378
|
+
const createFormEvents = (dispatch) => ({
|
|
379
|
+
dispatch
|
|
1125
380
|
});
|
|
381
|
+
const FORM_EVENTS_KEY = /* @__PURE__ */ Symbol("json-forms:events");
|
|
382
|
+
const provideFormEvents = (dispatch) => {
|
|
383
|
+
const events = createFormEvents(dispatch);
|
|
384
|
+
provide(FORM_EVENTS_KEY, events);
|
|
385
|
+
return events;
|
|
386
|
+
};
|
|
387
|
+
const useFormEvents = () => {
|
|
388
|
+
return inject(
|
|
389
|
+
FORM_EVENTS_KEY,
|
|
390
|
+
createFormEvents(() => {
|
|
391
|
+
})
|
|
392
|
+
);
|
|
393
|
+
};
|
|
1126
394
|
function $constructor(name, initializer2, params) {
|
|
1127
395
|
function init(inst, def) {
|
|
1128
396
|
if (!inst._zod) {
|
|
@@ -1657,7 +925,7 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
|
|
|
1657
925
|
}
|
|
1658
926
|
return { formErrors, fieldErrors };
|
|
1659
927
|
}
|
|
1660
|
-
function formatError(error2, mapper = (issue2) => issue2.message) {
|
|
928
|
+
function formatError$1(error2, mapper = (issue2) => issue2.message) {
|
|
1661
929
|
const fieldErrors = { _errors: [] };
|
|
1662
930
|
const processError = (error3) => {
|
|
1663
931
|
for (const issue2 of error3.issues) {
|
|
@@ -3110,11 +2378,11 @@ const $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
3110
2378
|
return payload;
|
|
3111
2379
|
};
|
|
3112
2380
|
});
|
|
3113
|
-
function handleArrayResult(result, final,
|
|
2381
|
+
function handleArrayResult(result, final, index2) {
|
|
3114
2382
|
if (result.issues.length) {
|
|
3115
|
-
final.issues.push(...prefixIssues(
|
|
2383
|
+
final.issues.push(...prefixIssues(index2, result.issues));
|
|
3116
2384
|
}
|
|
3117
|
-
final.value[
|
|
2385
|
+
final.value[index2] = result.value;
|
|
3118
2386
|
}
|
|
3119
2387
|
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
3120
2388
|
$ZodType.init(inst, def);
|
|
@@ -3605,14 +2873,14 @@ function mergeValues(a, b) {
|
|
|
3605
2873
|
return { valid: false, mergeErrorPath: [] };
|
|
3606
2874
|
}
|
|
3607
2875
|
const newArray = [];
|
|
3608
|
-
for (let
|
|
3609
|
-
const itemA = a[
|
|
3610
|
-
const itemB = b[
|
|
2876
|
+
for (let index2 = 0; index2 < a.length; index2++) {
|
|
2877
|
+
const itemA = a[index2];
|
|
2878
|
+
const itemB = b[index2];
|
|
3611
2879
|
const sharedValue = mergeValues(itemA, itemB);
|
|
3612
2880
|
if (!sharedValue.valid) {
|
|
3613
2881
|
return {
|
|
3614
2882
|
valid: false,
|
|
3615
|
-
mergeErrorPath: [
|
|
2883
|
+
mergeErrorPath: [index2, ...sharedValue.mergeErrorPath]
|
|
3616
2884
|
};
|
|
3617
2885
|
}
|
|
3618
2886
|
newArray.push(sharedValue.data);
|
|
@@ -3728,11 +2996,11 @@ const $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3728
2996
|
return payload;
|
|
3729
2997
|
};
|
|
3730
2998
|
});
|
|
3731
|
-
function handleTupleResult(result, final,
|
|
2999
|
+
function handleTupleResult(result, final, index2) {
|
|
3732
3000
|
if (result.issues.length) {
|
|
3733
|
-
final.issues.push(...prefixIssues(
|
|
3001
|
+
final.issues.push(...prefixIssues(index2, result.issues));
|
|
3734
3002
|
}
|
|
3735
|
-
final.value[
|
|
3003
|
+
final.value[index2] = result.value;
|
|
3736
3004
|
}
|
|
3737
3005
|
const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
3738
3006
|
$ZodType.init(inst, def);
|
|
@@ -6330,7 +5598,7 @@ const initializer = (inst, issues) => {
|
|
|
6330
5598
|
inst.name = "ZodError";
|
|
6331
5599
|
Object.defineProperties(inst, {
|
|
6332
5600
|
format: {
|
|
6333
|
-
value: (mapper) => formatError(inst, mapper)
|
|
5601
|
+
value: (mapper) => formatError$1(inst, mapper)
|
|
6334
5602
|
// enumerable: false,
|
|
6335
5603
|
},
|
|
6336
5604
|
flatten: {
|
|
@@ -7892,302 +7160,1402 @@ function convertBaseSchema(schema, ctx) {
|
|
|
7892
7160
|
if (typeof schema.multipleOf === "number") {
|
|
7893
7161
|
numberSchema = numberSchema.multipleOf(schema.multipleOf);
|
|
7894
7162
|
}
|
|
7895
|
-
zodSchema = numberSchema;
|
|
7163
|
+
zodSchema = numberSchema;
|
|
7164
|
+
break;
|
|
7165
|
+
}
|
|
7166
|
+
case "boolean": {
|
|
7167
|
+
zodSchema = z.boolean();
|
|
7168
|
+
break;
|
|
7169
|
+
}
|
|
7170
|
+
case "null": {
|
|
7171
|
+
zodSchema = z.null();
|
|
7172
|
+
break;
|
|
7173
|
+
}
|
|
7174
|
+
case "object": {
|
|
7175
|
+
const shape = {};
|
|
7176
|
+
const properties = schema.properties || {};
|
|
7177
|
+
const requiredSet = new Set(schema.required || []);
|
|
7178
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
7179
|
+
const propZodSchema = convertSchema(propSchema, ctx);
|
|
7180
|
+
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
7181
|
+
}
|
|
7182
|
+
if (schema.propertyNames) {
|
|
7183
|
+
const keySchema = convertSchema(schema.propertyNames, ctx);
|
|
7184
|
+
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
|
|
7185
|
+
if (Object.keys(shape).length === 0) {
|
|
7186
|
+
zodSchema = z.record(keySchema, valueSchema);
|
|
7187
|
+
break;
|
|
7188
|
+
}
|
|
7189
|
+
const objectSchema2 = z.object(shape).passthrough();
|
|
7190
|
+
const recordSchema = z.looseRecord(keySchema, valueSchema);
|
|
7191
|
+
zodSchema = z.intersection(objectSchema2, recordSchema);
|
|
7192
|
+
break;
|
|
7193
|
+
}
|
|
7194
|
+
if (schema.patternProperties) {
|
|
7195
|
+
const patternProps = schema.patternProperties;
|
|
7196
|
+
const patternKeys = Object.keys(patternProps);
|
|
7197
|
+
const looseRecords = [];
|
|
7198
|
+
for (const pattern of patternKeys) {
|
|
7199
|
+
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
7200
|
+
const keySchema = z.string().regex(new RegExp(pattern));
|
|
7201
|
+
looseRecords.push(z.looseRecord(keySchema, patternValue));
|
|
7202
|
+
}
|
|
7203
|
+
const schemasToIntersect = [];
|
|
7204
|
+
if (Object.keys(shape).length > 0) {
|
|
7205
|
+
schemasToIntersect.push(z.object(shape).passthrough());
|
|
7206
|
+
}
|
|
7207
|
+
schemasToIntersect.push(...looseRecords);
|
|
7208
|
+
if (schemasToIntersect.length === 0) {
|
|
7209
|
+
zodSchema = z.object({}).passthrough();
|
|
7210
|
+
} else if (schemasToIntersect.length === 1) {
|
|
7211
|
+
zodSchema = schemasToIntersect[0];
|
|
7212
|
+
} else {
|
|
7213
|
+
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
7214
|
+
for (let i = 2; i < schemasToIntersect.length; i++) {
|
|
7215
|
+
result = z.intersection(result, schemasToIntersect[i]);
|
|
7216
|
+
}
|
|
7217
|
+
zodSchema = result;
|
|
7218
|
+
}
|
|
7219
|
+
break;
|
|
7220
|
+
}
|
|
7221
|
+
const objectSchema = z.object(shape);
|
|
7222
|
+
if (schema.additionalProperties === false) {
|
|
7223
|
+
zodSchema = objectSchema.strict();
|
|
7224
|
+
} else if (typeof schema.additionalProperties === "object") {
|
|
7225
|
+
zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
|
|
7226
|
+
} else {
|
|
7227
|
+
zodSchema = objectSchema.passthrough();
|
|
7228
|
+
}
|
|
7229
|
+
break;
|
|
7230
|
+
}
|
|
7231
|
+
case "array": {
|
|
7232
|
+
const prefixItems = schema.prefixItems;
|
|
7233
|
+
const items = schema.items;
|
|
7234
|
+
if (prefixItems && Array.isArray(prefixItems)) {
|
|
7235
|
+
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
7236
|
+
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
|
|
7237
|
+
if (rest) {
|
|
7238
|
+
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
7239
|
+
} else {
|
|
7240
|
+
zodSchema = z.tuple(tupleItems);
|
|
7241
|
+
}
|
|
7242
|
+
if (typeof schema.minItems === "number") {
|
|
7243
|
+
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
7244
|
+
}
|
|
7245
|
+
if (typeof schema.maxItems === "number") {
|
|
7246
|
+
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
7247
|
+
}
|
|
7248
|
+
} else if (Array.isArray(items)) {
|
|
7249
|
+
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
7250
|
+
const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
|
|
7251
|
+
if (rest) {
|
|
7252
|
+
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
7253
|
+
} else {
|
|
7254
|
+
zodSchema = z.tuple(tupleItems);
|
|
7255
|
+
}
|
|
7256
|
+
if (typeof schema.minItems === "number") {
|
|
7257
|
+
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
7258
|
+
}
|
|
7259
|
+
if (typeof schema.maxItems === "number") {
|
|
7260
|
+
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
7261
|
+
}
|
|
7262
|
+
} else if (items !== void 0) {
|
|
7263
|
+
const element = convertSchema(items, ctx);
|
|
7264
|
+
let arraySchema = z.array(element);
|
|
7265
|
+
if (typeof schema.minItems === "number") {
|
|
7266
|
+
arraySchema = arraySchema.min(schema.minItems);
|
|
7267
|
+
}
|
|
7268
|
+
if (typeof schema.maxItems === "number") {
|
|
7269
|
+
arraySchema = arraySchema.max(schema.maxItems);
|
|
7270
|
+
}
|
|
7271
|
+
zodSchema = arraySchema;
|
|
7272
|
+
} else {
|
|
7273
|
+
zodSchema = z.array(z.any());
|
|
7274
|
+
}
|
|
7896
7275
|
break;
|
|
7897
7276
|
}
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7277
|
+
default:
|
|
7278
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
7279
|
+
}
|
|
7280
|
+
if (schema.description) {
|
|
7281
|
+
zodSchema = zodSchema.describe(schema.description);
|
|
7282
|
+
}
|
|
7283
|
+
if (schema.default !== void 0) {
|
|
7284
|
+
zodSchema = zodSchema.default(schema.default);
|
|
7285
|
+
}
|
|
7286
|
+
return zodSchema;
|
|
7287
|
+
}
|
|
7288
|
+
function convertSchema(schema, ctx) {
|
|
7289
|
+
if (typeof schema === "boolean") {
|
|
7290
|
+
return schema ? z.any() : z.never();
|
|
7291
|
+
}
|
|
7292
|
+
let baseSchema = convertBaseSchema(schema, ctx);
|
|
7293
|
+
const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
|
|
7294
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
7295
|
+
const options = schema.anyOf.map((s) => convertSchema(s, ctx));
|
|
7296
|
+
const anyOfUnion = z.union(options);
|
|
7297
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
7298
|
+
}
|
|
7299
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
7300
|
+
const options = schema.oneOf.map((s) => convertSchema(s, ctx));
|
|
7301
|
+
const oneOfUnion = z.xor(options);
|
|
7302
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
7303
|
+
}
|
|
7304
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
7305
|
+
if (schema.allOf.length === 0) {
|
|
7306
|
+
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
7307
|
+
} else {
|
|
7308
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
7309
|
+
const startIdx = hasExplicitType ? 0 : 1;
|
|
7310
|
+
for (let i = startIdx; i < schema.allOf.length; i++) {
|
|
7311
|
+
result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
|
|
7312
|
+
}
|
|
7313
|
+
baseSchema = result;
|
|
7901
7314
|
}
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7315
|
+
}
|
|
7316
|
+
if (schema.nullable === true && ctx.version === "openapi-3.0") {
|
|
7317
|
+
baseSchema = z.nullable(baseSchema);
|
|
7318
|
+
}
|
|
7319
|
+
if (schema.readOnly === true) {
|
|
7320
|
+
baseSchema = z.readonly(baseSchema);
|
|
7321
|
+
}
|
|
7322
|
+
const extraMeta = {};
|
|
7323
|
+
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
7324
|
+
for (const key of coreMetadataKeys) {
|
|
7325
|
+
if (key in schema) {
|
|
7326
|
+
extraMeta[key] = schema[key];
|
|
7905
7327
|
}
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7328
|
+
}
|
|
7329
|
+
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
7330
|
+
for (const key of contentMetadataKeys) {
|
|
7331
|
+
if (key in schema) {
|
|
7332
|
+
extraMeta[key] = schema[key];
|
|
7333
|
+
}
|
|
7334
|
+
}
|
|
7335
|
+
for (const key of Object.keys(schema)) {
|
|
7336
|
+
if (!RECOGNIZED_KEYS.has(key)) {
|
|
7337
|
+
extraMeta[key] = schema[key];
|
|
7338
|
+
}
|
|
7339
|
+
}
|
|
7340
|
+
if (Object.keys(extraMeta).length > 0) {
|
|
7341
|
+
ctx.registry.add(baseSchema, extraMeta);
|
|
7342
|
+
}
|
|
7343
|
+
return baseSchema;
|
|
7344
|
+
}
|
|
7345
|
+
function fromJSONSchema(schema, params) {
|
|
7346
|
+
if (typeof schema === "boolean") {
|
|
7347
|
+
return schema ? z.any() : z.never();
|
|
7348
|
+
}
|
|
7349
|
+
const version2 = detectVersion(schema);
|
|
7350
|
+
const defs = schema.$defs || schema.definitions || {};
|
|
7351
|
+
const ctx = {
|
|
7352
|
+
version: version2,
|
|
7353
|
+
defs,
|
|
7354
|
+
refs: /* @__PURE__ */ new Map(),
|
|
7355
|
+
processing: /* @__PURE__ */ new Set(),
|
|
7356
|
+
rootSchema: schema,
|
|
7357
|
+
registry: globalRegistry
|
|
7358
|
+
};
|
|
7359
|
+
return convertSchema(schema, ctx);
|
|
7360
|
+
}
|
|
7361
|
+
config(en());
|
|
7362
|
+
const errorPatterns = [
|
|
7363
|
+
[/^Invalid input: expected \w+, received undefined$/, "This field is required"],
|
|
7364
|
+
[/^Invalid input: expected \w+, received null$/, "This field is required"],
|
|
7365
|
+
[/^Expected string, received/, "Invalid value"],
|
|
7366
|
+
[/^String must contain at least (\d+)/, "Must be at least $1 characters"],
|
|
7367
|
+
[/^Number must be greater than or equal to (\d+)/, "Minimum value is $1"],
|
|
7368
|
+
[/^Number must be less than or equal to (\d+)/, "Maximum value is $1"]
|
|
7369
|
+
];
|
|
7370
|
+
const formatError = (message) => {
|
|
7371
|
+
if (!message) return void 0;
|
|
7372
|
+
for (const [pattern, replacement] of errorPatterns) {
|
|
7373
|
+
if (pattern.test(message)) {
|
|
7374
|
+
return message.replace(pattern, replacement);
|
|
7375
|
+
}
|
|
7376
|
+
}
|
|
7377
|
+
return message;
|
|
7378
|
+
};
|
|
7379
|
+
const registerZodErrorMap = () => {
|
|
7380
|
+
config({
|
|
7381
|
+
customError: (issue2) => {
|
|
7382
|
+
if (issue2.code === "invalid_type" && issue2.received === "undefined") {
|
|
7383
|
+
return { message: "This field is required" };
|
|
7913
7384
|
}
|
|
7914
|
-
if (
|
|
7915
|
-
|
|
7916
|
-
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
|
|
7917
|
-
if (Object.keys(shape).length === 0) {
|
|
7918
|
-
zodSchema = z.record(keySchema, valueSchema);
|
|
7919
|
-
break;
|
|
7920
|
-
}
|
|
7921
|
-
const objectSchema2 = z.object(shape).passthrough();
|
|
7922
|
-
const recordSchema = z.looseRecord(keySchema, valueSchema);
|
|
7923
|
-
zodSchema = z.intersection(objectSchema2, recordSchema);
|
|
7924
|
-
break;
|
|
7385
|
+
if (issue2.code === "invalid_type" && issue2.received === "null") {
|
|
7386
|
+
return { message: "This field is required" };
|
|
7925
7387
|
}
|
|
7926
|
-
if (
|
|
7927
|
-
const
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
for (const pattern of patternKeys) {
|
|
7931
|
-
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
7932
|
-
const keySchema = z.string().regex(new RegExp(pattern));
|
|
7933
|
-
looseRecords.push(z.looseRecord(keySchema, patternValue));
|
|
7388
|
+
if (issue2.code === "too_small") {
|
|
7389
|
+
const i = issue2;
|
|
7390
|
+
if (i.type === "string" && i.minimum === 1) {
|
|
7391
|
+
return { message: "This field is required" };
|
|
7934
7392
|
}
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
schemasToIntersect.push(z.object(shape).passthrough());
|
|
7393
|
+
if (i.type === "string") {
|
|
7394
|
+
return { message: `Must be at least ${i.minimum} characters` };
|
|
7938
7395
|
}
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
} else {
|
|
7945
|
-
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
7946
|
-
for (let i = 2; i < schemasToIntersect.length; i++) {
|
|
7947
|
-
result = z.intersection(result, schemasToIntersect[i]);
|
|
7948
|
-
}
|
|
7949
|
-
zodSchema = result;
|
|
7396
|
+
}
|
|
7397
|
+
if (issue2.code === "too_big") {
|
|
7398
|
+
const i = issue2;
|
|
7399
|
+
if (i.type === "string") {
|
|
7400
|
+
return { message: `Must be at most ${i.maximum} characters` };
|
|
7950
7401
|
}
|
|
7951
|
-
break;
|
|
7952
7402
|
}
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7403
|
+
return { message: issue2.message };
|
|
7404
|
+
}
|
|
7405
|
+
});
|
|
7406
|
+
};
|
|
7407
|
+
function findRenderer(registry2, uischema, schema) {
|
|
7408
|
+
let best = null;
|
|
7409
|
+
for (const entry of registry2) {
|
|
7410
|
+
const rank = entry.tester(uischema, schema);
|
|
7411
|
+
if (rank > -1 && (!best || rank > best.rank)) {
|
|
7412
|
+
best = { rank, renderer: entry.renderer };
|
|
7413
|
+
}
|
|
7414
|
+
}
|
|
7415
|
+
return best?.renderer ?? null;
|
|
7416
|
+
}
|
|
7417
|
+
const scopeToPath = (scope) => {
|
|
7418
|
+
if (!scope) return "";
|
|
7419
|
+
return scope.replace(/^#\//, "").split("/").filter((s) => s !== "properties").join(".");
|
|
7420
|
+
};
|
|
7421
|
+
const resolveSchema = (root, scope) => {
|
|
7422
|
+
const segments = scope.replace(/^#\//, "").split("/").filter(Boolean);
|
|
7423
|
+
return segments.reduce((acc, key) => acc?.[key], root);
|
|
7424
|
+
};
|
|
7425
|
+
const _hoisted_1$6 = {
|
|
7426
|
+
key: 1,
|
|
7427
|
+
class: "text-error text-xs"
|
|
7428
|
+
};
|
|
7429
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
7430
|
+
__name: "Dispatch",
|
|
7431
|
+
props: {
|
|
7432
|
+
uischema: {},
|
|
7433
|
+
schema: {},
|
|
7434
|
+
pathPrefix: { default: void 0 }
|
|
7435
|
+
},
|
|
7436
|
+
setup(__props) {
|
|
7437
|
+
const props = __props;
|
|
7438
|
+
const registry2 = inject("renderers");
|
|
7439
|
+
const rootSchema = inject("rootSchema");
|
|
7440
|
+
const parentPrefix = inject("pathPrefix", "");
|
|
7441
|
+
const effectivePrefix = props.pathPrefix ?? parentPrefix;
|
|
7442
|
+
if (props.pathPrefix !== void 0) {
|
|
7443
|
+
provide("pathPrefix", effectivePrefix);
|
|
7444
|
+
}
|
|
7445
|
+
const resolved = computed(() => {
|
|
7446
|
+
const u = props.uischema;
|
|
7447
|
+
if (!u.scope) return props.schema;
|
|
7448
|
+
const fromRoot = resolveSchema(rootSchema, u.scope);
|
|
7449
|
+
if (fromRoot) return fromRoot;
|
|
7450
|
+
return resolveSchema(props.schema, u.scope) ?? props.schema;
|
|
7451
|
+
});
|
|
7452
|
+
const renderer = computed(
|
|
7453
|
+
() => findRenderer(registry2, props.uischema, resolved.value)
|
|
7454
|
+
);
|
|
7455
|
+
return (_ctx, _cache) => {
|
|
7456
|
+
return renderer.value ? (openBlock(), createBlock(resolveDynamicComponent(renderer.value), {
|
|
7457
|
+
key: 0,
|
|
7458
|
+
uischema: __props.uischema,
|
|
7459
|
+
schema: resolved.value
|
|
7460
|
+
}, null, 8, ["uischema", "schema"])) : (openBlock(), createElementBlock("div", _hoisted_1$6, " No renderer for " + toDisplayString(__props.uischema.scope ?? __props.uischema.type), 1));
|
|
7461
|
+
};
|
|
7462
|
+
}
|
|
7463
|
+
});
|
|
7464
|
+
const JsonFormComponentProperties = {
|
|
7465
|
+
/** Unique identifier used to namespace the form element. */
|
|
7466
|
+
id: { type: String, required: true },
|
|
7467
|
+
/** HTML name attribute for the form. */
|
|
7468
|
+
name: { type: String, default: "form" },
|
|
7469
|
+
/** JSON schema describing the shape of the form data. */
|
|
7470
|
+
schema: { type: Object, required: true },
|
|
7471
|
+
/** UI schema describing the layout and controls. */
|
|
7472
|
+
uiSchema: { type: Object, required: true },
|
|
7473
|
+
/** Disable all form controls. */
|
|
7474
|
+
disabled: { type: Boolean, default: false },
|
|
7475
|
+
/** Current form data object. */
|
|
7476
|
+
formData: { type: Object, default: () => ({}) },
|
|
7477
|
+
/** When validation errors are shown (`'onBlur'`, `'onChange'`, `'onSubmit'`, `'always'`). */
|
|
7478
|
+
errorMode: {
|
|
7479
|
+
type: String,
|
|
7480
|
+
default: "onChanges"
|
|
7481
|
+
}
|
|
7482
|
+
};
|
|
7483
|
+
const JsonFormComponentEmits = [
|
|
7484
|
+
/** Emitted when form data changes. */
|
|
7485
|
+
"change",
|
|
7486
|
+
/** Emitted on form submission. */
|
|
7487
|
+
"submit",
|
|
7488
|
+
/** Emitted when validation errors change. */
|
|
7489
|
+
"errors",
|
|
7490
|
+
/** Emitted when form validity changes. */
|
|
7491
|
+
"valid",
|
|
7492
|
+
/** Emitted when a custom renderer dispatches a form event. */
|
|
7493
|
+
"events"
|
|
7494
|
+
];
|
|
7495
|
+
const ERROR_MODE_KEY = /* @__PURE__ */ Symbol("errorMode");
|
|
7496
|
+
const FORM_SUBMITTED_KEY = /* @__PURE__ */ Symbol("formSubmitted");
|
|
7497
|
+
const _hoisted_1$5 = { class: "flex-1" };
|
|
7498
|
+
const _hoisted_2$1 = { key: 0 };
|
|
7499
|
+
const _hoisted_3 = {
|
|
7500
|
+
key: 0,
|
|
7501
|
+
class: "text-sm text-base-content/50"
|
|
7502
|
+
};
|
|
7503
|
+
const _hoisted_4 = { key: 1 };
|
|
7504
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
7505
|
+
__name: "ArrayRenderer",
|
|
7506
|
+
props: {
|
|
7507
|
+
uischema: {},
|
|
7508
|
+
schema: {}
|
|
7509
|
+
},
|
|
7510
|
+
setup(__props) {
|
|
7511
|
+
const props = __props;
|
|
7512
|
+
const parentPrefix = inject("pathPrefix", "");
|
|
7513
|
+
const scope = props.uischema.scope;
|
|
7514
|
+
const scopePath = scopeToPath(scope);
|
|
7515
|
+
const path = parentPrefix ? `${parentPrefix}.${scopePath}` : scopePath;
|
|
7516
|
+
const rootSchema = inject("rootSchema");
|
|
7517
|
+
const arraySchema = resolveSchema(rootSchema, scope);
|
|
7518
|
+
const itemSchema = arraySchema?.items ?? {};
|
|
7519
|
+
const { fields, push, remove } = useFieldArray(path);
|
|
7520
|
+
if (fields.value.length === 0) {
|
|
7521
|
+
push({});
|
|
7522
|
+
}
|
|
7523
|
+
const opts = props.uischema.options ?? {};
|
|
7524
|
+
const layout = opts.layout ?? "column";
|
|
7525
|
+
const showActions = computed(() => !opts.hideActions);
|
|
7526
|
+
const detail = computed(
|
|
7527
|
+
() => props.uischema._detail ?? opts.detail
|
|
7528
|
+
);
|
|
7529
|
+
const childElements = computed(() => {
|
|
7530
|
+
if (!detail.value) {
|
|
7531
|
+
return props.uischema.elements ?? [];
|
|
7532
|
+
}
|
|
7533
|
+
const type = detail.value.type;
|
|
7534
|
+
if (type && type !== "Control") {
|
|
7535
|
+
return [detail.value];
|
|
7536
|
+
}
|
|
7537
|
+
return detail.value.elements ?? [detail.value];
|
|
7538
|
+
});
|
|
7539
|
+
return (_ctx, _cache) => {
|
|
7540
|
+
return openBlock(), createElementBlock("div", null, [
|
|
7541
|
+
createElementVNode("div", {
|
|
7542
|
+
class: normalizeClass([
|
|
7543
|
+
"flex gap-2",
|
|
7544
|
+
unref(layout) === "row" ? "flex-row items-center" : "flex-col"
|
|
7545
|
+
])
|
|
7546
|
+
}, [
|
|
7547
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(fields), (entry, index2) => {
|
|
7548
|
+
return openBlock(), createElementBlock("div", {
|
|
7549
|
+
key: entry.key,
|
|
7550
|
+
class: "flex-1"
|
|
7551
|
+
}, [
|
|
7552
|
+
createElementVNode("div", {
|
|
7553
|
+
class: normalizeClass([
|
|
7554
|
+
"flex gap-2",
|
|
7555
|
+
unref(layout) === "row" ? "flex-col" : "flex-row items-center"
|
|
7556
|
+
])
|
|
7557
|
+
}, [
|
|
7558
|
+
createElementVNode("div", _hoisted_1$5, [
|
|
7559
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(childElements.value, (child, ci) => {
|
|
7560
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
7561
|
+
key: ci,
|
|
7562
|
+
uischema: child,
|
|
7563
|
+
schema: unref(itemSchema),
|
|
7564
|
+
"path-prefix": `${unref(path)}[${index2}]`
|
|
7565
|
+
}, null, 8, ["uischema", "schema", "path-prefix"]);
|
|
7566
|
+
}), 128))
|
|
7567
|
+
]),
|
|
7568
|
+
showActions.value ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
|
|
7569
|
+
unref(fields).length > 1 ? (openBlock(), createBlock(unref(Btn), {
|
|
7570
|
+
key: 0,
|
|
7571
|
+
icon: unref(IconEnum).Delete,
|
|
7572
|
+
outline: true,
|
|
7573
|
+
onClick: ($event) => unref(remove)(index2)
|
|
7574
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
7575
|
+
])) : createCommentVNode("", true)
|
|
7576
|
+
], 2)
|
|
7577
|
+
]);
|
|
7578
|
+
}), 128)),
|
|
7579
|
+
unref(fields).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_3, " No data ")) : createCommentVNode("", true),
|
|
7580
|
+
showActions.value ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
7581
|
+
createVNode(unref(Btn), {
|
|
7582
|
+
icon: unref(IconEnum).Plus,
|
|
7583
|
+
outline: true,
|
|
7584
|
+
onClick: _cache[0] || (_cache[0] = ($event) => unref(push)({}))
|
|
7585
|
+
}, {
|
|
7586
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
7587
|
+
createTextVNode(" Add ", -1)
|
|
7588
|
+
])]),
|
|
7589
|
+
_: 1
|
|
7590
|
+
}, 8, ["icon"])
|
|
7591
|
+
])) : createCommentVNode("", true)
|
|
7592
|
+
], 2)
|
|
7593
|
+
]);
|
|
7594
|
+
};
|
|
7595
|
+
}
|
|
7596
|
+
});
|
|
7597
|
+
const isAutoCompleteControl = and(
|
|
7598
|
+
// uiTypeIs('Control'),
|
|
7599
|
+
optionIs("format", ControlType.autocomplete)
|
|
7600
|
+
);
|
|
7601
|
+
const isTextAreaControl = and(
|
|
7602
|
+
uiTypeIs("Control"),
|
|
7603
|
+
optionIs("format", ControlType.textArea)
|
|
7604
|
+
);
|
|
7605
|
+
const isStringFormat = and(
|
|
7606
|
+
uiTypeIs("Control"),
|
|
7607
|
+
or(optionIs("format", ControlType.string), schemaTypeIs("string"))
|
|
7608
|
+
);
|
|
7609
|
+
const isMarkdownControl = and(
|
|
7610
|
+
uiTypeIs("Control"),
|
|
7611
|
+
optionIs("format", ControlType.markdown)
|
|
7612
|
+
);
|
|
7613
|
+
const isArrayRenderer = and(
|
|
7614
|
+
schemaTypeIs("array")
|
|
7615
|
+
// optionIs('format', ControlType.array),
|
|
7616
|
+
);
|
|
7617
|
+
const isMultiselectControl = and(
|
|
7618
|
+
uiTypeIs("Control"),
|
|
7619
|
+
optionIs("format", ControlType.mutliSelect)
|
|
7620
|
+
);
|
|
7621
|
+
const isSelectControl = and(
|
|
7622
|
+
uiTypeIs("Control"),
|
|
7623
|
+
optionIs("format", ControlType.select)
|
|
7624
|
+
);
|
|
7625
|
+
const isBooleanControl = or(
|
|
7626
|
+
isBooleanControl$1,
|
|
7627
|
+
and(uiTypeIs("Control"), optionIs("format", ControlType.boolean))
|
|
7628
|
+
);
|
|
7629
|
+
const isNumberFormat = and(
|
|
7630
|
+
uiTypeIs("Control"),
|
|
7631
|
+
or(optionIs("format", ControlType.number), schemaTypeIs("number"))
|
|
7632
|
+
);
|
|
7633
|
+
const isIntegerFormat = and(
|
|
7634
|
+
uiTypeIs("Control"),
|
|
7635
|
+
or(optionIs("format", ControlType.integer), schemaTypeIs("integer"))
|
|
7636
|
+
);
|
|
7637
|
+
const arrayRenderers = [
|
|
7638
|
+
{ tester: rankWith(12, isArrayRenderer), renderer: _sfc_main$e }
|
|
7639
|
+
];
|
|
7640
|
+
const MethodSchema = _enum(["get", "post", "delete", "put", "patch"]);
|
|
7641
|
+
const OperationSchema = object({
|
|
7642
|
+
uri: string(),
|
|
7643
|
+
method: MethodSchema
|
|
7644
|
+
});
|
|
7645
|
+
const OperationsSchema = string().or(OperationSchema);
|
|
7646
|
+
const BooleanOperationSchema = boolean().or(OperationSchema).optional().default(false);
|
|
7647
|
+
const Operations = object({
|
|
7648
|
+
findAll: BooleanOperationSchema,
|
|
7649
|
+
findOne: BooleanOperationSchema,
|
|
7650
|
+
create: BooleanOperationSchema,
|
|
7651
|
+
update: BooleanOperationSchema,
|
|
7652
|
+
delete: BooleanOperationSchema,
|
|
7653
|
+
lookup: OperationsSchema.optional()
|
|
7654
|
+
});
|
|
7655
|
+
const OperationMap = {
|
|
7656
|
+
create: "post",
|
|
7657
|
+
delete: "delete",
|
|
7658
|
+
findAll: "get",
|
|
7659
|
+
findOne: "get",
|
|
7660
|
+
lookup: "get",
|
|
7661
|
+
update: "get"
|
|
7662
|
+
};
|
|
7663
|
+
const ResourceSchema = object({
|
|
7664
|
+
id: string(),
|
|
7665
|
+
uri: string(),
|
|
7666
|
+
operations: Operations,
|
|
7667
|
+
schema: object({
|
|
7668
|
+
ui: any().optional(),
|
|
7669
|
+
data: any()
|
|
7670
|
+
}).optional()
|
|
7671
|
+
}).transform((data) => {
|
|
7672
|
+
const schema = data.schema;
|
|
7673
|
+
if (schema) {
|
|
7674
|
+
if (!schema.ui) {
|
|
7675
|
+
schema.ui = uiFromJsonSchema(schema.data);
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
const operations = {};
|
|
7679
|
+
for (const k in OperationMap) {
|
|
7680
|
+
const key = k;
|
|
7681
|
+
const defaultOperation = OperationMap[key];
|
|
7682
|
+
const operation = data.operations[key];
|
|
7683
|
+
const mapResourceSchema = () => {
|
|
7684
|
+
if (isUndefined(operation) || operation === false) return null;
|
|
7685
|
+
if (operation === true)
|
|
7686
|
+
return { uri: data.uri, method: defaultOperation };
|
|
7687
|
+
if (typeof operation === "string")
|
|
7688
|
+
return { uri: operation, method: "get" };
|
|
7689
|
+
return {
|
|
7690
|
+
uri: operation.uri,
|
|
7691
|
+
method: operation.method ?? defaultOperation
|
|
7692
|
+
};
|
|
7693
|
+
};
|
|
7694
|
+
operations[key] = mapResourceSchema();
|
|
7695
|
+
}
|
|
7696
|
+
return {
|
|
7697
|
+
...data,
|
|
7698
|
+
schema,
|
|
7699
|
+
operations
|
|
7700
|
+
};
|
|
7701
|
+
});
|
|
7702
|
+
const getResourceSchema = async (resourceUri, skipAuth) => {
|
|
7703
|
+
const fetch = skipAuth ? axios : useApi();
|
|
7704
|
+
return fetch.get(resourceUri).then((response) => {
|
|
7705
|
+
const resource = ResourceSchema.safeParse(response.data);
|
|
7706
|
+
if (!resource.success)
|
|
7707
|
+
throw new Error(`Invalid resource schema: ${resource.error}`);
|
|
7708
|
+
return resource.data;
|
|
7709
|
+
});
|
|
7710
|
+
};
|
|
7711
|
+
const useRemoteOption = (options) => {
|
|
7712
|
+
return {
|
|
7713
|
+
fetchOptions: (searchTerm, signal) => {
|
|
7714
|
+
const fetch = options.skipAuth ? axios : useApi();
|
|
7715
|
+
return fetch.get(`${options.uri}${searchTerm}`, { signal }).then((data) => data.data[options.dataField ?? "data"]);
|
|
7716
|
+
}
|
|
7717
|
+
};
|
|
7718
|
+
};
|
|
7719
|
+
const useResourceOptions = async (options) => {
|
|
7720
|
+
const resource = await getResourceSchema(
|
|
7721
|
+
options.resource,
|
|
7722
|
+
options.skipAuth ?? false
|
|
7723
|
+
);
|
|
7724
|
+
const fetch = options.skipAuth ? axios : useApi();
|
|
7725
|
+
const lookup = resource.operations.lookup;
|
|
7726
|
+
return {
|
|
7727
|
+
fetchOptions: (searchTerm, signal) => {
|
|
7728
|
+
const uri = lookup.uri.replace("{text}", searchTerm);
|
|
7729
|
+
const method = lookup.method;
|
|
7730
|
+
return fetch[method](uri, { signal }).then(
|
|
7731
|
+
(data) => data.data[options.dataField ?? "data"]
|
|
7732
|
+
);
|
|
7733
|
+
},
|
|
7734
|
+
enableCreate: !!resource.operations.create,
|
|
7735
|
+
form: resource.operations.create ? {
|
|
7736
|
+
ui_schema: resource.schema.ui,
|
|
7737
|
+
json_schema: resource.schema.data,
|
|
7738
|
+
title: `Create new ${resource.id}`,
|
|
7739
|
+
create: async (data) => {
|
|
7740
|
+
const create = resource.operations.create;
|
|
7741
|
+
return fetch[create.method](create.uri, data).then(
|
|
7742
|
+
(result) => result.data
|
|
7743
|
+
);
|
|
7744
|
+
}
|
|
7745
|
+
} : null
|
|
7746
|
+
};
|
|
7747
|
+
};
|
|
7748
|
+
const useFetchOptions = async (options) => {
|
|
7749
|
+
let config2 = {};
|
|
7750
|
+
if (options.uri)
|
|
7751
|
+
config2 = useRemoteOption(options);
|
|
7752
|
+
if (options.resource)
|
|
7753
|
+
config2 = await useResourceOptions(options);
|
|
7754
|
+
return {
|
|
7755
|
+
fetchOptions: null,
|
|
7756
|
+
labelKey: options.labelKey,
|
|
7757
|
+
valueKey: options.valueKey,
|
|
7758
|
+
enableCreate: options.enableCreate ?? false,
|
|
7759
|
+
form: null,
|
|
7760
|
+
...config2
|
|
7761
|
+
};
|
|
7762
|
+
};
|
|
7763
|
+
const checkRequired = (rootSchema, scope, fieldName) => {
|
|
7764
|
+
const segments = scope.replace(/^#\//, "").split("/");
|
|
7765
|
+
const parentSegments = segments.slice(0, -2);
|
|
7766
|
+
if (parentSegments.length === 0) {
|
|
7767
|
+
const req2 = rootSchema?.required;
|
|
7768
|
+
return Array.isArray(req2) && req2.includes(fieldName);
|
|
7769
|
+
}
|
|
7770
|
+
const parentScope = `#/${parentSegments.join("/")}`;
|
|
7771
|
+
const parentSchema = resolveSchema(rootSchema, parentScope);
|
|
7772
|
+
const req = parentSchema?.required;
|
|
7773
|
+
return Array.isArray(req) && req.includes(fieldName);
|
|
7774
|
+
};
|
|
7775
|
+
const useInputProps = (uischema, schema, field, options = {}) => {
|
|
7776
|
+
const rootSchema = inject("rootSchema");
|
|
7777
|
+
const path = scopeToPath(uischema.scope);
|
|
7778
|
+
const { errorMessage, meta: meta2 } = field;
|
|
7779
|
+
const opts = uischema.options ?? {};
|
|
7780
|
+
const labelFromScope = path.split(".").pop() ?? "";
|
|
7781
|
+
const isRequired = rootSchema ? checkRequired(rootSchema, uischema.scope, labelFromScope) : false;
|
|
7782
|
+
const s = schema ?? {};
|
|
7783
|
+
const inferredType = (() => {
|
|
7784
|
+
if (opts.format === "text") return "text";
|
|
7785
|
+
if (s.format === "email") return "email";
|
|
7786
|
+
if (s.format === "uri") return "url";
|
|
7787
|
+
if (s.type === "number" || s.type === "integer") return "number";
|
|
7788
|
+
return options.defaultType ?? "text";
|
|
7789
|
+
})();
|
|
7790
|
+
const styles = mergeStyles(opts.styles);
|
|
7791
|
+
const errorMode = inject(ERROR_MODE_KEY, ref("onBlur"));
|
|
7792
|
+
const submitted = inject(FORM_SUBMITTED_KEY, ref(false));
|
|
7793
|
+
const shouldShowError = computed(() => {
|
|
7794
|
+
if (!errorMessage.value) return false;
|
|
7795
|
+
switch (errorMode.value) {
|
|
7796
|
+
case "always":
|
|
7797
|
+
return true;
|
|
7798
|
+
case "onChange":
|
|
7799
|
+
return meta2.dirty;
|
|
7800
|
+
case "onSubmit":
|
|
7801
|
+
return submitted.value;
|
|
7802
|
+
case "onBlur":
|
|
7803
|
+
default:
|
|
7804
|
+
return meta2.touched;
|
|
7805
|
+
}
|
|
7806
|
+
});
|
|
7807
|
+
const width = opts.colspan || styles?.width === "full" ? "w-full" : opts.width ?? "min-w-input";
|
|
7808
|
+
return computed(() => ({
|
|
7809
|
+
id: path,
|
|
7810
|
+
placeholder: opts.placeholder,
|
|
7811
|
+
description: s.description,
|
|
7812
|
+
errors: shouldShowError.value ? opts.errorMessage ?? formatError(errorMessage.value) : void 0,
|
|
7813
|
+
label: opts.label ?? labelFromScope.charAt(0).toUpperCase() + labelFromScope.slice(1),
|
|
7814
|
+
visible: opts.visible ?? true,
|
|
7815
|
+
required: isRequired,
|
|
7816
|
+
enabled: opts.readonly !== true,
|
|
7817
|
+
isFocused: false,
|
|
7818
|
+
isTouched: shouldShowError.value,
|
|
7819
|
+
hideLabel: opts.hideLabel ?? false,
|
|
7820
|
+
styles,
|
|
7821
|
+
width,
|
|
7822
|
+
type: inferredType,
|
|
7823
|
+
...options.overrides
|
|
7824
|
+
}));
|
|
7825
|
+
};
|
|
7826
|
+
const useCustomControlBinding = ({
|
|
7827
|
+
useProps,
|
|
7828
|
+
setDefaultValue
|
|
7829
|
+
} = {}) => {
|
|
7830
|
+
return (uischema, schema, options = {}) => {
|
|
7831
|
+
const pathPrefix = inject("pathPrefix", "");
|
|
7832
|
+
const scopePath = scopeToPath(uischema.scope);
|
|
7833
|
+
const path = pathPrefix ? `${pathPrefix}.${scopePath}` : scopePath;
|
|
7834
|
+
const field = useField(() => path);
|
|
7835
|
+
setDefaultValue?.(field);
|
|
7836
|
+
const wrapper = useInputProps(uischema, schema, field, options);
|
|
7837
|
+
const customWrapper = useProps?.(uischema, schema, field, options) ?? {
|
|
7838
|
+
value: {}
|
|
7839
|
+
};
|
|
7840
|
+
const onBlur = () => field.handleBlur(new Event("blur"));
|
|
7841
|
+
const onChange = () => field.handleChange(field.value.value);
|
|
7842
|
+
let initialized = false;
|
|
7843
|
+
watch(field.value, (val) => {
|
|
7844
|
+
if (!initialized) {
|
|
7845
|
+
initialized = true;
|
|
7846
|
+
return;
|
|
7960
7847
|
}
|
|
7961
|
-
|
|
7848
|
+
field.handleChange(val);
|
|
7849
|
+
});
|
|
7850
|
+
return {
|
|
7851
|
+
wrapper: computed(() => ({ ...wrapper.value, ...customWrapper.value })),
|
|
7852
|
+
value: field.value,
|
|
7853
|
+
field,
|
|
7854
|
+
onBlur,
|
|
7855
|
+
onChange,
|
|
7856
|
+
appliedOptions: computed(
|
|
7857
|
+
() => uischema.options ?? {}
|
|
7858
|
+
)
|
|
7859
|
+
};
|
|
7860
|
+
};
|
|
7861
|
+
};
|
|
7862
|
+
const useControlBinding = (uischema, schema, options = {}) => {
|
|
7863
|
+
return useCustomControlBinding()(uischema, schema, options);
|
|
7864
|
+
};
|
|
7865
|
+
const useSelectInput = (...fields) => (uischema, schema, field) => {
|
|
7866
|
+
const opts = uischema.options ?? {};
|
|
7867
|
+
return computed(() => {
|
|
7868
|
+
return pick$1(opts, fields);
|
|
7869
|
+
});
|
|
7870
|
+
};
|
|
7871
|
+
const useSelectBinding = useCustomControlBinding({
|
|
7872
|
+
useProps: useSelectInput("options", "labelKey", "valueKey")
|
|
7873
|
+
});
|
|
7874
|
+
const useAutocompleteBinding = useCustomControlBinding({
|
|
7875
|
+
useProps: useSelectInput(
|
|
7876
|
+
"options",
|
|
7877
|
+
"labelKey",
|
|
7878
|
+
"valueKey",
|
|
7879
|
+
"uri",
|
|
7880
|
+
"freeText",
|
|
7881
|
+
"enableCreate",
|
|
7882
|
+
"dataField",
|
|
7883
|
+
"skipAuth"
|
|
7884
|
+
)
|
|
7885
|
+
});
|
|
7886
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
7887
|
+
__name: "FormModal",
|
|
7888
|
+
props: /* @__PURE__ */ mergeModels(FormModalProperties, {
|
|
7889
|
+
"modelValue": {},
|
|
7890
|
+
"modelModifiers": {}
|
|
7891
|
+
}),
|
|
7892
|
+
emits: /* @__PURE__ */ mergeModels(FormModalEmits, ["update:modelValue"]),
|
|
7893
|
+
setup(__props, { emit: __emit }) {
|
|
7894
|
+
const properties = __props;
|
|
7895
|
+
const id = `modal_${Math.floor(Math.random() * 1e3)}`;
|
|
7896
|
+
const formRef = ref();
|
|
7897
|
+
const valid = ref(false);
|
|
7898
|
+
const formData = useModel(__props, "modelValue");
|
|
7899
|
+
const emits = __emit;
|
|
7900
|
+
if (properties.data) {
|
|
7901
|
+
formData.value = properties.data;
|
|
7962
7902
|
}
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
|
|
7983
|
-
if (rest) {
|
|
7984
|
-
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
7985
|
-
} else {
|
|
7986
|
-
zodSchema = z.tuple(tupleItems);
|
|
7987
|
-
}
|
|
7988
|
-
if (typeof schema.minItems === "number") {
|
|
7989
|
-
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
7990
|
-
}
|
|
7991
|
-
if (typeof schema.maxItems === "number") {
|
|
7992
|
-
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
7993
|
-
}
|
|
7994
|
-
} else if (items !== void 0) {
|
|
7995
|
-
const element = convertSchema(items, ctx);
|
|
7996
|
-
let arraySchema = z.array(element);
|
|
7997
|
-
if (typeof schema.minItems === "number") {
|
|
7998
|
-
arraySchema = arraySchema.min(schema.minItems);
|
|
7999
|
-
}
|
|
8000
|
-
if (typeof schema.maxItems === "number") {
|
|
8001
|
-
arraySchema = arraySchema.max(schema.maxItems);
|
|
8002
|
-
}
|
|
8003
|
-
zodSchema = arraySchema;
|
|
8004
|
-
} else {
|
|
8005
|
-
zodSchema = z.array(z.any());
|
|
7903
|
+
const onCancel = () => {
|
|
7904
|
+
formData.value = {};
|
|
7905
|
+
emits("closeModal", null);
|
|
7906
|
+
};
|
|
7907
|
+
const onChange = (data) => {
|
|
7908
|
+
formData.value = data;
|
|
7909
|
+
};
|
|
7910
|
+
const onSubmit = () => {
|
|
7911
|
+
formRef.value?.markSubmitted();
|
|
7912
|
+
if (!valid.value) return;
|
|
7913
|
+
emits("closeModal", { data: formData.value, valid: valid.value });
|
|
7914
|
+
};
|
|
7915
|
+
const onErrors = (errors) => {
|
|
7916
|
+
emits("errors", errors);
|
|
7917
|
+
valid.value = isEmpty(errors);
|
|
7918
|
+
};
|
|
7919
|
+
watch(valid, (newValid, oldValid) => {
|
|
7920
|
+
if (newValid !== oldValid) {
|
|
7921
|
+
emits("valid", newValid);
|
|
8006
7922
|
}
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
7923
|
+
});
|
|
7924
|
+
return (_ctx, _cache) => {
|
|
7925
|
+
return openBlock(), createBlock(unref(Modal), mergeProps(properties, {
|
|
7926
|
+
open: true,
|
|
7927
|
+
"disable-close": false,
|
|
7928
|
+
width: _ctx.modalSize,
|
|
7929
|
+
onCloseModal: onCancel
|
|
7930
|
+
}), {
|
|
7931
|
+
content: withCtx(() => [
|
|
7932
|
+
renderSlot(_ctx.$slots, "content-before"),
|
|
7933
|
+
createVNode(_sfc_main$2, {
|
|
7934
|
+
id: `modal-${id}`,
|
|
7935
|
+
ref_key: "formRef",
|
|
7936
|
+
ref: formRef,
|
|
7937
|
+
"form-data": formData.value,
|
|
7938
|
+
schema: _ctx.schema,
|
|
7939
|
+
"ui-schema": _ctx.uiSchema,
|
|
7940
|
+
"error-mode": _ctx.errorMode,
|
|
7941
|
+
onErrors,
|
|
7942
|
+
onChange,
|
|
7943
|
+
onEvents: _cache[0] || (_cache[0] = ($event) => emits("events", $event))
|
|
7944
|
+
}, null, 8, ["id", "form-data", "schema", "ui-schema", "error-mode"]),
|
|
7945
|
+
renderSlot(_ctx.$slots, "content-after")
|
|
7946
|
+
]),
|
|
7947
|
+
actions: withCtx(() => [
|
|
7948
|
+
createVNode(unref(Btn), {
|
|
7949
|
+
color: unref(Color).secondary,
|
|
7950
|
+
outline: true,
|
|
7951
|
+
"aria-label": "Cancel",
|
|
7952
|
+
onClick: onCancel
|
|
7953
|
+
}, {
|
|
7954
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
7955
|
+
createTextVNode(" Cancel ", -1)
|
|
7956
|
+
])]),
|
|
7957
|
+
_: 1
|
|
7958
|
+
}, 8, ["color"]),
|
|
7959
|
+
createVNode(unref(Btn), {
|
|
7960
|
+
disabled: !valid.value,
|
|
7961
|
+
"aria-label": "Save",
|
|
7962
|
+
onClick: onSubmit
|
|
7963
|
+
}, {
|
|
7964
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
|
7965
|
+
createTextVNode(" Save ", -1)
|
|
7966
|
+
])]),
|
|
7967
|
+
_: 1
|
|
7968
|
+
}, 8, ["disabled"])
|
|
7969
|
+
]),
|
|
7970
|
+
_: 3
|
|
7971
|
+
}, 16, ["width"]);
|
|
7972
|
+
};
|
|
8014
7973
|
}
|
|
8015
|
-
|
|
8016
|
-
|
|
7974
|
+
});
|
|
7975
|
+
class JsonFormModalService {
|
|
7976
|
+
static openModal({
|
|
7977
|
+
initialData,
|
|
7978
|
+
modalTitle,
|
|
7979
|
+
schema,
|
|
7980
|
+
uiSchema,
|
|
7981
|
+
modalSize,
|
|
7982
|
+
onClose,
|
|
7983
|
+
onEvents
|
|
7984
|
+
}) {
|
|
7985
|
+
ModalService.openModal({
|
|
7986
|
+
component: _sfc_main$d,
|
|
7987
|
+
props: {
|
|
7988
|
+
schema,
|
|
7989
|
+
uiSchema,
|
|
7990
|
+
modalSize,
|
|
7991
|
+
data: initialData ?? {},
|
|
7992
|
+
modalTitle,
|
|
7993
|
+
onClose,
|
|
7994
|
+
onEvents
|
|
7995
|
+
}
|
|
7996
|
+
});
|
|
8017
7997
|
}
|
|
8018
|
-
return zodSchema;
|
|
8019
7998
|
}
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
7999
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
8000
|
+
__name: "AutocompleteControlRenderer",
|
|
8001
|
+
props: {
|
|
8002
|
+
uischema: {},
|
|
8003
|
+
schema: {}
|
|
8004
|
+
},
|
|
8005
|
+
setup(__props) {
|
|
8006
|
+
const props = __props;
|
|
8007
|
+
const {
|
|
8008
|
+
wrapper,
|
|
8009
|
+
value,
|
|
8010
|
+
field,
|
|
8011
|
+
onBlur,
|
|
8012
|
+
onChange: onFieldChange,
|
|
8013
|
+
appliedOptions
|
|
8014
|
+
} = useAutocompleteBinding(props.uischema, props.schema);
|
|
8015
|
+
const fetchOptions = computedAsync(async () => {
|
|
8016
|
+
const config2 = await useFetchOptions(
|
|
8017
|
+
appliedOptions.value
|
|
8018
|
+
);
|
|
8019
|
+
return config2;
|
|
8020
|
+
});
|
|
8021
|
+
const onChange = (val) => {
|
|
8022
|
+
field.setValue(val);
|
|
8023
|
+
onFieldChange();
|
|
8024
|
+
};
|
|
8025
|
+
const formEvents = useFormEvents();
|
|
8026
|
+
const path = scopeToPath(props.uischema.scope);
|
|
8027
|
+
const onCreate = () => {
|
|
8028
|
+
if (fetchOptions.value?.enableCreate === false) return;
|
|
8029
|
+
const form = fetchOptions.value.form;
|
|
8030
|
+
if (form) {
|
|
8031
|
+
JsonFormModalService.openModal({
|
|
8032
|
+
schema: form.json_schema,
|
|
8033
|
+
uiSchema: form.ui_schema,
|
|
8034
|
+
modalTitle: `Create new ${wrapper.value.label}`,
|
|
8035
|
+
onClose: (result) => {
|
|
8036
|
+
if (!result || !result.valid) return;
|
|
8037
|
+
form.create(result.data).then((res) => {
|
|
8038
|
+
field.setValue(res);
|
|
8039
|
+
});
|
|
8040
|
+
}
|
|
8041
|
+
});
|
|
8042
|
+
return;
|
|
8043
|
+
}
|
|
8044
|
+
formEvents.dispatch({
|
|
8045
|
+
event: "create",
|
|
8046
|
+
type: path,
|
|
8047
|
+
data: value.value,
|
|
8048
|
+
onSuccess: (result) => {
|
|
8049
|
+
field.setValue(result);
|
|
8050
|
+
}
|
|
8051
|
+
});
|
|
8052
|
+
};
|
|
8053
|
+
return (_ctx, _cache) => {
|
|
8054
|
+
return unref(fetchOptions) ? (openBlock(), createBlock(unref(Autocomplete), mergeProps({ key: 0 }, unref(wrapper), {
|
|
8055
|
+
"model-value": unref(value),
|
|
8056
|
+
"fetch-options": unref(fetchOptions).fetchOptions,
|
|
8057
|
+
"label-key": unref(fetchOptions).labelKey,
|
|
8058
|
+
"value-key": unref(fetchOptions).valueKey,
|
|
8059
|
+
"enable-create": unref(fetchOptions).enableCreate,
|
|
8060
|
+
onChange,
|
|
8061
|
+
onBlur: unref(onBlur),
|
|
8062
|
+
onCreate
|
|
8063
|
+
}), null, 16, ["model-value", "fetch-options", "label-key", "value-key", "enable-create", "onBlur"])) : createCommentVNode("", true);
|
|
8064
|
+
};
|
|
8023
8065
|
}
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8066
|
+
});
|
|
8067
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
8068
|
+
__name: "BooleanControlRenderer",
|
|
8069
|
+
props: {
|
|
8070
|
+
uischema: {},
|
|
8071
|
+
schema: {}
|
|
8072
|
+
},
|
|
8073
|
+
setup(__props) {
|
|
8074
|
+
const props = __props;
|
|
8075
|
+
const useBooleanBinding = useCustomControlBinding({
|
|
8076
|
+
setDefaultValue: (field2) => {
|
|
8077
|
+
if (field2.value.value === void 0) field2.setValue(false);
|
|
8078
|
+
}
|
|
8079
|
+
});
|
|
8080
|
+
const { wrapper, value, field, onBlur, onChange: onFieldChange } = useBooleanBinding(props.uischema, props.schema);
|
|
8081
|
+
const onChange = (val) => {
|
|
8082
|
+
field.setValue(Boolean(val) ?? false);
|
|
8083
|
+
onFieldChange();
|
|
8084
|
+
};
|
|
8085
|
+
return (_ctx, _cache) => {
|
|
8086
|
+
return openBlock(), createBlock(unref(Checkbox), mergeProps(unref(wrapper), {
|
|
8087
|
+
"model-value": unref(value),
|
|
8088
|
+
onChange,
|
|
8089
|
+
onBlur: unref(onBlur)
|
|
8090
|
+
}), null, 16, ["model-value", "onBlur"]);
|
|
8091
|
+
};
|
|
8092
|
+
}
|
|
8093
|
+
});
|
|
8094
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
8095
|
+
__name: "MarkdownControlRenderer",
|
|
8096
|
+
props: {
|
|
8097
|
+
uischema: {},
|
|
8098
|
+
schema: {}
|
|
8099
|
+
},
|
|
8100
|
+
setup(__props) {
|
|
8101
|
+
const props = __props;
|
|
8102
|
+
const {
|
|
8103
|
+
wrapper,
|
|
8104
|
+
value,
|
|
8105
|
+
field,
|
|
8106
|
+
onBlur,
|
|
8107
|
+
onChange: onFieldChange
|
|
8108
|
+
} = useControlBinding(props.uischema, props.schema);
|
|
8109
|
+
const onChange = (val) => {
|
|
8110
|
+
field.setValue(val);
|
|
8111
|
+
onFieldChange();
|
|
8112
|
+
};
|
|
8113
|
+
return (_ctx, _cache) => {
|
|
8114
|
+
return openBlock(), createBlock(unref(Markdown), mergeProps(unref(wrapper), {
|
|
8115
|
+
"model-value": unref(value),
|
|
8116
|
+
onChange,
|
|
8117
|
+
onBlur: unref(onBlur)
|
|
8118
|
+
}), null, 16, ["model-value", "onBlur"]);
|
|
8119
|
+
};
|
|
8030
8120
|
}
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8121
|
+
});
|
|
8122
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
8123
|
+
__name: "MultiSelectControlRenderer",
|
|
8124
|
+
props: {
|
|
8125
|
+
uischema: {},
|
|
8126
|
+
schema: {}
|
|
8127
|
+
},
|
|
8128
|
+
setup(__props) {
|
|
8129
|
+
const props = __props;
|
|
8130
|
+
const {
|
|
8131
|
+
wrapper,
|
|
8132
|
+
value,
|
|
8133
|
+
field,
|
|
8134
|
+
onBlur,
|
|
8135
|
+
onChange: onFieldChange
|
|
8136
|
+
} = useSelectBinding(props.uischema, props.schema);
|
|
8137
|
+
const onChange = (val) => {
|
|
8138
|
+
field.setValue(val);
|
|
8139
|
+
onFieldChange();
|
|
8140
|
+
};
|
|
8141
|
+
return (_ctx, _cache) => {
|
|
8142
|
+
return openBlock(), createBlock(unref(MultiSelect), mergeProps(unref(wrapper), {
|
|
8143
|
+
"model-value": unref(value),
|
|
8144
|
+
onChange,
|
|
8145
|
+
onBlur: unref(onBlur)
|
|
8146
|
+
}), null, 16, ["model-value", "onBlur"]);
|
|
8147
|
+
};
|
|
8035
8148
|
}
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8149
|
+
});
|
|
8150
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
8151
|
+
__name: "NumberControlRenderer",
|
|
8152
|
+
props: {
|
|
8153
|
+
uischema: {},
|
|
8154
|
+
schema: {}
|
|
8155
|
+
},
|
|
8156
|
+
setup(__props) {
|
|
8157
|
+
const props = __props;
|
|
8158
|
+
const { wrapper, value, onBlur, onChange } = useControlBinding(
|
|
8159
|
+
props.uischema,
|
|
8160
|
+
props.schema,
|
|
8161
|
+
{ defaultType: "number" }
|
|
8162
|
+
);
|
|
8163
|
+
return (_ctx, _cache) => {
|
|
8164
|
+
return openBlock(), createBlock(unref(InputNumber), mergeProps(unref(wrapper), {
|
|
8165
|
+
modelValue: unref(value),
|
|
8166
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(value) ? value.value = $event : null),
|
|
8167
|
+
steps: 0.01,
|
|
8168
|
+
onBlur: unref(onBlur),
|
|
8169
|
+
onChange: unref(onChange)
|
|
8170
|
+
}), null, 16, ["modelValue", "onBlur", "onChange"]);
|
|
8171
|
+
};
|
|
8047
8172
|
}
|
|
8048
|
-
|
|
8049
|
-
|
|
8173
|
+
});
|
|
8174
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
8175
|
+
__name: "SelectControlRenderer",
|
|
8176
|
+
props: {
|
|
8177
|
+
uischema: {},
|
|
8178
|
+
schema: {}
|
|
8179
|
+
},
|
|
8180
|
+
setup(__props) {
|
|
8181
|
+
const props = __props;
|
|
8182
|
+
const {
|
|
8183
|
+
wrapper,
|
|
8184
|
+
value,
|
|
8185
|
+
field,
|
|
8186
|
+
onBlur,
|
|
8187
|
+
onChange: onFieldChange,
|
|
8188
|
+
appliedOptions
|
|
8189
|
+
} = useSelectBinding(props.uischema, props.schema);
|
|
8190
|
+
const selectOptions = computed(() => {
|
|
8191
|
+
return appliedOptions.options ?? [];
|
|
8192
|
+
});
|
|
8193
|
+
const onChange = (val) => {
|
|
8194
|
+
field.setValue(val);
|
|
8195
|
+
onFieldChange();
|
|
8196
|
+
};
|
|
8197
|
+
return (_ctx, _cache) => {
|
|
8198
|
+
return openBlock(), createBlock(unref(SelectComponent), mergeProps(unref(wrapper), {
|
|
8199
|
+
"model-value": unref(value),
|
|
8200
|
+
options: selectOptions.value,
|
|
8201
|
+
onChange,
|
|
8202
|
+
onBlur: unref(onBlur)
|
|
8203
|
+
}), null, 16, ["model-value", "options", "onBlur"]);
|
|
8204
|
+
};
|
|
8050
8205
|
}
|
|
8051
|
-
|
|
8052
|
-
|
|
8206
|
+
});
|
|
8207
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
8208
|
+
__name: "StringControlRenderer",
|
|
8209
|
+
props: {
|
|
8210
|
+
uischema: {},
|
|
8211
|
+
schema: {}
|
|
8212
|
+
},
|
|
8213
|
+
setup(__props) {
|
|
8214
|
+
const props = __props;
|
|
8215
|
+
const { wrapper, value, onBlur, onChange } = useControlBinding(
|
|
8216
|
+
props.uischema,
|
|
8217
|
+
props.schema
|
|
8218
|
+
);
|
|
8219
|
+
return (_ctx, _cache) => {
|
|
8220
|
+
return openBlock(), createBlock(unref(Input), mergeProps(unref(wrapper), {
|
|
8221
|
+
modelValue: unref(value),
|
|
8222
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(value) ? value.value = $event : null),
|
|
8223
|
+
onBlur: unref(onBlur),
|
|
8224
|
+
onChange: unref(onChange)
|
|
8225
|
+
}), null, 16, ["modelValue", "onBlur", "onChange"]);
|
|
8226
|
+
};
|
|
8053
8227
|
}
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
}
|
|
8228
|
+
});
|
|
8229
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
8230
|
+
__name: "TextAreaControlRenderer",
|
|
8231
|
+
props: {
|
|
8232
|
+
uischema: {},
|
|
8233
|
+
schema: {}
|
|
8234
|
+
},
|
|
8235
|
+
setup(__props) {
|
|
8236
|
+
const props = __props;
|
|
8237
|
+
const { wrapper, value, onBlur, onChange } = useControlBinding(
|
|
8238
|
+
props.uischema,
|
|
8239
|
+
props.schema
|
|
8240
|
+
);
|
|
8241
|
+
return (_ctx, _cache) => {
|
|
8242
|
+
return openBlock(), createBlock(unref(Textarea), mergeProps(unref(wrapper), {
|
|
8243
|
+
modelValue: unref(value),
|
|
8244
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(value) ? value.value = $event : null),
|
|
8245
|
+
onBlur: unref(onBlur),
|
|
8246
|
+
onChange: unref(onChange)
|
|
8247
|
+
}), null, 16, ["modelValue", "onBlur", "onChange"]);
|
|
8248
|
+
};
|
|
8060
8249
|
}
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8250
|
+
});
|
|
8251
|
+
const index = [
|
|
8252
|
+
{ tester: rankWith(10, isStringFormat), renderer: _sfc_main$6 },
|
|
8253
|
+
{
|
|
8254
|
+
tester: rankWith(11, isTextAreaControl),
|
|
8255
|
+
renderer: _sfc_main$5
|
|
8256
|
+
},
|
|
8257
|
+
{
|
|
8258
|
+
tester: rankWith(11, isMarkdownControl),
|
|
8259
|
+
renderer: _sfc_main$a
|
|
8260
|
+
},
|
|
8261
|
+
{ tester: rankWith(11, isBooleanControl), renderer: _sfc_main$b },
|
|
8262
|
+
{ tester: rankWith(11, isSelectControl), renderer: _sfc_main$7 },
|
|
8263
|
+
{
|
|
8264
|
+
tester: rankWith(11, isMultiselectControl),
|
|
8265
|
+
renderer: _sfc_main$9
|
|
8266
|
+
},
|
|
8267
|
+
{
|
|
8268
|
+
tester: rankWith(12, isAutoCompleteControl),
|
|
8269
|
+
renderer: _sfc_main$c
|
|
8270
|
+
},
|
|
8271
|
+
{
|
|
8272
|
+
tester: rankWith(12, isNumberFormat),
|
|
8273
|
+
renderer: _sfc_main$8
|
|
8274
|
+
},
|
|
8275
|
+
{
|
|
8276
|
+
tester: rankWith(12, isIntegerFormat),
|
|
8277
|
+
renderer: _sfc_main$8
|
|
8066
8278
|
}
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8279
|
+
];
|
|
8280
|
+
const COLSPAN = {
|
|
8281
|
+
1: "col-span-1",
|
|
8282
|
+
2: "col-span-2",
|
|
8283
|
+
3: "col-span-3",
|
|
8284
|
+
4: "col-span-4",
|
|
8285
|
+
5: "col-span-5",
|
|
8286
|
+
6: "col-span-6",
|
|
8287
|
+
7: "col-span-7",
|
|
8288
|
+
8: "col-span-8",
|
|
8289
|
+
9: "col-span-9",
|
|
8290
|
+
10: "col-span-10",
|
|
8291
|
+
11: "col-span-11",
|
|
8292
|
+
12: "col-span-12"
|
|
8293
|
+
};
|
|
8294
|
+
const _hoisted_1$4 = { class: "flex flex-col gap-4" };
|
|
8295
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
8296
|
+
__name: "CollapseLayoutRenderer",
|
|
8297
|
+
props: {
|
|
8298
|
+
uischema: {},
|
|
8299
|
+
schema: {}
|
|
8300
|
+
},
|
|
8301
|
+
setup(__props) {
|
|
8302
|
+
const props = __props;
|
|
8303
|
+
const pathPrefix = inject("pathPrefix", "");
|
|
8304
|
+
const opts = props.uischema.options ?? {};
|
|
8305
|
+
const titleKeyField = opts.titleKey ? useFieldValue(
|
|
8306
|
+
() => pathPrefix ? `${pathPrefix}.${opts.titleKey}` : opts.titleKey
|
|
8307
|
+
) : void 0;
|
|
8308
|
+
const title = computed(() => {
|
|
8309
|
+
if (titleKeyField?.value) return titleKeyField.value;
|
|
8310
|
+
return props.uischema.label ?? opts.title ?? "Details";
|
|
8311
|
+
});
|
|
8312
|
+
return (_ctx, _cache) => {
|
|
8313
|
+
return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
|
|
8314
|
+
default: withCtx(() => [
|
|
8315
|
+
createElementVNode("div", _hoisted_1$4, [
|
|
8316
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.uischema.elements, (child, i) => {
|
|
8317
|
+
return openBlock(), createElementBlock("div", {
|
|
8318
|
+
key: i,
|
|
8319
|
+
class: normalizeClass(unref(COLSPAN)[child.options?.colspan ?? 12])
|
|
8320
|
+
}, [
|
|
8321
|
+
createVNode(_sfc_main$f, {
|
|
8322
|
+
uischema: child,
|
|
8323
|
+
schema: __props.schema
|
|
8324
|
+
}, null, 8, ["uischema", "schema"])
|
|
8325
|
+
], 2);
|
|
8326
|
+
}), 128))
|
|
8327
|
+
])
|
|
8328
|
+
]),
|
|
8329
|
+
_: 1
|
|
8330
|
+
}, 8, ["title"]);
|
|
8331
|
+
};
|
|
8071
8332
|
}
|
|
8072
|
-
|
|
8073
|
-
|
|
8333
|
+
});
|
|
8334
|
+
const _hoisted_1$3 = {
|
|
8335
|
+
key: 1,
|
|
8336
|
+
class: "flex flex-col gap-3"
|
|
8337
|
+
};
|
|
8338
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
8339
|
+
__name: "LayoutRenderer",
|
|
8340
|
+
props: {
|
|
8341
|
+
uischema: {},
|
|
8342
|
+
schema: {}
|
|
8343
|
+
},
|
|
8344
|
+
setup(__props) {
|
|
8345
|
+
const props = __props;
|
|
8346
|
+
const LAYOUT = {
|
|
8347
|
+
GridLayout: "grid grid-cols-12 gap-3",
|
|
8348
|
+
HorizontalLayout: "flex flex-row gap-3",
|
|
8349
|
+
VerticalLayout: "flex flex-col gap-3"
|
|
8350
|
+
};
|
|
8351
|
+
const getLayout = computed(() => LAYOUT[props.uischema.type]);
|
|
8352
|
+
const isLayout = computed(() => props.uischema.type in LAYOUT);
|
|
8353
|
+
return (_ctx, _cache) => {
|
|
8354
|
+
return isLayout.value ? (openBlock(), createElementBlock("div", {
|
|
8355
|
+
key: 0,
|
|
8356
|
+
class: normalizeClass(getLayout.value)
|
|
8357
|
+
}, [
|
|
8358
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.uischema.elements, (child, i) => {
|
|
8359
|
+
return openBlock(), createElementBlock("div", {
|
|
8360
|
+
key: i,
|
|
8361
|
+
class: normalizeClass(unref(COLSPAN)[child.options?.colspan ?? 12])
|
|
8362
|
+
}, [
|
|
8363
|
+
createVNode(_sfc_main$f, {
|
|
8364
|
+
uischema: child,
|
|
8365
|
+
schema: __props.schema
|
|
8366
|
+
}, null, 8, ["uischema", "schema"])
|
|
8367
|
+
], 2);
|
|
8368
|
+
}), 128))
|
|
8369
|
+
], 2)) : (openBlock(), createElementBlock("div", _hoisted_1$3, " No Applicable Layout found "));
|
|
8370
|
+
};
|
|
8074
8371
|
}
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8372
|
+
});
|
|
8373
|
+
const isLayoutType = or$1(
|
|
8374
|
+
uiTypeIs("GridLayout"),
|
|
8375
|
+
uiTypeIs("HorizontalLayout"),
|
|
8376
|
+
uiTypeIs("VerticalLayout")
|
|
8377
|
+
);
|
|
8378
|
+
const layoutRenderes = [
|
|
8379
|
+
{ tester: rankWith(10, isLayoutType), renderer: _sfc_main$3 },
|
|
8380
|
+
{
|
|
8381
|
+
tester: rankWith(10, uiTypeIs("CollapseLayout")),
|
|
8382
|
+
renderer: _sfc_main$4
|
|
8080
8383
|
}
|
|
8081
|
-
const version2 = detectVersion(schema);
|
|
8082
|
-
const defs = schema.$defs || schema.definitions || {};
|
|
8083
|
-
const ctx = {
|
|
8084
|
-
version: version2,
|
|
8085
|
-
defs,
|
|
8086
|
-
refs: /* @__PURE__ */ new Map(),
|
|
8087
|
-
processing: /* @__PURE__ */ new Set(),
|
|
8088
|
-
rootSchema: schema,
|
|
8089
|
-
registry: globalRegistry
|
|
8090
|
-
};
|
|
8091
|
-
return convertSchema(schema, ctx);
|
|
8092
|
-
}
|
|
8093
|
-
config(en());
|
|
8094
|
-
const customRenderers = [
|
|
8095
|
-
controlRenderers,
|
|
8096
|
-
layoutRenderers,
|
|
8097
|
-
// ...complexRenderers,
|
|
8098
|
-
arrayRenderers
|
|
8099
|
-
// ...labelRenderers,
|
|
8100
|
-
].flat();
|
|
8101
|
-
const tailwindRenderers = [
|
|
8102
|
-
...vanillaRenderers,
|
|
8103
|
-
...customRenderers
|
|
8104
8384
|
];
|
|
8105
|
-
const
|
|
8385
|
+
const customRenderes = [layoutRenderes, index, arrayRenderers].flat();
|
|
8386
|
+
const _hoisted_1$2 = ["id"];
|
|
8106
8387
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
8107
|
-
__name: "
|
|
8108
|
-
props:
|
|
8109
|
-
emits:
|
|
8110
|
-
setup(__props, { emit: __emit }) {
|
|
8388
|
+
__name: "FormComponent",
|
|
8389
|
+
props: JsonFormComponentProperties,
|
|
8390
|
+
emits: JsonFormComponentEmits,
|
|
8391
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
8392
|
+
registerZodErrorMap();
|
|
8111
8393
|
const properties = __props;
|
|
8112
8394
|
const emits = __emit;
|
|
8113
|
-
const
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8395
|
+
const zodSchema = computed(() => {
|
|
8396
|
+
if (!properties.schema) return void 0;
|
|
8397
|
+
try {
|
|
8398
|
+
const patched = enforceRequiredStringMinLength(properties.schema);
|
|
8399
|
+
return fromJSONSchema(patched);
|
|
8400
|
+
} catch {
|
|
8401
|
+
return void 0;
|
|
8402
|
+
}
|
|
8403
|
+
});
|
|
8404
|
+
const { values, errors, meta: meta2, setValues, validate } = useForm({
|
|
8405
|
+
validationSchema: zodSchema,
|
|
8406
|
+
initialValues: properties.formData
|
|
8407
|
+
});
|
|
8408
|
+
provide("renderers", customRenderes);
|
|
8409
|
+
provide("rootSchema", properties.schema);
|
|
8410
|
+
provide("styles", myStyles);
|
|
8411
|
+
const submitted = ref(false);
|
|
8412
|
+
provide(ERROR_MODE_KEY, toRef(properties, "errorMode"));
|
|
8413
|
+
provide(FORM_SUBMITTED_KEY, submitted);
|
|
8414
|
+
onMounted(async () => {
|
|
8415
|
+
const result = await validate();
|
|
8416
|
+
emits("valid", result.valid);
|
|
8417
|
+
});
|
|
8418
|
+
provideFormEvents((payload) => {
|
|
8419
|
+
emits("events", payload);
|
|
8420
|
+
});
|
|
8421
|
+
let syncing = false;
|
|
8120
8422
|
watch(
|
|
8121
8423
|
() => properties.formData,
|
|
8122
|
-
(
|
|
8123
|
-
if (
|
|
8124
|
-
|
|
8125
|
-
|
|
8424
|
+
(newData) => {
|
|
8425
|
+
if (!newData) return;
|
|
8426
|
+
if (JSON.stringify(newData) === JSON.stringify(toRaw(values))) return;
|
|
8427
|
+
syncing = true;
|
|
8428
|
+
setValues(newData);
|
|
8429
|
+
nextTick(() => {
|
|
8430
|
+
syncing = false;
|
|
8431
|
+
});
|
|
8126
8432
|
},
|
|
8127
|
-
{ deep: true
|
|
8433
|
+
{ deep: true }
|
|
8128
8434
|
);
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8435
|
+
watch(
|
|
8436
|
+
values,
|
|
8437
|
+
(newValues) => {
|
|
8438
|
+
if (syncing) return;
|
|
8439
|
+
const isValid = meta2.value.valid;
|
|
8440
|
+
emits("valid", isValid);
|
|
8441
|
+
emits("change", toRaw(newValues));
|
|
8442
|
+
},
|
|
8443
|
+
{ deep: true }
|
|
8444
|
+
);
|
|
8445
|
+
watch(
|
|
8446
|
+
errors,
|
|
8447
|
+
(newErrors) => {
|
|
8448
|
+
const errorList = Object.entries(newErrors).filter(([, msg]) => !!msg).map(([path, message]) => ({ path, message }));
|
|
8449
|
+
emits("errors", errorList);
|
|
8450
|
+
},
|
|
8451
|
+
{ deep: true }
|
|
8452
|
+
);
|
|
8453
|
+
const onSubmit = () => {
|
|
8454
|
+
submitted.value = true;
|
|
8142
8455
|
emits("submit", {
|
|
8143
|
-
data:
|
|
8144
|
-
valid:
|
|
8456
|
+
data: toRaw(values),
|
|
8457
|
+
valid: meta2.value.valid
|
|
8145
8458
|
});
|
|
8146
8459
|
};
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
]);
|
|
8460
|
+
const markSubmitted = () => {
|
|
8461
|
+
submitted.value = true;
|
|
8462
|
+
};
|
|
8463
|
+
__expose({ markSubmitted });
|
|
8152
8464
|
return (_ctx, _cache) => {
|
|
8153
8465
|
return openBlock(), createElementBlock("form", {
|
|
8154
8466
|
id: _ctx.id,
|
|
8155
8467
|
onSubmit: withModifiers(onSubmit, ["prevent"])
|
|
8156
8468
|
}, [
|
|
8157
|
-
(
|
|
8158
|
-
key: _ctx.id,
|
|
8159
|
-
data: internalFormData.value,
|
|
8160
|
-
schema: _ctx.schema,
|
|
8469
|
+
createVNode(_sfc_main$f, {
|
|
8161
8470
|
uischema: _ctx.uiSchema,
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
onSubmit
|
|
8166
|
-
}, null, 8, ["data", "schema", "uischema", "renderers", "enabled"]))
|
|
8167
|
-
], 40, _hoisted_1$1);
|
|
8471
|
+
schema: _ctx.schema
|
|
8472
|
+
}, null, 8, ["uischema", "schema"])
|
|
8473
|
+
], 40, _hoisted_1$2);
|
|
8168
8474
|
};
|
|
8169
8475
|
}
|
|
8170
8476
|
});
|
|
8171
|
-
const
|
|
8477
|
+
const FormWithActionsProperties = {
|
|
8478
|
+
/** Unique identifier used to namespace the inner form element. */
|
|
8479
|
+
id: { type: String, required: true },
|
|
8480
|
+
/** Title shown when creating a new record. */
|
|
8481
|
+
createTitle: { type: String, required: true },
|
|
8482
|
+
/** Title shown when editing an existing record. Falls back to `createTitle` when omitted. */
|
|
8483
|
+
updateTitle: { type: String },
|
|
8484
|
+
/** JSON schema describing the shape of the form data. */
|
|
8485
|
+
schema: { type: Object },
|
|
8486
|
+
/** UI schema describing the layout and controls. */
|
|
8487
|
+
uiSchema: { type: Object },
|
|
8488
|
+
/** REST endpoint used by `FormStore` to persist data. When omitted the form emits `submit` instead. */
|
|
8489
|
+
uri: { type: String },
|
|
8490
|
+
/** Enable vertical scrolling inside the form area. */
|
|
8491
|
+
scrollable: { type: Boolean, default: false },
|
|
8492
|
+
/** Stretch the collapse wrapper to full height. */
|
|
8493
|
+
fullHeight: { type: Boolean, default: false },
|
|
8494
|
+
/** Two-way bound form data object. */
|
|
8495
|
+
modelValue: { type: Object, default: () => ({}) },
|
|
8496
|
+
/** When validation errors are shown (`'onBlur'`, `'onChange'`, `'onSubmit'`, `'always'`). */
|
|
8497
|
+
errorMode: {
|
|
8498
|
+
type: String,
|
|
8499
|
+
default: "onBlur"
|
|
8500
|
+
}
|
|
8501
|
+
};
|
|
8502
|
+
const FormWithActionsEmits = [
|
|
8503
|
+
/** Emitted when `modelValue` changes. */
|
|
8504
|
+
"update:modelValue",
|
|
8505
|
+
/** Emitted after a successful `FormStore.save()`. */
|
|
8506
|
+
"success",
|
|
8507
|
+
/** Emitted on submit when no `uri` is provided. */
|
|
8508
|
+
"submit",
|
|
8509
|
+
/** Emitted whenever form validity changes. */
|
|
8510
|
+
"valid",
|
|
8511
|
+
/** Emitted when a custom renderer dispatches a form event. */
|
|
8512
|
+
"events",
|
|
8513
|
+
/** Emitted when validation errors change. */
|
|
8514
|
+
"errors",
|
|
8515
|
+
/** Emitted when the user cancels editing an existing record. */
|
|
8516
|
+
"cancel"
|
|
8517
|
+
];
|
|
8518
|
+
class FormStore {
|
|
8519
|
+
constructor(uri) {
|
|
8520
|
+
this.uri = uri;
|
|
8521
|
+
}
|
|
8522
|
+
async delete(data) {
|
|
8523
|
+
return useApi().delete(`${this.uri}/${data.id}`).then(() => {
|
|
8524
|
+
NotificationService.success("Data deleted");
|
|
8525
|
+
}).catch((error2) => {
|
|
8526
|
+
console.error(error2);
|
|
8527
|
+
NotificationService.error("Error deleting data");
|
|
8528
|
+
});
|
|
8529
|
+
}
|
|
8530
|
+
async save(id, data) {
|
|
8531
|
+
if (!this.uri) return;
|
|
8532
|
+
const promise2 = id ? useApi().patch(`${this.uri}/${id}`, data) : useApi().post(this.uri, data);
|
|
8533
|
+
return promise2.then((response) => {
|
|
8534
|
+
NotificationService.success("Data saved");
|
|
8535
|
+
return response.data;
|
|
8536
|
+
}).catch((error2) => {
|
|
8537
|
+
console.error(error2);
|
|
8538
|
+
NotificationService.error("Error saving data");
|
|
8539
|
+
});
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
const _hoisted_1$1 = { class: "flex justify-end gap-2 p-2 mt-2 border-t border-gray-300 z-[30] shrink-0" };
|
|
8172
8543
|
const _hoisted_2 = { class: "flex justify-end gap-2" };
|
|
8173
8544
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
8174
|
-
__name: "
|
|
8175
|
-
props:
|
|
8176
|
-
...FormWithActionsProperties,
|
|
8177
|
-
modelValue: { type: Object, default: () => ({}) }
|
|
8178
|
-
},
|
|
8545
|
+
__name: "FormWithActions",
|
|
8546
|
+
props: FormWithActionsProperties,
|
|
8179
8547
|
emits: FormWithActionsEmits,
|
|
8180
8548
|
setup(__props, { emit: __emit }) {
|
|
8181
8549
|
const properties = __props;
|
|
8182
8550
|
const emits = __emit;
|
|
8551
|
+
const formRef = ref();
|
|
8183
8552
|
const formData = ref(properties.modelValue);
|
|
8184
8553
|
const initialFormData = ref(structuredClone(toRaw(properties.modelValue)));
|
|
8185
8554
|
const recordId = ref(properties.modelValue?.id ?? null);
|
|
8186
8555
|
const valid = ref(false);
|
|
8187
|
-
const submitted = ref(false);
|
|
8188
8556
|
watch(
|
|
8189
8557
|
() => properties.modelValue,
|
|
8190
|
-
(newValue
|
|
8558
|
+
(newValue) => {
|
|
8191
8559
|
if (newValue === formData.value) return;
|
|
8192
8560
|
recordId.value = newValue?.id ?? null;
|
|
8193
8561
|
initialFormData.value = structuredClone(toRaw(newValue));
|
|
@@ -8202,13 +8570,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8202
8570
|
emits("update:modelValue", data);
|
|
8203
8571
|
};
|
|
8204
8572
|
const save = () => {
|
|
8205
|
-
|
|
8206
|
-
if (!valid.value)
|
|
8207
|
-
return;
|
|
8208
|
-
}
|
|
8573
|
+
formRef.value?.markSubmitted();
|
|
8574
|
+
if (!valid.value) return;
|
|
8209
8575
|
if (store.value) {
|
|
8210
|
-
store.value.save(recordId.value, formData.value).then(() => {
|
|
8211
|
-
emits("success");
|
|
8576
|
+
store.value.save(recordId.value, formData.value).then((response) => {
|
|
8577
|
+
emits("success", response);
|
|
8212
8578
|
});
|
|
8213
8579
|
} else {
|
|
8214
8580
|
emits("submit", formData.value);
|
|
@@ -8216,28 +8582,31 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8216
8582
|
};
|
|
8217
8583
|
const clear = () => {
|
|
8218
8584
|
formData.value = { id: null };
|
|
8219
|
-
submitted.value = false;
|
|
8220
8585
|
emits("update:modelValue", formData.value);
|
|
8221
8586
|
};
|
|
8222
8587
|
const cancel = () => {
|
|
8223
8588
|
formData.value = structuredClone(toRaw(initialFormData.value));
|
|
8224
|
-
submitted.value = false;
|
|
8225
8589
|
emits("update:modelValue", formData.value);
|
|
8226
8590
|
emits("cancel");
|
|
8227
8591
|
};
|
|
8228
|
-
const onValid = (v) => {
|
|
8229
|
-
submitted.value = false;
|
|
8230
|
-
valid.value = v;
|
|
8231
|
-
emits("valid", v);
|
|
8232
|
-
};
|
|
8233
8592
|
const title = computed(() => {
|
|
8234
8593
|
if (!properties.updateTitle) return properties.createTitle;
|
|
8235
8594
|
return recordId.value ? properties.updateTitle : properties.createTitle;
|
|
8236
8595
|
});
|
|
8596
|
+
const onErrors = (errors) => {
|
|
8597
|
+
emits("errors", errors);
|
|
8598
|
+
valid.value = isEmpty(errors);
|
|
8599
|
+
};
|
|
8600
|
+
watch(valid, (newValid, oldValid) => {
|
|
8601
|
+
if (newValid !== oldValid) {
|
|
8602
|
+
emits("valid", newValid);
|
|
8603
|
+
}
|
|
8604
|
+
});
|
|
8237
8605
|
return (_ctx, _cache) => {
|
|
8238
8606
|
return openBlock(), createBlock(unref(Collapse), {
|
|
8239
8607
|
title: title.value,
|
|
8240
|
-
"height-full": _ctx.fullHeight
|
|
8608
|
+
"height-full": _ctx.fullHeight,
|
|
8609
|
+
scrollable: true
|
|
8241
8610
|
}, {
|
|
8242
8611
|
default: withCtx(() => [
|
|
8243
8612
|
createElementVNode("div", {
|
|
@@ -8248,24 +8617,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8248
8617
|
}, [
|
|
8249
8618
|
createVNode(_sfc_main$2, {
|
|
8250
8619
|
id: `form_${_ctx.id}`,
|
|
8620
|
+
ref_key: "formRef",
|
|
8621
|
+
ref: formRef,
|
|
8251
8622
|
"form-data": formData.value,
|
|
8252
8623
|
schema: _ctx.schema,
|
|
8253
8624
|
"ui-schema": _ctx.uiSchema,
|
|
8625
|
+
"error-mode": _ctx.errorMode,
|
|
8254
8626
|
onChange: updateValue,
|
|
8255
|
-
onValid: _cache[0] || (_cache[0] = ($event) => onValid($event)),
|
|
8256
8627
|
onSubmit: save,
|
|
8257
|
-
onErrors
|
|
8258
|
-
onEvents: _cache[
|
|
8259
|
-
}, null, 8, ["id", "form-data", "schema", "ui-schema"])
|
|
8628
|
+
onErrors,
|
|
8629
|
+
onEvents: _cache[0] || (_cache[0] = ($event) => emits("events", $event))
|
|
8630
|
+
}, null, 8, ["id", "form-data", "schema", "ui-schema", "error-mode"])
|
|
8260
8631
|
], 2),
|
|
8261
|
-
createElementVNode("div", _hoisted_1, [
|
|
8262
|
-
createElementVNode("div", null, [
|
|
8263
|
-
!valid.value && submitted.value ? (openBlock(), createBlock(unref(Alert), {
|
|
8264
|
-
key: 0,
|
|
8265
|
-
message: "The form is not valid",
|
|
8266
|
-
type: "error"
|
|
8267
|
-
})) : createCommentVNode("", true)
|
|
8268
|
-
]),
|
|
8632
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
8269
8633
|
createElementVNode("div", _hoisted_2, [
|
|
8270
8634
|
renderSlot(_ctx.$slots, "actions"),
|
|
8271
8635
|
recordId.value ? (openBlock(), createBlock(unref(Btn), {
|
|
@@ -8274,7 +8638,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8274
8638
|
outline: true,
|
|
8275
8639
|
onClick: cancel
|
|
8276
8640
|
}, {
|
|
8277
|
-
default: withCtx(() => [..._cache[
|
|
8641
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [
|
|
8278
8642
|
createTextVNode(" Cancel ", -1)
|
|
8279
8643
|
])]),
|
|
8280
8644
|
_: 1
|
|
@@ -8284,7 +8648,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8284
8648
|
outline: true,
|
|
8285
8649
|
onClick: clear
|
|
8286
8650
|
}, {
|
|
8287
|
-
default: withCtx(() => [..._cache[
|
|
8651
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
|
8288
8652
|
createTextVNode(" Clear ", -1)
|
|
8289
8653
|
])]),
|
|
8290
8654
|
_: 1
|
|
@@ -8292,10 +8656,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8292
8656
|
createVNode(unref(Btn), {
|
|
8293
8657
|
"aria-label": "Save",
|
|
8294
8658
|
color: unref(Color).primary,
|
|
8295
|
-
disabled:
|
|
8659
|
+
disabled: !valid.value,
|
|
8296
8660
|
onClick: save
|
|
8297
8661
|
}, {
|
|
8298
|
-
default: withCtx(() => [..._cache[
|
|
8662
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
8299
8663
|
createTextVNode(" Save ", -1)
|
|
8300
8664
|
])]),
|
|
8301
8665
|
_: 1
|
|
@@ -8309,216 +8673,175 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
8309
8673
|
};
|
|
8310
8674
|
}
|
|
8311
8675
|
});
|
|
8676
|
+
const FormWithTableProperties = {
|
|
8677
|
+
/** Unique identifier used to namespace the inner table element. */
|
|
8678
|
+
id: { type: String, required: true },
|
|
8679
|
+
/** Heading displayed above the table. */
|
|
8680
|
+
tableTitle: { type: String, required: true },
|
|
8681
|
+
/** Title shown in the modal when creating a new record. */
|
|
8682
|
+
createTitle: { type: String, required: true },
|
|
8683
|
+
/** Title shown in the modal when editing a record. Falls back to `createTitle` when omitted. */
|
|
8684
|
+
updateTitle: { type: String },
|
|
8685
|
+
/** Override URI used to fetch table data. Defaults to `uri` when omitted. */
|
|
8686
|
+
dataUri: { type: String },
|
|
8687
|
+
/** Custom row actions rendered in the table. */
|
|
8688
|
+
tableActions: { type: Array },
|
|
8689
|
+
/** JSON Forms layout for the create/edit modal form. */
|
|
8690
|
+
form: { type: Object },
|
|
8691
|
+
/** JSON Forms layout for the table. */
|
|
8692
|
+
table: { type: Object },
|
|
8693
|
+
/** JSON Forms layout for the table filter. */
|
|
8694
|
+
filter: { type: Object },
|
|
8695
|
+
/** REST endpoint used by `FormStore` for CRUD operations. */
|
|
8696
|
+
uri: { type: String },
|
|
8697
|
+
/** Default data pre-filled when creating a new record. */
|
|
8698
|
+
initialData: { type: Object, default: () => ({}) },
|
|
8699
|
+
/** When validation errors are shown in the modal form. */
|
|
8700
|
+
errorMode: {
|
|
8701
|
+
type: String,
|
|
8702
|
+
default: "onBlur"
|
|
8703
|
+
}
|
|
8704
|
+
};
|
|
8705
|
+
const FormWithTableEmits = [
|
|
8706
|
+
/** Emitted when a row is selected for editing (listener-based routing). */
|
|
8707
|
+
"editData",
|
|
8708
|
+
/** Emitted after a record is saved through the modal. */
|
|
8709
|
+
"save",
|
|
8710
|
+
/** Emitted after a record is deleted. */
|
|
8711
|
+
"delete",
|
|
8712
|
+
/** Emitted when a custom renderer dispatches a form event. */
|
|
8713
|
+
"events",
|
|
8714
|
+
/** Emitted when a custom edit handler is registered. */
|
|
8715
|
+
"custom:edit",
|
|
8716
|
+
/** Emitted when a custom create handler is registered. */
|
|
8717
|
+
"custom:create"
|
|
8718
|
+
];
|
|
8719
|
+
const _hoisted_1 = { class: "flex justify-between items-center mb-2" };
|
|
8312
8720
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8313
|
-
__name: "
|
|
8314
|
-
props:
|
|
8315
|
-
|
|
8316
|
-
saveLabel: { default: "save" },
|
|
8317
|
-
cancelLabel: { default: "cancel" },
|
|
8318
|
-
schema: {},
|
|
8319
|
-
uiSchema: {},
|
|
8320
|
-
modalSize: { default: "md" },
|
|
8321
|
-
onClose: {},
|
|
8322
|
-
onEvents: {},
|
|
8323
|
-
data: {}
|
|
8324
|
-
}, {
|
|
8325
|
-
"modelValue": {},
|
|
8326
|
-
"modelModifiers": {}
|
|
8327
|
-
}),
|
|
8328
|
-
emits: /* @__PURE__ */ mergeModels(["closeModal", "events"], ["update:modelValue"]),
|
|
8721
|
+
__name: "FormWithTable",
|
|
8722
|
+
props: FormWithTableProperties,
|
|
8723
|
+
emits: FormWithTableEmits,
|
|
8329
8724
|
setup(__props, { emit: __emit }) {
|
|
8330
8725
|
const properties = __props;
|
|
8331
|
-
const
|
|
8332
|
-
const
|
|
8333
|
-
const
|
|
8334
|
-
const
|
|
8335
|
-
const
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8726
|
+
const emit = __emit;
|
|
8727
|
+
const reload = ref(0);
|
|
8728
|
+
const resolvedForm = computed(() => properties.form);
|
|
8729
|
+
const resolvedTable = computed(() => properties.table);
|
|
8730
|
+
const resolvedFilter = computed(() => properties.filter);
|
|
8731
|
+
const resolvedUri = computed(() => properties.uri);
|
|
8732
|
+
let store = new FormStore(resolvedUri.value ?? "");
|
|
8733
|
+
watch(resolvedUri, (uri) => {
|
|
8734
|
+
store = new FormStore(uri ?? "");
|
|
8735
|
+
});
|
|
8736
|
+
const hasEdit = hasCustomEventListener("editData");
|
|
8737
|
+
const customEdit = hasCustomEventListener("custom:edit");
|
|
8738
|
+
const customCreate = hasCustomEventListener("custom:create");
|
|
8739
|
+
const edit = (data) => {
|
|
8740
|
+
if (customEdit) {
|
|
8741
|
+
emit("custom:edit", data);
|
|
8742
|
+
return;
|
|
8743
|
+
}
|
|
8744
|
+
if (hasEdit) {
|
|
8745
|
+
emit("editData", data);
|
|
8746
|
+
return;
|
|
8747
|
+
}
|
|
8748
|
+
openModal(data);
|
|
8342
8749
|
};
|
|
8343
|
-
const
|
|
8344
|
-
|
|
8345
|
-
|
|
8750
|
+
const create = () => {
|
|
8751
|
+
if (customCreate) {
|
|
8752
|
+
emit("custom:create");
|
|
8753
|
+
return;
|
|
8754
|
+
}
|
|
8755
|
+
openModal();
|
|
8346
8756
|
};
|
|
8347
|
-
const
|
|
8348
|
-
|
|
8757
|
+
const deleteFn = (data) => {
|
|
8758
|
+
ModalService.showConfirm({
|
|
8759
|
+
title: "Delete record",
|
|
8760
|
+
message: "Are you sure to delete, the data will be lost?",
|
|
8761
|
+
onClose: (result) => {
|
|
8762
|
+
if (result.confirmed) {
|
|
8763
|
+
store.delete(data).then(() => {
|
|
8764
|
+
reload.value = Date.now();
|
|
8765
|
+
emit("delete", data);
|
|
8766
|
+
});
|
|
8767
|
+
}
|
|
8768
|
+
}
|
|
8769
|
+
});
|
|
8349
8770
|
};
|
|
8350
|
-
const
|
|
8351
|
-
if (!
|
|
8352
|
-
|
|
8771
|
+
const openModal = (formData) => {
|
|
8772
|
+
if (!resolvedForm.value) return;
|
|
8773
|
+
const isUpdate = !!formData?.id;
|
|
8774
|
+
JsonFormModalService.openModal({
|
|
8775
|
+
schema: resolvedForm.value.schema,
|
|
8776
|
+
uiSchema: resolvedForm.value.uiSchema,
|
|
8777
|
+
modalSize: resolvedForm.value.modalSize,
|
|
8778
|
+
initialData: formData ?? properties.initialData,
|
|
8779
|
+
modalTitle: (isUpdate ? properties.updateTitle ?? properties.createTitle : properties.createTitle) ?? "",
|
|
8780
|
+
onClose: (result) => {
|
|
8781
|
+
if (result && result.valid) {
|
|
8782
|
+
store.save(formData?.id, result.data).then(() => {
|
|
8783
|
+
reload.value = Date.now();
|
|
8784
|
+
emit("save", { id: formData?.id, data: result.data });
|
|
8785
|
+
});
|
|
8786
|
+
}
|
|
8787
|
+
},
|
|
8788
|
+
onEvents: (payload) => emit("events", payload)
|
|
8789
|
+
});
|
|
8353
8790
|
};
|
|
8354
8791
|
return (_ctx, _cache) => {
|
|
8355
|
-
return openBlock(),
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
"
|
|
8369
|
-
|
|
8370
|
-
onChange,
|
|
8371
|
-
onEvents: _cache[2] || (_cache[2] = ($event) => emits("events", $event))
|
|
8372
|
-
}, null, 8, ["id", "modelValue", "schema", "ui-schema"]),
|
|
8373
|
-
renderSlot(_ctx.$slots, "content-after")
|
|
8374
|
-
]),
|
|
8375
|
-
actions: withCtx(() => [
|
|
8376
|
-
createVNode(unref(Btn), {
|
|
8377
|
-
color: unref(Color).secondary,
|
|
8378
|
-
outline: true,
|
|
8379
|
-
"aria-label": "Cancel",
|
|
8380
|
-
onClick: onCancel
|
|
8381
|
-
}, {
|
|
8382
|
-
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
8383
|
-
createTextVNode(" Cancel ", -1)
|
|
8384
|
-
])]),
|
|
8385
|
-
_: 1
|
|
8386
|
-
}, 8, ["color"]),
|
|
8387
|
-
createVNode(unref(Btn), {
|
|
8388
|
-
disabled: !hasBeenValid.value,
|
|
8389
|
-
"aria-label": "Save",
|
|
8390
|
-
onClick: onSubmit
|
|
8391
|
-
}, {
|
|
8392
|
-
default: withCtx(() => [..._cache[4] || (_cache[4] = [
|
|
8393
|
-
createTextVNode(" Save ", -1)
|
|
8394
|
-
])]),
|
|
8395
|
-
_: 1
|
|
8396
|
-
}, 8, ["disabled"])
|
|
8792
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
8793
|
+
createElementVNode("div", _hoisted_1, [
|
|
8794
|
+
createElementVNode("h1", null, toDisplayString(_ctx.tableTitle), 1),
|
|
8795
|
+
createElementVNode("div", null, [
|
|
8796
|
+
createVNode(unref(Btn), {
|
|
8797
|
+
icon: unref(IconEnum).Plus,
|
|
8798
|
+
outline: true,
|
|
8799
|
+
onClick: create
|
|
8800
|
+
}, {
|
|
8801
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
8802
|
+
createTextVNode(" Add new record ", -1)
|
|
8803
|
+
])]),
|
|
8804
|
+
_: 1
|
|
8805
|
+
}, 8, ["icon"])
|
|
8806
|
+
])
|
|
8397
8807
|
]),
|
|
8398
|
-
|
|
8399
|
-
|
|
8808
|
+
resolvedTable.value ? (openBlock(), createBlock(unref(Card), { key: 0 }, {
|
|
8809
|
+
default: withCtx(() => [
|
|
8810
|
+
resolvedUri.value ? (openBlock(), createBlock(unref(_sfc_main$g), {
|
|
8811
|
+
key: 0,
|
|
8812
|
+
id: `form_table_${_ctx.id}`,
|
|
8813
|
+
"ui-schema": resolvedTable.value.uiSchema,
|
|
8814
|
+
schema: resolvedTable.value.schema,
|
|
8815
|
+
"filter-ui-schema": resolvedFilter.value?.uiSchema,
|
|
8816
|
+
"filter-schema": resolvedFilter.value?.schema,
|
|
8817
|
+
uri: _ctx.dataUri ?? resolvedUri.value,
|
|
8818
|
+
reload: reload.value,
|
|
8819
|
+
actions: _ctx.tableActions,
|
|
8820
|
+
onEdit: edit,
|
|
8821
|
+
onDelete: deleteFn
|
|
8822
|
+
}, null, 8, ["id", "ui-schema", "schema", "filter-ui-schema", "filter-schema", "uri", "reload", "actions"])) : createCommentVNode("", true)
|
|
8823
|
+
]),
|
|
8824
|
+
_: 1
|
|
8825
|
+
})) : createCommentVNode("", true)
|
|
8826
|
+
], 64);
|
|
8400
8827
|
};
|
|
8401
8828
|
}
|
|
8402
8829
|
});
|
|
8403
|
-
class FormModalService {
|
|
8404
|
-
static openModal({
|
|
8405
|
-
initialData,
|
|
8406
|
-
modalTitle,
|
|
8407
|
-
schema,
|
|
8408
|
-
uiSchema,
|
|
8409
|
-
modalSize,
|
|
8410
|
-
onClose,
|
|
8411
|
-
onEvents
|
|
8412
|
-
}) {
|
|
8413
|
-
ModalService.openModal({
|
|
8414
|
-
component: _sfc_main,
|
|
8415
|
-
props: {
|
|
8416
|
-
schema,
|
|
8417
|
-
uiSchema,
|
|
8418
|
-
modalSize,
|
|
8419
|
-
data: initialData ?? {},
|
|
8420
|
-
modalTitle,
|
|
8421
|
-
onClose,
|
|
8422
|
-
onEvents
|
|
8423
|
-
}
|
|
8424
|
-
});
|
|
8425
|
-
}
|
|
8426
|
-
}
|
|
8427
|
-
const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
8428
|
-
const notificationEntity = options.notification?.entityType || "entity";
|
|
8429
|
-
const notificationStore = options.notification?.notification ?? null;
|
|
8430
|
-
const getDataUri = (...suffix) => {
|
|
8431
|
-
return [formSchemaModel.uri, ...suffix].join("/");
|
|
8432
|
-
};
|
|
8433
|
-
const handleSuccess = (message) => {
|
|
8434
|
-
notificationStore?.success(message);
|
|
8435
|
-
};
|
|
8436
|
-
const handleError = (error2, message) => {
|
|
8437
|
-
console.error(error2);
|
|
8438
|
-
notificationStore?.error(message);
|
|
8439
|
-
throw new Error(error2);
|
|
8440
|
-
};
|
|
8441
|
-
const create = (object2, options2) => {
|
|
8442
|
-
return httpRequest.post(getDataUri(), object2, options2).then((response) => {
|
|
8443
|
-
handleSuccess(`Created ${notificationEntity}`);
|
|
8444
|
-
return response.data;
|
|
8445
|
-
}).catch((response) => {
|
|
8446
|
-
handleError(response, `Failed to create ${notificationEntity}`);
|
|
8447
|
-
});
|
|
8448
|
-
};
|
|
8449
|
-
const patch = (id, object2, options2) => {
|
|
8450
|
-
return httpRequest.patch(getDataUri(id), object2, options2).then((response) => {
|
|
8451
|
-
handleSuccess(`Saved ${notificationEntity}`);
|
|
8452
|
-
return response.data;
|
|
8453
|
-
}).catch((response) => {
|
|
8454
|
-
handleError(response, `Failed to save ${notificationEntity}`);
|
|
8455
|
-
});
|
|
8456
|
-
};
|
|
8457
|
-
const get = (id, options2) => {
|
|
8458
|
-
return httpRequest.get(getDataUri(id), options2).then((response) => {
|
|
8459
|
-
return response.data;
|
|
8460
|
-
}).catch((response) => {
|
|
8461
|
-
handleError(response, `Failed to load data`);
|
|
8462
|
-
});
|
|
8463
|
-
};
|
|
8464
|
-
const _delete = (id, options2) => {
|
|
8465
|
-
return httpRequest.delete(getDataUri(id), options2).then((response) => {
|
|
8466
|
-
handleSuccess(`${notificationEntity} deleted`);
|
|
8467
|
-
return response;
|
|
8468
|
-
}).catch((response) => {
|
|
8469
|
-
handleError(response, `Failed to delete ${notificationEntity}`);
|
|
8470
|
-
});
|
|
8471
|
-
};
|
|
8472
|
-
const createMulti = (objects, options2) => {
|
|
8473
|
-
return Promise.all(
|
|
8474
|
-
objects.map((object2) => httpRequest.post(getDataUri(), object2, options2))
|
|
8475
|
-
).then((response) => {
|
|
8476
|
-
handleSuccess(`Created ${notificationEntity}`);
|
|
8477
|
-
return response.data;
|
|
8478
|
-
}).catch((response) => {
|
|
8479
|
-
handleError(response, `Failed to save ${notificationEntity}`);
|
|
8480
|
-
});
|
|
8481
|
-
};
|
|
8482
|
-
return { create, patch, createMulti, delete: _delete, get };
|
|
8483
|
-
};
|
|
8484
8830
|
export {
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
_sfc_main$
|
|
8488
|
-
_sfc_main$
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
_sfc_main as
|
|
8492
|
-
|
|
8493
|
-
FormStore,
|
|
8494
|
-
_sfc_main$1 as FormWithActions,
|
|
8495
|
-
FormWithActionsEmits,
|
|
8496
|
-
FormWithActionsProperties,
|
|
8497
|
-
_sfc_main$3 as FormWithTableComponent,
|
|
8498
|
-
FormWithTableEmits,
|
|
8499
|
-
FormWithTableProperties,
|
|
8500
|
-
_sfc_main$h as IntegerControlRenderer,
|
|
8501
|
-
_sfc_main$f as MultiSelectControlRender,
|
|
8502
|
-
_sfc_main$e as NumberControlRenderer,
|
|
8503
|
-
_sfc_main$d as SelectControlRender,
|
|
8504
|
-
_sfc_main$c as StringControlRenderer,
|
|
8505
|
-
_sfc_main$4 as TableComponent,
|
|
8831
|
+
FormModalEmits,
|
|
8832
|
+
FormModalProperties,
|
|
8833
|
+
_sfc_main$2 as JsonForm,
|
|
8834
|
+
_sfc_main$d as JsonFormModal,
|
|
8835
|
+
JsonFormModalService,
|
|
8836
|
+
_sfc_main$1 as JsonFormWithActions,
|
|
8837
|
+
_sfc_main as JsonFormWithTable,
|
|
8838
|
+
_sfc_main$g as TableComponent,
|
|
8506
8839
|
TableComponentEmits,
|
|
8507
8840
|
TableComponentProperties,
|
|
8508
|
-
arrayRenderers,
|
|
8509
|
-
controlRenderers,
|
|
8510
8841
|
createRepository,
|
|
8511
|
-
|
|
8512
|
-
isAutoCompleteControl,
|
|
8513
|
-
isBooleanControl,
|
|
8514
|
-
isCustomControl,
|
|
8515
|
-
isMarkdownControl,
|
|
8516
|
-
isMultiselectControl,
|
|
8517
|
-
isSelectControl,
|
|
8518
|
-
isStringFormat,
|
|
8519
|
-
isTextAreaControl,
|
|
8520
|
-
layoutRenderers,
|
|
8521
|
-
_sfc_main$g as markdownControlRenderer,
|
|
8842
|
+
formatError,
|
|
8522
8843
|
provideFormEvents,
|
|
8523
|
-
|
|
8844
|
+
registerZodErrorMap,
|
|
8845
|
+
useFormEvents,
|
|
8846
|
+
customRenderes as veeRenderers
|
|
8524
8847
|
};
|