Files
InvoiceShelf/resources/scripts-v2/components/form/FormGroup.vue
Darko Gjorgjijoski e43e515614 Phase 3: Typed Vue components in scripts-v2/
Migrate all shared components to TypeScript SFCs with script setup
lang=ts. 72 files, 7144 lines, zero any types.

- components/base/ (42 files): Button, Input, Textarea, Checkbox,
  Radio, Switch, Badge, Card, Modal, Dialog, Dropdown, DatePicker,
  TimePicker, Money, FileUploader, Select, Icon, Loader, Multiselect,
  TabGroup, Wizard, CustomerSelect, ItemSelect, CustomInput, alerts,
  status badges (Invoice/Estimate/Paid/RecurringInvoice), List/ListItem
- components/table/ (3 files): DataTable, TablePagination
- components/form/ (4 files): FormGroup, FormGrid, SwitchSection
- components/layout/ (11 files): Page, PageHeader, Breadcrumb,
  FilterWrapper, EmptyPlaceholder, ContentPlaceholders, SettingCard
- components/editor/ (2 files): RichEditor with Tiptap
- components/charts/ (2 files): LineChart with Chart.js
- components/notifications/ (3 files): NotificationRoot, NotificationItem
- components/icons/ (2 files): MainLogo

All use defineProps<Props>(), defineEmits<Emits>(), typed refs,
and import domain types from types/domain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 05:45:00 +02:00

97 lines
2.4 KiB
Vue

<template>
<div :class="containerClasses" class="relative w-full text-left">
<ContentPlaceholder v-if="contentLoading">
<ContentPlaceholderText :lines="1" :class="contentLoadClass" />
</ContentPlaceholder>
<label
v-else-if="label"
:class="labelClasses"
class="
flex
text-sm
not-italic
items-center
font-medium
text-heading
whitespace-nowrap
justify-between
"
>
<div>
{{ label }}
<span v-show="required" class="text-sm text-red-500"> * </span>
</div>
<slot v-if="hasRightLabelSlot" name="labelRight" />
<BaseIcon
v-if="tooltip"
v-tooltip="{ content: tooltip }"
name="InformationCircleIcon"
class="h-4 text-subtle cursor-pointer hover:text-body"
/>
</label>
<div :class="inputContainerClasses">
<slot></slot>
<span v-if="helpText" class="text-muted text-xs mt-1 font-light">
{{ helpText }}
</span>
<span v-if="error" class="block mt-0.5 text-sm text-red-500">
{{ error }}
</span>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, useSlots } from 'vue'
import { ContentPlaceholder, ContentPlaceholderText } from '../layout'
interface Props {
contentLoading?: boolean
contentLoadClass?: string
label?: string
variant?: 'vertical' | 'horizontal'
error?: string | boolean | null
required?: boolean
tooltip?: string | null
helpText?: string | null
}
const props = withDefaults(defineProps<Props>(), {
contentLoading: false,
contentLoadClass: 'w-16 h-5',
label: '',
variant: 'vertical',
error: null,
required: false,
tooltip: null,
helpText: null,
})
const containerClasses = computed<string>(() => {
if (props.variant === 'horizontal') {
return 'grid md:grid-cols-12 items-center'
}
return ''
})
const labelClasses = computed<string>(() => {
if (props.variant === 'horizontal') {
return 'relative pr-0 pt-1 mr-3 text-sm md:col-span-4 md:text-right mb-1 md:mb-0'
}
return ''
})
const inputContainerClasses = computed<string>(() => {
if (props.variant === 'horizontal') {
return 'md:col-span-8 md:col-start-5 md:col-ends-12'
}
return 'flex flex-col mt-1'
})
const slots = useSlots()
const hasRightLabelSlot = computed<boolean>(() => {
return !!slots.labelRight
})
</script>