@xsolla/xui-autocomplete 0.174.2 → 0.175.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
1
|
# Autocomplete
|
|
2
2
|
|
|
3
3
|
A cross-platform React autocomplete component that provides a filterable dropdown list of suggestions as the user types. Supports both simple string options and rich objects with icons and descriptions.
|
|
4
|
-
|
|
4
|
+
<!-- BEGIN:xui-mcp-instructions:autocomplete -->
|
|
5
|
+
Typically used for searching large or dynamic datasets. The data source is determined by the implementation — it may be a backend API, a large pre-loaded list, or any async data source. Unlike Select, the list is filtered on each keystroke.
|
|
6
|
+
|
|
7
|
+
In the Focus state, use the ContextMenu component as the dropdown. The spacing between the Autocomplete field and the ContextMenu is 4px in all sizes.
|
|
8
|
+
|
|
9
|
+
### When to use
|
|
10
|
+
- When the user must select a value from a large or dynamic dataset that cannot be loaded all at once
|
|
11
|
+
- When a free-text search with suggestions speeds up data entry (e.g. city names, product search, user lookup)
|
|
12
|
+
- When valid values need to be filtered or validated as the user types
|
|
13
|
+
|
|
14
|
+
### When not to use
|
|
15
|
+
- When the list is small and static — use a Select instead
|
|
16
|
+
- When the user can enter any free-form text without needing suggestions — use a plain Input
|
|
17
|
+
- When multiple values need to be selected simultaneously — use a MultiSelect
|
|
18
|
+
|
|
19
|
+
### Content guidelines
|
|
20
|
+
- Placeholder should describe what the user is searching for: *"Search city"*, *"Find product"* — not just *"Search"*.
|
|
21
|
+
- Error messages should be specific: *"No results found"*, *"Select a valid option from the list"* — not *"Invalid value"*.
|
|
22
|
+
- Value text should show the selected item's human-readable label, not an ID or code.
|
|
23
|
+
- Do not show the Remove button in the Disable state — users cannot clear a disabled field.
|
|
24
|
+
|
|
25
|
+
### ContextMenu integration
|
|
26
|
+
- The dropdown list is a separate ContextMenu component, not embedded in Autocomplete itself. Rules:
|
|
27
|
+
- Open on Focus; close on blur or item selection
|
|
28
|
+
- Position the ContextMenu 4px below the Autocomplete field, matching the field width
|
|
29
|
+
- Every keystroke should trigger a backend request to filter the list
|
|
30
|
+
- Show a loading indicator inside the ContextMenu while the request is in progress
|
|
31
|
+
- Show an empty state message when no results are found
|
|
32
|
+
|
|
33
|
+
### Behaviour guidelines
|
|
34
|
+
- Debounce backend requests — wait ~200–300ms after the user stops typing before firing the request. This reduces server load and avoids flickering results.
|
|
35
|
+
- Minimum query length — consider requiring at least 1–2 characters before querying. Show a hint (*"Type to search"*) in the dropdown if fewer characters are entered.
|
|
36
|
+
- Keyboard navigation — once the ContextMenu is open, arrow keys should move focus through options; Enter selects; Escape closes and returns focus to the input.
|
|
37
|
+
- Clear on re-focus — if the user focuses the field after a value is selected, either retain the value (for editing) or clear it to allow a new search. Document which behaviour the team has chosen.
|
|
38
|
+
- Selecting an item — selecting an option from the ContextMenu should populate the value, close the dropdown, and move the chevron back to down-state.
|
|
39
|
+
- Pasting — if the user pastes a value, trigger a search immediately.
|
|
40
|
+
|
|
41
|
+
### Accessibility
|
|
42
|
+
- Use role=*"combobox"* on the input, aria-expanded to reflect whether the dropdown is open, and aria-controls pointing to the ContextMenu list
|
|
43
|
+
- Use aria-autocomplete=*"list"* to indicate that suggestions come from a list
|
|
44
|
+
- The ContextMenu list should use role=*"listbox"* with role=*"option"* on each item
|
|
45
|
+
- Arrow-key navigation must move aria-activedescendant on the input to match the focused option
|
|
46
|
+
- Icon left (search icon) is decorative — add aria-hidden=*"true"*
|
|
47
|
+
- Remove button must have an accessible name: aria-label=*"Clear"*
|
|
48
|
+
- Chevron is decorative — add aria-hidden=*"true"*. Use aria-expanded to communicate open/closed state
|
|
49
|
+
- Error message must be linked via aria-describedby so screen readers announce it on focus
|
|
50
|
+
<!-- END:xui-mcp-instructions:autocomplete -->
|
|
5
51
|
## Installation
|
|
6
52
|
|
|
7
53
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-autocomplete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.175.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
18
|
-
"@xsolla/xui-spinner": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.175.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.175.0",
|
|
18
|
+
"@xsolla/xui-spinner": "0.175.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=16.8.0",
|