react-semaphor 0.1.281 → 0.1.282
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-controls-D3R8Z79V.js → dashboard-controls-B_F5f_BF.js} +4 -4
- package/dist/chunks/{dashboard-controls-CLd_NTpW.js → dashboard-controls-XX9__V-e.js} +1 -1
- package/dist/chunks/{dashboard-filter-controls-button-zj4HH2IS.js → dashboard-filter-controls-button-DVLBLHga.js} +60 -60
- package/dist/chunks/{dashboard-filter-controls-button-DLjcoN1G.js → dashboard-filter-controls-button-DZpvfXwU.js} +1 -1
- package/dist/chunks/{dashboard-json-CPyonfsi.js → dashboard-json-CexNQg-E.js} +1 -1
- package/dist/chunks/{dashboard-json-BcdeYcFr.js → dashboard-json-Dd9Q2bZm.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-Cpb9FCXf.js → dashboard-summary-settings-dialog-BjdrHb1l.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-BYQfaQGZ.js → dashboard-summary-settings-dialog-zdacBYZZ.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-NyBBQhsY.js → edit-dashboard-visual-Bi9pQx6G.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CsTmOttj.js → edit-dashboard-visual-DQts3aun.js} +2 -2
- package/dist/chunks/{index-DvAOngur.js → index-BY0YEY92.js} +223 -223
- package/dist/chunks/{index-CsX3UmQg.js → index-Bgn4zTsp.js} +25445 -24528
- package/dist/chunks/{resource-management-panel-BxJ99bHx.js → resource-management-panel--xIMLPdz.js} +2 -2
- package/dist/chunks/{resource-management-panel-lglhpWpc.js → resource-management-panel-w7afzaPB.js} +1 -1
- package/dist/chunks/use-create-flow-overlay-state-AsQy4tbh.js +21 -0
- package/dist/chunks/use-create-flow-overlay-state-COsIHnQp.js +1523 -0
- package/dist/chunks/{use-visual-utils-C7wVd3rs.js → use-visual-utils-BCWNcaWk.js} +1 -1
- package/dist/chunks/{use-visual-utils-C54WwvId.js → use-visual-utils-CI-7TNJI.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +9 -1
- package/dist/types/main.d.ts +9 -1
- package/dist/types/shared.d.ts +9 -1
- package/dist/types/surfboard.d.ts +9 -1
- package/dist/types/types.d.ts +9 -1
- package/package.json +1 -1
- package/dist/chunks/use-create-flow-overlay-state-BjV5Q6Lb.js +0 -1443
- package/dist/chunks/use-create-flow-overlay-state-BrmQZdh2.js +0 -21
package/dist/chunks/{resource-management-panel-BxJ99bHx.js → resource-management-panel--xIMLPdz.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r, Fragment as le } from "react/jsx-runtime";
|
|
2
|
-
import { bM as Pe, u as re, U as je, K as ce,
|
|
2
|
+
import { bM as Pe, u as re, U as je, K as ce, cC as Fe, cD as Be, c as X, B as P, cu as ie, cE as ze, cF as He, cG as Ke, cH as _e, cI as Q, w as oe, cJ as We, cK as Ge, cL as Ye, cM as ge, ch as ue, cN as $e, cO as Je, cP as xe, cQ as De, cR as we, cS as Qe, al as Ne, ah as ve, cT as ye, cU as Ce, cV as Se, cW as Ee, cX as Ve, cY as Le, cZ as Ae, c_ as Oe, c$ as Te, d0 as Xe, d1 as he, d2 as Ze, af as te, b as qe, d3 as Re, d4 as ke, e as et, f as tt, g as rt, h as nt, i as ot, L as be, I as de, v as st, d5 as at, d6 as it, d7 as dt, bT as lt, bU as ct, bV as ut, bW as ht, d8 as mt, d9 as pt } from "./index-Bgn4zTsp.js";
|
|
3
3
|
import ft, { useRef as gt, useEffect as ne, useState as x } from "react";
|
|
4
|
-
import { u as Ue } from "./use-visual-utils-
|
|
4
|
+
import { u as Ue } from "./use-visual-utils-BCWNcaWk.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license lucide-react v0.453.0 - ISC
|
|
7
7
|
*
|
package/dist/chunks/{resource-management-panel-lglhpWpc.js → resource-management-panel-w7afzaPB.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-BY0YEY92.js"),h=require("react"),re=require("./use-visual-utils-CI-7TNJI.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const e=require("./index-BY0YEY92.js"),t=require("react/jsx-runtime"),C=require("react"),le=require("./use-visual-utils-CI-7TNJI.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 je=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const fe=e.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const he=e.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const re=e.createLucideIcon("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function ae(){var h,g;const a=e.useEditorStore(v=>v.card),r=e.useEditorStore(v=>v.frame),o=C.useMemo(()=>e.findCustomVisualConfigCard(r,a),[r,a]),{manifest:c}=e.useCustomVisual(((h=o==null?void 0:o.customCardPreferences)==null?void 0:h.url)||""),m=C.useMemo(()=>{var v;return(v=c==null?void 0:c.visuals)==null?void 0:v.find(p=>{var b;return p.name===((b=o==null?void 0:o.customCardPreferences)==null?void 0:b.componentName)})},[c,(g=o==null?void 0:o.customCardPreferences)==null?void 0:g.componentName]),x=e.resolveMultiInputType(o,m),f=C.useMemo(()=>e.getCustomVisualInputCards({frame:r,configCard:o,isMultiInputVisual:x==="multiple"}),[r,o,x]),y=C.useMemo(()=>{const v=f.findIndex(p=>(p==null?void 0:p.id)===a.id);return v<0?-1:e.getSlotIndexForCard(a,v)},[f,a]);return C.useMemo(()=>!o||x!=="multiple"||y<0?a.type:e.getEffectiveCardTypeForSlot(a,y,m==null?void 0:m.slots)??a.type,[o,x,y,a,m==null?void 0:m.slots])}function ke({type:a,isLinked:r,className:o,showLabel:c=!1,showLocal:m=!1}){const x=e.useDashboardStore(V=>V.selectedFrameId),f=e.useManagementStore(V=>V.selectedVisual),y=e.useEditorStore(V=>V.frame);let h;if(a)h=a;else if(r!==void 0)h=r?"linked":"library";else if(!!!(y!=null&&y.visualId||f!=null&&f.id)&&x)h="local";else if(f&&!x)h="library";else if(y!=null&&y.visualId&&x)h="linked";else if(f!=null&&f.id&&x)h="library";else return null;if(h==="local"&&!m)return null;const g={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},v={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},p={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},b={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},k={local:t.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:t.jsx(he,{className:"h-3.5 w-3.5"}),library:t.jsx(fe,{className:"h-3.5 w-3.5"})},F={local:"Local",linked:"Linked",library:"Library"};return t.jsx(e.TooltipProvider,{children:t.jsxs(e.Tooltip,{delayDuration:300,children:[t.jsx(e.TooltipTrigger,{asChild:!0,children:t.jsxs(e.Badge,{variant:"outline",className:e.cn("cursor-help select-none transition-all",g[h],o),children:[k[h],c&&t.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:F[h]})]})}),t.jsxs(e.TooltipContent,{side:"bottom",className:e.cn("max-w-xs",p[h]),children:[t.jsx(e.TooltipArrow,{className:b[h]}),t.jsx("p",{children:v[h]})]})]})})}function Se(a,r){return{...a,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:r?a.customCardPreferences:void 0,visualizationMode:"builtin",type:r?a.type:"bar"}}function ne(a){const r=e.getDynamicFrameSaveIssue(a);return r?(e.ue.error(r),!1):!0}function Ne({className:a,variant:r="outline"}){const o=e.useEditorStore(x=>x.onSave),{getUpdatedFrame:c}=le.useVisualUtils();function m(){const x=c();ne(x)&&(o==null||o(x))}return t.jsxs(e.Button,{onClick:m,className:e.cn("h-8",a),size:"sm",variant:r,children:[t.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function De({className:a,variant:r="default"}){const o=e.useQueryClient(),[c,m]=C.useState(!1),x=e.useDashboardStore(b=>b.actions.setIsDashboardPanelOpen),{setIsVisualEditing:f}=e.useDashboardActions(),{getUpdatedFrame:y}=le.useVisualUtils(),h=e.useSelectedVisual(),g=e.useEditorStore(b=>b.frame),v=e.useUpdateVisualMutation(),p=()=>{const b=y();if(!ne(b))return;const k=(g==null?void 0:g.visualId)||(h==null?void 0:h.id);if(!k){e.ue.error("No visual to save");return}m(!0),v.mutate({visualId:k,data:{frameObject:b}},{onSuccess:()=>{m(!1),x(!0),e.ue.success("Visual updated successfully"),o.invalidateQueries({queryKey:["resource-by-id","visual",k],exact:!0})},onError:()=>{m(!1),e.ue.error("Failed to update visual")}})};return t.jsxs(e.Button,{onClick:p,className:e.cn("h-8",a),size:"sm",variant:r,children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!c&&t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function Ve({className:a}){const r=e.useQueryClient(),[o,c]=C.useState(!1),m=e.useSelectedVisual(),x=e.useEditorStore(b=>b.frame),f=e.useDashboardStore(b=>b.selectedSheetId),{updateFrame:y,setIsVisualEditing:h}=e.useDashboardActions(),{getUpdatedFrame:g}=le.useVisualUtils(),v=e.useUpdateVisualMutation(),p=async()=>{if(!f){e.ue.error("No sheet selected");return}const b=(x==null?void 0:x.visualId)||(m==null?void 0:m.id);if(!b){e.ue.error("No visual to update");return}c(!0);try{const k=g();if(!ne(k)){c(!1);return}await v.mutateAsync({visualId:b,data:{frameObject:k}});const F={...k,visualId:b};y(f,F),r.invalidateQueries({queryKey:["visuals"]}),r.invalidateQueries({queryKey:["visual",b]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{h(!1)},300)}catch(k){console.error("Failed to save and apply:",k),e.ue.error("Failed to save and apply changes")}finally{c(!1)}};return t.jsx(e.Button,{onClick:p,className:e.cn("h-8",a),size:"sm",variant:"default",disabled:o,children:o?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function we({className:a}){const{setTempQueryData:r,setSqlGen:o}=e.useEditorActions(),c=e.useQueryClient(),m=e.useEditorStore(p=>p.tempQueryData),x=e.useEditorStore(p=>p.onClose),f=e.useEditorStore(p=>p.card),y=ae(),h=C.useMemo(()=>y!==f.type?{...f,type:y}:f,[f,y]),{queryKey:g}=e.useDashboardCardQuery(h);function v(){if(m){const{queryKey:p,queryData:b}=m;p&&b&&c.setQueryData(p,b)}o({}),x==null||x()}return t.jsxs(e.Button,{onClick:v,className:e.cn("h-8",a),size:"sm",variant:"outline",children:[t.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function Ee({label:a="Clear",variant:r="secondary",className:o}={}){const{setTempQueryData:c}=e.useEditorActions(),m=e.useQueryClient(),x=e.useEditorStore(l=>l.tempQueryData),f=e.useEditorStore(l=>l.card),y=ae(),h=C.useMemo(()=>y!==f.type?{...f,type:y}:f,[f,y]),{queryKey:g}=e.useDashboardCardQuery(h),{setCardSql:v,setSqlGen:p,setCardPython:b,setCardCustomCfg:k,setCardPreferences:F,clearQueryConfig:V,setCardConfig:$,setCardType:G,setFrame:K,setCard:Q,setActiveTabCardId:W}=e.useEditorActions();function M(){var T,U,B,H;const l=m.getQueryData(g);x!=null&&x.queryData||c({queryKey:g,queryData:l}),m.setQueryData(g,null),m.removeQueries({queryKey:g,exact:!0}),v(""),p({}),V(),$(void 0),b(""),k(""),F({});const S=e.useEditorStore.getState().frame,L=e.useEditorStore.getState().card,N=e.findCustomVisualConfigCard(S,L),z=((T=N==null?void 0:N.customCardPreferences)==null?void 0:T.visualType)==="multiple"||!!((U=N==null?void 0:N.customCardPreferences)!=null&&U.dataInputCardIds)||(((B=N==null?void 0:N.customCardPreferences)==null?void 0:B.minInputs)||0)>1||(((H=N==null?void 0:N.customCardPreferences)==null?void 0:H.maxInputs)||0)>1,_=Se(L,z);K({...S,cards:S.cards.map(R=>R.id===_.id?_:R)}),W(_.id),Q(_),z||G("bar")}return t.jsxs(e.Button,{onClick:M,className:e.cn("h-8",o),size:"sm",variant:r,children:[t.jsx(e.X,{className:"mr-2 size-3.5"}),a]})}function ye(a){const{control:r,onChange:o}=a;return t.jsxs("div",{className:"space-y-1",children:[t.jsx(e.Label,{className:"text-xs",children:"Label"}),t.jsxs("div",{className:"relative",children:[t.jsx(e.Input,{className:"pr-40",value:r.label,placeholder:"Control label",onChange:c=>o(c.target.value)}),t.jsx(e.Badge,{variant:"outline",className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs",children:e.getFriendlyTypeOption(r.type).label})]})]})}function Te(a){const{currentStep:r,labels:o}=a;return t.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b bg-background/95 px-1 pb-2 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:t.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:o.map((c,m)=>{const x=m+1,f=x===r,y=x<r;return t.jsxs(C.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:e.cn("flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",f?"border-primary bg-primary text-primary-foreground":y?"border-primary/25 bg-primary/10 text-primary":"border-border bg-muted/30 text-muted-foreground"),children:x}),t.jsx("span",{className:e.cn("text-xs font-medium",f?"text-foreground":"text-muted-foreground"),children:c})]}),m<o.length-1?t.jsx("span",{className:"h-px w-5 bg-border/80 sm:w-8","aria-hidden":"true"}):null]},c)})})})}function X(a){const{secondary:r,tertiary:o,primary:c}=a;return t.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[r,o,c]})}function Ie(a){const{control:r,scope:o,detail:c}=a;return t.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-border/40 bg-muted/20 p-3",children:[t.jsx(e.CircleCheck,{className:"mt-0.5 h-4 w-4 text-emerald-600"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-sm font-medium",children:r.label}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.getFriendlyTypeOption(r.type).label," ·"," ",e.getControlOptionPreview(r)," ·"," ",e.getPlacementLabel(o,r.placement)]}),c?t.jsx("div",{className:"text-xs text-muted-foreground",children:c}):null]})]})}function se(a){const{title:r,children:o,className:c}=a;return t.jsxs("div",{className:e.cn("space-y-1 rounded-xl border border-border/40 bg-muted/20 p-3",c),children:[t.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:r}),o]})}function Fe(a){const{createdReference:r,description:o}=a;return t.jsxs(se,{title:"SQL cards",className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border/30 bg-muted/40 px-3 py-2",children:[t.jsx("code",{className:"min-w-0 truncate text-xs",children:r}),t.jsx(e.CopyButton,{text:r,ariaLabel:"Copy SQL control reference"})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:o})]})}function pe(a){const{control:r,defaultValue:o,availableFieldChoices:c,availableMetricChoices:m,previewControlDefinitions:x,previewControlValues:f,onControlChange:y,onLabelChange:h,onDefaultValueChange:g,onBack:v,onNext:p,nextDisabled:b}=a;return t.jsxs("div",{className:"space-y-3",children:[t.jsx(ye,{control:r,onChange:h}),t.jsx(e.ControlDefinitionOptionsEditor,{control:r,availableFieldChoices:c,availableMetricChoices:m,previewControlDefinitions:x,previewControlValues:f,controlLifecycle:"create",onChange:y}),t.jsx(e.ControlDefaultValueEditor,{control:r,value:o,onChange:g,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:x,previewControlValues:f}),t.jsx(X,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:v,children:"Back"}),primary:t.jsx(e.Button,{type:"button",onClick:p,disabled:b,children:"Next"})})]})}function xe(a){const{control:r,scope:o,createdReference:c,explorerContent:m,sqlDescription:x,summaryDetail:f,onBack:y,onCancel:h,onDone:g}=a;return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ie,{control:r,scope:o,detail:f}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:"How cards use this control"}),m,t.jsx(Fe,{createdReference:c,description:x})]}),t.jsx(X,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:y,children:"Back"}),tertiary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:h,children:"Cancel"}),primary:t.jsx(e.Button,{type:"button",onClick:g,children:"Done"})})]})}function Le(a){const r=e.createBlankControl(a.scope,a.existingControls,a.reservedIds),o=a.type===r.type?{...r,label:e.DEFAULT_LABEL_BY_TYPE[a.type]}:{...e.applyControlTypeChange({controls:[{...r,label:e.DEFAULT_LABEL_BY_TYPE[a.type]}],controlId:r.id,nextType:a.type}).controls[0],label:e.DEFAULT_LABEL_BY_TYPE[a.type]};return{step:2,control:o,defaultValue:e.getDefaultValueForType(o,void 0)}}function Be({scope:a,controls:r,reservedControlIds:o,defaultValues:c,onChange:m,emptyMessage:x,initialCreateFlow:f=!1,usageByControlId:y,availableFieldChoices:h,availableMetricChoices:g,structuralParticipants:v,structuralParticipantIdsByControlId:p,card:b,onCreateFlowActiveChange:k,onCreateFlowComplete:F}){const V=C.useMemo(()=>new Set(o||[]),[o]),$=e.getPlacementOptionsForScope(a),G=e.getDefaultPlacement(a),[K,Q]=C.useState(null),[W,M]=C.useState(null),[l,S]=C.useState(()=>f?{step:1,control:e.createBlankControl(a,r,Array.from(V))}:null),L=C.useRef({}),N=C.useRef(void 0),z=C.useRef(f),_=C.useMemo(()=>e.getFriendlyControlTypeOptions({scope:a,card:b}),[b,a]),T=C.useCallback(s=>a==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[a]),U=C.useMemo(()=>l?e.getEligibleParticipantsForStructuralControl(v||[],l.control.type):[],[l,v]),B=C.useMemo(()=>{if(!l)return{fields:h||[],metrics:g||[]};if(!T(l.control.type))return{fields:h||[],metrics:g||[]};const s=l.selectedCardIds||[],i=e.getCompatibleStructuralChoiceCatalog({controlType:l.control.type,participants:v||[],selectedCardIds:s});return{fields:l.control.type==="field_selector"?i.choices.map(n=>({option:n,target:i.fieldTargetMap[n.value]})):[],metrics:l.control.type==="metric_selector"?i.choices.map(n=>({option:n,target:i.metricTargetMap[n.value]})):[]}},[h,g,l,T,v]);C.useEffect(()=>{k==null||k(!!l)},[l,k]),C.useEffect(()=>{const s=f&&!z.current;z.current=f,s&&(S({step:1,control:e.createBlankControl(a,r,Array.from(V))}),M(null),Q(null))},[r,f,V,a]);const H=s=>{if(!T(s.type))return{fields:h||[],metrics:g||[]};const i=(p==null?void 0:p[s.id])||[];if(i.length===0)return{fields:h||[],metrics:g||[]};const n=e.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:v||[],selectedCardIds:i});return{fields:s.type==="field_selector"?n.choices.map(u=>({option:u,target:n.fieldTargetMap[u.value]})):[],metrics:s.type==="metric_selector"?n.choices.map(u=>({option:u,target:n.metricTargetMap[u.value]})):[]}},R=s=>{if(!T(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const i=(p==null?void 0:p[s.control.id])||[],n=e.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:v||[],selectedCardIds:s.nextSelectedCardIds}),u=e.reconcileStructuralControlChoices({control:s.control,choices:n.choices}),j=Object.fromEntries(i.filter(d=>!s.nextSelectedCardIds.includes(d)).map(d=>[d,void 0]));return s.nextSelectedCardIds.length>0&&u.source.kind==="manual"&&u.source.options.length>0&&Object.assign(j,e.buildStructuralControlBindingsForParticipants({control:u,participants:v||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:u,cardBindingsById:j}},I=C.useCallback((s,i=c,n={type:"update"})=>{const u=s.map(j=>(e.resolveAuthoringControlDefaultValue({control:j,defaultValues:i}),e.syncSqlQueryControlExecutionRequirement(j)));m(u,i,n)},[c,m]),P=(s,i)=>{const n=r.find(w=>w.id===s);let u=r.map(w=>w.id!==s?w:i(w));const j=u.find(w=>w.id===s);let d,D;if(j&&a==="dashboard"&&(j.type==="field_selector"||j.type==="metric_selector")){const w=(p==null?void 0:p[j.id])||[],O=R({control:j,nextSelectedCardIds:w});u=u.map(A=>A.id===s?O.nextControl:A),d=O.cardBindingsById,D=[j.id]}else if(n&&a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const w=(p==null?void 0:p[n.id])||[];d=Object.fromEntries(w.map(O=>[O,void 0])),D=[n.id]}const E=u.find(w=>w.id===s);let q=c;if(n&&E){const w=e.resolveAuthoringControlDefaultValue({control:n,defaultValues:c});n.source.kind==="manual"&&E.source.kind==="sql_query"&&(L.current[s]=w);const O=w===void 0&&n.source.kind==="sql_query"&&E.source.kind==="manual"?L.current[s]:w,A=e.getNextEditedControlDefaultValue({previousControl:n,nextControl:E,currentDefaultValue:O});E.source.kind==="manual"&&(L.current[s]=A),c&&(q={...c},A===void 0?delete q[s]:q[s]=A),u=u.map(me=>me.id===s?{...E,defaultValue:A}:me)}I(u,q,{type:"update",cardBindingsById:d,affectedBindingControlIds:D})},be=(s,i)=>{const n=i.trim();if(n.length===0||n===s||V.has(n)||r.some(d=>d.id===n&&d.id!==s))return;const u=r.map(d=>d.id===s?{...d,id:n}:d);if(!c){I(u,void 0,{type:"rename",oldId:s,newId:n});return}const j={...c};Object.prototype.hasOwnProperty.call(j,s)&&(j[n]=j[s],delete j[s]),I(u,j,{type:"rename",oldId:s,newId:n})},ve=s=>{const i=r.filter(u=>u.id!==s);if(!c){I(i,void 0,{type:"remove",controlId:s});return}const n={...c};delete n[s],I(i,n,{type:"remove",controlId:s})},Ce=C.useCallback(()=>{N.current=void 0,S({step:1,control:e.createBlankControl(a,r,Array.from(V))}),M(null),Q(null)},[r,V,a]),Y=s=>{S(i=>i&&(()=>{const n=s(i.control);i.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(N.current=i.defaultValue);const u=i.defaultValue===void 0&&i.control.source.kind==="sql_query"&&n.source.kind==="manual"?N.current:i.defaultValue,j=e.getNextEditedControlDefaultValue({previousControl:i.control,nextControl:n,currentDefaultValue:u});return n.source.kind==="manual"&&(N.current=j),{...i,control:n,defaultValue:j}})())},oe=s=>{S(i=>i&&(i.control.source.kind==="manual"&&(N.current=s),{...i,defaultValue:s}))},J=(()=>{if(!l)return!1;if(l.step===2&&T(l.control.type))return(l.selectedCardIds||[]).length>0;if(l.step!==2&&l.step!==3||!l.control.label.trim())return!1;const i=l.control.source.kind==="sql_query"?l.control:e.ensureManualSource(l.control);if(i.source.kind==="manual"&&(e.needsManualOptions(i)&&i.source.options.length===0||i.source.options.some(u=>u.label.trim().length===0||u.value.trim().length===0)))return!1;if(i.source.kind==="sql_query"){const{connectionId:n,sql:u,valueColumn:j}=i.source;return n.trim().length>0&&u.trim().length>0&&j.trim().length>0}return e.hasConcreteDefaultValue(e.getDefaultValueForType(i,l.defaultValue))})(),ie=()=>{var d;if(!l)return;const s=e.ensureManualSource(l.control),i=e.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:r,reservedIds:Array.from(V)}),n={...s,id:i},u=a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((d=l.selectedCardIds)!=null&&d.length)?e.buildStructuralControlBindingsForParticipants({control:n,participants:v||[],selectedCardIds:l.selectedCardIds}):void 0,j=e.getDefaultValueForType(n,l.defaultValue);S({step:a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:j,createdControlId:i,selectedCardIds:l.selectedCardIds,cardBindingsById:u})},Z=C.useCallback(()=>{S(null)},[]),de=C.useCallback(()=>{if(!(l!=null&&l.createdControlId)){S(null);return}const s=l.control,i=l.createdControlId,n=e.getDefaultValueForType(s,l.defaultValue);if(c){const u={...c};n===void 0?delete u[i]:u[i]=n,I([...r,{...s,defaultValue:n}],u,{type:"add",cardBindingsById:l.cardBindingsById})}else I([...r,{...s,defaultValue:n}],void 0,{type:"add",cardBindingsById:l.cardBindingsById});M(i),S(null),F==null||F()},[r,l,c,I,F]),ge=l?T(l.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],ce=l!=null&&l.createdControlId?`[[param.${l.createdControlId}]]`:l?`[[param.${e.slugifyControlValue(l.control.label)||l.control.id}]]`:"",ee=e.buildAuthoringPreviewControlValues({controls:r,defaultValues:c}),te=l?[...r,l.control]:r,ue=l?e.buildAuthoringPreviewControlValues({controls:te,defaultValues:c,overrides:[{controlId:l.control.id,value:l.defaultValue}]}):ee;return t.jsxs("div",{className:"space-y-4",children:[l?t.jsxs("div",{className:"space-y-4 pb-1",children:[t.jsx(Te,{currentStep:l.step,labels:ge}),l.step===1&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"What kind of input should viewers see?"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose the viewer experience first. You can fine-tune the details next."}),a==="card"&&(b==null?void 0:b.sql)==null?t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null]}),t.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:_.map(s=>t.jsxs("button",{type:"button",className:"rounded-xl border border-border/50 bg-muted/20 p-3 text-left transition-colors hover:border-border/70 hover:bg-muted/35",onClick:()=>S(Le({scope:a,existingControls:r,reservedIds:Array.from(V),type:s.value})),children:[t.jsx("div",{className:"text-sm font-medium",children:s.label}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.description})]},s.value))}),t.jsx(X,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:Z,children:"Back to controls"})})]}),l.step===2&&T(l.control.type)&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(ye,{control:l.control,onChange:s=>Y(i=>({...i,label:s}))}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),U.length===0?t.jsx("div",{className:"rounded-xl bg-muted/20 p-3 text-xs text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):t.jsx("div",{className:"space-y-2 rounded-xl bg-muted/20 p-3",children:U.map(s=>{const i=(l.selectedCardIds||[]).includes(s.cardId);return t.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[t.jsx(e.Checkbox,{checked:i,onCheckedChange:n=>S(u=>u&&{...u,selectedCardIds:n===!0?[...u.selectedCardIds||[],s.cardId]:(u.selectedCardIds||[]).filter(j=>j!==s.cardId)})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium",children:s.title}),t.jsx("div",{className:"text-xs text-muted-foreground",children:l.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),t.jsx(X,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:()=>S(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:t.jsx(e.Button,{type:"button",onClick:()=>S(s=>s&&{...s,step:3}),disabled:!J,children:"Next"})})]}),l.step===2&&!T(l.control.type)&&t.jsx(pe,{control:l.control,defaultValue:l.defaultValue,availableFieldChoices:B.fields,availableMetricChoices:B.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>Y(()=>s),onLabelChange:s=>Y(i=>({...i,label:s})),onDefaultValueChange:oe,onBack:()=>S(s=>s&&{...s,step:1}),onNext:ie,nextDisabled:!J}),l.step===3&&T(l.control.type)&&t.jsx(pe,{control:l.control,defaultValue:l.defaultValue,availableFieldChoices:B.fields,availableMetricChoices:B.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>Y(()=>s),onLabelChange:s=>Y(i=>({...i,label:s})),onDefaultValueChange:oe,onBack:()=>S(s=>s&&{...s,step:2}),onNext:ie,nextDisabled:!J}),l.step===3&&!T(l.control.type)&&t.jsx(xe,{control:l.control,scope:a,createdReference:ce,explorerContent:t.jsx(se,{title:"Explorer cards",children:t.jsxs("p",{className:"text-sm",children:["Open the card and use"," ",t.jsx("span",{className:"font-medium",children:"Settings → Controls"})," ","to choose what this control changes."]})}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>S(s=>s&&{...s,step:2}),onCancel:Z,onDone:de}),l.step===4&&T(l.control.type)&&t.jsx(xe,{control:l.control,scope:a,createdReference:ce,summaryDetail:t.jsxs(t.Fragment,{children:["Used by ",(l.selectedCardIds||[]).length," ","selected card",(l.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:t.jsx(se,{title:"Explorer cards",children:t.jsx("p",{className:"text-sm",children:"Selected cards have been set up to respond to this control automatically."})}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>S(s=>s&&{...s,step:3}),onCancel:Z,onDone:de})]}):null,!l&&r.length===0?t.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:x}):null,!l&&r.map(s=>{const i=H(s),n=y==null?void 0:y[s.id],u=e.resolveAuthoringControlDefaultValue({control:s,defaultValues:c}),j=W===s.id;return t.jsxs("div",{className:"rounded-md border",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 text-left",onClick:()=>M(d=>d===s.id?null:s.id),children:[j?t.jsx(e.ChevronDown,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):t.jsx(e.ChevronRight,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium",children:s.label||"Untitled control"}),t.jsx(e.Badge,{variant:"outline",className:"text-[11px]",children:e.getFriendlyTypeOption(s.type).label}),t.jsx(e.Badge,{variant:"secondary",className:"text-[11px]",children:e.getPlacementLabel(a,s.placement)})]}),t.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.getControlOptionPreview(s),n!=null&&n.status?` · ${n.status}`:""]})]})]}),t.jsx(e.Button,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 shrink-0",onClick:()=>ve(s.id),"aria-label":`Remove ${s.label}`,children:t.jsx(e.Trash2,{className:"h-4 w-4"})})]}),j&&t.jsxs("div",{className:"space-y-4 border-t px-3 py-4",children:[n!=null&&n.helper?t.jsx("div",{className:"rounded-md bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:n.helper}):null,t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Label"}),t.jsx(e.Input,{value:s.label,placeholder:"Control label",onChange:d=>P(s.id,D=>({...D,label:d.target.value}))})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Type"}),t.jsxs(e.Select,{value:s.type,onValueChange:d=>{const D=e.applyControlTypeChange({controls:r,controlId:s.id,nextType:d,defaultValues:c});I(D.controls,D.defaultValues)},children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.getFriendlyControlTypeOptions({scope:a,card:b,includeType:s.type}).map(d=>t.jsx(e.SelectItem,{value:d.value,children:d.label},d.value))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Show in"}),t.jsxs(e.Select,{value:s.placement||G,onValueChange:d=>P(s.id,D=>({...D,placement:d})),children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:$.map(d=>t.jsx(e.SelectItem,{value:d.value,children:d.label},d.value))})]})]})]}),T(s.type)?t.jsx(e.StructuralParticipantSelector,{type:s.type,participants:e.getEligibleParticipantsForStructuralControl(v||[],s.type).map(d=>({cardId:d.cardId,title:d.title,choiceCount:s.type==="field_selector"?d.fieldChoices.length:d.metricChoices.length})),selectedCardIds:(p==null?void 0:p[s.id])||[],onChange:d=>{const D=R({control:s,nextSelectedCardIds:d}),E=r.map(q=>q.id===s.id?D.nextControl:q);I(E,c,{type:"update",cardBindingsById:D.cardBindingsById})}}):null,t.jsx(e.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:i.fields,availableMetricChoices:i.metrics,previewControlDefinitions:r,previewControlValues:ee,controlLifecycle:"edit",onChange:d=>P(s.id,()=>d)}),s.initialValueStrategy==="saved_default"&&t.jsx(e.ControlDefaultValueEditor,{control:s,value:u,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:r,previewControlValues:ee,onChange:d=>{const D=r.map(E=>E.id===s.id?{...E,defaultValue:d}:E);if(s.source.kind==="manual"&&(L.current[s.id]=d),c){const E={...c};d===void 0?delete E[s.id]:E[s.id]=d,I(D,E);return}I(D,void 0)}}),t.jsxs(e.Collapsible,{open:K===s.id,onOpenChange:d=>Q(d?s.id:null),children:[t.jsx(e.CollapsibleTrigger,{asChild:!0,children:t.jsxs(e.Button,{type:"button",variant:"ghost",className:"h-auto px-0 text-xs text-muted-foreground hover:bg-transparent",children:[K===s.id?t.jsx(e.ChevronDown,{className:"mr-1 h-4 w-4"}):t.jsx(e.ChevronRight,{className:"mr-1 h-4 w-4"}),"Advanced"]})}),t.jsxs(e.CollapsibleContent,{className:"space-y-3 pt-2",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Control ID"}),t.jsx(e.ControlIdInput,{controlId:s.id,onCommit:d=>be(s.id,d)},s.id)]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Initial value"}),t.jsxs(e.Select,{value:s.initialValueStrategy,onValueChange:d=>P(s.id,D=>({...D,initialValueStrategy:d})),children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.INITIAL_VALUE_STRATEGY_OPTIONS.map(d=>t.jsx(e.SelectItem,{value:d.value,children:d.label},d.value))})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:e.getInitialValueStrategyHint(s.initialValueStrategy)})]})]}),t.jsx(e.ControlVisibilitySettings,{control:s,onChange:d=>P(s.id,()=>d)})]})]})]})]},s.id)}),!l&&t.jsxs(e.Button,{type:"button",variant:"outline",size:"sm",onClick:Ce,children:[t.jsx(e.Plus,{className:"mr-2 h-4 w-4"}),"Add control"]})]})}function qe(a){const{open:r,onOpenChange:o,initialCreateFlowActive:c=!1}=a,m=r!==void 0,[x,f]=C.useState(!1),[y,h]=C.useState(c),g=m?r:x,v=C.useCallback(k=>{!k&&y||(m||f(k),k||h(!1),o==null||o(k))},[m,y,o]),p=C.useCallback(()=>{m||f(!1),h(!1),o==null||o(!1)},[m,o]);C.useEffect(()=>{g||h(!1)},[g]);const b=C.useCallback(k=>{y&&k.preventDefault()},[y]);return{forceClose:p,handleOpenChange:v,isCreateFlowActive:y,preventPassiveDismissDuringCreate:b,resolvedOpen:g,setIsCreateFlowActive:h}}exports.CircleX=je;exports.ControlDefinitionListEditor=Be;exports.EditorAcceptButton=Ne;exports.EditorCancelButton=we;exports.EditorClearButton=Ee;exports.Library=fe;exports.Link2=he;exports.Save=re;exports.VisualBadge=ke;exports.VisualSaveAndApplyButton=Ve;exports.VisualSaveButton=De;exports.useCreateFlowOverlayState=qe;exports.useEffectiveEditorCardType=ae;
|