@zag-js/combobox 0.82.2 → 1.0.1
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 +80 -69
- package/dist/index.d.ts +80 -69
- package/dist/index.js +1164 -1089
- package/dist/index.mjs +1160 -1093
- package/package.json +18 -13
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from
|
|
|
3
3
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
4
4
|
import { CollectionOptions, ListCollection, CollectionItem } from '@zag-js/collection';
|
|
5
5
|
export { CollectionItem, CollectionOptions } from '@zag-js/collection';
|
|
6
|
-
import {
|
|
6
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
7
7
|
import * as _zag_js_core from '@zag-js/core';
|
|
8
|
-
import { Machine,
|
|
9
|
-
import { PositioningOptions } from '@zag-js/popper';
|
|
8
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
9
|
+
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
10
10
|
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
11
11
|
|
|
12
12
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "list" | "label" | "input" | "root" | "item" | "clearTrigger" | "control" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "positioner" | "trigger">;
|
|
@@ -55,23 +55,30 @@ type ElementIds = Partial<{
|
|
|
55
55
|
itemGroup(id: string | number): string;
|
|
56
56
|
itemGroupLabel(id: string | number): string;
|
|
57
57
|
}>;
|
|
58
|
-
interface
|
|
58
|
+
interface ComboboxProps<T extends CollectionItem = CollectionItem> extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* The controlled open state of the combobox
|
|
61
61
|
*/
|
|
62
62
|
open?: boolean | undefined;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* The initial open state of the combobox when rendered.
|
|
65
|
+
* Use when you don't need to control the open state of the combobox.
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
|
+
defaultOpen?: boolean | undefined;
|
|
67
68
|
/**
|
|
68
69
|
* The ids of the elements in the combobox. Useful for composition.
|
|
69
70
|
*/
|
|
70
71
|
ids?: ElementIds | undefined;
|
|
71
72
|
/**
|
|
72
|
-
* The
|
|
73
|
+
* The controlled value of the combobox's input
|
|
73
74
|
*/
|
|
74
|
-
inputValue
|
|
75
|
+
inputValue?: string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The initial value of the combobox's input when rendered.
|
|
78
|
+
* Use when you don't need to control the value of the combobox's input.
|
|
79
|
+
* @default ""
|
|
80
|
+
*/
|
|
81
|
+
defaultInputValue?: string | undefined;
|
|
75
82
|
/**
|
|
76
83
|
* The `name` attribute of the combobox's input. Useful for form submission
|
|
77
84
|
*/
|
|
@@ -102,13 +109,24 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
102
109
|
*/
|
|
103
110
|
placeholder?: string | undefined;
|
|
104
111
|
/**
|
|
105
|
-
* The
|
|
112
|
+
* The initial highlighted value of the combobox when rendered.
|
|
113
|
+
* Use when you don't need to control the highlighted value of the combobox.
|
|
106
114
|
*/
|
|
107
|
-
|
|
115
|
+
defaultHighlightedValue?: string | null | undefined;
|
|
108
116
|
/**
|
|
109
|
-
* The
|
|
117
|
+
* The controlled highlighted value of the combobox
|
|
110
118
|
*/
|
|
111
|
-
|
|
119
|
+
highlightedValue?: string | null | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* The controlled value of the combobox's selected items
|
|
122
|
+
*/
|
|
123
|
+
value?: string[] | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* The initial value of the combobox's selected items when rendered.
|
|
126
|
+
* Use when you don't need to control the value of the combobox's selected items.
|
|
127
|
+
* @default []
|
|
128
|
+
*/
|
|
129
|
+
defaultValue?: string[] | undefined;
|
|
112
130
|
/**
|
|
113
131
|
* Defines the auto-completion behavior of the combobox.
|
|
114
132
|
*
|
|
@@ -117,7 +135,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
117
135
|
*
|
|
118
136
|
* @default "none"
|
|
119
137
|
*/
|
|
120
|
-
inputBehavior
|
|
138
|
+
inputBehavior?: "autohighlight" | "autocomplete" | "none" | undefined;
|
|
121
139
|
/**
|
|
122
140
|
* The behavior of the combobox input when an item is selected
|
|
123
141
|
*
|
|
@@ -127,7 +145,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
127
145
|
*
|
|
128
146
|
* @default "replace"
|
|
129
147
|
*/
|
|
130
|
-
selectionBehavior
|
|
148
|
+
selectionBehavior?: "clear" | "replace" | "preserve" | undefined;
|
|
131
149
|
/**
|
|
132
150
|
* Whether to autofocus the input on mount
|
|
133
151
|
*/
|
|
@@ -153,8 +171,9 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
153
171
|
loopFocus?: boolean | undefined;
|
|
154
172
|
/**
|
|
155
173
|
* The positioning options to dynamically position the menu
|
|
174
|
+
* @default { placement: "bottom-start" }
|
|
156
175
|
*/
|
|
157
|
-
positioning
|
|
176
|
+
positioning?: PositioningOptions | undefined;
|
|
158
177
|
/**
|
|
159
178
|
* Function called when the input's value changes
|
|
160
179
|
*/
|
|
@@ -175,11 +194,11 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
175
194
|
/**
|
|
176
195
|
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
177
196
|
*/
|
|
178
|
-
translations
|
|
197
|
+
translations?: IntlTranslations | undefined;
|
|
179
198
|
/**
|
|
180
199
|
* The collection of items
|
|
181
200
|
*/
|
|
182
|
-
collection
|
|
201
|
+
collection?: ListCollection<T> | undefined;
|
|
183
202
|
/**
|
|
184
203
|
* Whether to allow multiple selection.
|
|
185
204
|
*
|
|
@@ -195,7 +214,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
195
214
|
* Whether to open the combobox on arrow key press
|
|
196
215
|
* @default true
|
|
197
216
|
*/
|
|
198
|
-
openOnKeyPress
|
|
217
|
+
openOnKeyPress?: boolean | undefined;
|
|
199
218
|
/**
|
|
200
219
|
* Function to scroll to a specific index
|
|
201
220
|
*/
|
|
@@ -204,7 +223,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
204
223
|
* Whether the combobox is a composed with other composite widgets like tabs
|
|
205
224
|
* @default true
|
|
206
225
|
*/
|
|
207
|
-
composite
|
|
226
|
+
composite?: boolean | undefined;
|
|
208
227
|
/**
|
|
209
228
|
* Whether to disable registering this a dismissable layer
|
|
210
229
|
*/
|
|
@@ -212,49 +231,36 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
212
231
|
/**
|
|
213
232
|
* Function to navigate to the selected item
|
|
214
233
|
*/
|
|
215
|
-
navigate
|
|
234
|
+
navigate?: ((details: NavigateDetails) => void) | undefined;
|
|
216
235
|
}
|
|
217
|
-
type
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}>;
|
|
243
|
-
interface PrivateContext<T extends CollectionItem = CollectionItem> {
|
|
244
|
-
/**
|
|
245
|
-
* The highlighted item
|
|
246
|
-
*/
|
|
247
|
-
highlightedItem: T | null;
|
|
248
|
-
}
|
|
249
|
-
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
250
|
-
}
|
|
251
|
-
interface MachineState {
|
|
252
|
-
value: "idle" | "focused" | "suggesting" | "interacting";
|
|
253
|
-
tags: "open" | "focused" | "idle" | "closed";
|
|
236
|
+
type PropsWithDefault = "openOnChange" | "openOnKeyPress" | "composite" | "navigate" | "loopFocus" | "positioning" | "openOnClick" | "openOnChange" | "inputBehavior" | "collection" | "selectionBehavior" | "closeOnSelect" | "translations" | "positioning";
|
|
237
|
+
interface ComboboxSchema<T extends CollectionItem = CollectionItem> {
|
|
238
|
+
props: RequiredBy<ComboboxProps<T>, PropsWithDefault>;
|
|
239
|
+
state: "idle" | "focused" | "suggesting" | "interacting";
|
|
240
|
+
tag: "open" | "focused" | "idle" | "closed";
|
|
241
|
+
context: {
|
|
242
|
+
value: string[];
|
|
243
|
+
inputValue: string;
|
|
244
|
+
highlightedValue: string | null;
|
|
245
|
+
currentPlacement?: Placement | undefined;
|
|
246
|
+
highlightedItem: T | null;
|
|
247
|
+
selectedItems: T[];
|
|
248
|
+
valueAsString: string;
|
|
249
|
+
};
|
|
250
|
+
computed: {
|
|
251
|
+
isInputValueEmpty: boolean;
|
|
252
|
+
isInteractive: boolean;
|
|
253
|
+
autoComplete: boolean;
|
|
254
|
+
autoHighlight: boolean;
|
|
255
|
+
hasSelectedItems: boolean;
|
|
256
|
+
};
|
|
257
|
+
event: EventObject;
|
|
258
|
+
action: string;
|
|
259
|
+
effect: string;
|
|
260
|
+
guard: string;
|
|
254
261
|
}
|
|
255
|
-
type
|
|
256
|
-
type
|
|
257
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
262
|
+
type ComboboxService<T extends CollectionItem = CollectionItem> = Service<ComboboxSchema<T>>;
|
|
263
|
+
type ComboboxMachine<T extends CollectionItem = CollectionItem> = Machine<ComboboxSchema<T>>;
|
|
258
264
|
interface TriggerProps {
|
|
259
265
|
/**
|
|
260
266
|
* Whether the trigger is focusable
|
|
@@ -295,7 +301,7 @@ interface ItemGroupProps {
|
|
|
295
301
|
interface ItemGroupLabelProps {
|
|
296
302
|
htmlFor: string;
|
|
297
303
|
}
|
|
298
|
-
interface
|
|
304
|
+
interface ComboboxApi<T extends PropTypes = PropTypes, V extends CollectionItem = CollectionItem> {
|
|
299
305
|
/**
|
|
300
306
|
* Whether the combobox is focused
|
|
301
307
|
*/
|
|
@@ -373,10 +379,6 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
|
|
|
373
379
|
* Function to toggle the combobox
|
|
374
380
|
*/
|
|
375
381
|
collection: ListCollection<V>;
|
|
376
|
-
/**
|
|
377
|
-
* Function to set the collection of items
|
|
378
|
-
*/
|
|
379
|
-
setCollection(collection: ListCollection<V>): void;
|
|
380
382
|
/**
|
|
381
383
|
* Function to set the positioning options
|
|
382
384
|
*/
|
|
@@ -405,8 +407,17 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
|
|
|
405
407
|
getItemGroupLabelProps(props: ItemGroupLabelProps): T["element"];
|
|
406
408
|
}
|
|
407
409
|
|
|
408
|
-
declare function connect<T extends PropTypes, V extends CollectionItem>(
|
|
410
|
+
declare function connect<T extends PropTypes, V extends CollectionItem>(service: ComboboxService<V>, normalize: NormalizeProps<T>): ComboboxApi<T, V>;
|
|
411
|
+
|
|
412
|
+
declare const machine: _zag_js_core.Machine<ComboboxSchema<any>>;
|
|
409
413
|
|
|
410
|
-
declare
|
|
414
|
+
declare const props: (keyof ComboboxProps<any>)[];
|
|
415
|
+
declare const splitProps: <Props extends Partial<ComboboxProps<any>>>(props: Props) => [Partial<ComboboxProps<any>>, Omit<Props, keyof ComboboxProps<any>>];
|
|
416
|
+
declare const itemGroupLabelProps: "htmlFor"[];
|
|
417
|
+
declare const splitItemGroupLabelProps: <Props extends ItemGroupLabelProps>(props: Props) => [ItemGroupLabelProps, Omit<Props, "htmlFor">];
|
|
418
|
+
declare const itemGroupProps: "id"[];
|
|
419
|
+
declare const splitItemGroupProps: <Props extends ItemGroupProps>(props: Props) => [ItemGroupProps, Omit<Props, "id">];
|
|
420
|
+
declare const itemProps: (keyof ItemProps)[];
|
|
421
|
+
declare const splitItemProps: <Props extends ItemProps>(props: Props) => [ItemProps, Omit<Props, keyof ItemProps>];
|
|
411
422
|
|
|
412
|
-
export { type
|
|
423
|
+
export { type ComboboxApi as Api, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type IntlTranslations, type ItemGroupLabelProps, type ItemGroupProps, type ItemProps, type ItemState, type ComboboxMachine as Machine, type NavigateDetails, type OpenChangeDetails, type ComboboxProps as Props, type ScrollToIndexDetails, type ComboboxService as Service, type TriggerProps, type ValueChangeDetails, anatomy, collection, connect, itemGroupLabelProps, itemGroupProps, itemProps, machine, props, splitItemGroupLabelProps, splitItemGroupProps, splitItemProps, splitProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from
|
|
|
3
3
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
4
4
|
import { CollectionOptions, ListCollection, CollectionItem } from '@zag-js/collection';
|
|
5
5
|
export { CollectionItem, CollectionOptions } from '@zag-js/collection';
|
|
6
|
-
import {
|
|
6
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
7
7
|
import * as _zag_js_core from '@zag-js/core';
|
|
8
|
-
import { Machine,
|
|
9
|
-
import { PositioningOptions } from '@zag-js/popper';
|
|
8
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
9
|
+
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
10
10
|
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
11
11
|
|
|
12
12
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "list" | "label" | "input" | "root" | "item" | "clearTrigger" | "control" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "positioner" | "trigger">;
|
|
@@ -55,23 +55,30 @@ type ElementIds = Partial<{
|
|
|
55
55
|
itemGroup(id: string | number): string;
|
|
56
56
|
itemGroupLabel(id: string | number): string;
|
|
57
57
|
}>;
|
|
58
|
-
interface
|
|
58
|
+
interface ComboboxProps<T extends CollectionItem = CollectionItem> extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* The controlled open state of the combobox
|
|
61
61
|
*/
|
|
62
62
|
open?: boolean | undefined;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* The initial open state of the combobox when rendered.
|
|
65
|
+
* Use when you don't need to control the open state of the combobox.
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
|
+
defaultOpen?: boolean | undefined;
|
|
67
68
|
/**
|
|
68
69
|
* The ids of the elements in the combobox. Useful for composition.
|
|
69
70
|
*/
|
|
70
71
|
ids?: ElementIds | undefined;
|
|
71
72
|
/**
|
|
72
|
-
* The
|
|
73
|
+
* The controlled value of the combobox's input
|
|
73
74
|
*/
|
|
74
|
-
inputValue
|
|
75
|
+
inputValue?: string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The initial value of the combobox's input when rendered.
|
|
78
|
+
* Use when you don't need to control the value of the combobox's input.
|
|
79
|
+
* @default ""
|
|
80
|
+
*/
|
|
81
|
+
defaultInputValue?: string | undefined;
|
|
75
82
|
/**
|
|
76
83
|
* The `name` attribute of the combobox's input. Useful for form submission
|
|
77
84
|
*/
|
|
@@ -102,13 +109,24 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
102
109
|
*/
|
|
103
110
|
placeholder?: string | undefined;
|
|
104
111
|
/**
|
|
105
|
-
* The
|
|
112
|
+
* The initial highlighted value of the combobox when rendered.
|
|
113
|
+
* Use when you don't need to control the highlighted value of the combobox.
|
|
106
114
|
*/
|
|
107
|
-
|
|
115
|
+
defaultHighlightedValue?: string | null | undefined;
|
|
108
116
|
/**
|
|
109
|
-
* The
|
|
117
|
+
* The controlled highlighted value of the combobox
|
|
110
118
|
*/
|
|
111
|
-
|
|
119
|
+
highlightedValue?: string | null | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* The controlled value of the combobox's selected items
|
|
122
|
+
*/
|
|
123
|
+
value?: string[] | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* The initial value of the combobox's selected items when rendered.
|
|
126
|
+
* Use when you don't need to control the value of the combobox's selected items.
|
|
127
|
+
* @default []
|
|
128
|
+
*/
|
|
129
|
+
defaultValue?: string[] | undefined;
|
|
112
130
|
/**
|
|
113
131
|
* Defines the auto-completion behavior of the combobox.
|
|
114
132
|
*
|
|
@@ -117,7 +135,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
117
135
|
*
|
|
118
136
|
* @default "none"
|
|
119
137
|
*/
|
|
120
|
-
inputBehavior
|
|
138
|
+
inputBehavior?: "autohighlight" | "autocomplete" | "none" | undefined;
|
|
121
139
|
/**
|
|
122
140
|
* The behavior of the combobox input when an item is selected
|
|
123
141
|
*
|
|
@@ -127,7 +145,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
127
145
|
*
|
|
128
146
|
* @default "replace"
|
|
129
147
|
*/
|
|
130
|
-
selectionBehavior
|
|
148
|
+
selectionBehavior?: "clear" | "replace" | "preserve" | undefined;
|
|
131
149
|
/**
|
|
132
150
|
* Whether to autofocus the input on mount
|
|
133
151
|
*/
|
|
@@ -153,8 +171,9 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
153
171
|
loopFocus?: boolean | undefined;
|
|
154
172
|
/**
|
|
155
173
|
* The positioning options to dynamically position the menu
|
|
174
|
+
* @default { placement: "bottom-start" }
|
|
156
175
|
*/
|
|
157
|
-
positioning
|
|
176
|
+
positioning?: PositioningOptions | undefined;
|
|
158
177
|
/**
|
|
159
178
|
* Function called when the input's value changes
|
|
160
179
|
*/
|
|
@@ -175,11 +194,11 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
175
194
|
/**
|
|
176
195
|
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
177
196
|
*/
|
|
178
|
-
translations
|
|
197
|
+
translations?: IntlTranslations | undefined;
|
|
179
198
|
/**
|
|
180
199
|
* The collection of items
|
|
181
200
|
*/
|
|
182
|
-
collection
|
|
201
|
+
collection?: ListCollection<T> | undefined;
|
|
183
202
|
/**
|
|
184
203
|
* Whether to allow multiple selection.
|
|
185
204
|
*
|
|
@@ -195,7 +214,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
195
214
|
* Whether to open the combobox on arrow key press
|
|
196
215
|
* @default true
|
|
197
216
|
*/
|
|
198
|
-
openOnKeyPress
|
|
217
|
+
openOnKeyPress?: boolean | undefined;
|
|
199
218
|
/**
|
|
200
219
|
* Function to scroll to a specific index
|
|
201
220
|
*/
|
|
@@ -204,7 +223,7 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
204
223
|
* Whether the combobox is a composed with other composite widgets like tabs
|
|
205
224
|
* @default true
|
|
206
225
|
*/
|
|
207
|
-
composite
|
|
226
|
+
composite?: boolean | undefined;
|
|
208
227
|
/**
|
|
209
228
|
* Whether to disable registering this a dismissable layer
|
|
210
229
|
*/
|
|
@@ -212,49 +231,36 @@ interface PublicContext<T extends CollectionItem = CollectionItem> extends Direc
|
|
|
212
231
|
/**
|
|
213
232
|
* Function to navigate to the selected item
|
|
214
233
|
*/
|
|
215
|
-
navigate
|
|
234
|
+
navigate?: ((details: NavigateDetails) => void) | undefined;
|
|
216
235
|
}
|
|
217
|
-
type
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}>;
|
|
243
|
-
interface PrivateContext<T extends CollectionItem = CollectionItem> {
|
|
244
|
-
/**
|
|
245
|
-
* The highlighted item
|
|
246
|
-
*/
|
|
247
|
-
highlightedItem: T | null;
|
|
248
|
-
}
|
|
249
|
-
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
250
|
-
}
|
|
251
|
-
interface MachineState {
|
|
252
|
-
value: "idle" | "focused" | "suggesting" | "interacting";
|
|
253
|
-
tags: "open" | "focused" | "idle" | "closed";
|
|
236
|
+
type PropsWithDefault = "openOnChange" | "openOnKeyPress" | "composite" | "navigate" | "loopFocus" | "positioning" | "openOnClick" | "openOnChange" | "inputBehavior" | "collection" | "selectionBehavior" | "closeOnSelect" | "translations" | "positioning";
|
|
237
|
+
interface ComboboxSchema<T extends CollectionItem = CollectionItem> {
|
|
238
|
+
props: RequiredBy<ComboboxProps<T>, PropsWithDefault>;
|
|
239
|
+
state: "idle" | "focused" | "suggesting" | "interacting";
|
|
240
|
+
tag: "open" | "focused" | "idle" | "closed";
|
|
241
|
+
context: {
|
|
242
|
+
value: string[];
|
|
243
|
+
inputValue: string;
|
|
244
|
+
highlightedValue: string | null;
|
|
245
|
+
currentPlacement?: Placement | undefined;
|
|
246
|
+
highlightedItem: T | null;
|
|
247
|
+
selectedItems: T[];
|
|
248
|
+
valueAsString: string;
|
|
249
|
+
};
|
|
250
|
+
computed: {
|
|
251
|
+
isInputValueEmpty: boolean;
|
|
252
|
+
isInteractive: boolean;
|
|
253
|
+
autoComplete: boolean;
|
|
254
|
+
autoHighlight: boolean;
|
|
255
|
+
hasSelectedItems: boolean;
|
|
256
|
+
};
|
|
257
|
+
event: EventObject;
|
|
258
|
+
action: string;
|
|
259
|
+
effect: string;
|
|
260
|
+
guard: string;
|
|
254
261
|
}
|
|
255
|
-
type
|
|
256
|
-
type
|
|
257
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
262
|
+
type ComboboxService<T extends CollectionItem = CollectionItem> = Service<ComboboxSchema<T>>;
|
|
263
|
+
type ComboboxMachine<T extends CollectionItem = CollectionItem> = Machine<ComboboxSchema<T>>;
|
|
258
264
|
interface TriggerProps {
|
|
259
265
|
/**
|
|
260
266
|
* Whether the trigger is focusable
|
|
@@ -295,7 +301,7 @@ interface ItemGroupProps {
|
|
|
295
301
|
interface ItemGroupLabelProps {
|
|
296
302
|
htmlFor: string;
|
|
297
303
|
}
|
|
298
|
-
interface
|
|
304
|
+
interface ComboboxApi<T extends PropTypes = PropTypes, V extends CollectionItem = CollectionItem> {
|
|
299
305
|
/**
|
|
300
306
|
* Whether the combobox is focused
|
|
301
307
|
*/
|
|
@@ -373,10 +379,6 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
|
|
|
373
379
|
* Function to toggle the combobox
|
|
374
380
|
*/
|
|
375
381
|
collection: ListCollection<V>;
|
|
376
|
-
/**
|
|
377
|
-
* Function to set the collection of items
|
|
378
|
-
*/
|
|
379
|
-
setCollection(collection: ListCollection<V>): void;
|
|
380
382
|
/**
|
|
381
383
|
* Function to set the positioning options
|
|
382
384
|
*/
|
|
@@ -405,8 +407,17 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
|
|
|
405
407
|
getItemGroupLabelProps(props: ItemGroupLabelProps): T["element"];
|
|
406
408
|
}
|
|
407
409
|
|
|
408
|
-
declare function connect<T extends PropTypes, V extends CollectionItem>(
|
|
410
|
+
declare function connect<T extends PropTypes, V extends CollectionItem>(service: ComboboxService<V>, normalize: NormalizeProps<T>): ComboboxApi<T, V>;
|
|
411
|
+
|
|
412
|
+
declare const machine: _zag_js_core.Machine<ComboboxSchema<any>>;
|
|
409
413
|
|
|
410
|
-
declare
|
|
414
|
+
declare const props: (keyof ComboboxProps<any>)[];
|
|
415
|
+
declare const splitProps: <Props extends Partial<ComboboxProps<any>>>(props: Props) => [Partial<ComboboxProps<any>>, Omit<Props, keyof ComboboxProps<any>>];
|
|
416
|
+
declare const itemGroupLabelProps: "htmlFor"[];
|
|
417
|
+
declare const splitItemGroupLabelProps: <Props extends ItemGroupLabelProps>(props: Props) => [ItemGroupLabelProps, Omit<Props, "htmlFor">];
|
|
418
|
+
declare const itemGroupProps: "id"[];
|
|
419
|
+
declare const splitItemGroupProps: <Props extends ItemGroupProps>(props: Props) => [ItemGroupProps, Omit<Props, "id">];
|
|
420
|
+
declare const itemProps: (keyof ItemProps)[];
|
|
421
|
+
declare const splitItemProps: <Props extends ItemProps>(props: Props) => [ItemProps, Omit<Props, keyof ItemProps>];
|
|
411
422
|
|
|
412
|
-
export { type
|
|
423
|
+
export { type ComboboxApi as Api, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type IntlTranslations, type ItemGroupLabelProps, type ItemGroupProps, type ItemProps, type ItemState, type ComboboxMachine as Machine, type NavigateDetails, type OpenChangeDetails, type ComboboxProps as Props, type ScrollToIndexDetails, type ComboboxService as Service, type TriggerProps, type ValueChangeDetails, anatomy, collection, connect, itemGroupLabelProps, itemGroupProps, itemProps, machine, props, splitItemGroupLabelProps, splitItemGroupProps, splitItemProps, splitProps };
|