@dvina/artifact-renderer-viewer 0.0.51 → 0.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.html CHANGED
@@ -37,7 +37,7 @@
37
37
  document.documentElement.dataset.themeMode = themeMode;
38
38
  })();
39
39
  </script>
40
- <script type="module" crossorigin src="/assets/index-CsCZv1Nk.js"></script>
40
+ <script type="module" crossorigin src="/assets/index-jpLSATjO.js"></script>
41
41
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-Dhb16r3m.js">
42
42
  <link rel="stylesheet" crossorigin href="/assets/index-rPjexcwV.css">
43
43
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvina/artifact-renderer-viewer",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "The Dvina Artifact Renderer viewer as a built static site: index.html and its assets, ready to serve from any static host.",
5
5
  "type": "module",
6
6
  "files": [
@@ -30,9 +30,9 @@
30
30
  "vite": "^6.3.5",
31
31
  "xlsx": "^0.18.5",
32
32
  "yaml": "^2.8.3",
33
- "@dvina/artifact-renderer-core": "0.0.51",
34
- "@dvina/artifact-renderer-protocol": "0.0.51",
35
- "@dvina/widget-kit": "0.0.51"
33
+ "@dvina/artifact-renderer-core": "0.0.53",
34
+ "@dvina/widget-kit": "0.0.53",
35
+ "@dvina/artifact-renderer-protocol": "0.0.53"
36
36
  },
37
37
  "license": "MIT",
38
38
  "repository": {
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/exceljs-vendor--7nq3sLx.js","assets/react-vendor-Dhb16r3m.js","assets/jszip-vendor-D1v1h9Q9.js"])))=>i.map(i=>d[i]);
2
- import{r as $,j as c,_ as A}from"./react-vendor-Dhb16r3m.js";import{r as k,u as M}from"./xlsx-vendor-BUW7exb-.js";function E(e){let o=e+1,a="";for(;o>0;){const u=(o-1)%26;a=String.fromCharCode(65+u)+a,o=Math.floor((o-1)/26)}return a}function _(e,o){if(typeof e=="number")return e;if(typeof o=="number")return Math.round(o*96/72)}function W(e){if(!e)return"";try{return M.format_cell(e)}catch{return e.w?String(e.w):e.v==null?"":String(e.v)}}function L(e,o){const a=o["!ref"];if(!a)return{name:e,rows:[],columnLabels:[],columnWidths:[],rowHeights:[],visibleRowNumbers:[],visibleColumnNumbers:[]};const u=M.decode_range(a),m=o["!cols"]??[],l=o["!rows"]??[],h=o["!merges"]??[],b=Array.from({length:u.e.c-u.s.c+1},(n,s)=>u.s.c+s).filter(n=>{var s;return!((s=m[n])!=null&&s.hidden)}),g=Array.from({length:u.e.r-u.s.r+1},(n,s)=>u.s.r+s).filter(n=>{var s;return!((s=l[n])!=null&&s.hidden)}),y=new Set,S=new Map;h.forEach(n=>{const s=b.filter(t=>t>=n.s.c&&t<=n.e.c),v=g.filter(t=>t>=n.s.r&&t<=n.e.r);if(s.length===0||v.length===0)return;const r=s[0],i=v[0];S.set(`${i}:${r}`,{rowSpan:v.length,colSpan:s.length}),v.forEach(t=>{s.forEach(d=>{t===i&&d===r||y.add(`${t}:${d}`)})})});const w=g.map(n=>b.map(s=>{const v=`${n}:${s}`;if(y.has(v))return null;const r=M.encode_cell({r:n,c:s}),i=o[r],t=S.get(v);return{key:r,value:W(i),numeric:typeof(i==null?void 0:i.v)=="number",colSpan:t==null?void 0:t.colSpan,rowSpan:t==null?void 0:t.rowSpan}})),j=b.map(n=>{const s=m[n];return typeof(s==null?void 0:s.wpx)=="number"?Math.max(s.wpx,88):typeof(s==null?void 0:s.wch)=="number"?Math.max(Math.round(s.wch*9+18),88):120}),x=g.map(n=>{const s=l[n];return _(s==null?void 0:s.hpx,s==null?void 0:s.hpt)??34});return{name:e,rows:w,columnLabels:b.map(n=>E(n)),columnWidths:j,rowHeights:x,visibleRowNumbers:g,visibleColumnNumbers:b}}function C(e){if(typeof e=="string"){if(e.length===8)return`#${e.slice(2)}`;if(e.length===6)return`#${e}`}}function R(e){switch(e){case"double":return"2px double";case"medium":case"thick":return"2px solid";case"dashed":return"1px dashed";case"dotted":return"1px dotted";default:return"1px solid"}}function T(e){var b,g,y,S,w,j,x;const o={},a=e==null?void 0:e.font,u=e==null?void 0:e.fill,m=e==null?void 0:e.alignment,l=e==null?void 0:e.border;a!=null&&a.name&&(o.fontFamily=`${a.name}, "Inter", "Segoe UI", sans-serif`),a!=null&&a.size&&(o.fontSize=`${a.size}px`),a!=null&&a.bold&&(o.fontWeight=700),a!=null&&a.italic&&(o.fontStyle="italic");const h=C((b=a==null?void 0:a.color)==null?void 0:b.argb);if(h&&(o.color=h),(u==null?void 0:u.type)==="pattern"&&u.pattern==="solid"){const n=C(((g=u.fgColor)==null?void 0:g.argb)??((y=u.bgColor)==null?void 0:y.argb));n&&(o.background=n)}if(m!=null&&m.horizontal){const n={left:"left",center:"center",right:"right",fill:"left",justify:"left"};o.textAlign=n[m.horizontal]??"left"}if(m!=null&&m.vertical){const n={top:"top",middle:"middle",bottom:"bottom"};o.verticalAlign=n[m.vertical]??"middle"}return m!=null&&m.wrapText&&(o.whiteSpace="pre-wrap",o.wordBreak="break-word"),l!=null&&l.top&&(o.borderTop=`${R(l.top.style)} ${C((S=l.top.color)==null?void 0:S.argb)??"rgba(17,24,39,0.12)"}`),l!=null&&l.right&&(o.borderRight=`${R(l.right.style)} ${C((w=l.right.color)==null?void 0:w.argb)??"rgba(17,24,39,0.12)"}`),l!=null&&l.bottom&&(o.borderBottom=`${R(l.bottom.style)} ${C((j=l.bottom.color)==null?void 0:j.argb)??"rgba(17,24,39,0.12)"}`),l!=null&&l.left&&(o.borderLeft=`${R(l.left.style)} ${C((x=l.left.color)==null?void 0:x.argb)??"rgba(17,24,39,0.12)"}`),Object.keys(o).length>0?o:void 0}async function z(e){const a=(await A(()=>import("./exceljs-vendor--7nq3sLx.js").then(h=>h.e),__vite__mapDeps([0,1,2]))).Workbook,u=new a;await u.xlsx.load(e);const m=u.worksheets.map(h=>h.name),l=Object.fromEntries(u.worksheets.map(h=>{var v;const b=h.dimensions;if(!b)return[h.name,{name:h.name,rows:[],columnLabels:[],columnWidths:[],rowHeights:[],visibleRowNumbers:[],visibleColumnNumbers:[]}];const g=Array.from({length:b.right-b.left+1},(r,i)=>b.left-1+i).filter(r=>!h.getColumn(r+1).hidden),y=Array.from({length:b.bottom-b.top+1},(r,i)=>b.top-1+i).filter(r=>!h.getRow(r+1).hidden),S=(((v=h.model)==null?void 0:v.merges)??[]).map(r=>M.decode_range(r)),w=new Set,j=new Map;S.forEach(r=>{const i=g.filter(p=>p>=r.s.c&&p<=r.e.c),t=y.filter(p=>p>=r.s.r&&p<=r.e.r);if(i.length===0||t.length===0)return;const d=i[0],f=t[0];j.set(`${f}:${d}`,{rowSpan:t.length,colSpan:i.length}),t.forEach(p=>{i.forEach(N=>{p===f&&N===d||w.add(`${p}:${N}`)})})});const x=y.map(r=>g.map(i=>{const t=`${r}:${i}`;if(w.has(t))return null;const f=h.getRow(r+1).getCell(i+1),p=j.get(t);return{key:`${h.name}:${r}:${i}`,value:typeof f.text=="string"?f.text:String(f.value??""),numeric:typeof f.value=="number",colSpan:p==null?void 0:p.colSpan,rowSpan:p==null?void 0:p.rowSpan,style:T(f)}})),n=g.map(r=>{const i=h.getColumn(r+1);return typeof i.width=="number"?Math.max(Math.round(i.width*8+22),88):120}),s=y.map(r=>{const i=h.getRow(r+1);return _(void 0,i.height)??34});return[h.name,{name:h.name,rows:x,columnLabels:g.map(r=>E(r)),columnWidths:n,rowHeights:s,visibleRowNumbers:y,visibleColumnNumbers:g}]}));return{sheetNames:m,sheets:l}}function O({document:e,request:o,onLoaded:a,onUnsupported:u,onError:m,onResize:l,useContainerResize:h,LoadingState:b}){var i;const g=$.useRef(null),[y,S]=$.useState(!0),[w,j]=$.useState(null),[x,n]=$.useState(null),s=((i=e.renderOptions)==null?void 0:i.spreadsheetMode)??"fast",v=s==="styled"&&e.format!=="xlsx"?"fast":s;h(g,l),$.useEffect(()=>{if(!o){u("feature-not-available","This spreadsheet does not expose a preview-safe URL.");return}const t=new AbortController;return S(!0),fetch(o.url,{...o.init,signal:t.signal}).then(async d=>{if(!d.ok)throw new Error(`Request failed with status ${d.status}`);if(v==="styled"){const N=await z(await d.arrayBuffer());if(N.sheetNames.length===0){u("feature-not-available","The workbook does not contain any visible sheets.");return}j(N),n(N.sheetNames[0]),S(!1),a();return}const f=e.format==="csv"?k(await d.text(),{type:"string",cellStyles:!0,cellNF:!0}):k(await d.arrayBuffer(),{type:"array",cellStyles:!0,cellNF:!0});if(f.SheetNames.length===0){u("feature-not-available","The workbook does not contain any visible sheets.");return}const p={sheetNames:f.SheetNames,sheets:Object.fromEntries(f.SheetNames.map(N=>[N,L(N,f.Sheets[N])]))};j(p),n(f.SheetNames[0]),S(!1),a()}).catch(d=>{t.signal.aborted||m("document-fetch-failed",d instanceof Error?d.message:"Spreadsheet preview failed to load.",!0)}),()=>{t.abort()}},[e,v,m,a,u,o]);const r=$.useMemo(()=>!w||!x?null:w.sheets[x]??null,[x,w]);return c.jsxs("div",{ref:g,className:"document-office-shell document-sheet-shell",children:[y?c.jsx(b,{label:"Rendering spreadsheet preview"}):null,w&&r?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"document-sheet-table-wrap",children:c.jsxs("table",{className:"document-sheet-table","data-viewer-zoom-target":!0,children:[c.jsxs("colgroup",{children:[c.jsx("col",{style:{width:44}}),r.columnWidths.map((t,d)=>c.jsx("col",{style:{width:t}},d))]}),c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"document-sheet-corner","aria-hidden":"true"}),r.columnLabels.map(t=>c.jsx("th",{className:"document-sheet-colhead",children:t},t))]})}),c.jsx("tbody",{children:r.rows.map((t,d)=>c.jsxs("tr",{style:{height:r.rowHeights[d]},children:[c.jsx("th",{className:"document-sheet-rowhead",children:r.visibleRowNumbers[d]+1}),t.map(f=>f?c.jsx("td",{className:f.numeric?"document-sheet-cell-numeric":void 0,colSpan:f.colSpan,rowSpan:f.rowSpan,style:f.style,children:f.value},f.key):null)]},r.visibleRowNumbers[d]))})]})}),c.jsxs("div",{className:"document-sheet-footer",children:[c.jsxs("div",{className:"document-sheet-footer-meta",children:[c.jsxs("span",{children:[w.sheetNames.length," sheets"]}),c.jsxs("span",{children:[r.rows.length," rows"]}),c.jsxs("span",{children:[r.columnLabels.length," columns"]})]}),c.jsx("div",{className:"gap"}),c.jsx("div",{className:"document-sheet-tabs document-sheet-tabs-footer",children:w.sheetNames.map(t=>c.jsx("button",{type:"button",className:t===x?"is-active":void 0,onClick:()=>n(t),children:t},t))})]})]}):null]})}export{O as default};