| 1 |
<template> |
| 2 |
<div |
| 3 |
:class="[ |
| 4 |
'ivyforms-field ivyforms-field__html ivyforms-mb-16', |
| 5 |
'ivyforms-field__html_' + field.id, |
| 6 |
field.cssClasses, |
| 7 |
]" |
| 8 |
> |
| 9 |
<IvyFormItem :label="field.hideLabel ? '' : field.label" :label-position="field.labelPosition"> |
| 10 |
<SafeHTML |
| 11 |
v-if="field.htmlContent" |
| 12 |
class="ivyforms-field__html-content" |
| 13 |
:html="field.htmlContent" |
| 14 |
:allowed-tags="ALLOWED_TAGS" |
| 15 |
:allowed-attributes="ALLOWED_ATTR" |
| 16 |
/> |
| 17 |
<div |
| 18 |
v-if="field.description" |
| 19 |
class="ivyforms-field__html-description ivyforms-width-100 ivyforms-mt-8 regular-14" |
| 20 |
> |
| 21 |
{{ field.description }} |
| 22 |
</div> |
| 23 |
</IvyFormItem> |
| 24 |
</div> |
| 25 |
</template> |
| 26 |
|
| 27 |
<script setup lang="ts"> |
| 28 |
import { computed } from 'vue' |
| 29 |
import SafeHTML from '@/views/_components/SafeHTML.vue' |
| 30 |
import { |
| 31 |
ALLOWED_HTML_TAGS as ALLOWED_TAGS, |
| 32 |
ALLOWED_HTML_ATTR as ALLOWED_ATTR, |
| 33 |
} from '@/constants/html-sanitization.ts' |
| 34 |
|
| 35 |
interface Field { |
| 36 |
id: number |
| 37 |
type: string |
| 38 |
label: string |
| 39 |
hideLabel?: boolean |
| 40 |
htmlContent?: string |
| 41 |
description?: string |
| 42 |
labelPosition?: string |
| 43 |
cssClasses?: string |
| 44 |
} |
| 45 |
|
| 46 |
interface Props { |
| 47 |
field: Field |
| 48 |
} |
| 49 |
|
| 50 |
const props = defineProps<Props>() |
| 51 |
const field = computed(() => props.field) |
| 52 |
</script> |
| 53 |
|
| 54 |
<style lang="scss" scoped> |
| 55 |
.ivyforms-field__html { |
| 56 |
.ivyforms-form-item { |
| 57 |
margin-bottom: 0; |
| 58 |
|
| 59 |
:deep(.ivyforms-form-item__label) { |
| 60 |
display: flex; |
| 61 |
align-items: center; |
| 62 |
color: var(--map-base-text-0); |
| 63 |
font-size: 14px; |
| 64 |
font-style: normal; |
| 65 |
font-weight: 500; |
| 66 |
line-height: 20px; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
&__html-content, |
| 71 |
.ivyforms-safe-html { |
| 72 |
width: 100%; |
| 73 |
display: block; |
| 74 |
white-space: normal; |
| 75 |
overflow-wrap: anywhere; |
| 76 |
word-break: break-word; |
| 77 |
} |
| 78 |
|
| 79 |
&-description { |
| 80 |
color: var(--map-base-text--1); |
| 81 |
display: block; |
| 82 |
white-space: normal; |
| 83 |
overflow-wrap: anywhere; |
| 84 |
word-break: break-word; |
| 85 |
} |
| 86 |
} |
| 87 |
</style> |
| 88 |
|