@atom63/mdx 0.4.0-beta.2 → 0.4.0-beta.4

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.
Files changed (32) hide show
  1. package/README.md +10 -2
  2. package/dist/article/index.d.ts +7 -5
  3. package/dist/article/index.js +3 -3
  4. package/dist/blocks/credits-block-entry.d.ts +2 -1
  5. package/dist/blocks/index.d.ts +5 -4
  6. package/dist/blocks/index.js +1 -1
  7. package/dist/blocks/media-caption-entry.d.ts +2 -1
  8. package/dist/{chunk-3FJTASAW.js → chunk-WBFPTNBO.js} +70 -20
  9. package/dist/chunk-WBFPTNBO.js.map +1 -0
  10. package/dist/{chunk-DYCKBZGD.js → chunk-XT6W33Q2.js} +3 -3
  11. package/dist/{chunk-DYCKBZGD.js.map → chunk-XT6W33Q2.js.map} +1 -1
  12. package/dist/editor/index.d.ts +2 -1
  13. package/dist/editor/index.js +1 -1
  14. package/dist/editor/index.js.map +1 -1
  15. package/dist/{framed-block-DM5LLxO7.d.ts → framed-block-B1hGPjE2.d.ts} +2 -1
  16. package/dist/index.d.ts +5 -5
  17. package/dist/index.js +3 -3
  18. package/dist/lightbox/index.d.ts +4 -3
  19. package/dist/{mdx-provider-6gOypsy5.d.ts → mdx-provider-FJp99Azd.d.ts} +3 -2
  20. package/dist/{photo-swipe-CwzAHpP-.d.ts → photo-swipe-BdrjP_BB.d.ts} +2 -1
  21. package/dist/primitives/index.d.ts +4 -3
  22. package/dist/runtime/index.d.ts +2 -1
  23. package/dist/{slots-BvPdUMdY.d.ts → slots-D8ZQyRhv.d.ts} +2 -1
  24. package/dist/{video-block-C0a5Yx9x.d.ts → video-block-Cg5EK_vS.d.ts} +19 -3
  25. package/package.json +25 -25
  26. package/src/blocks/callout/callout.css +1 -1
  27. package/src/blocks/mermaid-diagram/mermaid-diagram.css +1 -1
  28. package/src/blocks/page-table-of-contents/page-table-of-contents.css +1 -1
  29. package/src/blocks/stat-card/stat-card.css +1 -1
  30. package/src/blocks/video-block/video-block.css +7 -0
  31. package/src/styles/base.css +5 -5
  32. package/dist/chunk-3FJTASAW.js.map +0 -1
package/README.md CHANGED
@@ -10,7 +10,10 @@ fixtures are repository-only implementation detail.
10
10
 
11
11
  See `API.md` for the maintained public export snapshot.
12
12
 
13
- Public import paths:
13
+ Public import paths. The stability column is the API tier of each entry: a Stable entry keeps
14
+ its exports and props without breaking changes between releases, an Experimental one can change.
15
+ The package itself is still beta (`0.x-beta` on npm), so a release can still change a Stable
16
+ entry; such a change is called out in the changelog.
14
17
 
15
18
  | Subpath | Stability | Use |
16
19
  |---------|-----------|-----|
@@ -126,6 +129,11 @@ Site-specific media (`MediaBlock`, carousels, Compare) stays in atom63.io — se
126
129
 
127
130
  ## Block inventory
128
131
 
132
+ Each block's purpose, a working example and its props (read from its TypeScript types) are on
133
+ the docs page [MDX blocks](https://system.atom63.io/patterns/pattern-mdx-blocks),
134
+ and from the terminal with `atom63 api <Block>` (for example `atom63 api KeyIdea`) or
135
+ `atom63 docs pattern-mdx-blocks`.
136
+
129
137
  Registered on `mdxComponents` / `blockMdxComponents`:
130
138
 
131
139
  | Component | Purpose |
@@ -137,7 +145,7 @@ Registered on `mdxComponents` / `blockMdxComponents`:
137
145
  | `ExampleContainer` | Live demo frame with dot grid |
138
146
  | `FigureBlock` | Captioned image figure with a connected `MediaLightbox` gallery (default on) |
139
147
  | `MediaCaption` | Centered figure caption |
140
- | `VideoBlock` | Captioned or explicitly decorative video figure |
148
+ | `VideoBlock` | Captioned or explicitly decorative video figure. Set the caption track's language with `trackLang` (default `en`) and its menu name with `trackLabel` (default: the language's own name, such as "English" or "Deutsch") |
141
149
 
142
150
  Article-only components (atom63.io): `MediaBlock`, `ImageBlock`, `ImageCarousel`, `ImageGrid`, `BeforeAfter`, `LinkCard`.
143
151
 
@@ -1,11 +1,12 @@
1
- import { M as MdxComponentsMap, m as mdxComponents, a as MDXContentProviderProps } from '../mdx-provider-6gOypsy5.js';
2
- export { b as MdxProviderVariant, c as blockMdxComponents, u as useIsInsideExample, d as useMdxStyle } from '../mdx-provider-6gOypsy5.js';
3
- export { C as CalloutType, m as mdxStyles } from '../video-block-C0a5Yx9x.js';
1
+ import { M as MdxComponentsMap, a as MDXContentProviderProps } from '../mdx-provider-FJp99Azd.js';
2
+ import { mdxComponents } from '../index.js';
3
+ export { b as MdxProviderVariant, c as blockMdxComponents, u as useIsInsideExample, d as useMdxStyle } from '../mdx-provider-FJp99Azd.js';
4
+ export { C as CalloutType, m as mdxStyles } from '../video-block-Cg5EK_vS.js';
4
5
  import * as React from 'react';
5
6
  import '../blocks/credits-block-entry.js';
6
7
  import '../blocks/media-caption-entry.js';
7
8
  import '@mdx-js/react';
8
- import '../slots-BvPdUMdY.js';
9
+ import '../slots-D8ZQyRhv.js';
9
10
  import '@atom63/ui-react';
10
11
 
11
12
  /**
@@ -29,4 +30,5 @@ type MediaSpacingVariant = 'none' | 'sm' | 'default' | 'lg';
29
30
  /** Aligned with @atom63/mdx `mdxStyles.spacing` tokens. */
30
31
  declare const mediaSpacingStyles: Record<MediaSpacingVariant, string>;
31
32
 
32
- export { ArticleMDXContentProvider, MDXContentProviderProps, type MediaSpacingVariant, createMdxComponents, mediaSpacingStyles };
33
+ export { ArticleMDXContentProvider, MDXContentProviderProps, createMdxComponents, mediaSpacingStyles };
34
+ export type { MediaSpacingVariant };
@@ -1,6 +1,6 @@
1
- import { mdxComponents, MDXContentProvider } from '../chunk-DYCKBZGD.js';
2
- export { blockMdxComponents, useMdxStyle } from '../chunk-DYCKBZGD.js';
3
- export { useIsInsideExample } from '../chunk-3FJTASAW.js';
1
+ import { mdxComponents, MDXContentProvider } from '../chunk-XT6W33Q2.js';
2
+ export { blockMdxComponents, useMdxStyle } from '../chunk-XT6W33Q2.js';
3
+ export { useIsInsideExample } from '../chunk-WBFPTNBO.js';
4
4
  import '../chunk-WZ6US342.js';
5
5
  import '../chunk-DJSENA7Q.js';
6
6
  import '../chunk-2RCEDZBB.js';
@@ -11,4 +11,5 @@ type CreditsBlockProps = {
11
11
  };
12
12
  declare function CreditsBlock({ credits, className, label }: CreditsBlockProps): React.JSX.Element | null;
13
13
 
14
- export { type CreditEntry, CreditsBlock, type CreditsBlockProps };
14
+ export { CreditsBlock };
15
+ export type { CreditEntry, CreditsBlockProps };
@@ -1,9 +1,9 @@
1
1
  export { M as MDX_FIGURE_LIGHTBOX_GALLERY_ID } from '../constants-CuaBcwMe.js';
2
- export { A as Accordion, k as AccordionProps, a as Callout, l as CalloutProps, b as CodeBlock, n as CodeBlockProps, c as ColorSwatchItem, o as ColorSwatchItemProps, d as ComparisonPair, p as ComparisonPairProps, q as ComparisonSlotProps, r as DemoStage, D as DemoStageProps, E as ExampleContainer, s as ExampleContainerProps, F as FigureBlock, t as FigureBlockProps, M as MediaPlaceholder, u as MediaPlaceholderKind, v as MediaPlaceholderProps, e as MermaidDiagram, w as MermaidDiagramLabels, x as MermaidDiagramProps, P as PageMeta, y as PageMetaProps, f as PageTableOfContents, z as PageTableOfContentsProps, B as ResourceItem, R as ResourceList, G as ResourceListProps, S as ScrollStage, H as ScrollStageProps, I as ScrollStageStepProps, g as StatCard, J as StatCardProps, h as StatGrid, K as StatGridProps, L as StatTrend, i as Steps, N as StepsProps, O as StepsStepProps, T as Tabs, Q as TabsProps, j as Timeline, U as TimelineItemProps, W as TimelineProps, V as VideoBlock, X as VideoBlockProps, Y as defaultMermaidDiagramLabels } from '../video-block-C0a5Yx9x.js';
3
- import { S as SlotComponent } from '../slots-BvPdUMdY.js';
2
+ export { A as Accordion, k as AccordionProps, a as Callout, l as CalloutProps, b as CodeBlock, n as CodeBlockProps, c as ColorSwatchItem, o as ColorSwatchItemProps, d as ComparisonPair, p as ComparisonPairProps, q as ComparisonSlotProps, r as DemoStage, D as DemoStageProps, E as ExampleContainer, s as ExampleContainerProps, F as FigureBlock, t as FigureBlockProps, M as MediaPlaceholder, u as MediaPlaceholderKind, v as MediaPlaceholderProps, e as MermaidDiagram, w as MermaidDiagramLabels, x as MermaidDiagramProps, P as PageMeta, y as PageMetaProps, f as PageTableOfContents, z as PageTableOfContentsProps, B as ResourceItem, R as ResourceList, G as ResourceListProps, S as ScrollStage, H as ScrollStageProps, I as ScrollStageStepProps, g as StatCard, J as StatCardProps, h as StatGrid, K as StatGridProps, L as StatTrend, i as Steps, N as StepsProps, O as StepsStepProps, T as Tabs, Q as TabsProps, j as Timeline, U as TimelineItemProps, W as TimelineProps, V as VideoBlock, X as VideoBlockProps, Y as defaultMermaidDiagramLabels } from '../video-block-Cg5EK_vS.js';
3
+ import { SlotComponent } from '../primitives/index.js';
4
4
  import * as React from 'react';
5
5
  import { ReactNode, RefObject, HTMLAttributes } from 'react';
6
- import { M as MdxFrameItemTone } from '../framed-block-DM5LLxO7.js';
6
+ import { MdxFrameItemTone } from '../primitives/index.js';
7
7
  export { CreditEntry, CreditsBlock, CreditsBlockProps } from './credits-block-entry.js';
8
8
  export { MediaCaption, MediaCaptionProps } from './media-caption-entry.js';
9
9
  import '@atom63/ui-react';
@@ -172,4 +172,5 @@ declare function MdxPageSkeleton({ className, showInlineToc, showRail, variant,
172
172
  declare const portableBlockNames: readonly ["Accordion", "Callout", "CodeBlock", "ColorSwatchItem", "Compare", "ComparisonPair", "CreditsBlock", "DemoStage", "ExampleContainer", "FigureBlock", "ImageCompare", "KeyIdea", "LayerStack", "MediaCaption", "MediaPlaceholder", "MdxPageSkeleton", "MermaidDiagram", "PageMeta", "PageTableOfContents", "ResourceList", "ScrollStage", "StatCard", "StatGrid", "Steps", "Tabs", "Timeline", "VideoBlock"];
173
173
  type PortableBlockName = (typeof portableBlockNames)[number];
174
174
 
175
- export { Compare, type CompareItemProps, type CompareProps, DemoConfigPanel, type DemoConfigPanelProps, DocExample, DocExampleCode, type DocExampleCodeProps, type DocExampleProps, ImageCompare, type ImageCompareImage, type ImageCompareProps, KeyIdea, type KeyIdeaProps, LayerStack, type LayerStackItem, type LayerStackLabels, type LayerStackProps, MdxPageSkeleton, type MdxPageSkeletonProps, type PortableBlockName, portableBlockNames };
175
+ export { Compare, DemoConfigPanel, DocExample, DocExampleCode, ImageCompare, KeyIdea, LayerStack, MdxPageSkeleton, portableBlockNames };
176
+ export type { CompareItemProps, CompareProps, DemoConfigPanelProps, DocExampleCodeProps, DocExampleProps, ImageCompareImage, ImageCompareProps, KeyIdeaProps, LayerStackItem, LayerStackLabels, LayerStackProps, MdxPageSkeletonProps, PortableBlockName };
@@ -1,4 +1,4 @@
1
- export { Accordion, Callout, CodeBlock, ColorSwatchItem, Compare, ComparisonPair, DemoConfigPanel, DemoStage, DocExample, DocExampleCode, ExampleContainer, FigureBlock, ImageCompare, KeyIdea, LayerStack, MdxPageSkeleton, MediaPlaceholder, MermaidDiagram, PageMeta, PageTableOfContents, ResourceList, ScrollStage, StatCard, StatGrid, Steps, Tabs, Timeline, VideoBlock, defaultMermaidDiagramLabels, portableBlockNames } from '../chunk-3FJTASAW.js';
1
+ export { Accordion, Callout, CodeBlock, ColorSwatchItem, Compare, ComparisonPair, DemoConfigPanel, DemoStage, DocExample, DocExampleCode, ExampleContainer, FigureBlock, ImageCompare, KeyIdea, LayerStack, MdxPageSkeleton, MediaPlaceholder, MermaidDiagram, PageMeta, PageTableOfContents, ResourceList, ScrollStage, StatCard, StatGrid, Steps, Tabs, Timeline, VideoBlock, defaultMermaidDiagramLabels, portableBlockNames } from '../chunk-WBFPTNBO.js';
2
2
  import '../chunk-WZ6US342.js';
3
3
  export { CreditsBlock } from '../chunk-DJSENA7Q.js';
4
4
  export { MediaCaption } from '../chunk-2RCEDZBB.js';
@@ -8,4 +8,5 @@ type MediaCaptionProps = {
8
8
  /** Consistent caption styling for all media blocks. */
9
9
  declare function MediaCaption({ children, className }: MediaCaptionProps): React.JSX.Element;
10
10
 
11
- export { MediaCaption, type MediaCaptionProps };
11
+ export { MediaCaption };
12
+ export type { MediaCaptionProps };
@@ -7,7 +7,7 @@ import { Accordion as Accordion$1, AccordionItem, AccordionTrigger, AccordionCon
7
7
  import { clsx } from 'clsx';
8
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
9
  import React, { createContext, forwardRef, lazy, useState, useRef, useEffect, Suspense, useContext, useMemo, useLayoutEffect, useId, useCallback, Children, isValidElement, cloneElement } from 'react';
10
- import { MoveVertical, MoveHorizontal, SlidersHorizontal, LayoutTemplate, Film, ImageIcon, ZoomOut, RotateCcw, ZoomIn, ListTree, ArrowUpRight } from 'lucide-react';
10
+ import { MoveVertical, MoveHorizontal, SlidersHorizontal, LayoutTemplate, Film, ImageIcon, ZoomOut, RotateCcw, ZoomIn, ListTree, Pause, Play, ArrowUpRight } from 'lucide-react';
11
11
  import { useReducedMotion, motion, AnimatePresence } from 'motion/react';
12
12
  import { createPortal } from 'react-dom';
13
13
 
@@ -2393,44 +2393,94 @@ var fitClasses = {
2393
2393
  contain: "object-contain",
2394
2394
  cover: "object-cover"
2395
2395
  };
2396
+ function trackLabelFor(lang) {
2397
+ try {
2398
+ return new Intl.DisplayNames([lang], { type: "language" }).of(lang) ?? lang;
2399
+ } catch {
2400
+ return lang;
2401
+ }
2402
+ }
2396
2403
  function VideoBlock({
2397
2404
  title,
2398
2405
  autoPlay = false,
2399
2406
  caption,
2407
+ captionPolicy,
2400
2408
  className,
2401
2409
  controls = true,
2402
2410
  fit = "contain",
2403
2411
  loop = false,
2404
2412
  muted = false,
2413
+ pauseLabel = "Pause video",
2414
+ playLabel = "Play video",
2405
2415
  showCaption = false,
2406
2416
  spacing = "default",
2407
2417
  src,
2418
+ trackLabel,
2419
+ trackLang = "en",
2408
2420
  trackSrc
2409
2421
  }) {
2422
+ const reducedMotion = useMdxReducedMotion();
2423
+ const videoRef = useRef(null);
2424
+ const [playing, setPlaying] = useState(false);
2410
2425
  const shouldMute = muted || autoPlay;
2426
+ const showToggle = autoPlay && !controls;
2427
+ const hidden = captionPolicy === "decorative" && !controls;
2411
2428
  return /* @__PURE__ */ jsx(
2412
2429
  MediaFigure,
2413
2430
  {
2414
2431
  caption: showCaption ? caption : void 0,
2415
2432
  className,
2416
2433
  spacing,
2417
- children: /* @__PURE__ */ jsx(MediaFrame, { className: "mdx-video-block", children: /* @__PURE__ */ jsx("div", { className: "mdx-video-stage relative aspect-video overflow-hidden", children: /* @__PURE__ */ jsxs(
2418
- "video",
2419
- {
2420
- "aria-label": title,
2421
- autoPlay,
2422
- className: clsx("h-full w-full", fitClasses[fit]),
2423
- controls,
2424
- loop,
2425
- muted: shouldMute,
2426
- playsInline: true,
2427
- preload: "metadata",
2428
- children: [
2429
- /* @__PURE__ */ jsx("source", { src, type: "video/mp4" }),
2430
- trackSrc ? /* @__PURE__ */ jsx("track", { default: true, kind: "captions", label: "English captions", src: trackSrc, srcLang: "en" }) : null
2431
- ]
2432
- }
2433
- ) }) })
2434
+ children: /* @__PURE__ */ jsx(MediaFrame, { className: "mdx-video-block", children: /* @__PURE__ */ jsxs("div", { className: "mdx-video-stage relative aspect-video overflow-hidden", children: [
2435
+ /* @__PURE__ */ jsxs(
2436
+ "video",
2437
+ {
2438
+ "aria-hidden": hidden || void 0,
2439
+ "aria-label": hidden ? void 0 : title,
2440
+ autoPlay: autoPlay && !reducedMotion,
2441
+ className: clsx("h-full w-full", fitClasses[fit]),
2442
+ controls,
2443
+ loop,
2444
+ muted: shouldMute,
2445
+ onPause: () => setPlaying(false),
2446
+ onPlay: () => setPlaying(true),
2447
+ playsInline: true,
2448
+ preload: "metadata",
2449
+ ref: videoRef,
2450
+ children: [
2451
+ /* @__PURE__ */ jsx("source", { src, type: "video/mp4" }),
2452
+ trackSrc ? /* @__PURE__ */ jsx(
2453
+ "track",
2454
+ {
2455
+ default: true,
2456
+ kind: "captions",
2457
+ label: trackLabel ?? trackLabelFor(trackLang),
2458
+ src: trackSrc,
2459
+ srcLang: trackLang
2460
+ }
2461
+ ) : null
2462
+ ]
2463
+ }
2464
+ ),
2465
+ showToggle ? /* @__PURE__ */ jsx(
2466
+ Button,
2467
+ {
2468
+ "aria-label": playing ? pauseLabel : playLabel,
2469
+ className: "mdx-video-toggle",
2470
+ onClick: () => {
2471
+ const video = videoRef.current;
2472
+ if (!video) return;
2473
+ if (playing) video.pause();
2474
+ else video.play().catch(() => void 0);
2475
+ },
2476
+ shape: "round",
2477
+ size: "icon-sm",
2478
+ type: "button",
2479
+ variant: "overlay",
2480
+ children: playing ? /* @__PURE__ */ jsx(Pause, { "aria-hidden": true }) : /* @__PURE__ */ jsx(Play, { "aria-hidden": true })
2481
+ }
2482
+ ) : null
2483
+ ] }) })
2434
2484
  }
2435
2485
  );
2436
2486
  }
@@ -2467,5 +2517,5 @@ var portableBlockNames = [
2467
2517
  ];
2468
2518
 
2469
2519
  export { Accordion, Callout, CodeBlock, ColorSwatchItem, Compare, ComparisonPair, ComparisonProvider, DemoConfigPanel, DemoStage, DocExample, DocExampleCode, ExampleContainer, ExampleContext, FigureBlock, ImageCompare, KeyIdea, LayerStack, MdxPageSkeleton, MediaPlaceholder, MermaidDiagram, PageMeta, PageTableOfContents, ResourceList, ScrollStage, StatCard, StatGrid, Steps, Tabs, Timeline, VideoBlock, defaultMermaidDiagramLabels, portableBlockNames, useComparisonContext, useIsInsideExample };
2470
- //# sourceMappingURL=chunk-3FJTASAW.js.map
2471
- //# sourceMappingURL=chunk-3FJTASAW.js.map
2520
+ //# sourceMappingURL=chunk-WBFPTNBO.js.map
2521
+ //# sourceMappingURL=chunk-WBFPTNBO.js.map