PluginProbe
The Innovative Form Builder – IvyForms / 0.6
The Innovative Form Builder – IvyForms v0.6
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 / TextFormField.vue

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

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