<script setup lang="ts">
const props = withDefaults(
  defineProps<{
    labelFor: string
    size?: 'default' | 'narrow' | 'wide'
    height?: 'default' | 'compact'
    position?: 'default' | 'dynamic'
  }>(),
  {
    size: 'default',
    height: 'default',
    position: 'default',
  },
)

const sizeMap = {
  default: 'w-28 2xl:w-36',
  narrow: 'w-24 2xl:w-28',
  wide: 'w-44 2xl:w-48',
} as const

const heightMap = {
  default: 'pt-2 2xl:pt-2.5',
  compact: 'leading-[14pt]',
} as const

const positionWrapMap = {
  default: 'pe-2 text-start',
  dynamic: 'md:text-end',
} as const

const positionChildMap = {
  default: '',
  dynamic: 'block pe-2.5',
} as const

const wrapperClass = computed(() => [
  'block shrink-0',
  sizeMap[props.size],
  heightMap[props.height],
  positionWrapMap[props.position],
])

const labelClass = computed(() => positionChildMap[props.position])
</script>

<template>
  <div :class="wrapperClass">
    <label :class="labelClass" :for="labelFor">
      <slot />
    </label>
  </div>
</template>
