@ariakit/core 0.1.3 → 0.1.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 (90) hide show
  1. package/CHANGELOG.md +16 -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/{2YFRPUZP.cjs → DBHIHK7C.cjs} +6 -6
  6. package/cjs/__chunks/{W5IHD6VG.cjs → EUJ6NNA6.cjs} +56 -43
  7. package/cjs/__chunks/{4DQ3OTE7.cjs → FXEBKN6G.cjs} +22 -17
  8. package/cjs/__chunks/{ZJEEK57E.cjs → HEFJPUYD.cjs} +2 -2
  9. package/cjs/__chunks/LBTLD2RB.cjs +58 -0
  10. package/cjs/__chunks/{QNEPGQLL.cjs → M6ZA7XUP.cjs} +6 -2
  11. package/cjs/__chunks/{HLVPXX7H.cjs → SDBF6KIY.cjs} +107 -107
  12. package/cjs/__chunks/{OFNGELMA.cjs → ZNW4LSWU.cjs} +8 -6
  13. package/cjs/checkbox/checkbox-store.cjs +14 -10
  14. package/cjs/checkbox/checkbox-store.d.ts +7 -0
  15. package/cjs/collection/collection-store.cjs +6 -5
  16. package/cjs/combobox/combobox-store.cjs +49 -48
  17. package/cjs/combobox/combobox-store.d.ts +24 -0
  18. package/cjs/composite/composite-overflow-store.cjs +7 -6
  19. package/cjs/composite/composite-store.cjs +7 -6
  20. package/cjs/composite/composite-store.d.ts +38 -34
  21. package/cjs/dialog/dialog-store.cjs +6 -5
  22. package/cjs/disclosure/disclosure-store.cjs +5 -4
  23. package/cjs/disclosure/disclosure-store.d.ts +36 -6
  24. package/cjs/form/form-store.cjs +38 -35
  25. package/cjs/hovercard/hovercard-store.cjs +8 -7
  26. package/cjs/index.cjs +3 -1
  27. package/cjs/menu/menu-bar-store.cjs +17 -13
  28. package/cjs/menu/menu-store.cjs +41 -43
  29. package/cjs/popover/popover-store.cjs +7 -6
  30. package/cjs/radio/radio-store.cjs +25 -24
  31. package/cjs/select/select-store.cjs +42 -42
  32. package/cjs/select/select-store.d.ts +16 -0
  33. package/cjs/tab/tab-store.cjs +29 -28
  34. package/cjs/tab/tab-store.d.ts +9 -0
  35. package/cjs/toolbar/toolbar-store.cjs +17 -13
  36. package/cjs/tooltip/tooltip-store.cjs +24 -25
  37. package/cjs/tsconfig.build.tsbuildinfo +1 -1
  38. package/cjs/utils/array.cjs +1 -0
  39. package/cjs/utils/dom.cjs +3 -2
  40. package/cjs/utils/events.cjs +14 -9
  41. package/cjs/utils/focus.cjs +24 -14
  42. package/cjs/utils/misc.cjs +3 -2
  43. package/cjs/utils/platform.cjs +4 -3
  44. package/cjs/utils/store.cjs +4 -3
  45. package/esm/__chunks/4BKCJXBM.js +37 -0
  46. package/esm/__chunks/AHZW5LR4.js +58 -0
  47. package/esm/__chunks/{NA5BK7DD.js → BOKMNDR7.js} +22 -10
  48. package/esm/__chunks/{6PEWNRTN.js → CUW3E24J.js} +100 -100
  49. package/esm/__chunks/{WFGVC6LE.js → EWHSN7GO.js} +17 -12
  50. package/esm/__chunks/{4T5RHRE5.js → MNNKHNLW.js} +1 -1
  51. package/esm/__chunks/{UVCATTRC.js → N6JW4ITM.js} +7 -5
  52. package/esm/__chunks/{RMD7SNCC.js → NWU4GBZ6.js} +5 -1
  53. package/esm/__chunks/{X7MJ3FB5.js → R6VHFWTV.js} +49 -36
  54. package/esm/__chunks/{DXA3K2FY.js → TFBCK4JB.js} +1 -1
  55. package/esm/__chunks/{IOAGNCXX.js → ZV2GEGPL.js} +14 -10
  56. package/esm/checkbox/checkbox-store.d.ts +7 -0
  57. package/esm/checkbox/checkbox-store.js +11 -7
  58. package/esm/collection/collection-store.js +5 -4
  59. package/esm/combobox/combobox-store.d.ts +24 -0
  60. package/esm/combobox/combobox-store.js +34 -33
  61. package/esm/composite/composite-overflow-store.js +6 -5
  62. package/esm/composite/composite-store.d.ts +38 -34
  63. package/esm/composite/composite-store.js +6 -5
  64. package/esm/dialog/dialog-store.js +5 -4
  65. package/esm/disclosure/disclosure-store.d.ts +36 -6
  66. package/esm/disclosure/disclosure-store.js +4 -3
  67. package/esm/form/form-store.js +24 -21
  68. package/esm/hovercard/hovercard-store.js +7 -6
  69. package/esm/index.js +2 -0
  70. package/esm/menu/menu-bar-store.js +15 -11
  71. package/esm/menu/menu-store.js +31 -33
  72. package/esm/popover/popover-store.js +6 -5
  73. package/esm/radio/radio-store.js +22 -21
  74. package/esm/select/select-store.d.ts +16 -0
  75. package/esm/select/select-store.js +29 -29
  76. package/esm/tab/tab-store.d.ts +9 -0
  77. package/esm/tab/tab-store.js +23 -22
  78. package/esm/toolbar/toolbar-store.js +15 -11
  79. package/esm/tooltip/tooltip-store.js +20 -21
  80. package/esm/tsconfig.build.tsbuildinfo +1 -1
  81. package/esm/utils/array.js +1 -0
  82. package/esm/utils/dom.js +2 -1
  83. package/esm/utils/events.js +10 -5
  84. package/esm/utils/focus.js +14 -4
  85. package/esm/utils/misc.js +2 -1
  86. package/esm/utils/platform.js +3 -2
  87. package/esm/utils/store.js +3 -2
  88. package/package.json +1 -1
  89. package/cjs/__chunks/DQHU5K4Q.cjs +0 -57
  90. package/esm/__chunks/6HMPWUDT.js +0 -57
@@ -1,32 +1,39 @@
1
1
  import {
2
2
  createPopoverStore
3
- } from "../__chunks/6PEWNRTN.js";
4
- import "../__chunks/4T5RHRE5.js";
5
- import "../__chunks/IOAGNCXX.js";
3
+ } from "../__chunks/CUW3E24J.js";
4
+ import "../__chunks/MNNKHNLW.js";
5
+ import "../__chunks/ZV2GEGPL.js";
6
6
  import {
7
7
  createCompositeStore
8
- } from "../__chunks/X7MJ3FB5.js";
9
- import "../__chunks/WFGVC6LE.js";
8
+ } from "../__chunks/R6VHFWTV.js";
9
+ import "../__chunks/EWHSN7GO.js";
10
10
  import {
11
11
  createStore,
12
12
  mergeStore
13
- } from "../__chunks/NA5BK7DD.js";
13
+ } from "../__chunks/BOKMNDR7.js";
14
14
  import {
15
15
  defaultValue
16
- } from "../__chunks/RMD7SNCC.js";
17
- import "../__chunks/UVCATTRC.js";
16
+ } from "../__chunks/NWU4GBZ6.js";
17
+ import "../__chunks/N6JW4ITM.js";
18
18
  import {
19
19
  toArray
20
20
  } from "../__chunks/5XEKIOCW.js";
21
+ import {
22
+ __objRest,
23
+ __spreadProps,
24
+ __spreadValues
25
+ } from "../__chunks/4BKCJXBM.js";
21
26
 
22
27
  // src/select/select-store.ts
23
- function createSelectStore({
24
- combobox,
25
- ...props
26
- } = {}) {
28
+ function createSelectStore(_a = {}) {
29
+ var _b = _a, {
30
+ combobox
31
+ } = _b, props = __objRest(_b, [
32
+ "combobox"
33
+ ]);
27
34
  const store = mergeStore(
28
35
  props.store,
29
- combobox?.omit(
36
+ combobox == null ? void 0 : combobox.omit(
30
37
  "value",
31
38
  "items",
32
39
  "renderedItems",
@@ -39,8 +46,7 @@ function createSelectStore({
39
46
  )
40
47
  );
41
48
  const syncState = store.getState();
42
- const composite = createCompositeStore({
43
- ...props,
49
+ const composite = createCompositeStore(__spreadProps(__spreadValues({}, props), {
44
50
  store,
45
51
  virtualFocus: defaultValue(
46
52
  props.virtualFocus,
@@ -63,20 +69,17 @@ function createSelectStore({
63
69
  syncState.orientation,
64
70
  "vertical"
65
71
  )
66
- });
67
- const popover = createPopoverStore({
68
- ...props,
72
+ }));
73
+ const popover = createPopoverStore(__spreadProps(__spreadValues({}, props), {
69
74
  store,
70
75
  placement: defaultValue(
71
76
  props.placement,
72
77
  syncState.placement,
73
78
  "bottom-start"
74
79
  )
75
- });
80
+ }));
76
81
  const initialValue = new String("");
77
- const initialState = {
78
- ...composite.getState(),
79
- ...popover.getState(),
82
+ const initialState = __spreadProps(__spreadValues(__spreadValues({}, composite.getState()), popover.getState()), {
80
83
  value: defaultValue(
81
84
  props.value,
82
85
  syncState.value,
@@ -90,7 +93,7 @@ function createSelectStore({
90
93
  ),
91
94
  selectElement: defaultValue(syncState.selectElement, null),
92
95
  labelElement: defaultValue(syncState.labelElement, null)
93
- };
96
+ });
94
97
  const select = createStore(initialState, composite, popover, store);
95
98
  select.setup(
96
99
  () => select.sync(
@@ -102,7 +105,7 @@ function createSelectStore({
102
105
  const item = state.items.find(
103
106
  (item2) => !item2.disabled && item2.value != null
104
107
  );
105
- if (item?.value == null)
108
+ if ((item == null ? void 0 : item.value) == null)
106
109
  return;
107
110
  select.setState("value", item.value);
108
111
  },
@@ -150,14 +153,11 @@ function createSelectStore({
150
153
  ["setValueOnMove", "moves"]
151
154
  )
152
155
  );
153
- return {
154
- ...composite,
155
- ...popover,
156
- ...select,
156
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, composite), popover), select), {
157
157
  setValue: (value) => select.setState("value", value),
158
158
  setSelectElement: (element) => select.setState("selectElement", element),
159
159
  setLabelElement: (element) => select.setState("labelElement", element)
160
- };
160
+ });
161
161
  }
162
162
  export {
163
163
  createSelectStore
@@ -23,11 +23,17 @@ export interface TabStoreState extends CompositeStoreState<Item> {
23
23
  /**
24
24
  * The id of the tab whose panel is currently visible. If it's `undefined`, it
25
25
  * will be automatically set to the first enabled tab.
26
+ *
27
+ * Live examples:
28
+ * - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
26
29
  */
27
30
  selectedId: TabStoreState["activeId"];
28
31
  /**
29
32
  * Whether the tab should be selected when it receives focus. If it's set to
30
33
  * `false`, the tab will be selected only when it's clicked.
34
+ *
35
+ * Live examples:
36
+ * - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
31
37
  * @default true
32
38
  */
33
39
  selectOnMove?: boolean;
@@ -36,6 +42,9 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<Item> {
36
42
  /**
37
43
  * Sets the `selectedId` state without moving focus. If you want to move focus,
38
44
  * use the `select` function instead.
45
+ *
46
+ * Live examples:
47
+ * - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
39
48
  * @example
40
49
  * // Selects the tab with id "tab-1"
41
50
  * store.setSelectedId("tab-1");
@@ -1,45 +1,48 @@
1
1
  import {
2
2
  createCompositeStore
3
- } from "../__chunks/X7MJ3FB5.js";
3
+ } from "../__chunks/R6VHFWTV.js";
4
4
  import {
5
5
  createCollectionStore
6
- } from "../__chunks/WFGVC6LE.js";
6
+ } from "../__chunks/EWHSN7GO.js";
7
7
  import {
8
8
  createStore
9
- } from "../__chunks/NA5BK7DD.js";
9
+ } from "../__chunks/BOKMNDR7.js";
10
10
  import {
11
11
  defaultValue
12
- } from "../__chunks/RMD7SNCC.js";
13
- import "../__chunks/UVCATTRC.js";
12
+ } from "../__chunks/NWU4GBZ6.js";
13
+ import "../__chunks/N6JW4ITM.js";
14
14
  import "../__chunks/5XEKIOCW.js";
15
+ import {
16
+ __spreadProps,
17
+ __spreadValues
18
+ } from "../__chunks/4BKCJXBM.js";
15
19
 
16
20
  // src/tab/tab-store.ts
17
21
  function createTabStore(props = {}) {
18
- const syncState = props.store?.getState();
19
- const composite = createCompositeStore({
20
- ...props,
22
+ var _a;
23
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
24
+ const composite = createCompositeStore(__spreadProps(__spreadValues({}, props), {
21
25
  orientation: defaultValue(
22
26
  props.orientation,
23
- syncState?.orientation,
27
+ syncState == null ? void 0 : syncState.orientation,
24
28
  "horizontal"
25
29
  ),
26
- focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true)
27
- });
30
+ focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
31
+ }));
28
32
  const panels = createCollectionStore();
29
- const initialState = {
30
- ...composite.getState(),
33
+ const initialState = __spreadProps(__spreadValues({}, composite.getState()), {
31
34
  selectedId: defaultValue(
32
35
  props.selectedId,
33
- syncState?.selectedId,
36
+ syncState == null ? void 0 : syncState.selectedId,
34
37
  props.defaultSelectedId,
35
38
  void 0
36
39
  ),
37
40
  selectOnMove: defaultValue(
38
41
  props.selectOnMove,
39
- syncState?.selectOnMove,
42
+ syncState == null ? void 0 : syncState.selectOnMove,
40
43
  true
41
44
  )
42
- };
45
+ });
43
46
  const tab = createStore(initialState, composite, props.store);
44
47
  tab.setup(
45
48
  () => tab.sync(() => {
@@ -77,7 +80,7 @@ function createTabStore(props = {}) {
77
80
  const tabItem2 = renderedItems.find(
78
81
  (item) => !item.disabled && !item.dimmed
79
82
  );
80
- tab.setState("selectedId", tabItem2?.id);
83
+ tab.setState("selectedId", tabItem2 == null ? void 0 : tabItem2.id);
81
84
  }
82
85
  },
83
86
  ["selectedId", "renderedItems"]
@@ -101,7 +104,7 @@ function createTabStore(props = {}) {
101
104
  const tabItem = tabs[i];
102
105
  if (!tabItem)
103
106
  return;
104
- panels.renderItem({ ...panel, tabId: tabItem.id });
107
+ panels.renderItem(__spreadProps(__spreadValues({}, panel), { tabId: tabItem.id }));
105
108
  });
106
109
  },
107
110
  ["renderedItems"]
@@ -110,16 +113,14 @@ function createTabStore(props = {}) {
110
113
  ["renderedItems"]
111
114
  )
112
115
  );
113
- return {
114
- ...composite,
115
- ...tab,
116
+ return __spreadProps(__spreadValues(__spreadValues({}, composite), tab), {
116
117
  panels,
117
118
  setSelectedId: (id) => tab.setState("selectedId", id),
118
119
  select: (id) => {
119
120
  tab.setState("selectedId", id);
120
121
  composite.move(id);
121
122
  }
122
- };
123
+ });
123
124
  }
124
125
  export {
125
126
  createTabStore
@@ -1,26 +1,30 @@
1
1
  import {
2
2
  createCompositeStore
3
- } from "../__chunks/X7MJ3FB5.js";
4
- import "../__chunks/WFGVC6LE.js";
5
- import "../__chunks/NA5BK7DD.js";
3
+ } from "../__chunks/R6VHFWTV.js";
4
+ import "../__chunks/EWHSN7GO.js";
5
+ import "../__chunks/BOKMNDR7.js";
6
6
  import {
7
7
  defaultValue
8
- } from "../__chunks/RMD7SNCC.js";
9
- import "../__chunks/UVCATTRC.js";
8
+ } from "../__chunks/NWU4GBZ6.js";
9
+ import "../__chunks/N6JW4ITM.js";
10
10
  import "../__chunks/5XEKIOCW.js";
11
+ import {
12
+ __spreadProps,
13
+ __spreadValues
14
+ } from "../__chunks/4BKCJXBM.js";
11
15
 
12
16
  // src/toolbar/toolbar-store.ts
13
17
  function createToolbarStore(props = {}) {
14
- const syncState = props.store?.getState();
15
- return createCompositeStore({
16
- ...props,
18
+ var _a;
19
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
20
+ return createCompositeStore(__spreadProps(__spreadValues({}, props), {
17
21
  orientation: defaultValue(
18
22
  props.orientation,
19
- syncState?.orientation,
23
+ syncState == null ? void 0 : syncState.orientation,
20
24
  "horizontal"
21
25
  ),
22
- focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true)
23
- });
26
+ focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
27
+ }));
24
28
  }
25
29
  export {
26
30
  createToolbarStore
@@ -1,16 +1,20 @@
1
1
  import {
2
2
  createPopoverStore
3
- } from "../__chunks/6PEWNRTN.js";
4
- import "../__chunks/4T5RHRE5.js";
3
+ } from "../__chunks/CUW3E24J.js";
4
+ import "../__chunks/MNNKHNLW.js";
5
5
  import {
6
6
  createDisclosureStore
7
- } from "../__chunks/IOAGNCXX.js";
7
+ } from "../__chunks/ZV2GEGPL.js";
8
8
  import {
9
9
  createStore
10
- } from "../__chunks/NA5BK7DD.js";
10
+ } from "../__chunks/BOKMNDR7.js";
11
11
  import {
12
12
  defaultValue
13
- } from "../__chunks/RMD7SNCC.js";
13
+ } from "../__chunks/NWU4GBZ6.js";
14
+ import {
15
+ __spreadProps,
16
+ __spreadValues
17
+ } from "../__chunks/4BKCJXBM.js";
14
18
 
15
19
  // src/tooltip/tooltip-store.ts
16
20
  var tooltips = createStore({ activeRef: null });
@@ -19,23 +23,22 @@ function afterTimeout(timeoutMs, cb) {
19
23
  return () => clearTimeout(timeoutId);
20
24
  }
21
25
  function createTooltipStore(props = {}) {
22
- const syncState = props.store?.getState();
23
- const open = defaultValue(props.open, syncState?.open, false);
24
- const disclosure = createDisclosureStore({ ...props, open });
25
- const popover = createPopoverStore({
26
- ...props,
26
+ var _a;
27
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
28
+ const open = defaultValue(props.open, syncState == null ? void 0 : syncState.open, false);
29
+ const disclosure = createDisclosureStore(__spreadProps(__spreadValues({}, props), { open }));
30
+ const popover = createPopoverStore(__spreadProps(__spreadValues({}, props), {
27
31
  open,
28
32
  placement: defaultValue(
29
33
  props.placement,
30
- syncState?.placement,
34
+ syncState == null ? void 0 : syncState.placement,
31
35
  "top"
32
36
  ),
33
- gutter: defaultValue(props.gutter, syncState?.gutter, 8)
37
+ gutter: defaultValue(props.gutter, syncState == null ? void 0 : syncState.gutter, 8)
38
+ }));
39
+ const initialState = __spreadProps(__spreadValues({}, popover.getState()), {
40
+ timeout: defaultValue(props.timeout, syncState == null ? void 0 : syncState.timeout, 0)
34
41
  });
35
- const initialState = {
36
- ...popover.getState(),
37
- timeout: defaultValue(props.timeout, syncState?.timeout, 0)
38
- };
39
42
  const tooltip = createStore(
40
43
  initialState,
41
44
  popover,
@@ -87,11 +90,7 @@ function createTooltipStore(props = {}) {
87
90
  (activeRef) => activeRef === ref ? null : activeRef
88
91
  );
89
92
  });
90
- return {
91
- ...popover,
92
- ...disclosure,
93
- ...tooltip
94
- };
93
+ return __spreadValues(__spreadValues(__spreadValues({}, popover), disclosure), tooltip);
95
94
  }
96
95
  export {
97
96
  createTooltipStore