@teamnovu/nuxt-statamic-formbuilder-nuxt-ui 0.1.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/README.md +5 -0
- package/dist/module.d.mts +9 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +45 -0
- package/dist/runtime/components/FormBuilder.d.vue.ts +33 -0
- package/dist/runtime/components/FormBuilder.vue +164 -0
- package/dist/runtime/components/FormBuilder.vue.d.ts +33 -0
- package/dist/runtime/components/FormField.d.vue.ts +20 -0
- package/dist/runtime/components/FormField.vue +42 -0
- package/dist/runtime/components/FormField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/FormFieldCheckboxes.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldCheckboxes.vue +46 -0
- package/dist/runtime/components/fields/FormFieldCheckboxes.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldDate.d.vue.ts +13 -0
- package/dist/runtime/components/fields/FormFieldDate.vue +86 -0
- package/dist/runtime/components/fields/FormFieldDate.vue.d.ts +13 -0
- package/dist/runtime/components/fields/FormFieldDisplayText.d.vue.ts +7 -0
- package/dist/runtime/components/fields/FormFieldDisplayText.vue +25 -0
- package/dist/runtime/components/fields/FormFieldDisplayText.vue.d.ts +7 -0
- package/dist/runtime/components/fields/FormFieldEmail.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldEmail.vue +32 -0
- package/dist/runtime/components/fields/FormFieldEmail.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldFileUpload.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldFileUpload.vue +34 -0
- package/dist/runtime/components/fields/FormFieldFileUpload.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldNumber.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldNumber.vue +31 -0
- package/dist/runtime/components/fields/FormFieldNumber.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldPhone.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldPhone.vue +130 -0
- package/dist/runtime/components/fields/FormFieldPhone.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldRadioButtons.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldRadioButtons.vue +54 -0
- package/dist/runtime/components/fields/FormFieldRadioButtons.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldSelect.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldSelect.vue +65 -0
- package/dist/runtime/components/fields/FormFieldSelect.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldSlider.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldSlider.vue +31 -0
- package/dist/runtime/components/fields/FormFieldSlider.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldSwitch.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldSwitch.vue +33 -0
- package/dist/runtime/components/fields/FormFieldSwitch.vue.d.ts +10 -0
- package/dist/runtime/components/fields/FormFieldText.d.vue.ts +11 -0
- package/dist/runtime/components/fields/FormFieldText.vue +42 -0
- package/dist/runtime/components/fields/FormFieldText.vue.d.ts +11 -0
- package/dist/runtime/components/fields/FormFieldTextarea.d.vue.ts +10 -0
- package/dist/runtime/components/fields/FormFieldTextarea.vue +41 -0
- package/dist/runtime/components/fields/FormFieldTextarea.vue.d.ts +10 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +31 -0
- package/dist/runtime/reexports.d.ts +3 -0
- package/dist/runtime/reexports.js +7 -0
- package/dist/runtime/styles/form-builder.css +1 -0
- package/dist/runtime/types.d.ts +9 -0
- package/dist/runtime/types.js +0 -0
- package/dist/types.d.mts +5 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @teamnovu/nuxt-statamic-formbuilder-nuxt-ui
|
|
2
|
+
|
|
3
|
+
Nuxt UI field layer for `@teamnovu/nuxt-statamic-formbuilder`. Registers all `input_*` / `display_text` field components and exports `FormBuilder` (UForm shell).
|
|
4
|
+
|
|
5
|
+
See the [monorepo README](../../README.md) for install and usage.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export { FormBuilderStyleConfig } from '../dist/runtime/types.js';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
}
|
|
6
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
|
+
|
|
8
|
+
export { _default as default };
|
|
9
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, installModule, addComponent, addPlugin } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@teamnovu/nuxt-statamic-formbuilder-nuxt-ui",
|
|
6
|
+
configKey: "formBuilderNuxtUi"
|
|
7
|
+
},
|
|
8
|
+
defaults: {},
|
|
9
|
+
async setup(_options, nuxt) {
|
|
10
|
+
const resolver = createResolver(import.meta.url);
|
|
11
|
+
await installModule("@teamnovu/nuxt-statamic-formbuilder");
|
|
12
|
+
addComponent({
|
|
13
|
+
name: "FormBuilder",
|
|
14
|
+
filePath: resolver.resolve("./runtime/components/FormBuilder.vue")
|
|
15
|
+
});
|
|
16
|
+
addComponent({
|
|
17
|
+
name: "FormField",
|
|
18
|
+
filePath: resolver.resolve("./runtime/components/FormField.vue")
|
|
19
|
+
});
|
|
20
|
+
const fields = [
|
|
21
|
+
"FormFieldText",
|
|
22
|
+
"FormFieldTextarea",
|
|
23
|
+
"FormFieldEmail",
|
|
24
|
+
"FormFieldPhone",
|
|
25
|
+
"FormFieldNumber",
|
|
26
|
+
"FormFieldSelect",
|
|
27
|
+
"FormFieldDate",
|
|
28
|
+
"FormFieldSlider",
|
|
29
|
+
"FormFieldCheckboxes",
|
|
30
|
+
"FormFieldRadioButtons",
|
|
31
|
+
"FormFieldSwitch",
|
|
32
|
+
"FormFieldFileUpload",
|
|
33
|
+
"FormFieldDisplayText"
|
|
34
|
+
];
|
|
35
|
+
for (const name of fields) {
|
|
36
|
+
addComponent({
|
|
37
|
+
name,
|
|
38
|
+
filePath: resolver.resolve(`./runtime/components/fields/${name}.vue`)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FormBuilderConfiguration, type FormBuilderTexts, type FormBuilderSubmitter } from '../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
serverUrl?: string;
|
|
5
|
+
form: FormBuilderConfiguration;
|
|
6
|
+
texts?: Partial<FormBuilderTexts>;
|
|
7
|
+
styleConfig?: FormBuilderStyleConfig;
|
|
8
|
+
submitter?: FormBuilderSubmitter;
|
|
9
|
+
};
|
|
10
|
+
declare var __VLS_33: {}, __VLS_41: {}, __VLS_43: {}, __VLS_45: {};
|
|
11
|
+
type __VLS_Slots = {} & {
|
|
12
|
+
default?: (props: typeof __VLS_33) => any;
|
|
13
|
+
} & {
|
|
14
|
+
loading?: (props: typeof __VLS_41) => any;
|
|
15
|
+
} & {
|
|
16
|
+
success?: (props: typeof __VLS_43) => any;
|
|
17
|
+
} & {
|
|
18
|
+
error?: (props: typeof __VLS_45) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
+
serverUrl: string;
|
|
22
|
+
texts: Partial<FormBuilderTexts>;
|
|
23
|
+
styleConfig: FormBuilderStyleConfig;
|
|
24
|
+
submitter: FormBuilderSubmitter;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
29
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
30
|
+
new (): {
|
|
31
|
+
$slots: S;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UForm
|
|
3
|
+
novalidate
|
|
4
|
+
:schema="schema"
|
|
5
|
+
:state="state"
|
|
6
|
+
:validate-on="['input', 'blur']"
|
|
7
|
+
class="
|
|
8
|
+
@container -mb-8 grid grid-cols-12 gap-x-4
|
|
9
|
+
*:pb-8
|
|
10
|
+
"
|
|
11
|
+
:class="{ 'reset-form': requestState === 'success' }"
|
|
12
|
+
@error="onError"
|
|
13
|
+
@submit.prevent.stop="onSubmit"
|
|
14
|
+
>
|
|
15
|
+
<template v-if="'fields' in form">
|
|
16
|
+
<FormBuilderFields
|
|
17
|
+
:style-config="resolvedStyleConfig"
|
|
18
|
+
:form="form"
|
|
19
|
+
:fields="form.fields"
|
|
20
|
+
/>
|
|
21
|
+
</template>
|
|
22
|
+
<template v-else>
|
|
23
|
+
<FormBuilderFields
|
|
24
|
+
v-for="section in form.sections"
|
|
25
|
+
:key="section.display ?? void 0"
|
|
26
|
+
:style-config="resolvedStyleConfig"
|
|
27
|
+
:form="form"
|
|
28
|
+
:fields="section.fields"
|
|
29
|
+
/>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<input
|
|
33
|
+
v-if="form.honeypot"
|
|
34
|
+
:name="form.honeypot"
|
|
35
|
+
aria-hidden
|
|
36
|
+
class="hidden"
|
|
37
|
+
>
|
|
38
|
+
|
|
39
|
+
<ClientOnly>
|
|
40
|
+
<Transition
|
|
41
|
+
name="fade"
|
|
42
|
+
mode="out-in"
|
|
43
|
+
>
|
|
44
|
+
<slot
|
|
45
|
+
v-if="requestState === 'not_submitted' || requestState === 'error'"
|
|
46
|
+
name="default"
|
|
47
|
+
>
|
|
48
|
+
<div class="col-span-12 mt-4">
|
|
49
|
+
<UButton type="submit">
|
|
50
|
+
{{ props.texts?.send_button_text }}
|
|
51
|
+
</UButton>
|
|
52
|
+
</div>
|
|
53
|
+
</slot>
|
|
54
|
+
<slot
|
|
55
|
+
v-else-if="requestState === 'loading'"
|
|
56
|
+
name="loading"
|
|
57
|
+
>
|
|
58
|
+
<p class="col-span-12">
|
|
59
|
+
{{ props.texts?.message_loading }}
|
|
60
|
+
</p>
|
|
61
|
+
</slot>
|
|
62
|
+
<slot
|
|
63
|
+
v-else-if="requestState === 'success'"
|
|
64
|
+
name="success"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
class="col-span-12"
|
|
68
|
+
v-html="props.texts?.message_success"
|
|
69
|
+
/>
|
|
70
|
+
</slot>
|
|
71
|
+
</Transition>
|
|
72
|
+
<slot
|
|
73
|
+
v-if="requestState === 'error'"
|
|
74
|
+
name="error"
|
|
75
|
+
>
|
|
76
|
+
<p class="col-span-12">
|
|
77
|
+
{{ props.texts?.message_error }}
|
|
78
|
+
</p>
|
|
79
|
+
</slot>
|
|
80
|
+
</ClientOnly>
|
|
81
|
+
</UForm>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<script setup>
|
|
85
|
+
import { useToast } from "@nuxt/ui/composables";
|
|
86
|
+
import { useFormBuilder } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useFormBuilder";
|
|
87
|
+
import { useFormValidation } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useFormValidation";
|
|
88
|
+
import { useI18n } from "vue-i18n";
|
|
89
|
+
import { computed, provide, ref, watch } from "vue";
|
|
90
|
+
import { formBuilderStateKey } from "../reexports";
|
|
91
|
+
const { t } = useI18n();
|
|
92
|
+
const props = defineProps({
|
|
93
|
+
serverUrl: { type: String, required: false, default: void 0 },
|
|
94
|
+
form: { type: Object, required: true },
|
|
95
|
+
texts: { type: Object, required: false, default: void 0 },
|
|
96
|
+
styleConfig: { type: Object, required: false, default: void 0 },
|
|
97
|
+
submitter: { type: Function, required: false, default: void 0 }
|
|
98
|
+
});
|
|
99
|
+
const resolvedStyleConfig = computed(() => ({
|
|
100
|
+
color: "neutral",
|
|
101
|
+
variant: "outline",
|
|
102
|
+
size: "md",
|
|
103
|
+
highlight: false,
|
|
104
|
+
...props.styleConfig
|
|
105
|
+
}));
|
|
106
|
+
const {
|
|
107
|
+
submit,
|
|
108
|
+
reset,
|
|
109
|
+
requestState,
|
|
110
|
+
state
|
|
111
|
+
} = useFormBuilder(props.form, {
|
|
112
|
+
serverUrl: props.serverUrl,
|
|
113
|
+
submitter: props.submitter
|
|
114
|
+
});
|
|
115
|
+
const fields = computed(() => {
|
|
116
|
+
return [
|
|
117
|
+
..."fields" in props.form ? props.form.fields : props.form.sections.flatMap((section) => section.fields)
|
|
118
|
+
];
|
|
119
|
+
});
|
|
120
|
+
const { schema } = useFormValidation(fields, props.form.rules, state);
|
|
121
|
+
provide(formBuilderStateKey, state);
|
|
122
|
+
const result = ref(null);
|
|
123
|
+
async function onSubmit(event) {
|
|
124
|
+
result.value = await submit(event, state);
|
|
125
|
+
}
|
|
126
|
+
const toast = useToast();
|
|
127
|
+
watch(requestState, (newState) => {
|
|
128
|
+
if (newState === "success") {
|
|
129
|
+
toast.add({
|
|
130
|
+
title: t("form.user_feedback.success.title"),
|
|
131
|
+
icon: "i-lucide-circle-check",
|
|
132
|
+
description: props.texts?.message_success,
|
|
133
|
+
color: "success"
|
|
134
|
+
});
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
reset();
|
|
137
|
+
result.value = null;
|
|
138
|
+
}, 1e3);
|
|
139
|
+
}
|
|
140
|
+
if (newState === "error") {
|
|
141
|
+
toast.add({
|
|
142
|
+
title: t("form.user_feedback.error.title"),
|
|
143
|
+
icon: "i-lucide-circle-alert",
|
|
144
|
+
description: props.texts?.message_error,
|
|
145
|
+
color: "error"
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
function onError(event) {
|
|
150
|
+
const fieldLabels = event.errors.map((error) => {
|
|
151
|
+
const field = fields.value.find((f) => f.handle === error.name);
|
|
152
|
+
return field?.display ?? error.name;
|
|
153
|
+
});
|
|
154
|
+
toast.add({
|
|
155
|
+
title: t("form.user_feedback.error.title"),
|
|
156
|
+
icon: "i-lucide-circle-alert",
|
|
157
|
+
description: t("form.user_feedback.field_invalid", {
|
|
158
|
+
count: fieldLabels.length,
|
|
159
|
+
fields: fieldLabels.join(", ")
|
|
160
|
+
}),
|
|
161
|
+
color: "error"
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FormBuilderConfiguration, type FormBuilderTexts, type FormBuilderSubmitter } from '../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
serverUrl?: string;
|
|
5
|
+
form: FormBuilderConfiguration;
|
|
6
|
+
texts?: Partial<FormBuilderTexts>;
|
|
7
|
+
styleConfig?: FormBuilderStyleConfig;
|
|
8
|
+
submitter?: FormBuilderSubmitter;
|
|
9
|
+
};
|
|
10
|
+
declare var __VLS_33: {}, __VLS_41: {}, __VLS_43: {}, __VLS_45: {};
|
|
11
|
+
type __VLS_Slots = {} & {
|
|
12
|
+
default?: (props: typeof __VLS_33) => any;
|
|
13
|
+
} & {
|
|
14
|
+
loading?: (props: typeof __VLS_41) => any;
|
|
15
|
+
} & {
|
|
16
|
+
success?: (props: typeof __VLS_43) => any;
|
|
17
|
+
} & {
|
|
18
|
+
error?: (props: typeof __VLS_45) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
+
serverUrl: string;
|
|
22
|
+
texts: Partial<FormBuilderTexts>;
|
|
23
|
+
styleConfig: FormBuilderStyleConfig;
|
|
24
|
+
submitter: FormBuilderSubmitter;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
29
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
30
|
+
new (): {
|
|
31
|
+
$slots: S;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BaseFieldConfig, DefaultInputField } from '../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
input: DefaultInputField;
|
|
5
|
+
styleConfig: FormBuilderStyleConfig;
|
|
6
|
+
config?: BaseFieldConfig;
|
|
7
|
+
};
|
|
8
|
+
declare var __VLS_9: {};
|
|
9
|
+
type __VLS_Slots = {} & {
|
|
10
|
+
default?: (props: typeof __VLS_9) => any;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UFormField
|
|
3
|
+
v-bind="{ ...styleConfig }"
|
|
4
|
+
:hint="hint"
|
|
5
|
+
:help="help"
|
|
6
|
+
:required="input?.rules?.required ?? false"
|
|
7
|
+
:name="input?.name"
|
|
8
|
+
:label="label"
|
|
9
|
+
class="group/form-field relative isolate"
|
|
10
|
+
:class="{ 'has-floating-label': config?.floating_label }"
|
|
11
|
+
:ui="{
|
|
12
|
+
root: 'w-full',
|
|
13
|
+
labelWrapper: 'justify-between group-[.has-floating-label]/form-field:justify-end',
|
|
14
|
+
label: 'z-50 transition-all after:text-(--required-indicator)',
|
|
15
|
+
error: 'text-(--ui-text-error) block'
|
|
16
|
+
}"
|
|
17
|
+
>
|
|
18
|
+
<template #default>
|
|
19
|
+
<slot />
|
|
20
|
+
</template>
|
|
21
|
+
</UFormField>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
26
|
+
import { computed } from "vue";
|
|
27
|
+
const props = defineProps({
|
|
28
|
+
input: { type: Object, required: true },
|
|
29
|
+
styleConfig: { type: Object, required: true },
|
|
30
|
+
config: { type: Object, required: false }
|
|
31
|
+
});
|
|
32
|
+
const translateInput = useTranslatableInput();
|
|
33
|
+
const hint = computed(() => translateInput(props.config?.hint));
|
|
34
|
+
const help = computed(() => translateInput(props.config?.help));
|
|
35
|
+
const label = computed(
|
|
36
|
+
() => translateInput(props.config?.label) ?? props.input?.ariaLabel
|
|
37
|
+
);
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
.group\/form-field.has-floating-label{--label-resting-top:1.875rem;--label-floated-top:0rem}.group\/form-field.has-floating-label:not(:has([data-slot=hint])){--label-resting-top:0.625rem;--label-floated-top:-1.25rem}.group\/form-field.has-floating-label label{background:transparent;left:.5rem;position:absolute;right:0}.group\/form-field.has-floating-label:has(input:-moz-placeholder,textarea:-moz-placeholder,[data-placeholder]) label{pointer-events:none;top:var(--label-resting-top)}.group\/form-field.has-floating-label:has(input:placeholder-shown,textarea:placeholder-shown,[data-placeholder]) label{pointer-events:none;top:var(--label-resting-top)}.group\/form-field.has-floating-label:has(input,textarea,button) label{top:var(--label-floated-top)}.group\/form-field.has-floating-label:has(input:focus,textarea:focus,button:focus,button[data-state=open]) label{top:var(--label-floated-top)}
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BaseFieldConfig, DefaultInputField } from '../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
input: DefaultInputField;
|
|
5
|
+
styleConfig: FormBuilderStyleConfig;
|
|
6
|
+
config?: BaseFieldConfig;
|
|
7
|
+
};
|
|
8
|
+
declare var __VLS_9: {};
|
|
9
|
+
type __VLS_Slots = {} & {
|
|
10
|
+
default?: (props: typeof __VLS_9) => any;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputCheckboxesFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputCheckboxesFieldConfig;
|
|
5
|
+
input: DefaultInputField;
|
|
6
|
+
styleConfig: FormBuilderStyleConfig;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:input="input"
|
|
5
|
+
:style-config="styleConfig"
|
|
6
|
+
>
|
|
7
|
+
<UCheckboxGroup
|
|
8
|
+
v-bind="input"
|
|
9
|
+
:model-value="state[props.input?.name] ?? []"
|
|
10
|
+
@update:model-value="state[props.input?.name] = $event"
|
|
11
|
+
:orientation="config?.orientation"
|
|
12
|
+
:variant="config?.variant"
|
|
13
|
+
:indicator="config?.indicator"
|
|
14
|
+
:color="styleConfig?.color"
|
|
15
|
+
:size="styleConfig?.size"
|
|
16
|
+
:items="selectOptions ?? []"
|
|
17
|
+
:ui="{
|
|
18
|
+
fieldset: 'flex-wrap'
|
|
19
|
+
}"
|
|
20
|
+
>
|
|
21
|
+
<template #label="{ item }">
|
|
22
|
+
<span v-html="removePTags(item?.label) ?? ''" />
|
|
23
|
+
</template>
|
|
24
|
+
</UCheckboxGroup>
|
|
25
|
+
</FormField>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup>
|
|
29
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
30
|
+
import { removePTags } from "@teamnovu/nuxt-statamic-formbuilder/runtime/utils/removePTags";
|
|
31
|
+
import { computed, inject } from "vue";
|
|
32
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
33
|
+
const state = inject(formBuilderStateKey);
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
config: { type: Object, required: false },
|
|
36
|
+
input: { type: Object, required: true },
|
|
37
|
+
styleConfig: { type: Object, required: true }
|
|
38
|
+
});
|
|
39
|
+
const translateInput = useTranslatableInput();
|
|
40
|
+
const selectOptions = computed(() => {
|
|
41
|
+
return props.config?.options?.map((option) => ({
|
|
42
|
+
label: translateInput(option.text) ?? option.key,
|
|
43
|
+
value: option.key
|
|
44
|
+
})) ?? [];
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputCheckboxesFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputCheckboxesFieldConfig;
|
|
5
|
+
input: DefaultInputField;
|
|
6
|
+
styleConfig: FormBuilderStyleConfig;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputDateFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputDateFieldConfig;
|
|
5
|
+
input: DefaultInputField;
|
|
6
|
+
isRange?: boolean;
|
|
7
|
+
styleConfig: FormBuilderStyleConfig;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
10
|
+
isRange: boolean;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
<UInputDate
|
|
8
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
9
|
+
ref="inputDateRef"
|
|
10
|
+
v-model="modelValue"
|
|
11
|
+
:min-value="minDate"
|
|
12
|
+
:max-value="maxDate"
|
|
13
|
+
:range="isRange"
|
|
14
|
+
:ui="{
|
|
15
|
+
trailing: 'p-0'
|
|
16
|
+
}"
|
|
17
|
+
>
|
|
18
|
+
<template #trailing>
|
|
19
|
+
<UPopover :reference="inputDateRef?.inputsRef[0]?.$el">
|
|
20
|
+
<UButton
|
|
21
|
+
v-bind="{ ...styleConfig, variant: 'ghost' }"
|
|
22
|
+
icon="i-lucide-calendar"
|
|
23
|
+
:aria-label="isRange ? 'Select a date range' : 'Select a date'"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<template #content>
|
|
27
|
+
<UCalendar
|
|
28
|
+
v-bind="{ ...styleConfig, variant: styleConfig?.variant !== 'ghost' && styleConfig?.variant !== 'none' ? styleConfig?.variant : void 0 }"
|
|
29
|
+
v-model="modelValue"
|
|
30
|
+
:number-of-months="2"
|
|
31
|
+
:range="isRange"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
</UPopover>
|
|
35
|
+
</template>
|
|
36
|
+
</UInputDate>
|
|
37
|
+
</FormField>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup>
|
|
41
|
+
import { CalendarDate, parseDate } from "@internationalized/date";
|
|
42
|
+
import { computed, inject, shallowRef, useTemplateRef, watch } from "vue";
|
|
43
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
44
|
+
const props = defineProps({
|
|
45
|
+
config: { type: Object, required: false },
|
|
46
|
+
input: { type: Object, required: true },
|
|
47
|
+
isRange: { type: Boolean, required: false, default: false },
|
|
48
|
+
styleConfig: { type: Object, required: true }
|
|
49
|
+
});
|
|
50
|
+
const inputDateRef = useTemplateRef("inputDateRef");
|
|
51
|
+
const state = inject(formBuilderStateKey);
|
|
52
|
+
const minDate = computed(() => {
|
|
53
|
+
if (props.config?.earliest_date) {
|
|
54
|
+
return parseDate(props.config?.earliest_date);
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
});
|
|
58
|
+
const maxDate = computed(() => {
|
|
59
|
+
if (props.config?.latest_date) {
|
|
60
|
+
return parseDate(props.config?.latest_date);
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
});
|
|
64
|
+
const modelValue = shallowRef(void 0);
|
|
65
|
+
const convertedValue = computed(() => {
|
|
66
|
+
if (props.isRange) {
|
|
67
|
+
const rangeValue = modelValue.value;
|
|
68
|
+
const start = rangeValue?.start;
|
|
69
|
+
const end = rangeValue?.end;
|
|
70
|
+
if (!start || !end) {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
return `${start.toString()} - ${end.toString()}`;
|
|
74
|
+
}
|
|
75
|
+
const singleValue = modelValue.value;
|
|
76
|
+
return singleValue?.toString() ?? "";
|
|
77
|
+
});
|
|
78
|
+
watch(convertedValue, (newVal) => {
|
|
79
|
+
state.value[props.input.name] = newVal;
|
|
80
|
+
});
|
|
81
|
+
watch(() => state.value[props.input.name], (newVal) => {
|
|
82
|
+
if (newVal === void 0 || newVal === "") {
|
|
83
|
+
modelValue.value = void 0;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputDateFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputDateFieldConfig;
|
|
5
|
+
input: DefaultInputField;
|
|
6
|
+
isRange?: boolean;
|
|
7
|
+
styleConfig: FormBuilderStyleConfig;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
10
|
+
isRange: boolean;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayTextFieldConfig } from '../../reexports.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
config?: DisplayTextFieldConfig;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="col-span-12 flex flex-col gap-1">
|
|
3
|
+
<h3
|
|
4
|
+
v-if="resolvedTitle"
|
|
5
|
+
class="font-medium"
|
|
6
|
+
>
|
|
7
|
+
{{ resolvedTitle }}
|
|
8
|
+
</h3>
|
|
9
|
+
<div
|
|
10
|
+
v-if="resolvedText"
|
|
11
|
+
v-html="resolvedText"
|
|
12
|
+
/>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup>
|
|
17
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
18
|
+
import { computed } from "vue";
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
config: { type: Object, required: false }
|
|
21
|
+
});
|
|
22
|
+
const translateInput = useTranslatableInput();
|
|
23
|
+
const resolvedTitle = computed(() => translateInput(props.config?.title));
|
|
24
|
+
const resolvedText = computed(() => translateInput(props.config?.text));
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayTextFieldConfig } from '../../reexports.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
config?: DisplayTextFieldConfig;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputEmailFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputEmailFieldConfig;
|
|
5
|
+
input: DefaultInputField;
|
|
6
|
+
styleConfig: FormBuilderStyleConfig;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
<UInput
|
|
8
|
+
type="email"
|
|
9
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
10
|
+
v-model="state[input.name]"
|
|
11
|
+
:placeholder="config?.floating_label ? '' : translateInput(config?.placeholder)"
|
|
12
|
+
:ui="{
|
|
13
|
+
base: 'peer',
|
|
14
|
+
root: 'w-full'
|
|
15
|
+
}"
|
|
16
|
+
|
|
17
|
+
/>
|
|
18
|
+
</FormField>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
23
|
+
import { inject } from "vue";
|
|
24
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
25
|
+
const state = inject(formBuilderStateKey);
|
|
26
|
+
const translateInput = useTranslatableInput();
|
|
27
|
+
defineProps({
|
|
28
|
+
config: { type: Object, required: false },
|
|
29
|
+
input: { type: Object, required: true },
|
|
30
|
+
styleConfig: { type: Object, required: true }
|
|
31
|
+
});
|
|
32
|
+
</script>
|