frontile 0.18.0-alpha.8 → 0.18.0-alpha.9
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/declarations/components/collections/listbox/item.d.ts +1 -0
- package/declarations/components/collections/listbox/listbox.d.ts +1 -1
- package/declarations/components/forms/autocomplete.d.ts +402 -0
- package/declarations/components/forms/index.d.ts +1 -0
- package/declarations/template-registry.d.ts +2 -1
- package/declarations/utils/listManager.d.ts +7 -2
- package/dist/components/collections/listbox/item.js +4 -1
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/listbox/listbox.js.map +1 -1
- package/dist/components/forms/autocomplete.js +338 -0
- package/dist/components/forms/autocomplete.js.map +1 -0
- package/dist/components/forms/index.js +1 -0
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/forms/select.js +2 -2
- package/dist/components/forms/select.js.map +1 -1
- package/dist/forms.js +1 -0
- package/dist/forms.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/listManager.js +13 -5
- package/dist/utils/listManager.js.map +1 -1
- package/package.json +3 -3
|
@@ -28,7 +28,7 @@ interface ListboxSignature<T> {
|
|
|
28
28
|
autoActivateMode?: 'none' | 'first' | 'selected';
|
|
29
29
|
onAction?: (key: string) => void;
|
|
30
30
|
onSelectionChange?: (key: string[]) => void;
|
|
31
|
-
onActiveItemChange?: (key?: string) => void;
|
|
31
|
+
onActiveItemChange?: (key?: string, item?: ListItem) => void;
|
|
32
32
|
/**
|
|
33
33
|
* The appearance of each item
|
|
34
34
|
*
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type Owner from '@ember/owner';
|
|
3
|
+
import { type ListItem } from './native-select';
|
|
4
|
+
import { type ListboxSignature } from '../collections/listbox';
|
|
5
|
+
import { type AutocompleteSlots, type AutocompleteVariants, type SlotsToClasses } from '@frontile/theme';
|
|
6
|
+
import { type PopoverSignature, type ContentSignature } from '../overlays/popover';
|
|
7
|
+
import { type FormControlSharedArgs } from './form-control';
|
|
8
|
+
interface AutocompleteArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'flipOptions' | 'middleware' | 'shiftOptions' | 'offsetOptions' | 'strategy' | 'didClose'>, Pick<ListboxSignature<T>['Args'], 'appearance' | 'intent' | 'disabledKeys' | 'allowEmpty' | 'items' | 'onAction'>, Pick<ContentSignature['Args'], 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'transition'>, FormControlSharedArgs {
|
|
9
|
+
/**
|
|
10
|
+
* The currently selected key.
|
|
11
|
+
*
|
|
12
|
+
* Autocomplete is single-selection only — for a searchable multi-select,
|
|
13
|
+
* use `Select` with `@isFilterable` and `@selectionMode="multiple"`.
|
|
14
|
+
*
|
|
15
|
+
* **Data Flow:**
|
|
16
|
+
* - Pass this to set the initial selection
|
|
17
|
+
* - Update this in your `onSelectionChange` handler to maintain two-way binding
|
|
18
|
+
* - The component calls `onSelectionChange` whenever the user changes the selection
|
|
19
|
+
*/
|
|
20
|
+
selectedKey?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Callback fired when the selection changes.
|
|
23
|
+
*
|
|
24
|
+
* Update your `@selectedKey` state in this callback to maintain two-way binding.
|
|
25
|
+
*
|
|
26
|
+
* @param key - The newly selected key, or null if selection was cleared
|
|
27
|
+
*/
|
|
28
|
+
onSelectionChange?: (key: string | null) => void;
|
|
29
|
+
/**
|
|
30
|
+
* The unique identifier for the autocomplete component.
|
|
31
|
+
*/
|
|
32
|
+
id?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Defines the input size of the autocomplete.
|
|
35
|
+
*/
|
|
36
|
+
inputSize?: AutocompleteVariants['size'];
|
|
37
|
+
/**
|
|
38
|
+
* Defines the size of the popover dropdown.
|
|
39
|
+
* - 'sm': Small
|
|
40
|
+
* - 'md': Medium
|
|
41
|
+
* - 'lg': Large
|
|
42
|
+
* - 'trigger': Same size as the trigger
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue 'trigger'
|
|
45
|
+
*/
|
|
46
|
+
popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';
|
|
47
|
+
/**
|
|
48
|
+
* Custom classes to style different slots within the autocomplete component.
|
|
49
|
+
*/
|
|
50
|
+
classes?: SlotsToClasses<AutocompleteSlots>;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the autocomplete should close upon selecting an item.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue true
|
|
55
|
+
*/
|
|
56
|
+
closeOnItemSelect?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether scrolling should be blocked when the dropdown is open.
|
|
59
|
+
*
|
|
60
|
+
* @defaultValue true
|
|
61
|
+
*/
|
|
62
|
+
blockScroll?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the focus trap should be disabled when the dropdown is open.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue true
|
|
67
|
+
*/
|
|
68
|
+
disableFocusTrap?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The placeholder text displayed when the input is empty.
|
|
71
|
+
*/
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the autocomplete should be disabled, preventing user interaction.
|
|
75
|
+
*/
|
|
76
|
+
isDisabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* The text value of the input.
|
|
79
|
+
*
|
|
80
|
+
* Pass this together with `onInputChange` to control the input text externally,
|
|
81
|
+
* for example to implement server-side filtering.
|
|
82
|
+
*/
|
|
83
|
+
inputValue?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Callback fired whenever the user changes the input text.
|
|
86
|
+
*
|
|
87
|
+
* @param value - The current text of the input
|
|
88
|
+
*/
|
|
89
|
+
onInputChange?: (value: string) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Function to filter the items against the current input text.
|
|
92
|
+
* The default implementation performs a case-insensitive "contains" search.
|
|
93
|
+
*
|
|
94
|
+
* @param itemValue - The label of an item in the dropdown.
|
|
95
|
+
* @param inputValue - The user's input text.
|
|
96
|
+
* @returns A boolean indicating whether the item should be shown.
|
|
97
|
+
*/
|
|
98
|
+
filter?: (itemValue: string, inputValue: string) => boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Disables the built-in filtering, rendering `@items` as-is.
|
|
101
|
+
* Use together with `inputValue`/`onInputChange` when filtering happens
|
|
102
|
+
* outside of the component (e.g. server-side).
|
|
103
|
+
*
|
|
104
|
+
* @defaultValue false
|
|
105
|
+
*/
|
|
106
|
+
disableFiltering?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Async search function. When provided, the component calls it (debounced)
|
|
109
|
+
* as the user types and renders the resolved items, showing a loading
|
|
110
|
+
* spinner while the returned promise is pending. Stale responses are
|
|
111
|
+
* ignored (latest query wins). Built-in filtering is disabled; `@items`
|
|
112
|
+
* is used as the initial list before the first search.
|
|
113
|
+
*
|
|
114
|
+
* @param query - The current input text
|
|
115
|
+
* @returns The items matching the query
|
|
116
|
+
*/
|
|
117
|
+
onSearch?: (query: string) => Promise<T[]> | T[];
|
|
118
|
+
/**
|
|
119
|
+
* Debounce duration, in milliseconds, applied to `onSearch` calls.
|
|
120
|
+
*
|
|
121
|
+
* @defaultValue 250
|
|
122
|
+
*/
|
|
123
|
+
searchDebounce?: number;
|
|
124
|
+
/**
|
|
125
|
+
* When true, the text typed by the user is kept on blur/close even if it
|
|
126
|
+
* does not match any option. By default the input reverts to the selected
|
|
127
|
+
* item's label (or empty) when the dropdown closes without a selection.
|
|
128
|
+
*
|
|
129
|
+
* @defaultValue false
|
|
130
|
+
*/
|
|
131
|
+
allowsCustomValue?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* If true, the autocomplete will show a loading spinner instead of the dropdown icon.
|
|
134
|
+
* The spinner is also shown automatically while an `onSearch` promise is pending.
|
|
135
|
+
*/
|
|
136
|
+
isLoading?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* The name attribute for the autocomplete component, useful for form submissions.
|
|
139
|
+
*/
|
|
140
|
+
name?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Whether to include a clear button in the autocomplete component.
|
|
143
|
+
* If enabled, this allows users to clear the selection and input text.
|
|
144
|
+
* This option ignores the `allowEmpty` setting.
|
|
145
|
+
*
|
|
146
|
+
* @defaultValue false
|
|
147
|
+
*/
|
|
148
|
+
isClearable?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Controls pointer-events property of startContent.
|
|
151
|
+
* If you want to pass the click event to the input, set it to `none`.
|
|
152
|
+
*
|
|
153
|
+
* @defaultValue 'auto'
|
|
154
|
+
*/
|
|
155
|
+
startContentPointerEvents?: 'none' | 'auto';
|
|
156
|
+
/**
|
|
157
|
+
* Controls pointer-events property of endContent.
|
|
158
|
+
* Defaults to `none` to pass click events to the input. If your content
|
|
159
|
+
* needs to capture events, add the `pointer-events-auto` class to that element.
|
|
160
|
+
*
|
|
161
|
+
* @defaultValue 'none'
|
|
162
|
+
*/
|
|
163
|
+
endContentPointerEvents?: 'none' | 'auto';
|
|
164
|
+
/**
|
|
165
|
+
* If true, hides the empty content when there are no options available.
|
|
166
|
+
*
|
|
167
|
+
* @defaultValue false
|
|
168
|
+
*/
|
|
169
|
+
hideEmptyContent?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Message shown in the dropdown of an async autocomplete (`onSearch`)
|
|
172
|
+
* while the query is blank — e.g. "Type to search for an address…".
|
|
173
|
+
* Prompts the user to start typing when they open the dropdown by
|
|
174
|
+
* clicking. Also customizable via the `searchMessage` block.
|
|
175
|
+
*/
|
|
176
|
+
searchMessage?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Callback fired when the autocomplete component loses focus.
|
|
179
|
+
*/
|
|
180
|
+
onBlur?: () => void;
|
|
181
|
+
}
|
|
182
|
+
interface AutocompleteSignature<T> {
|
|
183
|
+
Args: AutocompleteArgs<T>;
|
|
184
|
+
Element: HTMLDivElement;
|
|
185
|
+
Blocks: ListboxSignature<T>['Blocks'] & {
|
|
186
|
+
/**
|
|
187
|
+
* Content to display at the **beginning** of the autocomplete component.
|
|
188
|
+
* This can be an icon, a label, or any custom UI element.
|
|
189
|
+
*/
|
|
190
|
+
startContent: [];
|
|
191
|
+
/**
|
|
192
|
+
* Content to display at the **end** of the autocomplete component.
|
|
193
|
+
* This can be an icon, a button, or any custom UI element.
|
|
194
|
+
*/
|
|
195
|
+
endContent: [];
|
|
196
|
+
/**
|
|
197
|
+
* The content to display when there are no matching options.
|
|
198
|
+
* If `hideEmptyContent` argument is true, this content will not be shown.
|
|
199
|
+
*/
|
|
200
|
+
emptyContent: [];
|
|
201
|
+
/**
|
|
202
|
+
* Message shown in the dropdown of an async autocomplete while the
|
|
203
|
+
* query is blank, prompting the user to start typing. Takes priority
|
|
204
|
+
* over the `searchMessage` argument.
|
|
205
|
+
*/
|
|
206
|
+
searchMessage: [];
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Autocomplete Component - a text input combined with a listbox popover,
|
|
211
|
+
* following the WAI-ARIA 1.2 combobox pattern.
|
|
212
|
+
*
|
|
213
|
+
* Users filter the options by typing (type-ahead). Options can come from a
|
|
214
|
+
* static list (built-in filtering), an externally filtered list
|
|
215
|
+
* (`disableFiltering` + `onInputChange`), or an async source (`onSearch`).
|
|
216
|
+
*
|
|
217
|
+
* Selection state follows the same two-way data binding pattern as `Select`:
|
|
218
|
+
* internal tracked state gives immediate UI updates, while `onSelectionChange`
|
|
219
|
+
* notifies the parent, whose arg updates sync back through modifiers.
|
|
220
|
+
*/
|
|
221
|
+
declare class Autocomplete<T = unknown> extends Component<AutocompleteSignature<T>> {
|
|
222
|
+
#private;
|
|
223
|
+
nodes: ListItem[];
|
|
224
|
+
isOpen: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Internal tracked selection state.
|
|
227
|
+
* Synced with @selectedKey via the updateSelectedKey modifier.
|
|
228
|
+
*/
|
|
229
|
+
_selectedKey: string | null;
|
|
230
|
+
/**
|
|
231
|
+
* The text the user has typed. `undefined` means the user is not editing,
|
|
232
|
+
* so the input displays the selected item's label instead.
|
|
233
|
+
*/
|
|
234
|
+
_inputValue?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Items resolved from the latest `onSearch` call. `undefined` until the
|
|
237
|
+
* first search resolves; `@items` is rendered in the meantime.
|
|
238
|
+
*/
|
|
239
|
+
asyncItems?: T[];
|
|
240
|
+
isSearchPending: boolean;
|
|
241
|
+
/** Element id of the currently active (highlighted) option, for aria-activedescendant. */
|
|
242
|
+
activeDescendant?: string;
|
|
243
|
+
/** The currently active (highlighted) option. */
|
|
244
|
+
activeItem?: ListItem;
|
|
245
|
+
/**
|
|
246
|
+
* Label of the selected key, captured at selection time. Needed in async
|
|
247
|
+
* mode, where the selected item may no longer be present in the currently
|
|
248
|
+
* rendered items (e.g. after search results are reset on close).
|
|
249
|
+
*/
|
|
250
|
+
selectedLabel?: string;
|
|
251
|
+
containerRef: {
|
|
252
|
+
current: HTMLDivElement | undefined;
|
|
253
|
+
"__#8@#onChange"?: ((el: HTMLDivElement | undefined) => void) | undefined;
|
|
254
|
+
setup: import("ember-modifier").FunctionBasedModifier<{
|
|
255
|
+
Args: {
|
|
256
|
+
Positional: unknown[];
|
|
257
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
258
|
+
};
|
|
259
|
+
Element: HTMLDivElement;
|
|
260
|
+
}>;
|
|
261
|
+
};
|
|
262
|
+
triggerRef: {
|
|
263
|
+
current: HTMLInputElement | undefined;
|
|
264
|
+
"__#8@#onChange"?: ((el: HTMLInputElement | undefined) => void) | undefined;
|
|
265
|
+
setup: import("ember-modifier").FunctionBasedModifier<{
|
|
266
|
+
Args: {
|
|
267
|
+
Positional: unknown[];
|
|
268
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
269
|
+
};
|
|
270
|
+
Element: HTMLInputElement;
|
|
271
|
+
}>;
|
|
272
|
+
};
|
|
273
|
+
constructor(owner: Owner, args: AutocompleteArgs<T>);
|
|
274
|
+
willDestroy(): void;
|
|
275
|
+
onSelectionChange: (keys: string[]) => void;
|
|
276
|
+
onNativeSelectionChange: (key: string | null) => void;
|
|
277
|
+
applySelection(key: string | null): void;
|
|
278
|
+
onOpenChange: (isOpen: boolean) => void;
|
|
279
|
+
onInput: (event: Event) => void;
|
|
280
|
+
setInputValue(value: string): void;
|
|
281
|
+
/** Cancels any in-flight search and restores the default `@items`. */
|
|
282
|
+
resetSearch(): void;
|
|
283
|
+
clearInputValue(): void;
|
|
284
|
+
performSearch(query: string): Promise<void>;
|
|
285
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
286
|
+
/** Current selection as an array, for the Listbox / NativeSelect API. */
|
|
287
|
+
get selectedKeys(): string[];
|
|
288
|
+
get blockScroll(): boolean;
|
|
289
|
+
get disableFocusTrap(): boolean;
|
|
290
|
+
onAction: (key: string) => void;
|
|
291
|
+
handleBlur: () => void;
|
|
292
|
+
clearSelectedKeys: () => void;
|
|
293
|
+
onItemsChange: (nodes: ListItem[], _: "add" | "remove") => void;
|
|
294
|
+
didClose: () => void;
|
|
295
|
+
onActiveItemChange: (_key?: string, item?: ListItem) => void;
|
|
296
|
+
get selectedTextValue(): string;
|
|
297
|
+
get inputValue(): string;
|
|
298
|
+
get isFiltering(): boolean;
|
|
299
|
+
get backdrop(): "blur" | "transparent" | "none" | "faded";
|
|
300
|
+
get classes(): {
|
|
301
|
+
base: (slotProps?: ({
|
|
302
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
303
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
304
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
305
|
+
hasStartContent?: boolean | undefined;
|
|
306
|
+
hasEndContent?: boolean | undefined;
|
|
307
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
308
|
+
innerContainer: (slotProps?: ({
|
|
309
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
310
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
311
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
312
|
+
hasStartContent?: boolean | undefined;
|
|
313
|
+
hasEndContent?: boolean | undefined;
|
|
314
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
315
|
+
startContent: (slotProps?: ({
|
|
316
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
317
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
318
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
319
|
+
hasStartContent?: boolean | undefined;
|
|
320
|
+
hasEndContent?: boolean | undefined;
|
|
321
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
322
|
+
endContent: (slotProps?: ({
|
|
323
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
324
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
325
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
326
|
+
hasStartContent?: boolean | undefined;
|
|
327
|
+
hasEndContent?: boolean | undefined;
|
|
328
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
329
|
+
input: (slotProps?: ({
|
|
330
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
331
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
332
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
333
|
+
hasStartContent?: boolean | undefined;
|
|
334
|
+
hasEndContent?: boolean | undefined;
|
|
335
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
336
|
+
} & {
|
|
337
|
+
base: (slotProps?: ({
|
|
338
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
339
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
340
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
341
|
+
hasStartContent?: boolean | undefined;
|
|
342
|
+
hasEndContent?: boolean | undefined;
|
|
343
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
344
|
+
listbox: (slotProps?: ({
|
|
345
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
346
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
347
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
348
|
+
hasStartContent?: boolean | undefined;
|
|
349
|
+
hasEndContent?: boolean | undefined;
|
|
350
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
351
|
+
icon: (slotProps?: ({
|
|
352
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
353
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
354
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
355
|
+
hasStartContent?: boolean | undefined;
|
|
356
|
+
hasEndContent?: boolean | undefined;
|
|
357
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
358
|
+
clearButton: (slotProps?: ({
|
|
359
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
360
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
361
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
362
|
+
hasStartContent?: boolean | undefined;
|
|
363
|
+
hasEndContent?: boolean | undefined;
|
|
364
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
365
|
+
input: (slotProps?: ({
|
|
366
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
367
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
368
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
369
|
+
hasStartContent?: boolean | undefined;
|
|
370
|
+
hasEndContent?: boolean | undefined;
|
|
371
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
372
|
+
emptyContent: (slotProps?: ({
|
|
373
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
374
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
375
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
376
|
+
hasStartContent?: boolean | undefined;
|
|
377
|
+
hasEndContent?: boolean | undefined;
|
|
378
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
379
|
+
} & {};
|
|
380
|
+
get isClearable(): boolean | undefined;
|
|
381
|
+
get isLoading(): boolean;
|
|
382
|
+
get filteredItems(): T[] | undefined;
|
|
383
|
+
/**
|
|
384
|
+
* True when an async autocomplete is open with a blank query and nothing
|
|
385
|
+
* to show — the moment to prompt the user to start typing.
|
|
386
|
+
*/
|
|
387
|
+
get isSearchPromptState(): boolean;
|
|
388
|
+
get showEmptyContent(): boolean;
|
|
389
|
+
get autoActivateMode(): 'first' | 'selected';
|
|
390
|
+
/**
|
|
391
|
+
* Syncs internal `_selectedKey` with external `@selectedKey` argument.
|
|
392
|
+
*/
|
|
393
|
+
updateSelectedKey: import("ember-modifier").FunctionBasedModifier<{
|
|
394
|
+
Args: {
|
|
395
|
+
Positional: [string | null | undefined];
|
|
396
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
397
|
+
};
|
|
398
|
+
Element: HTMLDivElement;
|
|
399
|
+
}>;
|
|
400
|
+
}
|
|
401
|
+
export { Autocomplete, type AutocompleteSignature };
|
|
402
|
+
export default Autocomplete;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Button, ButtonGroup, Chip, CloseButton, ToggleButton } from './components/buttons';
|
|
2
|
-
import type { Form, Checkbox, FormDescription, FormFeedback, Input, Label, NativeSelect, Select, Textarea, FormControl, RadioGroup, CheckboxGroup } from './components/forms';
|
|
2
|
+
import type { Form, Checkbox, FormDescription, FormFeedback, Input, Label, NativeSelect, Select, Autocomplete, Textarea, FormControl, RadioGroup, CheckboxGroup } from './components/forms';
|
|
3
3
|
import type { Listbox, Dropdown, Table, SimpleTable } from './components/collections';
|
|
4
4
|
import type { Overlay, Modal, Drawer, Popover } from './components/overlays';
|
|
5
5
|
import type { NotificationCard, NotificationsContainer } from './components/notifications';
|
|
@@ -19,6 +19,7 @@ export default interface Registry {
|
|
|
19
19
|
Label: typeof Label;
|
|
20
20
|
NativeSelect: typeof NativeSelect;
|
|
21
21
|
Select: typeof Select;
|
|
22
|
+
Autocomplete: typeof Autocomplete;
|
|
22
23
|
Textarea: typeof Textarea;
|
|
23
24
|
FormControl: typeof FormControl;
|
|
24
25
|
CheckboxGroup: typeof CheckboxGroup;
|
|
@@ -25,7 +25,7 @@ interface ListManagerArgs {
|
|
|
25
25
|
onAction?: (key: string) => void;
|
|
26
26
|
onSelectionChange?: (key: string[]) => void;
|
|
27
27
|
onListItemsChange?: (items: ListItem[], action: 'add' | 'remove') => void;
|
|
28
|
-
onActiveItemChange?: (key?: string) => void;
|
|
28
|
+
onActiveItemChange?: (key?: string, item?: ListItem) => void;
|
|
29
29
|
}
|
|
30
30
|
declare class ListManager {
|
|
31
31
|
#private;
|
|
@@ -70,5 +70,10 @@ declare function keyAndLabelForItem(item: unknown): {
|
|
|
70
70
|
key: string;
|
|
71
71
|
label: string;
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Default option-matching used by Select and Autocomplete:
|
|
75
|
+
* case-insensitive "contains".
|
|
76
|
+
*/
|
|
77
|
+
declare function defaultFilter(itemValue: string, filterValue: string): boolean;
|
|
73
78
|
export type { ListItem, ListItemArgs, SelectionMode, AutoActivateMode };
|
|
74
|
-
export { ListManager, keyAndLabelForItem };
|
|
79
|
+
export { ListManager, keyAndLabelForItem, defaultFilter };
|
|
@@ -12,6 +12,9 @@ import templateOnly from '@ember/component/template-only';
|
|
|
12
12
|
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../../runtime-BPCpkOf1-B5Lbloj7.js';
|
|
13
13
|
|
|
14
14
|
class ListboxItem extends Component {
|
|
15
|
+
// Stable element id so consumers (e.g. Autocomplete) can reference the
|
|
16
|
+
// option via aria-activedescendant.
|
|
17
|
+
itemId = `${guidFor(this)}-option`;
|
|
15
18
|
labelId = guidFor(this);
|
|
16
19
|
static {
|
|
17
20
|
decorateFieldV2(this.prototype, "listItem", [tracked]);
|
|
@@ -86,7 +89,7 @@ class ListboxItem extends Component {
|
|
|
86
89
|
return 'option';
|
|
87
90
|
}
|
|
88
91
|
static {
|
|
89
|
-
setComponentTemplate(precompileTemplate("\n <li {{this.manager.setupItem key=this.key textValue=@textValue onRegister=this.onRegister}} {{on \"click\" this.onClick}} role={{this.role}} aria-labelledby={{this.labelId}} tabindex={{this.tabindex}} data-active=\"{{this.listItem.isActive}}\" data-selected=\"{{this.listItem.isSelected}}\" data-test-id=\"listbox-item\" data-component=\"listbox-item\" data-key={{this.key}} aria-disabled={{if this.listItem.isDisabled \"true\"}} class={{this.classNames.base}} ...attributes>\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div class={{this.classNames.descriptionWrapper}}>\n <span data-test-id=\"listbox-item-label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n <span data-test-id=\"listbox-item-description\" class={{this.classNames.description}}>{{@description}}</span>\n </div>\n {{else}}\n <span data-test-id=\"listbox-item-label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <kbd data-test-id=\"listbox-item-shortcut\" class={{this.classNames.shortcut}}>{{@shortcut}}</kbd>\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-test-id=\"listbox-item-selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n ", {
|
|
92
|
+
setComponentTemplate(precompileTemplate("\n <li {{this.manager.setupItem key=this.key textValue=@textValue onRegister=this.onRegister}} {{on \"click\" this.onClick}} id={{this.itemId}} role={{this.role}} aria-labelledby={{this.labelId}} tabindex={{this.tabindex}} data-active=\"{{this.listItem.isActive}}\" data-selected=\"{{this.listItem.isSelected}}\" data-test-id=\"listbox-item\" data-component=\"listbox-item\" data-key={{this.key}} aria-disabled={{if this.listItem.isDisabled \"true\"}} class={{this.classNames.base}} ...attributes>\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div class={{this.classNames.descriptionWrapper}}>\n <span data-test-id=\"listbox-item-label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n <span data-test-id=\"listbox-item-description\" class={{this.classNames.description}}>{{@description}}</span>\n </div>\n {{else}}\n <span data-test-id=\"listbox-item-label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <kbd data-test-id=\"listbox-item-shortcut\" class={{this.classNames.shortcut}}>{{@shortcut}}</kbd>\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-test-id=\"listbox-item-selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n ", {
|
|
90
93
|
strictMode: true,
|
|
91
94
|
scope: () => ({
|
|
92
95
|
on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../../src/components/collections/listbox/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { guidFor } from '@ember/object/internals';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ListManager, ListItem } from '../../../utils/listManager';\n\nexport interface ListboxItemSignature {\n Args: {\n manager: ListManager;\n key: string;\n textValue?: string;\n description?: string;\n shortcut?: string;\n onClick?: () => void;\n class?: string;\n withDivider?: boolean;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'accent'\n | 'success'\n | 'warning'\n | 'danger';\n\n type?: 'menu' | 'listbox';\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [];\n selectedIcon: [];\n start: [];\n end: [];\n };\n}\n\nclass ListboxItem extends Component<ListboxItemSignature> {\n labelId = guidFor(this);\n @tracked listItem?: ListItem;\n\n get manager(): ListManager {\n assert(\n `ListboxItem does not have a listManager; Missing argument @manager`,\n this.args.manager\n );\n\n return this.args.manager;\n }\n\n get key(): string {\n assert(\n `Argument @key is undefined or null, @key must be provided in Listbox.Item component`,\n this.args.key\n );\n\n return this.args.key;\n }\n\n @action\n onRegister(item: ListItem) {\n this.listItem = item;\n }\n\n @action\n onClick(): void {\n if (this.listItem?.isDisabled) {\n return;\n }\n\n this.manager.selectItem(this.listItem);\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n }\n\n get tabindex() {\n if (this.listItem?.isActive || this.listItem?.isSelected) {\n return 0;\n }\n return -1;\n }\n\n get classNames() {\n const { listboxItem } = useStyles();\n\n const {\n base,\n descriptionWrapper,\n label,\n description,\n selectedIcon,\n shortcut\n } = listboxItem({\n appearance: this.args.appearance || 'default',\n intent: this.args.intent || 'default',\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return {\n base: base({ class: this.args.class }),\n descriptionWrapper: descriptionWrapper(),\n label: label(),\n description: description(),\n selectedIcon: selectedIcon(),\n shortcut: shortcut()\n };\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return 'menuitem';\n }\n return 'option';\n }\n\n <template>\n <li\n {{this.manager.setupItem\n key=this.key\n textValue=@textValue\n onRegister=this.onRegister\n }}\n {{on \"click\" this.onClick}}\n role={{this.role}}\n aria-labelledby={{this.labelId}}\n tabindex={{this.tabindex}}\n data-active=\"{{this.listItem.isActive}}\"\n data-selected=\"{{this.listItem.isSelected}}\"\n data-test-id=\"listbox-item\"\n data-component=\"listbox-item\"\n data-key={{this.key}}\n aria-disabled={{if this.listItem.isDisabled \"true\"}}\n class={{this.classNames.base}}\n ...attributes\n >\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div class={{this.classNames.descriptionWrapper}}>\n <span\n data-test-id=\"listbox-item-label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n <span\n data-test-id=\"listbox-item-description\"\n class={{this.classNames.description}}\n >{{@description}}</span>\n </div>\n {{else}}\n <span\n data-test-id=\"listbox-item-label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <kbd\n data-test-id=\"listbox-item-shortcut\"\n class={{this.classNames.shortcut}}\n >{{@shortcut}}</kbd>\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span\n data-test-id=\"listbox-item-selected-icon\"\n class={{this.classNames.selectedIcon}}\n >\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n </template>\n}\n\nconst CheckIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m4.5 12.75 6 6 9-13.5\"\n />\n </svg>\n</template>;\n\nexport { ListboxItem };\n"],"names":["ListboxItem","Component","
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../../src/components/collections/listbox/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { guidFor } from '@ember/object/internals';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ListManager, ListItem } from '../../../utils/listManager';\n\nexport interface ListboxItemSignature {\n Args: {\n manager: ListManager;\n key: string;\n textValue?: string;\n description?: string;\n shortcut?: string;\n onClick?: () => void;\n class?: string;\n withDivider?: boolean;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'accent'\n | 'success'\n | 'warning'\n | 'danger';\n\n type?: 'menu' | 'listbox';\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [];\n selectedIcon: [];\n start: [];\n end: [];\n };\n}\n\nclass ListboxItem extends Component<ListboxItemSignature> {\n // Stable element id so consumers (e.g. Autocomplete) can reference the\n // option via aria-activedescendant.\n itemId = `${guidFor(this)}-option`;\n labelId = guidFor(this);\n @tracked listItem?: ListItem;\n\n get manager(): ListManager {\n assert(\n `ListboxItem does not have a listManager; Missing argument @manager`,\n this.args.manager\n );\n\n return this.args.manager;\n }\n\n get key(): string {\n assert(\n `Argument @key is undefined or null, @key must be provided in Listbox.Item component`,\n this.args.key\n );\n\n return this.args.key;\n }\n\n @action\n onRegister(item: ListItem) {\n this.listItem = item;\n }\n\n @action\n onClick(): void {\n if (this.listItem?.isDisabled) {\n return;\n }\n\n this.manager.selectItem(this.listItem);\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n }\n\n get tabindex() {\n if (this.listItem?.isActive || this.listItem?.isSelected) {\n return 0;\n }\n return -1;\n }\n\n get classNames() {\n const { listboxItem } = useStyles();\n\n const {\n base,\n descriptionWrapper,\n label,\n description,\n selectedIcon,\n shortcut\n } = listboxItem({\n appearance: this.args.appearance || 'default',\n intent: this.args.intent || 'default',\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return {\n base: base({ class: this.args.class }),\n descriptionWrapper: descriptionWrapper(),\n label: label(),\n description: description(),\n selectedIcon: selectedIcon(),\n shortcut: shortcut()\n };\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return 'menuitem';\n }\n return 'option';\n }\n\n <template>\n <li\n {{this.manager.setupItem\n key=this.key\n textValue=@textValue\n onRegister=this.onRegister\n }}\n {{on \"click\" this.onClick}}\n id={{this.itemId}}\n role={{this.role}}\n aria-labelledby={{this.labelId}}\n tabindex={{this.tabindex}}\n data-active=\"{{this.listItem.isActive}}\"\n data-selected=\"{{this.listItem.isSelected}}\"\n data-test-id=\"listbox-item\"\n data-component=\"listbox-item\"\n data-key={{this.key}}\n aria-disabled={{if this.listItem.isDisabled \"true\"}}\n class={{this.classNames.base}}\n ...attributes\n >\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div class={{this.classNames.descriptionWrapper}}>\n <span\n data-test-id=\"listbox-item-label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n <span\n data-test-id=\"listbox-item-description\"\n class={{this.classNames.description}}\n >{{@description}}</span>\n </div>\n {{else}}\n <span\n data-test-id=\"listbox-item-label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <kbd\n data-test-id=\"listbox-item-shortcut\"\n class={{this.classNames.shortcut}}\n >{{@shortcut}}</kbd>\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span\n data-test-id=\"listbox-item-selected-icon\"\n class={{this.classNames.selectedIcon}}\n >\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n </template>\n}\n\nconst CheckIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m4.5 12.75 6 6 9-13.5\"\n />\n </svg>\n</template>;\n\nexport { ListboxItem };\n"],"names":["ListboxItem","Component","itemId","guidFor","labelId","g","prototype","tracked","i","void 0","manager","assert","args","key","onRegister","item","listItem","n","action","onClick","isDisabled","selectItem","tabindex","isActive","isSelected","classNames","listboxItem","useStyles","base","descriptionWrapper","label","description","selectedIcon","shortcut","appearance","intent","withDivider","class","role","type","setComponentTemplate","precompileTemplate","strictMode","scope","on","CheckIcon","Divider","templateOnly"],"mappings":";;;;;;;;;;;;;AAmDA,MAAMA,oBAAoBC,SAAA,CAAU;AAClC;AACA;AACAC,EAAAA,MAAA,GAAS,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAClCC,EAAAA,OAAA,GAAUD,OAAA,CAAQ,IAAI,CAAA;AAAE,EAAA;IAAAE,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,UAAA,EAAA,CACvBC,OAAA,CAAA,CAAA;AAAA;AAAA,EAAA,SAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,UAAA,CAAA,EAAAC,MAA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A,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.js","sources":["../../../../src/components/collections/listbox/listbox.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport {\n ListManager,\n keyAndLabelForItem,\n type SelectionMode,\n type ListItem\n} from '../../../utils/listManager';\nimport { ListboxItem, type ListboxItemSignature } from './item';\nimport { modifier } from 'ember-modifier';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<typeof ListboxItem, 'manager'>;\n\ninterface ListboxSignature<T> {\n Args: {\n /**\n * @default 'listbox'\n */\n type?: 'menu' | 'listbox';\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n items?: T[];\n class?: string;\n isKeyboardEventsEnabled?: boolean;\n\n /** The element to add keyboard events to.\n *\n * This does not respect the option `iskeyboardEventsEnabled`.\n * @defaultValue null\n */\n elementToAddKeyboardEvents?: HTMLElement;\n\n /**\n * @edefaultValue 'frist'\n */\n autoActivateMode?: 'none' | 'first' | 'selected';\n\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onActiveItemChange?: (key?: string) => void;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'accent'\n | 'success'\n | 'warning'\n | 'danger';\n };\n Element: HTMLUListElement;\n Blocks: {\n item: [{ item: T; key: string; label: string; Item: ItemCompBounded }];\n default: [{ Item: ItemCompBounded }];\n };\n}\n\nconst isInputElement = (\n target: EventTarget | null\n): target is HTMLInputElement => {\n return target instanceof HTMLInputElement;\n};\n\nconst isUndefined = (a: unknown) => typeof a === 'undefined';\n\nclass Listbox<T = unknown> extends Component<ListboxSignature<T>> {\n listManager = new ListManager({\n selectionMode: this.args.selectionMode,\n selectedKeys: this.args.selectedKeys,\n disabledKeys: this.args.disabledKeys,\n allowEmpty: this.args.allowEmpty,\n onSelectionChange: this.args.onSelectionChange,\n onAction: this.args.onAction,\n onActiveItemChange: this.args.onActiveItemChange,\n autoActivateMode: isUndefined(this.args.autoActivateMode)\n ? 'first'\n : this.args.autoActivateMode\n });\n\n handleKeyPress = (event: KeyboardEvent) => {\n if (isInputElement(event.target)) {\n if (event.key === 'Enter') {\n this.listManager.selectActiveItem();\n return;\n }\n } else {\n if (\n ['Enter', ' ', 'Space'].includes(event.key) &&\n this.listManager.searchKeys == ''\n ) {\n this.listManager.selectActiveItem();\n event.preventDefault();\n event.stopPropagation();\n return;\n } else if (event.key.length === 1) {\n this.listManager.search(event.key);\n return;\n }\n }\n };\n\n handleKeyDown = (event: KeyboardEvent) => {\n if (\n ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'].includes(\n event.key\n )\n ) {\n event.preventDefault();\n\n if (event.key === 'ArrowDown') {\n this.listManager.setNextOptionActive();\n } else if (event.key === 'ArrowUp') {\n this.listManager.setPreviousOptionActive();\n } else if (event.key === 'Home' || event.key === 'PageUp') {\n this.listManager.setFirstOptionActive();\n } else if (event.key === 'End' || event.key === 'PageDown') {\n this.listManager.setLastOptionActive();\n }\n }\n };\n\n onKeyPress = (event: KeyboardEvent) => {\n if (this.args.isKeyboardEventsEnabled) {\n this.handleKeyPress(event);\n }\n };\n\n onKeyDown = (event: KeyboardEvent) => {\n if (this.args.isKeyboardEventsEnabled) {\n this.handleKeyDown(event);\n }\n };\n\n setupEvents = modifier(\n (\n _el: HTMLElement,\n _: unknown[],\n args: { elementToAddKeyboardEvents?: HTMLElement }\n ) => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n args.elementToAddKeyboardEvents.addEventListener(\n 'keypress',\n this.handleKeyPress\n );\n }\n\n return () => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n args.elementToAddKeyboardEvents.removeEventListener(\n 'keypress',\n this.handleKeyPress\n );\n }\n };\n }\n );\n\n get classNames() {\n const { listbox } = useStyles();\n return listbox({ class: this.args.class });\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return this.args.type;\n }\n return 'listbox';\n }\n\n <template>\n <ul\n tabindex=\"0\"\n role={{this.role}}\n {{this.listManager.setup\n selectedKeys=@selectedKeys\n disabledKeys=@disabledKeys\n selectionMode=@selectionMode\n allowEmpty=@allowEmpty\n autoActivateMode=(if\n (isUndefined @autoActivateMode) \"first\" @autoActivateMode\n )\n }}\n {{on \"keypress\" this.onKeyPress}}\n {{on \"keydown\" this.onKeyDown}}\n {{this.setupEvents\n elementToAddKeyboardEvents=@elementToAddKeyboardEvents\n }}\n data-test-id=\"listbox\"\n data-component=\"listbox\"\n class={{this.classNames}}\n ...attributes\n >\n {{#each @items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{#if (has-block \"item\")}}\n {{yield\n (hash\n item=item\n key=keyLabel.key\n label=keyLabel.label\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n type=this.role\n key=keyLabel.key\n )\n )\n to=\"item\"\n }}\n {{else}}\n <ListboxItem\n @manager={{this.listManager}}\n @key={{keyLabel.key}}\n @appearance={{@appearance}}\n @intent={{@intent}}\n @type={{this.role}}\n >\n {{keyLabel.label}}\n </ListboxItem>\n {{/if}}\n {{/let}}\n {{/each}}\n\n {{yield\n (hash\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n type=this.role\n )\n )\n }}\n </ul>\n </template>\n}\n\nexport {\n Listbox,\n ListboxItem,\n type ListboxSignature,\n type ListboxItemSignature,\n type ListItem\n};\nexport default Listbox;\n"],"names":["isInputElement","target","HTMLInputElement","isUndefined","a","Listbox","Component","listManager","ListManager","selectionMode","args","selectedKeys","disabledKeys","allowEmpty","onSelectionChange","onAction","onActiveItemChange","autoActivateMode","handleKeyPress","event","key","selectActiveItem","includes","searchKeys","preventDefault","stopPropagation","length","search","handleKeyDown","setNextOptionActive","setPreviousOptionActive","setFirstOptionActive","setLastOptionActive","onKeyPress","isKeyboardEventsEnabled","onKeyDown","setupEvents","modifier","_el","_","elementToAddKeyboardEvents","addEventListener","removeEventListener","classNames","listbox","useStyles","class","role","type","setComponentTemplate","precompileTemplate","strictMode","scope","on","keyAndLabelForItem","hash","ListboxItem"],"mappings":";;;;;;;;;;AAuEA,MAAMA,iBACJC,MAA0B,IACf;EACX,OAAOA,MAAA,YAAkBC,gBAAA;AAC3B,CAAA;AAEA,MAAMC,cAAeC,CAAU,IAAK,OAAOA,CAAA,KAAM,WAAA;AAEjD,MAAMC,OAAA,SAA6BC,UAA2B;EAC5DC,WAAA,GAAc,IAAIC,WAAA,CAAY;AAC5BC,IAAAA,aAAA,EAAe,IAAI,CAACC,IAAI,CAACD,aAAa;AACtCE,IAAAA,YAAA,EAAc,IAAI,CAACD,IAAI,CAACC,YAAY;AACpCC,IAAAA,YAAA,EAAc,IAAI,CAACF,IAAI,CAACE,YAAY;AACpCC,IAAAA,UAAA,EAAY,IAAI,CAACH,IAAI,CAACG,UAAU;AAChCC,IAAAA,iBAAA,EAAmB,IAAI,CAACJ,IAAI,CAACI,iBAAiB;AAC9CC,IAAAA,QAAA,EAAU,IAAI,CAACL,IAAI,CAACK,QAAQ;AAC5BC,IAAAA,kBAAA,EAAoB,IAAI,CAACN,IAAI,CAACM,kBAAkB;AAChDC,IAAAA,gBAAA,EAAkBd,WAAA,CAAY,IAAI,CAACO,IAAI,CAACO,gBAAgB,CAAA,GACpD,OAAA,GACA,IAAI,CAACP,IAAI,CAACO;AAChB,GAAA,CAAA;EAEAC,cAAA,GAAkBC,KAAO,IAAA;AACvB,IAAA,IAAInB,cAAA,CAAemB,KAAA,CAAMlB,MAAM,CAAA,EAAG;AAChC,MAAA,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C1C,EAAA;EAEA,IAAIC,IAAAA,GAAO;AACT,IAAA,IAAI,IAAI,CAACrC,IAAI,CAACsC,IAAI,KAAK,MAAA,EAAQ;AAC7B,MAAA,OAAO,IAAI,CAACtC,IAAI,CAACsC,IAAI;AACvB,IAAA;AACA,IAAA,OAAO,SAAA;AACT,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,4vCAAA,EAoEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAjD,WAAA;QAAAkD,EAAA;QAAAC,kBAAA;QAAAC,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"listbox.js","sources":["../../../../src/components/collections/listbox/listbox.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport {\n ListManager,\n keyAndLabelForItem,\n type SelectionMode,\n type ListItem\n} from '../../../utils/listManager';\nimport { ListboxItem, type ListboxItemSignature } from './item';\nimport { modifier } from 'ember-modifier';\nimport type { WithBoundArgs } from '@glint/template';\n\ntype ItemCompBounded = WithBoundArgs<typeof ListboxItem, 'manager'>;\n\ninterface ListboxSignature<T> {\n Args: {\n /**\n * @default 'listbox'\n */\n type?: 'menu' | 'listbox';\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n items?: T[];\n class?: string;\n isKeyboardEventsEnabled?: boolean;\n\n /** The element to add keyboard events to.\n *\n * This does not respect the option `iskeyboardEventsEnabled`.\n * @defaultValue null\n */\n elementToAddKeyboardEvents?: HTMLElement;\n\n /**\n * @edefaultValue 'frist'\n */\n autoActivateMode?: 'none' | 'first' | 'selected';\n\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n\n /**\n * The appearance of each item\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The intent of each item\n */\n intent?:\n | 'default'\n | 'primary'\n | 'accent'\n | 'success'\n | 'warning'\n | 'danger';\n };\n Element: HTMLUListElement;\n Blocks: {\n item: [{ item: T; key: string; label: string; Item: ItemCompBounded }];\n default: [{ Item: ItemCompBounded }];\n };\n}\n\nconst isInputElement = (\n target: EventTarget | null\n): target is HTMLInputElement => {\n return target instanceof HTMLInputElement;\n};\n\nconst isUndefined = (a: unknown) => typeof a === 'undefined';\n\nclass Listbox<T = unknown> extends Component<ListboxSignature<T>> {\n listManager = new ListManager({\n selectionMode: this.args.selectionMode,\n selectedKeys: this.args.selectedKeys,\n disabledKeys: this.args.disabledKeys,\n allowEmpty: this.args.allowEmpty,\n onSelectionChange: this.args.onSelectionChange,\n onAction: this.args.onAction,\n onActiveItemChange: this.args.onActiveItemChange,\n autoActivateMode: isUndefined(this.args.autoActivateMode)\n ? 'first'\n : this.args.autoActivateMode\n });\n\n handleKeyPress = (event: KeyboardEvent) => {\n if (isInputElement(event.target)) {\n if (event.key === 'Enter') {\n this.listManager.selectActiveItem();\n return;\n }\n } else {\n if (\n ['Enter', ' ', 'Space'].includes(event.key) &&\n this.listManager.searchKeys == ''\n ) {\n this.listManager.selectActiveItem();\n event.preventDefault();\n event.stopPropagation();\n return;\n } else if (event.key.length === 1) {\n this.listManager.search(event.key);\n return;\n }\n }\n };\n\n handleKeyDown = (event: KeyboardEvent) => {\n if (\n ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'].includes(\n event.key\n )\n ) {\n event.preventDefault();\n\n if (event.key === 'ArrowDown') {\n this.listManager.setNextOptionActive();\n } else if (event.key === 'ArrowUp') {\n this.listManager.setPreviousOptionActive();\n } else if (event.key === 'Home' || event.key === 'PageUp') {\n this.listManager.setFirstOptionActive();\n } else if (event.key === 'End' || event.key === 'PageDown') {\n this.listManager.setLastOptionActive();\n }\n }\n };\n\n onKeyPress = (event: KeyboardEvent) => {\n if (this.args.isKeyboardEventsEnabled) {\n this.handleKeyPress(event);\n }\n };\n\n onKeyDown = (event: KeyboardEvent) => {\n if (this.args.isKeyboardEventsEnabled) {\n this.handleKeyDown(event);\n }\n };\n\n setupEvents = modifier(\n (\n _el: HTMLElement,\n _: unknown[],\n args: { elementToAddKeyboardEvents?: HTMLElement }\n ) => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.addEventListener(\n 'keydown',\n this.handleKeyDown\n );\n args.elementToAddKeyboardEvents.addEventListener(\n 'keypress',\n this.handleKeyPress\n );\n }\n\n return () => {\n if (args.elementToAddKeyboardEvents) {\n args.elementToAddKeyboardEvents.removeEventListener(\n 'keydown',\n this.handleKeyDown\n );\n args.elementToAddKeyboardEvents.removeEventListener(\n 'keypress',\n this.handleKeyPress\n );\n }\n };\n }\n );\n\n get classNames() {\n const { listbox } = useStyles();\n return listbox({ class: this.args.class });\n }\n\n get role() {\n if (this.args.type === 'menu') {\n return this.args.type;\n }\n return 'listbox';\n }\n\n <template>\n <ul\n tabindex=\"0\"\n role={{this.role}}\n {{this.listManager.setup\n selectedKeys=@selectedKeys\n disabledKeys=@disabledKeys\n selectionMode=@selectionMode\n allowEmpty=@allowEmpty\n autoActivateMode=(if\n (isUndefined @autoActivateMode) \"first\" @autoActivateMode\n )\n }}\n {{on \"keypress\" this.onKeyPress}}\n {{on \"keydown\" this.onKeyDown}}\n {{this.setupEvents\n elementToAddKeyboardEvents=@elementToAddKeyboardEvents\n }}\n data-test-id=\"listbox\"\n data-component=\"listbox\"\n class={{this.classNames}}\n ...attributes\n >\n {{#each @items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{#if (has-block \"item\")}}\n {{yield\n (hash\n item=item\n key=keyLabel.key\n label=keyLabel.label\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n type=this.role\n key=keyLabel.key\n )\n )\n to=\"item\"\n }}\n {{else}}\n <ListboxItem\n @manager={{this.listManager}}\n @key={{keyLabel.key}}\n @appearance={{@appearance}}\n @intent={{@intent}}\n @type={{this.role}}\n >\n {{keyLabel.label}}\n </ListboxItem>\n {{/if}}\n {{/let}}\n {{/each}}\n\n {{yield\n (hash\n Item=(component\n ListboxItem\n manager=this.listManager\n appearance=@appearance\n intent=@intent\n type=this.role\n )\n )\n }}\n </ul>\n </template>\n}\n\nexport {\n Listbox,\n ListboxItem,\n type ListboxSignature,\n type ListboxItemSignature,\n type ListItem\n};\nexport default Listbox;\n"],"names":["isInputElement","target","HTMLInputElement","isUndefined","a","Listbox","Component","listManager","ListManager","selectionMode","args","selectedKeys","disabledKeys","allowEmpty","onSelectionChange","onAction","onActiveItemChange","autoActivateMode","handleKeyPress","event","key","selectActiveItem","includes","searchKeys","preventDefault","stopPropagation","length","search","handleKeyDown","setNextOptionActive","setPreviousOptionActive","setFirstOptionActive","setLastOptionActive","onKeyPress","isKeyboardEventsEnabled","onKeyDown","setupEvents","modifier","_el","_","elementToAddKeyboardEvents","addEventListener","removeEventListener","classNames","listbox","useStyles","class","role","type","setComponentTemplate","precompileTemplate","strictMode","scope","on","keyAndLabelForItem","hash","ListboxItem"],"mappings":";;;;;;;;;;AAuEA,MAAMA,iBACJC,MAA0B,IACf;EACX,OAAOA,MAAA,YAAkBC,gBAAA;AAC3B,CAAA;AAEA,MAAMC,cAAeC,CAAU,IAAK,OAAOA,CAAA,KAAM,WAAA;AAEjD,MAAMC,OAAA,SAA6BC,UAA2B;EAC5DC,WAAA,GAAc,IAAIC,WAAA,CAAY;AAC5BC,IAAAA,aAAA,EAAe,IAAI,CAACC,IAAI,CAACD,aAAa;AACtCE,IAAAA,YAAA,EAAc,IAAI,CAACD,IAAI,CAACC,YAAY;AACpCC,IAAAA,YAAA,EAAc,IAAI,CAACF,IAAI,CAACE,YAAY;AACpCC,IAAAA,UAAA,EAAY,IAAI,CAACH,IAAI,CAACG,UAAU;AAChC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