react-semaphor 0.1.129 → 0.1.131

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.
Files changed (29) hide show
  1. package/dist/chunks/{dashboard-controls-CdYJPicU.js → dashboard-controls-B2o_Ml98.js} +3 -3
  2. package/dist/chunks/{dashboard-controls-D9rqbD5g.js → dashboard-controls-CLmhjguK.js} +1 -1
  3. package/dist/chunks/dashboard-export-dialog-Ch0ElsMI.js +6 -0
  4. package/dist/chunks/{dashboard-export-dialog-DNF_PQZb.js → dashboard-export-dialog-DwkHS7L_.js} +196 -195
  5. package/dist/chunks/{dashboard-json-Dtshd-QS.js → dashboard-json-BPO_6NQh.js} +1 -1
  6. package/dist/chunks/{dashboard-json-xVrkPU1h.js → dashboard-json-DawmOBwK.js} +1 -1
  7. package/dist/chunks/edit-dashboard-visual-CE0f3H3D.js +195 -0
  8. package/dist/chunks/{edit-dashboard-visual-VEw_9V-L.js → edit-dashboard-visual-VH55I2qe.js} +1506 -1430
  9. package/dist/chunks/{editor-action-buttons-BFF_pszh.js → editor-action-buttons-BCRzk-0n.js} +2 -2
  10. package/dist/chunks/{editor-action-buttons-C3KskLE0.js → editor-action-buttons-BCX2a6QA.js} +1 -1
  11. package/dist/chunks/{index-vRQsO2Ki.js → index-BiG_2DRk.js} +9728 -9701
  12. package/dist/chunks/{index-Df1tIEqs.js → index-D3VnAyrW.js} +115 -115
  13. package/dist/chunks/{resource-management-panel-DBZxxjm6.js → resource-management-panel-CFSAxmG5.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-C2Ee-LoN.js → resource-management-panel-DAc7CcYm.js} +1 -1
  15. package/dist/chunks/{use-visual-utils-BMr6v4np.js → use-visual-utils-_KE2a0K6.js} +1 -1
  16. package/dist/chunks/{use-visual-utils-Cdg5yE9F.js → use-visual-utils-iLF6cWs6.js} +1 -1
  17. package/dist/dashboard/index.cjs +1 -1
  18. package/dist/dashboard/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/surfboard/index.cjs +1 -1
  22. package/dist/surfboard/index.js +1 -1
  23. package/dist/types/dashboard.d.ts +17 -0
  24. package/dist/types/main.d.ts +18 -1
  25. package/dist/types/surfboard.d.ts +17 -0
  26. package/dist/types/types.d.ts +17 -0
  27. package/package.json +1 -1
  28. package/dist/chunks/dashboard-export-dialog-BjqND5hL.js +0 -6
  29. package/dist/chunks/edit-dashboard-visual-YSsXOgAP.js +0 -195
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as a, Fragment as me } from "react/jsx-runtime";
2
- import { b as Ke, u as de, f as qe, an as ne, b4 as We, b5 as Ye, c as ee, b6 as Qe, aF as Xe, aG as Ze, B as J, aH as $e, aI as ke, aJ as Y, b7 as ce, L as ie, b8 as et, b9 as tt, ba as st, bb as Ne, bc as pe, bd as at, be as nt, I as it, bf as we, bg as re, bh as Ce, bi as ve, bj as rt, J as ye, R as Se, bk as Ve, aN as Ee, aO as Le, aP as Ae, aR as Te, aS as Oe, aT as Pe, aU as Re, aV as Ie, bl as ot, bm as lt, bn as Ue, bo as je, bp as Me, bq as dt, br as Fe, bs as ct, aD as ae, am as ut, bt as ht, bu as ze, bv as mt, bw as pt, ar as ft, as as gt, at as Dt, au as xt, av as Nt, aw as be, ax as ue, aA as bt, bx as wt, by as Ct, bz as vt, bA as yt } from "./index-vRQsO2Ki.js";
2
+ import { b as Ke, u as de, f as qe, an as ne, b4 as We, b5 as Ye, c as ee, b6 as Qe, aF as Xe, aG as Ze, B as J, aH as $e, aI as ke, aJ as Y, b7 as ce, L as ie, b8 as et, b9 as tt, ba as st, bb as Ne, bc as pe, bd as at, be as nt, I as it, bf as we, bg as re, bh as Ce, bi as ve, bj as rt, J as ye, R as Se, bk as Ve, aN as Ee, aO as Le, aP as Ae, aR as Te, aS as Oe, aT as Pe, aU as Re, aV as Ie, bl as ot, bm as lt, bn as Ue, bo as je, bp as Me, bq as dt, br as Fe, bs as ct, aD as ae, am as ut, bt as ht, bu as ze, bv as mt, bw as pt, ar as ft, as as gt, at as Dt, au as xt, av as Nt, aw as be, ax as ue, aA as bt, bx as wt, by as Ct, bz as vt, bA as yt } from "./index-BiG_2DRk.js";
3
3
  import St, { useState as g, useEffect as he } from "react";
4
- import { a as Be } from "./use-visual-utils-BMr6v4np.js";
4
+ import { a as Be } from "./use-visual-utils-_KE2a0K6.js";
5
5
  import { u as Vt } from "./use-click-outside-CMeO_QFI.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Df1tIEqs.js"),m=require("react"),re=require("./use-visual-utils-Cdg5yE9F.js"),ue=require("./use-click-outside-B9T3lmcw.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-D3VnAyrW.js"),m=require("react"),re=require("./use-visual-utils-iLF6cWs6.js"),ue=require("./use-click-outside-B9T3lmcw.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import { al as G, am as z, h as Y, i as J, an as K, e as _, g as X, u as U, ao as Z, ap as q, l as v, aq as ee, f as h } from "./index-vRQsO2Ki.js";
1
+ import { al as G, am as z, h as Y, i as J, an as K, e as _, g as X, u as U, ao as Z, ap as q, l as v, aq as ee, f as h } from "./index-BiG_2DRk.js";
2
2
  import { useState as T, useEffect as te, useCallback as V } from "react";
3
3
  function re(e) {
4
4
  const o = e.toUpperCase().indexOf("WHERE"), r = e.toUpperCase().indexOf("GROUP BY"), t = e.toUpperCase().indexOf("LIMIT"), i = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";const o=require("./index-Df1tIEqs.js"),b=require("react");function _(e){const a=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),t=e.toUpperCase().indexOf("LIMIT"),d=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(d!==-1&&(c=d),t!==-1&&t<c&&(c=t),a!==-1){const n=e.substring(0,a),s=e.substring(a);return`${n} {{ filters | where }} AND ${s.substring(6)}`}else if(r!==-1){const n=e.substring(0,r),s=e.substring(r);return`${n} {{ filters | where }} ${s}`}else{const n=e.substring(0,c),s=e.substring(c);return console.log("beforeClause",n),console.log("afterClause",s),s?`${n} {{ filters | where }} ${s}`:`${n.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,r]=b.useState(null),[t,d]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){r(null),d(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const m=await import(l);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");r(()=>m.useChartStore),d(null)}catch(s){const l=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",l),d(l),r(null)}})()},[e,c]),a}function H(e,a){if(e.length===0)return"";if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const c=t.split("__")[0],n=e.find(s=>s.tabTitle===c);return n?n.id:e[0].id}return a}}return e[0].id}async function j(e,a,r,t){if(!a||!r)throw new Error("Missing auth token or visual ID");const d=["resource-by-id","visual",r],c=t.getQueryData(d);if(c)return console.log("Using cached visual data for:",r),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",r);const n=o.ue.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`${e}/management/v1/visuals/${r}`,{headers:{Authorization:`Bearer ${a}`}});if(!s.ok)throw new Error("Failed to load visual");const l=await s.json();return t.setQueryData(d,l),o.ue.dismiss(n),{data:l,fromCache:!1}}catch(s){throw o.ue.dismiss(n),s}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Q(e,a){var c,n;const r=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!r)return!1;const t=T(r);if(!(t!=null&&t.cards)||t.cards.length===0)return!1;const d=(n=t.cards)==null?void 0:n.find(s=>s.id===t.activeCardId);return d?(o.setupEditorWithCard({...a,frame:t,card:d,visualId:(e==null?void 0:e.id)||t.visualId}),!0):!1}function G(){var g;const{setCardSql:e}=o.useEditorActions(),a=o.useEditorStore(i=>i.frame),r=o.useEditorStore(i=>i.card),t=B(((g=r.customCardPreferences)==null?void 0:g.url)||""),d=o.useEditorStore(i=>i.selectedSchemaName),c=o.useEditorStore(i=>i.selectedDatamodelId),n=o.useEditorStore(i=>i.selectedDatabaseName),s=o.useEditorStore(i=>i.selectedTableName),l=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),f=r.sql;return{getUpdatedFrame:b.useCallback(()=>{var E;let i=f;f&&!f.includes("{{")&&(i=_(f),e(i));const C=(E=t==null?void 0:t.getState())==null?void 0:E.settings,U={...r,dataSource:r.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:c,lastSelectedDatabase:n,lastSelectedTable:s,connectionId:l,sql:i,customCfg:m?r.customCfg:null,preferences:r.preferences,...C&&{customCardPreferences:{...r.customCardPreferences,settings:C}}},w=a.cards.map(S=>S.id===r.id?U:S);return{...a,cards:w,activeCardId:H(w,a.activeCardId)}},[r,a,m,d,c,n,s,l,e,t,f])}}function z(){const{authToken:e,tokenProps:a}=o.useSemaphorContext(),r=o.useQueryClient(),t=o.useSelectedVisual(),{selectVisual:d}=o.useManagementActions(),{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E}=o.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:$,setSelectedFrameId:v,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),D=o.useDashboardStore(u=>u.selectedFrameId),O=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),y=o.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),M=b.useCallback(async u=>{try{d(u),A();const{data:p,fromCache:h}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r);if(!Q(p,{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E,setIsDashboardEditing:S,setIsVisualEditing:$,dashboard:O,selectedSheetId:I,selectedFrameId:D,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:h}}catch(p){return console.error("Error editing visual:",p),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,c,n,S,$,s,l,m,f,V,g,i,C,U,w,E,A,O,I,D,x]),k=b.useCallback(async u=>{var p;try{if(d(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:h,fromCache:W}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r),L=(h==null?void 0:h.frameObject)??((p=h==null?void 0:h.visual)==null?void 0:p.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const F=T(L);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...o.cloneFrameWithNewIds(F),visualId:u.id};return N(I,P,"end"),S(!0),v(P.id),R(!1),{success:!0,fromCache:W}}catch(h){return console.error("Error adding visual:",h),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,I,N,S,v,R]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:M,handleAddLibraryVisual:k,getUpdatedFrame:G().getUpdatedFrame,refetch:y.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=z;
1
+ "use strict";const o=require("./index-D3VnAyrW.js"),b=require("react");function _(e){const a=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),t=e.toUpperCase().indexOf("LIMIT"),d=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(d!==-1&&(c=d),t!==-1&&t<c&&(c=t),a!==-1){const n=e.substring(0,a),s=e.substring(a);return`${n} {{ filters | where }} AND ${s.substring(6)}`}else if(r!==-1){const n=e.substring(0,r),s=e.substring(r);return`${n} {{ filters | where }} ${s}`}else{const n=e.substring(0,c),s=e.substring(c);return console.log("beforeClause",n),console.log("afterClause",s),s?`${n} {{ filters | where }} ${s}`:`${n.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,r]=b.useState(null),[t,d]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){r(null),d(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const m=await import(l);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");r(()=>m.useChartStore),d(null)}catch(s){const l=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",l),d(l),r(null)}})()},[e,c]),a}function H(e,a){if(e.length===0)return"";if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const c=t.split("__")[0],n=e.find(s=>s.tabTitle===c);return n?n.id:e[0].id}return a}}return e[0].id}async function j(e,a,r,t){if(!a||!r)throw new Error("Missing auth token or visual ID");const d=["resource-by-id","visual",r],c=t.getQueryData(d);if(c)return console.log("Using cached visual data for:",r),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",r);const n=o.ue.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`${e}/management/v1/visuals/${r}`,{headers:{Authorization:`Bearer ${a}`}});if(!s.ok)throw new Error("Failed to load visual");const l=await s.json();return t.setQueryData(d,l),o.ue.dismiss(n),{data:l,fromCache:!1}}catch(s){throw o.ue.dismiss(n),s}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Q(e,a){var c,n;const r=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!r)return!1;const t=T(r);if(!(t!=null&&t.cards)||t.cards.length===0)return!1;const d=(n=t.cards)==null?void 0:n.find(s=>s.id===t.activeCardId);return d?(o.setupEditorWithCard({...a,frame:t,card:d,visualId:(e==null?void 0:e.id)||t.visualId}),!0):!1}function G(){var g;const{setCardSql:e}=o.useEditorActions(),a=o.useEditorStore(i=>i.frame),r=o.useEditorStore(i=>i.card),t=B(((g=r.customCardPreferences)==null?void 0:g.url)||""),d=o.useEditorStore(i=>i.selectedSchemaName),c=o.useEditorStore(i=>i.selectedDatamodelId),n=o.useEditorStore(i=>i.selectedDatabaseName),s=o.useEditorStore(i=>i.selectedTableName),l=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),f=r.sql;return{getUpdatedFrame:b.useCallback(()=>{var E;let i=f;f&&!f.includes("{{")&&(i=_(f),e(i));const C=(E=t==null?void 0:t.getState())==null?void 0:E.settings,U={...r,dataSource:r.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:c,lastSelectedDatabase:n,lastSelectedTable:s,connectionId:l,sql:i,customCfg:m?r.customCfg:null,preferences:r.preferences,...C&&{customCardPreferences:{...r.customCardPreferences,settings:C}}},w=a.cards.map(S=>S.id===r.id?U:S);return{...a,cards:w,activeCardId:H(w,a.activeCardId)}},[r,a,m,d,c,n,s,l,e,t,f])}}function z(){const{authToken:e,tokenProps:a}=o.useSemaphorContext(),r=o.useQueryClient(),t=o.useSelectedVisual(),{selectVisual:d}=o.useManagementActions(),{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E}=o.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:$,setSelectedFrameId:v,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),D=o.useDashboardStore(u=>u.selectedFrameId),O=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),y=o.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),M=b.useCallback(async u=>{try{d(u),A();const{data:p,fromCache:h}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r);if(!Q(p,{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E,setIsDashboardEditing:S,setIsVisualEditing:$,dashboard:O,selectedSheetId:I,selectedFrameId:D,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:h}}catch(p){return console.error("Error editing visual:",p),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,c,n,S,$,s,l,m,f,V,g,i,C,U,w,E,A,O,I,D,x]),k=b.useCallback(async u=>{var p;try{if(d(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:h,fromCache:W}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r),L=(h==null?void 0:h.frameObject)??((p=h==null?void 0:h.visual)==null?void 0:p.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const F=T(L);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...o.cloneFrameWithNewIds(F),visualId:u.id};return N(I,P,"end"),S(!0),v(P.id),R(!1),{success:!0,fromCache:W}}catch(h){return console.error("Error adding visual:",h),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,I,N,S,v,R]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:M,handleAddLibraryVisual:k,getUpdatedFrame:G().getUpdatedFrame,refetch:y.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=z;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-Df1tIEqs.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-D3VnAyrW.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as a } from "../chunks/index-vRQsO2Ki.js";
1
+ import { D as a } from "../chunks/index-BiG_2DRk.js";
2
2
  import { EMPTY_SELECTION as e } from "../types/index.js";
3
3
  export {
4
4
  a as Dashboard,
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-Df1tIEqs.js"),S=require("./types/index.cjs"),a=require("react/jsx-runtime"),g=require("react"),j=require("./chunks/resource-management-panel-C2Ee-LoN.js"),u=require("./chunks/dashboard-export-dialog-BjqND5hL.js");require("react-dom");function P(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}return t.default=r,Object.freeze(t)}const C=P(g);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-D3VnAyrW.js"),S=require("./types/index.cjs"),a=require("react/jsx-runtime"),g=require("react"),j=require("./chunks/resource-management-panel-DAc7CcYm.js"),u=require("./chunks/dashboard-export-dialog-Ch0ElsMI.js");require("react-dom");function P(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}return t.default=r,Object.freeze(t)}const C=P(g);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { b as S, E as y, F as P, S as w, U as M, m as k, n as A, u as F, o as g, p as L, P as R, q as I, B as V, c as v, r as _, s as U, t as B, v as W, I as j, w as q, x as z, y as H, z as O, C as G } from "./chunks/index-vRQsO2Ki.js";
2
- import { Y as oa, Z as na, D as ta, M as ia, a1 as la, R as da, H as ca, H as ua, J as ha, a as pa, Q as fa, ak as ma, a8 as Ca, V as va, N as ba, O as Da, a2 as ga, aa as ya, a9 as xa, ad as Ea, ae as Na, a7 as Ta, T as Sa, a6 as Pa, $ as wa, a0 as Ma, _ as ka, ab as Aa, a5 as Fa, a4 as La, a3 as Ra, af as Ia, ac as Va, K as _a, ah as Ua, aj as Ba, ai as Wa, g as ja, W as qa, A as za, e as Ha, ag as Oa, f as Ga, G as Qa } from "./chunks/index-vRQsO2Ki.js";
1
+ import { b as S, E as y, F as P, S as w, U as M, m as k, n as A, u as F, o as g, p as L, P as R, q as I, B as V, c as v, r as _, s as U, t as B, v as W, I as j, w as q, x as z, y as H, z as O, C as G } from "./chunks/index-BiG_2DRk.js";
2
+ import { Y as oa, Z as na, D as ta, M as ia, a1 as la, R as da, H as ca, H as ua, J as ha, a as pa, Q as fa, ak as ma, a8 as Ca, V as va, N as ba, O as Da, a2 as ga, aa as ya, a9 as xa, ad as Ea, ae as Na, a7 as Ta, T as Sa, a6 as Pa, $ as wa, a0 as Ma, _ as ka, ab as Aa, a5 as Fa, a4 as La, a3 as Ra, af as Ia, ac as Va, K as _a, ah as Ua, aj as Ba, ai as Wa, g as ja, W as qa, A as za, e as Ha, ag as Oa, f as Ga, G as Qa } from "./chunks/index-BiG_2DRk.js";
3
3
  import { EMPTY_SELECTION as Ya } from "./types/index.js";
4
4
  import { jsx as a, jsxs as l } from "react/jsx-runtime";
5
5
  import * as p from "react";
6
6
  import { useMemo as Q } from "react";
7
- import { ResourceManagementPanel as Ja } from "./chunks/resource-management-panel-DBZxxjm6.js";
8
- import { A as Za, D as ae, S as ee, U as se, V as re, u as oe } from "./chunks/dashboard-export-dialog-DNF_PQZb.js";
7
+ import { ResourceManagementPanel as Ja } from "./chunks/resource-management-panel-CFSAxmG5.js";
8
+ import { A as Za, D as ae, S as ee, U as se, V as re, u as oe } from "./chunks/dashboard-export-dialog-DwkHS7L_.js";
9
9
  import "react-dom";
10
10
  /**
11
11
  * @license lucide-react v0.453.0 - ISC
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-Df1tIEqs.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-D3VnAyrW.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { a } from "../chunks/index-vRQsO2Ki.js";
1
+ import { a } from "../chunks/index-BiG_2DRk.js";
2
2
  import { EMPTY_SELECTION as E } from "../types/index.js";
3
3
  export {
4
4
  E as EMPTY_SELECTION,
@@ -1247,6 +1247,7 @@ export declare type TCardPreferences = {
1247
1247
  bulletConfig?: TBulletConfig;
1248
1248
  heatmapConfig?: THeatmapConfig;
1249
1249
  bubbleScatterConfig?: TBubbleScatterConfig;
1250
+ funnelConfig?: TFunnelConfig;
1250
1251
  tablePrefs?: TablePreferences;
1251
1252
  allowDownload?: boolean;
1252
1253
  customVisualCode?: string;
@@ -1487,6 +1488,22 @@ export declare type TFrame = {
1487
1488
  activeCardId: string;
1488
1489
  };
1489
1490
 
1491
+ export declare type TFunnelConfig = {
1492
+ /**
1493
+ * How to calculate percentage in tooltips and data labels.
1494
+ * - 'percentOfTotal': Each stage shows % of total sum (default/current behavior)
1495
+ * - 'percentOfFirst': First stage = 100%, others relative to first
1496
+ */
1497
+ percentMode?: TFunnelPercentMode;
1498
+ };
1499
+
1500
+ /**
1501
+ * Tooltip/data label percentage calculation mode for funnel charts.
1502
+ * - 'percentOfTotal': Percentage relative to sum of all values (default)
1503
+ * - 'percentOfFirst': Percentage relative to the first stage value (first stage = 100%)
1504
+ */
1505
+ export declare type TFunnelPercentMode = 'percentOfTotal' | 'percentOfFirst';
1506
+
1490
1507
  export declare type THeatmapConfig = {
1491
1508
  colorMode?: 'continuous' | 'stepped';
1492
1509
  steps?: number;
@@ -860,7 +860,7 @@ export declare type Dialect = 'mysql' | 'postgres' | 'bigquery' | 'redshift' | '
860
860
 
861
861
  export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
862
862
 
863
- export declare function downloadPdf(apiServiceUrl: string, password?: string, sheetSelection?: 'current' | 'all'): Promise<void>;
863
+ export declare function downloadPdf(apiServiceUrl: string, authToken: AuthToken | undefined, password?: string, sheetSelection?: 'current' | 'all'): Promise<void>;
864
864
 
865
865
  declare interface DrillActions {
866
866
  updateDrillHierarchies: (h: DrillHierarchy[]) => void;
@@ -2180,6 +2180,7 @@ export declare type TCardPreferences = {
2180
2180
  bulletConfig?: TBulletConfig;
2181
2181
  heatmapConfig?: THeatmapConfig;
2182
2182
  bubbleScatterConfig?: TBubbleScatterConfig;
2183
+ funnelConfig?: TFunnelConfig;
2183
2184
  tablePrefs?: TablePreferences;
2184
2185
  allowDownload?: boolean;
2185
2186
  customVisualCode?: string;
@@ -2422,6 +2423,22 @@ export declare type TFrame = {
2422
2423
  activeCardId: string;
2423
2424
  };
2424
2425
 
2426
+ export declare type TFunnelConfig = {
2427
+ /**
2428
+ * How to calculate percentage in tooltips and data labels.
2429
+ * - 'percentOfTotal': Each stage shows % of total sum (default/current behavior)
2430
+ * - 'percentOfFirst': First stage = 100%, others relative to first
2431
+ */
2432
+ percentMode?: TFunnelPercentMode;
2433
+ };
2434
+
2435
+ /**
2436
+ * Tooltip/data label percentage calculation mode for funnel charts.
2437
+ * - 'percentOfTotal': Percentage relative to sum of all values (default)
2438
+ * - 'percentOfFirst': Percentage relative to the first stage value (first stage = 100%)
2439
+ */
2440
+ export declare type TFunnelPercentMode = 'percentOfTotal' | 'percentOfFirst';
2441
+
2425
2442
  export declare type THeatmapConfig = {
2426
2443
  colorMode?: 'continuous' | 'stepped';
2427
2444
  steps?: number;
@@ -1252,6 +1252,7 @@ export declare type TCardPreferences = {
1252
1252
  bulletConfig?: TBulletConfig;
1253
1253
  heatmapConfig?: THeatmapConfig;
1254
1254
  bubbleScatterConfig?: TBubbleScatterConfig;
1255
+ funnelConfig?: TFunnelConfig;
1255
1256
  tablePrefs?: TablePreferences;
1256
1257
  allowDownload?: boolean;
1257
1258
  customVisualCode?: string;
@@ -1492,6 +1493,22 @@ export declare type TFrame = {
1492
1493
  activeCardId: string;
1493
1494
  };
1494
1495
 
1496
+ export declare type TFunnelConfig = {
1497
+ /**
1498
+ * How to calculate percentage in tooltips and data labels.
1499
+ * - 'percentOfTotal': Each stage shows % of total sum (default/current behavior)
1500
+ * - 'percentOfFirst': First stage = 100%, others relative to first
1501
+ */
1502
+ percentMode?: TFunnelPercentMode;
1503
+ };
1504
+
1505
+ /**
1506
+ * Tooltip/data label percentage calculation mode for funnel charts.
1507
+ * - 'percentOfTotal': Percentage relative to sum of all values (default)
1508
+ * - 'percentOfFirst': Percentage relative to the first stage value (first stage = 100%)
1509
+ */
1510
+ export declare type TFunnelPercentMode = 'percentOfTotal' | 'percentOfFirst';
1511
+
1495
1512
  export declare type THeatmapConfig = {
1496
1513
  colorMode?: 'continuous' | 'stepped';
1497
1514
  steps?: number;
@@ -1244,6 +1244,7 @@ export declare type TCardPreferences = {
1244
1244
  bulletConfig?: TBulletConfig;
1245
1245
  heatmapConfig?: THeatmapConfig;
1246
1246
  bubbleScatterConfig?: TBubbleScatterConfig;
1247
+ funnelConfig?: TFunnelConfig;
1247
1248
  tablePrefs?: TablePreferences;
1248
1249
  allowDownload?: boolean;
1249
1250
  customVisualCode?: string;
@@ -1484,6 +1485,22 @@ export declare type TFrame = {
1484
1485
  activeCardId: string;
1485
1486
  };
1486
1487
 
1488
+ export declare type TFunnelConfig = {
1489
+ /**
1490
+ * How to calculate percentage in tooltips and data labels.
1491
+ * - 'percentOfTotal': Each stage shows % of total sum (default/current behavior)
1492
+ * - 'percentOfFirst': First stage = 100%, others relative to first
1493
+ */
1494
+ percentMode?: TFunnelPercentMode;
1495
+ };
1496
+
1497
+ /**
1498
+ * Tooltip/data label percentage calculation mode for funnel charts.
1499
+ * - 'percentOfTotal': Percentage relative to sum of all values (default)
1500
+ * - 'percentOfFirst': Percentage relative to the first stage value (first stage = 100%)
1501
+ */
1502
+ export declare type TFunnelPercentMode = 'percentOfTotal' | 'percentOfFirst';
1503
+
1487
1504
  export declare type THeatmapConfig = {
1488
1505
  colorMode?: 'continuous' | 'stepped';
1489
1506
  steps?: number;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.129",
8
+ "version": "0.1.131",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,6 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),s=require("./index-Df1tIEqs.js"),w=require("./editor-action-buttons-C3KskLE0.js"),p=require("react"),F=require("./use-visual-utils-Cdg5yE9F.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const A=s.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function P({open:c,onOpenChange:i,isLibraryVisual:t,currentVisualName:r,isSaving:l=!1,onConfirm:h}){const[a,o]=p.useState(t&&r?`Copy of ${r}`:r||""),[n,g]=p.useState(""),[f,v]=p.useState(!t),[j,b]=p.useState(!0);p.useEffect(()=>{c&&(o(t&&r?`Copy of ${r}`:r||""),g(""),v(!t),b(!0))},[c,t,r]);const S=()=>{a.trim()&&(!f&&!j||h({name:a.trim(),description:n.trim()||void 0,saveToLibrary:f,saveToCurrentDashboard:j}))},d=a.trim()&&(f||j);return e.jsx(s.Dialog,{open:c,onOpenChange:i,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Save Visual As"}),e.jsx(s.DialogDescription,{children:t?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"name",children:"Name"}),e.jsx(s.Input,{id:"name",value:a,onChange:x=>o(x.target.value),placeholder:"Enter visual name",disabled:l})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:n,onChange:x=>g(x.target.value),placeholder:"Enter visual description",rows:3,disabled:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(s.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"save-to-dashboard",checked:j,onCheckedChange:x=>b(!!x),disabled:l}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"save-to-library",checked:f,onCheckedChange:x=>v(!!x),disabled:l}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!f&&!j&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>i(!1),disabled:l,children:"Cancel"}),e.jsxs(s.Button,{onClick:S,disabled:!d||l,children:[l&&e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Saving...":"Save"]})]})]})})}function k(){const[c,i]=p.useState(!1),[t,r]=p.useState(!1),[l,h]=p.useState(null),a=s.useEditorStore(u=>u.frame),o=s.useEditorStore(u=>u.card),n=s.useSelectedVisual(),g=s.useDashboardStore(u=>u.selectedSheetId),f=s.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),{getUpdatedFrame:v}=F.useVisualUtils(),{selectVisual:j}=s.useManagementActions(),{addFrame:b,setSelectedFrameId:S,setIsVisualEditing:d}=s.useDashboardActions(),x=!!(a!=null&&a.visualId),C=(()=>{var u,D;return((u=a==null?void 0:a.cards)==null?void 0:u.length)===1&&((D=a.cards[0])!=null&&D.title)?a.cards[0].title:n!=null&&n.title?n.title:(o==null?void 0:o.title)||"Untitled Visual"})(),m=s.useCreateVisualWithFrame(u=>{if(u!=null&&u.id){if(j(u),t&&l&&g){const D={...l,id:s.v4(),visualId:u.id};b(g,D,"end"),S(D.id),r(!1),h(null),d(!1)}f(!0),i(!1)}});return{saveAsDialogOpen:c,setSaveAsDialogOpen:i,handleSaveAs:async u=>{if(!g){s.ue.error("No sheet selected");return}const D=v(),N=D.cards.length===1?{...D,cards:D.cards.map(y=>({...y,title:u.name}))}:D;if(u.saveToLibrary){r(u.saveToCurrentDashboard),h(N);const y={title:u.name,description:u.description,frameObject:N,isPrivate:!1};m.mutate(y)}else if(u.saveToCurrentDashboard){const y={...N,id:s.v4(),visualId:void 0};b(g,y,"end"),S(y.id),s.ue.success("Visual saved to dashboard"),i(!1),d(!1)}},isLibraryVisual:x,currentVisualName:C,isSaving:m.isPending}}function I({className:c}){const i=s.useEditorStore(m=>m.frame),t=s.useEditorStore(m=>m.card),r=s.useManagementStore(m=>m.selectedVisual),l=s.useDashboardStore(m=>m.selectedFrameId),h=s.useDashboardStore(m=>m.selectedSheetId),{setIsVisualEditing:a}=s.useDashboardActions(),o=!!(i!=null&&i.visualId||r!=null&&r.id),n=!!(i!=null&&i.visualId&&l),g=o&&!n,{saveAsDialogOpen:f,setSaveAsDialogOpen:v,handleSaveAs:j,isLibraryVisual:b,currentVisualName:S,isSaving:d}=k(),{handleAddLibraryVisual:x}=F.useVisualUtils(),C=async()=>{if(!h){s.ue.error("No dashboard sheet selected");return}if(!r){s.ue.error("No visual selected");return}const m=await x(r);m.success?(s.ue.success("Visual added to dashboard"),a(!1)):s.ue.error(m.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!o&&e.jsx(w.EditorAcceptButton,{className:c,variant:"default"}),o&&e.jsxs(e.Fragment,{children:[n&&e.jsx(w.VisualApplyLocalButton,{className:c}),g&&h&&t&&(t.sql||s.hasValidCardConfig(t.config))&&e.jsxs(s.Button,{onClick:C,className:s.cn(c),size:"sm",variant:"outline",children:[e.jsx(A,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),g&&e.jsx(w.VisualSaveButton,{className:c,variant:"default"}),n&&e.jsx(w.VisualSaveAndApplyButton,{className:c}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:s.cn(c,"w-8 p-0"),children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsxs(s.DropdownMenuItem,{onClick:m=>{m.stopPropagation(),v(!0)},children:[e.jsx(w.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!o&&e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:s.cn(c,"w-8 p-0"),children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>v(!0),children:[e.jsx(w.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(w.EditorCancelButton,{className:c}),e.jsx(P,{open:f,onOpenChange:m=>{d||v(m)},isLibraryVisual:b,currentVisualName:S,isSaving:d,onConfirm:j})]})}function E({className:c,switchClassName:i}){const t=s.useEditorStore(o=>o.isDevMode),r=s.useDashboardStore(o=>o.isVisualEditing),{setIsDevMode:l}=s.useEditorActions(),{config:h}=p.useContext(s.SemaphorContext).tokenProps,a=(h==null?void 0:h.showAdvancedMode)!==!1;return!r||!a?null:e.jsxs("div",{className:s.cn("flex items-center space-x-2",c),children:[e.jsx(s.DevModeSwitch,{className:s.cn("",i),checked:t,onCheckedChange:()=>l(!t),id:"advanced-mode",icon:e.jsx(s.CodeXml,{className:"h-4 w-4"}),tooltip:t?"Standard Mode":"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function M({open:c,onOpenChange:i,onSave:t,onDiscard:r,isSaving:l}){const h=a=>{!a&&l||i(a)};return e.jsx(s.AlertDialog,{open:c,onOpenChange:h,children:e.jsxs(s.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(s.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(s.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(s.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(s.AlertDialogCancel,{disabled:l,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:r,disabled:l,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(s.AlertDialogAction,{onClick:t,disabled:l,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:l?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function V(c,i,t,r){p.useEffect(()=>{c&&!t&&i&&r(s.cloneDeep(i))},[c,t,i,r])}function T({triggerButtonClassName:c}){const[i,t]=p.useState(!1),r=s.useDashboardStore(o=>{var n;return(n=o.dashboard)==null?void 0:n.id}),l=s.useDashboardStore(o=>{var n;return(n=o.dashboard)==null?void 0:n.title}),h=s.useDashboardStore(o=>{var n;return(n=o.dashboard)==null?void 0:n.sheets}),a=s.useDashboardStore(o=>o.selectedSheetId);return h==null||h.find(o=>o.id===a),r?e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Schedule Dashboard",className:s.cn("h-7 p-2",c),onClick:()=>t(!0),children:e.jsx(s.Clock,{className:"size-4"})}),e.jsx(s.EmailScheduleDialog,{open:i,onOpenChange:t,dashboardId:r,dashboardName:l})]}):null}function B({open:c,onOpenChange:i}){const[t,r]=p.useState(!1),[l,h]=p.useState(!1),[a,o]=p.useState({sheetSelection:"current",protectPdf:!1,password:""}),n=s.useDashboardStore(d=>{var x;return(x=d.dashboard)==null?void 0:x.sheets}),g=s.useDashboardStore(d=>d.selectedSheetId),{tokenProps:f}=s.useSemaphorContext(),v=n==null?void 0:n.find(d=>d.id===g),j=((n==null?void 0:n.length)||0)>1,b=()=>{o({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),i(!1)};async function S(){if(a.protectPdf&&!a.password){s.ue.error("Please enter a password to protect the PDF");return}h(!0);const d=a.sheetSelection==="all"?"Generating PDF for all sheets... This may take a while.":a.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",x=s.ue.loading(d);try{await s.downloadPdf(f.apiServiceUrl,a.protectPdf?a.password:void 0,a.sheetSelection),s.ue.dismiss(x);const C=a.sheetSelection==="all"?"All sheets PDF downloaded successfully!":a.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";s.ue.success(C,{duration:2e3}),b()}catch(C){s.ue.dismiss(x),s.ue.error("Failed to download PDF",{description:"Please try again or contact support.",richColors:!0}),console.error("PDF download error:",C)}finally{h(!1)}}return e.jsx(s.Dialog,{open:c,onOpenChange:d=>{if(!d){b();return}i(!0)},children:e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Export Dashboard"}),e.jsx(s.DialogDescription,{children:"Export your dashboard as a PDF document."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[j&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Export Scope"}),e.jsxs(s.RadioGroup,{value:a.sheetSelection,onValueChange:d=>o({...a,sheetSelection:d}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"current",id:"scope-current"}),e.jsxs(s.Label,{htmlFor:"scope-current",className:"cursor-pointer font-normal",children:["This sheet (",(v==null?void 0:v.title)||"Current",")"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"all",id:"scope-all"}),e.jsxs(s.Label,{htmlFor:"scope-all",className:"cursor-pointer font-normal",children:["All sheets (",n==null?void 0:n.length," sheets)"]})]})]})]}),e.jsx(s.Separator,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"protect-pdf",checked:a.protectPdf,onCheckedChange:d=>{o({...a,protectPdf:d,password:d?a.password:""}),d||r(!1)}}),e.jsxs(s.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center text-sm font-normal",children:[e.jsx(s.Lock,{className:"mr-2 h-3.5 w-3.5"}),"Password protect PDF"]})]}),a.protectPdf&&e.jsxs("div",{className:"ml-6 space-y-2",children:[e.jsx(s.Label,{htmlFor:"pdf-password",className:"text-sm",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(s.Input$1,{id:"pdf-password",type:t?"text":"password",value:a.password,onChange:d=>o({...a,password:d.target.value}),placeholder:"Enter password",className:"pr-10",onKeyDown:d=>{d.key==="Enter"&&a.password&&S()}}),e.jsx(s.Button,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>r(!t),children:t?e.jsx(s.EyeOff,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(s.Eye,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will need this password to open the PDF"})]})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:b,disabled:l,children:"Cancel"}),e.jsx(s.Button,{onClick:S,disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Exporting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Download,{className:"mr-2 h-4 w-4"}),"Export"]})})]})]})})}exports.AdvancedModeToggle=E;exports.DashboardExportDialog=B;exports.ScheduleDashboard=T;exports.UnsavedChangesAlert=M;exports.VisualEditingControls=I;exports.usePristineSnapshotInitializer=V;