downshift 9.4.0-alpha.1 → 9.4.0-alpha.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,4 +1,4 @@
1
- import { Environment, GetPropsCommonOptions, Overwrite } from '../../downshift.types';
1
+ import { AnyRef, Environment, GetPropsCommonOptions, Overwrite } from '../../downshift.types';
2
2
  export interface UseComboboxState<Item> {
3
3
  highlightedIndex: number;
4
4
  selectedItem: Item | null;
@@ -175,12 +175,12 @@ export interface UseComboboxInputValueChange<Item> extends UseComboboxStateChang
175
175
  }
176
176
  export interface UseComboboxGetMenuPropsOptions extends React.HTMLProps<HTMLElement> {
177
177
  refKey?: string;
178
- ref?: React.Ref<any>;
178
+ ref?: AnyRef;
179
179
  }
180
180
  export interface UseComboboxGetMenuPropsReturnValue {
181
181
  'aria-label': string | undefined;
182
182
  'aria-labelledby': string | undefined;
183
- ref?: React.Ref<any>;
183
+ ref?: AnyRef;
184
184
  role: 'listbox';
185
185
  id: string;
186
186
  onMouseLeave: React.MouseEventHandler;
@@ -189,7 +189,7 @@ export type UseComboboxGetMenuProps = <Options>(options?: UseComboboxGetMenuProp
189
189
  export interface UseComboboxGetToggleButtonPropsOptions extends React.HTMLProps<HTMLElement> {
190
190
  disabled?: boolean;
191
191
  refKey?: string;
192
- ref?: React.Ref<any>;
192
+ ref?: AnyRef;
193
193
  onPress?: (event: React.BaseSyntheticEvent) => void;
194
194
  }
195
195
  export interface UseComboboxGetToggleButtonPropsReturnValue {
@@ -198,7 +198,7 @@ export interface UseComboboxGetToggleButtonPropsReturnValue {
198
198
  id: string;
199
199
  onPress?: (event: React.BaseSyntheticEvent) => void;
200
200
  onClick?: React.MouseEventHandler;
201
- ref?: React.Ref<any>;
201
+ ref?: AnyRef;
202
202
  tabIndex: -1;
203
203
  }
204
204
  export type UseComboboxGetToggleButtonProps = <Options>(options?: UseComboboxGetToggleButtonPropsOptions & Options) => Overwrite<UseComboboxGetToggleButtonPropsReturnValue, Options>;
@@ -213,7 +213,7 @@ export interface UseComboboxGetItemPropsOptions<Item> extends React.HTMLProps<HT
213
213
  index?: number;
214
214
  item?: Item;
215
215
  refKey?: string;
216
- ref?: React.Ref<any>;
216
+ ref?: AnyRef;
217
217
  onPress?: (event: React.BaseSyntheticEvent) => void;
218
218
  }
219
219
  export interface UseComboboxGetItemPropsReturnValue {
@@ -224,7 +224,7 @@ export interface UseComboboxGetItemPropsReturnValue {
224
224
  onMouseDown?: React.MouseEventHandler;
225
225
  onMouseMove?: React.MouseEventHandler;
226
226
  onPress?: React.MouseEventHandler;
227
- ref?: React.Ref<any>;
227
+ ref?: AnyRef;
228
228
  role: 'option';
229
229
  }
230
230
  export type UseComboboxGetItemProps<Item> = <Options>(options?: UseComboboxGetItemPropsOptions<Item> & Options) => Omit<Overwrite<UseComboboxGetItemPropsReturnValue, Options>, 'index' | 'item'>;
@@ -234,7 +234,7 @@ export interface UseComboboxGetInputPropsOptions extends React.HTMLProps<HTMLInp
234
234
  onChangeText?: (event: React.BaseSyntheticEvent) => void;
235
235
  }
236
236
  export interface UseComboboxGetInputPropsReturnValue {
237
- ref?: React.Ref<any>;
237
+ ref?: AnyRef;
238
238
  'aria-activedescendant': string;
239
239
  'aria-autocomplete': 'list';
240
240
  'aria-controls': string;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Environment, GetPropsCommonOptions, Overwrite } from '../../downshift.types';
2
+ import { AnyRef, Environment, GetPropsCommonOptions, Overwrite } from '../../downshift.types';
3
3
  export interface UseMultipleSelectionState<Item> {
4
4
  selectedItems: Item[];
5
5
  activeIndex: number;
@@ -64,12 +64,12 @@ export interface A11yRemovalMessage<Item> {
64
64
  }
65
65
  export interface UseMultipleSelectionGetSelectedItemPropsOptions<Item> extends React.HTMLProps<HTMLElement> {
66
66
  refKey?: string;
67
- ref?: React.Ref<any>;
67
+ ref?: AnyRef;
68
68
  index?: number;
69
69
  selectedItem: Item;
70
70
  }
71
71
  export interface UseMultipleSelectionGetSelectedItemReturnValue {
72
- ref?: React.Ref<any>;
72
+ ref?: AnyRef;
73
73
  tabIndex: 0 | -1;
74
74
  onClick: React.MouseEventHandler;
75
75
  onKeyDown: React.KeyboardEventHandler;
@@ -77,10 +77,10 @@ export interface UseMultipleSelectionGetSelectedItemReturnValue {
77
77
  export interface UseMultipleSelectionGetDropdownPropsOptions extends React.HTMLProps<HTMLElement> {
78
78
  preventKeyAction?: boolean;
79
79
  refKey?: string;
80
- ref?: React.Ref<any>;
80
+ ref?: AnyRef;
81
81
  }
82
82
  export interface UseMultipleSelectionGetDropdownReturnValue {
83
- ref?: React.Ref<any>;
83
+ ref?: AnyRef;
84
84
  onClick?: React.MouseEventHandler;
85
85
  onKeyDown?: React.KeyboardEventHandler;
86
86
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Environment, GetPropsCommonOptions, Overwrite } from '../../downshift.types';
2
+ import { AnyRef, Environment, GetPropsCommonOptions, Overwrite } from '../../downshift.types';
3
3
  export interface UseSelectState<Item> {
4
4
  highlightedIndex: number;
5
5
  selectedItem: Item | null;
@@ -162,19 +162,19 @@ export interface UseSelectIsOpenChange<Item> extends UseSelectStateChange<Item>
162
162
  }
163
163
  export interface UseSelectGetMenuPropsOptions extends React.HTMLProps<HTMLElement> {
164
164
  refKey?: string;
165
- ref?: React.Ref<any>;
165
+ ref?: AnyRef;
166
166
  }
167
167
  export interface UseSelectGetMenuPropsReturnValue {
168
168
  'aria-labelledby': string | undefined;
169
169
  id: string;
170
170
  onMouseLeave: React.MouseEventHandler;
171
- ref?: React.Ref<any>;
171
+ ref?: AnyRef;
172
172
  role: 'listbox';
173
173
  }
174
174
  export type UseSelectGetMenuProps = <Options>(options?: UseSelectGetMenuPropsOptions & Options, otherOptions?: GetPropsCommonOptions) => Overwrite<UseSelectGetMenuPropsReturnValue, Options>;
175
175
  export interface UseSelectGetToggleButtonPropsOptions extends React.HTMLProps<HTMLElement> {
176
176
  refKey?: string;
177
- ref?: React.Ref<any>;
177
+ ref?: AnyRef;
178
178
  onPress?: (event: React.BaseSyntheticEvent) => void;
179
179
  }
180
180
  export interface UseSelectGetToggleButtonPropsReturnValue {
@@ -188,7 +188,7 @@ export interface UseSelectGetToggleButtonPropsReturnValue {
188
188
  onClick?: React.MouseEventHandler;
189
189
  onKeyDown?: React.KeyboardEventHandler;
190
190
  onPress?: (event: React.BaseSyntheticEvent) => void;
191
- ref?: React.Ref<any>;
191
+ ref?: AnyRef;
192
192
  role: 'combobox';
193
193
  tabIndex: 0;
194
194
  }
@@ -205,7 +205,7 @@ export interface UseSelectGetItemPropsOptions<Item> extends React.HTMLProps<HTML
205
205
  item?: Item;
206
206
  index?: number;
207
207
  refKey?: string;
208
- ref?: React.Ref<any>;
208
+ ref?: AnyRef;
209
209
  onPress?: (event: React.BaseSyntheticEvent) => void;
210
210
  }
211
211
  export interface UseSelectGetItemPropsReturnValue {
@@ -216,7 +216,7 @@ export interface UseSelectGetItemPropsReturnValue {
216
216
  onMouseDown?: React.MouseEventHandler;
217
217
  onMouseMove?: React.MouseEventHandler;
218
218
  onPress?: React.MouseEventHandler;
219
- ref?: React.Ref<any>;
219
+ ref?: AnyRef;
220
220
  role: 'option';
221
221
  }
222
222
  export type UseSelectGetItemProps<Item> = <Options>(options: UseSelectGetItemPropsOptions<Item> & Options) => Omit<Overwrite<UseSelectGetItemPropsReturnValue, Options>, 'index' | 'item'>;
@@ -1,4 +1,4 @@
1
- import { Environment } from '../../downshift.types';
1
+ import { AnyRef, Environment } from '../../downshift.types';
2
2
  export interface UseTagGroupState<Item> {
3
3
  activeIndex: number;
4
4
  items: Item[];
@@ -52,12 +52,12 @@ export interface UseTagGroupReturnValue<Item> {
52
52
  export interface GetTagPropsOptions extends React.HTMLProps<HTMLElement> {
53
53
  index: number;
54
54
  refKey?: string;
55
- ref?: React.Ref<any>;
55
+ ref?: AnyRef;
56
56
  }
57
57
  export interface GetTagPropsReturnValue {
58
58
  'aria-describedby': string;
59
59
  id: string;
60
- ref?: React.Ref<any>;
60
+ ref?: AnyRef;
61
61
  role: 'option';
62
62
  onPress?: (event: React.BaseSyntheticEvent) => void;
63
63
  onClick?: React.MouseEventHandler;
@@ -75,11 +75,11 @@ export interface GetTagRemovePropsReturnValue {
75
75
  }
76
76
  export interface GetTagGroupPropsOptions extends React.HTMLProps<HTMLElement> {
77
77
  refKey?: string;
78
- ref?: React.Ref<any>;
78
+ ref?: AnyRef;
79
79
  }
80
80
  export interface GetTagGroupPropsReturnValue {
81
81
  id: string;
82
- ref?: React.Ref<any>;
82
+ ref?: AnyRef;
83
83
  role: 'listbox';
84
84
  'aria-live': 'polite';
85
85
  'aria-atomic': 'false';
@@ -10,7 +10,7 @@ type DropdownState<Item> = {
10
10
  *
11
11
  * @param prevState The previous dropdown state.
12
12
  * @param newState The new dropdown state.
13
- * @returns Wheather the states are deeply equal.
13
+ * @returns Whether the states are deeply equal.
14
14
  */
15
15
  export declare function isDropdownStateEqual<Item>(prevState: DropdownState<Item>, newState: DropdownState<Item>): boolean;
16
16
  export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
3
+ export type AnyRef = React.Ref<any>;
4
+ export interface Environment {
5
+ addEventListener: typeof window.addEventListener;
6
+ removeEventListener: typeof window.removeEventListener;
7
+ document: Document;
8
+ Node: typeof window.Node;
9
+ }
10
+ export interface GetPropsCommonOptions {
11
+ suppressRefError?: boolean;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "downshift",
3
- "version": "9.4.0-alpha.1",
3
+ "version": "9.4.0-alpha.2",
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",
@@ -24,18 +24,18 @@
24
24
  "test:flow:coverage": "flow-coverage-report",
25
25
  "test:build": "jest --config other/misc-tests/jest.config.js",
26
26
  "// FIXME: test:build": "jest --projects other/misc-tests other/react-native",
27
- "test:cypress:dev": "npm-run-all --parallel --race docs:dev cy:open",
28
- "pretest:cypress": "npm run docs:build --silent",
29
- "test:cypress": "start-server-and-test docs:serve http://localhost:6006 cy:run",
30
- "cy:run": "cypress run",
31
- "cy:open": "cypress open",
27
+ "test:e2e:dev": "playwright test --ui",
28
+ "pretest:e2e": "npm run docs:build --silent",
29
+ "test:e2e": "playwright test",
30
+ "pw:run": "playwright test",
31
+ "pw:open": "playwright test --ui",
32
32
  "build-and-test": "npm run build -s && npm run test:build -s",
33
33
  "docs:build": "docusaurus build",
34
34
  "docs:dev": "docusaurus start",
35
35
  "docs:serve": "docusaurus serve --port 6006",
36
36
  "docs:clear": "docusaurus clear",
37
37
  "setup": "npm install && npm run validate",
38
- "validate": "kcd-scripts validate lint,build-and-test,test:cover,test:ts,test:ssr,test:cypress"
38
+ "validate": "kcd-scripts validate lint,build-and-test,test:cover,test:ts,test:ssr,test:e2e"
39
39
  },
40
40
  "husky": {
41
41
  "hooks": {
@@ -89,15 +89,14 @@
89
89
  },
90
90
  "devDependencies": {
91
91
  "@babel/helpers": "^7.28.6",
92
- "@babel/plugin-proposal-private-methods": "^7.18.6",
93
- "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
94
- "@docusaurus/core": "3.3.2",
95
- "@docusaurus/module-type-aliases": "3.3.2",
96
- "@docusaurus/preset-classic": "3.3.2",
92
+ "@docusaurus/babel": "3.10.1",
93
+ "@docusaurus/core": "3.10.1",
94
+ "@docusaurus/module-type-aliases": "3.10.1",
95
+ "@docusaurus/preset-classic": "3.10.1",
97
96
  "@mdx-js/react": "^3.0.1",
97
+ "@playwright/test": "^1.60.0",
98
98
  "@rollup/plugin-babel": "^6.1.0",
99
99
  "@rollup/plugin-commonjs": "^29.0.0",
100
- "@testing-library/cypress": "^10.1.0",
101
100
  "@testing-library/dom": "^10.4.1",
102
101
  "@testing-library/jest-dom": "^6.9.1",
103
102
  "@testing-library/preact": "^3.2.4",
@@ -114,9 +113,7 @@
114
113
  "buble": "^0.20.0",
115
114
  "cpy-cli": "^6.0.0",
116
115
  "cross-env": "^10.1.0",
117
- "cypress": "15.9.0",
118
116
  "eslint": "^8.57.0",
119
- "eslint-plugin-cypress": "^3.6.0",
120
117
  "eslint-plugin-react": "7.37.5",
121
118
  "flow-bin": "^0.299.0",
122
119
  "flow-coverage-report": "^0.8.0",
@@ -141,7 +138,8 @@
141
138
  "project": [
142
139
  "./tsconfig.json",
143
140
  "./docusaurus/tsconfig.json",
144
- "./test/tsconfig.json"
141
+ "./test/tsconfig.json",
142
+ "./e2e/tsconfig.json"
145
143
  ],
146
144
  "sourceType": "module"
147
145
  },
@@ -181,11 +179,16 @@
181
179
  "overrides": [
182
180
  {
183
181
  "files": [
184
- "cypress/**/*.js"
182
+ "e2e/**/*.ts"
185
183
  ],
186
184
  "rules": {
187
185
  "testing-library/prefer-screen-queries": "off",
188
- "testing-library/await-async-query": "off"
186
+ "import/no-extraneous-dependencies": [
187
+ "error",
188
+ {
189
+ "devDependencies": true
190
+ }
191
+ ]
189
192
  }
190
193
  }
191
194
  ]
@@ -196,7 +199,10 @@
196
199
  "dist",
197
200
  ".docusaurus",
198
201
  "build",
199
- "test"
202
+ "test",
203
+ "typings",
204
+ "playwright-report",
205
+ "test-results"
200
206
  ],
201
207
  "repository": {
202
208
  "type": "git",
@@ -2139,6 +2139,7 @@ function useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuElement
2139
2139
  } else {
2140
2140
  shouldScrollRef.current = true;
2141
2141
  }
2142
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally only re-runs when highlightedIndex changes; other params are refs/stable values that don't trigger scrolling
2142
2143
  }, [highlightedIndex]);
2143
2144
  return React__namespace.useCallback(function preventScroll() {
2144
2145
  shouldScrollRef.current = false;
@@ -2151,7 +2152,7 @@ function useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuElement
2151
2152
  *
2152
2153
  * @param prevState The previous dropdown state.
2153
2154
  * @param newState The new dropdown state.
2154
- * @returns Wheather the states are deeply equal.
2155
+ * @returns Whether the states are deeply equal.
2155
2156
  */
2156
2157
  function isDropdownStateEqual(prevState, newState) {
2157
2158
  return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
@@ -2215,7 +2216,6 @@ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2215
2216
  }
2216
2217
  return _extends({}, state, changes);
2217
2218
  }
2218
- /* eslint-enable complexity */
2219
2219
 
2220
2220
  var propTypes$3 = _extends({}, dropdownPropTypes, {
2221
2221
  items: PropTypes.array.isRequired,
@@ -2117,6 +2117,7 @@ function useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuElement
2117
2117
  } else {
2118
2118
  shouldScrollRef.current = true;
2119
2119
  }
2120
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally only re-runs when highlightedIndex changes; other params are refs/stable values that don't trigger scrolling
2120
2121
  }, [highlightedIndex]);
2121
2122
  return React.useCallback(function preventScroll() {
2122
2123
  shouldScrollRef.current = false;
@@ -2129,7 +2130,7 @@ function useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuElement
2129
2130
  *
2130
2131
  * @param prevState The previous dropdown state.
2131
2132
  * @param newState The new dropdown state.
2132
- * @returns Wheather the states are deeply equal.
2133
+ * @returns Whether the states are deeply equal.
2133
2134
  */
2134
2135
  function isDropdownStateEqual(prevState, newState) {
2135
2136
  return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
@@ -2193,7 +2194,6 @@ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2193
2194
  }
2194
2195
  return _extends({}, state, changes);
2195
2196
  }
2196
- /* eslint-enable complexity */
2197
2197
 
2198
2198
  var propTypes$3 = _extends({}, dropdownPropTypes, {
2199
2199
  items: PropTypes.array.isRequired,
@@ -2400,6 +2400,7 @@
2400
2400
  } else {
2401
2401
  shouldScrollRef.current = true;
2402
2402
  }
2403
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally only re-runs when highlightedIndex changes; other params are refs/stable values that don't trigger scrolling
2403
2404
  }, [highlightedIndex]);
2404
2405
  return React__namespace.useCallback(function preventScroll() {
2405
2406
  shouldScrollRef.current = false;
@@ -2412,7 +2413,7 @@
2412
2413
  *
2413
2414
  * @param prevState The previous dropdown state.
2414
2415
  * @param newState The new dropdown state.
2415
- * @returns Wheather the states are deeply equal.
2416
+ * @returns Whether the states are deeply equal.
2416
2417
  */
2417
2418
  function isDropdownStateEqual(prevState, newState) {
2418
2419
  return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
@@ -2476,7 +2477,6 @@
2476
2477
  }
2477
2478
  return _extends({}, state, changes);
2478
2479
  }
2479
- /* eslint-enable complexity */
2480
2480
 
2481
2481
  var propTypes$3 = _extends({}, dropdownPropTypes, {
2482
2482
  items: PropTypes.array.isRequired,