| 1 |
<template> |
| 2 |
<div class="ivyforms-field__numeric"> |
| 3 |
<IvyFormItem |
| 4 |
:label="hideLabel ? '' : label" |
| 5 |
:required="required" |
| 6 |
:label-position="labelPosition" |
| 7 |
> |
| 8 |
<IvyTextInput |
| 9 |
:id="index" |
| 10 |
readonly |
| 11 |
:placeholder="placeholder" |
| 12 |
:model-value="modelValue" |
| 13 |
type="number" |
| 14 |
/> |
| 15 |
<div v-if="description" class="ivyforms-description-message regular-14"> |
| 16 |
{{ description }} |
| 17 |
</div> |
| 18 |
</IvyFormItem> |
| 19 |
</div> |
| 20 |
</template> |
| 21 |
|
| 22 |
<script setup lang="ts"> |
| 23 |
import { computed } from 'vue' |
| 24 |
import { useFormBuilder } from '@/stores/useFormBuilder' |
| 25 |
|
| 26 |
const props = defineProps<{ fieldIndex: number }>() |
| 27 |
const formBuilderStore = useFormBuilder() |
| 28 |
|
| 29 |
// Computed properties to dynamically get values from the store |
| 30 |
const field = computed(() => formBuilderStore.fields.find((f) => f.fieldIndex === props.fieldIndex)) |
| 31 |
|
| 32 |
const label = computed(() => field.value?.label || '') |
| 33 |
const placeholder = computed(() => field.value?.placeholder || '') |
| 34 |
const required = computed(() => field.value?.required || false) |
| 35 |
const hideLabel = computed(() => field.value?.hideLabel || false) |
| 36 |
const index = computed(() => field.value?.fieldIndex ?? props.fieldIndex) |
| 37 |
const modelValue = computed(() => field.value?.defaultValue || '') |
| 38 |
const description = computed(() => field.value?.description || '') |
| 39 |
const labelPosition = computed(() => |
| 40 |
field.value?.labelPosition === 'default' ? 'top' : field.value?.labelPosition || 'top', |
| 41 |
) |
| 42 |
</script> |
| 43 |
|
| 44 |
<style lang="scss" scoped> |
| 45 |
.ivyforms-field__numeric { |
| 46 |
cursor: move; |
| 47 |
.ivyforms-form-item { |
| 48 |
margin-bottom: 0; |
| 49 |
:deep(.ivyforms-form-item__label) { |
| 50 |
display: flex; |
| 51 |
align-items: center; |
| 52 |
color: var(--map-base-text-0); |
| 53 |
font-size: 14px; |
| 54 |
font-style: normal; |
| 55 |
font-weight: 500; |
| 56 |
line-height: 20px; |
| 57 |
cursor: move; |
| 58 |
} |
| 59 |
:deep(.el-form-item__label) { |
| 60 |
cursor: move; |
| 61 |
} |
| 62 |
.ivyforms-input.el-input { |
| 63 |
:deep(.el-input__wrapper:hover), |
| 64 |
:deep(.el-input__wrapper.is-focus), |
| 65 |
:deep(.el-input__wrapper) { |
| 66 |
border-radius: var(--Radius-radius-md, 8px); |
| 67 |
border: 1px solid var(--map-base-dusk-stroke--2); |
| 68 |
background: var(--map-base-dusk-o05); |
| 69 |
box-shadow: none; |
| 70 |
padding: 0 12px; |
| 71 |
transition: none; |
| 72 |
cursor: move; |
| 73 |
} |
| 74 |
:deep(input) { |
| 75 |
border: none; |
| 76 |
background: transparent; |
| 77 |
cursor: move; |
| 78 |
box-shadow: none; |
| 79 |
|
| 80 |
&:focus { |
| 81 |
outline: none; |
| 82 |
border: 1px solid transparent; /* Ensure border does not change */ |
| 83 |
background: none; /* Ensure background does not change */ |
| 84 |
box-shadow: none; |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
.ivyforms-description-message { |
| 90 |
color: var(--map-base-text-0); |
| 91 |
display: block; |
| 92 |
width: 100%; |
| 93 |
white-space: normal; |
| 94 |
overflow-wrap: anywhere; |
| 95 |
word-break: break-word; |
| 96 |
} |
| 97 |
} |
| 98 |
</style> |
| 99 |
|