UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

136 lines (135 loc) 5.47 kB
import { defineComponent as V, computed as f, createBlock as r, openBlock as a, unref as l, withCtx as c, createElementVNode as n, createVNode as i, normalizeClass as A, toDisplayString as d, createCommentVNode as p, withModifiers as w, createTextVNode as m, createElementBlock as x, Fragment as B, renderList as O } from "vue"; import { Disclosure as T, DisclosureButton as $, DisclosurePanel as j } from "@headlessui/vue"; import { DataTableCell as v, DataTableRow as z, DataTableCheckbox as N } from "@scalar/api-client/components/DataTable"; import { ScalarButton as g, ScalarIcon as E } from "@scalar/components"; const F = { class: "flex h-fit w-full" }, I = { class: "flex-1" }, R = { class: "flex items-center gap-1.75" }, L = { class: "grid auto-rows-auto", style: { gridTemplateColumns: "1fr auto" } }, M = { key: 0 }, P = { class: "font-code text-xs" }, K = /* @__PURE__ */ V({ __name: "OAuthScopesInput", props: { flow: {}, updateScheme: { type: Function } }, setup(e) { const k = f( () => Object.entries(e.flow?.scopes ?? {}).map(([s, t]) => ({ id: s, label: s, description: t })) ), u = f(() => e.flow?.selectedScopes || []); function y(s, t) { t ? e.updateScheme(`flows.${e.flow.type}.selectedScopes`, [ ...u.value, s ]) : e.updateScheme( `flows.${e.flow.type}.selectedScopes`, u.value.filter((o) => o !== s) ); } const h = f( () => e.flow?.selectedScopes?.length === Object.keys(e.flow?.scopes ?? {}).length ), b = () => { e.updateScheme( `flows.${e.flow.type}.selectedScopes`, Object.keys(e.flow?.scopes ?? {}) ); }, C = () => { e.updateScheme(`flows.${e.flow.type}.selectedScopes`, []); }; return (s, t) => (a(), r(l(v), { class: "h-auto !max-h-[initial] min-h-8 items-center" }, { default: c(() => [ n("div", F, [ t[2] || (t[2] = n("div", { class: "text-c-1 h-full items-center" }, null, -1)), i(l(T), { as: "div", class: "bl flex w-full flex-col" }, { default: c(() => [ i(l($), { class: A([ "group/scopes-accordion hover:text-c-1 flex h-auto min-h-8 cursor-pointer items-center gap-1.5 pr-2.25 pl-3 text-left", (s.flow?.selectedScopes?.length || 0) > 0 ? "text-c-1" : "text-c-3" ]) }, { default: c(({ open: o }) => [ n("div", I, " Scopes Selected " + d(s.flow?.selectedScopes?.length || 0) + " / " + d(Object.keys(s.flow?.scopes ?? {}).length || 0), 1), n("div", R, [ h.value ? (a(), r(l(g), { key: 0, class: "pr-0.75 pl-1 transition-none", size: "sm", variant: "ghost", onClick: w(C, ["stop"]) }, { default: c(() => t[0] || (t[0] = [ m(" Deselect All ") ])), _: 1, __: [0] })) : p("", !0), h.value ? p("", !0) : (a(), r(l(g), { key: 1, class: "pr-0.75 pl-1 transition-none", size: "sm", variant: "ghost", onClick: w(b, ["stop"]) }, { default: c(() => t[1] || (t[1] = [ m(" Select All ") ])), _: 1, __: [1] })), i(l(E), { class: "text-c-3 group-hover/scopes-accordion:text-c-2", icon: o ? "ChevronDown" : "ChevronRight", size: "md" }, null, 8, ["icon"]) ]) ]), _: 1 }, 8, ["class"]), i(l(j), { as: "template" }, { default: c(() => [ n("table", L, [ (a(!0), x(B, null, O(k.value, ({ id: o, label: D, description: S }) => (a(), r(l(z), { key: o, class: "text-c-2", onClick: (U) => y(o, !u.value.includes(o)) }, { default: c(() => [ i(l(v), { class: "hover:text-c-1 box-border !max-h-[initial] w-full cursor-pointer px-3 py-1.5" }, { default: c(() => [ S ? (a(), x("div", M, [ n("span", P, d(D), 1), m(" – " + d(S), 1) ])) : p("", !0) ]), _: 2 }, 1024), i(l(N), { modelValue: u.value.includes(o), "onUpdate:modelValue": () => { } }, null, 8, ["modelValue"]) ]), _: 2 }, 1032, ["onClick"]))), 128)) ]) ]), _: 1 }) ]), _: 1 }) ]) ]), _: 1 })); } }); export { K as default };