@brandlab-digital/site-next 3.19.1 → 4.0.0
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/blog.d.ts +18 -2
- package/dist/blog.d.ts.map +1 -1
- package/dist/blog.js +14 -2
- package/dist/blog.js.map +1 -1
- package/dist/instrumentation-client.d.ts +1 -1
- package/dist/instrumentation-client.js +1 -1
- package/dist/instrumentation-client.js.map +1 -1
- package/dist/navigation/index.d.ts +2 -3
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +2 -3
- package/dist/navigation/index.js.map +1 -1
- package/dist/next-config.d.ts +1 -17
- package/dist/next-config.d.ts.map +1 -1
- package/dist/next-config.js +2 -33
- package/dist/next-config.js.map +1 -1
- package/package.json +4 -33
- package/dist/ui-kit/brandlab-skin.d.ts +0 -112
- package/dist/ui-kit/brandlab-skin.d.ts.map +0 -1
- package/dist/ui-kit/brandlab-skin.js +0 -2
- package/dist/ui-kit/brandlab-skin.js.map +0 -1
- package/dist/ui-kit/form/copy.d.ts +0 -3
- package/dist/ui-kit/form/copy.d.ts.map +0 -1
- package/dist/ui-kit/form/copy.js +0 -5
- package/dist/ui-kit/form/copy.js.map +0 -1
- package/dist/ui-kit/form/dialog.d.ts +0 -24
- package/dist/ui-kit/form/dialog.d.ts.map +0 -1
- package/dist/ui-kit/form/dialog.js +0 -17
- package/dist/ui-kit/form/dialog.js.map +0 -1
- package/dist/ui-kit/form/field.d.ts +0 -30
- package/dist/ui-kit/form/field.d.ts.map +0 -1
- package/dist/ui-kit/form/field.js +0 -11
- package/dist/ui-kit/form/field.js.map +0 -1
- package/dist/ui-kit/form/index.d.ts +0 -7
- package/dist/ui-kit/form/index.d.ts.map +0 -1
- package/dist/ui-kit/form/index.js +0 -7
- package/dist/ui-kit/form/index.js.map +0 -1
- package/dist/ui-kit/form/photo-upload.d.ts +0 -40
- package/dist/ui-kit/form/photo-upload.d.ts.map +0 -1
- package/dist/ui-kit/form/photo-upload.js +0 -19
- package/dist/ui-kit/form/photo-upload.js.map +0 -1
- package/dist/ui-kit/form/quote-dialog.d.ts +0 -15
- package/dist/ui-kit/form/quote-dialog.d.ts.map +0 -1
- package/dist/ui-kit/form/quote-dialog.js +0 -68
- package/dist/ui-kit/form/quote-dialog.js.map +0 -1
- package/dist/ui-kit/form/quote-form.d.ts +0 -172
- package/dist/ui-kit/form/quote-form.d.ts.map +0 -1
- package/dist/ui-kit/form/quote-form.js +0 -238
- package/dist/ui-kit/form/quote-form.js.map +0 -1
- package/dist/ui-kit/form/thank-you.d.ts +0 -40
- package/dist/ui-kit/form/thank-you.d.ts.map +0 -1
- package/dist/ui-kit/form/thank-you.js +0 -36
- package/dist/ui-kit/form/thank-you.js.map +0 -1
- package/dist/ui-kit/icon-glyphs.d.ts +0 -41
- package/dist/ui-kit/icon-glyphs.d.ts.map +0 -1
- package/dist/ui-kit/icon-glyphs.js +0 -138
- package/dist/ui-kit/icon-glyphs.js.map +0 -1
- package/dist/ui-kit/icon-sprite.d.ts +0 -19
- package/dist/ui-kit/icon-sprite.d.ts.map +0 -1
- package/dist/ui-kit/icon-sprite.js +0 -44
- package/dist/ui-kit/icon-sprite.js.map +0 -1
- package/dist/ui-kit/icons.d.ts +0 -50
- package/dist/ui-kit/icons.d.ts.map +0 -1
- package/dist/ui-kit/icons.js +0 -55
- package/dist/ui-kit/icons.js.map +0 -1
- package/dist/ui-kit/prefetch.d.ts +0 -59
- package/dist/ui-kit/prefetch.d.ts.map +0 -1
- package/dist/ui-kit/prefetch.js +0 -63
- package/dist/ui-kit/prefetch.js.map +0 -1
- package/dist/ui-kit/primitives/badge.d.ts +0 -25
- package/dist/ui-kit/primitives/badge.d.ts.map +0 -1
- package/dist/ui-kit/primitives/badge.js +0 -21
- package/dist/ui-kit/primitives/badge.js.map +0 -1
- package/dist/ui-kit/primitives/breadcrumbs.d.ts +0 -27
- package/dist/ui-kit/primitives/breadcrumbs.d.ts.map +0 -1
- package/dist/ui-kit/primitives/breadcrumbs.js +0 -40
- package/dist/ui-kit/primitives/breadcrumbs.js.map +0 -1
- package/dist/ui-kit/primitives/button.d.ts +0 -32
- package/dist/ui-kit/primitives/button.d.ts.map +0 -1
- package/dist/ui-kit/primitives/button.js +0 -8
- package/dist/ui-kit/primitives/button.js.map +0 -1
- package/dist/ui-kit/primitives/card.d.ts +0 -40
- package/dist/ui-kit/primitives/card.d.ts.map +0 -1
- package/dist/ui-kit/primitives/card.js +0 -8
- package/dist/ui-kit/primitives/card.js.map +0 -1
- package/dist/ui-kit/primitives/index.d.ts +0 -16
- package/dist/ui-kit/primitives/index.d.ts.map +0 -1
- package/dist/ui-kit/primitives/index.js +0 -16
- package/dist/ui-kit/primitives/index.js.map +0 -1
- package/dist/ui-kit/primitives/layout.d.ts +0 -85
- package/dist/ui-kit/primitives/layout.d.ts.map +0 -1
- package/dist/ui-kit/primitives/layout.js +0 -52
- package/dist/ui-kit/primitives/layout.js.map +0 -1
- package/dist/ui-kit/primitives/links.d.ts +0 -74
- package/dist/ui-kit/primitives/links.d.ts.map +0 -1
- package/dist/ui-kit/primitives/links.js +0 -41
- package/dist/ui-kit/primitives/links.js.map +0 -1
- package/dist/ui-kit/primitives/lists.d.ts +0 -51
- package/dist/ui-kit/primitives/lists.d.ts.map +0 -1
- package/dist/ui-kit/primitives/lists.js +0 -34
- package/dist/ui-kit/primitives/lists.js.map +0 -1
- package/dist/ui-kit/primitives/media-frame.d.ts +0 -33
- package/dist/ui-kit/primitives/media-frame.d.ts.map +0 -1
- package/dist/ui-kit/primitives/media-frame.js +0 -61
- package/dist/ui-kit/primitives/media-frame.js.map +0 -1
- package/dist/ui-kit/primitives/media.d.ts +0 -40
- package/dist/ui-kit/primitives/media.d.ts.map +0 -1
- package/dist/ui-kit/primitives/media.js +0 -9
- package/dist/ui-kit/primitives/media.js.map +0 -1
- package/dist/ui-kit/primitives/quote-button.d.ts +0 -46
- package/dist/ui-kit/primitives/quote-button.d.ts.map +0 -1
- package/dist/ui-kit/primitives/quote-button.js +0 -38
- package/dist/ui-kit/primitives/quote-button.js.map +0 -1
- package/dist/ui-kit/primitives/stat.d.ts +0 -25
- package/dist/ui-kit/primitives/stat.d.ts.map +0 -1
- package/dist/ui-kit/primitives/stat.js +0 -7
- package/dist/ui-kit/primitives/stat.js.map +0 -1
- package/dist/ui-kit/repeated-slots.d.ts +0 -153
- package/dist/ui-kit/repeated-slots.d.ts.map +0 -1
- package/dist/ui-kit/repeated-slots.js +0 -100
- package/dist/ui-kit/repeated-slots.js.map +0 -1
- package/dist/ui-kit/sections/accordion.d.ts +0 -28
- package/dist/ui-kit/sections/accordion.d.ts.map +0 -1
- package/dist/ui-kit/sections/accordion.js +0 -14
- package/dist/ui-kit/sections/accordion.js.map +0 -1
- package/dist/ui-kit/sections/area-map.d.ts +0 -64
- package/dist/ui-kit/sections/area-map.d.ts.map +0 -1
- package/dist/ui-kit/sections/area-map.js +0 -146
- package/dist/ui-kit/sections/area-map.js.map +0 -1
- package/dist/ui-kit/sections/before-after.d.ts +0 -59
- package/dist/ui-kit/sections/before-after.d.ts.map +0 -1
- package/dist/ui-kit/sections/before-after.js +0 -42
- package/dist/ui-kit/sections/before-after.js.map +0 -1
- package/dist/ui-kit/sections/contact-block.d.ts +0 -77
- package/dist/ui-kit/sections/contact-block.d.ts.map +0 -1
- package/dist/ui-kit/sections/contact-block.js +0 -23
- package/dist/ui-kit/sections/contact-block.js.map +0 -1
- package/dist/ui-kit/sections/council-rules.d.ts +0 -64
- package/dist/ui-kit/sections/council-rules.d.ts.map +0 -1
- package/dist/ui-kit/sections/council-rules.js +0 -46
- package/dist/ui-kit/sections/council-rules.js.map +0 -1
- package/dist/ui-kit/sections/coverage.d.ts +0 -53
- package/dist/ui-kit/sections/coverage.d.ts.map +0 -1
- package/dist/ui-kit/sections/coverage.js +0 -57
- package/dist/ui-kit/sections/coverage.js.map +0 -1
- package/dist/ui-kit/sections/cta-band.d.ts +0 -67
- package/dist/ui-kit/sections/cta-band.d.ts.map +0 -1
- package/dist/ui-kit/sections/cta-band.js +0 -11
- package/dist/ui-kit/sections/cta-band.js.map +0 -1
- package/dist/ui-kit/sections/emergency-band.d.ts +0 -60
- package/dist/ui-kit/sections/emergency-band.d.ts.map +0 -1
- package/dist/ui-kit/sections/emergency-band.js +0 -43
- package/dist/ui-kit/sections/emergency-band.js.map +0 -1
- package/dist/ui-kit/sections/faqs.d.ts +0 -46
- package/dist/ui-kit/sections/faqs.d.ts.map +0 -1
- package/dist/ui-kit/sections/faqs.js +0 -39
- package/dist/ui-kit/sections/faqs.js.map +0 -1
- package/dist/ui-kit/sections/gallery.d.ts +0 -60
- package/dist/ui-kit/sections/gallery.d.ts.map +0 -1
- package/dist/ui-kit/sections/gallery.js +0 -39
- package/dist/ui-kit/sections/gallery.js.map +0 -1
- package/dist/ui-kit/sections/hero.d.ts +0 -168
- package/dist/ui-kit/sections/hero.d.ts.map +0 -1
- package/dist/ui-kit/sections/hero.js +0 -147
- package/dist/ui-kit/sections/hero.js.map +0 -1
- package/dist/ui-kit/sections/index.d.ts +0 -29
- package/dist/ui-kit/sections/index.d.ts.map +0 -1
- package/dist/ui-kit/sections/index.js +0 -29
- package/dist/ui-kit/sections/index.js.map +0 -1
- package/dist/ui-kit/sections/licences.d.ts +0 -95
- package/dist/ui-kit/sections/licences.d.ts.map +0 -1
- package/dist/ui-kit/sections/licences.js +0 -72
- package/dist/ui-kit/sections/licences.js.map +0 -1
- package/dist/ui-kit/sections/local-facts.d.ts +0 -107
- package/dist/ui-kit/sections/local-facts.d.ts.map +0 -1
- package/dist/ui-kit/sections/local-facts.js +0 -44
- package/dist/ui-kit/sections/local-facts.js.map +0 -1
- package/dist/ui-kit/sections/nearby-areas.d.ts +0 -50
- package/dist/ui-kit/sections/nearby-areas.d.ts.map +0 -1
- package/dist/ui-kit/sections/nearby-areas.js +0 -49
- package/dist/ui-kit/sections/nearby-areas.js.map +0 -1
- package/dist/ui-kit/sections/nearby-jobs.d.ts +0 -84
- package/dist/ui-kit/sections/nearby-jobs.d.ts.map +0 -1
- package/dist/ui-kit/sections/nearby-jobs.js +0 -69
- package/dist/ui-kit/sections/nearby-jobs.js.map +0 -1
- package/dist/ui-kit/sections/page-header.d.ts +0 -29
- package/dist/ui-kit/sections/page-header.d.ts.map +0 -1
- package/dist/ui-kit/sections/page-header.js +0 -9
- package/dist/ui-kit/sections/page-header.js.map +0 -1
- package/dist/ui-kit/sections/price-guide.d.ts +0 -59
- package/dist/ui-kit/sections/price-guide.d.ts.map +0 -1
- package/dist/ui-kit/sections/price-guide.js +0 -28
- package/dist/ui-kit/sections/price-guide.js.map +0 -1
- package/dist/ui-kit/sections/price-table.d.ts +0 -42
- package/dist/ui-kit/sections/price-table.d.ts.map +0 -1
- package/dist/ui-kit/sections/price-table.js +0 -29
- package/dist/ui-kit/sections/price-table.js.map +0 -1
- package/dist/ui-kit/sections/projects.d.ts +0 -79
- package/dist/ui-kit/sections/projects.d.ts.map +0 -1
- package/dist/ui-kit/sections/projects.js +0 -69
- package/dist/ui-kit/sections/projects.js.map +0 -1
- package/dist/ui-kit/sections/proof-strip.d.ts +0 -68
- package/dist/ui-kit/sections/proof-strip.d.ts.map +0 -1
- package/dist/ui-kit/sections/proof-strip.js +0 -27
- package/dist/ui-kit/sections/proof-strip.js.map +0 -1
- package/dist/ui-kit/sections/quote-checklist.d.ts +0 -43
- package/dist/ui-kit/sections/quote-checklist.d.ts.map +0 -1
- package/dist/ui-kit/sections/quote-checklist.js +0 -19
- package/dist/ui-kit/sections/quote-checklist.js.map +0 -1
- package/dist/ui-kit/sections/rating-chip.d.ts +0 -35
- package/dist/ui-kit/sections/rating-chip.d.ts.map +0 -1
- package/dist/ui-kit/sections/rating-chip.js +0 -21
- package/dist/ui-kit/sections/rating-chip.js.map +0 -1
- package/dist/ui-kit/sections/related-services.d.ts +0 -41
- package/dist/ui-kit/sections/related-services.d.ts.map +0 -1
- package/dist/ui-kit/sections/related-services.js +0 -52
- package/dist/ui-kit/sections/related-services.js.map +0 -1
- package/dist/ui-kit/sections/reviews-band.d.ts +0 -124
- package/dist/ui-kit/sections/reviews-band.d.ts.map +0 -1
- package/dist/ui-kit/sections/reviews-band.js +0 -115
- package/dist/ui-kit/sections/reviews-band.js.map +0 -1
- package/dist/ui-kit/sections/section-sequence.d.ts +0 -41
- package/dist/ui-kit/sections/section-sequence.d.ts.map +0 -1
- package/dist/ui-kit/sections/section-sequence.js +0 -36
- package/dist/ui-kit/sections/section-sequence.js.map +0 -1
- package/dist/ui-kit/sections/services-grid.d.ts +0 -82
- package/dist/ui-kit/sections/services-grid.d.ts.map +0 -1
- package/dist/ui-kit/sections/services-grid.js +0 -90
- package/dist/ui-kit/sections/services-grid.js.map +0 -1
- package/dist/ui-kit/sections/signature-section.d.ts +0 -42
- package/dist/ui-kit/sections/signature-section.d.ts.map +0 -1
- package/dist/ui-kit/sections/signature-section.js +0 -14
- package/dist/ui-kit/sections/signature-section.js.map +0 -1
- package/dist/ui-kit/sections/site-footer-columns.d.ts +0 -12
- package/dist/ui-kit/sections/site-footer-columns.d.ts.map +0 -1
- package/dist/ui-kit/sections/site-footer-columns.js +0 -63
- package/dist/ui-kit/sections/site-footer-columns.js.map +0 -1
- package/dist/ui-kit/sections/site-footer.d.ts +0 -66
- package/dist/ui-kit/sections/site-footer.d.ts.map +0 -1
- package/dist/ui-kit/sections/site-footer.js +0 -49
- package/dist/ui-kit/sections/site-footer.js.map +0 -1
- package/dist/ui-kit/sections/work-photos.d.ts +0 -15
- package/dist/ui-kit/sections/work-photos.d.ts.map +0 -1
- package/dist/ui-kit/sections/work-photos.js +0 -24
- package/dist/ui-kit/sections/work-photos.js.map +0 -1
- package/dist/ui-kit/shell/back-to-top-client.d.ts +0 -9
- package/dist/ui-kit/shell/back-to-top-client.d.ts.map +0 -1
- package/dist/ui-kit/shell/back-to-top-client.js +0 -8
- package/dist/ui-kit/shell/back-to-top-client.js.map +0 -1
- package/dist/ui-kit/shell/back-to-top.d.ts +0 -13
- package/dist/ui-kit/shell/back-to-top.d.ts.map +0 -1
- package/dist/ui-kit/shell/back-to-top.js +0 -14
- package/dist/ui-kit/shell/back-to-top.js.map +0 -1
- package/dist/ui-kit/shell/call-bar-client.d.ts +0 -8
- package/dist/ui-kit/shell/call-bar-client.d.ts.map +0 -1
- package/dist/ui-kit/shell/call-bar-client.js +0 -13
- package/dist/ui-kit/shell/call-bar-client.js.map +0 -1
- package/dist/ui-kit/shell/current-link.d.ts +0 -45
- package/dist/ui-kit/shell/current-link.d.ts.map +0 -1
- package/dist/ui-kit/shell/current-link.js +0 -54
- package/dist/ui-kit/shell/current-link.js.map +0 -1
- package/dist/ui-kit/shell/drawer-client.d.ts +0 -22
- package/dist/ui-kit/shell/drawer-client.d.ts.map +0 -1
- package/dist/ui-kit/shell/drawer-client.js +0 -70
- package/dist/ui-kit/shell/drawer-client.js.map +0 -1
- package/dist/ui-kit/shell/header-client.d.ts +0 -44
- package/dist/ui-kit/shell/header-client.d.ts.map +0 -1
- package/dist/ui-kit/shell/header-client.js +0 -59
- package/dist/ui-kit/shell/header-client.js.map +0 -1
- package/dist/ui-kit/shell/index.d.ts +0 -7
- package/dist/ui-kit/shell/index.d.ts.map +0 -1
- package/dist/ui-kit/shell/index.js +0 -7
- package/dist/ui-kit/shell/index.js.map +0 -1
- package/dist/ui-kit/shell/intent-prefetch.d.ts +0 -4
- package/dist/ui-kit/shell/intent-prefetch.d.ts.map +0 -1
- package/dist/ui-kit/shell/intent-prefetch.js +0 -62
- package/dist/ui-kit/shell/intent-prefetch.js.map +0 -1
- package/dist/ui-kit/shell/mobile-call-bar.d.ts +0 -25
- package/dist/ui-kit/shell/mobile-call-bar.d.ts.map +0 -1
- package/dist/ui-kit/shell/mobile-call-bar.js +0 -21
- package/dist/ui-kit/shell/mobile-call-bar.js.map +0 -1
- package/dist/ui-kit/shell/mobile-drawer.d.ts +0 -41
- package/dist/ui-kit/shell/mobile-drawer.d.ts.map +0 -1
- package/dist/ui-kit/shell/mobile-drawer.js +0 -41
- package/dist/ui-kit/shell/mobile-drawer.js.map +0 -1
- package/dist/ui-kit/shell/shell-context.d.ts +0 -3
- package/dist/ui-kit/shell/shell-context.d.ts.map +0 -1
- package/dist/ui-kit/shell/shell-context.js +0 -5
- package/dist/ui-kit/shell/shell-context.js.map +0 -1
- package/dist/ui-kit/shell/shell-quote.d.ts +0 -10
- package/dist/ui-kit/shell/shell-quote.d.ts.map +0 -1
- package/dist/ui-kit/shell/shell-quote.js +0 -13
- package/dist/ui-kit/shell/shell-quote.js.map +0 -1
- package/dist/ui-kit/shell/site-header.d.ts +0 -55
- package/dist/ui-kit/shell/site-header.d.ts.map +0 -1
- package/dist/ui-kit/shell/site-header.js +0 -35
- package/dist/ui-kit/shell/site-header.js.map +0 -1
- package/dist/ui-kit/shell/social-links.d.ts +0 -7
- package/dist/ui-kit/shell/social-links.d.ts.map +0 -1
- package/dist/ui-kit/shell/social-links.js +0 -12
- package/dist/ui-kit/shell/social-links.js.map +0 -1
- package/dist/ui-kit/shell/utility-bar.d.ts +0 -33
- package/dist/ui-kit/shell/utility-bar.d.ts.map +0 -1
- package/dist/ui-kit/shell/utility-bar.js +0 -15
- package/dist/ui-kit/shell/utility-bar.js.map +0 -1
- package/dist/ui-kit/skin-index.d.ts +0 -4
- package/dist/ui-kit/skin-index.d.ts.map +0 -1
- package/dist/ui-kit/skin-index.js +0 -3
- package/dist/ui-kit/skin-index.js.map +0 -1
- package/dist/ui-kit/skin.d.ts +0 -65
- package/dist/ui-kit/skin.d.ts.map +0 -1
- package/dist/ui-kit/skin.js +0 -60
- package/dist/ui-kit/skin.js.map +0 -1
- package/dist/ui-kit/structure.css +0 -2546
- package/dist/ui-kit/types.d.ts +0 -27
- package/dist/ui-kit/types.d.ts.map +0 -1
- package/dist/ui-kit/types.js +0 -6
- package/dist/ui-kit/types.js.map +0 -1
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `PhotoUpload`: the "Add photos" drop box over the shared photo preparation (`useBrandlabContactAttachments`). A
|
|
3
|
-
* real file input, visually hidden but focusable, so the keyboard opens the picker with Enter or Space; the whole
|
|
4
|
-
* box is its label and a drop target. `accept="image/*"` and never a `capture` attribute, so phones offer the
|
|
5
|
-
* library as well as the camera. The "0 of 5" counter is a `HeadlessStatus`, so each change is announced. Chosen
|
|
6
|
-
* photos show as thumbnails with a remove button each.
|
|
7
|
-
*/
|
|
8
|
-
import type { BrandlabContactAttachmentErrorReason, UseBrandlabContactAttachmentsResult } from '../../contact/attachments-client.js';
|
|
9
|
-
import type { RepeatedSlotOf } from '../repeated-slots.js';
|
|
10
|
-
import { type SkinEntry } from '../skin.js';
|
|
11
|
-
export type PhotoUploadSlot = 'field' | 'label' | 'drop' | 'dropIcon' | 'counter' | 'photos' | 'photo' | 'thumb' | 'remove' | 'error';
|
|
12
|
-
/** Rendered once per chosen photo: styled from the skin stylesheet, never by class (3.14.0). */
|
|
13
|
-
export type PhotoUploadRepeatedSlot = RepeatedSlotOf<'photoUpload'>;
|
|
14
|
-
export type PhotoUploadSkin = SkinEntry<PhotoUploadSlot, never, Record<never, never>, PhotoUploadRepeatedSlot>;
|
|
15
|
-
export interface PhotoUploadProps extends PhotoUploadSkin {
|
|
16
|
-
/** The file input's id. */
|
|
17
|
-
readonly id: string;
|
|
18
|
-
/** The drop box's label, for example "Add photos". */
|
|
19
|
-
readonly label: string;
|
|
20
|
-
/** The prepared photos, from `useBrandlabContactForm().attachments` or `useBrandlabContactAttachments()`. */
|
|
21
|
-
readonly attachments: UseBrandlabContactAttachmentsResult;
|
|
22
|
-
/** The counter, with `{count}` and `{max}`, for example "{count} of {max}". */
|
|
23
|
-
readonly counter: string;
|
|
24
|
-
/** Each remove button's name, with `{number}`, for example "Remove photo {number}". */
|
|
25
|
-
readonly removeLabel: string;
|
|
26
|
-
/** `image/*` by default; `image/*,application/pdf` where the contract takes PDFs. */
|
|
27
|
-
readonly accept?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The site's message for each reason a photo is refused (`count` may use `{max}`). Without them the shared photo
|
|
30
|
-
* preparation's own wording shows.
|
|
31
|
-
*/
|
|
32
|
-
readonly errorMessages?: Readonly<Record<BrandlabContactAttachmentErrorReason, string>> | undefined;
|
|
33
|
-
/** A form-level message, for example when photos are required. A refused photo's message wins. */
|
|
34
|
-
readonly error?: string | undefined;
|
|
35
|
-
readonly required?: boolean;
|
|
36
|
-
/** Locks the box while an enquiry is sending. */
|
|
37
|
-
readonly disabled?: boolean;
|
|
38
|
-
}
|
|
39
|
-
export declare function PhotoUpload({ id, label, attachments, counter, removeLabel, accept, errorMessages, error, required, disabled, classes, }: PhotoUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
-
//# sourceMappingURL=photo-upload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"photo-upload.d.ts","sourceRoot":"","sources":["../../../src/ui-kit/form/photo-upload.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,oCAAoC,EACpC,mCAAmC,EACpC,MAAM,qCAAqC,CAAA;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAG/D,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,OAAO,GACP,MAAM,GACN,UAAU,GACV,SAAS,GACT,QAAQ,GACR,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,CAAA;AACX,gGAAgG;AAChG,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAA;AACnE,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,uBAAuB,CAAC,CAAA;AAE9G,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,6GAA6G;IAC7G,QAAQ,CAAC,WAAW,EAAE,mCAAmC,CAAA;IACzD,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,uFAAuF;IACvF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAA;IACnG,kGAAkG;IAClG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,wBAAgB,WAAW,CAAC,EAC1B,EAAE,EACF,KAAK,EACL,WAAW,EACX,OAAO,EACP,WAAW,EACX,MAAkB,EAClB,aAAa,EACb,KAAK,EACL,QAAgB,EAChB,QAAgB,EAChB,OAAO,GACR,EAAE,gBAAgB,2CAgElB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { createElement as _createElement } from "react";
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { HeadlessStatus } from '../../ui.js';
|
|
5
|
-
import { Icon } from '../icons.js';
|
|
6
|
-
import { repeatedSlot, slot } from '../skin.js';
|
|
7
|
-
import { fillCopy } from './copy.js';
|
|
8
|
-
export function PhotoUpload({ id, label, attachments, counter, removeLabel, accept = 'image/*', errorMessages, error, required = false, disabled = false, classes, }) {
|
|
9
|
-
const counterId = `${id}-count`;
|
|
10
|
-
const errorId = `${id}-error`;
|
|
11
|
-
const reason = attachments.errorReason;
|
|
12
|
-
const refused = reason && errorMessages ? fillCopy(errorMessages[reason], { max: attachments.maxImages }) : attachments.errorMessage;
|
|
13
|
-
const message = refused ?? error;
|
|
14
|
-
const state = attachments.isProcessing ? 'busy' : attachments.isDragging ? 'dragging' : 'idle';
|
|
15
|
-
return (_jsxs("div", { "data-bl": "photo-upload", ...slot(classes, 'field'), children: [_jsxs("div", { ...slot(classes, 'drop'), "data-state": state, "data-disabled": disabled ? 'true' : undefined, onDragOver: disabled ? undefined : attachments.handleDragOver, onDragLeave: disabled ? undefined : attachments.handleDragLeave, onDrop: disabled ? undefined : (event) => void attachments.handleDrop(event), children: [_jsx("input", { id: id, type: "file", accept: accept, multiple: true, disabled: disabled, "aria-required": required ? true : undefined, "aria-invalid": message ? true : undefined, "aria-describedby": [counterId, message ? errorId : undefined].filter(Boolean).join(' '), "data-bl-visually-hidden": "", onChange: (event) => void attachments.handleImageChange(event) }), _jsxs("label", { ...slot(classes, 'label'), htmlFor: id, children: [_jsx("span", { ...slot(classes, 'dropIcon'), children: _jsx(Icon, { name: "camera" }) }), _jsx("span", { children: label })] }), _jsx(HeadlessStatus, { ...slot(classes, 'counter'), id: counterId, children: fillCopy(counter, { count: attachments.images.length, max: attachments.maxImages }) })] }), attachments.images.length > 0 ? (_jsx("ul", { ...slot(classes, 'photos'), children: attachments.images.map((image, index) => (_createElement("li", { ...repeatedSlot('photo'), key: image.preview },
|
|
16
|
-
_jsx("img", { ...repeatedSlot('thumb'), src: image.preview, alt: "", width: 64, height: 64 }),
|
|
17
|
-
_jsxs("button", { ...repeatedSlot('remove'), type: "button", disabled: disabled, onClick: () => attachments.removeImage(index), children: [_jsx(Icon, { name: "close" }), _jsx("span", { "data-bl-visually-hidden": "", children: fillCopy(removeLabel, { number: index + 1 }) })] })))) })) : null, message ? (_jsx("div", { ...slot(classes, 'error'), id: errorId, role: "alert", children: message })) : null] }));
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=photo-upload.js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M,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,CAAC,GACrE,IACb,EACL,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,gBAAQ,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,YAC5B,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CACxC,0BAAQ,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO;oBAC/C,iBAAS,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAC,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAI;oBACpF,qBACM,YAAY,CAAC,QAAQ,CAAC,EAC1B,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,aAE7C,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,EACrB,0CAA8B,EAAE,YAAE,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,GAAQ,IAC/E,CACN,CACN,CAAC,GACC,CACN,CAAC,CAAC,CAAC,IAAI,EACP,OAAO,CAAC,CAAC,CAAC,CACT,iBAAS,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAC,OAAO,YACvD,OAAO,GACJ,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\n/**\n * `PhotoUpload`: the \"Add photos\" drop box over the shared photo preparation (`useBrandlabContactAttachments`). A\n * real file input, visually hidden but focusable, so the keyboard opens the picker with Enter or Space; the whole\n * box is its label and a drop target. `accept=\"image/*\"` and never a `capture` attribute, so phones offer the\n * library as well as the camera. The \"0 of 5\" counter is a `HeadlessStatus`, so each change is announced. Chosen\n * photos show as thumbnails with a remove button each.\n */\nimport type {\n BrandlabContactAttachmentErrorReason,\n UseBrandlabContactAttachmentsResult,\n} from '../../contact/attachments-client.js'\nimport { HeadlessStatus } from '../../ui.js'\nimport { Icon } from '../icons.js'\nimport type { RepeatedSlotOf } from '../repeated-slots.js'\nimport { repeatedSlot, slot, type SkinEntry } from '../skin.js'\nimport { fillCopy } from './copy.js'\n\nexport type PhotoUploadSlot =\n | 'field'\n | 'label'\n | 'drop'\n | 'dropIcon'\n | 'counter'\n | 'photos'\n | 'photo'\n | 'thumb'\n | 'remove'\n | 'error'\n/** Rendered once per chosen photo: styled from the skin stylesheet, never by class (3.14.0). */\nexport type PhotoUploadRepeatedSlot = RepeatedSlotOf<'photoUpload'>\nexport type PhotoUploadSkin = SkinEntry<PhotoUploadSlot, never, Record<never, never>, PhotoUploadRepeatedSlot>\n\nexport interface PhotoUploadProps extends PhotoUploadSkin {\n /** The file input's id. */\n readonly id: string\n /** The drop box's label, for example \"Add photos\". */\n readonly label: string\n /** The prepared photos, from `useBrandlabContactForm().attachments` or `useBrandlabContactAttachments()`. */\n readonly attachments: UseBrandlabContactAttachmentsResult\n /** The counter, with `{count}` and `{max}`, for example \"{count} of {max}\". */\n readonly counter: string\n /** Each remove button's name, with `{number}`, for example \"Remove photo {number}\". */\n readonly removeLabel: string\n /** `image/*` by default; `image/*,application/pdf` where the contract takes PDFs. */\n readonly accept?: string\n /**\n * The site's message for each reason a photo is refused (`count` may use `{max}`). Without them the shared photo\n * preparation's own wording shows.\n */\n readonly errorMessages?: Readonly<Record<BrandlabContactAttachmentErrorReason, string>> | undefined\n /** A form-level message, for example when photos are required. A refused photo's message wins. */\n readonly error?: string | undefined\n readonly required?: boolean\n /** Locks the box while an enquiry is sending. */\n readonly disabled?: boolean\n}\n\nexport function PhotoUpload({\n id,\n label,\n attachments,\n counter,\n removeLabel,\n accept = 'image/*',\n errorMessages,\n error,\n required = false,\n disabled = false,\n classes,\n}: PhotoUploadProps) {\n const counterId = `${id}-count`\n const errorId = `${id}-error`\n const reason = attachments.errorReason\n const refused = reason && errorMessages ? fillCopy(errorMessages[reason], { max: attachments.maxImages }) : attachments.errorMessage\n const message = refused ?? error\n const state = attachments.isProcessing ? 'busy' : attachments.isDragging ? 'dragging' : 'idle'\n return (\n <div data-bl=\"photo-upload\" {...slot(classes, 'field')}>\n <div\n {...slot(classes, 'drop')}\n data-state={state}\n data-disabled={disabled ? 'true' : undefined}\n onDragOver={disabled ? undefined : attachments.handleDragOver}\n onDragLeave={disabled ? undefined : attachments.handleDragLeave}\n onDrop={disabled ? undefined : (event) => void attachments.handleDrop(event)}\n >\n <input\n id={id}\n type=\"file\"\n accept={accept}\n multiple\n disabled={disabled}\n aria-required={required ? true : undefined}\n aria-invalid={message ? true : undefined}\n aria-describedby={[counterId, message ? errorId : undefined].filter(Boolean).join(' ')}\n data-bl-visually-hidden=\"\"\n onChange={(event) => void attachments.handleImageChange(event)}\n />\n <label {...slot(classes, 'label')} htmlFor={id}>\n <span {...slot(classes, 'dropIcon')}>\n <Icon name=\"camera\" />\n </span>\n <span>{label}</span>\n </label>\n <HeadlessStatus {...slot(classes, 'counter')} id={counterId}>\n {fillCopy(counter, { count: attachments.images.length, max: attachments.maxImages })}\n </HeadlessStatus>\n </div>\n {attachments.images.length > 0 ? (\n <ul {...slot(classes, 'photos')}>\n {attachments.images.map((image, index) => (\n <li {...repeatedSlot('photo')} key={image.preview}>\n <img {...repeatedSlot('thumb')} src={image.preview} alt=\"\" width={64} height={64} />\n <button\n {...repeatedSlot('remove')}\n type=\"button\"\n disabled={disabled}\n onClick={() => attachments.removeImage(index)}\n >\n <Icon name=\"close\" />\n <span data-bl-visually-hidden=\"\">{fillCopy(removeLabel, { number: index + 1 })}</span>\n </button>\n </li>\n ))}\n </ul>\n ) : null}\n {message ? (\n <div {...slot(classes, 'error')} id={errorId} role=\"alert\">\n {message}\n </div>\n ) : null}\n </div>\n )\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type DialogSkin } from './dialog.js';
|
|
3
|
-
export type QuoteDialogSkin = DialogSkin;
|
|
4
|
-
export interface QuoteDialogProps extends QuoteDialogSkin {
|
|
5
|
-
/** The dialog's H2, for example "Get a free quote". */
|
|
6
|
-
readonly title: string;
|
|
7
|
-
/** The close button's accessible name, for example "Close". */
|
|
8
|
-
readonly closeLabel: string;
|
|
9
|
-
/** The dialog's id (default `quote-dialog-panel`; the form inside is `quote-dialog`). */
|
|
10
|
-
readonly id?: string;
|
|
11
|
-
/** The form, rendered once the dialog first opens. */
|
|
12
|
-
readonly children: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
export declare function QuoteDialog({ title, closeLabel, id, classes, children }: QuoteDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
//# sourceMappingURL=quote-dialog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote-dialog.d.ts","sourceRoot":"","sources":["../../../src/ui-kit/form/quote-dialog.tsx"],"names":[],"mappings":"AAWA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAA;AAExC,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,yFAAyF;IACzF,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AA0BD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAyB,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAwChH"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
/**
|
|
4
|
-
* `QuoteDialog`: the quote form in a modal `Dialog`, opened by any `QuoteButton` (`[data-bl="quote-button"]`) on the
|
|
5
|
-
* page through one delegated click listener while the dialog is mounted. On the page the button links to (the form's
|
|
6
|
-
* own page, for example `/contact`) the link keeps its default and scrolls to the form. Without scripts every button
|
|
7
|
-
* stays a plain link to the form. The form mounts on the first open and stays mounted, so typed values survive
|
|
8
|
-
* closing and reopening; focus returns to the button that opened it. A client navigation (the consent link, for
|
|
9
|
-
* example) closes it.
|
|
10
|
-
*/
|
|
11
|
-
import { usePathname } from 'next/navigation';
|
|
12
|
-
import { useEffect, useRef, useState } from 'react';
|
|
13
|
-
import { Dialog } from './dialog.js';
|
|
14
|
-
function samePath(left, right) {
|
|
15
|
-
const trim = (path) => path.replace(/\/+$/, '') || '/';
|
|
16
|
-
return trim(left) === trim(right);
|
|
17
|
-
}
|
|
18
|
-
/** The quote button a click landed on, when the click should open the dialog. */
|
|
19
|
-
function quoteButtonFor(event) {
|
|
20
|
-
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
const target = event.target instanceof Element ? event.target.closest('a[data-bl="quote-button"]') : null;
|
|
24
|
-
if (!(target instanceof HTMLAnchorElement) || (target.target && target.target !== '_self'))
|
|
25
|
-
return undefined;
|
|
26
|
-
let url;
|
|
27
|
-
try {
|
|
28
|
-
url = new URL(target.href, window.location.href);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
if (url.origin !== window.location.origin)
|
|
34
|
-
return undefined;
|
|
35
|
-
// On the form's own page the link scrolls to the form instead.
|
|
36
|
-
if (samePath(url.pathname, window.location.pathname))
|
|
37
|
-
return undefined;
|
|
38
|
-
return target;
|
|
39
|
-
}
|
|
40
|
-
export function QuoteDialog({ title, closeLabel, id = 'quote-dialog-panel', classes, children }) {
|
|
41
|
-
const [open, setOpen] = useState(false);
|
|
42
|
-
const [mounted, setMounted] = useState(false);
|
|
43
|
-
const returnFocusRef = useRef(null);
|
|
44
|
-
const pathname = usePathname();
|
|
45
|
-
const shownPath = useRef(pathname);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (shownPath.current === pathname)
|
|
48
|
-
return;
|
|
49
|
-
shownPath.current = pathname;
|
|
50
|
-
setOpen(false);
|
|
51
|
-
}, [pathname]);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
// Capture phase: decided before a framework link handler starts a client navigation.
|
|
54
|
-
const onClick = (event) => {
|
|
55
|
-
const button = quoteButtonFor(event);
|
|
56
|
-
if (!button)
|
|
57
|
-
return;
|
|
58
|
-
event.preventDefault();
|
|
59
|
-
returnFocusRef.current = button;
|
|
60
|
-
setMounted(true);
|
|
61
|
-
setOpen(true);
|
|
62
|
-
};
|
|
63
|
-
document.addEventListener('click', onClick, true);
|
|
64
|
-
return () => document.removeEventListener('click', onClick, true);
|
|
65
|
-
}, []);
|
|
66
|
-
return (_jsx(Dialog, { id: id, open: open, onClose: () => setOpen(false), title: title, closeLabel: closeLabel, returnFocusRef: returnFocusRef, classes: classes, children: mounted ? children : null }));
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=quote-dialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote-dialog.js","sourceRoot":"","sources":["../../../src/ui-kit/form/quote-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QA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AC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;IACnE,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,KAAC,MAAM,IACL,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,YAEf,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GACnB,CACV,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\n/**\n * `QuoteDialog`: the quote form in a modal `Dialog`, opened by any `QuoteButton` (`[data-bl=\"quote-button\"]`) on the\n * page through one delegated click listener while the dialog is mounted. On the page the button links to (the form's\n * own page, for example `/contact`) the link keeps its default and scrolls to the form. Without scripts every button\n * stays a plain link to the form. The form mounts on the first open and stays mounted, so typed values survive\n * closing and reopening; focus returns to the button that opened it. A client navigation (the consent link, for\n * example) closes it.\n */\nimport { usePathname } from 'next/navigation'\nimport { useEffect, useRef, useState, type ReactNode } from 'react'\nimport { Dialog, type DialogSkin } from './dialog.js'\n\nexport type QuoteDialogSkin = DialogSkin\n\nexport interface QuoteDialogProps extends QuoteDialogSkin {\n /** The dialog's H2, for example \"Get a free quote\". */\n readonly title: string\n /** The close button's accessible name, for example \"Close\". */\n readonly closeLabel: string\n /** The dialog's id (default `quote-dialog-panel`; the form inside is `quote-dialog`). */\n readonly id?: string\n /** The form, rendered once the dialog first opens. */\n readonly children: ReactNode\n}\n\nfunction samePath(left: string, right: string) {\n const trim = (path: string) => path.replace(/\\/+$/, '') || '/'\n return trim(left) === trim(right)\n}\n\n/** The quote button a click landed on, when the click should open the dialog. */\nfunction quoteButtonFor(event: MouseEvent): HTMLAnchorElement | undefined {\n if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return undefined\n }\n const target = event.target instanceof Element ? event.target.closest('a[data-bl=\"quote-button\"]') : null\n if (!(target instanceof HTMLAnchorElement) || (target.target && target.target !== '_self')) return undefined\n let url: URL\n try {\n url = new URL(target.href, window.location.href)\n } catch {\n return undefined\n }\n if (url.origin !== window.location.origin) return undefined\n // On the form's own page the link scrolls to the form instead.\n if (samePath(url.pathname, window.location.pathname)) return undefined\n return target\n}\n\nexport function QuoteDialog({ title, closeLabel, id = 'quote-dialog-panel', classes, children }: QuoteDialogProps) {\n const [open, setOpen] = useState(false)\n const [mounted, setMounted] = useState(false)\n const returnFocusRef = useRef<HTMLElement | null>(null)\n const pathname = usePathname()\n const shownPath = useRef(pathname)\n\n useEffect(() => {\n if (shownPath.current === pathname) return\n shownPath.current = pathname\n setOpen(false)\n }, [pathname])\n\n useEffect(() => {\n // Capture phase: decided before a framework link handler starts a client navigation.\n const onClick = (event: MouseEvent) => {\n const button = quoteButtonFor(event)\n if (!button) return\n event.preventDefault()\n returnFocusRef.current = button\n setMounted(true)\n setOpen(true)\n }\n document.addEventListener('click', onClick, true)\n return () => document.removeEventListener('click', onClick, true)\n }, [])\n\n return (\n <Dialog\n id={id}\n open={open}\n onClose={() => setOpen(false)}\n title={title}\n closeLabel={closeLabel}\n returnFocusRef={returnFocusRef}\n classes={classes}\n >\n {mounted ? children : null}\n </Dialog>\n )\n}\n"]}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `QuoteForm`: the one enquiry form for the hero, the quote dialog, the contact page and cost guides, on the shared
|
|
3
|
-
* contact runtime (`useBrandlabContactForm`, `POST /api/contact`, photo preparation, idempotent retries).
|
|
4
|
-
*
|
|
5
|
-
* Locked layout (F8): Name · Suburb; Phone · Email, both required; the message ("How can we help?"), 5 rows; the
|
|
6
|
-
* "Add photos" drop box with its "0 of 5" counter; the button; then one consent line linking the privacy policy. One
|
|
7
|
-
* column below 640 px. No job select, no "(required)", no helper or reassurance lines: every label and message is
|
|
8
|
-
* the site's copy. Errors appear only after a submit attempt, as a summary plus a message under each field; every
|
|
9
|
-
* typed value and chosen photo is kept on any error. The button stays disabled until the page has hydrated and is
|
|
10
|
-
* locked with a busy label while photos are prepared or the enquiry sends. An accepted enquiry sends one
|
|
11
|
-
* `contact_form` (with `has_photos`) and opens the thank-you page once Google's tag can send it (3.18.0). A submit the
|
|
12
|
-
* form's own checks stop sends `lead_form_error` (stage `validation`, the first failing field).
|
|
13
|
-
*
|
|
14
|
-
* `contract` and `analytics` can't cross from a server component, so a site binds them once with `createQuoteForm`
|
|
15
|
-
* in its own `'use client'` file and renders the bound `QuoteForm` and `QuoteDialog` from its pages.
|
|
16
|
-
*/
|
|
17
|
-
import { type BrandlabContactContract, type ContactAttachmentPolicy } from '@brandlab-digital/site-core/contact';
|
|
18
|
-
import { type JSX } from 'react';
|
|
19
|
-
import type { BrandlabAnalytics } from '../../analytics.js';
|
|
20
|
-
import type { BrandlabContactAttachmentErrorReason, UseBrandlabContactAttachmentsOptions } from '../../contact/attachments-client.js';
|
|
21
|
-
import type { RepeatedSlotOf } from '../repeated-slots.js';
|
|
22
|
-
import { type SkinEntry } from '../skin.js';
|
|
23
|
-
import { type QuoteDialogSkin } from './quote-dialog.js';
|
|
24
|
-
export declare const QUOTE_FORM_VARIANTS: readonly ["card", "plain", "inline"];
|
|
25
|
-
export type QuoteFormVariant = (typeof QUOTE_FORM_VARIANTS)[number];
|
|
26
|
-
/** The form's id and its lead diagnostics' `form_id`, one per placement. */
|
|
27
|
-
export declare const QUOTE_FORM_PLACEMENTS: readonly ["quote-hero", "quote-dialog", "contact", "guide"];
|
|
28
|
-
export type QuoteFormPlacement = (typeof QUOTE_FORM_PLACEMENTS)[number];
|
|
29
|
-
/** The variant each placement takes unless the skin names one: the hero aside, the dialog and contact page, a guide. */
|
|
30
|
-
export declare const QUOTE_FORM_PLACEMENT_VARIANTS: Readonly<Record<QuoteFormPlacement, QuoteFormVariant>>;
|
|
31
|
-
export type QuoteFormSlot = 'root' | 'row' | 'field' | 'label' | 'input' | 'textarea' | 'drop' | 'dropIcon' | 'counter' | 'photos' | 'photo' | 'thumb' | 'remove' | 'submit' | 'consent' | 'errorSummary' | 'error' | 'status';
|
|
32
|
-
/** Labels always sit above their fields; density sets the spacing. */
|
|
33
|
-
export interface QuoteFormLayout {
|
|
34
|
-
readonly density?: 'comfortable' | 'compact';
|
|
35
|
-
}
|
|
36
|
-
/** The photo boxes, rendered once per chosen photo: styled from the skin stylesheet, never by class (3.14.0). */
|
|
37
|
-
export type QuoteFormRepeatedSlot = RepeatedSlotOf<'quoteForm'>;
|
|
38
|
-
export type QuoteFormSkin = SkinEntry<QuoteFormSlot, QuoteFormVariant, QuoteFormLayout, QuoteFormRepeatedSlot>;
|
|
39
|
-
/** Every visible phrase of the form, in the site's Australian English. */
|
|
40
|
-
export interface QuoteFormCopy {
|
|
41
|
-
readonly labels: {
|
|
42
|
-
readonly name: string;
|
|
43
|
-
readonly suburb: string;
|
|
44
|
-
readonly phone: string;
|
|
45
|
-
readonly email: string;
|
|
46
|
-
/** For example "How can we help?". */
|
|
47
|
-
readonly message: string;
|
|
48
|
-
/** For example "Add photos". */
|
|
49
|
-
readonly photos: string;
|
|
50
|
-
};
|
|
51
|
-
/** The message placeholder, for example "Tell us about your project". */
|
|
52
|
-
readonly messagePlaceholder: string;
|
|
53
|
-
/** The site's recorded button label, for example "Get my free quote". */
|
|
54
|
-
readonly submit: string;
|
|
55
|
-
/** Busy labels: "Sending…", "Sending photos…" and "Preparing photos…". */
|
|
56
|
-
readonly sending: string;
|
|
57
|
-
readonly sendingPhotos: string;
|
|
58
|
-
readonly preparingPhotos: string;
|
|
59
|
-
/** The photo counter with `{count}` and `{max}`, for example "{count} of {max}". */
|
|
60
|
-
readonly photoCount: string;
|
|
61
|
-
/** Each remove button's name with `{number}`, for example "Remove photo {number}". */
|
|
62
|
-
readonly removePhoto: string;
|
|
63
|
-
/** The one consent line: the sentence, the words in it that link, and the privacy policy's path. */
|
|
64
|
-
readonly consent: {
|
|
65
|
-
readonly sentence: string;
|
|
66
|
-
readonly linkText: string;
|
|
67
|
-
readonly href: string;
|
|
68
|
-
};
|
|
69
|
-
/** The error summary's heading, for example "Please check these details". */
|
|
70
|
-
readonly errorSummary: string;
|
|
71
|
-
/** A message under each field after a submit attempt. `photos` is needed only when photos are required. */
|
|
72
|
-
readonly errors: {
|
|
73
|
-
readonly name: string;
|
|
74
|
-
readonly suburb: string;
|
|
75
|
-
readonly phone: string;
|
|
76
|
-
readonly phoneFormat: string;
|
|
77
|
-
readonly email: string;
|
|
78
|
-
readonly emailFormat: string;
|
|
79
|
-
readonly message: string;
|
|
80
|
-
readonly photos?: string;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Why a chosen photo was refused: not an image type, too large, all photos together too large, more than the
|
|
84
|
-
* limit (`{max}` allowed), or it couldn't be prepared (an iPhone photo that wouldn't convert). Needed when the
|
|
85
|
-
* contract takes photos.
|
|
86
|
-
*/
|
|
87
|
-
readonly photoErrors?: Readonly<Record<BrandlabContactAttachmentErrorReason, string>>;
|
|
88
|
-
/** Shown when sending fails: the photos were refused, or anything else (say how to call instead). */
|
|
89
|
-
readonly failed: {
|
|
90
|
-
readonly attachment: string;
|
|
91
|
-
readonly general: string;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export interface QuoteFormProps extends QuoteFormSkin {
|
|
95
|
-
readonly formId: QuoteFormPlacement;
|
|
96
|
-
/** The contact contract from src/config/contact.ts. */
|
|
97
|
-
readonly contract: BrandlabContactContract;
|
|
98
|
-
/** The site's defineBrandlabAnalytics binding. */
|
|
99
|
-
readonly analytics?: BrandlabAnalytics | undefined;
|
|
100
|
-
/** Photo limits; the contract's attachment mode decides the default. */
|
|
101
|
-
readonly attachmentPolicy?: ContactAttachmentPolicy | undefined;
|
|
102
|
-
/** The thank-you page opened after an accepted enquiry, for example `/thank-you`. */
|
|
103
|
-
readonly redirectTo: string;
|
|
104
|
-
readonly copy: QuoteFormCopy;
|
|
105
|
-
/** The enquiry email's page row, for example "Contact". */
|
|
106
|
-
readonly pageLabel?: string | undefined;
|
|
107
|
-
/** The runtime's honeypot field (default `website`). */
|
|
108
|
-
readonly honeypotField?: string | undefined;
|
|
109
|
-
/** The contact endpoint (default `/api/contact`). */
|
|
110
|
-
readonly contactEndpoint?: string | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Client navigation to the thank-you page, for example `router.push`. By default a full page load once Google's tag
|
|
113
|
-
* has sent the enquiry's hits (`navigateAfterGoogleTag`, 3.18.0; at most 8 s).
|
|
114
|
-
*/
|
|
115
|
-
readonly navigate?: ((href: string) => void) | undefined;
|
|
116
|
-
/** Test seams: a fetch implementation and the photo preparation's options. */
|
|
117
|
-
readonly fetcher?: typeof fetch | undefined;
|
|
118
|
-
readonly attachmentOptions?: Omit<UseBrandlabContactAttachmentsOptions, 'policy'> | undefined;
|
|
119
|
-
}
|
|
120
|
-
export declare function QuoteForm({ formId, contract, analytics, attachmentPolicy, redirectTo, copy, pageLabel, honeypotField, contactEndpoint, navigate, fetcher, attachmentOptions, variant, layout, classes, }: QuoteFormProps): import("react/jsx-runtime").JSX.Element;
|
|
121
|
-
export interface CreateQuoteFormOptions {
|
|
122
|
-
readonly contract: BrandlabContactContract;
|
|
123
|
-
readonly analytics?: BrandlabAnalytics | undefined;
|
|
124
|
-
readonly attachmentPolicy?: ContactAttachmentPolicy | undefined;
|
|
125
|
-
/** The thank-you page, for example `/thank-you`. */
|
|
126
|
-
readonly redirectTo: string;
|
|
127
|
-
readonly copy: QuoteFormCopy;
|
|
128
|
-
/** The site's quote form skin; leave `variant` unset so each placement takes its own. */
|
|
129
|
-
readonly skin?: QuoteFormSkin | undefined;
|
|
130
|
-
/** The quote dialog's skin. */
|
|
131
|
-
readonly dialogSkin?: QuoteDialogSkin | undefined;
|
|
132
|
-
readonly honeypotField?: string | undefined;
|
|
133
|
-
readonly contactEndpoint?: string | undefined;
|
|
134
|
-
readonly navigate?: ((href: string) => void) | undefined;
|
|
135
|
-
readonly fetcher?: typeof fetch | undefined;
|
|
136
|
-
readonly attachmentOptions?: Omit<UseBrandlabContactAttachmentsOptions, 'policy'> | undefined;
|
|
137
|
-
}
|
|
138
|
-
/** What a page passes to the bound form: plain data, so a server component can render it. */
|
|
139
|
-
export interface BoundQuoteFormProps {
|
|
140
|
-
readonly formId: QuoteFormPlacement;
|
|
141
|
-
readonly pageLabel?: string;
|
|
142
|
-
/** This placement's own placeholder, for example on a cost guide. */
|
|
143
|
-
readonly messagePlaceholder?: string;
|
|
144
|
-
readonly layout?: QuoteFormLayout;
|
|
145
|
-
}
|
|
146
|
-
export interface BoundQuoteDialogProps {
|
|
147
|
-
/** The dialog's H2, for example "Get a free quote". */
|
|
148
|
-
readonly title: string;
|
|
149
|
-
/** The close button's accessible name, for example "Close". */
|
|
150
|
-
readonly closeLabel: string;
|
|
151
|
-
readonly pageLabel?: string;
|
|
152
|
-
readonly messagePlaceholder?: string;
|
|
153
|
-
}
|
|
154
|
-
export interface BoundQuoteForm {
|
|
155
|
-
readonly QuoteForm: (props: BoundQuoteFormProps) => JSX.Element;
|
|
156
|
-
readonly QuoteDialog: (props: BoundQuoteDialogProps) => JSX.Element;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Binds the form to the site's contract, analytics, photo policy, thank-you page, copy and skin. Call it once in the
|
|
160
|
-
* site's own `'use client'` file (`src/site/quote-form.tsx`) and export the two components:
|
|
161
|
-
*
|
|
162
|
-
* ```tsx
|
|
163
|
-
* 'use client'
|
|
164
|
-
* const quote = createQuoteForm({ contract: contactContract, analytics, redirectTo: '/thank-you', copy, skin: skin.quoteForm })
|
|
165
|
-
* export const QuoteForm = quote.QuoteForm
|
|
166
|
-
* export const QuoteDialog = quote.QuoteDialog
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* It checks the contract and copy when the module loads, so a form that couldn't send fails the build instead.
|
|
170
|
-
*/
|
|
171
|
-
export declare function createQuoteForm(options: CreateQuoteFormOptions): BoundQuoteForm;
|
|
172
|
-
//# sourceMappingURL=quote-form.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote-form.d.ts","sourceRoot":"","sources":["../../../src/ui-kit/form/quote-form.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAA6B,KAAK,GAAG,EAAkB,MAAM,OAAO,CAAA;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EACV,oCAAoC,EACpC,oCAAoC,EACrC,MAAM,qCAAqC,CAAA;AAO5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAGjD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAErE,eAAO,MAAM,mBAAmB,sCAAuC,CAAA;AACvE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnE,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,6DAA8D,CAAA;AAChG,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvE,wHAAwH;AACxH,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAKhG,CAAA;AAED,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,KAAK,GACL,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,MAAM,GACN,UAAU,GACV,SAAS,GACT,QAAQ,GACR,OAAO,GACP,OAAO,GACP,QAAQ,GACR,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
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
/**
|
|
4
|
-
* `QuoteForm`: the one enquiry form for the hero, the quote dialog, the contact page and cost guides, on the shared
|
|
5
|
-
* contact runtime (`useBrandlabContactForm`, `POST /api/contact`, photo preparation, idempotent retries).
|
|
6
|
-
*
|
|
7
|
-
* Locked layout (F8): Name · Suburb; Phone · Email, both required; the message ("How can we help?"), 5 rows; the
|
|
8
|
-
* "Add photos" drop box with its "0 of 5" counter; the button; then one consent line linking the privacy policy. One
|
|
9
|
-
* column below 640 px. No job select, no "(required)", no helper or reassurance lines: every label and message is
|
|
10
|
-
* the site's copy. Errors appear only after a submit attempt, as a summary plus a message under each field; every
|
|
11
|
-
* typed value and chosen photo is kept on any error. The button stays disabled until the page has hydrated and is
|
|
12
|
-
* locked with a busy label while photos are prepared or the enquiry sends. An accepted enquiry sends one
|
|
13
|
-
* `contact_form` (with `has_photos`) and opens the thank-you page once Google's tag can send it (3.18.0). A submit the
|
|
14
|
-
* form's own checks stop sends `lead_form_error` (stage `validation`, the first failing field).
|
|
15
|
-
*
|
|
16
|
-
* `contract` and `analytics` can't cross from a server component, so a site binds them once with `createQuoteForm`
|
|
17
|
-
* in its own `'use client'` file and renders the bound `QuoteForm` and `QuoteDialog` from its pages.
|
|
18
|
-
*/
|
|
19
|
-
import { defineContactContract, isValidAustralianPhoneNumber, } from '@brandlab-digital/site-core/contact';
|
|
20
|
-
import { usePathname } from 'next/navigation';
|
|
21
|
-
import { useMemo, useRef, useState } from 'react';
|
|
22
|
-
import { contactFieldProps, useBrandlabContactForm } from '../../contact/form-client.js';
|
|
23
|
-
import { navigateAfterGoogleTag } from '../../contact/google-tag-navigate.js';
|
|
24
|
-
import { CONTACT_FORM_FIELDS, CONTACT_PHONE_CHARACTERS } from '../../contact/shared.js';
|
|
25
|
-
import { HeadlessErrorSummary } from '../../ui.js';
|
|
26
|
-
import { HeadlessErrorFocus } from '../../ui-client.js';
|
|
27
|
-
import { TextLink } from '../primitives/links.js';
|
|
28
|
-
import { slot } from '../skin.js';
|
|
29
|
-
import { Field } from './field.js';
|
|
30
|
-
import { PhotoUpload } from './photo-upload.js';
|
|
31
|
-
import { QuoteDialog } from './quote-dialog.js';
|
|
32
|
-
export const QUOTE_FORM_VARIANTS = ['card', 'plain', 'inline'];
|
|
33
|
-
/** The form's id and its lead diagnostics' `form_id`, one per placement. */
|
|
34
|
-
export const QUOTE_FORM_PLACEMENTS = ['quote-hero', 'quote-dialog', 'contact', 'guide'];
|
|
35
|
-
/** The variant each placement takes unless the skin names one: the hero aside, the dialog and contact page, a guide. */
|
|
36
|
-
export const QUOTE_FORM_PLACEMENT_VARIANTS = {
|
|
37
|
-
'quote-hero': 'card',
|
|
38
|
-
'quote-dialog': 'plain',
|
|
39
|
-
contact: 'plain',
|
|
40
|
-
guide: 'inline',
|
|
41
|
-
};
|
|
42
|
-
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
43
|
-
const PHOTOS = 'photos';
|
|
44
|
-
/**
|
|
45
|
-
* The contract's keys for the locked layout. A required field the form can't render would make every enquiry fail,
|
|
46
|
-
* so it throws instead, when the site binds the form (at build).
|
|
47
|
-
*/
|
|
48
|
-
function quoteFields(contract) {
|
|
49
|
-
defineContactContract(contract);
|
|
50
|
-
const role = (name) => contract.fields.find((field) => field.role === name);
|
|
51
|
-
const location = role('location');
|
|
52
|
-
if (location && location.kind !== 'text') {
|
|
53
|
-
throw new Error(`QuoteForm renders the suburb as a text field; the contract's "${location.key}" is a ${location.kind}.`);
|
|
54
|
-
}
|
|
55
|
-
const unrendered = contract.fields.find((field) => field.role === 'custom' && field.required);
|
|
56
|
-
if (unrendered) {
|
|
57
|
-
throw new Error(`QuoteForm has no place for the required field "${unrendered.key}"; make it optional or drop it.`);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
name: role('name').key,
|
|
61
|
-
location: location?.key,
|
|
62
|
-
phone: role('phone').key,
|
|
63
|
-
email: role('email').key,
|
|
64
|
-
message: role('message').key,
|
|
65
|
-
maxLength: Object.fromEntries(contract.fields.map((field) => [field.key, field.maxLength])),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const PHOTO_ERROR_REASONS = ['type', 'size', 'total', 'count', 'prepare'];
|
|
69
|
-
function assertCopy(copy, photos) {
|
|
70
|
-
const text = [
|
|
71
|
-
...Object.values(copy.labels),
|
|
72
|
-
copy.messagePlaceholder,
|
|
73
|
-
copy.submit,
|
|
74
|
-
copy.sending,
|
|
75
|
-
copy.sendingPhotos,
|
|
76
|
-
copy.preparingPhotos,
|
|
77
|
-
copy.photoCount,
|
|
78
|
-
copy.removePhoto,
|
|
79
|
-
copy.consent.sentence,
|
|
80
|
-
copy.consent.linkText,
|
|
81
|
-
copy.consent.href,
|
|
82
|
-
copy.errorSummary,
|
|
83
|
-
copy.errors.name,
|
|
84
|
-
copy.errors.suburb,
|
|
85
|
-
copy.errors.phone,
|
|
86
|
-
copy.errors.phoneFormat,
|
|
87
|
-
copy.errors.email,
|
|
88
|
-
copy.errors.emailFormat,
|
|
89
|
-
copy.errors.message,
|
|
90
|
-
copy.failed.attachment,
|
|
91
|
-
copy.failed.general,
|
|
92
|
-
...(photos === 'none' ? [] : PHOTO_ERROR_REASONS.map((reason) => copy.photoErrors?.[reason])),
|
|
93
|
-
...(photos === 'required' ? [copy.errors.photos] : []),
|
|
94
|
-
];
|
|
95
|
-
if (text.some((value) => typeof value !== 'string' || !value.trim())) {
|
|
96
|
-
throw new Error('QuoteForm copy is incomplete: every label, message and the consent line is the site\'s own text.');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/** The checks the server makes, run before sending: never stricter than the server, so no real enquiry is blocked. */
|
|
100
|
-
function validate(form, fields, copy, photos) {
|
|
101
|
-
const value = (name) => {
|
|
102
|
-
const element = form.elements.namedItem(name);
|
|
103
|
-
return element && 'value' in element ? String(element.value).trim() : '';
|
|
104
|
-
};
|
|
105
|
-
const errors = {};
|
|
106
|
-
if (!value(fields.name))
|
|
107
|
-
errors[fields.name] = copy.errors.name;
|
|
108
|
-
if (fields.location && !value(fields.location))
|
|
109
|
-
errors[fields.location] = copy.errors.suburb;
|
|
110
|
-
const phone = value(fields.phone);
|
|
111
|
-
if (!phone)
|
|
112
|
-
errors[fields.phone] = copy.errors.phone;
|
|
113
|
-
else if (!CONTACT_PHONE_CHARACTERS.test(phone) || !isValidAustralianPhoneNumber(phone)) {
|
|
114
|
-
errors[fields.phone] = copy.errors.phoneFormat;
|
|
115
|
-
}
|
|
116
|
-
const email = value(fields.email).toLowerCase();
|
|
117
|
-
if (!email)
|
|
118
|
-
errors[fields.email] = copy.errors.email;
|
|
119
|
-
else if (!EMAIL_PATTERN.test(email))
|
|
120
|
-
errors[fields.email] = copy.errors.emailFormat;
|
|
121
|
-
if (!value(fields.message))
|
|
122
|
-
errors[fields.message] = copy.errors.message;
|
|
123
|
-
if (photos.required && photos.count === 0 && copy.errors.photos)
|
|
124
|
-
errors[PHOTOS] = copy.errors.photos;
|
|
125
|
-
return errors;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* The site's message for a field the server refused: the runtime's own wording never shows. An empty field gets its
|
|
129
|
-
* "enter" message; a filled phone or email its format message.
|
|
130
|
-
*/
|
|
131
|
-
function serverFieldMessage(form, key, fields, copy) {
|
|
132
|
-
const element = form?.elements.namedItem(key);
|
|
133
|
-
const filled = Boolean(element && 'value' in element && String(element.value).trim());
|
|
134
|
-
if (key === fields.phone)
|
|
135
|
-
return filled ? copy.errors.phoneFormat : copy.errors.phone;
|
|
136
|
-
if (key === fields.email)
|
|
137
|
-
return filled ? copy.errors.emailFormat : copy.errors.email;
|
|
138
|
-
if (key === fields.name)
|
|
139
|
-
return copy.errors.name;
|
|
140
|
-
if (key === fields.location)
|
|
141
|
-
return copy.errors.suburb;
|
|
142
|
-
return copy.errors.message;
|
|
143
|
-
}
|
|
144
|
-
function ConsentLine({ consent, hooks }) {
|
|
145
|
-
const at = consent.sentence.indexOf(consent.linkText);
|
|
146
|
-
const link = _jsx(TextLink, { href: consent.href, children: at < 0 ? consent.sentence : consent.linkText });
|
|
147
|
-
return (_jsx("p", { ...hooks, children: at < 0 ? link : (_jsxs(_Fragment, { children: [consent.sentence.slice(0, at), link, consent.sentence.slice(at + consent.linkText.length)] })) }));
|
|
148
|
-
}
|
|
149
|
-
export function QuoteForm({ formId, contract, analytics, attachmentPolicy, redirectTo, copy, pageLabel, honeypotField = CONTACT_FORM_FIELDS.honeypot, contactEndpoint, navigate, fetcher, attachmentOptions, variant, layout, classes, }) {
|
|
150
|
-
const fields = useMemo(() => quoteFields(contract), [contract]);
|
|
151
|
-
const mode = contract.attachments.mode;
|
|
152
|
-
const photosEnabled = mode !== 'none';
|
|
153
|
-
const photosRequired = mode === 'images-required';
|
|
154
|
-
assertCopy(copy, photosRequired ? 'required' : photosEnabled ? 'optional' : 'none');
|
|
155
|
-
const pagePath = usePathname() || '/';
|
|
156
|
-
const [clientErrors, setClientErrors] = useState(null);
|
|
157
|
-
const [attempt, setAttempt] = useState(0);
|
|
158
|
-
const [withPhotos, setWithPhotos] = useState(false);
|
|
159
|
-
const photoCount = useRef(0);
|
|
160
|
-
const form = useBrandlabContactForm({
|
|
161
|
-
contract,
|
|
162
|
-
...(analytics ? { analytics } : {}),
|
|
163
|
-
pagePath,
|
|
164
|
-
...(pageLabel ? { pageLabel } : {}),
|
|
165
|
-
formId,
|
|
166
|
-
redirectTo,
|
|
167
|
-
redirectDelayMs: 0,
|
|
168
|
-
navigate: navigate ?? navigateAfterGoogleTag,
|
|
169
|
-
...(contactEndpoint ? { contactEndpoint } : {}),
|
|
170
|
-
...(fetcher ? { fetcher } : {}),
|
|
171
|
-
attachments: { ...attachmentOptions, ...(attachmentPolicy ? { policy: attachmentPolicy } : {}) },
|
|
172
|
-
onSubmitStart: ({ form: element }) => {
|
|
173
|
-
const errors = validate(element, fields, copy, { required: photosRequired, count: photoCount.current });
|
|
174
|
-
setAttempt((count) => count + 1);
|
|
175
|
-
if (Object.keys(errors).length > 0) {
|
|
176
|
-
setClientErrors(errors);
|
|
177
|
-
// Nothing is sent; lead_form_error reports the failed checks, in the order of the fields (3.18.0).
|
|
178
|
-
return { invalidFields: Object.keys(errors) };
|
|
179
|
-
}
|
|
180
|
-
setClientErrors(null);
|
|
181
|
-
setWithPhotos(photoCount.current > 0);
|
|
182
|
-
return undefined;
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
photoCount.current = form.attachments.images.length;
|
|
186
|
-
const fieldId = (key) => `${formId}-${key}`;
|
|
187
|
-
const order = [fields.name, fields.location, fields.phone, fields.email, fields.message, photosEnabled ? PHOTOS : undefined]
|
|
188
|
-
.filter((key) => Boolean(key));
|
|
189
|
-
const errors = clientErrors ?? Object.fromEntries(order.flatMap((key) => key !== PHOTOS && form.fieldError(key) ? [[key, serverFieldMessage(form.formProps.ref.current, key, fields, copy)]] : []));
|
|
190
|
-
const summary = order.flatMap((key) => (errors[key] ? [{ fieldId: fieldId(key), message: errors[key] }] : []));
|
|
191
|
-
const leaving = form.succeeded;
|
|
192
|
-
const busyLabel = form.attachments.isProcessing
|
|
193
|
-
? copy.preparingPhotos
|
|
194
|
-
: form.pending || leaving
|
|
195
|
-
? withPhotos ? copy.sendingPhotos : copy.sending
|
|
196
|
-
: undefined;
|
|
197
|
-
const result = form.result;
|
|
198
|
-
const failure = !busyLabel && clientErrors === null && result && !result.ok && summary.length === 0
|
|
199
|
-
? result.code === 'attachment_rejected' ? copy.failed.attachment : copy.failed.general
|
|
200
|
-
: undefined;
|
|
201
|
-
const fieldClasses = { field: classes?.field, label: classes?.label, error: classes?.error };
|
|
202
|
-
const max = (key) => fields.maxLength[key];
|
|
203
|
-
const textField = (key, label, props) => (_jsx(Field, { id: fieldId(key), label: label, error: errors[key], required: true, classes: fieldClasses, children: (control) => (_jsx("input", { ...contactFieldProps(form, key), ...control, ...slot(classes, 'input'), type: props.type, autoComplete: props.autoComplete, ...(props.type === 'tel' ? { inputMode: 'tel' } : { maxLength: max(key) }), ...(props.type === 'email' ? { autoCapitalize: 'none', spellCheck: false } : {}) })) }));
|
|
204
|
-
return (_jsxs("form", { ...form.formProps, noValidate: true, "data-bl": "quote-form", "data-variant": variant ?? QUOTE_FORM_PLACEMENT_VARIANTS[formId], "data-density": layout?.density ?? 'comfortable', className: classes?.root, children: [_jsx(HeadlessErrorSummary, { ...slot(classes, 'errorSummary'), id: `${formId}-errors`, headingId: `${formId}-errors-heading`, heading: copy.errorSummary, errors: summary }), _jsx(HeadlessErrorFocus, { active: summary.length > 0, formId: formId, summaryId: `${formId}-errors` }, attempt), _jsx("div", { "data-bl-honeypot": "", "data-bl-visually-hidden": "", "aria-hidden": "true", inert: true, children: _jsx("input", { type: "text", name: honeypotField, tabIndex: -1, autoComplete: "off" }) }), _jsxs("div", { ...slot(classes, 'row'), children: [textField(fields.name, copy.labels.name, { type: 'text', autoComplete: 'name' }), fields.location ? (_jsx(Field, { id: fieldId(fields.location), label: copy.labels.suburb, error: errors[fields.location], required: true, classes: fieldClasses, children: (control) => (_jsx("input", { ...contactFieldProps(form, fields.location), ...control, ...slot(classes, 'input'), type: "text", autoComplete: "address-level2", maxLength: max(fields.location) })) })) : null] }), _jsxs("div", { ...slot(classes, 'row'), children: [textField(fields.phone, copy.labels.phone, { type: 'tel', autoComplete: 'tel' }), textField(fields.email, copy.labels.email, { type: 'email', autoComplete: 'email' })] }), _jsx(Field, { id: fieldId(fields.message), label: copy.labels.message, error: errors[fields.message], required: true, classes: fieldClasses, children: (control) => (_jsx("textarea", { ...contactFieldProps(form, fields.message), ...control, ...slot(classes, 'textarea'), rows: 5, placeholder: copy.messagePlaceholder, maxLength: max(fields.message) })) }), photosEnabled ? (_jsx(PhotoUpload, { id: fieldId(PHOTOS), label: copy.labels.photos, attachments: form.attachments, counter: copy.photoCount, removeLabel: copy.removePhoto, errorMessages: copy.photoErrors, accept: mode === 'images-and-pdfs-optional' ? 'image/*,application/pdf' : 'image/*', error: errors[PHOTOS], required: photosRequired, disabled: form.pending || leaving, classes: classes })) : null, _jsx("button", { ...form.submitProps, ...slot(classes, 'submit'), disabled: form.submitDisabled || leaving, "data-state": busyLabel ? 'busy' : 'idle', children: busyLabel ?? copy.submit }), _jsx(ConsentLine, { consent: copy.consent, hooks: slot(classes, 'consent') }), _jsx("div", { ...slot(classes, 'status'), ref: form.statusRef, role: "status", "aria-live": "polite", tabIndex: -1, "data-state": failure ? 'error' : busyLabel ? 'busy' : 'idle', children: failure ?? (busyLabel ? _jsx("span", { "data-bl-visually-hidden": "", children: busyLabel }) : null) })] }));
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Binds the form to the site's contract, analytics, photo policy, thank-you page, copy and skin. Call it once in the
|
|
208
|
-
* site's own `'use client'` file (`src/site/quote-form.tsx`) and export the two components:
|
|
209
|
-
*
|
|
210
|
-
* ```tsx
|
|
211
|
-
* 'use client'
|
|
212
|
-
* const quote = createQuoteForm({ contract: contactContract, analytics, redirectTo: '/thank-you', copy, skin: skin.quoteForm })
|
|
213
|
-
* export const QuoteForm = quote.QuoteForm
|
|
214
|
-
* export const QuoteDialog = quote.QuoteDialog
|
|
215
|
-
* ```
|
|
216
|
-
*
|
|
217
|
-
* It checks the contract and copy when the module loads, so a form that couldn't send fails the build instead.
|
|
218
|
-
*/
|
|
219
|
-
export function createQuoteForm(options) {
|
|
220
|
-
if (!options || typeof options !== 'object')
|
|
221
|
-
throw new TypeError('createQuoteForm needs the contract, copy and thank-you page.');
|
|
222
|
-
if (typeof options.redirectTo !== 'string' || !/^\/(?!\/)[^\s]*$/.test(options.redirectTo)) {
|
|
223
|
-
throw new TypeError('redirectTo must be a root-relative path such as /thank-you.');
|
|
224
|
-
}
|
|
225
|
-
quoteFields(options.contract);
|
|
226
|
-
const mode = options.contract.attachments.mode;
|
|
227
|
-
assertCopy(options.copy, mode === 'images-required' ? 'required' : mode === 'none' ? 'none' : 'optional');
|
|
228
|
-
const { skin, dialogSkin, ...shared } = options;
|
|
229
|
-
function BoundQuoteForm({ formId, pageLabel, messagePlaceholder, layout }) {
|
|
230
|
-
const merged = skin?.layout || layout ? { ...skin?.layout, ...layout } : undefined;
|
|
231
|
-
return (_jsx(QuoteForm, { ...shared, formId: formId, pageLabel: pageLabel, copy: messagePlaceholder ? { ...shared.copy, messagePlaceholder } : shared.copy, variant: skin?.variant, layout: merged, classes: skin?.classes }));
|
|
232
|
-
}
|
|
233
|
-
function BoundQuoteDialog({ title, closeLabel, pageLabel, messagePlaceholder }) {
|
|
234
|
-
return (_jsx(QuoteDialog, { title: title, closeLabel: closeLabel, classes: dialogSkin?.classes, children: _jsx(BoundQuoteForm, { formId: "quote-dialog", ...(pageLabel ? { pageLabel } : {}), ...(messagePlaceholder ? { messagePlaceholder } : {}) }) }));
|
|
235
|
-
}
|
|
236
|
-
return Object.freeze({ QuoteForm: BoundQuoteForm, QuoteDialog: BoundQuoteDialog });
|
|
237
|
-
}
|
|
238
|
-
//# sourceMappingURL=quote-form.js.map
|