| 1 |
<template> |
| 2 |
<div |
| 3 |
class="ivyforms-name-fields" |
| 4 |
:class="{ 'ivyforms-name-fields--readonly': !!field?.readOnly }" |
| 5 |
> |
| 6 |
<div v-if="!field?.hideLabel" class="ivyforms-name-fields__main-label ivyforms-mb-8 regular-16"> |
| 7 |
{{ field?.label || getLabel('name') }} |
| 8 |
</div> |
| 9 |
<div |
| 10 |
class="ivyforms-name-fields__layout ivyforms-flex ivyforms-flex-direction-row ivyforms-flex-wrap-wrap ivyforms-gap-16" |
| 11 |
> |
| 12 |
<div |
| 13 |
v-for="fieldData in nameFields" |
| 14 |
:key="fieldData.id" |
| 15 |
:class="[ |
| 16 |
'ivyforms-name-fields__layout-field ivyforms-flex-1', |
| 17 |
fieldData.type.toLowerCase() + '-name', |
| 18 |
]" |
| 19 |
> |
| 20 |
<IvyFormItem |
| 21 |
:label="fieldData.optionHide ? '' : fieldData.label" |
| 22 |
:required="fieldData.required" |
| 23 |
> |
| 24 |
<IvyTextInput |
| 25 |
:id="fieldData.id" |
| 26 |
readonly |
| 27 |
:model-value="fieldData.modelValue" |
| 28 |
type="text" |
| 29 |
:placeholder="fieldData.placeholder" |
| 30 |
/> |
| 31 |
<div |
| 32 |
v-if="fieldData.description" |
| 33 |
class="ivyforms-name-fields__layout-field-description regular-14 ivyforms-width-100" |
| 34 |
> |
| 35 |
{{ fieldData.description }} |
| 36 |
</div> |
| 37 |
</IvyFormItem> |
| 38 |
</div> |
| 39 |
</div> |
| 40 |
</div> |
| 41 |
</template> |
| 42 |
|
| 43 |
<script setup lang="ts"> |
| 44 |
import { computed } from 'vue' |
| 45 |
import { useFormBuilder } from '@/stores/useFormBuilder' |
| 46 |
import { useLabels } from '@/composables/useLabels' |
| 47 |
import type { NameSubField } from '@/types/field' |
| 48 |
|
| 49 |
const { getLabel } = useLabels() |
| 50 |
|
| 51 |
const props = defineProps<{ fieldIndex: number }>() |
| 52 |
const formBuilderStore = useFormBuilder() |
| 53 |
|
| 54 |
const field = computed(() => formBuilderStore.fields.find((f) => f.fieldIndex === props.fieldIndex)) |
| 55 |
|
| 56 |
const nameFields = computed<NameSubField[]>(() => field.value?.nameFields || []) |
| 57 |
</script> |
| 58 |
|
| 59 |
<style lang="scss" scoped> |
| 60 |
.ivyforms-name-fields { |
| 61 |
cursor: move; |
| 62 |
|
| 63 |
&--readonly { |
| 64 |
opacity: 0.6; |
| 65 |
} |
| 66 |
|
| 67 |
&__main-label { |
| 68 |
color: var(--map-base-text-0); |
| 69 |
} |
| 70 |
|
| 71 |
&__layout { |
| 72 |
&-field { |
| 73 |
min-width: 150px; |
| 74 |
|
| 75 |
&-description { |
| 76 |
color: var(--map-base-text-0); |
| 77 |
display: block; |
| 78 |
white-space: normal; |
| 79 |
overflow-wrap: anywhere; |
| 80 |
word-break: break-word; |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
.ivyforms-form-item { |
| 86 |
margin-bottom: 0; |
| 87 |
cursor: move; |
| 88 |
|
| 89 |
:deep(.ivyforms-form-item__label) { |
| 90 |
display: flex; |
| 91 |
align-items: center; |
| 92 |
color: var(--map-base-text-0); |
| 93 |
font-size: 14px; |
| 94 |
font-style: normal; |
| 95 |
font-weight: 500; |
| 96 |
height: 20px !important; |
| 97 |
} |
| 98 |
|
| 99 |
:deep(.el-form-item__label) { |
| 100 |
cursor: move; |
| 101 |
} |
| 102 |
|
| 103 |
.ivyforms-input.el-input { |
| 104 |
:deep(.el-input__wrapper:hover), |
| 105 |
:deep(.el-input__wrapper.is-focus), |
| 106 |
:deep(.el-input__wrapper) { |
| 107 |
border-radius: var(--Radius-radius-md, 8px); |
| 108 |
border: 1px solid var(--map-base-dusk-stroke--2); |
| 109 |
background: var(--map-base-dusk-o05); |
| 110 |
box-shadow: none; |
| 111 |
padding: 0 12px; |
| 112 |
transition: none; |
| 113 |
cursor: move; |
| 114 |
} |
| 115 |
|
| 116 |
:deep(input) { |
| 117 |
border: none; |
| 118 |
background: transparent; |
| 119 |
cursor: move; |
| 120 |
box-shadow: none; |
| 121 |
|
| 122 |
&:focus { |
| 123 |
outline: none; |
| 124 |
border: 1px solid transparent; |
| 125 |
background: none; |
| 126 |
box-shadow: none; |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
</style> |
| 133 |
|