Loheide-eu-mitarbeiterplatt.../public/build/assets/useMediaPicker-CwHsU6US.js
Friederich Loheide 2c96fcce1c
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m21s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m55s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m25s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s
Startseite frei gestalten, Neuigkeiten-Block mit Kategorien-Filter (0.26.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 09:38:18 +00:00

1 line
No EOL
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{D as e,E as t,Ht as n,On as r,Yt as i,Zn as a,_ as o,b as s,bt as c,g as l,gn as u,mt as d,o as f,qt as p,tr as m,tt as h,v as g,vn as _,wt as v,y}from"./runtime-core.esm-bundler-B8D2lM98.js";import{S as b,x}from"./runtime-dom.esm-bundler-BEWGoe8n.js";import{c as S,i as ee,n as te,r as ne,s as re,t as ie,u as ae}from"./useMediaList-BKDQOSha.js";import{t as oe}from"./external-link-Ddmamed9.js";import{t as se}from"./image-off-BO5qjHGQ.js";import{t as C}from"./loader-circle-Wr6tQn-J.js";import{t as ce}from"./search-x-Bfzq4V3S.js";import{t as w}from"./upload-QwHKBTTM.js";import{t as le}from"./x-DU8daajy.js";import{n as T}from"./lib-Be7KNAML.js";import{Lt as E,a as ue,n as de,o as fe,p as D,s as pe,yt as me}from"./app-D3K317qy.js";var he={class:`flex flex-wrap items-center gap-x-6 gap-y-2 border-b px-5 pt-4 pr-12`},ge={class:`pb-3`},_e={class:`-mb-px flex gap-1 self-end`,role:`tablist`},ve=[`aria-selected`,`onClick`],ye={class:`min-h-0 flex-1 overflow-y-auto p-5`},be={class:`flex min-h-0 flex-1`},xe={class:`flex min-w-0 flex-1 flex-col`},Se={class:`flex flex-wrap items-center gap-2 border-b px-4 py-2.5`},Ce={class:`relative min-w-48 flex-1`},we={class:`flex flex-wrap gap-1`},Te=[`aria-pressed`,`onClick`],O={key:0,class:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`},Ee={key:1,class:`grid place-items-center px-6 py-16 text-center`},De={class:`mt-3 text-sm font-medium`},Oe={class:`hidden w-72 shrink-0 overflow-y-auto border-l bg-muted/30 p-4 md:block`},ke={key:0,class:`grid gap-3`},Ae={class:`grid place-items-center overflow-hidden rounded-md border bg-card`},je=[`src`,`alt`],Me={class:`text-[13px]`},Ne={class:`font-medium break-all`},Pe={class:`text-muted-foreground`},Fe={class:`grid gap-1`},Ie={class:`flex items-center justify-between text-[13px] font-medium`},Le={class:`text-[13px]`},Re={key:0,class:`mb-1 font-medium text-brand-text`},ze={key:1,class:`text-muted-foreground`},Be=[`href`],Ve={key:1,class:`text-[13px] text-muted-foreground`},He={class:`flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3`},Ue={class:`flex min-w-0 flex-1 items-center gap-2`},We={class:`flex -space-x-2`},k=[`src`],Ge={class:`text-[13px] font-medium`},Ke={key:1,class:`text-[13px] text-muted-foreground`},A={__name:`MediaPicker`,props:{open:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},contextPaths:{type:Array,default:()=>[]},contextLabel:{type:String,default:`Hier verwendet`},upload:{type:Function,default:null},title:{type:String,default:``}},emits:[`update:open`,`select`],setup(u,{emit:A}){let j=u,M=A,N=_(`library`),P=_(`all`),F=_(``),qe=l(()=>({q:F.value,sortierung:P.value===`recent`?`verwendet`:`neu`,status:P.value===`unused`?`unbenutzt`:P.value===`recent`?`verwendet`:``,pfade:P.value===`here`?j.contextPaths.slice(0,500):void 0})),{items:I,total:L,loading:R,nextPage:Je,load:z,observe:B,replaceItem:Ye,prepend:Xe}=ie(qe),V=_(null),H=_(null),U=_([]),W=_(null),G=l(()=>new Set(j.contextPaths)),K=l(()=>I.value.find(e=>e.id===W.value)??U.value.find(e=>e.id===W.value)??null);n(()=>j.open,async e=>{e&&(U.value=[],W.value=null,F.value=``,P.value=`all`,N.value=`library`,await z(!0),await h(),B(V.value,H.value))},{immediate:!0}),n(N,async e=>{e===`library`&&(await h(),B(V.value,H.value))});let q=e=>U.value.some(t=>t.id===e.id);function J(e){if(!e.missing){if(W.value=e.id,!j.multiple){U.value=[e];return}U.value=q(e)?U.value.filter(t=>t.id!==e.id):[...U.value,e]}}function Ze(e,t){if(!j.multiple&&t?.detail===2&&!e.missing){U.value=[e],$();return}J(e)}async function Qe(e,t){let n=j.upload?await j.upload(e,t):await S.upload(e,t);return n?.media??n}function $e(e){let t=e.map(e=>({...e,usage_count:e.usage_count??0}));P.value=`all`,Xe(t),U.value=j.multiple?[...U.value,...t.filter(e=>!q(e))]:[t[t.length-1]],W.value=t[t.length-1].id,N.value=`library`}let Y=_(``),X=_(!1),Z=_(null);n(K,(e,t)=>{e?.id!==t?.id&&(Y.value=e?.alt??``,Z.value=null)});async function Q(){let e=K.value;if(e&&Y.value.trim()!==(e.alt??``)){X.value=!0;try{let t=await S.update(e.id,{alt:Y.value.trim()});Ye(t.media),U.value=U.value.map(n=>n.id===e.id?{...n,alt:t.media.alt}:n)}catch(e){T.error(e.message)}finally{X.value=!1}}}async function et(){try{Z.value=(await S.show(K.value.id)).usages}catch(e){T.error(e.message)}}async function $(){await Q(),M(`select`,U.value.map(e=>ae(I.value.find(t=>t.id===e.id)??e))),M(`update:open`,!1)}let tt=l(()=>[{key:`all`,label:`Alle`},{key:`recent`,label:`Zuletzt verwendet`},...j.contextPaths.length?[{key:`here`,label:j.contextLabel}]:[],{key:`unused`,label:`Nicht verwendet`}]);return(n,l)=>(d(),g(r(pe),{open:u.open,"onUpdate:open":l[6]||=e=>M(`update:open`,e)},{default:p(()=>[e(r(fe),{class:`flex h-[min(88vh,820px)] max-w-6xl flex-col gap-0 overflow-hidden p-0 sm:max-w-6xl`},{default:p(()=>[o(`header`,he,[o(`div`,ge,[e(r(de),{class:`text-base`},{default:p(()=>[t(m(u.title||(u.multiple?`Bilder auswählen`:`Bild auswählen`)),1)]),_:1}),e(r(ue),{class:`text-[13px]`},{default:p(()=>[t(m(u.multiple?`Mehrere Bilder anklicken – die Reihenfolge der Auswahl bleibt erhalten.`:`Ein Bild anklicken, mit Doppelklick direkt übernehmen.`),1)]),_:1})]),o(`nav`,_e,[(d(!0),s(f,null,c([{key:`upload`,label:`Hochladen`,icon:r(w)},{key:`library`,label:`Mediathek`,icon:r(E)}],e=>(d(),s(`button`,{key:e.key,type:`button`,role:`tab`,"aria-selected":N.value===e.key,class:a([`inline-flex items-center gap-1.5 border-b-2 px-3 pb-2.5 text-sm font-medium transition-colors`,N.value===e.key?`border-brand text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`]),onClick:t=>N.value=e.key},[(d(),g(v(e.icon),{class:`size-4`})),t(` `+m(e.label),1)],10,ve))),128))])]),i(o(`div`,ye,[u.open?(d(),g(ne,{key:0,upload:Qe,paste:N.value===`upload`,onDone:$e},null,8,[`paste`])):y(``,!0),l[7]||=o(`p`,{class:`mt-4 text-[13px] text-muted-foreground`},`Hochgeladene Bilder landen in der Mediathek und sind danach ausgewählt. Große Fotos werden automatisch verkleinert.`,-1)],512),[[b,N.value===`upload`]]),i(o(`div`,be,[o(`div`,xe,[o(`div`,Se,[o(`label`,Ce,[l[8]||=o(`span`,{class:`sr-only`},`Suchen`,-1),e(r(me),{class:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),i(o(`input`,{"onUpdate:modelValue":l[0]||=e=>F.value=e,type:`search`,placeholder:`Suchen: Name, Alternativtext, Schlagwort …`,class:`h-8 w-full rounded-md border border-input bg-card pr-3 pl-8 text-sm placeholder:text-muted-foreground focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none`},null,512),[[x,F.value]])]),o(`div`,we,[(d(!0),s(f,null,c(tt.value,e=>(d(),s(`button`,{key:e.key,type:`button`,class:a([`h-8 rounded-md px-2.5 text-[13px] font-medium transition-colors`,P.value===e.key?`bg-brand-soft text-brand-soft-foreground`:`text-muted-foreground hover:bg-accent hover:text-foreground`]),"aria-pressed":P.value===e.key,onClick:t=>P.value=e.key},m(e.label),11,Te))),128))])]),o(`div`,{ref_key:`scroller`,ref:H,class:`min-h-0 flex-1 overflow-y-auto p-4`},[r(I).length?(d(),s(`ul`,O,[(d(!0),s(f,null,c(r(I),t=>(d(),s(`li`,{key:t.id},[e(ee,{item:t,selected:q(t),checkable:u.multiple,here:G.value.has(t.path),onOpen:Ze,onToggle:J},null,8,[`item`,`selected`,`checkable`,`here`])]))),128))])):r(R)?y(``,!0):(d(),s(`div`,Ee,[(d(),g(v(F.value||P.value!==`all`?r(ce):r(E)),{class:`size-8 text-muted-foreground`,"stroke-width":1.5})),o(`p`,De,m(F.value||P.value!==`all`?`Keine Bilder gefunden`:`Die Mediathek ist noch leer`),1),e(r(D),{variant:`outline`,size:`sm`,class:`mt-3`,onClick:l[1]||=e=>N.value=`upload`},{default:p(()=>[e(r(w)),l[9]||=t(` Bilder hochladen`,-1)]),_:1})])),o(`div`,{ref_key:`sentinel`,ref:V,class:`grid h-12 place-items-center`},[r(R)?(d(),g(r(C),{key:0,class:`size-5 animate-spin text-muted-foreground`})):r(Je)&&r(I).length?(d(),g(r(D),{key:1,variant:`ghost`,size:`sm`,onClick:l[2]||=e=>r(z)()},{default:p(()=>[...l[10]||=[t(`Weitere laden`,-1)]]),_:1})):y(``,!0)],512)],512)]),o(`aside`,Oe,[K.value?(d(),s(`div`,ke,[o(`div`,Ae,[K.value.thumb_url||K.value.url?(d(),s(`img`,{key:0,src:K.value.url||K.value.thumb_url,alt:K.value.alt,class:`max-h-44 w-auto object-contain`},null,8,je)):(d(),g(r(se),{key:1,class:`my-10 size-6 text-muted-foreground`}))]),o(`div`,Me,[o(`p`,Ne,m(K.value.name),1),o(`p`,Pe,[K.value.width?(d(),s(f,{key:0},[t(m(K.value.width)+` × `+m(K.value.height)+` · `,1)],64)):y(``,!0),t(m(r(re)(K.value.size)),1)])]),o(`label`,Fe,[o(`span`,Ie,[l[11]||=t(` Alternativtext `,-1),X.value?(d(),g(r(C),{key:0,class:`size-3.5 animate-spin text-muted-foreground`})):y(``,!0)]),i(o(`textarea`,{"onUpdate:modelValue":l[3]||=e=>Y.value=e,rows:`3`,maxlength:`300`,placeholder:`Was ist auf dem Bild zu sehen?`,class:`w-full resize-none rounded-md border border-input bg-card px-2.5 py-1.5 text-[13px] focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none`,onBlur:Q},null,544),[[x,Y.value]]),l[12]||=o(`span`,{class:`text-[11px] text-muted-foreground`},`Wird in der Mediathek gespeichert und beim Einfügen übernommen.`,-1)]),o(`div`,Le,[G.value.has(K.value.path)?(d(),s(`p`,Re,m(u.contextLabel),1)):y(``,!0),K.value.usage_count?(d(),s(f,{key:2},[Z.value?(d(),g(te,{key:1,usages:Z.value},null,8,[`usages`])):(d(),s(`button`,{key:0,type:`button`,class:`font-medium text-brand-text hover:underline`,onClick:et},` In `+m(K.value.usage_count)+` `+m(K.value.usage_count===1?`Inhalt`:`Inhalten`)+` verwendet `,1))],64)):(d(),s(`p`,ze,`Noch nirgends verwendet.`))]),o(`a`,{href:`/redaktion/mediathek?q=${encodeURIComponent(K.value.name)}`,target:`_blank`,class:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground hover:underline`},[l[13]||=t(` In der Mediathek öffnen `,-1),e(r(oe),{class:`size-3`})],8,Be)])):(d(),s(`p`,Ve,`Bild anklicken, um Details zu sehen und den Alternativtext zu ergänzen.`))])],512),[[b,N.value===`library`]]),o(`footer`,He,[o(`div`,Ue,[U.value.length?(d(),s(f,{key:0},[o(`div`,We,[(d(!0),s(f,null,c(U.value.slice(-5),e=>(d(),s(`img`,{key:e.id,src:e.thumb_url,alt:``,class:`size-8 rounded border-2 border-card object-cover`},null,8,k))),128))]),o(`span`,Ge,m(U.value.length===1?`1 Bild ausgewählt`:`${U.value.length} Bilder ausgewählt`),1),u.multiple?(d(),s(`button`,{key:0,type:`button`,class:`inline-flex items-center gap-0.5 text-xs text-muted-foreground hover:text-foreground`,onClick:l[4]||=e=>U.value=[]},[e(r(le),{class:`size-3`}),l[14]||=t(` Auswahl leeren`,-1)])):y(``,!0)],64)):r(L)!==null&&N.value===`library`?(d(),s(`span`,Ke,m(r(L).toLocaleString(`de-DE`))+` `+m(r(L)===1?`Bild`:`Bilder`),1)):y(``,!0)]),e(r(D),{variant:`outline`,onClick:l[5]||=e=>M(`update:open`,!1)},{default:p(()=>[...l[15]||=[t(`Abbrechen`,-1)]]),_:1}),e(r(D),{disabled:!U.value.length,onClick:$},{default:p(()=>[t(m(u.multiple&&U.value.length>1?`${U.value.length} Bilder übernehmen`:`Übernehmen`),1)]),_:1},8,[`disabled`])])]),_:1})]),_:1},8,[`open`]))}},j={__name:`MediaPickerHost`,props:{picker:{type:Object,required:!0}},setup(e){return(t,n)=>(d(),g(A,{open:e.picker.state.open,multiple:e.picker.state.multiple,title:e.picker.state.title,"context-paths":e.picker.state.contextPaths,"context-label":e.picker.state.contextLabel,upload:e.picker.state.upload,onSelect:n[0]||=t=>e.picker.finish(t),"onUpdate:open":n[1]||=t=>!t&&e.picker.finish(null)},null,8,[`open`,`multiple`,`title`,`context-paths`,`context-label`,`upload`]))}};function M(e={}){let t=u({open:!1,multiple:!1,title:``,contextPaths:[],contextLabel:e.contextLabel??`Hier verwendet`,upload:e.upload??null,resolve:null});function n(n={}){return t.resolve?.(null),new Promise(r=>{Object.assign(t,{multiple:!!n.multiple,title:n.title??``,contextPaths:n.contextPaths??e.contextPaths?.()??[],resolve:r,open:!0})})}function r(e){let n=t.resolve;t.resolve=null,t.open=!1,n?.(e)}return{state:t,pick:n,finish:r}}export{j as n,M as t};