@sdxc/ui 2026.10.13 → 2026.10.15

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/README.md CHANGED
@@ -225,6 +225,8 @@ Every export carries JSDoc, so the editor shows each full signature.
225
225
  presets.
226
226
  - `AspectRatio`, `Resizable`, `ScrollArea`, `Carousel` — a ratio lock, split panes, a scroll region,
227
227
  and a scroll-snap slide set.
228
+ - `YouTubeEmbed` — a lazy-loaded 16:9 YouTube player (`videoId`, `start?`, `title`) served from
229
+ `www.youtube-nocookie.com`, which the page's `frame-src` has to allow.
228
230
  - `Text`, `Header`, `Keyboard`, `Typeset` — muted copy, a section label, a `<kbd>`, and typography
229
231
  for rendered markup (`docs`, `chat`, `reading`).
230
232
  - `ShortcutList` — a `<dl>` pairing actions with key caps.
@@ -165,8 +165,12 @@ export function zoom(options = {}) {
165
165
  }
166
166
  const DEFAULT_SLIDE_OPACITY = 0;
167
167
  const DEFAULT_SLIDE_DISTANCE = "0.5rem";
168
- /** Matches a plain signed length (`0.5rem`, `12px`, `50%`) whose number can be halved directly. */
169
- const PLAIN_LENGTH = /^(\d*\.?\d+)([a-z%]*)$/i;
168
+ /**
169
+ * Matches a plain length (`0.5rem`, `12px`, `.5em`, `50%`) whose number can be
170
+ * halved directly. The three numeric alternatives are mutually exclusive so a
171
+ * long run of digits still costs linear time when the string is not a length.
172
+ */
173
+ const PLAIN_LENGTH = /^(\d+\.\d+|\d+|\.\d+)([a-z%]*)$/i;
170
174
  /** Negates a length, keeping a plain length readable (`-0.5rem`) and wrapping anything else in `calc()`. */
171
175
  function negate(distance) {
172
176
  return PLAIN_LENGTH.test(distance) ? `-${distance}` : `calc(-1 * ${distance})`;
@@ -109,3 +109,4 @@ export * from "./toolbar.js";
109
109
  export * from "./tooltip.js";
110
110
  export * from "./tree.js";
111
111
  export * from "./typeset.js";
112
+ export * from "./youtube-embed.js";
@@ -109,3 +109,4 @@ export * from "./toolbar.js";
109
109
  export * from "./tooltip.js";
110
110
  export * from "./tree.js";
111
111
  export * from "./typeset.js";
112
+ export * from "./youtube-embed.js";
@@ -4,7 +4,7 @@ import { bg, border, borderEdge, fg, outline } from "@sdxc/u/color";
4
4
  import { rounded } from "@sdxc/u/effects";
5
5
  import { raw } from "@sdxc/u/general";
6
6
  import { block, container } from "@sdxc/u/layout";
7
- import { overflow } from "@sdxc/u/overflow";
7
+ import { overflow, overflowBlock, overflowInline } from "@sdxc/u/overflow";
8
8
  import { at } from "@sdxc/u/responsive";
9
9
  import { is, maxIs, pb, pi, pis } from "@sdxc/u/size";
10
10
  import { when } from "@sdxc/u/state";
@@ -251,7 +251,12 @@ export function Typeset(handle) {
251
251
  fg("neutral.emphasis"),
252
252
  pi("1em"),
253
253
  pb("0.875em"),
254
- overflow("auto"),
254
+ overflowInline("auto"),
255
+ overflowBlock("hidden"),
256
+ raw({
257
+ overscrollBehaviorInline: "contain",
258
+ overscrollBehaviorX: "contain",
259
+ }),
255
260
  ]),
256
261
  /**
257
262
  * A fenced block's `code` is an inline box, so the chip padding above would
@@ -0,0 +1,35 @@
1
+ /**
2
+ * A YouTube player sized to its container: a 16:9 `<iframe>` served from YouTube's
3
+ * privacy-enhanced host, so a visitor receives no YouTube cookies until they press play,
4
+ * and lazy-loaded so a video below the fold costs nothing until it scrolls into view.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Handle, Props as TagProps } from "remix/component";
10
+ /**
11
+ * Prop types for {@link YouTubeEmbed}.
12
+ */
13
+ export declare namespace YouTubeEmbed {
14
+ /**
15
+ * Props accepted by {@link YouTubeEmbed}.
16
+ */
17
+ interface Props extends Omit<TagProps<"iframe">, "src" | "title" | "allow" | "referrerpolicy" | "referrerPolicy"> {
18
+ /** The eleven-character id from the video's `watch?v=` or `youtu.be/` URL. */
19
+ videoId: string;
20
+ /** Seconds into the video the player starts at; zero or less starts at the beginning. */
21
+ start?: number;
22
+ /** The frame's accessible name, announced before a reader enters the player. */
23
+ title: string;
24
+ }
25
+ }
26
+ /**
27
+ * Renders the player filling its container's inline axis at 16:9. The frame always sends
28
+ * the embedding page's origin as referrer, without which YouTube refuses to play.
29
+ *
30
+ * @param handle Runtime handle carrying the host `<iframe>`'s props.
31
+ * @returns The render function producing the player's markup.
32
+ * @example <YouTubeEmbed videoId="dQw4w9WgXcQ" title={t("video.title")} />
33
+ * @example <YouTubeEmbed videoId="dQw4w9WgXcQ" start={90} title={t("video.title")} />
34
+ */
35
+ export declare function YouTubeEmbed(handle: Handle<YouTubeEmbed.Props>): () => import("remix/component").RemixElement;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "remix/component/jsx-runtime";
2
+ import { border } from "@sdxc/u/color";
3
+ import { rounded } from "@sdxc/u/effects";
4
+ import { block } from "@sdxc/u/layout";
5
+ import { aspect, is } from "@sdxc/u/size";
6
+ /** The host every player loads from; a page's `frame-src` has to allow it. */
7
+ const EMBED_ORIGIN = "https://www.youtube-nocookie.com";
8
+ /** Loading strategy {@link YouTubeEmbed} falls back to when `loading` is omitted. */
9
+ const DEFAULT_LOADING = "lazy";
10
+ /** The player features YouTube asks an embedding page to delegate. */
11
+ const ALLOWED_FEATURES = "accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";
12
+ /**
13
+ * Renders the player filling its container's inline axis at 16:9. The frame always sends
14
+ * the embedding page's origin as referrer, without which YouTube refuses to play.
15
+ *
16
+ * @param handle Runtime handle carrying the host `<iframe>`'s props.
17
+ * @returns The render function producing the player's markup.
18
+ * @example <YouTubeEmbed videoId="dQw4w9WgXcQ" title={t("video.title")} />
19
+ * @example <YouTubeEmbed videoId="dQw4w9WgXcQ" start={90} title={t("video.title")} />
20
+ */
21
+ export function YouTubeEmbed(handle) {
22
+ return () => {
23
+ let { videoId, start, title, loading, mix, ...rest } = handle.props;
24
+ let src = new URL(`/embed/${encodeURIComponent(videoId)}`, EMBED_ORIGIN);
25
+ if (start !== undefined && start >= 1)
26
+ src.searchParams.set("start", String(Math.floor(start)));
27
+ return (_jsx("iframe", { ...rest, "data-slot": "youtube-embed", src: src.href, title: title, loading: loading ?? DEFAULT_LOADING, referrerpolicy: "strict-origin-when-cross-origin", allow: ALLOWED_FEATURES, allowFullScreen: true, mix: [block(), is("full"), aspect("video"), border("none"), rounded("lg"), mix] }));
28
+ };
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/ui",
3
- "version": "2026.10.13",
3
+ "version": "2026.10.15",
4
4
  "description": "Styled, accessible remix/component components rendered as server HTML",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "@sdxc/uuid": "2026.10.13",
23
23
  "remix": "3.0.0"
24
24
  },
25
- "gitHead": "5ff758a57e35480a8db7abd24f1d9527b81bfb51",
25
+ "gitHead": "beb40c0508bf7ce7a13a884c14dc6b07299a6926",
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },