@stsdti/funky-ui-kit 1.8.5 → 1.8.7
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/dist/funky-ui-kit.css +1 -1
- package/dist/funky-ui-kit.esm.js +59 -10
- package/dist/funky-ui-kit.esm.js.map +1 -1
- package/package.json +1 -1
- package/web-types.json +7 -1
package/dist/funky-ui-kit.esm.js
CHANGED
|
@@ -67202,6 +67202,29 @@ var BaseRepository = class BaseRepository {
|
|
|
67202
67202
|
insert = (data) => {
|
|
67203
67203
|
return this.submit("post", this.fullURL, data);
|
|
67204
67204
|
};
|
|
67205
|
+
buildFormDataMultipart = (data, method = null) => {
|
|
67206
|
+
const formData = new FormData();
|
|
67207
|
+
if (!data) return formData;
|
|
67208
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
67209
|
+
if (value instanceof File || value instanceof FileList) return;
|
|
67210
|
+
if (typeof value === "object") {
|
|
67211
|
+
formData.append(key, value ? JSON.stringify(value) : "");
|
|
67212
|
+
return;
|
|
67213
|
+
}
|
|
67214
|
+
formData.append(key, value ?? "");
|
|
67215
|
+
});
|
|
67216
|
+
if (method) formData.append("_method", method);
|
|
67217
|
+
this.appendFormDataMultipart(formData, data);
|
|
67218
|
+
return formData;
|
|
67219
|
+
};
|
|
67220
|
+
updateToFormDataMultipart = (id, data) => {
|
|
67221
|
+
const formData = this.buildFormDataMultipart(data, "PATCH");
|
|
67222
|
+
return this.submitMultipart("post", `${this.fullURL}/${id}`, formData);
|
|
67223
|
+
};
|
|
67224
|
+
insertToFormDataMultipart = (data) => {
|
|
67225
|
+
const formData = this.buildFormDataMultipart(data, "POST");
|
|
67226
|
+
return this.submitMultipart("post", this.fullURL, formData);
|
|
67227
|
+
};
|
|
67205
67228
|
updateBulk = (data) => {
|
|
67206
67229
|
return this.submit("patch", this.fullURL, data);
|
|
67207
67230
|
};
|
|
@@ -67245,6 +67268,31 @@ var BaseRepository = class BaseRepository {
|
|
|
67245
67268
|
});
|
|
67246
67269
|
return requestPromise;
|
|
67247
67270
|
}
|
|
67271
|
+
submitMultipart(method, url, data = null, params = null, throttleMs = 400, axiosConfig = null) {
|
|
67272
|
+
if (!(data instanceof FormData)) throw new Error("submitMultipart requires data to be an instance of FormData");
|
|
67273
|
+
return this.axios({
|
|
67274
|
+
method,
|
|
67275
|
+
url,
|
|
67276
|
+
data,
|
|
67277
|
+
params,
|
|
67278
|
+
crossDomain: true,
|
|
67279
|
+
...axiosConfig ?? {},
|
|
67280
|
+
headers: {
|
|
67281
|
+
"Content-Type": "multipart/form-data",
|
|
67282
|
+
"X-Process-Multipart": "true",
|
|
67283
|
+
...axiosConfig?.headers ?? {}
|
|
67284
|
+
}
|
|
67285
|
+
});
|
|
67286
|
+
}
|
|
67287
|
+
appendFormDataMultipart(formData, data, rootName = "") {
|
|
67288
|
+
if (data instanceof FileList) throw new Error("FileList is not supported in multipart payload. Please provide a File instead.");
|
|
67289
|
+
else if (data instanceof File) formData.append(rootName, data);
|
|
67290
|
+
else if (Array.isArray(data)) for (let i = 0; i < data.length; i++) this.appendFormDataMultipart(formData, data[i], `${rootName}/${i}`);
|
|
67291
|
+
else if (typeof data === "object" && data !== null && !(data instanceof Date)) {
|
|
67292
|
+
for (const key in data) if (Object.hasOwn(data, key)) if (rootName === "") this.appendFormDataMultipart(formData, data[key], key);
|
|
67293
|
+
else this.appendFormDataMultipart(formData, data[key], `${rootName}/${key}`);
|
|
67294
|
+
}
|
|
67295
|
+
}
|
|
67248
67296
|
objectToQueryString(queryParameters) {
|
|
67249
67297
|
return Object.keys(queryParameters).map((key) => key + "=" + queryParameters[key]).join("&");
|
|
67250
67298
|
}
|
|
@@ -73228,22 +73276,23 @@ var AppInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
73228
73276
|
}),
|
|
73229
73277
|
emits: /*@__PURE__*/ mergeModels(["onSubmit", "blur"], ["update:modelValue"]),
|
|
73230
73278
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
73231
|
-
useSlots();
|
|
73279
|
+
const slots = useSlots();
|
|
73232
73280
|
let modelValue = useModel(__props, "modelValue");
|
|
73233
73281
|
const props = __props;
|
|
73234
73282
|
const emits = __emit;
|
|
73283
|
+
const hasLeftIcon = computed(() => !!props.leftIcon || !!slots.iconLeft);
|
|
73235
73284
|
const clearStyle = computed(() => ({ "margin-right": isTypeNumber.value ? "2px" : "8px" }));
|
|
73236
73285
|
const inputClass = computed(() => ({
|
|
73237
73286
|
"input-empty no-spinner flex-1": true,
|
|
73238
|
-
"pl-15": !
|
|
73287
|
+
"pl-15": !hasLeftIcon.value
|
|
73239
73288
|
}));
|
|
73240
73289
|
const inputContainerClass = computed(() => {
|
|
73241
73290
|
return {
|
|
73242
73291
|
"flex-center-vertical form-control": true,
|
|
73243
73292
|
"disabled-element": props.disabled,
|
|
73244
|
-
"p-0": !
|
|
73245
|
-
"no-padding-right": !!
|
|
73246
|
-
"gap-1": !!
|
|
73293
|
+
"p-0": !hasLeftIcon.value,
|
|
73294
|
+
"no-padding-right": !!hasLeftIcon.value,
|
|
73295
|
+
"gap-1": !!hasLeftIcon.value
|
|
73247
73296
|
};
|
|
73248
73297
|
});
|
|
73249
73298
|
const isTypeNumber = computed(() => props.type === "number");
|
|
@@ -73289,7 +73338,7 @@ var AppInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
73289
73338
|
return openBlock(), createBlock(AppFormElement_default, normalizeProps(guardReactiveProps(unref(formElementProps))), createSlots({
|
|
73290
73339
|
"help-block": withCtx(() => [renderSlot(_ctx.$slots, "help-block", {}, void 0, true)]),
|
|
73291
73340
|
default: withCtx(() => [createElementVNode("div", { class: normalizeClass(inputContainerClass.value) }, [
|
|
73292
|
-
|
|
73341
|
+
hasLeftIcon.value ? (openBlock(), createElementBlock("div", _hoisted_1$59, [renderSlot(_ctx.$slots, "iconLeft", {}, () => [createVNode(_component_app_icon, { value: __props.leftIcon }, null, 8, ["value"])], true)])) : createCommentVNode("", true),
|
|
73293
73342
|
withDirectives(createElementVNode("input", mergeProps({
|
|
73294
73343
|
ref_key: "inputElement",
|
|
73295
73344
|
ref: inputElement,
|
|
@@ -73327,7 +73376,7 @@ var AppInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
73327
73376
|
})]), 1040);
|
|
73328
73377
|
};
|
|
73329
73378
|
}
|
|
73330
|
-
}, [["__scopeId", "data-v-
|
|
73379
|
+
}, [["__scopeId", "data-v-7a5068b0"]]);
|
|
73331
73380
|
//#endregion
|
|
73332
73381
|
//#region src/components/small/app-link/AppLink.vue
|
|
73333
73382
|
var _hoisted_1$58 = {
|
|
@@ -125794,7 +125843,7 @@ var useFormEvent = {
|
|
|
125794
125843
|
fetched: "fetched"
|
|
125795
125844
|
};
|
|
125796
125845
|
function useForm(config, emits) {
|
|
125797
|
-
const { onEvent, model = null, shouldFetchOnMount: defaultShouldFetchOnMount = true, shouldEmitOnMount = true, useInModal = false } = config;
|
|
125846
|
+
const { onEvent, model = null, shouldFetchOnMount: defaultShouldFetchOnMount = true, shouldEmitOnMount = true, useInModal = false, useMultipart = false } = config;
|
|
125798
125847
|
const { fetchItem: fetchItem_, saveItem: saveItem_, deleteItem: deleteItem_ } = config;
|
|
125799
125848
|
const { validationPath: globalValidationPath } = config;
|
|
125800
125849
|
const repository = model?.getRepository();
|
|
@@ -125866,8 +125915,8 @@ function useForm(config, emits) {
|
|
|
125866
125915
|
let newItem = (0, import_lodash.cloneDeep)(item.value);
|
|
125867
125916
|
newItem = await transformer?.transformToApi?.(newItem);
|
|
125868
125917
|
let response = null;
|
|
125869
|
-
if (item.value?.id) response = await repository.update(item.value?.id, newItem);
|
|
125870
|
-
else response = await repository.insert(newItem);
|
|
125918
|
+
if (item.value?.id) response = useMultipart ? await repository.updateToFormDataMultipart(item.value?.id, newItem) : await repository.update(item.value?.id, newItem);
|
|
125919
|
+
else response = useMultipart ? await repository.insertToFormDataMultipart(newItem) : await repository.insert(newItem);
|
|
125871
125920
|
isLoading.value = false;
|
|
125872
125921
|
if (!ResponseUtils.isSuccess(response)) return response;
|
|
125873
125922
|
useDraft && formDraft.clearItemFromStorage();
|