@ariakit/react-core 0.4.3 → 0.4.4

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 (121) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/cjs/__chunks/{GYHP7IYG.cjs → 4XVTH6OR.cjs} +2 -2
  3. package/cjs/__chunks/{IHFGURUM.cjs → 54YZYOPA.cjs} +2 -2
  4. package/cjs/__chunks/{DCTXNU2X.cjs → COWKMNMZ.cjs} +3 -3
  5. package/cjs/__chunks/{HFNM6QV4.cjs → DAOFDKV2.cjs} +1 -1
  6. package/cjs/__chunks/{3C4RFBCG.cjs → EYZZO5IT.cjs} +1 -1
  7. package/cjs/__chunks/{3MKOUH5M.cjs → HPNCFYQJ.cjs} +4 -4
  8. package/cjs/__chunks/{A356CGND.cjs → JDCTLYQ4.cjs} +1 -1
  9. package/cjs/__chunks/{T5BWR4CB.cjs → KDTFHBKU.cjs} +2 -2
  10. package/cjs/__chunks/{NZSB7HSZ.cjs → LY4LCJM6.cjs} +2 -2
  11. package/cjs/__chunks/{7DQ2LBH2.cjs → QUHFOHHT.cjs} +35 -0
  12. package/cjs/__chunks/{AJF5DT5A.cjs → YO7LLGVA.cjs} +2 -2
  13. package/cjs/__chunks/{3XXW4Y4D.cjs → Z2VL7JHX.cjs} +2 -2
  14. package/cjs/__chunks/{CWS5RZSU.cjs → ZTAE5B6W.cjs} +9 -1
  15. package/cjs/checkbox/checkbox-check.cjs +2 -2
  16. package/cjs/collection/collection-renderer.d.cts +0 -2
  17. package/cjs/collection/collection-renderer.d.ts +0 -2
  18. package/cjs/combobox/combobox-cancel.cjs +1 -1
  19. package/cjs/combobox/combobox-disclosure.cjs +1 -1
  20. package/cjs/combobox/combobox-item-check.cjs +2 -2
  21. package/cjs/combobox/combobox-item.cjs +2 -2
  22. package/cjs/combobox/combobox-popover.cjs +23 -5
  23. package/cjs/combobox/combobox.cjs +14 -11
  24. package/cjs/combobox/combobox.d.cts +20 -0
  25. package/cjs/combobox/combobox.d.ts +20 -0
  26. package/cjs/composite/composite-input.cjs +91 -6
  27. package/cjs/composite/composite-input.d.cts +2 -0
  28. package/cjs/composite/composite-input.d.ts +2 -0
  29. package/cjs/composite/composite-item.cjs +2 -2
  30. package/cjs/composite/composite-overflow-disclosure.cjs +2 -2
  31. package/cjs/composite/composite-overflow.cjs +3 -3
  32. package/cjs/composite/composite-renderer.d.cts +0 -2
  33. package/cjs/composite/composite-renderer.d.ts +0 -2
  34. package/cjs/dialog/dialog-dismiss.cjs +2 -2
  35. package/cjs/dialog/dialog.cjs +2 -2
  36. package/cjs/form/form-radio.cjs +3 -3
  37. package/cjs/hovercard/hovercard-disclosure.cjs +1 -1
  38. package/cjs/hovercard/hovercard-dismiss.cjs +4 -4
  39. package/cjs/hovercard/hovercard.cjs +4 -4
  40. package/cjs/menu/menu-button-arrow.cjs +2 -2
  41. package/cjs/menu/menu-dismiss.cjs +4 -4
  42. package/cjs/menu/menu-item-check.cjs +2 -2
  43. package/cjs/menu/menu-item-checkbox.cjs +3 -3
  44. package/cjs/menu/menu-item-radio.cjs +5 -5
  45. package/cjs/menu/menu-item.cjs +3 -3
  46. package/cjs/menu/menu.cjs +5 -5
  47. package/cjs/popover/popover-disclosure-arrow.cjs +2 -2
  48. package/cjs/popover/popover-dismiss.cjs +3 -3
  49. package/cjs/popover/popover.cjs +3 -3
  50. package/cjs/radio/radio.cjs +3 -3
  51. package/cjs/select/select-arrow.cjs +3 -3
  52. package/cjs/select/select-item-check.cjs +2 -2
  53. package/cjs/select/select-item.cjs +2 -2
  54. package/cjs/select/select-popover.cjs +4 -4
  55. package/cjs/select/select.cjs +3 -3
  56. package/cjs/tab/tab.cjs +4 -4
  57. package/cjs/toolbar/toolbar-container.cjs +3 -3
  58. package/cjs/toolbar/toolbar-input.cjs +3 -7
  59. package/cjs/toolbar/toolbar-input.d.cts +3 -2
  60. package/cjs/toolbar/toolbar-input.d.ts +3 -2
  61. package/cjs/toolbar/toolbar-item.cjs +3 -3
  62. package/cjs/tooltip/tooltip.cjs +5 -5
  63. package/esm/__chunks/{LABIXQLW.js → 44PDY2W5.js} +1 -1
  64. package/esm/__chunks/{FYNSL2D5.js → 5H3YXAUC.js} +1 -1
  65. package/esm/__chunks/{JCOBPKEI.js → BY6P32UK.js} +1 -1
  66. package/esm/__chunks/{C5HA76JU.js → DSUHLHLE.js} +1 -1
  67. package/esm/__chunks/{NN4HLGKS.js → F2RFUFO2.js} +1 -1
  68. package/esm/__chunks/{2VWKZYYT.js → H5N72W37.js} +1 -1
  69. package/esm/__chunks/{NQ4PTILT.js → IOUGWXY5.js} +9 -1
  70. package/esm/__chunks/{X3V2DT2U.js → LTYEFENI.js} +1 -1
  71. package/esm/__chunks/{HW63KLP5.js → NFPDVAAW.js} +1 -1
  72. package/esm/__chunks/{XK6CE2M5.js → NHVUMSP7.js} +1 -1
  73. package/esm/__chunks/{RAKW656I.js → Q4PZFBSW.js} +1 -1
  74. package/esm/__chunks/{ONUY4D7O.js → R33ISPJY.js} +36 -1
  75. package/esm/__chunks/{6VDNHSLX.js → XEJ23EM6.js} +2 -2
  76. package/esm/checkbox/checkbox-check.js +1 -1
  77. package/esm/collection/collection-renderer.d.ts +0 -2
  78. package/esm/combobox/combobox-cancel.js +1 -1
  79. package/esm/combobox/combobox-disclosure.js +1 -1
  80. package/esm/combobox/combobox-item-check.js +1 -1
  81. package/esm/combobox/combobox-item.js +1 -1
  82. package/esm/combobox/combobox-popover.js +22 -4
  83. package/esm/combobox/combobox.d.ts +20 -0
  84. package/esm/combobox/combobox.js +14 -11
  85. package/esm/composite/composite-input.d.ts +2 -0
  86. package/esm/composite/composite-input.js +92 -7
  87. package/esm/composite/composite-item.js +1 -1
  88. package/esm/composite/composite-overflow-disclosure.js +1 -1
  89. package/esm/composite/composite-overflow.js +2 -2
  90. package/esm/composite/composite-renderer.d.ts +0 -2
  91. package/esm/dialog/dialog-dismiss.js +1 -1
  92. package/esm/dialog/dialog.js +1 -1
  93. package/esm/form/form-radio.js +2 -2
  94. package/esm/hovercard/hovercard-disclosure.js +1 -1
  95. package/esm/hovercard/hovercard-dismiss.js +3 -3
  96. package/esm/hovercard/hovercard.js +3 -3
  97. package/esm/menu/menu-button-arrow.js +1 -1
  98. package/esm/menu/menu-dismiss.js +3 -3
  99. package/esm/menu/menu-item-check.js +1 -1
  100. package/esm/menu/menu-item-checkbox.js +2 -2
  101. package/esm/menu/menu-item-radio.js +3 -3
  102. package/esm/menu/menu-item.js +2 -2
  103. package/esm/menu/menu.js +3 -3
  104. package/esm/popover/popover-disclosure-arrow.js +1 -1
  105. package/esm/popover/popover-dismiss.js +2 -2
  106. package/esm/popover/popover.js +2 -2
  107. package/esm/radio/radio.js +2 -2
  108. package/esm/select/select-arrow.js +2 -2
  109. package/esm/select/select-item-check.js +1 -1
  110. package/esm/select/select-item.js +1 -1
  111. package/esm/select/select-popover.js +2 -2
  112. package/esm/select/select.js +2 -2
  113. package/esm/tab/tab.js +1 -1
  114. package/esm/toolbar/toolbar-container.js +2 -2
  115. package/esm/toolbar/toolbar-input.d.ts +3 -2
  116. package/esm/toolbar/toolbar-input.js +2 -6
  117. package/esm/toolbar/toolbar-item.js +2 -2
  118. package/esm/tooltip/tooltip.js +3 -3
  119. package/package.json +2 -2
  120. package/cjs/__chunks/WGZQRLXV.cjs +0 -84
  121. package/esm/__chunks/RPGNBKKU.js +0 -84
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @ariakit/react-core
2
2
 
3
+ ## 0.4.4
4
+
5
+ ### Combobox `autoFocusOnHide` behavior
6
+
7
+ Previously, the [`autoFocusOnHide`](https://ariakit.org/reference/combobox-popover#autofocusonhide) feature on [`ComboboxPopover`](https://ariakit.org/reference/combobox-popover) was turned off by default. Most of the time, this didn't have any practical impact because the combobox input element was already focused when the popover was hidden.
8
+
9
+ Now, this feature is enabled by default and should work consistently even when [`virtualFocus`](https://ariakit.org/reference/combobox-provider#virtualfocus) is set to `false`.
10
+
11
+ ### Better SVG strokes
12
+
13
+ The `strokeWidth` property on SVG elements rendered by [`CheckboxCheck`](https://ariakit.org/reference/checkbox-check), [`ComboboxCancel`](https://ariakit.org/reference/combobox-cancel), [`ComboboxDisclosure`](https://ariakit.org/reference/combobox-disclosure), [`DialogDismiss`](https://ariakit.org/reference/dialog-dismiss), [`HovercardDisclosure`](https://ariakit.org/reference/hovercard-disclosure), [`PopoverDisclosureArrow`](https://ariakit.org/reference/popover-disclosure-arrow), and all components that use any of these now defaults to `1.5px` instead of `1.5pt`. This should make the strokes slightly thinner.
14
+
15
+ Remember, you can always override the SVG element rendered by these components by rendering custom `children`.
16
+
17
+ ### Minimum value length to show combobox options
18
+
19
+ A new [`showMinLength`](https://ariakit.org/reference/combobox#showminlength) prop has been added to the [`Combobox`](https://ariakit.org/reference/combobox) component. This prop lets you set the minimum length of the value before the combobox options appear. The default value is `0`.
20
+
21
+ ```jsx
22
+ <Combobox showMinLength={2} />
23
+ ```
24
+
25
+ Previously, achieving this behavior required combining three separate props: [`showOnChange`](https://ariakit.org/reference/combobox#showonchange), [`showOnClick`](https://ariakit.org/reference/combobox#showonclick), and [`showOnKeyPress`](https://ariakit.org/reference/combobox#showonkeypress). We've added this prop to simplify this common task.
26
+
27
+ These props continue to work as expected as they can be used to customize the behavior for each distinct event.
28
+
29
+ ### Rendering composite items as input elements
30
+
31
+ We've added the ability to render [`CompositeItem`](https://ariakit.org/reference/composite-item) as an input element using the [`render`](https://ariakit.org/reference/composite-item#render) prop:
32
+
33
+ ```jsx
34
+ <CompositeItem render={<input />} />
35
+ ```
36
+
37
+ Before, you could only do this with the experimental `CompositeInput` component. Now, this functionality is integrated directly into the [`CompositeItem`](https://ariakit.org/reference/composite-item) component.
38
+
39
+ ### Other updates
40
+
41
+ - Fixed [`Dialog`](https://ariakit.org/reference/dialog) calling [`autoFocusOnHide`](https://ariakit.org/reference/dialog#autofocusonhide) twice.
42
+ - Improved JSDocs.
43
+ - Updated dependencies: `@ariakit/core@0.4.4`
44
+
3
45
  ## 0.4.3
4
46
 
5
47
  - Fixed TypeScript types for `ref`.
@@ -10,7 +10,7 @@ var _MNMEDFSMcjs = require('./MNMEDFSM.cjs');
10
10
  var _Q6QJEXBKcjs = require('./Q6QJEXBK.cjs');
11
11
 
12
12
 
13
- var _7DQ2LBH2cjs = require('./7DQ2LBH2.cjs');
13
+ var _QUHFOHHTcjs = require('./QUHFOHHT.cjs');
14
14
 
15
15
 
16
16
 
@@ -112,7 +112,7 @@ var useMenuItem = _NGD3IQDBcjs.createHook.call(void 0,
112
112
  }, props), {
113
113
  onClick
114
114
  });
115
- props = _7DQ2LBH2cjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
115
+ props = _QUHFOHHTcjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
116
116
  store,
117
117
  preventScrollOnKeyDown
118
118
  }, props));
@@ -4,7 +4,7 @@
4
4
  var _OHXBMXTNcjs = require('./OHXBMXTN.cjs');
5
5
 
6
6
 
7
- var _7DQ2LBH2cjs = require('./7DQ2LBH2.cjs');
7
+ var _QUHFOHHTcjs = require('./QUHFOHHT.cjs');
8
8
 
9
9
 
10
10
 
@@ -147,7 +147,7 @@ var useRadio = _NGD3IQDBcjs.createHook.call(void 0, function useRadio2(_a) {
147
147
  onClick,
148
148
  onFocus
149
149
  });
150
- props = _7DQ2LBH2cjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
150
+ props = _QUHFOHHTcjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
151
151
  store,
152
152
  clickOnEnter: !nativeRadio
153
153
  }, props));
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _CWS5RZSUcjs = require('./CWS5RZSU.cjs');
5
+ var _ZTAE5B6Wcjs = require('./ZTAE5B6W.cjs');
6
6
 
7
7
 
8
8
 
@@ -355,7 +355,7 @@ var usePopover = _NGD3IQDBcjs.createHook.call(void 0,
355
355
  position: "relative"
356
356
  }, props.style)
357
357
  });
358
- props = _CWS5RZSUcjs.useDialog.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
358
+ props = _ZTAE5B6Wcjs.useDialog.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
359
359
  store,
360
360
  modal,
361
361
  portal,
@@ -368,7 +368,7 @@ var usePopover = _NGD3IQDBcjs.createHook.call(void 0,
368
368
  return props;
369
369
  }
370
370
  );
371
- var Popover = _CWS5RZSUcjs.createDialogComponent.call(void 0,
371
+ var Popover = _ZTAE5B6Wcjs.createDialogComponent.call(void 0,
372
372
  _NGD3IQDBcjs.forwardRef.call(void 0, function Popover2(props) {
373
373
  const htmlProps = usePopover(props);
374
374
  return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
@@ -45,7 +45,7 @@ var useDialogDismiss = _NGD3IQDBcjs.createHook.call(void 0,
45
45
  stroke: "currentColor",
46
46
  strokeLinecap: "round",
47
47
  strokeLinejoin: "round",
48
- strokeWidth: "1.5pt",
48
+ strokeWidth: 1.5,
49
49
  viewBox: "0 0 16 16",
50
50
  height: "1em",
51
51
  width: "1em",
@@ -44,7 +44,7 @@ var usePopoverDisclosureArrow = _NGD3IQDBcjs.createHook.call(void 0, function us
44
44
  stroke: "currentColor",
45
45
  strokeLinecap: "round",
46
46
  strokeLinejoin: "round",
47
- strokeWidth: "1.5pt",
47
+ strokeWidth: 1.5,
48
48
  viewBox: "0 0 16 16",
49
49
  height: "1em",
50
50
  width: "1em",
@@ -6,10 +6,10 @@
6
6
  var _KXQOQQ5Bcjs = require('./KXQOQQ5B.cjs');
7
7
 
8
8
 
9
- var _DCTXNU2Xcjs = require('./DCTXNU2X.cjs');
9
+ var _COWKMNMZcjs = require('./COWKMNMZ.cjs');
10
10
 
11
11
 
12
- var _CWS5RZSUcjs = require('./CWS5RZSU.cjs');
12
+ var _ZTAE5B6Wcjs = require('./ZTAE5B6W.cjs');
13
13
 
14
14
 
15
15
 
@@ -284,7 +284,7 @@ var useHovercard = _NGD3IQDBcjs.createHook.call(void 0,
284
284
  const autoFocusOnShow = store.useState(
285
285
  (state) => modal || state.autoFocusOnShow
286
286
  );
287
- props = _DCTXNU2Xcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
287
+ props = _COWKMNMZcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
288
288
  store,
289
289
  modal,
290
290
  portal,
@@ -305,7 +305,7 @@ var useHovercard = _NGD3IQDBcjs.createHook.call(void 0,
305
305
  return props;
306
306
  }
307
307
  );
308
- var Hovercard = _CWS5RZSUcjs.createDialogComponent.call(void 0,
308
+ var Hovercard = _ZTAE5B6Wcjs.createDialogComponent.call(void 0,
309
309
  _NGD3IQDBcjs.forwardRef.call(void 0, function Hovercard2(props) {
310
310
  const htmlProps = useHovercard(props);
311
311
  return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
@@ -26,7 +26,7 @@ var checkmark = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
26
26
  stroke: "currentColor",
27
27
  strokeLinecap: "round",
28
28
  strokeLinejoin: "round",
29
- strokeWidth: "1.5pt",
29
+ strokeWidth: 1.5,
30
30
  viewBox: "0 0 16 16",
31
31
  height: "1em",
32
32
  width: "1em",
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _3XXW4Y4Dcjs = require('./3XXW4Y4D.cjs');
4
+ var _Z2VL7JHXcjs = require('./Z2VL7JHX.cjs');
5
5
 
6
6
 
7
7
  var _XRPBWSUIcjs = require('./XRPBWSUI.cjs');
@@ -22,7 +22,7 @@ var useHovercardDismiss = _NGD3IQDBcjs.createHook.call(void 0,
22
22
  var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
23
23
  const context = _XRPBWSUIcjs.useHovercardScopedContext.call(void 0, );
24
24
  store = store || context;
25
- props = _3XXW4Y4Dcjs.usePopoverDismiss.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
25
+ props = _Z2VL7JHXcjs.usePopoverDismiss.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
26
26
  return props;
27
27
  }
28
28
  );
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _3C4RFBCGcjs = require('./3C4RFBCG.cjs');
4
+ var _EYZZO5ITcjs = require('./EYZZO5IT.cjs');
5
5
 
6
6
 
7
7
  var _HZDOLHROcjs = require('./HZDOLHRO.cjs');
@@ -22,7 +22,7 @@ var useSelectArrow = _NGD3IQDBcjs.createHook.call(void 0,
22
22
  var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
23
23
  const context = _HZDOLHROcjs.useSelectContext.call(void 0, );
24
24
  store = store || context;
25
- props = _3C4RFBCGcjs.usePopoverDisclosureArrow.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
25
+ props = _EYZZO5ITcjs.usePopoverDisclosureArrow.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
26
26
  return props;
27
27
  }
28
28
  );
@@ -9,6 +9,7 @@ var _HD5AHCRIcjs = require('./HD5AHCRI.cjs');
9
9
 
10
10
 
11
11
 
12
+
12
13
  var _6ZZYUFPWcjs = require('./6ZZYUFPW.cjs');
13
14
 
14
15
 
@@ -44,6 +45,8 @@ var _react = require('react');
44
45
 
45
46
 
46
47
 
48
+
49
+
47
50
  var _dom = require('@ariakit/core/utils/dom');
48
51
  var _events = require('@ariakit/core/utils/events');
49
52
 
@@ -52,6 +55,9 @@ var _events = require('@ariakit/core/utils/events');
52
55
  var _misc = require('@ariakit/core/utils/misc');
53
56
  var _jsxruntime = require('react/jsx-runtime');
54
57
  var TagName = "button";
58
+ function isTextbox(element) {
59
+ return element.isContentEditable || _dom.isTextField.call(void 0, element);
60
+ }
55
61
  function isEditableElement(element) {
56
62
  if (element.isContentEditable)
57
63
  return true;
@@ -59,6 +65,16 @@ function isEditableElement(element) {
59
65
  return true;
60
66
  return element.tagName === "INPUT" && !_dom.isButton.call(void 0, element);
61
67
  }
68
+ function getValueLength(element) {
69
+ if (_dom.isTextField.call(void 0, element)) {
70
+ return element.value.length;
71
+ } else if (element.isContentEditable) {
72
+ const range = _dom.getDocument.call(void 0, element).createRange();
73
+ range.selectNodeContents(element);
74
+ return range.toString().length;
75
+ }
76
+ return 0;
77
+ }
62
78
  function getNextPageOffset(scrollingElement, pageUp = false) {
63
79
  const height = scrollingElement.clientHeight;
64
80
  const { top } = scrollingElement.getBoundingClientRect();
@@ -217,6 +233,9 @@ var useCompositeItem = _NGD3IQDBcjs.createHook.call(void 0,
217
233
  return;
218
234
  const { virtualFocus: virtualFocus2, baseElement: baseElement2 } = store.getState();
219
235
  store.setActiveId(id);
236
+ if (isTextbox(event.currentTarget)) {
237
+ _6ZZYUFPWcjs.selectTextField.call(void 0, event.currentTarget);
238
+ }
220
239
  if (!virtualFocus2)
221
240
  return;
222
241
  if (!_events.isSelfTarget.call(void 0, event))
@@ -303,6 +322,22 @@ var useCompositeItem = _NGD3IQDBcjs.createHook.call(void 0,
303
322
  };
304
323
  const action = keyMap[event.key];
305
324
  if (action) {
325
+ if (isTextbox(currentTarget)) {
326
+ const selection = _dom.getTextboxSelection.call(void 0, currentTarget);
327
+ const isLeft = isHorizontal && event.key === "ArrowLeft";
328
+ const isRight = isHorizontal && event.key === "ArrowRight";
329
+ const isUp = isVertical && event.key === "ArrowUp";
330
+ const isDown = isVertical && event.key === "ArrowDown";
331
+ if (isRight || isDown) {
332
+ if (selection.end !== getValueLength(currentTarget)) {
333
+ return;
334
+ }
335
+ } else if (isLeft || isUp) {
336
+ if (selection.start !== 0) {
337
+ return;
338
+ }
339
+ }
340
+ }
306
341
  const nextId = action();
307
342
  if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
308
343
  if (!moveOnKeyPressProp(event))
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _7DQ2LBH2cjs = require('./7DQ2LBH2.cjs');
4
+ var _QUHFOHHTcjs = require('./QUHFOHHT.cjs');
5
5
 
6
6
 
7
7
  var _MVDQWSSVcjs = require('./MVDQWSSV.cjs');
@@ -23,7 +23,7 @@ var useToolbarItem = _NGD3IQDBcjs.createHook.call(void 0,
23
23
  var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
24
24
  const context = _MVDQWSSVcjs.useToolbarContext.call(void 0, );
25
25
  store = store || context;
26
- props = _7DQ2LBH2cjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
26
+ props = _QUHFOHHTcjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
27
27
  return props;
28
28
  }
29
29
  );
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _HFNM6QV4cjs = require('./HFNM6QV4.cjs');
4
+ var _DAOFDKV2cjs = require('./DAOFDKV2.cjs');
5
5
 
6
6
 
7
7
  var _77BAEZ2Zcjs = require('./77BAEZ2Z.cjs');
@@ -22,7 +22,7 @@ var usePopoverDismiss = _NGD3IQDBcjs.createHook.call(void 0,
22
22
  var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
23
23
  const context = _77BAEZ2Zcjs.usePopoverScopedContext.call(void 0, );
24
24
  store = store || context;
25
- props = _HFNM6QV4cjs.useDialogDismiss.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
25
+ props = _DAOFDKV2cjs.useDialogDismiss.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
26
26
  return props;
27
27
  }
28
28
  );
@@ -390,6 +390,7 @@ var useDialog = _NGD3IQDBcjs.createHook.call(void 0, function useDialog2(_a) {
390
390
  },
391
391
  [store, finalFocus, autoFocusOnHideProp]
392
392
  );
393
+ const focusedOnHideRef = _react.useRef.call(void 0, false);
393
394
  _TW3SFX4Ccjs.useSafeLayoutEffect.call(void 0, () => {
394
395
  if (open)
395
396
  return;
@@ -398,6 +399,7 @@ var useDialog = _NGD3IQDBcjs.createHook.call(void 0, function useDialog2(_a) {
398
399
  if (!mayAutoFocusOnHide)
399
400
  return;
400
401
  const dialog = ref.current;
402
+ focusedOnHideRef.current = true;
401
403
  focusOnHide(dialog);
402
404
  }, [open, hasOpened, domReady, mayAutoFocusOnHide, focusOnHide]);
403
405
  _react.useEffect.call(void 0, () => {
@@ -406,7 +408,13 @@ var useDialog = _NGD3IQDBcjs.createHook.call(void 0, function useDialog2(_a) {
406
408
  if (!mayAutoFocusOnHide)
407
409
  return;
408
410
  const dialog = ref.current;
409
- return () => focusOnHide(dialog);
411
+ return () => {
412
+ if (focusedOnHideRef.current) {
413
+ focusedOnHideRef.current = false;
414
+ return;
415
+ }
416
+ focusOnHide(dialog);
417
+ };
410
418
  }, [hasOpened, mayAutoFocusOnHide, focusOnHide]);
411
419
  const hideOnEscapeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, hideOnEscape);
412
420
  _react.useEffect.call(void 0, () => {
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _A356CGNDcjs = require('../__chunks/A356CGND.cjs');
5
+ var _JDCTLYQ4cjs = require('../__chunks/JDCTLYQ4.cjs');
6
6
  require('../__chunks/ERFHNHON.cjs');
7
7
  require('../__chunks/NGD3IQDB.cjs');
8
8
  require('../__chunks/TW3SFX4C.cjs');
@@ -11,4 +11,4 @@ require('../__chunks/AV6KTKLE.cjs');
11
11
 
12
12
 
13
13
 
14
- exports.CheckboxCheck = _A356CGNDcjs.CheckboxCheck; exports.useCheckboxCheck = _A356CGNDcjs.useCheckboxCheck;
14
+ exports.CheckboxCheck = _JDCTLYQ4cjs.CheckboxCheck; exports.useCheckboxCheck = _JDCTLYQ4cjs.useCheckboxCheck;
@@ -296,9 +296,7 @@ export declare function useCollectionRenderer<T extends Item = any>({ store, ite
296
296
  onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
297
297
  onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
298
298
  onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
299
- onPointerEnterCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
300
299
  onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
301
- onPointerLeaveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
302
300
  onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
303
301
  onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
304
302
  onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
@@ -296,9 +296,7 @@ export declare function useCollectionRenderer<T extends Item = any>({ store, ite
296
296
  onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
297
297
  onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
298
298
  onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
299
- onPointerEnterCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
300
299
  onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
301
- onPointerLeaveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
302
300
  onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
303
301
  onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
304
302
  onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
@@ -44,7 +44,7 @@ var children = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
44
44
  stroke: "currentColor",
45
45
  strokeLinecap: "round",
46
46
  strokeLinejoin: "round",
47
- strokeWidth: "1pt",
47
+ strokeWidth: 1.5,
48
48
  width: "1em",
49
49
  height: "1em",
50
50
  pointerEvents: "none",
@@ -43,7 +43,7 @@ var children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
43
43
  stroke: "currentColor",
44
44
  strokeLinecap: "round",
45
45
  strokeLinejoin: "round",
46
- strokeWidth: "1.5pt",
46
+ strokeWidth: 1.5,
47
47
  viewBox: "0 0 16 16",
48
48
  height: "1em",
49
49
  width: "1em",
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _A356CGNDcjs = require('../__chunks/A356CGND.cjs');
4
+ var _JDCTLYQ4cjs = require('../__chunks/JDCTLYQ4.cjs');
5
5
  require('../__chunks/ERFHNHON.cjs');
6
6
 
7
7
 
@@ -31,7 +31,7 @@ var useComboboxItemCheck = _NGD3IQDBcjs.createHook.call(void 0, function useComb
31
31
  var _b = _a, { store, checked } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store", "checked"]);
32
32
  const context = _react.useContext.call(void 0, _2IJSEADJcjs.ComboboxItemCheckedContext);
33
33
  checked = checked != null ? checked : context;
34
- props = _A356CGNDcjs.useCheckboxCheck.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), { checked }));
34
+ props = _JDCTLYQ4cjs.useCheckboxCheck.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), { checked }));
35
35
  return props;
36
36
  });
37
37
  var ComboboxItemCheck = _NGD3IQDBcjs.forwardRef.call(void 0, function ComboboxItemCheck2(props) {
@@ -4,7 +4,7 @@
4
4
  var _Q6QJEXBKcjs = require('../__chunks/Q6QJEXBK.cjs');
5
5
 
6
6
 
7
- var _7DQ2LBH2cjs = require('../__chunks/7DQ2LBH2.cjs');
7
+ var _QUHFOHHTcjs = require('../__chunks/QUHFOHHT.cjs');
8
8
  require('../__chunks/U4NXCMZ3.cjs');
9
9
 
10
10
 
@@ -181,7 +181,7 @@ var useComboboxItem = _NGD3IQDBcjs.createHook.call(void 0,
181
181
  onKeyDown
182
182
  });
183
183
  const moveOnKeyPressProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, moveOnKeyPress);
184
- props = _7DQ2LBH2cjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
184
+ props = _QUHFOHHTcjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
185
185
  store
186
186
  }, props), {
187
187
  getItem,
@@ -9,10 +9,10 @@ require('../__chunks/VPI3EKVY.cjs');
9
9
  require('../__chunks/NEK2UEJN.cjs');
10
10
 
11
11
 
12
- var _DCTXNU2Xcjs = require('../__chunks/DCTXNU2X.cjs');
12
+ var _COWKMNMZcjs = require('../__chunks/COWKMNMZ.cjs');
13
13
 
14
14
 
15
- var _CWS5RZSUcjs = require('../__chunks/CWS5RZSU.cjs');
15
+ var _ZTAE5B6Wcjs = require('../__chunks/ZTAE5B6W.cjs');
16
16
  require('../__chunks/TSEXNK3K.cjs');
17
17
  require('../__chunks/JF225FQ5.cjs');
18
18
  require('../__chunks/37BRXQN7.cjs');
@@ -58,6 +58,7 @@ require('../__chunks/CJDHQUBR.cjs');
58
58
  var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
59
59
 
60
60
  // src/combobox/combobox-popover.tsx
61
+ var _react = require('react');
61
62
  var _dom = require('@ariakit/core/utils/dom');
62
63
  var _misc = require('@ariakit/core/utils/misc');
63
64
  var TagName = "div";
@@ -79,12 +80,14 @@ var useComboboxPopover = _NGD3IQDBcjs.createHook.call(void 0,
79
80
  modal,
80
81
  tabIndex,
81
82
  alwaysVisible,
83
+ autoFocusOnHide = true,
82
84
  hideOnInteractOutside = true
83
85
  } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, [
84
86
  "store",
85
87
  "modal",
86
88
  "tabIndex",
87
89
  "alwaysVisible",
90
+ "autoFocusOnHide",
88
91
  "hideOnInteractOutside"
89
92
  ]);
90
93
  const context = _2IJSEADJcjs.useComboboxProviderContext.call(void 0, );
@@ -94,14 +97,14 @@ var useComboboxPopover = _NGD3IQDBcjs.createHook.call(void 0,
94
97
  process.env.NODE_ENV !== "production" && "ComboboxPopover must receive a `store` prop or be wrapped in a ComboboxProvider component."
95
98
  );
96
99
  const baseElement = store.useState("baseElement");
100
+ const hiddenByClickOutsideRef = _react.useRef.call(void 0, false);
97
101
  props = _Q6MAE3CVcjs.useComboboxList.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
98
- props = _DCTXNU2Xcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
102
+ props = _COWKMNMZcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
99
103
  store,
100
104
  modal,
101
105
  alwaysVisible,
102
106
  backdrop: false,
103
107
  autoFocusOnShow: false,
104
- autoFocusOnHide: false,
105
108
  finalFocus: baseElement,
106
109
  preserveTabOrderAnchor: null
107
110
  }, props), {
@@ -133,6 +136,18 @@ var useComboboxPopover = _NGD3IQDBcjs.createHook.call(void 0,
133
136
  const controlElements = doc.querySelectorAll(selector);
134
137
  return [...elements, ...controlElements];
135
138
  },
139
+ // The combobox popover should focus on the combobox input when it hides,
140
+ // unless the event was triggered by a click outside the popover, in which
141
+ // case the input shouldn't be re-focused.
142
+ autoFocusOnHide(element) {
143
+ if (_misc.isFalsyBooleanCallback.call(void 0, autoFocusOnHide, element))
144
+ return false;
145
+ if (hiddenByClickOutsideRef.current) {
146
+ hiddenByClickOutsideRef.current = false;
147
+ return false;
148
+ }
149
+ return true;
150
+ },
136
151
  // Make sure we don't hide the popover when the user interacts with the
137
152
  // combobox cancel or the combobox disclosure buttons. They will have the
138
153
  // aria-controls attribute pointing to either the combobox input or the
@@ -145,13 +160,16 @@ var useComboboxPopover = _NGD3IQDBcjs.createHook.call(void 0,
145
160
  if (isController(event.target, contentId, baseId))
146
161
  return false;
147
162
  const result = typeof hideOnInteractOutside === "function" ? hideOnInteractOutside(event) : hideOnInteractOutside;
163
+ if (result) {
164
+ hiddenByClickOutsideRef.current = event.type === "click";
165
+ }
148
166
  return result;
149
167
  }
150
168
  }));
151
169
  return props;
152
170
  }
153
171
  );
154
- var ComboboxPopover = _CWS5RZSUcjs.createDialogComponent.call(void 0,
172
+ var ComboboxPopover = _ZTAE5B6Wcjs.createDialogComponent.call(void 0,
155
173
  _NGD3IQDBcjs.forwardRef.call(void 0, function ComboboxPopover2(props) {
156
174
  const htmlProps = useComboboxPopover(props);
157
175
  return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
@@ -38,7 +38,7 @@ require('../__chunks/CJDHQUBR.cjs');
38
38
 
39
39
  var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
40
40
 
41
- // src/combobox/combobox.ts
41
+ // src/combobox/combobox.tsx
42
42
  var _react = require('react');
43
43
 
44
44
 
@@ -93,14 +93,15 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
93
93
  focusable = true,
94
94
  autoSelect: autoSelectProp = false,
95
95
  getAutoSelectId,
96
- showOnChange = true,
97
96
  setValueOnChange = true,
98
- showOnMouseDown = true,
97
+ showMinLength = 0,
98
+ showOnChange,
99
+ showOnMouseDown,
99
100
  showOnClick = showOnMouseDown,
101
+ showOnKeyDown,
102
+ showOnKeyPress = showOnKeyDown,
100
103
  blurActiveItemOnClick,
101
104
  setValueOnClick = true,
102
- showOnKeyDown = true,
103
- showOnKeyPress = showOnKeyDown,
104
105
  moveOnKeyPress = true,
105
106
  autoComplete = "list"
106
107
  } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, [
@@ -108,14 +109,15 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
108
109
  "focusable",
109
110
  "autoSelect",
110
111
  "getAutoSelectId",
111
- "showOnChange",
112
112
  "setValueOnChange",
113
+ "showMinLength",
114
+ "showOnChange",
113
115
  "showOnMouseDown",
114
116
  "showOnClick",
115
- "blurActiveItemOnClick",
116
- "setValueOnClick",
117
117
  "showOnKeyDown",
118
118
  "showOnKeyPress",
119
+ "blurActiveItemOnClick",
120
+ "setValueOnClick",
119
121
  "moveOnKeyPress",
120
122
  "autoComplete"
121
123
  ]);
@@ -312,8 +314,9 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
312
314
  elements.forEach((el) => el.removeEventListener("focusout", onBlur2));
313
315
  };
314
316
  }, [inline, contentElement, store, value]);
317
+ const canShow = value.length >= showMinLength;
315
318
  const onChangeProp = props.onChange;
316
- const showOnChangeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnChange);
319
+ const showOnChangeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnChange != null ? showOnChange : canShow);
317
320
  const setValueOnChangeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, setValueOnChange);
318
321
  const onChange = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
319
322
  onChangeProp == null ? void 0 : onChangeProp(event);
@@ -366,7 +369,7 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
366
369
  blurActiveItemOnClick != null ? blurActiveItemOnClick : () => !!(store == null ? void 0 : store.getState().includesBaseElement)
367
370
  );
368
371
  const setValueOnClickProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, setValueOnClick);
369
- const showOnClickProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnClick);
372
+ const showOnClickProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnClick != null ? showOnClick : canShow);
370
373
  const onMouseDown = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
371
374
  onMouseDownProp == null ? void 0 : onMouseDownProp(event);
372
375
  if (event.defaultPrevented)
@@ -388,7 +391,7 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
388
391
  }
389
392
  });
390
393
  const onKeyDownProp = props.onKeyDown;
391
- const showOnKeyPressProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnKeyPress);
394
+ const showOnKeyPressProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnKeyPress != null ? showOnKeyPress : canShow);
392
395
  const onKeyDown = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
393
396
  onKeyDownProp == null ? void 0 : onKeyDownProp(event);
394
397
  if (!event.repeat) {
@@ -143,6 +143,26 @@ export interface ComboboxOptions<T extends ElementType = TagName> extends Compos
143
143
  * value.
144
144
  */
145
145
  blurActiveItemOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
146
+ /**
147
+ * Specifies the minimum character count the input value should have before
148
+ * the [`ComboboxList`](https://ariakit.org/reference/combobox-list) or
149
+ * [`ComboboxPopover`](https://ariakit.org/reference/combobox-popover)
150
+ * components are displayed.
151
+ *
152
+ * The [`showOnChange`](https://ariakit.org/reference/combobox#showonchange),
153
+ * [`showOnClick`](https://ariakit.org/reference/combobox#showonclick), and
154
+ * [`showOnKeyPress`](https://ariakit.org/reference/combobox#showonkeypress)
155
+ * props allow you to tailor the behavior for each unique event.
156
+ * @default 0
157
+ * @example
158
+ * In the following example, the combobox list will be shown when the input
159
+ * value has at least one character. However, if the user presses the arrow
160
+ * keys, the list will be shown regardless of the input value length.
161
+ * ```jsx
162
+ * <Combobox showMinLength={1} showOnKeyPress />
163
+ * ```
164
+ */
165
+ showMinLength?: number;
146
166
  /**
147
167
  * Whether the [`ComboboxList`](https://ariakit.org/reference/combobox-list)
148
168
  * or [`ComboboxPopover`](https://ariakit.org/reference/combobox-popover)