@contentrain/astro-kit 0.46.0 → 0.46.1

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.
@@ -19,15 +19,20 @@ import { videoTarget } from './embed-target'
19
19
  type Kind = 'disclosure' | 'tablist' | 'carousel' | 'dialog' | 'countup' | 'toggle' | 'filter' | 'anchor' | 'lightbox'
20
20
 
21
21
  const KINDS: ReadonlySet<string> = new Set<Kind>(['disclosure', 'tablist', 'carousel', 'dialog', 'countup', 'toggle', 'filter', 'anchor', 'lightbox'])
22
- /** Past this many items an island wires the first ones; the rest stay visible as printed (said on the receipt). */
22
+ /**
23
+ * Past this many items an island that wires each item (tabs, a counter, a filter) wires the first ones; the rest stay
24
+ * visible as printed (said on the receipt). A carousel wires none of its slides one by one (one scroll-snap track), so it
25
+ * takes every slide: a 59-slide slider (x10's metaslider) cut at 50 left its track with slides it did not count, and stayed
26
+ * static with no controls.
27
+ */
23
28
  const MAX_ITEMS = 50
24
29
 
25
30
  const reduced = (): boolean => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches
26
31
 
27
32
  /** Elements under the island root for a selector the engine wrote; nothing (never a throw) for a bad selector. */
28
- function within(root: HTMLElement, selector: string | undefined): HTMLElement[] {
33
+ function within(root: HTMLElement, selector: string | undefined, limit = MAX_ITEMS): HTMLElement[] {
29
34
  if (!selector) return []
30
- try { return [...root.querySelectorAll<HTMLElement>(selector)].slice(0, MAX_ITEMS) }
35
+ try { return [...root.querySelectorAll<HTMLElement>(selector)].slice(0, limit) }
31
36
  catch { return [] }
32
37
  }
33
38
 
@@ -94,9 +99,9 @@ function setEnd(button: HTMLButtonElement, off: boolean, measured: boolean): voi
94
99
  }
95
100
 
96
101
  function carousel(root: HTMLElement): void {
97
- const items = within(root, root.dataset.crItems)
102
+ const items = within(root, root.dataset.crItems, Infinity)
98
103
  const track = items[0]?.parentElement
99
- // Past MAX_ITEMS (or other children in the track) the carousel stays static: never squeeze unwired slides into the row.
104
+ // Other children in the track keep the carousel static: never squeeze what is not a slide into the row.
100
105
  if (items.length < 2 || !track || !items.every(item => item.parentElement === track) || track.children.length !== items.length) return
101
106
  // A scroll-snap track: the browser moves it (swipe, keys, scroll); the buttons only scroll it. No timer: a slider
102
107
  // that advanced by itself on the old site waits for the visitor here (said on the receipt).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentrain/astro-kit",
3
- "version": "0.46.0",
3
+ "version": "0.46.1",
4
4
  "license": "MIT",
5
5
  "description": "Copy-in Astro components for Contentrain sites (shadcn model): typed props, tailwind-variants, zero JavaScript by default — with a machine-readable catalog",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  "mapping"
43
43
  ],
44
44
  "dependencies": {
45
- "@contentrain/types": "1.70.0"
45
+ "@contentrain/types": "1.71.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^22.10.0",