@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
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  useCompositeHover
4
4
  } from "../__chunks/VXKKJNIF.js";
5
- import {
6
- useCompositeItem
7
- } from "../__chunks/R33ISPJY.js";
8
- import "../__chunks/PJ7ERAIM.js";
9
5
  import {
10
6
  ComboboxItemCheckedContext,
11
7
  ComboboxItemValueContext,
12
8
  ComboboxListRoleContext,
13
9
  useComboboxScopedContext
14
10
  } from "../__chunks/N4X7J4OQ.js";
11
+ import {
12
+ useCompositeItem
13
+ } from "../__chunks/VGORKDMQ.js";
15
14
  import "../__chunks/IFMAUEA7.js";
15
+ import "../__chunks/PJ7ERAIM.js";
16
16
  import "../__chunks/3IEDWLST.js";
17
17
  import "../__chunks/QFI3MCMR.js";
18
18
  import "../__chunks/6LTHW2TQ.js";
@@ -74,8 +74,9 @@ var useComboboxItem = createHook(
74
74
  store,
75
75
  value,
76
76
  hideOnClick,
77
- selectValueOnClick = true,
78
77
  setValueOnClick,
78
+ selectValueOnClick = true,
79
+ resetValueOnSelect,
79
80
  focusOnHover = false,
80
81
  moveOnKeyPress = true,
81
82
  getItem: getItemProp
@@ -83,12 +84,14 @@ var useComboboxItem = createHook(
83
84
  "store",
84
85
  "value",
85
86
  "hideOnClick",
86
- "selectValueOnClick",
87
87
  "setValueOnClick",
88
+ "selectValueOnClick",
89
+ "resetValueOnSelect",
88
90
  "focusOnHover",
89
91
  "moveOnKeyPress",
90
92
  "getItem"
91
93
  ]);
94
+ var _a2;
92
95
  const context = useComboboxScopedContext();
93
96
  store = store || context;
94
97
  invariant(
@@ -108,11 +111,18 @@ var useComboboxItem = createHook(
108
111
  const multiSelectable = store.useState(
109
112
  (state) => Array.isArray(state.selectedValue)
110
113
  );
114
+ const selected = store.useState(
115
+ (state) => isSelected(state.selectedValue, value)
116
+ );
117
+ const resetValueOnSelectState = store.useState("resetValueOnSelect");
111
118
  setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
112
119
  hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
113
120
  const onClickProp = props.onClick;
114
121
  const setValueOnClickProp = useBooleanEvent(setValueOnClick);
115
122
  const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
123
+ const resetValueOnSelectProp = useBooleanEvent(
124
+ (_a2 = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a2 : multiSelectable
125
+ );
116
126
  const hideOnClickProp = useBooleanEvent(hideOnClick);
117
127
  const onClick = useEvent((event) => {
118
128
  onClickProp == null ? void 0 : onClickProp(event);
@@ -124,6 +134,9 @@ var useComboboxItem = createHook(
124
134
  return;
125
135
  if (value != null) {
126
136
  if (selectValueOnClickProp(event)) {
137
+ if (resetValueOnSelectProp(event)) {
138
+ store == null ? void 0 : store.resetValue();
139
+ }
127
140
  store == null ? void 0 : store.setSelectedValue((prevValue) => {
128
141
  if (!Array.isArray(prevValue))
129
142
  return value;
@@ -159,9 +172,6 @@ var useComboboxItem = createHook(
159
172
  }
160
173
  }
161
174
  });
162
- const selected = store.useState(
163
- (state) => isSelected(state.selectedValue, value)
164
- );
165
175
  if (multiSelectable && selected != null) {
166
176
  props = __spreadValues({
167
177
  "aria-selected": selected
@@ -9,32 +9,32 @@ import "../__chunks/QFI3MCMR.js";
9
9
  import "../__chunks/6LTHW2TQ.js";
10
10
  import {
11
11
  usePopover
12
- } from "../__chunks/LTYEFENI.js";
12
+ } from "../__chunks/6YVAEELE.js";
13
13
  import {
14
14
  createDialogComponent
15
- } from "../__chunks/IOUGWXY5.js";
16
- import "../__chunks/GOXKZAQI.js";
17
- import "../__chunks/6GXEOXGT.js";
18
- import "../__chunks/PTPUIM7N.js";
19
- import "../__chunks/4ZRXV5C7.js";
20
- import "../__chunks/U2L67A6K.js";
21
- import "../__chunks/4KKLZMKS.js";
15
+ } from "../__chunks/FGHVVLPU.js";
16
+ import "../__chunks/CMFBAHKI.js";
22
17
  import "../__chunks/HSFE2URL.js";
23
18
  import "../__chunks/H2NVVTJB.js";
19
+ import "../__chunks/6GXEOXGT.js";
24
20
  import "../__chunks/YNKDLCEK.js";
21
+ import "../__chunks/3TEK3C5Q.js";
22
+ import "../__chunks/4ZRXV5C7.js";
23
+ import "../__chunks/677M2CI3.js";
25
24
  import "../__chunks/MKDDWKFK.js";
26
25
  import "../__chunks/5QL6BP6J.js";
27
26
  import "../__chunks/OOBDFMJL.js";
27
+ import "../__chunks/BC72XE6E.js";
28
28
  import "../__chunks/53CQGCDZ.js";
29
- import "../__chunks/677M2CI3.js";
29
+ import "../__chunks/4KKLZMKS.js";
30
30
  import "../__chunks/UHSH3H5I.js";
31
31
  import "../__chunks/UYRJLDVS.js";
32
+ import "../__chunks/XPF5GU3Q.js";
32
33
  import "../__chunks/JPQNKTGF.js";
33
34
  import "../__chunks/LQTCWTYB.js";
34
35
  import "../__chunks/7452U3HH.js";
35
- import "../__chunks/XPF5GU3Q.js";
36
- import "../__chunks/4MFOHMLS.js";
37
36
  import "../__chunks/KCMTTTFR.js";
37
+ import "../__chunks/4MFOHMLS.js";
38
38
  import "../__chunks/5B3U64HV.js";
39
39
  import "../__chunks/IWHI6Y45.js";
40
40
  import "../__chunks/RG6J4TID.js";
@@ -48,7 +48,9 @@ import {
48
48
  } from "../__chunks/GUCZNEAD.js";
49
49
  import "../__chunks/2KACNUKS.js";
50
50
  import "../__chunks/ZIX5D53S.js";
51
- import "../__chunks/PWUXK5IM.js";
51
+ import {
52
+ useStoreState
53
+ } from "../__chunks/PWUXK5IM.js";
52
54
  import "../__chunks/WOWUAP42.js";
53
55
  import "../__chunks/XM66DUTO.js";
54
56
  import {
@@ -98,6 +100,10 @@ var useComboboxPopover = createHook(
98
100
  );
99
101
  const baseElement = store.useState("baseElement");
100
102
  const hiddenByClickOutsideRef = useRef(false);
103
+ const treeSnapshotKey = useStoreState(
104
+ store.tag,
105
+ (state) => state == null ? void 0 : state.renderedItems.length
106
+ );
101
107
  props = useComboboxList(__spreadValues({ store, alwaysVisible }, props));
102
108
  props = usePopover(__spreadProps(__spreadValues({
103
109
  store,
@@ -106,7 +112,8 @@ var useComboboxPopover = createHook(
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
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  useComboboxStore
4
- } from "../__chunks/ZFEEEZVE.js";
4
+ } from "../__chunks/DLLQM6DZ.js";
5
5
  import {
6
6
  ComboboxContextProvider
7
7
  } from "../__chunks/N4X7J4OQ.js";
8
+ import "../__chunks/WYDDZRWN.js";
8
9
  import "../__chunks/ZR5N62ZV.js";
9
10
  import "../__chunks/LGWSZOP2.js";
10
11
  import "../__chunks/QFI3MCMR.js";
@@ -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,13 @@
2
2
  import {
3
3
  useComboboxStore,
4
4
  useComboboxStoreProps
5
- } from "../__chunks/ZFEEEZVE.js";
5
+ } from "../__chunks/DLLQM6DZ.js";
6
+ import "../__chunks/WYDDZRWN.js";
6
7
  import "../__chunks/ZR5N62ZV.js";
7
8
  import "../__chunks/LGWSZOP2.js";
9
+ import "../__chunks/QFI3MCMR.js";
10
+ import "../__chunks/6LTHW2TQ.js";
11
+ import "../__chunks/GUCZNEAD.js";
8
12
  import "../__chunks/JNGHG5BN.js";
9
13
  import "../__chunks/2KACNUKS.js";
10
14
  import "../__chunks/ZIX5D53S.js";
@@ -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,32 @@
1
+ "use client";
2
+ import {
3
+ useComboboxContext
4
+ } from "../__chunks/N4X7J4OQ.js";
5
+ import "../__chunks/QFI3MCMR.js";
6
+ import "../__chunks/6LTHW2TQ.js";
7
+ import "../__chunks/5B3U64HV.js";
8
+ import "../__chunks/IWHI6Y45.js";
9
+ import "../__chunks/RG6J4TID.js";
10
+ import "../__chunks/GUCZNEAD.js";
11
+ import "../__chunks/WOWUAP42.js";
12
+ import "../__chunks/XM66DUTO.js";
13
+ import "../__chunks/4R3V3JGP.js";
14
+
15
+ // src/combobox/combobox-value.tsx
16
+ import { invariant } from "@ariakit/core/utils/misc";
17
+ function ComboboxValue({ store, children } = {}) {
18
+ const context = useComboboxContext();
19
+ store = store || context;
20
+ invariant(
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
+ export {
31
+ ComboboxValue
32
+ };
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import {
3
- usePopoverAnchor
4
- } from "../__chunks/DYQUE3V3.js";
5
2
  import {
6
3
  useComboboxProviderContext
7
4
  } from "../__chunks/N4X7J4OQ.js";
5
+ import {
6
+ usePopoverAnchor
7
+ } from "../__chunks/DYQUE3V3.js";
8
8
  import {
9
9
  useComposite
10
10
  } from "../__chunks/CDZXDIC7.js";
@@ -43,6 +43,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
43
43
  import {
44
44
  getPopupRole,
45
45
  getScrollingElement,
46
+ getTextboxSelection,
46
47
  setSelectionRange
47
48
  } from "@ariakit/core/utils/dom";
48
49
  import {
@@ -53,9 +54,10 @@ import { hasFocus } from "@ariakit/core/utils/focus";
53
54
  import {
54
55
  invariant,
55
56
  isFalsyBooleanCallback,
57
+ noop,
56
58
  normalizeString
57
59
  } from "@ariakit/core/utils/misc";
58
- import { flushSync } from "react-dom";
60
+ import { sync } from "@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 = createHook(
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 = createHook(
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 = useRef();
148
+ useEffect(() => {
149
+ return sync(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 = createHook(
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
  useEffect(() => {
171
190
  const element = ref.current;
172
191
  if (!element)
@@ -182,28 +201,43 @@ var useCombobox = createHook(
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 = noop;
196
216
  queueMicrotask(() => {
197
217
  const element = ref.current;
198
218
  if (!element)
199
219
  return;
200
- setSelectionRange(element, storeValue.length, activeValue.length);
220
+ const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
221
+ const nextStart = storeValue.length;
222
+ const nextEnd = inlineActiveValue.length;
223
+ setSelectionRange(element, nextStart, nextEnd);
224
+ cleanup = () => {
225
+ if (!hasFocus(element))
226
+ return;
227
+ const { start, end } = getTextboxSelection(element);
228
+ if (start !== nextStart)
229
+ return;
230
+ if (end !== nextEnd)
231
+ return;
232
+ setSelectionRange(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 = createHook(
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 = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
320
- const setValueOnChangeProp = useBooleanEvent(setValueOnChange);
357
+ const setValueOnChangeProp = useBooleanEvent(
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 = useEvent((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 = createHook(
340
382
  }
341
383
  if (setValueOnChangeProp(event)) {
342
384
  const isSameValue = value2 === store.getState().value;
343
- flushSync(() => store == null ? void 0 : store.setValue(value2));
344
- setSelectionRange(event.currentTarget, selectionStart, selectionEnd);
385
+ store.setValue(value2);
386
+ queueMicrotask(() => {
387
+ setSelectionRange(currentTarget, selectionStart, selectionEnd);
388
+ });
345
389
  if (inline && autoSelect && isSameValue) {
346
390
  forceValueUpdate();
347
391
  }
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  CompositeItem,
4
4
  useCompositeItem
5
- } from "../__chunks/R33ISPJY.js";
6
- import "../__chunks/PJ7ERAIM.js";
5
+ } from "../__chunks/VGORKDMQ.js";
7
6
  import "../__chunks/IFMAUEA7.js";
7
+ import "../__chunks/PJ7ERAIM.js";
8
8
  import "../__chunks/3IEDWLST.js";
9
9
  import "../__chunks/QFI3MCMR.js";
10
10
  import "../__chunks/6LTHW2TQ.js";
@@ -8,9 +8,9 @@ import "../__chunks/DYQUE3V3.js";
8
8
  import "../__chunks/CKAOM5LG.js";
9
9
  import {
10
10
  useCompositeItem
11
- } from "../__chunks/R33ISPJY.js";
12
- import "../__chunks/PJ7ERAIM.js";
11
+ } from "../__chunks/VGORKDMQ.js";
13
12
  import "../__chunks/IFMAUEA7.js";
13
+ import "../__chunks/PJ7ERAIM.js";
14
14
  import "../__chunks/3IEDWLST.js";
15
15
  import "../__chunks/QFI3MCMR.js";
16
16
  import "../__chunks/6LTHW2TQ.js";
@@ -1,30 +1,30 @@
1
1
  "use client";
2
2
  import {
3
3
  usePopover
4
- } from "../__chunks/LTYEFENI.js";
5
- import "../__chunks/IOUGWXY5.js";
6
- import "../__chunks/GOXKZAQI.js";
7
- import "../__chunks/6GXEOXGT.js";
8
- import "../__chunks/PTPUIM7N.js";
9
- import "../__chunks/4ZRXV5C7.js";
10
- import "../__chunks/U2L67A6K.js";
11
- import "../__chunks/4KKLZMKS.js";
4
+ } from "../__chunks/6YVAEELE.js";
5
+ import "../__chunks/FGHVVLPU.js";
6
+ import "../__chunks/CMFBAHKI.js";
12
7
  import "../__chunks/HSFE2URL.js";
13
8
  import "../__chunks/H2NVVTJB.js";
9
+ import "../__chunks/6GXEOXGT.js";
14
10
  import "../__chunks/YNKDLCEK.js";
11
+ import "../__chunks/3TEK3C5Q.js";
12
+ import "../__chunks/4ZRXV5C7.js";
13
+ import "../__chunks/677M2CI3.js";
15
14
  import "../__chunks/MKDDWKFK.js";
16
15
  import "../__chunks/5QL6BP6J.js";
17
16
  import "../__chunks/OOBDFMJL.js";
17
+ import "../__chunks/BC72XE6E.js";
18
18
  import "../__chunks/53CQGCDZ.js";
19
- import "../__chunks/677M2CI3.js";
19
+ import "../__chunks/4KKLZMKS.js";
20
20
  import "../__chunks/UHSH3H5I.js";
21
21
  import "../__chunks/UYRJLDVS.js";
22
+ import "../__chunks/XPF5GU3Q.js";
22
23
  import "../__chunks/JPQNKTGF.js";
23
24
  import "../__chunks/LQTCWTYB.js";
24
25
  import "../__chunks/7452U3HH.js";
25
- import "../__chunks/XPF5GU3Q.js";
26
- import "../__chunks/4MFOHMLS.js";
27
26
  import "../__chunks/KCMTTTFR.js";
27
+ import "../__chunks/4MFOHMLS.js";
28
28
  import "../__chunks/5B3U64HV.js";
29
29
  import "../__chunks/IWHI6Y45.js";
30
30
  import "../__chunks/RG6J4TID.js";
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import {
3
3
  DialogBackdrop
4
- } from "../__chunks/GOXKZAQI.js";
4
+ } from "../__chunks/CMFBAHKI.js";
5
5
  import "../__chunks/YNKDLCEK.js";
6
6
  import "../__chunks/MKDDWKFK.js";
7
7
  import "../__chunks/5QL6BP6J.js";
8
8
  import "../__chunks/53CQGCDZ.js";
9
- import "../__chunks/4MFOHMLS.js";
10
9
  import "../__chunks/KCMTTTFR.js";
10
+ import "../__chunks/4MFOHMLS.js";
11
11
  import "../__chunks/IWHI6Y45.js";
12
12
  import "../__chunks/RG6J4TID.js";
13
13
  import "../__chunks/GUCZNEAD.js";
@@ -254,6 +254,10 @@ export interface DialogOptions<T extends ElementType = TagName> extends Focusabl
254
254
  * will be focused again.
255
255
  */
256
256
  finalFocus?: HTMLElement | RefObject<HTMLElement> | null;
257
+ /**
258
+ * @private
259
+ */
260
+ unstable_treeSnapshotKey?: string | number | boolean | null;
257
261
  }
258
262
  export type DialogProps<T extends ElementType = TagName> = Props<T, DialogOptions<T>>;
259
263
  export {};
@@ -3,29 +3,29 @@ import {
3
3
  Dialog,
4
4
  createDialogComponent,
5
5
  useDialog
6
- } from "../__chunks/IOUGWXY5.js";
7
- import "../__chunks/GOXKZAQI.js";
8
- import "../__chunks/6GXEOXGT.js";
9
- import "../__chunks/PTPUIM7N.js";
10
- import "../__chunks/4ZRXV5C7.js";
11
- import "../__chunks/U2L67A6K.js";
12
- import "../__chunks/4KKLZMKS.js";
6
+ } from "../__chunks/FGHVVLPU.js";
7
+ import "../__chunks/CMFBAHKI.js";
13
8
  import "../__chunks/HSFE2URL.js";
14
9
  import "../__chunks/H2NVVTJB.js";
10
+ import "../__chunks/6GXEOXGT.js";
15
11
  import "../__chunks/YNKDLCEK.js";
12
+ import "../__chunks/3TEK3C5Q.js";
13
+ import "../__chunks/4ZRXV5C7.js";
14
+ import "../__chunks/677M2CI3.js";
16
15
  import "../__chunks/MKDDWKFK.js";
17
16
  import "../__chunks/5QL6BP6J.js";
18
17
  import "../__chunks/OOBDFMJL.js";
18
+ import "../__chunks/BC72XE6E.js";
19
19
  import "../__chunks/53CQGCDZ.js";
20
- import "../__chunks/677M2CI3.js";
20
+ import "../__chunks/4KKLZMKS.js";
21
21
  import "../__chunks/UHSH3H5I.js";
22
22
  import "../__chunks/UYRJLDVS.js";
23
+ import "../__chunks/XPF5GU3Q.js";
23
24
  import "../__chunks/JPQNKTGF.js";
24
25
  import "../__chunks/LQTCWTYB.js";
25
26
  import "../__chunks/7452U3HH.js";
26
- import "../__chunks/XPF5GU3Q.js";
27
- import "../__chunks/4MFOHMLS.js";
28
27
  import "../__chunks/KCMTTTFR.js";
28
+ import "../__chunks/4MFOHMLS.js";
29
29
  import "../__chunks/IWHI6Y45.js";
30
30
  import "../__chunks/RG6J4TID.js";
31
31
  import "../__chunks/7JCFLN3D.js";
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  disableTree,
4
4
  disableTreeOutside
5
- } from "../../__chunks/PTPUIM7N.js";
5
+ } from "../../__chunks/3TEK3C5Q.js";
6
6
  import "../../__chunks/4ZRXV5C7.js";
7
+ import "../../__chunks/677M2CI3.js";
7
8
  import "../../__chunks/MKDDWKFK.js";
8
9
  import "../../__chunks/5QL6BP6J.js";
9
10
  import "../../__chunks/53CQGCDZ.js";
10
- import "../../__chunks/677M2CI3.js";
11
11
  import "../../__chunks/4R3V3JGP.js";
12
12
  export {
13
13
  disableTree,
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  usePreventBodyScroll
4
- } from "../../__chunks/U2L67A6K.js";
5
- import "../../__chunks/4KKLZMKS.js";
4
+ } from "../../__chunks/BC72XE6E.js";
6
5
  import "../../__chunks/53CQGCDZ.js";
6
+ import "../../__chunks/4KKLZMKS.js";
7
7
  import "../../__chunks/WOWUAP42.js";
8
8
  import "../../__chunks/XM66DUTO.js";
9
9
  import "../../__chunks/4R3V3JGP.js";