@ariakit/core 0.1.4 → 0.2.0

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 (90) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/cjs/__chunks/{QYB6XH64.cjs → 27ZAGOYG.cjs} +17 -13
  3. package/cjs/__chunks/6455U47T.cjs +37 -0
  4. package/cjs/__chunks/{ZPOXPO2L.cjs → 6SPJEESB.cjs} +33 -21
  5. package/cjs/__chunks/CNODBYSG.cjs +58 -0
  6. package/cjs/__chunks/{2YFRPUZP.cjs → DBHIHK7C.cjs} +6 -6
  7. package/cjs/__chunks/{W5IHD6VG.cjs → EUJ6NNA6.cjs} +56 -43
  8. package/cjs/__chunks/{4DQ3OTE7.cjs → FXEBKN6G.cjs} +22 -17
  9. package/cjs/__chunks/{ZJEEK57E.cjs → HEFJPUYD.cjs} +2 -2
  10. package/cjs/__chunks/{QNEPGQLL.cjs → M6ZA7XUP.cjs} +6 -2
  11. package/cjs/__chunks/RD3S4VKY.cjs +60 -0
  12. package/cjs/__chunks/{OFNGELMA.cjs → ZNW4LSWU.cjs} +8 -6
  13. package/cjs/checkbox/checkbox-store.cjs +14 -10
  14. package/cjs/collection/collection-store.cjs +6 -5
  15. package/cjs/combobox/combobox-store.cjs +49 -48
  16. package/cjs/composite/composite-overflow-store.cjs +7 -6
  17. package/cjs/composite/composite-store.cjs +7 -6
  18. package/cjs/dialog/dialog-store.cjs +6 -5
  19. package/cjs/disclosure/disclosure-store.cjs +5 -4
  20. package/cjs/disclosure/disclosure-store.d.ts +8 -0
  21. package/cjs/form/form-store.cjs +38 -35
  22. package/cjs/hovercard/hovercard-store.cjs +8 -7
  23. package/cjs/hovercard/hovercard-store.d.ts +3 -2
  24. package/cjs/index.cjs +3 -1
  25. package/cjs/menu/menu-bar-store.cjs +17 -13
  26. package/cjs/menu/menu-store.cjs +41 -43
  27. package/cjs/popover/popover-store.cjs +7 -6
  28. package/cjs/popover/popover-store.d.ts +8 -89
  29. package/cjs/radio/radio-store.cjs +25 -24
  30. package/cjs/select/select-store.cjs +42 -42
  31. package/cjs/tab/tab-store.cjs +29 -28
  32. package/cjs/tab/tab-store.d.ts +9 -0
  33. package/cjs/toolbar/toolbar-store.cjs +17 -13
  34. package/cjs/tooltip/tooltip-store.cjs +31 -79
  35. package/cjs/tooltip/tooltip-store.d.ts +20 -15
  36. package/cjs/tsconfig.build.tsbuildinfo +1 -1
  37. package/cjs/utils/array.cjs +1 -0
  38. package/cjs/utils/dom.cjs +3 -2
  39. package/cjs/utils/events.cjs +14 -9
  40. package/cjs/utils/focus.cjs +24 -14
  41. package/cjs/utils/misc.cjs +3 -2
  42. package/cjs/utils/platform.cjs +4 -3
  43. package/cjs/utils/store.cjs +4 -3
  44. package/esm/__chunks/3BAGFTL5.js +58 -0
  45. package/esm/__chunks/4BKCJXBM.js +37 -0
  46. package/esm/__chunks/{NA5BK7DD.js → BOKMNDR7.js} +22 -10
  47. package/esm/__chunks/{WFGVC6LE.js → EWHSN7GO.js} +17 -12
  48. package/esm/__chunks/{4T5RHRE5.js → MNNKHNLW.js} +1 -1
  49. package/esm/__chunks/{UVCATTRC.js → N6JW4ITM.js} +7 -5
  50. package/esm/__chunks/{RMD7SNCC.js → NWU4GBZ6.js} +5 -1
  51. package/esm/__chunks/{X7MJ3FB5.js → R6VHFWTV.js} +49 -36
  52. package/esm/__chunks/{DXA3K2FY.js → TFBCK4JB.js} +1 -1
  53. package/esm/__chunks/Z5IDQSMV.js +60 -0
  54. package/esm/__chunks/{IOAGNCXX.js → ZV2GEGPL.js} +14 -10
  55. package/esm/checkbox/checkbox-store.js +11 -7
  56. package/esm/collection/collection-store.js +5 -4
  57. package/esm/combobox/combobox-store.js +34 -33
  58. package/esm/composite/composite-overflow-store.js +6 -5
  59. package/esm/composite/composite-store.js +6 -5
  60. package/esm/dialog/dialog-store.js +5 -4
  61. package/esm/disclosure/disclosure-store.d.ts +8 -0
  62. package/esm/disclosure/disclosure-store.js +4 -3
  63. package/esm/form/form-store.js +24 -21
  64. package/esm/hovercard/hovercard-store.d.ts +3 -2
  65. package/esm/hovercard/hovercard-store.js +7 -6
  66. package/esm/index.js +2 -0
  67. package/esm/menu/menu-bar-store.js +15 -11
  68. package/esm/menu/menu-store.js +31 -33
  69. package/esm/popover/popover-store.d.ts +8 -89
  70. package/esm/popover/popover-store.js +6 -5
  71. package/esm/radio/radio-store.js +22 -21
  72. package/esm/select/select-store.js +29 -29
  73. package/esm/tab/tab-store.d.ts +9 -0
  74. package/esm/tab/tab-store.js +23 -22
  75. package/esm/toolbar/toolbar-store.js +15 -11
  76. package/esm/tooltip/tooltip-store.d.ts +20 -15
  77. package/esm/tooltip/tooltip-store.js +32 -80
  78. package/esm/tsconfig.build.tsbuildinfo +1 -1
  79. package/esm/utils/array.js +1 -0
  80. package/esm/utils/dom.js +2 -1
  81. package/esm/utils/events.js +10 -5
  82. package/esm/utils/focus.js +14 -4
  83. package/esm/utils/misc.js +2 -1
  84. package/esm/utils/platform.js +3 -2
  85. package/esm/utils/store.js +3 -2
  86. package/package.json +1 -1
  87. package/cjs/__chunks/DQHU5K4Q.cjs +0 -57
  88. package/cjs/__chunks/HLVPXX7H.cjs +0 -1491
  89. package/esm/__chunks/6HMPWUDT.js +0 -57
  90. package/esm/__chunks/6PEWNRTN.js +0 -1491
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ export {
34
+ __spreadValues,
35
+ __spreadProps,
36
+ __objRest
37
+ };
@@ -6,7 +6,11 @@ import {
6
6
  noop,
7
7
  omit,
8
8
  pick
9
- } from "./RMD7SNCC.js";
9
+ } from "./NWU4GBZ6.js";
10
+ import {
11
+ __spreadProps,
12
+ __spreadValues
13
+ } from "./4BKCJXBM.js";
10
14
 
11
15
  // src/utils/store.ts
12
16
  function createStore(initialState, ...stores) {
@@ -34,18 +38,22 @@ function createStore(initialState, ...stores) {
34
38
  const desyncs = getKeys(state).map(
35
39
  (key) => chain(
36
40
  ...stores.map((store) => {
37
- const storeState = store?.getState?.();
41
+ var _a, _b;
42
+ const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
38
43
  if (!storeState)
39
44
  return;
40
45
  if (!hasOwnProperty(storeState, key))
41
46
  return;
42
- return store?.sync?.((state2) => setState(key, state2[key]), [key]);
47
+ return (_b = store == null ? void 0 : store.sync) == null ? void 0 : _b.call(store, (state2) => setState(key, state2[key]), [key]);
43
48
  })
44
49
  )
45
50
  );
46
51
  const teardowns = [];
47
52
  setups.forEach((setup2) => teardowns.push(setup2()));
48
- const cleanups = stores.map((store) => store?.init?.());
53
+ const cleanups = stores.map((store) => {
54
+ var _a;
55
+ return (_a = store == null ? void 0 : store.init) == null ? void 0 : _a.call(store);
56
+ });
49
57
  return chain(...desyncs, ...teardowns, ...cleanups, () => {
50
58
  initialized = false;
51
59
  });
@@ -55,7 +63,8 @@ function createStore(initialState, ...stores) {
55
63
  set.add(listener);
56
64
  listenerKeys.set(listener, keys);
57
65
  return () => {
58
- disposables.get(listener)?.();
66
+ var _a;
67
+ (_a = disposables.get(listener)) == null ? void 0 : _a();
59
68
  disposables.delete(listener);
60
69
  listenerKeys.delete(listener);
61
70
  set.delete(listener);
@@ -80,19 +89,21 @@ function createStore(initialState, ...stores) {
80
89
  if (nextValue === state[key])
81
90
  return;
82
91
  stores.forEach((store) => {
83
- store?.setState?.(key, nextValue);
92
+ var _a;
93
+ (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
84
94
  });
85
95
  const prevState = state;
86
- state = { ...state, [key]: nextValue };
96
+ state = __spreadProps(__spreadValues({}, state), { [key]: nextValue });
87
97
  const thisUpdate = Symbol();
88
98
  lastUpdate = thisUpdate;
89
99
  updating = true;
90
100
  updatedKeys.add(key);
91
101
  const run = (listener, prev, uKeys) => {
102
+ var _a;
92
103
  const keys = listenerKeys.get(listener);
93
104
  const updated = (k) => uKeys ? uKeys.has(k) : k === key;
94
105
  if (!keys || keys.some(updated)) {
95
- disposables.get(listener)?.();
106
+ (_a = disposables.get(listener)) == null ? void 0 : _a();
96
107
  disposables.set(listener, listener(state, prev));
97
108
  }
98
109
  };
@@ -128,10 +139,11 @@ function createStore(initialState, ...stores) {
128
139
  }
129
140
  function mergeStore(...stores) {
130
141
  const initialState = stores.reduce((state, store2) => {
131
- const nextState = store2?.getState?.();
142
+ var _a;
143
+ const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
132
144
  if (!nextState)
133
145
  return state;
134
- return { ...state, ...nextState };
146
+ return __spreadValues(__spreadValues({}, state), nextState);
135
147
  }, {});
136
148
  const store = createStore(initialState, ...stores);
137
149
  return store;
@@ -1,13 +1,17 @@
1
1
  import {
2
2
  createStore
3
- } from "./NA5BK7DD.js";
3
+ } from "./BOKMNDR7.js";
4
4
  import {
5
5
  chain,
6
6
  defaultValue
7
- } from "./RMD7SNCC.js";
7
+ } from "./NWU4GBZ6.js";
8
8
  import {
9
9
  getDocument
10
- } from "./UVCATTRC.js";
10
+ } from "./N6JW4ITM.js";
11
+ import {
12
+ __spreadProps,
13
+ __spreadValues
14
+ } from "./4BKCJXBM.js";
11
15
 
12
16
  // src/collection/collection-store.ts
13
17
  function isElementPreceding(a, b) {
@@ -42,10 +46,11 @@ function sortBasedOnDOMPosition(items) {
42
46
  return items;
43
47
  }
44
48
  function getCommonParent(items) {
49
+ var _a;
45
50
  const firstItem = items.find((item) => !!item.element);
46
51
  const lastItem = [...items].reverse().find((item) => !!item.element);
47
- let parentElement = firstItem?.element?.parentElement;
48
- while (parentElement && lastItem?.element) {
52
+ let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
53
+ while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
49
54
  const parent = parentElement;
50
55
  if (lastItem && parent.contains(lastItem.element)) {
51
56
  return parentElement;
@@ -55,11 +60,12 @@ function getCommonParent(items) {
55
60
  return getDocument(parentElement).body;
56
61
  }
57
62
  function createCollectionStore(props = {}) {
63
+ var _a;
58
64
  const itemsMap = /* @__PURE__ */ new Map();
59
- const syncState = props.store?.getState();
65
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
60
66
  const initialState = {
61
- items: defaultValue(props.items, syncState?.items, props.defaultItems, []),
62
- renderedItems: defaultValue(syncState?.renderedItems, [])
67
+ items: defaultValue(props.items, syncState == null ? void 0 : syncState.items, props.defaultItems, []),
68
+ renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
63
69
  };
64
70
  const privateStore = createStore({
65
71
  renderedItems: initialState.renderedItems
@@ -108,7 +114,7 @@ function createCollectionStore(props = {}) {
108
114
  const nextItems = items.slice();
109
115
  if (index && index >= 0) {
110
116
  prevItem = items[index];
111
- const nextItem = { ...prevItem, ...item };
117
+ const nextItem = __spreadValues(__spreadValues({}, prevItem), item);
112
118
  nextItems[index] = nextItem;
113
119
  itemsMap.set(item.id, nextItem);
114
120
  } else {
@@ -137,8 +143,7 @@ function createCollectionStore(props = {}) {
137
143
  return unmergeItem;
138
144
  };
139
145
  const registerItem = (item) => mergeItem(item, (getItems) => collection.setState("items", getItems), true);
140
- return {
141
- ...collection,
146
+ return __spreadProps(__spreadValues({}, collection), {
142
147
  registerItem,
143
148
  renderItem: (item) => chain(
144
149
  registerItem(item),
@@ -160,7 +165,7 @@ function createCollectionStore(props = {}) {
160
165
  }
161
166
  return item || null;
162
167
  }
163
- };
168
+ });
164
169
  }
165
170
 
166
171
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createDisclosureStore
3
- } from "./IOAGNCXX.js";
3
+ } from "./ZV2GEGPL.js";
4
4
 
5
5
  // src/dialog/dialog-store.ts
6
6
  function createDialogStore(props = {}) {
@@ -1,7 +1,8 @@
1
1
  // src/utils/dom.ts
2
2
  var canUseDOM = checkIsBrowser();
3
3
  function checkIsBrowser() {
4
- return typeof window !== "undefined" && !!window.document?.createElement;
4
+ var _a;
5
+ return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
5
6
  }
6
7
  function getDocument(node) {
7
8
  return node ? node.ownerDocument || node : document;
@@ -11,7 +12,7 @@ function getWindow(node) {
11
12
  }
12
13
  function getActiveElement(node, activeDescendant = false) {
13
14
  const { activeElement } = getDocument(node);
14
- if (!activeElement?.nodeName) {
15
+ if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
15
16
  return null;
16
17
  }
17
18
  if (isFrame(activeElement) && activeElement.contentDocument) {
@@ -88,13 +89,14 @@ function isTextField(element) {
88
89
  }
89
90
  function getPopupRole(element, fallback) {
90
91
  const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
91
- const role = element?.getAttribute("role");
92
+ const role = element == null ? void 0 : element.getAttribute("role");
92
93
  if (role && allowedPopupRoles.indexOf(role) !== -1) {
93
94
  return role;
94
95
  }
95
96
  return fallback;
96
97
  }
97
98
  function getPopupItemRole(element, fallback) {
99
+ var _a;
98
100
  const itemRoleByPopupRole = {
99
101
  menu: "menuitem",
100
102
  listbox: "option",
@@ -105,7 +107,7 @@ function getPopupItemRole(element, fallback) {
105
107
  if (!popupRole)
106
108
  return fallback;
107
109
  const key = popupRole;
108
- return itemRoleByPopupRole[key] ?? fallback;
110
+ return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
109
111
  }
110
112
  function getTextboxSelection(element) {
111
113
  let start = 0;
@@ -115,7 +117,7 @@ function getTextboxSelection(element) {
115
117
  end = element.selectionEnd || 0;
116
118
  } else if (element.isContentEditable) {
117
119
  const selection = getDocument(element).getSelection();
118
- if (selection?.rangeCount && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
120
+ if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
119
121
  const range = selection.getRangeAt(0);
120
122
  const nextRange = range.cloneRange();
121
123
  nextRange.selectNodeContents(element);
@@ -1,3 +1,7 @@
1
+ import {
2
+ __spreadValues
3
+ } from "./4BKCJXBM.js";
4
+
1
5
  // src/utils/misc.ts
2
6
  function noop(..._) {
3
7
  }
@@ -76,7 +80,7 @@ function normalizeString(str) {
76
80
  return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
77
81
  }
78
82
  function omit(object, keys) {
79
- const result = { ...object };
83
+ const result = __spreadValues({}, object);
80
84
  for (const key of keys) {
81
85
  if (hasOwnProperty(result, key)) {
82
86
  delete result[key];
@@ -1,16 +1,20 @@
1
1
  import {
2
2
  createCollectionStore
3
- } from "./WFGVC6LE.js";
3
+ } from "./EWHSN7GO.js";
4
4
  import {
5
5
  createStore
6
- } from "./NA5BK7DD.js";
6
+ } from "./BOKMNDR7.js";
7
7
  import {
8
8
  defaultValue
9
- } from "./RMD7SNCC.js";
9
+ } from "./NWU4GBZ6.js";
10
10
  import {
11
11
  flatten2DArray,
12
12
  reverseArray
13
13
  } from "./5XEKIOCW.js";
14
+ import {
15
+ __spreadProps,
16
+ __spreadValues
17
+ } from "./4BKCJXBM.js";
14
18
 
15
19
  // src/composite/composite-store.ts
16
20
  var NULL_ITEM = { id: null };
@@ -51,7 +55,10 @@ function flipItems(items, activeId, shouldInsertNullItem = false) {
51
55
  function groupItemsByRows(items) {
52
56
  const rows = [];
53
57
  for (const item of items) {
54
- const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
58
+ const row = rows.find((currentRow) => {
59
+ var _a;
60
+ return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
61
+ });
55
62
  if (row) {
56
63
  row.push(item);
57
64
  } else {
@@ -84,7 +91,7 @@ function normalizeRows(rows, activeId, focusShift) {
84
91
  if (!item || focusShift && item.disabled) {
85
92
  const isFirst = i === 0;
86
93
  const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i - 1];
87
- row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
94
+ row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
88
95
  }
89
96
  }
90
97
  }
@@ -98,77 +105,78 @@ function verticalizeItems(items) {
98
105
  for (const row of rows) {
99
106
  const item = row[i];
100
107
  if (item) {
101
- verticalized.push({
102
- ...item,
108
+ verticalized.push(__spreadProps(__spreadValues({}, item), {
103
109
  // If there's no rowId, it means that it's not a grid composite, but
104
110
  // a single row instead. So, instead of verticalizing it, that is,
105
111
  // assigning a different rowId based on the column index, we keep it
106
112
  // undefined so they will be part of the same row. This is useful
107
113
  // when using up/down on one-dimensional composites.
108
114
  rowId: item.rowId ? `${i}` : void 0
109
- });
115
+ }));
110
116
  }
111
117
  }
112
118
  }
113
119
  return verticalized;
114
120
  }
115
121
  function createCompositeStore(props = {}) {
116
- const syncState = props.store?.getState();
122
+ var _a;
123
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
117
124
  const collection = createCollectionStore(props);
118
125
  const activeId = defaultValue(
119
126
  props.activeId,
120
- syncState?.activeId,
127
+ syncState == null ? void 0 : syncState.activeId,
121
128
  props.defaultActiveId
122
129
  );
123
- const initialState = {
124
- ...collection.getState(),
130
+ const initialState = __spreadProps(__spreadValues({}, collection.getState()), {
125
131
  activeId,
126
- baseElement: defaultValue(syncState?.baseElement, null),
132
+ baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
127
133
  includesBaseElement: defaultValue(
128
134
  props.includesBaseElement,
129
- syncState?.includesBaseElement,
135
+ syncState == null ? void 0 : syncState.includesBaseElement,
130
136
  activeId === null
131
137
  ),
132
- moves: defaultValue(syncState?.moves, 0),
138
+ moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
133
139
  orientation: defaultValue(
134
140
  props.orientation,
135
- syncState?.orientation,
141
+ syncState == null ? void 0 : syncState.orientation,
136
142
  "both"
137
143
  ),
138
- rtl: defaultValue(props.rtl, syncState?.rtl, false),
144
+ rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
139
145
  virtualFocus: defaultValue(
140
146
  props.virtualFocus,
141
- syncState?.virtualFocus,
147
+ syncState == null ? void 0 : syncState.virtualFocus,
142
148
  false
143
149
  ),
144
- focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
145
- focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
146
- focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
147
- };
150
+ focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
151
+ focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
152
+ focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
153
+ });
148
154
  const composite = createStore(initialState, collection, props.store);
149
155
  composite.setup(
150
156
  () => composite.sync(
151
157
  (state) => {
152
158
  composite.setState("activeId", (activeId2) => {
159
+ var _a2;
153
160
  if (activeId2 !== void 0)
154
161
  return activeId2;
155
- return findFirstEnabledItem(state.renderedItems)?.id;
162
+ return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id;
156
163
  });
157
164
  },
158
165
  ["renderedItems", "activeId"]
159
166
  )
160
167
  );
161
168
  const getNextId = (items, orientation, hasNullItem, skip) => {
169
+ var _a2, _b;
162
170
  const { activeId: activeId2, rtl, focusLoop, focusWrap, includesBaseElement } = composite.getState();
163
171
  const isHorizontal = orientation !== "vertical";
164
172
  const isRTL = rtl && isHorizontal;
165
173
  const allItems = isRTL ? reverseArray(items) : items;
166
174
  if (activeId2 == null) {
167
- return findFirstEnabledItem(allItems)?.id;
175
+ return (_a2 = findFirstEnabledItem(allItems)) == null ? void 0 : _a2.id;
168
176
  }
169
177
  const activeItem = allItems.find((item) => item.id === activeId2);
170
178
  if (!activeItem) {
171
- return findFirstEnabledItem(allItems)?.id;
179
+ return (_b = findFirstEnabledItem(allItems)) == null ? void 0 : _b.id;
172
180
  }
173
181
  const isGrid = !!activeItem.rowId;
174
182
  const activeIndex = allItems.indexOf(activeItem);
@@ -178,7 +186,7 @@ function createCompositeStore(props = {}) {
178
186
  const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
179
187
  const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
180
188
  nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
181
- return nextItem2?.id;
189
+ return nextItem2 == null ? void 0 : nextItem2.id;
182
190
  }
183
191
  const oppositeOrientation = getOppositeOrientation(
184
192
  // If it's a grid and orientation is not set, it's a next/previous call,
@@ -193,7 +201,7 @@ function createCompositeStore(props = {}) {
193
201
  const loopItems = canWrap && !hasNullItem ? allItems : getItemsInRow(allItems, activeItem.rowId);
194
202
  const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
195
203
  const nextItem2 = findFirstEnabledItem(sortedItems, activeId2);
196
- return nextItem2?.id;
204
+ return nextItem2 == null ? void 0 : nextItem2.id;
197
205
  }
198
206
  if (canWrap) {
199
207
  const nextItem2 = findFirstEnabledItem(
@@ -206,18 +214,16 @@ function createCompositeStore(props = {}) {
206
214
  hasNullItem ? nextItemsInRow : nextItems,
207
215
  activeId2
208
216
  );
209
- const nextId = hasNullItem ? nextItem2?.id || null : nextItem2?.id;
217
+ const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
210
218
  return nextId;
211
219
  }
212
220
  const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
213
221
  if (!nextItem && hasNullItem) {
214
222
  return null;
215
223
  }
216
- return nextItem?.id;
224
+ return nextItem == null ? void 0 : nextItem.id;
217
225
  };
218
- return {
219
- ...collection,
220
- ...composite,
226
+ return __spreadProps(__spreadValues(__spreadValues({}, collection), composite), {
221
227
  setBaseElement: (element) => composite.setState("baseElement", element),
222
228
  setActiveId: (id) => composite.setState("activeId", id),
223
229
  move: (id) => {
@@ -226,15 +232,22 @@ function createCompositeStore(props = {}) {
226
232
  composite.setState("activeId", id);
227
233
  composite.setState("moves", (moves) => moves + 1);
228
234
  },
229
- first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
230
- last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
235
+ first: () => {
236
+ var _a2;
237
+ return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
238
+ },
239
+ last: () => {
240
+ var _a2;
241
+ return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
242
+ },
231
243
  next: (skip) => {
232
244
  const { renderedItems, orientation } = composite.getState();
233
245
  return getNextId(renderedItems, orientation, false, skip);
234
246
  },
235
247
  previous: (skip) => {
248
+ var _a2;
236
249
  const { renderedItems, orientation, includesBaseElement } = composite.getState();
237
- const isGrid = !!findFirstEnabledItem(renderedItems)?.rowId;
250
+ const isGrid = !!((_a2 = findFirstEnabledItem(renderedItems)) == null ? void 0 : _a2.rowId);
238
251
  const hasNullItem = !isGrid && includesBaseElement;
239
252
  return getNextId(
240
253
  reverseArray(renderedItems),
@@ -278,7 +291,7 @@ function createCompositeStore(props = {}) {
278
291
  const hasNullItem = includesBaseElement;
279
292
  return getNextId(verticalItems, "vertical", hasNullItem, skip);
280
293
  }
281
- };
294
+ });
282
295
  }
283
296
 
284
297
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  canUseDOM
3
- } from "./UVCATTRC.js";
3
+ } from "./N6JW4ITM.js";
4
4
 
5
5
  // src/utils/platform.ts
6
6
  function isTouchDevice() {
@@ -0,0 +1,60 @@
1
+ import {
2
+ createDialogStore
3
+ } from "./MNNKHNLW.js";
4
+ import {
5
+ createStore,
6
+ mergeStore
7
+ } from "./BOKMNDR7.js";
8
+ import {
9
+ defaultValue
10
+ } from "./NWU4GBZ6.js";
11
+ import {
12
+ __objRest,
13
+ __spreadProps,
14
+ __spreadValues
15
+ } from "./4BKCJXBM.js";
16
+
17
+ // src/popover/popover-store.ts
18
+ function createPopoverStore(_a = {}) {
19
+ var _b = _a, {
20
+ popover: otherPopover
21
+ } = _b, props = __objRest(_b, [
22
+ "popover"
23
+ ]);
24
+ const store = mergeStore(
25
+ props.store,
26
+ otherPopover == null ? void 0 : otherPopover.omit(
27
+ "arrowElement",
28
+ "anchorElement",
29
+ "contentElement",
30
+ "popoverElement",
31
+ "disclosureElement"
32
+ )
33
+ );
34
+ const syncState = store == null ? void 0 : store.getState();
35
+ const dialog = createDialogStore(__spreadProps(__spreadValues({}, props), { store }));
36
+ const placement = defaultValue(
37
+ props.placement,
38
+ syncState == null ? void 0 : syncState.placement,
39
+ "bottom"
40
+ );
41
+ const initialState = __spreadProps(__spreadValues({}, dialog.getState()), {
42
+ placement,
43
+ currentPlacement: placement,
44
+ anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
45
+ popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
46
+ arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
47
+ rendered: Symbol("rendered")
48
+ });
49
+ const popover = createStore(initialState, dialog, store);
50
+ return __spreadProps(__spreadValues(__spreadValues({}, dialog), popover), {
51
+ setAnchorElement: (element) => popover.setState("anchorElement", element),
52
+ setPopoverElement: (element) => popover.setState("popoverElement", element),
53
+ setArrowElement: (element) => popover.setState("arrowElement", element),
54
+ render: () => popover.setState("rendered", Symbol("rendered"))
55
+ });
56
+ }
57
+
58
+ export {
59
+ createPopoverStore
60
+ };
@@ -1,27 +1,32 @@
1
1
  import {
2
2
  createStore
3
- } from "./NA5BK7DD.js";
3
+ } from "./BOKMNDR7.js";
4
4
  import {
5
5
  defaultValue
6
- } from "./RMD7SNCC.js";
6
+ } from "./NWU4GBZ6.js";
7
+ import {
8
+ __spreadProps,
9
+ __spreadValues
10
+ } from "./4BKCJXBM.js";
7
11
 
8
12
  // src/disclosure/disclosure-store.ts
9
13
  function createDisclosureStore(props = {}) {
10
- const syncState = props.store?.getState();
14
+ var _a;
15
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
11
16
  const open = defaultValue(
12
17
  props.open,
13
- syncState?.open,
18
+ syncState == null ? void 0 : syncState.open,
14
19
  props.defaultOpen,
15
20
  false
16
21
  );
17
- const animated = defaultValue(props.animated, syncState?.animated, false);
22
+ const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
18
23
  const initialState = {
19
24
  open,
20
25
  animated,
21
26
  animating: !!animated && open,
22
27
  mounted: open,
23
- contentElement: defaultValue(syncState?.contentElement, null),
24
- disclosureElement: defaultValue(syncState?.disclosureElement, null)
28
+ contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
29
+ disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
25
30
  };
26
31
  const disclosure = createStore(initialState, props.store);
27
32
  disclosure.setup(
@@ -54,8 +59,7 @@ function createDisclosureStore(props = {}) {
54
59
  ["open", "animating"]
55
60
  )
56
61
  );
57
- return {
58
- ...disclosure,
62
+ return __spreadProps(__spreadValues({}, disclosure), {
59
63
  setOpen: (value) => disclosure.setState("open", value),
60
64
  show: () => disclosure.setState("open", true),
61
65
  hide: () => disclosure.setState("open", false),
@@ -63,7 +67,7 @@ function createDisclosureStore(props = {}) {
63
67
  stopAnimation: () => disclosure.setState("animating", false),
64
68
  setContentElement: (value) => disclosure.setState("contentElement", value),
65
69
  setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
66
- };
70
+ });
67
71
  }
68
72
 
69
73
  export {
@@ -1,26 +1,30 @@
1
1
  import {
2
2
  createStore
3
- } from "../__chunks/NA5BK7DD.js";
3
+ } from "../__chunks/BOKMNDR7.js";
4
4
  import {
5
5
  defaultValue
6
- } from "../__chunks/RMD7SNCC.js";
6
+ } from "../__chunks/NWU4GBZ6.js";
7
+ import {
8
+ __spreadProps,
9
+ __spreadValues
10
+ } from "../__chunks/4BKCJXBM.js";
7
11
 
8
12
  // src/checkbox/checkbox-store.ts
9
13
  function createCheckboxStore(props = {}) {
10
- const syncState = props.store?.getState();
14
+ var _a;
15
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
11
16
  const initialState = {
12
17
  value: defaultValue(
13
18
  props.value,
14
- syncState?.value,
19
+ syncState == null ? void 0 : syncState.value,
15
20
  props.defaultValue,
16
21
  false
17
22
  )
18
23
  };
19
24
  const checkbox = createStore(initialState, props.store);
20
- return {
21
- ...checkbox,
25
+ return __spreadProps(__spreadValues({}, checkbox), {
22
26
  setValue: (value) => checkbox.setState("value", value)
23
- };
27
+ });
24
28
  }
25
29
  export {
26
30
  createCheckboxStore