react-semaphor 0.1.183 → 0.1.185
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/calendar-preferences-dialog-BlkO2Iyl.js +1 -0
- package/dist/chunks/calendar-preferences-dialog-Cf45Z1iV.js +457 -0
- package/dist/chunks/common-types-CfJLrTJd.js +1 -0
- package/dist/chunks/common-types-DhqlRVrq.js +8 -0
- package/dist/chunks/{dashboard-controls-BqMZqU3v.js → dashboard-controls-99QUvc-v.js} +8 -8
- package/dist/chunks/{dashboard-controls-F8wbPI8x.js → dashboard-controls-BaIn2nYt.js} +499 -484
- package/dist/chunks/{dashboard-json-BFRJvB_f.js → dashboard-json-CLnZus5R.js} +1 -1
- package/dist/chunks/{dashboard-json-DUNbo5Io.js → dashboard-json-Wc0g-rU5.js} +1 -1
- package/dist/chunks/date-formatter-Sz6QDaM8.js +1 -0
- package/dist/chunks/{index-B4EhQdS9.js → date-formatter-Y8Za1ib3.js} +500 -544
- package/dist/chunks/{edit-dashboard-visual-CPwMz-Gl.js → edit-dashboard-visual-BILSP_JA.js} +3922 -3814
- package/dist/chunks/edit-dashboard-visual-C1GBD18Y.js +184 -0
- package/dist/chunks/{editor-action-buttons-C5pFQC5d.js → editor-action-buttons-CtZF2jZ1.js} +1 -1
- package/dist/chunks/{editor-action-buttons-DEi2BM_u.js → editor-action-buttons-Dms4qFF0.js} +27 -27
- package/dist/chunks/{index-LgltNjBB.js → index-CWTYAZIx.js} +21356 -21055
- package/dist/chunks/{index-CcVMCdNu.js → index-DnzN4EJh.js} +227 -227
- package/dist/chunks/{notification-bell-BCdcnJx6.js → notification-bell-BFuX86W5.js} +109 -109
- package/dist/chunks/{notification-bell-C0rpelXK.js → notification-bell-Ys7A4FR5.js} +2 -2
- package/dist/chunks/{resource-management-panel-D6ZT7DsU.js → resource-management-panel-D9YWCtpI.js} +160 -160
- package/dist/chunks/{resource-management-panel-CaKtrD1Q.js → resource-management-panel-KHhPka_P.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-F6Zc7Evm.js → use-role-aware-display-preferences-BQYah_5h.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-B3xYm_4b.js → use-role-aware-display-preferences-DLfXCRXV.js} +1 -1
- package/dist/chunks/use-visual-utils-CoQ-12pH.js +1 -0
- package/dist/chunks/{use-visual-utils-D48U4CBx.js → use-visual-utils-Dq99aM9P.js} +59 -53
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +3 -3
- package/dist/format-utils/index.cjs +5 -5
- package/dist/format-utils/index.js +200 -250
- package/dist/index.cjs +1 -1
- package/dist/index.js +75 -71
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +6 -4
- package/dist/types/dashboard.d.ts +35 -3
- package/dist/types/format-utils.d.ts +43 -20
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +8 -5
- package/dist/types/main.d.ts +140 -7
- package/dist/types/surfboard.d.ts +42 -3
- package/dist/types/types.d.ts +348 -3
- package/package.json +1 -1
- package/dist/chunks/edit-dashboard-visual-C-2xW9ZO.js +0 -184
- package/dist/chunks/index-8Crk3ROJ.js +0 -1
- package/dist/chunks/use-visual-utils-B1yUV6dt.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),a=require("./index-DnzN4EJh.js");function R(){var S,b,j,p;const{authToken:s,tokenProps:r}=a.useSemaphorContext(),[l,v]=o.useState(!1),[k,y]=o.useState(!1),[T,w]=o.useState(!1),[x,d]=o.useState(null),[m,f]=o.useState(null),C=m||{tz:((b=(S=r==null?void 0:r.params)==null?void 0:S.calendarContext)==null?void 0:b.tz)||null,weekStart:((p=(j=r==null?void 0:r.params)==null?void 0:j.calendarContext)==null?void 0:p.weekStart)??null},c=o.useCallback(async()=>{if(!(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))){v(!0),d(null);try{const i=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${s.accessToken}`}});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||"Failed to fetch preferences")}const n=await i.json();f({tz:n.tz,weekStart:n.weekStart,source:n.source,isInherited:n.isInherited,userHasPrefs:n.userHasPrefs,inherited:n.inherited})}catch(i){const n=i instanceof Error?i.message:"Unknown error";d(n)}finally{v(!1)}}},[s,r]);o.useEffect(()=>{c()},[c]);const h=o.useCallback(async i=>{if(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))return d("Not authenticated"),!1;y(!0),d(null);try{const n=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.accessToken}`},body:JSON.stringify(i)});if(!n.ok){const u=await n.json().catch(()=>({}));throw new Error(u.error||"Failed to update preferences")}return await c(),!0}catch(n){const u=n instanceof Error?n.message:"Unknown error";return d(u),!1}finally{y(!1)}},[s,r,c]),g=o.useCallback(async()=>{if(!(s!=null&&s.accessToken)||!(r!=null&&r.apiServiceUrl))return d("Not authenticated"),!1;w(!0),d(null);try{const i=await fetch(`${r.apiServiceUrl}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${s.accessToken}`}});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||"Failed to clear preferences")}const n=await i.text();if(n)try{const u=JSON.parse(n);return f({tz:u.tz,weekStart:u.weekStart,source:u.source,isInherited:u.isInherited??!0,userHasPrefs:!1,inherited:u.inherited}),!0}catch{}return await c(),!0}catch(i){const n=i instanceof Error?i.message:"Unknown error";return d(n),!1}finally{w(!1)}},[s,r,c]);return{preferences:C,isLoading:l,isSaving:k,isClearing:T,error:x,updatePreferences:h,clearPreferences:g,refetch:c}}const N=[{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"}],U=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function W(){try{const s=Intl;if(s.supportedValuesOf)return s.supportedValuesOf("timeZone")}catch{}return N.map(s=>s.value)}function B(s){switch(s){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function L(s){const r=N.find(l=>l.value===s);return r?r.label:s}function G(s){const r=U.find(l=>l.value===s);return r?r.label:String(s)}function _({open:s,onOpenChange:r}){var z,A,E;const{preferences:l,isLoading:v,isSaving:k,isClearing:y,updatePreferences:T,clearPreferences:w}=R(),x=l.tz||((z=l.inherited)==null?void 0:z.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,d=l.weekStart??((A=l.inherited)==null?void 0:A.weekStart)??1,[m,f]=o.useState(!l.userHasPrefs),[C,c]=o.useState(!1),[h,g]=o.useState(x),[S,b]=o.useState(d),[j,p]=o.useState(!1),i=o.useMemo(()=>W(),[]),n=o.useMemo(()=>i.filter(t=>!N.some($=>$.value===t)),[i]),u=o.useMemo(()=>L(h),[h]),I=l.inherited?L(l.inherited.tz):"UTC",D=l.inherited?G(l.inherited.weekStart):"Monday",F=B((E=l.inherited)==null?void 0:E.source);o.useEffect(()=>{if(!s){c(!1);return}C||(l.userHasPrefs!==void 0&&f(!l.userHasPrefs),g(x),b(d))},[s,C,l.userHasPrefs,x,d]);const H=async()=>{if(v){a.ue.error("Preferences are still loading. Please try again.");return}m?await w()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),r(!1)):a.ue.error("Failed to save preferences. Please try again."):await T({tz:h,weekStart:S})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),r(!1)):a.ue.error("Failed to save preferences. Please try again.")},O=()=>{r(!1)},P=k||y,M=P||v;return e.jsx(a.Dialog,{open:s,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),f(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),f(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",F," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[I,", Week starts ",D]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),f(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:j,onOpenChange:p,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":j,className:"w-full justify-between",disabled:m,children:[u,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 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:N.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),g(t.value),p(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",h===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:n.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),g(t),p(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",h===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(S),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:U.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:O,disabled:P,children:"Cancel"}),e.jsx(a.Button,{onClick:H,disabled:M,children:P?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}exports.CalendarPreferencesDialog=_;
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { jsx as s, jsxs as n, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import X, { useState as m, useCallback as L, useEffect as ee, useMemo as D } from "react";
|
|
3
|
+
import { l as ae, m as re, n as se, o as te, p as ne, q as le, R as j, c as v, r as I, L as N, P as ie, s as oe, B as F, C as ce, t as de, v as ue, w as me, x as fe, y as he, z as W, A as M, E as B, F as pe, G as ve, H as ge, I as T } from "./index-CWTYAZIx.js";
|
|
4
|
+
function be() {
|
|
5
|
+
var y, w, C, p;
|
|
6
|
+
const { authToken: e, tokenProps: a } = ae(), [l, g] = m(!1), [A, k] = m(!1), [E, x] = m(!1), [b, d] = m(null), [u, f] = m(null), P = u || {
|
|
7
|
+
tz: ((w = (y = a == null ? void 0 : a.params) == null ? void 0 : y.calendarContext) == null ? void 0 : w.tz) || null,
|
|
8
|
+
weekStart: ((p = (C = a == null ? void 0 : a.params) == null ? void 0 : C.calendarContext) == null ? void 0 : p.weekStart) ?? null
|
|
9
|
+
}, o = L(async () => {
|
|
10
|
+
if (!(!(e != null && e.accessToken) || !(a != null && a.apiServiceUrl))) {
|
|
11
|
+
g(!0), d(null);
|
|
12
|
+
try {
|
|
13
|
+
const i = await fetch(
|
|
14
|
+
`${a.apiServiceUrl}/v1/user-preferences/calendar`,
|
|
15
|
+
{
|
|
16
|
+
method: "GET",
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${e.accessToken}`
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
if (!i.ok) {
|
|
23
|
+
const c = await i.json().catch(() => ({}));
|
|
24
|
+
throw new Error(c.error || "Failed to fetch preferences");
|
|
25
|
+
}
|
|
26
|
+
const t = await i.json();
|
|
27
|
+
f({
|
|
28
|
+
tz: t.tz,
|
|
29
|
+
weekStart: t.weekStart,
|
|
30
|
+
source: t.source,
|
|
31
|
+
isInherited: t.isInherited,
|
|
32
|
+
userHasPrefs: t.userHasPrefs,
|
|
33
|
+
inherited: t.inherited
|
|
34
|
+
});
|
|
35
|
+
} catch (i) {
|
|
36
|
+
const t = i instanceof Error ? i.message : "Unknown error";
|
|
37
|
+
d(t);
|
|
38
|
+
} finally {
|
|
39
|
+
g(!1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [e, a]);
|
|
43
|
+
ee(() => {
|
|
44
|
+
o();
|
|
45
|
+
}, [o]);
|
|
46
|
+
const h = L(
|
|
47
|
+
async (i) => {
|
|
48
|
+
if (!(e != null && e.accessToken) || !(a != null && a.apiServiceUrl))
|
|
49
|
+
return d("Not authenticated"), !1;
|
|
50
|
+
k(!0), d(null);
|
|
51
|
+
try {
|
|
52
|
+
const t = await fetch(
|
|
53
|
+
`${a.apiServiceUrl}/v1/user-preferences/calendar`,
|
|
54
|
+
{
|
|
55
|
+
method: "PATCH",
|
|
56
|
+
headers: {
|
|
57
|
+
"Content-Type": "application/json",
|
|
58
|
+
Authorization: `Bearer ${e.accessToken}`
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify(i)
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
if (!t.ok) {
|
|
64
|
+
const c = await t.json().catch(() => ({}));
|
|
65
|
+
throw new Error(c.error || "Failed to update preferences");
|
|
66
|
+
}
|
|
67
|
+
return await o(), !0;
|
|
68
|
+
} catch (t) {
|
|
69
|
+
const c = t instanceof Error ? t.message : "Unknown error";
|
|
70
|
+
return d(c), !1;
|
|
71
|
+
} finally {
|
|
72
|
+
k(!1);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[e, a, o]
|
|
76
|
+
), S = L(async () => {
|
|
77
|
+
if (!(e != null && e.accessToken) || !(a != null && a.apiServiceUrl))
|
|
78
|
+
return d("Not authenticated"), !1;
|
|
79
|
+
x(!0), d(null);
|
|
80
|
+
try {
|
|
81
|
+
const i = await fetch(
|
|
82
|
+
`${a.apiServiceUrl}/v1/user-preferences/calendar`,
|
|
83
|
+
{
|
|
84
|
+
method: "DELETE",
|
|
85
|
+
headers: {
|
|
86
|
+
Authorization: `Bearer ${e.accessToken}`
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
if (!i.ok) {
|
|
91
|
+
const c = await i.json().catch(() => ({}));
|
|
92
|
+
throw new Error(c.error || "Failed to clear preferences");
|
|
93
|
+
}
|
|
94
|
+
const t = await i.text();
|
|
95
|
+
if (t)
|
|
96
|
+
try {
|
|
97
|
+
const c = JSON.parse(t);
|
|
98
|
+
return f({
|
|
99
|
+
tz: c.tz,
|
|
100
|
+
weekStart: c.weekStart,
|
|
101
|
+
source: c.source,
|
|
102
|
+
isInherited: c.isInherited ?? !0,
|
|
103
|
+
userHasPrefs: !1,
|
|
104
|
+
inherited: c.inherited
|
|
105
|
+
}), !0;
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
return await o(), !0;
|
|
109
|
+
} catch (i) {
|
|
110
|
+
const t = i instanceof Error ? i.message : "Unknown error";
|
|
111
|
+
return d(t), !1;
|
|
112
|
+
} finally {
|
|
113
|
+
x(!1);
|
|
114
|
+
}
|
|
115
|
+
}, [e, a, o]);
|
|
116
|
+
return {
|
|
117
|
+
preferences: P,
|
|
118
|
+
isLoading: l,
|
|
119
|
+
isSaving: A,
|
|
120
|
+
isClearing: E,
|
|
121
|
+
error: b,
|
|
122
|
+
updatePreferences: h,
|
|
123
|
+
clearPreferences: S,
|
|
124
|
+
refetch: o
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const z = [
|
|
128
|
+
{ value: "America/New_York", label: "Eastern Time (US & Canada)" },
|
|
129
|
+
{ value: "America/Chicago", label: "Central Time (US & Canada)" },
|
|
130
|
+
{ value: "America/Denver", label: "Mountain Time (US & Canada)" },
|
|
131
|
+
{ value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
|
|
132
|
+
{ value: "America/Phoenix", label: "Arizona" },
|
|
133
|
+
{ value: "America/Anchorage", label: "Alaska" },
|
|
134
|
+
{ value: "Pacific/Honolulu", label: "Hawaii" },
|
|
135
|
+
{ value: "Europe/London", label: "London" },
|
|
136
|
+
{ value: "Europe/Paris", label: "Paris, Berlin, Rome" },
|
|
137
|
+
{ value: "Asia/Tokyo", label: "Tokyo" },
|
|
138
|
+
{ value: "Asia/Shanghai", label: "Beijing, Shanghai" },
|
|
139
|
+
{ value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
|
|
140
|
+
{ value: "Australia/Sydney", label: "Sydney" },
|
|
141
|
+
{ value: "UTC", label: "UTC" }
|
|
142
|
+
], R = [
|
|
143
|
+
{ value: 0, label: "Sunday" },
|
|
144
|
+
{ value: 1, label: "Monday" },
|
|
145
|
+
{ value: 6, label: "Saturday" }
|
|
146
|
+
];
|
|
147
|
+
function Se() {
|
|
148
|
+
try {
|
|
149
|
+
const e = Intl;
|
|
150
|
+
if (e.supportedValuesOf)
|
|
151
|
+
return e.supportedValuesOf("timeZone");
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
return z.map((e) => e.value);
|
|
155
|
+
}
|
|
156
|
+
function ye(e) {
|
|
157
|
+
switch (e) {
|
|
158
|
+
case "tenant":
|
|
159
|
+
return "tenant";
|
|
160
|
+
case "organization":
|
|
161
|
+
return "organization";
|
|
162
|
+
case "system":
|
|
163
|
+
return "system";
|
|
164
|
+
default:
|
|
165
|
+
return "default";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function _(e) {
|
|
169
|
+
const a = z.find((l) => l.value === e);
|
|
170
|
+
return a ? a.label : e;
|
|
171
|
+
}
|
|
172
|
+
function we(e) {
|
|
173
|
+
const a = R.find((l) => l.value === e);
|
|
174
|
+
return a ? a.label : String(e);
|
|
175
|
+
}
|
|
176
|
+
function ke({
|
|
177
|
+
open: e,
|
|
178
|
+
onOpenChange: a
|
|
179
|
+
}) {
|
|
180
|
+
var H, O, $;
|
|
181
|
+
const {
|
|
182
|
+
preferences: l,
|
|
183
|
+
isLoading: g,
|
|
184
|
+
isSaving: A,
|
|
185
|
+
isClearing: k,
|
|
186
|
+
updatePreferences: E,
|
|
187
|
+
clearPreferences: x
|
|
188
|
+
} = be(), b = l.tz || ((H = l.inherited) == null ? void 0 : H.tz) || Intl.DateTimeFormat().resolvedOptions().timeZone, d = l.weekStart ?? ((O = l.inherited) == null ? void 0 : O.weekStart) ?? 1, [u, f] = m(!l.userHasPrefs), [P, o] = m(!1), [h, S] = m(
|
|
189
|
+
b
|
|
190
|
+
), [y, w] = m(
|
|
191
|
+
d
|
|
192
|
+
), [C, p] = m(!1), i = D(() => Se(), []), t = D(
|
|
193
|
+
() => i.filter(
|
|
194
|
+
(r) => !z.some((Y) => Y.value === r)
|
|
195
|
+
),
|
|
196
|
+
[i]
|
|
197
|
+
), c = D(() => _(h), [h]), G = l.inherited ? _(l.inherited.tz) : "UTC", V = l.inherited ? we(l.inherited.weekStart) : "Monday", Z = ye(
|
|
198
|
+
($ = l.inherited) == null ? void 0 : $.source
|
|
199
|
+
);
|
|
200
|
+
X.useEffect(() => {
|
|
201
|
+
if (!e) {
|
|
202
|
+
o(!1);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
P || (l.userHasPrefs !== void 0 && f(!l.userHasPrefs), S(b), w(d));
|
|
206
|
+
}, [
|
|
207
|
+
e,
|
|
208
|
+
P,
|
|
209
|
+
l.userHasPrefs,
|
|
210
|
+
b,
|
|
211
|
+
d
|
|
212
|
+
]);
|
|
213
|
+
const J = async () => {
|
|
214
|
+
if (g) {
|
|
215
|
+
T.error("Preferences are still loading. Please try again.");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
u ? await x() ? (T.success(
|
|
219
|
+
"Now using default settings. Please refresh the page to apply changes.",
|
|
220
|
+
{ duration: 5e3 }
|
|
221
|
+
), a(!1)) : T.error("Failed to save preferences. Please try again.") : await E({
|
|
222
|
+
tz: h,
|
|
223
|
+
weekStart: y
|
|
224
|
+
}) ? (T.success(
|
|
225
|
+
"Preferences saved. Please refresh the page to apply changes.",
|
|
226
|
+
{ duration: 5e3 }
|
|
227
|
+
), a(!1)) : T.error("Failed to save preferences. Please try again.");
|
|
228
|
+
}, K = () => {
|
|
229
|
+
a(!1);
|
|
230
|
+
}, U = A || k, q = U || g;
|
|
231
|
+
return /* @__PURE__ */ s(re, { open: e, onOpenChange: a, children: /* @__PURE__ */ n(se, { className: "sm:max-w-[425px]", children: [
|
|
232
|
+
/* @__PURE__ */ n(te, { children: [
|
|
233
|
+
/* @__PURE__ */ s(ne, { children: "Calendar Preferences" }),
|
|
234
|
+
/* @__PURE__ */ s(le, { children: "Set your timezone and week start preferences for date calculations and displays." })
|
|
235
|
+
] }),
|
|
236
|
+
/* @__PURE__ */ n("div", { className: "space-y-6 py-4", children: [
|
|
237
|
+
/* @__PURE__ */ n(
|
|
238
|
+
j,
|
|
239
|
+
{
|
|
240
|
+
value: u ? "defaults" : "custom",
|
|
241
|
+
onValueChange: (r) => {
|
|
242
|
+
o(!0), f(r === "defaults");
|
|
243
|
+
},
|
|
244
|
+
className: "space-y-3",
|
|
245
|
+
children: [
|
|
246
|
+
/* @__PURE__ */ n(
|
|
247
|
+
"div",
|
|
248
|
+
{
|
|
249
|
+
className: v(
|
|
250
|
+
"flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",
|
|
251
|
+
u ? "border-primary bg-primary/5" : "border-border hover:border-muted-foreground/50"
|
|
252
|
+
),
|
|
253
|
+
onClick: () => {
|
|
254
|
+
o(!0), f(!0);
|
|
255
|
+
},
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ s(I, { value: "defaults", id: "mode-defaults" }),
|
|
258
|
+
/* @__PURE__ */ n("div", { className: "flex-1 space-y-1", children: [
|
|
259
|
+
/* @__PURE__ */ n(
|
|
260
|
+
N,
|
|
261
|
+
{
|
|
262
|
+
htmlFor: "mode-defaults",
|
|
263
|
+
className: "cursor-pointer font-medium",
|
|
264
|
+
children: [
|
|
265
|
+
"Use ",
|
|
266
|
+
Z,
|
|
267
|
+
" defaults"
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
/* @__PURE__ */ n("p", { className: "text-sm text-muted-foreground", children: [
|
|
272
|
+
G,
|
|
273
|
+
", Week starts ",
|
|
274
|
+
V
|
|
275
|
+
] })
|
|
276
|
+
] })
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
/* @__PURE__ */ n(
|
|
281
|
+
"div",
|
|
282
|
+
{
|
|
283
|
+
className: v(
|
|
284
|
+
"flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",
|
|
285
|
+
u ? "border-border hover:border-muted-foreground/50" : "border-primary bg-primary/5"
|
|
286
|
+
),
|
|
287
|
+
onClick: () => {
|
|
288
|
+
o(!0), f(!1);
|
|
289
|
+
},
|
|
290
|
+
children: [
|
|
291
|
+
/* @__PURE__ */ s(I, { value: "custom", id: "mode-custom" }),
|
|
292
|
+
/* @__PURE__ */ s(
|
|
293
|
+
N,
|
|
294
|
+
{
|
|
295
|
+
htmlFor: "mode-custom",
|
|
296
|
+
className: "cursor-pointer font-medium",
|
|
297
|
+
children: "Use custom settings"
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
/* @__PURE__ */ n(
|
|
307
|
+
"div",
|
|
308
|
+
{
|
|
309
|
+
className: v(
|
|
310
|
+
"space-y-6 transition-opacity",
|
|
311
|
+
u && "opacity-50 pointer-events-none"
|
|
312
|
+
),
|
|
313
|
+
children: [
|
|
314
|
+
/* @__PURE__ */ n("div", { className: "space-y-2", children: [
|
|
315
|
+
/* @__PURE__ */ s(N, { children: "Timezone" }),
|
|
316
|
+
/* @__PURE__ */ n(
|
|
317
|
+
ie,
|
|
318
|
+
{
|
|
319
|
+
open: C,
|
|
320
|
+
onOpenChange: p,
|
|
321
|
+
modal: !0,
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ s(oe, { asChild: !0, children: /* @__PURE__ */ n(
|
|
324
|
+
F,
|
|
325
|
+
{
|
|
326
|
+
variant: "outline",
|
|
327
|
+
role: "combobox",
|
|
328
|
+
"aria-expanded": C,
|
|
329
|
+
className: "w-full justify-between",
|
|
330
|
+
disabled: u,
|
|
331
|
+
children: [
|
|
332
|
+
c,
|
|
333
|
+
/* @__PURE__ */ s(ce, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
) }),
|
|
337
|
+
/* @__PURE__ */ s(
|
|
338
|
+
de,
|
|
339
|
+
{
|
|
340
|
+
className: "z-50 w-[--radix-popover-trigger-width] p-0",
|
|
341
|
+
align: "start",
|
|
342
|
+
children: /* @__PURE__ */ n(ue, { className: "overflow-visible", children: [
|
|
343
|
+
/* @__PURE__ */ s(me, { placeholder: "Search timezones..." }),
|
|
344
|
+
/* @__PURE__ */ n(fe, { children: [
|
|
345
|
+
/* @__PURE__ */ s(he, { children: "No timezone found." }),
|
|
346
|
+
/* @__PURE__ */ s(W, { heading: "Common", children: z.map((r) => /* @__PURE__ */ n(
|
|
347
|
+
M,
|
|
348
|
+
{
|
|
349
|
+
value: `${r.value} ${r.label}`,
|
|
350
|
+
onSelect: () => {
|
|
351
|
+
o(!0), S(r.value), p(!1);
|
|
352
|
+
},
|
|
353
|
+
children: [
|
|
354
|
+
/* @__PURE__ */ s(
|
|
355
|
+
B,
|
|
356
|
+
{
|
|
357
|
+
className: v(
|
|
358
|
+
"mr-2 h-4 w-4",
|
|
359
|
+
h === r.value ? "opacity-100" : "opacity-0"
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
/* @__PURE__ */ s("span", { className: "flex-1", children: r.label }),
|
|
364
|
+
/* @__PURE__ */ s("span", { className: "text-xs text-muted-foreground", children: r.value })
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
r.value
|
|
368
|
+
)) }),
|
|
369
|
+
/* @__PURE__ */ s(pe, {}),
|
|
370
|
+
/* @__PURE__ */ s(W, { heading: "All Timezones", children: t.map((r) => /* @__PURE__ */ n(
|
|
371
|
+
M,
|
|
372
|
+
{
|
|
373
|
+
value: r,
|
|
374
|
+
onSelect: () => {
|
|
375
|
+
o(!0), S(r), p(!1);
|
|
376
|
+
},
|
|
377
|
+
children: [
|
|
378
|
+
/* @__PURE__ */ s(
|
|
379
|
+
B,
|
|
380
|
+
{
|
|
381
|
+
className: v(
|
|
382
|
+
"mr-2 h-4 w-4",
|
|
383
|
+
h === r ? "opacity-100" : "opacity-0"
|
|
384
|
+
)
|
|
385
|
+
}
|
|
386
|
+
),
|
|
387
|
+
r
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
r
|
|
391
|
+
)) })
|
|
392
|
+
] })
|
|
393
|
+
] })
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
)
|
|
399
|
+
] }),
|
|
400
|
+
/* @__PURE__ */ n("div", { className: "space-y-3", children: [
|
|
401
|
+
/* @__PURE__ */ s(N, { children: "Week Starts On" }),
|
|
402
|
+
/* @__PURE__ */ s(
|
|
403
|
+
j,
|
|
404
|
+
{
|
|
405
|
+
value: String(y),
|
|
406
|
+
onValueChange: (r) => {
|
|
407
|
+
o(!0), w(Number(r));
|
|
408
|
+
},
|
|
409
|
+
className: "flex gap-4",
|
|
410
|
+
disabled: u,
|
|
411
|
+
children: R.map((r) => /* @__PURE__ */ n(
|
|
412
|
+
"div",
|
|
413
|
+
{
|
|
414
|
+
className: "flex items-center space-x-2",
|
|
415
|
+
children: [
|
|
416
|
+
/* @__PURE__ */ s(
|
|
417
|
+
I,
|
|
418
|
+
{
|
|
419
|
+
value: String(r.value),
|
|
420
|
+
id: `week-start-${r.value}`,
|
|
421
|
+
disabled: u
|
|
422
|
+
}
|
|
423
|
+
),
|
|
424
|
+
/* @__PURE__ */ s(
|
|
425
|
+
N,
|
|
426
|
+
{
|
|
427
|
+
htmlFor: `week-start-${r.value}`,
|
|
428
|
+
className: v(
|
|
429
|
+
"cursor-pointer font-normal",
|
|
430
|
+
u && "cursor-not-allowed"
|
|
431
|
+
),
|
|
432
|
+
children: r.label
|
|
433
|
+
}
|
|
434
|
+
)
|
|
435
|
+
]
|
|
436
|
+
},
|
|
437
|
+
r.value
|
|
438
|
+
))
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
] })
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
] }),
|
|
446
|
+
/* @__PURE__ */ n(ve, { children: [
|
|
447
|
+
/* @__PURE__ */ s(F, { variant: "outline", onClick: K, disabled: U, children: "Cancel" }),
|
|
448
|
+
/* @__PURE__ */ s(F, { onClick: J, disabled: q, children: U ? /* @__PURE__ */ n(Q, { children: [
|
|
449
|
+
/* @__PURE__ */ s(ge, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
450
|
+
"Saving..."
|
|
451
|
+
] }) : "Save" })
|
|
452
|
+
] })
|
|
453
|
+
] }) });
|
|
454
|
+
}
|
|
455
|
+
export {
|
|
456
|
+
ke as C
|
|
457
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l={database:null,schema:null,table:null};exports.EMPTY_SELECTION=l;
|