@voxel51/voodo 2.11.0 → 2.12.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.
@@ -29,10 +29,8 @@ export declare namespace DropdownAnchor {
29
29
  type TopStart = typeof DropdownAnchor.TopStart;
30
30
  type TopEnd = typeof DropdownAnchor.TopEnd;
31
31
  }
32
- /**
33
- * Props for {@link Dropdown}.
34
- */
35
- export interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
32
+ /** The props every {@link Dropdown} takes, controlled or not. */
33
+ interface DropdownBaseProps extends HTMLAttributes<HTMLDivElement> {
36
34
  /**
37
35
  * The element that opens the dropdown when clicked.
38
36
  * Rendered inside the menu's trigger wrapper — any focusable element works.
@@ -59,6 +57,29 @@ export interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
59
57
  */
60
58
  disabled?: boolean;
61
59
  }
60
+ /**
61
+ * Props for {@link Dropdown}. `open` comes with `onOpenChange`: a menu given
62
+ * `open` alone could never close.
63
+ */
64
+ export type DropdownProps = DropdownBaseProps & ({
65
+ /** Uncontrolled: the trigger alone opens and closes the menu. */
66
+ open?: undefined;
67
+ /** Called when the menu opens or closes. */
68
+ onOpenChange?: (open: boolean) => void;
69
+ } | {
70
+ /**
71
+ * Whether the menu is open, for a menu its owner opens or holds open
72
+ * from code (a guided tour pointing into it, say). `disabled` wins:
73
+ * a disabled menu stays closed.
74
+ */
75
+ open: boolean;
76
+ /**
77
+ * Called when the menu asks to open or close: a trigger press, an
78
+ * item click, Escape or a click outside. A controlled menu changes
79
+ * only when `open` does, so the owner can keep it open through these.
80
+ */
81
+ onOpenChange: (open: boolean) => void;
82
+ });
62
83
  /**
63
84
  * A click-triggered menu component. Composes with the Menu primitives:
64
85
  * {@link MenuTextItem}, {@link MenuIconTextItem}, {@link MenuCheckItem},
@@ -91,14 +112,31 @@ export interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
91
112
  * </Dropdown>
92
113
  * ```
93
114
  *
115
+ * @example
116
+ * ```tsx
117
+ * // Held open from code: the owner decides, and ignores close requests
118
+ * // while a guide points into the menu
119
+ * const [open, setOpen] = useState(false);
120
+ * <Dropdown
121
+ * open={open || guideShowsMenu}
122
+ * onOpenChange={setOpen}
123
+ * trigger={<DropdownTrigger>Actions</DropdownTrigger>}
124
+ * >
125
+ * <MenuTextItem onClick={() => {}}>Rename</MenuTextItem>
126
+ * </Dropdown>
127
+ * ```
128
+ *
94
129
  * @param trigger The trigger element that opens the menu.
95
130
  * @param children Menu content — use the Menu* primitive components.
96
131
  * @param anchor Position of the menu panel relative to the trigger. See {@link DropdownAnchor}.
97
132
  * @param portal If `true` (the default), renders the panel in a portal above modals.
98
133
  * @param zIndex Explicit z-index for the panel; only applied when `portal` is `false`.
99
134
  * @param disabled If `true`, the menu cannot be opened.
135
+ * @param open Whether the menu is open, when its owner controls it; requires `onOpenChange`. Ignored while disabled.
136
+ * @param onOpenChange Called with the open state the menu asks for.
100
137
  * @param className `class` overrides for the root wrapper.
101
138
  * @param props Additional HTML properties for the root wrapper.
102
139
  */
103
140
  export declare const Dropdown: FC<DropdownProps>;
141
+ export {};
104
142
  //# sourceMappingURL=Dropdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,MAAM,EAAgB,MAAM,SAAS,CAAC;AAG/C;;;;;GAKG;AACH,eAAO,MAAM,cAAc;IACzB,gDAAgD;;IAEhD,gEAAgE;;IAEhE,+DAA+D;;IAE/D,gDAAgD;;IAEhD,gEAAgE;;IAEhE,+DAA+D;;CAEvD,CAAC;AACX,MAAM,MAAM,cAAc,GACxB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,EAAE,CAAC;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