@flamingo-stack/openframe-frontend-core 0.0.791 → 0.0.793
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-ABZGBMC2.cjs → chunk-BI6FE3HO.cjs} +10 -10
- package/dist/{chunk-W3Q7ZQLS.cjs → chunk-BTI4RRU2.cjs} +2 -2
- package/dist/{chunk-3XSWE5FW.cjs → chunk-CASWVIJC.cjs} +8 -4
- package/dist/{chunk-6TPROUHW.cjs → chunk-CB24ILOB.cjs} +24 -14
- package/dist/{chunk-YWNXZAQ2.cjs → chunk-CKSAUEEL.cjs} +16 -16
- package/dist/{chunk-3AN35WAO.cjs → chunk-DWYMZ3LO.cjs} +24 -24
- package/dist/{chunk-DKOLQPE7.cjs → chunk-FDZOE5TL.cjs} +16 -1
- package/dist/{chunk-YPWFYQFE.cjs → chunk-FEARCFP4.cjs} +5 -5
- package/dist/{chunk-STEJZPIO.cjs → chunk-LHV2R6QU.cjs} +3 -3
- package/dist/{chunk-O4TKEWNW.cjs → chunk-LMZICTQW.cjs} +3 -3
- package/dist/{chunk-EPWLLLGW.cjs → chunk-LVBSVUHD.cjs} +2 -2
- package/dist/{chunk-4YIDZCTL.cjs → chunk-SMZWXY4X.cjs} +7 -13
- package/dist/{chunk-6ZPHUDTP.cjs → chunk-XGE2WCOH.cjs} +3 -3
- package/dist/{chunk-MIUFSOUN.cjs → chunk-YDH5OVRQ.cjs} +45 -38
- package/dist/{chunk-2I2AXIBD.cjs → chunk-ZCNEO273.cjs} +75 -55
- package/dist/{cloud-tenants-TTOYIEN3.cjs → cloud-tenants-BISHVU2T.cjs} +12 -12
- package/dist/components/case-studies/index.cjs +11 -11
- package/dist/components/contact/index.cjs +3 -3
- package/dist/components/docs/index.cjs +5 -5
- package/dist/components/docs/skeletons.d.ts.map +1 -1
- package/dist/components/docs/skeletons.js +11 -1
- package/dist/components/embeds/index.cjs +3 -3
- package/dist/components/faq/index.cjs +3 -3
- 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 +2 -2
- package/dist/components/help-center-pages/index.cjs +50 -50
- package/dist/components/help-center-pages/trust-center-sections.js +1 -1
- package/dist/components/index.cjs +18 -18
- 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/directory.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/directory.js +3 -1
- package/dist/components/meeting-scheduler/index.cjs +137 -61
- 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 +3 -3
- package/dist/components/onboarding-guides/index.cjs +4 -4
- package/dist/components/product-demo/fixtures/devices.d.ts.map +1 -1
- package/dist/components/product-demo/fixtures/devices.js +5 -12
- package/dist/components/product-demo/fixtures/shared.d.ts +89 -0
- package/dist/components/product-demo/fixtures/shared.d.ts.map +1 -1
- package/dist/components/product-demo/fixtures/shared.js +15 -0
- package/dist/components/product-demo/index.cjs +16 -16
- package/dist/components/product-demo/screens/devices-view.d.ts.map +1 -1
- package/dist/components/product-demo/screens/devices-view.js +3 -1
- package/dist/components/shared/roadmap/roadmap-grid.d.ts.map +1 -1
- package/dist/components/shared/roadmap/roadmap-grid.js +15 -8
- package/dist/components/tickets/index.cjs +5 -5
- package/dist/components/ui/index.cjs +2 -2
- package/dist/{devices-SKWJYGUD.cjs → devices-GMR73ZF3.cjs} +8 -8
- package/dist/index.cjs +3 -3
- package/dist/{knowledge-BPB2TROI.cjs → knowledge-XC2K5VQO.cjs} +6 -6
- package/dist/loading-standard/engine.d.mts.map +1 -1
- package/dist/{logs-VIHYNQU4.cjs → logs-LBGQLETC.cjs} +24 -24
- package/dist/{policies-YVNOCNNO.cjs → policies-3XVE6266.cjs} +9 -9
- package/dist/{remote-session-WKLEYACD.cjs → remote-session-4ZNTOLOQ.cjs} +5 -5
- 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-MK5FCR7L.cjs → scripts-NE5IL4NC.cjs} +13 -13
- package/dist/{software-update-GDV75A2Z.cjs → software-update-EJDKTFAP.cjs} +13 -13
- package/dist/{tickets-board-URMIIAKD.cjs → tickets-board-X4GHEKPB.cjs} +17 -17
- package/package.json +1 -1
- package/src/components/docs/skeletons.tsx +7 -1
- package/src/components/features/conversation-card.tsx +89 -64
- package/src/components/help-center-pages/trust-center-sections.tsx +1 -1
- 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/directory.tsx +6 -1
- package/src/components/meeting-scheduler/index.tsx +23 -2
- package/src/components/product-demo/fixtures/devices.ts +5 -12
- package/src/components/product-demo/fixtures/shared.ts +20 -0
- package/src/components/product-demo/screens/devices-view.tsx +3 -0
- package/src/components/shared/roadmap/roadmap-grid.tsx +29 -7
- package/src/loading-standard/engine.mjs +6 -2
- package/src/schemas/meeting-booking-schema.ts +62 -0
|
@@ -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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeviceFilters, DeviceRow } from '../../features/devices';
|
|
2
2
|
import type { DemoCast } from '../cast';
|
|
3
|
-
import { DEMO_DEVICES, demoMinutesAgo } from './shared';
|
|
3
|
+
import { type DEMO_DEVICES, DEMO_FLEET, DEMO_FLEET_SEARCH_OS, demoMinutesAgo } from './shared';
|
|
4
4
|
|
|
5
5
|
type DemoDevice = (typeof DEMO_DEVICES)[keyof typeof DEMO_DEVICES];
|
|
6
6
|
|
|
@@ -48,16 +48,9 @@ export interface DevicesFixture {
|
|
|
48
48
|
|
|
49
49
|
/** The fleet of the three demo customers on an ordinary morning: a mix of states, one desktop offline since last night. */
|
|
50
50
|
export function buildDevicesFixture(cast: DemoCast): DevicesFixture {
|
|
51
|
-
const devices: DeviceRow[] =
|
|
52
|
-
device(cast,
|
|
53
|
-
|
|
54
|
-
device(cast, DEMO_DEVICES.mayaAir, 'laptop', 'ONLINE', 1),
|
|
55
|
-
device(cast, DEMO_DEVICES.buildServer, 'server', 'ONLINE', 1),
|
|
56
|
-
device(cast, DEMO_DEVICES.leoThinkPad, 'laptop', 'OFFLINE', 64),
|
|
57
|
-
device(cast, DEMO_DEVICES.samT14, 'laptop', 'ONLINE', 3),
|
|
58
|
-
device(cast, DEMO_DEVICES.jenSurface, 'laptop', 'ONLINE', 6),
|
|
59
|
-
device(cast, DEMO_DEVICES.priyaXps, 'laptop', 'ONLINE', 2),
|
|
60
|
-
];
|
|
51
|
+
const devices: DeviceRow[] = DEMO_FLEET.map(entry =>
|
|
52
|
+
device(cast, entry.device, entry.type, entry.status, entry.lastSeenMinutesAgo),
|
|
53
|
+
);
|
|
61
54
|
const deviceFilters: DeviceFilters = {
|
|
62
55
|
statuses: countBy(devices, row => row.status),
|
|
63
56
|
deviceTypes: countBy(devices, row => row.type),
|
|
@@ -75,7 +68,7 @@ export function buildDevicesFixture(cast: DemoCast): DevicesFixture {
|
|
|
75
68
|
/** The fleet narrowed to its Windows devices, the way the list answers that search. */
|
|
76
69
|
export function buildWindowsDevicesFixture(cast: DemoCast): DevicesFixture {
|
|
77
70
|
const fleet = buildDevicesFixture(cast);
|
|
78
|
-
const devices = fleet.devices.filter(row => row.osType ===
|
|
71
|
+
const devices = fleet.devices.filter(row => row.osType === DEMO_FLEET_SEARCH_OS);
|
|
79
72
|
return {
|
|
80
73
|
devices,
|
|
81
74
|
deviceFilters: { ...fleet.deviceFilters, filteredCount: devices.length },
|
|
@@ -42,6 +42,26 @@ export const DEMO_DEVICES = {
|
|
|
42
42
|
warehouse: { id: 'device-warehouse', hostname: 'WAREHOUSE-PC03', os: 'WINDOWS', organization: 'acme' },
|
|
43
43
|
} as const;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The fleet the Devices screen lists, in its order: each device with its kind, its status and how long ago it was
|
|
47
|
+
* seen. The fixture builds its rows from it, and the screen's loading state counts its rows from it, so the two
|
|
48
|
+
* always draw the same number of rows.
|
|
49
|
+
*/
|
|
50
|
+
export const DEMO_FLEET = [
|
|
51
|
+
{ device: DEMO_DEVICES.frontDesk, type: 'laptop', status: 'ONLINE', lastSeenMinutesAgo: 2 },
|
|
52
|
+
{ device: DEMO_DEVICES.reception, type: 'desktop', status: 'OFFLINE', lastSeenMinutesAgo: 190 },
|
|
53
|
+
{ device: DEMO_DEVICES.mayaAir, type: 'laptop', status: 'ONLINE', lastSeenMinutesAgo: 1 },
|
|
54
|
+
{ device: DEMO_DEVICES.buildServer, type: 'server', status: 'ONLINE', lastSeenMinutesAgo: 1 },
|
|
55
|
+
{ device: DEMO_DEVICES.leoThinkPad, type: 'laptop', status: 'OFFLINE', lastSeenMinutesAgo: 64 },
|
|
56
|
+
{ device: DEMO_DEVICES.samT14, type: 'laptop', status: 'ONLINE', lastSeenMinutesAgo: 3 },
|
|
57
|
+
{ device: DEMO_DEVICES.jenSurface, type: 'laptop', status: 'ONLINE', lastSeenMinutesAgo: 6 },
|
|
58
|
+
{ device: DEMO_DEVICES.priyaXps, type: 'laptop', status: 'ONLINE', lastSeenMinutesAgo: 2 },
|
|
59
|
+
] as const;
|
|
60
|
+
|
|
61
|
+
/** The OS the Devices screen's search answers, and how many fleet devices run it (the rows the search shows). */
|
|
62
|
+
export const DEMO_FLEET_SEARCH_OS = 'WINDOWS';
|
|
63
|
+
export const DEMO_FLEET_SEARCH_ROWS = DEMO_FLEET.filter(entry => entry.device.os === DEMO_FLEET_SEARCH_OS).length;
|
|
64
|
+
|
|
45
65
|
/**
|
|
46
66
|
* A fixed "now" for relative times, so a screen reads the same on every render
|
|
47
67
|
* and never drifts between the server and the browser.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { DevicesPanelView, type DeviceFilters, type DeviceRow, IDLE_DEVICES_TOOLBAR } from '../../features/devices';
|
|
4
|
+
import { DEMO_FLEET_SEARCH_ROWS } from '../fixtures/shared';
|
|
4
5
|
|
|
5
6
|
/** What the Devices page shows for a search: the query in the field and the rows that answer it. */
|
|
6
7
|
export const DEVICES_SEARCH_QUERY = 'Windows';
|
|
@@ -52,6 +53,8 @@ export function DevicesScreenView({
|
|
|
52
53
|
hideColumns={compact ? HIDDEN_WHEN_COMPACT : undefined}
|
|
53
54
|
loading={loading}
|
|
54
55
|
loadingRegion={false}
|
|
56
|
+
// The page is the search's answer: its rows, loading and loaded (never the product's page size).
|
|
57
|
+
pageSize={DEMO_FLEET_SEARCH_ROWS}
|
|
55
58
|
/>
|
|
56
59
|
</div>
|
|
57
60
|
);
|
|
@@ -32,7 +32,7 @@ import { EmptyState } from '../../empty-state';
|
|
|
32
32
|
import { LoadingRegion } from '../../loading/loading-region';
|
|
33
33
|
import { TextLineSkeleton } from '../../loading/unified-skeleton';
|
|
34
34
|
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '../../ui';
|
|
35
|
-
import { useLoadingScope } from '../../ui/loading-scope';
|
|
35
|
+
import { LoadingItems, useLoadingScope } from '../../ui/loading-scope';
|
|
36
36
|
import { useRoadmapVoting, type UseRoadmapVotingOptions } from './use-roadmap-voting';
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -234,8 +234,26 @@ const QUARTER_CONTENT_CLASS = 'pt-4';
|
|
|
234
234
|
const QUARTER_CONTENT_INNER_CLASS = 'pb-4';
|
|
235
235
|
|
|
236
236
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
237
|
+
* Collapsed past quarters the grouped grid draws while its items are read, before the open one: a TYPICAL count
|
|
238
|
+
* (measured on the live roadmap, 2026-10: four past quarters older than the ones kept open). The loaded grid shows
|
|
239
|
+
* every quarter older than `quartersToKeepClosed` collapsed (`computeDefaultExpandedQuarters`), so its first quarters
|
|
240
|
+
* are heads only.
|
|
241
|
+
*/
|
|
242
|
+
const ROADMAP_SKELETON_CLOSED_QUARTERS = 4;
|
|
243
|
+
|
|
244
|
+
/** A collapsed quarter while it is read: its heading and item count as bars, nothing under them. */
|
|
245
|
+
function RoadmapQuarterHeadSkeleton() {
|
|
246
|
+
return (
|
|
247
|
+
<div className={QUARTER_HEAD_CLASS}>
|
|
248
|
+
<TextLineSkeleton type="h2" className="w-40" />
|
|
249
|
+
<TextLineSkeleton type="h6" className="w-16" />
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The quarter-grouped grid while its items are read, in the loaded grid's shape: the collapsed past quarters (heads
|
|
256
|
+
* only), then one open quarter, its head and the grid's card skeletons.
|
|
239
257
|
*/
|
|
240
258
|
function RoadmapGridQuarterSkeleton({
|
|
241
259
|
showLeftMargin = true,
|
|
@@ -249,11 +267,15 @@ function RoadmapGridQuarterSkeleton({
|
|
|
249
267
|
}) {
|
|
250
268
|
return (
|
|
251
269
|
<div className={QUARTER_LIST_CLASS} aria-hidden>
|
|
270
|
+
<LoadingItems count={ROADMAP_SKELETON_CLOSED_QUARTERS}>
|
|
271
|
+
{() => (
|
|
272
|
+
<div data-loading-item>
|
|
273
|
+
<RoadmapQuarterHeadSkeleton />
|
|
274
|
+
</div>
|
|
275
|
+
)}
|
|
276
|
+
</LoadingItems>
|
|
252
277
|
<div className="flex flex-col" data-loading-item>
|
|
253
|
-
<
|
|
254
|
-
<TextLineSkeleton type="h2" className="w-40" />
|
|
255
|
-
<TextLineSkeleton type="h6" className="w-16" />
|
|
256
|
-
</div>
|
|
278
|
+
<RoadmapQuarterHeadSkeleton />
|
|
257
279
|
{/* The quarter's content box: the `AccordionContent` padding (`pt-4` here, the content's own `pb-4` inside). */}
|
|
258
280
|
<div className={QUARTER_CONTENT_CLASS}>
|
|
259
281
|
<div className={QUARTER_CONTENT_INNER_CLASS}>
|
|
@@ -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
|
+
}
|