@ariakit/core 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/cjs/__chunks/{QYB6XH64.cjs → 27ZAGOYG.cjs} +17 -13
- package/cjs/__chunks/6455U47T.cjs +37 -0
- package/cjs/__chunks/{ZPOXPO2L.cjs → 6SPJEESB.cjs} +33 -21
- package/cjs/__chunks/{2YFRPUZP.cjs → DBHIHK7C.cjs} +6 -6
- package/cjs/__chunks/{W5IHD6VG.cjs → EUJ6NNA6.cjs} +56 -43
- package/cjs/__chunks/{4DQ3OTE7.cjs → FXEBKN6G.cjs} +22 -17
- package/cjs/__chunks/{ZJEEK57E.cjs → HEFJPUYD.cjs} +2 -2
- package/cjs/__chunks/LBTLD2RB.cjs +58 -0
- package/cjs/__chunks/{QNEPGQLL.cjs → M6ZA7XUP.cjs} +6 -2
- package/cjs/__chunks/{HLVPXX7H.cjs → SDBF6KIY.cjs} +107 -107
- package/cjs/__chunks/{OFNGELMA.cjs → ZNW4LSWU.cjs} +8 -6
- package/cjs/checkbox/checkbox-store.cjs +14 -10
- package/cjs/checkbox/checkbox-store.d.ts +7 -0
- package/cjs/collection/collection-store.cjs +6 -5
- package/cjs/combobox/combobox-store.cjs +49 -48
- package/cjs/combobox/combobox-store.d.ts +24 -0
- package/cjs/composite/composite-overflow-store.cjs +7 -6
- package/cjs/composite/composite-store.cjs +7 -6
- package/cjs/composite/composite-store.d.ts +38 -34
- package/cjs/dialog/dialog-store.cjs +6 -5
- package/cjs/disclosure/disclosure-store.cjs +5 -4
- package/cjs/disclosure/disclosure-store.d.ts +36 -6
- package/cjs/form/form-store.cjs +38 -35
- package/cjs/hovercard/hovercard-store.cjs +8 -7
- package/cjs/index.cjs +3 -1
- package/cjs/menu/menu-bar-store.cjs +17 -13
- package/cjs/menu/menu-store.cjs +41 -43
- package/cjs/popover/popover-store.cjs +7 -6
- package/cjs/radio/radio-store.cjs +25 -24
- package/cjs/select/select-store.cjs +42 -42
- package/cjs/select/select-store.d.ts +16 -0
- package/cjs/tab/tab-store.cjs +29 -28
- package/cjs/tab/tab-store.d.ts +9 -0
- package/cjs/toolbar/toolbar-store.cjs +17 -13
- package/cjs/tooltip/tooltip-store.cjs +24 -25
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/cjs/utils/array.cjs +1 -0
- package/cjs/utils/dom.cjs +3 -2
- package/cjs/utils/events.cjs +14 -9
- package/cjs/utils/focus.cjs +24 -14
- package/cjs/utils/misc.cjs +3 -2
- package/cjs/utils/platform.cjs +4 -3
- package/cjs/utils/store.cjs +4 -3
- package/esm/__chunks/4BKCJXBM.js +37 -0
- package/esm/__chunks/AHZW5LR4.js +58 -0
- package/esm/__chunks/{NA5BK7DD.js → BOKMNDR7.js} +22 -10
- package/esm/__chunks/{6PEWNRTN.js → CUW3E24J.js} +100 -100
- package/esm/__chunks/{WFGVC6LE.js → EWHSN7GO.js} +17 -12
- package/esm/__chunks/{4T5RHRE5.js → MNNKHNLW.js} +1 -1
- package/esm/__chunks/{UVCATTRC.js → N6JW4ITM.js} +7 -5
- package/esm/__chunks/{RMD7SNCC.js → NWU4GBZ6.js} +5 -1
- package/esm/__chunks/{X7MJ3FB5.js → R6VHFWTV.js} +49 -36
- package/esm/__chunks/{DXA3K2FY.js → TFBCK4JB.js} +1 -1
- package/esm/__chunks/{IOAGNCXX.js → ZV2GEGPL.js} +14 -10
- package/esm/checkbox/checkbox-store.d.ts +7 -0
- package/esm/checkbox/checkbox-store.js +11 -7
- package/esm/collection/collection-store.js +5 -4
- package/esm/combobox/combobox-store.d.ts +24 -0
- package/esm/combobox/combobox-store.js +34 -33
- package/esm/composite/composite-overflow-store.js +6 -5
- package/esm/composite/composite-store.d.ts +38 -34
- package/esm/composite/composite-store.js +6 -5
- package/esm/dialog/dialog-store.js +5 -4
- package/esm/disclosure/disclosure-store.d.ts +36 -6
- package/esm/disclosure/disclosure-store.js +4 -3
- package/esm/form/form-store.js +24 -21
- package/esm/hovercard/hovercard-store.js +7 -6
- package/esm/index.js +2 -0
- package/esm/menu/menu-bar-store.js +15 -11
- package/esm/menu/menu-store.js +31 -33
- package/esm/popover/popover-store.js +6 -5
- package/esm/radio/radio-store.js +22 -21
- package/esm/select/select-store.d.ts +16 -0
- package/esm/select/select-store.js +29 -29
- package/esm/tab/tab-store.d.ts +9 -0
- package/esm/tab/tab-store.js +23 -22
- package/esm/toolbar/toolbar-store.js +15 -11
- package/esm/tooltip/tooltip-store.js +20 -21
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/esm/utils/array.js +1 -0
- package/esm/utils/dom.js +2 -1
- package/esm/utils/events.js +10 -5
- package/esm/utils/focus.js +14 -4
- package/esm/utils/misc.js +2 -1
- package/esm/utils/platform.js +3 -2
- package/esm/utils/store.js +3 -2
- package/package.json +1 -1
- package/cjs/__chunks/DQHU5K4Q.cjs +0 -57
- package/esm/__chunks/6HMPWUDT.js +0 -57
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCollectionStore
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./EWHSN7GO.js";
|
|
4
4
|
import {
|
|
5
5
|
createStore
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./BOKMNDR7.js";
|
|
7
7
|
import {
|
|
8
8
|
defaultValue
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./NWU4GBZ6.js";
|
|
10
10
|
import {
|
|
11
11
|
flatten2DArray,
|
|
12
12
|
reverseArray
|
|
13
13
|
} from "./5XEKIOCW.js";
|
|
14
|
+
import {
|
|
15
|
+
__spreadProps,
|
|
16
|
+
__spreadValues
|
|
17
|
+
} from "./4BKCJXBM.js";
|
|
14
18
|
|
|
15
19
|
// src/composite/composite-store.ts
|
|
16
20
|
var NULL_ITEM = { id: null };
|
|
@@ -51,7 +55,10 @@ function flipItems(items, activeId, shouldInsertNullItem = false) {
|
|
|
51
55
|
function groupItemsByRows(items) {
|
|
52
56
|
const rows = [];
|
|
53
57
|
for (const item of items) {
|
|
54
|
-
const row = rows.find((currentRow) =>
|
|
58
|
+
const row = rows.find((currentRow) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
|
|
61
|
+
});
|
|
55
62
|
if (row) {
|
|
56
63
|
row.push(item);
|
|
57
64
|
} else {
|
|
@@ -84,7 +91,7 @@ function normalizeRows(rows, activeId, focusShift) {
|
|
|
84
91
|
if (!item || focusShift && item.disabled) {
|
|
85
92
|
const isFirst = i === 0;
|
|
86
93
|
const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i - 1];
|
|
87
|
-
row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem
|
|
94
|
+
row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
}
|
|
@@ -98,77 +105,78 @@ function verticalizeItems(items) {
|
|
|
98
105
|
for (const row of rows) {
|
|
99
106
|
const item = row[i];
|
|
100
107
|
if (item) {
|
|
101
|
-
verticalized.push({
|
|
102
|
-
...item,
|
|
108
|
+
verticalized.push(__spreadProps(__spreadValues({}, item), {
|
|
103
109
|
// If there's no rowId, it means that it's not a grid composite, but
|
|
104
110
|
// a single row instead. So, instead of verticalizing it, that is,
|
|
105
111
|
// assigning a different rowId based on the column index, we keep it
|
|
106
112
|
// undefined so they will be part of the same row. This is useful
|
|
107
113
|
// when using up/down on one-dimensional composites.
|
|
108
114
|
rowId: item.rowId ? `${i}` : void 0
|
|
109
|
-
});
|
|
115
|
+
}));
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
return verticalized;
|
|
114
120
|
}
|
|
115
121
|
function createCompositeStore(props = {}) {
|
|
116
|
-
|
|
122
|
+
var _a;
|
|
123
|
+
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
117
124
|
const collection = createCollectionStore(props);
|
|
118
125
|
const activeId = defaultValue(
|
|
119
126
|
props.activeId,
|
|
120
|
-
syncState
|
|
127
|
+
syncState == null ? void 0 : syncState.activeId,
|
|
121
128
|
props.defaultActiveId
|
|
122
129
|
);
|
|
123
|
-
const initialState = {
|
|
124
|
-
...collection.getState(),
|
|
130
|
+
const initialState = __spreadProps(__spreadValues({}, collection.getState()), {
|
|
125
131
|
activeId,
|
|
126
|
-
baseElement: defaultValue(syncState
|
|
132
|
+
baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
|
|
127
133
|
includesBaseElement: defaultValue(
|
|
128
134
|
props.includesBaseElement,
|
|
129
|
-
syncState
|
|
135
|
+
syncState == null ? void 0 : syncState.includesBaseElement,
|
|
130
136
|
activeId === null
|
|
131
137
|
),
|
|
132
|
-
moves: defaultValue(syncState
|
|
138
|
+
moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
|
|
133
139
|
orientation: defaultValue(
|
|
134
140
|
props.orientation,
|
|
135
|
-
syncState
|
|
141
|
+
syncState == null ? void 0 : syncState.orientation,
|
|
136
142
|
"both"
|
|
137
143
|
),
|
|
138
|
-
rtl: defaultValue(props.rtl, syncState
|
|
144
|
+
rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
|
|
139
145
|
virtualFocus: defaultValue(
|
|
140
146
|
props.virtualFocus,
|
|
141
|
-
syncState
|
|
147
|
+
syncState == null ? void 0 : syncState.virtualFocus,
|
|
142
148
|
false
|
|
143
149
|
),
|
|
144
|
-
focusLoop: defaultValue(props.focusLoop, syncState
|
|
145
|
-
focusWrap: defaultValue(props.focusWrap, syncState
|
|
146
|
-
focusShift: defaultValue(props.focusShift, syncState
|
|
147
|
-
};
|
|
150
|
+
focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
|
|
151
|
+
focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
|
|
152
|
+
focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
|
|
153
|
+
});
|
|
148
154
|
const composite = createStore(initialState, collection, props.store);
|
|
149
155
|
composite.setup(
|
|
150
156
|
() => composite.sync(
|
|
151
157
|
(state) => {
|
|
152
158
|
composite.setState("activeId", (activeId2) => {
|
|
159
|
+
var _a2;
|
|
153
160
|
if (activeId2 !== void 0)
|
|
154
161
|
return activeId2;
|
|
155
|
-
return findFirstEnabledItem(state.renderedItems)
|
|
162
|
+
return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id;
|
|
156
163
|
});
|
|
157
164
|
},
|
|
158
165
|
["renderedItems", "activeId"]
|
|
159
166
|
)
|
|
160
167
|
);
|
|
161
168
|
const getNextId = (items, orientation, hasNullItem, skip) => {
|
|
169
|
+
var _a2, _b;
|
|
162
170
|
const { activeId: activeId2, rtl, focusLoop, focusWrap, includesBaseElement } = composite.getState();
|
|
163
171
|
const isHorizontal = orientation !== "vertical";
|
|
164
172
|
const isRTL = rtl && isHorizontal;
|
|
165
173
|
const allItems = isRTL ? reverseArray(items) : items;
|
|
166
174
|
if (activeId2 == null) {
|
|
167
|
-
return findFirstEnabledItem(allItems)
|
|
175
|
+
return (_a2 = findFirstEnabledItem(allItems)) == null ? void 0 : _a2.id;
|
|
168
176
|
}
|
|
169
177
|
const activeItem = allItems.find((item) => item.id === activeId2);
|
|
170
178
|
if (!activeItem) {
|
|
171
|
-
return findFirstEnabledItem(allItems)
|
|
179
|
+
return (_b = findFirstEnabledItem(allItems)) == null ? void 0 : _b.id;
|
|
172
180
|
}
|
|
173
181
|
const isGrid = !!activeItem.rowId;
|
|
174
182
|
const activeIndex = allItems.indexOf(activeItem);
|
|
@@ -178,7 +186,7 @@ function createCompositeStore(props = {}) {
|
|
|
178
186
|
const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
|
|
179
187
|
const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
|
|
180
188
|
nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
|
|
181
|
-
return nextItem2
|
|
189
|
+
return nextItem2 == null ? void 0 : nextItem2.id;
|
|
182
190
|
}
|
|
183
191
|
const oppositeOrientation = getOppositeOrientation(
|
|
184
192
|
// If it's a grid and orientation is not set, it's a next/previous call,
|
|
@@ -193,7 +201,7 @@ function createCompositeStore(props = {}) {
|
|
|
193
201
|
const loopItems = canWrap && !hasNullItem ? allItems : getItemsInRow(allItems, activeItem.rowId);
|
|
194
202
|
const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
|
|
195
203
|
const nextItem2 = findFirstEnabledItem(sortedItems, activeId2);
|
|
196
|
-
return nextItem2
|
|
204
|
+
return nextItem2 == null ? void 0 : nextItem2.id;
|
|
197
205
|
}
|
|
198
206
|
if (canWrap) {
|
|
199
207
|
const nextItem2 = findFirstEnabledItem(
|
|
@@ -206,18 +214,16 @@ function createCompositeStore(props = {}) {
|
|
|
206
214
|
hasNullItem ? nextItemsInRow : nextItems,
|
|
207
215
|
activeId2
|
|
208
216
|
);
|
|
209
|
-
const nextId = hasNullItem ? nextItem2
|
|
217
|
+
const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
|
|
210
218
|
return nextId;
|
|
211
219
|
}
|
|
212
220
|
const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
|
|
213
221
|
if (!nextItem && hasNullItem) {
|
|
214
222
|
return null;
|
|
215
223
|
}
|
|
216
|
-
return nextItem
|
|
224
|
+
return nextItem == null ? void 0 : nextItem.id;
|
|
217
225
|
};
|
|
218
|
-
return {
|
|
219
|
-
...collection,
|
|
220
|
-
...composite,
|
|
226
|
+
return __spreadProps(__spreadValues(__spreadValues({}, collection), composite), {
|
|
221
227
|
setBaseElement: (element) => composite.setState("baseElement", element),
|
|
222
228
|
setActiveId: (id) => composite.setState("activeId", id),
|
|
223
229
|
move: (id) => {
|
|
@@ -226,15 +232,22 @@ function createCompositeStore(props = {}) {
|
|
|
226
232
|
composite.setState("activeId", id);
|
|
227
233
|
composite.setState("moves", (moves) => moves + 1);
|
|
228
234
|
},
|
|
229
|
-
first: () =>
|
|
230
|
-
|
|
235
|
+
first: () => {
|
|
236
|
+
var _a2;
|
|
237
|
+
return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
|
|
238
|
+
},
|
|
239
|
+
last: () => {
|
|
240
|
+
var _a2;
|
|
241
|
+
return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
|
|
242
|
+
},
|
|
231
243
|
next: (skip) => {
|
|
232
244
|
const { renderedItems, orientation } = composite.getState();
|
|
233
245
|
return getNextId(renderedItems, orientation, false, skip);
|
|
234
246
|
},
|
|
235
247
|
previous: (skip) => {
|
|
248
|
+
var _a2;
|
|
236
249
|
const { renderedItems, orientation, includesBaseElement } = composite.getState();
|
|
237
|
-
const isGrid = !!findFirstEnabledItem(renderedItems)
|
|
250
|
+
const isGrid = !!((_a2 = findFirstEnabledItem(renderedItems)) == null ? void 0 : _a2.rowId);
|
|
238
251
|
const hasNullItem = !isGrid && includesBaseElement;
|
|
239
252
|
return getNextId(
|
|
240
253
|
reverseArray(renderedItems),
|
|
@@ -278,7 +291,7 @@ function createCompositeStore(props = {}) {
|
|
|
278
291
|
const hasNullItem = includesBaseElement;
|
|
279
292
|
return getNextId(verticalItems, "vertical", hasNullItem, skip);
|
|
280
293
|
}
|
|
281
|
-
};
|
|
294
|
+
});
|
|
282
295
|
}
|
|
283
296
|
|
|
284
297
|
export {
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createStore
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./BOKMNDR7.js";
|
|
4
4
|
import {
|
|
5
5
|
defaultValue
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./NWU4GBZ6.js";
|
|
7
|
+
import {
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "./4BKCJXBM.js";
|
|
7
11
|
|
|
8
12
|
// src/disclosure/disclosure-store.ts
|
|
9
13
|
function createDisclosureStore(props = {}) {
|
|
10
|
-
|
|
14
|
+
var _a;
|
|
15
|
+
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
11
16
|
const open = defaultValue(
|
|
12
17
|
props.open,
|
|
13
|
-
syncState
|
|
18
|
+
syncState == null ? void 0 : syncState.open,
|
|
14
19
|
props.defaultOpen,
|
|
15
20
|
false
|
|
16
21
|
);
|
|
17
|
-
const animated = defaultValue(props.animated, syncState
|
|
22
|
+
const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
|
|
18
23
|
const initialState = {
|
|
19
24
|
open,
|
|
20
25
|
animated,
|
|
21
26
|
animating: !!animated && open,
|
|
22
27
|
mounted: open,
|
|
23
|
-
contentElement: defaultValue(syncState
|
|
24
|
-
disclosureElement: defaultValue(syncState
|
|
28
|
+
contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
|
|
29
|
+
disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
|
|
25
30
|
};
|
|
26
31
|
const disclosure = createStore(initialState, props.store);
|
|
27
32
|
disclosure.setup(
|
|
@@ -54,8 +59,7 @@ function createDisclosureStore(props = {}) {
|
|
|
54
59
|
["open", "animating"]
|
|
55
60
|
)
|
|
56
61
|
);
|
|
57
|
-
return {
|
|
58
|
-
...disclosure,
|
|
62
|
+
return __spreadProps(__spreadValues({}, disclosure), {
|
|
59
63
|
setOpen: (value) => disclosure.setState("open", value),
|
|
60
64
|
show: () => disclosure.setState("open", true),
|
|
61
65
|
hide: () => disclosure.setState("open", false),
|
|
@@ -63,7 +67,7 @@ function createDisclosureStore(props = {}) {
|
|
|
63
67
|
stopAnimation: () => disclosure.setState("animating", false),
|
|
64
68
|
setContentElement: (value) => disclosure.setState("contentElement", value),
|
|
65
69
|
setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
|
|
66
|
-
};
|
|
70
|
+
});
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
export {
|
|
@@ -10,6 +10,9 @@ export type CheckboxStoreValue = Value;
|
|
|
10
10
|
export interface CheckboxStoreState<T extends Value = Value> {
|
|
11
11
|
/**
|
|
12
12
|
* The checked state of the checkbox.
|
|
13
|
+
*
|
|
14
|
+
* Live examples:
|
|
15
|
+
* - [Custom Checkbox](https://ariakit.org/examples/checkbox-custom)
|
|
13
16
|
*/
|
|
14
17
|
value: ToPrimitive<T>;
|
|
15
18
|
}
|
|
@@ -25,6 +28,10 @@ export interface CheckboxStoreFunctions<T extends Value = Value> {
|
|
|
25
28
|
export interface CheckboxStoreOptions<T extends Value = Value> extends StoreOptions<CheckboxStoreState<T>, "value"> {
|
|
26
29
|
/**
|
|
27
30
|
* The default value of the checkbox.
|
|
31
|
+
*
|
|
32
|
+
* Live examples:
|
|
33
|
+
* - [Custom Checkbox](https://ariakit.org/examples/checkbox-custom)
|
|
34
|
+
* - [Checkbox group](https://ariakit.org/examples/checkbox-group)
|
|
28
35
|
* @default false
|
|
29
36
|
*/
|
|
30
37
|
defaultValue?: CheckboxStoreState<T>["value"];
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createStore
|
|
3
|
-
} from "../__chunks/
|
|
3
|
+
} from "../__chunks/BOKMNDR7.js";
|
|
4
4
|
import {
|
|
5
5
|
defaultValue
|
|
6
|
-
} from "../__chunks/
|
|
6
|
+
} from "../__chunks/NWU4GBZ6.js";
|
|
7
|
+
import {
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "../__chunks/4BKCJXBM.js";
|
|
7
11
|
|
|
8
12
|
// src/checkbox/checkbox-store.ts
|
|
9
13
|
function createCheckboxStore(props = {}) {
|
|
10
|
-
|
|
14
|
+
var _a;
|
|
15
|
+
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
11
16
|
const initialState = {
|
|
12
17
|
value: defaultValue(
|
|
13
18
|
props.value,
|
|
14
|
-
syncState
|
|
19
|
+
syncState == null ? void 0 : syncState.value,
|
|
15
20
|
props.defaultValue,
|
|
16
21
|
false
|
|
17
22
|
)
|
|
18
23
|
};
|
|
19
24
|
const checkbox = createStore(initialState, props.store);
|
|
20
|
-
return {
|
|
21
|
-
...checkbox,
|
|
25
|
+
return __spreadProps(__spreadValues({}, checkbox), {
|
|
22
26
|
setValue: (value) => checkbox.setState("value", value)
|
|
23
|
-
};
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
29
|
export {
|
|
26
30
|
createCheckboxStore
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCollectionStore
|
|
3
|
-
} from "../__chunks/
|
|
4
|
-
import "../__chunks/
|
|
5
|
-
import "../__chunks/
|
|
6
|
-
import "../__chunks/
|
|
3
|
+
} from "../__chunks/EWHSN7GO.js";
|
|
4
|
+
import "../__chunks/BOKMNDR7.js";
|
|
5
|
+
import "../__chunks/NWU4GBZ6.js";
|
|
6
|
+
import "../__chunks/N6JW4ITM.js";
|
|
7
|
+
import "../__chunks/4BKCJXBM.js";
|
|
7
8
|
export {
|
|
8
9
|
createCollectionStore
|
|
9
10
|
};
|
|
@@ -19,6 +19,15 @@ export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverSt
|
|
|
19
19
|
includesBaseElement: boolean;
|
|
20
20
|
/**
|
|
21
21
|
* The input value.
|
|
22
|
+
*
|
|
23
|
+
* Live examples:
|
|
24
|
+
* - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
|
|
25
|
+
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
26
|
+
* - [Filterable Combobox](https://ariakit.org/examples/combobox-matches)
|
|
27
|
+
* - [Multi-selectable
|
|
28
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
29
|
+
* - [Textarea with inline
|
|
30
|
+
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
22
31
|
*/
|
|
23
32
|
value: string;
|
|
24
33
|
/**
|
|
@@ -27,12 +36,23 @@ export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverSt
|
|
|
27
36
|
activeValue: string | undefined;
|
|
28
37
|
/**
|
|
29
38
|
* Whether to reset the value when the combobox popover is hidden.
|
|
39
|
+
*
|
|
40
|
+
* Live examples:
|
|
41
|
+
* - [Multi-selectable
|
|
42
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
43
|
+
* @default false
|
|
30
44
|
*/
|
|
31
45
|
resetValueOnHide: boolean;
|
|
32
46
|
}
|
|
33
47
|
export interface ComboboxStoreFunctions extends CompositeStoreFunctions<Item>, PopoverStoreFunctions {
|
|
34
48
|
/**
|
|
35
49
|
* Sets the `value` state.
|
|
50
|
+
*
|
|
51
|
+
* Live examples:
|
|
52
|
+
* - [Multi-selectable
|
|
53
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
54
|
+
* - [Textarea with inline
|
|
55
|
+
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
36
56
|
* @example
|
|
37
57
|
* store.setValue("Hello world");
|
|
38
58
|
* store.setValue((value) => value + "!");
|
|
@@ -58,6 +78,10 @@ export interface ComboboxStoreOptions extends StoreOptions<ComboboxStoreState, "
|
|
|
58
78
|
select?: SelectStore;
|
|
59
79
|
/**
|
|
60
80
|
* The combobox initial value.
|
|
81
|
+
*
|
|
82
|
+
* Live examples:
|
|
83
|
+
* - [Multi-selectable
|
|
84
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
61
85
|
* @default ""
|
|
62
86
|
*/
|
|
63
87
|
defaultValue?: ComboboxStoreState["value"];
|
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPopoverStore
|
|
3
|
-
} from "../__chunks/
|
|
4
|
-
import "../__chunks/
|
|
5
|
-
import "../__chunks/
|
|
3
|
+
} from "../__chunks/CUW3E24J.js";
|
|
4
|
+
import "../__chunks/MNNKHNLW.js";
|
|
5
|
+
import "../__chunks/ZV2GEGPL.js";
|
|
6
6
|
import {
|
|
7
7
|
createCompositeStore
|
|
8
|
-
} from "../__chunks/
|
|
9
|
-
import "../__chunks/
|
|
8
|
+
} from "../__chunks/R6VHFWTV.js";
|
|
9
|
+
import "../__chunks/EWHSN7GO.js";
|
|
10
10
|
import {
|
|
11
11
|
createStore,
|
|
12
12
|
mergeStore
|
|
13
|
-
} from "../__chunks/
|
|
13
|
+
} from "../__chunks/BOKMNDR7.js";
|
|
14
14
|
import {
|
|
15
15
|
defaultValue
|
|
16
|
-
} from "../__chunks/
|
|
16
|
+
} from "../__chunks/NWU4GBZ6.js";
|
|
17
17
|
import {
|
|
18
18
|
isSafari,
|
|
19
19
|
isTouchDevice
|
|
20
|
-
} from "../__chunks/
|
|
21
|
-
import "../__chunks/
|
|
20
|
+
} from "../__chunks/TFBCK4JB.js";
|
|
21
|
+
import "../__chunks/N6JW4ITM.js";
|
|
22
22
|
import "../__chunks/5XEKIOCW.js";
|
|
23
|
+
import {
|
|
24
|
+
__objRest,
|
|
25
|
+
__spreadProps,
|
|
26
|
+
__spreadValues
|
|
27
|
+
} from "../__chunks/4BKCJXBM.js";
|
|
23
28
|
|
|
24
29
|
// src/combobox/combobox-store.ts
|
|
25
30
|
var isSafariOnMobile = isSafari() && isTouchDevice();
|
|
26
|
-
function createComboboxStore({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} =
|
|
31
|
+
function createComboboxStore(_a = {}) {
|
|
32
|
+
var _b = _a, {
|
|
33
|
+
menu,
|
|
34
|
+
select
|
|
35
|
+
} = _b, props = __objRest(_b, [
|
|
36
|
+
"menu",
|
|
37
|
+
"select"
|
|
38
|
+
]);
|
|
31
39
|
const store = mergeStore(
|
|
32
40
|
props.store,
|
|
33
|
-
menu
|
|
41
|
+
menu == null ? void 0 : menu.omit(
|
|
34
42
|
"baseElement",
|
|
35
43
|
"arrowElement",
|
|
36
44
|
"anchorElement",
|
|
@@ -38,7 +46,7 @@ function createComboboxStore({
|
|
|
38
46
|
"popoverElement",
|
|
39
47
|
"disclosureElement"
|
|
40
48
|
),
|
|
41
|
-
select
|
|
49
|
+
select == null ? void 0 : select.omit(
|
|
42
50
|
"value",
|
|
43
51
|
"items",
|
|
44
52
|
"renderedItems",
|
|
@@ -57,8 +65,7 @@ function createComboboxStore({
|
|
|
57
65
|
props.defaultActiveId,
|
|
58
66
|
null
|
|
59
67
|
);
|
|
60
|
-
const composite = createCompositeStore({
|
|
61
|
-
...props,
|
|
68
|
+
const composite = createCompositeStore(__spreadProps(__spreadValues({}, props), {
|
|
62
69
|
store,
|
|
63
70
|
activeId,
|
|
64
71
|
includesBaseElement: defaultValue(
|
|
@@ -75,28 +82,25 @@ function createComboboxStore({
|
|
|
75
82
|
focusWrap: defaultValue(props.focusWrap, syncState.focusWrap, true),
|
|
76
83
|
virtualFocus: defaultValue(
|
|
77
84
|
props.virtualFocus,
|
|
78
|
-
syncState
|
|
85
|
+
syncState == null ? void 0 : syncState.virtualFocus,
|
|
79
86
|
!isSafariOnMobile
|
|
80
87
|
)
|
|
81
|
-
});
|
|
82
|
-
const popover = createPopoverStore({
|
|
83
|
-
...props,
|
|
88
|
+
}));
|
|
89
|
+
const popover = createPopoverStore(__spreadProps(__spreadValues({}, props), {
|
|
84
90
|
store,
|
|
85
91
|
placement: defaultValue(
|
|
86
92
|
props.placement,
|
|
87
93
|
syncState.placement,
|
|
88
94
|
"bottom-start"
|
|
89
95
|
)
|
|
90
|
-
});
|
|
96
|
+
}));
|
|
91
97
|
const initialValue = defaultValue(
|
|
92
98
|
props.value,
|
|
93
99
|
syncState.value,
|
|
94
100
|
props.defaultValue,
|
|
95
101
|
""
|
|
96
102
|
);
|
|
97
|
-
const initialState = {
|
|
98
|
-
...composite.getState(),
|
|
99
|
-
...popover.getState(),
|
|
103
|
+
const initialState = __spreadProps(__spreadValues(__spreadValues({}, composite.getState()), popover.getState()), {
|
|
100
104
|
value: initialValue,
|
|
101
105
|
resetValueOnHide: defaultValue(
|
|
102
106
|
props.resetValueOnHide,
|
|
@@ -104,7 +108,7 @@ function createComboboxStore({
|
|
|
104
108
|
false
|
|
105
109
|
),
|
|
106
110
|
activeValue: syncState.activeValue
|
|
107
|
-
};
|
|
111
|
+
});
|
|
108
112
|
const combobox = createStore(initialState, composite, popover, store);
|
|
109
113
|
combobox.setup(
|
|
110
114
|
() => combobox.sync(
|
|
@@ -146,17 +150,14 @@ function createComboboxStore({
|
|
|
146
150
|
return;
|
|
147
151
|
const { activeId: activeId2 } = combobox.getState();
|
|
148
152
|
const activeItem = composite.item(activeId2);
|
|
149
|
-
combobox.setState("activeValue", activeItem
|
|
153
|
+
combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
|
|
150
154
|
},
|
|
151
155
|
["moves", "renderedItems"]
|
|
152
156
|
)
|
|
153
157
|
);
|
|
154
|
-
return {
|
|
155
|
-
...popover,
|
|
156
|
-
...composite,
|
|
157
|
-
...combobox,
|
|
158
|
+
return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, popover), composite), combobox), {
|
|
158
159
|
setValue: (value) => combobox.setState("value", value)
|
|
159
|
-
};
|
|
160
|
+
});
|
|
160
161
|
}
|
|
161
162
|
export {
|
|
162
163
|
createComboboxStore
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPopoverStore
|
|
3
|
-
} from "../__chunks/
|
|
4
|
-
import "../__chunks/
|
|
5
|
-
import "../__chunks/
|
|
6
|
-
import "../__chunks/
|
|
7
|
-
import "../__chunks/
|
|
3
|
+
} from "../__chunks/CUW3E24J.js";
|
|
4
|
+
import "../__chunks/MNNKHNLW.js";
|
|
5
|
+
import "../__chunks/ZV2GEGPL.js";
|
|
6
|
+
import "../__chunks/BOKMNDR7.js";
|
|
7
|
+
import "../__chunks/NWU4GBZ6.js";
|
|
8
|
+
import "../__chunks/4BKCJXBM.js";
|
|
8
9
|
|
|
9
10
|
// src/composite/composite-overflow-store.ts
|
|
10
11
|
function createCompositeOverflowStore(props = {}) {
|