@qredence/fleet 0.6.0 → 0.6.1
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 +7 -0
- package/dist/web/client/assets/action-swap-roll-COzQ86wm.js +1 -0
- package/dist/web/client/assets/agent-activity-svETLf_5.js +1 -0
- package/dist/web/client/assets/agent-disclosure-DAMuuGcM.js +1 -0
- package/dist/web/client/assets/analytics-stub-B6zGMuSV.js +1 -0
- package/dist/web/client/assets/{artifacts-panel-CJ75gQub.js → artifacts-panel-HVjqBMyx.js} +1 -1
- package/dist/web/client/assets/button-C5wFDY5_.js +1 -0
- package/dist/web/client/assets/card-DA3Vnqay.js +1 -0
- package/dist/web/client/assets/chat-BhYseKd6.js +52 -0
- package/dist/web/client/assets/{chat-command-palette-CkISHfKE.js → chat-command-palette-LILDO_vG.js} +1 -1
- package/dist/web/client/assets/{citations-C_tPOJE_.js → citations-BPv8HIpf.js} +2 -2
- package/dist/web/client/assets/command-PhicLCoO.js +1 -0
- package/dist/web/client/assets/dialog-pBGUjAQ7.js +1 -0
- package/dist/web/client/assets/{fleet-message-queue-BCno4XP-.js → fleet-message-queue-fbYYwMj0.js} +1 -1
- package/dist/web/client/assets/{fleet-pi-tool-renderer-BEDIO3al.js → fleet-pi-tool-renderer-BRgNnmaJ.js} +28 -28
- package/dist/web/client/assets/fleet-reasoning-panel-CjA2dwUJ.js +1 -0
- package/dist/web/client/assets/{fork-picker-dialog-ByBOGVsa.js → fork-picker-dialog-B7NNpVmW.js} +1 -1
- package/dist/web/client/assets/globals-CuIiqOTg.css +2 -0
- package/dist/web/client/assets/horizontal-resize-Cp3iHMH7.js +1 -0
- package/dist/web/client/assets/index-CSGplyr_.js +12 -0
- package/dist/web/client/assets/{input-0wwjWjKq.js → input-PcdubeKn.js} +1 -1
- package/dist/web/client/assets/input-group-C2HJEZvl.js +1 -0
- package/dist/web/client/assets/ipython-tool-CyuMOxz1.js +3 -0
- package/dist/web/client/assets/{markdown-code-CuQcR3UO.js → markdown-code-xNyjdZ4g.js} +1 -1
- package/dist/web/client/assets/{markdown-DInPmRUG.js → markdown-lvexwooo.js} +2 -2
- package/dist/web/client/assets/{model-selector-list-Ch05B2nZ.js → model-selector-list-CoXX358G.js} +1 -1
- package/dist/web/client/assets/{notify-DgMKgZZW.js → notify-DxL0VD7Z.js} +1 -1
- package/dist/web/client/assets/openui-renderer-TLNe5e_Q.js +378 -0
- package/dist/web/client/assets/prompt-input-fwP8TsgQ.js +1 -0
- package/dist/web/client/assets/{prompt-suggestions-Cc--lSNR.js → prompt-suggestions-BlGXmWS7.js} +1 -1
- package/dist/web/client/assets/provider-catalog-DYMFdbKc.js +1 -0
- package/dist/web/client/assets/provider-label-B4q5mI65.js +1 -0
- package/dist/web/client/assets/{repl-panel-DsPX04Xr.js → repl-panel-C5om8MGU.js} +1 -1
- package/dist/web/client/assets/{right-panel-registry-Dp8yX-oL.js → right-panel-registry-BBlxLxnx.js} +2 -2
- package/dist/web/client/assets/routes-XGsAIqBJ.js +16 -0
- package/dist/web/client/assets/settings-dialog-BSBasR3o.js +2 -0
- package/dist/web/client/assets/{subagent-chat-panel-Yujplxpb.js → subagent-chat-panel-oeLDPDAK.js} +1 -1
- package/dist/web/client/assets/{subagent-transcript-CnI-mqN0.js → subagent-transcript-DaVHjNUH.js} +1 -1
- package/dist/web/client/assets/{subagents-panel-CjXEdimj.js → subagents-panel-D_aVgSCi.js} +1 -1
- package/dist/web/client/assets/surfaces-BhAXz9So.js +1 -0
- package/dist/web/client/assets/{switch-9rTeg6J6.js → switch-WhXeJNNY.js} +1 -1
- package/dist/web/client/assets/{toast-Bt9p2OL4.js → toast-D3c9XeGe.js} +1 -1
- package/dist/web/client/assets/{tool-result-DfnPN0FQ.js → tool-result-Cki8WUNc.js} +3 -3
- package/dist/web/client/assets/virtualized-turn-list-CdMa-ydT.js +6 -0
- package/dist/web/client/assets/workspace-panel-77bDbprs.js +1 -0
- package/dist/web/client/bundle-budget.json +5 -5
- package/dist/web/launcher.mjs +10 -1
- package/dist/web/server/{_tanstack-start-manifest_v-DS_CSIFQ-WB3VTKF3.js → _tanstack-start-manifest_v-0L7fqnH4-KMVGUFE4.js} +24 -24
- package/dist/web/server/{agent-activity-CS2rbF_C-A3R26CYH.js → agent-activity-BuEE6iVw-CDZLK4D2.js} +4 -4
- package/dist/web/server/{artifacts-panel-CaKrX2XC-R37I4BHF.js → artifacts-panel-D3ySO--V-XSL53CXL.js} +18 -18
- package/dist/web/server/{chat-command-palette-7gbqEnm9-6XICQZN7.js → chat-command-palette-kAbXhWVg-TJWXH2WW.js} +9 -9
- package/dist/web/server/{chunk-CNXJN5HN.js → chunk-2DDWXTVG.js} +5 -5
- package/dist/web/server/{chunk-TWYHHG5N.js → chunk-2JHTYWD5.js} +15 -15
- package/dist/web/server/{chunk-EAE2QXRK.js → chunk-3TIMGWWI.js} +1 -2
- package/dist/web/server/{chunk-AGFRJQZ7.js → chunk-4WBFCB4O.js} +257 -257
- package/dist/web/server/{chunk-P6UMR32I.js → chunk-5UCAJBAH.js} +4 -4
- package/dist/web/server/{chunk-DZ2IC3FH.js → chunk-D27LRYVT.js} +42 -42
- package/dist/web/server/{chunk-YXXRP3NS.js → chunk-DLUZFOG3.js} +5 -5
- package/dist/web/server/{chunk-K3BXQG3N.js → chunk-EBG3XFGQ.js} +60 -60
- package/dist/web/server/{chunk-2ATMSG7U.js → chunk-EJEPDVK6.js} +3 -3
- package/dist/web/server/{chunk-IJPCV6DH.js → chunk-FYDQK6UX.js} +1 -1
- package/dist/web/server/{chunk-WHBVQJ4K.js → chunk-HF7DG7PC.js} +73 -73
- package/dist/web/server/{chunk-WYL2DW5R.js → chunk-JTCCQZLN.js} +2 -2
- package/dist/web/server/{chunk-UAPNEWCA.js → chunk-KP2PNDGL.js} +6 -6
- package/dist/web/server/{chunk-7SR6WDM2.js → chunk-MNBGB2SP.js} +2 -2
- package/dist/web/server/{chunk-HSJMLO36.js → chunk-MNPHMZU7.js} +3 -3
- package/dist/web/server/{chunk-JQDLJ7KI.js → chunk-NGCQJ33Y.js} +1134 -1134
- package/dist/web/server/{chunk-7SD2ZSEA.js → chunk-NIDBN7BQ.js} +1 -1
- package/dist/web/server/{chunk-ZJFA4F5X.js → chunk-NIZBFVJF.js} +2 -2
- package/dist/web/server/{chunk-PIOFZUOU.js → chunk-NJ4QEZHK.js} +3 -4
- package/dist/web/server/{chunk-WM4PUT6M.js → chunk-NNKJTKOQ.js} +234 -234
- package/dist/web/server/{chunk-N6NOTURM.js → chunk-NWDI3OWB.js} +4 -4
- package/dist/web/server/{chunk-KELEYPVK.js → chunk-O3HDELZ2.js} +74826 -74825
- package/dist/web/server/{chunk-YNUWKMNQ.js → chunk-PLYZ7P2Y.js} +1 -152
- package/dist/web/server/{chunk-LXJD6IGW.js → chunk-QFRCJWQQ.js} +7 -7
- package/dist/web/server/{chunk-NXJ32VFR.js → chunk-QIULBRTU.js} +13 -13
- package/dist/web/server/{chunk-DI7XRK2H.js → chunk-RIP3PBWT.js} +3 -3
- package/dist/web/server/{chunk-YKVGQBZA.js → chunk-S5LFXXDY.js} +625 -622
- package/dist/web/server/{chunk-XLNCWZMZ.js → chunk-UCUFC553.js} +3 -1
- package/dist/web/server/{chunk-KOUEJ3NU.js → chunk-UL2725KQ.js} +3 -3
- package/dist/web/server/{chunk-HFQTI7AX.js → chunk-VPKX7QRU.js} +3 -3
- package/dist/web/server/{chunk-LZ4Q5KUJ.js → chunk-WNCAL4HN.js} +133 -133
- package/dist/web/server/{chunk-C5X6G26O.js → chunk-XIB6XNUX.js} +436 -436
- package/dist/web/server/{chunk-EH4BZ6QM.js → chunk-YGYOBX7G.js} +2 -2
- package/dist/web/server/{chunk-BBBS5AS7.js → chunk-ZIFSJ3HQ.js} +626 -626
- package/dist/web/server/{fleet-message-queue-BS-cZ56r-GLZXUKDF.js → fleet-message-queue-D_w8lSeY-T3HB7HVQ.js} +5 -5
- package/dist/web/server/{fleet-pi-tool-renderer-umKunT3K-O4GBH35V.js → fleet-pi-tool-renderer-qwc-qZFq-4U556N5Q.js} +12 -12
- package/dist/web/server/{fleet-reasoning-panel-BxC2COxi-GPLMQSTT.js → fleet-reasoning-panel-DG_vuvv0-NCZWEEIT.js} +26 -26
- package/dist/web/server/{fleet-subagent-list-CpSYzCIq-JDH2LHSS.js → fleet-subagent-list-BGb0PjhF-2X67FMUV.js} +1 -1
- package/dist/web/server/{fleet-tool-timeline-IB36_PB2-XJENTO6I.js → fleet-tool-timeline-D6yM4ZMz-ZSFVRRRI.js} +1 -1
- package/dist/web/server/{fork-picker-dialog-DlINz9UQ-UWIXFDJX.js → fork-picker-dialog-Ds6Tgtu3-DIBWN7MV.js} +5 -5
- package/dist/web/server/{model-selector-list-jBTZc2Mu-OXJOS5NA.js → model-selector-list-DxeGZoD2-P6S6FSJH.js} +9 -9
- package/dist/web/server/{openui-renderer-Biyyjhjn-SJOEKPTJ.js → openui-renderer-MKFv6LlH-MDRSVFEY.js} +11 -11
- package/dist/web/server/{prompt-suggestions-D4AEEY7K-RZSP7PWV.js → prompt-suggestions-BOItmGnD-YQA7RHLG.js} +2 -2
- package/dist/web/server/{repl-panel-D5KsoJik-BQKO53JO.js → repl-panel-CuyF8wt5-CHDT2Q3N.js} +2 -2
- package/dist/web/server/{router-DWALoX_M-I5CBL7FQ.js → router-Dg72SESP-PCWKLFRG.js} +16 -16
- package/dist/web/server/{routes-BBVirYfL-5WXMOT7M.js → routes-BGrVtPYF-SURPAJN6.js} +6432 -6413
- package/dist/web/server/server.js +2 -2
- package/dist/web/server/{settings-dialog-DndPbM-v-RFNXXEAN.js → settings-dialog-CK0FJlTg-HZRBAXDZ.js} +1392 -1402
- package/dist/web/server/{subagent-chat-panel-C0RpnXav-J7VYO7QY.js → subagent-chat-panel-gzamnTgK-PQ2TLLJF.js} +21 -21
- package/dist/web/server/{subagents-panel-jDqIn9Nh-YEV6QLUY.js → subagents-panel-Berjd7HJ-EI5ZKC6V.js} +20 -20
- package/dist/web/server/{workspace-panel-CX_Vo6As-EWO6AMPI.js → workspace-panel-CBBa_3UO-B4PPFPMA.js} +45 -20
- package/package.json +1 -1
- package/dist/web/client/assets/action-swap-roll-BB8DFMuf.js +0 -1
- package/dist/web/client/assets/agent-activity-CwMDU7aP.js +0 -1
- package/dist/web/client/assets/agent-disclosure-B8SnhQXL.js +0 -1
- package/dist/web/client/assets/analytics-stub-Cas1He0w.js +0 -1
- package/dist/web/client/assets/button-BR2WWrFo.js +0 -1
- package/dist/web/client/assets/card-BKl76a3R.js +0 -1
- package/dist/web/client/assets/chat-Ci2cEQrR.js +0 -52
- package/dist/web/client/assets/command-_WjnervL.js +0 -1
- package/dist/web/client/assets/dialog-BEZuZhzk.js +0 -1
- package/dist/web/client/assets/fleet-reasoning-panel-CbkO7u-v.js +0 -1
- package/dist/web/client/assets/globals-B_I1Eq1u.css +0 -2
- package/dist/web/client/assets/horizontal-resize-CwoDojST.js +0 -1
- package/dist/web/client/assets/index-DJ1fFbQu.js +0 -12
- package/dist/web/client/assets/input-group-Tb5TYbzi.js +0 -1
- package/dist/web/client/assets/ipython-tool-ldJ9F1Cw.js +0 -3
- package/dist/web/client/assets/openui-renderer-Bf60nxNi.js +0 -378
- package/dist/web/client/assets/prompt-input-qPIXZ-Rb.js +0 -1
- package/dist/web/client/assets/provider-catalog-D8G66gwc.js +0 -1
- package/dist/web/client/assets/provider-label-DDLRnZyC.js +0 -1
- package/dist/web/client/assets/routes-DpgMJZ5n.js +0 -16
- package/dist/web/client/assets/settings-dialog-YJkvt5EB.js +0 -2
- package/dist/web/client/assets/surfaces-DI-U-_2a.js +0 -1
- package/dist/web/client/assets/virtualized-turn-list--Vynre4D.js +0 -6
- package/dist/web/client/assets/workspace-panel-CPPIznT9.js +0 -1
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
// web/app/dist/server/assets/createBaseUIEventDetails-
|
|
1
|
+
// web/app/dist/server/assets/createBaseUIEventDetails-hMAk6i9b.js
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
import { createElement as createElement2 } from "react";
|
|
4
4
|
import * as ReactDOM from "react-dom";
|
|
5
|
+
function NOOP() {
|
|
6
|
+
}
|
|
7
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
8
|
+
var EMPTY_OBJECT = Object.freeze({});
|
|
9
|
+
function useOnMount(fn) {
|
|
10
|
+
React$1.useEffect(fn, EMPTY_ARRAY);
|
|
11
|
+
}
|
|
12
|
+
var UNINITIALIZED = {};
|
|
13
|
+
function useRefWithInit(init, initArg) {
|
|
14
|
+
const ref = React$1.useRef(UNINITIALIZED);
|
|
15
|
+
if (ref.current === UNINITIALIZED) ref.current = init(initArg);
|
|
16
|
+
return ref;
|
|
17
|
+
}
|
|
18
|
+
var noop = () => {
|
|
19
|
+
};
|
|
20
|
+
var useIsoLayoutEffect = typeof document !== "undefined" ? React$1.useLayoutEffect : noop;
|
|
21
|
+
function createFormatErrorMessage(baseUrl, prefix) {
|
|
22
|
+
return function formatErrorMessage2(code, ...args) {
|
|
23
|
+
const url = new URL(baseUrl);
|
|
24
|
+
url.searchParams.set("code", code.toString());
|
|
25
|
+
args.forEach((arg) => url.searchParams.append("args[]", arg));
|
|
26
|
+
return `${prefix} error #${code}; visit ${url} for the full message.`;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
|
|
30
|
+
var majorVersion = parseInt(React$1.version, 10);
|
|
31
|
+
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
32
|
+
return majorVersion >= reactVersionToCheck;
|
|
33
|
+
}
|
|
34
|
+
var SafeReact = { ...React$1 };
|
|
35
|
+
var useInsertionEffect$1 = SafeReact.useInsertionEffect;
|
|
36
|
+
var useSafeInsertionEffect = useInsertionEffect$1 && useInsertionEffect$1 !== SafeReact.useLayoutEffect ? useInsertionEffect$1 : (fn) => fn();
|
|
37
|
+
function useStableCallback(callback) {
|
|
38
|
+
const stable = useRefWithInit(createStableCallback).current;
|
|
39
|
+
stable.next = callback;
|
|
40
|
+
useSafeInsertionEffect(stable.effect);
|
|
41
|
+
return stable.trampoline;
|
|
42
|
+
}
|
|
43
|
+
function createStableCallback() {
|
|
44
|
+
const stable = {
|
|
45
|
+
next: void 0,
|
|
46
|
+
callback: assertNotCalled,
|
|
47
|
+
trampoline: (...args) => stable.callback?.(...args),
|
|
48
|
+
effect: () => {
|
|
49
|
+
stable.callback = stable.next;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return stable;
|
|
53
|
+
}
|
|
54
|
+
function assertNotCalled() {
|
|
55
|
+
}
|
|
5
56
|
function hasWindow() {
|
|
6
57
|
return typeof window !== "undefined";
|
|
7
58
|
}
|
|
@@ -114,37 +165,163 @@ function getOverflowAncestors(node, list, traverseIframes) {
|
|
|
114
165
|
function getFrameElement(win) {
|
|
115
166
|
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
116
167
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return ref;
|
|
168
|
+
function addEventListener(target, type, listener, options) {
|
|
169
|
+
target.addEventListener(type, listener, options);
|
|
170
|
+
return () => {
|
|
171
|
+
target.removeEventListener(type, listener, options);
|
|
172
|
+
};
|
|
123
173
|
}
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
174
|
+
var EMPTY = null;
|
|
175
|
+
globalThis.requestAnimationFrame;
|
|
176
|
+
var Scheduler = class {
|
|
177
|
+
callbacks = [];
|
|
178
|
+
callbacksCount = 0;
|
|
179
|
+
nextId = 1;
|
|
180
|
+
startId = 1;
|
|
181
|
+
isScheduled = false;
|
|
182
|
+
tick = (timestamp) => {
|
|
183
|
+
this.isScheduled = false;
|
|
184
|
+
const currentCallbacks = this.callbacks;
|
|
185
|
+
const currentCallbacksCount = this.callbacksCount;
|
|
186
|
+
this.callbacks = [];
|
|
187
|
+
this.callbacksCount = 0;
|
|
188
|
+
this.startId = this.nextId;
|
|
189
|
+
if (currentCallbacksCount > 0) for (let i = 0; i < currentCallbacks.length; i += 1) currentCallbacks[i]?.(timestamp);
|
|
190
|
+
};
|
|
191
|
+
request(fn) {
|
|
192
|
+
const id = this.nextId;
|
|
193
|
+
this.nextId += 1;
|
|
194
|
+
this.callbacks.push(fn);
|
|
195
|
+
this.callbacksCount += 1;
|
|
196
|
+
if (!this.isScheduled || false) {
|
|
197
|
+
requestAnimationFrame(this.tick);
|
|
198
|
+
this.isScheduled = true;
|
|
199
|
+
}
|
|
200
|
+
return id;
|
|
201
|
+
}
|
|
202
|
+
cancel(id) {
|
|
203
|
+
const index = id - this.startId;
|
|
204
|
+
if (index < 0 || index >= this.callbacks.length) return;
|
|
205
|
+
this.callbacks[index] = null;
|
|
206
|
+
this.callbacksCount -= 1;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var scheduler = new Scheduler();
|
|
210
|
+
var AnimationFrame = class AnimationFrame2 {
|
|
211
|
+
static create() {
|
|
212
|
+
return new AnimationFrame2();
|
|
213
|
+
}
|
|
214
|
+
static request(fn) {
|
|
215
|
+
return scheduler.request(fn);
|
|
216
|
+
}
|
|
217
|
+
static cancel(id) {
|
|
218
|
+
return scheduler.cancel(id);
|
|
219
|
+
}
|
|
220
|
+
currentId = EMPTY;
|
|
221
|
+
/**
|
|
222
|
+
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
223
|
+
*/
|
|
224
|
+
request(fn) {
|
|
225
|
+
this.cancel();
|
|
226
|
+
this.currentId = scheduler.request(() => {
|
|
227
|
+
this.currentId = EMPTY;
|
|
228
|
+
fn();
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
cancel = () => {
|
|
232
|
+
if (this.currentId !== EMPTY) {
|
|
233
|
+
scheduler.cancel(this.currentId);
|
|
234
|
+
this.currentId = EMPTY;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
disposeEffect = () => {
|
|
238
|
+
return this.cancel;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
function useAnimationFrame() {
|
|
242
|
+
const timeout = useRefWithInit(AnimationFrame.create).current;
|
|
243
|
+
useOnMount(timeout.disposeEffect);
|
|
244
|
+
return timeout;
|
|
131
245
|
}
|
|
132
|
-
function
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
246
|
+
function useMergedRefs(a, b, c, d) {
|
|
247
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
248
|
+
if (didChange(forkRef, a, b, c, d)) update(forkRef, [
|
|
249
|
+
a,
|
|
250
|
+
b,
|
|
251
|
+
c,
|
|
252
|
+
d
|
|
253
|
+
]);
|
|
254
|
+
return forkRef.callback;
|
|
255
|
+
}
|
|
256
|
+
function useMergedRefsN(refs) {
|
|
257
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
258
|
+
if (didChangeN(forkRef, refs)) update(forkRef, refs);
|
|
259
|
+
return forkRef.callback;
|
|
260
|
+
}
|
|
261
|
+
function createForkRef() {
|
|
262
|
+
return {
|
|
263
|
+
callback: null,
|
|
264
|
+
cleanup: null,
|
|
265
|
+
refs: []
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function didChange(forkRef, a, b, c, d) {
|
|
269
|
+
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
|
|
270
|
+
}
|
|
271
|
+
function didChangeN(forkRef, newRefs) {
|
|
272
|
+
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
|
|
273
|
+
}
|
|
274
|
+
function update(forkRef, refs) {
|
|
275
|
+
forkRef.refs = refs;
|
|
276
|
+
if (refs.every((ref) => ref == null)) {
|
|
277
|
+
forkRef.callback = null;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
forkRef.callback = (instance) => {
|
|
281
|
+
if (forkRef.cleanup) {
|
|
282
|
+
forkRef.cleanup();
|
|
283
|
+
forkRef.cleanup = null;
|
|
284
|
+
}
|
|
285
|
+
if (instance != null) {
|
|
286
|
+
const cleanupCallbacks = Array(refs.length).fill(null);
|
|
287
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
288
|
+
const ref = refs[i];
|
|
289
|
+
if (ref == null) continue;
|
|
290
|
+
switch (typeof ref) {
|
|
291
|
+
case "function": {
|
|
292
|
+
const refCleanup = ref(instance);
|
|
293
|
+
if (typeof refCleanup === "function") cleanupCallbacks[i] = refCleanup;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case "object":
|
|
297
|
+
ref.current = instance;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
forkRef.cleanup = () => {
|
|
301
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
302
|
+
const ref = refs[i];
|
|
303
|
+
if (ref == null) continue;
|
|
304
|
+
switch (typeof ref) {
|
|
305
|
+
case "function": {
|
|
306
|
+
const cleanupCallback = cleanupCallbacks[i];
|
|
307
|
+
if (typeof cleanupCallback === "function") cleanupCallback();
|
|
308
|
+
else ref(null);
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
case "object":
|
|
312
|
+
ref.current = null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
139
316
|
}
|
|
140
317
|
};
|
|
141
|
-
return stable;
|
|
142
318
|
}
|
|
143
|
-
function
|
|
319
|
+
function getReactElementRef(element) {
|
|
320
|
+
if (!/* @__PURE__ */ React$1.isValidElement(element)) return null;
|
|
321
|
+
const reactElement = element;
|
|
322
|
+
const propsWithRef = reactElement.props;
|
|
323
|
+
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
|
|
144
324
|
}
|
|
145
|
-
var noop = () => {
|
|
146
|
-
};
|
|
147
|
-
var useIsoLayoutEffect = typeof document !== "undefined" ? React$1.useLayoutEffect : noop;
|
|
148
325
|
function mergeObjects(a, b) {
|
|
149
326
|
if (a && !b) return a;
|
|
150
327
|
if (!a && b) return b;
|
|
@@ -153,6 +330,26 @@ function mergeObjects(a, b) {
|
|
|
153
330
|
...b
|
|
154
331
|
};
|
|
155
332
|
}
|
|
333
|
+
function getStateAttributesProps(state, customMapping) {
|
|
334
|
+
const props = {};
|
|
335
|
+
for (const key in state) {
|
|
336
|
+
const value = state[key];
|
|
337
|
+
if (customMapping?.hasOwnProperty(key)) {
|
|
338
|
+
const customProps = customMapping[key](value);
|
|
339
|
+
if (customProps != null) Object.assign(props, customProps);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (value === true) props[`data-${key.toLowerCase()}`] = "";
|
|
343
|
+
else if (value) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
344
|
+
}
|
|
345
|
+
return props;
|
|
346
|
+
}
|
|
347
|
+
function resolveClassName(className, state) {
|
|
348
|
+
return typeof className === "function" ? className(state) : className;
|
|
349
|
+
}
|
|
350
|
+
function resolveStyle(style, state) {
|
|
351
|
+
return typeof style === "function" ? style(state) : style;
|
|
352
|
+
}
|
|
156
353
|
var EMPTY_PROPS = {};
|
|
157
354
|
function mergeProps(a, b, c, d, e) {
|
|
158
355
|
if (!c && !d && !e && !a) return createInitialMergedProps(b);
|
|
@@ -258,275 +455,6 @@ function mergeClassNames(ourClassName, theirClassName) {
|
|
|
258
455
|
function isSyntheticEvent(event) {
|
|
259
456
|
return event != null && typeof event === "object" && "nativeEvent" in event;
|
|
260
457
|
}
|
|
261
|
-
function createFormatErrorMessage(baseUrl, prefix) {
|
|
262
|
-
return function formatErrorMessage2(code, ...args) {
|
|
263
|
-
const url = new URL(baseUrl);
|
|
264
|
-
url.searchParams.set("code", code.toString());
|
|
265
|
-
args.forEach((arg) => url.searchParams.append("args[]", arg));
|
|
266
|
-
return `${prefix} error #${code}; visit ${url} for the full message.`;
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
var formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
|
|
270
|
-
var CompositeRootContext = /* @__PURE__ */ React$1.createContext(void 0);
|
|
271
|
-
function useCompositeRootContext(optional = false) {
|
|
272
|
-
const context = React$1.useContext(CompositeRootContext);
|
|
273
|
-
if (context === void 0 && !optional) throw new Error(formatErrorMessage(16));
|
|
274
|
-
return context;
|
|
275
|
-
}
|
|
276
|
-
function useFocusableWhenDisabled(parameters) {
|
|
277
|
-
const { focusableWhenDisabled, disabled: disabled2, composite = false, tabIndex: tabIndexProp = 0, isNativeButton } = parameters;
|
|
278
|
-
const isFocusableComposite = composite && focusableWhenDisabled !== false;
|
|
279
|
-
const isNonFocusableComposite = composite && focusableWhenDisabled === false;
|
|
280
|
-
return { props: React$1.useMemo(() => {
|
|
281
|
-
const additionalProps = { onKeyDown(event) {
|
|
282
|
-
if (disabled2 && focusableWhenDisabled && event.key !== "Tab") event.preventDefault();
|
|
283
|
-
} };
|
|
284
|
-
if (!composite) {
|
|
285
|
-
additionalProps.tabIndex = tabIndexProp;
|
|
286
|
-
if (!isNativeButton && disabled2) additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
|
|
287
|
-
}
|
|
288
|
-
if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) additionalProps["aria-disabled"] = disabled2;
|
|
289
|
-
if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) additionalProps.disabled = disabled2;
|
|
290
|
-
return additionalProps;
|
|
291
|
-
}, [
|
|
292
|
-
composite,
|
|
293
|
-
disabled2,
|
|
294
|
-
focusableWhenDisabled,
|
|
295
|
-
isFocusableComposite,
|
|
296
|
-
isNonFocusableComposite,
|
|
297
|
-
isNativeButton,
|
|
298
|
-
tabIndexProp
|
|
299
|
-
]) };
|
|
300
|
-
}
|
|
301
|
-
function dispatchClickWithModifiers(target, sourceEvent, { detail = 0 } = {}) {
|
|
302
|
-
target.dispatchEvent(new (getWindow(target)).PointerEvent("click", {
|
|
303
|
-
bubbles: true,
|
|
304
|
-
cancelable: true,
|
|
305
|
-
composed: true,
|
|
306
|
-
detail,
|
|
307
|
-
shiftKey: sourceEvent.shiftKey,
|
|
308
|
-
ctrlKey: sourceEvent.ctrlKey,
|
|
309
|
-
altKey: sourceEvent.altKey,
|
|
310
|
-
metaKey: sourceEvent.metaKey
|
|
311
|
-
}));
|
|
312
|
-
}
|
|
313
|
-
function useButton(parameters = {}) {
|
|
314
|
-
const { disabled: disabled2 = false, focusableWhenDisabled, tabIndex = 0, native: isNativeButton = true, composite: compositeProp } = parameters;
|
|
315
|
-
const elementRef = React$1.useRef(null);
|
|
316
|
-
const compositeRootContext = useCompositeRootContext(true);
|
|
317
|
-
const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
|
|
318
|
-
const { props: focusableWhenDisabledProps } = useFocusableWhenDisabled({
|
|
319
|
-
focusableWhenDisabled,
|
|
320
|
-
disabled: disabled2,
|
|
321
|
-
composite: isCompositeItem,
|
|
322
|
-
tabIndex,
|
|
323
|
-
isNativeButton
|
|
324
|
-
});
|
|
325
|
-
const updateDisabled = React$1.useCallback(() => {
|
|
326
|
-
const element = elementRef.current;
|
|
327
|
-
if (!isButtonElement(element)) return;
|
|
328
|
-
if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) element.disabled = false;
|
|
329
|
-
}, [
|
|
330
|
-
disabled2,
|
|
331
|
-
focusableWhenDisabledProps.disabled,
|
|
332
|
-
isCompositeItem
|
|
333
|
-
]);
|
|
334
|
-
useIsoLayoutEffect(updateDisabled, [updateDisabled]);
|
|
335
|
-
return {
|
|
336
|
-
getButtonProps: React$1.useCallback((externalProps = {}) => {
|
|
337
|
-
const { onClick: externalOnClick, onMouseDown: externalOnMouseDown, onKeyUp: externalOnKeyUp, onKeyDown: externalOnKeyDown, onPointerDown: externalOnPointerDown, ...otherExternalProps } = externalProps;
|
|
338
|
-
return mergeProps({
|
|
339
|
-
onClick(event) {
|
|
340
|
-
if (disabled2) {
|
|
341
|
-
event.preventDefault();
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
externalOnClick?.(event);
|
|
345
|
-
},
|
|
346
|
-
onMouseDown(event) {
|
|
347
|
-
if (!disabled2) externalOnMouseDown?.(event);
|
|
348
|
-
},
|
|
349
|
-
onKeyDown(event) {
|
|
350
|
-
if (disabled2) return;
|
|
351
|
-
makeEventPreventable(event);
|
|
352
|
-
externalOnKeyDown?.(event);
|
|
353
|
-
if (event.baseUIHandlerPrevented) return;
|
|
354
|
-
const isCurrentTarget = event.target === event.currentTarget;
|
|
355
|
-
const currentTarget = event.currentTarget;
|
|
356
|
-
const isButton = isButtonElement(currentTarget);
|
|
357
|
-
const isLink = !isNativeButton && isValidLinkElement(currentTarget);
|
|
358
|
-
const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);
|
|
359
|
-
const isEnterKey = event.key === "Enter";
|
|
360
|
-
const isSpaceKey = event.key === " ";
|
|
361
|
-
const role = currentTarget.getAttribute("role");
|
|
362
|
-
const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
|
|
363
|
-
if (isCurrentTarget && isCompositeItem && isSpaceKey) {
|
|
364
|
-
if (event.defaultPrevented && isTextNavigationRole) return;
|
|
365
|
-
event.preventDefault();
|
|
366
|
-
if (!isNativeButton || isButton) {
|
|
367
|
-
event.preventBaseUIHandler();
|
|
368
|
-
dispatchClickWithModifiers(currentTarget, event);
|
|
369
|
-
}
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
if (!shouldClick || isNativeButton || !isSpaceKey && !isEnterKey) {
|
|
373
|
-
if (isCurrentTarget && isLink && isSpaceKey) event.preventDefault();
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
if (event.defaultPrevented) return;
|
|
377
|
-
event.preventDefault();
|
|
378
|
-
if (isEnterKey) {
|
|
379
|
-
event.preventBaseUIHandler();
|
|
380
|
-
dispatchClickWithModifiers(currentTarget, event);
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
onKeyUp(event) {
|
|
384
|
-
if (disabled2) return;
|
|
385
|
-
makeEventPreventable(event);
|
|
386
|
-
externalOnKeyUp?.(event);
|
|
387
|
-
if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
|
|
388
|
-
event.preventDefault();
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
if (event.baseUIHandlerPrevented) return;
|
|
392
|
-
if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && !event.defaultPrevented && event.key === " ") {
|
|
393
|
-
event.preventBaseUIHandler();
|
|
394
|
-
dispatchClickWithModifiers(event.currentTarget, event);
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
onPointerDown(event) {
|
|
398
|
-
if (disabled2) {
|
|
399
|
-
event.preventDefault();
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
externalOnPointerDown?.(event);
|
|
403
|
-
}
|
|
404
|
-
}, isNativeButton ? { type: "button" } : { role: "button" }, focusableWhenDisabledProps, otherExternalProps);
|
|
405
|
-
}, [
|
|
406
|
-
disabled2,
|
|
407
|
-
focusableWhenDisabledProps,
|
|
408
|
-
isCompositeItem,
|
|
409
|
-
isNativeButton
|
|
410
|
-
]),
|
|
411
|
-
buttonRef: useStableCallback((element) => {
|
|
412
|
-
elementRef.current = element;
|
|
413
|
-
updateDisabled();
|
|
414
|
-
})
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
function isButtonElement(elem) {
|
|
418
|
-
return isHTMLElement(elem) && elem.tagName === "BUTTON";
|
|
419
|
-
}
|
|
420
|
-
function isValidLinkElement(elem) {
|
|
421
|
-
return isHTMLElement(elem) && elem.tagName === "A" && Boolean(elem.href);
|
|
422
|
-
}
|
|
423
|
-
function useMergedRefs(a, b, c, d) {
|
|
424
|
-
const forkRef = useRefWithInit(createForkRef).current;
|
|
425
|
-
if (didChange(forkRef, a, b, c, d)) update(forkRef, [
|
|
426
|
-
a,
|
|
427
|
-
b,
|
|
428
|
-
c,
|
|
429
|
-
d
|
|
430
|
-
]);
|
|
431
|
-
return forkRef.callback;
|
|
432
|
-
}
|
|
433
|
-
function useMergedRefsN(refs) {
|
|
434
|
-
const forkRef = useRefWithInit(createForkRef).current;
|
|
435
|
-
if (didChangeN(forkRef, refs)) update(forkRef, refs);
|
|
436
|
-
return forkRef.callback;
|
|
437
|
-
}
|
|
438
|
-
function createForkRef() {
|
|
439
|
-
return {
|
|
440
|
-
callback: null,
|
|
441
|
-
cleanup: null,
|
|
442
|
-
refs: []
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
function didChange(forkRef, a, b, c, d) {
|
|
446
|
-
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
|
|
447
|
-
}
|
|
448
|
-
function didChangeN(forkRef, newRefs) {
|
|
449
|
-
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
|
|
450
|
-
}
|
|
451
|
-
function update(forkRef, refs) {
|
|
452
|
-
forkRef.refs = refs;
|
|
453
|
-
if (refs.every((ref) => ref == null)) {
|
|
454
|
-
forkRef.callback = null;
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
forkRef.callback = (instance) => {
|
|
458
|
-
if (forkRef.cleanup) {
|
|
459
|
-
forkRef.cleanup();
|
|
460
|
-
forkRef.cleanup = null;
|
|
461
|
-
}
|
|
462
|
-
if (instance != null) {
|
|
463
|
-
const cleanupCallbacks = Array(refs.length).fill(null);
|
|
464
|
-
for (let i = 0; i < refs.length; i += 1) {
|
|
465
|
-
const ref = refs[i];
|
|
466
|
-
if (ref == null) continue;
|
|
467
|
-
switch (typeof ref) {
|
|
468
|
-
case "function": {
|
|
469
|
-
const refCleanup = ref(instance);
|
|
470
|
-
if (typeof refCleanup === "function") cleanupCallbacks[i] = refCleanup;
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
case "object":
|
|
474
|
-
ref.current = instance;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
forkRef.cleanup = () => {
|
|
478
|
-
for (let i = 0; i < refs.length; i += 1) {
|
|
479
|
-
const ref = refs[i];
|
|
480
|
-
if (ref == null) continue;
|
|
481
|
-
switch (typeof ref) {
|
|
482
|
-
case "function": {
|
|
483
|
-
const cleanupCallback = cleanupCallbacks[i];
|
|
484
|
-
if (typeof cleanupCallback === "function") cleanupCallback();
|
|
485
|
-
else ref(null);
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
case "object":
|
|
489
|
-
ref.current = null;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
var majorVersion = parseInt(React$1.version, 10);
|
|
497
|
-
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
498
|
-
return majorVersion >= reactVersionToCheck;
|
|
499
|
-
}
|
|
500
|
-
function getReactElementRef(element) {
|
|
501
|
-
if (!/* @__PURE__ */ React$1.isValidElement(element)) return null;
|
|
502
|
-
const reactElement = element;
|
|
503
|
-
const propsWithRef = reactElement.props;
|
|
504
|
-
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
|
|
505
|
-
}
|
|
506
|
-
function NOOP() {
|
|
507
|
-
}
|
|
508
|
-
var EMPTY_ARRAY = Object.freeze([]);
|
|
509
|
-
var EMPTY_OBJECT = Object.freeze({});
|
|
510
|
-
function getStateAttributesProps(state, customMapping) {
|
|
511
|
-
const props = {};
|
|
512
|
-
for (const key in state) {
|
|
513
|
-
const value = state[key];
|
|
514
|
-
if (customMapping?.hasOwnProperty(key)) {
|
|
515
|
-
const customProps = customMapping[key](value);
|
|
516
|
-
if (customProps != null) Object.assign(props, customProps);
|
|
517
|
-
continue;
|
|
518
|
-
}
|
|
519
|
-
if (value === true) props[`data-${key.toLowerCase()}`] = "";
|
|
520
|
-
else if (value) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
521
|
-
}
|
|
522
|
-
return props;
|
|
523
|
-
}
|
|
524
|
-
function resolveClassName(className, state) {
|
|
525
|
-
return typeof className === "function" ? className(state) : className;
|
|
526
|
-
}
|
|
527
|
-
function resolveStyle(style, state) {
|
|
528
|
-
return typeof style === "function" ? style(state) : style;
|
|
529
|
-
}
|
|
530
458
|
function useRenderElement(element, componentProps, params = {}) {
|
|
531
459
|
const renderProp = componentProps.render;
|
|
532
460
|
const outProps = useRenderElementProps(componentProps, params);
|
|
@@ -540,133 +468,52 @@ function useRenderElementProps(componentProps, params = {}) {
|
|
|
540
468
|
const style = enabled ? resolveStyle(styleProp, state) : void 0;
|
|
541
469
|
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
542
470
|
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
|
|
543
|
-
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
|
|
544
|
-
if (typeof document !== "undefined") {
|
|
545
|
-
if (!enabled) useMergedRefs(null, null);
|
|
546
|
-
else if (Array.isArray(ref)) outProps.ref = useMergedRefsN([
|
|
547
|
-
outProps.ref,
|
|
548
|
-
getReactElementRef(renderProp),
|
|
549
|
-
...ref
|
|
550
|
-
]);
|
|
551
|
-
else outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
|
|
552
|
-
}
|
|
553
|
-
if (!enabled) return EMPTY_OBJECT;
|
|
554
|
-
if (className !== void 0) outProps.className = mergeClassNames(outProps.className, className);
|
|
555
|
-
if (style !== void 0) outProps.style = mergeObjects(outProps.style, style);
|
|
556
|
-
return outProps;
|
|
557
|
-
}
|
|
558
|
-
function resolveRenderFunctionProps(props) {
|
|
559
|
-
if (Array.isArray(props)) return mergePropsN(props);
|
|
560
|
-
return mergeProps(void 0, props);
|
|
561
|
-
}
|
|
562
|
-
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
563
|
-
function evaluateRenderProp(element, render, props, state) {
|
|
564
|
-
if (render) {
|
|
565
|
-
if (typeof render === "function") return render(props, state);
|
|
566
|
-
const mergedProps = mergeProps(props, render.props);
|
|
567
|
-
mergedProps.ref = props.ref;
|
|
568
|
-
let newElement = render;
|
|
569
|
-
if (newElement?.$$typeof === REACT_LAZY_TYPE) newElement = React$1.Children.toArray(render)[0];
|
|
570
|
-
return /* @__PURE__ */ React$1.cloneElement(newElement, mergedProps);
|
|
571
|
-
}
|
|
572
|
-
if (element) {
|
|
573
|
-
if (typeof element === "string") return renderTag(element, props);
|
|
574
|
-
}
|
|
575
|
-
throw new Error(formatErrorMessage(8));
|
|
576
|
-
}
|
|
577
|
-
function renderTag(Tag, props) {
|
|
578
|
-
if (Tag === "button") return /* @__PURE__ */ createElement2("button", {
|
|
579
|
-
type: "button",
|
|
580
|
-
...props,
|
|
581
|
-
key: props.key
|
|
582
|
-
});
|
|
583
|
-
if (Tag === "img") return /* @__PURE__ */ createElement2("img", {
|
|
584
|
-
alt: "",
|
|
585
|
-
...props,
|
|
586
|
-
key: props.key
|
|
587
|
-
});
|
|
588
|
-
return /* @__PURE__ */ React$1.createElement(Tag, props);
|
|
589
|
-
}
|
|
590
|
-
function useOnMount(fn) {
|
|
591
|
-
React$1.useEffect(fn, EMPTY_ARRAY);
|
|
592
|
-
}
|
|
593
|
-
function addEventListener(target, type, listener, options) {
|
|
594
|
-
target.addEventListener(type, listener, options);
|
|
595
|
-
return () => {
|
|
596
|
-
target.removeEventListener(type, listener, options);
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
var EMPTY = null;
|
|
600
|
-
globalThis.requestAnimationFrame;
|
|
601
|
-
var Scheduler = class {
|
|
602
|
-
callbacks = [];
|
|
603
|
-
callbacksCount = 0;
|
|
604
|
-
nextId = 1;
|
|
605
|
-
startId = 1;
|
|
606
|
-
isScheduled = false;
|
|
607
|
-
tick = (timestamp) => {
|
|
608
|
-
this.isScheduled = false;
|
|
609
|
-
const currentCallbacks = this.callbacks;
|
|
610
|
-
const currentCallbacksCount = this.callbacksCount;
|
|
611
|
-
this.callbacks = [];
|
|
612
|
-
this.callbacksCount = 0;
|
|
613
|
-
this.startId = this.nextId;
|
|
614
|
-
if (currentCallbacksCount > 0) for (let i = 0; i < currentCallbacks.length; i += 1) currentCallbacks[i]?.(timestamp);
|
|
615
|
-
};
|
|
616
|
-
request(fn) {
|
|
617
|
-
const id = this.nextId;
|
|
618
|
-
this.nextId += 1;
|
|
619
|
-
this.callbacks.push(fn);
|
|
620
|
-
this.callbacksCount += 1;
|
|
621
|
-
if (!this.isScheduled || false) {
|
|
622
|
-
requestAnimationFrame(this.tick);
|
|
623
|
-
this.isScheduled = true;
|
|
624
|
-
}
|
|
625
|
-
return id;
|
|
626
|
-
}
|
|
627
|
-
cancel(id) {
|
|
628
|
-
const index = id - this.startId;
|
|
629
|
-
if (index < 0 || index >= this.callbacks.length) return;
|
|
630
|
-
this.callbacks[index] = null;
|
|
631
|
-
this.callbacksCount -= 1;
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
var scheduler = new Scheduler();
|
|
635
|
-
var AnimationFrame = class AnimationFrame2 {
|
|
636
|
-
static create() {
|
|
637
|
-
return new AnimationFrame2();
|
|
638
|
-
}
|
|
639
|
-
static request(fn) {
|
|
640
|
-
return scheduler.request(fn);
|
|
471
|
+
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
|
|
472
|
+
if (typeof document !== "undefined") {
|
|
473
|
+
if (!enabled) useMergedRefs(null, null);
|
|
474
|
+
else if (Array.isArray(ref)) outProps.ref = useMergedRefsN([
|
|
475
|
+
outProps.ref,
|
|
476
|
+
getReactElementRef(renderProp),
|
|
477
|
+
...ref
|
|
478
|
+
]);
|
|
479
|
+
else outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
|
|
641
480
|
}
|
|
642
|
-
|
|
643
|
-
|
|
481
|
+
if (!enabled) return EMPTY_OBJECT;
|
|
482
|
+
if (className !== void 0) outProps.className = mergeClassNames(outProps.className, className);
|
|
483
|
+
if (style !== void 0) outProps.style = mergeObjects(outProps.style, style);
|
|
484
|
+
return outProps;
|
|
485
|
+
}
|
|
486
|
+
function resolveRenderFunctionProps(props) {
|
|
487
|
+
if (Array.isArray(props)) return mergePropsN(props);
|
|
488
|
+
return mergeProps(void 0, props);
|
|
489
|
+
}
|
|
490
|
+
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
491
|
+
function evaluateRenderProp(element, render, props, state) {
|
|
492
|
+
if (render) {
|
|
493
|
+
if (typeof render === "function") return render(props, state);
|
|
494
|
+
const mergedProps = mergeProps(props, render.props);
|
|
495
|
+
mergedProps.ref = props.ref;
|
|
496
|
+
let newElement = render;
|
|
497
|
+
if (newElement?.$$typeof === REACT_LAZY_TYPE) newElement = React$1.Children.toArray(render)[0];
|
|
498
|
+
return /* @__PURE__ */ React$1.cloneElement(newElement, mergedProps);
|
|
644
499
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
648
|
-
*/
|
|
649
|
-
request(fn) {
|
|
650
|
-
this.cancel();
|
|
651
|
-
this.currentId = scheduler.request(() => {
|
|
652
|
-
this.currentId = EMPTY;
|
|
653
|
-
fn();
|
|
654
|
-
});
|
|
500
|
+
if (element) {
|
|
501
|
+
if (typeof element === "string") return renderTag(element, props);
|
|
655
502
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return
|
|
503
|
+
throw new Error(formatErrorMessage(8));
|
|
504
|
+
}
|
|
505
|
+
function renderTag(Tag, props) {
|
|
506
|
+
if (Tag === "button") return /* @__PURE__ */ createElement2("button", {
|
|
507
|
+
type: "button",
|
|
508
|
+
...props,
|
|
509
|
+
key: props.key
|
|
510
|
+
});
|
|
511
|
+
if (Tag === "img") return /* @__PURE__ */ createElement2("img", {
|
|
512
|
+
alt: "",
|
|
513
|
+
...props,
|
|
514
|
+
key: props.key
|
|
515
|
+
});
|
|
516
|
+
return /* @__PURE__ */ React$1.createElement(Tag, props);
|
|
670
517
|
}
|
|
671
518
|
var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
|
|
672
519
|
TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
|
|
@@ -770,6 +617,159 @@ function useId$1(idOverride, prefix) {
|
|
|
770
617
|
}
|
|
771
618
|
return useGlobalId(idOverride, prefix);
|
|
772
619
|
}
|
|
620
|
+
var CompositeRootContext = /* @__PURE__ */ React$1.createContext(void 0);
|
|
621
|
+
function useCompositeRootContext(optional = false) {
|
|
622
|
+
const context = React$1.useContext(CompositeRootContext);
|
|
623
|
+
if (context === void 0 && !optional) throw new Error(formatErrorMessage(16));
|
|
624
|
+
return context;
|
|
625
|
+
}
|
|
626
|
+
function useFocusableWhenDisabled(parameters) {
|
|
627
|
+
const { focusableWhenDisabled, disabled: disabled2, composite = false, tabIndex: tabIndexProp = 0, isNativeButton } = parameters;
|
|
628
|
+
const isFocusableComposite = composite && focusableWhenDisabled !== false;
|
|
629
|
+
const isNonFocusableComposite = composite && focusableWhenDisabled === false;
|
|
630
|
+
return { props: React$1.useMemo(() => {
|
|
631
|
+
const additionalProps = { onKeyDown(event) {
|
|
632
|
+
if (disabled2 && focusableWhenDisabled && event.key !== "Tab") event.preventDefault();
|
|
633
|
+
} };
|
|
634
|
+
if (!composite) {
|
|
635
|
+
additionalProps.tabIndex = tabIndexProp;
|
|
636
|
+
if (!isNativeButton && disabled2) additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
|
|
637
|
+
}
|
|
638
|
+
if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) additionalProps["aria-disabled"] = disabled2;
|
|
639
|
+
if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) additionalProps.disabled = disabled2;
|
|
640
|
+
return additionalProps;
|
|
641
|
+
}, [
|
|
642
|
+
composite,
|
|
643
|
+
disabled2,
|
|
644
|
+
focusableWhenDisabled,
|
|
645
|
+
isFocusableComposite,
|
|
646
|
+
isNonFocusableComposite,
|
|
647
|
+
isNativeButton,
|
|
648
|
+
tabIndexProp
|
|
649
|
+
]) };
|
|
650
|
+
}
|
|
651
|
+
function dispatchClickWithModifiers(target, sourceEvent, { detail = 0 } = {}) {
|
|
652
|
+
target.dispatchEvent(new (getWindow(target)).PointerEvent("click", {
|
|
653
|
+
bubbles: true,
|
|
654
|
+
cancelable: true,
|
|
655
|
+
composed: true,
|
|
656
|
+
detail,
|
|
657
|
+
shiftKey: sourceEvent.shiftKey,
|
|
658
|
+
ctrlKey: sourceEvent.ctrlKey,
|
|
659
|
+
altKey: sourceEvent.altKey,
|
|
660
|
+
metaKey: sourceEvent.metaKey
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
function useButton(parameters = {}) {
|
|
664
|
+
const { disabled: disabled2 = false, focusableWhenDisabled, tabIndex = 0, native: isNativeButton = true, composite: compositeProp } = parameters;
|
|
665
|
+
const elementRef = React$1.useRef(null);
|
|
666
|
+
const compositeRootContext = useCompositeRootContext(true);
|
|
667
|
+
const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
|
|
668
|
+
const { props: focusableWhenDisabledProps } = useFocusableWhenDisabled({
|
|
669
|
+
focusableWhenDisabled,
|
|
670
|
+
disabled: disabled2,
|
|
671
|
+
composite: isCompositeItem,
|
|
672
|
+
tabIndex,
|
|
673
|
+
isNativeButton
|
|
674
|
+
});
|
|
675
|
+
const updateDisabled = React$1.useCallback(() => {
|
|
676
|
+
const element = elementRef.current;
|
|
677
|
+
if (!isButtonElement(element)) return;
|
|
678
|
+
if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) element.disabled = false;
|
|
679
|
+
}, [
|
|
680
|
+
disabled2,
|
|
681
|
+
focusableWhenDisabledProps.disabled,
|
|
682
|
+
isCompositeItem
|
|
683
|
+
]);
|
|
684
|
+
useIsoLayoutEffect(updateDisabled, [updateDisabled]);
|
|
685
|
+
return {
|
|
686
|
+
getButtonProps: React$1.useCallback((externalProps = {}) => {
|
|
687
|
+
const { onClick: externalOnClick, onMouseDown: externalOnMouseDown, onKeyUp: externalOnKeyUp, onKeyDown: externalOnKeyDown, onPointerDown: externalOnPointerDown, ...otherExternalProps } = externalProps;
|
|
688
|
+
return mergeProps({
|
|
689
|
+
onClick(event) {
|
|
690
|
+
if (disabled2) {
|
|
691
|
+
event.preventDefault();
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
externalOnClick?.(event);
|
|
695
|
+
},
|
|
696
|
+
onMouseDown(event) {
|
|
697
|
+
if (!disabled2) externalOnMouseDown?.(event);
|
|
698
|
+
},
|
|
699
|
+
onKeyDown(event) {
|
|
700
|
+
if (disabled2) return;
|
|
701
|
+
makeEventPreventable(event);
|
|
702
|
+
externalOnKeyDown?.(event);
|
|
703
|
+
if (event.baseUIHandlerPrevented) return;
|
|
704
|
+
const isCurrentTarget = event.target === event.currentTarget;
|
|
705
|
+
const currentTarget = event.currentTarget;
|
|
706
|
+
const isButton = isButtonElement(currentTarget);
|
|
707
|
+
const isLink = !isNativeButton && isValidLinkElement(currentTarget);
|
|
708
|
+
const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);
|
|
709
|
+
const isEnterKey = event.key === "Enter";
|
|
710
|
+
const isSpaceKey = event.key === " ";
|
|
711
|
+
const role = currentTarget.getAttribute("role");
|
|
712
|
+
const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
|
|
713
|
+
if (isCurrentTarget && isCompositeItem && isSpaceKey) {
|
|
714
|
+
if (event.defaultPrevented && isTextNavigationRole) return;
|
|
715
|
+
event.preventDefault();
|
|
716
|
+
if (!isNativeButton || isButton) {
|
|
717
|
+
event.preventBaseUIHandler();
|
|
718
|
+
dispatchClickWithModifiers(currentTarget, event);
|
|
719
|
+
}
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (!shouldClick || isNativeButton || !isSpaceKey && !isEnterKey) {
|
|
723
|
+
if (isCurrentTarget && isLink && isSpaceKey) event.preventDefault();
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (event.defaultPrevented) return;
|
|
727
|
+
event.preventDefault();
|
|
728
|
+
if (isEnterKey) {
|
|
729
|
+
event.preventBaseUIHandler();
|
|
730
|
+
dispatchClickWithModifiers(currentTarget, event);
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
onKeyUp(event) {
|
|
734
|
+
if (disabled2) return;
|
|
735
|
+
makeEventPreventable(event);
|
|
736
|
+
externalOnKeyUp?.(event);
|
|
737
|
+
if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
|
|
738
|
+
event.preventDefault();
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (event.baseUIHandlerPrevented) return;
|
|
742
|
+
if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && !event.defaultPrevented && event.key === " ") {
|
|
743
|
+
event.preventBaseUIHandler();
|
|
744
|
+
dispatchClickWithModifiers(event.currentTarget, event);
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
onPointerDown(event) {
|
|
748
|
+
if (disabled2) {
|
|
749
|
+
event.preventDefault();
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
externalOnPointerDown?.(event);
|
|
753
|
+
}
|
|
754
|
+
}, isNativeButton ? { type: "button" } : { role: "button" }, focusableWhenDisabledProps, otherExternalProps);
|
|
755
|
+
}, [
|
|
756
|
+
disabled2,
|
|
757
|
+
focusableWhenDisabledProps,
|
|
758
|
+
isCompositeItem,
|
|
759
|
+
isNativeButton
|
|
760
|
+
]),
|
|
761
|
+
buttonRef: useStableCallback((element) => {
|
|
762
|
+
elementRef.current = element;
|
|
763
|
+
updateDisabled();
|
|
764
|
+
})
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function isButtonElement(elem) {
|
|
768
|
+
return isHTMLElement(elem) && elem.tagName === "BUTTON";
|
|
769
|
+
}
|
|
770
|
+
function isValidLinkElement(elem) {
|
|
771
|
+
return isHTMLElement(elem) && elem.tagName === "A" && Boolean(elem.href);
|
|
772
|
+
}
|
|
773
773
|
var none = "none";
|
|
774
774
|
var triggerPress = "trigger-press";
|
|
775
775
|
var triggerHover = "trigger-hover";
|
|
@@ -811,6 +811,15 @@ function createChangeEventDetails(reason, event, trigger, customProperties) {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
export {
|
|
814
|
+
NOOP,
|
|
815
|
+
EMPTY_ARRAY,
|
|
816
|
+
EMPTY_OBJECT,
|
|
817
|
+
useOnMount,
|
|
818
|
+
useRefWithInit,
|
|
819
|
+
useIsoLayoutEffect,
|
|
820
|
+
formatErrorMessage,
|
|
821
|
+
isReactVersionAtLeast,
|
|
822
|
+
useStableCallback,
|
|
814
823
|
getNodeName,
|
|
815
824
|
getWindow,
|
|
816
825
|
getDocumentElement,
|
|
@@ -830,32 +839,23 @@ export {
|
|
|
830
839
|
getParentNode,
|
|
831
840
|
getOverflowAncestors,
|
|
832
841
|
getFrameElement,
|
|
833
|
-
useRefWithInit,
|
|
834
|
-
useStableCallback,
|
|
835
|
-
useIsoLayoutEffect,
|
|
836
|
-
mergeProps,
|
|
837
|
-
formatErrorMessage,
|
|
838
|
-
CompositeRootContext,
|
|
839
|
-
useCompositeRootContext,
|
|
840
|
-
dispatchClickWithModifiers,
|
|
841
|
-
useButton,
|
|
842
|
-
useMergedRefs,
|
|
843
|
-
isReactVersionAtLeast,
|
|
844
|
-
NOOP,
|
|
845
|
-
EMPTY_ARRAY,
|
|
846
|
-
EMPTY_OBJECT,
|
|
847
|
-
resolveStyle,
|
|
848
|
-
useRenderElement,
|
|
849
|
-
useOnMount,
|
|
850
842
|
addEventListener,
|
|
851
843
|
AnimationFrame,
|
|
852
844
|
useAnimationFrame,
|
|
845
|
+
useMergedRefs,
|
|
846
|
+
resolveStyle,
|
|
847
|
+
mergeProps,
|
|
848
|
+
useRenderElement,
|
|
853
849
|
TransitionStatusDataAttributes,
|
|
854
850
|
transitionStatusMapping,
|
|
855
851
|
resolveRef,
|
|
856
852
|
useAnimationsFinished,
|
|
857
853
|
useOpenChangeComplete,
|
|
858
854
|
useId$1,
|
|
855
|
+
CompositeRootContext,
|
|
856
|
+
useCompositeRootContext,
|
|
857
|
+
dispatchClickWithModifiers,
|
|
858
|
+
useButton,
|
|
859
859
|
none,
|
|
860
860
|
triggerPress,
|
|
861
861
|
triggerHover,
|