@ariakit/react-core 0.4.4 → 0.4.5

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 (180) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/cjs/__chunks/{QUHFOHHT.cjs → 3HMQOCLF.cjs} +10 -27
  3. package/cjs/__chunks/{YO7LLGVA.cjs → AY5J25V7.cjs} +2 -2
  4. package/cjs/__chunks/{4XVTH6OR.cjs → DFXPO2ED.cjs} +2 -2
  5. package/cjs/__chunks/{HPNCFYQJ.cjs → GZ2NNSLV.cjs} +4 -4
  6. package/cjs/__chunks/ISJGSS4S.cjs +16 -0
  7. package/cjs/__chunks/{COWKMNMZ.cjs → N43E53E6.cjs} +3 -3
  8. package/cjs/__chunks/{54YZYOPA.cjs → NRPEUNJB.cjs} +2 -2
  9. package/cjs/__chunks/PVLZGFP6.cjs +34 -0
  10. package/cjs/__chunks/{ZTAE5B6W.cjs → QJDA4LG6.cjs} +19 -16
  11. package/cjs/__chunks/{NDVZ37O3.cjs → RG6U7KAS.cjs} +22 -4
  12. package/cjs/__chunks/YWAHOWYE.cjs +25 -0
  13. package/cjs/combobox/combobox-cancel.cjs +3 -3
  14. package/cjs/combobox/combobox-disclosure.cjs +3 -3
  15. package/cjs/combobox/combobox-item.cjs +19 -9
  16. package/cjs/combobox/combobox-item.d.cts +22 -12
  17. package/cjs/combobox/combobox-item.d.ts +22 -12
  18. package/cjs/combobox/combobox-popover.cjs +22 -15
  19. package/cjs/combobox/combobox-provider.cjs +3 -2
  20. package/cjs/combobox/combobox-store.cjs +6 -2
  21. package/cjs/combobox/combobox-store.d.cts +12 -4
  22. package/cjs/combobox/combobox-store.d.ts +12 -4
  23. package/cjs/combobox/combobox-value.cjs +32 -0
  24. package/cjs/combobox/combobox-value.d.cts +41 -0
  25. package/cjs/combobox/combobox-value.d.ts +41 -0
  26. package/cjs/combobox/combobox.cjs +66 -22
  27. package/cjs/composite/composite-item.cjs +3 -3
  28. package/cjs/composite/composite-overflow-disclosure.cjs +3 -3
  29. package/cjs/composite/composite-overflow.cjs +12 -12
  30. package/cjs/dialog/dialog-backdrop.cjs +3 -3
  31. package/cjs/dialog/dialog.cjs +11 -11
  32. package/cjs/dialog/dialog.d.cts +4 -0
  33. package/cjs/dialog/dialog.d.ts +4 -0
  34. package/cjs/dialog/utils/disable-tree.cjs +3 -3
  35. package/cjs/dialog/utils/use-prevent-body-scroll.cjs +3 -3
  36. package/cjs/form/form-checkbox.cjs +1 -1
  37. package/cjs/form/form-push.cjs +1 -1
  38. package/cjs/form/form-radio.cjs +4 -4
  39. package/cjs/hovercard/hovercard.cjs +13 -13
  40. package/cjs/menu/menu-item-checkbox.cjs +4 -4
  41. package/cjs/menu/menu-item-radio.cjs +7 -7
  42. package/cjs/menu/menu-item.cjs +4 -4
  43. package/cjs/menu/menu.cjs +14 -14
  44. package/cjs/popover/popover.cjs +12 -12
  45. package/cjs/radio/radio.cjs +4 -4
  46. package/cjs/select/select-item.cjs +4 -4
  47. package/cjs/select/select-popover.cjs +13 -13
  48. package/cjs/select/select-value.d.cts +8 -7
  49. package/cjs/select/select-value.d.ts +8 -7
  50. package/cjs/select/select.cjs +1 -1
  51. package/cjs/tab/tab-panel.cjs +2 -2
  52. package/cjs/tab/tab.cjs +7 -7
  53. package/cjs/tag/tag-context.cjs +25 -0
  54. package/cjs/tag/tag-context.d.cts +21 -0
  55. package/cjs/tag/tag-context.d.ts +21 -0
  56. package/cjs/tag/tag-input.cjs +191 -0
  57. package/cjs/tag/tag-input.d.cts +122 -0
  58. package/cjs/tag/tag-input.d.ts +122 -0
  59. package/cjs/tag/tag-list-label.cjs +56 -0
  60. package/cjs/tag/tag-list-label.d.cts +55 -0
  61. package/cjs/tag/tag-list-label.d.ts +55 -0
  62. package/cjs/tag/tag-list.cjs +141 -0
  63. package/cjs/tag/tag-list.d.cts +58 -0
  64. package/cjs/tag/tag-list.d.ts +58 -0
  65. package/cjs/tag/tag-provider.cjs +26 -0
  66. package/cjs/tag/tag-provider.d.cts +29 -0
  67. package/cjs/tag/tag-provider.d.ts +29 -0
  68. package/cjs/tag/tag-remove.cjs +119 -0
  69. package/cjs/tag/tag-remove.d.cts +67 -0
  70. package/cjs/tag/tag-remove.d.ts +67 -0
  71. package/cjs/tag/tag-store.cjs +15 -0
  72. package/cjs/tag/tag-store.d.cts +49 -0
  73. package/cjs/tag/tag-store.d.ts +49 -0
  74. package/cjs/tag/tag-value.cjs +29 -0
  75. package/cjs/tag/tag-value.d.cts +41 -0
  76. package/cjs/tag/tag-value.d.ts +41 -0
  77. package/cjs/tag/tag-values.cjs +29 -0
  78. package/cjs/tag/tag-values.d.cts +52 -0
  79. package/cjs/tag/tag-values.d.ts +52 -0
  80. package/cjs/tag/tag.cjs +130 -0
  81. package/cjs/tag/tag.d.cts +74 -0
  82. package/cjs/tag/tag.d.ts +74 -0
  83. package/cjs/tag/utils.cjs +8 -0
  84. package/cjs/tag/utils.d.cts +1 -0
  85. package/cjs/tag/utils.d.ts +1 -0
  86. package/cjs/toolbar/toolbar-container.cjs +4 -4
  87. package/cjs/toolbar/toolbar-input.cjs +4 -4
  88. package/cjs/toolbar/toolbar-item.cjs +4 -4
  89. package/cjs/tooltip/tooltip.cjs +14 -14
  90. package/combobox/combobox-value/package.json +8 -0
  91. package/esm/__chunks/{XEJ23EM6.js → 65LF6MEO.js} +2 -2
  92. package/esm/__chunks/{LTYEFENI.js → 6YVAEELE.js} +1 -1
  93. package/esm/__chunks/{ZFEEEZVE.js → DLLQM6DZ.js} +22 -4
  94. package/esm/__chunks/{IOUGWXY5.js → FGHVVLPU.js} +20 -17
  95. package/esm/__chunks/L7IM35RU.js +16 -0
  96. package/esm/__chunks/{NFPDVAAW.js → M354SEUF.js} +1 -1
  97. package/esm/__chunks/QNNHZL3W.js +25 -0
  98. package/esm/__chunks/{DSUHLHLE.js → QZJOXZKA.js} +1 -1
  99. package/esm/__chunks/{NHVUMSP7.js → UKDZLPKH.js} +1 -1
  100. package/esm/__chunks/{R33ISPJY.js → VGORKDMQ.js} +11 -28
  101. package/esm/__chunks/WYDDZRWN.js +34 -0
  102. package/esm/combobox/combobox-cancel.js +3 -3
  103. package/esm/combobox/combobox-disclosure.js +3 -3
  104. package/esm/combobox/combobox-item.d.ts +22 -12
  105. package/esm/combobox/combobox-item.js +19 -9
  106. package/esm/combobox/combobox-popover.js +20 -13
  107. package/esm/combobox/combobox-provider.js +2 -1
  108. package/esm/combobox/combobox-store.d.ts +12 -4
  109. package/esm/combobox/combobox-store.js +5 -1
  110. package/esm/combobox/combobox-value.d.ts +41 -0
  111. package/esm/combobox/combobox-value.js +32 -0
  112. package/esm/combobox/combobox.js +67 -23
  113. package/esm/composite/composite-item.js +2 -2
  114. package/esm/composite/composite-overflow-disclosure.js +2 -2
  115. package/esm/composite/composite-overflow.js +11 -11
  116. package/esm/dialog/dialog-backdrop.js +2 -2
  117. package/esm/dialog/dialog.d.ts +4 -0
  118. package/esm/dialog/dialog.js +10 -10
  119. package/esm/dialog/utils/disable-tree.js +2 -2
  120. package/esm/dialog/utils/use-prevent-body-scroll.js +2 -2
  121. package/esm/form/form-checkbox.js +1 -1
  122. package/esm/form/form-push.js +1 -1
  123. package/esm/form/form-radio.js +3 -3
  124. package/esm/hovercard/hovercard.js +12 -12
  125. package/esm/menu/menu-item-checkbox.js +3 -3
  126. package/esm/menu/menu-item-radio.js +5 -5
  127. package/esm/menu/menu-item.js +3 -3
  128. package/esm/menu/menu.js +12 -12
  129. package/esm/popover/popover.js +11 -11
  130. package/esm/radio/radio.js +3 -3
  131. package/esm/select/select-item.js +4 -4
  132. package/esm/select/select-popover.js +11 -11
  133. package/esm/select/select-value.d.ts +8 -7
  134. package/esm/select/select.js +1 -1
  135. package/esm/tab/tab-panel.js +3 -3
  136. package/esm/tab/tab.js +5 -5
  137. package/esm/tag/tag-context.d.ts +21 -0
  138. package/esm/tag/tag-context.js +25 -0
  139. package/esm/tag/tag-input.d.ts +122 -0
  140. package/esm/tag/tag-input.js +191 -0
  141. package/esm/tag/tag-list-label.d.ts +55 -0
  142. package/esm/tag/tag-list-label.js +56 -0
  143. package/esm/tag/tag-list.d.ts +58 -0
  144. package/esm/tag/tag-list.js +141 -0
  145. package/esm/tag/tag-provider.d.ts +29 -0
  146. package/esm/tag/tag-provider.js +26 -0
  147. package/esm/tag/tag-remove.d.ts +67 -0
  148. package/esm/tag/tag-remove.js +119 -0
  149. package/esm/tag/tag-store.d.ts +49 -0
  150. package/esm/tag/tag-store.js +15 -0
  151. package/esm/tag/tag-value.d.ts +41 -0
  152. package/esm/tag/tag-value.js +29 -0
  153. package/esm/tag/tag-values.d.ts +52 -0
  154. package/esm/tag/tag-values.js +29 -0
  155. package/esm/tag/tag.d.ts +74 -0
  156. package/esm/tag/tag.js +130 -0
  157. package/esm/tag/utils.d.ts +1 -0
  158. package/esm/tag/utils.js +8 -0
  159. package/esm/toolbar/toolbar-container.js +3 -3
  160. package/esm/toolbar/toolbar-input.js +3 -3
  161. package/esm/toolbar/toolbar-item.js +3 -3
  162. package/esm/tooltip/tooltip.js +12 -12
  163. package/package.json +86 -2
  164. package/tag/tag/package.json +8 -0
  165. package/tag/tag-context/package.json +8 -0
  166. package/tag/tag-input/package.json +8 -0
  167. package/tag/tag-list/package.json +8 -0
  168. package/tag/tag-list-label/package.json +8 -0
  169. package/tag/tag-provider/package.json +8 -0
  170. package/tag/tag-remove/package.json +8 -0
  171. package/tag/tag-store/package.json +8 -0
  172. package/tag/tag-value/package.json +8 -0
  173. package/tag/tag-values/package.json +8 -0
  174. package/tag/utils/package.json +8 -0
  175. package/cjs/__chunks/{37BRXQN7.cjs → BX2QEIBH.cjs} +3 -3
  176. package/cjs/__chunks/{PVYTX5U5.cjs → SL55T4ZB.cjs} +2 -2
  177. package/cjs/__chunks/{TSEXNK3K.cjs → VR6GCLOV.cjs} +2 -2
  178. package/esm/__chunks/{PTPUIM7N.js → 3TEK3C5Q.js} +3 -3
  179. package/esm/__chunks/{U2L67A6K.js → BC72XE6E.js} +3 -3
  180. package/esm/__chunks/{GOXKZAQI.js → CMFBAHKI.js} +3 -3
@@ -93,6 +93,20 @@ export interface ComboboxItemOptions<T extends ElementType = TagName> extends Co
93
93
  * - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)
94
94
  */
95
95
  hideOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
96
+ /**
97
+ * Whether to set the combobox
98
+ * [`value`](https://ariakit.org/reference/combobox-provider#value) state
99
+ * using this item's
100
+ * [`value`](https://ariakit.org/reference/combobox-item#value) when the item
101
+ * is clicked. The default is `true`, unless the combobox is
102
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
103
+ *
104
+ * Live examples:
105
+ * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
106
+ * - [Submenu with
107
+ * Combobox](https://ariakit.org/examples/menu-nested-combobox)
108
+ */
109
+ setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
96
110
  /**
97
111
  * Whether to set the
98
112
  * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
@@ -108,19 +122,15 @@ export interface ComboboxItemOptions<T extends ElementType = TagName> extends Co
108
122
  */
109
123
  selectValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
110
124
  /**
111
- * Whether to set the combobox
112
- * [`value`](https://ariakit.org/reference/combobox-provider#value) state
113
- * using this item's
114
- * [`value`](https://ariakit.org/reference/combobox-item#value) when the item
115
- * is clicked. The default is `true`, unless the combobox is
116
- * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
117
- *
118
- * Live examples:
119
- * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
120
- * - [Submenu with
121
- * Combobox](https://ariakit.org/examples/menu-nested-combobox)
125
+ * Whether to reset the the combobox input value when this item is selected or
126
+ * unselected by click. This prop is set to `true` by default if
127
+ * the combobox supports multiple selections. In other words, if the
128
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
129
+ * or
130
+ * [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
131
+ * props are arrays.
122
132
  */
123
- setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
133
+ resetValueOnSelect?: BooleanOrCallback<MouseEvent<HTMLElement>>;
124
134
  /**
125
135
  * @default false
126
136
  */
@@ -9,32 +9,32 @@ require('../__chunks/VPI3EKVY.cjs');
9
9
  require('../__chunks/NEK2UEJN.cjs');
10
10
 
11
11
 
12
- var _COWKMNMZcjs = require('../__chunks/COWKMNMZ.cjs');
12
+ var _N43E53E6cjs = require('../__chunks/N43E53E6.cjs');
13
13
 
14
14
 
15
- var _ZTAE5B6Wcjs = require('../__chunks/ZTAE5B6W.cjs');
16
- require('../__chunks/TSEXNK3K.cjs');
17
- require('../__chunks/JF225FQ5.cjs');
18
- require('../__chunks/37BRXQN7.cjs');
19
- require('../__chunks/MU7F4QWJ.cjs');
20
- require('../__chunks/PVYTX5U5.cjs');
21
- require('../__chunks/DLIQLPX4.cjs');
15
+ var _QJDA4LG6cjs = require('../__chunks/QJDA4LG6.cjs');
16
+ require('../__chunks/VR6GCLOV.cjs');
22
17
  require('../__chunks/UUJ5Q6IA.cjs');
23
18
  require('../__chunks/4H7FYXWQ.cjs');
19
+ require('../__chunks/JF225FQ5.cjs');
24
20
  require('../__chunks/JKERATCG.cjs');
21
+ require('../__chunks/BX2QEIBH.cjs');
22
+ require('../__chunks/MU7F4QWJ.cjs');
23
+ require('../__chunks/6IUEXB4L.cjs');
25
24
  require('../__chunks/7YLCVXZ7.cjs');
26
25
  require('../__chunks/CXZMA435.cjs');
27
26
  require('../__chunks/7TN63K2T.cjs');
27
+ require('../__chunks/SL55T4ZB.cjs');
28
28
  require('../__chunks/3ND7K6FF.cjs');
29
- require('../__chunks/6IUEXB4L.cjs');
29
+ require('../__chunks/DLIQLPX4.cjs');
30
30
  require('../__chunks/AFPGTIIH.cjs');
31
31
  require('../__chunks/J3OG6T3B.cjs');
32
+ require('../__chunks/2BIO7R5N.cjs');
32
33
  require('../__chunks/PE3KUHN6.cjs');
33
34
  require('../__chunks/AXNMZ6L6.cjs');
34
35
  require('../__chunks/CVD2AZE2.cjs');
35
- require('../__chunks/2BIO7R5N.cjs');
36
- require('../__chunks/R6M66EKZ.cjs');
37
36
  require('../__chunks/7CYY7U2A.cjs');
37
+ require('../__chunks/R6M66EKZ.cjs');
38
38
  require('../__chunks/77BAEZ2Z.cjs');
39
39
  require('../__chunks/GDEDCFNU.cjs');
40
40
  require('../__chunks/NTNMOEWE.cjs');
@@ -48,7 +48,9 @@ require('../__chunks/LLMPAMXI.cjs');
48
48
  var _NGD3IQDBcjs = require('../__chunks/NGD3IQDB.cjs');
49
49
  require('../__chunks/V3ZO7ICA.cjs');
50
50
  require('../__chunks/N6YOHUBI.cjs');
51
- require('../__chunks/GXMZA6DT.cjs');
51
+
52
+
53
+ var _GXMZA6DTcjs = require('../__chunks/GXMZA6DT.cjs');
52
54
  require('../__chunks/TW3SFX4C.cjs');
53
55
  require('../__chunks/CJDHQUBR.cjs');
54
56
 
@@ -98,15 +100,20 @@ var useComboboxPopover = _NGD3IQDBcjs.createHook.call(void 0,
98
100
  );
99
101
  const baseElement = store.useState("baseElement");
100
102
  const hiddenByClickOutsideRef = _react.useRef.call(void 0, false);
103
+ const treeSnapshotKey = _GXMZA6DTcjs.useStoreState.call(void 0,
104
+ store.tag,
105
+ (state) => state == null ? void 0 : state.renderedItems.length
106
+ );
101
107
  props = _Q6MAE3CVcjs.useComboboxList.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
102
- props = _COWKMNMZcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
108
+ props = _N43E53E6cjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
103
109
  store,
104
110
  modal,
105
111
  alwaysVisible,
106
112
  backdrop: false,
107
113
  autoFocusOnShow: false,
108
114
  finalFocus: baseElement,
109
- preserveTabOrderAnchor: null
115
+ preserveTabOrderAnchor: null,
116
+ unstable_treeSnapshotKey: treeSnapshotKey
110
117
  }, props), {
111
118
  // When the combobox popover is modal, we make sure to include the
112
119
  // combobox input and all the combobox controls (cancel, disclosure) in
@@ -169,7 +176,7 @@ var useComboboxPopover = _NGD3IQDBcjs.createHook.call(void 0,
169
176
  return props;
170
177
  }
171
178
  );
172
- var ComboboxPopover = _ZTAE5B6Wcjs.createDialogComponent.call(void 0,
179
+ var ComboboxPopover = _QJDA4LG6cjs.createDialogComponent.call(void 0,
173
180
  _NGD3IQDBcjs.forwardRef.call(void 0, function ComboboxPopover2(props) {
174
181
  const htmlProps = useComboboxPopover(props);
175
182
  return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
@@ -1,10 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _NDVZ37O3cjs = require('../__chunks/NDVZ37O3.cjs');
4
+ var _RG6U7KAScjs = require('../__chunks/RG6U7KAS.cjs');
5
5
 
6
6
 
7
7
  var _2IJSEADJcjs = require('../__chunks/2IJSEADJ.cjs');
8
+ require('../__chunks/PVLZGFP6.cjs');
8
9
  require('../__chunks/4H5ZMMOI.cjs');
9
10
  require('../__chunks/Q7DU7FP7.cjs');
10
11
  require('../__chunks/VPI3EKVY.cjs');
@@ -24,7 +25,7 @@ require('../__chunks/AV6KTKLE.cjs');
24
25
  // src/combobox/combobox-provider.tsx
25
26
  var _jsxruntime = require('react/jsx-runtime');
26
27
  function ComboboxProvider(props = {}) {
27
- const store = _NDVZ37O3cjs.useComboboxStore.call(void 0, props);
28
+ const store = _RG6U7KAScjs.useComboboxStore.call(void 0, props);
28
29
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _2IJSEADJcjs.ComboboxContextProvider, { value: store, children: props.children });
29
30
  }
30
31
 
@@ -2,9 +2,13 @@
2
2
 
3
3
 
4
4
 
5
- var _NDVZ37O3cjs = require('../__chunks/NDVZ37O3.cjs');
5
+ var _RG6U7KAScjs = require('../__chunks/RG6U7KAS.cjs');
6
+ require('../__chunks/PVLZGFP6.cjs');
6
7
  require('../__chunks/4H5ZMMOI.cjs');
7
8
  require('../__chunks/Q7DU7FP7.cjs');
9
+ require('../__chunks/VPI3EKVY.cjs');
10
+ require('../__chunks/NEK2UEJN.cjs');
11
+ require('../__chunks/NGD3IQDB.cjs');
8
12
  require('../__chunks/6RJSKW2C.cjs');
9
13
  require('../__chunks/V3ZO7ICA.cjs');
10
14
  require('../__chunks/N6YOHUBI.cjs');
@@ -15,4 +19,4 @@ require('../__chunks/AV6KTKLE.cjs');
15
19
 
16
20
 
17
21
 
18
- exports.useComboboxStore = _NDVZ37O3cjs.useComboboxStore; exports.useComboboxStoreProps = _NDVZ37O3cjs.useComboboxStoreProps;
22
+ exports.useComboboxStore = _RG6U7KAScjs.useComboboxStore; exports.useComboboxStoreProps = _RG6U7KAScjs.useComboboxStoreProps;
@@ -2,9 +2,12 @@ import * as Core from "@ariakit/core/combobox/combobox-store";
2
2
  import type { PickRequired } from "@ariakit/core/utils/types";
3
3
  import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
4
4
  import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
5
+ import type { TagStore } from "../tag/tag-store.js";
5
6
  import type { Store } from "../utils/store.js";
6
7
  export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(store: T, update: () => void, props: ComboboxStoreProps): T & {
7
8
  disclosure: import("../disclosure/disclosure-store.js").DisclosureStore | null | undefined;
9
+ } & {
10
+ tag: TagStore | null | undefined;
8
11
  };
9
12
  /**
10
13
  * Creates a combobox store to control the state of
@@ -31,9 +34,9 @@ export interface ComboboxStoreItem extends Core.ComboboxStoreItem {
31
34
  }
32
35
  export interface ComboboxStoreState<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Core.ComboboxStoreState<T>, CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
33
36
  }
34
- export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreFunctions<T>, "disclosure">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
37
+ export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Pick<ComboboxStoreOptions<T>, "tag">, Omit<Core.ComboboxStoreFunctions<T>, "tag" | "disclosure">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
35
38
  }
36
- export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreOptions<T>, "disclosure">, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
39
+ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreOptions<T>, "tag" | "disclosure">, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
37
40
  /**
38
41
  * A callback that gets called when the
39
42
  * [`value`](https://ariakit.org/reference/combobox-provider#value) state
@@ -61,8 +64,13 @@ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = Com
61
64
  * Combobox](https://ariakit.org/examples/combobox-multiple)
62
65
  */
63
66
  setSelectedValue?: (value: ComboboxStoreState<T>["selectedValue"]) => void;
67
+ /**
68
+ * A reference to a [tag store](https://ariakit.org/apis/use-tag-store). It's
69
+ * automatically set when rendering a combobox within a tag list.
70
+ */
71
+ tag?: TagStore | null;
64
72
  }
65
- export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, Omit<Core.ComboboxStoreProps<T>, "disclosure"> {
73
+ export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, Omit<Core.ComboboxStoreProps<T>, "tag" | "disclosure"> {
66
74
  }
67
- export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Omit<Store<Core.ComboboxStore<T>>, "disclosure"> {
75
+ export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Omit<Store<Core.ComboboxStore<T>>, "tag" | "disclosure"> {
68
76
  }
@@ -2,9 +2,12 @@ import * as Core from "@ariakit/core/combobox/combobox-store";
2
2
  import type { PickRequired } from "@ariakit/core/utils/types";
3
3
  import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
4
4
  import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
5
+ import type { TagStore } from "../tag/tag-store.js";
5
6
  import type { Store } from "../utils/store.js";
6
7
  export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(store: T, update: () => void, props: ComboboxStoreProps): T & {
7
8
  disclosure: import("../disclosure/disclosure-store.js").DisclosureStore | null | undefined;
9
+ } & {
10
+ tag: TagStore | null | undefined;
8
11
  };
9
12
  /**
10
13
  * Creates a combobox store to control the state of
@@ -31,9 +34,9 @@ export interface ComboboxStoreItem extends Core.ComboboxStoreItem {
31
34
  }
32
35
  export interface ComboboxStoreState<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Core.ComboboxStoreState<T>, CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
33
36
  }
34
- export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreFunctions<T>, "disclosure">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
37
+ export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Pick<ComboboxStoreOptions<T>, "tag">, Omit<Core.ComboboxStoreFunctions<T>, "tag" | "disclosure">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
35
38
  }
36
- export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreOptions<T>, "disclosure">, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
39
+ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreOptions<T>, "tag" | "disclosure">, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
37
40
  /**
38
41
  * A callback that gets called when the
39
42
  * [`value`](https://ariakit.org/reference/combobox-provider#value) state
@@ -61,8 +64,13 @@ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = Com
61
64
  * Combobox](https://ariakit.org/examples/combobox-multiple)
62
65
  */
63
66
  setSelectedValue?: (value: ComboboxStoreState<T>["selectedValue"]) => void;
67
+ /**
68
+ * A reference to a [tag store](https://ariakit.org/apis/use-tag-store). It's
69
+ * automatically set when rendering a combobox within a tag list.
70
+ */
71
+ tag?: TagStore | null;
64
72
  }
65
- export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, Omit<Core.ComboboxStoreProps<T>, "disclosure"> {
73
+ export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, Omit<Core.ComboboxStoreProps<T>, "tag" | "disclosure"> {
66
74
  }
67
- export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Omit<Store<Core.ComboboxStore<T>>, "disclosure"> {
75
+ export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Omit<Store<Core.ComboboxStore<T>>, "tag" | "disclosure"> {
68
76
  }
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _2IJSEADJcjs = require('../__chunks/2IJSEADJ.cjs');
5
+ require('../__chunks/VPI3EKVY.cjs');
6
+ require('../__chunks/NEK2UEJN.cjs');
7
+ require('../__chunks/77BAEZ2Z.cjs');
8
+ require('../__chunks/GDEDCFNU.cjs');
9
+ require('../__chunks/NTNMOEWE.cjs');
10
+ require('../__chunks/NGD3IQDB.cjs');
11
+ require('../__chunks/TW3SFX4C.cjs');
12
+ require('../__chunks/CJDHQUBR.cjs');
13
+ require('../__chunks/AV6KTKLE.cjs');
14
+
15
+ // src/combobox/combobox-value.tsx
16
+ var _misc = require('@ariakit/core/utils/misc');
17
+ function ComboboxValue({ store, children } = {}) {
18
+ const context = _2IJSEADJcjs.useComboboxContext.call(void 0, );
19
+ store = store || context;
20
+ _misc.invariant.call(void 0,
21
+ store,
22
+ process.env.NODE_ENV !== "production" && "ComboboxValue must receive a `store` prop or be wrapped in a ComboboxProvider component."
23
+ );
24
+ const value = store.useState("value");
25
+ if (children) {
26
+ return children(value);
27
+ }
28
+ return value;
29
+ }
30
+
31
+
32
+ exports.ComboboxValue = ComboboxValue;
@@ -0,0 +1,41 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ComboboxStore, ComboboxStoreState } from "./combobox-store.js";
3
+ /**
4
+ * Renders the current
5
+ * [`value`](https://ariakit.org/reference/use-combobox-store#value) state in
6
+ * the [combobox store](https://ariakit.org/reference/use-combobox-store).
7
+ *
8
+ * As a value component, it doesn't render any DOM elements and therefore
9
+ * doesn't accept HTML props.
10
+ *
11
+ * It takes a
12
+ * [`children`](https://ariakit.org/reference/combobox-value#children) function
13
+ * that gets called with the current value as an argument. This can be used as
14
+ * an uncontrolled API to render the combobox value in a custom way.
15
+ * @see https://ariakit.org/components/combobox
16
+ * @example
17
+ * ```jsx {3-5}
18
+ * <ComboboxProvider>
19
+ * <Combobox />
20
+ * <ComboboxValue>
21
+ * {(value) => `Current value: ${value}`}
22
+ * </ComboboxValue>
23
+ * </ComboboxProvider>
24
+ * ```
25
+ */
26
+ export declare function ComboboxValue({ store, children }?: ComboboxValueProps): ReactNode;
27
+ export interface ComboboxValueProps {
28
+ /**
29
+ * Object returned by the
30
+ * [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
31
+ * hook. If not provided, the closest
32
+ * [`ComboboxProvider`](https://ariakit.org/reference/combobox-provider)
33
+ * component's context will be used.
34
+ */
35
+ store?: ComboboxStore;
36
+ /**
37
+ * A function that gets called with the current value as an argument. It can
38
+ * be used to render the combobox value in a custom way.
39
+ */
40
+ children?: (value: ComboboxStoreState["value"]) => ReactNode;
41
+ }
@@ -0,0 +1,41 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ComboboxStore, ComboboxStoreState } from "./combobox-store.js";
3
+ /**
4
+ * Renders the current
5
+ * [`value`](https://ariakit.org/reference/use-combobox-store#value) state in
6
+ * the [combobox store](https://ariakit.org/reference/use-combobox-store).
7
+ *
8
+ * As a value component, it doesn't render any DOM elements and therefore
9
+ * doesn't accept HTML props.
10
+ *
11
+ * It takes a
12
+ * [`children`](https://ariakit.org/reference/combobox-value#children) function
13
+ * that gets called with the current value as an argument. This can be used as
14
+ * an uncontrolled API to render the combobox value in a custom way.
15
+ * @see https://ariakit.org/components/combobox
16
+ * @example
17
+ * ```jsx {3-5}
18
+ * <ComboboxProvider>
19
+ * <Combobox />
20
+ * <ComboboxValue>
21
+ * {(value) => `Current value: ${value}`}
22
+ * </ComboboxValue>
23
+ * </ComboboxProvider>
24
+ * ```
25
+ */
26
+ export declare function ComboboxValue({ store, children }?: ComboboxValueProps): ReactNode;
27
+ export interface ComboboxValueProps {
28
+ /**
29
+ * Object returned by the
30
+ * [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
31
+ * hook. If not provided, the closest
32
+ * [`ComboboxProvider`](https://ariakit.org/reference/combobox-provider)
33
+ * component's context will be used.
34
+ */
35
+ store?: ComboboxStore;
36
+ /**
37
+ * A function that gets called with the current value as an argument. It can
38
+ * be used to render the combobox value in a custom way.
39
+ */
40
+ children?: (value: ComboboxStoreState["value"]) => ReactNode;
41
+ }
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _YH42XRHRcjs = require('../__chunks/YH42XRHR.cjs');
4
+ var _2IJSEADJcjs = require('../__chunks/2IJSEADJ.cjs');
5
5
 
6
6
 
7
- var _2IJSEADJcjs = require('../__chunks/2IJSEADJ.cjs');
7
+ var _YH42XRHRcjs = require('../__chunks/YH42XRHR.cjs');
8
8
 
9
9
 
10
10
  var _EKW5CERCcjs = require('../__chunks/EKW5CERC.cjs');
@@ -44,6 +44,7 @@ var _react = require('react');
44
44
 
45
45
 
46
46
 
47
+
47
48
  var _dom = require('@ariakit/core/utils/dom');
48
49
 
49
50
 
@@ -54,8 +55,9 @@ var _focus = require('@ariakit/core/utils/focus');
54
55
 
55
56
 
56
57
 
58
+
57
59
  var _misc = require('@ariakit/core/utils/misc');
58
- var _reactdom = require('react-dom');
60
+ var _store = require('@ariakit/core/utils/store');
59
61
  var TagName = "input";
60
62
  function isFirstItemAutoSelected(items, activeValue, autoSelect) {
61
63
  if (!autoSelect)
@@ -93,7 +95,7 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
93
95
  focusable = true,
94
96
  autoSelect: autoSelectProp = false,
95
97
  getAutoSelectId,
96
- setValueOnChange = true,
98
+ setValueOnChange,
97
99
  showMinLength = 0,
98
100
  showOnChange,
99
101
  showOnMouseDown,
@@ -142,9 +144,26 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
142
144
  setCanInline(true);
143
145
  }, [inline]);
144
146
  const storeValue = store.useState("value");
145
- const activeValue = store.useState(
146
- (state) => inline && canInline ? state.activeValue : void 0
147
- );
147
+ const prevSelectedValueRef = _react.useRef.call(void 0, );
148
+ _react.useEffect.call(void 0, () => {
149
+ return _store.sync.call(void 0, store, ["selectedValue", "activeId"], (_, prev) => {
150
+ prevSelectedValueRef.current = prev.selectedValue;
151
+ });
152
+ }, []);
153
+ const inlineActiveValue = store.useState((state) => {
154
+ var _a2;
155
+ if (!inline)
156
+ return;
157
+ if (!canInline)
158
+ return;
159
+ if (state.activeValue && Array.isArray(state.selectedValue)) {
160
+ if (state.selectedValue.includes(state.activeValue))
161
+ return;
162
+ if ((_a2 = prevSelectedValueRef.current) == null ? void 0 : _a2.includes(state.activeValue))
163
+ return;
164
+ }
165
+ return state.activeValue;
166
+ });
148
167
  const items = store.useState("renderedItems");
149
168
  const open = store.useState("open");
150
169
  const contentElement = store.useState("contentElement");
@@ -155,18 +174,18 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
155
174
  return storeValue;
156
175
  const firstItemAutoSelected = isFirstItemAutoSelected(
157
176
  items,
158
- activeValue,
177
+ inlineActiveValue,
159
178
  autoSelect
160
179
  );
161
180
  if (firstItemAutoSelected) {
162
- if (hasCompletionString(storeValue, activeValue)) {
163
- const slice = (activeValue == null ? void 0 : activeValue.slice(storeValue.length)) || "";
181
+ if (hasCompletionString(storeValue, inlineActiveValue)) {
182
+ const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
164
183
  return storeValue + slice;
165
184
  }
166
185
  return storeValue;
167
186
  }
168
- return activeValue || storeValue;
169
- }, [inline, canInline, items, activeValue, autoSelect, storeValue]);
187
+ return inlineActiveValue || storeValue;
188
+ }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
170
189
  _react.useEffect.call(void 0, () => {
171
190
  const element = ref.current;
172
191
  if (!element)
@@ -182,28 +201,43 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
182
201
  return;
183
202
  if (!canInline)
184
203
  return;
185
- if (!activeValue)
204
+ if (!inlineActiveValue)
186
205
  return;
187
206
  const firstItemAutoSelected = isFirstItemAutoSelected(
188
207
  items,
189
- activeValue,
208
+ inlineActiveValue,
190
209
  autoSelect
191
210
  );
192
211
  if (!firstItemAutoSelected)
193
212
  return;
194
- if (!hasCompletionString(storeValue, activeValue))
213
+ if (!hasCompletionString(storeValue, inlineActiveValue))
195
214
  return;
215
+ let cleanup = _misc.noop;
196
216
  queueMicrotask(() => {
197
217
  const element = ref.current;
198
218
  if (!element)
199
219
  return;
200
- _dom.setSelectionRange.call(void 0, element, storeValue.length, activeValue.length);
220
+ const { start: prevStart, end: prevEnd } = _dom.getTextboxSelection.call(void 0, element);
221
+ const nextStart = storeValue.length;
222
+ const nextEnd = inlineActiveValue.length;
223
+ _dom.setSelectionRange.call(void 0, element, nextStart, nextEnd);
224
+ cleanup = () => {
225
+ if (!_focus.hasFocus.call(void 0, element))
226
+ return;
227
+ const { start, end } = _dom.getTextboxSelection.call(void 0, element);
228
+ if (start !== nextStart)
229
+ return;
230
+ if (end !== nextEnd)
231
+ return;
232
+ _dom.setSelectionRange.call(void 0, element, prevStart, prevEnd);
233
+ };
201
234
  });
235
+ return () => cleanup();
202
236
  }, [
203
237
  valueUpdated,
204
238
  inline,
205
239
  canInline,
206
- activeValue,
240
+ inlineActiveValue,
207
241
  items,
208
242
  autoSelect,
209
243
  storeValue
@@ -314,17 +348,25 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
314
348
  elements.forEach((el) => el.removeEventListener("focusout", onBlur2));
315
349
  };
316
350
  }, [inline, contentElement, store, value]);
317
- const canShow = value.length >= showMinLength;
351
+ const canShow = (event) => {
352
+ const currentTarget = event.currentTarget;
353
+ return currentTarget.value.length >= showMinLength;
354
+ };
318
355
  const onChangeProp = props.onChange;
319
356
  const showOnChangeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, showOnChange != null ? showOnChange : canShow);
320
- const setValueOnChangeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0, setValueOnChange);
357
+ const setValueOnChangeProp = _TW3SFX4Ccjs.useBooleanEvent.call(void 0,
358
+ // If the combobox is combined with tags, the value will be set by the tag
359
+ // input component.
360
+ setValueOnChange != null ? setValueOnChange : !store.tag
361
+ );
321
362
  const onChange = _TW3SFX4Ccjs.useEvent.call(void 0, (event) => {
322
363
  onChangeProp == null ? void 0 : onChangeProp(event);
323
364
  if (event.defaultPrevented)
324
365
  return;
325
366
  if (!store)
326
367
  return;
327
- const { value: value2, selectionStart, selectionEnd } = event.target;
368
+ const currentTarget = event.currentTarget;
369
+ const { value: value2, selectionStart, selectionEnd } = currentTarget;
328
370
  const nativeEvent = event.nativeEvent;
329
371
  canAutoSelectRef.current = true;
330
372
  if (isInputEvent(nativeEvent)) {
@@ -340,8 +382,10 @@ var useCombobox = _NGD3IQDBcjs.createHook.call(void 0,
340
382
  }
341
383
  if (setValueOnChangeProp(event)) {
342
384
  const isSameValue = value2 === store.getState().value;
343
- _reactdom.flushSync.call(void 0, () => store == null ? void 0 : store.setValue(value2));
344
- _dom.setSelectionRange.call(void 0, event.currentTarget, selectionStart, selectionEnd);
385
+ store.setValue(value2);
386
+ queueMicrotask(() => {
387
+ _dom.setSelectionRange.call(void 0, currentTarget, selectionStart, selectionEnd);
388
+ });
345
389
  if (inline && autoSelect && isSameValue) {
346
390
  forceValueUpdate();
347
391
  }
@@ -2,9 +2,9 @@
2
2
 
3
3
 
4
4
 
5
- var _QUHFOHHTcjs = require('../__chunks/QUHFOHHT.cjs');
6
- require('../__chunks/U4NXCMZ3.cjs');
5
+ var _3HMQOCLFcjs = require('../__chunks/3HMQOCLF.cjs');
7
6
  require('../__chunks/HD5AHCRI.cjs');
7
+ require('../__chunks/U4NXCMZ3.cjs');
8
8
  require('../__chunks/6ZZYUFPW.cjs');
9
9
  require('../__chunks/VPI3EKVY.cjs');
10
10
  require('../__chunks/NEK2UEJN.cjs');
@@ -18,4 +18,4 @@ require('../__chunks/AV6KTKLE.cjs');
18
18
 
19
19
 
20
20
 
21
- exports.CompositeItem = _QUHFOHHTcjs.CompositeItem; exports.useCompositeItem = _QUHFOHHTcjs.useCompositeItem;
21
+ exports.CompositeItem = _3HMQOCLFcjs.CompositeItem; exports.useCompositeItem = _3HMQOCLFcjs.useCompositeItem;
@@ -8,9 +8,9 @@ require('../__chunks/YH42XRHR.cjs');
8
8
  require('../__chunks/IXJIFLOA.cjs');
9
9
 
10
10
 
11
- var _QUHFOHHTcjs = require('../__chunks/QUHFOHHT.cjs');
12
- require('../__chunks/U4NXCMZ3.cjs');
11
+ var _3HMQOCLFcjs = require('../__chunks/3HMQOCLF.cjs');
13
12
  require('../__chunks/HD5AHCRI.cjs');
13
+ require('../__chunks/U4NXCMZ3.cjs');
14
14
  require('../__chunks/6ZZYUFPW.cjs');
15
15
  require('../__chunks/VPI3EKVY.cjs');
16
16
  require('../__chunks/NEK2UEJN.cjs');
@@ -70,7 +70,7 @@ var useCompositeOverflowDisclosure = _NGD3IQDBcjs.createHook.call(void 0, functi
70
70
  onFocus,
71
71
  onBlur
72
72
  });
73
- props = _QUHFOHHTcjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), { shouldRegisterItem }));
73
+ props = _3HMQOCLFcjs.useCompositeItem.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), { shouldRegisterItem }));
74
74
  props = _K6TBX2ZBcjs.usePopoverDisclosure.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store }, props));
75
75
  return props;
76
76
  });