An open source design system that's fully customizable and agent ready
TypeScript
fix(core): scope useContainerReveal by inheritance instead of a six-slot marker pool (#4955)
Cindy Zhang50f0adccae52
diff --git a/.changeset/usecontainerreveal-scopes-the-reveal-by-inherita-guca.md b/.changeset/usecontainerreveal-scopes-the-reveal-by-inherita-guca.mdnew file mode 100644index 0000000000..26c9b2d68b--- /dev/null+++ b/.changeset/usecontainerreveal-scopes-the-reveal-by-inherita-guca.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[fix] useContainerReveal scopes the reveal by inheritance instead of a marker pool: no dev warnings on lists longer than six rows, and isEnabled now takes effect after mount+@cixzhangdiff --git a/apps/storybook/stories/UseContainerReveal.stories.tsx b/apps/storybook/stories/UseContainerReveal.stories.tsxindex 38d634a245..bda08ff8dc 100644--- a/apps/storybook/stories/UseContainerReveal.stories.tsx+++ b/apps/storybook/stories/UseContainerReveal.stories.tsx@@ -2,6 +2,7 @@import type {Meta, StoryObj} from '@storybook/react';import * as stylex from '@stylexjs/stylex';+import {useState} from 'react';import {useContainerReveal} from '@astryxdesign/core/hooks';import {Button} from '@astryxdesign/core/Button';import {mergeProps} from '@astryxdesign/core/utils';@@ -32,6 +33,7 @@ const styles = stylex.create({label: {fontSize: 14},actions: {display: 'flex', gap: 4},hint: {fontSize: 12, color: '#888', marginBottom: 8},+ toggle: {marginBottom: 8},nested: {marginTop: 8,marginInlineStart: 24,@@ -51,7 +53,8 @@ function RevealRow({label}: {label: string}) {return (<div {...mergeProps(getContainerProps(), stylex.props(styles.row))}><span {...stylex.props(styles.label)}>{label}</span>- <span {...mergeProps(getContentRevealProps(), stylex.props(styles.actions))}>+ <span+ {...mergeProps(getContentRevealProps(), stylex.props(styles.actions))}><Buttonlabel={`Edit ${label}`}variant="ghost"@@ -80,8 +83,8 @@ export const Reveal: Story = {render: () => (<div {...stylex.props(styles.stack)}><p {...stylex.props(styles.hint)}>- Hover a row — or press Tab to focus into it — to reveal its actions.- On touch devices the actions are always visible.+ Hover a row — or press Tab to focus into it — to reveal its actions. On+ touch devices the actions are always visible.</p><RevealRow label="report.pdf" /><RevealRow label="budget.xlsx" />@@ -184,3 +187,67 @@ export const NestedIsolation: Story = {</div>),};++/**+ * A flat list of 20 rows. Sibling containers never nest, so every row can share+ * the same reveal scope: hovering one row reveals only that row's actions, and+ * mounting the list produces no console warnings.+ */+export const ManyRows: Story = {+ render: () => (+ <div {...stylex.props(styles.stack)}>+ <p {...stylex.props(styles.hint)}>+ Twenty rows on one page. Hover any row — including the last — to reveal+ its actions.+ </p>+ {Array.from({length: 20}, (_, i) => (+ <RevealRow+ key={i}+ label={`file-${String(i + 1).padStart(2, '0')}.txt`}+ />+ ))}+ </div>+ ),+};++/**+ * `isEnabled` is read on every render: flipping it off removes the reveal+ * styles and leaves the content permanently visible.+ */+export const ToggleEnabled: Story = {+ render: () => {+ function ToggleRow() {+ const [isEnabled, setIsEnabled] = useState(true);+ const {getContainerProps, getContentRevealProps} = useContainerReveal({+ isEnabled,+ });+ return (+ <div {...stylex.props(styles.stack)}>+ <div {...stylex.props(styles.toggle)}>+ <Button+ label={isEnabled ? 'Reveal on hover' : 'Always visible'}+ variant="secondary"+ onClick={() => setIsEnabled(v => !v)}+ />+ </div>+ <div {...mergeProps(getContainerProps(), stylex.props(styles.row))}>+ <span {...stylex.props(styles.label)}>report.pdf</span>+ <span+ {...mergeProps(+ getContentRevealProps(),+ stylex.props(styles.actions),+ )}>+ <Button+ label="Delete report.pdf"+ variant="ghost"+ isIconOnly+ icon={<TrashIcon style={{width: 16, height: 16}} />}+ />+ </span>+ </div>+ </div>+ );+ }+ return <ToggleRow />;+ },+};diff --git a/packages/core/src/hooks/containerReveal.pool.stylex.ts b/packages/core/src/hooks/containerReveal.pool.stylex.tsdeleted file mode 100644index 936705c60d..0000000000--- a/packages/core/src/hooks/containerReveal.pool.stylex.ts+++ /dev/null@@ -1,571 +0,0 @@-// Copyright (c) Meta Platforms, Inc. and affiliates.--/**- * @file containerReveal.pool.stylex.ts- * @input Uses StyleX, theme tokens- * @output A fixed pool of scoped markers, each paired with its reveal style- * blocks (reveal / conceal, each with a layout-preserved variant) compiled- * against that marker.- * @position Internal to useContainerReveal. GENERATED by- * scripts/gen-container-reveal-pool.mjs — do not edit by hand.- *- * WHY A POOL: `stylex.when.ancestor(':hover', marker)` welds the marker's- * class into the compiled selector (`.marker:hover *`), so a marker and the- * styles referencing it are inseparable at compile time. A single shared- * marker would leak hover/focus across NESTED reveal containers (an ancestor- * container's `:hover` matches a descendant container's revealed content).- * Pre-declaring N markers lets useContainerReveal hand each concurrently- * mounted container a distinct marker (free-list in useContainerReveal),- * isolating nested containers without the caller authoring any StyleX.- *- * SYNC: When the block shape changes, edit- * scripts/gen-container-reveal-pool.mjs and useContainerReveal.ts, then- * regenerate (node scripts/gen-container-reveal-pool.mjs) and commit.- */--import * as stylex from '@stylexjs/stylex';-import {durationVars, easeVars} from '../theme/tokens.stylex';--export const POOL_SIZE = 6;--export const m0 = stylex.defineMarker();-const s0 = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: {- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', m0)]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', m0)]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- },- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m0)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m0)]: 1,- '@media (any-pointer: coarse)': 1,- },- position: {- default: 'absolute',- [stylex.when.ancestor(':hover', m0)]: {'@media (hover: hover)': 'static'},- [stylex.when.ancestor(':focus-within', m0)]: 'static',- '@media (any-pointer: coarse)': 'static',- },- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m0)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m0)]: 1,- '@media (any-pointer: coarse)': 1,- },- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m0)]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m0)]: {'@media (hover: hover)': 0},- },- },-});--export const m1 = stylex.defineMarker();-const s1 = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: {- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', m1)]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', m1)]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- },- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m1)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m1)]: 1,- '@media (any-pointer: coarse)': 1,- },- position: {- default: 'absolute',- [stylex.when.ancestor(':hover', m1)]: {'@media (hover: hover)': 'static'},- [stylex.when.ancestor(':focus-within', m1)]: 'static',- '@media (any-pointer: coarse)': 'static',- },- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m1)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m1)]: 1,- '@media (any-pointer: coarse)': 1,- },- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m1)]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m1)]: {'@media (hover: hover)': 0},- },- },-});--export const m2 = stylex.defineMarker();-const s2 = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: {- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', m2)]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', m2)]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- },- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m2)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m2)]: 1,- '@media (any-pointer: coarse)': 1,- },- position: {- default: 'absolute',- [stylex.when.ancestor(':hover', m2)]: {'@media (hover: hover)': 'static'},- [stylex.when.ancestor(':focus-within', m2)]: 'static',- '@media (any-pointer: coarse)': 'static',- },- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m2)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m2)]: 1,- '@media (any-pointer: coarse)': 1,- },- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m2)]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m2)]: {'@media (hover: hover)': 0},- },- },-});--export const m3 = stylex.defineMarker();-const s3 = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: {- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', m3)]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', m3)]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- },- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m3)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m3)]: 1,- '@media (any-pointer: coarse)': 1,- },- position: {- default: 'absolute',- [stylex.when.ancestor(':hover', m3)]: {'@media (hover: hover)': 'static'},- [stylex.when.ancestor(':focus-within', m3)]: 'static',- '@media (any-pointer: coarse)': 'static',- },- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m3)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m3)]: 1,- '@media (any-pointer: coarse)': 1,- },- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m3)]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m3)]: {'@media (hover: hover)': 0},- },- },-});--export const m4 = stylex.defineMarker();-const s4 = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: {- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', m4)]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', m4)]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- },- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m4)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m4)]: 1,- '@media (any-pointer: coarse)': 1,- },- position: {- default: 'absolute',- [stylex.when.ancestor(':hover', m4)]: {'@media (hover: hover)': 'static'},- [stylex.when.ancestor(':focus-within', m4)]: 'static',- '@media (any-pointer: coarse)': 'static',- },- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m4)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m4)]: 1,- '@media (any-pointer: coarse)': 1,- },- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m4)]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m4)]: {'@media (hover: hover)': 0},- },- },-});--export const m5 = stylex.defineMarker();-const s5 = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: {- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', m5)]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', m5)]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- },- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m5)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m5)]: 1,- '@media (any-pointer: coarse)': 1,- },- position: {- default: 'absolute',- [stylex.when.ancestor(':hover', m5)]: {'@media (hover: hover)': 'static'},- [stylex.when.ancestor(':focus-within', m5)]: 'static',- '@media (any-pointer: coarse)': 'static',- },- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 0,- [stylex.when.ancestor(':hover', m5)]: {'@media (hover: hover)': 1},- [stylex.when.ancestor(':focus-within', m5)]: 1,- '@media (any-pointer: coarse)': 1,- },- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m5)]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- opacity: {- default: 1,- [stylex.when.ancestor(':hover', m5)]: {'@media (hover: hover)': 0},- },- },-});--// The compiled StyleX style objects carry `when.ancestor` conditionals that-// the public `StyleXStyles` type does not model, so the slot shape is inferred-// from the generated blocks rather than annotated.-export const POOL = [- {- marker: m0,- reveal: s0.reveal,- revealLayoutPreserved: s0.revealLayoutPreserved,- conceal: s0.conceal,- concealLayoutPreserved: s0.concealLayoutPreserved,- },- {- marker: m1,- reveal: s1.reveal,- revealLayoutPreserved: s1.revealLayoutPreserved,- conceal: s1.conceal,- concealLayoutPreserved: s1.concealLayoutPreserved,- },- {- marker: m2,- reveal: s2.reveal,- revealLayoutPreserved: s2.revealLayoutPreserved,- conceal: s2.conceal,- concealLayoutPreserved: s2.concealLayoutPreserved,- },- {- marker: m3,- reveal: s3.reveal,- revealLayoutPreserved: s3.revealLayoutPreserved,- conceal: s3.conceal,- concealLayoutPreserved: s3.concealLayoutPreserved,- },- {- marker: m4,- reveal: s4.reveal,- revealLayoutPreserved: s4.revealLayoutPreserved,- conceal: s4.conceal,- concealLayoutPreserved: s4.concealLayoutPreserved,- },- {- marker: m5,- reveal: s5.reveal,- revealLayoutPreserved: s5.revealLayoutPreserved,- conceal: s5.conceal,- concealLayoutPreserved: s5.concealLayoutPreserved,- },-] as const;--export type RevealSlot = (typeof POOL)[number];diff --git a/packages/core/src/hooks/containerReveal.stylex.ts b/packages/core/src/hooks/containerReveal.stylex.tsnew file mode 100644index 0000000000..50225e6242--- /dev/null+++ b/packages/core/src/hooks/containerReveal.stylex.ts@@ -0,0 +1,102 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file containerReveal.stylex.ts+ * @input Uses StyleX, theme tokens+ * @output The container style that publishes the reveal state, and the four+ * content style blocks (reveal / conceal, each with a layout-preserved+ * variant) that read it.+ * @position Internal to useContainerReveal.+ *+ * HOW THE SCOPING WORKS: the container declares its own reveal state as+ * inherited custom properties on itself, and content reads them. Because a+ * nested container re-declares the same properties on itself, its subtree sees+ * the inner value and never the ancestor's — nesting isolation falls out of the+ * cascade, with one static style block for any number of containers.+ *+ * SYNC: When the block shape changes, update useContainerReveal.ts.+ */++import * as stylex from '@stylexjs/stylex';+import {durationVars, easeVars} from '../theme/tokens.stylex';++const REST_DELAY = '0s, ' + durationVars['--duration-fast'];++export const styles = stylex.create({+ container: {+ '--_reveal-opacity': {+ default: 0,+ ':hover': {'@media (hover: hover)': 1},+ ':focus-within': 1,+ '@media (any-pointer: coarse)': 1,+ },+ '--_reveal-position': {+ default: 'absolute',+ ':hover': {'@media (hover: hover)': 'static'},+ ':focus-within': 'static',+ '@media (any-pointer: coarse)': 'static',+ },+ // The position flip is discrete, so it transitions with allow-discrete and+ // a state-conditional delay: 0 on entry (flips into flow immediately, then+ // fades in) and the fade duration on exit (stays in flow until the fade+ // finishes, then snaps out) — without this the exit would snap out of flow+ // at full opacity and flicker.+ '--_reveal-delay': {+ default: REST_DELAY,+ ':hover': {'@media (hover: hover)': '0s, 0s'},+ ':focus-within': '0s, 0s',+ '@media (any-pointer: coarse)': '0s, 0s',+ },+ // Conceal is a mouse-only visual swap, so it reads hover alone: no+ // :focus-within (a keyboard user must never watch content vanish) and no+ // coarse-pointer branch (it stays visible on touch).+ '--_conceal-opacity': {+ default: 1,+ ':hover': {'@media (hover: hover)': 0},+ },+ },+ // The fallbacks make content spread outside a reveal container fail visible+ // rather than invisible.+ reveal: {+ transitionProperty: 'opacity, position',+ transitionDuration: {+ default: durationVars['--duration-fast'] + ', 0s',+ '@media (prefers-reduced-motion: reduce)': '0s, 0s',+ },+ transitionTimingFunction: easeVars['--ease-standard'],+ transitionBehavior: 'allow-discrete',+ transitionDelay: {+ default: 'var(--_reveal-delay, 0s, 0s)',+ '@media (prefers-reduced-motion: reduce)': '0s, 0s',+ },+ opacity: 'var(--_reveal-opacity, 1)',+ position: 'var(--_reveal-position, static)',+ },+ revealLayoutPreserved: {+ transitionProperty: 'opacity',+ transitionDuration: {+ default: durationVars['--duration-fast'],+ '@media (prefers-reduced-motion: reduce)': '0s',+ },+ transitionTimingFunction: easeVars['--ease-standard'],+ opacity: 'var(--_reveal-opacity, 1)',+ },+ conceal: {+ transitionProperty: 'opacity',+ transitionDuration: {+ default: durationVars['--duration-fast'],+ '@media (prefers-reduced-motion: reduce)': '0s',+ },+ transitionTimingFunction: easeVars['--ease-standard'],+ opacity: 'var(--_conceal-opacity, 1)',+ },+ concealLayoutPreserved: {+ transitionProperty: 'opacity',+ transitionDuration: {+ default: durationVars['--duration-fast'],+ '@media (prefers-reduced-motion: reduce)': '0s',+ },+ transitionTimingFunction: easeVars['--ease-standard'],+ opacity: 'var(--_conceal-opacity, 1)',+ },+});diff --git a/packages/core/src/hooks/useContainerReveal.doc.mjs b/packages/core/src/hooks/useContainerReveal.doc.mjsindex 8faaa245f4..c3b6396ef2 100644--- a/packages/core/src/hooks/useContainerReveal.doc.mjs+++ b/packages/core/src/hooks/useContainerReveal.doc.mjs@@ -15,7 +15,7 @@ export const docs = {{name: 'options.isEnabled',type: 'boolean',- description: 'When false the hook is inert: no marker is applied and content getters return no styles, so content is always shown. Lets a component gate reveal on its own prop (e.g. revealOn === "hover").',+ description: 'When false the hook is inert: the container gets no styles and content getters return no styles, so content is always shown. Read on every render, so a component can flip it after mount (e.g. revealOn === "hover").',default: 'true',required: false,},@@ -34,11 +34,11 @@ export const docs = {],usage: {description:- 'A headless hover/focus reveal primitive. Gives a container a scoped trigger that reveals (or conceals) content inside it when the container is hovered or receives keyboard focus: the classic "row actions appear on hover" pattern. The reveal is CSS-only: no hover state lives in React and hovering never triggers a re-render. The caller authors no StyleX for the reveal itself; the hook hands out a scoped marker and matching styles, so nested containers never leak hover/focus into one another. Accessible by construction: revealed content is visually hidden at rest with position and opacity (never display:none), so it stays mounted, keeps its place in the tab order, and is announced to assistive technology; it reveals on :focus-within so keyboard users see it when tabbing in, stays visible on touch (never gated behind hover on coarse pointers), and honors prefers-reduced-motion.',+ 'A headless hover/focus reveal primitive. Gives a container a scoped trigger that reveals (or conceals) content inside it when the container is hovered or receives keyboard focus: the classic "row actions appear on hover" pattern. The reveal is CSS-only: no hover state lives in React and hovering never triggers a re-render. The caller authors no StyleX for the reveal itself; the hook hands out the container and content styles, and a nested container shadows its ancestor, so nested containers never leak hover/focus into one another. Accessible by construction: revealed content is visually hidden at rest with position and opacity (never display:none), so it stays mounted, keeps its place in the tab order, and is announced to assistive technology; it reveals on :focus-within so keyboard users see it when tabbing in, stays visible on touch (never gated behind hover on coarse pointers), and honors prefers-reduced-motion.',bestPractices: [{ guidance: true, description: 'Destructure getContainerProps and getContentRevealProps; spread getContainerProps() on the container (via mergeProps with your own stylex.props) and getContentRevealProps() on the content to reveal.' },{ guidance: true, description: 'Use for secondary affordances: reveal-on-hover row actions (edit/copy/remove on list or table rows) and overlay controls on a card or media tile (e.g. Thumbnail\'s remove button).' },- { guidance: true, description: 'Gate the reveal with isEnabled when a consumer prop decides whether content is revealed on hover or always shown.' },+ { guidance: true, description: 'Gate the reveal with isEnabled when a consumer prop decides whether content is revealed on hover or always shown; it can change at any time.' },{ guidance: true, description: 'Pass isLayoutPreserved for absolutely-positioned or overlay content to reserve its box and avoid layout shift when it appears.' },{ guidance: false, description: 'Use it to hide content that must always be discoverable; keep essential actions visible instead of gating them behind hover.' },],@@ -52,10 +52,10 @@ export const docs = {/** @type {import('@astryxdesign/cli/authoring').HookTranslationDoc} */export const docsDense = {description:- 'Headless hover/focus reveal primitive. Gives a container a scoped trigger that reveals (or conceals) content inside it on hover / keyboard focus: the "row actions appear on hover" pattern. CSS-only: no hover state in React, no re-render on hover. Caller authors no StyleX; hook hands out a scoped marker + matching styles, so nested containers never leak hover/focus. Accessible: revealed content visually hidden at rest via position + opacity (never display:none), stays mounted + in tab order + announced; reveals on :focus-within, stays visible on touch, honors prefers-reduced-motion.',+ 'Headless hover/focus reveal primitive. Gives a container a scoped trigger that reveals (or conceals) content inside it on hover / keyboard focus: the "row actions appear on hover" pattern. CSS-only: no hover state in React, no re-render on hover. Caller authors no StyleX; hook hands out container + content styles; a nested container shadows its ancestor, so nested containers never leak hover/focus. Accessible: revealed content visually hidden at rest via position + opacity (never display:none), stays mounted + in tab order + announced; reveals on :focus-within, stays visible on touch, honors prefers-reduced-motion.',paramDescriptions: {options: 'config for reveal container. optional.',- 'options.isEnabled': 'when false hook is inert: no marker, content getters return no styles, content always shown. Lets component gate reveal on its own prop.',+ 'options.isEnabled': 'when false hook is inert: no container styles, content getters return no styles, content always shown. Read every render, so it can flip after mount.',},returnDescriptions: {getContainerProps: 'spread onto container whose hover/focus-within drives reveal.',@@ -63,11 +63,11 @@ export const docsDense = {},usage: {description:- 'Headless hover/focus reveal primitive. Gives a container a scoped trigger that reveals (or conceals) content inside it on hover / keyboard focus: the "row actions appear on hover" pattern. CSS-only: no hover state in React, no re-render on hover. Caller authors no StyleX; hook hands out a scoped marker + matching styles, so nested containers never leak hover/focus. Accessible: revealed content visually hidden at rest via position + opacity (never display:none), stays mounted + in tab order + announced; reveals on :focus-within, stays visible on touch, honors prefers-reduced-motion.',+ 'Headless hover/focus reveal primitive. Gives a container a scoped trigger that reveals (or conceals) content inside it on hover / keyboard focus: the "row actions appear on hover" pattern. CSS-only: no hover state in React, no re-render on hover. Caller authors no StyleX; hook hands out container + content styles; a nested container shadows its ancestor, so nested containers never leak hover/focus. Accessible: revealed content visually hidden at rest via position + opacity (never display:none), stays mounted + in tab order + announced; reveals on :focus-within, stays visible on touch, honors prefers-reduced-motion.',bestPractices: [{ guidance: true, description: 'Destructure getContainerProps + getContentRevealProps; spread getContainerProps() on container (via mergeProps w/ your stylex.props) + getContentRevealProps() on content to reveal.' },{ guidance: true, description: 'Use for secondary affordances: reveal-on-hover row actions (edit/copy/remove on list / table rows) + overlay controls on card / media tile (e.g. Thumbnail remove button).' },- { guidance: true, description: 'Gate reveal w/ isEnabled when a consumer prop decides revealed-on-hover vs always shown.' },+ { guidance: true, description: 'Gate reveal w/ isEnabled when a consumer prop decides revealed-on-hover vs always shown; can change at any time.' },{ guidance: true, description: 'Pass isLayoutPreserved for absolutely-positioned / overlay content to reserve its box + avoid layout shift.' },{ guidance: false, description: 'Use to hide content that must always be discoverable; keep essential actions visible instead of gating behind hover.' },],diff --git a/packages/core/src/hooks/useContainerReveal.test.tsx b/packages/core/src/hooks/useContainerReveal.test.tsxindex 7afb92bc7c..bfca03bf25 100644--- a/packages/core/src/hooks/useContainerReveal.test.tsx+++ b/packages/core/src/hooks/useContainerReveal.test.tsx@@ -3,61 +3,55 @@/*** @file useContainerReveal.test.tsx* @input Uses vitest, @testing-library/react, useContainerReveal- * @output Unit tests for the marker-pool free-list, per-instance scoping, the- * inert (disabled) path, and the content-option → style-block mapping.- * @position Testing; validates useContainerReveal.ts and its pool.+ * @output Unit tests for the enabled/disabled contract, the dynamic isEnabled+ * prop, the content-option → style-block mapping, and the promise that a+ * large flat list mounts without dev warnings.+ * @position Testing; validates useContainerReveal.ts.+ *+ * Nesting isolation is a cascade behavior jsdom does not implement, so it is+ * verified in a real browser (Storybook's NestedIsolation story) rather than+ * asserted here.** SYNC: When useContainerReveal.ts changes, update these tests.*/-import {describe, it, expect} from 'vitest';-import {renderHook, render, act} from '@testing-library/react';+import {describe, it, expect, vi, afterEach} from 'vitest';+import {renderHook, render} from '@testing-library/react';import {useContainerReveal} from './useContainerReveal';-import {POOL_SIZE} from './containerReveal.pool.stylex';++afterEach(() => {+ vi.restoreAllMocks();+});describe('useContainerReveal', () => {it('returns spreadable getter props for container and content', () => {const {result} = renderHook(() => useContainerReveal());const container = result.current.getContainerProps();const content = result.current.getContentRevealProps();- expect(container).toHaveProperty('className');- expect(content).toHaveProperty('className');expect(typeof container.className).toBe('string');expect(typeof content.className).toBe('string');});- it('is inert when disabled: no marker class, empty content props', () => {- const {result} = renderHook(() =>- useContainerReveal({isEnabled: false}),- );+ it('is inert when disabled: no container class, empty content props', () => {+ const {result} = renderHook(() => useContainerReveal({isEnabled: false}));expect(result.current.getContainerProps()).toEqual({});expect(result.current.getContentRevealProps()).toEqual({});});- it('gives two concurrently mounted containers DISTINCT marker classes', () => {- // The core leak-safety property: nested/concurrent containers must never- // share a marker, or an ancestor container's :hover would reveal a- // descendant container's content.- const a = renderHook(() => useContainerReveal());- const b = renderHook(() => useContainerReveal());- const classA = a.result.current.getContainerProps().className;- const classB = b.result.current.getContainerProps().className;- expect(classA).toBeTruthy();- expect(classB).toBeTruthy();- expect(classA).not.toBe(classB);- a.unmount();- b.unmount();- });+ it('follows isEnabled after mount, in both directions', () => {+ const {result, rerender} = renderHook(+ ({isEnabled}) => useContainerReveal({isEnabled}),+ {initialProps: {isEnabled: true}},+ );+ expect(result.current.getContentRevealProps().className).toBeTruthy();- it('recycles a slot after unmount (free-list release)', () => {- const first = renderHook(() => useContainerReveal());- const firstClass = first.result.current.getContainerProps().className;- first.unmount();- // A fresh mount should be able to reclaim the just-released slot.- const second = renderHook(() => useContainerReveal());- const secondClass = second.result.current.getContainerProps().className;- expect(secondClass).toBe(firstClass);- second.unmount();+ rerender({isEnabled: false});+ expect(result.current.getContainerProps()).toEqual({});+ expect(result.current.getContentRevealProps()).toEqual({});++ rerender({isEnabled: true});+ expect(result.current.getContainerProps().className).toBeTruthy();+ expect(result.current.getContentRevealProps().className).toBeTruthy();});it('reveal and conceal map to different style blocks', () => {@@ -80,37 +74,23 @@ describe('useContainerReveal', () => {expect(clipped).not.toBe(preserved);});- it('assigns distinct markers across a full pool of concurrent containers', () => {- function Probe({onClass}: {onClass: (c: string) => void}) {- const {getContainerProps} = useContainerReveal();- onClass(getContainerProps().className ?? '');- return null;+ it('mounts a large flat list without a dev warning', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ function Row() {+ const {getContainerProps, getContentRevealProps} = useContainerReveal();+ return (+ <div {...getContainerProps()}>+ <span {...getContentRevealProps()}>actions</span>+ </div>+ );}- const classes: string[] = [];- const {unmount} = render(+ render(<>- {Array.from({length: POOL_SIZE}, (_, i) => (- <Probe key={i} onClass={(c) => classes.push(c)} />+ {Array.from({length: 500}, (_, i) => (+ <Row key={i} />))}</>,);- const unique = new Set(classes.filter(Boolean));- expect(unique.size).toBe(POOL_SIZE);- unmount();- });-- it('survives repeated mount/unmount without leaking the pool', () => {- // Mount and unmount a full pool several times; each cycle must still hand- // out POOL_SIZE distinct markers, proving slots are released.- for (let cycle = 0; cycle < 3; cycle++) {- const hooks = Array.from({length: POOL_SIZE}, () =>- renderHook(() => useContainerReveal()),- );- const classes = hooks.map(- (h) => h.result.current.getContainerProps().className,- );- expect(new Set(classes).size).toBe(POOL_SIZE);- act(() => hooks.forEach((h) => h.unmount()));- }+ expect(warn).not.toHaveBeenCalled();});});diff --git a/packages/core/src/hooks/useContainerReveal.ts b/packages/core/src/hooks/useContainerReveal.tsindex 2df4fbe436..63f6fd1926 100644--- a/packages/core/src/hooks/useContainerReveal.ts+++ b/packages/core/src/hooks/useContainerReveal.ts@@ -4,7 +4,7 @@/*** @file useContainerReveal.ts- * @input Uses React, the generated marker pool, useDevWarning+ * @input Uses the containerReveal styles* @output Exports useContainerReveal — a headless hover/focus reveal primitive* @position Core hook. Consumed by any component that reveals (or conceals)* content when its container is hovered or focused — e.g. Thumbnail's remove@@ -12,8 +12,13 @@** Gives a container a scoped hover/focus-within trigger that reveals or* conceals content inside it, entirely in CSS (no hover state in JS, no- * re-render on hover). The caller authors NO StyleX: the hook hands out a- * marker + matching reveal styles from a pre-compiled pool.+ * re-render on hover). The caller authors NO StyleX: the hook hands out the+ * container style and the matching content styles.+ *+ * Scoping is by inheritance: the container publishes its reveal state as+ * custom properties on itself and the content reads them, so a nested+ * container shadows its ancestor's state for its own subtree. See+ * containerReveal.stylex.ts.** ACCESSIBILITY (WCAG 2.2 by construction):* - Revealed content is visually hidden at rest via position + opacity, so it@@ -27,56 +32,19 @@** SYNC: When modified, update:* - /packages/core/src/hooks/index.ts (export)- * - containerReveal.pool.stylex.ts (if the slot shape changes)+ * - containerReveal.stylex.ts (if the style blocks change)*/-import {useState, useEffect, type CSSProperties} from 'react';+import {useMemo, type CSSProperties} from 'react';import * as stylex from '@stylexjs/stylex';-import {POOL, POOL_SIZE, type RevealSlot} from './containerReveal.pool.stylex';-import {useDevWarning} from './useDevWarning';--// Module-level free-list. Each mounted, enabled useContainerReveal claims a-// distinct pool slot so that any two CONCURRENTLY mounted containers — in-// particular a nested container inside another's revealed content — get-// different markers and cannot leak hover/focus into one another. Slots are-// returned on unmount. Sibling containers that would only ever collide when-// the pool is exhausted are harmless (a sibling is never an ancestor), so the-// pool only needs to cover the number of concurrently mounted containers, not-// instances over time.-const claimed: boolean[] = new Array(POOL_SIZE).fill(false);--interface Claim {- /** Pool index to use. */- index: number;- /** True when the pool was full and this claim fell back to a shared slot. */- isExhausted: boolean;-}--function claimSlot(): Claim {- for (let i = 0; i < POOL_SIZE; i++) {- if (!claimed[i]) {- claimed[i] = true;- return {index: i, isExhausted: false};- }- }- // Exhausted: fall back to slot 0. Safe for siblings (a sibling is never an- // ancestor); only nesting deeper than POOL_SIZE could reintroduce a leak.- // Surfaced via useDevWarning so the pool can be grown.- return {index: 0, isExhausted: true};-}--function releaseSlot(index: number, isExhausted: boolean): void {- // A fallback claim never owned the slot exclusively; leave it as-is.- if (!isExhausted) {- claimed[index] = false;- }-}+import {styles} from './containerReveal.stylex';export interface UseContainerRevealOptions {/**- * When false the hook is inert: no marker is applied and content getters- * return no styles, so content is always shown. Lets a component gate on its- * own prop (e.g. `revealOn === 'hover'`).+ * When false the hook is inert: the container gets no styles and content+ * getters return no styles, so content is always shown. Read on every+ * render, so a component can flip it with its own prop (e.g.+ * `revealOn === 'hover'`).* @default true*/isEnabled?: boolean;@@ -114,7 +82,7 @@ const EMPTY = Object.freeze({});* Scoped, CSS-only hover/focus reveal for content inside a container.** @example- * ```tsx+ * ```* const {getContainerProps, getContentRevealProps} = useContainerReveal({* isEnabled: revealOn === 'hover',* });@@ -132,50 +100,27 @@ export function useContainerReveal(): UseContainerRevealReturn {const {isEnabled = true} = options;- // Claim a slot for this container's lifetime. Assigned in the initializer- // (not the render body) and released on unmount so the free-list stays- // effect-scoped and StrictMode-safe.- const [claim] = useState<Claim | null>(() =>- isEnabled ? claimSlot() : null,- );-- useEffect(() => {- if (claim == null) {- return;+ return useMemo(() => {+ if (!isEnabled) {+ return {+ getContainerProps: () => EMPTY,+ getContentRevealProps: () => EMPTY,+ };}- return () => releaseSlot(claim.index, claim.isExhausted);- }, [claim]);-- useDevWarning(- 'useContainerReveal',- `More than ${POOL_SIZE} reveal containers are mounted at once; nested ` +- `containers beyond the pool may share a marker. Add markers to ` +- `containerReveal.pool.stylex.ts and raise POOL_SIZE.`,- claim?.isExhausted ?? false,- );-- if (claim == null) {return {- getContainerProps: () => EMPTY,- getContentRevealProps: () => EMPTY,+ getContainerProps: () => stylex.props(styles.container),+ getContentRevealProps: (contentOptions: ContentRevealOptions = {}) => {+ const {isRevealInverted = false, isLayoutPreserved = false} =+ contentOptions;+ const style = isRevealInverted+ ? isLayoutPreserved+ ? styles.concealLayoutPreserved+ : styles.conceal+ : isLayoutPreserved+ ? styles.revealLayoutPreserved+ : styles.reveal;+ return stylex.props(style);+ },};- }-- const slot: RevealSlot = POOL[claim.index];-- return {- getContainerProps: () => stylex.props(slot.marker),- getContentRevealProps: (contentOptions: ContentRevealOptions = {}) => {- const {isRevealInverted = false, isLayoutPreserved = false} =- contentOptions;- const style = isRevealInverted- ? isLayoutPreserved- ? slot.concealLayoutPreserved- : slot.conceal- : isLayoutPreserved- ? slot.revealLayoutPreserved- : slot.reveal;- return stylex.props(style);- },- };+ }, [isEnabled]);}diff --git a/scripts/gen-container-reveal-pool.mjs b/scripts/gen-container-reveal-pool.mjsdeleted file mode 100644index b101bcdb92..0000000000--- a/scripts/gen-container-reveal-pool.mjs+++ /dev/null@@ -1,165 +0,0 @@-// Copyright (c) Meta Platforms, Inc. and affiliates.--/**- * @file gen-container-reveal-pool.mjs- * @input POOL_SIZE- * @output packages/core/src/hooks/containerReveal.pool.stylex.ts- * @position Generator for the useContainerReveal marker pool. `stylex.create`- * must be static (no runtime loops), and each marker's reveal styles must be- * compiled against that specific marker, so the N repeated blocks are- * generated rather than hand-written.- *- * Run: node scripts/gen-container-reveal-pool.mjs- */--import {writeFileSync} from 'node:fs';-import {fileURLToPath} from 'node:url';-import {dirname, join} from 'node:path';--const POOL_SIZE = 6;-const OUT = join(- dirname(fileURLToPath(import.meta.url)),- '../packages/core/src/hooks/containerReveal.pool.stylex.ts',-);--const transition = `transitionProperty: 'opacity',- transitionDuration: {- default: durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s',- },- transitionTimingFunction: easeVars['--ease-standard'],`;--function toggled(m, hidden, shown) {- return `{- default: ${hidden},- [stylex.when.ancestor(':hover', ${m})]: {'@media (hover: hover)': ${shown}},- [stylex.when.ancestor(':focus-within', ${m})]: ${shown},- '@media (any-pointer: coarse)': ${shown},- }`;-}--// `position` is discrete, so it cannot tween. To avoid an exit flicker — where-// `static -> absolute` snaps at full opacity and yanks the element out of flow-// before it can fade — the flip participates in the transition with-// `allow-discrete`, and its `transition-delay` is state-conditional: 0 on entry-// (destination = shown) so it enters flow immediately and fades in, but the-// fade duration on exit (destination = rest) so it stays in flow until the-// opacity fade finishes, then snaps out. Under reduced motion both collapse to-// 0s so nothing lingers visible-but-empty.-function positionDelay(m) {- return `{- default: '0s, ' + durationVars['--duration-fast'],- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- [stylex.when.ancestor(':hover', ${m})]: {'@media (hover: hover)': '0s, 0s'},- [stylex.when.ancestor(':focus-within', ${m})]: '0s, 0s',- '@media (any-pointer: coarse)': '0s, 0s',- }`;-}--function block(i) {- const m = `m${i}`;- return `-export const ${m} = stylex.defineMarker();-const s${i} = stylex.create({- // Hidden at rest via position + opacity (kept in the a11y tree and tab- // order); on container :hover (fine pointer) or :focus-within it returns to- // flow and fades in. Always shown on touch. The position flip is discrete,- // so it transitions with allow-discrete + a state-conditional delay: 0 on- // entry (flips to static immediately, then fades in) and the fade duration- // on exit (stays in flow until the fade finishes, then snaps out) — without- // this, the exit would snap out of flow at full opacity and flicker.- reveal: {- transitionProperty: 'opacity, position',- transitionDuration: {- default: durationVars['--duration-fast'] + ', 0s',- '@media (prefers-reduced-motion: reduce)': '0s, 0s',- },- transitionTimingFunction: easeVars['--ease-standard'],- transitionBehavior: 'allow-discrete',- transitionDelay: ${positionDelay(m)},- opacity: ${toggled(m, '0', '1')},- position: ${toggled(m, "'absolute'", "'static'")},- },- // Opacity-only reveal that keeps the box reserved (no layout shift). Use for- // content that is already positioned (e.g. an absolute overlay).- revealLayoutPreserved: {- ${transition}- opacity: ${toggled(m, '0', '1')},- },- // Inverted: visible at rest, fades OUT on :hover only. Deliberately ignores- // :focus-within (a keyboard user must never watch content vanish) and stays- // visible on touch. Never leaves the a11y tree.- conceal: {- ${transition}- opacity: {- default: 1,- [stylex.when.ancestor(':hover', ${m})]: {'@media (hover: hover)': 0},- },- },- concealLayoutPreserved: {- ${transition}- opacity: {- default: 1,- [stylex.when.ancestor(':hover', ${m})]: {'@media (hover: hover)': 0},- },- },-});`;-}--const header = `// Copyright (c) Meta Platforms, Inc. and affiliates.--/**- * @file containerReveal.pool.stylex.ts- * @input Uses StyleX, theme tokens- * @output A fixed pool of scoped markers, each paired with its reveal style- * blocks (reveal / conceal, each with a layout-preserved variant) compiled- * against that marker.- * @position Internal to useContainerReveal. GENERATED by- * scripts/gen-container-reveal-pool.mjs — do not edit by hand.- *- * WHY A POOL: \`stylex.when.ancestor(':hover', marker)\` welds the marker's- * class into the compiled selector (\`.marker:hover *\`), so a marker and the- * styles referencing it are inseparable at compile time. A single shared- * marker would leak hover/focus across NESTED reveal containers (an ancestor- * container's \`:hover\` matches a descendant container's revealed content).- * Pre-declaring N markers lets useContainerReveal hand each concurrently- * mounted container a distinct marker (free-list in useContainerReveal),- * isolating nested containers without the caller authoring any StyleX.- *- * SYNC: When the block shape changes, edit- * scripts/gen-container-reveal-pool.mjs and useContainerReveal.ts, then- * regenerate (node scripts/gen-container-reveal-pool.mjs) and commit.- */--import * as stylex from '@stylexjs/stylex';-import {durationVars, easeVars} from '../theme/tokens.stylex';--export const POOL_SIZE = ${POOL_SIZE};-`;--const blocks = Array.from({length: POOL_SIZE}, (_, i) => block(i)).join('\n');--const footer = `--// The compiled StyleX style objects carry \`when.ancestor\` conditionals that-// the public \`StyleXStyles\` type does not model, so the slot shape is inferred-// from the generated blocks rather than annotated.-export const POOL = [-${Array.from(- {length: POOL_SIZE},- (_, i) =>- ` {- marker: m${i},- reveal: s${i}.reveal,- revealLayoutPreserved: s${i}.revealLayoutPreserved,- conceal: s${i}.conceal,- concealLayoutPreserved: s${i}.concealLayoutPreserved,- },`,-).join('\n')}-] as const;--export type RevealSlot = (typeof POOL)[number];-`;--writeFileSync(OUT, header + blocks + footer);-console.log(`Wrote ${OUT}`);