@ariakit/core 0.4.4 → 0.4.6

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 (128) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/__chunks/{Y7KNI5NS.cjs → 3HYNC3XA.cjs} +5 -5
  3. package/cjs/__chunks/{FFZYCAXA.cjs → 4W3OYRR3.cjs} +2 -2
  4. package/cjs/__chunks/{SU2BSHGB.cjs → B4AKUC4S.cjs} +2 -2
  5. package/cjs/__chunks/{7DU6YMLQ.cjs → D7M2PCAQ.cjs} +6 -6
  6. package/cjs/__chunks/LPDHSEHU.cjs +71 -0
  7. package/cjs/__chunks/{UKR6TQI3.cjs → Q2WCPTYS.cjs} +37 -39
  8. package/cjs/checkbox/checkbox-store.d.cts +2 -2
  9. package/cjs/checkbox/checkbox-store.d.ts +2 -2
  10. package/cjs/collection/collection-store.cjs +3 -3
  11. package/cjs/collection/collection-store.d.cts +2 -2
  12. package/cjs/collection/collection-store.d.ts +2 -2
  13. package/cjs/combobox/combobox-store.cjs +50 -22
  14. package/cjs/combobox/combobox-store.d.cts +20 -9
  15. package/cjs/combobox/combobox-store.d.ts +20 -9
  16. package/cjs/composite/composite-overflow-store.d.cts +2 -2
  17. package/cjs/composite/composite-overflow-store.d.ts +2 -2
  18. package/cjs/composite/composite-store.cjs +5 -5
  19. package/cjs/composite/composite-store.d.cts +3 -3
  20. package/cjs/composite/composite-store.d.ts +3 -3
  21. package/cjs/dialog/dialog-store.d.cts +2 -2
  22. package/cjs/dialog/dialog-store.d.ts +2 -2
  23. package/cjs/disclosure/disclosure-store.d.cts +2 -2
  24. package/cjs/disclosure/disclosure-store.d.ts +2 -2
  25. package/cjs/form/form-store.cjs +3 -3
  26. package/cjs/form/form-store.d.cts +4 -4
  27. package/cjs/form/form-store.d.ts +4 -4
  28. package/cjs/form/types.d.cts +3 -3
  29. package/cjs/form/types.d.ts +3 -3
  30. package/cjs/hovercard/hovercard-store.d.cts +3 -3
  31. package/cjs/hovercard/hovercard-store.d.ts +3 -3
  32. package/cjs/menu/menu-bar-store.cjs +6 -6
  33. package/cjs/menu/menu-bar-store.d.cts +2 -2
  34. package/cjs/menu/menu-bar-store.d.ts +2 -2
  35. package/cjs/menu/menu-store.cjs +7 -7
  36. package/cjs/menu/menu-store.d.cts +6 -6
  37. package/cjs/menu/menu-store.d.ts +6 -6
  38. package/cjs/menubar/menubar-store.cjs +6 -6
  39. package/cjs/menubar/menubar-store.d.cts +2 -2
  40. package/cjs/menubar/menubar-store.d.ts +2 -2
  41. package/cjs/popover/popover-store.d.cts +3 -3
  42. package/cjs/popover/popover-store.d.ts +3 -3
  43. package/cjs/radio/radio-store.cjs +5 -5
  44. package/cjs/radio/radio-store.d.cts +3 -3
  45. package/cjs/radio/radio-store.d.ts +3 -3
  46. package/cjs/select/select-store.cjs +21 -11
  47. package/cjs/select/select-store.d.cts +17 -9
  48. package/cjs/select/select-store.d.ts +17 -9
  49. package/cjs/tab/tab-store.cjs +46 -13
  50. package/cjs/tab/tab-store.d.cts +7 -6
  51. package/cjs/tab/tab-store.d.ts +7 -6
  52. package/cjs/tag/tag-store.cjs +90 -0
  53. package/cjs/tag/tag-store.d.cts +80 -0
  54. package/cjs/tag/tag-store.d.ts +80 -0
  55. package/cjs/toolbar/toolbar-store.cjs +5 -5
  56. package/cjs/toolbar/toolbar-store.d.cts +2 -2
  57. package/cjs/toolbar/toolbar-store.d.ts +2 -2
  58. package/cjs/tooltip/tooltip-store.d.cts +2 -2
  59. package/cjs/tooltip/tooltip-store.d.ts +2 -2
  60. package/cjs/utils/dom.cjs +2 -2
  61. package/cjs/utils/dom.d.cts +15 -22
  62. package/cjs/utils/dom.d.ts +15 -22
  63. package/cjs/utils/events.cjs +32 -16
  64. package/cjs/utils/events.d.cts +7 -1
  65. package/cjs/utils/events.d.ts +7 -1
  66. package/cjs/utils/focus.cjs +13 -15
  67. package/cjs/utils/focus.d.cts +1 -1
  68. package/cjs/utils/focus.d.ts +1 -1
  69. package/cjs/utils/misc.d.cts +1 -1
  70. package/cjs/utils/misc.d.ts +1 -1
  71. package/cjs/utils/platform.cjs +3 -3
  72. package/cjs/utils/store.d.cts +3 -3
  73. package/cjs/utils/store.d.ts +3 -3
  74. package/cjs/utils/undo.cjs +10 -0
  75. package/cjs/utils/undo.d.cts +19 -0
  76. package/cjs/utils/undo.d.ts +19 -0
  77. package/esm/__chunks/{VDNATJW2.js → CLSHHUGK.js} +1 -1
  78. package/esm/__chunks/EKIWAN6A.js +71 -0
  79. package/esm/__chunks/{URUD7X4C.js → EQPTKGFA.js} +1 -1
  80. package/esm/__chunks/{RRSZHCH6.js → I2NJJ3XW.js} +39 -41
  81. package/esm/__chunks/{PXYVPXSS.js → P3MTNH46.js} +1 -1
  82. package/esm/__chunks/{2H5K47H4.js → PBSSD2DM.js} +5 -5
  83. package/esm/checkbox/checkbox-store.d.ts +2 -2
  84. package/esm/collection/collection-store.d.ts +2 -2
  85. package/esm/collection/collection-store.js +2 -2
  86. package/esm/combobox/combobox-store.d.ts +20 -9
  87. package/esm/combobox/combobox-store.js +52 -24
  88. package/esm/composite/composite-overflow-store.d.ts +2 -2
  89. package/esm/composite/composite-store.d.ts +3 -3
  90. package/esm/composite/composite-store.js +4 -4
  91. package/esm/dialog/dialog-store.d.ts +2 -2
  92. package/esm/disclosure/disclosure-store.d.ts +2 -2
  93. package/esm/form/form-store.d.ts +4 -4
  94. package/esm/form/form-store.js +2 -2
  95. package/esm/form/types.d.ts +3 -3
  96. package/esm/hovercard/hovercard-store.d.ts +3 -3
  97. package/esm/menu/menu-bar-store.d.ts +2 -2
  98. package/esm/menu/menu-bar-store.js +5 -5
  99. package/esm/menu/menu-store.d.ts +6 -6
  100. package/esm/menu/menu-store.js +6 -6
  101. package/esm/menubar/menubar-store.d.ts +2 -2
  102. package/esm/menubar/menubar-store.js +5 -5
  103. package/esm/popover/popover-store.d.ts +3 -3
  104. package/esm/radio/radio-store.d.ts +3 -3
  105. package/esm/radio/radio-store.js +4 -4
  106. package/esm/select/select-store.d.ts +17 -9
  107. package/esm/select/select-store.js +20 -10
  108. package/esm/tab/tab-store.d.ts +7 -6
  109. package/esm/tab/tab-store.js +44 -11
  110. package/esm/tag/tag-store.d.ts +80 -0
  111. package/esm/tag/tag-store.js +90 -0
  112. package/esm/toolbar/toolbar-store.d.ts +2 -2
  113. package/esm/toolbar/toolbar-store.js +4 -4
  114. package/esm/tooltip/tooltip-store.d.ts +2 -2
  115. package/esm/utils/dom.d.ts +15 -22
  116. package/esm/utils/dom.js +5 -5
  117. package/esm/utils/events.d.ts +7 -1
  118. package/esm/utils/events.js +28 -12
  119. package/esm/utils/focus.d.ts +1 -1
  120. package/esm/utils/focus.js +5 -7
  121. package/esm/utils/misc.d.ts +1 -1
  122. package/esm/utils/platform.js +2 -2
  123. package/esm/utils/store.d.ts +3 -3
  124. package/esm/utils/undo.d.ts +19 -0
  125. package/esm/utils/undo.js +10 -0
  126. package/package.json +15 -1
  127. package/tag/tag-store/package.json +8 -0
  128. package/utils/undo/package.json +8 -0
@@ -1,7 +1,8 @@
1
- import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
- import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
3
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
- import type { PickRequired, SetState } from "../utils/types.js";
1
+ import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.ts";
3
+ import type { TagStore } from "../tag/tag-store.ts";
4
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
5
+ import type { PickRequired, SetState } from "../utils/types.ts";
5
6
  type MutableValue<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> = T extends string ? string : T;
6
7
  /**
7
8
  * Creates a combobox store.
@@ -80,14 +81,14 @@ export interface ComboboxStoreState<T extends ComboboxStoreSelectedValue = Combo
80
81
  * or
81
82
  * [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
82
83
  * props are arrays.
83
- *
84
- * Live examples:
85
- * - [Multi-selectable
86
- * Combobox](https://ariakit.org/examples/combobox-multiple)
84
+ * @deprecated Use the
85
+ * [`resetValueOnSelect`](https://ariakit.org/reference/combobox-item#resetvalueonselect)
86
+ * prop on [`ComboboxItem`](https://ariakit.org/reference/combobox-item)
87
+ * instead.
87
88
  */
88
89
  resetValueOnSelect: boolean;
89
90
  }
90
- export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
91
+ export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Pick<ComboboxStoreOptions<T>, "tag">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
91
92
  /**
92
93
  * Sets the [`value`](https://ariakit.org/reference/combobox-provider#value)
93
94
  * state.
@@ -100,6 +101,11 @@ export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = C
100
101
  * store.setValue((value) => value + "!");
101
102
  */
102
103
  setValue: SetState<ComboboxStoreState<T>["value"]>;
104
+ /**
105
+ * Resets the [`value`](https://ariakit.org/reference/combobox-provider#value)
106
+ * state to its initial value.
107
+ */
108
+ resetValue: () => void;
103
109
  /**
104
110
  * Sets the
105
111
  * [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
@@ -124,6 +130,11 @@ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = Com
124
130
  * @default ""
125
131
  */
126
132
  defaultSelectedValue?: ComboboxStoreState<T>["selectedValue"];
133
+ /**
134
+ * A reference to a tag store. This is used when rendering a combobox within a
135
+ * tag list. The stores will share the same state.
136
+ */
137
+ tag?: TagStore | null;
127
138
  }
128
139
  export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, StoreProps<ComboboxStoreState<T>> {
129
140
  }
@@ -1,39 +1,50 @@
1
1
  "use client";
2
+ import {
3
+ createCompositeStore
4
+ } from "../__chunks/PBSSD2DM.js";
5
+ import "../__chunks/EQPTKGFA.js";
6
+ import "../__chunks/7PRQYBBV.js";
2
7
  import {
3
8
  createPopoverStore
4
9
  } from "../__chunks/MFZZDIHG.js";
5
10
  import "../__chunks/5RJNXXU2.js";
6
11
  import "../__chunks/WCKXDMU7.js";
7
- import {
8
- createCompositeStore
9
- } from "../__chunks/2H5K47H4.js";
10
- import "../__chunks/URUD7X4C.js";
11
12
  import {
12
13
  batch,
13
14
  createStore,
15
+ mergeStore,
16
+ pick,
14
17
  setup,
15
18
  sync,
16
19
  throwOnConflictingProps
17
20
  } from "../__chunks/R676XYVY.js";
18
21
  import {
22
+ chain,
19
23
  defaultValue
20
24
  } from "../__chunks/22HHDS5F.js";
21
25
  import {
22
- isSafari
23
- } from "../__chunks/VDNATJW2.js";
24
- import "../__chunks/RRSZHCH6.js";
25
- import "../__chunks/7PRQYBBV.js";
26
+ isSafari,
27
+ isTouchDevice
28
+ } from "../__chunks/CLSHHUGK.js";
29
+ import "../__chunks/I2NJJ3XW.js";
26
30
  import {
31
+ __objRest,
27
32
  __spreadProps,
28
33
  __spreadValues
29
34
  } from "../__chunks/4R3V3JGP.js";
30
35
 
31
36
  // src/combobox/combobox-store.ts
32
- var isSafariOnMobile = isSafari() && matchMedia("(hover:none)").matches;
33
- function createComboboxStore(props = {}) {
34
- var _a;
35
- throwOnConflictingProps(props, props.store);
36
- const syncState = (_a = props.store) == null ? void 0 : _a.getState();
37
+ var isTouchSafari = isSafari() && isTouchDevice();
38
+ function createComboboxStore(_a = {}) {
39
+ var _b = _a, {
40
+ tag
41
+ } = _b, props = __objRest(_b, [
42
+ "tag"
43
+ ]);
44
+ const store = mergeStore(props.store, pick(tag, ["value", "rtl"]));
45
+ throwOnConflictingProps(props, store);
46
+ const tagState = tag == null ? void 0 : tag.getState();
47
+ const syncState = store == null ? void 0 : store.getState();
37
48
  const activeId = defaultValue(
38
49
  props.activeId,
39
50
  syncState == null ? void 0 : syncState.activeId,
@@ -57,7 +68,7 @@ function createComboboxStore(props = {}) {
57
68
  virtualFocus: defaultValue(
58
69
  props.virtualFocus,
59
70
  syncState == null ? void 0 : syncState.virtualFocus,
60
- !isSafariOnMobile
71
+ true
61
72
  )
62
73
  }));
63
74
  const popover = createPopoverStore(__spreadProps(__spreadValues({}, props), {
@@ -76,6 +87,7 @@ function createComboboxStore(props = {}) {
76
87
  const selectedValue = defaultValue(
77
88
  props.selectedValue,
78
89
  syncState == null ? void 0 : syncState.selectedValue,
90
+ tagState == null ? void 0 : tagState.values,
79
91
  props.defaultSelectedValue,
80
92
  ""
81
93
  );
@@ -91,11 +103,33 @@ function createComboboxStore(props = {}) {
91
103
  resetValueOnHide: defaultValue(
92
104
  props.resetValueOnHide,
93
105
  syncState == null ? void 0 : syncState.resetValueOnHide,
94
- multiSelectable
106
+ multiSelectable && !tag
95
107
  ),
96
108
  activeValue: syncState == null ? void 0 : syncState.activeValue
97
109
  });
98
- const combobox = createStore(initialState, composite, popover, props.store);
110
+ const combobox = createStore(initialState, composite, popover, store);
111
+ if (isTouchSafari) {
112
+ setup(
113
+ combobox,
114
+ () => sync(combobox, ["virtualFocus"], () => {
115
+ combobox.setState("virtualFocus", false);
116
+ })
117
+ );
118
+ }
119
+ setup(combobox, () => {
120
+ if (!tag)
121
+ return;
122
+ return chain(
123
+ sync(combobox, ["selectedValue"], (state) => {
124
+ if (!Array.isArray(state.selectedValue))
125
+ return;
126
+ tag.setValues(state.selectedValue);
127
+ }),
128
+ sync(tag, ["values"], (state) => {
129
+ combobox.setState("selectedValue", state.values);
130
+ })
131
+ );
132
+ });
99
133
  setup(
100
134
  combobox,
101
135
  () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
@@ -106,14 +140,6 @@ function createComboboxStore(props = {}) {
106
140
  combobox.setState("value", value);
107
141
  })
108
142
  );
109
- setup(
110
- combobox,
111
- () => sync(combobox, ["resetValueOnSelect", "selectedValue"], (state) => {
112
- if (!state.resetValueOnSelect)
113
- return;
114
- combobox.setState("value", value);
115
- })
116
- );
117
143
  setup(
118
144
  combobox,
119
145
  () => batch(combobox, ["mounted"], (state) => {
@@ -142,7 +168,9 @@ function createComboboxStore(props = {}) {
142
168
  })
143
169
  );
144
170
  return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, popover), composite), combobox), {
171
+ tag,
145
172
  setValue: (value2) => combobox.setState("value", value2),
173
+ resetValue: () => combobox.setState("value", initialState.value),
146
174
  setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
147
175
  });
148
176
  }
@@ -1,5 +1,5 @@
1
- import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
2
- import type { Store, StoreProps } from "../utils/store.js";
1
+ import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.ts";
2
+ import type { Store, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a compositeOverflow store.
5
5
  */
@@ -1,6 +1,6 @@
1
- import type { CollectionStoreFunctions, CollectionStoreItem, CollectionStoreOptions, CollectionStoreState } from "../collection/collection-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
- import type { SetState } from "../utils/types.js";
1
+ import type { CollectionStoreFunctions, CollectionStoreItem, CollectionStoreOptions, CollectionStoreState } from "../collection/collection-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { SetState } from "../utils/types.ts";
4
4
  type Orientation = "horizontal" | "vertical" | "both";
5
5
  /**
6
6
  * Creates a composite store.
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import {
3
3
  createCompositeStore
4
- } from "../__chunks/2H5K47H4.js";
5
- import "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/PBSSD2DM.js";
5
+ import "../__chunks/EQPTKGFA.js";
6
+ import "../__chunks/7PRQYBBV.js";
6
7
  import "../__chunks/R676XYVY.js";
7
8
  import "../__chunks/22HHDS5F.js";
8
- import "../__chunks/RRSZHCH6.js";
9
- import "../__chunks/7PRQYBBV.js";
9
+ import "../__chunks/I2NJJ3XW.js";
10
10
  import "../__chunks/4R3V3JGP.js";
11
11
  export {
12
12
  createCompositeStore
@@ -1,5 +1,5 @@
1
- import type { DisclosureStoreFunctions, DisclosureStoreOptions, DisclosureStoreState } from "../disclosure/disclosure-store.js";
2
- import type { Store, StoreProps } from "../utils/store.js";
1
+ import type { DisclosureStoreFunctions, DisclosureStoreOptions, DisclosureStoreState } from "../disclosure/disclosure-store.ts";
2
+ import type { Store, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a dialog store.
5
5
  */
@@ -1,5 +1,5 @@
1
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
2
- import type { SetState } from "../utils/types.js";
1
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
2
+ import type { SetState } from "../utils/types.ts";
3
3
  /**
4
4
  * Creates a disclosure store.
5
5
  */
@@ -1,7 +1,7 @@
1
- import type { CollectionStoreFunctions, CollectionStoreItem, CollectionStoreOptions, CollectionStoreState } from "../collection/collection-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
- import type { AnyObject, PickRequired, SetState, SetStateAction } from "../utils/types.js";
4
- import type { DeepMap, DeepPartial, Names, StringLike } from "./types.js";
1
+ import type { CollectionStoreFunctions, CollectionStoreItem, CollectionStoreOptions, CollectionStoreState } from "../collection/collection-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { AnyObject, PickRequired, SetState, SetStateAction } from "../utils/types.ts";
4
+ import type { DeepMap, DeepPartial, Names, StringLike } from "./types.ts";
5
5
  type ErrorMessage = string | undefined | null;
6
6
  export declare function hasMessages(object: FormStoreValues): boolean;
7
7
  export declare function get<T>(values: FormStoreValues, path: StringLike | string[], defaultValue?: T): T;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createCollectionStore
4
- } from "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/EQPTKGFA.js";
5
5
  import {
6
6
  createStore,
7
7
  init,
@@ -14,7 +14,7 @@ import {
14
14
  isInteger,
15
15
  isObject
16
16
  } from "../__chunks/22HHDS5F.js";
17
- import "../__chunks/RRSZHCH6.js";
17
+ import "../__chunks/I2NJJ3XW.js";
18
18
  import {
19
19
  __spreadProps,
20
20
  __spreadValues
@@ -1,11 +1,11 @@
1
- import type { AnyObject } from "../utils/types.js";
1
+ import type { AnyObject } from "../utils/types.ts";
2
2
  /**
3
3
  * An object or primitive value that can be converted to a string.
4
4
  */
5
- export type StringLike = {
5
+ export interface StringLike {
6
6
  toString: () => string;
7
7
  valueOf: () => string;
8
- };
8
+ }
9
9
  /**
10
10
  * Maps through an object `T` or array and defines the leaf values to the given
11
11
  * type `V`.
@@ -1,6 +1,6 @@
1
- import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
- import type { SetState } from "../utils/types.js";
1
+ import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { SetState } from "../utils/types.ts";
4
4
  /**
5
5
  * Creates a hovercard store.
6
6
  */
@@ -1,5 +1,5 @@
1
- import type { MenubarStoreFunctions, MenubarStoreOptions, MenubarStoreState } from "../menubar/menubar-store.js";
2
- import type { Store, StoreProps } from "../utils/store.js";
1
+ import type { MenubarStoreFunctions, MenubarStoreOptions, MenubarStoreState } from "../menubar/menubar-store.ts";
2
+ import type { Store, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a menu bar store.
5
5
  */
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import {
3
3
  createMenubarStore
4
- } from "../__chunks/PXYVPXSS.js";
5
- import "../__chunks/2H5K47H4.js";
6
- import "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/P3MTNH46.js";
5
+ import "../__chunks/PBSSD2DM.js";
6
+ import "../__chunks/EQPTKGFA.js";
7
+ import "../__chunks/7PRQYBBV.js";
7
8
  import "../__chunks/R676XYVY.js";
8
9
  import "../__chunks/22HHDS5F.js";
9
- import "../__chunks/RRSZHCH6.js";
10
- import "../__chunks/7PRQYBBV.js";
10
+ import "../__chunks/I2NJJ3XW.js";
11
11
  import "../__chunks/4R3V3JGP.js";
12
12
 
13
13
  // src/menu/menu-bar-store.ts
@@ -1,9 +1,9 @@
1
- import type { ComboboxStore } from "../combobox/combobox-store.js";
2
- import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
- import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
4
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
5
- import type { BivariantCallback, PickRequired, SetState, SetStateAction } from "../utils/types.js";
6
- import type { MenuBarStore } from "./menu-bar-store.js";
1
+ import type { ComboboxStore } from "../combobox/combobox-store.ts";
2
+ import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
3
+ import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.ts";
4
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
5
+ import type { BivariantCallback, PickRequired, SetState, SetStateAction } from "../utils/types.ts";
6
+ import type { MenuBarStore } from "./menu-bar-store.ts";
7
7
  export declare function createMenuStore<T extends MenuStoreValues = MenuStoreValues>(props: PickRequired<MenuStoreProps<T>, "values" | "defaultValues">): MenuStore<T>;
8
8
  export declare function createMenuStore(props?: MenuStoreProps): MenuStore;
9
9
  export type MenuStoreValues = Record<string, string | boolean | number | Array<string | number>>;
@@ -2,13 +2,14 @@
2
2
  import {
3
3
  createHovercardStore
4
4
  } from "../__chunks/BRS7GKWU.js";
5
+ import {
6
+ createCompositeStore
7
+ } from "../__chunks/PBSSD2DM.js";
8
+ import "../__chunks/EQPTKGFA.js";
9
+ import "../__chunks/7PRQYBBV.js";
5
10
  import "../__chunks/MFZZDIHG.js";
6
11
  import "../__chunks/5RJNXXU2.js";
7
12
  import "../__chunks/WCKXDMU7.js";
8
- import {
9
- createCompositeStore
10
- } from "../__chunks/2H5K47H4.js";
11
- import "../__chunks/URUD7X4C.js";
12
13
  import {
13
14
  createStore,
14
15
  mergeStore,
@@ -22,8 +23,7 @@ import {
22
23
  applyState,
23
24
  defaultValue
24
25
  } from "../__chunks/22HHDS5F.js";
25
- import "../__chunks/RRSZHCH6.js";
26
- import "../__chunks/7PRQYBBV.js";
26
+ import "../__chunks/I2NJJ3XW.js";
27
27
  import {
28
28
  __objRest,
29
29
  __spreadProps,
@@ -1,5 +1,5 @@
1
- import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
- import type { Store, StoreProps } from "../utils/store.js";
1
+ import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { Store, StoreProps } from "../utils/store.ts";
3
3
  /**
4
4
  * Creates a menubar store.
5
5
  */
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import {
3
3
  createMenubarStore
4
- } from "../__chunks/PXYVPXSS.js";
5
- import "../__chunks/2H5K47H4.js";
6
- import "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/P3MTNH46.js";
5
+ import "../__chunks/PBSSD2DM.js";
6
+ import "../__chunks/EQPTKGFA.js";
7
+ import "../__chunks/7PRQYBBV.js";
7
8
  import "../__chunks/R676XYVY.js";
8
9
  import "../__chunks/22HHDS5F.js";
9
- import "../__chunks/RRSZHCH6.js";
10
- import "../__chunks/7PRQYBBV.js";
10
+ import "../__chunks/I2NJJ3XW.js";
11
11
  import "../__chunks/4R3V3JGP.js";
12
12
  export {
13
13
  createMenubarStore
@@ -1,6 +1,6 @@
1
- import type { DialogStoreFunctions, DialogStoreOptions, DialogStoreState } from "../dialog/dialog-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
- import type { SetState } from "../utils/types.js";
1
+ import type { DialogStoreFunctions, DialogStoreOptions, DialogStoreState } from "../dialog/dialog-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { SetState } from "../utils/types.ts";
4
4
  type BasePlacement = "top" | "bottom" | "left" | "right";
5
5
  type Placement = BasePlacement | `${BasePlacement}-start` | `${BasePlacement}-end`;
6
6
  /**
@@ -1,6 +1,6 @@
1
- import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
2
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
- import type { SetState } from "../utils/types.js";
1
+ import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
3
+ import type { SetState } from "../utils/types.ts";
4
4
  /**
5
5
  * Creates a radio store.
6
6
  */
@@ -1,16 +1,16 @@
1
1
  "use client";
2
2
  import {
3
3
  createCompositeStore
4
- } from "../__chunks/2H5K47H4.js";
5
- import "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/PBSSD2DM.js";
5
+ import "../__chunks/EQPTKGFA.js";
6
+ import "../__chunks/7PRQYBBV.js";
6
7
  import {
7
8
  createStore
8
9
  } from "../__chunks/R676XYVY.js";
9
10
  import {
10
11
  defaultValue
11
12
  } from "../__chunks/22HHDS5F.js";
12
- import "../__chunks/RRSZHCH6.js";
13
- import "../__chunks/7PRQYBBV.js";
13
+ import "../__chunks/I2NJJ3XW.js";
14
14
  import {
15
15
  __objRest,
16
16
  __spreadProps,
@@ -1,8 +1,8 @@
1
- import type { ComboboxStore } from "../combobox/combobox-store.js";
2
- import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
- import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
4
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
5
- import type { PickRequired, SetState } from "../utils/types.js";
1
+ import type { ComboboxStore } from "../combobox/combobox-store.ts";
2
+ import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
3
+ import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.ts";
4
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
5
+ import type { PickRequired, SetState } from "../utils/types.ts";
6
6
  type MutableValue<T extends SelectStoreValue = SelectStoreValue> = T extends string ? string : T;
7
7
  export declare function createSelectStore<T extends SelectStoreValue = SelectStoreValue>(props: PickRequired<SelectStoreProps<T>, "value" | "defaultValue">): SelectStore<T>;
8
8
  export declare function createSelectStore(props?: SelectStoreProps): SelectStore;
@@ -46,6 +46,10 @@ export interface SelectStoreState<T extends SelectStoreValue = SelectStoreValue>
46
46
  * @default false
47
47
  */
48
48
  setValueOnMove: boolean;
49
+ /**
50
+ * The select label element.
51
+ */
52
+ labelElement: HTMLElement | null;
49
53
  /**
50
54
  * The select button element.
51
55
  *
@@ -54,9 +58,9 @@ export interface SelectStoreState<T extends SelectStoreValue = SelectStoreValue>
54
58
  */
55
59
  selectElement: HTMLElement | null;
56
60
  /**
57
- * The select label element.
61
+ * The select list element.
58
62
  */
59
- labelElement: HTMLElement | null;
63
+ listElement: HTMLElement | null;
60
64
  }
61
65
  export interface SelectStoreFunctions<T extends SelectStoreValue = SelectStoreValue> extends Pick<SelectStoreOptions<T>, "combobox">, CompositeStoreFunctions<SelectStoreItem>, PopoverStoreFunctions {
62
66
  /**
@@ -68,14 +72,18 @@ export interface SelectStoreFunctions<T extends SelectStoreValue = SelectStoreVa
68
72
  * store.setValue((value) => value === "Apple" ? "Banana" : "Apple"));
69
73
  */
70
74
  setValue: SetState<SelectStoreState<T>["value"]>;
75
+ /**
76
+ * Sets the `labelElement` state.
77
+ */
78
+ setLabelElement: SetState<SelectStoreState<T>["labelElement"]>;
71
79
  /**
72
80
  * Sets the `selectElement` state.
73
81
  */
74
82
  setSelectElement: SetState<SelectStoreState<T>["selectElement"]>;
75
83
  /**
76
- * Sets the `labelElement` state.
84
+ * Sets the `listElement` state.
77
85
  */
78
- setLabelElement: SetState<SelectStoreState<T>["labelElement"]>;
86
+ setListElement: SetState<SelectStoreState<T>["listElement"]>;
79
87
  }
80
88
  export interface SelectStoreOptions<T extends SelectStoreValue = SelectStoreValue> extends StoreOptions<SelectStoreState<T>, "virtualFocus" | "activeId" | "orientation" | "placement" | "value" | "setValueOnMove">, CompositeStoreOptions<SelectStoreItem>, PopoverStoreOptions {
81
89
  /**
@@ -1,13 +1,16 @@
1
1
  "use client";
2
+ import {
3
+ createCompositeStore
4
+ } from "../__chunks/PBSSD2DM.js";
5
+ import "../__chunks/EQPTKGFA.js";
6
+ import {
7
+ toArray
8
+ } from "../__chunks/7PRQYBBV.js";
2
9
  import {
3
10
  createPopoverStore
4
11
  } from "../__chunks/MFZZDIHG.js";
5
12
  import "../__chunks/5RJNXXU2.js";
6
13
  import "../__chunks/WCKXDMU7.js";
7
- import {
8
- createCompositeStore
9
- } from "../__chunks/2H5K47H4.js";
10
- import "../__chunks/URUD7X4C.js";
11
14
  import {
12
15
  batch,
13
16
  createStore,
@@ -20,10 +23,7 @@ import {
20
23
  import {
21
24
  defaultValue
22
25
  } from "../__chunks/22HHDS5F.js";
23
- import "../__chunks/RRSZHCH6.js";
24
- import {
25
- toArray
26
- } from "../__chunks/7PRQYBBV.js";
26
+ import "../__chunks/I2NJJ3XW.js";
27
27
  import {
28
28
  __objRest,
29
29
  __spreadProps,
@@ -98,8 +98,9 @@ function createSelectStore(_a = {}) {
98
98
  syncState.setValueOnMove,
99
99
  false
100
100
  ),
101
+ labelElement: defaultValue(syncState.labelElement, null),
101
102
  selectElement: defaultValue(syncState.selectElement, null),
102
- labelElement: defaultValue(syncState.labelElement, null)
103
+ listElement: defaultValue(syncState.listElement, null)
103
104
  });
104
105
  const select = createStore(initialState, composite, popover, store);
105
106
  setup(
@@ -117,6 +118,14 @@ function createSelectStore(_a = {}) {
117
118
  select.setState("value", item.value);
118
119
  })
119
120
  );
121
+ setup(
122
+ select,
123
+ () => sync(select, ["mounted"], (state) => {
124
+ if (state.mounted)
125
+ return;
126
+ select.setState("activeId", initialState.activeId);
127
+ })
128
+ );
120
129
  setup(
121
130
  select,
122
131
  () => sync(select, ["mounted", "items", "value"], (state) => {
@@ -157,8 +166,9 @@ function createSelectStore(_a = {}) {
157
166
  return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, composite), popover), select), {
158
167
  combobox,
159
168
  setValue: (value) => select.setState("value", value),
169
+ setLabelElement: (element) => select.setState("labelElement", element),
160
170
  setSelectElement: (element) => select.setState("selectElement", element),
161
- setLabelElement: (element) => select.setState("labelElement", element)
171
+ setListElement: (element) => select.setState("listElement", element)
162
172
  });
163
173
  }
164
174
  export {
@@ -1,8 +1,9 @@
1
- import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
- import type { ComboboxStore } from "../combobox/combobox-store.js";
3
- import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
4
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
5
- import type { SetState } from "../utils/types.js";
1
+ import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.ts";
2
+ import type { ComboboxStore } from "../combobox/combobox-store.ts";
3
+ import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.ts";
4
+ import type { SelectStore } from "../select/select-store.ts";
5
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
6
+ import type { SetState } from "../utils/types.ts";
6
7
  export declare function createTabStore({ composite: parentComposite, combobox, ...props }?: TabStoreProps): TabStore;
7
8
  export interface TabStoreItem extends CompositeStoreItem {
8
9
  dimmed?: boolean;
@@ -85,7 +86,7 @@ export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientatio
85
86
  * [Select](https://ariakit.org/components/select). The stores will share the
86
87
  * same state.
87
88
  */
88
- composite?: CompositeStore | null;
89
+ composite?: CompositeStore | SelectStore | null;
89
90
  /**
90
91
  * A reference to a [combobox
91
92
  * store](https://ariakit.org/reference/use-combobox-store). This is used when