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
43 changes: 11 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const meta = {
options: { control: { type: 'object' } },
multiple: { control: { type: 'boolean' } },
value: { control: { type: 'object' } },
prefix: { control: { type: 'text' } },
defaultValue: { control: { type: 'object' } },
placeholder: { control: { type: 'text' } },
searchable: { control: { type: 'boolean' } },
Expand Down Expand Up @@ -109,6 +110,7 @@ export const WithSelectAll: Story = {

export const Searchable: Story = {
args: {
prefix: 'Filter:',
searchable: true,
},
};
Expand Down
26 changes: 24 additions & 2 deletions src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface DialSelectProps {
options: SelectOption[];
multiple?: boolean;
value?: string | string[];
prefix?: string;
defaultValue?: string | string[];
placeholder?: string;
searchable?: boolean;
Expand Down Expand Up @@ -77,6 +78,7 @@ export interface DialSelectProps {
* @param options - Array of options to select from.
* @param [multiple] - Whether multiple selections are allowed.
* @param [value] - Controlled selected value(s).
* @param [prefix] - Prefix for selected value(s).
* @param [defaultValue] - Uncontrolled initial selected value(s).
* @param [placeholder] - Placeholder text when no selection is made.
* @param [searchable] - Whether to show a search input to filter options.
Expand All @@ -97,6 +99,7 @@ export const DialSelect: FC<DialSelectProps> = ({
multiple = false,
value,
defaultValue,
prefix,
placeholder = 'Select...',
searchable = false,
searchPlaceholder,
Expand Down Expand Up @@ -245,13 +248,26 @@ export const DialSelect: FC<DialSelectProps> = ({
{singleSelectedOption.icon && (
<DialIcon icon={singleSelectedOption.icon} />
)}
<DialEllipsisTooltip text={singleSelectedOption.label} />
<DialEllipsisTooltip
text={
prefix
? `${prefix} ${singleSelectedOption.label}`
: singleSelectedOption.label
}
/>
</>
);
}

return <span className="text-secondary truncate">{placeholder}</span>;
}, [hasSelection, multiple, placeholder, renderTags, singleSelectedOption]);
}, [
hasSelection,
multiple,
prefix,
placeholder,
renderTags,
singleSelectedOption,
]);

return (
<DialDropdown
Expand Down Expand Up @@ -373,6 +389,12 @@ export const DialSelect: FC<DialSelectProps> = ({
<div className="flex items-center gap-2 w-full">
{opt.icon && <DialIcon icon={opt.icon} />}
<DialEllipsisTooltip text={opt.label} />

{opt.description && (
<div className="text-secondary dial-small">
{opt.description}
</div>
)}
</div>
</button>
);
Expand Down