Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions packages/@react-spectrum/ai/src/PromptField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export interface PromptFieldProps {
styles?: StyleString;
variant?: 'balanced' | 'prominent' | 'subtle';
brandColor?: string;
hideDisclaimer?: boolean;
}

interface PromptFieldState {
Expand Down Expand Up @@ -193,7 +192,6 @@ export const PromptField = forwardRef(function PromptField(
styles,
onAddAttachments,
onRemoveAttachments,
hideDisclaimer,
variant = 'balanced',
brandColor
} = props;
Expand Down Expand Up @@ -286,17 +284,15 @@ export const PromptField = forwardRef(function PromptField(
inputRef={inputRef}>
{children}
</PromptFieldContainer>
{!hideDisclaimer && (
<p className={style({font: 'ui-sm', textAlign: 'center'})}>
{stringFormatter.format('promptfield.aiDisclaimer')}{' '}
<Link
variant="secondary"
href="https://www.adobe.com/legal/licenses-terms/adobe-gen-ai-user-guidelines.html"
target="_blank">
{stringFormatter.format('promptfield.aiUserGuidlines')}
</Link>
</p>
)}
<p className={style({font: 'ui-sm', textAlign: 'center'})}>
{stringFormatter.format('promptfield.aiDisclaimer')}{' '}
<Link
variant="secondary"
href="https://www.adobe.com/legal/licenses-terms/adobe-gen-ai-user-guidelines.html"
target="_blank">
{stringFormatter.format('promptfield.aiUserGuidlines')}
</Link>
</p>
</div>
</PromptFieldContext.Provider>
);
Expand Down
52 changes: 30 additions & 22 deletions packages/@react-spectrum/s2/src/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,19 @@ const SideNavItemLinkContext = createContext<{
onPressChange?: (isPressed: boolean) => void;
}>({});

const SideNavInternalItemContext = createContext<{setLinkPressed?: (isPressed: boolean) => void}>(
{}
);

export const SideNavItem = (props: SideNavItemProps): ReactNode => {
let {href, hrefLang, target, rel, download, ping, referrerPolicy, routerOptions, ...rest} = props;

let hasLink = href != null && href.length > 0;
let [isLinkPressed, setLinkPressed] = useState(false);
let rowRef = useRef<HTMLDivElement | null>(null);
// oxlint-disable-next-line react-compiler
let scaling = pressScale(rowRef);

return (
<SideNavItemLinkContext.Provider
value={{
Expand All @@ -338,13 +347,17 @@ export const SideNavItem = (props: SideNavItemProps): ReactNode => {
referrerPolicy,
routerOptions
}}>
<TreeItem
{...rest}
href={href}
focusMode={hasLink ? 'child' : undefined}
allowsArrowNavigation
className={renderProps => treeRow(renderProps)}
/>
<SideNavInternalItemContext.Provider value={{setLinkPressed}}>
<TreeItem
{...rest}
ref={rowRef}
style={({isPressed}) => scaling({isPressed: isLinkPressed || isPressed})}
href={href}
focusMode={hasLink ? 'child' : undefined}
allowsArrowNavigation
className={renderProps => treeRow(renderProps)}
/>
</SideNavInternalItemContext.Provider>
</SideNavItemLinkContext.Provider>
);
};
Expand Down Expand Up @@ -415,6 +428,7 @@ export const SideNavItemContent = (props: SideNavItemContentProps): ReactNode =>
let {children} = props;
let scale = useScale();
let linkProps = useContext(SideNavItemLinkContext);
let {setLinkPressed} = useContext(SideNavInternalItemContext);
let {selectedRoute} = useContext(InternalSideNavContext);

return (
Expand All @@ -437,6 +451,7 @@ export const SideNavItemContent = (props: SideNavItemContentProps): ReactNode =>
hasChildItems={hasChildItems}
isDisabled={isDisabled}
isSelected={isSelected}
setLinkPressed={setLinkPressed}
linkProps={linkProps}
scale={scale}
id={id}
Expand All @@ -460,13 +475,13 @@ const SideNavItemContentInner = props => {
hasChildItems,
isDisabled,
isSelected,
setLinkPressed,
linkProps,
scale,
id,
state,
selectedRoute,
isHovered,
isPressed,
isFocusVisible,
isFocusVisibleWithin,
children
Expand All @@ -478,38 +493,31 @@ const SideNavItemContentInner = props => {
// keyboard-only isFocusVisibleWithin below, this lets the row focus ring follow the link
// specifically and not other focusable children (e.g. an ActionMenu trigger).
let [isLinkFocused, setLinkFocused] = useState(false);
let [isLinkPressed, setLinkPressed] = useState(false);
let cellRef = useRef<HTMLDivElement | null>(null);

let hasLink = linkProps.href != null && linkProps.href.length > 0;

// oxlint-disable-next-line react-compiler
let itemScaling = pressScale(cellRef)({isPressed: isLinkPressed || isPressed});

return (
<>
<div
ref={cellRef}
className={treeRowFocusRing({
isFocusVisible: isFocusVisible || (isFocusVisibleWithin && isLinkFocused),
isSelected
})}
/>
<div
className={treeCellGrid({
isDisabled,
isSelected: linkProps.href === selectedRoute,
isDescendantSelected:
!isExpanded && hasChildItems && hasSelectedDescendant(id, state, selectedRoute)
})}
style={itemScaling}>
})}>
<div
className={indicator({
isDisabled,
isSelected: linkProps.href === selectedRoute,
isHovered: isHovered && hasLink
})}
/>
<div
className={treeRowFocusRing({
isFocusVisible: isFocusVisible || (isFocusVisibleWithin && isLinkFocused),
isSelected
})}
/>
<div
className={style({
gridArea: 'level-padding',
Expand Down
Loading