@reblu/site-blocks 0.29.0 → 0.31.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/client.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { ShopProductListItem, AcademyModulePublic, AcademyLessonPublic, DataRequestType, DataRequestInput, DataRequestSubmission, WithdrawalRequestInput, WithdrawalRequestSubmission } from '@reblu/site-contracts';
4
+ import { ShopProductListItem, AcademyModulePublic, AcademyLessonPublic, DataRequestType, DataRequestInput, DataRequestSubmission, WithdrawalRequestInput, WithdrawalRequestSubmission, ShopCheckoutCopy, AcademyCourseDetail, AcademyCheckoutRequest, AcademyCheckoutSession, AcademyCheckoutErrorCode } from '@reblu/site-contracts';
5
5
  export { DATA_REQUEST_TYPES } from '@reblu/site-contracts';
6
- import { H as HeadingLevel } from './_heading-BsNbc1wc.cjs';
6
+ import { H as HeadingLevel, C as CheckoutTermsCopy, F as FullInvoiceFieldsLabels } from './full-invoice-fields-DMX0sjPG.cjs';
7
7
 
8
8
  /**
9
9
  * `useCollection` — the headless heart of `@reblu/site-blocks`.
@@ -544,4 +544,106 @@ interface WithdrawalRequestFormProps {
544
544
  }
545
545
  declare function WithdrawalRequestForm({ getCaptchaToken, submit, endpoint, onInteract, onSubmitted, labels, locale, className, }: WithdrawalRequestFormProps): react_jsx_runtime.JSX.Element;
546
546
 
547
- export { AddToCartButton, type AddToCartButtonLabels, type AddToCartButtonProps, type AddToCartButtonStatus, CartIcon, type CartIconLabels, type CartIconProps, Collection, type CollectionFacet, type CollectionFacetOption, type CollectionFilter, type CollectionLabels, type CollectionProps, CourseSyllabus, type CourseSyllabusLabels, type CourseSyllabusModule, type CourseSyllabusProps, DATA_REQUEST_FIELD_LIMITS, DEFAULT_COURSE_SYLLABUS_LABELS, DEFAULT_DATA_REQUEST_FORM_LABELS, DEFAULT_PRODUCT_CAROUSEL_LABELS, DEFAULT_WITHDRAWAL_REQUEST_FORM_LABELS, DataRequestForm, type DataRequestFormLabels, type DataRequestFormProps, type DataRequestSubmitResult, ProductCarousel, type ProductCarouselCustomCardProps, type ProductCarouselDefaultCardProps, type ProductCarouselLabels, type ProductCarouselProps, ShareButtons, type ShareButtonsLabels, type ShareButtonsProps, type UseCollectionOptions, type UseCollectionResult, WITHDRAWAL_REQUEST_FIELD_LIMITS, WithdrawalRequestForm, type WithdrawalRequestFormLabels, type WithdrawalRequestFormProps, type WithdrawalRequestSubmitResult, useCollection };
547
+ /**
548
+ * `CourseGuestCheckoutForm` (REB-1264) — drop-in guest checkout of a course
549
+ * that needs no validation, over `POST /api/site/academy/checkout`: name,
550
+ * surname, email, the tenant's terms box, the course's consent box
551
+ * (`AcademyCourseDetail.withdrawalConsent`), the optional full invoice, the
552
+ * total and the pay notice. On success the buyer goes to Stripe; the account
553
+ * is created after payment.
554
+ *
555
+ * Stateful (client-only — ships from `./client`) but transport-agnostic, like
556
+ * `WithdrawalRequestForm`: `submit` sends the body; by default it POSTs JSON
557
+ * to the SITE's own Route Handler (`endpoint`, default `/api/academy/checkout`
558
+ * — mount `createAcademyCheckoutRoute()` from `@reblu/site-next/route-handlers`
559
+ * there), which adds the return URLs and the API key.
560
+ *
561
+ * When the server answers `ENROLLMENT_REQUEST_REQUIRED` (the course needs a
562
+ * validation, or is free), the form gives way to `requestForm`, the SITE's
563
+ * enrollment request form. Render `requestForm` straight away for a course
564
+ * `courseSellsAsGuest` rejects.
565
+ *
566
+ * No enumeration: the form says the same for every email and never mentions
567
+ * an account (REB-834). The copy is Spanish and neutral; replace any text
568
+ * with `labels` / `errorMessages`.
569
+ */
570
+ type CourseGuestCheckoutInput = Omit<AcademyCheckoutRequest, 'successUrl' | 'cancelUrl'> & Partial<Pick<AcademyCheckoutRequest, 'successUrl' | 'cancelUrl'>>;
571
+ type CourseGuestCheckoutResult = {
572
+ ok: true;
573
+ data: AcademyCheckoutSession;
574
+ }
575
+ /** `status` is the HTTP status, or `0` when the request never got an answer. */
576
+ | {
577
+ ok: false;
578
+ status: number;
579
+ code?: string;
580
+ details?: unknown;
581
+ };
582
+ /** The tenant's checkout copy (`ShopConfig.checkout`): terms box, button, notice and invoice texts. */
583
+ type CourseGuestCheckoutCopy = CheckoutTermsCopy & Partial<Pick<ShopCheckoutCopy, 'continueToPaymentLabel' | 'payNotice' | 'fullInvoiceCheckboxLabel' | 'fullInvoiceHelpText'>>;
584
+ interface CourseGuestCheckoutFormLabels {
585
+ firstNameLabel: string;
586
+ lastNameLabel: string;
587
+ emailLabel: string;
588
+ /** The total line; receives the formatted price. */
589
+ total: (formattedTotal: string) => ReactNode;
590
+ /** Button text when the copy carries none. */
591
+ submit: string;
592
+ submitting: string;
593
+ firstNameRequired: string;
594
+ lastNameRequired: string;
595
+ emailInvalid: string;
596
+ termsRequired: string;
597
+ consentRequired: string;
598
+ /** Shown above `requestForm` after `ENROLLMENT_REQUEST_REQUIRED`. `null` hides it. */
599
+ requestRequiredNotice: ReactNode;
600
+ genericError: string;
601
+ }
602
+ declare const DEFAULT_COURSE_GUEST_CHECKOUT_FORM_LABELS: CourseGuestCheckoutFormLabels;
603
+ /** Default copy for every `AcademyCheckoutErrorCode`; override any subset with `errorMessages`. */
604
+ declare const DEFAULT_COURSE_GUEST_CHECKOUT_ERROR_MESSAGES: Record<AcademyCheckoutErrorCode, string>;
605
+ interface CourseGuestCheckoutFormProps {
606
+ /**
607
+ * The fields of `AcademyCourseDetail` the form reads. `withdrawalConsent` is
608
+ * REQUIRED (pass `null` when the course has no box): omitting it for a
609
+ * course that has one would send no version, and the server would refuse
610
+ * every try with `CONSENT_VERSION_CHANGED`. The contract field is optional
611
+ * (older APIs), so pass `course.withdrawalConsent ?? null`.
612
+ */
613
+ course: Pick<AcademyCourseDetail, 'slug' | 'priceCents'> & {
614
+ withdrawalConsent: NonNullable<AcademyCourseDetail['withdrawalConsent']> | null;
615
+ };
616
+ /** The tenant's checkout copy — pass `ShopConfig.checkout`. */
617
+ copy: CourseGuestCheckoutCopy;
618
+ /** The SITE's terms page, used when the tenant set no `termsLinkUrl`. */
619
+ termsHref: string;
620
+ /** The SITE's enrollment request form, shown on `ENROLLMENT_REQUEST_REQUIRED`. */
621
+ requestForm: ReactNode;
622
+ /** `false` when the tenant issues no invoices: no full-invoice opt-in. @default true */
623
+ issuesInvoices?: boolean;
624
+ /** The tenant's simplified-invoice cap in cents (`ShopConfig.simplifiedInvoiceCapCents`). */
625
+ simplifiedInvoiceCapCents?: number | null;
626
+ /** Sends the body. Defaults to a JSON POST to `endpoint`. */
627
+ submit?: (input: CourseGuestCheckoutInput) => Promise<CourseGuestCheckoutResult>;
628
+ /** The SITE's Route Handler used by the default `submit`. @default '/api/academy/checkout' */
629
+ endpoint?: string;
630
+ /** Called with the Stripe URL. @default `window.location.assign(url)` */
631
+ onRedirect?: (url: string) => void;
632
+ /** Called with every refusal, e.g. to reload the page on a `*_VERSION_CHANGED`. */
633
+ onError?: (result: Extract<CourseGuestCheckoutResult, {
634
+ ok: false;
635
+ }>) => void;
636
+ labels?: Partial<CourseGuestCheckoutFormLabels>;
637
+ errorMessages?: Partial<Record<AcademyCheckoutErrorCode, string>>;
638
+ invoiceLabels?: Partial<FullInvoiceFieldsLabels>;
639
+ invoiceCountries?: ReadonlyArray<{
640
+ code: string;
641
+ name: string;
642
+ }>;
643
+ currencyCode?: string;
644
+ locale?: string;
645
+ className?: string;
646
+ }
647
+ declare function CourseGuestCheckoutForm({ course, copy, termsHref, requestForm, issuesInvoices, simplifiedInvoiceCapCents, submit, endpoint, onRedirect, onError, labels, errorMessages, invoiceLabels, invoiceCountries, currencyCode, locale, className, }: CourseGuestCheckoutFormProps): react_jsx_runtime.JSX.Element;
648
+
649
+ export { AddToCartButton, type AddToCartButtonLabels, type AddToCartButtonProps, type AddToCartButtonStatus, CartIcon, type CartIconLabels, type CartIconProps, Collection, type CollectionFacet, type CollectionFacetOption, type CollectionFilter, type CollectionLabels, type CollectionProps, type CourseGuestCheckoutCopy, CourseGuestCheckoutForm, type CourseGuestCheckoutFormLabels, type CourseGuestCheckoutFormProps, type CourseGuestCheckoutInput, type CourseGuestCheckoutResult, CourseSyllabus, type CourseSyllabusLabels, type CourseSyllabusModule, type CourseSyllabusProps, DATA_REQUEST_FIELD_LIMITS, DEFAULT_COURSE_GUEST_CHECKOUT_ERROR_MESSAGES, DEFAULT_COURSE_GUEST_CHECKOUT_FORM_LABELS, DEFAULT_COURSE_SYLLABUS_LABELS, DEFAULT_DATA_REQUEST_FORM_LABELS, DEFAULT_PRODUCT_CAROUSEL_LABELS, DEFAULT_WITHDRAWAL_REQUEST_FORM_LABELS, DataRequestForm, type DataRequestFormLabels, type DataRequestFormProps, type DataRequestSubmitResult, ProductCarousel, type ProductCarouselCustomCardProps, type ProductCarouselDefaultCardProps, type ProductCarouselLabels, type ProductCarouselProps, ShareButtons, type ShareButtonsLabels, type ShareButtonsProps, type UseCollectionOptions, type UseCollectionResult, WITHDRAWAL_REQUEST_FIELD_LIMITS, WithdrawalRequestForm, type WithdrawalRequestFormLabels, type WithdrawalRequestFormProps, type WithdrawalRequestSubmitResult, useCollection };
package/dist/client.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { ShopProductListItem, AcademyModulePublic, AcademyLessonPublic, DataRequestType, DataRequestInput, DataRequestSubmission, WithdrawalRequestInput, WithdrawalRequestSubmission } from '@reblu/site-contracts';
4
+ import { ShopProductListItem, AcademyModulePublic, AcademyLessonPublic, DataRequestType, DataRequestInput, DataRequestSubmission, WithdrawalRequestInput, WithdrawalRequestSubmission, ShopCheckoutCopy, AcademyCourseDetail, AcademyCheckoutRequest, AcademyCheckoutSession, AcademyCheckoutErrorCode } from '@reblu/site-contracts';
5
5
  export { DATA_REQUEST_TYPES } from '@reblu/site-contracts';
6
- import { H as HeadingLevel } from './_heading-BsNbc1wc.js';
6
+ import { H as HeadingLevel, C as CheckoutTermsCopy, F as FullInvoiceFieldsLabels } from './full-invoice-fields-DMX0sjPG.js';
7
7
 
8
8
  /**
9
9
  * `useCollection` — the headless heart of `@reblu/site-blocks`.
@@ -544,4 +544,106 @@ interface WithdrawalRequestFormProps {
544
544
  }
545
545
  declare function WithdrawalRequestForm({ getCaptchaToken, submit, endpoint, onInteract, onSubmitted, labels, locale, className, }: WithdrawalRequestFormProps): react_jsx_runtime.JSX.Element;
546
546
 
547
- export { AddToCartButton, type AddToCartButtonLabels, type AddToCartButtonProps, type AddToCartButtonStatus, CartIcon, type CartIconLabels, type CartIconProps, Collection, type CollectionFacet, type CollectionFacetOption, type CollectionFilter, type CollectionLabels, type CollectionProps, CourseSyllabus, type CourseSyllabusLabels, type CourseSyllabusModule, type CourseSyllabusProps, DATA_REQUEST_FIELD_LIMITS, DEFAULT_COURSE_SYLLABUS_LABELS, DEFAULT_DATA_REQUEST_FORM_LABELS, DEFAULT_PRODUCT_CAROUSEL_LABELS, DEFAULT_WITHDRAWAL_REQUEST_FORM_LABELS, DataRequestForm, type DataRequestFormLabels, type DataRequestFormProps, type DataRequestSubmitResult, ProductCarousel, type ProductCarouselCustomCardProps, type ProductCarouselDefaultCardProps, type ProductCarouselLabels, type ProductCarouselProps, ShareButtons, type ShareButtonsLabels, type ShareButtonsProps, type UseCollectionOptions, type UseCollectionResult, WITHDRAWAL_REQUEST_FIELD_LIMITS, WithdrawalRequestForm, type WithdrawalRequestFormLabels, type WithdrawalRequestFormProps, type WithdrawalRequestSubmitResult, useCollection };
547
+ /**
548
+ * `CourseGuestCheckoutForm` (REB-1264) — drop-in guest checkout of a course
549
+ * that needs no validation, over `POST /api/site/academy/checkout`: name,
550
+ * surname, email, the tenant's terms box, the course's consent box
551
+ * (`AcademyCourseDetail.withdrawalConsent`), the optional full invoice, the
552
+ * total and the pay notice. On success the buyer goes to Stripe; the account
553
+ * is created after payment.
554
+ *
555
+ * Stateful (client-only — ships from `./client`) but transport-agnostic, like
556
+ * `WithdrawalRequestForm`: `submit` sends the body; by default it POSTs JSON
557
+ * to the SITE's own Route Handler (`endpoint`, default `/api/academy/checkout`
558
+ * — mount `createAcademyCheckoutRoute()` from `@reblu/site-next/route-handlers`
559
+ * there), which adds the return URLs and the API key.
560
+ *
561
+ * When the server answers `ENROLLMENT_REQUEST_REQUIRED` (the course needs a
562
+ * validation, or is free), the form gives way to `requestForm`, the SITE's
563
+ * enrollment request form. Render `requestForm` straight away for a course
564
+ * `courseSellsAsGuest` rejects.
565
+ *
566
+ * No enumeration: the form says the same for every email and never mentions
567
+ * an account (REB-834). The copy is Spanish and neutral; replace any text
568
+ * with `labels` / `errorMessages`.
569
+ */
570
+ type CourseGuestCheckoutInput = Omit<AcademyCheckoutRequest, 'successUrl' | 'cancelUrl'> & Partial<Pick<AcademyCheckoutRequest, 'successUrl' | 'cancelUrl'>>;
571
+ type CourseGuestCheckoutResult = {
572
+ ok: true;
573
+ data: AcademyCheckoutSession;
574
+ }
575
+ /** `status` is the HTTP status, or `0` when the request never got an answer. */
576
+ | {
577
+ ok: false;
578
+ status: number;
579
+ code?: string;
580
+ details?: unknown;
581
+ };
582
+ /** The tenant's checkout copy (`ShopConfig.checkout`): terms box, button, notice and invoice texts. */
583
+ type CourseGuestCheckoutCopy = CheckoutTermsCopy & Partial<Pick<ShopCheckoutCopy, 'continueToPaymentLabel' | 'payNotice' | 'fullInvoiceCheckboxLabel' | 'fullInvoiceHelpText'>>;
584
+ interface CourseGuestCheckoutFormLabels {
585
+ firstNameLabel: string;
586
+ lastNameLabel: string;
587
+ emailLabel: string;
588
+ /** The total line; receives the formatted price. */
589
+ total: (formattedTotal: string) => ReactNode;
590
+ /** Button text when the copy carries none. */
591
+ submit: string;
592
+ submitting: string;
593
+ firstNameRequired: string;
594
+ lastNameRequired: string;
595
+ emailInvalid: string;
596
+ termsRequired: string;
597
+ consentRequired: string;
598
+ /** Shown above `requestForm` after `ENROLLMENT_REQUEST_REQUIRED`. `null` hides it. */
599
+ requestRequiredNotice: ReactNode;
600
+ genericError: string;
601
+ }
602
+ declare const DEFAULT_COURSE_GUEST_CHECKOUT_FORM_LABELS: CourseGuestCheckoutFormLabels;
603
+ /** Default copy for every `AcademyCheckoutErrorCode`; override any subset with `errorMessages`. */
604
+ declare const DEFAULT_COURSE_GUEST_CHECKOUT_ERROR_MESSAGES: Record<AcademyCheckoutErrorCode, string>;
605
+ interface CourseGuestCheckoutFormProps {
606
+ /**
607
+ * The fields of `AcademyCourseDetail` the form reads. `withdrawalConsent` is
608
+ * REQUIRED (pass `null` when the course has no box): omitting it for a
609
+ * course that has one would send no version, and the server would refuse
610
+ * every try with `CONSENT_VERSION_CHANGED`. The contract field is optional
611
+ * (older APIs), so pass `course.withdrawalConsent ?? null`.
612
+ */
613
+ course: Pick<AcademyCourseDetail, 'slug' | 'priceCents'> & {
614
+ withdrawalConsent: NonNullable<AcademyCourseDetail['withdrawalConsent']> | null;
615
+ };
616
+ /** The tenant's checkout copy — pass `ShopConfig.checkout`. */
617
+ copy: CourseGuestCheckoutCopy;
618
+ /** The SITE's terms page, used when the tenant set no `termsLinkUrl`. */
619
+ termsHref: string;
620
+ /** The SITE's enrollment request form, shown on `ENROLLMENT_REQUEST_REQUIRED`. */
621
+ requestForm: ReactNode;
622
+ /** `false` when the tenant issues no invoices: no full-invoice opt-in. @default true */
623
+ issuesInvoices?: boolean;
624
+ /** The tenant's simplified-invoice cap in cents (`ShopConfig.simplifiedInvoiceCapCents`). */
625
+ simplifiedInvoiceCapCents?: number | null;
626
+ /** Sends the body. Defaults to a JSON POST to `endpoint`. */
627
+ submit?: (input: CourseGuestCheckoutInput) => Promise<CourseGuestCheckoutResult>;
628
+ /** The SITE's Route Handler used by the default `submit`. @default '/api/academy/checkout' */
629
+ endpoint?: string;
630
+ /** Called with the Stripe URL. @default `window.location.assign(url)` */
631
+ onRedirect?: (url: string) => void;
632
+ /** Called with every refusal, e.g. to reload the page on a `*_VERSION_CHANGED`. */
633
+ onError?: (result: Extract<CourseGuestCheckoutResult, {
634
+ ok: false;
635
+ }>) => void;
636
+ labels?: Partial<CourseGuestCheckoutFormLabels>;
637
+ errorMessages?: Partial<Record<AcademyCheckoutErrorCode, string>>;
638
+ invoiceLabels?: Partial<FullInvoiceFieldsLabels>;
639
+ invoiceCountries?: ReadonlyArray<{
640
+ code: string;
641
+ name: string;
642
+ }>;
643
+ currencyCode?: string;
644
+ locale?: string;
645
+ className?: string;
646
+ }
647
+ declare function CourseGuestCheckoutForm({ course, copy, termsHref, requestForm, issuesInvoices, simplifiedInvoiceCapCents, submit, endpoint, onRedirect, onError, labels, errorMessages, invoiceLabels, invoiceCountries, currencyCode, locale, className, }: CourseGuestCheckoutFormProps): react_jsx_runtime.JSX.Element;
648
+
649
+ export { AddToCartButton, type AddToCartButtonLabels, type AddToCartButtonProps, type AddToCartButtonStatus, CartIcon, type CartIconLabels, type CartIconProps, Collection, type CollectionFacet, type CollectionFacetOption, type CollectionFilter, type CollectionLabels, type CollectionProps, type CourseGuestCheckoutCopy, CourseGuestCheckoutForm, type CourseGuestCheckoutFormLabels, type CourseGuestCheckoutFormProps, type CourseGuestCheckoutInput, type CourseGuestCheckoutResult, CourseSyllabus, type CourseSyllabusLabels, type CourseSyllabusModule, type CourseSyllabusProps, DATA_REQUEST_FIELD_LIMITS, DEFAULT_COURSE_GUEST_CHECKOUT_ERROR_MESSAGES, DEFAULT_COURSE_GUEST_CHECKOUT_FORM_LABELS, DEFAULT_COURSE_SYLLABUS_LABELS, DEFAULT_DATA_REQUEST_FORM_LABELS, DEFAULT_PRODUCT_CAROUSEL_LABELS, DEFAULT_WITHDRAWAL_REQUEST_FORM_LABELS, DataRequestForm, type DataRequestFormLabels, type DataRequestFormProps, type DataRequestSubmitResult, ProductCarousel, type ProductCarouselCustomCardProps, type ProductCarouselDefaultCardProps, type ProductCarouselLabels, type ProductCarouselProps, ShareButtons, type ShareButtonsLabels, type ShareButtonsProps, type UseCollectionOptions, type UseCollectionResult, WITHDRAWAL_REQUEST_FIELD_LIMITS, WithdrawalRequestForm, type WithdrawalRequestFormLabels, type WithdrawalRequestFormProps, type WithdrawalRequestSubmitResult, useCollection };