@evanschleret/formforgeclient 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +94 -0
- package/dist/module.cjs +112 -0
- package/dist/module.d.cts +20 -0
- package/dist/module.d.mts +20 -0
- package/dist/module.d.ts +20 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +109 -0
- package/dist/runtime/api/categories.d.ts +9 -0
- package/dist/runtime/api/categories.js +83 -0
- package/dist/runtime/api/client.d.ts +45 -0
- package/dist/runtime/api/client.js +148 -0
- package/dist/runtime/api/drafts.d.ts +6 -0
- package/dist/runtime/api/drafts.js +77 -0
- package/dist/runtime/api/http.d.ts +3 -0
- package/dist/runtime/api/http.js +138 -0
- package/dist/runtime/api/index.d.ts +9 -0
- package/dist/runtime/api/index.js +11 -0
- package/dist/runtime/api/management.d.ts +19 -0
- package/dist/runtime/api/management.js +180 -0
- package/dist/runtime/api/request.d.ts +8 -0
- package/dist/runtime/api/request.js +52 -0
- package/dist/runtime/api/responses.d.ts +6 -0
- package/dist/runtime/api/responses.js +61 -0
- package/dist/runtime/api/schema.d.ts +7 -0
- package/dist/runtime/api/schema.js +56 -0
- package/dist/runtime/api/submission.d.ts +11 -0
- package/dist/runtime/api/submission.js +47 -0
- package/dist/runtime/api/upload.d.ts +8 -0
- package/dist/runtime/api/upload.js +37 -0
- package/dist/runtime/composables/index.d.ts +31 -0
- package/dist/runtime/composables/index.js +16 -0
- package/dist/runtime/composables/useFormForgeApi.d.ts +3 -0
- package/dist/runtime/composables/useFormForgeApi.js +4 -0
- package/dist/runtime/composables/useFormForgeBuilder.d.ts +57 -0
- package/dist/runtime/composables/useFormForgeBuilder.js +515 -0
- package/dist/runtime/composables/useFormForgeCategory.d.ts +61 -0
- package/dist/runtime/composables/useFormForgeCategory.js +248 -0
- package/dist/runtime/composables/useFormForgeClient.d.ts +3 -0
- package/dist/runtime/composables/useFormForgeClient.js +200 -0
- package/dist/runtime/composables/useFormForgeDrafts.d.ts +20 -0
- package/dist/runtime/composables/useFormForgeDrafts.js +78 -0
- package/dist/runtime/composables/useFormForgeForm.d.ts +26 -0
- package/dist/runtime/composables/useFormForgeForm.js +114 -0
- package/dist/runtime/composables/useFormForgeGetForm.d.ts +22 -0
- package/dist/runtime/composables/useFormForgeGetForm.js +36 -0
- package/dist/runtime/composables/useFormForgeI18n.d.ts +250 -0
- package/dist/runtime/composables/useFormForgeI18n.js +324 -0
- package/dist/runtime/composables/useFormForgeManagement.d.ts +40 -0
- package/dist/runtime/composables/useFormForgeManagement.js +153 -0
- package/dist/runtime/composables/useFormForgeResolver.d.ts +28 -0
- package/dist/runtime/composables/useFormForgeResolver.js +88 -0
- package/dist/runtime/composables/useFormForgeResponses.d.ts +45 -0
- package/dist/runtime/composables/useFormForgeResponses.js +206 -0
- package/dist/runtime/composables/useFormForgeSchema.d.ts +24 -0
- package/dist/runtime/composables/useFormForgeSchema.js +69 -0
- package/dist/runtime/composables/useFormForgeSubmission.d.ts +12 -0
- package/dist/runtime/composables/useFormForgeSubmission.js +4 -0
- package/dist/runtime/composables/useFormForgeSubmit.d.ts +29 -0
- package/dist/runtime/composables/useFormForgeSubmit.js +291 -0
- package/dist/runtime/composables/useFormForgeUploads.d.ts +21 -0
- package/dist/runtime/composables/useFormForgeUploads.js +37 -0
- package/dist/runtime/composables/useFormForgeWizard.d.ts +20 -0
- package/dist/runtime/composables/useFormForgeWizard.js +83 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.js +14 -0
- package/dist/runtime/plugin.d.ts +3 -0
- package/dist/runtime/plugin.js +175 -0
- package/dist/runtime/renderers/default/FormForgeBuilder.d.vue.ts +40 -0
- package/dist/runtime/renderers/default/FormForgeBuilder.vue +1159 -0
- package/dist/runtime/renderers/default/FormForgeBuilder.vue.d.ts +40 -0
- package/dist/runtime/renderers/default/FormForgeCategoryCreateModal.d.vue.ts +16 -0
- package/dist/runtime/renderers/default/FormForgeCategoryCreateModal.vue +129 -0
- package/dist/runtime/renderers/default/FormForgeCategoryCreateModal.vue.d.ts +16 -0
- package/dist/runtime/renderers/default/FormForgeRenderer.d.vue.ts +72 -0
- package/dist/runtime/renderers/default/FormForgeRenderer.vue +1188 -0
- package/dist/runtime/renderers/default/FormForgeRenderer.vue.d.ts +72 -0
- package/dist/runtime/renderers/default/FormForgeResponse.d.vue.ts +18 -0
- package/dist/runtime/renderers/default/FormForgeResponse.vue +744 -0
- package/dist/runtime/renderers/default/FormForgeResponse.vue.d.ts +18 -0
- package/dist/runtime/renderers/default/index.d.ts +5 -0
- package/dist/runtime/renderers/default/index.js +4 -0
- package/dist/runtime/renderers/index.d.ts +2 -0
- package/dist/runtime/renderers/index.js +1 -0
- package/dist/runtime/types/api.d.ts +129 -0
- package/dist/runtime/types/api.js +0 -0
- package/dist/runtime/types/category.d.ts +42 -0
- package/dist/runtime/types/category.js +0 -0
- package/dist/runtime/types/errors.d.ts +16 -0
- package/dist/runtime/types/errors.js +0 -0
- package/dist/runtime/types/index.d.ts +8 -0
- package/dist/runtime/types/index.js +0 -0
- package/dist/runtime/types/json.d.ts +6 -0
- package/dist/runtime/types/json.js +0 -0
- package/dist/runtime/types/management.d.ts +46 -0
- package/dist/runtime/types/management.js +0 -0
- package/dist/runtime/types/nuxt.d.ts +13 -0
- package/dist/runtime/types/nuxt.js +1 -0
- package/dist/runtime/types/schema.d.ts +93 -0
- package/dist/runtime/types/schema.js +0 -0
- package/dist/runtime/utils/category.d.ts +5 -0
- package/dist/runtime/utils/category.js +101 -0
- package/dist/runtime/utils/form-data.d.ts +8 -0
- package/dist/runtime/utils/form-data.js +64 -0
- package/dist/runtime/utils/object.d.ts +8 -0
- package/dist/runtime/utils/object.js +43 -0
- package/dist/runtime/utils/schema.d.ts +3 -0
- package/dist/runtime/utils/schema.js +309 -0
- package/dist/runtime/utils/submission.d.ts +4 -0
- package/dist/runtime/utils/submission.js +45 -0
- package/dist/runtime/validation/errors.d.ts +5 -0
- package/dist/runtime/validation/errors.js +130 -0
- package/dist/runtime/validation/zod.d.ts +6 -0
- package/dist/runtime/validation/zod.js +203 -0
- package/dist/runtime.cjs +16 -0
- package/dist/runtime.d.cts +1 -0
- package/dist/runtime.d.mts +1 -0
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.mjs +1 -0
- package/dist/types.d.mts +3 -0
- package/package.json +60 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FormForgeBuilderDraft } from '../../composables/useFormForgeBuilder.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
formUuid?: string;
|
|
4
|
+
formKey?: string;
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
loadFormKey?: string;
|
|
7
|
+
loadFormVersion?: string;
|
|
8
|
+
locale?: string;
|
|
9
|
+
modelValue?: Partial<FormForgeBuilderDraft>;
|
|
10
|
+
autosave?: boolean;
|
|
11
|
+
autosaveDelay?: number;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
15
|
+
error: (value: string) => any;
|
|
16
|
+
"update:modelValue": (value: FormForgeBuilderDraft) => any;
|
|
17
|
+
save: (value: FormForgeBuilderDraft) => any;
|
|
18
|
+
publish: (value: FormForgeBuilderDraft) => any;
|
|
19
|
+
unpublish: (value: FormForgeBuilderDraft) => any;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
21
|
+
onError?: ((value: string) => any) | undefined;
|
|
22
|
+
"onUpdate:modelValue"?: ((value: FormForgeBuilderDraft) => any) | undefined;
|
|
23
|
+
onSave?: ((value: FormForgeBuilderDraft) => any) | undefined;
|
|
24
|
+
onPublish?: ((value: FormForgeBuilderDraft) => any) | undefined;
|
|
25
|
+
onUnpublish?: ((value: FormForgeBuilderDraft) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
readonly: boolean;
|
|
28
|
+
locale: string;
|
|
29
|
+
endpoint: string;
|
|
30
|
+
formUuid: string;
|
|
31
|
+
formKey: string;
|
|
32
|
+
loadFormKey: string;
|
|
33
|
+
loadFormVersion: string;
|
|
34
|
+
modelValue: Partial<FormForgeBuilderDraft>;
|
|
35
|
+
autosave: boolean;
|
|
36
|
+
autosaveDelay: number;
|
|
37
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
|
+
declare const _default: typeof __VLS_export;
|
|
39
|
+
export default _default;
|
|
40
|
+
//# sourceMappingURL=FormForgeBuilder.vue.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormForgeCategory } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
locale?: string;
|
|
4
|
+
endpoint?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
7
|
+
close: (value: FormForgeCategory | null) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
9
|
+
onClose?: ((value: FormForgeCategory | null) => any) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
locale: string;
|
|
12
|
+
endpoint: string;
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=FormForgeCategoryCreateModal.vue.d.ts.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "#imports";
|
|
3
|
+
import { useFormForgeCategory } from "../../composables/useFormForgeCategory";
|
|
4
|
+
import { useFormForgeI18n } from "../../composables/useFormForgeI18n";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
locale: { type: String, required: false, default: void 0 },
|
|
7
|
+
endpoint: { type: String, required: false, default: void 0 }
|
|
8
|
+
});
|
|
9
|
+
const emit = defineEmits(["close"]);
|
|
10
|
+
const { t } = useFormForgeI18n({
|
|
11
|
+
locale: () => props.locale
|
|
12
|
+
});
|
|
13
|
+
const categoryManager = useFormForgeCategory({
|
|
14
|
+
immediate: false,
|
|
15
|
+
endpoint: props.endpoint
|
|
16
|
+
});
|
|
17
|
+
const name = ref("");
|
|
18
|
+
const description = ref("");
|
|
19
|
+
const isActive = ref(true);
|
|
20
|
+
const nameError = computed(() => {
|
|
21
|
+
return name.value.trim() === "" ? t("builder.categoryModal.nameRequired") : void 0;
|
|
22
|
+
});
|
|
23
|
+
function close() {
|
|
24
|
+
emit("close", null);
|
|
25
|
+
}
|
|
26
|
+
function firstFieldError(errors) {
|
|
27
|
+
for (const messages of Object.values(errors)) {
|
|
28
|
+
if (messages.length > 0) {
|
|
29
|
+
return messages[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const submitError = computed(() => {
|
|
35
|
+
return firstFieldError(categoryManager.fieldErrors.value) ?? categoryManager.error.value;
|
|
36
|
+
});
|
|
37
|
+
const isSubmitting = computed(() => categoryManager.loading.value);
|
|
38
|
+
async function submit() {
|
|
39
|
+
const trimmedName = name.value.trim();
|
|
40
|
+
if (trimmedName === "") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const trimmedDescription = description.value.trim();
|
|
44
|
+
const payload = {
|
|
45
|
+
name: trimmedName,
|
|
46
|
+
description: trimmedDescription === "" ? null : trimmedDescription,
|
|
47
|
+
is_active: isActive.value
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
const created = await categoryManager.createCategory(payload);
|
|
51
|
+
emit("close", created);
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<UModal
|
|
60
|
+
:title="t('builder.categoryModal.title')"
|
|
61
|
+
:description="t('builder.categoryModal.description')"
|
|
62
|
+
:dismissible="true"
|
|
63
|
+
>
|
|
64
|
+
<template #body>
|
|
65
|
+
<div class="space-y-4">
|
|
66
|
+
<UAlert
|
|
67
|
+
v-if="submitError !== null"
|
|
68
|
+
color="error"
|
|
69
|
+
variant="soft"
|
|
70
|
+
icon="i-lucide-triangle-alert"
|
|
71
|
+
:title="submitError"
|
|
72
|
+
/>
|
|
73
|
+
|
|
74
|
+
<UFormField
|
|
75
|
+
:label="t('builder.categoryModal.nameLabel')"
|
|
76
|
+
:error="nameError"
|
|
77
|
+
required
|
|
78
|
+
>
|
|
79
|
+
<UInput
|
|
80
|
+
v-model="name"
|
|
81
|
+
icon="i-lucide-tag"
|
|
82
|
+
:placeholder="t('builder.categoryModal.namePlaceholder')"
|
|
83
|
+
@keydown.enter.prevent="submit"
|
|
84
|
+
/>
|
|
85
|
+
</UFormField>
|
|
86
|
+
|
|
87
|
+
<UFormField :label="t('builder.categoryModal.descriptionLabel')">
|
|
88
|
+
<UTextarea
|
|
89
|
+
v-model="description"
|
|
90
|
+
:rows="3"
|
|
91
|
+
:placeholder="t('builder.categoryModal.descriptionPlaceholder')"
|
|
92
|
+
/>
|
|
93
|
+
</UFormField>
|
|
94
|
+
|
|
95
|
+
<div class="flex items-center justify-between rounded-lg border border-default px-3 py-2">
|
|
96
|
+
<div class="flex items-center gap-2 text-sm text-toned">
|
|
97
|
+
<UIcon
|
|
98
|
+
name="i-lucide-circle-check-big"
|
|
99
|
+
class="size-4"
|
|
100
|
+
/>
|
|
101
|
+
<span>{{ t("builder.categoryModal.activeLabel") }}</span>
|
|
102
|
+
</div>
|
|
103
|
+
<USwitch v-model="isActive" />
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<template #footer>
|
|
109
|
+
<div class="flex w-full justify-end gap-2">
|
|
110
|
+
<UButton
|
|
111
|
+
color="neutral"
|
|
112
|
+
variant="ghost"
|
|
113
|
+
@click="close"
|
|
114
|
+
>
|
|
115
|
+
{{ t("builder.categoryModal.cancel") }}
|
|
116
|
+
</UButton>
|
|
117
|
+
<UButton
|
|
118
|
+
color="primary"
|
|
119
|
+
icon="i-lucide-folder-plus"
|
|
120
|
+
:loading="isSubmitting"
|
|
121
|
+
:disabled="nameError !== void 0 || isSubmitting"
|
|
122
|
+
@click="submit"
|
|
123
|
+
>
|
|
124
|
+
{{ t("builder.categoryModal.create") }}
|
|
125
|
+
</UButton>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
128
|
+
</UModal>
|
|
129
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormForgeCategory } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
locale?: string;
|
|
4
|
+
endpoint?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
7
|
+
close: (value: FormForgeCategory | null) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
9
|
+
onClose?: ((value: FormForgeCategory | null) => any) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
locale: string;
|
|
12
|
+
endpoint: string;
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=FormForgeCategoryCreateModal.vue.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { FormForgeClientConfig, FormForgeDatetimeMode, FormForgeFormSchema, FormForgeSubmissionPayload, FormForgeSubmissionResponse, FormForgeUploadMode } from '../../types/index.js';
|
|
2
|
+
interface FormForgeValidationError {
|
|
3
|
+
name: string;
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
type FormForgeValidationHandler = (state: FormForgeSubmissionPayload) => FormForgeValidationError[] | Promise<FormForgeValidationError[]>;
|
|
7
|
+
type FormForgeProgressVariant = 'stepper' | 'progress';
|
|
8
|
+
interface Props {
|
|
9
|
+
schema?: FormForgeFormSchema | {
|
|
10
|
+
value: FormForgeFormSchema | null;
|
|
11
|
+
};
|
|
12
|
+
modelValue?: FormForgeSubmissionPayload | {
|
|
13
|
+
value: FormForgeSubmissionPayload;
|
|
14
|
+
};
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
zodSchema?: object | {
|
|
17
|
+
value: object | undefined;
|
|
18
|
+
};
|
|
19
|
+
validate?: FormForgeValidationHandler;
|
|
20
|
+
datetimeMode?: FormForgeDatetimeMode;
|
|
21
|
+
formKey?: string;
|
|
22
|
+
formVersion?: string;
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
clientConfig?: FormForgeClientConfig;
|
|
25
|
+
submitLabel?: string;
|
|
26
|
+
showSubmit?: boolean;
|
|
27
|
+
simulation?: boolean;
|
|
28
|
+
uploadMode?: FormForgeUploadMode;
|
|
29
|
+
clearAfterSubmit?: boolean;
|
|
30
|
+
showProgress?: boolean;
|
|
31
|
+
progressVariant?: FormForgeProgressVariant;
|
|
32
|
+
showAlertOnError?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
35
|
+
submit: (value: FormForgeSubmissionPayload) => any;
|
|
36
|
+
error: (value: string) => any;
|
|
37
|
+
"update:modelValue": (value: FormForgeSubmissionPayload) => any;
|
|
38
|
+
submitted: (value: FormForgeSubmissionResponse) => any;
|
|
39
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
40
|
+
onSubmit?: ((value: FormForgeSubmissionPayload) => any) | undefined;
|
|
41
|
+
onError?: ((value: string) => any) | undefined;
|
|
42
|
+
"onUpdate:modelValue"?: ((value: FormForgeSubmissionPayload) => any) | undefined;
|
|
43
|
+
onSubmitted?: ((value: FormForgeSubmissionResponse) => any) | undefined;
|
|
44
|
+
}>, {
|
|
45
|
+
disabled: boolean;
|
|
46
|
+
schema: FormForgeFormSchema | {
|
|
47
|
+
value: FormForgeFormSchema | null;
|
|
48
|
+
};
|
|
49
|
+
uploadMode: FormForgeUploadMode;
|
|
50
|
+
datetimeMode: FormForgeDatetimeMode;
|
|
51
|
+
endpoint: string;
|
|
52
|
+
clientConfig: FormForgeClientConfig;
|
|
53
|
+
formKey: string;
|
|
54
|
+
modelValue: FormForgeSubmissionPayload | {
|
|
55
|
+
value: FormForgeSubmissionPayload;
|
|
56
|
+
};
|
|
57
|
+
zodSchema: object | {
|
|
58
|
+
value: object | undefined;
|
|
59
|
+
};
|
|
60
|
+
validate: FormForgeValidationHandler;
|
|
61
|
+
formVersion: string;
|
|
62
|
+
submitLabel: string;
|
|
63
|
+
showSubmit: boolean;
|
|
64
|
+
simulation: boolean;
|
|
65
|
+
clearAfterSubmit: boolean;
|
|
66
|
+
showProgress: boolean;
|
|
67
|
+
progressVariant: FormForgeProgressVariant;
|
|
68
|
+
showAlertOnError: boolean;
|
|
69
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
70
|
+
declare const _default: typeof __VLS_export;
|
|
71
|
+
export default _default;
|
|
72
|
+
//# sourceMappingURL=FormForgeRenderer.vue.d.ts.map
|