@ariakit/test 0.3.4 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ariakit/test
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### <kbd>Home</kbd> and <kbd>End</kbd> keys on text fields
6
+
7
+ Pressing the <kbd>Home</kbd> or <kbd>End</kbd> keys on text fields will now move the cursor (`selectionStart`/`selectionEnd` properties) to the start or finish of the text when using the `press` function.
8
+
9
+ ### Other updates
10
+
11
+ - Updated dependencies: `@ariakit/core@0.3.9`
12
+
13
+ ## 0.3.5
14
+
15
+ - Updated dependencies: `@ariakit/core@0.3.8`
16
+
3
17
  ## 0.3.4
4
18
 
5
19
  - Updated dependencies: `@ariakit/core@0.3.7`
@@ -81,6 +81,20 @@ var keyDownMap = {
81
81
  await submitFormByPressingEnterOn(element, options);
82
82
  }
83
83
  },
84
+ async Home(element, { shiftKey }) {
85
+ if (_dom.isTextField.call(void 0, element)) {
86
+ const { value, selectionEnd } = element;
87
+ const end = Math.min(value.length, shiftKey ? selectionEnd != null ? selectionEnd : 0 : 0);
88
+ element.setSelectionRange(0, end, "backward");
89
+ }
90
+ },
91
+ async End(element, { shiftKey }) {
92
+ if (_dom.isTextField.call(void 0, element)) {
93
+ const { value, selectionStart } = element;
94
+ const start = shiftKey ? selectionStart != null ? selectionStart : 0 : value.length;
95
+ element.setSelectionRange(start, value.length, "forward");
96
+ }
97
+ },
84
98
  async ArrowLeft(element, { shiftKey }) {
85
99
  if (_dom.isTextField.call(void 0, element)) {
86
100
  const { value, selectionStart, selectionEnd, selectionDirection } = element;
package/cjs/index.cjs CHANGED
@@ -27,7 +27,7 @@ var _LYOKT276cjs = require('./__chunks/LYOKT276.cjs');
27
27
  var _2KXSRUIVcjs = require('./__chunks/2KXSRUIV.cjs');
28
28
 
29
29
 
30
- var _ESE7QHAQcjs = require('./__chunks/ESE7QHAQ.cjs');
30
+ var _PRDOHIPOcjs = require('./__chunks/PRDOHIPO.cjs');
31
31
 
32
32
 
33
33
  var _VZINRVVHcjs = require('./__chunks/VZINRVVH.cjs');
@@ -61,4 +61,4 @@ require('./__chunks/OVN5OYWK.cjs');
61
61
 
62
62
 
63
63
 
64
- exports.blur = _KVNENCXTcjs.blur; exports.click = _PJWPDIUXcjs.click; exports.dispatch = _FU2U6RZLcjs.dispatch; exports.focus = _A5IFXY4Jcjs.focus; exports.hover = _LYOKT276cjs.hover; exports.mouseDown = _T5KVOIJTcjs.mouseDown; exports.mouseUp = _747HORQZcjs.mouseUp; exports.press = _ESE7QHAQcjs.press; exports.q = _2KXSRUIVcjs.q; exports.query = _2KXSRUIVcjs.query; exports.select = _DAHHEUOUcjs.select; exports.sleep = _NIEATM7Rcjs.sleep; exports.tap = _SDUGTL2Ncjs.tap; exports.type = _VZINRVVHcjs.type; exports.waitFor = _SEWCIANIcjs.waitFor;
64
+ exports.blur = _KVNENCXTcjs.blur; exports.click = _PJWPDIUXcjs.click; exports.dispatch = _FU2U6RZLcjs.dispatch; exports.focus = _A5IFXY4Jcjs.focus; exports.hover = _LYOKT276cjs.hover; exports.mouseDown = _T5KVOIJTcjs.mouseDown; exports.mouseUp = _747HORQZcjs.mouseUp; exports.press = _PRDOHIPOcjs.press; exports.q = _2KXSRUIVcjs.q; exports.query = _2KXSRUIVcjs.query; exports.select = _DAHHEUOUcjs.select; exports.sleep = _NIEATM7Rcjs.sleep; exports.tap = _SDUGTL2Ncjs.tap; exports.type = _VZINRVVHcjs.type; exports.waitFor = _SEWCIANIcjs.waitFor;
package/cjs/press.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _ESE7QHAQcjs = require('./__chunks/ESE7QHAQ.cjs');
4
+ var _PRDOHIPOcjs = require('./__chunks/PRDOHIPO.cjs');
5
5
  require('./__chunks/VZINRVVH.cjs');
6
6
  require('./__chunks/KVNENCXT.cjs');
7
7
  require('./__chunks/A5IFXY4J.cjs');
@@ -11,4 +11,4 @@ require('./__chunks/ZMMVJ3OT.cjs');
11
11
  require('./__chunks/OVN5OYWK.cjs');
12
12
 
13
13
 
14
- exports.press = _ESE7QHAQcjs.press;
14
+ exports.press = _PRDOHIPOcjs.press;
package/cjs/react.cjs CHANGED
@@ -27,7 +27,7 @@ var _LYOKT276cjs = require('./__chunks/LYOKT276.cjs');
27
27
  var _2KXSRUIVcjs = require('./__chunks/2KXSRUIV.cjs');
28
28
 
29
29
 
30
- var _ESE7QHAQcjs = require('./__chunks/ESE7QHAQ.cjs');
30
+ var _PRDOHIPOcjs = require('./__chunks/PRDOHIPO.cjs');
31
31
 
32
32
 
33
33
  var _VZINRVVHcjs = require('./__chunks/VZINRVVH.cjs');
@@ -46,6 +46,7 @@ var _NIEATM7Rcjs = require('./__chunks/NIEATM7R.cjs');
46
46
 
47
47
 
48
48
 
49
+
49
50
  var _ZMMVJ3OTcjs = require('./__chunks/ZMMVJ3OT.cjs');
50
51
 
51
52
 
@@ -66,7 +67,9 @@ async function render2(ui, options) {
66
67
  };
67
68
  return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
68
69
  const { unmount } = ReactTestingLibrary.render(ui, _OVN5OYWKcjs.__spreadProps.call(void 0, _OVN5OYWKcjs.__spreadValues.call(void 0, {}, options), { wrapper }));
70
+ await _ZMMVJ3OTcjs.flushMicrotasks.call(void 0, );
69
71
  await _ZMMVJ3OTcjs.nextFrame.call(void 0, );
72
+ await _ZMMVJ3OTcjs.flushMicrotasks.call(void 0, );
70
73
  return unmount;
71
74
  });
72
75
  }
@@ -87,4 +90,4 @@ async function render2(ui, options) {
87
90
 
88
91
 
89
92
 
90
- exports.blur = _KVNENCXTcjs.blur; exports.click = _PJWPDIUXcjs.click; exports.dispatch = _FU2U6RZLcjs.dispatch; exports.focus = _A5IFXY4Jcjs.focus; exports.hover = _LYOKT276cjs.hover; exports.mouseDown = _T5KVOIJTcjs.mouseDown; exports.mouseUp = _747HORQZcjs.mouseUp; exports.press = _ESE7QHAQcjs.press; exports.q = _2KXSRUIVcjs.q; exports.query = _2KXSRUIVcjs.query; exports.render = render2; exports.select = _DAHHEUOUcjs.select; exports.sleep = _NIEATM7Rcjs.sleep; exports.tap = _SDUGTL2Ncjs.tap; exports.type = _VZINRVVHcjs.type; exports.waitFor = _SEWCIANIcjs.waitFor;
93
+ exports.blur = _KVNENCXTcjs.blur; exports.click = _PJWPDIUXcjs.click; exports.dispatch = _FU2U6RZLcjs.dispatch; exports.focus = _A5IFXY4Jcjs.focus; exports.hover = _LYOKT276cjs.hover; exports.mouseDown = _T5KVOIJTcjs.mouseDown; exports.mouseUp = _747HORQZcjs.mouseUp; exports.press = _PRDOHIPOcjs.press; exports.q = _2KXSRUIVcjs.q; exports.query = _2KXSRUIVcjs.query; exports.render = render2; exports.select = _DAHHEUOUcjs.select; exports.sleep = _NIEATM7Rcjs.sleep; exports.tap = _SDUGTL2Ncjs.tap; exports.type = _VZINRVVHcjs.type; exports.waitFor = _SEWCIANIcjs.waitFor;
@@ -81,6 +81,20 @@ var keyDownMap = {
81
81
  await submitFormByPressingEnterOn(element, options);
82
82
  }
83
83
  },
84
+ async Home(element, { shiftKey }) {
85
+ if (isTextField(element)) {
86
+ const { value, selectionEnd } = element;
87
+ const end = Math.min(value.length, shiftKey ? selectionEnd != null ? selectionEnd : 0 : 0);
88
+ element.setSelectionRange(0, end, "backward");
89
+ }
90
+ },
91
+ async End(element, { shiftKey }) {
92
+ if (isTextField(element)) {
93
+ const { value, selectionStart } = element;
94
+ const start = shiftKey ? selectionStart != null ? selectionStart : 0 : value.length;
95
+ element.setSelectionRange(start, value.length, "forward");
96
+ }
97
+ },
84
98
  async ArrowLeft(element, { shiftKey }) {
85
99
  if (isTextField(element)) {
86
100
  const { value, selectionStart, selectionEnd, selectionDirection } = element;
package/esm/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  } from "./__chunks/HUBUFZ3U.js";
28
28
  import {
29
29
  press
30
- } from "./__chunks/UJCT5GXS.js";
30
+ } from "./__chunks/YGV4P2D2.js";
31
31
  import {
32
32
  type
33
33
  } from "./__chunks/HVRX3U4O.js";
package/esm/press.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  press
4
- } from "./__chunks/UJCT5GXS.js";
4
+ } from "./__chunks/YGV4P2D2.js";
5
5
  import "./__chunks/HVRX3U4O.js";
6
6
  import "./__chunks/ZIWQZF7I.js";
7
7
  import "./__chunks/WAYMNUAF.js";
package/esm/react.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  } from "./__chunks/HUBUFZ3U.js";
28
28
  import {
29
29
  press
30
- } from "./__chunks/UJCT5GXS.js";
30
+ } from "./__chunks/YGV4P2D2.js";
31
31
  import {
32
32
  type
33
33
  } from "./__chunks/HVRX3U4O.js";
@@ -44,6 +44,7 @@ import {
44
44
  sleep
45
45
  } from "./__chunks/YNAZUNNE.js";
46
46
  import {
47
+ flushMicrotasks,
47
48
  nextFrame,
48
49
  wrapAsync
49
50
  } from "./__chunks/LHKK7Y5F.js";
@@ -66,7 +67,9 @@ async function render2(ui, options) {
66
67
  };
67
68
  return wrapAsync(async () => {
68
69
  const { unmount } = ReactTestingLibrary.render(ui, __spreadProps(__spreadValues({}, options), { wrapper }));
70
+ await flushMicrotasks();
69
71
  await nextFrame();
72
+ await flushMicrotasks();
70
73
  return unmount;
71
74
  });
72
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariakit/test",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Ariakit test utils",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "react"
30
30
  ],
31
31
  "dependencies": {
32
- "@ariakit/core": "0.3.7",
32
+ "@ariakit/core": "0.3.9",
33
33
  "@testing-library/dom": "^8.0.0 || ^9.0.0"
34
34
  },
35
35
  "peerDependencies": {