@ariakit/core 0.0.1 → 0.1.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 (163) hide show
  1. package/.eslintignore +6 -0
  2. package/CHANGELOG.md +18 -0
  3. package/checkbox/checkbox-store/package.json +7 -0
  4. package/cjs/__chunks/2YFRPUZP.cjs +30 -0
  5. package/cjs/__chunks/3BBA3Z5G.cjs +143 -0
  6. package/cjs/__chunks/3KP2MDG6.cjs +1491 -0
  7. package/cjs/__chunks/5D5Y5EI4.cjs +146 -0
  8. package/cjs/__chunks/7ZXWQTAY.cjs +71 -0
  9. package/cjs/__chunks/AZVDLKO3.cjs +286 -0
  10. package/cjs/__chunks/EFEGT32M.cjs +12 -0
  11. package/cjs/__chunks/EIDN2CWH.cjs +57 -0
  12. package/cjs/__chunks/GDZQUFNP.cjs +30 -0
  13. package/cjs/__chunks/NX5OHIMM.cjs +169 -0
  14. package/cjs/__chunks/OFNGELMA.cjs +182 -0
  15. package/cjs/checkbox/checkbox-store.cjs +27 -0
  16. package/cjs/checkbox/checkbox-store.d.ts +34 -0
  17. package/cjs/collection/collection-store.cjs +9 -0
  18. package/cjs/collection/collection-store.d.ts +65 -0
  19. package/cjs/combobox/combobox-store.cjs +163 -0
  20. package/cjs/combobox/combobox-store.d.ts +67 -0
  21. package/cjs/composite/composite-overflow-store.cjs +15 -0
  22. package/cjs/composite/composite-overflow-store.d.ts +10 -0
  23. package/cjs/composite/composite-store.cjs +11 -0
  24. package/cjs/composite/composite-store.d.ts +202 -0
  25. package/cjs/dialog/dialog-store.cjs +9 -0
  26. package/cjs/dialog/dialog-store.d.ts +10 -0
  27. package/cjs/disclosure/disclosure-store.cjs +8 -0
  28. package/cjs/disclosure/disclosure-store.d.ts +87 -0
  29. package/cjs/form/form-store.cjs +241 -0
  30. package/cjs/form/form-store.d.ts +236 -0
  31. package/cjs/form/types.cjs +1 -0
  32. package/cjs/form/types.d.ts +38 -0
  33. package/cjs/hovercard/hovercard-store.cjs +11 -0
  34. package/cjs/hovercard/hovercard-store.d.ts +45 -0
  35. package/cjs/index.cjs +5 -0
  36. package/cjs/index.d.ts +2 -0
  37. package/cjs/menu/menu-bar-store.cjs +27 -0
  38. package/cjs/menu/menu-bar-store.d.ts +10 -0
  39. package/cjs/menu/menu-store.cjs +108 -0
  40. package/cjs/menu/menu-store.d.ts +70 -0
  41. package/cjs/popover/popover-store.cjs +10 -0
  42. package/cjs/popover/popover-store.d.ts +150 -0
  43. package/cjs/radio/radio-store.cjs +36 -0
  44. package/cjs/radio/radio-store.d.ts +31 -0
  45. package/cjs/select/select-store.cjs +164 -0
  46. package/cjs/select/select-store.d.ts +87 -0
  47. package/cjs/tab/tab-store.cjs +126 -0
  48. package/cjs/tab/tab-store.d.ts +78 -0
  49. package/cjs/toolbar/toolbar-store.cjs +27 -0
  50. package/cjs/toolbar/toolbar-store.d.ts +21 -0
  51. package/cjs/tooltip/tooltip-store.cjs +98 -0
  52. package/cjs/tooltip/tooltip-store.d.ts +28 -0
  53. package/cjs/tsconfig.build.tsbuildinfo +1 -0
  54. package/cjs/utils/array.cjs +12 -0
  55. package/cjs/utils/array.d.ts +29 -0
  56. package/cjs/utils/dom.cjs +38 -0
  57. package/cjs/utils/dom.d.ts +105 -0
  58. package/cjs/utils/events.cjs +132 -0
  59. package/cjs/utils/events.d.ts +73 -0
  60. package/cjs/utils/focus.cjs +222 -0
  61. package/cjs/utils/focus.d.ts +117 -0
  62. package/cjs/utils/misc.cjs +40 -0
  63. package/cjs/utils/misc.d.ts +111 -0
  64. package/cjs/utils/platform.cjs +15 -0
  65. package/cjs/utils/platform.d.ts +20 -0
  66. package/cjs/utils/store.cjs +9 -0
  67. package/cjs/utils/store.d.ts +99 -0
  68. package/cjs/utils/types.cjs +1 -0
  69. package/cjs/utils/types.d.ts +72 -0
  70. package/collection/collection-store/package.json +7 -0
  71. package/combobox/combobox-store/package.json +7 -0
  72. package/composite/composite-overflow-store/package.json +7 -0
  73. package/composite/composite-store/package.json +7 -0
  74. package/dialog/dialog-store/package.json +7 -0
  75. package/disclosure/disclosure-store/package.json +7 -0
  76. package/esm/__chunks/5XEKIOCW.js +30 -0
  77. package/esm/__chunks/6U25WEDX.js +286 -0
  78. package/esm/__chunks/6UPCMUXT.js +1491 -0
  79. package/esm/__chunks/ADRUFBEO.js +12 -0
  80. package/esm/__chunks/DXA3K2FY.js +30 -0
  81. package/esm/__chunks/HCKYJLMC.js +71 -0
  82. package/esm/__chunks/KLKI3AIB.js +146 -0
  83. package/esm/__chunks/L7KN5AYP.js +169 -0
  84. package/esm/__chunks/RX3ZUQ6U.js +57 -0
  85. package/esm/__chunks/UOJSZ35L.js +143 -0
  86. package/esm/__chunks/UVCATTRC.js +182 -0
  87. package/esm/checkbox/checkbox-store.d.ts +34 -0
  88. package/esm/checkbox/checkbox-store.js +27 -0
  89. package/esm/collection/collection-store.d.ts +65 -0
  90. package/esm/collection/collection-store.js +9 -0
  91. package/esm/combobox/combobox-store.d.ts +67 -0
  92. package/esm/combobox/combobox-store.js +163 -0
  93. package/esm/composite/composite-overflow-store.d.ts +10 -0
  94. package/esm/composite/composite-overflow-store.js +15 -0
  95. package/esm/composite/composite-store.d.ts +202 -0
  96. package/esm/composite/composite-store.js +11 -0
  97. package/esm/dialog/dialog-store.d.ts +10 -0
  98. package/esm/dialog/dialog-store.js +9 -0
  99. package/esm/disclosure/disclosure-store.d.ts +87 -0
  100. package/esm/disclosure/disclosure-store.js +8 -0
  101. package/esm/form/form-store.d.ts +236 -0
  102. package/esm/form/form-store.js +241 -0
  103. package/esm/form/types.d.ts +38 -0
  104. package/esm/form/types.js +0 -0
  105. package/esm/hovercard/hovercard-store.d.ts +45 -0
  106. package/esm/hovercard/hovercard-store.js +11 -0
  107. package/esm/index.d.ts +2 -0
  108. package/esm/index.js +5 -0
  109. package/esm/menu/menu-bar-store.d.ts +10 -0
  110. package/esm/menu/menu-bar-store.js +27 -0
  111. package/esm/menu/menu-store.d.ts +70 -0
  112. package/esm/menu/menu-store.js +108 -0
  113. package/esm/popover/popover-store.d.ts +150 -0
  114. package/esm/popover/popover-store.js +10 -0
  115. package/esm/radio/radio-store.d.ts +31 -0
  116. package/esm/radio/radio-store.js +36 -0
  117. package/esm/select/select-store.d.ts +87 -0
  118. package/esm/select/select-store.js +164 -0
  119. package/esm/tab/tab-store.d.ts +78 -0
  120. package/esm/tab/tab-store.js +126 -0
  121. package/esm/toolbar/toolbar-store.d.ts +21 -0
  122. package/esm/toolbar/toolbar-store.js +27 -0
  123. package/esm/tooltip/tooltip-store.d.ts +28 -0
  124. package/esm/tooltip/tooltip-store.js +98 -0
  125. package/esm/tsconfig.build.tsbuildinfo +1 -0
  126. package/esm/utils/array.d.ts +29 -0
  127. package/esm/utils/array.js +12 -0
  128. package/esm/utils/dom.d.ts +105 -0
  129. package/esm/utils/dom.js +38 -0
  130. package/esm/utils/events.d.ts +73 -0
  131. package/esm/utils/events.js +132 -0
  132. package/esm/utils/focus.d.ts +117 -0
  133. package/esm/utils/focus.js +222 -0
  134. package/esm/utils/misc.d.ts +111 -0
  135. package/esm/utils/misc.js +40 -0
  136. package/esm/utils/platform.d.ts +20 -0
  137. package/esm/utils/platform.js +15 -0
  138. package/esm/utils/store.d.ts +99 -0
  139. package/esm/utils/store.js +9 -0
  140. package/esm/utils/types.d.ts +72 -0
  141. package/esm/utils/types.js +0 -0
  142. package/form/form-store/package.json +7 -0
  143. package/form/types/package.json +7 -0
  144. package/hovercard/hovercard-store/package.json +7 -0
  145. package/license +21 -0
  146. package/menu/menu-bar-store/package.json +7 -0
  147. package/menu/menu-store/package.json +7 -0
  148. package/package.json +137 -6
  149. package/popover/popover-store/package.json +7 -0
  150. package/radio/radio-store/package.json +7 -0
  151. package/select/select-store/package.json +7 -0
  152. package/tab/tab-store/package.json +7 -0
  153. package/toolbar/toolbar-store/package.json +7 -0
  154. package/tooltip/tooltip-store/package.json +7 -0
  155. package/tsconfig.build.json +4 -0
  156. package/utils/array/package.json +7 -0
  157. package/utils/dom/package.json +7 -0
  158. package/utils/events/package.json +7 -0
  159. package/utils/focus/package.json +7 -0
  160. package/utils/misc/package.json +7 -0
  161. package/utils/platform/package.json +7 -0
  162. package/utils/store/package.json +7 -0
  163. package/utils/types/package.json +7 -0
package/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ cjs
2
+ esm
3
+ ts
4
+ umd
5
+ coverage
6
+ node_modules
package/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # @ariakit/core
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Updated package names to include the `@ariakit` scope, providing a more distinct and specific namespace for our packages.
8
+
9
+ Additionally, we've made a change to the versioning system, moving from `v2.0.0-beta.x` to `v0.x.x`. This alteration means that although the library is still in beta, we can release breaking changes in minor versions without disrupting projects that don't set exact versions in their `package.json`.
10
+
11
+ ```diff
12
+ - npm i ariakit
13
+ + npm i @ariakit/react
14
+ ```
15
+
16
+ ### Patch Changes
17
+
18
+ - Packages are now ESM by default (commonjs modules are still available with the `.cjs` extension).
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@ariakit/core/checkbox/checkbox-store",
3
+ "private": true,
4
+ "sideEffects": false,
5
+ "main": "../../cjs/checkbox/checkbox-store",
6
+ "module": "../../esm/checkbox/checkbox-store"
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _OFNGELMAcjs = require('./OFNGELMA.cjs');
4
+
5
+ // src/utils/platform.ts
6
+ function isTouchDevice() {
7
+ return _OFNGELMAcjs.canUseDOM && !!navigator.maxTouchPoints;
8
+ }
9
+ function isApple() {
10
+ if (!_OFNGELMAcjs.canUseDOM)
11
+ return false;
12
+ return /mac|iphone|ipad|ipod/i.test(navigator.platform);
13
+ }
14
+ function isSafari() {
15
+ return _OFNGELMAcjs.canUseDOM && isApple() && /apple/i.test(navigator.vendor);
16
+ }
17
+ function isFirefox() {
18
+ return _OFNGELMAcjs.canUseDOM && /firefox\//i.test(navigator.userAgent);
19
+ }
20
+ function isMac() {
21
+ return _OFNGELMAcjs.canUseDOM && navigator.platform.startsWith("Mac") && !isTouchDevice();
22
+ }
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ exports.isTouchDevice = isTouchDevice; exports.isApple = isApple; exports.isSafari = isSafari; exports.isFirefox = isFirefox; exports.isMac = isMac;
@@ -0,0 +1,143 @@
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; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _5D5Y5EI4cjs = require('./5D5Y5EI4.cjs');
10
+
11
+ // src/utils/store.ts
12
+ function createStore(initialState, ...stores) {
13
+ let state = initialState;
14
+ let prevStateBatch = state;
15
+ let lastUpdate = Symbol();
16
+ let updating = false;
17
+ let initialized = false;
18
+ const updatedKeys = /* @__PURE__ */ new Set();
19
+ const setups = /* @__PURE__ */ new Set();
20
+ const listeners = /* @__PURE__ */ new Set();
21
+ const listenersBatch = /* @__PURE__ */ new Set();
22
+ const disposables = /* @__PURE__ */ new WeakMap();
23
+ const listenerKeys = /* @__PURE__ */ new WeakMap();
24
+ const setup = (callback) => {
25
+ setups.add(callback);
26
+ return () => setups.delete(callback);
27
+ };
28
+ const init = () => {
29
+ if (initialized)
30
+ return _5D5Y5EI4cjs.noop;
31
+ if (!stores.length)
32
+ return _5D5Y5EI4cjs.noop;
33
+ initialized = true;
34
+ const desyncs = _5D5Y5EI4cjs.getKeys.call(void 0, state).map(
35
+ (key) => _5D5Y5EI4cjs.chain.call(void 0,
36
+ ...stores.map((store) => {
37
+ const storeState = _optionalChain([store, 'optionalAccess', _ => _.getState, 'optionalCall', _2 => _2()]);
38
+ if (!storeState)
39
+ return;
40
+ if (!_5D5Y5EI4cjs.hasOwnProperty.call(void 0, storeState, key))
41
+ return;
42
+ return _optionalChain([store, 'optionalAccess', _3 => _3.sync, 'optionalCall', _4 => _4((state2) => setState(key, state2[key]), [key])]);
43
+ })
44
+ )
45
+ );
46
+ const teardowns = [];
47
+ setups.forEach((setup2) => teardowns.push(setup2()));
48
+ const cleanups = stores.map((store) => _optionalChain([store, 'optionalAccess', _5 => _5.init, 'optionalCall', _6 => _6()]));
49
+ return _5D5Y5EI4cjs.chain.call(void 0, ...desyncs, ...teardowns, ...cleanups, () => {
50
+ initialized = false;
51
+ });
52
+ };
53
+ const sub = (listener, keys, batch = false) => {
54
+ const set = batch ? listenersBatch : listeners;
55
+ set.add(listener);
56
+ listenerKeys.set(listener, keys);
57
+ return () => {
58
+ _optionalChain([disposables, 'access', _7 => _7.get, 'call', _8 => _8(listener), 'optionalCall', _9 => _9()]);
59
+ disposables.delete(listener);
60
+ listenerKeys.delete(listener);
61
+ set.delete(listener);
62
+ };
63
+ };
64
+ const subscribe = (listener, keys) => sub(listener, keys);
65
+ const sync = (listener, keys) => {
66
+ disposables.set(listener, listener(state, state));
67
+ return sub(listener, keys);
68
+ };
69
+ const syncBatch = (listener, keys) => {
70
+ if (!updating) {
71
+ disposables.set(listener, listener(state, prevStateBatch));
72
+ }
73
+ return sub(listener, keys, true);
74
+ };
75
+ const getState = () => state;
76
+ const setState = (key, value) => {
77
+ if (!_5D5Y5EI4cjs.hasOwnProperty.call(void 0, state, key))
78
+ return;
79
+ const nextValue = _5D5Y5EI4cjs.applyState.call(void 0, value, state[key]);
80
+ if (nextValue === state[key])
81
+ return;
82
+ stores.forEach((store) => {
83
+ _optionalChain([store, 'optionalAccess', _10 => _10.setState, 'optionalCall', _11 => _11(key, nextValue)]);
84
+ });
85
+ const prevState = state;
86
+ state = { ...state, [key]: nextValue };
87
+ const thisUpdate = Symbol();
88
+ lastUpdate = thisUpdate;
89
+ updating = true;
90
+ updatedKeys.add(key);
91
+ const run = (listener, prev, uKeys) => {
92
+ const keys = listenerKeys.get(listener);
93
+ const updated = (k) => uKeys ? uKeys.has(k) : k === key;
94
+ if (!keys || keys.some(updated)) {
95
+ _optionalChain([disposables, 'access', _12 => _12.get, 'call', _13 => _13(listener), 'optionalCall', _14 => _14()]);
96
+ disposables.set(listener, listener(state, prev));
97
+ }
98
+ };
99
+ listeners.forEach((listener) => run(listener, prevState));
100
+ queueMicrotask(() => {
101
+ if (lastUpdate !== thisUpdate)
102
+ return;
103
+ updating = false;
104
+ const snapshot = state;
105
+ listenersBatch.forEach((listener) => {
106
+ run(listener, prevStateBatch, updatedKeys);
107
+ });
108
+ prevStateBatch = snapshot;
109
+ queueMicrotask(() => {
110
+ updatedKeys.clear();
111
+ });
112
+ });
113
+ };
114
+ const pick2 = (...keys) => createStore(_5D5Y5EI4cjs.pick.call(void 0, state, keys), finalStore);
115
+ const omit2 = (...keys) => createStore(_5D5Y5EI4cjs.omit.call(void 0, state, keys), finalStore);
116
+ const finalStore = {
117
+ setup,
118
+ init,
119
+ subscribe,
120
+ sync,
121
+ syncBatch,
122
+ getState,
123
+ setState,
124
+ pick: pick2,
125
+ omit: omit2
126
+ };
127
+ return finalStore;
128
+ }
129
+ function mergeStore(...stores) {
130
+ const initialState = stores.reduce((state, store2) => {
131
+ const nextState = _optionalChain([store2, 'optionalAccess', _15 => _15.getState, 'optionalCall', _16 => _16()]);
132
+ if (!nextState)
133
+ return state;
134
+ return { ...state, ...nextState };
135
+ }, {});
136
+ const store = createStore(initialState, ...stores);
137
+ return store;
138
+ }
139
+
140
+
141
+
142
+
143
+ exports.createStore = createStore; exports.mergeStore = mergeStore;