@ariakit/react-core 0.3.6 → 0.3.8

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 (148) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/cjs/__chunks/{VEG6PRAG.cjs → 3WCBE6SU.cjs} +3 -1
  3. package/cjs/__chunks/{45RPYV4J.cjs → EQ4A5RPW.cjs} +2 -2
  4. package/cjs/__chunks/{CILQPSH2.cjs → FA25CV2I.cjs} +2 -2
  5. package/cjs/__chunks/{RRW7YVFR.cjs → IPYAEPOT.cjs} +17 -6
  6. package/cjs/__chunks/{AYDXWQBF.cjs → L3WS5HGI.cjs} +2 -0
  7. package/cjs/__chunks/{QU2266CJ.cjs → WH4I6OSN.cjs} +12 -4
  8. package/cjs/__chunks/{LVOI2KVN.cjs → XGKLTARH.cjs} +2 -2
  9. package/cjs/__chunks/{4GLXDOKG.cjs → YAPOM5RT.cjs} +2 -2
  10. package/cjs/checkbox/checkbox-provider.cjs +2 -2
  11. package/cjs/combobox/combobox-cancel.cjs +2 -2
  12. package/cjs/combobox/combobox-context.cjs +4 -2
  13. package/cjs/combobox/combobox-context.d.cts +6 -5
  14. package/cjs/combobox/combobox-context.d.ts +6 -5
  15. package/cjs/combobox/combobox-disclosure.cjs +2 -2
  16. package/cjs/combobox/combobox-item-check.cjs +50 -0
  17. package/cjs/combobox/combobox-item-check.d.cts +60 -0
  18. package/cjs/combobox/combobox-item-check.d.ts +60 -0
  19. package/cjs/combobox/combobox-item-value.cjs +3 -3
  20. package/cjs/combobox/combobox-item.cjs +47 -10
  21. package/cjs/combobox/combobox-item.d.cts +31 -13
  22. package/cjs/combobox/combobox-item.d.ts +31 -13
  23. package/cjs/combobox/combobox-label.cjs +55 -0
  24. package/cjs/combobox/combobox-label.d.cts +42 -0
  25. package/cjs/combobox/combobox-label.d.ts +42 -0
  26. package/cjs/combobox/combobox-list.cjs +3 -3
  27. package/cjs/combobox/combobox-popover.cjs +7 -7
  28. package/cjs/combobox/combobox-provider.cjs +4 -4
  29. package/cjs/combobox/combobox-provider.d.cts +8 -4
  30. package/cjs/combobox/combobox-provider.d.ts +8 -4
  31. package/cjs/combobox/combobox-row.cjs +2 -2
  32. package/cjs/combobox/combobox-separator.cjs +2 -2
  33. package/cjs/combobox/combobox-store.cjs +2 -2
  34. package/cjs/combobox/combobox-store.d.cts +28 -9
  35. package/cjs/combobox/combobox-store.d.ts +28 -9
  36. package/cjs/combobox/combobox.cjs +28 -14
  37. package/cjs/combobox/combobox.d.cts +2 -1
  38. package/cjs/combobox/combobox.d.ts +2 -1
  39. package/cjs/composite/composite-hover.cjs +2 -2
  40. package/cjs/composite/composite-hover.d.cts +9 -0
  41. package/cjs/composite/composite-hover.d.ts +9 -0
  42. package/cjs/composite/composite-item.d.cts +3 -0
  43. package/cjs/composite/composite-item.d.ts +3 -0
  44. package/cjs/composite/composite-overflow.cjs +2 -2
  45. package/cjs/disclosure/disclosure-content.d.cts +3 -1
  46. package/cjs/disclosure/disclosure-content.d.ts +3 -1
  47. package/cjs/disclosure/disclosure.d.cts +3 -0
  48. package/cjs/disclosure/disclosure.d.ts +3 -0
  49. package/cjs/focusable/focusable.d.cts +2 -1
  50. package/cjs/focusable/focusable.d.ts +2 -1
  51. package/cjs/form/form-checkbox.cjs +1 -1
  52. package/cjs/hovercard/hovercard-anchor.d.cts +3 -0
  53. package/cjs/hovercard/hovercard-anchor.d.ts +3 -0
  54. package/cjs/hovercard/hovercard.cjs +3 -3
  55. package/cjs/menu/menu-button.cjs +33 -21
  56. package/cjs/menu/menu-item-checkbox.cjs +4 -4
  57. package/cjs/menu/menu-item-radio.cjs +3 -3
  58. package/cjs/menu/menu-item.cjs +3 -3
  59. package/cjs/menu/menu-provider.cjs +3 -3
  60. package/cjs/menu/menu-store.cjs +3 -3
  61. package/cjs/menu/menu-store.d.cts +7 -55
  62. package/cjs/menu/menu-store.d.ts +7 -55
  63. package/cjs/menu/menu.cjs +3 -3
  64. package/cjs/popover/popover.cjs +2 -2
  65. package/cjs/popover/popover.d.cts +4 -0
  66. package/cjs/popover/popover.d.ts +4 -0
  67. package/cjs/portal/portal.d.cts +5 -1
  68. package/cjs/portal/portal.d.ts +5 -1
  69. package/cjs/select/select-item.cjs +5 -5
  70. package/cjs/select/select-label.cjs +1 -1
  71. package/cjs/select/select-popover.cjs +2 -2
  72. package/cjs/select/select-provider.cjs +3 -3
  73. package/cjs/select/select-store.cjs +3 -3
  74. package/cjs/select/select-store.d.cts +1 -7
  75. package/cjs/select/select-store.d.ts +1 -7
  76. package/cjs/tooltip/tooltip.cjs +3 -3
  77. package/combobox/combobox-item-check/package.json +8 -0
  78. package/combobox/combobox-label/package.json +8 -0
  79. package/esm/__chunks/{KFUKDUTY.js → 4AMOOZBQ.js} +10 -2
  80. package/esm/__chunks/{PHTJ3BCW.js → 7HYEBVZE.js} +1 -1
  81. package/esm/__chunks/{YGJUONJM.js → BONLQCKO.js} +1 -1
  82. package/esm/__chunks/{BRO2JF5P.js → G6ONQ5EH.js} +20 -9
  83. package/esm/__chunks/{W3TC4TID.js → JRUYDVPB.js} +1 -1
  84. package/esm/__chunks/{NE6JAKK6.js → P3UZS6BC.js} +1 -1
  85. package/esm/__chunks/{MTC2KUZZ.js → W76OTZCC.js} +3 -1
  86. package/esm/__chunks/{24AKC2LC.js → ZETMAOTK.js} +2 -0
  87. package/esm/checkbox/checkbox-provider.js +3 -3
  88. package/esm/combobox/combobox-cancel.js +1 -1
  89. package/esm/combobox/combobox-context.d.ts +6 -5
  90. package/esm/combobox/combobox-context.js +3 -1
  91. package/esm/combobox/combobox-disclosure.js +1 -1
  92. package/esm/combobox/combobox-item-check.d.ts +60 -0
  93. package/esm/combobox/combobox-item-check.js +50 -0
  94. package/esm/combobox/combobox-item-value.js +1 -1
  95. package/esm/combobox/combobox-item.d.ts +31 -13
  96. package/esm/combobox/combobox-item.js +45 -8
  97. package/esm/combobox/combobox-label.d.ts +42 -0
  98. package/esm/combobox/combobox-label.js +55 -0
  99. package/esm/combobox/combobox-list.js +2 -2
  100. package/esm/combobox/combobox-popover.js +3 -3
  101. package/esm/combobox/combobox-provider.d.ts +8 -4
  102. package/esm/combobox/combobox-provider.js +2 -2
  103. package/esm/combobox/combobox-row.js +1 -1
  104. package/esm/combobox/combobox-separator.js +1 -1
  105. package/esm/combobox/combobox-store.d.ts +28 -9
  106. package/esm/combobox/combobox-store.js +1 -1
  107. package/esm/combobox/combobox.d.ts +2 -1
  108. package/esm/combobox/combobox.js +28 -14
  109. package/esm/composite/composite-hover.d.ts +9 -0
  110. package/esm/composite/composite-hover.js +1 -1
  111. package/esm/composite/composite-item.d.ts +3 -0
  112. package/esm/composite/composite-overflow.js +1 -1
  113. package/esm/disclosure/disclosure-content.d.ts +3 -1
  114. package/esm/disclosure/disclosure.d.ts +3 -0
  115. package/esm/focusable/focusable.d.ts +2 -1
  116. package/esm/form/form-checkbox.js +1 -1
  117. package/esm/hovercard/hovercard-anchor.d.ts +3 -0
  118. package/esm/hovercard/hovercard.js +2 -2
  119. package/esm/menu/menu-button.js +33 -21
  120. package/esm/menu/menu-item-checkbox.js +3 -3
  121. package/esm/menu/menu-item-radio.js +2 -2
  122. package/esm/menu/menu-item.js +2 -2
  123. package/esm/menu/menu-provider.js +2 -2
  124. package/esm/menu/menu-store.d.ts +7 -55
  125. package/esm/menu/menu-store.js +2 -2
  126. package/esm/menu/menu.js +2 -2
  127. package/esm/popover/popover.d.ts +4 -0
  128. package/esm/popover/popover.js +1 -1
  129. package/esm/portal/portal.d.ts +5 -1
  130. package/esm/select/select-item.js +4 -4
  131. package/esm/select/select-label.js +2 -2
  132. package/esm/select/select-popover.js +1 -1
  133. package/esm/select/select-provider.js +2 -2
  134. package/esm/select/select-store.d.ts +1 -7
  135. package/esm/select/select-store.js +2 -2
  136. package/esm/tooltip/tooltip.js +2 -2
  137. package/package.json +16 -2
  138. package/cjs/collection/collection-context.d.cts +0 -34
  139. package/cjs/collection/collection-context.d.ts +0 -34
  140. package/cjs/composite/utils.d.cts +0 -69
  141. package/cjs/composite/utils.d.ts +0 -69
  142. package/cjs/tab/tab-store.d.cts +0 -74
  143. package/cjs/tab/tab-store.d.ts +0 -74
  144. package/esm/collection/collection-context.d.ts +0 -34
  145. package/esm/composite/utils.d.ts +0 -69
  146. package/esm/tab/tab-store.d.ts +0 -74
  147. package/cjs/__chunks/{ISGOCBDC.cjs → RIZYIKBE.cjs} +1 -1
  148. package/esm/__chunks/{KB2HXEVC.js → WBQC3LL4.js} +1 -1
@@ -1,11 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _RRW7YVFRcjs = require('../__chunks/RRW7YVFR.cjs');
4
+ var _IPYAEPOTcjs = require('../__chunks/IPYAEPOT.cjs');
5
5
 
6
6
 
7
7
 
8
- var _VEG6PRAGcjs = require('../__chunks/VEG6PRAG.cjs');
8
+
9
+ var _3WCBE6SUcjs = require('../__chunks/3WCBE6SU.cjs');
9
10
 
10
11
 
11
12
  var _P43G7USHcjs = require('../__chunks/P43G7USH.cjs');
@@ -44,13 +45,24 @@ var _events = require('@ariakit/core/utils/events');
44
45
  var _focus = require('@ariakit/core/utils/focus');
45
46
  var _misc = require('@ariakit/core/utils/misc');
46
47
  var _jsxruntime = require('react/jsx-runtime');
48
+ function isSelected(storeValue, itemValue) {
49
+ if (itemValue == null)
50
+ return;
51
+ if (storeValue == null)
52
+ return false;
53
+ if (Array.isArray(storeValue)) {
54
+ return storeValue.includes(itemValue);
55
+ }
56
+ return storeValue === itemValue;
57
+ }
47
58
  var useComboboxItem = _RNZNGEL4cjs.createHook.call(void 0,
48
59
  (_a) => {
49
60
  var _b = _a, {
50
61
  store,
51
62
  value,
52
- hideOnClick = value != null,
53
- setValueOnClick = true,
63
+ hideOnClick,
64
+ selectValueOnClick = true,
65
+ setValueOnClick,
54
66
  focusOnHover = false,
55
67
  moveOnKeyPress = true,
56
68
  getItem: getItemProp
@@ -58,12 +70,13 @@ var useComboboxItem = _RNZNGEL4cjs.createHook.call(void 0,
58
70
  "store",
59
71
  "value",
60
72
  "hideOnClick",
73
+ "selectValueOnClick",
61
74
  "setValueOnClick",
62
75
  "focusOnHover",
63
76
  "moveOnKeyPress",
64
77
  "getItem"
65
78
  ]);
66
- const context = _VEG6PRAGcjs.useComboboxScopedContext.call(void 0, );
79
+ const context = _3WCBE6SUcjs.useComboboxScopedContext.call(void 0, );
67
80
  store = store || context;
68
81
  _misc.invariant.call(void 0,
69
82
  store,
@@ -79,8 +92,14 @@ var useComboboxItem = _RNZNGEL4cjs.createHook.call(void 0,
79
92
  },
80
93
  [value, getItemProp]
81
94
  );
95
+ const multiSelectable = store.useState(
96
+ (state) => Array.isArray(state.selectedValue)
97
+ );
98
+ setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
99
+ hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
82
100
  const onClickProp = props.onClick;
83
101
  const setValueOnClickProp = _EO6LS72Hcjs.useBooleanEvent.call(void 0, setValueOnClick);
102
+ const selectValueOnClickProp = _EO6LS72Hcjs.useBooleanEvent.call(void 0, selectValueOnClick);
84
103
  const hideOnClickProp = _EO6LS72Hcjs.useBooleanEvent.call(void 0, hideOnClick);
85
104
  const onClick = _EO6LS72Hcjs.useEvent.call(void 0, (event) => {
86
105
  onClickProp == null ? void 0 : onClickProp(event);
@@ -90,8 +109,20 @@ var useComboboxItem = _RNZNGEL4cjs.createHook.call(void 0,
90
109
  return;
91
110
  if (_events.isOpeningInNewTab.call(void 0, event))
92
111
  return;
93
- if (value != null && setValueOnClickProp(event)) {
94
- store == null ? void 0 : store.setValue(value);
112
+ if (value != null) {
113
+ if (selectValueOnClickProp(event)) {
114
+ store == null ? void 0 : store.setSelectedValue((prevValue) => {
115
+ if (!Array.isArray(prevValue))
116
+ return value;
117
+ if (prevValue.includes(value)) {
118
+ return prevValue.filter((v) => v !== value);
119
+ }
120
+ return [...prevValue, value];
121
+ });
122
+ }
123
+ if (setValueOnClickProp(event)) {
124
+ store == null ? void 0 : store.setValue(value);
125
+ }
95
126
  }
96
127
  if (hideOnClickProp(event)) {
97
128
  store == null ? void 0 : store.move(null);
@@ -116,10 +147,16 @@ var useComboboxItem = _RNZNGEL4cjs.createHook.call(void 0,
116
147
  }
117
148
  }
118
149
  });
150
+ const selected = store.useState(
151
+ (state) => isSelected(state.selectedValue, value)
152
+ );
153
+ if (multiSelectable && selected != null) {
154
+ props["aria-selected"] = selected;
155
+ }
119
156
  props = _EO6LS72Hcjs.useWrapElement.call(void 0,
120
157
  props,
121
- (element) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VEG6PRAGcjs.ComboboxItemValueContext.Provider, { value, children: element }),
122
- [value]
158
+ (element) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _3WCBE6SUcjs.ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _3WCBE6SUcjs.ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
159
+ [value, selected]
123
160
  );
124
161
  const contentElement = store.useState("contentElement");
125
162
  props = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
@@ -146,7 +183,7 @@ var useComboboxItem = _RNZNGEL4cjs.createHook.call(void 0,
146
183
  return true;
147
184
  }
148
185
  }));
149
- props = _RRW7YVFRcjs.useCompositeHover.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, focusOnHover }, props));
186
+ props = _IPYAEPOTcjs.useCompositeHover.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, focusOnHover }, props));
150
187
  return props;
151
188
  }
152
189
  );
@@ -52,15 +52,15 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
52
52
  store?: ComboboxStore;
53
53
  /**
54
54
  * The value of the item. This will be rendered as the children by default.
55
- * - If
56
- * [`setValueOnClick`](https://ariakit.org/reference/combobox-item#setvalueonclick)
57
- * is set to `true`, this will be the value of the combobox input when the
58
- * user clicks on this item.
59
- * - If the
60
- * [`autoComplete`](https://ariakit.org/reference/combobox#autocomplete)
61
- * prop on the [`Combobox`](https://ariakit.org/reference/combobox)
62
- * component is set to `both` or `inline`, this will be the value of the
63
- * combobox input when the combobox loses focus.
55
+ * - If
56
+ * [`setValueOnClick`](https://ariakit.org/reference/combobox-item#setvalueonclick)
57
+ * is set to `true`, this will be the value of the combobox input when the
58
+ * user clicks on this item.
59
+ * - If the
60
+ * [`autoComplete`](https://ariakit.org/reference/combobox#autocomplete)
61
+ * prop on the [`Combobox`](https://ariakit.org/reference/combobox)
62
+ * component is set to `both` or `inline`, this will be the value of the
63
+ * combobox input when the combobox loses focus.
64
64
  *
65
65
  * Live examples:
66
66
  * - [Animated Combobox](https://ariakit.org/examples/combobox-animated)
@@ -73,18 +73,36 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
73
73
  */
74
74
  value?: string;
75
75
  /**
76
- * Whether to hide the combobox when this item is clicked.
76
+ * Whether to hide the combobox when this item is clicked. By default, the
77
+ * combobox will be hidden when the user clicks on an item with a
78
+ * [`value`](https://ariakit.org/reference/combobox-item#value) prop, unless
79
+ * the combobox is
80
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
77
81
  *
78
82
  * Live examples:
79
83
  * - [Combobox with links](https://ariakit.org/examples/combobox-links)
80
- * @default true
81
84
  */
82
85
  hideOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
83
86
  /**
84
- * Whether to set the combobox value with this item's value when this item is
85
- * clicked.
87
+ * Whether to set the
88
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
89
+ * state using this item's
90
+ * [`value`](https://ariakit.org/reference/combobox-item#value) when the item
91
+ * is clicked.
86
92
  * @default true
87
93
  */
94
+ selectValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
95
+ /**
96
+ * Whether to set the combobox
97
+ * [`value`](https://ariakit.org/reference/combobox-provider#value) state
98
+ * using this item's
99
+ * [`value`](https://ariakit.org/reference/combobox-item#value) when the item
100
+ * is clicked. The default is `true`, unless the combobox is
101
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
102
+ *
103
+ * Live examples:
104
+ * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
105
+ */
88
106
  setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
89
107
  /**
90
108
  * @default false
@@ -52,15 +52,15 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
52
52
  store?: ComboboxStore;
53
53
  /**
54
54
  * The value of the item. This will be rendered as the children by default.
55
- * - If
56
- * [`setValueOnClick`](https://ariakit.org/reference/combobox-item#setvalueonclick)
57
- * is set to `true`, this will be the value of the combobox input when the
58
- * user clicks on this item.
59
- * - If the
60
- * [`autoComplete`](https://ariakit.org/reference/combobox#autocomplete)
61
- * prop on the [`Combobox`](https://ariakit.org/reference/combobox)
62
- * component is set to `both` or `inline`, this will be the value of the
63
- * combobox input when the combobox loses focus.
55
+ * - If
56
+ * [`setValueOnClick`](https://ariakit.org/reference/combobox-item#setvalueonclick)
57
+ * is set to `true`, this will be the value of the combobox input when the
58
+ * user clicks on this item.
59
+ * - If the
60
+ * [`autoComplete`](https://ariakit.org/reference/combobox#autocomplete)
61
+ * prop on the [`Combobox`](https://ariakit.org/reference/combobox)
62
+ * component is set to `both` or `inline`, this will be the value of the
63
+ * combobox input when the combobox loses focus.
64
64
  *
65
65
  * Live examples:
66
66
  * - [Animated Combobox](https://ariakit.org/examples/combobox-animated)
@@ -73,18 +73,36 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
73
73
  */
74
74
  value?: string;
75
75
  /**
76
- * Whether to hide the combobox when this item is clicked.
76
+ * Whether to hide the combobox when this item is clicked. By default, the
77
+ * combobox will be hidden when the user clicks on an item with a
78
+ * [`value`](https://ariakit.org/reference/combobox-item#value) prop, unless
79
+ * the combobox is
80
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
77
81
  *
78
82
  * Live examples:
79
83
  * - [Combobox with links](https://ariakit.org/examples/combobox-links)
80
- * @default true
81
84
  */
82
85
  hideOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
83
86
  /**
84
- * Whether to set the combobox value with this item's value when this item is
85
- * clicked.
87
+ * Whether to set the
88
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
89
+ * state using this item's
90
+ * [`value`](https://ariakit.org/reference/combobox-item#value) when the item
91
+ * is clicked.
86
92
  * @default true
87
93
  */
94
+ selectValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
95
+ /**
96
+ * Whether to set the combobox
97
+ * [`value`](https://ariakit.org/reference/combobox-provider#value) state
98
+ * using this item's
99
+ * [`value`](https://ariakit.org/reference/combobox-item#value) when the item
100
+ * is clicked. The default is `true`, unless the combobox is
101
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
102
+ *
103
+ * Live examples:
104
+ * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
105
+ */
88
106
  setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
89
107
  /**
90
108
  * @default false
@@ -0,0 +1,55 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _3WCBE6SUcjs = require('../__chunks/3WCBE6SU.cjs');
5
+ require('../__chunks/UZNYSPKP.cjs');
6
+ require('../__chunks/BZTDJIVT.cjs');
7
+ require('../__chunks/UVBBMANL.cjs');
8
+ require('../__chunks/F2A2ZQDB.cjs');
9
+ require('../__chunks/S6UU7NA4.cjs');
10
+
11
+
12
+
13
+
14
+ var _RNZNGEL4cjs = require('../__chunks/RNZNGEL4.cjs');
15
+ require('../__chunks/EO6LS72H.cjs');
16
+ require('../__chunks/CJDHQUBR.cjs');
17
+
18
+
19
+
20
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
21
+
22
+ // src/combobox/combobox-label.ts
23
+ var _misc = require('@ariakit/core/utils/misc');
24
+ var useComboboxLabel = _RNZNGEL4cjs.createHook.call(void 0,
25
+ (_a) => {
26
+ var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
27
+ const context = _3WCBE6SUcjs.useComboboxProviderContext.call(void 0, );
28
+ store = store || context;
29
+ _misc.invariant.call(void 0,
30
+ store,
31
+ process.env.NODE_ENV !== "production" && "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
32
+ );
33
+ const comboboxId = store.useState((state) => {
34
+ var _a2;
35
+ return (_a2 = state.baseElement) == null ? void 0 : _a2.id;
36
+ });
37
+ props = _AV6KTKLEcjs.__spreadValues.call(void 0, {
38
+ htmlFor: comboboxId
39
+ }, props);
40
+ return props;
41
+ }
42
+ );
43
+ var ComboboxLabel = _RNZNGEL4cjs.createMemoComponent.call(void 0,
44
+ (props) => {
45
+ const htmlProps = useComboboxLabel(props);
46
+ return _RNZNGEL4cjs.createElement.call(void 0, "label", htmlProps);
47
+ }
48
+ );
49
+ if (process.env.NODE_ENV !== "production") {
50
+ ComboboxLabel.displayName = "ComboboxLabel";
51
+ }
52
+
53
+
54
+
55
+ exports.ComboboxLabel = ComboboxLabel; exports.useComboboxLabel = useComboboxLabel;
@@ -0,0 +1,42 @@
1
+ import type { As, Options, Props } from "../utils/types.js";
2
+ import type { ComboboxStore } from "./combobox-store.js";
3
+ /**
4
+ * Returns props to create a `ComboboxLabel` component.
5
+ * @see https://ariakit.org/components/combobox
6
+ * @example
7
+ * ```jsx
8
+ * const store = useComboboxStore();
9
+ * const props = useComboboxLabel({ store });
10
+ * <Role {...props}>Favorite fruit</Role>
11
+ * <Combobox store={store} />
12
+ * ```
13
+ */
14
+ export declare const useComboboxLabel: import("../utils/types.js").Hook<ComboboxLabelOptions<"label">>;
15
+ /**
16
+ * Renders a label for the [`Combobox`](https://ariakit.org/reference/combobox)
17
+ * component.
18
+ * @see https://ariakit.org/components/combobox
19
+ * @example
20
+ * ```jsx {2}
21
+ * <ComboboxProvider>
22
+ * <ComboboxLabel>Favorite fruit</ComboboxLabel>
23
+ * <Combobox />
24
+ * <ComboboxPopover>
25
+ * <ComboboxItem value="Apple" />
26
+ * <ComboboxItem value="Orange" />
27
+ * </ComboboxPopover>
28
+ * </ComboboxProvider>
29
+ * ```
30
+ */
31
+ export declare const ComboboxLabel: import("../utils/types.js").Component<ComboboxLabelOptions<"label">>;
32
+ export interface ComboboxLabelOptions<T extends As = "label"> extends Options<T> {
33
+ /**
34
+ * Object returned by the
35
+ * [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
36
+ * hook. If not provided, the closest
37
+ * [`ComboboxProvider`](https://ariakit.org/reference/combobox-provider)
38
+ * component's context will be used.
39
+ */
40
+ store?: ComboboxStore;
41
+ }
42
+ export type ComboboxLabelProps<T extends As = "label"> = Props<ComboboxLabelOptions<T>>;
@@ -0,0 +1,42 @@
1
+ import type { As, Options, Props } from "../utils/types.js";
2
+ import type { ComboboxStore } from "./combobox-store.js";
3
+ /**
4
+ * Returns props to create a `ComboboxLabel` component.
5
+ * @see https://ariakit.org/components/combobox
6
+ * @example
7
+ * ```jsx
8
+ * const store = useComboboxStore();
9
+ * const props = useComboboxLabel({ store });
10
+ * <Role {...props}>Favorite fruit</Role>
11
+ * <Combobox store={store} />
12
+ * ```
13
+ */
14
+ export declare const useComboboxLabel: import("../utils/types.js").Hook<ComboboxLabelOptions<"label">>;
15
+ /**
16
+ * Renders a label for the [`Combobox`](https://ariakit.org/reference/combobox)
17
+ * component.
18
+ * @see https://ariakit.org/components/combobox
19
+ * @example
20
+ * ```jsx {2}
21
+ * <ComboboxProvider>
22
+ * <ComboboxLabel>Favorite fruit</ComboboxLabel>
23
+ * <Combobox />
24
+ * <ComboboxPopover>
25
+ * <ComboboxItem value="Apple" />
26
+ * <ComboboxItem value="Orange" />
27
+ * </ComboboxPopover>
28
+ * </ComboboxProvider>
29
+ * ```
30
+ */
31
+ export declare const ComboboxLabel: import("../utils/types.js").Component<ComboboxLabelOptions<"label">>;
32
+ export interface ComboboxLabelOptions<T extends As = "label"> extends Options<T> {
33
+ /**
34
+ * Object returned by the
35
+ * [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
36
+ * hook. If not provided, the closest
37
+ * [`ComboboxProvider`](https://ariakit.org/reference/combobox-provider)
38
+ * component's context will be used.
39
+ */
40
+ store?: ComboboxStore;
41
+ }
42
+ export type ComboboxLabelProps<T extends As = "label"> = Props<ComboboxLabelOptions<T>>;
@@ -2,8 +2,8 @@
2
2
 
3
3
 
4
4
 
5
- var _QU2266CJcjs = require('../__chunks/QU2266CJ.cjs');
6
- require('../__chunks/VEG6PRAG.cjs');
5
+ var _WH4I6OSNcjs = require('../__chunks/WH4I6OSN.cjs');
6
+ require('../__chunks/3WCBE6SU.cjs');
7
7
  require('../__chunks/UZNYSPKP.cjs');
8
8
  require('../__chunks/BZTDJIVT.cjs');
9
9
  require('../__chunks/7BSMGTGR.cjs');
@@ -20,4 +20,4 @@ require('../__chunks/AV6KTKLE.cjs');
20
20
 
21
21
 
22
22
 
23
- exports.ComboboxList = _QU2266CJcjs.ComboboxList; exports.useComboboxList = _QU2266CJcjs.useComboboxList;
23
+ exports.ComboboxList = _WH4I6OSNcjs.ComboboxList; exports.useComboboxList = _WH4I6OSNcjs.useComboboxList;
@@ -1,15 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _QU2266CJcjs = require('../__chunks/QU2266CJ.cjs');
4
+ var _WH4I6OSNcjs = require('../__chunks/WH4I6OSN.cjs');
5
5
 
6
6
 
7
- var _VEG6PRAGcjs = require('../__chunks/VEG6PRAG.cjs');
7
+ var _3WCBE6SUcjs = require('../__chunks/3WCBE6SU.cjs');
8
8
  require('../__chunks/UZNYSPKP.cjs');
9
9
  require('../__chunks/BZTDJIVT.cjs');
10
10
 
11
11
 
12
- var _ISGOCBDCcjs = require('../__chunks/ISGOCBDC.cjs');
12
+ var _RIZYIKBEcjs = require('../__chunks/RIZYIKBE.cjs');
13
13
 
14
14
 
15
15
  var _XFPRAS3Jcjs = require('../__chunks/XFPRAS3J.cjs');
@@ -84,15 +84,15 @@ var useComboboxPopover = _RNZNGEL4cjs.createHook.call(void 0,
84
84
  "alwaysVisible",
85
85
  "hideOnInteractOutside"
86
86
  ]);
87
- const context = _VEG6PRAGcjs.useComboboxProviderContext.call(void 0, );
87
+ const context = _3WCBE6SUcjs.useComboboxProviderContext.call(void 0, );
88
88
  store = store || context;
89
89
  _misc.invariant.call(void 0,
90
90
  store,
91
91
  process.env.NODE_ENV !== "production" && "ComboboxPopover must receive a `store` prop or be wrapped in a ComboboxProvider component."
92
92
  );
93
93
  const baseElement = store.useState("baseElement");
94
- props = _QU2266CJcjs.useComboboxList.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
95
- props = _ISGOCBDCcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
94
+ props = _WH4I6OSNcjs.useComboboxList.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
95
+ props = _RIZYIKBEcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
96
96
  store,
97
97
  alwaysVisible,
98
98
  autoFocusOnShow: false,
@@ -126,7 +126,7 @@ var ComboboxPopover = _XFPRAS3Jcjs.createDialogComponent.call(void 0,
126
126
  const htmlProps = useComboboxPopover(props);
127
127
  return _RNZNGEL4cjs.createElement.call(void 0, "div", htmlProps);
128
128
  }),
129
- _VEG6PRAGcjs.useComboboxProviderContext
129
+ _3WCBE6SUcjs.useComboboxProviderContext
130
130
  );
131
131
  if (process.env.NODE_ENV !== "production") {
132
132
  ComboboxPopover.displayName = "ComboboxPopover";
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _AYDXWQBFcjs = require('../__chunks/AYDXWQBF.cjs');
4
+ var _L3WS5HGIcjs = require('../__chunks/L3WS5HGI.cjs');
5
5
 
6
6
 
7
- var _VEG6PRAGcjs = require('../__chunks/VEG6PRAG.cjs');
7
+ var _3WCBE6SUcjs = require('../__chunks/3WCBE6SU.cjs');
8
8
  require('../__chunks/A5RWZSX7.cjs');
9
9
  require('../__chunks/TUVU5ERH.cjs');
10
10
  require('../__chunks/UZNYSPKP.cjs');
@@ -24,8 +24,8 @@ require('../__chunks/AV6KTKLE.cjs');
24
24
  // src/combobox/combobox-provider.tsx
25
25
  var _jsxruntime = require('react/jsx-runtime');
26
26
  function ComboboxProvider(props = {}) {
27
- const store = _AYDXWQBFcjs.useComboboxStore.call(void 0, props);
28
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VEG6PRAGcjs.ComboboxContextProvider, { value: store, children: props.children });
27
+ const store = _L3WS5HGIcjs.useComboboxStore.call(void 0, props);
28
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _3WCBE6SUcjs.ComboboxContextProvider, { value: store, children: props.children });
29
29
  }
30
30
 
31
31
 
@@ -1,5 +1,7 @@
1
- import type { ReactNode } from "react";
2
- import type { ComboboxStoreProps } from "./combobox-store.js";
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { PickRequired } from "@ariakit/core/utils/types";
3
+ import type { ComboboxStoreProps, ComboboxStoreSelectedValue } from "./combobox-store.js";
4
+ type Value = ComboboxStoreSelectedValue;
3
5
  /**
4
6
  * Provides a combobox store to Combobox components.
5
7
  * @see https://ariakit.org/components/combobox
@@ -15,7 +17,9 @@ import type { ComboboxStoreProps } from "./combobox-store.js";
15
17
  * </ComboboxProvider>
16
18
  * ```
17
19
  */
18
- export declare function ComboboxProvider(props?: ComboboxProviderProps): import("react/jsx-runtime").JSX.Element;
19
- export interface ComboboxProviderProps extends ComboboxStoreProps {
20
+ export declare function ComboboxProvider<T extends Value = Value>(props: PickRequired<ComboboxProviderProps<T>, "selectedValue" | "defaultSelectedValue">): ReactElement;
21
+ export declare function ComboboxProvider(props?: ComboboxProviderProps): ReactElement;
22
+ export interface ComboboxProviderProps<T extends Value = Value> extends ComboboxStoreProps<T> {
20
23
  children?: ReactNode;
21
24
  }
25
+ export {};
@@ -1,5 +1,7 @@
1
- import type { ReactNode } from "react";
2
- import type { ComboboxStoreProps } from "./combobox-store.js";
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { PickRequired } from "@ariakit/core/utils/types";
3
+ import type { ComboboxStoreProps, ComboboxStoreSelectedValue } from "./combobox-store.js";
4
+ type Value = ComboboxStoreSelectedValue;
3
5
  /**
4
6
  * Provides a combobox store to Combobox components.
5
7
  * @see https://ariakit.org/components/combobox
@@ -15,7 +17,9 @@ import type { ComboboxStoreProps } from "./combobox-store.js";
15
17
  * </ComboboxProvider>
16
18
  * ```
17
19
  */
18
- export declare function ComboboxProvider(props?: ComboboxProviderProps): import("react/jsx-runtime").JSX.Element;
19
- export interface ComboboxProviderProps extends ComboboxStoreProps {
20
+ export declare function ComboboxProvider<T extends Value = Value>(props: PickRequired<ComboboxProviderProps<T>, "selectedValue" | "defaultSelectedValue">): ReactElement;
21
+ export declare function ComboboxProvider(props?: ComboboxProviderProps): ReactElement;
22
+ export interface ComboboxProviderProps<T extends Value = Value> extends ComboboxStoreProps<T> {
20
23
  children?: ReactNode;
21
24
  }
25
+ export {};
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _VEG6PRAGcjs = require('../__chunks/VEG6PRAG.cjs');
4
+ var _3WCBE6SUcjs = require('../__chunks/3WCBE6SU.cjs');
5
5
 
6
6
 
7
7
  var _GJX4AG2Lcjs = require('../__chunks/GJX4AG2L.cjs');
@@ -28,7 +28,7 @@ var _misc = require('@ariakit/core/utils/misc');
28
28
  var useComboboxRow = _RNZNGEL4cjs.createHook.call(void 0,
29
29
  (_a) => {
30
30
  var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
31
- const context = _VEG6PRAGcjs.useComboboxScopedContext.call(void 0, );
31
+ const context = _3WCBE6SUcjs.useComboboxScopedContext.call(void 0, );
32
32
  store = store || context;
33
33
  _misc.invariant.call(void 0,
34
34
  store,
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _VEG6PRAGcjs = require('../__chunks/VEG6PRAG.cjs');
4
+ var _3WCBE6SUcjs = require('../__chunks/3WCBE6SU.cjs');
5
5
 
6
6
 
7
7
  var _F34KLJKGcjs = require('../__chunks/F34KLJKG.cjs');
@@ -28,7 +28,7 @@ var _misc = require('@ariakit/core/utils/misc');
28
28
  var useComboboxSeparator = _RNZNGEL4cjs.createHook.call(void 0,
29
29
  (_a) => {
30
30
  var _b = _a, { store } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, ["store"]);
31
- const context = _VEG6PRAGcjs.useComboboxScopedContext.call(void 0, );
31
+ const context = _3WCBE6SUcjs.useComboboxScopedContext.call(void 0, );
32
32
  store = store || context;
33
33
  _misc.invariant.call(void 0,
34
34
  store,
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _AYDXWQBFcjs = require('../__chunks/AYDXWQBF.cjs');
5
+ var _L3WS5HGIcjs = require('../__chunks/L3WS5HGI.cjs');
6
6
  require('../__chunks/A5RWZSX7.cjs');
7
7
  require('../__chunks/TUVU5ERH.cjs');
8
8
  require('../__chunks/65GJIQK5.cjs');
@@ -15,4 +15,4 @@ require('../__chunks/AV6KTKLE.cjs');
15
15
 
16
16
 
17
17
 
18
- exports.useComboboxStore = _AYDXWQBFcjs.useComboboxStore; exports.useComboboxStoreProps = _AYDXWQBFcjs.useComboboxStoreProps;
18
+ exports.useComboboxStore = _L3WS5HGIcjs.useComboboxStore; exports.useComboboxStoreProps = _L3WS5HGIcjs.useComboboxStoreProps;
@@ -1,7 +1,9 @@
1
1
  import * as Core from "@ariakit/core/combobox/combobox-store";
2
+ import type { PickRequired } from "@ariakit/core/utils/types";
2
3
  import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
4
  import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
4
5
  import type { Store } from "../utils/store.js";
6
+ type Value = Core.ComboboxStoreSelectedValue;
5
7
  export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(store: T, update: () => void, props: ComboboxStoreProps): T;
6
8
  /**
7
9
  * Creates a combobox store.
@@ -17,27 +19,44 @@ export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(stor
17
19
  * </ComboboxPopover>
18
20
  * ```
19
21
  */
22
+ export declare function useComboboxStore<T extends Value = Value>(props: PickRequired<ComboboxStoreProps<T>, "selectedValue" | "defaultSelectedValue">): ComboboxStore<T>;
20
23
  export declare function useComboboxStore(props?: ComboboxStoreProps): ComboboxStore;
21
24
  export type ComboboxStoreItem = Core.ComboboxStoreItem;
22
- export interface ComboboxStoreState extends Core.ComboboxStoreState, CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
25
+ export type ComboboxStoreSelectedValue = Core.ComboboxStoreSelectedValue;
26
+ export interface ComboboxStoreState<T extends Value = Value> extends Core.ComboboxStoreState<T>, CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
23
27
  }
24
- export interface ComboboxStoreFunctions extends Core.ComboboxStoreFunctions, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
28
+ export interface ComboboxStoreFunctions<T extends Value = Value> extends Core.ComboboxStoreFunctions<T>, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
25
29
  }
26
- export interface ComboboxStoreOptions extends Core.ComboboxStoreOptions, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
30
+ export interface ComboboxStoreOptions<T extends Value = Value> extends Core.ComboboxStoreOptions<T>, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
27
31
  /**
28
- * A callback that gets called when the `value` state changes.
32
+ * A callback that gets called when the
33
+ * [`value`](https://ariakit.org/reference/combobox-provider#value) state
34
+ * changes.
29
35
  *
30
36
  * Live examples:
31
- * - [Combobox filtering](https://ariakit.org/examples/combobox-filtering)
37
+ * - [Combobox with integrated
38
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
32
39
  * - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
33
40
  * - [Combobox with links](https://ariakit.org/examples/combobox-links)
34
41
  * - [Multi-selectable
35
42
  * Combobox](https://ariakit.org/examples/combobox-multiple)
36
43
  * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
37
44
  * - [Select with Combobox](https://ariakit.org/examples/select-combobox)
38
- * @param value The new value.
39
45
  */
40
- setValue?: (value: ComboboxStoreState["value"]) => void;
46
+ setValue?: (value: ComboboxStoreState<T>["value"]) => void;
47
+ /**
48
+ * A callback that gets called when the
49
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
50
+ * state changes.
51
+ *
52
+ * Live examples:
53
+ * - [Multi-selectable
54
+ * Combobox](https://ariakit.org/examples/combobox-multiple)
55
+ */
56
+ setSelectedValue?: (value: ComboboxStoreState<T>["selectedValue"]) => void;
57
+ }
58
+ export interface ComboboxStoreProps<T extends Value = Value> extends ComboboxStoreOptions<T>, Core.ComboboxStoreProps<T> {
59
+ }
60
+ export interface ComboboxStore<T extends Value = Value> extends ComboboxStoreFunctions<T>, Store<Core.ComboboxStore<T>> {
41
61
  }
42
- export type ComboboxStoreProps = ComboboxStoreOptions & Core.ComboboxStoreProps;
43
- export type ComboboxStore = ComboboxStoreFunctions & Store<Core.ComboboxStore>;
62
+ export {};