@flamingo-stack/openframe-frontend-core 0.0.698-2527.7789.1 → 0.0.698
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-2BS7SRKK.js → chunk-2QESJBGE.js} +6 -6
- package/dist/{chunk-XUXPIXEQ.cjs → chunk-3CFHHJKK.cjs} +3 -3
- package/dist/{chunk-XUXPIXEQ.cjs.map → chunk-3CFHHJKK.cjs.map} +1 -1
- package/dist/{chunk-U5N4424J.cjs → chunk-4FS56YZS.cjs} +349 -328
- package/dist/chunk-4FS56YZS.cjs.map +1 -0
- package/dist/{chunk-FXXBZHEM.cjs → chunk-55L6XDGC.cjs} +7 -7
- package/dist/{chunk-FXXBZHEM.cjs.map → chunk-55L6XDGC.cjs.map} +1 -1
- package/dist/{chunk-YQPN6IGK.js → chunk-5VXVHYHC.js} +3 -3
- package/dist/{chunk-BB246CT4.cjs → chunk-676MGKZW.cjs} +3 -3
- package/dist/{chunk-BB246CT4.cjs.map → chunk-676MGKZW.cjs.map} +1 -1
- package/dist/{chunk-AKMQG7PN.js → chunk-7QAT2DV5.js} +3 -3
- package/dist/{chunk-3523KRUN.js → chunk-AC6OEPUV.js} +4 -4
- package/dist/{chunk-ZSJOUXQZ.cjs → chunk-BRTCMVBG.cjs} +6 -6
- package/dist/{chunk-ZSJOUXQZ.cjs.map → chunk-BRTCMVBG.cjs.map} +1 -1
- package/dist/{chunk-ERHBYCLP.cjs → chunk-BZHARMWU.cjs} +55 -55
- package/dist/{chunk-ERHBYCLP.cjs.map → chunk-BZHARMWU.cjs.map} +1 -1
- package/dist/{chunk-BOZJLRDG.cjs → chunk-FBXR26Q4.cjs} +40 -40
- package/dist/{chunk-BOZJLRDG.cjs.map → chunk-FBXR26Q4.cjs.map} +1 -1
- package/dist/{chunk-5SDHD3PY.js → chunk-FI7ZPOYQ.js} +23 -2
- package/dist/chunk-FI7ZPOYQ.js.map +1 -0
- package/dist/{chunk-KSLQXGCP.js → chunk-FWVIDEOA.js} +2 -2
- package/dist/{chunk-K32G3W5N.js → chunk-HNHKXOCZ.js} +5 -5
- package/dist/{chunk-3XSOSIJJ.cjs → chunk-IRWS22CP.cjs} +17 -17
- package/dist/{chunk-3XSOSIJJ.cjs.map → chunk-IRWS22CP.cjs.map} +1 -1
- package/dist/{chunk-Q2PQXELU.js → chunk-J3ZS6CRA.js} +3 -3
- package/dist/{chunk-J3W4DGON.js → chunk-J6ZEVCVN.js} +2 -2
- package/dist/{chunk-SLO5WH6A.js → chunk-MOEOLUVD.js} +2 -2
- package/dist/{chunk-RD2RMUXY.cjs → chunk-OEX2WLZX.cjs} +10 -10
- package/dist/{chunk-RD2RMUXY.cjs.map → chunk-OEX2WLZX.cjs.map} +1 -1
- package/dist/{chunk-YS6UKG6O.js → chunk-R2XJXMAT.js} +5 -5
- package/dist/{chunk-6W4EKHPI.js → chunk-R4JFUVQ4.js} +2 -2
- package/dist/{chunk-RHP4QPBC.js → chunk-TN2RFU6D.js} +25 -18
- package/dist/{chunk-RHP4QPBC.js.map → chunk-TN2RFU6D.js.map} +1 -1
- package/dist/{chunk-QILYO7ZD.cjs → chunk-UXU4DROI.cjs} +3 -3
- package/dist/{chunk-QILYO7ZD.cjs.map → chunk-UXU4DROI.cjs.map} +1 -1
- package/dist/{chunk-DFXVX4OW.cjs → chunk-VCEO6AGC.cjs} +15 -15
- package/dist/{chunk-DFXVX4OW.cjs.map → chunk-VCEO6AGC.cjs.map} +1 -1
- package/dist/{chunk-Q4HYMAP7.cjs → chunk-VO2FJ2AL.cjs} +23 -23
- package/dist/{chunk-Q4HYMAP7.cjs.map → chunk-VO2FJ2AL.cjs.map} +1 -1
- package/dist/{chunk-XBB53UGE.js → chunk-VOSO3SC5.js} +4 -4
- package/dist/{chunk-KLJK5HSA.cjs → chunk-VP6PJLMI.cjs} +9 -2
- package/dist/chunk-VP6PJLMI.cjs.map +1 -0
- package/dist/{chunk-ZA4JA7EN.cjs → chunk-VQEXKCFM.cjs} +3 -3
- package/dist/{chunk-ZA4JA7EN.cjs.map → chunk-VQEXKCFM.cjs.map} +1 -1
- package/dist/{chunk-UCIH6J3Y.cjs → chunk-X2W4ANCM.cjs} +33 -33
- package/dist/{chunk-UCIH6J3Y.cjs.map → chunk-X2W4ANCM.cjs.map} +1 -1
- package/dist/{chunk-3PH2TF2S.js → chunk-YNBOPBO7.js} +3 -3
- package/dist/{chunk-7VOCFD43.cjs → chunk-YRSPHPGO.cjs} +21 -21
- package/dist/{chunk-7VOCFD43.cjs.map → chunk-YRSPHPGO.cjs.map} +1 -1
- package/dist/{chunk-URC357EJ.js → chunk-ZNJK5HOE.js} +2 -2
- package/dist/components/announcement-bar.d.ts.map +1 -1
- package/dist/components/case-studies/index.cjs +13 -13
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +52 -52
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +36 -35
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +15 -14
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +28 -28
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-scenario-player.d.ts +3 -0
- package/dist/hooks/use-scenario-player.d.ts.map +1 -1
- package/dist/index.cjs +13 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +21 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/path-pattern.d.ts +5 -0
- package/dist/utils/path-pattern.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/announcement-bar.tsx +3 -2
- package/src/hooks/__tests__/use-scenario-player.test.tsx +48 -0
- package/src/hooks/use-scenario-player.ts +22 -2
- package/src/utils/__tests__/path-pattern.test.ts +30 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/path-pattern.ts +31 -0
- package/dist/chunk-5SDHD3PY.js.map +0 -1
- package/dist/chunk-KLJK5HSA.cjs.map +0 -1
- package/dist/chunk-U5N4424J.cjs.map +0 -1
- /package/dist/{chunk-2BS7SRKK.js.map → chunk-2QESJBGE.js.map} +0 -0
- /package/dist/{chunk-YQPN6IGK.js.map → chunk-5VXVHYHC.js.map} +0 -0
- /package/dist/{chunk-AKMQG7PN.js.map → chunk-7QAT2DV5.js.map} +0 -0
- /package/dist/{chunk-3523KRUN.js.map → chunk-AC6OEPUV.js.map} +0 -0
- /package/dist/{chunk-KSLQXGCP.js.map → chunk-FWVIDEOA.js.map} +0 -0
- /package/dist/{chunk-K32G3W5N.js.map → chunk-HNHKXOCZ.js.map} +0 -0
- /package/dist/{chunk-Q2PQXELU.js.map → chunk-J3ZS6CRA.js.map} +0 -0
- /package/dist/{chunk-J3W4DGON.js.map → chunk-J6ZEVCVN.js.map} +0 -0
- /package/dist/{chunk-SLO5WH6A.js.map → chunk-MOEOLUVD.js.map} +0 -0
- /package/dist/{chunk-YS6UKG6O.js.map → chunk-R2XJXMAT.js.map} +0 -0
- /package/dist/{chunk-6W4EKHPI.js.map → chunk-R4JFUVQ4.js.map} +0 -0
- /package/dist/{chunk-XBB53UGE.js.map → chunk-VOSO3SC5.js.map} +0 -0
- /package/dist/{chunk-3PH2TF2S.js.map → chunk-YNBOPBO7.js.map} +0 -0
- /package/dist/{chunk-URC357EJ.js.map → chunk-ZNJK5HOE.js.map} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function isValidPathPattern(pattern: string): boolean;
|
|
2
|
+
export declare function matchesPathPattern(pathname: string, pattern: string): boolean;
|
|
3
|
+
/** True when the pathname matches any pattern of the list. */
|
|
4
|
+
export declare function pathMatchesAny(pathname: string, patterns: readonly string[] | null | undefined): boolean;
|
|
5
|
+
//# sourceMappingURL=path-pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-pattern.d.ts","sourceRoot":"","sources":["../../src/utils/path-pattern.ts"],"names":[],"mappings":"AAmBA,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAExG"}
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../utils/announcement-storage';
|
|
14
14
|
import { getAppType } from '../utils/app-config';
|
|
15
15
|
import { pickReadableTextColor } from '../utils/color-analysis';
|
|
16
|
+
import { pathMatchesAny } from '../utils/path-pattern';
|
|
16
17
|
import { EntityIcon } from './icon-display';
|
|
17
18
|
import { AnnouncementBarView } from './ui/announcement-bar-view';
|
|
18
19
|
import { Button } from './ui/button';
|
|
@@ -141,8 +142,8 @@ export function AnnouncementBar({
|
|
|
141
142
|
|
|
142
143
|
// Preview always mirrors the draft directly (storage is not consulted there).
|
|
143
144
|
// A page that shows the news itself (a hero's news pill) is listed in the
|
|
144
|
-
// announcement's `excluded_paths
|
|
145
|
-
const excludedHere = pathname != null && (announcement?.excluded_paths
|
|
145
|
+
// announcement's `excluded_paths` (path patterns); the bar stays collapsed there.
|
|
146
|
+
const excludedHere = pathname != null && pathMatchesAny(pathname, announcement?.excluded_paths);
|
|
146
147
|
const expanded = previewMode
|
|
147
148
|
? announcement != null
|
|
148
149
|
: announcement != null && expandedState && !dismissed && !excludedHere;
|
|
@@ -188,6 +188,54 @@ describe('useScenarioPlayer', () => {
|
|
|
188
188
|
expect(result.current.step).toBe(7);
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
it('takes its first step within a third of a second of becoming playable, then keeps the beat', () => {
|
|
192
|
+
stubReducedMotion(false);
|
|
193
|
+
const { result, rerender } = renderHook(({ enabled }) => useScenarioPlayer({ ...OPTIONS, enabled }), {
|
|
194
|
+
initialProps: { enabled: false },
|
|
195
|
+
});
|
|
196
|
+
rerender({ enabled: true });
|
|
197
|
+
act(() => {
|
|
198
|
+
vi.advanceTimersByTime(300);
|
|
199
|
+
});
|
|
200
|
+
expect(result.current.step).toBe(1);
|
|
201
|
+
// The next one takes a whole beat.
|
|
202
|
+
act(() => {
|
|
203
|
+
vi.advanceTimersByTime(1600);
|
|
204
|
+
});
|
|
205
|
+
expect(result.current.step).toBe(1);
|
|
206
|
+
act(() => {
|
|
207
|
+
vi.advanceTimersByTime(100);
|
|
208
|
+
});
|
|
209
|
+
expect(result.current.step).toBe(2);
|
|
210
|
+
|
|
211
|
+
// Coming back on screen is the same: it moves at once.
|
|
212
|
+
rerender({ enabled: false });
|
|
213
|
+
rerender({ enabled: true });
|
|
214
|
+
act(() => {
|
|
215
|
+
vi.advanceTimersByTime(300);
|
|
216
|
+
});
|
|
217
|
+
expect(result.current.step).toBe(3);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('still holds a finished scenario its full time when it becomes playable', () => {
|
|
221
|
+
stubReducedMotion(false);
|
|
222
|
+
const { result, rerender } = renderHook(
|
|
223
|
+
({ enabled }) => useScenarioPlayer({ ...OPTIONS, enabled, startAtEnd: true }),
|
|
224
|
+
{
|
|
225
|
+
initialProps: { enabled: false },
|
|
226
|
+
},
|
|
227
|
+
);
|
|
228
|
+
rerender({ enabled: true });
|
|
229
|
+
act(() => {
|
|
230
|
+
vi.advanceTimersByTime(4000);
|
|
231
|
+
});
|
|
232
|
+
expect(result.current).toMatchObject({ scenario: 0, step: 8 });
|
|
233
|
+
act(() => {
|
|
234
|
+
vi.advanceTimersByTime(200);
|
|
235
|
+
});
|
|
236
|
+
expect(result.current).toMatchObject({ scenario: 1, step: 0 });
|
|
237
|
+
});
|
|
238
|
+
|
|
191
239
|
it('parks on the last step under reduced motion and never advances', () => {
|
|
192
240
|
stubReducedMotion(true);
|
|
193
241
|
const { result } = renderHook(() => useScenarioPlayer(OPTIONS));
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useAutoplay } from './ui/use-autoplay';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* How soon the first step follows the moment the demo becomes playable (it
|
|
8
|
+
* scrolled into view, the tab came back, play was pressed). A demo that sits
|
|
9
|
+
* still for a whole step after it appears reads as broken; one that moves
|
|
10
|
+
* within a third of a second reads as responding to you.
|
|
11
|
+
*/
|
|
12
|
+
const START_MS = 300;
|
|
13
|
+
|
|
6
14
|
export interface UseScenarioPlayerOptions {
|
|
7
15
|
/** How many scenarios (tabs) the stage cycles through. */
|
|
8
16
|
scenarioCount: number;
|
|
@@ -55,6 +63,9 @@ export interface UseScenarioPlayerResult {
|
|
|
55
63
|
* not paused, motion allowed. Under reduced motion it parks on the last step
|
|
56
64
|
* of the current scenario, and every scenario can still be read by choosing it.
|
|
57
65
|
*
|
|
66
|
+
* The moment it becomes playable its first step follows within `START_MS`,
|
|
67
|
+
* not a whole step later; from there every step takes `stepMs`.
|
|
68
|
+
*
|
|
58
69
|
* A visitor's own choice (`go`, `setStep`) moves the clock there and un-pauses
|
|
59
70
|
* it; the rotation carries on from that point.
|
|
60
71
|
*/
|
|
@@ -79,9 +90,18 @@ export function useScenarioPlayer({
|
|
|
79
90
|
|
|
80
91
|
const playing = auto.playing && scenarioCount > 0;
|
|
81
92
|
|
|
93
|
+
// True from the moment it becomes playable until its first tick has been scheduled.
|
|
94
|
+
const starting = useRef(false);
|
|
95
|
+
const wasPlaying = useRef(false);
|
|
82
96
|
useEffect(() => {
|
|
97
|
+
if (playing && !wasPlaying.current) starting.current = true;
|
|
98
|
+
wasPlaying.current = playing;
|
|
83
99
|
if (!playing) return undefined;
|
|
84
100
|
const atEnd = rawStep >= lastStep;
|
|
101
|
+
// The first step after it becomes playable comes quickly. A finished
|
|
102
|
+
// scenario still holds its full time: it is there to be read.
|
|
103
|
+
const quickStart = starting.current && !atEnd;
|
|
104
|
+
starting.current = false;
|
|
85
105
|
const timer = setTimeout(
|
|
86
106
|
() => {
|
|
87
107
|
if (atEnd) {
|
|
@@ -91,7 +111,7 @@ export function useScenarioPlayer({
|
|
|
91
111
|
setRawStep(current => Math.min(current, lastStep) + 1);
|
|
92
112
|
}
|
|
93
113
|
},
|
|
94
|
-
atEnd ? holdMs : stepMs,
|
|
114
|
+
atEnd ? holdMs : quickStart ? Math.min(START_MS, stepMs) : stepMs,
|
|
95
115
|
);
|
|
96
116
|
return () => clearTimeout(timer);
|
|
97
117
|
}, [playing, rawStep, lastStep, stepMs, holdMs, scenario, scenarioCount]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { isValidPathPattern, matchesPathPattern, pathMatchesAny } from '../path-pattern';
|
|
3
|
+
|
|
4
|
+
describe('path patterns', () => {
|
|
5
|
+
it('a plain path matches itself and nothing longer', () => {
|
|
6
|
+
expect(matchesPathPattern('/', '/')).toBe(true);
|
|
7
|
+
expect(matchesPathPattern('/blog', '/')).toBe(false);
|
|
8
|
+
expect(matchesPathPattern('/blog/post', '/blog')).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('a regular expression matches the whole pathname', () => {
|
|
12
|
+
expect(matchesPathPattern('/blog/post', '/blog/.*')).toBe(true);
|
|
13
|
+
expect(matchesPathPattern('/blog', '/blog(/.*)?')).toBe(true);
|
|
14
|
+
expect(matchesPathPattern('/pricing', '/(pricing|trial)')).toBe(true);
|
|
15
|
+
expect(matchesPathPattern('/pricing/enterprise', '/(pricing|trial)')).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('a pattern that does not compile is invalid and matches nothing', () => {
|
|
19
|
+
expect(isValidPathPattern('/blog/(')).toBe(false);
|
|
20
|
+
expect(matchesPathPattern('/blog/(', '/blog/(')).toBe(false);
|
|
21
|
+
expect(isValidPathPattern(' ')).toBe(false);
|
|
22
|
+
expect(isValidPathPattern('/blog/.*')).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('matches against a list', () => {
|
|
26
|
+
expect(pathMatchesAny('/careers', ['/', '/careers'])).toBe(true);
|
|
27
|
+
expect(pathMatchesAny('/about', ['/', '/careers'])).toBe(false);
|
|
28
|
+
expect(pathMatchesAny('/about', null)).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
});
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PATH PATTERN is a regular expression matched against a WHOLE pathname:
|
|
3
|
+
* `/` matches the home page only, `/blog/.*` every page under the blog,
|
|
4
|
+
* `/(pricing|trial)` either page. A plain path is a pattern that matches
|
|
5
|
+
* itself. Used wherever an admin lists the pages something applies to (an
|
|
6
|
+
* announcement's "hidden on" list).
|
|
7
|
+
*
|
|
8
|
+
* The whole pathname must match (the pattern is anchored at both ends), so
|
|
9
|
+
* `/blog` never matches `/blog/post`. A pattern that does not compile matches
|
|
10
|
+
* nothing; `isValidPathPattern` lets a form say so before it is saved.
|
|
11
|
+
*/
|
|
12
|
+
function compile(pattern: string): RegExp | null {
|
|
13
|
+
try {
|
|
14
|
+
return new RegExp(`^(?:${pattern})$`);
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isValidPathPattern(pattern: string): boolean {
|
|
21
|
+
return pattern.trim().length > 0 && compile(pattern.trim()) !== null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function matchesPathPattern(pathname: string, pattern: string): boolean {
|
|
25
|
+
return compile(pattern.trim())?.test(pathname) ?? false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** True when the pathname matches any pattern of the list. */
|
|
29
|
+
export function pathMatchesAny(pathname: string, patterns: readonly string[] | null | undefined): boolean {
|
|
30
|
+
return (patterns ?? []).some(pattern => matchesPathPattern(pathname, pattern));
|
|
31
|
+
}
|