@ariakit/test 0.3.5 → 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,15 @@
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
+
3
13
  ## 0.3.5
4
14
 
5
15
  - Updated dependencies: `@ariakit/core@0.3.8`
@@ -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');
@@ -90,4 +90,4 @@ async function render2(ui, options) {
90
90
 
91
91
 
92
92
 
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 = _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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariakit/test",
3
- "version": "0.3.5",
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.8",
32
+ "@ariakit/core": "0.3.9",
33
33
  "@testing-library/dom": "^8.0.0 || ^9.0.0"
34
34
  },
35
35
  "peerDependencies": {