@czi-sds/mcp 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/component-props/Accordion.json +14 -15
- package/data/component-props/Alert.json +2 -44
- package/data/component-props/Autocomplete.json +14 -32
- package/data/component-props/Banner.json +11 -12
- package/data/component-props/Button.json +17 -82
- package/data/component-props/ButtonDropdown.json +26 -0
- package/data/component-props/ButtonIcon.json +4 -60
- package/data/component-props/ButtonToggle.json +2 -66
- package/data/component-props/Callout.json +11 -65
- package/data/component-props/CellBasic.json +28 -56
- package/data/component-props/CellComponent.json +4 -32
- package/data/component-props/CellHeader.json +13 -49
- package/data/component-props/ComplexFilter.json +24 -4
- package/data/component-props/ContentCard.json +66 -2
- package/data/component-props/Dialog.json +26 -0
- package/data/component-props/Dropdown.json +29 -67
- package/data/component-props/DropdownMenu.json +16 -56
- package/data/component-props/HeatmapChart.json +6 -87
- package/data/component-props/Icon.json +3 -8
- package/data/component-props/InputCheckbox.json +5 -53
- package/data/component-props/InputDropdown.json +11 -33
- package/data/component-props/InputRadio.json +5 -53
- package/data/component-props/InputSearch.json +6 -70
- package/data/component-props/InputSlider.json +21 -35
- package/data/component-props/InputText.json +7 -63
- package/data/component-props/InputToggle.json +5 -54
- package/data/component-props/Link.json +18 -0
- package/data/component-props/LoadingIndicator.json +1 -2
- package/data/component-props/MenuItem.json +11 -41
- package/data/component-props/MenuSelect.json +4 -67
- package/data/component-props/NavigationFooter.json +0 -8
- package/data/component-props/NavigationHeader.json +14 -65
- package/data/component-props/NavigationJumpTo.json +0 -40
- package/data/component-props/Notification.json +14 -58
- package/data/component-props/Pagination.json +8 -33
- package/data/component-props/Panel.json +4 -54
- package/data/component-props/SegmentedControl.json +0 -55
- package/data/component-props/TableRow.json +10 -38
- package/data/component-props/Tabs.json +18 -0
- package/data/component-props/Tag.json +10 -56
- package/data/component-props/TagFilter.json +0 -47
- package/data/component-props/Tooltip.json +12 -61
- package/data/component-props/TooltipCondensed.json +18 -0
- package/data/component-props/TooltipTable.json +0 -4
- package/data/zeroheight-exports/Accordion.md +167 -125
- package/data/zeroheight-exports/Banner.md +71 -48
- package/data/zeroheight-exports/Borders.md +72 -73
- package/data/zeroheight-exports/Buttons.md +375 -330
- package/data/zeroheight-exports/Callout.md +138 -116
- package/data/zeroheight-exports/Colors.md +254 -255
- package/data/zeroheight-exports/Content-Card.md +36 -37
- package/data/zeroheight-exports/Contributing-to-SDS.md +34 -35
- package/data/zeroheight-exports/Control-Inputs.md +289 -234
- package/data/zeroheight-exports/Corners.md +63 -64
- package/data/zeroheight-exports/Cover-page.md +0 -1
- package/data/zeroheight-exports/Dialog.md +237 -179
- package/data/zeroheight-exports/Downloads.md +10 -11
- package/data/zeroheight-exports/Drop-Shadows.md +40 -41
- package/data/zeroheight-exports/Dropdown-Input.md +158 -127
- package/data/zeroheight-exports/Dropdown-Menu.md +814 -718
- package/data/zeroheight-exports/Element-Status-Tracker.md +191 -192
- package/data/zeroheight-exports/Field-Inputs.md +149 -130
- package/data/zeroheight-exports/Filters.md +114 -94
- package/data/zeroheight-exports/Getting-Started.md +112 -249
- package/data/zeroheight-exports/Hero.md +43 -37
- package/data/zeroheight-exports/Icons.md +205 -206
- package/data/zeroheight-exports/Intent.md +6 -7
- package/data/zeroheight-exports/Introduction-to-Bases.md +8 -9
- package/data/zeroheight-exports/Introduction-to-Cells.md +11 -12
- package/data/zeroheight-exports/Introduction-to-DNA.md +8 -9
- package/data/zeroheight-exports/Introduction-to-Genes.md +8 -9
- package/data/zeroheight-exports/Introduction.md +52 -53
- package/data/zeroheight-exports/Link.md +50 -37
- package/data/zeroheight-exports/Lists.md +78 -63
- package/data/zeroheight-exports/Loading-Indicator.md +7 -8
- package/data/zeroheight-exports/Navigation.md +163 -142
- package/data/zeroheight-exports/Notification.md +132 -102
- package/data/zeroheight-exports/Panel.md +231 -115
- package/data/zeroheight-exports/Responsive-Design.md +35 -32
- package/data/zeroheight-exports/Search-Input.md +9 -10
- package/data/zeroheight-exports/Search.md +87 -104
- package/data/zeroheight-exports/Segmented-Control.md +68 -45
- package/data/zeroheight-exports/Spacing.md +210 -211
- package/data/zeroheight-exports/Table.md +414 -302
- package/data/zeroheight-exports/Tabs.md +126 -98
- package/data/zeroheight-exports/Tags.md +148 -118
- package/data/zeroheight-exports/Text-Link.md +32 -33
- package/data/zeroheight-exports/Theming.md +48 -29
- package/data/zeroheight-exports/Tooltips.md +253 -237
- package/data/zeroheight-exports/Typography.md +463 -464
- package/dist/stdio.js +44 -132
- package/package.json +3 -4
- package/data/component-props/Chip.json +0 -73
- package/data/component-props/List.json +0 -43
- package/data/component-props/Menu.json +0 -48
- package/data/component-props/Table.json +0 -26
- package/data/component-props-storybook/Accordion-storybook.json +0 -45
- package/data/component-props-storybook/Alert-storybook.json +0 -30
- package/data/component-props-storybook/Autocomplete-storybook.json +0 -67
- package/data/component-props-storybook/Banner-storybook.json +0 -78
- package/data/component-props-storybook/Button-storybook.json +0 -115
- package/data/component-props-storybook/ButtonDropdown-storybook.json +0 -73
- package/data/component-props-storybook/ButtonIcon-storybook.json +0 -60
- package/data/component-props-storybook/ButtonToggle-storybook.json +0 -68
- package/data/component-props-storybook/Callout-storybook.json +0 -90
- package/data/component-props-storybook/CellBasic-storybook.json +0 -138
- package/data/component-props-storybook/CellComponent-storybook.json +0 -48
- package/data/component-props-storybook/CellHeader-storybook.json +0 -71
- package/data/component-props-storybook/Chip-storybook.json +0 -26
- package/data/component-props-storybook/ComplexFilter-storybook.json +0 -60
- package/data/component-props-storybook/ContentCard-storybook.json +0 -175
- package/data/component-props-storybook/Dialog-storybook.json +0 -56
- package/data/component-props-storybook/Dropdown-storybook.json +0 -93
- package/data/component-props-storybook/DropdownMenu-storybook.json +0 -73
- package/data/component-props-storybook/HeatmapChart-storybook.json +0 -55
- package/data/component-props-storybook/Icon-storybook.json +0 -75
- package/data/component-props-storybook/InputCheckbox-storybook.json +0 -57
- package/data/component-props-storybook/InputDropdown-storybook.json +0 -80
- package/data/component-props-storybook/InputRadio-storybook.json +0 -56
- package/data/component-props-storybook/InputSearch-storybook.json +0 -55
- package/data/component-props-storybook/InputSlider-storybook.json +0 -55
- package/data/component-props-storybook/InputText-storybook.json +0 -59
- package/data/component-props-storybook/InputToggle-storybook.json +0 -42
- package/data/component-props-storybook/Link-storybook.json +0 -50
- package/data/component-props-storybook/List-storybook.json +0 -26
- package/data/component-props-storybook/LoadingIndicator-storybook.json +0 -34
- package/data/component-props-storybook/Menu-storybook.json +0 -26
- package/data/component-props-storybook/MenuItem-storybook.json +0 -74
- package/data/component-props-storybook/MenuSelect-storybook.json +0 -38
- package/data/component-props-storybook/NavigationFooter-storybook.json +0 -67
- package/data/component-props-storybook/NavigationHeader-storybook.json +0 -115
- package/data/component-props-storybook/NavigationJumpTo-storybook.json +0 -41
- package/data/component-props-storybook/Notification-storybook.json +0 -89
- package/data/component-props-storybook/Pagination-storybook.json +0 -50
- package/data/component-props-storybook/Panel-storybook.json +0 -52
- package/data/component-props-storybook/SegmentedControl-storybook.json +0 -30
- package/data/component-props-storybook/Table-storybook.json +0 -26
- package/data/component-props-storybook/TableHeader-storybook.json +0 -26
- package/data/component-props-storybook/TableRow-storybook.json +0 -62
- package/data/component-props-storybook/Tabs-storybook.json +0 -45
- package/data/component-props-storybook/Tag-storybook.json +0 -78
- package/data/component-props-storybook/TagFilter-storybook.json +0 -30
- package/data/component-props-storybook/Tooltip-storybook.json +0 -85
- package/data/component-props-storybook/TooltipCondensed-storybook.json +0 -38
- package/data/component-props-storybook/TooltipTable-storybook.json +0 -47
|
@@ -4,21 +4,21 @@ Dropdown Menus are coupled with Dropdown Inputs and in some cases Icon Buttons w
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> **Warning:** The Dropdown Menu and its affiliated components have undergone a major overhaul in their construction and how they have been coded, rendering the documentation below out of date.
|
|
8
8
|
>
|
|
9
|
-
>While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
9
|
+
> While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
10
10
|
|
|
11
11
|
## Dropdown Menu Variants
|
|
12
12
|
|
|
13
|
-
| In their basic form, Dropdown Menus are composed of a Menu Container that is filled with Menu Items offering the user options to adjust or select that are contextually relevant to the Dropdown Input they are coupled with. Menu Items can be optionally paired with additional details or with counters that indicate the number of items within that Menu Item's category.
|
|
14
|
-
|
|
|
13
|
+
| In their basic form, Dropdown Menus are composed of a Menu Container that is filled with Menu Items offering the user options to adjust or select that are contextually relevant to the Dropdown Input they are coupled with. Menu Items can be optionally paired with additional details or with counters that indicate the number of items within that Menu Item's category. Additionally, Dropdown Menus can be configured to include a Search Input, have their Menu Items separated out into different sections or groupings, or a combination of these features. | | **Jump to section:** Dropdown Menu Common Configurations Menu Item |
|
|
14
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------------ |
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
## Dropdown Menu
|
|
19
19
|
|
|
20
|
-
|
|
|
21
|
-
| --- |
|
|
20
|
+
| | In Figma | | | Meets Accessibility | | | In napari hub + .org Codebases |
|
|
21
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ------------------------------ |
|
|
22
22
|
|
|
23
23
|
Dropdown Menus can be configured to have their Menu Items all in one large list or separated out into different sections or groupings; these Menu Item formats are established by the `[array]` passed into the `options` prop. Additionally, Dropdown Menus can be configured to include a Search Input. See the Data Format section below for details about configuring the `[array]`.
|
|
24
24
|
|
|
@@ -26,11 +26,11 @@ Dropdown Menus are used in combination with Dropdown Inputs on napari hub as par
|
|
|
26
26
|
|
|
27
27
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
@@ -41,55 +41,55 @@ Use the following configuration for the `[array]` passed into the `options` prop
|
|
|
41
41
|
```js
|
|
42
42
|
data = [
|
|
43
43
|
{
|
|
44
|
-
// section with a Header and Menu Item Details
|
|
45
|
-
dataRows: [
|
|
46
|
-
{
|
|
44
|
+
// section with a Header and Menu Item Details
|
|
45
|
+
dataRows: [
|
|
46
|
+
{
|
|
47
|
+
name: "Menu Item",
|
|
48
|
+
details: "Details",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
47
51
|
name: "Menu Item",
|
|
48
|
-
details: "Details",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "Menu Item",
|
|
52
|
-
details: "Details",
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: "Menu Item",
|
|
56
|
-
details: "Details",
|
|
57
|
-
},
|
|
52
|
+
details: "Details",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "Menu Item",
|
|
56
|
+
details: "Details",
|
|
57
|
+
},
|
|
58
58
|
],
|
|
59
59
|
label: "Section One",
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
// section with Menu Item Counts
|
|
63
|
-
dataRows: [
|
|
64
|
-
{
|
|
65
|
-
name: "Menu Item",
|
|
63
|
+
dataRows: [
|
|
64
|
+
{
|
|
65
|
+
name: "Menu Item",
|
|
66
66
|
count: 20,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "Menu Item",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "Menu Item",
|
|
70
70
|
count: 40,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "Menu Item",
|
|
74
|
-
count: 60,
|
|
75
|
-
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "Menu Item",
|
|
74
|
+
count: 60,
|
|
75
|
+
},
|
|
76
76
|
],
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
// section with disabled Menu Items
|
|
80
|
-
dataRows: [
|
|
81
|
-
{
|
|
82
|
-
name: "Menu Item",
|
|
80
|
+
dataRows: [
|
|
81
|
+
{
|
|
82
|
+
name: "Menu Item",
|
|
83
|
+
disabled: true,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "Menu Item",
|
|
83
87
|
disabled: true,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "Menu Item",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "Menu Item",
|
|
87
91
|
disabled: true,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: "Menu Item",
|
|
91
|
-
disabled: true,
|
|
92
|
-
},
|
|
92
|
+
},
|
|
93
93
|
],
|
|
94
94
|
},
|
|
95
95
|
];
|
|
@@ -110,51 +110,51 @@ Dropdown Menus can be thought of as being comprised of different combinations of
|
|
|
110
110
|
Below are a number of common Dropdown Menu configurations, but by no means is this an exhaustive list:
|
|
111
111
|
|
|
112
112
|
| **Search + Count** | **Search + Sections** | **Search + Details** |
|
|
113
|
-
|
|
|
113
|
+
| ------------------ | --------------------- | -------------------- |
|
|
114
114
|
|
|
115
115
|
| **Sections + Details** | **Search + Sections + Details** | **Search + Sections + Count** |
|
|
116
|
-
|
|
|
116
|
+
| ---------------------- | ------------------------------- | ----------------------------- |
|
|
117
117
|
|
|
118
118
|
---
|
|
119
119
|
|
|
120
120
|
## Menu Item
|
|
121
121
|
|
|
122
|
-
|
|
|
123
|
-
| --- |
|
|
122
|
+
| | In Figma | | | Meets Accessibility | | | In napari hub + .org Codebases |
|
|
123
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ------------------------------ |
|
|
124
124
|
|
|
125
125
|
Menu Items can be optionally paired with additional clarifying details, with counters that indicate the number of items within that Menu Item's category, or be disabled entirely. These details are established within the `[array]` passed into the `options` prop on the Dropdown Menu component.
|
|
126
126
|
|
|
127
127
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
128
128
|
|
|
129
129
|
| **Default** | **Hover** | **Selected** | **Selected + Hover** | **Disabled** | **Selected + Disabled** |
|
|
130
|
-
|
|
|
130
|
+
| ----------- | --------- | ------------ | -------------------- | ------------ | ----------------------- |
|
|
131
131
|
|
|
132
132
|
| **Default + Count** | **Hover** | **Selected** | **Selected + Hover** | **Disabled** | **Selected + Disabled** |
|
|
133
|
-
|
|
|
133
|
+
| ------------------- | --------- | ------------ | -------------------- | ------------ | ----------------------- |
|
|
134
134
|
|
|
135
|
-
| **Default + Details** | **Hover** | **Selected** | **Selected + Hover** | **Disabled** |
|
|
136
|
-
|
|
|
135
|
+
| **Default + Details** | **Hover** | **Selected** | **Selected + Hover** | **Disabled** | **Selected + Disabled** |
|
|
136
|
+
| --------------------- | --------- | ------------ | -------------------- | ------------ | ------------------------ |
|
|
137
137
|
|
|
138
138
|
## Code
|
|
139
139
|
|
|
140
140
|
## Dropdown Menu Component
|
|
141
141
|
|
|
142
|
-
| Below you will find interactive Storybook iframes for the Dropdown Menu.
|
|
143
|
-
|
|
|
142
|
+
| Below you will find interactive Storybook iframes for the Dropdown Menu. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** DropdownMenu |
|
|
143
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ----------------------------------- |
|
|
144
144
|
|
|
145
145
|
---
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
> **Warning:** The Dropdown Menu and its affiliated components have undergone a major overhaul in their construction and how they have been coded, rendering the documentation below out of date.
|
|
148
148
|
>
|
|
149
|
-
>While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
149
|
+
> While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
150
150
|
|
|
151
|
-
>This component appears as it is in the default SDS codebase. Once imported into the napari hub or napari.org codebases, use a theme file to enable the napari visual appearance customization.
|
|
151
|
+
> This component appears as it is in the default SDS codebase. Once imported into the napari hub or napari.org codebases, use a theme file to enable the napari visual appearance customization.
|
|
152
152
|
|
|
153
153
|
### DropdownMenu
|
|
154
154
|
|
|
155
155
|
Storybook
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
|
|
159
159
|
---
|
|
160
160
|
|
|
@@ -162,21 +162,21 @@ Dropdown Menus are coupled with Dropdown Inputs, Dropdown Buttons, and in some c
|
|
|
162
162
|
|
|
163
163
|
## Overview
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
> **NOTE:** The Dropdown Menu and its affiliated components have undergone a major overhaul in their construction and how they have been coded, rendering the documentation below out of date.
|
|
166
166
|
>
|
|
167
|
-
>While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
167
|
+
> While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
168
168
|
|
|
169
169
|
## Dropdown Menu Variants
|
|
170
170
|
|
|
171
|
-
| In their basic form, Dropdown Menus are composed of a Menu Container that is filled with Menu Items offering the user options to adjust or select that are contextually relevant to the Button or Dropdown Input they are coupled with. Menu Items can be optionally paired with additional details or with counters that indicate the number of items within that Menu Item's category. Dropdown Menus can also be multi-select, allowing the user to choose multiple options from the group of Menu Items.
|
|
172
|
-
|
|
|
171
|
+
| In their basic form, Dropdown Menus are composed of a Menu Container that is filled with Menu Items offering the user options to adjust or select that are contextually relevant to the Button or Dropdown Input they are coupled with. Menu Items can be optionally paired with additional details or with counters that indicate the number of items within that Menu Item's category. Dropdown Menus can also be multi-select, allowing the user to choose multiple options from the group of Menu Items. Additionally, Dropdown Menus can be configured to include a Search Input, have their Menu Items separated out into different sections or groupings, have a built-in title, or any combination of these features. | | **Jump to section:** Dropdown Menu Common Configurations Menu Item |
|
|
172
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------------ |
|
|
173
173
|
|
|
174
174
|
---
|
|
175
175
|
|
|
176
176
|
## Dropdown Menu
|
|
177
177
|
|
|
178
|
-
|
|
|
179
|
-
| --- |
|
|
178
|
+
| | In Figma | | | Meets Accessibility | | | In CZ GEN EPI Codebase |
|
|
179
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ---------------------- |
|
|
180
180
|
|
|
181
181
|
### Single-select Dropdown Menu
|
|
182
182
|
|
|
@@ -184,7 +184,7 @@ Use the Single-select Dropdown Menu when users are only able to select one item
|
|
|
184
184
|
|
|
185
185
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
|
|
188
188
|
|
|
189
189
|
---
|
|
190
190
|
|
|
@@ -198,7 +198,7 @@ Use the Multi-select Dropdown Menu when users are able to select one or more ite
|
|
|
198
198
|
|
|
199
199
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
|
|
202
202
|
|
|
203
203
|
---
|
|
204
204
|
|
|
@@ -213,38 +213,38 @@ Use the following configuration for the `[array]` passed into the `options` prop
|
|
|
213
213
|
```js
|
|
214
214
|
data = [
|
|
215
215
|
{
|
|
216
|
-
// section with a Header and Menu Item Details
|
|
217
|
-
dataRows: [
|
|
218
|
-
{
|
|
216
|
+
// section with a Header and Menu Item Details
|
|
217
|
+
dataRows: [
|
|
218
|
+
{
|
|
219
|
+
name: "Menu Item",
|
|
220
|
+
details: "Details",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
219
223
|
name: "Menu Item",
|
|
220
|
-
details: "Details",
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: "Menu Item",
|
|
224
|
-
details: "Details",
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
name: "Menu Item",
|
|
228
|
-
details: "Details",
|
|
229
|
-
},
|
|
224
|
+
details: "Details",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "Menu Item",
|
|
228
|
+
details: "Details",
|
|
229
|
+
},
|
|
230
230
|
],
|
|
231
231
|
label: "Section One",
|
|
232
232
|
},
|
|
233
233
|
{
|
|
234
234
|
// section with Menu Item Counts
|
|
235
|
-
dataRows: [
|
|
236
|
-
{
|
|
237
|
-
name: "Menu Item",
|
|
235
|
+
dataRows: [
|
|
236
|
+
{
|
|
237
|
+
name: "Menu Item",
|
|
238
238
|
count: 20,
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: "Menu Item",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "Menu Item",
|
|
242
242
|
count: 40,
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
name: "Menu Item",
|
|
246
|
-
count: 60,
|
|
247
|
-
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: "Menu Item",
|
|
246
|
+
count: 60,
|
|
247
|
+
},
|
|
248
248
|
],
|
|
249
249
|
},
|
|
250
250
|
];
|
|
@@ -265,17 +265,17 @@ Dropdown Menus can be thought of as being comprised of different combinations of
|
|
|
265
265
|
Below are a number of common Dropdown Menu configurations, but by no means is this an exhaustive list:
|
|
266
266
|
|
|
267
267
|
| **Title + Count** | **Search + Sections + Details** | **Title + Details** |
|
|
268
|
-
|
|
|
268
|
+
| ----------------- | ------------------------------- | ------------------- |
|
|
269
269
|
|
|
270
270
|
| **Search + Details** | **Title + Search + Count** | **Title + Sections + Details** |
|
|
271
|
-
|
|
|
271
|
+
| -------------------- | -------------------------- | ------------------------------ |
|
|
272
272
|
|
|
273
273
|
---
|
|
274
274
|
|
|
275
275
|
## Menu Item
|
|
276
276
|
|
|
277
|
-
|
|
|
278
|
-
| --- |
|
|
277
|
+
| | In Figma | | | Meets Accessibility | | | In CZ GEN EPI Codebase |
|
|
278
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ---------------------- |
|
|
279
279
|
|
|
280
280
|
### Single-select Menu Item
|
|
281
281
|
|
|
@@ -284,15 +284,15 @@ Menu Items can be optionally paired with additional clarifying details, with cou
|
|
|
284
284
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
285
285
|
|
|
286
286
|
| **Default** | **Hover** | **Selected** | **Disabled** |
|
|
287
|
-
|
|
|
287
|
+
| ----------- | --------- | ------------ | ------------ |
|
|
288
288
|
|
|
289
289
|
| **Default + Count** | **Hover** | **Selected** | **Disabled** |
|
|
290
|
-
|
|
|
290
|
+
| ------------------- | --------- | ------------ | ------------ |
|
|
291
291
|
|
|
292
292
|
| **Default + Details** | **Hover** | **Selected** | **Disabled** |
|
|
293
|
-
|
|
|
293
|
+
| --------------------- | --------- | ------------ | ------------ |
|
|
294
|
+
|
|
294
295
|
|
|
295
|
-
|
|
296
296
|
|
|
297
297
|
### Multi-select Menu Item
|
|
298
298
|
|
|
@@ -301,28 +301,28 @@ Menu Items can be optionally paired with additional clarifying details, with cou
|
|
|
301
301
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
302
302
|
|
|
303
303
|
| **Default** | **Hover** | **Selected** | **Disabled** |
|
|
304
|
-
|
|
|
304
|
+
| ----------- | --------- | ------------ | ------------ |
|
|
305
305
|
|
|
306
306
|
| **Default + Count** | **Hover** | **Selected** | **Disabled** |
|
|
307
|
-
|
|
|
307
|
+
| ------------------- | --------- | ------------ | ------------ |
|
|
308
308
|
|
|
309
309
|
| **Default + Details** | **Hover** | **Selected** | **Disabled** |
|
|
310
|
-
|
|
|
310
|
+
| --------------------- | --------- | ------------ | ------------ |
|
|
311
311
|
|
|
312
312
|
## Code
|
|
313
313
|
|
|
314
314
|
## Dropdown Menu Component
|
|
315
315
|
|
|
316
|
-
| Below you will find interactive Storybook iframes for the Dropdown Menu.
|
|
317
|
-
|
|
|
316
|
+
| Below you will find interactive Storybook iframes for the Dropdown Menu. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** DropdownMenu |
|
|
317
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ----------------------------------- |
|
|
318
318
|
|
|
319
319
|
---
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
> **NOTE:** The Dropdown Menu and its affiliated components have undergone a major overhaul in their construction and how they have been coded, rendering the documentation below out of date.
|
|
322
322
|
>
|
|
323
|
-
>While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
323
|
+
> While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
324
324
|
|
|
325
|
-
>This component appears as it is in the default SDS codebase. Once imported into the CZ GEN EPI codebase, use a theme file to enable the CZ GEN EPI visual appearance customization.
|
|
325
|
+
> This component appears as it is in the default SDS codebase. Once imported into the CZ GEN EPI codebase, use a theme file to enable the CZ GEN EPI visual appearance customization.
|
|
326
326
|
|
|
327
327
|
### DropdownMenu
|
|
328
328
|
|
|
@@ -334,21 +334,21 @@ Dropdown Menus are coupled with Dropdown Inputs, Dropdown Buttons, and in some c
|
|
|
334
334
|
|
|
335
335
|
## Overview
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
> **Warning:** The Dropdown Menu and its affiliated components have undergone a major overhaul in their construction and how they have been coded, rendering the documentation below out of date.
|
|
338
338
|
>
|
|
339
|
-
>While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
339
|
+
> While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
340
340
|
|
|
341
341
|
## Dropdown Menu Variants
|
|
342
342
|
|
|
343
|
-
| In their basic form, Dropdown Menus are composed of a Menu Container that is filled with Menu Items offering the user options to adjust or select that are contextually relevant to the Button or Dropdown Input they are coupled with. Menu Items can be optionally paired with additional details or with counters that indicate the number of items within that Menu Item's category. Dropdown Menus can also be multi-select, allowing the user to choose multiple options from the group of Menu Items.
|
|
344
|
-
|
|
|
343
|
+
| In their basic form, Dropdown Menus are composed of a Menu Container that is filled with Menu Items offering the user options to adjust or select that are contextually relevant to the Button or Dropdown Input they are coupled with. Menu Items can be optionally paired with additional details or with counters that indicate the number of items within that Menu Item's category. Dropdown Menus can also be multi-select, allowing the user to choose multiple options from the group of Menu Items. Additionally, Dropdown Menus can be configured to include a Search Input, have their Menu Items separated out into different sections or groupings, have a built-in title, or any combination of these features. | | **Jump to section:** Dropdown Menu Common Configurations Menu Item |
|
|
344
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------------ |
|
|
345
345
|
|
|
346
346
|
---
|
|
347
347
|
|
|
348
348
|
## Dropdown Menu
|
|
349
349
|
|
|
350
|
-
|
|
|
351
|
-
| --- |
|
|
350
|
+
| | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
|
|
351
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ----------------- |
|
|
352
352
|
|
|
353
353
|
### Single-select Dropdown Menu
|
|
354
354
|
|
|
@@ -356,7 +356,7 @@ Use the Single-select Dropdown Menu when users are only able to select one item
|
|
|
356
356
|
|
|
357
357
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
|
|
361
361
|
---
|
|
362
362
|
|
|
@@ -364,7 +364,7 @@ Click on each state below to enter inspect view and get details on its code attr
|
|
|
364
364
|
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
|
|
368
368
|
|
|
369
369
|
### Multi-select Dropdown Menu
|
|
370
370
|
|
|
@@ -372,7 +372,7 @@ Use the Multi-select Dropdown Menu when users are able to select one or more ite
|
|
|
372
372
|
|
|
373
373
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
374
374
|
|
|
375
|
-
|
|
375
|
+
|
|
376
376
|
|
|
377
377
|
---
|
|
378
378
|
|
|
@@ -391,38 +391,38 @@ Use the following configuration for the `[array]` passed into the `options` prop
|
|
|
391
391
|
```js
|
|
392
392
|
data = [
|
|
393
393
|
{
|
|
394
|
-
// section with a Header and Menu Item Details
|
|
395
|
-
dataRows: [
|
|
396
|
-
{
|
|
394
|
+
// section with a Header and Menu Item Details
|
|
395
|
+
dataRows: [
|
|
396
|
+
{
|
|
397
|
+
name: "Menu Item",
|
|
398
|
+
details: "Details",
|
|
399
|
+
},
|
|
400
|
+
{
|
|
397
401
|
name: "Menu Item",
|
|
398
|
-
details: "Details",
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: "Menu Item",
|
|
402
|
-
details: "Details",
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
name: "Menu Item",
|
|
406
|
-
details: "Details",
|
|
407
|
-
},
|
|
402
|
+
details: "Details",
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "Menu Item",
|
|
406
|
+
details: "Details",
|
|
407
|
+
},
|
|
408
408
|
],
|
|
409
409
|
label: "Section One",
|
|
410
410
|
},
|
|
411
411
|
{
|
|
412
412
|
// section with Menu Item Counts
|
|
413
|
-
dataRows: [
|
|
414
|
-
{
|
|
415
|
-
name: "Menu Item",
|
|
413
|
+
dataRows: [
|
|
414
|
+
{
|
|
415
|
+
name: "Menu Item",
|
|
416
416
|
count: 20,
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
name: "Menu Item",
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: "Menu Item",
|
|
420
420
|
count: 40,
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
name: "Menu Item",
|
|
424
|
-
count: 60,
|
|
425
|
-
},
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: "Menu Item",
|
|
424
|
+
count: 60,
|
|
425
|
+
},
|
|
426
426
|
],
|
|
427
427
|
},
|
|
428
428
|
];
|
|
@@ -443,17 +443,17 @@ Dropdown Menus can be thought of as being comprised of different combinations of
|
|
|
443
443
|
Below are a number of common Dropdown Menu configurations, but by no means is this an exhaustive list:
|
|
444
444
|
|
|
445
445
|
| **Title + Count** | **Search + Sections + Details** | **Title + Details** |
|
|
446
|
-
|
|
|
446
|
+
| ----------------- | ------------------------------- | ------------------- |
|
|
447
447
|
|
|
448
448
|
| **Search + Details** | **Title + Search + Count** | **Title + Sections + Details** |
|
|
449
|
-
|
|
|
449
|
+
| -------------------- | -------------------------- | ------------------------------ |
|
|
450
450
|
|
|
451
451
|
---
|
|
452
452
|
|
|
453
453
|
## Menu Item
|
|
454
454
|
|
|
455
|
-
|
|
|
456
|
-
| --- |
|
|
455
|
+
| | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
|
|
456
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ----------------- |
|
|
457
457
|
|
|
458
458
|
### Single-select Menu Item
|
|
459
459
|
|
|
@@ -462,15 +462,15 @@ Menu Items can be optionally paired with additional clarifying details, with cou
|
|
|
462
462
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
463
463
|
|
|
464
464
|
| **Default** | **Hover** | **Selected** | **Disabled** |
|
|
465
|
-
|
|
|
465
|
+
| ----------- | --------- | ------------ | ------------ |
|
|
466
466
|
|
|
467
467
|
| **Default + Count** | **Hover** | **Selected** | **Disabled** |
|
|
468
|
-
|
|
|
468
|
+
| ------------------- | --------- | ------------ | ------------ |
|
|
469
469
|
|
|
470
470
|
| **Default + Details** | **Hover** | **Selected** | **Disabled** |
|
|
471
|
-
|
|
|
471
|
+
| --------------------- | --------- | ------------ | ------------ |
|
|
472
|
+
|
|
472
473
|
|
|
473
|
-
|
|
474
474
|
|
|
475
475
|
### Multi-select Menu Item
|
|
476
476
|
|
|
@@ -479,32 +479,32 @@ Menu Items can be optionally paired with additional clarifying details, with cou
|
|
|
479
479
|
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
480
480
|
|
|
481
481
|
| **Default** | **Hover** | **Selected** | **Disabled** |
|
|
482
|
-
|
|
|
482
|
+
| ----------- | --------- | ------------ | ------------ |
|
|
483
483
|
|
|
484
484
|
| **Default + Count** | **Hover** | **Selected** | **Disabled** |
|
|
485
|
-
|
|
|
485
|
+
| ------------------- | --------- | ------------ | ------------ |
|
|
486
486
|
|
|
487
487
|
| **Default + Details** | **Hover** | **Selected** | **Disabled** |
|
|
488
|
-
|
|
|
488
|
+
| --------------------- | --------- | ------------ | ------------ |
|
|
489
489
|
|
|
490
490
|
## Code
|
|
491
491
|
|
|
492
492
|
## Dropdown Menu Component
|
|
493
493
|
|
|
494
|
-
| Below you will find interactive Storybook iframes for the Dropdown Menu.
|
|
495
|
-
|
|
|
494
|
+
| Below you will find interactive Storybook iframes for the Dropdown Menu. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** DropdownMenu |
|
|
495
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ----------------------------------- |
|
|
496
496
|
|
|
497
497
|
---
|
|
498
498
|
|
|
499
|
-
|
|
499
|
+
> **NOTE:** The Dropdown Menu and its affiliated components have undergone a major overhaul in their construction and how they have been coded, rendering the documentation below out of date.
|
|
500
500
|
>
|
|
501
|
-
>While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
501
|
+
> While the SDS works on updating the documentation to reflect these changes, see `src/core/Dropdown/index.stories.tsx` within the `sci-components` codebase for example usage of the new Dropdown Menu structure.
|
|
502
502
|
|
|
503
503
|
### DropdownMenu
|
|
504
504
|
|
|
505
505
|
Storybook
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
|
|
508
508
|
|
|
509
509
|
---
|
|
510
510
|
|
|
@@ -514,8 +514,8 @@ Dropdown Menus are coupled with Dropdown Inputs, Dropdown Buttons, and in some c
|
|
|
514
514
|
|
|
515
515
|
## Dropdown Menu Components
|
|
516
516
|
|
|
517
|
-
| Dropdown Menus offer the user options to adjust or select. The Menu Items found within the Dropdown Menu have multiple format options.
|
|
518
|
-
|
|
|
517
|
+
| Dropdown Menus offer the user options to adjust or select. The Menu Items found within the Dropdown Menu have multiple format options. Dropdown Menus can be configured to include a Search Input, have their Menu Items separated out into different sections or groupings, have a built-in title, or any combination of these features. Dropdown Menus require a trigger element, such as a Dropdown Input, Dropdown Button, or Icon Button, to open the menu. Dropdown is a component created as a combination of Dropdown Menu and a trigger element to help make Dropdown Menu easier for developers to implement. | | **Jump to component:** Dropdown Dropdown Menu Menu Item |
|
|
518
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------- |
|
|
519
519
|
|
|
520
520
|
### Visual Preview
|
|
521
521
|
|
|
@@ -523,8 +523,8 @@ Dropdown Menus are coupled with Dropdown Inputs, Dropdown Buttons, and in some c
|
|
|
523
523
|
|
|
524
524
|
## Dropdown
|
|
525
525
|
|
|
526
|
-
|
|
|
527
|
-
| --- |
|
|
526
|
+
| | Meets Accessibility | | | In Code |
|
|
527
|
+
| --- | ------------------- | --- | --- | ------- |
|
|
528
528
|
|
|
529
529
|
### Overview
|
|
530
530
|
|
|
@@ -544,8 +544,8 @@ Default
|
|
|
544
544
|
|
|
545
545
|
## Dropdown Menu
|
|
546
546
|
|
|
547
|
-
|
|
|
548
|
-
| --- |
|
|
547
|
+
| | In Figma | | | Meets Accessibility | | | In Code |
|
|
548
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ------- |
|
|
549
549
|
|
|
550
550
|
### Dropdown Menu Types
|
|
551
551
|
|
|
@@ -564,29 +564,29 @@ Default
|
|
|
564
564
|
Use Single-select when users are only able to select one item from the menu. They can be configured to have their Menu Items separated out into different sections or groupings, have a built-in title at the top of the menu, include a Search Input allowing users to easily find specific Menu Items, or a combination of all three.
|
|
565
565
|
|
|
566
566
|
| Default | Default + Title | Default + Search | Default + Sections |
|
|
567
|
-
|
|
|
567
|
+
| ------- | --------------- | ---------------- | ------------------ |
|
|
568
568
|
|
|
569
569
|
---
|
|
570
570
|
|
|
571
|
-
### Dropdown Menu – Multi-select
|
|
571
|
+
### Dropdown Menu – Multi-select
|
|
572
572
|
|
|
573
573
|
Use Multi-select when users are able to select one or more items from the menu. They can be configured to have their Menu Items separated out into different sections or groupings, have a built-in title at the top of the menu, include a Search Input allowing users to easily find specific Menu Items, include confirmation and cancel Buttons at the bottom of the menu, or a combination of all four.
|
|
574
574
|
|
|
575
575
|
| Default | Default + Title | Default + Search | Default + Sections | Default + Buttons |
|
|
576
|
-
|
|
|
576
|
+
| ------- | --------------- | ---------------- | ------------------ | ----------------- |
|
|
577
577
|
|
|
578
578
|
---
|
|
579
579
|
|
|
580
580
|
### Dropdown Menu – Multi-column
|
|
581
581
|
|
|
582
|
-
Use Multi-column when there is a need to separate Menu Items across multiple columns. Columns can be dependent or independent of each other. With dependent columns, Menu Item selections made in one column will affect the Menu Items in the others, such as reducing the number of Menu Items visible in neighboring columns; use Indeterminate Menu Items when some, but not all sub-options have been made in a subsequent column. With independent columns, Menu Item selections made in one column will have no effect on the Menu Items in other columns.
|
|
582
|
+
Use Multi-column when there is a need to separate Menu Items across multiple columns. Columns can be dependent or independent of each other. With dependent columns, Menu Item selections made in one column will affect the Menu Items in the others, such as reducing the number of Menu Items visible in neighboring columns; use Indeterminate Menu Items when some, but not all sub-options have been made in a subsequent column. With independent columns, Menu Item selections made in one column will have no effect on the Menu Items in other columns.
|
|
583
583
|
|
|
584
584
|
The same configurations are available in the Multi-column variant as the Single-column including a built-in title at the top of the menu, a Search Input, section names at the top of each column, confirmation and cancel Buttons at the bottom of the menu, or a combination of all four. There can only be one section per column. Additionally, a Chevron icon can be placed between columns to help communicate the relationship between them.
|
|
585
585
|
|
|
586
586
|
Multi-column Dropdown Menus can be Single- or Multi-select.
|
|
587
587
|
|
|
588
588
|
| Default | Default + Title | Default + Search | Default + Buttons |
|
|
589
|
-
|
|
|
589
|
+
| ------- | --------------- | ---------------- | ----------------- |
|
|
590
590
|
|
|
591
591
|
---
|
|
592
592
|
|
|
@@ -598,8 +598,8 @@ These rules establish how much margin should exist between and around elements.
|
|
|
598
598
|
|
|
599
599
|
## Menu Item
|
|
600
600
|
|
|
601
|
-
|
|
|
602
|
-
| --- |
|
|
601
|
+
| | In Figma | | | Meets Accessibility | | | In Code |
|
|
602
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ------- |
|
|
603
603
|
|
|
604
604
|
### Menu Item Types
|
|
605
605
|
|
|
@@ -618,7 +618,7 @@ Default
|
|
|
618
618
|
Single-select Menu Items are used in Dropdown Menus where only one item can be selected at a time. They can optionally be paired with additional clarifying details or counters that indicate the number of items within that Menu Item's category.
|
|
619
619
|
|
|
620
620
|
| Default | Hover | Selected | Disabled |
|
|
621
|
-
|
|
|
621
|
+
| ------- | ----- | -------- | -------- |
|
|
622
622
|
|
|
623
623
|
---
|
|
624
624
|
|
|
@@ -629,14 +629,14 @@ Single-select Menu Items are used in Dropdown Menus where only one item can be s
|
|
|
629
629
|
Multi-select Menu Items are used in Dropdown Menus where multiple items can be selected at a time. The determinate variant should be used in Single-column Dropdown Menus or in Multi-column Dropdown Menus to communicate that all possible sub-options have been selected. Optionally They can optionally be paired with additional clarifying details or with counters that indicate the number of items within that Menu Item's category.
|
|
630
630
|
|
|
631
631
|
| Default | Hover | Selected | Disabled |
|
|
632
|
-
|
|
|
632
|
+
| ------- | ----- | -------- | -------- |
|
|
633
633
|
|
|
634
634
|
#### Indeterminate
|
|
635
635
|
|
|
636
636
|
Indeterminate Multi-select Menu Items are used **only** in Multi-column Dropdown Menus when there is a need to show when some, but not all sub-options have been selected. They can optionally be paired with additional clarifying details or with counters that indicate the number of items within that Menu Item's category.
|
|
637
637
|
|
|
638
638
|
| Default | Hover | Selected | Disabled |
|
|
639
|
-
|
|
|
639
|
+
| ------- | ----- | -------- | -------- |
|
|
640
640
|
|
|
641
641
|
---
|
|
642
642
|
|
|
@@ -645,18 +645,18 @@ Indeterminate Multi-select Menu Items are used **only** in Multi-column Dropdown
|
|
|
645
645
|
All Menu Item variants can be optionally displayed with an icon.
|
|
646
646
|
|
|
647
647
|
| Default + Icon | Default + Count + Icon | Default + Details + Icon |
|
|
648
|
-
|
|
|
648
|
+
| -------------- | ---------------------- | ------------------------ |
|
|
649
649
|
|
|
650
650
|
## Code
|
|
651
651
|
|
|
652
652
|
## Dropdown Menu Components
|
|
653
653
|
|
|
654
|
-
| `DropdownMenu` offers the user options to adjust or select. The `MenuItems` found within `DropdownMenu` have multiple format options.
|
|
655
|
-
|
|
|
654
|
+
| `DropdownMenu` offers the user options to adjust or select. The `MenuItems` found within `DropdownMenu` have multiple format options. `DropdownMenu` can be configured to include `InputSearch`, have their `MenuItems` separated out into different sections or groupings, have a built-in title, or any combination of these features. `DropdownMenu` requires a trigger element, such as `InputDropdown`, `ButtonDropdown`, or `ButtonIcon`, to open the menu. `Dropdown` is a component created as a combination of `DropdownMenu` and a trigger element to help make `DropdownMenu` easier for developers to implement. | | **Jump to component:** DropdownMenu MenuItem Dropdown |
|
|
655
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ----------------------------------------------------- |
|
|
656
656
|
|
|
657
657
|
### Visual Preview
|
|
658
658
|
|
|
659
|
-
|
|
659
|
+
> **Note:** The code examples below must install dependencies before displaying and may take extra time to load
|
|
660
660
|
|
|
661
661
|
---
|
|
662
662
|
|
|
@@ -668,36 +668,36 @@ The component's source code in the SDS codebase can be found here.
|
|
|
668
668
|
|
|
669
669
|
### SDS vs MUI
|
|
670
670
|
|
|
671
|
-
SDS's `Dropdown` component is a combination of two other SDS components: `DropdownMenu` and `InputDropdown`,
|
|
671
|
+
SDS's `Dropdown` component is a combination of two other SDS components: `DropdownMenu` and `InputDropdown`, since these would often be used together to create a complete dropdown element in the UI. `DropdownMenu` is built off of MUI's `Autocomplete` component, but `InputDropdown` is built from scratch.
|
|
672
672
|
|
|
673
673
|
These are a few of the most relevant ways in which SDS's `DropdownMenu` (which is used within `Dropdown`) integrates with`Autocomplete` and other MUI components:
|
|
674
674
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
675
|
+
- SDS `Dropdown` uses MUI `Autocomplete` under the hood, so all props passed to `DropdownMenu` are ultimately passed to the Autocomplete component as well. This means MUI's `Autocomplete` props can be used on SDS's `DropdownMenu` if needed.
|
|
676
|
+
- SDS `Dropdown` uses MUI `Popper`. A custom `Popper` component can be passed via `props.PopperComponent` and/or `props.PopperBaseProps` to control the popper component.
|
|
677
|
+
- Similarly, SDS `Dropdown` uses MUI `Paper`. A custom `Paper` component can be passed via `props.PaperComponent` to enable custom styling.
|
|
678
678
|
|
|
679
679
|
### Props
|
|
680
680
|
|
|
681
681
|
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
682
682
|
|
|
683
|
-
| Name
|
|
684
|
-
|
|
|
685
|
-
| `buttonPosition`
|
|
686
|
-
| `buttons`
|
|
687
|
-
| `closeOnBlur`
|
|
688
|
-
| `disabled`
|
|
689
|
-
| `isTriggerChangeOnOptionClick` | `bool`
|
|
690
|
-
| `label`
|
|
691
|
-
| `multiple`
|
|
692
|
-
| `onChange`
|
|
693
|
-
| `onClose`
|
|
694
|
-
| `search`
|
|
695
|
-
| `dropdownMenuProps`
|
|
696
|
-
| `options`
|
|
697
|
-
| `InputDropdownProps`
|
|
698
|
-
| `value`
|
|
699
|
-
| `PopperComponent`
|
|
700
|
-
| `InputDropdownComponent`
|
|
683
|
+
| Name | Type | Default | Description |
|
|
684
|
+
| ------------------------------ | ---------------------------------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
685
|
+
| `buttonPosition` | `"left"` ` | "right"` | `left` | Specifies the position of the `Apply`/`Cancel` buttons at the Dropdown footer. |
|
|
686
|
+
| `buttons` | `bool` | `false` | When set to `true`, a set of `Apply`/`Cancel` buttons will be displayed at the Dropdown footer. |
|
|
687
|
+
| `closeOnBlur` | `bool` | `true` | When set to `true`, the Dropdown will automatically close when a click occurs outside of it. |
|
|
688
|
+
| `disabled` | `bool` | `false` | When `true`, the Dropdown is disabled and user interaction is not allowed. |
|
|
689
|
+
| `isTriggerChangeOnOptionClick` | `bool` | `false` | When set to `true`, changes in Dropdown selections are applied in real-time to the react state. |
|
|
690
|
+
| `label` | `string` | `-` | The label of the Dropdown. |
|
|
691
|
+
| `multiple` | `bool` | `true` | Determines whether the Dropdown allows for multiple item selection. |
|
|
692
|
+
| `onChange` | `(options: Value<DefaultDropdownMenuOption, Multiple>) => void;` | `-` | Callback fired when the value changes. |
|
|
693
|
+
| `onClose` | `func` | `-` | Callback fired when the Dropdown requests to be closed. |
|
|
694
|
+
| `search` | `bool` | `true` | When set to `true`, a search input is displayed at the top of the Dropdown for filtering options. |
|
|
695
|
+
| `dropdownMenuProps` | `Partial<DropdownMenuProps>` | `-` | These props are directly passed to the underlying DropdownMenu component, customizing its behavior. |
|
|
696
|
+
| `options` | `Array<DefaultDropdownMenuOption>` | `-` | An array of options to be displayed as MenuItems within the Dropdown. |
|
|
697
|
+
| `InputDropdownProps` | `Partial<InputDropdownPropsType>` | `-` | These props are directly passed to the underlying InputDropdown component, customizing its behavior. |
|
|
698
|
+
| `value` | `string | Array<string>` | `-` | The current value of the Dropdown, representing the selected item(s) based on the multi-select status. |
|
|
699
|
+
| `PopperComponent` | `element` | `Paper` | The component used to render the wrapper of the inner DropdownMenu. |
|
|
700
|
+
| `InputDropdownComponent` | `element` | `InputDropdown` | The component used to render the Dropdown trigger button. |
|
|
701
701
|
|
|
702
702
|
### Code Examples
|
|
703
703
|
|
|
@@ -730,13 +730,11 @@ h1 {
|
|
|
730
730
|
|
|
731
731
|
```json
|
|
732
732
|
{
|
|
733
|
-
"include": [
|
|
734
|
-
"./**/*"
|
|
735
|
-
],
|
|
733
|
+
"include": ["./**/*"],
|
|
736
734
|
"compilerOptions": {
|
|
737
735
|
"strict": true,
|
|
738
736
|
"esModuleInterop": true,
|
|
739
|
-
"lib": [
|
|
737
|
+
"lib": ["dom", "es2015"],
|
|
740
738
|
"jsx": "react-jsx"
|
|
741
739
|
}
|
|
742
740
|
}
|
|
@@ -767,11 +765,7 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
767
765
|
function App() {
|
|
768
766
|
return (
|
|
769
767
|
<div className="app">
|
|
770
|
-
<Dropdown
|
|
771
|
-
label="Click Target"
|
|
772
|
-
onChange={() => {}}
|
|
773
|
-
options={MENU_ITEMS}
|
|
774
|
-
/>
|
|
768
|
+
<Dropdown label="Click Target" onChange={() => {}} options={MENU_ITEMS} />
|
|
775
769
|
</div>
|
|
776
770
|
);
|
|
777
771
|
}
|
|
@@ -816,13 +810,12 @@ root.render(
|
|
|
816
810
|
<RootApp />
|
|
817
811
|
</React.StrictMode>
|
|
818
812
|
);
|
|
819
|
-
|
|
820
813
|
```
|
|
821
814
|
|
|
822
815
|
**/public/index.html**
|
|
823
816
|
|
|
824
817
|
```html
|
|
825
|
-
<!
|
|
818
|
+
<!doctype html>
|
|
826
819
|
<html lang="en">
|
|
827
820
|
<head>
|
|
828
821
|
<meta charset="UTF-8" />
|
|
@@ -843,13 +836,24 @@ root.render(
|
|
|
843
836
|
<div id="root"></div>
|
|
844
837
|
</body>
|
|
845
838
|
</html>
|
|
846
|
-
|
|
847
839
|
```
|
|
848
840
|
|
|
849
841
|
**/package.json**
|
|
850
842
|
|
|
851
843
|
```json
|
|
852
|
-
{
|
|
844
|
+
{
|
|
845
|
+
"dependencies": {
|
|
846
|
+
"react": "^18.0.0",
|
|
847
|
+
"react-dom": "^18.0.0",
|
|
848
|
+
"react-scripts": "^4.0.0"
|
|
849
|
+
},
|
|
850
|
+
"devDependencies": {
|
|
851
|
+
"@types/react": "^18.0.0",
|
|
852
|
+
"@types/react-dom": "^18.0.0",
|
|
853
|
+
"typescript": "^4.0.0"
|
|
854
|
+
},
|
|
855
|
+
"main": "/index.tsx"
|
|
856
|
+
}
|
|
853
857
|
```
|
|
854
858
|
|
|
855
859
|
---
|
|
@@ -858,7 +862,7 @@ root.render(
|
|
|
858
862
|
|
|
859
863
|
A search feature can be easily incorporated into the `Dropdown` component by including the `search` prop.
|
|
860
864
|
|
|
861
|
-
The search functionality operates by dynamically filtering out non-matching options as the user types, displaying only the menu items whose text corresponds to that input. If no matching items are found, the `Dropdown` will automatically present "No options" below the search bar.
|
|
865
|
+
The search functionality operates by dynamically filtering out non-matching options as the user types, displaying only the menu items whose text corresponds to that input. If no matching items are found, the `Dropdown` will automatically present "No options" below the search bar.
|
|
862
866
|
|
|
863
867
|
To ensure that the search input retains its text even after a user selects a menu item (when multiple selections are allowed), set the `keepSearchOnSelect` prop to `true` within the `DropdownMenuProps` prop. This allows users to conveniently choose multiple menu items that match the searched term without the need to re-enter it for each selection.
|
|
864
868
|
|
|
@@ -887,13 +891,11 @@ h1 {
|
|
|
887
891
|
|
|
888
892
|
```json
|
|
889
893
|
{
|
|
890
|
-
"include": [
|
|
891
|
-
"./**/*"
|
|
892
|
-
],
|
|
894
|
+
"include": ["./**/*"],
|
|
893
895
|
"compilerOptions": {
|
|
894
896
|
"strict": true,
|
|
895
897
|
"esModuleInterop": true,
|
|
896
|
-
"lib": [
|
|
898
|
+
"lib": ["dom", "es2015"],
|
|
897
899
|
"jsx": "react-jsx"
|
|
898
900
|
}
|
|
899
901
|
}
|
|
@@ -910,36 +912,36 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
910
912
|
{
|
|
911
913
|
name: "Fruit: Apple",
|
|
912
914
|
section: "Fruit",
|
|
913
|
-
count: 10
|
|
915
|
+
count: 10,
|
|
914
916
|
},
|
|
915
917
|
{
|
|
916
918
|
name: "Fruit: Cherry",
|
|
917
919
|
section: "Fruit",
|
|
918
|
-
count: 150
|
|
920
|
+
count: 150,
|
|
919
921
|
},
|
|
920
922
|
{
|
|
921
923
|
name: "Fruit: Orange",
|
|
922
924
|
section: "Fruit",
|
|
923
|
-
count: 15
|
|
925
|
+
count: 15,
|
|
924
926
|
},
|
|
925
927
|
{
|
|
926
928
|
name: "Vegetable: Carrot",
|
|
927
929
|
section: "Vegetable",
|
|
928
|
-
count: 34
|
|
930
|
+
count: 34,
|
|
929
931
|
},
|
|
930
932
|
{
|
|
931
933
|
name: "Vegetable: Kale",
|
|
932
|
-
section: "Vegetable"
|
|
934
|
+
section: "Vegetable",
|
|
933
935
|
},
|
|
934
936
|
{
|
|
935
937
|
name: "Vegetable: Lettuce",
|
|
936
|
-
section: "Vegetable"
|
|
938
|
+
section: "Vegetable",
|
|
937
939
|
},
|
|
938
940
|
];
|
|
939
941
|
|
|
940
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
942
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
941
943
|
|
|
942
|
-
function handleClickAway(){}
|
|
944
|
+
function handleClickAway() {}
|
|
943
945
|
|
|
944
946
|
function App() {
|
|
945
947
|
const ref = useRef(null);
|
|
@@ -947,8 +949,8 @@ function App() {
|
|
|
947
949
|
|
|
948
950
|
useEffect(() => {
|
|
949
951
|
if (ref.current) setOpen(true);
|
|
950
|
-
}, [ref.current])
|
|
951
|
-
|
|
952
|
+
}, [ref.current]);
|
|
953
|
+
|
|
952
954
|
return (
|
|
953
955
|
<div className="app">
|
|
954
956
|
<Dropdown
|
|
@@ -1007,13 +1009,12 @@ root.render(
|
|
|
1007
1009
|
<RootApp />
|
|
1008
1010
|
</React.StrictMode>
|
|
1009
1011
|
);
|
|
1010
|
-
|
|
1011
1012
|
```
|
|
1012
1013
|
|
|
1013
1014
|
**/public/index.html**
|
|
1014
1015
|
|
|
1015
1016
|
```html
|
|
1016
|
-
<!
|
|
1017
|
+
<!doctype html>
|
|
1017
1018
|
<html lang="en">
|
|
1018
1019
|
<head>
|
|
1019
1020
|
<meta charset="UTF-8" />
|
|
@@ -1034,13 +1035,24 @@ root.render(
|
|
|
1034
1035
|
<div id="root"></div>
|
|
1035
1036
|
</body>
|
|
1036
1037
|
</html>
|
|
1037
|
-
|
|
1038
1038
|
```
|
|
1039
1039
|
|
|
1040
1040
|
**/package.json**
|
|
1041
1041
|
|
|
1042
1042
|
```json
|
|
1043
|
-
{
|
|
1043
|
+
{
|
|
1044
|
+
"dependencies": {
|
|
1045
|
+
"react": "^18.0.0",
|
|
1046
|
+
"react-dom": "^18.0.0",
|
|
1047
|
+
"react-scripts": "^4.0.0"
|
|
1048
|
+
},
|
|
1049
|
+
"devDependencies": {
|
|
1050
|
+
"@types/react": "^18.0.0",
|
|
1051
|
+
"@types/react-dom": "^18.0.0",
|
|
1052
|
+
"typescript": "^4.0.0"
|
|
1053
|
+
},
|
|
1054
|
+
"main": "/index.tsx"
|
|
1055
|
+
}
|
|
1044
1056
|
```
|
|
1045
1057
|
|
|
1046
1058
|
---
|
|
@@ -1057,9 +1069,9 @@ The component's source code in the SDS codebase can be found here.
|
|
|
1057
1069
|
|
|
1058
1070
|
Both SDS's `DropdownMenu` and MUI's `Autocomplete` have huge API surfaces, so it is not practical to list every way in which they differ (in part because the list would likely become obsolete quickly!). In summary, these are a few of the most relevant ways in which `DropdownMenu` integrates with `Autocomplete` and other MUI components:
|
|
1059
1071
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1072
|
+
- SDS `DropdownMenu` uses MUI `Autocomplete` under the hood, so all props passed to `DropdownMenu` are ultimately passed to the `Autocomplete` component as well. This means MUI's `Autocomplete` props can be used on SDS's `DropdownMenu` if needed.
|
|
1073
|
+
- SDS `DropdownMenu` uses MUI `Popper`. A custom `Popper` component can be passed via `props.PopperComponent` and/or `props.PopperBaseProps` to control the popper component.
|
|
1074
|
+
- Similarly, SDS `DropdownMenu` uses MUI `Paper`. A custom `Paper` component can be passed via `props.PaperComponent` to enable custom styling.
|
|
1063
1075
|
|
|
1064
1076
|
### MUI Documentation
|
|
1065
1077
|
|
|
@@ -1069,37 +1081,37 @@ Documentation for the underlying MUI `Autocomplete` component can be found here.
|
|
|
1069
1081
|
|
|
1070
1082
|
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
1071
1083
|
|
|
1072
|
-
| **Name**
|
|
1073
|
-
|
|
|
1074
|
-
| `anchorEl`
|
|
1075
|
-
| `clickAwayListenerProps` | `func`
|
|
1076
|
-
| `groupBy`
|
|
1077
|
-
| `isOptionEqualToValue`
|
|
1078
|
-
| `keepSearchOnSelect`
|
|
1079
|
-
| `multiple`
|
|
1080
|
-
| `noOptionsText`
|
|
1081
|
-
| `onClickAway`
|
|
1082
|
-
| `onInputChange`
|
|
1083
|
-
| `PopperBaseProps`
|
|
1084
|
-
| `PopperComponent`
|
|
1085
|
-
| `search`
|
|
1086
|
-
| `title`
|
|
1087
|
-
|
|
1088
|
-
There are many more props that can be used with the `DropdownMenu`
|
|
1089
|
-
|
|
1090
|
-
|
|
1084
|
+
| **Name** | **Type** | **Default** | **Description** |
|
|
1085
|
+
| ------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------ |
|
|
1086
|
+
| `anchorEl` | `HTML element` ` | object` ` | func` | `null` | Tells the DropdownMenu which element to use as an anchor; see more in the MUI `Popper` component's API |
|
|
1087
|
+
| `clickAwayListenerProps` | `func` | `-` | Passes props to the MUI `ClickAwayListener` |
|
|
1088
|
+
| `groupBy` | `func` | `-` | Groups menu items according to their assigned `section` |
|
|
1089
|
+
| `isOptionEqualToValue` | `func` | `(option, val): boolean {` `return option.name === val.name;` `}` | Changes how a selected value is compared against the available options; see more in the MUI Autocomplete API or in the DropdownMenu Component Recipes section |
|
|
1090
|
+
| `keepSearchOnSelect` | `bool` | `true` | Maintains a search input when a user selects a menu item (only if multiple selections are allowed via the `multiple` prop; otherwise the dropdown closes upon selection) |
|
|
1091
|
+
| `multiple` | `bool` | `false` | Allows user to select multiple menu items; see more in the MUI Autocomplete API |
|
|
1092
|
+
| `noOptionsText` | `string` | `"No options"` | Sets the text that displays if there are no matching search results; see more in the MUI Autocomplete API |
|
|
1093
|
+
| `onClickAway` | `func` | `-` | Sets what happens when a user clicks outside of the DropdownMenu |
|
|
1094
|
+
| `onInputChange` | `func` | `noop` | Specifies what happens when a new selection is made; see more in the MUI Autocomplete API or in the DropdownMenu Component Recipes section |
|
|
1095
|
+
| `PopperBaseProps` | | `-` | Passes custom props to the MUI`Popper` component, which is included as part of the SDS`DropdownMenu` component. Learn more in the Popper documentation, and see all the props available to pass to it on the Popper API page. See an example of `PopperBaseProps` in use in the DropdownMenu Component Recipes section |
|
|
1096
|
+
| `PopperComponent` | `func` | SDS's `StyledPopper`; see sci-components/packages/components/src/core/DropdownMenu/style.ts, ~ line 202 | The MUI `Popper` component is included as part of the SDS `DropdownMenu` component, and its styles can be changed or added to |
|
|
1097
|
+
| `search` | `bool` | `f``alse` | Provides a search bar at the top of the menu from which users can narrow the list of menu items |
|
|
1098
|
+
| `title` | `string` | `-` | Sets a heading for the menu |
|
|
1099
|
+
|
|
1100
|
+
There are many more props that can be used with the `DropdownMenu` component, via those available to MUI's `Autocomplete` component.
|
|
1101
|
+
|
|
1102
|
+
> **Note for use with SDS** **`Table`** **and other components:**
|
|
1091
1103
|
>
|
|
1092
|
-
>Each time a table column is shown/hidden a new table object is created. This causes components within the table to remount.
|
|
1104
|
+
> Each time a table column is shown/hidden a new table object is created. This causes components within the table to remount. _This can be a problem with_ _`DropdownMenu`_ _if the menu is supposed to stay open while the columns are hidden/shown because the anchor element also gets recreated._ To resolve this, move the `DropdownMenu` anchor element outside of the table or use the `pendingState` and only show/hide the columns when closing the dropdown.
|
|
1093
1105
|
|
|
1094
1106
|
### Code Examples
|
|
1095
1107
|
|
|
1096
1108
|
#### Default DropdownMenu
|
|
1097
1109
|
|
|
1098
|
-
This example has the minimum props and menu item metadata needed for the `DropdownMenu`.
|
|
1110
|
+
This example has the minimum props and menu item metadata needed for the `DropdownMenu`.
|
|
1099
1111
|
|
|
1100
|
-
Menu item metadata is stored as an array of objects (one per menu item) passed to the `DropdownMenu` component’s `options` prop.
|
|
1112
|
+
Menu item metadata is stored as an array of objects (one per menu item) passed to the `DropdownMenu` component’s `options` prop. At minimum each `MenuItem` needs a `name` property, which is the text it displays. `MenuItems` can display more metadata, though; see the “DropdownMenu with grouped sections” and “DropdownMenu with menu items that have count, icon, and / or details” examples below. Alternatively, a custom component can be displayed instead of a `MenuItem` component; see the “DropdownMenu with components in place of menu items” example below.
|
|
1101
1113
|
|
|
1102
|
-
The minimum width for the `DropdownMenu` is 225px, but longer text will automatically widen the `DropdownMenu` up to the length of the text provided.
|
|
1114
|
+
The minimum width for the `DropdownMenu` is 225px, but longer text will automatically widen the `DropdownMenu` up to the length of the text provided.
|
|
1103
1115
|
|
|
1104
1116
|
Although examples shows the minimum requirements for the `DropdownMenu`, there are many more options available to include; see subsequent code examples further below.
|
|
1105
1117
|
|
|
@@ -1128,13 +1140,11 @@ h1 {
|
|
|
1128
1140
|
|
|
1129
1141
|
```json
|
|
1130
1142
|
{
|
|
1131
|
-
"include": [
|
|
1132
|
-
"./**/*"
|
|
1133
|
-
],
|
|
1143
|
+
"include": ["./**/*"],
|
|
1134
1144
|
"compilerOptions": {
|
|
1135
1145
|
"strict": true,
|
|
1136
1146
|
"esModuleInterop": true,
|
|
1137
|
-
"lib": [
|
|
1147
|
+
"lib": ["dom", "es2015"],
|
|
1138
1148
|
"jsx": "react-jsx"
|
|
1139
1149
|
}
|
|
1140
1150
|
}
|
|
@@ -1144,7 +1154,7 @@ h1 {
|
|
|
1144
1154
|
|
|
1145
1155
|
```tsx
|
|
1146
1156
|
// Most minimal DropdownMenu (just has the basic requirements)
|
|
1147
|
-
|
|
1157
|
+
|
|
1148
1158
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
1149
1159
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
1150
1160
|
import "./styles.css";
|
|
@@ -1163,10 +1173,10 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
1163
1173
|
name: "Longer menu item than the others",
|
|
1164
1174
|
},
|
|
1165
1175
|
];
|
|
1166
|
-
|
|
1167
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
1168
1176
|
|
|
1169
|
-
|
|
1177
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
1178
|
+
|
|
1179
|
+
function handleClickAway() {}
|
|
1170
1180
|
|
|
1171
1181
|
function App() {
|
|
1172
1182
|
const ref = useRef(null);
|
|
@@ -1174,23 +1184,21 @@ function App() {
|
|
|
1174
1184
|
|
|
1175
1185
|
useEffect(() => {
|
|
1176
1186
|
if (ref.current) setOpen(true);
|
|
1177
|
-
}, [ref.current])
|
|
1178
|
-
|
|
1187
|
+
}, [ref.current]);
|
|
1188
|
+
|
|
1179
1189
|
return (
|
|
1180
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
1190
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
1181
1191
|
<div ref={ref} />
|
|
1182
|
-
{open &&
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
)
|
|
1193
|
-
}
|
|
1192
|
+
{open && (
|
|
1193
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
1194
|
+
<DropdownMenu
|
|
1195
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
1196
|
+
anchorEl={ref.current}
|
|
1197
|
+
onClickAway={handleClickAway}
|
|
1198
|
+
open={open}
|
|
1199
|
+
options={MENU_ITEMS}
|
|
1200
|
+
/>
|
|
1201
|
+
)}
|
|
1194
1202
|
</div>
|
|
1195
1203
|
);
|
|
1196
1204
|
}
|
|
@@ -1235,13 +1243,12 @@ root.render(
|
|
|
1235
1243
|
<RootApp />
|
|
1236
1244
|
</React.StrictMode>
|
|
1237
1245
|
);
|
|
1238
|
-
|
|
1239
1246
|
```
|
|
1240
1247
|
|
|
1241
1248
|
**/public/index.html**
|
|
1242
1249
|
|
|
1243
1250
|
```html
|
|
1244
|
-
<!
|
|
1251
|
+
<!doctype html>
|
|
1245
1252
|
<html lang="en">
|
|
1246
1253
|
<head>
|
|
1247
1254
|
<meta charset="UTF-8" />
|
|
@@ -1262,13 +1269,24 @@ root.render(
|
|
|
1262
1269
|
<div id="root"></div>
|
|
1263
1270
|
</body>
|
|
1264
1271
|
</html>
|
|
1265
|
-
|
|
1266
1272
|
```
|
|
1267
1273
|
|
|
1268
1274
|
**/package.json**
|
|
1269
1275
|
|
|
1270
1276
|
```json
|
|
1271
|
-
{
|
|
1277
|
+
{
|
|
1278
|
+
"dependencies": {
|
|
1279
|
+
"react": "^18.0.0",
|
|
1280
|
+
"react-dom": "^18.0.0",
|
|
1281
|
+
"react-scripts": "^4.0.0"
|
|
1282
|
+
},
|
|
1283
|
+
"devDependencies": {
|
|
1284
|
+
"@types/react": "^18.0.0",
|
|
1285
|
+
"@types/react-dom": "^18.0.0",
|
|
1286
|
+
"typescript": "^4.0.0"
|
|
1287
|
+
},
|
|
1288
|
+
"main": "/index.tsx"
|
|
1289
|
+
}
|
|
1272
1290
|
```
|
|
1273
1291
|
|
|
1274
1292
|
---
|
|
@@ -1302,13 +1320,11 @@ h1 {
|
|
|
1302
1320
|
|
|
1303
1321
|
```json
|
|
1304
1322
|
{
|
|
1305
|
-
"include": [
|
|
1306
|
-
"./**/*"
|
|
1307
|
-
],
|
|
1323
|
+
"include": ["./**/*"],
|
|
1308
1324
|
"compilerOptions": {
|
|
1309
1325
|
"strict": true,
|
|
1310
1326
|
"esModuleInterop": true,
|
|
1311
|
-
"lib": [
|
|
1327
|
+
"lib": ["dom", "es2015"],
|
|
1312
1328
|
"jsx": "react-jsx"
|
|
1313
1329
|
}
|
|
1314
1330
|
}
|
|
@@ -1318,9 +1334,13 @@ h1 {
|
|
|
1318
1334
|
|
|
1319
1335
|
```tsx
|
|
1320
1336
|
// DropdownMenu with custom click target
|
|
1321
|
-
|
|
1337
|
+
|
|
1322
1338
|
import React, { SyntheticEvent, useState, useRef } from "react";
|
|
1323
|
-
import {
|
|
1339
|
+
import {
|
|
1340
|
+
DropdownMenu,
|
|
1341
|
+
DefaultDropdownMenuOption,
|
|
1342
|
+
InputDropdown,
|
|
1343
|
+
} from "@czi-sds/components";
|
|
1324
1344
|
import "./styles.css";
|
|
1325
1345
|
|
|
1326
1346
|
function App() {
|
|
@@ -1369,7 +1389,7 @@ function App() {
|
|
|
1369
1389
|
label="Click Target"
|
|
1370
1390
|
sdsType="label"
|
|
1371
1391
|
sdsStyle="minimal"
|
|
1372
|
-
/>
|
|
1392
|
+
/>
|
|
1373
1393
|
<DropdownMenu
|
|
1374
1394
|
options={MENU_ITEMS}
|
|
1375
1395
|
anchorEl={anchorEl}
|
|
@@ -1422,13 +1442,12 @@ root.render(
|
|
|
1422
1442
|
<RootApp />
|
|
1423
1443
|
</React.StrictMode>
|
|
1424
1444
|
);
|
|
1425
|
-
|
|
1426
1445
|
```
|
|
1427
1446
|
|
|
1428
1447
|
**/public/index.html**
|
|
1429
1448
|
|
|
1430
1449
|
```html
|
|
1431
|
-
<!
|
|
1450
|
+
<!doctype html>
|
|
1432
1451
|
<html lang="en">
|
|
1433
1452
|
<head>
|
|
1434
1453
|
<meta charset="UTF-8" />
|
|
@@ -1449,13 +1468,24 @@ root.render(
|
|
|
1449
1468
|
<div id="root"></div>
|
|
1450
1469
|
</body>
|
|
1451
1470
|
</html>
|
|
1452
|
-
|
|
1453
1471
|
```
|
|
1454
1472
|
|
|
1455
1473
|
**/package.json**
|
|
1456
1474
|
|
|
1457
1475
|
```json
|
|
1458
|
-
{
|
|
1476
|
+
{
|
|
1477
|
+
"dependencies": {
|
|
1478
|
+
"react": "^18.0.0",
|
|
1479
|
+
"react-dom": "^18.0.0",
|
|
1480
|
+
"react-scripts": "^4.0.0"
|
|
1481
|
+
},
|
|
1482
|
+
"devDependencies": {
|
|
1483
|
+
"@types/react": "^18.0.0",
|
|
1484
|
+
"@types/react-dom": "^18.0.0",
|
|
1485
|
+
"typescript": "^4.0.0"
|
|
1486
|
+
},
|
|
1487
|
+
"main": "/index.tsx"
|
|
1488
|
+
}
|
|
1459
1489
|
```
|
|
1460
1490
|
|
|
1461
1491
|
---
|
|
@@ -1466,7 +1496,7 @@ An `InputSearch` component can be incorporated into the `DropdownMenu` component
|
|
|
1466
1496
|
|
|
1467
1497
|
The search functions by filtering out non-matches as the user types, leaving only menu items with text that match the input. If no matches are found, the `DropdownMenu` displays “No options” below the `InputSearch` by default. This text can be changed via the `noOptionsText` prop as shown below.
|
|
1468
1498
|
|
|
1469
|
-
By default, the search’s input text is maintained even when a user selects a `MenuItem` (if multiple selections are allowed; otherwise the dropdown closes upon selection). This way users can select multiple `MenuItems` that match the searched term without needing to re-enter it each time. However, this can be changed so that the search input clears upon making a selection; see the “Dropdown with search and multi-select; does
|
|
1499
|
+
By default, the search’s input text is maintained even when a user selects a `MenuItem` (if multiple selections are allowed; otherwise the dropdown closes upon selection). This way users can select multiple `MenuItems` that match the searched term without needing to re-enter it each time. However, this can be changed so that the search input clears upon making a selection; see the “Dropdown with search and multi-select; does _not_ maintain searched query upon selection of a menu item” example below.
|
|
1470
1500
|
|
|
1471
1501
|
1. In the search box, type in "fruit"
|
|
1472
1502
|
2. `DropdownMenu` will display "Fruit: Apple" and "Fruit: Orange"
|
|
@@ -1498,13 +1528,11 @@ h1 {
|
|
|
1498
1528
|
|
|
1499
1529
|
```json
|
|
1500
1530
|
{
|
|
1501
|
-
"include": [
|
|
1502
|
-
"./**/*"
|
|
1503
|
-
],
|
|
1531
|
+
"include": ["./**/*"],
|
|
1504
1532
|
"compilerOptions": {
|
|
1505
1533
|
"strict": true,
|
|
1506
1534
|
"esModuleInterop": true,
|
|
1507
|
-
"lib": [
|
|
1535
|
+
"lib": ["dom", "es2015"],
|
|
1508
1536
|
"jsx": "react-jsx"
|
|
1509
1537
|
}
|
|
1510
1538
|
}
|
|
@@ -1514,7 +1542,7 @@ h1 {
|
|
|
1514
1542
|
|
|
1515
1543
|
```tsx
|
|
1516
1544
|
// DropdownMenu with search
|
|
1517
|
-
|
|
1545
|
+
|
|
1518
1546
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
1519
1547
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
1520
1548
|
import "./styles.css";
|
|
@@ -1534,9 +1562,9 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
1534
1562
|
},
|
|
1535
1563
|
];
|
|
1536
1564
|
|
|
1537
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
1565
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
1538
1566
|
|
|
1539
|
-
function handleClickAway(){}
|
|
1567
|
+
function handleClickAway() {}
|
|
1540
1568
|
|
|
1541
1569
|
function App() {
|
|
1542
1570
|
const ref = useRef(null);
|
|
@@ -1544,25 +1572,23 @@ function App() {
|
|
|
1544
1572
|
|
|
1545
1573
|
useEffect(() => {
|
|
1546
1574
|
if (ref.current) setOpen(true);
|
|
1547
|
-
}, [ref.current])
|
|
1548
|
-
|
|
1575
|
+
}, [ref.current]);
|
|
1576
|
+
|
|
1549
1577
|
return (
|
|
1550
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
1578
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
1551
1579
|
<div ref={ref} />
|
|
1552
|
-
{open &&
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
)
|
|
1565
|
-
}
|
|
1580
|
+
{open && (
|
|
1581
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
1582
|
+
<DropdownMenu
|
|
1583
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
1584
|
+
anchorEl={ref.current}
|
|
1585
|
+
noOptionsText="No matches found, try again!"
|
|
1586
|
+
onClickAway={handleClickAway}
|
|
1587
|
+
open
|
|
1588
|
+
options={MENU_ITEMS}
|
|
1589
|
+
search
|
|
1590
|
+
/>
|
|
1591
|
+
)}
|
|
1566
1592
|
</div>
|
|
1567
1593
|
);
|
|
1568
1594
|
}
|
|
@@ -1607,13 +1633,12 @@ root.render(
|
|
|
1607
1633
|
<RootApp />
|
|
1608
1634
|
</React.StrictMode>
|
|
1609
1635
|
);
|
|
1610
|
-
|
|
1611
1636
|
```
|
|
1612
1637
|
|
|
1613
1638
|
**/public/index.html**
|
|
1614
1639
|
|
|
1615
1640
|
```html
|
|
1616
|
-
<!
|
|
1641
|
+
<!doctype html>
|
|
1617
1642
|
<html lang="en">
|
|
1618
1643
|
<head>
|
|
1619
1644
|
<meta charset="UTF-8" />
|
|
@@ -1634,20 +1659,31 @@ root.render(
|
|
|
1634
1659
|
<div id="root"></div>
|
|
1635
1660
|
</body>
|
|
1636
1661
|
</html>
|
|
1637
|
-
|
|
1638
1662
|
```
|
|
1639
1663
|
|
|
1640
1664
|
**/package.json**
|
|
1641
1665
|
|
|
1642
1666
|
```json
|
|
1643
|
-
{
|
|
1667
|
+
{
|
|
1668
|
+
"dependencies": {
|
|
1669
|
+
"react": "^18.0.0",
|
|
1670
|
+
"react-dom": "^18.0.0",
|
|
1671
|
+
"react-scripts": "^4.0.0"
|
|
1672
|
+
},
|
|
1673
|
+
"devDependencies": {
|
|
1674
|
+
"@types/react": "^18.0.0",
|
|
1675
|
+
"@types/react-dom": "^18.0.0",
|
|
1676
|
+
"typescript": "^4.0.0"
|
|
1677
|
+
},
|
|
1678
|
+
"main": "/index.tsx"
|
|
1679
|
+
}
|
|
1644
1680
|
```
|
|
1645
1681
|
|
|
1646
1682
|
---
|
|
1647
1683
|
|
|
1648
1684
|
#### DropdownMenu with multi-select
|
|
1649
1685
|
|
|
1650
|
-
You can allow users to select multiple menu items by passing the `DropdownMenu` component the `multiple` prop.
|
|
1686
|
+
You can allow users to select multiple menu items by passing the `DropdownMenu` component the `multiple` prop. `MenuItems` will be shifted further to the right to make room for checkmarks displayed upon selection.
|
|
1651
1687
|
|
|
1652
1688
|
If the `multiple` prop is not `true`, the `DropdownMenu` allows just one selection. It closes and applies the selection once a menu item is selected.
|
|
1653
1689
|
|
|
@@ -1676,13 +1712,11 @@ h1 {
|
|
|
1676
1712
|
|
|
1677
1713
|
```json
|
|
1678
1714
|
{
|
|
1679
|
-
"include": [
|
|
1680
|
-
"./**/*"
|
|
1681
|
-
],
|
|
1715
|
+
"include": ["./**/*"],
|
|
1682
1716
|
"compilerOptions": {
|
|
1683
1717
|
"strict": true,
|
|
1684
1718
|
"esModuleInterop": true,
|
|
1685
|
-
"lib": [
|
|
1719
|
+
"lib": ["dom", "es2015"],
|
|
1686
1720
|
"jsx": "react-jsx"
|
|
1687
1721
|
}
|
|
1688
1722
|
}
|
|
@@ -1692,7 +1726,7 @@ h1 {
|
|
|
1692
1726
|
|
|
1693
1727
|
```tsx
|
|
1694
1728
|
// DropdownMenu with multi-select
|
|
1695
|
-
|
|
1729
|
+
|
|
1696
1730
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
1697
1731
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
1698
1732
|
import "./styles.css";
|
|
@@ -1709,9 +1743,9 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
1709
1743
|
},
|
|
1710
1744
|
];
|
|
1711
1745
|
|
|
1712
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
1746
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
1713
1747
|
|
|
1714
|
-
function handleClickAway(){}
|
|
1748
|
+
function handleClickAway() {}
|
|
1715
1749
|
|
|
1716
1750
|
function App() {
|
|
1717
1751
|
const ref = useRef(null);
|
|
@@ -1719,24 +1753,22 @@ function App() {
|
|
|
1719
1753
|
|
|
1720
1754
|
useEffect(() => {
|
|
1721
1755
|
if (ref.current) setOpen(true);
|
|
1722
|
-
}, [ref.current])
|
|
1723
|
-
|
|
1756
|
+
}, [ref.current]);
|
|
1757
|
+
|
|
1724
1758
|
return (
|
|
1725
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
1759
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
1726
1760
|
<div ref={ref} />
|
|
1727
|
-
{open &&
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
)
|
|
1739
|
-
}
|
|
1761
|
+
{open && (
|
|
1762
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
1763
|
+
<DropdownMenu
|
|
1764
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
1765
|
+
anchorEl={ref.current}
|
|
1766
|
+
multiple
|
|
1767
|
+
onClickAway={handleClickAway}
|
|
1768
|
+
open
|
|
1769
|
+
options={MENU_ITEMS}
|
|
1770
|
+
/>
|
|
1771
|
+
)}
|
|
1740
1772
|
</div>
|
|
1741
1773
|
);
|
|
1742
1774
|
}
|
|
@@ -1781,13 +1813,12 @@ root.render(
|
|
|
1781
1813
|
<RootApp />
|
|
1782
1814
|
</React.StrictMode>
|
|
1783
1815
|
);
|
|
1784
|
-
|
|
1785
1816
|
```
|
|
1786
1817
|
|
|
1787
1818
|
**/public/index.html**
|
|
1788
1819
|
|
|
1789
1820
|
```html
|
|
1790
|
-
<!
|
|
1821
|
+
<!doctype html>
|
|
1791
1822
|
<html lang="en">
|
|
1792
1823
|
<head>
|
|
1793
1824
|
<meta charset="UTF-8" />
|
|
@@ -1808,18 +1839,29 @@ root.render(
|
|
|
1808
1839
|
<div id="root"></div>
|
|
1809
1840
|
</body>
|
|
1810
1841
|
</html>
|
|
1811
|
-
|
|
1812
1842
|
```
|
|
1813
1843
|
|
|
1814
1844
|
**/package.json**
|
|
1815
1845
|
|
|
1816
1846
|
```json
|
|
1817
|
-
{
|
|
1847
|
+
{
|
|
1848
|
+
"dependencies": {
|
|
1849
|
+
"react": "^18.0.0",
|
|
1850
|
+
"react-dom": "^18.0.0",
|
|
1851
|
+
"react-scripts": "^4.0.0"
|
|
1852
|
+
},
|
|
1853
|
+
"devDependencies": {
|
|
1854
|
+
"@types/react": "^18.0.0",
|
|
1855
|
+
"@types/react-dom": "^18.0.0",
|
|
1856
|
+
"typescript": "^4.0.0"
|
|
1857
|
+
},
|
|
1858
|
+
"main": "/index.tsx"
|
|
1859
|
+
}
|
|
1818
1860
|
```
|
|
1819
1861
|
|
|
1820
1862
|
---
|
|
1821
1863
|
|
|
1822
|
-
#### Dropdown with search and multi-select; does
|
|
1864
|
+
#### Dropdown with search and multi-select; does _not_ maintain searched query upon selection of a menu item
|
|
1823
1865
|
|
|
1824
1866
|
If search is included in the `DropdownMenu`, by default the search input will be maintained when a user selects a `MenuItem` (if multiple selections are allowed; otherwise the dropdown menu closes upon selection). However, the search input can be set to close upon selection by setting the optional `keepSearchOnSelect` prop to `false`.
|
|
1825
1867
|
|
|
@@ -1832,7 +1874,7 @@ To see how this works:
|
|
|
1832
1874
|
3. Select "Fruit: Apple"
|
|
1833
1875
|
4. Note that the search text is now cleared and all dropdown items reappear
|
|
1834
1876
|
|
|
1835
|
-
Compare this to the default behavior in the "DropdownMenu with search" example above, or change the `keepSearchOnSelect`
|
|
1877
|
+
Compare this to the default behavior in the "DropdownMenu with search" example above, or change the `keepSearchOnSelect` prop in the example below to `true`.
|
|
1836
1878
|
|
|
1837
1879
|
**/styles.css**
|
|
1838
1880
|
|
|
@@ -1859,13 +1901,11 @@ h1 {
|
|
|
1859
1901
|
|
|
1860
1902
|
```json
|
|
1861
1903
|
{
|
|
1862
|
-
"include": [
|
|
1863
|
-
"./**/*"
|
|
1864
|
-
],
|
|
1904
|
+
"include": ["./**/*"],
|
|
1865
1905
|
"compilerOptions": {
|
|
1866
1906
|
"strict": true,
|
|
1867
1907
|
"esModuleInterop": true,
|
|
1868
|
-
"lib": [
|
|
1908
|
+
"lib": ["dom", "es2015"],
|
|
1869
1909
|
"jsx": "react-jsx"
|
|
1870
1910
|
}
|
|
1871
1911
|
}
|
|
@@ -1875,7 +1915,7 @@ h1 {
|
|
|
1875
1915
|
|
|
1876
1916
|
```tsx
|
|
1877
1917
|
// Dropdown with multi-select that does not maintain searched query upon selection of a menu item
|
|
1878
|
-
|
|
1918
|
+
|
|
1879
1919
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
1880
1920
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
1881
1921
|
import "./styles.css";
|
|
@@ -1894,10 +1934,10 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
1894
1934
|
name: "Vegetable: Kale",
|
|
1895
1935
|
},
|
|
1896
1936
|
];
|
|
1897
|
-
|
|
1898
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
1899
1937
|
|
|
1900
|
-
|
|
1938
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
1939
|
+
|
|
1940
|
+
function handleClickAway() {}
|
|
1901
1941
|
|
|
1902
1942
|
function App() {
|
|
1903
1943
|
const ref = useRef(null);
|
|
@@ -1905,26 +1945,24 @@ function App() {
|
|
|
1905
1945
|
|
|
1906
1946
|
useEffect(() => {
|
|
1907
1947
|
if (ref.current) setOpen(true);
|
|
1908
|
-
}, [ref.current])
|
|
1909
|
-
|
|
1948
|
+
}, [ref.current]);
|
|
1949
|
+
|
|
1910
1950
|
return (
|
|
1911
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
1951
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
1912
1952
|
<div ref={ref} />
|
|
1913
|
-
{open &&
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
)
|
|
1927
|
-
}
|
|
1953
|
+
{open && (
|
|
1954
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
1955
|
+
<DropdownMenu
|
|
1956
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
1957
|
+
anchorEl={ref.current}
|
|
1958
|
+
keepSearchOnSelect={false}
|
|
1959
|
+
multiple
|
|
1960
|
+
onClickAway={function handleClickAway() {}}
|
|
1961
|
+
open
|
|
1962
|
+
options={MENU_ITEMS}
|
|
1963
|
+
search
|
|
1964
|
+
/>
|
|
1965
|
+
)}
|
|
1928
1966
|
</div>
|
|
1929
1967
|
);
|
|
1930
1968
|
}
|
|
@@ -1969,13 +2007,12 @@ root.render(
|
|
|
1969
2007
|
<RootApp />
|
|
1970
2008
|
</React.StrictMode>
|
|
1971
2009
|
);
|
|
1972
|
-
|
|
1973
2010
|
```
|
|
1974
2011
|
|
|
1975
2012
|
**/public/index.html**
|
|
1976
2013
|
|
|
1977
2014
|
```html
|
|
1978
|
-
<!
|
|
2015
|
+
<!doctype html>
|
|
1979
2016
|
<html lang="en">
|
|
1980
2017
|
<head>
|
|
1981
2018
|
<meta charset="UTF-8" />
|
|
@@ -1996,13 +2033,24 @@ root.render(
|
|
|
1996
2033
|
<div id="root"></div>
|
|
1997
2034
|
</body>
|
|
1998
2035
|
</html>
|
|
1999
|
-
|
|
2000
2036
|
```
|
|
2001
2037
|
|
|
2002
2038
|
**/package.json**
|
|
2003
2039
|
|
|
2004
2040
|
```json
|
|
2005
|
-
{
|
|
2041
|
+
{
|
|
2042
|
+
"dependencies": {
|
|
2043
|
+
"react": "^18.0.0",
|
|
2044
|
+
"react-dom": "^18.0.0",
|
|
2045
|
+
"react-scripts": "^4.0.0"
|
|
2046
|
+
},
|
|
2047
|
+
"devDependencies": {
|
|
2048
|
+
"@types/react": "^18.0.0",
|
|
2049
|
+
"@types/react-dom": "^18.0.0",
|
|
2050
|
+
"typescript": "^4.0.0"
|
|
2051
|
+
},
|
|
2052
|
+
"main": "/index.tsx"
|
|
2053
|
+
}
|
|
2006
2054
|
```
|
|
2007
2055
|
|
|
2008
2056
|
---
|
|
@@ -2015,19 +2063,19 @@ This requires passing `DropdownMenu` the `groupBy` prop to group options under t
|
|
|
2015
2063
|
|
|
2016
2064
|
`groupBy={(option) => {`
|
|
2017
2065
|
|
|
2018
|
-
|
|
2066
|
+
`return option.section; // this will group items by section`
|
|
2019
2067
|
|
|
2020
|
-
|
|
2068
|
+
`// Another example`
|
|
2021
2069
|
|
|
2022
|
-
|
|
2070
|
+
`// this will group items by the last character of their names`
|
|
2023
2071
|
|
|
2024
|
-
|
|
2072
|
+
`return option.name.at(-1);`
|
|
2025
2073
|
|
|
2026
2074
|
`}}`
|
|
2027
2075
|
|
|
2028
2076
|
This `groupBy` prop must be provided or the groups will not render, even if all menu items have `section` properties (see below).
|
|
2029
2077
|
|
|
2030
|
-
|
|
2078
|
+
> **Warning:** To avoid duplicate headers, please make sure that the options are also sorted with the same dimension that they are grouped by. (See: Issue and example below)
|
|
2031
2079
|
|
|
2032
2080
|
**/styles.css**
|
|
2033
2081
|
|
|
@@ -2054,13 +2102,11 @@ h1 {
|
|
|
2054
2102
|
|
|
2055
2103
|
```json
|
|
2056
2104
|
{
|
|
2057
|
-
"include": [
|
|
2058
|
-
"./**/*"
|
|
2059
|
-
],
|
|
2105
|
+
"include": ["./**/*"],
|
|
2060
2106
|
"compilerOptions": {
|
|
2061
2107
|
"strict": true,
|
|
2062
2108
|
"esModuleInterop": true,
|
|
2063
|
-
"lib": [
|
|
2109
|
+
"lib": ["dom", "es2015"],
|
|
2064
2110
|
"jsx": "react-jsx"
|
|
2065
2111
|
}
|
|
2066
2112
|
}
|
|
@@ -2070,7 +2116,7 @@ h1 {
|
|
|
2070
2116
|
|
|
2071
2117
|
```tsx
|
|
2072
2118
|
// Dropdown with grouped sections
|
|
2073
|
-
|
|
2119
|
+
|
|
2074
2120
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
2075
2121
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
2076
2122
|
import "./styles.css";
|
|
@@ -2078,34 +2124,34 @@ import "./styles.css";
|
|
|
2078
2124
|
const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
2079
2125
|
{
|
|
2080
2126
|
name: "Menu item A.1",
|
|
2081
|
-
section: "Section A"
|
|
2127
|
+
section: "Section A",
|
|
2082
2128
|
},
|
|
2083
2129
|
{
|
|
2084
2130
|
name: "Menu item A.2",
|
|
2085
|
-
section: "Section A"
|
|
2131
|
+
section: "Section A",
|
|
2086
2132
|
},
|
|
2087
2133
|
{
|
|
2088
2134
|
name: "Menu item without a specified section",
|
|
2089
2135
|
},
|
|
2090
2136
|
{
|
|
2091
2137
|
name: "Menu item B.1",
|
|
2092
|
-
section: "Section B"
|
|
2138
|
+
section: "Section B",
|
|
2093
2139
|
},
|
|
2094
2140
|
{
|
|
2095
2141
|
name: "Menu item C.1",
|
|
2096
|
-
section: "Section C"
|
|
2142
|
+
section: "Section C",
|
|
2097
2143
|
},
|
|
2098
2144
|
{
|
|
2099
2145
|
name: "Menu item C.2",
|
|
2100
|
-
section: "Section C"
|
|
2146
|
+
section: "Section C",
|
|
2101
2147
|
},
|
|
2102
2148
|
{
|
|
2103
2149
|
name: "Menu item C.3",
|
|
2104
|
-
section: "Section C"
|
|
2150
|
+
section: "Section C",
|
|
2105
2151
|
},
|
|
2106
2152
|
{
|
|
2107
2153
|
name: "Menu item B.2",
|
|
2108
|
-
section: "Section B"
|
|
2154
|
+
section: "Section B",
|
|
2109
2155
|
},
|
|
2110
2156
|
];
|
|
2111
2157
|
|
|
@@ -2127,12 +2173,12 @@ const SORTED_ITEMS = [...MENU_ITEMS].sort((a, b) => {
|
|
|
2127
2173
|
});
|
|
2128
2174
|
|
|
2129
2175
|
function groupBy(option) {
|
|
2130
|
-
return option.name.at(-1)
|
|
2176
|
+
return option.name.at(-1);
|
|
2131
2177
|
}
|
|
2132
2178
|
|
|
2133
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
2179
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
2134
2180
|
|
|
2135
|
-
function handleClickAway(){}
|
|
2181
|
+
function handleClickAway() {}
|
|
2136
2182
|
|
|
2137
2183
|
function App() {
|
|
2138
2184
|
const ref = useRef(null);
|
|
@@ -2140,24 +2186,22 @@ function App() {
|
|
|
2140
2186
|
|
|
2141
2187
|
useEffect(() => {
|
|
2142
2188
|
if (ref.current) setOpen(true);
|
|
2143
|
-
}, [ref.current])
|
|
2144
|
-
|
|
2189
|
+
}, [ref.current]);
|
|
2190
|
+
|
|
2145
2191
|
return (
|
|
2146
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
2192
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
2147
2193
|
<div ref={ref} />
|
|
2148
|
-
{open &&
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
)
|
|
2160
|
-
}
|
|
2194
|
+
{open && (
|
|
2195
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
2196
|
+
<DropdownMenu
|
|
2197
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
2198
|
+
anchorEl={ref.current}
|
|
2199
|
+
groupBy={groupBy}
|
|
2200
|
+
onClickAway={handleClickAway}
|
|
2201
|
+
open
|
|
2202
|
+
options={SORTED_ITEMS}
|
|
2203
|
+
/>
|
|
2204
|
+
)}
|
|
2161
2205
|
</div>
|
|
2162
2206
|
);
|
|
2163
2207
|
}
|
|
@@ -2202,13 +2246,12 @@ root.render(
|
|
|
2202
2246
|
<RootApp />
|
|
2203
2247
|
</React.StrictMode>
|
|
2204
2248
|
);
|
|
2205
|
-
|
|
2206
2249
|
```
|
|
2207
2250
|
|
|
2208
2251
|
**/public/index.html**
|
|
2209
2252
|
|
|
2210
2253
|
```html
|
|
2211
|
-
<!
|
|
2254
|
+
<!doctype html>
|
|
2212
2255
|
<html lang="en">
|
|
2213
2256
|
<head>
|
|
2214
2257
|
<meta charset="UTF-8" />
|
|
@@ -2229,26 +2272,37 @@ root.render(
|
|
|
2229
2272
|
<div id="root"></div>
|
|
2230
2273
|
</body>
|
|
2231
2274
|
</html>
|
|
2232
|
-
|
|
2233
2275
|
```
|
|
2234
2276
|
|
|
2235
2277
|
**/package.json**
|
|
2236
2278
|
|
|
2237
2279
|
```json
|
|
2238
|
-
{
|
|
2280
|
+
{
|
|
2281
|
+
"dependencies": {
|
|
2282
|
+
"react": "^18.0.0",
|
|
2283
|
+
"react-dom": "^18.0.0",
|
|
2284
|
+
"react-scripts": "^4.0.0"
|
|
2285
|
+
},
|
|
2286
|
+
"devDependencies": {
|
|
2287
|
+
"@types/react": "^18.0.0",
|
|
2288
|
+
"@types/react-dom": "^18.0.0",
|
|
2289
|
+
"typescript": "^4.0.0"
|
|
2290
|
+
},
|
|
2291
|
+
"main": "/index.tsx"
|
|
2292
|
+
}
|
|
2239
2293
|
```
|
|
2240
2294
|
|
|
2241
2295
|
---
|
|
2242
2296
|
|
|
2243
2297
|
#### DropdownMenu with menu items that have count, icon, and / or details
|
|
2244
2298
|
|
|
2245
|
-
Each `MenuItem` provided to `DropdownMenu` can optionally include `count`, `details` and `sdsIcon` properties.
|
|
2299
|
+
Each `MenuItem` provided to `DropdownMenu` can optionally include `count`, `details` and `sdsIcon` properties.
|
|
2246
2300
|
|
|
2247
2301
|
The `count` property takes a number which is displayed to the right of the menu item text, with built-in spacing to its left (to prevent the menu item's text from running into it).
|
|
2248
2302
|
|
|
2249
2303
|
Add a text string to the `details` property to display text below the menu item’s main text.
|
|
2250
2304
|
|
|
2251
|
-
`sdsIcon` can be passed the name of any icon in the SDS codebase and it will automatically render the icon to the left of the menu item’s text; if an invalid name is passed, the menu item will render the same as if no icon were passed to it.
|
|
2305
|
+
`sdsIcon` can be passed the name of any icon in the SDS codebase and it will automatically render the icon to the left of the menu item’s text; if an invalid name is passed, the menu item will render the same as if no icon were passed to it. The `sdsIconProps` prop can be added to a menu item with an icon to provide more specifics like a `className`or `color`.
|
|
2252
2306
|
|
|
2253
2307
|
**/styles.css**
|
|
2254
2308
|
|
|
@@ -2275,13 +2329,11 @@ h1 {
|
|
|
2275
2329
|
|
|
2276
2330
|
```json
|
|
2277
2331
|
{
|
|
2278
|
-
"include": [
|
|
2279
|
-
"./**/*"
|
|
2280
|
-
],
|
|
2332
|
+
"include": ["./**/*"],
|
|
2281
2333
|
"compilerOptions": {
|
|
2282
2334
|
"strict": true,
|
|
2283
2335
|
"esModuleInterop": true,
|
|
2284
|
-
"lib": [
|
|
2336
|
+
"lib": ["dom", "es2015"],
|
|
2285
2337
|
"jsx": "react-jsx"
|
|
2286
2338
|
}
|
|
2287
2339
|
}
|
|
@@ -2291,7 +2343,7 @@ h1 {
|
|
|
2291
2343
|
|
|
2292
2344
|
```tsx
|
|
2293
2345
|
// Dropdown with grouped sections
|
|
2294
|
-
|
|
2346
|
+
|
|
2295
2347
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
2296
2348
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
2297
2349
|
import "./styles.css";
|
|
@@ -2299,11 +2351,11 @@ import "./styles.css";
|
|
|
2299
2351
|
const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
2300
2352
|
{
|
|
2301
2353
|
name: "Menu item with count",
|
|
2302
|
-
count: 3
|
|
2354
|
+
count: 3,
|
|
2303
2355
|
},
|
|
2304
2356
|
{
|
|
2305
2357
|
name: "Menu item with details",
|
|
2306
|
-
details: "Details"
|
|
2358
|
+
details: "Details",
|
|
2307
2359
|
},
|
|
2308
2360
|
{
|
|
2309
2361
|
name: "Menu item with icon",
|
|
@@ -2325,9 +2377,9 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
2325
2377
|
},
|
|
2326
2378
|
];
|
|
2327
2379
|
|
|
2328
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
2380
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
2329
2381
|
|
|
2330
|
-
function handleClickAway(){}
|
|
2382
|
+
function handleClickAway() {}
|
|
2331
2383
|
|
|
2332
2384
|
function App() {
|
|
2333
2385
|
const ref = useRef(null);
|
|
@@ -2335,26 +2387,24 @@ function App() {
|
|
|
2335
2387
|
|
|
2336
2388
|
useEffect(() => {
|
|
2337
2389
|
if (ref.current) setOpen(true);
|
|
2338
|
-
}, [ref.current])
|
|
2339
|
-
|
|
2390
|
+
}, [ref.current]);
|
|
2391
|
+
|
|
2340
2392
|
return (
|
|
2341
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
2393
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
2342
2394
|
<div ref={ref} />
|
|
2343
|
-
{open &&
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
)
|
|
2357
|
-
}
|
|
2395
|
+
{open && (
|
|
2396
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
2397
|
+
<DropdownMenu
|
|
2398
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
2399
|
+
anchorEl={ref.current}
|
|
2400
|
+
groupBy={(option: DefaultDropdownMenuOption) => {
|
|
2401
|
+
return option.section as string;
|
|
2402
|
+
}}
|
|
2403
|
+
onClickAway={handleClickAway}
|
|
2404
|
+
open
|
|
2405
|
+
options={MENU_ITEMS}
|
|
2406
|
+
/>
|
|
2407
|
+
)}
|
|
2358
2408
|
</div>
|
|
2359
2409
|
);
|
|
2360
2410
|
}
|
|
@@ -2399,13 +2449,12 @@ root.render(
|
|
|
2399
2449
|
<RootApp />
|
|
2400
2450
|
</React.StrictMode>
|
|
2401
2451
|
);
|
|
2402
|
-
|
|
2403
2452
|
```
|
|
2404
2453
|
|
|
2405
2454
|
**/public/index.html**
|
|
2406
2455
|
|
|
2407
2456
|
```html
|
|
2408
|
-
<!
|
|
2457
|
+
<!doctype html>
|
|
2409
2458
|
<html lang="en">
|
|
2410
2459
|
<head>
|
|
2411
2460
|
<meta charset="UTF-8" />
|
|
@@ -2426,13 +2475,24 @@ root.render(
|
|
|
2426
2475
|
<div id="root"></div>
|
|
2427
2476
|
</body>
|
|
2428
2477
|
</html>
|
|
2429
|
-
|
|
2430
2478
|
```
|
|
2431
2479
|
|
|
2432
2480
|
**/package.json**
|
|
2433
2481
|
|
|
2434
2482
|
```json
|
|
2435
|
-
{
|
|
2483
|
+
{
|
|
2484
|
+
"dependencies": {
|
|
2485
|
+
"react": "^18.0.0",
|
|
2486
|
+
"react-dom": "^18.0.0",
|
|
2487
|
+
"react-scripts": "^4.0.0"
|
|
2488
|
+
},
|
|
2489
|
+
"devDependencies": {
|
|
2490
|
+
"@types/react": "^18.0.0",
|
|
2491
|
+
"@types/react-dom": "^18.0.0",
|
|
2492
|
+
"typescript": "^4.0.0"
|
|
2493
|
+
},
|
|
2494
|
+
"main": "/index.tsx"
|
|
2495
|
+
}
|
|
2436
2496
|
```
|
|
2437
2497
|
|
|
2438
2498
|
---
|
|
@@ -2445,7 +2505,7 @@ Any existing SDS component (must be imported) can be provided to the menu item's
|
|
|
2445
2505
|
|
|
2446
2506
|
These custom menu items can optionally be assigned metadata just like regular menu items, including `section`, `count`, and `sdsIcon` and `sdsIconProps`.
|
|
2447
2507
|
|
|
2448
|
-
|
|
2508
|
+
> **Warning:** Currently, there is a bug preventing the `details` property from rendering when used in combination with a custom component in place of a menu item; see issue #522 for _details_ (pun intended!).
|
|
2449
2509
|
|
|
2450
2510
|
**/styles.css**
|
|
2451
2511
|
|
|
@@ -2472,13 +2532,11 @@ h1 {
|
|
|
2472
2532
|
|
|
2473
2533
|
```json
|
|
2474
2534
|
{
|
|
2475
|
-
"include": [
|
|
2476
|
-
"./**/*"
|
|
2477
|
-
],
|
|
2535
|
+
"include": ["./**/*"],
|
|
2478
2536
|
"compilerOptions": {
|
|
2479
2537
|
"strict": true,
|
|
2480
2538
|
"esModuleInterop": true,
|
|
2481
|
-
"lib": [
|
|
2539
|
+
"lib": ["dom", "es2015"],
|
|
2482
2540
|
"jsx": "react-jsx"
|
|
2483
2541
|
}
|
|
2484
2542
|
}
|
|
@@ -2488,32 +2546,29 @@ h1 {
|
|
|
2488
2546
|
|
|
2489
2547
|
```tsx
|
|
2490
2548
|
// DropdownMenu with components in place of menu items
|
|
2491
|
-
|
|
2549
|
+
|
|
2492
2550
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
2493
|
-
import {
|
|
2551
|
+
import {
|
|
2552
|
+
DropdownMenu,
|
|
2553
|
+
DefaultDropdownMenuOption,
|
|
2554
|
+
Tag,
|
|
2555
|
+
Button,
|
|
2556
|
+
ButtonIcon,
|
|
2557
|
+
} from "@czi-sds/components";
|
|
2494
2558
|
import "./styles.css";
|
|
2495
2559
|
|
|
2496
2560
|
const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
2497
2561
|
{
|
|
2498
2562
|
component: (
|
|
2499
|
-
<Button
|
|
2500
|
-
sdsStyle="square"
|
|
2501
|
-
sdsType="primary"
|
|
2502
|
-
>
|
|
2563
|
+
<Button sdsStyle="square" sdsType="primary">
|
|
2503
2564
|
Button
|
|
2504
2565
|
</Button>
|
|
2505
2566
|
),
|
|
2506
2567
|
name: "Button component",
|
|
2507
|
-
section: "Button component"
|
|
2568
|
+
section: "Button component",
|
|
2508
2569
|
},
|
|
2509
2570
|
{
|
|
2510
|
-
component:
|
|
2511
|
-
<ButtonIcon
|
|
2512
|
-
sdsIcon="Copy"
|
|
2513
|
-
sdsSize="large"
|
|
2514
|
-
sdsType="primary"
|
|
2515
|
-
/>
|
|
2516
|
-
),
|
|
2571
|
+
component: <ButtonIcon sdsIcon="Copy" sdsSize="large" sdsType="primary" />,
|
|
2517
2572
|
name: "ButtonIcon component",
|
|
2518
2573
|
section: "ButtonIcon component",
|
|
2519
2574
|
},
|
|
@@ -2545,12 +2600,7 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
2545
2600
|
},
|
|
2546
2601
|
{
|
|
2547
2602
|
component: (
|
|
2548
|
-
<Tag
|
|
2549
|
-
label="Tag"
|
|
2550
|
-
sdsStyle="rounded"
|
|
2551
|
-
sdsType="secondary"
|
|
2552
|
-
color="neutral"
|
|
2553
|
-
/>
|
|
2603
|
+
<Tag label="Tag" sdsStyle="rounded" sdsType="secondary" color="neutral" />
|
|
2554
2604
|
),
|
|
2555
2605
|
name: "Button component",
|
|
2556
2606
|
section: "Component with count and icon",
|
|
@@ -2559,9 +2609,9 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
2559
2609
|
},
|
|
2560
2610
|
];
|
|
2561
2611
|
|
|
2562
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
2612
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
2563
2613
|
|
|
2564
|
-
function handleClickAway(){}
|
|
2614
|
+
function handleClickAway() {}
|
|
2565
2615
|
|
|
2566
2616
|
function App() {
|
|
2567
2617
|
const ref = useRef(null);
|
|
@@ -2569,26 +2619,24 @@ function App() {
|
|
|
2569
2619
|
|
|
2570
2620
|
useEffect(() => {
|
|
2571
2621
|
if (ref.current) setOpen(true);
|
|
2572
|
-
}, [ref.current])
|
|
2573
|
-
|
|
2622
|
+
}, [ref.current]);
|
|
2623
|
+
|
|
2574
2624
|
return (
|
|
2575
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
2625
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
2576
2626
|
<div ref={ref} />
|
|
2577
|
-
{open &&
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
)
|
|
2591
|
-
}
|
|
2627
|
+
{open && (
|
|
2628
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
2629
|
+
<DropdownMenu
|
|
2630
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
2631
|
+
anchorEl={ref.current}
|
|
2632
|
+
groupBy={(option: DefaultDropdownMenuOption) => {
|
|
2633
|
+
return option.section;
|
|
2634
|
+
}}
|
|
2635
|
+
onClickAway={handleClickAway}
|
|
2636
|
+
open
|
|
2637
|
+
options={MENU_ITEMS}
|
|
2638
|
+
/>
|
|
2639
|
+
)}
|
|
2592
2640
|
</div>
|
|
2593
2641
|
);
|
|
2594
2642
|
}
|
|
@@ -2633,13 +2681,12 @@ root.render(
|
|
|
2633
2681
|
<RootApp />
|
|
2634
2682
|
</React.StrictMode>
|
|
2635
2683
|
);
|
|
2636
|
-
|
|
2637
2684
|
```
|
|
2638
2685
|
|
|
2639
2686
|
**/public/index.html**
|
|
2640
2687
|
|
|
2641
2688
|
```html
|
|
2642
|
-
<!
|
|
2689
|
+
<!doctype html>
|
|
2643
2690
|
<html lang="en">
|
|
2644
2691
|
<head>
|
|
2645
2692
|
<meta charset="UTF-8" />
|
|
@@ -2660,13 +2707,24 @@ root.render(
|
|
|
2660
2707
|
<div id="root"></div>
|
|
2661
2708
|
</body>
|
|
2662
2709
|
</html>
|
|
2663
|
-
|
|
2664
2710
|
```
|
|
2665
2711
|
|
|
2666
2712
|
**/package.json**
|
|
2667
2713
|
|
|
2668
2714
|
```json
|
|
2669
|
-
{
|
|
2715
|
+
{
|
|
2716
|
+
"dependencies": {
|
|
2717
|
+
"react": "^18.0.0",
|
|
2718
|
+
"react-dom": "^18.0.0",
|
|
2719
|
+
"react-scripts": "^4.0.0"
|
|
2720
|
+
},
|
|
2721
|
+
"devDependencies": {
|
|
2722
|
+
"@types/react": "^18.0.0",
|
|
2723
|
+
"@types/react-dom": "^18.0.0",
|
|
2724
|
+
"typescript": "^4.0.0"
|
|
2725
|
+
},
|
|
2726
|
+
"main": "/index.tsx"
|
|
2727
|
+
}
|
|
2670
2728
|
```
|
|
2671
2729
|
|
|
2672
2730
|
---
|
|
@@ -2683,16 +2741,16 @@ The component's source code in the SDS codebase can be found here.
|
|
|
2683
2741
|
|
|
2684
2742
|
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
2685
2743
|
|
|
2686
|
-
| Name
|
|
2687
|
-
|
|
|
2688
|
-
| `column`
|
|
2689
|
-
| `children`
|
|
2690
|
-
| `disabled`
|
|
2691
|
-
| `isMultiSelect` | `bool`
|
|
2692
|
-
| `sdsIcon`
|
|
2693
|
-
| `sdsIconProps`
|
|
2694
|
-
| `sdsStyle`
|
|
2695
|
-
| `selected`
|
|
2744
|
+
| Name | Type | Default | Description |
|
|
2745
|
+
| --------------- | ----------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
2746
|
+
| `column` | `string` | `-` | The `column` prop determines the content displayed in the right column of the menu item. This content can be customized to provide additional information or context for the menu item. |
|
|
2747
|
+
| `children` | `node` | `-` | Main content of the MenuItem. |
|
|
2748
|
+
| `disabled` | `bool` | `false` | When set to `true`, the disabled prop indicates that the menu item is disabled and not interactable. |
|
|
2749
|
+
| `isMultiSelect` | `bool` | `false` | When `true`, designates that the menu item supports multi-select functionality. |
|
|
2750
|
+
| `sdsIcon` | `func` | `-` | Allows you to provide a custom SDS icon component to be displayed within the menu item. |
|
|
2751
|
+
| `sdsIconProps` | `func` | `-` | Enables you to pass additional props to customize the SDS icon within the menu item. |
|
|
2752
|
+
| `sdsStyle` | `"determinate"` ` | "indeterminate"` | `"determinate"` | Determines the style of the menu item, whether it is `determinate` or `indeterminate`. |
|
|
2753
|
+
| `selected` | `bool` | `false` | When set to `true`, the `selected` prop signifies that the menu item is currently selected. |
|
|
2696
2754
|
|
|
2697
2755
|
### Code Examples
|
|
2698
2756
|
|
|
@@ -2725,13 +2783,11 @@ h1 {
|
|
|
2725
2783
|
|
|
2726
2784
|
```json
|
|
2727
2785
|
{
|
|
2728
|
-
"include": [
|
|
2729
|
-
"./**/*"
|
|
2730
|
-
],
|
|
2786
|
+
"include": ["./**/*"],
|
|
2731
2787
|
"compilerOptions": {
|
|
2732
2788
|
"strict": true,
|
|
2733
2789
|
"esModuleInterop": true,
|
|
2734
|
-
"lib": [
|
|
2790
|
+
"lib": ["dom", "es2015"],
|
|
2735
2791
|
"jsx": "react-jsx"
|
|
2736
2792
|
}
|
|
2737
2793
|
}
|
|
@@ -2746,9 +2802,7 @@ import "./styles.css";
|
|
|
2746
2802
|
function App() {
|
|
2747
2803
|
return (
|
|
2748
2804
|
<div className="app">
|
|
2749
|
-
<MenuItem>
|
|
2750
|
-
MenuItem 1
|
|
2751
|
-
</MenuItem>
|
|
2805
|
+
<MenuItem>MenuItem 1</MenuItem>
|
|
2752
2806
|
</div>
|
|
2753
2807
|
);
|
|
2754
2808
|
}
|
|
@@ -2793,13 +2847,12 @@ root.render(
|
|
|
2793
2847
|
<RootApp />
|
|
2794
2848
|
</React.StrictMode>
|
|
2795
2849
|
);
|
|
2796
|
-
|
|
2797
2850
|
```
|
|
2798
2851
|
|
|
2799
2852
|
**/public/index.html**
|
|
2800
2853
|
|
|
2801
2854
|
```html
|
|
2802
|
-
<!
|
|
2855
|
+
<!doctype html>
|
|
2803
2856
|
<html lang="en">
|
|
2804
2857
|
<head>
|
|
2805
2858
|
<meta charset="UTF-8" />
|
|
@@ -2820,13 +2873,24 @@ root.render(
|
|
|
2820
2873
|
<div id="root"></div>
|
|
2821
2874
|
</body>
|
|
2822
2875
|
</html>
|
|
2823
|
-
|
|
2824
2876
|
```
|
|
2825
2877
|
|
|
2826
2878
|
**/package.json**
|
|
2827
2879
|
|
|
2828
2880
|
```json
|
|
2829
|
-
{
|
|
2881
|
+
{
|
|
2882
|
+
"dependencies": {
|
|
2883
|
+
"react": "^18.0.0",
|
|
2884
|
+
"react-dom": "^18.0.0",
|
|
2885
|
+
"react-scripts": "^4.0.0"
|
|
2886
|
+
},
|
|
2887
|
+
"devDependencies": {
|
|
2888
|
+
"@types/react": "^18.0.0",
|
|
2889
|
+
"@types/react-dom": "^18.0.0",
|
|
2890
|
+
"typescript": "^4.0.0"
|
|
2891
|
+
},
|
|
2892
|
+
"main": "/index.tsx"
|
|
2893
|
+
}
|
|
2830
2894
|
```
|
|
2831
2895
|
|
|
2832
2896
|
---
|
|
@@ -2835,7 +2899,7 @@ root.render(
|
|
|
2835
2899
|
|
|
2836
2900
|
This example showcases a multi-select `MenuItem` component featuring an SDS `Icon` and a distinct column value.
|
|
2837
2901
|
|
|
2838
|
-
|
|
2902
|
+
> **SDS Tip:** MenuItem exclusively accepts SDS Icons in `xs` and `s` sizes. To explore a comprehensive list of SDS icons and their available sizes, refer to the IconBank page within Storybook.
|
|
2839
2903
|
|
|
2840
2904
|
**/styles.css**
|
|
2841
2905
|
|
|
@@ -2862,13 +2926,11 @@ h1 {
|
|
|
2862
2926
|
|
|
2863
2927
|
```json
|
|
2864
2928
|
{
|
|
2865
|
-
"include": [
|
|
2866
|
-
"./**/*"
|
|
2867
|
-
],
|
|
2929
|
+
"include": ["./**/*"],
|
|
2868
2930
|
"compilerOptions": {
|
|
2869
2931
|
"strict": true,
|
|
2870
2932
|
"esModuleInterop": true,
|
|
2871
|
-
"lib": [
|
|
2933
|
+
"lib": ["dom", "es2015"],
|
|
2872
2934
|
"jsx": "react-jsx"
|
|
2873
2935
|
}
|
|
2874
2936
|
}
|
|
@@ -2885,18 +2947,18 @@ function App() {
|
|
|
2885
2947
|
const [selected, setSelected] = useState(false);
|
|
2886
2948
|
|
|
2887
2949
|
const handleClick = () => {
|
|
2888
|
-
setSelected(prev => !prev);
|
|
2950
|
+
setSelected((prev) => !prev);
|
|
2889
2951
|
};
|
|
2890
|
-
|
|
2952
|
+
|
|
2891
2953
|
return (
|
|
2892
2954
|
<div className="app">
|
|
2893
|
-
<MenuItem
|
|
2955
|
+
<MenuItem
|
|
2894
2956
|
isMultiSelect
|
|
2895
2957
|
column="Column Value"
|
|
2896
2958
|
sdsIcon="gear"
|
|
2897
2959
|
count={3}
|
|
2898
2960
|
sdsIconProps={{
|
|
2899
|
-
color: "beta"
|
|
2961
|
+
color: "beta",
|
|
2900
2962
|
}}
|
|
2901
2963
|
selected={selected}
|
|
2902
2964
|
onClick={handleClick}
|
|
@@ -2947,13 +3009,12 @@ root.render(
|
|
|
2947
3009
|
<RootApp />
|
|
2948
3010
|
</React.StrictMode>
|
|
2949
3011
|
);
|
|
2950
|
-
|
|
2951
3012
|
```
|
|
2952
3013
|
|
|
2953
3014
|
**/public/index.html**
|
|
2954
3015
|
|
|
2955
3016
|
```html
|
|
2956
|
-
<!
|
|
3017
|
+
<!doctype html>
|
|
2957
3018
|
<html lang="en">
|
|
2958
3019
|
<head>
|
|
2959
3020
|
<meta charset="UTF-8" />
|
|
@@ -2974,13 +3035,24 @@ root.render(
|
|
|
2974
3035
|
<div id="root"></div>
|
|
2975
3036
|
</body>
|
|
2976
3037
|
</html>
|
|
2977
|
-
|
|
2978
3038
|
```
|
|
2979
3039
|
|
|
2980
3040
|
**/package.json**
|
|
2981
3041
|
|
|
2982
3042
|
```json
|
|
2983
|
-
{
|
|
3043
|
+
{
|
|
3044
|
+
"dependencies": {
|
|
3045
|
+
"react": "^18.0.0",
|
|
3046
|
+
"react-dom": "^18.0.0",
|
|
3047
|
+
"react-scripts": "^4.0.0"
|
|
3048
|
+
},
|
|
3049
|
+
"devDependencies": {
|
|
3050
|
+
"@types/react": "^18.0.0",
|
|
3051
|
+
"@types/react-dom": "^18.0.0",
|
|
3052
|
+
"typescript": "^4.0.0"
|
|
3053
|
+
},
|
|
3054
|
+
"main": "/index.tsx"
|
|
3055
|
+
}
|
|
2984
3056
|
```
|
|
2985
3057
|
|
|
2986
3058
|
---
|
|
@@ -2989,8 +3061,8 @@ root.render(
|
|
|
2989
3061
|
|
|
2990
3062
|
## DropdownMenu Recipes
|
|
2991
3063
|
|
|
2992
|
-
| These component recipes show a few of the more complex approaches available for customizing Dropdown Menus.
|
|
2993
|
-
|
|
|
3064
|
+
| These component recipes show a few of the more complex approaches available for customizing Dropdown Menus. | | **Jump to recipe:** DropdownMenu with customized `isOptionEqualToValue` DropdownMenu with customized `onChange` DropdownMenu with custom `PopperBaseProps` DropdownMenu with custom `Popper` component |
|
|
3065
|
+
| ----------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
2994
3066
|
|
|
2995
3067
|
#### **DropdownMenu with customized** **`isOptionEqualToValue`**
|
|
2996
3068
|
|
|
@@ -3023,13 +3095,11 @@ h1 {
|
|
|
3023
3095
|
|
|
3024
3096
|
```json
|
|
3025
3097
|
{
|
|
3026
|
-
"include": [
|
|
3027
|
-
"./**/*"
|
|
3028
|
-
],
|
|
3098
|
+
"include": ["./**/*"],
|
|
3029
3099
|
"compilerOptions": {
|
|
3030
3100
|
"strict": true,
|
|
3031
3101
|
"esModuleInterop": true,
|
|
3032
|
-
"lib": [
|
|
3102
|
+
"lib": ["dom", "es2015"],
|
|
3033
3103
|
"jsx": "react-jsx"
|
|
3034
3104
|
}
|
|
3035
3105
|
}
|
|
@@ -3039,7 +3109,7 @@ h1 {
|
|
|
3039
3109
|
|
|
3040
3110
|
```tsx
|
|
3041
3111
|
// DropdownMenu with customized `isOptionEqualToValue`
|
|
3042
|
-
|
|
3112
|
+
|
|
3043
3113
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
3044
3114
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
3045
3115
|
import "./styles.css";
|
|
@@ -3049,25 +3119,25 @@ function optionIdEqualToValueId(option, value) {
|
|
|
3049
3119
|
}
|
|
3050
3120
|
|
|
3051
3121
|
const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3122
|
+
{
|
|
3123
|
+
name: "Menu item 1",
|
|
3124
|
+
id: "one",
|
|
3125
|
+
},
|
|
3126
|
+
{
|
|
3127
|
+
name: "Menu item 2",
|
|
3128
|
+
id: "two",
|
|
3129
|
+
},
|
|
3130
|
+
{
|
|
3131
|
+
name: "Menu item 3",
|
|
3132
|
+
id: "three",
|
|
3133
|
+
},
|
|
3134
|
+
{
|
|
3135
|
+
name: "Longer menu item than the others",
|
|
3136
|
+
id: "four",
|
|
3137
|
+
},
|
|
3138
|
+
];
|
|
3069
3139
|
|
|
3070
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
3140
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
3071
3141
|
|
|
3072
3142
|
function handleClickAway() {}
|
|
3073
3143
|
|
|
@@ -3077,24 +3147,22 @@ function App() {
|
|
|
3077
3147
|
|
|
3078
3148
|
useEffect(() => {
|
|
3079
3149
|
if (ref.current) setOpen(true);
|
|
3080
|
-
}, [ref.current])
|
|
3081
|
-
|
|
3150
|
+
}, [ref.current]);
|
|
3151
|
+
|
|
3082
3152
|
return (
|
|
3083
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
3153
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
3084
3154
|
<div ref={ref} />
|
|
3085
|
-
{open &&
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
)
|
|
3097
|
-
}
|
|
3155
|
+
{open && (
|
|
3156
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
3157
|
+
<DropdownMenu
|
|
3158
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
3159
|
+
anchorEl={ref.current}
|
|
3160
|
+
isOptionEqualToValue={optionIdEqualToValueId}
|
|
3161
|
+
onClickAway={handleClickAway}
|
|
3162
|
+
open
|
|
3163
|
+
options={MENU_ITEMS}
|
|
3164
|
+
/>
|
|
3165
|
+
)}
|
|
3098
3166
|
</div>
|
|
3099
3167
|
);
|
|
3100
3168
|
}
|
|
@@ -3139,13 +3207,12 @@ root.render(
|
|
|
3139
3207
|
<RootApp />
|
|
3140
3208
|
</React.StrictMode>
|
|
3141
3209
|
);
|
|
3142
|
-
|
|
3143
3210
|
```
|
|
3144
3211
|
|
|
3145
3212
|
**/public/index.html**
|
|
3146
3213
|
|
|
3147
3214
|
```html
|
|
3148
|
-
<!
|
|
3215
|
+
<!doctype html>
|
|
3149
3216
|
<html lang="en">
|
|
3150
3217
|
<head>
|
|
3151
3218
|
<meta charset="UTF-8" />
|
|
@@ -3166,22 +3233,33 @@ root.render(
|
|
|
3166
3233
|
<div id="root"></div>
|
|
3167
3234
|
</body>
|
|
3168
3235
|
</html>
|
|
3169
|
-
|
|
3170
3236
|
```
|
|
3171
3237
|
|
|
3172
3238
|
**/package.json**
|
|
3173
3239
|
|
|
3174
3240
|
```json
|
|
3175
|
-
{
|
|
3241
|
+
{
|
|
3242
|
+
"dependencies": {
|
|
3243
|
+
"react": "^18.0.0",
|
|
3244
|
+
"react-dom": "^18.0.0",
|
|
3245
|
+
"react-scripts": "^4.0.0"
|
|
3246
|
+
},
|
|
3247
|
+
"devDependencies": {
|
|
3248
|
+
"@types/react": "^18.0.0",
|
|
3249
|
+
"@types/react-dom": "^18.0.0",
|
|
3250
|
+
"typescript": "^4.0.0"
|
|
3251
|
+
},
|
|
3252
|
+
"main": "/index.tsx"
|
|
3253
|
+
}
|
|
3176
3254
|
```
|
|
3177
3255
|
|
|
3178
3256
|
---
|
|
3179
3257
|
|
|
3180
3258
|
#### **DropdownMenu with customized** **`onChange`** **prop**
|
|
3181
3259
|
|
|
3182
|
-
The optional `onChange` prop specifies what happens when a new selection is made.
|
|
3260
|
+
The optional `onChange` prop specifies what happens when a new selection is made.
|
|
3183
3261
|
|
|
3184
|
-
In the example below, `onChange` has been modified such that making a new selection logs the `value`
|
|
3262
|
+
In the example below, `onChange` has been modified such that making a new selection logs the `value` and `reason` to the console.
|
|
3185
3263
|
|
|
3186
3264
|
This is a MUI prop; learn more in the Autocomplete API.
|
|
3187
3265
|
|
|
@@ -3210,13 +3288,11 @@ h1 {
|
|
|
3210
3288
|
|
|
3211
3289
|
```json
|
|
3212
3290
|
{
|
|
3213
|
-
"include": [
|
|
3214
|
-
"./**/*"
|
|
3215
|
-
],
|
|
3291
|
+
"include": ["./**/*"],
|
|
3216
3292
|
"compilerOptions": {
|
|
3217
3293
|
"strict": true,
|
|
3218
3294
|
"esModuleInterop": true,
|
|
3219
|
-
"lib": [
|
|
3295
|
+
"lib": ["dom", "es2015"],
|
|
3220
3296
|
"jsx": "react-jsx"
|
|
3221
3297
|
}
|
|
3222
3298
|
}
|
|
@@ -3226,7 +3302,7 @@ h1 {
|
|
|
3226
3302
|
|
|
3227
3303
|
```tsx
|
|
3228
3304
|
// DropdownMenu with customized `onInputChange`
|
|
3229
|
-
|
|
3305
|
+
|
|
3230
3306
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
3231
3307
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
3232
3308
|
import "./styles.css";
|
|
@@ -3246,49 +3322,48 @@ const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
|
3246
3322
|
},
|
|
3247
3323
|
];
|
|
3248
3324
|
|
|
3249
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
3325
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
3250
3326
|
|
|
3251
|
-
function handleClickAway() {}
|
|
3327
|
+
function handleClickAway() {}
|
|
3252
3328
|
|
|
3253
|
-
function Message({message}) {
|
|
3329
|
+
function Message({ message }) {
|
|
3254
3330
|
return (
|
|
3255
|
-
<div
|
|
3331
|
+
<div
|
|
3332
|
+
style={{ position: "absolute", top: "170px", fontFamily: "sans-serif" }}
|
|
3333
|
+
>
|
|
3256
3334
|
<p>{JSON.stringify(message)}</p>
|
|
3257
3335
|
</div>
|
|
3258
3336
|
);
|
|
3259
3337
|
}
|
|
3260
3338
|
|
|
3261
3339
|
function App() {
|
|
3262
|
-
|
|
3263
3340
|
const [message, setMessage] = useState();
|
|
3264
|
-
|
|
3265
|
-
const ref = useRef(null);
|
|
3341
|
+
|
|
3342
|
+
const ref = useRef(null);
|
|
3266
3343
|
const [open, setOpen] = useState(false);
|
|
3267
3344
|
|
|
3268
3345
|
useEffect(() => {
|
|
3269
3346
|
if (ref.current) setOpen(true);
|
|
3270
|
-
}, [ref.current])
|
|
3271
|
-
|
|
3347
|
+
}, [ref.current]);
|
|
3348
|
+
|
|
3272
3349
|
return (
|
|
3273
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
3350
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
3274
3351
|
<div ref={ref} />
|
|
3275
|
-
{open &&
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
)
|
|
3291
|
-
}
|
|
3352
|
+
{open && (
|
|
3353
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
3354
|
+
<>
|
|
3355
|
+
<DropdownMenu
|
|
3356
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
3357
|
+
anchorEl={ref.current}
|
|
3358
|
+
keepSearchOnSelect
|
|
3359
|
+
onClickAway={handleClickAway}
|
|
3360
|
+
onChange={(_, value, reason) => setMessage({ value, reason })}
|
|
3361
|
+
open
|
|
3362
|
+
options={MENU_ITEMS}
|
|
3363
|
+
/>
|
|
3364
|
+
<Message message={message} />
|
|
3365
|
+
</>
|
|
3366
|
+
)}
|
|
3292
3367
|
</div>
|
|
3293
3368
|
);
|
|
3294
3369
|
}
|
|
@@ -3333,13 +3408,12 @@ root.render(
|
|
|
3333
3408
|
<RootApp />
|
|
3334
3409
|
</React.StrictMode>
|
|
3335
3410
|
);
|
|
3336
|
-
|
|
3337
3411
|
```
|
|
3338
3412
|
|
|
3339
3413
|
**/public/index.html**
|
|
3340
3414
|
|
|
3341
3415
|
```html
|
|
3342
|
-
<!
|
|
3416
|
+
<!doctype html>
|
|
3343
3417
|
<html lang="en">
|
|
3344
3418
|
<head>
|
|
3345
3419
|
<meta charset="UTF-8" />
|
|
@@ -3360,24 +3434,35 @@ root.render(
|
|
|
3360
3434
|
<div id="root"></div>
|
|
3361
3435
|
</body>
|
|
3362
3436
|
</html>
|
|
3363
|
-
|
|
3364
3437
|
```
|
|
3365
3438
|
|
|
3366
3439
|
**/package.json**
|
|
3367
3440
|
|
|
3368
3441
|
```json
|
|
3369
|
-
{
|
|
3442
|
+
{
|
|
3443
|
+
"dependencies": {
|
|
3444
|
+
"react": "^18.0.0",
|
|
3445
|
+
"react-dom": "^18.0.0",
|
|
3446
|
+
"react-scripts": "^4.0.0"
|
|
3447
|
+
},
|
|
3448
|
+
"devDependencies": {
|
|
3449
|
+
"@types/react": "^18.0.0",
|
|
3450
|
+
"@types/react-dom": "^18.0.0",
|
|
3451
|
+
"typescript": "^4.0.0"
|
|
3452
|
+
},
|
|
3453
|
+
"main": "/index.tsx"
|
|
3454
|
+
}
|
|
3370
3455
|
```
|
|
3371
3456
|
|
|
3372
3457
|
---
|
|
3373
3458
|
|
|
3374
3459
|
#### **DropdownMenu with custom** **`PopperBaseProps`**
|
|
3375
3460
|
|
|
3376
|
-
`PopperBaseProps` is an SDS-specific prop made for passing custom props to the `Popper` component, which is included as part of the `DropdownMenu` component.
|
|
3461
|
+
`PopperBaseProps` is an SDS-specific prop made for passing custom props to the `Popper` component, which is included as part of the `DropdownMenu` component.
|
|
3377
3462
|
|
|
3378
3463
|
The `Popper` component is part of MUI; learn more in the Popper documentation, and see all the props available to pass to it on the Popper API page.
|
|
3379
3464
|
|
|
3380
|
-
The example below passes the Popper a `className` prop to make some style changes (see the styles.css tab in the code window below) and additionally uses the `sx` prop to make more style changes (learn more on the MUI `sx`
|
|
3465
|
+
The example below passes the Popper a `className` prop to make some style changes (see the styles.css tab in the code window below) and additionally uses the `sx` prop to make more style changes (learn more on the MUI `sx` documentation page).
|
|
3381
3466
|
|
|
3382
3467
|
**/styles.css**
|
|
3383
3468
|
|
|
@@ -3404,13 +3489,11 @@ h1 {
|
|
|
3404
3489
|
|
|
3405
3490
|
```json
|
|
3406
3491
|
{
|
|
3407
|
-
"include": [
|
|
3408
|
-
"./**/*"
|
|
3409
|
-
],
|
|
3492
|
+
"include": ["./**/*"],
|
|
3410
3493
|
"compilerOptions": {
|
|
3411
3494
|
"strict": true,
|
|
3412
3495
|
"esModuleInterop": true,
|
|
3413
|
-
"lib": [
|
|
3496
|
+
"lib": ["dom", "es2015"],
|
|
3414
3497
|
"jsx": "react-jsx"
|
|
3415
3498
|
}
|
|
3416
3499
|
}
|
|
@@ -3420,35 +3503,35 @@ h1 {
|
|
|
3420
3503
|
|
|
3421
3504
|
```tsx
|
|
3422
3505
|
// DropdownMenu with custom `PopperBaseProps`
|
|
3423
|
-
|
|
3506
|
+
|
|
3424
3507
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
3425
3508
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
3426
3509
|
import "./styles.css";
|
|
3427
3510
|
|
|
3428
3511
|
const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3512
|
+
{
|
|
3513
|
+
name: "Menu item 1",
|
|
3514
|
+
},
|
|
3515
|
+
{
|
|
3516
|
+
name: "Menu item 2",
|
|
3517
|
+
},
|
|
3518
|
+
{
|
|
3519
|
+
name: "Menu item 3",
|
|
3520
|
+
},
|
|
3521
|
+
{
|
|
3522
|
+
name: "Longer menu item than the others",
|
|
3523
|
+
},
|
|
3524
|
+
];
|
|
3442
3525
|
|
|
3443
3526
|
const POPPER_BASE_PROPS = {
|
|
3444
3527
|
className: "popper",
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
popperOptions: { strategy: "absolute"},
|
|
3451
|
-
}
|
|
3528
|
+
sx: {
|
|
3529
|
+
width: 500,
|
|
3530
|
+
borderColor: "salmon",
|
|
3531
|
+
borderWidth: 10,
|
|
3532
|
+
},
|
|
3533
|
+
popperOptions: { strategy: "absolute" },
|
|
3534
|
+
};
|
|
3452
3535
|
|
|
3453
3536
|
function App() {
|
|
3454
3537
|
const ref = useRef(null);
|
|
@@ -3456,24 +3539,22 @@ function App() {
|
|
|
3456
3539
|
|
|
3457
3540
|
useEffect(() => {
|
|
3458
3541
|
if (ref.current) setOpen(true);
|
|
3459
|
-
}, [ref.current])
|
|
3460
|
-
|
|
3542
|
+
}, [ref.current]);
|
|
3543
|
+
|
|
3461
3544
|
return (
|
|
3462
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
3545
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
3463
3546
|
<div ref={ref} />
|
|
3464
|
-
{open &&
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
)
|
|
3476
|
-
}
|
|
3547
|
+
{open && (
|
|
3548
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
3549
|
+
<DropdownMenu
|
|
3550
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
3551
|
+
anchorEl={ref.current}
|
|
3552
|
+
onClickAway={function handleClickAway() {}}
|
|
3553
|
+
open
|
|
3554
|
+
options={MENU_ITEMS}
|
|
3555
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
3556
|
+
/>
|
|
3557
|
+
)}
|
|
3477
3558
|
</div>
|
|
3478
3559
|
);
|
|
3479
3560
|
}
|
|
@@ -3518,13 +3599,12 @@ root.render(
|
|
|
3518
3599
|
<RootApp />
|
|
3519
3600
|
</React.StrictMode>
|
|
3520
3601
|
);
|
|
3521
|
-
|
|
3522
3602
|
```
|
|
3523
3603
|
|
|
3524
3604
|
**/public/index.html**
|
|
3525
3605
|
|
|
3526
3606
|
```html
|
|
3527
|
-
<!
|
|
3607
|
+
<!doctype html>
|
|
3528
3608
|
<html lang="en">
|
|
3529
3609
|
<head>
|
|
3530
3610
|
<meta charset="UTF-8" />
|
|
@@ -3545,22 +3625,33 @@ root.render(
|
|
|
3545
3625
|
<div id="root"></div>
|
|
3546
3626
|
</body>
|
|
3547
3627
|
</html>
|
|
3548
|
-
|
|
3549
3628
|
```
|
|
3550
3629
|
|
|
3551
3630
|
**/package.json**
|
|
3552
3631
|
|
|
3553
3632
|
```json
|
|
3554
|
-
{
|
|
3633
|
+
{
|
|
3634
|
+
"dependencies": {
|
|
3635
|
+
"react": "^18.0.0",
|
|
3636
|
+
"react-dom": "^18.0.0",
|
|
3637
|
+
"react-scripts": "^4.0.0"
|
|
3638
|
+
},
|
|
3639
|
+
"devDependencies": {
|
|
3640
|
+
"@types/react": "^18.0.0",
|
|
3641
|
+
"@types/react-dom": "^18.0.0",
|
|
3642
|
+
"typescript": "^4.0.0"
|
|
3643
|
+
},
|
|
3644
|
+
"main": "/index.tsx"
|
|
3645
|
+
}
|
|
3555
3646
|
```
|
|
3556
3647
|
|
|
3557
3648
|
---
|
|
3558
3649
|
|
|
3559
3650
|
#### **DropdownMenu with custom Popper component**
|
|
3560
3651
|
|
|
3561
|
-
In addition to modifying the `Popper`'s
|
|
3652
|
+
In addition to modifying the `Popper`'s styles via `PopperBaseProps`, the styles for the `Popper` component can be overwritten more directly with `styled()`.
|
|
3562
3653
|
|
|
3563
|
-
To get all the default SDS styles used for `Popper`,
|
|
3654
|
+
To get all the default SDS styles used for `Popper`, first copy them into a custom-styled `Popper` (from within sci-components/packages/components/src/core/DropdownMenu/style.ts file). Then replace and / or follow up those styles with custom styles. The example below includes comments for each of these steps within `CustomPopper`.
|
|
3564
3655
|
|
|
3565
3656
|
**/styles.css**
|
|
3566
3657
|
|
|
@@ -3587,13 +3678,11 @@ h1 {
|
|
|
3587
3678
|
|
|
3588
3679
|
```json
|
|
3589
3680
|
{
|
|
3590
|
-
"include": [
|
|
3591
|
-
"./**/*"
|
|
3592
|
-
],
|
|
3681
|
+
"include": ["./**/*"],
|
|
3593
3682
|
"compilerOptions": {
|
|
3594
3683
|
"strict": true,
|
|
3595
3684
|
"esModuleInterop": true,
|
|
3596
|
-
"lib": [
|
|
3685
|
+
"lib": ["dom", "es2015"],
|
|
3597
3686
|
"jsx": "react-jsx"
|
|
3598
3687
|
}
|
|
3599
3688
|
}
|
|
@@ -3603,60 +3692,60 @@ h1 {
|
|
|
3603
3692
|
|
|
3604
3693
|
```tsx
|
|
3605
3694
|
// DropdownMenu with custom Popper component
|
|
3606
|
-
|
|
3695
|
+
|
|
3607
3696
|
import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
|
|
3608
3697
|
import { Popper, styled } from "@mui/material";
|
|
3609
3698
|
import { DropdownMenu, DefaultDropdownMenuOption } from "@czi-sds/components";
|
|
3610
3699
|
import "./styles.css";
|
|
3611
3700
|
|
|
3612
3701
|
const MENU_ITEMS: DefaultDropdownMenuOption[] = [
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3702
|
+
{
|
|
3703
|
+
name: "Menu item 1",
|
|
3704
|
+
},
|
|
3705
|
+
{
|
|
3706
|
+
name: "Menu item 2",
|
|
3707
|
+
},
|
|
3708
|
+
{
|
|
3709
|
+
name: "Menu item 3",
|
|
3710
|
+
},
|
|
3711
|
+
{
|
|
3712
|
+
name: "Longer menu item than the others",
|
|
3713
|
+
},
|
|
3714
|
+
];
|
|
3626
3715
|
|
|
3627
|
-
// Step 1/3: Copy existing base styles for the Popper component from
|
|
3716
|
+
// Step 1/3: Copy existing base styles for the Popper component from
|
|
3628
3717
|
// sci-components/packages/components/src/core/DropdownMenu/style.ts, ~lines 206-229:
|
|
3629
3718
|
const getBorders = ({ theme }: CommonThemeProps): Borders | null => {
|
|
3630
|
-
|
|
3719
|
+
return theme?.app?.borders || null;
|
|
3631
3720
|
};
|
|
3632
3721
|
|
|
3633
3722
|
const getCorners = ({ theme }: CommonThemeProps): Corners | null => {
|
|
3634
|
-
|
|
3723
|
+
return theme?.app?.corners || null;
|
|
3635
3724
|
};
|
|
3636
3725
|
|
|
3637
3726
|
const getShadows = ({ theme }: CommonThemeProps): Shadows | null => {
|
|
3638
|
-
|
|
3727
|
+
return theme?.app?.shadows || null;
|
|
3639
3728
|
};
|
|
3640
3729
|
|
|
3641
3730
|
const getSpaces = ({ theme }: CommonThemeProps): Spaces | null => {
|
|
3642
|
-
|
|
3731
|
+
return theme?.app?.spacing || null;
|
|
3643
3732
|
};
|
|
3644
3733
|
|
|
3645
3734
|
const CustomPopper = styled(Popper)`
|
|
3646
|
-
|
|
3735
|
+
.MuiAutocomplete-popperDisablePortal {
|
|
3647
3736
|
position: relative;
|
|
3648
3737
|
width: 100% !important;
|
|
3649
3738
|
box-shadow: none;
|
|
3650
3739
|
padding: 0;
|
|
3651
3740
|
border: none;
|
|
3652
3741
|
}
|
|
3653
|
-
|
|
3742
|
+
|
|
3654
3743
|
${(props) => {
|
|
3655
3744
|
const borders = getBorders(props);
|
|
3656
3745
|
const corners = getCorners(props);
|
|
3657
3746
|
const shadows = getShadows(props);
|
|
3658
3747
|
const spacings = getSpaces(props);
|
|
3659
|
-
|
|
3748
|
+
|
|
3660
3749
|
return `
|
|
3661
3750
|
background-color: white;
|
|
3662
3751
|
border: ${borders?.base?.divider};
|
|
@@ -3676,7 +3765,7 @@ const CustomPopper = styled(Popper)`
|
|
|
3676
3765
|
border-width: 15px !important;
|
|
3677
3766
|
`;
|
|
3678
3767
|
|
|
3679
|
-
const POPPER_BASE_PROPS = {popperOptions: { strategy: "absolute"}};
|
|
3768
|
+
const POPPER_BASE_PROPS = { popperOptions: { strategy: "absolute" } };
|
|
3680
3769
|
|
|
3681
3770
|
function App() {
|
|
3682
3771
|
const ref = useRef(null);
|
|
@@ -3684,25 +3773,23 @@ function App() {
|
|
|
3684
3773
|
|
|
3685
3774
|
useEffect(() => {
|
|
3686
3775
|
if (ref.current) setOpen(true);
|
|
3687
|
-
}, [ref.current])
|
|
3688
|
-
|
|
3776
|
+
}, [ref.current]);
|
|
3777
|
+
|
|
3689
3778
|
return (
|
|
3690
|
-
<div className="app" style={{paddingLeft: "10px"}}>
|
|
3779
|
+
<div className="app" style={{ paddingLeft: "10px" }}>
|
|
3691
3780
|
<div ref={ref} />
|
|
3692
|
-
{open &&
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
)
|
|
3705
|
-
}
|
|
3781
|
+
{open && (
|
|
3782
|
+
// 👇 Only pay attention to the props here, everything else is just Zeroheight glue code
|
|
3783
|
+
<DropdownMenu
|
|
3784
|
+
PopperBaseProps={POPPER_BASE_PROPS}
|
|
3785
|
+
anchorEl={ref.current}
|
|
3786
|
+
onClickAway={function handleClickAway() {}}
|
|
3787
|
+
open
|
|
3788
|
+
options={MENU_ITEMS}
|
|
3789
|
+
// Step 3/3: Pass the new CustomPopper to PopperComponent prop
|
|
3790
|
+
PopperComponent={CustomPopper}
|
|
3791
|
+
/>
|
|
3792
|
+
)}
|
|
3706
3793
|
</div>
|
|
3707
3794
|
);
|
|
3708
3795
|
}
|
|
@@ -3747,13 +3834,12 @@ root.render(
|
|
|
3747
3834
|
<RootApp />
|
|
3748
3835
|
</React.StrictMode>
|
|
3749
3836
|
);
|
|
3750
|
-
|
|
3751
3837
|
```
|
|
3752
3838
|
|
|
3753
3839
|
**/public/index.html**
|
|
3754
3840
|
|
|
3755
3841
|
```html
|
|
3756
|
-
<!
|
|
3842
|
+
<!doctype html>
|
|
3757
3843
|
<html lang="en">
|
|
3758
3844
|
<head>
|
|
3759
3845
|
<meta charset="UTF-8" />
|
|
@@ -3774,14 +3860,24 @@ root.render(
|
|
|
3774
3860
|
<div id="root"></div>
|
|
3775
3861
|
</body>
|
|
3776
3862
|
</html>
|
|
3777
|
-
|
|
3778
3863
|
```
|
|
3779
3864
|
|
|
3780
3865
|
**/package.json**
|
|
3781
3866
|
|
|
3782
3867
|
```json
|
|
3783
|
-
{
|
|
3868
|
+
{
|
|
3869
|
+
"dependencies": {
|
|
3870
|
+
"react": "^18.0.0",
|
|
3871
|
+
"react-dom": "^18.0.0",
|
|
3872
|
+
"react-scripts": "^4.0.0"
|
|
3873
|
+
},
|
|
3874
|
+
"devDependencies": {
|
|
3875
|
+
"@types/react": "^18.0.0",
|
|
3876
|
+
"@types/react-dom": "^18.0.0",
|
|
3877
|
+
"typescript": "^4.0.0"
|
|
3878
|
+
},
|
|
3879
|
+
"main": "/index.tsx"
|
|
3880
|
+
}
|
|
3784
3881
|
```
|
|
3785
3882
|
|
|
3786
3883
|
---
|
|
3787
|
-
|