@marimo-team/frontend 0.21.2-dev63 → 0.21.2-dev64
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/assets/{JsonOutput-Ca8qF0Zd.js → JsonOutput-C6G83us5.js} +9 -9
- package/dist/assets/{agent-panel-lhTAqQ2T.js → agent-panel-CEBChEgo.js} +1 -1
- package/dist/assets/{cell-editor-DlHW5qr3.js → cell-editor-By2GGVYQ.js} +1 -1
- package/dist/assets/{column-preview-ClCjoT33.js → column-preview-Bxza9N1V.js} +1 -1
- package/dist/assets/{command-palette-CF05xO-u.js → command-palette-Dx3dFDHn.js} +1 -1
- package/dist/assets/{context-aware-panel-BNcqd7JQ.js → context-aware-panel-BAsDUfG1.js} +1 -1
- package/dist/assets/{edit-page-CZshKgxH.js → edit-page-D2jHQ99Z.js} +3 -3
- package/dist/assets/{file-explorer-panel-DSpZ25B3.js → file-explorer-panel-Dxy2wacg.js} +1 -1
- package/dist/assets/{hooks-CpTBKWcv.js → hooks-DVW0qFsD.js} +1 -1
- package/dist/assets/{index-DIqPLE1R.js → index-BUi88mQ-.js} +15 -15
- package/dist/assets/{layout-am3J4ZNA.js → layout-b4TrkjtJ.js} +1 -1
- package/dist/assets/{panels-cRpwb1m4.js → panels-DxPykKF0.js} +1 -1
- package/dist/assets/{run-page-CUq8ZpoZ.js → run-page-Ce8MQ2gg.js} +1 -1
- package/dist/assets/{scratchpad-panel-CaZOnp24.js → scratchpad-panel-OulpXAJO.js} +1 -1
- package/dist/assets/{session-panel-B5exQEib.js → session-panel-BBXXuMQG.js} +1 -1
- package/dist/assets/{useNotebookActions-DH_ihkjl.js → useNotebookActions-BqjNClzw.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/src/components/data-table/__tests__/columns.test.tsx +138 -0
- package/src/components/data-table/columns.tsx +44 -4
- package/src/components/data-table/filters.ts +1 -0
- package/src/plugins/impl/DataTablePlugin.tsx +27 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as we}from"./chunk-LvLJmgfZ.js";import{d as L,l as Ze,p as Qe,u as de}from"./useEvent-O0nX5vok.js";import{t as et}from"./react-Bj1aDYRI.js";import{E as ge,Sn as tt,Vt as at,_ as ot,_i as ce,_n as nt,dr as it,et as st,h as je,jr as lt,nt as ve,or as rt,rr as dt,t as ct,tr as ht,tt as pt,vn as mt,yn as ut}from"./cells-BZ2tqr8k.js";import{t as D}from"./compiler-runtime-B3qBwwSJ.js";import{n as ft}from"./assertNever-DWSyoPEi.js";import{s as Ce}from"./useLifecycle-DA9DjSPo.js";import{i as yt,n as ze}from"./add-connection-dialog-S-Hiw5Sn.js";import{n as kt,x as bt}from"./ai-model-dropdown-C_T_oAXa.js";import{c as Me,m as T}from"./useEventListener-Dy81QR4n.js";import{y as xt}from"./utils-tNbLd14P.js";import{n as A,t as We}from"./constants-Rz_lD4HK.js";import{S as he,h as wt,x as gt}from"./config-DRN1Q5Ol.js";import{t as jt}from"./jsx-runtime-icT_Ltz2.js";import{r as vt,t as pe}from"./button-Ej3vmCIF.js";import{r as H}from"./requests-Bgjtqo_1.js";import{t as h}from"./createLucideIcon-Cm-Z7dYr.js";import{a as Se,f as Ct,i as _e,m as zt,p as De,u as Ae}from"./layout-am3J4ZNA.js";import{t as Pe}from"./check-DZA_bRpw.js";import{c as Ne,d as me,n as Mt,o as Wt,r as ue,t as St}from"./download-BX5RBVL8.js";import{n as _t}from"./maps-DQ4X82OB.js";import{r as Dt}from"./useCellActionButton-DBXavVBJ.js";import{t as At}from"./copy-CkudG0Ej.js";import{t as Pt}from"./download-DBW9RXtT.js";import{t as Nt}from"./eye-off-vwi9L975.js";import{t as It}from"./file-plus-corner-lLQw9OnR.js";import{t as J}from"./file-DzHkbIdO.js";import{t as Et}from"./github-BVtI-3F1.js";import{m as Lt}from"./form-DqfJycRl.js";import{n as Tt,r as Ht,t as qt}from"./youtube-DE-Ej6FR.js";import{n as Rt,t as Bt}from"./square-CxAsQQ77.js";import{t as Vt}from"./image-DXfkah9d.js";import{t as Ft}from"./link-Cf10mh3t.js";import{r as Ot}from"./input-6cciao_l.js";import{t as Yt}from"./settings-dVFT0AvU.js";import{y as Kt}from"./textarea-7F6-nuwz.js";import{t as C}from"./use-toast-BhMe50aT.js";import{n as Ie,t as Ut}from"./paths-bMgYkaP2.js";import{o as $t}from"./session-DKzpcHdK.js";import{a as Gt,c as Jt,i as Xt,n as Zt,r as Qt,s as ea,t as ta}from"./select-dNVaT2hT.js";import{t as aa}from"./tooltip-BCGmr4TU.js";import{o as oa}from"./alert-dialog-BfHy00ko.js";import{a as na,c as ia,i as sa,n as la,r as ra}from"./dialog-Dr3dl0Mn.js";import{n as fe}from"./ImperativeModal-DyRrGcKH.js";import{r as da,t as ca}from"./share-BKUsoia0.js";import{n as X}from"./copy-CIPmwSuj.js";import{r as ha}from"./useRunCells-CwObo_j4.js";import{a as pa}from"./cell-link-BgNPg6FR.js";import{a as ma}from"./renderShortcut-DKHsNYY8.js";import{t as ua}from"./icons-CIUvkMzI.js";import{t as fa}from"./links-BpU-Tgoi.js";import{r as ya,t as Ee}from"./hooks-CpTBKWcv.js";import{t as Le}from"./types-DQ8fCbJK.js";var ka=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ba=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Te=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),He=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),qe=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),xa=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),wa=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),ga=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Re=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ja=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),va=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Ca=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Be=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),za=h("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Ma=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Ve=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Fe=D(),ye=we(et(),1),a=we(jt(),1),Z="https://static.marimo.app";const Wa=e=>{let t=(0,Fe.c)(25),{onClose:n}=e,[o,s]=(0,ye.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Z}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let N=await r({download:!1,includeCode:!0,files:Ct.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Z}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:N,path:l})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:A.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ia,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(na,{children:[m,(0,a.jsxs)(ra,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:Z,target:"_blank",children:Z}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Ot,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Sa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(pe,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(pe,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await X(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(sa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(la,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var Sa=e=>{let t=(0,Fe.c)(8),[n,o]=ye.useState(!1),s;t[0]===e.text?s=t[1]:(s=vt.stopPropagation(async m=>{m.preventDefault(),await X(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(At,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(pe,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(aa,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},_a=D();function Da(){let e=document.getElementsByClassName(We.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=ce.findElement(t);if(!o){T.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ce.parse(o.id)}}}return T.warn("No visible output area found for scroll anchor"),null}function Aa(e){if(!e){T.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ce.create(e.cellId));if(!t){T.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${We.outputArea}`)){T.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Oe(){let e=(0,_a.c)(2),t=L(ve),n;return e[0]===t?n=e[1]:(n=()=>{let o=Da();t(s=>({mode:pt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Aa(o)})})},e[0]=t,e[1]=n),n}const Ye=Qe(!1);var Pa=D();const Na=()=>{let e=(0,Pa.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=_e();if(he()&&!tt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ea,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Jt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Zt,{children:(0,a.jsxs)(Qt,{children:[(0,a.jsx)(Gt,{children:"View as"}),Le.map(Ea)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(ta,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ia(e){return(0,a.jsx)(Ke(e),{className:"h-4 w-4"})}function Ke(e){switch(e){case"vertical":return ja;case"grid":return Ht;case"slides":return Be;default:return ft(e),Bt}}function Ue(e){return Ce(e)}function Ea(e){return(0,a.jsx)(Xt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ia(e),(0,a.jsx)("span",{children:Ue(e)})]})},e)}async function La(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ta=D();function Ha(e){let t=(0,Ta.c)(5),{openPrompt:n,closeModal:o}=fe(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=Ut.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ie.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Ie.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),fa(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const qa=()=>{let{updateCellConfig:e}=ge(),{saveCellConfig:t}=H();return(0,ye.useCallback)(async()=>{let n=new at,o=je(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ra=D();function $e(){let e=(0,Ra.c)(4),{openConfirm:t}=fe(),n=L(wt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(oa,{onClick:async()=>{n({state:gt.CLOSING}),await o(),da()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ba=D(),P=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Va(){var be,xe;let e=(0,Ba.c)(51),t=pa(),{openModal:n,closeModal:o}=fe(),{toggleApplication:s}=nt(),{selectedPanel:r}=mt(),[l]=Ze(ve),i=de(st),d=qa(),[m]=xt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ge(),b=$e(),x=ha(),j=Ha(t),v=L(Ye),N=L(kt),z=L(bt),{exportAsIPYNB:ee,exportAsMarkdown:te,readCode:I,saveCellConfig:ae,updateCellOutputs:M}=H(),W=ya(),oe=de(ot),ne=de(ct),{selectedLayout:q}=Se(),{setLayoutView:ie}=_e(),R=Oe(),B=((be=m.sharing)==null?void 0:be.html)??!0,V=((xe=m.sharing)==null?void 0:xe.wasm)??!0,ke=!he(),se=q==="slides",Ge=so,Je=io,F;e[0]!==t||e[1]!==W||e[2]!==M?(F=async c=>{let{preset:p,title:E}=c;if(!t){Q();return}await Ne(E,async re=>{await Ee({takeScreenshots:()=>W({progress:re}),updateCellOutputs:M}),await La({filename:t,preset:p,downloadPDF:Mt})})},e[0]=t,e[1]=W,e[2]=M,e[3]=F):F=e[3];let S=F,O;e[4]===S?O=e[5]:(O=async()=>{if(ke){await S({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(no,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=S,e[5]=O);let Y=O,K;e[6]!==ee||e[7]!==t||e[8]!==W||e[9]!==M?(K=async()=>{if(!t){Q();return}await Ne("Downloading IPYNB...",async c=>{await Ee({takeScreenshots:()=>W({progress:c}),updateCellOutputs:M});let p=await ee({download:!1});ue(new Blob([p],{type:"application/x-ipynb+json"}),me.toIPYNB(document.title))})},e[6]=ee,e[7]=t,e[8]=W,e[9]=M,e[10]=K):K=e[10];let le=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(De,{size:14,strokeWidth:1.5}),e[12]=$):$=e[12];let _;e[13]===t?_=e[14]:(_=async()=>{if(!t){Q();return}await Ae({filename:t,includeCode:!0})},e[13]=t,e[14]=_);let G;return e[15]!==f||e[16]!==ne||e[17]!==u||e[18]!==o||e[19]!==y||e[20]!==j||e[21]!==S||e[22]!==k||e[23]!==te||e[24]!==t||e[25]!==Y||e[26]!==le||e[27]!==oe||e[28]!==d||e[29]!==se||e[30]!==i||e[31]!==n||e[32]!==I||e[33]!==b||e[34]!==x||e[35]!==ae||e[36]!==q||e[37]!==r||e[38]!==v||e[39]!==z||e[40]!==ie||e[41]!==N||e[42]!==B||e[43]!==V||e[44]!==_||e[45]!==s||e[46]!==R||e[47]!==g||e[48]!==w||e[49]!==l.mode?(G=[{icon:U,label:"Download",handle:P,dropdown:[{icon:$,label:"Download as HTML",handle:_},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){Q();return}await Ae({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(ua,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await te({download:!1});ue(new Blob([c],{type:"text/plain"}),me.toMarkdown(document.title))}},{icon:(0,a.jsx)(va,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:le},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await I();ue(new Blob([c.contents],{type:"text/plain"}),me.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ma("global.hideCode",!1)]}),handle:oo},se?{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:P,dropdown:[{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:Y},{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Je(!0),hidden:!ke,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:Y}]},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Share",handle:P,hidden:!B&&!V,dropdown:[{icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(Wa,{onClose:o}))}},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!V,handle:async()=>{await X(ca({code:(await I()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:P,dropdown:ut.flatMap(c=>{let{type:p,Icon:E,hidden:re,additionalKeywords:Xe}=c;return re?[]:{label:Ce(p),rightElement:Ge(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:Xe}})},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Present as",handle:P,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{R()}},...Le.map((c,p)=>{let E=Ke(c);return{divider:p===0,label:Ue(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===c&&(0,a.jsx)(Pe,{size:14})}),handle:()=>{ie(c),l.mode==="edit"&&R()}}})]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||he(),handle:j},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await X((await I()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!oe||i,handle:async()=>{let c=lt(je());await ae({configs:Me.fromEntries(c.map(ao))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(ze,{onClose:o}))}},{icon:(0,a.jsx)(yt,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(ze,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ne||i,handle:()=>{g()}},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(rt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ba,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(He,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(to)},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(eo)},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>N(Qa),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Resources",handle:P,dropdown:[{icon:(0,a.jsx)(it,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Za},{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Xa},{icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ja},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ga},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Changelog",handle:$a}]},{divider:!0,icon:(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ua},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ka}].filter(Ya).map(Fa),e[15]=f,e[16]=ne,e[17]=u,e[18]=o,e[19]=y,e[20]=j,e[21]=S,e[22]=k,e[23]=te,e[24]=t,e[25]=Y,e[26]=le,e[27]=oe,e[28]=d,e[29]=se,e[30]=i,e[31]=n,e[32]=I,e[33]=b,e[34]=x,e[35]=ae,e[36]=q,e[37]=r,e[38]=v,e[39]=z,e[40]=ie,e[41]=N,e[42]=B,e[43]=V,e[44]=_,e[45]=s,e[46]=R,e[47]=g,e[48]=w,e[49]=l.mode,e[50]=G):G=e[50],G}function Fa(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Oa)}:e}function Oa(e){return!e.hidden}function Ya(e){return!e.hidden}function Ka(){let e=$t();window.open(e,"_blank")}function Ua(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function $a(){window.open(A.releasesPage,"_blank")}function Ga(){window.open(A.youtube,"_blank")}function Ja(){window.open(A.discordLink,"_blank")}function Xa(){window.open(A.githubPage,"_blank")}function Za(){window.open(A.docsPage,"_blank")}function Qa(e){return!e}function eo(e){return!e}function to(e){return!e}function ao(e){return[e,{disabled:!1}]}async function oo(){let e=document.getElementById("App");e&&await Wt({element:e,filename:document.title,prepare:St})}function no(){return window.print()}function io(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function so(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Pe,{size:14})})}function Q(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Oe as a,qe as c,Ye as i,He as l,$e as n,Ve as o,Na as r,Re as s,Va as t,Te as u};
|
|
1
|
+
import{s as we}from"./chunk-LvLJmgfZ.js";import{d as L,l as Ze,p as Qe,u as de}from"./useEvent-O0nX5vok.js";import{t as et}from"./react-Bj1aDYRI.js";import{E as ge,Sn as tt,Vt as at,_ as ot,_i as ce,_n as nt,dr as it,et as st,h as je,jr as lt,nt as ve,or as rt,rr as dt,t as ct,tr as ht,tt as pt,vn as mt,yn as ut}from"./cells-BZ2tqr8k.js";import{t as D}from"./compiler-runtime-B3qBwwSJ.js";import{n as ft}from"./assertNever-DWSyoPEi.js";import{s as Ce}from"./useLifecycle-DA9DjSPo.js";import{i as yt,n as ze}from"./add-connection-dialog-S-Hiw5Sn.js";import{n as kt,x as bt}from"./ai-model-dropdown-C_T_oAXa.js";import{c as Me,m as T}from"./useEventListener-Dy81QR4n.js";import{y as xt}from"./utils-tNbLd14P.js";import{n as A,t as We}from"./constants-Rz_lD4HK.js";import{S as he,h as wt,x as gt}from"./config-DRN1Q5Ol.js";import{t as jt}from"./jsx-runtime-icT_Ltz2.js";import{r as vt,t as pe}from"./button-Ej3vmCIF.js";import{r as H}from"./requests-Bgjtqo_1.js";import{t as h}from"./createLucideIcon-Cm-Z7dYr.js";import{a as Se,f as Ct,i as _e,m as zt,p as De,u as Ae}from"./layout-b4TrkjtJ.js";import{t as Pe}from"./check-DZA_bRpw.js";import{c as Ne,d as me,n as Mt,o as Wt,r as ue,t as St}from"./download-BX5RBVL8.js";import{n as _t}from"./maps-DQ4X82OB.js";import{r as Dt}from"./useCellActionButton-DBXavVBJ.js";import{t as At}from"./copy-CkudG0Ej.js";import{t as Pt}from"./download-DBW9RXtT.js";import{t as Nt}from"./eye-off-vwi9L975.js";import{t as It}from"./file-plus-corner-lLQw9OnR.js";import{t as J}from"./file-DzHkbIdO.js";import{t as Et}from"./github-BVtI-3F1.js";import{m as Lt}from"./form-DqfJycRl.js";import{n as Tt,r as Ht,t as qt}from"./youtube-DE-Ej6FR.js";import{n as Rt,t as Bt}from"./square-CxAsQQ77.js";import{t as Vt}from"./image-DXfkah9d.js";import{t as Ft}from"./link-Cf10mh3t.js";import{r as Ot}from"./input-6cciao_l.js";import{t as Yt}from"./settings-dVFT0AvU.js";import{y as Kt}from"./textarea-7F6-nuwz.js";import{t as C}from"./use-toast-BhMe50aT.js";import{n as Ie,t as Ut}from"./paths-bMgYkaP2.js";import{o as $t}from"./session-DKzpcHdK.js";import{a as Gt,c as Jt,i as Xt,n as Zt,r as Qt,s as ea,t as ta}from"./select-dNVaT2hT.js";import{t as aa}from"./tooltip-BCGmr4TU.js";import{o as oa}from"./alert-dialog-BfHy00ko.js";import{a as na,c as ia,i as sa,n as la,r as ra}from"./dialog-Dr3dl0Mn.js";import{n as fe}from"./ImperativeModal-DyRrGcKH.js";import{r as da,t as ca}from"./share-BKUsoia0.js";import{n as X}from"./copy-CIPmwSuj.js";import{r as ha}from"./useRunCells-CwObo_j4.js";import{a as pa}from"./cell-link-BgNPg6FR.js";import{a as ma}from"./renderShortcut-DKHsNYY8.js";import{t as ua}from"./icons-CIUvkMzI.js";import{t as fa}from"./links-BpU-Tgoi.js";import{r as ya,t as Ee}from"./hooks-DVW0qFsD.js";import{t as Le}from"./types-DQ8fCbJK.js";var ka=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ba=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Te=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),He=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),qe=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),xa=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),wa=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),ga=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Re=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ja=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),va=h("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Ca=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Be=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),za=h("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Ma=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Ve=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Fe=D(),ye=we(et(),1),a=we(jt(),1),Z="https://static.marimo.app";const Wa=e=>{let t=(0,Fe.c)(25),{onClose:n}=e,[o,s]=(0,ye.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Z}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let N=await r({download:!1,includeCode:!0,files:Ct.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Z}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:N,path:l})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:A.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ia,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(na,{children:[m,(0,a.jsxs)(ra,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:Z,target:"_blank",children:Z}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Ot,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Sa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(pe,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(pe,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await X(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(sa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(la,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var Sa=e=>{let t=(0,Fe.c)(8),[n,o]=ye.useState(!1),s;t[0]===e.text?s=t[1]:(s=vt.stopPropagation(async m=>{m.preventDefault(),await X(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(At,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(pe,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(aa,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},_a=D();function Da(){let e=document.getElementsByClassName(We.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=ce.findElement(t);if(!o){T.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ce.parse(o.id)}}}return T.warn("No visible output area found for scroll anchor"),null}function Aa(e){if(!e){T.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ce.create(e.cellId));if(!t){T.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${We.outputArea}`)){T.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Oe(){let e=(0,_a.c)(2),t=L(ve),n;return e[0]===t?n=e[1]:(n=()=>{let o=Da();t(s=>({mode:pt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Aa(o)})})},e[0]=t,e[1]=n),n}const Ye=Qe(!1);var Pa=D();const Na=()=>{let e=(0,Pa.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=_e();if(he()&&!tt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ea,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Jt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Zt,{children:(0,a.jsxs)(Qt,{children:[(0,a.jsx)(Gt,{children:"View as"}),Le.map(Ea)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(ta,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ia(e){return(0,a.jsx)(Ke(e),{className:"h-4 w-4"})}function Ke(e){switch(e){case"vertical":return ja;case"grid":return Ht;case"slides":return Be;default:return ft(e),Bt}}function Ue(e){return Ce(e)}function Ea(e){return(0,a.jsx)(Xt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ia(e),(0,a.jsx)("span",{children:Ue(e)})]})},e)}async function La(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ta=D();function Ha(e){let t=(0,Ta.c)(5),{openPrompt:n,closeModal:o}=fe(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=Ut.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ie.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Ie.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),fa(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const qa=()=>{let{updateCellConfig:e}=ge(),{saveCellConfig:t}=H();return(0,ye.useCallback)(async()=>{let n=new at,o=je(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Me.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ra=D();function $e(){let e=(0,Ra.c)(4),{openConfirm:t}=fe(),n=L(wt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(oa,{onClick:async()=>{n({state:gt.CLOSING}),await o(),da()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ba=D(),P=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Va(){var be,xe;let e=(0,Ba.c)(51),t=pa(),{openModal:n,closeModal:o}=fe(),{toggleApplication:s}=nt(),{selectedPanel:r}=mt(),[l]=Ze(ve),i=de(st),d=qa(),[m]=xt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ge(),b=$e(),x=ha(),j=Ha(t),v=L(Ye),N=L(kt),z=L(bt),{exportAsIPYNB:ee,exportAsMarkdown:te,readCode:I,saveCellConfig:ae,updateCellOutputs:M}=H(),W=ya(),oe=de(ot),ne=de(ct),{selectedLayout:q}=Se(),{setLayoutView:ie}=_e(),R=Oe(),B=((be=m.sharing)==null?void 0:be.html)??!0,V=((xe=m.sharing)==null?void 0:xe.wasm)??!0,ke=!he(),se=q==="slides",Ge=so,Je=io,F;e[0]!==t||e[1]!==W||e[2]!==M?(F=async c=>{let{preset:p,title:E}=c;if(!t){Q();return}await Ne(E,async re=>{await Ee({takeScreenshots:()=>W({progress:re}),updateCellOutputs:M}),await La({filename:t,preset:p,downloadPDF:Mt})})},e[0]=t,e[1]=W,e[2]=M,e[3]=F):F=e[3];let S=F,O;e[4]===S?O=e[5]:(O=async()=>{if(ke){await S({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(no,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=S,e[5]=O);let Y=O,K;e[6]!==ee||e[7]!==t||e[8]!==W||e[9]!==M?(K=async()=>{if(!t){Q();return}await Ne("Downloading IPYNB...",async c=>{await Ee({takeScreenshots:()=>W({progress:c}),updateCellOutputs:M});let p=await ee({download:!1});ue(new Blob([p],{type:"application/x-ipynb+json"}),me.toIPYNB(document.title))})},e[6]=ee,e[7]=t,e[8]=W,e[9]=M,e[10]=K):K=e[10];let le=K,U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),e[11]=U):U=e[11];let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(De,{size:14,strokeWidth:1.5}),e[12]=$):$=e[12];let _;e[13]===t?_=e[14]:(_=async()=>{if(!t){Q();return}await Ae({filename:t,includeCode:!0})},e[13]=t,e[14]=_);let G;return e[15]!==f||e[16]!==ne||e[17]!==u||e[18]!==o||e[19]!==y||e[20]!==j||e[21]!==S||e[22]!==k||e[23]!==te||e[24]!==t||e[25]!==Y||e[26]!==le||e[27]!==oe||e[28]!==d||e[29]!==se||e[30]!==i||e[31]!==n||e[32]!==I||e[33]!==b||e[34]!==x||e[35]!==ae||e[36]!==q||e[37]!==r||e[38]!==v||e[39]!==z||e[40]!==ie||e[41]!==N||e[42]!==B||e[43]!==V||e[44]!==_||e[45]!==s||e[46]!==R||e[47]!==g||e[48]!==w||e[49]!==l.mode?(G=[{icon:U,label:"Download",handle:P,dropdown:[{icon:$,label:"Download as HTML",handle:_},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){Q();return}await Ae({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(ua,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await te({download:!1});ue(new Blob([c],{type:"text/plain"}),me.toMarkdown(document.title))}},{icon:(0,a.jsx)(va,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:le},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await I();ue(new Blob([c.contents],{type:"text/plain"}),me.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ma("global.hideCode",!1)]}),handle:oo},se?{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:P,dropdown:[{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:Y},{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Je(!0),hidden:!ke,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:Y}]},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Share",handle:P,hidden:!B&&!V,dropdown:[{icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(Wa,{onClose:o}))}},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!V,handle:async()=>{await X(ca({code:(await I()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:P,dropdown:ut.flatMap(c=>{let{type:p,Icon:E,hidden:re,additionalKeywords:Xe}=c;return re?[]:{label:Ce(p),rightElement:Ge(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:Xe}})},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Present as",handle:P,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{R()}},...Le.map((c,p)=>{let E=Ke(c);return{divider:p===0,label:Ue(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===c&&(0,a.jsx)(Pe,{size:14})}),handle:()=>{ie(c),l.mode==="edit"&&R()}}})]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||he(),handle:j},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await X((await I()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!oe||i,handle:async()=>{let c=lt(je());await ae({configs:Me.fromEntries(c.map(ao))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(ze,{onClose:o}))}},{icon:(0,a.jsx)(yt,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(ze,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ne||i,handle:()=>{g()}},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(rt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ba,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(He,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(to)},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(eo)},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>N(Qa),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Resources",handle:P,dropdown:[{icon:(0,a.jsx)(it,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Za},{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Xa},{icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ja},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ga},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Changelog",handle:$a}]},{divider:!0,icon:(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ua},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ka}].filter(Ya).map(Fa),e[15]=f,e[16]=ne,e[17]=u,e[18]=o,e[19]=y,e[20]=j,e[21]=S,e[22]=k,e[23]=te,e[24]=t,e[25]=Y,e[26]=le,e[27]=oe,e[28]=d,e[29]=se,e[30]=i,e[31]=n,e[32]=I,e[33]=b,e[34]=x,e[35]=ae,e[36]=q,e[37]=r,e[38]=v,e[39]=z,e[40]=ie,e[41]=N,e[42]=B,e[43]=V,e[44]=_,e[45]=s,e[46]=R,e[47]=g,e[48]=w,e[49]=l.mode,e[50]=G):G=e[50],G}function Fa(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Oa)}:e}function Oa(e){return!e.hidden}function Ya(e){return!e.hidden}function Ka(){let e=$t();window.open(e,"_blank")}function Ua(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function $a(){window.open(A.releasesPage,"_blank")}function Ga(){window.open(A.youtube,"_blank")}function Ja(){window.open(A.discordLink,"_blank")}function Xa(){window.open(A.githubPage,"_blank")}function Za(){window.open(A.docsPage,"_blank")}function Qa(e){return!e}function eo(e){return!e}function to(e){return!e}function ao(e){return[e,{disabled:!1}]}async function oo(){let e=document.getElementById("App");e&&await Wt({element:e,filename:document.title,prepare:St})}function no(){return window.print()}function io(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function so(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Pe,{size:14})})}function Q(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Oe as a,qe as c,Ye as i,He as l,$e as n,Ve as o,Na as r,Re as s,Va as t,Te as u};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-BUi88mQ-.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-TXkS1QI3.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
|
@@ -197,14 +197,14 @@
|
|
|
197
197
|
<link rel="modulepreload" crossorigin href="./assets/capitalize-BfkXNxmI.js">
|
|
198
198
|
<link rel="modulepreload" crossorigin href="./assets/table-Od8PbuV-.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="./assets/message-circle-BaZF1NX9.js">
|
|
200
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
200
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-C6G83us5.js">
|
|
201
201
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-a9XtWmzk.js">
|
|
202
202
|
<link rel="modulepreload" crossorigin href="./assets/square-function-B-8YRDsr.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/spec-DbOXZaHd.js">
|
|
204
204
|
<link rel="modulepreload" crossorigin href="./assets/ellipsis-vertical-CAB7tdza.js">
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-Dd8FlTmm.js">
|
|
206
206
|
<link rel="modulepreload" crossorigin href="./assets/components-4-hSIFip.js">
|
|
207
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
207
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-Bxza9N1V.js">
|
|
208
208
|
<link rel="modulepreload" crossorigin href="./assets/icons-CIUvkMzI.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/switch-SqaUg_Rv.js">
|
|
210
210
|
<link rel="modulepreload" crossorigin href="./assets/toggle-iY_IwLg6.js">
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
<link rel="modulepreload" crossorigin href="./assets/get-DBdMgUNq.js">
|
|
217
217
|
<link rel="modulepreload" crossorigin href="./assets/_baseSet-D5BgdrnX.js">
|
|
218
218
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-CHZt2sgR.js">
|
|
219
|
-
<link rel="modulepreload" crossorigin href="./assets/context-aware-panel-
|
|
219
|
+
<link rel="modulepreload" crossorigin href="./assets/context-aware-panel-BAsDUfG1.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-DlCEpJuo.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="./assets/useAddCell-Dluq9z9F.js">
|
|
222
222
|
<link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-D67umz3-.js">
|
package/package.json
CHANGED
|
@@ -222,6 +222,75 @@ describe("generateColumns", () => {
|
|
|
222
222
|
expect(columns[1].meta?.dataType).toBe("number");
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
+
it("should auto right-align numeric columns", () => {
|
|
226
|
+
const columns = generateColumns({
|
|
227
|
+
rowHeaders: [],
|
|
228
|
+
selection: null,
|
|
229
|
+
fieldTypes,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// "age" is a number column — should auto right-align
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
const cell = (columns[1].cell as any)({
|
|
235
|
+
column: {
|
|
236
|
+
columnDef: columns[1],
|
|
237
|
+
},
|
|
238
|
+
renderValue: () => 25,
|
|
239
|
+
getValue: () => 25,
|
|
240
|
+
});
|
|
241
|
+
expect(cell?.props.className).toContain("text-right");
|
|
242
|
+
|
|
243
|
+
// "name" is a string column — should remain left-aligned
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
245
|
+
const nameCell = (columns[0].cell as any)({
|
|
246
|
+
column: {
|
|
247
|
+
columnDef: columns[0],
|
|
248
|
+
},
|
|
249
|
+
renderValue: () => "John",
|
|
250
|
+
getValue: () => "John",
|
|
251
|
+
});
|
|
252
|
+
expect(nameCell?.props.className).not.toContain("text-right");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("should respect explicit textJustifyColumns over auto alignment", () => {
|
|
256
|
+
const columns = generateColumns({
|
|
257
|
+
rowHeaders: [],
|
|
258
|
+
selection: null,
|
|
259
|
+
fieldTypes,
|
|
260
|
+
textJustifyColumns: { age: "left" },
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// "age" is numeric but explicitly set to left
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
const cell = (columns[1].cell as any)({
|
|
266
|
+
column: {
|
|
267
|
+
columnDef: columns[1],
|
|
268
|
+
},
|
|
269
|
+
renderValue: () => 25,
|
|
270
|
+
getValue: () => 25,
|
|
271
|
+
});
|
|
272
|
+
expect(cell?.props.className).not.toContain("text-right");
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("should set minFractionDigits from fractionDigitsByColumn", () => {
|
|
276
|
+
const numericFieldTypes: FieldTypesWithExternalType = [
|
|
277
|
+
["price", ["number", "float64"]],
|
|
278
|
+
["count", ["integer", "int64"]],
|
|
279
|
+
];
|
|
280
|
+
|
|
281
|
+
const columns = generateColumns({
|
|
282
|
+
rowHeaders: [],
|
|
283
|
+
selection: null,
|
|
284
|
+
fieldTypes: numericFieldTypes,
|
|
285
|
+
fractionDigitsByColumn: { price: 2 },
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// price has 2 fraction digits
|
|
289
|
+
expect(columns[0].meta?.minFractionDigits).toBe(2);
|
|
290
|
+
// count not in fractionDigitsByColumn
|
|
291
|
+
expect(columns[1].meta?.minFractionDigits).toBeUndefined();
|
|
292
|
+
});
|
|
293
|
+
|
|
225
294
|
it("should handle text justification and wrapping", () => {
|
|
226
295
|
const columns = generateColumns({
|
|
227
296
|
rowHeaders: [],
|
|
@@ -572,6 +641,75 @@ describe("LocaleNumber", () => {
|
|
|
572
641
|
);
|
|
573
642
|
expect(container.textContent).toMatchInlineSnapshot(`"10,000,000,000"`);
|
|
574
643
|
});
|
|
644
|
+
|
|
645
|
+
it("should pad decimals with minFractionDigits", () => {
|
|
646
|
+
const { container } = render(
|
|
647
|
+
<I18nProvider locale="en-US">
|
|
648
|
+
<LocaleNumber value={42} minFractionDigits={2} />
|
|
649
|
+
</I18nProvider>,
|
|
650
|
+
);
|
|
651
|
+
expect(container.textContent).toMatchInlineSnapshot(`"42.00"`);
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
it("should pad to minFractionDigits for numbers with fewer decimals", () => {
|
|
655
|
+
const { container } = render(
|
|
656
|
+
<I18nProvider locale="en-US">
|
|
657
|
+
<LocaleNumber value={1234.5} minFractionDigits={3} />
|
|
658
|
+
</I18nProvider>,
|
|
659
|
+
);
|
|
660
|
+
expect(container.textContent).toMatchInlineSnapshot(`"1,234.500"`);
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
it("should not truncate decimals beyond minFractionDigits", () => {
|
|
664
|
+
const { container } = render(
|
|
665
|
+
<I18nProvider locale="en-US">
|
|
666
|
+
<LocaleNumber value={1.234_56} minFractionDigits={2} />
|
|
667
|
+
</I18nProvider>,
|
|
668
|
+
);
|
|
669
|
+
expect(container.textContent).toMatchInlineSnapshot(`"1.23456"`);
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
describe("renderCellValue with boolean values", () => {
|
|
674
|
+
const createMockColumn = () =>
|
|
675
|
+
({
|
|
676
|
+
id: "active",
|
|
677
|
+
columnDef: {
|
|
678
|
+
meta: {
|
|
679
|
+
dataType: "boolean" as const,
|
|
680
|
+
dtype: "bool",
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
getColumnFormatting: () => undefined,
|
|
684
|
+
getColumnWrapping: () => undefined,
|
|
685
|
+
applyColumnFormatting: (value: unknown) => value,
|
|
686
|
+
}) as unknown as Column<unknown>;
|
|
687
|
+
|
|
688
|
+
it("should render true as True", () => {
|
|
689
|
+
const mockColumn = createMockColumn();
|
|
690
|
+
const result = renderCellValue({
|
|
691
|
+
column: mockColumn,
|
|
692
|
+
renderValue: () => true,
|
|
693
|
+
getValue: () => true,
|
|
694
|
+
selectCell: undefined,
|
|
695
|
+
cellStyles: "",
|
|
696
|
+
});
|
|
697
|
+
const { container } = render(result);
|
|
698
|
+
expect(container.textContent).toBe("True");
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
it("should render false as False", () => {
|
|
702
|
+
const mockColumn = createMockColumn();
|
|
703
|
+
const result = renderCellValue({
|
|
704
|
+
column: mockColumn,
|
|
705
|
+
renderValue: () => false,
|
|
706
|
+
getValue: () => false,
|
|
707
|
+
selectCell: undefined,
|
|
708
|
+
cellStyles: "",
|
|
709
|
+
});
|
|
710
|
+
const { container } = render(result);
|
|
711
|
+
expect(container.textContent).toBe("False");
|
|
712
|
+
});
|
|
575
713
|
});
|
|
576
714
|
|
|
577
715
|
describe("renderCellValue with datetime values", () => {
|
|
@@ -112,6 +112,7 @@ export function generateColumns<T>({
|
|
|
112
112
|
headerTooltip,
|
|
113
113
|
showDataTypes,
|
|
114
114
|
calculateTopKRows,
|
|
115
|
+
fractionDigitsByColumn,
|
|
115
116
|
}: {
|
|
116
117
|
rowHeaders: FieldTypesWithExternalType;
|
|
117
118
|
selection: DataTableSelection;
|
|
@@ -122,6 +123,7 @@ export function generateColumns<T>({
|
|
|
122
123
|
headerTooltip?: Record<string, string>;
|
|
123
124
|
showDataTypes?: boolean;
|
|
124
125
|
calculateTopKRows?: CalculateTopKRows;
|
|
126
|
+
fractionDigitsByColumn?: Record<string, number>;
|
|
125
127
|
}): ColumnDef<T>[] {
|
|
126
128
|
// Row-headers are typically index columns
|
|
127
129
|
const rowHeadersSet = new Set(rowHeaders.map(([columnName]) => columnName));
|
|
@@ -138,6 +140,7 @@ export function generateColumns<T>({
|
|
|
138
140
|
rowHeader: isRowHeader,
|
|
139
141
|
dtype: types?.[1],
|
|
140
142
|
dataType: types?.[0],
|
|
143
|
+
minFractionDigits: fractionDigitsByColumn?.[key],
|
|
141
144
|
};
|
|
142
145
|
}
|
|
143
146
|
|
|
@@ -146,9 +149,23 @@ export function generateColumns<T>({
|
|
|
146
149
|
filterType: getFilterTypeForFieldType(types[0]),
|
|
147
150
|
dtype: types[1],
|
|
148
151
|
dataType: types[0],
|
|
152
|
+
minFractionDigits: fractionDigitsByColumn?.[key],
|
|
149
153
|
};
|
|
150
154
|
};
|
|
151
155
|
|
|
156
|
+
const getJustify = (key: string): "left" | "center" | "right" | undefined => {
|
|
157
|
+
// Explicit user override takes precedence
|
|
158
|
+
if (textJustifyColumns?.[key]) {
|
|
159
|
+
return textJustifyColumns[key];
|
|
160
|
+
}
|
|
161
|
+
// Auto right-align numeric columns
|
|
162
|
+
const dataType = getMeta(key).dataType;
|
|
163
|
+
if (dataType === "number" || dataType === "integer") {
|
|
164
|
+
return "right";
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
};
|
|
168
|
+
|
|
152
169
|
const columnKeys: string[] = [
|
|
153
170
|
...rowHeadersSet,
|
|
154
171
|
...fieldTypes.map(([columnName]) => columnName),
|
|
@@ -186,7 +203,7 @@ export function generateColumns<T>({
|
|
|
186
203
|
</div>
|
|
187
204
|
) : null;
|
|
188
205
|
|
|
189
|
-
const justify =
|
|
206
|
+
const justify = getJustify(key);
|
|
190
207
|
|
|
191
208
|
const headerWithType = (
|
|
192
209
|
<div
|
|
@@ -254,18 +271,21 @@ export function generateColumns<T>({
|
|
|
254
271
|
cell.toggleSelected?.();
|
|
255
272
|
}
|
|
256
273
|
|
|
257
|
-
const justify =
|
|
274
|
+
const justify = getJustify(key);
|
|
258
275
|
const wrapped = wrappedColumns?.includes(key);
|
|
259
276
|
const isCellSelected = cell?.getIsSelected?.() || false;
|
|
260
277
|
const canSelectCell =
|
|
261
278
|
(selection === "single-cell" || selection === "multi-cell") &&
|
|
262
279
|
!isCellSelected;
|
|
263
280
|
|
|
281
|
+
const dataType = column.columnDef.meta?.dataType;
|
|
282
|
+
const isNumeric = dataType === "number" || dataType === "integer";
|
|
264
283
|
const cellStyles = getCellStyleClass(
|
|
265
284
|
justify,
|
|
266
285
|
wrapped,
|
|
267
286
|
canSelectCell,
|
|
268
287
|
isCellSelected,
|
|
288
|
+
isNumeric,
|
|
269
289
|
);
|
|
270
290
|
|
|
271
291
|
const renderedCell = renderCellValue({
|
|
@@ -430,6 +450,7 @@ function getCellStyleClass(
|
|
|
430
450
|
wrapped: boolean | undefined,
|
|
431
451
|
canSelectCell: boolean,
|
|
432
452
|
isSelected: boolean,
|
|
453
|
+
isNumeric?: boolean,
|
|
433
454
|
): string {
|
|
434
455
|
return cn(
|
|
435
456
|
canSelectCell && "cursor-pointer",
|
|
@@ -438,6 +459,7 @@ function getCellStyleClass(
|
|
|
438
459
|
"w-full",
|
|
439
460
|
"text-left",
|
|
440
461
|
"truncate",
|
|
462
|
+
isNumeric && "tabular-nums",
|
|
441
463
|
justify === "center" && "text-center",
|
|
442
464
|
justify === "right" && "text-right",
|
|
443
465
|
wrapped && `${COLUMN_WRAPPING_STYLES} break-words`,
|
|
@@ -589,7 +611,18 @@ export function renderCellValue<TData, TValue>({
|
|
|
589
611
|
if (typeof value === "number") {
|
|
590
612
|
return (
|
|
591
613
|
<div onClick={selectCell} className={cellStyles}>
|
|
592
|
-
<LocaleNumber
|
|
614
|
+
<LocaleNumber
|
|
615
|
+
value={value}
|
|
616
|
+
minFractionDigits={column.columnDef.meta?.minFractionDigits}
|
|
617
|
+
/>
|
|
618
|
+
</div>
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (typeof value === "boolean") {
|
|
623
|
+
return (
|
|
624
|
+
<div onClick={selectCell} className={cellStyles}>
|
|
625
|
+
{value ? "True" : "False"}
|
|
593
626
|
</div>
|
|
594
627
|
);
|
|
595
628
|
}
|
|
@@ -635,9 +668,16 @@ export function renderCellValue<TData, TValue>({
|
|
|
635
668
|
);
|
|
636
669
|
}
|
|
637
670
|
|
|
638
|
-
export const LocaleNumber = ({
|
|
671
|
+
export const LocaleNumber = ({
|
|
672
|
+
value,
|
|
673
|
+
minFractionDigits,
|
|
674
|
+
}: {
|
|
675
|
+
value: number;
|
|
676
|
+
minFractionDigits?: number;
|
|
677
|
+
}) => {
|
|
639
678
|
const { locale } = useLocale();
|
|
640
679
|
const format = useNumberFormatter({
|
|
680
|
+
minimumFractionDigits: minFractionDigits,
|
|
641
681
|
maximumFractionDigits: maxFractionalDigits(locale),
|
|
642
682
|
});
|
|
643
683
|
return format.format(value);
|
|
@@ -874,10 +874,35 @@ const DataTableComponent = ({
|
|
|
874
874
|
return memoizedUnclampedFieldTypes.slice(0, maxColumns);
|
|
875
875
|
}, [maxColumns, memoizedUnclampedFieldTypes]);
|
|
876
876
|
|
|
877
|
+
// Compute max fractional digits per numeric column for consistent formatting.
|
|
878
|
+
const computedFractionDigits = useMemo(() => {
|
|
879
|
+
const result: Record<string, number> = {};
|
|
880
|
+
if (data && data.length > 0) {
|
|
881
|
+
for (const [colName, types] of memoizedClampedFieldTypes) {
|
|
882
|
+
if (types[0] === "number") {
|
|
883
|
+
let maxDecimals = 0;
|
|
884
|
+
for (const row of data) {
|
|
885
|
+
const val = (row as Record<string, unknown>)[colName];
|
|
886
|
+
if (typeof val === "number" && Number.isFinite(val)) {
|
|
887
|
+
const str = String(val);
|
|
888
|
+
const dotIdx = str.indexOf(".");
|
|
889
|
+
if (dotIdx !== -1) {
|
|
890
|
+
maxDecimals = Math.max(maxDecimals, str.length - dotIdx - 1);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
result[colName] = maxDecimals;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return result;
|
|
899
|
+
}, [data, memoizedClampedFieldTypes]);
|
|
900
|
+
|
|
877
901
|
const memoizedRowHeaders = useDeepCompareMemoize(rowHeaders);
|
|
878
902
|
const memoizedTextJustifyColumns = useDeepCompareMemoize(textJustifyColumns);
|
|
879
903
|
const memoizedWrappedColumns = useDeepCompareMemoize(wrappedColumns);
|
|
880
904
|
const memoizedChartSpecModel = useDeepCompareMemoize(chartSpecModel);
|
|
905
|
+
const fractionDigitsByColumn = useDeepCompareMemoize(computedFractionDigits);
|
|
881
906
|
const shownColumns = memoizedClampedFieldTypes.length;
|
|
882
907
|
|
|
883
908
|
// If the field types are not set, we don't show them
|
|
@@ -898,6 +923,7 @@ const DataTableComponent = ({
|
|
|
898
923
|
// Only show data types if they are explicitly set
|
|
899
924
|
showDataTypes: showDataTypes,
|
|
900
925
|
calculateTopKRows: calculate_top_k_rows,
|
|
926
|
+
fractionDigitsByColumn: fractionDigitsByColumn,
|
|
901
927
|
}),
|
|
902
928
|
[
|
|
903
929
|
selection,
|
|
@@ -909,6 +935,7 @@ const DataTableComponent = ({
|
|
|
909
935
|
memoizedWrappedColumns,
|
|
910
936
|
headerTooltip,
|
|
911
937
|
calculate_top_k_rows,
|
|
938
|
+
fractionDigitsByColumn,
|
|
912
939
|
],
|
|
913
940
|
);
|
|
914
941
|
|