@bookinglab/booking-ui-react 1.10.0 → 1.11.1
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/index.d.cts +509 -3
- package/dist/index.d.ts +509 -3
- package/dist/index.js +4331 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4332 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -301,6 +301,502 @@ interface ResetPasswordFormRef {
|
|
|
301
301
|
setValues: (values: Partial<ResetPasswordFormValues>) => void;
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
interface FormSchemaResponse {
|
|
305
|
+
schema: {
|
|
306
|
+
type: 'extended' | 'legacy' | string;
|
|
307
|
+
form_name: string;
|
|
308
|
+
fields: RawSchemaField[];
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
interface ExtraItemProperties {
|
|
313
|
+
/** Booking extra item data including pricing details. */
|
|
314
|
+
data?: {
|
|
315
|
+
pmtTyp?: string;
|
|
316
|
+
[key: string]: unknown;
|
|
317
|
+
};
|
|
318
|
+
qty?: number;
|
|
319
|
+
field?: string;
|
|
320
|
+
[key: string]: unknown;
|
|
321
|
+
}
|
|
322
|
+
interface VenueResult {
|
|
323
|
+
pretty_name?: string;
|
|
324
|
+
venue_name: string;
|
|
325
|
+
venue_type?: string;
|
|
326
|
+
company_id?: string;
|
|
327
|
+
resource_id?: string;
|
|
328
|
+
description?: string;
|
|
329
|
+
image?: string;
|
|
330
|
+
[key: string]: unknown;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Runtime configuration for the booking API.
|
|
335
|
+
* Passed as a prop to SchemaFormBuilder and forwarded to all API calls.
|
|
336
|
+
*/
|
|
337
|
+
interface AppConfig {
|
|
338
|
+
/** Bearer token sent as the `clienttoken` HTTP header on all API requests. */
|
|
339
|
+
blApiToken: string;
|
|
340
|
+
/** The booking company ID for this council tenant. */
|
|
341
|
+
company_id: string;
|
|
342
|
+
/** The customer/client name identifier for schema resolution. */
|
|
343
|
+
customer_name: string;
|
|
344
|
+
/** Base URL of the Bookinglab API, e.g. `https://api.bookinglab.co.uk`. */
|
|
345
|
+
apiBaseUrl: string;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* A string validation shorthand.
|
|
349
|
+
* - 'email' → standard email format
|
|
350
|
+
* - 'mobile' → UK mobile number
|
|
351
|
+
* - 'phone' → UK landline/contact number
|
|
352
|
+
* - 'contact' → alias for phone
|
|
353
|
+
* - 'length' → maxLength(255)
|
|
354
|
+
*/
|
|
355
|
+
type ValidationShorthand = 'email' | 'mobile' | 'phone' | 'contact' | 'length';
|
|
356
|
+
interface ValidationMinLength {
|
|
357
|
+
minLength: number;
|
|
358
|
+
}
|
|
359
|
+
interface ValidationMaxLength {
|
|
360
|
+
maxLength: number;
|
|
361
|
+
}
|
|
362
|
+
interface ValidationMinDate {
|
|
363
|
+
/** Minimum allowed date in DD-MM-YYYY format. */
|
|
364
|
+
minDate: string;
|
|
365
|
+
}
|
|
366
|
+
interface ValidationMaxDate {
|
|
367
|
+
/** Maximum allowed date expressed as number of days from today. */
|
|
368
|
+
maxDate: number;
|
|
369
|
+
}
|
|
370
|
+
type ValidationRule = ValidationShorthand | ValidationMinLength | ValidationMaxLength | ValidationMinDate | ValidationMaxDate;
|
|
371
|
+
/**
|
|
372
|
+
* A single condition clause used in custom rule types.
|
|
373
|
+
*/
|
|
374
|
+
interface ConditionClause {
|
|
375
|
+
/** The field name whose current value is evaluated. */
|
|
376
|
+
field: string;
|
|
377
|
+
/** The expected value to compare against. Use '*' as a wildcard (any non-empty value). */
|
|
378
|
+
value: string;
|
|
379
|
+
/**
|
|
380
|
+
* Comparison operator. Defaults to '==' if omitted.
|
|
381
|
+
* Numeric operators ('>', '<', '>=', '<=') cast both sides to Number before comparing.
|
|
382
|
+
*/
|
|
383
|
+
operator?: '==' | '!=' | '>' | '<' | '>=' | '<=';
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* The `show` object on a field defines its conditional visibility rules.
|
|
387
|
+
* Multiple rule types can coexist on a single field.
|
|
388
|
+
* The final visibility is: ANY rule returning true → field is visible.
|
|
389
|
+
*
|
|
390
|
+
* Rule types:
|
|
391
|
+
*
|
|
392
|
+
* - `[fieldName]: expectedValue` Simple equality rule. Field is visible when
|
|
393
|
+
* `formValues[fieldName] === expectedValue`.
|
|
394
|
+
* Use '*' as expectedValue to match any non-empty value.
|
|
395
|
+
*
|
|
396
|
+
* - `custom` Array of ConditionClause. ALL clauses must be true (AND).
|
|
397
|
+
*
|
|
398
|
+
* - `custom_multiple_condition` A single group of ConditionClause. ALL must be true (AND).
|
|
399
|
+
*
|
|
400
|
+
* - `custom_multiple_conditions` Array of ConditionClause groups. ANY group being fully
|
|
401
|
+
* true makes the rule pass (OR between groups, AND within).
|
|
402
|
+
*
|
|
403
|
+
* - `custom_or_condition` Array of ConditionClause. ANY single clause being true
|
|
404
|
+
* passes the rule (OR logic).
|
|
405
|
+
*
|
|
406
|
+
* - `custom_all_lookups_successful` No value needed. Passes only when every visible AWS lookup
|
|
407
|
+
* field on the current page has `lookupSuccess === true`.
|
|
408
|
+
*/
|
|
409
|
+
interface ShowRules {
|
|
410
|
+
/** Object format: { fieldName: "expression" } or array of ConditionClause. AND logic. */
|
|
411
|
+
custom?: ConditionClause[] | Record<string, string>;
|
|
412
|
+
/** Object format: { conditions: [{ field: value }] } or ConditionClause[]. AND logic. */
|
|
413
|
+
custom_multiple_condition?: ConditionClause[] | {
|
|
414
|
+
conditions: Record<string, string>[];
|
|
415
|
+
};
|
|
416
|
+
/** Object format: { groups: [{ conditions: [...] }] } or ConditionClause[][]. OR-of-AND. */
|
|
417
|
+
custom_multiple_conditions?: ConditionClause[][] | {
|
|
418
|
+
groups: {
|
|
419
|
+
conditions: Record<string, string>[];
|
|
420
|
+
}[];
|
|
421
|
+
};
|
|
422
|
+
custom_or_condition?: ConditionClause[];
|
|
423
|
+
/** Value is irrelevant — presence of this key activates the all-lookups check. */
|
|
424
|
+
custom_all_lookups_successful?: unknown;
|
|
425
|
+
/** Any other key is treated as a simple field-name → expected-value equality rule. */
|
|
426
|
+
[fieldName: string]: unknown;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Declarative data copying between fields, including across pages via sessionStorage.
|
|
430
|
+
* When this field is visible and the optional `answer` condition is met,
|
|
431
|
+
* each `from[i]` field value is written to `to[i]`.
|
|
432
|
+
*/
|
|
433
|
+
interface CopyDataConfig {
|
|
434
|
+
/** Source field names (same page or a previous page stored in sessionStorage). */
|
|
435
|
+
from: string[];
|
|
436
|
+
/** Destination field names, index-aligned with `from`. */
|
|
437
|
+
to: string[];
|
|
438
|
+
/**
|
|
439
|
+
* If present, only copy when this field's current value strictly equals `answer`.
|
|
440
|
+
* If absent, copy whenever this field has any non-empty value.
|
|
441
|
+
*/
|
|
442
|
+
answer?: string;
|
|
443
|
+
}
|
|
444
|
+
interface AwsLookupMatchEntry {
|
|
445
|
+
/**
|
|
446
|
+
* The form field name whose value provides the lookup value.
|
|
447
|
+
* The field whose `field` property matches the current field name is the primary reference.
|
|
448
|
+
*/
|
|
449
|
+
form_field: string;
|
|
450
|
+
/** The DynamoDB attribute name to match against (e.g. 'home_office', 'name'). */
|
|
451
|
+
dynamodb_field: string;
|
|
452
|
+
}
|
|
453
|
+
interface AwsLookupConfig {
|
|
454
|
+
/** DynamoDB table name (environment suffix appended server-side, e.g. '-staging'). */
|
|
455
|
+
aws_table: string;
|
|
456
|
+
/**
|
|
457
|
+
* Fields participating in the lookup validation.
|
|
458
|
+
* The entry whose form_field matches this field's `field` property is the primary reference.
|
|
459
|
+
* Any other entries are secondary validations (e.g. name cross-check).
|
|
460
|
+
*/
|
|
461
|
+
match: AwsLookupMatchEntry[];
|
|
462
|
+
/**
|
|
463
|
+
* If present, the form control value is set to `response.reference[store_response_field]`
|
|
464
|
+
* on a successful lookup instead of the default `response.reference.home_office`.
|
|
465
|
+
*/
|
|
466
|
+
store_response_field?: string;
|
|
467
|
+
}
|
|
468
|
+
interface RadioOption {
|
|
469
|
+
/** The raw value stored in the form control when this option is selected. */
|
|
470
|
+
value: string;
|
|
471
|
+
/** Human-readable label rendered alongside the radio input. */
|
|
472
|
+
title: string;
|
|
473
|
+
}
|
|
474
|
+
interface DropdownOption {
|
|
475
|
+
value: string;
|
|
476
|
+
title: string;
|
|
477
|
+
/**
|
|
478
|
+
* If false, this option is excluded from the rendered select.
|
|
479
|
+
* Allows server-side control of available options without schema changes.
|
|
480
|
+
*/
|
|
481
|
+
visible: boolean;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* The field definition exactly as returned by the API.
|
|
485
|
+
* Do not mutate this shape. Hydrate into SchemaField after fetching.
|
|
486
|
+
*/
|
|
487
|
+
interface RawSchemaField {
|
|
488
|
+
/** Unique identifier. Maps 1:1 to a form control name. */
|
|
489
|
+
field: string;
|
|
490
|
+
/** Display label. May contain `{fieldName}` interpolation tokens. */
|
|
491
|
+
title: string;
|
|
492
|
+
type: 'text' | 'number' | 'email' | 'date' | 'textarea' | 'radio' | 'dropdown' | 'checkbox' | 'heading' | 'submit';
|
|
493
|
+
/**
|
|
494
|
+
* The route page slug this field belongs to (e.g. 'booking-details').
|
|
495
|
+
* Fields not matching the current page are skipped entirely.
|
|
496
|
+
*/
|
|
497
|
+
page: string;
|
|
498
|
+
required?: boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Hint text displayed below the label.
|
|
501
|
+
* May contain HTML — render with dangerouslySetInnerHTML.
|
|
502
|
+
*/
|
|
503
|
+
helptext?: string;
|
|
504
|
+
/** Array of validation rules applied to this field's form control. */
|
|
505
|
+
validation?: ValidationRule[];
|
|
506
|
+
/**
|
|
507
|
+
* Conditional visibility rules. If absent or empty, the field is always visible.
|
|
508
|
+
* See ShowRules for the full rule type documentation.
|
|
509
|
+
*/
|
|
510
|
+
show?: ShowRules;
|
|
511
|
+
radio_options?: RadioOption[];
|
|
512
|
+
options?: DropdownOption[];
|
|
513
|
+
/**
|
|
514
|
+
* Determines the visual treatment for `type === 'heading'` fields.
|
|
515
|
+
* Absent → standard h3 heading.
|
|
516
|
+
*/
|
|
517
|
+
component_type?: 'govbook-information_box' | 'govbook-warning_box' | 'body';
|
|
518
|
+
/**
|
|
519
|
+
* Rich text body content for heading variants.
|
|
520
|
+
* Render with dangerouslySetInnerHTML.
|
|
521
|
+
*/
|
|
522
|
+
component_text?: string;
|
|
523
|
+
/** If true, renders a postcode input + "Find address" button and an address select. */
|
|
524
|
+
address_lookup?: boolean;
|
|
525
|
+
lookup?: AwsLookupConfig;
|
|
526
|
+
/** If true, renders an autocomplete venue search input with typeahead. */
|
|
527
|
+
resource_lookup?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Field name whose value is used to filter venue search results by `venue_type`.
|
|
530
|
+
* Only applies when `resource_lookup` is true.
|
|
531
|
+
*/
|
|
532
|
+
filter_by?: string;
|
|
533
|
+
/** When this field becomes visible, emit `onCompanySet` with this company ID. */
|
|
534
|
+
company_set?: string;
|
|
535
|
+
/** When this field becomes visible, emit `onServiceSet` with this service ID. */
|
|
536
|
+
service_set?: string;
|
|
537
|
+
/** When this field becomes visible, emit `onResourceSet` with this resource ID. */
|
|
538
|
+
resource_set?: string;
|
|
539
|
+
/** When this field becomes visible, emit `onStaffSet` with this staff ID. */
|
|
540
|
+
staff_set?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Duration value (in minutes as a string) to add to the booking when visible.
|
|
543
|
+
* Negated and re-emitted when the field becomes hidden.
|
|
544
|
+
*/
|
|
545
|
+
add_duration?: string;
|
|
546
|
+
/**
|
|
547
|
+
* Appointment type identifier. Stored in sessionStorage on the `services` page.
|
|
548
|
+
* Used on `booking-details` to filter fields by appointment type.
|
|
549
|
+
*/
|
|
550
|
+
appointment_type?: string;
|
|
551
|
+
copy_data?: CopyDataConfig;
|
|
552
|
+
/** When visible and non-empty, emit `onUpdateDatastore({ booker_first_name: value })`. */
|
|
553
|
+
booker_first_name?: boolean | 'true';
|
|
554
|
+
booker_last_name?: boolean | 'true';
|
|
555
|
+
booker_email?: boolean | 'true';
|
|
556
|
+
booker_phone?: boolean | 'true';
|
|
557
|
+
/**
|
|
558
|
+
* Extra item ID to fetch and emit when this field is visible and has a truthy value.
|
|
559
|
+
* Note: serialised as a hyphenated key in JSON — access as `field['extra-item']`.
|
|
560
|
+
*/
|
|
561
|
+
'extra-item'?: string;
|
|
562
|
+
/** Service ID override for this field's extra item lookup. */
|
|
563
|
+
'service-id'?: string;
|
|
564
|
+
/**
|
|
565
|
+
* Per-resource extra item overrides. Key is resource ID, value contains `extra-item`.
|
|
566
|
+
* Takes precedence over `extra-item` when a matching resource is selected.
|
|
567
|
+
*/
|
|
568
|
+
resource_ids?: Record<string, {
|
|
569
|
+
'extra-item': string;
|
|
570
|
+
}>;
|
|
571
|
+
/** If true and schema type is not 'extended', use legacy trigger/trigger_value logic. */
|
|
572
|
+
conditional?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Pipe-separated list of field names to watch.
|
|
575
|
+
* Only used when `conditional === true` on a legacy schema.
|
|
576
|
+
*/
|
|
577
|
+
trigger?: string;
|
|
578
|
+
/**
|
|
579
|
+
* Pipe-separated list of expected values corresponding to `trigger` fields.
|
|
580
|
+
* Each value can be `&`-joined for multi-part AND conditions within a single trigger.
|
|
581
|
+
* Supports prefixes: `<`, `>`, `!` for numeric/inequality comparisons.
|
|
582
|
+
* Use `*` as a wildcard to match any non-empty value.
|
|
583
|
+
*/
|
|
584
|
+
trigger_value?: string;
|
|
585
|
+
/**
|
|
586
|
+
* If true on a visible field, the form-level submit button becomes visible.
|
|
587
|
+
* Used to gate progression in the booking journey.
|
|
588
|
+
*/
|
|
589
|
+
continue?: boolean;
|
|
590
|
+
/** If true, field is unconditionally hidden regardless of visibility rules. */
|
|
591
|
+
hidden_field?: boolean;
|
|
592
|
+
/** Whether to prevent dates in the future (sets `max` to today on date inputs). */
|
|
593
|
+
hide_dates_in_future?: boolean;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Extends RawSchemaField with all mutable runtime state added during form
|
|
597
|
+
* initialisation and visibility evaluation.
|
|
598
|
+
* This is the type you work with throughout the component.
|
|
599
|
+
*/
|
|
600
|
+
interface SchemaField extends RawSchemaField {
|
|
601
|
+
/** Number of keys in the `show` object. 0 = always visible. */
|
|
602
|
+
rules_count: number;
|
|
603
|
+
/** Whether this field's `page` matches the currently active route page. */
|
|
604
|
+
show_on_this_page: boolean;
|
|
605
|
+
/** Set to true during init when `lookup.aws_table` is present. */
|
|
606
|
+
aws_lookup?: boolean;
|
|
607
|
+
/** Current computed visibility. Updated by refreshVisibility(). */
|
|
608
|
+
visible: boolean;
|
|
609
|
+
/** Alias for `visible` — kept for API compatibility with legacy schema paths. */
|
|
610
|
+
is_visible: boolean;
|
|
611
|
+
/**
|
|
612
|
+
* Resolved title after `{fieldName}` tokens have been interpolated.
|
|
613
|
+
* Falls back to `title` if not yet resolved.
|
|
614
|
+
*/
|
|
615
|
+
rendered_title?: string;
|
|
616
|
+
/** Prevents `add_duration` from being emitted more than once per visible lifecycle. */
|
|
617
|
+
duration_added?: boolean;
|
|
618
|
+
/** Runtime company ID stored when `company_set` side-effect fires. */
|
|
619
|
+
company_id?: string;
|
|
620
|
+
/** Runtime service ID stored when `service_set` side-effect fires. */
|
|
621
|
+
service_id?: string;
|
|
622
|
+
/** Runtime resource ID stored when `resource_set` side-effect fires. */
|
|
623
|
+
resource_id?: string;
|
|
624
|
+
addresses?: Array<{
|
|
625
|
+
address: {
|
|
626
|
+
ADDRESS: string;
|
|
627
|
+
};
|
|
628
|
+
}>;
|
|
629
|
+
addressLoading?: boolean;
|
|
630
|
+
badPostcode?: boolean;
|
|
631
|
+
selected_address?: string;
|
|
632
|
+
lookupSuccess?: boolean;
|
|
633
|
+
lookupError?: boolean;
|
|
634
|
+
lookupUsed?: boolean;
|
|
635
|
+
lookupLoading?: boolean;
|
|
636
|
+
lookupResponse?: {
|
|
637
|
+
name?: string;
|
|
638
|
+
home_office?: string;
|
|
639
|
+
[key: string]: unknown;
|
|
640
|
+
} | null;
|
|
641
|
+
lookupNameMismatch?: boolean;
|
|
642
|
+
/**
|
|
643
|
+
* Set to true on secondary match fields (e.g. name input) after a successful
|
|
644
|
+
* lookup. Causes the field wrapper to receive the `hidden-field` CSS class,
|
|
645
|
+
* hiding the input while the verified info display is shown instead.
|
|
646
|
+
*/
|
|
647
|
+
lookupValidated?: boolean;
|
|
648
|
+
searching?: boolean;
|
|
649
|
+
noResults?: boolean;
|
|
650
|
+
selected_resource?: VenueResult;
|
|
651
|
+
/** Display value of the currently selected venue (for read-only display). */
|
|
652
|
+
answer?: string;
|
|
653
|
+
}
|
|
654
|
+
/** Individual field error. */
|
|
655
|
+
interface FieldError {
|
|
656
|
+
fieldName: string;
|
|
657
|
+
errors: Record<string, unknown>;
|
|
658
|
+
}
|
|
659
|
+
/** Extra item entry tracked by the form. */
|
|
660
|
+
interface ExtraItemEntry {
|
|
661
|
+
field: string;
|
|
662
|
+
serviceId: string;
|
|
663
|
+
extraItemId: string;
|
|
664
|
+
qty: number;
|
|
665
|
+
}
|
|
666
|
+
/** Status object emitted via onFormStatus on every form value change. */
|
|
667
|
+
interface FormSchemaStatus {
|
|
668
|
+
/** True when all visible, required fields on the current page are valid. */
|
|
669
|
+
status: boolean;
|
|
670
|
+
/** Array of field error objects for any invalid controls. */
|
|
671
|
+
errors: FieldError[];
|
|
672
|
+
/** Snapshot of all current form control values keyed by field name. */
|
|
673
|
+
formData: Record<string, string> | undefined;
|
|
674
|
+
/**
|
|
675
|
+
* Extra items currently tracked by the form (may be empty during initial load).
|
|
676
|
+
* Populated by the extra-items system — see Prompt 8.
|
|
677
|
+
*/
|
|
678
|
+
extraItems: ExtraItemEntry[];
|
|
679
|
+
/**
|
|
680
|
+
* Present when a field with a `service_set` side-effect just changed value.
|
|
681
|
+
* The parent uses this to trigger a service selection in the booking datastore.
|
|
682
|
+
*/
|
|
683
|
+
setService?: string;
|
|
684
|
+
}
|
|
685
|
+
/** Payload emitted via onVenueSet. */
|
|
686
|
+
interface VenueSetPayload {
|
|
687
|
+
/** The selected venue object, or null when the selection is cleared. */
|
|
688
|
+
venue: VenueResult | null;
|
|
689
|
+
/** The field name this venue selection belongs to. */
|
|
690
|
+
field: string;
|
|
691
|
+
/** Present when a venue is selected and has an associated company. */
|
|
692
|
+
companyId?: string;
|
|
693
|
+
/** Present when a venue is selected and has an associated resource. */
|
|
694
|
+
resourceId?: string;
|
|
695
|
+
}
|
|
696
|
+
/** Payload emitted via onAwsLookupSet. */
|
|
697
|
+
interface AwsLookupSetPayload {
|
|
698
|
+
/** The field name the lookup was performed on. */
|
|
699
|
+
field: string;
|
|
700
|
+
/** The reference object returned on success, or null when cleared. */
|
|
701
|
+
reference: {
|
|
702
|
+
name?: string;
|
|
703
|
+
home_office?: string;
|
|
704
|
+
[key: string]: unknown;
|
|
705
|
+
} | null;
|
|
706
|
+
success: boolean;
|
|
707
|
+
}
|
|
708
|
+
/** Payload emitted via onUpdateDatastore. */
|
|
709
|
+
interface UpdateDatastorePayload {
|
|
710
|
+
type?: 'lookupResponse';
|
|
711
|
+
field?: string;
|
|
712
|
+
lookupResponse?: Record<string, unknown>;
|
|
713
|
+
[key: string]: unknown;
|
|
714
|
+
}
|
|
715
|
+
/** Payload emitted via onFormReady. */
|
|
716
|
+
interface FormReadyPayload {
|
|
717
|
+
form_id: string;
|
|
718
|
+
extra_items: ExtraItemEntry[];
|
|
719
|
+
}
|
|
720
|
+
/** Props for the SchemaFormBuilder component. */
|
|
721
|
+
interface SchemaFormBuilderProps {
|
|
722
|
+
/** The schema ID used to fetch the form definition from the API. */
|
|
723
|
+
formId: string;
|
|
724
|
+
/** Runtime API configuration. Forwarded to all API calls. */
|
|
725
|
+
appConfig: AppConfig;
|
|
726
|
+
/** The current route page slug (e.g. 'booking-details'). Only fields for this page are rendered. */
|
|
727
|
+
currentPage: string;
|
|
728
|
+
/** The booking company ID for venue searches and extra item lookups. */
|
|
729
|
+
companyId: string;
|
|
730
|
+
/**
|
|
731
|
+
* Initial field values to pre-populate the form with.
|
|
732
|
+
* Keys must match `field.field` names in the schema.
|
|
733
|
+
*/
|
|
734
|
+
formData?: Record<string, unknown>;
|
|
735
|
+
/**
|
|
736
|
+
* Whether to show the submit/continue button.
|
|
737
|
+
* The form also manages this internally based on `field.continue` visibility —
|
|
738
|
+
* this prop provides an external override for the initial render.
|
|
739
|
+
*/
|
|
740
|
+
showSubmit?: boolean;
|
|
741
|
+
/**
|
|
742
|
+
* When provided, the form watches this value. If it changes to a new
|
|
743
|
+
* formId string, the form tears down and re-initialises with the new schema.
|
|
744
|
+
*/
|
|
745
|
+
formUpdateId?: string;
|
|
746
|
+
/**
|
|
747
|
+
* When provided, the component uses this schema directly instead of
|
|
748
|
+
* fetching from the API. Useful for testing schema implementations locally.
|
|
749
|
+
* Must conform to the FormSchemaResponse shape.
|
|
750
|
+
*/
|
|
751
|
+
initialSchema?: FormSchemaResponse;
|
|
752
|
+
/** Fired when the submit button is clicked and the form is valid. */
|
|
753
|
+
onFormSubmit?: (data: Record<string, string>) => void;
|
|
754
|
+
/** Fired on every form value change with current validity and form data. */
|
|
755
|
+
onFormStatus?: (status: FormSchemaStatus) => void;
|
|
756
|
+
/** Fired on submit with the raw schema object (used for downstream schema introspection). */
|
|
757
|
+
onSchema?: (schema: Record<string, unknown>) => void;
|
|
758
|
+
/** Fired when a field with `company_set` becomes visible. */
|
|
759
|
+
onCompanySet?: (companyId: string) => void;
|
|
760
|
+
/** Fired when a field with `service_set` becomes visible. */
|
|
761
|
+
onServiceSet?: (serviceId: string) => void;
|
|
762
|
+
/** Fired when a field with `resource_set` becomes visible. */
|
|
763
|
+
onResourceSet?: (resourceId: string) => void;
|
|
764
|
+
/** Fired when a field with `staff_set` becomes visible. */
|
|
765
|
+
onStaffSet?: (staffId: string) => void;
|
|
766
|
+
/**
|
|
767
|
+
* Fired when a field with `add_duration` becomes visible (positive string value)
|
|
768
|
+
* or hidden (negated string value, e.g. '-30').
|
|
769
|
+
*/
|
|
770
|
+
onAddDuration?: (duration: string) => void;
|
|
771
|
+
/** Fired once after the form schema has been fetched and controls built. */
|
|
772
|
+
onFormReady?: (payload: FormReadyPayload) => void;
|
|
773
|
+
/** Fired when a booker field (name, email, phone) is populated. */
|
|
774
|
+
onUpdateDatastore?: (payload: UpdateDatastorePayload) => void;
|
|
775
|
+
/** Fired when an address is selected from the address lookup dropdown. */
|
|
776
|
+
onAddressSet?: (address: string) => void;
|
|
777
|
+
/** Fired when an AWS lookup succeeds, fails, or is cleared. */
|
|
778
|
+
onAwsLookupSet?: (payload: AwsLookupSetPayload) => void;
|
|
779
|
+
/** Fired when a new extra item is fetched and should be added to the booking. */
|
|
780
|
+
onExtraItemSet?: (payload: {
|
|
781
|
+
item_id: string;
|
|
782
|
+
item: ExtraItemProperties | null;
|
|
783
|
+
}) => void;
|
|
784
|
+
/** Fired when an existing extra item's quantity changes. */
|
|
785
|
+
onExtraItemChanged?: (payload: {
|
|
786
|
+
item_id: string;
|
|
787
|
+
item: ExtraItemEntry;
|
|
788
|
+
}) => void;
|
|
789
|
+
/** Fired when a venue is selected or cleared. */
|
|
790
|
+
onVenueSet?: (payload: VenueSetPayload) => void;
|
|
791
|
+
/** Fired when any async operation (address lookup, AWS lookup, extra item fetch) starts or ends. */
|
|
792
|
+
onProcessing?: (loading: boolean) => void;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Hydrates a raw API field into a SchemaField by setting all initial
|
|
796
|
+
* runtime state to its default values.
|
|
797
|
+
*/
|
|
798
|
+
declare function hydrateField(raw: RawSchemaField, currentPage: string): SchemaField;
|
|
799
|
+
|
|
304
800
|
interface QuestionOption {
|
|
305
801
|
id: number;
|
|
306
802
|
name: string;
|
|
@@ -317,7 +813,7 @@ interface QuestionSettings {
|
|
|
317
813
|
interface Question {
|
|
318
814
|
id: number;
|
|
319
815
|
name: string;
|
|
320
|
-
detail_type: 'heading' | 'text_field' | 'text_area' | 'select' | 'date' | 'number' | 'check';
|
|
816
|
+
detail_type: 'heading' | 'text_field' | 'text_area' | 'select' | 'radio' | 'date' | 'number' | 'check';
|
|
321
817
|
required?: boolean;
|
|
322
818
|
important?: boolean;
|
|
323
819
|
admin_only?: boolean;
|
|
@@ -351,6 +847,12 @@ interface BookingFormClassNames {
|
|
|
351
847
|
inputError?: string;
|
|
352
848
|
/** Checkbox input specifically */
|
|
353
849
|
checkbox?: string;
|
|
850
|
+
/** Radio input specifically */
|
|
851
|
+
radio?: string;
|
|
852
|
+
/** Radio group wrapper */
|
|
853
|
+
radioGroup?: string;
|
|
854
|
+
/** Radio option label */
|
|
855
|
+
radioLabel?: string;
|
|
354
856
|
/** Help text below fields */
|
|
355
857
|
helpText?: string;
|
|
356
858
|
/** Error message text */
|
|
@@ -362,6 +864,8 @@ interface BookingFormProps {
|
|
|
362
864
|
questions: Question[];
|
|
363
865
|
onSubmit: (values: FormValues) => void;
|
|
364
866
|
submitLabel?: string;
|
|
867
|
+
/** Whether the current user is an admin. When false (default), questions with admin_only=true are hidden. */
|
|
868
|
+
isAdmin?: boolean;
|
|
365
869
|
/** Class name for the form element */
|
|
366
870
|
className?: string;
|
|
367
871
|
/** @deprecated Use classNames.label instead */
|
|
@@ -391,7 +895,7 @@ interface BookingUIConfig {
|
|
|
391
895
|
* />
|
|
392
896
|
* ```
|
|
393
897
|
*/
|
|
394
|
-
declare function BookingForm({ questions, onSubmit, submitLabel, className, labelClassName, classNames: classNamesProp, }: BookingFormProps): react_jsx_runtime.JSX.Element;
|
|
898
|
+
declare function BookingForm({ questions, onSubmit, submitLabel, isAdmin, className, labelClassName, classNames: classNamesProp, }: BookingFormProps): react_jsx_runtime.JSX.Element;
|
|
395
899
|
|
|
396
900
|
/**
|
|
397
901
|
* A reusable, accessible registration form component.
|
|
@@ -464,6 +968,8 @@ declare const ContactDetailsForm: React.ForwardRefExoticComponent<ContactDetails
|
|
|
464
968
|
*/
|
|
465
969
|
declare const ResetPasswordForm: React.ForwardRefExoticComponent<ResetPasswordFormProps & React.RefAttributes<ResetPasswordFormRef>>;
|
|
466
970
|
|
|
971
|
+
declare function SchemaFormBuilder(props: SchemaFormBuilderProps): react_jsx_runtime.JSX.Element | null;
|
|
972
|
+
|
|
467
973
|
/**
|
|
468
974
|
* Validation helper functions for form fields
|
|
469
975
|
* Each validator returns an error message string if invalid, or null if valid
|
|
@@ -497,4 +1003,4 @@ declare function minLen(min: number): (value: string) => string | null;
|
|
|
497
1003
|
*/
|
|
498
1004
|
declare function compose(...validators: Array<(value: string) => string | null>): (value: string) => string | null;
|
|
499
1005
|
|
|
500
|
-
export { BookingForm, type BookingFormClassNames, type BookingFormProps, type BookingUIConfig, type ContactDetailsAnswerEntry, type ContactDetailsFieldSettings, ContactDetailsForm, type ContactDetailsFormClassNames, type ContactDetailsFormProps, type ContactDetailsFormRef, type ContactDetailsInitialValues, type ContactDetailsQuestionEntry, type ContactDetailsValues, type ContactFieldSettings, type FieldConfig, type FieldOption, type FormErrors, type FormValues, type Question, type QuestionOption, type QuestionSettings, type RegistrationFieldSettings, RegistrationForm, type RegistrationFormClassNames, type RegistrationFormErrors, type RegistrationFormProps, type RegistrationFormRef, type RegistrationFormValues, ResetPasswordForm, type ResetPasswordFormClassNames, type ResetPasswordFormProps, type ResetPasswordFormRef, type ResetPasswordFormValues, compose, email, minLen, phone, required, ukPostcode };
|
|
1006
|
+
export { type AppConfig, type AwsLookupConfig, type AwsLookupMatchEntry, type AwsLookupSetPayload, BookingForm, type BookingFormClassNames, type BookingFormProps, type BookingUIConfig, type ConditionClause, type ContactDetailsAnswerEntry, type ContactDetailsFieldSettings, ContactDetailsForm, type ContactDetailsFormClassNames, type ContactDetailsFormProps, type ContactDetailsFormRef, type ContactDetailsInitialValues, type ContactDetailsQuestionEntry, type ContactDetailsValues, type ContactFieldSettings, type CopyDataConfig, type DropdownOption, type ExtraItemEntry, type FieldConfig, type FieldError, type FieldOption, type FormErrors, type FormReadyPayload, type FormSchemaStatus, type FormValues, type Question, type QuestionOption, type QuestionSettings, type RadioOption, type RawSchemaField, type RegistrationFieldSettings, RegistrationForm, type RegistrationFormClassNames, type RegistrationFormErrors, type RegistrationFormProps, type RegistrationFormRef, type RegistrationFormValues, ResetPasswordForm, type ResetPasswordFormClassNames, type ResetPasswordFormProps, type ResetPasswordFormRef, type ResetPasswordFormValues, type SchemaField, SchemaFormBuilder, type SchemaFormBuilderProps, type ShowRules, type UpdateDatastorePayload, type ValidationMaxDate, type ValidationMaxLength, type ValidationMinDate, type ValidationMinLength, type ValidationRule, type ValidationShorthand, type VenueSetPayload, compose, email, hydrateField, minLen, phone, required, ukPostcode };
|