@czi-sds/mcp 0.15.0 → 0.17.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.
Files changed (164) hide show
  1. package/README.md +2 -1
  2. package/data/component-docs/Accordion.md +291 -0
  3. package/data/component-docs/Autocomplete.md +525 -0
  4. package/data/component-docs/Banner.md +231 -0
  5. package/data/component-docs/Button.md +224 -0
  6. package/data/component-docs/ButtonDropdown.md +256 -0
  7. package/data/component-docs/ButtonGroup.md +320 -0
  8. package/data/component-docs/ButtonToggle.md +397 -0
  9. package/data/component-docs/Callout.md +268 -0
  10. package/data/component-docs/CellBasic.md +122 -0
  11. package/data/component-docs/CellComponent.md +63 -0
  12. package/data/component-docs/CellHeader.md +128 -0
  13. package/data/component-docs/ComplexFilter.md +294 -0
  14. package/data/component-docs/ContentCard.md +406 -0
  15. package/data/component-docs/Dialog.md +651 -0
  16. package/data/component-docs/Dropdown.md +155 -0
  17. package/data/component-docs/DropdownMenu.md +949 -0
  18. package/data/component-docs/HeatmapChart.md +782 -0
  19. package/data/component-docs/Hero.md +363 -0
  20. package/data/component-docs/Icon.md +283 -0
  21. package/data/component-docs/InputCheckbox.md +205 -0
  22. package/data/component-docs/InputDropdown.md +482 -0
  23. package/data/component-docs/InputRadio.md +173 -0
  24. package/data/component-docs/InputSearch.md +81 -0
  25. package/data/component-docs/InputSlider.md +189 -0
  26. package/data/component-docs/InputText.md +110 -0
  27. package/data/component-docs/InputToggle.md +141 -0
  28. package/data/component-docs/IntentMessage.md +293 -0
  29. package/data/component-docs/Legend.md +442 -0
  30. package/data/component-docs/Link.md +23 -0
  31. package/data/component-docs/List.md +300 -0
  32. package/data/component-docs/LoadingIndicator.md +198 -0
  33. package/data/component-docs/Menu.md +298 -0
  34. package/data/component-docs/MenuItem.md +100 -0
  35. package/data/component-docs/NavigationFooter.md +165 -0
  36. package/data/component-docs/NavigationHeader.md +500 -0
  37. package/data/component-docs/NavigationJumpTo.md +414 -0
  38. package/data/component-docs/Notification.md +288 -0
  39. package/data/component-docs/Pagination.md +67 -0
  40. package/data/component-docs/Panel.md +636 -0
  41. package/data/component-docs/Popover.md +448 -0
  42. package/data/component-docs/PreComposedTable.md +2947 -0
  43. package/data/component-docs/SegmentedControl.md +396 -0
  44. package/data/component-docs/StackedBarChart.md +475 -0
  45. package/data/component-docs/Table.md +2000 -0
  46. package/data/component-docs/TableHeader.md +53 -0
  47. package/data/component-docs/TableRow.md +74 -0
  48. package/data/component-docs/Tabs.md +455 -0
  49. package/data/component-docs/Tag.md +647 -0
  50. package/data/component-docs/TagFilter.md +131 -0
  51. package/data/component-docs/Tooltip.md +561 -0
  52. package/data/component-docs/TooltipCondensed.md +203 -0
  53. package/data/component-docs/TooltipTable.md +145 -0
  54. package/data/component-docs/index.json +262 -0
  55. package/data/component-list.json +2 -5
  56. package/data/component-props/Accordion.json +31 -11
  57. package/data/component-props/Alert.json +3 -3
  58. package/data/component-props/Autocomplete.json +150 -15
  59. package/data/component-props/Banner.json +31 -17
  60. package/data/component-props/Button.json +45 -20
  61. package/data/component-props/ButtonDropdown.json +36 -17
  62. package/data/component-props/ButtonDropdownLegacy.json +11 -11
  63. package/data/component-props/ButtonGroup.json +32 -11
  64. package/data/component-props/ButtonIcon.json +10 -10
  65. package/data/component-props/ButtonLegacy.json +19 -19
  66. package/data/component-props/ButtonToggle.json +32 -19
  67. package/data/component-props/ButtonToggleLegacy.json +11 -11
  68. package/data/component-props/Callout.json +58 -17
  69. package/data/component-props/CellBasic.json +94 -41
  70. package/data/component-props/CellComponent.json +23 -7
  71. package/data/component-props/CellHeader.json +62 -19
  72. package/data/component-props/ComplexFilter.json +52 -21
  73. package/data/component-props/ContentCard.json +70 -47
  74. package/data/component-props/Dialog.json +47 -14
  75. package/data/component-props/Dropdown.json +67 -31
  76. package/data/component-props/DropdownMenu.json +128 -23
  77. package/data/component-props/HeatmapChart.json +88 -12
  78. package/data/component-props/Hero.json +80 -39
  79. package/data/component-props/Icon.json +20 -9
  80. package/data/component-props/InputCheckbox.json +36 -14
  81. package/data/component-props/InputDropdown.json +75 -27
  82. package/data/component-props/InputRadio.json +31 -13
  83. package/data/component-props/InputSearch.json +41 -18
  84. package/data/component-props/InputSlider.json +46 -19
  85. package/data/component-props/InputText.json +26 -19
  86. package/data/component-props/InputToggle.json +26 -9
  87. package/data/component-props/IntentMessage.json +38 -9
  88. package/data/component-props/Link.json +13 -7
  89. package/data/component-props/LoadingIndicator.json +11 -3
  90. package/data/component-props/MenuItem.json +38 -19
  91. package/data/component-props/MenuSelect.json +8 -8
  92. package/data/component-props/NavigationFooter.json +49 -19
  93. package/data/component-props/NavigationHeader.json +150 -37
  94. package/data/component-props/NavigationJumpTo.json +33 -7
  95. package/data/component-props/Notification.json +39 -21
  96. package/data/component-props/Pagination.json +39 -11
  97. package/data/component-props/Panel.json +62 -9
  98. package/data/component-props/Popover.json +80 -7
  99. package/data/component-props/PreComposedTable.json +99 -27
  100. package/data/component-props/SegmentedControl.json +42 -3
  101. package/data/component-props/StackedBarChart.json +116 -42
  102. package/data/component-props/TableRow.json +38 -19
  103. package/data/component-props/Tabs.json +66 -9
  104. package/data/component-props/Tag.json +34 -17
  105. package/data/component-props/TagFilter.json +10 -3
  106. package/data/component-props/Tooltip.json +49 -18
  107. package/data/component-props/TooltipCondensed.json +18 -9
  108. package/data/component-props/TooltipTable.json +17 -7
  109. package/data/resources/{zeroheight-rules.md → documentation-rules.md} +43 -30
  110. package/data/resources/figma-rules.md +2 -2
  111. package/dist/stdio.js +483 -780
  112. package/package.json +12 -8
  113. package/data/component-props/ButtonDropdownV2.json +0 -34
  114. package/data/component-props/ButtonNew.json +0 -47
  115. package/data/component-props/ButtonToggleV2.json +0 -44
  116. package/data/component-props/ButtonV2.json +0 -43
  117. package/data/zeroheight-cache.json +0 -10259
  118. package/data/zeroheight-exports/Accordion.md +0 -774
  119. package/data/zeroheight-exports/Banner.md +0 -691
  120. package/data/zeroheight-exports/Borders.md +0 -117
  121. package/data/zeroheight-exports/Buttons.md +0 -1854
  122. package/data/zeroheight-exports/Callout.md +0 -931
  123. package/data/zeroheight-exports/Colors.md +0 -1755
  124. package/data/zeroheight-exports/Content-Card.md +0 -309
  125. package/data/zeroheight-exports/Contributing-to-SDS.md +0 -98
  126. package/data/zeroheight-exports/Control-Inputs.md +0 -2818
  127. package/data/zeroheight-exports/Corners.md +0 -104
  128. package/data/zeroheight-exports/Cover-page.md +0 -3
  129. package/data/zeroheight-exports/Dialog.md +0 -1367
  130. package/data/zeroheight-exports/Downloads.md +0 -236
  131. package/data/zeroheight-exports/Drop-Shadows.md +0 -79
  132. package/data/zeroheight-exports/Dropdown-Input.md +0 -1776
  133. package/data/zeroheight-exports/Dropdown-Menus.md +0 -913
  134. package/data/zeroheight-exports/Element-Status-Tracker.md +0 -267
  135. package/data/zeroheight-exports/Field-Inputs.md +0 -1405
  136. package/data/zeroheight-exports/Filters.md +0 -1111
  137. package/data/zeroheight-exports/Getting-Started.md +0 -1157
  138. package/data/zeroheight-exports/Hero.md +0 -414
  139. package/data/zeroheight-exports/Icons.md +0 -2067
  140. package/data/zeroheight-exports/Intent.md +0 -86
  141. package/data/zeroheight-exports/Introduction-to-Bases.md +0 -35
  142. package/data/zeroheight-exports/Introduction-to-Cells.md +0 -35
  143. package/data/zeroheight-exports/Introduction-to-DNA.md +0 -35
  144. package/data/zeroheight-exports/Introduction-to-Genes.md +0 -35
  145. package/data/zeroheight-exports/Introduction.md +0 -115
  146. package/data/zeroheight-exports/Link.md +0 -432
  147. package/data/zeroheight-exports/Lists.md +0 -986
  148. package/data/zeroheight-exports/Loading-Indicator.md +0 -41
  149. package/data/zeroheight-exports/Navigation.md +0 -1190
  150. package/data/zeroheight-exports/Notification.md +0 -1038
  151. package/data/zeroheight-exports/Panel.md +0 -1030
  152. package/data/zeroheight-exports/README.md +0 -122
  153. package/data/zeroheight-exports/Responsive-Design.md +0 -330
  154. package/data/zeroheight-exports/Search-Input.md +0 -91
  155. package/data/zeroheight-exports/Search.md +0 -822
  156. package/data/zeroheight-exports/Segmented-Control.md +0 -609
  157. package/data/zeroheight-exports/Spacing.md +0 -297
  158. package/data/zeroheight-exports/Table.md +0 -5345
  159. package/data/zeroheight-exports/Tabs.md +0 -1324
  160. package/data/zeroheight-exports/Tags.md +0 -1545
  161. package/data/zeroheight-exports/Text-Link.md +0 -268
  162. package/data/zeroheight-exports/Theming.md +0 -362
  163. package/data/zeroheight-exports/Tooltips.md +0 -2015
  164. package/data/zeroheight-exports/Typography.md +0 -800
@@ -1,1776 +0,0 @@
1
- # Dropdown Input
2
-
3
- The Dropdown Input is an element that triggers Dropdown Menus to open, enabling users to make selections and communicate choices in the UI.
4
-
5
- ## Overview
6
-
7
- | | In Figma | | | Meets Accessibility | | | In napari hub + .org Codebases |
8
- | --- | -------- | --- | --- | ------------------- | --- | --- | ------------------------------ |
9
-
10
- Dropdown Inputs are always accompanied by a Dropdown Menu which is triggered by the user clicking on the input.
11
-
12
- The Dropdown Input is used on napari hub as part of plugin Filters, enabling users to find plugins relevant to their work more easily.
13
-
14
- Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
15
-
16
- | **Default** | **Hover** | **Open** | **Disabled** |
17
- | ----------- | --------- | -------- | ------------ |
18
-
19
- **InputDropdown**
20
-
21
- ---
22
-
23
- **InputDropdown**
24
-
25
- ---
26
-
27
- **InputDropdown**
28
-
29
- ---
30
-
31
- **InputDropdown**
32
-
33
- ---
34
-
35
- ---
36
-
37
- ###  Dropdown Input Spacing
38
-
39
- These rules establish how much margin should exist between and around elements.
40
-
41
- **Dropdown Input spacing**
42
-
43
- ---
44
-
45
- ## Code
46
-
47
- ## Dropdown Input Component
48
-
49
- | Below you will find an interactive Storybook iframe for Dropdown Inputs. 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:** InputDropdown |
50
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------ |
51
-
52
- ---
53
-
54
- > 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.
55
-
56
- ### InputDropdown
57
-
58
- Storybook
59
-
60
- ---
61
-
62
- Dropdown Inputs are elements that trigger Dropdown Menus to open, enabling users to make selections and communicate choices in the UI.
63
-
64
- ## Overview
65
-
66
- ## Dropdown Input Variants
67
-
68
- | There are three Dropdown Input variants available for designers to use depending on the placement location within the UI. Dropdown Inputs are always accompanied by a Dropdown Menu which is triggered by the user clicking on the input. Follow the usage criteria accompanying each variant as a guide for selecting the correct Dropdown Input for any given use case. | | **Jump to variant:** Rounded Square Minimal |
69
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------- |
70
-
71
- ### Visual Preview
72
-
73
- Use the links below to jump to information on a specific Dropdown Input variant:
74
-
75
- **InputDropdown**
76
-
77
- ---
78
-
79
- **InputDropdown**
80
-
81
- ---
82
-
83
- **InputDropdown**
84
-
85
- ---
86
-
87
- ---
88
-
89
- ## Rounded Dropdown Input
90
-
91
- | | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
92
- | --- | -------- | --- | --- | ------------------- | --- | --- | ----------------- |
93
-
94
- ### Single-select Rounded Dropdown Input
95
-
96
- Use when the user is only able to select one option from a group of choices within the triggered Dropdown Menu.
97
-
98
- Used within CZ ID for filtering within Tables and datasets.
99
-
100
- Using the `details` prop, optional text can be added to the Input to communicate additional information such as providing a sub-label or listing the user's selection.
101
-
102
- Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
103
-
104
- | **Default** | **Hover** | **Default** | **Open** | **Disabled** |
105
- | ----------- | --------- | ----------- | -------- | ------------ |
106
-
107
- **InputDropdown**
108
-
109
- ---
110
-
111
- **InputDropdown**
112
-
113
- ---
114
-
115
- **InputDropdown**
116
-
117
- ---
118
-
119
- **InputDropdown**
120
-
121
- ---
122
-
123
- **InputDropdown**
124
-
125
- ---
126
-
127
- | **Default + Details** | **Hover** | **Default** | **Open** | **Disabled** |
128
- | --------------------- | --------- | ----------- | -------- | ------------ |
129
-
130
- **InputDropdown**
131
-
132
- ---
133
-
134
- **InputDropdown**
135
-
136
- ---
137
-
138
- **InputDropdown**
139
-
140
- ---
141
-
142
- **InputDropdown**
143
-
144
- ---
145
-
146
- **InputDropdown**
147
-
148
- ---
149
-
150
- ### Multi-select Rounded Dropdown Input
151
-
152
- Use when the user is able to select more than one option from a group of choices within the triggered Dropdown Menu.
153
-
154
- Used within CZ ID for filtering within Tables and datasets.
155
-
156
- Using the `details` prop, an optional counter can be added to the Input to communicate how many selections the user has chosen within the triggered Dropdown Menu.
157
-
158
- Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
159
-
160
- | **Default** | **Hover** | **Default** | **Open** | **Disabled** |
161
- | ----------- | --------- | ----------- | -------- | ------------ |
162
-
163
- **InputDropdown**
164
-
165
- ---
166
-
167
- **InputDropdown**
168
-
169
- ---
170
-
171
- **InputDropdown**
172
-
173
- ---
174
-
175
- **InputDropdown**
176
-
177
- ---
178
-
179
- **InputDropdown**
180
-
181
- ---
182
-
183
- | **Default + Details** | **Hover** | **Default** | **Open** | **Disabled** |
184
- | --------------------- | --------- | ----------- | -------- | ------------ |
185
-
186
- **InputDropdown**
187
-
188
- ---
189
-
190
- **InputDropdown**
191
-
192
- ---
193
-
194
- **InputDropdown**
195
-
196
- ---
197
-
198
- **InputDropdown**
199
-
200
- ---
201
-
202
- **InputDropdown**
203
-
204
- ---
205
-
206
- ### Rounded Dropdown Input Intent States
207
-
208
- The `intent` prop is used to communicate the state of the user's response from the accompanying Dropdown Menu.
209
-
210
- Use `intent: default` to communicate when a user has entered an accepted or complete response.
211
-
212
- Use `intent: error` to communicate when a user has entered an incorrect or incomplete response.
213
-
214
- Use `intent: warning` to communicate when a user needs to be alerted that their response needs attention.
215
-
216
- Each intent is demonstrated below using the Single-select Dropdown Input for reference; all variants follow the same pattern:
217
-
218
- | **Default** | **Error** | **Warning** |
219
- | ----------- | --------- | ----------- |
220
-
221
- **InputDropdown**
222
-
223
- ---
224
-
225
- **InputDropdown**
226
-
227
- ---
228
-
229
- **InputDropdown**
230
-
231
- ---
232
-
233
- ---
234
-
235
- ### Rounded Dropdown Input Spacing
236
-
237
- These rules establish how much margin should exist between and around elements.
238
-
239
- **Rounded Dropdown Input spacing**
240
-
241
- ---
242
-
243
- ---
244
-
245
- ## Square Dropdown Input
246
-
247
- | | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
248
- | --- | -------- | --- | --- | ------------------- | --- | --- | ----------------- |
249
-
250
- ### Single-select Square Dropdown Input
251
-
252
- Use when the user is only able to select one option from a group of choices within the triggered Dropdown Menu.
253
-
254
- Used within CZ ID on forms and Dialogs that contain menu options for users.
255
-
256
- Using the `details` prop, optional text can be added to the Input to communicate additional information such as providing a sub-label or listing the user's selection.
257
-
258
- Note: `singleSelect` is the only `sdsType` prop value available for Square Dropdown Input.
259
-
260
- Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
261
-
262
- | **Default** | **Hover** | **Default** | **Open** | **Disabled** |
263
- | ----------- | --------- | ----------- | -------- | ------------ |
264
-
265
- **InputDropdown**
266
-
267
- ---
268
-
269
- **InputDropdown**
270
-
271
- ---
272
-
273
- **InputDropdown**
274
-
275
- ---
276
-
277
- **InputDropdown**
278
-
279
- ---
280
-
281
- **InputDropdown**
282
-
283
- ---
284
-
285
- | **Default + Details** | **Hover** | **Default** | **Open** | **Disabled** |
286
- | --------------------- | --------- | ----------- | -------- | ------------ |
287
-
288
- **InputDropdown**
289
-
290
- ---
291
-
292
- **InputDropdown**
293
-
294
- ---
295
-
296
- **InputDropdown**
297
-
298
- ---
299
-
300
- **InputDropdown**
301
-
302
- ---
303
-
304
- **InputDropdown**
305
-
306
- ---
307
-
308
- ### Square Dropdown Input Intent States
309
-
310
- The `intent` prop is used to communicate the state of the user's response from the accompanying Dropdown Menu.
311
-
312
- Use `intent: default` to communicate when a user has entered an accepted or complete response.
313
-
314
- Use `intent: error` to communicate when a user has entered an incorrect or incomplete response.
315
-
316
- Use `intent: warning` to communicate when a user needs to be alerted that their response needs attention.
317
-
318
- Each intent is demonstrated below using the Single-select Dropdown Input for reference; all variants follow the same pattern:
319
-
320
- | **Default** | **Error** | **Warning** |
321
- | ----------- | --------- | ----------- |
322
-
323
- **InputDropdown**
324
-
325
- ---
326
-
327
- **InputDropdown**
328
-
329
- ---
330
-
331
- **InputDropdown**
332
-
333
- ---
334
-
335
- ---
336
-
337
- ### Square Dropdown Input Spacing
338
-
339
- These rules establish how much margin should exist between and around elements.
340
-
341
- **Square Dropdown Input spacing_CZ ID**
342
-
343
- ---
344
-
345
- ---
346
-
347
- ## Minimal Dropdown Input
348
-
349
- | | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
350
- | --- | -------- | --- | --- | ------------------- | --- | --- | ----------------- |
351
-
352
- Use when the user is only able to select one option from a group of choices within the triggered Dropdown Menu.
353
-
354
- The Minimal Dropdown Input is typically reserved for use in Filters (documentation coming soon).
355
-
356
- Note: `singleSelect` is the only `sdsType` prop value available for Minimal Dropdown Input.
357
-
358
- Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
359
-
360
- | **Default** | **Hover** | **Default** | **Open** | **Disabled** |
361
- | ----------- | --------- | ----------- | -------- | ------------ |
362
-
363
- **InputDropdown**
364
-
365
- ---
366
-
367
- **InputDropdown**
368
-
369
- ---
370
-
371
- **InputDropdown**
372
-
373
- ---
374
-
375
- **InputDropdown**
376
-
377
- ---
378
-
379
- **InputDropdown**
380
-
381
- ---
382
-
383
- ### Minimal Dropdown Input Intent States
384
-
385
- The `intent` prop is used to communicate the state of the user's response from the accompanying Dropdown Menu.
386
-
387
- Use `intent: default` to communicate when a user has entered an accepted or complete response.
388
-
389
- | **Default** | | |
390
- | ----------- | --- | --- |
391
-
392
- **InputDropdown**
393
-
394
- ---
395
-
396
- ---
397
-
398
- ### Minimal Dropdown Input Spacing
399
-
400
- These rules establish how much margin should exist between and around elements.
401
-
402
- **Minimal Dropdown Input spacing**
403
-
404
- ---
405
-
406
- ## Code
407
-
408
- ## Dropdown Input Component
409
-
410
- | Below you will find an interactive Storybook iframe for Dropdown Inputs. 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:** InputDropdown |
411
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------ |
412
-
413
- ---
414
-
415
- ### InputDropdown
416
-
417
- Storybook
418
-
419
- ---
420
-
421
- Dropdown Inputs are elements that trigger Dropdown Menus to open, enabling users to make selections and communicate choices in the UI.
422
-
423
- ## Guidelines
424
-
425
- ## Dropdown Input Component
426
-
427
- | | In Figma | | | Meets Accessibility | | | In Code |
428
- | --- | -------- | --- | --- | ------------------- | --- | --- | ------- |
429
-
430
- ### Dropdown Input Types
431
-
432
- There are two Dropdown Input types designers can use depending on whether their design calls for the input field's label to be inside the input itself (Label variant) or if an external label will be used with an accompanying Dropdown Input (Value variant).
433
-
434
- On click, Dropdown Inputs always trigger a Dropdown Menu to open.
435
-
436
- > **Note:** The external field label shown as part of the Value variant visual below is for demonstration purposes only and is not built into the component itself; a separate label must be added to achieve this in product.
437
-
438
- **Preview_Guidelines_InputDropdown_Label**
439
-
440
- ---
441
-
442
- **Preview_Guidelines_InputDropdown_Value**
443
-
444
- ---
445
-
446
- ---
447
-
448
- ### Live Instance
449
-
450
- Interact with the live instance below and adjust the available props to better conceptualize how it will appear in product:
451
-
452
- Default
453
-
454
- ---
455
-
456
- ### Dropdown Input – Label
457
-
458
- The Label variant functions as both the field label **and** the input field itself from which users make their selections. Before a selection is made, only the field label is displayed inside the input; after the user makes a selection, the selected value appears alongside the label inside the input field.
459
-
460
- In instances where users can select more than one value, a counter showing the number of selections made is shown beside the label (this feature is limited to the rounded and square variants only). In cases where the designer does not want the value to appear in the input field after a selection is made (such as when using in combination with Filter Tags), this feature can be disabled.
461
-
462
- Optionally, Intent Messages can be displayed to further communicate why a Negative or Notice intent was triggered.
463
-
464
- #### Rounded
465
-
466
- | Default | Hover | Open | Disabled |
467
- | :-----: | :---: | :--: | :------: |
468
-
469
- **InputDropdown_Label_Rounded_No Value_Default**
470
-
471
- ---
472
-
473
- **InputDropdown_Label_Rounded_No Value_Hover**
474
-
475
- ---
476
-
477
- **InputDropdown_Label_Rounded_No Value_Open**
478
-
479
- ---
480
-
481
- **InputDropdown_Label_Rounded_No Value_Disabled**
482
-
483
- ---
484
-
485
- **InputDropdown_Label_Rounded_Value_Default**
486
-
487
- ---
488
-
489
- **InputDropdown_Label_Rounded_Value_Hover**
490
-
491
- ---
492
-
493
- **InputDropdown_Label_Rounded_Value_Open**
494
-
495
- ---
496
-
497
- **InputDropdown_Label_Rounded_Value_Disabled**
498
-
499
- ---
500
-
501
- **InputDropdown_Label_Rounded_Count_Default**
502
-
503
- ---
504
-
505
- **InputDropdown_Label_Rounded_Count_Hover**
506
-
507
- ---
508
-
509
- **InputDropdown_Label_Rounded_Count_Open**
510
-
511
- ---
512
-
513
- **InputDropdown_Label_Rounded_Count_Disabled**
514
-
515
- ---
516
-
517
- _Intent Variations_
518
-
519
- Use Negative to communicate when a user has entered an incorrect or incomplete response and Notice when a user's response needs attention. Optionally, Intent Messages can be displayed to further communicate why a Negative or Notice intent was triggered. For more information see Intents.
520
-
521
- | Negative | Negative + Intent Message | Notice | Notice + Intent Message |
522
- | :------: | ------------------------- | :----: | ----------------------- |
523
-
524
- **InputDropdown_Label_Rounded_No Value_Negative**
525
-
526
- ---
527
-
528
- **InputDropdown_Label_Rounded_No Value_Negative + Message**
529
-
530
- ---
531
-
532
- **InputDropdown_Label_Rounded_No Value_Notice**
533
-
534
- ---
535
-
536
- **InputDropdown_Label_Rounded_No Value_Notice + Message**
537
-
538
- ---
539
-
540
- **InputDropdown_Label_Rounded_Value_Negative**
541
-
542
- ---
543
-
544
- **InputDropdown_Label_Rounded_Value_Negative + Message**
545
-
546
- ---
547
-
548
- **InputDropdown_Label_Rounded_Value_Notice**
549
-
550
- ---
551
-
552
- **InputDropdown_Label_Rounded_Value_Notice + Message**
553
-
554
- ---
555
-
556
- **InputDropdown_Label_Rounded_Count_Negative**
557
-
558
- ---
559
-
560
- **InputDropdown_Label_Rounded_Count_Negative + Message**
561
-
562
- ---
563
-
564
- **InputDropdown_Label_Rounded_Count_Notice**
565
-
566
- ---
567
-
568
- **InputDropdown_Label_Rounded_Count_Notice + Message**
569
-
570
- ---
571
-
572
- #### Square
573
-
574
- | Default | Hover | Open | Disabled |
575
- | :-----: | :---: | :--: | :------: |
576
-
577
- **InputDropdown_Label_Square_No Value_Default**
578
-
579
- ---
580
-
581
- **InputDropdown_Label_Square_No Value_Hover**
582
-
583
- ---
584
-
585
- **InputDropdown_Label_Square_No Value_Open**
586
-
587
- ---
588
-
589
- **InputDropdown_Label_Square_No Value_Disabled**
590
-
591
- ---
592
-
593
- **InputDropdown_Label_Square_Value_Default**
594
-
595
- ---
596
-
597
- **InputDropdown_Label_Square_Value_Hover**
598
-
599
- ---
600
-
601
- **InputDropdown_Label_Square_Value_Open**
602
-
603
- ---
604
-
605
- **InputDropdown_Label_Square_Value_Disabled**
606
-
607
- ---
608
-
609
- **InputDropdown_Label_Square_Count_Default**
610
-
611
- ---
612
-
613
- **InputDropdown_Label_Square_Count_Hover**
614
-
615
- ---
616
-
617
- **InputDropdown_Label_Square_Count_Open**
618
-
619
- ---
620
-
621
- **InputDropdown_Label_Square_Count_Disabled**
622
-
623
- ---
624
-
625
- _Intent Variations_
626
-
627
- Use Negative to communicate when a user has entered an incorrect or incomplete response and Notice when a user's response needs attention. Optionally, Intent Messages can be displayed to further communicate why a Negative or Notice intent was triggered. For more information see Intents.
628
-
629
- | Negative | Negative + Intent Message | Notice | Notice + Intent Message |
630
- | :------: | ------------------------- | :----: | ----------------------- |
631
-
632
- **InputDropdown_Label_Square_No Value_Negative**
633
-
634
- ---
635
-
636
- **InputDropdown_Label_Square_No Value_Negative + Message**
637
-
638
- ---
639
-
640
- **InputDropdown_Label_Square_No Value_Notice**
641
-
642
- ---
643
-
644
- **InputDropdown_Label_Square_No Value_Notice + Message**
645
-
646
- ---
647
-
648
- **InputDropdown_Label_Square_Value_Negative**
649
-
650
- ---
651
-
652
- **InputDropdown_Label_Square_Value_Negative + Message**
653
-
654
- ---
655
-
656
- **InputDropdown_Label_Square_Value_Notice**
657
-
658
- ---
659
-
660
- **InputDropdown_Label_Square_Value_Notice + Message**
661
-
662
- ---
663
-
664
- **InputDropdown_Label_Square_Count_Negative**
665
-
666
- ---
667
-
668
- **InputDropdown_Label_Square_Count_Negative + Message**
669
-
670
- ---
671
-
672
- **InputDropdown_Label_Square_Count_Notice**
673
-
674
- ---
675
-
676
- **InputDropdown_Label_Square_Count_Notice + Message**
677
-
678
- ---
679
-
680
- #### Minimal
681
-
682
- | Default | Hover | Open | Disabled |
683
- | :-----: | :---: | :--: | :------: |
684
-
685
- **InputDropdown_Label_Minimal_No Value_Default**
686
-
687
- ---
688
-
689
- **InputDropdown_Label_Minimal_No Value_Hover**
690
-
691
- ---
692
-
693
- **InputDropdown_Label_Minimal_No Value_Open**
694
-
695
- ---
696
-
697
- **InputDropdown_Label_Minimal_No Value_Disabled**
698
-
699
- ---
700
-
701
- **InputDropdown_Label_Minimal_Value_Default**
702
-
703
- ---
704
-
705
- **InputDropdown_Label_Minimal_Value_Hover**
706
-
707
- ---
708
-
709
- **InputDropdown_Label_Minimal_Value_Open**
710
-
711
- ---
712
-
713
- **InputDropdown_Label_Minimal_Value_Disabled**
714
-
715
- ---
716
-
717
- ---
718
-
719
- ### Dropdown Input – Value
720
-
721
- Use the Value variant when designs call for the input label to be a separate (external) HTML element from the input itself. Before a selection is made, the input should display a prompt instructing users to make a selection; after the user makes a selection, the selected value replaces the prompt in the input field.
722
-
723
- Additionally, detail text can be included with each value to communicate additional information to the user such as providing a sub-label or clarifying information.
724
-
725
- Optionally, Intent Messages can be displayed to further communicate why a Negative or Notice intent was triggered.
726
-
727
- #### **Rounded**
728
-
729
- | Default | Hover | Open | Disabled |
730
- | :-----: | :---: | :--: | :------: |
731
-
732
- **InputDropdown_Value_Rounded_No Details_Default**
733
-
734
- ---
735
-
736
- **InputDropdown_Value_Rounded_No Details_Hover**
737
-
738
- ---
739
-
740
- **InputDropdown_Value_Rounded_No Details_Open**
741
-
742
- ---
743
-
744
- **InputDropdown_Value_Rounded_No Details_Disabled**
745
-
746
- ---
747
-
748
- **InputDropdown_Value_Rounded_Details_Default**
749
-
750
- ---
751
-
752
- **InputDropdown_Value_Rounded_Details_Hover**
753
-
754
- ---
755
-
756
- **InputDropdown_Value_Rounded_Details_Open**
757
-
758
- ---
759
-
760
- **InputDropdown_Value_Rounded_Details_Disabled**
761
-
762
- ---
763
-
764
- _Intent Variations_
765
-
766
- Use Negative to communicate when a user has entered an incorrect or incomplete response and Notice when a user's response needs attention. Optionally, Intent Messages can be displayed to further communicate why a Negative or Notice intent was triggered. For more information see Intents.
767
-
768
- | Negative | Negative + Intent Message | Notice | Notice + Intent Message |
769
- | :------: | ------------------------- | :----: | ----------------------- |
770
-
771
- **InputDropdown_Value_Rounded_No Details_Negative**
772
-
773
- ---
774
-
775
- **InputDropdown_Value_Rounded_No Details_Negative + Message**
776
-
777
- ---
778
-
779
- **InputDropdown_Value_Rounded_No Details_Notice**
780
-
781
- ---
782
-
783
- **InputDropdown_Value_Rounded_No Details_Notice + Message**
784
-
785
- ---
786
-
787
- **InputDropdown_Value_Rounded_Details_Negative**
788
-
789
- ---
790
-
791
- **InputDropdown_Value_Rounded_Details_Negative + Message**
792
-
793
- ---
794
-
795
- **InputDropdown_Value_Rounded_Details_Notice**
796
-
797
- ---
798
-
799
- **InputDropdown_Value_Rounded_Details_Notice + Message**
800
-
801
- ---
802
-
803
- #### **Square**
804
-
805
- | Default | Hover | Open | Disabled |
806
- | :-----: | :---: | :--: | :------: |
807
-
808
- **InputDropdown_Value_Square_No Details_Default**
809
-
810
- ---
811
-
812
- **InputDropdown_Value_Square_No Details_Hover**
813
-
814
- ---
815
-
816
- **InputDropdown_Value_Square_No Details_Open**
817
-
818
- ---
819
-
820
- **InputDropdown_Value_Square_No Details_Disabled**
821
-
822
- ---
823
-
824
- **InputDropdown_Value_Square_Details_Default**
825
-
826
- ---
827
-
828
- **InputDropdown_Value_Square_Details_Hover**
829
-
830
- ---
831
-
832
- **InputDropdown_Value_Square_Details_Open**
833
-
834
- ---
835
-
836
- **InputDropdown_Value_Square_Details_Disabled**
837
-
838
- ---
839
-
840
- _Intent Variations_
841
-
842
- Use Negative to communicate when a user has entered an incorrect or incomplete response and Notice when a user's response needs attention. Optionally, Intent Messages can be displayed to further communicate why a Negative or Notice intent was triggered. For more information see Intents.
843
-
844
- | Negative | Negative + Intent Message | Notice | Notice + Intent Message |
845
- | :------: | ------------------------- | :----: | ----------------------- |
846
-
847
- **InputDropdown_Value_Square_No Details_Negative**
848
-
849
- ---
850
-
851
- **InputDropdown_Value_Square_No Details_Negative + Message**
852
-
853
- ---
854
-
855
- **InputDropdown_Value_Square_No Details_Notice**
856
-
857
- ---
858
-
859
- **InputDropdown_Value_Square_No Details_Notice + Message**
860
-
861
- ---
862
-
863
- **InputDropdown_Value_Square_Details_Negative**
864
-
865
- ---
866
-
867
- **InputDropdown_Value_Square_Details_Negative + Message**
868
-
869
- ---
870
-
871
- **InputDropdown_Value_Square_Details_Notice**
872
-
873
- ---
874
-
875
- **InputDropdown_Value_Square_Details_Notice + Message**
876
-
877
- ---
878
-
879
- #### **Minimal**
880
-
881
- | Default | Hover | Open | Disabled |
882
- | :-----: | :---: | :--: | :------: |
883
-
884
- **InputDropdown_Value_Minimal_No Details_Default**
885
-
886
- ---
887
-
888
- **InputDropdown_Value_Minimal_No Details_Hover**
889
-
890
- ---
891
-
892
- **InputDropdown_Value_Minimal_No Details_Open**
893
-
894
- ---
895
-
896
- **InputDropdown_Value_Minimal_No Details_Disabled**
897
-
898
- ---
899
-
900
- **InputDropdown_Value_Minimal_Details_Default**
901
-
902
- ---
903
-
904
- **InputDropdown_Value_Minimal_Details_Hover**
905
-
906
- ---
907
-
908
- **InputDropdown_Value_Minimal_Details_Open**
909
-
910
- ---
911
-
912
- **InputDropdown_Value_Minimal_Details_Disabled**
913
-
914
- ---
915
-
916
- ---
917
-
918
- ### Dropdown Input Spacing
919
-
920
- These rules establish how much margin should exist between and around elements.
921
-
922
- **Dropdown Input spacing**
923
-
924
- ---
925
-
926
- ## Code
927
-
928
- > **Note:** The code examples below must install dependencies before displaying and may take extra time to load
929
-
930
- ## InputDropdown
931
-
932
- ### SDS Source Code
933
-
934
- The component's source code in the SDS codebase can be found here.
935
-
936
- ### SDS vs MUI
937
-
938
- The SDS's `InputDropdown` component utilizes MUI's `Button` component as its foundation but introduces some SDS-specific enhancements. Below, the key distinctions between the SDS's `InputDropdown` and MUI's `Button` are outlined:
939
-
940
- - **Variation**: MUI's `Button` offers a `variant` prop to define different visual styles for buttons. SDS's `InputDropdown`, however, uses the `sdsStyle` prop instead, providing the ability to select between three variants: `square`, `rounded`, or `minimal`.
941
- - **Color**: In MUI's `Button`, the button's color can be modified using the `color` prop. SDS's `InputDropdown` deviates from this and introduces the `intent` prop. This prop provides the ability to choose between `default`, `warning`, and `error` colors, depending on the state of the `InputDropdown`.
942
- - **Size**: While MUI's `Button` provides a `size` prop for adjusting the button's size, SDS's `InputDropdown` does not offer this capability. The size of the `InputDropdown` component remains fixed and cannot be altered through props.
943
- - **Icon**: Unlike MUI's `Button`, which supports custom icons, SDS's `InputDropdown` does not accept external icon components. Instead, SDS's `InputDropdown` incorporates a built-in Chevron icon, which is an integral part of the component and cannot be replaced.
944
-
945
- ### MUI Documentation
946
-
947
- Documentation for the underlying MUI component can be found here.
948
-
949
- ### Props
950
-
951
- Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
952
-
953
- | Name | Type | Default | Description |
954
- | ------------------------------ | ------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | --------------------------- |
955
- | `counter` | `ReactNode` | `-` | If multiple set to `true`, this number shows the number of selected menu items. |
956
- | `details` | `ReactNode` | `-` | A text showing details for the selected menu item. |
957
- | `disabled` | `bool` | `false` | If `true`, the component is disabled. |
958
- | `intent` | `"default"` ` | "negative"` ` | "notice"` ` | "positive"` | `default` | The color of the component. |
959
- | `label` | `ReactNode` | `-` | The label of the Input Button. |
960
- | `multiple` | `bool` | `false` | Allows users to select multiple menu items.`multiple=true` cannot be used with the `minimum` variant. |
961
- | `onClick` | `func` | `(event: React.MouseEvent<HTMLElement>) => void` | Sets what happens when a user clicks on the component. |
962
- | `sdsStyle` | `"minimal"` ` | "square"` ` | "rounded"` | `square` | The visual appearance of the component. |
963
- | `sdsType` | `"label"` ` | "value"` | `label` | The `label` variant includes the label within the input field and showcases the selected menu item as additional details or sets the counter when in multi-select mode. The `value` variant replaces the label with the selected value directly within the input field. The detailed information is then displayed in a separate section dedicated to displaying additional details. However, it's important to note that the value variant cannot be used in conjunction with multi-select mode. |
964
- | `shouldPutAColonAfterLabel` | `bool` | `true` | If `true`, a colon (:) will be added after the label or value. |
965
- | `shouldTruncateMinimalDetails` | `bool` | `false` | If `true`, the details section of the minimal variant displays a truncated one-liner with an ellipsis (...), if `false` the details section expands to multiple lines for a comprehensive display. |
966
- | `value` | `ReactNode` | `-` | The value that will be displayed in the component for the `value` variant. |
967
-
968
- There are more props that can be used with the `InputDropdown` component, via those available to MUI's `Button` component.
969
-
970
- ### Code Examples
971
-
972
- #### Default InputDropdown
973
-
974
- This example has the minimum props needed for the `InputDropdown` component.
975
-
976
- **/styles.css**
977
-
978
- ```css
979
- body {
980
- font-size: 13px;
981
- font-weight: 400;
982
- letter-spacing: 0.08px;
983
- line-height: 20px;
984
- text-transform: none;
985
- font-family: "Inter", sans-serif;
986
- }
987
-
988
- h1 {
989
- font-size: 1.5rem;
990
- }
991
-
992
- .app {
993
- padding: 20px;
994
- }
995
- ```
996
-
997
- **tsconfig.json**
998
-
999
- ```json
1000
- {
1001
- "include": ["./**/*"],
1002
- "compilerOptions": {
1003
- "strict": true,
1004
- "esModuleInterop": true,
1005
- "lib": ["dom", "es2015"],
1006
- "jsx": "react-jsx"
1007
- }
1008
- }
1009
- ```
1010
-
1011
- **/App.tsx**
1012
-
1013
- ```tsx
1014
- // Most minimal InputDropdown (just has the basic requirements)
1015
-
1016
- import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
1017
- import { InputDropdown } from "@czi-sds/components";
1018
- import "./styles.css";
1019
-
1020
- function App() {
1021
- return (
1022
- <div className="app">
1023
- <InputDropdown label="Label" />
1024
- </div>
1025
- );
1026
- }
1027
-
1028
- export default App;
1029
- ```
1030
-
1031
- **/index.tsx**
1032
-
1033
- ```tsx
1034
- import React from "react";
1035
- import { createRoot } from "react-dom/client";
1036
- import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
1037
- import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
1038
- import { Theme } from "@czi-sds/components";
1039
- import CssBaseline from "@mui/material/CssBaseline";
1040
- import useMediaQuery from "@mui/material/useMediaQuery";
1041
-
1042
- import App from "./App";
1043
-
1044
- const container = document.getElementById("root");
1045
- const root = createRoot(container!);
1046
-
1047
- const RootApp = () => {
1048
- const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
1049
- const theme = prefersDarkMode ? Theme("dark") : Theme("light");
1050
-
1051
- return (
1052
- <StyledEngineProvider injectFirst>
1053
- <ThemeProvider theme={theme}>
1054
- <EmotionThemeProvider theme={theme}>
1055
- <CssBaseline />
1056
- <App />
1057
- </EmotionThemeProvider>
1058
- </ThemeProvider>
1059
- </StyledEngineProvider>
1060
- );
1061
- };
1062
-
1063
- root.render(
1064
- <React.StrictMode>
1065
- <RootApp />
1066
- </React.StrictMode>
1067
- );
1068
- ```
1069
-
1070
- **/public/index.html**
1071
-
1072
- ```html
1073
- <!doctype html>
1074
- <html lang="en">
1075
- <head>
1076
- <meta charset="UTF-8" />
1077
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1078
- <link rel="preconnect" href="https://fonts.googleapis.com" />
1079
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1080
- <link
1081
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
1082
- rel="stylesheet"
1083
- />
1084
- <link
1085
- href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap"
1086
- rel="stylesheet"
1087
- />
1088
- </head>
1089
- <body>
1090
- <div id="root"></div>
1091
- </body>
1092
- </html>
1093
- ```
1094
-
1095
- **/package.json**
1096
-
1097
- ```json
1098
- {
1099
- "dependencies": {
1100
- "react": "^18.0.0",
1101
- "react-dom": "^18.0.0",
1102
- "react-scripts": "^4.0.0"
1103
- },
1104
- "devDependencies": {
1105
- "@types/react": "^18.0.0",
1106
- "@types/react-dom": "^18.0.0",
1107
- "typescript": "^4.0.0"
1108
- },
1109
- "main": "/index.tsx"
1110
- }
1111
- ```
1112
-
1113
- ---
1114
-
1115
- > **MUI Tip:** To ensure the InputDropdown button expands to fit the width of its container, users can utilize the `fullWidth` prop provided by MUI. When set to `true`, the `fullWidth` prop enables the InputDropdown button to occupy the entire available width within its parent container.
1116
-
1117
- #### InputDropdown combined with a multi-select Dropdown
1118
-
1119
- Below is an example demonstrating the combined utilization of the `InputDropdown` component and a multi-select `Dropdown` component. The `Dropdown` allows multiple selections, while the `InputDropdown` features a `square` variant.
1120
-
1121
- **/styles.css**
1122
-
1123
- ```css
1124
- body {
1125
- font-size: 13px;
1126
- font-weight: 400;
1127
- letter-spacing: 0.08px;
1128
- line-height: 20px;
1129
- text-transform: none;
1130
- font-family: "Inter", sans-serif;
1131
- }
1132
-
1133
- h1 {
1134
- font-size: 1.5rem;
1135
- }
1136
-
1137
- .app {
1138
- padding: 20px;
1139
- }
1140
- ```
1141
-
1142
- **tsconfig.json**
1143
-
1144
- ```json
1145
- {
1146
- "include": ["./**/*"],
1147
- "compilerOptions": {
1148
- "strict": true,
1149
- "esModuleInterop": true,
1150
- "lib": ["dom", "es2015"],
1151
- "jsx": "react-jsx"
1152
- }
1153
- }
1154
- ```
1155
-
1156
- **/App.tsx**
1157
-
1158
- ```tsx
1159
- import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
1160
- import { InputDropdown, DropdownMenu, noop } from "@czi-sds/components";
1161
- import "./styles.css";
1162
-
1163
- const options = [
1164
- {
1165
- details: "Details",
1166
- name: "Menu Item 1",
1167
- },
1168
- {
1169
- details: "A very long Details for the second Menu Item",
1170
- name: "Menu Item 2",
1171
- },
1172
- {
1173
- name: "Menu Item 3",
1174
- },
1175
- ];
1176
-
1177
- function App() {
1178
- const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
1179
- const [open, setOpen] = useState(false);
1180
- const [details, setDetials] = useState<string>();
1181
- const [counter, setCounter] = useState<string>();
1182
- const [inputDropdownValue, setInputDropdownValue] = useState<string>();
1183
- const [value, setValue] = useState<
1184
- DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1185
- >([]);
1186
- const [pendingValue, setPendingValue] = useState<
1187
- DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1188
- >([]);
1189
-
1190
- return (
1191
- <div className="app">
1192
- <InputDropdown
1193
- label="Label"
1194
- onClick={handleClick}
1195
- sdsStyle="square"
1196
- multiple
1197
- value={inputDropdownValue}
1198
- counter={counter}
1199
- />
1200
- <DropdownMenu
1201
- open={open}
1202
- anchorEl={anchorEl}
1203
- onClose={noop}
1204
- onChange={handleChange}
1205
- search={false}
1206
- multiple
1207
- disableCloseOnSelect
1208
- options={options}
1209
- value={pendingValue}
1210
- onClickAway={handleClickAway}
1211
- />
1212
- </div>
1213
- );
1214
-
1215
- function handleClick(event: React.MouseEvent<HTMLElement>) {
1216
- if (open) {
1217
- setOpen(false);
1218
-
1219
- if (anchorEl) {
1220
- anchorEl.focus();
1221
- }
1222
-
1223
- setAnchorEl(null);
1224
- } else {
1225
- setAnchorEl(event.currentTarget);
1226
- setOpen(true);
1227
- }
1228
- }
1229
-
1230
- function handleChange(
1231
- _: React.SyntheticEvent<Element, Event>,
1232
- newValue: DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1233
- ) {
1234
- setPendingValue(newValue);
1235
- setCounter((newValue as DefaultDropdownMenuOption[])?.length.toString());
1236
- }
1237
-
1238
- function handleClickAway() {
1239
- if (open) {
1240
- setOpen(false);
1241
- }
1242
- setValue(pendingValue);
1243
- }
1244
- }
1245
-
1246
- export default App;
1247
- ```
1248
-
1249
- **/index.tsx**
1250
-
1251
- ```tsx
1252
- import React from "react";
1253
- import { createRoot } from "react-dom/client";
1254
- import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
1255
- import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
1256
- import { Theme } from "@czi-sds/components";
1257
- import CssBaseline from "@mui/material/CssBaseline";
1258
- import useMediaQuery from "@mui/material/useMediaQuery";
1259
-
1260
- import App from "./App";
1261
-
1262
- const container = document.getElementById("root");
1263
- const root = createRoot(container!);
1264
-
1265
- const RootApp = () => {
1266
- const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
1267
- const theme = prefersDarkMode ? Theme("dark") : Theme("light");
1268
-
1269
- return (
1270
- <StyledEngineProvider injectFirst>
1271
- <ThemeProvider theme={theme}>
1272
- <EmotionThemeProvider theme={theme}>
1273
- <CssBaseline />
1274
- <App />
1275
- </EmotionThemeProvider>
1276
- </ThemeProvider>
1277
- </StyledEngineProvider>
1278
- );
1279
- };
1280
-
1281
- root.render(
1282
- <React.StrictMode>
1283
- <RootApp />
1284
- </React.StrictMode>
1285
- );
1286
- ```
1287
-
1288
- **/public/index.html**
1289
-
1290
- ```html
1291
- <!doctype html>
1292
- <html lang="en">
1293
- <head>
1294
- <meta charset="UTF-8" />
1295
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1296
- <link rel="preconnect" href="https://fonts.googleapis.com" />
1297
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1298
- <link
1299
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
1300
- rel="stylesheet"
1301
- />
1302
- <link
1303
- href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap"
1304
- rel="stylesheet"
1305
- />
1306
- </head>
1307
- <body>
1308
- <div id="root"></div>
1309
- </body>
1310
- </html>
1311
- ```
1312
-
1313
- **/package.json**
1314
-
1315
- ```json
1316
- {
1317
- "dependencies": {
1318
- "react": "^18.0.0",
1319
- "react-dom": "^18.0.0",
1320
- "react-scripts": "^4.0.0"
1321
- },
1322
- "devDependencies": {
1323
- "@types/react": "^18.0.0",
1324
- "@types/react-dom": "^18.0.0",
1325
- "typescript": "^4.0.0"
1326
- },
1327
- "main": "/index.tsx"
1328
- }
1329
- ```
1330
-
1331
- ---
1332
-
1333
- #### Rounded InputDropdown combined with a single select Dropdown
1334
-
1335
- Below is an example demonstrating the combined utilization of the default `label` variant `InputDropdown` component and a single-select `Dropdown` component.
1336
-
1337
- **/styles.css**
1338
-
1339
- ```css
1340
- body {
1341
- font-size: 13px;
1342
- font-weight: 400;
1343
- letter-spacing: 0.08px;
1344
- line-height: 20px;
1345
- text-transform: none;
1346
- font-family: "Inter", sans-serif;
1347
- }
1348
-
1349
- h1 {
1350
- font-size: 1.5rem;
1351
- }
1352
-
1353
- .app {
1354
- padding: 20px;
1355
- }
1356
- ```
1357
-
1358
- **tsconfig.json**
1359
-
1360
- ```json
1361
- {
1362
- "include": ["./**/*"],
1363
- "compilerOptions": {
1364
- "strict": true,
1365
- "esModuleInterop": true,
1366
- "lib": ["dom", "es2015"],
1367
- "jsx": "react-jsx"
1368
- }
1369
- }
1370
- ```
1371
-
1372
- **/App.tsx**
1373
-
1374
- ```tsx
1375
- import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
1376
- import { InputDropdown, DropdownMenu, noop } from "@czi-sds/components";
1377
- import "./styles.css";
1378
-
1379
- const options = [
1380
- {
1381
- details: "Details",
1382
- name: "Menu Item 1",
1383
- },
1384
- {
1385
- details: "A very long Details for the second Menu Item",
1386
- name: "Menu Item 2",
1387
- },
1388
- {
1389
- name: "Menu Item 3",
1390
- },
1391
- ];
1392
-
1393
- function App() {
1394
- const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
1395
- const [open, setOpen] = useState(false);
1396
- const [details, setDetials] = useState<string>();
1397
- const [inputDropdownValue, setInputDropdownValue] = useState<string>();
1398
- const [value, setValue] = useState<
1399
- DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1400
- >(null);
1401
-
1402
- return (
1403
- <div className="app">
1404
- <InputDropdown
1405
- label="Label"
1406
- onClick={handleClick}
1407
- sdsStyle="rounded"
1408
- multiple={false}
1409
- value={inputDropdownValue}
1410
- />
1411
- <DropdownMenu
1412
- open={open}
1413
- anchorEl={anchorEl}
1414
- onClose={noop}
1415
- onChange={handleChange}
1416
- search={false}
1417
- multiple={false}
1418
- disableCloseOnSelect
1419
- options={options}
1420
- value={value}
1421
- onClickAway={handleClickAway}
1422
- />
1423
- </div>
1424
- );
1425
-
1426
- function handleClick(event: React.MouseEvent<HTMLElement>) {
1427
- if (open) {
1428
- setOpen(false);
1429
-
1430
- if (anchorEl) {
1431
- anchorEl.focus();
1432
- }
1433
-
1434
- setAnchorEl(null);
1435
- } else {
1436
- setAnchorEl(event.currentTarget);
1437
- setOpen(true);
1438
- }
1439
- }
1440
-
1441
- function handleChange(
1442
- _: React.SyntheticEvent<Element, Event>,
1443
- newValue: DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1444
- ) {
1445
- setOpen(false);
1446
- setValue(newValue);
1447
-
1448
- if (newValue) {
1449
- setInputDropdownValue(newValue.name);
1450
-
1451
- if (newValue?.details) setDetials(newValue?.details);
1452
- else setDetials(undefined);
1453
- } else {
1454
- setDetials(undefined);
1455
- setInputDropdownValue(undefined);
1456
- }
1457
- }
1458
-
1459
- function handleClickAway() {
1460
- if (open) {
1461
- setOpen(false);
1462
- }
1463
- }
1464
- }
1465
-
1466
- export default App;
1467
- ```
1468
-
1469
- **/index.tsx**
1470
-
1471
- ```tsx
1472
- import React from "react";
1473
- import { createRoot } from "react-dom/client";
1474
- import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
1475
- import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
1476
- import { Theme } from "@czi-sds/components";
1477
- import CssBaseline from "@mui/material/CssBaseline";
1478
- import useMediaQuery from "@mui/material/useMediaQuery";
1479
-
1480
- import App from "./App";
1481
-
1482
- const container = document.getElementById("root");
1483
- const root = createRoot(container!);
1484
-
1485
- const RootApp = () => {
1486
- const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
1487
- const theme = prefersDarkMode ? Theme("dark") : Theme("light");
1488
-
1489
- return (
1490
- <StyledEngineProvider injectFirst>
1491
- <ThemeProvider theme={theme}>
1492
- <EmotionThemeProvider theme={theme}>
1493
- <CssBaseline />
1494
- <App />
1495
- </EmotionThemeProvider>
1496
- </ThemeProvider>
1497
- </StyledEngineProvider>
1498
- );
1499
- };
1500
-
1501
- root.render(
1502
- <React.StrictMode>
1503
- <RootApp />
1504
- </React.StrictMode>
1505
- );
1506
- ```
1507
-
1508
- **/public/index.html**
1509
-
1510
- ```html
1511
- <!doctype html>
1512
- <html lang="en">
1513
- <head>
1514
- <meta charset="UTF-8" />
1515
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1516
- <link rel="preconnect" href="https://fonts.googleapis.com" />
1517
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1518
- <link
1519
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
1520
- rel="stylesheet"
1521
- />
1522
- <link
1523
- href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap"
1524
- rel="stylesheet"
1525
- />
1526
- </head>
1527
- <body>
1528
- <div id="root"></div>
1529
- </body>
1530
- </html>
1531
- ```
1532
-
1533
- **/package.json**
1534
-
1535
- ```json
1536
- {
1537
- "dependencies": {
1538
- "react": "^18.0.0",
1539
- "react-dom": "^18.0.0",
1540
- "react-scripts": "^4.0.0"
1541
- },
1542
- "devDependencies": {
1543
- "@types/react": "^18.0.0",
1544
- "@types/react-dom": "^18.0.0",
1545
- "typescript": "^4.0.0"
1546
- },
1547
- "main": "/index.tsx"
1548
- }
1549
- ```
1550
-
1551
- ---
1552
-
1553
- #### Minimal InputDropdown combined with a single-select Dropdown
1554
-
1555
- An example of the combined use of the value variation `InputDropdown` component and a single-select `Dropdown` component is shown below.
1556
-
1557
- > **Warning:** The `value` variant can not be used in conjunction with the multi-select Dropdowns. If you set `sdsType="value"` and `multiple="true"`, the component will default to showing a label and a counter instead.
1558
-
1559
- **/styles.css**
1560
-
1561
- ```css
1562
- body {
1563
- font-size: 13px;
1564
- font-weight: 400;
1565
- letter-spacing: 0.08px;
1566
- line-height: 20px;
1567
- text-transform: none;
1568
- font-family: "Inter", sans-serif;
1569
- }
1570
-
1571
- h1 {
1572
- font-size: 1.5rem;
1573
- }
1574
-
1575
- .app {
1576
- padding: 20px;
1577
- }
1578
- ```
1579
-
1580
- **tsconfig.json**
1581
-
1582
- ```json
1583
- {
1584
- "include": ["./**/*"],
1585
- "compilerOptions": {
1586
- "strict": true,
1587
- "esModuleInterop": true,
1588
- "lib": ["dom", "es2015"],
1589
- "jsx": "react-jsx"
1590
- }
1591
- }
1592
- ```
1593
-
1594
- **/App.tsx**
1595
-
1596
- ```tsx
1597
- import React, { SyntheticEvent, useState, useRef, useEffect } from "react";
1598
- import { InputDropdown, DropdownMenu, noop } from "@czi-sds/components";
1599
- import "./styles.css";
1600
-
1601
- const options = [
1602
- {
1603
- details: "Details",
1604
- name: "Menu Item 1",
1605
- },
1606
- {
1607
- details: "A very long Details for the second Menu Item",
1608
- name: "Menu Item 2",
1609
- },
1610
- {
1611
- name: "Menu Item 3",
1612
- },
1613
- ];
1614
-
1615
- function App() {
1616
- const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
1617
- const [open, setOpen] = useState(false);
1618
- const [details, setDetials] = useState<string>();
1619
- const [inputDropdownValue, setInputDropdownValue] = useState<string>();
1620
- const [value, setValue] = useState<
1621
- DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1622
- >(null);
1623
-
1624
- return (
1625
- <div className="app">
1626
- <InputDropdown
1627
- label="Label"
1628
- onClick={handleClick}
1629
- sdsType="value"
1630
- sdsStyle="minimal"
1631
- multiple={false}
1632
- details={details}
1633
- value={inputDropdownValue}
1634
- style={{ maxWidth: 250 }}
1635
- />
1636
- <DropdownMenu
1637
- open={open}
1638
- anchorEl={anchorEl}
1639
- onClose={noop}
1640
- onChange={handleChange}
1641
- search={false}
1642
- multiple={false}
1643
- disableCloseOnSelect
1644
- options={options}
1645
- value={value}
1646
- onClickAway={handleClickAway}
1647
- />
1648
- </div>
1649
- );
1650
-
1651
- function handleClick(event: React.MouseEvent<HTMLElement>) {
1652
- if (open) {
1653
- setOpen(false);
1654
-
1655
- if (anchorEl) {
1656
- anchorEl.focus();
1657
- }
1658
-
1659
- setAnchorEl(null);
1660
- } else {
1661
- setAnchorEl(event.currentTarget);
1662
- setOpen(true);
1663
- }
1664
- }
1665
-
1666
- function handleChange(
1667
- _: React.SyntheticEvent<Element, Event>,
1668
- newValue: DefaultDropdownMenuOption | DefaultDropdownMenuOption[] | null
1669
- ) {
1670
- setOpen(false);
1671
- setValue(newValue);
1672
-
1673
- if (newValue) {
1674
- setInputDropdownValue(newValue.name);
1675
-
1676
- if (newValue?.details) setDetials(newValue?.details);
1677
- else setDetials(undefined);
1678
- } else {
1679
- setDetials(undefined);
1680
- setInputDropdownValue(undefined);
1681
- }
1682
- }
1683
-
1684
- function handleClickAway() {
1685
- if (open) {
1686
- setOpen(false);
1687
- }
1688
- }
1689
- }
1690
-
1691
- export default App;
1692
- ```
1693
-
1694
- **/index.tsx**
1695
-
1696
- ```tsx
1697
- import React from "react";
1698
- import { createRoot } from "react-dom/client";
1699
- import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
1700
- import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
1701
- import { Theme } from "@czi-sds/components";
1702
- import CssBaseline from "@mui/material/CssBaseline";
1703
- import useMediaQuery from "@mui/material/useMediaQuery";
1704
-
1705
- import App from "./App";
1706
-
1707
- const container = document.getElementById("root");
1708
- const root = createRoot(container!);
1709
-
1710
- const RootApp = () => {
1711
- const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
1712
- const theme = prefersDarkMode ? Theme("dark") : Theme("light");
1713
-
1714
- return (
1715
- <StyledEngineProvider injectFirst>
1716
- <ThemeProvider theme={theme}>
1717
- <EmotionThemeProvider theme={theme}>
1718
- <CssBaseline />
1719
- <App />
1720
- </EmotionThemeProvider>
1721
- </ThemeProvider>
1722
- </StyledEngineProvider>
1723
- );
1724
- };
1725
-
1726
- root.render(
1727
- <React.StrictMode>
1728
- <RootApp />
1729
- </React.StrictMode>
1730
- );
1731
- ```
1732
-
1733
- **/public/index.html**
1734
-
1735
- ```html
1736
- <!doctype html>
1737
- <html lang="en">
1738
- <head>
1739
- <meta charset="UTF-8" />
1740
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1741
- <link rel="preconnect" href="https://fonts.googleapis.com" />
1742
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1743
- <link
1744
- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
1745
- rel="stylesheet"
1746
- />
1747
- <link
1748
- href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap"
1749
- rel="stylesheet"
1750
- />
1751
- </head>
1752
- <body>
1753
- <div id="root"></div>
1754
- </body>
1755
- </html>
1756
- ```
1757
-
1758
- **/package.json**
1759
-
1760
- ```json
1761
- {
1762
- "dependencies": {
1763
- "react": "^18.0.0",
1764
- "react-dom": "^18.0.0",
1765
- "react-scripts": "^4.0.0"
1766
- },
1767
- "devDependencies": {
1768
- "@types/react": "^18.0.0",
1769
- "@types/react-dom": "^18.0.0",
1770
- "typescript": "^4.0.0"
1771
- },
1772
- "main": "/index.tsx"
1773
- }
1774
- ```
1775
-
1776
- ---