@ariakit/components 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.
- package/CHANGELOG.md +19 -0
- package/dist/checkbox/checkbox-store.d.ts +47 -0
- package/dist/checkbox/checkbox-store.d.ts.map +1 -0
- package/dist/checkbox/checkbox-store.js +16 -0
- package/dist/checkbox/checkbox-store.js.map +1 -0
- package/dist/collection/collection-store.d.ts +2 -0
- package/dist/collection/collection-store.js +132 -0
- package/dist/collection/collection-store.js.map +1 -0
- package/dist/collection-store-yNe83BiS.d.ts +81 -0
- package/dist/collection-store-yNe83BiS.d.ts.map +1 -0
- package/dist/combobox/combobox-store.d.ts +150 -0
- package/dist/combobox/combobox-store.d.ts.map +1 -0
- package/dist/combobox/combobox-store.js +83 -0
- package/dist/combobox/combobox-store.js.map +1 -0
- package/dist/composite/composite-overflow-store.d.ts +16 -0
- package/dist/composite/composite-overflow-store.d.ts.map +1 -0
- package/dist/composite/composite-overflow-store.js +12 -0
- package/dist/composite/composite-overflow-store.js.map +1 -0
- package/dist/composite/composite-store.d.ts +2 -0
- package/dist/composite/composite-store.js +167 -0
- package/dist/composite/composite-store.js.map +1 -0
- package/dist/composite-store-B-iDEtZZ.d.ts +331 -0
- package/dist/composite-store-B-iDEtZZ.d.ts.map +1 -0
- package/dist/dialog/dialog-store.d.ts +2 -0
- package/dist/dialog/dialog-store.js +12 -0
- package/dist/dialog/dialog-store.js.map +1 -0
- package/dist/dialog-store-BOLvw2IX.d.ts +16 -0
- package/dist/dialog-store-BOLvw2IX.d.ts.map +1 -0
- package/dist/disclosure/disclosure-store.d.ts +2 -0
- package/dist/disclosure/disclosure-store.js +47 -0
- package/dist/disclosure/disclosure-store.js.map +1 -0
- package/dist/disclosure-store-xKlQffR0.d.ts +142 -0
- package/dist/disclosure-store-xKlQffR0.d.ts.map +1 -0
- package/dist/form/form-store.d.ts +247 -0
- package/dist/form/form-store.d.ts.map +1 -0
- package/dist/form/form-store.js +211 -0
- package/dist/form/form-store.js.map +1 -0
- package/dist/form/types.d.ts +37 -0
- package/dist/form/types.d.ts.map +1 -0
- package/dist/form/types.js +0 -0
- package/dist/hovercard/hovercard-store.d.ts +65 -0
- package/dist/hovercard/hovercard-store.d.ts.map +1 -0
- package/dist/hovercard/hovercard-store.js +31 -0
- package/dist/hovercard/hovercard-store.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/menu/menu-bar-store.d.ts +16 -0
- package/dist/menu/menu-bar-store.d.ts.map +1 -0
- package/dist/menu/menu-bar-store.js +12 -0
- package/dist/menu/menu-bar-store.js.map +1 -0
- package/dist/menu/menu-store.d.ts +100 -0
- package/dist/menu/menu-store.d.ts.map +1 -0
- package/dist/menu/menu-store.js +74 -0
- package/dist/menu/menu-store.js.map +1 -0
- package/dist/menubar/menubar-store.d.ts +2 -0
- package/dist/menubar/menubar-store.js +24 -0
- package/dist/menubar/menubar-store.js.map +1 -0
- package/dist/menubar-store-CD3YDYfW.d.ts +16 -0
- package/dist/menubar-store-CD3YDYfW.d.ts.map +1 -0
- package/dist/popover/popover-store.d.ts +2 -0
- package/dist/popover/popover-store.js +44 -0
- package/dist/popover/popover-store.js.map +1 -0
- package/dist/popover-store-DoCiTmUQ.d.ts +106 -0
- package/dist/popover-store-DoCiTmUQ.d.ts.map +1 -0
- package/dist/radio/radio-store.d.ts +42 -0
- package/dist/radio/radio-store.d.ts.map +1 -0
- package/dist/radio/radio-store.js +27 -0
- package/dist/radio/radio-store.js.map +1 -0
- package/dist/select/select-store.d.ts +116 -0
- package/dist/select/select-store.d.ts.map +1 -0
- package/dist/select/select-store.js +93 -0
- package/dist/select/select-store.js.map +1 -0
- package/dist/tab/tab-store.d.ts +127 -0
- package/dist/tab/tab-store.d.ts.map +1 -0
- package/dist/tab/tab-store.js +107 -0
- package/dist/tab/tab-store.js.map +1 -0
- package/dist/tag/tag-store.d.ts +2 -0
- package/dist/tag/tag-store.js +60 -0
- package/dist/tag/tag-store.js.map +1 -0
- package/dist/tag-store-D47X5_zA.d.ts +83 -0
- package/dist/tag-store-D47X5_zA.d.ts.map +1 -0
- package/dist/toolbar/toolbar-store.d.ts +21 -0
- package/dist/toolbar/toolbar-store.d.ts.map +1 -0
- package/dist/toolbar/toolbar-store.js +18 -0
- package/dist/toolbar/toolbar-store.js.map +1 -0
- package/dist/tooltip/tooltip-store.d.ts +35 -0
- package/dist/tooltip/tooltip-store.d.ts.map +1 -0
- package/dist/tooltip/tooltip-store.js +29 -0
- package/dist/tooltip/tooltip-store.js.map +1 -0
- package/license +21 -0
- package/package.json +121 -0
- package/readme.md +19 -0
- package/src/checkbox/checkbox-store.ts +93 -0
- package/src/collection/collection-store.ts +301 -0
- package/src/combobox/combobox-store.ts +382 -0
- package/src/composite/composite-overflow-store.ts +30 -0
- package/src/composite/composite-store.ts +711 -0
- package/src/dialog/dialog-store.ts +26 -0
- package/src/disclosure/disclosure-store.ts +226 -0
- package/src/form/form-store.ts +608 -0
- package/src/form/types.ts +44 -0
- package/src/hovercard/hovercard-store.ts +112 -0
- package/src/index.ts +1 -0
- package/src/menu/menu-bar-store.ts +28 -0
- package/src/menu/menu-store.ts +263 -0
- package/src/menubar/menubar-store.ts +51 -0
- package/src/popover/popover-store.ts +170 -0
- package/src/radio/radio-store.ts +80 -0
- package/src/select/select-store.ts +323 -0
- package/src/tab/tab-store.ts +330 -0
- package/src/tag/tag-store.ts +170 -0
- package/src/toolbar/toolbar-store.ts +47 -0
- package/src/tooltip/tooltip-store.ts +93 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as PopoverStoreState, n as PopoverStoreFunctions, r as PopoverStoreOptions } from "../popover-store-DoCiTmUQ.js";
|
|
2
|
+
import { Store, StoreProps } from "@ariakit/store";
|
|
3
|
+
|
|
4
|
+
//#region src/composite/composite-overflow-store.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates a compositeOverflow store.
|
|
7
|
+
*/
|
|
8
|
+
declare function createCompositeOverflowStore(props?: CompositeOverflowStoreProps): CompositeOverflowStore;
|
|
9
|
+
interface CompositeOverflowStoreState extends PopoverStoreState {}
|
|
10
|
+
interface CompositeOverflowStoreFunctions extends PopoverStoreFunctions {}
|
|
11
|
+
interface CompositeOverflowStoreOptions extends PopoverStoreOptions {}
|
|
12
|
+
interface CompositeOverflowStoreProps extends CompositeOverflowStoreOptions, StoreProps<CompositeOverflowStoreState> {}
|
|
13
|
+
interface CompositeOverflowStore extends CompositeOverflowStoreFunctions, Store<CompositeOverflowStoreState> {}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CompositeOverflowStore, CompositeOverflowStoreFunctions, CompositeOverflowStoreOptions, CompositeOverflowStoreProps, CompositeOverflowStoreState, createCompositeOverflowStore };
|
|
16
|
+
//# sourceMappingURL=composite-overflow-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-overflow-store.d.ts","names":["Store","StoreProps","PopoverStoreFunctions","PopoverStoreOptions","PopoverStoreState","createCompositeOverflowStore","CompositeOverflowStoreProps","CompositeOverflowStore","props","CompositeOverflowStoreState","CompositeOverflowStoreFunctions","CompositeOverflowStoreOptions"],"sources":["../../src/composite/composite-overflow-store.d.ts"],"mappings":";;;;;;AAKA;iBAAwBK,4BAAAA,CAA6BG,KAAAA,GAAQF,2BAAAA,GAA8BC,sBAAsB;AAAA,UAChGE,2BAAAA,SAAoCL,iBAAiB;AAAA,UAErDM,+BAAAA,SAAwCR,qBAAqB;AAAA,UAE7DS,6BAAAA,SAAsCR,mBAAmB;AAAA,UAEzDG,2BAAAA,SAAoCK,6BAAAA,EAA+BV,UAAAA,CAAWQ,2BAAAA;AAAAA,UAE9EF,sBAAAA,SAA+BG,+BAAAA,EAAiCV,KAAAA,CAAMS,2BAAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createPopoverStore } from "../popover/popover-store.js";
|
|
2
|
+
//#region src/composite/composite-overflow-store.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a compositeOverflow store.
|
|
5
|
+
*/
|
|
6
|
+
function createCompositeOverflowStore(props = {}) {
|
|
7
|
+
return createPopoverStore(props);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createCompositeOverflowStore };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=composite-overflow-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-overflow-store.js","names":[],"sources":["../../src/composite/composite-overflow-store.ts"],"sourcesContent":["import type { Store, StoreProps } from \"@ariakit/store\";\nimport type {\n PopoverStoreFunctions,\n PopoverStoreOptions,\n PopoverStoreState,\n} from \"../popover/popover-store.ts\";\nimport { createPopoverStore } from \"../popover/popover-store.ts\";\n\n/**\n * Creates a compositeOverflow store.\n */\nexport function createCompositeOverflowStore(\n props: CompositeOverflowStoreProps = {},\n): CompositeOverflowStore {\n return createPopoverStore(props);\n}\n\nexport interface CompositeOverflowStoreState extends PopoverStoreState {}\n\nexport interface CompositeOverflowStoreFunctions extends PopoverStoreFunctions {}\n\nexport interface CompositeOverflowStoreOptions extends PopoverStoreOptions {}\n\nexport interface CompositeOverflowStoreProps\n extends\n CompositeOverflowStoreOptions,\n StoreProps<CompositeOverflowStoreState> {}\n\nexport interface CompositeOverflowStore\n extends CompositeOverflowStoreFunctions, Store<CompositeOverflowStoreState> {}\n"],"mappings":";;;;;AAWA,SAAgB,6BACd,QAAqC,CAAC,GACd;CACxB,OAAO,mBAAmB,KAAK;AACjC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as CompositeStoreOrientation, c as createCompositeStore, i as CompositeStoreOptions, n as CompositeStoreFunctions, o as CompositeStoreProps, r as CompositeStoreItem, s as CompositeStoreState, t as CompositeStore } from "../composite-store-B-iDEtZZ.js";
|
|
2
|
+
export { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreOrientation, CompositeStoreProps, CompositeStoreState, createCompositeStore };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createCollectionStore } from "../collection/collection-store.js";
|
|
2
|
+
import { createStore, setup, sync } from "@ariakit/store";
|
|
3
|
+
import { defaultValue, flatten2DArray, reverseArray } from "@ariakit/utils";
|
|
4
|
+
//#region src/composite/composite-store.ts
|
|
5
|
+
const NULL_ITEM = { id: null };
|
|
6
|
+
function findFirstEnabledItem(items, excludeId) {
|
|
7
|
+
return items.find((item) => {
|
|
8
|
+
if (excludeId) return !item.disabled && item.id !== excludeId;
|
|
9
|
+
return !item.disabled;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function getEnabledItems(items, excludeId) {
|
|
13
|
+
return items.filter((item) => {
|
|
14
|
+
if (excludeId) return !item.disabled && item.id !== excludeId;
|
|
15
|
+
return !item.disabled;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function getItemsInRow(items, rowId) {
|
|
19
|
+
return items.filter((item) => item.rowId === rowId);
|
|
20
|
+
}
|
|
21
|
+
function flipItems(items, activeId, shouldInsertNullItem = false) {
|
|
22
|
+
const index = items.findIndex((item) => item.id === activeId);
|
|
23
|
+
return [
|
|
24
|
+
...items.slice(index + 1),
|
|
25
|
+
...shouldInsertNullItem ? [NULL_ITEM] : [],
|
|
26
|
+
...items.slice(0, index)
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
function groupItemsByRows(items) {
|
|
30
|
+
const rows = [];
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
|
|
33
|
+
if (row) row.push(item);
|
|
34
|
+
else rows.push([item]);
|
|
35
|
+
}
|
|
36
|
+
return rows;
|
|
37
|
+
}
|
|
38
|
+
function getMaxRowLength(array) {
|
|
39
|
+
let maxLength = 0;
|
|
40
|
+
for (const { length } of array) if (length > maxLength) maxLength = length;
|
|
41
|
+
return maxLength;
|
|
42
|
+
}
|
|
43
|
+
function createEmptyItem(rowId) {
|
|
44
|
+
return {
|
|
45
|
+
id: "__EMPTY_ITEM__",
|
|
46
|
+
disabled: true,
|
|
47
|
+
rowId
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function normalizeRows(rows, activeId, focusShift) {
|
|
51
|
+
const maxLength = getMaxRowLength(rows);
|
|
52
|
+
for (const row of rows) for (let i = 0; i < maxLength; i += 1) {
|
|
53
|
+
const item = row[i];
|
|
54
|
+
if (!item || focusShift && item.disabled) {
|
|
55
|
+
const previousItem = i === 0 && focusShift ? findFirstEnabledItem(row) : row[i - 1];
|
|
56
|
+
row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return rows;
|
|
60
|
+
}
|
|
61
|
+
function verticalizeItems(items) {
|
|
62
|
+
const rows = groupItemsByRows(items);
|
|
63
|
+
const maxLength = getMaxRowLength(rows);
|
|
64
|
+
const verticalized = [];
|
|
65
|
+
for (let i = 0; i < maxLength; i += 1) for (const row of rows) {
|
|
66
|
+
const item = row[i];
|
|
67
|
+
if (item) verticalized.push({
|
|
68
|
+
...item,
|
|
69
|
+
rowId: item.rowId ? `${i}` : void 0
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return verticalized;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a composite store.
|
|
76
|
+
*/
|
|
77
|
+
function createCompositeStore(props = {}) {
|
|
78
|
+
const syncState = props.store?.getState();
|
|
79
|
+
const collection = createCollectionStore(props);
|
|
80
|
+
const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
|
|
81
|
+
const composite = createStore({
|
|
82
|
+
...collection.getState(),
|
|
83
|
+
id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
|
|
84
|
+
activeId,
|
|
85
|
+
baseElement: defaultValue(syncState?.baseElement, null),
|
|
86
|
+
includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
|
|
87
|
+
moves: defaultValue(syncState?.moves, 0),
|
|
88
|
+
orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
|
|
89
|
+
rtl: defaultValue(props.rtl, syncState?.rtl, false),
|
|
90
|
+
virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
|
|
91
|
+
focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
|
|
92
|
+
focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
|
|
93
|
+
focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
|
|
94
|
+
}, collection, props.store);
|
|
95
|
+
setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
|
|
96
|
+
composite.setState("activeId", (activeId) => {
|
|
97
|
+
if (activeId !== void 0) return activeId;
|
|
98
|
+
return findFirstEnabledItem(state.renderedItems)?.id;
|
|
99
|
+
});
|
|
100
|
+
}));
|
|
101
|
+
const getNextId = (direction = "next", options = {}) => {
|
|
102
|
+
const defaultState = composite.getState();
|
|
103
|
+
const { skip = 0, activeId = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options;
|
|
104
|
+
const isVerticalDirection = direction === "up" || direction === "down";
|
|
105
|
+
const isNextDirection = direction === "next" || direction === "down";
|
|
106
|
+
const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
|
|
107
|
+
const canShift = focusShift && !skip;
|
|
108
|
+
let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId, canShift));
|
|
109
|
+
items = canReverse ? reverseArray(items) : items;
|
|
110
|
+
items = isVerticalDirection ? verticalizeItems(items) : items;
|
|
111
|
+
if (activeId == null) return findFirstEnabledItem(items)?.id;
|
|
112
|
+
const activeItem = items.find((item) => item.id === activeId);
|
|
113
|
+
if (!activeItem) return findFirstEnabledItem(items)?.id;
|
|
114
|
+
const isGrid = items.some((item) => item.rowId);
|
|
115
|
+
const activeIndex = items.indexOf(activeItem);
|
|
116
|
+
const nextItems = items.slice(activeIndex + 1);
|
|
117
|
+
const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
|
|
118
|
+
if (skip) {
|
|
119
|
+
const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId);
|
|
120
|
+
return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
|
|
121
|
+
}
|
|
122
|
+
const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
|
|
123
|
+
const canWrap = isGrid && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
|
|
124
|
+
const hasNullItem = isNextDirection ? (!isGrid || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
|
|
125
|
+
if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId, hasNullItem), activeId)?.id;
|
|
126
|
+
if (canWrap) {
|
|
127
|
+
const nextItem = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId);
|
|
128
|
+
return hasNullItem ? nextItem?.id || null : nextItem?.id;
|
|
129
|
+
}
|
|
130
|
+
const nextItem = findFirstEnabledItem(nextItemsInRow, activeId);
|
|
131
|
+
if (!nextItem && hasNullItem) return null;
|
|
132
|
+
return nextItem?.id;
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
...collection,
|
|
136
|
+
...composite,
|
|
137
|
+
setBaseElement: (element) => composite.setState("baseElement", element),
|
|
138
|
+
setActiveId: (id) => composite.setState("activeId", id),
|
|
139
|
+
move: (id) => {
|
|
140
|
+
if (id === void 0) return;
|
|
141
|
+
composite.setState("activeId", id);
|
|
142
|
+
composite.setState("moves", (moves) => moves + 1);
|
|
143
|
+
},
|
|
144
|
+
first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
|
|
145
|
+
last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
|
|
146
|
+
next: (options) => {
|
|
147
|
+
if (options !== void 0 && typeof options === "number") options = { skip: options };
|
|
148
|
+
return getNextId("next", options);
|
|
149
|
+
},
|
|
150
|
+
previous: (options) => {
|
|
151
|
+
if (options !== void 0 && typeof options === "number") options = { skip: options };
|
|
152
|
+
return getNextId("previous", options);
|
|
153
|
+
},
|
|
154
|
+
down: (options) => {
|
|
155
|
+
if (options !== void 0 && typeof options === "number") options = { skip: options };
|
|
156
|
+
return getNextId("down", options);
|
|
157
|
+
},
|
|
158
|
+
up: (options) => {
|
|
159
|
+
if (options !== void 0 && typeof options === "number") options = { skip: options };
|
|
160
|
+
return getNextId("up", options);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { createCompositeStore };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=composite-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-store.js","names":[],"sources":["../../src/composite/composite-store.ts"],"sourcesContent":["import { createStore, setup, sync } from \"@ariakit/store\";\nimport type { Store, StoreOptions, StoreProps } from \"@ariakit/store\";\nimport { flatten2DArray, reverseArray, defaultValue } from \"@ariakit/utils\";\nimport type { SetState } from \"@ariakit/utils\";\nimport type {\n CollectionStoreFunctions,\n CollectionStoreItem,\n CollectionStoreOptions,\n CollectionStoreState,\n} from \"../collection/collection-store.ts\";\nimport { createCollectionStore } from \"../collection/collection-store.ts\";\n\ntype Orientation = \"horizontal\" | \"vertical\" | \"both\";\n\ninterface NextOptions extends Pick<\n Partial<CompositeStoreState>,\n | \"activeId\"\n | \"focusShift\"\n | \"focusLoop\"\n | \"focusWrap\"\n | \"includesBaseElement\"\n | \"renderedItems\"\n | \"rtl\"\n> {\n /**\n * The number of items to skip.\n */\n skip?: number;\n}\n\nconst NULL_ITEM = { id: null as unknown as string };\n\nfunction findFirstEnabledItem(items: CompositeStoreItem[], excludeId?: string) {\n return items.find((item) => {\n if (excludeId) {\n return !item.disabled && item.id !== excludeId;\n }\n return !item.disabled;\n });\n}\n\nfunction getEnabledItems(items: CompositeStoreItem[], excludeId?: string) {\n return items.filter((item) => {\n if (excludeId) {\n return !item.disabled && item.id !== excludeId;\n }\n return !item.disabled;\n });\n}\n\nfunction getItemsInRow(items: CompositeStoreItem[], rowId?: string) {\n return items.filter((item) => item.rowId === rowId);\n}\n\nfunction flipItems(\n items: CompositeStoreItem[],\n activeId: string,\n shouldInsertNullItem = false,\n): CompositeStoreItem[] {\n const index = items.findIndex((item) => item.id === activeId);\n return [\n ...items.slice(index + 1),\n ...(shouldInsertNullItem ? [NULL_ITEM] : []),\n ...items.slice(0, index),\n ];\n}\n\nfunction groupItemsByRows(items: CompositeStoreItem[]) {\n const rows: CompositeStoreItem[][] = [];\n for (const item of items) {\n const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);\n if (row) {\n row.push(item);\n } else {\n rows.push([item]);\n }\n }\n return rows;\n}\n\nfunction getMaxRowLength(array: CompositeStoreItem[][]) {\n let maxLength = 0;\n for (const { length } of array) {\n if (length > maxLength) {\n maxLength = length;\n }\n }\n return maxLength;\n}\n\nfunction createEmptyItem(rowId?: string) {\n return {\n id: \"__EMPTY_ITEM__\",\n disabled: true,\n rowId,\n };\n}\n\nfunction normalizeRows(\n rows: CompositeStoreItem[][],\n activeId?: string | null,\n focusShift?: boolean,\n) {\n const maxLength = getMaxRowLength(rows);\n for (const row of rows) {\n for (let i = 0; i < maxLength; i += 1) {\n const item = row[i];\n if (!item || (focusShift && item.disabled)) {\n const isFirst = i === 0;\n const previousItem =\n isFirst && focusShift ? findFirstEnabledItem(row) : row[i - 1];\n row[i] =\n previousItem && activeId !== previousItem.id && focusShift\n ? previousItem\n : createEmptyItem(previousItem?.rowId);\n }\n }\n }\n return rows;\n}\n\nfunction verticalizeItems(items: CompositeStoreItem[]) {\n const rows = groupItemsByRows(items);\n const maxLength = getMaxRowLength(rows);\n const verticalized: CompositeStoreItem[] = [];\n for (let i = 0; i < maxLength; i += 1) {\n for (const row of rows) {\n const item = row[i];\n if (item) {\n verticalized.push({\n ...item,\n // If there's no rowId, it means that it's not a grid composite, but\n // a single row instead. So, instead of verticalizing it, that is,\n // assigning a different rowId based on the column index, we keep it\n // undefined so they will be part of the same row. This is useful\n // when using up/down on one-dimensional composites.\n rowId: item.rowId ? `${i}` : undefined,\n });\n }\n }\n }\n return verticalized;\n}\n\n/**\n * Creates a composite store.\n */\nexport function createCompositeStore<\n T extends CompositeStoreItem = CompositeStoreItem,\n>(props: CompositeStoreProps<T> = {}): CompositeStore<T> {\n const syncState = props.store?.getState();\n\n const collection = createCollectionStore(props);\n\n const activeId = defaultValue(\n props.activeId,\n syncState?.activeId,\n props.defaultActiveId,\n );\n\n const initialState: CompositeStoreState<T> = {\n ...collection.getState(),\n id:\n defaultValue(props.id, syncState?.id) ??\n `id-${Math.random().toString(36).slice(2, 8)}`,\n activeId,\n baseElement: defaultValue(syncState?.baseElement, null),\n includesBaseElement: defaultValue(\n props.includesBaseElement,\n syncState?.includesBaseElement,\n activeId === null,\n ),\n moves: defaultValue(syncState?.moves, 0),\n orientation: defaultValue(\n props.orientation,\n syncState?.orientation,\n \"both\" as const,\n ),\n rtl: defaultValue(props.rtl, syncState?.rtl, false),\n virtualFocus: defaultValue(\n props.virtualFocus,\n syncState?.virtualFocus,\n false,\n ),\n focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),\n focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),\n focusShift: defaultValue(props.focusShift, syncState?.focusShift, false),\n };\n\n const composite = createStore(initialState, collection, props.store);\n\n // When the activeId is undefined, we need to find the first enabled item and\n // set it as the activeId.\n setup(composite, () =>\n sync(composite, [\"renderedItems\", \"activeId\"], (state) => {\n composite.setState(\"activeId\", (activeId) => {\n if (activeId !== undefined) return activeId;\n return findFirstEnabledItem(state.renderedItems)?.id;\n });\n }),\n );\n\n const getNextId = (\n direction: \"next\" | \"previous\" | \"up\" | \"down\" = \"next\",\n options: NextOptions = {},\n ): string | null | undefined => {\n const defaultState = composite.getState();\n const {\n skip = 0,\n activeId = defaultState.activeId,\n focusShift = defaultState.focusShift,\n focusLoop = defaultState.focusLoop,\n focusWrap = defaultState.focusWrap,\n includesBaseElement = defaultState.includesBaseElement,\n renderedItems = defaultState.renderedItems,\n rtl = defaultState.rtl,\n } = options;\n\n const isVerticalDirection = direction === \"up\" || direction === \"down\";\n const isNextDirection = direction === \"next\" || direction === \"down\";\n\n const canReverse = isNextDirection\n ? rtl && !isVerticalDirection\n : !rtl || isVerticalDirection;\n\n const canShift = focusShift && !skip;\n\n let items = !isVerticalDirection\n ? renderedItems\n : flatten2DArray(\n normalizeRows(groupItemsByRows(renderedItems), activeId, canShift),\n );\n\n items = canReverse ? reverseArray(items) : items;\n items = isVerticalDirection ? verticalizeItems(items) : items;\n\n if (activeId == null) {\n // If there's no item focused, we just move the first one.\n return findFirstEnabledItem(items)?.id;\n }\n\n const activeItem = items.find((item) => item.id === activeId);\n if (!activeItem) {\n // If there's no item focused, we just move to the first one.\n return findFirstEnabledItem(items)?.id;\n }\n\n const isGrid = items.some((item) => item.rowId);\n const activeIndex = items.indexOf(activeItem);\n const nextItems = items.slice(activeIndex + 1);\n const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);\n\n if (skip) {\n // Home, End, PageUp, PageDown\n const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId);\n const nextItem =\n nextEnabledItemsInRow.slice(skip)[0] ||\n // If we can't find an item, just return the last one.\n nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];\n return nextItem?.id;\n }\n\n const canLoop =\n focusLoop &&\n (isVerticalDirection\n ? focusLoop !== \"horizontal\"\n : focusLoop !== \"vertical\");\n\n const canWrap =\n isGrid &&\n focusWrap &&\n (isVerticalDirection\n ? focusWrap !== \"horizontal\"\n : focusWrap !== \"vertical\");\n\n // When calling next directly, hasNullItem will only be true if if it's not\n // a grid and focusLoop is set to true, which means that pressing right or\n // down keys on grids will never focus the composite container element. On\n // one-dimensional composites that don't loop, pressing right or down keys\n // also doesn't focus on the composite container element.\n const hasNullItem = isNextDirection\n ? (!isGrid || isVerticalDirection) && canLoop && includesBaseElement\n : isVerticalDirection\n ? includesBaseElement\n : false;\n\n if (canLoop) {\n const loopItems =\n canWrap && !hasNullItem\n ? items\n : getItemsInRow(items, activeItem.rowId);\n const sortedItems = flipItems(loopItems, activeId, hasNullItem);\n const nextItem = findFirstEnabledItem(sortedItems, activeId);\n return nextItem?.id;\n }\n\n if (canWrap) {\n const nextItem = findFirstEnabledItem(\n // We can use nextItems, which contains all the next items, including\n // items from other rows, to wrap between rows. However, if there is a\n // null item (the composite container), we'll only use the next items in\n // the row. So moving next from the last item will focus on the\n // composite container. On grid composites, horizontal navigation never\n // focuses on the composite container, only vertical.\n hasNullItem ? nextItemsInRow : nextItems,\n activeId,\n );\n const nextId = hasNullItem ? nextItem?.id || null : nextItem?.id;\n return nextId;\n }\n\n const nextItem = findFirstEnabledItem(nextItemsInRow, activeId);\n if (!nextItem && hasNullItem) {\n return null;\n }\n return nextItem?.id;\n };\n\n return {\n ...collection,\n ...composite,\n\n setBaseElement: (element) => composite.setState(\"baseElement\", element),\n setActiveId: (id) => composite.setState(\"activeId\", id),\n\n move: (id) => {\n // move() does nothing\n if (id === undefined) return;\n composite.setState(\"activeId\", id);\n composite.setState(\"moves\", (moves) => moves + 1);\n },\n\n first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,\n last: () =>\n findFirstEnabledItem(reverseArray(composite.getState().renderedItems))\n ?.id,\n\n next: (options) => {\n if (options !== undefined && typeof options === \"number\") {\n options = { skip: options };\n }\n return getNextId(\"next\", options);\n },\n\n previous: (options) => {\n if (options !== undefined && typeof options === \"number\") {\n options = { skip: options };\n }\n return getNextId(\"previous\", options);\n },\n\n down: (options) => {\n if (options !== undefined && typeof options === \"number\") {\n options = { skip: options };\n }\n return getNextId(\"down\", options);\n },\n\n up: (options) => {\n if (options !== undefined && typeof options === \"number\") {\n options = { skip: options };\n }\n return getNextId(\"up\", options);\n },\n };\n}\n\nexport type CompositeStoreOrientation = Orientation;\n\nexport interface CompositeStoreItem extends CollectionStoreItem {\n /**\n * The row id of the item. This is only used on two-dimensional composite\n * widgets (when using\n * [`CompositeRow`](https://ariakit.com/reference/composite-row)).\n */\n rowId?: string;\n /**\n * If enabled, the item will be disabled and users won't be able to focus on\n * it using arrow keys.\n */\n disabled?: boolean;\n /**\n * The item children. This can be used for typeahead purposes.\n */\n children?: string;\n}\n\nexport interface CompositeStoreState<\n T extends CompositeStoreItem = CompositeStoreItem,\n> extends CollectionStoreState<T> {\n /**\n * The ID of the composite store is used to reference elements within the\n * composite widget before hydration. If not provided, a random ID will be\n * generated.\n */\n id: string;\n /**\n * The composite element itself. Typically, it's the wrapper element that\n * contains composite items. However, in a combobox, it's the input element.\n *\n * Live examples:\n * - [Sliding Menu](https://ariakit.com/examples/menu-slide)\n */\n baseElement: HTMLElement | null;\n /**\n * If enabled, the composite element will act as an\n * [aria-activedescendant](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_activedescendant)\n * container instead of [roving\n * tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex).\n * DOM focus will remain on the composite element while its items receive\n * virtual focus.\n *\n * In both scenarios, the item in focus will carry the\n * [`data-active-item`](https://ariakit.com/guide/styling#data-active-item)\n * attribute.\n *\n * Live examples:\n * - [Select with Combobox and\n * Tabs](https://ariakit.com/examples/select-combobox-tab)\n * @default false\n */\n virtualFocus: boolean;\n /**\n * Defines the orientation of the composite widget. If the composite has a\n * single row or column (one-dimensional), the `orientation` value determines\n * which arrow keys can be used to move focus:\n * - `both`: all arrow keys work.\n * - `horizontal`: only left and right arrow keys work.\n * - `vertical`: only up and down arrow keys work.\n *\n * It doesn't have any effect on two-dimensional composites.\n * @default \"both\"\n */\n orientation: Orientation;\n /**\n * Determines how the\n * [`next`](https://ariakit.com/reference/use-composite-store#next) and\n * [`previous`](https://ariakit.com/reference/use-composite-store#previous)\n * functions will behave. If `rtl` is set to `true`, they will be inverted.\n *\n * This only affects the composite widget behavior. You still need to set\n * `dir=\"rtl\"` on HTML/CSS.\n * @default false\n */\n rtl: boolean;\n /**\n * Determines how the focus behaves when the user reaches the end of the\n * composite widget.\n *\n * On one-dimensional composite widgets:\n * - `true` loops from the last item to the first item and vice-versa.\n * - `horizontal` loops only if\n * [`orientation`](https://ariakit.com/reference/composite-provider#orientation)\n * is `horizontal` or not set.\n * - `vertical` loops only if\n * [`orientation`](https://ariakit.com/reference/composite-provider#orientation)\n * is `vertical` or not set.\n * - If\n * [`includesBaseElement`](https://ariakit.com/reference/composite-provider#includesbaseelement)\n * is set to `true` (or\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * is initially set to `null`), the composite element will be focused in\n * between the last and first items.\n *\n * On two-dimensional composite widgets (when using\n * [`CompositeRow`](https://ariakit.com/reference/composite-row) or explicitly\n * passing a [`rowId`](https://ariakit.com/reference/composite-item#rowid)\n * prop to composite items):\n * - `true` loops from the last row/column item to the first item in the same\n * row/column and vice-versa. If it's the last item in the last row, it\n * moves to the first item in the first row and vice-versa.\n * - `horizontal` loops only from the last row item to the first item in the\n * same row.\n * - `vertical` loops only from the last column item to the first item in the\n * column row.\n * - If\n * [`includesBaseElement`](https://ariakit.com/reference/composite-provider#includesbaseelement)\n * is set to `true` (or\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * is initially set to `null`), vertical loop will have no effect as moving\n * down from the last row or up from the first row will focus on the\n * composite element.\n * - If\n * [`focusWrap`](https://ariakit.com/reference/composite-provider#focuswrap)\n * matches the value of `focusLoop`, it'll wrap between the last item in the\n * last row or column and the first item in the first row or column and\n * vice-versa.\n *\n * Live examples:\n * - [Command Menu](https://ariakit.com/examples/dialog-combobox-command-menu)\n * - [Command Menu with\n * Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)\n * @default false\n */\n focusLoop: boolean | Orientation;\n /**\n * **Works only on two-dimensional composite widgets**.\n *\n * If enabled, moving to the next item from the last one in a row or column\n * will focus on the first item in the next row or column and vice-versa.\n * - `true` wraps between rows and columns.\n * - `horizontal` wraps only between rows.\n * - `vertical` wraps only between columns.\n * - If\n * [`focusLoop`](https://ariakit.com/reference/composite-provider#focusloop)\n * matches the value of `focusWrap`, it'll wrap between the last item in the\n * last row or column and the first item in the first row or column and\n * vice-versa.\n *\n * Live examples:\n * - [Command Menu with\n * Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)\n * @default false\n */\n focusWrap: boolean | Orientation;\n /**\n * **Works only on two-dimensional composite widgets**.\n *\n * If enabled, moving up or down when there's no next item or when the next\n * item is disabled will shift to the item right before it.\n *\n * Live examples:\n * - [Command Menu with\n * Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)\n * @default false\n */\n focusShift: boolean;\n /**\n * The number of times the\n * [`move`](https://ariakit.com/reference/use-composite-store#move) function\n * has been called.\n */\n moves: number;\n /**\n * Indicates if the composite base element (the one with a [composite\n * role](https://w3c.github.io/aria/#composite)) should be part of the focus\n * order when navigating with arrow keys. In other words, moving to the\n * previous element when the first item is in focus will focus on the\n * composite element itself. The same applies to the last item when moving to\n * the next element.\n *\n * Live examples:\n * - [Submenu with\n * Combobox](https://ariakit.com/examples/menu-nested-combobox)\n * - [Command Menu](https://ariakit.com/examples/dialog-combobox-command-menu)\n * @default false\n */\n includesBaseElement: boolean;\n /**\n * The current active item `id`. The active item is the element within the\n * composite widget that has either DOM or virtual focus (in case\n * [`virtualFocus`](https://ariakit.com/reference/composite-provider#virtualfocus)\n * is enabled).\n * - `null` represents the base composite element (the one with a [composite\n * role](https://w3c.github.io/aria/#composite)). Users will be able to\n * navigate out of it using arrow keys.\n * - If `activeId` is initially set to `null`, the\n * [`includesBaseElement`](https://ariakit.com/reference/composite-provider#includesbaseelement)\n * prop will also default to `true`, which means the base composite element\n * itself will have focus and users will be able to navigate to it using\n * arrow keys.\n *\n * Live examples:\n * - [Combobox with Tabs](https://ariakit.com/examples/combobox-tabs)\n */\n activeId: string | null | undefined;\n}\n\nexport interface CompositeStoreFunctions<\n T extends CompositeStoreItem = CompositeStoreItem,\n> extends CollectionStoreFunctions<T> {\n /**\n * Sets the `baseElement` state.\n */\n setBaseElement: SetState<CompositeStoreState<T>[\"baseElement\"]>;\n /**\n * Sets the\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * state _without moving focus_. If you want to move focus, use the\n * [`move`](https://ariakit.com/reference/use-composite-store#move) function\n * instead.\n * @example\n * // Sets the composite element as the active item\n * store.setActiveId(null);\n * // Sets the item with id \"item-1\" as the active item\n * store.setActiveId(\"item-1\");\n * // Sets the next item as the active item\n * store.setActiveId(store.next());\n */\n setActiveId: SetState<CompositeStoreState<T>[\"activeId\"]>;\n /**\n * Moves focus to a given item id and sets it as the active item.\n * - Passing `null` will focus on the composite element itself (the one with a\n * [composite role](https://w3c.github.io/aria/#composite)). Users will be\n * able to navigate out of it using arrow keys.\n * - If you want to set the active item id _without moving focus_, use the\n * [`setActiveId`](https://ariakit.com/reference/use-composite-store#setactiveid)\n * function instead.\n *\n * Live examples:\n * - [Select Grid](https://ariakit.com/examples/select-grid)\n * @example\n * // Moves focus to the composite element\n * store.move(null);\n * // Moves focus to the item with id \"item-1\"\n * store.move(\"item-1\");\n * // Moves focus to the next item\n * store.move(store.next());\n */\n move: (id?: string | null) => void;\n /**\n * Returns the id of the next enabled item based on the current\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * state. You can pass additional options to override the current state.\n * @example\n * const nextId = store.next();\n */\n next: {\n (options?: NextOptions): string | null | undefined;\n /**\n * @deprecated Use the object syntax instead: `next({ skip: 2 })`.\n */\n (skip?: number): string | null | undefined;\n };\n /**\n * Returns the id of the previous enabled item based on the current\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * state. You can pass additional options to override the current state.\n * @example\n * const previousId = store.previous();\n */\n previous: {\n (options?: NextOptions): string | null | undefined;\n /**\n * @deprecated Use the object syntax instead: `previous({ skip: 2 })`.\n */\n (skip?: number): string | null | undefined;\n };\n /**\n * Returns the id of the enabled item above based on the current\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * state. You can pass additional options to override the current state.\n * @example\n * const upId = store.up();\n */\n up: {\n (options?: NextOptions): string | null | undefined;\n /**\n * @deprecated Use the object syntax instead: `up({ skip: 2 })`.\n */\n (skip?: number): string | null | undefined;\n };\n /**\n * Returns the id of the enabled item below based on the current\n * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)\n * state. You can pass additional options to override the current state.\n * @example\n * const downId = store.down();\n */\n down: {\n (options?: NextOptions): string | null | undefined;\n /**\n * @deprecated Use the object syntax instead: `down({ skip: 2 })`.\n */\n (skip?: number): string | null | undefined;\n };\n /**\n * Returns the id of the first enabled item.\n */\n first: () => string | null | undefined;\n /**\n * Returns the id of the last enabled item.\n */\n last: () => string | null | undefined;\n}\n\nexport interface CompositeStoreOptions<\n T extends CompositeStoreItem = CompositeStoreItem,\n>\n extends\n CollectionStoreOptions<T>,\n StoreOptions<\n CompositeStoreState<T>,\n | \"id\"\n | \"virtualFocus\"\n | \"orientation\"\n | \"rtl\"\n | \"focusLoop\"\n | \"focusWrap\"\n | \"focusShift\"\n | \"includesBaseElement\"\n | \"activeId\"\n > {\n /**\n * The composite item id that should be active by default when the composite\n * widget is rendered. If `null`, the composite element itself will have focus\n * and users will be able to navigate to it using arrow keys. If `undefined`,\n * the first enabled item will be focused.\n */\n defaultActiveId?: CompositeStoreState<T>[\"activeId\"];\n}\n\nexport interface CompositeStoreProps<\n T extends CompositeStoreItem = CompositeStoreItem,\n>\n extends CompositeStoreOptions<T>, StoreProps<CompositeStoreState<T>> {}\n\nexport interface CompositeStore<\n T extends CompositeStoreItem = CompositeStoreItem,\n>\n extends CompositeStoreFunctions<T>, Store<CompositeStoreState<T>> {}\n"],"mappings":";;;;AA8BA,MAAM,YAAY,EAAE,IAAI,KAA0B;AAElD,SAAS,qBAAqB,OAA6B,WAAoB;CAC7E,OAAO,MAAM,MAAM,SAAS;EAC1B,IAAI,WACF,OAAO,CAAC,KAAK,YAAY,KAAK,OAAO;EAEvC,OAAO,CAAC,KAAK;CACf,CAAC;AACH;AAEA,SAAS,gBAAgB,OAA6B,WAAoB;CACxE,OAAO,MAAM,QAAQ,SAAS;EAC5B,IAAI,WACF,OAAO,CAAC,KAAK,YAAY,KAAK,OAAO;EAEvC,OAAO,CAAC,KAAK;CACf,CAAC;AACH;AAEA,SAAS,cAAc,OAA6B,OAAgB;CAClE,OAAO,MAAM,QAAQ,SAAS,KAAK,UAAU,KAAK;AACpD;AAEA,SAAS,UACP,OACA,UACA,uBAAuB,OACD;CACtB,MAAM,QAAQ,MAAM,WAAW,SAAS,KAAK,OAAO,QAAQ;CAC5D,OAAO;EACL,GAAG,MAAM,MAAM,QAAQ,CAAC;EACxB,GAAI,uBAAuB,CAAC,SAAS,IAAI,CAAC;EAC1C,GAAG,MAAM,MAAM,GAAG,KAAK;CACzB;AACF;AAEA,SAAS,iBAAiB,OAA6B;CACrD,MAAM,OAA+B,CAAC;CACtC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,KAAK,MAAM,eAAe,WAAW,IAAI,UAAU,KAAK,KAAK;EACzE,IAAI,KACF,IAAI,KAAK,IAAI;OAEb,KAAK,KAAK,CAAC,IAAI,CAAC;CAEpB;CACA,OAAO;AACT;AAEA,SAAS,gBAAgB,OAA+B;CACtD,IAAI,YAAY;CAChB,KAAK,MAAM,EAAE,YAAY,OACvB,IAAI,SAAS,WACX,YAAY;CAGhB,OAAO;AACT;AAEA,SAAS,gBAAgB,OAAgB;CACvC,OAAO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,KAAa,OAAO,YAAY,UAC9C,UAAU,EAAE,MAAM,QAAQ;GAE5B,OAAO,UAAU,QAAQ,OAAO;EAClC;EAEA,WAAW,YAAY;GACrB,IAAI,YAAY,KAAA,KAAa,OAAO,YAAY,UAC9C,UAAU,EAAE,MAAM,QAAQ;GAE5B,OAAO,UAAU,YAAY,OAAO;EACtC;EAEA,OAAO,YAAY;GACjB,IAAI,YAAY,KAAA,KAAa,OAAO,YAAY,UAC9C,UAAU,EAAE,MAAM,QAAQ;GAE5B,OAAO,UAAU,QAAQ,OAAO;EAClC;EAEA,KAAK,YAAY;GACf,IAAI,YAAY,KAAA,KAAa,OAAO,YAAY,UAC9C,UAAU,EAAE,MAAM,QAAQ;GAE5B,OAAO,UAAU,MAAM,OAAO;EAChC;CACF;AACF"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { i as CollectionStoreOptions, n as CollectionStoreFunctions, o as CollectionStoreState, r as CollectionStoreItem } from "./collection-store-yNe83BiS.js";
|
|
2
|
+
import { Store, StoreOptions, StoreProps } from "@ariakit/store";
|
|
3
|
+
import { SetState } from "@ariakit/utils";
|
|
4
|
+
|
|
5
|
+
//#region src/composite/composite-store.d.ts
|
|
6
|
+
type Orientation = "horizontal" | "vertical" | "both";
|
|
7
|
+
interface NextOptions extends Pick<Partial<CompositeStoreState>, "activeId" | "focusShift" | "focusLoop" | "focusWrap" | "includesBaseElement" | "renderedItems" | "rtl"> {
|
|
8
|
+
/**
|
|
9
|
+
* The number of items to skip.
|
|
10
|
+
*/
|
|
11
|
+
skip?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a composite store.
|
|
15
|
+
*/
|
|
16
|
+
declare function createCompositeStore<T extends CompositeStoreItem = CompositeStoreItem>(props?: CompositeStoreProps<T>): CompositeStore<T>;
|
|
17
|
+
type CompositeStoreOrientation = Orientation;
|
|
18
|
+
interface CompositeStoreItem extends CollectionStoreItem {
|
|
19
|
+
/**
|
|
20
|
+
* The row id of the item. This is only used on two-dimensional composite
|
|
21
|
+
* widgets (when using
|
|
22
|
+
* [`CompositeRow`](https://ariakit.com/reference/composite-row)).
|
|
23
|
+
*/
|
|
24
|
+
rowId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* If enabled, the item will be disabled and users won't be able to focus on
|
|
27
|
+
* it using arrow keys.
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The item children. This can be used for typeahead purposes.
|
|
32
|
+
*/
|
|
33
|
+
children?: string;
|
|
34
|
+
}
|
|
35
|
+
interface CompositeStoreState<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreState<T> {
|
|
36
|
+
/**
|
|
37
|
+
* The ID of the composite store is used to reference elements within the
|
|
38
|
+
* composite widget before hydration. If not provided, a random ID will be
|
|
39
|
+
* generated.
|
|
40
|
+
*/
|
|
41
|
+
id: string;
|
|
42
|
+
/**
|
|
43
|
+
* The composite element itself. Typically, it's the wrapper element that
|
|
44
|
+
* contains composite items. However, in a combobox, it's the input element.
|
|
45
|
+
*
|
|
46
|
+
* Live examples:
|
|
47
|
+
* - [Sliding Menu](https://ariakit.com/examples/menu-slide)
|
|
48
|
+
*/
|
|
49
|
+
baseElement: HTMLElement | null;
|
|
50
|
+
/**
|
|
51
|
+
* If enabled, the composite element will act as an
|
|
52
|
+
* [aria-activedescendant](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_activedescendant)
|
|
53
|
+
* container instead of [roving
|
|
54
|
+
* tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex).
|
|
55
|
+
* DOM focus will remain on the composite element while its items receive
|
|
56
|
+
* virtual focus.
|
|
57
|
+
*
|
|
58
|
+
* In both scenarios, the item in focus will carry the
|
|
59
|
+
* [`data-active-item`](https://ariakit.com/guide/styling#data-active-item)
|
|
60
|
+
* attribute.
|
|
61
|
+
*
|
|
62
|
+
* Live examples:
|
|
63
|
+
* - [Select with Combobox and
|
|
64
|
+
* Tabs](https://ariakit.com/examples/select-combobox-tab)
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
virtualFocus: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Defines the orientation of the composite widget. If the composite has a
|
|
70
|
+
* single row or column (one-dimensional), the `orientation` value determines
|
|
71
|
+
* which arrow keys can be used to move focus:
|
|
72
|
+
* - `both`: all arrow keys work.
|
|
73
|
+
* - `horizontal`: only left and right arrow keys work.
|
|
74
|
+
* - `vertical`: only up and down arrow keys work.
|
|
75
|
+
*
|
|
76
|
+
* It doesn't have any effect on two-dimensional composites.
|
|
77
|
+
* @default "both"
|
|
78
|
+
*/
|
|
79
|
+
orientation: Orientation;
|
|
80
|
+
/**
|
|
81
|
+
* Determines how the
|
|
82
|
+
* [`next`](https://ariakit.com/reference/use-composite-store#next) and
|
|
83
|
+
* [`previous`](https://ariakit.com/reference/use-composite-store#previous)
|
|
84
|
+
* functions will behave. If `rtl` is set to `true`, they will be inverted.
|
|
85
|
+
*
|
|
86
|
+
* This only affects the composite widget behavior. You still need to set
|
|
87
|
+
* `dir="rtl"` on HTML/CSS.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
rtl: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Determines how the focus behaves when the user reaches the end of the
|
|
93
|
+
* composite widget.
|
|
94
|
+
*
|
|
95
|
+
* On one-dimensional composite widgets:
|
|
96
|
+
* - `true` loops from the last item to the first item and vice-versa.
|
|
97
|
+
* - `horizontal` loops only if
|
|
98
|
+
* [`orientation`](https://ariakit.com/reference/composite-provider#orientation)
|
|
99
|
+
* is `horizontal` or not set.
|
|
100
|
+
* - `vertical` loops only if
|
|
101
|
+
* [`orientation`](https://ariakit.com/reference/composite-provider#orientation)
|
|
102
|
+
* is `vertical` or not set.
|
|
103
|
+
* - If
|
|
104
|
+
* [`includesBaseElement`](https://ariakit.com/reference/composite-provider#includesbaseelement)
|
|
105
|
+
* is set to `true` (or
|
|
106
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
107
|
+
* is initially set to `null`), the composite element will be focused in
|
|
108
|
+
* between the last and first items.
|
|
109
|
+
*
|
|
110
|
+
* On two-dimensional composite widgets (when using
|
|
111
|
+
* [`CompositeRow`](https://ariakit.com/reference/composite-row) or explicitly
|
|
112
|
+
* passing a [`rowId`](https://ariakit.com/reference/composite-item#rowid)
|
|
113
|
+
* prop to composite items):
|
|
114
|
+
* - `true` loops from the last row/column item to the first item in the same
|
|
115
|
+
* row/column and vice-versa. If it's the last item in the last row, it
|
|
116
|
+
* moves to the first item in the first row and vice-versa.
|
|
117
|
+
* - `horizontal` loops only from the last row item to the first item in the
|
|
118
|
+
* same row.
|
|
119
|
+
* - `vertical` loops only from the last column item to the first item in the
|
|
120
|
+
* column row.
|
|
121
|
+
* - If
|
|
122
|
+
* [`includesBaseElement`](https://ariakit.com/reference/composite-provider#includesbaseelement)
|
|
123
|
+
* is set to `true` (or
|
|
124
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
125
|
+
* is initially set to `null`), vertical loop will have no effect as moving
|
|
126
|
+
* down from the last row or up from the first row will focus on the
|
|
127
|
+
* composite element.
|
|
128
|
+
* - If
|
|
129
|
+
* [`focusWrap`](https://ariakit.com/reference/composite-provider#focuswrap)
|
|
130
|
+
* matches the value of `focusLoop`, it'll wrap between the last item in the
|
|
131
|
+
* last row or column and the first item in the first row or column and
|
|
132
|
+
* vice-versa.
|
|
133
|
+
*
|
|
134
|
+
* Live examples:
|
|
135
|
+
* - [Command Menu](https://ariakit.com/examples/dialog-combobox-command-menu)
|
|
136
|
+
* - [Command Menu with
|
|
137
|
+
* Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
focusLoop: boolean | Orientation;
|
|
141
|
+
/**
|
|
142
|
+
* **Works only on two-dimensional composite widgets**.
|
|
143
|
+
*
|
|
144
|
+
* If enabled, moving to the next item from the last one in a row or column
|
|
145
|
+
* will focus on the first item in the next row or column and vice-versa.
|
|
146
|
+
* - `true` wraps between rows and columns.
|
|
147
|
+
* - `horizontal` wraps only between rows.
|
|
148
|
+
* - `vertical` wraps only between columns.
|
|
149
|
+
* - If
|
|
150
|
+
* [`focusLoop`](https://ariakit.com/reference/composite-provider#focusloop)
|
|
151
|
+
* matches the value of `focusWrap`, it'll wrap between the last item in the
|
|
152
|
+
* last row or column and the first item in the first row or column and
|
|
153
|
+
* vice-versa.
|
|
154
|
+
*
|
|
155
|
+
* Live examples:
|
|
156
|
+
* - [Command Menu with
|
|
157
|
+
* Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)
|
|
158
|
+
* @default false
|
|
159
|
+
*/
|
|
160
|
+
focusWrap: boolean | Orientation;
|
|
161
|
+
/**
|
|
162
|
+
* **Works only on two-dimensional composite widgets**.
|
|
163
|
+
*
|
|
164
|
+
* If enabled, moving up or down when there's no next item or when the next
|
|
165
|
+
* item is disabled will shift to the item right before it.
|
|
166
|
+
*
|
|
167
|
+
* Live examples:
|
|
168
|
+
* - [Command Menu with
|
|
169
|
+
* Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)
|
|
170
|
+
* @default false
|
|
171
|
+
*/
|
|
172
|
+
focusShift: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* The number of times the
|
|
175
|
+
* [`move`](https://ariakit.com/reference/use-composite-store#move) function
|
|
176
|
+
* has been called.
|
|
177
|
+
*/
|
|
178
|
+
moves: number;
|
|
179
|
+
/**
|
|
180
|
+
* Indicates if the composite base element (the one with a [composite
|
|
181
|
+
* role](https://w3c.github.io/aria/#composite)) should be part of the focus
|
|
182
|
+
* order when navigating with arrow keys. In other words, moving to the
|
|
183
|
+
* previous element when the first item is in focus will focus on the
|
|
184
|
+
* composite element itself. The same applies to the last item when moving to
|
|
185
|
+
* the next element.
|
|
186
|
+
*
|
|
187
|
+
* Live examples:
|
|
188
|
+
* - [Submenu with
|
|
189
|
+
* Combobox](https://ariakit.com/examples/menu-nested-combobox)
|
|
190
|
+
* - [Command Menu](https://ariakit.com/examples/dialog-combobox-command-menu)
|
|
191
|
+
* @default false
|
|
192
|
+
*/
|
|
193
|
+
includesBaseElement: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The current active item `id`. The active item is the element within the
|
|
196
|
+
* composite widget that has either DOM or virtual focus (in case
|
|
197
|
+
* [`virtualFocus`](https://ariakit.com/reference/composite-provider#virtualfocus)
|
|
198
|
+
* is enabled).
|
|
199
|
+
* - `null` represents the base composite element (the one with a [composite
|
|
200
|
+
* role](https://w3c.github.io/aria/#composite)). Users will be able to
|
|
201
|
+
* navigate out of it using arrow keys.
|
|
202
|
+
* - If `activeId` is initially set to `null`, the
|
|
203
|
+
* [`includesBaseElement`](https://ariakit.com/reference/composite-provider#includesbaseelement)
|
|
204
|
+
* prop will also default to `true`, which means the base composite element
|
|
205
|
+
* itself will have focus and users will be able to navigate to it using
|
|
206
|
+
* arrow keys.
|
|
207
|
+
*
|
|
208
|
+
* Live examples:
|
|
209
|
+
* - [Combobox with Tabs](https://ariakit.com/examples/combobox-tabs)
|
|
210
|
+
*/
|
|
211
|
+
activeId: string | null | undefined;
|
|
212
|
+
}
|
|
213
|
+
interface CompositeStoreFunctions<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreFunctions<T> {
|
|
214
|
+
/**
|
|
215
|
+
* Sets the `baseElement` state.
|
|
216
|
+
*/
|
|
217
|
+
setBaseElement: SetState<CompositeStoreState<T>["baseElement"]>;
|
|
218
|
+
/**
|
|
219
|
+
* Sets the
|
|
220
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
221
|
+
* state _without moving focus_. If you want to move focus, use the
|
|
222
|
+
* [`move`](https://ariakit.com/reference/use-composite-store#move) function
|
|
223
|
+
* instead.
|
|
224
|
+
* @example
|
|
225
|
+
* // Sets the composite element as the active item
|
|
226
|
+
* store.setActiveId(null);
|
|
227
|
+
* // Sets the item with id "item-1" as the active item
|
|
228
|
+
* store.setActiveId("item-1");
|
|
229
|
+
* // Sets the next item as the active item
|
|
230
|
+
* store.setActiveId(store.next());
|
|
231
|
+
*/
|
|
232
|
+
setActiveId: SetState<CompositeStoreState<T>["activeId"]>;
|
|
233
|
+
/**
|
|
234
|
+
* Moves focus to a given item id and sets it as the active item.
|
|
235
|
+
* - Passing `null` will focus on the composite element itself (the one with a
|
|
236
|
+
* [composite role](https://w3c.github.io/aria/#composite)). Users will be
|
|
237
|
+
* able to navigate out of it using arrow keys.
|
|
238
|
+
* - If you want to set the active item id _without moving focus_, use the
|
|
239
|
+
* [`setActiveId`](https://ariakit.com/reference/use-composite-store#setactiveid)
|
|
240
|
+
* function instead.
|
|
241
|
+
*
|
|
242
|
+
* Live examples:
|
|
243
|
+
* - [Select Grid](https://ariakit.com/examples/select-grid)
|
|
244
|
+
* @example
|
|
245
|
+
* // Moves focus to the composite element
|
|
246
|
+
* store.move(null);
|
|
247
|
+
* // Moves focus to the item with id "item-1"
|
|
248
|
+
* store.move("item-1");
|
|
249
|
+
* // Moves focus to the next item
|
|
250
|
+
* store.move(store.next());
|
|
251
|
+
*/
|
|
252
|
+
move: (id?: string | null) => void;
|
|
253
|
+
/**
|
|
254
|
+
* Returns the id of the next enabled item based on the current
|
|
255
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
256
|
+
* state. You can pass additional options to override the current state.
|
|
257
|
+
* @example
|
|
258
|
+
* const nextId = store.next();
|
|
259
|
+
*/
|
|
260
|
+
next: {
|
|
261
|
+
(options?: NextOptions): string | null | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* @deprecated Use the object syntax instead: `next({ skip: 2 })`.
|
|
264
|
+
*/
|
|
265
|
+
(skip?: number): string | null | undefined;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Returns the id of the previous enabled item based on the current
|
|
269
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
270
|
+
* state. You can pass additional options to override the current state.
|
|
271
|
+
* @example
|
|
272
|
+
* const previousId = store.previous();
|
|
273
|
+
*/
|
|
274
|
+
previous: {
|
|
275
|
+
(options?: NextOptions): string | null | undefined;
|
|
276
|
+
/**
|
|
277
|
+
* @deprecated Use the object syntax instead: `previous({ skip: 2 })`.
|
|
278
|
+
*/
|
|
279
|
+
(skip?: number): string | null | undefined;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Returns the id of the enabled item above based on the current
|
|
283
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
284
|
+
* state. You can pass additional options to override the current state.
|
|
285
|
+
* @example
|
|
286
|
+
* const upId = store.up();
|
|
287
|
+
*/
|
|
288
|
+
up: {
|
|
289
|
+
(options?: NextOptions): string | null | undefined;
|
|
290
|
+
/**
|
|
291
|
+
* @deprecated Use the object syntax instead: `up({ skip: 2 })`.
|
|
292
|
+
*/
|
|
293
|
+
(skip?: number): string | null | undefined;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Returns the id of the enabled item below based on the current
|
|
297
|
+
* [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
|
|
298
|
+
* state. You can pass additional options to override the current state.
|
|
299
|
+
* @example
|
|
300
|
+
* const downId = store.down();
|
|
301
|
+
*/
|
|
302
|
+
down: {
|
|
303
|
+
(options?: NextOptions): string | null | undefined;
|
|
304
|
+
/**
|
|
305
|
+
* @deprecated Use the object syntax instead: `down({ skip: 2 })`.
|
|
306
|
+
*/
|
|
307
|
+
(skip?: number): string | null | undefined;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Returns the id of the first enabled item.
|
|
311
|
+
*/
|
|
312
|
+
first: () => string | null | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* Returns the id of the last enabled item.
|
|
315
|
+
*/
|
|
316
|
+
last: () => string | null | undefined;
|
|
317
|
+
}
|
|
318
|
+
interface CompositeStoreOptions<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreOptions<T>, StoreOptions<CompositeStoreState<T>, "id" | "virtualFocus" | "orientation" | "rtl" | "focusLoop" | "focusWrap" | "focusShift" | "includesBaseElement" | "activeId"> {
|
|
319
|
+
/**
|
|
320
|
+
* The composite item id that should be active by default when the composite
|
|
321
|
+
* widget is rendered. If `null`, the composite element itself will have focus
|
|
322
|
+
* and users will be able to navigate to it using arrow keys. If `undefined`,
|
|
323
|
+
* the first enabled item will be focused.
|
|
324
|
+
*/
|
|
325
|
+
defaultActiveId?: CompositeStoreState<T>["activeId"];
|
|
326
|
+
}
|
|
327
|
+
interface CompositeStoreProps<T extends CompositeStoreItem = CompositeStoreItem> extends CompositeStoreOptions<T>, StoreProps<CompositeStoreState<T>> {}
|
|
328
|
+
interface CompositeStore<T extends CompositeStoreItem = CompositeStoreItem> extends CompositeStoreFunctions<T>, Store<CompositeStoreState<T>> {}
|
|
329
|
+
//#endregion
|
|
330
|
+
export { CompositeStoreOrientation as a, createCompositeStore as c, CompositeStoreOptions as i, CompositeStoreFunctions as n, CompositeStoreProps as o, CompositeStoreItem as r, CompositeStoreState as s, CompositeStore as t };
|
|
331
|
+
//# sourceMappingURL=composite-store-B-iDEtZZ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-store-B-iDEtZZ.d.ts","names":["Store","StoreOptions","StoreProps","SetState","CollectionStoreFunctions","CollectionStoreItem","CollectionStoreOptions","CollectionStoreState","Orientation","NextOptions","CompositeStoreState","Partial","Pick","skip","createCompositeStore","T","CompositeStoreItem","CompositeStoreProps","CompositeStore","props","CompositeStoreOrientation","rowId","disabled","children","HTMLElement","id","baseElement","virtualFocus","orientation","rtl","focusLoop","focusWrap","focusShift","moves","includesBaseElement","activeId","CompositeStoreFunctions","setBaseElement","setActiveId","move","next","options","previous","up","down","first","last","CompositeStoreOptions","defaultActiveId"],"sources":["../src/composite/composite-store.d.ts"],"mappings":";;;;;KAGKQ,WA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tCqB,cAAAA,EAAgBlC,QAAAA,CAASO,mBAAAA,CAAoBK,CAAAA;EAgHsEf;;;;AAA2B;;;;;;;;;;EAjG9IsC,WAAAA,EAAanC,QAAAA,CAASO,mBAAAA,CAAoBK,CAAAA;;;;;;;;;;;;;;;;;;;;EAoB1CwB,IAAAA,GAAOd,EAAAA;;;;;;;;EAQPe,IAAAA;IAAAA,CACKC,OAAAA,GAAUhC,WAAAA;;;;KAIVI,IAAAA;EAAAA;;;;;;;;EASL6B,QAAAA;IAAAA,CACKD,OAAAA,GAAUhC,WAAAA;;;;KAIVI,IAAAA;EAAAA;;;;;;;;EASL8B,EAAAA;IAAAA,CACKF,OAAAA,GAAUhC,WAAAA;;;;KAIVI,IAAAA;EAAAA;;;;;;;;EASL+B,IAAAA;IAAAA,CACKH,OAAAA,GAAUhC,WAAAA;;;;KAIVI,IAAAA;EAAAA;;;;EAKLgC,KAAAA;;;;EAIAC,IAAAA;AAAAA;AAAAA,UAEaC,qBAAAA,WAAgC/B,kBAAAA,GAAqBA,kBAAAA,UAA4BV,sBAAAA,CAAuBS,CAAAA,GAAId,YAAAA,CAAaS,mBAAAA,CAAoBK,CAAAA;;;;;;;EAO1JiC,eAAAA,GAAkBtC,mBAAAA,CAAoBK,CAAAA;AAAAA;AAAAA,UAEzBE,mBAAAA,WAA8BD,kBAAAA,GAAqBA,kBAAAA,UAA4B+B,qBAAAA,CAAsBhC,CAAAA,GAAIb,UAAAA,CAAWQ,mBAAAA,CAAoBK,CAAAA;AAAAA,UAExIG,cAAAA,WAAyBF,kBAAAA,GAAqBA,kBAAAA,UAA4BoB,uBAAAA,CAAwBrB,CAAAA,GAAIf,KAAAA,CAAMU,mBAAAA,CAAoBK,CAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DialogStoreState, i as DialogStoreProps, n as DialogStoreFunctions, o as createDialogStore, r as DialogStoreOptions, t as DialogStore } from "../dialog-store-BOLvw2IX.js";
|
|
2
|
+
export { DialogStore, DialogStoreFunctions, DialogStoreOptions, DialogStoreProps, DialogStoreState, createDialogStore };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createDisclosureStore } from "../disclosure/disclosure-store.js";
|
|
2
|
+
//#region src/dialog/dialog-store.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a dialog store.
|
|
5
|
+
*/
|
|
6
|
+
function createDialogStore(props = {}) {
|
|
7
|
+
return createDisclosureStore(props);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createDialogStore };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=dialog-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-store.js","names":[],"sources":["../../src/dialog/dialog-store.ts"],"sourcesContent":["import type { Store, StoreProps } from \"@ariakit/store\";\nimport type {\n DisclosureStoreFunctions,\n DisclosureStoreOptions,\n DisclosureStoreState,\n} from \"../disclosure/disclosure-store.ts\";\nimport { createDisclosureStore } from \"../disclosure/disclosure-store.ts\";\n\n/**\n * Creates a dialog store.\n */\nexport function createDialogStore(props: DialogStoreProps = {}): DialogStore {\n return createDisclosureStore(props);\n}\n\nexport interface DialogStoreState extends DisclosureStoreState {}\n\nexport interface DialogStoreFunctions extends DisclosureStoreFunctions {}\n\nexport interface DialogStoreOptions extends DisclosureStoreOptions {}\n\nexport interface DialogStoreProps\n extends DialogStoreOptions, StoreProps<DialogStoreState> {}\n\nexport interface DialogStore\n extends DialogStoreFunctions, Store<DialogStoreState> {}\n"],"mappings":";;;;;AAWA,SAAgB,kBAAkB,QAA0B,CAAC,GAAgB;CAC3E,OAAO,sBAAsB,KAAK;AACpC"}
|