downshift 9.4.0-alpha.2 → 9.4.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.
Files changed (44) hide show
  1. package/dist/downshift.cjs.cjs +132 -126
  2. package/dist/downshift.d.ts +60 -56
  3. package/dist/downshift.esm.mjs +132 -126
  4. package/dist/downshift.native.cjs.cjs +129 -126
  5. package/dist/downshift.nativeweb.cjs.cjs +132 -126
  6. package/dist/downshift.umd.js +132 -126
  7. package/dist/downshift.umd.js.map +1 -1
  8. package/dist/downshift.umd.min.js +1 -1
  9. package/dist/downshift.umd.min.js.map +1 -1
  10. package/dist/hooks/testUtils/interactions.d.ts +7 -7
  11. package/dist/hooks/useCombobox/__tests__/utils/renderCombobox.d.ts +3 -59
  12. package/dist/hooks/useCombobox/__tests__/utils/renderUseCombobox.d.ts +1 -1
  13. package/dist/hooks/useCombobox/index.types.d.ts +0 -1
  14. package/dist/hooks/useCombobox/utils/getInitialState.d.ts +1 -6
  15. package/dist/hooks/useCombobox/utils/propTypes.d.ts +1 -43
  16. package/dist/hooks/useSelect/__tests__/utils/getItemIndexByCharacter.d.ts +1 -1
  17. package/dist/hooks/useSelect/__tests__/utils/renderSelect.d.ts +2 -58
  18. package/dist/hooks/useSelect/__tests__/utils/renderUseSelect.d.ts +1 -1
  19. package/dist/hooks/useSelect/__tests__/utils/stateChangeTestCases.d.ts +29 -50
  20. package/dist/hooks/useSelect/utils/propTypes.d.ts +1 -38
  21. package/dist/hooks/useTagGroup/__tests__/utils/renderTagGroup.d.ts +1 -63
  22. package/dist/hooks/useTagGroup/__tests__/utils/renderUseTagGroup.d.ts +2 -2
  23. package/dist/hooks/utils/dropdownDefaultProps.d.ts +3 -4
  24. package/dist/hooks/utils/useMouseAndTouchTracker.d.ts +3 -3
  25. package/dist/hooks/utils/useScrollIntoView.d.ts +4 -3
  26. package/dist/utils/getHighlightedIndex.d.ts +1 -1
  27. package/dist/utils/getNonDisabledIndex.d.ts +1 -1
  28. package/dist/utils/index.d.ts +1 -0
  29. package/dist/utils/useIsomorphicLayoutEffect.d.ts +2 -0
  30. package/dist/utils/useLatestRef.d.ts +1 -1
  31. package/package.json +15 -2
  32. package/preact/dist/downshift.cjs.cjs +132 -126
  33. package/preact/dist/downshift.esm.mjs +132 -126
  34. package/preact/dist/downshift.umd.js +132 -126
  35. package/preact/dist/downshift.umd.js.map +1 -1
  36. package/preact/dist/downshift.umd.min.js +1 -1
  37. package/preact/dist/downshift.umd.min.js.map +1 -1
  38. package/dist/hooks/useMultipleSelection/index.d.ts +0 -50
  39. package/dist/hooks/useMultipleSelection/reducer.d.ts +0 -1
  40. package/dist/hooks/useMultipleSelection/stateChangeTypes.d.ts +0 -13
  41. package/dist/hooks/useMultipleSelection/utils.d.ts +0 -44
  42. package/dist/types.d.ts +0 -12
  43. package/preact/dist/downshift.cjs.js +0 -4265
  44. package/preact/dist/downshift.esm.js +0 -4238
@@ -6,10 +6,10 @@ import { Environment } from '../../downshift.types';
6
6
  * @param environment The environment to add the event listeners to, for instance window.
7
7
  * @param handleBlur The function that is called if mouseDown or touchEnd occured outside the downshiftElements.
8
8
  * @param downshiftRefs The refs for the elements that should not trigger a blur action from mouseDown or touchEnd.
9
- * @returns The mouse and touch events information.
9
+ * @returns A ref holding the mouse and touch events information. Read `.current` only inside event handlers/effects.
10
10
  */
11
- export declare function useMouseAndTouchTracker(environment: Environment | undefined, handleBlur: () => void, downshiftRefs: React.RefObject<HTMLElement>[]): {
11
+ export declare function useMouseAndTouchTracker(environment: Environment | undefined, handleBlur: () => void, downshiftRefs: React.RefObject<HTMLElement>[]): React.MutableRefObject<{
12
12
  isMouseDown: boolean;
13
13
  isTouchMove: boolean;
14
14
  isTouchEnd: boolean;
15
- };
15
+ }>;
@@ -1,11 +1,12 @@
1
+ import * as React from 'react';
1
2
  /**
2
3
  * Utility hook that scrolls an item from a menu into view.
3
4
  * @param scrollIntoView The function that does the scroll.
4
5
  * @param highlightedIndex The index of the item that should be scrolled.
5
6
  * @param isOpen If the menu is open or not.
6
- * @param menuElement The menu element.
7
- * @param itemElements The object containing item elements.
7
+ * @param menuRef The ref to the menu element.
8
+ * @param itemsRef The ref to the object containing item elements.
8
9
  * @param getItemId The function to get the item id from index.
9
10
  * @returns Function that when called prevents the scroll.
10
11
  */
11
- export declare function useScrollIntoView(scrollIntoView: (node: HTMLElement, menuNode: HTMLElement) => void, highlightedIndex: number, isOpen: boolean, menuElement: HTMLElement | null, itemElements: Record<string, HTMLElement>, getItemId: (index: number) => string): () => void;
12
+ export declare function useScrollIntoView(scrollIntoView: (node: HTMLElement, menuNode: HTMLElement) => void, highlightedIndex: number, isOpen: boolean, menuRef: React.MutableRefObject<HTMLElement | null>, itemsRef: React.MutableRefObject<Record<string, HTMLElement>>, getItemId: (index: number) => string): () => void;
@@ -8,4 +8,4 @@
8
8
  * @param circular If the search reaches the end, if it can search again starting from the other end.
9
9
  * @returns The next highlightedIndex.
10
10
  */
11
- export declare function getHighlightedIndex<Item>(start: number, offset: number, items: Item[], isItemDisabled: (item: Item, index: number) => boolean, circular?: boolean): number;
11
+ export declare function getHighlightedIndex<Item>(start: number, offset: number, items: Item[], isItemDisabled: (item: Item, index: number) => boolean, circular?: boolean): any;
@@ -8,4 +8,4 @@
8
8
  * @param circular If the search reaches the end, if it can search again starting from the other end.
9
9
  * @returns The next non-disabled index.
10
10
  */
11
- export declare function getNonDisabledIndex<Item>(start: number, backwards: boolean, items: Item[], isItemDisabled: (item: Item, index: number) => boolean, circular?: boolean): number;
11
+ export declare function getNonDisabledIndex<Item>(start: number, backwards: boolean, items: Item[], isItemDisabled: (item: Item, index: number) => boolean, circular?: boolean): any;
@@ -1,4 +1,5 @@
1
1
  export { generateId, setIdCounter, resetIdCounter } from './generateId';
2
+ export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
2
3
  export { useLatestRef } from './useLatestRef';
3
4
  export { handleRefs } from './handleRefs';
4
5
  export { callAllEventHandlers } from './callAllEventHandlers';
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const useIsomorphicLayoutEffect: typeof React.useEffect;
@@ -1,2 +1,2 @@
1
1
  import * as React from 'react';
2
- export declare function useLatestRef<T>(val: T): React.MutableRefObject<T>;
2
+ export declare function useLatestRef<T>(value: T): React.MutableRefObject<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "downshift",
3
- "version": "9.4.0-alpha.2",
3
+ "version": "9.4.0",
4
4
  "description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
5
5
  "main": "dist/downshift.cjs.cjs",
6
6
  "react-native": "dist/downshift.native.cjs.cjs",
@@ -39,9 +39,16 @@
39
39
  },
40
40
  "husky": {
41
41
  "hooks": {
42
- "pre-commit": "unset ELECTRON_RUN_AS_NODE && kcd-scripts pre-commit"
42
+ "pre-commit": "kcd-scripts pre-commit"
43
43
  }
44
44
  },
45
+ "lint-staged": {
46
+ "*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|gql|graphql|mdx|vue)": [
47
+ "kcd-scripts format",
48
+ "kcd-scripts lint",
49
+ "kcd-scripts test --findRelatedTests --passWithNoTests"
50
+ ]
51
+ },
45
52
  "files": [
46
53
  "dist",
47
54
  "typings",
@@ -115,6 +122,7 @@
115
122
  "cross-env": "^10.1.0",
116
123
  "eslint": "^8.57.0",
117
124
  "eslint-plugin-react": "7.37.5",
125
+ "eslint-plugin-react-hooks": "^7.1.1",
118
126
  "flow-bin": "^0.299.0",
119
127
  "flow-coverage-report": "^0.8.0",
120
128
  "get-pkg-repo": "5.0.0",
@@ -124,6 +132,7 @@
124
132
  "preact": "^10.28.2",
125
133
  "prism-react-renderer": "^2.4.1",
126
134
  "react": "^18.3.1",
135
+ "react-compiler-runtime": "^1.0.0",
127
136
  "react-dom": "^18.3.1",
128
137
  "react-is": "^18.3.1",
129
138
  "react-native": "^0.76.0",
@@ -132,6 +141,9 @@
132
141
  "start-server-and-test": "^2.1.3",
133
142
  "typescript": "^5.9.3"
134
143
  },
144
+ "overrides": {
145
+ "eslint-plugin-react-hooks": "^7.1.1"
146
+ },
135
147
  "eslintConfig": {
136
148
  "parserOptions": {
137
149
  "ecmaVersion": 2023,
@@ -165,6 +177,7 @@
165
177
  },
166
178
  "extends": "./node_modules/kcd-scripts/eslint.js",
167
179
  "rules": {
180
+ "react-hooks/refs": "error",
168
181
  "react/jsx-indent": "off",
169
182
  "react/prop-types": "off",
170
183
  "max-lines-per-function": "off",