generated from abelflopes/lerna-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: select support groups #10
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
abelflopes
wants to merge
4
commits into
master
Choose a base branch
from
feat/7-select-support-groups
base: master
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
4 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
| import React from "react"; | ||
| import { DISPLAY_NAME_ATTRIBUTE } from "@react-ck/react-utils"; | ||
| import { type SelectGroupProps } from "./types"; | ||
| import { Text } from "../text"; | ||
| import styles from "./styles/index.module.scss"; | ||
| import { useManagerContext } from "@react-ck/manager"; | ||
|
|
||
| /** | ||
| * A group component for organizing Select options with a label. | ||
| * Provides visual separation and organization for related options. | ||
| * | ||
| * @example | ||
| * ```tsx | ||
| * <Select> | ||
| * <Select.Group name="Fruits"> | ||
| * <Select.Option value="apple">Apple</Select.Option> | ||
| * <Select.Option value="banana">Banana</Select.Option> | ||
| * </Select.Group> | ||
| * <Select.Group name="Vegetables"> | ||
| * <Select.Option value="carrot">Carrot</Select.Option> | ||
| * <Select.Option value="broccoli">Broccoli</Select.Option> | ||
| * </Select.Group> | ||
| * </Select> | ||
| * ``` | ||
| * | ||
| * @param props - Component props {@link SelectGroupProps} | ||
| * @returns React element | ||
| */ | ||
| const SelectGroup = ({ | ||
| name, | ||
| children, | ||
| }: Readonly<Omit<SelectGroupProps, "disabled">>): React.ReactElement => { | ||
| const { generateUniqueId } = useManagerContext(); | ||
|
|
||
| const uniqueId = generateUniqueId(); | ||
|
|
||
| return ( | ||
| <div role="group" aria-labelledby={uniqueId} className={styles.group}> | ||
| <div id={uniqueId} className={styles.group_name}> | ||
| <Text margin="none" variation="small" skin={["bold", "soft"]}> | ||
| {name} | ||
| </Text> | ||
| </div> | ||
| {children} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| SelectGroup[DISPLAY_NAME_ATTRIBUTE] = "SelectGroup"; | ||
|
|
||
| export { SelectGroup }; |
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
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.
Preserve SelectGroup props when rebuilding grouped options
We rebuild each group but only pass
name, dropping every other prop coming from the original<Select.Group>(e.g.description,disabled,className, test ids). Any consumer relying on those props loses functionality as soon as a search term is applied. Please carry the capturedselectGroupPropsforward when rendering the grouped result so groups behave identically before and after filtering.Suggested approach:
Make sure to import
SelectGroupProps(or reuse the existing type) accordingly.📝 Committable suggestion
🤖 Prompt for AI Agents