Files
InvoiceShelf/resources/scripts/components/form/SwitchSection.vue
Darko Gjorgjijoski f3ab0f22fc chore(frontend): fix ESLint, add Pint+ESLint pre-commit hook, centralize v-html
Fix the broken ESLint setup: add vue-eslint-parser and @typescript-eslint/parser
and wire the TS parser into eslint.config.mjs so .ts and <script lang=ts> parse
(was failing outright). Clear the resulting backlog to a clean 0/0 baseline —
fix genuine issues, relax two intentional-pattern rules (multi-word-component-names,
no-required-prop-with-default).

Add a committed .githooks/pre-commit (enabled via core.hooksPath, auto-set by the
prepare script) that runs Pint on staged PHP and ESLint --max-warnings 0 on staged
resources/scripts JS/TS/Vue, blocking on failure. Add composer/npm lint scripts and
document the gate in CLAUDE.md.

Replace every scattered v-html with a single audited BaseSanitizedHtml component
that DOMPurify-sanitizes its input (new utils/markdown.ts sanitizeHtml), so
server/registry-provided HTML is actually sanitized and vue/no-v-html stays enabled
everywhere but one reviewed sink.
2026-06-11 11:11:12 +02:00

66 lines
1.6 KiB
Vue

<template>
<SwitchGroup as="li" class="py-4 flex items-center justify-between">
<div class="flex flex-col">
<SwitchLabel
as="p"
class="p-0 mb-1 text-sm leading-snug text-heading font-medium"
passive
>
{{ title }}
</SwitchLabel>
<SwitchDescription class="text-sm text-muted">
{{ description }}
</SwitchDescription>
</div>
<Switch
:disabled="disabled"
:model-value="modelValue"
:class="[
modelValue ? 'bg-primary-500' : 'bg-surface-muted',
'ml-4 relative inline-flex shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-primary-500',
]"
@update:model-value="onUpdate"
>
<span
aria-hidden="true"
:class="[
modelValue ? 'translate-x-5' : 'translate-x-0',
'inline-block h-5 w-5 rounded-full bg-white shadow ring-0 transition ease-in-out duration-200',
]"
/>
</Switch>
</SwitchGroup>
</template>
<script setup lang="ts">
import {
Switch,
SwitchDescription,
SwitchGroup,
SwitchLabel,
} from '@headlessui/vue'
interface Props {
title: string
description?: string
modelValue?: boolean
disabled?: boolean
}
interface Emits {
(e: 'update:modelValue', value: boolean): void
}
withDefaults(defineProps<Props>(), {
description: '',
modelValue: false,
disabled: false,
})
const emit = defineEmits<Emits>()
function onUpdate(value: boolean): void {
emit('update:modelValue', value)
}
</script>