@marimo-team/frontend 0.24.1-dev95 → 0.24.1-dev96
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/{index-B6Nvcqin.js → index-BTUbA8tU.js} +2 -2
- package/dist/assets/vega-component-BSXJcTJb.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/plugins/impl/vega/__tests__/__snapshots__/make-selectable.test.ts.snap +185 -185
- package/src/plugins/impl/vega/__tests__/make-selectable.test.ts +78 -2
- package/src/plugins/impl/vega/params.ts +26 -10
- package/src/plugins/impl/vega/vega-component.tsx +7 -2
- package/dist/assets/vega-component-Bel2PDO-.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./useEvent-xfs0Sn4r.js";import{t as n}from"./react-CBDbhulC.js";import{t as r}from"./compiler-runtime-CYIjoINj.js";import{t as i}from"./debounce-aFmHgJZY.js";import{f as a,g as o}from"./useEventListener-D27Dii_l.js";import{t as s}from"./objects-snlMn4yk.js";import{n as c}from"./config-D4frVGQ4.js";import{t as l}from"./cn-ldLVeaqm.js";import{t as u}from"./jsx-runtime-B74pBk57.js";import{t as d}from"./tooltip-D7dq6bnc.js";import{r as f}from"./button-Btj6GXNy.js";import{u as p}from"./arrays-BqUx5USx.js";import{u as ee}from"./toDate-hGYJX0Ha.js";import{r as te}from"./useTheme-CF-zG9YH.js";import{n as ne}from"./useAsyncData-Buhk-UgR.js";import{t as m}from"./isValid-nQ3Iam8J.js";import{r as re,t as ie}from"./tooltip-Cwltdez8.js";import{n as h}from"./vega-loader.browser-AQmjV9CX.js";import{t as ae}from"./react-vega-C3-Qk46W.js";import{r as oe,t as se}from"./alert-dmKwNsrp.js";import{n as ce}from"./error-banner-BYN8YUMe.js";import{t as le}from"./utils-49LGK4zG.js";import{t as g}from"./formats-DSzGCKeO.js";import{t as ue}from"./useDeepCompareMemoize-CLytDdMl.js";import{t as de}from"./semaphore-BjoL5P0h.js";import{t as fe}from"./use-vega-container-remeasure-xx9nX6Kv.js";var pe=e(n(),1),me=r();function he(e){return e.data&&`url`in e.data&&(e.data.url=c(e.data.url).href),e}var _={arc:`arc`,area:`area`,bar:`bar`,image:`image`,line:`line`,point:`point`,rect:`rect`,rule:`rule`,text:`text`,tick:`tick`,trail:`trail`,circle:`circle`,square:`square`,geoshape:`geoshape`},v=new Set([`boxplot`,`errorband`,`errorbar`]),y={getMarkType(e){let t=typeof e==`string`?e:e.type;if(v.has(t))throw Error(`Not supported`);return t},isInteractive(e){let t=typeof e==`string`?e:e.type;return!v.has(t)},makeClickable(e){let t=typeof e==`string`?e:e.type;return t in _?typeof e==`string`?{type:e,cursor:`pointer`,tooltip:!0}:{...e,type:t,cursor:`pointer`,tooltip:!0}:e},getOpacity(e){return typeof e==`string`?null:`opacity`in e&&typeof e.opacity==`number`?e.opacity:null}},b={point(e){return e==null?`select_point`:`select_point_${e}`},interval(e){return e==null?`select_interval`:`select_interval_${e}`},legendSelection(e){return`legend_selection_${e}`},binColoring(e){return e==null?`bin_coloring`:`bin_coloring_${e}`},HIGHLIGHT:`highlight`,PAN_ZOOM:`pan_zoom`,hasPoint(e){return e.some(e=>e.startsWith(`select_point`))},hasInterval(e){return e.some(e=>e.startsWith(`select_interval`))},hasLegend(e){return e.some(e=>e.startsWith(`legend_selection`))},hasPanZoom(e){return e.some(e=>e.startsWith(`pan_zoom`))},isBinColoring(e){return e.startsWith(`bin_coloring`)}};function x(){return a()?`metaKey`:`ctrlKey`}var S={highlight(){return{name:b.HIGHLIGHT,select:{type:`point`,on:`mouseover`}}},interval(e,t){let n=x();return{name:b.interval(t),select:{type:`interval`,encodings:C(e),mark:{fill:`#669EFF`,fillOpacity:.07,stroke:`#669EFF`,strokeOpacity:.4},on:`[mousedown[!event.${n}], mouseup] > mousemove[!event.${n}]`,translate:`[mousedown[!event.${n}], mouseup] > mousemove[!event.${n}]`}}},point(e,t){return{name:b.point(t),select:{type:`point`,encodings:C(e),on:`click[!event.${x()}]`}}},binColoring(e){return{name:b.binColoring(e),select:{type:`point`,on:`click[!event.${x()}]`}}},legend(e){return{name:b.legendSelection(e),select:{type:`point`,fields:[e]},bind:`legend`}},panZoom(){let e=x();return{name:b.PAN_ZOOM,bind:`scales`,select:{type:`interval`,on:`[mousedown[event.${e}], window:mouseup] > window:mousemove!`,translate:`[mousedown[event.${e}], window:mouseup] > window:mousemove!`,zoom:`wheel![event.${e}]`}}}};function C(e){switch(y.getMarkType(e.mark)){case _.image:case _.trail:return;case _.area:case _.arc:return[`color`];case _.bar:{let t=T(e);return t===`horizontal`?[`y`]:t===`vertical`?[`x`]:void 0}case _.circle:case _.geoshape:case _.line:case _.point:case _.rect:case _.rule:case _.square:case _.text:case _.tick:return[`x`,`y`]}}function w(e){if(`params`in e&&e.params&&e.params.length>0){let t=e.params.filter(e=>e!=null&&`select`in e&&e.select!==void 0).map(e=>e.name);return p(t)}return`layer`in e?p(e.layer.flatMap(w)):`vconcat`in e?p(e.vconcat.flatMap(w)):`hconcat`in e?p(e.hconcat.flatMap(w)):[]}function T(e){if(!e||!(`mark`in e))return;let t=e.encoding?.x,n=e.encoding?.y;if(t&&`type`in t&&t.type===`nominal`)return`vertical`;if(n&&`type`in n&&n.type===`nominal`||t&&`aggregate`in t)return`horizontal`;if(n&&`aggregate`in n)return`vertical`}function E(e){if(!e.encoding)return[];let t=[];for(let n of Object.values(e.encoding))n&&typeof n==`object`&&`bin`in n&&n.bin&&`field`in n&&typeof n.field==`string`&&t.push(n.field);return t}function D(e){if(!e||!(`encoding`in e))return[];let{encoding:t}=e;return t?Object.entries(t).flatMap(e=>{let[t,n]=e;return!n||!O.has(t)?[]:`field`in n&&typeof n.field==`string`?[n.field]:`condition`in n&&n.condition&&typeof n.condition==`object`&&`field`in n.condition&&n.condition.field&&typeof n.condition.field==`string`?[n.condition.field]:[]}):[]}var O=new Set([`color`,`fill`,`fillOpacity`,`opacity`,`shape`,`size`]);function k(e,t,n,r){let i=n.filter(e=>b.isBinColoring(e)),a={and:(i.length>0?i:n).map(e=>({param:e}))};switch(e){case`opacity`:{let e=y.getOpacity(r)||1;return{...t,opacity:{condition:{test:a,value:e},value:e/5}}}default:return t}}function A(e){if(!(`select`in e)||!e.select)return JSON.stringify(e);let t=e.select;if(typeof t==`string`)return JSON.stringify({type:t,bind:e.bind});let n={type:t.type,encodings:`encodings`in t&&t.encodings?[...t.encodings].toSorted():void 0,fields:`fields`in t&&t.fields?[...t.fields].toSorted():void 0,bind:e.bind};return JSON.stringify(n)}function j(e){let t=M(e);if(t.length===0)return e;let n=N(t);return n.length===0?e:{...F(P(e,new Set(n.map(e=>e.name))),n.map(e=>e.name)),params:[...e.params||[],...n]}}function M(e){let t=[];if(`vconcat`in e&&Array.isArray(e.vconcat))for(let n of e.vconcat)t.push(...M(n));else if(`hconcat`in e&&Array.isArray(e.hconcat))for(let n of e.hconcat)t.push(...M(n));else if(`layer`in e)return[];else`mark`in e&&`params`in e&&e.params&&e.params.length>0&&t.push({params:e.params});return t}function N(e){if(e.length===0)return[];let t=new Map,n=e.length;for(let{params:n}of e){let e=new Set;for(let r of n){let n=A(r);e.has(n)||(e.add(n),t.has(n)||t.set(n,{count:0,param:r}),t.get(n).count++)}}let r=[];for(let[,{count:e,param:i}]of t)e===n&&r.push(i);return r}function P(e,t){if(`vconcat`in e&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>P(e,t))};if(`hconcat`in e&&Array.isArray(e.hconcat))return{...e,hconcat:e.hconcat.map(e=>P(e,t))};if(`mark`in e&&`params`in e&&e.params){let n=e.params,r=[];for(let e of n){if(!e||typeof e!=`object`||!(`name`in e)){r.push(e);continue}t.has(e.name)||r.push(e)}if(r.length===0){let{params:t,...n}=e;return n}return{...e,params:r}}return e}function F(e,t){return`vconcat`in e&&Array.isArray(e.vconcat)?{...e,vconcat:e.vconcat.map(e=>F(e,t))}:`hconcat`in e&&Array.isArray(e.hconcat)?{...e,hconcat:e.hconcat.map(e=>F(e,t))}:`layer`in e?e:`mark`in e&&y.isInteractive(e.mark)?{...e,mark:y.makeClickable(e.mark),encoding:k(`opacity`,e.encoding||{},t,e.mark)}:e}function ge(e,t){let{chartSelection:n=!0,fieldSelection:r=!0}=t;if(!n&&!r)return e;e.params?.some(e=>e.bind===`legend`)&&(r=!1);let i=e.params?.some(e=>!e.bind);i&&(n=!1);let a=`vconcat`in e||`hconcat`in e;if(i&&a)return e;if(`vconcat`in e){let t=e.vconcat.map(e=>`mark`in e?ge(e,{chartSelection:n,fieldSelection:r}):e);return j({...e,vconcat:t})}if(`hconcat`in e){let t=e.hconcat.map(e=>`mark`in e?ge(e,{chartSelection:n,fieldSelection:r}):e);return j({...e,hconcat:t})}if(`layer`in e){let t=e.params&&e.params.length>0,i=r!==!1&&!t,a=[];if(i){let t=e.layer.flatMap(e=>`mark`in e?D(e):[]);a=[...new Set(t)],Array.isArray(r)&&(a=a.filter(e=>r.includes(e)))}let o=e.layer.map((e,t)=>{if(!(`mark`in e))return e;let r=e;if(t===0&&a.length>0){let e=a.map(e=>S.legend(e));r={...r,params:[...r.params||[],...e]}}return r=L(r,n,t),r=z(r),t===0&&(r=R(r)),r});return{...e,layer:o}}if(!(`mark`in e)||!y.isInteractive(e.mark))return e;let o=e;return o=I(o,r),o=L(o,n,void 0),o=z(o),o=R(o),o}function I(e,t){if(t===!1)return e;let n=D(e);Array.isArray(t)&&(n=n.filter(e=>t.includes(e)));let r=n.map(e=>S.legend(e)),i=[...e.params||[],...r];return{...e,params:i}}function L(e,t,n){if(t===!1)return e;let r;try{r=y.getMarkType(e.mark)}catch{return e}if(r===`geoshape`)return e;let i=E(e),a=t===!0?i.length>0?[`point`]:B(r):[t];if(!a||a.length===0)return e;let o=a.map(t=>t===`interval`?S.interval(e,n):S.point(e,n)),s=[...e.params||[],...o];return i.length>0&&a.includes(`point`)&&s.push(S.binColoring(n)),{...e,params:s}}function R(e){let t;try{t=y.getMarkType(e.mark)}catch{}if(t===`geoshape`)return e;let n=e.params||[];return n.some(e=>e.bind===`scales`)?e:{...e,params:[...n,S.panZoom()]}}function z(e){let t=`encoding`in e?e.encoding:void 0,n=e.params||[],r=n.map(e=>e.name);return n.length===0||!y.isInteractive(e.mark)?e:{...e,mark:y.makeClickable(e.mark),encoding:k(`opacity`,t||{},r,e.mark)}}function B(e){switch(e){case`arc`:case`area`:return[`point`];case`text`:case`bar`:return[`point`,`interval`];case`line`:return;default:return[`point`,`interval`]}}var V=5;async function H(e){if(!e)return e;let t=`datasets`in e?{...e.datasets}:{},n=new de(V),r=async e=>{if(!e)return e;if(`layer`in e){let t=await Promise.all(e.layer.map(r));e={...e,layer:t}}if(`hconcat`in e){let t=await Promise.all(e.hconcat.map(r));e={...e,hconcat:t}}if(`vconcat`in e){let t=await Promise.all(e.vconcat.map(r));e={...e,vconcat:t}}if(`spec`in e&&(e={...e,spec:await r(e.spec)}),!e.data||!(`url`in e.data))return e;let i;try{i=c(e.data.url)}catch{return e}let a=e.data.format,o=await n.run(()=>re(i.href,a));return t[i.pathname]=o,{...e,data:{name:i.pathname}}},i=await r(e);return Object.keys(t).length===0?i:{...i,datasets:t}}var U=u();h(`arrow`,g);var W=e=>{let t=(0,me.c)(12),{value:n,setValue:r,chartSelection:i,fieldSelection:a,spec:o,embedOptions:s}=e,c,l;t[0]===o?(c=t[1],l=t[2]):(c=async()=>H(o),l=[o],t[0]=o,t[1]=c,t[2]=l);let{data:u,error:d}=ne(c,l);if(d){let e;return t[3]===d?e=t[4]:(e=(0,U.jsx)(ce,{error:d}),t[3]=d,t[4]=e),e}if(!u)return null;let f;return t[5]!==i||t[6]!==s||t[7]!==a||t[8]!==u||t[9]!==r||t[10]!==n?(f=(0,U.jsx)(G,{value:n,setValue:r,chartSelection:i,fieldSelection:a,spec:u,embedOptions:s}),t[5]=i,t[6]=s,t[7]=a,t[8]=u,t[9]=r,t[10]=n,t[11]=f):f=t[11],f},G=e=>{let n=(0,me.c)(50),{value:r,setValue:c,chartSelection:u,fieldSelection:p,spec:ne,embedOptions:m}=e,{theme:re}=te(),h=(0,pe.useRef)(null),ce=(0,pe.useRef)(void 0),[g,de]=(0,pe.useState)(),_;bb0:{if(m&&`actions`in m){_=m.actions;break bb0}let e;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(e={source:!1,compiled:!1},n[0]=e):e=n[0],_=e}let v=_,y=ue(ne),x;n[1]!==u||n[2]!==p||n[3]!==y?(x=ge(he(y),{chartSelection:u,fieldSelection:p}),n[1]=u,n[2]=p,n[3]=y,n[4]=x):x=n[4];let S=x,C;n[5]===S?C=n[6]:(C=w(S),n[5]=S,n[6]=C);let T=C,E;n[7]!==c||n[8]!==r?(E=e=>{c({...r,...e})},n[7]=c,n[8]=r,n[9]=E):E=n[9];let D=t(E),O;n[10]===D?O=n[11]:(O=i((e,t)=>{o.debug(`[Vega signal]`,e,t);let n=s.mapValues(t,ve);n=s.mapValues(n,_e),D({[e]:n})},100),n[10]=D,n[11]=O);let k=O,A=ue(T),j;if(n[12]!==k||n[13]!==A){let e;n[15]===k?e=n[16]:(e=(e,t)=>(b.PAN_ZOOM===t||b.isBinColoring(t)||e.push({signalName:t,handler:(e,t)=>k(e,t)}),e),n[15]=k,n[16]=e),j=A.reduce(e,[]),n[12]=k,n[13]=A,n[14]=j}else j=n[14];let M=j,N;n[17]===S?N=n[18]:(N=e=>{o.error(e),o.debug(S),de(e)},n[17]=S,n[18]=N);let P=t(N),F;n[19]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{o.debug(`[Vega view] created`,e),ce.current=e,de(void 0)},n[19]=F):F=n[19];let I=t(F),L;n[20]===T?L=n[21]:(L=()=>{let e=[];if(b.hasPoint(T)&&e.push([`Point selection`,`click to select a point; hold shift for multi-select`]),b.hasInterval(T)&&e.push([`Interval selection`,`click and drag to select an interval`]),b.hasLegend(T)&&e.push([`Legend selection`,`click to select a legend item; hold shift for multi-select`]),b.hasPanZoom(T)){let t=a()?`⌘`:`ctrl`;e.push([`Pan`,`hold the ${t} key and drag`],[`Zoom`,`hold the ${t} key and scroll`])}return e.length===0?null:(0,U.jsx)(d,{delayDuration:300,side:`left`,content:(0,U.jsx)(`div`,{className:`text-xs flex flex-col`,children:e.map(ye)}),children:(0,U.jsx)(ee,{className:`absolute bottom-1 right-0 m-2 h-4 w-4 cursor-help text-muted-foreground hover:text-foreground`})})},n[20]=T,n[21]=L);let R=L,z=re===`dark`?`dark`:void 0,B;n[22]!==v||n[23]!==z?(B={theme:z,actions:v,mode:`vega-lite`,tooltip:ie.call,renderer:`canvas`},n[22]=v,n[23]=z,n[24]=B):B=n[24];let V;n[25]!==P||n[26]!==I||n[27]!==S||n[28]!==B?(V={ref:h,spec:S,options:B,onError:P,onEmbed:I},n[25]=P,n[26]=I,n[27]=S,n[28]=B,n[29]=V):V=n[29];let H=ae(V),W;n[30]===S?W=n[31]:(W=le(S),n[30]=S,n[31]=W);let G=W;fe(h,G===`container`);let K,q;n[32]!==H||n[33]!==M?(K=()=>(M.forEach(e=>{let{signalName:t,handler:n}=e;try{H?.view.addSignalListener(t,n)}catch(e){let t=e;o.error(t)}}),()=>{M.forEach(e=>{let{signalName:t,handler:n}=e;try{H?.view.removeSignalListener(t,n)}catch(e){let t=e;o.error(t)}})}),q=[H,M],n[32]=H,n[33]=M,n[34]=K,n[35]=q):(K=n[34],q=n[35]),(0,pe.useEffect)(K,q);let J;n[36]===g?J=n[37]:(J=g&&(0,U.jsxs)(se,{variant:`destructive`,children:[(0,U.jsx)(oe,{children:g.message}),(0,U.jsx)(`div`,{className:`text-md`,children:g.stack})]}),n[36]=g,n[37]=J);let Y,X;n[38]===Symbol.for(`react.memo_cache_sentinel`)?(Y=l(`relative`),X=f.stopPropagation(),n[38]=Y,n[39]=X):(Y=n[38],X=n[39]);let Z;n[40]===G?Z=n[41]:(Z=(0,U.jsx)(`div`,{ref:h,"data-container-width":G}),n[40]=G,n[41]=Z);let Q;n[42]===R?Q=n[43]:(Q=R(),n[42]=R,n[43]=Q);let $;n[44]!==Z||n[45]!==Q?($=(0,U.jsxs)(`div`,{className:Y,onPointerDown:X,children:[Z,Q]}),n[44]=Z,n[45]=Q,n[46]=$):$=n[46];let be;return n[47]!==J||n[48]!==$?(be=(0,U.jsxs)(U.Fragment,{children:[J,$]}),n[47]=J,n[48]=$,n[49]=be):be=n[49],be};function _e(e){return e instanceof Set?[...e]:e}function ve(e){return Array.isArray(e)?e.map(e=>e instanceof Date&&m(e)?new Date(e).getTime():e):e}function ye(e,t){return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`font-bold tracking-wide`,children:[e[0],`:`]}),` `,e[1]]},t)}export{W as default};
|
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-BTUbA8tU.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-B0Z9INg1.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/react-CBDbhulC.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/compiler-runtime-CYIjoINj.js">
|