@ariakit/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 (113) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/cjs/__chunks/{GZDVJEID.cjs → 2LS4JJ4S.cjs} +2 -2
  3. package/cjs/__chunks/{46BH65MC.cjs → 2UK5WUJX.cjs} +15 -7
  4. package/cjs/__chunks/{GXIZMD53.cjs → 3J44Z7YH.cjs} +4 -4
  5. package/cjs/__chunks/{PD7XZBXC.cjs → 5SIVMOID.cjs} +4 -4
  6. package/cjs/__chunks/{7ZUFMSXJ.cjs → EFIT5L4X.cjs} +7 -7
  7. package/cjs/__chunks/{MEHGRTJ3.cjs → GJFZ5ZPP.cjs} +11 -11
  8. package/cjs/__chunks/{6WBY3ZZM.cjs → QAZ4PF7S.cjs} +6 -6
  9. package/cjs/__chunks/{JLC5A6WF.cjs → ZQTYFYRS.cjs} +18 -9
  10. package/cjs/checkbox/checkbox-store.cjs +3 -3
  11. package/cjs/checkbox/checkbox-store.d.cts +9 -9
  12. package/cjs/checkbox/checkbox-store.d.ts +9 -9
  13. package/cjs/collection/collection-store.cjs +3 -3
  14. package/cjs/collection/collection-store.d.cts +18 -12
  15. package/cjs/collection/collection-store.d.ts +18 -12
  16. package/cjs/combobox/combobox-store.cjs +45 -23
  17. package/cjs/combobox/combobox-store.d.cts +66 -23
  18. package/cjs/combobox/combobox-store.d.ts +66 -23
  19. package/cjs/composite/composite-overflow-store.cjs +5 -5
  20. package/cjs/composite/composite-overflow-store.d.cts +13 -7
  21. package/cjs/composite/composite-overflow-store.d.ts +13 -7
  22. package/cjs/composite/composite-store.cjs +4 -4
  23. package/cjs/composite/composite-store.d.cts +24 -16
  24. package/cjs/composite/composite-store.d.ts +24 -16
  25. package/cjs/dialog/dialog-store.cjs +4 -4
  26. package/cjs/dialog/dialog-store.d.cts +12 -6
  27. package/cjs/dialog/dialog-store.d.ts +12 -6
  28. package/cjs/disclosure/disclosure-store.cjs +3 -3
  29. package/cjs/disclosure/disclosure-store.d.cts +6 -2
  30. package/cjs/disclosure/disclosure-store.d.ts +6 -2
  31. package/cjs/form/form-store.cjs +7 -7
  32. package/cjs/form/form-store.d.cts +15 -15
  33. package/cjs/form/form-store.d.ts +15 -15
  34. package/cjs/hovercard/hovercard-store.cjs +6 -6
  35. package/cjs/hovercard/hovercard-store.d.cts +11 -3
  36. package/cjs/hovercard/hovercard-store.d.ts +11 -3
  37. package/cjs/menu/menu-bar-store.cjs +5 -5
  38. package/cjs/menu/menu-bar-store.d.cts +12 -6
  39. package/cjs/menu/menu-bar-store.d.ts +12 -6
  40. package/cjs/menu/menu-store.cjs +18 -18
  41. package/cjs/menu/menu-store.d.cts +8 -8
  42. package/cjs/menu/menu-store.d.ts +8 -8
  43. package/cjs/menubar/menubar-store.cjs +5 -5
  44. package/cjs/menubar/menubar-store.d.cts +1 -1
  45. package/cjs/menubar/menubar-store.d.ts +1 -1
  46. package/cjs/popover/popover-store.cjs +5 -5
  47. package/cjs/popover/popover-store.d.cts +8 -3
  48. package/cjs/popover/popover-store.d.ts +8 -3
  49. package/cjs/radio/radio-store.cjs +5 -5
  50. package/cjs/radio/radio-store.d.cts +5 -3
  51. package/cjs/radio/radio-store.d.ts +5 -3
  52. package/cjs/select/select-store.cjs +18 -18
  53. package/cjs/select/select-store.d.cts +39 -31
  54. package/cjs/select/select-store.d.ts +39 -31
  55. package/cjs/tab/tab-store.cjs +15 -15
  56. package/cjs/tab/tab-store.d.cts +15 -16
  57. package/cjs/tab/tab-store.d.ts +15 -16
  58. package/cjs/toolbar/toolbar-store.cjs +4 -4
  59. package/cjs/toolbar/toolbar-store.d.cts +9 -6
  60. package/cjs/toolbar/toolbar-store.d.ts +9 -6
  61. package/cjs/tooltip/tooltip-store.cjs +7 -7
  62. package/cjs/tooltip/tooltip-store.d.cts +5 -3
  63. package/cjs/tooltip/tooltip-store.d.ts +5 -3
  64. package/cjs/utils/store.cjs +2 -2
  65. package/cjs/utils/store.d.cts +3 -0
  66. package/cjs/utils/store.d.ts +3 -0
  67. package/esm/__chunks/{ANO6WJO4.js → A2AGSVJO.js} +2 -2
  68. package/esm/__chunks/{E7OQVGGY.js → A2J4XZ5T.js} +15 -7
  69. package/esm/__chunks/{OGMLJYDV.js → CTZ2GQIZ.js} +2 -2
  70. package/esm/__chunks/{CCU5UHQ2.js → HMQYEBKF.js} +15 -6
  71. package/esm/__chunks/{WY3EMTH6.js → J6JIOWCS.js} +2 -2
  72. package/esm/__chunks/{CL47ZAPY.js → LT2OYWRD.js} +1 -1
  73. package/esm/__chunks/{DYD4YNLE.js → NKLTHWCR.js} +1 -1
  74. package/esm/__chunks/{BXH3I7ML.js → T3DVYGXI.js} +2 -2
  75. package/esm/checkbox/checkbox-store.d.ts +9 -9
  76. package/esm/checkbox/checkbox-store.js +1 -1
  77. package/esm/collection/collection-store.d.ts +18 -12
  78. package/esm/collection/collection-store.js +2 -2
  79. package/esm/combobox/combobox-store.d.ts +66 -23
  80. package/esm/combobox/combobox-store.js +33 -11
  81. package/esm/composite/composite-overflow-store.d.ts +13 -7
  82. package/esm/composite/composite-overflow-store.js +4 -4
  83. package/esm/composite/composite-store.d.ts +24 -16
  84. package/esm/composite/composite-store.js +3 -3
  85. package/esm/dialog/dialog-store.d.ts +12 -6
  86. package/esm/dialog/dialog-store.js +3 -3
  87. package/esm/disclosure/disclosure-store.d.ts +6 -2
  88. package/esm/disclosure/disclosure-store.js +2 -2
  89. package/esm/form/form-store.d.ts +15 -15
  90. package/esm/form/form-store.js +2 -2
  91. package/esm/hovercard/hovercard-store.d.ts +11 -3
  92. package/esm/hovercard/hovercard-store.js +5 -5
  93. package/esm/menu/menu-bar-store.d.ts +12 -6
  94. package/esm/menu/menu-bar-store.js +4 -4
  95. package/esm/menu/menu-store.d.ts +8 -8
  96. package/esm/menu/menu-store.js +7 -7
  97. package/esm/menubar/menubar-store.d.ts +1 -1
  98. package/esm/menubar/menubar-store.js +4 -4
  99. package/esm/popover/popover-store.d.ts +8 -3
  100. package/esm/popover/popover-store.js +4 -4
  101. package/esm/radio/radio-store.d.ts +5 -3
  102. package/esm/radio/radio-store.js +3 -3
  103. package/esm/select/select-store.d.ts +39 -31
  104. package/esm/select/select-store.js +6 -6
  105. package/esm/tab/tab-store.d.ts +15 -16
  106. package/esm/tab/tab-store.js +3 -3
  107. package/esm/toolbar/toolbar-store.d.ts +9 -6
  108. package/esm/toolbar/toolbar-store.js +3 -3
  109. package/esm/tooltip/tooltip-store.d.ts +5 -3
  110. package/esm/tooltip/tooltip-store.js +5 -5
  111. package/esm/utils/store.d.ts +3 -0
  112. package/esm/utils/store.js +1 -1
  113. package/package.json +1 -1
@@ -1,20 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _7ZUFMSXJcjs = require('../__chunks/7ZUFMSXJ.cjs');
5
- require('../__chunks/GZDVJEID.cjs');
6
- require('../__chunks/MEHGRTJ3.cjs');
4
+ var _EFIT5L4Xcjs = require('../__chunks/EFIT5L4X.cjs');
5
+ require('../__chunks/2LS4JJ4S.cjs');
6
+ require('../__chunks/GJFZ5ZPP.cjs');
7
7
 
8
8
 
9
- var _6WBY3ZZMcjs = require('../__chunks/6WBY3ZZM.cjs');
10
- require('../__chunks/JLC5A6WF.cjs');
9
+ var _QAZ4PF7Scjs = require('../__chunks/QAZ4PF7S.cjs');
10
+ require('../__chunks/ZQTYFYRS.cjs');
11
11
 
12
12
 
13
13
 
14
14
 
15
15
 
16
16
 
17
- var _46BH65MCcjs = require('../__chunks/46BH65MC.cjs');
17
+ var _2UK5WUJXcjs = require('../__chunks/2UK5WUJX.cjs');
18
18
 
19
19
 
20
20
  var _3UT5FE6Kcjs = require('../__chunks/3UT5FE6K.cjs');
@@ -33,7 +33,7 @@ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
33
33
  var isSafariOnMobile = _YIUPKKEKcjs.isSafari.call(void 0, ) && _YIUPKKEKcjs.isTouchDevice.call(void 0, );
34
34
  function createComboboxStore(props = {}) {
35
35
  var _a;
36
- _46BH65MCcjs.throwOnConflictingProps.call(void 0, props, props.store);
36
+ _2UK5WUJXcjs.throwOnConflictingProps.call(void 0, props, props.store);
37
37
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
38
38
  const activeId = _3UT5FE6Kcjs.defaultValue.call(void 0,
39
39
  props.activeId,
@@ -41,7 +41,7 @@ function createComboboxStore(props = {}) {
41
41
  props.defaultActiveId,
42
42
  null
43
43
  );
44
- const composite = _6WBY3ZZMcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
44
+ const composite = _QAZ4PF7Scjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
45
45
  activeId,
46
46
  includesBaseElement: _3UT5FE6Kcjs.defaultValue.call(void 0,
47
47
  props.includesBaseElement,
@@ -61,59 +61,80 @@ function createComboboxStore(props = {}) {
61
61
  !isSafariOnMobile
62
62
  )
63
63
  }));
64
- const popover = _7ZUFMSXJcjs.createPopoverStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
64
+ const popover = _EFIT5L4Xcjs.createPopoverStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
65
65
  placement: _3UT5FE6Kcjs.defaultValue.call(void 0,
66
66
  props.placement,
67
67
  syncState == null ? void 0 : syncState.placement,
68
68
  "bottom-start"
69
69
  )
70
70
  }));
71
- const initialValue = _3UT5FE6Kcjs.defaultValue.call(void 0,
71
+ const value = _3UT5FE6Kcjs.defaultValue.call(void 0,
72
72
  props.value,
73
73
  syncState == null ? void 0 : syncState.value,
74
74
  props.defaultValue,
75
75
  ""
76
76
  );
77
+ const selectedValue = _3UT5FE6Kcjs.defaultValue.call(void 0,
78
+ props.selectedValue,
79
+ syncState == null ? void 0 : syncState.selectedValue,
80
+ props.defaultSelectedValue,
81
+ ""
82
+ );
83
+ const multiSelectable = Array.isArray(selectedValue);
77
84
  const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite.getState()), popover.getState()), {
78
- value: initialValue,
85
+ value,
86
+ selectedValue,
87
+ resetValueOnSelect: _3UT5FE6Kcjs.defaultValue.call(void 0,
88
+ props.resetValueOnSelect,
89
+ syncState == null ? void 0 : syncState.resetValueOnSelect,
90
+ multiSelectable
91
+ ),
79
92
  resetValueOnHide: _3UT5FE6Kcjs.defaultValue.call(void 0,
80
93
  props.resetValueOnHide,
81
94
  syncState == null ? void 0 : syncState.resetValueOnHide,
82
- false
95
+ multiSelectable
83
96
  ),
84
97
  activeValue: syncState == null ? void 0 : syncState.activeValue
85
98
  });
86
- const combobox = _46BH65MCcjs.createStore.call(void 0, initialState, composite, popover, props.store);
87
- _46BH65MCcjs.setup.call(void 0,
99
+ const combobox = _2UK5WUJXcjs.createStore.call(void 0, initialState, composite, popover, props.store);
100
+ _2UK5WUJXcjs.setup.call(void 0,
88
101
  combobox,
89
- () => _46BH65MCcjs.sync.call(void 0, combobox, ["resetValueOnHide", "mounted"], (state) => {
102
+ () => _2UK5WUJXcjs.sync.call(void 0, combobox, ["resetValueOnHide", "mounted"], (state) => {
90
103
  if (!state.resetValueOnHide)
91
104
  return;
92
105
  if (state.mounted)
93
106
  return;
94
- combobox.setState("value", initialValue);
107
+ combobox.setState("value", value);
108
+ })
109
+ );
110
+ _2UK5WUJXcjs.setup.call(void 0,
111
+ combobox,
112
+ () => _2UK5WUJXcjs.sync.call(void 0, combobox, ["resetValueOnSelect", "selectedValue"], (state) => {
113
+ if (!state.resetValueOnSelect)
114
+ return;
115
+ combobox.setState("value", value);
95
116
  })
96
117
  );
97
- _46BH65MCcjs.setup.call(void 0,
118
+ _2UK5WUJXcjs.setup.call(void 0,
98
119
  combobox,
99
- () => _46BH65MCcjs.batch.call(void 0, combobox, ["mounted"], (state) => {
120
+ () => _2UK5WUJXcjs.batch.call(void 0, combobox, ["mounted"], (state) => {
100
121
  if (state.mounted)
101
122
  return;
102
123
  combobox.setState("activeId", activeId);
103
124
  combobox.setState("moves", 0);
104
125
  })
105
126
  );
106
- _46BH65MCcjs.setup.call(void 0,
127
+ _2UK5WUJXcjs.setup.call(void 0,
107
128
  combobox,
108
- () => _46BH65MCcjs.sync.call(void 0, combobox, ["moves", "activeId"], (state, prevState) => {
129
+ () => _2UK5WUJXcjs.sync.call(void 0, combobox, ["moves", "activeId"], (state, prevState) => {
109
130
  if (state.moves === prevState.moves) {
110
131
  combobox.setState("activeValue", void 0);
111
132
  }
112
133
  })
113
134
  );
114
- _46BH65MCcjs.setup.call(void 0,
135
+ _2UK5WUJXcjs.setup.call(void 0,
115
136
  combobox,
116
- () => _46BH65MCcjs.batch.call(void 0, combobox, ["moves", "renderedItems"], (state, prev) => {
137
+ () => _2UK5WUJXcjs.batch.call(void 0, combobox, ["moves", "renderedItems"], (state, prev) => {
117
138
  if (state.moves === prev.moves)
118
139
  return;
119
140
  const { activeId: activeId2 } = combobox.getState();
@@ -122,7 +143,8 @@ function createComboboxStore(props = {}) {
122
143
  })
123
144
  );
124
145
  return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, popover), composite), combobox), {
125
- setValue: (value) => combobox.setState("value", value)
146
+ setValue: (value2) => combobox.setState("value", value2),
147
+ setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
126
148
  });
127
149
  }
128
150
 
@@ -1,22 +1,24 @@
1
1
  import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
2
  import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
3
3
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
- import type { SetState } from "../utils/types.js";
5
- type Item = CompositeStoreItem & {
6
- value?: string;
7
- };
4
+ import type { PickRequired, SetState } from "../utils/types.js";
5
+ type MutableValue<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> = T extends string ? string : T;
8
6
  /**
9
7
  * Creates a combobox store.
10
8
  */
9
+ export declare function createComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue>(props: PickRequired<ComboboxStoreProps<T>, "selectedValue" | "defaultSelectedValue">): ComboboxStore<T>;
11
10
  export declare function createComboboxStore(props?: ComboboxStoreProps): ComboboxStore;
12
- export type ComboboxStoreItem = Item;
13
- export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverStoreState {
11
+ export type ComboboxStoreSelectedValue = string | string[];
12
+ export interface ComboboxStoreItem extends CompositeStoreItem {
13
+ value?: string;
14
+ }
15
+ export interface ComboboxStoreState<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
14
16
  /**
15
17
  * @default true
16
18
  */
17
19
  includesBaseElement: boolean;
18
20
  /**
19
- * The input value.
21
+ * The combobox input value.
20
22
  *
21
23
  * Live examples:
22
24
  * - [Combobox with integrated
@@ -34,47 +36,88 @@ export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverSt
34
36
  */
35
37
  activeValue: string | undefined;
36
38
  /**
37
- * Whether to reset the value when the combobox popover is hidden.
39
+ * The value(s) of the currently selected item(s). This can be a string or an
40
+ * array of strings. If it's an array, the combobox is considered
41
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
42
+ *
43
+ * Live examples:
44
+ * - [Multi-selectable
45
+ * Combobox](https://ariakit.org/examples/combobox-multiple)
46
+ */
47
+ selectedValue: MutableValue<T>;
48
+ /**
49
+ * Whether to reset the value when the combobox popover closes. This prop is
50
+ * automatically set to `true` by default if the combobox supports multiple
51
+ * selections. In other words, if the
52
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
53
+ * or
54
+ * [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
55
+ * props are arrays.
38
56
  *
39
57
  * Live examples:
40
58
  * - [Multi-selectable
41
59
  * Combobox](https://ariakit.org/examples/combobox-multiple)
42
60
  * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
43
61
  * - [Select with Combobox](https://ariakit.org/examples/select-combobox)
44
- * @default false
45
62
  */
46
63
  resetValueOnHide: boolean;
47
- }
48
- export interface ComboboxStoreFunctions extends CompositeStoreFunctions<Item>, PopoverStoreFunctions {
49
64
  /**
50
- * Sets the `value` state.
65
+ * Whether to reset the value when an item is selected. This prop is
66
+ * automatically set to `true` by default if the combobox supports multiple
67
+ * selections. In other words, if the
68
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
69
+ * or
70
+ * [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
71
+ * props are arrays.
51
72
  *
52
73
  * Live examples:
53
74
  * - [Multi-selectable
54
75
  * Combobox](https://ariakit.org/examples/combobox-multiple)
76
+ */
77
+ resetValueOnSelect: boolean;
78
+ }
79
+ export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
80
+ /**
81
+ * Sets the [`value`](https://ariakit.org/reference/combobox-provider#value)
82
+ * state.
83
+ *
84
+ * Live examples:
55
85
  * - [Textarea with inline
56
86
  * Combobox](https://ariakit.org/examples/combobox-textarea)
57
87
  * @example
58
88
  * store.setValue("Hello world");
59
89
  * store.setValue((value) => value + "!");
60
90
  */
61
- setValue: SetState<ComboboxStoreState["value"]>;
91
+ setValue: SetState<ComboboxStoreState<T>["value"]>;
92
+ /**
93
+ * Sets the
94
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
95
+ * state.
96
+ */
97
+ setSelectedValue: SetState<ComboboxStoreState<T>["selectedValue"]>;
62
98
  }
63
- export interface ComboboxStoreOptions extends StoreOptions<ComboboxStoreState, "includesBaseElement" | "value" | "resetValueOnHide">, CompositeStoreOptions<Item>, PopoverStoreOptions {
99
+ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions, StoreOptions<ComboboxStoreState<T>, "includesBaseElement" | "value" | "selectedValue" | "resetValueOnHide" | "resetValueOnSelect"> {
64
100
  /**
65
101
  * @default null
66
102
  */
67
- defaultActiveId?: CompositeStoreOptions<Item>["activeId"];
103
+ defaultActiveId?: CompositeStoreOptions<ComboboxStoreItem>["activeId"];
68
104
  /**
69
- * The combobox initial value.
70
- *
71
- * Live examples:
72
- * - [Multi-selectable
73
- * Combobox](https://ariakit.org/examples/combobox-multiple)
105
+ * The initial value of the combobox input.
106
+ * @default ""
107
+ */
108
+ defaultValue?: ComboboxStoreState<T>["value"];
109
+ /**
110
+ * The initial value of the
111
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
112
+ * state. This can be a string or an array of strings. If it's an array, the
113
+ * combobox is considered
114
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
74
115
  * @default ""
75
116
  */
76
- defaultValue?: ComboboxStoreState["value"];
117
+ defaultSelectedValue?: ComboboxStoreState<T>["selectedValue"];
118
+ }
119
+ export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, StoreProps<ComboboxStoreState<T>> {
120
+ }
121
+ export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Store<ComboboxStoreState<T>> {
77
122
  }
78
- export type ComboboxStoreProps = ComboboxStoreOptions & StoreProps<ComboboxStoreState>;
79
- export type ComboboxStore = ComboboxStoreFunctions & Store<ComboboxStoreState>;
80
123
  export {};
@@ -1,22 +1,24 @@
1
1
  import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
2
  import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
3
3
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
- import type { SetState } from "../utils/types.js";
5
- type Item = CompositeStoreItem & {
6
- value?: string;
7
- };
4
+ import type { PickRequired, SetState } from "../utils/types.js";
5
+ type MutableValue<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> = T extends string ? string : T;
8
6
  /**
9
7
  * Creates a combobox store.
10
8
  */
9
+ export declare function createComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue>(props: PickRequired<ComboboxStoreProps<T>, "selectedValue" | "defaultSelectedValue">): ComboboxStore<T>;
11
10
  export declare function createComboboxStore(props?: ComboboxStoreProps): ComboboxStore;
12
- export type ComboboxStoreItem = Item;
13
- export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverStoreState {
11
+ export type ComboboxStoreSelectedValue = string | string[];
12
+ export interface ComboboxStoreItem extends CompositeStoreItem {
13
+ value?: string;
14
+ }
15
+ export interface ComboboxStoreState<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
14
16
  /**
15
17
  * @default true
16
18
  */
17
19
  includesBaseElement: boolean;
18
20
  /**
19
- * The input value.
21
+ * The combobox input value.
20
22
  *
21
23
  * Live examples:
22
24
  * - [Combobox with integrated
@@ -34,47 +36,88 @@ export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverSt
34
36
  */
35
37
  activeValue: string | undefined;
36
38
  /**
37
- * Whether to reset the value when the combobox popover is hidden.
39
+ * The value(s) of the currently selected item(s). This can be a string or an
40
+ * array of strings. If it's an array, the combobox is considered
41
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
42
+ *
43
+ * Live examples:
44
+ * - [Multi-selectable
45
+ * Combobox](https://ariakit.org/examples/combobox-multiple)
46
+ */
47
+ selectedValue: MutableValue<T>;
48
+ /**
49
+ * Whether to reset the value when the combobox popover closes. This prop is
50
+ * automatically set to `true` by default if the combobox supports multiple
51
+ * selections. In other words, if the
52
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
53
+ * or
54
+ * [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
55
+ * props are arrays.
38
56
  *
39
57
  * Live examples:
40
58
  * - [Multi-selectable
41
59
  * Combobox](https://ariakit.org/examples/combobox-multiple)
42
60
  * - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
43
61
  * - [Select with Combobox](https://ariakit.org/examples/select-combobox)
44
- * @default false
45
62
  */
46
63
  resetValueOnHide: boolean;
47
- }
48
- export interface ComboboxStoreFunctions extends CompositeStoreFunctions<Item>, PopoverStoreFunctions {
49
64
  /**
50
- * Sets the `value` state.
65
+ * Whether to reset the value when an item is selected. This prop is
66
+ * automatically set to `true` by default if the combobox supports multiple
67
+ * selections. In other words, if the
68
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
69
+ * or
70
+ * [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
71
+ * props are arrays.
51
72
  *
52
73
  * Live examples:
53
74
  * - [Multi-selectable
54
75
  * Combobox](https://ariakit.org/examples/combobox-multiple)
76
+ */
77
+ resetValueOnSelect: boolean;
78
+ }
79
+ export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
80
+ /**
81
+ * Sets the [`value`](https://ariakit.org/reference/combobox-provider#value)
82
+ * state.
83
+ *
84
+ * Live examples:
55
85
  * - [Textarea with inline
56
86
  * Combobox](https://ariakit.org/examples/combobox-textarea)
57
87
  * @example
58
88
  * store.setValue("Hello world");
59
89
  * store.setValue((value) => value + "!");
60
90
  */
61
- setValue: SetState<ComboboxStoreState["value"]>;
91
+ setValue: SetState<ComboboxStoreState<T>["value"]>;
92
+ /**
93
+ * Sets the
94
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
95
+ * state.
96
+ */
97
+ setSelectedValue: SetState<ComboboxStoreState<T>["selectedValue"]>;
62
98
  }
63
- export interface ComboboxStoreOptions extends StoreOptions<ComboboxStoreState, "includesBaseElement" | "value" | "resetValueOnHide">, CompositeStoreOptions<Item>, PopoverStoreOptions {
99
+ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions, StoreOptions<ComboboxStoreState<T>, "includesBaseElement" | "value" | "selectedValue" | "resetValueOnHide" | "resetValueOnSelect"> {
64
100
  /**
65
101
  * @default null
66
102
  */
67
- defaultActiveId?: CompositeStoreOptions<Item>["activeId"];
103
+ defaultActiveId?: CompositeStoreOptions<ComboboxStoreItem>["activeId"];
68
104
  /**
69
- * The combobox initial value.
70
- *
71
- * Live examples:
72
- * - [Multi-selectable
73
- * Combobox](https://ariakit.org/examples/combobox-multiple)
105
+ * The initial value of the combobox input.
106
+ * @default ""
107
+ */
108
+ defaultValue?: ComboboxStoreState<T>["value"];
109
+ /**
110
+ * The initial value of the
111
+ * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
112
+ * state. This can be a string or an array of strings. If it's an array, the
113
+ * combobox is considered
114
+ * [multi-selectable](https://ariakit.org/examples/combobox-multiple).
74
115
  * @default ""
75
116
  */
76
- defaultValue?: ComboboxStoreState["value"];
117
+ defaultSelectedValue?: ComboboxStoreState<T>["selectedValue"];
118
+ }
119
+ export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, StoreProps<ComboboxStoreState<T>> {
120
+ }
121
+ export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Store<ComboboxStoreState<T>> {
77
122
  }
78
- export type ComboboxStoreProps = ComboboxStoreOptions & StoreProps<ComboboxStoreState>;
79
- export type ComboboxStore = ComboboxStoreFunctions & Store<ComboboxStoreState>;
80
123
  export {};
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _7ZUFMSXJcjs = require('../__chunks/7ZUFMSXJ.cjs');
5
- require('../__chunks/GZDVJEID.cjs');
6
- require('../__chunks/MEHGRTJ3.cjs');
7
- require('../__chunks/46BH65MC.cjs');
4
+ var _EFIT5L4Xcjs = require('../__chunks/EFIT5L4X.cjs');
5
+ require('../__chunks/2LS4JJ4S.cjs');
6
+ require('../__chunks/GJFZ5ZPP.cjs');
7
+ require('../__chunks/2UK5WUJX.cjs');
8
8
  require('../__chunks/3UT5FE6K.cjs');
9
9
  require('../__chunks/AV6KTKLE.cjs');
10
10
 
11
11
  // src/composite/composite-overflow-store.ts
12
12
  function createCompositeOverflowStore(props = {}) {
13
- return _7ZUFMSXJcjs.createPopoverStore.call(void 0, props);
13
+ return _EFIT5L4Xcjs.createPopoverStore.call(void 0, props);
14
14
  }
15
15
 
16
16
 
@@ -1,10 +1,16 @@
1
- import type { PopoverStore, PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreProps, PopoverStoreState } from "../popover/popover-store.js";
1
+ import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
2
+ import type { Store, StoreProps } from "../utils/store.js";
2
3
  /**
3
- * Creates a composite overflow store.
4
+ * Creates a compositeOverflow store.
4
5
  */
5
6
  export declare function createCompositeOverflowStore(props?: CompositeOverflowStoreProps): CompositeOverflowStore;
6
- export type CompositeOverflowStoreState = PopoverStoreState;
7
- export type CompositeOverflowStoreFunctions = PopoverStoreFunctions;
8
- export type CompositeOverflowStoreOptions = PopoverStoreOptions;
9
- export type CompositeOverflowStoreProps = PopoverStoreProps;
10
- export type CompositeOverflowStore = PopoverStore;
7
+ export interface CompositeOverflowStoreState extends PopoverStoreState {
8
+ }
9
+ export interface CompositeOverflowStoreFunctions extends PopoverStoreFunctions {
10
+ }
11
+ export interface CompositeOverflowStoreOptions extends PopoverStoreOptions {
12
+ }
13
+ export interface CompositeOverflowStoreProps extends CompositeOverflowStoreOptions, StoreProps<CompositeOverflowStoreState> {
14
+ }
15
+ export interface CompositeOverflowStore extends CompositeOverflowStoreFunctions, Store<CompositeOverflowStoreState> {
16
+ }
@@ -1,10 +1,16 @@
1
- import type { PopoverStore, PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreProps, PopoverStoreState } from "../popover/popover-store.js";
1
+ import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
2
+ import type { Store, StoreProps } from "../utils/store.js";
2
3
  /**
3
- * Creates a composite overflow store.
4
+ * Creates a compositeOverflow store.
4
5
  */
5
6
  export declare function createCompositeOverflowStore(props?: CompositeOverflowStoreProps): CompositeOverflowStore;
6
- export type CompositeOverflowStoreState = PopoverStoreState;
7
- export type CompositeOverflowStoreFunctions = PopoverStoreFunctions;
8
- export type CompositeOverflowStoreOptions = PopoverStoreOptions;
9
- export type CompositeOverflowStoreProps = PopoverStoreProps;
10
- export type CompositeOverflowStore = PopoverStore;
7
+ export interface CompositeOverflowStoreState extends PopoverStoreState {
8
+ }
9
+ export interface CompositeOverflowStoreFunctions extends PopoverStoreFunctions {
10
+ }
11
+ export interface CompositeOverflowStoreOptions extends PopoverStoreOptions {
12
+ }
13
+ export interface CompositeOverflowStoreProps extends CompositeOverflowStoreOptions, StoreProps<CompositeOverflowStoreState> {
14
+ }
15
+ export interface CompositeOverflowStore extends CompositeOverflowStoreFunctions, Store<CompositeOverflowStoreState> {
16
+ }
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _6WBY3ZZMcjs = require('../__chunks/6WBY3ZZM.cjs');
5
- require('../__chunks/JLC5A6WF.cjs');
6
- require('../__chunks/46BH65MC.cjs');
4
+ var _QAZ4PF7Scjs = require('../__chunks/QAZ4PF7S.cjs');
5
+ require('../__chunks/ZQTYFYRS.cjs');
6
+ require('../__chunks/2UK5WUJX.cjs');
7
7
  require('../__chunks/3UT5FE6K.cjs');
8
8
  require('../__chunks/5F4DVUNS.cjs');
9
9
  require('../__chunks/ULSPM3Y3.cjs');
10
10
  require('../__chunks/AV6KTKLE.cjs');
11
11
 
12
12
 
13
- exports.createCompositeStore = _6WBY3ZZMcjs.createCompositeStore;
13
+ exports.createCompositeStore = _QAZ4PF7Scjs.createCompositeStore;
@@ -2,18 +2,28 @@ import type { CollectionStoreFunctions, CollectionStoreItem, CollectionStoreOpti
2
2
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
3
  import type { SetState } from "../utils/types.js";
4
4
  type Orientation = "horizontal" | "vertical" | "both";
5
- type Item = CollectionStoreItem & {
6
- rowId?: string;
7
- disabled?: boolean;
8
- children?: string;
9
- };
10
5
  /**
11
6
  * Creates a composite store.
12
7
  */
13
- export declare function createCompositeStore<T extends Item = Item>(props?: CompositeStoreProps<T>): CompositeStore<T>;
8
+ export declare function createCompositeStore<T extends CompositeStoreItem = CompositeStoreItem>(props?: CompositeStoreProps<T>): CompositeStore<T>;
14
9
  export type CompositeStoreOrientation = Orientation;
15
- export type CompositeStoreItem = Item;
16
- export interface CompositeStoreState<T extends Item = Item> extends CollectionStoreState<T> {
10
+ export interface CompositeStoreItem extends CollectionStoreItem {
11
+ /**
12
+ * The row id of the item. This is only used on two-dimensional composites
13
+ * (when using `CompositeRow`).
14
+ */
15
+ rowId?: string;
16
+ /**
17
+ * If enabled, the item will be disabled and users won't be able to focus it
18
+ * using arrow keys.
19
+ */
20
+ disabled?: boolean;
21
+ /**
22
+ * The item children. This can be used for typeahead purposes.
23
+ */
24
+ children?: string;
25
+ }
26
+ export interface CompositeStoreState<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreState<T> {
17
27
  /**
18
28
  * The composite element.
19
29
  */
@@ -25,10 +35,6 @@ export interface CompositeStoreState<T extends Item = Item> extends CollectionSt
25
35
  * tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex).
26
36
  * DOM focus will remain on the composite element while its items receive
27
37
  * virtual focus.
28
- *
29
- * Live examples:
30
- * - [Multi-selectable
31
- * Combobox](https://ariakit.org/examples/combobox-multiple)
32
38
  * @default false
33
39
  */
34
40
  virtualFocus: boolean;
@@ -121,7 +127,7 @@ export interface CompositeStoreState<T extends Item = Item> extends CollectionSt
121
127
  */
122
128
  activeId: string | null | undefined;
123
129
  }
124
- export interface CompositeStoreFunctions<T extends Item = Item> extends CollectionStoreFunctions<T> {
130
+ export interface CompositeStoreFunctions<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreFunctions<T> {
125
131
  /**
126
132
  * Sets the `baseElement`.
127
133
  */
@@ -192,7 +198,7 @@ export interface CompositeStoreFunctions<T extends Item = Item> extends Collecti
192
198
  */
193
199
  last: () => string | null | undefined;
194
200
  }
195
- export interface CompositeStoreOptions<T extends Item = Item> extends StoreOptions<CompositeStoreState<T>, "virtualFocus" | "orientation" | "rtl" | "focusLoop" | "focusWrap" | "focusShift" | "includesBaseElement" | "activeId">, CollectionStoreOptions<T> {
201
+ export interface CompositeStoreOptions<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreOptions<T>, StoreOptions<CompositeStoreState<T>, "virtualFocus" | "orientation" | "rtl" | "focusLoop" | "focusWrap" | "focusShift" | "includesBaseElement" | "activeId"> {
196
202
  /**
197
203
  * The composite item id that should be active by default when the composite
198
204
  * widget is rendered. If `null`, the composite element itself will have focus
@@ -201,6 +207,8 @@ export interface CompositeStoreOptions<T extends Item = Item> extends StoreOptio
201
207
  */
202
208
  defaultActiveId?: CompositeStoreState<T>["activeId"];
203
209
  }
204
- export type CompositeStoreProps<T extends Item = Item> = CompositeStoreOptions<T> & StoreProps<CompositeStoreState<T>>;
205
- export type CompositeStore<T extends Item = Item> = CompositeStoreFunctions<T> & Store<CompositeStoreState<T>>;
210
+ export interface CompositeStoreProps<T extends CompositeStoreItem = CompositeStoreItem> extends CompositeStoreOptions<T>, StoreProps<CompositeStoreState<T>> {
211
+ }
212
+ export interface CompositeStore<T extends CompositeStoreItem = CompositeStoreItem> extends CompositeStoreFunctions<T>, Store<CompositeStoreState<T>> {
213
+ }
206
214
  export {};