@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
|
@@ -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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputFileUploadFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputFileUploadFieldConfig;
|
|
5
|
+
styleConfig: FormBuilderStyleConfig;
|
|
6
|
+
input: DefaultInputField;
|
|
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,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
no-help
|
|
4
|
+
:config="config"
|
|
5
|
+
:style-config="styleConfig"
|
|
6
|
+
:input="input"
|
|
7
|
+
>
|
|
8
|
+
<UFileUpload
|
|
9
|
+
v-bind="{ ...input, ...{ ...styleConfig, variant: 'area' } }"
|
|
10
|
+
v-model="state[input?.name]"
|
|
11
|
+
icon="i-lucide-image"
|
|
12
|
+
:multiple="config?.max_files ? config.max_files > 1 : false"
|
|
13
|
+
:description="fileDescription"
|
|
14
|
+
:accept="accept"
|
|
15
|
+
/>
|
|
16
|
+
</FormField>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
21
|
+
import { computed, inject } from "vue";
|
|
22
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
config: { type: Object, required: false },
|
|
25
|
+
styleConfig: { type: Object, required: true },
|
|
26
|
+
input: { type: Object, required: true }
|
|
27
|
+
});
|
|
28
|
+
const state = inject(formBuilderStateKey);
|
|
29
|
+
const translateInput = useTranslatableInput();
|
|
30
|
+
const fileDescription = computed(() => translateInput(props.config?.icon_label) ?? void 0);
|
|
31
|
+
const accept = computed(() => {
|
|
32
|
+
return Object.values(props.config?.allowed_mimes ?? {}).join(",");
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputFileUploadFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputFileUploadFieldConfig;
|
|
5
|
+
styleConfig: FormBuilderStyleConfig;
|
|
6
|
+
input: DefaultInputField;
|
|
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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputNumberFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputNumberFieldConfig;
|
|
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,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
<UInputNumber
|
|
8
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
9
|
+
:model-value="state[props.input?.name] ?? config?.default ?? 0"
|
|
10
|
+
@update:model-value="state[props.input?.name] = $event"
|
|
11
|
+
:min="config?.min ?? 0"
|
|
12
|
+
:max="config?.max ?? 100"
|
|
13
|
+
:step="config?.step ?? 1"
|
|
14
|
+
:ui="{
|
|
15
|
+
root: 'w-full',
|
|
16
|
+
base: 'peer'
|
|
17
|
+
}"
|
|
18
|
+
/>
|
|
19
|
+
</FormField>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import { inject } from "vue";
|
|
24
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
25
|
+
const state = inject(formBuilderStateKey);
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
config: { type: Object, required: false },
|
|
28
|
+
input: { type: Object, required: true },
|
|
29
|
+
styleConfig: { type: Object, required: true }
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputNumberFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputNumberFieldConfig;
|
|
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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputPhoneFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputPhoneFieldConfig;
|
|
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,130 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
<UFieldGroup class="w-full">
|
|
8
|
+
<USelectMenu
|
|
9
|
+
v-if="config?.show_country_code_selector"
|
|
10
|
+
v-bind="{ ...styleConfig }"
|
|
11
|
+
v-model="countryCodeValue"
|
|
12
|
+
:placeholder="translateInput(config?.placeholder) ?? void 0"
|
|
13
|
+
:items="countrySelectItems ?? []"
|
|
14
|
+
value-key="value"
|
|
15
|
+
:icon="icon"
|
|
16
|
+
:search-input="config?.show_search ? {
|
|
17
|
+
placeholder: 'Filter...',
|
|
18
|
+
icon: 'i-lucide-search'
|
|
19
|
+
} : false"
|
|
20
|
+
arrow
|
|
21
|
+
class="w-30"
|
|
22
|
+
:ui="{
|
|
23
|
+
base: 'justify-center'
|
|
24
|
+
}"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
<UInput
|
|
28
|
+
type="text"
|
|
29
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
30
|
+
v-model="value"
|
|
31
|
+
:placeholder="config?.floating_label ? '' : translateInput(config?.placeholder)"
|
|
32
|
+
v-maska="mask"
|
|
33
|
+
:ui="{
|
|
34
|
+
base: 'peer',
|
|
35
|
+
root: 'w-full'
|
|
36
|
+
}"
|
|
37
|
+
|
|
38
|
+
/>
|
|
39
|
+
</UFieldGroup>
|
|
40
|
+
</FormField>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup>
|
|
44
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
45
|
+
import { vMaska } from "maska/vue";
|
|
46
|
+
import { computed, inject, ref, watch } from "vue";
|
|
47
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
48
|
+
const props = defineProps({
|
|
49
|
+
config: { type: Object, required: false },
|
|
50
|
+
input: { type: Object, required: true },
|
|
51
|
+
styleConfig: { type: Object, required: true }
|
|
52
|
+
});
|
|
53
|
+
const translateInput = useTranslatableInput();
|
|
54
|
+
const countrySelectItems = ref(Object.entries(props.config?.country_codes ?? {}).map(([key, value2]) => ({
|
|
55
|
+
label: `${key.toUpperCase()}`,
|
|
56
|
+
value: value2,
|
|
57
|
+
icon: "circle-flags:" + key.toLowerCase()
|
|
58
|
+
})) ?? []);
|
|
59
|
+
const countryCodeValue = ref(props.config?.default_country_code ?? countrySelectItems.value[0]?.value);
|
|
60
|
+
const value = computed({
|
|
61
|
+
get: () => state.value[props.input?.name] ?? `${countryCodeValue.value} `,
|
|
62
|
+
set: (v) => {
|
|
63
|
+
state.value[props.input?.name] = v;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const icon = computed(() => countrySelectItems.value.find((item) => item.value === countryCodeValue.value)?.icon);
|
|
67
|
+
watch(countryCodeValue, (newVal, oldVal) => {
|
|
68
|
+
if (value.value.startsWith(`${oldVal ?? ""} `)) {
|
|
69
|
+
value.value = value.value.replace(`${oldVal ?? ""} `, `${newVal ?? ""} `);
|
|
70
|
+
}
|
|
71
|
+
if (value.value.length === 0) {
|
|
72
|
+
value.value = `${newVal ?? ""} `;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const maskMap = {
|
|
76
|
+
"+41": "+41 ## ### ## ##",
|
|
77
|
+
// CH
|
|
78
|
+
"+49": "+49 ### #######",
|
|
79
|
+
// DE
|
|
80
|
+
"+33": "+33 # ## ## ## ##",
|
|
81
|
+
// FR
|
|
82
|
+
"+39": "+39 ### #######",
|
|
83
|
+
// IT
|
|
84
|
+
"+1": "+1 ### ### ####",
|
|
85
|
+
// US
|
|
86
|
+
"+44": "+44 #### ######",
|
|
87
|
+
// GB
|
|
88
|
+
"+34": "+34 ### ### ###",
|
|
89
|
+
// ES
|
|
90
|
+
"+31": "+31 ## ### ####",
|
|
91
|
+
// NL
|
|
92
|
+
"+32": "+32 ### ## ## ##",
|
|
93
|
+
// BE
|
|
94
|
+
"+46": "+46 ## ### ## ##",
|
|
95
|
+
// SE
|
|
96
|
+
"+47": "+47 ## ## ## ##",
|
|
97
|
+
// NO
|
|
98
|
+
"+45": "+45 ## ## ## ##",
|
|
99
|
+
// DK
|
|
100
|
+
"+358": "+358 ## ### ####",
|
|
101
|
+
// FI
|
|
102
|
+
"+372": "+372 #### ####",
|
|
103
|
+
// EE
|
|
104
|
+
"+371": "+371 ## ### ###",
|
|
105
|
+
// LV
|
|
106
|
+
"+370": "+370 ### ## ###",
|
|
107
|
+
// LT
|
|
108
|
+
"+48": "+48 ### ### ###",
|
|
109
|
+
// PL
|
|
110
|
+
"+420": "+420 ### ### ###",
|
|
111
|
+
// CZ
|
|
112
|
+
"+421": "+421 ### ### ###",
|
|
113
|
+
// SK
|
|
114
|
+
"+36": "+36 ## ### ####",
|
|
115
|
+
// HU
|
|
116
|
+
"+40": "+40 ### ### ###",
|
|
117
|
+
// RO
|
|
118
|
+
"+359": "+359 ## ### ####"
|
|
119
|
+
// BG
|
|
120
|
+
};
|
|
121
|
+
const mask = computed(() => {
|
|
122
|
+
return (countryCodeValue.value ? maskMap[countryCodeValue.value] : void 0) ?? `${countryCodeValue.value} #############`;
|
|
123
|
+
});
|
|
124
|
+
const state = inject(formBuilderStateKey);
|
|
125
|
+
watch(() => state.value[props.input?.name], (newVal) => {
|
|
126
|
+
if (!newVal) {
|
|
127
|
+
countryCodeValue.value = props.config?.default_country_code ?? countrySelectItems.value[0]?.value;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputPhoneFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputPhoneFieldConfig;
|
|
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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputRadioButtonsFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputRadioButtonsFieldConfig;
|
|
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,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:input="input"
|
|
5
|
+
:style-config="styleConfig"
|
|
6
|
+
>
|
|
7
|
+
<URadioGroup
|
|
8
|
+
v-bind="input"
|
|
9
|
+
:model-value="state[props.input?.name]?.[0] ?? void 0"
|
|
10
|
+
@update:model-value="state[props.input?.name] = toArray($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
|
+
</URadioGroup>
|
|
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
|
+
const toArray = (value) => {
|
|
47
|
+
if (!value || value.length === 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === "string") {
|
|
51
|
+
return [value];
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputRadioButtonsFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputRadioButtonsFieldConfig;
|
|
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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputSelectFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputSelectFieldConfig;
|
|
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,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
|
|
8
|
+
<div :data-placeholder="isEmpty ? '' : void 0" class="w-full">
|
|
9
|
+
<USelectMenu
|
|
10
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
11
|
+
:model-value="state[props.input?.name] ?? (config?.multiple ? [] : '')"
|
|
12
|
+
value-key="value"
|
|
13
|
+
:multiple="!!config?.multiple"
|
|
14
|
+
:search-input="config?.show_search == true ? {
|
|
15
|
+
placeholder: 'Filter...',
|
|
16
|
+
icon: 'i-lucide-search'
|
|
17
|
+
} : false"
|
|
18
|
+
arrow
|
|
19
|
+
:items="selectOptions ?? []"
|
|
20
|
+
@update:model-value="state[props.input?.name] = config?.multiple ? toArray($event) : toSingle($event)"
|
|
21
|
+
:placeholder="config?.floating_label ? '\xA0' : translateInput(config?.placeholder)"
|
|
22
|
+
class="w-full"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
</FormField>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup>
|
|
29
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
30
|
+
import { computed, inject } from "vue";
|
|
31
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
32
|
+
const state = inject(formBuilderStateKey);
|
|
33
|
+
const translateInput = useTranslatableInput();
|
|
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 selectOptions = computed(() => {
|
|
40
|
+
return props.config?.options?.map((option) => ({
|
|
41
|
+
label: translateInput(option.text) ?? option.key,
|
|
42
|
+
value: option.key
|
|
43
|
+
})) ?? [];
|
|
44
|
+
});
|
|
45
|
+
const isEmpty = computed(() => {
|
|
46
|
+
const value = state.value[props.input?.name];
|
|
47
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
48
|
+
return !value;
|
|
49
|
+
});
|
|
50
|
+
const toArray = (inputValue) => {
|
|
51
|
+
if (Array.isArray(inputValue)) {
|
|
52
|
+
return inputValue;
|
|
53
|
+
}
|
|
54
|
+
if (typeof inputValue === "string" && inputValue.length > 0) {
|
|
55
|
+
return [inputValue];
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
};
|
|
59
|
+
const toSingle = (inputValue) => {
|
|
60
|
+
if (Array.isArray(inputValue)) {
|
|
61
|
+
return inputValue[0] ?? "";
|
|
62
|
+
}
|
|
63
|
+
return inputValue ?? "";
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputSelectFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputSelectFieldConfig;
|
|
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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputSliderFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputSliderFieldConfig;
|
|
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,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
<USlider
|
|
8
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
9
|
+
:model-value="state[props.input?.name] ?? config?.default ?? 0"
|
|
10
|
+
class="py-1"
|
|
11
|
+
:min="config?.min ?? 0"
|
|
12
|
+
:max="config?.max ?? 100"
|
|
13
|
+
:step="config?.step ?? 1"
|
|
14
|
+
@update:model-value="state[props.input?.name] = $event"
|
|
15
|
+
/>
|
|
16
|
+
<div class="absolute right-0 bottom-0">
|
|
17
|
+
{{ state[props.input?.name] }}
|
|
18
|
+
</div>
|
|
19
|
+
</FormField>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import { inject } from "vue";
|
|
24
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
config: { type: Object, required: false },
|
|
27
|
+
input: { type: Object, required: true },
|
|
28
|
+
styleConfig: { type: Object, required: true }
|
|
29
|
+
});
|
|
30
|
+
const state = inject(formBuilderStateKey);
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputSliderFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputSliderFieldConfig;
|
|
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,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputSwitchFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputSwitchFieldConfig;
|
|
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,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
no-label
|
|
4
|
+
:config="config"
|
|
5
|
+
:style-config="styleConfig"
|
|
6
|
+
:input="input"
|
|
7
|
+
>
|
|
8
|
+
<USwitch
|
|
9
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
10
|
+
:model-value="state[props.input?.name] ?? config?.default ?? false"
|
|
11
|
+
unchecked-icon="i-lucide-x"
|
|
12
|
+
checked-icon="i-lucide-check"
|
|
13
|
+
:label="switchLabel"
|
|
14
|
+
@update:model-value="state[props.input?.name] = $event"
|
|
15
|
+
/>
|
|
16
|
+
</FormField>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
21
|
+
import { computed, inject } from "vue";
|
|
22
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
config: { type: Object, required: false },
|
|
25
|
+
input: { type: Object, required: true },
|
|
26
|
+
styleConfig: { type: Object, required: true }
|
|
27
|
+
});
|
|
28
|
+
const state = inject(formBuilderStateKey);
|
|
29
|
+
const translateInput = useTranslatableInput();
|
|
30
|
+
const switchLabel = computed(() => {
|
|
31
|
+
return state.value[props.input?.name] ? translateInput(props.config?.label_activated) : translateInput(props.config?.label_deactivated) ?? "";
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputSwitchFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputSwitchFieldConfig;
|
|
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,11 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputTextFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputTextFieldConfig;
|
|
5
|
+
styleConfig: FormBuilderStyleConfig;
|
|
6
|
+
input: DefaultInputField;
|
|
7
|
+
error?: string;
|
|
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<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField
|
|
3
|
+
:config="config"
|
|
4
|
+
:style-config="styleConfig"
|
|
5
|
+
:input="input"
|
|
6
|
+
>
|
|
7
|
+
<UInput
|
|
8
|
+
v-bind="{ ...input, ...styleConfig }"
|
|
9
|
+
v-model="state[input.name]"
|
|
10
|
+
type="text"
|
|
11
|
+
:placeholder="config?.floating_label ? '' : translateInput(config?.placeholder)"
|
|
12
|
+
:maxlength="config?.character_limit"
|
|
13
|
+
:ui="{
|
|
14
|
+
root: 'w-full',
|
|
15
|
+
base: 'peer'
|
|
16
|
+
}"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<!-- Character count for textarea if character_limit is set -->
|
|
20
|
+
<div
|
|
21
|
+
v-if="config?.character_limit"
|
|
22
|
+
class="absolute right-0 bottom-1 text-dimmed"
|
|
23
|
+
:class="{ 'text-(--ui-text-error)/70!': state[input?.name]?.length >= (config?.character_limit ?? 0) }"
|
|
24
|
+
>
|
|
25
|
+
{{ state[input?.name]?.length ?? 0 }} / {{ config?.character_limit }}
|
|
26
|
+
</div>
|
|
27
|
+
</FormField>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup>
|
|
31
|
+
import { useTranslatableInput } from "@teamnovu/nuxt-statamic-formbuilder/runtime/composables/useTranslatableInput";
|
|
32
|
+
import { inject } from "vue";
|
|
33
|
+
import { formBuilderStateKey } from "../../reexports";
|
|
34
|
+
const state = inject(formBuilderStateKey);
|
|
35
|
+
const translateInput = useTranslatableInput();
|
|
36
|
+
defineProps({
|
|
37
|
+
config: { type: Object, required: false },
|
|
38
|
+
styleConfig: { type: Object, required: true },
|
|
39
|
+
input: { type: Object, required: true },
|
|
40
|
+
error: { type: String, required: false }
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputTextFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputTextFieldConfig;
|
|
5
|
+
styleConfig: FormBuilderStyleConfig;
|
|
6
|
+
input: DefaultInputField;
|
|
7
|
+
error?: string;
|
|
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<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DefaultInputField, type InputTextareaFieldConfig } from '../../reexports.js';
|
|
2
|
+
import type { FormBuilderStyleConfig } from '../../types.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
config?: InputTextareaFieldConfig;
|
|
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;
|