@fusion.dev/helix-headless 0.33.4 → 0.33.5

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.
@@ -9526,6 +9526,20 @@
9526
9526
  "kind": "class",
9527
9527
  "description": "The track is a scroller with scroll snapping, so a drag, a trackpad swipe,\nand the browser's own momentum all work without being reimplemented. The\ncontrols scroll it; they do not drive a transform.\n\nSlides are the consumer's own elements, and nothing is written onto them. The\ncomponent renders a pane per slide carrying `role=\"group\"`,\n`aria-roledescription=\"slide\"` and a name reading its position in the set,\nand assigns the slide into it: a screen-reader user hears where they are, and\na slide that is itself a link is still a link. See `assign`.\n\n**Rotation stops on focus and on hover, and once stopped it stays stopped.**\nThe APG is explicit: rotation must not resume unless the reader asks for it,\nso hovering away does not start it again. The control names the action it\nperforms, and it is first in the tab order.",
9528
9528
  "name": "HelixHeadlessCarousel",
9529
+ "cssProperties": [
9530
+ {
9531
+ "description": "Space between slides. A sheet sets it and the component measures the run with it.",
9532
+ "name": "--carousel-gap"
9533
+ },
9534
+ {
9535
+ "description": "The size one pane is laid out at. A sheet sets it and the component measures the run with it.",
9536
+ "name": "--carousel-pane"
9537
+ },
9538
+ {
9539
+ "description": "How far short of a whole pixel the run ends, on the last slide alone, for a sheet to take up as `margin-inline-end`. See `runEnd`.",
9540
+ "name": "--carousel-run-end"
9541
+ }
9542
+ ],
9529
9543
  "cssParts": [
9530
9544
  {
9531
9545
  "description": "The row of controls.",
@@ -9966,6 +9980,17 @@
9966
9980
  },
9967
9981
  "description": "Puts each slide into the pane rendered for it.\n\n**The panes carry the ARIA and the consumer's element carries none**, which\nis the whole reason this is a manual assignment rather than a plain slot.\nThe APG wants each slide to be a `group` with `aria-roledescription=\"slide\"`\nand a name saying where it sits in the run, and writing those onto the\nelements a consumer wrote fails twice, only one of them about frameworks.\n\n**A React consumer's slides are nodes React is in the middle of hydrating.**\nAttributes landing before React reaches them are a DOM it did not render,\nwhich it reports as a mismatch and will not patch up: the ARIA survives and\nthe announcement is correct, so the console is the only tell. Deferring the\nwrite does not help, a frame being a race rather than an ordering: measured\nin Chromium on the landing page, a tab opened in the foreground still\nreported the mismatch and a tab opened hidden did not, only because\n`requestAnimationFrame` had not run there yet. `Chat`'s comment on\n`shadowRootOptions` reaches the same conclusion.\n\n**And `role=\"group\"` on a consumer's `<a href>` is not additive.** It\nreplaces the implicit link role, so six insight cards on the landing page\nannounced as groups and left the links list entirely. No amount of\ndeferring helps, because the write is the bug. A pane around the slide is\nwhat the pattern actually asks for: a group holding a link, rather than a\nlink relabeled as a group."
9968
9982
  },
9983
+ {
9984
+ "kind": "method",
9985
+ "name": "runEnd",
9986
+ "privacy": "private",
9987
+ "return": {
9988
+ "type": {
9989
+ "text": "string | typeof nothing"
9990
+ }
9991
+ },
9992
+ "description": "How far short of a whole pixel the run of slides ends, for the last one.\n\n**The run has to end on a whole pixel, because a right-to-left track cannot\nreach a fraction.** Three across 692 makes the run 450.66 longer than the\ntrack. Chromium measures a right-to-left scroller from its far end and\nfloors that length, so the track stops at -450 where a left-to-right one\nrounds to 451, and two thirds of a pixel of the slide before stays at the\nleading edge. Ending on a whole pixel, the far end is one number both ways\nand the last place rests on it in both, so a swipe to the end stops there\ntoo.\n\n**Here rather than in a stylesheet, because the count is the component's.**\nThe arithmetic wants how many slides there are, and CSS can only ask\n`sibling-count()`, which is Chromium-only, evaluates to 0 through\n`::part()`, and needs a `:last-child` that `::part()` cannot carry either.\nSo the styled tier could correct its run and a consumer writing their own\nseveral-across sheet could not: measured in Chromium at three across, the\nheadless tier rested at 451 against -450 while the styled tier rested at\none number both ways. Published from here, one declaration reading this\ngets both tiers and any consumer to the same place.\n\n**WebKit takes the margin and does not need it**, which is the reason a\ncorrection written in CSS looked like enough. It has no `sibling-count()`\nat all, so nothing reached that engine, and its track rested on one number\nboth ways anyway. Measured with the margin in place, the same widths:\nevery resting place is the number it was without it.\n\n**On the last slide alone, which is what makes that one declaration\nenough.** A sheet writes `margin-inline-end: var(--carousel-run-end, 0px)`\nacross every pane and the fallback answers on all but the last, so nothing\nhas to select a slide by its position in the run.\n\n**A sheet says how wide a pane is and how far apart they sit, and this\nreads both back.** Set neither and the correction is invalid at\ncomputed-value time, which is the fallback rather than a broken margin. The\npercentage resolves where the value is used, on the last pane, so it is the\ntrack's content box and not the track's own containing block: the width the\nrun is actually measured against.\n\nHorizontal only. A vertical track scrolls the other axis, `scrollTop`\ncounts up from zero whatever the writing mode, and there is no far end to\nfloor."
9993
+ },
9969
9994
  {
9970
9995
  "kind": "field",
9971
9996
  "name": "tier",
@@ -10402,6 +10427,10 @@
10402
10427
  {
10403
10428
  "description": "The same carousel on the headless tier, with every rule written by hand.",
10404
10429
  "slug": "preview"
10430
+ },
10431
+ {
10432
+ "description": "Three slides across, with the pane, the gap and the run's end written by hand.",
10433
+ "slug": "several-across"
10405
10434
  }
10406
10435
  ],
10407
10436
  "source": "helix/headless/src/carousel"
@@ -41,6 +41,10 @@ import { type PropertyValues, type TemplateResult } from 'lit';
41
41
  * @csspart rotation-mark - The glyph on the play and pause control.
42
42
  * @csspart slide - The pane one slide is shown in, and the box the track snaps to.
43
43
  * @csspart track - The scroller the slides sit in.
44
+ *
45
+ * @cssproperty --carousel-gap - Space between slides. A sheet sets it and the component measures the run with it.
46
+ * @cssproperty --carousel-pane - The size one pane is laid out at. A sheet sets it and the component measures the run with it.
47
+ * @cssproperty --carousel-run-end - How far short of a whole pixel the run ends, on the last slide alone, for a sheet to take up as `margin-inline-end`. See `runEnd`.
44
48
  */
45
49
  export declare class HelixHeadlessCarousel extends HelixElement {
46
50
  /**
@@ -394,6 +398,51 @@ export declare class HelixHeadlessCarousel extends HelixElement {
394
398
  * link relabeled as a group.
395
399
  */
396
400
  private assign;
401
+ /**
402
+ * How far short of a whole pixel the run of slides ends, for the last one.
403
+ *
404
+ * **The run has to end on a whole pixel, because a right-to-left track cannot
405
+ * reach a fraction.** Three across 692 makes the run 450.66 longer than the
406
+ * track. Chromium measures a right-to-left scroller from its far end and
407
+ * floors that length, so the track stops at -450 where a left-to-right one
408
+ * rounds to 451, and two thirds of a pixel of the slide before stays at the
409
+ * leading edge. Ending on a whole pixel, the far end is one number both ways
410
+ * and the last place rests on it in both, so a swipe to the end stops there
411
+ * too.
412
+ *
413
+ * **Here rather than in a stylesheet, because the count is the component's.**
414
+ * The arithmetic wants how many slides there are, and CSS can only ask
415
+ * `sibling-count()`, which is Chromium-only, evaluates to 0 through
416
+ * `::part()`, and needs a `:last-child` that `::part()` cannot carry either.
417
+ * So the styled tier could correct its run and a consumer writing their own
418
+ * several-across sheet could not: measured in Chromium at three across, the
419
+ * headless tier rested at 451 against -450 while the styled tier rested at
420
+ * one number both ways. Published from here, one declaration reading this
421
+ * gets both tiers and any consumer to the same place.
422
+ *
423
+ * **WebKit takes the margin and does not need it**, which is the reason a
424
+ * correction written in CSS looked like enough. It has no `sibling-count()`
425
+ * at all, so nothing reached that engine, and its track rested on one number
426
+ * both ways anyway. Measured with the margin in place, the same widths:
427
+ * every resting place is the number it was without it.
428
+ *
429
+ * **On the last slide alone, which is what makes that one declaration
430
+ * enough.** A sheet writes `margin-inline-end: var(--carousel-run-end, 0px)`
431
+ * across every pane and the fallback answers on all but the last, so nothing
432
+ * has to select a slide by its position in the run.
433
+ *
434
+ * **A sheet says how wide a pane is and how far apart they sit, and this
435
+ * reads both back.** Set neither and the correction is invalid at
436
+ * computed-value time, which is the fallback rather than a broken margin. The
437
+ * percentage resolves where the value is used, on the last pane, so it is the
438
+ * track's content box and not the track's own containing block: the width the
439
+ * run is actually measured against.
440
+ *
441
+ * Horizontal only. A vertical track scrolls the other axis, `scrollTop`
442
+ * counts up from zero whatever the writing mode, and there is no far end to
443
+ * floor.
444
+ */
445
+ private runEnd;
397
446
  protected render(): TemplateResult;
398
447
  }
399
448
  declare global {
@@ -241,8 +241,17 @@ let HelixHeadlessCarousel = class HelixHeadlessCarousel extends HelixElement {
241
241
  panes[index]?.assign?.(slide);
242
242
  });
243
243
  }
244
+ runEnd() {
245
+ if (this.orientation === 'vertical') {
246
+ return nothing;
247
+ }
248
+ const run = `${this.slides.length} * (var(--carousel-pane) + var(--carousel-gap))` +
249
+ ' - var(--carousel-gap) - 100%';
250
+ return `--carousel-run-end: calc(round(${run}, 1px) - (${run}))`;
251
+ }
244
252
  render() {
245
253
  const rotating = this.rotating;
254
+ const last = this.slides.length - 1;
246
255
  return html `<div part="controls">
247
256
  ${this.autoplay
248
257
  ? html `<button
@@ -297,6 +306,7 @@ let HelixHeadlessCarousel = class HelixHeadlessCarousel extends HelixElement {
297
306
  role="group"
298
307
  aria-roledescription="slide"
299
308
  aria-label=${`${index + 1} of ${this.slides.length}`}
309
+ style=${index === last ? this.runEnd() : nothing}
300
310
  >
301
311
  <slot
302
312
  name=${this.assignsByName ? `slide-${index + 1}` : nothing}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fusion.dev/helix-headless",
3
3
  "description": "Headless component tier. Structure, accessibility, state, and form participation. No styling.",
4
- "version": "0.33.4",
4
+ "version": "0.33.5",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -46,14 +46,14 @@
46
46
  },
47
47
  "bugs": "https://github.com/project-fusion/fusion/issues",
48
48
  "dependencies": {
49
- "@fusion.dev/helix-core": "0.33.4",
50
- "@fusion.dev/helix-icons": "0.33.4",
49
+ "@fusion.dev/helix-core": "0.33.5",
50
+ "@fusion.dev/helix-icons": "0.33.5",
51
51
  "uqr": "^0.1.3"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@custom-elements-manifest/analyzer": "^0.11.0",
55
- "@fusion.dev/helix-cem": "0.33.4",
56
- "@fusion.dev/helix-testing": "0.33.4",
55
+ "@fusion.dev/helix-cem": "0.33.5",
56
+ "@fusion.dev/helix-testing": "0.33.5",
57
57
  "@fusion.dev/scripts": "0.0.0-dev",
58
58
  "@happy-dom/global-registrator": "^20.0.0",
59
59
  "@lit-labs/ssr": "^4.1.0",
package/types/jsx.d.ts CHANGED
@@ -18781,6 +18781,14 @@ export type CustomElements = {
18781
18781
  *
18782
18782
  * - `goTo(index: number) => void`: Moves to a slide, wrapping only where `loop` says to.
18783
18783
  *
18784
+ * ## CSS Custom Properties
18785
+ *
18786
+ * CSS variables available for styling the component.
18787
+ *
18788
+ * - `--carousel-gap`: Space between slides. A sheet sets it and the component measures the run with it. (default: `undefined`)
18789
+ * - `--carousel-pane`: The size one pane is laid out at. A sheet sets it and the component measures the run with it. (default: `undefined`)
18790
+ * - `--carousel-run-end`: How far short of a whole pixel the run ends, on the last slide alone, for a sheet to take up as `margin-inline-end`. See `runEnd`. (default: `undefined`)
18791
+ *
18784
18792
  * ## CSS Parts
18785
18793
  *
18786
18794
  * Custom selectors for styling elements within the component.
@@ -36172,6 +36180,14 @@ export type CustomElementsSolidJs = {
36172
36180
  *
36173
36181
  * - `goTo(index: number) => void`: Moves to a slide, wrapping only where `loop` says to.
36174
36182
  *
36183
+ * ## CSS Custom Properties
36184
+ *
36185
+ * CSS variables available for styling the component.
36186
+ *
36187
+ * - `--carousel-gap`: Space between slides. A sheet sets it and the component measures the run with it. (default: `undefined`)
36188
+ * - `--carousel-pane`: The size one pane is laid out at. A sheet sets it and the component measures the run with it. (default: `undefined`)
36189
+ * - `--carousel-run-end`: How far short of a whole pixel the run ends, on the last slide alone, for a sheet to take up as `margin-inline-end`. See `runEnd`. (default: `undefined`)
36190
+ *
36175
36191
  * ## CSS Parts
36176
36192
  *
36177
36193
  * Custom selectors for styling elements within the component.
@@ -51967,6 +51983,12 @@ export type CustomCssProperties = {
51967
51983
  "--bar-chart-secondary"?: (string) | undefined;
51968
51984
  /** The gradient a bar would take, named per bar so the styled tier can point `fill` at it. Drawn whatever the treatment and used only where `wash="gradient"` asks for it. */
51969
51985
  "--chart-bar-wash"?: (string) | undefined;
51986
+ /** Space between slides. A sheet sets it and the component measures the run with it. */
51987
+ "--carousel-gap"?: (string) | undefined;
51988
+ /** The size one pane is laid out at. A sheet sets it and the component measures the run with it. */
51989
+ "--carousel-pane"?: (string) | undefined;
51990
+ /** How far short of a whole pixel the run ends, on the last slide alone, for a sheet to take up as `margin-inline-end`. See `runEnd`. */
51991
+ "--carousel-run-end"?: (string) | undefined;
51970
51992
  /** The chosen color, to paint over the transparency check. */
51971
51993
  "--color-input-swatch"?: (string) | undefined;
51972
51994
  /** The chosen brightness, 0 to 100, as a percentage. */
package/types/vue.d.ts CHANGED
@@ -8715,6 +8715,12 @@ export type CustomCssProperties = {
8715
8715
  "--bar-chart-secondary"?: (string) | undefined;
8716
8716
  /** The gradient a bar would take, named per bar so the styled tier can point `fill` at it. Drawn whatever the treatment and used only where `wash="gradient"` asks for it. */
8717
8717
  "--chart-bar-wash"?: (string) | undefined;
8718
+ /** Space between slides. A sheet sets it and the component measures the run with it. */
8719
+ "--carousel-gap"?: (string) | undefined;
8720
+ /** The size one pane is laid out at. A sheet sets it and the component measures the run with it. */
8721
+ "--carousel-pane"?: (string) | undefined;
8722
+ /** How far short of a whole pixel the run ends, on the last slide alone, for a sheet to take up as `margin-inline-end`. See `runEnd`. */
8723
+ "--carousel-run-end"?: (string) | undefined;
8718
8724
  /** The chosen color, to paint over the transparency check. */
8719
8725
  "--color-input-swatch"?: (string) | undefined;
8720
8726
  /** The chosen brightness, 0 to 100, as a percentage. */