@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
@@ -1,32 +1,39 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _HLVPXX7Hcjs = require('../__chunks/HLVPXX7H.cjs');
4
- require('../__chunks/ZJEEK57E.cjs');
5
- require('../__chunks/QYB6XH64.cjs');
3
+ var _RD3S4VKYcjs = require('../__chunks/RD3S4VKY.cjs');
4
+ require('../__chunks/HEFJPUYD.cjs');
5
+ require('../__chunks/27ZAGOYG.cjs');
6
6
 
7
7
 
8
- var _W5IHD6VGcjs = require('../__chunks/W5IHD6VG.cjs');
9
- require('../__chunks/4DQ3OTE7.cjs');
8
+ var _EUJ6NNA6cjs = require('../__chunks/EUJ6NNA6.cjs');
9
+ require('../__chunks/FXEBKN6G.cjs');
10
10
 
11
11
 
12
12
 
13
- var _ZPOXPO2Lcjs = require('../__chunks/ZPOXPO2L.cjs');
13
+ var _6SPJEESBcjs = require('../__chunks/6SPJEESB.cjs');
14
14
 
15
15
 
16
- var _QNEPGQLLcjs = require('../__chunks/QNEPGQLL.cjs');
17
- require('../__chunks/OFNGELMA.cjs');
16
+ var _M6ZA7XUPcjs = require('../__chunks/M6ZA7XUP.cjs');
17
+ require('../__chunks/ZNW4LSWU.cjs');
18
18
 
19
19
 
20
20
  var _GDZQUFNPcjs = require('../__chunks/GDZQUFNP.cjs');
21
21
 
22
+
23
+
24
+
25
+ var _6455U47Tcjs = require('../__chunks/6455U47T.cjs');
26
+
22
27
  // src/select/select-store.ts
23
- function createSelectStore({
24
- combobox,
25
- ...props
26
- } = {}) {
27
- const store = _ZPOXPO2Lcjs.mergeStore.call(void 0,
28
+ function createSelectStore(_a = {}) {
29
+ var _b = _a, {
30
+ combobox
31
+ } = _b, props = _6455U47Tcjs.__objRest.call(void 0, _b, [
32
+ "combobox"
33
+ ]);
34
+ const store = _6SPJEESBcjs.mergeStore.call(void 0,
28
35
  props.store,
29
- _optionalChain([combobox, 'optionalAccess', _ => _.omit, 'call', _2 => _2(
36
+ combobox == null ? void 0 : combobox.omit(
30
37
  "value",
31
38
  "items",
32
39
  "renderedItems",
@@ -36,62 +43,58 @@ function createSelectStore({
36
43
  "contentElement",
37
44
  "popoverElement",
38
45
  "disclosureElement"
39
- )])
46
+ )
40
47
  );
41
48
  const syncState = store.getState();
42
- const composite = _W5IHD6VGcjs.createCompositeStore.call(void 0, {
43
- ...props,
49
+ const composite = _EUJ6NNA6cjs.createCompositeStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
44
50
  store,
45
- virtualFocus: _QNEPGQLLcjs.defaultValue.call(void 0,
51
+ virtualFocus: _M6ZA7XUPcjs.defaultValue.call(void 0,
46
52
  props.virtualFocus,
47
53
  syncState.virtualFocus,
48
54
  true
49
55
  ),
50
- includesBaseElement: _QNEPGQLLcjs.defaultValue.call(void 0,
56
+ includesBaseElement: _M6ZA7XUPcjs.defaultValue.call(void 0,
51
57
  props.includesBaseElement,
52
58
  syncState.includesBaseElement,
53
59
  false
54
60
  ),
55
- activeId: _QNEPGQLLcjs.defaultValue.call(void 0,
61
+ activeId: _M6ZA7XUPcjs.defaultValue.call(void 0,
56
62
  props.activeId,
57
63
  syncState.activeId,
58
64
  props.defaultActiveId,
59
65
  null
60
66
  ),
61
- orientation: _QNEPGQLLcjs.defaultValue.call(void 0,
67
+ orientation: _M6ZA7XUPcjs.defaultValue.call(void 0,
62
68
  props.orientation,
63
69
  syncState.orientation,
64
70
  "vertical"
65
71
  )
66
- });
67
- const popover = _HLVPXX7Hcjs.createPopoverStore.call(void 0, {
68
- ...props,
72
+ }));
73
+ const popover = _RD3S4VKYcjs.createPopoverStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
69
74
  store,
70
- placement: _QNEPGQLLcjs.defaultValue.call(void 0,
75
+ placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
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(),
80
- value: _QNEPGQLLcjs.defaultValue.call(void 0,
82
+ const initialState = _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, composite.getState()), popover.getState()), {
83
+ value: _M6ZA7XUPcjs.defaultValue.call(void 0,
81
84
  props.value,
82
85
  syncState.value,
83
86
  props.defaultValue,
84
87
  initialValue
85
88
  ),
86
- setValueOnMove: _QNEPGQLLcjs.defaultValue.call(void 0,
89
+ setValueOnMove: _M6ZA7XUPcjs.defaultValue.call(void 0,
87
90
  props.setValueOnMove,
88
91
  syncState.setValueOnMove,
89
92
  false
90
93
  ),
91
- selectElement: _QNEPGQLLcjs.defaultValue.call(void 0, syncState.selectElement, null),
92
- labelElement: _QNEPGQLLcjs.defaultValue.call(void 0, syncState.labelElement, null)
93
- };
94
- const select = _ZPOXPO2Lcjs.createStore.call(void 0, initialState, composite, popover, store);
94
+ selectElement: _M6ZA7XUPcjs.defaultValue.call(void 0, syncState.selectElement, null),
95
+ labelElement: _M6ZA7XUPcjs.defaultValue.call(void 0, syncState.labelElement, null)
96
+ });
97
+ const select = _6SPJEESBcjs.createStore.call(void 0, initialState, composite, popover, store);
95
98
  select.setup(
96
99
  () => select.sync(
97
100
  (state) => {
@@ -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 (_optionalChain([item, 'optionalAccess', _3 => _3.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 _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, 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
 
163
163
 
@@ -1,46 +1,49 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _W5IHD6VGcjs = require('../__chunks/W5IHD6VG.cjs');
3
+ var _EUJ6NNA6cjs = require('../__chunks/EUJ6NNA6.cjs');
4
4
 
5
5
 
6
- var _4DQ3OTE7cjs = require('../__chunks/4DQ3OTE7.cjs');
6
+ var _FXEBKN6Gcjs = require('../__chunks/FXEBKN6G.cjs');
7
7
 
8
8
 
9
- var _ZPOXPO2Lcjs = require('../__chunks/ZPOXPO2L.cjs');
9
+ var _6SPJEESBcjs = require('../__chunks/6SPJEESB.cjs');
10
10
 
11
11
 
12
- var _QNEPGQLLcjs = require('../__chunks/QNEPGQLL.cjs');
13
- require('../__chunks/OFNGELMA.cjs');
12
+ var _M6ZA7XUPcjs = require('../__chunks/M6ZA7XUP.cjs');
13
+ require('../__chunks/ZNW4LSWU.cjs');
14
14
  require('../__chunks/GDZQUFNP.cjs');
15
15
 
16
+
17
+
18
+ var _6455U47Tcjs = require('../__chunks/6455U47T.cjs');
19
+
16
20
  // src/tab/tab-store.ts
17
21
  function createTabStore(props = {}) {
18
- const syncState = _optionalChain([props, 'access', _ => _.store, 'optionalAccess', _2 => _2.getState, 'call', _3 => _3()]);
19
- const composite = _W5IHD6VGcjs.createCompositeStore.call(void 0, {
20
- ...props,
21
- orientation: _QNEPGQLLcjs.defaultValue.call(void 0,
22
+ var _a;
23
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
24
+ const composite = _EUJ6NNA6cjs.createCompositeStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
25
+ orientation: _M6ZA7XUPcjs.defaultValue.call(void 0,
22
26
  props.orientation,
23
- _optionalChain([syncState, 'optionalAccess', _4 => _4.orientation]),
27
+ syncState == null ? void 0 : syncState.orientation,
24
28
  "horizontal"
25
29
  ),
26
- focusLoop: _QNEPGQLLcjs.defaultValue.call(void 0, props.focusLoop, _optionalChain([syncState, 'optionalAccess', _5 => _5.focusLoop]), true)
27
- });
28
- const panels = _4DQ3OTE7cjs.createCollectionStore.call(void 0, );
29
- const initialState = {
30
- ...composite.getState(),
31
- selectedId: _QNEPGQLLcjs.defaultValue.call(void 0,
30
+ focusLoop: _M6ZA7XUPcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
31
+ }));
32
+ const panels = _FXEBKN6Gcjs.createCollectionStore.call(void 0, );
33
+ const initialState = _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, composite.getState()), {
34
+ selectedId: _M6ZA7XUPcjs.defaultValue.call(void 0,
32
35
  props.selectedId,
33
- _optionalChain([syncState, 'optionalAccess', _6 => _6.selectedId]),
36
+ syncState == null ? void 0 : syncState.selectedId,
34
37
  props.defaultSelectedId,
35
38
  void 0
36
39
  ),
37
- selectOnMove: _QNEPGQLLcjs.defaultValue.call(void 0,
40
+ selectOnMove: _M6ZA7XUPcjs.defaultValue.call(void 0,
38
41
  props.selectOnMove,
39
- _optionalChain([syncState, 'optionalAccess', _7 => _7.selectOnMove]),
42
+ syncState == null ? void 0 : syncState.selectOnMove,
40
43
  true
41
44
  )
42
- };
43
- const tab = _ZPOXPO2Lcjs.createStore.call(void 0, initialState, composite, props.store);
45
+ });
46
+ const tab = _6SPJEESBcjs.createStore.call(void 0, initialState, composite, props.store);
44
47
  tab.setup(
45
48
  () => tab.sync(() => {
46
49
  const { activeId, selectOnMove } = tab.getState();
@@ -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", _optionalChain([tabItem2, 'optionalAccess', _8 => _8.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(_6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, 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 _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, 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
 
125
126
 
@@ -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,26 +1,30 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _W5IHD6VGcjs = require('../__chunks/W5IHD6VG.cjs');
4
- require('../__chunks/4DQ3OTE7.cjs');
5
- require('../__chunks/ZPOXPO2L.cjs');
3
+ var _EUJ6NNA6cjs = require('../__chunks/EUJ6NNA6.cjs');
4
+ require('../__chunks/FXEBKN6G.cjs');
5
+ require('../__chunks/6SPJEESB.cjs');
6
6
 
7
7
 
8
- var _QNEPGQLLcjs = require('../__chunks/QNEPGQLL.cjs');
9
- require('../__chunks/OFNGELMA.cjs');
8
+ var _M6ZA7XUPcjs = require('../__chunks/M6ZA7XUP.cjs');
9
+ require('../__chunks/ZNW4LSWU.cjs');
10
10
  require('../__chunks/GDZQUFNP.cjs');
11
11
 
12
+
13
+
14
+ var _6455U47Tcjs = require('../__chunks/6455U47T.cjs');
15
+
12
16
  // src/toolbar/toolbar-store.ts
13
17
  function createToolbarStore(props = {}) {
14
- const syncState = _optionalChain([props, 'access', _ => _.store, 'optionalAccess', _2 => _2.getState, 'call', _3 => _3()]);
15
- return _W5IHD6VGcjs.createCompositeStore.call(void 0, {
16
- ...props,
17
- orientation: _QNEPGQLLcjs.defaultValue.call(void 0,
18
+ var _a;
19
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
20
+ return _EUJ6NNA6cjs.createCompositeStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
21
+ orientation: _M6ZA7XUPcjs.defaultValue.call(void 0,
18
22
  props.orientation,
19
- _optionalChain([syncState, 'optionalAccess', _4 => _4.orientation]),
23
+ syncState == null ? void 0 : syncState.orientation,
20
24
  "horizontal"
21
25
  ),
22
- focusLoop: _QNEPGQLLcjs.defaultValue.call(void 0, props.focusLoop, _optionalChain([syncState, 'optionalAccess', _5 => _5.focusLoop]), true)
23
- });
26
+ focusLoop: _M6ZA7XUPcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
27
+ }));
24
28
  }
25
29
 
26
30
 
@@ -1,97 +1,49 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _HLVPXX7Hcjs = require('../__chunks/HLVPXX7H.cjs');
4
- require('../__chunks/ZJEEK57E.cjs');
3
+ var _CNODBYSGcjs = require('../__chunks/CNODBYSG.cjs');
4
+ require('../__chunks/RD3S4VKY.cjs');
5
+ require('../__chunks/HEFJPUYD.cjs');
6
+ require('../__chunks/27ZAGOYG.cjs');
5
7
 
6
8
 
7
- var _QYB6XH64cjs = require('../__chunks/QYB6XH64.cjs');
9
+ var _6SPJEESBcjs = require('../__chunks/6SPJEESB.cjs');
8
10
 
9
11
 
10
- var _ZPOXPO2Lcjs = require('../__chunks/ZPOXPO2L.cjs');
12
+ var _M6ZA7XUPcjs = require('../__chunks/M6ZA7XUP.cjs');
11
13
 
12
14
 
13
- var _QNEPGQLLcjs = require('../__chunks/QNEPGQLL.cjs');
15
+
16
+ var _6455U47Tcjs = require('../__chunks/6455U47T.cjs');
14
17
 
15
18
  // src/tooltip/tooltip-store.ts
16
- var tooltips = _ZPOXPO2Lcjs.createStore.call(void 0, { activeRef: null });
17
- function afterTimeout(timeoutMs, cb) {
18
- const timeoutId = setTimeout(cb, timeoutMs);
19
- return () => clearTimeout(timeoutId);
20
- }
21
19
  function createTooltipStore(props = {}) {
22
- const syncState = _optionalChain([props, 'access', _ => _.store, 'optionalAccess', _2 => _2.getState, 'call', _3 => _3()]);
23
- const open = _QNEPGQLLcjs.defaultValue.call(void 0, props.open, _optionalChain([syncState, 'optionalAccess', _4 => _4.open]), false);
24
- const disclosure = _QYB6XH64cjs.createDisclosureStore.call(void 0, { ...props, open });
25
- const popover = _HLVPXX7Hcjs.createPopoverStore.call(void 0, {
26
- ...props,
27
- open,
28
- placement: _QNEPGQLLcjs.defaultValue.call(void 0,
20
+ var _a;
21
+ const syncState = (_a = props.store) == null ? void 0 : _a.getState();
22
+ const hovercard = _CNODBYSGcjs.createHovercardStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
23
+ placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
29
24
  props.placement,
30
- _optionalChain([syncState, 'optionalAccess', _5 => _5.placement]),
25
+ syncState == null ? void 0 : syncState.placement,
31
26
  "top"
32
27
  ),
33
- gutter: _QNEPGQLLcjs.defaultValue.call(void 0, props.gutter, _optionalChain([syncState, 'optionalAccess', _6 => _6.gutter]), 8)
34
- });
35
- const initialState = {
36
- ...popover.getState(),
37
- timeout: _QNEPGQLLcjs.defaultValue.call(void 0, props.timeout, _optionalChain([syncState, 'optionalAccess', _7 => _7.timeout]), 0)
38
- };
39
- const tooltip = _ZPOXPO2Lcjs.createStore.call(void 0,
40
- initialState,
41
- popover,
42
- disclosure.omit("open", "mounted"),
43
- props.store
44
- );
45
- const ref = Symbol();
46
- tooltip.setup(
47
- () => disclosure.sync(
48
- (state, prev) => {
49
- const { timeout } = tooltip.getState();
50
- const { activeRef } = tooltips.getState();
51
- if (state.open) {
52
- if (!timeout || activeRef) {
53
- tooltips.setState("activeRef", ref);
54
- tooltip.setState("open", true);
55
- return;
56
- } else {
57
- tooltips.setState("activeRef", null);
58
- return afterTimeout(timeout, () => {
59
- tooltips.setState("activeRef", ref);
60
- });
61
- }
62
- } else if (state.open !== prev.open) {
63
- tooltip.setState("open", false);
64
- return afterTimeout(timeout, () => {
65
- tooltips.setState(
66
- "activeRef",
67
- (activeRef2) => activeRef2 === ref ? null : activeRef2
68
- );
69
- });
70
- }
71
- return;
72
- },
73
- ["open"]
74
- )
75
- );
76
- tooltip.setup(
77
- () => tooltips.sync(
78
- (state) => {
79
- tooltip.setState("open", state.activeRef === ref);
80
- },
81
- ["activeRef"]
28
+ showTimeout: _M6ZA7XUPcjs.defaultValue.call(void 0,
29
+ props.showTimeout,
30
+ syncState == null ? void 0 : syncState.showTimeout,
31
+ props.timeout,
32
+ 500
33
+ ),
34
+ hideTimeout: _M6ZA7XUPcjs.defaultValue.call(void 0,
35
+ props.hideTimeout,
36
+ syncState == null ? void 0 : syncState.hideTimeout,
37
+ props.timeout,
38
+ 0
82
39
  )
83
- );
84
- tooltip.setup(() => () => {
85
- tooltips.setState(
86
- "activeRef",
87
- (activeRef) => activeRef === ref ? null : activeRef
88
- );
40
+ }));
41
+ const initialState = _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, hovercard.getState()), {
42
+ type: _M6ZA7XUPcjs.defaultValue.call(void 0, props.type, syncState == null ? void 0 : syncState.type, "description"),
43
+ skipTimeout: _M6ZA7XUPcjs.defaultValue.call(void 0, props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
89
44
  });
90
- return {
91
- ...popover,
92
- ...disclosure,
93
- ...tooltip
94
- };
45
+ const tooltip = _6SPJEESBcjs.createStore.call(void 0, initialState, hovercard, props.store);
46
+ return _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, hovercard), tooltip);
95
47
  }
96
48
 
97
49
 
@@ -1,28 +1,33 @@
1
- import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
1
+ import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
2
2
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
3
  /**
4
4
  * Creates a tooltip store.
5
5
  */
6
6
  export declare function createTooltipStore(props?: TooltipStoreProps): TooltipStore;
7
- export interface TooltipStoreState extends PopoverStoreState {
7
+ export interface TooltipStoreState extends HovercardStoreState {
8
8
  /**
9
- * @default "top"
9
+ * Determines whether the tooltip is being used as a label or a description
10
+ * for the anchor element.
11
+ * @default "description"
10
12
  */
11
- placement: PopoverStoreState["placement"];
13
+ type: "label" | "description";
12
14
  /**
13
- * @default 8
15
+ * The amount of time after a tooltip is hidden while all tooltips on the
16
+ * page can be shown immediately, without waiting for the show timeout.
17
+ * @default 300
14
18
  */
15
- gutter: PopoverStoreState["gutter"];
16
- /**
17
- * The amount in milliseconds to wait before showing the tooltip. When there's
18
- * already an open tooltip in the page, this value will be ignored and other
19
- * tooltips will be shown immediately.
20
- * @default 0
21
- */
22
- timeout: number;
19
+ skipTimeout: number;
20
+ /** @default "top" */
21
+ placement: HovercardStoreState["placement"];
22
+ /** @default 0 */
23
+ timeout: HovercardStoreState["timeout"];
24
+ /** @default 500 */
25
+ showTimeout: HovercardStoreState["showTimeout"];
26
+ /** @default 0 */
27
+ hideTimeout: HovercardStoreState["hideTimeout"];
23
28
  }
24
- export type TooltipStoreFunctions = PopoverStoreFunctions;
25
- export interface TooltipStoreOptions extends StoreOptions<TooltipStoreState, "placement" | "gutter" | "timeout">, PopoverStoreOptions {
29
+ export type TooltipStoreFunctions = HovercardStoreFunctions;
30
+ export interface TooltipStoreOptions extends StoreOptions<TooltipStoreState, "type" | "placement" | "timeout" | "showTimeout" | "hideTimeout" | "skipTimeout">, HovercardStoreOptions {
26
31
  }
27
32
  export type TooltipStoreProps = TooltipStoreOptions & StoreProps<TooltipStoreState>;
28
33
  export type TooltipStore = TooltipStoreFunctions & Store<TooltipStoreState>;