react-semaphor 0.1.299 → 0.1.301
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/{braces-uehz1QT7.js → braces-Bhqo4iW1.js} +1 -1
- package/dist/chunks/{braces-DytC2b1M.js → braces-BwK7fWd_.js} +1 -1
- package/dist/chunks/{dashboard-controls-Cpjx2gxm.js → dashboard-controls-BIRiWCUK.js} +1 -1
- package/dist/chunks/{dashboard-controls-poI7wP8s.js → dashboard-controls-DIlnYo96.js} +5 -5
- package/dist/chunks/{dashboard-filter-controls-button-94HgSpK_.js → dashboard-filter-controls-button-CK1-mKQh.js} +1 -1
- package/dist/chunks/{dashboard-filter-controls-button-DMf1fdxi.js → dashboard-filter-controls-button-DjALRkvg.js} +3 -3
- package/dist/chunks/{dashboard-json-D0F8qMeN.js → dashboard-json-D-zIG46N.js} +1 -1
- package/dist/chunks/{dashboard-json-BRe2AM7l.js → dashboard-json-DK4mQ1gS.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-DC7cZ5lN.js → dashboard-summary-settings-dialog-D-F1eEJI.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-CEwWfmp2.js → dashboard-summary-settings-dialog-DSxNqxFI.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Ceiypy27.js → edit-dashboard-visual-BjflrL8w.js} +7882 -7677
- package/dist/chunks/edit-dashboard-visual-DCsrtJr_.js +193 -0
- package/dist/chunks/{index-BMkPMHd1.js → index-8GnvL1_L.js} +259 -264
- package/dist/chunks/{index-DaSdwe0q.js → index-DDA12yqV.js} +30598 -30716
- package/dist/chunks/{resource-management-panel-DBAwCjlr.js → resource-management-panel-B2558XA1.js} +2 -2
- package/dist/chunks/{resource-management-panel-elCFmiX9.js → resource-management-panel-CKp4_aem.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-D_k2LA86.js → use-create-flow-overlay-state-BUw_JtLs.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-DK53WJCX.js → use-create-flow-overlay-state-CWcCdPbC.js} +1 -1
- package/dist/chunks/{use-visual-utils-BIQHlvEU.js → use-visual-utils-C45OxsOf.js} +1 -1
- package/dist/chunks/{use-visual-utils-lNM_pQBw.js → use-visual-utils-DyaThRzf.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/package.json +1 -1
- package/dist/chunks/edit-dashboard-visual-DuPcJx1w.js +0 -188
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),e=require("./index-8GnvL1_L.js"),g=require("react");require("react-dom");const G=require("./dashboard-filter-controls-button-CK1-mKQh.js"),at=require("./date-formatter-CqXdM6JO.js"),xs=require("./dashboard-summary-settings-dialog-DSxNqxFI.js"),nt=require("./use-debounced-dirty-check-XHSwAefL.js"),Fe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),Se=require("./use-create-flow-overlay-state-CWcCdPbC.js"),rt=require("./braces-BwK7fWd_.js");function ot(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const N=ot(g);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c, Fragment as k } from "react/jsx-runtime";
|
|
2
|
-
import { c as Z, dt as ls, u as D, B as L, du as Nt, Q as wt, d as j, e as Fe, dv as cs, cx as dt, f as Re, g as Ge, h as $e, i as St, L as ut, I as de, w as ds, dw as ce, cO as Pe, dx as us, dy as ta, dz as da, b as Y, dA as ua, dB as ms, d3 as Dt, dC as hs, dD as ps, dE as fs, dF as gs, dG as vs, dH as bs, J as Ve, Z as ze, y as I, dI as qe, dJ as ma, dK as ha, dc as ys, dL as xs, x as X, dM as Ns, dN as ws, dO as mt, dP as Ss, dQ as Ds, dR as pa, dS as fa, dT as Te, dU as _e, d8 as ht, cT as pt, dV as ft, cN as Ct, cl as ga, dW as gt, cg as va, dX as Cs, cW as ba, cX as ya, cY as xa, cZ as Na, c_ as wa, c$ as Sa, d0 as Da, d1 as vt, dY as Ca, dZ as Es, cF as Is, d_ as Ls, aj as Ms, d$ as As, W as aa, ai as Oe, e0 as Os, ap as ks, ak as nt, e1 as Ps, e2 as Ts, e3 as _s, aE as Us, e4 as Fs, aa as rt, e5 as Rs, bV as Gs, bW as $s, bX as Vs, e6 as zs, bY as qs, e7 as Hs, ds as Bs, e8 as js, cG as Ks, cH as Qs, cI as Ws, cJ as Js, cK as V, di as Ys, ac as Xs, cQ as Zs, e9 as en, cL as sa, av as tn, ea as an, eb as sn, ec as nn, ao as rn, ad as on, ed as ln, a8 as bt, ee as cn } from "./index-
|
|
2
|
+
import { c as Z, dt as ls, u as D, B as L, du as Nt, Q as wt, d as j, e as Fe, dv as cs, cx as dt, f as Re, g as Ge, h as $e, i as St, L as ut, I as de, w as ds, dw as ce, cO as Pe, dx as us, dy as ta, dz as da, b as Y, dA as ua, dB as ms, d3 as Dt, dC as hs, dD as ps, dE as fs, dF as gs, dG as vs, dH as bs, J as Ve, Z as ze, y as I, dI as qe, dJ as ma, dK as ha, dc as ys, dL as xs, x as X, dM as Ns, dN as ws, dO as mt, dP as Ss, dQ as Ds, dR as pa, dS as fa, dT as Te, dU as _e, d8 as ht, cT as pt, dV as ft, cN as Ct, cl as ga, dW as gt, cg as va, dX as Cs, cW as ba, cX as ya, cY as xa, cZ as Na, c_ as wa, c$ as Sa, d0 as Da, d1 as vt, dY as Ca, dZ as Es, cF as Is, d_ as Ls, aj as Ms, d$ as As, W as aa, ai as Oe, e0 as Os, ap as ks, ak as nt, e1 as Ps, e2 as Ts, e3 as _s, aE as Us, e4 as Fs, aa as rt, e5 as Rs, bV as Gs, bW as $s, bX as Vs, e6 as zs, bY as qs, e7 as Hs, ds as Bs, e8 as js, cG as Ks, cH as Qs, cI as Ws, cJ as Js, cK as V, di as Ys, ac as Xs, cQ as Zs, e9 as en, cL as sa, av as tn, ea as an, eb as sn, ec as nn, ao as rn, ad as on, ed as ln, a8 as bt, ee as cn } from "./index-DDA12yqV.js";
|
|
3
3
|
import * as M from "react";
|
|
4
4
|
import Ea, { useState as N, useMemo as F, useCallback as Ue, useEffect as ot } from "react";
|
|
5
5
|
import "react-dom";
|
|
6
|
-
import { b as dn, u as un, A as mn, V as hn, c as pn, D as fn, N as gn, U as vn } from "./dashboard-filter-controls-button-
|
|
6
|
+
import { b as dn, u as un, A as mn, V as hn, c as pn, D as fn, N as gn, U as vn } from "./dashboard-filter-controls-button-DjALRkvg.js";
|
|
7
7
|
import { l as bn } from "./date-formatter-vkCj9Ct-.js";
|
|
8
|
-
import { C as yn, D as xn } from "./dashboard-summary-settings-dialog-
|
|
8
|
+
import { C as yn, D as xn } from "./dashboard-summary-settings-dialog-D-F1eEJI.js";
|
|
9
9
|
import { u as Nn } from "./use-debounced-dirty-check-BwAbnX_5.js";
|
|
10
10
|
import { s as it } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
|
|
11
|
-
import { u as wn, e as Sn, S as na } from "./use-create-flow-overlay-state-
|
|
12
|
-
import { B as Dn } from "./braces-
|
|
11
|
+
import { u as wn, e as Sn, S as na } from "./use-create-flow-overlay-state-BUw_JtLs.js";
|
|
12
|
+
import { B as Dn } from "./braces-Bhqo4iW1.js";
|
|
13
13
|
/**
|
|
14
14
|
* @license lucide-react v0.453.0 - ISC
|
|
15
15
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const v=require("react"),e=require("./index-
|
|
1
|
+
"use strict";const v=require("react"),e=require("./index-8GnvL1_L.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-CWcCdPbC.js"),O=require("./use-visual-utils-DyaThRzf.js"),M=require("./date-formatter-CqXdM6JO.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Se, { useState as T, useRef as X, useCallback as $, useEffect as B, useContext as Ae } from "react";
|
|
2
|
-
import { c as le, d as K, aF as z, bM as Q, bI as de, bJ as W, aG as ce, bH as Ie, e as ue, f as me, g as he, h as pe, i as fe, L as Z, I as Fe, dc as Le, w as Te, B as I, x as q, W as j, M as ke, u as O, N as Pe, Q as J, c0 as ve, dd as Ue, de as ee, y as P, c2 as ge, c1 as G, ai as Me, cG as be, cH as xe, a9 as ye, cJ as we, cK as R, t as Ve, cO as Oe, cx as Be, O as ze, df as Re, b as H, dg as Y, dh as $e, cW as _e, cX as He, cY as je, cZ as Xe, c_ as Ge, c$ as Ke, d0 as Qe, bO as We, X as qe, di as Je, dj as Ye, cD as Ze, bK as te, ab as et, aI as tt, P as Ce, k as De, dk as at, m as Ne, dl as st, dm as rt, dn as ot, dp as nt, dq as it, dr as ae, ds as lt } from "./index-
|
|
2
|
+
import { c as le, d as K, aF as z, bM as Q, bI as de, bJ as W, aG as ce, bH as Ie, e as ue, f as me, g as he, h as pe, i as fe, L as Z, I as Fe, dc as Le, w as Te, B as I, x as q, W as j, M as ke, u as O, N as Pe, Q as J, c0 as ve, dd as Ue, de as ee, y as P, c2 as ge, c1 as G, ai as Me, cG as be, cH as xe, a9 as ye, cJ as we, cK as R, t as Ve, cO as Oe, cx as Be, O as ze, df as Re, b as H, dg as Y, dh as $e, cW as _e, cX as He, cY as je, cZ as Xe, c_ as Ge, c$ as Ke, d0 as Qe, bO as We, X as qe, di as Je, dj as Ye, cD as Ze, bK as te, ab as et, aI as tt, P as Ce, k as De, dk as at, m as Ne, dl as st, dm as rt, dn as ot, dp as nt, dq as it, dr as ae, ds as lt } from "./index-DDA12yqV.js";
|
|
3
3
|
import { jsx as t, jsxs as s, Fragment as _ } from "react/jsx-runtime";
|
|
4
|
-
import { V as dt, E as se, a as re, b as ct, c as ut, L as mt, d as ht, C as pt, u as ft, e as vt } from "./use-create-flow-overlay-state-
|
|
5
|
-
import { u as Ee } from "./use-visual-utils-
|
|
4
|
+
import { V as dt, E as se, a as re, b as ct, c as ut, L as mt, d as ht, C as pt, u as ft, e as vt } from "./use-create-flow-overlay-state-BUw_JtLs.js";
|
|
5
|
+
import { u as Ee } from "./use-visual-utils-C45OxsOf.js";
|
|
6
6
|
import { k as oe } from "./date-formatter-vkCj9Ct-.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license lucide-react v0.453.0 - ISC
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as b, useState as f, useRef as m, useEffect as S } from "react";
|
|
3
|
-
import { u as e, b as N, B as D, X as p, C as J } from "./index-
|
|
3
|
+
import { u as e, b as N, B as D, X as p, C as J } from "./index-DDA12yqV.js";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
function x() {
|
|
6
6
|
const o = e((s) => s.dashboard), c = e((s) => s.actions.setDashboard), h = e(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),s=require("./index-8GnvL1_L.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),i=s.useDashboardStore(e=>e.actions.setDashboard),h=s.useDashboardStore(e=>e.showDashboardJSON),u=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=r.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=r.useState(a),n=r.useRef(a);return r.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),o.jsxs("div",{className:s.cn("relative p-2",{hidden:!h}),children:[o.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>u(!1),children:[o.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),o.jsx("div",{className:"h-[550px] overflow-hidden",children:o.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const c=JSON.parse(e);n.current=JSON.stringify(c,null,2),i(c)}catch{}},language:"json"})})]})}exports.default=b;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as ue } from "react/jsx-runtime";
|
|
2
2
|
import me, { useState as f, useCallback as $, useEffect as Y, useMemo as F } from "react";
|
|
3
|
-
import { d as he, e as Q, f as ee, g as ae, h as te, i as se, R, b as k, j, L as P, P as fe, k as pe, B as A, l as xe, m as be, n as ve, o as ge, p as Se, q as ye, r as V, s as G, t as X, v as Ne, w as re, x as we, y as I, S as ke, z as Ce, A as Te, E as Ie, F as Pe, G as Z, I as Ae } from "./index-
|
|
3
|
+
import { d as he, e as Q, f as ee, g as ae, h as te, i as se, R, b as k, j, L as P, P as fe, k as pe, B as A, l as xe, m as be, n as ve, o as ge, p as Se, q as ye, r as V, s as G, t as X, v as Ne, w as re, x as we, y as I, S as ke, z as Ce, A as Te, E as Ie, F as Pe, G as Z, I as Ae } from "./index-DDA12yqV.js";
|
|
4
4
|
function ze(r = {}) {
|
|
5
5
|
var T, L, D, M;
|
|
6
6
|
const { authToken: i, tokenProps: t } = he(), v = r.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (t == null ? void 0 : t.apiServiceUrl) ?? null, [N, S] = f(!1), [g, x] = f(!1), [u, n] = f(!1), [y, c] = f(null), [p, w] = f(null), z = p || {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-BMkPMHd1.js");function V(r={}){var C,I,P,A;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),g=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,x=(s==null?void 0:s.apiServiceUrl)??null,[y,v]=l.useState(!1),[S,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[f,N]=l.useState(null),k=f||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((A=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:A.weekStart)??null},b=l.useCallback(async()=>{if(!(!g||!d||!x)){v(!0),c(null);try{const u=await fetch(`${x}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();N({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{v(!1)}}},[d,x,g]);l.useEffect(()=>{g&&b()},[g,b]);const T=l.useCallback(async u=>{if(!d||!x)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${x}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,x,b]),w=l.useCallback(async()=>{if(!d||!x)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${x}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return N({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,x,b]);return{preferences:k,isLoading:y,isSaving:S,isClearing:m,error:j,updatePreferences:T,clearPreferences:w,refetch:b}}const z=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],_=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],U="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function X(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return z.map(r=>r.value)}function q(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function B(r){const o=z.find(s=>s.value===r);return o?o.label:r}function Z(r){const o=_.find(s=>s.value===r);return o?o.label:String(r)}function J({open:r,onOpenChange:o}){var L,M,F;const{preferences:s,isLoading:g,isSaving:d,isClearing:x,updatePreferences:y,clearPreferences:v}=V({enabled:r}),S=s.tz||((L=s.inherited)==null?void 0:L.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((M=s.inherited)==null?void 0:M.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[f,N]=l.useState(S),[k,b]=l.useState(p),[T,w]=l.useState(!1),C=l.useMemo(()=>X(),[]),I=l.useMemo(()=>C.filter(t=>!z.some(W=>W.value===t)),[C]),P=l.useMemo(()=>B(f),[f]),A=s.inherited?B(s.inherited.tz):"UTC",u=s.inherited?Z(s.inherited.weekStart):"Monday",i=q((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),N(S),b(p))},[r,j,s.userHasPrefs,S,p]);const h=async()=>{if(g){a.ue.error("Preferences are still loading. Please try again.");return}m?await v()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:f,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},R=()=>{o(!1)},D=d||x,G=D||g;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"rounded-[6px] border-border/60 sm:max-w-[440px] sm:rounded-[6px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:a.cn("flex cursor-pointer items-start gap-2 rounded-[5px] px-2 py-1.5 hover:bg-muted/50",m&&"bg-muted/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[A,", week starts ",u]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:a.cn("flex cursor-pointer items-start gap-2 rounded-[5px] px-2 py-1.5 hover:bg-muted/50",!m&&"bg-muted/50"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",m&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{className:U,children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":T,className:"w-full justify-between text-[12px] font-normal",disabled:m,children:[e.jsx("span",{className:"truncate",children:P}),e.jsx(a.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:z.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),N(t.value),w(!1)},children:[e.jsx(a.Check,{className:a.cn("h-3.5 w-3.5",f===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),N(t),w(!1)},children:[e.jsx(a.Check,{className:a.cn("h-3.5 w-3.5",f===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{className:U,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:_.map(t=>e.jsxs("label",{htmlFor:`week-start-${t.value}`,className:a.cn("flex cursor-pointer items-center gap-2 text-[13px]",m&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),t.label]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",size:"xs",onClick:R,disabled:D,children:"Cancel"}),e.jsx(a.Button,{size:"xs",onClick:h,disabled:G,children:D?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const E=6,$=1,O=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function K(r){return Number.isNaN(r)?E:Math.min(O,Math.max($,r))}function Y({open:r,onOpenChange:o,dashboard:s,onApply:g,disabled:d=!1}){const[x,y]=l.useState(!1),[v,S]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),S((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>K(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{g({enabled:x,position:v,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"rounded-[6px] border-border/60 sm:max-w-[420px] sm:rounded-[6px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(a.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:x,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(a.Select,{value:v,disabled:d,onValueChange:f=>S(f),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(a.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:$,max:O,disabled:d,value:p,onChange:f=>m(f.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",size:"xs",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{size:"xs",onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=J;exports.DashboardSummarySettingsDialog=Y;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-8GnvL1_L.js");function V(r={}){var C,I,P,A;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),g=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,x=(s==null?void 0:s.apiServiceUrl)??null,[y,v]=l.useState(!1),[S,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[f,N]=l.useState(null),k=f||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((A=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:A.weekStart)??null},b=l.useCallback(async()=>{if(!(!g||!d||!x)){v(!0),c(null);try{const u=await fetch(`${x}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();N({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{v(!1)}}},[d,x,g]);l.useEffect(()=>{g&&b()},[g,b]);const T=l.useCallback(async u=>{if(!d||!x)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${x}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,x,b]),w=l.useCallback(async()=>{if(!d||!x)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${x}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return N({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,x,b]);return{preferences:k,isLoading:y,isSaving:S,isClearing:m,error:j,updatePreferences:T,clearPreferences:w,refetch:b}}const z=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],_=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],U="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function X(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return z.map(r=>r.value)}function q(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function B(r){const o=z.find(s=>s.value===r);return o?o.label:r}function Z(r){const o=_.find(s=>s.value===r);return o?o.label:String(r)}function J({open:r,onOpenChange:o}){var L,M,F;const{preferences:s,isLoading:g,isSaving:d,isClearing:x,updatePreferences:y,clearPreferences:v}=V({enabled:r}),S=s.tz||((L=s.inherited)==null?void 0:L.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((M=s.inherited)==null?void 0:M.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[f,N]=l.useState(S),[k,b]=l.useState(p),[T,w]=l.useState(!1),C=l.useMemo(()=>X(),[]),I=l.useMemo(()=>C.filter(t=>!z.some(W=>W.value===t)),[C]),P=l.useMemo(()=>B(f),[f]),A=s.inherited?B(s.inherited.tz):"UTC",u=s.inherited?Z(s.inherited.weekStart):"Monday",i=q((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),N(S),b(p))},[r,j,s.userHasPrefs,S,p]);const h=async()=>{if(g){a.ue.error("Preferences are still loading. Please try again.");return}m?await v()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:f,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},R=()=>{o(!1)},D=d||x,G=D||g;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"rounded-[6px] border-border/60 sm:max-w-[440px] sm:rounded-[6px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:a.cn("flex cursor-pointer items-start gap-2 rounded-[5px] px-2 py-1.5 hover:bg-muted/50",m&&"bg-muted/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[A,", week starts ",u]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:a.cn("flex cursor-pointer items-start gap-2 rounded-[5px] px-2 py-1.5 hover:bg-muted/50",!m&&"bg-muted/50"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",m&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{className:U,children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":T,className:"w-full justify-between text-[12px] font-normal",disabled:m,children:[e.jsx("span",{className:"truncate",children:P}),e.jsx(a.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:z.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),N(t.value),w(!1)},children:[e.jsx(a.Check,{className:a.cn("h-3.5 w-3.5",f===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),N(t),w(!1)},children:[e.jsx(a.Check,{className:a.cn("h-3.5 w-3.5",f===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{className:U,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:_.map(t=>e.jsxs("label",{htmlFor:`week-start-${t.value}`,className:a.cn("flex cursor-pointer items-center gap-2 text-[13px]",m&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),t.label]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",size:"xs",onClick:R,disabled:D,children:"Cancel"}),e.jsx(a.Button,{size:"xs",onClick:h,disabled:G,children:D?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const E=6,$=1,O=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function K(r){return Number.isNaN(r)?E:Math.min(O,Math.max($,r))}function Y({open:r,onOpenChange:o,dashboard:s,onApply:g,disabled:d=!1}){const[x,y]=l.useState(!1),[v,S]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),S((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>K(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{g({enabled:x,position:v,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"rounded-[6px] border-border/60 sm:max-w-[420px] sm:rounded-[6px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(a.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:x,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(a.Select,{value:v,disabled:d,onValueChange:f=>S(f),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(a.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:$,max:O,disabled:d,value:p,onChange:f=>m(f.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",size:"xs",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{size:"xs",onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=J;exports.DashboardSummarySettingsDialog=Y;
|