@flamingo-stack/openframe-frontend-core 0.0.792 → 0.0.794
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/{case-study-card-MCAM232N.cjs → case-study-card-KU4ZIONR.cjs} +2 -2
- package/dist/{chunk-HMV32LV4.cjs → chunk-2KLYMAHF.cjs} +4 -4
- package/dist/{chunk-ZZPGSLMO.cjs → chunk-3XAFK4WH.cjs} +8 -8
- package/dist/{chunk-P2JY2XCV.cjs → chunk-43ZVXQJK.cjs} +52 -52
- package/dist/{chunk-OKQQJ5TD.cjs → chunk-6TUI5KQS.cjs} +39 -39
- package/dist/{chunk-ZW2TS775.cjs → chunk-6VP5UWZG.cjs} +2 -2
- package/dist/{chunk-6ZPHUDTP.cjs → chunk-A6E5ZNQR.cjs} +3 -3
- package/dist/{chunk-ABZGBMC2.cjs → chunk-BFCGOHQG.cjs} +32 -32
- package/dist/{chunk-3AN35WAO.cjs → chunk-CLEZ6TWZ.cjs} +68 -68
- package/dist/{chunk-7EH7KKFW.cjs → chunk-F73DM65J.cjs} +71 -71
- package/dist/{chunk-IHLGPIFO.cjs → chunk-FOWQ4XTB.cjs} +2 -2
- package/dist/{chunk-VUQNTCAL.cjs → chunk-FYHXMHY6.cjs} +13 -13
- package/dist/{chunk-OZIPPOSJ.cjs → chunk-FYPVCCCV.cjs} +101 -101
- package/dist/{chunk-5MIGBLDC.cjs → chunk-HXL7AUPG.cjs} +17 -17
- package/dist/{chunk-UNUJ5YQ5.cjs → chunk-IJ23KNYI.cjs} +4 -4
- package/dist/{chunk-YPWFYQFE.cjs → chunk-IQTVKPRG.cjs} +22 -22
- package/dist/{chunk-EPWLLLGW.cjs → chunk-KQPU5N7T.cjs} +13 -13
- package/dist/{chunk-TBGVWIF7.cjs → chunk-NGGEYE5R.cjs} +2 -2
- package/dist/{chunk-W3Q7ZQLS.cjs → chunk-NIW4ETGC.cjs} +4 -4
- package/dist/{chunk-SXEIK7RU.cjs → chunk-OK467OQJ.cjs} +2 -2
- package/dist/{chunk-FBA6S4ES.cjs → chunk-QDW64E6T.cjs} +99 -99
- package/dist/{chunk-YWNXZAQ2.cjs → chunk-U4D4ABXK.cjs} +38 -38
- package/dist/{chunk-WWWLOMZI.cjs → chunk-UAZTXYPC.cjs} +81 -79
- package/dist/{chunk-C5EPWKM7.cjs → chunk-UN6LC5PK.cjs} +1 -1
- package/dist/{chunk-2I2AXIBD.cjs → chunk-YPKAMHYA.cjs} +230 -210
- package/dist/{chunk-O4TKEWNW.cjs → chunk-YYKXX5NA.cjs} +11 -11
- package/dist/{chunk-4G2KZHZW.cjs → chunk-ZIMPE7D5.cjs} +3 -3
- package/dist/{cloud-tenants-CQOD6DDR.cjs → cloud-tenants-Z3AYAXF5.cjs} +7 -7
- package/dist/components/case-studies/index.cjs +22 -22
- package/dist/components/chat/index.cjs +6 -6
- package/dist/components/contact/index.cjs +8 -8
- package/dist/components/docs/index.cjs +11 -11
- package/dist/components/embeds/index.cjs +8 -8
- package/dist/components/faq/index.cjs +9 -9
- package/dist/components/features/conversation-card.d.ts.map +1 -1
- package/dist/components/features/conversation-card.js +77 -56
- package/dist/components/features/index.cjs +7 -7
- package/dist/components/help-center-pages/index.cjs +84 -84
- package/dist/components/index.cjs +56 -56
- package/dist/components/meeting-scheduler/booking-context-summary.d.ts +8 -0
- package/dist/components/meeting-scheduler/booking-context-summary.d.ts.map +1 -0
- package/dist/components/meeting-scheduler/booking-context-summary.js +54 -0
- package/dist/components/meeting-scheduler/booking-form.d.ts +14 -1
- package/dist/components/meeting-scheduler/booking-form.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/booking-form.js +13 -3
- package/dist/components/meeting-scheduler/index.cjs +154 -80
- package/dist/components/meeting-scheduler/index.d.ts +6 -2
- package/dist/components/meeting-scheduler/index.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.js +7 -2
- package/dist/components/navigation/index.cjs +10 -10
- package/dist/components/onboarding-guides/index.cjs +10 -10
- package/dist/components/product-demo/index.cjs +16 -16
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/shared/roadmap/roadmap-grid.d.ts.map +1 -1
- package/dist/components/shared/roadmap/roadmap-grid.js +3 -1
- package/dist/components/tickets/index.cjs +14 -14
- package/dist/components/ui/index.cjs +7 -7
- package/dist/components/ui/status-badge.d.ts.map +1 -1
- package/dist/components/ui/status-badge.js +1 -1
- package/dist/{devices-PEBUW34G.cjs → devices-P6XQL23S.cjs} +8 -8
- package/dist/{embeddable-chat-54X3TTG4.cjs → embeddable-chat-6BNLOSBB.cjs} +67 -67
- package/dist/index.cjs +11 -11
- package/dist/{knowledge-KL4BP2YK.cjs → knowledge-IU5ORU7U.cjs} +8 -8
- package/dist/loading-standard/engine.d.mts.map +1 -1
- package/dist/{logs-TO277M4F.cjs → logs-DCFTQVKA.cjs} +15 -15
- package/dist/{policies-6HSKMG4I.cjs → policies-ESC6XCVH.cjs} +11 -11
- package/dist/schemas/meeting-booking-schema.cjs +21 -0
- package/dist/schemas/meeting-booking-schema.d.ts +43 -0
- package/dist/schemas/meeting-booking-schema.d.ts.map +1 -1
- package/dist/schemas/meeting-booking-schema.js +21 -0
- package/dist/{scripts-4IO2LPMY.cjs → scripts-24PIP2VO.cjs} +12 -12
- package/dist/{software-update-RMAWEZKX.cjs → software-update-47GDTKMI.cjs} +10 -10
- package/package.json +1 -1
- package/src/components/features/conversation-card.tsx +89 -64
- package/src/components/meeting-scheduler/booking-context-summary.tsx +100 -0
- package/src/components/meeting-scheduler/booking-form.tsx +28 -0
- package/src/components/meeting-scheduler/index.tsx +23 -2
- package/src/components/shared/roadmap/roadmap-grid.tsx +5 -1
- package/src/components/ui/status-badge.tsx +4 -2
- package/src/loading-standard/engine.mjs +6 -2
- package/src/schemas/meeting-booking-schema.ts +62 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { type CSSProperties, type ReactNode, useId } from 'react';
|
|
3
|
+
import { type ComponentProps, type CSSProperties, type ReactNode, useId } from 'react';
|
|
4
4
|
import { cn } from '../../utils/cn';
|
|
5
5
|
import { isOwnClick } from '../../utils/own-click';
|
|
6
6
|
import { useAgentTint } from '../agent-identity';
|
|
@@ -10,7 +10,7 @@ import { CheckIcon } from '../icons-v2-generated/signs-and-symbols/check-icon';
|
|
|
10
10
|
import { PlusIcon } from '../icons-v2-generated/signs-and-symbols/plus-icon';
|
|
11
11
|
import { LoadingRegion } from '../loading/loading-region';
|
|
12
12
|
import { TextLineSkeleton } from '../loading/unified-skeleton';
|
|
13
|
-
import {
|
|
13
|
+
import { Button } from '../ui/button/button';
|
|
14
14
|
import { InertWhileLoading, useLoadingScope } from '../ui/loading-scope';
|
|
15
15
|
import { Tag } from '../ui/tag';
|
|
16
16
|
|
|
@@ -50,12 +50,14 @@ const OUTCOME_CHECK_CLASS = 'flex shrink-0 items-center';
|
|
|
50
50
|
const OUTCOME_CHECK_STYLE = { height: '1lh' } as const;
|
|
51
51
|
/** The request's quote: two lines at least, cut at two. Read by the card and its skeleton. */
|
|
52
52
|
const REQUEST_TEXT_CLASS = 'm-0 line-clamp-2 min-h-[2lh] text-ods-text-primary text-h3';
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
53
|
+
/**
|
|
54
|
+
* A pickable card's first row: the asker's turn, then the selection toggle in its own column at the row's end. The
|
|
55
|
+
* toggle is part of the layout, never drawn over it (the selectable-card practice of Carbon, Salt and PatternFly: the
|
|
56
|
+
* mark always visible, in a place of its own), so the asker's name and time make room for it instead of running under it.
|
|
57
|
+
*/
|
|
58
|
+
const REQUESTER_ROW_CLASS = 'flex items-start gap-[var(--spacing-system-xsf)]';
|
|
59
|
+
const REQUESTER_TURN_CLASS = 'min-w-0 flex-1';
|
|
60
|
+
const SELECTION_TOGGLE_CLASS = 'shrink-0';
|
|
59
61
|
/** The context's label ("Today"): copy the page states, drawn for real in both forms. */
|
|
60
62
|
const CONTEXT_LABEL_CLASS = 'text-ods-text-secondary text-h6';
|
|
61
63
|
/** The speakers' avatar corner as the skeleton draws it. */
|
|
@@ -186,36 +188,35 @@ export function ConversationCard({
|
|
|
186
188
|
})
|
|
187
189
|
}
|
|
188
190
|
>
|
|
189
|
-
{selection && (
|
|
190
|
-
// The toggle is a regular boxed Button in the card's corner, named by the
|
|
191
|
-
// request; a click anywhere on the card toggles it too (a pointer
|
|
192
|
-
// convenience: the Button is the control keyboards and screen readers use).
|
|
193
|
-
<Button
|
|
194
|
-
type="button"
|
|
195
|
-
variant={selection.pressed ? 'accent' : 'outline'}
|
|
196
|
-
size="icon-sm"
|
|
197
|
-
aria-pressed={selection.pressed}
|
|
198
|
-
aria-labelledby={requestId}
|
|
199
|
-
onClick={event => {
|
|
200
|
-
event.stopPropagation();
|
|
201
|
-
selection.onToggle();
|
|
202
|
-
}}
|
|
203
|
-
className={SELECTION_TOGGLE_CLASS}
|
|
204
|
-
>
|
|
205
|
-
{selection.pressed ? <CheckIcon /> : <PlusIcon />}
|
|
206
|
-
</Button>
|
|
207
|
-
)}
|
|
208
191
|
{/* Every part keeps at least its number of lines, so cards in a row or a carousel line up part by part. */}
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
192
|
+
<RequesterRow
|
|
193
|
+
selection={
|
|
194
|
+
// A regular boxed Button, named by the request; a click anywhere on the card toggles it too (a pointer
|
|
195
|
+
// convenience: the Button is the control keyboards and screen readers use).
|
|
196
|
+
selection && (
|
|
197
|
+
<SelectionToggle
|
|
198
|
+
pressed={selection.pressed}
|
|
199
|
+
aria-labelledby={requestId}
|
|
200
|
+
onClick={event => {
|
|
201
|
+
event.stopPropagation();
|
|
202
|
+
selection.onToggle();
|
|
203
|
+
}}
|
|
204
|
+
/>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
>
|
|
208
|
+
<ChatTurn
|
|
209
|
+
avatar={requester.avatar}
|
|
210
|
+
name={requester.name}
|
|
211
|
+
meta={requester.meta}
|
|
212
|
+
time={requester.time}
|
|
213
|
+
className={selection ? REQUESTER_TURN_CLASS : undefined}
|
|
215
214
|
>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
<p id={requestId} className={REQUEST_TEXT_CLASS} title={request}>
|
|
216
|
+
“{request}”
|
|
217
|
+
</p>
|
|
218
|
+
</ChatTurn>
|
|
219
|
+
</RequesterRow>
|
|
219
220
|
{context && (
|
|
220
221
|
<div className={CONTEXT_BLOCK_CLASS}>
|
|
221
222
|
<span className={CONTEXT_LABEL_CLASS}>{context.label}</span>
|
|
@@ -304,34 +305,28 @@ function ConversationCardSkeleton({
|
|
|
304
305
|
const outcomeLines = partLines(lines?.outcome);
|
|
305
306
|
return (
|
|
306
307
|
<LoadingRegion label={label} announce={announce} className={cn(CARD_FRAME_CLASS, className)}>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
<div style={selection ? REQUEST_CLEAR_TOGGLE_STYLE : undefined}>
|
|
330
|
-
<TextLineSkeleton lines={2} type="h3" />
|
|
331
|
-
</div>
|
|
332
|
-
),
|
|
333
|
-
}}
|
|
334
|
-
/>
|
|
308
|
+
<RequesterRow
|
|
309
|
+
selection={
|
|
310
|
+
selection && (
|
|
311
|
+
<InertWhileLoading className="contents">
|
|
312
|
+
<SelectionToggle pressed={selection.pressed} />
|
|
313
|
+
</InertWhileLoading>
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
>
|
|
317
|
+
<ChatTurn
|
|
318
|
+
loading
|
|
319
|
+
name=""
|
|
320
|
+
className={selection ? REQUESTER_TURN_CLASS : undefined}
|
|
321
|
+
skeleton={{
|
|
322
|
+
avatarPx,
|
|
323
|
+
avatarShape: SKELETON_AVATAR_SHAPE,
|
|
324
|
+
meta: requesterMeta,
|
|
325
|
+
time: requesterTime,
|
|
326
|
+
body: <TextLineSkeleton lines={2} type="h3" />,
|
|
327
|
+
}}
|
|
328
|
+
/>
|
|
329
|
+
</RequesterRow>
|
|
335
330
|
{context && (
|
|
336
331
|
<div className={CONTEXT_BLOCK_CLASS}>
|
|
337
332
|
{typeof context === 'string' ? (
|
|
@@ -377,3 +372,33 @@ function ConversationCardSkeleton({
|
|
|
377
372
|
</LoadingRegion>
|
|
378
373
|
);
|
|
379
374
|
}
|
|
375
|
+
|
|
376
|
+
/** The asker's turn, and the selection toggle at the row's end when the card is pickable (`REQUESTER_ROW_CLASS`). */
|
|
377
|
+
function RequesterRow({ selection, children }: { selection?: ReactNode; children: ReactNode }) {
|
|
378
|
+
if (!selection) return <>{children}</>;
|
|
379
|
+
return (
|
|
380
|
+
<div className={REQUESTER_ROW_CLASS}>
|
|
381
|
+
{children}
|
|
382
|
+
{selection}
|
|
383
|
+
</div>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** The selection toggle: ONE element for the card and its skeleton, a "+" until picked and a check once picked. */
|
|
388
|
+
function SelectionToggle({
|
|
389
|
+
pressed,
|
|
390
|
+
...props
|
|
391
|
+
}: { pressed: boolean } & Pick<ComponentProps<typeof Button>, 'onClick' | 'aria-labelledby'>) {
|
|
392
|
+
return (
|
|
393
|
+
<Button
|
|
394
|
+
type="button"
|
|
395
|
+
variant={pressed ? 'accent' : 'outline'}
|
|
396
|
+
size="icon-sm"
|
|
397
|
+
aria-pressed={pressed}
|
|
398
|
+
className={SELECTION_TOGGLE_CLASS}
|
|
399
|
+
{...props}
|
|
400
|
+
>
|
|
401
|
+
{pressed ? <CheckIcon /> : <PlusIcon />}
|
|
402
|
+
</Button>
|
|
403
|
+
);
|
|
404
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The booking form's summary of what the visitor told the page before it (a `BookingContext`): its label, then one
|
|
5
|
+
* tag per line. Read only: the visitor changes it where they gave it (the page above the form).
|
|
6
|
+
*
|
|
7
|
+
* With a `slot` (`BookingContextSlot`) the block keeps the space of its most lines from its first paint: a grid of
|
|
8
|
+
* that many cells, one line each. Loading, every cell is a tag's skeleton; loaded, the given lines fill the cells in
|
|
9
|
+
* order, and with none an empty state (the slot's `emptyText`) fills the whole space. The block is one height in all
|
|
10
|
+
* three, so picking a card never moves the page. Without a slot it takes room only once it has a line.
|
|
11
|
+
*/
|
|
12
|
+
import type { ReactNode } from 'react';
|
|
13
|
+
import { type BookingContext, type BookingContextSlot, hasBookingContext } from '../../schemas/meeting-booking-schema';
|
|
14
|
+
import { cn } from '../../utils/cn';
|
|
15
|
+
import { useLoadingScope } from '../ui/loading-scope';
|
|
16
|
+
import { Tag } from '../ui/tag';
|
|
17
|
+
|
|
18
|
+
/** The cells: one column on a phone, two from `content-md`. ONE class for every state. */
|
|
19
|
+
const SLOT_GRID_CLASS = 'grid grid-cols-1 gap-[var(--spacing-system-xs)] content-md:grid-cols-2';
|
|
20
|
+
/** A cell: a flex row, so a tag (or its inline skeleton) is the cell's whole height, with no line box around it. */
|
|
21
|
+
const SLOT_CELL_CLASS = 'flex min-w-0';
|
|
22
|
+
/** A line's tag: the sentence tag, never wider than its cell (a longer line clips, whole in the tag's tooltip). */
|
|
23
|
+
const LINE_TAG_PROPS = { variant: 'outline', size: 'sentence', className: 'max-w-full' } as const;
|
|
24
|
+
/** A line while loading: a typical sentence's width, not the tag skeleton's label width. */
|
|
25
|
+
const LOADING_LINE_CLASS = 'w-3/4';
|
|
26
|
+
/** The empty state, over the whole reserved space (its slots hidden under it). */
|
|
27
|
+
const EMPTY_CLASS =
|
|
28
|
+
'absolute inset-0 flex items-center justify-center rounded-md border border-dashed border-ods-border px-[var(--spacing-system-sf)] text-center text-ods-text-secondary text-h6';
|
|
29
|
+
/** A cell no line has filled yet: a dashed slot at a tag's height, so the reserved space reads as places to fill. */
|
|
30
|
+
const EMPTY_CELL_CLASS = 'h-9 w-full rounded-md border border-dashed border-ods-border';
|
|
31
|
+
|
|
32
|
+
export function BookingContextSummary({
|
|
33
|
+
context,
|
|
34
|
+
slot,
|
|
35
|
+
loading: loadingProp,
|
|
36
|
+
}: {
|
|
37
|
+
context?: BookingContext | null;
|
|
38
|
+
slot?: BookingContextSlot;
|
|
39
|
+
/** Draw the loading form outside a loading scope too. */
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
}) {
|
|
42
|
+
const loading = useLoadingScope() || loadingProp;
|
|
43
|
+
const items = hasBookingContext(context) ? context.items.filter(item => item.trim()) : [];
|
|
44
|
+
const label = slot?.label ?? context?.label;
|
|
45
|
+
if (!label || (!slot && items.length === 0)) return null;
|
|
46
|
+
if (!slot) {
|
|
47
|
+
return (
|
|
48
|
+
<SummaryFrame label={label}>
|
|
49
|
+
<ul className="flex flex-wrap gap-[var(--spacing-system-xs)]" aria-label={label}>
|
|
50
|
+
{items.map(item => (
|
|
51
|
+
<li key={item} className="min-w-0 max-w-full">
|
|
52
|
+
<Tag label={item} {...LINE_TAG_PROPS} />
|
|
53
|
+
</li>
|
|
54
|
+
))}
|
|
55
|
+
</ul>
|
|
56
|
+
</SummaryFrame>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const cells = Array.from({ length: Math.max(slot.slots, items.length) }, (_, index) => items[index]);
|
|
60
|
+
return (
|
|
61
|
+
<SummaryFrame label={label}>
|
|
62
|
+
<div className="relative">
|
|
63
|
+
<ul className={SLOT_GRID_CLASS} aria-label={label}>
|
|
64
|
+
{cells.map((item, index) => {
|
|
65
|
+
const empty = !loading && !item;
|
|
66
|
+
return (
|
|
67
|
+
<li
|
|
68
|
+
key={item ?? `empty-${index}`}
|
|
69
|
+
className={SLOT_CELL_CLASS}
|
|
70
|
+
aria-hidden={empty || undefined}
|
|
71
|
+
// Each cell is an item of the list in every state, so loading and loaded count the same cells.
|
|
72
|
+
data-loading-item=""
|
|
73
|
+
>
|
|
74
|
+
{loading ? (
|
|
75
|
+
<Tag label="" loading {...LINE_TAG_PROPS} className={LOADING_LINE_CLASS} />
|
|
76
|
+
) : item ? (
|
|
77
|
+
<Tag label={item} {...LINE_TAG_PROPS} />
|
|
78
|
+
) : (
|
|
79
|
+
// With no line at all the empty state covers every slot; with some, the rest stay as slots.
|
|
80
|
+
<span className={cn(EMPTY_CELL_CLASS, items.length === 0 && 'invisible')} />
|
|
81
|
+
)}
|
|
82
|
+
</li>
|
|
83
|
+
);
|
|
84
|
+
})}
|
|
85
|
+
</ul>
|
|
86
|
+
{!loading && items.length === 0 && <p className={EMPTY_CLASS}>{slot.emptyText}</p>}
|
|
87
|
+
</div>
|
|
88
|
+
</SummaryFrame>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function SummaryFrame({ label, children }: { label: string; children: ReactNode }) {
|
|
93
|
+
return (
|
|
94
|
+
<div className="flex flex-col gap-[var(--spacing-system-xs)]">
|
|
95
|
+
{/* The label is the page's copy: drawn for real while loading too. */}
|
|
96
|
+
<p className="text-ods-text-secondary text-h6">{label}</p>
|
|
97
|
+
{children}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -26,6 +26,9 @@ import {
|
|
|
26
26
|
type MeetingFormField,
|
|
27
27
|
type SupportedMeetingFormField,
|
|
28
28
|
type BookingFormValues,
|
|
29
|
+
bookingContextFields,
|
|
30
|
+
type BookingContext,
|
|
31
|
+
type BookingContextSlot,
|
|
29
32
|
} from '../../schemas/meeting-booking-schema';
|
|
30
33
|
import { cn } from '../../utils/cn';
|
|
31
34
|
import type { FormRescueDefinition } from '../../utils/form-rescue';
|
|
@@ -53,6 +56,7 @@ import {
|
|
|
53
56
|
import { HoneypotField } from '../ui/honeypot-field';
|
|
54
57
|
import { LOADING_NOOP, useLoadingScope } from '../ui/loading-scope';
|
|
55
58
|
import { TOGGLE_SIZE_CLASS } from '../ui/toggle';
|
|
59
|
+
import { BookingContextSummary } from './booking-context-summary';
|
|
56
60
|
|
|
57
61
|
/**
|
|
58
62
|
* One field in a host-supplied row. `name` is a built-in (`email`, `firstName`,
|
|
@@ -466,6 +470,19 @@ export interface BookingFormProps {
|
|
|
466
470
|
* does not ask is ignored.
|
|
467
471
|
*/
|
|
468
472
|
answers?: Readonly<Record<string, string>>;
|
|
473
|
+
/**
|
|
474
|
+
* What the visitor told the page before the form, beside the link's questions (the cards they picked): drawn at
|
|
475
|
+
* the top of the form as a summary of tags and sent with the booking (`BOOKING_CONTEXT_FIELD`), whatever questions
|
|
476
|
+
* the link declares. Read live, so a change made above the form shows at once; omitted or empty draws nothing.
|
|
477
|
+
* In `deferSlot` mode the form only shows it: the parent attaches the live context when it POSTs.
|
|
478
|
+
*/
|
|
479
|
+
context?: BookingContext | null;
|
|
480
|
+
/**
|
|
481
|
+
* The space the form keeps for `context` from its first paint (loading included), so the page does not jump when
|
|
482
|
+
* a line is added: its label, the most lines, and what it shows while there are none. Omitted: the context takes
|
|
483
|
+
* room only once it has a line.
|
|
484
|
+
*/
|
|
485
|
+
contextSlot?: BookingContextSlot;
|
|
469
486
|
/** Defaults to "Confirm Booking"; details-first says "Continue". */
|
|
470
487
|
submitLabel?: string;
|
|
471
488
|
/** Small print beside the submit (details-first sets expectations). */
|
|
@@ -546,6 +563,7 @@ export function BookingForm(props: BookingFormProps) {
|
|
|
546
563
|
consent={props.consent}
|
|
547
564
|
footerNote={props.footerNote}
|
|
548
565
|
submitLabel={props.submitLabel}
|
|
566
|
+
contextSlot={props.contextSlot}
|
|
549
567
|
/>
|
|
550
568
|
);
|
|
551
569
|
}
|
|
@@ -561,6 +579,8 @@ function BookingFormBody({
|
|
|
561
579
|
deferSlot = false,
|
|
562
580
|
initialValues,
|
|
563
581
|
answers,
|
|
582
|
+
context,
|
|
583
|
+
contextSlot,
|
|
564
584
|
submitLabel,
|
|
565
585
|
footerNote,
|
|
566
586
|
fieldRows,
|
|
@@ -738,6 +758,7 @@ function BookingFormBody({
|
|
|
738
758
|
// must do so synchronously in this call — this form and its honeypot are
|
|
739
759
|
// still mounted here, and `getSignals()` reads a detached ref once they
|
|
740
760
|
// unmount, which would silently disable the decoy.
|
|
761
|
+
// No context here: it can change while the visitor picks a time, so the parent attaches it live at the POST.
|
|
741
762
|
await onSubmit({ ...data, meetingId, [HOST_CONSENT_KEY]: consented, ...formRescue.submitFields() });
|
|
742
763
|
return;
|
|
743
764
|
}
|
|
@@ -748,6 +769,8 @@ function BookingFormBody({
|
|
|
748
769
|
startTimeMs,
|
|
749
770
|
durationMs,
|
|
750
771
|
timezone,
|
|
772
|
+
// The page's context rides beside the answers, never inside them: the server strips it from the booking.
|
|
773
|
+
...bookingContextFields(context),
|
|
751
774
|
...getSignals(),
|
|
752
775
|
...formRescue.submitFields(),
|
|
753
776
|
});
|
|
@@ -851,6 +874,7 @@ function BookingFormBody({
|
|
|
851
874
|
return (
|
|
852
875
|
<form id={formId} onSubmit={submit} className={FORM_STACK} noValidate {...HUBSPOT_DO_NOT_COLLECT_FORM_PROPS}>
|
|
853
876
|
<HoneypotField {...honeypotInputProps} />
|
|
877
|
+
<BookingContextSummary context={context} slot={contextSlot} />
|
|
854
878
|
|
|
855
879
|
{/* Email first, name pair below — the order the desktop and mobile mocks
|
|
856
880
|
both draw. The pair stays TWO columns even on a phone (164px each at
|
|
@@ -1000,6 +1024,7 @@ function BookingFormPending({
|
|
|
1000
1024
|
consent,
|
|
1001
1025
|
footerNote,
|
|
1002
1026
|
submitLabel = DEFAULT_SUBMIT_LABEL,
|
|
1027
|
+
contextSlot,
|
|
1003
1028
|
}: {
|
|
1004
1029
|
fieldRows?: BookingFieldRow[];
|
|
1005
1030
|
/** The optional questions the form asks (`BookingForm`'s `optionalFields`): a row slot naming another optional
|
|
@@ -1015,6 +1040,8 @@ function BookingFormPending({
|
|
|
1015
1040
|
footerNote?: string;
|
|
1016
1041
|
/** The submit button's label (`BookingForm`'s `submitLabel`): the button is drawn for real at its own size. */
|
|
1017
1042
|
submitLabel?: string;
|
|
1043
|
+
/** The context's reserved space (`BookingForm`'s `contextSlot`), drawn as its loading form at its full size. */
|
|
1044
|
+
contextSlot?: BookingContextSlot;
|
|
1018
1045
|
}) {
|
|
1019
1046
|
const consentId = useId();
|
|
1020
1047
|
// The real submit button (static copy), inert with the rest of the form.
|
|
@@ -1026,6 +1053,7 @@ function BookingFormPending({
|
|
|
1026
1053
|
return (
|
|
1027
1054
|
// Inert: the fields are the form's own controls, drawn so each is its loaded size; none takes focus.
|
|
1028
1055
|
<div className={cn('flex-1', FORM_STACK)} aria-hidden inert>
|
|
1056
|
+
<BookingContextSummary slot={contextSlot} loading />
|
|
1029
1057
|
{/* The host's rows (or the built-in layout) through the SAME grid, column
|
|
1030
1058
|
rule and normalisation as the loaded form — see `normalizeFieldRows`. */}
|
|
1031
1059
|
{skeletonRows(fieldRows ?? DEFAULT_FIELD_ROWS, optionalFields).map(row => (
|
|
@@ -48,6 +48,7 @@ import { BOOKING_IN_FLIGHT_MESSAGE, useMeetingBooking } from '../../hooks/use-me
|
|
|
48
48
|
import { useToast } from '../../hooks/use-toast';
|
|
49
49
|
import {
|
|
50
50
|
blocksNativeBooking,
|
|
51
|
+
bookingContextFields,
|
|
51
52
|
type BookingConfirmation,
|
|
52
53
|
type MeetingAvailability,
|
|
53
54
|
type MeetingBookingErrorCode,
|
|
@@ -156,10 +157,20 @@ export interface HubSpotMeetingSchedulerProps {
|
|
|
156
157
|
* so a Server Component can pass it across the RSC boundary where a component
|
|
157
158
|
* cannot. `answers` are what the page took outside the form (a choice made
|
|
158
159
|
* higher up the page), written into questions the visitor has not answered.
|
|
160
|
+
* `context` is what the page learned outside the link's questions, shown in the
|
|
161
|
+
* form and sent with the booking (`BookingContext`); `contextSlot` is the space the
|
|
162
|
+
* form keeps for it from its first paint.
|
|
159
163
|
*/
|
|
160
164
|
detailsFormProps?: Pick<
|
|
161
165
|
BookingFormProps,
|
|
162
|
-
|
|
166
|
+
| 'fieldRows'
|
|
167
|
+
| 'optionalFields'
|
|
168
|
+
| 'consent'
|
|
169
|
+
| 'fieldCopy'
|
|
170
|
+
| 'deniedEmailDomains'
|
|
171
|
+
| 'answers'
|
|
172
|
+
| 'context'
|
|
173
|
+
| 'contextSlot'
|
|
163
174
|
>;
|
|
164
175
|
/** Form rescue for the details form (`RESCUE_FORMS.meetingBooking`). OPT-IN:
|
|
165
176
|
* omitted or `null` saves nothing. */
|
|
@@ -1174,6 +1185,8 @@ export function HubSpotMeetingScheduler({
|
|
|
1174
1185
|
// copies frozen at that point can be stale.
|
|
1175
1186
|
durationMs,
|
|
1176
1187
|
timezone,
|
|
1188
|
+
// Live too: the page's context can change while the visitor is on the calendar.
|
|
1189
|
+
...bookingContextFields(detailsFormProps?.context),
|
|
1177
1190
|
}).finally(() => {
|
|
1178
1191
|
inFlightRef.current = false;
|
|
1179
1192
|
});
|
|
@@ -1213,10 +1226,18 @@ export {
|
|
|
1213
1226
|
type BookingFormConsent,
|
|
1214
1227
|
} from './booking-form';
|
|
1215
1228
|
|
|
1229
|
+
export { BookingContextSummary } from './booking-context-summary';
|
|
1230
|
+
|
|
1216
1231
|
export {
|
|
1217
1232
|
MeetingSchedulerDirectory,
|
|
1218
1233
|
MEETING_DIRECTORY_PAGE_SIZE,
|
|
1219
1234
|
type MeetingSchedulerDirectoryProps,
|
|
1220
1235
|
} from './directory';
|
|
1221
1236
|
export type { MeetingAvailability, BookingConfirmation, MeetingBookingErrorCode, MeetingHost };
|
|
1222
|
-
export type {
|
|
1237
|
+
export type {
|
|
1238
|
+
SchedulingLink,
|
|
1239
|
+
SchedulingLinksPayload,
|
|
1240
|
+
DeniedEmailDomains,
|
|
1241
|
+
BookingContext,
|
|
1242
|
+
BookingContextSlot,
|
|
1243
|
+
} from '../../schemas/meeting-booking-schema';
|
|
@@ -69,6 +69,9 @@ interface RoadmapGridSkeletonProps {
|
|
|
69
69
|
columns?: 1 | 2;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** The loading cards' vote handler: they draw the vote row and take no vote. */
|
|
73
|
+
const NO_VOTE = () => {};
|
|
74
|
+
|
|
72
75
|
function RoadmapGridSkeleton({
|
|
73
76
|
region = true,
|
|
74
77
|
count = ROADMAP_GRID_SKELETON_CARDS,
|
|
@@ -79,7 +82,8 @@ function RoadmapGridSkeleton({
|
|
|
79
82
|
<LoadingRegion label="Loading the roadmap" announce={region} className={roadmapGridClass(columns, showLeftMargin)}>
|
|
80
83
|
{Array.from({ length: count }).map((_, i) => (
|
|
81
84
|
<div key={i} className="min-w-0" data-loading-item>
|
|
82
|
-
|
|
85
|
+
{/* With its vote row, as every card of the loaded grid has (the grid always passes `onVote`). */}
|
|
86
|
+
<RoadmapCard loading onVote={NO_VOTE} />
|
|
83
87
|
</div>
|
|
84
88
|
))}
|
|
85
89
|
</LoadingRegion>
|
|
@@ -103,7 +103,9 @@ export interface StatusBadgeProps
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* A badge while its text is read: one skeleton box with the badge's own padding and type step, its content one line
|
|
106
|
-
* of that step (`box-content`: the padding adds to the line, as it does around the badge's text).
|
|
106
|
+
* of that step (`box-content`: the padding adds to the line, as it does around the badge's text). `align-top`: an
|
|
107
|
+
* empty inline box's baseline is its bottom edge, so on its own line it would add the line's descent below it (5 to
|
|
108
|
+
* 7px taller than the badge with its text).
|
|
107
109
|
*/
|
|
108
110
|
function StatusBadgeSkeleton({ variant, className }: { variant?: 'card' | 'button' | null; className?: string }) {
|
|
109
111
|
return (
|
|
@@ -111,7 +113,7 @@ function StatusBadgeSkeleton({ variant, className }: { variant?: 'card' | 'butto
|
|
|
111
113
|
as="span"
|
|
112
114
|
className={cn(
|
|
113
115
|
statusBadgeVariants({ variant, colorScheme: null }),
|
|
114
|
-
'box-content h-[1lh] w-12 border-transparent',
|
|
116
|
+
'box-content h-[1lh] w-12 border-transparent align-top',
|
|
115
117
|
className,
|
|
116
118
|
)}
|
|
117
119
|
/>
|
|
@@ -257,9 +257,13 @@ const LOADERS = new Set([
|
|
|
257
257
|
'OpenmspHeartbeatLoader',
|
|
258
258
|
'Spinner',
|
|
259
259
|
]);
|
|
260
|
-
/**
|
|
260
|
+
/**
|
|
261
|
+
* The lib's skeleton parts: what a `*Skeleton` (or a component's own loading branch) is built from.
|
|
262
|
+
* `TextLinesByBreakpointSkeleton` is `TextLineSkeleton` at a line count per width (a wrapping title or paragraph):
|
|
263
|
+
* bars with no component of their own, like the rest of the list.
|
|
264
|
+
*/
|
|
261
265
|
const PRIMITIVE =
|
|
262
|
-
/^(?:UnifiedSkeleton|TextLineSkeleton|FieldValueSkeleton|TextHold|LayoutHold|Skeleton)$|^(?:TextSkeleton|MediaSkeleton|InteractiveSkeleton)\./;
|
|
266
|
+
/^(?:UnifiedSkeleton|TextLineSkeleton|TextLinesByBreakpointSkeleton|FieldValueSkeleton|TextHold|LayoutHold|Skeleton)$|^(?:TextSkeleton|MediaSkeleton|InteractiveSkeleton)\./;
|
|
263
267
|
/** The lib's loading wrappers (not loading states of a component). */
|
|
264
268
|
const LOADING_WRAPPER = /^(?:Loading(?:Items|When|Fallback|Suspense|Scope|Region)|InertWhileLoading)$/;
|
|
265
269
|
const WHOLE_VIEW =
|
|
@@ -753,3 +753,65 @@ export type MeetingBookingPayload = z.infer<ReturnType<typeof makeBookingSchema>
|
|
|
753
753
|
* the two survives only on TS's bivariant method-parameter check.
|
|
754
754
|
*/
|
|
755
755
|
export type BookingFormValues = z.infer<ReturnType<typeof makeDeferredBookingSchema>>;
|
|
756
|
+
|
|
757
|
+
// ---------------------------------------------------------------------------
|
|
758
|
+
// Booking context
|
|
759
|
+
// ---------------------------------------------------------------------------
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* What the visitor told the host page BEFORE its form, beside the link's own
|
|
763
|
+
* questions: a labelled list ("Fix these first:" and the cards they picked).
|
|
764
|
+
* The form shows it as a summary of tags and sends it with the booking under
|
|
765
|
+
* `BOOKING_CONTEXT_FIELD`; it never depends on a question the link declares, so
|
|
766
|
+
* a page can carry it on any link. The host reads it on its server with
|
|
767
|
+
* `readBookingContext` and records it where the person running the call sees
|
|
768
|
+
* it (the hub: a note on the HubSpot contact). Never sent to the booking
|
|
769
|
+
* itself: the server schema strips it like any undeclared key.
|
|
770
|
+
*/
|
|
771
|
+
export interface BookingContext {
|
|
772
|
+
/** The summary's heading and the note's lead ("Fix these first:"). */
|
|
773
|
+
label: string;
|
|
774
|
+
/** One line each, in the order the visitor gave them. */
|
|
775
|
+
items: string[];
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* The space a form keeps for its context BEFORE any line is given: the page knows how many lines it can hold (the
|
|
780
|
+
* cards it lists), so the form reserves that many from its first paint, loading included, and the page never jumps
|
|
781
|
+
* when the visitor picks. Display only: never sent.
|
|
782
|
+
*/
|
|
783
|
+
export interface BookingContextSlot {
|
|
784
|
+
/** The block's heading, the context's own label ("Fix these first:"). */
|
|
785
|
+
label: string;
|
|
786
|
+
/** The most lines it can hold: the space reserved. */
|
|
787
|
+
slots: number;
|
|
788
|
+
/** Shown in that space while no line is given ("Nothing picked yet…"). */
|
|
789
|
+
emptyText: string;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/** The booking body's key for the context. */
|
|
793
|
+
export const BOOKING_CONTEXT_FIELD = 'bookingContext';
|
|
794
|
+
|
|
795
|
+
/** Bounds of a context the server accepts; a longer list or line is refused whole. */
|
|
796
|
+
export const BOOKING_CONTEXT_LIMITS = { label: 120, items: 20, item: 400 } as const;
|
|
797
|
+
|
|
798
|
+
const bookingContextSchema = z.object({
|
|
799
|
+
label: z.string().trim().min(1).max(BOOKING_CONTEXT_LIMITS.label),
|
|
800
|
+
items: z.array(z.string().trim().min(1).max(BOOKING_CONTEXT_LIMITS.item)).min(1).max(BOOKING_CONTEXT_LIMITS.items),
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
/** A context worth showing and sending: a label and at least one line. */
|
|
804
|
+
export function hasBookingContext(context: BookingContext | null | undefined): context is BookingContext {
|
|
805
|
+
return Boolean(context && context.label.trim() && context.items.some(item => item.trim()));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/** The body fields that carry a context: none when there is nothing to send. */
|
|
809
|
+
export function bookingContextFields(context: BookingContext | null | undefined): Record<string, BookingContext> {
|
|
810
|
+
return hasBookingContext(context) ? { [BOOKING_CONTEXT_FIELD]: context } : {};
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** The context a booking body carries (`BOOKING_CONTEXT_FIELD`), validated; null when absent or malformed. */
|
|
814
|
+
export function readBookingContext(body: Record<string, unknown>): BookingContext | null {
|
|
815
|
+
const parsed = bookingContextSchema.safeParse(body[BOOKING_CONTEXT_FIELD]);
|
|
816
|
+
return parsed.success ? parsed.data : null;
|
|
817
|
+
}
|