-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11678a0
commit 61cc89e
Showing
5 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
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,2 @@ | ||
--- | ||
--- |
103 changes: 103 additions & 0 deletions
103
packages/components/src/__future__/Select/_docs/Select-api.mdx
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,103 @@ | ||
import { Canvas, Controls, Meta } from "@storybook/blocks" | ||
import { ResourceLinks, KAIOInstallation } from "~storybook/components" | ||
import * as SelectStories from "./Select.stories" | ||
|
||
<Meta title="Components/Select/Select (Future)/API Specification" /> | ||
|
||
# Select | ||
|
||
<ResourceLinks | ||
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Select" | ||
figma="https://www.figma.com/file/ZRfnoNUXbGZv4eVWLbF4Az/%F0%9F%96%BC%EF%B8%8F-Component-Gallery?node-id=9%3A37837&mode=dev" | ||
designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081896474/Select" | ||
|
||
/> | ||
|
||
<KAIOInstallation exportNames="Select" isFuture /> | ||
|
||
## Playground | ||
|
||
<Canvas of={SelectStories.Playground} /> | ||
<Controls of={SelectStories.Playground} /> | ||
|
||
## API | ||
|
||
### Options | ||
|
||
Provide options in `items` in the `SelectOption` format to populate the options. | ||
```ts | ||
export type SelectOption = { | ||
label: string | ||
value: string | number | ||
disabled?: boolean | ||
options?: never | ||
} | ||
|
||
``` | ||
<Canvas of={SelectStories.SingleItems} /> | ||
|
||
### Grouped options | ||
|
||
Group options by providing your `items` in the `SelectOptionGroup` format. | ||
```ts | ||
export type SelectOptionGroup<Option extends SelectOption> = { | ||
label: string | ||
options: Iterable<Option> | ||
} | ||
|
||
``` | ||
<Canvas of={SelectStories.GroupedItems} /> | ||
|
||
### Disabled options | ||
|
||
Disable options by setting the `disabled` attribute within an individual option your `items` to `true`. | ||
|
||
Alternatively, define the `disabledKeys` prop with the `value` of your options.<br/> | ||
**Note:** This will override the definitions in `items`. | ||
|
||
<Canvas of={SelectStories.DisabledItems} /> | ||
|
||
### Custom options rendering | ||
|
||
Customise the list of options using `children` (render function with arg `{ items: Array<SelectItemNode<Option>>}`). | ||
|
||
Use the default render component `<Select.ItemDefaultRender>` for any items you do not want to customise. | ||
|
||
#### Section divider | ||
|
||
To add a section divider between your options, use the `children` render function and find the item or group | ||
you want to prepend/append to and add a `<Select.SectionDivider>`. | ||
|
||
<Canvas of={SelectStories.SectionDivider} /> | ||
|
||
#### Additional option properties (generic) | ||
|
||
Extend the option type to have additional properties to use for rendering. | ||
|
||
<Canvas of={SelectStories.AdditionalProperties} /> | ||
|
||
### Customise trigger button | ||
|
||
The `trigger` prop allows you to extend the existing `<Select.TriggerButton>` with additional properties (eg. `id`). | ||
|
||
Note that the `ref` exists as part of these spread props (there is a second arg containing the `ref` which is deprecated). | ||
|
||
<Canvas of={SelectStories.CustomiseTrigger} /> | ||
|
||
### Validation | ||
|
||
Add validation messages using `status` and `validationMessage`. | ||
<Canvas of={SelectStories.Validation} /> | ||
|
||
### Full width | ||
|
||
Set `isFullWidth` to `true` to have the Select span the full width of its container. | ||
<Canvas of={SelectStories.FullWidth} /> | ||
|
||
### Portals | ||
|
||
By default, the Select's popover will attach itself to the `body` of the document using React's `createPortal`. | ||
|
||
You can change the default behaviour by providing a `portalContainerId` to attach this to different element in the DOM. This can help to resolve issues that may arise with `z-index` or having a Select in a modal. | ||
|
||
<Canvas of={SelectStories.PortalContainer} /> |
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