-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore: Setup ai components package #10095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
snowystinger
wants to merge
13
commits into
main
Choose a base branch
from
setup-ai-components-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e81d477
chore: setup S2 AI components package
snowystinger d9e1578
fix all the lints
snowystinger 94d0817
cleanup
snowystinger 9eae6b9
fix lint
snowystinger ae6bb8c
add test, fix implementation, remove extra subpaths, split components
snowystinger d872fe4
fix ts
snowystinger 71c5fe2
fix build
snowystinger 33cf8f5
Merge branch 'main' into setup-ai-components-package
snowystinger 89b7e76
Merge branch 'main' into setup-ai-components-package
snowystinger 124504c
copy code and reduce new exports
snowystinger e194b37
reduce diff
snowystinger 29a82b7
undo
snowystinger 87f3c5a
fix all the things
snowystinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # @react-spectrum/s2-ai | ||
|
|
||
| This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export {Asset, AssetList} from '../src/AssetList'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export {BasicHorizontalCard, HorizontalCard, CardPreview} from '../src/HorizontalCard'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export {Asset, AssetList} from '../src/AssetList'; | ||
| export {BasicHorizontalCard, HorizontalCard} from '../src/HorizontalCard'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| { | ||
| "name": "@react-spectrum/s2-ai", | ||
| "version": "1.0.0-alpha.1", | ||
| "description": "Spectrum 2 UI AI components in React", | ||
| "license": "Apache-2.0", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/adobe/react-spectrum" | ||
| }, | ||
| "source": "exports/index.ts", | ||
| "files": [ | ||
| "dist", | ||
| "src", | ||
| "exports", | ||
| "*.js" | ||
| ], | ||
| "sideEffects": [ | ||
| "*.css" | ||
| ], | ||
| "main": "./dist/exports/index.cjs", | ||
| "module": "./dist/exports/index.mjs", | ||
| "types": "./dist/types/exports/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "source": "./exports/index.ts", | ||
| "types": "./dist/types/exports/index.d.ts", | ||
| "module": "./dist/exports/index.mjs", | ||
| "import": "./dist/exports/index.mjs", | ||
| "require": "./dist/exports/index.cjs" | ||
| }, | ||
| "./package.json": "./package.json", | ||
| "./*": { | ||
| "source": "./exports/*.ts", | ||
| "types": "./dist/types/exports/*.d.ts", | ||
| "import": "./dist/exports/*.mjs", | ||
| "require": "./dist/exports/*.cjs" | ||
| }, | ||
| "./private/*": null | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "scripts": { | ||
| "prepack": "npm pkg delete scripts devDependencies resolutions alias targets", | ||
| "postpack": "git checkout -- package.json" | ||
| }, | ||
| "dependencies": { | ||
| "@internationalized/date": "^3.12.1", | ||
| "@internationalized/number": "^3.6.6", | ||
| "@parcel/macros": "^2.16.3", | ||
| "@react-spectrum/s2": "^1.3.1", | ||
| "@react-types/shared": "^3.34.0", | ||
| "react-aria": "3.48.0", | ||
| "react-aria-components": "1.17.0", | ||
| "react-stately": "3.46.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@react-aria/test-utils": "^1.0.0-alpha.8", | ||
| "@storybook/jest": "^0.2.3", | ||
| "@testing-library/dom": "^10.1.0", | ||
| "@testing-library/react": "^16.0.0", | ||
| "@testing-library/user-event": "^14.0.0", | ||
| "react": "^19.0.0-rc.1", | ||
| "react-dom": "^19.0.0-rc.1" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^19.0.0-rc.1", | ||
| "react-dom": "^19.0.0-rc.1" | ||
| }, | ||
| "browserslist": "last 2 Chrome versions, last 2 Safari versions, last 2 Firefox versions, last 2 Edge versions", | ||
| "targets": { | ||
| "module": false, | ||
| "main": false, | ||
| "types": false, | ||
| "exports-module": { | ||
| "source": "exports/*.ts", | ||
| "distDir": "dist", | ||
| "isLibrary": true, | ||
| "outputFormat": "esmodule", | ||
| "includeNodeModules": false | ||
| }, | ||
| "exports-main": { | ||
| "source": "exports/*.ts", | ||
| "distDir": "dist", | ||
| "isLibrary": true, | ||
| "outputFormat": "commonjs", | ||
| "includeNodeModules": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| /* | ||
| * Copyright 2026 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 {AriaLabelingProps, DOMRef} from '@react-types/shared'; | ||
| import {baseColor, focusRing, style} from '@react-spectrum/s2/style' with {type: 'macro'}; | ||
| import {BasicHorizontalCard} from './HorizontalCard'; | ||
| import {Button} from 'react-aria-components/Button'; | ||
| import {CardProps} from '@react-spectrum/s2/Card'; | ||
| import Close from '@react-spectrum/s2/icons/Close'; | ||
| import {controlSize, getAllowedOverrides} from './style-utils-copy' with {type: 'macro'}; | ||
| import {forwardRef, useRef} from 'react'; | ||
| import {iconStyle} from '@react-spectrum/s2/style' with {type: 'macro'}; | ||
| import {pressScale} from '@react-spectrum/s2/pressScale'; | ||
| import {Tag, TagGroup, TagList} from 'react-aria-components/TagGroup'; | ||
| import {useDOMRef} from './useDOMRef'; | ||
|
|
||
| const hoverBackground = { | ||
| default: 'gray-200', | ||
| isStaticColor: 'transparent-overlay-200' | ||
| } as const; | ||
|
|
||
| const styles = style<{ | ||
| isDisabled: boolean; | ||
| isHovered: boolean; | ||
| isFocusVisible: boolean; | ||
| isPressed: boolean; | ||
| size: 'S' | 'M' | 'L' | 'XL'; | ||
| }>( | ||
| { | ||
| ...focusRing(), | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| size: controlSize(), | ||
| flexShrink: 0, | ||
| borderRadius: 'full', | ||
| padding: 0, | ||
| borderStyle: 'none', | ||
| transition: 'default', | ||
| backgroundColor: { | ||
| default: 'gray-200', | ||
| isHovered: hoverBackground, | ||
| isFocusVisible: hoverBackground, | ||
| isPressed: hoverBackground | ||
| }, | ||
| '--iconPrimary': { | ||
| type: 'color', | ||
| value: { | ||
| default: baseColor('neutral'), | ||
| isDisabled: 'disabled', | ||
| forcedColors: { | ||
| default: 'ButtonText', | ||
| isDisabled: 'GrayText' | ||
| } | ||
| } | ||
| }, | ||
| outlineColor: { | ||
| default: 'focus-ring', | ||
| forcedColors: 'Highlight' | ||
| }, | ||
| disableTapHighlight: true | ||
| }, | ||
| getAllowedOverrides() | ||
| ); | ||
|
|
||
| const closeIconStyle = ({size = 'M'}) => { | ||
| if (size === 'S') return iconStyle({size: 'XS'}); | ||
| else if (size === 'M') return iconStyle({size: 'S'}); | ||
| else if (size === 'L') return iconStyle({size: 'M'}); | ||
| else if (size === 'XL') return iconStyle({size: 'L'}); | ||
| else return iconStyle({size: 'S'}); | ||
| }; | ||
|
|
||
| const CloseButton = function CloseButton(props) { | ||
| let ref = useRef(null); | ||
| return ( | ||
| <Button | ||
| {...props} | ||
| ref={ref} | ||
| slot="remove" | ||
| style={pressScale(ref, {})} | ||
| className={renderProps => styles({...renderProps, size: props.size || 'M'}, props.styles)}> | ||
| <Close styles={closeIconStyle({size: props.size ?? 'M'})} /> | ||
| </Button> | ||
| ); | ||
| }; | ||
|
|
||
| let assetListStyles = style({}, getAllowedOverrides()); | ||
|
|
||
| export const AssetList = forwardRef(function AssetList(props: any, ref: DOMRef<HTMLDivElement>) { | ||
| let domRef = useDOMRef(ref); | ||
| return ( | ||
| <TagGroup {...props} className={assetListStyles(props.styles)} ref={domRef}> | ||
| <TagList | ||
| className={style({ | ||
| display: 'flex', | ||
| flexDirection: 'row', | ||
| gap: 16, | ||
| flexWrap: 'wrap', | ||
| alignItems: 'center', | ||
| width: 'full' | ||
| })}> | ||
| {props.children} | ||
| </TagList> | ||
| </TagGroup> | ||
| ); | ||
| }); | ||
|
|
||
| export const Asset = forwardRef(function Asset( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we call these AttachmentList / Attachment? I think that's the name design is using. |
||
| props: CardProps & AriaLabelingProps, | ||
| ref: DOMRef<HTMLDivElement> | ||
| ) { | ||
| let { | ||
| textValue, | ||
| 'aria-label': ariaLabel, | ||
| 'aria-labelledby': ariaLabelledby, | ||
| 'aria-describedby': ariaDescribedby, | ||
| ...otherProps | ||
| } = props; | ||
| let domRef = useDOMRef(ref); | ||
| return ( | ||
| <Tag | ||
| textValue={textValue} | ||
| aria-label={ariaLabel} | ||
| aria-labelledby={ariaLabelledby} | ||
| aria-describedby={ariaDescribedby} | ||
| ref={domRef} | ||
| className={style({flexShrink: 0, flexGrow: 0, position: 'relative'})}> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs focus ring? I'm seeing the native browser one |
||
| <BasicHorizontalCard {...otherProps}>{props.children}</BasicHorizontalCard> | ||
| {/** Definitely not a close button, though looks like one. */} | ||
| <div | ||
| className={style({ | ||
| position: 'absolute', | ||
| top: 0, | ||
| insetEnd: 0, | ||
| transform: 'translate(50%, -50%)' | ||
| })}> | ||
| <CloseButton size="XS" /> | ||
| </div> | ||
| </Tag> | ||
| ); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to just call it
@react-spectrum/ai?