@purpurds/autocomplete 7.4.0 → 7.5.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/LICENSE.txt +3 -3
- package/dist/autocomplete.cjs.js +5 -5
- package/dist/autocomplete.cjs.js.map +1 -1
- package/dist/autocomplete.es.js +52 -52
- package/dist/autocomplete.es.js.map +1 -1
- package/dist/useAutocomplete.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/autocomplete.stories.tsx +2 -2
- package/src/useAutocomplete.ts +12 -10
- package/src/utils.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/autocomplete",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.1",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/autocomplete.cjs.js",
|
|
6
6
|
"types": "./dist/autocomplete.d.ts",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"classnames": "~2.5.0",
|
|
19
19
|
"eslint": "9.24.0",
|
|
20
|
-
"@purpurds/
|
|
21
|
-
"@purpurds/
|
|
22
|
-
"@purpurds/
|
|
23
|
-
"@purpurds/notification": "7.
|
|
24
|
-
"@purpurds/paragraph": "7.
|
|
25
|
-
"@purpurds/text-field": "7.
|
|
26
|
-
"@purpurds/tokens": "7.
|
|
20
|
+
"@purpurds/heading": "7.5.1",
|
|
21
|
+
"@purpurds/icon": "7.5.1",
|
|
22
|
+
"@purpurds/listbox": "7.5.1",
|
|
23
|
+
"@purpurds/notification": "7.5.1",
|
|
24
|
+
"@purpurds/paragraph": "7.5.1",
|
|
25
|
+
"@purpurds/text-field": "7.5.1",
|
|
26
|
+
"@purpurds/tokens": "7.5.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@storybook/blocks": "^8.6.4",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"typescript": "^5.6.3",
|
|
46
46
|
"vite": "^6.2.1",
|
|
47
47
|
"vitest": "^3.1.2",
|
|
48
|
-
"@purpurds/button": "7.
|
|
48
|
+
"@purpurds/button": "7.5.1",
|
|
49
49
|
"@purpurds/component-rig": "1.0.0",
|
|
50
|
-
"@purpurds/icon": "7.
|
|
51
|
-
"@purpurds/label": "7.
|
|
52
|
-
"@purpurds/search-field": "7.
|
|
50
|
+
"@purpurds/icon": "7.5.1",
|
|
51
|
+
"@purpurds/label": "7.5.1",
|
|
52
|
+
"@purpurds/search-field": "7.5.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@types/react": "^18 || ^19",
|
|
@@ -57,7 +57,7 @@ const OnInputEventPitfallNotification = () => (
|
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
const meta = {
|
|
60
|
-
title: "Inputs/Autocomplete",
|
|
60
|
+
title: "Forms and Inputs/Autocomplete",
|
|
61
61
|
component: Autocomplete,
|
|
62
62
|
args: {
|
|
63
63
|
options,
|
|
@@ -374,7 +374,7 @@ export const WithCombobox: Story = {
|
|
|
374
374
|
updateArgs({ selectedOption: undefined });
|
|
375
375
|
}}
|
|
376
376
|
placeholder="Find your fruit"
|
|
377
|
-
|
|
377
|
+
clearButtonAriaLabel="Clear text field"
|
|
378
378
|
/>
|
|
379
379
|
)}
|
|
380
380
|
combobox
|
package/src/useAutocomplete.ts
CHANGED
|
@@ -268,18 +268,20 @@ export const useAutocomplete = <T extends AutocompleteOption>({
|
|
|
268
268
|
|
|
269
269
|
const handleOnBlur: React.FocusEventHandler<HTMLInputElement> = (event) => {
|
|
270
270
|
onInputBlur?.(event);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
// Use a timeout to allow click events on the listbox to fire before this check
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
if (
|
|
274
|
+
!inputRef.current?.contains(document.activeElement) &&
|
|
275
|
+
!listboxRef.current?.contains(document.activeElement)
|
|
276
|
+
) {
|
|
277
|
+
closeListbox();
|
|
278
|
+
|
|
279
|
+
// If the blur happened due to a click inside the listbox for a combobox, don't reset the value
|
|
280
|
+
if (combobox) {
|
|
279
281
|
populateInputField(selectedOption ? selectedOption.label : "");
|
|
280
282
|
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
283
285
|
};
|
|
284
286
|
|
|
285
287
|
const listboxStyle: CSSProperties = {
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MutableRefObject, useCallback, useEffect, useRef } from "react";
|
|
1
|
+
import { type MutableRefObject, useCallback, useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
3
|
// Used to "merge" "intersection types". Used to get comments on the props to the docs.
|
|
4
4
|
export type Prettify<T> = {
|