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