| 1 |
<template> |
| 2 |
<div |
| 3 |
:class="[ |
| 4 |
'field-resize-handle ivyforms-flex ivyforms-justify-content-center ivyforms-align-items-center', |
| 5 |
`field-resize-handle--${direction}`, |
| 6 |
{ |
| 7 |
'field-resize-handle--active': isResizing, |
| 8 |
'field-resize-handle--disabled': isDisabled, |
| 9 |
}, |
| 10 |
]" |
| 11 |
@mousedown="onMouseDown" |
| 12 |
> |
| 13 |
<div |
| 14 |
class="field-resize-handle__grip ivyforms-flex ivyforms-gap-2 ivyforms-align-items-center ivyforms-justify-content-center" |
| 15 |
> |
| 16 |
<div class="field-resize-handle__line"></div> |
| 17 |
<div class="field-resize-handle__line"></div> |
| 18 |
</div> |
| 19 |
</div> |
| 20 |
</template> |
| 21 |
|
| 22 |
<script setup lang="ts"> |
| 23 |
import { computed } from 'vue' |
| 24 |
import type { Field } from '@/types/field' |
| 25 |
import { useFieldResize } from '@/composables/useFieldResize' |
| 26 |
|
| 27 |
interface Props { |
| 28 |
field: Field |
| 29 |
direction: 'left' | 'right' |
| 30 |
} |
| 31 |
|
| 32 |
const props = defineProps<Props>() |
| 33 |
|
| 34 |
const { startResize, resizingField } = useFieldResize() |
| 35 |
|
| 36 |
const isResizing = computed(() => { |
| 37 |
return resizingField.value?.fieldIndex === props.field.fieldIndex |
| 38 |
}) |
| 39 |
|
| 40 |
const isDisabled = computed(() => { |
| 41 |
// Only supports right direction |
| 42 |
if (props.direction !== 'right') return true |
| 43 |
|
| 44 |
// Never disable - just enforce minimum width in the resize logic |
| 45 |
return false |
| 46 |
}) |
| 47 |
|
| 48 |
const onMouseDown = (event: MouseEvent) => { |
| 49 |
if (isDisabled.value) return |
| 50 |
startResize(event, props.field, props.direction) |
| 51 |
} |
| 52 |
</script> |
| 53 |
|
| 54 |
<style scoped lang="scss"> |
| 55 |
.field-resize-handle { |
| 56 |
position: absolute; |
| 57 |
top: 8px; |
| 58 |
bottom: 8px; |
| 59 |
width: 16px; |
| 60 |
cursor: col-resize; |
| 61 |
z-index: 150; |
| 62 |
opacity: 0; |
| 63 |
transition: opacity 0.15s ease; |
| 64 |
pointer-events: auto; |
| 65 |
|
| 66 |
&--left { |
| 67 |
left: -12px; |
| 68 |
} |
| 69 |
|
| 70 |
&--right { |
| 71 |
right: -14px; |
| 72 |
} |
| 73 |
|
| 74 |
&:hover, |
| 75 |
&--active { |
| 76 |
opacity: 1 !important; |
| 77 |
} |
| 78 |
|
| 79 |
// Keep visible when parent is being hovered for resize |
| 80 |
.ivyforms-draggable__item-wrapper--resizable:hover &, |
| 81 |
.ivyforms-draggable__item-wrapper--resizing &, |
| 82 |
.ivyforms-draggable__field-container:hover & { |
| 83 |
opacity: 1 !important; |
| 84 |
} |
| 85 |
|
| 86 |
// Global class when any field is being resized - keeps ALL handles visible |
| 87 |
:global(body.ivyforms-resizing-field) & { |
| 88 |
opacity: 1 !important; |
| 89 |
} |
| 90 |
|
| 91 |
&--disabled { |
| 92 |
cursor: not-allowed; |
| 93 |
|
| 94 |
.field-resize-handle__grip { |
| 95 |
.field-resize-handle__line { |
| 96 |
background: var(--map-base-dusk-stroke--2); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
&:hover .field-resize-handle__grip .field-resize-handle__line, |
| 101 |
&.field-resize-handle--active .field-resize-handle__grip .field-resize-handle__line { |
| 102 |
background: var(--map-base-dusk-stroke--2); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
&__grip { |
| 107 |
height: 100%; |
| 108 |
padding: 0 4px; |
| 109 |
} |
| 110 |
|
| 111 |
&__line { |
| 112 |
width: 2px; |
| 113 |
height: 24px; |
| 114 |
background: var(--map-base-purple-stroke-0); |
| 115 |
border-radius: 1px; |
| 116 |
transition: all 0.2s ease; |
| 117 |
} |
| 118 |
|
| 119 |
&:hover &__line, |
| 120 |
&--active &__line { |
| 121 |
height: 32px; |
| 122 |
background: var(--map-base-purple-symbol-0); |
| 123 |
} |
| 124 |
} |
| 125 |
</style> |
| 126 |
|