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 / ParagraphFormField.vue

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

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