@ariakit/test 0.3.13 → 0.3.14

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,10 @@
1
1
  # @ariakit/test
2
2
 
3
+ ## 0.3.14
4
+
5
+ - Added `within` function to queries.
6
+ - Updated dependencies: `@ariakit/core@0.4.5`
7
+
3
8
  ## 0.3.13
4
9
 
5
10
  - Updated dependencies: `@ariakit/core@0.4.4`
@@ -85,14 +85,14 @@ var keyDownMap = {
85
85
  if (_dom.isTextField.call(void 0, element)) {
86
86
  const { value, selectionEnd } = element;
87
87
  const end = Math.min(value.length, shiftKey ? selectionEnd != null ? selectionEnd : 0 : 0);
88
- element.setSelectionRange(0, end, "backward");
88
+ _dom.setSelectionRange.call(void 0, element, 0, end, "backward");
89
89
  }
90
90
  },
91
91
  async End(element, { shiftKey }) {
92
92
  if (_dom.isTextField.call(void 0, element)) {
93
93
  const { value, selectionStart } = element;
94
94
  const start = shiftKey ? selectionStart != null ? selectionStart : 0 : value.length;
95
- element.setSelectionRange(start, value.length, "forward");
95
+ _dom.setSelectionRange.call(void 0, element, start, value.length, "forward");
96
96
  }
97
97
  },
98
98
  async ArrowLeft(element, { shiftKey }) {
@@ -102,7 +102,8 @@ var keyDownMap = {
102
102
  const collapsing = !shiftKey && start !== end;
103
103
  const nextStart = Math.max(0, collapsing ? start : start - 1);
104
104
  const nextEnd = Math.min(value.length, shiftKey ? end : nextStart);
105
- element.setSelectionRange(
105
+ _dom.setSelectionRange.call(void 0,
106
+ element,
106
107
  nextStart,
107
108
  nextEnd,
108
109
  selectionDirection || "backward"
@@ -116,7 +117,8 @@ var keyDownMap = {
116
117
  const collapsing = !shiftKey && start !== end;
117
118
  const nextEnd = Math.min(value.length, collapsing ? end : end + 1);
118
119
  const nextStart = Math.max(0, shiftKey ? start : nextEnd);
119
- element.setSelectionRange(
120
+ _dom.setSelectionRange.call(void 0,
121
+ element,
120
122
  nextStart,
121
123
  nextEnd,
122
124
  selectionDirection || "forward"
@@ -126,14 +128,14 @@ var keyDownMap = {
126
128
  async ArrowUp(element, { shiftKey }) {
127
129
  if (_dom.isTextField.call(void 0, element)) {
128
130
  if (!shiftKey) {
129
- return element.setSelectionRange(0, 0);
131
+ return _dom.setSelectionRange.call(void 0, element, 0, 0);
130
132
  } else {
131
133
  const { selectionStart, selectionEnd, selectionDirection } = element;
132
134
  const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
133
135
  if (selectionDirection === "forward") {
134
- element.setSelectionRange(start, start);
136
+ _dom.setSelectionRange.call(void 0, element, start, start);
135
137
  } else {
136
- element.setSelectionRange(0, end, "backward");
138
+ _dom.setSelectionRange.call(void 0, element, 0, end, "backward");
137
139
  }
138
140
  }
139
141
  } else if (isNumberInput(element)) {
@@ -144,14 +146,14 @@ var keyDownMap = {
144
146
  if (_dom.isTextField.call(void 0, element)) {
145
147
  const length = element.value.length;
146
148
  if (!shiftKey) {
147
- element.setSelectionRange(length, length);
149
+ _dom.setSelectionRange.call(void 0, element, length, length);
148
150
  } else {
149
151
  const { selectionStart, selectionEnd, selectionDirection } = element;
150
152
  const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
151
153
  if (selectionDirection === "backward") {
152
- element.setSelectionRange(end, end);
154
+ _dom.setSelectionRange.call(void 0, element, end, end);
153
155
  } else {
154
- element.setSelectionRange(start, length, "forward");
156
+ _dom.setSelectionRange.call(void 0, element, start, length, "forward");
155
157
  }
156
158
  }
157
159
  } else if (isNumberInput(element)) {
@@ -8,11 +8,15 @@ var _ERFCHS75cjs = require('./ERFCHS75.cjs');
8
8
  var _OVN5OYWKcjs = require('./OVN5OYWK.cjs');
9
9
 
10
10
  // src/query.ts
11
+ var _misc = require('@ariakit/core/utils/misc');
11
12
  var _dom = require('@testing-library/dom');
12
- var queries = Object.entries(_dom.queries).reduce((queries2, [key, query2]) => {
13
- queries2[key] = (...args) => query2(document.body, ...args);
14
- return queries2;
15
- }, {});
13
+ function createQueries(container = document.body) {
14
+ return Object.entries(_dom.queries).reduce((queries, [key, query2]) => {
15
+ queries[key] = (...args) => query2(container, ...args);
16
+ return queries;
17
+ }, {});
18
+ }
19
+ var documentQueries = createQueries();
16
20
  function matchName(name, accessibleName) {
17
21
  if (accessibleName == null)
18
22
  return false;
@@ -42,7 +46,7 @@ function getNameOption(name, includesHidden) {
42
46
  return matchName(name, label.textContent);
43
47
  };
44
48
  }
45
- function createRoleQuery(role) {
49
+ function createRoleQuery(role, queries = documentQueries) {
46
50
  const createQuery = (query3) => {
47
51
  return (name, options) => {
48
52
  return query3(role, _OVN5OYWKcjs.__spreadValues.call(void 0, {
@@ -85,7 +89,13 @@ function createRoleQuery(role) {
85
89
  ensure
86
90
  });
87
91
  }
88
- function createTextQuery() {
92
+ function createRoleQueries(queries = documentQueries) {
93
+ return _ERFCHS75cjs.roles.reduce((acc, role) => {
94
+ acc[role] = createRoleQuery(role, queries);
95
+ return acc;
96
+ }, {});
97
+ }
98
+ function createTextQuery(queries = documentQueries) {
89
99
  const all = Object.assign(queries.queryAllByText, {
90
100
  wait: queries.findAllByText,
91
101
  ensure: queries.getAllByText
@@ -98,7 +108,7 @@ function createTextQuery() {
98
108
  });
99
109
  return Object.assign(queries.queryByText, { all, wait, ensure });
100
110
  }
101
- function createLabeledQuery() {
111
+ function createLabeledQuery(queries = documentQueries) {
102
112
  const all = Object.assign(queries.queryAllByLabelText, {
103
113
  wait: queries.findAllByLabelText,
104
114
  ensure: queries.getAllByLabelText
@@ -111,14 +121,17 @@ function createLabeledQuery() {
111
121
  });
112
122
  return Object.assign(queries.queryByLabelText, { all, wait, ensure });
113
123
  }
114
- var roleQueries = _ERFCHS75cjs.roles.reduce((acc, role) => {
115
- acc[role] = createRoleQuery(role);
116
- return acc;
117
- }, {});
118
- var query = _OVN5OYWKcjs.__spreadProps.call(void 0, _OVN5OYWKcjs.__spreadValues.call(void 0, {}, roleQueries), {
119
- text: createTextQuery(),
120
- labeled: createLabeledQuery()
121
- });
124
+ function createQueryObject(queries = documentQueries) {
125
+ return _OVN5OYWKcjs.__spreadProps.call(void 0, _OVN5OYWKcjs.__spreadValues.call(void 0, {}, createRoleQueries(queries)), {
126
+ text: createTextQuery(queries),
127
+ labeled: createLabeledQuery(queries),
128
+ within: (element) => {
129
+ _misc.invariant.call(void 0, element, "Unable to create queries for null element");
130
+ return createQueryObject(createQueries(element));
131
+ }
132
+ });
133
+ }
134
+ var query = createQueryObject();
122
135
  var q = query;
123
136
 
124
137
 
package/cjs/index.cjs CHANGED
@@ -24,11 +24,11 @@ var _UWCNB4SRcjs = require('./__chunks/UWCNB4SR.cjs');
24
24
 
25
25
 
26
26
 
27
- var _W53ATX47cjs = require('./__chunks/W53ATX47.cjs');
27
+ var _BIB7E6LNcjs = require('./__chunks/BIB7E6LN.cjs');
28
28
  require('./__chunks/ERFCHS75.cjs');
29
29
 
30
30
 
31
- var _KFHFWZQNcjs = require('./__chunks/KFHFWZQN.cjs');
31
+ var _6OCVCOFLcjs = require('./__chunks/6OCVCOFL.cjs');
32
32
 
33
33
 
34
34
  var _K2XRALNEcjs = require('./__chunks/K2XRALNE.cjs');
@@ -62,4 +62,4 @@ require('./__chunks/OVN5OYWK.cjs');
62
62
 
63
63
 
64
64
 
65
- exports.blur = _CYMYDRLScjs.blur; exports.click = _7U3THWRScjs.click; exports.dispatch = _VD3ERVOFcjs.dispatch; exports.focus = _YH2W6C46cjs.focus; exports.hover = _UWCNB4SRcjs.hover; exports.mouseDown = _GIKCTITRcjs.mouseDown; exports.mouseUp = _QCXNVFD7cjs.mouseUp; exports.press = _KFHFWZQNcjs.press; exports.q = _W53ATX47cjs.q; exports.query = _W53ATX47cjs.query; exports.select = _ISKAHQPCcjs.select; exports.sleep = _HQ3KUD6Fcjs.sleep; exports.tap = _DWIHFDL3cjs.tap; exports.type = _K2XRALNEcjs.type; exports.waitFor = _LG7B6NOGcjs.waitFor;
65
+ exports.blur = _CYMYDRLScjs.blur; exports.click = _7U3THWRScjs.click; exports.dispatch = _VD3ERVOFcjs.dispatch; exports.focus = _YH2W6C46cjs.focus; exports.hover = _UWCNB4SRcjs.hover; exports.mouseDown = _GIKCTITRcjs.mouseDown; exports.mouseUp = _QCXNVFD7cjs.mouseUp; exports.press = _6OCVCOFLcjs.press; exports.q = _BIB7E6LNcjs.q; exports.query = _BIB7E6LNcjs.query; exports.select = _ISKAHQPCcjs.select; exports.sleep = _HQ3KUD6Fcjs.sleep; exports.tap = _DWIHFDL3cjs.tap; exports.type = _K2XRALNEcjs.type; exports.waitFor = _LG7B6NOGcjs.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 _KFHFWZQNcjs = require('./__chunks/KFHFWZQN.cjs');
4
+ var _6OCVCOFLcjs = require('./__chunks/6OCVCOFL.cjs');
5
5
  require('./__chunks/K2XRALNE.cjs');
6
6
  require('./__chunks/CYMYDRLS.cjs');
7
7
  require('./__chunks/YH2W6C46.cjs');
@@ -11,4 +11,4 @@ require('./__chunks/BXOTZFAK.cjs');
11
11
  require('./__chunks/OVN5OYWK.cjs');
12
12
 
13
13
 
14
- exports.press = _KFHFWZQNcjs.press;
14
+ exports.press = _6OCVCOFLcjs.press;
package/cjs/query.cjs CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _W53ATX47cjs = require('./__chunks/W53ATX47.cjs');
5
+ var _BIB7E6LNcjs = require('./__chunks/BIB7E6LN.cjs');
6
6
  require('./__chunks/ERFCHS75.cjs');
7
7
  require('./__chunks/OVN5OYWK.cjs');
8
8
 
9
9
 
10
10
 
11
- exports.q = _W53ATX47cjs.q; exports.query = _W53ATX47cjs.query;
11
+ exports.q = _BIB7E6LNcjs.q; exports.query = _BIB7E6LNcjs.query;
package/cjs/query.d.cts CHANGED
@@ -24,6 +24,7 @@ export declare const query: {
24
24
  all: (<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => T_9[]) & ((id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[]);
25
25
  };
26
26
  };
27
+ within: (element?: HTMLElement | null) => any;
27
28
  alert: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null) & {
28
29
  includesHidden: (name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null;
29
30
  all: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement[]) & {
@@ -2018,6 +2019,7 @@ export declare const q: {
2018
2019
  all: (<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => T_9[]) & ((id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[]);
2019
2020
  };
2020
2021
  };
2022
+ within: (element?: HTMLElement | null) => any;
2021
2023
  alert: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null) & {
2022
2024
  includesHidden: (name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null;
2023
2025
  all: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement[]) & {
package/cjs/query.d.ts CHANGED
@@ -24,6 +24,7 @@ export declare const query: {
24
24
  all: (<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => T_9[]) & ((id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[]);
25
25
  };
26
26
  };
27
+ within: (element?: HTMLElement | null) => any;
27
28
  alert: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null) & {
28
29
  includesHidden: (name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null;
29
30
  all: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement[]) & {
@@ -2018,6 +2019,7 @@ export declare const q: {
2018
2019
  all: (<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => T_9[]) & ((id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[]);
2019
2020
  };
2020
2021
  };
2022
+ within: (element?: HTMLElement | null) => any;
2021
2023
  alert: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null) & {
2022
2024
  includesHidden: (name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null;
2023
2025
  all: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement[]) & {
package/cjs/react.cjs CHANGED
@@ -24,11 +24,11 @@ var _UWCNB4SRcjs = require('./__chunks/UWCNB4SR.cjs');
24
24
 
25
25
 
26
26
 
27
- var _W53ATX47cjs = require('./__chunks/W53ATX47.cjs');
27
+ var _BIB7E6LNcjs = require('./__chunks/BIB7E6LN.cjs');
28
28
  require('./__chunks/ERFCHS75.cjs');
29
29
 
30
30
 
31
- var _KFHFWZQNcjs = require('./__chunks/KFHFWZQN.cjs');
31
+ var _6OCVCOFLcjs = require('./__chunks/6OCVCOFL.cjs');
32
32
 
33
33
 
34
34
  var _K2XRALNEcjs = require('./__chunks/K2XRALNE.cjs');
@@ -91,4 +91,4 @@ async function render2(ui, options) {
91
91
 
92
92
 
93
93
 
94
- exports.blur = _CYMYDRLScjs.blur; exports.click = _7U3THWRScjs.click; exports.dispatch = _VD3ERVOFcjs.dispatch; exports.focus = _YH2W6C46cjs.focus; exports.hover = _UWCNB4SRcjs.hover; exports.mouseDown = _GIKCTITRcjs.mouseDown; exports.mouseUp = _QCXNVFD7cjs.mouseUp; exports.press = _KFHFWZQNcjs.press; exports.q = _W53ATX47cjs.q; exports.query = _W53ATX47cjs.query; exports.render = render2; exports.select = _ISKAHQPCcjs.select; exports.sleep = _HQ3KUD6Fcjs.sleep; exports.tap = _DWIHFDL3cjs.tap; exports.type = _K2XRALNEcjs.type; exports.waitFor = _LG7B6NOGcjs.waitFor;
94
+ exports.blur = _CYMYDRLScjs.blur; exports.click = _7U3THWRScjs.click; exports.dispatch = _VD3ERVOFcjs.dispatch; exports.focus = _YH2W6C46cjs.focus; exports.hover = _UWCNB4SRcjs.hover; exports.mouseDown = _GIKCTITRcjs.mouseDown; exports.mouseUp = _QCXNVFD7cjs.mouseUp; exports.press = _6OCVCOFLcjs.press; exports.q = _BIB7E6LNcjs.q; exports.query = _BIB7E6LNcjs.query; exports.render = render2; exports.select = _ISKAHQPCcjs.select; exports.sleep = _HQ3KUD6Fcjs.sleep; exports.tap = _DWIHFDL3cjs.tap; exports.type = _K2XRALNEcjs.type; exports.waitFor = _LG7B6NOGcjs.waitFor;
@@ -8,11 +8,15 @@ import {
8
8
  } from "./Q65FZOE2.js";
9
9
 
10
10
  // src/query.ts
11
+ import { invariant } from "@ariakit/core/utils/misc";
11
12
  import { queries as baseQueries } from "@testing-library/dom";
12
- var queries = Object.entries(baseQueries).reduce((queries2, [key, query2]) => {
13
- queries2[key] = (...args) => query2(document.body, ...args);
14
- return queries2;
15
- }, {});
13
+ function createQueries(container = document.body) {
14
+ return Object.entries(baseQueries).reduce((queries, [key, query2]) => {
15
+ queries[key] = (...args) => query2(container, ...args);
16
+ return queries;
17
+ }, {});
18
+ }
19
+ var documentQueries = createQueries();
16
20
  function matchName(name, accessibleName) {
17
21
  if (accessibleName == null)
18
22
  return false;
@@ -42,7 +46,7 @@ function getNameOption(name, includesHidden) {
42
46
  return matchName(name, label.textContent);
43
47
  };
44
48
  }
45
- function createRoleQuery(role) {
49
+ function createRoleQuery(role, queries = documentQueries) {
46
50
  const createQuery = (query3) => {
47
51
  return (name, options) => {
48
52
  return query3(role, __spreadValues({
@@ -85,7 +89,13 @@ function createRoleQuery(role) {
85
89
  ensure
86
90
  });
87
91
  }
88
- function createTextQuery() {
92
+ function createRoleQueries(queries = documentQueries) {
93
+ return roles.reduce((acc, role) => {
94
+ acc[role] = createRoleQuery(role, queries);
95
+ return acc;
96
+ }, {});
97
+ }
98
+ function createTextQuery(queries = documentQueries) {
89
99
  const all = Object.assign(queries.queryAllByText, {
90
100
  wait: queries.findAllByText,
91
101
  ensure: queries.getAllByText
@@ -98,7 +108,7 @@ function createTextQuery() {
98
108
  });
99
109
  return Object.assign(queries.queryByText, { all, wait, ensure });
100
110
  }
101
- function createLabeledQuery() {
111
+ function createLabeledQuery(queries = documentQueries) {
102
112
  const all = Object.assign(queries.queryAllByLabelText, {
103
113
  wait: queries.findAllByLabelText,
104
114
  ensure: queries.getAllByLabelText
@@ -111,14 +121,17 @@ function createLabeledQuery() {
111
121
  });
112
122
  return Object.assign(queries.queryByLabelText, { all, wait, ensure });
113
123
  }
114
- var roleQueries = roles.reduce((acc, role) => {
115
- acc[role] = createRoleQuery(role);
116
- return acc;
117
- }, {});
118
- var query = __spreadProps(__spreadValues({}, roleQueries), {
119
- text: createTextQuery(),
120
- labeled: createLabeledQuery()
121
- });
124
+ function createQueryObject(queries = documentQueries) {
125
+ return __spreadProps(__spreadValues({}, createRoleQueries(queries)), {
126
+ text: createTextQuery(queries),
127
+ labeled: createLabeledQuery(queries),
128
+ within: (element) => {
129
+ invariant(element, "Unable to create queries for null element");
130
+ return createQueryObject(createQueries(element));
131
+ }
132
+ });
133
+ }
134
+ var query = createQueryObject();
122
135
  var q = query;
123
136
 
124
137
  export {
@@ -22,7 +22,7 @@ import {
22
22
  } from "./Q65FZOE2.js";
23
23
 
24
24
  // src/press.ts
25
- import { isTextField } from "@ariakit/core/utils/dom";
25
+ import { isTextField, setSelectionRange } from "@ariakit/core/utils/dom";
26
26
  import {
27
27
  getNextTabbable,
28
28
  getPreviousTabbable,
@@ -85,14 +85,14 @@ var keyDownMap = {
85
85
  if (isTextField(element)) {
86
86
  const { value, selectionEnd } = element;
87
87
  const end = Math.min(value.length, shiftKey ? selectionEnd != null ? selectionEnd : 0 : 0);
88
- element.setSelectionRange(0, end, "backward");
88
+ setSelectionRange(element, 0, end, "backward");
89
89
  }
90
90
  },
91
91
  async End(element, { shiftKey }) {
92
92
  if (isTextField(element)) {
93
93
  const { value, selectionStart } = element;
94
94
  const start = shiftKey ? selectionStart != null ? selectionStart : 0 : value.length;
95
- element.setSelectionRange(start, value.length, "forward");
95
+ setSelectionRange(element, start, value.length, "forward");
96
96
  }
97
97
  },
98
98
  async ArrowLeft(element, { shiftKey }) {
@@ -102,7 +102,8 @@ var keyDownMap = {
102
102
  const collapsing = !shiftKey && start !== end;
103
103
  const nextStart = Math.max(0, collapsing ? start : start - 1);
104
104
  const nextEnd = Math.min(value.length, shiftKey ? end : nextStart);
105
- element.setSelectionRange(
105
+ setSelectionRange(
106
+ element,
106
107
  nextStart,
107
108
  nextEnd,
108
109
  selectionDirection || "backward"
@@ -116,7 +117,8 @@ var keyDownMap = {
116
117
  const collapsing = !shiftKey && start !== end;
117
118
  const nextEnd = Math.min(value.length, collapsing ? end : end + 1);
118
119
  const nextStart = Math.max(0, shiftKey ? start : nextEnd);
119
- element.setSelectionRange(
120
+ setSelectionRange(
121
+ element,
120
122
  nextStart,
121
123
  nextEnd,
122
124
  selectionDirection || "forward"
@@ -126,14 +128,14 @@ var keyDownMap = {
126
128
  async ArrowUp(element, { shiftKey }) {
127
129
  if (isTextField(element)) {
128
130
  if (!shiftKey) {
129
- return element.setSelectionRange(0, 0);
131
+ return setSelectionRange(element, 0, 0);
130
132
  } else {
131
133
  const { selectionStart, selectionEnd, selectionDirection } = element;
132
134
  const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
133
135
  if (selectionDirection === "forward") {
134
- element.setSelectionRange(start, start);
136
+ setSelectionRange(element, start, start);
135
137
  } else {
136
- element.setSelectionRange(0, end, "backward");
138
+ setSelectionRange(element, 0, end, "backward");
137
139
  }
138
140
  }
139
141
  } else if (isNumberInput(element)) {
@@ -144,14 +146,14 @@ var keyDownMap = {
144
146
  if (isTextField(element)) {
145
147
  const length = element.value.length;
146
148
  if (!shiftKey) {
147
- element.setSelectionRange(length, length);
149
+ setSelectionRange(element, length, length);
148
150
  } else {
149
151
  const { selectionStart, selectionEnd, selectionDirection } = element;
150
152
  const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
151
153
  if (selectionDirection === "backward") {
152
- element.setSelectionRange(end, end);
154
+ setSelectionRange(element, end, end);
153
155
  } else {
154
- element.setSelectionRange(start, length, "forward");
156
+ setSelectionRange(element, start, length, "forward");
155
157
  }
156
158
  }
157
159
  } else if (isNumberInput(element)) {
package/esm/index.js CHANGED
@@ -24,11 +24,11 @@ import {
24
24
  import {
25
25
  q,
26
26
  query
27
- } from "./__chunks/2L7BSF5A.js";
27
+ } from "./__chunks/6GDQHEBE.js";
28
28
  import "./__chunks/CWTUOQ5Z.js";
29
29
  import {
30
30
  press
31
- } from "./__chunks/YRF6BLTM.js";
31
+ } from "./__chunks/HT6XK7H3.js";
32
32
  import {
33
33
  type
34
34
  } from "./__chunks/H2ALBSTH.js";
package/esm/press.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  press
4
- } from "./__chunks/YRF6BLTM.js";
4
+ } from "./__chunks/HT6XK7H3.js";
5
5
  import "./__chunks/H2ALBSTH.js";
6
6
  import "./__chunks/QE2YCTHV.js";
7
7
  import "./__chunks/HZKYXBIJ.js";
package/esm/query.d.ts CHANGED
@@ -24,6 +24,7 @@ export declare const query: {
24
24
  all: (<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => T_9[]) & ((id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[]);
25
25
  };
26
26
  };
27
+ within: (element?: HTMLElement | null) => any;
27
28
  alert: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null) & {
28
29
  includesHidden: (name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null;
29
30
  all: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement[]) & {
@@ -2018,6 +2019,7 @@ export declare const q: {
2018
2019
  all: (<T_9 extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => T_9[]) & ((id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[]);
2019
2020
  };
2020
2021
  };
2022
+ within: (element?: HTMLElement | null) => any;
2021
2023
  alert: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null) & {
2022
2024
  includesHidden: (name?: string | RegExp, options?: ByRoleOptions) => HTMLElement | null;
2023
2025
  all: ((name?: string | RegExp, options?: ByRoleOptions) => HTMLElement[]) & {
package/esm/query.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  q,
4
4
  query
5
- } from "./__chunks/2L7BSF5A.js";
5
+ } from "./__chunks/6GDQHEBE.js";
6
6
  import "./__chunks/CWTUOQ5Z.js";
7
7
  import "./__chunks/Q65FZOE2.js";
8
8
  export {
package/esm/react.js CHANGED
@@ -24,11 +24,11 @@ import {
24
24
  import {
25
25
  q,
26
26
  query
27
- } from "./__chunks/2L7BSF5A.js";
27
+ } from "./__chunks/6GDQHEBE.js";
28
28
  import "./__chunks/CWTUOQ5Z.js";
29
29
  import {
30
30
  press
31
- } from "./__chunks/YRF6BLTM.js";
31
+ } from "./__chunks/HT6XK7H3.js";
32
32
  import {
33
33
  type
34
34
  } from "./__chunks/H2ALBSTH.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariakit/test",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
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.4.4",
32
+ "@ariakit/core": "0.4.5",
33
33
  "@testing-library/dom": "^8.0.0 || ^9.0.0"
34
34
  },
35
35
  "peerDependencies": {