Loheide-eu-mitarbeiterplatt.../public/build/assets/useMediaPicker-DdbVR98B.js
Friederich Loheide 268742983a
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m17s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m28s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 6m32s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 6m48s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 8m51s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 8m52s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 7m31s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 52s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 7m51s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m22s
KI-Assistent: OpenAI und Ollama als Anbieter (0.35.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 13:57:37 +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-1uuyDm8q.js";import{t as oe}from"./external-link-Ddmamed9.js";import{t as se}from"./image-off-BO5qjHGQ.js";import{t as C}from"./images-seG0j9y2.js";import{t as w}from"./loader-circle-Wr6tQn-J.js";import{t as ce}from"./search-x-Bfzq4V3S.js";import{t as T}from"./upload-QwHKBTTM.js";import{t as le}from"./x-DU8daajy.js";import{n as E}from"./lib-Be7KNAML.js";import{_ as D,a as ue,n as de,o as fe,s as pe,vt as me}from"./app-9hFE_0ay.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`},Ge=[`src`],Ke={class:`text-[13px] font-medium`},qe={key:1,class:`text-[13px] text-muted-foreground`},k={__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:k}){let A=u,j=k,M=_(`library`),N=_(`all`),P=_(``),Je=l(()=>({q:P.value,sortierung:N.value===`recent`?`verwendet`:`neu`,status:N.value===`unused`?`unbenutzt`:N.value===`recent`?`verwendet`:``,pfade:N.value===`here`?A.contextPaths.slice(0,500):void 0})),{items:F,total:I,loading:L,nextPage:Ye,load:R,observe:z,replaceItem:Xe,prepend:Ze}=ie(Je),B=_(null),V=_(null),H=_([]),U=_(null),W=l(()=>new Set(A.contextPaths)),G=l(()=>F.value.find(e=>e.id===U.value)??H.value.find(e=>e.id===U.value)??null);n(()=>A.open,async e=>{e&&(H.value=[],U.value=null,P.value=``,N.value=`all`,M.value=`library`,await R(!0),await h(),z(B.value,V.value))},{immediate:!0}),n(M,async e=>{e===`library`&&(await h(),z(B.value,V.value))});let K=e=>H.value.some(t=>t.id===e.id);function q(e){if(!e.missing){if(U.value=e.id,!A.multiple){H.value=[e];return}H.value=K(e)?H.value.filter(t=>t.id!==e.id):[...H.value,e]}}function Qe(e,t){if(!A.multiple&&t?.detail===2&&!e.missing){H.value=[e],$();return}q(e)}async function $e(e,t){let n=A.upload?await A.upload(e,t):await S.upload(e,t);return n?.media??n}function et(e){let t=e.map(e=>({...e,usage_count:e.usage_count??0}));N.value=`all`,Ze(t),H.value=A.multiple?[...H.value,...t.filter(e=>!K(e))]:[t[t.length-1]],U.value=t[t.length-1].id,M.value=`library`}let J=_(``),Y=_(!1),X=_(null);n(G,(e,t)=>{e?.id!==t?.id&&(J.value=e?.alt??``,X.value=null)});async function Z(){let e=G.value;if(e&&J.value.trim()!==(e.alt??``)){Y.value=!0;try{let t=await S.update(e.id,{alt:J.value.trim()});Xe(t.media),H.value=H.value.map(n=>n.id===e.id?{...n,alt:t.media.alt}:n)}catch(e){E.error(e.message)}finally{Y.value=!1}}}async function Q(){try{X.value=(await S.show(G.value.id)).usages}catch(e){E.error(e.message)}}async function $(){await Z(),j(`select`,H.value.map(e=>ae(F.value.find(t=>t.id===e.id)??e))),j(`update:open`,!1)}let tt=l(()=>[{key:`all`,label:`Alle`},{key:`recent`,label:`Zuletzt verwendet`},...A.contextPaths.length?[{key:`here`,label:A.contextLabel}]:[],{key:`unused`,label:`Nicht verwendet`}]);return(n,l)=>(d(),g(r(pe),{open:u.open,"onUpdate:open":l[6]||=e=>j(`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(T)},{key:`library`,label:`Mediathek`,icon:r(C)}],e=>(d(),s(`button`,{key:e.key,type:`button`,role:`tab`,"aria-selected":M.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`,M.value===e.key?`border-brand text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`]),onClick:t=>M.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:$e,paste:M.value===`upload`,onDone:et},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,M.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=>P.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,P.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`,N.value===e.key?`bg-brand-soft text-brand-soft-foreground`:`text-muted-foreground hover:bg-accent hover:text-foreground`]),"aria-pressed":N.value===e.key,onClick:t=>N.value=e.key},m(e.label),11,Te))),128))])]),o(`div`,{ref_key:`scroller`,ref:V,class:`min-h-0 flex-1 overflow-y-auto p-4`},[r(F).length?(d(),s(`ul`,O,[(d(!0),s(f,null,c(r(F),t=>(d(),s(`li`,{key:t.id},[e(ee,{item:t,selected:K(t),checkable:u.multiple,here:W.value.has(t.path),onOpen:Qe,onToggle:q},null,8,[`item`,`selected`,`checkable`,`here`])]))),128))])):r(L)?y(``,!0):(d(),s(`div`,Ee,[(d(),g(v(P.value||N.value!==`all`?r(ce):r(C)),{class:`size-8 text-muted-foreground`,"stroke-width":1.5})),o(`p`,De,m(P.value||N.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=>M.value=`upload`},{default:p(()=>[e(r(T)),l[9]||=t(` Bilder hochladen`,-1)]),_:1})])),o(`div`,{ref_key:`sentinel`,ref:B,class:`grid h-12 place-items-center`},[r(L)?(d(),g(r(w),{key:0,class:`size-5 animate-spin text-muted-foreground`})):r(Ye)&&r(F).length?(d(),g(r(D),{key:1,variant:`ghost`,size:`sm`,onClick:l[2]||=e=>r(R)()},{default:p(()=>[...l[10]||=[t(`Weitere laden`,-1)]]),_:1})):y(``,!0)],512)],512)]),o(`aside`,Oe,[G.value?(d(),s(`div`,ke,[o(`div`,Ae,[G.value.thumb_url||G.value.url?(d(),s(`img`,{key:0,src:G.value.url||G.value.thumb_url,alt:G.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(G.value.name),1),o(`p`,Pe,[G.value.width?(d(),s(f,{key:0},[t(m(G.value.width)+` × `+m(G.value.height)+` · `,1)],64)):y(``,!0),t(m(r(re)(G.value.size)),1)])]),o(`label`,Fe,[o(`span`,Ie,[l[11]||=t(` Alternativtext `,-1),Y.value?(d(),g(r(w),{key:0,class:`size-3.5 animate-spin text-muted-foreground`})):y(``,!0)]),i(o(`textarea`,{"onUpdate:modelValue":l[3]||=e=>J.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:Z},null,544),[[x,J.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,[W.value.has(G.value.path)?(d(),s(`p`,Re,m(u.contextLabel),1)):y(``,!0),G.value.usage_count?(d(),s(f,{key:2},[X.value?(d(),g(te,{key:1,usages:X.value},null,8,[`usages`])):(d(),s(`button`,{key:0,type:`button`,class:`font-medium text-brand-text hover:underline`,onClick:Q},` In `+m(G.value.usage_count)+` `+m(G.value.usage_count===1?`Inhalt`:`Inhalten`)+` verwendet `,1))],64)):(d(),s(`p`,ze,`Noch nirgends verwendet.`))]),o(`a`,{href:`/redaktion/mediathek?q=${encodeURIComponent(G.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,M.value===`library`]]),o(`footer`,He,[o(`div`,Ue,[H.value.length?(d(),s(f,{key:0},[o(`div`,We,[(d(!0),s(f,null,c(H.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,Ge))),128))]),o(`span`,Ke,m(H.value.length===1?`1 Bild ausgewählt`:`${H.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=>H.value=[]},[e(r(le),{class:`size-3`}),l[14]||=t(` Auswahl leeren`,-1)])):y(``,!0)],64)):r(I)!==null&&M.value===`library`?(d(),s(`span`,qe,m(r(I).toLocaleString(`de-DE`))+` `+m(r(I)===1?`Bild`:`Bilder`),1)):y(``,!0)]),e(r(D),{variant:`outline`,onClick:l[5]||=e=>j(`update:open`,!1)},{default:p(()=>[...l[15]||=[t(`Abbrechen`,-1)]]),_:1}),e(r(D),{disabled:!H.value.length,onClick:$},{default:p(()=>[t(m(u.multiple&&H.value.length>1?`${H.value.length} Bilder übernehmen`:`Übernehmen`),1)]),_:1},8,[`disabled`])])]),_:1})]),_:1},8,[`open`]))}},A={__name:`MediaPickerHost`,props:{picker:{type:Object,required:!0}},setup(e){return(t,n)=>(d(),g(k,{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 j(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{A as n,j as t};