@zag-js/combobox 0.48.0 → 0.50.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/dist/index.d.mts CHANGED
@@ -1,14 +1,15 @@
1
+ import { InteractOutsideHandlers } from '@zag-js/dismissable';
2
+ export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
1
3
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
4
  import { CollectionOptions, Collection, CollectionItem } from '@zag-js/collection';
3
5
  export { CollectionItem, CollectionOptions } from '@zag-js/collection';
4
6
  import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
5
7
  import * as _zag_js_core from '@zag-js/core';
6
8
  import { StateMachine } from '@zag-js/core';
7
- import { InteractOutsideHandlers } from '@zag-js/dismissable';
8
9
  import { PositioningOptions } from '@zag-js/popper';
9
10
  export { Placement, PositioningOptions } from '@zag-js/popper';
10
11
 
11
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "input" | "positioner" | "control" | "trigger" | "content" | "clearTrigger" | "item" | "itemText" | "itemIndicator" | "itemGroup" | "itemGroupLabel">;
12
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"input" | "label" | "content" | "item" | "root" | "positioner" | "control" | "trigger" | "clearTrigger" | "itemText" | "itemIndicator" | "itemGroup" | "itemGroupLabel">;
12
13
 
13
14
  declare const collection: {
14
15
  <T extends unknown>(options: CollectionOptions<T>): Collection<T>;
@@ -21,7 +22,7 @@ interface ValueChangeDetails<T extends CollectionItem = CollectionItem> {
21
22
  }
22
23
  interface HighlightChangeDetails<T extends CollectionItem = CollectionItem> {
23
24
  highlightedValue: string | null;
24
- highligtedItem: T | null;
25
+ highlightedItem: T | null;
25
26
  }
26
27
  interface InputValueChangeDetails {
27
28
  inputValue: string;
@@ -110,6 +111,8 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
110
111
  *
111
112
  * - `autohighlight`: The first focused item is highlighted as the user types
112
113
  * - `autocomplete`: Navigating the listbox with the arrow keys selects the item and the input is updated
114
+ *
115
+ * @default "none"
113
116
  */
114
117
  inputBehavior: "autohighlight" | "autocomplete" | "none";
115
118
  /**
@@ -118,6 +121,8 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
118
121
  * - `replace`: The selected item string is set as the input value
119
122
  * - `clear`: The input value is cleared
120
123
  * - `preserve`: The input value is preserved
124
+ *
125
+ * @default "replace"
121
126
  */
122
127
  selectionBehavior: "clear" | "replace" | "preserve";
123
128
  /**
@@ -126,10 +131,12 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
126
131
  autoFocus?: boolean;
127
132
  /**
128
133
  * Whether to open the combobox popup on initial click on the input
134
+ * @default false
129
135
  */
130
136
  openOnClick?: boolean;
131
137
  /**
132
138
  * Whether to show the combobox when the input value changes
139
+ * @default true
133
140
  */
134
141
  openOnChange?: boolean | ((details: InputValueChangeDetails) => boolean);
135
142
  /**
@@ -138,6 +145,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
138
145
  allowCustomValue?: boolean;
139
146
  /**
140
147
  * Whether to loop the keyboard navigation through the items
148
+ * @default true
141
149
  */
142
150
  loopFocus?: boolean;
143
151
  /**
@@ -183,6 +191,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
183
191
  getSelectionValue?: (details: SelectionValueDetails<T>) => string;
184
192
  /**
185
193
  * Whether to open the combobox on arrow key press
194
+ * @default true
186
195
  */
187
196
  openOnKeyPress: boolean;
188
197
  /**
@@ -190,15 +199,14 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
190
199
  */
191
200
  scrollToIndexFn?: (details: ScrollToIndexDetails) => void;
192
201
  /**
193
- * The underling `aria-haspopup` attribute to use for the combobox
194
- * - `listbox`: The combobox has a listbox popup (default)
195
- * - `dialog`: The combobox has a dialog popup. Useful when in select only mode
202
+ * Whether the combobox is a composed with other composite widgets like tabs
203
+ * @default true
196
204
  */
197
- popup: "listbox" | "dialog";
205
+ composite: boolean;
198
206
  /**
199
- * Whether to register this combobox as a dismissable layer
207
+ * Whether to disable registering this a dismissable layer
200
208
  */
201
- dismissable: boolean;
209
+ disableLayer?: boolean;
202
210
  }
203
211
  type UserDefinedContext<T extends CollectionItem = CollectionItem> = RequiredBy<PublicContext<T>, "id" | "collection">;
204
212
  type ComputedContext = Readonly<{
@@ -250,6 +258,12 @@ interface MachineState {
250
258
  }
251
259
  type State = StateMachine.State<MachineContext, MachineState>;
252
260
  type Send = StateMachine.Send<StateMachine.AnyEventObject>;
261
+ interface TriggerProps {
262
+ /**
263
+ * Whether the trigger is focusable
264
+ */
265
+ focusable?: boolean;
266
+ }
253
267
  interface ItemProps {
254
268
  /**
255
269
  * Whether hovering outside should clear the highlighted state
@@ -293,10 +307,6 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
293
307
  * Whether the combobox is open
294
308
  */
295
309
  open: boolean;
296
- /**
297
- * Whether the combobox input value is empty
298
- */
299
- inputEmpty: boolean;
300
310
  /**
301
311
  * The value of the combobox input
302
312
  */
@@ -312,7 +322,7 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
312
322
  /**
313
323
  * The value of the combobox input
314
324
  */
315
- highlightValue(value: string): void;
325
+ setHighlightValue(value: string): void;
316
326
  /**
317
327
  * The selected items
318
328
  */
@@ -375,7 +385,7 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
375
385
  positionerProps: T["element"];
376
386
  inputProps: T["input"];
377
387
  contentProps: T["element"];
378
- triggerProps: T["button"];
388
+ getTriggerProps(props?: TriggerProps): T["button"];
379
389
  clearTriggerProps: T["button"];
380
390
  listProps: T["element"];
381
391
  getItemProps(props: ItemProps): T["element"];
@@ -389,4 +399,4 @@ declare function connect<T extends PropTypes, V extends CollectionItem>(state: S
389
399
 
390
400
  declare function machine<T extends CollectionItem>(userContext: UserDefinedContext<T>): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
391
401
 
392
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type ItemGroupLabelProps, type ItemGroupProps, type ItemProps, type ItemState, type OpenChangeDetails, type ScrollToIndexDetails, type SelectionValueDetails, type ValueChangeDetails, anatomy, collection, connect, machine };
402
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type IntlTranslations, type ItemGroupLabelProps, type ItemGroupProps, type ItemProps, type ItemState, type OpenChangeDetails, type ScrollToIndexDetails, type SelectionValueDetails, type TriggerProps, type ValueChangeDetails, anatomy, collection, connect, machine };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
+ import { InteractOutsideHandlers } from '@zag-js/dismissable';
2
+ export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
1
3
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
4
  import { CollectionOptions, Collection, CollectionItem } from '@zag-js/collection';
3
5
  export { CollectionItem, CollectionOptions } from '@zag-js/collection';
4
6
  import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
5
7
  import * as _zag_js_core from '@zag-js/core';
6
8
  import { StateMachine } from '@zag-js/core';
7
- import { InteractOutsideHandlers } from '@zag-js/dismissable';
8
9
  import { PositioningOptions } from '@zag-js/popper';
9
10
  export { Placement, PositioningOptions } from '@zag-js/popper';
10
11
 
11
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "input" | "positioner" | "control" | "trigger" | "content" | "clearTrigger" | "item" | "itemText" | "itemIndicator" | "itemGroup" | "itemGroupLabel">;
12
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"input" | "label" | "content" | "item" | "root" | "positioner" | "control" | "trigger" | "clearTrigger" | "itemText" | "itemIndicator" | "itemGroup" | "itemGroupLabel">;
12
13
 
13
14
  declare const collection: {
14
15
  <T extends unknown>(options: CollectionOptions<T>): Collection<T>;
@@ -21,7 +22,7 @@ interface ValueChangeDetails<T extends CollectionItem = CollectionItem> {
21
22
  }
22
23
  interface HighlightChangeDetails<T extends CollectionItem = CollectionItem> {
23
24
  highlightedValue: string | null;
24
- highligtedItem: T | null;
25
+ highlightedItem: T | null;
25
26
  }
26
27
  interface InputValueChangeDetails {
27
28
  inputValue: string;
@@ -110,6 +111,8 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
110
111
  *
111
112
  * - `autohighlight`: The first focused item is highlighted as the user types
112
113
  * - `autocomplete`: Navigating the listbox with the arrow keys selects the item and the input is updated
114
+ *
115
+ * @default "none"
113
116
  */
114
117
  inputBehavior: "autohighlight" | "autocomplete" | "none";
115
118
  /**
@@ -118,6 +121,8 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
118
121
  * - `replace`: The selected item string is set as the input value
119
122
  * - `clear`: The input value is cleared
120
123
  * - `preserve`: The input value is preserved
124
+ *
125
+ * @default "replace"
121
126
  */
122
127
  selectionBehavior: "clear" | "replace" | "preserve";
123
128
  /**
@@ -126,10 +131,12 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
126
131
  autoFocus?: boolean;
127
132
  /**
128
133
  * Whether to open the combobox popup on initial click on the input
134
+ * @default false
129
135
  */
130
136
  openOnClick?: boolean;
131
137
  /**
132
138
  * Whether to show the combobox when the input value changes
139
+ * @default true
133
140
  */
134
141
  openOnChange?: boolean | ((details: InputValueChangeDetails) => boolean);
135
142
  /**
@@ -138,6 +145,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
138
145
  allowCustomValue?: boolean;
139
146
  /**
140
147
  * Whether to loop the keyboard navigation through the items
148
+ * @default true
141
149
  */
142
150
  loopFocus?: boolean;
143
151
  /**
@@ -183,6 +191,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
183
191
  getSelectionValue?: (details: SelectionValueDetails<T>) => string;
184
192
  /**
185
193
  * Whether to open the combobox on arrow key press
194
+ * @default true
186
195
  */
187
196
  openOnKeyPress: boolean;
188
197
  /**
@@ -190,15 +199,14 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
190
199
  */
191
200
  scrollToIndexFn?: (details: ScrollToIndexDetails) => void;
192
201
  /**
193
- * The underling `aria-haspopup` attribute to use for the combobox
194
- * - `listbox`: The combobox has a listbox popup (default)
195
- * - `dialog`: The combobox has a dialog popup. Useful when in select only mode
202
+ * Whether the combobox is a composed with other composite widgets like tabs
203
+ * @default true
196
204
  */
197
- popup: "listbox" | "dialog";
205
+ composite: boolean;
198
206
  /**
199
- * Whether to register this combobox as a dismissable layer
207
+ * Whether to disable registering this a dismissable layer
200
208
  */
201
- dismissable: boolean;
209
+ disableLayer?: boolean;
202
210
  }
203
211
  type UserDefinedContext<T extends CollectionItem = CollectionItem> = RequiredBy<PublicContext<T>, "id" | "collection">;
204
212
  type ComputedContext = Readonly<{
@@ -250,6 +258,12 @@ interface MachineState {
250
258
  }
251
259
  type State = StateMachine.State<MachineContext, MachineState>;
252
260
  type Send = StateMachine.Send<StateMachine.AnyEventObject>;
261
+ interface TriggerProps {
262
+ /**
263
+ * Whether the trigger is focusable
264
+ */
265
+ focusable?: boolean;
266
+ }
253
267
  interface ItemProps {
254
268
  /**
255
269
  * Whether hovering outside should clear the highlighted state
@@ -293,10 +307,6 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
293
307
  * Whether the combobox is open
294
308
  */
295
309
  open: boolean;
296
- /**
297
- * Whether the combobox input value is empty
298
- */
299
- inputEmpty: boolean;
300
310
  /**
301
311
  * The value of the combobox input
302
312
  */
@@ -312,7 +322,7 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
312
322
  /**
313
323
  * The value of the combobox input
314
324
  */
315
- highlightValue(value: string): void;
325
+ setHighlightValue(value: string): void;
316
326
  /**
317
327
  * The selected items
318
328
  */
@@ -375,7 +385,7 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
375
385
  positionerProps: T["element"];
376
386
  inputProps: T["input"];
377
387
  contentProps: T["element"];
378
- triggerProps: T["button"];
388
+ getTriggerProps(props?: TriggerProps): T["button"];
379
389
  clearTriggerProps: T["button"];
380
390
  listProps: T["element"];
381
391
  getItemProps(props: ItemProps): T["element"];
@@ -389,4 +399,4 @@ declare function connect<T extends PropTypes, V extends CollectionItem>(state: S
389
399
 
390
400
  declare function machine<T extends CollectionItem>(userContext: UserDefinedContext<T>): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
391
401
 
392
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type ItemGroupLabelProps, type ItemGroupProps, type ItemProps, type ItemState, type OpenChangeDetails, type ScrollToIndexDetails, type SelectionValueDetails, type ValueChangeDetails, anatomy, collection, connect, machine };
402
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type IntlTranslations, type ItemGroupLabelProps, type ItemGroupProps, type ItemProps, type ItemState, type OpenChangeDetails, type ScrollToIndexDetails, type SelectionValueDetails, type TriggerProps, type ValueChangeDetails, anatomy, collection, connect, machine };