@tonyclaw/llm-inspector 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +17 -0
- package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
- package/.output/public/assets/index-B3RwBPLW.css +1 -0
- package/.output/public/assets/index-s4lwsWvq.js +97 -0
- package/.output/public/assets/main-Cp8AM0Pa.js +17 -0
- package/.output/public/assets/minimax-BPMzvuL-.jpeg +0 -0
- package/.output/public/assets/qwen-CONDcHqt.png +0 -0
- package/.output/public/assets/zhipuai-BPNAnxo-.svg +219 -0
- package/.output/server/_chunks/ssr-renderer.mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
- package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
- package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +34 -0
- package/.output/server/_libs/ajv-formats.mjs +330 -0
- package/.output/server/_libs/ajv.mjs +11444 -0
- package/.output/server/_libs/aria-hidden.mjs +122 -0
- package/.output/server/_libs/atomically.mjs +152 -0
- package/.output/server/_libs/bail.mjs +8 -0
- package/.output/server/_libs/character-entities.mjs +2130 -0
- package/.output/server/_libs/class-variance-authority.mjs +44 -0
- package/.output/server/_libs/clsx.mjs +16 -0
- package/.output/server/_libs/comma-separated-tokens.mjs +10 -0
- package/.output/server/_libs/conf.mjs +635 -0
- package/.output/server/_libs/cookie-es.mjs +58 -0
- package/.output/server/_libs/core-util-is.mjs +75 -0
- package/.output/server/_libs/croner.mjs +1 -0
- package/.output/server/_libs/crossws.mjs +1 -0
- package/.output/server/_libs/debounce-fn.mjs +69 -0
- package/.output/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/.output/server/_libs/detect-node-es.mjs +1 -0
- package/.output/server/_libs/devlop.mjs +8 -0
- package/.output/server/_libs/dot-prop.mjs +265 -0
- package/.output/server/_libs/env-paths.mjs +57 -0
- package/.output/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/.output/server/_libs/extend.mjs +97 -0
- package/.output/server/_libs/fast-deep-equal.mjs +38 -0
- package/.output/server/_libs/fast-uri.mjs +812 -0
- package/.output/server/_libs/floating-ui__core.mjs +725 -0
- package/.output/server/_libs/floating-ui__dom.mjs +622 -0
- package/.output/server/_libs/floating-ui__react-dom.mjs +292 -0
- package/.output/server/_libs/floating-ui__utils.mjs +320 -0
- package/.output/server/_libs/get-nonce.mjs +9 -0
- package/.output/server/_libs/h3-v2.mjs +276 -0
- package/.output/server/_libs/h3.mjs +400 -0
- package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/.output/server/_libs/hast-util-whitespace.mjs +10 -0
- package/.output/server/_libs/hookable.mjs +1 -0
- package/.output/server/_libs/html-url-attributes.mjs +26 -0
- package/.output/server/_libs/immediate.mjs +74 -0
- package/.output/server/_libs/inherits.mjs +50 -0
- package/.output/server/_libs/inline-style-parser.mjs +142 -0
- package/.output/server/_libs/is-plain-obj.mjs +10 -0
- package/.output/server/_libs/isarray.mjs +14 -0
- package/.output/server/_libs/isbot.mjs +20 -0
- package/.output/server/_libs/json-schema-traverse.mjs +180 -0
- package/.output/server/_libs/jszip.mjs +3049 -0
- package/.output/server/_libs/lie.mjs +273 -0
- package/.output/server/_libs/lucide-react.mjs +368 -0
- package/.output/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/.output/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/.output/server/_libs/mdast-util-to-string.mjs +38 -0
- package/.output/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/.output/server/_libs/micromark-factory-destination.mjs +94 -0
- package/.output/server/_libs/micromark-factory-label.mjs +63 -0
- package/.output/server/_libs/micromark-factory-space.mjs +24 -0
- package/.output/server/_libs/micromark-factory-title.mjs +65 -0
- package/.output/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/.output/server/_libs/micromark-util-character.mjs +44 -0
- package/.output/server/_libs/micromark-util-chunked.mjs +36 -0
- package/.output/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/.output/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/.output/server/_libs/micromark-util-encode.mjs +1 -0
- package/.output/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/.output/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/.output/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/.output/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/.output/server/_libs/micromark.mjs +906 -0
- package/.output/server/_libs/mimic-function.mjs +47 -0
- package/.output/server/_libs/ohash.mjs +1 -0
- package/.output/server/_libs/pako.mjs +4223 -0
- package/.output/server/_libs/process-nextick-args.mjs +48 -0
- package/.output/server/_libs/property-information.mjs +1209 -0
- package/.output/server/_libs/radix-ui.mjs +1 -0
- package/.output/server/_libs/radix-ui__number.mjs +6 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
- package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
- package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +144 -0
- package/.output/server/_libs/radix-ui__react-collection.mjs +69 -0
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
- package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
- package/.output/server/_libs/radix-ui__react-dialog.mjs +325 -0
- package/.output/server/_libs/radix-ui__react-direction.mjs +9 -0
- package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
- package/.output/server/_libs/radix-ui__react-form.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-label.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menu.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popover.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-popper.mjs +286 -0
- package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
- package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
- package/.output/server/_libs/radix-ui__react-primitive.mjs +42 -0
- package/.output/server/_libs/radix-ui__react-progress.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +224 -0
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +721 -0
- package/.output/server/_libs/radix-ui__react-select.mjs +1163 -0
- package/.output/server/_libs/radix-ui__react-separator.mjs +28 -0
- package/.output/server/_libs/radix-ui__react-slider.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-slot.mjs +99 -0
- package/.output/server/_libs/radix-ui__react-switch.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tabs.mjs +189 -0
- package/.output/server/_libs/radix-ui__react-toast.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -0
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +495 -0
- package/.output/server/_libs/radix-ui__react-use-previous.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-use-size.mjs +39 -0
- package/.output/server/_libs/react-dom.mjs +9935 -0
- package/.output/server/_libs/react-markdown.mjs +147 -0
- package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
- package/.output/server/_libs/react-remove-scroll.mjs +328 -0
- package/.output/server/_libs/react-style-singleton.mjs +69 -0
- package/.output/server/_libs/react.mjs +515 -0
- package/.output/server/_libs/readable-stream.mjs +1518 -0
- package/.output/server/_libs/remark-parse.mjs +19 -0
- package/.output/server/_libs/remark-rehype.mjs +21 -0
- package/.output/server/_libs/rou3.mjs +8 -0
- package/.output/server/_libs/safe-buffer.mjs +64 -0
- package/.output/server/_libs/semver.mjs +1984 -0
- package/.output/server/_libs/seroval-plugins.mjs +58 -0
- package/.output/server/_libs/seroval.mjs +1765 -0
- package/.output/server/_libs/setimmediate.mjs +1 -0
- package/.output/server/_libs/space-separated-tokens.mjs +6 -0
- package/.output/server/_libs/srvx.mjs +334 -0
- package/.output/server/_libs/stubborn-fs.mjs +91 -0
- package/.output/server/_libs/stubborn-utils.mjs +66 -0
- package/.output/server/_libs/style-to-js.mjs +72 -0
- package/.output/server/_libs/style-to-object.mjs +38 -0
- package/.output/server/_libs/tailwind-merge.mjs +3010 -0
- package/.output/server/_libs/tanstack__history.mjs +217 -0
- package/.output/server/_libs/tanstack__react-router.mjs +1480 -0
- package/.output/server/_libs/tanstack__react-store.mjs +1 -0
- package/.output/server/_libs/tanstack__react-virtual.mjs +44 -0
- package/.output/server/_libs/tanstack__router-core.mjs +4827 -0
- package/.output/server/_libs/tanstack__store.mjs +1 -0
- package/.output/server/_libs/tanstack__virtual-core.mjs +1225 -0
- package/.output/server/_libs/tiny-invariant.mjs +12 -0
- package/.output/server/_libs/tiny-warning.mjs +5 -0
- package/.output/server/_libs/trim-lines.mjs +41 -0
- package/.output/server/_libs/trough.mjs +85 -0
- package/.output/server/_libs/tslib.mjs +576 -0
- package/.output/server/_libs/ufo.mjs +54 -0
- package/.output/server/_libs/uint8array-extras.mjs +69 -0
- package/.output/server/_libs/unctx.mjs +1 -0
- package/.output/server/_libs/ungap__structured-clone.mjs +212 -0
- package/.output/server/_libs/unified.mjs +661 -0
- package/.output/server/_libs/unist-util-is.mjs +100 -0
- package/.output/server/_libs/unist-util-position.mjs +27 -0
- package/.output/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/.output/server/_libs/unist-util-visit-parents.mjs +82 -0
- package/.output/server/_libs/unist-util-visit.mjs +24 -0
- package/.output/server/_libs/unstorage.mjs +1 -0
- package/.output/server/_libs/use-callback-ref.mjs +66 -0
- package/.output/server/_libs/use-sidecar.mjs +106 -0
- package/.output/server/_libs/use-sync-external-store.mjs +1 -0
- package/.output/server/_libs/util-deprecate.mjs +12 -0
- package/.output/server/_libs/vfile-message.mjs +138 -0
- package/.output/server/_libs/vfile.mjs +467 -0
- package/.output/server/_libs/when-exit.mjs +53 -0
- package/.output/server/_libs/zod.mjs +4460 -0
- package/.output/server/_ssr/index-ByCLZu7J.mjs +3061 -0
- package/.output/server/_ssr/index.mjs +1176 -0
- package/.output/server/_ssr/router-Bq_mxeNz.mjs +2872 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-C4E0e9my.mjs +4 -0
- package/.output/server/index.mjs +393 -0
- package/README.md +196 -0
- package/package.json +91 -0
- package/src/assets/logos/alibaba.svg +1 -0
- package/src/assets/logos/anthropic.svg +1 -0
- package/src/assets/logos/deepseek.svg +1 -0
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +1 -0
- package/src/assets/logos/qwen.png +0 -0
- package/src/assets/logos/zhipuai.svg +219 -0
- package/src/cli.ts +68 -0
- package/src/components/ProxyViewer.tsx +325 -0
- package/src/components/ProxyViewerContainer.tsx +211 -0
- package/src/components/providers/ProviderCard.tsx +186 -0
- package/src/components/providers/ProviderForm.tsx +259 -0
- package/src/components/providers/ProviderLogo.tsx +111 -0
- package/src/components/providers/ProvidersPanel.tsx +259 -0
- package/src/components/providers/SettingsDialog.tsx +39 -0
- package/src/components/proxy-viewer/ConversationGroup.tsx +68 -0
- package/src/components/proxy-viewer/ConversationHeader.tsx +141 -0
- package/src/components/proxy-viewer/LogEntry.tsx +225 -0
- package/src/components/proxy-viewer/LogEntryHeader.tsx +250 -0
- package/src/components/proxy-viewer/ReplayDialog.tsx +208 -0
- package/src/components/proxy-viewer/ResponseView.tsx +161 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +171 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +139 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +64 -0
- package/src/components/proxy-viewer/formats/index.tsx +24 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +80 -0
- package/src/components/proxy-viewer/index.ts +8 -0
- package/src/components/ui/badge.tsx +47 -0
- package/src/components/ui/button.tsx +47 -0
- package/src/components/ui/collapsible.tsx +21 -0
- package/src/components/ui/dialog.tsx +129 -0
- package/src/components/ui/json-viewer.tsx +464 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/select.tsx +178 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/tabs.tsx +88 -0
- package/src/components/ui/tooltip.tsx +51 -0
- package/src/index.css +11 -0
- package/src/lib/export-logs.ts +51 -0
- package/src/lib/utils.ts +22 -0
- package/src/proxy/chunkStorage.ts +118 -0
- package/src/proxy/constants.ts +36 -0
- package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
- package/src/proxy/formats/anthropic/handler.ts +74 -0
- package/src/proxy/formats/anthropic/index.ts +14 -0
- package/src/proxy/formats/anthropic/register.ts +4 -0
- package/src/proxy/formats/anthropic/schemas.ts +217 -0
- package/src/proxy/formats/anthropic/stream.ts +167 -0
- package/src/proxy/formats/handler.ts +46 -0
- package/src/proxy/formats/index.ts +12 -0
- package/src/proxy/formats/jsonSchema.ts +24 -0
- package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
- package/src/proxy/formats/openai/handler.ts +70 -0
- package/src/proxy/formats/openai/index.ts +25 -0
- package/src/proxy/formats/openai/provider.ts +50 -0
- package/src/proxy/formats/openai/register.ts +4 -0
- package/src/proxy/formats/openai/schemas.ts +150 -0
- package/src/proxy/formats/openai/stream.ts +153 -0
- package/src/proxy/formats/protocol.ts +50 -0
- package/src/proxy/formats/providerRegistry.ts +51 -0
- package/src/proxy/formats/providers/index.ts +3 -0
- package/src/proxy/formats/registry.ts +61 -0
- package/src/proxy/handler.ts +389 -0
- package/src/proxy/logIndex.ts +187 -0
- package/src/proxy/logger.ts +99 -0
- package/src/proxy/providers.ts +234 -0
- package/src/proxy/schemas.ts +160 -0
- package/src/proxy/socketTracker.ts +158 -0
- package/src/proxy/store.ts +386 -0
- package/src/router.tsx +16 -0
- package/src/routes/__root.tsx +38 -0
- package/src/routes/api/config.paths.ts +14 -0
- package/src/routes/api/health.ts +11 -0
- package/src/routes/api/logs.$id.chunks.ts +36 -0
- package/src/routes/api/logs.$id.replay.ts +262 -0
- package/src/routes/api/logs.$id.ts +22 -0
- package/src/routes/api/logs.stream.ts +64 -0
- package/src/routes/api/logs.ts +30 -0
- package/src/routes/api/models.ts +10 -0
- package/src/routes/api/providers.$providerId.ts +45 -0
- package/src/routes/api/providers.ts +37 -0
- package/src/routes/api/sessions.ts +10 -0
- package/src/routes/index.tsx +6 -0
- package/src/routes/proxy/$.ts +15 -0
- package/styles/globals.css +121 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./react.mjs";
|
|
2
|
+
import { c as composeEventHandlers } from "./radix-ui__primitive.mjs";
|
|
3
|
+
import { u as useComposedRefs } from "./radix-ui__react-compose-refs.mjs";
|
|
4
|
+
import { c as createContextScope, a as createContext2 } from "./radix-ui__react-context.mjs";
|
|
5
|
+
import { u as useId } from "./radix-ui__react-id.mjs";
|
|
6
|
+
import { u as useControllableState } from "./@radix-ui/react-use-controllable-state+[...].mjs";
|
|
7
|
+
import { D as DismissableLayer } from "./@radix-ui/react-dismissable-layer+[...].mjs";
|
|
8
|
+
import { F as FocusScope } from "./radix-ui__react-focus-scope.mjs";
|
|
9
|
+
import { P as Portal$1 } from "./radix-ui__react-portal.mjs";
|
|
10
|
+
import { P as Presence } from "./radix-ui__react-presence.mjs";
|
|
11
|
+
import { P as Primitive } from "./radix-ui__react-primitive.mjs";
|
|
12
|
+
import { u as useFocusGuards } from "./radix-ui__react-focus-guards.mjs";
|
|
13
|
+
import { R as ReactRemoveScroll } from "./react-remove-scroll.mjs";
|
|
14
|
+
import { h as hideOthers } from "./aria-hidden.mjs";
|
|
15
|
+
import { c as createSlot } from "./radix-ui__react-slot.mjs";
|
|
16
|
+
var DIALOG_NAME = "Dialog";
|
|
17
|
+
var [createDialogContext] = createContextScope(DIALOG_NAME);
|
|
18
|
+
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
19
|
+
var Dialog = (props) => {
|
|
20
|
+
const {
|
|
21
|
+
__scopeDialog,
|
|
22
|
+
children,
|
|
23
|
+
open: openProp,
|
|
24
|
+
defaultOpen,
|
|
25
|
+
onOpenChange,
|
|
26
|
+
modal = true
|
|
27
|
+
} = props;
|
|
28
|
+
const triggerRef = reactExports.useRef(null);
|
|
29
|
+
const contentRef = reactExports.useRef(null);
|
|
30
|
+
const [open, setOpen] = useControllableState({
|
|
31
|
+
prop: openProp,
|
|
32
|
+
defaultProp: defaultOpen ?? false,
|
|
33
|
+
onChange: onOpenChange,
|
|
34
|
+
caller: DIALOG_NAME
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
37
|
+
DialogProvider,
|
|
38
|
+
{
|
|
39
|
+
scope: __scopeDialog,
|
|
40
|
+
triggerRef,
|
|
41
|
+
contentRef,
|
|
42
|
+
contentId: useId(),
|
|
43
|
+
titleId: useId(),
|
|
44
|
+
descriptionId: useId(),
|
|
45
|
+
open,
|
|
46
|
+
onOpenChange: setOpen,
|
|
47
|
+
onOpenToggle: reactExports.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
48
|
+
modal,
|
|
49
|
+
children
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
Dialog.displayName = DIALOG_NAME;
|
|
54
|
+
var TRIGGER_NAME = "DialogTrigger";
|
|
55
|
+
var DialogTrigger = reactExports.forwardRef(
|
|
56
|
+
(props, forwardedRef) => {
|
|
57
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
58
|
+
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
59
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
60
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
61
|
+
Primitive.button,
|
|
62
|
+
{
|
|
63
|
+
type: "button",
|
|
64
|
+
"aria-haspopup": "dialog",
|
|
65
|
+
"aria-expanded": context.open,
|
|
66
|
+
"aria-controls": context.contentId,
|
|
67
|
+
"data-state": getState(context.open),
|
|
68
|
+
...triggerProps,
|
|
69
|
+
ref: composedTriggerRef,
|
|
70
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
DialogTrigger.displayName = TRIGGER_NAME;
|
|
76
|
+
var PORTAL_NAME = "DialogPortal";
|
|
77
|
+
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
78
|
+
forceMount: void 0
|
|
79
|
+
});
|
|
80
|
+
var DialogPortal = (props) => {
|
|
81
|
+
const { __scopeDialog, forceMount, children, container } = props;
|
|
82
|
+
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
83
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: reactExports.Children.map(children, (child) => /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Portal$1, { asChild: true, container, children: child }) })) });
|
|
84
|
+
};
|
|
85
|
+
DialogPortal.displayName = PORTAL_NAME;
|
|
86
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
87
|
+
var DialogOverlay = reactExports.forwardRef(
|
|
88
|
+
(props, forwardedRef) => {
|
|
89
|
+
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
90
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
91
|
+
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
92
|
+
return context.modal ? /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
DialogOverlay.displayName = OVERLAY_NAME;
|
|
96
|
+
var Slot = createSlot("DialogOverlay.RemoveScroll");
|
|
97
|
+
var DialogOverlayImpl = reactExports.forwardRef(
|
|
98
|
+
(props, forwardedRef) => {
|
|
99
|
+
const { __scopeDialog, ...overlayProps } = props;
|
|
100
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
101
|
+
return (
|
|
102
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
103
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
104
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
105
|
+
Primitive.div,
|
|
106
|
+
{
|
|
107
|
+
"data-state": getState(context.open),
|
|
108
|
+
...overlayProps,
|
|
109
|
+
ref: forwardedRef,
|
|
110
|
+
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
var CONTENT_NAME = "DialogContent";
|
|
117
|
+
var DialogContent = reactExports.forwardRef(
|
|
118
|
+
(props, forwardedRef) => {
|
|
119
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
120
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
121
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
122
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsxRuntimeExports.jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsxRuntimeExports.jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
DialogContent.displayName = CONTENT_NAME;
|
|
126
|
+
var DialogContentModal = reactExports.forwardRef(
|
|
127
|
+
(props, forwardedRef) => {
|
|
128
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
129
|
+
const contentRef = reactExports.useRef(null);
|
|
130
|
+
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
131
|
+
reactExports.useEffect(() => {
|
|
132
|
+
const content = contentRef.current;
|
|
133
|
+
if (content) return hideOthers(content);
|
|
134
|
+
}, []);
|
|
135
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
136
|
+
DialogContentImpl,
|
|
137
|
+
{
|
|
138
|
+
...props,
|
|
139
|
+
ref: composedRefs,
|
|
140
|
+
trapFocus: context.open,
|
|
141
|
+
disableOutsidePointerEvents: true,
|
|
142
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
context.triggerRef.current?.focus();
|
|
145
|
+
}),
|
|
146
|
+
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
147
|
+
const originalEvent = event.detail.originalEvent;
|
|
148
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
149
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
150
|
+
if (isRightClick) event.preventDefault();
|
|
151
|
+
}),
|
|
152
|
+
onFocusOutside: composeEventHandlers(
|
|
153
|
+
props.onFocusOutside,
|
|
154
|
+
(event) => event.preventDefault()
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
var DialogContentNonModal = reactExports.forwardRef(
|
|
161
|
+
(props, forwardedRef) => {
|
|
162
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
163
|
+
const hasInteractedOutsideRef = reactExports.useRef(false);
|
|
164
|
+
const hasPointerDownOutsideRef = reactExports.useRef(false);
|
|
165
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
166
|
+
DialogContentImpl,
|
|
167
|
+
{
|
|
168
|
+
...props,
|
|
169
|
+
ref: forwardedRef,
|
|
170
|
+
trapFocus: false,
|
|
171
|
+
disableOutsidePointerEvents: false,
|
|
172
|
+
onCloseAutoFocus: (event) => {
|
|
173
|
+
props.onCloseAutoFocus?.(event);
|
|
174
|
+
if (!event.defaultPrevented) {
|
|
175
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
}
|
|
178
|
+
hasInteractedOutsideRef.current = false;
|
|
179
|
+
hasPointerDownOutsideRef.current = false;
|
|
180
|
+
},
|
|
181
|
+
onInteractOutside: (event) => {
|
|
182
|
+
props.onInteractOutside?.(event);
|
|
183
|
+
if (!event.defaultPrevented) {
|
|
184
|
+
hasInteractedOutsideRef.current = true;
|
|
185
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
186
|
+
hasPointerDownOutsideRef.current = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const target = event.target;
|
|
190
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
191
|
+
if (targetIsTrigger) event.preventDefault();
|
|
192
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
var DialogContentImpl = reactExports.forwardRef(
|
|
201
|
+
(props, forwardedRef) => {
|
|
202
|
+
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
203
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
204
|
+
const contentRef = reactExports.useRef(null);
|
|
205
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
206
|
+
useFocusGuards();
|
|
207
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
208
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
209
|
+
FocusScope,
|
|
210
|
+
{
|
|
211
|
+
asChild: true,
|
|
212
|
+
loop: true,
|
|
213
|
+
trapped: trapFocus,
|
|
214
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
215
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
216
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
217
|
+
DismissableLayer,
|
|
218
|
+
{
|
|
219
|
+
role: "dialog",
|
|
220
|
+
id: context.contentId,
|
|
221
|
+
"aria-describedby": context.descriptionId,
|
|
222
|
+
"aria-labelledby": context.titleId,
|
|
223
|
+
"data-state": getState(context.open),
|
|
224
|
+
...contentProps,
|
|
225
|
+
ref: composedRefs,
|
|
226
|
+
onDismiss: () => context.onOpenChange(false)
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
232
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TitleWarning, { titleId: context.titleId }),
|
|
233
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
234
|
+
] })
|
|
235
|
+
] });
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
var TITLE_NAME = "DialogTitle";
|
|
239
|
+
var DialogTitle = reactExports.forwardRef(
|
|
240
|
+
(props, forwardedRef) => {
|
|
241
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
242
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
243
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
DialogTitle.displayName = TITLE_NAME;
|
|
247
|
+
var DESCRIPTION_NAME = "DialogDescription";
|
|
248
|
+
var DialogDescription = reactExports.forwardRef(
|
|
249
|
+
(props, forwardedRef) => {
|
|
250
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
251
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
252
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
256
|
+
var CLOSE_NAME = "DialogClose";
|
|
257
|
+
var DialogClose = reactExports.forwardRef(
|
|
258
|
+
(props, forwardedRef) => {
|
|
259
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
260
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
261
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
262
|
+
Primitive.button,
|
|
263
|
+
{
|
|
264
|
+
type: "button",
|
|
265
|
+
...closeProps,
|
|
266
|
+
ref: forwardedRef,
|
|
267
|
+
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
DialogClose.displayName = CLOSE_NAME;
|
|
273
|
+
function getState(open) {
|
|
274
|
+
return open ? "open" : "closed";
|
|
275
|
+
}
|
|
276
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
277
|
+
var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
|
|
278
|
+
contentName: CONTENT_NAME,
|
|
279
|
+
titleName: TITLE_NAME,
|
|
280
|
+
docsSlug: "dialog"
|
|
281
|
+
});
|
|
282
|
+
var TitleWarning = ({ titleId }) => {
|
|
283
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
284
|
+
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
285
|
+
|
|
286
|
+
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
287
|
+
|
|
288
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
289
|
+
reactExports.useEffect(() => {
|
|
290
|
+
if (titleId) {
|
|
291
|
+
const hasTitle = document.getElementById(titleId);
|
|
292
|
+
if (!hasTitle) console.error(MESSAGE);
|
|
293
|
+
}
|
|
294
|
+
}, [MESSAGE, titleId]);
|
|
295
|
+
return null;
|
|
296
|
+
};
|
|
297
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
298
|
+
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
299
|
+
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
300
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
301
|
+
reactExports.useEffect(() => {
|
|
302
|
+
const describedById = contentRef.current?.getAttribute("aria-describedby");
|
|
303
|
+
if (descriptionId && describedById) {
|
|
304
|
+
const hasDescription = document.getElementById(descriptionId);
|
|
305
|
+
if (!hasDescription) console.warn(MESSAGE);
|
|
306
|
+
}
|
|
307
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
308
|
+
return null;
|
|
309
|
+
};
|
|
310
|
+
var Root = Dialog;
|
|
311
|
+
var Trigger = DialogTrigger;
|
|
312
|
+
var Portal = DialogPortal;
|
|
313
|
+
var Overlay = DialogOverlay;
|
|
314
|
+
var Content = DialogContent;
|
|
315
|
+
var Title = DialogTitle;
|
|
316
|
+
var Close = DialogClose;
|
|
317
|
+
export {
|
|
318
|
+
Content as C,
|
|
319
|
+
Overlay as O,
|
|
320
|
+
Portal as P,
|
|
321
|
+
Root as R,
|
|
322
|
+
Trigger as T,
|
|
323
|
+
Close as a,
|
|
324
|
+
Title as b
|
|
325
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { r as reactExports } from "./react.mjs";
|
|
2
|
+
var DirectionContext = reactExports.createContext(void 0);
|
|
3
|
+
function useDirection(localDir) {
|
|
4
|
+
const globalDir = reactExports.useContext(DirectionContext);
|
|
5
|
+
return localDir || globalDir || "ltr";
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
useDirection as u
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { r as reactExports } from "./react.mjs";
|
|
2
|
+
var count = 0;
|
|
3
|
+
function useFocusGuards() {
|
|
4
|
+
reactExports.useEffect(() => {
|
|
5
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
6
|
+
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
7
|
+
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
8
|
+
count++;
|
|
9
|
+
return () => {
|
|
10
|
+
if (count === 1) {
|
|
11
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
12
|
+
}
|
|
13
|
+
count--;
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
17
|
+
function createFocusGuard() {
|
|
18
|
+
const element = document.createElement("span");
|
|
19
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
20
|
+
element.tabIndex = 0;
|
|
21
|
+
element.style.outline = "none";
|
|
22
|
+
element.style.opacity = "0";
|
|
23
|
+
element.style.position = "fixed";
|
|
24
|
+
element.style.pointerEvents = "none";
|
|
25
|
+
return element;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
useFocusGuards as u
|
|
29
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./react.mjs";
|
|
2
|
+
import { u as useComposedRefs } from "./radix-ui__react-compose-refs.mjs";
|
|
3
|
+
import { P as Primitive } from "./radix-ui__react-primitive.mjs";
|
|
4
|
+
import { u as useCallbackRef } from "./@radix-ui/react-use-callback-ref+[...].mjs";
|
|
5
|
+
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
6
|
+
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
7
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
8
|
+
var FOCUS_SCOPE_NAME = "FocusScope";
|
|
9
|
+
var FocusScope = reactExports.forwardRef((props, forwardedRef) => {
|
|
10
|
+
const {
|
|
11
|
+
loop = false,
|
|
12
|
+
trapped = false,
|
|
13
|
+
onMountAutoFocus: onMountAutoFocusProp,
|
|
14
|
+
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
15
|
+
...scopeProps
|
|
16
|
+
} = props;
|
|
17
|
+
const [container, setContainer] = reactExports.useState(null);
|
|
18
|
+
const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
|
|
19
|
+
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
20
|
+
const lastFocusedElementRef = reactExports.useRef(null);
|
|
21
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
22
|
+
const focusScope = reactExports.useRef({
|
|
23
|
+
paused: false,
|
|
24
|
+
pause() {
|
|
25
|
+
this.paused = true;
|
|
26
|
+
},
|
|
27
|
+
resume() {
|
|
28
|
+
this.paused = false;
|
|
29
|
+
}
|
|
30
|
+
}).current;
|
|
31
|
+
reactExports.useEffect(() => {
|
|
32
|
+
if (trapped) {
|
|
33
|
+
let handleFocusIn2 = function(event) {
|
|
34
|
+
if (focusScope.paused || !container) return;
|
|
35
|
+
const target = event.target;
|
|
36
|
+
if (container.contains(target)) {
|
|
37
|
+
lastFocusedElementRef.current = target;
|
|
38
|
+
} else {
|
|
39
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
40
|
+
}
|
|
41
|
+
}, handleFocusOut2 = function(event) {
|
|
42
|
+
if (focusScope.paused || !container) return;
|
|
43
|
+
const relatedTarget = event.relatedTarget;
|
|
44
|
+
if (relatedTarget === null) return;
|
|
45
|
+
if (!container.contains(relatedTarget)) {
|
|
46
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
47
|
+
}
|
|
48
|
+
}, handleMutations2 = function(mutations) {
|
|
49
|
+
const focusedElement = document.activeElement;
|
|
50
|
+
if (focusedElement !== document.body) return;
|
|
51
|
+
for (const mutation of mutations) {
|
|
52
|
+
if (mutation.removedNodes.length > 0) focus(container);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
document.addEventListener("focusin", handleFocusIn2);
|
|
56
|
+
document.addEventListener("focusout", handleFocusOut2);
|
|
57
|
+
const mutationObserver = new MutationObserver(handleMutations2);
|
|
58
|
+
if (container) mutationObserver.observe(container, { childList: true, subtree: true });
|
|
59
|
+
return () => {
|
|
60
|
+
document.removeEventListener("focusin", handleFocusIn2);
|
|
61
|
+
document.removeEventListener("focusout", handleFocusOut2);
|
|
62
|
+
mutationObserver.disconnect();
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, [trapped, container, focusScope.paused]);
|
|
66
|
+
reactExports.useEffect(() => {
|
|
67
|
+
if (container) {
|
|
68
|
+
focusScopesStack.add(focusScope);
|
|
69
|
+
const previouslyFocusedElement = document.activeElement;
|
|
70
|
+
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
71
|
+
if (!hasFocusedCandidate) {
|
|
72
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
73
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
74
|
+
container.dispatchEvent(mountEvent);
|
|
75
|
+
if (!mountEvent.defaultPrevented) {
|
|
76
|
+
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
77
|
+
if (document.activeElement === previouslyFocusedElement) {
|
|
78
|
+
focus(container);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
86
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
87
|
+
container.dispatchEvent(unmountEvent);
|
|
88
|
+
if (!unmountEvent.defaultPrevented) {
|
|
89
|
+
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
90
|
+
}
|
|
91
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
92
|
+
focusScopesStack.remove(focusScope);
|
|
93
|
+
}, 0);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
97
|
+
const handleKeyDown = reactExports.useCallback(
|
|
98
|
+
(event) => {
|
|
99
|
+
if (!loop && !trapped) return;
|
|
100
|
+
if (focusScope.paused) return;
|
|
101
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
102
|
+
const focusedElement = document.activeElement;
|
|
103
|
+
if (isTabKey && focusedElement) {
|
|
104
|
+
const container2 = event.currentTarget;
|
|
105
|
+
const [first, last] = getTabbableEdges(container2);
|
|
106
|
+
const hasTabbableElementsInside = first && last;
|
|
107
|
+
if (!hasTabbableElementsInside) {
|
|
108
|
+
if (focusedElement === container2) event.preventDefault();
|
|
109
|
+
} else {
|
|
110
|
+
if (!event.shiftKey && focusedElement === last) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
if (loop) focus(first, { select: true });
|
|
113
|
+
} else if (event.shiftKey && focusedElement === first) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
if (loop) focus(last, { select: true });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
[loop, trapped, focusScope.paused]
|
|
121
|
+
);
|
|
122
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
|
|
123
|
+
});
|
|
124
|
+
FocusScope.displayName = FOCUS_SCOPE_NAME;
|
|
125
|
+
function focusFirst(candidates, { select = false } = {}) {
|
|
126
|
+
const previouslyFocusedElement = document.activeElement;
|
|
127
|
+
for (const candidate of candidates) {
|
|
128
|
+
focus(candidate, { select });
|
|
129
|
+
if (document.activeElement !== previouslyFocusedElement) return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function getTabbableEdges(container) {
|
|
133
|
+
const candidates = getTabbableCandidates(container);
|
|
134
|
+
const first = findVisible(candidates, container);
|
|
135
|
+
const last = findVisible(candidates.reverse(), container);
|
|
136
|
+
return [first, last];
|
|
137
|
+
}
|
|
138
|
+
function getTabbableCandidates(container) {
|
|
139
|
+
const nodes = [];
|
|
140
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
141
|
+
acceptNode: (node) => {
|
|
142
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
143
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
144
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
148
|
+
return nodes;
|
|
149
|
+
}
|
|
150
|
+
function findVisible(elements, container) {
|
|
151
|
+
for (const element of elements) {
|
|
152
|
+
if (!isHidden(element, { upTo: container })) return element;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function isHidden(node, { upTo }) {
|
|
156
|
+
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
157
|
+
while (node) {
|
|
158
|
+
if (upTo !== void 0 && node === upTo) return false;
|
|
159
|
+
if (getComputedStyle(node).display === "none") return true;
|
|
160
|
+
node = node.parentElement;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
function isSelectableInput(element) {
|
|
165
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
166
|
+
}
|
|
167
|
+
function focus(element, { select = false } = {}) {
|
|
168
|
+
if (element && element.focus) {
|
|
169
|
+
const previouslyFocusedElement = document.activeElement;
|
|
170
|
+
element.focus({ preventScroll: true });
|
|
171
|
+
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
172
|
+
element.select();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var focusScopesStack = createFocusScopesStack();
|
|
176
|
+
function createFocusScopesStack() {
|
|
177
|
+
let stack = [];
|
|
178
|
+
return {
|
|
179
|
+
add(focusScope) {
|
|
180
|
+
const activeFocusScope = stack[0];
|
|
181
|
+
if (focusScope !== activeFocusScope) {
|
|
182
|
+
activeFocusScope?.pause();
|
|
183
|
+
}
|
|
184
|
+
stack = arrayRemove(stack, focusScope);
|
|
185
|
+
stack.unshift(focusScope);
|
|
186
|
+
},
|
|
187
|
+
remove(focusScope) {
|
|
188
|
+
stack = arrayRemove(stack, focusScope);
|
|
189
|
+
stack[0]?.resume();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function arrayRemove(array, item) {
|
|
194
|
+
const updatedArray = [...array];
|
|
195
|
+
const index = updatedArray.indexOf(item);
|
|
196
|
+
if (index !== -1) {
|
|
197
|
+
updatedArray.splice(index, 1);
|
|
198
|
+
}
|
|
199
|
+
return updatedArray;
|
|
200
|
+
}
|
|
201
|
+
function removeLinks(items) {
|
|
202
|
+
return items.filter((item) => item.tagName !== "A");
|
|
203
|
+
}
|
|
204
|
+
export {
|
|
205
|
+
FocusScope as F
|
|
206
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { r as reactExports, R as React } from "./react.mjs";
|
|
2
|
+
import { u as useLayoutEffect2 } from "./@radix-ui/react-use-layout-effect+[...].mjs";
|
|
3
|
+
var useReactId = React[" useId ".trim().toString()] || (() => void 0);
|
|
4
|
+
var count = 0;
|
|
5
|
+
function useId(deterministicId) {
|
|
6
|
+
const [id, setId] = reactExports.useState(useReactId());
|
|
7
|
+
useLayoutEffect2(() => {
|
|
8
|
+
setId((reactId) => reactId ?? String(count++));
|
|
9
|
+
}, [deterministicId]);
|
|
10
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useId as u
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|