-
Notifications
You must be signed in to change notification settings - Fork 8
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
Rewrite select #137
Merged
Merged
Rewrite select #137
Changes from 23 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
dfc2df1
Add select changes
vineethasok 6b6c563
Add Select Changes
vineethasok db87641
Remove drag feature
vineethasok da1ed82
Fix Select changes
vineethasok 4869b20
Fix tests
vineethasok 96586a3
Fix sort issue
vineethasok 012205f
Fix package install
vineethasok a6c5261
Remove yarn lock
vineethasok 0f1b611
Fix initial loading of the item
vineethasok d091ac5
Fix showSearch in storybook
vineethasok f588455
Update storybook orientation
vineethasok 2e93103
Call onSelect on value change
vineethasok 09a855f
Add Select Changes
vineethasok 10c917c
Fix Hidden Select Component
vineethasok 779b5d4
Fix linting issues
vineethasok 0ff570e
Fix show Search in Select
vineethasok 2fa34a2
Fix Select Open State issue
vineethasok 7aef59a
Add Select Changes
vineethasok 1714813
Add Select changes
vineethasok 79d47fc
Add Select Changes
vineethasok 8ce431c
Fix Multi select sorting
vineethasok 7d1adaa
Remove open from story book
vineethasok 3037322
Fix initial selection and also props naming
vineethasok c9fd4b6
Add styling changes
vineethasok a0e5ec6
Change onChange to onSelect in Select and MultiSelect props
vineethasok f3c7286
Fix Select Test
vineethasok 40a0950
Add types
vineethasok 55a48a2
Fix incorrect assignment
vineethasok 626241e
Fix Select Styling
vineethasok c487ce0
Merge branch 'main' into rewrite-select
vineethasok 721b8ac
Merge branch 'main' into rewrite-select
vineethasok 85460a1
Add Ellipsis changes
vineethasok 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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,55 @@ | ||
import { ReactNode } from "react"; | ||
import { HorizontalDirection, Icon, IconName } from "@/components"; | ||
import { IconSize } from "@/components/Icon/types"; | ||
import styled from "styled-components"; | ||
import { EllipsisContainer } from "../commonElement"; | ||
|
||
const LabelContainer = styled.span` | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
width: 100%; | ||
width: -webkit-fill-available; | ||
width: fill-available; | ||
width: stretch; | ||
gap: ${({ theme }) => theme.click.sidebar.navigation.item.default.space.gap}; | ||
`; | ||
|
||
const IconWrapper = ({ | ||
icon, | ||
iconDir = "start", | ||
size = "sm", | ||
width, | ||
height, | ||
children, | ||
}: { | ||
icon?: IconName; | ||
iconDir?: HorizontalDirection; | ||
children: ReactNode; | ||
size?: IconSize; | ||
width?: number | string; | ||
height?: number | string; | ||
}) => { | ||
return ( | ||
<LabelContainer> | ||
{icon && iconDir === "start" && ( | ||
<Icon | ||
name={icon} | ||
size={size} | ||
width={width} | ||
height={height} | ||
/> | ||
)} | ||
<EllipsisContainer>{children}</EllipsisContainer> | ||
{icon && iconDir === "end" && ( | ||
<Icon | ||
name={icon} | ||
size={size} | ||
width={width} | ||
height={height} | ||
/> | ||
)} | ||
</LabelContainer> | ||
); | ||
}; | ||
export default IconWrapper; |
This file contains 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,137 @@ | ||
import { Icon } from "@/components"; | ||
import { MultiSelect, MultiSelectProps } from "./MultiSelect"; | ||
import { selectOptions } from "./selectOptions"; | ||
import { useEffect, useState } from "react"; | ||
interface Props extends Omit<MultiSelectProps, "value"> { | ||
clickableNoData?: boolean; | ||
value: string; | ||
childrenType: "children" | "options"; | ||
} | ||
const MultiSelectExample = ({ | ||
clickableNoData, | ||
childrenType, | ||
value, | ||
...props | ||
}: Props) => { | ||
const [selectedValues, setSelectedValues] = useState( | ||
value ? value.split(",") : undefined | ||
); | ||
useEffect(() => { | ||
setSelectedValues(value ? value.split(",") : undefined); | ||
}, [value]); | ||
|
||
if (childrenType === "options") { | ||
return ( | ||
<MultiSelect | ||
value={selectedValues} | ||
onCreateOption={ | ||
clickableNoData ? search => console.log("Clicked ", search) : undefined | ||
} | ||
options={selectOptions} | ||
onChange={value => setSelectedValues(value)} | ||
{...props} | ||
/> | ||
); | ||
} | ||
return ( | ||
<MultiSelect | ||
value={value ? value.split(",") : undefined} | ||
onCreateOption={ | ||
clickableNoData ? search => console.log("Clicked ", search) : undefined | ||
} | ||
{...props} | ||
> | ||
<MultiSelect.Group heading="Group label"> | ||
<MultiSelect.Item value="content0"> | ||
<Icon name="user" /> | ||
Content0 | ||
</MultiSelect.Item> | ||
</MultiSelect.Group> | ||
<div> | ||
<MultiSelect.Item value="content1">Content1 long text content</MultiSelect.Item> | ||
</div> | ||
<MultiSelect.Item | ||
value="content2" | ||
label="Content2" | ||
/> | ||
<MultiSelect.Item value="content3">Content3</MultiSelect.Item> | ||
</MultiSelect> | ||
); | ||
}; | ||
export default { | ||
component: MultiSelectExample, | ||
title: "Forms/MultiSelect", | ||
tags: ["form-field", "select", "autodocs"], | ||
argTypes: { | ||
label: { control: "text" }, | ||
disabled: { control: "boolean" }, | ||
sortable: { control: "boolean" }, | ||
error: { control: "text" }, | ||
value: { control: "text" }, | ||
defaultValue: { control: "text" }, | ||
name: { control: "text" }, | ||
required: { control: "boolean" }, | ||
showSearch: { control: "boolean" }, | ||
form: { control: "text" }, | ||
clickableNoData: { control: "boolean" }, | ||
showCheck: { control: "boolean" }, | ||
orientation: { control: "inline-radio", options: ["horizontal", "vertical"] }, | ||
dir: { control: "inline-radio", options: ["start", "end"] }, | ||
}, | ||
}; | ||
|
||
export const Playground = { | ||
args: { | ||
label: "Label", | ||
value: "content1", | ||
showSearch: true, | ||
childrenType: "children", | ||
}, | ||
parameters: { | ||
docs: { | ||
source: { | ||
transform: (_: string, story: { args: Props; [x: string]: unknown }) => { | ||
const { clickableNoData, childrenType, value, ...props } = story.args; | ||
return `<MultiSelect\n value={${JSON.stringify((value ?? "").split(","))}}\n${ | ||
clickableNoData | ||
? " onCreateOption={search => console.log('Clicked ', search)}\n" | ||
: "" | ||
} | ||
${Object.entries(props) | ||
.flatMap(([key, value]) => | ||
typeof value === "boolean" | ||
? value | ||
? ` ${key}` | ||
: [] | ||
: ` ${key}=${typeof value == "string" ? `"${value}"` : `{${value}}`}` | ||
) | ||
.join("\n")} | ||
${childrenType === "options" ? "/" : ""}> | ||
${ | ||
childrenType !== "options" | ||
? ` | ||
<MultiSelect.Group heading="Group label"> | ||
<MultiSelect.Item value="content0"> | ||
<Icon name="user" /> | ||
Content0 | ||
</MultiSelect.Item> | ||
</MultiSelect.Group> | ||
<div> | ||
<MultiSelect.Item value="content1">Content1 long text content</MultiSelect.Item> | ||
</div> | ||
<MultiSelect.Item | ||
value="content2" | ||
disabled | ||
> | ||
Content2 | ||
</MultiSelect.Item> | ||
<MultiSelect.Item value="content3">Content3</MultiSelect.Item> | ||
</Select> | ||
` | ||
: "" | ||
}`; | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
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.
label is not aligned when there's an error
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.
This error may happen to the input and other form elements too
Should I fix them in this PR or a new one separately for them? @serdec
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.
another one is ok