@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @ariakit/core
2
2
 
3
+ ## 0.4.6
4
+
5
+ - Ensured [Combobox](https://ariakit.org/components/combobox) uses roving tabindex to manage focus on mobile Safari.
6
+ - Added a new `listElement` state to the Select store.
7
+ - Removed unnecessary utility functions: `closest`, `matches`.
8
+ - Improved use of [Tab](https://ariakit.org/components/tab) components within [Select](https://ariakit.org/components/select) widgets.
9
+ - Improved JSDocs.
10
+
11
+ ## 0.4.5
12
+
13
+ - Added new `undo` utils.
14
+ - Added new experimental Tag components.
15
+ - Added DOM utils: `isTextbox`, `getTextboxValue`.
16
+ - Added event function: `getInputType`.
17
+ - Added new [`resetValue`](https://ariakit.org/reference/use-combobox-store#resetvalue) method to combobox store.
18
+ - Improved JSDocs.
19
+
3
20
  ## 0.4.4
4
21
 
5
22
  ### Combobox `autoFocusOnHide` behavior
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _FFZYCAXAcjs = require('./FFZYCAXA.cjs');
4
+ var _4W3OYRR3cjs = require('./4W3OYRR3.cjs');
5
5
 
6
6
 
7
7
 
8
+ var _ULSPM3Y3cjs = require('./ULSPM3Y3.cjs');
8
9
 
9
- var _B4LYZ4EMcjs = require('./B4LYZ4EM.cjs');
10
10
 
11
11
 
12
- var _EEDWPDM2cjs = require('./EEDWPDM2.cjs');
13
12
 
13
+ var _B4LYZ4EMcjs = require('./B4LYZ4EM.cjs');
14
14
 
15
15
 
16
- var _ULSPM3Y3cjs = require('./ULSPM3Y3.cjs');
16
+ var _EEDWPDM2cjs = require('./EEDWPDM2.cjs');
17
17
 
18
18
 
19
19
 
@@ -124,7 +124,7 @@ function verticalizeItems(items) {
124
124
  function createCompositeStore(props = {}) {
125
125
  var _a;
126
126
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
127
- const collection = _FFZYCAXAcjs.createCollectionStore.call(void 0, props);
127
+ const collection = _4W3OYRR3cjs.createCollectionStore.call(void 0, props);
128
128
  const activeId = _EEDWPDM2cjs.defaultValue.call(void 0,
129
129
  props.activeId,
130
130
  syncState == null ? void 0 : syncState.activeId,
@@ -12,7 +12,7 @@ var _B4LYZ4EMcjs = require('./B4LYZ4EM.cjs');
12
12
  var _EEDWPDM2cjs = require('./EEDWPDM2.cjs');
13
13
 
14
14
 
15
- var _UKR6TQI3cjs = require('./UKR6TQI3.cjs');
15
+ var _Q2WCPTYScjs = require('./Q2WCPTYS.cjs');
16
16
 
17
17
 
18
18
 
@@ -62,7 +62,7 @@ function getCommonParent(items) {
62
62
  }
63
63
  parentElement = parentElement.parentElement;
64
64
  }
65
- return _UKR6TQI3cjs.getDocument.call(void 0, parentElement).body;
65
+ return _Q2WCPTYScjs.getDocument.call(void 0, parentElement).body;
66
66
  }
67
67
  function getPrivateStore(store) {
68
68
  return store == null ? void 0 : store.__unstablePrivateStore;
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _Y7KNI5NScjs = require('./Y7KNI5NS.cjs');
4
+ var _3HYNC3XAcjs = require('./3HYNC3XA.cjs');
5
5
 
6
6
 
7
7
  var _B4LYZ4EMcjs = require('./B4LYZ4EM.cjs');
@@ -17,7 +17,7 @@ var _AV6KTKLEcjs = require('./AV6KTKLE.cjs');
17
17
  function createMenubarStore(props = {}) {
18
18
  var _a;
19
19
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
20
- const composite = _Y7KNI5NScjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
20
+ const composite = _3HYNC3XAcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
21
21
  orientation: _EEDWPDM2cjs.defaultValue.call(void 0,
22
22
  props.orientation,
23
23
  syncState == null ? void 0 : syncState.orientation,
@@ -1,25 +1,25 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _UKR6TQI3cjs = require('./UKR6TQI3.cjs');
4
+ var _Q2WCPTYScjs = require('./Q2WCPTYS.cjs');
5
5
 
6
6
  // src/utils/platform.ts
7
7
  function isTouchDevice() {
8
- return _UKR6TQI3cjs.canUseDOM && !!navigator.maxTouchPoints;
8
+ return _Q2WCPTYScjs.canUseDOM && !!navigator.maxTouchPoints;
9
9
  }
10
10
  function isApple() {
11
- if (!_UKR6TQI3cjs.canUseDOM)
11
+ if (!_Q2WCPTYScjs.canUseDOM)
12
12
  return false;
13
13
  return /mac|iphone|ipad|ipod/i.test(navigator.platform);
14
14
  }
15
15
  function isSafari() {
16
- return _UKR6TQI3cjs.canUseDOM && isApple() && /apple/i.test(navigator.vendor);
16
+ return _Q2WCPTYScjs.canUseDOM && isApple() && /apple/i.test(navigator.vendor);
17
17
  }
18
18
  function isFirefox() {
19
- return _UKR6TQI3cjs.canUseDOM && /firefox\//i.test(navigator.userAgent);
19
+ return _Q2WCPTYScjs.canUseDOM && /firefox\//i.test(navigator.userAgent);
20
20
  }
21
21
  function isMac() {
22
- return _UKR6TQI3cjs.canUseDOM && navigator.platform.startsWith("Mac") && !isTouchDevice();
22
+ return _Q2WCPTYScjs.canUseDOM && navigator.platform.startsWith("Mac") && !isTouchDevice();
23
23
  }
24
24
 
25
25
 
@@ -0,0 +1,71 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"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
+
69
+
70
+
71
+ exports.UndoManager = UndoManager; exports.createUndoManager = createUndoManager;
@@ -57,29 +57,13 @@ var buttonInputTypes = [
57
57
  "reset",
58
58
  "submit"
59
59
  ];
60
- function matches(element, selectors) {
61
- if ("matches" in element) {
62
- return element.matches(selectors);
63
- }
64
- if ("msMatchesSelector" in element) {
65
- return element.msMatchesSelector(selectors);
66
- }
67
- return element.webkitMatchesSelector(selectors);
68
- }
69
60
  function isVisible(element) {
61
+ if (typeof element.checkVisibility === "function") {
62
+ return element.checkVisibility();
63
+ }
70
64
  const htmlElement = element;
71
65
  return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
72
66
  }
73
- function closest(element, selectors) {
74
- if ("closest" in element)
75
- return element.closest(selectors);
76
- do {
77
- if (matches(element, selectors))
78
- return element;
79
- element = element.parentElement || element.parentNode;
80
- } while (element !== null && element.nodeType === 1);
81
- return null;
82
- }
83
67
  function isTextField(element) {
84
68
  try {
85
69
  const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
@@ -89,26 +73,19 @@ function isTextField(element) {
89
73
  return false;
90
74
  }
91
75
  }
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;
76
+ function isTextbox(element) {
77
+ return element.isContentEditable || isTextField(element);
99
78
  }
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;
79
+ function getTextboxValue(element) {
80
+ if (isTextField(element)) {
81
+ return element.value;
82
+ }
83
+ if (element.isContentEditable) {
84
+ const range = getDocument(element).createRange();
85
+ range.selectNodeContents(element);
86
+ return range.toString();
87
+ }
88
+ return "";
112
89
  }
113
90
  function getTextboxSelection(element) {
114
91
  let start = 0;
@@ -130,6 +107,27 @@ function getTextboxSelection(element) {
130
107
  }
131
108
  return { start, end };
132
109
  }
110
+ function getPopupRole(element, fallback) {
111
+ const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
112
+ const role = element == null ? void 0 : element.getAttribute("role");
113
+ if (role && allowedPopupRoles.indexOf(role) !== -1) {
114
+ return role;
115
+ }
116
+ return fallback;
117
+ }
118
+ function getPopupItemRole(element, fallback) {
119
+ var _a;
120
+ const itemRoleByPopupRole = {
121
+ menu: "menuitem",
122
+ listbox: "option",
123
+ tree: "treeitem"
124
+ };
125
+ const popupRole = getPopupRole(element);
126
+ if (!popupRole)
127
+ return fallback;
128
+ const key = popupRole;
129
+ return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
130
+ }
133
131
  function scrollIntoViewIfNeeded(element, arg) {
134
132
  if (isPartiallyHidden(element) && "scrollIntoView" in element) {
135
133
  element.scrollIntoView(arg);
@@ -193,4 +191,4 @@ function setSelectionRange(element, ...args) {
193
191
 
194
192
 
195
193
 
196
- exports.canUseDOM = canUseDOM; exports.getDocument = getDocument; exports.getWindow = getWindow; exports.getActiveElement = getActiveElement; exports.contains = contains; exports.isFrame = isFrame; exports.isButton = isButton; exports.matches = matches; exports.isVisible = isVisible; exports.closest = closest; exports.isTextField = isTextField; exports.getPopupRole = getPopupRole; exports.getPopupItemRole = getPopupItemRole; exports.getTextboxSelection = getTextboxSelection; exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded; exports.getScrollingElement = getScrollingElement; exports.isPartiallyHidden = isPartiallyHidden; exports.setSelectionRange = setSelectionRange;
194
+ exports.canUseDOM = canUseDOM; exports.getDocument = getDocument; exports.getWindow = getWindow; exports.getActiveElement = getActiveElement; exports.contains = contains; exports.isFrame = isFrame; exports.isButton = isButton; exports.isVisible = isVisible; exports.isTextField = isTextField; exports.isTextbox = isTextbox; exports.getTextboxValue = getTextboxValue; exports.getTextboxSelection = getTextboxSelection; exports.getPopupRole = getPopupRole; exports.getPopupItemRole = getPopupItemRole; exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded; exports.getScrollingElement = getScrollingElement; exports.isPartiallyHidden = isPartiallyHidden; exports.setSelectionRange = setSelectionRange;
@@ -1,5 +1,5 @@
1
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
2
- import type { PickRequired, SetState, ToPrimitive } from "../utils/types.js";
1
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
2
+ import type { PickRequired, SetState, ToPrimitive } from "../utils/types.ts";
3
3
  /**
4
4
  * Creates a checkbox store.
5
5
  */
@@ -1,5 +1,5 @@
1
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
2
- import type { PickRequired, SetState, ToPrimitive } from "../utils/types.js";
1
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
2
+ import type { PickRequired, SetState, ToPrimitive } from "../utils/types.ts";
3
3
  /**
4
4
  * Creates a checkbox store.
5
5
  */
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _FFZYCAXAcjs = require('../__chunks/FFZYCAXA.cjs');
4
+ var _4W3OYRR3cjs = require('../__chunks/4W3OYRR3.cjs');
5
5
  require('../__chunks/B4LYZ4EM.cjs');
6
6
  require('../__chunks/EEDWPDM2.cjs');
7
- require('../__chunks/UKR6TQI3.cjs');
7
+ require('../__chunks/Q2WCPTYS.cjs');
8
8
  require('../__chunks/AV6KTKLE.cjs');
9
9
 
10
10
 
11
- exports.createCollectionStore = _FFZYCAXAcjs.createCollectionStore;
11
+ exports.createCollectionStore = _4W3OYRR3cjs.createCollectionStore;
@@ -1,5 +1,5 @@
1
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
2
- import type { BivariantCallback } from "../utils/types.js";
1
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
2
+ import type { BivariantCallback } from "../utils/types.ts";
3
3
  /**
4
4
  * Creates a collection store.
5
5
  */
@@ -1,5 +1,5 @@
1
- import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
2
- import type { BivariantCallback } from "../utils/types.js";
1
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
2
+ import type { BivariantCallback } from "../utils/types.ts";
3
3
  /**
4
4
  * Creates a collection store.
5
5
  */
@@ -1,13 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
+ var _3HYNC3XAcjs = require('../__chunks/3HYNC3XA.cjs');
5
+ require('../__chunks/4W3OYRR3.cjs');
6
+ require('../__chunks/ULSPM3Y3.cjs');
7
+
8
+
4
9
  var _5JEQEZFRcjs = require('../__chunks/5JEQEZFR.cjs');
5
10
  require('../__chunks/LTLFSC4X.cjs');
6
11
  require('../__chunks/AETQC2AR.cjs');
7
12
 
8
13
 
9
- var _Y7KNI5NScjs = require('../__chunks/Y7KNI5NS.cjs');
10
- require('../__chunks/FFZYCAXA.cjs');
11
14
 
12
15
 
13
16
 
@@ -17,30 +20,38 @@ require('../__chunks/FFZYCAXA.cjs');
17
20
  var _B4LYZ4EMcjs = require('../__chunks/B4LYZ4EM.cjs');
18
21
 
19
22
 
23
+
20
24
  var _EEDWPDM2cjs = require('../__chunks/EEDWPDM2.cjs');
21
25
 
22
26
 
23
- var _7DU6YMLQcjs = require('../__chunks/7DU6YMLQ.cjs');
24
- require('../__chunks/UKR6TQI3.cjs');
25
- require('../__chunks/ULSPM3Y3.cjs');
27
+
28
+ var _D7M2PCAQcjs = require('../__chunks/D7M2PCAQ.cjs');
29
+ require('../__chunks/Q2WCPTYS.cjs');
30
+
26
31
 
27
32
 
28
33
 
29
34
  var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
30
35
 
31
36
  // src/combobox/combobox-store.ts
32
- var isSafariOnMobile = _7DU6YMLQcjs.isSafari.call(void 0, ) && matchMedia("(hover:none)").matches;
33
- function createComboboxStore(props = {}) {
34
- var _a;
35
- _B4LYZ4EMcjs.throwOnConflictingProps.call(void 0, props, props.store);
36
- const syncState = (_a = props.store) == null ? void 0 : _a.getState();
37
+ var isTouchSafari = _D7M2PCAQcjs.isSafari.call(void 0, ) && _D7M2PCAQcjs.isTouchDevice.call(void 0, );
38
+ function createComboboxStore(_a = {}) {
39
+ var _b = _a, {
40
+ tag
41
+ } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, [
42
+ "tag"
43
+ ]);
44
+ const store = _B4LYZ4EMcjs.mergeStore.call(void 0, props.store, _B4LYZ4EMcjs.pick.call(void 0, tag, ["value", "rtl"]));
45
+ _B4LYZ4EMcjs.throwOnConflictingProps.call(void 0, props, store);
46
+ const tagState = tag == null ? void 0 : tag.getState();
47
+ const syncState = store == null ? void 0 : store.getState();
37
48
  const activeId = _EEDWPDM2cjs.defaultValue.call(void 0,
38
49
  props.activeId,
39
50
  syncState == null ? void 0 : syncState.activeId,
40
51
  props.defaultActiveId,
41
52
  null
42
53
  );
43
- const composite = _Y7KNI5NScjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
54
+ const composite = _3HYNC3XAcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
44
55
  activeId,
45
56
  includesBaseElement: _EEDWPDM2cjs.defaultValue.call(void 0,
46
57
  props.includesBaseElement,
@@ -57,7 +68,7 @@ function createComboboxStore(props = {}) {
57
68
  virtualFocus: _EEDWPDM2cjs.defaultValue.call(void 0,
58
69
  props.virtualFocus,
59
70
  syncState == null ? void 0 : syncState.virtualFocus,
60
- !isSafariOnMobile
71
+ true
61
72
  )
62
73
  }));
63
74
  const popover = _5JEQEZFRcjs.createPopoverStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
@@ -76,6 +87,7 @@ function createComboboxStore(props = {}) {
76
87
  const selectedValue = _EEDWPDM2cjs.defaultValue.call(void 0,
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: _EEDWPDM2cjs.defaultValue.call(void 0,
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 = _B4LYZ4EMcjs.createStore.call(void 0, initialState, composite, popover, props.store);
110
+ const combobox = _B4LYZ4EMcjs.createStore.call(void 0, initialState, composite, popover, store);
111
+ if (isTouchSafari) {
112
+ _B4LYZ4EMcjs.setup.call(void 0,
113
+ combobox,
114
+ () => _B4LYZ4EMcjs.sync.call(void 0, combobox, ["virtualFocus"], () => {
115
+ combobox.setState("virtualFocus", false);
116
+ })
117
+ );
118
+ }
119
+ _B4LYZ4EMcjs.setup.call(void 0, combobox, () => {
120
+ if (!tag)
121
+ return;
122
+ return _EEDWPDM2cjs.chain.call(void 0,
123
+ _B4LYZ4EMcjs.sync.call(void 0, combobox, ["selectedValue"], (state) => {
124
+ if (!Array.isArray(state.selectedValue))
125
+ return;
126
+ tag.setValues(state.selectedValue);
127
+ }),
128
+ _B4LYZ4EMcjs.sync.call(void 0, tag, ["values"], (state) => {
129
+ combobox.setState("selectedValue", state.values);
130
+ })
131
+ );
132
+ });
99
133
  _B4LYZ4EMcjs.setup.call(void 0,
100
134
  combobox,
101
135
  () => _B4LYZ4EMcjs.sync.call(void 0, combobox, ["resetValueOnHide", "mounted"], (state) => {
@@ -106,14 +140,6 @@ function createComboboxStore(props = {}) {
106
140
  combobox.setState("value", value);
107
141
  })
108
142
  );
109
- _B4LYZ4EMcjs.setup.call(void 0,
110
- combobox,
111
- () => _B4LYZ4EMcjs.sync.call(void 0, combobox, ["resetValueOnSelect", "selectedValue"], (state) => {
112
- if (!state.resetValueOnSelect)
113
- return;
114
- combobox.setState("value", value);
115
- })
116
- );
117
143
  _B4LYZ4EMcjs.setup.call(void 0,
118
144
  combobox,
119
145
  () => _B4LYZ4EMcjs.batch.call(void 0, combobox, ["mounted"], (state) => {
@@ -142,7 +168,9 @@ function createComboboxStore(props = {}) {
142
168
  })
143
169
  );
144
170
  return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, 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,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,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,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,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,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _Y7KNI5NScjs = require('../__chunks/Y7KNI5NS.cjs');
5
- require('../__chunks/FFZYCAXA.cjs');
4
+ var _3HYNC3XAcjs = require('../__chunks/3HYNC3XA.cjs');
5
+ require('../__chunks/4W3OYRR3.cjs');
6
+ require('../__chunks/ULSPM3Y3.cjs');
6
7
  require('../__chunks/B4LYZ4EM.cjs');
7
8
  require('../__chunks/EEDWPDM2.cjs');
8
- require('../__chunks/UKR6TQI3.cjs');
9
- require('../__chunks/ULSPM3Y3.cjs');
9
+ require('../__chunks/Q2WCPTYS.cjs');
10
10
  require('../__chunks/AV6KTKLE.cjs');
11
11
 
12
12
 
13
- exports.createCompositeStore = _Y7KNI5NScjs.createCompositeStore;
13
+ exports.createCompositeStore = _3HYNC3XAcjs.createCompositeStore;