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

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

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