An open source design system that's fully customizable and agent ready
TypeScript
refactor(core): drop a dead private selector and collapse duplicate attribute spellings (INV23 step 4) (#9256)
Cindy Zhang891aa236cf9d
diff --git a/.changeset/inv23-dead-duplicate-private-selectors.md b/.changeset/inv23-dead-duplicate-private-selectors.mdnew file mode 100644index 0000000000..16ebbbbeb3--- /dev/null+++ b/.changeset/inv23-dead-duplicate-private-selectors.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[chore] Internal: ChatLayout drops a scrollbar style rule whose condition nothing ever set, and Popover, Table and the press feedback controller each read an internal marker through one shared name instead of a second hand-typed copy. No visible or behavioral change.++@cixzhangdiff --git a/internal/eslint-plugin-astryx/no-raw-private-attribute.baseline.json b/internal/eslint-plugin-astryx/no-raw-private-attribute.baseline.jsonindex e2dd8379f4..871fa48cb0 100644--- a/internal/eslint-plugin-astryx/no-raw-private-attribute.baseline.json+++ b/internal/eslint-plugin-astryx/no-raw-private-attribute.baseline.json@@ -7,7 +7,6 @@"packages/core/src/Chat/ChatComposerInput.tsx": ["data-astryx-dictation-interim"],- "packages/core/src/Chat/ChatLayout.tsx": ["data-astryx-scrolling"],"packages/core/src/Chat/useChatComposerTokens.ts": ["data-astryx-token-id"],"packages/core/src/Chat/useChatDictation.ts": ["data-astryx-dictation-interim"@@ -67,7 +66,6 @@"data-astryx-press"],"packages/core/src/Popover/Popover.tsx": [- "data-astryx-popover-fallback-close","data-astryx-popover-fallback-close"],"packages/core/src/Popover/usePopover.tsx": [@@ -108,7 +106,6 @@],"packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx": ["data-astryx-cell-gliding",- "data-astryx-table-pinned","data-astryx-table-pinned"],"packages/core/src/Thumbnail/Thumbnail.tsx": [diff --git a/packages/core/src/Chat/ChatLayout.tsx b/packages/core/src/Chat/ChatLayout.tsxindex d239344391..5f6f3a0807 100644--- a/packages/core/src/Chat/ChatLayout.tsx+++ b/packages/core/src/Chat/ChatLayout.tsx@@ -119,12 +119,6 @@ const styles = stylex.create({rootScrollable: {overflowY: 'auto',overflowX: 'hidden',- // Hide scrollbar during programmatic scroll animation- // to prevent flash. Restored when animation settles.- scrollbarWidth: {- default: null,- ':is([data-astryx-scrolling])': 'none',- },},messageArea: {diff --git a/packages/core/src/Popover/Popover.tsx b/packages/core/src/Popover/Popover.tsxindex 7800ff5585..a0ae8ab2ee 100644--- a/packages/core/src/Popover/Popover.tsx+++ b/packages/core/src/Popover/Popover.tsx@@ -49,7 +49,7 @@ import {useThemeDefinition} from '../theme/useTheme';import * as stylex from '@stylexjs/stylex';import {devWarn} from '../utils/devWarning';import type {BaseProps} from '../BaseProps';-import {usePopover} from './usePopover';+import {FALLBACK_CLOSE_SELECTOR, usePopover} from './usePopover';import {FOCUSABLE_SELECTOR} from '../hooks/focusableSelector';import type {LayerAlignment, LayerPlacement} from '../Layer/useLayer';import {layerAnimations} from '../Layer/layerAnimations.stylex';@@ -645,7 +645,7 @@ export function Popover({// BottomSheet's scroll area is the panel's own child; content// sits inside it.element.parentElement !== sheetPanel &&- element.closest('[data-astryx-popover-fallback-close]') == null,+ element.closest(FALLBACK_CLOSE_SELECTOR) == null,);if (target != null) {target.focus({preventScroll: true});diff --git a/packages/core/src/Popover/usePopover.tsx b/packages/core/src/Popover/usePopover.tsxindex bc64eeb26f..6aa8868fea 100644--- a/packages/core/src/Popover/usePopover.tsx+++ b/packages/core/src/Popover/usePopover.tsx@@ -5,7 +5,8 @@/*** @file usePopover.tsx* @input Uses useLayer, useFocusTrap, React hooks- * @output Exports the public usePopover hook with derived focus and guarded opening.+ * @output Exports the public usePopover hook with derived focus and guarded opening,+ * and FALLBACK_CLOSE_SELECTOR for Popover.tsx (internal).* @position Higher-level layer utility; used by DatePicker, Combobox, etc.** Combines popover layer behavior with focus trap for dialog-like popovers.@@ -39,7 +40,11 @@ import {paddingStyles} from '../Layout/padding.stylex';import type {SpacingStep} from '../utils/types';import {stableClassName} from '../naming';-const FALLBACK_CLOSE_SELECTOR = '[data-astryx-popover-fallback-close]';+/**+ * The fallback close button's wrapper (anchored layer) or button (sheet,+ * Popover.tsx); initial focus skips it.+ */+export const FALLBACK_CLOSE_SELECTOR = '[data-astryx-popover-fallback-close]';function attemptFocus(element: HTMLElement): boolean {try {diff --git a/packages/core/src/Table/glidingDivider.ts b/packages/core/src/Table/glidingDivider.tsindex e1d071508b..7bb8caa1ac 100644--- a/packages/core/src/Table/glidingDivider.ts+++ b/packages/core/src/Table/glidingDivider.ts@@ -6,7 +6,8 @@* computed borders, StyleX* @output Exports `glidingDividerStyles` (a row's stand-in divider while it* glides), `markGlidingRows` (marks the moving rows for that glide and- * carries each row's own border onto the stand-in) and `rowEdge`+ * carries each row's own border onto the stand-in), `rowEdge`, and the+ * row and pinned-cell attribute names plugins/stickyColumns reads* @position Table internals. With collapsed borders the table paints every* border at its cell's static place, so a row that moves leaves its divider* behind. For the glide only, the moving row's cells are marked: their@@ -37,8 +38,12 @@ const CELL_ATTRIBUTE = 'data-astryx-cell-gliding';const CELL_GLIDING = '[data-astryx-cell-gliding]';const CELL_LINE = '[data-astryx-cell-gliding="line"]';-/** On a pinned (sticky) cell: plugins/stickyColumns. */-const PINNED_ATTRIBUTE = 'data-astryx-table-pinned';+/**+ * On a pinned (sticky) cell, written by plugins/stickyColumns. Named here+ * because that plugin already imports this module; naming it there would make+ * the two import each other.+ */+export const PINNED_ATTRIBUTE = 'data-astryx-table-pinned';/*** A row's divider, carried on the row for its glide. Names no cell sets, sodiff --git a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsxindex e800cc3b17..332d465f4f 100644--- a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx+++ b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx@@ -33,7 +33,7 @@ import type {} from '../../types';import {resolveColumnFloorWidths} from '../../columnUtils';import {collapsedBottom} from '../../rowDivider';-import {GLIDING_ATTRIBUTE} from '../../glidingDivider';+import {GLIDING_ATTRIBUTE, PINNED_ATTRIBUTE} from '../../glidingDivider';import {useTheme, useThemeName} from '../../../theme/useTheme';// =============================================================================@@ -183,7 +183,6 @@ const SHADOW_VAR_END = '--table-sticky-shadow-end';// border on the row, or the next row's top border), it is read after each// commit and on resize and carried as the cell's `carry` state// (syncPinnedDividers).-const PINNED_ATTRIBUTE = 'data-astryx-table-pinned';/** Spread into a pinned cell's props: the attribute the divider sync finds. */const PINNED_PROPS: Record<string, string> = {[PINNED_ATTRIBUTE]: ''};const CARRY = 'carry';diff --git a/packages/core/src/hooks/menuPressMarker.ts b/packages/core/src/hooks/menuPressMarker.tsnew file mode 100644index 0000000000..442057bb36--- /dev/null+++ b/packages/core/src/hooks/menuPressMarker.ts@@ -0,0 +1,15 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file menuPressMarker.ts+ * @input None (a plain attribute-name constant)+ * @output Exports MENU_PRESS_MARKER+ * @position Dependency-free home of the public menu-press marker, so the press+ * feedback controller (utils/pressFeedback.ts) can read it without loading+ * the menu-press hook into every pressable component's bundle.+ * useMenuPress.ts re-exports it; the public path stays+ * `@astryxdesign/core/hooks`.+ */++/** Marks a menu root that carries the menu press model (useMenuPress). */+export const MENU_PRESS_MARKER = 'data-astryx-menu-press';diff --git a/packages/core/src/hooks/useMenuPress.ts b/packages/core/src/hooks/useMenuPress.tsindex 451c2552c5..aad8315001 100644--- a/packages/core/src/hooks/useMenuPress.ts+++ b/packages/core/src/hooks/useMenuPress.ts@@ -66,13 +66,13 @@ import {type MenuPressGesture,type MenuPressPointerType,} from './menuPressGesture';+import {MENU_PRESS_MARKER} from './menuPressMarker';import {useLongPress, type UseLongPressHandlers} from './useLongPress';import {edgeAutoscroll} from '../utils/edgeAutoscroll';import {focusForLastInput} from '../utils/focusReturn';import {useInteractionModalityTrackingFor} from '../utils/interactionModality';-/** Marks a menu root that carries this press model. */-export const MENU_PRESS_MARKER = 'data-astryx-menu-press';+export {MENU_PRESS_MARKER};const MENU_PRESS_ROOT_SELECTOR = `[${MENU_PRESS_MARKER}]`;/*** Carried by a menu root that another root renders beside itself rather thandiff --git a/packages/core/src/utils/pressFeedback.ts b/packages/core/src/utils/pressFeedback.tsindex 59561d7d02..e88c89fe4e 100644--- a/packages/core/src/utils/pressFeedback.ts+++ b/packages/core/src/utils/pressFeedback.ts@@ -2,8 +2,9 @@/*** @file pressFeedback.ts- * @input The press state machine (pressGesture.ts) and the document's pointer,- * keyboard, scroll and visibility events+ * @input The press state machine (pressGesture.ts), the menu-press marker+ * (hooks/menuPressMarker.ts) and the document's pointer, keyboard, scroll and+ * visibility events* @output Exports PRESSABLE_ATTRIBUTE, PRESSED_ATTRIBUTE, pressableProps and* installPressFeedback* @position The DOM half of the touch press model: one delegated controller@@ -44,6 +45,7 @@* pressFeedback.test.ts.*/+import {MENU_PRESS_MARKER} from '../hooks/menuPressMarker';import type {PressGesture, PressPaint, PressStep} from './pressGesture';import {idlePressGesture,@@ -107,7 +109,7 @@ const SPACE_ACTIVATED_INPUT_TYPES: ReadonlySet<string> = new Set([* FR6, DEC-6): a press held on one row while the highlight follows the* pointer to another would light two rows.*/-const MENU_PRESS_ROOT = '[data-astryx-menu-press]';+const MENU_PRESS_ROOT = `[${MENU_PRESS_MARKER}]`;interface LiveGesture {element: HTMLElement;