diff --git a/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx b/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx index e638a2ec08b..239a7727355 100644 --- a/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx +++ b/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx @@ -15,7 +15,7 @@ import {XIcon} from '@primer/octicons-react' import classes from './AnchoredOverlay.module.css' import {clsx} from 'clsx' import {useFeatureFlag} from '../FeatureFlags' -import {widthMap} from '../Overlay/Overlay' +import {widthMap} from '../Overlay/constants' interface AnchoredOverlayPropsWithAnchor { /** diff --git a/packages/react/src/KeybindingHint/KeybindingHint.tsx b/packages/react/src/KeybindingHint/KeybindingHint.tsx index 00f3b28b908..7e837d27e1d 100644 --- a/packages/react/src/KeybindingHint/KeybindingHint.tsx +++ b/packages/react/src/KeybindingHint/KeybindingHint.tsx @@ -2,8 +2,7 @@ import {type ReactNode} from 'react' import {memo} from 'react' import Text from '../Text' import type {KeybindingHintProps} from './props' -import {accessibleSequenceString, Sequence} from './components/Sequence' -import type {Platform} from './platform' +import {Sequence} from './components/Sequence' import classes from './KeybindingHint.module.css' import {clsx} from 'clsx' @@ -30,18 +29,3 @@ export const KeybindingHint = memo(({className, ...props}: KeybindingHintProps) )) KeybindingHint.displayName = 'KeybindingHint' - -/** - * AVOID: `KeybindingHint` is nearly always sufficient for providing both visible and accessible keyboard hints. - * However, there may be cases where we need a plain string version, such as when building `aria-label` or - * `aria-description`. In that case, this plain string builder can be used instead. - * - * NOTE that this string should _only_ be used when building `aria-label` or `aria-description` props (never rendered - * visibly) and should nearly always also be paired with a visible hint for sighted users. - * - * The `platform` argument controls how platform-specific keys (such as `Meta`, `Alt`, and `Mod`) are named. For - * backwards compatibility, a `boolean` may be passed instead, where `true` is treated as `'apple'` and `false` as - * `'other'`. - */ -export const getAccessibleKeybindingHintString = (sequence: string, platform: Platform | boolean) => - accessibleSequenceString(sequence, typeof platform === 'boolean' ? (platform ? 'apple' : 'other') : platform) diff --git a/packages/react/src/KeybindingHint/components/Chord.tsx b/packages/react/src/KeybindingHint/components/Chord.tsx index 11120d20ffc..b07f8c9c68a 100644 --- a/packages/react/src/KeybindingHint/components/Chord.tsx +++ b/packages/react/src/KeybindingHint/components/Chord.tsx @@ -4,7 +4,7 @@ import type {KeybindingHintProps} from '../props' import {Key} from './Key' import {clsx} from 'clsx' import classes from './Chord.module.css' -import {accessibleChordString, splitChord} from './utils' +import {splitChord} from './utils' export const Chord = ({keys, format = 'condensed', variant = 'normal', size = 'normal'}: KeybindingHintProps) => ( sequence.split(' ') @@ -20,5 +19,3 @@ export const Sequence = ({keys, ...chordProps}: KeybindingHintProps) => )) - -export {accessibleSequenceString} diff --git a/packages/react/src/KeybindingHint/index.ts b/packages/react/src/KeybindingHint/index.ts index dc5f4cb31d5..195dccefdc9 100644 --- a/packages/react/src/KeybindingHint/index.ts +++ b/packages/react/src/KeybindingHint/index.ts @@ -1,3 +1,4 @@ -export * from './KeybindingHint' +export {KeybindingHint} from './KeybindingHint' +export {getAccessibleKeybindingHintString} from './utils' export type {KeybindingHintProps} from './props' diff --git a/packages/react/src/KeybindingHint/utils.ts b/packages/react/src/KeybindingHint/utils.ts new file mode 100644 index 00000000000..93b1096f210 --- /dev/null +++ b/packages/react/src/KeybindingHint/utils.ts @@ -0,0 +1,17 @@ +import {accessibleSequenceString} from './components/utils' +import type {Platform} from './platform' + +/** + * AVOID: `KeybindingHint` is nearly always sufficient for providing both visible and accessible keyboard hints. + * However, there may be cases where we need a plain string version, such as when building `aria-label` or + * `aria-description`. In that case, this plain string builder can be used instead. + * + * NOTE that this string should _only_ be used when building `aria-label` or `aria-description` props (never rendered + * visibly) and should nearly always also be paired with a visible hint for sighted users. + * + * The `platform` argument controls how platform-specific keys (such as `Meta`, `Alt`, and `Mod`) are named. For + * backwards compatibility, a `boolean` may be passed instead, where `true` is treated as `'apple'` and `false` is + * treated as `'other'`. + */ +export const getAccessibleKeybindingHintString = (sequence: string, platform: Platform | boolean) => + accessibleSequenceString(sequence, typeof platform === 'boolean' ? (platform ? 'apple' : 'other') : platform) diff --git a/packages/react/src/Overlay/Overlay.tsx b/packages/react/src/Overlay/Overlay.tsx index 22e12673ee6..31ee7ebcf5d 100644 --- a/packages/react/src/Overlay/Overlay.tsx +++ b/packages/react/src/Overlay/Overlay.tsx @@ -10,7 +10,7 @@ import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../uti import classes from './Overlay.module.css' import {clsx} from 'clsx' import {useFeatureFlag} from '../FeatureFlags' -import {heightMap, widthMap} from './constants' +import type {heightMap, widthMap} from './constants' type StyledOverlayProps = { width?: keyof typeof widthMap @@ -22,7 +22,6 @@ type StyledOverlayProps = { style?: React.CSSProperties } -export {heightMap, widthMap} const animationDuration = 200 function getSlideAnimationStartingVector(anchorSide?: AnchorSide): {x: number; y: number} { diff --git a/packages/react/src/TextInputWithTokens/TextInputWithTokens.test.tsx b/packages/react/src/TextInputWithTokens/TextInputWithTokens.test.tsx index f5cbceea2c0..39dd3684811 100644 --- a/packages/react/src/TextInputWithTokens/TextInputWithTokens.test.tsx +++ b/packages/react/src/TextInputWithTokens/TextInputWithTokens.test.tsx @@ -2,7 +2,7 @@ import React from 'react' import {render as HTMLRender, fireEvent, act, render} from '@testing-library/react' import {describe, expect, it, vi, beforeEach, afterEach} from 'vitest' import type {TokenSizeKeys} from '../Token/TokenBase' -import {tokenSizes} from '../Token/TokenBase' +import {tokenSizes} from '../Token/constants' import {IssueLabelToken} from '../Token' import type {TextInputWithTokensProps} from '../TextInputWithTokens' import TextInputWithTokens from '../TextInputWithTokens' diff --git a/packages/react/src/Timeline/Timeline.stories.tsx b/packages/react/src/Timeline/Timeline.stories.tsx index e9ec3204d6c..7dd6a50dfd5 100644 --- a/packages/react/src/Timeline/Timeline.stories.tsx +++ b/packages/react/src/Timeline/Timeline.stories.tsx @@ -2,7 +2,8 @@ import type {Meta, StoryFn} from '@storybook/react-vite' import React from 'react' import {useArgs} from 'storybook/preview-api' import type {ComponentProps} from '../utils/types' -import Timeline, {TimelineBadgeVariants, type TimelineBadgeVariant} from './Timeline' +import Timeline, {type TimelineBadgeVariant} from './Timeline' +import {TimelineBadgeVariants} from './constants' import Avatar from '../Avatar' import {Button} from '../Button' import Link from '../Link' diff --git a/packages/react/src/Timeline/Timeline.tsx b/packages/react/src/Timeline/Timeline.tsx index 1932a779ac2..a3d257ed4e5 100644 --- a/packages/react/src/Timeline/Timeline.tsx +++ b/packages/react/src/Timeline/Timeline.tsx @@ -2,7 +2,7 @@ import {clsx} from 'clsx' import React from 'react' import {useFeatureFlag} from '../FeatureFlags' import classes from './Timeline.module.css' -import {TimelineBadgeVariants} from './constants' +import type {TimelineBadgeVariants} from './constants' type StyledTimelineProps = {clipSidebar?: boolean | 'start' | 'end' | 'both'; className?: string} @@ -84,8 +84,6 @@ const TimelineItem = React.forwardRef { const widthToFit = navWidth - moreMenuWidth let breakpoint = childWidthArray.length // assume all items will fit diff --git a/packages/react/src/experimental/SelectPanel2/SelectPanel.tsx b/packages/react/src/experimental/SelectPanel2/SelectPanel.tsx index cc9efdea44a..e43442e5ced 100644 --- a/packages/react/src/experimental/SelectPanel2/SelectPanel.tsx +++ b/packages/react/src/experimental/SelectPanel2/SelectPanel.tsx @@ -17,7 +17,8 @@ import {ActionListContainerContext} from '../../ActionList/ActionListContainerCo import {useSlots} from '../../hooks/useSlots' import {useProvidedRefOrCreate, useId, useAnchoredPosition} from '../../hooks' import type {OverlayProps} from '../../Overlay/Overlay' -import {BaseOverlay, heightMap} from '../../Overlay/Overlay' +import {BaseOverlay} from '../../Overlay/Overlay' +import {heightMap} from '../../Overlay/constants' import {InputLabel} from '../../internal/components/InputLabel' import {invariant} from '../../utils/invariant' import {AriaStatus} from '../../live-region' diff --git a/packages/react/src/experimental/SelectPanel2/index.tsx b/packages/react/src/experimental/SelectPanel2/index.tsx index 34390b81ce8..0482ca2311c 100644 --- a/packages/react/src/experimental/SelectPanel2/index.tsx +++ b/packages/react/src/experimental/SelectPanel2/index.tsx @@ -1 +1,2 @@ -export * from './SelectPanel' +export {SelectPanel} from './SelectPanel' +export type {SelectPanelMessageProps, SelectPanelProps, SelectPanelSecondaryActionProps} from './SelectPanel' diff --git a/packages/react/src/utils/story-helpers.tsx b/packages/react/src/utils/story-helpers.ts similarity index 100% rename from packages/react/src/utils/story-helpers.tsx rename to packages/react/src/utils/story-helpers.ts