@restio/ui 0.2.1-20260901160735 → 0.2.1-20261007123729
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/README.md +9 -35
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +245 -87
- package/dist/core.js +32 -27
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +186 -145
- package/dist/data.js +19 -19
- package/dist/experimental.cjs +2 -1
- package/dist/experimental.d.ts +206 -33
- package/dist/experimental.js +899 -566
- package/dist/framework.cjs +1 -1
- package/dist/framework.d.ts +73 -101
- package/dist/framework.js +29 -26
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +431 -304
- package/dist/index.js +96 -88
- package/dist/{src-DaTjVaGd.js → src-Bzrq1hWW.js} +12070 -11460
- package/dist/src-kY7g6XFo.cjs +158 -0
- package/dist/ui.css +1 -1
- package/package.json +6 -5
- package/dist/src-gB-fpYMb.cjs +0 -156
package/dist/data.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { A as s, B as t,
|
|
1
|
+
import { A as s, B as t, F as e, H as r, I as o, K as i, L as n, M as p, N as u, P as c, R as C, T as L, U as d, V as l, W as y, j as P, k as m, pt as K, q as f, w as h, z as F } from "./src-Bzrq1hWW.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
l as Calendar,
|
|
4
4
|
y as Card,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
F as CardList,
|
|
6
|
+
i as Cell,
|
|
7
|
+
K as Chart,
|
|
8
|
+
L as DataComponentConfigurator,
|
|
9
|
+
t as Form,
|
|
10
|
+
d as Gantt,
|
|
11
|
+
o as KPI,
|
|
12
|
+
h as Switcher,
|
|
13
|
+
f as TableGrid,
|
|
14
14
|
C as Tree,
|
|
15
15
|
n as TreeCard,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
P as cardLayoutPresetOptions,
|
|
17
|
+
p as cardLayoutWithIcon,
|
|
18
|
+
r as createDataStructureFromFile,
|
|
19
|
+
c as financeKpiLayout,
|
|
20
|
+
e as financeKpiLayoutWithIcon,
|
|
21
|
+
m as kpiLayoutPresetOptions,
|
|
22
|
+
u as resolveCardLayoutPreset,
|
|
23
|
+
s as resolveKpiLayoutPreset
|
|
24
24
|
};
|
package/dist/experimental.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./src-gB-fpYMb.cjs");let s=require("react");s=l.__toESM(s,1);var xe=1;function pe(r,h){const p=r.col+r.w,b=r.row+r.h,S=h.col+h.w,f=h.row+h.h;return r.col<S&&p>h.col&&r.row<f&&b>h.row}function le(r){return r.col>=1&&r.col+r.w-1<=12&&r.row>=1&&r.row+r.h-1<=30}function de(r,h,p){for(const b of h)if(b.id!==p&&pe(r,b.position))return b.id;return null}function ce(r,h,p){for(let f=1;f<=30-h+1;f++)for(let g=1;g<=12-r+1;g++){const I={col:g,row:f,w:r,h};if(!de(I,p))return I}return{col:1,row:p.reduce((f,g)=>Math.max(f,g.position.row+g.position.h),1),w:r,h}}function fe(r,h){const p={};for(const b of r){const S=h[b.dataSourceId];if(!S)continue;const f=S.data??[],g=l.generateColumnsFromSchema(f.length>0?Object.keys(f[0]):[]),I=l.fieldOptionsFromColumns(b.columns??g),M=new Set,n=[];for(const v of I)M.has(v.id)||(M.add(v.id),n.push(v));p[b.dataSourceId]=n}return p}var ie=0;function oe(){return ie+=1,`widget-${Date.now()}-${ie}`}function ne(){return{version:1,name:"Untitled Dashboard",filters:null,widgets:[]}}function ge(r,h){const[p,b]=(0,s.useState)(r??ne),[S,f]=(0,s.useState)(null),[g,I]=(0,s.useState)(h?"view":"edit"),M=(0,s.useRef)(!1),n=(0,s.useCallback)(()=>{M.current=!0},[]),v=(0,s.useCallback)((i,u,D)=>{b(t=>{const _={id:oe(),title:`New ${i}`,componentType:i,dataSourceId:u,position:D};return{...t,widgets:[...t.widgets,_]}}),n()},[n]),R=(0,s.useCallback)(i=>{b(u=>{const D=ce(6,3,u.widgets),t={id:oe(),position:D,...i.widget};return{...u,widgets:[...u.widgets,t]}}),n()},[n]),W=(0,s.useCallback)(i=>{b(u=>({...u,widgets:u.widgets.filter(D=>D.id!==i)})),f(u=>u===i?null:u),n()},[n]),O=(0,s.useCallback)((i,u)=>{b(D=>({...D,widgets:D.widgets.map(t=>{if(t.id!==i)return t;const _={...t,...u};if(u.dataSourceId&&u.dataSourceId!==t.dataSourceId){const z=l.propSchemaRegistry[t.componentType]??[];_.columns=void 0,_.componentProps=l.buildDefaultPropsFromSchema(z),_.filters=void 0,_.uiConfig=void 0}return _})})),n()},[n]),j=(0,s.useCallback)((i,u)=>{O(i,{position:u})},[O]),B=(0,s.useCallback)(i=>{f(i)},[]),Y=p.widgets.find(i=>i.id===S)??null,H=(0,s.useCallback)(i=>{b(u=>({...u,name:i})),n()},[n]),a=(0,s.useCallback)(i=>{b(u=>({...u,filters:typeof i=="function"?i(u.filters):i})),n()},[n]),o=(0,s.useCallback)(i=>{b(i??ne()),f(null),M.current=!1},[]),P=(0,s.useCallback)(i=>{b(i),f(null),M.current=!1},[]);return{state:{config:p,selectedWidgetId:S,isDirty:M.current},mode:g,setMode:I,addWidget:v,addPrebuiltWidget:R,removeWidget:W,updateWidget:O,moveWidget:j,selectWidget:B,selectedWidget:Y,setName:H,setFilters:a,resetConfig:o,loadConfig:P}}var d={"rst-dashboard-builder":"_rst-dashboard-builder_ukxxh_2","rst-dashboard-builder-sidebar":"_rst-dashboard-builder-sidebar_ukxxh_18","rst-dashboard-builder-sidebar-header":"_rst-dashboard-builder-sidebar-header_ukxxh_28","rst-dashboard-builder-sidebar-list":"_rst-dashboard-builder-sidebar-list_ukxxh_33","rst-dashboard-builder-widget-type-item":"_rst-dashboard-builder-widget-type-item_ukxxh_40","rst-dashboard-builder-widget-type-label":"_rst-dashboard-builder-widget-type-label_ukxxh_59","rst-dashboard-builder-widget-type-desc":"_rst-dashboard-builder-widget-type-desc_ukxxh_63","rst-dashboard-builder-main":"_rst-dashboard-builder-main_ukxxh_69","rst-dashboard-builder-toolbar":"_rst-dashboard-builder-toolbar_ukxxh_77","rst-dashboard-builder-toolbar-left":"_rst-dashboard-builder-toolbar-left_ukxxh_87","rst-dashboard-builder-toolbar-right":"_rst-dashboard-builder-toolbar-right_ukxxh_93","rst-dashboard-builder-name-input":"_rst-dashboard-builder-name-input_ukxxh_99","rst-dashboard-builder-name-display":"_rst-dashboard-builder-name-display_ukxxh_115","rst-dashboard-builder-view":"_rst-dashboard-builder-view_ukxxh_122","rst-dashboard-widget":"_rst-dashboard-widget_ukxxh_146","rst-switcher":"_rst-switcher_ukxxh_170","rst-dashboard-builder-canvas":"_rst-dashboard-builder-canvas_ukxxh_183","rst-dashboard-builder-grid":"_rst-dashboard-builder-grid_ukxxh_191","rst-dashboard-builder-grid-cell":"_rst-dashboard-builder-grid-cell_ukxxh_201","rst-dashboard-builder-grid-cell-view":"_rst-dashboard-builder-grid-cell-view_ukxxh_213","rst-dashboard-builder-grid-empty":"_rst-dashboard-builder-grid-empty_ukxxh_219","rst-dashboard-builder-widget":"_rst-dashboard-builder-widget_ukxxh_40","rst-dashboard-builder-widget-view":"_rst-dashboard-builder-widget-view_ukxxh_290","rst-dashboard-builder-widget-selected":"_rst-dashboard-builder-widget-selected_ukxxh_298","rst-dashboard-builder-widget-dragging":"_rst-dashboard-builder-widget-dragging_ukxxh_304","rst-dashboard-builder-widget-collision":"_rst-dashboard-builder-widget-collision_ukxxh_310","rst-dashboard-builder-resize-handle-n":"_rst-dashboard-builder-resize-handle-n_ukxxh_317","rst-dashboard-builder-resize-handle-s":"_rst-dashboard-builder-resize-handle-s_ukxxh_318","rst-dashboard-builder-resize-handle-e":"_rst-dashboard-builder-resize-handle-e_ukxxh_319","rst-dashboard-builder-resize-handle-w":"_rst-dashboard-builder-resize-handle-w_ukxxh_320","rst-dashboard-builder-resize-handle-ne":"_rst-dashboard-builder-resize-handle-ne_ukxxh_321","rst-dashboard-builder-resize-handle-nw":"_rst-dashboard-builder-resize-handle-nw_ukxxh_322","rst-dashboard-builder-resize-handle-se":"_rst-dashboard-builder-resize-handle-se_ukxxh_323","rst-dashboard-builder-resize-handle-sw":"_rst-dashboard-builder-resize-handle-sw_ukxxh_324","rst-dashboard-builder-filter-body":"_rst-dashboard-builder-filter-body_ukxxh_540","rst-dashboard-builder-filter-tabs":"_rst-dashboard-builder-filter-tabs_ukxxh_548","rst-dashboard-builder-configurator":"_rst-dashboard-builder-configurator_ukxxh_557","rst-dashboard-builder-configurator-header":"_rst-dashboard-builder-configurator-header_ukxxh_567","rst-dashboard-builder-configurator-body":"_rst-dashboard-builder-configurator-body_ukxxh_575","rst-dashboard-builder-configurator-empty":"_rst-dashboard-builder-configurator-empty_ukxxh_582","rst-dashboard-builder-configurator-divider":"_rst-dashboard-builder-configurator-divider_ukxxh_593","rst-dashboard-builder-field":"_rst-dashboard-builder-field_ukxxh_599","rst-dashboard-builder-field-label":"_rst-dashboard-builder-field-label_ukxxh_605","rst-dashboard-builder-checkbox-row":"_rst-dashboard-builder-checkbox-row_ukxxh_611","rst-dashboard-builder-checkbox-label":"_rst-dashboard-builder-checkbox-label_ukxxh_618","rst-dashboard-builder-drag-ghost":"_rst-dashboard-builder-drag-ghost_ukxxh_624","rst-dashboard-builder-drop-zone":"_rst-dashboard-builder-drop-zone_ukxxh_638","rst-dashboard-builder-add-widget-item":"_rst-dashboard-builder-add-widget-item_ukxxh_646","rst-dashboard-builder-add-widget-item-label":"_rst-dashboard-builder-add-widget-item-label_ukxxh_667","rst-dashboard-builder-add-widget-item-desc":"_rst-dashboard-builder-add-widget-item-desc_ukxxh_673","rst-dashboard-builder-template-wrapper":"_rst-dashboard-builder-template-wrapper_ukxxh_679","rst-dashboard-builder-template-picker":"_rst-dashboard-builder-template-picker_ukxxh_683","rst-dashboard-builder-template-picker-header":"_rst-dashboard-builder-template-picker-header_ukxxh_697","rst-dashboard-builder-template-item":"_rst-dashboard-builder-template-item_ukxxh_705","rst-dashboard-builder-template-item-name":"_rst-dashboard-builder-template-item-name_ukxxh_727","rst-dashboard-builder-template-item-desc":"_rst-dashboard-builder-template-item-desc_ukxxh_733"},K=12,ee=30,se=12;function _e({widgets:r,onMoveWidget:h,onAddWidget:p,onChange:b}){const S=(0,s.useRef)(null),[f,g]=(0,s.useState)(null),[I,M]=(0,s.useState)(null),[n,v]=(0,s.useState)(null),[R,W]=(0,s.useState)(null),[O,j]=(0,s.useState)(!1),[B,Y]=(0,s.useState)(null),[H,a]=(0,s.useState)(null),[o,P]=(0,s.useState)(null),[i,u]=(0,s.useState)(null),[D,t]=(0,s.useState)(!1),_=(0,s.useCallback)(()=>S.current?{colWidth:(S.current.getBoundingClientRect().width-se*(K-1))/K,rowHeight:92}:null,[]),z=(0,s.useCallback)((x,k)=>{if(!S.current)return{col:1,row:1};const y=S.current.getBoundingClientRect(),w=(y.width-se*(K-1))/K;return{col:Math.max(1,Math.min(K,Math.round((x-y.left)/(w+se))+1)),row:Math.max(1,Math.min(ee,Math.round((k-y.top)/92)+1))}},[]),J=(0,s.useCallback)(x=>{if(x.preventDefault(),x.dataTransfer.types.includes("application/widget-type")){x.dataTransfer.dropEffect="copy";return}if(x.dataTransfer.types.includes("application/move-widget")&&f&&I&&n){x.dataTransfer.dropEffect="move";const k=r.find(N=>N.id===f);if(!k)return;const y=_();if(!y)return;const w=x.clientX-I.x,L=x.clientY-I.y,ae=Math.round(w/(y.colWidth+se)),V=Math.round(L/y.rowHeight),$={col:Math.max(1,Math.min(K-k.position.w+1,n.col+ae)),row:Math.max(1,Math.min(ee-k.position.h+1,n.row+V)),w:k.position.w,h:k.position.h};W($);const E=de($,r,f);j(E!==null)}},[f,I,n,_,r]),Q=(0,s.useCallback)(x=>{x.preventDefault();const k=x.dataTransfer.getData("application/widget-type");if(k){const{col:y,row:w}=z(x.clientX,x.clientY),L={col:y,row:w,w:4,h:3};if(y+4-1>K&&(L.col=9),w+3-1>ee&&(L.row=28),de(L,r))return;p(k,"",L),b();return}f&&R&&(!O&&le(R)&&(h(f,R),b()),g(null),M(null),v(null),W(null),j(!1))},[z,r,p,b,f,R,O,h]),Z=(0,s.useCallback)((x,k)=>{x.stopPropagation(),x.dataTransfer.setData("application/move-widget",k.id),x.dataTransfer.effectAllowed="move",g(k.id),M({x:x.clientX,y:x.clientY}),v({...k.position}),W({...k.position}),j(!1)},[]),m=(0,s.useCallback)(()=>{g(null),M(null),v(null),W(null),j(!1)},[]),re=(0,s.useCallback)((x,k,y)=>{x.stopPropagation(),x.preventDefault(),Y(k.id),a(y),P({...k.position}),u({x:x.clientX,y:x.clientY}),t(!1)},[]);return(0,s.useEffect)(()=>{if(!B||!H||!o||!i)return;const x=y=>{if(!r.find(C=>C.id===B))return;const w=_();if(!w)return;const L=y.clientX-i.x,ae=y.clientY-i.y,V=Math.round(L/(w.colWidth+se)),$=Math.round(ae/w.rowHeight),E=o.col,N=o.row,A=o.w,X=o.h;let F={...o};switch(H){case"e":{const C=Math.max(1,Math.min(K-E+1,A+V));F={...F,w:C};break}case"w":{const C=Math.max(1,Math.min(E+A-1,E+V)),T=E+A-C;F={...o,col:C,w:Math.max(1,T)};break}case"s":{const C=Math.max(1,Math.min(ee-N+1,X+$));F={...o,h:C};break}case"n":{const C=Math.max(1,Math.min(N+X-1,N+$)),T=N+X-C;F={...o,row:C,h:Math.max(1,T)};break}case"se":{const C=Math.max(1,Math.min(K-E+1,A+V)),T=Math.max(1,Math.min(ee-N+1,X+$));F={...o,w:C,h:T};break}case"sw":{const C=Math.max(1,Math.min(E+A-1,E+V)),T=E+A-C,c=Math.max(1,Math.min(ee-N+1,X+$));F={...o,col:C,w:Math.max(1,T),h:c};break}case"ne":{const C=Math.max(1,Math.min(N+X-1,N+$)),T=N+X-C,c=Math.max(1,Math.min(K-E+1,A+V));F={...o,row:C,h:Math.max(1,T),w:c};break}case"nw":{const C=Math.max(1,Math.min(E+A-1,E+V)),T=Math.max(1,Math.min(N+X-1,N+$)),c=E+A-C,G=N+X-T;F={col:C,row:T,w:Math.max(1,c),h:Math.max(1,G)};break}}W(F),g(B);const te=de(F,r,B);t(te!==null),j(te!==null)},k=()=>{r.find(y=>y.id===B)&&R&&!D&&le(R)&&(h(B,R),b()),Y(null),a(null),P(null),u(null),t(!1),g(null),M(null),v(null),W(null),j(!1)};return document.addEventListener("mousemove",x),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",k)}},[B,H,o,i,r,R,D,_,h,b]),{gridRef:S,draggingWidgetId:f,dragPreviewPos:R,hasCollision:O,resizeCollision:D,handleDragOver:J,handleDrop:Q,handleWidgetDragStart:Z,handleWidgetDragEnd:m,handleResizeStart:re,pixelToGrid:z}}var e=l.require_jsx_runtime(),ve=12,ke=20,ue=({widgets:r,selectedWidgetId:h,dataSources:p,onSelectWidget:b,onMoveWidget:S,onRemoveWidget:f,onAddWidget:g,onChange:I,getWidgetActions:M,mode:n="edit"})=>{const v=n==="view",{gridRef:R,draggingWidgetId:W,dragPreviewPos:O,hasCollision:j,handleDragOver:B,handleDrop:Y,handleWidgetDragStart:H,handleWidgetDragEnd:a,handleResizeStart:o}=_e({widgets:r,onMoveWidget:S,onAddWidget:g,onChange:I}),P=(0,s.useCallback)((t,_)=>{t.stopPropagation(),b(_)},[b]),i=(0,s.useCallback)(()=>{b(null)},[b]),u=(0,s.useCallback)(t=>{const _=p[t.dataSourceId]?.data??[],z=_.length>0?Object.keys(_[0]):[];return{data:_,columns:t.columns??l.generateColumnsFromSchema(z)}},[p]),D=[];for(let t=1;t<=ke;t++)for(let _=1;_<=ve;_++){const z=v?d["rst-dashboard-builder-grid-cell-view"]:d["rst-dashboard-builder-grid-cell"];D.push((0,e.jsx)("div",{className:z,style:{gridColumn:_,gridRow:t}},`cell-${t}-${_}`))}return(0,e.jsx)("div",{className:d["rst-dashboard-builder-canvas"],onClick:i,children:(0,e.jsxs)("div",{ref:R,className:d["rst-dashboard-builder-grid"],onDragOver:B,onDrop:Y,children:[D,r.length===0&&(0,e.jsx)("div",{className:d["rst-dashboard-builder-grid-empty"],children:"Drag a widget from the palette to get started"}),r.map(t=>{const _=!v&&t.id===h,z=!v&&t.id===W,J=u(t),Q=z&&O?O:t.position,Z=z&&j;return(0,e.jsxs)("div",{className:[d["rst-dashboard-builder-widget"],v?d["rst-dashboard-builder-widget-view"]:"",_?d["rst-dashboard-builder-widget-selected"]:"",z?d["rst-dashboard-builder-widget-dragging"]:"",Z?d["rst-dashboard-builder-widget-collision"]:""].filter(Boolean).join(" "),style:{gridColumn:`${Q.col} / span ${Q.w}`,gridRow:`${Q.row} / span ${Q.h}`},draggable:!v,...v?{}:{onDragStart:m=>H(m,t),onDragEnd:a,onClick:m=>P(m,t.id),role:"button",tabIndex:0,"aria-label":`Widget: ${t.title}`,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),b(t.id)),(m.key==="Delete"||m.key==="Backspace")&&(m.preventDefault(),f(t.id),I())}},children:[(0,e.jsx)(l.DashboardWidget,{id:t.id,dataSourceId:t.dataSourceId,title:t.title,subtitle:t.subtitle,icon:t.icon,data:J.data,columns:J.columns,enableExport:M?.(t).enableExport??!0,enableScreenshot:M?.(t).enableScreenshot??!1,enableExpand:M?.(t).enableExpand??!0,enableFilter:M?.(t).enableFilter??!1,fieldOptions:l.fieldOptionsFromColumns(J.columns),children:({data:m})=>(0,e.jsx)(l.Switcher,{data:m,columns:J.columns,activeComponent:t.componentType,componentProps:t.componentProps,showConfigurator:!1})}),!v&&_&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-n"],onMouseDown:m=>o(m,t,"n")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-s"],onMouseDown:m=>o(m,t,"s")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-e"],onMouseDown:m=>o(m,t,"e")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-w"],onMouseDown:m=>o(m,t,"w")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-ne"],onMouseDown:m=>o(m,t,"ne")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-nw"],onMouseDown:m=>o(m,t,"nw")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-se"],onMouseDown:m=>o(m,t,"se")}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-resize-handle-sw"],onMouseDown:m=>o(m,t,"sw")})]})]},`${t.id}::${t.dataSourceId}`)})]})})};ue.displayName="BuilderCanvas";var Ce=[{type:"table-grid",label:"Table",icon:"table",description:"Sortable, filterable data table"},{type:"chart",label:"Chart",icon:"chart",description:"Bar, line, pie charts"},{type:"calendar",label:"Calendar",icon:"calendar",description:"Calendar view of events"},{type:"card-list",label:"Card List",icon:"list",description:"Visual card layout"},{type:"form",label:"Form",icon:"form",description:"Editable form from schema"},{type:"gantt",label:"Gantt",icon:"chart-gantt",description:"Project timeline view"},{type:"kpi",label:"KPI",icon:"chart",description:"Single-metric KPI card"}],be=({widget:r,dataSources:h,onUpdate:p,onRemove:b,onClose:S,onAddWidget:f,prebuiltSections:g,onAddPrebuiltSection:I})=>{const M=Object.values(h).map(a=>({value:a.id,label:a.name})),n=(0,s.useMemo)(()=>[{value:"",id:"none"},...Object.keys(l.svgAssets).map(a=>({value:a,leadingVisual:a}))],[]),v=r?.dataSourceId,R=(0,s.useMemo)(()=>{if(!v)return[];const a=h[v];return a?a.fields.map(o=>({id:o.id,header:o.name,accessorKey:o.id})):[]},[v,h]),W=(0,s.useMemo)(()=>l.propSchemaRegistry[r?.componentType??"table-grid"]??[],[r?.componentType]),O=(0,s.useMemo)(()=>r?.componentProps??l.buildDefaultPropsFromSchema(W),[r?.componentProps,W]),j=(0,s.useCallback)((a,o)=>{p({[a]:o})},[p]),B=(0,s.useCallback)(a=>{p({componentType:a,componentProps:l.buildDefaultPropsFromSchema(l.propSchemaRegistry[a]??[])})},[p]),Y=(0,s.useCallback)((a,o)=>{p({componentProps:{...O,[a]:o}})},[O,p]),H=(0,s.useMemo)(()=>!g||g.length===0?[]:g.filter(a=>a.version===1),[g]);return r?(0,e.jsxs)("aside",{className:d["rst-dashboard-builder-configurator"],"aria-label":"Widget configurator",children:[(0,e.jsxs)("div",{className:d["rst-dashboard-builder-configurator-header"],children:[(0,e.jsx)(l.Typography,{variant:"heading",children:"Configure"}),(0,e.jsx)(l.Button,{variant:"invisible",size:"small",leadingVisual:"close",onClick:S,"aria-label":"Close configurator"})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-configurator-body"],children:[(0,e.jsxs)("div",{className:d["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:d["rst-dashboard-builder-field-label"],children:"Title"}),(0,e.jsx)(l.TextInput,{value:r.title,onChange:a=>j("title",a??""),placeholder:"Widget title"})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:d["rst-dashboard-builder-field-label"],children:"Subtitle"}),(0,e.jsx)(l.TextInput,{value:r.subtitle??"",onChange:a=>j("subtitle",a||void 0),placeholder:"Optional subtitle"})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:d["rst-dashboard-builder-field-label"],children:"Icon"}),(0,e.jsx)(l.Select,{value:r.icon??"",onChange:a=>j("icon",a||void 0),options:n,renderList:({options:a,value:o,onChange:P,onClose:i})=>(0,e.jsx)(l.List,{options:a,activeIndex:[typeof o=="string"?o:""],onClick:u=>{P(u.value),i()},showFilter:!0})})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:d["rst-dashboard-builder-field-label"],children:"Data Source"}),(0,e.jsx)(l.Select,{value:r.dataSourceId,onChange:a=>j("dataSourceId",a),options:M})]}),r.dataSourceId&&h[r.dataSourceId]&&(0,e.jsxs)("div",{className:d["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:d["rst-dashboard-builder-field-label"],children:"Columns"}),(0,e.jsx)(l.CheckboxGroup,{options:h[r.dataSourceId].fields.map(a=>({value:a.id,label:a.name})),value:r.columns?.map(a=>a.id).filter(Boolean)??h[r.dataSourceId].fields.map(a=>a.id),onChange:a=>{const o=h[r.dataSourceId],P=a.map(i=>o.fields.find(u=>u.id===i)).filter(Boolean).map(i=>({id:i.id,header:i.name,accessorKey:i.id}));p({columns:P.length===o.fields.length?void 0:P})}})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:d["rst-dashboard-builder-field-label"],children:"Actions"}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(l.Checkbox,{checked:r.enableExport??!0,onChange:a=>j("enableExport",a)}),(0,e.jsx)("span",{className:d["rst-dashboard-builder-checkbox-label"],children:"Export CSV"})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(l.Checkbox,{checked:r.enableScreenshot??!1,onChange:a=>j("enableScreenshot",a)}),(0,e.jsx)("span",{className:d["rst-dashboard-builder-checkbox-label"],children:"Screenshot"})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(l.Checkbox,{checked:r.enableExpand??!0,onChange:a=>j("enableExpand",a)}),(0,e.jsx)("span",{className:d["rst-dashboard-builder-checkbox-label"],children:"Expand"})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(l.Checkbox,{checked:r.enableFilter??!0,onChange:a=>j("enableFilter",a)}),(0,e.jsx)("span",{className:d["rst-dashboard-builder-checkbox-label"],children:"Filter"})]})]}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-configurator-divider"]}),(0,e.jsx)(l.DataComponentConfigurator,{schema:W,values:O,onChange:Y,columns:R,scope:"all",componentId:r.componentType,onComponentChange:B,componentMetaList:l.dataComponentMetaList},r.dataSourceId??"no-ds"),(0,e.jsx)("div",{className:d["rst-dashboard-builder-configurator-divider"]}),(0,e.jsx)(l.Button,{variant:"danger",size:"small",value:"Remove widget",leadingVisual:"trash",onClick:b})]})]}):(0,e.jsxs)("aside",{className:d["rst-dashboard-builder-configurator"],"aria-label":"Add widget",children:[(0,e.jsx)("div",{className:d["rst-dashboard-builder-configurator-header"],children:(0,e.jsx)(l.Typography,{variant:"heading",children:"Add Widget"})}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-configurator-body"],children:[Ce.map(a=>(0,e.jsxs)("button",{className:d["rst-dashboard-builder-add-widget-item"],onClick:()=>f(a.type),children:[(0,e.jsx)(l.Icon,{src:a.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:d["rst-dashboard-builder-add-widget-item-label"],children:a.label}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-add-widget-item-desc"],children:a.description})]})]},a.type)),H.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:d["rst-dashboard-builder-configurator-divider"]}),(0,e.jsx)(l.Typography,{variant:"heading",children:"Pre-built Sections"}),H.map(a=>(0,e.jsxs)("button",{className:d["rst-dashboard-builder-add-widget-item"],onClick:()=>I?.(a),children:[(0,e.jsx)(l.Icon,{src:"layout"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:d["rst-dashboard-builder-add-widget-item-label"],children:a.name}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-add-widget-item-desc"],children:a.description})]})]},a.name))]})]})]})};be.displayName="WidgetConfigurator";var he=({dataSources:r,initialConfig:h,templates:p,prebuiltSections:b,onSave:S,onChange:f,widgetActionDefaults:g,readOnly:I,className:M})=>{const{state:n,mode:v,setMode:R,addWidget:W,addPrebuiltWidget:O,removeWidget:j,updateWidget:B,moveWidget:Y,selectWidget:H,selectedWidget:a,setName:o,setFilters:P,loadConfig:i}=ge(h,I),[u,D]=(0,s.useState)(!1),[t,_]=(0,s.useState)("dialog"),[z,J]=(0,s.useState)(null),[Q,Z]=(0,s.useState)(null),[m,re]=(0,s.useState)(!1),[x,k]=(0,s.useState)(null),y=(0,s.useMemo)(()=>fe(n.config.widgets,r),[n.config.widgets,r]),w=v==="view",L=w?Q:n.config.filters;(0,s.useEffect)(()=>{u&&k(L)},[u]);const ae=(0,s.useCallback)(()=>{w?Z(x):P(x),D(!1)},[x,w,P]);(0,s.useEffect)(()=>{w&&!m&&(Z(n.config.filters),re(!0)),w||re(!1)},[w,m,n.config.filters]);const V=(0,s.useRef)(f);V.current=f;const $=(0,s.useCallback)((c,G)=>{(w?Z:P)(U=>({...U??{},[c]:G}))},[w,P]),E=(0,s.useMemo)(()=>({filters:L,onFilterChange:$}),[L,$]),N=(0,s.useMemo)(()=>!p||p.length===0?[]:p.filter(c=>c.version===1),[p]),A=(0,s.useMemo)(()=>N.map(c=>({value:c.name,id:c.name,description:c.description})),[N]),X=(0,s.useCallback)(c=>{const G=N.find(q=>q.name===c);if(!G)return;const U={version:1,...G.config};i(U)},[N,i]),F=(0,s.useMemo)(()=>({enableExport:g?.enableExport??!0,enableScreenshot:g?.enableScreenshot??!1,enableExpand:g?.enableExpand??!0,enableFilter:g?.enableFilter??!0}),[g]),te=(0,s.useCallback)(c=>({enableExport:c.enableExport??F.enableExport,enableScreenshot:c.enableScreenshot??F.enableScreenshot,enableExpand:c.enableExpand??F.enableExpand,enableFilter:c.enableFilter??F.enableFilter}),[F]);(0,s.useEffect)(()=>{V.current?.(n.config)},[n.config]);const C=[d["rst-dashboard-builder"],M].filter(Boolean).join(" "),T=(0,s.useCallback)(()=>{S(n.config)},[n.config,S]);return(0,e.jsx)("div",{className:C,children:(0,e.jsxs)("div",{className:d["rst-dashboard-builder-main"],children:[(0,e.jsxs)("div",{className:d["rst-dashboard-builder-toolbar"],children:[(0,e.jsxs)("div",{className:d["rst-dashboard-builder-toolbar-left"],children:[w?(0,e.jsx)("span",{className:d["rst-dashboard-builder-name-display"],children:n.config.name}):(0,e.jsx)("input",{className:d["rst-dashboard-builder-name-input"],type:"text",value:n.config.name,onChange:c=>o(c.target.value),placeholder:"Dashboard name","aria-label":"Dashboard name"}),Object.keys(y).length>0&&(0,e.jsx)(l.Button,{variant:"invisible",size:"small",leadingVisual:"filter",onClick:()=>D(c=>!c),"aria-label":"Toggle filter panel","aria-pressed":u})]}),(0,e.jsxs)("div",{className:d["rst-dashboard-builder-toolbar-right"],children:[N.length>0&&!w&&(0,e.jsx)(l.ButtonDropdown,{options:A,onChange:X,placeholder:"Load Template",size:"small"}),!I&&(0,e.jsx)(l.ButtonGroup,{value:v,options:[{value:"edit"},{value:"view"}],onChange:c=>R(c)}),!w&&(0,e.jsx)(l.Button,{variant:"primary",size:"small",value:"Save",onClick:T})]})]}),(0,e.jsx)(l.DashboardContext,{value:E,children:(0,e.jsxs)("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[(0,e.jsx)(ue,{mode:v,widgets:n.config.widgets,selectedWidgetId:n.selectedWidgetId,dataSources:r,onSelectWidget:H,onMoveWidget:Y,onRemoveWidget:j,onAddWidget:W,onChange:()=>{},getWidgetActions:te}),u&&Object.keys(y).length>0&&(0,e.jsxs)(l.OverlayPanel,{open:u,variant:t,position:t==="dialog"?"center":"right",onClose:()=>D(!1),closeOnEscape:!0,closeOnClickOutside:t==="dialog",width:t==="sidepanel"?360:void 0,maxWidth:t==="dialog"?640:void 0,maxHeight:t==="dialog"?"80vh":void 0,"aria-label":"Dashboard filters",children:[(0,e.jsx)(l.OverlayPanel.Header,{title:"Filters",onClose:()=>D(!1),actions:(0,e.jsx)(l.Button,{variant:"invisible",size:"small",leadingVisual:t==="dialog"?"square-half":"open-center",onClick:()=>_(c=>c==="dialog"?"sidepanel":"dialog"),"aria-label":t==="dialog"?"Switch to side panel":"Switch to dialog"})}),(0,e.jsx)("div",{className:d["rst-dashboard-builder-filter-body"],children:(()=>{const c=Object.keys(y);if(c.length===0)return(0,e.jsx)("div",{style:{padding:"var(--rst-space-default)"},children:"No data sources to filter."});const G=z&&c.includes(z)?z:c[0],U=x?.[G]??l.emptyFilterGroup();return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:d["rst-dashboard-builder-filter-tabs"],children:c.map(q=>(0,e.jsx)(l.Button,{value:q,variant:q===G?"base":"invisible",size:"small",onClick:()=>J(q),children:q},q))}),(0,e.jsx)(l.FilterBuilder,{filters:U,onChange:q=>k(me=>({...me??{},[G]:q.filters.length===0?null:q})),fieldOptions:y[G]})]})})()}),(0,e.jsxs)(l.OverlayPanel.Footer,{children:[(0,e.jsx)(l.Button,{variant:"invisible",size:"small",value:"Clear",onClick:()=>k({})}),(0,e.jsx)(l.Button,{variant:"primary",size:"small",value:"Apply",onClick:ae})]})]}),!w&&(0,e.jsx)(be,{widget:a,dataSources:r,onUpdate:c=>{a&&B(a.id,c)},onRemove:()=>{a&&j(a.id)},onClose:()=>H(null),onAddWidget:c=>{const G=Object.values(r)[0],U=ce(6,3,n.config.widgets);W(c,G?.id??"",U)},prebuiltSections:b,onAddPrebuiltSection:c=>{O(c)}})]})})]})})};he.displayName="DashboardBuilder";exports.DASHBOARD_CONFIG_VERSION=xe;exports.DashboardBuilder=he;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./src-kY7g6XFo.cjs");let r=require("react");r=n.__toESM(r,1);let ve=require("react-dom");var ye={"rst-pip-container":"_rst-pip-container_63eby_1"},e=n.require_jsx_runtime(),Ce=({pipWindow:a,className:t,children:o,...l})=>a?(0,ve.createPortal)((0,e.jsx)("div",{className:[ye["rst-pip-container"],t].filter(Boolean).join(" "),...l,children:o}),a.document.body):null;function be(){return globalThis.documentPictureInPicture}function ke(){return be()!==void 0}function je(a,t=document){for(const o of Array.from(t.querySelectorAll('style, link[rel="stylesheet"]')))a.head.appendChild(o.cloneNode(!0));for(const{name:o,value:l}of Array.from(t.documentElement.attributes))a.documentElement.setAttribute(o,l);for(const{name:o,value:l}of Array.from(t.body.attributes))a.body.setAttribute(o,l)}function we(a){const t=a.createElement("style");t.textContent=["html, body { height: 100%; margin: 0; }","body {"," background-color: var(--rst-backgroundColor-default);"," color: var(--rst-fontColor-main);"," font: var(--rst-font-body);","}"].join(`
|
|
2
|
+
`),a.head.appendChild(t)}function Se({width:a,height:t,copyStyles:o=!0}={}){const[l,p]=(0,r.useState)(null),[m,g]=(0,r.useState)(null),k=(0,r.useRef)(null),S=(0,r.useCallback)(async()=>{const _=be();if(!(!_||k.current)){g(null);try{const v=await _.requestWindow({width:a,height:t});k.current=v,o&&je(v.document),we(v.document),v.addEventListener("pagehide",()=>{k.current=null,p(null)}),p(v)}catch(v){g(v instanceof Error?`${v.name}: ${v.message}`:String(v))}}},[a,t,o]),b=(0,r.useCallback)(()=>{k.current?.close()},[]);return(0,r.useEffect)(()=>()=>k.current?.close(),[]),{pipWindow:l,error:m,isOpen:l!==null,isSupported:ke(),open:S,close:b}}var Me=1;function Ne(a,t){const o=a.col+a.w,l=a.row+a.h,p=t.col+t.w,m=t.row+t.h;return a.col<p&&o>t.col&&a.row<m&&l>t.row}function ie(a){return a.col>=1&&a.col+a.w-1<=12&&a.row>=1&&a.row+a.h-1<=30}function oe(a,t,o){for(const l of t)if(l.id!==o&&Ne(a,l.position))return l.id;return null}function he(a,t,o){for(let m=1;m<=30-t+1;m++)for(let g=1;g<=12-a+1;g++){const k={col:g,row:m,w:a,h:t};if(!oe(k,o))return k}return{col:1,row:o.reduce((m,g)=>Math.max(m,g.position.row+g.position.h),1),w:a,h:t}}function De(a,t){const o={};for(const l of a){const p=t[l.dataSourceId];if(!p)continue;const m=p.data??[],g=n.generateColumnsFromSchema(m.length>0?Object.keys(m[0]):[]),k=n.fieldOptionsFromColumns(l.columns??g),S=new Set,b=[];for(const _ of k)S.has(_.id)||(S.add(_.id),b.push(_));o[l.dataSourceId]=b}return o}var ne=0;function ce(){return ne+=1,`widget-${Date.now()}-${ne}`}function ue(){return{version:1,name:"Untitled Dashboard",filters:null,widgets:[]}}function ze(a,t){const[o,l]=(0,r.useState)(a??ue),[p,m]=(0,r.useState)(null),[g,k]=(0,r.useState)(t?"view":"edit"),S=(0,r.useRef)(!1),b=(0,r.useCallback)(()=>{S.current=!0},[]),_=(0,r.useCallback)((h,f,I)=>{l(d=>{const w={id:ce(),title:`New ${h}`,componentType:h,dataSourceId:f,position:I};return{...d,widgets:[...d.widgets,w]}}),b()},[b]),v=(0,r.useCallback)(h=>{l(f=>{const I=he(6,3,f.widgets),d={id:ce(),position:I,...h.widget};return{...f,widgets:[...f.widgets,d]}}),b()},[b]),j=(0,r.useCallback)(h=>{l(f=>({...f,widgets:f.widgets.filter(I=>I.id!==h)})),m(f=>f===h?null:f),b()},[b]),R=(0,r.useCallback)((h,f)=>{l(I=>({...I,widgets:I.widgets.map(d=>{if(d.id!==h)return d;const w={...d,...f};if(f.dataSourceId&&f.dataSourceId!==d.dataSourceId){const W=n.propSchemaRegistry[d.componentType]??[];w.columns=void 0,w.componentProps=n.buildDefaultPropsFromSchema(W),w.filters=void 0,w.uiConfig=void 0}return w})})),b()},[b]),c=(0,r.useCallback)((h,f)=>{R(h,{position:f})},[R]),P=(0,r.useCallback)(h=>{m(h)},[]),G=o.widgets.find(h=>h.id===p)??null,O=(0,r.useCallback)(h=>{l(f=>({...f,name:h})),b()},[b]),s=(0,r.useCallback)(h=>{l(f=>({...f,filters:typeof h=="function"?h(f.filters):h})),b()},[b]),u=(0,r.useCallback)(h=>{l(h??ue()),m(null),S.current=!1},[]),B=(0,r.useCallback)(h=>{l(h),m(null),S.current=!1},[]);return{state:{config:o,selectedWidgetId:p,isDirty:S.current},mode:g,setMode:k,addWidget:_,addPrebuiltWidget:v,removeWidget:j,updateWidget:R,moveWidget:c,selectWidget:P,selectedWidget:G,setName:O,setFilters:s,resetConfig:u,loadConfig:B}}var i={"rst-dashboard-builder":"_rst-dashboard-builder_ukxxh_2","rst-dashboard-builder-sidebar":"_rst-dashboard-builder-sidebar_ukxxh_18","rst-dashboard-builder-sidebar-header":"_rst-dashboard-builder-sidebar-header_ukxxh_28","rst-dashboard-builder-sidebar-list":"_rst-dashboard-builder-sidebar-list_ukxxh_33","rst-dashboard-builder-widget-type-item":"_rst-dashboard-builder-widget-type-item_ukxxh_40","rst-dashboard-builder-widget-type-label":"_rst-dashboard-builder-widget-type-label_ukxxh_59","rst-dashboard-builder-widget-type-desc":"_rst-dashboard-builder-widget-type-desc_ukxxh_63","rst-dashboard-builder-main":"_rst-dashboard-builder-main_ukxxh_69","rst-dashboard-builder-toolbar":"_rst-dashboard-builder-toolbar_ukxxh_77","rst-dashboard-builder-toolbar-left":"_rst-dashboard-builder-toolbar-left_ukxxh_87","rst-dashboard-builder-toolbar-right":"_rst-dashboard-builder-toolbar-right_ukxxh_93","rst-dashboard-builder-name-input":"_rst-dashboard-builder-name-input_ukxxh_99","rst-dashboard-builder-name-display":"_rst-dashboard-builder-name-display_ukxxh_115","rst-dashboard-builder-view":"_rst-dashboard-builder-view_ukxxh_122","rst-dashboard-widget":"_rst-dashboard-widget_ukxxh_146","rst-switcher":"_rst-switcher_ukxxh_170","rst-dashboard-builder-canvas":"_rst-dashboard-builder-canvas_ukxxh_183","rst-dashboard-builder-grid":"_rst-dashboard-builder-grid_ukxxh_191","rst-dashboard-builder-grid-cell":"_rst-dashboard-builder-grid-cell_ukxxh_201","rst-dashboard-builder-grid-cell-view":"_rst-dashboard-builder-grid-cell-view_ukxxh_213","rst-dashboard-builder-grid-empty":"_rst-dashboard-builder-grid-empty_ukxxh_219","rst-dashboard-builder-widget":"_rst-dashboard-builder-widget_ukxxh_40","rst-dashboard-builder-widget-view":"_rst-dashboard-builder-widget-view_ukxxh_290","rst-dashboard-builder-widget-selected":"_rst-dashboard-builder-widget-selected_ukxxh_298","rst-dashboard-builder-widget-dragging":"_rst-dashboard-builder-widget-dragging_ukxxh_304","rst-dashboard-builder-widget-collision":"_rst-dashboard-builder-widget-collision_ukxxh_310","rst-dashboard-builder-resize-handle-n":"_rst-dashboard-builder-resize-handle-n_ukxxh_317","rst-dashboard-builder-resize-handle-s":"_rst-dashboard-builder-resize-handle-s_ukxxh_318","rst-dashboard-builder-resize-handle-e":"_rst-dashboard-builder-resize-handle-e_ukxxh_319","rst-dashboard-builder-resize-handle-w":"_rst-dashboard-builder-resize-handle-w_ukxxh_320","rst-dashboard-builder-resize-handle-ne":"_rst-dashboard-builder-resize-handle-ne_ukxxh_321","rst-dashboard-builder-resize-handle-nw":"_rst-dashboard-builder-resize-handle-nw_ukxxh_322","rst-dashboard-builder-resize-handle-se":"_rst-dashboard-builder-resize-handle-se_ukxxh_323","rst-dashboard-builder-resize-handle-sw":"_rst-dashboard-builder-resize-handle-sw_ukxxh_324","rst-dashboard-builder-filter-body":"_rst-dashboard-builder-filter-body_ukxxh_540","rst-dashboard-builder-filter-tabs":"_rst-dashboard-builder-filter-tabs_ukxxh_548","rst-dashboard-builder-configurator":"_rst-dashboard-builder-configurator_ukxxh_557","rst-dashboard-builder-configurator-header":"_rst-dashboard-builder-configurator-header_ukxxh_567","rst-dashboard-builder-configurator-body":"_rst-dashboard-builder-configurator-body_ukxxh_575","rst-dashboard-builder-configurator-empty":"_rst-dashboard-builder-configurator-empty_ukxxh_582","rst-dashboard-builder-configurator-divider":"_rst-dashboard-builder-configurator-divider_ukxxh_593","rst-dashboard-builder-field":"_rst-dashboard-builder-field_ukxxh_599","rst-dashboard-builder-field-label":"_rst-dashboard-builder-field-label_ukxxh_605","rst-dashboard-builder-checkbox-row":"_rst-dashboard-builder-checkbox-row_ukxxh_611","rst-dashboard-builder-checkbox-label":"_rst-dashboard-builder-checkbox-label_ukxxh_618","rst-dashboard-builder-drag-ghost":"_rst-dashboard-builder-drag-ghost_ukxxh_624","rst-dashboard-builder-drop-zone":"_rst-dashboard-builder-drop-zone_ukxxh_638","rst-dashboard-builder-add-widget-item":"_rst-dashboard-builder-add-widget-item_ukxxh_646","rst-dashboard-builder-add-widget-item-label":"_rst-dashboard-builder-add-widget-item-label_ukxxh_667","rst-dashboard-builder-add-widget-item-desc":"_rst-dashboard-builder-add-widget-item-desc_ukxxh_673","rst-dashboard-builder-template-wrapper":"_rst-dashboard-builder-template-wrapper_ukxxh_679","rst-dashboard-builder-template-picker":"_rst-dashboard-builder-template-picker_ukxxh_683","rst-dashboard-builder-template-picker-header":"_rst-dashboard-builder-template-picker-header_ukxxh_697","rst-dashboard-builder-template-item":"_rst-dashboard-builder-template-item_ukxxh_705","rst-dashboard-builder-template-item-name":"_rst-dashboard-builder-template-item-name_ukxxh_727","rst-dashboard-builder-template-item-desc":"_rst-dashboard-builder-template-item-desc_ukxxh_733"},J=12,ae=30,te=12;function Re({widgets:a,onMoveWidget:t,onAddWidget:o,onChange:l}){const p=(0,r.useRef)(null),[m,g]=(0,r.useState)(null),[k,S]=(0,r.useState)(null),[b,_]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[R,c]=(0,r.useState)(!1),[P,G]=(0,r.useState)(null),[O,s]=(0,r.useState)(null),[u,B]=(0,r.useState)(null),[h,f]=(0,r.useState)(null),[I,d]=(0,r.useState)(!1),w=(0,r.useCallback)(()=>p.current?{colWidth:(p.current.getBoundingClientRect().width-te*(J-1))/J,rowHeight:92}:null,[]),W=(0,r.useCallback)((C,M)=>{if(!p.current)return{col:1,row:1};const z=p.current.getBoundingClientRect(),D=(z.width-te*(J-1))/J;return{col:Math.max(1,Math.min(J,Math.round((C-z.left)/(D+te))+1)),row:Math.max(1,Math.min(ae,Math.round((M-z.top)/92)+1))}},[]),Q=(0,r.useCallback)(C=>{if(C.preventDefault(),C.dataTransfer.types.includes("application/widget-type")){C.dataTransfer.dropEffect="copy";return}if(C.dataTransfer.types.includes("application/move-widget")&&m&&k&&b){C.dataTransfer.dropEffect="move";const M=a.find(E=>E.id===m);if(!M)return;const z=w();if(!z)return;const D=C.clientX-k.x,L=C.clientY-k.y,re=Math.round(D/(z.colWidth+te)),q=Math.round(L/z.rowHeight),H={col:Math.max(1,Math.min(J-M.position.w+1,b.col+re)),row:Math.max(1,Math.min(ae-M.position.h+1,b.row+q)),w:M.position.w,h:M.position.h};j(H);const T=oe(H,a,m);c(T!==null)}},[m,k,b,w,a]),Z=(0,r.useCallback)(C=>{C.preventDefault();const M=C.dataTransfer.getData("application/widget-type");if(M){const{col:z,row:D}=W(C.clientX,C.clientY),L={col:z,row:D,w:4,h:3};if(z+4-1>J&&(L.col=9),D+3-1>ae&&(L.row=28),oe(L,a))return;o(M,"",L),l();return}m&&v&&(!R&&ie(v)&&(t(m,v),l()),g(null),S(null),_(null),j(null),c(!1))},[W,a,o,l,m,v,R,t]),U=(0,r.useCallback)((C,M)=>{C.stopPropagation(),C.dataTransfer.setData("application/move-widget",M.id),C.dataTransfer.effectAllowed="move",g(M.id),S({x:C.clientX,y:C.clientY}),_({...M.position}),j({...M.position}),c(!1)},[]),y=(0,r.useCallback)(()=>{g(null),S(null),_(null),j(null),c(!1)},[]),se=(0,r.useCallback)((C,M,z)=>{C.stopPropagation(),C.preventDefault(),G(M.id),s(z),B({...M.position}),f({x:C.clientX,y:C.clientY}),d(!1)},[]);return(0,r.useEffect)(()=>{if(!P||!O||!u||!h)return;const C=z=>{if(!a.find(N=>N.id===P))return;const D=w();if(!D)return;const L=z.clientX-h.x,re=z.clientY-h.y,q=Math.round(L/(D.colWidth+te)),H=Math.round(re/D.rowHeight),T=u.col,E=u.row,Y=u.w,K=u.h;let F={...u};switch(O){case"e":{const N=Math.max(1,Math.min(J-T+1,Y+q));F={...F,w:N};break}case"w":{const N=Math.max(1,Math.min(T+Y-1,T+q)),A=T+Y-N;F={...u,col:N,w:Math.max(1,A)};break}case"s":{const N=Math.max(1,Math.min(ae-E+1,K+H));F={...u,h:N};break}case"n":{const N=Math.max(1,Math.min(E+K-1,E+H)),A=E+K-N;F={...u,row:N,h:Math.max(1,A)};break}case"se":{const N=Math.max(1,Math.min(J-T+1,Y+q)),A=Math.max(1,Math.min(ae-E+1,K+H));F={...u,w:N,h:A};break}case"sw":{const N=Math.max(1,Math.min(T+Y-1,T+q)),A=T+Y-N,x=Math.max(1,Math.min(ae-E+1,K+H));F={...u,col:N,w:Math.max(1,A),h:x};break}case"ne":{const N=Math.max(1,Math.min(E+K-1,E+H)),A=E+K-N,x=Math.max(1,Math.min(J-T+1,Y+q));F={...u,row:N,h:Math.max(1,A),w:x};break}case"nw":{const N=Math.max(1,Math.min(T+Y-1,T+q)),A=Math.max(1,Math.min(E+K-1,E+H)),x=T+Y-N,$=E+K-A;F={col:N,row:A,w:Math.max(1,x),h:Math.max(1,$)};break}}j(F),g(P);const le=oe(F,a,P);d(le!==null),c(le!==null)},M=()=>{a.find(z=>z.id===P)&&v&&!I&&ie(v)&&(t(P,v),l()),G(null),s(null),B(null),f(null),d(!1),g(null),S(null),_(null),j(null),c(!1)};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",M),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",M)}},[P,O,u,h,a,v,I,w,t,l]),{gridRef:p,draggingWidgetId:m,dragPreviewPos:v,hasCollision:R,resizeCollision:I,handleDragOver:Q,handleDrop:Z,handleWidgetDragStart:U,handleWidgetDragEnd:y,handleResizeStart:se,pixelToGrid:W}}var Ie=12,Ee=20,me=({widgets:a,selectedWidgetId:t,dataSources:o,onSelectWidget:l,onMoveWidget:p,onRemoveWidget:m,onAddWidget:g,onChange:k,getWidgetActions:S,mode:b="edit"})=>{const _=b==="view",{gridRef:v,draggingWidgetId:j,dragPreviewPos:R,hasCollision:c,handleDragOver:P,handleDrop:G,handleWidgetDragStart:O,handleWidgetDragEnd:s,handleResizeStart:u}=Re({widgets:a,onMoveWidget:p,onAddWidget:g,onChange:k}),B=(0,r.useCallback)((d,w)=>{d.stopPropagation(),l(w)},[l]),h=(0,r.useCallback)(()=>{l(null)},[l]),f=(0,r.useCallback)(d=>{const w=o[d.dataSourceId]?.data??[],W=w.length>0?Object.keys(w[0]):[];return{data:w,columns:d.columns??n.generateColumnsFromSchema(W)}},[o]),I=[];for(let d=1;d<=Ee;d++)for(let w=1;w<=Ie;w++){const W=_?i["rst-dashboard-builder-grid-cell-view"]:i["rst-dashboard-builder-grid-cell"];I.push((0,e.jsx)("div",{className:W,style:{gridColumn:w,gridRow:d}},`cell-${d}-${w}`))}return(0,e.jsx)("div",{className:i["rst-dashboard-builder-canvas"],onClick:h,children:(0,e.jsxs)("div",{ref:v,className:i["rst-dashboard-builder-grid"],onDragOver:P,onDrop:G,children:[I,a.length===0&&(0,e.jsx)("div",{className:i["rst-dashboard-builder-grid-empty"],children:"Drag a widget from the palette to get started"}),a.map(d=>{const w=!_&&d.id===t,W=!_&&d.id===j,Q=f(d),Z=W&&R?R:d.position,U=W&&c;return(0,e.jsxs)("div",{className:[i["rst-dashboard-builder-widget"],_?i["rst-dashboard-builder-widget-view"]:"",w?i["rst-dashboard-builder-widget-selected"]:"",W?i["rst-dashboard-builder-widget-dragging"]:"",U?i["rst-dashboard-builder-widget-collision"]:""].filter(Boolean).join(" "),style:{gridColumn:`${Z.col} / span ${Z.w}`,gridRow:`${Z.row} / span ${Z.h}`},draggable:!_,..._?{}:{onDragStart:y=>O(y,d),onDragEnd:s,onClick:y=>B(y,d.id),role:"button",tabIndex:0,"aria-label":`Widget: ${d.title}`,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),l(d.id)),(y.key==="Delete"||y.key==="Backspace")&&(y.preventDefault(),m(d.id),k())}},children:[(0,e.jsx)(n.DashboardWidget,{id:d.id,dataSourceId:d.dataSourceId,title:d.title,subtitle:d.subtitle,icon:d.icon,data:Q.data,columns:Q.columns,enableExport:S?.(d).enableExport??!0,enableScreenshot:S?.(d).enableScreenshot??!1,enableExpand:S?.(d).enableExpand??!0,enableFilter:S?.(d).enableFilter??!1,fieldOptions:n.fieldOptionsFromColumns(Q.columns),children:({data:y})=>(0,e.jsx)(n.Switcher,{data:y,columns:Q.columns,activeComponent:d.componentType,componentProps:d.componentProps,showConfigurator:!1})}),!_&&w&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-n"],onMouseDown:y=>u(y,d,"n")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-s"],onMouseDown:y=>u(y,d,"s")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-e"],onMouseDown:y=>u(y,d,"e")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-w"],onMouseDown:y=>u(y,d,"w")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-ne"],onMouseDown:y=>u(y,d,"ne")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-nw"],onMouseDown:y=>u(y,d,"nw")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-se"],onMouseDown:y=>u(y,d,"se")}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-resize-handle-sw"],onMouseDown:y=>u(y,d,"sw")})]})]},`${d.id}::${d.dataSourceId}`)})]})})};me.displayName="BuilderCanvas";var Pe=[{type:"table-grid",label:"Table",icon:"table",description:"Sortable, filterable data table"},{type:"chart",label:"Chart",icon:"chart",description:"Bar, line, pie charts"},{type:"calendar",label:"Calendar",icon:"calendar",description:"Calendar view of events"},{type:"card-list",label:"Card List",icon:"list",description:"Visual card layout"},{type:"form",label:"Form",icon:"form",description:"Editable form from schema"},{type:"gantt",label:"Gantt",icon:"chart-gantt",description:"Project timeline view"},{type:"kpi",label:"KPI",icon:"chart",description:"Single-metric KPI card"}],pe=({widget:a,dataSources:t,onUpdate:o,onRemove:l,onClose:p,onAddWidget:m,prebuiltSections:g,onAddPrebuiltSection:k})=>{const S=Object.values(t).map(s=>({value:s.id,label:s.name})),b=(0,r.useMemo)(()=>[{value:"",id:"none"},...Object.keys(n.svgAssets).map(s=>({value:s,leadingVisual:s}))],[]),_=a?.dataSourceId,v=(0,r.useMemo)(()=>{if(!_)return[];const s=t[_];return s?s.fields.map(u=>({id:u.id,header:u.name,accessorKey:u.id})):[]},[_,t]),j=(0,r.useMemo)(()=>n.propSchemaRegistry[a?.componentType??"table-grid"]??[],[a?.componentType]),R=(0,r.useMemo)(()=>a?.componentProps??n.buildDefaultPropsFromSchema(j),[a?.componentProps,j]),c=(0,r.useCallback)((s,u)=>{o({[s]:u})},[o]),P=(0,r.useCallback)(s=>{o({componentType:s,componentProps:n.buildDefaultPropsFromSchema(n.propSchemaRegistry[s]??[])})},[o]),G=(0,r.useCallback)((s,u)=>{o({componentProps:{...R,[s]:u}})},[R,o]),O=(0,r.useMemo)(()=>!g||g.length===0?[]:g.filter(s=>s.version===1),[g]);return a?(0,e.jsxs)("aside",{className:i["rst-dashboard-builder-configurator"],"aria-label":"Widget configurator",children:[(0,e.jsxs)("div",{className:i["rst-dashboard-builder-configurator-header"],children:[(0,e.jsx)(n.Typography,{variant:"heading",children:"Configure"}),(0,e.jsx)(n.Button,{variant:"invisible",size:"small",leadingVisual:"close",onClick:p,"aria-label":"Close configurator"})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-configurator-body"],children:[(0,e.jsxs)("div",{className:i["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:i["rst-dashboard-builder-field-label"],children:"Title"}),(0,e.jsx)(n.TextInput,{value:a.title,onChange:s=>c("title",s??""),placeholder:"Widget title"})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:i["rst-dashboard-builder-field-label"],children:"Subtitle"}),(0,e.jsx)(n.TextInput,{value:a.subtitle??"",onChange:s=>c("subtitle",s||void 0),placeholder:"Optional subtitle"})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:i["rst-dashboard-builder-field-label"],children:"Icon"}),(0,e.jsx)(n.Select,{value:a.icon??"",onChange:s=>c("icon",s||void 0),options:b,renderList:({options:s,value:u,onChange:B,onClose:h})=>(0,e.jsx)(n.List,{options:s,activeIndex:[typeof u=="string"?u:""],onClick:f=>{B(f.value),h()},showFilter:!0})})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:i["rst-dashboard-builder-field-label"],children:"Data Source"}),(0,e.jsx)(n.Select,{value:a.dataSourceId,onChange:s=>c("dataSourceId",s),options:S})]}),a.dataSourceId&&t[a.dataSourceId]&&(0,e.jsxs)("div",{className:i["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:i["rst-dashboard-builder-field-label"],children:"Columns"}),(0,e.jsx)(n.CheckboxGroup,{options:t[a.dataSourceId].fields.map(s=>({value:s.id,label:s.name})),value:a.columns?.map(s=>s.id).filter(Boolean)??t[a.dataSourceId].fields.map(s=>s.id),onChange:s=>{const u=t[a.dataSourceId],B=s.map(h=>u.fields.find(f=>f.id===h)).filter(Boolean).map(h=>({id:h.id,header:h.name,accessorKey:h.id}));o({columns:B.length===u.fields.length?void 0:B})}})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-field"],children:[(0,e.jsx)("label",{className:i["rst-dashboard-builder-field-label"],children:"Actions"}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(n.Checkbox,{checked:a.enableExport??!0,onChange:s=>c("enableExport",s)}),(0,e.jsx)("span",{className:i["rst-dashboard-builder-checkbox-label"],children:"Export CSV"})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(n.Checkbox,{checked:a.enableScreenshot??!1,onChange:s=>c("enableScreenshot",s)}),(0,e.jsx)("span",{className:i["rst-dashboard-builder-checkbox-label"],children:"Screenshot"})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(n.Checkbox,{checked:a.enableExpand??!0,onChange:s=>c("enableExpand",s)}),(0,e.jsx)("span",{className:i["rst-dashboard-builder-checkbox-label"],children:"Expand"})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-checkbox-row"],children:[(0,e.jsx)(n.Checkbox,{checked:a.enableFilter??!0,onChange:s=>c("enableFilter",s)}),(0,e.jsx)("span",{className:i["rst-dashboard-builder-checkbox-label"],children:"Filter"})]})]}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-configurator-divider"]}),(0,e.jsx)(n.DataComponentConfigurator,{schema:j,values:R,onChange:G,columns:v,scope:"all",componentId:a.componentType,onComponentChange:P,componentMetaList:n.dataComponentMetaList},a.dataSourceId??"no-ds"),(0,e.jsx)("div",{className:i["rst-dashboard-builder-configurator-divider"]}),(0,e.jsx)(n.Button,{variant:"danger",size:"small",value:"Remove widget",leadingVisual:"trash",onClick:l})]})]}):(0,e.jsxs)("aside",{className:i["rst-dashboard-builder-configurator"],"aria-label":"Add widget",children:[(0,e.jsx)("div",{className:i["rst-dashboard-builder-configurator-header"],children:(0,e.jsx)(n.Typography,{variant:"heading",children:"Add Widget"})}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-configurator-body"],children:[Pe.map(s=>(0,e.jsxs)("button",{className:i["rst-dashboard-builder-add-widget-item"],onClick:()=>m(s.type),children:[(0,e.jsx)(n.Icon,{src:s.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:i["rst-dashboard-builder-add-widget-item-label"],children:s.label}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-add-widget-item-desc"],children:s.description})]})]},s.type)),O.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:i["rst-dashboard-builder-configurator-divider"]}),(0,e.jsx)(n.Typography,{variant:"heading",children:"Pre-built Sections"}),O.map(s=>(0,e.jsxs)("button",{className:i["rst-dashboard-builder-add-widget-item"],onClick:()=>k?.(s),children:[(0,e.jsx)(n.Icon,{src:"layout"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:i["rst-dashboard-builder-add-widget-item-label"],children:s.name}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-add-widget-item-desc"],children:s.description})]})]},s.name))]})]})]})};pe.displayName="WidgetConfigurator";var xe=({dataSources:a,initialConfig:t,templates:o,prebuiltSections:l,onSave:p,onChange:m,widgetActionDefaults:g,readOnly:k,className:S})=>{const{state:b,mode:_,setMode:v,addWidget:j,addPrebuiltWidget:R,removeWidget:c,updateWidget:P,moveWidget:G,selectWidget:O,selectedWidget:s,setName:u,setFilters:B,loadConfig:h}=ze(t,k),[f,I]=(0,r.useState)(!1),[d,w]=(0,r.useState)("dialog"),[W,Q]=(0,r.useState)(null),[Z,U]=(0,r.useState)(null),[y,se]=(0,r.useState)(!1),[C,M]=(0,r.useState)(null),z=(0,r.useMemo)(()=>De(b.config.widgets,a),[b.config.widgets,a]),D=_==="view",L=D?Z:b.config.filters;(0,r.useEffect)(()=>{f&&M(L)},[f]);const re=(0,r.useCallback)(()=>{D?U(C):B(C),I(!1)},[C,D,B]);(0,r.useEffect)(()=>{D&&!y&&(U(b.config.filters),se(!0)),D||se(!1)},[D,y,b.config.filters]);const q=(0,r.useRef)(m);q.current=m;const H=(0,r.useCallback)((x,$)=>{(D?U:B)(ee=>({...ee??{},[x]:$}))},[D,B]),T=(0,r.useMemo)(()=>({filters:L,onFilterChange:H}),[L,H]),E=(0,r.useMemo)(()=>!o||o.length===0?[]:o.filter(x=>x.version===1),[o]),Y=(0,r.useMemo)(()=>E.map(x=>({value:x.name,id:x.name,description:x.description})),[E]),K=(0,r.useCallback)(x=>{const $=E.find(X=>X.name===x);if(!$)return;const ee={version:1,...$.config};h(ee)},[E,h]),F=(0,r.useMemo)(()=>({enableExport:g?.enableExport??!0,enableScreenshot:g?.enableScreenshot??!1,enableExpand:g?.enableExpand??!0,enableFilter:g?.enableFilter??!0}),[g]),le=(0,r.useCallback)(x=>({enableExport:x.enableExport??F.enableExport,enableScreenshot:x.enableScreenshot??F.enableScreenshot,enableExpand:x.enableExpand??F.enableExpand,enableFilter:x.enableFilter??F.enableFilter}),[F]);(0,r.useEffect)(()=>{q.current?.(b.config)},[b.config]);const N=[i["rst-dashboard-builder"],S].filter(Boolean).join(" "),A=(0,r.useCallback)(()=>{p(b.config)},[b.config,p]);return(0,e.jsx)("div",{className:N,children:(0,e.jsxs)("div",{className:i["rst-dashboard-builder-main"],children:[(0,e.jsxs)("div",{className:i["rst-dashboard-builder-toolbar"],children:[(0,e.jsxs)("div",{className:i["rst-dashboard-builder-toolbar-left"],children:[D?(0,e.jsx)("span",{className:i["rst-dashboard-builder-name-display"],children:b.config.name}):(0,e.jsx)("input",{className:i["rst-dashboard-builder-name-input"],type:"text",value:b.config.name,onChange:x=>u(x.target.value),placeholder:"Dashboard name","aria-label":"Dashboard name"}),Object.keys(z).length>0&&(0,e.jsx)(n.Button,{variant:"invisible",size:"small",leadingVisual:"filter",onClick:()=>I(x=>!x),"aria-label":"Toggle filter panel","aria-pressed":f})]}),(0,e.jsxs)("div",{className:i["rst-dashboard-builder-toolbar-right"],children:[E.length>0&&!D&&(0,e.jsx)(n.ButtonDropdown,{options:Y,onChange:K,placeholder:"Load Template",size:"small"}),!k&&(0,e.jsx)(n.ButtonGroup,{value:_,options:[{value:"edit"},{value:"view"}],onChange:x=>v(x)}),!D&&(0,e.jsx)(n.Button,{variant:"primary",size:"small",value:"Save",onClick:A})]})]}),(0,e.jsx)(n.DashboardContext,{value:T,children:(0,e.jsxs)("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[(0,e.jsx)(me,{mode:_,widgets:b.config.widgets,selectedWidgetId:b.selectedWidgetId,dataSources:a,onSelectWidget:O,onMoveWidget:G,onRemoveWidget:c,onAddWidget:j,onChange:()=>{},getWidgetActions:le}),f&&Object.keys(z).length>0&&(0,e.jsxs)(n.OverlayPanel,{open:f,variant:d,position:d==="dialog"?"center":"right",onClose:()=>I(!1),closeOnEscape:!0,closeOnClickOutside:d==="dialog",width:d==="sidepanel"?360:void 0,maxWidth:d==="dialog"?640:void 0,maxHeight:d==="dialog"?"80vh":void 0,"aria-label":"Dashboard filters",children:[(0,e.jsx)(n.OverlayPanel.Header,{title:"Filters",onClose:()=>I(!1),actions:(0,e.jsx)(n.Button,{variant:"invisible",size:"small",leadingVisual:d==="dialog"?"square-half":"open-center",onClick:()=>w(x=>x==="dialog"?"sidepanel":"dialog"),"aria-label":d==="dialog"?"Switch to side panel":"Switch to dialog"})}),(0,e.jsx)("div",{className:i["rst-dashboard-builder-filter-body"],children:(()=>{const x=Object.keys(z);if(x.length===0)return(0,e.jsx)("div",{style:{padding:"var(--rst-space-default)"},children:"No data sources to filter."});const $=W&&x.includes(W)?W:x[0],ee=C?.[$]??n.emptyFilterGroup();return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:i["rst-dashboard-builder-filter-tabs"],children:x.map(X=>(0,e.jsx)(n.Button,{value:X,variant:X===$?"base":"invisible",size:"small",onClick:()=>Q(X),children:X},X))}),(0,e.jsx)(n.FilterBuilder,{filters:ee,onChange:X=>M(_e=>({..._e??{},[$]:X.filters.length===0?null:X})),fieldOptions:z[$]})]})})()}),(0,e.jsxs)(n.OverlayPanel.Footer,{children:[(0,e.jsx)(n.Button,{variant:"invisible",size:"small",value:"Clear",onClick:()=>M({})}),(0,e.jsx)(n.Button,{variant:"primary",size:"small",value:"Apply",onClick:re})]})]}),!D&&(0,e.jsx)(pe,{widget:s,dataSources:a,onUpdate:x=>{s&&P(s.id,x)},onRemove:()=>{s&&c(s.id)},onClose:()=>O(null),onAddWidget:x=>{const $=Object.values(a)[0],ee=he(6,3,b.config.widgets);j(x,$?.id??"",ee)},prebuiltSections:l,onAddPrebuiltSection:x=>{R(x)}})]})})]})})};xe.displayName="DashboardBuilder";var de={"rst-border-beam":"_rst-border-beam_4g5sg_1","rst-border-beam-effect":"_rst-border-beam-effect_4g5sg_7","rst-border-beam-ring":"_rst-border-beam-ring_4g5sg_15","rst-border-beam-spin":"_rst-border-beam-spin_4g5sg_27","rst-border-beam-travel":"_rst-border-beam-travel_4g5sg_1"};function We(a){return[...a].filter(t=>t.color).map(t=>({...t,percent:Math.min(100,Math.max(0,t.percent))})).sort((t,o)=>t.percent-o.percent)}function Fe(a,t,o,l){const p=360/Math.max(1,l),m=2*(t+o);return m<=0||a<=0?Math.min(90,p):Math.min(a/m*360,p)}function Oe(a,t){const o=Math.max(0,Math.min(t,360)),l=We(a);return`conic-gradient(from 0deg, ${l.length?l.map(p=>`${p.color} ${p.percent/100*o}deg`).join(", "):"var(--rst-borderColor-focus) 0deg"}, transparent ${o}deg, transparent 360deg)`}var Be=[{color:"transparent",percent:0},{color:"var(--rst-borderColor-primary-default)",percent:70},{color:"var(--rst-borderColor-focus)",percent:100}],fe=({children:a,color:t=Be,count:o=1,duration:l=6,lineWidth:p=1,outset:m=0,inset:g=0,size:k=120,className:S,style:b,..._})=>{const v=(0,r.useRef)(null),[j,R]=(0,r.useState)({radius:"",width:0,height:0});(0,r.useEffect)(()=>{const s=v.current?.firstElementChild;if(!s||typeof ResizeObserver>"u")return;const u=new ResizeObserver(()=>{R({radius:getComputedStyle(s).borderTopLeftRadius,width:s.clientWidth,height:s.clientHeight})});return u.observe(s),()=>u.disconnect()},[]);const c=Math.max(1,Math.floor(o)),P=(0,r.useMemo)(()=>Oe(t,Fe(k,j.width,j.height,c)),[t,k,j.width,j.height,c]),G=360/c,O=Math.hypot(j.width+2*m,j.height+2*m);return(0,e.jsxs)("div",{ref:v,className:[de["rst-border-beam"],S].filter(Boolean).join(" "),style:{"--rst-border-beam-gradient":P,"--rst-border-beam-duration":`${l}s`,"--rst-border-beam-line-width":`${p}px`,"--rst-border-beam-outset":`${m}px`,"--rst-border-beam-inset":`${g}px`,...O>0?{"--rst-border-beam-diagonal":`${O}px`}:{},...j.radius?{"--rst-border-beam-radius":j.radius}:{},...b},..._,children:[a,(0,e.jsx)("span",{className:de["rst-border-beam-effect"],"aria-hidden":"true",children:(0,e.jsx)("span",{className:de["rst-border-beam-ring"],children:Array.from({length:c},(s,u)=>(0,e.jsx)("span",{className:de["rst-border-beam-spin"],style:{"--rst-border-beam-offset":`${u*G}deg`}},u))})})]})};fe.displayName="BorderBeam";function Te(a){return a.filter(t=>t.type==="text").map(t=>t.text).join(" ").trim()}function Ae(a){return a.data??[]}function ge(a,t){return a.events?.includes(t)??!1}function $e({block:a,onBlockEvent:t}){const o=Ae(a),l=a.props??{};if(a.component==="form")return(0,e.jsx)(Ge,{block:a,onBlockEvent:t});if(a.component==="chart"){const p=l.height??16;return(0,e.jsx)(n.Chart,{data:o,columns:a.columns,type:l.type??"bar",xAxisColumn:l.xAxisColumn,yAxisColumns:l.yAxisColumns,series:l.series,title:l.title,subtitle:l.subtitle,showLegend:l.showLegend,showGrid:l.showGrid,height:p})}return a.component==="kpi"?(0,e.jsx)(n.KPI,{data:o[0]??{},columns:a.columns,layout:n.resolveKpiLayoutPreset(l.layout)}):a.component==="card-list"?(0,e.jsx)(n.CardList,{data:o,columns:a.columns,layout:n.resolveCardLayoutPreset(l.layout),onCardClick:ge(a,"action")?p=>t?.({blockId:a.id,component:"card-list",event:"action",handler:a.handler,values:p}):void 0}):(0,e.jsx)(n.TableGrid,{data:o,columns:a.columns,enableSorting:l.enableSorting!==!1,enableSelection:l.enableSelection===!0,showGrid:l.showGrid??"horizontal",columnSizing:"fixed",enableVirtualization:l.enableVirtualization!==!1})}function Ge({block:a,onBlockEvent:t}){const[o,l]=(0,r.useState)(!1);return ge(a,"submit")?(0,e.jsx)(n.Form,{data:a.data??[{}],columns:a.columns,labelAlign:"top",onSubmit:async p=>{l(!0);try{await t?.({blockId:a.id,component:"form",event:"submit",handler:a.handler,values:p})}finally{l(!1)}},actions:[{type:"submit",variant:"primary",value:"Submit",loading:o,disabled:o},{type:"reset",variant:"invisible",value:"Reset",disabled:o}]}):(0,e.jsx)(n.Form,{data:a.data??[{}],columns:a.columns})}var V={"rst-chat":"_rst-chat_12syz_1","rst-chat-empty":"_rst-chat-empty_12syz_9","rst-chat-messages":"_rst-chat-messages_12syz_19","rst-chat-message":"_rst-chat-message_12syz_19","rst-chat-message-user":"_rst-chat-message-user_12syz_33","rst-chat-message-assistant":"_rst-chat-message-assistant_12syz_37","rst-chat-bubble":"_rst-chat-bubble_12syz_41","rst-chat-bubble-user":"_rst-chat-bubble-user_12syz_51","rst-chat-bubble-assistant":"_rst-chat-bubble-assistant_12syz_56","rst-chat-text":"_rst-chat-text_12syz_63","rst-chat-block":"_rst-chat-block_12syz_68","rst-chat-block-title":"_rst-chat-block-title_12syz_76","rst-chat-processing":"_rst-chat-processing_12syz_80","rst-chat-composer":"_rst-chat-composer_12syz_84"};function Le({messages:a,isProcessing:t=!1,inputValue:o,onInputChange:l,onSubmit:p,onKeyDown:m,onBlockEvent:g,emptyStateText:k="Ask a question to get started.",inputPlaceholder:S="Ask something...",className:b,renderBlock:_}){const v=(0,r.useRef)(null);(0,r.useEffect)(()=>{const c=v.current;c&&(c.scrollTop=c.scrollHeight)},[a,t]);const j=t||o.trim().length===0,R=(c,P)=>c.type==="text"?(0,e.jsx)(n.Typography,{variant:"body",className:V["rst-chat-text"],children:c.text},P):(0,e.jsxs)("div",{className:V["rst-chat-block"],children:[c.block.meta?.title&&(0,e.jsx)(n.Typography,{variant:"label",className:V["rst-chat-block-title"],children:c.block.meta.title}),_?_(c.block):(0,e.jsx)($e,{block:c.block,onBlockEvent:g})]},c.block.id);return(0,e.jsxs)("div",{className:[V["rst-chat"],b].filter(Boolean).join(" "),children:[a.length===0?(0,e.jsx)("div",{className:V["rst-chat-empty"],children:(0,e.jsx)(n.Typography,{variant:"body",children:k})}):(0,e.jsxs)("div",{ref:v,className:V["rst-chat-messages"],role:"log","aria-live":"polite",children:[a.map(c=>(0,e.jsx)("article",{className:[V["rst-chat-message"],V[`rst-chat-message-${c.role}`]].join(" "),"aria-label":`${c.role==="user"?"You":"Assistant"}: ${Te(c.parts)}`,children:(0,e.jsx)("div",{className:[V["rst-chat-bubble"],V[`rst-chat-bubble-${c.role}`]].join(" "),children:c.parts.map(R)})},c.id)),t&&(0,e.jsx)("div",{className:V["rst-chat-processing"],children:(0,e.jsx)(n.Typography,{variant:"caption",children:"Working..."})})]}),(0,e.jsxs)("form",{className:V["rst-chat-composer"],onSubmit:c=>{c.preventDefault(),j||p()},children:[(0,e.jsx)(n.Textarea,{value:o,onChange:l,onKeyDown:m,placeholder:S,ariaLabel:"Message",rows:1,disabled:t}),(0,e.jsx)(n.Button,{type:"submit",variant:"primary",value:"Send",leadingVisual:"send",disabled:j})]})]})}exports.BorderBeam=fe;exports.ChatSurface=Le;exports.DASHBOARD_CONFIG_VERSION=Me;exports.DashboardBuilder=xe;exports.PipContainer=Ce;exports.usePip=Se;
|
package/dist/experimental.d.ts
CHANGED
|
@@ -1,4 +1,79 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { HTMLAttributes, ReactNode, KeyboardEvent } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Size requested for a picture-in-picture window, in CSS pixels; omitted values use the browser default.
|
|
6
|
+
*/
|
|
7
|
+
interface PipWindowOptions {
|
|
8
|
+
/** Initial width of the picture-in-picture window. */
|
|
9
|
+
width?: number;
|
|
10
|
+
/** Initial height of the picture-in-picture window. */
|
|
11
|
+
height?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Options for {@link usePip}. */
|
|
14
|
+
interface UsePipOptions extends PipWindowOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Copies the opener document's stylesheets and root attributes into the window;
|
|
17
|
+
* without it components render unstyled.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
copyStyles?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** State and controls returned by {@link usePip}. */
|
|
23
|
+
interface UsePipResult {
|
|
24
|
+
/** The open picture-in-picture window, or `null` when the window is closed. */
|
|
25
|
+
pipWindow: Window | null;
|
|
26
|
+
/**
|
|
27
|
+
* Why the last `open` failed, or `null` after a successful request.
|
|
28
|
+
* Chromium refuses the request outside a user gesture or a top-level context.
|
|
29
|
+
*/
|
|
30
|
+
error: string | null;
|
|
31
|
+
/** Whether a picture-in-picture window is currently open. */
|
|
32
|
+
isOpen: boolean;
|
|
33
|
+
/** Whether the current browser implements the Document Picture-in-Picture API. */
|
|
34
|
+
isSupported: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Opens the picture-in-picture window. Call it synchronously from a user gesture,
|
|
37
|
+
* otherwise browsers refuse the request and the promise resolves without opening anything.
|
|
38
|
+
*/
|
|
39
|
+
open: () => Promise<void>;
|
|
40
|
+
/** Closes the picture-in-picture window. Does nothing when no window is open. */
|
|
41
|
+
close: () => void;
|
|
42
|
+
}
|
|
43
|
+
/** Props for {@link PipContainer}. */
|
|
44
|
+
interface PipContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
45
|
+
/**
|
|
46
|
+
* The picture-in-picture window to render into, as returned by `usePip`.
|
|
47
|
+
* Nothing is rendered while this is `null`.
|
|
48
|
+
*/
|
|
49
|
+
pipWindow: Window | null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Renders its children inside a Document Picture-in-Picture window, portaled into its `document.body`.
|
|
54
|
+
*
|
|
55
|
+
* Nothing is rendered while `pipWindow` is `null`.
|
|
56
|
+
*/
|
|
57
|
+
declare const PipContainer: React__default.FC<PipContainerProps>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Opens a Document Picture-in-Picture window on demand and hands its document back as `pipWindow`.
|
|
61
|
+
*
|
|
62
|
+
* `open` must run inside a user gesture, so call it from a click handler rather than an effect.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const { pipWindow, isSupported, open } = usePip({ width: 420, height: 600 })
|
|
67
|
+
*
|
|
68
|
+
* return (
|
|
69
|
+
* <>
|
|
70
|
+
* <Button value="Open in picture-in-picture" disabled={!isSupported} onClick={open} />
|
|
71
|
+
* <PipContainer pipWindow={pipWindow}>{content}</PipContainer>
|
|
72
|
+
* </>
|
|
73
|
+
* )
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function usePip({ width, height, copyStyles }?: UsePipOptions): UsePipResult;
|
|
2
77
|
|
|
3
78
|
/** Interface for an option in a component */
|
|
4
79
|
interface Option {
|
|
@@ -98,7 +173,7 @@ interface BaseTypographyProps {
|
|
|
98
173
|
/**
|
|
99
174
|
* Prefer children when rendering rich/nested content
|
|
100
175
|
*/
|
|
101
|
-
children?:
|
|
176
|
+
children?: React__default.ReactNode;
|
|
102
177
|
variant: TypographyVariant;
|
|
103
178
|
/**
|
|
104
179
|
* Flag to indicate if the component is disabled.
|
|
@@ -177,9 +252,8 @@ interface ProgressBarProps {
|
|
|
177
252
|
}
|
|
178
253
|
|
|
179
254
|
/**
|
|
180
|
-
* Maps each CellType to the component
|
|
181
|
-
*
|
|
182
|
-
* the underlying component actually understands.
|
|
255
|
+
* Maps each CellType to the component props accepted by `uiVariant`, so TypeScript
|
|
256
|
+
* only allows props the underlying component understands.
|
|
183
257
|
*/
|
|
184
258
|
type CellUIVariantMap = {
|
|
185
259
|
[K in CellType]: K extends "IMAGE" ? Partial<Omit<IconProps, "src">> : K extends "TAG" ? Partial<{
|
|
@@ -209,10 +283,8 @@ type LookupCellType<TData, TColumns extends readonly DataStructureColumn<TData>[
|
|
|
209
283
|
/** Comparison operators for AST-like UI rules */
|
|
210
284
|
type UIRuleOperator = "==" | "!=" | ">" | ">=" | "<" | "<=" | "includes" | "startsWith" | "endsWith" | "isEmpty" | "isNotEmpty";
|
|
211
285
|
/**
|
|
212
|
-
* A
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* When `field` and `op` are omitted, the rule always matches (static styling).
|
|
286
|
+
* A declarative styling rule evaluated against a row, compiled once into a fast
|
|
287
|
+
* evaluator. Omitting `field` and `op` makes it a static rule that always matches.
|
|
216
288
|
*
|
|
217
289
|
* @example conditional
|
|
218
290
|
* { field: "price", op: ">", value: 100, uiVariant: { color: "var(--rst-color-success)", fontWeight: "bold" } }
|
|
@@ -282,17 +354,13 @@ interface DataStructureColumn<TData, TValue = TData[keyof TData]> {
|
|
|
282
354
|
/** Helper text shown below the field (e.g. "Opzionale", "Usa +/− per il segno"). */
|
|
283
355
|
helperText?: string;
|
|
284
356
|
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
* referenced by `cellType` (e.g. ChartProps for CHART, TableGridProps for TABLE_GRID).
|
|
288
|
-
* `data` and `columns` are excluded — they come from the cell value and schema.
|
|
357
|
+
* Column-level config for the component named by `cellType` (e.g. ChartProps for
|
|
358
|
+
* CHART). `data` and `columns` are excluded — they come from the cell value and schema.
|
|
289
359
|
*/
|
|
290
360
|
columnConfig?: Record<string, unknown>;
|
|
291
361
|
/**
|
|
292
|
-
* Called when an interactive cell (e.g. BUTTON
|
|
293
|
-
*
|
|
294
|
-
* action id (for BUTTON = `option.value`). Works in any data-component
|
|
295
|
-
* that renders Cell in display mode (CardList, TableGrid, …).
|
|
362
|
+
* Called when an interactive cell (e.g. BUTTON) fires an action; the first argument
|
|
363
|
+
* is the action id (for BUTTON, `option.value`).
|
|
296
364
|
*/
|
|
297
365
|
onCellClick?: (actionId: string, rowData: TData, column: DataStructureColumn<TData, TValue>) => void;
|
|
298
366
|
}
|
|
@@ -396,11 +464,8 @@ interface DashboardTemplate {
|
|
|
396
464
|
config: Omit<DashboardConfig, "version">;
|
|
397
465
|
}
|
|
398
466
|
/**
|
|
399
|
-
* A pre-
|
|
400
|
-
*
|
|
401
|
-
* can click to add to the canvas without manual configuration.
|
|
402
|
-
*
|
|
403
|
-
* Appears in the "Add Widget" panel below the generic widget types.
|
|
467
|
+
* A pre-configured widget (data source, columns, title, component type) offered in the
|
|
468
|
+
* "Add Widget" panel below the generic widget types, ready to drop on the canvas.
|
|
404
469
|
*/
|
|
405
470
|
interface PrebuiltSection {
|
|
406
471
|
/** Must match DASHBOARD_CONFIG_VERSION to be loadable */
|
|
@@ -471,16 +536,124 @@ interface DashboardBuilderState {
|
|
|
471
536
|
}
|
|
472
537
|
|
|
473
538
|
/**
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
*
|
|
481
|
-
|
|
539
|
+
* Visual, Notion-style dashboard configurator with an edit mode (palette, canvas,
|
|
540
|
+
* configurator) and a view mode that renders the real components. Produces a serializable `DashboardConfig`.
|
|
541
|
+
*/
|
|
542
|
+
declare const DashboardBuilder: React__default.FC<DashboardBuilderProps>;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* One stop of the beam gradient, positioned along the beam arc.
|
|
546
|
+
*/
|
|
547
|
+
interface BorderBeamColorStop {
|
|
548
|
+
/** Any CSS color, including a `var(--rst-*)` token reference. */
|
|
549
|
+
color: string;
|
|
550
|
+
/** Offset along the beam arc, from `0` (tail) to `100` (head). */
|
|
551
|
+
percent: number;
|
|
552
|
+
}
|
|
553
|
+
/** Props for {@link BorderBeam}. */
|
|
554
|
+
interface BorderBeamProps extends Omit<HTMLAttributes<HTMLDivElement>, "color"> {
|
|
555
|
+
/** Content to wrap; its border radius is detected automatically. */
|
|
556
|
+
children?: ReactNode;
|
|
557
|
+
/** Gradient stops for the beam. Defaults to the primary info gradient. */
|
|
558
|
+
color?: BorderBeamColorStop[];
|
|
559
|
+
/** Number of beams traveling the border. @default 1 */
|
|
560
|
+
count?: number;
|
|
561
|
+
/** Seconds taken by one full revolution. @default 6 */
|
|
562
|
+
duration?: number;
|
|
563
|
+
/** Beam thickness in pixels. @default 1 */
|
|
564
|
+
lineWidth?: number;
|
|
565
|
+
/** Distance in pixels the beam sits outside the border. @default 0 */
|
|
566
|
+
outset?: number;
|
|
567
|
+
/** Distance in pixels the beam sits inside the border. @default 0 */
|
|
568
|
+
inset?: number;
|
|
569
|
+
/** Beam arc length in pixels. @default 120 */
|
|
570
|
+
size?: number;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Paints an animated beam around its children's border. Decorative only:
|
|
575
|
+
* it never replaces the focus ring, a validation border or status feedback.
|
|
576
|
+
*/
|
|
577
|
+
declare const BorderBeam: React__default.FC<BorderBeamProps>;
|
|
578
|
+
|
|
579
|
+
interface FormColumn<TData> extends DataStructureColumn<TData> {
|
|
580
|
+
/** Optional: custom message when required validation fails */
|
|
581
|
+
requiredMessage?: string;
|
|
582
|
+
/** Optional: custom validation function */
|
|
583
|
+
validate?: (value: TData[keyof TData], rowData: TData) => string | undefined;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** Components the chat can render inside an assistant message. */
|
|
587
|
+
type ChatBlockComponent = "table-grid" | "chart" | "form" | "kpi" | "card-list";
|
|
588
|
+
/** Interactions a block can opt into. Only declared events are wired. */
|
|
589
|
+
type ChatBlockEventType = "submit" | "action";
|
|
590
|
+
/**
|
|
591
|
+
* A data-only descriptor for one rendered component. `props` holds component-specific
|
|
592
|
+
* options (chart type, axis columns, layout preset id) and is passed through as-is.
|
|
593
|
+
*/
|
|
594
|
+
interface ChatBlock {
|
|
595
|
+
/** Stable key; also echoed back in `ChatBlockEventPayload`. */
|
|
596
|
+
id: string;
|
|
597
|
+
component: ChatBlockComponent;
|
|
598
|
+
/** Rows for table-grid / chart / card-list; a single row for kpi / form defaults. */
|
|
599
|
+
data?: Record<string, unknown>[];
|
|
600
|
+
/** `FormColumn` extends `DataStructureColumn`, so one type serves every block. */
|
|
601
|
+
columns?: FormColumn<Record<string, unknown>>[];
|
|
602
|
+
props?: Record<string, unknown>;
|
|
603
|
+
/** Events this block opts into. */
|
|
604
|
+
events?: ChatBlockEventType[];
|
|
605
|
+
/** Host-side command forwarded with every event, e.g. "create_order". */
|
|
606
|
+
handler?: string;
|
|
607
|
+
meta?: {
|
|
608
|
+
title?: string;
|
|
609
|
+
description?: string;
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
/** One rendered piece of a message: prose or a component block. */
|
|
613
|
+
type ChatPart = {
|
|
614
|
+
type: "text";
|
|
615
|
+
text: string;
|
|
616
|
+
} | {
|
|
617
|
+
type: "block";
|
|
618
|
+
block: ChatBlock;
|
|
619
|
+
};
|
|
620
|
+
interface ChatMessage {
|
|
621
|
+
id: string;
|
|
622
|
+
role: "user" | "assistant";
|
|
623
|
+
parts: ChatPart[];
|
|
624
|
+
}
|
|
625
|
+
/** Emitted when a rendered block interacts; the host owns the outcome. */
|
|
626
|
+
interface ChatBlockEventPayload {
|
|
627
|
+
blockId: string;
|
|
628
|
+
component: ChatBlockComponent;
|
|
629
|
+
event: ChatBlockEventType;
|
|
630
|
+
handler?: string;
|
|
631
|
+
/** Present for `submit` — the form values as submitted. */
|
|
632
|
+
values?: Record<string, unknown>;
|
|
633
|
+
}
|
|
634
|
+
interface ChatSurfaceProps {
|
|
635
|
+
messages: ChatMessage[];
|
|
636
|
+
isProcessing?: boolean;
|
|
637
|
+
inputValue: string;
|
|
638
|
+
onInputChange: (value: string) => void;
|
|
639
|
+
onSubmit: () => void;
|
|
640
|
+
onKeyDown?: ChatComposerKeyDown;
|
|
641
|
+
/** Called when a block interacts. Without it, blocks render read-only. */
|
|
642
|
+
onBlockEvent?: (payload: ChatBlockEventPayload) => void | Promise<void>;
|
|
643
|
+
emptyStateText?: string;
|
|
644
|
+
inputPlaceholder?: string;
|
|
645
|
+
className?: string;
|
|
646
|
+
/** Replaces the default block renderer for a given block. */
|
|
647
|
+
renderBlock?: (block: ChatBlock) => ReactNode;
|
|
648
|
+
}
|
|
649
|
+
/** Textarea keydown signature, aligned with `Textarea`'s `onKeyDown`. */
|
|
650
|
+
type ChatComposerKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Chat surface that renders assistant replies as parts — prose plus live Restio
|
|
654
|
+
* components — and routes block interactions back through `onBlockEvent`.
|
|
482
655
|
*/
|
|
483
|
-
declare
|
|
656
|
+
declare function ChatSurface({ messages, isProcessing, inputValue, onInputChange, onSubmit, onKeyDown, onBlockEvent, emptyStateText, inputPlaceholder, className, renderBlock, }: ChatSurfaceProps): React.JSX.Element;
|
|
484
657
|
|
|
485
|
-
export { DASHBOARD_CONFIG_VERSION, DashboardBuilder };
|
|
486
|
-
export type { DashboardBuilderProps, DashboardBuilderState, DashboardConfig, DashboardTemplate, DashboardWidgetConfig, DataSourceDefinition, DataSourceField, DataSourceRegistry, FieldFormat, PrebuiltSection, WidgetActionDefaults, WidgetComponentType, WidgetPosition, WidgetTypeDescriptor };
|
|
658
|
+
export { BorderBeam, ChatSurface, DASHBOARD_CONFIG_VERSION, DashboardBuilder, PipContainer, usePip };
|
|
659
|
+
export type { BorderBeamColorStop, BorderBeamProps, ChatBlock, ChatBlockComponent, ChatBlockEventPayload, ChatBlockEventType, ChatMessage, ChatPart, ChatSurfaceProps, DashboardBuilderProps, DashboardBuilderState, DashboardConfig, DashboardTemplate, DashboardWidgetConfig, DataSourceDefinition, DataSourceField, DataSourceRegistry, FieldFormat, PipContainerProps, PipWindowOptions, PrebuiltSection, UsePipOptions, UsePipResult, WidgetActionDefaults, WidgetComponentType, WidgetPosition, WidgetTypeDescriptor };
|