@sdxc/ui 2026.10.20 → 2026.10.23

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
@@ -229,7 +229,7 @@ Every export carries JSDoc, so the editor shows each full signature.
229
229
  - `YouTubeEmbed` — a lazy-loaded 16:9 YouTube player (`videoId`, `start?`, `title`) served from
230
230
  `www.youtube-nocookie.com`, which the page's `frame-src` has to allow.
231
231
  - `Text`, `Header`, `Keyboard`, `Typeset` — muted copy, a section label, a `<kbd>`, and typography
232
- for rendered markup (`docs`, `chat`, `reading`).
232
+ for rendered markup. `Typeset` sets the body at 18px (`docs`), 20px (`reading`) or 15px (`chat`).
233
233
  - `ShortcutList` — a `<dl>` pairing actions with key caps.
234
234
  - `Highlight` — `{ text, match }` segments rendered with each match in a `<mark>`.
235
235
  - `HeadingScope`, `Heading` — a heading-depth scope, and the `<h1>`–`<h6>` that reads it.
@@ -7,6 +7,7 @@
7
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
8
8
  * @copyright Sergio Xalambrí 2026
9
9
  */
10
+ import { iife } from "@sdxc/iife";
10
11
  import { TypedEventTarget } from "remix/component";
11
12
  import { dispatchChange } from "../utils/dispatch-change.js";
12
13
  const DEFAULT_QUERY = "";
@@ -166,11 +167,11 @@ export class FilterModel extends TypedEventTarget {
166
167
  return;
167
168
  }
168
169
  let index = this.#matches.findIndex((option) => option.id === this.#activeId);
169
- let nextIndex = index === -1
170
- ? delta > 0
171
- ? 0
172
- : this.#matches.length - 1
173
- : (index + delta + this.#matches.length) % this.#matches.length;
170
+ let nextIndex = iife(() => {
171
+ if (index === -1)
172
+ return delta > 0 ? 0 : this.#matches.length - 1;
173
+ return (index + delta + this.#matches.length) % this.#matches.length;
174
+ });
174
175
  let nextOption = this.#matches[nextIndex];
175
176
  if (nextOption === undefined)
176
177
  return;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "remix/component/jsx-runtime";
2
+ import { iife } from "@sdxc/iife";
2
3
  import { bg, border, fg, outline } from "@sdxc/u/color";
3
4
  import { rounded, transition } from "@sdxc/u/effects";
4
5
  import { raw } from "@sdxc/u/general";
@@ -272,7 +273,14 @@ Attachment.Trigger = function AttachmentTrigger(handle) {
272
273
  return () => {
273
274
  let { href, commandfor, command, target, role, tabIndex, children, mix, ...rest } = handle.props;
274
275
  let isConfigured = href !== undefined || commandfor !== undefined;
275
- let resolvedRole = role ?? (href !== undefined ? "link" : isConfigured ? "button" : undefined);
276
+ let inferredRole = iife(() => {
277
+ if (href !== undefined)
278
+ return "link";
279
+ if (isConfigured)
280
+ return "button";
281
+ return undefined;
282
+ });
283
+ let resolvedRole = role ?? inferredRole;
276
284
  let resolvedTabIndex = tabIndex ?? (isConfigured ? 0 : undefined);
277
285
  if (import.meta.env?.DEV && !isConfigured) {
278
286
  console.warn('Attachment.Trigger: rendered with neither "href" nor "commandfor" — nothing will happen once `attachmentTrigger()` handles an activation.');
@@ -47,7 +47,7 @@ export declare namespace Sidebar {
47
47
  /**
48
48
  * Every native `<div>` attribute, plus the `mix` passthrough. Establishes
49
49
  * the shell's row layout — {@link Sidebar} beside {@link Sidebar.Inset} —
50
- * plus the {@link PROVIDER_CONTAINER_NAME} container and `:checked` collapse rules.
50
+ * plus the {@link PROVIDER_CONTAINER_NAME} container the collapse rules query.
51
51
  */
52
52
  interface ProviderProps extends TagProps<"div"> {
53
53
  /** {@link Sidebar} and {@link Sidebar.Inset}, in either order. */
@@ -242,9 +242,9 @@ export declare namespace Sidebar {
242
242
  }
243
243
  }
244
244
  /**
245
- * Renders the rail itself: a native `<aside>` sized and styled through its
246
- * `data-variant`, `data-collapsible`, and `data-side` attributes, with
247
- * every collapse rule keyed off {@link Sidebar.Provider}'s `:has()` state.
245
+ * Renders the rail itself: a native `<aside>` styled through its `data-*`
246
+ * attributes, with collapse rules keyed off {@link Sidebar.Provider}'s `:has()`
247
+ * state and declared after its base size, so both directions animate.
248
248
  *
249
249
  * @param handle Runtime handle carrying the host `<aside>`'s props.
250
250
  * @returns The render function producing the rail's markup.
@@ -58,7 +58,7 @@ const WIDE_SHELL_QUERY = `@container ${PROVIDER_CONTAINER_NAME} (min-width: 48re
58
58
  /**
59
59
  * Selector matching {@link Sidebar.Trigger}'s own checkbox input once it
60
60
  * carries the platform's native `:checked` state — the single source of
61
- * truth every collapse-driven rule in {@link Sidebar.Provider} reads from.
61
+ * truth every collapse-driven rule in {@link Sidebar} reads from.
62
62
  */
63
63
  const TOGGLE_CHECKED_SELECTOR = '[data-slot="toggle"]:checked';
64
64
  /**
@@ -70,9 +70,9 @@ function resolveAriaCurrent(current, ariaCurrent) {
70
70
  return ariaCurrent ?? (current ? "page" : undefined);
71
71
  }
72
72
  /**
73
- * Renders the rail itself: a native `<aside>` sized and styled through its
74
- * `data-variant`, `data-collapsible`, and `data-side` attributes, with
75
- * every collapse rule keyed off {@link Sidebar.Provider}'s `:has()` state.
73
+ * Renders the rail itself: a native `<aside>` styled through its `data-*`
74
+ * attributes, with collapse rules keyed off {@link Sidebar.Provider}'s `:has()`
75
+ * state and declared after its base size, so both directions animate.
76
76
  *
77
77
  * @param handle Runtime handle carrying the host `<aside>`'s props.
78
78
  * @returns The render function producing the rail's markup.
@@ -128,14 +128,39 @@ export function Sidebar(handle) {
128
128
  }),
129
129
  data("variant", "floating", [rounded("xl"), border({ color: "neutral", width: 1 })]),
130
130
  data("variant", "inset", [rounded("xl"), border({ color: "neutral", width: 1 })]),
131
+ when(`[data-slot="provider"]:has(${TOGGLE_CHECKED_SELECTOR}) &`, [
132
+ when('&[data-collapsible="icon"]', [
133
+ is(varUtility("sidebar-width-icon", "3rem")),
134
+ when("[data-sidebar-collapsed-hide]", visuallyHidden()),
135
+ when('[data-slot="group-label"]', visuallyHidden()),
136
+ when('[data-slot="menu-badge"]', hidden()),
137
+ when('[data-slot="menu-sub"]', hidden()),
138
+ when('[data-slot="menu-button"], [data-slot="menu-link"]', [
139
+ justify("center"),
140
+ pi("0"),
141
+ ]),
142
+ ]),
143
+ when('&[data-collapsible="offcanvas"][data-side="left"]', [
144
+ translateX("-100%"),
145
+ is("0"),
146
+ overflow("hidden"),
147
+ border({ width: "0", noStyleDefault: true }),
148
+ ]),
149
+ when('&[data-collapsible="offcanvas"][data-side="right"]', [
150
+ translateX("100%"),
151
+ is("0"),
152
+ overflow("hidden"),
153
+ border({ width: "0", noStyleDefault: true }),
154
+ ]),
155
+ ]),
131
156
  mix,
132
157
  ] }));
133
158
  };
134
159
  }
135
160
  /**
136
161
  * Renders the shell's layout root: a flex row placing {@link Sidebar} beside
137
- * {@link Sidebar.Inset}, hosting every collapse rule keyed purely off
138
- * {@link Sidebar.Trigger}'s checkbox reaching `:checked` in this subtree.
162
+ * {@link Sidebar.Inset}, whose subtree {@link Sidebar} watches for
163
+ * {@link Sidebar.Trigger}'s checkbox reaching `:checked`.
139
164
  *
140
165
  * @param handle Runtime handle carrying the host `<div>`'s props.
141
166
  * @returns The render function producing the shell's markup.
@@ -168,31 +193,6 @@ Sidebar.Provider = function SidebarProvider(handle) {
168
193
  items("stretch"),
169
194
  minBs("100dvh"),
170
195
  is("full"),
171
- when(`&:has(${TOGGLE_CHECKED_SELECTOR})`, [
172
- when('[data-slot="sidebar"][data-collapsible="icon"]', [
173
- is(varUtility("sidebar-width-icon", "3rem")),
174
- when("[data-sidebar-collapsed-hide]", visuallyHidden()),
175
- when('[data-slot="group-label"]', visuallyHidden()),
176
- when('[data-slot="menu-badge"]', hidden()),
177
- when('[data-slot="menu-sub"]', hidden()),
178
- when('[data-slot="menu-button"], [data-slot="menu-link"]', [
179
- justify("center"),
180
- pi("0"),
181
- ]),
182
- ]),
183
- when('[data-slot="sidebar"][data-collapsible="offcanvas"][data-side="left"]', [
184
- translateX("-100%"),
185
- is("0"),
186
- overflow("hidden"),
187
- border({ width: "0", noStyleDefault: true }),
188
- ]),
189
- when('[data-slot="sidebar"][data-collapsible="offcanvas"][data-side="right"]', [
190
- translateX("100%"),
191
- is("0"),
192
- overflow("hidden"),
193
- border({ width: "0", noStyleDefault: true }),
194
- ]),
195
- ]),
196
196
  container(PROVIDER_CONTAINER_NAME),
197
197
  mix,
198
198
  ] }));
@@ -14,9 +14,9 @@ import type { Handle, Props as TagProps } from "remix/component";
14
14
  */
15
15
  export declare namespace Typeset {
16
16
  /**
17
- * Rhythm context: `"docs"` is the spacious default, `"chat"` tightens the
18
- * scale for a conversational bubble's denser turn-taking, and `"reading"`
19
- * opens both further for a long-form article.
17
+ * Rhythm context. `"docs"` sets the body at 18px, the size for a page meant
18
+ * to be read. `"reading"` sets it at 20px for a long-form article. `"chat"`
19
+ * sets it at 15px for a turn in a denser column.
20
20
  */
21
21
  type Preset = "docs" | "chat" | "reading";
22
22
  /**
@@ -19,6 +19,21 @@ import { easings } from "../animations/tokens.js";
19
19
  const CONTAINER_NAME = "ui-typeset";
20
20
  /** Rhythm context {@link Typeset} falls back to when `preset` is omitted. */
21
21
  const DEFAULT_PRESET = "docs";
22
+ /**
23
+ * Body size each preset writes to `--ui-typeset-size`. On a 16px root, `docs`
24
+ * is 18px and `reading` is 20px, so long-form copy is large enough to read;
25
+ * `chat` is 15px for a turn taken in a denser column.
26
+ */
27
+ const PRESET_BODY_SIZE = {
28
+ docs: "1.125rem",
29
+ chat: "0.9375rem",
30
+ reading: "1.25rem",
31
+ };
32
+ /**
33
+ * Size body copy and headings compute from. Clearing `--ui-typeset-size`
34
+ * still leaves the docs body, which is the preset a host uses by default.
35
+ */
36
+ const TYPESET_SIZE = `var(--ui-typeset-size, ${PRESET_BODY_SIZE.docs})`;
22
37
  /** CSS length each edge of a wide table's own fade tapers over. */
23
38
  const TABLE_FADE_SIZE = "2.5rem";
24
39
  /**
@@ -87,20 +102,20 @@ export function Typeset(handle) {
87
102
  container(CONTAINER_NAME),
88
103
  keyframes(TABLE_FADE_KEYFRAMES_NAME, TABLE_FADE_KEYFRAMES),
89
104
  raw({
90
- fontSize: "var(--ui-typeset-size, 1rem)",
105
+ fontSize: TYPESET_SIZE,
91
106
  lineHeight: "var(--ui-typeset-leading, 1.75)",
92
107
  '&[data-preset="docs"]': {
93
- "--ui-typeset-size": "1rem",
108
+ "--ui-typeset-size": PRESET_BODY_SIZE.docs,
94
109
  "--ui-typeset-leading": "1.75",
95
110
  "--ui-typeset-flow": "1.25em",
96
111
  },
97
112
  '&[data-preset="chat"]': {
98
- "--ui-typeset-size": "0.9375rem",
113
+ "--ui-typeset-size": PRESET_BODY_SIZE.chat,
99
114
  "--ui-typeset-leading": "1.5",
100
115
  "--ui-typeset-flow": "0.75em",
101
116
  },
102
117
  '&[data-preset="reading"]': {
103
- "--ui-typeset-size": "1.125rem",
118
+ "--ui-typeset-size": PRESET_BODY_SIZE.reading,
104
119
  "--ui-typeset-leading": "1.8",
105
120
  "--ui-typeset-flow": "1.5em",
106
121
  },
@@ -111,22 +126,22 @@ export function Typeset(handle) {
111
126
  marginBlockStart: "var(--ui-typeset-flow, 1.25em)",
112
127
  },
113
128
  "& :where(h1)": {
114
- fontSize: "calc(var(--ui-typeset-size, 1rem) * 2)",
129
+ fontSize: `calc(${TYPESET_SIZE} * 2)`,
115
130
  },
116
131
  "& :where(h2)": {
117
- fontSize: "calc(var(--ui-typeset-size, 1rem) * 1.5)",
132
+ fontSize: `calc(${TYPESET_SIZE} * 1.5)`,
118
133
  },
119
134
  "& :where(h3)": {
120
- fontSize: "calc(var(--ui-typeset-size, 1rem) * 1.25)",
135
+ fontSize: `calc(${TYPESET_SIZE} * 1.25)`,
121
136
  },
122
137
  "& :where(h4)": {
123
- fontSize: "calc(var(--ui-typeset-size, 1rem) * 1.125)",
138
+ fontSize: `calc(${TYPESET_SIZE} * 1.125)`,
124
139
  },
125
140
  "& :where(h5)": {
126
- fontSize: "var(--ui-typeset-size, 1rem)",
141
+ fontSize: TYPESET_SIZE,
127
142
  },
128
143
  "& :where(h6)": {
129
- fontSize: "calc(var(--ui-typeset-size, 1rem) * 0.875)",
144
+ fontSize: `calc(${TYPESET_SIZE} * 0.875)`,
130
145
  },
131
146
  "& :where(ul)": {
132
147
  listStyleType: "disc",
@@ -131,7 +131,6 @@ export const calendarKeys = createMixin((handle) => {
131
131
  case "End":
132
132
  event.preventDefault();
133
133
  model.focusMonthEnd();
134
- return;
135
134
  }
136
135
  }),
137
136
  ],
@@ -256,7 +256,6 @@ export const carouselControls = createMixin((handle) => {
256
256
  let index = readGotoSlideIndex(commandEvent.source);
257
257
  if (index !== null)
258
258
  scrollToSlide(viewport, index);
259
- return;
260
259
  }
261
260
  }
262
261
  }),
@@ -50,9 +50,7 @@ export const contextMenu = createMixin((handle) => {
50
50
  cleanupAnchor = anchor(surface, point, { placement: DEFAULT_PLACEMENT, ...options });
51
51
  }
52
52
  return (id, options = {}, props = options) => {
53
- if (props === options) {
54
- options = {};
55
- }
53
+ let resolved = props === options ? {} : options;
56
54
  return createElement(handle.element, {
57
55
  mix: [
58
56
  attrs({ "aria-controls": id, "aria-haspopup": "menu" }),
@@ -65,10 +63,10 @@ export const contextMenu = createMixin((handle) => {
65
63
  event.preventDefault();
66
64
  let point = { x: event.clientX, y: event.clientY };
67
65
  if (event.button !== SECONDARY_BUTTON) {
68
- openSurfaceAt(id, point, options);
66
+ openSurfaceAt(id, point, resolved);
69
67
  return;
70
68
  }
71
- document.addEventListener("pointerup", () => openSurfaceAt(id, point, options), {
69
+ document.addEventListener("pointerup", () => openSurfaceAt(id, point, resolved), {
72
70
  capture: true,
73
71
  once: true,
74
72
  signal: lifetime,
@@ -79,7 +77,7 @@ export const contextMenu = createMixin((handle) => {
79
77
  return;
80
78
  event.preventDefault();
81
79
  let rect = event.currentTarget.getBoundingClientRect();
82
- openSurfaceAt(id, { x: rect.left, y: rect.top, width: rect.width, height: rect.height }, options);
80
+ openSurfaceAt(id, { x: rect.left, y: rect.top, width: rect.width, height: rect.height }, resolved);
83
81
  }),
84
82
  ],
85
83
  });
@@ -103,13 +103,11 @@ export const dismiss = createMixin((handle) => {
103
103
  scheduleRemaining();
104
104
  }
105
105
  return (options = {}, props = options) => {
106
- if (props === options) {
107
- options = {};
108
- }
109
- let pauseOnHover = options.pauseOnHover ?? true;
106
+ let resolved = props === options ? {} : options;
107
+ let pauseOnHover = resolved.pauseOnHover ?? true;
110
108
  if (!initialized) {
111
109
  initialized = true;
112
- duration = options.duration === undefined ? DEFAULT_DURATION : options.duration;
110
+ duration = resolved.duration === undefined ? DEFAULT_DURATION : resolved.duration;
113
111
  if (duration !== null) {
114
112
  remaining = duration;
115
113
  scheduleRemaining();
@@ -276,7 +276,6 @@ export const gridListKeys = createMixin((handle) => {
276
276
  return;
277
277
  event.preventDefault();
278
278
  model.selectAll();
279
- return;
280
279
  }
281
280
  }),
282
281
  ],
@@ -84,10 +84,8 @@ export const longPress = createMixin((handle) => {
84
84
  origin = undefined;
85
85
  }
86
86
  return (options = {}, props = options) => {
87
- if (props === options) {
88
- options = {};
89
- }
90
- let duration = options.duration ?? DEFAULT_DURATION;
87
+ let resolved = props === options ? {} : options;
88
+ let duration = resolved.duration ?? DEFAULT_DURATION;
91
89
  return createElement(handle.element, {
92
90
  mix: [
93
91
  on("pointerdown", (event) => {
@@ -47,9 +47,8 @@ export const menuKeys = createMixin((_handle) => {
47
47
  let buffer = "";
48
48
  let resetBufferId;
49
49
  return (options = {}, props = options) => {
50
- if (props === options)
51
- options = {};
52
- let selector = options.itemSelector ?? DEFAULT_ITEM_SELECTOR;
50
+ let resolved = props === options ? {} : options;
51
+ let selector = resolved.itemSelector ?? DEFAULT_ITEM_SELECTOR;
53
52
  return ref((host, signal) => {
54
53
  let initialItems = queryItems(host, selector);
55
54
  if (initialItems.length > 0)
@@ -122,10 +122,9 @@ export const menubarKeys = createMixin((_handle) => {
122
122
  let buffer = "";
123
123
  let resetBufferId;
124
124
  return (options = {}, props = options) => {
125
- if (props === options)
126
- options = {};
127
- let triggerSelector = options.triggerSelector ?? DEFAULT_TRIGGER_SELECTOR;
128
- let itemSelector = options.itemSelector ?? DEFAULT_ITEM_SELECTOR;
125
+ let resolved = props === options ? {} : options;
126
+ let triggerSelector = resolved.triggerSelector ?? DEFAULT_TRIGGER_SELECTOR;
127
+ let itemSelector = resolved.itemSelector ?? DEFAULT_ITEM_SELECTOR;
129
128
  return ref((host, signal) => {
130
129
  let initialTriggers = queryTriggers(host, triggerSelector);
131
130
  if (initialTriggers.length > 0)
@@ -170,7 +170,6 @@ function fulfillScrollRequest(host, request) {
170
170
  block: request.align,
171
171
  behavior: request.smooth ? resolveScrollBehavior() : "instant",
172
172
  });
173
- return;
174
173
  }
175
174
  }
176
175
  }
@@ -126,10 +126,8 @@ function applyMode(mode) {
126
126
  */
127
127
  export const themeToggle = createMixin((handle) => {
128
128
  return (options = {}, props = options) => {
129
- if (props === options) {
130
- options = {};
131
- }
132
- let cookieName = options.cookieName ?? THEME_COOKIE_NAME;
129
+ let resolved = props === options ? {} : options;
130
+ let cookieName = resolved.cookieName ?? THEME_COOKIE_NAME;
133
131
  return createElement(handle.element, {
134
132
  mix: [
135
133
  on("command", (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/ui",
3
- "version": "2026.10.20",
3
+ "version": "2026.10.23",
4
4
  "description": "Styled, accessible remix/component components rendered as server HTML",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,13 +19,14 @@
19
19
  "dependencies": {
20
20
  "@remix-run/ui": "0.12.1",
21
21
  "@sdxc/icons": "2026.10.20",
22
- "@sdxc/u": "2026.10.20",
22
+ "@sdxc/iife": "2026.10.23",
23
+ "@sdxc/u": "2026.10.23",
23
24
  "@sdxc/uuid": "2026.10.13"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "remix": "3.0.0"
27
28
  },
28
- "gitHead": "bd4473246f405c43055d2fc5e08c62ba35197258",
29
+ "gitHead": "8e428ddf15290d44500a9618ec4d04bd7629fa99",
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  },