@ariakit/core 0.4.1 → 0.4.2
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.
- package/CHANGELOG.md +6 -0
- package/cjs/collection/collection-store.d.cts +3 -0
- package/cjs/collection/collection-store.d.ts +3 -0
- package/cjs/composite/composite-store.d.cts +0 -16
- package/cjs/composite/composite-store.d.ts +0 -16
- package/cjs/select/select-store.d.cts +4 -0
- package/cjs/select/select-store.d.ts +4 -0
- package/cjs/tab/tab-store.cjs +24 -4
- package/cjs/tab/tab-store.d.cts +15 -5
- package/cjs/tab/tab-store.d.ts +15 -5
- package/cjs/utils/dom.d.cts +6 -5
- package/cjs/utils/dom.d.ts +6 -5
- package/cjs/utils/focus.cjs +1 -1
- package/esm/collection/collection-store.d.ts +3 -0
- package/esm/composite/composite-store.d.ts +0 -16
- package/esm/select/select-store.d.ts +4 -0
- package/esm/tab/tab-store.d.ts +15 -5
- package/esm/tab/tab-store.js +24 -4
- package/esm/utils/dom.d.ts +6 -5
- package/esm/utils/focus.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ariakit/core
|
|
2
2
|
|
|
3
|
+
## 0.4.2
|
|
4
|
+
|
|
5
|
+
- Fixed [`Focusable`](https://ariakit.org/reference/focusable) to identify `summary` as a native tabbable element.
|
|
6
|
+
- Added new [`composite`](https://ariakit.org/reference/tab-provider#composite) property to tab store.
|
|
7
|
+
- Improved JSDocs.
|
|
8
|
+
|
|
3
9
|
## 0.4.1
|
|
4
10
|
|
|
5
11
|
- Added [`disclosure`](https://ariakit.org/reference/use-disclosure-store#disclosure-1) property to disclosure stores.
|
|
@@ -52,6 +52,9 @@ export interface CollectionStoreFunctions<T extends CollectionStoreItem = Collec
|
|
|
52
52
|
renderItem: BivariantCallback<(item: T) => () => void>;
|
|
53
53
|
/**
|
|
54
54
|
* Gets an item by its id.
|
|
55
|
+
*
|
|
56
|
+
* Live examples:
|
|
57
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
55
58
|
* @example
|
|
56
59
|
* const item = store.item("item-1");
|
|
57
60
|
*/
|
|
@@ -52,6 +52,9 @@ export interface CollectionStoreFunctions<T extends CollectionStoreItem = Collec
|
|
|
52
52
|
renderItem: BivariantCallback<(item: T) => () => void>;
|
|
53
53
|
/**
|
|
54
54
|
* Gets an item by its id.
|
|
55
|
+
*
|
|
56
|
+
* Live examples:
|
|
57
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
55
58
|
* @example
|
|
56
59
|
* const item = store.item("item-1");
|
|
57
60
|
*/
|
|
@@ -159,7 +159,6 @@ export interface CompositeStoreState<T extends CompositeStoreItem = CompositeSto
|
|
|
159
159
|
* Live examples:
|
|
160
160
|
* - [Submenu with
|
|
161
161
|
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
162
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
163
162
|
* - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)
|
|
164
163
|
* @default false
|
|
165
164
|
*/
|
|
@@ -194,9 +193,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
194
193
|
* state _without moving focus_. If you want to move focus, use the
|
|
195
194
|
* [`move`](https://ariakit.org/reference/use-composite-store#move) function
|
|
196
195
|
* instead.
|
|
197
|
-
*
|
|
198
|
-
* Live examples:
|
|
199
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
200
196
|
* @example
|
|
201
197
|
* // Sets the composite element as the active item
|
|
202
198
|
* store.setActiveId(null);
|
|
@@ -230,9 +226,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
230
226
|
* Returns the id of the next enabled item based on the current
|
|
231
227
|
* [`activeId`](https://ariakit.org/reference/composite-provider#activeid)
|
|
232
228
|
* state.
|
|
233
|
-
*
|
|
234
|
-
* Live examples:
|
|
235
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
236
229
|
* @example
|
|
237
230
|
* const nextId = store.next();
|
|
238
231
|
* const nextNextId = store.next(2);
|
|
@@ -242,9 +235,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
242
235
|
* Returns the id of the previous enabled item based on the current
|
|
243
236
|
* [`activeId`](https://ariakit.org/reference/composite-provider#activeid)
|
|
244
237
|
* state.
|
|
245
|
-
*
|
|
246
|
-
* Live examples:
|
|
247
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
248
238
|
* @example
|
|
249
239
|
* const previousId = store.previous();
|
|
250
240
|
* const previousPreviousId = store.previous(2);
|
|
@@ -270,16 +260,10 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
270
260
|
down: (skip?: number) => string | null | undefined;
|
|
271
261
|
/**
|
|
272
262
|
* Returns the id of the first enabled item.
|
|
273
|
-
*
|
|
274
|
-
* Live examples:
|
|
275
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
276
263
|
*/
|
|
277
264
|
first: () => string | null | undefined;
|
|
278
265
|
/**
|
|
279
266
|
* Returns the id of the last enabled item.
|
|
280
|
-
*
|
|
281
|
-
* Live examples:
|
|
282
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
283
267
|
*/
|
|
284
268
|
last: () => string | null | undefined;
|
|
285
269
|
}
|
|
@@ -159,7 +159,6 @@ export interface CompositeStoreState<T extends CompositeStoreItem = CompositeSto
|
|
|
159
159
|
* Live examples:
|
|
160
160
|
* - [Submenu with
|
|
161
161
|
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
162
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
163
162
|
* - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)
|
|
164
163
|
* @default false
|
|
165
164
|
*/
|
|
@@ -194,9 +193,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
194
193
|
* state _without moving focus_. If you want to move focus, use the
|
|
195
194
|
* [`move`](https://ariakit.org/reference/use-composite-store#move) function
|
|
196
195
|
* instead.
|
|
197
|
-
*
|
|
198
|
-
* Live examples:
|
|
199
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
200
196
|
* @example
|
|
201
197
|
* // Sets the composite element as the active item
|
|
202
198
|
* store.setActiveId(null);
|
|
@@ -230,9 +226,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
230
226
|
* Returns the id of the next enabled item based on the current
|
|
231
227
|
* [`activeId`](https://ariakit.org/reference/composite-provider#activeid)
|
|
232
228
|
* state.
|
|
233
|
-
*
|
|
234
|
-
* Live examples:
|
|
235
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
236
229
|
* @example
|
|
237
230
|
* const nextId = store.next();
|
|
238
231
|
* const nextNextId = store.next(2);
|
|
@@ -242,9 +235,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
242
235
|
* Returns the id of the previous enabled item based on the current
|
|
243
236
|
* [`activeId`](https://ariakit.org/reference/composite-provider#activeid)
|
|
244
237
|
* state.
|
|
245
|
-
*
|
|
246
|
-
* Live examples:
|
|
247
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
248
238
|
* @example
|
|
249
239
|
* const previousId = store.previous();
|
|
250
240
|
* const previousPreviousId = store.previous(2);
|
|
@@ -270,16 +260,10 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
270
260
|
down: (skip?: number) => string | null | undefined;
|
|
271
261
|
/**
|
|
272
262
|
* Returns the id of the first enabled item.
|
|
273
|
-
*
|
|
274
|
-
* Live examples:
|
|
275
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
276
263
|
*/
|
|
277
264
|
first: () => string | null | undefined;
|
|
278
265
|
/**
|
|
279
266
|
* Returns the id of the last enabled item.
|
|
280
|
-
*
|
|
281
|
-
* Live examples:
|
|
282
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
283
267
|
*/
|
|
284
268
|
last: () => string | null | undefined;
|
|
285
269
|
}
|
|
@@ -29,6 +29,8 @@ export interface SelectStoreState<T extends SelectStoreValue = SelectStoreValue>
|
|
|
29
29
|
* items](https://ariakit.org/examples/select-item-custom)
|
|
30
30
|
* - [Multi-Select](https://ariakit.org/examples/select-multiple)
|
|
31
31
|
* - [Toolbar with Select](https://ariakit.org/examples/toolbar-select)
|
|
32
|
+
* - [Select with Next.js App
|
|
33
|
+
* Router](https://ariakit.org/examples/select-next-router)
|
|
32
34
|
*/
|
|
33
35
|
value: MutableValue<T>;
|
|
34
36
|
/**
|
|
@@ -90,6 +92,8 @@ export interface SelectStoreOptions<T extends SelectStoreValue = SelectStoreValu
|
|
|
90
92
|
* - [Animated Select](https://ariakit.org/examples/select-animated)
|
|
91
93
|
* - [Select with Combobox](https://ariakit.org/examples/select-combobox)
|
|
92
94
|
* - [SelectGroup](https://ariakit.org/examples/select-group)
|
|
95
|
+
* - [Select with Next.js App
|
|
96
|
+
* Router](https://ariakit.org/examples/select-next-router)
|
|
93
97
|
*/
|
|
94
98
|
defaultValue?: SelectStoreState<T>["value"];
|
|
95
99
|
}
|
|
@@ -29,6 +29,8 @@ export interface SelectStoreState<T extends SelectStoreValue = SelectStoreValue>
|
|
|
29
29
|
* items](https://ariakit.org/examples/select-item-custom)
|
|
30
30
|
* - [Multi-Select](https://ariakit.org/examples/select-multiple)
|
|
31
31
|
* - [Toolbar with Select](https://ariakit.org/examples/toolbar-select)
|
|
32
|
+
* - [Select with Next.js App
|
|
33
|
+
* Router](https://ariakit.org/examples/select-next-router)
|
|
32
34
|
*/
|
|
33
35
|
value: MutableValue<T>;
|
|
34
36
|
/**
|
|
@@ -90,6 +92,8 @@ export interface SelectStoreOptions<T extends SelectStoreValue = SelectStoreValu
|
|
|
90
92
|
* - [Animated Select](https://ariakit.org/examples/select-animated)
|
|
91
93
|
* - [Select with Combobox](https://ariakit.org/examples/select-combobox)
|
|
92
94
|
* - [SelectGroup](https://ariakit.org/examples/select-group)
|
|
95
|
+
* - [Select with Next.js App
|
|
96
|
+
* Router](https://ariakit.org/examples/select-next-router)
|
|
93
97
|
*/
|
|
94
98
|
defaultValue?: SelectStoreState<T>["value"];
|
|
95
99
|
}
|
package/cjs/tab/tab-store.cjs
CHANGED
|
@@ -10,6 +10,8 @@ var _FFZYCAXAcjs = require('../__chunks/FFZYCAXA.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
|
|
14
|
+
|
|
13
15
|
var _B4LYZ4EMcjs = require('../__chunks/B4LYZ4EM.cjs');
|
|
14
16
|
|
|
15
17
|
|
|
@@ -19,12 +21,30 @@ require('../__chunks/ULSPM3Y3.cjs');
|
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
|
|
22
25
|
var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
|
|
23
26
|
|
|
24
27
|
// src/tab/tab-store.ts
|
|
25
|
-
function createTabStore(
|
|
26
|
-
var _a
|
|
27
|
-
|
|
28
|
+
function createTabStore(_a = {}) {
|
|
29
|
+
var _b = _a, {
|
|
30
|
+
composite: parentComposite
|
|
31
|
+
} = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, [
|
|
32
|
+
"composite"
|
|
33
|
+
]);
|
|
34
|
+
const store = _B4LYZ4EMcjs.mergeStore.call(void 0,
|
|
35
|
+
props.store,
|
|
36
|
+
_B4LYZ4EMcjs.omit.call(void 0, parentComposite, [
|
|
37
|
+
"items",
|
|
38
|
+
"renderedItems",
|
|
39
|
+
"moves",
|
|
40
|
+
"orientation",
|
|
41
|
+
"baseElement",
|
|
42
|
+
"focusLoop",
|
|
43
|
+
"focusShift",
|
|
44
|
+
"focusWrap"
|
|
45
|
+
])
|
|
46
|
+
);
|
|
47
|
+
const syncState = store == null ? void 0 : store.getState();
|
|
28
48
|
const composite = _Y7KNI5NScjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
29
49
|
orientation: _EEDWPDM2cjs.defaultValue.call(void 0,
|
|
30
50
|
props.orientation,
|
|
@@ -47,7 +67,7 @@ function createTabStore(props = {}) {
|
|
|
47
67
|
true
|
|
48
68
|
)
|
|
49
69
|
});
|
|
50
|
-
const tab = _B4LYZ4EMcjs.createStore.call(void 0, initialState, composite,
|
|
70
|
+
const tab = _B4LYZ4EMcjs.createStore.call(void 0, initialState, composite, store);
|
|
51
71
|
_B4LYZ4EMcjs.setup.call(void 0,
|
|
52
72
|
tab,
|
|
53
73
|
() => _B4LYZ4EMcjs.sync.call(void 0, tab, ["moves"], () => {
|
package/cjs/tab/tab-store.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
|
|
2
|
-
import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
2
|
+
import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
3
3
|
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
4
4
|
import type { SetState } from "../utils/types.js";
|
|
5
|
-
export declare function createTabStore(props?: TabStoreProps): TabStore;
|
|
5
|
+
export declare function createTabStore({ composite: parentComposite, ...props }?: TabStoreProps): TabStore;
|
|
6
6
|
export interface TabStoreItem extends CompositeStoreItem {
|
|
7
7
|
dimmed?: boolean;
|
|
8
8
|
}
|
|
@@ -54,6 +54,9 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
54
54
|
setSelectedId: SetState<TabStoreState["selectedId"]>;
|
|
55
55
|
/**
|
|
56
56
|
* A collection store containing the tab panels.
|
|
57
|
+
*
|
|
58
|
+
* Live examples:
|
|
59
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
57
60
|
*/
|
|
58
61
|
panels: CollectionStore<TabStorePanel>;
|
|
59
62
|
/**
|
|
@@ -62,9 +65,6 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
62
65
|
* state without moving focus, use the
|
|
63
66
|
* [`setSelectedId`](https://ariakit.org/reference/use-tab-store#setselectedid-1)
|
|
64
67
|
* function instead.
|
|
65
|
-
*
|
|
66
|
-
* Live examples:
|
|
67
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
68
68
|
* @example
|
|
69
69
|
* // Selects the tab with id "tab-1"
|
|
70
70
|
* store.select("tab-1");
|
|
@@ -76,12 +76,22 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
76
76
|
select: TabStore["move"];
|
|
77
77
|
}
|
|
78
78
|
export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<TabStoreItem> {
|
|
79
|
+
/**
|
|
80
|
+
* A reference to another [composite
|
|
81
|
+
* store](https://ariakit.org/reference/composite-store). This is used when
|
|
82
|
+
* rendering tabs as part of another composite widget such as
|
|
83
|
+
* [Combobox](https://ariakit.org/components/combobox) or
|
|
84
|
+
* [Select](https://ariakit.org/components/select). The stores will share the
|
|
85
|
+
* same state.
|
|
86
|
+
*/
|
|
87
|
+
composite?: CompositeStore | null;
|
|
79
88
|
/**
|
|
80
89
|
* The id of the tab whose panel is currently visible. If it's `undefined`, it
|
|
81
90
|
* will be automatically set to the first enabled tab.
|
|
82
91
|
*
|
|
83
92
|
* Live examples:
|
|
84
93
|
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
94
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
85
95
|
*/
|
|
86
96
|
defaultSelectedId?: TabStoreState["selectedId"];
|
|
87
97
|
}
|
package/cjs/tab/tab-store.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
|
|
2
|
-
import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
2
|
+
import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
3
3
|
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
4
4
|
import type { SetState } from "../utils/types.js";
|
|
5
|
-
export declare function createTabStore(props?: TabStoreProps): TabStore;
|
|
5
|
+
export declare function createTabStore({ composite: parentComposite, ...props }?: TabStoreProps): TabStore;
|
|
6
6
|
export interface TabStoreItem extends CompositeStoreItem {
|
|
7
7
|
dimmed?: boolean;
|
|
8
8
|
}
|
|
@@ -54,6 +54,9 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
54
54
|
setSelectedId: SetState<TabStoreState["selectedId"]>;
|
|
55
55
|
/**
|
|
56
56
|
* A collection store containing the tab panels.
|
|
57
|
+
*
|
|
58
|
+
* Live examples:
|
|
59
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
57
60
|
*/
|
|
58
61
|
panels: CollectionStore<TabStorePanel>;
|
|
59
62
|
/**
|
|
@@ -62,9 +65,6 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
62
65
|
* state without moving focus, use the
|
|
63
66
|
* [`setSelectedId`](https://ariakit.org/reference/use-tab-store#setselectedid-1)
|
|
64
67
|
* function instead.
|
|
65
|
-
*
|
|
66
|
-
* Live examples:
|
|
67
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
68
68
|
* @example
|
|
69
69
|
* // Selects the tab with id "tab-1"
|
|
70
70
|
* store.select("tab-1");
|
|
@@ -76,12 +76,22 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
76
76
|
select: TabStore["move"];
|
|
77
77
|
}
|
|
78
78
|
export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<TabStoreItem> {
|
|
79
|
+
/**
|
|
80
|
+
* A reference to another [composite
|
|
81
|
+
* store](https://ariakit.org/reference/composite-store). This is used when
|
|
82
|
+
* rendering tabs as part of another composite widget such as
|
|
83
|
+
* [Combobox](https://ariakit.org/components/combobox) or
|
|
84
|
+
* [Select](https://ariakit.org/components/select). The stores will share the
|
|
85
|
+
* same state.
|
|
86
|
+
*/
|
|
87
|
+
composite?: CompositeStore | null;
|
|
79
88
|
/**
|
|
80
89
|
* The id of the tab whose panel is currently visible. If it's `undefined`, it
|
|
81
90
|
* will be automatically set to the first enabled tab.
|
|
82
91
|
*
|
|
83
92
|
* Live examples:
|
|
84
93
|
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
94
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
85
95
|
*/
|
|
86
96
|
defaultSelectedId?: TabStoreState["selectedId"];
|
|
87
97
|
}
|
package/cjs/utils/dom.d.cts
CHANGED
|
@@ -104,11 +104,12 @@ export declare function getScrollingElement(element?: Element | null): HTMLEleme
|
|
|
104
104
|
*/
|
|
105
105
|
export declare function isPartiallyHidden(element: Element): boolean;
|
|
106
106
|
/**
|
|
107
|
-
* SelectionRange only works on a few types of input.
|
|
108
|
-
*
|
|
109
|
-
* To avoid it, we check if its type supports SelectionRange first.
|
|
110
|
-
*
|
|
107
|
+
* SelectionRange only works on a few types of input. Calling
|
|
108
|
+
* `setSelectionRange` on a unsupported input type may throw an error on certain
|
|
109
|
+
* browsers. To avoid it, we check if its type supports SelectionRange first. It
|
|
110
|
+
* will be a noop to non-supported types until we find a workaround.
|
|
111
111
|
*
|
|
112
|
-
* @see
|
|
112
|
+
* @see
|
|
113
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
113
114
|
*/
|
|
114
115
|
export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
|
package/cjs/utils/dom.d.ts
CHANGED
|
@@ -104,11 +104,12 @@ export declare function getScrollingElement(element?: Element | null): HTMLEleme
|
|
|
104
104
|
*/
|
|
105
105
|
export declare function isPartiallyHidden(element: Element): boolean;
|
|
106
106
|
/**
|
|
107
|
-
* SelectionRange only works on a few types of input.
|
|
108
|
-
*
|
|
109
|
-
* To avoid it, we check if its type supports SelectionRange first.
|
|
110
|
-
*
|
|
107
|
+
* SelectionRange only works on a few types of input. Calling
|
|
108
|
+
* `setSelectionRange` on a unsupported input type may throw an error on certain
|
|
109
|
+
* browsers. To avoid it, we check if its type supports SelectionRange first. It
|
|
110
|
+
* will be a noop to non-supported types until we find a workaround.
|
|
111
111
|
*
|
|
112
|
-
* @see
|
|
112
|
+
* @see
|
|
113
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
113
114
|
*/
|
|
114
115
|
export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
|
package/cjs/utils/focus.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var _UKR6TQI3cjs = require('../__chunks/UKR6TQI3.cjs');
|
|
|
12
12
|
var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
|
|
13
13
|
|
|
14
14
|
// src/utils/focus.ts
|
|
15
|
-
var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
|
|
15
|
+
var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
|
|
16
16
|
function hasNegativeTabIndex(element) {
|
|
17
17
|
const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
|
|
18
18
|
return tabIndex < 0;
|
|
@@ -52,6 +52,9 @@ export interface CollectionStoreFunctions<T extends CollectionStoreItem = Collec
|
|
|
52
52
|
renderItem: BivariantCallback<(item: T) => () => void>;
|
|
53
53
|
/**
|
|
54
54
|
* Gets an item by its id.
|
|
55
|
+
*
|
|
56
|
+
* Live examples:
|
|
57
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
55
58
|
* @example
|
|
56
59
|
* const item = store.item("item-1");
|
|
57
60
|
*/
|
|
@@ -159,7 +159,6 @@ export interface CompositeStoreState<T extends CompositeStoreItem = CompositeSto
|
|
|
159
159
|
* Live examples:
|
|
160
160
|
* - [Submenu with
|
|
161
161
|
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
162
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
163
162
|
* - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)
|
|
164
163
|
* @default false
|
|
165
164
|
*/
|
|
@@ -194,9 +193,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
194
193
|
* state _without moving focus_. If you want to move focus, use the
|
|
195
194
|
* [`move`](https://ariakit.org/reference/use-composite-store#move) function
|
|
196
195
|
* instead.
|
|
197
|
-
*
|
|
198
|
-
* Live examples:
|
|
199
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
200
196
|
* @example
|
|
201
197
|
* // Sets the composite element as the active item
|
|
202
198
|
* store.setActiveId(null);
|
|
@@ -230,9 +226,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
230
226
|
* Returns the id of the next enabled item based on the current
|
|
231
227
|
* [`activeId`](https://ariakit.org/reference/composite-provider#activeid)
|
|
232
228
|
* state.
|
|
233
|
-
*
|
|
234
|
-
* Live examples:
|
|
235
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
236
229
|
* @example
|
|
237
230
|
* const nextId = store.next();
|
|
238
231
|
* const nextNextId = store.next(2);
|
|
@@ -242,9 +235,6 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
242
235
|
* Returns the id of the previous enabled item based on the current
|
|
243
236
|
* [`activeId`](https://ariakit.org/reference/composite-provider#activeid)
|
|
244
237
|
* state.
|
|
245
|
-
*
|
|
246
|
-
* Live examples:
|
|
247
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
248
238
|
* @example
|
|
249
239
|
* const previousId = store.previous();
|
|
250
240
|
* const previousPreviousId = store.previous(2);
|
|
@@ -270,16 +260,10 @@ export interface CompositeStoreFunctions<T extends CompositeStoreItem = Composit
|
|
|
270
260
|
down: (skip?: number) => string | null | undefined;
|
|
271
261
|
/**
|
|
272
262
|
* Returns the id of the first enabled item.
|
|
273
|
-
*
|
|
274
|
-
* Live examples:
|
|
275
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
276
263
|
*/
|
|
277
264
|
first: () => string | null | undefined;
|
|
278
265
|
/**
|
|
279
266
|
* Returns the id of the last enabled item.
|
|
280
|
-
*
|
|
281
|
-
* Live examples:
|
|
282
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
283
267
|
*/
|
|
284
268
|
last: () => string | null | undefined;
|
|
285
269
|
}
|
|
@@ -29,6 +29,8 @@ export interface SelectStoreState<T extends SelectStoreValue = SelectStoreValue>
|
|
|
29
29
|
* items](https://ariakit.org/examples/select-item-custom)
|
|
30
30
|
* - [Multi-Select](https://ariakit.org/examples/select-multiple)
|
|
31
31
|
* - [Toolbar with Select](https://ariakit.org/examples/toolbar-select)
|
|
32
|
+
* - [Select with Next.js App
|
|
33
|
+
* Router](https://ariakit.org/examples/select-next-router)
|
|
32
34
|
*/
|
|
33
35
|
value: MutableValue<T>;
|
|
34
36
|
/**
|
|
@@ -90,6 +92,8 @@ export interface SelectStoreOptions<T extends SelectStoreValue = SelectStoreValu
|
|
|
90
92
|
* - [Animated Select](https://ariakit.org/examples/select-animated)
|
|
91
93
|
* - [Select with Combobox](https://ariakit.org/examples/select-combobox)
|
|
92
94
|
* - [SelectGroup](https://ariakit.org/examples/select-group)
|
|
95
|
+
* - [Select with Next.js App
|
|
96
|
+
* Router](https://ariakit.org/examples/select-next-router)
|
|
93
97
|
*/
|
|
94
98
|
defaultValue?: SelectStoreState<T>["value"];
|
|
95
99
|
}
|
package/esm/tab/tab-store.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
|
|
2
|
-
import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
2
|
+
import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
3
3
|
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
4
4
|
import type { SetState } from "../utils/types.js";
|
|
5
|
-
export declare function createTabStore(props?: TabStoreProps): TabStore;
|
|
5
|
+
export declare function createTabStore({ composite: parentComposite, ...props }?: TabStoreProps): TabStore;
|
|
6
6
|
export interface TabStoreItem extends CompositeStoreItem {
|
|
7
7
|
dimmed?: boolean;
|
|
8
8
|
}
|
|
@@ -54,6 +54,9 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
54
54
|
setSelectedId: SetState<TabStoreState["selectedId"]>;
|
|
55
55
|
/**
|
|
56
56
|
* A collection store containing the tab panels.
|
|
57
|
+
*
|
|
58
|
+
* Live examples:
|
|
59
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
57
60
|
*/
|
|
58
61
|
panels: CollectionStore<TabStorePanel>;
|
|
59
62
|
/**
|
|
@@ -62,9 +65,6 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
62
65
|
* state without moving focus, use the
|
|
63
66
|
* [`setSelectedId`](https://ariakit.org/reference/use-tab-store#setselectedid-1)
|
|
64
67
|
* function instead.
|
|
65
|
-
*
|
|
66
|
-
* Live examples:
|
|
67
|
-
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
68
68
|
* @example
|
|
69
69
|
* // Selects the tab with id "tab-1"
|
|
70
70
|
* store.select("tab-1");
|
|
@@ -76,12 +76,22 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
|
|
|
76
76
|
select: TabStore["move"];
|
|
77
77
|
}
|
|
78
78
|
export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<TabStoreItem> {
|
|
79
|
+
/**
|
|
80
|
+
* A reference to another [composite
|
|
81
|
+
* store](https://ariakit.org/reference/composite-store). This is used when
|
|
82
|
+
* rendering tabs as part of another composite widget such as
|
|
83
|
+
* [Combobox](https://ariakit.org/components/combobox) or
|
|
84
|
+
* [Select](https://ariakit.org/components/select). The stores will share the
|
|
85
|
+
* same state.
|
|
86
|
+
*/
|
|
87
|
+
composite?: CompositeStore | null;
|
|
79
88
|
/**
|
|
80
89
|
* The id of the tab whose panel is currently visible. If it's `undefined`, it
|
|
81
90
|
* will be automatically set to the first enabled tab.
|
|
82
91
|
*
|
|
83
92
|
* Live examples:
|
|
84
93
|
* - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)
|
|
94
|
+
* - [Animated TabPanel](https://ariakit.org/examples/tab-panel-animated)
|
|
85
95
|
*/
|
|
86
96
|
defaultSelectedId?: TabStoreState["selectedId"];
|
|
87
97
|
}
|
package/esm/tab/tab-store.js
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
batch,
|
|
10
10
|
createStore,
|
|
11
|
+
mergeStore,
|
|
12
|
+
omit,
|
|
11
13
|
setup,
|
|
12
14
|
sync
|
|
13
15
|
} from "../__chunks/R676XYVY.js";
|
|
@@ -17,14 +19,32 @@ import {
|
|
|
17
19
|
import "../__chunks/RRSZHCH6.js";
|
|
18
20
|
import "../__chunks/7PRQYBBV.js";
|
|
19
21
|
import {
|
|
22
|
+
__objRest,
|
|
20
23
|
__spreadProps,
|
|
21
24
|
__spreadValues
|
|
22
25
|
} from "../__chunks/4R3V3JGP.js";
|
|
23
26
|
|
|
24
27
|
// src/tab/tab-store.ts
|
|
25
|
-
function createTabStore(
|
|
26
|
-
var _a
|
|
27
|
-
|
|
28
|
+
function createTabStore(_a = {}) {
|
|
29
|
+
var _b = _a, {
|
|
30
|
+
composite: parentComposite
|
|
31
|
+
} = _b, props = __objRest(_b, [
|
|
32
|
+
"composite"
|
|
33
|
+
]);
|
|
34
|
+
const store = mergeStore(
|
|
35
|
+
props.store,
|
|
36
|
+
omit(parentComposite, [
|
|
37
|
+
"items",
|
|
38
|
+
"renderedItems",
|
|
39
|
+
"moves",
|
|
40
|
+
"orientation",
|
|
41
|
+
"baseElement",
|
|
42
|
+
"focusLoop",
|
|
43
|
+
"focusShift",
|
|
44
|
+
"focusWrap"
|
|
45
|
+
])
|
|
46
|
+
);
|
|
47
|
+
const syncState = store == null ? void 0 : store.getState();
|
|
28
48
|
const composite = createCompositeStore(__spreadProps(__spreadValues({}, props), {
|
|
29
49
|
orientation: defaultValue(
|
|
30
50
|
props.orientation,
|
|
@@ -47,7 +67,7 @@ function createTabStore(props = {}) {
|
|
|
47
67
|
true
|
|
48
68
|
)
|
|
49
69
|
});
|
|
50
|
-
const tab = createStore(initialState, composite,
|
|
70
|
+
const tab = createStore(initialState, composite, store);
|
|
51
71
|
setup(
|
|
52
72
|
tab,
|
|
53
73
|
() => sync(tab, ["moves"], () => {
|
package/esm/utils/dom.d.ts
CHANGED
|
@@ -104,11 +104,12 @@ export declare function getScrollingElement(element?: Element | null): HTMLEleme
|
|
|
104
104
|
*/
|
|
105
105
|
export declare function isPartiallyHidden(element: Element): boolean;
|
|
106
106
|
/**
|
|
107
|
-
* SelectionRange only works on a few types of input.
|
|
108
|
-
*
|
|
109
|
-
* To avoid it, we check if its type supports SelectionRange first.
|
|
110
|
-
*
|
|
107
|
+
* SelectionRange only works on a few types of input. Calling
|
|
108
|
+
* `setSelectionRange` on a unsupported input type may throw an error on certain
|
|
109
|
+
* browsers. To avoid it, we check if its type supports SelectionRange first. It
|
|
110
|
+
* will be a noop to non-supported types until we find a workaround.
|
|
111
111
|
*
|
|
112
|
-
* @see
|
|
112
|
+
* @see
|
|
113
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
113
114
|
*/
|
|
114
115
|
export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
|
package/esm/utils/focus.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../__chunks/4R3V3JGP.js";
|
|
13
13
|
|
|
14
14
|
// src/utils/focus.ts
|
|
15
|
-
var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
|
|
15
|
+
var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
|
|
16
16
|
function hasNegativeTabIndex(element) {
|
|
17
17
|
const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
|
|
18
18
|
return tabIndex < 0;
|