@internetarchive/elements 0.1.1-webdev-8119.1 → 0.1.1-webdev-8151.2

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.
@@ -1,427 +0,0 @@
1
- import { LitElement, nothing, TemplateResult, CSSResultGroup, PropertyValues } from 'lit';
2
- import { type IAComboBoxBehavior, type IAComboBoxFilterOption, type IAComboBoxOption } from './models';
3
- /**
4
- * A flexible component combining the features of a dropdown menu and a text input,
5
- * allowing users to either select from a predefined list of options or type
6
- * freeform text to filter down & find specific options.
7
- */
8
- export declare class IAComboBox extends LitElement {
9
- /**
10
- * Array of options representing values that this combo box can take.
11
- *
12
- * If this combo box's `behavior` property is `select-only` or `list`, these options
13
- * represent _all_ of the allowed values that the user may choose from.
14
- *
15
- * If this combo box's `behavior` property is `freeform`, this array simply represents
16
- * a non-exhaustive list of _suggested_ values, which the user may either choose from
17
- * or enter their own value.
18
- * @see {@linkcode IAComboBox.behavior}
19
- */
20
- options: IAComboBoxOption[];
21
- /**
22
- * Optional placeholder text to display in the combo box when no option is selected.
23
- */
24
- placeholder?: string;
25
- /**
26
- * What style of behavior to use for the combo box.
27
- *
28
- * Currently, the options are
29
- * - `select-only` (behaving similar to a `<select>`, disallowing text entry and only
30
- * allowing selection from the predefined, unfiltered options)
31
- * - `list` (the default, allowing text entry to filter the dropdown list, but still
32
- * requiring values to be set from the predefined options)
33
- * - `freeform` (allows text entry to filter the dropdown list, and also allows setting
34
- * custom values not included in the list)
35
- */
36
- behavior: IAComboBoxBehavior;
37
- /**
38
- * Maximum number of options to include in the autocomplete menu when filtering.
39
- *
40
- * Default value is `Infinity`, presenting all matching options regardless of count.
41
- */
42
- maxAutocompleteEntries: number;
43
- /**
44
- * Specifies how the options should be filtered when text is entered into the combo box.
45
- * Has no effect if `behavior` is `select-only`, as the component is not text-editable.
46
- *
47
- * Default is `substring`, showing only options whose `text` contains the value entered
48
- * as a substring at any position. The possible preset options are:
49
- * - `all`: Does not filter the dropdown entries. They will always all be shown (up to
50
- * the limit specified by `maxAutocompleteEntries`).
51
- * - `prefix`: Only includes options whose text _starts_ with the entered value.
52
- * - `suffix`: Only includes options whose text _ends_ with the entered value.
53
- * - `substring`: Only includes options whose text contains the entered value as a
54
- * contiguous substring.
55
- * - `subsequence`: Only shows options whose text has the characters of the entered
56
- * value in order, though they do not need to be contiguous.
57
- * E.g., `ace` is a subsequence of `archive` (but not a substring).
58
- *
59
- * If custom filtering outside of these presets is desired, an arbitrary filtering function
60
- * may instead be bound to this property directly.
61
- *
62
- * @see {@link IAComboBox.caseSensitive} to enable case-sensitive filtering.
63
- */
64
- filter: IAComboBoxFilterOption;
65
- /**
66
- * Whether filtering should be case-sensitive. Default is `false`, performing only
67
- * case-insensitive filtering.
68
- */
69
- caseSensitive: boolean;
70
- /**
71
- * Whether the filtered options should be listed in lexicographically-sorted order,
72
- * respecting the current `caseSensitive` setting.
73
- * Default is `false`, displaying them in the same order as the provided options array.
74
- */
75
- sort: boolean;
76
- /**
77
- * Whether the combo box allows multiple options to be selected at once.
78
- * Default is `false`, allowing only a single option to be selected.
79
- */
80
- /**
81
- * Whether pressing the Up/Down arrow keys should wrap focus back to the text input box
82
- * while focus is already on the first/last option, respectively.
83
- *
84
- * Default is `false`, doing nothing upon such key presses.
85
- */
86
- wrapArrowKeys: boolean;
87
- /**
88
- * Whether the options list should remain open after an option is selected.
89
- *
90
- * Default is `false`, closing the options list when a selection is made.
91
- */
92
- stayOpen: boolean;
93
- /**
94
- * Whether the combo box shows a clear button when a value is selected.
95
- * Default is `false`.
96
- */
97
- clearable: boolean;
98
- /**
99
- * Whether the combo box's option menu is currently expanded. Default is `false`.
100
- */
101
- open: boolean;
102
- /**
103
- * Whether the combo box should be rendered in its disabled state, preventing all
104
- * interactions such as editing the text field or opening the options menu.
105
- * Default is `false`.
106
- */
107
- disabled: boolean;
108
- /**
109
- * If used within a form, whether this combo box is required to have a value selected
110
- * before the form may be submitted. Default is `false`.
111
- */
112
- required: boolean;
113
- /**
114
- * For `select-only` or `list` behavior, this value is the ID of the selected option,
115
- * or `null` if there is no selection.
116
- *
117
- * For `freeform` behavior, this may be any string entered into the text field, and
118
- * need not correspond to an option ID.
119
- */
120
- value: string | null;
121
- /**
122
- * Whether any part of this component currently has focus.
123
- */
124
- private hasFocus;
125
- /**
126
- * Which option in the dropdown menu is currently highlighted by the user. Not to be
127
- * confused with the _selected_ option that has been committed, this field only
128
- * represents the user's current navigation state within the menu, which they may
129
- * subsequently select by, e.g., hitting Enter.
130
- */
131
- private highlightedOption;
132
- /**
133
- * The text than has been entered into the text input box.
134
- */
135
- private enteredText;
136
- /**
137
- * The text that we are currently using the filter the dropdown menu options.
138
- */
139
- private filterText;
140
- private mainWidgetRow;
141
- private textInput;
142
- private optionsList;
143
- static formAssociated: boolean;
144
- static shadowRootOptions: ShadowRootInit;
145
- private internals;
146
- /**
147
- * Set when part of the component blurs, and cleared when any part of it is focused.
148
- * If still set on the next tick after a blur event, this serves as a signal that focus
149
- * has moved away from the component as a whole and should be closed.
150
- */
151
- private losingFocus;
152
- /**
153
- * A cache of the mapping from option IDs to their corresponding options, so that
154
- * we can more efficiently look up options by ID.
155
- */
156
- private optionsByID;
157
- /**
158
- * A cache of the values against which each option should be filtered, to minimize
159
- * the work needed at filter time to handle case-insensitivity etc.
160
- */
161
- private optionFilteringValues;
162
- /**
163
- * A cache of the current set of options that is pre-sorted if the component's
164
- * `sort` flag is set, or as provided otherwise. Just ensures we don't have to
165
- * sort all the options again every time we filter them.
166
- */
167
- private optionsRespectingSortFlag;
168
- /**
169
- * A cache of the current set of filtered options, so that we don't have to
170
- * recalculate it unnecessarily whenever the component is opened/closed/etc.
171
- */
172
- private filteredOptions;
173
- constructor();
174
- render(): TemplateResult | typeof nothing;
175
- willUpdate(changed: PropertyValues): void;
176
- updated(changed: PropertyValues): void;
177
- /**
178
- * Template for the main label for the combo box.
179
- *
180
- * Uses the contents of the `label` named slot as the label text.
181
- */
182
- private get labelTemplate();
183
- /**
184
- * Template for the text input field that users can edit to filter the available
185
- * options or (if freeform behavior) to enter a custom value.
186
- */
187
- private get textInputTemplate();
188
- /**
189
- * Template for the clear button that is shown when the `clearable` property
190
- * is true.
191
- */
192
- private get clearButtonTemplate();
193
- /**
194
- * Template for the caret open/closed icons to show beside the text input.
195
- * The icons are wrapped in named slots to allow consumers to override them.
196
- */
197
- private get caretTemplate();
198
- /**
199
- * Template for the caret button to be shown beside the text input.
200
- */
201
- private get caretButtonTemplate();
202
- /**
203
- * Template for the options list that is displayed when the combo box is open.
204
- */
205
- private get optionsListTemplate();
206
- /**
207
- * Array of templates for all of the filtered options to be shown in the options menu.
208
- */
209
- private get optionTemplates();
210
- /**
211
- * Info message shown in the listbox when no options match the entered text.
212
- * Renders within an `empty-options` named slot so that its content can be customized.
213
- */
214
- private get emptyOptionsTemplate();
215
- /**
216
- * Handler for when the pointer device enters an option element in the dropdown.
217
- */
218
- private handleOptionPointerEnter;
219
- /**
220
- * Handler for when the pointer device is moved within an option in the dropdown.
221
- */
222
- private handleOptionPointerMove;
223
- /**
224
- * Handler for when the user clicks on an option in the dropdown.
225
- */
226
- private handleOptionClick;
227
- /**
228
- * Handler for `keydown` events on various special keys.
229
- */
230
- private handleComboBoxKeyDown;
231
- /**
232
- * Handler for `input` events in the text input box.
233
- */
234
- private handleTextBoxInput;
235
- /**
236
- * Handler for when the Enter key is pressed
237
- */
238
- private handleEnterPressed;
239
- /**
240
- * Handler for when the Escape key is pressed
241
- */
242
- private handleEscapePressed;
243
- /**
244
- * Handler for when the Up Arrow key is pressed (without modifiers).
245
- * @see {@linkcode handleAltUpArrowPressed()} for behavior under the Alt modifier.
246
- */
247
- private handleUpArrowPressed;
248
- /**
249
- * Handler for when the Down Arrow key is pressed (without modifiers).
250
- * @see {@linkcode handleAltDownArrowPressed()} for behavior under the Alt modifier.
251
- */
252
- private handleDownArrowPressed;
253
- /**
254
- * Handler for when the Alt + Up Arrow key combo is pressed
255
- */
256
- private handleAltUpArrowPressed;
257
- /**
258
- * Handler for when the Alt + Down Arrow key combo is pressed
259
- */
260
- private handleAltDownArrowPressed;
261
- /**
262
- * Handler for when the Tab key is pressed
263
- */
264
- private handleTabPressed;
265
- /**
266
- * Handler for when the Space key is handleTabPressed
267
- */
268
- private handleSpacePressed;
269
- /**
270
- * Handler for clicks on the combo box input field or caret button.
271
- */
272
- private handleComboBoxClick;
273
- /**
274
- * Handler for when the clear button is clicked.
275
- */
276
- private handleClearButtonClick;
277
- /**
278
- * Handler for when any part of the combo box receives focus.
279
- */
280
- private handleFocus;
281
- /**
282
- * Handler for when any part of the combo box loses focus.
283
- */
284
- private handleBlur;
285
- /**
286
- * Handler for when the `value` of this component is changed externally
287
- */
288
- private handleValueChanged;
289
- /**
290
- * Highlights the first option shown in the filtered list.
291
- */
292
- private highlightFirstOption;
293
- /**
294
- * Highlights the last option shown in the filtered list.
295
- */
296
- private highlightLastOption;
297
- /**
298
- * Highlights the option before the currently highlighted one in the list, or the last one
299
- * if none is highlighted.
300
- */
301
- private highlightPreviousOption;
302
- /**
303
- * Highlights the option after the currently highlighted one in the list, or the first one
304
- * if none is highlighted.
305
- */
306
- private highlightNextOption;
307
- /**
308
- * Highlights the given option and scrolls it into view if necessary.
309
- * If `null` is provided, any current highlight will be cleared.
310
- */
311
- private setHighlightedOption;
312
- /**
313
- * Changes this combo box's selected option to the one matching the specified ID.
314
- *
315
- * Throws a `RangeError` if given an ID that does not correspond to any option
316
- * held by this combo box.
317
- */
318
- setSelectedOption(id: string): void;
319
- /**
320
- * Clears any currently selected option from this combo box, setting it to null
321
- * and clearing any value in the text box.
322
- */
323
- clearSelectedOption(): void;
324
- /**
325
- * Set this combo box's value to the given string if possible.
326
- *
327
- * In `freeform` behavior, this always succeeds.
328
- *
329
- * In other behavior modes, this method is identical to `setSelectedOption`,
330
- * interpreting the input as an option ID and throwing an error if no such
331
- * option exists.
332
- *
333
- * @see {@linkcode IAComboBox.setSelectedOption}
334
- */
335
- private setValue;
336
- /**
337
- * Changes the value of the text input box, and updates the filter accordingly.
338
- *
339
- * @param setFilter Whether to also update the filter text against which options are
340
- * matched. Defaults to `true`.
341
- */
342
- private setTextValue;
343
- /**
344
- * Sets the current filter text based on the provided string. The resulting filter
345
- * text might not exactly match the provided value, depending on the current case
346
- * sensitivity.
347
- */
348
- private setFilterText;
349
- openOptionsMenu(): void;
350
- closeOptionsMenu(): void;
351
- toggleOptionsMenu(): void;
352
- private updateFormValidity;
353
- private emitChangeEvent;
354
- private emitToggleEvent;
355
- /**
356
- * True iff no selection has been made and no text has been entered.
357
- */
358
- private get isEmpty();
359
- /**
360
- * We only show the clear button when the `clearable` property is set
361
- * and the combo box is neither empty nor disabled.
362
- */
363
- private get shouldShowClearButton();
364
- /**
365
- * Sets the size and position of the options menu to match the size and position of
366
- * the combo box widget. Prefers to position below the main widget, but will flip
367
- * to the top if needed & if there's more room above.
368
- */
369
- private positionOptionsMenu;
370
- /**
371
- * A function to transform option & filter text based on the combo box's
372
- * current case sensitivity.
373
- */
374
- private get caseTransform();
375
- /**
376
- * Returns the combo box option having the given ID, or null if none exists.
377
- */
378
- private getOptionFor;
379
- /**
380
- * Clears any previously-cached mapping of IDs to options, and rebuilds the
381
- * map based on the current set of options.
382
- */
383
- private rebuildOptionIDMap;
384
- /**
385
- * Applies any required sort to the options and caches the result to be used
386
- * at filter/display time.
387
- */
388
- private rebuildSortedOptions;
389
- /**
390
- * Clears any previously-cached option filtering values, and rebuilds the
391
- * map based on the current component properties.
392
- */
393
- private rebuildOptionFilteringValues;
394
- /**
395
- * Returns the filtered array of options by applying the specified filter function
396
- * with the current filter text, up to the limit specified by `maxAutocompleteEntries`.
397
- */
398
- private rebuildFilteredOptions;
399
- /**
400
- * The first option appearing in the filtered list, or null if there are none.
401
- */
402
- private get firstFilteredOption();
403
- /**
404
- * The last option appearing in the filtered list, or null if there are none.
405
- */
406
- private get lastFilteredOption();
407
- /**
408
- * The index of the last filtered option, or -1 if no options match the filter.
409
- */
410
- private get lastFilteredIndex();
411
- /**
412
- * The IAComboBoxOption that is currently selected, or null if none is selected.
413
- */
414
- get selectedOption(): IAComboBoxOption | null;
415
- /**
416
- * The index of the currently highlighted option in the filtered list, or -1 if
417
- * no option is currently highlighted.
418
- */
419
- private get highlightedIndex();
420
- /**
421
- * The HTML element representing the currently-highlighted option, or null if
422
- * no option is highlighted.
423
- */
424
- private get highlightedElement();
425
- static get styles(): CSSResultGroup;
426
- }
427
- //# sourceMappingURL=ia-combo-box.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ia-combo-box.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-combo-box/ia-combo-box.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,OAAO,EACP,cAAc,EACd,cAAc,EAEd,cAAc,EACf,MAAM,KAAK,CAAC;AAQb,OAAO,EAGL,KAAK,kBAAkB,EAEvB,KAAK,sBAAsB,EAE3B,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AA0BlB;;;;GAIG;AACH,qBACa,UAAW,SAAQ,UAAU;IACxC;;;;;;;;;;OAUG;IACwB,OAAO,EAAE,gBAAgB,EAAE,CAAM;IAE5D;;OAEG;IACyB,WAAW,CAAC,EAAE,MAAM,CAAC;IAEjD;;;;;;;;;;OAUG;IACyB,QAAQ,EAAE,kBAAkB,CAAoB;IAE5E;;;;OAIG;IAEH,sBAAsB,SAA4B;IAElD;;;;;;;;;;;;;;;;;;;;OAoBG;IACyB,MAAM,EAAE,sBAAsB,CAClC;IAExB;;;OAGG;IAEH,aAAa,UAAS;IAEtB;;;;OAIG;IACyC,IAAI,UAAS;IAEzD;;;OAGG;IAGH;;;;;OAKG;IAEH,aAAa,UAAS;IAEtB;;;;OAIG;IAEH,QAAQ,UAAS;IAEjB;;;OAGG;IACyC,SAAS,UAAS;IAE9D;;OAEG;IACyC,IAAI,UAAS;IAEzD;;;;OAIG;IACyC,QAAQ,UAAS;IAE7D;;;OAGG;IACyC,QAAQ,UAAS;IAE7D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