| 1 |
import { computed, type ComputedRef } from 'vue' |
| 2 |
import { DEFAULT_FORM_STYLES } from '@/constants/defaultFormStyles' |
| 3 |
import type { FormStyleSettings } from '@/types/form-style' |
| 4 |
|
| 5 |
const FALLBACK_HORIZONTAL_SPACING = DEFAULT_FORM_STYLES.quickMode?.horizontalSpacing || '12px' |
| 6 |
|
| 7 |
export function resolveHorizontalSpacing( |
| 8 |
styleSettings?: FormStyleSettings | null, |
| 9 |
fallback: string = FALLBACK_HORIZONTAL_SPACING, |
| 10 |
): string { |
| 11 |
if (!styleSettings) { |
| 12 |
return fallback |
| 13 |
} |
| 14 |
|
| 15 |
return ( |
| 16 |
styleSettings.advancedMode?.general?.horizontalSpacing || |
| 17 |
styleSettings.quickMode?.horizontalSpacing || |
| 18 |
fallback |
| 19 |
) |
| 20 |
} |
| 21 |
|
| 22 |
export function useHorizontalSpacing( |
| 23 |
styleSettings: ComputedRef<FormStyleSettings | null | undefined>, |
| 24 |
fallback: string = FALLBACK_HORIZONTAL_SPACING, |
| 25 |
) { |
| 26 |
return computed(() => resolveHorizontalSpacing(styleSettings.value, fallback)) |
| 27 |
} |
| 28 |
|