msw-dev-tool 1.1.10 → 1.1.12
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/README.md +19 -4
- package/dist/cjs/index.js +1700 -304
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/msw-dev-tool.css +1 -1
- package/dist/esm/index.js +1701 -306
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/msw-dev-tool.css +1 -1
- package/dist/types/index.d.ts +43 -2
- package/package.json +2 -1
package/dist/esm/index.js
CHANGED
@@ -3,8 +3,9 @@ import React__default, { useState, useLayoutEffect, useEffect, useMemo, forwardR
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
4
4
|
import * as ReactDOM from 'react-dom';
|
5
5
|
import ReactDOM__default from 'react-dom';
|
6
|
+
import { setupWorker } from 'msw/browser';
|
6
7
|
import { create } from 'zustand';
|
7
|
-
import { http, matchRequestUrl } from 'msw';
|
8
|
+
import { http, delay, HttpResponse, matchRequestUrl } from 'msw';
|
8
9
|
|
9
10
|
// packages/react/compose-refs/src/composeRefs.tsx
|
10
11
|
function setRef$1(ref, value) {
|
@@ -259,6 +260,67 @@ function composeContextScopes(...scopes) {
|
|
259
260
|
return createScope;
|
260
261
|
}
|
261
262
|
|
263
|
+
function createCollection(name) {
|
264
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
265
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
266
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
|
267
|
+
PROVIDER_NAME,
|
268
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
269
|
+
);
|
270
|
+
const CollectionProvider = (props) => {
|
271
|
+
const { scope, children } = props;
|
272
|
+
const ref = React__default.useRef(null);
|
273
|
+
const itemMap = React__default.useRef(/* @__PURE__ */ new Map()).current;
|
274
|
+
return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
275
|
+
};
|
276
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
277
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
278
|
+
const CollectionSlot = React__default.forwardRef(
|
279
|
+
(props, forwardedRef) => {
|
280
|
+
const { scope, children } = props;
|
281
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
282
|
+
const composedRefs = useComposedRefs$1(forwardedRef, context.collectionRef);
|
283
|
+
return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });
|
284
|
+
}
|
285
|
+
);
|
286
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
287
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
288
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
289
|
+
const CollectionItemSlot = React__default.forwardRef(
|
290
|
+
(props, forwardedRef) => {
|
291
|
+
const { scope, children, ...itemData } = props;
|
292
|
+
const ref = React__default.useRef(null);
|
293
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref);
|
294
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
295
|
+
React__default.useEffect(() => {
|
296
|
+
context.itemMap.set(ref, { ref, ...itemData });
|
297
|
+
return () => void context.itemMap.delete(ref);
|
298
|
+
});
|
299
|
+
return /* @__PURE__ */ jsx(Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
300
|
+
}
|
301
|
+
);
|
302
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
303
|
+
function useCollection(scope) {
|
304
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
305
|
+
const getItems = React__default.useCallback(() => {
|
306
|
+
const collectionNode = context.collectionRef.current;
|
307
|
+
if (!collectionNode) return [];
|
308
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
309
|
+
const items = Array.from(context.itemMap.values());
|
310
|
+
const orderedItems = items.sort(
|
311
|
+
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
312
|
+
);
|
313
|
+
return orderedItems;
|
314
|
+
}, [context.collectionRef, context.itemMap]);
|
315
|
+
return getItems;
|
316
|
+
}
|
317
|
+
return [
|
318
|
+
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
319
|
+
useCollection,
|
320
|
+
createCollectionScope
|
321
|
+
];
|
322
|
+
}
|
323
|
+
|
262
324
|
// packages/core/primitive/src/primitive.tsx
|
263
325
|
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
264
326
|
return function handleEvent(event) {
|
@@ -888,7 +950,7 @@ function removeLinks(items) {
|
|
888
950
|
return items.filter((item) => item.tagName !== "A");
|
889
951
|
}
|
890
952
|
|
891
|
-
var PORTAL_NAME$
|
953
|
+
var PORTAL_NAME$3 = "Portal";
|
892
954
|
var Portal$2 = React.forwardRef((props, forwardedRef) => {
|
893
955
|
const { container: containerProp, ...portalProps } = props;
|
894
956
|
const [mounted, setMounted] = React.useState(false);
|
@@ -896,7 +958,7 @@ var Portal$2 = React.forwardRef((props, forwardedRef) => {
|
|
896
958
|
const container = containerProp || mounted && globalThis?.document?.body;
|
897
959
|
return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
898
960
|
});
|
899
|
-
Portal$2.displayName = PORTAL_NAME$
|
961
|
+
Portal$2.displayName = PORTAL_NAME$3;
|
900
962
|
|
901
963
|
var count$1 = 0;
|
902
964
|
function useFocusGuards() {
|
@@ -1851,11 +1913,11 @@ var Dialog = (props) => {
|
|
1851
1913
|
);
|
1852
1914
|
};
|
1853
1915
|
Dialog.displayName = DIALOG_NAME;
|
1854
|
-
var TRIGGER_NAME$
|
1916
|
+
var TRIGGER_NAME$2 = "DialogTrigger";
|
1855
1917
|
var DialogTrigger = React.forwardRef(
|
1856
1918
|
(props, forwardedRef) => {
|
1857
1919
|
const { __scopeDialog, ...triggerProps } = props;
|
1858
|
-
const context = useDialogContext(TRIGGER_NAME$
|
1920
|
+
const context = useDialogContext(TRIGGER_NAME$2, __scopeDialog);
|
1859
1921
|
const composedTriggerRef = useComposedRefs$1(forwardedRef, context.triggerRef);
|
1860
1922
|
return /* @__PURE__ */ jsx(
|
1861
1923
|
Primitive.button,
|
@@ -1872,17 +1934,17 @@ var DialogTrigger = React.forwardRef(
|
|
1872
1934
|
);
|
1873
1935
|
}
|
1874
1936
|
);
|
1875
|
-
DialogTrigger.displayName = TRIGGER_NAME$
|
1876
|
-
var PORTAL_NAME$
|
1877
|
-
var [PortalProvider$1, usePortalContext$1] = createDialogContext(PORTAL_NAME$
|
1937
|
+
DialogTrigger.displayName = TRIGGER_NAME$2;
|
1938
|
+
var PORTAL_NAME$2 = "DialogPortal";
|
1939
|
+
var [PortalProvider$1, usePortalContext$1] = createDialogContext(PORTAL_NAME$2, {
|
1878
1940
|
forceMount: void 0
|
1879
1941
|
});
|
1880
1942
|
var DialogPortal = (props) => {
|
1881
1943
|
const { __scopeDialog, forceMount, children, container } = props;
|
1882
|
-
const context = useDialogContext(PORTAL_NAME$
|
1944
|
+
const context = useDialogContext(PORTAL_NAME$2, __scopeDialog);
|
1883
1945
|
return /* @__PURE__ */ jsx(PortalProvider$1, { scope: __scopeDialog, forceMount, children: React.Children.map(children, (child) => /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$2, { asChild: true, container, children: child }) })) });
|
1884
1946
|
};
|
1885
|
-
DialogPortal.displayName = PORTAL_NAME$
|
1947
|
+
DialogPortal.displayName = PORTAL_NAME$2;
|
1886
1948
|
var OVERLAY_NAME = "DialogOverlay";
|
1887
1949
|
var DialogOverlay = React.forwardRef(
|
1888
1950
|
(props, forwardedRef) => {
|
@@ -1912,19 +1974,19 @@ var DialogOverlayImpl = React.forwardRef(
|
|
1912
1974
|
);
|
1913
1975
|
}
|
1914
1976
|
);
|
1915
|
-
var CONTENT_NAME$
|
1977
|
+
var CONTENT_NAME$3 = "DialogContent";
|
1916
1978
|
var DialogContent = React.forwardRef(
|
1917
1979
|
(props, forwardedRef) => {
|
1918
|
-
const portalContext = usePortalContext$1(CONTENT_NAME$
|
1980
|
+
const portalContext = usePortalContext$1(CONTENT_NAME$3, props.__scopeDialog);
|
1919
1981
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
1920
|
-
const context = useDialogContext(CONTENT_NAME$
|
1982
|
+
const context = useDialogContext(CONTENT_NAME$3, props.__scopeDialog);
|
1921
1983
|
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
1922
1984
|
}
|
1923
1985
|
);
|
1924
|
-
DialogContent.displayName = CONTENT_NAME$
|
1986
|
+
DialogContent.displayName = CONTENT_NAME$3;
|
1925
1987
|
var DialogContentModal = React.forwardRef(
|
1926
1988
|
(props, forwardedRef) => {
|
1927
|
-
const context = useDialogContext(CONTENT_NAME$
|
1989
|
+
const context = useDialogContext(CONTENT_NAME$3, props.__scopeDialog);
|
1928
1990
|
const contentRef = React.useRef(null);
|
1929
1991
|
const composedRefs = useComposedRefs$1(forwardedRef, context.contentRef, contentRef);
|
1930
1992
|
React.useEffect(() => {
|
@@ -1958,7 +2020,7 @@ var DialogContentModal = React.forwardRef(
|
|
1958
2020
|
);
|
1959
2021
|
var DialogContentNonModal = React.forwardRef(
|
1960
2022
|
(props, forwardedRef) => {
|
1961
|
-
const context = useDialogContext(CONTENT_NAME$
|
2023
|
+
const context = useDialogContext(CONTENT_NAME$3, props.__scopeDialog);
|
1962
2024
|
const hasInteractedOutsideRef = React.useRef(false);
|
1963
2025
|
const hasPointerDownOutsideRef = React.useRef(false);
|
1964
2026
|
return /* @__PURE__ */ jsx(
|
@@ -1999,7 +2061,7 @@ var DialogContentNonModal = React.forwardRef(
|
|
1999
2061
|
var DialogContentImpl = React.forwardRef(
|
2000
2062
|
(props, forwardedRef) => {
|
2001
2063
|
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
2002
|
-
const context = useDialogContext(CONTENT_NAME$
|
2064
|
+
const context = useDialogContext(CONTENT_NAME$3, __scopeDialog);
|
2003
2065
|
const contentRef = React.useRef(null);
|
2004
2066
|
const composedRefs = useComposedRefs$1(forwardedRef, contentRef);
|
2005
2067
|
useFocusGuards();
|
@@ -2074,7 +2136,7 @@ function getState(open) {
|
|
2074
2136
|
}
|
2075
2137
|
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
2076
2138
|
var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
|
2077
|
-
contentName: CONTENT_NAME$
|
2139
|
+
contentName: CONTENT_NAME$3,
|
2078
2140
|
titleName: TITLE_NAME,
|
2079
2141
|
docsSlug: "dialog"
|
2080
2142
|
});
|
@@ -2115,6 +2177,18 @@ var Title = DialogTitle;
|
|
2115
2177
|
var Description = DialogDescription;
|
2116
2178
|
var Close = DialogClose;
|
2117
2179
|
|
2180
|
+
// packages/react/use-previous/src/usePrevious.tsx
|
2181
|
+
function usePrevious(value) {
|
2182
|
+
const ref = React.useRef({ value, previous: value });
|
2183
|
+
return React.useMemo(() => {
|
2184
|
+
if (ref.current.value !== value) {
|
2185
|
+
ref.current.previous = ref.current.value;
|
2186
|
+
ref.current.value = value;
|
2187
|
+
}
|
2188
|
+
return ref.current.previous;
|
2189
|
+
}, [value]);
|
2190
|
+
}
|
2191
|
+
|
2118
2192
|
// packages/react/use-size/src/useSize.tsx
|
2119
2193
|
function useSize(element) {
|
2120
2194
|
const [size, setSize] = React.useState(void 0);
|
@@ -4326,6 +4400,12 @@ var Root$2 = Arrow$1;
|
|
4326
4400
|
var POPPER_NAME = "Popper";
|
4327
4401
|
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
4328
4402
|
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
4403
|
+
var Popper = (props) => {
|
4404
|
+
const { __scopePopper, children } = props;
|
4405
|
+
const [anchor, setAnchor] = React.useState(null);
|
4406
|
+
return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
4407
|
+
};
|
4408
|
+
Popper.displayName = POPPER_NAME;
|
4329
4409
|
var ANCHOR_NAME = "PopperAnchor";
|
4330
4410
|
var PopperAnchor = React.forwardRef(
|
4331
4411
|
(props, forwardedRef) => {
|
@@ -4340,8 +4420,8 @@ var PopperAnchor = React.forwardRef(
|
|
4340
4420
|
}
|
4341
4421
|
);
|
4342
4422
|
PopperAnchor.displayName = ANCHOR_NAME;
|
4343
|
-
var CONTENT_NAME$
|
4344
|
-
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$
|
4423
|
+
var CONTENT_NAME$2 = "PopperContent";
|
4424
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$2);
|
4345
4425
|
var PopperContent = React.forwardRef(
|
4346
4426
|
(props, forwardedRef) => {
|
4347
4427
|
const {
|
@@ -4360,7 +4440,7 @@ var PopperContent = React.forwardRef(
|
|
4360
4440
|
onPlaced,
|
4361
4441
|
...contentProps
|
4362
4442
|
} = props;
|
4363
|
-
const context = usePopperContext(CONTENT_NAME$
|
4443
|
+
const context = usePopperContext(CONTENT_NAME$2, __scopePopper);
|
4364
4444
|
const [content, setContent] = React.useState(null);
|
4365
4445
|
const composedRefs = useComposedRefs$1(forwardedRef, (node) => setContent(node));
|
4366
4446
|
const [arrow$1, setArrow] = React.useState(null);
|
@@ -4483,8 +4563,8 @@ var PopperContent = React.forwardRef(
|
|
4483
4563
|
);
|
4484
4564
|
}
|
4485
4565
|
);
|
4486
|
-
PopperContent.displayName = CONTENT_NAME$
|
4487
|
-
var ARROW_NAME$
|
4566
|
+
PopperContent.displayName = CONTENT_NAME$2;
|
4567
|
+
var ARROW_NAME$2 = "PopperArrow";
|
4488
4568
|
var OPPOSITE_SIDE = {
|
4489
4569
|
top: "bottom",
|
4490
4570
|
right: "left",
|
@@ -4493,7 +4573,7 @@ var OPPOSITE_SIDE = {
|
|
4493
4573
|
};
|
4494
4574
|
var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
4495
4575
|
const { __scopePopper, ...arrowProps } = props;
|
4496
|
-
const contentContext = useContentContext(ARROW_NAME$
|
4576
|
+
const contentContext = useContentContext(ARROW_NAME$2, __scopePopper);
|
4497
4577
|
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
4498
4578
|
return (
|
4499
4579
|
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
@@ -4538,7 +4618,7 @@ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
4538
4618
|
)
|
4539
4619
|
);
|
4540
4620
|
});
|
4541
|
-
PopperArrow.displayName = ARROW_NAME$
|
4621
|
+
PopperArrow.displayName = ARROW_NAME$2;
|
4542
4622
|
function isNotNull(value) {
|
4543
4623
|
return value !== null;
|
4544
4624
|
}
|
@@ -4577,6 +4657,7 @@ function getSideAndAlignFromPlacement(placement) {
|
|
4577
4657
|
const [side, align = "center"] = placement.split("-");
|
4578
4658
|
return [side, align];
|
4579
4659
|
}
|
4660
|
+
var Root2 = Popper;
|
4580
4661
|
var Anchor = PopperAnchor;
|
4581
4662
|
var Content$1 = PopperContent;
|
4582
4663
|
var Arrow = PopperArrow;
|
@@ -4675,11 +4756,11 @@ var ScrollArea = React.forwardRef(
|
|
4675
4756
|
}
|
4676
4757
|
);
|
4677
4758
|
ScrollArea.displayName = SCROLL_AREA_NAME;
|
4678
|
-
var VIEWPORT_NAME = "ScrollAreaViewport";
|
4759
|
+
var VIEWPORT_NAME$1 = "ScrollAreaViewport";
|
4679
4760
|
var ScrollAreaViewport = React.forwardRef(
|
4680
4761
|
(props, forwardedRef) => {
|
4681
4762
|
const { __scopeScrollArea, children, nonce, ...viewportProps } = props;
|
4682
|
-
const context = useScrollAreaContext(VIEWPORT_NAME, __scopeScrollArea);
|
4763
|
+
const context = useScrollAreaContext(VIEWPORT_NAME$1, __scopeScrollArea);
|
4683
4764
|
const ref = React.useRef(null);
|
4684
4765
|
const composedRefs = useComposedRefs$1(forwardedRef, ref, context.onViewportChange);
|
4685
4766
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
@@ -4720,7 +4801,7 @@ var ScrollAreaViewport = React.forwardRef(
|
|
4720
4801
|
] });
|
4721
4802
|
}
|
4722
4803
|
);
|
4723
|
-
ScrollAreaViewport.displayName = VIEWPORT_NAME;
|
4804
|
+
ScrollAreaViewport.displayName = VIEWPORT_NAME$1;
|
4724
4805
|
var SCROLLBAR_NAME = "ScrollAreaScrollbar";
|
4725
4806
|
var ScrollAreaScrollbar = React.forwardRef(
|
4726
4807
|
(props, forwardedRef) => {
|
@@ -5311,213 +5392,1316 @@ var Scrollbar = ScrollAreaScrollbar;
|
|
5311
5392
|
var Thumb = ScrollAreaThumb;
|
5312
5393
|
var Corner = ScrollAreaCorner;
|
5313
5394
|
|
5314
|
-
var [
|
5395
|
+
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
5396
|
+
var SELECTION_KEYS = [" ", "Enter"];
|
5397
|
+
var SELECT_NAME = "Select";
|
5398
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
|
5399
|
+
var [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
|
5400
|
+
createCollectionScope,
|
5315
5401
|
createPopperScope
|
5316
5402
|
]);
|
5317
|
-
var usePopperScope = createPopperScope();
|
5318
|
-
var
|
5319
|
-
var
|
5320
|
-
var
|
5321
|
-
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
5322
|
-
var TooltipProvider = (props) => {
|
5403
|
+
var usePopperScope$1 = createPopperScope();
|
5404
|
+
var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
5405
|
+
var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
5406
|
+
var Select = (props) => {
|
5323
5407
|
const {
|
5324
|
-
|
5325
|
-
|
5326
|
-
|
5327
|
-
|
5328
|
-
|
5408
|
+
__scopeSelect,
|
5409
|
+
children,
|
5410
|
+
open: openProp,
|
5411
|
+
defaultOpen,
|
5412
|
+
onOpenChange,
|
5413
|
+
value: valueProp,
|
5414
|
+
defaultValue,
|
5415
|
+
onValueChange,
|
5416
|
+
dir,
|
5417
|
+
name,
|
5418
|
+
autoComplete,
|
5419
|
+
disabled,
|
5420
|
+
required,
|
5421
|
+
form
|
5329
5422
|
} = props;
|
5330
|
-
const
|
5331
|
-
const
|
5332
|
-
const
|
5333
|
-
React.
|
5334
|
-
|
5335
|
-
|
5336
|
-
|
5337
|
-
|
5338
|
-
|
5423
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
5424
|
+
const [trigger, setTrigger] = React.useState(null);
|
5425
|
+
const [valueNode, setValueNode] = React.useState(null);
|
5426
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
5427
|
+
const direction = useDirection(dir);
|
5428
|
+
const [open = false, setOpen] = useControllableState$1({
|
5429
|
+
prop: openProp,
|
5430
|
+
defaultProp: defaultOpen,
|
5431
|
+
onChange: onOpenChange
|
5432
|
+
});
|
5433
|
+
const [value, setValue] = useControllableState$1({
|
5434
|
+
prop: valueProp,
|
5435
|
+
defaultProp: defaultValue,
|
5436
|
+
onChange: onValueChange
|
5437
|
+
});
|
5438
|
+
const triggerPointerDownPosRef = React.useRef(null);
|
5439
|
+
const isFormControl = trigger ? form || !!trigger.closest("form") : true;
|
5440
|
+
const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
|
5441
|
+
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
5442
|
+
return /* @__PURE__ */ jsx(Root2, { ...popperScope, children: /* @__PURE__ */ jsxs(
|
5443
|
+
SelectProvider,
|
5339
5444
|
{
|
5340
|
-
|
5341
|
-
|
5342
|
-
|
5343
|
-
|
5344
|
-
|
5345
|
-
|
5346
|
-
|
5347
|
-
|
5348
|
-
|
5349
|
-
|
5350
|
-
|
5351
|
-
|
5352
|
-
|
5353
|
-
|
5354
|
-
|
5355
|
-
|
5356
|
-
|
5357
|
-
|
5358
|
-
|
5359
|
-
|
5445
|
+
required,
|
5446
|
+
scope: __scopeSelect,
|
5447
|
+
trigger,
|
5448
|
+
onTriggerChange: setTrigger,
|
5449
|
+
valueNode,
|
5450
|
+
onValueNodeChange: setValueNode,
|
5451
|
+
valueNodeHasChildren,
|
5452
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
5453
|
+
contentId: useId(),
|
5454
|
+
value,
|
5455
|
+
onValueChange: setValue,
|
5456
|
+
open,
|
5457
|
+
onOpenChange: setOpen,
|
5458
|
+
dir: direction,
|
5459
|
+
triggerPointerDownPosRef,
|
5460
|
+
disabled,
|
5461
|
+
children: [
|
5462
|
+
/* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
|
5463
|
+
SelectNativeOptionsProvider,
|
5464
|
+
{
|
5465
|
+
scope: props.__scopeSelect,
|
5466
|
+
onNativeOptionAdd: React.useCallback((option) => {
|
5467
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
5468
|
+
}, []),
|
5469
|
+
onNativeOptionRemove: React.useCallback((option) => {
|
5470
|
+
setNativeOptionsSet((prev) => {
|
5471
|
+
const optionsSet = new Set(prev);
|
5472
|
+
optionsSet.delete(option);
|
5473
|
+
return optionsSet;
|
5474
|
+
});
|
5475
|
+
}, []),
|
5476
|
+
children
|
5477
|
+
}
|
5478
|
+
) }),
|
5479
|
+
isFormControl ? /* @__PURE__ */ jsxs(
|
5480
|
+
BubbleSelect,
|
5481
|
+
{
|
5482
|
+
"aria-hidden": true,
|
5483
|
+
required,
|
5484
|
+
tabIndex: -1,
|
5485
|
+
name,
|
5486
|
+
autoComplete,
|
5487
|
+
value,
|
5488
|
+
onChange: (event) => setValue(event.target.value),
|
5489
|
+
disabled,
|
5490
|
+
form,
|
5491
|
+
children: [
|
5492
|
+
value === void 0 ? /* @__PURE__ */ jsx("option", { value: "" }) : null,
|
5493
|
+
Array.from(nativeOptionsSet)
|
5494
|
+
]
|
5495
|
+
},
|
5496
|
+
nativeSelectKey
|
5497
|
+
) : null
|
5498
|
+
]
|
5360
5499
|
}
|
5361
|
-
);
|
5500
|
+
) });
|
5362
5501
|
};
|
5363
|
-
|
5364
|
-
var
|
5365
|
-
var
|
5366
|
-
var TRIGGER_NAME = "TooltipTrigger";
|
5367
|
-
var TooltipTrigger = React.forwardRef(
|
5502
|
+
Select.displayName = SELECT_NAME;
|
5503
|
+
var TRIGGER_NAME$1 = "SelectTrigger";
|
5504
|
+
var SelectTrigger = React.forwardRef(
|
5368
5505
|
(props, forwardedRef) => {
|
5369
|
-
const {
|
5370
|
-
const
|
5371
|
-
const
|
5372
|
-
const
|
5373
|
-
const
|
5374
|
-
const
|
5375
|
-
const
|
5376
|
-
const
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5380
|
-
|
5506
|
+
const { __scopeSelect, disabled = false, ...triggerProps } = props;
|
5507
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
5508
|
+
const context = useSelectContext(TRIGGER_NAME$1, __scopeSelect);
|
5509
|
+
const isDisabled = context.disabled || disabled;
|
5510
|
+
const composedRefs = useComposedRefs$1(forwardedRef, context.onTriggerChange);
|
5511
|
+
const getItems = useCollection(__scopeSelect);
|
5512
|
+
const pointerTypeRef = React.useRef("touch");
|
5513
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
|
5514
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
5515
|
+
const currentItem = enabledItems.find((item) => item.value === context.value);
|
5516
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
5517
|
+
if (nextItem !== void 0) {
|
5518
|
+
context.onValueChange(nextItem.value);
|
5519
|
+
}
|
5520
|
+
});
|
5521
|
+
const handleOpen = (pointerEvent) => {
|
5522
|
+
if (!isDisabled) {
|
5523
|
+
context.onOpenChange(true);
|
5524
|
+
resetTypeahead();
|
5525
|
+
}
|
5526
|
+
if (pointerEvent) {
|
5527
|
+
context.triggerPointerDownPosRef.current = {
|
5528
|
+
x: Math.round(pointerEvent.pageX),
|
5529
|
+
y: Math.round(pointerEvent.pageY)
|
5530
|
+
};
|
5531
|
+
}
|
5532
|
+
};
|
5381
5533
|
return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
|
5382
5534
|
Primitive.button,
|
5383
5535
|
{
|
5384
|
-
"
|
5385
|
-
"
|
5536
|
+
type: "button",
|
5537
|
+
role: "combobox",
|
5538
|
+
"aria-controls": context.contentId,
|
5539
|
+
"aria-expanded": context.open,
|
5540
|
+
"aria-required": context.required,
|
5541
|
+
"aria-autocomplete": "none",
|
5542
|
+
dir: context.dir,
|
5543
|
+
"data-state": context.open ? "open" : "closed",
|
5544
|
+
disabled: isDisabled,
|
5545
|
+
"data-disabled": isDisabled ? "" : void 0,
|
5546
|
+
"data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
|
5386
5547
|
...triggerProps,
|
5387
5548
|
ref: composedRefs,
|
5388
|
-
|
5389
|
-
|
5390
|
-
if (
|
5391
|
-
|
5392
|
-
hasPointerMoveOpenedRef.current = true;
|
5549
|
+
onClick: composeEventHandlers(triggerProps.onClick, (event) => {
|
5550
|
+
event.currentTarget.focus();
|
5551
|
+
if (pointerTypeRef.current !== "mouse") {
|
5552
|
+
handleOpen(event);
|
5393
5553
|
}
|
5394
5554
|
}),
|
5395
|
-
|
5396
|
-
|
5397
|
-
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
|
5555
|
+
onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
|
5556
|
+
pointerTypeRef.current = event.pointerType;
|
5557
|
+
const target = event.target;
|
5558
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
5559
|
+
target.releasePointerCapture(event.pointerId);
|
5560
|
+
}
|
5561
|
+
if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
|
5562
|
+
handleOpen(event);
|
5563
|
+
event.preventDefault();
|
5564
|
+
}
|
5405
5565
|
}),
|
5406
|
-
|
5407
|
-
|
5566
|
+
onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
|
5567
|
+
const isTypingAhead = searchRef.current !== "";
|
5568
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
5569
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
5570
|
+
if (isTypingAhead && event.key === " ") return;
|
5571
|
+
if (OPEN_KEYS.includes(event.key)) {
|
5572
|
+
handleOpen();
|
5573
|
+
event.preventDefault();
|
5574
|
+
}
|
5575
|
+
})
|
5408
5576
|
}
|
5409
5577
|
) });
|
5410
5578
|
}
|
5411
5579
|
);
|
5412
|
-
|
5413
|
-
var
|
5414
|
-
var
|
5415
|
-
forceMount: void 0
|
5416
|
-
});
|
5417
|
-
var CONTENT_NAME = "TooltipContent";
|
5418
|
-
var TooltipContent = React.forwardRef(
|
5580
|
+
SelectTrigger.displayName = TRIGGER_NAME$1;
|
5581
|
+
var VALUE_NAME = "SelectValue";
|
5582
|
+
var SelectValue = React.forwardRef(
|
5419
5583
|
(props, forwardedRef) => {
|
5420
|
-
const
|
5421
|
-
const
|
5422
|
-
const
|
5423
|
-
|
5584
|
+
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
5585
|
+
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
5586
|
+
const { onValueNodeHasChildrenChange } = context;
|
5587
|
+
const hasChildren = children !== void 0;
|
5588
|
+
const composedRefs = useComposedRefs$1(forwardedRef, context.onValueNodeChange);
|
5589
|
+
useLayoutEffect2(() => {
|
5590
|
+
onValueNodeHasChildrenChange(hasChildren);
|
5591
|
+
}, [onValueNodeHasChildrenChange, hasChildren]);
|
5592
|
+
return /* @__PURE__ */ jsx(
|
5593
|
+
Primitive.span,
|
5594
|
+
{
|
5595
|
+
...valueProps,
|
5596
|
+
ref: composedRefs,
|
5597
|
+
style: { pointerEvents: "none" },
|
5598
|
+
children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsx(Fragment, { children: placeholder }) : children
|
5599
|
+
}
|
5600
|
+
);
|
5424
5601
|
}
|
5425
5602
|
);
|
5426
|
-
|
5427
|
-
|
5428
|
-
|
5429
|
-
|
5430
|
-
|
5431
|
-
|
5432
|
-
|
5433
|
-
|
5434
|
-
|
5435
|
-
|
5436
|
-
|
5437
|
-
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5443
|
-
|
5444
|
-
|
5445
|
-
|
5446
|
-
|
5447
|
-
|
5448
|
-
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
}, [handleRemoveGraceArea]);
|
5455
|
-
React.useEffect(() => {
|
5456
|
-
if (trigger && content) {
|
5457
|
-
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
5458
|
-
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
5459
|
-
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
5460
|
-
content.addEventListener("pointerleave", handleContentLeave);
|
5461
|
-
return () => {
|
5462
|
-
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
5463
|
-
content.removeEventListener("pointerleave", handleContentLeave);
|
5464
|
-
};
|
5465
|
-
}
|
5466
|
-
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
5467
|
-
React.useEffect(() => {
|
5468
|
-
if (pointerGraceArea) {
|
5469
|
-
const handleTrackPointerGrace = (event) => {
|
5470
|
-
const target = event.target;
|
5471
|
-
const pointerPosition = { x: event.clientX, y: event.clientY };
|
5472
|
-
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
5473
|
-
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
5474
|
-
if (hasEnteredTarget) {
|
5475
|
-
handleRemoveGraceArea();
|
5476
|
-
} else if (isPointerOutsideGraceArea) {
|
5477
|
-
handleRemoveGraceArea();
|
5478
|
-
onClose();
|
5479
|
-
}
|
5480
|
-
};
|
5481
|
-
document.addEventListener("pointermove", handleTrackPointerGrace);
|
5482
|
-
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
5603
|
+
SelectValue.displayName = VALUE_NAME;
|
5604
|
+
var ICON_NAME = "SelectIcon";
|
5605
|
+
var SelectIcon = React.forwardRef(
|
5606
|
+
(props, forwardedRef) => {
|
5607
|
+
const { __scopeSelect, children, ...iconProps } = props;
|
5608
|
+
return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
|
5609
|
+
}
|
5610
|
+
);
|
5611
|
+
SelectIcon.displayName = ICON_NAME;
|
5612
|
+
var PORTAL_NAME$1 = "SelectPortal";
|
5613
|
+
var SelectPortal = (props) => {
|
5614
|
+
return /* @__PURE__ */ jsx(Portal$2, { asChild: true, ...props });
|
5615
|
+
};
|
5616
|
+
SelectPortal.displayName = PORTAL_NAME$1;
|
5617
|
+
var CONTENT_NAME$1 = "SelectContent";
|
5618
|
+
var SelectContent = React.forwardRef(
|
5619
|
+
(props, forwardedRef) => {
|
5620
|
+
const context = useSelectContext(CONTENT_NAME$1, props.__scopeSelect);
|
5621
|
+
const [fragment, setFragment] = React.useState();
|
5622
|
+
useLayoutEffect2(() => {
|
5623
|
+
setFragment(new DocumentFragment());
|
5624
|
+
}, []);
|
5625
|
+
if (!context.open) {
|
5626
|
+
const frag = fragment;
|
5627
|
+
return frag ? ReactDOM.createPortal(
|
5628
|
+
/* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
|
5629
|
+
frag
|
5630
|
+
) : null;
|
5483
5631
|
}
|
5484
|
-
|
5485
|
-
|
5486
|
-
|
5487
|
-
|
5488
|
-
var
|
5632
|
+
return /* @__PURE__ */ jsx(SelectContentImpl, { ...props, ref: forwardedRef });
|
5633
|
+
}
|
5634
|
+
);
|
5635
|
+
SelectContent.displayName = CONTENT_NAME$1;
|
5636
|
+
var CONTENT_MARGIN = 10;
|
5637
|
+
var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME$1);
|
5638
|
+
var CONTENT_IMPL_NAME = "SelectContentImpl";
|
5639
|
+
var SelectContentImpl = React.forwardRef(
|
5489
5640
|
(props, forwardedRef) => {
|
5490
5641
|
const {
|
5491
|
-
|
5492
|
-
|
5493
|
-
|
5642
|
+
__scopeSelect,
|
5643
|
+
position = "item-aligned",
|
5644
|
+
onCloseAutoFocus,
|
5494
5645
|
onEscapeKeyDown,
|
5495
5646
|
onPointerDownOutside,
|
5647
|
+
//
|
5648
|
+
// PopperContent props
|
5649
|
+
side,
|
5650
|
+
sideOffset,
|
5651
|
+
align,
|
5652
|
+
alignOffset,
|
5653
|
+
arrowPadding,
|
5654
|
+
collisionBoundary,
|
5655
|
+
collisionPadding,
|
5656
|
+
sticky,
|
5657
|
+
hideWhenDetached,
|
5658
|
+
avoidCollisions,
|
5659
|
+
//
|
5496
5660
|
...contentProps
|
5497
5661
|
} = props;
|
5498
|
-
const context =
|
5499
|
-
const
|
5500
|
-
const
|
5662
|
+
const context = useSelectContext(CONTENT_NAME$1, __scopeSelect);
|
5663
|
+
const [content, setContent] = React.useState(null);
|
5664
|
+
const [viewport, setViewport] = React.useState(null);
|
5665
|
+
const composedRefs = useComposedRefs$1(forwardedRef, (node) => setContent(node));
|
5666
|
+
const [selectedItem, setSelectedItem] = React.useState(null);
|
5667
|
+
const [selectedItemText, setSelectedItemText] = React.useState(
|
5668
|
+
null
|
5669
|
+
);
|
5670
|
+
const getItems = useCollection(__scopeSelect);
|
5671
|
+
const [isPositioned, setIsPositioned] = React.useState(false);
|
5672
|
+
const firstValidItemFoundRef = React.useRef(false);
|
5501
5673
|
React.useEffect(() => {
|
5502
|
-
|
5503
|
-
|
5504
|
-
|
5674
|
+
if (content) return hideOthers(content);
|
5675
|
+
}, [content]);
|
5676
|
+
useFocusGuards();
|
5677
|
+
const focusFirst = React.useCallback(
|
5678
|
+
(candidates) => {
|
5679
|
+
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
5680
|
+
const [lastItem] = restItems.slice(-1);
|
5681
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
5682
|
+
for (const candidate of candidates) {
|
5683
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
5684
|
+
candidate?.scrollIntoView({ block: "nearest" });
|
5685
|
+
if (candidate === firstItem && viewport) viewport.scrollTop = 0;
|
5686
|
+
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
5687
|
+
candidate?.focus();
|
5688
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
5689
|
+
}
|
5690
|
+
},
|
5691
|
+
[getItems, viewport]
|
5692
|
+
);
|
5693
|
+
const focusSelectedItem = React.useCallback(
|
5694
|
+
() => focusFirst([selectedItem, content]),
|
5695
|
+
[focusFirst, selectedItem, content]
|
5696
|
+
);
|
5505
5697
|
React.useEffect(() => {
|
5506
|
-
if (
|
5507
|
-
|
5508
|
-
const target = event.target;
|
5509
|
-
if (target?.contains(context.trigger)) onClose();
|
5510
|
-
};
|
5511
|
-
window.addEventListener("scroll", handleScroll, { capture: true });
|
5512
|
-
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
5698
|
+
if (isPositioned) {
|
5699
|
+
focusSelectedItem();
|
5513
5700
|
}
|
5514
|
-
}, [
|
5515
|
-
|
5516
|
-
|
5517
|
-
{
|
5518
|
-
|
5519
|
-
|
5520
|
-
|
5701
|
+
}, [isPositioned, focusSelectedItem]);
|
5702
|
+
const { onOpenChange, triggerPointerDownPosRef } = context;
|
5703
|
+
React.useEffect(() => {
|
5704
|
+
if (content) {
|
5705
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
5706
|
+
const handlePointerMove = (event) => {
|
5707
|
+
pointerMoveDelta = {
|
5708
|
+
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
5709
|
+
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
5710
|
+
};
|
5711
|
+
};
|
5712
|
+
const handlePointerUp = (event) => {
|
5713
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
5714
|
+
event.preventDefault();
|
5715
|
+
} else {
|
5716
|
+
if (!content.contains(event.target)) {
|
5717
|
+
onOpenChange(false);
|
5718
|
+
}
|
5719
|
+
}
|
5720
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
5721
|
+
triggerPointerDownPosRef.current = null;
|
5722
|
+
};
|
5723
|
+
if (triggerPointerDownPosRef.current !== null) {
|
5724
|
+
document.addEventListener("pointermove", handlePointerMove);
|
5725
|
+
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
5726
|
+
}
|
5727
|
+
return () => {
|
5728
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
5729
|
+
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
5730
|
+
};
|
5731
|
+
}
|
5732
|
+
}, [content, onOpenChange, triggerPointerDownPosRef]);
|
5733
|
+
React.useEffect(() => {
|
5734
|
+
const close = () => onOpenChange(false);
|
5735
|
+
window.addEventListener("blur", close);
|
5736
|
+
window.addEventListener("resize", close);
|
5737
|
+
return () => {
|
5738
|
+
window.removeEventListener("blur", close);
|
5739
|
+
window.removeEventListener("resize", close);
|
5740
|
+
};
|
5741
|
+
}, [onOpenChange]);
|
5742
|
+
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
|
5743
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
5744
|
+
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
5745
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
5746
|
+
if (nextItem) {
|
5747
|
+
setTimeout(() => nextItem.ref.current.focus());
|
5748
|
+
}
|
5749
|
+
});
|
5750
|
+
const itemRefCallback = React.useCallback(
|
5751
|
+
(node, value, disabled) => {
|
5752
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
5753
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
5754
|
+
if (isSelectedItem || isFirstValidItem) {
|
5755
|
+
setSelectedItem(node);
|
5756
|
+
if (isFirstValidItem) firstValidItemFoundRef.current = true;
|
5757
|
+
}
|
5758
|
+
},
|
5759
|
+
[context.value]
|
5760
|
+
);
|
5761
|
+
const handleItemLeave = React.useCallback(() => content?.focus(), [content]);
|
5762
|
+
const itemTextRefCallback = React.useCallback(
|
5763
|
+
(node, value, disabled) => {
|
5764
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
5765
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
5766
|
+
if (isSelectedItem || isFirstValidItem) {
|
5767
|
+
setSelectedItemText(node);
|
5768
|
+
}
|
5769
|
+
},
|
5770
|
+
[context.value]
|
5771
|
+
);
|
5772
|
+
const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
|
5773
|
+
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
5774
|
+
side,
|
5775
|
+
sideOffset,
|
5776
|
+
align,
|
5777
|
+
alignOffset,
|
5778
|
+
arrowPadding,
|
5779
|
+
collisionBoundary,
|
5780
|
+
collisionPadding,
|
5781
|
+
sticky,
|
5782
|
+
hideWhenDetached,
|
5783
|
+
avoidCollisions
|
5784
|
+
} : {};
|
5785
|
+
return /* @__PURE__ */ jsx(
|
5786
|
+
SelectContentProvider,
|
5787
|
+
{
|
5788
|
+
scope: __scopeSelect,
|
5789
|
+
content,
|
5790
|
+
viewport,
|
5791
|
+
onViewportChange: setViewport,
|
5792
|
+
itemRefCallback,
|
5793
|
+
selectedItem,
|
5794
|
+
onItemLeave: handleItemLeave,
|
5795
|
+
itemTextRefCallback,
|
5796
|
+
focusSelectedItem,
|
5797
|
+
selectedItemText,
|
5798
|
+
position,
|
5799
|
+
isPositioned,
|
5800
|
+
searchRef,
|
5801
|
+
children: /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
|
5802
|
+
FocusScope,
|
5803
|
+
{
|
5804
|
+
asChild: true,
|
5805
|
+
trapped: context.open,
|
5806
|
+
onMountAutoFocus: (event) => {
|
5807
|
+
event.preventDefault();
|
5808
|
+
},
|
5809
|
+
onUnmountAutoFocus: composeEventHandlers(onCloseAutoFocus, (event) => {
|
5810
|
+
context.trigger?.focus({ preventScroll: true });
|
5811
|
+
event.preventDefault();
|
5812
|
+
}),
|
5813
|
+
children: /* @__PURE__ */ jsx(
|
5814
|
+
DismissableLayer,
|
5815
|
+
{
|
5816
|
+
asChild: true,
|
5817
|
+
disableOutsidePointerEvents: true,
|
5818
|
+
onEscapeKeyDown,
|
5819
|
+
onPointerDownOutside,
|
5820
|
+
onFocusOutside: (event) => event.preventDefault(),
|
5821
|
+
onDismiss: () => context.onOpenChange(false),
|
5822
|
+
children: /* @__PURE__ */ jsx(
|
5823
|
+
SelectPosition,
|
5824
|
+
{
|
5825
|
+
role: "listbox",
|
5826
|
+
id: context.contentId,
|
5827
|
+
"data-state": context.open ? "open" : "closed",
|
5828
|
+
dir: context.dir,
|
5829
|
+
onContextMenu: (event) => event.preventDefault(),
|
5830
|
+
...contentProps,
|
5831
|
+
...popperContentProps,
|
5832
|
+
onPlaced: () => setIsPositioned(true),
|
5833
|
+
ref: composedRefs,
|
5834
|
+
style: {
|
5835
|
+
// flex layout so we can place the scroll buttons properly
|
5836
|
+
display: "flex",
|
5837
|
+
flexDirection: "column",
|
5838
|
+
// reset the outline by default as the content MAY get focused
|
5839
|
+
outline: "none",
|
5840
|
+
...contentProps.style
|
5841
|
+
},
|
5842
|
+
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
5843
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
5844
|
+
if (event.key === "Tab") event.preventDefault();
|
5845
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
5846
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
5847
|
+
const items = getItems().filter((item) => !item.disabled);
|
5848
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
5849
|
+
if (["ArrowUp", "End"].includes(event.key)) {
|
5850
|
+
candidateNodes = candidateNodes.slice().reverse();
|
5851
|
+
}
|
5852
|
+
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
5853
|
+
const currentElement = event.target;
|
5854
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
5855
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
5856
|
+
}
|
5857
|
+
setTimeout(() => focusFirst(candidateNodes));
|
5858
|
+
event.preventDefault();
|
5859
|
+
}
|
5860
|
+
})
|
5861
|
+
}
|
5862
|
+
)
|
5863
|
+
}
|
5864
|
+
)
|
5865
|
+
}
|
5866
|
+
) })
|
5867
|
+
}
|
5868
|
+
);
|
5869
|
+
}
|
5870
|
+
);
|
5871
|
+
SelectContentImpl.displayName = CONTENT_IMPL_NAME;
|
5872
|
+
var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
|
5873
|
+
var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
|
5874
|
+
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
5875
|
+
const context = useSelectContext(CONTENT_NAME$1, __scopeSelect);
|
5876
|
+
const contentContext = useSelectContentContext(CONTENT_NAME$1, __scopeSelect);
|
5877
|
+
const [contentWrapper, setContentWrapper] = React.useState(null);
|
5878
|
+
const [content, setContent] = React.useState(null);
|
5879
|
+
const composedRefs = useComposedRefs$1(forwardedRef, (node) => setContent(node));
|
5880
|
+
const getItems = useCollection(__scopeSelect);
|
5881
|
+
const shouldExpandOnScrollRef = React.useRef(false);
|
5882
|
+
const shouldRepositionRef = React.useRef(true);
|
5883
|
+
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
5884
|
+
const position = React.useCallback(() => {
|
5885
|
+
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
5886
|
+
const triggerRect = context.trigger.getBoundingClientRect();
|
5887
|
+
const contentRect = content.getBoundingClientRect();
|
5888
|
+
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
5889
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
5890
|
+
if (context.dir !== "rtl") {
|
5891
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
5892
|
+
const left = valueNodeRect.left - itemTextOffset;
|
5893
|
+
const leftDelta = triggerRect.left - left;
|
5894
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
5895
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
5896
|
+
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
5897
|
+
const clampedLeft = clamp(left, [
|
5898
|
+
CONTENT_MARGIN,
|
5899
|
+
// Prevents the content from going off the starting edge of the
|
5900
|
+
// viewport. It may still go off the ending edge, but this can be
|
5901
|
+
// controlled by the user since they may want to manage overflow in a
|
5902
|
+
// specific way.
|
5903
|
+
// https://github.com/radix-ui/primitives/issues/2049
|
5904
|
+
Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
|
5905
|
+
]);
|
5906
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
5907
|
+
contentWrapper.style.left = clampedLeft + "px";
|
5908
|
+
} else {
|
5909
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
5910
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
5911
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
5912
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
5913
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
5914
|
+
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
5915
|
+
const clampedRight = clamp(right, [
|
5916
|
+
CONTENT_MARGIN,
|
5917
|
+
Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
|
5918
|
+
]);
|
5919
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
5920
|
+
contentWrapper.style.right = clampedRight + "px";
|
5921
|
+
}
|
5922
|
+
const items = getItems();
|
5923
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
5924
|
+
const itemsHeight = viewport.scrollHeight;
|
5925
|
+
const contentStyles = window.getComputedStyle(content);
|
5926
|
+
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
5927
|
+
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
5928
|
+
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
5929
|
+
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
5930
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
5931
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
5932
|
+
const viewportStyles = window.getComputedStyle(viewport);
|
5933
|
+
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
5934
|
+
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
5935
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
5936
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
5937
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
5938
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
5939
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
5940
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
5941
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
5942
|
+
if (willAlignWithoutTopOverflow) {
|
5943
|
+
const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
|
5944
|
+
contentWrapper.style.bottom = "0px";
|
5945
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
5946
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(
|
5947
|
+
triggerMiddleToBottomEdge,
|
5948
|
+
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
5949
|
+
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
5950
|
+
);
|
5951
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
5952
|
+
contentWrapper.style.height = height + "px";
|
5953
|
+
} else {
|
5954
|
+
const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
|
5955
|
+
contentWrapper.style.top = "0px";
|
5956
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(
|
5957
|
+
topEdgeToTriggerMiddle,
|
5958
|
+
contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
5959
|
+
(isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
|
5960
|
+
);
|
5961
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
5962
|
+
contentWrapper.style.height = height + "px";
|
5963
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
5964
|
+
}
|
5965
|
+
contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
|
5966
|
+
contentWrapper.style.minHeight = minContentHeight + "px";
|
5967
|
+
contentWrapper.style.maxHeight = availableHeight + "px";
|
5968
|
+
onPlaced?.();
|
5969
|
+
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
5970
|
+
}
|
5971
|
+
}, [
|
5972
|
+
getItems,
|
5973
|
+
context.trigger,
|
5974
|
+
context.valueNode,
|
5975
|
+
contentWrapper,
|
5976
|
+
content,
|
5977
|
+
viewport,
|
5978
|
+
selectedItem,
|
5979
|
+
selectedItemText,
|
5980
|
+
context.dir,
|
5981
|
+
onPlaced
|
5982
|
+
]);
|
5983
|
+
useLayoutEffect2(() => position(), [position]);
|
5984
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
5985
|
+
useLayoutEffect2(() => {
|
5986
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
5987
|
+
}, [content]);
|
5988
|
+
const handleScrollButtonChange = React.useCallback(
|
5989
|
+
(node) => {
|
5990
|
+
if (node && shouldRepositionRef.current === true) {
|
5991
|
+
position();
|
5992
|
+
focusSelectedItem?.();
|
5993
|
+
shouldRepositionRef.current = false;
|
5994
|
+
}
|
5995
|
+
},
|
5996
|
+
[position, focusSelectedItem]
|
5997
|
+
);
|
5998
|
+
return /* @__PURE__ */ jsx(
|
5999
|
+
SelectViewportProvider,
|
6000
|
+
{
|
6001
|
+
scope: __scopeSelect,
|
6002
|
+
contentWrapper,
|
6003
|
+
shouldExpandOnScrollRef,
|
6004
|
+
onScrollButtonChange: handleScrollButtonChange,
|
6005
|
+
children: /* @__PURE__ */ jsx(
|
6006
|
+
"div",
|
6007
|
+
{
|
6008
|
+
ref: setContentWrapper,
|
6009
|
+
style: {
|
6010
|
+
display: "flex",
|
6011
|
+
flexDirection: "column",
|
6012
|
+
position: "fixed",
|
6013
|
+
zIndex: contentZIndex
|
6014
|
+
},
|
6015
|
+
children: /* @__PURE__ */ jsx(
|
6016
|
+
Primitive.div,
|
6017
|
+
{
|
6018
|
+
...popperProps,
|
6019
|
+
ref: composedRefs,
|
6020
|
+
style: {
|
6021
|
+
// When we get the height of the content, it includes borders. If we were to set
|
6022
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
6023
|
+
boxSizing: "border-box",
|
6024
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
6025
|
+
maxHeight: "100%",
|
6026
|
+
...popperProps.style
|
6027
|
+
}
|
6028
|
+
}
|
6029
|
+
)
|
6030
|
+
}
|
6031
|
+
)
|
6032
|
+
}
|
6033
|
+
);
|
6034
|
+
});
|
6035
|
+
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
6036
|
+
var POPPER_POSITION_NAME = "SelectPopperPosition";
|
6037
|
+
var SelectPopperPosition = React.forwardRef((props, forwardedRef) => {
|
6038
|
+
const {
|
6039
|
+
__scopeSelect,
|
6040
|
+
align = "start",
|
6041
|
+
collisionPadding = CONTENT_MARGIN,
|
6042
|
+
...popperProps
|
6043
|
+
} = props;
|
6044
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
6045
|
+
return /* @__PURE__ */ jsx(
|
6046
|
+
Content$1,
|
6047
|
+
{
|
6048
|
+
...popperScope,
|
6049
|
+
...popperProps,
|
6050
|
+
ref: forwardedRef,
|
6051
|
+
align,
|
6052
|
+
collisionPadding,
|
6053
|
+
style: {
|
6054
|
+
// Ensure border-box for floating-ui calculations
|
6055
|
+
boxSizing: "border-box",
|
6056
|
+
...popperProps.style,
|
6057
|
+
// re-namespace exposed content custom properties
|
6058
|
+
...{
|
6059
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
6060
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
6061
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
6062
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
6063
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
6064
|
+
}
|
6065
|
+
}
|
6066
|
+
}
|
6067
|
+
);
|
6068
|
+
});
|
6069
|
+
SelectPopperPosition.displayName = POPPER_POSITION_NAME;
|
6070
|
+
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME$1, {});
|
6071
|
+
var VIEWPORT_NAME = "SelectViewport";
|
6072
|
+
var SelectViewport = React.forwardRef(
|
6073
|
+
(props, forwardedRef) => {
|
6074
|
+
const { __scopeSelect, nonce, ...viewportProps } = props;
|
6075
|
+
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
|
6076
|
+
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
|
6077
|
+
const composedRefs = useComposedRefs$1(forwardedRef, contentContext.onViewportChange);
|
6078
|
+
const prevScrollTopRef = React.useRef(0);
|
6079
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
6080
|
+
/* @__PURE__ */ jsx(
|
6081
|
+
"style",
|
6082
|
+
{
|
6083
|
+
dangerouslySetInnerHTML: {
|
6084
|
+
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
|
6085
|
+
},
|
6086
|
+
nonce
|
6087
|
+
}
|
6088
|
+
),
|
6089
|
+
/* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
|
6090
|
+
Primitive.div,
|
6091
|
+
{
|
6092
|
+
"data-radix-select-viewport": "",
|
6093
|
+
role: "presentation",
|
6094
|
+
...viewportProps,
|
6095
|
+
ref: composedRefs,
|
6096
|
+
style: {
|
6097
|
+
// we use position: 'relative' here on the `viewport` so that when we call
|
6098
|
+
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
6099
|
+
// (independent of the scrollUpButton).
|
6100
|
+
position: "relative",
|
6101
|
+
flex: 1,
|
6102
|
+
// Viewport should only be scrollable in the vertical direction.
|
6103
|
+
// This won't work in vertical writing modes, so we'll need to
|
6104
|
+
// revisit this if/when that is supported
|
6105
|
+
// https://developer.chrome.com/blog/vertical-form-controls
|
6106
|
+
overflow: "hidden auto",
|
6107
|
+
...viewportProps.style
|
6108
|
+
},
|
6109
|
+
onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
|
6110
|
+
const viewport = event.currentTarget;
|
6111
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
6112
|
+
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
6113
|
+
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
6114
|
+
if (scrolledBy > 0) {
|
6115
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
6116
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
6117
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
6118
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
6119
|
+
if (prevHeight < availableHeight) {
|
6120
|
+
const nextHeight = prevHeight + scrolledBy;
|
6121
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
6122
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
6123
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
6124
|
+
if (contentWrapper.style.bottom === "0px") {
|
6125
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
6126
|
+
contentWrapper.style.justifyContent = "flex-end";
|
6127
|
+
}
|
6128
|
+
}
|
6129
|
+
}
|
6130
|
+
}
|
6131
|
+
prevScrollTopRef.current = viewport.scrollTop;
|
6132
|
+
})
|
6133
|
+
}
|
6134
|
+
) })
|
6135
|
+
] });
|
6136
|
+
}
|
6137
|
+
);
|
6138
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
6139
|
+
var GROUP_NAME = "SelectGroup";
|
6140
|
+
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
6141
|
+
var SelectGroup = React.forwardRef(
|
6142
|
+
(props, forwardedRef) => {
|
6143
|
+
const { __scopeSelect, ...groupProps } = props;
|
6144
|
+
const groupId = useId();
|
6145
|
+
return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
6146
|
+
}
|
6147
|
+
);
|
6148
|
+
SelectGroup.displayName = GROUP_NAME;
|
6149
|
+
var LABEL_NAME = "SelectLabel";
|
6150
|
+
var SelectLabel = React.forwardRef(
|
6151
|
+
(props, forwardedRef) => {
|
6152
|
+
const { __scopeSelect, ...labelProps } = props;
|
6153
|
+
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
6154
|
+
return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
6155
|
+
}
|
6156
|
+
);
|
6157
|
+
SelectLabel.displayName = LABEL_NAME;
|
6158
|
+
var ITEM_NAME = "SelectItem";
|
6159
|
+
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
6160
|
+
var SelectItem$1 = React.forwardRef(
|
6161
|
+
(props, forwardedRef) => {
|
6162
|
+
const {
|
6163
|
+
__scopeSelect,
|
6164
|
+
value,
|
6165
|
+
disabled = false,
|
6166
|
+
textValue: textValueProp,
|
6167
|
+
...itemProps
|
6168
|
+
} = props;
|
6169
|
+
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
6170
|
+
const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
|
6171
|
+
const isSelected = context.value === value;
|
6172
|
+
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
6173
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
6174
|
+
const composedRefs = useComposedRefs$1(
|
6175
|
+
forwardedRef,
|
6176
|
+
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
6177
|
+
);
|
6178
|
+
const textId = useId();
|
6179
|
+
const pointerTypeRef = React.useRef("touch");
|
6180
|
+
const handleSelect = () => {
|
6181
|
+
if (!disabled) {
|
6182
|
+
context.onValueChange(value);
|
6183
|
+
context.onOpenChange(false);
|
6184
|
+
}
|
6185
|
+
};
|
6186
|
+
if (value === "") {
|
6187
|
+
throw new Error(
|
6188
|
+
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
|
6189
|
+
);
|
6190
|
+
}
|
6191
|
+
return /* @__PURE__ */ jsx(
|
6192
|
+
SelectItemContextProvider,
|
6193
|
+
{
|
6194
|
+
scope: __scopeSelect,
|
6195
|
+
value,
|
6196
|
+
disabled,
|
6197
|
+
textId,
|
6198
|
+
isSelected,
|
6199
|
+
onItemTextChange: React.useCallback((node) => {
|
6200
|
+
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
6201
|
+
}, []),
|
6202
|
+
children: /* @__PURE__ */ jsx(
|
6203
|
+
Collection.ItemSlot,
|
6204
|
+
{
|
6205
|
+
scope: __scopeSelect,
|
6206
|
+
value,
|
6207
|
+
disabled,
|
6208
|
+
textValue,
|
6209
|
+
children: /* @__PURE__ */ jsx(
|
6210
|
+
Primitive.div,
|
6211
|
+
{
|
6212
|
+
role: "option",
|
6213
|
+
"aria-labelledby": textId,
|
6214
|
+
"data-highlighted": isFocused ? "" : void 0,
|
6215
|
+
"aria-selected": isSelected && isFocused,
|
6216
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
6217
|
+
"aria-disabled": disabled || void 0,
|
6218
|
+
"data-disabled": disabled ? "" : void 0,
|
6219
|
+
tabIndex: disabled ? void 0 : -1,
|
6220
|
+
...itemProps,
|
6221
|
+
ref: composedRefs,
|
6222
|
+
onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
|
6223
|
+
onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
|
6224
|
+
onClick: composeEventHandlers(itemProps.onClick, () => {
|
6225
|
+
if (pointerTypeRef.current !== "mouse") handleSelect();
|
6226
|
+
}),
|
6227
|
+
onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
|
6228
|
+
if (pointerTypeRef.current === "mouse") handleSelect();
|
6229
|
+
}),
|
6230
|
+
onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
|
6231
|
+
pointerTypeRef.current = event.pointerType;
|
6232
|
+
}),
|
6233
|
+
onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
|
6234
|
+
pointerTypeRef.current = event.pointerType;
|
6235
|
+
if (disabled) {
|
6236
|
+
contentContext.onItemLeave?.();
|
6237
|
+
} else if (pointerTypeRef.current === "mouse") {
|
6238
|
+
event.currentTarget.focus({ preventScroll: true });
|
6239
|
+
}
|
6240
|
+
}),
|
6241
|
+
onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
|
6242
|
+
if (event.currentTarget === document.activeElement) {
|
6243
|
+
contentContext.onItemLeave?.();
|
6244
|
+
}
|
6245
|
+
}),
|
6246
|
+
onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
|
6247
|
+
const isTypingAhead = contentContext.searchRef?.current !== "";
|
6248
|
+
if (isTypingAhead && event.key === " ") return;
|
6249
|
+
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
6250
|
+
if (event.key === " ") event.preventDefault();
|
6251
|
+
})
|
6252
|
+
}
|
6253
|
+
)
|
6254
|
+
}
|
6255
|
+
)
|
6256
|
+
}
|
6257
|
+
);
|
6258
|
+
}
|
6259
|
+
);
|
6260
|
+
SelectItem$1.displayName = ITEM_NAME;
|
6261
|
+
var ITEM_TEXT_NAME = "SelectItemText";
|
6262
|
+
var SelectItemText = React.forwardRef(
|
6263
|
+
(props, forwardedRef) => {
|
6264
|
+
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
6265
|
+
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
6266
|
+
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
6267
|
+
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
6268
|
+
const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
|
6269
|
+
const [itemTextNode, setItemTextNode] = React.useState(null);
|
6270
|
+
const composedRefs = useComposedRefs$1(
|
6271
|
+
forwardedRef,
|
6272
|
+
(node) => setItemTextNode(node),
|
6273
|
+
itemContext.onItemTextChange,
|
6274
|
+
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
6275
|
+
);
|
6276
|
+
const textContent = itemTextNode?.textContent;
|
6277
|
+
const nativeOption = React.useMemo(
|
6278
|
+
() => /* @__PURE__ */ jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
|
6279
|
+
[itemContext.disabled, itemContext.value, textContent]
|
6280
|
+
);
|
6281
|
+
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
6282
|
+
useLayoutEffect2(() => {
|
6283
|
+
onNativeOptionAdd(nativeOption);
|
6284
|
+
return () => onNativeOptionRemove(nativeOption);
|
6285
|
+
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
6286
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
6287
|
+
/* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
6288
|
+
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
|
6289
|
+
] });
|
6290
|
+
}
|
6291
|
+
);
|
6292
|
+
SelectItemText.displayName = ITEM_TEXT_NAME;
|
6293
|
+
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
6294
|
+
var SelectItemIndicator = React.forwardRef(
|
6295
|
+
(props, forwardedRef) => {
|
6296
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
6297
|
+
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
6298
|
+
return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
6299
|
+
}
|
6300
|
+
);
|
6301
|
+
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
6302
|
+
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
6303
|
+
var SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
6304
|
+
const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
6305
|
+
const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
6306
|
+
const [canScrollUp, setCanScrollUp] = React.useState(false);
|
6307
|
+
const composedRefs = useComposedRefs$1(forwardedRef, viewportContext.onScrollButtonChange);
|
6308
|
+
useLayoutEffect2(() => {
|
6309
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
6310
|
+
let handleScroll2 = function() {
|
6311
|
+
const canScrollUp2 = viewport.scrollTop > 0;
|
6312
|
+
setCanScrollUp(canScrollUp2);
|
6313
|
+
};
|
6314
|
+
const viewport = contentContext.viewport;
|
6315
|
+
handleScroll2();
|
6316
|
+
viewport.addEventListener("scroll", handleScroll2);
|
6317
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
6318
|
+
}
|
6319
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
6320
|
+
return canScrollUp ? /* @__PURE__ */ jsx(
|
6321
|
+
SelectScrollButtonImpl,
|
6322
|
+
{
|
6323
|
+
...props,
|
6324
|
+
ref: composedRefs,
|
6325
|
+
onAutoScroll: () => {
|
6326
|
+
const { viewport, selectedItem } = contentContext;
|
6327
|
+
if (viewport && selectedItem) {
|
6328
|
+
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
6329
|
+
}
|
6330
|
+
}
|
6331
|
+
}
|
6332
|
+
) : null;
|
6333
|
+
});
|
6334
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
6335
|
+
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
6336
|
+
var SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
6337
|
+
const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
6338
|
+
const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
6339
|
+
const [canScrollDown, setCanScrollDown] = React.useState(false);
|
6340
|
+
const composedRefs = useComposedRefs$1(forwardedRef, viewportContext.onScrollButtonChange);
|
6341
|
+
useLayoutEffect2(() => {
|
6342
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
6343
|
+
let handleScroll2 = function() {
|
6344
|
+
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
6345
|
+
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
6346
|
+
setCanScrollDown(canScrollDown2);
|
6347
|
+
};
|
6348
|
+
const viewport = contentContext.viewport;
|
6349
|
+
handleScroll2();
|
6350
|
+
viewport.addEventListener("scroll", handleScroll2);
|
6351
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
6352
|
+
}
|
6353
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
6354
|
+
return canScrollDown ? /* @__PURE__ */ jsx(
|
6355
|
+
SelectScrollButtonImpl,
|
6356
|
+
{
|
6357
|
+
...props,
|
6358
|
+
ref: composedRefs,
|
6359
|
+
onAutoScroll: () => {
|
6360
|
+
const { viewport, selectedItem } = contentContext;
|
6361
|
+
if (viewport && selectedItem) {
|
6362
|
+
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
6363
|
+
}
|
6364
|
+
}
|
6365
|
+
}
|
6366
|
+
) : null;
|
6367
|
+
});
|
6368
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
6369
|
+
var SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
6370
|
+
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
6371
|
+
const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
|
6372
|
+
const autoScrollTimerRef = React.useRef(null);
|
6373
|
+
const getItems = useCollection(__scopeSelect);
|
6374
|
+
const clearAutoScrollTimer = React.useCallback(() => {
|
6375
|
+
if (autoScrollTimerRef.current !== null) {
|
6376
|
+
window.clearInterval(autoScrollTimerRef.current);
|
6377
|
+
autoScrollTimerRef.current = null;
|
6378
|
+
}
|
6379
|
+
}, []);
|
6380
|
+
React.useEffect(() => {
|
6381
|
+
return () => clearAutoScrollTimer();
|
6382
|
+
}, [clearAutoScrollTimer]);
|
6383
|
+
useLayoutEffect2(() => {
|
6384
|
+
const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
|
6385
|
+
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
6386
|
+
}, [getItems]);
|
6387
|
+
return /* @__PURE__ */ jsx(
|
6388
|
+
Primitive.div,
|
6389
|
+
{
|
6390
|
+
"aria-hidden": true,
|
6391
|
+
...scrollIndicatorProps,
|
6392
|
+
ref: forwardedRef,
|
6393
|
+
style: { flexShrink: 0, ...scrollIndicatorProps.style },
|
6394
|
+
onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
|
6395
|
+
if (autoScrollTimerRef.current === null) {
|
6396
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
6397
|
+
}
|
6398
|
+
}),
|
6399
|
+
onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
|
6400
|
+
contentContext.onItemLeave?.();
|
6401
|
+
if (autoScrollTimerRef.current === null) {
|
6402
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
6403
|
+
}
|
6404
|
+
}),
|
6405
|
+
onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
|
6406
|
+
clearAutoScrollTimer();
|
6407
|
+
})
|
6408
|
+
}
|
6409
|
+
);
|
6410
|
+
});
|
6411
|
+
var SEPARATOR_NAME = "SelectSeparator";
|
6412
|
+
var SelectSeparator = React.forwardRef(
|
6413
|
+
(props, forwardedRef) => {
|
6414
|
+
const { __scopeSelect, ...separatorProps } = props;
|
6415
|
+
return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
6416
|
+
}
|
6417
|
+
);
|
6418
|
+
SelectSeparator.displayName = SEPARATOR_NAME;
|
6419
|
+
var ARROW_NAME$1 = "SelectArrow";
|
6420
|
+
var SelectArrow = React.forwardRef(
|
6421
|
+
(props, forwardedRef) => {
|
6422
|
+
const { __scopeSelect, ...arrowProps } = props;
|
6423
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
6424
|
+
const context = useSelectContext(ARROW_NAME$1, __scopeSelect);
|
6425
|
+
const contentContext = useSelectContentContext(ARROW_NAME$1, __scopeSelect);
|
6426
|
+
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
6427
|
+
}
|
6428
|
+
);
|
6429
|
+
SelectArrow.displayName = ARROW_NAME$1;
|
6430
|
+
function shouldShowPlaceholder(value) {
|
6431
|
+
return value === "" || value === void 0;
|
6432
|
+
}
|
6433
|
+
var BubbleSelect = React.forwardRef(
|
6434
|
+
(props, forwardedRef) => {
|
6435
|
+
const { value, ...selectProps } = props;
|
6436
|
+
const ref = React.useRef(null);
|
6437
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref);
|
6438
|
+
const prevValue = usePrevious(value);
|
6439
|
+
React.useEffect(() => {
|
6440
|
+
const select = ref.current;
|
6441
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
6442
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
6443
|
+
selectProto,
|
6444
|
+
"value"
|
6445
|
+
);
|
6446
|
+
const setValue = descriptor.set;
|
6447
|
+
if (prevValue !== value && setValue) {
|
6448
|
+
const event = new Event("change", { bubbles: true });
|
6449
|
+
setValue.call(select, value);
|
6450
|
+
select.dispatchEvent(event);
|
6451
|
+
}
|
6452
|
+
}, [prevValue, value]);
|
6453
|
+
return /* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx("select", { ...selectProps, ref: composedRefs, defaultValue: value }) });
|
6454
|
+
}
|
6455
|
+
);
|
6456
|
+
BubbleSelect.displayName = "BubbleSelect";
|
6457
|
+
function useTypeaheadSearch(onSearchChange) {
|
6458
|
+
const handleSearchChange = useCallbackRef$2(onSearchChange);
|
6459
|
+
const searchRef = React.useRef("");
|
6460
|
+
const timerRef = React.useRef(0);
|
6461
|
+
const handleTypeaheadSearch = React.useCallback(
|
6462
|
+
(key) => {
|
6463
|
+
const search = searchRef.current + key;
|
6464
|
+
handleSearchChange(search);
|
6465
|
+
(function updateSearch(value) {
|
6466
|
+
searchRef.current = value;
|
6467
|
+
window.clearTimeout(timerRef.current);
|
6468
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
6469
|
+
})(search);
|
6470
|
+
},
|
6471
|
+
[handleSearchChange]
|
6472
|
+
);
|
6473
|
+
const resetTypeahead = React.useCallback(() => {
|
6474
|
+
searchRef.current = "";
|
6475
|
+
window.clearTimeout(timerRef.current);
|
6476
|
+
}, []);
|
6477
|
+
React.useEffect(() => {
|
6478
|
+
return () => window.clearTimeout(timerRef.current);
|
6479
|
+
}, []);
|
6480
|
+
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
6481
|
+
}
|
6482
|
+
function findNextItem(items, search, currentItem) {
|
6483
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
6484
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
6485
|
+
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
6486
|
+
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
6487
|
+
const excludeCurrentItem = normalizedSearch.length === 1;
|
6488
|
+
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
6489
|
+
const nextItem = wrappedItems.find(
|
6490
|
+
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
6491
|
+
);
|
6492
|
+
return nextItem !== currentItem ? nextItem : void 0;
|
6493
|
+
}
|
6494
|
+
function wrapArray(array, startIndex) {
|
6495
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
6496
|
+
}
|
6497
|
+
|
6498
|
+
var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
|
6499
|
+
createPopperScope
|
6500
|
+
]);
|
6501
|
+
var usePopperScope = createPopperScope();
|
6502
|
+
var PROVIDER_NAME = "TooltipProvider";
|
6503
|
+
var DEFAULT_DELAY_DURATION = 700;
|
6504
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
6505
|
+
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
6506
|
+
var TooltipProvider = (props) => {
|
6507
|
+
const {
|
6508
|
+
__scopeTooltip,
|
6509
|
+
delayDuration = DEFAULT_DELAY_DURATION,
|
6510
|
+
skipDelayDuration = 300,
|
6511
|
+
disableHoverableContent = false,
|
6512
|
+
children
|
6513
|
+
} = props;
|
6514
|
+
const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
|
6515
|
+
const isPointerInTransitRef = React.useRef(false);
|
6516
|
+
const skipDelayTimerRef = React.useRef(0);
|
6517
|
+
React.useEffect(() => {
|
6518
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
6519
|
+
return () => window.clearTimeout(skipDelayTimer);
|
6520
|
+
}, []);
|
6521
|
+
return /* @__PURE__ */ jsx(
|
6522
|
+
TooltipProviderContextProvider,
|
6523
|
+
{
|
6524
|
+
scope: __scopeTooltip,
|
6525
|
+
isOpenDelayed,
|
6526
|
+
delayDuration,
|
6527
|
+
onOpen: React.useCallback(() => {
|
6528
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
6529
|
+
setIsOpenDelayed(false);
|
6530
|
+
}, []),
|
6531
|
+
onClose: React.useCallback(() => {
|
6532
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
6533
|
+
skipDelayTimerRef.current = window.setTimeout(
|
6534
|
+
() => setIsOpenDelayed(true),
|
6535
|
+
skipDelayDuration
|
6536
|
+
);
|
6537
|
+
}, [skipDelayDuration]),
|
6538
|
+
isPointerInTransitRef,
|
6539
|
+
onPointerInTransitChange: React.useCallback((inTransit) => {
|
6540
|
+
isPointerInTransitRef.current = inTransit;
|
6541
|
+
}, []),
|
6542
|
+
disableHoverableContent,
|
6543
|
+
children
|
6544
|
+
}
|
6545
|
+
);
|
6546
|
+
};
|
6547
|
+
TooltipProvider.displayName = PROVIDER_NAME;
|
6548
|
+
var TOOLTIP_NAME = "Tooltip";
|
6549
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
6550
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
6551
|
+
var TooltipTrigger = React.forwardRef(
|
6552
|
+
(props, forwardedRef) => {
|
6553
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
6554
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
6555
|
+
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
|
6556
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
6557
|
+
const ref = React.useRef(null);
|
6558
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref, context.onTriggerChange);
|
6559
|
+
const isPointerDownRef = React.useRef(false);
|
6560
|
+
const hasPointerMoveOpenedRef = React.useRef(false);
|
6561
|
+
const handlePointerUp = React.useCallback(() => isPointerDownRef.current = false, []);
|
6562
|
+
React.useEffect(() => {
|
6563
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
6564
|
+
}, [handlePointerUp]);
|
6565
|
+
return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
|
6566
|
+
Primitive.button,
|
6567
|
+
{
|
6568
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
6569
|
+
"data-state": context.stateAttribute,
|
6570
|
+
...triggerProps,
|
6571
|
+
ref: composedRefs,
|
6572
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
6573
|
+
if (event.pointerType === "touch") return;
|
6574
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
6575
|
+
context.onTriggerEnter();
|
6576
|
+
hasPointerMoveOpenedRef.current = true;
|
6577
|
+
}
|
6578
|
+
}),
|
6579
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
6580
|
+
context.onTriggerLeave();
|
6581
|
+
hasPointerMoveOpenedRef.current = false;
|
6582
|
+
}),
|
6583
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
6584
|
+
isPointerDownRef.current = true;
|
6585
|
+
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
6586
|
+
}),
|
6587
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
6588
|
+
if (!isPointerDownRef.current) context.onOpen();
|
6589
|
+
}),
|
6590
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
6591
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
6592
|
+
}
|
6593
|
+
) });
|
6594
|
+
}
|
6595
|
+
);
|
6596
|
+
TooltipTrigger.displayName = TRIGGER_NAME;
|
6597
|
+
var PORTAL_NAME = "TooltipPortal";
|
6598
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
|
6599
|
+
forceMount: void 0
|
6600
|
+
});
|
6601
|
+
var CONTENT_NAME = "TooltipContent";
|
6602
|
+
var TooltipContent = React.forwardRef(
|
6603
|
+
(props, forwardedRef) => {
|
6604
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
6605
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
6606
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
6607
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.disableHoverableContent ? /* @__PURE__ */ jsx(TooltipContentImpl, { side, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(TooltipContentHoverable, { side, ...contentProps, ref: forwardedRef }) });
|
6608
|
+
}
|
6609
|
+
);
|
6610
|
+
var TooltipContentHoverable = React.forwardRef((props, forwardedRef) => {
|
6611
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
6612
|
+
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
|
6613
|
+
const ref = React.useRef(null);
|
6614
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref);
|
6615
|
+
const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
|
6616
|
+
const { trigger, onClose } = context;
|
6617
|
+
const content = ref.current;
|
6618
|
+
const { onPointerInTransitChange } = providerContext;
|
6619
|
+
const handleRemoveGraceArea = React.useCallback(() => {
|
6620
|
+
setPointerGraceArea(null);
|
6621
|
+
onPointerInTransitChange(false);
|
6622
|
+
}, [onPointerInTransitChange]);
|
6623
|
+
const handleCreateGraceArea = React.useCallback(
|
6624
|
+
(event, hoverTarget) => {
|
6625
|
+
const currentTarget = event.currentTarget;
|
6626
|
+
const exitPoint = { x: event.clientX, y: event.clientY };
|
6627
|
+
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
6628
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
6629
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
6630
|
+
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
6631
|
+
setPointerGraceArea(graceArea);
|
6632
|
+
onPointerInTransitChange(true);
|
6633
|
+
},
|
6634
|
+
[onPointerInTransitChange]
|
6635
|
+
);
|
6636
|
+
React.useEffect(() => {
|
6637
|
+
return () => handleRemoveGraceArea();
|
6638
|
+
}, [handleRemoveGraceArea]);
|
6639
|
+
React.useEffect(() => {
|
6640
|
+
if (trigger && content) {
|
6641
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
6642
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
6643
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
6644
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
6645
|
+
return () => {
|
6646
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
6647
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
6648
|
+
};
|
6649
|
+
}
|
6650
|
+
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
6651
|
+
React.useEffect(() => {
|
6652
|
+
if (pointerGraceArea) {
|
6653
|
+
const handleTrackPointerGrace = (event) => {
|
6654
|
+
const target = event.target;
|
6655
|
+
const pointerPosition = { x: event.clientX, y: event.clientY };
|
6656
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
6657
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
6658
|
+
if (hasEnteredTarget) {
|
6659
|
+
handleRemoveGraceArea();
|
6660
|
+
} else if (isPointerOutsideGraceArea) {
|
6661
|
+
handleRemoveGraceArea();
|
6662
|
+
onClose();
|
6663
|
+
}
|
6664
|
+
};
|
6665
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
6666
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
6667
|
+
}
|
6668
|
+
}, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);
|
6669
|
+
return /* @__PURE__ */ jsx(TooltipContentImpl, { ...props, ref: composedRefs });
|
6670
|
+
});
|
6671
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
|
6672
|
+
var TooltipContentImpl = React.forwardRef(
|
6673
|
+
(props, forwardedRef) => {
|
6674
|
+
const {
|
6675
|
+
__scopeTooltip,
|
6676
|
+
children,
|
6677
|
+
"aria-label": ariaLabel,
|
6678
|
+
onEscapeKeyDown,
|
6679
|
+
onPointerDownOutside,
|
6680
|
+
...contentProps
|
6681
|
+
} = props;
|
6682
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
6683
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
6684
|
+
const { onClose } = context;
|
6685
|
+
React.useEffect(() => {
|
6686
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
6687
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
6688
|
+
}, [onClose]);
|
6689
|
+
React.useEffect(() => {
|
6690
|
+
if (context.trigger) {
|
6691
|
+
const handleScroll = (event) => {
|
6692
|
+
const target = event.target;
|
6693
|
+
if (target?.contains(context.trigger)) onClose();
|
6694
|
+
};
|
6695
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
6696
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
6697
|
+
}
|
6698
|
+
}, [context.trigger, onClose]);
|
6699
|
+
return /* @__PURE__ */ jsx(
|
6700
|
+
DismissableLayer,
|
6701
|
+
{
|
6702
|
+
asChild: true,
|
6703
|
+
disableOutsidePointerEvents: false,
|
6704
|
+
onEscapeKeyDown,
|
5521
6705
|
onPointerDownOutside,
|
5522
6706
|
onFocusOutside: (event) => event.preventDefault(),
|
5523
6707
|
onDismiss: onClose,
|
@@ -10555,6 +11739,41 @@ function useReactTable(options) {
|
|
10555
11739
|
return tableRef.current;
|
10556
11740
|
}
|
10557
11741
|
|
11742
|
+
const HttpStatusCode = {
|
11743
|
+
// 4xx Client Error
|
11744
|
+
BAD_REQUEST: 400,
|
11745
|
+
UNAUTHORIZED: 401,
|
11746
|
+
PAYMENT_REQUIRED: 402,
|
11747
|
+
FORBIDDEN: 403,
|
11748
|
+
NOT_FOUND: 404,
|
11749
|
+
METHOD_NOT_ALLOWED: 405,
|
11750
|
+
NOT_ACCEPTABLE: 406,
|
11751
|
+
CONFLICT: 409,
|
11752
|
+
GONE: 410,
|
11753
|
+
PRECONDITION_FAILED: 412,
|
11754
|
+
PAYLOAD_TOO_LARGE: 413,
|
11755
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
11756
|
+
RANGE_NOT_SATISFIABLE: 416,
|
11757
|
+
TOO_MANY_REQUESTS: 429,
|
11758
|
+
// 5xx Server Error
|
11759
|
+
INTERNAL_SERVER_ERROR: 500,
|
11760
|
+
NOT_IMPLEMENTED: 501,
|
11761
|
+
BAD_GATEWAY: 502,
|
11762
|
+
SERVICE_UNAVAILABLE: 503,
|
11763
|
+
GATEWAY_TIMEOUT: 504,
|
11764
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
11765
|
+
};
|
11766
|
+
const CustomBehavior = {
|
11767
|
+
DEFAULT: "default",
|
11768
|
+
DELAY: "delay",
|
11769
|
+
RETURN_NULL: "return null",
|
11770
|
+
NETWORK_ERROR: "network error",
|
11771
|
+
};
|
11772
|
+
const HttpHandlerBehavior = {
|
11773
|
+
...CustomBehavior,
|
11774
|
+
...HttpStatusCode,
|
11775
|
+
};
|
11776
|
+
|
10558
11777
|
const dummyUrl = "/msw-dev-tool-dummy";
|
10559
11778
|
const dummyHandler = http.get(dummyUrl, () => { });
|
10560
11779
|
|
@@ -10567,7 +11786,7 @@ const convertHandlers = (handlers) => {
|
|
10567
11786
|
const flattenHandlers = handlers.reduce((acc, _handler) => {
|
10568
11787
|
// Current, GraphQL & WebSocketHandler is not supported.
|
10569
11788
|
const handler = _handler;
|
10570
|
-
if (!(
|
11789
|
+
if (!isHttpHandler(handler)) {
|
10571
11790
|
unsupportedHandlers.push(handler);
|
10572
11791
|
return acc;
|
10573
11792
|
}
|
@@ -10579,6 +11798,7 @@ const convertHandlers = (handlers) => {
|
|
10579
11798
|
method,
|
10580
11799
|
enabled: true,
|
10581
11800
|
handler,
|
11801
|
+
behavior: HttpHandlerBehavior.DEFAULT,
|
10582
11802
|
});
|
10583
11803
|
return acc;
|
10584
11804
|
}, []);
|
@@ -10611,6 +11831,33 @@ const initMSWDevToolStore = (worker) => {
|
|
10611
11831
|
}, {});
|
10612
11832
|
return { worker, flattenHandlers, unsupportedHandlers, handlerRowSelection };
|
10613
11833
|
};
|
11834
|
+
const isHttpHandler = (handler) => {
|
11835
|
+
return ("info" in handler && "method" in handler.info && "path" in handler.info);
|
11836
|
+
};
|
11837
|
+
const getHandlerResponseByBehavior = async (behavior, originalResolverCallback) => {
|
11838
|
+
if (!behavior || behavior === CustomBehavior.DEFAULT) {
|
11839
|
+
return originalResolverCallback();
|
11840
|
+
}
|
11841
|
+
if (behavior === CustomBehavior.DELAY) {
|
11842
|
+
await delay("infinite");
|
11843
|
+
return new Response();
|
11844
|
+
}
|
11845
|
+
if (behavior === CustomBehavior.RETURN_NULL) {
|
11846
|
+
return new HttpResponse(null, { status: 200 });
|
11847
|
+
}
|
11848
|
+
if (behavior === CustomBehavior.NETWORK_ERROR) {
|
11849
|
+
return HttpResponse.error();
|
11850
|
+
}
|
11851
|
+
for (const code of Object.values(HttpStatusCode)) {
|
11852
|
+
if (behavior === code) {
|
11853
|
+
return new HttpResponse(null, {
|
11854
|
+
status: code,
|
11855
|
+
statusText: `${code} triggered by dev tools.`,
|
11856
|
+
});
|
11857
|
+
}
|
11858
|
+
}
|
11859
|
+
return originalResolverCallback();
|
11860
|
+
};
|
10614
11861
|
|
10615
11862
|
var lodash = {exports: {}};
|
10616
11863
|
|
@@ -27821,26 +29068,52 @@ const useHandlerStore = create((set, get) => ({
|
|
27821
29068
|
worker: null,
|
27822
29069
|
restHandlers: [],
|
27823
29070
|
handlerRowSelection: {},
|
29071
|
+
setupDevToolWorker: (...handlers) => {
|
29072
|
+
const _handlers = handlers.map((handler) => {
|
29073
|
+
if (!isHttpHandler(handler)) {
|
29074
|
+
return handler;
|
29075
|
+
}
|
29076
|
+
const originalResolver = handler.resolver;
|
29077
|
+
handler.resolver = async (args) => {
|
29078
|
+
const id = getRowId({
|
29079
|
+
path: handler.info.path.toString(),
|
29080
|
+
method: handler.info.method.toString(),
|
29081
|
+
});
|
29082
|
+
const behavior = get().getHandlerBehavior(id);
|
29083
|
+
return await getHandlerResponseByBehavior(behavior, () => originalResolver(args));
|
29084
|
+
};
|
29085
|
+
return handler;
|
29086
|
+
});
|
29087
|
+
const worker = setupWorker(..._handlers);
|
29088
|
+
const { flattenHandlers, handlerRowSelection, unsupportedHandlers } = initMSWDevToolStore(worker);
|
29089
|
+
set({
|
29090
|
+
worker,
|
29091
|
+
flattenHandlers,
|
29092
|
+
handlerRowSelection,
|
29093
|
+
restHandlers: unsupportedHandlers,
|
29094
|
+
});
|
29095
|
+
return worker;
|
29096
|
+
},
|
27824
29097
|
initMSWDevTool: (_worker) => {
|
27825
29098
|
const { worker, flattenHandlers, handlerRowSelection, unsupportedHandlers, } = initMSWDevToolStore(_worker);
|
27826
|
-
set({ worker });
|
27827
|
-
set({ flattenHandlers });
|
27828
29099
|
set({
|
29100
|
+
worker,
|
29101
|
+
flattenHandlers,
|
27829
29102
|
handlerRowSelection,
|
29103
|
+
restHandlers: unsupportedHandlers,
|
27830
29104
|
});
|
27831
|
-
set({ restHandlers: unsupportedHandlers });
|
27832
29105
|
return worker;
|
27833
29106
|
},
|
27834
29107
|
resetMSWDevTool: () => {
|
27835
29108
|
const _worker = get().getWorker();
|
27836
29109
|
_worker.resetHandlers();
|
27837
29110
|
const { worker, flattenHandlers, handlerRowSelection, unsupportedHandlers, } = initMSWDevToolStore(_worker);
|
27838
|
-
set({ worker });
|
27839
|
-
set({ flattenHandlers });
|
27840
29111
|
set({
|
29112
|
+
worker,
|
29113
|
+
flattenHandlers,
|
27841
29114
|
handlerRowSelection,
|
29115
|
+
restHandlers: unsupportedHandlers,
|
27842
29116
|
});
|
27843
|
-
set({ restHandlers: unsupportedHandlers });
|
27844
29117
|
},
|
27845
29118
|
handleHandlerRowSelectionChange: (updater) => {
|
27846
29119
|
const worker = get().getWorker();
|
@@ -27870,103 +29143,28 @@ const useHandlerStore = create((set, get) => ({
|
|
27870
29143
|
throw new Error("Worker is not initialized");
|
27871
29144
|
return worker;
|
27872
29145
|
},
|
27873
|
-
|
27874
|
-
|
27875
|
-
|
27876
|
-
|
27877
|
-
|
27878
|
-
|
27879
|
-
|
27880
|
-
return
|
27881
|
-
|
27882
|
-
|
27883
|
-
|
27884
|
-
|
27885
|
-
|
27886
|
-
|
27887
|
-
|
27888
|
-
|
27889
|
-
} })),
|
27890
|
-
}),
|
27891
|
-
columnHelper.accessor("path", {
|
27892
|
-
header: "Protocol",
|
27893
|
-
cell: ({ row }) => {
|
27894
|
-
const protocol = new URL(row.original.path, location.href).protocol;
|
27895
|
-
return protocol;
|
27896
|
-
},
|
27897
|
-
id: "protocol",
|
27898
|
-
}),
|
27899
|
-
columnHelper.accessor("path", {
|
27900
|
-
header: "Host",
|
27901
|
-
cell: ({ row }) => {
|
27902
|
-
const host = new URL(row.original.path, location.href).host;
|
27903
|
-
return host;
|
27904
|
-
},
|
27905
|
-
id: "host",
|
27906
|
-
}),
|
27907
|
-
columnHelper.accessor("path", {
|
27908
|
-
header: "Path",
|
27909
|
-
cell: ({ row }) => {
|
27910
|
-
const path = new URL(row.original.path, location.href).pathname;
|
27911
|
-
return path;
|
27912
|
-
},
|
27913
|
-
id: "path",
|
27914
|
-
}),
|
27915
|
-
columnHelper.accessor("method", {
|
27916
|
-
header: "Method",
|
27917
|
-
cell: ({ row }) => row.original.method,
|
29146
|
+
getFlattenHandlerById: (id) => {
|
29147
|
+
return get().flattenHandlers.find((handler) => handler.id === id);
|
29148
|
+
},
|
29149
|
+
getHandlerBehavior: (id) => {
|
29150
|
+
const handler = get().getFlattenHandlerById(id);
|
29151
|
+
if (!handler)
|
29152
|
+
return undefined;
|
29153
|
+
return handler.behavior;
|
29154
|
+
},
|
29155
|
+
setHandlerBehavior: (id, behavior) => {
|
29156
|
+
set({
|
29157
|
+
flattenHandlers: get().flattenHandlers.map((handler) => {
|
29158
|
+
if (handler.id === id) {
|
29159
|
+
return { ...handler, behavior };
|
29160
|
+
}
|
29161
|
+
return handler;
|
27918
29162
|
}),
|
27919
|
-
|
27920
|
-
},
|
27921
|
-
const table = useReactTable({
|
27922
|
-
columns,
|
27923
|
-
data: flattenHandlers,
|
27924
|
-
getCoreRowModel: getCoreRowModel(),
|
27925
|
-
state: {
|
27926
|
-
rowSelection: handlerRowSelection,
|
27927
|
-
},
|
27928
|
-
onRowSelectionChange: handleHandlerRowSelectionChange,
|
27929
|
-
getRowId: (row) => row.id,
|
27930
|
-
enableRowSelection: true,
|
27931
|
-
});
|
27932
|
-
return table;
|
27933
|
-
};
|
27934
|
-
|
27935
|
-
const useUiControlStore = create((set) => ({
|
27936
|
-
currentHandler: null,
|
27937
|
-
setDebuggerHandler: (handler) => set({ currentHandler: handler }),
|
29163
|
+
});
|
29164
|
+
},
|
27938
29165
|
}));
|
27939
|
-
|
27940
|
-
const
|
27941
|
-
const table = useFlattenHandlersTable();
|
27942
|
-
const { setDebuggerHandler } = useUiControlStore();
|
27943
|
-
const currentHandler = useUiControlStore((state) => state.currentHandler);
|
27944
|
-
return (React__default.createElement(p$3, { style: { flex: 3, overflowY: "auto" }, direction: "column", gap: "4" },
|
27945
|
-
React__default.createElement(r$8, { as: "h2", size: "5" }, "Handlers"),
|
27946
|
-
React__default.createElement(m, { onDragStart: (e) => e.stopPropagation(), style: { userSelect: "text" } },
|
27947
|
-
React__default.createElement(d, null, table.getHeaderGroups().map((headerGroup) => (React__default.createElement(P, { key: headerGroup.id }, headerGroup.headers.map((header) => (React__default.createElement(f$1, { key: header.id }, header.isPlaceholder
|
27948
|
-
? null
|
27949
|
-
: flexRender(header.column.columnDef.header, header.getContext())))))))),
|
27950
|
-
React__default.createElement(b, null, table.getRowModel().rows.map((row) => (React__default.createElement(P, { key: row.id, align: "center", className: `msw-dt-http-control-row ${row.original.handler === currentHandler && "msw-dt-current-row"}`, onClick: () => {
|
27951
|
-
setDebuggerHandler(row.original.handler);
|
27952
|
-
} }, row.getVisibleCells().map((cell) => (React__default.createElement(T, { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())))))))))));
|
27953
|
-
};
|
27954
|
-
|
27955
|
-
const PathParamSetter = ({ paramValues, onParamChange, }) => {
|
27956
|
-
return (paramValues &&
|
27957
|
-
Object.keys(paramValues).length > 0 && (React__default.createElement(p$6, null,
|
27958
|
-
React__default.createElement(Label, null, "Path Parameters"),
|
27959
|
-
React__default.createElement(p$3, { direction: "column", gap: "2", py: "2" }, Object.entries(paramValues).map(([key, value]) => (React__default.createElement(p$3, { align: "center", gap: "2", key: key },
|
27960
|
-
React__default.createElement(Label, { htmlFor: `param-${key}`, style: { width: "160px" } },
|
27961
|
-
key,
|
27962
|
-
":"),
|
27963
|
-
React__default.createElement(u, { id: `param-${key}`, type: "text", value: value, onChange: (e) => onParamChange(key, e.target.value), placeholder: "value of path param", style: {
|
27964
|
-
padding: "4px 8px",
|
27965
|
-
borderRadius: "4px",
|
27966
|
-
border: "1px solid #ccc",
|
27967
|
-
width: "180px",
|
27968
|
-
} }))))))));
|
27969
|
-
};
|
29166
|
+
const initMSWDevTool = useHandlerStore.getState().initMSWDevTool;
|
29167
|
+
const setupDevToolWorker = useHandlerStore.getState().setupDevToolWorker;
|
27970
29168
|
|
27971
29169
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
27972
29170
|
if (source == null) return {};
|
@@ -27983,6 +29181,72 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
27983
29181
|
return target;
|
27984
29182
|
}
|
27985
29183
|
|
29184
|
+
var _excluded$T = ["color"];
|
29185
|
+
var CheckIcon = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
29186
|
+
var _ref$color = _ref.color,
|
29187
|
+
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
|
29188
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$T);
|
29189
|
+
|
29190
|
+
return createElement("svg", Object.assign({
|
29191
|
+
width: "15",
|
29192
|
+
height: "15",
|
29193
|
+
viewBox: "0 0 15 15",
|
29194
|
+
fill: "none",
|
29195
|
+
xmlns: "http://www.w3.org/2000/svg"
|
29196
|
+
}, props, {
|
29197
|
+
ref: forwardedRef
|
29198
|
+
}), createElement("path", {
|
29199
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
29200
|
+
fill: color,
|
29201
|
+
fillRule: "evenodd",
|
29202
|
+
clipRule: "evenodd"
|
29203
|
+
}));
|
29204
|
+
});
|
29205
|
+
|
29206
|
+
var _excluded$W = ["color"];
|
29207
|
+
var ChevronDownIcon = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
29208
|
+
var _ref$color = _ref.color,
|
29209
|
+
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
|
29210
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$W);
|
29211
|
+
|
29212
|
+
return createElement("svg", Object.assign({
|
29213
|
+
width: "15",
|
29214
|
+
height: "15",
|
29215
|
+
viewBox: "0 0 15 15",
|
29216
|
+
fill: "none",
|
29217
|
+
xmlns: "http://www.w3.org/2000/svg"
|
29218
|
+
}, props, {
|
29219
|
+
ref: forwardedRef
|
29220
|
+
}), createElement("path", {
|
29221
|
+
d: "M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",
|
29222
|
+
fill: color,
|
29223
|
+
fillRule: "evenodd",
|
29224
|
+
clipRule: "evenodd"
|
29225
|
+
}));
|
29226
|
+
});
|
29227
|
+
|
29228
|
+
var _excluded$Z = ["color"];
|
29229
|
+
var ChevronUpIcon = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
29230
|
+
var _ref$color = _ref.color,
|
29231
|
+
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
|
29232
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$Z);
|
29233
|
+
|
29234
|
+
return createElement("svg", Object.assign({
|
29235
|
+
width: "15",
|
29236
|
+
height: "15",
|
29237
|
+
viewBox: "0 0 15 15",
|
29238
|
+
fill: "none",
|
29239
|
+
xmlns: "http://www.w3.org/2000/svg"
|
29240
|
+
}, props, {
|
29241
|
+
ref: forwardedRef
|
29242
|
+
}), createElement("path", {
|
29243
|
+
d: "M3.13523 8.84197C3.3241 9.04343 3.64052 9.05363 3.84197 8.86477L7.5 5.43536L11.158 8.86477C11.3595 9.05363 11.6759 9.04343 11.8648 8.84197C12.0536 8.64051 12.0434 8.32409 11.842 8.13523L7.84197 4.38523C7.64964 4.20492 7.35036 4.20492 7.15803 4.38523L3.15803 8.13523C2.95657 8.32409 2.94637 8.64051 3.13523 8.84197Z",
|
29244
|
+
fill: color,
|
29245
|
+
fillRule: "evenodd",
|
29246
|
+
clipRule: "evenodd"
|
29247
|
+
}));
|
29248
|
+
});
|
29249
|
+
|
27986
29250
|
var _excluded$3w = ["color"];
|
27987
29251
|
var PlayIcon = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
27988
29252
|
var _ref$color = _ref.color,
|
@@ -28071,6 +29335,137 @@ var TrashIcon = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
28071
29335
|
}));
|
28072
29336
|
});
|
28073
29337
|
|
29338
|
+
const BehaviorSelect = ({ row }) => {
|
29339
|
+
var _a;
|
29340
|
+
const id = row.original.id;
|
29341
|
+
const { setHandlerBehavior, getHandlerBehavior } = useHandlerStore();
|
29342
|
+
return (React__default.createElement(Select, { onValueChange: (_value) => {
|
29343
|
+
const value = _value;
|
29344
|
+
setHandlerBehavior(row.original.id, value);
|
29345
|
+
} },
|
29346
|
+
React__default.createElement(SelectTrigger, { className: "msw-dt-select-trigger", "aria-label": "Behavior", onClick: (e) => e.stopPropagation() },
|
29347
|
+
React__default.createElement(SelectValue, { placeholder: (_a = getHandlerBehavior(id)) !== null && _a !== void 0 ? _a : HttpHandlerBehavior.DEFAULT, className: "msw-dt-text-ellipsis" }),
|
29348
|
+
React__default.createElement(SelectIcon, { className: "msw-dt-select-icon" },
|
29349
|
+
React__default.createElement(ChevronDownIcon, null))),
|
29350
|
+
React__default.createElement(SelectPortal, null,
|
29351
|
+
React__default.createElement(SelectContent, { className: "msw-dt-select-content", style: { zIndex: 10000 } },
|
29352
|
+
React__default.createElement(SelectScrollUpButton, { className: "msw-dt-select-scroll-button" },
|
29353
|
+
React__default.createElement(ChevronUpIcon, null)),
|
29354
|
+
React__default.createElement(SelectViewport, { className: "msw-dt-select-viewport" }, Object.values(HttpHandlerBehavior).map((behavior) => {
|
29355
|
+
return (React__default.createElement(SelectItem, { key: behavior, value: behavior }, behavior));
|
29356
|
+
})),
|
29357
|
+
React__default.createElement(SelectScrollDownButton, { className: "msw-dt-select-scroll-button" },
|
29358
|
+
React__default.createElement(ChevronDownIcon, null))))));
|
29359
|
+
};
|
29360
|
+
const SelectItem = React__default.forwardRef(({ children, className, value, ...props }, forwardedRef) => {
|
29361
|
+
return (React__default.createElement(SelectItem$1, { className: "msw-dt-select-item", value: value, ...props, ref: forwardedRef },
|
29362
|
+
React__default.createElement(SelectItemText, null, children),
|
29363
|
+
React__default.createElement(SelectItemIndicator, { className: "msw-dt-select-item-indicator" },
|
29364
|
+
React__default.createElement(CheckIcon, null))));
|
29365
|
+
});
|
29366
|
+
SelectItem.displayName = "SelectItem";
|
29367
|
+
|
29368
|
+
const useFlattenHandlersTable = () => {
|
29369
|
+
const { flattenHandlers, handlerRowSelection, handleHandlerRowSelectionChange, } = useHandlerStore();
|
29370
|
+
const columnHelper = createColumnHelper();
|
29371
|
+
const columns = useMemo(() => {
|
29372
|
+
return [
|
29373
|
+
columnHelper.accessor("enabled", {
|
29374
|
+
header: ({ table }) => (React__default.createElement("input", { type: "checkbox", checked: table.getIsAllRowsSelected(), onChange: (e) => {
|
29375
|
+
e.stopPropagation();
|
29376
|
+
table.toggleAllRowsSelected(e.target.checked);
|
29377
|
+
} })),
|
29378
|
+
cell: ({ row }) => (React__default.createElement("input", { type: "checkbox", checked: row.getIsSelected(), onChange: (e) => {
|
29379
|
+
e.stopPropagation();
|
29380
|
+
row.toggleSelected(e.target.checked);
|
29381
|
+
} })),
|
29382
|
+
}),
|
29383
|
+
columnHelper.accessor("path", {
|
29384
|
+
header: "Protocol",
|
29385
|
+
cell: ({ row }) => {
|
29386
|
+
const protocol = new URL(row.original.path, location.href).protocol;
|
29387
|
+
return protocol;
|
29388
|
+
},
|
29389
|
+
id: "protocol",
|
29390
|
+
}),
|
29391
|
+
columnHelper.accessor("path", {
|
29392
|
+
header: "Host",
|
29393
|
+
cell: ({ row }) => {
|
29394
|
+
const host = new URL(row.original.path, location.href).host;
|
29395
|
+
return host;
|
29396
|
+
},
|
29397
|
+
id: "host",
|
29398
|
+
}),
|
29399
|
+
columnHelper.accessor("path", {
|
29400
|
+
header: "Path",
|
29401
|
+
cell: ({ row }) => {
|
29402
|
+
const path = new URL(row.original.path, location.href).pathname;
|
29403
|
+
return path;
|
29404
|
+
},
|
29405
|
+
id: "path",
|
29406
|
+
}),
|
29407
|
+
columnHelper.accessor("method", {
|
29408
|
+
header: "Method",
|
29409
|
+
cell: ({ row }) => row.original.method,
|
29410
|
+
}),
|
29411
|
+
columnHelper.accessor("behavior", {
|
29412
|
+
header: "Behavior",
|
29413
|
+
cell: ({ row }) => {
|
29414
|
+
return React__default.createElement(BehaviorSelect, { row: row });
|
29415
|
+
},
|
29416
|
+
}),
|
29417
|
+
];
|
29418
|
+
}, []);
|
29419
|
+
const table = useReactTable({
|
29420
|
+
columns,
|
29421
|
+
data: flattenHandlers,
|
29422
|
+
getCoreRowModel: getCoreRowModel(),
|
29423
|
+
state: {
|
29424
|
+
rowSelection: handlerRowSelection,
|
29425
|
+
},
|
29426
|
+
onRowSelectionChange: handleHandlerRowSelectionChange,
|
29427
|
+
getRowId: (row) => row.id,
|
29428
|
+
enableRowSelection: true,
|
29429
|
+
});
|
29430
|
+
return table;
|
29431
|
+
};
|
29432
|
+
|
29433
|
+
const useUiControlStore = create((set) => ({
|
29434
|
+
currentHandler: null,
|
29435
|
+
setDebuggerHandler: (handler) => set({ currentHandler: handler }),
|
29436
|
+
}));
|
29437
|
+
|
29438
|
+
const HandlerTable = () => {
|
29439
|
+
const table = useFlattenHandlersTable();
|
29440
|
+
const { setDebuggerHandler } = useUiControlStore();
|
29441
|
+
const currentHandler = useUiControlStore((state) => state.currentHandler);
|
29442
|
+
return (React__default.createElement(p$3, { style: { flex: 3, overflowY: "auto" }, direction: "column", gap: "4" },
|
29443
|
+
React__default.createElement(r$8, { as: "h2", size: "5" }, "Handlers"),
|
29444
|
+
React__default.createElement(m, { onDragStart: (e) => e.stopPropagation(), style: { userSelect: "text" } },
|
29445
|
+
React__default.createElement(d, null, table.getHeaderGroups().map((headerGroup) => (React__default.createElement(P, { key: headerGroup.id }, headerGroup.headers.map((header) => (React__default.createElement(f$1, { key: header.id }, header.isPlaceholder
|
29446
|
+
? null
|
29447
|
+
: flexRender(header.column.columnDef.header, header.getContext())))))))),
|
29448
|
+
React__default.createElement(b, null, table.getRowModel().rows.map((row) => (React__default.createElement(P, { key: row.id, align: "center", className: `msw-dt-http-control-row ${row.original.handler === currentHandler && "msw-dt-current-row"}`, onClick: () => {
|
29449
|
+
setDebuggerHandler(row.original.handler);
|
29450
|
+
} }, row.getVisibleCells().map((cell) => (React__default.createElement(T, { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())))))))))));
|
29451
|
+
};
|
29452
|
+
|
29453
|
+
const PathParamSetter = ({ paramValues, onParamChange, }) => {
|
29454
|
+
return (paramValues &&
|
29455
|
+
Object.keys(paramValues).length > 0 && (React__default.createElement(p$6, null,
|
29456
|
+
React__default.createElement(Label, null, "Path Parameters"),
|
29457
|
+
React__default.createElement(p$3, { direction: "column", gap: "2", py: "2" }, Object.entries(paramValues).map(([key, value]) => (React__default.createElement(p$3, { align: "center", gap: "2", key: key },
|
29458
|
+
React__default.createElement(Label, { htmlFor: `param-${key}`, style: { width: "160px" } },
|
29459
|
+
key,
|
29460
|
+
":"),
|
29461
|
+
React__default.createElement(u, { id: `param-${key}`, type: "text", value: value, onChange: (e) => onParamChange(key, e.target.value), placeholder: "value of path param", style: {
|
29462
|
+
padding: "4px 8px",
|
29463
|
+
borderRadius: "4px",
|
29464
|
+
border: "1px solid #ccc",
|
29465
|
+
width: "180px",
|
29466
|
+
} }))))))));
|
29467
|
+
};
|
29468
|
+
|
28074
29469
|
const KeyValueInputList = ({ items, setItems, title, }) => {
|
28075
29470
|
const id = useId$1();
|
28076
29471
|
const [key, setKey] = useState("");
|
@@ -28339,9 +29734,9 @@ const MSWDevTool = () => {
|
|
28339
29734
|
React__default.createElement(DialogDescription, { className: "msw-dt-sub-text", style: { display: "none" } }, "Dev tool to control mock logic, and monitor handler logic calls."),
|
28340
29735
|
React__default.createElement(ToolButtonGroup, null),
|
28341
29736
|
React__default.createElement(p$3, { gap: "6", style: { flex: 1, overflow: "hidden" } },
|
28342
|
-
React__default.createElement(
|
29737
|
+
React__default.createElement(HandlerTable, null),
|
28343
29738
|
React__default.createElement(HandlerDebugger, null))))))));
|
28344
29739
|
};
|
28345
29740
|
|
28346
|
-
export { MSWDevTool, initMSWDevTool };
|
29741
|
+
export { MSWDevTool, initMSWDevTool, setupDevToolWorker };
|
28347
29742
|
//# sourceMappingURL=index.js.map
|