diff --git a/apps/design-system/src/components/SingleSelect.stories.tsx b/apps/design-system/src/components/Dropdown.stories.tsx similarity index 77% rename from apps/design-system/src/components/SingleSelect.stories.tsx rename to apps/design-system/src/components/Dropdown.stories.tsx index d95219d14..8647e1df5 100644 --- a/apps/design-system/src/components/SingleSelect.stories.tsx +++ b/apps/design-system/src/components/Dropdown.stories.tsx @@ -1,20 +1,20 @@ -import { SelectDropdown, SelectDropdownOption } from '@asyncapi/studio-ui' +import { Dropdown, DropdownOption } from '@asyncapi/studio-ui' import type { Meta, StoryObj } from "@storybook/react" /* eslint-disable import/no-anonymous-default-export */ -const meta: Meta = { - component: SelectDropdown, +const meta: Meta = { + component: Dropdown, parameters: { layout: "fullscreen", backgrounds: { - default: "dark", + default: "light", }, }, } export default meta -const options: SelectDropdownOption[] = [ +const options: DropdownOption[] = [ { type: "group", label: "MQTT", @@ -57,7 +57,7 @@ const options: SelectDropdownOption[] = [ value: "socket.io", }, ] -type Story = StoryObj +type Story = StoryObj export const Default: Story = { args: { options, diff --git a/apps/design-system/src/components/Form.stories.tsx b/apps/design-system/src/components/Form.stories.tsx index 83f0c2bf4..c6237432c 100644 --- a/apps/design-system/src/components/Form.stories.tsx +++ b/apps/design-system/src/components/Form.stories.tsx @@ -9,7 +9,7 @@ import { IconButton, TextInput, Label, - SelectDropdown, + Dropdown, ChipInput, } from "@asyncapi/studio-ui" import { AddIcon, TrashIcon } from "@asyncapi/studio-ui/icons" @@ -35,7 +35,6 @@ const singleSelectOptions = [ { label: "Pulsar", value: "pulsar" }, ] export const Default = () => ( - <>
(
- + @@ -70,7 +69,7 @@ export const Default = () => (
- +
@@ -80,7 +79,7 @@ export const Default = () => (
- +
@@ -103,5 +102,4 @@ export const Default = () => ( - ) diff --git a/packages/ui/components/Form/Inputs/SelectDropdown.tsx b/packages/ui/components/Form/Inputs/Dropdown.tsx similarity index 69% rename from packages/ui/components/Form/Inputs/SelectDropdown.tsx rename to packages/ui/components/Form/Inputs/Dropdown.tsx index a5ad5aa3c..55256eb00 100644 --- a/packages/ui/components/Form/Inputs/SelectDropdown.tsx +++ b/packages/ui/components/Form/Inputs/Dropdown.tsx @@ -2,17 +2,17 @@ import * as RadixSelect from '@radix-ui/react-select' import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from '../../icons' import classnames from 'classnames' -type SelectDropdownRegularOption = { +type DropdownRegularOption = { type?: 'regular' value: string label: string } -type SelectDropdownRegularOptionProps = { - option: SelectDropdownRegularOption +type DropdownRegularOptionProps = { + option: DropdownRegularOption } -const SelectDropdownRegularOption = ({ option: { value, label } }: SelectDropdownRegularOptionProps) => { +const DropdownRegularOption = ({ option: { value, label } }: DropdownRegularOptionProps) => { return ( { +const DropdownGroupOption = ({ option: { label, options } }: DropdownGroupOptionProps) => { return ( <> {label} {options.map((option) => ( - + ))} ) } -type SelectDropdownSeparatorOption = { +type DropdownSeparatorOption = { type: 'separator' } -const SelectDropdownSeparatorOption = () => { +const DropdownSeparatorOption = () => { return } -export type SelectDropdownOption = SelectDropdownGroupOption | SelectDropdownRegularOption | SelectDropdownSeparatorOption +export type DropdownOption = DropdownGroupOption | DropdownRegularOption | DropdownSeparatorOption -type SelectDropdownOptionProps = { - option: SelectDropdownOption +type DropdownOptionProps = { + option: DropdownOption } -const SelectDropdownOption = ({ option }: SelectDropdownOptionProps) => { +const DropdownOption = ({ option }: DropdownOptionProps) => { switch (option.type) { case 'separator': - return + return case 'group': - return + return default: - return + return } } -export type SelectDropdownProps = { - options: SelectDropdownOption[] +export type DropdownProps = { + options: DropdownOption[] value?: string onChange?: (selectedOption: string) => void placeholder?: string @@ -84,7 +84,7 @@ export type SelectDropdownProps = { className?: string } -export function SelectDropdown({ +export function Dropdown({ options, value, onChange, @@ -92,7 +92,7 @@ export function SelectDropdown({ name, isDisabled, className, -}: SelectDropdownProps) { +}: DropdownProps) { return ( <> @@ -116,7 +116,7 @@ export function SelectDropdown({ {options.map((option, index) => ( - + ))} diff --git a/packages/ui/components/Form/Inputs/index.ts b/packages/ui/components/Form/Inputs/index.ts index c7df7fc7e..752a77f30 100644 --- a/packages/ui/components/Form/Inputs/index.ts +++ b/packages/ui/components/Form/Inputs/index.ts @@ -1,3 +1,3 @@ export * from './TextInput' export * from './TextArea' -export * from './SelectDropdown' +export * from './Dropdown'