@ariakit/core 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/cjs/__chunks/{7DU6YMLQ.cjs → 2D5LEVE7.cjs} +6 -6
  3. package/cjs/__chunks/{UKR6TQI3.cjs → IMYW2UAC.cjs} +36 -20
  4. package/cjs/__chunks/{Y7KNI5NS.cjs → KL74MAHB.cjs} +5 -5
  5. package/cjs/__chunks/LPDHSEHU.cjs +71 -0
  6. package/cjs/__chunks/{SU2BSHGB.cjs → MHZQJPY3.cjs} +2 -2
  7. package/cjs/__chunks/{FFZYCAXA.cjs → QD2A4YF6.cjs} +2 -2
  8. package/cjs/collection/collection-store.cjs +3 -3
  9. package/cjs/combobox/combobox-store.cjs +40 -21
  10. package/cjs/combobox/combobox-store.d.cts +16 -5
  11. package/cjs/combobox/combobox-store.d.ts +16 -5
  12. package/cjs/composite/composite-store.cjs +5 -5
  13. package/cjs/form/form-store.cjs +3 -3
  14. package/cjs/menu/menu-bar-store.cjs +6 -6
  15. package/cjs/menu/menu-store.cjs +7 -7
  16. package/cjs/menubar/menubar-store.cjs +6 -6
  17. package/cjs/radio/radio-store.cjs +5 -5
  18. package/cjs/select/select-store.cjs +9 -9
  19. package/cjs/tab/tab-store.cjs +6 -6
  20. package/cjs/tag/tag-store.cjs +90 -0
  21. package/cjs/tag/tag-store.d.cts +80 -0
  22. package/cjs/tag/tag-store.d.ts +80 -0
  23. package/cjs/toolbar/toolbar-store.cjs +5 -5
  24. package/cjs/utils/dom.cjs +6 -2
  25. package/cjs/utils/dom.d.cts +14 -5
  26. package/cjs/utils/dom.d.ts +14 -5
  27. package/cjs/utils/events.cjs +17 -6
  28. package/cjs/utils/events.d.cts +6 -0
  29. package/cjs/utils/events.d.ts +6 -0
  30. package/cjs/utils/focus.cjs +13 -13
  31. package/cjs/utils/platform.cjs +3 -3
  32. package/cjs/utils/undo.cjs +10 -0
  33. package/cjs/utils/undo.d.cts +19 -0
  34. package/cjs/utils/undo.d.ts +19 -0
  35. package/esm/__chunks/{URUD7X4C.js → ABMC67JW.js} +1 -1
  36. package/esm/__chunks/EKIWAN6A.js +71 -0
  37. package/esm/__chunks/{RRSZHCH6.js → IUORCTET.js} +36 -20
  38. package/esm/__chunks/{PXYVPXSS.js → K7A7LTR3.js} +1 -1
  39. package/esm/__chunks/{VDNATJW2.js → QAI5BPCY.js} +1 -1
  40. package/esm/__chunks/{2H5K47H4.js → YVUNPQHS.js} +5 -5
  41. package/esm/collection/collection-store.js +2 -2
  42. package/esm/combobox/combobox-store.d.ts +16 -5
  43. package/esm/combobox/combobox-store.js +40 -21
  44. package/esm/composite/composite-store.js +4 -4
  45. package/esm/form/form-store.js +2 -2
  46. package/esm/menu/menu-bar-store.js +5 -5
  47. package/esm/menu/menu-store.js +6 -6
  48. package/esm/menubar/menubar-store.js +5 -5
  49. package/esm/radio/radio-store.js +4 -4
  50. package/esm/select/select-store.js +8 -8
  51. package/esm/tab/tab-store.js +4 -4
  52. package/esm/tag/tag-store.d.ts +80 -0
  53. package/esm/tag/tag-store.js +90 -0
  54. package/esm/toolbar/toolbar-store.js +4 -4
  55. package/esm/utils/dom.d.ts +14 -5
  56. package/esm/utils/dom.js +5 -1
  57. package/esm/utils/events.d.ts +6 -0
  58. package/esm/utils/events.js +13 -2
  59. package/esm/utils/focus.js +1 -1
  60. package/esm/utils/platform.js +2 -2
  61. package/esm/utils/undo.d.ts +19 -0
  62. package/esm/utils/undo.js +10 -0
  63. package/package.json +15 -1
  64. package/tag/tag-store/package.json +8 -0
  65. package/utils/undo/package.json +8 -0
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- var _UKR6TQI3cjs = require('../__chunks/UKR6TQI3.cjs');
9
+ var _IMYW2UACcjs = require('../__chunks/IMYW2UAC.cjs');
10
10
 
11
11
 
12
12
  var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
@@ -18,11 +18,11 @@ function hasNegativeTabIndex(element) {
18
18
  return tabIndex < 0;
19
19
  }
20
20
  function isFocusable(element) {
21
- if (!_UKR6TQI3cjs.matches.call(void 0, element, selector))
21
+ if (!_IMYW2UACcjs.matches.call(void 0, element, selector))
22
22
  return false;
23
- if (!_UKR6TQI3cjs.isVisible.call(void 0, element))
23
+ if (!_IMYW2UACcjs.isVisible.call(void 0, element))
24
24
  return false;
25
- if (_UKR6TQI3cjs.closest.call(void 0, element, "[inert]"))
25
+ if (_IMYW2UACcjs.closest.call(void 0, element, "[inert]"))
26
26
  return false;
27
27
  return true;
28
28
  }
@@ -44,7 +44,7 @@ function isTabbable(element) {
44
44
  return true;
45
45
  if (!("length" in radioGroup))
46
46
  return true;
47
- const activeElement = _UKR6TQI3cjs.getActiveElement.call(void 0, element);
47
+ const activeElement = _IMYW2UACcjs.getActiveElement.call(void 0, element);
48
48
  if (!activeElement)
49
49
  return true;
50
50
  if (activeElement === element)
@@ -66,7 +66,7 @@ function getAllFocusableIn(container, includeContainer) {
66
66
  }
67
67
  const focusableElements = elements.filter(isFocusable);
68
68
  focusableElements.forEach((element, i) => {
69
- if (_UKR6TQI3cjs.isFrame.call(void 0, element) && element.contentDocument) {
69
+ if (_IMYW2UACcjs.isFrame.call(void 0, element) && element.contentDocument) {
70
70
  const frameBody = element.contentDocument.body;
71
71
  focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody));
72
72
  }
@@ -92,7 +92,7 @@ function getAllTabbableIn(container, includeContainer, fallbackToFocusable) {
92
92
  tabbableElements.unshift(container);
93
93
  }
94
94
  tabbableElements.forEach((element, i) => {
95
- if (_UKR6TQI3cjs.isFrame.call(void 0, element) && element.contentDocument) {
95
+ if (_IMYW2UACcjs.isFrame.call(void 0, element) && element.contentDocument) {
96
96
  const frameBody = element.contentDocument.body;
97
97
  const allFrameTabbable = getAllTabbableIn(
98
98
  frameBody,
@@ -133,7 +133,7 @@ function getLastTabbable(fallbackToFocusable) {
133
133
  return getLastTabbableIn(document.body, false, fallbackToFocusable);
134
134
  }
135
135
  function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) {
136
- const activeElement = _UKR6TQI3cjs.getActiveElement.call(void 0, container);
136
+ const activeElement = _IMYW2UACcjs.getActiveElement.call(void 0, container);
137
137
  const allFocusable = getAllFocusableIn(container, includeContainer);
138
138
  const activeIndex = allFocusable.indexOf(activeElement);
139
139
  const nextFocusableElements = allFocusable.slice(activeIndex + 1);
@@ -148,7 +148,7 @@ function getNextTabbable(fallbackToFirst, fallbackToFocusable) {
148
148
  );
149
149
  }
150
150
  function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) {
151
- const activeElement = _UKR6TQI3cjs.getActiveElement.call(void 0, container);
151
+ const activeElement = _IMYW2UACcjs.getActiveElement.call(void 0, container);
152
152
  const allFocusable = getAllFocusableIn(container, includeContainer).reverse();
153
153
  const activeIndex = allFocusable.indexOf(activeElement);
154
154
  const previousFocusableElements = allFocusable.slice(activeIndex + 1);
@@ -164,12 +164,12 @@ function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) {
164
164
  }
165
165
  function getClosestFocusable(element) {
166
166
  while (element && !isFocusable(element)) {
167
- element = _UKR6TQI3cjs.closest.call(void 0, element, selector);
167
+ element = _IMYW2UACcjs.closest.call(void 0, element, selector);
168
168
  }
169
169
  return element || null;
170
170
  }
171
171
  function hasFocus(element) {
172
- const activeElement = _UKR6TQI3cjs.getActiveElement.call(void 0, element);
172
+ const activeElement = _IMYW2UACcjs.getActiveElement.call(void 0, element);
173
173
  if (!activeElement)
174
174
  return false;
175
175
  if (activeElement === element)
@@ -180,10 +180,10 @@ function hasFocus(element) {
180
180
  return activeDescendant === element.id;
181
181
  }
182
182
  function hasFocusWithin(element) {
183
- const activeElement = _UKR6TQI3cjs.getActiveElement.call(void 0, element);
183
+ const activeElement = _IMYW2UACcjs.getActiveElement.call(void 0, element);
184
184
  if (!activeElement)
185
185
  return false;
186
- if (_UKR6TQI3cjs.contains.call(void 0, element, activeElement))
186
+ if (_IMYW2UACcjs.contains.call(void 0, element, activeElement))
187
187
  return true;
188
188
  const activeDescendant = activeElement.getAttribute("aria-activedescendant");
189
189
  if (!activeDescendant)
@@ -5,8 +5,8 @@
5
5
 
6
6
 
7
7
 
8
- var _7DU6YMLQcjs = require('../__chunks/7DU6YMLQ.cjs');
9
- require('../__chunks/UKR6TQI3.cjs');
8
+ var _2D5LEVE7cjs = require('../__chunks/2D5LEVE7.cjs');
9
+ require('../__chunks/IMYW2UAC.cjs');
10
10
  require('../__chunks/AV6KTKLE.cjs');
11
11
 
12
12
 
@@ -14,4 +14,4 @@ require('../__chunks/AV6KTKLE.cjs');
14
14
 
15
15
 
16
16
 
17
- exports.isApple = _7DU6YMLQcjs.isApple; exports.isFirefox = _7DU6YMLQcjs.isFirefox; exports.isMac = _7DU6YMLQcjs.isMac; exports.isSafari = _7DU6YMLQcjs.isSafari; exports.isTouchDevice = _7DU6YMLQcjs.isTouchDevice;
17
+ exports.isApple = _2D5LEVE7cjs.isApple; exports.isFirefox = _2D5LEVE7cjs.isFirefox; exports.isMac = _2D5LEVE7cjs.isMac; exports.isSafari = _2D5LEVE7cjs.isSafari; exports.isTouchDevice = _2D5LEVE7cjs.isTouchDevice;
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+
5
+ var _LPDHSEHUcjs = require('../__chunks/LPDHSEHU.cjs');
6
+ require('../__chunks/AV6KTKLE.cjs');
7
+
8
+
9
+
10
+ exports.UndoManager = _LPDHSEHUcjs.UndoManager; exports.createUndoManager = _LPDHSEHUcjs.createUndoManager;
@@ -0,0 +1,19 @@
1
+ type Callback = void | (() => Callback | Promise<Callback>);
2
+ interface CreateUndoManagerOptions {
3
+ limit?: number;
4
+ }
5
+ export declare const UndoManager: {
6
+ canUndo: () => boolean;
7
+ canRedo: () => boolean;
8
+ undo: () => Promise<void>;
9
+ redo: () => Promise<void>;
10
+ execute: (callback: Callback, group?: string) => Promise<void>;
11
+ };
12
+ export declare function createUndoManager({ limit, }?: CreateUndoManagerOptions): {
13
+ canUndo: () => boolean;
14
+ canRedo: () => boolean;
15
+ undo: () => Promise<void>;
16
+ redo: () => Promise<void>;
17
+ execute: (callback: Callback, group?: string) => Promise<void>;
18
+ };
19
+ export {};
@@ -0,0 +1,19 @@
1
+ type Callback = void | (() => Callback | Promise<Callback>);
2
+ interface CreateUndoManagerOptions {
3
+ limit?: number;
4
+ }
5
+ export declare const UndoManager: {
6
+ canUndo: () => boolean;
7
+ canRedo: () => boolean;
8
+ undo: () => Promise<void>;
9
+ redo: () => Promise<void>;
10
+ execute: (callback: Callback, group?: string) => Promise<void>;
11
+ };
12
+ export declare function createUndoManager({ limit, }?: CreateUndoManagerOptions): {
13
+ canUndo: () => boolean;
14
+ canRedo: () => boolean;
15
+ undo: () => Promise<void>;
16
+ redo: () => Promise<void>;
17
+ execute: (callback: Callback, group?: string) => Promise<void>;
18
+ };
19
+ export {};
@@ -12,7 +12,7 @@ import {
12
12
  } from "./22HHDS5F.js";
13
13
  import {
14
14
  getDocument
15
- } from "./RRSZHCH6.js";
15
+ } from "./IUORCTET.js";
16
16
  import {
17
17
  __spreadProps,
18
18
  __spreadValues
@@ -0,0 +1,71 @@
1
+ "use client";
2
+
3
+ // src/utils/undo.ts
4
+ function createUndoCallback(callback) {
5
+ return async () => {
6
+ const redo = await (callback == null ? void 0 : callback());
7
+ return createUndoCallback(async () => {
8
+ await (redo == null ? void 0 : redo());
9
+ return callback;
10
+ });
11
+ };
12
+ }
13
+ var UndoManager = createUndoManager();
14
+ function createUndoManager({
15
+ limit = 100
16
+ } = {}) {
17
+ const undoStack = [];
18
+ let redoStack = [];
19
+ let currentGroup = null;
20
+ const canUndo = () => undoStack.length > 0;
21
+ const canRedo = () => redoStack.length > 0;
22
+ const undo = async () => {
23
+ var _a;
24
+ if (!canUndo())
25
+ return;
26
+ currentGroup = null;
27
+ redoStack.push(await ((_a = undoStack.pop()) == null ? void 0 : _a()));
28
+ };
29
+ const redo = async () => {
30
+ var _a;
31
+ if (!canRedo())
32
+ return;
33
+ currentGroup = null;
34
+ undoStack.push(await ((_a = redoStack.pop()) == null ? void 0 : _a()));
35
+ };
36
+ const execute = async (callback, group) => {
37
+ if (!callback)
38
+ return;
39
+ while (undoStack.length > limit) {
40
+ undoStack.shift();
41
+ }
42
+ const sameGroup = group === currentGroup;
43
+ currentGroup = group != null ? group : null;
44
+ const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
45
+ const undoCallback = await callback();
46
+ if (!undoCallback)
47
+ return;
48
+ redoStack = [];
49
+ const currentUndo = undoStack[nextIndex];
50
+ undoStack[nextIndex] = createUndoCallback(async () => {
51
+ await (undoCallback == null ? void 0 : undoCallback());
52
+ const currentRedo = await (currentUndo == null ? void 0 : currentUndo());
53
+ return async () => {
54
+ await (currentRedo == null ? void 0 : currentRedo());
55
+ await (callback == null ? void 0 : callback());
56
+ };
57
+ });
58
+ };
59
+ return {
60
+ canUndo,
61
+ canRedo,
62
+ undo,
63
+ redo,
64
+ execute
65
+ };
66
+ }
67
+
68
+ export {
69
+ UndoManager,
70
+ createUndoManager
71
+ };
@@ -89,26 +89,19 @@ function isTextField(element) {
89
89
  return false;
90
90
  }
91
91
  }
92
- function getPopupRole(element, fallback) {
93
- const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
94
- const role = element == null ? void 0 : element.getAttribute("role");
95
- if (role && allowedPopupRoles.indexOf(role) !== -1) {
96
- return role;
97
- }
98
- return fallback;
92
+ function isTextbox(element) {
93
+ return element.isContentEditable || isTextField(element);
99
94
  }
100
- function getPopupItemRole(element, fallback) {
101
- var _a;
102
- const itemRoleByPopupRole = {
103
- menu: "menuitem",
104
- listbox: "option",
105
- tree: "treeitem"
106
- };
107
- const popupRole = getPopupRole(element);
108
- if (!popupRole)
109
- return fallback;
110
- const key = popupRole;
111
- return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
95
+ function getTextboxValue(element) {
96
+ if (isTextField(element)) {
97
+ return element.value;
98
+ }
99
+ if (element.isContentEditable) {
100
+ const range = getDocument(element).createRange();
101
+ range.selectNodeContents(element);
102
+ return range.toString();
103
+ }
104
+ return "";
112
105
  }
113
106
  function getTextboxSelection(element) {
114
107
  let start = 0;
@@ -130,6 +123,27 @@ function getTextboxSelection(element) {
130
123
  }
131
124
  return { start, end };
132
125
  }
126
+ function getPopupRole(element, fallback) {
127
+ const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
128
+ const role = element == null ? void 0 : element.getAttribute("role");
129
+ if (role && allowedPopupRoles.indexOf(role) !== -1) {
130
+ return role;
131
+ }
132
+ return fallback;
133
+ }
134
+ function getPopupItemRole(element, fallback) {
135
+ var _a;
136
+ const itemRoleByPopupRole = {
137
+ menu: "menuitem",
138
+ listbox: "option",
139
+ tree: "treeitem"
140
+ };
141
+ const popupRole = getPopupRole(element);
142
+ if (!popupRole)
143
+ return fallback;
144
+ const key = popupRole;
145
+ return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
146
+ }
133
147
  function scrollIntoViewIfNeeded(element, arg) {
134
148
  if (isPartiallyHidden(element) && "scrollIntoView" in element) {
135
149
  element.scrollIntoView(arg);
@@ -186,9 +200,11 @@ export {
186
200
  isVisible,
187
201
  closest,
188
202
  isTextField,
203
+ isTextbox,
204
+ getTextboxValue,
205
+ getTextboxSelection,
189
206
  getPopupRole,
190
207
  getPopupItemRole,
191
- getTextboxSelection,
192
208
  scrollIntoViewIfNeeded,
193
209
  getScrollingElement,
194
210
  isPartiallyHidden,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createCompositeStore
4
- } from "./2H5K47H4.js";
4
+ } from "./YVUNPQHS.js";
5
5
  import {
6
6
  createStore
7
7
  } from "./R676XYVY.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  canUseDOM
4
- } from "./RRSZHCH6.js";
4
+ } from "./IUORCTET.js";
5
5
 
6
6
  // src/utils/platform.ts
7
7
  function isTouchDevice() {
@@ -1,7 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  createCollectionStore
4
- } from "./URUD7X4C.js";
4
+ } from "./ABMC67JW.js";
5
+ import {
6
+ flatten2DArray,
7
+ reverseArray
8
+ } from "./7PRQYBBV.js";
5
9
  import {
6
10
  createStore,
7
11
  setup,
@@ -10,10 +14,6 @@ import {
10
14
  import {
11
15
  defaultValue
12
16
  } from "./22HHDS5F.js";
13
- import {
14
- flatten2DArray,
15
- reverseArray
16
- } from "./7PRQYBBV.js";
17
17
  import {
18
18
  __spreadProps,
19
19
  __spreadValues
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  createCollectionStore
4
- } from "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/ABMC67JW.js";
5
5
  import "../__chunks/R676XYVY.js";
6
6
  import "../__chunks/22HHDS5F.js";
7
- import "../__chunks/RRSZHCH6.js";
7
+ import "../__chunks/IUORCTET.js";
8
8
  import "../__chunks/4R3V3JGP.js";
9
9
  export {
10
10
  createCollectionStore
@@ -1,5 +1,6 @@
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
+ import type { TagStore } from "../tag/tag-store.js";
3
4
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
5
  import type { PickRequired, SetState } from "../utils/types.js";
5
6
  type MutableValue<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> = T extends string ? string : T;
@@ -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,49 @@
1
1
  "use client";
2
+ import {
3
+ createCompositeStore
4
+ } from "../__chunks/YVUNPQHS.js";
5
+ import "../__chunks/ABMC67JW.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
26
  isSafari
23
- } from "../__chunks/VDNATJW2.js";
24
- import "../__chunks/RRSZHCH6.js";
25
- import "../__chunks/7PRQYBBV.js";
27
+ } from "../__chunks/QAI5BPCY.js";
28
+ import "../__chunks/IUORCTET.js";
26
29
  import {
30
+ __objRest,
27
31
  __spreadProps,
28
32
  __spreadValues
29
33
  } from "../__chunks/4R3V3JGP.js";
30
34
 
31
35
  // src/combobox/combobox-store.ts
32
36
  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
+ function createComboboxStore(_a = {}) {
38
+ var _b = _a, {
39
+ tag
40
+ } = _b, props = __objRest(_b, [
41
+ "tag"
42
+ ]);
43
+ const store = mergeStore(props.store, pick(tag, ["value", "rtl"]));
44
+ throwOnConflictingProps(props, store);
45
+ const tagState = tag == null ? void 0 : tag.getState();
46
+ const syncState = store == null ? void 0 : store.getState();
37
47
  const activeId = defaultValue(
38
48
  props.activeId,
39
49
  syncState == null ? void 0 : syncState.activeId,
@@ -76,6 +86,7 @@ function createComboboxStore(props = {}) {
76
86
  const selectedValue = defaultValue(
77
87
  props.selectedValue,
78
88
  syncState == null ? void 0 : syncState.selectedValue,
89
+ tagState == null ? void 0 : tagState.values,
79
90
  props.defaultSelectedValue,
80
91
  ""
81
92
  );
@@ -91,11 +102,25 @@ function createComboboxStore(props = {}) {
91
102
  resetValueOnHide: defaultValue(
92
103
  props.resetValueOnHide,
93
104
  syncState == null ? void 0 : syncState.resetValueOnHide,
94
- multiSelectable
105
+ multiSelectable && !tag
95
106
  ),
96
107
  activeValue: syncState == null ? void 0 : syncState.activeValue
97
108
  });
98
- const combobox = createStore(initialState, composite, popover, props.store);
109
+ const combobox = createStore(initialState, composite, popover, store);
110
+ setup(combobox, () => {
111
+ if (!tag)
112
+ return;
113
+ return chain(
114
+ sync(combobox, ["selectedValue"], (state) => {
115
+ if (!Array.isArray(state.selectedValue))
116
+ return;
117
+ tag.setValues(state.selectedValue);
118
+ }),
119
+ sync(tag, ["values"], (state) => {
120
+ combobox.setState("selectedValue", state.values);
121
+ })
122
+ );
123
+ });
99
124
  setup(
100
125
  combobox,
101
126
  () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
@@ -106,14 +131,6 @@ function createComboboxStore(props = {}) {
106
131
  combobox.setState("value", value);
107
132
  })
108
133
  );
109
- setup(
110
- combobox,
111
- () => sync(combobox, ["resetValueOnSelect", "selectedValue"], (state) => {
112
- if (!state.resetValueOnSelect)
113
- return;
114
- combobox.setState("value", value);
115
- })
116
- );
117
134
  setup(
118
135
  combobox,
119
136
  () => batch(combobox, ["mounted"], (state) => {
@@ -142,7 +159,9 @@ function createComboboxStore(props = {}) {
142
159
  })
143
160
  );
144
161
  return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, popover), composite), combobox), {
162
+ tag,
145
163
  setValue: (value2) => combobox.setState("value", value2),
164
+ resetValue: () => combobox.setState("value", initialState.value),
146
165
  setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
147
166
  });
148
167
  }
@@ -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/YVUNPQHS.js";
5
+ import "../__chunks/ABMC67JW.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/IUORCTET.js";
10
10
  import "../__chunks/4R3V3JGP.js";
11
11
  export {
12
12
  createCompositeStore
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createCollectionStore
4
- } from "../__chunks/URUD7X4C.js";
4
+ } from "../__chunks/ABMC67JW.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/IUORCTET.js";
18
18
  import {
19
19
  __spreadProps,
20
20
  __spreadValues
@@ -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/K7A7LTR3.js";
5
+ import "../__chunks/YVUNPQHS.js";
6
+ import "../__chunks/ABMC67JW.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/IUORCTET.js";
11
11
  import "../__chunks/4R3V3JGP.js";
12
12
 
13
13
  // src/menu/menu-bar-store.ts
@@ -2,13 +2,14 @@
2
2
  import {
3
3
  createHovercardStore
4
4
  } from "../__chunks/BRS7GKWU.js";
5
+ import {
6
+ createCompositeStore
7
+ } from "../__chunks/YVUNPQHS.js";
8
+ import "../__chunks/ABMC67JW.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/IUORCTET.js";
27
27
  import {
28
28
  __objRest,
29
29
  __spreadProps,
@@ -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/K7A7LTR3.js";
5
+ import "../__chunks/YVUNPQHS.js";
6
+ import "../__chunks/ABMC67JW.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/IUORCTET.js";
11
11
  import "../__chunks/4R3V3JGP.js";
12
12
  export {
13
13
  createMenubarStore