@acusti/dropdown 1.0.0-alpha.1 → 1.0.0-alpha.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.
- package/README.md +46 -5
- package/dist/Dropdown.d.ts +8 -0
- package/dist/Dropdown.js +311 -235
- package/dist/Dropdown.js.map +1 -1
- package/dist/context.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -266,6 +266,14 @@ type Props = {
|
|
|
266
266
|
onMouseDown?: (event: React.MouseEvent<HTMLElement>) => unknown;
|
|
267
267
|
onMouseUp?: (event: React.MouseEvent<HTMLElement>) => unknown;
|
|
268
268
|
onOpen?: () => unknown;
|
|
269
|
+
/**
|
|
270
|
+
* Opens the dropdown when the pointer hovers the trigger, and closes it a
|
|
271
|
+
* short moment after the pointer leaves the trigger and body entirely (the
|
|
272
|
+
* close is delayed so crossing the gap between them, or pausing over
|
|
273
|
+
* either, doesn’t flicker-close it). Click and keyboard opening keep
|
|
274
|
+
* working as usual alongside it.
|
|
275
|
+
*/
|
|
276
|
+
openOnHover?: boolean;
|
|
269
277
|
/**
|
|
270
278
|
* Called when an item is selected. The payload includes:
|
|
271
279
|
* - element: The DOM element that was clicked
|
|
@@ -427,6 +435,29 @@ function MultiSelectDropdown() {
|
|
|
427
435
|
}
|
|
428
436
|
```
|
|
429
437
|
|
|
438
|
+
### Open on Hover
|
|
439
|
+
|
|
440
|
+
```tsx
|
|
441
|
+
function HoverMenu() {
|
|
442
|
+
return (
|
|
443
|
+
<Dropdown openOnHover>
|
|
444
|
+
<button type="button">Account</button>
|
|
445
|
+
<ul>
|
|
446
|
+
<li>Profile</li>
|
|
447
|
+
<li>Settings</li>
|
|
448
|
+
<li>Sign out</li>
|
|
449
|
+
</ul>
|
|
450
|
+
</Dropdown>
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Click and keyboard opening (Enter/Space while focused) still work —
|
|
456
|
+
hovering is an additional way in, not a replacement. This makes the most
|
|
457
|
+
sense for a dropdown whose body is inspectable at a glance (a short menu, a
|
|
458
|
+
preview card); for anything the user needs to click into, keep the default
|
|
459
|
+
click-to-open behavior so a stray hover doesn’t pop it open.
|
|
460
|
+
|
|
430
461
|
### Dropdown with Interactive Content
|
|
431
462
|
|
|
432
463
|
For dropdowns whose body is a form (inputs, date pickers, buttons that
|
|
@@ -645,9 +676,11 @@ Most props keep their meaning, scoped to the submenu:
|
|
|
645
676
|
- `className`/`style`: applied to the parent item element
|
|
646
677
|
|
|
647
678
|
Props that only make sense at the top level (`allowCreate`, `allowEmpty`,
|
|
648
|
-
`isOpenOnMount`, `isSearchable`, `keepOpenOnSubmit`, `name`, `
|
|
649
|
-
`tabIndex`, `value`) are ignored on a nested dropdown and
|
|
650
|
-
(unconditionally, matching the children-count misuse error).
|
|
679
|
+
`isOpenOnMount`, `isSearchable`, `keepOpenOnSubmit`, `name`, `openOnHover`,
|
|
680
|
+
`placeholder`, `tabIndex`, `value`) are ignored on a nested dropdown and
|
|
681
|
+
warn (unconditionally, matching the children-count misuse error). A submenu
|
|
682
|
+
already discloses on hover intent — see [Submenus](#submenus) — so
|
|
683
|
+
`openOnHover` has nothing to add there.
|
|
651
684
|
|
|
652
685
|
### Submenu placement and styling
|
|
653
686
|
|
|
@@ -766,8 +799,16 @@ Menubar behaviors:
|
|
|
766
799
|
|
|
767
800
|
- renders `role="menubar"`; each dropdown trigger is a menubar item
|
|
768
801
|
- at most one menu in the bar is open at a time
|
|
769
|
-
-
|
|
770
|
-
|
|
802
|
+
- opening a trigger’s menu (by click or keyboard) engages the bar
|
|
803
|
+
(menu-mode). While engaged, hovering or focusing another trigger switches
|
|
804
|
+
to that menu without a click, matching the macOS menu bar
|
|
805
|
+
- while engaged, hovering a non-menu control in the bar (e.g. a plain
|
|
806
|
+
button placed alongside the dropdowns) closes the open menu but keeps the
|
|
807
|
+
bar engaged, so hovering back onto a trigger reopens a menu; sliding
|
|
808
|
+
across the gaps between triggers leaves the open menu alone
|
|
809
|
+
- a deliberate dismissal — **Escape**, a click outside the bar, or
|
|
810
|
+
selecting an item — leaves menu-mode, after which hovering a trigger no
|
|
811
|
+
longer opens its menu until a menu is opened again to re-engage the bar
|
|
771
812
|
- **←/→** move between menus, wrapping at the ends: with the bar focused
|
|
772
813
|
they move focus between triggers, and while a menu is open they slide the
|
|
773
814
|
open menu to the adjacent trigger — unless the active item is a parent
|
package/dist/Dropdown.d.ts
CHANGED
|
@@ -57,6 +57,14 @@ export type Props = {
|
|
|
57
57
|
onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;
|
|
58
58
|
onOpen?: () => unknown;
|
|
59
59
|
onSubmitItem?: (payload: Item) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Opens the dropdown when the pointer hovers the trigger, and closes it a
|
|
62
|
+
* short moment after the pointer leaves the trigger and body entirely (the
|
|
63
|
+
* close is delayed so crossing the gap between them, or pausing over
|
|
64
|
+
* either, doesn’t flicker-close it). Click and keyboard opening keep
|
|
65
|
+
* working as usual alongside it.
|
|
66
|
+
*/
|
|
67
|
+
openOnHover?: boolean;
|
|
60
68
|
/**
|
|
61
69
|
* Only usable in conjunction with {isSearchable: true}.
|
|
62
70
|
* Used as search input’s placeholder.
|