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
77 changes: 77 additions & 0 deletions packages/@react-spectrum/s2/chromatic/SelectBoxGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2025 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import {action} from '@storybook/addon-actions';
import type {Meta, StoryObj} from '@storybook/react';
import PaperAirplane from '../spectrum-illustrations/linear/Paperairplane';
import React from 'react';
import {SelectBox, SelectBoxGroup, Text} from '../src';
import Server from '../spectrum-illustrations/linear/Server';

const meta: Meta<typeof SelectBoxGroup> = {
component: SelectBoxGroup,
parameters: {
chromaticProvider: {disableAnimations: true}
},
title: 'S2 Chromatic/SelectBoxGroup'
};

export default meta;
type Story = StoryObj<typeof SelectBoxGroup>;

export const VerticalOrientation: Story = {
render: () => (
<div style={{width: 600}}>
<SelectBoxGroup
orientation="vertical"
onSelectionChange={action('onSelectionChange')}>
<SelectBox value="text-only">
<Text slot="label">V: Text Only</Text>
</SelectBox>
<SelectBox value="illustration-text">
<Server />
<Text slot="label">V: Illustration + Text</Text>
</SelectBox>
<SelectBox value="illustration-desc">
<PaperAirplane />
</SelectBox>
</SelectBoxGroup>
</div>
)
};

export const HorizontalOrientation: Story = {
render: () => (
<div style={{width: 800}}>
<SelectBoxGroup
orientation="horizontal"
onSelectionChange={action('onSelectionChange')}>
<SelectBox value="text-only">
<Text slot="label">Title Only</Text>
</SelectBox>
<SelectBox value="illustration-text">
<Server />
<Text slot="label">Illustration + Title</Text>
</SelectBox>
<SelectBox value="text-desc">
<Text slot="label">Title + Description</Text>
<Text slot="description">Additional description</Text>
</SelectBox>
<SelectBox value="h-all">
<Server />
<Text slot="label">Illustration + Title + Description</Text>
<Text slot="description">Full horizontal layout with all elements</Text>
</SelectBox>
</SelectBoxGroup>
</div>
)
};
23 changes: 4 additions & 19 deletions packages/@react-spectrum/s2/src/SelectBoxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,7 @@ import React, {createContext, forwardRef, ReactNode, useContext, useMemo, useRef
import {TextContext} from './Content';
import {useSpectrumContextProps} from './useSpectrumContextProps';

type ExcludedListBoxProps =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like we were excluding these but maybe they weren't picked up on the tsdiff? anyway, i decided to remove them and just add them directly to the Omit

| keyof GlobalDOMAttributes
| 'layout'
| 'dragAndDropHooks'
| 'renderEmptyState'
| 'dependencies'
| 'items'
| 'onAction'
| 'children'
| 'selectionMode'
| 'shouldSelectOnPress'
| 'shouldFocusWrap'
| 'selectionBehavior'
| 'shouldSelectOnFocus';

export interface SelectBoxGroupProps<T> extends StyleProps, Omit<ListBoxProps<T>, ExcludedListBoxProps> {
export interface SelectBoxGroupProps<T> extends StyleProps, Omit<ListBoxProps<T>, keyof GlobalDOMAttributes | 'layout' | 'dragAndDropHooks' | 'dependencies' | 'renderEmptyState' | 'children' | 'onAction' | 'shouldFocusOnHover' | 'selectionBehavior' | 'style' | 'className'> {
/**
* The SelectBox elements contained within the SelectBoxGroup.
*/
Expand All @@ -67,7 +52,7 @@ export interface SelectBoxProps extends StyleProps {
/**
* The label for the element.
*/
children?: ReactNode,
children: ReactNode,
/**
* Whether the SelectBox is disabled.
*/
Expand Down Expand Up @@ -320,7 +305,7 @@ export function SelectBox(props: SelectBoxProps): ReactNode {
className={style({
position: 'absolute',
top: 8,
left: 8,
insetStart: 8,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed that the checkbox was showing up on the wrong side when i added it to chromatic

pointerEvents: 'none'
})}
aria-hidden="true">
Expand Down Expand Up @@ -369,7 +354,7 @@ export function SelectBox(props: SelectBoxProps): ReactNode {
/*
* SelectBoxGroup allows users to select one or more options from a list.
*/
export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T>(props: SelectBoxGroupProps<T>, ref: DOMRef<HTMLDivElement>) {
export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T extends object>(props: SelectBoxGroupProps<T>, ref: DOMRef<HTMLDivElement>) {
[props, ref] = useSpectrumContextProps(props, ref, SelectBoxGroupContext);

let {
Expand Down
28 changes: 12 additions & 16 deletions packages/@react-spectrum/s2/stories/SelectBoxGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
/*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just changed this to match how our files do it

* Copyright 2025 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Copyright 2025 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
**************************************************************************/
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import {action} from '@storybook/addon-actions';
import AlertNotice from '../spectrum-illustrations/linear/AlertNotice';
Expand Down Expand Up @@ -312,5 +307,6 @@ export const AllSlotCombinations: Story = {
</div>

</div>
)
),
tags: ['!autodocs']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could either remove this and rely on chromatic or leave this in storybook and remove it from the docs

};