@reblu/site-blocks 0.15.0 → 0.17.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/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ShopErrorCode, PageDetail, PageListItem, ShopProductListItem, ShopProductTrustIcon, ShopProductTrustItem, TrustBadgeType, TrustBadge, BlockType, PageBlock, ResolvedEmbed, ShopFacets, ShopOrder, ShopBillingInput, ShopCheckoutInput, ShopOrderInvoice } from '@reblu/site-contracts';
2
+ export { DATA_REQUEST_TYPES } from '@reblu/site-contracts';
2
3
  import { FaqItem } from './seo.cjs';
3
4
  export { FaqPageJsonLd, MarkdownToPlainTextOptions, buildFaqPageJsonLd, collectFaqItems, markdownToPlainText } from './seo.cjs';
4
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import * as React$1 from 'react';
5
7
  import { ReactNode, ComponentType, FormEvent } from 'react';
6
8
 
7
9
  declare function readingTime(content: string | null | undefined): number | null;
@@ -225,8 +227,27 @@ interface MarkdownRendererProps {
225
227
  * the page keeps a single h1.
226
228
  */
227
229
  headingOffset?: number;
230
+ /**
231
+ * Restrict and render images (REB-1075). Absent: every image the sanitiser keeps is
232
+ * rendered as a lazy `<img>` inside its paragraph (the historical behaviour).
233
+ */
234
+ images?: MarkdownImageOptions;
235
+ }
236
+ /** The `images` option of {@link MarkdownRenderer}. */
237
+ interface MarkdownImageOptions {
238
+ /**
239
+ * Absolute URL prefixes an image may load from (e.g. a storage bucket's public URL,
240
+ * ending in `/`). Any other image is dropped. Compared on the parsed, normalised URL
241
+ * (`..` resolved), with the scheme included, so `http:` never matches an `https:` prefix.
242
+ */
243
+ allowedUrlPrefixes: readonly string[];
244
+ /** Render an allowed image yourself (e.g. `next/image`). Default: a lazy `<img>`. */
245
+ render?: (image: {
246
+ src: string;
247
+ alt: string;
248
+ }) => React$1.ReactNode;
228
249
  }
229
- declare function MarkdownRenderer({ content, className, headingOffset }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
250
+ declare function MarkdownRenderer({ content, className, headingOffset, images, }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
230
251
  /**
231
252
  * Render an **already-sanitised** HTML string through the same token-driven
232
253
  * component map as {@link MarkdownRenderer}. Consumers pass HTML that has been run
@@ -489,8 +510,14 @@ declare function FaqAccordion({ items, heading, headingLevel, questionHeadingLev
489
510
  * - Badges are grouped by type (in {@link DEFAULT_TRUST_BADGE_TYPE_ORDER}, or
490
511
  * the `types` prop), each group under an overridable heading, and ordered by
491
512
  * `sortOrder` inside it.
492
- * - A logo is an `<img>` whose `alt` is the badge name; a badge without a logo
513
+ * - A logo is an `<img>` whose `alt` is the badge name, rendered only when its
514
+ * URL is http(s) or root-relative (REB-1002); a badge without a usable logo
493
515
  * shows its name as text.
516
+ * - `heading` (optional) wraps everything in a `<section>` labelled by it
517
+ * (`headingId`), with the group headings one level below — so a SITE keeps
518
+ * its `<section aria-labelledby>` landmark (REB-1002).
519
+ * - Consumer classNames follow the REB-997 slot rule: `headingClassName` and
520
+ * `sectionHeadingClassName` REPLACE that heading's default typography.
494
521
  * - `url` links only when it is http(s), in a new window with
495
522
  * `rel="noopener noreferrer"` and a visually hidden new-window hint.
496
523
  */
@@ -505,7 +532,18 @@ interface TrustBadgesProps {
505
532
  headings?: Partial<Record<TrustBadgeType, string | null>>;
506
533
  /** Which groups to render, in this order. Defaults to every type. */
507
534
  types?: readonly TrustBadgeType[];
508
- /** Heading level of each group title. Defaults to `2`. */
535
+ /**
536
+ * Optional section title, e.g. «Nos avalan». When given, the root is a
537
+ * `<section aria-labelledby={headingId}>` and the group headings render one
538
+ * level below `headingLevel`.
539
+ */
540
+ heading?: ReactNode;
541
+ /** `id` of the section heading (the section's `aria-labelledby`). @default 'trust-badges-heading' */
542
+ headingId?: string;
543
+ /**
544
+ * Heading level of the section title when `heading` is given, otherwise of
545
+ * each group title. Defaults to `2`.
546
+ */
509
547
  headingLevel?: HeadingLevel;
510
548
  /** Visually hidden text appended to linked badges. */
511
549
  newWindowLabel?: string;
@@ -513,14 +551,22 @@ interface TrustBadgesProps {
513
551
  className?: string;
514
552
  /** Classes for each group. */
515
553
  groupClassName?: string;
516
- /** Classes for each group heading. */
554
+ /**
555
+ * Classes for each group heading. When given, they REPLACE the default
556
+ * `text-sm font-semibold uppercase tracking-widest` (REB-997).
557
+ */
517
558
  headingClassName?: string;
559
+ /**
560
+ * Classes for the section heading (only with `heading`). When given, they
561
+ * REPLACE the default `text-xl font-semibold` (REB-997).
562
+ */
563
+ sectionHeadingClassName?: string;
518
564
  /** Classes for each group's `<ul>`. */
519
565
  listClassName?: string;
520
566
  /** Classes for each logo `<img>`. */
521
567
  logoClassName?: string;
522
568
  }
523
- declare function TrustBadges({ badges, headings, types, headingLevel, newWindowLabel, className, groupClassName, headingClassName, listClassName, logoClassName, }: TrustBadgesProps): react_jsx_runtime.JSX.Element | null;
569
+ declare function TrustBadges({ badges, headings, types, heading, headingId, headingLevel, newWindowLabel, className, groupClassName, headingClassName, sectionHeadingClassName, listClassName, logoClassName, }: TrustBadgesProps): react_jsx_runtime.JSX.Element | null;
524
570
 
525
571
  /**
526
572
  * REB-850 — `PageBlocks`: the shared renderer for a page's registry blocks
@@ -1203,4 +1249,4 @@ interface OrderInvoiceLinkProps {
1203
1249
  }
1204
1250
  declare function OrderInvoiceLink({ invoice, labels, className }: OrderInvoiceLinkProps): react_jsx_runtime.JSX.Element | null;
1205
1251
 
1206
- export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };
1252
+ export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, type MarkdownImageOptions, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ShopErrorCode, PageDetail, PageListItem, ShopProductListItem, ShopProductTrustIcon, ShopProductTrustItem, TrustBadgeType, TrustBadge, BlockType, PageBlock, ResolvedEmbed, ShopFacets, ShopOrder, ShopBillingInput, ShopCheckoutInput, ShopOrderInvoice } from '@reblu/site-contracts';
2
+ export { DATA_REQUEST_TYPES } from '@reblu/site-contracts';
2
3
  import { FaqItem } from './seo.js';
3
4
  export { FaqPageJsonLd, MarkdownToPlainTextOptions, buildFaqPageJsonLd, collectFaqItems, markdownToPlainText } from './seo.js';
4
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import * as React$1 from 'react';
5
7
  import { ReactNode, ComponentType, FormEvent } from 'react';
6
8
 
7
9
  declare function readingTime(content: string | null | undefined): number | null;
@@ -225,8 +227,27 @@ interface MarkdownRendererProps {
225
227
  * the page keeps a single h1.
226
228
  */
227
229
  headingOffset?: number;
230
+ /**
231
+ * Restrict and render images (REB-1075). Absent: every image the sanitiser keeps is
232
+ * rendered as a lazy `<img>` inside its paragraph (the historical behaviour).
233
+ */
234
+ images?: MarkdownImageOptions;
235
+ }
236
+ /** The `images` option of {@link MarkdownRenderer}. */
237
+ interface MarkdownImageOptions {
238
+ /**
239
+ * Absolute URL prefixes an image may load from (e.g. a storage bucket's public URL,
240
+ * ending in `/`). Any other image is dropped. Compared on the parsed, normalised URL
241
+ * (`..` resolved), with the scheme included, so `http:` never matches an `https:` prefix.
242
+ */
243
+ allowedUrlPrefixes: readonly string[];
244
+ /** Render an allowed image yourself (e.g. `next/image`). Default: a lazy `<img>`. */
245
+ render?: (image: {
246
+ src: string;
247
+ alt: string;
248
+ }) => React$1.ReactNode;
228
249
  }
229
- declare function MarkdownRenderer({ content, className, headingOffset }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
250
+ declare function MarkdownRenderer({ content, className, headingOffset, images, }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
230
251
  /**
231
252
  * Render an **already-sanitised** HTML string through the same token-driven
232
253
  * component map as {@link MarkdownRenderer}. Consumers pass HTML that has been run
@@ -489,8 +510,14 @@ declare function FaqAccordion({ items, heading, headingLevel, questionHeadingLev
489
510
  * - Badges are grouped by type (in {@link DEFAULT_TRUST_BADGE_TYPE_ORDER}, or
490
511
  * the `types` prop), each group under an overridable heading, and ordered by
491
512
  * `sortOrder` inside it.
492
- * - A logo is an `<img>` whose `alt` is the badge name; a badge without a logo
513
+ * - A logo is an `<img>` whose `alt` is the badge name, rendered only when its
514
+ * URL is http(s) or root-relative (REB-1002); a badge without a usable logo
493
515
  * shows its name as text.
516
+ * - `heading` (optional) wraps everything in a `<section>` labelled by it
517
+ * (`headingId`), with the group headings one level below — so a SITE keeps
518
+ * its `<section aria-labelledby>` landmark (REB-1002).
519
+ * - Consumer classNames follow the REB-997 slot rule: `headingClassName` and
520
+ * `sectionHeadingClassName` REPLACE that heading's default typography.
494
521
  * - `url` links only when it is http(s), in a new window with
495
522
  * `rel="noopener noreferrer"` and a visually hidden new-window hint.
496
523
  */
@@ -505,7 +532,18 @@ interface TrustBadgesProps {
505
532
  headings?: Partial<Record<TrustBadgeType, string | null>>;
506
533
  /** Which groups to render, in this order. Defaults to every type. */
507
534
  types?: readonly TrustBadgeType[];
508
- /** Heading level of each group title. Defaults to `2`. */
535
+ /**
536
+ * Optional section title, e.g. «Nos avalan». When given, the root is a
537
+ * `<section aria-labelledby={headingId}>` and the group headings render one
538
+ * level below `headingLevel`.
539
+ */
540
+ heading?: ReactNode;
541
+ /** `id` of the section heading (the section's `aria-labelledby`). @default 'trust-badges-heading' */
542
+ headingId?: string;
543
+ /**
544
+ * Heading level of the section title when `heading` is given, otherwise of
545
+ * each group title. Defaults to `2`.
546
+ */
509
547
  headingLevel?: HeadingLevel;
510
548
  /** Visually hidden text appended to linked badges. */
511
549
  newWindowLabel?: string;
@@ -513,14 +551,22 @@ interface TrustBadgesProps {
513
551
  className?: string;
514
552
  /** Classes for each group. */
515
553
  groupClassName?: string;
516
- /** Classes for each group heading. */
554
+ /**
555
+ * Classes for each group heading. When given, they REPLACE the default
556
+ * `text-sm font-semibold uppercase tracking-widest` (REB-997).
557
+ */
517
558
  headingClassName?: string;
559
+ /**
560
+ * Classes for the section heading (only with `heading`). When given, they
561
+ * REPLACE the default `text-xl font-semibold` (REB-997).
562
+ */
563
+ sectionHeadingClassName?: string;
518
564
  /** Classes for each group's `<ul>`. */
519
565
  listClassName?: string;
520
566
  /** Classes for each logo `<img>`. */
521
567
  logoClassName?: string;
522
568
  }
523
- declare function TrustBadges({ badges, headings, types, headingLevel, newWindowLabel, className, groupClassName, headingClassName, listClassName, logoClassName, }: TrustBadgesProps): react_jsx_runtime.JSX.Element | null;
569
+ declare function TrustBadges({ badges, headings, types, heading, headingId, headingLevel, newWindowLabel, className, groupClassName, headingClassName, sectionHeadingClassName, listClassName, logoClassName, }: TrustBadgesProps): react_jsx_runtime.JSX.Element | null;
524
570
 
525
571
  /**
526
572
  * REB-850 — `PageBlocks`: the shared renderer for a page's registry blocks
@@ -1203,4 +1249,4 @@ interface OrderInvoiceLinkProps {
1203
1249
  }
1204
1250
  declare function OrderInvoiceLink({ invoice, labels, className }: OrderInvoiceLinkProps): react_jsx_runtime.JSX.Element | null;
1205
1251
 
1206
- export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };
1252
+ export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, type MarkdownImageOptions, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };