@scalar/blocks 0.7.1 → 0.7.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/CHANGELOG.md +37 -0
- package/dist/code-example/components/AsyncApiCodeExample.vue.d.ts.map +1 -1
- package/dist/code-example/components/AsyncApiCodeExample.vue.js +1 -1
- package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
- package/dist/code-example/components/CodeExample.vue.js +1 -1
- package/dist/code-example/components/CodeExample.vue.js.map +1 -1
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +76 -78
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue.d.ts.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +25 -24
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.js +6 -3
- package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-body.js +5 -5
- package/dist/code-example/mount.d.ts.map +1 -1
- package/dist/code-example/mount.js +32 -31
- package/dist/code-example/mount.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.d.ts.map +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +2 -5
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaPropertyExamples.vue.d.ts.map +1 -1
- package/dist/schema/SchemaPropertyExamples.vue.js +1 -1
- package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +85 -81
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/helpers/get-rendered-example.d.ts +19 -0
- package/dist/schema/helpers/get-rendered-example.d.ts.map +1 -0
- package/dist/schema/helpers/get-rendered-example.js +45 -0
- package/dist/schema/helpers/get-rendered-example.js.map +1 -0
- package/dist/schema/helpers/get-schema-type.d.ts.map +1 -1
- package/dist/schema/helpers/get-schema-type.js +1 -1
- package/dist/schema/helpers/get-schema-type.js.map +1 -1
- package/dist/schema/helpers/index.d.ts +1 -0
- package/dist/schema/helpers/index.d.ts.map +1 -1
- package/dist/schema/helpers/index.js +13 -12
- package/dist/style.css +83 -9
- package/dist/vue-styles.css +1 -1
- package/package.json +10 -10
|
@@ -1,129 +1,133 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ScalarIcon as
|
|
7
|
-
import { useClipboard as
|
|
8
|
-
import { onClickOutside as
|
|
1
|
+
import { normalizeRenderedExamples as e } from "./helpers/get-rendered-example.js";
|
|
2
|
+
import t from "./LinkButton.vue.js";
|
|
3
|
+
import { useLocalization as n } from "./localization/index.js";
|
|
4
|
+
import { formatExample as r } from "./helpers/format-example.js";
|
|
5
|
+
import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, normalizeClass as f, openBlock as p, ref as m, renderList as h, toDisplayString as g, unref as _, useId as v, withCtx as y } from "vue";
|
|
6
|
+
import { ScalarIcon as b } from "@scalar/components/icon";
|
|
7
|
+
import { useClipboard as x } from "@scalar/use-hooks/useClipboard";
|
|
8
|
+
import { onClickOutside as S, onKeyStroke as C } from "@vueuse/core";
|
|
9
9
|
//#region src/schema/SchemaPropertyExamples.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
-
var
|
|
10
|
+
var w = ["id"], T = ["aria-label"], E = ["id"], D = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "text-c-2 font-sans text-xs font-normal break-words"
|
|
13
|
+
}, O = ["aria-label", "onClick"], k = 500, A = /*@__PURE__*/ d({
|
|
11
14
|
__name: "SchemaPropertyExamples",
|
|
12
15
|
props: {
|
|
13
16
|
align: { default: "center" },
|
|
14
17
|
examples: {},
|
|
15
18
|
example: {}
|
|
16
19
|
},
|
|
17
|
-
setup(
|
|
18
|
-
let { copyToClipboard: A } =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
G = !1;
|
|
20
|
+
setup(d) {
|
|
21
|
+
let { copyToClipboard: A } = x(), { translate: j } = n(), M = a(() => d.example !== void 0), N = a(() => e(d.examples, { allowRawObjects: !0 }).map((e) => {
|
|
22
|
+
let t = e.summary || e.name, n = r(e.value);
|
|
23
|
+
return {
|
|
24
|
+
label: t,
|
|
25
|
+
value: n,
|
|
26
|
+
ariaLabel: `${j("common.copyExample")}: ${t ? `${t}: ` : ""}${n}`
|
|
27
|
+
};
|
|
28
|
+
})), P = a(() => N.value.length > 0), F = a(() => N.value.length === 1 ? j("schema.example") : j("schema.examples")), I = m(null), L = m(null), R = m(!1), z = v(), B = m(null), V = m(null), H = m(!1), U = v(), W = !1, G = 0, K = !1, q = () => {
|
|
29
|
+
W = !0, window.clearTimeout(G), G = window.setTimeout(() => {
|
|
30
|
+
W = !1;
|
|
29
31
|
}, k);
|
|
30
|
-
},
|
|
32
|
+
}, J = (e, t) => {
|
|
31
33
|
let n = e.relatedTarget;
|
|
32
34
|
return !(n instanceof Node) || !t?.contains(n);
|
|
33
|
-
},
|
|
34
|
-
!
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
!
|
|
39
|
-
},
|
|
40
|
-
|
|
35
|
+
}, Y = () => {
|
|
36
|
+
!W && !K && (R.value = !0);
|
|
37
|
+
}, X = (e) => {
|
|
38
|
+
J(e, I.value) && (R.value = !1);
|
|
39
|
+
}, Z = () => {
|
|
40
|
+
!W && !K && (H.value = !0);
|
|
41
|
+
}, Q = (e) => {
|
|
42
|
+
J(e, B.value) && (H.value = !1);
|
|
41
43
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}),
|
|
45
|
-
|
|
44
|
+
S(I, () => {
|
|
45
|
+
R.value = !1;
|
|
46
|
+
}), S(B, () => {
|
|
47
|
+
H.value = !1;
|
|
46
48
|
});
|
|
47
49
|
let $ = (e, t, n) => {
|
|
48
50
|
if (!e.value) return;
|
|
49
51
|
let r = t.value?.contains(document.activeElement);
|
|
50
52
|
if (e.value = !1, r) {
|
|
51
53
|
let e = n.value, t = e instanceof HTMLElement ? e : e?.$el;
|
|
52
|
-
|
|
54
|
+
K = !0, t?.focus?.(), K = !1;
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
|
-
return
|
|
56
|
-
$(
|
|
57
|
-
}), (
|
|
57
|
+
return C("Escape", () => {
|
|
58
|
+
$(R, I, L), $(H, B, V);
|
|
59
|
+
}), (e, n) => (p(), s(i, null, [M.value ? (p(), s("div", {
|
|
58
60
|
key: 0,
|
|
59
61
|
ref_key: "singleRootRef",
|
|
60
|
-
ref:
|
|
61
|
-
class:
|
|
62
|
-
onFocusin:
|
|
63
|
-
onFocusout:
|
|
64
|
-
}, [
|
|
62
|
+
ref: I,
|
|
63
|
+
class: f(["property-example", { "is-open": R.value }]),
|
|
64
|
+
onFocusin: Y,
|
|
65
|
+
onFocusout: X
|
|
66
|
+
}, [u(t, {
|
|
65
67
|
ref_key: "singleTriggerRef",
|
|
66
|
-
ref:
|
|
67
|
-
"aria-controls":
|
|
68
|
-
"aria-expanded":
|
|
68
|
+
ref: L,
|
|
69
|
+
"aria-controls": _(z),
|
|
70
|
+
"aria-expanded": R.value,
|
|
69
71
|
class: "decoration-dotted",
|
|
70
|
-
onClick:
|
|
71
|
-
onPointerdown:
|
|
72
|
+
onClick: n[0] ||= (e) => R.value = !R.value,
|
|
73
|
+
onPointerdown: q
|
|
72
74
|
}, {
|
|
73
|
-
default:
|
|
75
|
+
default: y(() => [l(g(_(j)("schema.example")), 1)]),
|
|
74
76
|
_: 1
|
|
75
|
-
}, 8, ["aria-controls", "aria-expanded"]),
|
|
76
|
-
id:
|
|
77
|
-
class:
|
|
78
|
-
"flex!":
|
|
79
|
-
"property-example-value-list-start":
|
|
77
|
+
}, 8, ["aria-controls", "aria-expanded"]), c("div", {
|
|
78
|
+
id: _(z),
|
|
79
|
+
class: f(["property-example-value-list", {
|
|
80
|
+
"flex!": R.value,
|
|
81
|
+
"property-example-value-list-start": d.align === "start"
|
|
80
82
|
}])
|
|
81
|
-
}, [
|
|
82
|
-
"aria-label": `${
|
|
83
|
+
}, [c("button", {
|
|
84
|
+
"aria-label": `${_(j)("common.copyExample")}: ${_(r)(d.example)}`,
|
|
83
85
|
class: "property-example-value group",
|
|
84
86
|
type: "button",
|
|
85
|
-
onClick:
|
|
86
|
-
}, [
|
|
87
|
+
onClick: n[1] ||= (e) => _(A)(_(r)(d.example))
|
|
88
|
+
}, [c("span", null, g(_(r)(d.example)), 1), u(_(b), {
|
|
87
89
|
"aria-hidden": "true",
|
|
88
90
|
class: "group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3",
|
|
89
91
|
icon: "Clipboard",
|
|
90
92
|
size: "xs"
|
|
91
|
-
})], 8,
|
|
93
|
+
})], 8, T)], 10, w)], 34)) : o("", !0), P.value ? (p(), s("div", {
|
|
92
94
|
key: 1,
|
|
93
95
|
ref_key: "multipleRootRef",
|
|
94
|
-
ref:
|
|
95
|
-
class:
|
|
96
|
-
onFocusin:
|
|
97
|
-
onFocusout:
|
|
98
|
-
}, [
|
|
96
|
+
ref: B,
|
|
97
|
+
class: f(["property-example", { "is-open": H.value }]),
|
|
98
|
+
onFocusin: Z,
|
|
99
|
+
onFocusout: Q
|
|
100
|
+
}, [u(t, {
|
|
99
101
|
ref_key: "multipleTriggerRef",
|
|
100
|
-
ref:
|
|
101
|
-
"aria-controls":
|
|
102
|
-
"aria-expanded":
|
|
102
|
+
ref: V,
|
|
103
|
+
"aria-controls": _(U),
|
|
104
|
+
"aria-expanded": H.value,
|
|
103
105
|
class: "decoration-dotted",
|
|
104
|
-
onClick:
|
|
105
|
-
onPointerdown:
|
|
106
|
+
onClick: n[2] ||= (e) => H.value = !H.value,
|
|
107
|
+
onPointerdown: q
|
|
106
108
|
}, {
|
|
107
|
-
default:
|
|
109
|
+
default: y(() => [l(g(F.value), 1)]),
|
|
108
110
|
_: 1
|
|
109
|
-
}, 8, ["aria-controls", "aria-expanded"]),
|
|
110
|
-
id:
|
|
111
|
-
class:
|
|
112
|
-
"flex!":
|
|
113
|
-
"property-example-value-list-start":
|
|
111
|
+
}, 8, ["aria-controls", "aria-expanded"]), c("div", {
|
|
112
|
+
id: _(U),
|
|
113
|
+
class: f(["property-example-value-list gap-3! p-3!", {
|
|
114
|
+
"flex!": H.value,
|
|
115
|
+
"property-example-value-list-start": d.align === "start"
|
|
114
116
|
}])
|
|
115
|
-
}, [(
|
|
117
|
+
}, [(p(!0), s(i, null, h(N.value, (e, t) => (p(), s("div", {
|
|
116
118
|
key: t,
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
+
class: "flex min-w-0 flex-col gap-1.5"
|
|
120
|
+
}, [e.label ? (p(), s("span", D, g(e.label), 1)) : o("", !0), c("button", {
|
|
121
|
+
"aria-label": e.ariaLabel,
|
|
122
|
+
class: "property-example-value group text-left",
|
|
119
123
|
type: "button",
|
|
120
|
-
onClick: (t) =>
|
|
121
|
-
}, [
|
|
124
|
+
onClick: (t) => _(A)(e.value)
|
|
125
|
+
}, [c("span", null, g(e.value), 1), u(_(b), {
|
|
122
126
|
"aria-hidden": "true",
|
|
123
127
|
class: "text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3",
|
|
124
128
|
icon: "Clipboard",
|
|
125
129
|
size: "xs"
|
|
126
|
-
})], 8, O))), 128))], 10,
|
|
130
|
+
})], 8, O)]))), 128))], 10, E)], 34)) : o("", !0)], 64));
|
|
127
131
|
}
|
|
128
132
|
});
|
|
129
133
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_normalizeClass","_createVNode","LinkButton","_unref","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createCommentVNode","_renderList","LinkButton_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","POINTER_GUARD_MS","SchemaPropertyExamples_vue_vue_type_script_setup_true_lang_default","useClipboard","useLocalization","hasSingleExample","computed","__props","normalizedExamples","isObjectLike","hasMultipleExamples","multipleExamplesLabel","translate","unwrapExampleObject","isObject","value","singleRootRef","ref","singleTriggerRef","isSingleOpen","singlePopupId","useId","multipleRootRef","multipleTriggerRef","isMultipleOpen","multiplePopupId","openedByPointer","pointerGuardTimer","restoringFocus","onPointerDown","leftPopup","next","event","root","onSingleFocusIn","onSingleFocusOut","onMultipleFocusIn","onMultipleFocusOut","onClickOutside","closeAndRestore","open","wasInside","element","trigger","focusable","onKeyStroke","openBlock","createElementBlock","Fragment","normalizeClass","createVNode","unref","_cache","withCtx","createTextVNode","toDisplayString","createElementVNode","formatExample","copyToClipboard","ScalarIcon","createCommentVNode","renderList","ex"],"sources":["../../src/schema/SchemaPropertyExamples.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { isObject, isObjectLike } from '@scalar/helpers/object/is-object'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { onClickOutside, onKeyStroke } from '@vueuse/core'\nimport { computed, ref, useId } from 'vue'\n\nimport { formatExample } from './helpers/format-example'\nimport LinkButton from './LinkButton.vue'\nimport { useLocalization } from './localization'\n\nconst {\n examples,\n example,\n align = 'center',\n} = defineProps<{\n /** Align the popup with its label when centering would overlap adjacent content. */\n align?: 'center' | 'start'\n examples?: unknown\n example?: unknown\n}>()\n\nconst { copyToClipboard } = useClipboard()\nconst { translate } = useLocalization()\n\n// `null` is a meaningful example value for nullable schemas, so only treat\n// `undefined` as \"not provided\".\nconst hasSingleExample = computed(() => example !== undefined)\n\nconst normalizedExamples = computed<Record<string, unknown>>(() => {\n if (isObjectLike(examples)) {\n return examples\n }\n\n return {}\n})\n\nconst hasMultipleExamples = computed(\n () => Object.keys(normalizedExamples.value).length > 0,\n)\n\nconst multipleExamplesLabel = computed(() =>\n Object.keys(normalizedExamples.value).length === 1\n ? translate('schema.example')\n : translate('schema.examples'),\n)\n\n/**\n * Unwrap an OpenAPI 3 Example Object (`{ value, externalValue, summary, description }`)\n * to the actual sample. Plain values pass through untouched.\n */\nfunction unwrapExampleObject(value: unknown): unknown {\n if (isObject(value)) {\n if ('value' in value) {\n return value.value\n }\n if ('externalValue' in value) {\n return value.externalValue\n }\n }\n return value\n}\n\n/**\n * Hover/`:focus-within` CSS alone left the popup unreachable by Enter, Escape\n * or touch, so it is pinned open on click (as in SchemaPropertyPattern.vue).\n * `example` and `examples` can both render, so each popup has its own state.\n */\nconst singleRootRef = ref<HTMLElement | null>(null)\nconst singleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isSingleOpen = ref(false)\nconst singlePopupId = useId()\n\nconst multipleRootRef = ref<HTMLElement | null>(null)\nconst multipleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isMultipleOpen = ref(false)\nconst multiplePopupId = useId()\n\n/**\n * Focus opens the popup through the same state as the click, not a separate\n * `:focus-within` rule; with both, a click's own `focusin` opened it first and\n * the click closed it again. This flag stops a pointer press counting as focus.\n */\nlet openedByPointer = false\n\n/** Long enough to span a touch tap's delayed compatibility mouse events. */\nconst POINTER_GUARD_MS = 500\nlet pointerGuardTimer = 0\n\n/**\n * `closeAndRestore` refocuses the trigger, and `focus()` fires `focusin`\n * synchronously, which would re-open the popup and make the first Escape inert.\n */\nlet restoringFocus = false\n\nconst onPointerDown = (): void => {\n /*\n * A touch tap's compatibility mousedown (which moves focus) lands 50-150ms\n * after touchend, past any one-frame guard, so the tap opened then closed.\n */\n openedByPointer = true\n window.clearTimeout(pointerGuardTimer)\n pointerGuardTimer = window.setTimeout(() => {\n openedByPointer = false\n }, POINTER_GUARD_MS)\n}\n\nconst leftPopup = (event: FocusEvent, root: HTMLElement | null): boolean => {\n const next = event.relatedTarget\n\n return !(next instanceof Node) || !root?.contains(next)\n}\n\nconst onSingleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isSingleOpen.value = true\n }\n}\n\nconst onSingleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, singleRootRef.value)) {\n isSingleOpen.value = false\n }\n}\n\nconst onMultipleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isMultipleOpen.value = true\n }\n}\n\nconst onMultipleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, multipleRootRef.value)) {\n isMultipleOpen.value = false\n }\n}\n\nonClickOutside(singleRootRef, () => {\n isSingleOpen.value = false\n})\n\nonClickOutside(multipleRootRef, () => {\n isMultipleOpen.value = false\n})\n\n/**\n * Closing hides the popup outright, so focus is handed back deliberately, or\n * Escape from inside it drops focus to <body>.\n */\nconst closeAndRestore = (\n open: typeof isSingleOpen,\n root: typeof singleRootRef,\n trigger: typeof singleTriggerRef,\n): void => {\n if (!open.value) {\n return\n }\n\n const wasInside = root.value?.contains(document.activeElement)\n\n open.value = false\n\n if (wasInside) {\n const element = trigger.value\n const focusable = element instanceof HTMLElement ? element : element?.$el\n\n restoringFocus = true\n focusable?.focus?.()\n restoringFocus = false\n }\n}\n\nonKeyStroke('Escape', () => {\n closeAndRestore(isSingleOpen, singleRootRef, singleTriggerRef)\n closeAndRestore(isMultipleOpen, multipleRootRef, multipleTriggerRef)\n})\n</script>\n<template>\n <!-- single example (deprecated) -->\n <template v-if=\"hasSingleExample\">\n <div\n ref=\"singleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isSingleOpen }\"\n @focusin=\"onSingleFocusIn\"\n @focusout=\"onSingleFocusOut\">\n <LinkButton\n ref=\"singleTriggerRef\"\n :aria-controls=\"singlePopupId\"\n :aria-expanded=\"isSingleOpen\"\n class=\"decoration-dotted\"\n @click=\"isSingleOpen = !isSingleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ translate('schema.example') }}\n </LinkButton>\n <div\n :id=\"singlePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isSingleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(example)}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(example))\">\n <span>\n {{ formatExample(example) }}\n </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n\n <!-- multiple examples -->\n <template v-if=\"hasMultipleExamples\">\n <div\n ref=\"multipleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isMultipleOpen }\"\n @focusin=\"onMultipleFocusIn\"\n @focusout=\"onMultipleFocusOut\">\n <LinkButton\n ref=\"multipleTriggerRef\"\n :aria-controls=\"multiplePopupId\"\n :aria-expanded=\"isMultipleOpen\"\n class=\"decoration-dotted\"\n @click=\"isMultipleOpen = !isMultipleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ multipleExamplesLabel }}\n </LinkButton>\n <div\n :id=\"multiplePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isMultipleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n v-for=\"(ex, key) in normalizedExamples\"\n :key=\"key\"\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(unwrapExampleObject(ex))}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(unwrapExampleObject(ex)))\">\n <span>{{ formatExample(unwrapExampleObject(ex)) }} </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n</template>\n\n<style scoped>\n@reference \"../style.css\";\n\n.property-example {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-mini);\n position: relative;\n}\n.property-example:hover:before {\n pointer-events: none;\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 20px;\n border-radius: var(--scalar-radius);\n}\n.property-example-value {\n font-family: var(--scalar-font-code);\n display: flex;\n gap: 8px;\n align-items: center;\n width: 100%;\n padding: 6px;\n}\n.property-example-value span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n}\n.property-example-value :deep(svg) {\n color: var(--scalar-color-3);\n}\n\n.property-example-value:hover :deep(svg) {\n color: var(--scalar-color-1);\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n}\n.property-example-value-list {\n position: absolute;\n top: 18px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n overflow: auto;\n background-color: var(--scalar-background-1);\n box-shadow: var(--scalar-shadow-1);\n border-radius: var(--scalar-radius-lg);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 9px;\n min-width: 200px;\n max-width: 300px;\n flex-direction: column;\n gap: 3px;\n display: none;\n @apply z-context;\n}\n.property-example-value-list-start {\n left: 0;\n transform: none;\n}\n.property-example:hover .property-example-value-list {\n display: flex;\n}\n</style>\n"],"mappings":";;;;;;;;;A,+EAsFMkB,IAAmB,K;;;;;;;;EAhEzB,IAAM,EAAE,uBAAoBE,EAAa,GACnC,EAAE,iBAAcC,EAAgB,GAIhCC,IAAmBC,QAAeC,EAAA,YAAY,KAAA,CAAS,GAEvDC,IAAqBF,QACrBG,EAAaF,EAAA,QAAQ,IAChBA,EAAA,WAGF,CAAC,CACT,GAEKG,IAAsBJ,QACpB,OAAO,KAAKE,EAAmB,KAAK,CAAC,CAAC,SAAS,CACvD,GAEMG,IAAwBL,QAC5B,OAAO,KAAKE,EAAmB,KAAK,CAAC,CAAC,WAAW,IAC7CI,EAAU,gBAAgB,IAC1BA,EAAU,iBAAiB,CACjC;EAMA,SAASC,EAAoB,GAAyB;GACpD,IAAIC,EAASC,CAAK,GAAG;IACnB,IAAI,WAAWA,GACb,OAAOA,EAAM;IAEf,IAAI,mBAAmBA,GACrB,OAAOA,EAAM;GAEjB;GACA,OAAOA;EACT;EAOA,IAAMC,IAAgBC,EAAwB,IAAI,GAC5CC,IAAmBD,EAA+C,IAAI,GACtEE,IAAeF,EAAI,EAAK,GACxBG,IAAgBC,EAAM,GAEtBC,IAAkBL,EAAwB,IAAI,GAC9CM,IAAqBN,EAA+C,IAAI,GACxEO,IAAiBP,EAAI,EAAK,GAC1BQ,IAAkBJ,EAAM,GAO1BK,IAAkB,IAIlBC,IAAoB,GAMpBC,IAAiB,IAEfC,UAA4B;GAOhC,AAFA,IAAkB,IAClB,OAAO,aAAaF,CAAiB,GACrC,IAAoB,OAAO,iBAAiB;IAC1C,IAAkB;GACpB,GAAG1B,CAAgB;EACrB,GAEM6B,KAAa,GAAmB,MAAsC;GAC1E,IAAMC,IAAOC,EAAM;GAEnB,OAAO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C,+BAA6B;IACN,SAAAsC,EAAA;IAA+D,qCAAAjB,EAAA,UAAK;;E,KAIjGxB,EAAA,EAAA,GAAAC,EAaSC,GAAA,MAAAU,EAZaa,EAAA,QAAZ,GAAI,OADdzB,EAAA,GAAAC,EAaS,UAAA;GAXD;GACL,cAAU,GAAKK,EAAAuB,CAAA,CAAS,CAAA,oBAAA,EAAA,IAA2BvB,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA;GACxF,OAAM;GACN,MAAK;GACJ,UAAK,MAAEzE,EAAAqE,CAAA,CAAe,CAACrE,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA,CAAA;E,IAC5DrE,EAA0D,QAAA,MAAAD,EAAjDH,EAAAoE,CAAA,CAAa,CAAC5C,EAAoBiD,CAAE,CAAA,CAAA,GAAA,CAAA,GAC7C3E,EAIcE,EAAAsE,CAAA,GAAA;GAHZ,eAAY;GACZ,OAAM;GACN,MAAK;GACL,MAAK"}
|
|
1
|
+
{"version":3,"file":"SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_normalizeClass","_createVNode","LinkButton","_unref","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createCommentVNode","_renderList","LinkButton_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","POINTER_GUARD_MS","SchemaPropertyExamples_vue_vue_type_script_setup_true_lang_default","useClipboard","useLocalization","hasSingleExample","computed","__props","normalizedExamples","normalizeRenderedExamples","label","entry","value","formatExample","translate","hasMultipleExamples","multipleExamplesLabel","singleRootRef","ref","singleTriggerRef","isSingleOpen","singlePopupId","useId","multipleRootRef","multipleTriggerRef","isMultipleOpen","multiplePopupId","openedByPointer","pointerGuardTimer","restoringFocus","onPointerDown","leftPopup","next","event","root","onSingleFocusIn","onSingleFocusOut","onMultipleFocusIn","onMultipleFocusOut","onClickOutside","closeAndRestore","open","wasInside","element","trigger","focusable","onKeyStroke","openBlock","createElementBlock","Fragment","normalizeClass","createVNode","unref","_cache","withCtx","createTextVNode","toDisplayString","createElementVNode","copyToClipboard","ScalarIcon","createCommentVNode","renderList","ex"],"sources":["../../src/schema/SchemaPropertyExamples.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { onClickOutside, onKeyStroke } from '@vueuse/core'\nimport { computed, ref, useId } from 'vue'\n\nimport { formatExample } from './helpers/format-example'\nimport { normalizeRenderedExamples } from './helpers/get-rendered-example'\nimport LinkButton from './LinkButton.vue'\nimport { useLocalization } from './localization'\n\nconst {\n examples,\n example,\n align = 'center',\n} = defineProps<{\n /** Align the popup with its label when centering would overlap adjacent content. */\n align?: 'center' | 'start'\n examples?: unknown\n example?: unknown\n}>()\n\nconst { copyToClipboard } = useClipboard()\nconst { translate } = useLocalization()\n\n// `null` is a meaningful example value for nullable schemas, so only treat\n// `undefined` as \"not provided\".\nconst hasSingleExample = computed(() => example !== undefined)\n\nconst normalizedExamples = computed<\n { label: string | undefined; value: string | number; ariaLabel: string }[]\n>(() =>\n normalizeRenderedExamples(examples, { allowRawObjects: true }).map(\n (entry) => {\n const label = entry.summary || entry.name\n const value = formatExample(entry.value)\n return {\n label,\n value,\n ariaLabel: `${translate('common.copyExample')}: ${label ? `${label}: ` : ''}${value}`,\n }\n },\n ),\n)\n\nconst hasMultipleExamples = computed(() => normalizedExamples.value.length > 0)\n\nconst multipleExamplesLabel = computed(() =>\n normalizedExamples.value.length === 1\n ? translate('schema.example')\n : translate('schema.examples'),\n)\n\n/**\n * Hover/`:focus-within` CSS alone left the popup unreachable by Enter, Escape\n * or touch, so it is pinned open on click (as in SchemaPropertyPattern.vue).\n * `example` and `examples` can both render, so each popup has its own state.\n */\nconst singleRootRef = ref<HTMLElement | null>(null)\nconst singleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isSingleOpen = ref(false)\nconst singlePopupId = useId()\n\nconst multipleRootRef = ref<HTMLElement | null>(null)\nconst multipleTriggerRef = ref<HTMLElement | { $el: HTMLElement } | null>(null)\nconst isMultipleOpen = ref(false)\nconst multiplePopupId = useId()\n\n/**\n * Focus opens the popup through the same state as the click, not a separate\n * `:focus-within` rule; with both, a click's own `focusin` opened it first and\n * the click closed it again. This flag stops a pointer press counting as focus.\n */\nlet openedByPointer = false\n\n/** Long enough to span a touch tap's delayed compatibility mouse events. */\nconst POINTER_GUARD_MS = 500\nlet pointerGuardTimer = 0\n\n/**\n * `closeAndRestore` refocuses the trigger, and `focus()` fires `focusin`\n * synchronously, which would re-open the popup and make the first Escape inert.\n */\nlet restoringFocus = false\n\nconst onPointerDown = (): void => {\n /*\n * A touch tap's compatibility mousedown (which moves focus) lands 50-150ms\n * after touchend, past any one-frame guard, so the tap opened then closed.\n */\n openedByPointer = true\n window.clearTimeout(pointerGuardTimer)\n pointerGuardTimer = window.setTimeout(() => {\n openedByPointer = false\n }, POINTER_GUARD_MS)\n}\n\nconst leftPopup = (event: FocusEvent, root: HTMLElement | null): boolean => {\n const next = event.relatedTarget\n\n return !(next instanceof Node) || !root?.contains(next)\n}\n\nconst onSingleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isSingleOpen.value = true\n }\n}\n\nconst onSingleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, singleRootRef.value)) {\n isSingleOpen.value = false\n }\n}\n\nconst onMultipleFocusIn = (): void => {\n if (!openedByPointer && !restoringFocus) {\n isMultipleOpen.value = true\n }\n}\n\nconst onMultipleFocusOut = (event: FocusEvent): void => {\n if (leftPopup(event, multipleRootRef.value)) {\n isMultipleOpen.value = false\n }\n}\n\nonClickOutside(singleRootRef, () => {\n isSingleOpen.value = false\n})\n\nonClickOutside(multipleRootRef, () => {\n isMultipleOpen.value = false\n})\n\n/**\n * Closing hides the popup outright, so focus is handed back deliberately, or\n * Escape from inside it drops focus to <body>.\n */\nconst closeAndRestore = (\n open: typeof isSingleOpen,\n root: typeof singleRootRef,\n trigger: typeof singleTriggerRef,\n): void => {\n if (!open.value) {\n return\n }\n\n const wasInside = root.value?.contains(document.activeElement)\n\n open.value = false\n\n if (wasInside) {\n const element = trigger.value\n const focusable = element instanceof HTMLElement ? element : element?.$el\n\n restoringFocus = true\n focusable?.focus?.()\n restoringFocus = false\n }\n}\n\nonKeyStroke('Escape', () => {\n closeAndRestore(isSingleOpen, singleRootRef, singleTriggerRef)\n closeAndRestore(isMultipleOpen, multipleRootRef, multipleTriggerRef)\n})\n</script>\n<template>\n <!-- single example (deprecated) -->\n <template v-if=\"hasSingleExample\">\n <div\n ref=\"singleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isSingleOpen }\"\n @focusin=\"onSingleFocusIn\"\n @focusout=\"onSingleFocusOut\">\n <LinkButton\n ref=\"singleTriggerRef\"\n :aria-controls=\"singlePopupId\"\n :aria-expanded=\"isSingleOpen\"\n class=\"decoration-dotted\"\n @click=\"isSingleOpen = !isSingleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ translate('schema.example') }}\n </LinkButton>\n <div\n :id=\"singlePopupId\"\n class=\"property-example-value-list\"\n :class=\"{\n 'flex!': isSingleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <button\n :aria-label=\"`${translate('common.copyExample')}: ${formatExample(example)}`\"\n class=\"property-example-value group\"\n type=\"button\"\n @click=\"copyToClipboard(formatExample(example))\">\n <span>\n {{ formatExample(example) }}\n </span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"group-hover:text-c-1 text-c-3 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </template>\n\n <!-- multiple examples -->\n <template v-if=\"hasMultipleExamples\">\n <div\n ref=\"multipleRootRef\"\n class=\"property-example\"\n :class=\"{ 'is-open': isMultipleOpen }\"\n @focusin=\"onMultipleFocusIn\"\n @focusout=\"onMultipleFocusOut\">\n <LinkButton\n ref=\"multipleTriggerRef\"\n :aria-controls=\"multiplePopupId\"\n :aria-expanded=\"isMultipleOpen\"\n class=\"decoration-dotted\"\n @click=\"isMultipleOpen = !isMultipleOpen\"\n @pointerdown=\"onPointerDown\">\n {{ multipleExamplesLabel }}\n </LinkButton>\n <div\n :id=\"multiplePopupId\"\n class=\"property-example-value-list gap-3! p-3!\"\n :class=\"{\n 'flex!': isMultipleOpen,\n 'property-example-value-list-start': align === 'start',\n }\">\n <div\n v-for=\"(ex, key) in normalizedExamples\"\n :key=\"key\"\n class=\"flex min-w-0 flex-col gap-1.5\">\n <span\n v-if=\"ex.label\"\n class=\"text-c-2 font-sans text-xs font-normal break-words\">\n {{ ex.label }}\n </span>\n <button\n :aria-label=\"ex.ariaLabel\"\n class=\"property-example-value group text-left\"\n type=\"button\"\n @click=\"copyToClipboard(ex.value)\">\n <span>{{ ex.value }}</span>\n <ScalarIcon\n aria-hidden=\"true\"\n class=\"text-c-3 group-hover:text-c-1 ml-auto min-h-3 min-w-3\"\n icon=\"Clipboard\"\n size=\"xs\" />\n </button>\n </div>\n </div>\n </div>\n </template>\n</template>\n\n<style scoped>\n@reference \"../style.css\";\n\n.property-example {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-mini);\n position: relative;\n}\n.property-example:hover:before {\n pointer-events: none;\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 20px;\n border-radius: var(--scalar-radius);\n}\n.property-example-value {\n font-family: var(--scalar-font-code);\n display: flex;\n gap: 8px;\n align-items: center;\n width: 100%;\n padding: 6px;\n}\n.property-example-value span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n}\n.property-example-value :deep(svg) {\n color: var(--scalar-color-3);\n}\n\n.property-example-value:hover :deep(svg) {\n color: var(--scalar-color-1);\n}\n\n.property-example-value {\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n}\n.property-example-value-list {\n position: absolute;\n top: 18px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n overflow: auto;\n background-color: var(--scalar-background-1);\n box-shadow: var(--scalar-shadow-1);\n border-radius: var(--scalar-radius-lg);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n padding: 9px;\n min-width: 200px;\n max-width: 300px;\n flex-direction: column;\n gap: 3px;\n display: none;\n @apply z-context;\n}\n.property-example-value-list-start {\n left: 0;\n transform: none;\n}\n.property-example:hover .property-example-value-list {\n display: flex;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;A,kCA4EMmB,IAAmB,K;;;;;;;;EAtDzB,IAAM,EAAE,uBAAoBE,EAAa,GACnC,EAAE,iBAAcC,EAAgB,GAIhCC,IAAmBC,QAAeC,EAAA,YAAY,KAAA,CAAS,GAEvDC,IAAqBF,QAGzBG,EAA0BF,EAAA,UAAU,EAAE,iBAAiB,GAAK,CAAC,CAAC,CAAC,KAC5D,MAAU;GACT,IAAMG,IAAQC,EAAM,WAAWA,EAAM,MAC/BC,IAAQC,EAAcF,EAAM,KAAK;GACvC,OAAO;IACL;IACA;IACA,WAAW,GAAGG,EAAU,oBAAoB,EAAE,IAAIJ,IAAQ,GAAGA,EAAM,MAAM,KAAKE;GAChF;EACF,CACF,CACF,GAEMG,IAAsBT,QAAeE,EAAmB,MAAM,SAAS,CAAC,GAExEQ,IAAwBV,QAC5BE,EAAmB,MAAM,WAAW,IAChCM,EAAU,gBAAgB,IAC1BA,EAAU,iBAAiB,CACjC,GAOMG,IAAgBC,EAAwB,IAAI,GAC5CC,IAAmBD,EAA+C,IAAI,GACtEE,IAAeF,EAAI,EAAK,GACxBG,IAAgBC,EAAM,GAEtBC,IAAkBL,EAAwB,IAAI,GAC9CM,IAAqBN,EAA+C,IAAI,GACxEO,IAAiBP,EAAI,EAAK,GAC1BQ,IAAkBJ,EAAM,GAO1BK,IAAkB,IAIlBC,IAAoB,GAMpBC,IAAiB,IAEfC,UAA4B;GAOhC,AAFA,IAAkB,IAClB,OAAO,aA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,SAAAzC,QAA2B,CAAxBC,EAAAC,EAAAyB,EAAA,KAAqB,GAAA,CAAA,C;;E,2CAE1BxB,EA6BM,OAAA;GA5BH,IAAIJ,EAAAsC,CAAA;GACL,OAAKzC,EAAA,CAAC,2CAAyC;IAClB,SAAAwC,EAAA;IAA+D,qCAAAlB,EAAA,UAAK;;E,KAIjGzB,EAAA,EAAA,GAAAC,EAqBMC,GAAA,MAAAU,EApBgBc,EAAA,QAAZ,GAAI,OADd1B,EAAA,GAAAC,EAqBM,OAAA;GAnBE;GACN,OAAM;E,IAEE+E,EAAG,SADXhF,EAAA,GAAAC,EAIO,QAJPgB,GAIOR,EADFuE,EAAG,KAAK,GAAA,CAAA,K,WAEbtE,EAWS,UAAA;GAVN,cAAYsE,EAAG;GAChB,OAAM;GACN,MAAK;GACJ,UAAK,MAAE1E,EAAAsE,CAAA,CAAe,CAACI,EAAG,KAAK;E,IAChCtE,EAA2B,QAAA,MAAAD,EAAlBuE,EAAG,KAAK,GAAA,CAAA,GACjB5E,EAIcE,EAAAuE,CAAA,GAAA;GAHZ,eAAY;GACZ,OAAM;GACN,MAAK;GACL,MAAK"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Only renderer-created wrappers carry this marker; JSON payload fields remain ordinary data. */
|
|
2
|
+
declare const renderedExample: unique symbol;
|
|
3
|
+
/** Display metadata stays separate from the selected payload, including payloads with a `value` field. */
|
|
4
|
+
export type RenderedExample = {
|
|
5
|
+
[renderedExample]: true;
|
|
6
|
+
name?: string;
|
|
7
|
+
summary?: string;
|
|
8
|
+
value: unknown;
|
|
9
|
+
};
|
|
10
|
+
/** Find the nearest summary annotation, including overrides on a chain of references. */
|
|
11
|
+
export declare const getExampleSummary: (entry: unknown) => string | undefined;
|
|
12
|
+
/** Resolve a named Example Object once, preserving its label and the existing value preference. */
|
|
13
|
+
export declare const getRenderedExample: (entry: unknown, name?: string, preferData?: boolean) => RenderedExample | undefined;
|
|
14
|
+
/** Schema arrays contain raw payloads; legacy schema maps may also contain raw objects beside Example Objects. */
|
|
15
|
+
export declare const normalizeRenderedExamples: (examples: unknown, { allowRawObjects }?: {
|
|
16
|
+
allowRawObjects?: boolean;
|
|
17
|
+
}) => RenderedExample[];
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=get-rendered-example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-rendered-example.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/get-rendered-example.ts"],"names":[],"mappings":"AAIA,kGAAkG;AAClG,QAAA,MAAM,eAAe,eAA6B,CAAA;AAElD,0GAA0G;AAC1G,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAW3D,CAAA;AAED,mGAAmG;AACnG,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,EAAE,oBAAkB,KAAG,eAAe,GAAG,SAiBxG,CAAA;AAED,kHAAkH;AAClH,eAAO,MAAM,yBAAyB,GACpC,UAAU,OAAO,EACjB,sBAA6B;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,KAC9D,eAAe,EA6BjB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isObjectLike as e } from "@scalar/helpers/object/is-object";
|
|
2
|
+
import { getExampleValue as t } from "@scalar/workspace-store/helpers/get-example-value";
|
|
3
|
+
import { getResolvedRef as n } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
|
+
//#region src/schema/helpers/get-rendered-example.ts
|
|
5
|
+
var r = Symbol("rendered-example"), i = (t) => {
|
|
6
|
+
let r = /* @__PURE__ */ new Set(), i = t;
|
|
7
|
+
for (; e(i) && !r.has(i);) {
|
|
8
|
+
if (typeof i.summary == "string") return i.summary;
|
|
9
|
+
r.add(i), i = n(i);
|
|
10
|
+
}
|
|
11
|
+
}, a = (a, o, s = !1) => {
|
|
12
|
+
let c = n(a);
|
|
13
|
+
if (!e(c)) return c === void 0 ? void 0 : {
|
|
14
|
+
[r]: !0,
|
|
15
|
+
name: o,
|
|
16
|
+
value: c
|
|
17
|
+
};
|
|
18
|
+
let l = s && c.dataValue !== void 0 ? { value: c.dataValue } : t(c), u = l ? l.value : c.externalValue;
|
|
19
|
+
return u === void 0 ? void 0 : {
|
|
20
|
+
[r]: !0,
|
|
21
|
+
name: o,
|
|
22
|
+
summary: i(a),
|
|
23
|
+
value: u
|
|
24
|
+
};
|
|
25
|
+
}, o = (t, { allowRawObjects: n = !1 } = {}) => Array.isArray(t) ? t.filter((e) => e !== void 0).map((t) => e(t) && r in t && t[r] === !0 ? t : {
|
|
26
|
+
[r]: !0,
|
|
27
|
+
value: t
|
|
28
|
+
}) : e(t) ? Object.entries(t).flatMap(([t, i]) => {
|
|
29
|
+
let o = a(i, t);
|
|
30
|
+
return o ? [o] : n && e(i) && ![
|
|
31
|
+
"$ref",
|
|
32
|
+
"value",
|
|
33
|
+
"externalValue",
|
|
34
|
+
"dataValue",
|
|
35
|
+
"serializedValue"
|
|
36
|
+
].some((e) => e in i) ? [{
|
|
37
|
+
[r]: !0,
|
|
38
|
+
name: t,
|
|
39
|
+
value: i
|
|
40
|
+
}] : [];
|
|
41
|
+
}) : [];
|
|
42
|
+
//#endregion
|
|
43
|
+
export { i as getExampleSummary, a as getRenderedExample, o as normalizeRenderedExamples };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=get-rendered-example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-rendered-example.js","names":["renderedExample","getExampleSummary","seen","current","entry","isObjectLike","getResolvedRef","getRenderedExample","example","selected","preferData","getExampleValue","value","normalizeRenderedExamples","examples","name","allowRawObjects","key"],"sources":["../../../src/schema/helpers/get-rendered-example.ts"],"sourcesContent":["import { isObjectLike } from '@scalar/helpers/object/is-object'\nimport { getExampleValue } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\n/** Only renderer-created wrappers carry this marker; JSON payload fields remain ordinary data. */\nconst renderedExample = Symbol('rendered-example')\n\n/** Display metadata stays separate from the selected payload, including payloads with a `value` field. */\nexport type RenderedExample = {\n [renderedExample]: true\n name?: string\n summary?: string\n value: unknown\n}\n\n/** Find the nearest summary annotation, including overrides on a chain of references. */\nexport const getExampleSummary = (entry: unknown): string | undefined => {\n const seen = new Set<unknown>()\n let current = entry\n while (isObjectLike(current) && !seen.has(current)) {\n if (typeof current.summary === 'string') {\n return current.summary\n }\n seen.add(current)\n current = getResolvedRef(current)\n }\n return undefined\n}\n\n/** Resolve a named Example Object once, preserving its label and the existing value preference. */\nexport const getRenderedExample = (entry: unknown, name?: string, preferData = false): RenderedExample | undefined => {\n const example = getResolvedRef(entry)\n if (!isObjectLike(example)) {\n return example === undefined ? undefined : { [renderedExample]: true, name, value: example }\n }\n const selected =\n preferData && example.dataValue !== undefined ? { value: example.dataValue } : getExampleValue(example)\n // Display the URL until the bundler has loaded an external example's payload.\n const value = selected ? selected.value : example.externalValue\n return value === undefined\n ? undefined\n : {\n [renderedExample]: true,\n name,\n summary: getExampleSummary(entry),\n value,\n }\n}\n\n/** Schema arrays contain raw payloads; legacy schema maps may also contain raw objects beside Example Objects. */\nexport const normalizeRenderedExamples = (\n examples: unknown,\n { allowRawObjects = false }: { allowRawObjects?: boolean } = {},\n): RenderedExample[] => {\n if (Array.isArray(examples)) {\n return examples\n .filter((value) => value !== undefined)\n .map((value: unknown) => {\n if (isObjectLike(value) && renderedExample in value && value[renderedExample] === true) {\n return value as RenderedExample\n }\n return { [renderedExample]: true, value }\n })\n }\n if (isObjectLike(examples)) {\n return Object.entries(examples).flatMap(([name, entry]) => {\n const example = getRenderedExample(entry, name)\n if (example) {\n return [example]\n }\n // Keep legacy schema maps readable without turning unresolved references or empty value fields into payloads.\n if (\n allowRawObjects &&\n isObjectLike(entry) &&\n !['$ref', 'value', 'externalValue', 'dataValue', 'serializedValue'].some((key) => key in entry)\n ) {\n return [{ [renderedExample]: true, name, value: entry }]\n }\n return []\n })\n }\n return []\n}\n"],"mappings":";;;;AAKA,IAAMA,IAAkB,OAAO,kBAAkB,GAWpCC,KAAqB,MAAuC;CACvE,IAAMC,oBAAO,IAAI,IAAa,GAC1BC,IAAUC;CACd,OAAOC,EAAaF,CAAO,KAAK,CAACD,EAAK,IAAIC,CAAO,IAAG;EAClD,IAAI,OAAOA,EAAQ,WAAY,UAC7B,OAAOA,EAAQ;EAGjB,AADAD,EAAK,IAAIC,CAAO,GAChB,IAAUG,EAAeH,CAAO;CAClC;AAEF,GAGaI,KAAsB,GAAgB,GAAe,IAAa,OAAuC;CACpH,IAAMC,IAAUF,EAAeF,CAAK;CACpC,IAAI,CAACC,EAAaG,CAAO,GACvB,OAAOA,MAAY,KAAA,IAAY,KAAA,IAAY;GAAGR,IAAkB;EAAM;EAAM,OAAOQ;CAAQ;CAE7F,IAAMC,IACJC,KAAcF,EAAQ,cAAc,KAAA,IAAY,EAAE,OAAOA,EAAQ,UAAU,IAAIG,EAAgBH,CAAO,GAElGI,IAAQH,IAAWA,EAAS,QAAQD,EAAQ;CAClD,OAAOI,MAAU,KAAA,IACb,KAAA,IACA;GACGZ,IAAkB;EACnB;EACA,SAASC,EAAkBG,CAAK;EAChC;CACF;AACN,GAGaS,KACX,GACA,EAAE,qBAAkB,OAAyC,CAAC,MAE1D,MAAM,QAAQC,CAAQ,IACjBA,EACJ,QAAQ,MAAUF,MAAU,KAAA,CAAS,CAAC,CACtC,KAAK,MACAP,EAAaO,CAAK,KAAKZ,KAAmBY,KAASA,EAAMZ,OAAqB,KACzEY,IAEF;EAAGZ,IAAkB;CAAM;AAAM,CACzC,IAEDK,EAAaS,CAAQ,IAChB,OAAO,QAAQA,CAAQ,CAAC,CAAC,SAAS,CAACC,GAAMX,OAAW;CACzD,IAAMI,IAAUD,EAAmBH,GAAOW,CAAI;CAY9C,OAXIP,IACK,CAACA,CAAO,IAIfQ,KACAX,EAAaD,CAAK,KAClB,CAAC;EAAC;EAAQ;EAAS;EAAiB;EAAa;CAAiB,CAAC,CAAC,MAAM,MAAQa,KAAOb,CAAK,IAEvF,CAAC;GAAGJ,IAAkB;EAAM;EAAM,OAAOI;CAAM,CAAC,IAElD,CAAC;AACV,CAAC,IAEI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-schema-type.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/get-schema-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"get-schema-type.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/get-schema-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAqC/G;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,YAAY,GAAG,aAAa,CAAC,YAAY,CAAC,KAAG,MAuCtF,CAAA"}
|
|
@@ -10,7 +10,7 @@ var n = (e) => e ? `array ${e.includes(" | ") ? `(${e})` : e}[]` : "array", r =
|
|
|
10
10
|
let i = e.schema(n);
|
|
11
11
|
if (i.const !== void 0) return "const";
|
|
12
12
|
if ("type" in i && Array.isArray(i.type)) {
|
|
13
|
-
if (i.type.includes("array") && i.items) {
|
|
13
|
+
if (i.type.includes("array") && "items" in i && i.items) {
|
|
14
14
|
let e = r(i, !0), t = i.type.filter((e) => e !== "array");
|
|
15
15
|
return t.length > 0 ? `${e} | ${t.join(" | ")}` : e;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-schema-type.js","names":["formatArrayType","itemType","processArrayType","value","baseType","getSchemaType","resolve","isUnionType","valueOrRef","arrayType","otherTypes","t","isArraySchema"],"sources":["../../../src/schema/helpers/get-schema-type.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { ReferenceType, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\n/**\n * Formats an array type string with proper wrapping for union types.\n */\nconst formatArrayType = (itemType: string): string => {\n if (!itemType) {\n return 'array'\n }\n\n const wrappedItemType = itemType.includes(' | ') ? `(${itemType})` : itemType\n return `array ${wrappedItemType}[]`\n}\n\n/**\n * Handles array type processing for both single array types and union types containing array.\n */\nconst processArrayType = (value: Extract<SchemaObject, { type: 'array' }
|
|
1
|
+
{"version":3,"file":"get-schema-type.js","names":["formatArrayType","itemType","processArrayType","value","baseType","getSchemaType","resolve","isUnionType","valueOrRef","arrayType","otherTypes","t","isArraySchema"],"sources":["../../../src/schema/helpers/get-schema-type.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { ReferenceType, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\n/**\n * Formats an array type string with proper wrapping for union types.\n */\nconst formatArrayType = (itemType: string): string => {\n if (!itemType) {\n return 'array'\n }\n\n const wrappedItemType = itemType.includes(' | ') ? `(${itemType})` : itemType\n return `array ${wrappedItemType}[]`\n}\n\n/**\n * Handles array type processing for both single array types and union types containing array.\n */\nconst processArrayType = (\n value: Extract<SchemaObject, { type: 'array' | string[] }>,\n isUnionType: boolean = false,\n): string => {\n if (!value.items) {\n return 'array'\n }\n\n const itemType = getSchemaType(resolve.schema(value.items))\n const baseType = formatArrayType(itemType)\n\n if (isUnionType) {\n return baseType\n }\n\n // Handle nullable arrays for non-union types\n return (value as any).nullable ? `${baseType} | null` : baseType\n}\n\n/**\n * Computes the structural type for a schema.\n * This helper always returns type information, never schema titles or ref names.\n *\n * Priority order:\n * 1. const values\n * 2. Array types (with special handling for items)\n * 3. type with contentEncoding\n * 4. raw type\n */\nexport const getSchemaType = (valueOrRef: SchemaObject | ReferenceType<SchemaObject>): string => {\n // Early return for falsy values\n if (!valueOrRef) {\n return ''\n }\n\n const value = resolve.schema(valueOrRef)\n\n // Handle const values first (highest priority)\n if (value.const !== undefined) {\n return 'const'\n }\n\n // Handle union types (array of types)\n if ('type' in value && Array.isArray(value.type)) {\n // Special case: union types containing 'array'\n if (value.type.includes('array') && 'items' in value && value.items) {\n const arrayType = processArrayType(value, true)\n const otherTypes = value.type.filter((t) => t !== 'array')\n\n return otherTypes.length > 0 ? `${arrayType} | ${otherTypes.join(' | ')}` : arrayType\n }\n\n // Regular union types\n return value.type.join(' | ')\n }\n\n // Handle single array type\n if (isArraySchema(value)) {\n return processArrayType(value, false)\n }\n\n // Handle type with content encoding\n if ('type' in value && value.type && value.contentEncoding) {\n return `${value.type} • ${value.contentEncoding}`\n }\n\n // Fallback to raw type\n return 'type' in value ? (value.type as string) : ''\n}\n"],"mappings":";;;AAOA,IAAMA,KAAmB,MAClBC,IAKE,SADiBA,EAAS,SAAS,KAAK,IAAI,IAAIA,EAAS,KAAKA,EACrC,MAJvB,SAULC,KACJ,GACA,IAAuB,OACZ;CACX,IAAI,CAACC,EAAM,OACT,OAAO;CAIT,IAAMC,IAAWJ,EADAK,EAAcC,EAAQ,OAAOH,EAAM,KAAK,CACxB,CAAQ;CAOzC,OALII,IACKH,IAIDD,EAAc,WAAW,GAAGC,EAAS,WAAWA;AAC1D,GAYaC,KAAiB,MAAmE;CAE/F,IAAI,CAACG,GACH,OAAO;CAGT,IAAML,IAAQG,EAAQ,OAAOE,CAAU;CAGvC,IAAIL,EAAM,UAAU,KAAA,GAClB,OAAO;CAIT,IAAI,UAAUA,KAAS,MAAM,QAAQA,EAAM,IAAI,GAAG;EAEhD,IAAIA,EAAM,KAAK,SAAS,OAAO,KAAK,WAAWA,KAASA,EAAM,OAAO;GACnE,IAAMM,IAAYP,EAAiBC,GAAO,EAAI,GACxCO,IAAaP,EAAM,KAAK,QAAQ,MAAMQ,MAAM,OAAO;GAEzD,OAAOD,EAAW,SAAS,IAAI,GAAGD,EAAU,KAAKC,EAAW,KAAK,KAAK,MAAMD;EAC9E;EAGA,OAAON,EAAM,KAAK,KAAK,KAAK;CAC9B;CAaA,OAVIS,EAAcT,CAAK,IACdD,EAAiBC,GAAO,EAAK,IAIlC,UAAUA,KAASA,EAAM,QAAQA,EAAM,kBAClC,GAAGA,EAAM,KAAK,KAAKA,EAAM,oBAI3B,UAAUA,IAASA,EAAM,OAAkB;AACpD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { inferDiscriminatorMappingComposition } from './get-compositions-to-render';
|
|
2
2
|
export { getRefName } from './get-ref-name';
|
|
3
|
+
export { type RenderedExample, getRenderedExample, normalizeRenderedExamples } from './get-rendered-example';
|
|
3
4
|
export { getSchemaType } from './get-schema-type';
|
|
4
5
|
export { getTypeSignatureTokens } from './get-type-signature-tokens';
|
|
5
6
|
export { hasComplexArrayItems } from './has-complex-array-items';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
1
|
+
import { getRenderedExample as e, normalizeRenderedExamples as t } from "./get-rendered-example.js";
|
|
2
|
+
import { getRefName as n } from "./get-ref-name.js";
|
|
3
|
+
import { hasComplexArrayItems as r } from "./has-complex-array-items.js";
|
|
4
|
+
import { inferDiscriminatorMappingComposition as i } from "./get-compositions-to-render.js";
|
|
5
|
+
import { isTypeObject as a } from "./is-type-object.js";
|
|
6
|
+
import { handleTreeKeydown as o } from "./schema-keyboard-nav.js";
|
|
7
|
+
import { getSchemaType as s } from "./get-schema-type.js";
|
|
8
|
+
import { getModelNameFromSchema as c, getModelNameWithArray as l } from "./schema-name.js";
|
|
9
|
+
import { reduceNamesToObject as u, sortPropertyNames as d } from "./sort-property-names.js";
|
|
10
|
+
import { getTypeSignatureTokens as f } from "./get-type-signature-tokens.js";
|
|
11
|
+
import { optimizeValueForDisplay as p } from "./optimize-value-for-display.js";
|
|
12
|
+
import { isModelLinkable as m } from "./is-model-linkable.js";
|
|
13
|
+
export { c as getModelNameFromSchema, l as getModelNameWithArray, n as getRefName, e as getRenderedExample, s as getSchemaType, f as getTypeSignatureTokens, o as handleTreeKeydown, r as hasComplexArrayItems, i as inferDiscriminatorMappingComposition, m as isModelLinkable, a as isTypeObject, t as normalizeRenderedExamples, p as optimizeValueForDisplay, u as reduceNamesToObject, d as sortPropertyNames };
|