@zendeskgarden/react-dropdowns 9.0.0-next.1 → 9.0.0-next.3

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 (94) hide show
  1. package/README.md +73 -69
  2. package/dist/index.cjs.js +1634 -1712
  3. package/dist/index.esm.js +1633 -1700
  4. package/dist/typings/context/useComboboxContext.d.ts +25 -0
  5. package/dist/typings/context/useFieldContext.d.ts +32 -0
  6. package/dist/typings/context/useItemContext.d.ts +14 -0
  7. package/dist/typings/context/useItemGroupContext.d.ts +15 -0
  8. package/dist/typings/context/useMenuContext.d.ts +23 -0
  9. package/dist/typings/context/useOptionContext.d.ts +14 -0
  10. package/dist/typings/elements/{Combobox → combobox}/Combobox.d.ts +0 -2
  11. package/dist/typings/elements/{Fields → combobox}/Label.d.ts +1 -1
  12. package/dist/typings/elements/{Menu/Items/MediaBody.d.ts → combobox/Listbox.d.ts} +2 -4
  13. package/dist/typings/elements/{Fields → combobox}/Message.d.ts +1 -1
  14. package/dist/typings/elements/{Menu/Items/HeaderItem.d.ts → combobox/OptGroup.d.ts} +2 -2
  15. package/dist/typings/elements/{Menu/Items/MediaItem.d.ts → combobox/Option.d.ts} +5 -2
  16. package/dist/typings/elements/{Menu/Items/HeaderIcon.d.ts → combobox/OptionMeta.d.ts} +1 -1
  17. package/dist/typings/elements/combobox/Tag.d.ts +15 -0
  18. package/dist/typings/elements/combobox/TagAvatar.d.ts +14 -0
  19. package/dist/typings/elements/combobox/TagGroup.d.ts +12 -0
  20. package/dist/typings/elements/combobox/utils.d.ts +38 -0
  21. package/dist/typings/elements/{Menu/Items → menu}/Item.d.ts +5 -2
  22. package/dist/typings/elements/{Menu/Items/AddItem.d.ts → menu/ItemGroup.d.ts} +2 -2
  23. package/dist/typings/elements/{Menu/Items → menu}/ItemMeta.d.ts +2 -2
  24. package/dist/typings/elements/{Menu → menu}/Menu.d.ts +0 -2
  25. package/dist/typings/elements/menu/MenuList.d.ts +12 -0
  26. package/dist/typings/elements/{Menu → menu}/Separator.d.ts +1 -1
  27. package/dist/typings/elements/menu/utils.d.ts +29 -0
  28. package/dist/typings/index.d.ts +18 -25
  29. package/dist/typings/types/index.d.ts +242 -121
  30. package/dist/typings/{styled/items/StyledItemIcon.d.ts → views/combobox/StyledCombobox.d.ts} +4 -6
  31. package/dist/typings/{styled/multiselect/StyledMultiselectItemWrapper.d.ts → views/combobox/StyledContainer.d.ts} +1 -1
  32. package/dist/typings/{styled/select/StyledSelect.d.ts → views/combobox/StyledField.d.ts} +1 -1
  33. package/dist/typings/views/combobox/StyledFloatingListbox.d.ts +18 -0
  34. package/dist/typings/views/combobox/StyledHint.d.ts +11 -0
  35. package/dist/typings/views/combobox/StyledInput.d.ts +20 -0
  36. package/dist/typings/{styled/items/StyledAddItem.d.ts → views/combobox/StyledInputGroup.d.ts} +2 -4
  37. package/dist/typings/views/combobox/StyledInputIcon.d.ts +20 -0
  38. package/dist/typings/views/combobox/StyledLabel.d.ts +11 -0
  39. package/dist/typings/views/combobox/StyledListbox.d.ts +17 -0
  40. package/dist/typings/{styled/items/StyledNextItem.d.ts → views/combobox/StyledListboxSeparator.d.ts} +2 -4
  41. package/dist/typings/views/combobox/StyledMessage.d.ts +11 -0
  42. package/dist/typings/views/combobox/StyledOptGroup.d.ts +14 -0
  43. package/dist/typings/views/combobox/StyledOption.d.ts +18 -0
  44. package/dist/typings/views/combobox/StyledOptionContent.d.ts +10 -0
  45. package/dist/typings/views/combobox/StyledOptionIcon.d.ts +12 -0
  46. package/dist/typings/views/combobox/StyledOptionMeta.d.ts +14 -0
  47. package/dist/typings/views/combobox/StyledOptionTypeIcon.d.ts +17 -0
  48. package/dist/typings/views/combobox/StyledTag.d.ts +17 -0
  49. package/dist/typings/views/combobox/StyledTagsButton.d.ts +16 -0
  50. package/dist/typings/views/combobox/StyledTrigger.d.ts +24 -0
  51. package/dist/typings/views/combobox/StyledValue.d.ts +21 -0
  52. package/dist/typings/views/index.d.ts +38 -0
  53. package/dist/typings/views/menu/StyledButton.d.ts +20 -0
  54. package/dist/typings/views/menu/StyledFloatingMenu.d.ts +13 -0
  55. package/dist/typings/{styled/items/StyledPreviousItem.d.ts → views/menu/StyledItem.d.ts} +4 -4
  56. package/dist/typings/views/menu/StyledItemContent.d.ts +13 -0
  57. package/dist/typings/views/menu/StyledItemGroup.d.ts +13 -0
  58. package/dist/typings/views/menu/StyledItemIcon.d.ts +14 -0
  59. package/dist/typings/{styled/items → views/menu}/StyledItemMeta.d.ts +5 -10
  60. package/dist/typings/views/menu/StyledItemTypeIcon.d.ts +14 -0
  61. package/dist/typings/views/menu/StyledMenu.d.ts +19 -0
  62. package/dist/typings/{styled → views}/menu/StyledSeparator.d.ts +7 -4
  63. package/package.json +16 -14
  64. package/dist/typings/elements/Autocomplete/Autocomplete.d.ts +0 -14
  65. package/dist/typings/elements/Dropdown/Dropdown.d.ts +0 -26
  66. package/dist/typings/elements/Menu/Items/MediaFigure.d.ts +0 -11
  67. package/dist/typings/elements/Menu/Items/NextItem.d.ts +0 -12
  68. package/dist/typings/elements/Menu/Items/PreviousItem.d.ts +0 -12
  69. package/dist/typings/elements/Multiselect/Multiselect.d.ts +0 -14
  70. package/dist/typings/elements/Select/Select.d.ts +0 -14
  71. package/dist/typings/elements/Trigger/Trigger.d.ts +0 -24
  72. package/dist/typings/styled/index.d.ts +0 -29
  73. package/dist/typings/styled/items/StyledItem.d.ts +0 -20
  74. package/dist/typings/styled/items/StyledNextIcon.d.ts +0 -12
  75. package/dist/typings/styled/items/StyledPreviousIcon.d.ts +0 -12
  76. package/dist/typings/styled/items/header/StyledHeaderIcon.d.ts +0 -14
  77. package/dist/typings/styled/items/header/StyledHeaderItem.d.ts +0 -16
  78. package/dist/typings/styled/items/media/StyledMediaBody.d.ts +0 -17
  79. package/dist/typings/styled/items/media/StyledMediaFigure.d.ts +0 -287
  80. package/dist/typings/styled/items/media/StyledMediaItem.d.ts +0 -13
  81. package/dist/typings/styled/menu/StyledMenu.d.ts +0 -20
  82. package/dist/typings/styled/menu/StyledMenuWrapper.d.ts +0 -16
  83. package/dist/typings/styled/multiselect/StyledMultiselectInput.d.ts +0 -22
  84. package/dist/typings/styled/multiselect/StyledMultiselectItemsContainer.d.ts +0 -16
  85. package/dist/typings/styled/multiselect/StyledMultiselectMoreAnchor.d.ts +0 -15
  86. package/dist/typings/styled/select/StyledFauxInput.d.ts +0 -22
  87. package/dist/typings/styled/select/StyledInput.d.ts +0 -15
  88. package/dist/typings/utils/garden-placements.d.ts +0 -26
  89. package/dist/typings/utils/useDropdownContext.d.ts +0 -28
  90. package/dist/typings/utils/useFieldContext.d.ts +0 -17
  91. package/dist/typings/utils/useItemContext.d.ts +0 -16
  92. package/dist/typings/utils/useMenuContext.d.ts +0 -17
  93. /package/dist/typings/elements/{Fields → combobox}/Field.d.ts +0 -0
  94. /package/dist/typings/elements/{Fields → combobox}/Hint.d.ts +0 -0
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # @zendeskgarden/react-dropdowns [![npm version](https://flat.badgen.net/npm/v/@zendeskgarden/react-dropdowns)](https://www.npmjs.com/package/@zendeskgarden/react-dropdowns)
1
+ # @zendeskgarden/react-dropdowns [![npm version][npm version badge]][npm version link]
2
2
 
3
- This package includes components relating to dropdowns in the
3
+ [npm version badge]: https://flat.badgen.net/npm/v/@zendeskgarden/react-dropdowns
4
+ [npm version link]: https://www.npmjs.com/package/@zendeskgarden/react-dropdowns
5
+
6
+ This package includes components related to dropdowns in the
4
7
  [Garden Design System](https://zendeskgarden.github.io/).
5
8
 
6
9
  ## Installation
@@ -12,85 +15,86 @@ npm install @zendeskgarden/react-dropdowns
12
15
  npm install react react-dom styled-components @zendeskgarden/react-theming
13
16
  ```
14
17
 
15
- ## Basic Example
18
+ ## Usage
19
+
20
+ ### Combobox
16
21
 
17
22
  ```jsx
18
23
  import { ThemeProvider } from '@zendeskgarden/react-theming';
19
- import { Dropdown, Menu, Item, Trigger } from '@zendeskgarden/react-dropdowns';
24
+ import { Field, Label, Combobox, Option } from '@zendeskgarden/react-dropdowns';
20
25
 
21
26
  /**
22
27
  * Place a `ThemeProvider` at the root of your React application
23
28
  */
24
29
  <ThemeProvider>
25
- <Dropdown onSelect={value => console.log(`Selected: ${value}`)}>
26
- <Trigger>
27
- <button>This triggers a menu</button>
28
- </Trigger>
29
- <Menu placement="end" hasArrow>
30
- <Item value="option-1">Option 1</Item>
31
- <Item value="option-2">Option 2</Item>
32
- <Item value="option-3">Option 3</Item>
33
- </Menu>
34
- </Dropdown>
30
+ <Field>
31
+ <Label>Combobox</Label>
32
+ <Combobox>
33
+ <Option value="One" />
34
+ <Option value="Two" />
35
+ <Option value="Three" />
36
+ </Combobox>
37
+ </Field>
35
38
  </ThemeProvider>;
36
39
  ```
37
40
 
38
- For all components within the `react-dropdowns` package, the menu layouts and
39
- implementations are interchangeable.
40
-
41
- Whether you're making a `Select`, `Autocomplete`, or a traditional `Menu` the `<Menu>` implementation
42
- will adapted to its consumer.
43
-
44
- ## Usage
45
-
46
- ### Overview
47
-
48
- The `react-dropdowns` package abstracts the common concepts of `Menus`, `Selects`, and `Autocompletes`
49
- into a common API. This includes consistent visuals, common keyboard interaction, and a fully accessible
50
- experience for sighted and non-sighted users.
51
-
52
- The customizations available within this can be broken into two groups: _placement / positioning_
53
- and _dropdown state_
54
-
55
- ### Placement / Positioning
56
-
57
- Internally, the `<Dropdown>` component uses [PopperJS](https://popper.js.org/popper-documentation.html)
58
- for its positioning calculations.
59
-
60
- The `<Menu>` component accepts all customizations regarding placement, boundaries, overflows,
61
- etc. via the `popperModifiers` prop.
41
+ Beyond this basic example, Garden's `Combobox` offers a comprehensive set of
42
+ WAI-ARIA compliant combobox features. Key capabilities include:
43
+
44
+ - **Controllable**: The `Combobox` functions in both [uncontrolled and
45
+ controlled](https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components)
46
+ modes. Controlled mode enables aspects, such as input value, selection value(s),
47
+ listbox expansion, and current option active index, to share and adapt to the
48
+ surrounding UI.
49
+ - **Autocomplete-able**: Denotes the `Combobox` with [list
50
+ autocomplete](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/).
51
+ Filtering implementation is left to the API consumer.
52
+ - **Selectable**: The `Combobox` API ensures the selection of one or more
53
+ listbox option values, while also supporting the W3C [no autocomplete
54
+ example](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-none/)
55
+ for use cases like search.
56
+ - **Multi-selectable**: This feature enables the `Combobox` to provide WAI-ARIA
57
+ [multi-select
58
+ listbox](https://www.w3.org/WAI/ARIA/apg/patterns/listbox/examples/listbox-rearrangeable/#ex2_label)
59
+ functionality with option-as-tag value rendering.
60
+ - **Non-editable**: The `Combobox` supports [select-only
61
+ mode](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/),
62
+ where the user cannot modify the `<input>`.
63
+ - **Filterable**: The `Combobox` offers various filtering methods for listbox
64
+ options. Details of the filtering implementation are left to the API consumer.
65
+ - **Markup-able**: The `Combobox` can convert input value text to rich HTML
66
+ markup on blur in single-selection mode.
67
+ - **Decorate-able**: The `Combobox` allows adding start and end media (SVG icons).
68
+ Certain features will replace end media with Garden's standard dropdown chevron
69
+ treatment.
70
+ - **Group-able**: The `Combobox` API utilizes fully accessible `<OptGroup>`
71
+ components for grouping, similar to the corresponding HTML element.
72
+ - **Compactible**: Like other form elements, the `Combobox` supports compact
73
+ sizing.
74
+ - **Field-able**: The `Combobox` builds on Garden’s Field API context to
75
+ establish accessible relationships with corresponding Label, Hint, and Message
76
+ components.
77
+ - **Validate-able**: The `Combobox` provides validation styling and
78
+ accessibility comparable to other Garden form components.
79
+ - **RTL theme-able**: Functionality displays and operates correctly for
80
+ left-to-right and right-to-left layouts.
81
+
82
+ ### Menu
62
83
 
63
84
  ```jsx
64
- /** Customize default overflow settings to position against the `viewport` */
65
- <Menu popperModifiers={{ preventOverflow: { boundariesElement: 'viewport' } }}>
66
- <Item value="item-1">Item 1</Item>
67
- <Item value="item-2">Item 2</Item>
68
- <Item value="item-3">Item 3</Item>
69
- </Menu>
70
- ```
71
-
72
- ### Dropdown State
73
-
74
- We use the [Downshift](https://github.com/downshift-js/downshift) render-prop library to
75
- handle our keyboard and accessibility logic.
76
-
77
- The following states can be controlled directly from the `<Dropdown>` component:
78
-
79
- - **isOpen** Whether the dropdown is currently open
80
- - **highlightedIndex** Which index is currently highlighted
81
- - **inputValue** The value of the input when it's used as an `Autocomplete`
82
- - **selectedItem** The currently selected item
83
- - **selectedItems** The currently selected items
84
-
85
- All other customizations may be provided directly to the Downshift provider
86
- via the `downshiftProps` prop.
87
-
88
- Downshift provides several advanced customization features that can be very helpful when
89
- customizing this component. The [stateReducer](https://github.com/downshift-js/downshift#statereducer)
90
- pattern is a common customization strategy.
85
+ import { ThemeProvider } from '@zendeskgarden/react-theming';
86
+ import { Menu, Item } from '@zendeskgarden/react-dropdowns';
91
87
 
92
- ### Server Side Rendering
88
+ /**
89
+ * Place a `ThemeProvider` at the root of your React application
90
+ */
91
+ <ThemeProvider>
92
+ <Menu button="Choose an item">
93
+ <Item value="item-01" label="One" />
94
+ <Item value="item-02" label="Two" />
95
+ <Item value="item-03" label="Three" />
96
+ </Menu>
97
+ </ThemeProvider>;
98
+ ```
93
99
 
94
- If you are using server side rendering you may need to [configure specific Downshift settings](https://github.com/downshift-js/downshift#resetidcounter).
95
- This package re-exports the Downshift `resetIdCounter` utility. It allows resetting the internal id
96
- counter which is used to generate unique ids for Downshift.
100
+ Visit [storybook](https://zendeskgarden.github.io/react-components) for live examples.