fumadocs-openapi 12.6.2 → 12.6.3
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/css/generated/shared.css +1 -1
- package/dist/packages/shared-api/dist/.translations/index.d.ts +1 -2
- package/dist/packages/shared-api/dist/.translations/keys.json.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/fields.js +268 -227
- package/dist/packages/shared-api/dist/components/playground/panels.js +2 -2
- package/dist/packages/shared-api/dist/components/playground/server-select.js +2 -2
- package/dist/packages/shared-api/dist/components/select-tab.js +1 -1
- package/dist/playground/auth.d.ts +9 -2
- package/dist/playground/auth.js +19 -16
- package/dist/playground/use-playground.js +3 -3
- package/dist/ui/playground/components/request-panel.js +6 -4
- package/package.json +1 -1
package/css/generated/shared.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source inline("!collapsed !headers !readOnly !renderBodyField !required !returned *:flex-1 *:justify-center *:min-w-0 --accordion-panel-height --active-tab-height --active-tab-left --active-tab-top --active-tab-width --anchor-width --available-height --collapsible-panel-height --fd-docs-height --fd-docs-row-3 --spacing --transform-origin -mode -ms-0.5 -ms-2 -mt-1 -my-1 -z-1 @4xl:flex @4xl:flex-col @4xl:flex-row @4xl:items-start @4xl:max-h-[calc(var(--fd-docs-height,100dvh)-var(--fd-docs-row-3,0px)-2rem)] @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-3,0px)+1rem)] @4xl:w-[400px] @container @default @defaultValue @deprecated @fuma-translate/react @fumadocs/json-schema @fumari/stf @max-sm:bg-fd-secondary/50 @max-sm:border @max-sm:empty:w-2 @max-sm:mx-4 @max-sm:overflow-hidden @max-sm:pb-1.5 @max-sm:pb-3 @max-sm:pe-2 @max-sm:rounded-lg @max-xl:basis-full @max-xl:border-t @max-xl:flex-1 @max-xl:ps-1.5 @md:block @param @returns @scalar/api-client-react @see @sm:-me-2 @sm:-me-2.5 @sm:border-s @sm:grid-cols-[minmax(9rem,1fr)_minmax(0,2fr)] @sm:min-h-10 @sm:pe-7.5 @sm:pe-8 @xl:w-40 [&>div:has(>figcaption)]:h-10 [&[hidden]:not([hidden='until-found'])]:hidden [&_a]:underline [&_code]:font-mono [&_figcaption]:font-medium [&_figcaption]:overflow-visible [&_figcaption]:text-[0.8125rem] [&_figcaption]:text-fd-foreground [&_figcaption]:text-xs [&_svg]:size-3 [&_svg]:size-3.5 [--fd-docs-row-3:0px] [grid-area:1/1] [scrollbar-width:none] a abort above absolute accept access access_token accordion accordions across actions active:scale-[0.97] activity actual adapter adapters add addLogEntry added adding additional additionalProperties after again against alias align aligns all allOf allow allowCopy allowJson allowed already also alt among an anchor anchorSegments and animate-spin animates another any anyFields anyOf apiExample apiKey apiPlayground appearance-none application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml applied applies apply are aria-checked aria-current aria-expanded aria-expanded:bg-fd-accent aria-expanded:decoration-solid aria-expanded:text-fd-accent-foreground aria-hidden aria-label aria-live aria-pressed aria-pressed:bg-fd-background aria-pressed:ring-1 aria-pressed:ring-fd-border aria-pressed:shadow-sm aria-pressed:text-fd-foreground arkdown array arrow as async at audience auth authNode authProviders authSchemes authenticate authorization authorizationCode authorizationUrl authorization_code authorization_pending authorization_url authorize authorized authorizes auto-cols-[minmax(0,max-content)] autoComplete available avoid await away back backdrop-blur-[1px] backdrop-blur-xs badgeVariants bar base basic basis-full be bearer before behavior below beside between bg-amber-500 bg-amber-500/10 bg-black/40 bg-blue-500 bg-current/10 bg-fd-accent bg-fd-background bg-fd-card bg-fd-card/70 bg-fd-muted bg-fd-muted-foreground bg-fd-muted-foreground/50 bg-fd-popover bg-fd-primary bg-fd-primary/10 bg-fd-secondary bg-green-500 bg-linear-to-b bg-linear-to-t bg-red-500 bg-transparent binary block blocked blocks blue body bodyMediaType bodyNode bodyUrlRef boolean border border-0 border-b border-b-0 border-current border-dashed border-fd-border/60 border-fd-muted-foreground/50 border-fd-primary border-s border-t border-x-0 bottom bottom-0 box box-content breadcrumbs break-all browser built-in builtinAuthProviders builtinProviders bundled busy but button buttonVariants buttons by bytes cache cached cachedDocFiles callbacks callbacksNode came can cancel cancelled candidates cannot caption captionCodeBlock captioned card cardCodeBlock cards case catch cause cell center certificate ch challenge change changes charset check checkbox checked chevron chevronClassName children class class-variance-authority className cleanup clear clearResponse click client client-rendered clientAuth clientCredentials clientId clientSecret clientWidth client_auth client_credentials client_error client_id client_secret clients cloned close closeDelay closed closest cn code codeProps codeUsages code_challenge code_challenge_method code_verifier codeblock col-span-2 collapse collapses color column come component components compute confidential config configUrl configuration configurations connecting connection const constraints consumers container content contentTypes contents control controller controllerRef controls cookie cookies copies copy copyable copying core count covered covers createContext createOAuthHandler createOpenAPIPage createOpenAPIPageBase createProxy created credentials cross-origin crumbClassName crumbs css csv ctions ctx current currentValue cursor-pointer cursor-text custom customise customization dark dark:aria-pressed:bg-fd-accent dark:bg-fd-accent dark:text-amber-400 dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-active:text-fd-foreground data-checked data-checked:bg-fd-primary data-checked:bg-fd-primary-foreground data-checked:text-fd-accent-foreground data-checked:translate-x-3 data-empty:hidden data-ending-style:duration-150 data-ending-style:h-0 data-ending-style:opacity-0 data-ending-style:scale-95 data-ending-style:scale-[0.97] data-ending-style:scale-[0.98] data-highlighted:bg-fd-accent data-highlighted:text-fd-accent-foreground data-placeholder:text-fd-muted-foreground data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground data-popup-open:text-fd-foreground data-starting-style:h-0 data-starting-style:opacity-0 data-starting-style:scale-95 data-starting-style:scale-[0.98] dataEngine decimal declare decode decoration-dotted default defaultColor defaultMdxComponents defaultShikiFactory defaultShikiOptions defaultValue defaultValues defaults define definitions delay delay-150 delete deprecated depth dereference dereferenced described describes description descriptionNode descriptions detail details device deviceAuthorization deviceAuthorizationUrl device_authorization_url device_code devices dialog didn direction directories disable disableCache disabled disabled:cursor-not-allowed disabled:opacity-50 disabled:opacity-80 discovered discovering display displayNames disposition div doc docCache docFilesCache docRoot docs document documents does doesn domain don download downloaded drives drop duplicated duration duration-150 duration-200 duration-250 duration-300 during dynamic dynamicSource e each eading early ease-[cubic-bezier(0.16,1,0.3,1)] ease-[cubic-bezier(0.22,1,0.36,1)] ease-out edge edit edited editing editor edits element elements else empty enabled encode encodeRequestData encoded end ending endpoint endpoints ends enforce engine enter entries entry enum err error error_description errors eslint-disable-next-line even every example exampleCardClassName exampleCodeBlock examples exclusiveMax exclusiveMin expand expanded expands expected expiresAt expires_in export exported expressions extended extends fades failed fallback false fast-content-type-parse fd-page-tree-item-name fd-scroll-container fetch fetchOptions fetcher field field-sizing-content fieldData fieldName fields file fileName files fill-current filled filling fills filter filterable finally finishes finishing first first:border-t-0 first:mt-0 fixed flattened flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flow-root flowInfo flowReturned flows flushSync focus-visible:bg-fd-accent/40 focus-visible:bg-fd-primary/15 focus-visible:bg-fd-secondary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-primary/30 focus-visible:ring-fd-ring focus-visible:ring-fd-ring/50 focus-visible:ring-inset focus-visible:text-fd-accent-foreground focus-within:ring-1 focus-within:ring-fd-ring focus:outline-none focus:ring focus:ring-0 focus:ring-fd-ring follow font-light font-medium font-mono font-normal font-sans font-semibold for form form-encoded format forward fragment from from-fd-popover full fumadocs-core/highlight fumadocs-core/source fumadocs-core/toc fumadocs-openapi-flow fumadocs-openapi-oauth fumadocs-openapi-oauth-returned fumadocs-ui/mdx fumadocs:openapi fumadocs_openapi_requests function gap-0.5 gap-1 gap-1.5 gap-2 gap-2.5 gap-24 gap-3 gap-4 gap-x-2 gap-x-3 gap-x-6 gap-y-1 gap-y-4 generate generateDefault generateSchemaUI generateTypeScriptDefinitions generated generators get getLink getOpenAPIPageProps getPageProps getPreferredType getRaw getSchema getSchemas getState gets ghost github-dark github-light given go goes going grant_type grant_types_supported grants gray green grid grid-cols-[auto_minmax(0,1fr)] grid-cols-[auto_minmax(0,1fr)_auto] grid-cols-[minmax(0,2fr)_minmax(0,3fr)] grid-flow-col grid-rows-[auto_minmax(0,1fr)] group group-data-[panel-open]/accordion:rotate-90 group-data-popup-open:rotate-180 group-hover/nav:translate-x-0.5 group-hover/open:translate-x-0.5 group-hover/property:opacity-100 group-hover:translate-x-0.5 group-hover:translate-x-px group/accordion group/nav group/open group/property group/row h-(--accordion-panel-height) h-(--active-tab-height) h-(--collapsible-panel-height) h-10 h-12 h-4 h-5 h-6 h-7 h-8 h-9 h-[calc(--spacing(10)-1px)] h-auto h-full h-px h1 handle handled handles happens has has-focus-visible:bg-fd-secondary has-focus-visible:border-fd-ring hasVariables hash have headNode header headerRef headers heading headingLevel headless here hidden hiddenKeys highlighted highlighter hint holding holds hook hour hour12 hover hover:bg-fd-accent hover:bg-fd-accent/40 hover:bg-fd-accent/50 hover:bg-fd-primary/15 hover:bg-transparent hover:text-fd-accent-foreground hover:text-fd-foreground how href html htmlFor http hydration i icon icon-sm icon-xs iconButtonClassName id idx if img implicit import imports in includeDocument including index indicator info infoTags init initAuth initial inline inline-flex input inputMode inputs inset-0 inset-x-0 inside installed instanceof instead integer interface interval into invalid invisible is isCopied isDynamic isExpanded isHighlighted isLazy isLoading isMac isNumber isSending isn issues it item itemSchema itemToStringValue items items-baseline items-center items-start items-stretch its itself js json json-schema-typed justify-between justify-center justify-end k kB keep keeps kept key keyboard keyed keyof keys kind label labelled lang language languages larger last last:border-b-0 last:shrink-0 lasts latest layout layouts lazy leading-5 leading-relaxed leave leaving left left-0 length let light like line-clamp-3 line-through link links list listed listener listeners live load loadDocument loaded loaderPlugin loading loads location lock locked log long longer looks lucide-react make many map mapValues margin margins marked match matching max max-age max-h-(--available-height) max-h-[min(18rem,30vh)] max-h-[min(var(--available-height),20rem)] max-h-none max-md:hidden max-w-1/2 max-w-40 max-w-60 max-w-64 max-w-72 max-w-80 max-w-[calc(100vw-2rem)] max-w-full maxEntries may mb-3 mb-4 md md:border-s md:grid-cols-[minmax(0,11fr)_minmax(0,9fr)] md:hidden me-1 me-2 me-auto measure measured measures media mediaAdapters mediaType member members memoized menu menuItems merge message messages metaData metaKey method methods milliseconds mime min min-h-0 min-h-10 min-h-11 min-h-60 min-h-9 min-h-full min-w-0 min-w-16 min-w-40 min-w-[calc(var(--anchor-width)+--spacing(2))] minute mode more motion motion-reduce:transition-none motion-reduce:transition-opacity motion-safe:-translate-x-6 motion-safe:animate-pulse motion-safe:duration-300 motion-safe:ease-[cubic-bezier(0.16,1,0.3,1)] motion-safe:starting:-translate-x-2 motion-safe:starting:-translate-x-6 motion-safe:starting:-translate-y-4 motion-safe:starting:opacity-0 motion-safe:starting:scale-0 motion-safe:starting:scale-150 motion-safe:starting:translate-x-2 motion-safe:starting:translate-x-6 motion-safe:starting:translate-y-1 motion-safe:starting:translate-y-4 motion-safe:transition-[opacity,translate] motion-safe:transition-opacity motion-safe:transition-transform motionClassNames mounted ms ms-1 ms-1.5 ms-auto mt-0! mt-0.5 mt-1 mt-1.5 mt-10 mt-2.5 mt-px multipart/form-data multiple must mutual mutualTLS mx-3 mx-px my-0! my-1 my-3 name name! named names namespace narrow nav navigate navigated navigator nearest needs nested network never new next next/previous nextId no no-cache noValidate node noop noreferrer normalizes not not-prose note now null number oauth oauth2 oauthRedirectUrl object objectGet objects observer obtain of off ok older omit omitted on onAppend onAuthorize onBack onCancel onChange onCheckedChange onClear onClick onCopy onKeyDown onLink onNavigate onOpenChange onRemove onReset onReturn onRoot onSelect onSubmit onUserCode onValueChange once one oneOf ones only opacity-0 opacity-60 opacity-80 open openApiData openIdConnect openIdConnectUrl openNested openOnHover openOnInputClick openapi openapiMeta opened opening opens operation options or orange origin origin-(--transform-origin) other others otherwise out outline-none output outside over overflow-auto overflow-clip overflow-hidden overflow-x-auto overflow-y-auto override overview own p-0 p-0.5 p-1 p-1.5 p-2 p-2.5 p-3 p-4 p-5 p-6 packages padding page pageData pages panel panelCodeBlock panelKey panelTopCodeBlock panels param parameter parameterLabel parameterNode parameters params parent parentIndex parents parsed parts party pass password path pathItem pathnameFromRequest pattern patternProperties payload pb-1 pb-2 pb-2.5 pb-3 pe-1 pe-1.5 pe-2 pe-3 pe-4 pendingFlowKey per persisted pill place placed placeholder placeholder:font-sans placeholder:text-fd-muted-foreground placeholder:text-fd-muted-foreground/70 placeholder:text-fd-primary/50 plain playground playgrounds please plugins pointer-coarse:opacity-100 polite poll polling popover pops popup port position postForm pre preferred prefers prefixed preloadOpenAPIPage preloaded presents prev preventDefault preview previous primary primitive private processor prop properties property props prose prose-no-margin prose-sm prose-xs provider providers proxied proxy proxyForwardCookie proxyUrl ps-1 ps-1.5 ps-3 ps-3.5 ps-4 ps-6 pt-1.5 pt-2 pt-2.5 public px-1 px-1.5 px-2 px-2.5 px-3 px-4 py-0 py-0.5 py-1 py-1.5 py-2 py-2.5 py-3 py-6 py-8 q query quiet random range raw reach react react-dom react-hooks/exhaustive-deps read read-only readOnly readers readonly reads received record red redirect redirectUrl redirect_uri redirected redirects ref reference refs regenerated rejected rejects rel relative reloading remark remark-rehype remarkGfm remarkRehype remounted removable removal remove removeItem removed render renderAPIExampleUsageTabs renderBodyField renderCodeblock renderDefault renderMarkdown renderParameterField rendered renderers renders replace replaces represents request request-body requestBody requestData requestInit requestTimeout requestUrl requested requesting requests required requirement requirements res reserved reset resize-none resized resolve resolveMediaAdapter resolveUrl resolved resolvedInput resolvedTheme resolves respond response response-body responseNode responseTabs response_type responses rest restore restored result return returned returnedFlow returnedScheme returnedUrl returning returns reversed revoked right ring-1 ring-3 ring-fd-border ring-green-500/20 role room root rootId rounded rounded-[5px] rounded-full rounded-lg rounded-md rounded-none rounded-sm rounded-xl route row row-span-2 rowButtonClassName rows run runtime s safeParse same sample satisfies scalar scan schema schemaId schemaKeys schemaUI schemas scheme schemeId schemes scope scopeOptions scopes scopes_supported screen screens scroll scroll-m-20 scroll-mt-[calc(var(--fd-docs-row-3,0px)+1rem)] scrollArrowClassName scrollMarginClassName scrolling search second secondary seconds secret secrets section sectionIcons sectionNames sections security see segments segs select select-all select-none selectExample selectable selected selectedCodeUsages selectedType selecting selection selector selectors selects self-center self-stretch send sender sending sends sent server server-to-server serverSchema serverUrl servers services session sessionStorage set setAuthorizing setClientAuth setCode setCollapsed setDraft setFilter setIndex setInfo setMode setMotion setName setOpen setResponse setScopes setSelected setSelectedFor setSending setServerVariables setShowSchema setStack setType setUserCode setValue setView several shadow-lg shadow-md shadow-none shadow-sm share shared shared-api/auto-anchor shared-api/source shiki shikiOptions shortcut shorten show showDescription showExample showResponseSchema showTitle shown shows shrink shrink-0 shrinks sibling siblings side sideOffset signal signing single size size-2 size-3 size-3.5 size-4 size-5 skipNonRequired skipReadOnly slashes slides sliding slot slotClassName slots slow_down sm sm:-translate-x-1/2 sm:-translate-y-1/2 sm:border sm:h-[min(52rem,calc(100dvh-3rem))] sm:inline sm:inset-auto sm:left-1/2 sm:max-h-[min(52rem,calc(100dvh-3rem))] sm:mb-4 sm:mx-4 sm:ps-5 sm:px-4 sm:rounded-2xl sm:shadow-2xl sm:top-1/2 sm:w-[min(64rem,calc(100vw-3rem))] sm:w-[min(80rem,calc(100vw-3rem))] small smaller smooth so some something space spellCheck sr-only src stable stack stacked start started starting starting:opacity-0 starts state staticSource status statusInfo stay stays step stf sticky still stops storage storageKey storageKeyPrefix store stored string stringSchema stringifyFieldKey structuredData style styles submit subscribe subscribeNever successful such suggestions summary suspends svg switch switches switching sync syncExample synced t tPlayground tab tables tabs tabular-nums tag tagClassName taken takes target tell telling text text-4xl text-[0.8125rem] text-amber-600 text-blue-600 text-center text-fd-accent-foreground text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/60 text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-secondary-foreground text-green-600 text-nowrap text-orange-600 text-red-400 text-red-600 text-sm text-start text-xl text-xs text-yellow-600 text/css text/csv text/html text/plain texts than that the their them themes then there they this three through throw time timeFormat timeout timer timerRef tips title titleBarClassName tls to to-transparent toStaticData toVirtualFiles toc toggle toggled token tokenUrl token_type token_url top top-(--active-tab-top) top-0 total tracking-tight tracking-widest transform transformPageTree transition-[background-color,scale] transition-[height,opacity] transition-[height] transition-[opacity,scale] transition-[translate,background-color] transition-[translate,width] transition-colors transition-opacity transition-shadow transition-transform transitionClassName translate-x-(--active-tab-left) translations trigger true truncate truncating try turns type typeClassName typeof types typing undefined under underline underline-offset-4 union unionField unions unique unit unknown unless unset until up update updateInfo updated updating url urn:ietf:params:oauth:grant-type:device_code usage usageTabs usages use useAnchorId useAnchorLink useApiClient useComponents useCopyButton useDataEngine useFieldValue useListener useMemo useNamespace useOnChange useOpenAPI useOperation useQuery useRef useRenderContext useResolvedSchema useResponseExamples useSchemaUtils useServer useState useStf useSyncExternalStore useTheme useTranslations userCode user_code username users using v value valueSchema values variable variables variant variants verification verificationUri verificationUriComplete verification_uri verifier via view viewportClassName viewportProps views virtual void w-(--active-tab-width) w-7 w-72 w-[min(26rem,calc(100vw-2rem))] w-auto w-fit w-full w-max warn warning was we webhook webhooks what when where while whitespace-pre whitespace-pre-wrap whose why width widths will window with without would wrap wrap-anywhere wrap-break-word wrapping write writeOnly written x-exclusiveCodeSample x-playground-lazy xml yellow yet your z-0 z-10 z-50");
|
|
1
|
+
@source inline("!collapsed !headers !isSecret !readOnly !renderBodyField !required !returned *:flex-1 *:justify-center *:min-w-0 --accordion-panel-height --active-tab-height --active-tab-left --active-tab-top --active-tab-width --anchor-width --available-height --collapsible-panel-height --fd-docs-height --fd-docs-row-3 --spacing --transform-origin -me-3 -mode -ms-0.5 -ms-2 -mt-1 -my-1 -z-1 @4xl:flex @4xl:flex-col @4xl:flex-row @4xl:items-start @4xl:max-h-[calc(var(--fd-docs-height,100dvh)-var(--fd-docs-row-3,0px)-2rem)] @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-3,0px)+1rem)] @4xl:w-[400px] @container @default @defaultValue @deprecated @fuma-translate/react @fumadocs/json-schema @fumari/stf @max-sm:bg-fd-secondary/50 @max-sm:border @max-sm:mx-4 @max-sm:overflow-hidden @max-sm:pb-1.5 @max-sm:pb-3 @max-sm:pt-2 @max-sm:rounded-lg @max-xl:basis-full @max-xl:border-t @max-xl:flex-1 @max-xl:ps-1.5 @md:block @param @returns @scalar/api-client-react @see @sm:border-s @sm:flex @sm:grid-cols-[minmax(9rem,1fr)_minmax(0,2fr)] @sm:min-h-10 @sm:min-w-0 @xl:w-40 [&>div:has(>figcaption)]:h-10 [&[hidden]:not([hidden='until-found'])]:hidden [&_a]:underline [&_code]:font-mono [&_figcaption]:font-medium [&_figcaption]:overflow-visible [&_figcaption]:text-[0.8125rem] [&_figcaption]:text-fd-foreground [&_figcaption]:text-xs [&_svg]:size-3 [&_svg]:size-3.5 [--fd-docs-row-3:0px] [grid-area:1/1] [scrollbar-width:none] a abort above absolute accept access access_token accordion accordions across action actions active:scale-[0.97] activity actual adapter adapters add addLogEntry added adding additional additionalProperties adds after again against alias align aligns all allOf allow allowCopy allowJson allowed already also alt among an anchor anchorSegments and animate-spin animates another any anyFields anyOf apiExample apiKey apiPlayground appearance-none application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml applied applies apply are aren aria-checked aria-current aria-expanded aria-expanded:bg-fd-accent aria-expanded:decoration-solid aria-expanded:text-fd-accent-foreground aria-hidden aria-label aria-live aria-pressed arkdown array arrow arrows as aside async at audience auth authNode authProviders authSchemes authenticate authorization authorizationCode authorizationUrl authorization_code authorization_pending authorization_url authorize authorized authorizes auto-cols-[minmax(0,max-content)] autoComplete available avoid await away back backdrop-blur-[1px] backdrop-blur-xs badgeVariants bar base basic basis-full be bearer before behavior below beside between bg-amber-500 bg-amber-500/10 bg-black/40 bg-blue-500 bg-current/10 bg-fd-accent bg-fd-background bg-fd-card bg-fd-card/70 bg-fd-muted bg-fd-muted-foreground bg-fd-muted-foreground/50 bg-fd-popover bg-fd-primary bg-fd-primary/10 bg-fd-secondary bg-green-500 bg-linear-to-b bg-linear-to-t bg-red-500 bg-transparent binary block blocked blocks blue body bodyMediaType bodyNode bodyUrlRef boolean border border-0 border-b border-b-0 border-current border-dashed border-fd-border/60 border-fd-muted-foreground/50 border-fd-primary border-s border-t border-x-0 bottom bottom-0 box box-content breadcrumbs break-all browser built-in builtinAuthProviders builtinProviders bundled busy but button buttonVariants buttons by bytes cache cached cachedDocFiles callbacks callbacksNode came can cancel cancelled candidates cannot caption captionCodeBlock captioned card cardCodeBlock cards case catch cause cell center certificate ch challenge change changes changing charset check checkbox checked chevron chevronClassName children chosen class class-variance-authority className cleanup clear clearResponse click clicking client client-rendered clientAuth clientCredentials clientId clientSecret clientWidth client_auth client_credentials client_error client_id client_secret clients cloned close closeDelay closed closest cn code codeProps codeUsages code_challenge code_challenge_method code_verifier codeblock col-span-2 col-span-full col-start-2 collapse collapses color column come component components compute confidential config configUrl configuration configurations connecting connection const constraints consumers container content contentTypes contents control controller controllerRef controls cookie cookies copies copy copyable copying core count covered covers createContext createOAuthHandler createOpenAPIPage createOpenAPIPageBase createProxy created credentials cross-origin crumbClassName crumbs css csv ctions ctx current currentValue cursor-help cursor-pointer cursor-text custom customise customization dark dark:bg-fd-accent dark:text-amber-400 dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-active:text-fd-foreground data-checked data-checked:bg-fd-primary data-checked:bg-fd-primary-foreground data-checked:text-fd-accent-foreground data-checked:translate-x-3 data-empty:hidden data-ending-style:duration-150 data-ending-style:h-0 data-ending-style:opacity-0 data-ending-style:scale-95 data-ending-style:scale-[0.97] data-ending-style:scale-[0.98] data-highlighted:bg-fd-accent data-highlighted:text-fd-accent-foreground data-placeholder:text-fd-muted-foreground data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground data-popup-open:underline data-starting-style:h-0 data-starting-style:opacity-0 data-starting-style:scale-95 data-starting-style:scale-[0.98] dataEngine decimal declare decode decoration-dotted default defaultColor defaultMdxComponents defaultShikiFactory defaultShikiOptions defaultValue defaultValues defaults define definitions delay delay-150 delete deprecated depth dereference dereferenced described describes description descriptionNode descriptions detail details device deviceAuthorization deviceAuthorizationUrl device_authorization_url device_code devices dialog didn direction directories disable disableCache disabled disabled:cursor-not-allowed disabled:opacity-50 disabled:opacity-80 discovered discovering display displayNames disposition div doc docCache docFilesCache docRoot docs document documents does doesn domain don download downloaded drives drop duplicated duration duration-150 duration-200 duration-250 duration-300 during dynamic dynamicSource e each eading early ease-[cubic-bezier(0.16,1,0.3,1)] ease-[cubic-bezier(0.22,1,0.36,1)] ease-out edge edit edited editing editor edits element elements else empty enabled encode encodeRequestData encoded end ending endpoint endpoints ends enforce engine enter entered entries entry enum err error error_description errors eslint-disable-next-line even every example exampleCardClassName exampleCodeBlock examples exclusiveMax exclusiveMin expand expanded expands expected expiresAt expires_in export exported expressions extended extends fades failed fallback false fast-content-type-parse fd-page-tree-item-name fd-scroll-container fetch fetchOptions fetcher field field-sizing-content fieldData fieldName fields file fileName files fill-current filled filling fills filter filterable finally finishes finishing first first:border-t-0 first:mt-0 fixed flattened flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flow-root flowInfo flowReturned flows flushSync focus-visible:bg-fd-accent focus-visible:bg-fd-accent/40 focus-visible:bg-fd-primary/15 focus-visible:bg-fd-secondary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-primary/30 focus-visible:ring-fd-ring focus-visible:ring-inset focus-visible:text-fd-accent-foreground focus-within:ring-1 focus-within:ring-fd-ring focus:outline-none focus:ring focus:ring-0 focus:ring-fd-ring follow font-light font-medium font-mono font-normal font-sans font-semibold for form form-encoded format forward fragment from from-fd-popover full fumadocs-core/highlight fumadocs-core/source fumadocs-core/toc fumadocs-openapi-flow fumadocs-openapi-oauth fumadocs-openapi-oauth-returned fumadocs-ui/mdx fumadocs:openapi fumadocs_openapi_requests function gap-0.5 gap-1 gap-1.5 gap-2 gap-2.5 gap-24 gap-3 gap-4 gap-x-2 gap-x-3 gap-x-6 gap-y-1 gap-y-4 generate generateDefault generateSchemaUI generateTypeScriptDefinitions generated generators get getLink getOpenAPIPageProps getPageProps getPreferredType getRaw getSchema getSchemas getState gets ghost github-dark github-light given gives go goes going grant_type grant_types_supported grants gray green grid grid-cols-[auto_minmax(0,1fr)] grid-cols-[auto_minmax(0,1fr)_auto] grid-cols-[minmax(0,1fr)_auto] grid-cols-[minmax(0,2fr)_minmax(0,3fr)] grid-flow-col grid-rows-[auto_minmax(0,1fr)] group group-data-[panel-open]/accordion:rotate-90 group-data-popup-open:rotate-180 group-hover/nav:translate-x-0.5 group-hover/open:translate-x-0.5 group-hover/property:opacity-100 group-hover:translate-x-0.5 group-hover:translate-x-px group/accordion group/nav group/open group/property group/row h-(--accordion-panel-height) h-(--active-tab-height) h-(--collapsible-panel-height) h-10 h-12 h-4 h-6 h-7 h-8 h-9 h-[calc(--spacing(10)-1px)] h-full h-px h1 handle handled handles happens has has-focus-visible:bg-fd-secondary hasVariables hash have headNode header headerRef headers heading headingLevel headless here hidden hiddenKeys highlighted highlighter highlights hint holding hook hour hour12 hover hover:bg-fd-accent hover:bg-fd-accent/40 hover:bg-fd-accent/50 hover:bg-fd-primary/15 hover:text-fd-accent-foreground hover:underline how href html htmlFor http hydration i icon icon-sm icon-xs iconButtonClassName id idx if img implicit import imports in includeDocument including index indicator info infoTags init initAuth initial inline inline-flex input inputMode inputs inset-0 inset-x-0 inside installed instanceof instead integer interface interval into invalid invisible is isCopied isDynamic isExpanded isHighlighted isLazy isLoading isMac isNumber isSecret isSending isn issues it item itemSchema itemToStringValue items items-baseline items-center items-start items-stretch its itself js json json-schema-typed justify-between justify-center justify-end k kB keep keeps kept key keyboard keyed keyof keys kind label labelled lang language languages larger last last:border-b-0 last:shrink-0 lasts latest layout layouts lazy leading-5 leading-[1.375rem] leading-relaxed leave leaving left left-0 length let light like line line-clamp-3 line-through link links list listed listener listeners literal live load loadDocument loaded loaderPlugin loading loads location lock locked log long longer looks lucide-react make many map mapValues margin margins marked masked match matches matching max max-age max-h-(--available-height) max-h-[min(18rem,30vh)] max-h-[min(var(--available-height),20rem)] max-h-none max-md:hidden max-w-1/2 max-w-40 max-w-60 max-w-64 max-w-72 max-w-80 max-w-[calc(100vw-2rem)] max-w-full maxEntries may mb-3 mb-4 md md:border-s md:grid-cols-[minmax(0,11fr)_minmax(0,9fr)] md:hidden me-1 me-2 me-auto measure measured measures media mediaAdapters mediaType member members memoized menu menuItems merge message messages metaData metaKey method methods milliseconds mime min min-h-0 min-h-10 min-h-11 min-h-60 min-h-9 min-h-full min-w-0 min-w-16 min-w-40 min-w-[calc(var(--anchor-width)+--spacing(2))] minute mode more motion motion-reduce:transition-none motion-reduce:transition-opacity motion-safe:-translate-x-6 motion-safe:animate-pulse motion-safe:duration-300 motion-safe:ease-[cubic-bezier(0.16,1,0.3,1)] motion-safe:starting:-translate-x-2 motion-safe:starting:-translate-x-6 motion-safe:starting:-translate-y-4 motion-safe:starting:opacity-0 motion-safe:starting:scale-0 motion-safe:starting:scale-150 motion-safe:starting:translate-x-2 motion-safe:starting:translate-x-6 motion-safe:starting:translate-y-1 motion-safe:starting:translate-y-4 motion-safe:transition-[opacity,translate] motion-safe:transition-opacity motion-safe:transition-transform motionClassNames mounted move moves ms ms-1 ms-1.5 ms-auto mt-0! mt-0.5 mt-1 mt-1.5 mt-10 mt-2.5 mt-px multi-type multipart/form-data multiple must muted mutual mutualTLS mx-3 mx-px my-0! my-1 my-3 name name! nameClassName named names namespace narrow nav navigate navigated navigator nearest needs nested network never new next next/previous nextId no no-cache noValidate node noop noreferrer normalizes not not-first:border-s not-prose note now null number oauth oauth2 oauthRedirectUrl object objectGet objects observer obtain of off ok older omit omitted on onAppend onAuthorize onBack onCancel onChange onCheckedChange onClear onClick onCopy onKeyDown onLink onNavigate onOpenChange onRemove onReset onReturn onRoot onSelect onSubmit onUserCode onValueChange once one oneOf ones only opacity-0 opacity-60 opacity-80 open openApiData openIdConnect openIdConnectUrl openNested openOnHover openOnInputClick openapi openapiMeta opened opening opens operation optional options or orange origin origin-(--transform-origin) other others otherwise out outline-none output outside over overflow-auto overflow-clip overflow-hidden overflow-x-auto overflow-y-auto override overview own p-0.5 p-1 p-1.5 p-2 p-2.5 p-3 p-4 p-5 p-6 packages padding page pageData pages panel panelCodeBlock panelKey panelTopCodeBlock panels param parameter parameterLabel parameterNode parameters params parent parentIndex parents parsed parts party pass password paste path pathItem pathnameFromRequest pattern patternProperties payload pb-1 pb-2 pb-2.5 pb-3 pe-1 pe-1.5 pe-2 pe-3 pe-4 pendingFlowKey per persisted pill place placed placeholder placeholder:font-sans placeholder:text-fd-muted-foreground placeholder:text-fd-muted-foreground/70 placeholder:text-fd-primary/50 plain playground playgrounds please plugins pointer-coarse:opacity-100 polite poll polling popover pops popup port position postForm pre preferred prefers preloadOpenAPIPage preloaded presents prev preventDefault preview previous primary primitive private processor prop properties property props prose prose-no-margin prose-sm prose-xs provider providers proxied proxy proxyForwardCookie proxyUrl ps-1 ps-1.5 ps-3 ps-3.5 ps-4 ps-6 pt-1.5 pt-2 pt-2.5 public px-1 px-1.5 px-2 px-2.5 px-3 px-4 py-0 py-0.5 py-1 py-1.5 py-2 py-2.5 py-3 py-6 py-8 q query quiet random range raw reach react react-dom react-hooks/exhaustive-deps read read-only readOnly readers readonly reads received record red redirect redirectUrl redirect_uri redirected redirects ref reference refs regenerated rejected rejects rel relative reloading remark remark-rehype remarkGfm remarkRehype remounted removable removal remove removeItem removed render renderAPIExampleUsageTabs renderBodyField renderCodeblock renderDefault renderMarkdown renderParameterField rendered renderers renders replace replaces represents request request-body requestBody requestData requestInit requestTimeout requestUrl requested requesting requests required requirement requirements res reset resize-none resized resolve resolveMediaAdapter resolveUrl resolved resolvedInput resolvedTheme resolves respond response response-body responseNode responseTabs response_type responses rest restore restored result return returned returnedFlow returnedScheme returnedUrl returning returns reversed revoked right ring-1 ring-3 ring-fd-border ring-green-500/20 role room root rootId rounded-[5px] rounded-full rounded-lg rounded-md rounded-none rounded-sm rounded-xl route row row-span-2 row-start-1 row-start-2 rowButtonClassName rows run runtime s safeParse same sample satisfies scalar scan schema schemaId schemaKeys schemaUI schemas scheme schemeId schemes scope scopeOptions scopes scopes_supported screen screens scroll scroll-m-20 scroll-mt-[calc(var(--fd-docs-row-3,0px)+1rem)] scrollArrowClassName scrollMarginClassName scrolling search second secondary seconds secret secretSchema secrets section sectionIcons sectionNames sections security see segment segmentClassName segments segs select select-all select-none selectExample selectable selected selectedCodeUsages selectedType selecting selection selector selectors selects self-center self-stretch send sender sending sends sent server server-to-server serverSchema serverUrl servers services session sessionStorage set setAuthorizing setClientAuth setCode setCollapsed setDraft setFilter setIndex setInfo setMode setMotion setName setOpen setResponse setScopes setSelected setSelectedFor setSending setServerVariables setShowSchema setStack setType setUserCode setValue setView several shadow-lg shadow-md shadow-none shadow-sm share shared shared-api/auto-anchor shared-api/source shiki shikiOptions shortcut shorten show showDescription showExample showResponseSchema showTitle shown shows shrink shrink-0 shrinks sibling siblings side sideOffset signal signing single sits size size-2 size-3 size-3.5 size-4 size-5 skipNonRequired skipReadOnly slashes slides sliding slots slow_down sm sm:-translate-x-1/2 sm:-translate-y-1/2 sm:border sm:h-[min(52rem,calc(100dvh-3rem))] sm:inline sm:inset-auto sm:left-1/2 sm:max-h-[min(52rem,calc(100dvh-3rem))] sm:mb-4 sm:mx-4 sm:ps-5 sm:px-4 sm:rounded-2xl sm:shadow-2xl sm:top-1/2 sm:w-[min(64rem,calc(100vw-3rem))] sm:w-[min(80rem,calc(100vw-3rem))] small smaller smooth so some something space spellCheck sr-only src stable stack start started starting starting:opacity-0 starts state staticSource status statusInfo stay stays step stf sticky still stops storage storageKey storageKeyPrefix store stored string stringifyFieldKey structuredData style styles submit subscribe subscribeNever successful such suggestions summary suspends svg switch switches switching sync syncExample synced t tPlayground tab tabIndex tabs tabular-nums tag tagClassName taken takes target telling text text-4xl text-[0.8125rem] text-amber-600 text-blue-600 text-center text-fd-accent-foreground text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/60 text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-secondary-foreground text-green-600 text-nowrap text-orange-600 text-red-400 text-red-600 text-sm text-start text-xl text-xs text-yellow-600 text/css text/csv text/html text/plain texts than that the their them themes then there they this three through throw time timeFormat timeout timer timerRef tips title titleBarClassName tls to to-transparent toStaticData toVirtualFiles toc toggle toggled token tokenUrl token_type token_url top top-(--active-tab-top) top-0 total tracking-tight tracking-widest transform transformPageTree transition-[background-color,scale] transition-[height,opacity] transition-[height] transition-[opacity,scale] transition-[translate,background-color] transition-[translate,width] transition-colors transition-opacity transition-shadow transition-transform transitionClassName translate-x-(--active-tab-left) translations trigger true truncate truncating try turns type typeClassName typeof types typing undefined under underline underline-offset-4 union unionField unions unique unit unknown unless unset unsetting until up update updateInfo updated updating url urn:ietf:params:oauth:grant-type:device_code usage usageTabs usages use useAnchorId useAnchorLink useApiClient useComponents useCopyButton useDataEngine useFieldValue useListener useMemo useNamespace useOnChange useOpenAPI useOperation useQuery useRef useRenderContext useResolvedSchema useResponseExamples useSchemaUtils useServer useState useStf useSyncExternalStore useTheme useTranslations userCode user_code username users using v value valueSchema values variable variables variant variants verification verificationUri verificationUriComplete verification_uri verifier via view viewportClassName viewportProps views virtual void w-(--active-tab-width) w-6 w-7 w-72 w-[min(26rem,calc(100vw-2rem))] w-auto w-fit w-full w-max warn warning was we webhook webhooks what when where while whitespace-pre whitespace-pre-wrap whole whose why width widths will window with without would wrap wrap-anywhere wrap-break-word wrapping write writeOnly written x-exclusiveCodeSample x-playground-lazy xml yellow yet your z-0 z-10 z-50");
|
|
@@ -2,6 +2,7 @@ export type Translations = {
|
|
|
2
2
|
"1 item(playground)": string;
|
|
3
3
|
"Accepted(playground status info)": string;
|
|
4
4
|
"Add Item(playground)": string;
|
|
5
|
+
"Add {name}(playground)": string;
|
|
5
6
|
"Add(playground)": string;
|
|
6
7
|
"Back(playground)": string;
|
|
7
8
|
"Bad Gateway(playground status info)": string;
|
|
@@ -28,7 +29,6 @@ export type Translations = {
|
|
|
28
29
|
"Error(playground status info)": string;
|
|
29
30
|
"Example(playground)": string;
|
|
30
31
|
"Example(schema UI)": string;
|
|
31
|
-
"Field Info(playground)": string;
|
|
32
32
|
"Filter Properties(schema UI)": string;
|
|
33
33
|
"Forbidden(playground status info)": string;
|
|
34
34
|
"Format(schema UI)": string;
|
|
@@ -63,7 +63,6 @@ export type Translations = {
|
|
|
63
63
|
"Show Path(schema UI)(aria-label)": string;
|
|
64
64
|
"Show Property(playground)": string;
|
|
65
65
|
"Successful(playground status info)": string;
|
|
66
|
-
"Suggestions(playground)": string;
|
|
67
66
|
"Switch Field(playground)": string;
|
|
68
67
|
"Too Many Requests(playground status info)": string;
|
|
69
68
|
"Try in Playground(playground)": string;
|
|
@@ -3,6 +3,7 @@ var keys_default = [
|
|
|
3
3
|
"1 item(playground)",
|
|
4
4
|
"Accepted(playground status info)",
|
|
5
5
|
"Add Item(playground)",
|
|
6
|
+
"Add {name}(playground)",
|
|
6
7
|
"Add(playground)",
|
|
7
8
|
"Back(playground)",
|
|
8
9
|
"Bad Gateway(playground status info)",
|
|
@@ -29,7 +30,6 @@ var keys_default = [
|
|
|
29
30
|
"Error(playground status info)",
|
|
30
31
|
"Example(playground)",
|
|
31
32
|
"Example(schema UI)",
|
|
32
|
-
"Field Info(playground)",
|
|
33
33
|
"Filter Properties(schema UI)",
|
|
34
34
|
"Forbidden(playground status info)",
|
|
35
35
|
"Format(schema UI)",
|
|
@@ -64,7 +64,6 @@ var keys_default = [
|
|
|
64
64
|
"Show Path(schema UI)(aria-label)",
|
|
65
65
|
"Show Property(playground)",
|
|
66
66
|
"Successful(playground status info)",
|
|
67
|
-
"Suggestions(playground)",
|
|
68
67
|
"Switch Field(playground)",
|
|
69
68
|
"Too Many Requests(playground status info)",
|
|
70
69
|
"Try in Playground(playground)",
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { anyFields, useFieldInfo, useResolvedSchema, useSchemaContext, useSchemaUtils } from "./schema.js";
|
|
3
|
-
import { Select as Select$2, SelectContent, SelectItem,
|
|
3
|
+
import { Select as Select$2, SelectContent, SelectItem, SelectValue } from "../select.js";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
5
|
import { Fragment, useId, useMemo, useState } from "react";
|
|
6
6
|
import { dereference, matches, matchesType, mergeAllOf, stringify } from "@fumadocs/json-schema";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useTranslations } from "@fuma-translate/react";
|
|
9
|
-
import { Check, ChevronDown, ChevronRight, ChevronsUpDown, Copy,
|
|
9
|
+
import { Check, ChevronDown, ChevronRight, ChevronsUpDown, Copy, Plus, Trash2, Upload, X } from "lucide-react";
|
|
10
10
|
import { Select } from "@base-ui/react/select";
|
|
11
11
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
12
12
|
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
13
|
+
import { flushSync } from "react-dom";
|
|
13
14
|
import { useArray, useDataEngine, useFieldValue, useObject } from "@fumari/stf";
|
|
14
15
|
import { isPlainObject, stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
15
16
|
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
16
17
|
import { Popover } from "@base-ui/react/popover";
|
|
17
18
|
// ../shared-api/dist/components/playground/fields.js
|
|
18
|
-
/**
|
|
19
|
-
const
|
|
20
|
-
/**
|
|
21
|
-
|
|
19
|
+
/** a segment of the type pill, the type or an action on the field */
|
|
20
|
+
const segmentClassName = "flex items-center transition-colors not-first:border-s hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:bg-fd-accent focus-visible:outline-none data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground";
|
|
21
|
+
/** the type of a field and the actions on it, like changing its type or unsetting it */
|
|
22
|
+
function TypePill({ type, action, quiet = false }) {
|
|
23
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
24
|
+
className: cn("flex h-6 shrink-0 items-stretch overflow-hidden rounded-md border bg-fd-secondary font-mono text-xs", quiet ? "text-fd-muted-foreground/70" : "text-fd-muted-foreground"),
|
|
25
|
+
children: [typeof type === "string" ? /* @__PURE__ */ jsx("span", {
|
|
26
|
+
className: "max-w-40 truncate px-1.5 leading-[1.375rem]",
|
|
27
|
+
title: type,
|
|
28
|
+
children: type
|
|
29
|
+
}) : type, action]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
22
32
|
const rowButtonClassName = "flex h-10 w-full items-center gap-2 px-4 text-[0.8125rem] text-fd-muted-foreground transition-colors hover:bg-fd-accent/40 hover:text-fd-accent-foreground focus-visible:bg-fd-secondary focus-visible:text-fd-accent-foreground focus-visible:outline-none";
|
|
23
33
|
function getType(field) {
|
|
24
34
|
if (typeof field.type === "string") return field.type;
|
|
@@ -39,7 +49,7 @@ function getOptions(field) {
|
|
|
39
49
|
value: item.const,
|
|
40
50
|
label: item.title ?? valueLabel(item.const)
|
|
41
51
|
}));
|
|
42
|
-
return (field.const !== void 0 ? [field.const] : field.enum)?.map((value) => ({
|
|
52
|
+
return (field.const !== void 0 ? [field.const] : field.enum ?? (field.type === "boolean" ? [true, false] : void 0))?.map((value) => ({
|
|
43
53
|
value,
|
|
44
54
|
label: valueLabel(value)
|
|
45
55
|
}));
|
|
@@ -103,19 +113,7 @@ function SchemaSwitch({ fieldName, schema, depth = 0, children }) {
|
|
|
103
113
|
const { info, updateInfo } = useFieldInfo(fieldName, field, depth);
|
|
104
114
|
const union = info.unionField ? field[info.unionField] : void 0;
|
|
105
115
|
const types = Array.isArray(field.type) ? field.type : void 0;
|
|
106
|
-
const member = useMemo(() =>
|
|
107
|
-
if (union && union.length > 0) return union[info.oneOf];
|
|
108
|
-
if (types) return {
|
|
109
|
-
...field,
|
|
110
|
-
type: info.selectedType ?? types[0]
|
|
111
|
-
};
|
|
112
|
-
}, [
|
|
113
|
-
field,
|
|
114
|
-
union,
|
|
115
|
-
types,
|
|
116
|
-
info.oneOf,
|
|
117
|
-
info.selectedType
|
|
118
|
-
]);
|
|
116
|
+
const member = useMemo(() => getMember(field, info), [field, info]);
|
|
119
117
|
if (member === void 0 || isConstUnion(union) || getSuggestions(field)) return children(field, null);
|
|
120
118
|
let selector = null;
|
|
121
119
|
if (union && union.length > 1) selector = /* @__PURE__ */ jsx(TypeSelect, {
|
|
@@ -141,6 +139,19 @@ function SchemaSwitch({ fieldName, schema, depth = 0, children }) {
|
|
|
141
139
|
children: (resolved, inner) => children(resolved, joinNodes(selector, inner))
|
|
142
140
|
});
|
|
143
141
|
}
|
|
142
|
+
/** the member of a union or a multi-type field chosen by `info` */
|
|
143
|
+
function getMember(field, info) {
|
|
144
|
+
const union = info.unionField ? field[info.unionField] : void 0;
|
|
145
|
+
if (union && union.length > 0) return union[info.oneOf];
|
|
146
|
+
if (!Array.isArray(field.type)) return;
|
|
147
|
+
const type = info.selectedType ?? field.type[0];
|
|
148
|
+
return {
|
|
149
|
+
...field,
|
|
150
|
+
type,
|
|
151
|
+
default: matchesType(field.default, type) ? field.default : void 0,
|
|
152
|
+
examples: field.examples?.filter((example) => matchesType(example, type))
|
|
153
|
+
};
|
|
154
|
+
}
|
|
144
155
|
function TypeSelect({ value, options, onChange }) {
|
|
145
156
|
const t = useTranslations({ note: "playground" });
|
|
146
157
|
return /* @__PURE__ */ jsxs(Select$2, {
|
|
@@ -149,7 +160,7 @@ function TypeSelect({ value, options, onChange }) {
|
|
|
149
160
|
onValueChange: (v) => v !== null && onChange(v),
|
|
150
161
|
children: [/* @__PURE__ */ jsxs(Select.Trigger, {
|
|
151
162
|
"aria-label": t("Type"),
|
|
152
|
-
className: "
|
|
163
|
+
className: cn(segmentClassName, "max-w-40 min-w-0 cursor-pointer gap-0.5 ps-1.5 pe-1"),
|
|
153
164
|
children: [/* @__PURE__ */ jsx(SelectValue, { className: "truncate" }), /* @__PURE__ */ jsx(Select.Icon, {
|
|
154
165
|
className: "shrink-0",
|
|
155
166
|
children: /* @__PURE__ */ jsx(ChevronsUpDown, { className: "size-3" })
|
|
@@ -161,28 +172,55 @@ function TypeSelect({ value, options, onChange }) {
|
|
|
161
172
|
}, option.value)) })]
|
|
162
173
|
});
|
|
163
174
|
}
|
|
164
|
-
/** a field in the editor: its name
|
|
165
|
-
function Row({ name, required = false, info, htmlFor, readOnly = false, children }) {
|
|
175
|
+
/** a field in the editor: its name, its input filling the cell, then its type and actions */
|
|
176
|
+
function Row({ name, required = false, info, htmlFor, readOnly = false, quiet = false, aside, children }) {
|
|
177
|
+
const nameClassName = cn("truncate font-mono text-[0.8125rem]", quiet ? "text-fd-muted-foreground" : "text-fd-foreground");
|
|
166
178
|
return /* @__PURE__ */ jsxs("div", {
|
|
167
|
-
className: "group/row grid border-b last:border-b-0 @max-sm:pb-3 @sm:min-h-10 @sm:grid-cols-[minmax(9rem,1fr)_minmax(0,2fr)]",
|
|
179
|
+
className: cn("group/row grid grid-cols-[minmax(0,1fr)_auto] border-b transition-colors last:border-b-0 @max-sm:pb-3 @sm:min-h-10 @sm:grid-cols-[minmax(9rem,1fr)_minmax(0,2fr)]", !readOnly && "hover:bg-fd-accent/40 has-focus-visible:bg-fd-secondary"),
|
|
168
180
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
169
181
|
className: "flex min-w-0 items-center gap-1 py-2 ps-4 pe-3 @max-sm:pb-1.5",
|
|
170
|
-
children: [
|
|
182
|
+
children: [info ? /* @__PURE__ */ jsxs(Popover.Root, { children: [
|
|
171
183
|
/* @__PURE__ */ jsx("label", {
|
|
172
184
|
htmlFor,
|
|
173
|
-
|
|
174
|
-
className: "truncate font-mono text-[0.8125rem] text-fd-foreground",
|
|
185
|
+
className: "sr-only",
|
|
175
186
|
children: name
|
|
176
187
|
}),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
/* @__PURE__ */ jsx(Popover.Trigger, {
|
|
189
|
+
openOnHover: true,
|
|
190
|
+
delay: 200,
|
|
191
|
+
closeDelay: 100,
|
|
192
|
+
title: name,
|
|
193
|
+
className: cn(nameClassName, "cursor-help rounded-sm decoration-dotted underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring data-popup-open:underline"),
|
|
194
|
+
children: name
|
|
180
195
|
}),
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
/* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
197
|
+
side: "bottom",
|
|
198
|
+
align: "start",
|
|
199
|
+
sideOffset: 6,
|
|
200
|
+
className: "z-50",
|
|
201
|
+
children: /* @__PURE__ */ jsx(Popover.Popup, {
|
|
202
|
+
className: "w-72 max-w-[calc(100vw-2rem)] origin-(--transform-origin) rounded-xl border bg-fd-popover p-3 text-fd-popover-foreground shadow-lg outline-none transition-[opacity,scale] duration-150 ease-out data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none",
|
|
203
|
+
children: info
|
|
204
|
+
})
|
|
205
|
+
}) })
|
|
206
|
+
] }) : /* @__PURE__ */ jsx("label", {
|
|
207
|
+
htmlFor,
|
|
208
|
+
title: name,
|
|
209
|
+
className: nameClassName,
|
|
210
|
+
children: name
|
|
211
|
+
}), required && /* @__PURE__ */ jsx("span", {
|
|
212
|
+
className: "-ms-0.5 text-red-400",
|
|
213
|
+
children: "*"
|
|
214
|
+
})]
|
|
215
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
216
|
+
className: "contents @sm:flex @sm:min-w-0",
|
|
217
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
218
|
+
className: "col-span-full row-start-2 flex min-h-9 min-w-0 flex-1 items-stretch text-[0.8125rem] @max-sm:mx-4 @max-sm:overflow-hidden @max-sm:rounded-lg @max-sm:border @max-sm:bg-fd-secondary/50 @sm:min-h-10 @sm:border-s",
|
|
219
|
+
children
|
|
220
|
+
}), aside && /* @__PURE__ */ jsx("div", {
|
|
221
|
+
className: "col-start-2 row-start-1 flex shrink-0 items-center pe-4 @max-sm:pt-2 @max-sm:pb-1.5",
|
|
222
|
+
children: aside
|
|
223
|
+
})]
|
|
186
224
|
})]
|
|
187
225
|
});
|
|
188
226
|
}
|
|
@@ -195,10 +233,9 @@ function formatRange(value, min, exclusiveMin, max, exclusiveMax) {
|
|
|
195
233
|
else if (exclusiveMax !== void 0) out.push(`< ${exclusiveMax}`);
|
|
196
234
|
if (out.length > 1) return out.join(" ");
|
|
197
235
|
}
|
|
198
|
-
/** the
|
|
199
|
-
function
|
|
236
|
+
/** the card of a field: its description and constraints, `null` without them */
|
|
237
|
+
function useFieldCard(name, field, description) {
|
|
200
238
|
const t = useTranslations({ note: "schema UI" });
|
|
201
|
-
const tPlayground = useTranslations({ note: "playground" });
|
|
202
239
|
const constraints = [];
|
|
203
240
|
if (field.default !== void 0) constraints.push([t("Default"), JSON.stringify(field.default)]);
|
|
204
241
|
let range = formatRange("value", field.minimum, field.exclusiveMinimum, field.maximum, field.exclusiveMaximum);
|
|
@@ -211,112 +248,77 @@ function FieldInfo({ name, field, description }) {
|
|
|
211
248
|
if (field.pattern) constraints.push([t("Match"), field.pattern]);
|
|
212
249
|
if (field.examples && field.examples.length > 0) constraints.push([t("Example"), JSON.stringify(field.examples[0])]);
|
|
213
250
|
if (!description && constraints.length === 0) return null;
|
|
214
|
-
return /* @__PURE__ */ jsxs(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
description && /* @__PURE__ */ jsx("div", {
|
|
240
|
-
className: "mt-1.5 text-xs leading-relaxed text-fd-muted-foreground prose-no-margin [&_a]:underline [&_code]:font-mono",
|
|
241
|
-
children: /* @__PURE__ */ jsx(FieldMarkdown, { md: description })
|
|
242
|
-
}),
|
|
243
|
-
constraints.length > 0 && /* @__PURE__ */ jsx("dl", {
|
|
244
|
-
className: "mt-2.5 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-t pt-2.5 text-xs",
|
|
245
|
-
children: constraints.map(([label, value]) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
|
|
246
|
-
className: "text-fd-muted-foreground",
|
|
247
|
-
children: label
|
|
248
|
-
}), /* @__PURE__ */ jsx("dd", {
|
|
249
|
-
className: "truncate font-mono",
|
|
250
|
-
title: value,
|
|
251
|
-
children: value
|
|
252
|
-
})] }, label))
|
|
253
|
-
})
|
|
254
|
-
]
|
|
251
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
252
|
+
/* @__PURE__ */ jsxs("p", {
|
|
253
|
+
className: "flex items-baseline gap-3",
|
|
254
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
255
|
+
className: "truncate font-mono text-[0.8125rem] font-medium",
|
|
256
|
+
children: name
|
|
257
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
258
|
+
className: "ms-auto shrink-0 font-mono text-xs text-fd-muted-foreground",
|
|
259
|
+
children: typeLabel(field)
|
|
260
|
+
})]
|
|
261
|
+
}),
|
|
262
|
+
description && /* @__PURE__ */ jsx("div", {
|
|
263
|
+
className: "mt-1.5 text-xs leading-relaxed text-fd-muted-foreground prose-no-margin [&_a]:underline [&_code]:font-mono",
|
|
264
|
+
children: /* @__PURE__ */ jsx(FieldMarkdown, { md: description })
|
|
265
|
+
}),
|
|
266
|
+
constraints.length > 0 && /* @__PURE__ */ jsx("dl", {
|
|
267
|
+
className: "mt-2.5 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-t pt-2.5 text-xs",
|
|
268
|
+
children: constraints.map(([label, value]) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
|
|
269
|
+
className: "text-fd-muted-foreground",
|
|
270
|
+
children: label
|
|
271
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
272
|
+
className: "truncate font-mono",
|
|
273
|
+
title: value,
|
|
274
|
+
children: value
|
|
275
|
+
})] }, label))
|
|
255
276
|
})
|
|
256
|
-
|
|
277
|
+
] });
|
|
257
278
|
}
|
|
258
|
-
function
|
|
279
|
+
function ActionButton({ label, onClick, tabIndex, children }) {
|
|
259
280
|
return /* @__PURE__ */ jsx("button", {
|
|
260
281
|
type: "button",
|
|
261
282
|
"aria-label": label,
|
|
262
283
|
title: label,
|
|
284
|
+
tabIndex,
|
|
263
285
|
onClick,
|
|
264
|
-
className: "
|
|
286
|
+
className: cn(segmentClassName, "w-6 justify-center [&_svg]:size-3"),
|
|
265
287
|
children
|
|
266
288
|
});
|
|
267
289
|
}
|
|
268
|
-
function
|
|
269
|
-
const engine = useDataEngine();
|
|
270
|
-
const t = useTranslations({ note: "playground" });
|
|
271
|
-
const [isDefined] = useFieldValue(fieldName, { compute: (value) => value !== void 0 });
|
|
272
|
-
if (!isDefined) return null;
|
|
273
|
-
return /* @__PURE__ */ jsx(SlotButton, {
|
|
274
|
-
label: t("Unset"),
|
|
275
|
-
onClick: () => engine.delete(fieldName),
|
|
276
|
-
children: /* @__PURE__ */ jsx(X, {})
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
function ValueRow({ fieldName, field, type, end, required, marked = required, name, description, slot }) {
|
|
290
|
+
function ValueRow({ fieldName, field, type, start, end, required, marked = required, name, description, action }) {
|
|
280
291
|
const id = stringifyFieldKey(fieldName);
|
|
281
292
|
return /* @__PURE__ */ jsxs(Row, {
|
|
282
293
|
name,
|
|
283
294
|
required: marked,
|
|
284
295
|
htmlFor: id,
|
|
285
|
-
info:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
296
|
+
info: useFieldCard(name, field, description),
|
|
297
|
+
aside: (type || action) && /* @__PURE__ */ jsx(TypePill, {
|
|
298
|
+
type,
|
|
299
|
+
action
|
|
289
300
|
}),
|
|
290
301
|
children: [
|
|
302
|
+
start && /* @__PURE__ */ jsx("label", {
|
|
303
|
+
htmlFor: id,
|
|
304
|
+
className: "flex shrink-0 items-center ps-3 text-fd-muted-foreground",
|
|
305
|
+
children: start
|
|
306
|
+
}),
|
|
291
307
|
/* @__PURE__ */ jsx(FieldValue, {
|
|
292
308
|
id,
|
|
293
309
|
fieldName,
|
|
294
|
-
field
|
|
295
|
-
required
|
|
296
|
-
}),
|
|
297
|
-
type && /* @__PURE__ */ jsx("span", {
|
|
298
|
-
className: typeClassName,
|
|
299
|
-
children: type
|
|
310
|
+
field
|
|
300
311
|
}),
|
|
301
|
-
end
|
|
302
|
-
/* @__PURE__ */ jsx("span", {
|
|
303
|
-
className: slotClassName,
|
|
304
|
-
children: slot
|
|
305
|
-
})
|
|
312
|
+
end
|
|
306
313
|
]
|
|
307
314
|
});
|
|
308
315
|
}
|
|
309
|
-
/** the type in the cell of a primitive field, its selector when it has multiple */
|
|
310
|
-
function cellType(field, selector) {
|
|
311
|
-
if (selector) return selector;
|
|
312
|
-
if (field.type !== "null" && !getOptions(field) && !getSuggestions(field)) return typeLabel(field);
|
|
313
|
-
}
|
|
314
316
|
/** the input of a primitive field */
|
|
315
|
-
function FieldValue({ id, fieldName, field
|
|
317
|
+
function FieldValue({ id, fieldName, field }) {
|
|
316
318
|
const [value, setValue] = useFieldValue(fieldName);
|
|
317
319
|
const t = useTranslations({ note: "playground" });
|
|
318
320
|
if (field.type === "null") return /* @__PURE__ */ jsx("span", {
|
|
319
|
-
className: "flex flex-1 items-center px-3 font-mono text-
|
|
321
|
+
className: "flex flex-1 items-center px-3 font-mono text-xs",
|
|
320
322
|
children: "null"
|
|
321
323
|
});
|
|
322
324
|
if (field.type === "string" && field.format === "binary") return /* @__PURE__ */ jsxs("label", {
|
|
@@ -353,44 +355,30 @@ function FieldValue({ id, fieldName, field, required = false }) {
|
|
|
353
355
|
const options = getOptions(field);
|
|
354
356
|
if (options && options.length > 0) {
|
|
355
357
|
const idx = options.findIndex((option) => option.value === value);
|
|
356
|
-
const items = options.map((option, i) => ({
|
|
357
|
-
value: String(i),
|
|
358
|
-
label: option.label
|
|
359
|
-
}));
|
|
360
|
-
if (!required) items.push({
|
|
361
|
-
value: "-1",
|
|
362
|
-
label: /* @__PURE__ */ jsx("span", {
|
|
363
|
-
className: "text-fd-muted-foreground",
|
|
364
|
-
children: t("Unset")
|
|
365
|
-
})
|
|
366
|
-
});
|
|
367
358
|
return /* @__PURE__ */ jsx(CellSelect, {
|
|
368
359
|
id,
|
|
369
|
-
items,
|
|
370
|
-
|
|
371
|
-
|
|
360
|
+
items: options.map((option, i) => ({
|
|
361
|
+
value: String(i),
|
|
362
|
+
label: /* @__PURE__ */ jsx("span", {
|
|
363
|
+
className: "font-mono text-xs",
|
|
364
|
+
children: option.label
|
|
365
|
+
})
|
|
366
|
+
})),
|
|
367
|
+
value: idx !== -1 ? String(idx) : null,
|
|
368
|
+
onValueChange: (v) => setValue(options[Number(v)].value),
|
|
372
369
|
placeholder: t("Select")
|
|
373
370
|
});
|
|
374
371
|
}
|
|
375
|
-
if (field.type === "boolean") return /* @__PURE__ */ jsx("div", {
|
|
376
|
-
className: "flex flex-1 items-center gap-0.5 ps-1 pe-2",
|
|
377
|
-
children: [true, false].map((option) => /* @__PURE__ */ jsx("button", {
|
|
378
|
-
type: "button",
|
|
379
|
-
"aria-pressed": value === option,
|
|
380
|
-
onClick: () => setValue(option),
|
|
381
|
-
className: "h-6 rounded px-2 font-mono text-xs text-fd-muted-foreground transition-colors hover:text-fd-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring aria-pressed:bg-fd-background aria-pressed:text-fd-foreground aria-pressed:shadow-sm aria-pressed:ring-1 aria-pressed:ring-fd-border dark:aria-pressed:bg-fd-accent",
|
|
382
|
-
children: String(option)
|
|
383
|
-
}, String(option)))
|
|
384
|
-
});
|
|
385
372
|
const isNumber = field.type === "integer" || field.type === "number";
|
|
373
|
+
const isSecret = field.format === "password";
|
|
386
374
|
const hint = field.default ?? field.examples?.[0];
|
|
387
375
|
return /* @__PURE__ */ jsx("input", {
|
|
388
376
|
id,
|
|
389
|
-
type: isNumber ? "number" :
|
|
377
|
+
type: isNumber ? "number" : isSecret ? "password" : "text",
|
|
390
378
|
step: isNumber ? "any" : void 0,
|
|
391
379
|
autoComplete: "off",
|
|
392
380
|
spellCheck: false,
|
|
393
|
-
placeholder: value === "" ? "\"\"" : hint !== void 0 && typeof hint !== "object" ? String(hint) : t("Enter value"),
|
|
381
|
+
placeholder: value === "" && !isSecret ? "\"\"" : hint !== void 0 && typeof hint !== "object" ? String(hint) : t("Enter value"),
|
|
394
382
|
value: value == null ? "" : String(value),
|
|
395
383
|
onChange: (e) => {
|
|
396
384
|
if (!isNumber) setValue(e.target.value);
|
|
@@ -400,7 +388,7 @@ function FieldValue({ id, fieldName, field, required = false }) {
|
|
|
400
388
|
});
|
|
401
389
|
}
|
|
402
390
|
/** an object or array, opened in its own panel */
|
|
403
|
-
function NavRow({ fieldName, field, type, required, marked = required, name, description, onNavigate }) {
|
|
391
|
+
function NavRow({ fieldName, field, type, required, marked = required, name, description, action, onNavigate }) {
|
|
404
392
|
const t = useTranslations({ note: "playground" });
|
|
405
393
|
const id = stringifyFieldKey(fieldName);
|
|
406
394
|
const [preview] = useFieldValue(fieldName, { compute(value) {
|
|
@@ -417,57 +405,44 @@ function NavRow({ fieldName, field, type, required, marked = required, name, des
|
|
|
417
405
|
name,
|
|
418
406
|
required: marked,
|
|
419
407
|
htmlFor: id,
|
|
420
|
-
info:
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
408
|
+
info: useFieldCard(name, field, description),
|
|
409
|
+
aside: /* @__PURE__ */ jsx(TypePill, {
|
|
410
|
+
type,
|
|
411
|
+
action
|
|
424
412
|
}),
|
|
425
|
-
children: /* @__PURE__ */ jsx(
|
|
413
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
426
414
|
id,
|
|
427
|
-
type,
|
|
415
|
+
type: "button",
|
|
428
416
|
onClick: onNavigate,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
417
|
+
className: "flex min-w-0 flex-1 items-center px-3 text-start outline-none",
|
|
418
|
+
children: preview !== null ? /* @__PURE__ */ jsx("span", {
|
|
419
|
+
className: "truncate font-mono text-xs",
|
|
420
|
+
children: preview
|
|
421
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
422
|
+
className: "text-fd-muted-foreground/70",
|
|
423
|
+
children: t("Not set")
|
|
432
424
|
})
|
|
433
425
|
})
|
|
434
426
|
});
|
|
435
427
|
}
|
|
436
|
-
/** fills a cell, opens something else on click */
|
|
437
|
-
function NavButton({ id, type, onClick, children }) {
|
|
438
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
439
|
-
id,
|
|
440
|
-
type: "button",
|
|
441
|
-
onClick,
|
|
442
|
-
className: "group/nav flex min-w-0 flex-1 items-center ps-3 text-start outline-none",
|
|
443
|
-
children: [
|
|
444
|
-
/* @__PURE__ */ jsx("span", {
|
|
445
|
-
className: "min-w-0 flex-1 truncate pe-2",
|
|
446
|
-
children
|
|
447
|
-
}),
|
|
448
|
-
type && /* @__PURE__ */ jsx("span", {
|
|
449
|
-
className: typeClassName,
|
|
450
|
-
children: type
|
|
451
|
-
}),
|
|
452
|
-
/* @__PURE__ */ jsx("span", {
|
|
453
|
-
className: slotClassName,
|
|
454
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground transition-transform duration-200 group-hover/nav:translate-x-0.5 motion-reduce:transition-none" })
|
|
455
|
-
})
|
|
456
|
-
]
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
428
|
/** a select filling a cell */
|
|
460
429
|
function CellSelect({ id, items, value, onValueChange, placeholder }) {
|
|
461
430
|
return /* @__PURE__ */ jsxs(Select$2, {
|
|
462
431
|
items,
|
|
463
432
|
value,
|
|
464
433
|
onValueChange: (v) => v !== null && onValueChange(v),
|
|
465
|
-
children: [/* @__PURE__ */ jsx(
|
|
434
|
+
children: [/* @__PURE__ */ jsx(Select.Trigger, {
|
|
466
435
|
id,
|
|
467
|
-
className: "
|
|
468
|
-
children: /* @__PURE__ */
|
|
469
|
-
className: "
|
|
470
|
-
|
|
436
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center px-3 text-start text-fd-foreground outline-none data-placeholder:text-fd-muted-foreground",
|
|
437
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
438
|
+
className: "flex min-w-0 flex-1 items-center justify-between gap-2 font-mono text-xs",
|
|
439
|
+
children: [/* @__PURE__ */ jsx(SelectValue, {
|
|
440
|
+
className: "truncate",
|
|
441
|
+
placeholder
|
|
442
|
+
}), /* @__PURE__ */ jsx(Select.Icon, {
|
|
443
|
+
className: "shrink-0 text-fd-muted-foreground",
|
|
444
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })
|
|
445
|
+
})]
|
|
471
446
|
})
|
|
472
447
|
}), /* @__PURE__ */ jsx(SelectContent, { children: items.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
473
448
|
value: item.value,
|
|
@@ -485,7 +460,6 @@ function matchesSuggestion(item, query) {
|
|
|
485
460
|
return item.value.toLowerCase().includes(q) || item.label.toLowerCase().includes(q);
|
|
486
461
|
}
|
|
487
462
|
function CellAutocomplete({ id, items, value, onValueChange, placeholder }) {
|
|
488
|
-
const t = useTranslations({ note: "playground" });
|
|
489
463
|
const filled = items.some((item) => item.value === value);
|
|
490
464
|
return /* @__PURE__ */ jsxs(Autocomplete.Root, {
|
|
491
465
|
items,
|
|
@@ -494,18 +468,14 @@ function CellAutocomplete({ id, items, value, onValueChange, placeholder }) {
|
|
|
494
468
|
itemToStringValue: (item) => item.value,
|
|
495
469
|
filter: filled ? null : matchesSuggestion,
|
|
496
470
|
openOnInputClick: true,
|
|
497
|
-
children: [/* @__PURE__ */
|
|
471
|
+
children: [/* @__PURE__ */ jsx(Autocomplete.InputGroup, {
|
|
498
472
|
className: "flex min-w-0 flex-1 items-center",
|
|
499
|
-
children:
|
|
473
|
+
children: /* @__PURE__ */ jsx(Autocomplete.Input, {
|
|
500
474
|
id,
|
|
501
475
|
spellCheck: false,
|
|
502
476
|
placeholder,
|
|
503
477
|
className: "min-w-0 flex-1 self-stretch bg-transparent px-3 text-fd-foreground outline-none placeholder:text-fd-muted-foreground/70"
|
|
504
|
-
})
|
|
505
|
-
"aria-label": t("Suggestions"),
|
|
506
|
-
className: "flex shrink-0 items-center pe-1 text-fd-muted-foreground",
|
|
507
|
-
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })
|
|
508
|
-
})]
|
|
478
|
+
})
|
|
509
479
|
}), /* @__PURE__ */ jsx(Autocomplete.Portal, { children: /* @__PURE__ */ jsx(Autocomplete.Positioner, {
|
|
510
480
|
align: "start",
|
|
511
481
|
sideOffset: 4,
|
|
@@ -523,41 +493,35 @@ function CellAutocomplete({ id, items, value, onValueChange, placeholder }) {
|
|
|
523
493
|
}
|
|
524
494
|
function SelectRow({ name, ...props }) {
|
|
525
495
|
const id = useId();
|
|
526
|
-
return /* @__PURE__ */
|
|
496
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
527
497
|
name,
|
|
528
498
|
htmlFor: id,
|
|
529
|
-
children:
|
|
499
|
+
children: /* @__PURE__ */ jsx(CellSelect, {
|
|
530
500
|
id,
|
|
531
501
|
...props
|
|
532
|
-
})
|
|
502
|
+
})
|
|
533
503
|
});
|
|
534
504
|
}
|
|
535
505
|
/** a row of read-only text */
|
|
536
506
|
function TextRow({ name, description, copyable = false, children }) {
|
|
537
|
-
return /* @__PURE__ */
|
|
507
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
538
508
|
name,
|
|
539
509
|
readOnly: true,
|
|
540
|
-
info:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
description
|
|
544
|
-
}),
|
|
545
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
510
|
+
info: useFieldCard(name, { type: "string" }, description),
|
|
511
|
+
aside: copyable && /* @__PURE__ */ jsx(TypePill, { action: /* @__PURE__ */ jsx(CopyButton, { text: children }) }),
|
|
512
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
546
513
|
className: "flex min-w-0 flex-1 items-center px-3 text-fd-muted-foreground",
|
|
547
514
|
children: /* @__PURE__ */ jsx("span", {
|
|
548
515
|
className: "truncate",
|
|
549
516
|
children
|
|
550
517
|
})
|
|
551
|
-
})
|
|
552
|
-
className: slotClassName,
|
|
553
|
-
children: copyable && /* @__PURE__ */ jsx(CopyButton, { text: children })
|
|
554
|
-
})]
|
|
518
|
+
})
|
|
555
519
|
});
|
|
556
520
|
}
|
|
557
521
|
function CopyButton({ text }) {
|
|
558
522
|
const t = useTranslations({ note: "playground" });
|
|
559
523
|
const [isChecked, onCopy] = useCopyButton(() => navigator.clipboard.writeText(text));
|
|
560
|
-
return /* @__PURE__ */ jsx(
|
|
524
|
+
return /* @__PURE__ */ jsx(ActionButton, {
|
|
561
525
|
label: isChecked ? t("Copied", { note: "aria-label" }) : t("Copy", { note: "aria-label" }),
|
|
562
526
|
onClick: onCopy,
|
|
563
527
|
children: isChecked ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {})
|
|
@@ -569,20 +533,19 @@ function LinkRow({ name, onClick, children }) {
|
|
|
569
533
|
type: "button",
|
|
570
534
|
onClick,
|
|
571
535
|
className: cn(rowButtonClassName, "group/nav border-b last:border-b-0"),
|
|
572
|
-
children: [
|
|
573
|
-
|
|
574
|
-
|
|
536
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
537
|
+
className: "flex min-w-0 flex-1 items-center gap-1.5 text-start",
|
|
538
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
539
|
+
className: "truncate",
|
|
575
540
|
children
|
|
576
|
-
}),
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
/* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 transition-transform duration-200 group-hover/nav:translate-x-0.5 motion-reduce:transition-none" })
|
|
582
|
-
]
|
|
541
|
+
}), /* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 shrink-0 text-fd-muted-foreground transition-transform duration-200 group-hover/nav:translate-x-0.5 motion-reduce:transition-none" })]
|
|
542
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
543
|
+
className: "shrink-0 font-mono text-xs text-fd-muted-foreground",
|
|
544
|
+
children: name
|
|
545
|
+
})]
|
|
583
546
|
});
|
|
584
547
|
}
|
|
585
|
-
/** a row toggled on click, its check box
|
|
548
|
+
/** a row toggled on click, its check box in the last column */
|
|
586
549
|
function CheckRow({ name, checked, onCheckedChange, children }) {
|
|
587
550
|
const id = useId();
|
|
588
551
|
return /* @__PURE__ */ jsx(Row, {
|
|
@@ -594,12 +557,12 @@ function CheckRow({ name, checked, onCheckedChange, children }) {
|
|
|
594
557
|
role: "checkbox",
|
|
595
558
|
"aria-checked": checked,
|
|
596
559
|
onClick: () => onCheckedChange(!checked),
|
|
597
|
-
className: "flex min-w-0 flex-1 items-center
|
|
560
|
+
className: "flex min-w-0 flex-1 items-center gap-2 px-3 text-start outline-none",
|
|
598
561
|
children: [/* @__PURE__ */ jsx("span", {
|
|
599
|
-
className: "min-w-0 flex-1 truncate
|
|
562
|
+
className: "min-w-0 flex-1 truncate text-fd-muted-foreground",
|
|
600
563
|
children
|
|
601
564
|
}), /* @__PURE__ */ jsx("span", {
|
|
602
|
-
className:
|
|
565
|
+
className: "flex shrink-0",
|
|
603
566
|
children: /* @__PURE__ */ jsx("span", {
|
|
604
567
|
className: cn("flex size-4 items-center justify-center rounded-[5px] border transition-colors", checked ? "border-fd-primary bg-fd-primary text-fd-primary-foreground" : "border-fd-muted-foreground/50"),
|
|
605
568
|
children: checked && /* @__PURE__ */ jsx(Check, { className: "size-3" })
|
|
@@ -608,6 +571,58 @@ function CheckRow({ name, checked, onCheckedChange, children }) {
|
|
|
608
571
|
})
|
|
609
572
|
});
|
|
610
573
|
}
|
|
574
|
+
/** an optional field out of the request, clicking it adds the field and moves to its input */
|
|
575
|
+
function QuietRow({ name, fieldName, field, description, type, onNavigate }) {
|
|
576
|
+
const engine = useDataEngine();
|
|
577
|
+
const { generateDefault } = useSchemaUtils();
|
|
578
|
+
const { info } = useFieldInfo(fieldName, field);
|
|
579
|
+
const t = useTranslations({ note: "playground" });
|
|
580
|
+
const id = stringifyFieldKey(fieldName);
|
|
581
|
+
const label = t("Add {name}", { variables: { name } });
|
|
582
|
+
const example = field.const ?? field.default ?? field.examples?.[0];
|
|
583
|
+
const hint = example !== null && typeof example === "object" ? void 0 : example;
|
|
584
|
+
const member = getMember(field, info) ?? field;
|
|
585
|
+
function add() {
|
|
586
|
+
engine.update(fieldName, generateDefault(member));
|
|
587
|
+
}
|
|
588
|
+
/** add it, then move to its editor */
|
|
589
|
+
function edit() {
|
|
590
|
+
flushSync(add);
|
|
591
|
+
const kind = getType(resolveField(member, engine.get(fieldName)) ?? field);
|
|
592
|
+
if (kind === "object" || kind === "array") return onNavigate();
|
|
593
|
+
const editor = document.getElementById(id);
|
|
594
|
+
editor?.focus();
|
|
595
|
+
if (editor instanceof HTMLInputElement) editor.select();
|
|
596
|
+
else editor?.click();
|
|
597
|
+
}
|
|
598
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
599
|
+
name,
|
|
600
|
+
htmlFor: id,
|
|
601
|
+
quiet: true,
|
|
602
|
+
info: useFieldCard(name, field, description),
|
|
603
|
+
aside: /* @__PURE__ */ jsx(TypePill, {
|
|
604
|
+
quiet: true,
|
|
605
|
+
type: type ?? typeLabel(field, true),
|
|
606
|
+
action: /* @__PURE__ */ jsx(ActionButton, {
|
|
607
|
+
label,
|
|
608
|
+
tabIndex: -1,
|
|
609
|
+
onClick: add,
|
|
610
|
+
children: /* @__PURE__ */ jsx(Plus, {})
|
|
611
|
+
})
|
|
612
|
+
}),
|
|
613
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
614
|
+
id,
|
|
615
|
+
type: "button",
|
|
616
|
+
"aria-label": label,
|
|
617
|
+
onClick: edit,
|
|
618
|
+
className: "flex min-w-0 flex-1 items-center px-3 text-start text-fd-muted-foreground/70 outline-none",
|
|
619
|
+
children: hint !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
620
|
+
className: cn("truncate", (typeof hint !== "string" || getOptions(field)) && "font-mono text-xs"),
|
|
621
|
+
children: valueLabel(hint)
|
|
622
|
+
})
|
|
623
|
+
})
|
|
624
|
+
});
|
|
625
|
+
}
|
|
611
626
|
function getRemoval(required, removable) {
|
|
612
627
|
if (removable) return "remove";
|
|
613
628
|
if (!required) return "unset";
|
|
@@ -615,8 +630,21 @@ function getRemoval(required, removable) {
|
|
|
615
630
|
function FieldRow({ entry: { name, fieldName, schema }, required = false, description, type: label, onNavigate, onRemove }) {
|
|
616
631
|
const { readOnly, writeOnly } = useSchemaContext();
|
|
617
632
|
const resolved = useResolvedSchema(schema);
|
|
633
|
+
const engine = useDataEngine();
|
|
618
634
|
const t = useTranslations({ note: "playground" });
|
|
635
|
+
const [isUnset] = useFieldValue(fieldName, { compute: (value) => value === void 0 });
|
|
619
636
|
if (schema === false) return null;
|
|
637
|
+
if (!required && isUnset) {
|
|
638
|
+
if (resolved.readOnly && !readOnly || resolved.writeOnly && !writeOnly) return null;
|
|
639
|
+
return /* @__PURE__ */ jsx(QuietRow, {
|
|
640
|
+
name,
|
|
641
|
+
fieldName,
|
|
642
|
+
field: resolved,
|
|
643
|
+
description: description ?? resolved.description,
|
|
644
|
+
type: label,
|
|
645
|
+
onNavigate
|
|
646
|
+
});
|
|
647
|
+
}
|
|
620
648
|
return /* @__PURE__ */ jsx(SchemaSwitch, {
|
|
621
649
|
fieldName,
|
|
622
650
|
schema,
|
|
@@ -629,11 +657,15 @@ function FieldRow({ entry: { name, fieldName, schema }, required = false, descri
|
|
|
629
657
|
description: description ?? resolved.description ?? field.description,
|
|
630
658
|
fieldName,
|
|
631
659
|
field,
|
|
632
|
-
|
|
660
|
+
action: onRemove ? /* @__PURE__ */ jsx(ActionButton, {
|
|
633
661
|
label: t("Remove Item", { note: "aria-label" }),
|
|
634
662
|
onClick: onRemove,
|
|
635
663
|
children: /* @__PURE__ */ jsx(Trash2, {})
|
|
636
|
-
}) : !required && /* @__PURE__ */ jsx(
|
|
664
|
+
}) : !required && /* @__PURE__ */ jsx(ActionButton, {
|
|
665
|
+
label: t("Unset"),
|
|
666
|
+
onClick: () => engine.delete(fieldName),
|
|
667
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
668
|
+
})
|
|
637
669
|
};
|
|
638
670
|
const type = getType(field);
|
|
639
671
|
if (type === "object" || type === "array") return /* @__PURE__ */ jsx(NavRow, {
|
|
@@ -643,7 +675,7 @@ function FieldRow({ entry: { name, fieldName, schema }, required = false, descri
|
|
|
643
675
|
});
|
|
644
676
|
return /* @__PURE__ */ jsx(ValueRow, {
|
|
645
677
|
...props,
|
|
646
|
-
type: selector ?? label ??
|
|
678
|
+
type: selector ?? label ?? typeLabel(field)
|
|
647
679
|
});
|
|
648
680
|
}
|
|
649
681
|
});
|
|
@@ -678,9 +710,18 @@ function ObjectRows({ fieldName, field, onNavigate }) {
|
|
|
678
710
|
hiddenKeys.length > 0 && /* @__PURE__ */ jsxs(Select$2, {
|
|
679
711
|
value: null,
|
|
680
712
|
onValueChange: (v) => v !== null && onAppend(v),
|
|
681
|
-
children: [/* @__PURE__ */ jsxs(
|
|
682
|
-
className: cn(rowButtonClassName, "
|
|
683
|
-
children: [/* @__PURE__ */ jsx(Plus, { className: "size-3.5" }), /* @__PURE__ */
|
|
713
|
+
children: [/* @__PURE__ */ jsxs(Select.Trigger, {
|
|
714
|
+
className: cn(rowButtonClassName, "cursor-pointer border-b last:border-b-0"),
|
|
715
|
+
children: [/* @__PURE__ */ jsx(Plus, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ jsxs("span", {
|
|
716
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
717
|
+
children: [/* @__PURE__ */ jsx(SelectValue, {
|
|
718
|
+
className: "truncate",
|
|
719
|
+
placeholder: t("Show Property")
|
|
720
|
+
}), /* @__PURE__ */ jsx(Select.Icon, {
|
|
721
|
+
className: "shrink-0",
|
|
722
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })
|
|
723
|
+
})]
|
|
724
|
+
})]
|
|
684
725
|
}), /* @__PURE__ */ jsx(SelectContent, { children: hiddenKeys.map((key) => /* @__PURE__ */ jsx(SelectItem, {
|
|
685
726
|
value: key,
|
|
686
727
|
className: "font-mono text-[0.8125rem]",
|
|
@@ -698,7 +739,7 @@ function NewPropertyRow({ onAppend }) {
|
|
|
698
739
|
setName("");
|
|
699
740
|
}
|
|
700
741
|
return /* @__PURE__ */ jsxs("div", {
|
|
701
|
-
className: "flex min-h-10 items-center gap-2 border-b ps-4 pe-
|
|
742
|
+
className: "flex min-h-10 items-center gap-2 border-b ps-4 pe-4 last:border-b-0",
|
|
702
743
|
children: [
|
|
703
744
|
/* @__PURE__ */ jsx(Plus, { className: "size-3.5 shrink-0 text-fd-muted-foreground" }),
|
|
704
745
|
/* @__PURE__ */ jsx("input", {
|
|
@@ -770,7 +811,7 @@ function FieldRows({ entry, onNavigate, showDescription = false }) {
|
|
|
770
811
|
});
|
|
771
812
|
else rows = /* @__PURE__ */ jsx(ValueRow, {
|
|
772
813
|
name: entry.name,
|
|
773
|
-
type:
|
|
814
|
+
type: typeLabel(field),
|
|
774
815
|
required: true,
|
|
775
816
|
fieldName: entry.fieldName,
|
|
776
817
|
field
|
|
@@ -781,10 +822,10 @@ function FieldRows({ entry, onNavigate, showDescription = false }) {
|
|
|
781
822
|
children: /* @__PURE__ */ jsx(FieldMarkdown, { md: field.description })
|
|
782
823
|
}),
|
|
783
824
|
selector && /* @__PURE__ */ jsxs("div", {
|
|
784
|
-
className: "flex min-h-10 items-center gap-2 border-b ps-4 pe-4 text-xs text-fd-muted-foreground
|
|
825
|
+
className: "flex min-h-10 items-center gap-2 border-b ps-4 pe-4 text-xs text-fd-muted-foreground",
|
|
785
826
|
children: [t("Schema"), /* @__PURE__ */ jsx("span", {
|
|
786
827
|
className: "ms-auto",
|
|
787
|
-
children: selector
|
|
828
|
+
children: /* @__PURE__ */ jsx(TypePill, { type: selector })
|
|
788
829
|
})]
|
|
789
830
|
}),
|
|
790
831
|
rows
|
|
@@ -215,7 +215,7 @@ function SiblingSelect({ entry, siblings, onSelect }) {
|
|
|
215
215
|
},
|
|
216
216
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
217
217
|
"aria-label": t("Switch Field"),
|
|
218
|
-
className: "h-7 w-auto min-w-0 gap-1 border-0 bg-transparent px-1.5 py-0 font-mono text-[0.8125rem] font-medium text-fd-foreground hover:bg-fd-accent focus:ring-0 focus-visible:ring-2 data-popup-open:bg-fd-accent",
|
|
218
|
+
className: "h-7 w-auto min-w-0 gap-1.5 border-0 bg-transparent px-1.5 py-0 font-mono text-[0.8125rem] font-medium text-fd-foreground hover:bg-fd-accent focus:ring-0 focus-visible:ring-2 data-popup-open:bg-fd-accent",
|
|
219
219
|
children: /* @__PURE__ */ jsx(SelectValue, { className: "truncate" })
|
|
220
220
|
}), /* @__PURE__ */ jsx(SelectContent, { children: items.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
221
221
|
value: item.value,
|
|
@@ -229,7 +229,7 @@ function Section({ icon: Icon, title, count, actions, children }) {
|
|
|
229
229
|
return /* @__PURE__ */ jsxs("section", {
|
|
230
230
|
className: "border-b last:border-b-0",
|
|
231
231
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
232
|
-
className: "sticky top-0 z-10 flex h-10 items-center gap-2 border-b bg-fd-card ps-4 pe-
|
|
232
|
+
className: "sticky top-0 z-10 flex h-10 items-center gap-2 border-b bg-fd-card ps-4 pe-4",
|
|
233
233
|
children: [
|
|
234
234
|
/* @__PURE__ */ jsx(Icon, { className: "size-3.5 shrink-0 text-fd-primary" }),
|
|
235
235
|
/* @__PURE__ */ jsx("h3", {
|
|
@@ -17,11 +17,11 @@ function ServerPopover({ label, title, options, value, onValueChange, className,
|
|
|
17
17
|
open,
|
|
18
18
|
onOpenChange: setOpen,
|
|
19
19
|
children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
20
|
-
className: cn("group flex min-w-0 shrink items-center gap-1 rounded-lg px-1.5 py-1 text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground", className),
|
|
20
|
+
className: cn("group flex min-w-0 shrink items-center gap-1.5 rounded-lg px-1.5 py-1 text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground", className),
|
|
21
21
|
children: [/* @__PURE__ */ jsx("span", {
|
|
22
22
|
className: "truncate",
|
|
23
23
|
children: label
|
|
24
|
-
}), /* @__PURE__ */ jsx(ChevronDown, { className: "size-3 shrink-0 transition-transform duration-200 group-data-popup-open:rotate-180" })]
|
|
24
|
+
}), /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5 shrink-0 transition-transform duration-200 group-data-popup-open:rotate-180" })]
|
|
25
25
|
}), /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
26
26
|
side: "bottom",
|
|
27
27
|
align: "start",
|
|
@@ -41,7 +41,7 @@ function SelectTabTrigger({ items, className, ...props }) {
|
|
|
41
41
|
value,
|
|
42
42
|
onValueChange: setValue,
|
|
43
43
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
44
|
-
className: cn("not-prose h-7 w-auto min-w-0 gap-1 border-0 bg-transparent px-1.5 py-0 text-[0.8125rem] font-medium *:min-w-0 hover:bg-fd-accent hover:text-fd-accent-foreground focus:ring-0 focus-visible:ring-2 focus-visible:ring-inset data-popup-open:bg-fd-accent", className),
|
|
44
|
+
className: cn("not-prose h-7 w-auto min-w-0 gap-1.5 border-0 bg-transparent px-1.5 py-0 text-[0.8125rem] font-medium *:min-w-0 hover:bg-fd-accent hover:text-fd-accent-foreground focus:ring-0 focus-visible:ring-2 focus-visible:ring-inset data-popup-open:bg-fd-accent", className),
|
|
45
45
|
...props,
|
|
46
46
|
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
47
47
|
}), /* @__PURE__ */ jsx(SelectContent, { children: items.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, {
|
|
@@ -154,8 +154,11 @@ export interface AuthRenderProps {
|
|
|
154
154
|
name: string;
|
|
155
155
|
type?: string;
|
|
156
156
|
description?: string;
|
|
157
|
+
/** a secret string by default, entered in a password input */
|
|
157
158
|
schema?: Exclude<JsonSchema, boolean>;
|
|
158
159
|
path?: string;
|
|
160
|
+
/** fixed text before the input, like the scheme of a token */
|
|
161
|
+
start?: ReactNode;
|
|
159
162
|
/** after the input, like a button filling the value */
|
|
160
163
|
end?: ReactNode;
|
|
161
164
|
}>;
|
|
@@ -189,8 +192,12 @@ export interface AuthFields {
|
|
|
189
192
|
select: (index: number) => void;
|
|
190
193
|
/** the fields of the selected requirement */
|
|
191
194
|
fields: AuthField[];
|
|
192
|
-
/**
|
|
193
|
-
|
|
195
|
+
/**
|
|
196
|
+
* encode the auth values of page into request data, like the form values
|
|
197
|
+
*
|
|
198
|
+
* @param masked - replace the values with `********`, for code usages
|
|
199
|
+
*/
|
|
200
|
+
mapValues: <T>(values: T, masked?: boolean) => T;
|
|
194
201
|
/** restore the persisted values, returns a cleanup */
|
|
195
202
|
init: () => () => void;
|
|
196
203
|
}
|
package/dist/playground/auth.js
CHANGED
|
@@ -363,14 +363,11 @@ const builtinProviders = [
|
|
|
363
363
|
name: "username",
|
|
364
364
|
type: "basic",
|
|
365
365
|
description: field.scheme.description,
|
|
366
|
-
path: "username"
|
|
366
|
+
path: "username",
|
|
367
|
+
schema: { type: "string" }
|
|
367
368
|
}), /* @__PURE__ */ jsx(Value, {
|
|
368
369
|
name: "password",
|
|
369
|
-
path: "password"
|
|
370
|
-
schema: {
|
|
371
|
-
type: "string",
|
|
372
|
-
format: "password"
|
|
373
|
-
}
|
|
370
|
+
path: "password"
|
|
374
371
|
})] }),
|
|
375
372
|
onRequest(data, value) {
|
|
376
373
|
const { username, password } = value;
|
|
@@ -394,13 +391,15 @@ const builtinProviders = [
|
|
|
394
391
|
onRequest() {}
|
|
395
392
|
},
|
|
396
393
|
{
|
|
397
|
-
render: ({ field, Value }) => /* @__PURE__ */ jsx(Value, {
|
|
394
|
+
render: ({ field: { scheme }, Value }) => /* @__PURE__ */ jsx(Value, {
|
|
398
395
|
name: "Authorization",
|
|
399
396
|
type: "header",
|
|
400
|
-
|
|
397
|
+
start: getAuthScheme(scheme),
|
|
398
|
+
description: scheme.description
|
|
401
399
|
}),
|
|
402
|
-
onRequest(data, value) {
|
|
403
|
-
|
|
400
|
+
onRequest(data, value, { scheme }) {
|
|
401
|
+
const token = value;
|
|
402
|
+
data.header.Authorization = token.includes(" ") ? token : `${getAuthScheme(scheme)} ${token}`;
|
|
404
403
|
}
|
|
405
404
|
}
|
|
406
405
|
];
|
|
@@ -414,14 +413,17 @@ function findProvider(providers = [], item) {
|
|
|
414
413
|
return provider;
|
|
415
414
|
}
|
|
416
415
|
function getDefaultValue(scheme) {
|
|
417
|
-
if (scheme.type === "apiKey") return "";
|
|
418
416
|
if (scheme.type === "mutualTLS") return null;
|
|
419
|
-
if (scheme.type
|
|
420
|
-
if (scheme.scheme.toLowerCase() === "basic") return {
|
|
417
|
+
if (scheme.type === "http" && scheme.scheme?.toLowerCase() === "basic") return {
|
|
421
418
|
username: "",
|
|
422
419
|
password: ""
|
|
423
420
|
};
|
|
424
|
-
return
|
|
421
|
+
return "";
|
|
422
|
+
}
|
|
423
|
+
/** the scheme of `Authorization` header, like `Bearer` */
|
|
424
|
+
function getAuthScheme(scheme) {
|
|
425
|
+
if (scheme.type !== "http" || !scheme.scheme) return "Bearer";
|
|
426
|
+
return `${scheme.scheme[0].toUpperCase()}${scheme.scheme.slice(1)}`;
|
|
425
427
|
}
|
|
426
428
|
/**
|
|
427
429
|
* The auth fields of an API playground: the values it persists, and the request data they encode into.
|
|
@@ -492,10 +494,11 @@ function useAuthFields(engine, { operation, providers, transform } = {}) {
|
|
|
492
494
|
selected,
|
|
493
495
|
select,
|
|
494
496
|
fields,
|
|
495
|
-
mapValues: useCallback((values) => {
|
|
497
|
+
mapValues: useCallback((values, masked) => {
|
|
498
|
+
const auth = page.get(["auth"]) ?? {};
|
|
496
499
|
const cloned = structuredClone({
|
|
497
500
|
...values,
|
|
498
|
-
auth:
|
|
501
|
+
auth: masked ? JSON.parse(JSON.stringify(auth), (_, v) => typeof v === "string" && v ? "********" : v) : auth
|
|
499
502
|
});
|
|
500
503
|
const data = cloned;
|
|
501
504
|
for (const field of fields) field.provider.onRequest(data, objectGet(data, field.fieldName), field);
|
|
@@ -79,14 +79,14 @@ function usePlayground({ authProviders, transformAuthInputs, fetchOptions } = {}
|
|
|
79
79
|
providers: authProviders,
|
|
80
80
|
transform: transformAuthInputs
|
|
81
81
|
});
|
|
82
|
-
function getRequestData() {
|
|
82
|
+
function getRequestData(masked) {
|
|
83
83
|
return auth.mapValues({
|
|
84
84
|
...engine.getData(),
|
|
85
85
|
method,
|
|
86
86
|
bodyMediaType: body?.mediaType
|
|
87
|
-
});
|
|
87
|
+
}, masked);
|
|
88
88
|
}
|
|
89
|
-
const syncExample = useEffectEvent(() => update(getRequestData()));
|
|
89
|
+
const syncExample = useEffectEvent(() => update(getRequestData(true)));
|
|
90
90
|
const [selectedFor, setSelectedFor] = useState();
|
|
91
91
|
if (returnedScheme !== selectedFor) {
|
|
92
92
|
setSelectedFor(returnedScheme);
|
|
@@ -151,7 +151,7 @@ function AuthSection({ auth, onAuthorize }) {
|
|
|
151
151
|
value: selected,
|
|
152
152
|
onValueChange: (v) => v !== null && select(v),
|
|
153
153
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
154
|
-
className: "h-7 w-auto max-w-60 gap-1.5
|
|
154
|
+
className: "h-7 w-auto max-w-60 -me-3 gap-1.5 border-0 bg-transparent px-2 text-xs hover:bg-fd-accent focus:ring-0 focus-visible:ring-2",
|
|
155
155
|
children: /* @__PURE__ */ jsx(SelectValue, { className: "truncate" })
|
|
156
156
|
}), /* @__PURE__ */ jsx(SelectContent, {
|
|
157
157
|
align: "end",
|
|
@@ -182,8 +182,11 @@ function AuthSection({ auth, onAuthorize }) {
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
const AuthFieldContext = createContext(null);
|
|
185
|
-
const
|
|
186
|
-
|
|
185
|
+
const secretSchema = {
|
|
186
|
+
type: "string",
|
|
187
|
+
format: "password"
|
|
188
|
+
};
|
|
189
|
+
function AuthValue({ path, schema = secretSchema, ...props }) {
|
|
187
190
|
const { field } = use(AuthFieldContext);
|
|
188
191
|
return /* @__PURE__ */ jsx(ValueRow, {
|
|
189
192
|
...props,
|
|
@@ -228,7 +231,6 @@ function BodySection({ body, renderBodyField, onNavigate }) {
|
|
|
228
231
|
}), allowJson && /* @__PURE__ */ jsx(Segmented, {
|
|
229
232
|
value: mode,
|
|
230
233
|
onValueChange: setMode,
|
|
231
|
-
className: "@sm:-me-2.5",
|
|
232
234
|
children: /* @__PURE__ */ jsx(SegmentedList, {
|
|
233
235
|
"aria-label": t("Editor"),
|
|
234
236
|
items: [{
|