PluginProbe
The Innovative Form Builder – IvyForms / 0.5
The Innovative Form Builder – IvyForms v0.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / views / public / fields / WebsiteFormField.vue

WebsiteFormField.vue in The Innovative Form Builder – IvyForms 0.5, at frontend/src/views/public/fields/WebsiteFormField.vue

122 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <template>
2 <div
3 :class="['ivyforms-field__website', 'ivyforms-field__website_' + field.id, field.cssClasses]"
4 >
5 <IvyFormItem
6 :label="field.hideLabel ? '' : field.label"
7 :required="field.required"
8 :error="error"
9 :prop="field.type + '_' + field.fieldIndex"
10 :show-info="!!field.description"
11 :info-text="field.description || ''"
12 :show-info-icon="false"
13 :label-position="field.labelPosition"
14 >
15 <IvyTextInput
16 :id="fieldID"
17 v-model="localModelValue"
18 class="ivyforms-field__website-input"
19 type="text"
20 :aria-label="field.label"
21 :placeholder="field.placeholder"
22 :disabled="disabled"
23 :readonly="field.readOnly"
24 :required="field.required"
25 :maxlength="field.limitMaxLength ? field.maxLength : undefined"
26 >
27 <template v-if="field.inputPrefix" #prefix>
28 <span class="ivyforms-field__website-prefix">{{ field.inputPrefix }}</span>
29 </template>
30 <template v-if="field.inputSuffix" #suffix>
31 <span class="ivyforms-field__website-suffix">{{ field.inputSuffix }}</span>
32 </template>
33 </IvyTextInput>
34 </IvyFormItem>
35 </div>
36 </template>
37
38 <script setup lang="ts">
39 import { computed, inject } from 'vue'
40
41 interface Field {
42 id: number
43 formId: number
44 fieldIndex: number
45 type: string
46 label: string
47 placeholder?: string
48 required?: boolean
49 hideLabel?: boolean
50 readOnly?: boolean
51 description?: string
52 cssClasses?: string
53 limitMaxLength?: boolean
54 maxLength?: number
55 labelPosition?: string
56 noDuplicates?: boolean
57 inputPrefix?: string
58 inputSuffix?: string
59 // Any other field properties from your data
60 }
61 interface FieldProps {
62 modelValue: string | number | null | undefined
63 field: Field
64 disabled?: boolean
65 error?: string
66 }
67
68 const props = withDefaults(defineProps<FieldProps>(), {
69 modelValue: '',
70 disabled: false,
71 error: '',
72 })
73
74 const emit = defineEmits(['update:modelValue'])
75
76 // Inject clearFieldError function from parent
77 const clearFieldError = inject<(fieldKey: string) => void>('clearFieldError', () => {})
78
79 // Generate field key for clearing errors
80 const fieldKey = computed(() => {
81 return props.field.type + '_' + props.field.fieldIndex
82 })
83
84 // Handle input event to clear errors when user starts typing
85 const handleInput = (value: string | number | null | undefined) => {
86 emit('update:modelValue', value)
87 clearFieldError(fieldKey.value)
88 }
89
90 const localModelValue = computed({
91 get() {
92 return props.modelValue
93 },
94 set(value) {
95 handleInput(value)
96 },
97 })
98 // Generate unique field ID as a string
99 const fieldID = computed(() => {
100 return `ivyforms-field__website-input_${props.field.formId || ''}_${props.field.fieldIndex || ''}`
101 })
102 </script>
103
104 <style scoped>
105 .ivyforms-field__website-prefix,
106 .ivyforms-field__website-suffix {
107 display: inline-block;
108 padding: 0 8px;
109 font-size: 14px;
110 line-height: 40px;
111 color: var(--map-base-text-0);
112 }
113
114 .ivyforms-field__website-prefix {
115 border-right: 1px solid var(--map-base-dusk-stroke--2);
116 }
117
118 .ivyforms-field__website-suffix {
119 border-left: 1px solid var(--map-base-dusk-stroke--2);
120 }
121 </style>
122