- Success Stories: full migration from old site (48/48, audited), markets n:n, quotation content block, columns content block, pretty SEO detail URLs via SuccessStoryPathRewrite middleware, list/detail split (list page 4 / story page), detailUrl/backUrl - New plugins: VITEC Locations (grid/list/map + RTE map text), VITEC Customer Logos (color/bw logic, only-show-selected), VITEC Card (one plugin for product/story/market/solution with reloading FlexForm + custom backend preview renderer) - Eventlist: layout dropdown (list/grid/teaserbar) in settings - Hero section CB: Images/Video tabs, background video + overlay - Product JSON: full category rootline (parents), fixed missing ConnectionPool import (all-products crash), category tree map - Backend preview CSS: container-query responsive (narrow columns) - Docs: ISO architecture spec, root + extension READMEs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 line
21 KiB
JavaScript
1 line
21 KiB
JavaScript
import{A as e,E as t,J as n,O as r,T as i,c as a,k as o,mt as s,ot as c,r as l,ut as u}from"./index-CM0zIqrs.js";import{t as d}from"./jszip.min-DxLKr7hR.js";var f=s(u(),1),p=s(d(),1),m=c(),h=`vitec_datasheets_view`,g=`vitec_datasheets_favorites`,_=e=>e?e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`:``;async function v(e,t){let r=new p.default;await Promise.all(e.map(async e=>{let t=e.datasheet?.file?.url;if(!t)return;let i=await fetch(n(t,a.base_url,a.router_mode));i.ok&&r.file(e.datasheet?.file?.name??`${e.product?.slug??`datasheet`}.pdf`,await i.blob())}));let i=await r.generateAsync({type:`blob`}),o=Object.assign(document.createElement(`a`),{href:URL.createObjectURL(i),download:t});o.click(),URL.revokeObjectURL(o.href)}function y({ext:t}){return t?(0,m.jsx)(e,{component:`span`,sx:{fontSize:`0.5625rem`,fontWeight:700,letterSpacing:`0.06em`,px:`0.3125rem`,py:`0.125rem`,borderRadius:`0.1875rem`,background:`rgba(var(--vitec-brand), 1)`,color:`#fff`,textTransform:`uppercase`,flexShrink:0},children:t}):null}function b({href:e}){return(0,m.jsxs)(r,{component:`a`,href:e,target:`_blank`,rel:`noreferrer noopener`,sx:{display:`inline-flex`,alignItems:`center`,gap:`0.3rem`,fontSize:`0.8125rem`,fontWeight:600,color:`rgba(var(--vitec-orange), 1)`,textDecoration:`none`,"&:hover":{color:`rgba(var(--vitec-orange-dark), 1)`},flexShrink:0},children:[(0,m.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,m.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,m.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]}),`Download`]})}function x({active:e,onToggle:t,size:n=18}){return(0,m.jsx)(`button`,{onClick:t,title:e?`Remove from favorites`:`Add to favorites`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:0,border:`none`,outline:`none`,background:`none`,cursor:`pointer`,transition:`transform 0.15s`,lineHeight:0},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.2)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:(0,m.jsx)(`svg`,{width:n,height:n,viewBox:`0 0 24 24`,fill:e?`#f59e0b`:`none`,stroke:e?`#f59e0b`:`#9ca3af`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,m.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})})}function S(){return(0,m.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,style:{display:`block`},children:[(0,m.jsx)(`rect`,{x:`1`,y:`1`,width:`6`,height:`6`,rx:`1`,fill:`currentColor`}),(0,m.jsx)(`rect`,{x:`9`,y:`1`,width:`6`,height:`6`,rx:`1`,fill:`currentColor`}),(0,m.jsx)(`rect`,{x:`1`,y:`9`,width:`6`,height:`6`,rx:`1`,fill:`currentColor`}),(0,m.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,fill:`currentColor`})]})}function C(){return(0,m.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,style:{display:`block`},children:[(0,m.jsx)(`rect`,{x:`1`,y:`2`,width:`14`,height:`2.5`,rx:`1`,fill:`currentColor`}),(0,m.jsx)(`rect`,{x:`1`,y:`7`,width:`14`,height:`2.5`,rx:`1`,fill:`currentColor`}),(0,m.jsx)(`rect`,{x:`1`,y:`11.5`,width:`14`,height:`2.5`,rx:`1`,fill:`currentColor`})]})}function w({view:e,onChange:t}){let n=e=>({display:`flex`,alignItems:`center`,justifyContent:`center`,width:`2rem`,height:`2rem`,padding:0,border:`none`,borderRadius:`0.25rem`,background:e?`rgba(var(--vitec-brand), 1)`:`transparent`,color:e?`#ffffff`:`#6b7280`,cursor:e?`default`:`pointer`,transition:`background 0.15s, color 0.15s`});return(0,m.jsxs)(`div`,{style:{display:`flex`,border:`1px solid #e5e7eb`,borderRadius:`0.375rem`,padding:`0.1875rem`,gap:`0.1875rem`,background:`#fff`},children:[(0,m.jsx)(`button`,{onClick:()=>t(`grid`),title:`Grid view`,style:n(e===`grid`),children:(0,m.jsx)(S,{})}),(0,m.jsx)(`button`,{onClick:()=>t(`table`),title:`Table view`,style:n(e===`table`),children:(0,m.jsx)(C,{})})]})}function T({value:e,onChange:t}){return(0,m.jsxs)(r,{sx:{display:`flex`,alignItems:`center`,gap:`0.625rem`,px:`0.875rem`,py:`0.5rem`,borderRadius:`0.5rem`,border:`1.5px solid`,borderColor:e?`rgba(var(--vitec-brand), 1)`:`divider`,bgcolor:`#fff`,maxWidth:`24rem`,transition:`border-color 0.15s`,"&:focus-within":{borderColor:`rgba(var(--vitec-brand), 1)`}},children:[(0,m.jsx)(r,{sx:{color:`text.disabled`,flexShrink:0,display:`flex`},children:(0,m.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,m.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]})}),(0,m.jsx)(r,{component:`input`,value:e,onChange:e=>t(e.target.value),placeholder:`Search datasheets…`,sx:{flex:1,border:`none`,outline:`none`,background:`transparent`,fontSize:`0.875rem`,color:`text.primary`,"&::placeholder":{color:`text.disabled`}}}),e&&(0,m.jsx)(r,{component:`button`,onClick:()=>t(``),sx:{display:`flex`,p:0,border:`none`,background:`none`,cursor:`pointer`,color:`text.disabled`,"&:hover":{color:`text.primary`}},children:(0,m.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,m.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function E({items:t,onRemove:o,onClear:s}){let[c,l]=(0,f.useState)(`idle`),u=async()=>{if(c!==`loading`){l(`loading`);try{await v(t,`vitec-datasheets-favorites.zip`),l(`idle`)}catch{l(`error`),setTimeout(()=>l(`idle`),3e3)}}};return(0,m.jsxs)(r,{sx:{borderRadius:`0.75rem`,overflow:`hidden`,border:`1px solid`,borderColor:`divider`,boxShadow:`0 0.25rem 1.5rem rgba(0,0,0,0.1)`},children:[(0,m.jsxs)(r,{sx:{background:`linear-gradient(135deg, rgba(var(--vitec-brand), 1) 0%, rgba(var(--vitec-navy-deep), 1) 100%)`,p:`1rem 1rem 0.875rem`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:1},children:[(0,m.jsxs)(i,{direction:`row`,spacing:.75,alignItems:`center`,children:[(0,m.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`#f59e0b`,stroke:`#f59e0b`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,m.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})}),(0,m.jsx)(e,{sx:{color:`#fff`,fontWeight:700,fontSize:`0.875rem`},children:`Your favorites`}),(0,m.jsx)(r,{sx:{background:`rgba(255,255,255,0.2)`,color:`#fff`,fontSize:`0.6875rem`,fontWeight:700,px:`0.375rem`,py:`0.0625rem`,borderRadius:`999px`,lineHeight:1.6},children:t.length})]}),(0,m.jsx)(r,{component:`button`,onClick:s,title:`Clear all`,sx:{display:`flex`,p:0,border:`none`,background:`none`,cursor:`pointer`,color:`rgba(255,255,255,0.6)`,"&:hover":{color:`#fff`},transition:`color 0.15s`},children:(0,m.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,m.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,m.jsx)(i,{sx:{bgcolor:`#fff`,maxHeight:`60vh`,overflowY:`auto`},divider:(0,m.jsx)(r,{sx:{borderTop:`1px solid`,borderColor:`divider`}}),children:t.map(t=>{let s=t.datasheet?.file?.url?n(t.datasheet.file.url,a.base_url,a.router_mode):void 0,c=t.datasheet?.file?.thumbnail?n(t.datasheet.file.thumbnail,a.base_url,a.router_mode):void 0,l=(t.product?.image?.url?n(t.product.image.url,a.base_url,a.router_mode):void 0)??c,u=t.datasheet?.uid??t.product?.uid;return(0,m.jsxs)(i,{direction:`row`,alignItems:`center`,spacing:1,sx:{p:`0.625rem 0.875rem`,"&:hover":{bgcolor:`rgba(var(--vitec-brand), 0.03)`}},children:[l&&(0,m.jsx)(r,{sx:{width:`2.5rem`,height:`2.5rem`,flexShrink:0,borderRadius:`0.25rem`,overflow:`hidden`,border:`1px solid`,borderColor:`divider`,bgcolor:`#f5f5f5`},children:(0,m.jsx)(r,{component:`img`,src:l,alt:``,loading:`lazy`,sx:{width:`100%`,height:`100%`,objectFit:`cover`,display:`block`}})}),(0,m.jsxs)(i,{spacing:.125,sx:{flex:1,minWidth:0},children:[(0,m.jsx)(e,{variant:`caption`,sx:{fontWeight:700,fontSize:`0.75rem`,lineHeight:1.3,color:`text.primary`},noWrap:!0,children:t.product?.title??t.datasheet?.title}),s&&(0,m.jsxs)(r,{component:`a`,href:s,target:`_blank`,rel:`noreferrer noopener`,sx:{fontSize:`0.6875rem`,color:`rgba(var(--vitec-orange), 1)`,textDecoration:`none`,"&:hover":{textDecoration:`underline`},display:`flex`,alignItems:`center`,gap:`0.25rem`},children:[(0,m.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,m.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,m.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]}),t.datasheet?.title??`Datasheet`]})]}),(0,m.jsx)(x,{active:!0,size:15,onToggle:e=>{e.preventDefault(),u!=null&&o(u)}})]},u)})}),t.length>1&&(0,m.jsx)(r,{sx:{p:`0.75rem`,borderTop:`1px solid`,borderColor:`divider`,bgcolor:`#fafafa`},children:(0,m.jsxs)(r,{component:`button`,onClick:u,disabled:c===`loading`,sx:{width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0.375rem`,py:`0.5rem`,px:`1rem`,border:`none`,borderRadius:`0.375rem`,cursor:c===`loading`?`default`:`pointer`,background:c===`error`?`rgba(239,68,68,0.1)`:`rgba(var(--vitec-brand), 1)`,color:c===`error`?`rgba(239,68,68,1)`:`#fff`,fontSize:`0.8125rem`,fontWeight:600,transition:`background 0.15s`,"&:hover:not(:disabled)":{background:`rgba(var(--vitec-navy-deep), 1)`}},children:[c===`loading`?(0,m.jsx)(r,{sx:{width:`1rem`,height:`1rem`,border:`2px solid rgba(255,255,255,0.4)`,borderTopColor:`#fff`,borderRadius:`50%`,animation:`spin 0.7s linear infinite`,"@keyframes spin":{to:{transform:`rotate(360deg)`}}}}):(0,m.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,m.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,m.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]}),c===`error`?`Download failed`:`Download all (ZIP)`]})})]})}function D({item:t,isFav:o,onToggleFav:s}){let c=t.product,l=t.datasheet,u=l?.file,d=u?.url?n(u.url,a.base_url,a.router_mode):void 0,f=u?.thumbnail?n(u.thumbnail,a.base_url,a.router_mode):void 0,p=(c?.image?.url?n(c.image.url,a.base_url,a.router_mode):void 0)??f,h=_(u?.size),g=(u?.extension??``).toUpperCase(),v=c?.categories?.[0];return(0,m.jsxs)(r,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,borderRadius:`0.5rem`,border:`1px solid`,borderColor:`divider`,overflow:`hidden`,bgcolor:`#fff`,boxShadow:`0 0.125rem 0.5rem rgba(0,0,0,0.05)`,transition:`box-shadow 0.2s, transform 0.2s`,"&:hover":{boxShadow:`0 0.5rem 1.5rem rgba(0,0,0,0.11)`,transform:`translateY(-0.125rem)`}},children:[(0,m.jsxs)(r,{sx:{aspectRatio:`16/9`,overflow:`hidden`,flexShrink:0,bgcolor:`#f0f2f5`,position:`relative`},children:[p?(0,m.jsx)(r,{component:`img`,src:p,alt:``,loading:`lazy`,sx:{width:`100%`,height:`100%`,objectFit:`cover`,display:`block`}}):(0,m.jsx)(r,{sx:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,m.jsxs)(`svg`,{width:`40`,height:`40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`0.75`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{opacity:.15},"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,m.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]})}),(0,m.jsx)(r,{sx:{position:`absolute`,top:`0.5rem`,right:`0.5rem`,bgcolor:`rgba(255,255,255,0.9)`,borderRadius:`50%`,width:`1.75rem`,height:`1.75rem`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:`0 1px 4px rgba(0,0,0,0.12)`},children:(0,m.jsx)(x,{active:o,onToggle:e=>{e.preventDefault(),e.stopPropagation(),s()}})})]}),(0,m.jsxs)(i,{sx:{p:`0.875rem`,flex:1,gap:`0.375rem`},children:[v&&(0,m.jsx)(e,{component:`span`,sx:{fontSize:`0.625rem`,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.06em`,color:`rgba(var(--vitec-brand), 1)`},children:v.title}),(0,m.jsx)(e,{variant:`subtitle1`,fontWeight:700,sx:{lineHeight:1.25,fontSize:`0.9375rem`},children:c?.title??l?.title}),c?.subtitle&&(0,m.jsx)(e,{variant:`body2`,color:`text.secondary`,sx:{fontSize:`0.8125rem`,lineHeight:1.4},children:c.subtitle}),(0,m.jsxs)(r,{sx:{mt:`auto`,pt:`0.625rem`,borderTop:`1px solid`,borderColor:`divider`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`0.5rem`},children:[(0,m.jsxs)(i,{direction:`row`,spacing:.625,alignItems:`center`,children:[(0,m.jsx)(y,{ext:g}),h&&(0,m.jsx)(e,{variant:`caption`,color:`text.disabled`,children:h})]}),d&&(0,m.jsx)(b,{href:d})]})]})]})}function O({item:t,odd:o,isFav:s,onToggleFav:c}){let l=t.product,u=t.datasheet,d=u?.file,f=d?.url?n(d.url,a.base_url,a.router_mode):void 0,p=d?.thumbnail?n(d.thumbnail,a.base_url,a.router_mode):void 0,h=(l?.image?.url?n(l.image.url,a.base_url,a.router_mode):void 0)??p,g=_(d?.size),v=(d?.extension??``).toUpperCase();return(0,m.jsxs)(r,{component:`tr`,sx:{bgcolor:o?`rgba(var(--vitec-brand), 0.025)`:`#fff`,"&:hover":{bgcolor:`rgba(var(--vitec-brand), 0.06)`},transition:`background 0.12s`},children:[(0,m.jsx)(r,{component:`td`,sx:{p:`0.5rem 0.5rem 0.5rem 0.75rem`,width:`2rem`,verticalAlign:`middle`},children:(0,m.jsx)(x,{active:s,onToggle:e=>{e.preventDefault(),e.stopPropagation(),c()}})}),(0,m.jsx)(r,{component:`td`,sx:{p:`0.5rem 0.75rem`,width:`3.5rem`,verticalAlign:`middle`},children:(0,m.jsx)(r,{sx:{width:`3rem`,height:`3rem`,borderRadius:`0.25rem`,overflow:`hidden`,bgcolor:`#f0f2f5`},children:h?(0,m.jsx)(r,{component:`img`,src:h,alt:``,loading:`lazy`,sx:{width:`100%`,height:`100%`,objectFit:`cover`,display:`block`}}):(0,m.jsx)(r,{sx:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,m.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{opacity:.25},"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,m.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]})})})}),(0,m.jsxs)(r,{component:`td`,sx:{p:`0.5rem 0.75rem`,verticalAlign:`middle`},children:[(0,m.jsx)(e,{variant:`subtitle2`,fontWeight:700,sx:{fontSize:`0.875rem`,lineHeight:1.3},children:l?.title??u?.title}),l?.subtitle&&(0,m.jsx)(e,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,lineHeight:1.4},children:l.subtitle})]}),(0,m.jsx)(r,{component:`td`,sx:{p:`0.5rem 0.75rem`,verticalAlign:`middle`},children:(0,m.jsx)(i,{direction:`row`,spacing:.5,flexWrap:`wrap`,useFlexGap:!0,children:(l?.categories??[]).map(t=>(0,m.jsx)(e,{component:`span`,sx:{fontSize:`0.625rem`,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.05em`,px:`0.375rem`,py:`0.125rem`,borderRadius:`0.1875rem`,border:`1px solid`,borderColor:`rgba(var(--vitec-brand), 0.3)`,color:`rgba(var(--vitec-brand), 1)`},children:t.title},t.uid))})}),(0,m.jsx)(r,{component:`td`,sx:{p:`0.5rem 0.75rem`,verticalAlign:`middle`,whiteSpace:`nowrap`},children:(0,m.jsxs)(i,{direction:`row`,spacing:.625,alignItems:`center`,children:[(0,m.jsx)(y,{ext:v}),g&&(0,m.jsx)(e,{variant:`caption`,color:`text.disabled`,children:g})]})}),(0,m.jsx)(r,{component:`td`,sx:{p:`0.5rem 0.75rem`,verticalAlign:`middle`,textAlign:`right`},children:f&&(0,m.jsx)(b,{href:f})})]})}function k({items:e,favorites:t,onToggleFav:n}){return(0,m.jsx)(r,{sx:{width:`100%`,overflowX:`auto`,borderRadius:`0.5rem`,border:`1px solid`,borderColor:`divider`,bgcolor:`#fff`,boxShadow:`0 0.125rem 0.5rem rgba(0,0,0,0.05)`},children:(0,m.jsxs)(r,{component:`table`,sx:{width:`100%`,borderCollapse:`collapse`,minWidth:`36rem`},children:[(0,m.jsx)(r,{component:`thead`,children:(0,m.jsx)(r,{component:`tr`,sx:{borderBottom:`2px solid`,borderColor:`divider`,bgcolor:`rgba(var(--vitec-brand), 0.04)`},children:[``,``,`Product`,`Category`,`File`,``].map((e,t)=>(0,m.jsx)(r,{component:`th`,sx:{px:`0.75rem`,py:`0.625rem`,textAlign:t===5?`right`:`left`,fontSize:`0.6875rem`,fontWeight:700,textTransform:`uppercase`,letterSpacing:`0.06em`,color:`text.secondary`,whiteSpace:`nowrap`,width:t===0?`2rem`:t===1?`3.5rem`:t===5?`7rem`:void 0},children:e},t))})}),(0,m.jsx)(r,{component:`tbody`,children:e.map((e,r)=>{let i=e.datasheet?.uid??e.product?.uid;return(0,m.jsx)(O,{item:e,odd:r%2==1,isFav:i!=null&&t.has(i),onToggleFav:()=>{i!=null&&n(i)}},i??r)})})]})})}function A({page:e,total:t,onChange:n}){return t<=1?null:(0,m.jsx)(i,{direction:`row`,spacing:.5,justifyContent:`center`,flexWrap:`wrap`,useFlexGap:!0,children:Array.from({length:t},(e,t)=>t+1).map(t=>(0,m.jsx)(r,{component:`button`,onClick:()=>n(t),sx:{minWidth:`2rem`,height:`2rem`,px:`0.5rem`,borderRadius:`0.25rem`,border:`1px solid`,background:t===e?`rgba(var(--vitec-brand), 1)`:`transparent`,borderColor:t===e?`rgba(var(--vitec-brand), 1)`:`divider`,color:t===e?`#fff`:`inherit`,fontSize:`0.875rem`,fontWeight:t===e?600:400,cursor:`pointer`,transition:`all 0.15s`,"&:hover:not(:disabled)":{borderColor:`rgba(var(--vitec-brand), 1)`,color:t===e?`#fff`:`rgba(var(--vitec-brand), 1)`}},children:t},t))})}function j({element:n,className:a,nested:s,devInfoTags:c,uid:u,spaceBefore:d,spaceAfter:p}){let _=n.content?.datasheets,v=_?.items??[],y=_?.settings,b=y?.showSearch??!0,x=y?.showFilter??!0,S=y?.itemsPerPage??20,[C,O]=(0,f.useState)(()=>{try{return localStorage.getItem(h)??`grid`}catch{return`grid`}}),[j,M]=(0,f.useState)(``),[N,P]=(0,f.useState)(new Set),[F,I]=(0,f.useState)(1),[L,R]=(0,f.useState)(()=>{try{let e=localStorage.getItem(g);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}),z=e=>{O(e);try{localStorage.setItem(h,e)}catch{}},B=(0,f.useCallback)(e=>{R(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(g,JSON.stringify([...n]))}catch{}return n})},[]),V=(0,f.useCallback)(()=>{R(new Set);try{localStorage.removeItem(g)}catch{}},[]),H=(0,f.useMemo)(()=>{let e=new Map;for(let t of v)for(let n of t.product?.categories??[])n.uid!=null&&n.title&&e.set(n.uid,n.title);return Array.from(e.entries()).map(([e,t])=>({uid:e,title:t})).sort((e,t)=>e.title.localeCompare(t.title))},[v]),U=(0,f.useMemo)(()=>{let e=j.toLowerCase().trim();return v.filter(t=>{let n=!e||t.product?.title?.toLowerCase().includes(e)||t.product?.subtitle?.toLowerCase().includes(e)||t.datasheet?.title?.toLowerCase().includes(e),r=N.size===0||(t.product?.categories??[]).some(e=>e.uid!=null&&N.has(e.uid));return n&&r})},[v,j,N]);(0,f.useEffect)(()=>{I(1)},[j,N]);let W=Math.ceil(U.length/S),G=U.slice((F-1)*S,F*S),K=(0,f.useMemo)(()=>v.filter(e=>{let t=e.datasheet?.uid??e.product?.uid;return t!=null&&L.has(t)}),[v,L]),q=e=>{P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},J=K.length>0;return(0,m.jsx)(l,{className:a,devInfoTags:c,nested:s,uid:u,spaceBefore:d,spaceAfter:p,children:(0,m.jsxs)(i,{direction:{xs:`column`,lg:`row`},spacing:3,alignItems:`flex-start`,children:[(0,m.jsxs)(i,{spacing:2,sx:{flex:1,minWidth:0},children:[(0,m.jsxs)(i,{direction:`row`,alignItems:`center`,gap:1.5,flexWrap:`wrap`,children:[b&&(0,m.jsx)(T,{value:j,onChange:M}),(0,m.jsxs)(i,{direction:`row`,alignItems:`center`,spacing:1.5,sx:{ml:`auto`},children:[(0,m.jsx)(e,{variant:`body2`,color:`text.secondary`,sx:{whiteSpace:`nowrap`},children:U.length===v.length?`${v.length} datasheet${v.length===1?``:`s`}`:`${U.length} of ${v.length}`}),(0,m.jsx)(w,{view:C,onChange:z})]})]}),x&&H.length>0&&(0,m.jsxs)(i,{direction:`row`,spacing:.75,flexWrap:`wrap`,useFlexGap:!0,children:[H.map(e=>(0,m.jsx)(o,{label:e.title,size:`small`,clickable:!0,onClick:()=>q(e.uid),variant:N.has(e.uid)?`filled`:`outlined`,sx:{fontSize:`0.75rem`,...N.has(e.uid)&&{bgcolor:`rgba(var(--vitec-brand), 1)`,color:`#fff`,"&:hover":{bgcolor:`rgba(var(--vitec-navy-deep), 1)`}}}},e.uid)),N.size>0&&(0,m.jsx)(o,{label:`Clear`,size:`small`,clickable:!0,onClick:()=>P(new Set),sx:{fontSize:`0.75rem`,color:`text.secondary`}})]}),G.length>0?C===`grid`?(0,m.jsx)(t,{container:!0,spacing:2,children:G.map(e=>{let n=e.datasheet?.uid??e.product?.uid;return(0,m.jsx)(t,{size:{xs:12,sm:6,md:J?6:4},children:(0,m.jsx)(D,{item:e,isFav:n!=null&&L.has(n),onToggleFav:()=>{n!=null&&B(n)}})},n)})}):(0,m.jsx)(k,{items:G,favorites:L,onToggleFav:B}):(0,m.jsx)(r,{sx:{py:`3rem`,textAlign:`center`},children:(0,m.jsx)(e,{color:`text.secondary`,children:`No datasheets match your search.`})}),(0,m.jsx)(A,{page:F,total:W,onChange:I})]}),J&&(0,m.jsx)(r,{sx:{width:{xs:`100%`,lg:`17rem`},flexShrink:0,position:{lg:`sticky`},top:{lg:`5rem`}},children:(0,m.jsx)(E,{items:K,onRemove:B,onClear:V})})]})})}export{j as VitecDatasheets}; |