sodtrack-web-ui 0.113.0 → 0.114.0

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.
@@ -0,0 +1 @@
1
+ import {ptBR,es,enUS}from'date-fns/locale';import {LocaleProvider}from'@ark-ui/react/locale';import {setDefaultOptions}from'date-fns';import {createContext,useContext,useState,useCallback,useMemo,useLayoutEffect}from'react';import {jsx}from'react/jsx-runtime';var F={en:enUS,es:es,pt:ptBR},p=e=>F[e];var u=new Date(2006,10,22,13,45),U=(e,t,o)=>e.formatToParts(t).find(n=>n.type===o)?.value,l=(e,t)=>e.map(o=>t.has(o.type)?o.type==="year"?"0".repeat(o.value.length):"00":o.value).join(""),Z=({language:e,formatRegion:t,timeZone:o=Intl.DateTimeFormat().resolvedOptions().timeZone,date:n=new Date})=>{let r=`${e}-${t}`,c=new Intl.DateTimeFormat("en-US",{timeZone:o,timeZoneName:"longOffset"}),i=new Intl.DateTimeFormat(r,{timeZone:o,dateStyle:"short"}),g=new Intl.DateTimeFormat(r,{timeZone:o,timeStyle:"short"}),a=U(c,n,"timeZoneName")??"GMT";return {timeZone:o,utcOffset:a==="GMT"?"GMT+00:00":a,datePattern:l(i.formatToParts(u),new Set(["day","month","year"])),timePattern:l(g.formatToParts(u),new Set(["hour","minute","second"]))}};var S=["en","es","pt"],w=["AG","AR","BS","BB","BZ","BO","BR","CA","CL","CO","CR","CU","DM","DO","EC","SV","GD","GT","GY","HT","HN","JM","MX","NI","PA","PY","PE","KN","LC","VC","SR","TT","UY","US","VE"],I=["blue","green","indigo","purple","red","black","sodtrack"],N=["horizontal","vertical"],E=new Set(S),A=new Set(w),x=new Set(I),h=new Set(N),O=e=>typeof e=="string"&&E.has(e),D=e=>typeof e=="string"&&A.has(e),C=e=>typeof e=="string"&&x.has(e),_=e=>typeof e=="string"&&h.has(e),s=e=>{if(typeof e!="object"||e===null)return false;let t=e;return O(t.language)&&D(t.formatRegion)&&C(t.themeId)&&(t.navigationLayout===void 0||_(t.navigationLayout))};var m={language:"en",formatRegion:"US"},P=e=>{m=e;},z=()=>m,X=()=>{let{language:e,formatRegion:t}=m;return `${e}-${t}`};var y="sodtrack.ui-preferences.v1",v=createContext(void 0),f=(e,t)=>t===(e.navigationLayout!==void 0),H=(e,t)=>{if(!s(e)||!f(e,t))throw new Error("PreferencesProvider received invalid default preferences.");if(typeof window>"u")return e;try{let o=window.localStorage.getItem(y);if(!o)return e;let n=JSON.parse(o);return s(n)&&f(n,t)?n:e}catch{return e}},ae=()=>{let e=useContext(v);if(!e)throw new Error("usePreferences must be used within a PreferencesProvider.");return e},ie=({capabilities:e,defaultValue:t,children:o})=>{let n=e.navigationLayout,[r,c]=useState(()=>H(t,n)),i=useCallback(a=>{if(!s(a)||!f(a,n))throw new Error("Cannot save invalid UI preferences.");window.localStorage.setItem(y,JSON.stringify(a)),c(a);},[n]),g=useMemo(()=>({capabilities:{navigationLayout:n},preferences:r,savePreferences:i}),[n,r,i]);return useLayoutEffect(()=>{document.documentElement.dataset.theme=r.themeId;},[r.themeId]),P({language:r.language,formatRegion:r.formatRegion}),setDefaultOptions({locale:p(r.language)}),jsx(v.Provider,{value:g,children:jsx(LocaleProvider,{locale:`${r.language}-${r.formatRegion}`,children:o})})};export{p as a,z as b,X as c,Z as d,S as e,w as f,I as g,N as h,O as i,D as j,C as k,_ as l,s as m,ae as n,ie as o};
package/dist/format.d.ts CHANGED
@@ -11,7 +11,11 @@ declare const getDateFnsLocale: (language: UiLanguage) => Locale;
11
11
 
12
12
  declare const DATE_ERROR = "Invalid date";
13
13
  type DateFormatOptions = {
14
+ /** Format in UTC. Takes precedence over `timeZone` when both are provided. */
14
15
  utc?: boolean;
16
+ /** IANA time zone used to format values that represent an instant. */
17
+ timeZone?: string;
18
+ /** Returned when the value or time zone is invalid. */
15
19
  fallback?: string;
16
20
  };
17
21
  type TimeRangeOptions = DateFormatOptions & {
@@ -53,7 +57,9 @@ declare const formatDateTime: (value: Date | string, options?: DateFormatOptions
53
57
  * Bare `HH:mm[:ss]` strings are supported.
54
58
  *
55
59
  * @example With `es-CL` active:
56
- * formatTime("2026-03-04T09:05:00Z", { utc: true }); // "9:05 a. m."
60
+ * formatTime("2026-03-04T09:05:00Z", {
61
+ * timeZone: "America/Santiago",
62
+ * }); // "6:05 a. m."
57
63
  */
58
64
  declare const formatTime: (value: Date | string, options?: DateFormatOptions) => string;
59
65
  /**
@@ -107,6 +113,13 @@ declare const formatRelativeTime: (value: Date | string, base?: Date, options?:
107
113
  * "2000-01-01T12:00:00Z",
108
114
  * { utc: true, hour12: false },
109
115
  * ); // "08:00 - 12:00"
116
+ *
117
+ * @example With `es-CL` active:
118
+ * formatTimeRange(
119
+ * "2026-03-04T09:05:00Z",
120
+ * "2026-03-04T17:30:00Z",
121
+ * { timeZone: "America/Santiago" },
122
+ * ); // "6:05 a. m. - 2:30 p. m."
110
123
  */
111
124
  declare const formatTimeRange: (start: Date | string, end: Date | string, options?: TimeRangeOptions) => string;
112
125
  /**
@@ -156,37 +169,43 @@ declare const formatDurationFromMinutes: (minutes: number, options?: FormatDurat
156
169
  */
157
170
  declare const formatDurationFromSeconds: (seconds: number, options?: FormatDurationOptions) => string;
158
171
 
172
+ type NumberFormatValue = number | string;
159
173
  type NumberFormatOptions = Intl.NumberFormatOptions & {
160
174
  fallback?: string;
161
175
  };
162
176
  type CurrencyFormatOptions = Omit<NumberFormatOptions, "currency" | "style">;
163
177
  type PercentageFormatOptions = Omit<NumberFormatOptions, "style">;
178
+
164
179
  /**
165
- * Formats a finite number with the language and formatting region applied by
166
- * `PreferencesProvider`.
180
+ * Formats a finite number or numeric string with the language and formatting
181
+ * region applied by `PreferencesProvider`.
182
+ * Use `useNumberFormat` when the result must react to preference changes.
167
183
  *
168
184
  * @example With `es-CL` active:
169
185
  * formatNumber(1234.5); // "1.234,5"
186
+ * formatNumber("4000.00"); // "4.000"
170
187
  */
171
- declare const formatNumber: (value: number, { fallback, ...options }?: NumberFormatOptions) => string;
188
+ declare const formatNumber: (value: NumberFormatValue, options?: NumberFormatOptions) => string;
172
189
  /**
173
190
  * Formats a finite number as currency with the active language and formatting
174
191
  * region. When `currency` is missing or invalid, it falls back to
175
192
  * `formatNumber`.
193
+ * Use `useNumberFormat` when the result must react to preference changes.
176
194
  *
177
195
  * @example With `es-CL` active:
178
196
  * formatCurrency(1234.5, "USD"); // "US$1.234,50"
179
197
  * formatCurrency(1234.5); // "1.234,5"
180
198
  */
181
- declare const formatCurrency: (value: number, currency?: string, { fallback, ...options }?: CurrencyFormatOptions) => string;
199
+ declare const formatCurrency: (value: NumberFormatValue, currency?: string, options?: CurrencyFormatOptions) => string;
182
200
  /**
183
201
  * Formats a percentage expressed on a 0–100 scale with the active language and
184
202
  * formatting region.
203
+ * Use `useNumberFormat` when the result must react to preference changes.
185
204
  *
186
205
  * @example With `es-CL` active:
187
206
  * formatPercentage(12.5); // "12,5%"
188
207
  */
189
- declare const formatPercentage: (value: number, { fallback, maximumFractionDigits, ...options }?: PercentageFormatOptions) => string;
208
+ declare const formatPercentage: (value: NumberFormatValue, options?: PercentageFormatOptions) => string;
190
209
 
191
210
  type RegionalFormatPreview = {
192
211
  timeZone: string;
@@ -221,4 +240,23 @@ type RegionalFormatPreviewOptions = {
221
240
  */
222
241
  declare const getRegionalFormatPreview: ({ language, formatRegion, timeZone, date, }: RegionalFormatPreviewOptions) => RegionalFormatPreview;
223
242
 
224
- export { type CurrencyFormatOptions, DATE_ERROR, type DateFormatOptions, type NumberFormatOptions, type PercentageFormatOptions, type RegionalFormatPreview, type RegionalFormatPreviewOptions, type TimeRangeOptions, formatCurrency, formatDate, formatDateTime, formatDateTimeRange, formatDuration, formatDurationFromMinutes, formatDurationFromSeconds, formatElapsed, formatLongDate, formatMonthYear, formatNumber, formatPercentage, formatRelativeTime, formatShortDate, formatTime, formatTime24h, formatTimeRange, formatWeekday, getDateFnsLocale, getRegionalFormatPreview };
243
+ type NumberFormatters = {
244
+ formatNumber: (value: NumberFormatValue, options?: NumberFormatOptions) => string;
245
+ formatCurrency: (value: NumberFormatValue, currency?: string, options?: CurrencyFormatOptions) => string;
246
+ formatPercentage: (value: NumberFormatValue, options?: PercentageFormatOptions) => string;
247
+ };
248
+ /**
249
+ * Returns number formatters bound to the language and formatting region from
250
+ * `PreferencesProvider`. The returned functions update when either preference
251
+ * changes and keep stable identities while the active locale remains unchanged.
252
+ *
253
+ * @example With `es-CL` active:
254
+ * const { formatCurrency, formatNumber, formatPercentage } = useNumberFormat();
255
+ *
256
+ * formatNumber("4000.00"); // "4.000"
257
+ * formatCurrency("4000.00", "USD"); // "US$4.000,00"
258
+ * formatPercentage("12.50"); // "12,5%"
259
+ */
260
+ declare const useNumberFormat: () => NumberFormatters;
261
+
262
+ export { type CurrencyFormatOptions, DATE_ERROR, type DateFormatOptions, type NumberFormatOptions, type NumberFormatValue, type NumberFormatters, type PercentageFormatOptions, type RegionalFormatPreview, type RegionalFormatPreviewOptions, type TimeRangeOptions, formatCurrency, formatDate, formatDateTime, formatDateTimeRange, formatDuration, formatDurationFromMinutes, formatDurationFromSeconds, formatElapsed, formatLongDate, formatMonthYear, formatNumber, formatPercentage, formatRelativeTime, formatShortDate, formatTime, formatTime24h, formatTimeRange, formatWeekday, getDateFnsLocale, getRegionalFormatPreview, useNumberFormat };
package/dist/format.js CHANGED
@@ -1 +1 @@
1
- import {d as d$1,c,a}from'./chunk-OGXELKVW.js';export{a as getDateFnsLocale,e as getRegionalFormatPreview}from'./chunk-OGXELKVW.js';import {UTCDateMini}from'@date-fns/utc';import {isValid,millisecondsToHours,millisecondsToMinutes,millisecondsToSeconds,formatDuration,parseISO}from'date-fns';var u="Invalid date",V=/^([0-1]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,h=new Map,I=new Map,_=[{amount:60,unit:"second"},{amount:60,unit:"minute"},{amount:24,unit:"hour"},{amount:7,unit:"day"},{amount:4.34524,unit:"week"},{amount:12,unit:"month"},{amount:Number.POSITIVE_INFINITY,unit:"year"}],U=(t,r)=>{let e=`${t}:${JSON.stringify(r)}`,n=h.get(e);return n||(n=new Intl.DateTimeFormat(t,r),h.set(e,n)),n},R=t=>V.test(t),x=(t,r)=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(t)||!R(r))return null;let e=l(`${t}T${r}`);return isValid(e)?e:null},l=(t,r)=>{if(t instanceof Date)return t;if(r)return new UTCDateMini(t);let e=parseISO(t);return isValid(e)?e:new Date(t)},g=(t,r)=>typeof t=="string"&&R(t)?l(`2000-01-01T${t}`,r):l(t,r),Y=(t,r)=>r?{...t,timeZone:"UTC"}:t,m=(t,r,e,n=l)=>{let o=n(t,e?.utc);if(!isValid(o))return e?.fallback??u;try{return U(d$1(),Y(r,e?.utc)).format(o)}catch{return e?.fallback??u}},N=(t,r)=>m(t,{dateStyle:"medium"},r),z=(t,r)=>m(t,{dateStyle:"long"},r),H=(t,r)=>m(t,{dateStyle:"short"},r),w=(t,r)=>m(t,{dateStyle:"medium",timeStyle:"short"},r),p=(t,r)=>m(t,{timeStyle:"short"},r,g),M=(t,r)=>m(t,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"},r,g),J=(t,r)=>{let e=m(t,{month:"long",year:"numeric"},r);return !r?.capitalize||e===(r.fallback??u)?e:e.charAt(0).toLocaleUpperCase(d$1())+e.slice(1)},W=(t,r)=>m(t,{hour:"numeric",minute:"2-digit",hour12:true},r,g),B=(t,r)=>m(t,{weekday:r?.weekday??"long"},r),Z=(t,r=new Date,e)=>{let n=l(t);if(!isValid(n))return e?.fallback??u;let o=d$1(),a=I.get(o);a||(a=new Intl.RelativeTimeFormat(o,{numeric:"auto"}),I.set(o,a));let i=(n.getTime()-r.getTime())/1e3;for(let{amount:f,unit:D}of _){if(Math.abs(i)<f)return a.format(Math.round(i),D);i/=f;}return e?.fallback??u},j=(t,r,e)=>{let n=e?.fallback??u,o=g(t,e?.utc),a=g(r,e?.utc);if(!isValid(o)||!isValid(a))return n;let i=e?.hour12===false?M:e?.hour12===true?W:p,f={utc:e?.utc,fallback:e?.fallback},D=i(o,f),k=i(a,f);return `${D} - ${k}`},q=(t,r,e,n)=>{let o=n?.fallback??u,a=x(t,r);if(!a)return o;if(!e)return w(a,n);let i=x(t,e);return i?`${N(a,n)} (${p(a,n)} - ${p(i,n)})`:o},G=(t,r=new Date)=>{let e=l(t);if(!isValid(e))return null;let n=Math.max(0,r.getTime()-e.getTime()),o=a=>String(a).padStart(2,"0");return `${o(millisecondsToHours(n))}:${o(millisecondsToMinutes(n)%60)}:${o(millisecondsToSeconds(n)%60)}`},d=(t,r)=>{let{language:e}=c();return formatDuration(t,{locale:a(e),...r})},K=(t,r,e={hours:true,minutes:true})=>{if(!Number.isFinite(t))return "Invalid duration";let n=Math.round(t),o=e.hours!==false,a=e.minutes!==false,i={};return o&&(i.hours=a?Math.floor(n/60):Math.round(n/60)),a&&(i.minutes=o?n%60:n),d(i,r)},Q=(t,r)=>Number.isFinite(t)?d({days:Math.floor(t/86400),hours:Math.floor(t%86400/3600),minutes:Math.floor(t%3600/60)},r):"Invalid duration";var S=new Map,b=(t,r)=>{let e=`${t}:${JSON.stringify(r)}`,n=S.get(e);return n||(n=new Intl.NumberFormat(t,r),S.set(e,n)),n},O=t=>Number.isFinite(t),y=(t,{fallback:r="Invalid number",...e}={})=>{if(!O(t))return r;try{return b(d$1(),e).format(t)}catch{return r}},X=(t,r,{fallback:e="Invalid currency",...n}={})=>{if(!O(t))return e;if(!r)return y(t,{fallback:e,...n});try{return b(d$1(),{...n,style:"currency",currency:r}).format(t)}catch{return y(t,{fallback:e,...n})}},tt=(t,{fallback:r="Invalid percentage",maximumFractionDigits:e=2,...n}={})=>{if(!O(t))return r;try{return b(d$1(),{...n,style:"percent",maximumFractionDigits:e}).format(t/100)}catch{return r}};export{u as DATE_ERROR,X as formatCurrency,N as formatDate,w as formatDateTime,q as formatDateTimeRange,d as formatDuration,K as formatDurationFromMinutes,Q as formatDurationFromSeconds,G as formatElapsed,z as formatLongDate,J as formatMonthYear,y as formatNumber,tt as formatPercentage,Z as formatRelativeTime,H as formatShortDate,p as formatTime,M as formatTime24h,j as formatTimeRange,B as formatWeekday};
1
+ import {c,b as b$1,a,n}from'./chunk-W4P4M4HC.js';export{a as getDateFnsLocale,d as getRegionalFormatPreview}from'./chunk-W4P4M4HC.js';import {UTCDateMini}from'@date-fns/utc';import {isValid,millisecondsToHours,millisecondsToMinutes,millisecondsToSeconds,formatDuration,parseISO}from'date-fns';import {useMemo}from'react';var u="Invalid date",z=/^([0-1]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,V=new Map,R=new Map,O=new Map,H=[{amount:60,unit:"second"},{amount:60,unit:"minute"},{amount:24,unit:"hour"},{amount:7,unit:"day"},{amount:4.34524,unit:"week"},{amount:12,unit:"month"},{amount:Number.POSITIVE_INFINITY,unit:"year"}],J=(t,r)=>{let e=`${t}:${JSON.stringify(r)}`,o=V.get(e);return o||(o=new Intl.DateTimeFormat(t,r),V.set(e,o)),o},w=t=>z.test(t),C=(t,r)=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(t)||!w(r))return null;let e=l(`${t}T${r}`);return isValid(e)?e:null},l=(t,r)=>{if(t instanceof Date)return t;if(r)return new UTCDateMini(t);let e=parseISO(t);return isValid(e)?e:new Date(t)},p=(t,r)=>typeof t=="string"&&w(t)?l(`2000-01-01T${t}`,r):l(t,r),M=t=>t?.utc?"UTC":t?.timeZone,W=t=>{if(t===void 0)return true;let r=O.get(t);if(r!==void 0)return r;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),O.set(t,!0),!0}catch{return O.set(t,false),false}},B=(t,r)=>{let e=M(r);return e===void 0?t:{...t,timeZone:e}},i=(t,r,e,o=l)=>{let n=o(t,e?.utc);if(!isValid(n))return e?.fallback??u;try{return J(c(),B(r,e)).format(n)}catch{return e?.fallback??u}},P=(t,r)=>i(t,{dateStyle:"medium"},r),j=(t,r)=>i(t,{dateStyle:"long"},r),q=(t,r)=>i(t,{dateStyle:"short"},r),S=(t,r)=>i(t,{dateStyle:"medium",timeStyle:"short"},r),F=(t,r)=>i(t,{timeStyle:"short"},r,p),k=(t,r)=>i(t,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"},r,p),G=(t,r)=>{let e=i(t,{month:"long",year:"numeric"},r);return !r?.capitalize||e===(r.fallback??u)?e:e.charAt(0).toLocaleUpperCase(c())+e.slice(1)},K=(t,r)=>i(t,{hour:"numeric",minute:"2-digit",hour12:true},r,p),Q=(t,r)=>i(t,{weekday:r?.weekday??"long"},r),X=(t,r=new Date,e)=>{let o=l(t);if(!isValid(o))return e?.fallback??u;let n=c(),a=R.get(n);a||(a=new Intl.RelativeTimeFormat(n,{numeric:"auto"}),R.set(n,a));let m=(o.getTime()-r.getTime())/1e3;for(let{amount:g,unit:y}of H){if(Math.abs(m)<g)return a.format(Math.round(m),y);m/=g;}return e?.fallback??u},tt=(t,r,e)=>{let o=e?.fallback??u,n=p(t,e?.utc),a=p(r,e?.utc);if(!isValid(n)||!isValid(a)||!W(M(e)))return o;let m=e?.hour12===false?k:e?.hour12===true?K:F,g={utc:e?.utc,timeZone:e?.timeZone,fallback:e?.fallback},y=m(n,g),L=m(a,g);return `${y} - ${L}`},rt=(t,r,e,o)=>{let n=o?.fallback??u,a=C(t,r);if(!a)return n;if(!e)return S(a,o);let m=C(t,e);return m?`${P(a,o)} (${F(a,o)} - ${F(m,o)})`:n},et=(t,r=new Date)=>{let e=l(t);if(!isValid(e))return null;let o=Math.max(0,r.getTime()-e.getTime()),n=a=>String(a).padStart(2,"0");return `${n(millisecondsToHours(o))}:${n(millisecondsToMinutes(o)%60)}:${n(millisecondsToSeconds(o)%60)}`},N=(t,r)=>{let{language:e}=b$1();return formatDuration(t,{locale:a(e),...r})},ot=(t,r,e={hours:true,minutes:true})=>{if(!Number.isFinite(t))return "Invalid duration";let o=Math.round(t),n=e.hours!==false,a=e.minutes!==false,m={};return n&&(m.hours=a?Math.floor(o/60):Math.round(o/60)),a&&(m.minutes=n?o%60:o),N(m,r)},nt=(t,r)=>Number.isFinite(t)?N({days:Math.floor(t/86400),hours:Math.floor(t%86400/3600),minutes:Math.floor(t%3600/60)},r):"Invalid duration";var $=new Map,T=(t,r)=>{let e=`${t}:${JSON.stringify(r)}`,o=$.get(e);return o||(o=new Intl.NumberFormat(t,r),$.set(e,o)),o},h=t=>{if(typeof t=="string"&&t.trim()==="")return null;let r=typeof t=="string"?Number(t):t;return Number.isFinite(r)?r:null},f=(t,r,{fallback:e="Invalid number",...o}={})=>{let n=h(r);if(n===null)return e;try{return T(t,o).format(n)}catch{return e}},D=(t,r,e,{fallback:o="Invalid currency",...n}={})=>{let a=h(r);if(a===null)return o;if(!e)return f(t,a,{fallback:o,...n});try{return T(t,{...n,style:"currency",currency:e}).format(a)}catch{return f(t,a,{fallback:o,...n})}},b=(t,r,{fallback:e="Invalid percentage",maximumFractionDigits:o=2,...n}={})=>{let a=h(r);if(a===null)return e;try{return T(t,{...n,style:"percent",maximumFractionDigits:o}).format(a/100)}catch{return e}};var at=(t,r)=>f(c(),t,r),mt=(t,r,e)=>D(c(),t,r,e),it=(t,r)=>b(c(),t,r);var ut=()=>{let{preferences:{language:t,formatRegion:r}}=n(),e=`${t}-${r}`;return useMemo(()=>({formatNumber:(o,n)=>f(e,o,n),formatCurrency:(o,n,a)=>D(e,o,n,a),formatPercentage:(o,n)=>b(e,o,n)}),[e])};export{u as DATE_ERROR,mt as formatCurrency,P as formatDate,S as formatDateTime,rt as formatDateTimeRange,N as formatDuration,ot as formatDurationFromMinutes,nt as formatDurationFromSeconds,et as formatElapsed,j as formatLongDate,G as formatMonthYear,at as formatNumber,it as formatPercentage,X as formatRelativeTime,q as formatShortDate,F as formatTime,k as formatTime24h,tt as formatTimeRange,Q as formatWeekday,ut as useNumberFormat};
package/dist/locale.d.ts CHANGED
@@ -89,24 +89,6 @@ declare const getLanguageName: (locale: SupportedLocale$1, displayIn?: Supported
89
89
  declare const setActiveLocale: (locale: SupportedLocale$1) => void;
90
90
  /** @deprecated Read applied preferences with `usePreferences`. */
91
91
  declare const getActiveLocale: () => SupportedLocale$1;
92
- /** @deprecated Use `formatNumber` from `sodtrack-web-ui/format`. */
93
- declare const formatNumber: (locale: string, value: number, options?: Intl.NumberFormatOptions) => string;
94
- /** @deprecated Use `formatCurrency` from `sodtrack-web-ui/format`. */
95
- declare const formatCurrency: (locale: string, value: number, currency: string, options?: Intl.NumberFormatOptions) => string;
96
- /** @deprecated Use `formatPercentage` from `sodtrack-web-ui/format`, which expects a 0–100 value. */
97
- declare const formatPercent: (locale: string, ratio: number, options?: Intl.NumberFormatOptions) => string;
98
- /** @deprecated Use `formatNumber` from `sodtrack-web-ui/format`. */
99
- declare const toNumber: (value: number, options?: Intl.NumberFormatOptions) => string;
100
- /** @deprecated Use `formatCurrency` from `sodtrack-web-ui/format`. */
101
- declare const toCurrency: (value: number, currency?: string, options?: Intl.NumberFormatOptions) => string;
102
- /** @deprecated Use `formatPercentage` from `sodtrack-web-ui/format`. */
103
- declare const toPercentage: (value: number, options?: Intl.NumberFormatOptions) => string;
104
- /** @deprecated Import the provider-aware formatters from `sodtrack-web-ui/format` directly. */
105
- declare const useNumber: () => {
106
- toNumber: (value: number, options?: Intl.NumberFormatOptions) => string;
107
- toCurrency: (value: number, currency?: string, options?: Intl.NumberFormatOptions) => string;
108
- toPercentage: (value: number, options?: Intl.NumberFormatOptions) => string;
109
- };
110
92
  /** @deprecated Use `DATE_ERROR` from `sodtrack-web-ui/format`. */
111
93
  declare const DATE_ERROR = "Invalid date";
112
94
  /** @deprecated Use application validation or `date-fns`. */
@@ -173,4 +155,4 @@ declare const LocaleFlag: ({ locale, className, alt, }: {
173
155
  alt?: string;
174
156
  }) => react_jsx_runtime.JSX.Element;
175
157
 
176
- export { type BackendLang, DATE_ERROR, type DateFormatOptions, LOCALE_REGISTRY, type LocaleConfig, LocaleFlag, SUPPORTED_LOCALES, type SupportedLocale, type UiLanguage, formatCurrency, formatDate, formatDateTime, formatDateTimeRange, formatDuration, formatDurationFromMinutes, formatDurationFromSeconds, formatElapsed, formatLongDate, formatMonthYear, formatNumber, formatPercent, formatRelativeTime, formatShortDate, formatTime, formatTime24h, formatTimeRange, formatWeekday, getActiveLocale, getBackendLang, getDateFnsLocale, getIntlTag, getLanguageName, getLocaleConfig, isSupportedLocale, isValidDateString, isValidTimeString, parseDate, pickTranslation, resolveSupportedLocale, setActiveLocale, syncDateFnsLocale, toCalendarDate, toCurrency, toNumber, toPercentage, useNumber };
158
+ export { type BackendLang, DATE_ERROR, type DateFormatOptions, LOCALE_REGISTRY, type LocaleConfig, LocaleFlag, SUPPORTED_LOCALES, type SupportedLocale, type UiLanguage, formatDate, formatDateTime, formatDateTimeRange, formatDuration, formatDurationFromMinutes, formatDurationFromSeconds, formatElapsed, formatLongDate, formatMonthYear, formatRelativeTime, formatShortDate, formatTime, formatTime24h, formatTimeRange, formatWeekday, getActiveLocale, getBackendLang, getDateFnsLocale, getIntlTag, getLanguageName, getLocaleConfig, isSupportedLocale, isValidDateString, isValidTimeString, parseDate, pickTranslation, resolveSupportedLocale, setActiveLocale, syncDateFnsLocale, toCalendarDate };
package/dist/locale.js CHANGED
@@ -1,2 +1,2 @@
1
- import {j,c as c$1,o,r,y,B,C,D,z,p as p$1,u,w,q as q$1,s as s$1,t,x,v,b,g as g$1,f as f$1,e,i as i$1,d,l,k,m as m$1,h as h$1,a,A,n as n$1}from'./chunk-WG3SEC6O.js';import {jsx}from'react/jsx-runtime';import {useMemo}from'react';var Y='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1155)"><path d="M16.001 32.5c8.836 0 16.001-7.163 16.001-16.001C32.002 7.66 24.837.5 16.002.5 7.165.5 0 7.663 0 16.501c0 8.838 7.163 16.001 16.001 16.001V32.5z" fill="%236DA544"/><path d="M16 6.76l13.218 9.741-13.217 9.74-13.22-9.74 13.217-9.74h.003z" fill="%23FFDA44"/><path d="M16.002 22.064a5.564 5.564 0 005.565-5.565 5.564 5.564 0 00-5.566-5.566 5.564 5.564 0 00-5.565 5.566 5.564 5.564 0 005.566 5.565z" fill="%23F0F0F0"/><path d="M13.217 16.152c-.967 0-1.902.147-2.781.421a5.565 5.565 0 0010.122 3.122 9.38 9.38 0 00-7.34-3.54v-.003zM21.462 17.566a5.564 5.564 0 00-5.463-6.63 5.568 5.568 0 00-5.114 3.367 11.45 11.45 0 0110.575 3.26l.002.003z" fill="%230052B4"/></g><defs><clipPath id="prefix__clip0_1899_1155"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var G='data:image/svg+xml,<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x=".5" y=".5" width="31" height="31" rx="15.5" stroke="%23fff"/><path d="M16 31c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15C7.716 1 1 7.716 1 16c0 8.284 6.716 15 15 15z" fill="%23F6F5F5"/><path d="M31 16c0 8.284-6.716 15-15 15-8.284 0-15-6.716-15-15 0-8.284 15 0 15 0h15z" fill="%23D80027"/><path d="M1 16C1 7.716 7.716 1 16 1v15H1z" fill="%230052B4"/><path d="M9.929 6.217l.971 2.99h3.143l-2.542 1.847.97 2.99-2.542-1.848-2.543 1.848.971-2.99-2.542-1.847h3.143l.971-2.99z" fill="%23F6F5F5"/></svg>';var X='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1166)"><path d="M0 16.501c0 1.956.349 3.833.993 5.566L16 23.457l15.006-1.39c.644-1.733.993-3.608.993-5.566 0-1.958-.35-3.833-.993-5.565L15.999 9.545.993 10.935A15.934 15.934 0 000 16.502z" fill="%23FFDA44"/><path d="M31.007 10.936C28.744 4.842 22.88.5 16 .5 9.121.5 3.256 4.842.993 10.936h30.014zM.993 22.064C3.256 28.158 9.12 32.5 16 32.5c6.88 0 12.745-4.342 15.006-10.436H.993z" fill="%23D80027"/></g><defs><clipPath id="prefix__clip0_1899_1166"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var W='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1170)"><path d="M16.001 32.5c8.838 0 16.001-7.163 16.001-16.001C32.002 7.66 24.84.5 16.002.5 7.162.5 0 7.663 0 16.501c0 8.838 7.163 16.001 16.001 16.001V32.5z" fill="%23F0F0F0"/><path d="M32 16.501c0-6.342-3.693-11.824-9.044-14.413v28.826C28.305 28.325 32 22.844 32 16.5z" fill="%23D80027"/><path d="M0 16.501c0 6.342 3.693 11.824 9.045 14.413V2.088C3.693 4.675 0 10.157 0 16.501zM11.824 16.501a4.176 4.176 0 008.35 0v-1.39h-8.35v1.39z" fill="%236DA544"/><path d="M21.562 13.717h-4.167a1.392 1.392 0 00-2.787 0h-4.167c0 .768.67 1.391 1.437 1.391h-.051c0 .768.625 1.39 1.393 1.39 0 .768.618 1.392 1.388 1.392h2.789c.77 0 1.388-.624 1.388-1.391.77 0 1.393-.623 1.393-1.39h-.05c.77 0 1.437-.624 1.437-1.392h-.003z" fill="%23FF9811"/></g><defs><clipPath id="prefix__clip0_1899_1170"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var $='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1195)"><path d="M16 32.5c8.837 0 16-7.163 16-16S24.837.5 16 .5 0 7.663 0 16.5s7.163 16 16 16z" fill="%23F0F0F0"/><path d="M15.304 16.5H32c0-1.444-.192-2.843-.551-4.174H15.304V16.5zM15.304 8.152h14.348a16.084 16.084 0 00-3.692-4.174H15.304v4.174zM16 32.5c3.766 0 7.227-1.302 9.96-3.478H6.04A15.932 15.932 0 0016 32.5zM2.348 24.848h27.304a15.901 15.901 0 001.797-4.174H.55a15.903 15.903 0 001.797 4.174z" fill="%23D80027"/><path d="M7.412 2.999H8.87l-1.357.985.518 1.594-1.356-.985-1.356.985.447-1.377A16.088 16.088 0 002.663 7.66h.467l-.863.627c-.134.224-.263.452-.387.683l.412 1.27-.769-.56c-.191.405-.366.82-.523 1.242l.454 1.398H3.13l-1.356.986.518 1.594-1.356-.985-.812.59C.042 15.159 0 15.825 0 16.5h16V.5c-3.16 0-6.107.917-8.588 2.499zm.62 11.901l-1.357-.985-1.356.985.518-1.594-1.356-.986h1.676l.518-1.594.518 1.594H8.87l-1.357.986.518 1.594zm-.519-6.255l.518 1.594-1.356-.985-1.356.985.518-1.594-1.356-.985h1.676l.518-1.595.518 1.595H8.87l-1.357.985zm6.258 6.255l-1.357-.985-1.356.985.518-1.594-1.356-.986h1.676l.518-1.594.518 1.594h1.677l-1.357.986.518 1.594zm-.519-6.255l.518 1.594-1.356-.985-1.356.985.518-1.594-1.356-.985h1.676l.518-1.595.518 1.595h1.677l-1.357.985zm0-4.661l.518 1.594-1.356-.985-1.356.985.518-1.594-1.356-.985h1.676l.518-1.595L12.932 3h1.677l-1.357.985z" fill="%230052B4"/></g><defs><clipPath id="prefix__clip0_1899_1195"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var at={en:$,es:X,pt:Y,"es-MX":W,"es-CL":G},J=({locale:t,className:e,alt:o=""})=>jsx("img",{src:at[t],alt:o,className:e,width:32,height:32});var q=new Map,p=(t,e)=>{let o=`${t}:${JSON.stringify(e??{})}`,a=q.get(o);return a||(a=new Intl.NumberFormat(t,e),q.set(o,a)),a},c=(t,e,o)=>p(t,o).format(e),i=(t,e,o,a)=>{try{return p(t,{style:"currency",currency:o,...a}).format(e)}catch{return c(t,e,a)}},g=(t,e,o)=>p(t,{style:"percent",...o}).format(e),n=(t,e$1)=>c(e(b()),t,e$1),m=(t,e$1,o)=>e$1?i(e(b()),t,e$1,o):n(t,o),f=(t,e$1)=>g(e(b()),t/100,{maximumFractionDigits:2,...e$1}),K=()=>{let t=b();return useMemo(()=>({toNumber:(e,o)=>n(e,o),toCurrency:(e,o,a)=>m(e,o,a),toPercentage:(e,o)=>f(e,o)}),[t])};var h=["en","es","pt","es-MX","es-CL"],nt=new Set(h),s=t=>nt.has(t),Q=(t,e="en")=>{if(t&&s(t))return t;let o=t?.split("-")[0];return o&&s(o)?o:e};var vt=h,zt=s,wt=Q,Tt=c$1,Ot=d,Pt=e,At=f$1,Rt=g$1,Et=h$1,It=i$1,Ht=a,kt=b,Vt=c,Bt=i,Ut=g,Yt=n,Gt=m,Xt=f,Wt=K,$t=j,Jt=k,qt=l,Kt=m$1,Qt=n$1,Zt=o,jt=p$1,te=q$1,ee=r,oe=s$1,ae=t,re=u,le=v,ce=w,ne=x,se=y,pe=z,ie=A,ge=B,me=C,fe=D,he=J;
2
- export{$t as DATE_ERROR,Tt as LOCALE_REGISTRY,he as LocaleFlag,vt as SUPPORTED_LOCALES,Bt as formatCurrency,Zt as formatDate,ee as formatDateTime,se as formatDateTimeRange,ge as formatDuration,me as formatDurationFromMinutes,fe as formatDurationFromSeconds,pe as formatElapsed,jt as formatLongDate,re as formatMonthYear,Vt as formatNumber,Ut as formatPercent,ce as formatRelativeTime,te as formatShortDate,oe as formatTime,ae as formatTime24h,ne as formatTimeRange,le as formatWeekday,kt as getActiveLocale,Rt as getBackendLang,At as getDateFnsLocale,Pt as getIntlTag,It as getLanguageName,Ot as getLocaleConfig,zt as isSupportedLocale,qt as isValidDateString,Jt as isValidTimeString,Kt as parseDate,Et as pickTranslation,wt as resolveSupportedLocale,Ht as setActiveLocale,ie as syncDateFnsLocale,Qt as toCalendarDate,Gt as toCurrency,Yt as toNumber,Xt as toPercentage,Wt as useNumber};
1
+ import {j,c,o,r,y,B as B$1,C,D,z,p,u,w,q as q$1,s,t,x,v,b,g,f,e,i,d,l as l$1,k as k$1,m,h,a as a$1,A,n}from'./chunk-WG3SEC6O.js';import {jsx}from'react/jsx-runtime';var H='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1155)"><path d="M16.001 32.5c8.836 0 16.001-7.163 16.001-16.001C32.002 7.66 24.837.5 16.002.5 7.165.5 0 7.663 0 16.501c0 8.838 7.163 16.001 16.001 16.001V32.5z" fill="%236DA544"/><path d="M16 6.76l13.218 9.741-13.217 9.74-13.22-9.74 13.217-9.74h.003z" fill="%23FFDA44"/><path d="M16.002 22.064a5.564 5.564 0 005.565-5.565 5.564 5.564 0 00-5.566-5.566 5.564 5.564 0 00-5.565 5.566 5.564 5.564 0 005.566 5.565z" fill="%23F0F0F0"/><path d="M13.217 16.152c-.967 0-1.902.147-2.781.421a5.565 5.565 0 0010.122 3.122 9.38 9.38 0 00-7.34-3.54v-.003zM21.462 17.566a5.564 5.564 0 00-5.463-6.63 5.568 5.568 0 00-5.114 3.367 11.45 11.45 0 0110.575 3.26l.002.003z" fill="%230052B4"/></g><defs><clipPath id="prefix__clip0_1899_1155"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var k='data:image/svg+xml,<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x=".5" y=".5" width="31" height="31" rx="15.5" stroke="%23fff"/><path d="M16 31c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15C7.716 1 1 7.716 1 16c0 8.284 6.716 15 15 15z" fill="%23F6F5F5"/><path d="M31 16c0 8.284-6.716 15-15 15-8.284 0-15-6.716-15-15 0-8.284 15 0 15 0h15z" fill="%23D80027"/><path d="M1 16C1 7.716 7.716 1 16 1v15H1z" fill="%230052B4"/><path d="M9.929 6.217l.971 2.99h3.143l-2.542 1.847.97 2.99-2.542-1.848-2.543 1.848.971-2.99-2.542-1.847h3.143l.971-2.99z" fill="%23F6F5F5"/></svg>';var V='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1166)"><path d="M0 16.501c0 1.956.349 3.833.993 5.566L16 23.457l15.006-1.39c.644-1.733.993-3.608.993-5.566 0-1.958-.35-3.833-.993-5.565L15.999 9.545.993 10.935A15.934 15.934 0 000 16.502z" fill="%23FFDA44"/><path d="M31.007 10.936C28.744 4.842 22.88.5 16 .5 9.121.5 3.256 4.842.993 10.936h30.014zM.993 22.064C3.256 28.158 9.12 32.5 16 32.5c6.88 0 12.745-4.342 15.006-10.436H.993z" fill="%23D80027"/></g><defs><clipPath id="prefix__clip0_1899_1166"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var B='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1170)"><path d="M16.001 32.5c8.838 0 16.001-7.163 16.001-16.001C32.002 7.66 24.84.5 16.002.5 7.162.5 0 7.663 0 16.501c0 8.838 7.163 16.001 16.001 16.001V32.5z" fill="%23F0F0F0"/><path d="M32 16.501c0-6.342-3.693-11.824-9.044-14.413v28.826C28.305 28.325 32 22.844 32 16.5z" fill="%23D80027"/><path d="M0 16.501c0 6.342 3.693 11.824 9.045 14.413V2.088C3.693 4.675 0 10.157 0 16.501zM11.824 16.501a4.176 4.176 0 008.35 0v-1.39h-8.35v1.39z" fill="%236DA544"/><path d="M21.562 13.717h-4.167a1.392 1.392 0 00-2.787 0h-4.167c0 .768.67 1.391 1.437 1.391h-.051c0 .768.625 1.39 1.393 1.39 0 .768.618 1.392 1.388 1.392h2.789c.77 0 1.388-.624 1.388-1.391.77 0 1.393-.623 1.393-1.39h-.05c.77 0 1.437-.624 1.437-1.392h-.003z" fill="%23FF9811"/></g><defs><clipPath id="prefix__clip0_1899_1170"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var U='data:image/svg+xml,<svg width="32" height="33" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(%23prefix__clip0_1899_1195)"><path d="M16 32.5c8.837 0 16-7.163 16-16S24.837.5 16 .5 0 7.663 0 16.5s7.163 16 16 16z" fill="%23F0F0F0"/><path d="M15.304 16.5H32c0-1.444-.192-2.843-.551-4.174H15.304V16.5zM15.304 8.152h14.348a16.084 16.084 0 00-3.692-4.174H15.304v4.174zM16 32.5c3.766 0 7.227-1.302 9.96-3.478H6.04A15.932 15.932 0 0016 32.5zM2.348 24.848h27.304a15.901 15.901 0 001.797-4.174H.55a15.903 15.903 0 001.797 4.174z" fill="%23D80027"/><path d="M7.412 2.999H8.87l-1.357.985.518 1.594-1.356-.985-1.356.985.447-1.377A16.088 16.088 0 002.663 7.66h.467l-.863.627c-.134.224-.263.452-.387.683l.412 1.27-.769-.56c-.191.405-.366.82-.523 1.242l.454 1.398H3.13l-1.356.986.518 1.594-1.356-.985-.812.59C.042 15.159 0 15.825 0 16.5h16V.5c-3.16 0-6.107.917-8.588 2.499zm.62 11.901l-1.357-.985-1.356.985.518-1.594-1.356-.986h1.676l.518-1.594.518 1.594H8.87l-1.357.986.518 1.594zm-.519-6.255l.518 1.594-1.356-.985-1.356.985.518-1.594-1.356-.985h1.676l.518-1.595.518 1.595H8.87l-1.357.985zm6.258 6.255l-1.357-.985-1.356.985.518-1.594-1.356-.986h1.676l.518-1.594.518 1.594h1.677l-1.357.986.518 1.594zm-.519-6.255l.518 1.594-1.356-.985-1.356.985.518-1.594-1.356-.985h1.676l.518-1.595.518 1.595h1.677l-1.357.985zm0-4.661l.518 1.594-1.356-.985-1.356.985.518-1.594-1.356-.985h1.676l.518-1.595L12.932 3h1.677l-1.357.985z" fill="%230052B4"/></g><defs><clipPath id="prefix__clip0_1899_1195"><path fill="%23fff" transform="translate(0 .5)" d="M0 0h32v32H0z"/></clipPath></defs></svg>';var q={en:U,es:V,pt:H,"es-MX":B,"es-CL":k},I=({locale:e,className:o,alt:t=""})=>jsx("img",{src:q[e],alt:t,className:o,width:32,height:32});var l=["en","es","pt","es-MX","es-CL"],K=new Set(l),a=e=>K.has(e),N=(e,o="en")=>{if(e&&a(e))return e;let t=e?.split("-")[0];return t&&a(t)?t:o};var h1=l,m1=a,L1=N,d1=c,D1=d,x1=e,y1=f,S1=g,_1=h,u1=i,C1=a$1,F1=b,v1=j,M1=k$1,z1=l$1,w1=m,T1=n,A1=o,R1=p,E1=q$1,P1=r,O1=s,H1=t,k1=u,V1=v,B1=w,U1=x,I1=y,N1=z,Y1=A,G1=B$1,X1=C,b1=D,W1=I;
2
+ export{v1 as DATE_ERROR,d1 as LOCALE_REGISTRY,W1 as LocaleFlag,h1 as SUPPORTED_LOCALES,A1 as formatDate,P1 as formatDateTime,I1 as formatDateTimeRange,G1 as formatDuration,X1 as formatDurationFromMinutes,b1 as formatDurationFromSeconds,N1 as formatElapsed,R1 as formatLongDate,k1 as formatMonthYear,B1 as formatRelativeTime,E1 as formatShortDate,O1 as formatTime,H1 as formatTime24h,U1 as formatTimeRange,V1 as formatWeekday,F1 as getActiveLocale,S1 as getBackendLang,y1 as getDateFnsLocale,x1 as getIntlTag,u1 as getLanguageName,D1 as getLocaleConfig,m1 as isSupportedLocale,z1 as isValidDateString,M1 as isValidTimeString,w1 as parseDate,_1 as pickTranslation,L1 as resolveSupportedLocale,C1 as setActiveLocale,Y1 as syncDateFnsLocale,T1 as toCalendarDate};
@@ -1 +1 @@
1
- import {c}from'./chunk-Q2KEE7CU.js';import {a as a$1,d,e as e$1,g,f as f$1}from'./chunk-U5V4RBJ2.js';import {c as c$2}from'./chunk-6R4QD7UB.js';import {a as a$2}from'./chunk-X7KMSQTD.js';import {d as d$1,a as a$3,b as b$1,c as c$1}from'./chunk-K2S6L5P6.js';import'./chunk-7JM2X4UD.js';import'./chunk-ZCMXCZC2.js';import'./chunk-YFDUDY6Y.js';import'./chunk-PI7DECIN.js';import'./chunk-JW7HS6NX.js';import'./chunk-XYBXEU3T.js';import'./chunk-NGC5DGW6.js';import'./chunk-TW4CJXQY.js';import'./chunk-VIMWKUML.js';import'./chunk-T5NU5E4O.js';import'./chunk-3RNV3YTB.js';import {b,a,e}from'./chunk-OGXELKVW.js';import'./chunk-QMPBFFFC.js';import'./chunk-ICF6RQIW.js';import'./chunk-HZYZAFW3.js';import {e as e$2}from'./chunk-P7NW2XNB.js';import'./chunk-C7TLKKPT.js';import'./chunk-CQI4KDR4.js';import'./chunk-P6B33GL6.js';import {a as a$4}from'./chunk-OBZIYJO7.js';import {RadioGroupItem,RadioGroupItemControl,RadioGroupItemHiddenInput}from'@ark-ui/react/radio-group';import {LanguagesIcon,PaletteIcon,LayoutDashboardIcon,CheckIcon}from'lucide-react';import {createContext,useContext,useState,useCallback,useMemo,useLayoutEffect,useEffect}from'react';import {LocaleProvider}from'@ark-ui/react/locale';import {setDefaultOptions}from'date-fns';import {jsx,jsxs}from'react/jsx-runtime';var f=["en","es","pt"],p=["AG","AR","BS","BB","BZ","BO","BR","CA","CL","CO","CR","CU","DM","DO","EC","SV","GD","GT","GY","HT","HN","JM","MX","NI","PA","PY","PE","KN","LC","VC","SR","TT","UY","US","VE"],J=["blue","green","indigo","purple","red","black","sodtrack"],v=["horizontal","vertical"],pe=new Set(f),ve=new Set(p),ye=new Set(J),Pe=new Set(v),$=e=>typeof e=="string"&&pe.has(e),K=e=>typeof e=="string"&&ve.has(e),q=e=>typeof e=="string"&&ye.has(e),X=e=>typeof e=="string"&&Pe.has(e),y=e=>{if(typeof e!="object"||e===null)return false;let r=e;return $(r.language)&&K(r.formatRegion)&&q(r.themeId)&&(r.navigationLayout===void 0||X(r.navigationLayout))};var he={en:{title:"Preferences",regionalSettings:"Language and region",language:"Language",formatRegion:"Country",appearance:"Appearance",navigationLayout:"Navigation",timeZone:"Time zone",formats:"Formats",themes:{blue:"Blue",green:"Green",indigo:"Indigo",purple:"Purple",red:"Red",black:"Black",sodtrack:"Sodtrack"},cancel:"Cancel",save:"Save",saveError:"Preferences could not be saved. Please try again."},es:{title:"Preferencias",regionalSettings:"Idioma y regi\xF3n",language:"Idioma",formatRegion:"Pa\xEDs",appearance:"Apariencia",navigationLayout:"Navegaci\xF3n",timeZone:"Huso horario",formats:"Formatos",themes:{blue:"Azul",green:"Verde",indigo:"\xCDndigo",purple:"Morado",red:"Rojo",black:"Negro",sodtrack:"Sodtrack"},cancel:"Cancelar",save:"Guardar",saveError:"No se pudieron guardar las preferencias. Int\xE9ntalo de nuevo."},pt:{title:"Prefer\xEAncias",regionalSettings:"Idioma e regi\xE3o",language:"Idioma",formatRegion:"Pa\xEDs",appearance:"Apar\xEAncia",navigationLayout:"Navega\xE7\xE3o",timeZone:"Fuso hor\xE1rio",formats:"Formatos",themes:{blue:"Azul",green:"Verde",indigo:"\xCDndigo",purple:"Roxo",red:"Vermelho",black:"Preto",sodtrack:"Sodtrack"},cancel:"Cancelar",save:"Salvar",saveError:"N\xE3o foi poss\xEDvel salvar as prefer\xEAncias. Tente novamente."}},Q=e=>he[e];var ae="sodtrack.ui-preferences.v1",re=createContext(void 0),A=(e,r)=>r===(e.navigationLayout!==void 0),Se=(e,r)=>{if(!y(e)||!A(e,r))throw new Error("PreferencesProvider received invalid default preferences.");if(typeof window>"u")return e;try{let t=window.localStorage.getItem(ae);if(!t)return e;let c=JSON.parse(t);return y(c)&&A(c,r)?c:e}catch{return e}},T=()=>{let e=useContext(re);if(!e)throw new Error("usePreferences must be used within a PreferencesProvider.");return e},Ee=({capabilities:e,defaultValue:r,children:t})=>{let c=e.navigationLayout,[i,n]=useState(()=>Se(r,c)),o=useCallback(d=>{if(!y(d)||!A(d,c))throw new Error("Cannot save invalid UI preferences.");window.localStorage.setItem(ae,JSON.stringify(d)),n(d);},[c]),u=useMemo(()=>({capabilities:{navigationLayout:c},preferences:i,savePreferences:o}),[c,i,o]);return useLayoutEffect(()=>{document.documentElement.dataset.theme=i.themeId;},[i.themeId]),b({language:i.language,formatRegion:i.formatRegion}),setDefaultOptions({locale:a(i.language)}),jsx(re.Provider,{value:u,children:jsx(LocaleProvider,{locale:`${i.language}-${i.formatRegion}`,children:t})})};var oe=["sodtrack","black","red","green","blue","indigo","purple"],Ge=(e,r)=>e.language===r.language&&e.formatRegion===r.formatRegion&&e.themeId===r.themeId&&e.navigationLayout===r.navigationLayout,w=(e,r,t)=>{if(!(r!==void 0&&t.includes(r)))throw new Error(`PreferencesDrawer received an unsupported ${e} value.`)},ne=(e,r)=>e.charAt(0).toLocaleUpperCase(r)+e.slice(1),Oe=({label:e,value:r,options:t,disabled:c,onChange:i})=>jsx(c$2,{value:r,disabled:c,onValueChange:n=>{let o=t.find(u=>u.value===n);o&&i(o.value);},"aria-label":e,innerClassName:"gap-4",children:t.map(n=>jsxs(RadioGroupItem,{value:n.value,"aria-label":n.label,title:n.label,className:"group/item rounded-full",children:[jsx(RadioGroupItemControl,{"data-theme":n.value,className:a$4("bg-primary-500 relative flex size-8 cursor-pointer items-center justify-center rounded-full border-2 border-neutral-50 ring-neutral-500 outline-none data-disabled:cursor-not-allowed data-disabled:opacity-60","data-[state=checked]:ring-primary-500 data-[state=checked]:ring-2"),children:jsx(CheckIcon,{className:"size-3.5 text-neutral-50 opacity-0 group-data-[state=checked]/item:opacity-100",strokeWidth:3,"aria-hidden":"true"})}),jsx(RadioGroupItemHiddenInput,{})]},n.value))}),_e=({layout:e})=>e==="vertical"?jsxs("div",{className:"flex h-full w-full flex-col",children:[jsx("div",{className:"flex shrink-0 gap-0.5 bg-neutral-100 px-1 py-0.5",children:Array.from({length:3},(r,t)=>t).map(r=>jsx("div",{className:"size-1 rounded-full bg-neutral-300"},r))}),jsxs("div",{className:"flex min-h-0 flex-1 items-stretch",children:[jsxs("div",{className:"bg-primary-300 w-1/5 self-stretch p-1",children:[jsx("div",{className:"bg-primary-100 h-1.5 w-full rounded-[0.0625rem]"}),jsx("div",{className:"bg-transparent-neutral-50-60 my-1 h-px w-full"}),jsx("div",{className:"flex flex-col gap-0.75",children:Array.from({length:7},(r,t)=>t).map(r=>jsx("div",{className:"bg-primary-400 h-1 w-full rounded-[0.0625rem]"},r))})]}),jsxs("div",{className:"flex w-4/5 flex-col gap-1 p-1",children:[jsxs("div",{className:"flex items-center",children:[jsx("div",{className:"h-3 w-1/2 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"mr-0.75 ml-auto h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"})]}),jsx("div",{className:"h-2.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-full rounded-[0.0625rem] bg-neutral-200"})]})]})]}):jsxs("div",{className:"flex h-full w-full flex-col",children:[jsx("div",{className:"flex shrink-0 gap-0.5 bg-neutral-100 px-1 py-0.5",children:Array.from({length:3},(r,t)=>t).map(r=>jsx("div",{className:"size-1 rounded-full bg-neutral-300"},r))}),jsxs("div",{className:"bg-primary-300 px-1.5 py-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("div",{className:"bg-primary-100 h-1.5 w-14/100 rounded-[0.0625rem]"}),jsx("div",{className:"bg-primary-100 size-1.5 rounded-full"})]}),jsx("div",{className:"bg-transparent-neutral-50-60 my-1 h-px w-full"}),jsxs("div",{className:"flex justify-between",children:[jsx("div",{className:"flex w-full gap-1",children:Array.from({length:7},(r,t)=>t).map(r=>jsx("div",{className:"bg-primary-400 h-1 w-9/100 rounded-[0.0625rem]"},r))}),jsx("div",{className:"flex gap-1",children:Array.from({length:2},(r,t)=>t).map(r=>jsx("div",{className:"bg-primary-400 size-1 rounded-[0.0625rem]"},r))})]})]}),jsxs("div",{className:"flex h-full flex-col gap-1 p-1",children:[jsxs("div",{className:"flex items-center",children:[jsx("div",{className:"h-3 w-1/2 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"mr-0.75 ml-auto h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"})]}),jsx("div",{className:"h-2.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-full rounded-[0.0625rem] bg-neutral-200"})]})]}),Be=({value:e,options:r,disabled:t,onChange:c})=>jsx(c$2,{value:e,disabled:t,orientation:"horizontal",onValueChange:i=>{let n=r.find(o=>o===i);n&&c(n);},innerClassName:"grid w-full grid-cols-2 gap-3",children:r.map(i=>jsxs(RadioGroupItem,{value:i,className:"group/item min-w-0 rounded-lg outline-none",children:[jsx(RadioGroupItemControl,{className:a$4("relative h-27 w-full cursor-pointer overflow-hidden rounded-md outline-none","after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:border after:border-neutral-400 after:content-['']","data-[state=checked]:after:border-primary-700 data-[state=checked]:after:border-3","data-disabled:cursor-not-allowed data-disabled:opacity-60"),children:jsx(_e,{layout:i})}),jsx(RadioGroupItemHiddenInput,{})]},i))}),Fe=({open:e$3,onDismiss:r})=>{let{preferences:t,savePreferences:c$2}=T(),i=t.language,n=Q(i),[o,u]=useState(t),[d$2,D]=useState(false),[ce,m]=useState(false),G=!Ge(o,t),O=t.navigationLayout!==void 0,de=useMemo(()=>{let s=new Intl.DisplayNames(i,{type:"language"});return f.map(g=>{let R=s.of(g)??g;return {value:g,label:ne(R,i)}})},[i]),_=useMemo(()=>{let s=new Intl.DisplayNames(i,{type:"region"});return p.map(g=>{let R=s.of(g)??g;return {value:g,label:ne(R,i)}})},[i]),ue=oe.map(s=>({value:s,label:n.themes[s]}));w("language",o.language,f),w("formatRegion",o.formatRegion,p),w("themeId",o.themeId,oe),O&&w("navigationLayout",o.navigationLayout,v);let ge=_.find(s=>s.value===o.formatRegion)?.label??o.formatRegion,I=useMemo(()=>e({language:o.language,formatRegion:o.formatRegion}),[o.formatRegion,o.language]);useEffect(()=>{e$3||(u(t),m(false));},[e$3,t]);let P=s=>{u(s),m(false);},L=useCallback(()=>{d$2||(u(t),m(false),r());},[d$2,r,t]),me=useCallback(s=>{s||L();},[L]),fe=async()=>{if(!(!G||d$2)){D(true),m(false);try{await c$2(o),r();}catch{m(true);}finally{D(false);}}};return jsx(a$1,{open:e$3,onOpenChange:me,children:jsxs(d,{size:"sm",className:"w-full max-w-[calc(100vw-1rem)] sm:max-w-117.5","aria-label":n.title,children:[jsx(e$1,{title:n.title}),jsxs(g,{className:"flex flex-col gap-3",children:[ce&&jsx(a$2,{title:n.saveError,variant:"error",hasCloseButton:false}),jsxs(d$1,{children:[jsx(a$3,{title:n.regionalSettings,leading:{type:"icon",Icon:LanguagesIcon}}),jsxs(b$1,{className:"gap-4.5",children:[jsx(c,{label:n.language,options:[...de],value:o.language,clearable:false,disabled:d$2,onSelect:s=>{s&&P({...o,language:s.value});}}),jsx(c,{label:n.formatRegion,options:[..._],value:o.formatRegion,clearable:false,disabled:d$2,onSelect:s=>{s&&P({...o,formatRegion:s.value});}})]}),jsx(c$1,{children:jsxs("p",{className:"text-xs leading-[133%]",children:[n.timeZone," (",I.utcOffset,") |"," ",n.formats," ",ge,":"," ",I.datePattern,","," ",I.timePattern]})})]}),jsxs(d$1,{children:[jsx(a$3,{title:n.appearance,leading:{type:"icon",Icon:PaletteIcon}}),jsx(b$1,{children:jsx(Oe,{label:n.appearance,value:o.themeId,options:ue,disabled:d$2,onChange:s=>P({...o,themeId:s})})})]}),O&&o.navigationLayout&&jsxs(d$1,{children:[jsx(a$3,{title:n.navigationLayout,leading:{type:"icon",Icon:LayoutDashboardIcon}}),jsx(b$1,{children:jsx(Be,{value:o.navigationLayout,options:v,disabled:d$2,onChange:s=>P({...o,navigationLayout:s})})})]})]}),jsxs(f$1,{children:[jsx(e$2,{type:"button",variant:"secondary",size:"lg",disabled:d$2,onClick:L,children:n.cancel}),jsx(e$2,{size:"lg",loading:d$2,disabled:!G||d$2,onClick:fe,children:n.save})]})]})})};export{p as FORMAT_REGIONS,v as NAVIGATION_LAYOUTS,Fe as PreferencesDrawer,Ee as PreferencesProvider,J as THEME_IDS,f as UI_LANGUAGES,K as isFormatRegion,X as isNavigationLayout,q as isThemeId,$ as isUiLanguage,y as isUiPreferences,T as usePreferences};
1
+ import {c}from'./chunk-Q2KEE7CU.js';import {a,d as d$1,e as e$1,g,f as f$1}from'./chunk-U5V4RBJ2.js';import {c as c$2}from'./chunk-6R4QD7UB.js';import {a as a$1}from'./chunk-X7KMSQTD.js';import {d as d$2,a as a$2,b,c as c$1}from'./chunk-K2S6L5P6.js';import'./chunk-7JM2X4UD.js';import'./chunk-ZCMXCZC2.js';import'./chunk-YFDUDY6Y.js';import'./chunk-PI7DECIN.js';import'./chunk-JW7HS6NX.js';import'./chunk-XYBXEU3T.js';import'./chunk-NGC5DGW6.js';import'./chunk-TW4CJXQY.js';import'./chunk-VIMWKUML.js';import'./chunk-T5NU5E4O.js';import'./chunk-3RNV3YTB.js';import {n,e,f,d,h}from'./chunk-W4P4M4HC.js';export{f as FORMAT_REGIONS,h as NAVIGATION_LAYOUTS,o as PreferencesProvider,g as THEME_IDS,e as UI_LANGUAGES,j as isFormatRegion,l as isNavigationLayout,k as isThemeId,i as isUiLanguage,m as isUiPreferences,n as usePreferences}from'./chunk-W4P4M4HC.js';import'./chunk-QMPBFFFC.js';import'./chunk-ICF6RQIW.js';import'./chunk-HZYZAFW3.js';import {e as e$2}from'./chunk-P7NW2XNB.js';import'./chunk-C7TLKKPT.js';import'./chunk-CQI4KDR4.js';import'./chunk-P6B33GL6.js';import {a as a$3}from'./chunk-OBZIYJO7.js';import {RadioGroupItem,RadioGroupItemControl,RadioGroupItemHiddenInput}from'@ark-ui/react/radio-group';import {LanguagesIcon,PaletteIcon,LayoutDashboardIcon,CheckIcon}from'lucide-react';import {useState,useMemo,useEffect,useCallback}from'react';import {jsx,jsxs}from'react/jsx-runtime';var ce={en:{title:"Preferences",regionalSettings:"Language and region",language:"Language",formatRegion:"Country",appearance:"Appearance",navigationLayout:"Navigation",timeZone:"Time zone",formats:"Formats",themes:{blue:"Blue",green:"Green",indigo:"Indigo",purple:"Purple",red:"Red",black:"Black",sodtrack:"Sodtrack"},cancel:"Cancel",save:"Save",saveError:"Preferences could not be saved. Please try again."},es:{title:"Preferencias",regionalSettings:"Idioma y regi\xF3n",language:"Idioma",formatRegion:"Pa\xEDs",appearance:"Apariencia",navigationLayout:"Navegaci\xF3n",timeZone:"Huso horario",formats:"Formatos",themes:{blue:"Azul",green:"Verde",indigo:"\xCDndigo",purple:"Morado",red:"Rojo",black:"Negro",sodtrack:"Sodtrack"},cancel:"Cancelar",save:"Guardar",saveError:"No se pudieron guardar las preferencias. Int\xE9ntalo de nuevo."},pt:{title:"Prefer\xEAncias",regionalSettings:"Idioma e regi\xE3o",language:"Idioma",formatRegion:"Pa\xEDs",appearance:"Apar\xEAncia",navigationLayout:"Navega\xE7\xE3o",timeZone:"Fuso hor\xE1rio",formats:"Formatos",themes:{blue:"Azul",green:"Verde",indigo:"\xCDndigo",purple:"Roxo",red:"Vermelho",black:"Preto",sodtrack:"Sodtrack"},cancel:"Cancelar",save:"Salvar",saveError:"N\xE3o foi poss\xEDvel salvar as prefer\xEAncias. Tente novamente."}},Z=i=>ce[i];var Y=["sodtrack","black","red","green","blue","indigo","purple"],ve=(i,a)=>i.language===a.language&&i.formatRegion===a.formatRegion&&i.themeId===a.themeId&&i.navigationLayout===a.navigationLayout,P=(i,a,t)=>{if(!(a!==void 0&&t.includes(a)))throw new Error(`PreferencesDrawer received an unsupported ${i} value.`)},W=(i,a)=>i.charAt(0).toLocaleUpperCase(a)+i.slice(1),ye=({label:i,value:a,options:t,disabled:m,onChange:l})=>jsx(c$2,{value:a,disabled:m,onValueChange:o=>{let r=t.find(u=>u.value===o);r&&l(r.value);},"aria-label":i,innerClassName:"gap-4",children:t.map(o=>jsxs(RadioGroupItem,{value:o.value,"aria-label":o.label,title:o.label,className:"group/item rounded-full",children:[jsx(RadioGroupItemControl,{"data-theme":o.value,className:a$3("bg-primary-500 relative flex size-8 cursor-pointer items-center justify-center rounded-full border-2 border-neutral-50 ring-neutral-500 outline-none data-disabled:cursor-not-allowed data-disabled:opacity-60","data-[state=checked]:ring-primary-500 data-[state=checked]:ring-2"),children:jsx(CheckIcon,{className:"size-3.5 text-neutral-50 opacity-0 group-data-[state=checked]/item:opacity-100",strokeWidth:3,"aria-hidden":"true"})}),jsx(RadioGroupItemHiddenInput,{})]},o.value))}),he=({layout:i})=>i==="vertical"?jsxs("div",{className:"flex h-full w-full flex-col",children:[jsx("div",{className:"flex shrink-0 gap-0.5 bg-neutral-100 px-1 py-0.5",children:Array.from({length:3},(a,t)=>t).map(a=>jsx("div",{className:"size-1 rounded-full bg-neutral-300"},a))}),jsxs("div",{className:"flex min-h-0 flex-1 items-stretch",children:[jsxs("div",{className:"bg-primary-300 w-1/5 self-stretch p-1",children:[jsx("div",{className:"bg-primary-100 h-1.5 w-full rounded-[0.0625rem]"}),jsx("div",{className:"bg-transparent-neutral-50-60 my-1 h-px w-full"}),jsx("div",{className:"flex flex-col gap-0.75",children:Array.from({length:7},(a,t)=>t).map(a=>jsx("div",{className:"bg-primary-400 h-1 w-full rounded-[0.0625rem]"},a))})]}),jsxs("div",{className:"flex w-4/5 flex-col gap-1 p-1",children:[jsxs("div",{className:"flex items-center",children:[jsx("div",{className:"h-3 w-1/2 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"mr-0.75 ml-auto h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"})]}),jsx("div",{className:"h-2.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-full rounded-[0.0625rem] bg-neutral-200"})]})]})]}):jsxs("div",{className:"flex h-full w-full flex-col",children:[jsx("div",{className:"flex shrink-0 gap-0.5 bg-neutral-100 px-1 py-0.5",children:Array.from({length:3},(a,t)=>t).map(a=>jsx("div",{className:"size-1 rounded-full bg-neutral-300"},a))}),jsxs("div",{className:"bg-primary-300 px-1.5 py-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("div",{className:"bg-primary-100 h-1.5 w-14/100 rounded-[0.0625rem]"}),jsx("div",{className:"bg-primary-100 size-1.5 rounded-full"})]}),jsx("div",{className:"bg-transparent-neutral-50-60 my-1 h-px w-full"}),jsxs("div",{className:"flex justify-between",children:[jsx("div",{className:"flex w-full gap-1",children:Array.from({length:7},(a,t)=>t).map(a=>jsx("div",{className:"bg-primary-400 h-1 w-9/100 rounded-[0.0625rem]"},a))}),jsx("div",{className:"flex gap-1",children:Array.from({length:2},(a,t)=>t).map(a=>jsx("div",{className:"bg-primary-400 size-1 rounded-[0.0625rem]"},a))})]})]}),jsxs("div",{className:"flex h-full flex-col gap-1 p-1",children:[jsxs("div",{className:"flex items-center",children:[jsx("div",{className:"h-3 w-1/2 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"mr-0.75 ml-auto h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-2.25 w-4.5 rounded-[0.0625rem] bg-neutral-200"})]}),jsx("div",{className:"h-2.5 rounded-[0.0625rem] bg-neutral-200"}),jsx("div",{className:"h-full rounded-[0.0625rem] bg-neutral-200"})]})]}),be=({value:i,options:a,disabled:t,onChange:m})=>jsx(c$2,{value:i,disabled:t,orientation:"horizontal",onValueChange:l=>{let o=a.find(r=>r===l);o&&m(o);},innerClassName:"grid w-full grid-cols-2 gap-3",children:a.map(l=>jsxs(RadioGroupItem,{value:l,className:"group/item min-w-0 rounded-lg outline-none",children:[jsx(RadioGroupItemControl,{className:a$3("relative h-27 w-full cursor-pointer overflow-hidden rounded-md outline-none","after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:border after:border-neutral-400 after:content-['']","data-[state=checked]:after:border-primary-700 data-[state=checked]:after:border-3","data-disabled:cursor-not-allowed data-disabled:opacity-60"),children:jsx(he,{layout:l})}),jsx(RadioGroupItemHiddenInput,{})]},l))}),Ne=({open:i,onDismiss:a$3})=>{let{preferences:t,savePreferences:m}=n(),l=t.language,o=Z(l),[r,u]=useState(t),[d$3,T]=useState(false),[K,g$1]=useState(false),E=!ve(r,t),B=t.navigationLayout!==void 0,Q=useMemo(()=>{let n=new Intl.DisplayNames(l,{type:"language"});return e.map(c=>{let R=n.of(c)??c;return {value:c,label:W(R,l)}})},[l]),G=useMemo(()=>{let n=new Intl.DisplayNames(l,{type:"region"});return f.map(c=>{let R=n.of(c)??c;return {value:c,label:W(R,l)}})},[l]),X=Y.map(n=>({value:n,label:o.themes[n]}));P("language",r.language,e),P("formatRegion",r.formatRegion,f),P("themeId",r.themeId,Y),B&&P("navigationLayout",r.navigationLayout,h);let ee=G.find(n=>n.value===r.formatRegion)?.label??r.formatRegion,w=useMemo(()=>d({language:r.language,formatRegion:r.formatRegion}),[r.formatRegion,r.language]);useEffect(()=>{i||(u(t),g$1(false));},[i,t]);let p=n=>{u(n),g$1(false);},I=useCallback(()=>{d$3||(u(t),g$1(false),a$3());},[d$3,a$3,t]),ae=useCallback(n=>{n||I();},[I]),re=async()=>{if(!(!E||d$3)){T(true),g$1(false);try{await m(r),a$3();}catch{g$1(true);}finally{T(false);}}};return jsx(a,{open:i,onOpenChange:ae,children:jsxs(d$1,{size:"sm",className:"w-full max-w-[calc(100vw-1rem)] sm:max-w-117.5","aria-label":o.title,children:[jsx(e$1,{title:o.title}),jsxs(g,{className:"flex flex-col gap-3",children:[K&&jsx(a$1,{title:o.saveError,variant:"error",hasCloseButton:false}),jsxs(d$2,{children:[jsx(a$2,{title:o.regionalSettings,leading:{type:"icon",Icon:LanguagesIcon}}),jsxs(b,{className:"gap-4.5",children:[jsx(c,{label:o.language,options:[...Q],value:r.language,clearable:false,disabled:d$3,onSelect:n=>{n&&p({...r,language:n.value});}}),jsx(c,{label:o.formatRegion,options:[...G],value:r.formatRegion,clearable:false,disabled:d$3,onSelect:n=>{n&&p({...r,formatRegion:n.value});}})]}),jsx(c$1,{children:jsxs("p",{className:"text-xs leading-[133%]",children:[o.timeZone," (",w.utcOffset,") |"," ",o.formats," ",ee,":"," ",w.datePattern,","," ",w.timePattern]})})]}),jsxs(d$2,{children:[jsx(a$2,{title:o.appearance,leading:{type:"icon",Icon:PaletteIcon}}),jsx(b,{children:jsx(ye,{label:o.appearance,value:r.themeId,options:X,disabled:d$3,onChange:n=>p({...r,themeId:n})})})]}),B&&r.navigationLayout&&jsxs(d$2,{children:[jsx(a$2,{title:o.navigationLayout,leading:{type:"icon",Icon:LayoutDashboardIcon}}),jsx(b,{children:jsx(be,{value:r.navigationLayout,options:h,disabled:d$3,onChange:n=>p({...r,navigationLayout:n})})})]})]}),jsxs(f$1,{children:[jsx(e$2,{type:"button",variant:"secondary",size:"lg",disabled:d$3,onClick:I,children:o.cancel}),jsx(e$2,{size:"lg",loading:d$3,disabled:!E||d$3,onClick:re,children:o.save})]})]})})};export{Ne as PreferencesDrawer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sodtrack-web-ui",
3
- "version": "0.113.0",
3
+ "version": "0.114.0",
4
4
  "type": "module",
5
5
  "description": "UI components for Sodtrack Web",
6
6
  "exports": {
@@ -1 +0,0 @@
1
- import {ptBR,es,enUS}from'date-fns/locale';var u={en:enUS,es:es,pt:ptBR},d=e=>u[e];var m=new Date(2006,10,22,13,45),R=(e,a,t)=>e.formatToParts(a).find(o=>o.type===t)?.value,s=(e,a)=>e.map(t=>a.has(t.type)?t.type==="year"?"0".repeat(t.value.length):"00":t.value).join(""),D=({language:e,formatRegion:a,timeZone:t=Intl.DateTimeFormat().resolvedOptions().timeZone,date:o=new Date})=>{let r=`${e}-${a}`,g=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}),l=new Intl.DateTimeFormat(r,{timeZone:t,dateStyle:"short"}),c=new Intl.DateTimeFormat(r,{timeZone:t,timeStyle:"short"}),i=R(g,o,"timeZoneName")??"GMT";return {timeZone:t,utcOffset:i==="GMT"?"GMT+00:00":i,datePattern:s(l.formatToParts(m),new Set(["day","month","year"])),timePattern:s(c.formatToParts(m),new Set(["hour","minute","second"]))}};var n={language:"en",formatRegion:"US"},L=e=>{n=e;},v=()=>n,w=()=>{let{language:e,formatRegion:a}=n;return `${e}-${a}`};export{d as a,L as b,v as c,w as d,D as e};