Loheide-eu-mitarbeiterplatt.../public/build/assets/useMediaPicker-BdNeoeRH.js
Friederich Loheide b2599f7bc3
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 13m31s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 13m53s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 13m53s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 13m44s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 12m3s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 12m20s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m35s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 1m1s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 12m13s
CI / Build-Artefakte aktuell (pull_request) Successful in 4m56s
Gefällt mir im Feed, Suche links in der App-Kopfzeile (0.58.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 14:55:48 +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,Et as t,Ot as n,P as r,T as ee,W as i,w as te,x as ne}from"./ui-DY0WbyhT.js";import{At as a,C as o,Dt as s,O as c,Q as l,S as u,T as d,Tt as f,V as p,Y as m,_t as h,gt as g,k as _,m as v,ot as y,p as b,q as x,rt as S,st as C,v as w,w as T,x as E}from"./framework-Cy4cevSy.js";import{c as D,i as re,n as ie,r as ae,s as oe,t as se,u as ce}from"./useMediaList-ON0CK2CK.js";import{t as le}from"./external-link-CCO7Aupk.js";import{t as ue}from"./image-off-CyrS49Nm.js";import{t as de}from"./search-x-0wR3oofw.js";import{t as O}from"./upload-KXabp0v-.js";import{U as fe,dt as k}from"./app-drEEtcyr.js";var pe={class:`flex flex-wrap items-center gap-x-6 gap-y-2 border-b px-5 pt-4 pr-12`},me={class:`pb-3`},he={class:`-mb-px flex gap-1 self-end`,role:`tablist`},ge=[`aria-selected`,`onClick`],_e={class:`min-h-0 flex-1 overflow-y-auto p-5`},ve={class:`flex min-h-0 flex-1`},ye={class:`flex min-w-0 flex-1 flex-col`},be={class:`flex flex-wrap items-center gap-2 border-b px-4 py-2.5`},xe={class:`relative min-w-48 flex-1`},Se={class:`flex flex-wrap gap-1`},Ce=[`aria-pressed`,`onClick`],we={key:0,class:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`},Te={key:1,class:`grid place-items-center px-6 py-16 text-center`},Ee={class:`mt-3 text-sm font-medium`},De={class:`hidden w-72 shrink-0 overflow-y-auto border-l bg-muted/30 p-4 md:block`},Oe={key:0,class:`grid gap-3`},ke={class:`grid place-items-center overflow-hidden rounded-md border bg-card`},Ae=[`src`,`alt`],je={class:`text-[13px]`},Me={class:`font-medium break-all`},Ne={class:`text-muted-foreground`},Pe={class:`grid gap-1`},Fe={class:`flex items-center justify-between text-[13px] font-medium`},Ie={class:`text-[13px]`},Le={key:0,class:`mb-1 font-medium text-brand-text`},Re={key:1,class:`text-muted-foreground`},ze=[`href`],Be={key:1,class:`text-[13px] text-muted-foreground`},Ve={class:`flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3`},He={class:`flex min-w-0 flex-1 items-center gap-2`},Ue={class:`flex -space-x-2`},We=[`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(g,{emit:A}){let j=g,M=A,N=h(`library`),P=h(`all`),F=h(``),qe=E(()=>({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}=se(qe),V=h(null),H=h(null),U=h([]),W=h(null),G=E(()=>new Set(j.contextPaths)),K=E(()=>I.value.find(e=>e.id===W.value)??U.value.find(e=>e.id===W.value)??null);S(()=>j.open,async e=>{e&&(U.value=[],W.value=null,F.value=``,P.value=`all`,N.value=`library`,await z(!0),await p(),B(V.value,H.value))},{immediate:!0}),S(N,async e=>{e===`library`&&(await p(),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 D.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=h(``),X=h(!1),Z=h(null);S(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 D.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){i.error(e.message)}finally{X.value=!1}}}async function et(){try{Z.value=(await D.show(K.value.id)).usages}catch(e){i.error(e.message)}}async function $(){await Q(),M(`select`,U.value.map(e=>ce(I.value.find(t=>t.id===e.id)??e))),M(`update:open`,!1)}let tt=E(()=>[{key:`all`,label:`Alle`},{key:`recent`,label:`Zuletzt verwendet`},...j.contextPaths.length?[{key:`here`,label:j.contextLabel}]:[],{key:`unused`,label:`Nicht verwendet`}]);return(i,p)=>(x(),o(f(e),{open:g.open,"onUpdate:open":p[6]||=e=>M(`update:open`,e)},{default:y(()=>[_(f(ee),{class:`flex h-[min(88vh,820px)] max-w-6xl flex-col gap-0 overflow-hidden p-0 sm:max-w-6xl`},{default:y(()=>[u(`header`,pe,[u(`div`,me,[_(f(ne),{class:`text-base`},{default:y(()=>[c(a(g.title||(g.multiple?`Bilder auswählen`:`Bild auswählen`)),1)]),_:1}),_(f(te),{class:`text-[13px]`},{default:y(()=>[c(a(g.multiple?`Mehrere Bilder anklicken – die Reihenfolge der Auswahl bleibt erhalten.`:`Ein Bild anklicken, mit Doppelklick direkt übernehmen.`),1)]),_:1})]),u(`nav`,he,[(x(!0),d(w,null,m([{key:`upload`,label:`Hochladen`,icon:f(O)},{key:`library`,label:`Mediathek`,icon:f(k)}],e=>(x(),d(`button`,{key:e.key,type:`button`,role:`tab`,"aria-selected":N.value===e.key,class:s([`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},[(x(),o(l(e.icon),{class:`size-4`})),c(` `+a(e.label),1)],10,ge))),128))])]),C(u(`div`,_e,[g.open?(x(),o(ae,{key:0,upload:Qe,paste:N.value===`upload`,onDone:$e},null,8,[`paste`])):T(``,!0),p[7]||=u(`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),[[v,N.value===`upload`]]),C(u(`div`,ve,[u(`div`,ye,[u(`div`,be,[u(`label`,xe,[p[8]||=u(`span`,{class:`sr-only`},`Suchen`,-1),_(f(fe),{class:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),C(u(`input`,{"onUpdate:modelValue":p[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),[[b,F.value]])]),u(`div`,Se,[(x(!0),d(w,null,m(tt.value,e=>(x(),d(`button`,{key:e.key,type:`button`,class:s([`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},a(e.label),11,Ce))),128))])]),u(`div`,{ref_key:`scroller`,ref:H,class:`min-h-0 flex-1 overflow-y-auto p-4`},[f(I).length?(x(),d(`ul`,we,[(x(!0),d(w,null,m(f(I),e=>(x(),d(`li`,{key:e.id},[_(re,{item:e,selected:q(e),checkable:g.multiple,here:G.value.has(e.path),onOpen:Ze,onToggle:J},null,8,[`item`,`selected`,`checkable`,`here`])]))),128))])):f(R)?T(``,!0):(x(),d(`div`,Te,[(x(),o(l(F.value||P.value!==`all`?f(de):f(k)),{class:`size-8 text-muted-foreground`,"stroke-width":1.5})),u(`p`,Ee,a(F.value||P.value!==`all`?`Keine Bilder gefunden`:`Die Mediathek ist noch leer`),1),_(f(r),{variant:`outline`,size:`sm`,class:`mt-3`,onClick:p[1]||=e=>N.value=`upload`},{default:y(()=>[_(f(O)),p[9]||=c(` Bilder hochladen`,-1)]),_:1})])),u(`div`,{ref_key:`sentinel`,ref:V,class:`grid h-12 place-items-center`},[f(R)?(x(),o(f(n),{key:0,class:`size-5 animate-spin text-muted-foreground`})):f(Je)&&f(I).length?(x(),o(f(r),{key:1,variant:`ghost`,size:`sm`,onClick:p[2]||=e=>f(z)()},{default:y(()=>[...p[10]||=[c(`Weitere laden`,-1)]]),_:1})):T(``,!0)],512)],512)]),u(`aside`,De,[K.value?(x(),d(`div`,Oe,[u(`div`,ke,[K.value.thumb_url||K.value.url?(x(),d(`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,Ae)):(x(),o(f(ue),{key:1,class:`my-10 size-6 text-muted-foreground`}))]),u(`div`,je,[u(`p`,Me,a(K.value.name),1),u(`p`,Ne,[K.value.width?(x(),d(w,{key:0},[c(a(K.value.width)+` × `+a(K.value.height)+` · `,1)],64)):T(``,!0),c(a(f(oe)(K.value.size)),1)])]),u(`label`,Pe,[u(`span`,Fe,[p[11]||=c(` Alternativtext `,-1),X.value?(x(),o(f(n),{key:0,class:`size-3.5 animate-spin text-muted-foreground`})):T(``,!0)]),C(u(`textarea`,{"onUpdate:modelValue":p[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),[[b,Y.value]]),p[12]||=u(`span`,{class:`text-[11px] text-muted-foreground`},`Wird in der Mediathek gespeichert und beim Einfügen übernommen.`,-1)]),u(`div`,Ie,[G.value.has(K.value.path)?(x(),d(`p`,Le,a(g.contextLabel),1)):T(``,!0),K.value.usage_count?(x(),d(w,{key:2},[Z.value?(x(),o(ie,{key:1,usages:Z.value},null,8,[`usages`])):(x(),d(`button`,{key:0,type:`button`,class:`font-medium text-brand-text hover:underline`,onClick:et},` In `+a(K.value.usage_count)+` `+a(K.value.usage_count===1?`Inhalt`:`Inhalten`)+` verwendet `,1))],64)):(x(),d(`p`,Re,`Noch nirgends verwendet.`))]),u(`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`},[p[13]||=c(` In der Mediathek öffnen `,-1),_(f(le),{class:`size-3`})],8,ze)])):(x(),d(`p`,Be,`Bild anklicken, um Details zu sehen und den Alternativtext zu ergänzen.`))])],512),[[v,N.value===`library`]]),u(`footer`,Ve,[u(`div`,He,[U.value.length?(x(),d(w,{key:0},[u(`div`,Ue,[(x(!0),d(w,null,m(U.value.slice(-5),e=>(x(),d(`img`,{key:e.id,src:e.thumb_url,alt:``,class:`size-8 rounded border-2 border-card object-cover`},null,8,We))),128))]),u(`span`,Ge,a(U.value.length===1?`1 Bild ausgewählt`:`${U.value.length} Bilder ausgewählt`),1),g.multiple?(x(),d(`button`,{key:0,type:`button`,class:`inline-flex items-center gap-0.5 text-xs text-muted-foreground hover:text-foreground`,onClick:p[4]||=e=>U.value=[]},[_(f(t),{class:`size-3`}),p[14]||=c(` Auswahl leeren`,-1)])):T(``,!0)],64)):f(L)!==null&&N.value===`library`?(x(),d(`span`,Ke,a(f(L).toLocaleString(`de-DE`))+` `+a(f(L)===1?`Bild`:`Bilder`),1)):T(``,!0)]),_(f(r),{variant:`outline`,onClick:p[5]||=e=>M(`update:open`,!1)},{default:y(()=>[...p[15]||=[c(`Abbrechen`,-1)]]),_:1}),_(f(r),{disabled:!U.value.length,onClick:$},{default:y(()=>[c(a(g.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)=>(x(),o(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=g({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};