Phase 4: Seiten mit Pagebuilder, Redaktion und Freigaben
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m2s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m40s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m2s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m40s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
- Seiten-Plugin: Seitenbaum mit Adressen, Seitennavigation, Brotkrumen und optional Hauptnavigation; Sichtbarkeit vererbt sich auf Unterseiten - Pagebuilder (Block-Registry im Kern, Plugins tragen Blöcke bei): Abschnitt, Spalten, Tabs, Akkordeon, Box, Überschrift, Text (TipTap), Zitat, Schaltflächen, Symbolliste, Tabelle, Trennlinie, Abstand, Bild, Galerie, Video (erst nach Klick), Titelbild, Ansprechpartner, Downloads, Unterseiten, Neuigkeiten, Termine; Sichtbarkeit je Block; Bereinigung beim Speichern - Editor im Portal: Ziehen und Ablegen, Autospeichern als Entwurf, Rückgängig, Gerätevorschau, Versionen, Zeitsteuerung, Bearbeitungssperre, Freigabe anfordern - Rechte „inkl. Unterseiten“ werden im Rechte-Cache aufgelöst - Neuigkeiten: Schreiben im Portal, Freigabe-Workflow mit Benachrichtigungen - Bereich „Redaktion“, Benachrichtigungen im Portal - storage/.migrations-fingerprint nicht mehr ausliefern Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6269d3302c
commit
f3987e8386
328 changed files with 10618 additions and 389 deletions
|
|
@ -138,3 +138,12 @@
|
|||
.prose :where(blockquote p:last-of-type)::after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
/* Text in farbigen Boxen des Pagebuilders übernimmt die Farbe der Box. */
|
||||
.pb-box .prose {
|
||||
--tw-prose-body: currentColor;
|
||||
--tw-prose-bold: currentColor;
|
||||
--tw-prose-links: currentColor;
|
||||
--tw-prose-bullets: currentColor;
|
||||
--tw-prose-headings: currentColor;
|
||||
}
|
||||
|
|
|
|||
27
resources/js/components/NativeSelect.vue
Normal file
27
resources/js/components/NativeSelect.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { ChevronDown } from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Schlichtes Auswahlfeld im Stil der Eingabefelder – zuverlässig auf allen Geräten.
|
||||
*/
|
||||
defineProps({
|
||||
options: { type: Array, required: true }, // [{ value, label }]
|
||||
placeholder: { type: String, default: '' },
|
||||
});
|
||||
|
||||
const model = defineModel({ type: [String, Number, null], default: null });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative">
|
||||
<select
|
||||
v-model="model"
|
||||
class="h-9 w-full appearance-none rounded-md border border-input bg-card pr-8 pl-3 text-sm shadow-xs focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none disabled:opacity-60"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<option v-if="placeholder" :value="null">{{ placeholder }}</option>
|
||||
<option v-for="option in options" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<ChevronDown class="pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
</div>
|
||||
</template>
|
||||
80
resources/js/components/NotificationBell.vue
Normal file
80
resources/js/components/NotificationBell.vue
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { router, usePage } from '@inertiajs/vue3';
|
||||
import { Bell, CheckCheck, FileCheck, LoaderCircle, MessageSquare, Newspaper, Undo2 } from '@lucide/vue';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { http } from '@/lib/http';
|
||||
import { formatRelative } from '@/lib/format';
|
||||
|
||||
/**
|
||||
* Glocke im Header: Benachrichtigungen (z. B. Freigabe angefordert, Beitrag freigegeben).
|
||||
*/
|
||||
const page = usePage();
|
||||
const unread = computed(() => page.props.notifications?.unread ?? 0);
|
||||
const items = ref(null);
|
||||
const localUnread = ref(null);
|
||||
const count = computed(() => localUnread.value ?? unread.value);
|
||||
|
||||
const icons = { 'file-check': FileCheck, newspaper: Newspaper, undo: Undo2, message: MessageSquare };
|
||||
|
||||
async function load(open) {
|
||||
if (!open) return;
|
||||
|
||||
items.value = null;
|
||||
const data = await http.get('/benachrichtigungen');
|
||||
items.value = data.notifications;
|
||||
localUnread.value = data.unread;
|
||||
}
|
||||
|
||||
async function markAll() {
|
||||
await http.post('/benachrichtigungen/gelesen');
|
||||
items.value = items.value.map((item) => ({ ...item, read: true }));
|
||||
localUnread.value = 0;
|
||||
}
|
||||
|
||||
function open(item) {
|
||||
localUnread.value = null;
|
||||
router.visit(`/benachrichtigungen/${item.id}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Popover @update:open="load">
|
||||
<PopoverTrigger
|
||||
class="relative grid size-10 place-items-center rounded-md text-foreground/70 hover:bg-accent hover:text-foreground"
|
||||
:aria-label="count ? `Benachrichtigungen, ${count} ungelesen` : 'Benachrichtigungen'"
|
||||
>
|
||||
<Bell class="size-5" />
|
||||
<span v-if="count" class="absolute top-1.5 right-1.5 grid h-4 min-w-4 place-items-center rounded-full bg-brand px-1 text-[10px] leading-none font-semibold text-brand-foreground">
|
||||
{{ count > 9 ? '9+' : count }}
|
||||
</span>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" class="w-[22rem] p-0">
|
||||
<div class="flex items-center justify-between border-b px-4 py-3">
|
||||
<h2 class="text-sm font-semibold">Benachrichtigungen</h2>
|
||||
<button v-if="count" type="button" class="inline-flex items-center gap-1 text-xs font-medium text-brand-text hover:underline" @click="markAll">
|
||||
<CheckCheck class="size-3.5" /> Alle gelesen
|
||||
</button>
|
||||
</div>
|
||||
<div class="max-h-[60vh] overflow-y-auto">
|
||||
<div v-if="items === null" class="grid place-items-center py-8"><LoaderCircle class="size-5 animate-spin text-muted-foreground" /></div>
|
||||
<p v-else-if="!items.length" class="px-4 py-8 text-center text-sm text-muted-foreground">Keine Benachrichtigungen.</p>
|
||||
<ul v-else class="divide-y">
|
||||
<li v-for="item in items" :key="item.id">
|
||||
<button type="button" class="flex w-full gap-3 px-4 py-3 text-left hover:bg-accent/60" @click="open(item)">
|
||||
<span class="mt-0.5 grid size-8 shrink-0 place-items-center rounded-full" :class="item.read ? 'bg-muted text-muted-foreground' : 'bg-brand-soft text-brand-text'">
|
||||
<component :is="icons[item.icon] ?? Bell" class="size-4" />
|
||||
</span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block text-sm" :class="item.read ? 'text-foreground/80' : 'font-semibold'">{{ item.title }}</span>
|
||||
<span v-if="item.body" class="mt-0.5 line-clamp-2 block text-[13px] text-muted-foreground">{{ item.body }}</span>
|
||||
<span class="mt-1 block text-xs text-muted-foreground">{{ formatRelative(item.created_at) }}</span>
|
||||
</span>
|
||||
<span v-if="!item.read" class="mt-2 size-2 shrink-0 rounded-full bg-brand" aria-label="ungelesen" />
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
174
resources/js/components/RichTextEditor.vue
Normal file
174
resources/js/components/RichTextEditor.vue
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<script setup>
|
||||
import { onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { EditorContent, useEditor } from '@tiptap/vue-3';
|
||||
import StarterKit from '@tiptap/starter-kit';
|
||||
import Image from '@tiptap/extension-image';
|
||||
import { Placeholder } from '@tiptap/extensions';
|
||||
import {
|
||||
Bold,
|
||||
Check,
|
||||
Heading2,
|
||||
Heading3,
|
||||
ImagePlus,
|
||||
Italic,
|
||||
Link as LinkIcon,
|
||||
List,
|
||||
ListOrdered,
|
||||
LoaderCircle,
|
||||
Quote,
|
||||
Redo2,
|
||||
Underline,
|
||||
Undo2,
|
||||
Unlink,
|
||||
X,
|
||||
} from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Formatierter Text (TipTap). Liefert HTML – bereinigt wird auf dem Server
|
||||
* (App\Support\RichText::sanitize). Bilder nur, wenn uploadImage übergeben wird.
|
||||
*/
|
||||
const props = defineProps({
|
||||
modelValue: { type: String, default: '' },
|
||||
placeholder: { type: String, default: '' },
|
||||
headings: { type: Array, default: () => [2, 3] },
|
||||
uploadImage: { type: Function, default: null },
|
||||
minHeight: { type: String, default: '' },
|
||||
bordered: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
const editor = useEditor({
|
||||
content: props.modelValue,
|
||||
extensions: [
|
||||
StarterKit.configure({
|
||||
heading: { levels: props.headings },
|
||||
code: false,
|
||||
codeBlock: false,
|
||||
link: { openOnClick: false, autolink: true, protocols: ['mailto', 'tel'], HTMLAttributes: { rel: 'noopener noreferrer', target: null } },
|
||||
}),
|
||||
Image.configure({ HTMLAttributes: { loading: 'lazy' } }),
|
||||
Placeholder.configure({ placeholder: props.placeholder }),
|
||||
],
|
||||
editorProps: {
|
||||
attributes: {
|
||||
class: 'prose prose-neutral max-w-none focus:outline-none prose-headings:tracking-tight prose-img:rounded-lg',
|
||||
},
|
||||
},
|
||||
onUpdate: ({ editor }) => emit('update:modelValue', editor.isEmpty ? '' : editor.getHTML()),
|
||||
});
|
||||
|
||||
watch(() => props.modelValue, (value) => {
|
||||
if (editor.value && value !== editor.value.getHTML() && !(value === '' && editor.value.isEmpty)) {
|
||||
editor.value.commands.setContent(value || '', { emitUpdate: false });
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => editor.value?.destroy());
|
||||
|
||||
// Link bearbeiten
|
||||
const linkOpen = ref(false);
|
||||
const linkUrl = ref('');
|
||||
|
||||
function openLink() {
|
||||
linkUrl.value = editor.value.getAttributes('link').href ?? '';
|
||||
linkOpen.value = true;
|
||||
}
|
||||
|
||||
function applyLink() {
|
||||
let url = linkUrl.value.trim();
|
||||
|
||||
if (url && !/^(https?:\/\/|mailto:|tel:|\/|#)/i.test(url)) {
|
||||
url = `https://${url}`;
|
||||
}
|
||||
|
||||
const chain = editor.value.chain().focus().extendMarkRange('link');
|
||||
(url ? chain.setLink({ href: url }) : chain.unsetLink()).run();
|
||||
linkOpen.value = false;
|
||||
}
|
||||
|
||||
// Bild einfügen
|
||||
const fileInput = ref(null);
|
||||
const uploading = ref(false);
|
||||
|
||||
async function insertImage(event) {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
|
||||
if (!file || !props.uploadImage) return;
|
||||
|
||||
uploading.value = true;
|
||||
|
||||
try {
|
||||
const url = await props.uploadImage(file);
|
||||
editor.value.chain().focus().setImage({ src: url, alt: '' }).run();
|
||||
} finally {
|
||||
uploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const buttonClass = (active) => [
|
||||
'grid size-8 place-items-center rounded-md transition-colors disabled:opacity-40',
|
||||
active ? 'bg-brand-soft text-brand-soft-foreground' : 'text-muted-foreground hover:bg-accent hover:text-foreground',
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="editor" class="group/rte" :class="bordered ? 'rounded-md border border-input bg-card shadow-xs focus-within:border-brand-400 focus-within:ring-3 focus-within:ring-ring/30' : ''">
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-0.5"
|
||||
:class="bordered ? 'border-b px-1.5 py-1' : 'sticky top-0 z-10 -mx-1 mb-2 hidden rounded-md border bg-card px-1 py-0.5 shadow-sm group-focus-within/rte:flex'"
|
||||
role="toolbar"
|
||||
aria-label="Textformatierung"
|
||||
@mousedown.prevent
|
||||
>
|
||||
<button type="button" :class="buttonClass(editor.isActive('bold'))" title="Fett (Strg+B)" @click="editor.chain().focus().toggleBold().run()"><Bold class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(editor.isActive('italic'))" title="Kursiv (Strg+I)" @click="editor.chain().focus().toggleItalic().run()"><Italic class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(editor.isActive('underline'))" title="Unterstrichen (Strg+U)" @click="editor.chain().focus().toggleUnderline().run()"><Underline class="size-4" /></button>
|
||||
<span class="mx-1 h-5 w-px bg-border" />
|
||||
<button v-if="headings.includes(2)" type="button" :class="buttonClass(editor.isActive('heading', { level: 2 }))" title="Zwischenüberschrift" @click="editor.chain().focus().toggleHeading({ level: 2 }).run()"><Heading2 class="size-4" /></button>
|
||||
<button v-if="headings.includes(3)" type="button" :class="buttonClass(editor.isActive('heading', { level: 3 }))" title="Kleine Überschrift" @click="editor.chain().focus().toggleHeading({ level: 3 }).run()"><Heading3 class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(editor.isActive('bulletList'))" title="Aufzählung" @click="editor.chain().focus().toggleBulletList().run()"><List class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(editor.isActive('orderedList'))" title="Nummerierte Liste" @click="editor.chain().focus().toggleOrderedList().run()"><ListOrdered class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(editor.isActive('blockquote'))" title="Zitat" @click="editor.chain().focus().toggleBlockquote().run()"><Quote class="size-4" /></button>
|
||||
<span class="mx-1 h-5 w-px bg-border" />
|
||||
<button type="button" :class="buttonClass(editor.isActive('link'))" title="Link" @click="openLink"><LinkIcon class="size-4" /></button>
|
||||
<button v-if="editor.isActive('link')" type="button" :class="buttonClass(false)" title="Link entfernen" @click="editor.chain().focus().unsetLink().run()"><Unlink class="size-4" /></button>
|
||||
<template v-if="uploadImage">
|
||||
<button type="button" :class="buttonClass(false)" title="Bild einfügen" :disabled="uploading" @click="fileInput?.click()">
|
||||
<LoaderCircle v-if="uploading" class="size-4 animate-spin" />
|
||||
<ImagePlus v-else class="size-4" />
|
||||
</button>
|
||||
<input ref="fileInput" type="file" accept="image/jpeg,image/png,image/webp,image/gif" class="hidden" @change="insertImage" />
|
||||
</template>
|
||||
<span class="mx-1 h-5 w-px bg-border" />
|
||||
<button type="button" :class="buttonClass(false)" title="Rückgängig" :disabled="!editor.can().undo()" @click="editor.chain().focus().undo().run()"><Undo2 class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(false)" title="Wiederholen" :disabled="!editor.can().redo()" @click="editor.chain().focus().redo().run()"><Redo2 class="size-4" /></button>
|
||||
|
||||
<form v-if="linkOpen" class="flex w-full items-center gap-1 border-t px-1 pt-1.5 pb-1" @submit.prevent="applyLink" @mousedown.stop>
|
||||
<input
|
||||
v-model="linkUrl"
|
||||
type="text"
|
||||
placeholder="https://… oder /seiten/…"
|
||||
class="h-8 min-w-0 flex-1 rounded-md border border-input bg-card px-2 text-sm focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/30"
|
||||
aria-label="Adresse des Links"
|
||||
autofocus
|
||||
/>
|
||||
<button type="submit" :class="buttonClass(false)" title="Übernehmen"><Check class="size-4" /></button>
|
||||
<button type="button" :class="buttonClass(false)" title="Abbrechen" @click="linkOpen = false"><X class="size-4" /></button>
|
||||
</form>
|
||||
</div>
|
||||
<EditorContent :editor="editor" :class="[bordered ? 'px-4 py-3' : '', minHeight]" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.tiptap p.is-editor-empty:first-child::before {
|
||||
content: attr(data-placeholder);
|
||||
float: left;
|
||||
height: 0;
|
||||
pointer-events: none;
|
||||
color: var(--muted-foreground);
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
18
resources/js/components/ui/accordion/Accordion.vue
Normal file
18
resources/js/components/ui/accordion/Accordion.vue
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<script setup lang="ts">
|
||||
import type { AccordionRootEmits, AccordionRootProps } from "reka-ui"
|
||||
import {
|
||||
AccordionRoot,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
|
||||
const props = defineProps<AccordionRootProps>()
|
||||
const emits = defineEmits<AccordionRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccordionRoot v-slot="slotProps" data-slot="accordion" v-bind="forwarded">
|
||||
<slot v-bind="slotProps" />
|
||||
</AccordionRoot>
|
||||
</template>
|
||||
23
resources/js/components/ui/accordion/AccordionContent.vue
Normal file
23
resources/js/components/ui/accordion/AccordionContent.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<script setup lang="ts">
|
||||
import type { AccordionContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { AccordionContent } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<AccordionContentProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccordionContent
|
||||
data-slot="accordion-content"
|
||||
v-bind="delegatedProps"
|
||||
class="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
|
||||
>
|
||||
<div :class="cn('pt-0 pb-4', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</template>
|
||||
24
resources/js/components/ui/accordion/AccordionItem.vue
Normal file
24
resources/js/components/ui/accordion/AccordionItem.vue
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<script setup lang="ts">
|
||||
import type { AccordionItemProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { AccordionItem, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<AccordionItemProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccordionItem
|
||||
v-slot="slotProps"
|
||||
data-slot="accordion-item"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('border-b last:border-b-0', props.class)"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</AccordionItem>
|
||||
</template>
|
||||
37
resources/js/components/ui/accordion/AccordionTrigger.vue
Normal file
37
resources/js/components/ui/accordion/AccordionTrigger.vue
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<script setup lang="ts">
|
||||
import type { AccordionTriggerProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { ChevronDown } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
AccordionHeader,
|
||||
AccordionTrigger,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<AccordionTriggerProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccordionHeader class="flex">
|
||||
<AccordionTrigger
|
||||
data-slot="accordion-trigger"
|
||||
v-bind="delegatedProps"
|
||||
:class="
|
||||
cn(
|
||||
'focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
<slot name="icon">
|
||||
<ChevronDown
|
||||
class="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"
|
||||
/>
|
||||
</slot>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeader>
|
||||
</template>
|
||||
4
resources/js/components/ui/accordion/index.ts
Normal file
4
resources/js/components/ui/accordion/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { default as Accordion } from "./Accordion.vue"
|
||||
export { default as AccordionContent } from "./AccordionContent.vue"
|
||||
export { default as AccordionItem } from "./AccordionItem.vue"
|
||||
export { default as AccordionTrigger } from "./AccordionTrigger.vue"
|
||||
15
resources/js/components/ui/alert-dialog/AlertDialog.vue
Normal file
15
resources/js/components/ui/alert-dialog/AlertDialog.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogEmits, AlertDialogProps } from "reka-ui"
|
||||
import { AlertDialogRoot, useForwardPropsEmits } from "reka-ui"
|
||||
|
||||
const props = defineProps<AlertDialogProps>()
|
||||
const emits = defineEmits<AlertDialogEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogRoot v-slot="slotProps" data-slot="alert-dialog" v-bind="forwarded">
|
||||
<slot v-bind="slotProps" />
|
||||
</AlertDialogRoot>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogActionProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { AlertDialogAction } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = defineProps<AlertDialogActionProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogAction v-bind="delegatedProps" :class="cn(buttonVariants(), props.class)">
|
||||
<slot />
|
||||
</AlertDialogAction>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogCancelProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { AlertDialogCancel } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = defineProps<AlertDialogCancelProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogCancel
|
||||
v-bind="delegatedProps"
|
||||
:class="cn(
|
||||
buttonVariants({ variant: 'outline' }),
|
||||
'mt-2 sm:mt-0',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogCancel>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogContentEmits, AlertDialogContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
AlertDialogContent,
|
||||
AlertDialogOverlay,
|
||||
AlertDialogPortal,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = defineProps<AlertDialogContentProps & { class?: HTMLAttributes["class"] }>()
|
||||
const emits = defineEmits<AlertDialogContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogPortal>
|
||||
<AlertDialogOverlay
|
||||
data-slot="alert-dialog-overlay"
|
||||
class="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80"
|
||||
/>
|
||||
<AlertDialogContent
|
||||
data-slot="alert-dialog-content"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="
|
||||
cn(
|
||||
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogContent>
|
||||
</AlertDialogPortal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogDescriptionProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
AlertDialogDescription,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<AlertDialogDescriptionProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogDescription
|
||||
data-slot="alert-dialog-description"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('text-muted-foreground text-sm', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogDescription>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes["class"]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-dialog-footer"
|
||||
:class="
|
||||
cn(
|
||||
'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes["class"]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-dialog-header"
|
||||
:class="cn('flex flex-col gap-2 text-center sm:text-left', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
21
resources/js/components/ui/alert-dialog/AlertDialogTitle.vue
Normal file
21
resources/js/components/ui/alert-dialog/AlertDialogTitle.vue
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogTitleProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { AlertDialogTitle } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<AlertDialogTitleProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogTitle
|
||||
data-slot="alert-dialog-title"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('text-lg font-semibold', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogTitle>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
import type { AlertDialogTriggerProps } from "reka-ui"
|
||||
import { AlertDialogTrigger } from "reka-ui"
|
||||
|
||||
const props = defineProps<AlertDialogTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogTrigger data-slot="alert-dialog-trigger" v-bind="props">
|
||||
<slot />
|
||||
</AlertDialogTrigger>
|
||||
</template>
|
||||
9
resources/js/components/ui/alert-dialog/index.ts
Normal file
9
resources/js/components/ui/alert-dialog/index.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export { default as AlertDialog } from "./AlertDialog.vue"
|
||||
export { default as AlertDialogAction } from "./AlertDialogAction.vue"
|
||||
export { default as AlertDialogCancel } from "./AlertDialogCancel.vue"
|
||||
export { default as AlertDialogContent } from "./AlertDialogContent.vue"
|
||||
export { default as AlertDialogDescription } from "./AlertDialogDescription.vue"
|
||||
export { default as AlertDialogFooter } from "./AlertDialogFooter.vue"
|
||||
export { default as AlertDialogHeader } from "./AlertDialogHeader.vue"
|
||||
export { default as AlertDialogTitle } from "./AlertDialogTitle.vue"
|
||||
export { default as AlertDialogTrigger } from "./AlertDialogTrigger.vue"
|
||||
19
resources/js/components/ui/dialog/Dialog.vue
Normal file
19
resources/js/components/ui/dialog/Dialog.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogRootEmits, DialogRootProps } from "reka-ui"
|
||||
import { DialogRoot, useForwardPropsEmits } from "reka-ui"
|
||||
|
||||
const props = defineProps<DialogRootProps>()
|
||||
const emits = defineEmits<DialogRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="dialog"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</DialogRoot>
|
||||
</template>
|
||||
15
resources/js/components/ui/dialog/DialogClose.vue
Normal file
15
resources/js/components/ui/dialog/DialogClose.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogCloseProps } from "reka-ui"
|
||||
import { DialogClose } from "reka-ui"
|
||||
|
||||
const props = defineProps<DialogCloseProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogClose
|
||||
data-slot="dialog-close"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</DialogClose>
|
||||
</template>
|
||||
53
resources/js/components/ui/dialog/DialogContent.vue
Normal file
53
resources/js/components/ui/dialog/DialogContent.vue
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogContentEmits, DialogContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { X } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogPortal,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
import DialogOverlay from "./DialogOverlay.vue"
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = withDefaults(defineProps<DialogContentProps & { class?: HTMLAttributes["class"], showCloseButton?: boolean }>(), {
|
||||
showCloseButton: true,
|
||||
})
|
||||
const emits = defineEmits<DialogContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogContent
|
||||
data-slot="dialog-content"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="
|
||||
cn(
|
||||
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
|
||||
<DialogClose
|
||||
v-if="showCloseButton"
|
||||
data-slot="dialog-close"
|
||||
class="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
||||
>
|
||||
<X />
|
||||
<span class="sr-only">Schließen</span>
|
||||
</DialogClose>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</template>
|
||||
23
resources/js/components/ui/dialog/DialogDescription.vue
Normal file
23
resources/js/components/ui/dialog/DialogDescription.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogDescriptionProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { DialogDescription, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<DialogDescriptionProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogDescription
|
||||
data-slot="dialog-description"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('text-muted-foreground text-sm', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</DialogDescription>
|
||||
</template>
|
||||
27
resources/js/components/ui/dialog/DialogFooter.vue
Normal file
27
resources/js/components/ui/dialog/DialogFooter.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { DialogClose } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
class?: HTMLAttributes["class"]
|
||||
showCloseButton?: boolean
|
||||
}>(), {
|
||||
showCloseButton: false,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="dialog-footer"
|
||||
:class="cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', props.class)"
|
||||
>
|
||||
<slot />
|
||||
<DialogClose v-if="showCloseButton" as-child>
|
||||
<Button variant="outline">
|
||||
Close
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</div>
|
||||
</template>
|
||||
17
resources/js/components/ui/dialog/DialogHeader.vue
Normal file
17
resources/js/components/ui/dialog/DialogHeader.vue
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes["class"]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="dialog-header"
|
||||
:class="cn('flex flex-col gap-2 text-center sm:text-left', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
21
resources/js/components/ui/dialog/DialogOverlay.vue
Normal file
21
resources/js/components/ui/dialog/DialogOverlay.vue
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogOverlayProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { DialogOverlay } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<DialogOverlayProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogOverlay
|
||||
data-slot="dialog-overlay"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</DialogOverlay>
|
||||
</template>
|
||||
59
resources/js/components/ui/dialog/DialogScrollContent.vue
Normal file
59
resources/js/components/ui/dialog/DialogScrollContent.vue
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogContentEmits, DialogContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { X } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogOverlay,
|
||||
DialogPortal,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = defineProps<DialogContentProps & { class?: HTMLAttributes["class"] }>()
|
||||
const emits = defineEmits<DialogContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<DialogOverlay
|
||||
class="fixed inset-0 z-50 grid place-items-center overflow-y-auto bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
|
||||
>
|
||||
<DialogContent
|
||||
:class="
|
||||
cn(
|
||||
'relative z-50 grid w-full max-w-lg my-8 gap-4 border border-border bg-background p-6 shadow-lg duration-200 sm:rounded-lg md:w-full',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
@pointer-down-outside="(event) => {
|
||||
const originalEvent = event.detail.originalEvent;
|
||||
const target = originalEvent.target as HTMLElement;
|
||||
if (originalEvent.offsetX > target.clientWidth || originalEvent.offsetY > target.clientHeight) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}"
|
||||
>
|
||||
<slot />
|
||||
|
||||
<DialogClose
|
||||
class="absolute top-4 right-4 p-0.5 transition-colors rounded-md hover:bg-secondary"
|
||||
>
|
||||
<X class="w-4 h-4" />
|
||||
<span class="sr-only">Schließen</span>
|
||||
</DialogClose>
|
||||
</DialogContent>
|
||||
</DialogOverlay>
|
||||
</DialogPortal>
|
||||
</template>
|
||||
23
resources/js/components/ui/dialog/DialogTitle.vue
Normal file
23
resources/js/components/ui/dialog/DialogTitle.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogTitleProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { DialogTitle, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<DialogTitleProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogTitle
|
||||
data-slot="dialog-title"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('text-lg leading-none font-semibold', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</DialogTitle>
|
||||
</template>
|
||||
15
resources/js/components/ui/dialog/DialogTrigger.vue
Normal file
15
resources/js/components/ui/dialog/DialogTrigger.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { DialogTriggerProps } from "reka-ui"
|
||||
import { DialogTrigger } from "reka-ui"
|
||||
|
||||
const props = defineProps<DialogTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogTrigger
|
||||
data-slot="dialog-trigger"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</DialogTrigger>
|
||||
</template>
|
||||
10
resources/js/components/ui/dialog/index.ts
Normal file
10
resources/js/components/ui/dialog/index.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export { default as Dialog } from "./Dialog.vue"
|
||||
export { default as DialogClose } from "./DialogClose.vue"
|
||||
export { default as DialogContent } from "./DialogContent.vue"
|
||||
export { default as DialogDescription } from "./DialogDescription.vue"
|
||||
export { default as DialogFooter } from "./DialogFooter.vue"
|
||||
export { default as DialogHeader } from "./DialogHeader.vue"
|
||||
export { default as DialogOverlay } from "./DialogOverlay.vue"
|
||||
export { default as DialogScrollContent } from "./DialogScrollContent.vue"
|
||||
export { default as DialogTitle } from "./DialogTitle.vue"
|
||||
export { default as DialogTrigger } from "./DialogTrigger.vue"
|
||||
19
resources/js/components/ui/popover/Popover.vue
Normal file
19
resources/js/components/ui/popover/Popover.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup lang="ts">
|
||||
import type { PopoverRootEmits, PopoverRootProps } from "reka-ui"
|
||||
import { PopoverRoot, useForwardPropsEmits } from "reka-ui"
|
||||
|
||||
const props = defineProps<PopoverRootProps>()
|
||||
const emits = defineEmits<PopoverRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PopoverRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="popover"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</PopoverRoot>
|
||||
</template>
|
||||
15
resources/js/components/ui/popover/PopoverAnchor.vue
Normal file
15
resources/js/components/ui/popover/PopoverAnchor.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { PopoverAnchorProps } from "reka-ui"
|
||||
import { PopoverAnchor } from "reka-ui"
|
||||
|
||||
const props = defineProps<PopoverAnchorProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PopoverAnchor
|
||||
data-slot="popover-anchor"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</PopoverAnchor>
|
||||
</template>
|
||||
45
resources/js/components/ui/popover/PopoverContent.vue
Normal file
45
resources/js/components/ui/popover/PopoverContent.vue
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<script setup lang="ts">
|
||||
import type { PopoverContentEmits, PopoverContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
PopoverContent,
|
||||
PopoverPortal,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<PopoverContentProps & { class?: HTMLAttributes["class"] }>(),
|
||||
{
|
||||
align: "center",
|
||||
sideOffset: 4,
|
||||
},
|
||||
)
|
||||
const emits = defineEmits<PopoverContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PopoverPortal>
|
||||
<PopoverContent
|
||||
data-slot="popover-content"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="
|
||||
cn(
|
||||
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 max-w-(--reka-popover-content-available-width) rounded-md border p-4 shadow-md origin-(--reka-popover-content-transform-origin) outline-hidden',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</PopoverContent>
|
||||
</PopoverPortal>
|
||||
</template>
|
||||
15
resources/js/components/ui/popover/PopoverTrigger.vue
Normal file
15
resources/js/components/ui/popover/PopoverTrigger.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { PopoverTriggerProps } from "reka-ui"
|
||||
import { PopoverTrigger } from "reka-ui"
|
||||
|
||||
const props = defineProps<PopoverTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PopoverTrigger
|
||||
data-slot="popover-trigger"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</PopoverTrigger>
|
||||
</template>
|
||||
4
resources/js/components/ui/popover/index.ts
Normal file
4
resources/js/components/ui/popover/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { default as Popover } from "./Popover.vue"
|
||||
export { default as PopoverAnchor } from "./PopoverAnchor.vue"
|
||||
export { default as PopoverContent } from "./PopoverContent.vue"
|
||||
export { default as PopoverTrigger } from "./PopoverTrigger.vue"
|
||||
19
resources/js/components/ui/select/Select.vue
Normal file
19
resources/js/components/ui/select/Select.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectRootEmits, SelectRootProps } from "reka-ui"
|
||||
import { SelectRoot, useForwardPropsEmits } from "reka-ui"
|
||||
|
||||
const props = defineProps<SelectRootProps>()
|
||||
const emits = defineEmits<SelectRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="select"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</SelectRoot>
|
||||
</template>
|
||||
51
resources/js/components/ui/select/SelectContent.vue
Normal file
51
resources/js/components/ui/select/SelectContent.vue
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectContentEmits, SelectContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
SelectContent,
|
||||
SelectPortal,
|
||||
SelectViewport,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { SelectScrollDownButton, SelectScrollUpButton } from "."
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<SelectContentProps & { class?: HTMLAttributes["class"] }>(),
|
||||
{
|
||||
position: "popper",
|
||||
},
|
||||
)
|
||||
const emits = defineEmits<SelectContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectPortal>
|
||||
<SelectContent
|
||||
data-slot="select-content"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="cn(
|
||||
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--reka-select-content-available-height) min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-md border shadow-md',
|
||||
position === 'popper'
|
||||
&& 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectViewport :class="cn('p-1', position === 'popper' && 'h-(--reka-select-trigger-height) w-full min-w-(--reka-select-trigger-width) scroll-my-1')">
|
||||
<slot />
|
||||
</SelectViewport>
|
||||
<SelectScrollDownButton />
|
||||
</SelectContent>
|
||||
</SelectPortal>
|
||||
</template>
|
||||
15
resources/js/components/ui/select/SelectGroup.vue
Normal file
15
resources/js/components/ui/select/SelectGroup.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectGroupProps } from "reka-ui"
|
||||
import { SelectGroup } from "reka-ui"
|
||||
|
||||
const props = defineProps<SelectGroupProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectGroup
|
||||
data-slot="select-group"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</SelectGroup>
|
||||
</template>
|
||||
44
resources/js/components/ui/select/SelectItem.vue
Normal file
44
resources/js/components/ui/select/SelectItem.vue
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectItemProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { Check } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
SelectItem,
|
||||
SelectItemIndicator,
|
||||
SelectItemText,
|
||||
useForwardProps,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<SelectItemProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectItem
|
||||
data-slot="select-item"
|
||||
v-bind="forwardedProps"
|
||||
:class="
|
||||
cn(
|
||||
`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<span class="absolute right-2 flex size-3.5 items-center justify-center">
|
||||
<SelectItemIndicator>
|
||||
<slot name="indicator-icon">
|
||||
<Check class="size-4" />
|
||||
</slot>
|
||||
</SelectItemIndicator>
|
||||
</span>
|
||||
|
||||
<SelectItemText>
|
||||
<slot />
|
||||
</SelectItemText>
|
||||
</SelectItem>
|
||||
</template>
|
||||
15
resources/js/components/ui/select/SelectItemText.vue
Normal file
15
resources/js/components/ui/select/SelectItemText.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectItemTextProps } from "reka-ui"
|
||||
import { SelectItemText } from "reka-ui"
|
||||
|
||||
const props = defineProps<SelectItemTextProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectItemText
|
||||
data-slot="select-item-text"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</SelectItemText>
|
||||
</template>
|
||||
17
resources/js/components/ui/select/SelectLabel.vue
Normal file
17
resources/js/components/ui/select/SelectLabel.vue
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectLabelProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { SelectLabel } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<SelectLabelProps & { class?: HTMLAttributes["class"] }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectLabel
|
||||
data-slot="select-label"
|
||||
:class="cn('text-muted-foreground px-2 py-1.5 text-xs', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</SelectLabel>
|
||||
</template>
|
||||
26
resources/js/components/ui/select/SelectScrollDownButton.vue
Normal file
26
resources/js/components/ui/select/SelectScrollDownButton.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectScrollDownButtonProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { ChevronDown } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { SelectScrollDownButton, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<SelectScrollDownButtonProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectScrollDownButton
|
||||
data-slot="select-scroll-down-button"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('flex cursor-default items-center justify-center py-1', props.class)"
|
||||
>
|
||||
<slot>
|
||||
<ChevronDown class="size-4" />
|
||||
</slot>
|
||||
</SelectScrollDownButton>
|
||||
</template>
|
||||
26
resources/js/components/ui/select/SelectScrollUpButton.vue
Normal file
26
resources/js/components/ui/select/SelectScrollUpButton.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectScrollUpButtonProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { ChevronUp } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { SelectScrollUpButton, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<SelectScrollUpButtonProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectScrollUpButton
|
||||
data-slot="select-scroll-up-button"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('flex cursor-default items-center justify-center py-1', props.class)"
|
||||
>
|
||||
<slot>
|
||||
<ChevronUp class="size-4" />
|
||||
</slot>
|
||||
</SelectScrollUpButton>
|
||||
</template>
|
||||
19
resources/js/components/ui/select/SelectSeparator.vue
Normal file
19
resources/js/components/ui/select/SelectSeparator.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectSeparatorProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { SelectSeparator } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<SelectSeparatorProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectSeparator
|
||||
data-slot="select-separator"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('bg-border pointer-events-none -mx-1 my-1 h-px', props.class)"
|
||||
/>
|
||||
</template>
|
||||
33
resources/js/components/ui/select/SelectTrigger.vue
Normal file
33
resources/js/components/ui/select/SelectTrigger.vue
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectTriggerProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { ChevronDown } from "@lucide/vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { SelectIcon, SelectTrigger, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<SelectTriggerProps & { class?: HTMLAttributes["class"], size?: "sm" | "default" }>(),
|
||||
{ size: "default" },
|
||||
)
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class", "size")
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectTrigger
|
||||
data-slot="select-trigger"
|
||||
:data-size="size"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn(
|
||||
`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
<SelectIcon as-child>
|
||||
<ChevronDown class="size-4 opacity-50" />
|
||||
</SelectIcon>
|
||||
</SelectTrigger>
|
||||
</template>
|
||||
15
resources/js/components/ui/select/SelectValue.vue
Normal file
15
resources/js/components/ui/select/SelectValue.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { SelectValueProps } from "reka-ui"
|
||||
import { SelectValue } from "reka-ui"
|
||||
|
||||
const props = defineProps<SelectValueProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SelectValue
|
||||
data-slot="select-value"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</SelectValue>
|
||||
</template>
|
||||
11
resources/js/components/ui/select/index.ts
Normal file
11
resources/js/components/ui/select/index.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export { default as Select } from "./Select.vue"
|
||||
export { default as SelectContent } from "./SelectContent.vue"
|
||||
export { default as SelectGroup } from "./SelectGroup.vue"
|
||||
export { default as SelectItem } from "./SelectItem.vue"
|
||||
export { default as SelectItemText } from "./SelectItemText.vue"
|
||||
export { default as SelectLabel } from "./SelectLabel.vue"
|
||||
export { default as SelectScrollDownButton } from "./SelectScrollDownButton.vue"
|
||||
export { default as SelectScrollUpButton } from "./SelectScrollUpButton.vue"
|
||||
export { default as SelectSeparator } from "./SelectSeparator.vue"
|
||||
export { default as SelectTrigger } from "./SelectTrigger.vue"
|
||||
export { default as SelectValue } from "./SelectValue.vue"
|
||||
|
|
@ -55,7 +55,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
|||
class="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"
|
||||
>
|
||||
<X class="size-4" />
|
||||
<span class="sr-only">Close</span>
|
||||
<span class="sr-only">Schließen</span>
|
||||
</DialogClose>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
|
|
|
|||
38
resources/js/components/ui/switch/Switch.vue
Normal file
38
resources/js/components/ui/switch/Switch.vue
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<script setup lang="ts">
|
||||
import type { SwitchRootEmits, SwitchRootProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import {
|
||||
SwitchRoot,
|
||||
SwitchThumb,
|
||||
useForwardPropsEmits,
|
||||
} from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<SwitchRootProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const emits = defineEmits<SwitchRootEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SwitchRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="switch"
|
||||
v-bind="forwarded"
|
||||
:class="cn(
|
||||
'peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<SwitchThumb
|
||||
data-slot="switch-thumb"
|
||||
:class="cn('bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0')"
|
||||
>
|
||||
<slot name="thumb" v-bind="slotProps" />
|
||||
</SwitchThumb>
|
||||
</SwitchRoot>
|
||||
</template>
|
||||
1
resources/js/components/ui/switch/index.ts
Normal file
1
resources/js/components/ui/switch/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { default as Switch } from "./Switch.vue"
|
||||
24
resources/js/components/ui/tabs/Tabs.vue
Normal file
24
resources/js/components/ui/tabs/Tabs.vue
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<script setup lang="ts">
|
||||
import type { TabsRootEmits, TabsRootProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { TabsRoot, useForwardPropsEmits } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<TabsRootProps & { class?: HTMLAttributes["class"] }>()
|
||||
const emits = defineEmits<TabsRootEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="tabs"
|
||||
v-bind="forwarded"
|
||||
:class="cn('flex flex-col gap-2', props.class)"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</TabsRoot>
|
||||
</template>
|
||||
21
resources/js/components/ui/tabs/TabsContent.vue
Normal file
21
resources/js/components/ui/tabs/TabsContent.vue
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<script setup lang="ts">
|
||||
import type { TabsContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { TabsContent } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<TabsContentProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsContent
|
||||
data-slot="tabs-content"
|
||||
:class="cn('flex-1 outline-none', props.class)"
|
||||
v-bind="delegatedProps"
|
||||
>
|
||||
<slot />
|
||||
</TabsContent>
|
||||
</template>
|
||||
24
resources/js/components/ui/tabs/TabsList.vue
Normal file
24
resources/js/components/ui/tabs/TabsList.vue
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<script setup lang="ts">
|
||||
import type { TabsListProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { TabsList } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<TabsListProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsList
|
||||
data-slot="tabs-list"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn(
|
||||
'bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-0.75',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</TabsList>
|
||||
</template>
|
||||
26
resources/js/components/ui/tabs/TabsTrigger.vue
Normal file
26
resources/js/components/ui/tabs/TabsTrigger.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup lang="ts">
|
||||
import type { TabsTriggerProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { TabsTrigger, useForwardProps } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const props = defineProps<TabsTriggerProps & { class?: HTMLAttributes["class"] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsTrigger
|
||||
data-slot="tabs-trigger"
|
||||
:class="cn(
|
||||
`data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-3 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,
|
||||
props.class,
|
||||
)"
|
||||
v-bind="forwardedProps"
|
||||
>
|
||||
<slot />
|
||||
</TabsTrigger>
|
||||
</template>
|
||||
4
resources/js/components/ui/tabs/index.ts
Normal file
4
resources/js/components/ui/tabs/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { default as Tabs } from "./Tabs.vue"
|
||||
export { default as TabsContent } from "./TabsContent.vue"
|
||||
export { default as TabsList } from "./TabsList.vue"
|
||||
export { default as TabsTrigger } from "./TabsTrigger.vue"
|
||||
19
resources/js/components/ui/tooltip/Tooltip.vue
Normal file
19
resources/js/components/ui/tooltip/Tooltip.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup lang="ts">
|
||||
import type { TooltipRootEmits, TooltipRootProps } from "reka-ui"
|
||||
import { TooltipRoot, useForwardPropsEmits } from "reka-ui"
|
||||
|
||||
const props = defineProps<TooltipRootProps>()
|
||||
const emits = defineEmits<TooltipRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="tooltip"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</TooltipRoot>
|
||||
</template>
|
||||
34
resources/js/components/ui/tooltip/TooltipContent.vue
Normal file
34
resources/js/components/ui/tooltip/TooltipContent.vue
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<script setup lang="ts">
|
||||
import type { TooltipContentEmits, TooltipContentProps } from "reka-ui"
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { reactiveOmit } from "@vueuse/core"
|
||||
import { TooltipArrow, TooltipContent, TooltipPortal, useForwardPropsEmits } from "reka-ui"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = withDefaults(defineProps<TooltipContentProps & { class?: HTMLAttributes["class"] }>(), {
|
||||
sideOffset: 4,
|
||||
})
|
||||
|
||||
const emits = defineEmits<TooltipContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class")
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipPortal>
|
||||
<TooltipContent
|
||||
data-slot="tooltip-content"
|
||||
v-bind="{ ...forwarded, ...$attrs }"
|
||||
:class="cn('bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit rounded-md px-3 py-1.5 text-xs text-balance', props.class)"
|
||||
>
|
||||
<slot />
|
||||
|
||||
<TooltipArrow class="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-xs" />
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</template>
|
||||
14
resources/js/components/ui/tooltip/TooltipProvider.vue
Normal file
14
resources/js/components/ui/tooltip/TooltipProvider.vue
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<script setup lang="ts">
|
||||
import type { TooltipProviderProps } from "reka-ui"
|
||||
import { TooltipProvider } from "reka-ui"
|
||||
|
||||
const props = withDefaults(defineProps<TooltipProviderProps>(), {
|
||||
delayDuration: 0,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipProvider v-bind="props">
|
||||
<slot />
|
||||
</TooltipProvider>
|
||||
</template>
|
||||
15
resources/js/components/ui/tooltip/TooltipTrigger.vue
Normal file
15
resources/js/components/ui/tooltip/TooltipTrigger.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { TooltipTriggerProps } from "reka-ui"
|
||||
import { TooltipTrigger } from "reka-ui"
|
||||
|
||||
const props = defineProps<TooltipTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipTrigger
|
||||
data-slot="tooltip-trigger"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</TooltipTrigger>
|
||||
</template>
|
||||
4
resources/js/components/ui/tooltip/index.ts
Normal file
4
resources/js/components/ui/tooltip/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { default as Tooltip } from "./Tooltip.vue"
|
||||
export { default as TooltipContent } from "./TooltipContent.vue"
|
||||
export { default as TooltipProvider } from "./TooltipProvider.vue"
|
||||
export { default as TooltipTrigger } from "./TooltipTrigger.vue"
|
||||
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from '@/components/ui/dropdown-menu';
|
||||
import { Toaster } from '@/components/ui/sonner';
|
||||
import BrandLogo from '@/components/BrandLogo.vue';
|
||||
import NotificationBell from '@/components/NotificationBell.vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import { useThemePreference } from '@/composables/useThemePreference';
|
||||
|
||||
|
|
@ -108,6 +109,8 @@ const themeOptions = [
|
|||
<Search class="size-5" />
|
||||
</Link>
|
||||
|
||||
<NotificationBell />
|
||||
|
||||
<a
|
||||
v-if="user.can_admin"
|
||||
href="/admin"
|
||||
|
|
|
|||
53
resources/js/lib/http.js
Normal file
53
resources/js/lib/http.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* JSON-Anfragen an das Portal (außerhalb von Inertia-Seitenwechseln), mit
|
||||
* CSRF-Schutz über das XSRF-TOKEN-Cookie von Laravel.
|
||||
*/
|
||||
function xsrfToken() {
|
||||
const match = document.cookie.match(/(?:^|; )XSRF-TOKEN=([^;]*)/);
|
||||
|
||||
return match ? decodeURIComponent(match[1]) : '';
|
||||
}
|
||||
|
||||
export class HttpError extends Error {
|
||||
constructor(status, data) {
|
||||
super(data?.message || `Anfrage fehlgeschlagen (${status})`);
|
||||
this.status = status;
|
||||
this.data = data ?? {};
|
||||
}
|
||||
|
||||
/** Erste Fehlermeldung je Feld aus einer 422-Antwort. */
|
||||
get fieldErrors() {
|
||||
return Object.fromEntries(Object.entries(this.data.errors ?? {}).map(([key, messages]) => [key, messages[0]]));
|
||||
}
|
||||
}
|
||||
|
||||
export async function request(method, url, body, options = {}) {
|
||||
const headers = {
|
||||
Accept: 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'X-XSRF-TOKEN': xsrfToken(),
|
||||
};
|
||||
|
||||
let payload = body;
|
||||
|
||||
if (body !== undefined && !(body instanceof FormData)) {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
payload = JSON.stringify(body);
|
||||
}
|
||||
|
||||
const response = await fetch(url, { method, headers, body: payload, credentials: 'same-origin', keepalive: options.keepalive ?? false });
|
||||
const data = response.headers.get('content-type')?.includes('application/json') ? await response.json() : null;
|
||||
|
||||
if (!response.ok) {
|
||||
throw new HttpError(response.status, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export const http = {
|
||||
get: (url) => request('GET', url),
|
||||
post: (url, body, options) => request('POST', url, body ?? {}, options),
|
||||
put: (url, body) => request('PUT', url, body),
|
||||
delete: (url, body) => request('DELETE', url, body),
|
||||
};
|
||||
27
resources/js/pagebuilder/BlockList.vue
Normal file
27
resources/js/pagebuilder/BlockList.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
import { blockComponent } from './registry';
|
||||
|
||||
/**
|
||||
* Anzeige einer Blockliste. Container-Blöcke rendern ihre Bereiche mit der
|
||||
* Komponente aus inject('pagebuilder:list') – im Editor ist das die
|
||||
* bearbeitbare Liste, sonst diese hier.
|
||||
*/
|
||||
defineProps({
|
||||
item: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const types = inject('pagebuilder:types', {});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid gap-6">
|
||||
<template v-for="block in item.blocks" :key="block.id">
|
||||
<component
|
||||
:is="blockComponent(types[block.type]?.component ?? block.component ?? '')"
|
||||
v-if="blockComponent(types[block.type]?.component ?? block.component ?? '')"
|
||||
:block="block"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
27
resources/js/pagebuilder/PageContent.vue
Normal file
27
resources/js/pagebuilder/PageContent.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { computed, provide } from 'vue';
|
||||
import BlockList from './BlockList.vue';
|
||||
|
||||
/**
|
||||
* Anzeigefertiger Seiteninhalt (siehe App\Pagebuilder\Content::render).
|
||||
* Die Blöcke reagieren auf die Breite dieses Bereichs (Container Queries) –
|
||||
* so stimmt auch die Geräte-Vorschau im Editor.
|
||||
*/
|
||||
const props = defineProps({
|
||||
content: { type: Object, required: true },
|
||||
types: { type: Object, default: null },
|
||||
});
|
||||
|
||||
provide('pagebuilder:list', BlockList);
|
||||
provide('pagebuilder:editing', false);
|
||||
provide('pagebuilder:types', props.types ?? {});
|
||||
|
||||
const root = computed(() => ({ blocks: props.content.blocks ?? [] }));
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="@container">
|
||||
<BlockList :item="root" />
|
||||
</div>
|
||||
</template>
|
||||
42
resources/js/pagebuilder/blocks/Accordion.vue
Normal file
42
resources/js/pagebuilder/blocks/Accordion.vue
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
import { AccordionContent, AccordionHeader, AccordionItem, AccordionRoot, AccordionTrigger } from 'reka-ui';
|
||||
import { ChevronDown } from '@lucide/vue';
|
||||
|
||||
const props = defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const List = inject('pagebuilder:list');
|
||||
const editing = inject('pagebuilder:editing', false);
|
||||
|
||||
const initial = computed(() => {
|
||||
const first = props.block.items[0]?.id;
|
||||
|
||||
if (props.block.data.multiple) return props.block.data.first_open && first ? [first] : [];
|
||||
|
||||
return props.block.data.first_open ? first : undefined;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccordionRoot
|
||||
:key="`${block.data.multiple}-${editing}`"
|
||||
:type="block.data.multiple ? 'multiple' : 'single'"
|
||||
:default-value="initial"
|
||||
collapsible
|
||||
class="divide-y rounded-lg border bg-card"
|
||||
>
|
||||
<AccordionItem v-for="(item, index) in block.items" :key="item.id" :value="item.id">
|
||||
<AccordionHeader as="h3">
|
||||
<AccordionTrigger class="group flex w-full items-center justify-between gap-4 px-5 py-4 text-left text-[15px] font-medium hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/30">
|
||||
{{ item.title || `Abschnitt ${index + 1}` }}
|
||||
<ChevronDown class="size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeader>
|
||||
<AccordionContent class="overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down">
|
||||
<div class="px-5 pt-1 pb-5">
|
||||
<component :is="List" :item="item" />
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</AccordionRoot>
|
||||
</template>
|
||||
27
resources/js/pagebuilder/blocks/Box.vue
Normal file
27
resources/js/pagebuilder/blocks/Box.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
import { CircleAlert, CircleCheck, Info, Lightbulb, Star, TriangleAlert } from '@lucide/vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const List = inject('pagebuilder:list');
|
||||
|
||||
const variants = {
|
||||
info: { icon: Info, class: 'border-sky-200 bg-sky-50 text-sky-950 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-100', iconClass: 'text-sky-600 dark:text-sky-400' },
|
||||
note: { icon: Lightbulb, class: 'border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100', iconClass: 'text-amber-600 dark:text-amber-400' },
|
||||
warning: { icon: TriangleAlert, class: 'border-red-200 bg-red-50 text-red-950 dark:border-red-900 dark:bg-red-950/40 dark:text-red-100', iconClass: 'text-red-600 dark:text-red-400' },
|
||||
success: { icon: CircleCheck, class: 'border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-100', iconClass: 'text-emerald-600 dark:text-emerald-400' },
|
||||
neutral: { icon: CircleAlert, class: 'border-border bg-muted text-foreground', iconClass: 'text-muted-foreground' },
|
||||
highlight: { icon: Star, class: 'border-brand-200 bg-brand-soft text-foreground', iconClass: 'text-brand-text' },
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="pb-box flex gap-3 rounded-lg border p-4 @xl:p-5" :class="variants[block.data.variant]?.class" :role="block.data.variant === 'warning' ? 'alert' : 'note'">
|
||||
<component :is="variants[block.data.variant]?.icon" v-if="block.data.show_icon" class="mt-0.5 size-5 shrink-0" :class="variants[block.data.variant]?.iconClass" />
|
||||
<div class="min-w-0 flex-1">
|
||||
<p v-if="block.data.title" class="mb-2 font-semibold">{{ block.data.title }}</p>
|
||||
<component :is="List" :item="block.items[0]" />
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
20
resources/js/pagebuilder/blocks/Buttons.vue
Normal file
20
resources/js/pagebuilder/blocks/Buttons.vue
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<script setup>
|
||||
import { ArrowUpRight } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const variants = { primary: 'default', outline: 'outline', link: 'link' };
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-3" :class="{ 'justify-center': block.data.align === 'center' }">
|
||||
<Button v-for="(button, index) in block.data.buttons" :key="index" :variant="variants[button.variant] ?? 'default'" as-child>
|
||||
<a :href="button.url || '#'" :target="button.new_tab ? '_blank' : undefined" :rel="button.new_tab ? 'noopener' : undefined">
|
||||
{{ button.label || 'Schaltfläche' }}
|
||||
<ArrowUpRight v-if="button.new_tab" />
|
||||
</a>
|
||||
</Button>
|
||||
<p v-if="!block.data.buttons.length" class="text-sm text-muted-foreground">Noch keine Schaltflächen.</p>
|
||||
</div>
|
||||
</template>
|
||||
26
resources/js/pagebuilder/blocks/Columns.vue
Normal file
26
resources/js/pagebuilder/blocks/Columns.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
|
||||
const props = defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const List = inject('pagebuilder:list');
|
||||
|
||||
// Umbruchpunkt als Container Query: die Spalten richten sich nach der Breite des Inhaltsbereichs.
|
||||
const stack = { sm: '@xl:grid-cols-(--cols)', md: '@3xl:grid-cols-(--cols)', lg: '@5xl:grid-cols-(--cols)' };
|
||||
const gaps = { small: 'gap-3', normal: 'gap-6', large: 'gap-10' };
|
||||
const aligns = { start: 'items-start', center: 'items-center', stretch: 'items-stretch' };
|
||||
|
||||
const columns = computed(() => (props.block.data.layout ?? '1-1').split('-').map((part) => `${part}fr`).join(' '));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="grid grid-cols-1"
|
||||
:class="[stack[block.data.stack] ?? stack.md, gaps[block.data.gap] ?? gaps.normal, aligns[block.data.align] ?? aligns.start]"
|
||||
:style="{ '--cols': columns }"
|
||||
>
|
||||
<div v-for="item in block.items" :key="item.id" class="min-w-0">
|
||||
<component :is="List" :item="item" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
32
resources/js/pagebuilder/blocks/Contacts.vue
Normal file
32
resources/js/pagebuilder/blocks/Contacts.vue
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { Mail, Phone } from '@lucide/vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h3 v-if="block.data.title" class="mb-3 text-lg font-semibold">{{ block.data.title }}</h3>
|
||||
<div :class="block.data.layout === 'list' ? 'divide-y rounded-lg border bg-card' : 'grid gap-4 @xl:grid-cols-2 @4xl:grid-cols-3'">
|
||||
<div
|
||||
v-for="person in block.props?.people ?? []"
|
||||
:key="person.id"
|
||||
class="flex gap-3"
|
||||
:class="block.data.layout === 'list' ? 'items-center px-4 py-3' : 'rounded-lg border bg-card p-4'"
|
||||
>
|
||||
<PersonAvatar :person="person" class="size-12 shrink-0" />
|
||||
<div class="min-w-0">
|
||||
<Link :href="`/personen/${person.id}`" class="block truncate font-semibold hover:underline">{{ person.name }}</Link>
|
||||
<p v-if="person.job_title" class="truncate text-[13px] text-muted-foreground">{{ person.job_title }}</p>
|
||||
<div class="mt-1.5 flex flex-wrap gap-x-4 gap-y-1 text-[13px]">
|
||||
<a v-if="person.phone" :href="`tel:${person.phone}`" class="inline-flex items-center gap-1 text-brand-text hover:underline"><Phone class="size-3.5" /> {{ person.phone }}</a>
|
||||
<a :href="`mailto:${person.email}`" class="inline-flex min-w-0 items-center gap-1 text-brand-text hover:underline"><Mail class="size-3.5 shrink-0" /> <span class="truncate">{{ person.email }}</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!(block.props?.people ?? []).length" class="text-sm text-muted-foreground">Noch keine Personen ausgewählt.</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
3
resources/js/pagebuilder/blocks/Divider.vue
Normal file
3
resources/js/pagebuilder/blocks/Divider.vue
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<template>
|
||||
<hr class="border-border" />
|
||||
</template>
|
||||
32
resources/js/pagebuilder/blocks/Gallery.vue
Normal file
32
resources/js/pagebuilder/blocks/Gallery.vue
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { ImageIcon } from '@lucide/vue';
|
||||
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
|
||||
|
||||
const props = defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const columns = { 2: '@xl:grid-cols-2', 3: '@xl:grid-cols-2 @3xl:grid-cols-3', 4: '@xl:grid-cols-3 @3xl:grid-cols-4' };
|
||||
const images = computed(() => props.block.data.images.map((image, index) => ({ ...image, url: props.block.props?.urls?.[index] ?? null })));
|
||||
const open = ref(null);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-2 gap-3" :class="columns[block.data.columns]">
|
||||
<figure v-for="(image, index) in images" :key="index">
|
||||
<button v-if="image.url" type="button" class="block w-full overflow-hidden rounded-lg focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none" @click="open = image">
|
||||
<img :src="image.url" :alt="image.alt" loading="lazy" class="aspect-[4/3] w-full object-cover transition-transform hover:scale-[1.02]" />
|
||||
</button>
|
||||
<div v-else class="grid aspect-[4/3] place-items-center rounded-lg border border-dashed bg-muted text-muted-foreground"><ImageIcon class="size-6" /></div>
|
||||
<figcaption v-if="image.caption" class="mt-1.5 text-xs text-muted-foreground">{{ image.caption }}</figcaption>
|
||||
</figure>
|
||||
<p v-if="!images.length" class="col-span-full text-sm text-muted-foreground">Noch keine Bilder.</p>
|
||||
</div>
|
||||
|
||||
<Dialog :open="!!open" @update:open="(value) => !value && (open = null)">
|
||||
<DialogContent class="max-w-5xl p-2 sm:max-w-5xl">
|
||||
<DialogTitle class="sr-only">{{ open?.alt || 'Bild' }}</DialogTitle>
|
||||
<img v-if="open" :src="open.url" :alt="open.alt" class="max-h-[80vh] w-full rounded-md object-contain" />
|
||||
<p v-if="open?.caption" class="px-2 pb-1 text-sm text-muted-foreground">{{ open.caption }}</p>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
28
resources/js/pagebuilder/blocks/Heading.vue
Normal file
28
resources/js/pagebuilder/blocks/Heading.vue
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const editing = inject('pagebuilder:editing', false);
|
||||
|
||||
const sizes = {
|
||||
2: 'text-2xl font-semibold tracking-tight',
|
||||
3: 'text-xl font-semibold tracking-tight',
|
||||
4: 'text-base font-semibold',
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
v-if="editing"
|
||||
v-model="block.data.text"
|
||||
class="w-full bg-transparent outline-none placeholder:text-muted-foreground/60"
|
||||
:class="[sizes[block.data.level], block.data.align === 'center' ? 'text-center' : '']"
|
||||
placeholder="Überschrift"
|
||||
maxlength="200"
|
||||
aria-label="Überschrift"
|
||||
/>
|
||||
<component :is="`h${block.data.level}`" v-else-if="block.data.text" :class="[sizes[block.data.level], block.data.align === 'center' ? 'text-center' : '']">
|
||||
{{ block.data.text }}
|
||||
</component>
|
||||
</template>
|
||||
21
resources/js/pagebuilder/blocks/Hero.vue
Normal file
21
resources/js/pagebuilder/blocks/Hero.vue
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<script setup>
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const heights = { small: 'min-h-48', medium: 'min-h-72', large: 'min-h-96' };
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="relative flex items-end overflow-hidden rounded-lg bg-brand text-white" :class="heights[block.data.height]">
|
||||
<img v-if="block.props?.url" :src="block.props.url" alt="" class="absolute inset-0 size-full object-cover" />
|
||||
<div class="absolute inset-0 bg-gradient-to-t from-black/70 via-black/30 to-transparent" />
|
||||
<div class="relative max-w-2xl p-6 @3xl:p-10">
|
||||
<h2 v-if="block.data.title" class="text-2xl font-semibold tracking-tight @3xl:text-3xl">{{ block.data.title }}</h2>
|
||||
<p v-if="block.data.text" class="mt-2 text-[15px] leading-relaxed text-white/90 @3xl:text-base">{{ block.data.text }}</p>
|
||||
<Button v-if="block.data.button_label && block.data.button_url" as-child class="mt-5 bg-white text-neutral-900 hover:bg-white/90">
|
||||
<a :href="block.data.button_url">{{ block.data.button_label }}</a>
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
27
resources/js/pagebuilder/blocks/IconList.vue
Normal file
27
resources/js/pagebuilder/blocks/IconList.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { Link as LinkIcon } from '@lucide/vue';
|
||||
import { quickLinkIcons } from '@/lib/icons';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul :class="block.data.layout === 'grid' ? 'grid gap-4 @xl:grid-cols-2 @4xl:grid-cols-3' : 'grid gap-4'">
|
||||
<li v-for="(item, index) in block.data.items" :key="index">
|
||||
<component
|
||||
:is="item.url ? 'a' : 'div'"
|
||||
:href="item.url || undefined"
|
||||
class="flex gap-4"
|
||||
:class="[block.data.layout === 'grid' ? 'h-full rounded-lg border bg-card p-4' : '', item.url ? 'group' : '']"
|
||||
>
|
||||
<span class="grid size-10 shrink-0 place-items-center rounded-lg bg-brand-soft text-brand-text">
|
||||
<component :is="quickLinkIcons[item.icon] ?? LinkIcon" class="size-5" />
|
||||
</span>
|
||||
<span class="min-w-0">
|
||||
<span class="block font-medium" :class="{ 'group-hover:underline': item.url }">{{ item.title }}</span>
|
||||
<span v-if="item.text" class="mt-0.5 block text-sm leading-relaxed whitespace-pre-line text-muted-foreground">{{ item.text }}</span>
|
||||
</span>
|
||||
</component>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
19
resources/js/pagebuilder/blocks/Image.vue
Normal file
19
resources/js/pagebuilder/blocks/Image.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup>
|
||||
import { ImageIcon } from '@lucide/vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const sizes = { full: 'w-full', medium: 'mx-auto w-full @3xl:w-2/3', small: 'mx-auto w-full @xl:w-1/2 @3xl:w-1/3' };
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure :class="sizes[block.data.size]">
|
||||
<component :is="block.data.url ? 'a' : 'div'" v-if="block.props?.url" :href="block.data.url || undefined">
|
||||
<img :src="block.props.url" :alt="block.data.alt" loading="lazy" class="w-full rounded-lg" />
|
||||
</component>
|
||||
<div v-else class="grid aspect-video place-items-center rounded-lg border border-dashed bg-muted text-muted-foreground">
|
||||
<ImageIcon class="size-8" />
|
||||
</div>
|
||||
<figcaption v-if="block.data.caption" class="mt-2 text-sm text-muted-foreground">{{ block.data.caption }}</figcaption>
|
||||
</figure>
|
||||
</template>
|
||||
10
resources/js/pagebuilder/blocks/Quote.vue
Normal file
10
resources/js/pagebuilder/blocks/Quote.vue
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<script setup>
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure class="border-l-4 border-brand-300 py-1 pl-5">
|
||||
<blockquote class="text-lg leading-relaxed whitespace-pre-line">{{ block.data.text || 'Zitat' }}</blockquote>
|
||||
<figcaption v-if="block.data.source" class="mt-2 text-sm text-muted-foreground">– {{ block.data.source }}</figcaption>
|
||||
</figure>
|
||||
</template>
|
||||
22
resources/js/pagebuilder/blocks/Section.vue
Normal file
22
resources/js/pagebuilder/blocks/Section.vue
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const List = inject('pagebuilder:list');
|
||||
|
||||
const backgrounds = {
|
||||
none: '',
|
||||
muted: 'bg-muted',
|
||||
card: 'bg-card border',
|
||||
'brand-soft': 'bg-brand-soft',
|
||||
brand: 'bg-brand text-brand-foreground [&_.prose]:text-brand-foreground [&_a]:text-brand-foreground',
|
||||
};
|
||||
const paddings = { none: '', normal: 'p-5 @3xl:p-8', large: 'p-8 @3xl:p-12' };
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="rounded-lg" :class="[backgrounds[block.data.background], paddings[block.data.padding]]">
|
||||
<component :is="List" :item="block.items[0]" />
|
||||
</section>
|
||||
</template>
|
||||
9
resources/js/pagebuilder/blocks/Spacer.vue
Normal file
9
resources/js/pagebuilder/blocks/Spacer.vue
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<script setup>
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const sizes = { small: 'h-2', medium: 'h-8', large: 'h-16' };
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="sizes[block.data.size]" aria-hidden="true" />
|
||||
</template>
|
||||
26
resources/js/pagebuilder/blocks/Table.vue
Normal file
26
resources/js/pagebuilder/blocks/Table.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const head = computed(() => (props.block.data.header ? props.block.data.rows[0] ?? [] : null));
|
||||
const body = computed(() => (props.block.data.header ? props.block.data.rows.slice(1) : props.block.data.rows));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure class="overflow-x-auto rounded-lg border bg-card">
|
||||
<table class="w-full text-left text-sm">
|
||||
<thead v-if="head" class="bg-muted/60">
|
||||
<tr>
|
||||
<th v-for="(cell, index) in head" :key="index" class="px-4 py-2.5 font-semibold whitespace-pre-line">{{ cell }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y">
|
||||
<tr v-for="(row, rowIndex) in body" :key="rowIndex">
|
||||
<td v-for="(cell, index) in row" :key="index" class="px-4 py-2.5 align-top whitespace-pre-line">{{ cell }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<figcaption v-if="block.data.caption" class="border-t px-4 py-2 text-xs text-muted-foreground">{{ block.data.caption }}</figcaption>
|
||||
</figure>
|
||||
</template>
|
||||
32
resources/js/pagebuilder/blocks/Tabs.vue
Normal file
32
resources/js/pagebuilder/blocks/Tabs.vue
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<script setup>
|
||||
import { inject, ref, watch } from 'vue';
|
||||
import { TabsContent, TabsList, TabsRoot, TabsTrigger } from 'reka-ui';
|
||||
|
||||
const props = defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const List = inject('pagebuilder:list');
|
||||
const active = ref(props.block.items[0]?.id);
|
||||
|
||||
// Im Editor können Tabs entfernt werden – dann den ersten zeigen.
|
||||
watch(() => props.block.items.map((item) => item.id), (ids) => {
|
||||
if (!ids.includes(active.value)) active.value = ids[0];
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsRoot v-model="active">
|
||||
<TabsList class="-mb-px flex gap-1 overflow-x-auto border-b" aria-label="Reiter">
|
||||
<TabsTrigger
|
||||
v-for="(item, index) in block.items"
|
||||
:key="item.id"
|
||||
:value="item.id"
|
||||
class="relative shrink-0 px-4 py-2.5 text-sm font-medium whitespace-nowrap text-muted-foreground transition-colors hover:text-foreground data-[state=active]:text-foreground data-[state=active]:after:absolute data-[state=active]:after:inset-x-2 data-[state=active]:after:bottom-0 data-[state=active]:after:h-[3px] data-[state=active]:after:rounded-t-full data-[state=active]:after:bg-brand"
|
||||
>
|
||||
{{ item.title || `Tab ${index + 1}` }}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent v-for="item in block.items" :key="item.id" :value="item.id" class="pt-5 focus-visible:outline-none">
|
||||
<component :is="List" :item="item" />
|
||||
</TabsContent>
|
||||
</TabsRoot>
|
||||
</template>
|
||||
15
resources/js/pagebuilder/blocks/Text.vue
Normal file
15
resources/js/pagebuilder/blocks/Text.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup>
|
||||
import { defineAsyncComponent, inject } from 'vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const editing = inject('pagebuilder:editing', false);
|
||||
|
||||
// Der Editor (TipTap) wird nur im Pagebuilder geladen, nicht beim Lesen.
|
||||
const RichTextEditor = defineAsyncComponent(() => import('@/components/RichTextEditor.vue'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RichTextEditor v-if="editing" v-model="block.data.html" placeholder="Text eingeben …" />
|
||||
<div v-else class="prose prose-neutral max-w-none prose-headings:tracking-tight prose-img:rounded-lg" v-html="block.data.html" />
|
||||
</template>
|
||||
35
resources/js/pagebuilder/blocks/Video.vue
Normal file
35
resources/js/pagebuilder/blocks/Video.vue
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { Play, Video as VideoIcon } from '@lucide/vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
// Externe Videos erst nach Klick laden – vorher gehen keine Daten an YouTube oder Vimeo.
|
||||
const loaded = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure>
|
||||
<div class="relative aspect-video overflow-hidden rounded-lg bg-neutral-900">
|
||||
<template v-if="block.props?.embed">
|
||||
<video v-if="block.props.embed.provider === 'file'" :src="block.props.embed.src" controls preload="metadata" class="size-full" />
|
||||
<iframe
|
||||
v-else-if="loaded"
|
||||
:src="`${block.props.embed.src}&autoplay=1`"
|
||||
:title="block.data.title || 'Video'"
|
||||
class="size-full"
|
||||
allow="autoplay; fullscreen; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
<button v-else type="button" class="grid size-full place-items-center text-white" @click="loaded = true">
|
||||
<span class="grid justify-items-center gap-3 px-6 text-center">
|
||||
<span class="grid size-16 place-items-center rounded-full bg-white/15 transition-colors hover:bg-white/25"><Play class="size-7 fill-current" /></span>
|
||||
<span class="font-medium">{{ block.data.title || 'Video abspielen' }}</span>
|
||||
<span class="max-w-md text-xs text-white/70">Beim Abspielen wird das Video von {{ block.props.embed.provider }} geladen. Dabei werden Daten an {{ block.props.embed.provider }} übertragen.</span>
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
<div v-else class="grid size-full place-items-center text-white/60"><VideoIcon class="size-8" /></div>
|
||||
</div>
|
||||
</figure>
|
||||
</template>
|
||||
51
resources/js/pagebuilder/editor/BlockPalette.vue
Normal file
51
resources/js/pagebuilder/editor/BlockPalette.vue
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
import { VueDraggable } from 'vue-draggable-plus';
|
||||
import { blockIcon } from './icons';
|
||||
import { createBlock } from './tree';
|
||||
|
||||
/**
|
||||
* Auswahl der Blockarten, nach Gruppen. Anklicken fügt ein, Ziehen legt an
|
||||
* beliebiger Stelle im Inhalt ab.
|
||||
*/
|
||||
defineProps({
|
||||
compact: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const emit = defineEmits(['pick']);
|
||||
const editor = inject('pagebuilder:editor');
|
||||
|
||||
const groups = computed(() => Object.entries(editor.groups)
|
||||
.map(([key, label]) => ({ key, label, types: Object.values(editor.types).filter((type) => type.group === key) }))
|
||||
.filter((group) => group.types.length));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid gap-4">
|
||||
<section v-for="group in groups" :key="group.key">
|
||||
<h3 class="mb-2 text-xs font-semibold tracking-wide text-muted-foreground uppercase">{{ group.label }}</h3>
|
||||
<VueDraggable
|
||||
:model-value="group.types"
|
||||
:group="{ name: 'pagebuilder', pull: 'clone', put: false }"
|
||||
:clone="(type) => createBlock(type)"
|
||||
:sort="false"
|
||||
:disabled="compact || editor.readOnly.value"
|
||||
class="grid grid-cols-2 gap-2"
|
||||
>
|
||||
<button
|
||||
v-for="type in group.types"
|
||||
:key="type.key"
|
||||
type="button"
|
||||
class="flex items-center gap-2 rounded-md border bg-card px-2.5 py-2 text-left text-[13px] font-medium transition-colors hover:border-brand-300 hover:bg-brand-soft/60"
|
||||
:class="compact ? '' : 'cursor-grab active:cursor-grabbing'"
|
||||
:title="type.description || type.label"
|
||||
:disabled="editor.readOnly.value"
|
||||
@click="emit('pick', type)"
|
||||
>
|
||||
<component :is="blockIcon(type.icon)" class="size-4 shrink-0 text-brand-text" />
|
||||
<span class="truncate">{{ type.label }}</span>
|
||||
</button>
|
||||
</VueDraggable>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
135
resources/js/pagebuilder/editor/BlockSettings.vue
Normal file
135
resources/js/pagebuilder/editor/BlockSettings.vue
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<script setup>
|
||||
import { computed, inject, watch } from 'vue';
|
||||
import { ArrowDown, ArrowUp, EyeOff, Plus, Trash2 } from '@lucide/vue';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import FieldInput from './FieldInput.vue';
|
||||
import { blockIcon } from './icons';
|
||||
import { syncColumns, uid } from './tree';
|
||||
|
||||
const props = defineProps({
|
||||
block: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const editor = inject('pagebuilder:editor');
|
||||
const type = computed(() => editor.types[props.block.type]);
|
||||
|
||||
// Formatierter Text wird direkt im Block bearbeitet.
|
||||
const fields = computed(() => (type.value?.fields ?? []).filter((field) => field.type !== 'html'));
|
||||
|
||||
watch(() => props.block.data.layout, () => {
|
||||
if (props.block.type === 'columns') syncColumns(props.block);
|
||||
});
|
||||
|
||||
function addItem() {
|
||||
props.block.items.push({ id: uid(), title: `${type.value.container.label} ${props.block.items.length + 1}`, blocks: [] });
|
||||
}
|
||||
|
||||
function moveItem(index, direction) {
|
||||
const items = props.block.items;
|
||||
const target = index + direction;
|
||||
|
||||
if (target >= 0 && target < items.length) {
|
||||
[items[index], items[target]] = [items[target], items[index]];
|
||||
}
|
||||
}
|
||||
|
||||
function removeItem(index) {
|
||||
const item = props.block.items[index];
|
||||
|
||||
if (item.blocks.length && !window.confirm(`„${item.title || type.value.container.label}“ enthält Inhalte. Trotzdem entfernen?`)) return;
|
||||
|
||||
props.block.items.splice(index, 1);
|
||||
}
|
||||
|
||||
// Sichtbarkeit einzelner Blöcke
|
||||
const visibility = computed(() => props.block.visibility ?? {});
|
||||
const restricted = computed(() => Object.values(visibility.value).some((values) => values?.length));
|
||||
|
||||
function toggleRule(rule, value) {
|
||||
const current = new Set(visibility.value[rule] ?? []);
|
||||
current.has(value) ? current.delete(value) : current.add(value);
|
||||
props.block.visibility = { ...visibility.value, [rule]: [...current] };
|
||||
}
|
||||
|
||||
const ruleGroups = computed(() => [
|
||||
{ key: 'role', label: 'Rollen', options: editor.audienceOptions.role },
|
||||
{ key: 'department', label: 'Abteilungen', options: editor.audienceOptions.department.map((value) => ({ value, label: value })) },
|
||||
{ key: 'location', label: 'Standorte', options: editor.audienceOptions.location.map((value) => ({ value, label: value })) },
|
||||
].filter((group) => group.options.length));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="type" class="grid gap-5">
|
||||
<header class="flex items-start gap-3">
|
||||
<span class="grid size-9 shrink-0 place-items-center rounded-md bg-brand-soft text-brand-text"><component :is="blockIcon(type.icon)" class="size-4.5" /></span>
|
||||
<div class="min-w-0">
|
||||
<h2 class="font-semibold">{{ type.label }}</h2>
|
||||
<p v-if="type.description" class="text-xs text-muted-foreground">{{ type.description }}</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<p v-if="type.fields.some((field) => field.type === 'html')" class="rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground">
|
||||
Den Text bearbeiten Sie direkt im Block. Markieren Sie Text für Fettdruck, Links und Listen.
|
||||
</p>
|
||||
|
||||
<FieldInput
|
||||
v-for="field in fields"
|
||||
:id="`field-${block.id}-${field.name}`"
|
||||
:key="`${block.id}-${field.name}`"
|
||||
v-model="block.data[field.name]"
|
||||
:field="field"
|
||||
/>
|
||||
|
||||
<section v-if="type.container && type.container.max > 1 && type.key !== 'columns'" class="grid gap-2">
|
||||
<h3 class="text-[13px] font-medium">{{ type.container.label }}s</h3>
|
||||
<div v-for="(item, index) in block.items" :key="item.id" class="flex items-center gap-1">
|
||||
<Input v-if="type.container.titled" v-model="item.title" class="h-8" :aria-label="`Titel ${index + 1}`" maxlength="120" />
|
||||
<span v-else class="flex-1 text-[13px]">{{ type.container.label }} {{ index + 1 }}</span>
|
||||
<button type="button" class="grid size-7 shrink-0 place-items-center rounded hover:bg-accent" title="Nach oben" @click="moveItem(index, -1)"><ArrowUp class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-7 shrink-0 place-items-center rounded hover:bg-accent" title="Nach unten" @click="moveItem(index, 1)"><ArrowDown class="size-3.5" /></button>
|
||||
<button
|
||||
type="button"
|
||||
class="grid size-7 shrink-0 place-items-center rounded text-destructive hover:bg-destructive/10 disabled:opacity-30"
|
||||
title="Entfernen"
|
||||
:disabled="block.items.length <= type.container.min"
|
||||
@click="removeItem(index)"
|
||||
>
|
||||
<Trash2 class="size-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-if="block.items.length < type.container.max"
|
||||
type="button"
|
||||
class="flex h-8 items-center justify-center gap-1.5 rounded-md border border-dashed text-[13px] font-medium text-muted-foreground hover:border-brand-300 hover:text-foreground"
|
||||
@click="addItem"
|
||||
>
|
||||
<Plus class="size-3.5" /> {{ type.container.label }} hinzufügen
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<details v-if="ruleGroups.length" class="rounded-md border" :open="restricted">
|
||||
<summary class="flex cursor-pointer items-center gap-2 px-3 py-2 text-[13px] font-medium">
|
||||
<EyeOff class="size-4 text-muted-foreground" />
|
||||
Sichtbarkeit
|
||||
<span v-if="restricted" class="ml-auto rounded bg-amber-100 px-1.5 py-0.5 text-[11px] text-amber-800 dark:bg-amber-900/50 dark:text-amber-200">eingeschränkt</span>
|
||||
</summary>
|
||||
<div class="grid gap-3 border-t px-3 py-3">
|
||||
<p class="text-xs text-muted-foreground">Leer = für alle, die die Seite sehen. Sonst nur für Personen, die mindestens eine Angabe erfüllen.</p>
|
||||
<fieldset v-for="group in ruleGroups" :key="group.key" class="grid gap-1">
|
||||
<legend class="mb-1 text-xs font-semibold text-muted-foreground">{{ group.label }}</legend>
|
||||
<div class="grid max-h-36 gap-0.5 overflow-y-auto">
|
||||
<label v-for="option in group.options" :key="option.value" class="flex items-center gap-2 rounded px-1 py-0.5 text-[13px] hover:bg-accent">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="size-4 accent-[var(--brand)]"
|
||||
:checked="(visibility[group.key] ?? []).includes(option.value)"
|
||||
@change="toggleRule(group.key, option.value)"
|
||||
/>
|
||||
{{ option.label }}
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</template>
|
||||
57
resources/js/pagebuilder/editor/EditorBlock.vue
Normal file
57
resources/js/pagebuilder/editor/EditorBlock.vue
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
import { ChevronDown, ChevronUp, Copy, EyeOff, GripVertical, Trash2 } from '@lucide/vue';
|
||||
import { blockComponent } from '../registry';
|
||||
import { blockIcon } from './icons';
|
||||
|
||||
const props = defineProps({
|
||||
block: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const editor = inject('pagebuilder:editor');
|
||||
|
||||
const type = computed(() => editor.types[props.block.type]);
|
||||
const selected = computed(() => editor.selectedId.value === props.block.id);
|
||||
const hovered = computed(() => editor.hoveredId.value === props.block.id);
|
||||
const restricted = computed(() => Object.values(props.block.visibility ?? {}).some((values) => values?.length));
|
||||
|
||||
// Dynamische Daten (Bild-URLs, aktuelle Beiträge …) kommen aus der Vorschau des Servers.
|
||||
const view = computed(() => ({ ...props.block, props: editor.previews[props.block.id] ?? props.block.props }));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="relative rounded-md outline-offset-4 transition-[outline-color]"
|
||||
:class="[
|
||||
selected ? 'outline-2 outline-brand-500' : hovered ? 'outline-1 outline-brand-300' : 'outline-1 outline-transparent',
|
||||
type ? '' : 'opacity-60',
|
||||
]"
|
||||
:data-block-id="block.id"
|
||||
@click.stop="editor.select(block.id)"
|
||||
@mouseover.stop="editor.hoveredId.value = block.id"
|
||||
@mouseleave="editor.hoveredId.value === block.id && (editor.hoveredId.value = null)"
|
||||
>
|
||||
<div
|
||||
v-if="(selected || hovered) && !editor.readOnly.value"
|
||||
class="absolute -top-3.5 right-2 z-20 flex items-center gap-0.5 rounded-md border bg-card px-1 py-0.5 text-xs shadow-sm"
|
||||
@click.stop
|
||||
>
|
||||
<span class="pb-handle flex cursor-grab items-center gap-1 rounded px-1 py-0.5 font-medium text-muted-foreground active:cursor-grabbing" title="Ziehen zum Verschieben">
|
||||
<GripVertical class="size-3.5" />
|
||||
<component :is="blockIcon(type?.icon)" class="size-3.5" />
|
||||
{{ type?.label ?? block.type }}
|
||||
</span>
|
||||
<EyeOff v-if="restricted" class="mx-1 size-3.5 text-amber-600" title="Nur für bestimmte Personen sichtbar" />
|
||||
<span class="mx-0.5 h-4 w-px bg-border" />
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Nach oben" @click="editor.move(block.id, -1)"><ChevronUp class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Nach unten" @click="editor.move(block.id, 1)"><ChevronDown class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Duplizieren" @click="editor.duplicate(block.id)"><Copy class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded text-destructive hover:bg-destructive/10" title="Entfernen" @click="editor.remove(block.id)"><Trash2 class="size-3.5" /></button>
|
||||
</div>
|
||||
|
||||
<component :is="blockComponent(type.component)" v-if="type && blockComponent(type.component)" :block="view" />
|
||||
<div v-else class="rounded-md border border-dashed p-4 text-sm text-muted-foreground">
|
||||
Dieser Block ({{ block.type }}) ist nicht verfügbar – vermutlich ist das zugehörige Plugin deaktiviert. Er wird nicht angezeigt.
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
62
resources/js/pagebuilder/editor/EditorBlockList.vue
Normal file
62
resources/js/pagebuilder/editor/EditorBlockList.vue
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
import { VueDraggable } from 'vue-draggable-plus';
|
||||
import { Plus } from '@lucide/vue';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import BlockPalette from './BlockPalette.vue';
|
||||
import EditorBlock from './EditorBlock.vue';
|
||||
|
||||
/**
|
||||
* Bearbeitbare Blockliste: Ziehen und Ablegen (auch zwischen Bereichen),
|
||||
* Hinzufügen per „+“. Wird von Container-Blöcken über inject('pagebuilder:list') genutzt.
|
||||
*/
|
||||
const props = defineProps({
|
||||
item: { type: Object, required: true },
|
||||
root: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const editor = inject('pagebuilder:editor');
|
||||
|
||||
const parentActive = computed(() => props.root || editor.containsActive(props.item));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid" :class="root ? 'gap-6' : 'gap-4'">
|
||||
<VueDraggable
|
||||
v-model="item.blocks"
|
||||
:group="{ name: 'pagebuilder' }"
|
||||
handle=".pb-handle"
|
||||
:animation="150"
|
||||
:disabled="editor.readOnly.value"
|
||||
ghost-class="pb-ghost"
|
||||
class="grid min-h-6"
|
||||
:class="[root ? 'gap-6' : 'gap-4', item.blocks.length ? '' : 'rounded-md border border-dashed border-border bg-muted/40 p-3']"
|
||||
@add="(event) => editor.select(item.blocks[event.newIndex]?.id)"
|
||||
>
|
||||
<EditorBlock v-for="block in item.blocks" :key="block.id" :block="block" />
|
||||
<p v-if="!item.blocks.length" class="pointer-events-none text-center text-xs text-muted-foreground">
|
||||
{{ root ? 'Noch keine Inhalte. Blöcke aus der rechten Spalte hierher ziehen oder hinzufügen.' : 'Blöcke hierher ziehen' }}
|
||||
</p>
|
||||
</VueDraggable>
|
||||
|
||||
<Popover v-if="!editor.readOnly.value && (parentActive || !item.blocks.length)">
|
||||
<PopoverTrigger
|
||||
class="flex h-8 items-center justify-center gap-1.5 rounded-md border border-dashed text-xs font-medium text-muted-foreground transition-colors hover:border-brand-300 hover:bg-brand-soft hover:text-brand-soft-foreground"
|
||||
@click.stop
|
||||
>
|
||||
<Plus class="size-3.5" /> Block hinzufügen
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="max-h-[70vh] w-[22rem] overflow-y-auto p-3" align="center" @click.stop>
|
||||
<BlockPalette compact @pick="(type) => editor.insert(item.blocks, item.blocks.length, type)" />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.pb-ghost {
|
||||
opacity: 0.4;
|
||||
outline: 2px dashed var(--brand-400);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
</style>
|
||||
314
resources/js/pagebuilder/editor/FieldInput.vue
Normal file
314
resources/js/pagebuilder/editor/FieldInput.vue
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
<script setup>
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { ArrowDown, ArrowUp, FileDown, ImagePlus, LoaderCircle, Plus, Search, Trash2, Upload, X } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import RichTextEditor from '@/components/RichTextEditor.vue';
|
||||
import { quickLinkIcons } from '@/lib/icons';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
/**
|
||||
* Eingabefeld für ein Blockfeld – erzeugt aus der Feldbeschreibung des Servers
|
||||
* (App\Pagebuilder\Field). Plugin-Blöcke bekommen so ihr Formular geschenkt.
|
||||
*/
|
||||
const props = defineProps({
|
||||
field: { type: Object, required: true },
|
||||
id: { type: String, required: true },
|
||||
});
|
||||
|
||||
const model = defineModel({ default: null });
|
||||
const editor = inject('pagebuilder:editor');
|
||||
const emit = defineEmits(['image-uploaded']);
|
||||
|
||||
// Bild
|
||||
const uploading = ref(false);
|
||||
const imageInput = ref(null);
|
||||
|
||||
async function uploadImage(event) {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
|
||||
if (!file) return;
|
||||
|
||||
uploading.value = true;
|
||||
|
||||
try {
|
||||
const result = await editor.uploadImage(file);
|
||||
model.value = result.path;
|
||||
emit('image-uploaded', result);
|
||||
} catch (error) {
|
||||
toast.error(error.fieldErrors?.image ?? error.message);
|
||||
} finally {
|
||||
uploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Personen
|
||||
const peopleQuery = ref('');
|
||||
const peopleResults = ref([]);
|
||||
const peopleCache = editor.peopleCache;
|
||||
let searchTimer;
|
||||
|
||||
watch(peopleQuery, (query) => {
|
||||
clearTimeout(searchTimer);
|
||||
|
||||
if (query.trim().length < 2) {
|
||||
peopleResults.value = [];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
searchTimer = setTimeout(async () => {
|
||||
const data = await http.get(`/personen/suche?q=${encodeURIComponent(query.trim())}`);
|
||||
data.people.forEach((person) => (peopleCache[person.id] = person));
|
||||
peopleResults.value = data.people.filter((person) => !(model.value ?? []).includes(person.id));
|
||||
}, 250);
|
||||
});
|
||||
|
||||
if (props.field.type === 'people' && (model.value ?? []).some((id) => !peopleCache[id])) {
|
||||
const missing = model.value.filter((id) => !peopleCache[id]);
|
||||
http.get(`/personen/suche?${missing.map((id) => `ids[]=${id}`).join('&')}`).then((data) => data.people.forEach((person) => (peopleCache[person.id] = person)));
|
||||
}
|
||||
|
||||
function addPerson(person) {
|
||||
model.value = [...(model.value ?? []), person.id];
|
||||
peopleQuery.value = '';
|
||||
peopleResults.value = [];
|
||||
}
|
||||
|
||||
// Listen (Wiederholer, Personen, Dateien)
|
||||
function moveItem(list, index, direction) {
|
||||
const target = index + direction;
|
||||
|
||||
if (target < 0 || target >= list.length) return;
|
||||
|
||||
const copy = [...list];
|
||||
[copy[index], copy[target]] = [copy[target], copy[index]];
|
||||
model.value = copy;
|
||||
}
|
||||
|
||||
function removeItem(index) {
|
||||
model.value = model.value.filter((_, i) => i !== index);
|
||||
}
|
||||
|
||||
function addRepeaterItem() {
|
||||
const item = Object.fromEntries(props.field.fields.map((sub) => [sub.name, structuredClone(sub.default ?? (sub.type === 'toggle' ? false : sub.type === 'repeater' ? [] : ''))]));
|
||||
model.value = [...(model.value ?? []), item];
|
||||
}
|
||||
|
||||
// Tabelle
|
||||
const table = computed(() => model.value ?? [['']]);
|
||||
|
||||
function updateCell(row, col, value) {
|
||||
const copy = table.value.map((r) => [...r]);
|
||||
copy[row][col] = value;
|
||||
model.value = copy;
|
||||
}
|
||||
|
||||
function addRow() {
|
||||
model.value = [...table.value, Array(table.value[0]?.length ?? 1).fill('')];
|
||||
}
|
||||
|
||||
function addColumn() {
|
||||
model.value = table.value.map((row) => [...row, '']);
|
||||
}
|
||||
|
||||
function removeRow(index) {
|
||||
if (table.value.length > 1) model.value = table.value.filter((_, i) => i !== index);
|
||||
}
|
||||
|
||||
function removeColumn(index) {
|
||||
if ((table.value[0]?.length ?? 1) > 1) model.value = table.value.map((row) => row.filter((_, i) => i !== index));
|
||||
}
|
||||
|
||||
// Dateien (Downloads)
|
||||
const fileInput = ref(null);
|
||||
const files = computed(() => Object.fromEntries(editor.files.value.map((file) => [file.id, file])));
|
||||
|
||||
async function uploadFiles(event) {
|
||||
const chosen = [...(event.target.files ?? [])];
|
||||
event.target.value = '';
|
||||
uploading.value = true;
|
||||
|
||||
try {
|
||||
for (const file of chosen) {
|
||||
const result = await editor.uploadFile(file);
|
||||
model.value = [...(model.value ?? []), result.id];
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error(error.fieldErrors?.file ?? error.message);
|
||||
} finally {
|
||||
uploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const availableFiles = computed(() => editor.files.value.filter((file) => !(model.value ?? []).includes(file.id)));
|
||||
|
||||
const formatSize = (bytes) => (bytes > 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1).replace('.', ',')} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`);
|
||||
|
||||
const iconOptions = computed(() => (props.field.choices ?? []).map((choice) => ({ ...choice, icon: quickLinkIcons[choice.value] })));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid gap-1.5">
|
||||
<label v-if="field.type !== 'toggle'" :for="id" class="text-[13px] font-medium">{{ field.label }}</label>
|
||||
|
||||
<Input v-if="field.type === 'text'" :id="id" v-model="model" :maxlength="field.max" :placeholder="field.placeholder ?? ''" />
|
||||
<Input v-else-if="field.type === 'url'" :id="id" v-model="model" type="text" inputmode="url" placeholder="https://… oder /seiten/…" />
|
||||
<Textarea v-else-if="field.type === 'textarea'" :id="id" v-model="model" :maxlength="field.max" rows="3" />
|
||||
<RichTextEditor v-else-if="field.type === 'html'" v-model="model" bordered min-height="[&_.tiptap]:min-h-24" />
|
||||
<Input v-else-if="field.type === 'number'" :id="id" v-model.number="model" type="number" :min="field.min" :max="field.max" />
|
||||
<NativeSelect v-else-if="field.type === 'select'" :id="id" v-model="model" :options="field.choices" />
|
||||
|
||||
<label v-else-if="field.type === 'toggle'" :for="id" class="flex items-center justify-between gap-3 py-0.5 text-[13px] font-medium">
|
||||
{{ field.label }}
|
||||
<Switch :id="id" v-model="model" />
|
||||
</label>
|
||||
|
||||
<div v-else-if="field.type === 'icon'" class="grid grid-cols-6 gap-1.5">
|
||||
<button
|
||||
v-for="option in iconOptions"
|
||||
:key="option.value"
|
||||
type="button"
|
||||
class="grid aspect-square place-items-center rounded-md border transition-colors"
|
||||
:class="model === option.value ? 'border-brand-400 bg-brand-soft text-brand-soft-foreground' : 'text-muted-foreground hover:bg-accent'"
|
||||
:title="option.label"
|
||||
:aria-pressed="model === option.value"
|
||||
@click="model = option.value"
|
||||
>
|
||||
<component :is="option.icon" class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="field.type === 'image'" class="grid gap-2">
|
||||
<div v-if="model" class="relative overflow-hidden rounded-md border bg-muted">
|
||||
<img :src="editor.imageUrl(model)" alt="" class="aspect-video w-full object-cover" />
|
||||
<button type="button" class="absolute top-1.5 right-1.5 grid size-7 place-items-center rounded-md bg-card/90 shadow-sm hover:bg-card" title="Bild entfernen" @click="model = null">
|
||||
<X class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-9 items-center justify-center gap-2 rounded-md border border-dashed text-[13px] font-medium text-muted-foreground hover:border-brand-300 hover:text-foreground"
|
||||
:disabled="uploading"
|
||||
@click="imageInput?.click()"
|
||||
>
|
||||
<LoaderCircle v-if="uploading" class="size-4 animate-spin" />
|
||||
<ImagePlus v-else class="size-4" />
|
||||
{{ model ? 'Anderes Bild wählen' : 'Bild hochladen' }}
|
||||
</button>
|
||||
<input ref="imageInput" type="file" accept="image/jpeg,image/png,image/webp,image/gif" class="hidden" @change="uploadImage" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="field.type === 'people'" class="grid gap-2">
|
||||
<ul v-if="(model ?? []).length" class="grid gap-1">
|
||||
<li v-for="(personId, index) in model" :key="personId" class="flex items-center gap-2 rounded-md border bg-card px-2 py-1.5">
|
||||
<PersonAvatar v-if="peopleCache[personId]" :person="peopleCache[personId]" class="size-7 text-[10px]" />
|
||||
<span class="min-w-0 flex-1 truncate text-[13px]">{{ peopleCache[personId]?.name ?? '…' }}</span>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Nach oben" @click="moveItem(model, index, -1)"><ArrowUp class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Entfernen" @click="removeItem(index)"><X class="size-3.5" /></button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="relative">
|
||||
<Search class="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input :id="id" v-model="peopleQuery" class="pl-8" placeholder="Person suchen …" autocomplete="off" />
|
||||
<ul v-if="peopleResults.length" class="absolute inset-x-0 top-full z-30 mt-1 max-h-60 overflow-y-auto rounded-md border bg-popover p-1 shadow-md">
|
||||
<li v-for="person in peopleResults" :key="person.id">
|
||||
<button type="button" class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[13px] hover:bg-accent" @click="addPerson(person)">
|
||||
<PersonAvatar :person="person" class="size-7 text-[10px]" />
|
||||
<span class="min-w-0"><span class="block truncate font-medium">{{ person.name }}</span><span class="block truncate text-xs text-muted-foreground">{{ person.job_title }}</span></span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="field.type === 'table'" class="grid gap-2">
|
||||
<div class="overflow-x-auto rounded-md border">
|
||||
<table class="w-full text-[13px]">
|
||||
<tbody>
|
||||
<tr v-for="(row, rowIndex) in table" :key="rowIndex" class="border-b last:border-0">
|
||||
<td v-for="(cell, colIndex) in row" :key="colIndex" class="border-r p-0 last:border-r-0">
|
||||
<input
|
||||
:value="cell"
|
||||
class="h-8 w-full min-w-20 bg-transparent px-2 focus:bg-brand-soft/50 focus:outline-none"
|
||||
:aria-label="`Zeile ${rowIndex + 1}, Spalte ${colIndex + 1}`"
|
||||
@input="updateCell(rowIndex, colIndex, $event.target.value)"
|
||||
/>
|
||||
</td>
|
||||
<td class="w-7 p-0 text-center"><button type="button" class="grid size-7 place-items-center text-muted-foreground hover:text-destructive" title="Zeile entfernen" @click="removeRow(rowIndex)"><X class="size-3.5" /></button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td v-for="(_, colIndex) in table[0]" :key="colIndex" class="p-0 text-center">
|
||||
<button type="button" class="mx-auto grid size-7 place-items-center text-muted-foreground hover:text-destructive" title="Spalte entfernen" @click="removeColumn(colIndex)"><X class="size-3.5" /></button>
|
||||
</td>
|
||||
<td />
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button type="button" class="inline-flex items-center gap-1 text-[13px] font-medium text-brand-text hover:underline" @click="addRow"><Plus class="size-3.5" /> Zeile</button>
|
||||
<button type="button" class="inline-flex items-center gap-1 text-[13px] font-medium text-brand-text hover:underline" @click="addColumn"><Plus class="size-3.5" /> Spalte</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="field.type === 'repeater'" class="grid gap-2">
|
||||
<details v-for="(entry, index) in model ?? []" :key="index" class="group rounded-md border bg-card" :open="index === (model ?? []).length - 1">
|
||||
<summary class="flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-[13px] font-medium">
|
||||
<span class="min-w-0 flex-1 truncate">{{ entry.label || entry.title || entry.alt || `${field.itemLabel} ${index + 1}` }}</span>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Nach oben" @click.prevent="moveItem(model, index, -1)"><ArrowUp class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Nach unten" @click.prevent="moveItem(model, index, 1)"><ArrowDown class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded text-destructive hover:bg-destructive/10" title="Entfernen" @click.prevent="removeItem(index)"><Trash2 class="size-3.5" /></button>
|
||||
</summary>
|
||||
<div class="grid gap-3 border-t px-3 py-3">
|
||||
<FieldInput v-for="sub in field.fields" :id="`${id}-${index}-${sub.name}`" :key="sub.name" v-model="entry[sub.name]" :field="sub" />
|
||||
</div>
|
||||
</details>
|
||||
<button
|
||||
v-if="(model ?? []).length < field.max"
|
||||
type="button"
|
||||
class="flex h-8 items-center justify-center gap-1.5 rounded-md border border-dashed text-[13px] font-medium text-muted-foreground hover:border-brand-300 hover:text-foreground"
|
||||
@click="addRepeaterItem"
|
||||
>
|
||||
<Plus class="size-3.5" /> {{ field.itemLabel }} hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="field.type === 'ids' && field.kind === 'page-file'" class="grid gap-2">
|
||||
<ul v-if="(model ?? []).length" class="grid gap-1">
|
||||
<li v-for="(fileId, index) in model" :key="fileId" class="flex items-center gap-2 rounded-md border bg-card px-2 py-1.5 text-[13px]">
|
||||
<FileDown class="size-4 shrink-0 text-muted-foreground" />
|
||||
<span class="min-w-0 flex-1 truncate">{{ files[fileId]?.name ?? 'Datei nicht mehr vorhanden' }}</span>
|
||||
<span v-if="files[fileId]" class="shrink-0 text-xs text-muted-foreground">{{ formatSize(files[fileId].size) }}</span>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Nach oben" @click="moveItem(model, index, -1)"><ArrowUp class="size-3.5" /></button>
|
||||
<button type="button" class="grid size-6 place-items-center rounded hover:bg-accent" title="Entfernen" @click="removeItem(index)"><X class="size-3.5" /></button>
|
||||
</li>
|
||||
</ul>
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-9 items-center justify-center gap-2 rounded-md border border-dashed text-[13px] font-medium text-muted-foreground hover:border-brand-300 hover:text-foreground"
|
||||
:disabled="uploading"
|
||||
@click="fileInput?.click()"
|
||||
>
|
||||
<LoaderCircle v-if="uploading" class="size-4 animate-spin" />
|
||||
<Upload v-else class="size-4" />
|
||||
Dateien hochladen
|
||||
</button>
|
||||
<input ref="fileInput" type="file" multiple class="hidden" @change="uploadFiles" />
|
||||
<NativeSelect
|
||||
v-if="availableFiles.length"
|
||||
:model-value="null"
|
||||
:options="availableFiles.map((file) => ({ value: file.id, label: file.name }))"
|
||||
placeholder="Bereits hochgeladene Datei wählen …"
|
||||
@update:model-value="(value) => value && (model = [...(model ?? []), value])"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p v-if="field.help" class="text-xs text-muted-foreground">{{ field.help }}</p>
|
||||
</div>
|
||||
</template>
|
||||
58
resources/js/pagebuilder/editor/icons.js
Normal file
58
resources/js/pagebuilder/editor/icons.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import {
|
||||
Box,
|
||||
Columns3,
|
||||
Contact,
|
||||
FileDown,
|
||||
FolderTree,
|
||||
Heading,
|
||||
Image,
|
||||
Images,
|
||||
ListChecks,
|
||||
ListCollapse,
|
||||
MessageSquareWarning,
|
||||
Minus,
|
||||
MousePointerClick,
|
||||
MoveVertical,
|
||||
Newspaper,
|
||||
PanelTop,
|
||||
GalleryHorizontalEnd,
|
||||
Play,
|
||||
Quote,
|
||||
SquareDashed,
|
||||
Table,
|
||||
Text,
|
||||
CalendarDays,
|
||||
} from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Symbole der Blockarten (Namen aus App\Pagebuilder\Blocks, Lucide-Schreibweise).
|
||||
* Unbekannte Symbole von Plugin-Blöcken fallen auf „box“ zurück.
|
||||
*/
|
||||
const icons = {
|
||||
'square-dashed': SquareDashed,
|
||||
'columns-3': Columns3,
|
||||
'panel-top': PanelTop,
|
||||
'list-collapse': ListCollapse,
|
||||
'message-square-warning': MessageSquareWarning,
|
||||
heading: Heading,
|
||||
text: Text,
|
||||
quote: Quote,
|
||||
'mouse-pointer-click': MousePointerClick,
|
||||
'list-checks': ListChecks,
|
||||
table: Table,
|
||||
minus: Minus,
|
||||
'move-vertical': MoveVertical,
|
||||
image: Image,
|
||||
images: Images,
|
||||
play: Play,
|
||||
panorama: GalleryHorizontalEnd,
|
||||
contact: Contact,
|
||||
'file-down': FileDown,
|
||||
'folder-tree': FolderTree,
|
||||
newspaper: Newspaper,
|
||||
'calendar-days': CalendarDays,
|
||||
};
|
||||
|
||||
export function blockIcon(name) {
|
||||
return icons[name] ?? Box;
|
||||
}
|
||||
86
resources/js/pagebuilder/editor/tree.js
Normal file
86
resources/js/pagebuilder/editor/tree.js
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* Hilfsfunktionen für den Blockbaum im Editor.
|
||||
*/
|
||||
export function uid() {
|
||||
return Math.random().toString(36).slice(2, 8) + Date.now().toString(36).slice(-6);
|
||||
}
|
||||
|
||||
export function clone(value) {
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
}
|
||||
|
||||
function itemCount(type, data) {
|
||||
if (!type.container) return 0;
|
||||
if (type.key === 'columns') return (data.layout ?? '1-1').split('-').length;
|
||||
if (type.key === 'tabs') return 2;
|
||||
if (type.key === 'accordion') return 3;
|
||||
|
||||
return type.container.min;
|
||||
}
|
||||
|
||||
export function createBlock(type) {
|
||||
const data = clone(type.defaults ?? {});
|
||||
const block = { id: uid(), type: type.key, data };
|
||||
|
||||
if (type.container) {
|
||||
block.items = Array.from({ length: itemCount(type, data) }, (_, index) => ({
|
||||
id: uid(),
|
||||
title: type.container.titled ? `${type.container.label} ${index + 1}` : undefined,
|
||||
blocks: [],
|
||||
}));
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
/** Kopie mit neuen IDs (Duplizieren, Vorlagen). */
|
||||
export function duplicate(block) {
|
||||
const copy = clone(block);
|
||||
const renew = (b) => {
|
||||
b.id = uid();
|
||||
(b.items ?? []).forEach((item) => {
|
||||
item.id = uid();
|
||||
item.blocks.forEach(renew);
|
||||
});
|
||||
};
|
||||
renew(copy);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
/** Block im Baum finden: liefert Block, Liste und Position. */
|
||||
export function locate(blocks, id, parent = null) {
|
||||
for (let index = 0; index < blocks.length; index++) {
|
||||
const block = blocks[index];
|
||||
|
||||
if (block.id === id) return { block, list: blocks, index, parent };
|
||||
|
||||
for (const item of block.items ?? []) {
|
||||
const found = locate(item.blocks, id, block);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function walk(blocks, callback) {
|
||||
for (const block of blocks) {
|
||||
callback(block);
|
||||
(block.items ?? []).forEach((item) => walk(item.blocks, callback));
|
||||
}
|
||||
}
|
||||
|
||||
/** Anzahl der Spalten an die Aufteilung anpassen, ohne Inhalte zu verlieren. */
|
||||
export function syncColumns(block) {
|
||||
const count = (block.data.layout ?? '1-1').split('-').length;
|
||||
|
||||
while (block.items.length < count) {
|
||||
block.items.push({ id: uid(), blocks: [] });
|
||||
}
|
||||
|
||||
if (block.items.length > count) {
|
||||
const overflow = block.items.splice(count).flatMap((item) => item.blocks);
|
||||
block.items[count - 1].blocks.push(...overflow);
|
||||
}
|
||||
}
|
||||
24
resources/js/pagebuilder/registry.js
Normal file
24
resources/js/pagebuilder/registry.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { defineAsyncComponent } from 'vue';
|
||||
|
||||
/**
|
||||
* Vue-Komponenten der Pagebuilder-Blöcke: „Name“ aus resources/js/pagebuilder/blocks,
|
||||
* „<plugin>::Name“ aus plugins-core/<plugin>/resources/js/blocks.
|
||||
* Komponente und Blockart kommen aus der Registry App\Pagebuilder\Blocks.
|
||||
*/
|
||||
const core = import.meta.glob('./blocks/*.vue');
|
||||
const plugins = import.meta.glob('../../../plugins-core/*/resources/js/blocks/*.vue');
|
||||
|
||||
const components = {};
|
||||
|
||||
for (const [path, loader] of Object.entries(core)) {
|
||||
components[path.split('/').pop().replace('.vue', '')] = defineAsyncComponent(loader);
|
||||
}
|
||||
|
||||
for (const [path, loader] of Object.entries(plugins)) {
|
||||
const [, slug] = path.match(/plugins-core\/([^/]+)\//);
|
||||
components[`${slug}::${path.split('/').pop().replace('.vue', '')}`] = defineAsyncComponent(loader);
|
||||
}
|
||||
|
||||
export function blockComponent(name) {
|
||||
return components[name] ?? null;
|
||||
}
|
||||
31
resources/js/pages/Editorial/Index.vue
Normal file
31
resources/js/pages/Editorial/Index.vue
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<script setup>
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
|
||||
/**
|
||||
* Redaktion: Arbeitslisten der Plugins („<plugin>::Name“ aus plugins-core/<plugin>/resources/js/editorial).
|
||||
*/
|
||||
defineProps({
|
||||
sections: { type: Array, required: true },
|
||||
});
|
||||
|
||||
const loaders = import.meta.glob('../../../../plugins-core/*/resources/js/editorial/*.vue');
|
||||
const components = {};
|
||||
|
||||
for (const [path, loader] of Object.entries(loaders)) {
|
||||
const [, slug] = path.match(/plugins-core\/([^/]+)\//);
|
||||
components[`${slug}::${path.split('/').pop().replace('.vue', '')}`] = defineAsyncComponent(loader);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Redaktion">
|
||||
<div class="mb-6">
|
||||
<h1 class="text-2xl font-semibold tracking-tight">Redaktion</h1>
|
||||
<p class="mt-1 text-sm text-muted-foreground">Ihre Seiten und Beiträge – Entwürfe, Freigaben und Geplantes.</p>
|
||||
</div>
|
||||
<div class="grid items-start gap-6 xl:grid-cols-2">
|
||||
<component :is="components[section.component]" v-for="section in sections" :key="section.key" v-bind="section.props" />
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue