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/cjs/index.js
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
var React = require('react');
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
5
5
|
var ReactDOM = require('react-dom');
|
6
|
+
var browser = require('msw/browser');
|
6
7
|
var zustand = require('zustand');
|
7
8
|
var msw = require('msw');
|
8
9
|
|
@@ -279,6 +280,67 @@ function composeContextScopes(...scopes) {
|
|
279
280
|
return createScope;
|
280
281
|
}
|
281
282
|
|
283
|
+
function createCollection(name) {
|
284
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
285
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
286
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
|
287
|
+
PROVIDER_NAME,
|
288
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
289
|
+
);
|
290
|
+
const CollectionProvider = (props) => {
|
291
|
+
const { scope, children } = props;
|
292
|
+
const ref = React.useRef(null);
|
293
|
+
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
294
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
295
|
+
};
|
296
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
297
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
298
|
+
const CollectionSlot = React.forwardRef(
|
299
|
+
(props, forwardedRef) => {
|
300
|
+
const { scope, children } = props;
|
301
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
302
|
+
const composedRefs = useComposedRefs$1(forwardedRef, context.collectionRef);
|
303
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Slot, { ref: composedRefs, children });
|
304
|
+
}
|
305
|
+
);
|
306
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
307
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
308
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
309
|
+
const CollectionItemSlot = React.forwardRef(
|
310
|
+
(props, forwardedRef) => {
|
311
|
+
const { scope, children, ...itemData } = props;
|
312
|
+
const ref = React.useRef(null);
|
313
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref);
|
314
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
315
|
+
React.useEffect(() => {
|
316
|
+
context.itemMap.set(ref, { ref, ...itemData });
|
317
|
+
return () => void context.itemMap.delete(ref);
|
318
|
+
});
|
319
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
320
|
+
}
|
321
|
+
);
|
322
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
323
|
+
function useCollection(scope) {
|
324
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
325
|
+
const getItems = React.useCallback(() => {
|
326
|
+
const collectionNode = context.collectionRef.current;
|
327
|
+
if (!collectionNode) return [];
|
328
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
329
|
+
const items = Array.from(context.itemMap.values());
|
330
|
+
const orderedItems = items.sort(
|
331
|
+
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
332
|
+
);
|
333
|
+
return orderedItems;
|
334
|
+
}, [context.collectionRef, context.itemMap]);
|
335
|
+
return getItems;
|
336
|
+
}
|
337
|
+
return [
|
338
|
+
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
339
|
+
useCollection,
|
340
|
+
createCollectionScope
|
341
|
+
];
|
342
|
+
}
|
343
|
+
|
282
344
|
// packages/core/primitive/src/primitive.tsx
|
283
345
|
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
284
346
|
return function handleEvent(event) {
|
@@ -908,7 +970,7 @@ function removeLinks(items) {
|
|
908
970
|
return items.filter((item) => item.tagName !== "A");
|
909
971
|
}
|
910
972
|
|
911
|
-
var PORTAL_NAME$
|
973
|
+
var PORTAL_NAME$3 = "Portal";
|
912
974
|
var Portal$2 = React__namespace.forwardRef((props, forwardedRef) => {
|
913
975
|
const { container: containerProp, ...portalProps } = props;
|
914
976
|
const [mounted, setMounted] = React__namespace.useState(false);
|
@@ -916,7 +978,7 @@ var Portal$2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
916
978
|
const container = containerProp || mounted && globalThis?.document?.body;
|
917
979
|
return container ? ReactDOM.createPortal(/* @__PURE__ */ jsxRuntime.jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
918
980
|
});
|
919
|
-
Portal$2.displayName = PORTAL_NAME$
|
981
|
+
Portal$2.displayName = PORTAL_NAME$3;
|
920
982
|
|
921
983
|
var count$1 = 0;
|
922
984
|
function useFocusGuards() {
|
@@ -1871,11 +1933,11 @@ var Dialog = (props) => {
|
|
1871
1933
|
);
|
1872
1934
|
};
|
1873
1935
|
Dialog.displayName = DIALOG_NAME;
|
1874
|
-
var TRIGGER_NAME$
|
1936
|
+
var TRIGGER_NAME$2 = "DialogTrigger";
|
1875
1937
|
var DialogTrigger = React__namespace.forwardRef(
|
1876
1938
|
(props, forwardedRef) => {
|
1877
1939
|
const { __scopeDialog, ...triggerProps } = props;
|
1878
|
-
const context = useDialogContext(TRIGGER_NAME$
|
1940
|
+
const context = useDialogContext(TRIGGER_NAME$2, __scopeDialog);
|
1879
1941
|
const composedTriggerRef = useComposedRefs$1(forwardedRef, context.triggerRef);
|
1880
1942
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1881
1943
|
Primitive.button,
|
@@ -1892,17 +1954,17 @@ var DialogTrigger = React__namespace.forwardRef(
|
|
1892
1954
|
);
|
1893
1955
|
}
|
1894
1956
|
);
|
1895
|
-
DialogTrigger.displayName = TRIGGER_NAME$
|
1896
|
-
var PORTAL_NAME$
|
1897
|
-
var [PortalProvider$1, usePortalContext$1] = createDialogContext(PORTAL_NAME$
|
1957
|
+
DialogTrigger.displayName = TRIGGER_NAME$2;
|
1958
|
+
var PORTAL_NAME$2 = "DialogPortal";
|
1959
|
+
var [PortalProvider$1, usePortalContext$1] = createDialogContext(PORTAL_NAME$2, {
|
1898
1960
|
forceMount: void 0
|
1899
1961
|
});
|
1900
1962
|
var DialogPortal = (props) => {
|
1901
1963
|
const { __scopeDialog, forceMount, children, container } = props;
|
1902
|
-
const context = useDialogContext(PORTAL_NAME$
|
1964
|
+
const context = useDialogContext(PORTAL_NAME$2, __scopeDialog);
|
1903
1965
|
return /* @__PURE__ */ jsxRuntime.jsx(PortalProvider$1, { scope: __scopeDialog, forceMount, children: React__namespace.Children.map(children, (child) => /* @__PURE__ */ jsxRuntime.jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsxRuntime.jsx(Portal$2, { asChild: true, container, children: child }) })) });
|
1904
1966
|
};
|
1905
|
-
DialogPortal.displayName = PORTAL_NAME$
|
1967
|
+
DialogPortal.displayName = PORTAL_NAME$2;
|
1906
1968
|
var OVERLAY_NAME = "DialogOverlay";
|
1907
1969
|
var DialogOverlay = React__namespace.forwardRef(
|
1908
1970
|
(props, forwardedRef) => {
|
@@ -1932,19 +1994,19 @@ var DialogOverlayImpl = React__namespace.forwardRef(
|
|
1932
1994
|
);
|
1933
1995
|
}
|
1934
1996
|
);
|
1935
|
-
var CONTENT_NAME$
|
1997
|
+
var CONTENT_NAME$3 = "DialogContent";
|
1936
1998
|
var DialogContent = React__namespace.forwardRef(
|
1937
1999
|
(props, forwardedRef) => {
|
1938
|
-
const portalContext = usePortalContext$1(CONTENT_NAME$
|
2000
|
+
const portalContext = usePortalContext$1(CONTENT_NAME$3, props.__scopeDialog);
|
1939
2001
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
1940
|
-
const context = useDialogContext(CONTENT_NAME$
|
2002
|
+
const context = useDialogContext(CONTENT_NAME$3, props.__scopeDialog);
|
1941
2003
|
return /* @__PURE__ */ jsxRuntime.jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsxRuntime.jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsxRuntime.jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
1942
2004
|
}
|
1943
2005
|
);
|
1944
|
-
DialogContent.displayName = CONTENT_NAME$
|
2006
|
+
DialogContent.displayName = CONTENT_NAME$3;
|
1945
2007
|
var DialogContentModal = React__namespace.forwardRef(
|
1946
2008
|
(props, forwardedRef) => {
|
1947
|
-
const context = useDialogContext(CONTENT_NAME$
|
2009
|
+
const context = useDialogContext(CONTENT_NAME$3, props.__scopeDialog);
|
1948
2010
|
const contentRef = React__namespace.useRef(null);
|
1949
2011
|
const composedRefs = useComposedRefs$1(forwardedRef, context.contentRef, contentRef);
|
1950
2012
|
React__namespace.useEffect(() => {
|
@@ -1978,7 +2040,7 @@ var DialogContentModal = React__namespace.forwardRef(
|
|
1978
2040
|
);
|
1979
2041
|
var DialogContentNonModal = React__namespace.forwardRef(
|
1980
2042
|
(props, forwardedRef) => {
|
1981
|
-
const context = useDialogContext(CONTENT_NAME$
|
2043
|
+
const context = useDialogContext(CONTENT_NAME$3, props.__scopeDialog);
|
1982
2044
|
const hasInteractedOutsideRef = React__namespace.useRef(false);
|
1983
2045
|
const hasPointerDownOutsideRef = React__namespace.useRef(false);
|
1984
2046
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2019,7 +2081,7 @@ var DialogContentNonModal = React__namespace.forwardRef(
|
|
2019
2081
|
var DialogContentImpl = React__namespace.forwardRef(
|
2020
2082
|
(props, forwardedRef) => {
|
2021
2083
|
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
2022
|
-
const context = useDialogContext(CONTENT_NAME$
|
2084
|
+
const context = useDialogContext(CONTENT_NAME$3, __scopeDialog);
|
2023
2085
|
const contentRef = React__namespace.useRef(null);
|
2024
2086
|
const composedRefs = useComposedRefs$1(forwardedRef, contentRef);
|
2025
2087
|
useFocusGuards();
|
@@ -2094,7 +2156,7 @@ function getState(open) {
|
|
2094
2156
|
}
|
2095
2157
|
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
2096
2158
|
var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
|
2097
|
-
contentName: CONTENT_NAME$
|
2159
|
+
contentName: CONTENT_NAME$3,
|
2098
2160
|
titleName: TITLE_NAME,
|
2099
2161
|
docsSlug: "dialog"
|
2100
2162
|
});
|
@@ -2135,6 +2197,18 @@ var Title = DialogTitle;
|
|
2135
2197
|
var Description = DialogDescription;
|
2136
2198
|
var Close = DialogClose;
|
2137
2199
|
|
2200
|
+
// packages/react/use-previous/src/usePrevious.tsx
|
2201
|
+
function usePrevious(value) {
|
2202
|
+
const ref = React__namespace.useRef({ value, previous: value });
|
2203
|
+
return React__namespace.useMemo(() => {
|
2204
|
+
if (ref.current.value !== value) {
|
2205
|
+
ref.current.previous = ref.current.value;
|
2206
|
+
ref.current.value = value;
|
2207
|
+
}
|
2208
|
+
return ref.current.previous;
|
2209
|
+
}, [value]);
|
2210
|
+
}
|
2211
|
+
|
2138
2212
|
// packages/react/use-size/src/useSize.tsx
|
2139
2213
|
function useSize(element) {
|
2140
2214
|
const [size, setSize] = React__namespace.useState(void 0);
|
@@ -4346,6 +4420,12 @@ var Root$2 = Arrow$1;
|
|
4346
4420
|
var POPPER_NAME = "Popper";
|
4347
4421
|
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
4348
4422
|
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
4423
|
+
var Popper = (props) => {
|
4424
|
+
const { __scopePopper, children } = props;
|
4425
|
+
const [anchor, setAnchor] = React__namespace.useState(null);
|
4426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
4427
|
+
};
|
4428
|
+
Popper.displayName = POPPER_NAME;
|
4349
4429
|
var ANCHOR_NAME = "PopperAnchor";
|
4350
4430
|
var PopperAnchor = React__namespace.forwardRef(
|
4351
4431
|
(props, forwardedRef) => {
|
@@ -4360,8 +4440,8 @@ var PopperAnchor = React__namespace.forwardRef(
|
|
4360
4440
|
}
|
4361
4441
|
);
|
4362
4442
|
PopperAnchor.displayName = ANCHOR_NAME;
|
4363
|
-
var CONTENT_NAME$
|
4364
|
-
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$
|
4443
|
+
var CONTENT_NAME$2 = "PopperContent";
|
4444
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$2);
|
4365
4445
|
var PopperContent = React__namespace.forwardRef(
|
4366
4446
|
(props, forwardedRef) => {
|
4367
4447
|
const {
|
@@ -4380,7 +4460,7 @@ var PopperContent = React__namespace.forwardRef(
|
|
4380
4460
|
onPlaced,
|
4381
4461
|
...contentProps
|
4382
4462
|
} = props;
|
4383
|
-
const context = usePopperContext(CONTENT_NAME$
|
4463
|
+
const context = usePopperContext(CONTENT_NAME$2, __scopePopper);
|
4384
4464
|
const [content, setContent] = React__namespace.useState(null);
|
4385
4465
|
const composedRefs = useComposedRefs$1(forwardedRef, (node) => setContent(node));
|
4386
4466
|
const [arrow$1, setArrow] = React__namespace.useState(null);
|
@@ -4503,8 +4583,8 @@ var PopperContent = React__namespace.forwardRef(
|
|
4503
4583
|
);
|
4504
4584
|
}
|
4505
4585
|
);
|
4506
|
-
PopperContent.displayName = CONTENT_NAME$
|
4507
|
-
var ARROW_NAME$
|
4586
|
+
PopperContent.displayName = CONTENT_NAME$2;
|
4587
|
+
var ARROW_NAME$2 = "PopperArrow";
|
4508
4588
|
var OPPOSITE_SIDE = {
|
4509
4589
|
top: "bottom",
|
4510
4590
|
right: "left",
|
@@ -4513,7 +4593,7 @@ var OPPOSITE_SIDE = {
|
|
4513
4593
|
};
|
4514
4594
|
var PopperArrow = React__namespace.forwardRef(function PopperArrow2(props, forwardedRef) {
|
4515
4595
|
const { __scopePopper, ...arrowProps } = props;
|
4516
|
-
const contentContext = useContentContext(ARROW_NAME$
|
4596
|
+
const contentContext = useContentContext(ARROW_NAME$2, __scopePopper);
|
4517
4597
|
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
4518
4598
|
return (
|
4519
4599
|
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
@@ -4558,7 +4638,7 @@ var PopperArrow = React__namespace.forwardRef(function PopperArrow2(props, forwa
|
|
4558
4638
|
)
|
4559
4639
|
);
|
4560
4640
|
});
|
4561
|
-
PopperArrow.displayName = ARROW_NAME$
|
4641
|
+
PopperArrow.displayName = ARROW_NAME$2;
|
4562
4642
|
function isNotNull(value) {
|
4563
4643
|
return value !== null;
|
4564
4644
|
}
|
@@ -4597,6 +4677,7 @@ function getSideAndAlignFromPlacement(placement) {
|
|
4597
4677
|
const [side, align = "center"] = placement.split("-");
|
4598
4678
|
return [side, align];
|
4599
4679
|
}
|
4680
|
+
var Root2 = Popper;
|
4600
4681
|
var Anchor = PopperAnchor;
|
4601
4682
|
var Content$1 = PopperContent;
|
4602
4683
|
var Arrow = PopperArrow;
|
@@ -4695,11 +4776,11 @@ var ScrollArea = React__namespace.forwardRef(
|
|
4695
4776
|
}
|
4696
4777
|
);
|
4697
4778
|
ScrollArea.displayName = SCROLL_AREA_NAME;
|
4698
|
-
var VIEWPORT_NAME = "ScrollAreaViewport";
|
4779
|
+
var VIEWPORT_NAME$1 = "ScrollAreaViewport";
|
4699
4780
|
var ScrollAreaViewport = React__namespace.forwardRef(
|
4700
4781
|
(props, forwardedRef) => {
|
4701
4782
|
const { __scopeScrollArea, children, nonce, ...viewportProps } = props;
|
4702
|
-
const context = useScrollAreaContext(VIEWPORT_NAME, __scopeScrollArea);
|
4783
|
+
const context = useScrollAreaContext(VIEWPORT_NAME$1, __scopeScrollArea);
|
4703
4784
|
const ref = React__namespace.useRef(null);
|
4704
4785
|
const composedRefs = useComposedRefs$1(forwardedRef, ref, context.onViewportChange);
|
4705
4786
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
@@ -4740,7 +4821,7 @@ var ScrollAreaViewport = React__namespace.forwardRef(
|
|
4740
4821
|
] });
|
4741
4822
|
}
|
4742
4823
|
);
|
4743
|
-
ScrollAreaViewport.displayName = VIEWPORT_NAME;
|
4824
|
+
ScrollAreaViewport.displayName = VIEWPORT_NAME$1;
|
4744
4825
|
var SCROLLBAR_NAME = "ScrollAreaScrollbar";
|
4745
4826
|
var ScrollAreaScrollbar = React__namespace.forwardRef(
|
4746
4827
|
(props, forwardedRef) => {
|
@@ -5331,213 +5412,1316 @@ var Scrollbar = ScrollAreaScrollbar;
|
|
5331
5412
|
var Thumb = ScrollAreaThumb;
|
5332
5413
|
var Corner = ScrollAreaCorner;
|
5333
5414
|
|
5334
|
-
var [
|
5415
|
+
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
5416
|
+
var SELECTION_KEYS = [" ", "Enter"];
|
5417
|
+
var SELECT_NAME = "Select";
|
5418
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
|
5419
|
+
var [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
|
5420
|
+
createCollectionScope,
|
5335
5421
|
createPopperScope
|
5336
5422
|
]);
|
5337
|
-
var usePopperScope = createPopperScope();
|
5338
|
-
var
|
5339
|
-
var
|
5340
|
-
var
|
5341
|
-
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
5342
|
-
var TooltipProvider = (props) => {
|
5423
|
+
var usePopperScope$1 = createPopperScope();
|
5424
|
+
var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
5425
|
+
var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
5426
|
+
var Select = (props) => {
|
5343
5427
|
const {
|
5344
|
-
|
5345
|
-
|
5346
|
-
|
5347
|
-
|
5348
|
-
|
5428
|
+
__scopeSelect,
|
5429
|
+
children,
|
5430
|
+
open: openProp,
|
5431
|
+
defaultOpen,
|
5432
|
+
onOpenChange,
|
5433
|
+
value: valueProp,
|
5434
|
+
defaultValue,
|
5435
|
+
onValueChange,
|
5436
|
+
dir,
|
5437
|
+
name,
|
5438
|
+
autoComplete,
|
5439
|
+
disabled,
|
5440
|
+
required,
|
5441
|
+
form
|
5349
5442
|
} = props;
|
5350
|
-
const
|
5351
|
-
const
|
5352
|
-
const
|
5353
|
-
React__namespace.
|
5354
|
-
|
5355
|
-
|
5356
|
-
|
5357
|
-
|
5358
|
-
|
5443
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
5444
|
+
const [trigger, setTrigger] = React__namespace.useState(null);
|
5445
|
+
const [valueNode, setValueNode] = React__namespace.useState(null);
|
5446
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = React__namespace.useState(false);
|
5447
|
+
const direction = useDirection(dir);
|
5448
|
+
const [open = false, setOpen] = useControllableState$1({
|
5449
|
+
prop: openProp,
|
5450
|
+
defaultProp: defaultOpen,
|
5451
|
+
onChange: onOpenChange
|
5452
|
+
});
|
5453
|
+
const [value, setValue] = useControllableState$1({
|
5454
|
+
prop: valueProp,
|
5455
|
+
defaultProp: defaultValue,
|
5456
|
+
onChange: onValueChange
|
5457
|
+
});
|
5458
|
+
const triggerPointerDownPosRef = React__namespace.useRef(null);
|
5459
|
+
const isFormControl = trigger ? form || !!trigger.closest("form") : true;
|
5460
|
+
const [nativeOptionsSet, setNativeOptionsSet] = React__namespace.useState(/* @__PURE__ */ new Set());
|
5461
|
+
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
5462
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Root2, { ...popperScope, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
5463
|
+
SelectProvider,
|
5359
5464
|
{
|
5360
|
-
|
5361
|
-
|
5362
|
-
|
5363
|
-
|
5364
|
-
|
5365
|
-
|
5366
|
-
|
5367
|
-
|
5368
|
-
|
5369
|
-
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
|
5375
|
-
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5465
|
+
required,
|
5466
|
+
scope: __scopeSelect,
|
5467
|
+
trigger,
|
5468
|
+
onTriggerChange: setTrigger,
|
5469
|
+
valueNode,
|
5470
|
+
onValueNodeChange: setValueNode,
|
5471
|
+
valueNodeHasChildren,
|
5472
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
5473
|
+
contentId: useId(),
|
5474
|
+
value,
|
5475
|
+
onValueChange: setValue,
|
5476
|
+
open,
|
5477
|
+
onOpenChange: setOpen,
|
5478
|
+
dir: direction,
|
5479
|
+
triggerPointerDownPosRef,
|
5480
|
+
disabled,
|
5481
|
+
children: [
|
5482
|
+
/* @__PURE__ */ jsxRuntime.jsx(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx(
|
5483
|
+
SelectNativeOptionsProvider,
|
5484
|
+
{
|
5485
|
+
scope: props.__scopeSelect,
|
5486
|
+
onNativeOptionAdd: React__namespace.useCallback((option) => {
|
5487
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
5488
|
+
}, []),
|
5489
|
+
onNativeOptionRemove: React__namespace.useCallback((option) => {
|
5490
|
+
setNativeOptionsSet((prev) => {
|
5491
|
+
const optionsSet = new Set(prev);
|
5492
|
+
optionsSet.delete(option);
|
5493
|
+
return optionsSet;
|
5494
|
+
});
|
5495
|
+
}, []),
|
5496
|
+
children
|
5497
|
+
}
|
5498
|
+
) }),
|
5499
|
+
isFormControl ? /* @__PURE__ */ jsxRuntime.jsxs(
|
5500
|
+
BubbleSelect,
|
5501
|
+
{
|
5502
|
+
"aria-hidden": true,
|
5503
|
+
required,
|
5504
|
+
tabIndex: -1,
|
5505
|
+
name,
|
5506
|
+
autoComplete,
|
5507
|
+
value,
|
5508
|
+
onChange: (event) => setValue(event.target.value),
|
5509
|
+
disabled,
|
5510
|
+
form,
|
5511
|
+
children: [
|
5512
|
+
value === void 0 ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "" }) : null,
|
5513
|
+
Array.from(nativeOptionsSet)
|
5514
|
+
]
|
5515
|
+
},
|
5516
|
+
nativeSelectKey
|
5517
|
+
) : null
|
5518
|
+
]
|
5380
5519
|
}
|
5381
|
-
);
|
5520
|
+
) });
|
5382
5521
|
};
|
5383
|
-
|
5384
|
-
var
|
5385
|
-
var
|
5386
|
-
var TRIGGER_NAME = "TooltipTrigger";
|
5387
|
-
var TooltipTrigger = React__namespace.forwardRef(
|
5522
|
+
Select.displayName = SELECT_NAME;
|
5523
|
+
var TRIGGER_NAME$1 = "SelectTrigger";
|
5524
|
+
var SelectTrigger = React__namespace.forwardRef(
|
5388
5525
|
(props, forwardedRef) => {
|
5389
|
-
const {
|
5390
|
-
const
|
5391
|
-
const
|
5392
|
-
const
|
5393
|
-
const
|
5394
|
-
const
|
5395
|
-
const
|
5396
|
-
const
|
5397
|
-
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5526
|
+
const { __scopeSelect, disabled = false, ...triggerProps } = props;
|
5527
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
5528
|
+
const context = useSelectContext(TRIGGER_NAME$1, __scopeSelect);
|
5529
|
+
const isDisabled = context.disabled || disabled;
|
5530
|
+
const composedRefs = useComposedRefs$1(forwardedRef, context.onTriggerChange);
|
5531
|
+
const getItems = useCollection(__scopeSelect);
|
5532
|
+
const pointerTypeRef = React__namespace.useRef("touch");
|
5533
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
|
5534
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
5535
|
+
const currentItem = enabledItems.find((item) => item.value === context.value);
|
5536
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
5537
|
+
if (nextItem !== void 0) {
|
5538
|
+
context.onValueChange(nextItem.value);
|
5539
|
+
}
|
5540
|
+
});
|
5541
|
+
const handleOpen = (pointerEvent) => {
|
5542
|
+
if (!isDisabled) {
|
5543
|
+
context.onOpenChange(true);
|
5544
|
+
resetTypeahead();
|
5545
|
+
}
|
5546
|
+
if (pointerEvent) {
|
5547
|
+
context.triggerPointerDownPosRef.current = {
|
5548
|
+
x: Math.round(pointerEvent.pageX),
|
5549
|
+
y: Math.round(pointerEvent.pageY)
|
5550
|
+
};
|
5551
|
+
}
|
5552
|
+
};
|
5401
5553
|
return /* @__PURE__ */ jsxRuntime.jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsxRuntime.jsx(
|
5402
5554
|
Primitive.button,
|
5403
5555
|
{
|
5404
|
-
"
|
5405
|
-
"
|
5556
|
+
type: "button",
|
5557
|
+
role: "combobox",
|
5558
|
+
"aria-controls": context.contentId,
|
5559
|
+
"aria-expanded": context.open,
|
5560
|
+
"aria-required": context.required,
|
5561
|
+
"aria-autocomplete": "none",
|
5562
|
+
dir: context.dir,
|
5563
|
+
"data-state": context.open ? "open" : "closed",
|
5564
|
+
disabled: isDisabled,
|
5565
|
+
"data-disabled": isDisabled ? "" : void 0,
|
5566
|
+
"data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
|
5406
5567
|
...triggerProps,
|
5407
5568
|
ref: composedRefs,
|
5408
|
-
|
5409
|
-
|
5410
|
-
if (
|
5411
|
-
|
5412
|
-
hasPointerMoveOpenedRef.current = true;
|
5569
|
+
onClick: composeEventHandlers(triggerProps.onClick, (event) => {
|
5570
|
+
event.currentTarget.focus();
|
5571
|
+
if (pointerTypeRef.current !== "mouse") {
|
5572
|
+
handleOpen(event);
|
5413
5573
|
}
|
5414
5574
|
}),
|
5415
|
-
|
5416
|
-
|
5417
|
-
|
5418
|
-
|
5419
|
-
|
5420
|
-
|
5421
|
-
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5575
|
+
onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
|
5576
|
+
pointerTypeRef.current = event.pointerType;
|
5577
|
+
const target = event.target;
|
5578
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
5579
|
+
target.releasePointerCapture(event.pointerId);
|
5580
|
+
}
|
5581
|
+
if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
|
5582
|
+
handleOpen(event);
|
5583
|
+
event.preventDefault();
|
5584
|
+
}
|
5425
5585
|
}),
|
5426
|
-
|
5427
|
-
|
5586
|
+
onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
|
5587
|
+
const isTypingAhead = searchRef.current !== "";
|
5588
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
5589
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
5590
|
+
if (isTypingAhead && event.key === " ") return;
|
5591
|
+
if (OPEN_KEYS.includes(event.key)) {
|
5592
|
+
handleOpen();
|
5593
|
+
event.preventDefault();
|
5594
|
+
}
|
5595
|
+
})
|
5428
5596
|
}
|
5429
5597
|
) });
|
5430
5598
|
}
|
5431
5599
|
);
|
5432
|
-
|
5433
|
-
var
|
5434
|
-
var
|
5435
|
-
forceMount: void 0
|
5436
|
-
});
|
5437
|
-
var CONTENT_NAME = "TooltipContent";
|
5438
|
-
var TooltipContent = React__namespace.forwardRef(
|
5600
|
+
SelectTrigger.displayName = TRIGGER_NAME$1;
|
5601
|
+
var VALUE_NAME = "SelectValue";
|
5602
|
+
var SelectValue = React__namespace.forwardRef(
|
5439
5603
|
(props, forwardedRef) => {
|
5440
|
-
const
|
5441
|
-
const
|
5442
|
-
const
|
5443
|
-
|
5604
|
+
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
5605
|
+
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
5606
|
+
const { onValueNodeHasChildrenChange } = context;
|
5607
|
+
const hasChildren = children !== void 0;
|
5608
|
+
const composedRefs = useComposedRefs$1(forwardedRef, context.onValueNodeChange);
|
5609
|
+
useLayoutEffect2(() => {
|
5610
|
+
onValueNodeHasChildrenChange(hasChildren);
|
5611
|
+
}, [onValueNodeHasChildrenChange, hasChildren]);
|
5612
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5613
|
+
Primitive.span,
|
5614
|
+
{
|
5615
|
+
...valueProps,
|
5616
|
+
ref: composedRefs,
|
5617
|
+
style: { pointerEvents: "none" },
|
5618
|
+
children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: placeholder }) : children
|
5619
|
+
}
|
5620
|
+
);
|
5444
5621
|
}
|
5445
5622
|
);
|
5446
|
-
|
5447
|
-
|
5448
|
-
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
|
5455
|
-
|
5456
|
-
|
5457
|
-
|
5458
|
-
|
5459
|
-
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5464
|
-
|
5465
|
-
|
5466
|
-
|
5467
|
-
|
5468
|
-
|
5469
|
-
|
5470
|
-
|
5471
|
-
|
5472
|
-
|
5473
|
-
|
5474
|
-
}, [handleRemoveGraceArea]);
|
5475
|
-
React__namespace.useEffect(() => {
|
5476
|
-
if (trigger && content) {
|
5477
|
-
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
5478
|
-
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
5479
|
-
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
5480
|
-
content.addEventListener("pointerleave", handleContentLeave);
|
5481
|
-
return () => {
|
5482
|
-
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
5483
|
-
content.removeEventListener("pointerleave", handleContentLeave);
|
5484
|
-
};
|
5485
|
-
}
|
5486
|
-
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
5487
|
-
React__namespace.useEffect(() => {
|
5488
|
-
if (pointerGraceArea) {
|
5489
|
-
const handleTrackPointerGrace = (event) => {
|
5490
|
-
const target = event.target;
|
5491
|
-
const pointerPosition = { x: event.clientX, y: event.clientY };
|
5492
|
-
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
5493
|
-
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
5494
|
-
if (hasEnteredTarget) {
|
5495
|
-
handleRemoveGraceArea();
|
5496
|
-
} else if (isPointerOutsideGraceArea) {
|
5497
|
-
handleRemoveGraceArea();
|
5498
|
-
onClose();
|
5499
|
-
}
|
5500
|
-
};
|
5501
|
-
document.addEventListener("pointermove", handleTrackPointerGrace);
|
5502
|
-
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
5623
|
+
SelectValue.displayName = VALUE_NAME;
|
5624
|
+
var ICON_NAME = "SelectIcon";
|
5625
|
+
var SelectIcon = React__namespace.forwardRef(
|
5626
|
+
(props, forwardedRef) => {
|
5627
|
+
const { __scopeSelect, children, ...iconProps } = props;
|
5628
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
|
5629
|
+
}
|
5630
|
+
);
|
5631
|
+
SelectIcon.displayName = ICON_NAME;
|
5632
|
+
var PORTAL_NAME$1 = "SelectPortal";
|
5633
|
+
var SelectPortal = (props) => {
|
5634
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Portal$2, { asChild: true, ...props });
|
5635
|
+
};
|
5636
|
+
SelectPortal.displayName = PORTAL_NAME$1;
|
5637
|
+
var CONTENT_NAME$1 = "SelectContent";
|
5638
|
+
var SelectContent = React__namespace.forwardRef(
|
5639
|
+
(props, forwardedRef) => {
|
5640
|
+
const context = useSelectContext(CONTENT_NAME$1, props.__scopeSelect);
|
5641
|
+
const [fragment, setFragment] = React__namespace.useState();
|
5642
|
+
useLayoutEffect2(() => {
|
5643
|
+
setFragment(new DocumentFragment());
|
5644
|
+
}, []);
|
5645
|
+
if (!context.open) {
|
5646
|
+
const frag = fragment;
|
5647
|
+
return frag ? ReactDOM__namespace.createPortal(
|
5648
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: props.children }) }) }),
|
5649
|
+
frag
|
5650
|
+
) : null;
|
5503
5651
|
}
|
5504
|
-
|
5505
|
-
|
5506
|
-
|
5507
|
-
|
5508
|
-
var
|
5652
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectContentImpl, { ...props, ref: forwardedRef });
|
5653
|
+
}
|
5654
|
+
);
|
5655
|
+
SelectContent.displayName = CONTENT_NAME$1;
|
5656
|
+
var CONTENT_MARGIN = 10;
|
5657
|
+
var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME$1);
|
5658
|
+
var CONTENT_IMPL_NAME = "SelectContentImpl";
|
5659
|
+
var SelectContentImpl = React__namespace.forwardRef(
|
5509
5660
|
(props, forwardedRef) => {
|
5510
5661
|
const {
|
5511
|
-
|
5512
|
-
|
5513
|
-
|
5662
|
+
__scopeSelect,
|
5663
|
+
position = "item-aligned",
|
5664
|
+
onCloseAutoFocus,
|
5514
5665
|
onEscapeKeyDown,
|
5515
5666
|
onPointerDownOutside,
|
5667
|
+
//
|
5668
|
+
// PopperContent props
|
5669
|
+
side,
|
5670
|
+
sideOffset,
|
5671
|
+
align,
|
5672
|
+
alignOffset,
|
5673
|
+
arrowPadding,
|
5674
|
+
collisionBoundary,
|
5675
|
+
collisionPadding,
|
5676
|
+
sticky,
|
5677
|
+
hideWhenDetached,
|
5678
|
+
avoidCollisions,
|
5679
|
+
//
|
5516
5680
|
...contentProps
|
5517
5681
|
} = props;
|
5518
|
-
const context =
|
5519
|
-
const
|
5520
|
-
const
|
5682
|
+
const context = useSelectContext(CONTENT_NAME$1, __scopeSelect);
|
5683
|
+
const [content, setContent] = React__namespace.useState(null);
|
5684
|
+
const [viewport, setViewport] = React__namespace.useState(null);
|
5685
|
+
const composedRefs = useComposedRefs$1(forwardedRef, (node) => setContent(node));
|
5686
|
+
const [selectedItem, setSelectedItem] = React__namespace.useState(null);
|
5687
|
+
const [selectedItemText, setSelectedItemText] = React__namespace.useState(
|
5688
|
+
null
|
5689
|
+
);
|
5690
|
+
const getItems = useCollection(__scopeSelect);
|
5691
|
+
const [isPositioned, setIsPositioned] = React__namespace.useState(false);
|
5692
|
+
const firstValidItemFoundRef = React__namespace.useRef(false);
|
5521
5693
|
React__namespace.useEffect(() => {
|
5522
|
-
|
5523
|
-
|
5524
|
-
|
5694
|
+
if (content) return hideOthers(content);
|
5695
|
+
}, [content]);
|
5696
|
+
useFocusGuards();
|
5697
|
+
const focusFirst = React__namespace.useCallback(
|
5698
|
+
(candidates) => {
|
5699
|
+
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
5700
|
+
const [lastItem] = restItems.slice(-1);
|
5701
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
5702
|
+
for (const candidate of candidates) {
|
5703
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
5704
|
+
candidate?.scrollIntoView({ block: "nearest" });
|
5705
|
+
if (candidate === firstItem && viewport) viewport.scrollTop = 0;
|
5706
|
+
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
5707
|
+
candidate?.focus();
|
5708
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
5709
|
+
}
|
5710
|
+
},
|
5711
|
+
[getItems, viewport]
|
5712
|
+
);
|
5713
|
+
const focusSelectedItem = React__namespace.useCallback(
|
5714
|
+
() => focusFirst([selectedItem, content]),
|
5715
|
+
[focusFirst, selectedItem, content]
|
5716
|
+
);
|
5525
5717
|
React__namespace.useEffect(() => {
|
5526
|
-
if (
|
5527
|
-
|
5528
|
-
const target = event.target;
|
5529
|
-
if (target?.contains(context.trigger)) onClose();
|
5530
|
-
};
|
5531
|
-
window.addEventListener("scroll", handleScroll, { capture: true });
|
5532
|
-
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
5718
|
+
if (isPositioned) {
|
5719
|
+
focusSelectedItem();
|
5533
5720
|
}
|
5534
|
-
}, [
|
5535
|
-
|
5536
|
-
|
5537
|
-
{
|
5538
|
-
|
5539
|
-
|
5540
|
-
|
5721
|
+
}, [isPositioned, focusSelectedItem]);
|
5722
|
+
const { onOpenChange, triggerPointerDownPosRef } = context;
|
5723
|
+
React__namespace.useEffect(() => {
|
5724
|
+
if (content) {
|
5725
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
5726
|
+
const handlePointerMove = (event) => {
|
5727
|
+
pointerMoveDelta = {
|
5728
|
+
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
5729
|
+
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
5730
|
+
};
|
5731
|
+
};
|
5732
|
+
const handlePointerUp = (event) => {
|
5733
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
5734
|
+
event.preventDefault();
|
5735
|
+
} else {
|
5736
|
+
if (!content.contains(event.target)) {
|
5737
|
+
onOpenChange(false);
|
5738
|
+
}
|
5739
|
+
}
|
5740
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
5741
|
+
triggerPointerDownPosRef.current = null;
|
5742
|
+
};
|
5743
|
+
if (triggerPointerDownPosRef.current !== null) {
|
5744
|
+
document.addEventListener("pointermove", handlePointerMove);
|
5745
|
+
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
5746
|
+
}
|
5747
|
+
return () => {
|
5748
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
5749
|
+
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
5750
|
+
};
|
5751
|
+
}
|
5752
|
+
}, [content, onOpenChange, triggerPointerDownPosRef]);
|
5753
|
+
React__namespace.useEffect(() => {
|
5754
|
+
const close = () => onOpenChange(false);
|
5755
|
+
window.addEventListener("blur", close);
|
5756
|
+
window.addEventListener("resize", close);
|
5757
|
+
return () => {
|
5758
|
+
window.removeEventListener("blur", close);
|
5759
|
+
window.removeEventListener("resize", close);
|
5760
|
+
};
|
5761
|
+
}, [onOpenChange]);
|
5762
|
+
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
|
5763
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
5764
|
+
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
5765
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
5766
|
+
if (nextItem) {
|
5767
|
+
setTimeout(() => nextItem.ref.current.focus());
|
5768
|
+
}
|
5769
|
+
});
|
5770
|
+
const itemRefCallback = React__namespace.useCallback(
|
5771
|
+
(node, value, disabled) => {
|
5772
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
5773
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
5774
|
+
if (isSelectedItem || isFirstValidItem) {
|
5775
|
+
setSelectedItem(node);
|
5776
|
+
if (isFirstValidItem) firstValidItemFoundRef.current = true;
|
5777
|
+
}
|
5778
|
+
},
|
5779
|
+
[context.value]
|
5780
|
+
);
|
5781
|
+
const handleItemLeave = React__namespace.useCallback(() => content?.focus(), [content]);
|
5782
|
+
const itemTextRefCallback = React__namespace.useCallback(
|
5783
|
+
(node, value, disabled) => {
|
5784
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
5785
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
5786
|
+
if (isSelectedItem || isFirstValidItem) {
|
5787
|
+
setSelectedItemText(node);
|
5788
|
+
}
|
5789
|
+
},
|
5790
|
+
[context.value]
|
5791
|
+
);
|
5792
|
+
const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
|
5793
|
+
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
5794
|
+
side,
|
5795
|
+
sideOffset,
|
5796
|
+
align,
|
5797
|
+
alignOffset,
|
5798
|
+
arrowPadding,
|
5799
|
+
collisionBoundary,
|
5800
|
+
collisionPadding,
|
5801
|
+
sticky,
|
5802
|
+
hideWhenDetached,
|
5803
|
+
avoidCollisions
|
5804
|
+
} : {};
|
5805
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5806
|
+
SelectContentProvider,
|
5807
|
+
{
|
5808
|
+
scope: __scopeSelect,
|
5809
|
+
content,
|
5810
|
+
viewport,
|
5811
|
+
onViewportChange: setViewport,
|
5812
|
+
itemRefCallback,
|
5813
|
+
selectedItem,
|
5814
|
+
onItemLeave: handleItemLeave,
|
5815
|
+
itemTextRefCallback,
|
5816
|
+
focusSelectedItem,
|
5817
|
+
selectedItemText,
|
5818
|
+
position,
|
5819
|
+
isPositioned,
|
5820
|
+
searchRef,
|
5821
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
5822
|
+
FocusScope,
|
5823
|
+
{
|
5824
|
+
asChild: true,
|
5825
|
+
trapped: context.open,
|
5826
|
+
onMountAutoFocus: (event) => {
|
5827
|
+
event.preventDefault();
|
5828
|
+
},
|
5829
|
+
onUnmountAutoFocus: composeEventHandlers(onCloseAutoFocus, (event) => {
|
5830
|
+
context.trigger?.focus({ preventScroll: true });
|
5831
|
+
event.preventDefault();
|
5832
|
+
}),
|
5833
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
5834
|
+
DismissableLayer,
|
5835
|
+
{
|
5836
|
+
asChild: true,
|
5837
|
+
disableOutsidePointerEvents: true,
|
5838
|
+
onEscapeKeyDown,
|
5839
|
+
onPointerDownOutside,
|
5840
|
+
onFocusOutside: (event) => event.preventDefault(),
|
5841
|
+
onDismiss: () => context.onOpenChange(false),
|
5842
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
5843
|
+
SelectPosition,
|
5844
|
+
{
|
5845
|
+
role: "listbox",
|
5846
|
+
id: context.contentId,
|
5847
|
+
"data-state": context.open ? "open" : "closed",
|
5848
|
+
dir: context.dir,
|
5849
|
+
onContextMenu: (event) => event.preventDefault(),
|
5850
|
+
...contentProps,
|
5851
|
+
...popperContentProps,
|
5852
|
+
onPlaced: () => setIsPositioned(true),
|
5853
|
+
ref: composedRefs,
|
5854
|
+
style: {
|
5855
|
+
// flex layout so we can place the scroll buttons properly
|
5856
|
+
display: "flex",
|
5857
|
+
flexDirection: "column",
|
5858
|
+
// reset the outline by default as the content MAY get focused
|
5859
|
+
outline: "none",
|
5860
|
+
...contentProps.style
|
5861
|
+
},
|
5862
|
+
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
5863
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
5864
|
+
if (event.key === "Tab") event.preventDefault();
|
5865
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
5866
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
5867
|
+
const items = getItems().filter((item) => !item.disabled);
|
5868
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
5869
|
+
if (["ArrowUp", "End"].includes(event.key)) {
|
5870
|
+
candidateNodes = candidateNodes.slice().reverse();
|
5871
|
+
}
|
5872
|
+
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
5873
|
+
const currentElement = event.target;
|
5874
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
5875
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
5876
|
+
}
|
5877
|
+
setTimeout(() => focusFirst(candidateNodes));
|
5878
|
+
event.preventDefault();
|
5879
|
+
}
|
5880
|
+
})
|
5881
|
+
}
|
5882
|
+
)
|
5883
|
+
}
|
5884
|
+
)
|
5885
|
+
}
|
5886
|
+
) })
|
5887
|
+
}
|
5888
|
+
);
|
5889
|
+
}
|
5890
|
+
);
|
5891
|
+
SelectContentImpl.displayName = CONTENT_IMPL_NAME;
|
5892
|
+
var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
|
5893
|
+
var SelectItemAlignedPosition = React__namespace.forwardRef((props, forwardedRef) => {
|
5894
|
+
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
5895
|
+
const context = useSelectContext(CONTENT_NAME$1, __scopeSelect);
|
5896
|
+
const contentContext = useSelectContentContext(CONTENT_NAME$1, __scopeSelect);
|
5897
|
+
const [contentWrapper, setContentWrapper] = React__namespace.useState(null);
|
5898
|
+
const [content, setContent] = React__namespace.useState(null);
|
5899
|
+
const composedRefs = useComposedRefs$1(forwardedRef, (node) => setContent(node));
|
5900
|
+
const getItems = useCollection(__scopeSelect);
|
5901
|
+
const shouldExpandOnScrollRef = React__namespace.useRef(false);
|
5902
|
+
const shouldRepositionRef = React__namespace.useRef(true);
|
5903
|
+
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
5904
|
+
const position = React__namespace.useCallback(() => {
|
5905
|
+
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
5906
|
+
const triggerRect = context.trigger.getBoundingClientRect();
|
5907
|
+
const contentRect = content.getBoundingClientRect();
|
5908
|
+
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
5909
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
5910
|
+
if (context.dir !== "rtl") {
|
5911
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
5912
|
+
const left = valueNodeRect.left - itemTextOffset;
|
5913
|
+
const leftDelta = triggerRect.left - left;
|
5914
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
5915
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
5916
|
+
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
5917
|
+
const clampedLeft = clamp(left, [
|
5918
|
+
CONTENT_MARGIN,
|
5919
|
+
// Prevents the content from going off the starting edge of the
|
5920
|
+
// viewport. It may still go off the ending edge, but this can be
|
5921
|
+
// controlled by the user since they may want to manage overflow in a
|
5922
|
+
// specific way.
|
5923
|
+
// https://github.com/radix-ui/primitives/issues/2049
|
5924
|
+
Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
|
5925
|
+
]);
|
5926
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
5927
|
+
contentWrapper.style.left = clampedLeft + "px";
|
5928
|
+
} else {
|
5929
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
5930
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
5931
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
5932
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
5933
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
5934
|
+
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
5935
|
+
const clampedRight = clamp(right, [
|
5936
|
+
CONTENT_MARGIN,
|
5937
|
+
Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
|
5938
|
+
]);
|
5939
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
5940
|
+
contentWrapper.style.right = clampedRight + "px";
|
5941
|
+
}
|
5942
|
+
const items = getItems();
|
5943
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
5944
|
+
const itemsHeight = viewport.scrollHeight;
|
5945
|
+
const contentStyles = window.getComputedStyle(content);
|
5946
|
+
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
5947
|
+
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
5948
|
+
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
5949
|
+
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
5950
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
5951
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
5952
|
+
const viewportStyles = window.getComputedStyle(viewport);
|
5953
|
+
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
5954
|
+
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
5955
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
5956
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
5957
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
5958
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
5959
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
5960
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
5961
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
5962
|
+
if (willAlignWithoutTopOverflow) {
|
5963
|
+
const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
|
5964
|
+
contentWrapper.style.bottom = "0px";
|
5965
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
5966
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(
|
5967
|
+
triggerMiddleToBottomEdge,
|
5968
|
+
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
5969
|
+
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
5970
|
+
);
|
5971
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
5972
|
+
contentWrapper.style.height = height + "px";
|
5973
|
+
} else {
|
5974
|
+
const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
|
5975
|
+
contentWrapper.style.top = "0px";
|
5976
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(
|
5977
|
+
topEdgeToTriggerMiddle,
|
5978
|
+
contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
5979
|
+
(isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
|
5980
|
+
);
|
5981
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
5982
|
+
contentWrapper.style.height = height + "px";
|
5983
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
5984
|
+
}
|
5985
|
+
contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
|
5986
|
+
contentWrapper.style.minHeight = minContentHeight + "px";
|
5987
|
+
contentWrapper.style.maxHeight = availableHeight + "px";
|
5988
|
+
onPlaced?.();
|
5989
|
+
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
5990
|
+
}
|
5991
|
+
}, [
|
5992
|
+
getItems,
|
5993
|
+
context.trigger,
|
5994
|
+
context.valueNode,
|
5995
|
+
contentWrapper,
|
5996
|
+
content,
|
5997
|
+
viewport,
|
5998
|
+
selectedItem,
|
5999
|
+
selectedItemText,
|
6000
|
+
context.dir,
|
6001
|
+
onPlaced
|
6002
|
+
]);
|
6003
|
+
useLayoutEffect2(() => position(), [position]);
|
6004
|
+
const [contentZIndex, setContentZIndex] = React__namespace.useState();
|
6005
|
+
useLayoutEffect2(() => {
|
6006
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
6007
|
+
}, [content]);
|
6008
|
+
const handleScrollButtonChange = React__namespace.useCallback(
|
6009
|
+
(node) => {
|
6010
|
+
if (node && shouldRepositionRef.current === true) {
|
6011
|
+
position();
|
6012
|
+
focusSelectedItem?.();
|
6013
|
+
shouldRepositionRef.current = false;
|
6014
|
+
}
|
6015
|
+
},
|
6016
|
+
[position, focusSelectedItem]
|
6017
|
+
);
|
6018
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
6019
|
+
SelectViewportProvider,
|
6020
|
+
{
|
6021
|
+
scope: __scopeSelect,
|
6022
|
+
contentWrapper,
|
6023
|
+
shouldExpandOnScrollRef,
|
6024
|
+
onScrollButtonChange: handleScrollButtonChange,
|
6025
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
6026
|
+
"div",
|
6027
|
+
{
|
6028
|
+
ref: setContentWrapper,
|
6029
|
+
style: {
|
6030
|
+
display: "flex",
|
6031
|
+
flexDirection: "column",
|
6032
|
+
position: "fixed",
|
6033
|
+
zIndex: contentZIndex
|
6034
|
+
},
|
6035
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
6036
|
+
Primitive.div,
|
6037
|
+
{
|
6038
|
+
...popperProps,
|
6039
|
+
ref: composedRefs,
|
6040
|
+
style: {
|
6041
|
+
// When we get the height of the content, it includes borders. If we were to set
|
6042
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
6043
|
+
boxSizing: "border-box",
|
6044
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
6045
|
+
maxHeight: "100%",
|
6046
|
+
...popperProps.style
|
6047
|
+
}
|
6048
|
+
}
|
6049
|
+
)
|
6050
|
+
}
|
6051
|
+
)
|
6052
|
+
}
|
6053
|
+
);
|
6054
|
+
});
|
6055
|
+
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
6056
|
+
var POPPER_POSITION_NAME = "SelectPopperPosition";
|
6057
|
+
var SelectPopperPosition = React__namespace.forwardRef((props, forwardedRef) => {
|
6058
|
+
const {
|
6059
|
+
__scopeSelect,
|
6060
|
+
align = "start",
|
6061
|
+
collisionPadding = CONTENT_MARGIN,
|
6062
|
+
...popperProps
|
6063
|
+
} = props;
|
6064
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
6065
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
6066
|
+
Content$1,
|
6067
|
+
{
|
6068
|
+
...popperScope,
|
6069
|
+
...popperProps,
|
6070
|
+
ref: forwardedRef,
|
6071
|
+
align,
|
6072
|
+
collisionPadding,
|
6073
|
+
style: {
|
6074
|
+
// Ensure border-box for floating-ui calculations
|
6075
|
+
boxSizing: "border-box",
|
6076
|
+
...popperProps.style,
|
6077
|
+
// re-namespace exposed content custom properties
|
6078
|
+
...{
|
6079
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
6080
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
6081
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
6082
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
6083
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
6084
|
+
}
|
6085
|
+
}
|
6086
|
+
}
|
6087
|
+
);
|
6088
|
+
});
|
6089
|
+
SelectPopperPosition.displayName = POPPER_POSITION_NAME;
|
6090
|
+
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME$1, {});
|
6091
|
+
var VIEWPORT_NAME = "SelectViewport";
|
6092
|
+
var SelectViewport = React__namespace.forwardRef(
|
6093
|
+
(props, forwardedRef) => {
|
6094
|
+
const { __scopeSelect, nonce, ...viewportProps } = props;
|
6095
|
+
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
|
6096
|
+
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
|
6097
|
+
const composedRefs = useComposedRefs$1(forwardedRef, contentContext.onViewportChange);
|
6098
|
+
const prevScrollTopRef = React__namespace.useRef(0);
|
6099
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
6100
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
6101
|
+
"style",
|
6102
|
+
{
|
6103
|
+
dangerouslySetInnerHTML: {
|
6104
|
+
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
|
6105
|
+
},
|
6106
|
+
nonce
|
6107
|
+
}
|
6108
|
+
),
|
6109
|
+
/* @__PURE__ */ jsxRuntime.jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsxRuntime.jsx(
|
6110
|
+
Primitive.div,
|
6111
|
+
{
|
6112
|
+
"data-radix-select-viewport": "",
|
6113
|
+
role: "presentation",
|
6114
|
+
...viewportProps,
|
6115
|
+
ref: composedRefs,
|
6116
|
+
style: {
|
6117
|
+
// we use position: 'relative' here on the `viewport` so that when we call
|
6118
|
+
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
6119
|
+
// (independent of the scrollUpButton).
|
6120
|
+
position: "relative",
|
6121
|
+
flex: 1,
|
6122
|
+
// Viewport should only be scrollable in the vertical direction.
|
6123
|
+
// This won't work in vertical writing modes, so we'll need to
|
6124
|
+
// revisit this if/when that is supported
|
6125
|
+
// https://developer.chrome.com/blog/vertical-form-controls
|
6126
|
+
overflow: "hidden auto",
|
6127
|
+
...viewportProps.style
|
6128
|
+
},
|
6129
|
+
onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
|
6130
|
+
const viewport = event.currentTarget;
|
6131
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
6132
|
+
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
6133
|
+
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
6134
|
+
if (scrolledBy > 0) {
|
6135
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
6136
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
6137
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
6138
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
6139
|
+
if (prevHeight < availableHeight) {
|
6140
|
+
const nextHeight = prevHeight + scrolledBy;
|
6141
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
6142
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
6143
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
6144
|
+
if (contentWrapper.style.bottom === "0px") {
|
6145
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
6146
|
+
contentWrapper.style.justifyContent = "flex-end";
|
6147
|
+
}
|
6148
|
+
}
|
6149
|
+
}
|
6150
|
+
}
|
6151
|
+
prevScrollTopRef.current = viewport.scrollTop;
|
6152
|
+
})
|
6153
|
+
}
|
6154
|
+
) })
|
6155
|
+
] });
|
6156
|
+
}
|
6157
|
+
);
|
6158
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
6159
|
+
var GROUP_NAME = "SelectGroup";
|
6160
|
+
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
6161
|
+
var SelectGroup = React__namespace.forwardRef(
|
6162
|
+
(props, forwardedRef) => {
|
6163
|
+
const { __scopeSelect, ...groupProps } = props;
|
6164
|
+
const groupId = useId();
|
6165
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsxRuntime.jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
6166
|
+
}
|
6167
|
+
);
|
6168
|
+
SelectGroup.displayName = GROUP_NAME;
|
6169
|
+
var LABEL_NAME = "SelectLabel";
|
6170
|
+
var SelectLabel = React__namespace.forwardRef(
|
6171
|
+
(props, forwardedRef) => {
|
6172
|
+
const { __scopeSelect, ...labelProps } = props;
|
6173
|
+
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
6174
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
6175
|
+
}
|
6176
|
+
);
|
6177
|
+
SelectLabel.displayName = LABEL_NAME;
|
6178
|
+
var ITEM_NAME = "SelectItem";
|
6179
|
+
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
6180
|
+
var SelectItem$1 = React__namespace.forwardRef(
|
6181
|
+
(props, forwardedRef) => {
|
6182
|
+
const {
|
6183
|
+
__scopeSelect,
|
6184
|
+
value,
|
6185
|
+
disabled = false,
|
6186
|
+
textValue: textValueProp,
|
6187
|
+
...itemProps
|
6188
|
+
} = props;
|
6189
|
+
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
6190
|
+
const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
|
6191
|
+
const isSelected = context.value === value;
|
6192
|
+
const [textValue, setTextValue] = React__namespace.useState(textValueProp ?? "");
|
6193
|
+
const [isFocused, setIsFocused] = React__namespace.useState(false);
|
6194
|
+
const composedRefs = useComposedRefs$1(
|
6195
|
+
forwardedRef,
|
6196
|
+
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
6197
|
+
);
|
6198
|
+
const textId = useId();
|
6199
|
+
const pointerTypeRef = React__namespace.useRef("touch");
|
6200
|
+
const handleSelect = () => {
|
6201
|
+
if (!disabled) {
|
6202
|
+
context.onValueChange(value);
|
6203
|
+
context.onOpenChange(false);
|
6204
|
+
}
|
6205
|
+
};
|
6206
|
+
if (value === "") {
|
6207
|
+
throw new Error(
|
6208
|
+
"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."
|
6209
|
+
);
|
6210
|
+
}
|
6211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
6212
|
+
SelectItemContextProvider,
|
6213
|
+
{
|
6214
|
+
scope: __scopeSelect,
|
6215
|
+
value,
|
6216
|
+
disabled,
|
6217
|
+
textId,
|
6218
|
+
isSelected,
|
6219
|
+
onItemTextChange: React__namespace.useCallback((node) => {
|
6220
|
+
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
6221
|
+
}, []),
|
6222
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
6223
|
+
Collection.ItemSlot,
|
6224
|
+
{
|
6225
|
+
scope: __scopeSelect,
|
6226
|
+
value,
|
6227
|
+
disabled,
|
6228
|
+
textValue,
|
6229
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
6230
|
+
Primitive.div,
|
6231
|
+
{
|
6232
|
+
role: "option",
|
6233
|
+
"aria-labelledby": textId,
|
6234
|
+
"data-highlighted": isFocused ? "" : void 0,
|
6235
|
+
"aria-selected": isSelected && isFocused,
|
6236
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
6237
|
+
"aria-disabled": disabled || void 0,
|
6238
|
+
"data-disabled": disabled ? "" : void 0,
|
6239
|
+
tabIndex: disabled ? void 0 : -1,
|
6240
|
+
...itemProps,
|
6241
|
+
ref: composedRefs,
|
6242
|
+
onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
|
6243
|
+
onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
|
6244
|
+
onClick: composeEventHandlers(itemProps.onClick, () => {
|
6245
|
+
if (pointerTypeRef.current !== "mouse") handleSelect();
|
6246
|
+
}),
|
6247
|
+
onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
|
6248
|
+
if (pointerTypeRef.current === "mouse") handleSelect();
|
6249
|
+
}),
|
6250
|
+
onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
|
6251
|
+
pointerTypeRef.current = event.pointerType;
|
6252
|
+
}),
|
6253
|
+
onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
|
6254
|
+
pointerTypeRef.current = event.pointerType;
|
6255
|
+
if (disabled) {
|
6256
|
+
contentContext.onItemLeave?.();
|
6257
|
+
} else if (pointerTypeRef.current === "mouse") {
|
6258
|
+
event.currentTarget.focus({ preventScroll: true });
|
6259
|
+
}
|
6260
|
+
}),
|
6261
|
+
onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
|
6262
|
+
if (event.currentTarget === document.activeElement) {
|
6263
|
+
contentContext.onItemLeave?.();
|
6264
|
+
}
|
6265
|
+
}),
|
6266
|
+
onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
|
6267
|
+
const isTypingAhead = contentContext.searchRef?.current !== "";
|
6268
|
+
if (isTypingAhead && event.key === " ") return;
|
6269
|
+
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
6270
|
+
if (event.key === " ") event.preventDefault();
|
6271
|
+
})
|
6272
|
+
}
|
6273
|
+
)
|
6274
|
+
}
|
6275
|
+
)
|
6276
|
+
}
|
6277
|
+
);
|
6278
|
+
}
|
6279
|
+
);
|
6280
|
+
SelectItem$1.displayName = ITEM_NAME;
|
6281
|
+
var ITEM_TEXT_NAME = "SelectItemText";
|
6282
|
+
var SelectItemText = React__namespace.forwardRef(
|
6283
|
+
(props, forwardedRef) => {
|
6284
|
+
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
6285
|
+
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
6286
|
+
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
6287
|
+
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
6288
|
+
const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
|
6289
|
+
const [itemTextNode, setItemTextNode] = React__namespace.useState(null);
|
6290
|
+
const composedRefs = useComposedRefs$1(
|
6291
|
+
forwardedRef,
|
6292
|
+
(node) => setItemTextNode(node),
|
6293
|
+
itemContext.onItemTextChange,
|
6294
|
+
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
6295
|
+
);
|
6296
|
+
const textContent = itemTextNode?.textContent;
|
6297
|
+
const nativeOption = React__namespace.useMemo(
|
6298
|
+
() => /* @__PURE__ */ jsxRuntime.jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
|
6299
|
+
[itemContext.disabled, itemContext.value, textContent]
|
6300
|
+
);
|
6301
|
+
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
6302
|
+
useLayoutEffect2(() => {
|
6303
|
+
onNativeOptionAdd(nativeOption);
|
6304
|
+
return () => onNativeOptionRemove(nativeOption);
|
6305
|
+
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
6306
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
6307
|
+
/* @__PURE__ */ jsxRuntime.jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
6308
|
+
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM__namespace.createPortal(itemTextProps.children, context.valueNode) : null
|
6309
|
+
] });
|
6310
|
+
}
|
6311
|
+
);
|
6312
|
+
SelectItemText.displayName = ITEM_TEXT_NAME;
|
6313
|
+
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
6314
|
+
var SelectItemIndicator = React__namespace.forwardRef(
|
6315
|
+
(props, forwardedRef) => {
|
6316
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
6317
|
+
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
6318
|
+
return itemContext.isSelected ? /* @__PURE__ */ jsxRuntime.jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
6319
|
+
}
|
6320
|
+
);
|
6321
|
+
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
6322
|
+
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
6323
|
+
var SelectScrollUpButton = React__namespace.forwardRef((props, forwardedRef) => {
|
6324
|
+
const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
6325
|
+
const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
6326
|
+
const [canScrollUp, setCanScrollUp] = React__namespace.useState(false);
|
6327
|
+
const composedRefs = useComposedRefs$1(forwardedRef, viewportContext.onScrollButtonChange);
|
6328
|
+
useLayoutEffect2(() => {
|
6329
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
6330
|
+
let handleScroll2 = function() {
|
6331
|
+
const canScrollUp2 = viewport.scrollTop > 0;
|
6332
|
+
setCanScrollUp(canScrollUp2);
|
6333
|
+
};
|
6334
|
+
const viewport = contentContext.viewport;
|
6335
|
+
handleScroll2();
|
6336
|
+
viewport.addEventListener("scroll", handleScroll2);
|
6337
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
6338
|
+
}
|
6339
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
6340
|
+
return canScrollUp ? /* @__PURE__ */ jsxRuntime.jsx(
|
6341
|
+
SelectScrollButtonImpl,
|
6342
|
+
{
|
6343
|
+
...props,
|
6344
|
+
ref: composedRefs,
|
6345
|
+
onAutoScroll: () => {
|
6346
|
+
const { viewport, selectedItem } = contentContext;
|
6347
|
+
if (viewport && selectedItem) {
|
6348
|
+
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
6349
|
+
}
|
6350
|
+
}
|
6351
|
+
}
|
6352
|
+
) : null;
|
6353
|
+
});
|
6354
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
6355
|
+
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
6356
|
+
var SelectScrollDownButton = React__namespace.forwardRef((props, forwardedRef) => {
|
6357
|
+
const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
6358
|
+
const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
6359
|
+
const [canScrollDown, setCanScrollDown] = React__namespace.useState(false);
|
6360
|
+
const composedRefs = useComposedRefs$1(forwardedRef, viewportContext.onScrollButtonChange);
|
6361
|
+
useLayoutEffect2(() => {
|
6362
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
6363
|
+
let handleScroll2 = function() {
|
6364
|
+
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
6365
|
+
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
6366
|
+
setCanScrollDown(canScrollDown2);
|
6367
|
+
};
|
6368
|
+
const viewport = contentContext.viewport;
|
6369
|
+
handleScroll2();
|
6370
|
+
viewport.addEventListener("scroll", handleScroll2);
|
6371
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
6372
|
+
}
|
6373
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
6374
|
+
return canScrollDown ? /* @__PURE__ */ jsxRuntime.jsx(
|
6375
|
+
SelectScrollButtonImpl,
|
6376
|
+
{
|
6377
|
+
...props,
|
6378
|
+
ref: composedRefs,
|
6379
|
+
onAutoScroll: () => {
|
6380
|
+
const { viewport, selectedItem } = contentContext;
|
6381
|
+
if (viewport && selectedItem) {
|
6382
|
+
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
6383
|
+
}
|
6384
|
+
}
|
6385
|
+
}
|
6386
|
+
) : null;
|
6387
|
+
});
|
6388
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
6389
|
+
var SelectScrollButtonImpl = React__namespace.forwardRef((props, forwardedRef) => {
|
6390
|
+
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
6391
|
+
const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
|
6392
|
+
const autoScrollTimerRef = React__namespace.useRef(null);
|
6393
|
+
const getItems = useCollection(__scopeSelect);
|
6394
|
+
const clearAutoScrollTimer = React__namespace.useCallback(() => {
|
6395
|
+
if (autoScrollTimerRef.current !== null) {
|
6396
|
+
window.clearInterval(autoScrollTimerRef.current);
|
6397
|
+
autoScrollTimerRef.current = null;
|
6398
|
+
}
|
6399
|
+
}, []);
|
6400
|
+
React__namespace.useEffect(() => {
|
6401
|
+
return () => clearAutoScrollTimer();
|
6402
|
+
}, [clearAutoScrollTimer]);
|
6403
|
+
useLayoutEffect2(() => {
|
6404
|
+
const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
|
6405
|
+
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
6406
|
+
}, [getItems]);
|
6407
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
6408
|
+
Primitive.div,
|
6409
|
+
{
|
6410
|
+
"aria-hidden": true,
|
6411
|
+
...scrollIndicatorProps,
|
6412
|
+
ref: forwardedRef,
|
6413
|
+
style: { flexShrink: 0, ...scrollIndicatorProps.style },
|
6414
|
+
onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
|
6415
|
+
if (autoScrollTimerRef.current === null) {
|
6416
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
6417
|
+
}
|
6418
|
+
}),
|
6419
|
+
onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
|
6420
|
+
contentContext.onItemLeave?.();
|
6421
|
+
if (autoScrollTimerRef.current === null) {
|
6422
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
6423
|
+
}
|
6424
|
+
}),
|
6425
|
+
onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
|
6426
|
+
clearAutoScrollTimer();
|
6427
|
+
})
|
6428
|
+
}
|
6429
|
+
);
|
6430
|
+
});
|
6431
|
+
var SEPARATOR_NAME = "SelectSeparator";
|
6432
|
+
var SelectSeparator = React__namespace.forwardRef(
|
6433
|
+
(props, forwardedRef) => {
|
6434
|
+
const { __scopeSelect, ...separatorProps } = props;
|
6435
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
6436
|
+
}
|
6437
|
+
);
|
6438
|
+
SelectSeparator.displayName = SEPARATOR_NAME;
|
6439
|
+
var ARROW_NAME$1 = "SelectArrow";
|
6440
|
+
var SelectArrow = React__namespace.forwardRef(
|
6441
|
+
(props, forwardedRef) => {
|
6442
|
+
const { __scopeSelect, ...arrowProps } = props;
|
6443
|
+
const popperScope = usePopperScope$1(__scopeSelect);
|
6444
|
+
const context = useSelectContext(ARROW_NAME$1, __scopeSelect);
|
6445
|
+
const contentContext = useSelectContentContext(ARROW_NAME$1, __scopeSelect);
|
6446
|
+
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
6447
|
+
}
|
6448
|
+
);
|
6449
|
+
SelectArrow.displayName = ARROW_NAME$1;
|
6450
|
+
function shouldShowPlaceholder(value) {
|
6451
|
+
return value === "" || value === void 0;
|
6452
|
+
}
|
6453
|
+
var BubbleSelect = React__namespace.forwardRef(
|
6454
|
+
(props, forwardedRef) => {
|
6455
|
+
const { value, ...selectProps } = props;
|
6456
|
+
const ref = React__namespace.useRef(null);
|
6457
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref);
|
6458
|
+
const prevValue = usePrevious(value);
|
6459
|
+
React__namespace.useEffect(() => {
|
6460
|
+
const select = ref.current;
|
6461
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
6462
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
6463
|
+
selectProto,
|
6464
|
+
"value"
|
6465
|
+
);
|
6466
|
+
const setValue = descriptor.set;
|
6467
|
+
if (prevValue !== value && setValue) {
|
6468
|
+
const event = new Event("change", { bubbles: true });
|
6469
|
+
setValue.call(select, value);
|
6470
|
+
select.dispatchEvent(event);
|
6471
|
+
}
|
6472
|
+
}, [prevValue, value]);
|
6473
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("select", { ...selectProps, ref: composedRefs, defaultValue: value }) });
|
6474
|
+
}
|
6475
|
+
);
|
6476
|
+
BubbleSelect.displayName = "BubbleSelect";
|
6477
|
+
function useTypeaheadSearch(onSearchChange) {
|
6478
|
+
const handleSearchChange = useCallbackRef$2(onSearchChange);
|
6479
|
+
const searchRef = React__namespace.useRef("");
|
6480
|
+
const timerRef = React__namespace.useRef(0);
|
6481
|
+
const handleTypeaheadSearch = React__namespace.useCallback(
|
6482
|
+
(key) => {
|
6483
|
+
const search = searchRef.current + key;
|
6484
|
+
handleSearchChange(search);
|
6485
|
+
(function updateSearch(value) {
|
6486
|
+
searchRef.current = value;
|
6487
|
+
window.clearTimeout(timerRef.current);
|
6488
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
6489
|
+
})(search);
|
6490
|
+
},
|
6491
|
+
[handleSearchChange]
|
6492
|
+
);
|
6493
|
+
const resetTypeahead = React__namespace.useCallback(() => {
|
6494
|
+
searchRef.current = "";
|
6495
|
+
window.clearTimeout(timerRef.current);
|
6496
|
+
}, []);
|
6497
|
+
React__namespace.useEffect(() => {
|
6498
|
+
return () => window.clearTimeout(timerRef.current);
|
6499
|
+
}, []);
|
6500
|
+
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
6501
|
+
}
|
6502
|
+
function findNextItem(items, search, currentItem) {
|
6503
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
6504
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
6505
|
+
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
6506
|
+
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
6507
|
+
const excludeCurrentItem = normalizedSearch.length === 1;
|
6508
|
+
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
6509
|
+
const nextItem = wrappedItems.find(
|
6510
|
+
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
6511
|
+
);
|
6512
|
+
return nextItem !== currentItem ? nextItem : void 0;
|
6513
|
+
}
|
6514
|
+
function wrapArray(array, startIndex) {
|
6515
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
6516
|
+
}
|
6517
|
+
|
6518
|
+
var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
|
6519
|
+
createPopperScope
|
6520
|
+
]);
|
6521
|
+
var usePopperScope = createPopperScope();
|
6522
|
+
var PROVIDER_NAME = "TooltipProvider";
|
6523
|
+
var DEFAULT_DELAY_DURATION = 700;
|
6524
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
6525
|
+
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
6526
|
+
var TooltipProvider = (props) => {
|
6527
|
+
const {
|
6528
|
+
__scopeTooltip,
|
6529
|
+
delayDuration = DEFAULT_DELAY_DURATION,
|
6530
|
+
skipDelayDuration = 300,
|
6531
|
+
disableHoverableContent = false,
|
6532
|
+
children
|
6533
|
+
} = props;
|
6534
|
+
const [isOpenDelayed, setIsOpenDelayed] = React__namespace.useState(true);
|
6535
|
+
const isPointerInTransitRef = React__namespace.useRef(false);
|
6536
|
+
const skipDelayTimerRef = React__namespace.useRef(0);
|
6537
|
+
React__namespace.useEffect(() => {
|
6538
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
6539
|
+
return () => window.clearTimeout(skipDelayTimer);
|
6540
|
+
}, []);
|
6541
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
6542
|
+
TooltipProviderContextProvider,
|
6543
|
+
{
|
6544
|
+
scope: __scopeTooltip,
|
6545
|
+
isOpenDelayed,
|
6546
|
+
delayDuration,
|
6547
|
+
onOpen: React__namespace.useCallback(() => {
|
6548
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
6549
|
+
setIsOpenDelayed(false);
|
6550
|
+
}, []),
|
6551
|
+
onClose: React__namespace.useCallback(() => {
|
6552
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
6553
|
+
skipDelayTimerRef.current = window.setTimeout(
|
6554
|
+
() => setIsOpenDelayed(true),
|
6555
|
+
skipDelayDuration
|
6556
|
+
);
|
6557
|
+
}, [skipDelayDuration]),
|
6558
|
+
isPointerInTransitRef,
|
6559
|
+
onPointerInTransitChange: React__namespace.useCallback((inTransit) => {
|
6560
|
+
isPointerInTransitRef.current = inTransit;
|
6561
|
+
}, []),
|
6562
|
+
disableHoverableContent,
|
6563
|
+
children
|
6564
|
+
}
|
6565
|
+
);
|
6566
|
+
};
|
6567
|
+
TooltipProvider.displayName = PROVIDER_NAME;
|
6568
|
+
var TOOLTIP_NAME = "Tooltip";
|
6569
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
6570
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
6571
|
+
var TooltipTrigger = React__namespace.forwardRef(
|
6572
|
+
(props, forwardedRef) => {
|
6573
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
6574
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
6575
|
+
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
|
6576
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
6577
|
+
const ref = React__namespace.useRef(null);
|
6578
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref, context.onTriggerChange);
|
6579
|
+
const isPointerDownRef = React__namespace.useRef(false);
|
6580
|
+
const hasPointerMoveOpenedRef = React__namespace.useRef(false);
|
6581
|
+
const handlePointerUp = React__namespace.useCallback(() => isPointerDownRef.current = false, []);
|
6582
|
+
React__namespace.useEffect(() => {
|
6583
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
6584
|
+
}, [handlePointerUp]);
|
6585
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsxRuntime.jsx(
|
6586
|
+
Primitive.button,
|
6587
|
+
{
|
6588
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
6589
|
+
"data-state": context.stateAttribute,
|
6590
|
+
...triggerProps,
|
6591
|
+
ref: composedRefs,
|
6592
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
6593
|
+
if (event.pointerType === "touch") return;
|
6594
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
6595
|
+
context.onTriggerEnter();
|
6596
|
+
hasPointerMoveOpenedRef.current = true;
|
6597
|
+
}
|
6598
|
+
}),
|
6599
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
6600
|
+
context.onTriggerLeave();
|
6601
|
+
hasPointerMoveOpenedRef.current = false;
|
6602
|
+
}),
|
6603
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
6604
|
+
isPointerDownRef.current = true;
|
6605
|
+
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
6606
|
+
}),
|
6607
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
6608
|
+
if (!isPointerDownRef.current) context.onOpen();
|
6609
|
+
}),
|
6610
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
6611
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
6612
|
+
}
|
6613
|
+
) });
|
6614
|
+
}
|
6615
|
+
);
|
6616
|
+
TooltipTrigger.displayName = TRIGGER_NAME;
|
6617
|
+
var PORTAL_NAME = "TooltipPortal";
|
6618
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
|
6619
|
+
forceMount: void 0
|
6620
|
+
});
|
6621
|
+
var CONTENT_NAME = "TooltipContent";
|
6622
|
+
var TooltipContent = React__namespace.forwardRef(
|
6623
|
+
(props, forwardedRef) => {
|
6624
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
6625
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
6626
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
6627
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Presence, { present: forceMount || context.open, children: context.disableHoverableContent ? /* @__PURE__ */ jsxRuntime.jsx(TooltipContentImpl, { side, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsxRuntime.jsx(TooltipContentHoverable, { side, ...contentProps, ref: forwardedRef }) });
|
6628
|
+
}
|
6629
|
+
);
|
6630
|
+
var TooltipContentHoverable = React__namespace.forwardRef((props, forwardedRef) => {
|
6631
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
6632
|
+
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
|
6633
|
+
const ref = React__namespace.useRef(null);
|
6634
|
+
const composedRefs = useComposedRefs$1(forwardedRef, ref);
|
6635
|
+
const [pointerGraceArea, setPointerGraceArea] = React__namespace.useState(null);
|
6636
|
+
const { trigger, onClose } = context;
|
6637
|
+
const content = ref.current;
|
6638
|
+
const { onPointerInTransitChange } = providerContext;
|
6639
|
+
const handleRemoveGraceArea = React__namespace.useCallback(() => {
|
6640
|
+
setPointerGraceArea(null);
|
6641
|
+
onPointerInTransitChange(false);
|
6642
|
+
}, [onPointerInTransitChange]);
|
6643
|
+
const handleCreateGraceArea = React__namespace.useCallback(
|
6644
|
+
(event, hoverTarget) => {
|
6645
|
+
const currentTarget = event.currentTarget;
|
6646
|
+
const exitPoint = { x: event.clientX, y: event.clientY };
|
6647
|
+
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
6648
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
6649
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
6650
|
+
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
6651
|
+
setPointerGraceArea(graceArea);
|
6652
|
+
onPointerInTransitChange(true);
|
6653
|
+
},
|
6654
|
+
[onPointerInTransitChange]
|
6655
|
+
);
|
6656
|
+
React__namespace.useEffect(() => {
|
6657
|
+
return () => handleRemoveGraceArea();
|
6658
|
+
}, [handleRemoveGraceArea]);
|
6659
|
+
React__namespace.useEffect(() => {
|
6660
|
+
if (trigger && content) {
|
6661
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
6662
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
6663
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
6664
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
6665
|
+
return () => {
|
6666
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
6667
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
6668
|
+
};
|
6669
|
+
}
|
6670
|
+
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
6671
|
+
React__namespace.useEffect(() => {
|
6672
|
+
if (pointerGraceArea) {
|
6673
|
+
const handleTrackPointerGrace = (event) => {
|
6674
|
+
const target = event.target;
|
6675
|
+
const pointerPosition = { x: event.clientX, y: event.clientY };
|
6676
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
6677
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
6678
|
+
if (hasEnteredTarget) {
|
6679
|
+
handleRemoveGraceArea();
|
6680
|
+
} else if (isPointerOutsideGraceArea) {
|
6681
|
+
handleRemoveGraceArea();
|
6682
|
+
onClose();
|
6683
|
+
}
|
6684
|
+
};
|
6685
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
6686
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
6687
|
+
}
|
6688
|
+
}, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);
|
6689
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipContentImpl, { ...props, ref: composedRefs });
|
6690
|
+
});
|
6691
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
|
6692
|
+
var TooltipContentImpl = React__namespace.forwardRef(
|
6693
|
+
(props, forwardedRef) => {
|
6694
|
+
const {
|
6695
|
+
__scopeTooltip,
|
6696
|
+
children,
|
6697
|
+
"aria-label": ariaLabel,
|
6698
|
+
onEscapeKeyDown,
|
6699
|
+
onPointerDownOutside,
|
6700
|
+
...contentProps
|
6701
|
+
} = props;
|
6702
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
6703
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
6704
|
+
const { onClose } = context;
|
6705
|
+
React__namespace.useEffect(() => {
|
6706
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
6707
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
6708
|
+
}, [onClose]);
|
6709
|
+
React__namespace.useEffect(() => {
|
6710
|
+
if (context.trigger) {
|
6711
|
+
const handleScroll = (event) => {
|
6712
|
+
const target = event.target;
|
6713
|
+
if (target?.contains(context.trigger)) onClose();
|
6714
|
+
};
|
6715
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
6716
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
6717
|
+
}
|
6718
|
+
}, [context.trigger, onClose]);
|
6719
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
6720
|
+
DismissableLayer,
|
6721
|
+
{
|
6722
|
+
asChild: true,
|
6723
|
+
disableOutsidePointerEvents: false,
|
6724
|
+
onEscapeKeyDown,
|
5541
6725
|
onPointerDownOutside,
|
5542
6726
|
onFocusOutside: (event) => event.preventDefault(),
|
5543
6727
|
onDismiss: onClose,
|
@@ -10575,6 +11759,41 @@ function useReactTable(options) {
|
|
10575
11759
|
return tableRef.current;
|
10576
11760
|
}
|
10577
11761
|
|
11762
|
+
const HttpStatusCode = {
|
11763
|
+
// 4xx Client Error
|
11764
|
+
BAD_REQUEST: 400,
|
11765
|
+
UNAUTHORIZED: 401,
|
11766
|
+
PAYMENT_REQUIRED: 402,
|
11767
|
+
FORBIDDEN: 403,
|
11768
|
+
NOT_FOUND: 404,
|
11769
|
+
METHOD_NOT_ALLOWED: 405,
|
11770
|
+
NOT_ACCEPTABLE: 406,
|
11771
|
+
CONFLICT: 409,
|
11772
|
+
GONE: 410,
|
11773
|
+
PRECONDITION_FAILED: 412,
|
11774
|
+
PAYLOAD_TOO_LARGE: 413,
|
11775
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
11776
|
+
RANGE_NOT_SATISFIABLE: 416,
|
11777
|
+
TOO_MANY_REQUESTS: 429,
|
11778
|
+
// 5xx Server Error
|
11779
|
+
INTERNAL_SERVER_ERROR: 500,
|
11780
|
+
NOT_IMPLEMENTED: 501,
|
11781
|
+
BAD_GATEWAY: 502,
|
11782
|
+
SERVICE_UNAVAILABLE: 503,
|
11783
|
+
GATEWAY_TIMEOUT: 504,
|
11784
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
11785
|
+
};
|
11786
|
+
const CustomBehavior = {
|
11787
|
+
DEFAULT: "default",
|
11788
|
+
DELAY: "delay",
|
11789
|
+
RETURN_NULL: "return null",
|
11790
|
+
NETWORK_ERROR: "network error",
|
11791
|
+
};
|
11792
|
+
const HttpHandlerBehavior = {
|
11793
|
+
...CustomBehavior,
|
11794
|
+
...HttpStatusCode,
|
11795
|
+
};
|
11796
|
+
|
10578
11797
|
const dummyUrl = "/msw-dev-tool-dummy";
|
10579
11798
|
const dummyHandler = msw.http.get(dummyUrl, () => { });
|
10580
11799
|
|
@@ -10587,7 +11806,7 @@ const convertHandlers = (handlers) => {
|
|
10587
11806
|
const flattenHandlers = handlers.reduce((acc, _handler) => {
|
10588
11807
|
// Current, GraphQL & WebSocketHandler is not supported.
|
10589
11808
|
const handler = _handler;
|
10590
|
-
if (!(
|
11809
|
+
if (!isHttpHandler(handler)) {
|
10591
11810
|
unsupportedHandlers.push(handler);
|
10592
11811
|
return acc;
|
10593
11812
|
}
|
@@ -10599,6 +11818,7 @@ const convertHandlers = (handlers) => {
|
|
10599
11818
|
method,
|
10600
11819
|
enabled: true,
|
10601
11820
|
handler,
|
11821
|
+
behavior: HttpHandlerBehavior.DEFAULT,
|
10602
11822
|
});
|
10603
11823
|
return acc;
|
10604
11824
|
}, []);
|
@@ -10631,6 +11851,33 @@ const initMSWDevToolStore = (worker) => {
|
|
10631
11851
|
}, {});
|
10632
11852
|
return { worker, flattenHandlers, unsupportedHandlers, handlerRowSelection };
|
10633
11853
|
};
|
11854
|
+
const isHttpHandler = (handler) => {
|
11855
|
+
return ("info" in handler && "method" in handler.info && "path" in handler.info);
|
11856
|
+
};
|
11857
|
+
const getHandlerResponseByBehavior = async (behavior, originalResolverCallback) => {
|
11858
|
+
if (!behavior || behavior === CustomBehavior.DEFAULT) {
|
11859
|
+
return originalResolverCallback();
|
11860
|
+
}
|
11861
|
+
if (behavior === CustomBehavior.DELAY) {
|
11862
|
+
await msw.delay("infinite");
|
11863
|
+
return new Response();
|
11864
|
+
}
|
11865
|
+
if (behavior === CustomBehavior.RETURN_NULL) {
|
11866
|
+
return new msw.HttpResponse(null, { status: 200 });
|
11867
|
+
}
|
11868
|
+
if (behavior === CustomBehavior.NETWORK_ERROR) {
|
11869
|
+
return msw.HttpResponse.error();
|
11870
|
+
}
|
11871
|
+
for (const code of Object.values(HttpStatusCode)) {
|
11872
|
+
if (behavior === code) {
|
11873
|
+
return new msw.HttpResponse(null, {
|
11874
|
+
status: code,
|
11875
|
+
statusText: `${code} triggered by dev tools.`,
|
11876
|
+
});
|
11877
|
+
}
|
11878
|
+
}
|
11879
|
+
return originalResolverCallback();
|
11880
|
+
};
|
10634
11881
|
|
10635
11882
|
var lodash = {exports: {}};
|
10636
11883
|
|
@@ -27841,26 +29088,52 @@ const useHandlerStore = zustand.create((set, get) => ({
|
|
27841
29088
|
worker: null,
|
27842
29089
|
restHandlers: [],
|
27843
29090
|
handlerRowSelection: {},
|
29091
|
+
setupDevToolWorker: (...handlers) => {
|
29092
|
+
const _handlers = handlers.map((handler) => {
|
29093
|
+
if (!isHttpHandler(handler)) {
|
29094
|
+
return handler;
|
29095
|
+
}
|
29096
|
+
const originalResolver = handler.resolver;
|
29097
|
+
handler.resolver = async (args) => {
|
29098
|
+
const id = getRowId({
|
29099
|
+
path: handler.info.path.toString(),
|
29100
|
+
method: handler.info.method.toString(),
|
29101
|
+
});
|
29102
|
+
const behavior = get().getHandlerBehavior(id);
|
29103
|
+
return await getHandlerResponseByBehavior(behavior, () => originalResolver(args));
|
29104
|
+
};
|
29105
|
+
return handler;
|
29106
|
+
});
|
29107
|
+
const worker = browser.setupWorker(..._handlers);
|
29108
|
+
const { flattenHandlers, handlerRowSelection, unsupportedHandlers } = initMSWDevToolStore(worker);
|
29109
|
+
set({
|
29110
|
+
worker,
|
29111
|
+
flattenHandlers,
|
29112
|
+
handlerRowSelection,
|
29113
|
+
restHandlers: unsupportedHandlers,
|
29114
|
+
});
|
29115
|
+
return worker;
|
29116
|
+
},
|
27844
29117
|
initMSWDevTool: (_worker) => {
|
27845
29118
|
const { worker, flattenHandlers, handlerRowSelection, unsupportedHandlers, } = initMSWDevToolStore(_worker);
|
27846
|
-
set({ worker });
|
27847
|
-
set({ flattenHandlers });
|
27848
29119
|
set({
|
29120
|
+
worker,
|
29121
|
+
flattenHandlers,
|
27849
29122
|
handlerRowSelection,
|
29123
|
+
restHandlers: unsupportedHandlers,
|
27850
29124
|
});
|
27851
|
-
set({ restHandlers: unsupportedHandlers });
|
27852
29125
|
return worker;
|
27853
29126
|
},
|
27854
29127
|
resetMSWDevTool: () => {
|
27855
29128
|
const _worker = get().getWorker();
|
27856
29129
|
_worker.resetHandlers();
|
27857
29130
|
const { worker, flattenHandlers, handlerRowSelection, unsupportedHandlers, } = initMSWDevToolStore(_worker);
|
27858
|
-
set({ worker });
|
27859
|
-
set({ flattenHandlers });
|
27860
29131
|
set({
|
29132
|
+
worker,
|
29133
|
+
flattenHandlers,
|
27861
29134
|
handlerRowSelection,
|
29135
|
+
restHandlers: unsupportedHandlers,
|
27862
29136
|
});
|
27863
|
-
set({ restHandlers: unsupportedHandlers });
|
27864
29137
|
},
|
27865
29138
|
handleHandlerRowSelectionChange: (updater) => {
|
27866
29139
|
const worker = get().getWorker();
|
@@ -27890,103 +29163,28 @@ const useHandlerStore = zustand.create((set, get) => ({
|
|
27890
29163
|
throw new Error("Worker is not initialized");
|
27891
29164
|
return worker;
|
27892
29165
|
},
|
27893
|
-
|
27894
|
-
|
27895
|
-
|
27896
|
-
|
27897
|
-
|
27898
|
-
|
27899
|
-
|
27900
|
-
return
|
27901
|
-
|
27902
|
-
|
27903
|
-
|
27904
|
-
|
27905
|
-
|
27906
|
-
|
27907
|
-
|
27908
|
-
|
27909
|
-
} })),
|
27910
|
-
}),
|
27911
|
-
columnHelper.accessor("path", {
|
27912
|
-
header: "Protocol",
|
27913
|
-
cell: ({ row }) => {
|
27914
|
-
const protocol = new URL(row.original.path, location.href).protocol;
|
27915
|
-
return protocol;
|
27916
|
-
},
|
27917
|
-
id: "protocol",
|
27918
|
-
}),
|
27919
|
-
columnHelper.accessor("path", {
|
27920
|
-
header: "Host",
|
27921
|
-
cell: ({ row }) => {
|
27922
|
-
const host = new URL(row.original.path, location.href).host;
|
27923
|
-
return host;
|
27924
|
-
},
|
27925
|
-
id: "host",
|
27926
|
-
}),
|
27927
|
-
columnHelper.accessor("path", {
|
27928
|
-
header: "Path",
|
27929
|
-
cell: ({ row }) => {
|
27930
|
-
const path = new URL(row.original.path, location.href).pathname;
|
27931
|
-
return path;
|
27932
|
-
},
|
27933
|
-
id: "path",
|
27934
|
-
}),
|
27935
|
-
columnHelper.accessor("method", {
|
27936
|
-
header: "Method",
|
27937
|
-
cell: ({ row }) => row.original.method,
|
29166
|
+
getFlattenHandlerById: (id) => {
|
29167
|
+
return get().flattenHandlers.find((handler) => handler.id === id);
|
29168
|
+
},
|
29169
|
+
getHandlerBehavior: (id) => {
|
29170
|
+
const handler = get().getFlattenHandlerById(id);
|
29171
|
+
if (!handler)
|
29172
|
+
return undefined;
|
29173
|
+
return handler.behavior;
|
29174
|
+
},
|
29175
|
+
setHandlerBehavior: (id, behavior) => {
|
29176
|
+
set({
|
29177
|
+
flattenHandlers: get().flattenHandlers.map((handler) => {
|
29178
|
+
if (handler.id === id) {
|
29179
|
+
return { ...handler, behavior };
|
29180
|
+
}
|
29181
|
+
return handler;
|
27938
29182
|
}),
|
27939
|
-
|
27940
|
-
},
|
27941
|
-
const table = useReactTable({
|
27942
|
-
columns,
|
27943
|
-
data: flattenHandlers,
|
27944
|
-
getCoreRowModel: getCoreRowModel(),
|
27945
|
-
state: {
|
27946
|
-
rowSelection: handlerRowSelection,
|
27947
|
-
},
|
27948
|
-
onRowSelectionChange: handleHandlerRowSelectionChange,
|
27949
|
-
getRowId: (row) => row.id,
|
27950
|
-
enableRowSelection: true,
|
27951
|
-
});
|
27952
|
-
return table;
|
27953
|
-
};
|
27954
|
-
|
27955
|
-
const useUiControlStore = zustand.create((set) => ({
|
27956
|
-
currentHandler: null,
|
27957
|
-
setDebuggerHandler: (handler) => set({ currentHandler: handler }),
|
29183
|
+
});
|
29184
|
+
},
|
27958
29185
|
}));
|
27959
|
-
|
27960
|
-
const
|
27961
|
-
const table = useFlattenHandlersTable();
|
27962
|
-
const { setDebuggerHandler } = useUiControlStore();
|
27963
|
-
const currentHandler = useUiControlStore((state) => state.currentHandler);
|
27964
|
-
return (React.createElement(p$3, { style: { flex: 3, overflowY: "auto" }, direction: "column", gap: "4" },
|
27965
|
-
React.createElement(r$8, { as: "h2", size: "5" }, "Handlers"),
|
27966
|
-
React.createElement(m, { onDragStart: (e) => e.stopPropagation(), style: { userSelect: "text" } },
|
27967
|
-
React.createElement(d, null, table.getHeaderGroups().map((headerGroup) => (React.createElement(P, { key: headerGroup.id }, headerGroup.headers.map((header) => (React.createElement(f$1, { key: header.id }, header.isPlaceholder
|
27968
|
-
? null
|
27969
|
-
: flexRender(header.column.columnDef.header, header.getContext())))))))),
|
27970
|
-
React.createElement(b, null, table.getRowModel().rows.map((row) => (React.createElement(P, { key: row.id, align: "center", className: `msw-dt-http-control-row ${row.original.handler === currentHandler && "msw-dt-current-row"}`, onClick: () => {
|
27971
|
-
setDebuggerHandler(row.original.handler);
|
27972
|
-
} }, row.getVisibleCells().map((cell) => (React.createElement(T, { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())))))))))));
|
27973
|
-
};
|
27974
|
-
|
27975
|
-
const PathParamSetter = ({ paramValues, onParamChange, }) => {
|
27976
|
-
return (paramValues &&
|
27977
|
-
Object.keys(paramValues).length > 0 && (React.createElement(p$6, null,
|
27978
|
-
React.createElement(Label, null, "Path Parameters"),
|
27979
|
-
React.createElement(p$3, { direction: "column", gap: "2", py: "2" }, Object.entries(paramValues).map(([key, value]) => (React.createElement(p$3, { align: "center", gap: "2", key: key },
|
27980
|
-
React.createElement(Label, { htmlFor: `param-${key}`, style: { width: "160px" } },
|
27981
|
-
key,
|
27982
|
-
":"),
|
27983
|
-
React.createElement(u, { id: `param-${key}`, type: "text", value: value, onChange: (e) => onParamChange(key, e.target.value), placeholder: "value of path param", style: {
|
27984
|
-
padding: "4px 8px",
|
27985
|
-
borderRadius: "4px",
|
27986
|
-
border: "1px solid #ccc",
|
27987
|
-
width: "180px",
|
27988
|
-
} }))))))));
|
27989
|
-
};
|
29186
|
+
const initMSWDevTool = useHandlerStore.getState().initMSWDevTool;
|
29187
|
+
const setupDevToolWorker = useHandlerStore.getState().setupDevToolWorker;
|
27990
29188
|
|
27991
29189
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
27992
29190
|
if (source == null) return {};
|
@@ -28003,6 +29201,72 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
28003
29201
|
return target;
|
28004
29202
|
}
|
28005
29203
|
|
29204
|
+
var _excluded$T = ["color"];
|
29205
|
+
var CheckIcon = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
29206
|
+
var _ref$color = _ref.color,
|
29207
|
+
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
|
29208
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$T);
|
29209
|
+
|
29210
|
+
return React.createElement("svg", Object.assign({
|
29211
|
+
width: "15",
|
29212
|
+
height: "15",
|
29213
|
+
viewBox: "0 0 15 15",
|
29214
|
+
fill: "none",
|
29215
|
+
xmlns: "http://www.w3.org/2000/svg"
|
29216
|
+
}, props, {
|
29217
|
+
ref: forwardedRef
|
29218
|
+
}), React.createElement("path", {
|
29219
|
+
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",
|
29220
|
+
fill: color,
|
29221
|
+
fillRule: "evenodd",
|
29222
|
+
clipRule: "evenodd"
|
29223
|
+
}));
|
29224
|
+
});
|
29225
|
+
|
29226
|
+
var _excluded$W = ["color"];
|
29227
|
+
var ChevronDownIcon = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
29228
|
+
var _ref$color = _ref.color,
|
29229
|
+
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
|
29230
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$W);
|
29231
|
+
|
29232
|
+
return React.createElement("svg", Object.assign({
|
29233
|
+
width: "15",
|
29234
|
+
height: "15",
|
29235
|
+
viewBox: "0 0 15 15",
|
29236
|
+
fill: "none",
|
29237
|
+
xmlns: "http://www.w3.org/2000/svg"
|
29238
|
+
}, props, {
|
29239
|
+
ref: forwardedRef
|
29240
|
+
}), React.createElement("path", {
|
29241
|
+
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",
|
29242
|
+
fill: color,
|
29243
|
+
fillRule: "evenodd",
|
29244
|
+
clipRule: "evenodd"
|
29245
|
+
}));
|
29246
|
+
});
|
29247
|
+
|
29248
|
+
var _excluded$Z = ["color"];
|
29249
|
+
var ChevronUpIcon = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
29250
|
+
var _ref$color = _ref.color,
|
29251
|
+
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
|
29252
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$Z);
|
29253
|
+
|
29254
|
+
return React.createElement("svg", Object.assign({
|
29255
|
+
width: "15",
|
29256
|
+
height: "15",
|
29257
|
+
viewBox: "0 0 15 15",
|
29258
|
+
fill: "none",
|
29259
|
+
xmlns: "http://www.w3.org/2000/svg"
|
29260
|
+
}, props, {
|
29261
|
+
ref: forwardedRef
|
29262
|
+
}), React.createElement("path", {
|
29263
|
+
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",
|
29264
|
+
fill: color,
|
29265
|
+
fillRule: "evenodd",
|
29266
|
+
clipRule: "evenodd"
|
29267
|
+
}));
|
29268
|
+
});
|
29269
|
+
|
28006
29270
|
var _excluded$3w = ["color"];
|
28007
29271
|
var PlayIcon = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
28008
29272
|
var _ref$color = _ref.color,
|
@@ -28091,6 +29355,137 @@ var TrashIcon = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
28091
29355
|
}));
|
28092
29356
|
});
|
28093
29357
|
|
29358
|
+
const BehaviorSelect = ({ row }) => {
|
29359
|
+
var _a;
|
29360
|
+
const id = row.original.id;
|
29361
|
+
const { setHandlerBehavior, getHandlerBehavior } = useHandlerStore();
|
29362
|
+
return (React.createElement(Select, { onValueChange: (_value) => {
|
29363
|
+
const value = _value;
|
29364
|
+
setHandlerBehavior(row.original.id, value);
|
29365
|
+
} },
|
29366
|
+
React.createElement(SelectTrigger, { className: "msw-dt-select-trigger", "aria-label": "Behavior", onClick: (e) => e.stopPropagation() },
|
29367
|
+
React.createElement(SelectValue, { placeholder: (_a = getHandlerBehavior(id)) !== null && _a !== void 0 ? _a : HttpHandlerBehavior.DEFAULT, className: "msw-dt-text-ellipsis" }),
|
29368
|
+
React.createElement(SelectIcon, { className: "msw-dt-select-icon" },
|
29369
|
+
React.createElement(ChevronDownIcon, null))),
|
29370
|
+
React.createElement(SelectPortal, null,
|
29371
|
+
React.createElement(SelectContent, { className: "msw-dt-select-content", style: { zIndex: 10000 } },
|
29372
|
+
React.createElement(SelectScrollUpButton, { className: "msw-dt-select-scroll-button" },
|
29373
|
+
React.createElement(ChevronUpIcon, null)),
|
29374
|
+
React.createElement(SelectViewport, { className: "msw-dt-select-viewport" }, Object.values(HttpHandlerBehavior).map((behavior) => {
|
29375
|
+
return (React.createElement(SelectItem, { key: behavior, value: behavior }, behavior));
|
29376
|
+
})),
|
29377
|
+
React.createElement(SelectScrollDownButton, { className: "msw-dt-select-scroll-button" },
|
29378
|
+
React.createElement(ChevronDownIcon, null))))));
|
29379
|
+
};
|
29380
|
+
const SelectItem = React.forwardRef(({ children, className, value, ...props }, forwardedRef) => {
|
29381
|
+
return (React.createElement(SelectItem$1, { className: "msw-dt-select-item", value: value, ...props, ref: forwardedRef },
|
29382
|
+
React.createElement(SelectItemText, null, children),
|
29383
|
+
React.createElement(SelectItemIndicator, { className: "msw-dt-select-item-indicator" },
|
29384
|
+
React.createElement(CheckIcon, null))));
|
29385
|
+
});
|
29386
|
+
SelectItem.displayName = "SelectItem";
|
29387
|
+
|
29388
|
+
const useFlattenHandlersTable = () => {
|
29389
|
+
const { flattenHandlers, handlerRowSelection, handleHandlerRowSelectionChange, } = useHandlerStore();
|
29390
|
+
const columnHelper = createColumnHelper();
|
29391
|
+
const columns = React.useMemo(() => {
|
29392
|
+
return [
|
29393
|
+
columnHelper.accessor("enabled", {
|
29394
|
+
header: ({ table }) => (React.createElement("input", { type: "checkbox", checked: table.getIsAllRowsSelected(), onChange: (e) => {
|
29395
|
+
e.stopPropagation();
|
29396
|
+
table.toggleAllRowsSelected(e.target.checked);
|
29397
|
+
} })),
|
29398
|
+
cell: ({ row }) => (React.createElement("input", { type: "checkbox", checked: row.getIsSelected(), onChange: (e) => {
|
29399
|
+
e.stopPropagation();
|
29400
|
+
row.toggleSelected(e.target.checked);
|
29401
|
+
} })),
|
29402
|
+
}),
|
29403
|
+
columnHelper.accessor("path", {
|
29404
|
+
header: "Protocol",
|
29405
|
+
cell: ({ row }) => {
|
29406
|
+
const protocol = new URL(row.original.path, location.href).protocol;
|
29407
|
+
return protocol;
|
29408
|
+
},
|
29409
|
+
id: "protocol",
|
29410
|
+
}),
|
29411
|
+
columnHelper.accessor("path", {
|
29412
|
+
header: "Host",
|
29413
|
+
cell: ({ row }) => {
|
29414
|
+
const host = new URL(row.original.path, location.href).host;
|
29415
|
+
return host;
|
29416
|
+
},
|
29417
|
+
id: "host",
|
29418
|
+
}),
|
29419
|
+
columnHelper.accessor("path", {
|
29420
|
+
header: "Path",
|
29421
|
+
cell: ({ row }) => {
|
29422
|
+
const path = new URL(row.original.path, location.href).pathname;
|
29423
|
+
return path;
|
29424
|
+
},
|
29425
|
+
id: "path",
|
29426
|
+
}),
|
29427
|
+
columnHelper.accessor("method", {
|
29428
|
+
header: "Method",
|
29429
|
+
cell: ({ row }) => row.original.method,
|
29430
|
+
}),
|
29431
|
+
columnHelper.accessor("behavior", {
|
29432
|
+
header: "Behavior",
|
29433
|
+
cell: ({ row }) => {
|
29434
|
+
return React.createElement(BehaviorSelect, { row: row });
|
29435
|
+
},
|
29436
|
+
}),
|
29437
|
+
];
|
29438
|
+
}, []);
|
29439
|
+
const table = useReactTable({
|
29440
|
+
columns,
|
29441
|
+
data: flattenHandlers,
|
29442
|
+
getCoreRowModel: getCoreRowModel(),
|
29443
|
+
state: {
|
29444
|
+
rowSelection: handlerRowSelection,
|
29445
|
+
},
|
29446
|
+
onRowSelectionChange: handleHandlerRowSelectionChange,
|
29447
|
+
getRowId: (row) => row.id,
|
29448
|
+
enableRowSelection: true,
|
29449
|
+
});
|
29450
|
+
return table;
|
29451
|
+
};
|
29452
|
+
|
29453
|
+
const useUiControlStore = zustand.create((set) => ({
|
29454
|
+
currentHandler: null,
|
29455
|
+
setDebuggerHandler: (handler) => set({ currentHandler: handler }),
|
29456
|
+
}));
|
29457
|
+
|
29458
|
+
const HandlerTable = () => {
|
29459
|
+
const table = useFlattenHandlersTable();
|
29460
|
+
const { setDebuggerHandler } = useUiControlStore();
|
29461
|
+
const currentHandler = useUiControlStore((state) => state.currentHandler);
|
29462
|
+
return (React.createElement(p$3, { style: { flex: 3, overflowY: "auto" }, direction: "column", gap: "4" },
|
29463
|
+
React.createElement(r$8, { as: "h2", size: "5" }, "Handlers"),
|
29464
|
+
React.createElement(m, { onDragStart: (e) => e.stopPropagation(), style: { userSelect: "text" } },
|
29465
|
+
React.createElement(d, null, table.getHeaderGroups().map((headerGroup) => (React.createElement(P, { key: headerGroup.id }, headerGroup.headers.map((header) => (React.createElement(f$1, { key: header.id }, header.isPlaceholder
|
29466
|
+
? null
|
29467
|
+
: flexRender(header.column.columnDef.header, header.getContext())))))))),
|
29468
|
+
React.createElement(b, null, table.getRowModel().rows.map((row) => (React.createElement(P, { key: row.id, align: "center", className: `msw-dt-http-control-row ${row.original.handler === currentHandler && "msw-dt-current-row"}`, onClick: () => {
|
29469
|
+
setDebuggerHandler(row.original.handler);
|
29470
|
+
} }, row.getVisibleCells().map((cell) => (React.createElement(T, { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())))))))))));
|
29471
|
+
};
|
29472
|
+
|
29473
|
+
const PathParamSetter = ({ paramValues, onParamChange, }) => {
|
29474
|
+
return (paramValues &&
|
29475
|
+
Object.keys(paramValues).length > 0 && (React.createElement(p$6, null,
|
29476
|
+
React.createElement(Label, null, "Path Parameters"),
|
29477
|
+
React.createElement(p$3, { direction: "column", gap: "2", py: "2" }, Object.entries(paramValues).map(([key, value]) => (React.createElement(p$3, { align: "center", gap: "2", key: key },
|
29478
|
+
React.createElement(Label, { htmlFor: `param-${key}`, style: { width: "160px" } },
|
29479
|
+
key,
|
29480
|
+
":"),
|
29481
|
+
React.createElement(u, { id: `param-${key}`, type: "text", value: value, onChange: (e) => onParamChange(key, e.target.value), placeholder: "value of path param", style: {
|
29482
|
+
padding: "4px 8px",
|
29483
|
+
borderRadius: "4px",
|
29484
|
+
border: "1px solid #ccc",
|
29485
|
+
width: "180px",
|
29486
|
+
} }))))))));
|
29487
|
+
};
|
29488
|
+
|
28094
29489
|
const KeyValueInputList = ({ items, setItems, title, }) => {
|
28095
29490
|
const id = React.useId();
|
28096
29491
|
const [key, setKey] = React.useState("");
|
@@ -28359,10 +29754,11 @@ const MSWDevTool = () => {
|
|
28359
29754
|
React.createElement(DialogDescription, { className: "msw-dt-sub-text", style: { display: "none" } }, "Dev tool to control mock logic, and monitor handler logic calls."),
|
28360
29755
|
React.createElement(ToolButtonGroup, null),
|
28361
29756
|
React.createElement(p$3, { gap: "6", style: { flex: 1, overflow: "hidden" } },
|
28362
|
-
React.createElement(
|
29757
|
+
React.createElement(HandlerTable, null),
|
28363
29758
|
React.createElement(HandlerDebugger, null))))))));
|
28364
29759
|
};
|
28365
29760
|
|
28366
29761
|
exports.MSWDevTool = MSWDevTool;
|
28367
29762
|
exports.initMSWDevTool = initMSWDevTool;
|
29763
|
+
exports.setupDevToolWorker = setupDevToolWorker;
|
28368
29764
|
//# sourceMappingURL=index.js.map
|