@flamingo-stack/openframe-frontend-core 0.0.695 → 0.0.696
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/{chunk-DT6DOSXV.cjs → chunk-2FK7BZIM.cjs} +15 -15
- package/dist/{chunk-DT6DOSXV.cjs.map → chunk-2FK7BZIM.cjs.map} +1 -1
- package/dist/{chunk-2NLZ4CB4.js → chunk-3S56I5MX.js} +2 -2
- package/dist/{chunk-E4QJXPJP.cjs → chunk-3V7O7J4S.cjs} +28 -28
- package/dist/{chunk-E4QJXPJP.cjs.map → chunk-3V7O7J4S.cjs.map} +1 -1
- package/dist/{chunk-BU77ENDT.cjs → chunk-5DBWXJBG.cjs} +934 -860
- package/dist/chunk-5DBWXJBG.cjs.map +1 -0
- package/dist/{chunk-RWAHGA2H.cjs → chunk-75CG72QX.cjs} +33 -33
- package/dist/{chunk-RWAHGA2H.cjs.map → chunk-75CG72QX.cjs.map} +1 -1
- package/dist/{chunk-H74TCWVN.js → chunk-77XUG4Z4.js} +7 -7
- package/dist/{chunk-ETFVFDJG.cjs → chunk-7MM6EDNA.cjs} +19 -19
- package/dist/{chunk-ETFVFDJG.cjs.map → chunk-7MM6EDNA.cjs.map} +1 -1
- package/dist/{chunk-IE2H2P4K.cjs → chunk-CVMWOUAX.cjs} +30 -30
- package/dist/{chunk-IE2H2P4K.cjs.map → chunk-CVMWOUAX.cjs.map} +1 -1
- package/dist/{chunk-3DOGI3XP.cjs → chunk-EWQZ4BXD.cjs} +7 -7
- package/dist/{chunk-3DOGI3XP.cjs.map → chunk-EWQZ4BXD.cjs.map} +1 -1
- package/dist/{chunk-DHQXA6FM.cjs → chunk-FZFEIXGB.cjs} +81 -81
- package/dist/{chunk-DHQXA6FM.cjs.map → chunk-FZFEIXGB.cjs.map} +1 -1
- package/dist/{chunk-TGIBJHM6.js → chunk-H6SSHFMD.js} +4 -4
- package/dist/{chunk-CI7HVQAK.js → chunk-J4VGVLQI.js} +3 -3
- package/dist/{chunk-7LYRB7DE.js → chunk-JBMFCHNT.js} +3160 -3086
- package/dist/chunk-JBMFCHNT.js.map +1 -0
- package/dist/{chunk-HKM3DTSS.cjs → chunk-KLDCI3KF.cjs} +3 -3
- package/dist/{chunk-HKM3DTSS.cjs.map → chunk-KLDCI3KF.cjs.map} +1 -1
- package/dist/{chunk-H66LCO6R.cjs → chunk-LEGNIETR.cjs} +5 -5
- package/dist/{chunk-H66LCO6R.cjs.map → chunk-LEGNIETR.cjs.map} +1 -1
- package/dist/{chunk-43YWCHYX.js → chunk-LF4S37VU.js} +5 -5
- package/dist/{chunk-SSBK7TBW.js → chunk-LNOXNCEC.js} +4 -4
- package/dist/{chunk-WGKTGAP3.js → chunk-LZXZ3C6M.js} +3 -3
- package/dist/{chunk-LAGFAZ2H.cjs → chunk-MFU3ALKM.cjs} +192 -192
- package/dist/{chunk-LAGFAZ2H.cjs.map → chunk-MFU3ALKM.cjs.map} +1 -1
- package/dist/{chunk-WQ4BZDLO.cjs → chunk-N4G3C4B4.cjs} +12 -12
- package/dist/{chunk-WQ4BZDLO.cjs.map → chunk-N4G3C4B4.cjs.map} +1 -1
- package/dist/{chunk-N22KLGTR.cjs → chunk-NE4H4JJG.cjs} +35 -35
- package/dist/{chunk-N22KLGTR.cjs.map → chunk-NE4H4JJG.cjs.map} +1 -1
- package/dist/{chunk-ZOVS6HJW.js → chunk-OB3ZJ7GQ.js} +2 -2
- package/dist/{chunk-VDROT42I.js → chunk-PYNHPMDB.js} +3 -3
- package/dist/{chunk-ZF2KSQER.js → chunk-QD4BVKAU.js} +4 -4
- package/dist/{chunk-JUO6CFGZ.js → chunk-QYFXRVH3.js} +6 -6
- package/dist/{chunk-UPLNZA6P.cjs → chunk-RIDRAKQ5.cjs} +11 -11
- package/dist/{chunk-UPLNZA6P.cjs.map → chunk-RIDRAKQ5.cjs.map} +1 -1
- package/dist/{chunk-4XR3D6BN.js → chunk-SG53SIJX.js} +6 -6
- package/dist/{chunk-DELTA7VU.cjs → chunk-T33ICOHD.cjs} +23 -23
- package/dist/{chunk-DELTA7VU.cjs.map → chunk-T33ICOHD.cjs.map} +1 -1
- package/dist/{chunk-IPKFWZDD.cjs → chunk-VCR3TW2H.cjs} +16 -5
- package/dist/chunk-VCR3TW2H.cjs.map +1 -0
- package/dist/{chunk-IHIEAC2G.js → chunk-VE7HLTVQ.js} +2 -2
- package/dist/{chunk-HDBKLVB6.cjs → chunk-WADR7VIA.cjs} +62 -62
- package/dist/{chunk-HDBKLVB6.cjs.map → chunk-WADR7VIA.cjs.map} +1 -1
- package/dist/{chunk-2ACUTFHC.js → chunk-WVDBRL2S.js} +5 -5
- package/dist/{chunk-OQBJQJ6E.cjs → chunk-XRW5VZKH.cjs} +6 -6
- package/dist/{chunk-OQBJQJ6E.cjs.map → chunk-XRW5VZKH.cjs.map} +1 -1
- package/dist/{chunk-2WTBDVR3.js → chunk-Y2MDXJB4.js} +12 -1
- package/dist/chunk-Y2MDXJB4.js.map +1 -0
- package/dist/{chunk-SFIVEDZA.js → chunk-YCVDJX7Z.js} +3 -3
- package/dist/{chunk-YHE4PSYQ.js → chunk-Z7A7FUWY.js} +3 -3
- package/dist/components/case-studies/index.cjs +17 -17
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/index.cjs +3 -3
- package/dist/components/chat/index.js +2 -2
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/docs/index.js +7 -7
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +5 -5
- package/dist/components/faq/index.js +4 -4
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +91 -91
- package/dist/components/help-center-pages/index.js +15 -15
- package/dist/components/index.cjs +64 -56
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +23 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/back-button.d.ts +13 -1
- package/dist/components/layout/back-button.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/context-panel.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +54 -83
- package/dist/components/meeting-scheduler/index.cjs.map +1 -1
- package/dist/components/meeting-scheduler/index.js +18 -47
- package/dist/components/meeting-scheduler/index.js.map +1 -1
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/navigation/index.js +6 -6
- package/dist/components/onboarding-guides/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.js +6 -6
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/index.cjs +12 -4
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +11 -3
- package/dist/components/ui/timezone-select.d.ts +25 -0
- package/dist/components/ui/timezone-select.d.ts.map +1 -0
- package/dist/index.cjs +19 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/image-proxy.d.ts +7 -0
- package/dist/utils/image-proxy.d.ts.map +1 -1
- package/dist/utils/index.cjs +11 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +11 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/layout/back-button.tsx +55 -14
- package/src/components/meeting-scheduler/context-panel.tsx +3 -36
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/timezone-select.test.tsx +48 -0
- package/src/components/ui/timezone-select.tsx +75 -0
- package/src/utils/image-proxy.ts +17 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/skips-image-optimizer.test.ts +14 -0
- package/dist/chunk-2WTBDVR3.js.map +0 -1
- package/dist/chunk-7LYRB7DE.js.map +0 -1
- package/dist/chunk-BU77ENDT.cjs.map +0 -1
- package/dist/chunk-IPKFWZDD.cjs.map +0 -1
- /package/dist/{chunk-2NLZ4CB4.js.map → chunk-3S56I5MX.js.map} +0 -0
- /package/dist/{chunk-H74TCWVN.js.map → chunk-77XUG4Z4.js.map} +0 -0
- /package/dist/{chunk-TGIBJHM6.js.map → chunk-H6SSHFMD.js.map} +0 -0
- /package/dist/{chunk-CI7HVQAK.js.map → chunk-J4VGVLQI.js.map} +0 -0
- /package/dist/{chunk-43YWCHYX.js.map → chunk-LF4S37VU.js.map} +0 -0
- /package/dist/{chunk-SSBK7TBW.js.map → chunk-LNOXNCEC.js.map} +0 -0
- /package/dist/{chunk-WGKTGAP3.js.map → chunk-LZXZ3C6M.js.map} +0 -0
- /package/dist/{chunk-ZOVS6HJW.js.map → chunk-OB3ZJ7GQ.js.map} +0 -0
- /package/dist/{chunk-VDROT42I.js.map → chunk-PYNHPMDB.js.map} +0 -0
- /package/dist/{chunk-ZF2KSQER.js.map → chunk-QD4BVKAU.js.map} +0 -0
- /package/dist/{chunk-JUO6CFGZ.js.map → chunk-QYFXRVH3.js.map} +0 -0
- /package/dist/{chunk-4XR3D6BN.js.map → chunk-SG53SIJX.js.map} +0 -0
- /package/dist/{chunk-IHIEAC2G.js.map → chunk-VE7HLTVQ.js.map} +0 -0
- /package/dist/{chunk-2ACUTFHC.js.map → chunk-WVDBRL2S.js.map} +0 -0
- /package/dist/{chunk-SFIVEDZA.js.map → chunk-YCVDJX7Z.js.map} +0 -0
- /package/dist/{chunk-YHE4PSYQ.js.map → chunk-Z7A7FUWY.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,30 +1,71 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type React from 'react';
|
|
4
|
+
import Link from '../../embed-shims/next-link';
|
|
4
5
|
import { cn } from '../../utils/cn';
|
|
5
6
|
import { Chevron02LeftIcon } from '../icons-v2-generated/arrows/chevron-02-left-icon';
|
|
6
7
|
|
|
7
8
|
export interface BackButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
8
9
|
label?: string;
|
|
9
10
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
11
|
+
/**
|
|
12
|
+
* Where "back" goes. With it the control is a real link (open in a new tab,
|
|
13
|
+
* prefetch, right-click); without it, a button that runs `onClick`.
|
|
14
|
+
*/
|
|
15
|
+
href?: string;
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const BACK_BUTTON_CLASS = cn(
|
|
19
|
+
'group inline-flex items-center justify-center self-start rounded-md',
|
|
20
|
+
'gap-[var(--spacing-system-xsf)] py-[var(--spacing-system-sf)]',
|
|
21
|
+
'text-ods-text-secondary hover:text-ods-text-primary',
|
|
22
|
+
'transition-colors duration-200',
|
|
23
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ods-focus',
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/** The footprint of a `BackButton`, for a loading skeleton that must not move the page. */
|
|
27
|
+
export const BACK_BUTTON_SKELETON_CLASS = 'h-12 w-40 rounded-md';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* THE back navigation of a page: the chevron and its label, above the title.
|
|
31
|
+
* Every detail page renders this one (through `PageLayout`'s `backButton` or
|
|
32
|
+
* directly), never a hand-built link.
|
|
33
|
+
*/
|
|
34
|
+
export function BackButton({ label = 'Back', className, type = 'button', href, ...props }: BackButtonProps) {
|
|
35
|
+
const content = (
|
|
36
|
+
<>
|
|
26
37
|
<Chevron02LeftIcon className="size-6 shrink-0" />
|
|
27
38
|
<span className="text-h4">{label}</span>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
if (href) {
|
|
42
|
+
// A link takes everything a button and an anchor share (id, title, data-*, aria-*,
|
|
43
|
+
// handlers); what only a button understands is left off.
|
|
44
|
+
const {
|
|
45
|
+
disabled: _disabled,
|
|
46
|
+
form: _form,
|
|
47
|
+
formAction: _formAction,
|
|
48
|
+
formEncType: _formEncType,
|
|
49
|
+
formMethod: _formMethod,
|
|
50
|
+
formNoValidate: _formNoValidate,
|
|
51
|
+
formTarget: _formTarget,
|
|
52
|
+
name: _name,
|
|
53
|
+
value: _value,
|
|
54
|
+
...shared
|
|
55
|
+
} = props;
|
|
56
|
+
return (
|
|
57
|
+
<Link
|
|
58
|
+
{...(shared as unknown as React.AnchorHTMLAttributes<HTMLAnchorElement>)}
|
|
59
|
+
href={href}
|
|
60
|
+
className={cn(BACK_BUTTON_CLASS, className)}
|
|
61
|
+
>
|
|
62
|
+
{content}
|
|
63
|
+
</Link>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return (
|
|
67
|
+
<button type={type} className={cn(BACK_BUTTON_CLASS, className)} {...props}>
|
|
68
|
+
{content}
|
|
28
69
|
</button>
|
|
29
70
|
);
|
|
30
71
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
3
|
import type { MeetingHost } from '../../schemas/meeting-booking-schema';
|
|
5
4
|
import { cn } from '../../utils/cn';
|
|
6
5
|
import { formatDurationCompact } from '../../utils/format';
|
|
7
6
|
import { BackButton } from '../layout/back-button';
|
|
8
|
-
import { SquareAvatar, AvatarStack, Button, Skeleton
|
|
7
|
+
import { SquareAvatar, AvatarStack, Button, Skeleton } from '../ui';
|
|
8
|
+
import { TimezoneSelect } from '../ui/timezone-select';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* ContextPanel — the "who / what / how long" side of the scheduler card
|
|
@@ -100,19 +100,6 @@ const BACK_BUTTON_CLASS = 'py-0';
|
|
|
100
100
|
* section headers. */
|
|
101
101
|
const FIELD_LABEL_CLASS = 'text-h4 text-ods-text-primary';
|
|
102
102
|
|
|
103
|
-
function zoneLabel(tz: string): string {
|
|
104
|
-
try {
|
|
105
|
-
const parts = new Intl.DateTimeFormat('en-US', {
|
|
106
|
-
timeZone: tz,
|
|
107
|
-
timeZoneName: 'shortOffset',
|
|
108
|
-
}).formatToParts(new Date());
|
|
109
|
-
const offset = parts.find(p => p.type === 'timeZoneName')?.value ?? '';
|
|
110
|
-
return offset ? `${tz.replace(/_/g, ' ')} (${offset})` : tz.replace(/_/g, ' ');
|
|
111
|
-
} catch {
|
|
112
|
-
return tz.replace(/_/g, ' ');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
103
|
/**
|
|
117
104
|
* Same-footprint skeleton — swaps with the loaded panel with zero shift.
|
|
118
105
|
* STATIC labels ("Duration", "Timezone") render REAL; only data-driven
|
|
@@ -172,22 +159,6 @@ export function SchedulerContextPanel({
|
|
|
172
159
|
showTimezone = true,
|
|
173
160
|
className,
|
|
174
161
|
}: SchedulerContextPanelProps) {
|
|
175
|
-
// All IANA zones with live GMT offsets — computed once, client-only (the
|
|
176
|
-
// panel renders the picker only after the parent resolves a zone).
|
|
177
|
-
const zoneOptions = useMemo(() => {
|
|
178
|
-
if (!timezone) return [];
|
|
179
|
-
let zones: string[];
|
|
180
|
-
try {
|
|
181
|
-
// Older lib targets don't type supportedValuesOf (ES2022) — runtime-guarded.
|
|
182
|
-
const intl = Intl as typeof Intl & { supportedValuesOf?: (key: string) => string[] };
|
|
183
|
-
zones = intl.supportedValuesOf ? intl.supportedValuesOf('timeZone') : [timezone];
|
|
184
|
-
} catch {
|
|
185
|
-
zones = [timezone];
|
|
186
|
-
}
|
|
187
|
-
if (!zones.includes(timezone)) zones = [timezone, ...zones];
|
|
188
|
-
return zones.map(tz => ({ value: tz, label: zoneLabel(tz) }));
|
|
189
|
-
}, [timezone]);
|
|
190
|
-
|
|
191
162
|
return (
|
|
192
163
|
<div className={cn(PANEL_STACK, className)}>
|
|
193
164
|
{/* The card's ONE back edge, at every step — the caller decides where it
|
|
@@ -273,16 +244,12 @@ export function SchedulerContextPanel({
|
|
|
273
244
|
<div className={cn(STRIP_ASIDE, locked && 'max-lg:hidden')}>
|
|
274
245
|
<p className={FIELD_LABEL_CLASS}>Timezone</p>
|
|
275
246
|
{timezone ? (
|
|
276
|
-
<
|
|
247
|
+
<TimezoneSelect
|
|
277
248
|
value={timezone}
|
|
278
249
|
disabled={disabled}
|
|
279
250
|
onChange={tz => {
|
|
280
251
|
if (tz) onTimezoneChange?.(tz);
|
|
281
252
|
}}
|
|
282
|
-
options={zoneOptions}
|
|
283
|
-
placeholder="Search timezone…"
|
|
284
|
-
noOptionsText="No matching timezone"
|
|
285
|
-
showClearAll={false}
|
|
286
253
|
/>
|
|
287
254
|
) : (
|
|
288
255
|
<Skeleton className="h-12 w-full" />
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { BackButton } from '../layout/back-button';
|
|
4
|
+
import { timezoneLabel, timezoneOptions } from './timezone-select';
|
|
5
|
+
|
|
6
|
+
describe('timezone options', () => {
|
|
7
|
+
it('labels a zone with its name and GMT offset', () => {
|
|
8
|
+
expect(timezoneLabel('America/New_York')).toMatch(/^America\/New York \(GMT[-+]\d+\)$/);
|
|
9
|
+
expect(timezoneLabel('UTC')).toMatch(/^UTC/);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('lists the IANA zones and keeps a current zone the runtime does not list', () => {
|
|
13
|
+
const options = timezoneOptions('Mars/Olympus');
|
|
14
|
+
expect(options[0]).toEqual({ value: 'Mars/Olympus', label: 'Mars/Olympus' });
|
|
15
|
+
expect(options.some(o => o.value === 'Europe/Rome')).toBe(true);
|
|
16
|
+
expect(timezoneOptions().some(o => o.value === 'Mars/Olympus')).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('BackButton', () => {
|
|
21
|
+
it('is a link when it is given an href, a button otherwise', () => {
|
|
22
|
+
const link = renderToStaticMarkup(<BackButton label="Back to list" href="/list" />);
|
|
23
|
+
expect(link).toMatch(/^<a [^>]*href="\/list"/);
|
|
24
|
+
expect(link).toContain('Back to list');
|
|
25
|
+
expect(renderToStaticMarkup(<BackButton label="Back" />)).toMatch(/^<button type="button"/);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('a link keeps the attributes a caller passes, minus the button-only ones', () => {
|
|
29
|
+
const link = renderToStaticMarkup(
|
|
30
|
+
<BackButton
|
|
31
|
+
label="Back"
|
|
32
|
+
href="/list"
|
|
33
|
+
id="back"
|
|
34
|
+
title="Go back"
|
|
35
|
+
data-testid="back"
|
|
36
|
+
aria-label="Back to list"
|
|
37
|
+
disabled
|
|
38
|
+
name="x"
|
|
39
|
+
/>,
|
|
40
|
+
);
|
|
41
|
+
expect(link).toContain('id="back"');
|
|
42
|
+
expect(link).toContain('title="Go back"');
|
|
43
|
+
expect(link).toContain('data-testid="back"');
|
|
44
|
+
expect(link).toContain('aria-label="Back to list"');
|
|
45
|
+
expect(link).not.toContain('disabled');
|
|
46
|
+
expect(link).not.toContain('name=');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { Autocomplete } from './autocomplete';
|
|
5
|
+
|
|
6
|
+
/** An IANA zone as people read it: "Europe/Rome (GMT+2)". */
|
|
7
|
+
export function timezoneLabel(tz: string): string {
|
|
8
|
+
const name = tz.replace(/_/g, ' ');
|
|
9
|
+
try {
|
|
10
|
+
const parts = new Intl.DateTimeFormat('en-US', {
|
|
11
|
+
timeZone: tz,
|
|
12
|
+
timeZoneName: 'shortOffset',
|
|
13
|
+
}).formatToParts(new Date());
|
|
14
|
+
const offset = parts.find(p => p.type === 'timeZoneName')?.value ?? '';
|
|
15
|
+
return offset ? `${name} (${offset})` : name;
|
|
16
|
+
} catch {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Every IANA zone the runtime knows, with `current` kept in the list when it is not one of them. */
|
|
22
|
+
export function timezoneOptions(current?: string | null): { value: string; label: string }[] {
|
|
23
|
+
let zones: string[] = [];
|
|
24
|
+
try {
|
|
25
|
+
// Older lib targets don't type supportedValuesOf (ES2022) — runtime-guarded.
|
|
26
|
+
const intl = Intl as typeof Intl & { supportedValuesOf?: (key: string) => string[] };
|
|
27
|
+
zones = intl.supportedValuesOf ? intl.supportedValuesOf('timeZone') : [];
|
|
28
|
+
} catch {
|
|
29
|
+
zones = [];
|
|
30
|
+
}
|
|
31
|
+
if (current && !zones.includes(current)) zones = [current, ...zones];
|
|
32
|
+
return zones.map(tz => ({ value: tz, label: timezoneLabel(tz) }));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TimezoneSelectProps {
|
|
36
|
+
/** The chosen IANA zone; empty or null for none. */
|
|
37
|
+
value: string | null;
|
|
38
|
+
/** The zone picked, or null when the field was cleared (only with `clearable`). */
|
|
39
|
+
onChange: (timezone: string | null) => void;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/** Whether the field may be emptied. Default false: a zone, once set, is only replaced. */
|
|
42
|
+
clearable?: boolean;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* THE timezone picker: a searchable list of every IANA zone with its live GMT
|
|
49
|
+
* offset. The meeting scheduler and every form that stores a zone use it, so a
|
|
50
|
+
* zone is always chosen from the list and never typed.
|
|
51
|
+
*/
|
|
52
|
+
export function TimezoneSelect({
|
|
53
|
+
value,
|
|
54
|
+
onChange,
|
|
55
|
+
disabled,
|
|
56
|
+
clearable = false,
|
|
57
|
+
placeholder = 'Search timezone…',
|
|
58
|
+
className,
|
|
59
|
+
}: TimezoneSelectProps) {
|
|
60
|
+
const options = useMemo(() => timezoneOptions(value), [value]);
|
|
61
|
+
return (
|
|
62
|
+
<Autocomplete
|
|
63
|
+
className={className}
|
|
64
|
+
value={value || null}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
onChange={tz => {
|
|
67
|
+
if (tz || clearable) onChange(tz ?? null);
|
|
68
|
+
}}
|
|
69
|
+
options={options}
|
|
70
|
+
placeholder={placeholder}
|
|
71
|
+
noOptionsText="No matching timezone"
|
|
72
|
+
showClearAll={clearable}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
package/src/utils/image-proxy.ts
CHANGED
|
@@ -121,3 +121,20 @@ export function shouldProxyImage(imageUrl: string | null, proxyPrefix?: string):
|
|
|
121
121
|
export function generateImageSizes(_url: string): string {
|
|
122
122
|
return `(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw`;
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether an image must be served as it is, past the host's image optimizer
|
|
127
|
+
* (`<Image unoptimized>`): a Google-hosted avatar (the optimizer's fetch of it is
|
|
128
|
+
* refused, and Google already serves it at the size its URL asks for) and an SVG
|
|
129
|
+
* (a vector has nothing to resize). The one rule for every avatar and logo.
|
|
130
|
+
*/
|
|
131
|
+
export function skipsImageOptimizer(url: string | null | undefined): boolean {
|
|
132
|
+
if (!url) return false;
|
|
133
|
+
if (urlPathLooksLikeSvg(url)) return true;
|
|
134
|
+
try {
|
|
135
|
+
const hostname = new URL(url.startsWith('//') ? `https:${url}` : url).hostname.toLowerCase();
|
|
136
|
+
return hostname === 'googleusercontent.com' || hostname.endsWith('.googleusercontent.com');
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { skipsImageOptimizer } from './image-proxy';
|
|
3
|
+
|
|
4
|
+
describe('skipsImageOptimizer', () => {
|
|
5
|
+
it('skips Google-hosted avatars and SVGs, nothing else', () => {
|
|
6
|
+
expect(skipsImageOptimizer('https://lh3.googleusercontent.com/a/abc=s96-c')).toBe(true);
|
|
7
|
+
expect(skipsImageOptimizer('//lh3.googleusercontent.com/a/abc')).toBe(true);
|
|
8
|
+
expect(skipsImageOptimizer('https://cdn.example.com/logo.svg?v=2')).toBe(true);
|
|
9
|
+
expect(skipsImageOptimizer('https://evilgoogleusercontent.com/a.png')).toBe(false);
|
|
10
|
+
expect(skipsImageOptimizer('https://cdn.example.com/photo.jpg')).toBe(false);
|
|
11
|
+
expect(skipsImageOptimizer('/api/image-proxy?url=x')).toBe(false);
|
|
12
|
+
expect(skipsImageOptimizer(null)).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
});
|